SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
Go to the documentation of this file.
10 #ifndef smtk_model_Resource_h
11 #define smtk_model_Resource_h
16 #include "smtk/SharedPtr.h"
17 #include "smtk/SystemConfig.h"
19 #include "smtk/model/Arrangement.h"
20 #include "smtk/model/AttributeAssignments.h"
21 #include "smtk/model/AuxiliaryGeometry.h"
22 #include "smtk/model/Entity.h"
23 #include "smtk/model/Events.h"
24 #include "smtk/model/FloatData.h"
25 #include "smtk/model/IntegerData.h"
27 #include "smtk/model/SessionRef.h"
29 #include "smtk/model/Tessellation.h"
31 #include "smtk/geometry/Resource.h"
33 #include "smtk/resource/DerivedFrom.h"
35 #include "smtk/common/UUID.h"
50 #define SMTK_MODEL_RESOURCE_NAME "model"
57 #define SMTK_TESS_GEN_PROP "_tessgen"
63 #define SMTK_MESH_GEN_PROP "_meshgen"
69 #define SMTK_GEOM_STYLE_PROP "_geomstyle"
75 #define SMTK_BOUNDING_BOX_PROP "_boundingBox"
87 typedef UUIDsToEntities::const_iterator UUIDWithConstEntityPtr;
96 typedef storage_type::iterator iter_type;
97 typedef UUIDsToTessellations::iterator tess_iter_type;
107 static constexpr smtk::resource::Links::RoleType AssociationRole = -1;
112 static constexpr smtk::resource::Links::RoleType TessellationRole = -2;
119 shared_ptr<UUIDsToEntities> topology,
120 shared_ptr<UUIDsToTessellations> tess,
121 shared_ptr<UUIDsToTessellations> analysismesh,
122 shared_ptr<UUIDsToAttributeAssignments> attribs,
131 UUIDsToTessellations& tessellations();
132 const UUIDsToTessellations& tessellations()
const;
134 UUIDsToTessellations& analysisMesh();
135 const UUIDsToTessellations& analysisMesh()
const;
155 const std::string&)
const override;
156 void visit(smtk::resource::Component::Visitor&)
const override;
168 const Model& entityref,
188 int higherDimension);
195 iter_type insertEntityOfTypeAndDimension(
BitFlags entityFlags,
int dim);
207 iter_type insertCellOfDimension(
int dim);
219 void setFloatProperty(
221 const std::string& propName,
222 smtk::model::Float propValue);
223 void setFloatProperty(
225 const std::string& propName,
226 const smtk::model::FloatList& propValue);
227 smtk::model::FloatList
const& floatProperty(
229 const std::string& propName)
const;
230 smtk::model::FloatList& floatProperty(
232 const std::string& propName);
233 bool hasFloatProperty(
const smtk::common::UUID& entity,
const std::string& propName)
const;
234 bool removeFloatProperty(
const smtk::common::UUID& entity,
const std::string& propName);
236 void setStringProperty(
238 const std::string& propName,
240 void setStringProperty(
242 const std::string& propName,
246 const std::string& propName)
const;
249 const std::string& propName);
250 bool hasStringProperty(
const smtk::common::UUID& entity,
const std::string& propName)
const;
251 bool removeStringProperty(
const smtk::common::UUID& entity,
const std::string& propName);
253 void setIntegerProperty(
255 const std::string& propName,
256 smtk::model::Integer propValue);
257 void setIntegerProperty(
259 const std::string& propName,
260 const smtk::model::IntegerList& propValue);
261 smtk::model::IntegerList
const& integerProperty(
263 const std::string& propName)
const;
264 smtk::model::IntegerList& integerProperty(
266 const std::string& propName);
267 bool hasIntegerProperty(
const smtk::common::UUID& entity,
const std::string& propName)
const;
268 bool removeIntegerProperty(
const smtk::common::UUID& entity,
const std::string& propName);
273 void assignDefaultNames();
282 bool unregisterSession(
SessionPtr session,
bool expungeSession =
true);
286 EntityRefArray findEntitiesByProperty(
const std::string& pname, Integer pval);
287 EntityRefArray findEntitiesByProperty(
const std::string& pname, Float pval);
288 EntityRefArray findEntitiesByProperty(
const std::string& pname,
const std::string& pval);
289 EntityRefArray findEntitiesByProperty(
const std::string& pname,
const IntegerList& pval);
290 EntityRefArray findEntitiesByProperty(
const std::string& pname,
const FloatList& pval);
294 template<
typename Collection,
typename Type>
295 Collection findEntitiesByTypeAndPropertyAs(
const std::string& pname,
const Type& pval);
296 template<
typename Collection,
typename Type>
297 Collection findEntitiesByTypeAndPropertyAs(
298 const std::string& pname,
299 const std::vector<Type>& pval);
301 template<
typename Collection>
304 return findEntitiesByTypeAndPropertyAs<Collection, long>(pname, pval);
306 template<
typename Collection>
309 return findEntitiesByTypeAndPropertyAs<Collection, long>(pname, pval);
311 template<
typename Collection>
314 return findEntitiesByTypeAndPropertyAs<Collection, double>(pname, pval);
316 template<
typename Collection>
319 return findEntitiesByTypeAndPropertyAs<Collection, double>(pname, pval);
321 template<
typename Collection>
324 return findEntitiesByTypeAndPropertyAs<Collection, std::string>(pname, pval);
326 template<
typename Collection>
328 const std::string& pname,
329 const std::vector<std::string>& pval)
331 return findEntitiesByTypeAndPropertyAs<Collection, std::string>(pname, pval);
333 template<
typename Collection>
334 Collection entitiesMatchingFlagsAs(
BitFlags flags,
bool exactMatch =
true);
336 tess_iter_type setTessellation(
342 tess_iter_type setTessellationAndBoundingBox(
351 const std::vector<double>& coords,
352 int providedBBox = 0);
364 bool removeIfLast =
false);
377 int findArrangementInvolvingEntity(
381 bool findDualArrangements(
386 bool addDualArrangement(
393 int findCellHasUseWithSense(
410 bool findOrAddIncludedShell(
418 bool findOrAddInclusionToCellOrModel(
436 bool associateAttribute(
440 bool disassociateAttribute(
444 bool reverse =
true);
445 bool insertEntityAssociations(
447 std::set<smtk::attribute::AttributePtr>& associations);
448 std::set<smtk::attribute::AttributePtr> associations(
const EntityRef& modelEntity);
501 const std::string& name = std::string());
502 Group addGroup(
int extraFlags = 0,
const std::string& name = std::string());
511 int parametricDim = 3,
512 int embeddingDim = 3,
513 const std::string& name = std::string());
515 addModel(
int parametricDim = 3,
int embeddingDim = 3,
const std::string& name = std::string());
521 bool insertModelFaceWithOrientedOuterLoop(
525 const T& orderedEdgesWithOrientation);
528 bool insertModelFaceOrientedInnerLoop(
531 const T& orderedEdgesWithOrientation);
533 template<
typename T,
typename U,
typename V>
534 bool deleteEntities(T& entities, U& modified, V& expunged,
bool debugLog);
557 void assignDefaultNamesWithOwner(
560 const std::string& ownersName,
561 std::set<smtk::common::UUID>& remaining,
565 void prepareForEntity(std::pair<smtk::common::UUID, EntityPtr>& entry);
569 std::set<smtk::common::UUID>& visited)
const;
572 std::set<smtk::common::UUID>& visited)
const;
575 smtk::shared_ptr<UUIDsToEntities> m_topology;
576 smtk::shared_ptr<UUIDsToTessellations> m_tessellations;
577 smtk::shared_ptr<UUIDsToTessellations> m_analysisMesh;
578 smtk::shared_ptr<UUIDsToAttributeAssignments> m_attributeAssignments;
579 smtk::shared_ptr<UUIDsToSessions> m_sessions;
580 typedef std::owner_less<smtk::attribute::WeakResourcePtr> ResourceLessThan;
581 typedef std::set<smtk::attribute::WeakResourcePtr, ResourceLessThan> WeakResourceSet;
582 WeakResourceSet m_attributeResources;
584 smtk::shared_ptr<Session> m_defaultSession;
586 IntegerList m_globalCounters;
588 std::set<ConditionTrigger> m_conditionTriggers;
589 std::set<OneToOneTrigger> m_oneToOneTriggers;
590 std::set<OneToManyTrigger> m_oneToManyTriggers;
593 template<
typename Collection,
typename Type>
594 Collection Resource::findEntitiesByTypeAndPropertyAs(
const std::string& pname,
const Type& pval)
596 Collection collection;
597 auto& uuidsToValues =
598 this->properties().data().
at<std::unordered_map<smtk::common::UUID, std::vector<Type>>>(pname);
599 for (
auto it = uuidsToValues.begin(); it != uuidsToValues.end(); ++it)
601 if (it->second.size() == 1 && it->second.at(0) == pval)
603 typename Collection::value_type entry(shared_from_this(), it->first);
606 collection.insert(collection.end(), entry);
613 template<
typename Collection,
typename Type>
614 Collection Resource::findEntitiesByTypeAndPropertyAs(
615 const std::string& pname,
616 const std::vector<Type>& pval)
618 Collection collection;
619 auto& uuidsToValues =
620 this->properties().data().
at<std::unordered_map<smtk::common::UUID, std::vector<Type>>>(pname);
621 for (
auto it = uuidsToValues.begin(); it != uuidsToValues.end(); ++it)
623 if (it->second == pval)
625 typename Collection::value_type entry(shared_from_this(), it->first);
628 collection.insert(collection.end(), entry);
635 template<
typename Collection>
636 Collection Resource::entitiesMatchingFlagsAs(
BitFlags mask,
bool exactMatch)
639 Collection collection;
640 for (smtk::common::UUIDs::iterator it = matches.begin(); it != matches.end(); ++it)
642 typename Collection::value_type entry(shared_from_this(), *it);
644 collection.insert(collection.end(), entry);
652 #endif // smtk_model_Resource_h
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
int(* OneToOneCallback)(ResourceEventType, const smtk::model::EntityRef &, const smtk::model::EntityRef &, void *)
Callbacks for one-to-one relationships between entities. WARNING: Likely to change in future releases...
Definition: Events.h:133
Derived resources are subclassed from smtk::resource::Resource.
Definition: DerivedFrom.h:32
A entityref subclass that provides methods specific to 1-d edge cells.
Definition: EdgeUse.h:37
Orientation
Constants that describe a cell-use's orientation relative to its parent cell.
Definition: ArrangementKind.h:39
std::set< smtk::common::UUID > UUIDs
Definition: PublicPointerDefs.h:31
Collection findEntitiesByPropertyAs(const std::string &pname, const std::vector< long > &pval)
Return entities with a property named pname whose values match the given pval.
Definition: Resource.h:307
std::string name() const override
Return the user-assigned name of the resource.
Definition: Resource.cxx:199
A entityref subclass with methods specific to face-shells.
Definition: Shell.h:32
std::pair< ResourceEventChangeType, ResourceEventRelationType > ResourceEventType
A notification of a model resource event.
Definition: Events.h:123
smtk::shared_ptr< smtk::mesh::Resource > ResourcePtr
Definition: PublicPointerDefs.h:356
Store an arrangement of solid model entities.
Definition: Arrangement.h:40
A entityref subclass that provides methods specific to models.
Definition: Model.h:30
unsigned int BitFlags
The integer type used to hold bit values describing an entity's type.
Definition: EntityTypeBits.h:25
std::vector< String > StringList
Use vectors of String objects for holding string properties on model entities.
Definition: StringData.h:32
Collection findEntitiesByPropertyAs(const std::string &pname, Float pval)
Return entities with a property named pname whose values match the given pval.
Definition: Resource.h:312
std::vector< smtk::model::Arrangement > Arrangements
A vector of Arrangements is associated to each Manager entity.
Definition: PublicPointerDefs.h:141
Log messages for later presentation to a user or a file.
Definition: Logger.h:94
Store geometric information related to model entities.
Definition: Tessellation.h:91
@ SESSION_EVERYTHING
Transcribe all information about the entity.
Definition: Session.h:87
A entityref subclass that provides methods specific to 3-d volume cells.
Definition: Volume.h:31
smtk::shared_ptr< smtk::model::Session > SessionPtr
Definition: PublicPointerDefs.h:391
Collection findEntitiesByPropertyAs(const std::string &pname, const std::vector< std::string > &pval)
Return entities with a property named pname whose values match the given pval.
Definition: Resource.h:327
static UUID null()
Generate a nil UUID.
Definition: UUID.cxx:78
A entityref subclass that provides methods specific to 1-d edge cells.
Definition: Edge.h:32
smtk::shared_ptr< smtk::model::Entity > EntityPtr
Definition: PublicPointerDefs.h:423
A entityref subclass that provides methods specific to 0-d vertex cells.
Definition: VolumeUse.h:31
std::set< smtk::resource::ResourcePtr > ResourceSet
Definition: PublicPointerDefs.h:317
std::vector< smtk::model::EntityRef > EntityRefArray
Definition: PublicPointerDefs.h:166
A entityref subclass that provides methods specific to 0-d vertex cells.
Definition: Vertex.h:30
An EntityRef subclass for representing unmodeled geometry to be included in a scene.
Definition: AuxiliaryGeometry.h:44
Store information about solid models.
Definition: Resource.h:91
A entityref subclass that provides methods specific to 0-d vertex cells.
Definition: VertexUse.h:32
#define smtkTypeMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:128
smtk::common::UUIDs entitiesMatchingFlags(BitFlags mask, bool exactMatch=true)
Return all entities of the requested dimension that are present in the solid.
Definition: Resource.cxx:963
A entityref subclass that provides methods specific to entity use records.
Definition: Instance.h:23
A entityref subclass that provides methods specific to entity use records.
Definition: SessionRef.h:28
std::string String
Use std::string for holding string values.
Definition: StringData.h:30
UUIDsToEntities::iterator UUIDWithEntityPtr
An abbreviation for an iterator into primary model storage.
Definition: Resource.h:86
Store information about attribute definitions and instances.
Definition: Resource.h:76
unsigned long SessionInfoBits
Bit-vector combinations of SessionInformation values for requesting information to transcribe.
Definition: Session.h:34
A entityref subclass that provides methods specific to entity use records.
Definition: Group.h:27
std::map< smtk::common::UUID, EntityPtr > UUIDsToEntities
Store information mapping IDs to Entity records. This is the primary storage for SMTK models.
Definition: Resource.h:83
#define smtkSharedPtrCreateMacro(...)
A convenience macro for declaring shared_from_this and create methods.
Definition: SharedFromThis.h:267
A entityref subclass with methods specific to edge-loops.
Definition: Loop.h:33
A entityref subclass that provides methods specific to 0-d vertex cells.
Definition: FaceUse.h:37
std::map< smtk::common::UUID, AttributeAssignments > UUIDsToAttributeAssignments
Each Manager entity's UUID is mapped to a set of assigned attribute IDs.
Definition: AttributeAssignments.h:43
A entityref subclass that provides methods specific to 2-d face cells.
Definition: Face.h:36
A entityref subclass with methods specific to vertex-chains.
Definition: Chain.h:38
Collection findEntitiesByPropertyAs(const std::string &pname, const std::string &pval)
Return entities with a property named pname whose values match the given pval.
Definition: Resource.h:322
std::vector< smtk::model::SessionRef > SessionRefs
Definition: PublicPointerDefs.h:149
Type & at(const KeyType &key)
Access value of type Type indexed by key.
Definition: TypeMap.h:197
Collection findEntitiesByPropertyAs(const std::string &pname, const std::vector< double > &pval)
Return entities with a property named pname whose values match the given pval.
Definition: Resource.h:317
Component is the base class for records stored in an smtk::resource::Resource.
Definition: Component.h:43
Macros for dealing with shared-pointer classes.
Collection findEntitiesByPropertyAs(const std::string &pname, long pval)
Return entities with a property named pname whose values match the given pval.
Definition: Resource.h:302
int(* OneToManyCallback)(ResourceEventType, const smtk::model::EntityRef &, const smtk::model::EntityRefArray &, void *)
Callbacks for one-to-many relationships between entities. WARNING: Likely to change in future release...
Definition: Events.h:144
ArrangementKind
Specification of how a cell's relations are arranged.
Definition: ArrangementKind.h:48
An abstract base class for SMTK resources and their components.
Definition: PersistentObject.h:39
smtk::shared_ptr< smtk::resource::Manager > ManagerPtr
Definition: PublicPointerDefs.h:281
smtk::shared_ptr< smtk::resource::Component > ComponentPtr
Definition: PublicPointerDefs.h:297
A lightweight entityref pointing to a model entity's resource.
Definition: EntityRef.h:112
int(* ConditionCallback)(ResourceEventType, const smtk::model::EntityRef &, void *)
Callbacks for changes in the condition of an entity. WARNING: Likely to change in future releases.
Definition: Events.h:126
smtk::shared_ptr< smtk::attribute::Resource > ResourcePtr
Definition: PublicPointerDefs.h:604
An abstract base class for SMTK resources that provide geometry for themselves and/or their component...
Definition: Resource.h:33
smtk::shared_ptr< smtk::resource::Resource > ResourcePtr
Definition: PublicPointerDefs.h:295
std::vector< smtk::model::ArrangementReference > ArrangementReferences
An array of ArrangementReference objects used, for instance, to enumerate inverse relations.
Definition: PublicPointerDefs.h:138