Volume Cartographer 2.27.0
meshing.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cstddef>
6
7#include <smgl/Node.hpp>
8
13#include "vc/meshing/ACVD.hpp"
18
19namespace volcart
20{
21
28class MeshingNode : public smgl::Node
29{
30private:
36 ITKMesh::Pointer mesh_;
37
38public:
40 smgl::InputPort<Mesher::PointSet> points;
42 smgl::OutputPort<ITKMesh::Pointer> mesh;
43
46
47private:
49 auto serialize_(bool useCache, const filesystem::path& cacheDir)
50 -> smgl::Metadata override;
51
54 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
55};
56
63class ScaleMeshNode : public smgl::Node
64{
65private:
67 ITKMesh::Pointer input_;
69 double scaleFactor_{1};
71 ITKMesh::Pointer output_;
72
73public:
75 smgl::InputPort<ITKMesh::Pointer> input;
77 smgl::InputPort<double> scaleFactor;
79 smgl::OutputPort<ITKMesh::Pointer> output;
80
83
84private:
86 auto serialize_(bool useCache, const filesystem::path& cacheDir)
87 -> smgl::Metadata override;
88
91 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
92};
93
106class CalculateNumVertsNode : public smgl::Node
107{
108private:
110 ITKMesh::Pointer mesh_{nullptr};
112 double voxelSize_{100};
114 double density_{50};
116 std::size_t numVerts_{0};
117
118public:
120 smgl::InputPort<ITKMesh::Pointer> mesh;
126 smgl::InputPort<double> voxelSize;
128 smgl::InputPort<double> density;
130 smgl::OutputPort<std::size_t> numVerts;
131
134
135private:
137 auto serialize_(bool /*useCache*/, const filesystem::path& /*cacheDir*/)
138 -> smgl::Metadata override;
139
142 const smgl::Metadata& meta,
143 const filesystem::path& /*cacheDir*/) override;
144};
145
151class LaplacianSmoothMeshNode : public smgl::Node
152{
153private:
159 ITKMesh::Pointer mesh_;
160
161public:
163 smgl::InputPort<ITKMesh::Pointer> input;
165 smgl::OutputPort<ITKMesh::Pointer> output;
166
169
170private:
172 auto serialize_(bool useCache, const filesystem::path& cacheDir)
173 -> smgl::Metadata override;
174
177 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
178};
179
186class ResampleMeshNode : public smgl::Node
187{
188private:
194 ITKMesh::Pointer mesh_;
195
196public:
199
201 smgl::InputPort<ITKMesh::Pointer> input;
203 smgl::InputPort<Mode> mode;
205 smgl::InputPort<std::size_t> numVertices;
207 smgl::InputPort<double> gradation;
209 smgl::InputPort<std::size_t> subsampleThreshold;
211 smgl::InputPort<std::size_t> quadricsOptimizationLevel;
213 smgl::OutputPort<ITKMesh::Pointer> output;
214
217
218private:
220 auto serialize_(bool useCache, const filesystem::path& cacheDir)
221 -> smgl::Metadata override;
222
225 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
226};
227
234class UVMapToMeshNode : public smgl::Node
235{
236private:
240 bool scaleDims_{false};
242 ITKMesh::Pointer output_{nullptr};
243
244public:
246 smgl::InputPort<ITKMesh::Pointer> inputMesh;
248 smgl::InputPort<UVMap::Pointer> uvMap;
250 smgl::InputPort<bool> scaleToUVDimensions;
252 smgl::OutputPort<ITKMesh::Pointer> outputMesh;
253
256
257private:
259 auto serialize_(bool useCache, const filesystem::path& cacheDir)
260 -> smgl::Metadata override;
261
264 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
265};
266
273class OrientNormalsNode : public smgl::Node
274{
275private:
281 ITKMesh::Pointer output_{nullptr};
282
283public:
286
288 smgl::InputPort<ITKMesh::Pointer> input;
290 smgl::InputPort<ReferenceMode> referenceMode;
292 smgl::InputPort<cv::Vec3d> referencePoint;
294 smgl::OutputPort<ITKMesh::Pointer> output;
295
298
299private:
301 auto serialize_(bool useCache, const filesystem::path& cacheDir)
302 -> smgl::Metadata override;
303
306 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
307};
308
309} // namespace volcart
Utility functions for calculations on meshes.
Calculate the number of vertices required to produce a particular resampling density factor.
Definition: meshing.hpp:107
smgl::InputPort< ITKMesh::Pointer > mesh
Input mesh.
Definition: meshing.hpp:120
auto serialize_(bool, const filesystem::path &) -> smgl::Metadata override
smgl::InputPort< double > density
Target density factor.
Definition: meshing.hpp:128
smgl::OutputPort< std::size_t > numVerts
Resulting number of vertices.
Definition: meshing.hpp:130
smgl::InputPort< double > voxelSize
Voxel size (um) in the mesh's coordinate space.
Definition: meshing.hpp:126
void deserialize_(const smgl::Metadata &meta, const filesystem::path &) override
Apply Laplacian smoothing to a mesh.
Definition: meshing.hpp:152
smgl::OutputPort< ITKMesh::Pointer > output
Output mesh.
Definition: meshing.hpp:165
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< ITKMesh::Pointer > input
Input mesh.
Definition: meshing.hpp:163
Generate an ordered mesh from an OrderedPointSet.
Definition: meshing.hpp:29
ITKMesh::Pointer mesh_
Definition: meshing.hpp:36
smgl::InputPort< Mesher::PointSet > points
Input point set.
Definition: meshing.hpp:40
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::OutputPort< ITKMesh::Pointer > mesh
Output mesh.
Definition: meshing.hpp:42
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
Orient vertex normals towards a reference point.
Definition: meshing.hpp:274
smgl::InputPort< ITKMesh::Pointer > input
Input mesh.
Definition: meshing.hpp:288
smgl::InputPort< ReferenceMode > referenceMode
Set reference point mode.
Definition: meshing.hpp:290
ITKMesh::Pointer output_
Definition: meshing.hpp:281
smgl::InputPort< cv::Vec3d > referencePoint
Set manual reference point.
Definition: meshing.hpp:292
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::OutputPort< ITKMesh::Pointer > output
Output mesh.
Definition: meshing.hpp:294
OrientNormals orientNormals_
Definition: meshing.hpp:279
Mesh resampling using Approximated Centroidal Voronoi Diagrams.
Definition: meshing.hpp:187
smgl::InputPort< std::size_t > subsampleThreshold
The subsampling threshold.
Definition: meshing.hpp:209
ITKMesh::Pointer mesh_
Definition: meshing.hpp:194
smgl::InputPort< ITKMesh::Pointer > input
Input mesh.
Definition: meshing.hpp:201
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< std::size_t > numVertices
The number of voronoi clusters to use for remeshing.
Definition: meshing.hpp:205
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< double > gradation
The gradation (curvature) constraint.
Definition: meshing.hpp:207
smgl::InputPort< std::size_t > quadricsOptimizationLevel
Quadrics optimization level.
Definition: meshing.hpp:211
smgl::InputPort< Mode > mode
Isotropy mode.
Definition: meshing.hpp:203
smgl::OutputPort< ITKMesh::Pointer > output
Resampled mesh.
Definition: meshing.hpp:213
Scale an ITKMesh by a linear scale factor.
Definition: meshing.hpp:64
smgl::InputPort< ITKMesh::Pointer > input
Input mesh.
Definition: meshing.hpp:75
smgl::InputPort< double > scaleFactor
Linear scale factor.
Definition: meshing.hpp:77
ITKMesh::Pointer output_
Definition: meshing.hpp:71
smgl::OutputPort< ITKMesh::Pointer > output
Scaled output mesh.
Definition: meshing.hpp:79
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
ITKMesh::Pointer input_
Definition: meshing.hpp:67
Convert a UVMap to a mesh.
Definition: meshing.hpp:235
smgl::OutputPort< ITKMesh::Pointer > outputMesh
UV mesh.
Definition: meshing.hpp:252
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< ITKMesh::Pointer > inputMesh
Input mesh.
Definition: meshing.hpp:246
ITKMesh::Pointer output_
Definition: meshing.hpp:242
smgl::InputPort< UVMap::Pointer > uvMap
Input UVMap.
Definition: meshing.hpp:248
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< bool > scaleToUVDimensions
If true, scale the output mesh to the width/height stored in the UVMap. Default: false.
Definition: meshing.hpp:250
meshing::UVMapToITKMesh mesher_
Definition: meshing.hpp:238
Mesh resampling using Approximated Centroidal Voronoi Diagrams.
Definition: ACVD.hpp:32
Mode
Isotropy modes.
Definition: ACVD.hpp:35
Apply Laplacian smoothing to a mesh.
Generate an ordered mesh from an OrderedPointSet.
Orient vertex normals towards a reference point.
ReferenceMode
Reference point mode.
Convert a UVMap to a mesh.
Volume Cartographer library