SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
A solid model entity, defined by a type and relations to other entities. More...
#include <Entity.h>
Public Types | |
using | UUID = smtk::common::UUID |
using | QueryFunctor = std::function< bool(const smtk::resource::Component &)> |
Public Types inherited from smtk::resource::Component | |
typedef std::function< void(const ComponentPtr &)> | Visitor |
typedef detail::ComponentLinks | Links |
typedef detail::ComponentProperties | Properties |
Public Member Functions | |
smtkTypeMacro (smtk::model::Entity) | |
smtkSuperclassMacro (smtk::resource::Component) | |
smtkSharedPtrCreateMacro (smtk::resource::PersistentObject) | |
EntityPtr | setup (BitFlags entityFlags, int dimension, ResourcePtr resource=nullptr, bool resetRelations=true) |
Populate an object with the given dimension with a type specified by entityFlags. More... | |
const smtk::resource::ResourcePtr | resource () const override |
Components are required to return their owning resource (if any). More... | |
ResourcePtr | modelResource () const |
EntityPtr | owningModel () const |
Return the model (if any) that owns the entity. | |
template<typename T > | |
T | referenceAs () const |
Return the templated object (usually EntityRef or a subclass) that points to this component. | |
bool | reparent (ResourcePtr newParent) |
std::string | name () const override |
Return the name of the object - by default it will return the UUID but that can be overridden. | |
int | dimension () const |
Return the dimension of the associated entity. More... | |
BitFlags | dimensionBits () const |
BitFlags | entityFlags () const |
Return the bit vector describing the type and attributes of the associated entity. More... | |
bool | setEntityFlags (BitFlags flags) |
smtk::common::UUIDArray & | relations () |
const smtk::common::UUIDArray & | relations () const |
int | appendRelation (const smtk::common::UUID &b, bool useHoles=true) |
Append a relation b to this entity's list of relations. More... | |
EntityPtr | pushRelation (const smtk::common::UUID &b) |
EntityPtr | removeRelation (const smtk::common::UUID &b) |
Remove the relation from the entity. More... | |
void | resetRelations () |
Completely clear the entire list of related entities. More... | |
int | findOrAppendRelation (const smtk::common::UUID &r) |
Find the given relation r and return its index, inserting it if not present. | |
int | invalidateRelation (const smtk::common::UUID &r) |
Find the given relation r and invalidate its index. More... | |
int | invalidateRelationByIndex (int relIdx) |
Given a valid index, invalidate the UUID at that index. More... | |
std::string | flagSummary (int form=0) const |
std::string | flagDescription (int form=0) const |
int | arrange (ArrangementKind, const Arrangement &arr, int index=-1) |
int | unarrange (ArrangementKind, int index, bool removeIfLast=false) |
bool | clearArrangements () |
const Arrangements * | hasArrangementsOfKind (ArrangementKind) const |
Arrangements * | hasArrangementsOfKind (ArrangementKind) |
Arrangements & | arrangementsOfKind (ArrangementKind) |
const Arrangement * | findArrangement (ArrangementKind kind, int index) const |
Arrangement * | findArrangement (ArrangementKind kind, int index) |
int | findArrangementInvolvingEntity (ArrangementKind k, const smtk::common::UUID &involved) const |
bool | findDualArrangements (ArrangementKind kind, int index, ArrangementReferences &duals) const |
const KindsToArrangements & | arrangementMap () const |
const common::UUID & | id () const override |
Return a unique identifier for the object which will be persistent across sessions. | |
bool | setId (const common::UUID &uid) override |
Assign an ID to this object (used by readers; not for arbitrary reuse). More... | |
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 |
smtk::attribute::Attributes | attributes (smtk::attribute::ConstDefinitionPtr def) const |
Return a list of attributes on the entity based on an attribute definition. More... | |
Public Member Functions inherited from smtk::resource::Component | |
smtkTypeMacro (smtk::resource::Component) | |
smtkSuperclassMacro (smtk::resource::PersistentObject) | |
smtkSharedFromThisMacro (smtk::resource::PersistentObject) | |
virtual Resource * | parentResource () const |
Return a raw (not shared) pointer to the resource that owns this component. More... | |
template<typename ResourceType > | |
ResourceType * | parentResourceAs () const |
This variant of parentResource casts the result to the given ResourceType. | |
Links & | links () override |
Return the links that connect this component to external resources/components. | |
const Links & | links () const override |
Properties & | properties () override |
Return properties defined on this component. | |
const Properties & | properties () const override |
Public Member Functions inherited from smtk::resource::PersistentObject | |
smtkTypeMacroBase (smtk::resource::PersistentObject) | |
template<typename T > | |
T::Ptr | as () |
Attempt to cast this object to a subclass. | |
template<typename T > | |
T::ConstPtr | as () const |
Attempt to cast this object to a subclass. | |
Static Public Member Functions | |
static EntityPtr | create (const UUID &uid, BitFlags entityFlags=EntityTypeBits::INVALID, ResourcePtr resource=nullptr) |
Create and set up an entity object in a single call. This version sets the Entity's UUID. | |
static EntityPtr | create (BitFlags entityFlags, int dimension, ResourcePtr resource=nullptr) |
Create and set up an entity object in a single call. This version does not set the UUID. | |
static std::string | flagDimensionList (BitFlags entityFlags, bool &plural) |
Return a list the dimension bits set in entityFlags. More... | |
static std::string | flagSummaryHelper (BitFlags entityFlags, int form=0) |
static std::string | flagSummary (BitFlags entityFlags, int form=0) |
Return a string summarizing the type of the entity given its bit-vector flags. | |
static std::string | flagDescription (BitFlags entityFlags, int form=0) |
static int | countForType (BitFlags flags, IntegerList &counters, bool incr=false) |
Return the next pedigree ID for an entity of the given type when given a vector of counters appropriate to the context. More... | |
static std::string | defaultNameFromCounters (BitFlags entityFlags, IntegerList &counters, bool incr=true) |
Given a vector of counters, return a numbered name string and advance counters as required. More... | |
static std::string | flagToSpecifierString (BitFlags flagsOrMask, bool textual=true) |
Given a bitmask or entity flag, return a string specifier. More... | |
static BitFlags | specifierStringToFlag (const std::string &spec) |
static BitFlags | dimensionToDimensionBits (int dim) |
Given a dimension number (0, 1, 2, 3, 4), return the proper bitcode. More... | |
static int | dimensionBitsToDimension (BitFlags dimBits) |
static QueryFunctor | filterStringToQueryFunctor (const std::string &spec) |
Protected Member Functions | |
Entity () | |
The default constructor creates an invalid link. | |
int | consumeInvalidIndex (const smtk::common::UUID &uid) |
smtk::model::Resource * | rawModelResource () const |
Protected Attributes | |
BitFlags | m_entityFlags { INVALID } |
smtk::common::UUIDArray | m_relations |
smtk::model::WeakResourcePtr | m_resource |
KindsToArrangements | m_arrangements |
int | m_firstInvalid { -1 } |
smtk::common::UUID | m_id |
smtk::model::Resource * | m_rawResource = nullptr |
Friends | |
class | smtk::model::Resource |
A solid model entity, defined by a type and relations to other entities.
A solid model is an smtk::model::Resource instance that maps UUIDs to to records of various types. Every entity (topological cell, geometric, group, submodel, or scene-graph instance) must have an Entity record describing the type of the entity and relating it to other entities. Other records, such as string, integer, or vector properties are optional.
The entity type is stored as a bit vector named entityFlags(). This also encodes the parametric dimension (or dimensions) associated with the entity.
Store links between named entities.
int smtk::model::Entity::appendRelation | ( | const smtk::common::UUID & | b, |
bool | useHoles = true |
||
) |
Append a relation b to this entity's list of relations.
This returns the index of b in the entity's list of relations.
If useHoles is true, then a slower algorithm is used that replaces the first invalid relation with b (or appends b if there are no invalid relations). Once the hole is used, a linear-time search is used to find the next hole. If you will be performing many intermixed insertions and invalidations, you may wish to set useHoles to false. Also, if you are restoring an Entity from an archive, you should pass false.
smtk::attribute::Attributes smtk::model::Entity::attributes | ( | smtk::attribute::ConstDefinitionPtr | def | ) | const |
Return a list of attributes on the entity based on an attribute definition.
Return the attributes associated with the entity that are of type (or derived type) def.
|
static |
Return the next pedigree ID for an entity of the given type when given a vector of counters appropriate to the context.
This does not increment the counter by default (so that it can be used to assign names), however if you pass incr = true, the counter will be incremented.
|
static |
Given a vector of counters, return a numbered name string and advance counters as required.
If you change this method, you may also need to change flagSummmary/flagDescription.
By default, this increments the counter as the name is assigned but the incr argument can be provided to override this behavior.
int smtk::model::Entity::dimension | ( | ) | const |
Return the dimension of the associated entity.
When entityFlags() includes the CELL bit, this must be in [0,3] for the cell to be considered valid. For the SHELL bit, this must be in [1,3] for the shell to be valid. For the USE bit, this must be in [0,2] for the use to be valid.
For the GROUP bit, the integer returned should be treated as a bit vector. Valid values include [0,15].
|
static |
Given a dimension number (0, 1, 2, 3, 4), return the proper bitcode.
This does bounds checking and will return 0 for out-of-bound dimensions.
BitFlags smtk::model::Entity::entityFlags | ( | ) | const |
Return the bit vector describing the type and attributes of the associated entity.
|
static |
Return a list the dimension bits set in entityFlags.
The plural reference is set to true if flags has more than 1 dimension bit set. Otherwise, it returns false.
|
static |
Given a bitmask or entity flag, return a string specifier.
The second argument, textual, indicates whether or not the value will be converted to a human-oriented textual description of the bits set or simply a string containing the decimal value of the bit vector. The default is to generate human-oriented text since it is also robust to version changes.
The textual version should never begin with a number so that the inverse of this method (specifierStringToFlag) need not expend effort inferring the format.
int smtk::model::Entity::invalidateRelation | ( | const smtk::common::UUID & | r | ) |
Find the given relation r and invalidate its index.
This returns the invalidated index if the relation was found and -1 if r was not present.
int smtk::model::Entity::invalidateRelationByIndex | ( | int | relIdx | ) |
Given a valid index, invalidate the UUID at that index.
This returns the index upon success or -1 upon failure.
EntityPtr smtk::model::Entity::removeRelation | ( | const smtk::common::UUID & | b | ) |
Remove the relation from the entity.
Do not use this unless you know what you are doing.
Instead of this method, you should probably use invalidateRelation().
This removes the first array entry holding b. When the relation b is not at the end of the entity's array of relations, the index of all following relations is reduced by one (because the array is compacted). Since arrangements store indices into this list of relations, you should only call removeRelation when you also update all of the Entity's arrangements.
void smtk::model::Entity::resetRelations | ( | ) |
Completely clear the entire list of related entities.
|
overridevirtual |
Components are required to return their owning resource (if any).
Components may not have an owning resource at some points in their lifecycle, so be sure to verify the returned value is non-null.
Implements smtk::resource::Component.
|
inlineoverridevirtual |
Assign an ID to this object (used by readers; not for arbitrary reuse).
TODO: care must be taken to modify the recorded ID in all links that connect to this object (see Resource::setId and its treatment of manager registration for reference).
Implements smtk::resource::PersistentObject.
EntityPtr smtk::model::Entity::setup | ( | BitFlags | entityFlags, |
int | dimension, | ||
ResourcePtr | resource = nullptr , |
||
bool | resetRelations = true |
||
) |
Populate an object with the given dimension with a type specified by entityFlags.
By default, this does resets the array of relations, since changing the type or dimension of an object would usually invalidate relations; if it does not, you should pass resetRelations = false.