Got a mirror fix working for the T-slot use case, but it broke the OCC bottle example.
This commit is contained in:
parent
cde33d8204
commit
1961c22268
|
@ -17,9 +17,10 @@
|
|||
License along with this library; If not, see <http://www.gnu.org/licenses/>
|
||||
"""
|
||||
|
||||
import math,sys
|
||||
import math
|
||||
import cadquery
|
||||
import FreeCAD
|
||||
#Turns out we don't need the Part module here.
|
||||
import Part as FreeCADPart
|
||||
|
||||
def sortWiresByBuildOrder(wireList,plane,result=[]):
|
||||
"""
|
||||
|
@ -403,9 +404,9 @@ class Plane:
|
|||
correctly.
|
||||
|
||||
"""
|
||||
if isinstance(obj,Vector):
|
||||
if isinstance(obj, Vector):
|
||||
return Vector(self.fG.multiply(obj.wrapped))
|
||||
elif isinstance(obj,Shape):
|
||||
elif isinstance(obj, cadquery.Shape):
|
||||
return obj.transformShape(self.rG)
|
||||
else:
|
||||
raise ValueError("Dont know how to convert type %s to local coordinates" % str(type(obj)))
|
||||
|
@ -464,7 +465,7 @@ class Plane:
|
|||
newP= Plane(self.origin,newXdir,newZdir)
|
||||
return newP
|
||||
|
||||
def rotateShapes(self,listOfShapes,rotationMatrix):
|
||||
def rotateShapes(self, listOfShapes, rotationMatrix):
|
||||
"""
|
||||
rotate the listOfShapes by the rotationMatrix supplied.
|
||||
@param listOfShapes is a list of shape objects
|
||||
|
@ -480,12 +481,19 @@ class Plane:
|
|||
#There might be a better way, but to do this rotation takes 3 steps
|
||||
#transform geometry to local coordinates
|
||||
#then rotate about x
|
||||
#then transform back to global coordiante
|
||||
#then transform back to global coordinates
|
||||
|
||||
resultWires = []
|
||||
for w in listOfShapes:
|
||||
mirrored = w.transformGeometry(rotationMatrix.wrapped)
|
||||
resultWires.append(mirrored)
|
||||
|
||||
# Make sure that our mirrored edges meet up and are ordered properly
|
||||
aEdges = w.wrapped.Edges
|
||||
aEdges.extend(mirrored.wrapped.Edges)
|
||||
comp = FreeCADPart.Compound(aEdges)
|
||||
mirroredWire = comp.connectEdgesToWires(False).Wires[0]
|
||||
|
||||
resultWires.append(cadquery.Shape.cast(mirroredWire))
|
||||
|
||||
return resultWires
|
||||
|
||||
|
|
|
@ -3,43 +3,42 @@ import unittest
|
|||
import sys
|
||||
import os
|
||||
|
||||
#from cadquery.freecad_impl.verutil import fc_import
|
||||
#FreeCAD = fc_import("FreeCAD")
|
||||
#import cadquery.freecad_impl
|
||||
import FreeCAD
|
||||
|
||||
# P = fc_import("FreeCAD.Part")
|
||||
# V = fc_import("FreeCAD").Base.Vector
|
||||
|
||||
import Part as P
|
||||
from FreeCAD import Vector as V
|
||||
|
||||
|
||||
def readFileAsString(fileName):
|
||||
f= open(fileName,'r')
|
||||
f= open(fileName, 'r')
|
||||
s = f.read()
|
||||
f.close()
|
||||
return s
|
||||
|
||||
def writeStringToFile(strToWrite,fileName):
|
||||
f = open(fileName,'w')
|
||||
|
||||
def writeStringToFile(strToWrite, fileName):
|
||||
f = open(fileName, 'w')
|
||||
f.write(strToWrite)
|
||||
f.close()
|
||||
|
||||
|
||||
def makeUnitSquareWire():
|
||||
return Solid.cast(P.makePolygon([V(0,0,0),V(1,0,0),V(1,1,0),V(0,1,0),V(0,0,0)]))
|
||||
return Solid.cast(P.makePolygon([V(0, 0, 0), V(1, 0, 0), V(1, 1, 0), V(0, 1, 0), V(0, 0, 0)]))
|
||||
|
||||
|
||||
def makeUnitCube():
|
||||
return makeCube(1.0)
|
||||
|
||||
|
||||
def makeCube(size):
|
||||
return Solid.makeBox(size,size,size)
|
||||
return Solid.makeBox(size, size, size)
|
||||
|
||||
|
||||
def toTuple(v):
|
||||
"convert a vector or a vertex to a 3-tuple: x,y,z"
|
||||
"""convert a vector or a vertex to a 3-tuple: x,y,z"""
|
||||
pnt = v
|
||||
if type(v) == FreeCAD.Base.Vector:
|
||||
return (v.Point.x,v.Point.y,v.Point.z)
|
||||
return (v.Point.x, v.Point.y, v.Point.z)
|
||||
elif type(v) == Vector:
|
||||
return v.toTuple()
|
||||
else:
|
||||
|
@ -48,8 +47,8 @@ def toTuple(v):
|
|||
|
||||
class BaseTest(unittest.TestCase):
|
||||
|
||||
def assertTupleAlmostEquals(self,expected,actual,places):
|
||||
for i,j in zip(actual,expected):
|
||||
self.assertAlmostEquals(i,j,places)
|
||||
def assertTupleAlmostEquals(self, expected, actual, places):
|
||||
for i, j in zip(actual, expected):
|
||||
self.assertAlmostEquals(i, j, places)
|
||||
|
||||
__all__ = [ 'TestCadObjects','TestCadQuery','TestCQSelectors','TestWorkplanes','TestExporters','TestCQSelectors','TestImporters']
|
||||
__all__ = ['TestCadObjects', 'TestCadQuery', 'TestCQSelectors', 'TestWorkplanes', 'TestExporters', 'TestCQSelectors', 'TestImporters']
|
||||
|
|
Loading…
Reference in New Issue
Block a user