OpenVDB  2.3.0
Composite.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2013 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30 //
36 
37 #ifndef OPENVDB_TOOLS_COMPOSITE_HAS_BEEN_INCLUDED
38 #define OPENVDB_TOOLS_COMPOSITE_HAS_BEEN_INCLUDED
39 
40 #include <openvdb/Platform.h>
41 #include <openvdb/Exceptions.h>
42 #include <openvdb/Types.h>
43 #include <openvdb/Grid.h>
44 #include <openvdb/math/Math.h> // for isExactlyEqual()
45 #include "ValueTransformer.h" // for transformValues()
46 #include <boost/utility/enable_if.hpp>
47 
48 
49 namespace openvdb {
51 namespace OPENVDB_VERSION_NAME {
52 namespace tools {
53 
57 template<typename GridOrTreeT> OPENVDB_STATIC_SPECIALIZATION
58 inline void csgUnion(GridOrTreeT& a, GridOrTreeT& b, bool prune = true);
62 template<typename GridOrTreeT> OPENVDB_STATIC_SPECIALIZATION
63 inline void csgIntersection(GridOrTreeT& a, GridOrTreeT& b, bool prune = true);
67 template<typename GridOrTreeT> OPENVDB_STATIC_SPECIALIZATION
68 inline void csgDifference(GridOrTreeT& a, GridOrTreeT& b, bool prune = true);
69 
72 template<typename GridOrTreeT> OPENVDB_STATIC_SPECIALIZATION
73 inline void compMax(GridOrTreeT& a, GridOrTreeT& b);
76 template<typename GridOrTreeT> OPENVDB_STATIC_SPECIALIZATION
77 inline void compMin(GridOrTreeT& a, GridOrTreeT& b);
80 template<typename GridOrTreeT> OPENVDB_STATIC_SPECIALIZATION
81 inline void compSum(GridOrTreeT& a, GridOrTreeT& b);
84 template<typename GridOrTreeT> OPENVDB_STATIC_SPECIALIZATION
85 inline void compMul(GridOrTreeT& a, GridOrTreeT& b);
88 template<typename GridOrTreeT> OPENVDB_STATIC_SPECIALIZATION
89 inline void compDiv(GridOrTreeT& a, GridOrTreeT& b);
90 
92 template<typename GridOrTreeT> OPENVDB_STATIC_SPECIALIZATION
93 inline void compReplace(GridOrTreeT& a, const GridOrTreeT& b);
94 
95 
97 
98 
99 namespace composite {
100 
101 // composite::min() and composite::max() for non-vector types compare with operator<().
102 template<typename T> inline
103 const typename boost::disable_if_c<VecTraits<T>::IsVec, T>::type& // = T if T is not a vector type
104 min(const T& a, const T& b) { return std::min(a, b); }
105 
106 template<typename T> inline
107 const typename boost::disable_if_c<VecTraits<T>::IsVec, T>::type&
108 max(const T& a, const T& b) { return std::max(a, b); }
109 
110 
111 // composite::min() and composite::max() for OpenVDB vector types compare by magnitude.
112 template<typename T> inline
113 const typename boost::enable_if_c<VecTraits<T>::IsVec, T>::type& // = T if T is a vector type
114 min(const T& a, const T& b)
115 {
116  const typename T::ValueType aMag = a.lengthSqr(), bMag = b.lengthSqr();
117  return (aMag < bMag ? a : (bMag < aMag ? b : std::min(a, b)));
118 }
119 
120 template<typename T> inline
121 const typename boost::enable_if_c<VecTraits<T>::IsVec, T>::type&
122 max(const T& a, const T& b)
123 {
124  const typename T::ValueType aMag = a.lengthSqr(), bMag = b.lengthSqr();
125  return (aMag < bMag ? b : (bMag < aMag ? a : std::max(a, b)));
126 }
127 
128 } // namespace composite
129 
130 
131 template<typename GridOrTreeT>
133 compMax(GridOrTreeT& aTree, GridOrTreeT& bTree)
134 {
135  typedef TreeAdapter<GridOrTreeT> Adapter;
136  typedef typename Adapter::TreeType TreeT;
137  typedef typename TreeT::ValueType ValueT;
138  struct Local {
139  static inline void op(CombineArgs<ValueT>& args) {
140  args.setResult(composite::max(args.a(), args.b()));
141  }
142  };
143  Adapter::tree(aTree).combineExtended(Adapter::tree(bTree), Local::op, /*prune=*/false);
144 }
145 
146 
147 template<typename GridOrTreeT>
149 compMin(GridOrTreeT& aTree, GridOrTreeT& bTree)
150 {
151  typedef TreeAdapter<GridOrTreeT> Adapter;
152  typedef typename Adapter::TreeType TreeT;
153  typedef typename TreeT::ValueType ValueT;
154  struct Local {
155  static inline void op(CombineArgs<ValueT>& args) {
156  args.setResult(composite::min(args.a(), args.b()));
157  }
158  };
159  Adapter::tree(aTree).combineExtended(Adapter::tree(bTree), Local::op, /*prune=*/false);
160 }
161 
162 
163 template<typename GridOrTreeT>
165 compSum(GridOrTreeT& aTree, GridOrTreeT& bTree)
166 {
167  typedef TreeAdapter<GridOrTreeT> Adapter;
168  typedef typename Adapter::TreeType TreeT;
169  struct Local {
170  static inline void op(CombineArgs<typename TreeT::ValueType>& args) {
171  args.setResult(args.a() + args.b());
172  }
173  };
174  Adapter::tree(aTree).combineExtended(Adapter::tree(bTree), Local::op, /*prune=*/false);
175 }
176 
177 
178 template<typename GridOrTreeT>
180 compMul(GridOrTreeT& aTree, GridOrTreeT& bTree)
181 {
182  typedef TreeAdapter<GridOrTreeT> Adapter;
183  typedef typename Adapter::TreeType TreeT;
184  struct Local {
185  static inline void op(CombineArgs<typename TreeT::ValueType>& args) {
186  args.setResult(args.a() * args.b());
187  }
188  };
189  Adapter::tree(aTree).combineExtended(Adapter::tree(bTree), Local::op, /*prune=*/false);
190 }
191 
192 
193 template<typename GridOrTreeT>
195 compDiv(GridOrTreeT& aTree, GridOrTreeT& bTree)
196 {
197  typedef TreeAdapter<GridOrTreeT> Adapter;
198  typedef typename Adapter::TreeType TreeT;
199  struct Local {
200  static inline void op(CombineArgs<typename TreeT::ValueType>& args) {
201  args.setResult(args.a() / args.b());
202  }
203  };
204  Adapter::tree(aTree).combineExtended(Adapter::tree(bTree), Local::op, /*prune=*/false);
205 }
206 
207 
209 
210 
211 template<typename TreeT>
213 {
214  TreeT* const aTree;
215 
216  CompReplaceOp(TreeT& _aTree): aTree(&_aTree) {}
217 
218  void operator()(const typename TreeT::ValueOnCIter& iter) const
219  {
220  CoordBBox bbox;
221  iter.getBoundingBox(bbox);
222  aTree->fill(bbox, *iter);
223  }
224 
225  void operator()(const typename TreeT::LeafCIter& leafIter) const
226  {
227  tree::ValueAccessor<TreeT> acc(*aTree);
228  for (typename TreeT::LeafCIter::LeafNodeT::ValueOnCIter iter =
229  leafIter->cbeginValueOn(); iter; ++iter)
230  {
231  acc.setValue(iter.getCoord(), *iter);
232  }
233  }
234 };
235 
236 
237 template<typename GridOrTreeT>
239 compReplace(GridOrTreeT& aTree, const GridOrTreeT& bTree)
240 {
241  typedef TreeAdapter<GridOrTreeT> Adapter;
242  typedef typename Adapter::TreeType TreeT;
243  typedef typename TreeT::ValueOnCIter ValueOnCIterT;
244 
245  // Copy active states (but not values) from B to A.
246  Adapter::tree(aTree).topologyUnion(Adapter::tree(bTree));
247 
248  CompReplaceOp<TreeT> op(Adapter::tree(aTree));
249 
250  // Copy all active tile values from B to A.
251  ValueOnCIterT iter = bTree.cbeginValueOn();
252  iter.setMaxDepth(iter.getLeafDepth() - 1); // don't descend into leaf nodes
253  foreach(iter, op);
254 
255  // Copy all active voxel values from B to A.
256  foreach(Adapter::tree(bTree).cbeginLeaf(), op);
257 }
258 
259 
261 
262 
265 template<typename TreeType>
267 {
268 public:
269  typedef TreeType TreeT;
270  typedef typename TreeT::ValueType ValueT;
271  typedef typename TreeT::LeafNodeType::ChildAllIter ChildIterT;
272 
273  enum { STOP = 3 };
274 
275  CsgVisitorBase(const TreeT& aTree, const TreeT& bTree):
276  mAOutside(aTree.background()),
277  mAInside(math::negative(mAOutside)),
278  mBOutside(bTree.background()),
279  mBInside(math::negative(mBOutside))
280  {
281  const ValueT zero = zeroVal<ValueT>();
282  if (!(mAOutside > zero)) {
284  "expected grid A outside value > 0, got " << mAOutside);
285  }
286  if (!(mAInside < zero)) {
288  "expected grid A inside value < 0, got " << mAInside);
289  }
290  if (!(mBOutside > zero)) {
292  "expected grid B outside value > 0, got " << mBOutside);
293  }
294  if (!(mBInside < zero)) {
296  "expected grid B outside value < 0, got " << mBOutside);
297  }
298  }
299 
300 protected:
301  ValueT mAOutside, mAInside, mBOutside, mBInside;
302 };
303 
304 
306 
307 
308 template<typename TreeType>
309 struct CsgUnionVisitor: public CsgVisitorBase<TreeType>
310 {
311  typedef TreeType TreeT;
312  typedef typename TreeT::ValueType ValueT;
313  typedef typename TreeT::LeafNodeType::ChildAllIter ChildIterT;
314 
316 
317  CsgUnionVisitor(const TreeT& a, const TreeT& b): CsgVisitorBase<TreeT>(a, b) {}
318 
320  template<typename AIterT, typename BIterT>
321  inline int operator()(AIterT&, BIterT&) { return 0; }
322 
324  template<typename IterT>
325  inline int operator()(IterT& aIter, IterT& bIter)
326  {
327  ValueT aValue = zeroVal<ValueT>();
328  typename IterT::ChildNodeType* aChild = aIter.probeChild(aValue);
329  if (!aChild && aValue < zeroVal<ValueT>()) {
330  // A is an inside tile. Leave it alone and stop traversing this branch.
331  return STOP;
332  }
333 
334  ValueT bValue = zeroVal<ValueT>();
335  typename IterT::ChildNodeType* bChild = bIter.probeChild(bValue);
336  if (!bChild && bValue < zeroVal<ValueT>()) {
337  // B is an inside tile. Make A an inside tile and stop traversing this branch.
338  aIter.setValue(this->mAInside);
339  aIter.setValueOn(bIter.isValueOn());
340  delete aChild;
341  return STOP;
342  }
343 
344  if (!aChild && aValue > zeroVal<ValueT>()) {
345  // A is an outside tile. If B has a child, transfer it to A,
346  // otherwise leave A alone.
347  if (bChild) {
348  bIter.setValue(this->mBOutside);
349  bIter.setValueOff();
350  bChild->resetBackground(this->mBOutside, this->mAOutside);
351  aIter.setChild(bChild); // transfer child
352  delete aChild;
353  }
354  return STOP;
355  }
356 
357  // If A has a child and B is an outside tile, stop traversing this branch.
358  // Continue traversal only if A and B both have children.
359  return (aChild && bChild) ? 0 : STOP;
360  }
361 
363  inline int operator()(ChildIterT& aIter, ChildIterT& bIter)
364  {
365  ValueT aValue, bValue;
366  aIter.probeValue(aValue);
367  bIter.probeValue(bValue);
368  if (aValue > bValue) { // a = min(a, b)
369  aIter.setValue(bValue);
370  aIter.setValueOn(bIter.isValueOn());
371  }
372  return 0;
373  }
374 };
375 
376 
377 
379 
380 
381 template<typename TreeType>
382 struct CsgIntersectVisitor: public CsgVisitorBase<TreeType>
383 {
384  typedef TreeType TreeT;
385  typedef typename TreeT::ValueType ValueT;
386  typedef typename TreeT::LeafNodeType::ChildAllIter ChildIterT;
387 
389 
390  CsgIntersectVisitor(const TreeT& a, const TreeT& b): CsgVisitorBase<TreeT>(a, b) {}
391 
393  template<typename AIterT, typename BIterT>
394  inline int operator()(AIterT&, BIterT&) { return 0; }
395 
397  template<typename IterT>
398  inline int operator()(IterT& aIter, IterT& bIter)
399  {
400  ValueT aValue = zeroVal<ValueT>();
401  typename IterT::ChildNodeType* aChild = aIter.probeChild(aValue);
402  if (!aChild && !(aValue < zeroVal<ValueT>())) {
403  // A is an outside tile. Leave it alone and stop traversing this branch.
404  return STOP;
405  }
406 
407  ValueT bValue = zeroVal<ValueT>();
408  typename IterT::ChildNodeType* bChild = bIter.probeChild(bValue);
409  if (!bChild && !(bValue < zeroVal<ValueT>())) {
410  // B is an outside tile. Make A an outside tile and stop traversing this branch.
411  aIter.setValue(this->mAOutside);
412  aIter.setValueOn(bIter.isValueOn());
413  delete aChild;
414  return STOP;
415  }
416 
417  if (!aChild && aValue < zeroVal<ValueT>()) {
418  // A is an inside tile. If B has a child, transfer it to A,
419  // otherwise leave A alone.
420  if (bChild) {
421  bIter.setValue(this->mBOutside);
422  bIter.setValueOff();
423  bChild->resetBackground(this->mBOutside, this->mAOutside);
424  aIter.setChild(bChild); // transfer child
425  delete aChild;
426  }
427  return STOP;
428  }
429 
430  // If A has a child and B is an outside tile, stop traversing this branch.
431  // Continue traversal only if A and B both have children.
432  return (aChild && bChild) ? 0 : STOP;
433  }
434 
436  inline int operator()(ChildIterT& aIter, ChildIterT& bIter)
437  {
438  ValueT aValue, bValue;
439  aIter.probeValue(aValue);
440  bIter.probeValue(bValue);
441  if (aValue < bValue) { // a = max(a, b)
442  aIter.setValue(bValue);
443  aIter.setValueOn(bIter.isValueOn());
444  }
445  return 0;
446  }
447 };
448 
449 
451 
452 
453 template<typename TreeType>
454 struct CsgDiffVisitor: public CsgVisitorBase<TreeType>
455 {
456  typedef TreeType TreeT;
457  typedef typename TreeT::ValueType ValueT;
458  typedef typename TreeT::LeafNodeType::ChildAllIter ChildIterT;
459 
461 
462  CsgDiffVisitor(const TreeT& a, const TreeT& b): CsgVisitorBase<TreeT>(a, b) {}
463 
465  template<typename AIterT, typename BIterT>
466  inline int operator()(AIterT&, BIterT&) { return 0; }
467 
469  template<typename IterT>
470  inline int operator()(IterT& aIter, IterT& bIter)
471  {
472  ValueT aValue = zeroVal<ValueT>();
473  typename IterT::ChildNodeType* aChild = aIter.probeChild(aValue);
474  if (!aChild && !(aValue < zeroVal<ValueT>())) {
475  // A is an outside tile. Leave it alone and stop traversing this branch.
476  return STOP;
477  }
478 
479  ValueT bValue = zeroVal<ValueT>();
480  typename IterT::ChildNodeType* bChild = bIter.probeChild(bValue);
481  if (!bChild && bValue < zeroVal<ValueT>()) {
482  // B is an inside tile. Make A an inside tile and stop traversing this branch.
483  aIter.setValue(this->mAOutside);
484  aIter.setValueOn(bIter.isValueOn());
485  delete aChild;
486  return STOP;
487  }
488 
489  if (!aChild && aValue < zeroVal<ValueT>()) {
490  // A is an inside tile. If B has a child, transfer it to A,
491  // otherwise leave A alone.
492  if (bChild) {
493  bIter.setValue(this->mBOutside);
494  bIter.setValueOff();
495  bChild->resetBackground(this->mBOutside, this->mAOutside);
496  aIter.setChild(bChild); // transfer child
497  bChild->negate();
498  delete aChild;
499  }
500  return STOP;
501  }
502 
503  // If A has a child and B is an outside tile, stop traversing this branch.
504  // Continue traversal only if A and B both have children.
505  return (aChild && bChild) ? 0 : STOP;
506  }
507 
509  inline int operator()(ChildIterT& aIter, ChildIterT& bIter)
510  {
511  ValueT aValue, bValue;
512  aIter.probeValue(aValue);
513  bIter.probeValue(bValue);
514  bValue = math::negative(bValue);
515  if (aValue < bValue) { // a = max(a, -b)
516  aIter.setValue(bValue);
517  aIter.setValueOn(bIter.isValueOn());
518  }
519  return 0;
520  }
521 };
522 
523 
525 
526 
527 template<typename GridOrTreeT>
529 csgUnion(GridOrTreeT& a, GridOrTreeT& b, bool prune)
530 {
531  typedef TreeAdapter<GridOrTreeT> Adapter;
532  typedef typename Adapter::TreeType TreeT;
533  TreeT &aTree = Adapter::tree(a), &bTree = Adapter::tree(b);
534  CsgUnionVisitor<TreeT> visitor(aTree, bTree);
535  aTree.visit2(bTree, visitor);
536  if (prune) aTree.pruneLevelSet();
537  //if (prune) aTree.prune();
538 }
539 
540 template<typename GridOrTreeT>
542 csgIntersection(GridOrTreeT& a, GridOrTreeT& b, bool prune)
543 {
544  typedef TreeAdapter<GridOrTreeT> Adapter;
545  typedef typename Adapter::TreeType TreeT;
546  TreeT &aTree = Adapter::tree(a), &bTree = Adapter::tree(b);
547  CsgIntersectVisitor<TreeT> visitor(aTree, bTree);
548  aTree.visit2(bTree, visitor);
549  if (prune) aTree.pruneLevelSet();
550  //if (prune) aTree.prune();
551 }
552 
553 template<typename GridOrTreeT>
555 csgDifference(GridOrTreeT& a, GridOrTreeT& b, bool prune)
556 {
557  typedef TreeAdapter<GridOrTreeT> Adapter;
558  typedef typename Adapter::TreeType TreeT;
559  TreeT &aTree = Adapter::tree(a), &bTree = Adapter::tree(b);
560  CsgDiffVisitor<TreeT> visitor(aTree, bTree);
561  aTree.visit2(bTree, visitor);
562  if (prune) aTree.pruneLevelSet();
563  //if (prune) aTree.prune();
564 }
565 
566 } // namespace tools
567 } // namespace OPENVDB_VERSION_NAME
568 } // namespace openvdb
569 
570 #endif // OPENVDB_TOOLS_COMPOSITE_HAS_BEEN_INCLUDED
571 
572 // Copyright (c) 2012-2013 DreamWorks Animation LLC
573 // All rights reserved. This software is distributed under the
574 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
TreeType TreeT
Definition: Composite.h:311
int operator()(AIterT &, BIterT &)
Don't process nodes that are at different tree levels.
Definition: Composite.h:466
TreeType TreeT
Definition: Composite.h:269
TreeType TreeT
Definition: Composite.h:456
void setValue(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
Definition: ValueAccessor.h:241
TreeType TreeT
Definition: Composite.h:384
const boost::enable_if_c< VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:114
CsgUnionVisitor(const TreeT &a, const TreeT &b)
Definition: Composite.h:317
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:97
TreeT::LeafNodeType::ChildAllIter ChildIterT
Definition: Composite.h:458
int operator()(ChildIterT &aIter, ChildIterT &bIter)
Process leaf node values.
Definition: Composite.h:363
CombineArgs & setResult(const AValueType &val)
Set the output value.
Definition: Types.h:300
OPENVDB_STATIC_SPECIALIZATION void compMin(GridOrTreeT &a, GridOrTreeT &b)
Given grids A and B, compute min(a, b) per voxel (using sparse traversal). Store the result in the A ...
Definition: Composite.h:149
void operator()(const typename TreeT::ValueOnCIter &iter) const
Definition: Composite.h:218
void operator()(const typename TreeT::LeafCIter &leafIter) const
Definition: Composite.h:225
CompReplaceOp(TreeT &_aTree)
Definition: Composite.h:216
TreeT::ValueType ValueT
Definition: Composite.h:385
Definition: Exceptions.h:88
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:837
int operator()(ChildIterT &aIter, ChildIterT &bIter)
Process leaf node values.
Definition: Composite.h:509
const boost::enable_if_c< VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:122
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:265
TreeT::LeafNodeType::ChildAllIter ChildIterT
Definition: Composite.h:313
OPENVDB_STATIC_SPECIALIZATION void csgUnion(GridOrTreeT &a, GridOrTreeT &b, bool prune=true)
Given two level set grids, replace the A grid with the union of A and B.
Definition: Composite.h:529
#define OPENVDB_VERSION_NAME
Definition: version.h:45
OPENVDB_STATIC_SPECIALIZATION void csgDifference(GridOrTreeT &a, GridOrTreeT &b, bool prune=true)
Given two level set grids, replace the A grid with the difference A / B.
Definition: Composite.h:555
OPENVDB_STATIC_SPECIALIZATION void csgIntersection(GridOrTreeT &a, GridOrTreeT &b, bool prune=true)
Given two level set grids, replace the A grid with the intersection of A and B.
Definition: Composite.h:542
Definition: Composite.h:309
int operator()(IterT &aIter, IterT &bIter)
Process root and internal nodes.
Definition: Composite.h:325
OPENVDB_STATIC_SPECIALIZATION void compMax(GridOrTreeT &a, GridOrTreeT &b)
Given grids A and B, compute max(a, b) per voxel (using sparse traversal). Store the result in the A ...
Definition: Composite.h:133
Definition: Composite.h:266
int operator()(IterT &aIter, IterT &bIter)
Process root and internal nodes.
Definition: Composite.h:398
Definition: Composite.h:454
const AValueType & a() const
Get the A input value.
Definition: Types.h:290
CsgIntersectVisitor(const TreeT &a, const TreeT &b)
Definition: Composite.h:390
OPENVDB_STATIC_SPECIALIZATION void compMul(GridOrTreeT &a, GridOrTreeT &b)
Given grids A and B, compute a * b per voxel (using sparse traversal). Store the result in the A grid...
Definition: Composite.h:180
const BValueType & b() const
Get the B input value.
Definition: Types.h:292
TreeT *const aTree
Definition: Composite.h:214
Definition: Composite.h:212
int operator()(ChildIterT &aIter, ChildIterT &bIter)
Process leaf node values.
Definition: Composite.h:436
#define OPENVDB_STATIC_SPECIALIZATION
Macro for determining if there are sufficient C++0x/C++11 features.
Definition: Platform.h:89
ValueT mBOutside
Definition: Composite.h:301
TreeT::ValueType ValueT
Definition: Composite.h:270
CsgDiffVisitor(const TreeT &a, const TreeT &b)
Definition: Composite.h:462
int operator()(AIterT &, BIterT &)
Don't process nodes that are at different tree levels.
Definition: Composite.h:394
TreeT::ValueType ValueT
Definition: Composite.h:457
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:107
OPENVDB_STATIC_SPECIALIZATION void compDiv(GridOrTreeT &a, GridOrTreeT &b)
Given grids A and B, compute a / b per voxel (using sparse traversal). Store the result in the A grid...
Definition: Composite.h:195
TreeT::LeafNodeType::ChildAllIter ChildIterT
Definition: Composite.h:386
TreeT::ValueType ValueT
Definition: Composite.h:312
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:67
OPENVDB_STATIC_SPECIALIZATION void compReplace(GridOrTreeT &a, const GridOrTreeT &b)
Copy the active voxels of B into A.
Definition: Composite.h:239
OPENVDB_STATIC_SPECIALIZATION void compSum(GridOrTreeT &a, GridOrTreeT &b)
Given grids A and B, compute a + b per voxel (using sparse traversal). Store the result in the A grid...
Definition: Composite.h:165
TreeT::LeafNodeType::ChildAllIter ChildIterT
Definition: Composite.h:271
CsgVisitorBase(const TreeT &aTree, const TreeT &bTree)
Definition: Composite.h:275
int operator()(IterT &aIter, IterT &bIter)
Process root and internal nodes.
Definition: Composite.h:470
int operator()(AIterT &, BIterT &)
Don't process nodes that are at different tree levels.
Definition: Composite.h:321