Revision: 57131
http://sourceforge.net/p/brlcad/code/57131
Author: phoenixyjll
Date: 2013-08-26 06:32:15 +0000 (Mon, 26 Aug 2013)
Log Message:
-----------
Decide whether the trimmed faces belong to the final structure according to
type of the operation.
Modified Paths:
--------------
brlcad/trunk/include/brep.h
brlcad/trunk/src/libbrep/boolean.cpp
brlcad/trunk/src/libged/brep.c
brlcad/trunk/src/librt/primitives/brep/brep.cpp
Modified: brlcad/trunk/include/brep.h
===================================================================
--- brlcad/trunk/include/brep.h 2013-08-26 06:11:28 UTC (rev 57130)
+++ brlcad/trunk/include/brep.h 2013-08-26 06:32:15 UTC (rev 57131)
@@ -2026,6 +2026,13 @@
Subsurface* treeB = 0);
+enum op_type {
+ BOOLEAN_UNION = 0,
+ BOOLEAN_INTERSECT = 1,
+ BOOLEAN_DIFF = 2
+};
+
+
/**
* Evaluate NURBS boolean operations.
*
@@ -2035,7 +2042,7 @@
* @param operation [in]
*/
extern BREP_EXPORT int
-ON_Boolean(ON_Brep* brepO, const ON_Brep* brepA, const ON_Brep* brepB, int
operation);
+ON_Boolean(ON_Brep* brepO, const ON_Brep* brepA, const ON_Brep* brepB, op_type
operation);
/**
Modified: brlcad/trunk/src/libbrep/boolean.cpp
===================================================================
--- brlcad/trunk/src/libbrep/boolean.cpp 2013-08-26 06:11:28 UTC (rev
57130)
+++ brlcad/trunk/src/libbrep/boolean.cpp 2013-08-26 06:32:15 UTC (rev
57131)
@@ -1316,7 +1316,7 @@
int
-ON_Boolean(ON_Brep* brepO, const ON_Brep* brepA, const ON_Brep* brepB, int
UNUSED(operation))
+ON_Boolean(ON_Brep* brepO, const ON_Brep* brepA, const ON_Brep* brepB, op_type
operation)
{
int facecount1 = brepA->m_F.Count();
int facecount2 = brepB->m_F.Count();
@@ -1531,26 +1531,34 @@
const ON_Brep* another_brep = i >= facecount1 ? brepA : brepB;
ON_SimpleArray<Subsurface*>& surf_tree = i >= facecount1 ? surf_treeA :
surf_treeB;
for (int j = 0; j < splitted.Count(); j++) {
- // Just for test. WIP.
+ bool belong_to_final = false;
if (IsFaceInsideBrep(splitted[j], another_brep, surf_tree)) {
- bu_log("The trimmed face is inside the other brep.\n");
+ if (DEBUG_BREP_BOOLEAN)
+ bu_log("The trimmed face is inside the other brep.\n");
+ if (operation == BOOLEAN_INTERSECT || (operation ==
BOOLEAN_DIFF && i >= facecount1))
+ belong_to_final = true;
} else {
- bu_log("The trimmed face is not inside the other brep.\n");
+ if (DEBUG_BREP_BOOLEAN)
+ bu_log("The trimmed face is not inside the other brep.\n");
+ if (operation == BOOLEAN_UNION || (operation == BOOLEAN_DIFF &&
i < facecount1))
+ belong_to_final = true;
}
- // Add the surfaces, faces, loops, trims, vertices, edges, etc.
- // to the brep structure.
- ON_Surface *new_surf = surf->Duplicate();
- int surfindex = brepO->AddSurface(new_surf);
- ON_BrepFace& new_face = brepO->NewFace(surfindex);
+ if (belong_to_final) {
+ // Add the surfaces, faces, loops, trims, vertices, edges, etc.
+ // to the brep structure.
+ ON_Surface *new_surf = surf->Duplicate();
+ int surfindex = brepO->AddSurface(new_surf);
+ ON_BrepFace& new_face = brepO->NewFace(surfindex);
- add_elements(brepO, new_face, splitted[j]->m_outerloop,
ON_BrepLoop::outer);
- // ON_BrepLoop &loop = brepO->m_L[brepO->m_L.Count() - 1];
- for (unsigned int k = 0; k < splitted[j]->m_innerloop.size(); k++)
- add_elements(brepO, new_face, splitted[j]->m_innerloop[k],
ON_BrepLoop::inner);
+ add_elements(brepO, new_face, splitted[j]->m_outerloop,
ON_BrepLoop::outer);
+ // ON_BrepLoop &loop = brepO->m_L[brepO->m_L.Count() - 1];
+ for (unsigned int k = 0; k < splitted[j]->m_innerloop.size();
k++)
+ add_elements(brepO, new_face, splitted[j]->m_innerloop[k],
ON_BrepLoop::inner);
- brepO->SetTrimIsoFlags(new_face);
- brepO->FlipFace(new_face);
+ brepO->SetTrimIsoFlags(new_face);
+ brepO->FlipFace(new_face);
+ }
}
}
Modified: brlcad/trunk/src/libged/brep.c
===================================================================
--- brlcad/trunk/src/libged/brep.c 2013-08-26 06:11:28 UTC (rev 57130)
+++ brlcad/trunk/src/libged/brep.c 2013-08-26 06:32:15 UTC (rev 57131)
@@ -51,7 +51,7 @@
RT_EXPORT extern int brep_intersect_curve_curve(struct rt_db_internal
*intern1, struct rt_db_internal *intern2, int i, int j);
RT_EXPORT extern int brep_intersect_curve_surface(struct rt_db_internal
*intern1, struct rt_db_internal *intern2, int i, int j);
RT_EXPORT extern int brep_intersect_surface_surface(struct rt_db_internal
*intern1, struct rt_db_internal *intern2, int i, int j, struct bn_vlblock *vbp);
-RT_EXPORT extern int rt_brep_boolean(struct rt_db_internal *out, const struct
rt_db_internal *ip1, const struct rt_db_internal *ip2, const int operation);
+RT_EXPORT extern int rt_brep_boolean(struct rt_db_internal *out, const struct
rt_db_internal *ip1, const struct rt_db_internal *ip2, const enum op_type
operation);
int
Modified: brlcad/trunk/src/librt/primitives/brep/brep.cpp
===================================================================
--- brlcad/trunk/src/librt/primitives/brep/brep.cpp 2013-08-26 06:11:28 UTC
(rev 57130)
+++ brlcad/trunk/src/librt/primitives/brep/brep.cpp 2013-08-26 06:32:15 UTC
(rev 57131)
@@ -91,7 +91,7 @@
int rt_brep_tclget(Tcl_Interp *interp, const struct rt_db_internal
*intern, const char *attr);
int rt_brep_tcladjust(Tcl_Interp *interp, struct rt_db_internal *intern,
int argc, const char **argv);
int rt_brep_params(struct pc_pc_set *, const struct rt_db_internal *ip);
- RT_EXPORT extern int rt_brep_boolean(struct rt_db_internal *out, const
struct rt_db_internal *ip1, const struct rt_db_internal *ip2, const int
operation);
+ RT_EXPORT extern int rt_brep_boolean(struct rt_db_internal *out, const
struct rt_db_internal *ip1, const struct rt_db_internal *ip2, const enum
op_type operation);
#ifdef __cplusplus
}
#endif
@@ -4065,7 +4065,7 @@
int
-rt_brep_boolean(struct rt_db_internal *out, const struct rt_db_internal *ip1,
const struct rt_db_internal *ip2, const int operation)
+rt_brep_boolean(struct rt_db_internal *out, const struct rt_db_internal *ip1,
const struct rt_db_internal *ip2, const enum op_type operation)
{
RT_CK_DB_INTERNAL(ip1);
RT_CK_DB_INTERNAL(ip2);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits