Panda3D
 All Classes Functions Variables Enumerations
nurbsSurfaceResult.h
1 // Filename: nurbsSurfaceResult.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 NURBSSURFACERESULT_H
16 #define NURBSSURFACERESULT_H
17 
18 #include "pandabase.h"
19 #include "referenceCount.h"
20 #include "nurbsBasisVector.h"
21 #include "epvector.h"
22 
23 class NurbsVertex;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : NurbsSurfaceResult
27 // Description : The result of a NurbsSurfaceEvaluator. This object
28 // represents a surface in a particular coordinate space.
29 // It can return the point and/or normal to the surface
30 // at any point.
31 ////////////////////////////////////////////////////////////////////
32 class EXPCL_PANDA_PARAMETRICS NurbsSurfaceResult : public ReferenceCount {
33 public:
34  NurbsSurfaceResult(const NurbsBasisVector &u_basis,
35  const NurbsBasisVector &v_basis,
36  const LVecBase4 vecs[], const NurbsVertex *verts,
37  int num_u_vertices, int num_v_vertices);
38 
39 PUBLISHED:
40  INLINE ~NurbsSurfaceResult();
41 
42  INLINE PN_stdfloat get_start_u() const;
43  INLINE PN_stdfloat get_end_u() const;
44 
45  INLINE PN_stdfloat get_start_v() const;
46  INLINE PN_stdfloat get_end_v() const;
47 
48  INLINE bool eval_point(PN_stdfloat u, PN_stdfloat v, LVecBase3 &point);
49  INLINE bool eval_normal(PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal);
50  INLINE PN_stdfloat eval_extended_point(PN_stdfloat u, PN_stdfloat v, int d);
51  INLINE bool eval_extended_points(PN_stdfloat u, PN_stdfloat v, int d,
52  PN_stdfloat result[], int num_values);
53 
54  INLINE int get_num_u_segments() const;
55  INLINE int get_num_v_segments() const;
56  void eval_segment_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &point) const;
57  void eval_segment_normal(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal) const;
58  PN_stdfloat eval_segment_extended_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d) const;
59  void eval_segment_extended_points(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d,
60  PN_stdfloat result[], int num_values) const;
61  INLINE PN_stdfloat get_segment_u(int ui, PN_stdfloat u) const;
62  INLINE PN_stdfloat get_segment_v(int vi, PN_stdfloat v) const;
63 
64 private:
65  INLINE int verti(int ui, int vi) const;
66  INLINE int segi(int ui, int vi) const;
67 
68  int find_u_segment(PN_stdfloat u);
69  int r_find_u_segment(PN_stdfloat u, int top, int bot) const;
70  int find_v_segment(PN_stdfloat v);
71  int r_find_v_segment(PN_stdfloat v, int top, int bot) const;
72 
73  NurbsBasisVector _u_basis;
74  NurbsBasisVector _v_basis;
75  const NurbsVertex *_verts;
76  int _num_u_vertices;
77  int _num_v_vertices;
78 
79  // We pre-compose the basis matrix and the geometry vectors, so we
80  // have these handy for evaluation. There is one entry in the
81  // _composed for each entry in u_basis._segments *
82  // v_basis._segments.
83  class ComposedMats {
84  public:
85  LMatrix4 _x, _y, _z, _w;
86  };
87  typedef epvector<ComposedMats> ComposedGeom;
88  ComposedGeom _composed;
89 
90 
91  int _last_u_segment;
92  PN_stdfloat _last_u_from;
93  PN_stdfloat _last_u_to;
94  int _last_v_segment;
95  PN_stdfloat _last_v_from;
96  PN_stdfloat _last_v_to;
97 };
98 
99 #include "nurbsSurfaceResult.I"
100 
101 #endif
102 
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
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...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
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.