(Common) Boolean Intersection between Shapes

Quaoar

Administrator
Staff member
Btw, the repair command will fix the orientation but it's much better to understand why the shape came in corrupted that way. Shape healing is a "last chance" tool to apply when things completely get out of control.
 

Lingkan

Active CAD practitioner
Et voila! We're up and running!

Applying a ShapeFix to the Face works like a charm...

FYI: The faulty Face comes from a BRepAlgoAPI_Common with using the planar face as arguments and a bounding box solid as tools. (Usage is to limit a plane by a global bounding box to keep as a Reference Surface and then use it to cut or limit panels/plates from it)

I want to summarize the following learnings from out today's session:
  1. OCC Booleans work as intended
  2. Use and export a BRep representation of your shapes if you want to debug them (Exporting as STEP might give you a different version of that shape)
 

Lingkan

Active CAD practitioner
Btw, the repair command will fix the orientation but it's much better to understand why the shape came in corrupted that way. Shape healing is a "last chance" tool to apply when things completely get out of control.

Maybe you can elaborate on this provided the context...
The faulty Face comes from a BRepAlgoAPI_Common with using the planar face as arguments and a bounding box solid as tools.
 

Quaoar

Administrator
Staff member
Use and export a BRep representation of your shapes if you want to debug them (Exporting as STEP might give you a different version of that shape)
Yes, for debugging it's either BREP or immediate drawing to the display from memory (to avoid any "unintentional healing").
 

Lingkan

Active CAD practitioner
Hello folks!

More on Boolean Fuse: Now given the following collection of shapes (see attachment)
1717442565286.png

How can I filter to retrieve the following resulting edge (black) along the other (yellow, non-manifold edge)?
1717442663072.png

I used the snippet u provided earlier:
Code:
clear; load-part C:/Work/.../shape.brep; fit;
explode
bop-fuse-gen r "SHELL 1" "SHELL 2"
set-as-part r
donly

To filter the non-manifold edges I use the code snippet from ASITUS SDK:
C++:
// Find non-manifold edges
// TODO: ASITUS SDK

// Get child-parent relationships
TopTools_IndexedDataMapOfShapeListOfShape M;
TopExp::MapShapesAndAncestors(fused, TopAbs_EDGE, TopAbs_FACE, M);

// Check for every edge the number of its owning faces
const int nEdges = M.Extent();
for (int e = 1; e <= nEdges; ++e) {
  const TopoDS_Edge &E = TopoDS::Edge(M.FindKey(e));
  //
  if (BRep_Tool::Degenerated(E)) continue;

  const int nOwningFaces = M.FindFromIndex(e).Extent();
  if (nOwningFaces > 2) {
    bbuilder.Add(nonManifoldEdges, E);
    //
    bbuilder.Add(dbgDump, E);
  }
}
 

Attachments

  • shape.brep
    198 KB · Views: 2

Quaoar

Administrator
Staff member
Well, this is a sort of "corner case." A topologically non-manifold joint between faces is reported to be manifold, because this is how the manifoldness property check is done. According to the code, if an edge belongs to 2 faces, then the edge is manifold. We see that it's not necessarily true. To overcome the issue I would have probably considered checking if the orientation of an edge is INTERNAL and add all such "internal" edges to the result as well. You can see such internal edges in yellow in the Domain view:

1717489332267.png

The easiest way to do it is to enhance a little the condition you use:

Code:
if (nOwningFaces > 2 || E.Orientation() == TopAbs_INTERNAL) {
 ...
}

1717489731574.png
 
Top