[OpenSCAD] Fix projection for OCCT7.3
OCCT 7.3 did not work well when using a very large projection plane, so this commit reduces the plane size to the minimum required for the cut operation. It also performs some minor refactoring in anticipation of the implementation of the true projection feature, and it removes the last attempted fix, which proved unnecessary.
This commit is contained in:
@@ -434,15 +434,6 @@ class Twist:
|
||||
|
||||
auxiliary_spine = Part.makeHelix(pitch, height, radius, 0.0, left_handed)
|
||||
|
||||
# OCC versions before 7.5 had a problem with using a helix as the auxilliary spine, so approximate
|
||||
# it piecewise
|
||||
occ_version = Part.OCC_VERSION.split(".")
|
||||
if int(occ_version[0]) <= 7 and int(occ_version[1]) < 5:
|
||||
num_points = int(max(3,num_revolutions * 36)) # Every ten degrees is adequate
|
||||
wire = auxiliary_spine.Wires[0]
|
||||
points = wire.discretize(Number=num_points)
|
||||
auxiliary_spine = Part.makePolygon(points)
|
||||
|
||||
faces = [lower_face,upper_face]
|
||||
for wire1,wire2 in zip(lower_face.Wires,upper_face.Wires):
|
||||
pipe_shell = Part.BRepOffsetAPI.MakePipeShell(spine)
|
||||
|
||||
@@ -1322,25 +1322,27 @@ def p_polyhedron_action(p) :
|
||||
def p_projection_action(p) :
|
||||
'projection_action : projection LPAREN keywordargument_list RPAREN OBRACE block_list EBRACE'
|
||||
if printverbose: print('Projection')
|
||||
if p[3]['cut']=='true' :
|
||||
planedim=1e9 # large but finite
|
||||
#infinite planes look bad in the GUI
|
||||
planename='xy_plane_used_for_project_cut'
|
||||
obj=doc.addObject('Part::MultiCommon','projection_cut')
|
||||
plane = doc.getObject(planename)
|
||||
if not plane:
|
||||
plane=doc.addObject("Part::Plane",planename)
|
||||
plane.Length=planedim*2
|
||||
plane.Width=planedim*2
|
||||
plane.Placement = FreeCAD.Placement(FreeCAD.Vector(\
|
||||
-planedim,-planedim,0),FreeCAD.Rotation())
|
||||
if gui:
|
||||
plane.ViewObject.hide()
|
||||
|
||||
doc.recompute()
|
||||
bbox = p[6][0].Shape.BoundBox
|
||||
for shape in p[6]:
|
||||
bbox.add(shape.Shape.BoundBox)
|
||||
print (bbox)
|
||||
plane = doc.addObject("Part::Plane","xy_plane_used_for_projection")
|
||||
plane.Length = bbox.XLength
|
||||
plane.Width = bbox.YLength
|
||||
plane.Placement = FreeCAD.Placement(FreeCAD.Vector(\
|
||||
bbox.XMin,bbox.YMin,0),FreeCAD.Rotation())
|
||||
if gui:
|
||||
plane.ViewObject.hide()
|
||||
|
||||
if p[3]['cut'] == 'true' :
|
||||
obj = doc.addObject('Part::MultiCommon','projection_cut')
|
||||
if (len(p[6]) > 1):
|
||||
subobj = [fuse(p[6],"projection_cut_implicit_group")]
|
||||
else:
|
||||
subobj = p[6]
|
||||
obj.Shapes = [plane]+subobj
|
||||
obj.Shapes = [plane] + subobj
|
||||
if gui:
|
||||
subobj[0].ViewObject.hide()
|
||||
p[0] = [obj]
|
||||
@@ -1348,6 +1350,6 @@ def p_projection_action(p) :
|
||||
if gui and not FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/OpenSCAD").\
|
||||
GetBool('usePlaceholderForUnsupported'):
|
||||
from PySide import QtGui
|
||||
QtGui.QMessageBox.critical(None, translate('OpenSCAD',"Unsupported Function")+" : "+p[1],translate('OpenSCAD',"Press OK"))
|
||||
QtGui.QMessageBox.critical(None, translate('OpenSCAD',"Unsupported Function") + " : " + p[1],translate('OpenSCAD',"Press OK"))
|
||||
else:
|
||||
p[0] = [placeholder(p[1],p[6],p[3])]
|
||||
|
||||
Reference in New Issue
Block a user