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 * This class implements a piecewise Bezier curve defined by 00018 * a set of breakpoints, basis function, and CVs. 00019 * 00020 */ 00021 00022 #ifndef __GD_PrimRBezCurve_h__ 00023 #define __GD_PrimRBezCurve_h__ 00024 00025 #include "GD_API.h" 00026 #include "GD_Curve.h" 00027 #include "GD_PrimType.h" 00028 00029 class UT_Vector3; 00030 00031 class GD_API GD_PrimRBezCurve : public GD_Curve { 00032 public: 00033 // Constructor that attaches this curve to detail "d". 00034 GD_PrimRBezCurve(GD_Detail *d) : GD_Curve(d) {} 00035 00036 // Trivial class destructor, virtual by inheritance. Please read the 00037 // comments on the parent class d-tor. 00038 ~GD_PrimRBezCurve(); 00039 00040 // Build a new curve and insert it into the given detail. 00041 static GD_PrimRBezCurve *build(GD_Detail *gudp, 00042 int nelems, int order = 4, int closed=0, 00043 int appendPoints = 1); 00044 00045 // Given a domain value (u), store all the basis derivatives (from 0 to du 00046 // inclusive) into bmatx. Return the min index of the CVs needed 00047 // for the linear combination. The indices may exceed the number of 00048 // vertices if the curve is wrapped, so remember to use % getVertexCount(). 00049 virtual int evaluateBasisDerivs(float u,float bmatx[][GB_MAXORDER], 00050 int &cvoffset, unsigned du = 0, 00051 int uoffset = -1) const; 00052 00053 // Evaluate the basis at the given point in the domain and also return 00054 // the index of the first CV to linearly combine the basis with. The CV 00055 // index may exceed the number of vertices if the curve is wrapped, 00056 // so remember to use modulus (%). This method handles both rational and 00057 // non-rational curves. 00058 virtual int evaluateBasis(float u,float *ubvals, int &cvoffset, 00059 unsigned du=0, int uoffset=-1) const; 00060 00061 // Curve evaluator that takes a start and a stop index 00062 // in the valid knot domain and an lod representing number of points to 00063 // be interpolated between every two breakpoints. The methods ALWAYS 00064 // interpolate the encountered breakpoints (aka "edit points"). They return 00065 // the number of points in the list or -1 if unsuccessful. Please save 00066 // yourself headaches and pass VALID start and end indices (see the 00067 // method validInterval() in GB_Basis). 00068 virtual int evaluateBreakSegm(int uStartIdx, int uStopIdx, int lod, 00069 UT_Vector3 *pos, unsigned du=0) const; 00070 00071 // Remove all repeated vertices - (only gets consecutive vertices) 00072 virtual int removeRepeatedVertices(int check_order = 0); 00073 00074 // Given a CV index figure out the min/max indicies of the knots between 00075 // which the curve needs to be re-evaluated if the CV changes. If not 00076 // given a valid CV index, the method returns -1. Otherwise it returns 0. 00077 // If the curve wraps the domain we return will be rather large. 00078 virtual int domainRangeOfCV(int cvidx, int &mink,int &maxk) const; 00079 00080 // Close up an open curve. 00081 virtual void close(int rounded = 1, int preserveShape = 0); 00082 00083 // Open up a closed curve. 00084 virtual void open(int preserveShape = 0, int safe = 0); 00085 00086 // Insert or delete vertices. The insertion methods return the index if 00087 // successful and -1 otherwise. The deletion methods return 0 if ok and 00088 // -1 otherwise. The insertion methods create the point if it does not 00089 // exist. 00090 virtual int insertVertex(GD_Point *ppt=0, unsigned int where=0); 00091 virtual int appendVertex(GD_Point *ppt=0); 00092 virtual int deleteVertex(GD_Vertex &vtx); 00093 virtual int deleteVertex(unsigned int num); 00094 00095 // Delete the vertex that uses the point. 00096 virtual int ifDetachPoint(GB_Element *ppt) const; 00097 00098 // Reverses the vertices of the curve. 00099 virtual void reverse(); 00100 00101 // Query the primitive type. The function is virtual by inheritance. 00102 virtual unsigned getPrimitiveId(void) const; 00103 00104 // Build a trim loop (which will be open unless the face is closed). The 00105 // loop is build every time you call this method, so it's expensive. You 00106 // must free the loop yourself when you are done with it. The trim pieces 00107 // are generated in the [ustart,ustop] or [ustop,ustart] interval, where 00108 // ustart and ustop are parametric values. 00109 virtual GD_TrimLoop *trimLoop(float ustart, float ustop) const; 00110 00111 00112 protected: 00113 // Get a new basis of a type that matches our type: 00114 virtual GB_Basis *newBasis(void) const; 00115 00116 // Two different closing methods: 00117 void closeSharp(void); 00118 void closeRounded(void); 00119 00120 00121 private: 00122 // Fill the curve with data and build the basis. Return 0 if OK, and -1 00123 // if error. 00124 int create(int nelems, int order = 4, int closed = 0, 00125 int appendPoints = 1); 00126 00127 // Find out if a curve segment is straight: 00128 int isSegmentCollinear(int i) const; 00129 }; 00130 00131 #endif
1.5.9