Revision: 41482
          http://brlcad.svn.sourceforge.net/brlcad/?rev=41482&view=rev
Author:   indianlarry
Date:     2010-11-30 15:25:20 +0000 (Tue, 30 Nov 2010)

Log Message:
-----------
Added BREP knot plotting routing to 'brep' command for debugging. Also modified 
some of the 'brep' command logging to build a string and return to 'mged' 
through vls string(problems with 'mged' when dumping large amounts of blather 
to stderr)

Modified Paths:
--------------
    brlcad/trunk/src/librt/primitives/brep/brep_debug.cpp

Modified: brlcad/trunk/src/librt/primitives/brep/brep_debug.cpp
===================================================================
--- brlcad/trunk/src/librt/primitives/brep/brep_debug.cpp       2010-11-30 
14:15:40 UTC (rev 41481)
+++ brlcad/trunk/src/librt/primitives/brep/brep_debug.cpp       2010-11-30 
15:25:20 UTC (rev 41482)
@@ -158,6 +158,7 @@
     VSETALL(min, 0.0);
 
     ON_TextLog tl(stderr);
+
     vhead = rt_vlblock_find(vbp, RED);
     RT_ADD_VLIST(vhead, min, BN_VLIST_LINE_MOVE);
     vhead = rt_vlblock_find(vbp, BLUE);
@@ -182,6 +183,7 @@
        }
        BB_PLOT_VLIST(min, max);
     }
+
     return;
 }
 
@@ -197,6 +199,7 @@
     VSETALL(min, 0.0);
 
     ON_TextLog tl(stderr);
+
     vhead = rt_vlblock_find(vbp, RED);
     RT_ADD_VLIST(vhead, min, BN_VLIST_LINE_MOVE);
     vhead = rt_vlblock_find(vbp, BLUE);
@@ -222,6 +225,7 @@
        }
        BB_PLOT_VLIST(min, max);
     }
+
     return;
 }
 
@@ -320,6 +324,7 @@
     ON_2dPoint from, to;
 
     ON_TextLog tl(stderr);
+
     vhead = rt_vlblock_find(vbp, YELLOW);
 
     surf->GetDomain(0, &umin, &umax);
@@ -347,6 +352,7 @@
            }
        }
     }
+
     return;
 }
 
@@ -361,6 +367,7 @@
     ON_2dPoint from, to;
 
     ON_TextLog tl(stderr);
+
     vhead = rt_vlblock_find(vbp, YELLOW);
 
     surf->GetDomain(0, &umin, &umax);
@@ -386,6 +393,7 @@
            }
        }
     }
+
     return;
 }
 
@@ -401,6 +409,7 @@
     ON_2dPoint from, to;
 
     ON_TextLog tl(stderr);
+
     vhead = rt_vlblock_find(vbp, RED);
 
     surf->GetDomain(0, &umin, &umax);
@@ -449,6 +458,7 @@
     ON_2dPoint from, to;
 
     ON_TextLog tl(stderr);
+
     vhead = rt_vlblock_find(vbp, YELLOW);
 
     surf->GetDomain(0, &umin, &umax);
@@ -475,6 +485,7 @@
 }
 
 
+
 void
 plottrimdirection(ON_BrepFace &face, struct bn_vlblock *vbp, int plotres)
 {
@@ -485,6 +496,7 @@
     ON_2dPoint from, to;
 
     ON_TextLog tl(stderr);
+
     vhead = rt_vlblock_find(vbp, GREEN);
 
     surf->GetDomain(0, &umin, &umax);
@@ -530,6 +542,7 @@
            }
        }
     }
+
     return;
 }
 
@@ -598,7 +611,41 @@
     return;
 }
 
+void
+plotsurfaceknots(ON_Surface &surf, struct bn_vlblock *vbp)
+{
+    register struct bu_list *vhead;
+    double pt1[3], pt2[3];
+    ON_2dPoint from, to;
+       int spanu_cnt = surf.SpanCount(0);
+       int spanv_cnt = surf.SpanCount(1);
+       double *spanu = NULL;
+       double *spanv = NULL;
+       spanu = new double[spanu_cnt+1];
+       spanv = new double[spanv_cnt+1];
+       surf.GetSpanVector(0,spanu);
+       surf.GetSpanVector(1,spanv);
 
+    vhead = rt_vlblock_find(vbp, YELLOW);
+
+    ON_Interval udom = surf.Domain(0);
+    ON_Interval vdom = surf.Domain(1);
+
+    for (int u = 0; u <= spanu_cnt; u++) {
+       for (int v = 0; v <= spanv_cnt; v++) {
+           ON_3dPoint p = surf.PointAt(spanu[u], spanv[v]);
+           ON_3dVector n = surf.NormalAt(spanu[u], spanv[v]);
+           n.Unitize();
+           VMOVE(pt1, p);
+           VSCALE(pt2, n, 3.0);
+           VADD2(pt2, pt1, pt2);
+           RT_ADD_VLIST(vhead, pt1, BN_VLIST_LINE_MOVE);
+           RT_ADD_VLIST(vhead, pt2, BN_VLIST_LINE_DRAW);
+       }
+    }
+    return;
+}
+
 void
 plotcurve(ON_Curve &curve, struct bn_vlblock *vbp, int plotres)
 {
@@ -867,9 +914,11 @@
 
 
 int
-brep_facetrim_plot(struct bu_vls *, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres, bool dim3d)
+brep_facetrim_plot(struct bu_vls *vls, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres, bool dim3d)
 {
-    ON_TextLog tl(stderr);
+       ON_wString wstr;
+    ON_TextLog tl(wstr);
+
     ON_Brep* brep = bs->brep;
     if (brep == NULL || !brep->IsValid(&tl)) {
        bu_log("brep is NOT valid");
@@ -892,14 +941,18 @@
            plottrim(face, vbp, plotres, dim3d);
        }
     }
+
+    bu_vls_printf(vls, ON_String(wstr).Array());
     return 0;
 }
 
 
 int
-brep_trim_direction_plot(struct bu_vls *, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres)
+brep_trim_direction_plot(struct bu_vls *vls, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres)
 {
-    ON_TextLog tl(stderr);
+       ON_wString wstr;
+    ON_TextLog tl(wstr);
+
     ON_Brep* brep = bs->brep;
     if (brep == NULL || !brep->IsValid(&tl)) {
        bu_log("brep is NOT valid");
@@ -918,14 +971,18 @@
            plottrimdirection(face, vbp, plotres);
        }
     }
+
+    bu_vls_printf(vls, ON_String(wstr).Array());
     return 0;
 }
 
 
 int
-brep_surface_plot(struct bu_vls *, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres)
+brep_surface_plot(struct bu_vls *vls, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres)
 {
-    ON_TextLog tl(stderr);
+       ON_wString wstr;
+    ON_TextLog tl(wstr);
+
     ON_Brep* brep = bs->brep;
     if (brep == NULL || !brep->IsValid(&tl)) {
        bu_log("brep is NOT valid");
@@ -942,14 +999,18 @@
        plotsurface(*surf, vbp, plotres, 10);
     }
 
+    bu_vls_printf(vls, ON_String(wstr).Array());
+
     return 0;
 }
 
 
 int
