00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef NURBSCURVERESULT_H
00016 #define NURBSCURVERESULT_H
00017
00018 #include "pandabase.h"
00019 #include "referenceCount.h"
00020 #include "nurbsBasisVector.h"
00021 #include "vector_stdfloat.h"
00022
00023 class NurbsVertex;
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class EXPCL_PANDA_PARAMETRICS NurbsCurveResult : public ReferenceCount {
00039 public:
00040 NurbsCurveResult(const NurbsBasisVector &basis,
00041 const LVecBase4 vecs[], const NurbsVertex *verts,
00042 int num_vertices);
00043
00044 PUBLISHED:
00045 INLINE ~NurbsCurveResult();
00046
00047 INLINE PN_stdfloat get_start_t() const;
00048 INLINE PN_stdfloat get_end_t() const;
00049
00050 INLINE bool eval_point(PN_stdfloat t, LVecBase3 &point);
00051 INLINE bool eval_tangent(PN_stdfloat t, LVecBase3 &tangent);
00052 INLINE PN_stdfloat eval_extended_point(PN_stdfloat t, int d);
00053 INLINE bool eval_extended_points(PN_stdfloat t, int d,
00054 PN_stdfloat result[], int num_values);
00055
00056 INLINE int get_num_segments() const;
00057 void eval_segment_point(int segment, PN_stdfloat t, LVecBase3 &point) const;
00058 void eval_segment_tangent(int segment, PN_stdfloat t, LVecBase3 &tangent) const;
00059 PN_stdfloat eval_segment_extended_point(int segment, PN_stdfloat t, int d) const;
00060 void eval_segment_extended_points(int segment, PN_stdfloat t, int d,
00061 PN_stdfloat result[], int num_values) const;
00062 INLINE PN_stdfloat get_segment_t(int segment, PN_stdfloat t) const;
00063
00064 void adaptive_sample(PN_stdfloat tolerance);
00065 INLINE int get_num_samples() const;
00066 INLINE PN_stdfloat get_sample_t(int n) const;
00067 INLINE const LPoint3 &get_sample_point(int n) const;
00068 MAKE_SEQ(get_sample_ts, get_num_samples, get_sample_t);
00069 MAKE_SEQ(get_sample_points, get_num_samples, get_sample_points);
00070
00071 private:
00072 int find_segment(PN_stdfloat t);
00073 int r_find_segment(PN_stdfloat t, int top, int bot) const;
00074
00075 void r_adaptive_sample(int segment, PN_stdfloat t0, const LPoint3 &p0,
00076 PN_stdfloat t1, const LPoint3 &p1, PN_stdfloat tolerance_2);
00077 static PN_stdfloat sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin,
00078 const LVector3 &vec);
00079
00080 NurbsBasisVector _basis;
00081 const NurbsVertex *_verts;
00082
00083
00084
00085
00086 typedef epvector<LMatrix4> ComposedGeom;
00087 ComposedGeom _composed;
00088
00089 int _last_segment;
00090 PN_stdfloat _last_from;
00091 PN_stdfloat _last_to;
00092
00093 class AdaptiveSample {
00094 public:
00095 INLINE AdaptiveSample(PN_stdfloat t, const LPoint3 &point);
00096 PN_stdfloat _t;
00097 LPoint3 _point;
00098 };
00099 typedef pvector<AdaptiveSample> AdaptiveResult;
00100 AdaptiveResult _adaptive_result;
00101 };
00102
00103 #include "nurbsCurveResult.I"
00104
00105 #endif
00106