MeVisLab Toolbox Reference
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:
35
39 WEMNode(const WEMNode& n);
40 WEMNode(WEMNode&&n) noexcept;
41 WEMNode& operator=(WEMNode &&n) noexcept;
43 ~WEMNode() override;
45 void reset();
47 void clone(WEMNode* n);
48
50 inline const Vector3& getPosition() const { return _position; }
52 inline void getPosition(double& x, double& y, double& z) const { x=_position.x; y=_position.y; z=_position.z;}
53
55 inline void setPosition(const Vector3& position) { _position = position; invalidateBoundingBoxesOfAdjacentFaces(); }
57 inline void setPosition(double x, double y, double z) { _position.assign(x,y,z); invalidateBoundingBoxesOfAdjacentFaces(); }
59 inline void translate(const Vector3& offset) { _position += offset; invalidateBoundingBoxesOfAdjacentFaces(); }
64 inline void scale(const Vector3& scaleFactor) { _position *= scaleFactor; invalidateBoundingBoxesOfAdjacentFaces(); }
66 inline unsigned int getFaceValence() const { return _faces.num(); }
68 inline unsigned int getEdgeValence() const { return _edges.num(); }
70 inline unsigned int getNumFaces() const { return getFaceValence(); }
72 inline unsigned int getNumEdges() const { return getEdgeValence(); }
74 inline Vector4 getColor() const { return _color; }
76 inline void setColor(const Vector4& color) { _color = color; }
78 inline void setColor(float r, float g, float b) { _color[0] = r; _color[1] = g; _color[2] = b; }
80 inline void setColor(float a) { _color[3] = a; }
82 inline Vector3 getNormal() const { return _normal; }
84 inline void setNormal(const Vector3& normal) { _normal = normal; }
86 inline void setNormal(float x, float y, float z) { _normal.assign(x,y,z); }
90 inline WEMFace* getFaceAt(unsigned int index) { return _faces.at(index); }
92 inline const WEMFace* getFaceAt(unsigned int index) const { return const_cast<WEMNode*>(this)->getFaceAt(index); }
94 inline WEMTriangle* getTriangleAt(unsigned int index) { return (_faces.at(index)) ? reinterpret_cast<WEMTriangle*>(_faces.at(index)) : nullptr; }
96 inline const WEMTriangle* getTriangleAt(unsigned int index) const { return const_cast<WEMNode*>(this)->getTriangleAt(index); }
98 inline WEMQuad* getQuadAt(unsigned int index) { return (_faces.at(index)) ? reinterpret_cast<WEMQuad*>(_faces.at(index)) : nullptr; }
100 inline const WEMQuad* getQuadAt(unsigned int index) const { return const_cast<WEMNode*>(this)->getQuadAt(index); }
102 inline WEMPolygon* getPolygonAt(unsigned int index) { return (_faces.at(index)) ? reinterpret_cast<WEMPolygon*>(_faces.at(index)) : nullptr; }
104 inline const WEMPolygon* getPolygonAt(unsigned int index) const { return const_cast<WEMNode*>(this)->getPolygonAt(index); }
106 inline void addFace(WEMFace* face) { _faces.append(face); }
110 inline WEMEdge* getEdgeAt(unsigned int index) { return _edges.at(index); }
112 inline const WEMEdge* getEdgeAt(unsigned int index) const { return const_cast<WEMNode*>(this)->getEdgeAt(index); }
114 inline void addEdge(WEMEdge* edge) { _edges.append(edge); }
116 void remove(WEMEdge* edge);
120 inline const WEMEdge* getEdgeWith(WEMNode* node) const { return const_cast<WEMNode*>(this)->getEdgeWith(node); }
122 inline bool isBoundary() const { return (_edges.num() && (_edges.num() != _faces.num())); }
128 inline void removeEdges() { _edges.clear(); }
130 inline void removeFaces() { _faces.clear(); }
136
137private:
138
139 void invalidateBoundingBoxesOfAdjacentFaces();
140
141 void resetNode();
142
144 Vector3 _position;
146 Vector4 _color;
148 Vector3 _normal;
153};
154
156
158
160
#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:130
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:94
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:55
unsigned int getFaceValence() const
Returns the face valence of node. The valence denotes the number of attached faces.
Definition WEMNode.h:66
const WEMPolygon * getPolygonAt(unsigned int index) const
Returns the face at the given index and casts it to WEMPolygon.
Definition WEMNode.h:104
void setColor(float a)
Sets the alpha color of the node.
Definition WEMNode.h:80
const WEMEdge * getEdgeWith(WEMNode *node) const
Returns the edge shared with the given node.
Definition WEMNode.h:120
unsigned int getEdgeValence() const
Returns the edge valence of node. The valence denotes the number of attached edges.
Definition WEMNode.h:68
void setNormal(const Vector3 &normal)
Sets the normal of the node.
Definition WEMNode.h:84
void setColor(const Vector4 &color)
Sets the color of the node.
Definition WEMNode.h:76
void setNormal(float x, float y, float z)
Sets the normal of the node.
Definition WEMNode.h:86
const WEMFace * getFaceAt(unsigned int index) const
Returns the face at the given index.
Definition WEMNode.h:92
~WEMNode() override
Standard destructor.
void translate(const Vector3 &offset)
Translates the position by the given vector.
Definition WEMNode.h:59
void getPosition(double &x, double &y, double &z) const
Returns the world position.
Definition WEMNode.h:52
Vector4 getColor() const
Returns the color of the node.
Definition WEMNode.h:74
unsigned int getNumFaces() const
Returns the number of faces attached to this node.
Definition WEMNode.h:70
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:110
void addEdge(WEMEdge *edge)
Adds the edge.
Definition WEMNode.h:114
WEMFace * getFaceAt(unsigned int index)
Returns the face at the given index.
Definition WEMNode.h:90
const WEMEdge * getEdgeAt(unsigned int index) const
Returns the edge at the given index.
Definition WEMNode.h:112
void setPosition(double x, double y, double z)
Sets the position in world coordinates.
Definition WEMNode.h:57
const Vector3 & getPosition() const
Returns the world position.
Definition WEMNode.h:50
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:96
void remove(WEMEdge *edge)
Removes the given edge.
WEMQuad * getQuadAt(unsigned int index)
Returns the face at the given index and casts it to WEMQuad.
Definition WEMNode.h:98
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:128
Vector3 getNormal() const
Returns the normal of the node.
Definition WEMNode.h:82
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(float r, float g, float b)
Sets the RGB color of the node.
Definition WEMNode.h:78
bool isBoundary() const
Returns whether the node has any edge which is a boundary edge.
Definition WEMNode.h:122
unsigned int getNumEdges() const
Returns the number of edges attached to this node.
Definition WEMNode.h:72
const WEMQuad * getQuadAt(unsigned int index) const
Returns the face at the given index and casts it to WEMQuad.
Definition WEMNode.h:100
void scale(const Vector3 &scaleFactor)
Scales the position by given vector.
Definition WEMNode.h:64
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:102
void addFace(WEMFace *face)
Adds the given face.
Definition WEMNode.h:106
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:28
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
bool MLWEM_EXPORT nodesAtAlmostIdenticalPositions(const WEMNode &x, const WEMNode &y)