Fri, 12/13/2024 - 22:26
Forums:
Hello all,
running on version 7.7.0
if I "fuse" two or multiple TopoDS_Shape (made with BRepPrimAPI_MakePrism, BRepPrimAPI_MakeCylinder, BRepPrimAPI_MakeBox etc) with BRepAlgoAPI_Fuse all works as expect. See picture 1.png
if I "fuse" a BRepPrimAPI_MakeCylinder with a "self made" cube (picture 2.png) then I get a strange result: the "fuse" only works from the point both shapes are in common. hard to explain so please see the picture 3.png.
I am stuck since 2 days - any help is much appreciated. Thanks!!
code for the working cube:
// Dimensions of the cube
double length = 500.0; // Length along X-axis
double width = 100.0; // Width along Y-axis
double height = 1000.0; // Height along Z-axis
// Create the cube as a TopoDS_Shape
TopoDS_Shape cube = BRepPrimAPI_MakeBox(length, width, height).Shape();
code for my custom shape what doesn't work correct:
double height = 1000;
// Define the 8 points
// bottom
gp_Pnt p1(0, 0, 0); // Point 1
gp_Pnt p2(500, 0, 0); // Point 2
gp_Pnt p3(500, 100, 0); // Point 3
gp_Pnt p4(0, 100, 0); // Point 4
// top
gp_Pnt p5(0, 0, height); // Point 5
gp_Pnt p6(100, 0, height); // Point 6
gp_Pnt p7(100, 100, height); // Point 7
gp_Pnt p8(0, 100, height); // Point 8
// Create vertices
TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(p1);
TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(p2);
TopoDS_Vertex v3 = BRepBuilderAPI_MakeVertex(p3);
TopoDS_Vertex v4 = BRepBuilderAPI_MakeVertex(p4);
TopoDS_Vertex v5 = BRepBuilderAPI_MakeVertex(p5);
TopoDS_Vertex v6 = BRepBuilderAPI_MakeVertex(p6);
TopoDS_Vertex v7 = BRepBuilderAPI_MakeVertex(p7);
TopoDS_Vertex v8 = BRepBuilderAPI_MakeVertex(p8);
// Create edges by connecting the vertices
TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(v1, v2);
TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(v2, v3);
TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(v3, v4);
TopoDS_Edge e4 = BRepBuilderAPI_MakeEdge(v4, v1);
TopoDS_Edge e5 = BRepBuilderAPI_MakeEdge(v5, v6);
TopoDS_Edge e6 = BRepBuilderAPI_MakeEdge(v6, v7);
TopoDS_Edge e7 = BRepBuilderAPI_MakeEdge(v7, v8);
TopoDS_Edge e8 = BRepBuilderAPI_MakeEdge(v8, v5);
TopoDS_Edge e9 = BRepBuilderAPI_MakeEdge(v1, v5);
TopoDS_Edge e10 = BRepBuilderAPI_MakeEdge(v2, v6);
TopoDS_Edge e11 = BRepBuilderAPI_MakeEdge(v3, v7);
TopoDS_Edge e12 = BRepBuilderAPI_MakeEdge(v4, v8);
// Create wires for each face (4 edges per face)
TopoDS_Wire w1 = BRepBuilderAPI_MakeWire(e1, e2, e3, e4); // Bottom face
TopoDS_Wire w2 = BRepBuilderAPI_MakeWire(e5, e6, e7, e8); // Top face
TopoDS_Wire w3 = BRepBuilderAPI_MakeWire(e1, e9, e5, e10); // Side face
TopoDS_Wire w4 = BRepBuilderAPI_MakeWire(e2, e10, e6, e11); // Side face
TopoDS_Wire w5 = BRepBuilderAPI_MakeWire(e3, e11, e7, e12); // Side face
TopoDS_Wire w6 = BRepBuilderAPI_MakeWire(e4, e12, e8, e9); // Side face
// Create faces
TopoDS_Face f1 = BRepBuilderAPI_MakeFace(w1); // Bottom face
TopoDS_Face f2 = BRepBuilderAPI_MakeFace(w2); // Top face
TopoDS_Face f3 = BRepBuilderAPI_MakeFace(w3); // Side face
TopoDS_Face f4 = BRepBuilderAPI_MakeFace(w4); // Side face
TopoDS_Face f5 = BRepBuilderAPI_MakeFace(w5); // Side face
TopoDS_Face f6 = BRepBuilderAPI_MakeFace(w6); // Side face
// Combine faces into a compound shape
TopoDS_Shell shell;
BRep_Builder builder;
builder.MakeShell(shell);
builder.Add(shell, f1);
builder.Add(shell, f2);
builder.Add(shell, f3);
builder.Add(shell, f4);
builder.Add(shell, f5);
builder.Add(shell, f6);
BRepBuilderAPI_MakeSolid solidMaker(shell);
both shape are transformed in plus X and minus Z:
gp_Trsf aTrsf;
aTrsf.SetTranslationPart(gp_Vec(500.0, 0.0, -500.0));
gp_Quaternion q;
q.SetEulerAngles(gp_Extrinsic_XYZ, 0, 0, 0.1);
aTrsf.SetRotationPart(q);
for the cube:
return BRepBuilderAPI_Transform(cube, aTrsf).Shape();
for the self made:
return BRepBuilderAPI_Transform(solidMaker.Shape(), aTrsf).Shape();
then finally the fusion between a cylinder and the cube or custom shape:
aCylinder = BRepPrimAPI_MakeCylinder(anAxis, diameter/2, width).Shape();
works as expected:
BRepAlgoAPI_Fuse(aCylinder , aCube)
does not work correct:
BRepAlgoAPI_Fuse(aCylinder , aCustomShape)
Sat, 12/14/2024 - 15:57
Hello.
It is not a direct bug of the Fuse operation. The issue with not valid edge orientation in Wire. You had bad connected shapes by BRepCheck_Analyzer. You can check the validity of your shape by check shape operation.
Best regards, Dmitrii.
Sat, 12/14/2024 - 19:50
Works great - thanks so much!
Have a good weekend