Panda3D
nurbsSurfaceEvaluator.h
1 // Filename: nurbsSurfaceEvaluator.h
2 // Created by: drose (10Oct03)
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 NURBSSURFACEEVALUATOR_H
16 #define NURBSSURFACEEVALUATOR_H
17 
18 #include "pandabase.h"
19 #include "nurbsBasisVector.h"
20 #include "nurbsSurfaceResult.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 : NurbsSurfaceEvaluator
32 // Description : This class is an abstraction for evaluating NURBS
33 // surfaces. 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 class EXPCL_PANDA_PARAMETRICS NurbsSurfaceEvaluator : public ReferenceCount {
39 PUBLISHED:
42 
43  INLINE void set_u_order(int u_order);
44  INLINE int get_u_order() const;
45 
46  INLINE void set_v_order(int v_order);
47  INLINE int get_v_order() const;
48 
49  void reset(int num_u_vertices, int num_v_vertices);
50 
51  INLINE int get_num_u_vertices() const;
52  INLINE int get_num_v_vertices() const;
53  INLINE void set_vertex(int ui, int vi, const LVecBase4 &vertex);
54  INLINE void set_vertex(int ui, int vi, const LVecBase3 &vertex, PN_stdfloat weight = 1.0);
55  INLINE const LVecBase4 &get_vertex(int ui, int vi) const;
56  INLINE LVecBase4 get_vertex(int ui, int vi, const NodePath &rel_to) const;
57 
58  INLINE void set_vertex_space(int ui, int vi, const NodePath &space);
59  INLINE void set_vertex_space(int ui, int vi, const string &space);
60  NodePath get_vertex_space(int ui, int vi, const NodePath &rel_to) const;
61 
62  INLINE void set_extended_vertex(int ui, int vi, int d, PN_stdfloat value);
63  INLINE PN_stdfloat get_extended_vertex(int ui, int vi, int d) const;
64  void set_extended_vertices(int ui, int vi, int d,
65  const PN_stdfloat values[], int num_values);
66 
67  INLINE int get_num_u_knots() const;
68  void set_u_knot(int i, PN_stdfloat knot);
69  PN_stdfloat get_u_knot(int i) const;
70  MAKE_SEQ(get_u_knots, get_num_u_knots, get_u_knot);
71  void normalize_u_knots();
72 
73  INLINE int get_num_v_knots() const;
74  void set_v_knot(int i, PN_stdfloat knot);
75  PN_stdfloat get_v_knot(int i) const;
76  MAKE_SEQ(get_v_knots, get_num_v_knots, get_v_knot);
77  void normalize_v_knots();
78 
79  INLINE int get_num_u_segments() const;
80  INLINE int get_num_v_segments() const;
81 
82  PT(NurbsSurfaceResult) evaluate(const NodePath &rel_to = NodePath()) const;
83 
84  void output(ostream &out) const;
85 
86 public:
87  typedef epvector<LVecBase4> Vert4Array;
89  void get_vertices(Vert4Array &verts, const NodePath &rel_to) const;
90  void get_vertices(Vert3Array &verts, const NodePath &rel_to) const;
91 
92 private:
93  INLINE NurbsVertex &vert(int ui, int vi);
94  INLINE const NurbsVertex &vert(int ui, int vi) const;
95 
96  void recompute_u_knots();
97  void recompute_v_knots();
98  void recompute_u_basis();
99  void recompute_v_basis();
100 
101  int _u_order;
102  int _v_order;
103 
104  typedef epvector<NurbsVertex> Vertices;
105  Vertices _vertices;
106  int _num_u_vertices;
107  int _num_v_vertices;
108 
109  bool _u_knots_dirty;
110  bool _v_knots_dirty;
111  typedef vector_stdfloat Knots;
112  Knots _u_knots;
113  Knots _v_knots;
114 
115  bool _u_basis_dirty;
116  bool _v_basis_dirty;
117  NurbsBasisVector _u_basis;
118  NurbsBasisVector _v_basis;
119 };
120 
121 INLINE ostream &operator << (ostream &out, const NurbsSurfaceEvaluator &n);
122 
123 #include "nurbsSurfaceEvaluator.I"
124 
125 #endif
126 
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
This class is an abstraction for evaluating NURBS surfaces.
This represents a single control vertex in a NurbsEvaluator.
Definition: nurbsVertex.h:36
This encapsulates a series of matrices that are used to represent the sequential segments of a NurbsC...
The result of a NurbsSurfaceEvaluator.
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.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165