system: improve auto relax multiple PlaneCoincidence
This commit is contained in:
parent
c3380e602d
commit
6bb16b5550
|
@ -125,6 +125,7 @@ class SystemExtension(object):
|
||||||
self.firstInfo = None
|
self.firstInfo = None
|
||||||
self.secondInfo = None
|
self.secondInfo = None
|
||||||
self.relax = False
|
self.relax = False
|
||||||
|
self.coincidences = {}
|
||||||
|
|
||||||
def checkRedundancy(self,obj,firstInfo,secondInfo):
|
def checkRedundancy(self,obj,firstInfo,secondInfo):
|
||||||
self.cstrObj,self.firstInfo,self.secondInfo=obj,firstInfo,secondInfo
|
self.cstrObj,self.firstInfo,self.secondInfo=obj,firstInfo,secondInfo
|
||||||
|
@ -189,6 +190,10 @@ class SystemExtension(object):
|
||||||
if count < 0:
|
if count < 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if count == 1:
|
||||||
|
self.coincidences[(self.firstInfo.Part, self.secondInfo.Part)] = pln1
|
||||||
|
self.coincidences[(self.secondInfo.Part, self.firstInfo.Part)] = pln2
|
||||||
|
|
||||||
if d or dx or dy:
|
if d or dx or dy:
|
||||||
dx,dy,d = pln2.normal.rot.multVec(FreeCAD.Vector(dx,dy,d))
|
dx,dy,d = pln2.normal.rot.multVec(FreeCAD.Vector(dx,dy,d))
|
||||||
v = pln2.origin.vector+FreeCAD.Vector(dx,dy,d)
|
v = pln2.origin.vector+FreeCAD.Vector(dx,dy,d)
|
||||||
|
@ -200,23 +205,21 @@ class SystemExtension(object):
|
||||||
|
|
||||||
if not lockAngle and count==2:
|
if not lockAngle and count==2:
|
||||||
# if there is already some other plane coincident constraint set for
|
# if there is already some other plane coincident constraint set for
|
||||||
# this pair of parts, we reduce this second constraint to either a
|
# this pair of parts, we reduce this second constraint to a 2D
|
||||||
# points horizontal or vertical constraint, i.e. reduce the
|
# PointOnLine. The line is formed by the first part's two elements
|
||||||
# constraining DOF down to 1.
|
# in the previous and the current constraint. The point is taken
|
||||||
|
# from the element of the second part of the current constraint.
|
||||||
|
# The projection plane is taken from the element of the first part
|
||||||
|
# of the current constraint.
|
||||||
#
|
#
|
||||||
# We project the initial points to the first element plane, and
|
# This 2D PointOnLine effectively reduce the second PlaneCoincidence
|
||||||
# check for differences in x and y components of the points to
|
# constraining DOF down to 1.
|
||||||
# determine whether to use horizontal or vertical constraint.
|
prev = self.coincidences.get(
|
||||||
rot = pln1.normal.pla.Rotation.multiply(pln1.normal.rot)
|
(self.firstInfo.Part, self.secondInfo.Part))
|
||||||
v1 = pln1.normal.pla.multVec(pln1.origin.vector)
|
ln = self.addLineSegment(prev.origin.entity,
|
||||||
v2 = pln2.normal.pla.multVec(v)
|
pln1.origin.entity, group=self.firstInfo.Group)
|
||||||
v1,v2 = project2D(rot, v1, v2)
|
h.append(self.addPointOnLine(
|
||||||
if abs(v1.x-v2.x) < abs(v1.y-v2.y):
|
pln2.origin.entity, ln, pln1.entity, group=group))
|
||||||
h.append(self.addPointsHorizontal(
|
|
||||||
pln1.origin.entity, e, pln1.entity, group=group))
|
|
||||||
else:
|
|
||||||
h.append(self.addPointsVertical(
|
|
||||||
pln1.origin.entity, e, pln1.entity, group=group))
|
|
||||||
return h
|
return h
|
||||||
|
|
||||||
h.append(self.addPointsCoincident(pln1.origin.entity, e, group=group))
|
h.append(self.addPointsCoincident(pln1.origin.entity, e, group=group))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user