SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
smtk::geometry::Geometry Class Referenceabstract

A base class for objects which can provide renderable geometry. More...

#include <Geometry.h>

Inheritance diagram for smtk::geometry::Geometry:
[legend]
Collaboration diagram for smtk::geometry::Geometry:
[legend]

Public Types

using GenerationNumber = size_t
 An integral type to hold monotonically increasing generation numbers (a.k.a. More...
 
using BoundingBox = std::array< double, 6 >
 A bounding box is represented as an array of 6 numbers, ordered xmin, xmax, ymin, ymax, zmin, zmax.
 
using Visitor = std::function< bool(const resource::PersistentObject::Ptr &, GenerationNumber)>
 The signature of functions used to visit all objects with tessellation data.
 
using Specification = std::tuple< smtk::resource::ResourcePtr, const smtk::geometry::Backend & >
 The data needed to request a geometry provider (a resource and backend). More...
 
using UniquePtr = std::unique_ptr< smtk::geometry::Geometry >
 The return type of the geometry-provider generator class. More...
 

Public Member Functions

 smtkTypeMacroBase (Geometry)
 
virtual const Backendbackend () const =0
 Every provider must indicate the backend for which it is specialized.
 
virtual ResourcePtr resource () const =0
 Every provider must indicate the resource it provides geometry for.
 
GenerationNumber lastModified () const
 Indication of when the geometry has last been updated. More...
 
virtual GenerationNumber generationNumber (const resource::PersistentObject::Ptr &) const =0
 Query methods. More...
 
virtual void bounds (const resource::PersistentObject::Ptr &, BoundingBox &bds) const =0
 Populate the bounds (bds) with the given object's bounds.
 
virtual bool readLockRequired () const
 Return true if the resource owning this geometryProvider must be read-locked before rendering prep. More...
 
virtual void visit (Visitor fn) const =0
 Visit each persistent object that has renderable geometry.
 
virtual void markModified (const resource::PersistentObject::Ptr &obj)=0
 Modfication methods. More...
 
virtual bool erase (const smtk::common::UUID &uid)=0
 Inform the geometry provider that an object is about to be or has been deleted. More...
 

Static Public Attributes

static constexpr GenerationNumber Invalid = std::numeric_limits<GenerationNumber>::lowest()
 A special generation number that marks an object as having no geometric representation.
 
static constexpr GenerationNumber Initial = std::numeric_limits<GenerationNumber>::lowest() + 1
 The lowest valid generation number (which may be used as the initial value).
 

Protected Attributes

std::atomic< GenerationNumberm_lastModified
 

Detailed Description

A base class for objects which can provide renderable geometry.

Resources which have renderable data should provide access to that data by returning a concrete instance of this class. Subclasses present in other libraries (which have additional dependencies on e.g., VTK, VTK-m) provide the API by which the geometry is exchanged. However, this base class provides related functionality independent of any rendering that all renderable objects must share in common.

Resources register a Generator with their resource index as the input and a subclass of Geometry as the output. Then, applications or scripts can ask the resource for a geometry provider and query component/resource geometric bounds. They can also mark components and resources as "dirty" (indicating that any cached geometry or bounds information should be discarded). Each resource produces a single instance of some subclass of this class. The geometry instance for a resource should be capable of providing geometry for the entire resource and/or any of its components as needed.

Producing renderable geometry can be computationally expensive, so this class provides a generation number associated with the geometry. So long as the generation number is unchanged, so is the geometry. Classes (such as vtkModelMultiBlockSource) need only compare the generation number to the value they obtained when last querying the geometryProvider; if it is the same, then no changes have occurred and the prior geometry can be used (saving the expense of recomputing it).

Similarly, it is best for objects to cache bounds. These may even be available without resorting to discretizing the model geometry, so this class also provides a method for obtaining bounds as a 6-tuple (xmin, xmax, ymin, ymax, zmin, zmax).

See also
smtk::session::vtk::source::Geometry
smtk::session::polygon::Geometry

Member Typedef Documentation

◆ GenerationNumber

An integral type to hold monotonically increasing generation numbers (a.k.a.

generation numbers, sequence numbers, version numbers, timestamps) used to indicate when the tessellation has changed.

Note that 0 is reserved; no object should have generation number 0.

◆ Specification

The data needed to request a geometry provider (a resource and backend).

The "using" statements below this class declaration reference this to make registering geometry providers simpler and less error-prone;

◆ UniquePtr

The return type of the geometry-provider generator class.

Geometry providers are unique pointers to ensure that copies of cached geometry are not copied accidentally.

Member Function Documentation

◆ erase()

virtual bool smtk::geometry::Geometry::erase ( const smtk::common::UUID uid)
pure virtual

Inform the geometry provider that an object is about to be or has been deleted.

This is different from markModified(), which simply removes any cached geometry; this method tells the geometry provider never to ask for the geometry of the given uid again.

Implemented in smtk::geometry::Cache< smtk::extension::vtk::geometry::Geometry >.

◆ generationNumber()

virtual GenerationNumber smtk::geometry::Geometry::generationNumber ( const resource::PersistentObject::Ptr &  ) const
pure virtual

Query methods.

These methods are invoked by consumers of geometry. Return a monotonically increasing number that changes whenever the object's geometry changes.

◆ lastModified()

GenerationNumber smtk::geometry::Geometry::lastModified ( ) const
inline

Indication of when the geometry has last been updated.

This may be used by consumers to determine whether any object's renderable geometry has been updated.

Consumers are responsible for remembering the previously returned value. Whenever this method returns a larger number, at least one object has been updated.

Providers are responsible for updating m_lastModified.

◆ markModified()

virtual void smtk::geometry::Geometry::markModified ( const resource::PersistentObject::Ptr &  obj)
pure virtual

Modfication methods.

These methods are typically invoked by operations that create or modify objects with renderable geometry. There is no requirement that these methods be used by subclasses (there may be alternate methods) Mark the object's geometry as modified. Calling this should increment the generation number and recompute any tessellation the next time the object is queried. This is a way for applications to "force refresh" a tessellation.

◆ readLockRequired()

virtual bool smtk::geometry::Geometry::readLockRequired ( ) const
inlinevirtual

Return true if the resource owning this geometryProvider must be read-locked before rendering prep.

The default is to return true (i.e., conservatively assume zero-copying is performed).


The documentation for this class was generated from the following file: