Revision: 74302
          http://sourceforge.net/p/brlcad/code/74302
Author:   starseeker
Date:     2019-11-06 00:36:51 +0000 (Wed, 06 Nov 2019)
Log Message:
-----------
Temporary (and ugly) visualization mechanism for RTree boxes.  Need to inspect 
what's going on as we test and manipulate the boxes.

Modified Paths:
--------------
    brlcad/trunk/src/libbrep/RTree.h
    brlcad/trunk/src/libbrep/cdt_ovlps.cpp

Modified: brlcad/trunk/src/libbrep/RTree.h
===================================================================
--- brlcad/trunk/src/libbrep/RTree.h    2019-11-05 23:56:45 UTC (rev 74301)
+++ brlcad/trunk/src/libbrep/RTree.h    2019-11-06 00:36:51 UTC (rev 74302)
@@ -9,6 +9,7 @@
 #include <type_traits>
 #include <cmath>
 #include <set>
+#include "bn/plot3.h"
 #include "opennurbs.h"
 
 #define RTreeAssert assert // RTree uses RTreeAssert( condition )
@@ -305,8 +306,8 @@
        return *a_it;
     }
 
-protected:
 
+
     /// Minimal bounding rectangle (n-dimensional)
     struct Rect {
        ElementType m_min[kNumDimensions] = { 0, };                      ///< 
Min dimensions of bounding box
@@ -313,6 +314,7 @@
        ElementType m_max[kNumDimensions] = { 0, };                      ///< 
Max dimensions of bounding box
     };
 
+protected:
     /// May be data or may be another subtree
     /// The parents level determines this.
     /// If the parents level is 0, then this is data
@@ -402,9 +404,55 @@
 
     Node* m_root = nullptr;                                         ///< Root 
of tree
     ElementTypeReal m_unitSphereVolume = kElementTypeRealZero;      ///< Unit 
sphere constant for required number of dimensions
+
+public:
+    void plot(Rect *a_rect, const char *fname) __attribute__((noinline));
+
 };
 
+#define RECT_TREE_LEAF_FACE_3D(pf, valp, a, b, c, d)  \
+        pdv_3move(pf, pt[a]); \
+    pdv_3cont(pf, pt[b]); \
+    pdv_3cont(pf, pt[c]); \
+    pdv_3cont(pf, pt[d]); \
+    pdv_3cont(pf, pt[a]); \
 
+#define RECT_BBOX_PLOT(pf, bb) {                 \
+        fastf_t pt[8][3];                       \
+        point_t min, max;                       \
+        min[0] = bb.Min().x;                    \
+        min[1] = bb.Min().y;                    \
+        min[2] = bb.Min().z;                    \
+        max[0] = bb.Max().x;                    \
+        max[1] = bb.Max().y;                    \
+        max[2] = bb.Max().z;                    \
+        VSET(pt[0], max[X], min[Y], min[Z]);    \
+        VSET(pt[1], max[X], max[Y], min[Z]);    \
+        VSET(pt[2], max[X], max[Y], max[Z]);    \
+        VSET(pt[3], max[X], min[Y], max[Z]);    \
+        VSET(pt[4], min[X], min[Y], min[Z]);    \
+        VSET(pt[5], min[X], max[Y], min[Z]);    \
+        VSET(pt[6], min[X], max[Y], max[Z]);    \
+        VSET(pt[7], min[X], min[Y], max[Z]);    \
+        RECT_TREE_LEAF_FACE_3D(pf, pt, 0, 1, 2, 3);      \
+        RECT_TREE_LEAF_FACE_3D(pf, pt, 4, 0, 3, 7);      \
+        RECT_TREE_LEAF_FACE_3D(pf, pt, 5, 4, 7, 6);      \
+        RECT_TREE_LEAF_FACE_3D(pf, pt, 1, 5, 6, 2);      \
+}
+
+// For debugging - works only with 3D trees
+RTREE_TEMPLATE
+void RTREE_QUAL::plot(Rect *a_rect, const char *fname)
+{
+    if (!fname) return;
+    ON_3dPoint p1(a_rect->m_min[0], a_rect->m_min[1], a_rect->m_min[2]);
+    ON_3dPoint p2(a_rect->m_max[0], a_rect->m_max[1], a_rect->m_max[2]);
+    ON_BoundingBox bb(p1, p2);
+    FILE *p = fopen(fname, "w");
+    RECT_BBOX_PLOT(p, bb);
+    fclose(p);
+}
+
 // Because there is not stream support, this is a quick and dirty file I/O 
helper.
 // Users will likely replace its usage with a Stream implementation from their 
favorite API.
 class RTFileStream

Modified: brlcad/trunk/src/libbrep/cdt_ovlps.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_ovlps.cpp      2019-11-05 23:56:45 UTC (rev 
74301)
+++ brlcad/trunk/src/libbrep/cdt_ovlps.cpp      2019-11-06 00:36:51 UTC (rev 
74302)
@@ -1386,6 +1386,8 @@
 
 #if 1
            if (BU_STR_EQUAL(omesh->fmesh->name, "p.s")) {
+               RTree<long, double, 3>::Rect r;
+               omesh->vtree.plot(&r, NULL);
                ON_3dPoint 
problem(3.4452740189190436,7.674473756016984,22.999999999999989);
                if (problem.DistanceTo(epnts[i].spnt) < 0.1) {
                    std::cout << "search problem\n";

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



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to