MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
WEMNode.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#pragma once
14
15#include "WEMPrimitive.h"
16#include "WEMFace.h"
17#include "WEMEdge.h"
20
22
24
25class WEMTriangle;
26class WEMQuad;
27class WEMPolygon;
28
30
33{
34public:
38 WEMNode(const WEMNode& n);
39 WEMNode(WEMNode&& n) noexcept;
40 WEMNode& operator=(WEMNode&& n) noexcept;
42 ~WEMNode() override;
44 void reset();
46 void clone(WEMNode* n);
47
49 inline const Vector3& getPosition() const
50 {
51 return _position;
52 }
54 inline void getPosition(double& x, double& y, double& z) const
55 {
56 x = _position.x;
57 y = _position.y;
58 z = _position.z;
59 }
60
62 inline void setPosition(const Vector3& position)
63 {
64 _position = position;
65 invalidateBoundingBoxesOfAdjacentFaces();
66 }
68 inline void setPosition(double x, double y, double z)
69 {
70 _position.assign(x, y, z);
71 invalidateBoundingBoxesOfAdjacentFaces();
72 }
75 {
76 _position = position;
77 }
79 inline void setPositionNoInvalidationOfBoundingBoxes(double x, double y, double z)
80 {
81 _position.assign(x, y, z);
82 }
84 inline void translate(const Vector3& offset)
85 {
86 _position += offset;
87 invalidateBoundingBoxesOfAdjacentFaces();
88 }
93 inline void scale(const Vector3& scaleFactor)
94 {
95 _position *= scaleFactor;
96 invalidateBoundingBoxesOfAdjacentFaces();
97 }
99 inline unsigned int getFaceValence() const
100 {
101 return _faces.num();
102 }
104 inline unsigned int getEdgeValence() const
105 {
106 return _edges.num();
107 }
109 inline unsigned int getNumFaces() const
110 {
111 return getFaceValence();
112 }
114 inline unsigned int getNumEdges() const
115 {
116 return getEdgeValence();
117 }
119 inline Vector4 getColor() const
120 {
121 return _color;
122 }
124 inline void setColor(const Vector4& color)
125 {
126 _color = color;
127 }
129 inline void setColor(double r, double g, double b)
130 {
131 _color[0] = r;
132 _color[1] = g;
133 _color[2] = b;
134 }
136 inline void setColor(double a)
137 {
138 _color[3] = a;
139 }
141 inline Vector3 getNormal() const
142 {
143 return _normal;
144 }
146 inline void setNormal(const Vector3& normal)
147 {
148 _normal = normal;
149 }
151 inline void setNormal(double x, double y, double z)
152 {
153 _normal.assign(x, y, z);
154 }
158 inline WEMFace* getFaceAt(unsigned int index)
159 {
160 return _faces.at(index);
161 }
163 inline const WEMFace* getFaceAt(unsigned int index) const
164 {
165 return const_cast<WEMNode*>(this)->getFaceAt(index);
166 }
168 inline WEMTriangle* getTriangleAt(unsigned int index)
169 {
170 return (_faces.at(index)) ? reinterpret_cast<WEMTriangle*>(_faces.at(index)) : nullptr;
171 }
173 inline const WEMTriangle* getTriangleAt(unsigned int index) const
174 {
175 return const_cast<WEMNode*>(this)->getTriangleAt(index);
176 }
178 inline WEMQuad* getQuadAt(unsigned int index)
179 {
180 return (_faces.at(index)) ? reinterpret_cast<WEMQuad*>(_faces.at(index)) : nullptr;
181 }
183 inline const WEMQuad* getQuadAt(unsigned int index) const
184 {
185 return const_cast<WEMNode*>(this)->getQuadAt(index);
186 }
188 inline WEMPolygon* getPolygonAt(unsigned int index)
189 {
190 return (_faces.at(index)) ? reinterpret_cast<WEMPolygon*>(_faces.at(index)) : nullptr;
191 }
193 inline const WEMPolygon* getPolygonAt(unsigned int index) const
194 {
195 return const_cast<WEMNode*>(this)->getPolygonAt(index);
196 }
198 inline void addFace(WEMFace* face)
199 {
200 _faces.append(face);
201 }
203 inline void resizeFaces(unsigned int numFaces)
204 {
205 _faces.resize(numFaces);
206 }
208 inline void setFace(unsigned int index, WEMFace* face)
209 {
210 _faces.set(index, face);
211 }
215 inline WEMEdge* getEdgeAt(unsigned int index)
216 {
217 return _edges.at(index);
218 }
220 inline const WEMEdge* getEdgeAt(unsigned int index) const
221 {
222 return const_cast<WEMNode*>(this)->getEdgeAt(index);
223 }
225 inline void addEdge(WEMEdge* edge)
226 {
227 _edges.append(edge);
228 }
230 void remove(WEMEdge* edge);
234 inline const WEMEdge* getEdgeWith(WEMNode* node) const
235 {
236 return const_cast<WEMNode*>(this)->getEdgeWith(node);
237 }
239 inline bool isBoundary() const
240 {
241 return (_edges.num() && (_edges.num() != _faces.num()));
242 }
248 inline void removeEdges()
249 {
250 _edges.clear();
251 }
253 inline void removeFaces()
254 {
255 _faces.clear();
256 }
262
263private:
264 void invalidateBoundingBoxesOfAdjacentFaces();
265
266 void resetNode();
267
269 Vector3 _position;
271 Vector4 _color;
273 Vector3 _normal;
278};
279
281
283
285
#define MLWEM_EXPORT
Definition MLWEMSystem.h:18
Defines the mesh component: edge.
Definition WEMEdge.h:30
Defines the mesh component: face.
Definition WEMFace.h:30
Defines the mesh component: node.
Definition WEMNode.h:33
void removeFaces()
Removes all faces attached to this node.
Definition WEMNode.h:253
double getLargestDihedralAngle() const
Returns the largest angle between the node normal and any incident face's normal.
WEMTriangle * getTriangleAt(unsigned int index)
Returns the face at the given index and casts it to WEMTriangle.
Definition WEMNode.h:168
void replace(WEMEdge *orig, WEMEdge *replacement)
Replaces an edge orig in the internal edge's vector by another edge replace.
void clone(WEMNode *n)
Clones given node.
void setPosition(const Vector3 &position)
Sets the position in world coordinates.
Definition WEMNode.h:62
unsigned int getFaceValence() const
Returns the face valence of node. The valence denotes the number of attached faces.
Definition WEMNode.h:99
const WEMPolygon * getPolygonAt(unsigned int index) const
Returns the face at the given index and casts it to WEMPolygon.
Definition WEMNode.h:193
const WEMEdge * getEdgeWith(WEMNode *node) const
Returns the edge shared with the given node.
Definition WEMNode.h:234
unsigned int getEdgeValence() const
Returns the edge valence of node. The valence denotes the number of attached edges.
Definition WEMNode.h:104
void setNormal(const Vector3 &normal)
Sets the normal of the node.
Definition WEMNode.h:146
void setColor(const Vector4 &color)
Sets the color of the node.
Definition WEMNode.h:124
const WEMFace * getFaceAt(unsigned int index) const
Returns the face at the given index.
Definition WEMNode.h:163
~WEMNode() override
Standard destructor.
void translate(const Vector3 &offset)
Translates the position by the given vector.
Definition WEMNode.h:84
void getPosition(double &x, double &y, double &z) const
Returns the world position.
Definition WEMNode.h:54
Vector4 getColor() const
Returns the color of the node.
Definition WEMNode.h:119
unsigned int getNumFaces() const
Returns the number of faces attached to this node.
Definition WEMNode.h:109
void applyMatrix(const Matrix4 &transformMatrix)
Multiplies the node's position with the given transformation matrix.
WEMEdge * getEdgeAt(unsigned int index)
Returns the edge at the given index.
Definition WEMNode.h:215
void addEdge(WEMEdge *edge)
Adds the edge.
Definition WEMNode.h:225
void setPositionNoInvalidationOfBoundingBoxes(const Vector3 &position)
Sets the position in world coordinates without invalidating the bounding boxes of adjacent faces.
Definition WEMNode.h:74
WEMFace * getFaceAt(unsigned int index)
Returns the face at the given index.
Definition WEMNode.h:158
void resizeFaces(unsigned int numFaces)
Resizes the internal face vector to the given number of faces.
Definition WEMNode.h:203
const WEMEdge * getEdgeAt(unsigned int index) const
Returns the edge at the given index.
Definition WEMNode.h:220
void setPosition(double x, double y, double z)
Sets the position in world coordinates.
Definition WEMNode.h:68
const Vector3 & getPosition() const
Returns the world position.
Definition WEMNode.h:49
WEMEdge * getEdgeWith(WEMNode *node)
Returns the edge shared with the given node.
const WEMTriangle * getTriangleAt(unsigned int index) const
Returns the face at the given index and casts it to WEMTriangle.
Definition WEMNode.h:173
void remove(WEMEdge *edge)
Removes the given edge.
void setNormal(double x, double y, double z)
Sets the normal of the node.
Definition WEMNode.h:151
void setFace(unsigned int index, WEMFace *face)
Sets the given face at the given index.
Definition WEMNode.h:208
WEMQuad * getQuadAt(unsigned int index)
Returns the face at the given index and casts it to WEMQuad.
Definition WEMNode.h:178
WEMNode(const WEMNode &n)
Copy constructor.
void replace(WEMFace *orig, WEMFace *replacement)
Replaces a face orig in the internal face's vector by another face replace.
void removeEdges()
Removes all edges attached to this node.
Definition WEMNode.h:248
Vector3 getNormal() const
Returns the normal of the node.
Definition WEMNode.h:141
void setPositionNoInvalidationOfBoundingBoxes(double x, double y, double z)
Sets the position in world coordinates without invalidating the bounding boxes of adjacent faces.
Definition WEMNode.h:79
void setColor(double r, double g, double b)
Sets the RGB color of the node.
Definition WEMNode.h:129
WEMNode(WEMNode &&n) noexcept
void remove(WEMFace *face)
Removes the given face.
WEMNode & operator=(WEMNode &&n) noexcept
void reset()
Resets the object to default constructed state.
void setColor(double a)
Sets the alpha color of the node.
Definition WEMNode.h:136
bool isBoundary() const
Returns whether the node has any edge which is a boundary edge.
Definition WEMNode.h:239
unsigned int getNumEdges() const
Returns the number of edges attached to this node.
Definition WEMNode.h:114
const WEMQuad * getQuadAt(unsigned int index) const
Returns the face at the given index and casts it to WEMQuad.
Definition WEMNode.h:183
void scale(const Vector3 &scaleFactor)
Scales the position by given vector.
Definition WEMNode.h:93
double getPrimitiveValue(const WEMPrimitiveValueList *valueList) const
Returns the node value from the given primitive value list.
void computeNormal()
Computes the normal of the node.
WEMPolygon * getPolygonAt(unsigned int index)
Returns the face at the given index and casts it to WEMPolygon.
Definition WEMNode.h:188
void addFace(WEMFace *face)
Adds the given face.
Definition WEMNode.h:198
WEMNode()
Standard constructor.
Defines the mesh component: polygon.
Definition WEMPolygon.h:22
Stores a value list where the values are associated to primitives (WEMNode, WEMEdge,...
This is the base class for the WEM elements nodes, edges, and faces.
Defines the mesh component: quad.
Definition WEMQuad.h:25
Defines the mesh component: triangle.
Definition WEMTriangle.h:27
Dynamic templated vector.
Definition WEMVector.h:27
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
bool MLWEM_EXPORT nodesAtAlmostIdenticalPositions(const WEMNode &x, const WEMNode &y)