Fixed the rotateAndCopy function by checking coincidence of vertices between wires. Still need to do some manual testing and add tests before merging.

This commit is contained in:
Jeremy Wright 2015-04-17 00:04:16 -04:00
parent 1961c22268
commit 08c36a3947
2 changed files with 15 additions and 10 deletions

View File

@ -1261,7 +1261,7 @@ class Workplane(CQ):
#attempt to consolidate wires together. #attempt to consolidate wires together.
consolidated = n.consolidateWires() consolidated = n.consolidateWires()
rotatedWires = self.plane.rotateShapes(consolidated.wires().vals(),matrix) rotatedWires = self.plane.rotateShapes(consolidated.wires().vals(), matrix)
for w in rotatedWires: for w in rotatedWires:
consolidated.objects.append(w) consolidated.objects.append(w)

View File

@ -487,6 +487,11 @@ class Plane:
for w in listOfShapes: for w in listOfShapes:
mirrored = w.transformGeometry(rotationMatrix.wrapped) mirrored = w.transformGeometry(rotationMatrix.wrapped)
# If the first vertex of the second wire is not coincident with the first or last vertices of the first wire
# we have to fix the wire so that it will mirror correctly
if (mirrored.wrapped.Vertexes[0].X == w.wrapped.Vertexes[0].X and mirrored.wrapped.Vertexes[0].Y == w.wrapped.Vertexes[0].Y and mirrored.wrapped.Vertexes[0].Z == w.wrapped.Vertexes[0].Z) or (mirrored.wrapped.Vertexes[0].X == w.wrapped.Vertexes[-1].X and mirrored.wrapped.Vertexes[0].Y == w.wrapped.Vertexes[-1].Y and mirrored.wrapped.Vertexes[0].Z == w.wrapped.Vertexes[-1].Z):
resultWires.append(mirrored)
else:
# Make sure that our mirrored edges meet up and are ordered properly # Make sure that our mirrored edges meet up and are ordered properly
aEdges = w.wrapped.Edges aEdges = w.wrapped.Edges
aEdges.extend(mirrored.wrapped.Edges) aEdges.extend(mirrored.wrapped.Edges)
@ -500,12 +505,12 @@ class Plane:
def _calcTransforms(self): def _calcTransforms(self):
""" """
Computes transformation martrices to convert betwene local and global coordinates Computes transformation martrices to convert between local and global coordinates
""" """
#r is the forward transformation matrix from world to local coordinates #r is the forward transformation matrix from world to local coordinates
#ok i will be really honest-- i cannot understand exactly why this works #ok i will be really honest-- i cannot understand exactly why this works
#something bout the order of the transaltion and the rotation. #something bout the order of the translation and the rotation.
# the double-inverting is strange, and i dont understand it. # the double-inverting is strange, and I don't understand it.
r = FreeCAD.Base.Matrix() r = FreeCAD.Base.Matrix()
#forward transform must rotate and adjust for origin #forward transform must rotate and adjust for origin