- Tons of addtions
This commit is contained in:
@@ -157,7 +157,13 @@ class OCGeometryKernel(GeometryKernel):
|
||||
direction: Tuple[float, float, float] = (0, 0, 1),
|
||||
symmetric: bool = False,
|
||||
) -> GeometryObject:
|
||||
"""Extrude a 2D sketch into a 3D solid."""
|
||||
"""Extrude a 2D sketch into a 3D solid.
|
||||
|
||||
*height* is extruded along *direction* (default +Z). A negative *height*
|
||||
extrudes in the opposite direction. The *direction* argument is accepted
|
||||
for API compatibility; currently only the sign of *height* is used for
|
||||
direction (positive → +Z, negative → -Z).
|
||||
"""
|
||||
import cadquery as cq
|
||||
|
||||
cq_obj = self._get_cq_obj(sketch)
|
||||
@@ -604,7 +610,9 @@ class OCGeometryKernel(GeometryKernel):
|
||||
from OCP.BRep import BRep_Tool
|
||||
from OCP.TopLoc import TopLoc_Location
|
||||
|
||||
mesh = BRepMesh_IncrementalMesh(shape, tolerance, False, 0.5, False)
|
||||
# Use finer angular deflection (0.15 rad ≈ 24 segments/circle) so
|
||||
# curved surfaces like cylinders render smoothly instead of faceted.
|
||||
mesh = BRepMesh_IncrementalMesh(shape, tolerance, False, 0.15, True)
|
||||
mesh.Perform()
|
||||
|
||||
vertices_list: List[List[float]] = []
|
||||
@@ -612,6 +620,7 @@ class OCGeometryKernel(GeometryKernel):
|
||||
vertex_offset = 0
|
||||
|
||||
from OCP.TopoDS import TopoDS
|
||||
from OCP.TopAbs import TopAbs_Orientation
|
||||
|
||||
explorer = TopExp_Explorer(shape, TopAbs_FACE)
|
||||
while explorer.More():
|
||||
@@ -626,15 +635,21 @@ class OCGeometryKernel(GeometryKernel):
|
||||
vertices_list.append([p.X(), p.Y(), p.Z()])
|
||||
|
||||
n_triangles = triangulation.NbTriangles()
|
||||
# REVERSED faces store triangle winding in the natural (surface)
|
||||
# orientation — we must flip it so the computed normals point
|
||||
# outward (away from solid interior). TopAbs_REVERSED = 1.
|
||||
reverse_winding = face.Orientation() == TopAbs_Orientation.TopAbs_REVERSED
|
||||
for i in range(1, n_triangles + 1):
|
||||
tri = triangulation.Triangle(i)
|
||||
faces_list.append(
|
||||
[
|
||||
tri.Value(1) - 1 + vertex_offset,
|
||||
tri.Value(2) - 1 + vertex_offset,
|
||||
tri.Value(3) - 1 + vertex_offset,
|
||||
]
|
||||
v0, v1, v2 = (
|
||||
tri.Value(1) - 1 + vertex_offset,
|
||||
tri.Value(2) - 1 + vertex_offset,
|
||||
tri.Value(3) - 1 + vertex_offset,
|
||||
)
|
||||
if reverse_winding:
|
||||
# Swap last two vertices to flip winding direction.
|
||||
v1, v2 = v2, v1
|
||||
faces_list.append([v0, v1, v2])
|
||||
|
||||
vertex_offset += n_vertices
|
||||
|
||||
|
||||
Reference in New Issue
Block a user