VTK-m  2.2
ImplicitFunction.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_ImplicitFunction_h
11 #define vtk_m_ImplicitFunction_h
12 
13 #include <vtkm/Bounds.h>
14 #include <vtkm/Math.h>
15 #include <vtkm/VecVariable.h>
16 #include <vtkm/VectorAnalysis.h>
17 #include <vtkm/exec/Variant.h>
18 
19 // For interface class only.
21 
22 namespace vtkm
23 {
24 
25 //============================================================================
26 namespace internal
27 {
28 
38 template <typename Derived>
39 class ImplicitFunctionBase : public vtkm::cont::ExecutionAndControlObjectBase
40 {
41 public:
42  using Scalar = vtkm::FloatDefault;
43  using Vector = vtkm::Vec<Scalar, 3>;
44 
45  VTKM_EXEC_CONT Scalar Value(Scalar x, Scalar y, Scalar z) const
46  {
47  return reinterpret_cast<const Derived*>(this)->Value(Vector(x, y, z));
48  }
49 
50  VTKM_EXEC_CONT Vector Gradient(Scalar x, Scalar y, Scalar z) const
51  {
52  return reinterpret_cast<const Derived*>(this)->Gradient(Vector(x, y, z));
53  }
54 
55  VTKM_CONT Derived PrepareForExecution(vtkm::cont::DeviceAdapterId, vtkm::cont::Token&) const
56  {
57  return *reinterpret_cast<const Derived*>(this);
58  }
59 
60  VTKM_CONT Derived PrepareForControl() const { return *reinterpret_cast<const Derived*>(this); }
61 };
62 
63 } // namespace vtkm::internal
64 
65 //============================================================================
70 template <typename FunctionType>
72 {
73 public:
74  using Scalar = typename FunctionType::Scalar;
75  using Vector = typename FunctionType::Vector;
76 
77  ImplicitFunctionValueFunctor() = default;
78 
80  const vtkm::internal::ImplicitFunctionBase<FunctionType>& function)
81  : Function(reinterpret_cast<const FunctionType&>(function))
82  {
83  }
84 
85  VTKM_EXEC_CONT ImplicitFunctionValueFunctor(const FunctionType& function)
86  : Function(function)
87  {
88  }
89 
90  VTKM_EXEC_CONT Scalar operator()(const Vector& point) const
91  {
92  return this->Function.Value(point);
93  }
94 
95 private:
96  FunctionType Function;
97 };
98 
103 template <typename FunctionType>
105 {
106 public:
107  using Scalar = typename FunctionType::Scalar;
108  using Vector = typename FunctionType::Vector;
109 
111 
113  const vtkm::internal::ImplicitFunctionBase<FunctionType>& function)
114  : Function(reinterpret_cast<const FunctionType&>(function))
115  {
116  }
117 
118  VTKM_EXEC_CONT ImplicitFunctionGradientFunctor(const FunctionType& function)
119  : Function(function)
120  {
121  }
122 
124  {
125  return this->Function->Gradient(point);
126  }
127 
128 private:
129  FunctionType Function;
130 };
131 
132 //============================================================================
139 
140 class VTKM_ALWAYS_EXPORT Box : public internal::ImplicitFunctionBase<Box>
141 {
142 public:
145  : MinPoint(Vector(Scalar(-0.5)))
146  , MaxPoint(Vector(Scalar(0.5)))
147  {
148  }
149 
151  VTKM_EXEC_CONT Box(const Vector& minPoint, const Vector& maxPoint)
152  : MinPoint(minPoint)
153  , MaxPoint(maxPoint)
154  {
155  }
156 
158  VTKM_EXEC_CONT Box(Scalar xmin, Scalar xmax, Scalar ymin, Scalar ymax, Scalar zmin, Scalar zmax)
159  : MinPoint(xmin, ymin, zmin)
160  , MaxPoint(xmax, ymax, zmax)
161  {
162  }
163 
165  VTKM_CONT Box(const vtkm::Bounds& bounds) { this->SetBounds(bounds); }
166 
168  VTKM_CONT void SetMinPoint(const Vector& point) { this->MinPoint = point; }
169 
171  VTKM_CONT void SetMaxPoint(const Vector& point) { this->MaxPoint = point; }
172 
174  VTKM_EXEC_CONT const Vector& GetMinPoint() const { return this->MinPoint; }
175 
177  VTKM_EXEC_CONT const Vector& GetMaxPoint() const { return this->MaxPoint; }
178 
180  VTKM_CONT void SetBounds(const vtkm::Bounds& bounds)
181  {
182  this->SetMinPoint({ Scalar(bounds.X.Min), Scalar(bounds.Y.Min), Scalar(bounds.Z.Min) });
183  this->SetMaxPoint({ Scalar(bounds.X.Max), Scalar(bounds.Y.Max), Scalar(bounds.Z.Max) });
184  }
185 
188  {
189  return vtkm::Bounds(vtkm::Range(this->MinPoint[0], this->MaxPoint[0]),
190  vtkm::Range(this->MinPoint[1], this->MaxPoint[1]),
191  vtkm::Range(this->MinPoint[2], this->MaxPoint[2]));
192  }
193 
203  VTKM_EXEC_CONT Scalar Value(const Vector& point) const
204  {
205  Scalar minDistance = vtkm::NegativeInfinity32();
206  Scalar diff, t, dist;
207  Scalar distance = Scalar(0.0);
208  vtkm::IdComponent inside = 1;
209 
210  for (vtkm::IdComponent d = 0; d < 3; d++)
211  {
212  diff = this->MaxPoint[d] - this->MinPoint[d];
213  if (diff != Scalar(0.0))
214  {
215  t = (point[d] - this->MinPoint[d]) / diff;
216  // Outside before the box
217  if (t < Scalar(0.0))
218  {
219  inside = 0;
220  dist = this->MinPoint[d] - point[d];
221  }
222  // Outside after the box
223  else if (t > Scalar(1.0))
224  {
225  inside = 0;
226  dist = point[d] - this->MaxPoint[d];
227  }
228  else
229  {
230  // Inside the box in lower half
231  if (t <= Scalar(0.5))
232  {
233  dist = MinPoint[d] - point[d];
234  }
235  // Inside the box in upper half
236  else
237  {
238  dist = point[d] - MaxPoint[d];
239  }
240  if (dist > minDistance)
241  {
242  minDistance = dist;
243  }
244  }
245  }
246  else
247  {
248  dist = vtkm::Abs(point[d] - MinPoint[d]);
249  if (dist > Scalar(0.0))
250  {
251  inside = 0;
252  }
253  }
254  if (dist > Scalar(0.0))
255  {
256  distance += dist * dist;
257  }
258  }
259 
260  distance = vtkm::Sqrt(distance);
261  if (inside)
262  {
263  return minDistance;
264  }
265  else
266  {
267  return distance;
268  }
269  }
270 
278  VTKM_EXEC_CONT Vector Gradient(const Vector& point) const
279  {
280  vtkm::IdComponent minAxis = 0;
281  Scalar dist = 0.0;
282  Scalar minDist = vtkm::Infinity32();
283  vtkm::IdComponent3 location;
284  Vector normal(Scalar(0));
285  Vector inside(Scalar(0));
286  Vector outside(Scalar(0));
287  Vector center((this->MaxPoint + this->MinPoint) * Scalar(0.5));
288 
289  // Compute the location of the point with respect to the box
290  // Point will lie in one of 27 separate regions around or within the box
291  // Gradient vector is computed differently in each of the regions.
292  for (vtkm::IdComponent d = 0; d < 3; d++)
293  {
294  if (point[d] < this->MinPoint[d])
295  {
296  // Outside the box low end
297  location[d] = 0;
298  outside[d] = -1.0;
299  }
300  else if (point[d] > this->MaxPoint[d])
301  {
302  // Outside the box high end
303  location[d] = 2;
304  outside[d] = 1.0;
305  }
306  else
307  {
308  location[d] = 1;
309  if (point[d] <= center[d])
310  {
311  // Inside the box low end
312  dist = point[d] - this->MinPoint[d];
313  inside[d] = -1.0;
314  }
315  else
316  {
317  // Inside the box high end
318  dist = this->MaxPoint[d] - point[d];
319  inside[d] = 1.0;
320  }
321  if (dist < minDist) // dist is negative
322  {
323  minDist = dist;
324  minAxis = d;
325  }
326  }
327  }
328 
329  vtkm::Id indx = location[0] + 3 * location[1] + 9 * location[2];
330  switch (indx)
331  {
332  // verts - gradient points away from center point
333  case 0:
334  case 2:
335  case 6:
336  case 8:
337  case 18:
338  case 20:
339  case 24:
340  case 26:
341  for (vtkm::IdComponent d = 0; d < 3; d++)
342  {
343  normal[d] = point[d] - center[d];
344  }
345  vtkm::Normalize(normal);
346  break;
347 
348  // edges - gradient points out from axis of cube
349  case 1:
350  case 3:
351  case 5:
352  case 7:
353  case 9:
354  case 11:
355  case 15:
356  case 17:
357  case 19:
358  case 21:
359  case 23:
360  case 25:
361  for (vtkm::IdComponent d = 0; d < 3; d++)
362  {
363  if (outside[d] != 0.0)
364  {
365  normal[d] = point[d] - center[d];
366  }
367  else
368  {
369  normal[d] = 0.0;
370  }
371  }
372  vtkm::Normalize(normal);
373  break;
374 
375  // faces - gradient points perpendicular to face
376  case 4:
377  case 10:
378  case 12:
379  case 14:
380  case 16:
381  case 22:
382  for (vtkm::IdComponent d = 0; d < 3; d++)
383  {
384  normal[d] = outside[d];
385  }
386  break;
387 
388  // interior - gradient is perpendicular to closest face
389  case 13:
390  normal[0] = normal[1] = normal[2] = 0.0;
391  normal[minAxis] = inside[minAxis];
392  break;
393  default:
394  VTKM_ASSERT(false);
395  break;
396  }
397  return normal;
398  }
399 
400 private:
401  Vector MinPoint;
402  Vector MaxPoint;
403 };
404 
405 //============================================================================
416 class VTKM_ALWAYS_EXPORT Cylinder : public vtkm::internal::ImplicitFunctionBase<Cylinder>
417 {
418 public:
422  : Center(Scalar(0))
423  , Axis(Scalar(0), Scalar(1), Scalar(0))
424  , Radius(Scalar(0.5))
425  {
426  }
427 
430  VTKM_EXEC_CONT Cylinder(const Vector& axis, Scalar radius)
431  : Center(Scalar(0))
432  , Axis(axis)
433  , Radius(radius)
434  {
435  }
436 
438  VTKM_EXEC_CONT Cylinder(const Vector& center, const Vector& axis, Scalar radius)
439  : Center(center)
440  , Axis(vtkm::Normal(axis))
441  , Radius(radius)
442  {
443  }
444 
448  VTKM_CONT void SetCenter(const Vector& center) { this->Center = center; }
449 
451  VTKM_CONT void SetAxis(const Vector& axis) { this->Axis = vtkm::Normal(axis); }
452 
454  VTKM_CONT void SetRadius(Scalar radius) { this->Radius = radius; }
455 
465  VTKM_EXEC_CONT Scalar Value(const Vector& point) const
466  {
467  Vector x2c = point - this->Center;
468  FloatDefault proj = vtkm::Dot(this->Axis, x2c);
469  return vtkm::Dot(x2c, x2c) - (proj * proj) - (this->Radius * this->Radius);
470  }
471 
479  VTKM_EXEC_CONT Vector Gradient(const Vector& point) const
480  {
481  Vector x2c = point - this->Center;
482  FloatDefault t = this->Axis[0] * x2c[0] + this->Axis[1] * x2c[1] + this->Axis[2] * x2c[2];
483  vtkm::Vec<FloatDefault, 3> closestPoint = this->Center + (this->Axis * t);
484  return (point - closestPoint) * FloatDefault(2);
485  }
486 
487 private:
488  Vector Center;
489  Vector Axis;
490  Scalar Radius;
491 };
492 
493 //============================================================================
495 class VTKM_ALWAYS_EXPORT Frustum : public vtkm::internal::ImplicitFunctionBase<Frustum>
496 {
497 public:
499  Frustum() = default;
500 
502  VTKM_EXEC_CONT Frustum(const Vector points[6], const Vector normals[6])
503  {
504  this->SetPlanes(points, normals);
505  }
506 
510  VTKM_EXEC_CONT explicit Frustum(const Vector points[8]) { this->CreateFromPoints(points); }
511 
513  VTKM_EXEC void SetPlanes(const Vector points[6], const Vector normals[6])
514  {
515  for (vtkm::Id index : { 0, 1, 2, 3, 4, 5 })
516  {
517  this->Points[index] = points[index];
518  }
519  for (vtkm::Id index : { 0, 1, 2, 3, 4, 5 })
520  {
521  this->Normals[index] = normals[index];
522  }
523  }
524 
526  VTKM_EXEC void SetPlane(int idx, const Vector& point, const Vector& normal)
527  {
528  VTKM_ASSERT((idx >= 0) && (idx < 6));
529  this->Points[idx] = point;
530  this->Normals[idx] = normal;
531  }
532 
534  VTKM_EXEC_CONT void GetPlanes(Vector points[6], Vector normals[6]) const
535  {
536  for (vtkm::Id index : { 0, 1, 2, 3, 4, 5 })
537  {
538  points[index] = this->Points[index];
539  }
540  for (vtkm::Id index : { 0, 1, 2, 3, 4, 5 })
541  {
542  normals[index] = this->Normals[index];
543  }
544  }
545 
546  VTKM_EXEC_CONT const Vector* GetPoints() const { return this->Points; }
547 
548  VTKM_EXEC_CONT const Vector* GetNormals() const { return this->Normals; }
549 
553  VTKM_EXEC_CONT void CreateFromPoints(const Vector points[8])
554  {
555  // XXX(clang-format-3.9): 3.8 is silly. 3.9 makes it look like this.
556  // clang-format off
557  int planes[6][3] = {
558  { 3, 2, 0 }, { 4, 5, 7 }, { 0, 1, 4 }, { 1, 2, 5 }, { 2, 3, 6 }, { 3, 0, 7 }
559  };
560  // clang-format on
561 
562  for (int i = 0; i < 6; ++i)
563  {
564  const Vector& v0 = points[planes[i][0]];
565  const Vector& v1 = points[planes[i][1]];
566  const Vector& v2 = points[planes[i][2]];
567 
568  this->Points[i] = v0;
569  this->Normals[i] = vtkm::Normal(vtkm::TriangleNormal(v0, v1, v2));
570  }
571  }
572 
582  VTKM_EXEC_CONT Scalar Value(const Vector& point) const
583  {
584  Scalar maxVal = vtkm::NegativeInfinity<Scalar>();
585  for (vtkm::Id index : { 0, 1, 2, 3, 4, 5 })
586  {
587  const Vector& p = this->Points[index];
588  const Vector& n = this->Normals[index];
589  const Scalar val = vtkm::Dot(point - p, n);
590  maxVal = vtkm::Max(maxVal, val);
591  }
592  return maxVal;
593  }
594 
602  VTKM_EXEC_CONT Vector Gradient(const Vector& point) const
603  {
604  Scalar maxVal = vtkm::NegativeInfinity<Scalar>();
605  vtkm::Id maxValIdx = 0;
606  for (vtkm::Id index : { 0, 1, 2, 3, 4, 5 })
607  {
608  const Vector& p = this->Points[index];
609  const Vector& n = this->Normals[index];
610  Scalar val = vtkm::Dot(point - p, n);
611  if (val > maxVal)
612  {
613  maxVal = val;
614  maxValIdx = index;
615  }
616  }
617  return this->Normals[maxValIdx];
618  }
619 
620 private:
621  Vector Points[6] = { { -0.5f, 0.0f, 0.0f }, { 0.5f, 0.0f, 0.0f }, { 0.0f, -0.5f, 0.0f },
622  { 0.0f, 0.5f, 0.0f }, { 0.0f, 0.0f, -0.5f }, { 0.0f, 0.0f, 0.5f } };
623  Vector Normals[6] = { { -1.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f }, { 0.0f, -1.0f, 0.0f },
624  { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, 1.0f } };
625 };
626 
627 //============================================================================
634 class VTKM_ALWAYS_EXPORT Plane : public vtkm::internal::ImplicitFunctionBase<Plane>
635 {
636 public:
638  VTKM_EXEC_CONT explicit Plane(const Vector& normal = { 0, 0, 1 })
639  : Origin(Scalar(0))
640  , Normal(normal)
641  {
642  }
643 
645  VTKM_EXEC_CONT Plane(const Vector& origin, const Vector& normal)
646  : Origin(origin)
647  , Normal(normal)
648  {
649  }
650 
654  VTKM_CONT void SetOrigin(const Vector& origin) { this->Origin = origin; }
655 
662  VTKM_CONT void SetNormal(const Vector& normal) { this->Normal = normal; }
663 
665  VTKM_EXEC_CONT const Vector& GetOrigin() const { return this->Origin; }
667  VTKM_EXEC_CONT const Vector& GetNormal() const { return this->Normal; }
668 
678  VTKM_EXEC_CONT Scalar Value(const Vector& point) const
679  {
680  return vtkm::Dot(point - this->Origin, this->Normal);
681  }
682 
690  VTKM_EXEC_CONT Vector Gradient(const Vector&) const { return this->Normal; }
691 
692 private:
693  Vector Origin;
694  Vector Normal;
695 };
696 
697 //============================================================================
705 class VTKM_ALWAYS_EXPORT Sphere : public vtkm::internal::ImplicitFunctionBase<Sphere>
706 {
707 public:
709  VTKM_EXEC_CONT explicit Sphere(Scalar radius = 0.5)
710  : Radius(radius)
711  , Center(Scalar(0))
712  {
713  }
714 
716  VTKM_EXEC_CONT Sphere(Vector center, Scalar radius)
717  : Radius(radius)
718  , Center(center)
719  {
720  }
721 
723  VTKM_CONT void SetRadius(Scalar radius) { this->Radius = radius; }
724 
726  VTKM_CONT void SetCenter(const Vector& center) { this->Center = center; }
727 
729  VTKM_EXEC_CONT Scalar GetRadius() const { return this->Radius; }
730 
732  VTKM_EXEC_CONT const Vector& GetCenter() const { return this->Center; }
733 
743  VTKM_EXEC_CONT Scalar Value(const Vector& point) const
744  {
745  return vtkm::MagnitudeSquared(point - this->Center) - (this->Radius * this->Radius);
746  }
747 
755  VTKM_EXEC_CONT Vector Gradient(const Vector& point) const
756  {
757  return Scalar(2) * (point - this->Center);
758  }
759 
760 private:
761  Scalar Radius;
762  Vector Center;
763 };
764 
765 //============================================================================
771 template <vtkm::IdComponent MaxNumPlanes>
773  : public vtkm::internal::ImplicitFunctionBase<MultiPlane<MaxNumPlanes>>
774 {
775 public:
778  VTKM_CONT MultiPlane() = default;
779  template <vtkm::IdComponent SrcMaxPlanes>
781  : Planes(src.GetPlanes())
782  {
783  }
784  template <vtkm::IdComponent SrcMaxPlanes>
786  {
788  }
789  VTKM_CONT void AddPlane(const Vector& origin, const Vector& normal)
790  {
791  VTKM_ASSERT(this->Planes.GetNumberOfComponents() < MaxNumPlanes);
792  this->Planes.Append(Plane(origin, normal));
793  }
795  {
796  VTKM_ASSERT((idx >= 0) && (idx < MaxNumPlanes));
797  return this->Planes[idx];
798  }
800 
810  VTKM_EXEC_CONT Scalar Value(const Vector& point) const
811  {
812  Scalar maxVal = vtkm::NegativeInfinity<Scalar>();
813  vtkm::IdComponent NumPlanes = this->Planes.GetNumberOfComponents();
814  for (vtkm::IdComponent index = 0; index < NumPlanes; ++index)
815  {
816  const Vector& p = this->Planes[index].GetOrigin();
817  const Vector& n = this->Planes[index].GetNormal();
818  const Scalar val = vtkm::Dot(point - p, n);
819  maxVal = vtkm::Max(maxVal, val);
820  }
821  return maxVal;
822  }
823 
831  VTKM_EXEC_CONT Vector Gradient(const Vector& point) const
832  {
833  Scalar maxVal = vtkm::NegativeInfinity<Scalar>();
834  vtkm::IdComponent maxValIdx = 0;
835  vtkm::IdComponent NumPlanes = Planes.GetNumberOfComponents();
836  for (vtkm::IdComponent index = 0; index < NumPlanes; ++index)
837  {
838  const Vector& p = this->Planes[index].GetOrigin();
839  const Vector& n = this->Planes[index].GetNormal();
840  Scalar val = vtkm::Dot(point - p, n);
841  if (val > maxVal)
842  {
843  maxVal = val;
844  maxValIdx = index;
845  }
846  }
847  return this->Planes[maxValIdx].GetNormal();
848  }
849 
850 private:
852 };
853 
854 namespace detail
855 {
856 
858 {
859  template <typename ImplicitFunctionType>
860  VTKM_EXEC_CONT typename ImplicitFunctionType::Scalar operator()(
861  const ImplicitFunctionType& function,
862  const typename ImplicitFunctionType::Vector& point) const
863  {
864  return function.Value(point);
865  }
866 };
867 
868 struct ImplicitFunctionGradientFunctor
869 {
870  template <typename ImplicitFunctionType>
871  VTKM_EXEC_CONT typename ImplicitFunctionType::Vector operator()(
872  const ImplicitFunctionType& function,
873  const typename ImplicitFunctionType::Vector& point) const
874  {
875  return function.Gradient(point);
876  }
877 };
878 
879 } // namespace detail
880 
881 //============================================================================
898 template <typename... ImplicitFunctionTypes>
900  : public vtkm::internal::ImplicitFunctionBase<
901  ImplicitFunctionMultiplexer<ImplicitFunctionTypes...>>
902 {
903  vtkm::exec::Variant<ImplicitFunctionTypes...> Variant;
904 
905  using Superclass =
906  vtkm::internal::ImplicitFunctionBase<ImplicitFunctionMultiplexer<ImplicitFunctionTypes...>>;
907 
908 public:
909  using Scalar = typename Superclass::Scalar;
910  using Vector = typename Superclass::Vector;
911 
912  ImplicitFunctionMultiplexer() = default;
913 
914  template <typename FunctionType>
916  const vtkm::internal::ImplicitFunctionBase<FunctionType>& function)
917  : Variant(reinterpret_cast<const FunctionType&>(function))
918  {
919  }
920 
930  VTKM_EXEC_CONT Scalar Value(const Vector& point) const
931  {
932  return this->Variant.CastAndCall(detail::ImplicitFunctionValueFunctor{}, point);
933  }
934 
942  VTKM_EXEC_CONT Vector Gradient(const Vector& point) const
943  {
944  return this->Variant.CastAndCall(detail::ImplicitFunctionGradientFunctor{}, point);
945  }
946 };
947 
948 //============================================================================
966  : public vtkm::ImplicitFunctionMultiplexer<vtkm::Box,
967  vtkm::Cylinder,
968  vtkm::Frustum,
969  vtkm::Plane,
970  vtkm::Sphere,
971  vtkm::MultiPlane<3>>
972 {
976  vtkm::Plane,
977  vtkm::Sphere,
979 
980 public:
982 };
983 
984 } // namespace vtkm
985 
986 #endif //vtk_m_ImplicitFunction_h
vtkm::Box::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:203
vtkm::ImplicitFunctionMultiplexer::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:930
vtkm::Plane::Gradient
Vector Gradient(const Vector &) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:690
vtkm::MultiPlane
Implicit function for a MultiPlane.
Definition: ImplicitFunction.h:772
vtkm::Frustum::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:582
vtkm::ImplicitFunctionValueFunctor::Vector
typename FunctionType::Vector Vector
Definition: ImplicitFunction.h:75
vtkm::ImplicitFunctionGradientFunctor::ImplicitFunctionGradientFunctor
ImplicitFunctionGradientFunctor()=default
vtkm::Frustum::GetPlanes
void GetPlanes(Vector points[6], Vector normals[6]) const
Specifies the 6 planes of the frustum.
Definition: ImplicitFunction.h:534
vtkm::Frustum
Implicit function for a frustum.
Definition: ImplicitFunction.h:495
vtkm::ImplicitFunctionGeneral
Implicit function that can switch among known implicit function types.
Definition: ImplicitFunction.h:965
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm::Plane::SetOrigin
void SetOrigin(const Vector &origin)
Specify the origin of the plane.
Definition: ImplicitFunction.h:654
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::Sqrt
vtkm::Float32 Sqrt(vtkm::Float32 x)
Definition: Math.h:943
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::Cylinder::Center
Vector Center
Definition: ImplicitFunction.h:488
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::ImplicitFunctionValueFunctor::ImplicitFunctionValueFunctor
ImplicitFunctionValueFunctor()=default
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::ImplicitFunctionMultiplexer
Implicit function that can switch among different types.
Definition: ImplicitFunction.h:899
vtkm::Cylinder::SetRadius
void SetRadius(Scalar radius)
Specify the radius of the cylinder.
Definition: ImplicitFunction.h:454
vtkm::ImplicitFunctionGradientFunctor::Scalar
typename FunctionType::Scalar Scalar
Definition: ImplicitFunction.h:107
vtkm::Plane::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:678
vtkm::Sphere::Radius
Scalar Radius
Definition: ImplicitFunction.h:761
vtkm::Plane::GetOrigin
const Vector & GetOrigin() const
Specify the origin of the plane.
Definition: ImplicitFunction.h:665
vtkm::Cylinder::Axis
Vector Axis
Definition: ImplicitFunction.h:489
Variant.h
vtkm::Sphere::Sphere
Sphere(Scalar radius=0.5)
Construct a sphere with center at (0,0,0) and the given radius.
Definition: ImplicitFunction.h:709
vtkm::Cylinder::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:465
vtkm::ImplicitFunctionMultiplexer::ImplicitFunctionMultiplexer
ImplicitFunctionMultiplexer(const vtkm::internal::ImplicitFunctionBase< FunctionType > &function)
Definition: ImplicitFunction.h:915
vtkm::TriangleNormal
vtkm::Vec< typename detail::FloatingPointReturnType< T >::Type, 3 > TriangleNormal(const vtkm::Vec< T, 3 > &a, const vtkm::Vec< T, 3 > &b, const vtkm::Vec< T, 3 > &c)
Find the normal of a triangle.
Definition: VectorAnalysis.h:203
vtkm::Cylinder::Cylinder
Cylinder(const Vector &center, const Vector &axis, Scalar radius)
Construct a cylinder at the given center, axis, and radius.
Definition: ImplicitFunction.h:438
vtkm::MultiPlane::GetPlanes
vtkm::VecVariable< vtkm::Plane, MaxNumPlanes > GetPlanes() const
Definition: ImplicitFunction.h:799
vtkm::Plane::GetNormal
const Vector & GetNormal() const
Specify the normal vector to the plane.
Definition: ImplicitFunction.h:667
vtkm::Box::Box
Box(const vtkm::Bounds &bounds)
Construct a box that encompasses the given bounds.
Definition: ImplicitFunction.h:165
vtkm::MultiPlane::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:810
vtkm::ImplicitFunctionGradientFunctor::ImplicitFunctionGradientFunctor
ImplicitFunctionGradientFunctor(const vtkm::internal::ImplicitFunctionBase< FunctionType > &function)
Definition: ImplicitFunction.h:112
vtkm::Plane::SetNormal
void SetNormal(const Vector &normal)
Specify the normal vector to the plane.
Definition: ImplicitFunction.h:662
vtkm::ImplicitFunctionMultiplexer::Variant
vtkm::exec::Variant< ImplicitFunctionTypes... > Variant
Definition: ImplicitFunction.h:903
vtkm::Normal
T Normal(const T &x)
Returns a normalized version of the given vector.
Definition: VectorAnalysis.h:158
vtkm::ImplicitFunctionGradientFunctor
A helpful functor that calls the gradient method of a given ImplicitFunction.
Definition: ImplicitFunction.h:104
vtkm::Sphere::GetCenter
const Vector & GetCenter() const
Specify the center of the sphere.
Definition: ImplicitFunction.h:732
vtkm::Box::GetMaxPoint
const Vector & GetMaxPoint() const
Specify the maximum coordinate of the box.
Definition: ImplicitFunction.h:177
vtkm::cont::ExecutionAndControlObjectBase
Base ExecutionAndControlObjectBase class.
Definition: ExecutionAndControlObjectBase.h:28
VectorAnalysis.h
vtkm::Box::GetMinPoint
const Vector & GetMinPoint() const
Specify the minimum coordinate of the box.
Definition: ImplicitFunction.h:174
vtkm::Cylinder::Cylinder
Cylinder()
Construct cylinder radius of 0.5; centered at origin with axis along y coordinate axis.
Definition: ImplicitFunction.h:421
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::MultiPlane::GetPlane
vtkm::Plane GetPlane(int idx)
Definition: ImplicitFunction.h:794
vtkm::Frustum::GetPoints
const Vector * GetPoints() const
Definition: ImplicitFunction.h:546
vtkm::MagnitudeSquared
detail::FloatingPointReturnType< T >::Type MagnitudeSquared(const T &x)
Returns the square of the magnitude of a vector.
Definition: VectorAnalysis.h:64
vtkm::Cylinder::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:479
vtkm::ImplicitFunctionMultiplexer< vtkm::Box, vtkm::Cylinder, vtkm::Frustum, vtkm::Plane, vtkm::Sphere, vtkm::MultiPlane< 3 > >::Vector
typename Superclass::Vector Vector
Definition: ImplicitFunction.h:910
vtkm::MultiPlane::Scalar
vtkm::FloatDefault Scalar
Definition: ImplicitFunction.h:776
vtkm::Box::Box
Box()
Construct box with center at (0,0,0) and each side of length 1.0.
Definition: ImplicitFunction.h:144
Bounds.h
vtkm::Box::SetMinPoint
void SetMinPoint(const Vector &point)
Specify the minimum coordinate of the box.
Definition: ImplicitFunction.h:168
vtkm::ImplicitFunctionGradientFunctor::Function
FunctionType Function
Definition: ImplicitFunction.h:129
Math.h
vtkm::Frustum::SetPlanes
void SetPlanes(const Vector points[6], const Vector normals[6])
Specifies the 6 planes of the frustum.
Definition: ImplicitFunction.h:513
vtkm::MultiPlane::operator=
MultiPlane & operator=(const MultiPlane< SrcMaxPlanes > &src)
Definition: ImplicitFunction.h:785
vtkm::MultiPlane::Planes
vtkm::VecVariable< vtkm::Plane, MaxNumPlanes > Planes
Definition: ImplicitFunction.h:851
vtkm::ImplicitFunctionMultiplexer::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:942
vtkm::Box::SetBounds
void SetBounds(const vtkm::Bounds &bounds)
Specify the size and location of the box by the bounds it encompasses.
Definition: ImplicitFunction.h:180
vtkm::VecVariable< vtkm::Plane, MaxNumPlanes >
vtkm::Sphere::GetRadius
Scalar GetRadius() const
Specify the radius of the sphere.
Definition: ImplicitFunction.h:729
vtkm::MultiPlane::AddPlane
void AddPlane(const Vector &origin, const Vector &normal)
Definition: ImplicitFunction.h:789
vtkm::Frustum::GetNormals
const Vector * GetNormals() const
Definition: ImplicitFunction.h:548
vtkm::Cylinder::Radius
Scalar Radius
Definition: ImplicitFunction.h:490
vtkm::Box::GetBounds
vtkm::Bounds GetBounds() const
Specify the size and location of the box by the bounds it encompasses.
Definition: ImplicitFunction.h:187
vtkm::Sphere::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:755
vtkm::Frustum::CreateFromPoints
void CreateFromPoints(const Vector points[8])
Specifies the frustum as the 8 points of the bounding hexahedron.
Definition: ImplicitFunction.h:553
ExecutionAndControlObjectBase.h
vtkm::ImplicitFunctionMultiplexer< vtkm::Box, vtkm::Cylinder, vtkm::Frustum, vtkm::Plane, vtkm::Sphere, vtkm::MultiPlane< 3 > >::Scalar
typename Superclass::Scalar Scalar
Definition: ImplicitFunction.h:909
vtkm::Sphere::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:743
vtkm::Box::MinPoint
Vector MinPoint
Definition: ImplicitFunction.h:401
vtkm::Frustum::Frustum
Frustum(const Vector points[8])
Construct a frustum defined by the 8 points of the bounding hexahedron.
Definition: ImplicitFunction.h:510
vtkm::Normalize
void Normalize(T &x)
Changes a vector to be normal.
Definition: VectorAnalysis.h:169
vtkm::Bounds::Z
vtkm::Range Z
The range of values in the Z direction.
Definition: Bounds.h:39
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::ImplicitFunctionMultiplexer< vtkm::Box, vtkm::Cylinder, vtkm::Frustum, vtkm::Plane, vtkm::Sphere, vtkm::MultiPlane< 3 > >::Superclass
vtkm::internal::ImplicitFunctionBase< ImplicitFunctionMultiplexer< ImplicitFunctionTypes... > > Superclass
Definition: ImplicitFunction.h:906
vtkm::Bounds
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:29
vtkm::Cylinder::SetCenter
void SetCenter(const Vector &center)
Specify the center of the cylinder.
Definition: ImplicitFunction.h:448
vtkm::Sphere::SetCenter
void SetCenter(const Vector &center)
Specify the center of the sphere.
Definition: ImplicitFunction.h:726
vtkm::Sphere::Sphere
Sphere(Vector center, Scalar radius)
Construct a sphere with the given center and radius.
Definition: ImplicitFunction.h:716
vtkm::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
vtkm::Sphere
Represent a sphere of the given Dimension.
Definition: Geometry.h:27
vtkm::Vec
A short fixed-length array.
Definition: Types.h:357
vtkm::Frustum::Frustum
Frustum(const Vector points[6], const Vector normals[6])
Construct a frustum defined with 6 planes of the given points and normals.
Definition: ImplicitFunction.h:502
vtkm::FloatDefault
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:236
VecVariable.h
vtkm::MultiPlane::MultiPlane
MultiPlane(const MultiPlane< SrcMaxPlanes > &src)
Definition: ImplicitFunction.h:780
vtkm::ImplicitFunctionValueFunctor::ImplicitFunctionValueFunctor
ImplicitFunctionValueFunctor(const FunctionType &function)
Definition: ImplicitFunction.h:85
vtkm::Range::Min
vtkm::Float64 Min
The minumum value of the range (inclusive).
Definition: Range.h:34
vtkm::ImplicitFunctionValueFunctor::ImplicitFunctionValueFunctor
ImplicitFunctionValueFunctor(const vtkm::internal::ImplicitFunctionBase< FunctionType > &function)
Definition: ImplicitFunction.h:79
vtkm::ImplicitFunctionValueFunctor
A helpful functor that calls the value method of a given ImplicitFunction.
Definition: ImplicitFunction.h:71
vtkm::Frustum::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:602
vtkm::Box
Implicit function for a box.
Definition: ImplicitFunction.h:140
vtkm::ImplicitFunctionValueFunctor::operator()
Scalar operator()(const Vector &point) const
Definition: ImplicitFunction.h:90
vtkm::ImplicitFunctionMultiplexer::ImplicitFunctionMultiplexer
ImplicitFunctionMultiplexer()=default
vtkm::ImplicitFunctionValueFunctor::Scalar
typename FunctionType::Scalar Scalar
Definition: ImplicitFunction.h:74
vtkm::Bounds::X
vtkm::Range X
The range of values in the X direction.
Definition: Bounds.h:33
vtkm::Bounds::Y
vtkm::Range Y
The range of values in the Y direction.
Definition: Bounds.h:36
vtkm::MultiPlane::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:831
vtkm::Plane::Plane
Plane(const Vector &normal={ 0, 0, 1 })
Construct a plane through the origin with the given normal.
Definition: ImplicitFunction.h:638
vtkm::Box::Box
Box(const Vector &minPoint, const Vector &maxPoint)
Construct a box with the specified minimum and maximum point.
Definition: ImplicitFunction.h:151
vtkm::Range::Max
vtkm::Float64 Max
Tha maximum value of the range (inclusive).
Definition: Range.h:36
vtkm::Box::MaxPoint
Vector MaxPoint
Definition: ImplicitFunction.h:402
vtkm::Box::Box
Box(Scalar xmin, Scalar xmax, Scalar ymin, Scalar ymax, Scalar zmin, Scalar zmax)
Construct a box with the specified minimum and maximum point.
Definition: ImplicitFunction.h:158
VTKM_ALWAYS_EXPORT
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:89
vtkm::Cylinder::Cylinder
Cylinder(const Vector &axis, Scalar radius)
Construct a cylinder with the given axis and radius.
Definition: ImplicitFunction.h:430
vtkm::ImplicitFunctionGradientFunctor::Vector
typename FunctionType::Vector Vector
Definition: ImplicitFunction.h:108
vtkm::Plane
Represent a plane with a base point (origin) and normal vector.
Definition: Geometry.h:25
vtkm::Sphere::SetRadius
void SetRadius(Scalar radius)
Specify the radius of the sphere.
Definition: ImplicitFunction.h:723
vtkm::ImplicitFunctionValueFunctor::Function
FunctionType Function
Definition: ImplicitFunction.h:96
vtkm::Box::SetMaxPoint
void SetMaxPoint(const Vector &point)
Specify the maximum coordinate of the box.
Definition: ImplicitFunction.h:171
vtkm::Plane::Plane
Plane(const Vector &origin, const Vector &normal)
Construct a plane through the given point with the given normal.
Definition: ImplicitFunction.h:645
vtkm::Cylinder::SetAxis
void SetAxis(const Vector &axis)
Specify the direction of the axis of the cylinder.
Definition: ImplicitFunction.h:451
vtkm::Cylinder
Implicit function for a cylinder.
Definition: ImplicitFunction.h:416
vtkm::Box::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:278
vtkm::Frustum::SetPlane
void SetPlane(int idx, const Vector &point, const Vector &normal)
Set one of the 6 planes of the frustum.
Definition: ImplicitFunction.h:526
vtkm::ImplicitFunctionGradientFunctor::operator()
Vector operator()(const Vector &point) const
Definition: ImplicitFunction.h:123
vtkm::ImplicitFunctionGradientFunctor::ImplicitFunctionGradientFunctor
ImplicitFunctionGradientFunctor(const FunctionType &function)
Definition: ImplicitFunction.h:118
vtkm::Range
Represent a continuous scalar range of values.
Definition: Range.h:31