OpenVDB 3.2.0

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