Commit df5afb93 authored by David Thompson's avatar David Thompson

Do *not* use strings to hold UUIDs.

parent 3c978c0b
......@@ -57,21 +57,32 @@
namespace
{
void ColorBlockAsEntity(vtkCompositePolyDataMapper2* mapper, vtkDataObject* block,
const std::string& uuid, const smtk::resource::ResourcePtr& res)
void SetAttributeBlockColorToEntity(vtkCompositeDataDisplayAttributes* atts, vtkDataObject* block,
const smtk::common::UUID& uuid, const smtk::resource::ResourcePtr& res)
{
using namespace smtk::model;
auto modelResource = std::static_pointer_cast<Resource>(res);
EntityRef entity(modelResource, smtk::common::UUID(uuid));
EntityRef entity(modelResource, uuid);
FloatList color = entity.color();
color = color[3] < 0 ? FloatList({ 1., 1., 1., 1. }) : color;
// FloatList is a typedef for std::vector<double>, so it is safe to
// pass the raw pointer to its data.
auto atts = mapper->GetCompositeDataDisplayAttributes();
atts->SetBlockColor(block, color.data());
}
void ColorBlockAsEntity(vtkGlyph3DMapper* mapper, vtkDataObject* block,
const smtk::common::UUID& uuid, const smtk::resource::ResourcePtr& res)
{
SetAttributeBlockColorToEntity(mapper->GetBlockAttributes(), block, uuid, res);
}
void ColorBlockAsEntity(vtkCompositePolyDataMapper2* mapper, vtkDataObject* block,
const smtk::common::UUID& uuid, const smtk::resource::ResourcePtr& res)
{
SetAttributeBlockColorToEntity(mapper->GetCompositeDataDisplayAttributes(), block, uuid, res);
}
void AddRenderables(
vtkMultiBlockDataSet* data, vtkSMTKModelRepresentation::RenderableDataMap& renderables)
{
......@@ -788,23 +799,16 @@ void vtkSMTKModelRepresentation::UpdateSelection(
}
vtkDataObject* vtkSMTKModelRepresentation::FindNode(
vtkMultiBlockDataSet* data, const std::string& uuid)
vtkMultiBlockDataSet* data, const smtk::common::UUID& uuid)
{
const int numBlocks = data->GetNumberOfBlocks();
for (int index = 0; index < numBlocks; index++)
{
auto currentBlock = data->GetBlock(index);
if (data->HasMetaData(index))
auto currentId = vtkModelMultiBlockSource::GetDataObjectUUID(data->GetMetaData(index));
if (currentId == uuid)
{
auto currentId = data->GetMetaData(index)->Get(vtkModelMultiBlockSource::ENTITYID());
if (currentId)
{
const std::string currentIdStr = currentId;
if (currentIdStr.compare(uuid) == 0)
{
return currentBlock;
}
}
return currentBlock;
}
auto childBlock = vtkMultiBlockDataSet::SafeDownCast(currentBlock);
......@@ -1246,13 +1250,16 @@ void vtkSMTKModelRepresentation::ColorByEntity(vtkMultiBlockDataSet* data)
while (!it->IsDoneWithTraversal())
{
auto dataObj = it->GetCurrentDataObject();
if (data->HasMetaData(it))
auto uuid = vtkModelMultiBlockSource::GetDataObjectUUID(data->GetMetaData(it));
if (uuid)
{
auto uuid = data->GetMetaData(it)->Get(vtkModelMultiBlockSource::ENTITYID());
if (uuid)
auto ent = std::dynamic_pointer_cast<smtk::model::Entity>(this->Resource->find(uuid));
if (ent && ent->isInstance())
{
ColorBlockAsEntity(this->GlyphMapper, dataObj, uuid, this->Resource);
}
else
{
// FIXME? Check whether UUID corresponds to an instance or not.
// Instances should use the GlyphMapper rather than the EntityMapper.
ColorBlockAsEntity(this->EntityMapper, dataObj, uuid, this->Resource);
}
}
......
......@@ -319,7 +319,7 @@ protected:
vtkMultiBlockDataSet* modelData, vtkMultiBlockDataSet* instanceData);
void UpdateSelection(
vtkMultiBlockDataSet* data, vtkCompositeDataDisplayAttributes* blockAttr, vtkActor* actor);
vtkDataObject* FindNode(vtkMultiBlockDataSet* data, const std::string& uuid);
vtkDataObject* FindNode(vtkMultiBlockDataSet* data, const smtk::common::UUID& uuid);
/**
* Clear the current selection stored in the mapper's
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment