Volume Cartographer 2.27.0
VolumePkg.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cstddef>
6#include <iostream>
7#include <map>
8
16
17namespace volcart
18{
19
37{
38public:
51 VolumePkg(filesystem::path path, int version);
52
58 explicit VolumePkg(const filesystem::path& path);
59
61 using Pointer = std::shared_ptr<VolumePkg>;
62
68 static auto New(const filesystem::path& path, int version) -> Pointer;
69
75 static auto New(const filesystem::path& path) -> Pointer;
84 [[nodiscard]] auto name() const -> std::string;
85
95 [[nodiscard]] auto version() const -> int;
96
113 [[nodiscard]] auto materialThickness() const -> double;
114
116 [[nodiscard]] auto metadata() const -> Metadata;
117
126 template <typename T>
127 void setMetadata(const std::string& key, T value)
128 {
129 config_.set<T>(key, value);
130 }
131
135 void saveMetadata() const;
136
141 void saveMetadata(const filesystem::path& filePath) const;
147 [[nodiscard]] auto hasVolumes() const -> bool;
148
150 [[nodiscard]] auto hasVolume(const Volume::Identifier& id) const -> bool;
151
153 [[nodiscard]] auto numberOfVolumes() const -> std::size_t;
154
156 [[nodiscard]] auto volumeIDs() const -> std::vector<Volume::Identifier>;
157
159 [[nodiscard]] auto volumeNames() const -> std::vector<std::string>;
160
167 auto newVolume(std::string name = "") -> Volume::Pointer;
168
170 [[nodiscard]] auto volume() const -> Volume::Pointer;
171
174
176 [[nodiscard]] auto volume(const Volume::Identifier& id) const
177 -> Volume::Pointer;
178
180 auto volume(const Volume::Identifier& id) -> Volume::Pointer;
186 [[nodiscard]] auto hasSegmentations() const -> bool;
187
189 [[nodiscard]] auto numberOfSegmentations() const -> std::size_t;
190
192 [[nodiscard]] auto segmentationIDs() const
193 -> std::vector<Segmentation::Identifier>;
194
196 [[nodiscard]] auto segmentationNames() const -> std::vector<std::string>;
197
205 auto newSegmentation(std::string name = "") -> Segmentation::Pointer;
206
222 auto removeSegmentation(const Segmentation::Identifier& id) -> bool;
223
225 [[nodiscard]] auto segmentation(const Segmentation::Identifier& id) const
227
230 auto segmentation(const Segmentation::Identifier& id)
237 [[nodiscard]] auto hasRenders() const -> bool;
238
240 [[nodiscard]] auto numberOfRenders() const -> std::size_t;
241
243 [[nodiscard]] auto renderIDs() const -> std::vector<Render::Identifier>;
244
246 [[nodiscard]] auto renderNames() const -> std::vector<std::string>;
247
254 auto newRender(std::string name = "") -> Render::Pointer;
255
257 [[nodiscard]] auto render(const Render::Identifier& id) const
258 -> Render::Pointer;
259
261 auto render(const Render::Identifier& id) -> Render::Pointer;
267 [[nodiscard]] auto hasTransforms() const -> bool;
268
279 [[nodiscard]] auto hasTransform(const Transform3D::Identifier& id) const
280 -> bool;
281
284 -> Transform3D::Identifier;
285
288 const Transform3D::Identifier& id,
290
304 [[nodiscard]] auto transform(Transform3D::Identifier id) const
306
323 [[nodiscard]] auto transform(
324 const Volume::Identifier& src, const Volume::Identifier& tgt) const
325 -> std::vector<
326 std::pair<Transform3D::Identifier, Transform3D::Pointer>>;
327
329 [[nodiscard]] auto transformIDs() const
330 -> std::vector<Transform3D::Identifier>;
334 static void Upgrade(
335 const filesystem::path& path,
337 bool force = false);
338
339private:
343 filesystem::path rootDir_;
345 std::map<Volume::Identifier, Volume::Pointer> volumes_;
349 std::map<Render::Identifier, Render::Pointer> renders_;
352
363 static auto InitConfig(const Dictionary& dict, int version) -> Metadata;
364};
365} // namespace volcart
VolumePkg metadata templates.
Generic interface for storing metadata as key/value pairs.
Definition: Metadata.hpp:27
void set(const std::string &key, T value)
Set a metadata key and value.
Definition: Metadata.hpp:99
Render data.
Definition: Render.hpp:27
Segmentation data.
Base class for 3D transforms.
Definition: Transforms.hpp:50
The interface to the VolumePkg (.volpkg) file format.
Definition: VolumePkg.hpp:37
auto removeSegmentation(const Segmentation::Identifier &id) -> bool
Removes an existing segmentation.
void setTransform(const Transform3D::Identifier &id, const Transform3D::Pointer &transform)
Replace an existing transform.
std::map< Transform3D::Identifier, Transform3D::Pointer > transforms_
Definition: VolumePkg.hpp:351
auto renderNames() const -> std::vector< std::string >
Get the list of Render names.
auto hasVolumes() const -> bool
Return whether there are Volumes.
auto transformIDs() const -> std::vector< Transform3D::Identifier >
Get the list of transform IDs.
void saveMetadata(const filesystem::path &filePath) const
Saves the metadata to a user-specified location.
filesystem::path rootDir_
Definition: VolumePkg.hpp:343
VolumePkg(const filesystem::path &path)
Construct a VolumePkg from a .volpkg file stored at fileLocation.
auto newRender(std::string name="") -> Render::Pointer
Creates a new Render.
std::map< Render::Identifier, Render::Pointer > renders_
Definition: VolumePkg.hpp:349
static auto New(const filesystem::path &path, int version) -> Pointer
Construct an empty VolumePkg of a specific version number.
auto renderIDs() const -> std::vector< Render::Identifier >
Get the list of Render IDs.
auto segmentationNames() const -> std::vector< std::string >
Get the list of Segmentation names.
auto volumeNames() const -> std::vector< std::string >
Get the list of volumes names.
auto hasRenders() const -> bool
Return whether there are Renders.
auto numberOfSegmentations() const -> std::size_t
Get the number of Segmentations.
static void Upgrade(const filesystem::path &path, int version=VOLPKG_VERSION_LATEST, bool force=false)
auto hasTransforms() const -> bool
Return whether there are transforms in the VolumePkg.
auto materialThickness() const -> double
Returns the approx. thickness of a material layer in microns (um).
void setMetadata(const std::string &key, T value)
Sets the value of key in the VolumePkg metadata.
Definition: VolumePkg.hpp:127
void saveMetadata() const
Saves the metadata to the VolumePkg (.volpkg) file.
auto hasTransform(const Transform3D::Identifier &id) const -> bool
Return whether a transform with the given identifier is in the VolumePkg.
VolumePkg(filesystem::path path, int version)
Construct an empty VolumePkg of a specific version number.
auto hasSegmentations() const -> bool
Return whether there are Segmentations.
auto version() const -> int
Returns the VolumePkg version.
auto newSegmentation(std::string name="") -> Segmentation::Pointer
Creates a new segmentation.
std::map< Segmentation::Identifier, Segmentation::Pointer > segmentations_
Definition: VolumePkg.hpp:347
auto hasVolume(const Volume::Identifier &id) const -> bool
Whether a volume with the given identifier is in the VolumePkg.
auto render(const Render::Identifier &id) const -> Render::Pointer
Get a Render by uuid.
auto volume() const -> Volume::Pointer
Get the first Volume.
auto segmentation(const Segmentation::Identifier &id) const -> Segmentation::Pointer
Get a Segmentation by uuid.
static auto New(const filesystem::path &path) -> Pointer
auto transform(Transform3D::Identifier id) const -> Transform3D::Pointer
Get a transform by ID.
auto segmentationIDs() const -> std::vector< Segmentation::Identifier >
Get the list of Segmentation IDs.
std::shared_ptr< VolumePkg > Pointer
Definition: VolumePkg.hpp:61
auto addTransform(const Transform3D::Pointer &transform) -> Transform3D::Identifier
Add a transform to the VolPkg.
std::map< Volume::Identifier, Volume::Pointer > volumes_
Definition: VolumePkg.hpp:345
auto newVolume(std::string name="") -> Volume::Pointer
Add a new Volume to the VolumePkg.
auto name() const -> std::string
Returns the identifying name of the VolumePkg.
static auto InitConfig(const Dictionary &dict, int version) -> Metadata
Populates an empty VolumePkg::config from a volcart::Dictionary template.
auto numberOfRenders() const -> std::size_t
Get the number of Renders.
auto metadata() const -> Metadata
Return the VolumePkg Metadata.
auto numberOfVolumes() const -> std::size_t
Get the number of Volumes.
auto volumeIDs() const -> std::vector< Volume::Identifier >
Get the list of volume IDs.
Volumetric image data.
Definition: Volume.hpp:36
Volume Cartographer library
static constexpr int VOLPKG_VERSION_LATEST
Volume Package version generated by this release
std::unordered_map< DictionaryEntryKey, DictionaryEntryType > Dictionary