Commit c8635af2 authored by T.J. Corona's avatar T.J. Corona Committed by Kitware Robot

Merge topic 'mesh-as-resource-and-components-3'

e80a524f Use mesh::Component for mesh operations
3671e1eb Introduce smtk::mesh::Component
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: David Thompson's avatarDavid Thompson <david.thompson@kitware.com>
Merge-request: !1318
parents 6c2a3834 e80a524f
Pipeline #122739 canceled with stage
in 0 seconds
# Introduce smtk::mesh::Component
To adhere to the Resource/Component paradigm in SMTK 3.0, we have
introduced the lightweight class smtk::mesh::Component, which
facilitates the ability to pass meshsets as component items in an
attribute.
### User-facing changes
`smtk::mesh::Component` is now used to send/retrieve meshsets to/from
attributes.
......@@ -4,6 +4,7 @@ set(meshSrcs
core/CellField.cxx
core/CellTypes.cxx
core/Collection.cxx
core/Component.cxx
core/ForEachTypes.cxx
core/Handle.cxx
core/MeshSet.cxx
......@@ -46,7 +47,6 @@ set(meshSrcs
operators/UndoElevateMesh.cxx
operators/WriteMesh.cxx
resource/MeshComponent.cxx
resource/Registrar.cxx
utility/ApplyToMesh.cxx
......@@ -63,6 +63,7 @@ set(meshHeaders
core/CellTraits.h
core/CellTypes.h
core/Collection.h
core/Component.h
core/DimensionTypes.h
core/FieldTypes.h
core/ForEachTypes.h
......@@ -101,7 +102,6 @@ set(meshHeaders
operators/UndoElevateMesh.h
operators/WriteMesh.h
resource/MeshComponent.h
resource/PropertyData.h
resource/Registrar.h
......
......@@ -10,7 +10,7 @@
#include "smtk/mesh/core/Collection.h"
#include "smtk/mesh/resource/MeshComponent.h"
#include "smtk/mesh/core/Component.h"
#include "smtk/mesh/moab/Interface.h"
......@@ -105,14 +105,8 @@ Collection::~Collection()
smtk::resource::ComponentPtr Collection::find(const smtk::common::UUID& compId) const
{
const smtk::mesh::InterfacePtr& iface = m_internals->mesh_iface();
smtk::mesh::Handle handle;
if (iface->findById(m_internals->mesh_root_handle(), compId, handle))
{
return smtk::mesh::MeshComponent::create(this->shared_from_this(), handle);
}
return smtk::resource::ComponentPtr();
return std::static_pointer_cast<smtk::resource::Component>(
Component::create(std::const_pointer_cast<smtk::mesh::Collection>(shared_from_this()), compId));
}
std::function<bool(const resource::ComponentPtr&)> Collection::queryOperation(
......
//=========================================================================
// 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.
//=========================================================================
#include "smtk/mesh/core/Component.h"
#include "smtk/common/UUIDGenerator.h"
namespace smtk
{
namespace mesh
{
Component::Component(const smtk::mesh::CollectionPtr& collection, const smtk::common::UUID& id)
: m_collection(collection)
, m_id(id)
{
}
Component::Component(const smtk::mesh::MeshSet& meshset)
: Component(meshset.collection(), meshset.id())
{
if (m_id == smtk::common::UUID::null())
{
m_id = smtk::common::UUIDGenerator::instance().random();
const_cast<smtk::mesh::MeshSet&>(meshset).setId(m_id);
}
}
std::shared_ptr<Component> Component::create(
const smtk::mesh::CollectionPtr& collection, const smtk::common::UUID& id)
{
std::shared_ptr<smtk::resource::Component> shared(new Component(collection, id));
return std::static_pointer_cast<smtk::mesh::Component>(shared);
}
std::shared_ptr<Component> Component::create(const smtk::mesh::MeshSet& meshset)
{
std::shared_ptr<smtk::resource::Component> shared(new Component(meshset));
return std::static_pointer_cast<smtk::mesh::Component>(shared);
}
const smtk::resource::ResourcePtr Component::resource() const
{
return std::static_pointer_cast<smtk::resource::Resource>(m_collection.lock());
}
const smtk::mesh::MeshSet Component::mesh() const
{
if (auto collection = m_collection.lock())
{
const smtk::mesh::InterfacePtr& iface = collection->interface();
smtk::mesh::Handle handle;
if (iface->findById(iface->getRoot(), m_id, handle))
{
return smtk::mesh::MeshSet(collection, handle);
}
}
return smtk::mesh::MeshSet();
}
smtk::mesh::MeshSet Component::mesh()
{
if (auto collection = m_collection.lock())
{
const smtk::mesh::InterfacePtr& iface = collection->interface();
smtk::mesh::Handle handle;
if (iface->findById(iface->getRoot(), m_id, handle))
{
return smtk::mesh::MeshSet(collection, handle);
}
}
return smtk::mesh::MeshSet();
}
}
}
//=========================================================================
// 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_mesh_Component_h
#define __smtk_mesh_Component_h
#include "smtk/CoreExports.h"
#include "smtk/PublicPointerDefs.h"
#include "smtk/TupleTraits.h"
#include "smtk/resource/Component.h"
#include "smtk/mesh/core/Collection.h"
#include "smtk/mesh/core/MeshSet.h"
namespace smtk
{
namespace mesh
{
class Component;
typedef std::vector<smtk::mesh::Component> ComponentList;
typedef std::set<smtk::mesh::Component> Components;
/// A lightweight object for representing meshset information as a resource
/// component. This is useful for constructing links between meshsets and other
/// resources/components and for representing meshsets within smtk's attribute
/// system.
class SMTKCORE_EXPORT Component : public smtk::resource::Component
{
protected:
Component(const smtk::mesh::CollectionPtr&, const smtk::common::UUID&);
Component(const smtk::mesh::MeshSet&);
public:
smtkTypeMacro(Component);
smtkSharedFromThisMacro(smtk::resource::Component);
/// Construct a mesh component corresponding to a meshset from the input
/// collection and id. No checking is performed that the collection has a
/// meshset with this id; if this is the case, the resolved mesh() will return
/// a default-constructed (and invalid) mesh.
static std::shared_ptr<Component> create(
const smtk::mesh::CollectionPtr&, const smtk::common::UUID&);
/// Construct a mesh component correpsonding to the input meshset.
static std::shared_ptr<Component> create(const smtk::mesh::MeshSet&);
/// Access the component's resource.
const smtk::resource::ResourcePtr resource() const override;
/// Access the component's id.
const smtk::common::UUID& id() const override { return m_id; }
/// Set the component's id. No checking is performed that the collection has a
/// meshset with this id; if this is the case, the resolved mesh() will return
/// a default-constructed (and invalid) mesh.
bool setId(const smtk::common::UUID& myID) override
{
m_id = myID;
return true;
}
/// Access the meshset represented by this component.
const smtk::mesh::MeshSet mesh() const;
smtk::mesh::MeshSet mesh();
private:
std::weak_ptr<smtk::mesh::Collection> m_collection;
smtk::common::UUID m_id;
};
} // namespace mesh
} // namespace smtk
#endif
......@@ -1026,10 +1026,22 @@ bool Interface::findById(
tag::QueryIdTag mtag(id, this->moabInterface());
::moab::ErrorCode rval;
rval = m_iface->get_entities_by_type_and_tag(
root, ::moab::MBENTITYSET, mtag.moabTagPtr(), mtag.moabTagValuePtr(), 1, result);
if (rval != ::moab::MB_SUCCESS || result.size() != 1)
{
// The above call does not check the root if it has the tag value. Let's do
// that before we give up.
smtk::common::UUID rootId =
detail::computeDenseOpaqueTagValue<smtk::common::UUID>(mtag, root, this->moabInterface());
if (rootId != smtk::common::UUID::null())
{
meshset = root;
return true;
}
return false;
}
meshset = *result.begin();
......
......@@ -10,13 +10,15 @@
#include "smtk/mesh/operators/DeleteMesh.h"
#include "smtk/mesh/core/Collection.h"
#include "smtk/mesh/core/Component.h"
#include "smtk/mesh/core/MeshSet.h"
#include "smtk/model/Session.h"
#include "smtk/model/Session.h"
#include "smtk/attribute/Attribute.h"
#include "smtk/attribute/MeshItem.h"
#include "smtk/attribute/ComponentItem.h"
#include "smtk/attribute/IntItem.h"
#include "smtk/mesh/DeleteMesh_xml.h"
......@@ -27,23 +29,28 @@ namespace mesh
smtk::mesh::DeleteMesh::Result DeleteMesh::operateInternal()
{
// ableToOperate should have verified that mesh(s) are set
smtk::attribute::MeshItem::Ptr meshItem = this->parameters()->findMesh("mesh");
Result result = this->createResult(smtk::operation::Operation::Outcome::SUCCEEDED);
smtk::mesh::MeshSets expunged;
bool success = true;
for (attribute::MeshItem::const_mesh_it mit = meshItem->begin(); mit != meshItem->end(); ++mit)
smtk::attribute::ReferenceItem::Ptr meshItem = this->parameters()->associations();
bool allRemoved = true;
for (std::size_t i = 0; i < meshItem->numberOfValues(); i++)
{
// all mesh items are guaranteed to have a valid associated collection by ableToOperate
smtk::mesh::CollectionPtr collec = mit->collection();
}
smtk::mesh::Component::Ptr meshComponent = meshItem->valueAs<smtk::mesh::Component>(i);
smtk::mesh::MeshSet meshset = meshComponent->mesh();
bool removed = meshset.collection()->removeMeshes(meshset);
if (removed)
{
result->findComponent("expunged")->appendValue(meshComponent);
}
Result result = this->createResult(success ? smtk::operation::Operation::Outcome::SUCCEEDED
: smtk::operation::Operation::Outcome::FAILED);
allRemoved &= removed;
}
if (success)
if (allRemoved == false)
{
result->findMesh("mesh_expunged")->appendValues(expunged);
result->findInt("outcome")->setValue(
0, static_cast<int>(smtk::operation::Operation::Outcome::FAILED));
}
return result;
}
......
......@@ -4,9 +4,9 @@
<Definitions>
<include href="smtk/operation/Operation.xml"/>
<AttDef Type="delete mesh" BaseType="operation" Label="Mesh - Delete">
<ItemDefinitions>
<MeshEntity Name="mesh" NumberOfRequiredValues="1" Extensible="true" />
</ItemDefinitions>
<AssociationsDef Name="mesh" NumberOfRequiredValues="1" Extensible="false">
<Accepts><Resource Name="smtk::mesh::Collection" Filter="meshset"/></Accepts>
</AssociationsDef>
<BriefDescription>
Remove a mesh from the model instance.
</BriefDescription>
......@@ -20,7 +20,6 @@
<include href="smtk/operation/Result.xml"/>
<AttDef Type="result(delete mesh)" BaseType="result">
<ItemDefinitions>
<MeshEntity Name="mesh_expunged" NumberOfRequiredValues="0" Extensible="true" AdvanceLevel="11"/>
</ItemDefinitions>
</AttDef>
</Definitions>
......
......@@ -17,11 +17,13 @@
#include "smtk/attribute/GroupItem.h"
#include "smtk/attribute/IntItem.h"
#include "smtk/attribute/MeshItem.h"
#include "smtk/attribute/ReferenceItem.h"
#include "smtk/attribute/StringItem.h"
#include "smtk/attribute/VoidItem.h"
#include "smtk/mesh/core/CellField.h"
#include "smtk/mesh/core/Collection.h"
#include "smtk/mesh/core/Component.h"
#include "smtk/mesh/core/MeshSet.h"
#include "smtk/mesh/core/PointField.h"
......@@ -122,13 +124,6 @@ bool ElevateMesh::ableToOperate()
{
return false;
}
smtk::attribute::MeshItem::Ptr meshItem = this->parameters()->findMesh("mesh");
if (!meshItem || meshItem->numberOfValues() == 0)
{
return false;
}
return true;
}
......@@ -138,7 +133,9 @@ ElevateMesh::Result ElevateMesh::operateInternal()
smtk::attribute::StringItem::Ptr inputDataItem = this->parameters()->findString("input data");
// Access the mesh to elevate
smtk::attribute::MeshItem::Ptr meshItem = this->parameters()->findMesh("mesh");
smtk::attribute::ReferenceItem::Ptr meshItem = this->parameters()->associations();
smtk::mesh::MeshSet meshset = meshItem->valueAs<smtk::mesh::Component>()->mesh();
smtk::mesh::Collection::Ptr collection = meshset.collection();
// Access the string describing the interpolation scheme
smtk::attribute::StringItem::Ptr interpolationSchemeItem =
......@@ -207,7 +204,7 @@ ElevateMesh::Result ElevateMesh::operateInternal()
{
// Compute the radial average function
interpolation = radialAverageFrom<smtk::model::AuxiliaryGeometry>(
auxGeo, radiusItem->value(), prefilter, meshItem->value().collection()->interface());
auxGeo, radiusItem->value(), prefilter, collection->interface());
}
else if (interpolationSchemeItem->value() == "inverse distance weighting")
{
......@@ -231,7 +228,7 @@ ElevateMesh::Result ElevateMesh::operateInternal()
{
// Compute the radial average function
interpolation = radialAverageFrom<std::string>(
fileName, radiusItem->value(), prefilter, meshItem->value().collection()->interface());
fileName, radiusItem->value(), prefilter, collection->interface());
}
else if (interpolationSchemeItem->value() == "inverse distance weighting")
{
......@@ -273,8 +270,7 @@ ElevateMesh::Result ElevateMesh::operateInternal()
if (interpolationSchemeItem->value() == "radial average")
{
interpolation = smtk::mesh::RadialAverage(
smtk::mesh::Collection::create(meshItem->value().collection()->interface()), pointcloud,
radiusItem->value());
smtk::mesh::Collection::create(collection->interface()), pointcloud, radiusItem->value());
}
else if (interpolationSchemeItem->value() == "inverse distance weighting")
{
......@@ -364,8 +360,6 @@ ElevateMesh::Result ElevateMesh::operateInternal()
// Access the attribute associated with the modified meshes
Result result = this->createResult(smtk::operation::Operation::Outcome::SUCCEEDED);
smtk::attribute::MeshItem::Ptr modifiedMeshes = result->findMesh("mesh_modified");
modifiedMeshes->setNumberOfValues(meshItem->numberOfValues());
// Access the attribute associated with the modified model
smtk::attribute::ComponentItem::Ptr modified = result->findComponent("modified");
......@@ -377,11 +371,12 @@ ElevateMesh::Result ElevateMesh::operateInternal()
// apply the interpolator to the meshes and populate the result attributes
for (std::size_t i = 0; i < meshItem->numberOfValues(); i++)
{
smtk::mesh::MeshSet mesh = meshItem->value(i);
auto meshComponent = meshItem->valueAs<smtk::mesh::Component>(i);
auto mesh = meshComponent->mesh();
smtk::mesh::utility::applyWarp(fn, mesh, true);
modifiedMeshes->appendValue(mesh);
modified->appendObjectValue(meshComponent);
smtk::model::EntityRefArray entities;
bool entitiesAreValid = mesh.modelEntities(entities);
......
......@@ -16,6 +16,11 @@
data set, and it computes new z-coordinates at each mesh node
as a radial average of the scalar values in the external data set.
</DetailedDescription>
<AssociationsDef Name="mesh" NumberOfRequiredValues="1" Extensible="false">
<Accepts><Resource Name="smtk::mesh::Collection" Filter="meshset"/></Accepts>
</AssociationsDef>
<ItemDefinitions>
<String Name="input data" Label="Input Data">
......@@ -110,10 +115,6 @@
</DiscreteInfo>
</String>
<MeshEntity Name="mesh" Label="Mesh" NumberOfRequiredValues="1" Extensible="true" >
<BriefDescription>The mesh to elevate.</BriefDescription>
</MeshEntity>
<String Name="interpolation scheme" Label="Interpolation Scheme">
<BriefDescription>The interpolation scheme to apply to the input data</BriefDescription>
......@@ -260,7 +261,6 @@
<include href="smtk/operation/Result.xml"/>
<AttDef Type="result(elevate mesh)" BaseType="result">
<ItemDefinitions>
<MeshEntity Name="mesh_modified" NumberOfRequiredValues="0" Extensible="true" AdvanceLevel="11"/>
<Component Name="tess_changed" NumberOfRequiredValues="0"
Extensible="true" AdvanceLevel="11">
<Accepts><Resource Name="smtk::model::Resource" Filter=""/></Accepts>
......
......@@ -20,6 +20,7 @@
#include "smtk/mesh/ExportMesh_xml.h"
#include "smtk/mesh/core/Collection.h"
#include "smtk/mesh/core/Component.h"
#include "smtk/mesh/core/MeshSet.h"
#include "smtk/model/Resource.h"
......@@ -58,28 +59,27 @@ bool ExportMesh::ableToOperate()
{
return false;
}
smtk::attribute::MeshItem::Ptr meshItem = this->parameters()->findMesh("mesh");
return meshItem && meshItem->numberOfValues() > 0;
return true;
}
ExportMesh::Result ExportMesh::operateInternal()
{
std::string outputfile = this->parameters()->findFile("filename")->value();
// ableToOperate should have verified that mesh(s) are set
smtk::attribute::MeshItem::Ptr meshItem = this->parameters()->findMesh("mesh");
smtk::attribute::ReferenceItem::Ptr meshItem = this->parameters()->associations();
// for multiple meshes, we suffix the file name root with ascending integers
std::string root = outputfile.substr(0, outputfile.find_last_of("."));
std::string ext = outputfile.substr(outputfile.find_last_of("."));
int index = 0;
smtk::mesh::MeshSets written;
std::vector<std::string> generatedFiles;
for (attribute::MeshItem::const_mesh_it mit = meshItem->begin(); mit != meshItem->end(); ++mit)
for (std::size_t i = 0; i < meshItem->numberOfValues(); i++)
{
smtk::mesh::CollectionPtr collection = mit->collection();
smtk::mesh::Component::Ptr meshComponent = meshItem->valueAs<smtk::mesh::Component>(i);
smtk::mesh::CollectionPtr collection =
std::dynamic_pointer_cast<smtk::mesh::Collection>(meshComponent->resource());
bool fileExportSuccess = false;
if (collection)
......@@ -98,7 +98,6 @@ ExportMesh::Result ExportMesh::operateInternal()
{
++index;
generatedFiles.push_back(outputfile);
written.insert(*mit);
}
}
......
......@@ -15,8 +15,10 @@
mesh is not guaranteed to contain all of the information from
the original mesh.
</DetailedDescription>
<AssociationsDef Name="mesh" NumberOfRequiredValues="1" Extensible="false">
<Accepts><Resource Name="smtk::mesh::Collection" Filter="meshset"/></Accepts>
</AssociationsDef>
<ItemDefinitions>
<MeshEntity Name="mesh" NumberOfRequiredValues="1" Extensible="true" />
<File Name="filename" NumberOfRequiredValues="1" ShouldExist="false"
FileFilters="AdH 2D Mesh file (*.2dm);;AdH 3D Mesh file (*.3dm)">
</File>
......
......@@ -21,6 +21,7 @@
#include "smtk/mesh/GenerateHotStartData_xml.h"
#include "smtk/mesh/core/CellField.h"
#include "smtk/mesh/core/Component.h"
#include "smtk/mesh/core/MeshSet.h"
#include "smtk/mesh/core/PointField.h"
......@@ -188,20 +189,13 @@ bool GenerateHotStartData::ableToOperate()
{
return false;
}
smtk::attribute::MeshItem::Ptr meshItem = this->parameters()->findMesh("mesh");
if (!meshItem || meshItem->numberOfValues() == 0)
{
return false;
}
return true;
}
GenerateHotStartData::Result GenerateHotStartData::operateInternal()
{
// Access the mesh to elevate
smtk::attribute::MeshItem::Ptr meshItem = this->parameters()->findMesh("mesh");
smtk::attribute::ReferenceItem::Ptr meshItem = this->parameters()->associations();
// Access the data set type
smtk::attribute::StringItem::Ptr typeItem = this->parameters()->findString("dstype");
......@@ -249,7 +243,7 @@ GenerateHotStartData::Result GenerateHotStartData::operateInternal()
bool meshIsContainedByPointCloud = true;
for (std::size_t i = 0; i < meshItem->numberOfValues(); i++)
{
smtk::mesh::MeshSet mesh = meshItem->value(i);
smtk::mesh::MeshSet mesh = meshItem->valueAs<smtk::mesh::Component>(i)->mesh();
std::array<double, 6> mesh_bounds = bounds(mesh);
for (std::size_t j = 0; j < 3; j++)
......@@ -271,10 +265,8 @@ GenerateHotStartData::Result GenerateHotStartData::operateInternal()
// Construct an instance of our interpolator and set its parameters
smtk::mesh::InverseDistanceWeighting interpolator(pointcloud, powerItem->value());
// Access the attribute associated with the modified meshes
// Construct a result object to hold our output
Result result = this->createResult(smtk::operation::Operation::Outcome::SUCCEEDED);
smtk::attribute::MeshItem::Ptr modifiedMeshes = result->findMesh("mesh_modified");
modifiedMeshes->setNumberOfValues(meshItem->numberOfValues());
// Access the attribute associated with the modified model
smtk::attribute::ComponentItem::Ptr modified = result->findComponent("modified");
......@@ -310,11 +302,11 @@ GenerateHotStartData::Result GenerateHotStartData::operateInternal()
// apply the interpolator to the meshes and populate the result attributes
for (std::size_t i = 0; i < meshItem->numberOfValues(); i++)
{
smtk::mesh::MeshSet mesh = meshItem->value(i);
smtk::mesh::Component::Ptr meshComponent = meshItem->valueAs<smtk::mesh::Component>(i);
smtk::mesh::MeshSet mesh = meshComponent->mesh();
smtk::mesh::utility::applyScalarPointField(fn, name, mesh);
modifiedMeshes->appendValue(mesh);
modified->appendValue(meshComponent);
smtk::model::EntityRefArray entities;
bool entitiesAreValid = mesh.modelEntities(entities);
......
......@@ -18,11 +18,12 @@
onto either the points or the cells of the mesh. The input
points can be inserted manually or read from a CSV file.
</DetailedDescription>
<ItemDefinitions>
<MeshEntity Name="mesh" Label="Mesh" NumberOfRequiredValues="1" Extensible="true" >
<BriefDescription>The mesh to elevate.</BriefDescription>
</MeshEntity>
<AssociationsDef Name="mesh" NumberOfRequiredValues="1" Extensible="false">
<Accepts><Resource Name="smtk::mesh::Collection" Filter="meshset"/></Accepts>
</AssociationsDef>
<ItemDefinitions>
<String Name="dstype" Label="Data Type" NumberOfRequiredValues="1">
<BriefDescription>The name of the data set.</BriefDescription>
<DiscreteInfo DefaultIndex="0">
......
......@@ -16,13 +16,13 @@
#include "smtk/attribute/FileItem.h"
#include "smtk/attribute/GroupItem.h"
#include "smtk/attribute/IntItem.h"
#include "smtk/attribute/MeshItem.h"
#include "smtk/attribute/StringItem.h"
#include "smtk/attribute/VoidItem.h"
#include "smtk/mesh/InterpolateOntoMesh_xml.h"
#include "smtk/mesh/core/CellField.h"
#include "smtk/mesh/core/Collection.h"
#include "smtk/mesh/core/Component.h"
#include "smtk/mesh/core/MeshSet.h"
#include "smtk/mesh/core/PointField.h"
......@@ -130,12 +130,6 @@ bool InterpolateOntoMesh::ableToOperate()
return false;
}
smtk::attribute::MeshItem::Ptr meshItem = this->parameters()->findMesh("mesh");
if (!meshItem || meshItem->numberOfValues() == 0)
{
return false;
}
return true;
}
......@@ -145,7 +139,9 @@ InterpolateOntoMesh::Result InterpolateOntoMesh::operateInternal()
smtk::attribute::StringItem::Ptr inputDataItem = this->parameters()->findString("input data");
// Access the mesh to elevate
smtk::attribute::MeshItem::Ptr meshItem = this->parameters()->findMesh("mesh");
smtk::attribute::ReferenceItem::Ptr meshItem = this->parameters()->associations();
smtk::mesh::MeshSet meshset = meshItem->valueAs<smtk::mesh::Component>()->mesh();
smtk::mesh::Collection::Ptr collection = meshset.collection();
// Access the string describing the interpolation scheme
smtk::attribute::StringItem::Ptr interpolationSchemeItem =
......@@ -220,7 +216,7 @@ InterpolateOntoMesh::Result InterpolateOntoMesh::operateInternal()
{
// Compute the radial average function
interpolation = radialAverageFrom<smtk::model::AuxiliaryGeometry>(
auxGeo, radiusItem->value(), prefilter, meshItem->value().collection()->interface());
auxGeo, radiusItem->value(), prefilter, collection->interface());
}
else if (interpolationSchemeItem->value() == "inverse distance weighting")
{
......@@ -244,7 +240,7 @@ InterpolateOntoMesh::Result InterpolateOntoMesh::operateInternal()
{
// Compute the radial average function
interpolation = radialAverageFrom<std::string>(
fileName, radiusItem->value(), prefilter, meshItem->value().collection()->interface());
fileName, radiusItem->value(), prefilter, collection->interface());
}
else if (interpolationSchemeItem->value() == "inverse distance weighting")
{
......@@ -286,8 +282,7 @@ InterpolateOntoMesh::Result InterpolateOntoMesh::operateInternal()
if (interpolationSchemeItem->value() == "radial average")
{
interpolation = smtk::mesh::RadialAverage(
smtk::mesh::Collection::create(meshItem->value().collection()->interface()), pointcloud,
radiusItem->value());
smtk::mesh::Collection::create(collection->interface()), pointcloud, radiusItem->value());
}
else if (interpolationSchemeItem->value() == "inverse distance weighting")
{
......@@ -364,8 +359,6 @@ InterpolateOntoMesh::Result InterpolateOntoMesh::operateInternal()
// Access the attribute associated with the modified meshes
Result result = this->createResult(smtk::operation::Operation::Outcome::SUCCEEDED);
smtk::attribute::MeshItem::Ptr modifiedMeshes = result->findMesh("mesh_modified");
modifiedMeshes->setNumberOfValues(meshItem->numberOfValues());
// Access the attribute associated with the modified model
smtk::attribute::ComponentItem::Ptr modified = result->findComponent("modified");
......@@ -388,7 +381,8 @@ InterpolateOntoMesh::Result InterpolateOntoMesh::operateInternal()
// apply the interpolator to the meshes and populate the result attributes
for (std::size_t i = 0; i < meshItem->numberOfValues(); i++)
{
smtk::mesh::MeshSet mesh = meshItem->value(i);
smtk::mesh::Component::Ptr meshComponent = meshItem->valueAs<smtk::mesh::Component>(i);
smtk::mesh::MeshSet mesh = meshComponent->mesh();
if (modeItem->value(0) == CELL_FIELD)
{
......@@ -399,7 +393,7 @@ InterpolateOntoMesh::Result InterpolateOntoMesh::operateInternal()
smtk::mesh::utility::applyScalarPointField(fn, nameItem->value(), mesh);
}
modifiedMeshes->appendValue(mesh);
modified->appendValue(meshComponent);
smtk::model::EntityRefArray entities;
bool entitiesAreValid = mesh.modelEntities(entities);
......
......@@ -17,6 +17,11 @@
Shepard's method for interpolation. The input points can be
inserted manually or read from a CSV file.