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