/********************************************************************** *< FILE: spline3d.cpp DESCRIPTION: General-purpose 3D spline class CREATED BY: Tom Hudson & Dan Silva HISTORY: created 2/23/95 4/16/97 TH: Converted to use relative values for bezier vectors *> Copyright (c) 1995, All Rights Reserved. **********************************************************************/ #ifndef __SPLINE3D_H__ #define __SPLINE3D_H__ #include "polyshp.h" // Need this for PolyLine class // Parameter types for shape interpolation (Must match types in object.h) #define PARAM_SIMPLE 0 // Parameter space based on segments #define PARAM_NORMALIZED 1 // Parameter space normalized to curve length // Point flags for PolyShape representation #define BEZ_SHAPE_KNOT (1<<0) // It's a knot point #define BEZ_SHAPE_INTERPOLATED (1<<1) // It's an interpolated point between two knots // Line types: #define LTYPE_CURVE 0 #define LTYPE_LINE 1 // Compound line types #define CURVE_CURVE (LTYPE_CURVE | (LTYPE_CURVE<<2)) #define LINE_CURVE (LTYPE_LINE | (LTYPE_CURVE<<2)) #define CURVE_LINE (LTYPE_CURVE | (LTYPE_LINE<<2)) #define LINE_LINE (LTYPE_LINE | (LTYPE_LINE<<2)) // Knot types #define KTYPE_AUTO 0 #define KTYPE_CORNER 1 #define KTYPE_BEZIER 2 #define KTYPE_BEZIER_CORNER (KTYPE_BEZIER | KTYPE_CORNER) #define KTYPE_RESET 4 // Parameter types #define PARM_UNIFORM 0 #define PARM_ARCLENGTH 1 #define PARM_CENTRIPETAL 2 #define PARM_CUSTOM 3 // The drawPhase values #define DRAW_IDLE 0 #define DRAW_INITIAL_MOUSE_DOWN 1 #define DRAW_FREEMOVE_POINT 2 #define DRAW_FREEMOVE_POINT_MOUSE_DOWN 3 // Inserting's initial click inside spline #define DRAW_INITIAL_BEZ_ADJ 11 #define DRAW_DRAGGING_VECTOR 22 // Parameter types for shape interpolation (Must match interpolation types in object.h) #define SPLINE_INTERP_SIMPLE 0 // Parameter space based on segments #define SPLINE_INTERP_NORMALIZED 1 // Parameter space normalized to curve length class Spline3D; class SplineKnotAssy; class SplineKnot; // // 'aux' fields in spline are available in 3 channels: // 0: Used in capping process // 1: Used to track topology changes in spline editing // 2: Available to user // // This class has the vertex-level point information for the Spline3D class class SplinePoint { friend class Spline3D; friend class SplineKnotAssy; friend class SplineKnot; private: Point3 point; int aux[3]; public: CoreExport SplinePoint(); CoreExport SplinePoint(Point3 &p, int a1 = -1, int a2 = -1, int a3 = -1); CoreExport SplinePoint& operator=(SplinePoint &fromSP); inline Point3& GetPoint() { return point; } inline int GetAux(int index) { return aux[index]; } inline void SetPoint(const Point3 &p) { point = p; } inline void SetAux(int index, int a) { aux[index] = a; } }; // The mat ID is stored in the HIWORD of the knot flags #define SPLINE_MATID_SHIFT 16 #define SPLINE_MATID_MASK 0xFFFF //watje #define SEGMENT_VISIBLE (1<<0) #define SPLINEKNOT_NO_SNAP (1<<1) // Suppresses snapping to knot if set #define SPLINEKNOT_ADD_SEL (1<<2) // CAL-05/23/03: additional selection for transformation // This class is used for the internal storage of spline knot assemblies // in the Spline3D class class SplineKnotAssy { friend class Spline3D; friend class SplineKnot; private: int ktype; // Knot type int ltype; // Line type float du; // Parameter value SplinePoint inVec; // The in vector SplinePoint knot; // The knot SplinePoint outVec; // The out vector DWORD flags; public: CoreExport SplineKnotAssy(); CoreExport SplineKnotAssy(int k, int l, Point3 p, Point3 in, Point3 out, int a1= -1, int a2= -1, int a3= -1, int Ia1= -1, int Ia2= -1, int Ia3= -1, int Oa1= -1, int Oa2= -1, int Oa3= -1, DWORD f=0); CoreExport SplineKnotAssy(int k, int l, SplinePoint p, SplinePoint in, SplinePoint out, DWORD f=0); CoreExport SplineKnotAssy(SplineKnot &k); inline int Ktype() { return ktype; } inline void SetKtype(int t) { ktype=t; } inline int Ltype() { return ltype; } inline void SetLtype(int t) { ltype=t; } inline Point3 Knot() { return knot.point; } inline void SetKnot(const Point3 &p) { knot.point=p; } inline Point3 InVec() { return inVec.point; } inline void SetInVec(const Point3 &p) { inVec.point=p; } inline Point3 OutVec() { return outVec.point; } inline void SetOutVec(const Point3 &p) { outVec.point=p; } inline float GetParm() { return du; } inline void SetParm(float p) { du = p; } inline MtlID GetMatID() {return (int)((flags>>SPLINE_MATID_SHIFT)&SPLINE_MATID_MASK);} inline void SetMatID(MtlID id) {flags &= 0xFFFF; flags |= (DWORD)(id<>SPLINE_MATID_SHIFT)&SPLINE_MATID_MASK);} inline void SetMatID(MtlID id) {flags &= 0xFFFF; flags |= (DWORD)(id<