Panda3D
Loading...
Searching...
No Matches
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 */
39class EXPCL_PANDA_PARAMETRICS NurbsCurveEvaluator : public ReferenceCount {
40PUBLISHED:
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
79public:
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
85private:
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
102INLINE std::ostream &operator << (std::ostream &out, const NurbsCurveEvaluator &n);
103
104#include "nurbsCurveEvaluator.I"
105
106#endif
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
This encapsulates a series of matrices that are used to represent the sequential segments of a NurbsC...
This class is an abstraction for evaluating NURBS curves.
void reset(int num_vertices)
Resets all the vertices and knots to their default values, and sets the curve up with the indicated n...
get_num_vertices
Returns the number of control vertices in the curve.
void normalize_knots()
Normalizes the knot sequence so that the parametric range of the curve is 0
NodePath get_vertex_space(int i, const NodePath &rel_to) const
Returns the coordinate space of the nth control vertex of the curve, expressed as a NodePath.
void set_vertex(int i, const LVecBase4 &vertex)
Sets the nth control vertex of the curve, as a vertex in 4-d homogeneous space.
void set_order(int order)
Sets the order of the curve.
void set_extended_vertex(int i, int d, PN_stdfloat value)
Sets an n-dimensional vertex value.
get_vertex
Returns the nth control vertex of the curve, relative to its indicated coordinate space.
int get_order() const
Returns the order of the curve as set by a previous call to set_order().
void set_extended_vertices(int i, int d, const PN_stdfloat values[], int num_values)
Simultaneously sets several extended values in the slots d through (d + num_values - 1) from the num_...
int get_num_segments() const
Returns the number of piecewise continuous segments in the curve.
PN_stdfloat get_extended_vertex(int i, int d) const
Returns an n-dimensional vertex value.
get_num_knots
Returns the number of knot values in the curve.
void set_vertex_space(int i, const NodePath &space)
Sets the coordinate space of the nth control vertex.
get_knot
Returns the value of the nth knot.
void set_knot(int i, PN_stdfloat knot)
Sets the value of the nth knot.
The result of a NurbsCurveEvaluator.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.