40 #ifndef OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED
41 #define OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED
59 template<
typename DerivedType,
typename Gr
idT,
bool IsSafe>
68 typedef typename BufferType::iterator
IterType;
76 mStencil[0] = mCache.getValue(ijk);
77 static_cast<DerivedType&
>(*this).init(mCenter);
88 mStencil[0] = centerValue;
89 static_cast<DerivedType&
>(*this).init(mCenter);
97 template<
typename IterType>
100 mCenter = iter.getCoord();
102 static_cast<DerivedType&
>(*this).init(mCenter);
111 template<
typename RealType>
114 Coord ijk = openvdb::Coord::floor(xyz);
115 if (ijk != mCenter) this->moveTo(ijk);
125 assert(pos < mStencil.size());
126 return mStencil[pos];
130 template<
int i,
int j,
int k>
133 return mStencil[
static_cast<const DerivedType&
>(*this).template pos<i,j,k>()];
137 template<
int i,
int j,
int k>
140 mStencil[
static_cast<const DerivedType&
>(*this).template pos<i,j,k>()] = value;
144 inline int size() {
return mStencil.size(); }
150 assert(!tmp.empty());
151 size_t midpoint = (tmp.size() - 1) >> 1;
153 std::nth_element(tmp.begin(), tmp.begin() + midpoint, tmp.end());
154 return tmp[midpoint];
161 for (
int n = 0, s =
int(mStencil.size()); n < s; ++n) sum += mStencil[n];
168 IterType iter = std::min_element(mStencil.begin(), mStencil.end());
175 IterType iter = std::max_element(mStencil.begin(), mStencil.end());
189 const bool less = this->getValue< 0, 0, 0>() < isoValue;
190 return (less ^ (this->getValue<-1, 0, 0>() < isoValue)) ||
191 (less ^ (this->getValue< 1, 0, 0>() < isoValue)) ||
192 (less ^ (this->getValue< 0,-1, 0>() < isoValue)) ||
193 (less ^ (this->getValue< 0, 1, 0>() < isoValue)) ||
194 (less ^ (this->getValue< 0, 0,-1>() < isoValue)) ||
195 (less ^ (this->getValue< 0, 0, 1>() < isoValue)) ;
210 , mCache(grid.tree())
230 template<
int i,
int j,
int k>
struct SevenPt {};
231 template<>
struct SevenPt< 0, 0, 0> {
enum { idx = 0 }; };
232 template<>
struct SevenPt< 1, 0, 0> {
enum { idx = 1 }; };
233 template<>
struct SevenPt< 0, 1, 0> {
enum { idx = 2 }; };
234 template<>
struct SevenPt< 0, 0, 1> {
enum { idx = 3 }; };
235 template<>
struct SevenPt<-1, 0, 0> {
enum { idx = 4 }; };
236 template<>
struct SevenPt< 0,-1, 0> {
enum { idx = 5 }; };
237 template<>
struct SevenPt< 0, 0,-1> {
enum { idx = 6 }; };
242 template<
typename Gr
idT,
bool IsSafe = true>
252 static const int SIZE = 7;
257 template<
int i,
int j,
int k>
258 unsigned int pos()
const {
return SevenPt<i,j,k>::idx; }
261 inline void init(
const Coord& ijk)
263 BaseType::template setValue<-1, 0, 0>(mCache.getValue(ijk.
offsetBy(-1, 0, 0)));
264 BaseType::template setValue< 1, 0, 0>(mCache.getValue(ijk.
offsetBy( 1, 0, 0)));
266 BaseType::template setValue< 0,-1, 0>(mCache.getValue(ijk.
offsetBy( 0,-1, 0)));
267 BaseType::template setValue< 0, 1, 0>(mCache.getValue(ijk.
offsetBy( 0, 1, 0)));
269 BaseType::template setValue< 0, 0,-1>(mCache.getValue(ijk.
offsetBy( 0, 0,-1)));
270 BaseType::template setValue< 0, 0, 1>(mCache.getValue(ijk.
offsetBy( 0, 0, 1)));
274 using BaseType::mCache;
275 using BaseType::mStencil;
285 template<
int i,
int j,
int k>
struct BoxPt {};
286 template<>
struct BoxPt< 0, 0, 0> {
enum { idx = 0 }; };
287 template<>
struct BoxPt< 0, 0, 1> {
enum { idx = 1 }; };
288 template<>
struct BoxPt< 0, 1, 1> {
enum { idx = 2 }; };
289 template<>
struct BoxPt< 0, 1, 0> {
enum { idx = 3 }; };
290 template<>
struct BoxPt< 1, 0, 0> {
enum { idx = 4 }; };
291 template<>
struct BoxPt< 1, 0, 1> {
enum { idx = 5 }; };
292 template<>
struct BoxPt< 1, 1, 1> {
enum { idx = 6 }; };
293 template<>
struct BoxPt< 1, 1, 0> {
enum { idx = 7 }; };
296 template<
typename Gr
idT,
bool IsSafe = true>
306 static const int SIZE = 8;
311 template<
int i,
int j,
int k>
312 unsigned int pos()
const {
return BoxPt<i,j,k>::idx; }
318 const bool less = mStencil[0] < isoValue;
319 return (less ^ (mStencil[1] < isoValue)) ||
320 (less ^ (mStencil[2] < isoValue)) ||
321 (less ^ (mStencil[3] < isoValue)) ||
322 (less ^ (mStencil[4] < isoValue)) ||
323 (less ^ (mStencil[5] < isoValue)) ||
324 (less ^ (mStencil[6] < isoValue)) ||
325 (less ^ (mStencil[7] < isoValue)) ;
338 const ValueType u = xyz[0] - BaseType::mCenter[0];
339 const ValueType v = xyz[1] - BaseType::mCenter[1];
340 const ValueType w = xyz[2] - BaseType::mCenter[2];
343 assert(u>=0 && u<=1);
344 assert(v>=0 && v<=1);
345 assert(w>=0 && w<=1);
347 ValueType V = BaseType::template getValue<0,0,0>();
348 ValueType A =
static_cast<ValueType>(V + (BaseType::template getValue<0,0,1>() - V) * w);
349 V = BaseType::template getValue< 0, 1, 0>();
350 ValueType B =
static_cast<ValueType>(V + (BaseType::template getValue<0,1,1>() - V) * w);
353 V = BaseType::template getValue<1,0,0>();
354 A =
static_cast<ValueType>(V + (BaseType::template getValue<1,0,1>() - V) * w);
355 V = BaseType::template getValue<1,1,0>();
356 B =
static_cast<ValueType>(V + (BaseType::template getValue<1,1,1>() - V) * w);
359 return static_cast<ValueType>(C + (D - C) * u);
372 const ValueType u = xyz[0] - BaseType::mCenter[0];
373 const ValueType v = xyz[1] - BaseType::mCenter[1];
374 const ValueType w = xyz[2] - BaseType::mCenter[2];
377 assert(u>=0 && u<=1);
378 assert(v>=0 && v<=1);
379 assert(w>=0 && w<=1);
381 ValueType D[4]={BaseType::template getValue<0,0,1>()-BaseType::template getValue<0,0,0>(),
382 BaseType::template getValue<0,1,1>()-BaseType::template getValue<0,1,0>(),
383 BaseType::template getValue<1,0,1>()-BaseType::template getValue<1,0,0>(),
384 BaseType::template getValue<1,1,1>()-BaseType::template getValue<1,1,0>()};
390 zeroVal<ValueType>(),
391 static_cast<ValueType>(A + (B - A) * u));
393 D[0] =
static_cast<ValueType>(BaseType::template getValue<0,0,0>() + D[0] * w);
394 D[1] =
static_cast<ValueType>(BaseType::template getValue<0,1,0>() + D[1] * w);
395 D[2] =
static_cast<ValueType>(BaseType::template getValue<1,0,0>() + D[2] * w);
396 D[3] =
static_cast<ValueType>(BaseType::template getValue<1,1,0>() + D[3] * w);
399 A =
static_cast<ValueType>(D[0] + (D[1] - D[0]) * v);
400 B =
static_cast<ValueType>(D[2] + (D[3] - D[2]) * v);
408 grad[1] =
static_cast<ValueType>(A + (B - A) * u);
410 return BaseType::mGrid->transform().baseMap()->applyIJT(grad, xyz);
414 inline void init(
const Coord& ijk)
416 BaseType::template setValue< 0, 0, 1>(mCache.getValue(ijk.
offsetBy( 0, 0, 1)));
417 BaseType::template setValue< 0, 1, 1>(mCache.getValue(ijk.
offsetBy( 0, 1, 1)));
418 BaseType::template setValue< 0, 1, 0>(mCache.getValue(ijk.
offsetBy( 0, 1, 0)));
419 BaseType::template setValue< 1, 0, 0>(mCache.getValue(ijk.
offsetBy( 1, 0, 0)));
420 BaseType::template setValue< 1, 0, 1>(mCache.getValue(ijk.
offsetBy( 1, 0, 1)));
421 BaseType::template setValue< 1, 1, 1>(mCache.getValue(ijk.
offsetBy( 1, 1, 1)));
422 BaseType::template setValue< 1, 1, 0>(mCache.getValue(ijk.
offsetBy( 1, 1, 0)));
426 using BaseType::mCache;
427 using BaseType::mStencil;
437 template<
int i,
int j,
int k>
struct DensePt {};
438 template<>
struct DensePt< 0, 0, 0> {
enum { idx = 0 }; };
440 template<>
struct DensePt< 1, 0, 0> {
enum { idx = 1 }; };
441 template<>
struct DensePt< 0, 1, 0> {
enum { idx = 2 }; };
442 template<>
struct DensePt< 0, 0, 1> {
enum { idx = 3 }; };
444 template<>
struct DensePt<-1, 0, 0> {
enum { idx = 4 }; };
445 template<>
struct DensePt< 0,-1, 0> {
enum { idx = 5 }; };
446 template<>
struct DensePt< 0, 0,-1> {
enum { idx = 6 }; };
448 template<>
struct DensePt<-1,-1, 0> {
enum { idx = 7 }; };
449 template<>
struct DensePt< 0,-1,-1> {
enum { idx = 8 }; };
450 template<>
struct DensePt<-1, 0,-1> {
enum { idx = 9 }; };
452 template<>
struct DensePt< 1,-1, 0> {
enum { idx = 10 }; };
453 template<>
struct DensePt< 0, 1,-1> {
enum { idx = 11 }; };
454 template<>
struct DensePt<-1, 0, 1> {
enum { idx = 12 }; };
456 template<>
struct DensePt<-1, 1, 0> {
enum { idx = 13 }; };
457 template<>
struct DensePt< 0,-1, 1> {
enum { idx = 14 }; };
458 template<>
struct DensePt< 1, 0,-1> {
enum { idx = 15 }; };
460 template<>
struct DensePt< 1, 1, 0> {
enum { idx = 16 }; };
461 template<>
struct DensePt< 0, 1, 1> {
enum { idx = 17 }; };
462 template<>
struct DensePt< 1, 0, 1> {
enum { idx = 18 }; };
467 template<
typename Gr
idT,
bool IsSafe = true>
469 :
public BaseStencil<SecondOrderDenseStencil<GridT, IsSafe>, GridT, IsSafe >
478 static const int SIZE = 19;
483 template<
int i,
int j,
int k>
484 unsigned int pos()
const {
return DensePt<i,j,k>::idx; }
487 inline void init(
const Coord& ijk)
489 mStencil[DensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
490 mStencil[DensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
491 mStencil[DensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
493 mStencil[DensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
494 mStencil[DensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
495 mStencil[DensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
497 mStencil[DensePt<-1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, -1, 0));
498 mStencil[DensePt< 1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, -1, 0));
499 mStencil[DensePt<-1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 1, 0));
500 mStencil[DensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
502 mStencil[DensePt<-1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, -1));
503 mStencil[DensePt< 1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, -1));
504 mStencil[DensePt<-1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 1));
505 mStencil[DensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 1));
507 mStencil[DensePt< 0,-1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, -1));
508 mStencil[DensePt< 0, 1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, -1));
509 mStencil[DensePt< 0,-1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, 1));
510 mStencil[DensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
514 using BaseType::mCache;
515 using BaseType::mStencil;
525 template<
int i,
int j,
int k>
struct ThirteenPt {};
526 template<>
struct ThirteenPt< 0, 0, 0> {
enum { idx = 0 }; };
528 template<>
struct ThirteenPt< 1, 0, 0> {
enum { idx = 1 }; };
529 template<>
struct ThirteenPt< 0, 1, 0> {
enum { idx = 2 }; };
530 template<>
struct ThirteenPt< 0, 0, 1> {
enum { idx = 3 }; };
532 template<>
struct ThirteenPt<-1, 0, 0> {
enum { idx = 4 }; };
533 template<>
struct ThirteenPt< 0,-1, 0> {
enum { idx = 5 }; };
534 template<>
struct ThirteenPt< 0, 0,-1> {
enum { idx = 6 }; };
536 template<>
struct ThirteenPt< 2, 0, 0> {
enum { idx = 7 }; };
537 template<>
struct ThirteenPt< 0, 2, 0> {
enum { idx = 8 }; };
538 template<>
struct ThirteenPt< 0, 0, 2> {
enum { idx = 9 }; };
540 template<>
struct ThirteenPt<-2, 0, 0> {
enum { idx = 10 }; };
541 template<>
struct ThirteenPt< 0,-2, 0> {
enum { idx = 11 }; };
542 template<>
struct ThirteenPt< 0, 0,-2> {
enum { idx = 12 }; };
547 template<
typename Gr
idT,
bool IsSafe = true>
549 :
public BaseStencil<ThirteenPointStencil<GridT, IsSafe>, GridT, IsSafe>
558 static const int SIZE = 13;
563 template<
int i,
int j,
int k>
564 unsigned int pos()
const {
return ThirteenPt<i,j,k>::idx; }
567 inline void init(
const Coord& ijk)
569 mStencil[ThirteenPt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
570 mStencil[ThirteenPt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
571 mStencil[ThirteenPt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
572 mStencil[ThirteenPt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
574 mStencil[ThirteenPt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
575 mStencil[ThirteenPt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
576 mStencil[ThirteenPt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
577 mStencil[ThirteenPt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -2, 0));
579 mStencil[ThirteenPt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
580 mStencil[ThirteenPt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
581 mStencil[ThirteenPt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
582 mStencil[ThirteenPt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -2));
586 using BaseType::mCache;
587 using BaseType::mStencil;
597 template<
int i,
int j,
int k>
struct FourthDensePt {};
598 template<>
struct FourthDensePt< 0, 0, 0> {
enum { idx = 0 }; };
600 template<>
struct FourthDensePt<-2, 2, 0> {
enum { idx = 1 }; };
601 template<>
struct FourthDensePt<-1, 2, 0> {
enum { idx = 2 }; };
602 template<>
struct FourthDensePt< 0, 2, 0> {
enum { idx = 3 }; };
603 template<>
struct FourthDensePt< 1, 2, 0> {
enum { idx = 4 }; };
604 template<>
struct FourthDensePt< 2, 2, 0> {
enum { idx = 5 }; };
606 template<>
struct FourthDensePt<-2, 1, 0> {
enum { idx = 6 }; };
607 template<>
struct FourthDensePt<-1, 1, 0> {
enum { idx = 7 }; };
608 template<>
struct FourthDensePt< 0, 1, 0> {
enum { idx = 8 }; };
609 template<>
struct FourthDensePt< 1, 1, 0> {
enum { idx = 9 }; };
610 template<>
struct FourthDensePt< 2, 1, 0> {
enum { idx = 10 }; };
612 template<>
struct FourthDensePt<-2, 0, 0> {
enum { idx = 11 }; };
613 template<>
struct FourthDensePt<-1, 0, 0> {
enum { idx = 12 }; };
614 template<>
struct FourthDensePt< 1, 0, 0> {
enum { idx = 13 }; };
615 template<>
struct FourthDensePt< 2, 0, 0> {
enum { idx = 14 }; };
617 template<>
struct FourthDensePt<-2,-1, 0> {
enum { idx = 15 }; };
618 template<>
struct FourthDensePt<-1,-1, 0> {
enum { idx = 16 }; };
619 template<>
struct FourthDensePt< 0,-1, 0> {
enum { idx = 17 }; };
620 template<>
struct FourthDensePt< 1,-1, 0> {
enum { idx = 18 }; };
621 template<>
struct FourthDensePt< 2,-1, 0> {
enum { idx = 19 }; };
623 template<>
struct FourthDensePt<-2,-2, 0> {
enum { idx = 20 }; };
624 template<>
struct FourthDensePt<-1,-2, 0> {
enum { idx = 21 }; };
625 template<>
struct FourthDensePt< 0,-2, 0> {
enum { idx = 22 }; };
626 template<>
struct FourthDensePt< 1,-2, 0> {
enum { idx = 23 }; };
627 template<>
struct FourthDensePt< 2,-2, 0> {
enum { idx = 24 }; };
630 template<>
struct FourthDensePt<-2, 0, 2> {
enum { idx = 25 }; };
631 template<>
struct FourthDensePt<-1, 0, 2> {
enum { idx = 26 }; };
632 template<>
struct FourthDensePt< 0, 0, 2> {
enum { idx = 27 }; };
633 template<>
struct FourthDensePt< 1, 0, 2> {
enum { idx = 28 }; };
634 template<>
struct FourthDensePt< 2, 0, 2> {
enum { idx = 29 }; };
636 template<>
struct FourthDensePt<-2, 0, 1> {
enum { idx = 30 }; };
637 template<>
struct FourthDensePt<-1, 0, 1> {
enum { idx = 31 }; };
638 template<>
struct FourthDensePt< 0, 0, 1> {
enum { idx = 32 }; };
639 template<>
struct FourthDensePt< 1, 0, 1> {
enum { idx = 33 }; };
640 template<>
struct FourthDensePt< 2, 0, 1> {
enum { idx = 34 }; };
642 template<>
struct FourthDensePt<-2, 0,-1> {
enum { idx = 35 }; };
643 template<>
struct FourthDensePt<-1, 0,-1> {
enum { idx = 36 }; };
644 template<>
struct FourthDensePt< 0, 0,-1> {
enum { idx = 37 }; };
645 template<>
struct FourthDensePt< 1, 0,-1> {
enum { idx = 38 }; };
646 template<>
struct FourthDensePt< 2, 0,-1> {
enum { idx = 39 }; };
648 template<>
struct FourthDensePt<-2, 0,-2> {
enum { idx = 40 }; };
649 template<>
struct FourthDensePt<-1, 0,-2> {
enum { idx = 41 }; };
650 template<>
struct FourthDensePt< 0, 0,-2> {
enum { idx = 42 }; };
651 template<>
struct FourthDensePt< 1, 0,-2> {
enum { idx = 43 }; };
652 template<>
struct FourthDensePt< 2, 0,-2> {
enum { idx = 44 }; };
655 template<>
struct FourthDensePt< 0,-2, 2> {
enum { idx = 45 }; };
656 template<>
struct FourthDensePt< 0,-1, 2> {
enum { idx = 46 }; };
657 template<>
struct FourthDensePt< 0, 1, 2> {
enum { idx = 47 }; };
658 template<>
struct FourthDensePt< 0, 2, 2> {
enum { idx = 48 }; };
660 template<>
struct FourthDensePt< 0,-2, 1> {
enum { idx = 49 }; };
661 template<>
struct FourthDensePt< 0,-1, 1> {
enum { idx = 50 }; };
662 template<>
struct FourthDensePt< 0, 1, 1> {
enum { idx = 51 }; };
663 template<>
struct FourthDensePt< 0, 2, 1> {
enum { idx = 52 }; };
665 template<>
struct FourthDensePt< 0,-2,-1> {
enum { idx = 53 }; };
666 template<>
struct FourthDensePt< 0,-1,-1> {
enum { idx = 54 }; };
667 template<>
struct FourthDensePt< 0, 1,-1> {
enum { idx = 55 }; };
668 template<>
struct FourthDensePt< 0, 2,-1> {
enum { idx = 56 }; };
670 template<>
struct FourthDensePt< 0,-2,-2> {
enum { idx = 57 }; };
671 template<>
struct FourthDensePt< 0,-1,-2> {
enum { idx = 58 }; };
672 template<>
struct FourthDensePt< 0, 1,-2> {
enum { idx = 59 }; };
673 template<>
struct FourthDensePt< 0, 2,-2> {
enum { idx = 60 }; };
678 template<
typename Gr
idT,
bool IsSafe = true>
680 :
public BaseStencil<FourthOrderDenseStencil<GridT, IsSafe>, GridT, IsSafe>
689 static const int SIZE = 61;
694 template<
int i,
int j,
int k>
695 unsigned int pos()
const {
return FourthDensePt<i,j,k>::idx; }
698 inline void init(
const Coord& ijk)
700 mStencil[FourthDensePt<-2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 2, 0));
701 mStencil[FourthDensePt<-1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 2, 0));
702 mStencil[FourthDensePt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
703 mStencil[FourthDensePt< 1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 2, 0));
704 mStencil[FourthDensePt< 2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 2, 0));
706 mStencil[FourthDensePt<-2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 1, 0));
707 mStencil[FourthDensePt<-1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 1, 0));
708 mStencil[FourthDensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
709 mStencil[FourthDensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
710 mStencil[FourthDensePt< 2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 1, 0));
712 mStencil[FourthDensePt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
713 mStencil[FourthDensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
714 mStencil[FourthDensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
715 mStencil[FourthDensePt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
717 mStencil[FourthDensePt<-2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-1, 0));
718 mStencil[FourthDensePt<-1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-1, 0));
719 mStencil[FourthDensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 0));
720 mStencil[FourthDensePt< 1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-1, 0));
721 mStencil[FourthDensePt< 2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-1, 0));
723 mStencil[FourthDensePt<-2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-2, 0));
724 mStencil[FourthDensePt<-1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-2, 0));
725 mStencil[FourthDensePt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 0));
726 mStencil[FourthDensePt< 1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-2, 0));
727 mStencil[FourthDensePt< 2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-2, 0));
729 mStencil[FourthDensePt<-2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 2));
730 mStencil[FourthDensePt<-1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 2));
731 mStencil[FourthDensePt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
732 mStencil[FourthDensePt< 1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 2));
733 mStencil[FourthDensePt< 2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 2));
735 mStencil[FourthDensePt<-2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 1));
736 mStencil[FourthDensePt<-1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 1));
737 mStencil[FourthDensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
738 mStencil[FourthDensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 1));
739 mStencil[FourthDensePt< 2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 1));
741 mStencil[FourthDensePt<-2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-1));
742 mStencil[FourthDensePt<-1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-1));
743 mStencil[FourthDensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-1));
744 mStencil[FourthDensePt< 1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-1));
745 mStencil[FourthDensePt< 2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-1));
747 mStencil[FourthDensePt<-2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-2));
748 mStencil[FourthDensePt<-1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-2));
749 mStencil[FourthDensePt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-2));
750 mStencil[FourthDensePt< 1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-2));
751 mStencil[FourthDensePt< 2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-2));
754 mStencil[FourthDensePt< 0,-2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 2));
755 mStencil[FourthDensePt< 0,-1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 2));
756 mStencil[FourthDensePt< 0, 1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 2));
757 mStencil[FourthDensePt< 0, 2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 2));
759 mStencil[FourthDensePt< 0,-2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 1));
760 mStencil[FourthDensePt< 0,-1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 1));
761 mStencil[FourthDensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
762 mStencil[FourthDensePt< 0, 2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 1));
764 mStencil[FourthDensePt< 0,-2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-1));
765 mStencil[FourthDensePt< 0,-1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-1));
766 mStencil[FourthDensePt< 0, 1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-1));
767 mStencil[FourthDensePt< 0, 2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-1));
769 mStencil[FourthDensePt< 0,-2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-2));
770 mStencil[FourthDensePt< 0,-1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-2));
771 mStencil[FourthDensePt< 0, 1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-2));
772 mStencil[FourthDensePt< 0, 2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-2));
776 using BaseType::mCache;
777 using BaseType::mStencil;
787 template<
int i,
int j,
int k>
struct NineteenPt {};
788 template<>
struct NineteenPt< 0, 0, 0> {
enum { idx = 0 }; };
790 template<>
struct NineteenPt< 1, 0, 0> {
enum { idx = 1 }; };
791 template<>
struct NineteenPt< 0, 1, 0> {
enum { idx = 2 }; };
792 template<>
struct NineteenPt< 0, 0, 1> {
enum { idx = 3 }; };
794 template<>
struct NineteenPt<-1, 0, 0> {
enum { idx = 4 }; };
795 template<>
struct NineteenPt< 0,-1, 0> {
enum { idx = 5 }; };
796 template<>
struct NineteenPt< 0, 0,-1> {
enum { idx = 6 }; };
798 template<>
struct NineteenPt< 2, 0, 0> {
enum { idx = 7 }; };
799 template<>
struct NineteenPt< 0, 2, 0> {
enum { idx = 8 }; };
800 template<>
struct NineteenPt< 0, 0, 2> {
enum { idx = 9 }; };
802 template<>
struct NineteenPt<-2, 0, 0> {
enum { idx = 10 }; };
803 template<>
struct NineteenPt< 0,-2, 0> {
enum { idx = 11 }; };
804 template<>
struct NineteenPt< 0, 0,-2> {
enum { idx = 12 }; };
806 template<>
struct NineteenPt< 3, 0, 0> {
enum { idx = 13 }; };
807 template<>
struct NineteenPt< 0, 3, 0> {
enum { idx = 14 }; };
808 template<>
struct NineteenPt< 0, 0, 3> {
enum { idx = 15 }; };
810 template<>
struct NineteenPt<-3, 0, 0> {
enum { idx = 16 }; };
811 template<>
struct NineteenPt< 0,-3, 0> {
enum { idx = 17 }; };
812 template<>
struct NineteenPt< 0, 0,-3> {
enum { idx = 18 }; };
817 template<
typename Gr
idT,
bool IsSafe = true>
819 :
public BaseStencil<NineteenPointStencil<GridT, IsSafe>, GridT, IsSafe>
828 static const int SIZE = 19;
833 template<
int i,
int j,
int k>
834 unsigned int pos()
const {
return NineteenPt<i,j,k>::idx; }
837 inline void init(
const Coord& ijk)
839 mStencil[NineteenPt< 3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 0));
840 mStencil[NineteenPt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
841 mStencil[NineteenPt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
842 mStencil[NineteenPt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
843 mStencil[NineteenPt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
844 mStencil[NineteenPt<-3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 0));
846 mStencil[NineteenPt< 0, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 0));
847 mStencil[NineteenPt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
848 mStencil[NineteenPt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
849 mStencil[NineteenPt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
850 mStencil[NineteenPt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -2, 0));
851 mStencil[NineteenPt< 0,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -3, 0));
853 mStencil[NineteenPt< 0, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 3));
854 mStencil[NineteenPt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
855 mStencil[NineteenPt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
856 mStencil[NineteenPt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
857 mStencil[NineteenPt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -2));
858 mStencil[NineteenPt< 0, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -3));
862 using BaseType::mCache;
863 using BaseType::mStencil;
873 template<
int i,
int j,
int k>
struct SixthDensePt { };
874 template<>
struct SixthDensePt< 0, 0, 0> {
enum { idx = 0 }; };
876 template<>
struct SixthDensePt<-3, 3, 0> {
enum { idx = 1 }; };
877 template<>
struct SixthDensePt<-2, 3, 0> {
enum { idx = 2 }; };
878 template<>
struct SixthDensePt<-1, 3, 0> {
enum { idx = 3 }; };
879 template<>
struct SixthDensePt< 0, 3, 0> {
enum { idx = 4 }; };
880 template<>
struct SixthDensePt< 1, 3, 0> {
enum { idx = 5 }; };
881 template<>
struct SixthDensePt< 2, 3, 0> {
enum { idx = 6 }; };
882 template<>
struct SixthDensePt< 3, 3, 0> {
enum { idx = 7 }; };
884 template<>
struct SixthDensePt<-3, 2, 0> {
enum { idx = 8 }; };
885 template<>
struct SixthDensePt<-2, 2, 0> {
enum { idx = 9 }; };
886 template<>
struct SixthDensePt<-1, 2, 0> {
enum { idx = 10 }; };
887 template<>
struct SixthDensePt< 0, 2, 0> {
enum { idx = 11 }; };
888 template<>
struct SixthDensePt< 1, 2, 0> {
enum { idx = 12 }; };
889 template<>
struct SixthDensePt< 2, 2, 0> {
enum { idx = 13 }; };
890 template<>
struct SixthDensePt< 3, 2, 0> {
enum { idx = 14 }; };
892 template<>
struct SixthDensePt<-3, 1, 0> {
enum { idx = 15 }; };
893 template<>
struct SixthDensePt<-2, 1, 0> {
enum { idx = 16 }; };
894 template<>
struct SixthDensePt<-1, 1, 0> {
enum { idx = 17 }; };
895 template<>
struct SixthDensePt< 0, 1, 0> {
enum { idx = 18 }; };
896 template<>
struct SixthDensePt< 1, 1, 0> {
enum { idx = 19 }; };
897 template<>
struct SixthDensePt< 2, 1, 0> {
enum { idx = 20 }; };
898 template<>
struct SixthDensePt< 3, 1, 0> {
enum { idx = 21 }; };
900 template<>
struct SixthDensePt<-3, 0, 0> {
enum { idx = 22 }; };
901 template<>
struct SixthDensePt<-2, 0, 0> {
enum { idx = 23 }; };
902 template<>
struct SixthDensePt<-1, 0, 0> {
enum { idx = 24 }; };
903 template<>
struct SixthDensePt< 1, 0, 0> {
enum { idx = 25 }; };
904 template<>
struct SixthDensePt< 2, 0, 0> {
enum { idx = 26 }; };
905 template<>
struct SixthDensePt< 3, 0, 0> {
enum { idx = 27 }; };
908 template<>
struct SixthDensePt<-3,-1, 0> {
enum { idx = 28 }; };
909 template<>
struct SixthDensePt<-2,-1, 0> {
enum { idx = 29 }; };
910 template<>
struct SixthDensePt<-1,-1, 0> {
enum { idx = 30 }; };
911 template<>
struct SixthDensePt< 0,-1, 0> {
enum { idx = 31 }; };
912 template<>
struct SixthDensePt< 1,-1, 0> {
enum { idx = 32 }; };
913 template<>
struct SixthDensePt< 2,-1, 0> {
enum { idx = 33 }; };
914 template<>
struct SixthDensePt< 3,-1, 0> {
enum { idx = 34 }; };
917 template<>
struct SixthDensePt<-3,-2, 0> {
enum { idx = 35 }; };
918 template<>
struct SixthDensePt<-2,-2, 0> {
enum { idx = 36 }; };
919 template<>
struct SixthDensePt<-1,-2, 0> {
enum { idx = 37 }; };
920 template<>
struct SixthDensePt< 0,-2, 0> {
enum { idx = 38 }; };
921 template<>
struct SixthDensePt< 1,-2, 0> {
enum { idx = 39 }; };
922 template<>
struct SixthDensePt< 2,-2, 0> {
enum { idx = 40 }; };
923 template<>
struct SixthDensePt< 3,-2, 0> {
enum { idx = 41 }; };
926 template<>
struct SixthDensePt<-3,-3, 0> {
enum { idx = 42 }; };
927 template<>
struct SixthDensePt<-2,-3, 0> {
enum { idx = 43 }; };
928 template<>
struct SixthDensePt<-1,-3, 0> {
enum { idx = 44 }; };
929 template<>
struct SixthDensePt< 0,-3, 0> {
enum { idx = 45 }; };
930 template<>
struct SixthDensePt< 1,-3, 0> {
enum { idx = 46 }; };
931 template<>
struct SixthDensePt< 2,-3, 0> {
enum { idx = 47 }; };
932 template<>
struct SixthDensePt< 3,-3, 0> {
enum { idx = 48 }; };
935 template<>
struct SixthDensePt<-3, 0, 3> {
enum { idx = 49 }; };
936 template<>
struct SixthDensePt<-2, 0, 3> {
enum { idx = 50 }; };
937 template<>
struct SixthDensePt<-1, 0, 3> {
enum { idx = 51 }; };
938 template<>
struct SixthDensePt< 0, 0, 3> {
enum { idx = 52 }; };
939 template<>
struct SixthDensePt< 1, 0, 3> {
enum { idx = 53 }; };
940 template<>
struct SixthDensePt< 2, 0, 3> {
enum { idx = 54 }; };
941 template<>
struct SixthDensePt< 3, 0, 3> {
enum { idx = 55 }; };
944 template<>
struct SixthDensePt<-3, 0, 2> {
enum { idx = 56 }; };
945 template<>
struct SixthDensePt<-2, 0, 2> {
enum { idx = 57 }; };
946 template<>
struct SixthDensePt<-1, 0, 2> {
enum { idx = 58 }; };
947 template<>
struct SixthDensePt< 0, 0, 2> {
enum { idx = 59 }; };
948 template<>
struct SixthDensePt< 1, 0, 2> {
enum { idx = 60 }; };
949 template<>
struct SixthDensePt< 2, 0, 2> {
enum { idx = 61 }; };
950 template<>
struct SixthDensePt< 3, 0, 2> {
enum { idx = 62 }; };
952 template<>
struct SixthDensePt<-3, 0, 1> {
enum { idx = 63 }; };
953 template<>
struct SixthDensePt<-2, 0, 1> {
enum { idx = 64 }; };
954 template<>
struct SixthDensePt<-1, 0, 1> {
enum { idx = 65 }; };
955 template<>
struct SixthDensePt< 0, 0, 1> {
enum { idx = 66 }; };
956 template<>
struct SixthDensePt< 1, 0, 1> {
enum { idx = 67 }; };
957 template<>
struct SixthDensePt< 2, 0, 1> {
enum { idx = 68 }; };
958 template<>
struct SixthDensePt< 3, 0, 1> {
enum { idx = 69 }; };
961 template<>
struct SixthDensePt<-3, 0,-1> {
enum { idx = 70 }; };
962 template<>
struct SixthDensePt<-2, 0,-1> {
enum { idx = 71 }; };
963 template<>
struct SixthDensePt<-1, 0,-1> {
enum { idx = 72 }; };
964 template<>
struct SixthDensePt< 0, 0,-1> {
enum { idx = 73 }; };
965 template<>
struct SixthDensePt< 1, 0,-1> {
enum { idx = 74 }; };
966 template<>
struct SixthDensePt< 2, 0,-1> {
enum { idx = 75 }; };
967 template<>
struct SixthDensePt< 3, 0,-1> {
enum { idx = 76 }; };
970 template<>
struct SixthDensePt<-3, 0,-2> {
enum { idx = 77 }; };
971 template<>
struct SixthDensePt<-2, 0,-2> {
enum { idx = 78 }; };
972 template<>
struct SixthDensePt<-1, 0,-2> {
enum { idx = 79 }; };
973 template<>
struct SixthDensePt< 0, 0,-2> {
enum { idx = 80 }; };
974 template<>
struct SixthDensePt< 1, 0,-2> {
enum { idx = 81 }; };
975 template<>
struct SixthDensePt< 2, 0,-2> {
enum { idx = 82 }; };
976 template<>
struct SixthDensePt< 3, 0,-2> {
enum { idx = 83 }; };
979 template<>
struct SixthDensePt<-3, 0,-3> {
enum { idx = 84 }; };
980 template<>
struct SixthDensePt<-2, 0,-3> {
enum { idx = 85 }; };
981 template<>
struct SixthDensePt<-1, 0,-3> {
enum { idx = 86 }; };
982 template<>
struct SixthDensePt< 0, 0,-3> {
enum { idx = 87 }; };
983 template<>
struct SixthDensePt< 1, 0,-3> {
enum { idx = 88 }; };
984 template<>
struct SixthDensePt< 2, 0,-3> {
enum { idx = 89 }; };
985 template<>
struct SixthDensePt< 3, 0,-3> {
enum { idx = 90 }; };
988 template<>
struct SixthDensePt< 0,-3, 3> {
enum { idx = 91 }; };
989 template<>
struct SixthDensePt< 0,-2, 3> {
enum { idx = 92 }; };
990 template<>
struct SixthDensePt< 0,-1, 3> {
enum { idx = 93 }; };
991 template<>
struct SixthDensePt< 0, 1, 3> {
enum { idx = 94 }; };
992 template<>
struct SixthDensePt< 0, 2, 3> {
enum { idx = 95 }; };
993 template<>
struct SixthDensePt< 0, 3, 3> {
enum { idx = 96 }; };
995 template<>
struct SixthDensePt< 0,-3, 2> {
enum { idx = 97 }; };
996 template<>
struct SixthDensePt< 0,-2, 2> {
enum { idx = 98 }; };
997 template<>
struct SixthDensePt< 0,-1, 2> {
enum { idx = 99 }; };
998 template<>
struct SixthDensePt< 0, 1, 2> {
enum { idx = 100 }; };
999 template<>
struct SixthDensePt< 0, 2, 2> {
enum { idx = 101 }; };
1000 template<>
struct SixthDensePt< 0, 3, 2> {
enum { idx = 102 }; };
1002 template<>
struct SixthDensePt< 0,-3, 1> {
enum { idx = 103 }; };
1003 template<>
struct SixthDensePt< 0,-2, 1> {
enum { idx = 104 }; };
1004 template<>
struct SixthDensePt< 0,-1, 1> {
enum { idx = 105 }; };
1005 template<>
struct SixthDensePt< 0, 1, 1> {
enum { idx = 106 }; };
1006 template<>
struct SixthDensePt< 0, 2, 1> {
enum { idx = 107 }; };
1007 template<>
struct SixthDensePt< 0, 3, 1> {
enum { idx = 108 }; };
1009 template<>
struct SixthDensePt< 0,-3,-1> {
enum { idx = 109 }; };
1010 template<>
struct SixthDensePt< 0,-2,-1> {
enum { idx = 110 }; };
1011 template<>
struct SixthDensePt< 0,-1,-1> {
enum { idx = 111 }; };
1012 template<>
struct SixthDensePt< 0, 1,-1> {
enum { idx = 112 }; };
1013 template<>
struct SixthDensePt< 0, 2,-1> {
enum { idx = 113 }; };
1014 template<>
struct SixthDensePt< 0, 3,-1> {
enum { idx = 114 }; };
1016 template<>
struct SixthDensePt< 0,-3,-2> {
enum { idx = 115 }; };
1017 template<>
struct SixthDensePt< 0,-2,-2> {
enum { idx = 116 }; };
1018 template<>
struct SixthDensePt< 0,-1,-2> {
enum { idx = 117 }; };
1019 template<>
struct SixthDensePt< 0, 1,-2> {
enum { idx = 118 }; };
1020 template<>
struct SixthDensePt< 0, 2,-2> {
enum { idx = 119 }; };
1021 template<>
struct SixthDensePt< 0, 3,-2> {
enum { idx = 120 }; };
1023 template<>
struct SixthDensePt< 0,-3,-3> {
enum { idx = 121 }; };
1024 template<>
struct SixthDensePt< 0,-2,-3> {
enum { idx = 122 }; };
1025 template<>
struct SixthDensePt< 0,-1,-3> {
enum { idx = 123 }; };
1026 template<>
struct SixthDensePt< 0, 1,-3> {
enum { idx = 124 }; };
1027 template<>
struct SixthDensePt< 0, 2,-3> {
enum { idx = 125 }; };
1028 template<>
struct SixthDensePt< 0, 3,-3> {
enum { idx = 126 }; };
1033 template<
typename Gr
idT,
bool IsSafe = true>
1035 :
public BaseStencil<SixthOrderDenseStencil<GridT, IsSafe>, GridT, IsSafe>
1044 static const int SIZE = 127;
1049 template<
int i,
int j,
int k>
1050 unsigned int pos()
const {
return SixthDensePt<i,j,k>::idx; }
1053 inline void init(
const Coord& ijk)
1055 mStencil[SixthDensePt<-3, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 3, 0));
1056 mStencil[SixthDensePt<-2, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 3, 0));
1057 mStencil[SixthDensePt<-1, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 3, 0));
1058 mStencil[SixthDensePt< 0, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 0));
1059 mStencil[SixthDensePt< 1, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 3, 0));
1060 mStencil[SixthDensePt< 2, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 3, 0));
1061 mStencil[SixthDensePt< 3, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 3, 0));
1063 mStencil[SixthDensePt<-3, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 2, 0));
1064 mStencil[SixthDensePt<-2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 2, 0));
1065 mStencil[SixthDensePt<-1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 2, 0));
1066 mStencil[SixthDensePt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
1067 mStencil[SixthDensePt< 1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 2, 0));
1068 mStencil[SixthDensePt< 2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 2, 0));
1069 mStencil[SixthDensePt< 3, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 2, 0));
1071 mStencil[SixthDensePt<-3, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 1, 0));
1072 mStencil[SixthDensePt<-2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 1, 0));
1073 mStencil[SixthDensePt<-1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 1, 0));
1074 mStencil[SixthDensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
1075 mStencil[SixthDensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
1076 mStencil[SixthDensePt< 2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 1, 0));
1077 mStencil[SixthDensePt< 3, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 1, 0));
1079 mStencil[SixthDensePt<-3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 0));
1080 mStencil[SixthDensePt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
1081 mStencil[SixthDensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
1082 mStencil[SixthDensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
1083 mStencil[SixthDensePt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
1084 mStencil[SixthDensePt< 3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 0));
1086 mStencil[SixthDensePt<-3,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3,-1, 0));
1087 mStencil[SixthDensePt<-2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-1, 0));
1088 mStencil[SixthDensePt<-1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-1, 0));
1089 mStencil[SixthDensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 0));
1090 mStencil[SixthDensePt< 1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-1, 0));
1091 mStencil[SixthDensePt< 2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-1, 0));
1092 mStencil[SixthDensePt< 3,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3,-1, 0));
1094 mStencil[SixthDensePt<-3,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3,-2, 0));
1095 mStencil[SixthDensePt<-2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-2, 0));
1096 mStencil[SixthDensePt<-1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-2, 0));
1097 mStencil[SixthDensePt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 0));
1098 mStencil[SixthDensePt< 1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-2, 0));
1099 mStencil[SixthDensePt< 2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-2, 0));
1100 mStencil[SixthDensePt< 3,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3,-2, 0));
1102 mStencil[SixthDensePt<-3,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3,-3, 0));
1103 mStencil[SixthDensePt<-2,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-3, 0));
1104 mStencil[SixthDensePt<-1,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-3, 0));
1105 mStencil[SixthDensePt< 0,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 0));
1106 mStencil[SixthDensePt< 1,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-3, 0));
1107 mStencil[SixthDensePt< 2,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-3, 0));
1108 mStencil[SixthDensePt< 3,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3,-3, 0));
1110 mStencil[SixthDensePt<-3, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 3));
1111 mStencil[SixthDensePt<-2, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 3));
1112 mStencil[SixthDensePt<-1, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 3));
1113 mStencil[SixthDensePt< 0, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 3));
1114 mStencil[SixthDensePt< 1, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 3));
1115 mStencil[SixthDensePt< 2, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 3));
1116 mStencil[SixthDensePt< 3, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 3));
1118 mStencil[SixthDensePt<-3, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 2));
1119 mStencil[SixthDensePt<-2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 2));
1120 mStencil[SixthDensePt<-1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 2));
1121 mStencil[SixthDensePt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
1122 mStencil[SixthDensePt< 1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 2));
1123 mStencil[SixthDensePt< 2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 2));
1124 mStencil[SixthDensePt< 3, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 2));
1126 mStencil[SixthDensePt<-3, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 1));
1127 mStencil[SixthDensePt<-2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 1));
1128 mStencil[SixthDensePt<-1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 1));
1129 mStencil[SixthDensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
1130 mStencil[SixthDensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 1));
1131 mStencil[SixthDensePt< 2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 1));
1132 mStencil[SixthDensePt< 3, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 1));
1134 mStencil[SixthDensePt<-3, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0,-1));
1135 mStencil[SixthDensePt<-2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-1));
1136 mStencil[SixthDensePt<-1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-1));
1137 mStencil[SixthDensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-1));
1138 mStencil[SixthDensePt< 1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-1));
1139 mStencil[SixthDensePt< 2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-1));
1140 mStencil[SixthDensePt< 3, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0,-1));
1142 mStencil[SixthDensePt<-3, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0,-2));
1143 mStencil[SixthDensePt<-2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-2));
1144 mStencil[SixthDensePt<-1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-2));
1145 mStencil[SixthDensePt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-2));
1146 mStencil[SixthDensePt< 1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-2));
1147 mStencil[SixthDensePt< 2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-2));
1148 mStencil[SixthDensePt< 3, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0,-2));
1150 mStencil[SixthDensePt<-3, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0,-3));
1151 mStencil[SixthDensePt<-2, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-3));
1152 mStencil[SixthDensePt<-1, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-3));
1153 mStencil[SixthDensePt< 0, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-3));
1154 mStencil[SixthDensePt< 1, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-3));
1155 mStencil[SixthDensePt< 2, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-3));
1156 mStencil[SixthDensePt< 3, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0,-3));
1158 mStencil[SixthDensePt< 0,-3, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 3));
1159 mStencil[SixthDensePt< 0,-2, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 3));
1160 mStencil[SixthDensePt< 0,-1, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 3));
1161 mStencil[SixthDensePt< 0, 1, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 3));
1162 mStencil[SixthDensePt< 0, 2, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 3));
1163 mStencil[SixthDensePt< 0, 3, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 3));
1165 mStencil[SixthDensePt< 0,-3, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 2));
1166 mStencil[SixthDensePt< 0,-2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 2));
1167 mStencil[SixthDensePt< 0,-1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 2));
1168 mStencil[SixthDensePt< 0, 1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 2));
1169 mStencil[SixthDensePt< 0, 2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 2));
1170 mStencil[SixthDensePt< 0, 3, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 2));
1172 mStencil[SixthDensePt< 0,-3, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 1));
1173 mStencil[SixthDensePt< 0,-2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 1));
1174 mStencil[SixthDensePt< 0,-1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 1));
1175 mStencil[SixthDensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
1176 mStencil[SixthDensePt< 0, 2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 1));
1177 mStencil[SixthDensePt< 0, 3, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 1));
1179 mStencil[SixthDensePt< 0,-3,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3,-1));
1180 mStencil[SixthDensePt< 0,-2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-1));
1181 mStencil[SixthDensePt< 0,-1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-1));
1182 mStencil[SixthDensePt< 0, 1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-1));
1183 mStencil[SixthDensePt< 0, 2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-1));
1184 mStencil[SixthDensePt< 0, 3,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3,-1));
1186 mStencil[SixthDensePt< 0,-3,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3,-2));
1187 mStencil[SixthDensePt< 0,-2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-2));
1188 mStencil[SixthDensePt< 0,-1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-2));
1189 mStencil[SixthDensePt< 0, 1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-2));
1190 mStencil[SixthDensePt< 0, 2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-2));
1191 mStencil[SixthDensePt< 0, 3,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3,-2));
1193 mStencil[SixthDensePt< 0,-3,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3,-3));
1194 mStencil[SixthDensePt< 0,-2,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-3));
1195 mStencil[SixthDensePt< 0,-1,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-3));
1196 mStencil[SixthDensePt< 0, 1,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-3));
1197 mStencil[SixthDensePt< 0, 2,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-3));
1198 mStencil[SixthDensePt< 0, 3,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3,-3));
1202 using BaseType::mCache;
1203 using BaseType::mStencil;
1212 template<
int i,
int j,
int k>
struct GradPt {};
1213 template<>
struct GradPt< 0, 0, 0> {
enum { idx = 0 }; };
1214 template<>
struct GradPt< 1, 0, 0> {
enum { idx = 2 }; };
1215 template<>
struct GradPt< 0, 1, 0> {
enum { idx = 4 }; };
1216 template<>
struct GradPt< 0, 0, 1> {
enum { idx = 6 }; };
1217 template<>
struct GradPt<-1, 0, 0> {
enum { idx = 1 }; };
1218 template<>
struct GradPt< 0,-1, 0> {
enum { idx = 3 }; };
1219 template<>
struct GradPt< 0, 0,-1> {
enum { idx = 5 }; };
1228 template<
typename Gr
idT,
bool IsSafe = true>
1238 static const int SIZE = 7;
1242 , mInv2Dx(
ValueType(0.5 / grid.voxelSize()[0]))
1243 , mInvDx2(
ValueType(4.0 * mInv2Dx * mInv2Dx))
1250 , mInvDx2(
ValueType(4.0 * mInv2Dx * mInv2Dx))
1262 mStencil[0] - mStencil[1],
1263 mStencil[2] - mStencil[0],
1264 mStencil[0] - mStencil[3],
1265 mStencil[4] - mStencil[0],
1266 mStencil[0] - mStencil[5],
1267 mStencil[6] - mStencil[0]);
1278 mStencil[4] - mStencil[3],
1279 mStencil[6] - mStencil[5])*mInv2Dx;
1288 V[0]>0 ? mStencil[0] - mStencil[1] : mStencil[2] - mStencil[0],
1289 V[1]>0 ? mStencil[0] - mStencil[3] : mStencil[4] - mStencil[0],
1290 V[2]>0 ? mStencil[0] - mStencil[5] : mStencil[6] - mStencil[0])*2*mInv2Dx;
1297 return mInvDx2 * (mStencil[1] + mStencil[2] +
1298 mStencil[3] + mStencil[4] +
1299 mStencil[5] + mStencil[6] - 6*mStencil[0]);
1307 return (v[0]>0 ? (v[1]<0 || v[2]<0 || v[3]<0 || v[4]<0 || v[5]<0 || v[6]<0)
1308 : (v[1]>0 || v[2]>0 || v[3]>0 || v[4]>0 || v[5]>0 || v[6]>0));
1320 const Coord& ijk = BaseType::getCenterCoord();
1324 ijk[1] - d*(mStencil[4] - mStencil[3]),
1325 ijk[2] - d*(mStencil[6] - mStencil[5]));
1331 template<
int i,
int j,
int k>
1332 unsigned int pos()
const {
return GradPt<i,j,k>::idx; }
1336 inline void init(
const Coord& ijk)
1338 BaseType::template setValue<-1, 0, 0>(mCache.getValue(ijk.
offsetBy(-1, 0, 0)));
1339 BaseType::template setValue< 1, 0, 0>(mCache.getValue(ijk.
offsetBy( 1, 0, 0)));
1341 BaseType::template setValue< 0,-1, 0>(mCache.getValue(ijk.
offsetBy( 0,-1, 0)));
1342 BaseType::template setValue< 0, 1, 0>(mCache.getValue(ijk.
offsetBy( 0, 1, 0)));
1344 BaseType::template setValue< 0, 0,-1>(mCache.getValue(ijk.
offsetBy( 0, 0,-1)));
1345 BaseType::template setValue< 0, 0, 1>(mCache.getValue(ijk.
offsetBy( 0, 0, 1)));
1349 using BaseType::mCache;
1350 using BaseType::mStencil;
1362 template<
typename Gr
idT,
bool IsSafe = true>
1372 static const int SIZE = 19;
1377 , mInv2Dx(
ValueType(0.5 / grid.voxelSize()[0]))
1401 v1(v[2]-v[1], v[ 8]-v[ 7], v[14]-v[13], 0),
1402 v2(v[3]-v[2], v[ 9]-v[ 8], v[15]-v[14], 0),
1403 v3(v[0]-v[3], v[ 0]-v[ 9], v[ 0]-v[15], 0),
1404 v4(v[4]-v[0], v[10]-v[ 0], v[16]-v[ 0], 0),
1405 v5(v[5]-v[4], v[11]-v[10], v[17]-v[16], 0),
1406 v6(v[6]-v[5], v[12]-v[11], v[18]-v[17], 0),
1413 dP_xm =
math::WENO5(v[ 2]-v[ 1],v[ 3]-v[ 2],v[ 0]-v[ 3],v[ 4]-v[ 0],v[ 5]-v[ 4],mDx2),
1414 dP_xp =
math::WENO5(v[ 6]-v[ 5],v[ 5]-v[ 4],v[ 4]-v[ 0],v[ 0]-v[ 3],v[ 3]-v[ 2],mDx2),
1415 dP_ym =
math::WENO5(v[ 8]-v[ 7],v[ 9]-v[ 8],v[ 0]-v[ 9],v[10]-v[ 0],v[11]-v[10],mDx2),
1416 dP_yp =
math::WENO5(v[12]-v[11],v[11]-v[10],v[10]-v[ 0],v[ 0]-v[ 9],v[ 9]-v[ 8],mDx2),
1417 dP_zm =
math::WENO5(v[14]-v[13],v[15]-v[14],v[ 0]-v[15],v[16]-v[ 0],v[17]-v[16],mDx2),
1418 dP_zp =
math::WENO5(v[18]-v[17],v[17]-v[16],v[16]-v[ 0],v[ 0]-v[15],v[15]-v[14],mDx2);
1433 V[0]>0 ?
math::WENO5(v[ 2]-v[ 1],v[ 3]-v[ 2],v[ 0]-v[ 3], v[ 4]-v[ 0],v[ 5]-v[ 4],mDx2)
1434 :
math::WENO5(v[ 6]-v[ 5],v[ 5]-v[ 4],v[ 4]-v[ 0], v[ 0]-v[ 3],v[ 3]-v[ 2],mDx2),
1435 V[1]>0 ?
math::WENO5(v[ 8]-v[ 7],v[ 9]-v[ 8],v[ 0]-v[ 9], v[10]-v[ 0],v[11]-v[10],mDx2)
1436 :
math::WENO5(v[12]-v[11],v[11]-v[10],v[10]-v[ 0], v[ 0]-v[ 9],v[ 9]-v[ 8],mDx2),
1437 V[2]>0 ?
math::WENO5(v[14]-v[13],v[15]-v[14],v[ 0]-v[15], v[16]-v[ 0],v[17]-v[16],mDx2)
1438 :
math::WENO5(v[18]-v[17],v[17]-v[16],v[16]-v[ 0], v[ 0]-v[15],v[15]-v[14],mDx2));
1448 mStencil[10] - mStencil[ 9],
1449 mStencil[16] - mStencil[15]);
1460 mStencil[ 3] + mStencil[ 4] +
1461 mStencil[ 9] + mStencil[10] +
1462 mStencil[15] + mStencil[16] - 6*mStencil[0]);
1470 return (v[ 0]>0 ? (v[ 3]<0 || v[ 4]<0 || v[ 9]<0 || v[10]<0 || v[15]<0 || v[16]<0)
1471 : (v[ 3]>0 || v[ 4]>0 || v[ 9]>0 || v[10]>0 || v[15]>0 || v[16]>0));
1475 inline void init(
const Coord& ijk)
1477 mStencil[ 1] = mCache.getValue(ijk.
offsetBy(-3, 0, 0));
1478 mStencil[ 2] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
1479 mStencil[ 3] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
1480 mStencil[ 4] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
1481 mStencil[ 5] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
1482 mStencil[ 6] = mCache.getValue(ijk.
offsetBy( 3, 0, 0));
1484 mStencil[ 7] = mCache.getValue(ijk.
offsetBy( 0, -3, 0));
1485 mStencil[ 8] = mCache.getValue(ijk.
offsetBy( 0, -2, 0));
1486 mStencil[ 9] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
1487 mStencil[10] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
1488 mStencil[11] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
1489 mStencil[12] = mCache.getValue(ijk.
offsetBy( 0, 3, 0));
1491 mStencil[13] = mCache.getValue(ijk.
offsetBy( 0, 0, -3));
1492 mStencil[14] = mCache.getValue(ijk.
offsetBy( 0, 0, -2));
1493 mStencil[15] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
1494 mStencil[16] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
1495 mStencil[17] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
1496 mStencil[18] = mCache.getValue(ijk.
offsetBy( 0, 0, 3));
1500 using BaseType::mCache;
1501 using BaseType::mStencil;
1509 template<
typename Gr
idT,
bool IsSafe = true>
1519 static const int SIZE = 19;
1523 , mInv2Dx(
ValueType(0.5 / grid.voxelSize()[0]))
1524 , mInvDx2(
ValueType(4.0 * mInv2Dx * mInv2Dx))
1531 , mInvDx2(
ValueType(4.0 * mInv2Dx * mInv2Dx))
1565 mStencil[1] + mStencil[2] +
1566 mStencil[3] + mStencil[4] +
1567 mStencil[5] + mStencil[6] - 6*mStencil[0]);
1578 mStencil[2] - mStencil[1],
1579 mStencil[4] - mStencil[3],
1580 mStencil[6] - mStencil[5])*mInv2Dx;
1584 inline void init(
const Coord &ijk)
1586 mStencil[ 1] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
1587 mStencil[ 2] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
1589 mStencil[ 3] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
1590 mStencil[ 4] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
1592 mStencil[ 5] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
1593 mStencil[ 6] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
1595 mStencil[ 7] = mCache.getValue(ijk.
offsetBy(-1, -1, 0));
1596 mStencil[ 8] = mCache.getValue(ijk.
offsetBy( 1, -1, 0));
1597 mStencil[ 9] = mCache.getValue(ijk.
offsetBy(-1, 1, 0));
1598 mStencil[10] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
1600 mStencil[11] = mCache.getValue(ijk.
offsetBy(-1, 0, -1));
1601 mStencil[12] = mCache.getValue(ijk.
offsetBy( 1, 0, -1));
1602 mStencil[13] = mCache.getValue(ijk.
offsetBy(-1, 0, 1));
1603 mStencil[14] = mCache.getValue(ijk.
offsetBy( 1, 0, 1));
1605 mStencil[15] = mCache.getValue(ijk.
offsetBy( 0, -1, -1));
1606 mStencil[16] = mCache.getValue(ijk.
offsetBy( 0, 1, -1));
1607 mStencil[17] = mCache.getValue(ijk.
offsetBy( 0, -1, 1));
1608 mStencil[18] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
1615 Half(0.5), Quarter(0.25),
1616 Dx = Half * (mStencil[2] - mStencil[1]), Dx2 = Dx * Dx,
1617 Dy = Half * (mStencil[4] - mStencil[3]), Dy2 = Dy * Dy,
1618 Dz = Half * (mStencil[6] - mStencil[5]), Dz2 = Dz * Dz,
1619 normGrad = Dx2 + Dy2 + Dz2;
1625 Dxx = mStencil[2] - 2 * mStencil[0] + mStencil[1],
1626 Dyy = mStencil[4] - 2 * mStencil[0] + mStencil[3],
1627 Dzz = mStencil[6] - 2 * mStencil[0] + mStencil[5],
1628 Dxy = Quarter * (mStencil[10] - mStencil[ 8] + mStencil[7] - mStencil[ 9]),
1629 Dxz = Quarter * (mStencil[14] - mStencil[12] + mStencil[11] - mStencil[13]),
1630 Dyz = Quarter * (mStencil[18] - mStencil[16] + mStencil[15] - mStencil[17]);
1631 alpha = (Dx2*(Dyy+Dzz)+Dy2*(Dxx+Dzz)+Dz2*(Dxx+Dyy)-2*(Dx*(Dy*Dxy+Dz*Dxz)+Dy*Dz*Dyz));
1632 beta = std::sqrt(normGrad);
1637 using BaseType::mCache;
1638 using BaseType::mStencil;
1647 template<
typename Gr
idT,
bool IsSafe = true>
1659 , mHalfWidth(halfWidth)
1661 assert(halfWidth>0);
1670 BaseType::mCenter = ijk;
1675 template<
typename IterType>
1678 BaseType::mCenter = iter.getCoord();
1679 this->init(BaseType::mCenter);
1685 inline void init(
const Coord& ijk)
1689 for (p[1] = ijk[1]-mHalfWidth; p[1] <= q[1]; ++p[1]) {
1690 for (p[2] = ijk[2]-mHalfWidth; p[2] <= q[2]; ++p[2]) {
1691 mStencil[n++] = mCache.getValue(p);
1698 using BaseType::mCache;
1699 using BaseType::mStencil;
1700 const int mHalfWidth;
1708 #endif // OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED