changed prism to dprism and modified wire sorting

This commit is contained in:
adam-urbanczyk
2019-02-28 11:24:27 +01:00
parent 11ee24ee4a
commit 93b021c25d

View File

@ -111,7 +111,7 @@ from OCC.Core.Addons import (text_to_brep,
Font_FA_Italic, Font_FA_Italic,
Font_FA_Bold) Font_FA_Bold)
from OCC.Core.BRepFeat import BRepFeat_MakePrism from OCC.Core.BRepFeat import BRepFeat_MakePrism, BRepFeat_MakeDPrism
from math import pi, sqrt from math import pi, sqrt
@ -1439,25 +1439,39 @@ class Solid(Shape, Mixin3D):
return cls(builder.Shape()) return cls(builder.Shape())
def prism(self, basis, profile, depth=None, thruAll=True, additive=True): def dprism(self, basis, profiles, depth=None, taper=0, thruAll=True,
additive=True):
""" """
Make a prismatic feature (additive or subtractive) Make a prismatic feature (additive or subtractive)
:param basis: face to perfrom the operation on
:param profiles: list of profiles
:param depth: depth of the cut or extrusion
:param thruAll: cut thruAll
:return: a Solid object
""" """
face = Face.makeFromWires(profile) sorted_profiles = sortWiresByBuildOrder(profiles)
feat = BRepFeat_MakePrism(self.wrapped, shape = self.wrapped
basis.wrapped, basis = basis.wrapped
face.wrapped, for p in sorted_profiles:
basis.normalAt().wrapped, face = Face.makeFromWires(p[0],p[1:])
additive, feat = BRepFeat_MakeDPrism(shape,
False) face.wrapped,
basis,
#basis.normalAt().toDir(),
taper*DEG2RAD,
additive,
False)
if thruAll: if thruAll:
feat.PerformThruAll() feat.PerformThruAll()
else: else:
feat.Perform(depth) feat.Perform(depth)
return self.__class__(feat.Shape()) shape = feat.Shape()
return self.__class__(shape)
class Compound(Shape, Mixin3D): class Compound(Shape, Mixin3D):
""" """
@ -1499,7 +1513,7 @@ class Compound(Shape, Mixin3D):
# TODO this is likely not needed if sing PythonOCC.Core.correclty but we will see # TODO this is likely not needed if sing PythonOCC.Core.correclty but we will see
def sortWiresByBuildOrder(wireList, plane, result=[]): def sortWiresByBuildOrder(wireList, result=[]):
"""Tries to determine how wires should be combined into faces. """Tries to determine how wires should be combined into faces.
Assume: Assume: