SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
smtk::model::Instance Class Reference

A entityref subclass that provides methods specific to entity use records. More...

#include <Instance.h>

Inheritance diagram for smtk::model::Instance:
[legend]
Collaboration diagram for smtk::model::Instance:
[legend]

Public Member Functions

 SMTK_ENTITYREF_CLASS (Instance, EntityRef, isInstance)
 
EntityRef prototype () const
 Return the model entity whose geometry serves as the prototype for this instance's placements.
 
bool setPrototype (const EntityRef &prototype)
 Change source of geometry for this instance.
 
TessellationgenerateTessellation ()
 Apply rules (stored in properties) to recompute the tessellation for this instance. More...
 
std::string rule () const
 
bool setRule (const std::string &nextRule)
 
bool setSampleSurface (const EntityRef &surface)
 
EntityRef sampleSurface () const
 
EntityRefs snapEntities () const
 
bool addSnapEntity (const EntityRef &snapTo)
 
bool removeSnapEntity (const EntityRef &snapTo)
 
bool setSnapEntity (const EntityRef &snapTo)
 
bool setSnapEntities (const EntityRefs &snapTo)
 
std::size_t numberOfPlacements ()
 Return the number of placements (building a tessellation as needed).
 
bool isClone () const
 Return whether this instance is a temporary clone of another instance.
 
template<typename I >
Instance clonePlacements (I begin, I end, bool relate=true)
 Create a new instance duplicating a subset of this instance's placements. More...
 
template<typename Container >
Container divide (bool merge=false, Container *clonesIncluded=nullptr)
 Divide an instance into several based on "subset" clones. More...
 
- Public Member Functions inherited from smtk::model::EntityRef
 SMTK_BASE_TYPE (EntityRef)
 
 EntityRef ()
 Construct an invalid entityref.
 
 EntityRef (ResourcePtr resource, const smtk::common::UUID &entityId)
 Construct a entityref referencing a given entity residing in the given rsrc.
 
 EntityRef (EntityPtr src)
 Construct a entityref referencing a given entity residing in the given rsrc.
 
bool setResource (ResourcePtr resource)
 Change the underlying resource the entityref references.
 
ResourcePtr resource ()
 Return the underlying resource the entityref references.
 
const ResourcePtr resource () const
 
bool setEntity (const smtk::common::UUID &entityId)
 Change the UUID of the entity the entityref references.
 
const smtk::common::UUIDentity () const
 Return the UUID of the entity the entityref references.
 
smtk::model::EntityPtr entityRecord () const
 Return the smtk::model::Entity record for this model entity.
 
smtk::resource::ComponentPtr component () const
 Return the resource component for this model entity.
 
int dimension () const
 Return the nominal parametric dimension of the entity (or -1). More...
 
int dimensionBits () const
 Return the nominal parametric dimension(s) of the entity as a bit vector. More...
 
void setDimensionBits (BitFlags dim)
 Set the dimensionality of this entity. More...
 
BitFlags entityFlags () const
 Return the bit vector describing the entity's type. More...
 
std::string flagSummary (int form=0) const
 A string summary of the type of entity represented by this entityref. More...
 
int maxParametricDimension () const
 Return the maximum number of coordinates required to parameterize this model's point locus. More...
 
int embeddingDimension () const
 Return the dimension of the space into which this entity is embedded. More...
 
std::string name () const
 Report the name associated with this entity. More...
 
void setName (const std::string &n)
 Assign a name to an entity. More...
 
std::string assignDefaultName (bool overwrite=false)
 Assign a default name to the entity. More...
 
bool hasVisibility () const
 Returns true if the "visible" integer-property exists.
 
bool visible () const
 Report the visibility associated with this entity. More...
 
void setVisible (bool vis)
 Assign the visible property to an entity. More...
 
void setExclusions (bool v, int mask=Exclusions::Everything)
 Set the exclusions. More...
 
int exclusions (int mask=Exclusions::Everything) const
 Get the exclusions status. More...
 
FloatList color () const
 Return a user-assigned color for the entity. More...
 
bool hasColor () const
 Returns true if the "color" float-property exists. No check on the size is performed.
 
void setColor (const FloatList &rgba)
 Assign a color to an entity. More...
 
void setColor (double r, double g, double b, double a=1.)
 Assign a color to an entity. More...
 
bool isValid () const
 Return whether the entityref is pointing to valid resource that contains the UUID of the entity. More...
 
virtual bool isValid (EntityPtr *entityRecord) const
 Return whether the entityref is pointing to valid resource that contains the UUID of the entity. More...
 
virtual bool checkForArrangements (ArrangementKind k, EntityPtr &entry, Arrangements *&arr) const
 A wrapper around EntityRef::isValid() which also verifies an arrangement exists.
 
bool isCellEntity () const
 
bool isUseEntity () const
 
bool isShellEntity () const
 
bool isGroup () const
 
bool isModel () const
 
bool isInstance () const
 
bool isSessionRef () const
 
bool isAuxiliaryGeometry () const
 
bool isConcept () const
 
bool isVertex () const
 
bool isEdge () const
 
bool isFace () const
 
bool isVolume () const
 
bool isChain () const
 
bool isLoop () const
 
bool isShell () const
 
bool isVertexUse () const
 
bool isEdgeUse () const
 
bool isFaceUse () const
 
bool isVolumeUse () const
 
template<typename T >
as () const
 Reinterpret a entityref as a subclass. More...
 
EntityRefs bordantEntities (int ofDimension=-2) const
 
EntityRefs boundaryEntities (int ofDimension=-2) const
 
std::vector< double > boundingBox () const
 
std::vector< double > unionBoundingBox (const std::vector< double > &b1, const std::vector< double > &b2) const
 
std::vector< double > unionBoundingBox (const std::vector< double > &b1, const std::array< double, 6 > &b2) const
 
EntityRefs lowerDimensionalBoundaries (int lowerDimension)
 
EntityRefs higherDimensionalBordants (int higherDimension)
 
EntityRefs adjacentEntities (int ofDimension)
 
template<typename T >
relationsAs () const
 Return all of the entities related to this entityref. More...
 
EntityRefs relations () const
 Return a set of entities related to this entity. This method is provided for Python wrapping.
 
EntityRefaddRawRelation (const EntityRef &ent)
 Add a relation to an entity, ent, without specifying the relationship's nature. More...
 
EntityReffindOrAddRawRelation (const EntityRef &ent)
 Find or add a relation to an entity, ent, without specifying the relationship's nature. More...
 
EntityRefelideRawRelation (const EntityRef &ent)
 Nullify a relation to the given entity, ent. More...
 
smtk::mesh::MeshSet meshTessellation () const
 Return the entity's mesh tessellation. More...
 
TessellationresetTessellation ()
 Return an empty tessellation attached to the entity. More...
 
const TessellationhasTessellation () const
 Return the entity's tessellation if one exists or nullptr otherwise.
 
const TessellationhasAnalysisMesh () const
 Return the entity's analysis mesh if one exists or nullptr otherwise.
 
const TessellationgotMesh () const
 Return the entity's analysis mesh if one exists, otherwise return the entity's tessellation. More...
 
int setTessellation (const Tessellation *tess, int analysisMesh=0, bool updateBBox=false)
 Set the tessellation of the entity, returning its generation number (or -1 on failure). More...
 
int setTessellationAndBoundingBox (const Tessellation *tess, int analysisMesh=0)
 
bool removeTessellation (bool removeGen=false)
 Remove the tessellation of the entity, returning true if such a tessellation existed. More...
 
void findEntitiesWithTessellation (std::map< smtk::model::EntityRef, smtk::model::EntityRef > &entityrefMap, std::set< smtk::model::EntityRef > &touched) const
 A convenient method for finding all entities with tessellations owned by this entity. More...
 
int tessellationGeneration () const
 Return the generation number of the current tessellation (or -1 if no tessellation).
 
bool setTessellationGeneration (int gen)
 Set the tessellation generation number. More...
 
void setBoundingBox (const double bbox[6])
 Set the bounding box of the entity. More...
 
template<typename T >
bool disassociateAttributes (const T &attribPtrs)
 Returns true if at least 1 attribute in the set of attribPtrs was removed.
 
smtk::attribute::Attributes attributes (smtk::attribute::ConstResourcePtr res) const
 Return a list of attributes on the entity based on an attribute resource.
 
smtk::attribute::Attributes attributes () const
 Return a list of attributes on the entity based on the resource manager. More...
 
template<typename T >
bool removeProperty (const std::string &name)
 Remove the property of type T with the given name, returning true on success. More...
 
void setFloatProperty (const std::string &propName, smtk::model::Float propValue)
 
void setFloatProperty (const std::string &propName, const smtk::model::FloatList &propValue)
 
smtk::model::FloatList const & floatProperty (const std::string &propName) const
 
smtk::model::FloatList & floatProperty (const std::string &propName)
 
bool hasFloatProperty (const std::string &propName) const
 
bool removeFloatProperty (const std::string &propName)
 
bool hasFloatProperties () const
 Does this entity have any float-valued properties? More...
 
std::set< std::string > floatPropertyNames () const
 Return the names of all the floating-point properties.
 
void setStringProperty (const std::string &propName, const smtk::model::String &propValue)
 
void setStringProperty (const std::string &propName, const smtk::model::StringList &propValue)
 
smtk::model::StringList const & stringProperty (const std::string &propName) const
 
smtk::model::StringListstringProperty (const std::string &propName)
 
bool hasStringProperty (const std::string &propName) const
 
bool removeStringProperty (const std::string &propName)
 
bool hasStringProperties () const
 Does this entity have any string-valued properties? More...
 
std::set< std::string > stringPropertyNames () const
 Return the names of all the string properties.
 
void setIntegerProperty (const std::string &propName, smtk::model::Integer propValue)
 
void setIntegerProperty (const std::string &propName, const smtk::model::IntegerList &propValue)
 
smtk::model::IntegerList const & integerProperty (const std::string &propName) const
 
smtk::model::IntegerList & integerProperty (const std::string &propName)
 
bool hasIntegerProperty (const std::string &propName) const
 
bool removeIntegerProperty (const std::string &propName)
 
bool hasIntegerProperties () const
 Does this entity have any integer-valued properties? More...
 
std::set< std::string > integerPropertyNames () const
 Return the names of all the integer properties.
 
int numberOfArrangementsOfKind (ArrangementKind k) const
 Return the number of arrangements of the given kind k.
 
ArrangementfindArrangement (ArrangementKind k, int index)
 Return the i-th arrangement of kind k (or nullptr).
 
const ArrangementfindArrangement (ArrangementKind k, int index) const
 Return the i-th arrangement of kind k (or nullptr).
 
bool clearArrangements ()
 Delete all arrangements of this entity with prejudice.
 
EntityRef relationFromArrangement (ArrangementKind k, int arrangementIndex, int offset) const
 Return the relation specified by the offset into the specified arrangement.
 
bool removeArrangement (ArrangementKind k, int index=-1)
 Remove an arrangement. More...
 
EntityRefembedEntity (const EntityRef &thingToEmbed, bool checkExistence=true)
 Embed the specified thingToEmbed as an inclusion into this entityref's entity. More...
 
template<typename T >
EntityRefembedEntities (const T &container, bool checkExistence=true)
 Embed each of the entities in the container inside this entity.
 
bool isEmbedded (EntityRef &ent) const
 Return whether the specified entity is a direct inclusion in this entityref's entity.
 
EntityRef embeddedIn () const
 Report the entity into which this entity is directly embedded. More...
 
bool unembedEntity (const EntityRef &thingToUnembed)
 Unembed the specified thingToUnembed as an inclusion into this entityref's entity. More...
 
template<typename T >
EntityRefunembedEntities (const T &container)
 
template<typename T >
embeddedEntities () const
 
template<typename T >
instances () const
 Return all the instances this object serves as a prototype for.
 
Model owningModel () const
 Return the Model which owns this entity. More...
 
SessionRef owningSession () const
 Return the SessionRef which owns this entity. More...
 
Groups containingGroups () const
 Return the Groups which contains this entity.
 
bool isMember (const EntityRef &entity) const
 Return true when this EntityRef has a SUPERSET_OF relationship with ent.
 
EntityRef memberOf () const
 Return the first entity that this EntityRef has a SUBSET_OF relationship with.
 
bool operator== (const EntityRef &other) const
 A comparator provided so that entityrefs may be included in ordered sets.
 
bool operator!= (const EntityRef &other) const
 A comparator provided for convenience.
 
bool operator< (const EntityRef &other) const
 A comparator provided so that entityrefs may be included in ordered sets.
 
 operator bool () const
 
std::size_t hash () const
 A hash function for entityrefs. More...
 
template<>
SMTKCORE_EXPORT bool removeProperty (const std::string &pname)
 
template<>
SMTKCORE_EXPORT bool removeProperty (const std::string &pname)
 
template<>
SMTKCORE_EXPORT bool removeProperty (const std::string &pname)
 
bool hasAttributes () const
 Does the entityref have any attributes associated with it? Note that this method uses the resource manager. More...
 
bool hasAttributes (smtk::attribute::ConstResourcePtr attRes) const
 Does the entityref have any attributes associated with it from a specific attribute resource?
 
bool hasAttribute (const smtk::common::UUID &attribId) const
 Does the entityref have a specific attribute (represented by an UUID) associate to it. More...
 
bool associateAttribute (smtk::attribute::ResourcePtr attResource, const smtk::common::UUID &attribId)
 Does the entityref have any attributes associated with it? - To be deprecated.
 
bool disassociateAttribute (smtk::attribute::ResourcePtr attResource, const smtk::common::UUID &attribId)
 Disassociate an attribute from the entity? - To be deprecated.
 
bool disassociateAttribute (smtk::attribute::ResourcePtr attResource, const smtk::common::UUID &attribId, bool reverse)
 Disassociate an attribute from the entity? - To be deprecated!
 
bool disassociateAllAttributes (smtk::attribute::ResourcePtr attResource)
 Remove all attribute association form this entityref.
 
bool disassociateAllAttributes (smtk::attribute::ResourcePtr attResource, bool reverse)
 Remove all attribute association form this entityref - To be deprecated!
 
smtk::attribute::Attributes attributes (smtk::attribute::ConstDefinitionPtr def) const
 Return a list of attributes on the entity based on an attribute definition. More...
 

Static Public Member Functions

template<typename Container >
static Instance merge (const Container &instances)
 Merge two or more instances that have everything but placements in common. More...
 
- Static Public Member Functions inherited from smtk::model::EntityRef
template<typename S , typename T >
static void EntityRefsFromUUIDs (S &result, ResourcePtr, const T &uids)
 Convert a set of UUIDs into a set of entityrefs referencing the same rsrc. More...
 
template<typename S , typename T >
static void EntityRefsToUUIDs (S &uids, const T &entRefs)
 

Static Public Attributes

static constexpr const char *const placements = "placements"
 A float-property key used to store/fetch placements.
 
static constexpr const char *const orientations = "orientations"
 A float-property key used to store/fetch orientation. More...
 
static constexpr const char *const scales = "scales"
 A float-property key used to store/fetch scales. More...
 
static constexpr const char *const masks = "masks"
 An int-property key used to store/fetch masks(AKA visibility). More...
 
static constexpr const char *const colors = "colors"
 A float-property key used to store/fetch colors in rgb 0~255. More...
 
static constexpr const char *const subset = "subset"
 An int-property key used to fetch-store clone subset indices. More...
 

Protected Member Functions

template<typename Container >
void divideMapInternal (Instance &clone, std::set< int > &taken, bool merge, std::vector< std::vector< int >> &output, Container *clonesIncluded)
 
bool checkMergeable (const Instance &other) const
 
bool mergeInternal (const Instance &other)
 
- Protected Member Functions inherited from smtk::model::EntityRef
EntityRefaddMemberEntity (const EntityRef &memberToAdd)
 Add an entity as a member of this entity without any membership constraint checks.
 
template<typename T >
EntityRefaddMemberEntities (T begin, T end)
 
EntityRefremoveMemberEntity (const EntityRef &memberToRemove)
 Remove the memberToRemove from this EntityRef. More...
 
EntityRefremoveMemberEntity (int indexOfMemberToRemove)
 Remove a member from this EntityRef given the index of its arrangement. More...
 
template<typename T >
EntityRefremoveMemberEntities (T begin, T end)
 
ResourceEventRelationType subsetRelationType (const EntityRef &member) const
 Determine the nature of a SUPERSET_OF relationship. More...
 
ResourceEventRelationType embeddingRelationType (const EntityRef &embedded) const
 Determine the nature of an EMBEDDED_IN relationship. More...
 

Additional Inherited Members

- Protected Attributes inherited from smtk::model::EntityRef
smtk::model::WeakResourcePtr m_resource
 
smtk::common::UUID m_entity
 

Detailed Description

A entityref subclass that provides methods specific to entity use records.

Member Function Documentation

◆ clonePlacements()

template<typename I >
Instance smtk::model::Instance::clonePlacements ( begin,
end,
bool  relate = true 
)

Create a new instance duplicating a subset of this instance's placements.

This creates and returns a new instance. The new instance may have a different rule than the original as placement-subsetting may not be possible otherwise.

The begin and end arguments are iterators whose values are 0-based integer offsets into the sequence of placements.

The new instance will have an Instance::subset integer property listing the points selected from the original and will be related to the original as if it was a group member (i.e., with ArrangementKind::SUBSET_OF).

◆ divide()

template<typename Container >
Container smtk::model::Instance::divide ( bool  merge = false,
Container *  clonesIncluded = nullptr 
)

Divide an instance into several based on "subset" clones.

Once you are done creating subsets of an instance (via the clonePlacements method), you can call divideInstance() on the source instance (i.e., the parent of all the clones). It will inspect the clones and create new instances for all of the placements subsets (including the remainder of placements not in any subset).

If merge is true, then all clones marked as subsets of this instance will result in a single output instance. Otherwise, each clone will have its own output instance. The clones included in the division can be reported; if you pass in a non-null pointer for clonesIncluded, it will have the set of clones appended. Note that clonesIncluded is not reset by this method; any pre-existing entries will be preserved.

If divide is called on an instance with no clone-children, the returned set will be empty.

◆ generateTessellation()

Tessellation * smtk::model::Instance::generateTessellation ( )

Apply rules (stored in properties) to recompute the tessellation for this instance.

This will always update the instance's tessellation whether it needs it or not. This method is called by EntityRef::hasTessellation() when no tessellation exists, so if you change properties that govern an instance's placements/transforms you may just remove the current tessellation and the tessellation will be created when asked for.

◆ merge()

template<typename Container >
static Instance smtk::model::Instance::merge ( const Container &  instances)
static

Merge two or more instances that have everything but placements in common.

If instances have the same prototype, rule, and other settings in common, this method will attempt to append their placements (and orientations, scalings, and colors) into a common output instance.

If instances cannot be merged, an invalid instance is returned.

NB: The current implementation will always merge instances into an instance with a tabular rule.

Member Data Documentation

◆ colors

constexpr const char* const smtk::model::Instance::colors = "colors"
staticconstexpr

A float-property key used to store/fetch colors in rgb 0~255.

It will be retranscribed as vtkUnsignedCharArray when passing into vtkGlyph3DMapper if specified.

◆ masks

constexpr const char* const smtk::model::Instance::masks = "masks"
staticconstexpr

An int-property key used to store/fetch masks(AKA visibility).

It will be retranscribed as vtkUnsignedCharArray when passing into vtkGlyph3DMapper if specified.

◆ orientations

constexpr const char* const smtk::model::Instance::orientations = "orientations"
staticconstexpr

A float-property key used to store/fetch orientation.

It will be retranscribed as vtkDoubleArray when passing into vtkGlyph3DMapper if specified.

◆ scales

constexpr const char* const smtk::model::Instance::scales = "scales"
staticconstexpr

A float-property key used to store/fetch scales.

It will be retranscribed as vtkDoubleArray when passing into vtkGlyph3DMapper if specified.

◆ subset

constexpr const char* const smtk::model::Instance::subset = "subset"
staticconstexpr

An int-property key used to fetch-store clone subset indices.

It is used by the divide() method to operate on interactive selections.


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