From d9f83ea2714c51d93439a2a68062509d08e423a6 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Mon, 20 Mar 2023 12:38:07 +0000 Subject: [PATCH 1/3] PrimitiveBinding : Remove unused assignments Switching the `boost::optional` to a `std::optional` would make these into a compilation error. --- src/IECoreScene/bindings/PrimitiveBinding.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/IECoreScene/bindings/PrimitiveBinding.cpp b/src/IECoreScene/bindings/PrimitiveBinding.cpp index 3012cc53f4..a60f76bed3 100644 --- a/src/IECoreScene/bindings/PrimitiveBinding.cpp +++ b/src/IECoreScene/bindings/PrimitiveBinding.cpp @@ -123,7 +123,7 @@ void testVariableIndexedView() bool exceptionRaised = false; try { - boost::optional> optionalIndexedView = primitive->variableIndexedView( + primitive->variableIndexedView( "MISSING", IECoreScene::PrimitiveVariable::Interpolation::Vertex, true /* throwIfInvalid */ ); } @@ -149,7 +149,7 @@ void testVariableIndexedView() bool exceptionRaised = false; try { - boost::optional> optionalIndexedView = primitive->variableIndexedView( + primitive->variableIndexedView( "P", IECoreScene::PrimitiveVariable::Interpolation::FaceVarying, true /* throwIfInvalid */ ); } @@ -178,7 +178,7 @@ void testVariableIndexedView() bool exceptionRaised = false; try { - boost::optional> optionalIndexedView = primitive->variableIndexedView( + primitive->variableIndexedView( "P", IECoreScene::PrimitiveVariable::Interpolation::Vertex, true /* throwIfInvalid */ ); } From 702fb14feaed1dfe244391d80c7d439b357c8988 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Mon, 20 Mar 2023 12:42:20 +0000 Subject: [PATCH 2/3] MeshAlgo : Remove leading whitespace --- src/IECoreScene/MeshAlgoDistributePoints.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IECoreScene/MeshAlgoDistributePoints.cpp b/src/IECoreScene/MeshAlgoDistributePoints.cpp index 65a13a916d..7a7ac84b30 100644 --- a/src/IECoreScene/MeshAlgoDistributePoints.cpp +++ b/src/IECoreScene/MeshAlgoDistributePoints.cpp @@ -160,7 +160,7 @@ struct Generator size_t v2I = v1I + 1; Imath::V2f uv0, uv1, uv2; - + if( m_faceVaryingUVs ) { uv0 = m_uvs[v0I]; From 6b7d7837ae0440e33a16413b6899f950db9242fd Mon Sep 17 00:00:00 2001 From: John Haddon Date: Mon, 20 Mar 2023 12:40:16 +0000 Subject: [PATCH 3/3] Replace `boost::optional` with `std::optional` --- Changes | 8 ++++++++ include/IECore/StreamIndexedIO.h | 1 - include/IECoreScene/Primitive.h | 4 ++-- include/IECoreScene/Primitive.inl | 8 ++++---- src/IECore/StreamIndexedIO.cpp | 12 ++++++------ src/IECoreScene/MeshAlgoDistributePoints.cpp | 2 +- src/IECoreScene/MeshAlgoFaceArea.cpp | 2 +- src/IECoreScene/bindings/PrimitiveBinding.cpp | 10 +++++----- 8 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Changes b/Changes index 7de921ec59..caba2565e1 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,11 @@ +10.x.x.x (relative to 10.4.x.x) +======== + +Breaking Changes +---------------- + +- Primitive : Changed `variableIndexedView()` return type from `boost::optional` to `std::optional`. + 10.4.6.0 (relative to 10.4.5.0) ======== diff --git a/include/IECore/StreamIndexedIO.h b/include/IECore/StreamIndexedIO.h index 9ebc11956f..916bc8bf6e 100644 --- a/include/IECore/StreamIndexedIO.h +++ b/include/IECore/StreamIndexedIO.h @@ -41,7 +41,6 @@ #include "IECore/VectorTypedData.h" #include "boost/iostreams/filtering_stream.hpp" -#include "boost/optional.hpp" #include #include diff --git a/include/IECoreScene/Primitive.h b/include/IECoreScene/Primitive.h index 0152770cc2..e73dac3fe3 100644 --- a/include/IECoreScene/Primitive.h +++ b/include/IECoreScene/Primitive.h @@ -42,7 +42,7 @@ #include "IECore/Canceller.h" #include "IECore/MessageHandler.h" -#include "boost/optional.hpp" +#include namespace IECoreScene { @@ -73,7 +73,7 @@ class IECORESCENE_API Primitive : public VisibleRenderable /// If the required interpolation & datatype do not match then an empty optional is returned unless throwIfInvalid is true. /// The returned IndexedView lifetime must be bound by the primitive variable data it is viewing. template - boost::optional> variableIndexedView( + std::optional> variableIndexedView( const std::string &name, PrimitiveVariable::Interpolation requiredInterpolation = PrimitiveVariable::Invalid, bool throwIfInvalid = false diff --git a/include/IECoreScene/Primitive.inl b/include/IECoreScene/Primitive.inl index b3a23e53f0..5ba7948fce 100644 --- a/include/IECoreScene/Primitive.inl +++ b/include/IECoreScene/Primitive.inl @@ -38,7 +38,7 @@ namespace IECoreScene { -template boost::optional > +template std::optional> Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Interpolation requiredInterpolation, bool throwIfInvalid ) const { PrimitiveVariableMap::const_iterator it = variables.find( name ); @@ -50,7 +50,7 @@ Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Inte } else { - return boost::none; + return std::nullopt; } } @@ -68,7 +68,7 @@ Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Inte } else { - return boost::none; + return std::nullopt; } } @@ -93,7 +93,7 @@ Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Inte } else { - return boost::none; + return std::nullopt; } } diff --git a/src/IECore/StreamIndexedIO.cpp b/src/IECore/StreamIndexedIO.cpp index eb8da165b8..27f611e1b9 100644 --- a/src/IECore/StreamIndexedIO.cpp +++ b/src/IECore/StreamIndexedIO.cpp @@ -53,7 +53,6 @@ #include "boost/iostreams/filtering_stream.hpp" #include "boost/iostreams/filtering_streambuf.hpp" #include "boost/iostreams/stream.hpp" -#include "boost/optional.hpp" #include "boost/tokenizer.hpp" #include @@ -61,6 +60,7 @@ #include #include #include +#include #include #include @@ -415,11 +415,11 @@ size_t compress( int compressionLevel, const std::string &compressor, int threadCount, - boost::optional maxBlockSize = boost::optional(), + std::optional maxBlockSize = std::optional(), size_t minCompressedBlockSize = 1024U ) { - size_t maxCompressedBlockSize = maxBlockSize ? maxBlockSize.get() : BLOSC_MAX_BUFFERSIZE; + const size_t maxCompressedBlockSize = maxBlockSize.value_or( BLOSC_MAX_BUFFERSIZE ); if( size < minCompressedBlockSize ) { @@ -765,7 +765,7 @@ class DirectoryNode : public NodeBase typedef std::vector< NodeBase* > ChildMap; // regular constructor - DirectoryNode(IndexedIO::EntryID name, boost::optional numChildren = boost::optional()) : NodeBase( NodeBase::Directory, name ), + DirectoryNode(IndexedIO::EntryID name, std::optional numChildren = std::optional()) : NodeBase( NodeBase::Directory, name ), m_subindex( NoSubIndex ), m_sortedChildren( false ), m_subindexChildren( false ), @@ -774,7 +774,7 @@ class DirectoryNode : public NodeBase { if ( numChildren ) { - m_children.reserve( numChildren.get() ); + m_children.reserve( *numChildren ); } } @@ -1124,7 +1124,7 @@ class StreamIndexedIO::Index : public RefCounted int m_compressionLevel; int m_compressionThreadCount; int m_decompressionThreadCount; - boost::optional m_maxCompressedBlockSize; + std::optional m_maxCompressedBlockSize; std::string m_compressor; struct FreePage diff --git a/src/IECoreScene/MeshAlgoDistributePoints.cpp b/src/IECoreScene/MeshAlgoDistributePoints.cpp index 7a7ac84b30..d96a31178a 100644 --- a/src/IECoreScene/MeshAlgoDistributePoints.cpp +++ b/src/IECoreScene/MeshAlgoDistributePoints.cpp @@ -232,7 +232,7 @@ PointsPrimitivePtr MeshAlgo::distributePoints( const MeshPrimitive *mesh, float MeshPrimitiveEvaluatorPtr meshEvaluator = new MeshPrimitiveEvaluator( updatedMesh ); bool faceVaryingUVs = true; - boost::optional > uvView = updatedMesh->variableIndexedView( uvSet, PrimitiveVariable::FaceVarying, /* throwOnInvalid */ false ); + std::optional> uvView = updatedMesh->variableIndexedView( uvSet, PrimitiveVariable::FaceVarying, /* throwOnInvalid */ false ); if( !uvView ) { faceVaryingUVs = false; diff --git a/src/IECoreScene/MeshAlgoFaceArea.cpp b/src/IECoreScene/MeshAlgoFaceArea.cpp index 484e2b8021..3c6ffc9a96 100644 --- a/src/IECoreScene/MeshAlgoFaceArea.cpp +++ b/src/IECoreScene/MeshAlgoFaceArea.cpp @@ -97,7 +97,7 @@ PrimitiveVariable MeshAlgo::calculateFaceArea( const MeshPrimitive *mesh, const PrimitiveVariable MeshAlgo::calculateFaceTextureArea( const MeshPrimitive *mesh, const std::string &uvSet, const std::string &position, const Canceller *canceller ) { PrimitiveVariable::Interpolation uvInterpolation = PrimitiveVariable::Vertex; - boost::optional > uvView = mesh->variableIndexedView( uvSet, PrimitiveVariable::Vertex, false ); + std::optional> uvView = mesh->variableIndexedView( uvSet, PrimitiveVariable::Vertex, false ); if( !uvView ) { uvView = mesh->variableIndexedView( uvSet, PrimitiveVariable::FaceVarying, false ); diff --git a/src/IECoreScene/bindings/PrimitiveBinding.cpp b/src/IECoreScene/bindings/PrimitiveBinding.cpp index a60f76bed3..b2ed85a8f6 100644 --- a/src/IECoreScene/bindings/PrimitiveBinding.cpp +++ b/src/IECoreScene/bindings/PrimitiveBinding.cpp @@ -74,7 +74,7 @@ void testVariableIndexedView() // check we get an view if type & interpolation are compatible { - boost::optional> optionalIndexedView = primitive->variableIndexedView( + std::optional> optionalIndexedView = primitive->variableIndexedView( "P", IECoreScene::PrimitiveVariable::Interpolation::Vertex ); @@ -92,7 +92,7 @@ void testVariableIndexedView() } // If requiredInterpolation = Invalid matches any interpolation - boost::optional> optionalIndexedView2 = primitive->variableIndexedView( + std::optional> optionalIndexedView2 = primitive->variableIndexedView( "P", IECoreScene::PrimitiveVariable::Interpolation::Invalid ); @@ -113,7 +113,7 @@ void testVariableIndexedView() // missing primvar { { - boost::optional> optionalIndexedView = primitive->variableIndexedView( + std::optional> optionalIndexedView = primitive->variableIndexedView( "MISSING", IECoreScene::PrimitiveVariable::Interpolation::Vertex ); @@ -139,7 +139,7 @@ void testVariableIndexedView() // invalid interpolation { { - boost::optional> optionalIndexedView = primitive->variableIndexedView( + std::optional> optionalIndexedView = primitive->variableIndexedView( "P", IECoreScene::PrimitiveVariable::Interpolation::FaceVarying ); @@ -168,7 +168,7 @@ void testVariableIndexedView() // invalid type { { - boost::optional> optionalIndexedView = primitive->variableIndexedView( + std::optional> optionalIndexedView = primitive->variableIndexedView( "P", IECoreScene::PrimitiveVariable::Interpolation::Vertex );