Commit bac551d5 authored by David Thompson's avatar David Thompson

Free-form properties for all resources and components.

+ Add property and property-storage classes.
+ Eliminate duplicate floating-point storage in smtk::model.
+ Eliminate `smtk/model/FloatData.h`.
  These types have moved to `smtk/resource/PropertyType.h`.
+ Eliminate m_floatData in smtk::model::Resource and methods
  that provided access.
  The new methods for accessing property are available on
  a per-entity basis in smtk::model::EntityRef.
+ Move SetProperty operation from model to operation
  directory/namespace.
parent 455469b6
Pipeline #147458 failed with stage
......@@ -13,3 +13,4 @@ so that the provenance of all the inputs to a simulation can be tracked.
:maxdepth: 3
concepts.rst
properties.rst
Properties
==========
All SMTK resources and components may have dynamic, free-form properties placed upon them.
These :smtk:`dynamic properties <smtk::resource::DynamicProperty>` are given string keys
and have values that may be a vector of integers, floating-point numbers, or strings.
The query methods (e.g., :smtk:`smtk::resource::Resource::queryOperation`) allow you to
filter components based on the presence or values of these properties, making it easy
to locate and group components based on runtime data present in resources.
Dynamic properties are implemented so that custom subclasses
of :smtk:`smtk::resource::Resource` may store arbitrary structured data.
While this is not advised as a way to extend attribute resources, it is
intended for custom model resources where existing modeling entity types
need to be extended with additional, application-specific information.
Some examples include:
+ A hydrological modeling simulation where some edges are intended to
represent rivers and some edges are intended to represent roads.
Roads may need to be marked with the number of lanes in each direction
while rivers might store salinity.
+ A medical application where surfaces represent organ boundaries, some
of which are simple while others might represent tissue with anisotropic
fibers whose orientations must be modeled with a spatially-varying frame field.
Each face might store a varying-length list of spatial locations and a
fiber orientation at each location.
In both cases, model entities (edges, faces, etc.) may be extended with additional
structures for storing values.
We will discuss both types of property information in separate sections below.
Dynamic properties
------------------
As mentioned above, _dynamic_ properties store vectors of plain-old data (POD) types
with string names.
While the types of the values are fixed at compile time, the number of values and
expectations for which types of objects may hold what data are set at run time.
You may access these values by calling
the :smtk:`dynamicProperties<T>() <smtk::resource::Resource::dynamicProperties>`
method on a resource or component.
The template parameter should be one of:
+ :smtk:`smtk::resource::Integer`
+ :smtk:`smtk::resource::Float`
+ :smtk:`smtk::resource::String`
Dynamic properties are persistent; they are always included when a resource is serialized.
Extended properties
-------------------
When you want compile-time type safety to ensure that certain properties exist on
custom components and resources, you may also use the same framework used to
implement dynamic properties above to extend the property system.
In this case, properties you add may be arbitrary structures rather than POD types.
We will call these _extended_ properties to differentiate them from the dynamic
properties above.
To add extended properties, you must add storage to the :smtk:`smtk::resource::Properties`
instance owned by a resource and then add methods to the resource and/or component
subclasses you create to provide access to the properties.
......@@ -262,6 +262,7 @@ typedef smtk::shared_ptr<smtk::resource::PersistentObject> PersistentObjectPtr;
typedef smtk::shared_ptr<smtk::resource::Resource> ResourcePtr;
typedef smtk::shared_ptr<smtk::resource::Component> ComponentPtr;
typedef smtk::weak_ptr<smtk::resource::Resource> WeakResourcePtr;
typedef smtk::weak_ptr<const smtk::resource::Resource> ConstWeakResourcePtr;
typedef smtk::shared_ptr<smtk::resource::Set> SetPtr;
typedef smtk::shared_ptr<const smtk::resource::Component> ConstComponentPtr;
typedef smtk::shared_ptr<const smtk::resource::Resource> ConstResourcePtr;
......
......@@ -169,7 +169,9 @@ public:
template <typename Container>
void as(Container& result,
std::function<typename Container::value_type(const PersistentObjectPtr&)> converter = [](
const PersistentObjectPtr& obj) { return obj; }) const
const PersistentObjectPtr& obj) -> typename Container::value_type {
return std::dynamic_pointer_cast<typename Container::value_type::element_type>(obj);
}) const
{
for (auto it = this->begin(); it != this->end(); ++it)
{
......@@ -181,8 +183,11 @@ public:
}
}
template <typename Container>
Container as(std::function<typename Container::value_type(const PersistentObjectPtr&)> converter =
[](const PersistentObjectPtr& obj) { return obj; }) const
Container as(
std::function<typename Container::value_type(const PersistentObjectPtr&)> converter = [](
const PersistentObjectPtr& obj) {
return std::dynamic_pointer_cast<typename Container::value_type::element_type>(obj);
}) const
{
Container result;
this->as(result, converter);
......
......@@ -18,10 +18,7 @@
#include "smtk/model/Entity.h"
#include "smtk/model/EntityRef.h"
#include "smtk/model/FloatData.h"
#include "smtk/model/IntegerData.h"
#include "smtk/model/Resource.h"
#include "smtk/model/StringData.h"
#include "smtk/mesh/core/Component.h"
#include "smtk/mesh/core/Resource.h"
......
......@@ -28,7 +28,6 @@
#include "smtk/model/Resource.h"
#include "smtk/model/Session.h"
#include "smtk/model/StringData.h"
#include "smtk/view/View.h"
#include "smtk/io/Logger.h"
......
......@@ -13,12 +13,9 @@
#include "smtk/extension/qt/qtModelView.h"
#include "smtk/model/Entity.h"
#include "smtk/model/EntityRef.h"
#include "smtk/model/FloatData.h"
#include "smtk/model/Group.h"
#include "smtk/model/IntegerData.h"
#include "smtk/model/Model.h"
#include "smtk/model/Resource.h"
#include "smtk/model/StringData.h"
#include <QPointer>
......
......@@ -16,13 +16,10 @@
#include "smtk/model/Entity.h"
#include "smtk/model/EntityIterator.h"
#include "smtk/model/FloatData.h"
#include "smtk/model/Group.h"
#include "smtk/model/IntegerData.h"
#include "smtk/model/Model.h"
#include "smtk/model/Resource.h"
#include "smtk/model/SessionRef.h"
#include "smtk/model/StringData.h"
#include "smtk/model/SessionRef.h"
......
......@@ -22,9 +22,12 @@
#include "smtk/model/Volume.h"
#include "smtk/mesh/core/CellSet.h"
#include "smtk/mesh/core/Component.h"
#include "smtk/mesh/core/DimensionTypes.h"
#include "smtk/mesh/core/Resource.h"
#include "smtk/resource/Properties.h"
#include "smtk/extension/vtk/io/mesh/ExportVTKData.h"
#include "vtkCellArray.h"
......@@ -134,7 +137,9 @@ static void internal_AddBlockInfo(const smtk::mesh::ResourcePtr& meshcollect,
const smtk::model::EntityRef& bordantCell, const vtkIdType& blockId, vtkPolyData* poly,
std::map<smtk::common::UUID, vtkIdType>& uuid2BlockId)
{
meshcollect->setIntegerProperty(blockmesh, "block_index", blockId);
(void)meshcollect;
auto meshComp = smtk::mesh::Component::create(blockmesh);
meshComp->properties().get<smtk::resource::Integer>()["block_index"] = IntegerList(1, blockId);
internal_AddBlockEntityInfo(blockmesh, entityref, blockId, poly, uuid2BlockId);
......
......@@ -25,9 +25,9 @@ vtkSmartPointer<T> vtkModelAuxiliaryGeometry::ReadData(
vtkSmartPointer<T> data = vtkSmartPointer<T>::New();
if (auxGeom.hasFloatProperties())
{
const smtk::model::FloatData& props(auxGeom.floatProperties());
const smtk::resource::FloatData& props(auxGeom.floatProperties());
const char* propNames[3] = { "scale", "rotate", "translate" };
smtk::model::FloatData::const_iterator propIt;
smtk::resource::FloatData::const_iterator propIt;
bool hasTransform = false;
vtkNew<vtkTransform> tfm;
//tfm->PostMultiply();
......
......@@ -36,6 +36,8 @@
#include "smtk/model/UseEntity.h"
#include "smtk/model/Volume.h"
#include "smtk/resource/Properties.h"
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkDataObjectTreeIterator.h"
......@@ -315,7 +317,9 @@ static void addBlockInfo(const smtk::model::ResourcePtr& resource,
const vtkIdType& blockId, vtkDataObject* dobj,
std::map<smtk::common::UUID, vtkIdType>& uuid2BlockId)
{
resource->setIntegerProperty(entityref.entity(), "block_index", blockId);
(void)resource;
entityref.entityRecord()->properties().get<smtk::resource::Integer>()["block_index"] =
smtk::resource::IntegerList(1, blockId);
uuid2BlockId[entityref.entity()] = blockId;
// Add Entity UUID to fieldData
......
......@@ -47,7 +47,6 @@
#include "smtk/model/EntityRef.h"
#include "smtk/model/Group.h"
#include "smtk/model/Resource.h"
#include "smtk/model/StringData.h"
#include <sstream>
......
......@@ -22,6 +22,8 @@
#include "smtk/model/EntityRef.h"
#include "smtk/model/Resource.h"
#include "smtk/resource/Properties.h"
SMTK_THIRDPARTY_PRE_INCLUDE
#define BOOST_FILESYSTEM_VERSION 3
#include "boost/filesystem.hpp"
......@@ -334,6 +336,7 @@ std::vector<MeshByRegion> subsetByModelProperty(smtk::mesh::ResourcePtr meshReso
smtk::model::ResourcePtr resource, const std::string& modelPropertyName,
smtk::mesh::DimensionType type)
{
(void)resource;
std::vector<MeshByRegion> meshesByModelRef;
smtk::mesh::MeshSet meshes = meshResource->meshes(type);
if (meshes.is_empty())
......@@ -347,14 +350,18 @@ std::vector<MeshByRegion> subsetByModelProperty(smtk::mesh::ResourcePtr meshReso
typedef smtk::model::EntityRefArray::const_iterator it;
for (it i = modelIds.begin(); i != modelIds.end(); ++i)
{
const smtk::model::IntegerList& values =
resource->integerProperty(i->entity(), modelPropertyName);
smtk::mesh::MeshSet subset = meshResource->findAssociatedMeshes(*i, type);
if (values.size() == 1 && !subset.is_empty())
{ //only accept model properties that have single values
//since that is what we think region id's should be
const int& region = values[0];
meshesByModelRef.push_back(MeshByRegion(subset, region, type));
const auto& iprops = i->entityRecord()->properties().get<smtk::resource::Integer>();
smtk::resource::IntegerData::const_iterator pit;
if ((pit = iprops.find(modelPropertyName)) != iprops.end() && !pit->second.empty())
{
const smtk::model::IntegerList& values = pit->second;
smtk::mesh::MeshSet subset = meshResource->findAssociatedMeshes(*i, type);
if (values.size() == 1 && !subset.is_empty())
{ //only accept model properties that have single values
//since that is what we think region id's should be
const int& region = values[0];
meshesByModelRef.push_back(MeshByRegion(subset, region, type));
}
}
}
......
......@@ -18,7 +18,6 @@
#include "smtk/model/Resource.h"
#include "smtk/model/SessionIOJSON.h"
#include "smtk/model/SessionRegistrar.h"
#include "smtk/model/StringData.h"
#include "smtk/model/Tessellation.h"
#include "smtk/attribute/Attribute.h"
......
......@@ -127,7 +127,6 @@ set(meshHeaders
operators/Write.h
operators/WriteResource.h
resource/PropertyData.h
resource/Registrar.h
resource/Selection.h
......
This diff is collapsed.
......@@ -18,8 +18,6 @@
#include "smtk/common/FileLocation.h"
#include "smtk/common/UUID.h"
#include "smtk/mesh/resource/PropertyData.h"
#include "smtk/mesh/core/CellSet.h"
#include "smtk/mesh/core/Component.h"
#include "smtk/mesh/core/Handle.h"
......@@ -294,48 +292,6 @@ public:
void setModelResource(smtk::model::ResourcePtr resource) { m_modelResource = resource; }
smtk::model::ResourcePtr modelResource() const { return m_modelResource.lock(); }
// Float, String, Integer properties for a meshset given its handle range.
void setFloatProperty(
const smtk::mesh::MeshSet& meshset, const std::string& propName, smtk::model::Float propValue);
void setFloatProperty(const smtk::mesh::MeshSet& meshset, const std::string& propName,
const smtk::model::FloatList& propValue);
smtk::model::FloatList const& floatProperty(
const smtk::mesh::MeshSet& meshset, const std::string& propName) const;
smtk::model::FloatList& floatProperty(
const smtk::mesh::MeshSet& meshset, const std::string& propName);
bool hasFloatProperty(const smtk::mesh::MeshSet& meshset, const std::string& propName) const;
bool removeFloatProperty(const smtk::mesh::MeshSet& meshset, const std::string& propName);
void setStringProperty(const smtk::mesh::MeshSet& meshset, const std::string& propName,
const smtk::model::String& propValue);
void setStringProperty(const smtk::mesh::MeshSet& meshset, const std::string& propName,
const smtk::model::StringList& propValue);
smtk::model::StringList const& stringProperty(
const smtk::mesh::MeshSet& meshset, const std::string& propName) const;
smtk::model::StringList& stringProperty(
const smtk::mesh::MeshSet& meshset, const std::string& propName);
bool hasStringProperty(const smtk::mesh::MeshSet& meshset, const std::string& propName) const;
bool removeStringProperty(const smtk::mesh::MeshSet& meshset, const std::string& propName);
void setIntegerProperty(const smtk::mesh::MeshSet& meshset, const std::string& propName,
smtk::model::Integer propValue);
void setIntegerProperty(const smtk::mesh::MeshSet& meshset, const std::string& propName,
const smtk::model::IntegerList& propValue);
smtk::model::IntegerList const& integerProperty(
const smtk::mesh::MeshSet& meshset, const std::string& propName) const;
smtk::model::IntegerList& integerProperty(
const smtk::mesh::MeshSet& meshset, const std::string& propName);
bool hasIntegerProperty(const smtk::mesh::MeshSet& meshset, const std::string& propName) const;
bool removeIntegerProperty(const smtk::mesh::MeshSet& meshset, const std::string& propName);
// For T = {MeshIntegerData, MeshFloatData, MeshStringData}:
template <typename T>
T* properties();
// For T = {IntegerData, FloatData, StringData}:
template <typename T>
T* meshProperties(const smtk::mesh::MeshSet& meshset);
template <typename T>
bool removeProperty(const smtk::mesh::MeshSet& meshset, const std::string& name);
private:
Resource(const Resource& other); //blank since we are used by shared_ptr
Resource& operator=(const Resource& other); //blank since we are used by shared_ptr
......@@ -358,9 +314,6 @@ private:
smtk::common::FileLocation m_writeLocation;
smtk::model::WeakResourcePtr m_modelResource;
smtk::shared_ptr<MeshFloatData> m_floatData;
smtk::shared_ptr<MeshStringData> m_stringData;
smtk::shared_ptr<MeshIntegerData> m_integerData;
int m_nameCounter;
......
......@@ -62,14 +62,7 @@ PySharedPtrClass< smtk::mesh::Resource> pybind11_init_smtk_mesh_Resource(py::mod
.def("findAssociatedTypes", (smtk::mesh::TypeSet (smtk::mesh::Resource::*)(::smtk::model::EntityRef const &) const) &smtk::mesh::Resource::findAssociatedTypes, py::arg("eref"))
.def("findAssociatedTypes", (smtk::mesh::TypeSet (smtk::mesh::Resource::*)(::smtk::common::UUID const &) const) &smtk::mesh::Resource::findAssociatedTypes, py::arg("id"))
.def("findAssociatedTypes", (smtk::mesh::TypeSet (smtk::mesh::Resource::*)(::smtk::model::EntityIterator &) const) &smtk::mesh::Resource::findAssociatedTypes, py::arg("refIt"))
.def("floatProperty", (smtk::model::FloatList const & (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &) const) &smtk::mesh::Resource::floatProperty, py::arg("meshset"), py::arg("propName"))
.def("floatProperty", (smtk::model::FloatList & (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &)) &smtk::mesh::Resource::floatProperty, py::arg("meshset"), py::arg("propName"))
.def("hasAssociations", &smtk::mesh::Resource::hasAssociations)
.def("hasFloatProperty", &smtk::mesh::Resource::hasFloatProperty, py::arg("meshset"), py::arg("propName"))
.def("hasIntegerProperty", &smtk::mesh::Resource::hasIntegerProperty, py::arg("meshset"), py::arg("propName"))
.def("hasStringProperty", &smtk::mesh::Resource::hasStringProperty, py::arg("meshset"), py::arg("propName"))
.def("integerProperty", (smtk::model::IntegerList const & (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &) const) &smtk::mesh::Resource::integerProperty, py::arg("meshset"), py::arg("propName"))
.def("integerProperty", (smtk::model::IntegerList & (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &)) &smtk::mesh::Resource::integerProperty, py::arg("meshset"), py::arg("propName"))
.def("interface", &smtk::mesh::Resource::interface)
.def("interfaceName", &smtk::mesh::Resource::interfaceName)
.def("isAssociatedToModel", &smtk::mesh::Resource::isAssociatedToModel)
......@@ -88,23 +81,12 @@ PySharedPtrClass< smtk::mesh::Resource> pybind11_init_smtk_mesh_Resource(py::mod
.def("pointConnectivity", &smtk::mesh::Resource::pointConnectivity)
.def("points", &smtk::mesh::Resource::points)
.def("readLocation", (const smtk::common::FileLocation& (smtk::mesh::Resource::*)() const) &smtk::mesh::Resource::readLocation)
.def("removeFloatProperty", &smtk::mesh::Resource::removeFloatProperty, py::arg("meshset"), py::arg("propName"))
.def("removeIntegerProperty", &smtk::mesh::Resource::removeIntegerProperty, py::arg("meshset"), py::arg("propName"))
.def("removeMeshes", &smtk::mesh::Resource::removeMeshes, py::arg("meshesToDelete"))
.def("removeStringProperty", &smtk::mesh::Resource::removeStringProperty, py::arg("meshset"), py::arg("propName"))
.def("setAssociation", &smtk::mesh::Resource::setAssociation, py::arg("eref"), py::arg("meshset"))
.def("setDirichletOnMeshes", &smtk::mesh::Resource::setDirichletOnMeshes, py::arg("meshes"), py::arg("d"))
.def("setDomainOnMeshes", &smtk::mesh::Resource::setDomainOnMeshes, py::arg("meshes"), py::arg("m"))
.def("setFloatProperty", (void (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &, ::smtk::model::Float)) &smtk::mesh::Resource::setFloatProperty, py::arg("meshset"), py::arg("propName"), py::arg("propValue"))
.def("setFloatProperty", (void (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &, ::smtk::model::FloatList const &)) &smtk::mesh::Resource::setFloatProperty, py::arg("meshset"), py::arg("propName"), py::arg("propValue"))
.def("setIntegerProperty", (void (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &, ::smtk::model::Integer)) &smtk::mesh::Resource::setIntegerProperty, py::arg("meshset"), py::arg("propName"), py::arg("propValue"))
.def("setIntegerProperty", (void (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &, ::smtk::model::IntegerList const &)) &smtk::mesh::Resource::setIntegerProperty, py::arg("meshset"), py::arg("propName"), py::arg("propValue"))
// .def("setName", [](smtk::mesh::Resource::Ptr& resource, const std::string& name) { resource->setName(name); })
.def("setNeumannOnMeshes", &smtk::mesh::Resource::setNeumannOnMeshes, py::arg("meshes"), py::arg("n"))
.def("setStringProperty", (void (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &, ::smtk::model::String const &)) &smtk::mesh::Resource::setStringProperty, py::arg("meshset"), py::arg("propName"), py::arg("propValue"))
.def("setStringProperty", (void (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &, ::smtk::model::StringList const &)) &smtk::mesh::Resource::setStringProperty, py::arg("meshset"), py::arg("propName"), py::arg("propValue"))
.def("stringProperty", (smtk::model::StringList const & (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &) const) &smtk::mesh::Resource::stringProperty, py::arg("meshset"), py::arg("propName"))
.def("stringProperty", (smtk::model::StringList & (smtk::mesh::Resource::*)(::smtk::mesh::MeshSet const &, ::std::string const &)) &smtk::mesh::Resource::stringProperty, py::arg("meshset"), py::arg("propName"))
.def("types", &smtk::mesh::Resource::types)
.def("writeLocation", (void (smtk::mesh::Resource::*)(::smtk::common::FileLocation const &)) &smtk::mesh::Resource::writeLocation, py::arg("path"))
.def("writeLocation", (void (smtk::mesh::Resource::*)(::std::string const &)) &smtk::mesh::Resource::writeLocation, py::arg("path"))
......
......@@ -13,7 +13,6 @@ set(modelOps
GroupAuxiliaryGeometry
MergeInstances
SetInstancePrototype
SetProperty
TerrainExtraction
)
......@@ -88,11 +87,9 @@ set(modelHeaders
Face.h
FaceUse.h
FilterGrammar.h
FloatData.h
GridInfo.h
Group.h
Instance.h
IntegerData.h
LimitingClause.h
Loop.h
Model.h
......@@ -103,7 +100,6 @@ set(modelHeaders
ShellEntity.txx
Resource.h
Resource.txx
StringData.h
Tessellation.h
UseEntity.h
Vertex.h
......
......@@ -17,6 +17,8 @@
#include "smtk/attribute/Definition.h"
#include "smtk/attribute/Resource.h"
#include "smtk/resource/Component.h"
#include "smtk/resource/Properties.h"
#include "smtk/resource/PropertyType.h"
#include "smtk/resource/Resource.h"
......@@ -1304,8 +1306,8 @@ Entity::QueryFunctor limitedQueryFunctor(
{
case smtk::resource::PropertyType::FLOAT_PROPERTY:
{
auto props = modelRsrc->floatPropertiesForEntity(comp->id());
if (props == modelRsrc->floatProperties().end() || props->second.empty())
const auto& props = comp->properties().get<smtk::resource::Float>();
if (props.empty())
{
return false;
}
......@@ -1313,8 +1315,8 @@ Entity::QueryFunctor limitedQueryFunctor(
{
return true;
}
auto pit = props->second.find(clause.m_propName);
if (pit == props->second.end())
auto pit = props.find(clause.m_propName);
if (pit == props.end())
{
return false;
}
......@@ -1331,8 +1333,8 @@ Entity::QueryFunctor limitedQueryFunctor(
case smtk::resource::PropertyType::STRING_PROPERTY:
{
auto props = modelRsrc->stringPropertiesForEntity(comp->id());
if (props == modelRsrc->stringProperties().end() || props->second.empty())
const auto& props = comp->properties().get<smtk::resource::String>();
if (props.empty())
{
return false;
}
......@@ -1343,8 +1345,8 @@ Entity::QueryFunctor limitedQueryFunctor(
StringData::const_iterator pit;
if (!clause.m_propNameIsRegex)
{
pit = props->second.find(clause.m_propName);
if (pit == props->second.end())
pit = props.find(clause.m_propName);
if (pit == props.end())
{
return false;
}
......@@ -1353,7 +1355,7 @@ Entity::QueryFunctor limitedQueryFunctor(
else
{
regex re(clause.m_propName);
for (pit = props->second.begin(); pit != props->second.end(); ++pit)
for (pit = props.begin(); pit != props.end(); ++pit)
{
if (regex_search(pit->first, re))
{
......@@ -1371,8 +1373,8 @@ Entity::QueryFunctor limitedQueryFunctor(
case smtk::resource::PropertyType::INTEGER_PROPERTY:
{
auto props = modelRsrc->integerPropertiesForEntity(comp->id());
if (props == modelRsrc->integerProperties().end() || props->second.empty())
const auto& props = comp->properties().get<smtk::resource::Integer>();
if (props.empty())
{
return false;
}
......@@ -1380,8 +1382,8 @@ Entity::QueryFunctor limitedQueryFunctor(
{
return true;
}
auto pit = props->second.find(clause.m_propName);
if (pit == props->second.end())
auto pit = props.find(clause.m_propName);
if (pit == props.end())
{
return false;
}
......
......@@ -17,8 +17,8 @@
#include "smtk/model/Arrangement.h" // for Arrangement, ArrangementKind
#include "smtk/model/EntityTypeBits.h" // for entityFlags values
#include "smtk/model/IntegerData.h" // for IntegerList
#include "smtk/model/StringData.h" // for StringList
#include "smtk/resource/PropertyType.h" // for IntegerList
#include <map>
#include <set>
......@@ -49,6 +49,7 @@ class SMTKCORE_EXPORT Entity : public smtk::resource::Component
public:
using UUID = smtk::common::UUID;
using IntegerList = smtk::resource::IntegerList;
using QueryFunctor = std::function<bool(const smtk::resource::ConstComponentPtr&)>;
//using ResourcePtr = smtk::resource::ResourcePtr;
......
This diff is collapsed.
......@@ -17,14 +17,15 @@
#include "smtk/common/UUID.h"
#include "smtk/resource/PropertyType.h"
#include "smtk/model/Arrangement.h" // for ArrangementKind and Arrangements types
#include "smtk/model/AttributeAssignments.h" // for BitFlags type
#include "smtk/model/Entity.h" // for isValid() method
#include "smtk/model/EntityTypeBits.h" // for BitFlags type
#include "smtk/model/Events.h" // for ResourceEventRelationType type
#include "smtk/model/FloatData.h" // for Float, FloatData, ...
#include "smtk/model/IntegerData.h" // for Integer, IntegerData, ...
#include "smtk/model/StringData.h" // for String, StringData, ...
#include "smtk/resource/PropertyType.h" // for Float, FloatData, String, StringData, ...
#include <iostream>
#include <set>
......@@ -84,6 +85,12 @@ class Tessellation;
typedef std::set<EntityRef> EntityRefs;
typedef std::vector<EntityRef> EntityRefArray;
typedef std::vector<Group> Groups;
using FloatList = smtk::resource::FloatList;
using FloatData = smtk::resource::FloatData;
using StringList = smtk::resource::StringList;
using StringData = smtk::resource::StringData;
using IntegerList = smtk::resource::IntegerList;
using IntegerData = smtk::resource::IntegerData;
/**\brief Indicate an entity is excluded from which parts in smtk
*
......@@ -280,10 +287,10 @@ public:
template <typename T>
bool removeProperty(const std::string& name);
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);
void setFloatProperty(const std::string& propName, smtk::resource::Float propValue);
void setFloatProperty(const std::string& propName, const smtk::resource::FloatList& propValue);
smtk::resource::FloatList const& floatProperty(const std::string& propName) const;
smtk::resource::FloatList& floatProperty(const std::string& propName);
bool hasFloatProperty(const std::string& propName) const;
bool removeFloatProperty(const std::string& propName);
bool hasFloatProperties() const;
......@@ -291,10 +298,10 @@ public:
FloatData& floatProperties();
FloatData const& floatProperties() const;
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::StringList& stringProperty(const std::string& propName);
void setStringProperty(const std::string& propName, const smtk::resource::String& propValue);
void setStringProperty(const std::string& propName, const smtk::resource::StringList& propValue);
smtk::resource::StringList const& stringProperty(const std::string& propName) const;
smtk::resource::StringList& stringProperty(const std::string& propName);
bool hasStringProperty(const std::string& propName) const;
bool removeStringProperty(const std::string& propName);
bool hasStringProperties() const;
......@@ -302,10 +309,11 @@ public:
StringData& stringProperties();
StringData const& stringProperties() const;
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);
void setIntegerProperty(const std::string& propName, smtk::resource::Integer propValue);
void setIntegerProperty(
const std::string& propName, const smtk::resource::IntegerList& propValue);
smtk::resource::IntegerList const& integerProperty(const std::string& propName) const;
smtk::resource::IntegerList& integerProperty(const std::string& propName);
bool hasIntegerProperty(const std::string& propName) const;
bool removeIntegerProperty(const std::string& propName);
bool hasIntegerProperties() const;
......
......@@ -51,7 +51,7 @@ static void GenerateTabularTessellation(Instance& inst, Tessellation* placements
{
return;
}
const FloatData& fprops(inst.floatProperties());
const smtk::resource::FloatData& fprops(inst.floatProperties());
auto posn = fprops.find("placements");
int numPosn = static_cast<int>(posn->second.size() / 3);
for (int ii = 0; ii < numPosn; ++ii)
......@@ -66,8 +66,8 @@ static void GenerateRandomTessellation(Instance& inst, Tessellation* placements)
{
return;
}
const FloatData& fprops(inst.floatProperties());
const IntegerData& iprops(inst.integerProperties());
const smtk::resource::FloatData& fprops(inst.floatProperties());
const smtk::resource::IntegerData& iprops(inst.integerProperties());
auto numPts = iprops.find("sample size");
auto seed = iprops.find("seed");
auto voi = fprops.find("voi");
......
//=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#ifndef __smtk_model_IntegerData_h
#define __smtk_model_IntegerData_h
#include "smtk/SystemConfig.h"
#include "smtk/common/UUID.h"
#include <map>
#include <string>
#include <vector>
namespace smtk
{
namespace model
{
typedef long Integer;
typedef std::vector<long> IntegerList;
typedef std::map<std::string, IntegerList> IntegerData;
typedef std::map<smtk::common::UUID, IntegerData> UUIDsToIntegerData;
typedef UUIDsToIntegerData::iterator UUIDWithIntegerProperties;
typedef IntegerData::iterator PropertyNameWithIntegers;
typedef IntegerData::const_iterator PropertyNameWithConstIntegers;
} // namespace model
} // namespace smtk
#endif // __smtk_model_IntegerData_h
......@@ -25,7 +25,6 @@
#include "smtk/model/operators/GroupAuxiliaryGeometry.h"
#include "smtk/model/operators/MergeInstances.h"