Panda3D
nurbsCurveResult.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 nurbsCurveResult.h
10  * @author drose
11  * @date 2002-12-03
12  */
13 
14 #ifndef NURBSCURVERESULT_H
15 #define NURBSCURVERESULT_H
16 
17 #include "pandabase.h"
18 #include "referenceCount.h"
19 #include "nurbsBasisVector.h"
20 #include "vector_stdfloat.h"
21 #include "epvector.h"
22 
23 class NurbsVertex;
24 
25 /**
26  * The result of a NurbsCurveEvaluator. This object represents a curve in a
27  * particular coordinate space. It can return the point and/or tangent to the
28  * curve at any point.
29  *
30  * This is not related to NurbsCurve, CubicCurveseg or any of the
31  * ParametricCurve-derived objects in this module. It is a completely
32  * parallel implementation of NURBS curves, and will probably eventually
33  * replace the whole ParametricCurve class hierarchy.
34  */
35 class EXPCL_PANDA_PARAMETRICS NurbsCurveResult : public ReferenceCount {
36 public:
38  const LVecBase4 vecs[], const NurbsVertex *verts,
39  int num_vertices);
40 
41 PUBLISHED:
42  INLINE ~NurbsCurveResult();
43 
44  INLINE PN_stdfloat get_start_t() const;
45  INLINE PN_stdfloat get_end_t() const;
46 
47  INLINE bool eval_point(PN_stdfloat t, LVecBase3 &point);
48  INLINE bool eval_tangent(PN_stdfloat t, LVecBase3 &tangent);
49  INLINE PN_stdfloat eval_extended_point(PN_stdfloat t, int d);
50  INLINE bool eval_extended_points(PN_stdfloat t, int d,
51  PN_stdfloat result[], int num_values);
52 
53  INLINE int get_num_segments() const;
54  void eval_segment_point(int segment, PN_stdfloat t, LVecBase3 &point) const;
55  void eval_segment_tangent(int segment, PN_stdfloat t, LVecBase3 &tangent) const;
56  PN_stdfloat eval_segment_extended_point(int segment, PN_stdfloat t, int d) const;
57  void eval_segment_extended_points(int segment, PN_stdfloat t, int d,
58  PN_stdfloat result[], int num_values) const;
59  INLINE PN_stdfloat get_segment_t(int segment, PN_stdfloat t) const;
60 
61  void adaptive_sample(PN_stdfloat tolerance);
62  INLINE int get_num_samples() const;
63  INLINE PN_stdfloat get_sample_t(int n) const;
64  INLINE const LPoint3 &get_sample_point(int n) const;
65  MAKE_SEQ(get_sample_ts, get_num_samples, get_sample_t);
66  MAKE_SEQ(get_sample_points, get_num_samples, get_sample_point);
67 
68 private:
69  int find_segment(PN_stdfloat t);
70  int r_find_segment(PN_stdfloat t, int top, int bot) const;
71 
72  void r_adaptive_sample(int segment, PN_stdfloat t0, const LPoint3 &p0,
73  PN_stdfloat t1, const LPoint3 &p1, PN_stdfloat tolerance_2);
74  static PN_stdfloat sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin,
75  const LVector3 &vec);
76 
77  NurbsBasisVector _basis;
78  const NurbsVertex *_verts;
79 
80  // We pre-compose the basis matrix and the geometry vectors, so we have
81  // these handy for evaluation. There is one entry in the _composed for each
82  // entry in basis._segments.
83  typedef epvector<LMatrix4> ComposedGeom;
84  ComposedGeom _composed;
85 
86  int _last_segment;
87  PN_stdfloat _last_from;
88  PN_stdfloat _last_to;
89 
90  class AdaptiveSample {
91  public:
92  INLINE AdaptiveSample(PN_stdfloat t, const LPoint3 &point);
93  PN_stdfloat _t;
94  LPoint3 _point;
95  };
96  typedef pvector<AdaptiveSample> AdaptiveResult;
97  AdaptiveResult _adaptive_result;
98 };
99 
100 #include "nurbsCurveResult.I"
101 
102 #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.
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.
A base class for all things that want to be reference-counted.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The result of a NurbsCurveEvaluator.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.