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"
52 #define SMTK_MODEL_RESOURCE_NAME "model"
59 #define SMTK_TESS_GEN_PROP "_tessgen"
65 #define SMTK_MESH_GEN_PROP "_meshgen"
71 #define SMTK_GEOM_STYLE_PROP "_geomstyle"
77 #define SMTK_BOUNDING_BOX_PROP "_boundingBox"
89 typedef UUIDsToEntities::const_iterator UUIDWithConstEntityPtr;
98 typedef storage_type::iterator iter_type;
99 typedef UUIDsToTessellations::iterator tess_iter_type;
109 static constexpr smtk::resource::Links::RoleType AssociationRole = -1;
114 static constexpr smtk::resource::Links::RoleType TessellationRole = -2;
121 shared_ptr<UUIDsToEntities> topology,
122 shared_ptr<UUIDsToTessellations> tess,
123 shared_ptr<UUIDsToTessellations> analysismesh,
124 shared_ptr<UUIDsToAttributeAssignments> attribs,
133 UUIDsToTessellations& tessellations();
134 const UUIDsToTessellations& tessellations()
const;
136 UUIDsToTessellations& analysisMesh();
137 const UUIDsToTessellations& analysisMesh()
const;
157 const std::string&)
const override;
158 void visit(smtk::resource::Component::Visitor&)
const override;
170 const Model& entityref,
190 int higherDimension);
197 iter_type insertEntityOfTypeAndDimension(
BitFlags entityFlags,
int dim);
209 iter_type insertCellOfDimension(
int dim);
221 void setFloatProperty(
223 const std::string& propName,
224 smtk::model::Float propValue);
225 void setFloatProperty(
227 const std::string& propName,
228 const smtk::model::FloatList& propValue);
229 smtk::model::FloatList
const& floatProperty(
231 const std::string& propName)
const;
232 smtk::model::FloatList& floatProperty(
234 const std::string& propName);
235 bool hasFloatProperty(
const smtk::common::UUID& entity,
const std::string& propName)
const;
236 bool removeFloatProperty(
const smtk::common::UUID& entity,
const std::string& propName);
238 void setStringProperty(
240 const std::string& propName,
242 void setStringProperty(
244 const std::string& propName,
248 const std::string& propName)
const;
251 const std::string& propName);
252 bool hasStringProperty(
const smtk::common::UUID& entity,
const std::string& propName)
const;
253 bool removeStringProperty(
const smtk::common::UUID& entity,
const std::string& propName);
255 void setIntegerProperty(
257 const std::string& propName,
258 smtk::model::Integer propValue);
259 void setIntegerProperty(
261 const std::string& propName,
262 const smtk::model::IntegerList& propValue);
263 smtk::model::IntegerList
const& integerProperty(
265 const std::string& propName)
const;
266 smtk::model::IntegerList& integerProperty(
268 const std::string& propName);
269 bool hasIntegerProperty(
const smtk::common::UUID& entity,
const std::string& propName)
const;
270 bool removeIntegerProperty(
const smtk::common::UUID& entity,
const std::string& propName);
275 void assignDefaultNames();
284 bool unregisterSession(
SessionPtr session,
bool expungeSession =
true);
288 EntityRefArray findEntitiesByProperty(
const std::string& pname, Integer pval);
289 EntityRefArray findEntitiesByProperty(
const std::string& pname, Float pval);
290 EntityRefArray findEntitiesByProperty(
const std::string& pname,
const std::string& pval);
291 EntityRefArray findEntitiesByProperty(
const std::string& pname,
const IntegerList& pval);
292 EntityRefArray findEntitiesByProperty(
const std::string& pname,
const FloatList& pval);
296 template<
typename Collection,
typename Type>
297 Collection findEntitiesByTypeAndPropertyAs(
const std::string& pname,
const Type& pval);
298 template<
typename Collection,
typename Type>
299 Collection findEntitiesByTypeAndPropertyAs(
300 const std::string& pname,
301 const std::vector<Type>& pval);
303 template<
typename Collection>
306 return findEntitiesByTypeAndPropertyAs<Collection, long>(pname, pval);
308 template<
typename Collection>
311 return findEntitiesByTypeAndPropertyAs<Collection, long>(pname, pval);
313 template<
typename Collection>
316 return findEntitiesByTypeAndPropertyAs<Collection, double>(pname, pval);
318 template<
typename Collection>
321 return findEntitiesByTypeAndPropertyAs<Collection, double>(pname, pval);
323 template<
typename Collection>
326 return findEntitiesByTypeAndPropertyAs<Collection, std::string>(pname, pval);
328 template<
typename Collection>
330 const std::string& pname,
331 const std::vector<std::string>& pval)
333 return findEntitiesByTypeAndPropertyAs<Collection, std::string>(pname, pval);
335 template<
typename Collection>
336 Collection entitiesMatchingFlagsAs(
BitFlags flags,
bool exactMatch =
true);
338 tess_iter_type setTessellation(
344 tess_iter_type setTessellationAndBoundingBox(
353 const std::vector<double>& coords,
354 int providedBBox = 0);
366 bool removeIfLast =
false);
379 int findArrangementInvolvingEntity(
383 bool findDualArrangements(
388 bool addDualArrangement(
395 int findCellHasUseWithSense(
412 bool findOrAddIncludedShell(
420 bool findOrAddInclusionToCellOrModel(
438 bool associateAttribute(
442 bool disassociateAttribute(
446 bool reverse =
true);
447 bool insertEntityAssociations(
449 std::set<smtk::attribute::AttributePtr>& associations);
450 std::set<smtk::attribute::AttributePtr> associations(
const EntityRef& modelEntity);
503 const std::string& name = std::string());
504 Group addGroup(
int extraFlags = 0,
const std::string& name = std::string());
513 int parametricDim = 3,
514 int embeddingDim = 3,
515 const std::string& name = std::string());
517 addModel(
int parametricDim = 3,
int embeddingDim = 3,
const std::string& name = std::string());
523 bool insertModelFaceWithOrientedOuterLoop(
527 const T& orderedEdgesWithOrientation);
530 bool insertModelFaceOrientedInnerLoop(
533 const T& orderedEdgesWithOrientation);
535 template<
typename T,
typename U,
typename V>
536 bool deleteEntities(T& entities, U& modified, V& expunged,
bool debugLog);
559 void assignDefaultNamesWithOwner(
562 const std::string& ownersName,
563 std::set<smtk::common::UUID>& remaining,
567 void prepareForEntity(std::pair<smtk::common::UUID, EntityPtr>& entry);
571 std::set<smtk::common::UUID>& visited)
const;
574 std::set<smtk::common::UUID>& visited)
const;
577 smtk::shared_ptr<UUIDsToEntities> m_topology;
578 smtk::shared_ptr<UUIDsToTessellations> m_tessellations;
579 smtk::shared_ptr<UUIDsToTessellations> m_analysisMesh;
580 smtk::shared_ptr<UUIDsToAttributeAssignments> m_attributeAssignments;
581 smtk::shared_ptr<UUIDsToSessions> m_sessions;
582 typedef std::owner_less<smtk::attribute::WeakResourcePtr> ResourceLessThan;
583 typedef std::set<smtk::attribute::WeakResourcePtr, ResourceLessThan> WeakResourceSet;
584 WeakResourceSet m_attributeResources;
586 smtk::shared_ptr<Session> m_defaultSession;
588 IntegerList m_globalCounters;
590 std::set<ConditionTrigger> m_conditionTriggers;
591 std::set<OneToOneTrigger> m_oneToOneTriggers;
592 std::set<OneToManyTrigger> m_oneToManyTriggers;
595 template<
typename Collection,
typename Type>
596 Collection Resource::findEntitiesByTypeAndPropertyAs(
const std::string& pname,
const Type& pval)
598 Collection collection;
599 auto& uuidsToValues =
600 this->properties().data().
at<std::unordered_map<smtk::common::UUID, std::vector<Type>>>(pname);
601 for (
auto it = uuidsToValues.begin(); it != uuidsToValues.end(); ++it)
603 if (it->second.size() == 1 && it->second.at(0) == pval)
605 typename Collection::value_type entry(shared_from_this(), it->first);
608 collection.insert(collection.end(), entry);
615 template<
typename Collection,
typename Type>
616 Collection Resource::findEntitiesByTypeAndPropertyAs(
617 const std::string& pname,
618 const std::vector<Type>& pval)
620 Collection collection;
621 auto& uuidsToValues =
622 this->properties().data().
at<std::unordered_map<smtk::common::UUID, std::vector<Type>>>(pname);
623 for (
auto it = uuidsToValues.begin(); it != uuidsToValues.end(); ++it)
625 if (it->second == pval)
627 typename Collection::value_type entry(shared_from_this(), it->first);
630 collection.insert(collection.end(), entry);
637 template<
typename Collection>
638 Collection Resource::entitiesMatchingFlagsAs(
BitFlags mask,
bool exactMatch)
641 Collection collection;
642 for (smtk::common::UUIDs::iterator it = matches.begin(); it != matches.end(); ++it)
644 typename Collection::value_type entry(shared_from_this(), *it);
646 collection.insert(collection.end(), entry);
654 #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:309
std::string name() const override
Return the user-assigned name of the resource.
Definition: Resource.cxx:198
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:314
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:95
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:329
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:93
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:51
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:88
Store information about attribute definitions and instances.
Definition: Resource.h:77
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:85
#define smtkSharedPtrCreateMacro(...)
A convenience macro for declaring shared_from_this and create methods.
Definition: SharedFromThis.h:207
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:324
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:319
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:304
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