iMSTK
Interactive Medical Simulation Toolkit
imstkCompositeImplicitGeometry.h
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 #pragma once
8 
9 #include "imstkImplicitGeometry.h"
10 #include "imstkMacros.h"
11 
12 namespace imstk
13 {
21 {
22 public:
23  enum class GeometryBoolType
24  {
25  Intersection,
26  Difference,
27  Union
28  };
29 
30  using GeometryBoolPair = std::pair<std::shared_ptr<ImplicitGeometry>, GeometryBoolType>;
31 
32  CompositeImplicitGeometry() = default;
33  ~CompositeImplicitGeometry() override = default;
34 
35  IMSTK_TYPE_NAME(CompositeImplicitGeometry)
36 
37 
38  double getFunctionValue(const Vec3d& pos) const override;
41 
47  void addImplicitGeometry(std::shared_ptr<ImplicitGeometry> geometry, const GeometryBoolType type)
48  {
49  geometry->updatePostTransformData();
50  geometries.push_back(GeometryBoolPair(geometry, type));
51  }
52 
57  std::unique_ptr<CompositeImplicitGeometry> clone()
58  {
59  return std::unique_ptr<CompositeImplicitGeometry>(cloneImplementation());
60  }
61 
62 protected:
63  std::list<GeometryBoolPair> geometries;
64 
65 private:
66  CompositeImplicitGeometry* cloneImplementation() const
67  {
68  return new CompositeImplicitGeometry(*this);
69  }
70 };
71 } // namespace imstk
Compound Geometry.
std::unique_ptr< CompositeImplicitGeometry > clone()
Polymorphic clone, hides the declaration in superclass return own type.
void addImplicitGeometry(std::shared_ptr< ImplicitGeometry > geometry, const GeometryBoolType type)
Add an implicit geometry to have boolean operations done with.
double getFunctionValue(const Vec3d &pos) const override
Returns signed distance to surface at pos.
Class that can represent the geometry of multiple implicit geometries as boolean functions One may su...