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