@@ -37,7 +37,7 @@ namespace points {
3737template <typename PointDataGridT>
3838inline typename PointDataGridT::Ptr
3939replicate (const PointDataGridT& source,
40- const size_t multiplier,
40+ const Index multiplier,
4141 const std::vector<std::string>& attributes,
4242 const std::string& scaleAttribute = " " ,
4343 const std::string& replicationIndex = " " );
@@ -58,7 +58,7 @@ replicate(const PointDataGridT& source,
5858template <typename PointDataGridT>
5959inline typename PointDataGridT::Ptr
6060replicate (const PointDataGridT& source,
61- const size_t multiplier,
61+ const Index multiplier,
6262 const std::string& scaleAttribute = " " ,
6363 const std::string& replicationIndex = " " );
6464
@@ -69,7 +69,7 @@ replicate(const PointDataGridT& source,
6969template <typename PointDataGridT>
7070inline typename PointDataGridT::Ptr
7171replicate (const PointDataGridT& source,
72- const size_t multiplier,
72+ const Index multiplier,
7373 const std::vector<std::string>& attributes,
7474 const std::string& scaleAttribute,
7575 const std::string& replicationIndex)
@@ -78,7 +78,15 @@ replicate(const PointDataGridT& source,
7878 // to the target (replicated grid).
7979 struct CopyIter
8080 {
81+ #ifdef __clang__
82+ // Silence incorrect clang warning
83+ _Pragma (" clang diagnostic push" )
84+ _Pragma(" clang diagnostic ignored \" -Wunused-local-typedef\" " )
8185 using GetIncrementCB = std::function<Index(const Index)>;
86+ _Pragma (" clang diagnostic pop" )
87+ #else
88+ using GetIncrementCB = std::function<Index(const Index)>;
89+ #endif
8290
8391 CopyIter (const Index end, const GetIncrementCB& cb)
8492 : mIt (0 ), mEnd (0 ), mSource (0 ), mSourceEnd (end), mCallback (cb) {
@@ -174,8 +182,12 @@ replicate(const PointDataGridT& source,
174182 using ValueType = PointDataTree::ValueType;
175183
176184 const auto & sourceLeaf = sourceManager.leaf (pos);
177- const openvdb::Index64 sourceCount = sourceLeaf.pointCount ();
178- size_t uniformMultiplier = multiplier;
185+ // @note This really shoudn't return uint64_t as AttributeArray's size is
186+ // limited to the max of a uint32_t...
187+ assert (sourceLeaf.pointCount () < Index64 (std::numeric_limits<Index>::max ()));
188+ const Index sourceCount = static_cast <Index>(sourceLeaf.pointCount ());
189+
190+ Index uniformMultiplier = multiplier;
179191 AttributeHandle<float >::UniquePtr scaleHandle (nullptr );
180192 bool useScale = scaleIdx != AttributeSet::INVALID_POS;
181193 if (useScale) {
@@ -185,9 +197,9 @@ replicate(const PointDataGridT& source,
185197 // small lambda that returns the amount of points to generate
186198 // based on a scale. Should only be called if useScale is true,
187199 // otherwise the scaleHandle will be reset or null
188- auto getPointsToGenerate = [&](const size_t index) -> size_t {
200+ auto getPointsToGenerate = [&](const Index index) -> Index {
189201 const float scale = std::max (0 .0f , scaleHandle->get (index));
190- return static_cast <size_t >
202+ return static_cast <Index >
191203 (math::Round (static_cast <float >(multiplier) * scale));
192204 };
193205
@@ -203,7 +215,7 @@ replicate(const PointDataGridT& source,
203215 // don't have to cache the offset vector. Note that the leaf offsets become
204216 // invalid until leaf.replaceAttributeSet is called and should not be used
205217
206- openvdb::Index64 total = 0 ;
218+ Index total = 0 ;
207219
208220 if (useScale) {
209221 for (auto iter = sourceLeaf.cbeginValueAll (); iter; ++iter) {
@@ -268,17 +280,17 @@ replicate(const PointDataGridT& source,
268280 assert (idxHandle.size () == total);
269281
270282 if (useScale) {
271- size_t offset = 0 ;
272- for (size_t i = 0 ; i < sourceCount; ++i) {
273- const size_t pointRepCount = getPointsToGenerate (i);
274- for (size_t j = 0 ; j < pointRepCount; ++j, ++offset) {
283+ Index offset = 0 ;
284+ for (Index i = 0 ; i < sourceCount; ++i) {
285+ const Index pointRepCount = getPointsToGenerate (i);
286+ for (Index j = 0 ; j < pointRepCount; ++j, ++offset) {
275287 idxHandle.set (offset, j);
276288 }
277289 }
278290 }
279291 else {
280- for (size_t i = 0 ; i < total;) {
281- for (size_t j = 0 ; j < uniformMultiplier; ++j, ++i) {
292+ for (Index i = 0 ; i < total;) {
293+ for (Index j = 0 ; j < uniformMultiplier; ++j, ++i) {
282294 idxHandle.set (i, j);
283295 }
284296 }
@@ -298,7 +310,7 @@ replicate(const PointDataGridT& source,
298310template <typename PointDataGridT>
299311inline typename PointDataGridT::Ptr
300312replicate (const PointDataGridT& source,
301- const size_t multiplier,
313+ const Index multiplier,
302314 const std::string& scaleAttribute,
303315 const std::string& replicationIndex)
304316{
0 commit comments