Panda3D
nurbsCurveEvaluator.h
1 // Filename: nurbsCurveEvaluator.h
2 // Created by: drose (03Dec02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef NURBSCURVEEVALUATOR_H
16 #define NURBSCURVEEVALUATOR_H
17 
18 #include "pandabase.h"
19 #include "nurbsBasisVector.h"
20 #include "nurbsCurveResult.h"
21 #include "nurbsVertex.h"
22 #include "pointerTo.h"
23 #include "vector_stdfloat.h"
24 #include "pvector.h"
25 #include "epvector.h"
26 #include "nodePath.h"
27 #include "referenceCount.h"
28 #include "luse.h"
29 
30 ////////////////////////////////////////////////////////////////////
31 // Class : NurbsCurveEvaluator
32 // Description : This class is an abstraction for evaluating NURBS
33 // curves. It accepts an array of vertices, each of
34 // which may be in a different coordinate space (as
35 // defined by a NodePath), as well as an optional knot
36 // vector.
37 //
38 // This is not related to NurbsCurve, CubicCurveseg or
39 // any of the ParametricCurve-derived objects in this
40 // module. It is a completely parallel implementation
41 // of NURBS curves, and will probably eventually replace
42 // the whole ParametricCurve class hierarchy.
43 ////////////////////////////////////////////////////////////////////
44 class EXPCL_PANDA_PARAMETRICS NurbsCurveEvaluator : public ReferenceCount {
45 PUBLISHED:
48 
49  INLINE void set_order(int order);
50  INLINE int get_order() const;
51 
52  void reset(int num_vertices);
53 
54  INLINE int get_num_vertices() const;
55  INLINE void set_vertex(int i, const LVecBase4 &vertex);
56  INLINE void set_vertex(int i, const LVecBase3 &vertex, PN_stdfloat weight = 1.0);
57  INLINE const LVecBase4 &get_vertex(int i) const;
58  INLINE LVecBase4 get_vertex(int i, const NodePath &rel_to) const;
59  MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
60 
61  INLINE void set_vertex_space(int i, const NodePath &space);
62  INLINE void set_vertex_space(int i, const string &space);
63  NodePath get_vertex_space(int i, const NodePath &rel_to) const;
64 
65  INLINE void set_extended_vertex(int i, int d, PN_stdfloat value);
66  INLINE PN_stdfloat get_extended_vertex(int i, int d) const;
67  void set_extended_vertices(int i, int d,
68  const PN_stdfloat values[], int num_values);
69 
70  INLINE int get_num_knots() const;
71  void set_knot(int i, PN_stdfloat knot);
72  PN_stdfloat get_knot(int i) const;
73  MAKE_SEQ(get_knots, get_num_knots, get_knot);
74  void normalize_knots();
75 
76  INLINE int get_num_segments() const;
77 
78  PT(NurbsCurveResult) evaluate(const NodePath &rel_to = NodePath()) const;
79  PT(NurbsCurveResult) evaluate(const NodePath &rel_to,
80  const LMatrix4 &mat) const;
81 
82  void output(ostream &out) const;
83 
84 public:
85  typedef epvector<LVecBase4> Vert4Array;
87  void get_vertices(Vert4Array &verts, const NodePath &rel_to) const;
88  void get_vertices(Vert3Array &verts, const NodePath &rel_to) const;
89 
90 private:
91  void recompute_knots();
92  void recompute_basis();
93 
94  int _order;
95 
96  typedef epvector<NurbsVertex> Vertices;
97  Vertices _vertices;
98 
99  bool _knots_dirty;
100  typedef vector_stdfloat Knots;
101  Knots _knots;
102 
103  bool _basis_dirty;
104  NurbsBasisVector _basis;
105 };
106 
107 INLINE ostream &operator << (ostream &out, const NurbsCurveEvaluator &n);
108 
109 #include "nurbsCurveEvaluator.I"
110 
111 #endif
112 
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
This class is an abstraction for evaluating NURBS curves.
This encapsulates a series of matrices that are used to represent the sequential segments of a NurbsC...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
A base class for all things that want to be reference-counted.
The result of a NurbsCurveEvaluator.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165