iMSTK
Interactive Medical Simulation Toolkit
imstkCompositeImplicitGeometry.cpp
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #include "imstkCompositeImplicitGeometry.h"
8 
9 namespace imstk
10 {
11 double
13 {
14  // Initialize everything to outside
15  double distA = std::numeric_limits<double>::max();
16  for (auto i = geometries.begin(); i != geometries.end(); i++)
17  {
18  const GeometryBoolPair& pair = *i;
19  double distB = pair.first->getFunctionValue(pos);
20  switch (pair.second)
21  {
22  case GeometryBoolType::Difference:
23  distA = std::max(distA, -distB);
24  break;
25  case GeometryBoolType::Intersection:
26  distA = std::max(distA, distB);
27  break;
28  case GeometryBoolType::Union:
29  distA = std::min(distA, distB);
30  break;
31  }
32  }
33  return distA;
34 }
35 } // namespace imstk
Compound Geometry.
double getFunctionValue(const Vec3d &pos) const override
Returns signed distance to surface at pos.