Panda3D

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