MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00004 00011 #ifndef __WEMNode_H 00012 #define __WEMNode_H 00013 00014 #include "WEMPrimitive.h" 00015 #include "WEMFace.h" 00016 #include "WEMEdge.h" 00017 #include "WEMPrimitiveValueList.h" 00018 #include "WEMDataStructure/WEMVector.h" 00019 00020 ML_START_NAMESPACE 00021 00022 // some forward declarations. 00023 class WEMEdge; 00024 class WEMTriangle; 00025 class WEMQuad; 00026 class WEMPolygon; 00027 00029 class MLWEM_EXPORT WEMNode : public WEMPrimitive 00030 { 00031 00032 public: 00033 00035 WEMNode(); 00037 WEMNode(const WEMNode& n); 00039 virtual ~WEMNode(); 00041 void clone(WEMNode* n); 00042 00044 inline Vector3 getPosition() const { return _position; } 00046 inline void getPosition(double& x, double& y, double& z) const { x=_position.x; y=_position.y; z=_position.z;} 00047 00048 #ifdef ML_DEPRECATED 00049 00050 00051 00052 00053 00054 inline void getPosition(float& x, float& y, float& z) 00055 { 00056 x=static_cast<float>(_position.x); 00057 y=static_cast<float>(_position.y); 00058 z=static_cast<float>(_position.z); 00059 } 00061 #endif 00062 00064 inline void setPosition(const Vector3& position) { _position = position; } 00066 inline void setPosition(double x, double y, double z) { _position.assign(x,y,z); } 00068 inline void translate(const Vector3& offset) { _position += offset; } 00070 void applyMatrix(Matrix4 transformMatrix); 00072 inline void scale(const Vector3& scaleFactor) { _position *= scaleFactor; } 00074 inline unsigned int getFaceValence() const { return _faces.num(); } 00076 inline unsigned int getEdgeValence() const { return _edges.num(); } 00078 inline Vector4 getColor() const { return _color; } 00080 inline void setColor(const Vector4& color) { _color = color; } 00082 inline void setColor(float r, float g, float b) { _color[0] = r; _color[1] = g; _color[2] = b; } 00084 inline void setColor(float a) { _color[3] = a; } 00086 inline Vector3 getNormal() const { return _normal; } 00088 inline void setNormal(const Vector3& normal) { _normal = normal; } 00090 inline void setNormal(float x, float y, float z) { _normal.assign(x,y,z); } 00092 void computeNormal(); 00094 inline WEMFace* getFaceAt(unsigned int index) { return _faces.at(index); } 00096 inline const WEMFace* getFaceAt(unsigned int index) const { return const_cast<WEMNode*>(this)->getFaceAt(index); } 00098 inline WEMTriangle* getTriangleAt(unsigned int index) { return (_faces.at(index)) ? reinterpret_cast<WEMTriangle*>(_faces.at(index)) : NULL; } 00100 inline const WEMTriangle* getTriangleAt(unsigned int index) const { return const_cast<WEMNode*>(this)->getTriangleAt(index); } 00102 inline WEMQuad* getQuadAt(unsigned int index) { return (_faces.at(index)) ? reinterpret_cast<WEMQuad*>(_faces.at(index)) : NULL; } 00104 inline const WEMQuad* getQuadAt(unsigned int index) const { return const_cast<WEMNode*>(this)->getQuadAt(index); } 00106 inline WEMPolygon* getPolygonAt(unsigned int index) { return (_faces.at(index)) ? reinterpret_cast<WEMPolygon*>(_faces.at(index)) : NULL; } 00108 inline const WEMPolygon* getPolygonAt(unsigned int index) const { return const_cast<WEMNode*>(this)->getPolygonAt(index); } 00110 inline void addFace(WEMFace* face) { _faces.append(face); } 00112 void remove(WEMFace* face); 00114 inline WEMEdge* getEdgeAt(unsigned int index) { return _edges.at(index); } 00116 inline const WEMEdge* getEdgeAt(unsigned int index) const { return const_cast<WEMNode*>(this)->getEdgeAt(index); } 00118 inline void addEdge(WEMEdge* edge) { _edges.append(edge); } 00120 void remove(WEMEdge* edge); 00122 WEMEdge* getEdgeWith(WEMNode* node); 00124 inline const WEMEdge* getEdgeWith(WEMNode* node) const { return const_cast<WEMNode*>(this)->getEdgeWith(node); } 00126 inline bool isBoundary() const { return (_edges.num() && (_edges.num() != _faces.num())); } 00128 void replace(WEMEdge* orig, WEMEdge* replacement); 00130 void replace(WEMFace* orig, WEMFace* replacement); 00132 inline void removeEdges() { _edges.clear(); } 00134 inline void removeFaces() { _faces.clear(); } 00136 double getLargestDihedralAngle() const; 00139 double getPrimitiveValue(const WEMPrimitiveValueList* valueList) const; 00140 00141 private: 00142 00144 Vector3 _position; 00146 Vector4 _color; 00148 Vector3 _normal; 00150 WEMVector<WEMFace> _faces; 00152 WEMVector<WEMEdge> _edges; 00153 }; 00154 00155 00156 ML_END_NAMESPACE 00157 00158 #endif // __WEMNode_H