-brep_surface_normal_plot(struct bu_vls *, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int)
+brep_surface_normal_plot(struct bu_vls *vls, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres)
 {
-    ON_TextLog tl(stderr);
+       ON_wString wstr;
+    ON_TextLog tl(wstr);
+
     ON_Brep* brep = bs->brep;
     if (brep == NULL || !brep->IsValid(&tl)) {
        bu_log("brep is NOT valid");
@@ -958,22 +1019,53 @@
     if (index == -1) {
        for (index = 0; index < brep->m_S.Count(); index++) {
            ON_Surface *surf = brep->m_S[index];
-           plotsurfacenormals(*surf, vbp, 10);
+           plotsurfaceknots(*surf, vbp);
+           plotsurfacenormals(*surf, vbp, plotres);
        }
     } else if (index < brep->m_S.Count()) {
        ON_Surface *surf = brep->m_S[index];
        surf->Dump(tl);
-       plotsurfacenormals(*surf, vbp, 10);
+    plotsurfaceknots(*surf, vbp);
+       plotsurfacenormals(*surf, vbp, plotres);
     }
 
+    bu_vls_printf(vls, ON_String(wstr).Array());
     return 0;
 }
 
+int
+brep_surface_knot_plot(struct bu_vls *vls, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index)
+{
+       ON_wString wstr;
+    ON_TextLog tl(wstr);
 
+    ON_Brep* brep = bs->brep;
+    if (brep == NULL || !brep->IsValid(&tl)) {
+       bu_log("brep is NOT valid");
+       //return -1;
+    }
+    if (index == -1) {
+       for (index = 0; index < brep->m_S.Count(); index++) {
+           ON_Surface *surf = brep->m_S[index];
+           plotsurfaceknots(*surf, vbp);
+       }
+    } else if (index < brep->m_S.Count()) {
+       ON_Surface *surf = brep->m_S[index];
+       surf->Dump(tl);
+    plotsurfaceknots(*surf, vbp);
+    }
+
+    bu_vls_printf(vls, ON_String(wstr).Array());
+    return 0;
+}
+
+
 int
-brep_edge3d_plot(struct bu_vls *, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres)
+brep_edge3d_plot(struct bu_vls *vls, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres)
 {
-    ON_TextLog tl(stderr);
+       ON_wString wstr;
+    ON_TextLog tl(wstr);
+
     ON_Brep* brep = bs->brep;
     if (brep == NULL || !brep->IsValid(&tl)) {
        bu_log("brep is NOT valid");
@@ -991,14 +1083,17 @@
        plotcurve(*curve, vbp, plotres);
     }
 
+    bu_vls_printf(vls, ON_String(wstr).Array());
     return 0;
 }
 
 
 int
-brep_trim_plot(struct bu_vls *, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres, bool dim3d)
+brep_trim_plot(struct bu_vls *vls, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres, bool dim3d)
 {
-    ON_TextLog tl(stderr);
+       ON_wString wstr;
+    ON_TextLog tl(wstr);
+
     ON_Brep* brep = bs->brep;
     if (brep == NULL || !brep->IsValid(&tl)) {
        bu_log("brep is NOT valid");
@@ -1015,6 +1110,7 @@
        plottrim(trim, vbp, plotres, dim3d);
     }
 
+    bu_vls_printf(vls, ON_String(wstr).Array());
     return 0;
 }
 
@@ -1527,7 +1623,9 @@
 
 int brep_isosurface_plot(struct bu_vls *vls, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, int index, int plotres)
 {
-       ON_TextLog tl(stderr);
+       ON_wString wstr;
+    ON_TextLog tl(wstr);
+
        ON_Brep* brep = bs->brep;
        if (brep == NULL || !brep->IsValid(&tl)) {
                bu_log("brep is NOT valid");
@@ -1557,13 +1655,17 @@
                        delete st;
                }
        }
+
+    bu_vls_printf(vls, ON_String(wstr).Array());
        return 0;
 }
 
 int
 brep_surfaceleafs_plot(struct bu_vls *vls, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, bool dim3d, int index, int)
 {
-    ON_TextLog tl(stderr);
+       ON_wString wstr;
+    ON_TextLog tl(wstr);
+
     ON_Brep* brep = bs->brep;
     if (brep == NULL || !brep->IsValid(&tl)) {
        bu_log("brep is NOT valid");
@@ -1583,6 +1685,8 @@
            plotsurfaceleafs(st, vbp, dim3d);
        }
     }
+
+    bu_vls_printf(vls, ON_String(wstr).Array());
     return 0;
 }
 
@@ -1590,7 +1694,9 @@
 int
 brep_trimleafs_plot(struct bu_vls *vls, struct brep_specific* bs, struct 
rt_brep_internal*, struct bn_vlblock *vbp, bool dim3d, int index, int)
 {
-    ON_TextLog tl(stderr);
+       ON_wString wstr;
+    ON_TextLog tl(wstr);
+
     ON_Brep* brep = bs->brep;
     if (brep == NULL || !brep->IsValid(&tl)) {
        bu_log("brep is NOT valid");
@@ -1610,6 +1716,8 @@
            plottrimleafs(st, vbp, dim3d);
        }
     }
+
+    bu_vls_printf(vls, ON_String(wstr).Array());
     return 0;
 }
 
@@ -1705,6 +1813,9 @@
            } else if (strcmp(part, "SN") == 0) {
                snprintf(commtag, 64, "_BC_SN_");
                ret = brep_surface_normal_plot(vls, bs, bi, vbp, index, 
plotres);
+           } else if (strcmp(part, "KN") == 0) {
+               snprintf(commtag, 64, "_BC_KN_");
+               ret = brep_surface_knot_plot(vls, bs, bi, vbp, index);
            } else if (strcmp(part, "F") == 0) {
                snprintf(commtag, 64, "_BC_F_");
                ret = brep_facetrim_plot(vls, bs, bi, vbp, index, plotres, 
true);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to