MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00004 00011 #ifndef __WEMTriangle_H 00012 #define __WEMTriangle_H 00013 00014 #include "WEMFace.h" 00015 #include "WEMNode.h" 00016 #include "WEMEdge.h" 00017 00018 ML_START_NAMESPACE 00019 00021 class MLWEM_EXPORT WEMTriangle : public WEMFace 00022 { 00023 public: 00024 00026 WEMTriangle(); 00028 WEMTriangle(const WEMTriangle& t); 00030 virtual ~WEMTriangle(); 00032 void clone(WEMTriangle* triangle); 00033 00035 virtual void computeNormal(); 00037 virtual inline unsigned int getNumNodes() const { return 3; } 00039 virtual int getIndex(WEMNode* node) const; 00041 virtual inline WEMNode* getNodeAt(unsigned int index) { return _nodes[index]; } 00043 virtual inline const WEMNode* getNodeAt(unsigned int index) const { return const_cast<WEMTriangle*>(this)->getNodeAt(index); } 00045 virtual inline void setNode(unsigned int index, WEMNode* node) { _nodes[index] = node; } 00047 virtual inline void setNodes(WEMNode* node1, WEMNode* node2, WEMNode* node3) { 00048 _nodes[0] = node1; _nodes[1] = node2; _nodes[2] = node3; 00049 } 00051 virtual void replace(WEMNode* orig, WEMNode* replacement); 00053 virtual bool contains(WEMNode* node) const; 00055 virtual Vector3 getNodePositionAt(unsigned int index) const { return _nodes[index]->getPosition(); } 00056 00058 virtual int getIndex(WEMEdge* edge) const; 00060 virtual inline WEMEdge* getEdgeAt(unsigned int index) { return _edges[index]; } 00062 virtual inline const WEMEdge* getEdgeAt(unsigned int index) const { return const_cast<WEMTriangle*>(this)->getEdgeAt(index); } 00064 virtual inline void setEdge(unsigned int index, WEMEdge* edge) { _edges[index] = edge; } 00066 virtual inline void setEdges(WEMEdge* edge1, WEMEdge* edge2, WEMEdge* edge3) { 00067 _edges[0] = edge1; _edges[1] = edge2; _edges[2] = edge3; 00068 } 00070 virtual void replace(WEMEdge* orig, WEMEdge* replacement); 00072 virtual bool contains(WEMEdge* edge) const; 00073 00075 virtual Vector3 getCentroid() const; 00077 virtual double getPerimeter() const; 00079 virtual double getArea() const; 00081 virtual WEMNode* getOther(WEMNode* n1, WEMNode* n2); 00083 virtual inline const WEMNode* getOther(WEMNode* n1, WEMNode* n2) const { return const_cast<WEMTriangle*>(this)->getOther(n1, n2); } 00085 virtual WEMEdge* getOther(WEMEdge* e1, WEMEdge* e2); 00087 virtual inline const WEMEdge* getOther(WEMEdge* e1, WEMEdge* e2) const { return const_cast<WEMTriangle*>(this)->getOther(e1, e2); } 00089 virtual WEMEdge* getEdgeNotContaining(WEMNode* n); 00091 virtual inline const WEMEdge* getEdgeNotContaining(WEMNode* n) const { return const_cast<WEMTriangle*>(this)->getEdgeNotContaining(n); } 00098 virtual double getQuality() const; 00100 virtual int isConcave() const { return 0; } 00102 virtual bool isFolding(WEMNode *node, const Vector3& position) const; 00104 virtual bool pointInTriangle(const Vector3& position) const; 00106 virtual bool rayIntersect(const Vector3& origin, const Vector3& direction) const; 00108 virtual void mirror(); 00109 00110 private: 00111 00113 WEMNode* _nodes[3]; 00115 WEMEdge* _edges[3]; 00116 }; 00117 00118 00119 ML_END_NAMESPACE 00120 00121 #endif // __WEMTriangle_H