Commit e6fe60bc authored by David Thompson's avatar David Thompson Committed by Kitware Robot

Merge topic 'no-bad-strings'

f82ccd26 Fix warnings.
df5afb93 Do *not* use strings to hold UUIDs.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: T.J. Corona's avatarT.J. Corona <tj.corona@kitware.com>
Merge-request: !1476
parents 3c978c0b f82ccd26
Pipeline #129667 running with stage
......@@ -335,7 +335,7 @@ SMTKCORE_EXPORT void from_json(const json& j, smtk::attribute::ResourcePtr& res)
std::vector<smtk::attribute::DefinitionPtr> defs;
for (auto strIter = excObj.begin(); strIter != excObj.end(); strIter++)
{
auto def = res->findDefinition(strIter->get<std::string>());
def = res->findDefinition(strIter->get<std::string>());
if (def)
{
defs.push_back(def);
......@@ -385,7 +385,7 @@ SMTKCORE_EXPORT void from_json(const json& j, smtk::attribute::ResourcePtr& res)
auto preDefs = preObj.at("Prerequisite");
for (auto strIter = preDefs.begin(); strIter != preDefs.end(); strIter++)
{
auto def = res->findDefinition(strIter->get<std::string>());
def = res->findDefinition(strIter->get<std::string>());
if (def)
{
tdef->addPrerequisite(def);
......
......@@ -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
......
......@@ -189,7 +189,7 @@ int TestResourceManager(int, char** const)
auto indexA = ResourceA::type_index;
auto resourcesByIndex =
resourceManager->resources().get<smtk::resource::IndexTag>().equal_range(indexA);
int count = std::distance(resourcesByIndex.first, resourcesByIndex.second);
auto count = std::distance(resourcesByIndex.first, resourcesByIndex.second);
smtkTest(count == 2, "Fetched " << count << " instead of 2 resources by type-index failed.");
return 0;
......
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