system: fix plane alignment redundancy handling
This commit is contained in:
parent
a27d387e34
commit
f881db0229
36
system.py
36
system.py
|
@ -75,7 +75,7 @@ def _makePropInfo(name,tp,doc='',default=None):
|
||||||
PropertyInfo(System,name,tp,doc,group='Solver',default=default)
|
PropertyInfo(System,name,tp,doc,group='Solver',default=default)
|
||||||
|
|
||||||
_makePropInfo('Verbose','App::PropertyBool')
|
_makePropInfo('Verbose','App::PropertyBool')
|
||||||
_makePropInfo('AutoRelax','App::PropertyBool')
|
_makePropInfo('AutoRelax','App::PropertyBool',default=True)
|
||||||
|
|
||||||
class SystemBase(with_metaclass(System, object)):
|
class SystemBase(with_metaclass(System, object)):
|
||||||
_id = 0
|
_id = 0
|
||||||
|
@ -150,13 +150,12 @@ class SystemExtension(object):
|
||||||
if warn:
|
if warn:
|
||||||
logger.warn('skip redundant ' + msg, frame=1)
|
logger.warn('skip redundant ' + msg, frame=1)
|
||||||
else:
|
else:
|
||||||
logger.info('auto relax ' + msg, frame=1)
|
logger.debug('auto relax ' + msg, frame=1)
|
||||||
|
|
||||||
def countConstraints(self,increment,limit,*names):
|
def _countConstraints(self,increment,limit,*names):
|
||||||
first,second = self.firstInfo,self.secondInfo
|
first,second = self.firstInfo,self.secondInfo
|
||||||
if not first or not second:
|
if not first or not second:
|
||||||
return 0
|
return []
|
||||||
count = 0
|
|
||||||
for name in names:
|
for name in names:
|
||||||
cstrs = first.CstrMap.get(second.Part,{}).get(name,None)
|
cstrs = first.CstrMap.get(second.Part,{}).get(name,None)
|
||||||
if not cstrs:
|
if not cstrs:
|
||||||
|
@ -165,15 +164,16 @@ class SystemExtension(object):
|
||||||
first.Part,{}).setdefault(name,[])
|
first.Part,{}).setdefault(name,[])
|
||||||
else:
|
else:
|
||||||
cstrs = second.CstrMap.get(first.Part,{}).get(name,[])
|
cstrs = second.CstrMap.get(first.Part,{}).get(name,[])
|
||||||
if increment:
|
|
||||||
cstrs += [None]*increment
|
cstrs += [None]*increment
|
||||||
count += len(cstrs)
|
count = len(cstrs)
|
||||||
if limit and count>=limit:
|
if limit and count>=limit:
|
||||||
|
self.reportRedundancy(count>limit)
|
||||||
|
return cstrs
|
||||||
|
|
||||||
|
def countConstraints(self,increment,limit,*names):
|
||||||
|
count = len(self._countConstraints(increment,limit,*names))
|
||||||
if count>limit:
|
if count>limit:
|
||||||
self.reportRedundancy(True)
|
|
||||||
return -1
|
return -1
|
||||||
elif count>len(cstrs):
|
|
||||||
self.reportRedundancy()
|
|
||||||
return count
|
return count
|
||||||
|
|
||||||
def addPlaneCoincident(
|
def addPlaneCoincident(
|
||||||
|
@ -226,11 +226,17 @@ class SystemExtension(object):
|
||||||
group = self.GroupHandle
|
group = self.GroupHandle
|
||||||
h = []
|
h = []
|
||||||
if self.relax:
|
if self.relax:
|
||||||
count = self.countConstraints(2 if lockAngle else 1,3,'Alignment')
|
dof = 2 if lockAngle else 1
|
||||||
if count < 0:
|
cstrs = self._countConstraints(dof,3,'Alignment')
|
||||||
|
count = len(cstrs)
|
||||||
|
if count > 3:
|
||||||
return
|
return
|
||||||
|
if count == 1:
|
||||||
|
cstrs[0] = pln1.entity
|
||||||
else:
|
else:
|
||||||
count = 0
|
count = 0
|
||||||
|
cstrs = None
|
||||||
|
|
||||||
if d:
|
if d:
|
||||||
h.append(self.addPointPlaneDistance(
|
h.append(self.addPointPlaneDistance(
|
||||||
d, pln2.origin.entity, pln1.entity, group=group))
|
d, pln2.origin.entity, pln1.entity, group=group))
|
||||||
|
@ -238,10 +244,12 @@ class SystemExtension(object):
|
||||||
h.append(self.addPointInPlane(
|
h.append(self.addPointInPlane(
|
||||||
pln2.origin.entity, pln1.entity,group=group))
|
pln2.origin.entity, pln1.entity,group=group))
|
||||||
if count<=2:
|
if count<=2:
|
||||||
|
n1,n2 = pln1.normal,pln2.normal
|
||||||
if count==2 and not lockAngle:
|
if count==2 and not lockAngle:
|
||||||
self.reportRedundancy()
|
self.reportRedundancy()
|
||||||
self.setOrientation(h, lockAngle, yaw, pitch, roll,
|
h.append(self.addParallel(n2.entity,n1.entity,cstrs[0],group))
|
||||||
pln1.normal, pln2.normal, group)
|
else:
|
||||||
|
self.setOrientation(h,lockAngle,yaw,pitch,roll,n1,n2,group)
|
||||||
return h
|
return h
|
||||||
|
|
||||||
def addAxialAlignment(self,lockAngle,yaw,pitch,roll,ln1,ln2,group=0):
|
def addAxialAlignment(self,lockAngle,yaw,pitch,roll,ln1,ln2,group=0):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user