Revision: 64379
http://sourceforge.net/p/brlcad/code/64379
Author: starseeker
Date: 2015-03-12 19:58:31 +0000 (Thu, 12 Mar 2015)
Log Message:
-----------
Thanks to Keith for the pointer to his surface_GetBoundingBox routine. This
adds in subtractions where needed to the CSG tree, based on overlapping
bounding boxes.
Modified Paths:
--------------
brlcad/trunk/src/libbrep/shape_recognition.cpp
brlcad/trunk/src/libbrep/shape_recognition.h
brlcad/trunk/src/libbrep/shape_recognition_util.cpp
Modified: brlcad/trunk/src/libbrep/shape_recognition.cpp
===================================================================
--- brlcad/trunk/src/libbrep/shape_recognition.cpp 2015-03-12 19:39:45 UTC
(rev 64378)
+++ brlcad/trunk/src/libbrep/shape_recognition.cpp 2015-03-12 19:58:31 UTC
(rev 64379)
@@ -344,10 +344,26 @@
for (sb_it2 = ignore_queue.begin(); sb_it2 != ignore_queue.end();
sb_it2++) {
local_subtraction_queue.erase(*sb_it2);
}
+
// Now, whatever is left in the local subtraction queue has to be ruled
out based on volumetric
// intersection testing.
- //
- // TODO - bounding box fun.
+
+ // Construct bounding box for pobj
+ if (!pobj->bbox_set) subbrep_bbox(pobj);
+ // Iterate over the queue
+ for (sb_it2 = local_subtraction_queue.begin(); sb_it2 !=
local_subtraction_queue.end(); sb_it2++) {
+ struct subbrep_object_data *sobj = (struct subbrep_object_data
*)(*sb_it2);
+ //std::cout << "Checking subbrep " << bu_vls_addr(sobj->key) <<
"\n";
+ // Construct bounding box for sobj
+ if (!sobj->bbox_set) subbrep_bbox(sobj);
+ ON_BoundingBox isect;
+ bool bbi = isect.Intersection(*pobj->bbox, *sobj->bbox);
+ bool bbc = pobj->bbox->Includes(*sobj->bbox);
+ if (bbi || bbc) {
+ std::cout << " Found intersecting subbrep " <<
bu_vls_addr(sobj->key) << " under " << bu_vls_addr(pobj->key) << "\n";
+ bu_ptbl_ins(subbreps_tree, *sb_it2);
+ }
+ }
}
return subbreps_tree;
}
Modified: brlcad/trunk/src/libbrep/shape_recognition.h
===================================================================
--- brlcad/trunk/src/libbrep/shape_recognition.h 2015-03-12 19:39:45 UTC
(rev 64378)
+++ brlcad/trunk/src/libbrep/shape_recognition.h 2015-03-12 19:58:31 UTC
(rev 64379)
@@ -126,6 +126,8 @@
* 1 = positive
* 0 = unknown/unset */
int negative_shape;
+ ON_BoundingBox *bbox;
+ int bbox_set;
};
void subbrep_object_init(struct subbrep_object_data *obj, const ON_Brep *brep);
@@ -143,6 +145,8 @@
void subbrep_planar_close_obj(struct subbrep_object_data *data);
void subbrep_add_planar_face(struct subbrep_object_data *data, ON_Plane *pcyl,
ON_SimpleArray<const ON_BrepVertex *> *vert_loop, int neg_surf);
+void subbrep_bbox(struct subbrep_object_data *obj);
+
struct bu_ptbl *find_subbreps(const ON_Brep *brep);
struct bu_ptbl *find_top_level_hierarchy(struct bu_ptbl *subbreps);
void print_subbrep_object(struct subbrep_object_data *data, const char
*offset);
Modified: brlcad/trunk/src/libbrep/shape_recognition_util.cpp
===================================================================
--- brlcad/trunk/src/libbrep/shape_recognition_util.cpp 2015-03-12 19:39:45 UTC
(rev 64378)
+++ brlcad/trunk/src/libbrep/shape_recognition_util.cpp 2015-03-12 19:58:31 UTC
(rev 64379)
@@ -207,6 +207,61 @@
}
void
+ON_MinMaxInit(ON_3dPoint *min, ON_3dPoint *max)
+{
+ min->x = ON_DBL_MAX;
+ min->y = ON_DBL_MAX;
+ min->z = ON_DBL_MAX;
+ max->x = -ON_DBL_MAX;
+ max->y = -ON_DBL_MAX;
+ max->z = -ON_DBL_MAX;
+}
+
+void
+subbrep_bbox(struct subbrep_object_data *obj)
+{
+ for (int i = 0; i < obj->fol_cnt; i++) {
+ ON_3dPoint min, max;
+ ON_MinMaxInit(&min, &max);
+ const ON_BrepFace *face = &(obj->brep->m_F[obj->fol[i]]);
+ // Bounding interfals of outer loop
+ for (int ti = 0; ti < face->OuterLoop()->TrimCount(); ti++) {
+ ON_BrepTrim *trim = face->OuterLoop()->Trim(ti);
+ trim->GetBoundingBox(min, max, true);
+ }
+ ON_Interval u(min.x, max.x);
+ ON_Interval v(min.y, max.y);
+ surface_GetBoundingBox(face->SurfaceOf(), u, v, *(obj->bbox), true);
+ }
+ std::set<int> loops;
+ array_to_set(&loops, obj->loops, obj->loops_cnt);
+ for (int i = 0; i < obj->fil_cnt; i++) {
+ ON_3dPoint min, max;
+ ON_MinMaxInit(&min, &max);
+ const ON_BrepFace *face = &(obj->brep->m_F[obj->fil[i]]);
+ int loop_ind = -1;
+ for (int li = 0; li < face->LoopCount(); li++) {
+ int loop_index = face->Loop(li)->m_loop_index;
+ if (loops.find(loop_index) != loops.end()) {
+ loop_ind = loop_index;
+ break;
+ }
+ }
+ if (loop_ind == -1) {
+ std::cout << "Error - could not find fil loop!\n";
+ }
+ const ON_BrepLoop *loop= &(obj->brep->m_L[loop_ind]);
+ for (int ti = 0; ti < loop->TrimCount(); ti++) {
+ ON_BrepTrim *trim = loop->Trim(ti);
+ trim->GetBoundingBox(min, max, true);
+ }
+ ON_Interval u(min.x, max.x);
+ ON_Interval v(min.y, max.y);
+ surface_GetBoundingBox(face->SurfaceOf(), u, v, *(obj->bbox), true);
+ }
+}
+
+void
subbrep_object_init(struct subbrep_object_data *obj, const ON_Brep *brep)
{
if (!obj) return;
@@ -224,6 +279,9 @@
obj->type = BREP;
obj->is_island = 0;
obj->negative_shape = 0;
+ obj->bbox = new ON_BoundingBox();
+ ON_MinMaxInit(&(obj->bbox->m_min), &(obj->bbox->m_max));
+ obj->bbox_set = 0;
}
void
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits