SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Geometry.h
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 smtk_geometry_Geometry_h
11 #define smtk_geometry_Geometry_h
12 
13 #include "smtk/geometry/Backend.h"
14 #include "smtk/resource/PersistentObject.h"
15 
16 #include <array>
17 #include <atomic>
18 #include <limits>
19 
20 namespace smtk
21 {
22 namespace geometry
23 {
24 
60 class SMTKCORE_EXPORT Geometry : smtkEnableSharedPtr(Geometry)
61 {
62 public:
68  using GenerationNumber = size_t;
69 
71  static constexpr GenerationNumber Invalid = std::numeric_limits<GenerationNumber>::lowest();
72 
74  static constexpr GenerationNumber Initial = std::numeric_limits<GenerationNumber>::lowest() + 1;
75 
78  using BoundingBox = std::array<double, 6>;
79 
81  using Visitor = std::function<bool(const resource::PersistentObject::Ptr&, GenerationNumber)>;
82 
87  using Specification = std::tuple<smtk::resource::ResourcePtr, const smtk::geometry::Backend&>;
88 
93  using UniquePtr = std::unique_ptr<smtk::geometry::Geometry>;
94 
96  Geometry()
97  : m_lastModified(Initial)
98  {
99  }
100 
101  virtual ~Geometry() = default;
102 
104  virtual const Backend& backend() const = 0;
105 
107  virtual ResourcePtr resource() const = 0;
108 
119  GenerationNumber lastModified() const { return m_lastModified; }
120 
124 
125  virtual GenerationNumber generationNumber(const resource::PersistentObject::Ptr&) const = 0;
128  virtual void bounds(const resource::PersistentObject::Ptr&, BoundingBox& bds) const = 0;
132  virtual bool readLockRequired() const { return true; }
134  virtual void visit(Visitor fn) const = 0;
136 
143 
144  virtual void markModified(const resource::PersistentObject::Ptr& obj) = 0;
149 
154  virtual bool erase(const smtk::common::UUID& uid) = 0;
156 
157 protected:
158  std::atomic<GenerationNumber> m_lastModified;
159 };
160 
161 } // namespace geometry
162 } // namespace smtk
163 
164 #endif // smtk_geometry_Geometry_h
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
smtk::geometry::Geometry::UniquePtr
std::unique_ptr< smtk::geometry::Geometry > UniquePtr
The return type of the geometry-provider generator class.
Definition: Geometry.h:93
smtk::geometry::Geometry::Specification
std::tuple< smtk::resource::ResourcePtr, const smtk::geometry::Backend & > Specification
The data needed to request a geometry provider (a resource and backend).
Definition: Geometry.h:87
smtk::geometry::Geometry::readLockRequired
virtual bool readLockRequired() const
Return true if the resource owning this geometryProvider must be read-locked before rendering prep.
Definition: Geometry.h:132
smtk::geometry::BoundingBox
An API for computing the bounding box for a geometric resource or component.
Definition: BoundingBox.h:30
smtk::common::UUID
Definition: UUID.h:38
smtk::geometry::Geometry::Visitor
std::function< bool(const resource::PersistentObject::Ptr &, GenerationNumber)> Visitor
The signature of functions used to visit all objects with tessellation data.
Definition: Geometry.h:81
smtk::geometry::Geometry::lastModified
GenerationNumber lastModified() const
Indication of when the geometry has last been updated.
Definition: Geometry.h:119
smtkEnableSharedPtr
#define smtkEnableSharedPtr(...)
An abbreviation for enabling shared pointers.
Definition: SharedFromThis.h:154
smtk::geometry::Geometry::BoundingBox
std::array< double, 6 > BoundingBox
A bounding box is represented as an array of 6 numbers, ordered xmin, xmax, ymin, ymax,...
Definition: Geometry.h:78
smtk::geometry::Geometry
A base class for objects which can provide renderable geometry.
Definition: Geometry.h:60
smtk::geometry::Backend
This is an empty class used by geometry providers to specify their interface.
Definition: Backend.h:28
smtk::geometry::ResourcePtr
std::shared_ptr< Resource > ResourcePtr
Definition: PublicPointerDefs.h:330
smtkTypeMacroBase
#define smtkTypeMacroBase(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:55
smtk::geometry::Geometry::GenerationNumber
size_t GenerationNumber
An integral type to hold monotonically increasing generation numbers (a.k.a.
Definition: Geometry.h:68