Merge remote-tracking branch 'refs/remotes/upstream/master' into add-simplify

This commit is contained in:
hyOzd 2015-08-06 22:06:23 +03:00
commit 299ecf5cf5
3 changed files with 14 additions and 5 deletions

BIN
.coverage

Binary file not shown.

View File

@ -684,8 +684,7 @@ class CQ(object):
endVec = Vector(axisEndPoint)
def _rot(obj):
# TODO: compute the weighted average instead of using the first solid
startPt = obj.Solids()[0].Center()
startPt = obj.Center()
endPt = startPt + endVec
return obj.rotate(startPt, endPt, angleDegrees)

View File

@ -185,7 +185,18 @@ class Shape(object):
return BoundBox(self.wrapped.BoundBox)
def Center(self):
return Vector(self.wrapped.CenterOfMass)
# A Part.Shape object doesn't have the CenterOfMass function, but it's wrapped Solid(s) does
if isinstance(self.wrapped, FreeCADPart.Shape):
# If there are no Solids, we're probably dealing with a Face or something similar
if len(self.Solids()) == 0:
return Vector(self.wrapped.CenterOfMass)
else:
# TODO: compute the weighted average instead of using the first solid
return Vector(self.Solids()[0].wrapped.CenterOfMass)
elif isinstance(self.wrapped, FreeCADPart.Solid):
return Vector(self.wrapped.CenterOfMass)
else:
raise ValueError("Cannot find the center of %s object type" % str(type(self.Solids()[0].wrapped)))
def Closed(self):
return self.wrapped.Closed
@ -851,8 +862,7 @@ class Compound(Shape):
self.wrapped = obj
def Center(self):
# TODO: compute the weighted average instead of the first solid
return self.Solids()[0].Center()
return self.Center()
@classmethod
def makeCompound(cls, listOfShapes):