00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef NURBSCURVEEVALUATOR_H
00016 #define NURBSCURVEEVALUATOR_H
00017
00018 #include "pandabase.h"
00019 #include "nurbsBasisVector.h"
00020 #include "nurbsCurveResult.h"
00021 #include "nurbsVertex.h"
00022 #include "pointerTo.h"
00023 #include "vector_stdfloat.h"
00024 #include "pvector.h"
00025 #include "nodePath.h"
00026 #include "referenceCount.h"
00027 #include "luse.h"
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 class EXPCL_PANDA_PARAMETRICS NurbsCurveEvaluator : public ReferenceCount {
00044 PUBLISHED:
00045 NurbsCurveEvaluator();
00046 ~NurbsCurveEvaluator();
00047
00048 INLINE void set_order(int order);
00049 INLINE int get_order() const;
00050
00051 void reset(int num_vertices);
00052
00053 INLINE int get_num_vertices() const;
00054 INLINE void set_vertex(int i, const LVecBase4 &vertex);
00055 INLINE void set_vertex(int i, const LVecBase3 &vertex, PN_stdfloat weight = 1.0);
00056 INLINE const LVecBase4 &get_vertex(int i) const;
00057 INLINE LVecBase4 get_vertex(int i, const NodePath &rel_to) const;
00058 MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
00059
00060 INLINE void set_vertex_space(int i, const NodePath &space);
00061 INLINE void set_vertex_space(int i, const string &space);
00062 NodePath get_vertex_space(int i, const NodePath &rel_to) const;
00063
00064 INLINE void set_extended_vertex(int i, int d, PN_stdfloat value);
00065 INLINE PN_stdfloat get_extended_vertex(int i, int d) const;
00066 void set_extended_vertices(int i, int d,
00067 const PN_stdfloat values[], int num_values);
00068
00069 INLINE int get_num_knots() const;
00070 void set_knot(int i, PN_stdfloat knot);
00071 PN_stdfloat get_knot(int i) const;
00072 MAKE_SEQ(get_knots, get_num_knots, get_knot);
00073 void normalize_knots();
00074
00075 INLINE int get_num_segments() const;
00076
00077 PT(NurbsCurveResult) evaluate(const NodePath &rel_to = NodePath()) const;
00078 PT(NurbsCurveResult) evaluate(const NodePath &rel_to,
00079 const LMatrix4 &mat) const;
00080
00081 void output(ostream &out) const;
00082
00083 public:
00084 typedef epvector<LVecBase4> Vert4Array;
00085 typedef pvector<LPoint3> Vert3Array;
00086 void get_vertices(Vert4Array &verts, const NodePath &rel_to) const;
00087 void get_vertices(Vert3Array &verts, const NodePath &rel_to) const;
00088
00089 private:
00090 void recompute_knots();
00091 void recompute_basis();
00092
00093 int _order;
00094
00095 typedef epvector<NurbsVertex> Vertices;
00096 Vertices _vertices;
00097
00098 bool _knots_dirty;
00099 typedef vector_stdfloat Knots;
00100 Knots _knots;
00101
00102 bool _basis_dirty;
00103 NurbsBasisVector _basis;
00104 };
00105
00106 INLINE ostream &operator << (ostream &out, const NurbsCurveEvaluator &n);
00107
00108 #include "nurbsCurveEvaluator.I"
00109
00110 #endif
00111