00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Cristin Barghiel 00008 * Side Effects Software Inc. 00009 * 20 Maud St. 00010 * Toronto, Ontario, M5V 2M5 00011 * Canada 00012 * 416-366-4607 00013 * 00014 * NAME: Geometry Library (C++) 00015 * 00016 * COMMENTS: 00017 * The vertex class. As opposed to GEO_Points, all vertices are unique. 00018 * 00019 * WARNING: Try to avoid using the assignment operator '=' because it is 00020 * shallow in the attribute component! 00021 * 00022 */ 00023 00024 #ifndef __GEO_Vertex_H__ 00025 #define __GEO_Vertex_H__ 00026 00027 #include "GEO_API.h" 00028 #include <GB/GB_Vertex.h> 00029 #include <GB/GB_Attribute.h> 00030 #include "GEO_Point.h" 00031 00032 class GEO_Detail; 00033 00034 class GEO_API GEO_Vertex : public GB_Vertex, public GB_AttributeElem 00035 { 00036 public: 00037 explicit GEO_Vertex( GEO_Point *p=0) : GB_Vertex(p) {} 00038 explicit GEO_Vertex(GEO_Detail *d,GEO_Point *p=0) : GB_Vertex(p) 00039 { initAttributeData(d); } 00040 00041 virtual ~GEO_Vertex() { } 00042 00043 // Avoid using this c-tor because it's dangerously shallow! 00044 GEO_Vertex(const GEO_Vertex &vtx) 00045 : GB_Vertex(vtx.getBasePt()), GB_AttributeElem(vtx) {} 00046 00047 void initAttributeData(GEO_Detail *d); 00048 void copyAttributeData(const GEO_Vertex *src, int size); 00049 00050 GEO_Point *getPt(void) const { return (GEO_Point*)getBasePt(); } 00051 00052 UT_Vector4 &getPos() 00053 { 00054 return ((GEO_Point*)getBasePt())->getPos(); 00055 } 00056 const UT_Vector4 &getPos() const 00057 { 00058 return ((const GEO_Point*)getBasePt())->getPos(); 00059 } 00060 00061 void steal(GEO_Vertex &src) 00062 { 00063 GB_Vertex::steal(src); 00064 getAttrib().steal(src.getAttrib()); 00065 } 00066 00067 void copyVertex(const GEO_Vertex *src, GEO_Point *pt, 00068 int avsize) 00069 { 00070 setPt(pt); 00071 copyAttributeData(src, avsize); 00072 } 00073 void copyVertex(const GEO_Vertex *src, int avsize) 00074 { 00075 setPt(src->getBasePt()); 00076 copyAttributeData(src, avsize); 00077 } 00078 00079 // Avoid using operator=() because it's dangerously shallow! 00080 GEO_Vertex &operator=(const GEO_Vertex &vtx) 00081 { 00082 if (this != &vtx) 00083 { 00084 setPt(vtx.getBasePt()); 00085 getAttrib() = vtx.getAttrib(); // shallow! 00086 } 00087 return *this; 00088 00089 } 00090 int operator==(const GEO_Vertex &vtx) const 00091 { 00092 // Trivial check to make it simple. Do not change. 00093 return this == &vtx; 00094 } 00095 00096 private: 00097 // Nothing. 00098 }; 00099 00100 #endif
1.5.9