Commit 9b2dd7b2 authored by David Thompson's avatar David Thompson
Browse files

WIP: Progress on class generation

parent 7984307e
add_subdirectory(session)
add_subdirectory(markup)
set(sources)
set(headers)
list(APPEND classes
Component
Domain
IdSpace
ParameterSpace
Index
IdAllotment
Collection
Ontology
Frame
AnalyticShape
Plane
Sphere
Cone
Box
ImplicitShape
DiscreteGeometry
Image
Grid
VolumeGrid
SurfaceGrid
References
Subset
ExplicitSubset
RangedSubset
CompositeSubset
SideSet
Field
LabelMap
Segmentation
Label
OntologyIdentifier
Comment
Feature
Landmark
# arcs/Children<NodeType, bool Hold>
# arcs/Parents<NodeType>
# arcs/DerivedData
)
# Turn "classes" into source and headers entries
foreach(class ${classes})
list(APPEND headers ${class}.h)
list(APPEND sources ${class}.cxx)
endforeach()
add_library(smtkMarkup SHARED ${sources} ${headers})
smtk_export_header(smtkMarkup Exports.h)
# add_dependencies(smtkMarkup ${aevaDependencies})
target_link_libraries(smtkMarkup
PUBLIC
smtkCore
smtkPVServerExt
vtkSMTKSourceExt
VTK::AEVAExt
VTK::MeshingNetGen
nglib
PRIVATE
VTK::CommonCore
VTK::CommonDataModel
VTK::IOImage
VTK::IOXML
VTK::IOGeometry
VTK::FiltersCore
VTK::FiltersExtraction
VTK::FiltersGeometry
VTK::FiltersParallelDIY2
VTK::FiltersPoints
smtkPQComponentsExt
${ITK_LIBRARIES}
${__dependencies}
Boost::filesystem
VTK::hdf5
)
// Copyright © Kitware Inc under the [BSD-3-clause license](https://kitware.com/licenses/bsd.md).
#include "smtk/markup/Component.h"
namespace smtk
{
namespace markup
{
Component::~Component() = default;
} // namespace markup
} // namespace smtk
// Copyright © Kitware Inc under the [BSD-3-clause license](https://kitware.com/licenses/bsd.md).
#ifndef smtk_markup_Component_h
#define smtk_markup_Component_h
#include "smtk/markup/Exports.h"
#include "smtk/graph/Component.h"
namespace smtk
{
namespace markup
{
class SMTKMARKUP_EXPORT Component : public smtk::graph::Component
{
public:
smtkTypeMacro(smtk::markup::Component);
smtkSuperclassMacro(smtk::graph::Component);
template<typename... Args>
Component(Args&&... args)
: smtk::graph::Component(std::forward<Args>(args)...)
{
}
~Component() override;
protected:
};
} // namespace markup
} // namespace smtk
#endif // smtk_markup_Component_h
\ No newline at end of file
// Copyright © Kitware Inc under the [BSD-3-clause license](https://kitware.com/licenses/bsd.md).
#include "smtk/markup/Domain.h"
namespace smtk
{
namespace markup
{
Domain::~Domain() = default;
} // namespace markup
} // namespace smtk
// Copyright © Kitware Inc under the [BSD-3-clause license](https://kitware.com/licenses/bsd.md).
#ifndef smtk_markup_Domain_h
#define smtk_markup_Domain_h
#include "smtk/markup/Component.h"
namespace smtk
{
namespace markup
{
/// The domain of a discrete or parameterized dataset.
class SMTKMARKUP_EXPORT Domain : public smtk::markup::Component
{
public:
smtkTypeMacro(smtk::markup::Domain);
smtkSuperclassMacro(smtk::markup::Component);
template<typename... Args>
Domain(Args&&... args)
: smtk::markup::Component(std::forward<Args>(args)...)
{
}
~Domain() override;
protected:
};
} // namespace markup
} // namespace smtk
#endif // smtk_markup_Domain_h
\ No newline at end of file
// Copyright © Kitware Inc under the [BSD-3-clause license](https://kitware.com/licenses/bsd.md).
#include "smtk/markup/IdSpace.h"
namespace smtk
{
namespace markup
{
IdSpace::~IdSpace() = default;
const std::array<IdSpace::IdType, 2>& IdSpace::range() const
{
return m_range;
}
std::array<IdSpace::IdType, 2>& IdSpace::range()
{
return m_range;
}
} // namespace markup
} // namespace smtk
// Copyright © Kitware Inc under the [BSD-3-clause license](https://kitware.com/licenses/bsd.md).
#ifndef smtk_markup_IdSpace_h
#define smtk_markup_IdSpace_h
#include "smtk/markup/Domain.h"
#include <array>
namespace smtk
{
namespace markup
{
/// A numbering used in a context.
/// Examples: node numbers, element numbers, side numbers, pedigree IDs, global IDs.
class SMTKMARKUP_EXPORT IdSpace : public smtk::markup::Domain
{
public:
smtkTypeMacro(smtk::markup::IdSpace);
smtkSuperclassMacro(smtk::markup::Domain);
using IdType = std::size_t;
template<typename... Args>
IdSpace(Args&&... args)
: smtk::markup::Domain(std::forward<Args>(args)...)
{
}
~IdSpace() override;
const std::array<IdType, 2>& range() const;
std::array<IdType, 2>& range();
protected:
std::array<IdType, 2> m_range;
};
} // namespace markup
} // namespace smtk
#endif // smtk_markup_IdSpace_h
\ No newline at end of file
......@@ -46,7 +46,7 @@ set(operators
# SmoothSurface
# UnreferencedPrimitives
# VolumeMesher
Write
#Write
)
set(icons
......
......@@ -19,7 +19,6 @@
#include "smtk/session/aeva/Read_xml.h"
#include "smtk/session/aeva/Resource.h"
#include "smtk/session/aeva/json/jsonResource.h"
#include "smtk/session/aeva/operators/Import.h"
#include "smtk/common/Paths.h"
......@@ -67,6 +66,12 @@ vtkSmartPointer<vtkDataSet> readVTKData(const std::string& filename)
return data;
}
Read::Result Read::readLegacy(nlohmann::json& jdata, const std::shared_ptr<Resource>& rsrc)
{
// FIXME TODO
return this->createResult(smtk::operation::Operation::Outcome::FAILED);
}
Read::Result Read::operateInternal()
{
std::string filename = this->parameters()->findFile("filename")->value();
......@@ -99,62 +104,34 @@ Read::Result Read::operateInternal()
return this->createResult(smtk::operation::Operation::Outcome::FAILED);
}
// Fetch the ordered list of model UUIDs corresponding to each json record.
json preservedUUIDs = jdata.at("preservedUUIDs");
// Create a new resource for the import
auto rsrc = smtk::session::aeva::Resource::create();
rsrc->setLocation(filename);
smtk::session::aeva::from_json(jdata, rsrc);
// The file names in the smtk file are relative to the smtk file itself. We
// need to append the smtk file's prefix to these values.
std::string fileDirectory = smtk::common::Paths::directory(filename) + "/";
for (auto& info : preservedUUIDs)
// Read legacy (model-based, not graph-based) aeva data
// Fetch the ordered list of model UUIDs corresponding to each json record.
json preservedUUIDs;
try
{
std::string aevaDatatype = info["type"];
std::string subFilename = info["filename"];
smtk::common::UUID uuid = info["uuid"];
if (subFilename.empty())
{
smtkErrorMacro(this->log(), "Empty filename for preserved data.");
continue;
}
// Turn relative paths into absolute ones (because they are
// relative to the .smtk file not the current working directory):
boost::filesystem::path p(subFilename);
if (!p.is_absolute())
{
subFilename.insert(0, fileDirectory);
}
preservedUUIDs = jdata.at("preservedUUIDs");
return this->readLegacy(jdata, rsrc);
}
catch (...)
{
// do nothing
}
if (aevaDatatype == "image")
{
vtkSmartPointer<vtkImageData> image = Import::readVTKImage(subFilename);
if (!image)
{
smtkErrorMacro(log(), "Cannot import file \"" << subFilename << "\".");
return this->createResult(smtk::operation::Operation::Outcome::FAILED);
}
session->addStorage(uuid, image);
}
if (aevaDatatype == "poly")
{
vtkSmartPointer<vtkDataSet> data = readVTKData(subFilename);
if (!data)
{
smtkErrorMacro(log(), "Cannot import file \"" << subFilename << "\".");
return this->createResult(smtk::operation::Operation::Outcome::FAILED);
}
session->addStorage(uuid, data);
}
try
{
smtk::session::aeva::from_json(jdata, rsrc);
}
catch (...)
{
smtkErrorMacro(log(), "Cannot process file \"" << filename << "\".");
return this->createResult(smtk::operation::Operation::Outcome::FAILED);
}
Result result = this->createResult(smtk::operation::Operation::Outcome::SUCCEEDED);
{
smtk::attribute::ResourceItem::Ptr created = result->findResource("resource");
created->setValue(rsrc);
......
......@@ -14,6 +14,8 @@
#include "smtk/session/aeva/Operation.h"
#include "smtk/session/aeva/Resource.h"
#include "nlohmann/json.hpp"
namespace smtk
{
namespace session
......@@ -32,6 +34,7 @@ public:
smtkSuperclassMacro(Operation);
protected:
Result readLegacy(nlohmann::json& jdata, const std::shared_ptr<Resource>& rsrc);
Result operateInternal() override;
virtual const char* xmlDescription() const override;
void markModifiedResources(Result&) override;
......
......@@ -13,7 +13,6 @@
#include "smtk/session/aeva/Resource.h"
#include "smtk/session/aeva/Write_xml.h"
#include "smtk/session/aeva/json/jsonResource.h"
#include "smtk/session/aeva/operators/Export.h"
#include "smtk/attribute/Attribute.h"
#include "smtk/attribute/FileItem.h"
......
......@@ -14,7 +14,7 @@ set (unit_tests
)
set (unit_tests_which_require_data
TestDelete.cxx
#TestDelete.cxx
# TestBooleans.cxx
# TestEditFreeformAttributes.cxx
# TestExpectedArrays.cxx
......
Supports Markdown
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