Volume Cartographer 2.27.0
ShapePrimitive.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cstddef>
6
7#include <opencv2/core.hpp>
8#include <vtkCellArray.h>
9#include <vtkCellData.h>
10#include <vtkDoubleArray.h>
11#include <vtkPointData.h>
12#include <vtkPoints.h>
13#include <vtkPolyData.h>
14#include <vtkPolyDataReader.h>
15#include <vtkSmartPointer.h>
16
21
22namespace volcart::shapes
23{
42{
43public:
46 ITKMesh::Pointer itkMesh();
47
49 vtkSmartPointer<vtkPolyData> vtkMesh();
58
68 std::vector<SimpleMesh::Vertex> getPoints() const { return points_; }
69
71 std::vector<SimpleMesh::Cell> getCells() const { return cells_; }
82
90
92 bool isOrdered() const { return ordered_; }
93
95 std::size_t orderedWidth() const { return orderedWidth_; }
96
98 std::size_t orderedHeight() const { return orderedHeight_; }
101protected:
104
106 std::vector<SimpleMesh::Vertex> points_;
108 std::vector<SimpleMesh::Cell> cells_;
109
111 void addVertex_(double x, double y, double z);
112
117 void addCell_(int v1, int v2, int v3);
118
125 void updateNormal_(int vertID, double nx, double ny, double nz);
126
129 bool ordered_{false};
131 std::size_t orderedWidth_{0};
133 std::size_t orderedHeight_{0};
135};
136} // namespace volcart::shapes
Simple mesh structure.
Base class for shape generators.
ITKMesh::Pointer itkMesh()
Return the shape as an ITKMesh.
OrderedPointSet< cv::Vec3d > orderedPoints()
Return the vertices as an OrderedPointSet.
std::vector< SimpleMesh::Vertex > points_
std::size_t orderedHeight() const
Return the height of the ordered vertex set.
PointSet< cv::Vec3d > unorderedPoints()
Return the vertices as a PointSet.
std::size_t orderedWidth() const
Return the width of the ordered vertex set.
vtkSmartPointer< vtkPolyData > vtkMesh()
Return the shape as a vtkPolyData.
void addVertex_(double x, double y, double z)
Add a new vertex to the shape.
std::vector< SimpleMesh::Vertex > getPoints() const
Return the vertices as a list of SimpleMesh::Vertex.
void updateNormal_(int vertID, double nx, double ny, double nz)
Update the normal of a vertex with a new normal component.
void addCell_(int v1, int v2, int v3)
Add a new triangular face to the mesh from vertex IDs.
bool isOrdered() const
Return if the shape generator created ordered vertices.
OrderedPointSet< cv::Vec6d > orderedPointNormal()
Return the vertices and vertex normals as an OrderedPointSet.
std::vector< SimpleMesh::Cell > cells_
std::vector< SimpleMesh::Cell > getCells() const
Return the faces as a list of volcart::Cell.
PointSet< cv::Vec6d > unorderedPointNormal()
Return the vertices and vertex normals as a PointSet.
Shape and mesh primitives.