Revision: 57275
http://sourceforge.net/p/brlcad/code/57275
Author: indianlarry
Date: 2013-08-29 19:57:11 +0000 (Thu, 29 Aug 2013)
Log Message:
-----------
just added some debugging code ; currently just hanging up on surface with a
singularity so should be pretty easy to work through
Modified Paths:
--------------
brlcad/branches/nurbs/src/librt/primitives/brep/brep.cpp
Modified: brlcad/branches/nurbs/src/librt/primitives/brep/brep.cpp
===================================================================
--- brlcad/branches/nurbs/src/librt/primitives/brep/brep.cpp 2013-08-29
19:53:21 UTC (rev 57274)
+++ brlcad/branches/nurbs/src/librt/primitives/brep/brep.cpp 2013-08-29
19:57:11 UTC (rev 57275)
@@ -2999,8 +2999,8 @@
ON_Interval u_interval(uspan[u_span_index-1],uspan[u_span_index]);
ON_Interval v_interval(vspan[v_span_index-1],vspan[v_span_index]);
+#if 1
-
double distance =
surface_GetClosestPoint3dFirstOrderByRange(surf,p,u_interval,v_interval,working_p2d,working_p3d,tol);
if (distance < current_distance) {
@@ -3009,7 +3009,7 @@
p2d = working_p2d;
}
-#if 0
+#else
double udot_1 =
normal[u_span_index-1][v_span_index-1]*normal[u_span_index][v_span_index-1];
double udot_2 =
normal[u_span_index-1][v_span_index]*normal[u_span_index][v_span_index];
double vdot_1 =
normal[u_span_index-1][v_span_index-1]*normal[u_span_index-1][v_span_index];
@@ -3533,471 +3533,6 @@
p2d0.x =
(p2d0.x < u_interval.m_t[i]) ?
u_interval.m_t[i] :
- bool notdone = true;
- bool testing = false;
-
- if (testing) {
-
surface_GetClosestPoint3dFirstOrderByRange(surf,p,u_interval,v_interval,p2d0,p0,tol);
- }
-
- p2d0.x = (uspan[u_span_index -
1] + uspan[u_span_index])
- / 2.0;
- p2d0.y = (vspan[v_span_index -
1] + vspan[v_span_index])
- / 2.0;
- double previous_distance =
DBL_MAX;
- double distance;
- ON_3dPoint working_p3d;
- ON_3dPoint working_p2d;
- int errcnt=0;
- /* need to subdivide while normals flip
- double u0,u1,v0,v1;
- u0 = uspan[u_span_index - 1]
- while (notdone) {
- ON_3dVector subnormal;
- double stepu =
(uspan[u_span_index] - uspan[u_span_index - 1]) / (surf->Degree(0)+1);
- double stepv =
(vspan[v_span_index] - vspan[v_span_index - 1]) / (surf->Degree(1)+1);
- for(int iu = 0; iu <
surf->Degree(0)+1; iu++) {
- double u =
uspan[u_span_index - 1] + iu * stepu;
- for(int iv=0; iv <
surf->Degree(1)+1; iv++) {
- double v =
vspan[v_span_index - 1] + iv * stepv;
- if (surf->Ev2Der(u,
v, p0, ds,
-
dt, dss, dst, dtt)) {
- subnormal =
ON_CrossProduct(ds,dt);
-
subnormal.Unitize();
- }
- }
- }
- }
- */
- while (notdone
- &&
(surf->Ev2Der(p2d0.x, p2d0.y, p0, ds,
- dt, dss, dst,
dtt))
- ) {
- if ((distance =
p0.DistanceTo(p)) >= previous_distance) {
- if (++errcnt <= 10) {
- p2d0 = (p2d0 +
working_p2d)/2.0;
- continue;
- } else {
- break;
- }
- /* if (++errcnt > 10)
break; */
- } else {
- previous_distance =
distance;
- working_p3d = p0;
- working_p2d = p2d0;
- errcnt=0;
- }
- ON_EvCurvature(ds, dt, T,
K);
- ON_3dVector N =
ON_CrossProduct(ds, dt);
- N.Unitize();
- ON_Plane plane(p0, N);
- ON_3dPoint q =
plane.ClosestPointTo(p);
- ON_2dVector pullback;
- ON_3dVector vector = q - p0;
- double vlength =
vector.Length();
-
- if (vlength > 0.0) {
- rc = true;
-
- if
(ON_Pullback3dVector(vector, 0.0, ds, dt, dss, dst,
- dtt, pullback))
{
- p2d0 = p2d0 +
pullback;
- if
(!u_interval.Includes(p2d0.x, false)) {
- int i =
-
(u_interval.m_t[0] <= u_interval.m_t[1]) ?
-
0 : 1;
- p2d0.x =
- (p2d0.x
< u_interval.m_t[i]) ?
-
u_interval.m_t[i] :
-
u_interval.m_t[1 - i];
- }
- if
(!v_interval.Includes(p2d0.y, false)) {
- int i =
-
(v_interval.m_t[0] <= v_interval.m_t[1]) ?
-
0 : 1;
- p2d0.y =
- (p2d0.y
< v_interval.m_t[i]) ?
-
v_interval.m_t[i] :
-
v_interval.m_t[1 - i];
- }
- /*
- if (distance <
tol) {
- notdone = false;
- break;
- }
- */
- } else {
- notdone = false;
- rc = false;
- break;
- }
- } else {
- // can't get any closer
- rc = true;
- notdone = false;
- break;
- }
- }
- if (previous_distance <
current_distance) {
- current_distance =
previous_distance;
- p3d = working_p3d;
- p2d = working_p2d;
- }
- tol = 1.e-12;
- if (current_distance > tol) {
- ON_2dPoint p2d_pass1 = p2d;
- double step =
sqrt(current_distance/sqrt(2.0));
- //for now do slow four
corner
- for(int ui = 0; ui < 2 &&
current_distance > tol; ui++) {
- /*
- p2d0.x = (p2d_pass1.x +
uspan[u_span_index - 1 + ui])/2.0;
- if (ui == 0) {
- p2d0.x =
p2d_pass1.x - (uspan[u_span_index] - uspan[u_span_index - 1])*0.01;
- } else {
- p2d0.x =
p2d_pass1.x + (uspan[u_span_index] - uspan[u_span_index - 1])*0.01;
- }
- p2d0.x = (p2d_pass1.x +
uspan[u_span_index - 1 + ui])/2.0;
- */
- for(int vi = 0; vi < 2
&& current_distance > tol; vi++) {
- bool notdone = true;
- /*
- if (vi == 0) {
- p2d0.y =
p2d_pass1.y - (vspan[v_span_index] - vspan[v_span_index - 1])*0.01;
- } else {
- p2d0.y =
p2d_pass1.y + (vspan[v_span_index] - vspan[v_span_index - 1])*0.01;
- }
- p2d0.x =
(p2d_pass1.x + uspan[u_span_index - 1 + ui])/2.0;
- p2d0.y =
(p2d_pass1.y + vspan[v_span_index - 1 + vi])/2.0;
- if (ui == 0) {
- p2d0.x =
p2d_pass1.x - (uspan[u_span_index] - uspan[u_span_index - 1])*0.01;
- } else {
- p2d0.x =
p2d_pass1.x + (uspan[u_span_index] - uspan[u_span_index - 1])*0.01;
- }
- if (vi == 0) {
- p2d0.y =
p2d_pass1.y - (vspan[v_span_index] - vspan[v_span_index - 1])*0.01;
- } else {
- p2d0.y =
p2d_pass1.y + (vspan[v_span_index] - vspan[v_span_index - 1])*0.01;
- }
- p2d0.x =
uspan[u_span_index - 1 + ui];
- p2d0.y =
vspan[v_span_index - 1 + vi];
- */
- if (ui == 0) {
- p2d0.x =
p2d_pass1.x - step;
- } else {
- p2d0.x =
p2d_pass1.x + step;
- }
- if (vi == 0) {
- p2d0.y =
p2d_pass1.y - step;
- } else {
- p2d0.y =
p2d_pass1.y + step;
- }
- p2d0.x =
(p2d_pass1.x + uspan[u_span_index - 1 + ui])/2.0;
- p2d0.y =
(p2d_pass1.y + vspan[v_span_index - 1 + vi])/2.0;
- if
(!u_interval.Includes(p2d0.x, false)) {
- int i =
-
(u_interval.m_t[0] <= u_interval.m_t[1]) ?
-
0 : 1;
- p2d0.x =
- (p2d0.x
< u_interval.m_t[i]) ?
-
u_interval.m_t[i] :
-
u_interval.m_t[1 - i];
- }
- if
(!v_interval.Includes(p2d0.y, false)) {
- int i =
-
(v_interval.m_t[0] <= v_interval.m_t[1]) ?
-
0 : 1;
- p2d0.y =
- (p2d0.y
< v_interval.m_t[i]) ?
-
v_interval.m_t[i] :
-
v_interval.m_t[1 - i];
- }
- ON_3dPoint
working_p3d;
- ON_2dPoint
working_p2d;
- int errcnt=0;
- double
previous_distance = DBL_MAX;
- double distance;
- ON_2dVector
pullback;
-
- while (notdone
- &&
(surf->Ev2Der(p2d0.x, p2d0.y, p0, ds,
- dt,
dss, dst, dtt))) {
- if ((distance =
p0.DistanceTo(p)) >= previous_distance) {
- if
(++errcnt <= 10) {
- p2d0 =
(p2d0 + working_p2d)/2.0;
-
continue;
- } else {
- break;
- }
- //if
(++errcnt > 10) break;
- } else {
-
previous_distance = distance;
- working_p3d
= p0;
- working_p2d
= p2d0;
- errcnt=0;
- }
-
ON_EvCurvature(ds, dt, T, K);
- ON_3dVector N =
ON_CrossProduct(ds, dt);
- N.Unitize();
- ON_Plane
plane(p0, N);
- ON_3dPoint q =
plane.ClosestPointTo(p);
- //ON_2dVector
pullback;
- ON_3dVector
vector = q - p0;
- double vlength
= vector.Length();
-
- if (vlength >
0.0) {
- rc = true;
-
- if
(ON_Pullback3dVector(vector, vlength, ds, dt, dss, dst,
-
dtt, pullback)) {
- p2d0 =
p2d0 + pullback;
- if
(!u_interval.Includes(p2d0.x, false)) {
- int
i =
-
(u_interval.m_t[0] <= u_interval.m_t[1]) ?
-
0 : 1;
-
p2d0.x =
-
(p2d0.x < u_interval.m_t[i]) ?
-
u_interval.m_t[i] :
-
u_interval.m_t[1 - i];
- }
- if
(!v_interval.Includes(p2d0.y, false)) {
- int
i =
-
(v_interval.m_t[0] <= v_interval.m_t[1]) ?
-
0 : 1;
-
p2d0.y =
-
(p2d0.y < v_interval.m_t[i]) ?
-
v_interval.m_t[i] :
-
v_interval.m_t[1 - i];
- }
- } else {
- const
double ds_o_V = ds*vector;
- const
double dt_o_V = dt*vector;
- const
double ds_o_ds = ds*ds;
- const
double ds_o_dt = ds*dt;
- const
double dt_o_ds = dt*ds;
- const
double dt_o_dt = dt*dt;
-
- int
s_sign = sign(ds_o_V);
- int
t_sign = sign(dt_o_V);
- double
s_delta = 0.0;
- if
(fabs(ds_o_V) > 0.0) {
-
s_delta = vlength / ds_o_V / ds_o_ds;
- } else {
-
s_delta = 0.0;
- }
- double
t_delta = 0.0;
- if
(fabs(dt_o_V) > 0.0) {
-
t_delta = vlength / dt_o_V / dt_o_dt;
- } else {
-
t_delta = 0.0;
- }
- p2d0.x
= p2d0.x + s_delta;
- p2d0.y
= p2d0.y + t_delta;
- //
perform jittered perturbation in parametric domain....
-
//p2d0.x = p2d0.x + .1 * (drand48()-0.5) * (uspan[u_span_index] -
uspan[u_span_index - 1]);
-
//p2d0.y = p2d0.y + .1 * (drand48()-0.5) * (vspan[v_span_index] -
vspan[v_span_index - 1]);
- if
(!u_interval.Includes(p2d0.x, false)) {
- int
i =
-
(u_interval.m_t[0] <= u_interval.m_t[1]) ?
-
0 : 1;
-
p2d0.x =
-
(p2d0.x < u_interval.m_t[i]) ?
-
u_interval.m_t[i] :
-
u_interval.m_t[1 - i];
- }
- if
(!v_interval.Includes(p2d0.y, false)) {
- int
i =
-
(v_interval.m_t[0] <= v_interval.m_t[1]) ?
-
0 : 1;
-
p2d0.y =
-
(p2d0.y < v_interval.m_t[i]) ?
-
v_interval.m_t[i] :
-
v_interval.m_t[1 - i];
- }
-
- }
- } else {
- // can't
get any closer
- rc = true;
- notdone =
false;
- break;
- }
- }
- if
(previous_distance < current_distance) {
-
current_distance = previous_distance;
- p3d =
working_p3d;
- p2d =
working_p2d;
- }
- }
- }
- for(int ui = 0; ui < 2 &&
current_distance > tol; ui++) {
- p2d0.x = (p2d_pass1.x +
uspan[u_span_index - 1 + ui])/2.0;
- if (ui == 0) {
- p2d0.x =
p2d_pass1.x - (uspan[u_span_index] - uspan[u_span_index - 1])*0.01;
- } else {
- p2d0.x =
p2d_pass1.x + (uspan[u_span_index] - uspan[u_span_index - 1])*0.01;
- }
- p2d0.y = p2d_pass1.y;
- bool notdone = true;
- ON_3dPoint working_p3d;
- ON_2dPoint working_p2d;
- int errcnt=0;
- double
previous_distance = DBL_MAX;
- double distance;
- ON_2dVector pullback;
-
- while (notdone
- &&
(surf->Ev2Der(p2d0.x, p2d0.y, p0, ds,
- dt,
dss, dst, dtt))) {
- if ((distance =
p0.DistanceTo(p)) >= previous_distance) {
- if (++errcnt <=
10) {
- p2d0 =
(p2d0 + working_p2d)/2.0;
- continue;
- } else {
- break;
- }
- //if (++errcnt
> 10) break;
- } else {
-
previous_distance = distance;
- working_p3d =
p0;
- working_p2d =
p2d0;
- errcnt=0;
- }
- ON_EvCurvature(ds,
dt, T, K);
- ON_3dVector N =
ON_CrossProduct(ds, dt);
- N.Unitize();
- ON_Plane plane(p0,
N);
- ON_3dPoint q =
plane.ClosestPointTo(p);
- //ON_2dVector
pullback;
- ON_3dVector vector
= q - p0;
- double vlength =
vector.Length();
-
- if (vlength > 0.0) {
- rc = true;
-
- if
(ON_Pullback3dVector(vector, 0.0, ds, dt, dss, dst,
- dtt,
pullback)) {
- p2d0 = p2d0
+ pullback;
- if
(!u_interval.Includes(p2d0.x, false)) {
- int i =
-
(u_interval.m_t[0] <= u_interval.m_t[1]) ?
-
0 : 1;
- p2d0.x =
-
(p2d0.x < u_interval.m_t[i]) ?
-
u_interval.m_t[i] :
-
u_interval.m_t[1 - i];
- }
- if
(!v_interval.Includes(p2d0.y, false)) {
- int i =
-
(v_interval.m_t[0] <= v_interval.m_t[1]) ?
-
0 : 1;
- p2d0.y =
-
(p2d0.y < v_interval.m_t[i]) ?
-
v_interval.m_t[i] :
-
v_interval.m_t[1 - i];
- }
- } else {
- notdone =
false;
- rc = false;
- break;
- }
- } else {
- // can't get
any closer
- rc = true;
- notdone = false;
- break;
- }
- }
- if (previous_distance <
current_distance) {
- current_distance =
previous_distance;
- p3d = working_p3d;
- p2d = working_p2d;
- }
- }
- for(int vi = 0; vi < 2 &&
current_distance > tol; vi++) {
- bool notdone = true;
- p2d0.x = p2d_pass1.x;
- if (vi == 0) {
- p2d0.y =
p2d_pass1.y - (vspan[v_span_index] - vspan[v_span_index - 1])*0.01;
- } else {
- p2d0.y =
p2d_pass1.y + (vspan[v_span_index] - vspan[v_span_index - 1])*0.01;
- }
- ON_3dPoint working_p3d;
- ON_2dPoint working_p2d;
- int errcnt=0;
- double
previous_distance = DBL_MAX;
- double distance;
- ON_2dVector pullback;
-
- while (notdone
- &&
(surf->Ev2Der(p2d0.x, p2d0.y, p0, ds,
- dt,
dss, dst, dtt))) {
- if ((distance =
p0.DistanceTo(p)) >= previous_distance) {
- if (++errcnt <=
10) {
- p2d0 =
(p2d0 + working_p2d)/2.0;
- continue;
- } else {
- break;
- }
- //if (++errcnt
> 10) break;
- } else {
-
previous_distance = distance;
- working_p3d =
p0;
- working_p2d =
p2d0;
- errcnt=0;
- }
- ON_EvCurvature(ds,
dt, T, K);
- ON_3dVector N =
ON_CrossProduct(ds, dt);
- N.Unitize();
- ON_Plane plane(p0,
N);
- ON_3dPoint q =
plane.ClosestPointTo(p);
- //ON_2dVector
pullback;
- ON_3dVector vector
= q - p0;
- double vlength =
vector.Length();
-
- if (vlength > 0.0) {
- rc = true;
-
- if
(ON_Pullback3dVector(vector, 0.0, ds, dt, dss, dst,
- dtt,
pullback)) {
- p2d0 = p2d0
+ pullback;
- if
(!u_interval.Includes(p2d0.x, false)) {
- int i =
-
(u_interval.m_t[0] <= u_interval.m_t[1]) ?
-
0 : 1;
- p2d0.x =
-
(p2d0.x < u_interval.m_t[i]) ?
-
u_interval.m_t[i] :
-
u_interval.m_t[1 - i];
- }
- if
(!v_interval.Includes(p2d0.y, false)) {
- int i =
-
(v_interval.m_t[0] <= v_interval.m_t[1]) ?
-
0 : 1;
- p2d0.y =
-
(p2d0.y < v_interval.m_t[i]) ?
-
v_interval.m_t[i] :
-
v_interval.m_t[1 - i];
- }
- } else {
- notdone =
false;
- rc = false;
- break;
- }
- } else {
- // can't get
any closer
- rc = true;
- notdone = false;
- break;
- }
- }
- if (previous_distance <
current_distance) {
- current_distance =
previous_distance;
- p3d = working_p3d;
- p2d = working_p2d;
- }
- }
- }
-
u_interval.m_t[1 - i];
}
if (!v_interval.Includes(p2d0.y, false)) {
@@ -4227,7 +3762,8 @@
return rc;
}
-
+static int lfi = -1;
+static int hfi = 99999;
void poly2tri_CDT(struct bu_list *vhead, ON_BrepFace &face,
const struct rt_tess_tol *ttol, const struct bn_tol *tol,
const struct rt_view_info *info, bool watertight = false, int plottype =
@@ -4243,6 +3779,8 @@
p2t::CDT* cdt = NULL;
ON_BoundingBox loop_bb;
+ if ((fi > hfi) || (fi < lfi))
+ return;
if (s->GetSurfaceSize(&surface_width, &surface_height)) {
if ((surface_width < tol->dist) || (surface_height < tol->dist)) {
return;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits
