00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CLASSICNURBSCURVE_H
00020 #define CLASSICNURBSCURVE_H
00021
00022 #include <pandabase.h>
00023
00024 #include "piecewiseCurve.h"
00025 #include "nurbsCurveInterface.h"
00026 #include "cubicCurveseg.h"
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 class EXPCL_PANDA ClassicNurbsCurve : public PiecewiseCurve, public NurbsCurveInterface {
00052 PUBLISHED:
00053 ClassicNurbsCurve();
00054 ClassicNurbsCurve(const ParametricCurve &pc);
00055 public:
00056 ClassicNurbsCurve(int order, int num_cvs,
00057 const float knots[], const LVecBase4f cvs[]);
00058 PUBLISHED:
00059 virtual ~ClassicNurbsCurve();
00060
00061 public:
00062
00063
00064 virtual void set_order(int order);
00065 virtual int get_order() const;
00066
00067 virtual int get_num_cvs() const;
00068 virtual int get_num_knots() const;
00069
00070 virtual bool insert_cv(float t);
00071
00072 virtual bool remove_cv(int n);
00073 virtual void remove_all_cvs();
00074
00075 virtual bool set_cv(int n, const LVecBase4f &v);
00076 virtual LVecBase4f get_cv(int n) const;
00077
00078 virtual bool set_knot(int n, float t);
00079 virtual float get_knot(int n) const;
00080
00081 virtual bool recompute();
00082
00083 public:
00084 virtual bool
00085 rebuild_curveseg(int rtype0, float t0, const LVecBase4f &v0,
00086 int rtype1, float t1, const LVecBase4f &v1,
00087 int rtype2, float t2, const LVecBase4f &v2,
00088 int rtype3, float t3, const LVecBase4f &v3);
00089
00090 virtual bool stitch(const ParametricCurve *a, const ParametricCurve *b);
00091
00092 INLINE CubicCurveseg *get_curveseg(int ti);
00093
00094 virtual NurbsCurveInterface *get_nurbs_interface();
00095 virtual bool convert_to_nurbs(ParametricCurve *nc) const;
00096 virtual void write(ostream &out, int indent_level = 0) const;
00097
00098 protected:
00099 virtual int append_cv_impl(const LVecBase4f &v);
00100 virtual bool format_egg(ostream &out, const string &name,
00101 const string &curve_type, int indent_level) const;
00102
00103 int find_cv(float t);
00104
00105 int _order;
00106
00107 class CV {
00108 public:
00109 CV() {}
00110 CV(const LVecBase4f &p, float t) : _p(p), _t(t) {}
00111 LVecBase4f _p;
00112 float _t;
00113 };
00114
00115 pvector<CV> _cvs;
00116
00117
00118
00119 public:
00120 static void register_with_read_factory();
00121
00122 protected:
00123 static TypedWritable *make_ClassicNurbsCurve(const FactoryParams ¶ms);
00124 virtual void write_datagram(BamWriter *manager, Datagram &me);
00125 void fillin(DatagramIterator &scan, BamReader *manager);
00126
00127 public:
00128 static TypeHandle get_class_type() {
00129 return _type_handle;
00130 }
00131 static void init_type() {
00132 PiecewiseCurve::init_type();
00133 NurbsCurveInterface::init_type();
00134 register_type(_type_handle, "ClassicNurbsCurve",
00135 PiecewiseCurve::get_class_type(),
00136 NurbsCurveInterface::get_class_type());
00137 register_type(_orig_type_handle, "NurbsCurve",
00138 PiecewiseCurve::get_class_type(),
00139 NurbsCurveInterface::get_class_type());
00140 }
00141 virtual TypeHandle get_type() const {
00142 return get_class_type();
00143 }
00144 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00145
00146 private:
00147 static TypeHandle _type_handle;
00148 static TypeHandle _orig_type_handle;
00149 };
00150
00151 #ifndef HAVE_NURBSPP
00152 typedef ClassicNurbsCurve NurbsCurve;
00153 #endif
00154
00155 #include "classicNurbsCurve.I"
00156
00157 #endif