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 * Jeff Lait 00008 * Side Effects 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: GU library (C++) 00015 * 00016 * COMMENTS: Describes a set of space curves. Creates nodes 00017 * whereever the space curves intersect, recording which 00018 * curves and where they intersected. Curves are 00019 * also given an index when they are added, allowing 00020 * easy cross referencing to other data structures. 00021 * 00022 */ 00023 00024 #ifndef __GU_CurveSet_h__ 00025 #define __GU_CurveSet_h__ 00026 00027 #include "GU_API.h" 00028 #include <UT/UT_RefArray.h> 00029 #include <UT/UT_PtrArray.h> 00030 #include <UT/UT_Vector3.h> 00031 00032 // Node iterator: 00033 #define FOR_ALL_NODES(curveset, node) \ 00034 for (node = curveset.getHeadNode(); node; node = node->next()) 00035 00036 class GD_TrimLoop; 00037 class GU_CurveSet; 00038 class GU_CurveNode; 00039 class GEO_Face; 00040 class GU_Detail; 00041 00042 class GU_API GU_CurveSetInfo 00043 { 00044 public: 00045 // Not a very intelligent == operator, something is required for 00046 // NT build though. 00047 int operator==(const GU_CurveSetInfo &curveInfo) 00048 { return curve == curveInfo.curve; } 00049 00050 GEO_Face *curve; 00051 UT_PtrArray<GU_CurveNode *> nodes; 00052 00053 void removeNode(const GU_CurveNode *node); 00054 }; 00055 00056 class GU_API GU_CurveNodeInfo 00057 { 00058 public: 00059 int operator==(const GU_CurveNodeInfo & /*ni*/) 00060 { return 1; } // Req'd for NT 00061 00062 // data 00063 int curveidx; // The curve that hits this node. 00064 float u; // Where that curve isects. 00065 float d2; // Distance of curve to this node 00066 }; 00067 00068 class GU_API GU_CurveNode 00069 { 00070 public: 00071 void addCurve(GU_CurveSetInfo &curveinfo, int curveidx, 00072 float u, float d2, const UT_Vector3 &pt); 00073 00074 GU_CurveNode *next() const { return myNext; } 00075 int degree() const { return myDegree; } 00076 GU_CurveNodeInfo &operator()(int i) { return myEdges(i); } 00077 GU_CurveNodeInfo operator()(int i) const { return myEdges(i); } 00078 UT_Vector3 &point() { return myPt; } 00079 UT_Vector3 point() const { return myPt; } 00080 UT_Vector3 &normal() { return myNormal; } 00081 UT_Vector3 normal() const { return myNormal; } 00082 00083 public: 00084 // data 00085 UT_Vector3 myPt; // Where isection is 00086 UT_Vector3 myNormal; // Orientation of node 00087 int myDegree; // # curves isecting here 00088 UT_RefArray<GU_CurveNodeInfo> myEdges; // All edges hitting here. 00089 GU_CurveNode *myNext; // Next in chain. 00090 float myD2; // Dist of isect to point. 00091 }; 00092 00093 class GU_API GU_CurveSet 00094 { 00095 public: 00096 GU_CurveSet(int useEnds = 0); 00097 ~GU_CurveSet(); 00098 00099 // Merges two curvesets. Curve indices are changed: 00100 void merge(GU_CurveSet &curveset); 00101 00102 // Adds new curve. Returns its index 00103 // Not const as intersection info is generated. 00104 int merge(GEO_Face &curve); 00105 00106 int isEmpty() const 00107 { return (myCurves.entries()) ? 0 : 1; } 00108 int numCurves() const { return myCurves.entries(); } 00109 00110 // Clears all local information without destroying the refarray. 00111 void reset(); 00112 00113 GU_CurveSetInfo &operator()(int i) { return myCurves(i); } 00114 GU_CurveSetInfo operator()(int i) const { return myCurves(i); } 00115 00116 // Not a very intelligent == operator, something is required for 00117 // NT build though. 00118 int operator==(const GU_CurveSet &curveSet) 00119 { return myCurves == curveSet.myCurves; } 00120 00121 // Builds topological info of set. 00122 void buildNodeList(float tol = 1e-3); 00123 00124 GU_CurveNode *getHeadNode() const { return myNodes; } 00125 00126 private: 00127 // Eliminates topological information of set. 00128 void clearNodeList(); 00129 00130 GU_CurveNode *findNode(const UT_Vector3 &p, 00131 float tol = 1e-3) const; 00132 GU_CurveNode *createNode(const UT_Vector3 &p); 00133 00134 // List of all curves that are present. 00135 UT_RefArray<GU_CurveSetInfo> myCurves; 00136 // Head of the node list. 00137 GU_CurveNode *myNodes; 00138 // True if we only use ends of curves. 00139 int myUseEnds; 00140 }; 00141 00142 #endif 00143
1.5.9