Skip to content

Commit 98176b8

Browse files
committed
Fixed C++20 support for OpenVDB
Signed-off-by: maletsden <maletsden@gmail.com>
1 parent 7f88880 commit 98176b8

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

openvdb/openvdb/points/AttributeSet.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ AttributeSet::isShared(size_t pos) const
280280
{
281281
assert(pos != INVALID_POS);
282282
assert(pos < mAttrs.size());
283-
return !mAttrs[pos].unique();
283+
// Warning: In multithreaded environment, the value returned by use_count is approximate.
284+
return mAttrs[pos].use_count() != 1;
284285
}
285286

286287

@@ -289,7 +290,8 @@ AttributeSet::makeUnique(size_t pos)
289290
{
290291
assert(pos != INVALID_POS);
291292
assert(pos < mAttrs.size());
292-
if (!mAttrs[pos].unique()) {
293+
// Warning: In multithreaded environment, the value returned by use_count is approximate.
294+
if (mAttrs[pos].use_count() != 1) {
293295
mAttrs[pos] = mAttrs[pos]->copy();
294296
}
295297
}

openvdb/openvdb/tools/Diagnostics.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ class InactiveTileValues
12091209
void getInactiveValues(SetType&) const;
12101210

12111211
inline InactiveTileValues(const InactiveTileValues<TreeType>&, tbb::split);
1212-
inline void operator()(IterRange&);
1212+
inline void operator()(const IterRange&);
12131213
inline void join(const InactiveTileValues<TreeType>&);
12141214

12151215
private:
@@ -1252,10 +1252,10 @@ InactiveTileValues<TreeType>::runSerial(IterRange& range)
12521252

12531253
template<typename TreeType>
12541254
inline void
1255-
InactiveTileValues<TreeType>::operator()(IterRange& range)
1255+
InactiveTileValues<TreeType>::operator()(const IterRange& range)
12561256
{
1257-
for (; range && !thread::isGroupExecutionCancelled(); ++range) {
1258-
typename TreeType::ValueOffCIter iter = range.iterator();
1257+
for (IterRange it(range); it.test() && !thread::isGroupExecutionCancelled(); ++it) {
1258+
typename TreeType::ValueOffCIter iter = it.iterator();
12591259
for (; iter; ++iter) {
12601260
mInactiveValues.insert(iter.getValue());
12611261
}

openvdb/openvdb/tools/GridTransformer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -799,11 +799,11 @@ class GridResampler::RangeProcessor
799799
void setInterrupt(const InterruptFunc& f) { mInterrupt = f; }
800800

801801
/// Transform each leaf node in the given range.
802-
void operator()(LeafRange& r)
802+
void operator()(const LeafRange& r)
803803
{
804-
for ( ; r; ++r) {
804+
for (LeafRange it(r); it.test(); ++it) {
805805
if (interrupt()) break;
806-
LeafIterT i = r.iterator();
806+
LeafIterT i = it.iterator();
807807
CoordBBox bbox(i->origin(), i->origin() + Coord(i->dim()));
808808
if (!mBBox.empty()) {
809809
// Intersect the leaf node's bounding box with mBBox.
@@ -818,12 +818,12 @@ class GridResampler::RangeProcessor
818818
}
819819

820820
/// Transform each non-background tile in the given range.
821-
void operator()(TileRange& r)
821+
void operator()(const TileRange& r)
822822
{
823-
for ( ; r; ++r) {
823+
for (TileRange it(r); it.test(); ++it) {
824824
if (interrupt()) break;
825825

826-
TileIterT i = r.iterator();
826+
TileIterT i = it.iterator();
827827
// Skip voxels and background tiles.
828828
if (!i.isTileValue()) continue;
829829
if (!i.isValueOn() && math::isApproxEqual(*i, mOutTree->background())) continue;

openvdb/openvdb/tools/LevelSetSphere.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class LevelSetSphere
189189
Op(TreeT &tree) : mDelete(false), mTree(&tree) {}
190190
Op(const Op& other, tbb::split) : mDelete(true), mTree(new TreeT(other.mTree->background())) {}
191191
~Op() { if (mDelete) delete mTree; }
192-
void operator()(RangeT &r) { for (auto i=r.begin(); i!=r.end(); ++i) this->merge(*i);}
192+
void operator()(const RangeT &r) { for (auto i=r.begin(); i!=r.end(); ++i) this->merge(*i);}
193193
void join(Op &other) { this->merge(*(other.mTree)); }
194194
void merge(TreeT &tree) { mTree->merge(tree, openvdb::MERGE_ACTIVE_STATES); }
195195
} op( mGrid->tree() );

openvdb/openvdb/tools/ValueTransformer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ class OpAccumulator
657657
}
658658
}
659659

660-
void operator()(IterRange& r) { for ( ; r; ++r) (*mOp)(r.iterator()); }
660+
void operator()(const IterRange& r) { for (IterRange it(r); it.test(); ++it) (*mOp)(it.iterator()); }
661661

662662
void join(OpAccumulator& other) { mOp->join(*other.mOp); }
663663

0 commit comments

Comments
 (0)