Thu, 11/21/2024 - 20:17
Hi guys, first post here, sorry if wrong section.
I came here looking for understanding the proper way of reading the result of a Common operation.
I tried to setup a fairly simple experiment and still failed to grasp what is happening wrong :
I create two rectangles from BSpline of degree 1 ( So polylines )
2x4 and 4x2 sizes
I then use BRepBuilderAPI_MakeWire and BRepBuilderAPI_MakeFace to obtain my two shapes.
Then i use BRepAlgoAPI_Common and when visualised, gives me a square face 2x2 : good so far
But what i need is the external wire/contour of this face. I tried using TopExplorer to collect the edges i was looking for and the edges found are those from the two original rectangle.
How can i get my square wire here ?
Here is the not working as expected BRepAlgoAPI_Common code (Python, OCP 7.7) :
common_algo = BRepAlgoAPI_Common(brepA.GetShape(), brepB.GetShape())
print(Brep(common_algo.Shape()))
explorer = TopExp_Explorer(common_algo.Shape(), TopAbs_FACE)
face_count = 0
while explorer.More():
face = TopoDS.Face_s(explorer.Current())
face_count += 1
outer_wire = BRepTools.OuterWire_s(face)
if outer_wire.IsNull():
explorer.Next()
continue
wire_explorer = TopExp_Explorer(outer_wire, TopAbs_EDGE)
while wire_explorer.More():
edge = TopoDS.Edge_s(wire_explorer.Current())
first_param = 0.0
last_param = 0.0
geom_curve = BRep_Tool.Curve_s(edge, first_param, last_param)
intersection_curves.append(Curve(geom_curve))
wire_explorer.Next()
explorer.Next()
print(f"Total faces processed: {face_count}")
print(f"Total intersection curves: {len(intersection_curves)}")
print(f"Curves: {intersection_curves}")
Any guide/link would also help a lot, thank you in advance