MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / Node

Class Node

src/examples/csg_primitive.cpp:38–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36boost::none_t const null = boost::none;
37
38class Node {
39private:
40 typedef enum {
41 OP_ADD, OP_SUBTRACT, OP_INTERSECT, OP_TERMINAL
42 } Op;
43 typedef enum {
44 PRIM_BOX, PRIM_CONE, PRIM_CYLINDER, PRIM_PYRAMID, PRIM_SPHERE
45 } Prim;
46
47 double x,y,z, zx,zy,zz, xx,xy,xz, a,b,c;
48 const Node *left, *right;
49
50 Op op;
51 Prim prim;
52
53 Node& operate(Op op, const Node& p) {
54 left = new Node(*this);
55 right = new Node(p);
56 this->op = op;
57 return *this;
58 }
59
60 Node(Prim p, double la, double lb=0., double lc=0.)
61 : prim(p), op(OP_TERMINAL),
62 x(0.), y(0.), z(0.),
63 zx(0.), zy(0.), zz(1.),
64 xx(1.), xy(0.), xz(0.),
65 a(la), b(lb), c(lc) {}
66public:
67 static Node Sphere(double r) {
68 return Node(PRIM_SPHERE, r);
69 }
70 static Node Box(double dx, double dy, double dz) {
71 return Node(PRIM_BOX, dx, dy, dz);
72 }
73 static Node Pyramid(double dx, double dy, double dz) {
74 return Node(PRIM_PYRAMID, dx, dy, dz);
75 }
76 static Node Cylinder(double r, double h) {
77 return Node(PRIM_CYLINDER, r, h);
78 }
79 static Node Cone(double r, double h) {
80 return Node(PRIM_CONE, r, h);
81 }
82
83 Node& move(
84 double px = 0., double py = 0., double pz = 0.,
85 double zx = 0., double zy = 0., double zz = 1.,
86 double xx = 1., double xy = 0., double xz = 0.)
87 {
88 this->x = px; this->y = py; this->z = pz;
89 this->zx = zx; this->zy = zy; this->zz = zz;
90 this->xx = xx; this->xy = xy; this->xz = xz;
91 return *this;
92 }
93
94 Node& add(const Node& p) {
95 return operate(OP_ADD, p);

Callers 6

SphereMethod · 0.70
BoxMethod · 0.70
PyramidMethod · 0.70
CylinderMethod · 0.70
ConeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected