Volume Cartographer 2.27.0
Arch.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cmath>
6
7#include <opencv2/core.hpp>
8
9#include "ShapePrimitive.hpp"
10
11namespace volcart::shapes
12{
30class Arch : public ShapePrimitive
31{
32public:
33 Arch(int width = 10, int height = 10)
34 {
35
36 float rad = 5;
37
38 std::vector<cv::Vec3d> curve;
39 std::vector<cv::Vec3d> points;
40
41 // rad will always be the same
42 // theta (t) will be between 0 and pi
43 // z will be between 0 and width
44 cv::Vec3d c_point;
45 for (int w = 0; w < width; ++w) {
46 double t = w * M_PI / width;
47 c_point[0] = rad * cos(t);
48 c_point[1] = rad * sin(t);
49 c_point[2] = 0;
50 curve.push_back(c_point);
51 }
52
53 for (float z = 0; z < height; z += 1) {
54 for (auto p_id = curve.begin(); p_id != curve.end(); ++p_id) {
55 addVertex_(p_id->val[0], p_id->val[1], z);
56 }
57 }
58
59 // generate the cells
60 for (int i = 1; i < height; ++i) {
61 for (int j = 1; j < width; ++j) {
62 int v1, v2, v3, v4;
63 v1 = i * width + j;
64 v2 = v1 - 1;
65 v3 = v2 - width;
66 v4 = v1 - width;
67 addCell_(v1, v2, v3);
68 addCell_(v1, v3, v4);
69 }
70 }
71
72 // Set this as an ordered mesh
73 ordered_ = true;
74 orderedWidth_ = width;
75 orderedHeight_ = height;
76 }
77};
78} // namespace volcart::shapes
Half-circle arch shape.
Definition: Arch.hpp:31
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.