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 */
39 class 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
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
102INLINE 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
NurbsCurveEvaluator::reset
void reset(int num_vertices)
Resets all the vertices and knots to their default values, and sets the curve up with the indicated n...
Definition nurbsCurveEvaluator.cxx:39
NurbsCurveEvaluator::get_num_vertices
get_num_vertices
Returns the number of control vertices in the curve.
Definition nurbsCurveEvaluator.h:54
NurbsCurveEvaluator::normalize_knots
void normalize_knots()
Normalizes the knot sequence so that the parametric range of the curve is 0
Definition nurbsCurveEvaluator.cxx:110
NurbsCurveEvaluator::get_vertex_space
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.
Definition nurbsCurveEvaluator.cxx:55
NurbsCurveEvaluator::set_vertex
void set_vertex(int i, const LVecBase4 &vertex)
Sets the nth control vertex of the curve, as a vertex in 4-d homogeneous space.
Definition nurbsCurveEvaluator.I:52
NurbsCurveEvaluator::set_order
void set_order(int order)
Sets the order of the curve.
Definition nurbsCurveEvaluator.I:22
NurbsCurveEvaluator::set_extended_vertex
void set_extended_vertex(int i, int d, PN_stdfloat value)
Sets an n-dimensional vertex value.
Definition nurbsCurveEvaluator.I:141
NurbsCurveEvaluator::get_vertex
get_vertex
Returns the nth control vertex of the curve, relative to its indicated coordinate space.
Definition nurbsCurveEvaluator.h:54
NurbsCurveEvaluator::get_order
int get_order() const
Returns the order of the curve as set by a previous call to set_order().
Definition nurbsCurveEvaluator.I:32
NurbsCurveEvaluator::set_extended_vertices
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_...
Definition nurbsCurveEvaluator.cxx:70
NurbsCurveEvaluator::get_num_segments
int get_num_segments() const
Returns the number of piecewise continuous segments in the curve.
Definition nurbsCurveEvaluator.I:171
NurbsCurveEvaluator::get_extended_vertex
PN_stdfloat get_extended_vertex(int i, int d) const
Returns an n-dimensional vertex value.
Definition nurbsCurveEvaluator.I:152
NurbsCurveEvaluator::get_num_knots
get_num_knots
Returns the number of knot values in the curve.
Definition nurbsCurveEvaluator.h:68
NurbsCurveEvaluator::set_vertex_space
void set_vertex_space(int i, const NodePath &space)
Sets the coordinate space of the nth control vertex.
Definition nurbsCurveEvaluator.I:106
NurbsCurveEvaluator::get_knot
get_knot
Returns the value of the nth knot.
Definition nurbsCurveEvaluator.h:68
NurbsCurveEvaluator::set_knot
void set_knot(int i, PN_stdfloat knot)
Sets the value of the nth knot.
Definition nurbsCurveEvaluator.cxx:85
NurbsCurveResult
The result of a NurbsCurveEvaluator.
Definition nurbsCurveResult.h:35
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.