[brlcad-commits] CVS: brlcad/src/other/openNURBS opennurbs_curve.cpp, 1.4, 1.5
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: jason o. <jl...@us...> - 2007-06-28 20:50:53
|
Update of /cvsroot/brlcad/brlcad/src/other/openNURBS In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8095/src/other/openNURBS Modified Files: opennurbs_curve.cpp Log Message: begin implementing generic CloseTo algorithm: step 1 is to sample the curve and collect closest points to the ray Index: opennurbs_curve.cpp =================================================================== RCS file: /cvsroot/brlcad/brlcad/src/other/openNURBS/opennurbs_curve.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -w -u -r1.4 -r1.5 --- opennurbs_curve.cpp 28 Jun 2007 17:15:17 -0000 1.4 +++ opennurbs_curve.cpp 28 Jun 2007 20:50:54 -0000 1.5 @@ -3154,10 +3154,51 @@ assert(false); } +#include <list> + +class Sample { +public: + ON_Curve* c; + ON_3dPoint pt; + ON_3dVector tangent; + double t; + double dist; + + Sample(ON_Curve* curve, double param) : c(curve), t(param), dist(0.0) { + c->Ev1Der(t, pt, tangent); + } + Sample(const Sample& s) : + c(s.c), pt(s.pt), tangent(s.tangent), t(s.t) {} + Sample& operator=(const Sample& s) { + c = s.c; + pt = s.pt; + tangent = s.tangent; + t = s.t; + } + + bool operator<(const Sample& s) { + return (ON_NearZero(dist-s.dist,ON_ZERO_TOLERANCE)) ? t < s.t : dist < s.dist; + } +}; + +bool +isFlat(const Sample& p1, const Sample& m, const Sample& p2, double chord_tol, double der_tol) +{ + ON_Line line = ON_Line(p1.pt, p2.pt); + double chord = line.DistanceTo(m.pt); + double der = (p1.tangent * m.tangent) * (m.tangent * p2.tangent); + return (der >= der_tol) && (chord <= chord_tol); +} + +void sample(ON_Curve* c, std::list<Sample>& out_samples) { + +} + bool ON_Curve::CloseTo(const ON_Ray& ray, double epsilon, double& curve_t, double& ray_t) const { - // XXX - finish + + return false; } |