00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GEO_Point_H__
00021 #define __GEO_Point_H__
00022
00023 #include "GEO_API.h"
00024 #include <UT/UT_SmallObject.h>
00025 #include <UT/UT_Vector4.h>
00026 #include <GB/GB_Element.h>
00027 #include <GB/GB_Attribute.h>
00028
00029 class GEO_Primitive;
00030 class GB_FloatOffsets;
00031
00032 class GEO_API GEO_Point : public GB_Element, public GB_AttributeElem,
00033 public UT_SmallObject<GEO_Point,
00034 UT_SMALLOBJECT_CLEANPAGES_DEFAULT,
00035 UT_SMALLOBJECT_PAGESIZE_DEFAULT,
00036 UT_SMALLOBJECT_THREADSAFE_ON>
00037 {
00038 public:
00039
00040
00041
00042 GEO_Point()
00043 { myPos.assign(0.0F,0.0F,0.0F,1.0F); }
00044 GEO_Point(const UT_Vector4 &P, GB_AttributeData &adata)
00045 { myPos = P; getAttrib().swapData(adata); }
00046 virtual ~GEO_Point();
00047
00048
00049 virtual int isPrimary(void) const;
00050
00051 void copyPoint(const GEO_Point *src, int asize)
00052 {
00053 myPos = src->myPos;
00054 copyAttribData(src, asize);
00055 }
00056 void copyPoint(const GEO_Point *src,
00057 const GB_AttributeDict &src_dict,
00058 const GB_AttributeDict &dest_dict)
00059 {
00060 myPos = src->myPos;
00061 copyAttribData(src, src_dict, dest_dict);
00062 }
00063 void copyAttributeData(const GEO_Point *src, int asize)
00064 {
00065 copyAttribData(src, asize);
00066 }
00067
00068 UT_Vector4 &getPos() { return myPos; }
00069 const UT_Vector4 &getPos() const { return myPos; }
00070 void setPos(const UT_Vector4 &p)
00071 { myPos = p; }
00072 void setPos(const UT_Vector3 &p, float w=1)
00073 { myPos.assign(p.x(), p.y(), p.z(), w); }
00074
00075
00076 void homogenize (void) { myPos.homogenize(); }
00077 void dehomogenize(void) { myPos.dehomogenize(); }
00078 void homogenizeWAttrib(const GB_FloatOffsets &foffsets)
00079 {
00080 if (myPos.w() != 1.0f)
00081 {
00082 myPos.homogenize();
00083 getAttrib().mulf(myPos.w(), foffsets);
00084 }
00085 }
00086 void dehomogenizeWAttrib(const GB_FloatOffsets &foffsets)
00087 {
00088 if (myPos.w() != 1.0f)
00089 {
00090 myPos.dehomogenize();
00091 getAttrib().divf(myPos.w(), foffsets);
00092 }
00093 }
00094
00095
00096 int saveASCII(ostream &os) const;
00097 int saveBinary(ostream &os) const;
00098 bool load(UT_IStream &is);
00099
00100 private:
00101 UT_Vector4 myPos;
00102 };
00103
00104 #endif