00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __GEO_PrimTube_H__
00031 #define __GEO_PrimTube_H__
00032
00033 #include "GEO_API.h"
00034 #include "GEO_Quadric.h"
00035 #include "GEO_PrimType.h"
00036 #include "GEO_Vertex.h"
00037
00038 #define GEO_TUBE_XSECT_TOP_XP 0
00039 #define GEO_TUBE_XSECT_TOP_XN 1
00040 #define GEO_TUBE_XSECT_TOP_ZP 2
00041 #define GEO_TUBE_XSECT_TOP_ZN 3
00042 #define GEO_TUBE_XSECT_TOP_CTR 4
00043 #define GEO_TUBE_XSECT_BOT_XP 5
00044 #define GEO_TUBE_XSECT_BOT_XN 6
00045 #define GEO_TUBE_XSECT_BOT_ZP 7
00046 #define GEO_TUBE_XSECT_BOT_ZN 8
00047 #define GEO_TUBE_XSECT_BOT_CTR 9
00048 #define GEO_TUBE_XSECT_MID_XP 10
00049 #define GEO_TUBE_XSECT_MID_XN 11
00050 #define GEO_TUBE_XSECT_MID_ZP 12
00051 #define GEO_TUBE_XSECT_MID_ZN 13
00052
00053 #define GEO_TUBE_GUIDEEDGE_BX 0
00054 #define GEO_TUBE_GUIDEEDGE_BZ 1
00055 #define GEO_TUBE_GUIDEEDGE_MX 2
00056 #define GEO_TUBE_GUIDEEDGE_MZ 3
00057 #define GEO_TUBE_GUIDEEDGE_TX 4
00058 #define GEO_TUBE_GUIDEEDGE_TZ 5
00059 #define GEO_TUBE_GUIDEEDGE_XN 6
00060 #define GEO_TUBE_GUIDEEDGE_XP 7
00061 #define GEO_TUBE_GUIDEEDGE_ZN 8
00062 #define GEO_TUBE_GUIDEEDGE_ZP 9
00063
00064
00065
00066
00067 enum GEO_TubeCaptureAtrFields {
00068 I_GEO_TUBECAPTURE_BCAP=0,
00069 I_GEO_TUBECAPTURE_TCAP,
00070 I_GEO_TUBECAPTURE_TAPERX,
00071 I_GEO_TUBECAPTURE_TAPERZ,
00072 I_GEO_TUBECAPTURE_INWEIGHT,
00073 I_GEO_TUBECAPTURE_OUTWEIGHT,
00074 GEO_TUBECAPTURE_ATTRIB_SZ
00075 };
00076
00077 class GEO_API GEO_PrimTubeFlags {
00078 public:
00079 GEO_PrimTubeFlags()
00080 {
00081 endcaps = 0;
00082 }
00083 unsigned endcaps:1;
00084 };
00085
00086 class GEO_API GEO_PrimTube : public GEO_Quadric {
00087 public:
00088 GEO_PrimTube(GEO_Detail *d);
00089 ~GEO_PrimTube();
00090
00091 virtual unsigned getPrimitiveId() const;
00092
00093
00094
00095
00096
00097 virtual bool evaluatePoint( GEO_Vertex &result,
00098 GEO_AttributeHandleList &hlist,
00099 fpreal u, fpreal v, uint du, uint dv) const;
00100 virtual int evaluatePoint( UT_Vector4 &pos, float u, float v = 0,
00101 unsigned du=0, unsigned dv=0) const;
00102 virtual int evaluatePointWAttrib(UT_Vector4 &pos,
00103 GB_AttributeData &adata,
00104 const GB_FloatOffsets &foffsets,
00105 float u, float v = 0, unsigned du = 0,
00106 unsigned dv = 0) const;
00107
00108 virtual int getBBox(UT_BoundingBox *bbox) const;
00109 virtual void addToBSphere(UT_BoundingSphere *bsphere) const;
00110
00111 virtual GEO_Primitive *copy(int preserve_shared_pts = 0) const;
00112 virtual void copyPrimitive(const GEO_Primitive *src,
00113 GEO_Point **ptredirect);
00114
00115 virtual int hasGuideEdge(int edgeid, UT_Vector4 &a,
00116 UT_Vector4 &b) const;
00117 virtual int hasXsectPoint(int pointid, UT_Vector4 &p) const;
00118
00119
00120
00121 unsigned endcaps(void) const { return flags.endcaps; }
00122 void setEndCaps(int onOff) { flags.endcaps = onOff; }
00123 float getTaper(void) const { return myTaper; }
00124 void setTaper(float t) { myTaper = t; }
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 float getCaptureRegionWeight( const UT_Vector3 &pos,
00137 int tubeCaptAtrOffset ) const;
00138 static float computeCaptureRegionWeight( const UT_Vector3 &pos,
00139 float bcap, float tcap, float taperx,
00140 float taperz, float min_weight,
00141 float max_weight );
00142
00143 virtual float calcVolume(UT_Vector3 &refpt) const;
00144 virtual float calcArea() const;
00145 virtual float calcPerimeter() const;
00146 protected:
00147 virtual void copyOffsetPrimitive(const GEO_Primitive *src,
00148 int basept);
00149
00150 virtual int savePrivate(ostream &os, int binary) const;
00151 virtual bool loadPrivate(UT_IStream &is);
00152
00153 private:
00154 GEO_PrimTubeFlags flags;
00155
00156
00157
00158 float myTaper;
00159
00160 friend ostream &operator<<(ostream &os, const GEO_PrimTube &d)
00161 {
00162 d.save(os, 0);
00163 return os;
00164 }
00165 };
00166 #endif