Volume Cartographer 2.28.0
Plane.hpp
Go to the documentation of this file.
1#pragma once
2
5#include "ShapePrimitive.hpp"
6
7namespace volcart::shapes
8{
23class Plane : public ShapePrimitive
24{
25public:
26 Plane(int width = 5, int height = 5)
27 {
28 // generate the points along the y-axis
29 double y = 0;
30 for (double x = 0; x < width; x += 1) {
31 for (double z = 0; z < height; z += 1) {
32 addVertex_(x, y, z);
33 }
34 }
35
36 // generate the cells
37 for (int i = 1; i < height; ++i) {
38 for (int j = 1; j < width; ++j) {
39 const int v1 = i * width + j;
40 const int v2 = v1 - 1;
41 const int v3 = v2 - width;
42 const int v4 = v1 - width;
43 addCell_(v1, v2, v3);
44 addCell_(v1, v3, v4);
45 }
46 }
47
48 // Set this as an ordered mesh
49 ordered_ = true;
50 orderedWidth_ = width;
51 orderedHeight_ = height;
52
53 } // Constructor
54
55}; // Plane
56} // namespace volcart::shapes
Planar surface shape.
Definition: Plane.hpp:24
Base class for shape generators.
void addVertex_(double x, double y, double z)
Add a new vertex to the shape.
void addCell_(int v1, int v2, int v3)
Add a new triangular face to the mesh from vertex IDs.
Shape and mesh primitives.