Commit 4aad98ed authored by David Thompson's avatar David Thompson
Browse files

WIP: Arc-less, but builds+tests with smtk/master (20220120).

parent bf5a5d11
// Copyright © Kitware Inc under the [BSD-3-clause license](https://opensource.org/licenses/BSD-3-Clause).
#ifndef aeva_Options_h
#define aeva_Options_h
// Compile-time options chosen for this build of SMTK.
#define aeva_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
#endif // aeva_Options_h
# Declare unit tests Usage:
#
# smtk_unit_tests(
# unit_tests(
# LABEL <prefix for all unit tests>
# SOURCES <test_source_list>
# SOURCES_REQUIRE_DATA <test_sources_that_require_DATA_DIR>
......
option(AEVA_ENABLE_TESTING "Enable tests." ON)
if (AEVA_ENABLE_TESTING)
include(TestingMacros)
endif()
option(AEVA_ENABLE_PYTHON "Build python bindings for aeva." OFF)
# AEVA_BUILD_DOCUMENTATION is an enumerated option:
# never == No documentation, and no documentation tools are required.
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
#ifndef smtk_markup_AnalyticShape_h
#define smtk_markup_AnalyticShape_h
#include "smtk/markup/Component.h"
#include "smtk/markup/SpatialData.h"
namespace smtk
{
......@@ -10,15 +10,15 @@ namespace markup
{
/// Simple shapes that have analytic representations, generally as implicit, trivariate functions whose zero level-set defines the shape.
class SMTKMARKUP_EXPORT AnalyticShape : public smtk::markup::Component
class SMTKMARKUP_EXPORT AnalyticShape : public smtk::markup::SpatialData
{
public:
smtkTypeMacro(smtk::markup::AnalyticShape);
smtkSuperclassMacro(smtk::markup::Component);
smtkSuperclassMacro(smtk::markup::SpatialData);
template<typename... Args>
AnalyticShape(Args&&... args)
: smtk::markup::Component(std::forward<Args>(args)...)
: smtk::markup::SpatialData(std::forward<Args>(args)...)
{
}
......
// Copyright © Kitware Inc under the [BSD-3-clause license](https://opensource.org/licenses/BSD-3-Clause).
#ifndef smtk_markup_ArcEditor_h
#define smtk_markup_ArcEditor_h
#include "smtk/markup/Exports.h"
#include "smtk/graph/arcs/Arcs.h"
namespace smtk
{
namespace markup
{
/**\brief A class to iterate over and edit arcs in a graph resource.
*
* Of note, this class supports insertion and removal during iteration.
*
* Examples:
* ```c++
* // Ranged for-loops are supported:
* std::shared_ptr<Group> group;
* for (const auto& member : group->members())
* {
* std::cout << " Member "<< member.name() << "\n";
* }
*
* // The editor also presents a stateful API for iteration
* auto members = group->members();
* for (; !members.done(); ++members)
* {
* if (members->name() == "foo")
* {
* // It is possible to erase the current arc during iteration.
* members.erase();
* }
* }
* ```
*/
template<typename SourceNodeType, typename NodeType>
class SMTKMARKUP_EXPORT ArcEditor
{
public:
NodeType& operator () ();
NodeType& operator * ();
NodeType& operator -> ();
bool operator ++ ();
bool done() const;
/// Return true when comparing whether two arc editors reference the same node.
///
/// When \a other == this, then we only return true when the iterator is at
/// the end of iteration.
bool operator == (const ArcEditor<SourceNodeType, NodeType>& other)
{
if (&other == this)
{
// only return true when at end.
return this->done();
}
return (*this)() == other();
}
const ArcEditor<SourceNodeType, NodeType>& begin() { return *this; }
const ArcEditor<SourceNodeType, NodeType>& end() { return *this; }
protected:
typename smtk::graph::Arcs<SourceNodeType, NodeType>::API& m_api;
};
} // namespace markup
} // namespace smtk
#endif // smtk_markup_ArcEditor_h
// Copyright © Kitware Inc under the [BSD-3-clause license](https://kitware.com/licenses/bsd.md).
#include "smtk/markup/AssignedIds.h"
namespace smtk
{
namespace markup
{
AssignedIds::~AssignedIds() = default;
bool AssignedIds::setSpace(const std::weak_ptr<smtk::markup::IdSpace>& space)
{
auto mlocked = m_space.lock();
auto vlocked = space.lock();
if (mlocked == vlocked)
{
return false;
}
m_space = vlocked;
return true;
}
const std::weak_ptr<smtk::markup::IdSpace>& AssignedIds::space() const
{
return m_space;
}
std::weak_ptr<smtk::markup::IdSpace>& AssignedIds::space()
{
return m_space;
}
bool AssignedIds::setNature(const AssignedIds::Nature& nature)
{
if (m_nature == nature)
{
return false;
}
m_nature = nature;
return true;
}
const AssignedIds::Nature& AssignedIds::nature() const
{
return m_nature;
}
AssignedIds::Nature& AssignedIds::nature()
{
return m_nature;
}
} // namespace markup
} // namespace smtk
// Copyright © Kitware Inc under the [BSD-3-clause license](https://opensource.org/licenses/BSD-3-Clause).
#ifndef smtk_markup_AssignedIds_h
#define smtk_markup_AssignedIds_h
#include "smtk/markup/Component.h"
#include "smtk/common/Visit.h"
#include "smtk/markup/IdSpace.h"
namespace smtk
{
namespace markup
{
/// An API for querying the IDs allotted to a component in an IdSpace.
class SMTKMARKUP_EXPORT AssignedIds : public smtk::markup::Component
{
public:
smtkTypeMacro(smtk::markup::AssignedIds);
smtkSuperclassMacro(smtk::markup::Component);
enum Nature
{ Primary,Referential,NonExclusive };
using IdType = smtk::markup::IdSpace::IdType;
using IdIterator = struct { smtk::markup::IdSpace* idSpace; IdType begin; IdType end; Nature nature; };
using IdRange = struct { smtk::markup::IdSpace* idSpace; IdType begin; IdType end; };
using Iterable = std::function<bool(IdIterator&)>;
using ContainsFunctor = std::function<std::size_t(const IdRange&)>;
using Visitor = std::function<smtk::common::Visit(smtk::markup::IdSpace&, IdType)>;
template<typename... Args>
AssignedIds(Args&&... args)
: smtk::markup::Component(std::forward<Args>(args)...)
{
}
~AssignedIds() override;
std::array<AssignedIds::IdType, 2> range() const;
Iterable iterable() const;
ContainsFunctor contains() const;
smtk::common::Visit visit(Visitor visitor) const;
bool setSpace(const std::weak_ptr<smtk::markup::IdSpace>& space);
const std::weak_ptr<smtk::markup::IdSpace>& space() const;
std::weak_ptr<smtk::markup::IdSpace>& space();
bool setNature(const AssignedIds::Nature& nature);
const AssignedIds::Nature& nature() const;
AssignedIds::Nature& nature();
protected:
std::weak_ptr<smtk::markup::IdSpace> m_space;
AssignedIds::Nature m_nature;
};
} // namespace markup
} // namespace smtk
#endif // smtk_markup_AssignedIds_h
\ No newline at end of file
set(sources)
set(headers)
set(headers
queries/SelectionFootprint.h
)
list(APPEND classes
Resource
Component
Domain
BoundaryOperator
......@@ -31,6 +35,7 @@ list(APPEND classes
Field
LabelMap
Segmentation
SpatialData
Label
OntologyIdentifier
Comment
......@@ -76,3 +81,6 @@ target_link_libraries(smtkMarkup
VTK::hdf5
)
if (AEVA_ENABLE_TESTING)
add_subdirectory(testing/cxx)
endif()
......@@ -8,6 +8,46 @@ namespace markup
Comment::~Comment() = default;
bool Comment::setData(const smtk::string::Token& data)
{
if (m_data == data)
{
return false;
}
m_data = data;
return true;
}
const smtk::string::Token& Comment::data() const
{
return m_data;
}
smtk::string::Token& Comment::data()
{
return m_data;
}
bool Comment::setMimetype(const smtk::string::Token& mimetype)
{
if (m_mimetype == mimetype)
{
return false;
}
m_mimetype = mimetype;
return true;
}
const smtk::string::Token& Comment::mimetype() const
{
return m_mimetype;
}
smtk::string::Token& Comment::mimetype()
{
return m_mimetype;
}
} // namespace markup
} // namespace smtk
......@@ -3,6 +3,7 @@
#define smtk_markup_Comment_h
#include "smtk/markup/Label.h"
#include "smtk/string/Token.h"
namespace smtk
{
......@@ -23,10 +24,22 @@ public:
~Comment() override;
/// Text of the comment.
bool setData(const smtk::string::Token& data);
const smtk::string::Token& data() const;
smtk::string::Token& data();
/// Mime type of the comment. The default is "text/plain".
bool setMimetype(const smtk::string::Token& mimetype);
const smtk::string::Token& mimetype() const;
smtk::string::Token& mimetype();
protected:
smtk::string::Token m_data;
smtk::string::Token m_mimetype;
};
} // namespace markup
} // namespace smtk
#endif // smtk_markup_Comment_h
\ No newline at end of file
#endif // smtk_markup_Comment_h
......@@ -6,11 +6,16 @@
#include "smtk/graph/Component.h"
#include "smtk/markup/ArcEditor.h"
namespace smtk
{
namespace markup
{
class Group;
class Label;
class SMTKMARKUP_EXPORT Component : public smtk::graph::Component
{
public:
......@@ -25,10 +30,14 @@ public:
~Component() override;
ArcEditor<SelfType, smtk::markup::Group> groups() const;
ArcEditor<SelfType, smtk::markup::Label> labels() const;
protected:
};
} // namespace markup
} // namespace smtk
#endif // smtk_markup_Component_h
\ No newline at end of file
#endif // smtk_markup_Component_h
......@@ -2,22 +2,22 @@
#ifndef smtk_markup_DiscreteGeometry_h
#define smtk_markup_DiscreteGeometry_h
#include "smtk/markup/Component.h"
#include "smtk/markup/SpatialData.h"
namespace smtk
{
namespace markup
{
class SMTKMARKUP_EXPORT DiscreteGeometry : public smtk::markup::Component
class SMTKMARKUP_EXPORT DiscreteGeometry : public smtk::markup::SpatialData
{
public:
smtkTypeMacro(smtk::markup::DiscreteGeometry);
smtkSuperclassMacro(smtk::markup::Component);
smtkSuperclassMacro(smtk::markup::SpatialData);
template<typename... Args>
DiscreteGeometry(Args&&... args)
: smtk::markup::Component(std::forward<Args>(args)...)
: smtk::markup::SpatialData(std::forward<Args>(args)...)
{
}
......
// Copyright © Kitware Inc under the [BSD-3-clause license](https://kitware.com/licenses/bsd.md).
#include "smtk/markup/Field.h"
#include "smtk/markup/IdAllotment.h"
#include "smtk/markup/AssignedIds.h"
#include "smtk/markup/Index.h"
namespace smtk
......@@ -13,10 +13,10 @@ Field::~Field() = default;
std::string Field::name() const
{
return m_name;
return m_name.data();
}
bool Field::setName(const std::string& name)
bool Field::setName(const smtk::string::Token& name)
{
if (m_name == name)
{
......@@ -26,7 +26,7 @@ bool Field::setName(const std::string& name)
return true;
}
bool Field::setType(const std::string& type)
bool Field::setType(const smtk::string::Token& type)
{
if (m_type == type)
{
......@@ -36,12 +36,12 @@ bool Field::setType(const std::string& type)
return true;
}
const std::string& Field::type() const
const smtk::string::Token& Field::type() const
{
return m_type;
}
std::string& Field::type()
smtk::string::Token& Field::type()
{
return m_type;
}
......@@ -66,26 +66,26 @@ std::vector<int>& Field::order()
return m_order;
}
bool Field::setIdSpace(const std::weak_ptr<smtk::markup::IdAllotment>& idSpace)
bool Field::setIds(const std::weak_ptr<smtk::markup::AssignedIds>& ids)
{
auto mlocked = m_idSpace.lock();
auto vlocked = idSpace.lock();
auto mlocked = m_ids.lock();
auto vlocked = ids.lock();
if (mlocked == vlocked)
{
return false;
}
m_idSpace = vlocked;
m_ids = vlocked;
return true;
}
const std::weak_ptr<smtk::markup::IdAllotment>& Field::idSpace() const
const std::weak_ptr<smtk::markup::AssignedIds>& Field::ids() const
{
return m_idSpace;
return m_ids;
}
std::weak_ptr<smtk::markup::IdAllotment>& Field::idSpace()
std::weak_ptr<smtk::markup::AssignedIds>& Field::ids()
{
return m_idSpace;
return m_ids;
}
bool Field::setIndex(const std::weak_ptr<smtk::markup::Index>& index)
......
......@@ -5,8 +5,9 @@
#include "smtk/markup/Component.h"
#include <string>
#include "smtk/string/Token.h"
namespace smtk {namespace markup { class IdAllotment; } }
namespace smtk {namespace markup { class AssignedIds; } }
namespace smtk {namespace markup { class Index; } }
namespace smtk
......@@ -30,29 +31,29 @@ public:
std::string name() const;
bool setName(const std::string& name);
bool setName(const smtk::string::Token& name);
bool setType(const std::string& type);
const std::string& type() const;
std::string& type();
bool setType(const smtk::string::Token& type);
const smtk::string::Token& type() const;
smtk::string::Token& type();
bool setOrder(const std::vector<int>& order);
const std::vector<int>& order() const;
std::vector<int>& order();
bool setIdSpace(const std::weak_ptr<smtk::markup::IdAllotment>& idSpace);
const std::weak_ptr<smtk::markup::IdAllotment>& idSpace() const;
std::weak_ptr<smtk::markup::IdAllotment>& idSpace();
bool setIds(const std::weak_ptr<smtk::markup::AssignedIds>& ids);
const std::weak_ptr<smtk::markup::AssignedIds>& ids() const;
std::weak_ptr<smtk::markup::AssignedIds>& ids();
bool setIndex(const std::weak_ptr<smtk::markup::Index>& index);
const std::weak_ptr<smtk::markup::Index>& index() const;
std::weak_ptr<smtk::markup::Index>& index();
protected:
std::string m_name;
std::string m_type;
smtk::string::Token m_name;
smtk::string::Token m_type;
std::vector<int> m_order;
std::weak_ptr<smtk::markup::IdAllotment> m_idSpace;
std::weak_ptr<smtk::markup::AssignedIds> m_ids;
std::weak_ptr<smtk::markup::Index> m_index;
};
......
......@@ -2,7 +2,7 @@
#ifndef smtk_markup_Frame_h
#define smtk_markup_Frame_h
#include "smtk/markup/Component.h"
#include "smtk/markup/SpatialData.h"
namespace smtk
{
......@@ -10,15 +10,15 @@ namespace markup
{
/// A coordinate frame (i.e., a set of orthonormal basis vectors that span a space).
class SMTKMARKUP_EXPORT Frame : public smtk::markup::Component
class SMTKMARKUP_EXPORT Frame : public smtk::markup::SpatialData
{
public:
smtkTypeMacro(smtk::markup::Frame);
smtkSuperclassMacro(smtk::markup::Component);
smtkSuperclassMacro(smtk::markup::SpatialData);
template<typename... Args>
Frame(Args&&... args)
: smtk::markup::Component(std::forward<Args>(args)...)
: smtk::markup::SpatialData(std::forward<Args>(args)...)
{
}
......
......@@ -8,7 +8,7 @@ namespace markup
Grid::~Grid() = default;
bool Grid::setPoints(const std::weak_ptr<smtk::markup::IdAllotment>& points)
bool Grid::setPoints(const std::weak_ptr<smtk::markup::AssignedIds>& points)
{
auto mlocked = m_points.lock();
auto vlocked = points.lock();
......@@ -20,17 +20,17 @@ bool Grid::setPoints(const std::weak_ptr<smtk::markup::IdAllotment>& points)
return true;
}
const std::weak_ptr<smtk::markup::IdAllotment>& Grid::points() const
const std::weak_ptr<smtk::markup::AssignedIds>& Grid::points() const
{
return m_points;
}
std::weak_ptr<smtk::markup::IdAllotment>& Grid::points()
std::weak_ptr<smtk::markup::AssignedIds>& Grid::points()
{
return m_points;
}
bool Grid::setCells(const std::weak_ptr<smtk::markup::IdAllotment>& cells)
bool Grid::setCells(const std::weak_ptr<smtk::markup::AssignedIds>& cells)
{
auto mlocked = m_cells.lock();
auto vlocked = cells.lock();
......@@ -42,12 +42,12 @@ bool Grid::setCells(const std::weak_ptr<smtk::markup::IdAllotment>& cells)
return true;
}
const std::weak_ptr<smtk::markup::IdAllotment>& Grid::cells() const
const std::weak_ptr<smtk::markup::AssignedIds>& Grid::cells() const
{
return m_cells;
}
std::weak_ptr<smtk::markup::IdAllotment>& Grid::cells()
std::weak_ptr<smtk::markup::AssignedIds>& Grid::cells()
{
return m_cells;
}
......