- Improved sketching
This commit is contained in:
@@ -185,17 +185,28 @@ class OCGeometryKernel(GeometryKernel):
|
||||
) -> GeometryObject:
|
||||
"""Revolve a 2D sketch around an axis."""
|
||||
import cadquery as cq
|
||||
import math
|
||||
|
||||
cq_obj = self._get_cq_obj(sketch)
|
||||
# Get the OCC shape directly
|
||||
shape = self._get_shape(sketch)
|
||||
|
||||
if isinstance(cq_obj, cq.Workplane):
|
||||
solid = cq_obj.revolve(angle)
|
||||
else:
|
||||
face = cq.Face.makeFromWires(cq_obj)
|
||||
axis_vec = cq.Vector(*axis)
|
||||
origin_vec = cq.Vector(*origin)
|
||||
solid = face.revolve(axis_vec, origin_vec, angle)
|
||||
from OCP.BRepBuilderAPI import BRepBuilderAPI_MakeFace
|
||||
from OCP.gp import gp_Ax1, gp_Pnt, gp_Dir
|
||||
from OCP.BRepPrimAPI import BRepPrimAPI_MakeRevol
|
||||
|
||||
# Build a face from the wire/shape
|
||||
face_maker = BRepBuilderAPI_MakeFace(shape, False)
|
||||
face_maker.Build()
|
||||
face = face_maker.Face()
|
||||
|
||||
# Revolve the face around the axis
|
||||
revolve_axis = gp_Ax1(gp_Pnt(*origin), gp_Dir(*axis))
|
||||
angle_rad = math.radians(angle)
|
||||
revolver = BRepPrimAPI_MakeRevol(face, revolve_axis, angle_rad)
|
||||
revolver.Build()
|
||||
solid_shape = revolver.Shape()
|
||||
|
||||
solid = cq.Shape(solid_shape)
|
||||
return OCCGeometryObject(solid, {"type": "revolution"})
|
||||
|
||||
def loft(self, profiles: List[GeometryObject], ruled: bool = False) -> GeometryObject:
|
||||
@@ -673,7 +684,8 @@ class OCGeometryKernel(GeometryKernel):
|
||||
|
||||
explorer = TopExp_Explorer(shape, TopAbs_EDGE)
|
||||
while explorer.More():
|
||||
edge = explorer.Current()
|
||||
from OCP.TopoDS import TopoDS
|
||||
edge = TopoDS.Edge_s(explorer.Current())
|
||||
edge_points = discretize_edge(edge)
|
||||
|
||||
for i, pt in enumerate(edge_points):
|
||||
|
||||
Reference in New Issue
Block a user