This commit is contained in:
cvw 2013-04-26 14:24:18 +00:00
parent b1672f75ae
commit 6b258aaf7a
2 changed files with 111 additions and 148 deletions

View File

@ -59,7 +59,7 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
self.LE_ParamsFile.setText(self.paramsFile) self.LE_ParamsFile.setText(self.paramsFile)
self.LE_MeshFile.setText("") self.LE_MeshFile.setText("")
self.LE_MeshSmesh.setText("") self.LE_MeshSmesh.setText("")
self.resize(800, 500)
self.clean() self.clean()
def connecterSignaux(self) : def connecterSignaux(self) :
@ -75,7 +75,12 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
self.connect(self.LE_MeshFile,SIGNAL("returnPressed()"),self.meshFileNameChanged) self.connect(self.LE_MeshFile,SIGNAL("returnPressed()"),self.meshFileNameChanged)
self.connect(self.LE_ParamsFile,SIGNAL("returnPressed()"),self.paramsFileNameChanged) self.connect(self.LE_ParamsFile,SIGNAL("returnPressed()"),self.paramsFileNameChanged)
#QtCore.QObject.connect(self.checkBox, QtCore.SIGNAL('stateChanged(int)'), self.change)
self.connect(self.CB_FillHoles,SIGNAL("stateChanged(int)"),self.SP_minHoleSize.setEnabled)
self.connect(self.CB_computedToleranceDisplacement,SIGNAL("stateChanged(int)"),self.SP_toleranceDisplacement.setDisabled)
self.connect(self.CB_computedResolutionLength,SIGNAL("stateChanged(int)"),self.SP_resolutionLength.setDisabled)
self.connect(self.CB_computedOverlapDistance,SIGNAL("stateChanged(int)"),self.SP_overlapDistance.setDisabled)
def PBHelpPressed(self): def PBHelpPressed(self):
try : try :
mydir=os.environ['SMESH_ROOT_DIR'] mydir=os.environ['SMESH_ROOT_DIR']
@ -87,10 +92,10 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
def PBOKPressed(self): def PBOKPressed(self):
if not(self.PrepareLigneCommande()) : return if not(self.PrepareLigneCommande()): return
self.PBSavePressed(NomHypo=True) self.PBSavePressed(NomHypo=True)
maFenetre=MGCleanerMonViewText(self,self.commande) maFenetre=MGCleanerMonViewText(self,self.commande)
if os.path.isfile(self.fichierOut) :self.enregistreResultat() if os.path.isfile(self.fichierOut): self.enregistreResultat()
def enregistreResultat(self): def enregistreResultat(self):
import smesh import smesh
@ -127,9 +132,13 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
return True return True
def PBSavePressed(self,NomHypo=False): def PBSavePressed(self,NomHypo=False):
if NomHypo : text = '# Params for Hypothese : anHypo_MGCleaner_'+str(self.num - 1)+"\n" if NomHypo:
else : text = '# Save intermediate params \n' text = '# Params for Hypothese : anHypo_MGCleaner_'+str(self.num - 1)+"\n"
else:
text = '# Save intermediate params \n'
text += "# Params for mesh : " + self.LE_MeshSmesh.text() +'\n' text += "# Params for mesh : " + self.LE_MeshSmesh.text() +'\n'
"""
for RB in self.GBOptim.findChildren(QRadioButton,): for RB in self.GBOptim.findChildren(QRadioButton,):
if RB.isChecked()==True: if RB.isChecked()==True:
text+="Optimisation ='"+RB.text()+"'\n" text+="Optimisation ='"+RB.text()+"'\n"
@ -138,7 +147,6 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
if RB.isChecked()==True: if RB.isChecked()==True:
text+="Units ='"+RB.text()+"'\n" text+="Units ='"+RB.text()+"'\n"
text+='Chordal_Tolerance_Deviation='+str(self.SP_Tolerance.value())+'\n' text+='Chordal_Tolerance_Deviation='+str(self.SP_Tolerance.value())+'\n'
text+='Ridge_Detection=' + str(self.CB_Ridge.isChecked())+'\n' text+='Ridge_Detection=' + str(self.CB_Ridge.isChecked())+'\n'
text+='Split_Edge=' + str(self.CB_SplitEdge.isChecked())+'\n' text+='Split_Edge=' + str(self.CB_SplitEdge.isChecked())+'\n'
text+='Point_Smoothing=' + str(self.CB_Point.isChecked())+'\n' text+='Point_Smoothing=' + str(self.CB_Point.isChecked())+'\n'
@ -147,33 +155,31 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
text+='Maximum_Size=' + str(self.SP_MaxSize.value()) +'\n' text+='Maximum_Size=' + str(self.SP_MaxSize.value()) +'\n'
text+='Minimum_Size=' + str(self.SP_MaxSize.value()) +'\n' text+='Minimum_Size=' + str(self.SP_MaxSize.value()) +'\n'
text+='Mesh_Gradation=' + str(self.SP_Gradation.value())+'\n' text+='Mesh_Gradation=' + str(self.SP_Gradation.value())+'\n'
text+='Verbosity=' + str(self.SP_Verbosity.value())+'\n' text+='Verbosity=' + str(self.SP_Verbosity.value())+'\n'
text+='Memory=' + str(self.SP_Memory.value())+'\n'
text+='\n\n' text+='\n\n'
"""
try : try:
f=open(self.paramsFile,'a') f=open(self.paramsFile,'a')
except : except:
QMessageBox.warning( self, "File", "Unable to open "+self.paramsFile) QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile)
return return
try : try:
f.write(text) f.write(text)
except : except:
QMessageBox.warning( self, "File", "Unable to write "+self.paramsFile) QMessageBox.warning(self, "File", "Unable to write "+self.paramsFile)
return return
f.close() f.close()
def PBLoadPressed(self): def PBLoadPressed(self):
try : try:
f=open(self.paramsFile,'r') f=open(self.paramsFile,'r')
except : except :
QMessageBox.warning( self, "File", "Unable to open "+self.paramsFile) QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile)
return return
try : try:
text=f.read() text=f.read()
except : except :
QMessageBox.warning( self, "File", "Unable to read "+self.paramsFile) QMessageBox.warning(self, "File", "Unable to read "+self.paramsFile)
return return
f.close() f.close()
d={} d={}
@ -183,7 +189,7 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
RB.setChecked(True) RB.setChecked(True)
break break
for RB in self.GBUnit.findChildren(QRadioButton,): for RB in self.GBUnit.findChildren(QRadioButton,):
if d['Units']== RB.text(): if d['Units']==RB.text():
RB.setChecked(True) RB.setChecked(True)
break break
self.SP_Tolerance.setValue(d['Chordal_Tolerance_Deviation']) self.SP_Tolerance.setValue(d['Chordal_Tolerance_Deviation'])
@ -218,7 +224,6 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
self.LE_ParamsFile.setText(infile) self.LE_ParamsFile.setText(infile)
self.paramsFile=infile.toLatin1() self.paramsFile=infile.toLatin1()
def meshFileNameChanged(self): def meshFileNameChanged(self):
self.fichierIn=self.LE_MeshFile.text() self.fichierIn=self.LE_MeshFile.text()
if os.path.exists(self.fichierIn): return if os.path.exists(self.fichierIn): return
@ -268,61 +273,54 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
mg-cleaner.exe --in Porsche.mesh --out Porschefix.mesh --fix mg-cleaner.exe --in Porsche.mesh --out Porschefix.mesh --fix
mg-cleaner.exe --in Porsche.mesh --out PorscheNewfix.mesh --fix --resolution_length 0.03 mg-cleaner.exe --in Porsche.mesh --out PorscheNewfix.mesh --fix --resolution_length 0.03
""" """
self.commande="mg-cleaner.exe " #self.commande="mg-cleaner.exe --in " + self.fichierIn + " --out " + self.fichierOut + " --fix2pass"
verbosity=str(self.SP_Verbosity.value()) #return True
self.commande+="-v "+verbosity
for obj in self.mesRB.children():
try :
if obj.isChecked():
self.style=obj.objectName().remove(0,3)
self.style.replace("_","-")
break
except :
pass
self.commande+=" -O "+self.style.toLatin1()
if self.fichierIn=="" and self.MeshIn=="" : if self.fichierIn=="" and self.MeshIn=="" :
QMessageBox.critical(self, "Mesh", "select an input mesh") QMessageBox.critical(self, "Mesh", "select an input mesh")
return False return False
if self.MeshIn!="" : self.prepareFichier() if self.MeshIn!="" : self.prepareFichier()
if not (os.path.isfile(self.fichierIn)): if not (os.path.isfile(self.fichierIn)):
QMessageBox.critical(self, "File", "unable to read GMF Mesh in "+str(self.fichierIn)) QMessageBox.critical(self, "File", "unable to read GMF Mesh in "+str(self.fichierIn))
return False return False
self.commande="mg-cleaner.exe"
verbosity=str(self.SP_Verbosity.value())
self.commande+=" --verbose " + verbosity
self.commande+=" --in " + self.fichierIn
deb=os.path.splitext(self.fichierIn) deb=os.path.splitext(self.fichierIn)
self.fichierOut=deb[0]+'.d.meshb' self.fichierOut=deb[0] + "_fix.mesh"
self.commande+=" --out "+self.fichierOut
if self.RB_Absolute.isChecked()==True : if self.RB_Fix1.isChecked():
self.commande+=' -Dabsolute' self.commande+=" --fix1pass"
else : else:
self.commande+=' -Drelative' if self.RB_Fix2.isChecked():
self.commande+=',tolerance=%f'%self.SP_Tolerance.value() self.commande+=" --fix2pass"
if self.CB_Ridge.isChecked()==False : self.commande+=',nr' else:
if self.CB_Point.isChecked()==False : self.commande+=',ns' self.commande+=" --check"
if self.SP_Geomapp.value()!=0.04 : self.commande+=',geomapp=%f'%self.SP_Geomapp.value() if self.CB_PreserveTopology.isChecked():
if self.SP_Ridge.value()!=45.0 : self.commande+=',ridge=%f'%self.SP_Ridge.value() self.commande+=" --topology respect"
if self.SP_MaxSize.value()!=100 : self.commande+=',maxsize=%f'%self.SP_MaxSize.value() else:
if self.SP_MinSize.value()!=5 : self.commande+=',minsize=%f'%self.SP_MinSize.value() self.commande+=" --topology ignore"
if self.SP_Gradation.value()!=1.3 : self.commande+=',gradation=%f'%self.SP_MaxSize.value() if self.CB_FillHoles.isChecked(): #no fill holes default
if self.CB_SplitEdge.isChecked()==True : self.commande+=',splitedge=1' self.commande+=" --min_hole_size " + str(self.SP_minHoleSize.value())
if not self.CB_computedToleranceDisplacement.isChecked(): #computed default
if self.SP_Verbosity.value()!=3 : self.commande+=' -v %d'%self.SP_Verbosity.value() self.commande+=" --tolerance_displacement " + str(self.SP_toleranceDisplacement.value())
if self.SP_Memory.value()!=0 : self.commande+=' -m %d'%self.SP_Memory.value() if not self.CB_computedResolutionLength.isChecked(): #computed default
self.commande+=" --tolerance_displacement " + str(self.SP_resolutionLength.value())
self.commande+=" "+self.fichierIn self.commande+=" --folding_angle " + str(self.SP_foldingAngle.value())
if self.CB_RemeshPlanes.isChecked(): #no remesh default
#for the moment self.commande+=" --remesh_planes"
deb=os.path.splitext(self.fichierIn) if not self.CB_computedOverlapDistance.isChecked(): #computed default
self.fichierOut=deb[0]+'_fix.mesh' self.commande+=" --overlap_distance " + str(self.SP_overlapDistance.value())
self.commande="mg-cleaner.exe --in " + self.fichierIn + " --out " + self.fichierOut + " --fix" self.commande+=" --overlap_angle " + str(self.SP_overlapAngle.value())
return True return True
def clean(self): def clean(self):
self.RB_Check.setChecked(False) self.RB_Check.setChecked(False)
self.RB_Fix1.setChecked(False) self.RB_Fix1.setChecked(False)
self.RB_Fix2.setChecked(True) self.RB_Fix2.setChecked(True)
self.CB_Preserve.setChecked(False) self.CB_PreserveTopology.setChecked(False)
self.CB_FillHoles.setChecked(False) self.CB_FillHoles.setChecked(False)
self.CB_RemeshPlanes.setChecked(False) self.CB_RemeshPlanes.setChecked(False)
@ -330,7 +328,7 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
self.SP_toleranceDisplacement.setProperty("value", 0) self.SP_toleranceDisplacement.setProperty("value", 0)
self.SP_resolutionLength.setProperty("value", 0) self.SP_resolutionLength.setProperty("value", 0)
self.SP_foldingAngle.setProperty("value", 15) self.SP_foldingAngle.setProperty("value", 15)
self.SP_overlapdistance.setProperty("value", 0) self.SP_overlapDistance.setProperty("value", 0)
self.SP_overlapAngle.setProperty("value", 15) self.SP_overlapAngle.setProperty("value", 15)
self.SP_Verbosity.setProperty("value", 3) self.SP_Verbosity.setProperty("value", 3)
@ -351,3 +349,23 @@ def getDialog():
# __dialog.clean() # __dialog.clean()
return __dialog return __dialog
#
# ==============================================================================
# Basic use cases and unit test functions
# ==============================================================================
#
def TEST_MGCleanerMonPlugDialog():
print 'TEST_MGCleanerMonPlugDialog'
import sys
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QObject, SIGNAL, SLOT
app = QApplication(sys.argv)
QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
dlg=MGCleanerMonPlugDialog()
dlg.show()
sys.exit(app.exec_())
if __name__ == "__main__":
TEST_MGCleanerMonPlugDialog()

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>800</width>
<height>400</height> <height>500</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -221,7 +221,7 @@ Default is to fix with two passes.</string>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="CB_Preserve"> <widget class="QCheckBox" name="CB_PreserveTopology">
<property name="toolTip"> <property name="toolTip">
<string>Disables fixing operations which induce topology modifications. <string>Disables fixing operations which induce topology modifications.
Default is enable topology modifications. Default is enable topology modifications.
@ -640,7 +640,7 @@ Default is 15 degrees.</string>
</property> </property>
</widget> </widget>
#5 #5
<widget class="QDoubleSpinBox" name="SP_overlapdistance"> <widget class="QDoubleSpinBox" name="SP_overlapDistance">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>20</x>
@ -665,7 +665,7 @@ Default is 15 degrees.</string>
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="LA_overlapdistance"> <widget class="QLabel" name="LA_overlapDistance">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>130</x> <x>130</x>
@ -762,99 +762,44 @@ Default is 15 degrees.</string>
<property name="title"> <property name="title">
<string>MGCleaner Generic Options</string> <string>MGCleaner Generic Options</string>
</property> </property>
<widget class="QWidget" name="layoutWidget">
<widget class="QSpinBox" name="SP_Verbosity">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>40</x> <x>20</x>
<y>30</y> <y>30</y>
<width>441</width> <width>100</width>
<height>27</height> <height>25</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Verbosity Level</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>28</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="SP_Verbosity">
<property name="maximum"> <property name="maximum">
<number>10</number> <number>10</number>
</property> </property>
<property name="value"> <property name="value">
<number>7</number> <number>3</number>
</property> </property>
</widget> </widget>
</item>
</layout> <widget class="QLabel" name="label">
</widget>
<widget class="QWidget" name="layoutWidget_2">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>40</x> <x>130</x>
<y>70</y> <y>30</y>
<width>441</width> <width>600</width>
<height>27</height> <height>30</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <property name="toolTip">
<item> <string>sets the verbosity level.
<widget class="QLabel" name="label_6"> From 0 (no detail) to 10 (very detailed).
<property name="minimumSize"> Default is 3.</string>
<size> </property>
<width>225</width>
<height>25</height>
</size>
</property>
<property name="text"> <property name="text">
<string>zzz21</string> <string>Verbosity Level</string>
</property> </property>
</widget> </widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>28</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="SP_Memory">
<property name="toolTip">
<string>zzz22</string>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
<widget class="QGroupBox" name="groupBox_6"> <widget class="QGroupBox" name="groupBox_6">
<property name="geometry"> <property name="geometry">