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

Merge topic 'mesh-name'

964d0ee1 Make mesh resource name API consistent...
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: !1458
parents ea6003a2 964d0ee1
Pipeline #128598 running with stage
## Mesh system changes
### Smaller API changes
+ Now that `smtk::resource::Resource` holds a separate name
(i.e., independent of location), remove the API that mesh
resources provided to avoid duplication.
......@@ -48,7 +48,6 @@ private:
Resource::Resource()
: smtk::resource::DerivedFrom<Resource, smtk::resource::Resource>(
smtk::common::UUIDGenerator::instance().random())
, m_name()
, m_readLocation()
, m_writeLocation()
, m_floatData(new MeshFloatData)
......@@ -61,7 +60,6 @@ Resource::Resource()
Resource::Resource(const smtk::common::UUID& resourceID)
: smtk::resource::DerivedFrom<Resource, smtk::resource::Resource>(resourceID)
, m_name()
, m_readLocation()
, m_writeLocation()
, m_floatData(new MeshFloatData)
......@@ -75,7 +73,6 @@ Resource::Resource(const smtk::common::UUID& resourceID)
Resource::Resource(smtk::mesh::InterfacePtr interface)
: smtk::resource::DerivedFrom<Resource, smtk::resource::Resource>(
smtk::common::UUIDGenerator::instance().random())
, m_name()
, m_readLocation()
, m_writeLocation()
, m_floatData(new MeshFloatData)
......@@ -88,7 +85,6 @@ Resource::Resource(smtk::mesh::InterfacePtr interface)
Resource::Resource(const smtk::common::UUID& resourceID, smtk::mesh::InterfacePtr interface)
: smtk::resource::DerivedFrom<Resource, smtk::resource::Resource>(resourceID)
, m_name()
, m_readLocation()
, m_writeLocation()
, m_floatData(new MeshFloatData)
......@@ -171,16 +167,6 @@ bool Resource::isModified() const
return this->interface()->isModified();
}
std::string Resource::name() const
{
return m_name;
}
void Resource::name(const std::string& n)
{
m_name = n;
}
const smtk::common::FileLocation& Resource::readLocation() const
{
return m_readLocation;
......
......@@ -116,10 +116,6 @@ public:
//reset to false.
bool isModified() const;
//get the name of a mesh resource
std::string name() const override;
void name(const std::string& n);
//get the file that this resource was created from
//will return an empty FileLocation if this resource wasn't read from file
const smtk::common::FileLocation& readLocation() const;
......@@ -357,7 +353,6 @@ private:
friend class smtk::io::ReadMesh;
std::string m_name;
smtk::common::FileLocation m_readLocation;
smtk::common::FileLocation m_writeLocation;
......
......@@ -30,7 +30,7 @@ void verify_valid_constructor()
//verify the name
test((resource->name() == std::string()));
resource->name("example");
resource->setName("example");
test((resource->name() == std::string("example")));
//verify the interface name
......@@ -53,7 +53,7 @@ void verify_resource_info_moab()
//verify the name
test((resource->name() == std::string()));
resource->name("example");
resource->setName("example");
test((resource->name() == std::string("example")));
//verify the interface name
......@@ -82,7 +82,7 @@ void verify_resource_info_json()
//verify the name
test((resource->name() == std::string()));
resource->name("example");
resource->setName("example");
test((resource->name() == std::string("example")));
//verify the interface name
......
......@@ -350,7 +350,7 @@ ImportOperation::Result ImportOperation::operateInternal()
{
if (c->name().empty())
{
c->name(vtksys::SystemTools::GetFilenameWithoutExtension(filename));
c->setName(vtksys::SystemTools::GetFilenameWithoutExtension(filename));
}
result->findComponent("mesh_created")->setValue(modelEntity.component());
......
......@@ -136,7 +136,8 @@ Import::Result Import::operateInternal()
std::string name = smtk::common::Paths::stem(filePath);
if (!name.empty())
{
meshResource->name(name);
meshResource->setName(name);
resource->setName(name);
}
auto format = smtk::io::meshFileFormat(filePath);
......
......@@ -33,6 +33,8 @@
#include "smtk/model/Resource.h"
#include "smtk/model/SessionRef.h"
#include "smtk/common/Paths.h"
#include "smtk/extension/vtk/reader/vtkCMBGeometryReader.h"
#ifdef SMTK_ENABLE_REMUS_SUPPORT
#include "smtk/extension/vtk/reader/vtkCMBMapReader.h"
......@@ -496,6 +498,12 @@ Import::Result Import::operateInternal()
smtk::session::polygon::Resource::Ptr resource =
std::dynamic_pointer_cast<smtk::session::polygon::Resource>(resourceItem->value());
std::string potentialName = smtk::common::Paths::stem(filename);
if (!potentialName.empty() && resource && resource->name().empty())
{
resource->setName(potentialName);
}
// Retrieve the resulting model
smtk::attribute::ComponentItemPtr componentItem =
std::dynamic_pointer_cast<smtk::attribute::ComponentItem>(modResult->findComponent("model"));
......
......@@ -26,6 +26,8 @@
#include "smtk/model/Group.h"
#include "smtk/model/Model.h"
#include "smtk/common/Paths.h"
#include "vtkContourFilter.h"
#include "vtkDataArray.h"
#include "vtkDataSetAttributes.h"
......@@ -124,6 +126,12 @@ Import::Result Import::operateInternal()
resource->setSession(session);
}
std::string potentialName = smtk::common::Paths::stem(filename);
if (resource->name().empty() && !potentialName.empty())
{
resource->setName(potentialName);
}
// Downcase the filetype (especially for when we did not infer it):
std::transform(filetype.begin(), filetype.end(), filetype.begin(), ::tolower);
......
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