Closed jdegenstein closed 10 months ago
I was under the impression that it was not possible to create a valid shell/solid if the vertices along an edge weren't consistent - this is wrong. Here is an experiment:
from build123d import *
from build123d import downcast
from ocp_vscode import *
from OCP.BRepBuilderAPI import (
BRepBuilderAPI_MakeFace,
BRepBuilderAPI_MakePolygon,
BRepBuilderAPI_MakeSolid,
BRepBuilderAPI_MakeVertex,
BRepBuilderAPI_Sewing,
)
from OCP.gp import gp_Pnt
pnt_set = [
[gp_Pnt(*p) for p in [(0, 0, 0), (0.5, 0, 0), (0, 1, 0)]],
[gp_Pnt(*p) for p in [(0.5, 0, 0), (1, 0, 0), (0, 1, 0)]],
[gp_Pnt(*p) for p in [(0, 0, 0), (1, 0, 0), (0, -1, 0)]],
[gp_Pnt(*p) for p in [(0, -1, 0), (0, 1, 0), (0, 0, -1)]],
[gp_Pnt(*p) for p in [(0, -1, 0), (0, 0, -1), (1, 0, 0)]],
[gp_Pnt(*p) for p in [(0, 1, 0), (1, 0, 0), (0, 0, -1)]],
]
shell_builder = BRepBuilderAPI_Sewing()
for pnts in pnt_set:
vertices = [downcast(BRepBuilderAPI_MakeVertex(pnt).Vertex()) for pnt in pnts]
wire_builder = BRepBuilderAPI_MakePolygon(*vertices, Close=True)
face_builder = BRepBuilderAPI_MakeFace(wire_builder.Wire())
shell_builder.Add(face_builder.Face())
shell_builder.Perform()
occ_sewed_shape = downcast(shell_builder.SewedShape())
solid_builder = BRepBuilderAPI_MakeSolid(occ_sewed_shape)
ocp_solid = solid_builder.Solid()
bd_solid = Solid(ocp_solid)
print(bd_solid.is_manifold, bd_solid.is_valid(), bd_solid.volume, len(bd_solid.faces()))
# bd_solid.clean()
# print(bd_solid.is_manifold, bd_solid.is_valid(), bd_solid.volume, len(bd_solid.faces()))
show(occ_sewed_shape, ocp_solid, bd_solid)
True True 0.33333333333333337 6
clean()
has the predicted impact of reducing the number of faces to four.
cyl_w_rect_hole.zip build123d has trouble properly loading the attached STL file which has been verified as manifold using multiple external tools.
build123d returns a
Shell
when it should have been aSolid
. After further investigation, it was found that the two methods for checking if an object is manifold disagree if this object is manifold.:There are 4 total faces with their normal direction flipped, and 3 faces are on the bottom of the object (pictured):
Returns:
The last flipped face somehow has 8 vertices.