OpenVDB: GridOperators.h Source File

OpenVDB 7.1.0

GridOperators.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
8
9 #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
10 #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
11
12 #include <openvdb/Grid.h>
13 #include <openvdb/math/Operators.h>
14 #include <openvdb/util/NullInterrupter.h>
15 #include <openvdb/tree/LeafManager.h>
16 #include <openvdb/tree/ValueAccessor.h>
17 #include "ValueTransformer.h" // for tools::foreach()
18 #include <tbb/parallel_for.h>
19
20
21 namespace openvdb {
22 OPENVDB_USE_VERSION_NAMESPACE
23 namespace OPENVDB_VERSION_NAME {
24 namespace tools {
25
30 template<typename VectorGridType> struct VectorToScalarConverter {
31 typedef typename VectorGridType::ValueType::value_type VecComponentValueT;
32 typedef typename VectorGridType::template ValueConverter<VecComponentValueT>::Type Type;
33 };
34
39 template<typename ScalarGridType> struct ScalarToVectorConverter {
40 typedef math::Vec3<typename ScalarGridType::ValueType> VectorValueT;
41 typedef typename ScalarGridType::template ValueConverter<VectorValueT>::Type Type;
42 };
43
44
51 template<typename GridType, typename InterruptT> inline
52 typename ScalarToVectorConverter<GridType>::Type::Ptr
53 cpt(const GridType& grid, bool threaded, InterruptT* interrupt);
54
55 template<typename GridType, typename MaskT, typename InterruptT> inline
56 typename ScalarToVectorConverter<GridType>::Type::Ptr
57 cpt(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
58
59 template<typename GridType> inline
60 typename ScalarToVectorConverter<GridType>::Type::Ptr
61 cpt(const GridType& grid, bool threaded = true)
62 {
63 return cpt<GridType, util::NullInterrupter>(grid, threaded, nullptr);
64 }
65
66 template<typename GridType, typename MaskT> inline
67 typename ScalarToVectorConverter<GridType>::Type::Ptr
68 cpt(const GridType& grid, const MaskT& mask, bool threaded = true)
69 {
70 return cpt<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
71 }
72
73
79 template<typename GridType, typename InterruptT> inline
80 typename GridType::Ptr
81 curl(const GridType& grid, bool threaded, InterruptT* interrupt);
82
83 template<typename GridType, typename MaskT, typename InterruptT> inline
84 typename GridType::Ptr
85 curl(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
86
87 template<typename GridType> inline
88 typename GridType::Ptr
89 curl(const GridType& grid, bool threaded = true)
90 {
91 return curl<GridType, util::NullInterrupter>(grid, threaded, nullptr);
92 }
93
94 template<typename GridType, typename MaskT> inline
95 typename GridType::Ptr
96 curl(const GridType& grid, const MaskT& mask, bool threaded = true)
97 {
98 return curl<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
99 }
100
101
108 template<typename GridType, typename InterruptT> inline
109 typename VectorToScalarConverter<GridType>::Type::Ptr
110 divergence(const GridType& grid, bool threaded, InterruptT* interrupt);
111
112 template<typename GridType, typename MaskT, typename InterruptT> inline
113 typename VectorToScalarConverter<GridType>::Type::Ptr
114 divergence(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
115
116 template<typename GridType> inline
117 typename VectorToScalarConverter<GridType>::Type::Ptr
118 divergence(const GridType& grid, bool threaded = true)
119 {
120 return divergence<GridType, util::NullInterrupter>(grid, threaded, nullptr);
121 }
122
123 template<typename GridType, typename MaskT> inline
124 typename VectorToScalarConverter<GridType>::Type::Ptr
125 divergence(const GridType& grid, const MaskT& mask, bool threaded = true)
126 {
127 return divergence<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
128 }
129
130
137 template<typename GridType, typename InterruptT> inline
138 typename ScalarToVectorConverter<GridType>::Type::Ptr
139 gradient(const GridType& grid, bool threaded, InterruptT* interrupt);
140
141 template<typename GridType, typename MaskT, typename InterruptT> inline
142 typename ScalarToVectorConverter<GridType>::Type::Ptr
143 gradient(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
144
145 template<typename GridType> inline
146 typename ScalarToVectorConverter<GridType>::Type::Ptr
147 gradient(const GridType& grid, bool threaded = true)
148 {
149 return gradient<GridType, util::NullInterrupter>(grid, threaded, nullptr);
150 }
151
152 template<typename GridType, typename MaskT> inline
153 typename ScalarToVectorConverter<GridType>::Type::Ptr
154 gradient(const GridType& grid, const MaskT& mask, bool threaded = true)
155 {
156 return gradient<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
157 }
158
159
165 template<typename GridType, typename InterruptT> inline
166 typename GridType::Ptr
167 laplacian(const GridType& grid, bool threaded, InterruptT* interrupt);
168
169 template<typename GridType, typename MaskT, typename InterruptT> inline
170 typename GridType::Ptr
171 laplacian(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
172
173 template<typename GridType> inline
174 typename GridType::Ptr
175 laplacian(const GridType& grid, bool threaded = true)
176 {
177 return laplacian<GridType, util::NullInterrupter>(grid, threaded, nullptr);
178 }
179
180 template<typename GridType, typename MaskT> inline
181 typename GridType::Ptr
182 laplacian(const GridType& grid, const MaskT mask, bool threaded = true)
183 {
184 return laplacian<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
185 }
186
187
193 template<typename GridType, typename InterruptT> inline
194 typename GridType::Ptr
195 meanCurvature(const GridType& grid, bool threaded, InterruptT* interrupt);
196
197 template<typename GridType, typename MaskT, typename InterruptT> inline
198 typename GridType::Ptr
199 meanCurvature(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
200
201 template<typename GridType> inline
202 typename GridType::Ptr
203 meanCurvature(const GridType& grid, bool threaded = true)
204 {
205 return meanCurvature<GridType, util::NullInterrupter>(grid, threaded, nullptr);
206 }
207
208 template<typename GridType, typename MaskT> inline
209 typename GridType::Ptr
210 meanCurvature(const GridType& grid, const MaskT& mask, bool threaded = true)
211 {
212 return meanCurvature<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
213 }
214
215
222 template<typename GridType, typename InterruptT> inline
223 typename VectorToScalarConverter<GridType>::Type::Ptr
224 magnitude(const GridType& grid, bool threaded, InterruptT* interrupt);
225
226 template<typename GridType, typename MaskT, typename InterruptT> inline
227 typename VectorToScalarConverter<GridType>::Type::Ptr
228 magnitude(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
229
230 template<typename GridType> inline
231 typename VectorToScalarConverter<GridType>::Type::Ptr
232 magnitude(const GridType& grid, bool threaded = true)
233 {
234 return magnitude<GridType, util::NullInterrupter>(grid, threaded, nullptr);
235 }
236
237 template<typename GridType, typename MaskT> inline
238 typename VectorToScalarConverter<GridType>::Type::Ptr
239 magnitude(const GridType& grid, const MaskT& mask, bool threaded = true)
240 {
241 return magnitude<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
242 }
243
244
250 template<typename GridType, typename InterruptT> inline
251 typename GridType::Ptr
252 normalize(const GridType& grid, bool threaded, InterruptT* interrupt);
253
254 template<typename GridType, typename MaskT, typename InterruptT> inline
255 typename GridType::Ptr
256 normalize(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
257
258 template<typename GridType> inline
259 typename GridType::Ptr
260 normalize(const GridType& grid, bool threaded = true)
261 {
262 return normalize<GridType, util::NullInterrupter>(grid, threaded, nullptr);
263 }
264
265 template<typename GridType, typename MaskT> inline
266 typename GridType::Ptr
267 normalize(const GridType& grid, const MaskT& mask, bool threaded = true)
268 {
269 return normalize<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
270 }
271
272
274
275
276 namespace gridop {
277
281 template<typename GridType>
282 struct ToMaskGrid {
283 typedef Grid<typename GridType::TreeType::template ValueConverter<ValueMask>::Type> Type;
284 };
285
286
292 template<
293 typename InGridT,
294 typename MaskGridType,
295 typename OutGridT,
296 typename MapT,
297 typename OperatorT,
298 typename InterruptT = util::NullInterrupter>
299 class GridOperator
300 {
301 public:
302 typedef typename OutGridT::TreeType OutTreeT;
303 typedef typename OutTreeT::LeafNodeType OutLeafT;
304 typedef typename tree::LeafManager<OutTreeT> LeafManagerT;
305
306 GridOperator(const InGridT& grid, const MaskGridType* mask, const MapT& map,
307 InterruptT* interrupt = nullptr, bool densify = true)
308 : mAcc(grid.getConstAccessor())
309 , mMap(map)
310 , mInterrupt(interrupt)
311 , mMask(mask)
312 , mDensify(densify)
313 {
314 }
315 GridOperator(const GridOperator&) = default;
316 GridOperator& operator=(const GridOperator&) = default;
317 virtual ~GridOperator() = default;
318
319 typename OutGridT::Ptr process(bool threaded = true)
320 {
321 if (mInterrupt) mInterrupt->start("Processing grid");
322
323 // Derive background value of the output grid
324 typename InGridT::TreeType tmp(mAcc.tree().background());
325 typename OutGridT::ValueType backg = OperatorT::result(mMap, tmp, math::Coord(0));
326
327 // The output tree is topology copy, optionally densified, of the input tree.
328 // (Densification is necessary for some operators because applying the operator to
329 // a constant tile produces distinct output values, particularly along tile borders.)
332 typename OutTreeT::Ptr tree(new OutTreeT(mAcc.tree(), backg, TopologyCopy()));
333 if (mDensify) tree->voxelizeActiveTiles();
334
335 // create grid with output tree and unit transform
336 typename OutGridT::Ptr result(new OutGridT(tree));
337
338 // Modify the solution area if a mask was supplied.
339 if (mMask) {
340 result->topologyIntersection(*mMask);
341 }
342
343 // transform of output grid = transform of input grid
344 result->setTransform(math::Transform::Ptr(new math::Transform( mMap.copy() )));
345
346 LeafManagerT leafManager(*tree);
347
348 if (threaded) {
349 tbb::parallel_for(leafManager.leafRange(), *this);
350 } else {
351 (*this)(leafManager.leafRange());
352 }
353
354 // If the tree wasn't densified, it might have active tiles that need to be processed.
355 if (!mDensify) {
356 using TileIter = typename OutTreeT::ValueOnIter;
357
358 TileIter tileIter = tree->beginValueOn();
359 tileIter.setMaxDepth(tileIter.getLeafDepth() - 1); // skip leaf values (i.e., voxels)
360
361 AccessorT inAcc = mAcc; // each thread needs its own accessor, captured by value
362 auto tileOp = [this, inAcc](const TileIter& it) {
363 // Apply the operator to the input grid's tile value at the iterator's
364 // current coordinates, and set the output tile's value to the result.
365 it.setValue(OperatorT::result(this->mMap, inAcc, it.getCoord()));
366 };
367
368 // Apply the operator to tile values, optionally in parallel.
369 // (But don't share the functor; each thread needs its own accessor.)
370 tools::foreach(tileIter, tileOp, threaded, /*shareFunctor=*/false);
371 }
372
373 if (mDensify) tree->prune();
374
375 if (mInterrupt) mInterrupt->end();
376 return result;
377 }
378
384 void operator()(const typename LeafManagerT::LeafRange& range) const
385 {
386 if (util::wasInterrupted(mInterrupt)) tbb::task::self().cancel_group_execution();
387
388 for (typename LeafManagerT::LeafRange::Iterator leaf=range.begin(); leaf; ++leaf) {
389 for (typename OutLeafT::ValueOnIter value=leaf->beginValueOn(); value; ++value) {
390 value.setValue(OperatorT::result(mMap, mAcc, value.getCoord()));
391 }
392 }
393 }
394
395 protected:
396 typedef typename InGridT::ConstAccessor AccessorT;
397 mutable AccessorT mAcc;
398 const MapT& mMap;
399 InterruptT* mInterrupt;
400 const MaskGridType* mMask;
401 const bool mDensify;
402 }; // end of GridOperator class
403
404 } // namespace gridop
405
406
408
409
411 template<
412 typename InGridT,
413 typename MaskGridType = typename gridop::ToMaskGrid<InGridT>::Type,
414 typename InterruptT = util::NullInterrupter>
415 class Cpt
416 {
417 public:
418 typedef InGridT InGridType;
419 typedef typename ScalarToVectorConverter<InGridT>::Type OutGridType;
420
421 Cpt(const InGridType& grid, InterruptT* interrupt = nullptr):
422 mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
423 {
424 }
425
426 Cpt(const InGridType& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
427 mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
428 {
429 }
430
431 typename OutGridType::Ptr process(bool threaded = true, bool useWorldTransform = true)
432 {
433 Functor functor(mInputGrid, mMask, threaded, useWorldTransform, mInterrupt);
434 processTypedMap(mInputGrid.transform(), functor);
435 if (functor.mOutputGrid) functor.mOutputGrid->setVectorType(VEC_CONTRAVARIANT_ABSOLUTE);
436 return functor.mOutputGrid;
437 }
438
439 private:
440 struct IsOpT
441 {
442 template<typename MapT, typename AccT>
443 static typename OutGridType::ValueType
444 result(const MapT& map, const AccT& acc, const Coord& xyz)
445 {
446 return math::CPT<MapT, math::CD_2ND>::result(map, acc, xyz);
447 }
448 };
449 struct WsOpT
450 {
451 template<typename MapT, typename AccT>
452 static typename OutGridType::ValueType
453 result(const MapT& map, const AccT& acc, const Coord& xyz)
454 {
455 return math::CPT_RANGE<MapT, math::CD_2ND>::result(map, acc, xyz);
456 }
457 };
458 struct Functor
459 {
460 Functor(const InGridType& grid, const MaskGridType* mask,
461 bool threaded, bool worldspace, InterruptT* interrupt)
462 : mThreaded(threaded)
463 , mWorldSpace(worldspace)
464 , mInputGrid(grid)
465 , mInterrupt(interrupt)
466 , mMask(mask)
467 {}
468
469 template<typename MapT>
470 void operator()(const MapT& map)
471 {
472 if (mWorldSpace) {
473 gridop::GridOperator<InGridType, MaskGridType, OutGridType, MapT, WsOpT, InterruptT>
474 op(mInputGrid, mMask, map, mInterrupt, /*densify=*/false);
475 mOutputGrid = op.process(mThreaded); // cache the result
476 } else {
477 gridop::GridOperator<InGridType, MaskGridType, OutGridType, MapT, IsOpT, InterruptT>
478 op(mInputGrid, mMask, map, mInterrupt, /*densify=*/false);
479 mOutputGrid = op.process(mThreaded); // cache the result
480 }
481 }
482 const bool mThreaded;
483 const bool mWorldSpace;
484 const InGridType& mInputGrid;
485 typename OutGridType::Ptr mOutputGrid;
486 InterruptT* mInterrupt;
487 const MaskGridType* mMask;
488 };
489 const InGridType& mInputGrid;
490 InterruptT* mInterrupt;
491 const MaskGridType* mMask;
492 }; // end of Cpt class
493
494
496
497
499 template<
500 typename GridT,
501 typename MaskGridType = typename gridop::ToMaskGrid<GridT>::Type,
502 typename InterruptT = util::NullInterrupter>
503 class Curl
504 {
505 public:
506 typedef GridT InGridType;
507 typedef GridT OutGridType;
508
509 Curl(const GridT& grid, InterruptT* interrupt = nullptr):
510 mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
511 {
512 }
513
514 Curl(const GridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
515 mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
516 {
517 }
518
519 typename GridT::Ptr process(bool threaded = true)
520 {
521 Functor functor(mInputGrid, mMask, threaded, mInterrupt);
522 processTypedMap(mInputGrid.transform(), functor);
523 if (functor.mOutputGrid) functor.mOutputGrid->setVectorType(VEC_COVARIANT);
524 return functor.mOutputGrid;
525 }
526
527 private:
528 struct Functor
529 {
530 Functor(const GridT& grid, const MaskGridType* mask,
531 bool threaded, InterruptT* interrupt):
532 mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
533
534 template<typename MapT>
535 void operator()(const MapT& map)
536 {
537 typedef math::Curl<MapT, math::CD_2ND> OpT;
538 gridop::GridOperator<GridT, MaskGridType, GridT, MapT, OpT, InterruptT>
539 op(mInputGrid, mMask, map, mInterrupt);
540 mOutputGrid = op.process(mThreaded); // cache the result
541 }
542
543 const bool mThreaded;
544 const GridT& mInputGrid;
545 typename GridT::Ptr mOutputGrid;
546 InterruptT* mInterrupt;
547 const MaskGridType* mMask;
548 }; // Private Functor
549
550 const GridT& mInputGrid;
551 InterruptT* mInterrupt;
552 const MaskGridType* mMask;
553 }; // end of Curl class
554
555
557
558
560 template<
561 typename InGridT,
562 typename MaskGridType = typename gridop::ToMaskGrid<InGridT>::Type,
563 typename InterruptT = util::NullInterrupter>
564 class Divergence
565 {
566 public:
567 typedef InGridT InGridType;
568 typedef typename VectorToScalarConverter<InGridT>::Type OutGridType;
569
570 Divergence(const InGridT& grid, InterruptT* interrupt = nullptr):
571 mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
572 {
573 }
574
575 Divergence(const InGridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
576 mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
577 {
578 }
579
580 typename OutGridType::Ptr process(bool threaded = true)
581 {
582 if (mInputGrid.getGridClass() == GRID_STAGGERED) {
583 Functor<math::FD_1ST> functor(mInputGrid, mMask, threaded, mInterrupt);
584 processTypedMap(mInputGrid.transform(), functor);
585 return functor.mOutputGrid;
586 } else {
587 Functor<math::CD_2ND> functor(mInputGrid, mMask, threaded, mInterrupt);
588 processTypedMap(mInputGrid.transform(), functor);
589 return functor.mOutputGrid;
590 }
591 }
592
593 protected:
594 template<math::DScheme DiffScheme>
595 struct Functor
596 {
597 Functor(const InGridT& grid, const MaskGridType* mask,
598 bool threaded, InterruptT* interrupt):
599 mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
600
601 template<typename MapT>
602 void operator()(const MapT& map)
603 {
604 typedef math::Divergence<MapT, DiffScheme> OpT;
605 gridop::GridOperator<InGridType, MaskGridType, OutGridType, MapT, OpT, InterruptT>
606 op(mInputGrid, mMask, map, mInterrupt);
607 mOutputGrid = op.process(mThreaded); // cache the result
608 }
609
610 const bool mThreaded;
611 const InGridType& mInputGrid;
612 typename OutGridType::Ptr mOutputGrid;
613 InterruptT* mInterrupt;
614 const MaskGridType* mMask;
615 }; // Private Functor
616
617 const InGridType& mInputGrid;
618 InterruptT* mInterrupt;
619 const MaskGridType* mMask;
620 }; // end of Divergence class
621
622
624
625
627 template<
628 typename InGridT,
629 typename MaskGridType = typename gridop::ToMaskGrid<InGridT>::Type,
630 typename InterruptT = util::NullInterrupter>
631 class Gradient
632 {
633 public:
634 typedef InGridT InGridType;
635 typedef typename ScalarToVectorConverter<InGridT>::Type OutGridType;
636
637 Gradient(const InGridT& grid, InterruptT* interrupt = nullptr):
638 mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
639 {
640 }
641
642 Gradient(const InGridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
643 mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
644 {
645 }
646
647 typename OutGridType::Ptr process(bool threaded = true)
648 {
649 Functor functor(mInputGrid, mMask, threaded, mInterrupt);
650 processTypedMap(mInputGrid.transform(), functor);
651 if (functor.mOutputGrid) functor.mOutputGrid->setVectorType(VEC_COVARIANT);
652 return functor.mOutputGrid;
653 }
654
655 protected:
656 struct Functor
657 {
658 Functor(const InGridT& grid, const MaskGridType* mask,
659 bool threaded, InterruptT* interrupt):
660 mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
661
662 template<typename MapT>
663 void operator()(const MapT& map)
664 {
665 typedef math::Gradient<MapT, math::CD_2ND> OpT;
666 gridop::GridOperator<InGridType, MaskGridType, OutGridType, MapT, OpT, InterruptT>
667 op(mInputGrid, mMask, map, mInterrupt);
668 mOutputGrid = op.process(mThreaded); // cache the result
669 }
670
671 const bool mThreaded;
672 const InGridT& mInputGrid;
673 typename OutGridType::Ptr mOutputGrid;
674 InterruptT* mInterrupt;
675 const MaskGridType* mMask;
676 }; // Private Functor
677
678 const InGridT& mInputGrid;
679 InterruptT* mInterrupt;
680 const MaskGridType* mMask;
681 }; // end of Gradient class
682
683
685
686
687 template<
688 typename GridT,
689 typename MaskGridType = typename gridop::ToMaskGrid<GridT>::Type,
690 typename InterruptT = util::NullInterrupter>
691 class Laplacian
692 {
693 public:
694 typedef GridT InGridType;
695 typedef GridT OutGridType;
696
697 Laplacian(const GridT& grid, InterruptT* interrupt = nullptr):
698 mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
699 {
700 }
701
702 Laplacian(const GridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
703 mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
704 {
705 }
706
707 typename GridT::Ptr process(bool threaded = true)
708 {
709 Functor functor(mInputGrid, mMask, threaded, mInterrupt);
710 processTypedMap(mInputGrid.transform(), functor);
711 if (functor.mOutputGrid) functor.mOutputGrid->setVectorType(VEC_COVARIANT);
712 return functor.mOutputGrid;
713 }
714
715 protected:
716 struct Functor
717 {
718 Functor(const GridT& grid, const MaskGridType* mask, bool threaded, InterruptT* interrupt):
719 mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
720
721 template<typename MapT>
722 void operator()(const MapT& map)
723 {
724 typedef math::Laplacian<MapT, math::CD_SECOND> OpT;
725 gridop::GridOperator<GridT, MaskGridType, GridT, MapT, OpT, InterruptT>
726 op(mInputGrid, mMask, map, mInterrupt);
727 mOutputGrid = op.process(mThreaded); // cache the result
728 }
729
730 const bool mThreaded;
731 const GridT& mInputGrid;
732 typename GridT::Ptr mOutputGrid;
733 InterruptT* mInterrupt;
734 const MaskGridType* mMask;
735 }; // Private Functor
736
737 const GridT& mInputGrid;
738 InterruptT* mInterrupt;
739 const MaskGridType* mMask;
740 }; // end of Laplacian class
741
742
744
745
746 template<
747 typename GridT,
748 typename MaskGridType = typename gridop::ToMaskGrid<GridT>::Type,
749 typename InterruptT = util::NullInterrupter>
750 class MeanCurvature
751 {
752 public:
753 typedef GridT InGridType;
754 typedef GridT OutGridType;
755
756 MeanCurvature(const GridT& grid, InterruptT* interrupt = nullptr):
757 mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
758 {
759 }
760
761 MeanCurvature(const GridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
762 mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
763 {
764 }
765
766 typename GridT::Ptr process(bool threaded = true)
767 {
768 Functor functor(mInputGrid, mMask, threaded, mInterrupt);
769 processTypedMap(mInputGrid.transform(), functor);
770 if (functor.mOutputGrid) functor.mOutputGrid->setVectorType(VEC_COVARIANT);
771 return functor.mOutputGrid;
772 }
773
774 protected:
775 struct Functor
776 {
777 Functor(const GridT& grid, const MaskGridType* mask, bool threaded, InterruptT* interrupt):
778 mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
779
780 template<typename MapT>
781 void operator()(const MapT& map)
782 {
783 typedef math::MeanCurvature<MapT, math::CD_SECOND, math::CD_2ND> OpT;
784 gridop::GridOperator<GridT, MaskGridType, GridT, MapT, OpT, InterruptT>
785 op(mInputGrid, mMask, map, mInterrupt);
786 mOutputGrid = op.process(mThreaded); // cache the result
787 }
788
789 const bool mThreaded;
790 const GridT& mInputGrid;
791 typename GridT::Ptr mOutputGrid;
792 InterruptT* mInterrupt;
793 const MaskGridType* mMask;
794 }; // Private Functor
795
796 const GridT& mInputGrid;
797 InterruptT* mInterrupt;
798 const MaskGridType* mMask;
799 }; // end of MeanCurvature class
800
801
803
804
805 template<
806 typename InGridT,
807 typename MaskGridType = typename gridop::ToMaskGrid<InGridT>::Type,
808 typename InterruptT = util::NullInterrupter>
809 class Magnitude
810 {
811 public:
812 typedef InGridT InGridType;
813 typedef typename VectorToScalarConverter<InGridT>::Type OutGridType;
814
815 Magnitude(const InGridType& grid, InterruptT* interrupt = nullptr):
816 mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
817 {
818 }
819
820 Magnitude(const InGridType& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
821 mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
822 {
823 }
824
825 typename OutGridType::Ptr process(bool threaded = true)
826 {
827 Functor functor(mInputGrid, mMask, threaded, mInterrupt);
828 processTypedMap(mInputGrid.transform(), functor);
829 return functor.mOutputGrid;
830 }
831
832 protected:
833 struct OpT
834 {
835 template<typename MapT, typename AccT>
836 static typename OutGridType::ValueType
837 result(const MapT&, const AccT& acc, const Coord& xyz) { return acc.getValue(xyz).length();}
838 };
839 struct Functor
840 {
841 Functor(const InGridT& grid, const MaskGridType* mask,
842 bool threaded, InterruptT* interrupt):
843 mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
844
845 template<typename MapT>
846 void operator()(const MapT& map)
847 {
848 gridop::GridOperator<InGridType, MaskGridType, OutGridType, MapT, OpT, InterruptT>
849 op(mInputGrid, mMask, map, mInterrupt, /*densify=*/false);
850 mOutputGrid = op.process(mThreaded); // cache the result
851 }
852
853 const bool mThreaded;
854 const InGridType& mInputGrid;
855 typename OutGridType::Ptr mOutputGrid;
856 InterruptT* mInterrupt;
857 const MaskGridType* mMask;
858 }; // Private Functor
859
860 const InGridType& mInputGrid;
861 InterruptT* mInterrupt;
862 const MaskGridType* mMask;
863 }; // end of Magnitude class
864
865
867
868
869 template<
870 typename GridT,
871 typename MaskGridType = typename gridop::ToMaskGrid<GridT>::Type,
872 typename InterruptT = util::NullInterrupter>
873 class Normalize
874 {
875 public:
876 typedef GridT InGridType;
877 typedef GridT OutGridType;
878
879 Normalize(const GridT& grid, InterruptT* interrupt = nullptr):
880 mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
881 {
882 }
883
884 Normalize(const GridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
885 mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
886 {
887 }
888
889 typename GridT::Ptr process(bool threaded = true)
890 {
891 Functor functor(mInputGrid, mMask, threaded, mInterrupt);
892 processTypedMap(mInputGrid.transform(), functor);
893 if (typename GridT::Ptr outGrid = functor.mOutputGrid) {
894 const VecType vecType = mInputGrid.getVectorType();
895 if (vecType == VEC_COVARIANT) {
896 outGrid->setVectorType(VEC_COVARIANT_NORMALIZE);
897 } else {
898 outGrid->setVectorType(vecType);
899 }
900 }
901 return functor.mOutputGrid;
902 }
903
904 protected:
905 struct OpT
906 {
907 template<typename MapT, typename AccT>
908 static typename OutGridType::ValueType
909 result(const MapT&, const AccT& acc, const Coord& xyz)
910 {
911 typename OutGridType::ValueType vec = acc.getValue(xyz);
912 if ( !vec.normalize() ) vec.setZero();
913 return vec;
914 }
915 };
916 struct Functor
917 {
918 Functor(const GridT& grid, const MaskGridType* mask, bool threaded, InterruptT* interrupt):
919 mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
920
921 template<typename MapT>
922 void operator()(const MapT& map)
923 {
924 gridop::GridOperator<GridT, MaskGridType, GridT, MapT, OpT, InterruptT>
925 op(mInputGrid, mMask, map, mInterrupt, /*densify=*/false);
926 mOutputGrid = op.process(mThreaded); // cache the result
927 }
928
929 const bool mThreaded;
930 const GridT& mInputGrid;
931 typename GridT::Ptr mOutputGrid;
932 InterruptT* mInterrupt;
933 const MaskGridType* mMask;
934 }; // Private Functor
935
936 const GridT& mInputGrid;
937 InterruptT* mInterrupt;
938 const MaskGridType* mMask;
939 }; // end of Normalize class
940
941
943
944
945 template<typename GridType, typename InterruptT> inline
946 typename ScalarToVectorConverter<GridType>::Type::Ptr
947 cpt(const GridType& grid, bool threaded, InterruptT* interrupt)
948 {
949 Cpt<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT> op(grid, interrupt);
950 return op.process(threaded);
951 }
952
953 template<typename GridType, typename MaskT, typename InterruptT> inline
954 typename ScalarToVectorConverter<GridType>::Type::Ptr
955 cpt(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
956 {
957 Cpt<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
958 return op.process(threaded);
959 }
960
961 template<typename GridType, typename InterruptT> inline
962 typename GridType::Ptr
963 curl(const GridType& grid, bool threaded, InterruptT* interrupt)
964 {
965 Curl<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT> op(grid, interrupt);
966 return op.process(threaded);
967 }
968
969 template<typename GridType, typename MaskT, typename InterruptT> inline
970 typename GridType::Ptr
971 curl(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
972 {
973 Curl<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
974 return op.process(threaded);
975 }
976
977 template<typename GridType, typename InterruptT> inline
978 typename VectorToScalarConverter<GridType>::Type::Ptr
979 divergence(const GridType& grid, bool threaded, InterruptT* interrupt)
980 {
981 Divergence<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
982 op(grid, interrupt);
983 return op.process(threaded);
984 }
985
986 template<typename GridType, typename MaskT, typename InterruptT> inline
987 typename VectorToScalarConverter<GridType>::Type::Ptr
988 divergence(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
989 {
990 Divergence<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
991 return op.process(threaded);
992 }
993
994 template<typename GridType, typename InterruptT> inline
995 typename ScalarToVectorConverter<GridType>::Type::Ptr
996 gradient(const GridType& grid, bool threaded, InterruptT* interrupt)
997 {
998 Gradient<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
999 op(grid, interrupt);
1000 return op.process(threaded);
1001 }
1002
1003 template<typename GridType, typename MaskT, typename InterruptT> inline
1004 typename ScalarToVectorConverter<GridType>::Type::Ptr
1005 gradient(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
1006 {
1007 Gradient<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
1008 return op.process(threaded);
1009 }
1010
1011 template<typename GridType, typename InterruptT> inline
1012 typename GridType::Ptr
1013 laplacian(const GridType& grid, bool threaded, InterruptT* interrupt)
1014 {
1015 Laplacian<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
1016 op(grid, interrupt);
1017 return op.process(threaded);
1018 }
1019
1020 template<typename GridType, typename MaskT, typename InterruptT> inline
1021 typename GridType::Ptr
1022 laplacian(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
1023 {
1024 Laplacian<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
1025 return op.process(threaded);
1026 }
1027
1028 template<typename GridType, typename InterruptT> inline
1029 typename GridType::Ptr
1030 meanCurvature(const GridType& grid, bool threaded, InterruptT* interrupt)
1031 {
1032 MeanCurvature<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
1033 op(grid, interrupt);
1034 return op.process(threaded);
1035 }
1036
1037 template<typename GridType, typename MaskT, typename InterruptT> inline
1038 typename GridType::Ptr
1039 meanCurvature(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
1040 {
1041 MeanCurvature<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
1042 return op.process(threaded);
1043 }
1044
1045 template<typename GridType, typename InterruptT> inline
1046 typename VectorToScalarConverter<GridType>::Type::Ptr
1047 magnitude(const GridType& grid, bool threaded, InterruptT* interrupt)
1048 {
1049 Magnitude<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
1050 op(grid, interrupt);
1051 return op.process(threaded);
1052 }
1053
1054 template<typename GridType, typename MaskT, typename InterruptT> inline
1055 typename VectorToScalarConverter<GridType>::Type::Ptr
1056 magnitude(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
1057 {
1058 Magnitude<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
1059 return op.process(threaded);
1060 }
1061
1062 template<typename GridType, typename InterruptT> inline
1063 typename GridType::Ptr
1064 normalize(const GridType& grid, bool threaded, InterruptT* interrupt)
1065 {
1066 Normalize<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
1067 op(grid, interrupt);
1068 return op.process(threaded);
1069 }
1070
1071 template<typename GridType, typename MaskT, typename InterruptT> inline
1072 typename GridType::Ptr
1073 normalize(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
1074 {
1075 Normalize<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
1076 return op.process(threaded);
1077 }
1078
1079 } // namespace tools
1080 } // namespace OPENVDB_VERSION_NAME
1081 } // namespace openvdb
1082
1083 #endif // OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
openvdb::v7_1::math::Vec3
Definition: Mat.h:170
openvdb::v7_1::tools::gridop::GridOperator::mMask
const MaskGridType * mMask
Definition: GridOperators.h:400
openvdb::v7_1::tools::normalize
GridType::Ptr normalize(const GridType &grid, const MaskT &mask, bool threaded=true)
Definition: GridOperators.h:267
openvdb::v7_1::tools::Laplacian::Functor::Functor
Functor(const GridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition: GridOperators.h:718
openvdb::v7_1::tools::Magnitude::Functor::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:856
openvdb::v7_1::tools::MeanCurvature::Functor::mThreaded
const bool mThreaded
Definition: GridOperators.h:789
openvdb::v7_1::tools::Laplacian::Laplacian
Laplacian(const GridT &grid, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:697
openvdb::v7_1::tools::Divergence::Functor::Functor
Functor(const InGridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition: GridOperators.h:597
openvdb::v7_1::tools::Divergence::Divergence
Divergence(const InGridT &grid, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:570
openvdb::v7_1::tools::Normalize::Functor::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:932
openvdb::v7_1::tools::Gradient::process
OutGridType::Ptr process(bool threaded=true)
Definition: GridOperators.h:647
openvdb::v7_1::tools::Magnitude::Functor::mMask
const MaskGridType * mMask
Definition: GridOperators.h:857
openvdb::v7_1::tools::Laplacian::Functor::mInputGrid
const GridT & mInputGrid
Definition: GridOperators.h:731
openvdb::v7_1::math::Gradient
Center difference gradient operators, defined with respect to the range-space of the map.
Definition: Operators.h:617
openvdb::v7_1::tools::Normalize
Definition: GridOperators.h:874
openvdb::v7_1::VEC_COVARIANT_NORMALIZE
@ VEC_COVARIANT_NORMALIZE
Definition: Types.h:849
openvdb::v7_1::tools::gradient
ScalarToVectorConverter< GridType >::Type::Ptr gradient(const GridType &grid, const MaskT &mask, bool threaded=true)
Definition: GridOperators.h:154
openvdb::v7_1::tools::MeanCurvature::Functor::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:792
openvdb::v7_1::tools::Normalize::OutGridType
GridT OutGridType
Definition: GridOperators.h:877
openvdb::v7_1::tools::Laplacian::Functor::mThreaded
const bool mThreaded
Definition: GridOperators.h:730
openvdb::v7_1::tools::MeanCurvature::mMask
const MaskGridType * mMask
Definition: GridOperators.h:798
openvdb::v7_1::tools::Normalize::mInputGrid
const GridT & mInputGrid
Definition: GridOperators.h:936
openvdb::v7_1::tools::MeanCurvature::InGridType
GridT InGridType
Definition: GridOperators.h:753
openvdb::v7_1::tools::Curl::process
GridT::Ptr process(bool threaded=true)
Definition: GridOperators.h:519
openvdb::v7_1::tools::Normalize::Functor::Functor
Functor(const GridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition: GridOperators.h:918
openvdb::v7_1::tools::Gradient::Functor::operator()
void operator()(const MapT &map)
Definition: GridOperators.h:663
openvdb::v7_1::tools::Magnitude::OutGridType
VectorToScalarConverter< InGridT >::Type OutGridType
Definition: GridOperators.h:813
openvdb::v7_1::tools::gridop::GridOperator::AccessorT
InGridT::ConstAccessor AccessorT
Definition: GridOperators.h:396
openvdb::v7_1::TopologyCopy
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:1045
openvdb::v7_1::tools::Normalize::Functor::mOutputGrid
GridT::Ptr mOutputGrid
Definition: GridOperators.h:931
openvdb::v7_1::tools::curl
GridType::Ptr curl(const GridType &grid, const MaskT &mask, bool threaded=true)
Definition: GridOperators.h:96
openvdb::v7_1::tools::Curl::Curl
Curl(const GridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:514
openvdb::v7_1::tools::Normalize::Normalize
Normalize(const GridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:884
openvdb::v7_1::tools::Gradient::Functor::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:674
openvdb::v7_1::tools::Normalize::process
GridT::Ptr process(bool threaded=true)
Definition: GridOperators.h:889
openvdb::v7_1::tools::gridop::GridOperator::LeafManagerT
tree::LeafManager< OutTreeT > LeafManagerT
Definition: GridOperators.h:304
openvdb::v7_1::tools::gridop::GridOperator::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:399
openvdb::v7_1::math::Laplacian
Compute the Laplacian at a given location in a grid using finite differencing of various orders....
Definition: Operators.h:1417
openvdb::v7_1::tools::Laplacian::InGridType
GridT InGridType
Definition: GridOperators.h:694
openvdb::v7_1::tools::Magnitude::Functor::mOutputGrid
OutGridType::Ptr mOutputGrid
Definition: GridOperators.h:855
openvdb::v7_1::util::wasInterrupted
bool wasInterrupted(T *i, int percent=-1)
Definition: NullInterrupter.h:49
openvdb::v7_1::tools::Gradient::OutGridType
ScalarToVectorConverter< InGridT >::Type OutGridType
Definition: GridOperators.h:635
openvdb::v7_1::tools::MeanCurvature::Functor::operator()
void operator()(const MapT &map)
Definition: GridOperators.h:781
openvdb::v7_1::tools::MeanCurvature::Functor::mInputGrid
const GridT & mInputGrid
Definition: GridOperators.h:790
openvdb::v7_1::tools::Normalize::Normalize
Normalize(const GridT &grid, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:879
openvdb::v7_1::tools::Cpt::InGridType
InGridT InGridType
Definition: GridOperators.h:418
openvdb::v7_1::tools::Laplacian::process
GridT::Ptr process(bool threaded=true)
Definition: GridOperators.h:707
openvdb::v7_1::VEC_COVARIANT
@ VEC_COVARIANT
Definition: Types.h:848
openvdb::v7_1::tree::LeafManager
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition: LeafManager.h:83
openvdb::v7_1::tools::Laplacian::Functor::operator()
void operator()(const MapT &map)
Definition: GridOperators.h:722
openvdb::v7_1::tools::VectorToScalarConverter::Type
VectorGridType::template ValueConverter< VecComponentValueT >::Type Type
Definition: GridOperators.h:32
Grid.h
openvdb::v7_1::tools::Laplacian::Functor::mMask
const MaskGridType * mMask
Definition: GridOperators.h:734
openvdb::v7_1::tools::MeanCurvature::Functor::Functor
Functor(const GridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition: GridOperators.h:777
openvdb::v7_1::tools::Magnitude::Functor
Definition: GridOperators.h:840
openvdb::v7_1::tools::Divergence::InGridType
InGridT InGridType
Definition: GridOperators.h:567
openvdb::v7_1::tools::VectorToScalarConverter::VecComponentValueT
VectorGridType::ValueType::value_type VecComponentValueT
Definition: GridOperators.h:31
openvdb::v7_1::tools::gridop::GridOperator::OutTreeT
OutGridT::TreeType OutTreeT
Definition: GridOperators.h:302
openvdb::v7_1::tools::Gradient::Gradient
Gradient(const InGridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:642
openvdb::v7_1::tools::Divergence::Functor::mOutputGrid
OutGridType::Ptr mOutputGrid
Definition: GridOperators.h:612
openvdb::v7_1::tools::cpt
ScalarToVectorConverter< GridType >::Type::Ptr cpt(const GridType &grid, const MaskT &mask, bool threaded=true)
Definition: GridOperators.h:68
ValueAccessor.h
openvdb::v7_1::tools::laplacian
GridType::Ptr laplacian(const GridType &grid, const MaskT mask, bool threaded=true)
Definition: GridOperators.h:182
openvdb::v7_1::tools::Magnitude::Magnitude
Magnitude(const InGridType &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:820
openvdb::v7_1::tools::Laplacian::Laplacian
Laplacian(const GridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:702
openvdb::v7_1::util::NullInterrupter
Dummy NOOP interrupter class defining interface.
Definition: NullInterrupter.h:26
openvdb::v7_1::tools::Magnitude::mMask
const MaskGridType * mMask
Definition: GridOperators.h:862
openvdb::v7_1::tools::MeanCurvature::mInputGrid
const GridT & mInputGrid
Definition: GridOperators.h:796
openvdb::v7_1::tools::gridop::GridOperator::mDensify
const bool mDensify
Definition: GridOperators.h:401
openvdb::v7_1::tools::MeanCurvature::MeanCurvature
MeanCurvature(const GridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:761
openvdb::v7_1::Grid
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:28
openvdb::v7_1::tools::Magnitude::InGridType
InGridT InGridType
Definition: GridOperators.h:812
openvdb::v7_1::tools::Gradient::Gradient
Gradient(const InGridT &grid, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:637
openvdb::v7_1::tools::Magnitude::OpT
Definition: GridOperators.h:834
openvdb::v7_1::tools::Cpt
Compute the closest-point transform of a scalar grid.
Definition: GridOperators.h:416
openvdb::v7_1::tools::MeanCurvature::Functor::mOutputGrid
GridT::Ptr mOutputGrid
Definition: GridOperators.h:791
openvdb::v7_1::tools::MeanCurvature::Functor::mMask
const MaskGridType * mMask
Definition: GridOperators.h:793
openvdb::v7_1::tools::gridop::GridOperator::mMap
const MapT & mMap
Definition: GridOperators.h:398
openvdb::v7_1::tools::gridop::ToMaskGrid
ToMaskGrid<T>::Type is the type of a grid having the same tree hierarchy as grid type T but a value e...
Definition: GridOperators.h:282
openvdb::v7_1::tools::Laplacian::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:738
openvdb::v7_1::tools::Normalize::Functor::mInputGrid
const GridT & mInputGrid
Definition: GridOperators.h:930
openvdb::v7_1::tools::Gradient::Functor::mInputGrid
const InGridT & mInputGrid
Definition: GridOperators.h:672
openvdb::v7_1::tools::MeanCurvature
Definition: GridOperators.h:751
openvdb::v7_1::tools::Divergence::OutGridType
VectorToScalarConverter< InGridT >::Type OutGridType
Definition: GridOperators.h:568
openvdb::v7_1::tools::Laplacian::mInputGrid
const GridT & mInputGrid
Definition: GridOperators.h:737
openvdb::v7_1::tools::MeanCurvature::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:797
openvdb::v7_1::tools::Divergence::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:618
openvdb::v7_1::tools::Divergence::Divergence
Divergence(const InGridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:575
openvdb::v7_1::tools::foreach
void foreach(const IterT &iter, XformOp &op, bool threaded=true, bool shareOp=true)
Definition: ValueTransformer.h:374
openvdb::v7_1::tools::Magnitude::mInputGrid
const InGridType & mInputGrid
Definition: GridOperators.h:860
openvdb::v7_1::tools::Magnitude::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:861
openvdb::v7_1::tools::Gradient::Functor::mMask
const MaskGridType * mMask
Definition: GridOperators.h:675
openvdb::v7_1::math::Divergence
Compute the divergence of a vector-valued grid using differencing of various orders,...
Definition: Operators.h:947
openvdb::v7_1::tools::Magnitude
Definition: GridOperators.h:810
openvdb::v7_1::tools::Laplacian::Functor
Definition: GridOperators.h:717
ValueTransformer.h
openvdb::v7_1::tools::Laplacian::mMask
const MaskGridType * mMask
Definition: GridOperators.h:739
openvdb::v7_1::tools::Divergence::process
OutGridType::Ptr process(bool threaded=true)
Definition: GridOperators.h:580
openvdb::v7_1::tools::gridop::GridOperator::mAcc
AccessorT mAcc
Definition: GridOperators.h:397
openvdb::v7_1::tools::ScalarToVectorConverter
ScalarToVectorConverter<ScalarGridType>::Type is the type of a grid having the same tree configuratio...
Definition: GridOperators.h:39
openvdb::v7_1::tools::gridop::GridOperator
Apply an operator to an input grid to produce an output grid with the same active voxel topology but ...
Definition: GridOperators.h:300
openvdb::v7_1::tools::Gradient::Functor::mOutputGrid
OutGridType::Ptr mOutputGrid
Definition: GridOperators.h:673
openvdb::v7_1::tools::Laplacian
Definition: GridOperators.h:692
openvdb::v7_1::tools::Gradient::Functor::Functor
Functor(const InGridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition: GridOperators.h:658
NullInterrupter.h
openvdb::v7_1::tools::Divergence::Functor::mMask
const MaskGridType * mMask
Definition: GridOperators.h:614
openvdb::v7_1::math::MeanCurvature
Compute the mean curvature.
Definition: Operators.h:1759
openvdb::v7_1::tools::Curl::Curl
Curl(const GridT &grid, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:509
openvdb::v7_1::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
openvdb::v7_1::tools::Gradient::mInputGrid
const InGridT & mInputGrid
Definition: GridOperators.h:678
openvdb::v7_1::tools::gridop::ToMaskGrid::Type
Grid< typename GridType::TreeType::template ValueConverter< ValueMask >::Type > Type
Definition: GridOperators.h:283
openvdb::v7_1::tools::Divergence::Functor::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:613
openvdb::v7_1::tools::gridop::GridOperator::operator()
void operator()(const typename LeafManagerT::LeafRange &range) const
Iterate sequentially over LeafNodes and voxels in the output grid and apply the operator using a valu...
Definition: GridOperators.h:384
openvdb::v7_1::tools::Divergence::mMask
const MaskGridType * mMask
Definition: GridOperators.h:619
openvdb::v7_1::tools::Normalize::Functor::mThreaded
const bool mThreaded
Definition: GridOperators.h:929
openvdb::v7_1::tools::Curl::OutGridType
GridT OutGridType
Definition: GridOperators.h:507
openvdb::v7_1::tools::Curl::InGridType
GridT InGridType
Definition: GridOperators.h:506
openvdb::v7_1::VEC_CONTRAVARIANT_ABSOLUTE
@ VEC_CONTRAVARIANT_ABSOLUTE
Definition: Types.h:851
openvdb::v7_1::tools::Cpt::process
OutGridType::Ptr process(bool threaded=true, bool useWorldTransform=true)
Definition: GridOperators.h:431
openvdb::v7_1::VecType
VecType
Definition: Types.h:846
openvdb::v7_1::tools::Normalize::Functor::operator()
void operator()(const MapT &map)
Definition: GridOperators.h:922
openvdb::v7_1::math::CPT_RANGE
Compute the closest-point transform to a level set.
Definition: Operators.h:1716
openvdb::v7_1::tools::VectorToScalarConverter
VectorToScalarConverter<VectorGridType>::Type is the type of a grid having the same tree configuratio...
Definition: GridOperators.h:30
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:146
openvdb::v7_1::tools::Divergence
Compute the divergence of a vector grid.
Definition: GridOperators.h:565
openvdb::v7_1::math::processTypedMap
bool processTypedMap(TransformType &transform, OpType &op)
Utility function that, given a generic map pointer, calls a functor on the fully-resoved map.
Definition: Transform.h:233
openvdb::v7_1::tree::LeafManager::LeafRange::begin
Iterator begin() const
Definition: LeafManager.h:153
openvdb::v7_1::tools::Magnitude::Functor::Functor
Functor(const InGridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition: GridOperators.h:841
openvdb::v7_1::tools::gridop::GridOperator::GridOperator
GridOperator(const GridOperator &)=default
openvdb::v7_1::tools::gridop::GridOperator::OutLeafT
OutTreeT::LeafNodeType OutLeafT
Definition: GridOperators.h:303
openvdb::v7_1::tools::Normalize::Functor
Definition: GridOperators.h:917
openvdb::v7_1::tree::LeafManager::LeafRange
Definition: LeafManager.h:100
openvdb::v7_1::tools::Gradient::Functor::mThreaded
const bool mThreaded
Definition: GridOperators.h:671
openvdb::v7_1::tools::MeanCurvature::OutGridType
GridT OutGridType
Definition: GridOperators.h:754
LeafManager.h
A LeafManager manages a linear array of pointers to a given tree's leaf nodes, as well as optional au...
openvdb::v7_1::tools::Laplacian::OutGridType
GridT OutGridType
Definition: GridOperators.h:695
openvdb::v7_1::GRID_STAGGERED
@ GRID_STAGGERED
Definition: Types.h:820
openvdb::v7_1::tools::Magnitude::Functor::operator()
void operator()(const MapT &map)
Definition: GridOperators.h:846
openvdb::v7_1::tools::Magnitude::Functor::mThreaded
const bool mThreaded
Definition: GridOperators.h:853
openvdb::v7_1::tools::Normalize::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:937
openvdb::v7_1::tools::magnitude
VectorToScalarConverter< GridType >::Type::Ptr magnitude(const GridType &grid, const MaskT &mask, bool threaded=true)
Definition: GridOperators.h:239
openvdb::v7_1::tools::MeanCurvature::MeanCurvature
MeanCurvature(const GridT &grid, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:756
openvdb::v7_1::tools::Divergence::Functor::mInputGrid
const InGridType & mInputGrid
Definition: GridOperators.h:611
openvdb::v7_1::tools::gridop::GridOperator::operator=
GridOperator & operator=(const GridOperator &)=default
openvdb::v7_1::tools::Gradient::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:679
openvdb::v7_1::tools::Normalize::OpT::result
static OutGridType::ValueType result(const MapT &, const AccT &acc, const Coord &xyz)
Definition: GridOperators.h:909
openvdb::v7_1::tools::ScalarToVectorConverter::VectorValueT
math::Vec3< typename ScalarGridType::ValueType > VectorValueT
Definition: GridOperators.h:40
openvdb::v7_1::tools::Normalize::OpT
Definition: GridOperators.h:906
openvdb::v7_1::tree::LeafManager::leafRange
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:358
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:94
openvdb::v7_1::math::Curl
Compute the curl of a vector-valued grid using differencing of various orders in the space defined by...
Definition: Operators.h:1272
openvdb::v7_1::tools::Normalize::Functor::mMask
const MaskGridType * mMask
Definition: GridOperators.h:933
openvdb::v7_1::tools::MeanCurvature::Functor
Definition: GridOperators.h:776
openvdb::v7_1::tools::Gradient::InGridType
InGridT InGridType
Definition: GridOperators.h:634
openvdb::v7_1::tools::Cpt::Cpt
Cpt(const InGridType &grid, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:421
openvdb::v7_1::math::Transform::Ptr
SharedPtr< Transform > Ptr
Definition: Transform.h:42
openvdb::v7_1::tools::Curl
Compute the curl of a vector grid.
Definition: GridOperators.h:504
openvdb::v7_1::math::CPT
Compute the closest-point transform to a level set.
Definition: Operators.h:1663
openvdb::v7_1::tools::Cpt::Cpt
Cpt(const InGridType &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:426
openvdb::v7_1::math::Transform
Definition: Transform.h:40
openvdb::v7_1::tools::meanCurvature
GridType::Ptr meanCurvature(const GridType &grid, const MaskT &mask, bool threaded=true)
Definition: GridOperators.h:210
openvdb::v7_1::tools::Divergence::Functor::mThreaded
const bool mThreaded
Definition: GridOperators.h:610
openvdb::v7_1::tools::Cpt::OutGridType
ScalarToVectorConverter< InGridT >::Type OutGridType
Definition: GridOperators.h:419
openvdb::v7_1::tools::divergence
VectorToScalarConverter< GridType >::Type::Ptr divergence(const GridType &grid, const MaskT &mask, bool threaded=true)
Definition: GridOperators.h:125
openvdb::v7_1::tools::Gradient
Compute the gradient of a scalar grid.
Definition: GridOperators.h:632
openvdb
Definition: Exceptions.h:13
openvdb::v7_1::tools::gridop::GridOperator::process
OutGridT::Ptr process(bool threaded=true)
Definition: GridOperators.h:319
openvdb::v7_1::tools::MeanCurvature::process
GridT::Ptr process(bool threaded=true)
Definition: GridOperators.h:766
openvdb::v7_1::tools::Magnitude::Functor::mInputGrid
const InGridType & mInputGrid
Definition: GridOperators.h:854
openvdb::v7_1::tools::Magnitude::OpT::result
static OutGridType::ValueType result(const MapT &, const AccT &acc, const Coord &xyz)
Definition: GridOperators.h:837
openvdb::v7_1::tools::Magnitude::process
OutGridType::Ptr process(bool threaded=true)
Definition: GridOperators.h:825
openvdb::v7_1::tools::Laplacian::Functor::mInterrupt
InterruptT * mInterrupt
Definition: GridOperators.h:733
openvdb::v7_1::tools::Normalize::InGridType
GridT InGridType
Definition: GridOperators.h:876
openvdb::v7_1::tools::Divergence::mInputGrid
const InGridType & mInputGrid
Definition: GridOperators.h:617
openvdb::v7_1::tools::Divergence::Functor::operator()
void operator()(const MapT &map)
Definition: GridOperators.h:602
openvdb::v7_1::tools::gridop::GridOperator::GridOperator
GridOperator(const InGridT &grid, const MaskGridType *mask, const MapT &map, InterruptT *interrupt=nullptr, bool densify=true)
Definition: GridOperators.h:306
openvdb::v7_1::tools::Gradient::mMask
const MaskGridType * mMask
Definition: GridOperators.h:680
Operators.h
openvdb::v7_1::tools::Gradient::Functor
Definition: GridOperators.h:657
openvdb::v7_1::tools::Magnitude::Magnitude
Magnitude(const InGridType &grid, InterruptT *interrupt=nullptr)
Definition: GridOperators.h:815
openvdb::v7_1::tools::gridop::GridOperator::~GridOperator
virtual ~GridOperator()=default
openvdb::v7_1::tools::ScalarToVectorConverter::Type
ScalarGridType::template ValueConverter< VectorValueT >::Type Type
Definition: GridOperators.h:41
openvdb::v7_1::tools::Normalize::mMask
const MaskGridType * mMask
Definition: GridOperators.h:938
openvdb::v7_1::tools::Divergence::Functor
Definition: GridOperators.h:596
openvdb::v7_1::tools::Laplacian::Functor::mOutputGrid
GridT::Ptr mOutputGrid
Definition: GridOperators.h:732