Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close open shell boundary #1297

Open
andysfd opened this issue Jan 9, 2024 · 3 comments
Open

close open shell boundary #1297

andysfd opened this issue Jan 9, 2024 · 3 comments

Comments

@andysfd
Copy link

andysfd commented Jan 9, 2024

Hello

I imported a Step file representing an open shell (<class 'TopoDS_Shell'>).
I now want to find a correct and easy method to close the two existing holes. I searched several documentations but couldn't find a function for this purpose.

question

Furtherone i need to check points inside and outside the shell and the distances, which i successfully accomplished with BRepClass3d_SolidClassifier and BRepExtrema_DistShapeShape. However to get correct results at the beginning of the shell i need to properly close it.

question2

Thanks in advance for any help!
Wish you all a happy new year

@tpaviot
Copy link
Owner

tpaviot commented Jan 9, 2024

For each red wire, you can build a face using the BRepBuilderAPI_MakeFace class:

face_1 = BRepBuilderAPI_MakeFace(red_wire_1).Face()
face_2 = BRepBuilderAPI_MakeFace(red_wire_2).Face()

In order to get those wires, use the TopologyExplorer class:

from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.TopologyUtils import TopologyExplorer
step_shp = read_step_file("yourstepfile.stp")
wires = TopologyExplorer(step_shp).wires()

and loop over wires

@andysfd
Copy link
Author

andysfd commented Jan 9, 2024

so i could extract the vertices of the openings and construct my own faces?

But isn't there a robust solution? i do not know how to detect the edges / vertices associated to the openings. I thought about using ShapeAnalysis_FreeBounds or something but had no success.

When i simply extract the wires and sew them togeter its still open, meaning the red_wire does not exist yet in the model and needs to be constructed from the existing edges.

@andysfd
Copy link
Author

andysfd commented Jan 10, 2024

i managed to do it, although i don't think it is the cleanest solution:

I extracted the faces and used the sewing algorithm in order to detect the boundaries with .FreeEdges.
I then extracted the edges and joined them consecutively to a new face.

Is there an other algorithm which gives me FreeEdges without the need for resewing of the already existing shell?

wires = TopologyExplorer(shp).wires()
faces=[]
for wire in wires:
    faces.append(BRepBuilderAPI_MakeFace(wire).Face())

sew = BRepBuilderAPI_Sewing() 
for face in faces:
    sew.Add(face)
sew.Perform()  

print("Free edge", sew.NbFreeEdges())
free_edges =[]
for i in range(1, sew.NbFreeEdges()+1):
    free_edges.append(sew.FreeEdge(i))

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants