Viskores  1.0
ImplicitFunction.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_ImplicitFunction_h
19 #define viskores_ImplicitFunction_h
20 
21 #include <viskores/Bounds.h>
22 #include <viskores/Math.h>
23 #include <viskores/VecVariable.h>
25 #include <viskores/exec/Variant.h>
26 
27 // For interface class only.
29 
30 namespace viskores
31 {
32 
33 //============================================================================
34 namespace internal
35 {
36 
46 template <typename Derived>
47 class ImplicitFunctionBase : public viskores::cont::ExecutionAndControlObjectBase
48 {
49 public:
50  using Scalar = viskores::FloatDefault;
51  using Vector = viskores::Vec<Scalar, 3>;
52 
53  VISKORES_EXEC_CONT Scalar Value(Scalar x, Scalar y, Scalar z) const
54  {
55  return reinterpret_cast<const Derived*>(this)->Value(Vector(x, y, z));
56  }
57 
58  VISKORES_EXEC_CONT Vector Gradient(Scalar x, Scalar y, Scalar z) const
59  {
60  return reinterpret_cast<const Derived*>(this)->Gradient(Vector(x, y, z));
61  }
62 
63  VISKORES_CONT Derived PrepareForExecution(viskores::cont::DeviceAdapterId,
64  viskores::cont::Token&) const
65  {
66  return *reinterpret_cast<const Derived*>(this);
67  }
68 
69  VISKORES_CONT Derived PrepareForControl() const
70  {
71  return *reinterpret_cast<const Derived*>(this);
72  }
73 };
74 
75 } // namespace viskores::internal
76 
77 //============================================================================
82 template <typename FunctionType>
84 {
85 public:
86  using Scalar = typename FunctionType::Scalar;
87  using Vector = typename FunctionType::Vector;
88 
89  ImplicitFunctionValueFunctor() = default;
90 
92  const viskores::internal::ImplicitFunctionBase<FunctionType>& function)
93  : Function(reinterpret_cast<const FunctionType&>(function))
94  {
95  }
96 
97  VISKORES_EXEC_CONT ImplicitFunctionValueFunctor(const FunctionType& function)
98  : Function(function)
99  {
100  }
101 
103  {
104  return this->Function.Value(point);
105  }
106 
107 private:
108  FunctionType Function;
109 };
110 
115 template <typename FunctionType>
117 {
118 public:
119  using Scalar = typename FunctionType::Scalar;
120  using Vector = typename FunctionType::Vector;
121 
123 
125  const viskores::internal::ImplicitFunctionBase<FunctionType>& function)
126  : Function(reinterpret_cast<const FunctionType&>(function))
127  {
128  }
129 
131  : Function(function)
132  {
133  }
134 
136  {
137  return this->Function->Gradient(point);
138  }
139 
140 private:
141  FunctionType Function;
142 };
143 
144 //============================================================================
151 
152 class VISKORES_ALWAYS_EXPORT Box : public internal::ImplicitFunctionBase<Box>
153 {
154 public:
157  : MinPoint(Vector(Scalar(-0.5)))
158  , MaxPoint(Vector(Scalar(0.5)))
159  {
160  }
161 
163  VISKORES_EXEC_CONT Box(const Vector& minPoint, const Vector& maxPoint)
164  : MinPoint(minPoint)
165  , MaxPoint(maxPoint)
166  {
167  }
168 
170  VISKORES_EXEC_CONT Box(Scalar xmin,
171  Scalar xmax,
172  Scalar ymin,
173  Scalar ymax,
174  Scalar zmin,
175  Scalar zmax)
176  : MinPoint(xmin, ymin, zmin)
177  , MaxPoint(xmax, ymax, zmax)
178  {
179  }
180 
182  VISKORES_CONT Box(const viskores::Bounds& bounds) { this->SetBounds(bounds); }
183 
185  VISKORES_CONT void SetMinPoint(const Vector& point) { this->MinPoint = point; }
186 
188  VISKORES_CONT void SetMaxPoint(const Vector& point) { this->MaxPoint = point; }
189 
191  VISKORES_EXEC_CONT const Vector& GetMinPoint() const { return this->MinPoint; }
192 
194  VISKORES_EXEC_CONT const Vector& GetMaxPoint() const { return this->MaxPoint; }
195 
198  {
199  this->SetMinPoint({ Scalar(bounds.X.Min), Scalar(bounds.Y.Min), Scalar(bounds.Z.Min) });
200  this->SetMaxPoint({ Scalar(bounds.X.Max), Scalar(bounds.Y.Max), Scalar(bounds.Z.Max) });
201  }
202 
205  {
206  return viskores::Bounds(viskores::Range(this->MinPoint[0], this->MaxPoint[0]),
207  viskores::Range(this->MinPoint[1], this->MaxPoint[1]),
208  viskores::Range(this->MinPoint[2], this->MaxPoint[2]));
209  }
210 
220  VISKORES_EXEC_CONT Scalar Value(const Vector& point) const
221  {
222  Scalar minDistance = viskores::NegativeInfinity32();
223  Scalar diff, t, dist;
224  Scalar distance = Scalar(0.0);
225  viskores::IdComponent inside = 1;
226 
227  for (viskores::IdComponent d = 0; d < 3; d++)
228  {
229  diff = this->MaxPoint[d] - this->MinPoint[d];
230  if (diff != Scalar(0.0))
231  {
232  t = (point[d] - this->MinPoint[d]) / diff;
233  // Outside before the box
234  if (t < Scalar(0.0))
235  {
236  inside = 0;
237  dist = this->MinPoint[d] - point[d];
238  }
239  // Outside after the box
240  else if (t > Scalar(1.0))
241  {
242  inside = 0;
243  dist = point[d] - this->MaxPoint[d];
244  }
245  else
246  {
247  // Inside the box in lower half
248  if (t <= Scalar(0.5))
249  {
250  dist = MinPoint[d] - point[d];
251  }
252  // Inside the box in upper half
253  else
254  {
255  dist = point[d] - MaxPoint[d];
256  }
257  if (dist > minDistance)
258  {
259  minDistance = dist;
260  }
261  }
262  }
263  else
264  {
265  dist = viskores::Abs(point[d] - MinPoint[d]);
266  if (dist > Scalar(0.0))
267  {
268  inside = 0;
269  }
270  }
271  if (dist > Scalar(0.0))
272  {
273  distance += dist * dist;
274  }
275  }
276 
277  distance = viskores::Sqrt(distance);
278  if (inside)
279  {
280  return minDistance;
281  }
282  else
283  {
284  return distance;
285  }
286  }
287 
295  VISKORES_EXEC_CONT Vector Gradient(const Vector& point) const
296  {
297  viskores::IdComponent minAxis = 0;
298  Scalar dist = 0.0;
299  Scalar minDist = viskores::Infinity32();
300  viskores::IdComponent3 location;
301  Vector normal(Scalar(0));
302  Vector inside(Scalar(0));
303  Vector outside(Scalar(0));
304  Vector center((this->MaxPoint + this->MinPoint) * Scalar(0.5));
305 
306  // Compute the location of the point with respect to the box
307  // Point will lie in one of 27 separate regions around or within the box
308  // Gradient vector is computed differently in each of the regions.
309  for (viskores::IdComponent d = 0; d < 3; d++)
310  {
311  if (point[d] < this->MinPoint[d])
312  {
313  // Outside the box low end
314  location[d] = 0;
315  outside[d] = -1.0;
316  }
317  else if (point[d] > this->MaxPoint[d])
318  {
319  // Outside the box high end
320  location[d] = 2;
321  outside[d] = 1.0;
322  }
323  else
324  {
325  location[d] = 1;
326  if (point[d] <= center[d])
327  {
328  // Inside the box low end
329  dist = point[d] - this->MinPoint[d];
330  inside[d] = -1.0;
331  }
332  else
333  {
334  // Inside the box high end
335  dist = this->MaxPoint[d] - point[d];
336  inside[d] = 1.0;
337  }
338  if (dist < minDist) // dist is negative
339  {
340  minDist = dist;
341  minAxis = d;
342  }
343  }
344  }
345 
346  viskores::Id indx = location[0] + 3 * location[1] + 9 * location[2];
347  switch (indx)
348  {
349  // verts - gradient points away from center point
350  case 0:
351  case 2:
352  case 6:
353  case 8:
354  case 18:
355  case 20:
356  case 24:
357  case 26:
358  for (viskores::IdComponent d = 0; d < 3; d++)
359  {
360  normal[d] = point[d] - center[d];
361  }
362  viskores::Normalize(normal);
363  break;
364 
365  // edges - gradient points out from axis of cube
366  case 1:
367  case 3:
368  case 5:
369  case 7:
370  case 9:
371  case 11:
372  case 15:
373  case 17:
374  case 19:
375  case 21:
376  case 23:
377  case 25:
378  for (viskores::IdComponent d = 0; d < 3; d++)
379  {
380  if (outside[d] != 0.0)
381  {
382  normal[d] = point[d] - center[d];
383  }
384  else
385  {
386  normal[d] = 0.0;
387  }
388  }
389  viskores::Normalize(normal);
390  break;
391 
392  // faces - gradient points perpendicular to face
393  case 4:
394  case 10:
395  case 12:
396  case 14:
397  case 16:
398  case 22:
399  for (viskores::IdComponent d = 0; d < 3; d++)
400  {
401  normal[d] = outside[d];
402  }
403  break;
404 
405  // interior - gradient is perpendicular to closest face
406  case 13:
407  normal[0] = normal[1] = normal[2] = 0.0;
408  normal[minAxis] = inside[minAxis];
409  break;
410  default:
411  VISKORES_ASSERT(false);
412  break;
413  }
414  return normal;
415  }
416 
417 private:
418  Vector MinPoint;
419  Vector MaxPoint;
420 };
421 
422 //============================================================================
433 class VISKORES_ALWAYS_EXPORT Cylinder : public viskores::internal::ImplicitFunctionBase<Cylinder>
434 {
435 public:
439  : Center(Scalar(0))
440  , Axis(Scalar(0), Scalar(1), Scalar(0))
441  , Radius(Scalar(0.5))
442  {
443  }
444 
447  VISKORES_EXEC_CONT Cylinder(const Vector& axis, Scalar radius)
448  : Center(Scalar(0))
449  , Axis(axis)
450  , Radius(radius)
451  {
452  }
453 
455  VISKORES_EXEC_CONT Cylinder(const Vector& center, const Vector& axis, Scalar radius)
456  : Center(center)
457  , Axis(viskores::Normal(axis))
458  , Radius(radius)
459  {
460  }
461 
465  VISKORES_CONT void SetCenter(const Vector& center) { this->Center = center; }
466 
468  VISKORES_CONT void SetAxis(const Vector& axis) { this->Axis = viskores::Normal(axis); }
469 
471  VISKORES_CONT void SetRadius(Scalar radius) { this->Radius = radius; }
472 
482  VISKORES_EXEC_CONT Scalar Value(const Vector& point) const
483  {
484  Vector x2c = point - this->Center;
485  FloatDefault proj = viskores::Dot(this->Axis, x2c);
486  return viskores::Dot(x2c, x2c) - (proj * proj) - (this->Radius * this->Radius);
487  }
488 
496  VISKORES_EXEC_CONT Vector Gradient(const Vector& point) const
497  {
498  Vector x2c = point - this->Center;
499  FloatDefault t = this->Axis[0] * x2c[0] + this->Axis[1] * x2c[1] + this->Axis[2] * x2c[2];
500  viskores::Vec<FloatDefault, 3> closestPoint = this->Center + (this->Axis * t);
501  return (point - closestPoint) * FloatDefault(2);
502  }
503 
504 private:
505  Vector Center;
506  Vector Axis;
507  Scalar Radius;
508 };
509 
510 //============================================================================
512 class VISKORES_ALWAYS_EXPORT Frustum : public viskores::internal::ImplicitFunctionBase<Frustum>
513 {
514 public:
516  Frustum() = default;
517 
519  VISKORES_EXEC_CONT Frustum(const Vector points[6], const Vector normals[6])
520  {
521  this->SetPlanes(points, normals);
522  }
523 
527  VISKORES_EXEC_CONT explicit Frustum(const Vector points[8]) { this->CreateFromPoints(points); }
528 
530  VISKORES_EXEC void SetPlanes(const Vector points[6], const Vector normals[6])
531  {
532  for (viskores::Id index : { 0, 1, 2, 3, 4, 5 })
533  {
534  this->Points[index] = points[index];
535  }
536  for (viskores::Id index : { 0, 1, 2, 3, 4, 5 })
537  {
538  this->Normals[index] = normals[index];
539  }
540  }
541 
543  VISKORES_EXEC void SetPlane(int idx, const Vector& point, const Vector& normal)
544  {
545  VISKORES_ASSERT((idx >= 0) && (idx < 6));
546  this->Points[idx] = point;
547  this->Normals[idx] = normal;
548  }
549 
551  VISKORES_EXEC_CONT void GetPlanes(Vector points[6], Vector normals[6]) const
552  {
553  for (viskores::Id index : { 0, 1, 2, 3, 4, 5 })
554  {
555  points[index] = this->Points[index];
556  }
557  for (viskores::Id index : { 0, 1, 2, 3, 4, 5 })
558  {
559  normals[index] = this->Normals[index];
560  }
561  }
562 
563  VISKORES_EXEC_CONT const Vector* GetPoints() const { return this->Points; }
564 
565  VISKORES_EXEC_CONT const Vector* GetNormals() const { return this->Normals; }
566 
570  VISKORES_EXEC_CONT void CreateFromPoints(const Vector points[8])
571  {
572  // XXX(clang-format-3.9): 3.8 is silly. 3.9 makes it look like this.
573  // clang-format off
574  int planes[6][3] = {
575  { 3, 2, 0 }, { 4, 5, 7 }, { 0, 1, 4 }, { 1, 2, 5 }, { 2, 3, 6 }, { 3, 0, 7 }
576  };
577  // clang-format on
578 
579  for (int i = 0; i < 6; ++i)
580  {
581  const Vector& v0 = points[planes[i][0]];
582  const Vector& v1 = points[planes[i][1]];
583  const Vector& v2 = points[planes[i][2]];
584 
585  this->Points[i] = v0;
586  this->Normals[i] = viskores::Normal(viskores::TriangleNormal(v0, v1, v2));
587  }
588  }
589 
599  VISKORES_EXEC_CONT Scalar Value(const Vector& point) const
600  {
601  Scalar maxVal = viskores::NegativeInfinity<Scalar>();
602  for (viskores::Id index : { 0, 1, 2, 3, 4, 5 })
603  {
604  const Vector& p = this->Points[index];
605  const Vector& n = this->Normals[index];
606  const Scalar val = viskores::Dot(point - p, n);
607  maxVal = viskores::Max(maxVal, val);
608  }
609  return maxVal;
610  }
611 
619  VISKORES_EXEC_CONT Vector Gradient(const Vector& point) const
620  {
621  Scalar maxVal = viskores::NegativeInfinity<Scalar>();
622  viskores::Id maxValIdx = 0;
623  for (viskores::Id index : { 0, 1, 2, 3, 4, 5 })
624  {
625  const Vector& p = this->Points[index];
626  const Vector& n = this->Normals[index];
627  Scalar val = viskores::Dot(point - p, n);
628  if (val > maxVal)
629  {
630  maxVal = val;
631  maxValIdx = index;
632  }
633  }
634  return this->Normals[maxValIdx];
635  }
636 
637 private:
638  Vector Points[6] = { { -0.5f, 0.0f, 0.0f }, { 0.5f, 0.0f, 0.0f }, { 0.0f, -0.5f, 0.0f },
639  { 0.0f, 0.5f, 0.0f }, { 0.0f, 0.0f, -0.5f }, { 0.0f, 0.0f, 0.5f } };
640  Vector Normals[6] = { { -1.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f }, { 0.0f, -1.0f, 0.0f },
641  { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, 1.0f } };
642 };
643 
644 //============================================================================
651 class VISKORES_ALWAYS_EXPORT Plane : public viskores::internal::ImplicitFunctionBase<Plane>
652 {
653 public:
655  VISKORES_EXEC_CONT explicit Plane(const Vector& normal = { 0, 0, 1 })
656  : Origin(Scalar(0))
657  , Normal(normal)
658  {
659  }
660 
662  VISKORES_EXEC_CONT Plane(const Vector& origin, const Vector& normal)
663  : Origin(origin)
664  , Normal(normal)
665  {
666  }
667 
671  VISKORES_CONT void SetOrigin(const Vector& origin) { this->Origin = origin; }
672 
679  VISKORES_CONT void SetNormal(const Vector& normal) { this->Normal = normal; }
680 
682  VISKORES_EXEC_CONT const Vector& GetOrigin() const { return this->Origin; }
684  VISKORES_EXEC_CONT const Vector& GetNormal() const { return this->Normal; }
685 
695  VISKORES_EXEC_CONT Scalar Value(const Vector& point) const
696  {
697  return viskores::Dot(point - this->Origin, this->Normal);
698  }
699 
707  VISKORES_EXEC_CONT Vector Gradient(const Vector&) const { return this->Normal; }
708 
709 private:
710  Vector Origin;
711  Vector Normal;
712 };
713 
714 //============================================================================
722 class VISKORES_ALWAYS_EXPORT Sphere : public viskores::internal::ImplicitFunctionBase<Sphere>
723 {
724 public:
726  VISKORES_EXEC_CONT explicit Sphere(Scalar radius = 0.5)
727  : Radius(radius)
728  , Center(Scalar(0))
729  {
730  }
731 
733  VISKORES_EXEC_CONT Sphere(Vector center, Scalar radius)
734  : Radius(radius)
735  , Center(center)
736  {
737  }
738 
740  VISKORES_CONT void SetRadius(Scalar radius) { this->Radius = radius; }
741 
743  VISKORES_CONT void SetCenter(const Vector& center) { this->Center = center; }
744 
746  VISKORES_EXEC_CONT Scalar GetRadius() const { return this->Radius; }
747 
749  VISKORES_EXEC_CONT const Vector& GetCenter() const { return this->Center; }
750 
760  VISKORES_EXEC_CONT Scalar Value(const Vector& point) const
761  {
762  return viskores::MagnitudeSquared(point - this->Center) - (this->Radius * this->Radius);
763  }
764 
773  {
774  return Scalar(2) * (point - this->Center);
775  }
776 
777 private:
778  Scalar Radius;
779  Vector Center;
780 };
781 
782 //============================================================================
788 template <viskores::IdComponent MaxNumPlanes>
789 class VISKORES_ALWAYS_EXPORT MultiPlane
790  : public viskores::internal::ImplicitFunctionBase<MultiPlane<MaxNumPlanes>>
791 {
792 public:
795  VISKORES_CONT MultiPlane() = default;
796  template <viskores::IdComponent SrcMaxPlanes>
798  : Planes(src.GetPlanes())
799  {
800  }
801  template <viskores::IdComponent SrcMaxPlanes>
803  {
805  }
806  VISKORES_CONT void AddPlane(const Vector& origin, const Vector& normal)
807  {
808  VISKORES_ASSERT(this->Planes.GetNumberOfComponents() < MaxNumPlanes);
809  this->Planes.Append(Plane(origin, normal));
810  }
812  {
813  VISKORES_ASSERT((idx >= 0) && (idx < MaxNumPlanes));
814  return this->Planes[idx];
815  }
817  {
818  return this->Planes;
819  }
820 
830  VISKORES_EXEC_CONT Scalar Value(const Vector& point) const
831  {
832  Scalar maxVal = viskores::NegativeInfinity<Scalar>();
833  viskores::IdComponent NumPlanes = this->Planes.GetNumberOfComponents();
834  for (viskores::IdComponent index = 0; index < NumPlanes; ++index)
835  {
836  const Vector& p = this->Planes[index].GetOrigin();
837  const Vector& n = this->Planes[index].GetNormal();
838  const Scalar val = viskores::Dot(point - p, n);
839  maxVal = viskores::Max(maxVal, val);
840  }
841  return maxVal;
842  }
843 
852  {
853  Scalar maxVal = viskores::NegativeInfinity<Scalar>();
854  viskores::IdComponent maxValIdx = 0;
855  viskores::IdComponent NumPlanes = Planes.GetNumberOfComponents();
856  for (viskores::IdComponent index = 0; index < NumPlanes; ++index)
857  {
858  const Vector& p = this->Planes[index].GetOrigin();
859  const Vector& n = this->Planes[index].GetNormal();
860  Scalar val = viskores::Dot(point - p, n);
861  if (val > maxVal)
862  {
863  maxVal = val;
864  maxValIdx = index;
865  }
866  }
867  return this->Planes[maxValIdx].GetNormal();
868  }
869 
870 private:
872 };
873 
874 namespace detail
875 {
876 
878 {
879  template <typename ImplicitFunctionType>
880  VISKORES_EXEC_CONT typename ImplicitFunctionType::Scalar operator()(
881  const ImplicitFunctionType& function,
882  const typename ImplicitFunctionType::Vector& point) const
883  {
884  return function.Value(point);
885  }
886 };
887 
888 struct ImplicitFunctionGradientFunctor
889 {
890  template <typename ImplicitFunctionType>
891  VISKORES_EXEC_CONT typename ImplicitFunctionType::Vector operator()(
892  const ImplicitFunctionType& function,
893  const typename ImplicitFunctionType::Vector& point) const
894  {
895  return function.Gradient(point);
896  }
897 };
898 
899 } // namespace detail
900 
901 //============================================================================
918 template <typename... ImplicitFunctionTypes>
920  : public viskores::internal::ImplicitFunctionBase<
921  ImplicitFunctionMultiplexer<ImplicitFunctionTypes...>>
922 {
923  viskores::exec::Variant<ImplicitFunctionTypes...> Variant;
924 
925  using Superclass =
926  viskores::internal::ImplicitFunctionBase<ImplicitFunctionMultiplexer<ImplicitFunctionTypes...>>;
927 
928 public:
929  using Scalar = typename Superclass::Scalar;
930  using Vector = typename Superclass::Vector;
931 
932  ImplicitFunctionMultiplexer() = default;
933 
934  template <typename FunctionType>
936  const viskores::internal::ImplicitFunctionBase<FunctionType>& function)
937  : Variant(reinterpret_cast<const FunctionType&>(function))
938  {
939  }
940 
950  VISKORES_EXEC_CONT Scalar Value(const Vector& point) const
951  {
952  return this->Variant.CastAndCall(detail::ImplicitFunctionValueFunctor{}, point);
953  }
954 
963  {
964  return this->Variant.CastAndCall(detail::ImplicitFunctionGradientFunctor{}, point);
965  }
966 };
967 
968 //============================================================================
986  : public viskores::ImplicitFunctionMultiplexer<viskores::Box,
987  viskores::Cylinder,
988  viskores::Frustum,
989  viskores::Plane,
990  viskores::Sphere,
991  viskores::MultiPlane<3>>
992 {
999 
1000 public:
1001  using Superclass::Superclass;
1002 };
1003 
1004 } // namespace viskores
1005 
1006 #endif //viskores_ImplicitFunction_h
viskores::Frustum::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:619
viskores::Box
Implicit function for a box.
Definition: ImplicitFunction.h:152
viskores::Plane::SetNormal
void SetNormal(const Vector &normal)
Specify the normal vector to the plane.
Definition: ImplicitFunction.h:679
viskores::ImplicitFunctionValueFunctor::ImplicitFunctionValueFunctor
ImplicitFunctionValueFunctor(const FunctionType &function)
Definition: ImplicitFunction.h:97
viskores::ImplicitFunctionGeneral
Implicit function that can switch among known implicit function types.
Definition: ImplicitFunction.h:985
viskores::MultiPlane
Implicit function for a MultiPlane.
Definition: ImplicitFunction.h:789
viskores::ImplicitFunctionGradientFunctor::operator()
Vector operator()(const Vector &point) const
Definition: ImplicitFunction.h:135
viskores::Bounds
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:37
viskores::Normal
T Normal(const T &x)
Returns a normalized version of the given vector.
Definition: VectorAnalysis.h:166
viskores::MultiPlane::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:851
viskores::Box::SetMaxPoint
void SetMaxPoint(const Vector &point)
Specify the maximum coordinate of the box.
Definition: ImplicitFunction.h:188
viskores::MultiPlane::AddPlane
void AddPlane(const Vector &origin, const Vector &normal)
Definition: ImplicitFunction.h:806
viskores::Frustum::GetPlanes
void GetPlanes(Vector points[6], Vector normals[6]) const
Specifies the 6 planes of the frustum.
Definition: ImplicitFunction.h:551
viskores::VecVariable< viskores::Plane, MaxNumPlanes >
viskores::Cylinder::SetRadius
void SetRadius(Scalar radius)
Specify the radius of the cylinder.
Definition: ImplicitFunction.h:471
viskores::Range::Min
viskores::Float64 Min
The minumum value of the range (inclusive).
Definition: Range.h:42
viskores::Frustum::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:599
viskores::Sphere::SetCenter
void SetCenter(const Vector &center)
Specify the center of the sphere.
Definition: ImplicitFunction.h:743
viskores::Sphere::GetRadius
Scalar GetRadius() const
Specify the radius of the sphere.
Definition: ImplicitFunction.h:746
viskores::Plane::Plane
Plane(const Vector &normal={ 0, 0, 1 })
Construct a plane through the origin with the given normal.
Definition: ImplicitFunction.h:655
viskores::Normalize
void Normalize(T &x)
Changes a vector to be normal.
Definition: VectorAnalysis.h:177
Variant.h
viskores::Sphere::GetCenter
const Vector & GetCenter() const
Specify the center of the sphere.
Definition: ImplicitFunction.h:749
viskores::Cylinder::Cylinder
Cylinder()
Construct cylinder radius of 0.5; centered at origin with axis along y coordinate axis.
Definition: ImplicitFunction.h:438
viskores::ImplicitFunctionValueFunctor::Scalar
typename FunctionType::Scalar Scalar
Definition: ImplicitFunction.h:86
viskores::ImplicitFunctionGradientFunctor::ImplicitFunctionGradientFunctor
ImplicitFunctionGradientFunctor()=default
viskores::MultiPlane::MultiPlane
MultiPlane(const MultiPlane< SrcMaxPlanes > &src)
Definition: ImplicitFunction.h:797
viskores::ImplicitFunctionMultiplexer::ImplicitFunctionMultiplexer
ImplicitFunctionMultiplexer()=default
viskores::ImplicitFunctionGradientFunctor::Scalar
typename FunctionType::Scalar Scalar
Definition: ImplicitFunction.h:119
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
viskores::ImplicitFunctionGradientFunctor
A helpful functor that calls the gradient method of a given ImplicitFunction.
Definition: ImplicitFunction.h:116
viskores::Frustum::GetPoints
const Vector * GetPoints() const
Definition: ImplicitFunction.h:563
VISKORES_EXEC_CONT
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
viskores::Box::SetMinPoint
void SetMinPoint(const Vector &point)
Specify the minimum coordinate of the box.
Definition: ImplicitFunction.h:185
viskores::Sqrt
viskores::Float32 Sqrt(viskores::Float32 x)
Definition: Math.h:951
viskores::ImplicitFunctionMultiplexer
Implicit function that can switch among different types.
Definition: ImplicitFunction.h:919
viskores::Cylinder::Cylinder
Cylinder(const Vector &axis, Scalar radius)
Construct a cylinder with the given axis and radius.
Definition: ImplicitFunction.h:447
viskores::Range::Max
viskores::Float64 Max
Tha maximum value of the range (inclusive).
Definition: Range.h:44
viskores::Sphere::Sphere
Sphere(Vector center, Scalar radius)
Construct a sphere with the given center and radius.
Definition: ImplicitFunction.h:733
viskores::ImplicitFunctionMultiplexer::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:950
viskores::ImplicitFunctionGradientFunctor::Vector
typename FunctionType::Vector Vector
Definition: ImplicitFunction.h:120
viskores::ImplicitFunctionMultiplexer::ImplicitFunctionMultiplexer
ImplicitFunctionMultiplexer(const viskores::internal::ImplicitFunctionBase< FunctionType > &function)
Definition: ImplicitFunction.h:935
viskores::Box::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:295
VectorAnalysis.h
viskores::ImplicitFunctionMultiplexer::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:962
viskores::Plane::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:695
viskores::MultiPlane::Scalar
viskores::FloatDefault Scalar
Definition: ImplicitFunction.h:793
viskores::Box::Box
Box(const Vector &minPoint, const Vector &maxPoint)
Construct a box with the specified minimum and maximum point.
Definition: ImplicitFunction.h:163
viskores::ImplicitFunctionMultiplexer< viskores::Box, viskores::Cylinder, viskores::Frustum, viskores::Plane, viskores::Sphere, viskores::MultiPlane< 3 > >::Vector
typename Superclass::Vector Vector
Definition: ImplicitFunction.h:930
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::Sphere::Sphere
Sphere(Scalar radius=0.5)
Construct a sphere with center at (0,0,0) and the given radius.
Definition: ImplicitFunction.h:726
viskores::Cylinder::SetCenter
void SetCenter(const Vector &center)
Specify the center of the cylinder.
Definition: ImplicitFunction.h:465
viskores::Box::Box
Box(const viskores::Bounds &bounds)
Construct a box that encompasses the given bounds.
Definition: ImplicitFunction.h:182
viskores::Box::GetBounds
viskores::Bounds GetBounds() const
Specify the size and location of the box by the bounds it encompasses.
Definition: ImplicitFunction.h:204
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores::MultiPlane::GetPlanes
viskores::VecVariable< viskores::Plane, MaxNumPlanes > GetPlanes() const
Definition: ImplicitFunction.h:816
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::Plane::GetOrigin
const Vector & GetOrigin() const
Specify the origin of the plane.
Definition: ImplicitFunction.h:682
Bounds.h
Math.h
viskores::Sphere::SetRadius
void SetRadius(Scalar radius)
Specify the radius of the sphere.
Definition: ImplicitFunction.h:740
viskores::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:519
viskores::Frustum
Implicit function for a frustum.
Definition: ImplicitFunction.h:512
viskores::ImplicitFunctionGradientFunctor::Function
FunctionType Function
Definition: ImplicitFunction.h:141
viskores::cont::ExecutionAndControlObjectBase
Base ExecutionAndControlObjectBase class.
Definition: ExecutionAndControlObjectBase.h:36
viskores::MultiPlane::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:830
ExecutionAndControlObjectBase.h
viskores::ImplicitFunctionMultiplexer< viskores::Box, viskores::Cylinder, viskores::Frustum, viskores::Plane, viskores::Sphere, viskores::MultiPlane< 3 > >::Scalar
typename Superclass::Scalar Scalar
Definition: ImplicitFunction.h:929
viskores::ImplicitFunctionValueFunctor
A helpful functor that calls the value method of a given ImplicitFunction.
Definition: ImplicitFunction.h:83
viskores::ImplicitFunctionGradientFunctor::ImplicitFunctionGradientFunctor
ImplicitFunctionGradientFunctor(const viskores::internal::ImplicitFunctionBase< FunctionType > &function)
Definition: ImplicitFunction.h:124
viskores::Cylinder::Center
Vector Center
Definition: ImplicitFunction.h:505
viskores::ImplicitFunctionGradientFunctor::ImplicitFunctionGradientFunctor
ImplicitFunctionGradientFunctor(const FunctionType &function)
Definition: ImplicitFunction.h:130
viskores::Frustum::SetPlanes
void SetPlanes(const Vector points[6], const Vector normals[6])
Specifies the 6 planes of the frustum.
Definition: ImplicitFunction.h:530
viskores::ImplicitFunctionValueFunctor::operator()
Scalar operator()(const Vector &point) const
Definition: ImplicitFunction.h:102
viskores::Plane::Plane
Plane(const Vector &origin, const Vector &normal)
Construct a plane through the given point with the given normal.
Definition: ImplicitFunction.h:662
viskores::Box::MaxPoint
Vector MaxPoint
Definition: ImplicitFunction.h:419
viskores::Box::Box
Box()
Construct box with center at (0,0,0) and each side of length 1.0.
Definition: ImplicitFunction.h:156
VISKORES_ASSERT
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
viskores::Frustum::SetPlane
void SetPlane(int idx, const Vector &point, const Vector &normal)
Set one of the 6 planes of the frustum.
Definition: ImplicitFunction.h:543
viskores::Cylinder::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:496
viskores::Cylinder::Radius
Scalar Radius
Definition: ImplicitFunction.h:507
viskores::ImplicitFunctionValueFunctor::ImplicitFunctionValueFunctor
ImplicitFunctionValueFunctor(const viskores::internal::ImplicitFunctionBase< FunctionType > &function)
Definition: ImplicitFunction.h:91
viskores::Bounds::Z
viskores::Range Z
The range of values in the Z direction.
Definition: Bounds.h:47
viskores::Box::MinPoint
Vector MinPoint
Definition: ImplicitFunction.h:418
viskores::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
viskores::Range
Represent a continuous scalar range of values.
Definition: Range.h:39
viskores::MultiPlane::Planes
viskores::VecVariable< viskores::Plane, MaxNumPlanes > Planes
Definition: ImplicitFunction.h:871
viskores::Frustum::CreateFromPoints
void CreateFromPoints(const Vector points[8])
Specifies the frustum as the 8 points of the bounding hexahedron.
Definition: ImplicitFunction.h:570
VecVariable.h
viskores::MultiPlane::GetPlane
viskores::Plane GetPlane(int idx)
Definition: ImplicitFunction.h:811
viskores::Frustum::GetNormals
const Vector * GetNormals() const
Definition: ImplicitFunction.h:565
viskores::FloatDefault
viskores::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:244
viskores::Cylinder::SetAxis
void SetAxis(const Vector &axis)
Specify the direction of the axis of the cylinder.
Definition: ImplicitFunction.h:468
viskores::Bounds::Y
viskores::Range Y
The range of values in the Y direction.
Definition: Bounds.h:44
viskores::MultiPlane::operator=
MultiPlane & operator=(const MultiPlane< SrcMaxPlanes > &src)
Definition: ImplicitFunction.h:802
viskores::Plane::SetOrigin
void SetOrigin(const Vector &origin)
Specify the origin of the plane.
Definition: ImplicitFunction.h:671
viskores::Box::GetMinPoint
const Vector & GetMinPoint() const
Specify the minimum coordinate of the box.
Definition: ImplicitFunction.h:191
viskores::Cylinder
Implicit function for a cylinder.
Definition: ImplicitFunction.h:433
viskores::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:170
viskores::Sphere::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:760
viskores::Sphere::Radius
Scalar Radius
Definition: ImplicitFunction.h:778
viskores::MagnitudeSquared
detail::FloatingPointReturnType< T >::Type MagnitudeSquared(const T &x)
Returns the square of the magnitude of a vector.
Definition: VectorAnalysis.h:72
viskores::ImplicitFunctionMultiplexer< viskores::Box, viskores::Cylinder, viskores::Frustum, viskores::Plane, viskores::Sphere, viskores::MultiPlane< 3 > >::Superclass
viskores::internal::ImplicitFunctionBase< ImplicitFunctionMultiplexer< ImplicitFunctionTypes... > > Superclass
Definition: ImplicitFunction.h:926
viskores::Box::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:220
viskores::ImplicitFunctionValueFunctor::ImplicitFunctionValueFunctor
ImplicitFunctionValueFunctor()=default
viskores::Cylinder::Value
Scalar Value(const Vector &point) const
Evaluate the value of the implicit function.
Definition: ImplicitFunction.h:482
viskores::TriangleNormal
viskores::Vec< typename detail::FloatingPointReturnType< T >::Type, 3 > TriangleNormal(const viskores::Vec< T, 3 > &a, const viskores::Vec< T, 3 > &b, const viskores::Vec< T, 3 > &c)
Find the normal of a triangle.
Definition: VectorAnalysis.h:211
viskores::Cylinder::Axis
Vector Axis
Definition: ImplicitFunction.h:506
viskores::ImplicitFunctionValueFunctor::Vector
typename FunctionType::Vector Vector
Definition: ImplicitFunction.h:87
viskores::Sphere::Gradient
Vector Gradient(const Vector &point) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:772
viskores::Box::SetBounds
void SetBounds(const viskores::Bounds &bounds)
Specify the size and location of the box by the bounds it encompasses.
Definition: ImplicitFunction.h:197
viskores::Vec
A short fixed-length array.
Definition: Types.h:365
viskores::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
viskores::Cylinder::Cylinder
Cylinder(const Vector &center, const Vector &axis, Scalar radius)
Construct a cylinder at the given center, axis, and radius.
Definition: ImplicitFunction.h:455
viskores::ImplicitFunctionValueFunctor::Function
FunctionType Function
Definition: ImplicitFunction.h:108
VISKORES_EXEC
#define VISKORES_EXEC
Definition: ExportMacros.h:59
viskores::Plane::Gradient
Vector Gradient(const Vector &) const
Evaluate the gradient of the implicit function.
Definition: ImplicitFunction.h:707
viskores::ImplicitFunctionMultiplexer::Variant
viskores::exec::Variant< ImplicitFunctionTypes... > Variant
Definition: ImplicitFunction.h:923
viskores::Bounds::X
viskores::Range X
The range of values in the X direction.
Definition: Bounds.h:41
viskores::Plane
Represent a plane with a base point (origin) and normal vector.
Definition: Geometry.h:33
viskores::Box::GetMaxPoint
const Vector & GetMaxPoint() const
Specify the maximum coordinate of the box.
Definition: ImplicitFunction.h:194
viskores::Plane::GetNormal
const Vector & GetNormal() const
Specify the normal vector to the plane.
Definition: ImplicitFunction.h:684
viskores::Frustum::Frustum
Frustum(const Vector points[8])
Construct a frustum defined by the 8 points of the bounding hexahedron.
Definition: ImplicitFunction.h:527
viskores::Sphere
Represent a sphere of the given Dimension.
Definition: Geometry.h:35