MeVisLab Toolbox Reference
WEMPolygon.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 "WEMFace.h"
16 #include "WEMNode.h"
17 
18 ML_START_NAMESPACE
19 
22 {
23 public:
24 
30  ~WEMPolygon() override;
32  void clone(WEMPolygon* polygon);
33 
35  void computeNormal() override;
37  inline unsigned int getNumNodes() const override { return _numNodes; }
39  virtual inline void setNumNodes(unsigned int numNodes) { _numNodes = numNodes; }
41  int getIndex(WEMNode* node) const override;
43  inline WEMNode* getNodeAt(unsigned int index) override { return _nodes[index]; }
45  inline const WEMNode* getNodeAt(unsigned int index) const override { return const_cast<WEMPolygon*>(this)->getNodeAt(index); }
48  inline void setNode(unsigned int index, WEMNode* node) override { _nodes[index] = node; invalidateBoundingBox(); }
50  void replace(WEMNode* orig, WEMNode* replacement) override;
52  bool contains(WEMNode* node) const override;
54  virtual inline void addNode(WEMNode* node) { _nodes[_numNodes ++] = node; invalidateBoundingBox(); }
56  Vector3 getNodePositionAt(unsigned int index) const override { return _nodes[index]->getPosition(); }
57 
59  int getIndex(WEMEdge* edge) const override;
61  inline WEMEdge* getEdgeAt(unsigned int index) override { return _edges[index]; }
63  inline const WEMEdge* getEdgeAt(unsigned int index) const override { return const_cast<WEMPolygon*>(this)->getEdgeAt(index); }
65  inline void setEdge(unsigned int index, WEMEdge* edge) override { _edges[index] = edge;}
67  void replace(WEMEdge* orig, WEMEdge* replacement) override;
69  bool contains(WEMEdge* edge) const override;
71  void removeEdges() override;
72 
74  Vector3 getCentroid() const override;
75  void getCentroid(Vector3& centroid) const override;
77  double getPerimeter() const override;
79  double getArea() const override;
81  WEMNode* getOther(WEMNode* , WEMNode* ) override { return nullptr; }
83  const WEMNode* getOther(WEMNode* , WEMNode* ) const override { return nullptr; }
85  WEMEdge* getOther(WEMEdge* , WEMEdge* ) override { return nullptr; }
87  const WEMEdge* getOther(WEMEdge* , WEMEdge* ) const override { return nullptr; }
89  WEMEdge* getEdgeNotContaining(WEMNode* ) override { return nullptr; }
91  const WEMEdge* getEdgeNotContaining(WEMNode* ) const override{ return nullptr; }
98  double getQuality() const override;
100  int isConcave() const override;
103  void mirror() override;
104 
105 private:
106 
108  WEMNode* _nodes[WEM_MAX_NUM_NODES];
110  unsigned int _numNodes;
112  WEMEdge* _edges[WEM_MAX_NUM_NODES];
113 };
114 
115 ML_END_NAMESPACE
const unsigned int WEM_MAX_NUM_NODES
Maximum number of nodes for polygons.
Definition: MLWEMIncludes.h:40
#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
void invalidateBoundingBox()
Definition: WEMFace.h:98
Defines the mesh component: node.
Definition: WEMNode.h:33
Defines the mesh component: polygon.
Definition: WEMPolygon.h:22
Vector3 getNodePositionAt(unsigned int index) const override
Returns the world position of a node at the given index.
Definition: WEMPolygon.h:56
void removeEdges() override
Removes all edge pointers of this face.
const WEMEdge * getEdgeNotContaining(WEMNode *) const override
Returns the edge not containing given node.
Definition: WEMPolygon.h:91
virtual void setNumNodes(unsigned int numNodes)
Sets the number of nodes.
Definition: WEMPolygon.h:39
WEMNode * getNodeAt(unsigned int index) override
Returns the node at the given index in the face.
Definition: WEMPolygon.h:43
~WEMPolygon() override
Standard destructor.
double getQuality() const override
Calculates the quality of this face.
int getIndex(WEMEdge *edge) const override
Returns the index of the given edge.
WEMEdge * getEdgeAt(unsigned int index) override
Returns the edge at the given index in this face.
Definition: WEMPolygon.h:61
void computeNormal() override
Computes the normal.
const WEMNode * getNodeAt(unsigned int index) const override
Returns the node at the given index in the face.
Definition: WEMPolygon.h:45
void clone(WEMPolygon *polygon)
Clones given triangle.
WEMPolygon()
Standard constructor.
const WEMNode * getOther(WEMNode *, WEMNode *) const override
Returns the node incident to this face that is not given as a parameter.
Definition: WEMPolygon.h:83
void replace(WEMEdge *orig, WEMEdge *replacement) override
Replaces the given orig node by the given replace edge.
WEMEdge * getOther(WEMEdge *, WEMEdge *) override
Returns the edge incident to this face that is not given as a parameter.
Definition: WEMPolygon.h:85
WEMPolygon(const WEMPolygon &p)
Standard copy constructor.
double getPerimeter() const override
Calculates the perimeter of this face.
void getCentroid(Vector3 &centroid) const override
virtual void addNode(WEMNode *node)
Adds the given node (dynamic).
Definition: WEMPolygon.h:54
const WEMEdge * getEdgeAt(unsigned int index) const override
Returns the edge at the given index in this face.
Definition: WEMPolygon.h:63
WEMEdge * getEdgeNotContaining(WEMNode *) override
Returns the edge not containing given node.
Definition: WEMPolygon.h:89
unsigned int getNumNodes() const override
Returns the number of nodes.
Definition: WEMPolygon.h:37
WEMNode * getOther(WEMNode *, WEMNode *) override
Returns the node incident to this face that is not given as a parameter.
Definition: WEMPolygon.h:81
Vector3 getCentroid() const override
Returns the geometric centroid of this face.
int getIndex(WEMNode *node) const override
Returns the index of the given node.
bool contains(WEMEdge *edge) const override
Returns whether this face contains the given edge.
const WEMEdge * getOther(WEMEdge *, WEMEdge *) const override
Returns the edge incident to this face that is not given as a parameter.
Definition: WEMPolygon.h:87
int isConcave() const override
Checks whether this face is concave and returns the number of concavities.
void mirror() override
Mirrors this face.
void replace(WEMNode *orig, WEMNode *replacement) override
Replaces the given orig node by the given replace node.
bool contains(WEMNode *node) const override
Returns whether this face contains the given node.
double getArea() const override
Calculates the area of this face.
void setEdge(unsigned int index, WEMEdge *edge) override
Sets the given edge to the given index in this face.
Definition: WEMPolygon.h:65
void setNode(unsigned int index, WEMNode *node) override
Sets the given node to the given index in face.
Definition: WEMPolygon.h:48