plugin dialog blocFissure general

This commit is contained in:
Paul RASCLE 2016-02-12 23:21:05 +01:00
parent db1bdbcddc
commit 330463b252
4 changed files with 451 additions and 45 deletions

View File

@ -26,6 +26,7 @@ SET(plugin_SCRIPTS
__init__.py
fissureCoude_ihm.py
fissureCoude_plugin.py
fissureGenerale_plugin.py
dialogFissureCoude.dic
)

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>631</width>
<height>490</height>
<height>560</height>
</rect>
</property>
<property name="windowTitle">
@ -16,51 +16,13 @@
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Insertion d'un maillage de fissure dans un maillage hexaédrique sain.&lt;/p&gt;&lt;p&gt;Le maillage sain est fourni sous forme de fichier Med.&lt;/p&gt;&lt;p&gt;La face de fissure est décrite par une géométrie dans un fichier brep.&lt;/p&gt;&lt;p&gt;La ou les arêtes de fond de fissure sont données par leurs index dans la face de fissure.&lt;/p&gt;&lt;p&gt;La procédure identfie des mailles saines à enlever et remailler, construit un maillage régulier rayonnant autour de la ligne de fond de fissure, reconstitue les faces externes en triangles, complète la zone à remailler en tétraèdres.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>maillage sain et géometries de fissure</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pb_maillage">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;sélection du fichier med du maillage sain (hexaèdres)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>maillage sain</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_maillage">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;fichier med du maillage sain (hexaèdres)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pb_facefiss">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;sélection du fichier brep (géométrie) décrivant la face de fissure.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>face fissure</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_facefiss">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;fichier brep (géométrie) décrivant la face de fissure.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -92,12 +54,50 @@
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="le_maillage">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;fichier med du maillage sain (hexaèdres)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pb_facefiss">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;sélection du fichier brep (géométrie) décrivant la face de fissure.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>face fissure</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_facefiss">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;fichier brep (géométrie) décrivant la face de fissure.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pb_maillage">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;sélection du fichier med du maillage sain (hexaèdres)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>maillage sain</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<zorder></zorder>
<zorder></zorder>
</widget>
</item>
<item row="1" column="0" colspan="2">
<item>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
@ -119,6 +119,9 @@
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;La zone remaillée contiendra toutes les mailles du maillage sain à une distance de la face de fissure inférieure à cette valeur.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="decimals">
<number>5</number>
</property>
</widget>
</item>
</layout>
@ -156,6 +159,9 @@
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pour faciliter la détermination de la zone à remailler, il faut des points sur la face de fissure, suffisament resserrés, en relation avec la taille des mailles du maillage sain.&lt;/p&gt;&lt;p&gt;Ces points sont obtenus par pré maillage de la face de fissure, en triangles. On donne la taille min et max des triangles.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="decimals">
<number>5</number>
</property>
<property name="maximum">
<double>1000000.000000000000000</double>
</property>
@ -173,6 +179,9 @@
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pour faciliter la détermination de la zone à remailler, il faut des points sur la face de fissure, suffisament resserrés, en relation avec la taille des mailles du maillage sain.&lt;/p&gt;&lt;p&gt;Ces points sont obtenus par pré maillage de la face de fissure, en triangles. On donne la taille min et max des triangles.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="decimals">
<number>5</number>
</property>
<property name="maximum">
<double>1000000.000000000000000</double>
</property>
@ -225,6 +234,9 @@
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pipe rayonnant construit sur le fond de fissure :&lt;/p&gt;&lt;p&gt;Rayon du pipe.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="decimals">
<number>5</number>
</property>
<property name="maximum">
<double>1000000.000000000000000</double>
</property>
@ -242,6 +254,9 @@
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pipe rayonnant construit sur le fond de fissure :&lt;/p&gt;&lt;p&gt;Longueur des mailles le long de la ligne de fond de fissure.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="decimals">
<number>5</number>
</property>
<property name="maximum">
<double>1000000.000000000000000</double>
</property>
@ -329,6 +344,9 @@
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Faces externes de la zone à remailler.&lt;/p&gt;&lt;p&gt;Mailage en triangles : valeur cible des arêtes.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="decimals">
<number>5</number>
</property>
<property name="maximum">
<double>1000000.000000000000000</double>
</property>
@ -368,7 +386,7 @@
</item>
</layout>
</item>
<item row="2" column="1">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -381,8 +399,90 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lb_calcul">
<property name="font">
<font>
<pointsize>24</pointsize>
</font>
</property>
<property name="text">
<string>--- Calcul en cours ---</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="pb_reset">
<property name="toolTip">
<string>réinitialisation de tous les paramètres à leur valeur par défaut</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_valPrec">
<property name="toolTip">
<string>réinitialisation de tous les paramètres à leur valeur de la précédente éxécution</string>
</property>
<property name="text">
<string>Précédent</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_recharger">
<property name="toolTip">
<string>réinitialisation des paramètres à partir d'un fichier préalablement sauvegardé</string>
</property>
<property name="text">
<string>Recharger</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_sauver">
<property name="toolTip">
<string>sauvegarde des paramètres dans un fichier à choisir</string>
</property>
<property name="text">
<string>Sauver</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">

View File

@ -0,0 +1,297 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2006-2015 EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
# if you already have plugins defined in a salome_plugins.py file, add this file at the end.
# if not, copy this file as ${HOME}/Plugins/smesh_plugins.py or ${APPLI}/Plugins/smesh_plugins.py
import sys, traceback
import math
from blocFissure import gmu
from blocFissure.gmu import initLog
#initLog.setDebug()
initLog.setVerbose()
from blocFissure.gmu import geomsmesh
from blocFissure.gmu.casStandard import casStandard
def fissureGeneraleDlg(context):
# get context study, studyId, salomeGui
study = context.study
studyId = context.studyId
sg = context.sg
import os
#import subprocess
#import tempfile
from PyQt4 import QtCore
from PyQt4 import QtGui
from PyQt4.QtGui import QFileDialog
from PyQt4.QtGui import QMessageBox
from PyQt4.QtGui import QPalette
from PyQt4.QtGui import QColor
from fissureGenerale_ui import Ui_Dialog
class fissureGeneraleDialog(QtGui.QDialog):
def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.blackPalette = self.ui.dsb_influence.palette()
self.redPalette = QPalette()
self.redPalette.setColor(QPalette.Text, QColor(255,0,0))
self.NOK = False
self.initDefaut()
self.initDialog(self.defaut)
self.ui.lb_calcul.hide()
# Connect up the buttons.
self.connect(self.ui.pb_valPrec, QtCore.SIGNAL("clicked()"),
self.readValPrec)
self.connect(self.ui.pb_reset, QtCore.SIGNAL("clicked()"),
self.resetVal)
self.connect(self.ui.pb_recharger, QtCore.SIGNAL("clicked()"),
self.recharger)
self.connect(self.ui.pb_sauver, QtCore.SIGNAL("clicked()"),
self.sauver)
self.connect(self.ui.pb_maillage, QtCore.SIGNAL("clicked()"),
self.selectMaillage)
self.connect(self.ui.pb_facefiss, QtCore.SIGNAL("clicked()"),
self.selectFacefiss)
self.disconnect(self.ui.bb_OkCancel, QtCore.SIGNAL("accepted()"), self.accept)
self.connect(self.ui.bb_OkCancel, QtCore.SIGNAL("accepted()"),
self.execute)
def initDefaut(self):
self.defaut = dict(
nomCas = 'angleCube',
maillageSain = os.path.join(gmu.pathBloc, 'materielCasTests/CubeAngle.med'),
brepFaceFissure = os.path.join(gmu.pathBloc, "materielCasTests/CubeAngleFiss.brep"),
edgeFissIds = [4],
lgInfluence = 20,
meshBrep = (5,10),
rayonPipe = 5,
lenSegPipe = 2.5,
nbSegRad = 5,
nbSegCercle = 32,
areteFaceFissure = 10)
def initDialog(self, dico):
self.ui.le_maillage.setText(dico['maillageSain'])
self.ui.le_facefiss.setText(dico['brepFaceFissure'])
self.ui.le_fondfiss.setText(str(dico['edgeFissIds']))
self.ui.dsb_influence.setValue(dico['lgInfluence'])
self.ui.dsb_meshBrepMin.setValue(dico['meshBrep'][0])
self.ui.dsb_meshBrepMax.setValue(dico['meshBrep'][1])
self.ui.dsb_rayonPipe.setValue(dico['rayonPipe'])
self.ui.dsb_lenSegPipe.setValue(dico['lenSegPipe'])
self.ui.sb_couronnes.setValue(dico['nbSegRad'])
self.ui.sb_secteurs.setValue(dico['nbSegCercle'])
self.ui.dsb_areteFaceFissure.setValue(dico['areteFaceFissure'])
incomplet = self.testval(dico)
pass
def testval(self, dico):
incomplet = False
if not os.path.lexists(dico['maillageSain']):
self.ui.le_maillage.setPalette(self.redPalette)
incomplet = True
else:
self.ui.le_maillage.setPalette(self.blackPalette)
if not os.path.lexists(dico['brepFaceFissure']):
self.ui.le_facefiss.setPalette(self.redPalette)
incomplet = True
else:
self.ui.le_facefiss.setPalette(self.blackPalette)
edgeFissIdsOK=True
try:
l = dico['edgeFissIds']
for i in l:
if not isinstance(i, int):
print"not isinstance(i, int)"
incomplet = True
edgeFissIdsOK=False
break
except:
print "except eval"
incomplet = True
edgeFissIdsOK=False
if edgeFissIdsOK:
self.ui.le_fondfiss.setPalette(self.blackPalette)
else:
self.ui.le_fondfiss.setPalette(self.redPalette)
if dico['meshBrep'][0] == 0:
self.ui.dsb_meshBrepMin.setPalette(self.redPalette)
incomplet = True
else:
self.ui.dsb_meshBrepMin.setPalette(self.blackPalette)
if dico['meshBrep'][1] == 0:
self.ui.dsb_meshBrepMax.setPalette(self.redPalette)
incomplet = True
else:
self.ui.dsb_meshBrepMax.setPalette(self.blackPalette)
if dico['rayonPipe'] == 0:
self.ui.dsb_rayonPipe.setPalette(self.redPalette)
incomplet = True
else:
self.ui.dsb_rayonPipe.setPalette(self.blackPalette)
if dico['lenSegPipe'] == 0:
self.ui.dsb_lenSegPipe.setPalette(self.redPalette)
incomplet = True
else:
self.ui.dsb_lenSegPipe.setPalette(self.blackPalette)
if dico['areteFaceFissure'] == 0:
self.ui.dsb_areteFaceFissure.setPalette(self.redPalette)
incomplet = True
else:
self.ui.dsb_areteFaceFissure.setPalette(self.blackPalette)
print "incomplet: ", incomplet
return incomplet
def fileDefault(self):
filedef = os.path.expanduser("~/.config/salome/dialogFissureGenerale.dic")
print filedef
return filedef
def writeDefault(self, dico):
filedef = self.fileDefault()
f = open(filedef, 'w')
f.write(str(dico))
f.close()
def readValPrec(self):
filedef = self.fileDefault()
if os.path.exists(filedef):
f = open(filedef, 'r')
txt = f.read()
dico = eval(txt)
print dico
self.initDialog(dico)
def resetVal(self):
#self.initDefaut()
self.initDialog(self.defaut)
def sauver(self):
print "sauver"
fileDiag = QFileDialog(self)
fileDiag.setFileMode(QFileDialog.AnyFile)
fileDiag.setNameFilter("Parametres *.dic (*.dic)")
fileDiag.setViewMode(QFileDialog.List)
if fileDiag.exec_() :
fileNames = fileDiag.selectedFiles()
filedef = fileNames[0]
dico = self.creeDico()
f = open(filedef, 'w')
f.write(str(dico))
f.close()
def recharger(self):
print "recharger"
fileDiag = QFileDialog(self)
fileDiag.setFileMode(QFileDialog.ExistingFile)
fileDiag.setNameFilter("Parametres *.dic (*.dic)")
fileDiag.setViewMode(QFileDialog.Detail)
if fileDiag.exec_() :
fileNames = fileDiag.selectedFiles()
filedef = fileNames[0]
print filedef
if os.path.exists(filedef):
f = open(filedef, 'r')
txt = f.read()
dico = eval(txt)
print dico
self.initDialog(dico)
def selectMaillage(self):
fileDiag = QFileDialog(self)
fileDiag.setFileMode(QFileDialog.ExistingFile)
fileDiag.setNameFilter("Maillage *.med (*.med)")
fileDiag.setViewMode(QFileDialog.Detail)
if fileDiag.exec_() :
fileNames = fileDiag.selectedFiles()
filedef = fileNames[0]
print filedef
self.ui.le_maillage.setText(filedef)
def selectFacefiss(self):
fileDiag = QFileDialog(self)
fileDiag.setFileMode(QFileDialog.ExistingFile)
fileDiag.setNameFilter("Face fissure *.brep (*.brep)")
fileDiag.setViewMode(QFileDialog.Detail)
if fileDiag.exec_() :
fileNames = fileDiag.selectedFiles()
filedef = fileNames[0]
print filedef
self.ui.le_facefiss.setText(filedef)
def creeDico(self):
dico = dict(
maillageSain = str(self.ui.le_maillage.text()),
brepFaceFissure = str(self.ui.le_facefiss.text()),
edgeFissIds = eval(str(self.ui.le_fondfiss.text())),
lgInfluence = self.ui.dsb_influence.value(),
meshBrep = [self.ui.dsb_meshBrepMin.value(),self.ui.dsb_meshBrepMax.value()],
rayonPipe = self.ui.dsb_rayonPipe.value(),
lenSegPipe = self.ui.dsb_lenSegPipe.value(),
nbSegRad = self.ui.sb_couronnes.value(),
nbSegCercle = self.ui.sb_secteurs.value(),
areteFaceFissure = self.ui.dsb_areteFaceFissure.value()
)
print dico
return dico
def checkValues(self):
return self.NOK
def execute(self):
dico = self.creeDico()
NOK = self.testval(dico)
if not(NOK):
self.writeDefault(dico)
self.ui.lb_calcul.show()
execInstance = casStandard(dico)
self.NOK = NOK
self.accept()
pass
# ----------------------------------------------------------------------------
window = fissureGeneraleDialog()
retry = True
while(retry):
retry = False
window.exec_()
result = window.result()
if result:
# dialog accepted
print "dialog accepted, check"
retry = window.checkValues()
else:
print "dialog rejected, exit"
pass

View File

@ -66,6 +66,14 @@ try:
except:
salome_pluginsmanager.logger.info('ERROR: Meshed Pipe with a crack plug-in is unavailable')
pass
try:
from blocFissure.ihm.fissureGenerale_plugin import fissureGeneraleDlg
salome_pluginsmanager.AddFunction('Add a crack in a mesh',
'Insert a crack in an hexahedral mesh with blocFissure tool',
fissureGeneraleDlg)
except:
salome_pluginsmanager.logger.info('ERROR: Meshed Pipe with a crack plug-in is unavailable')
pass
# ZCracks plugin requires the module EFICAS to be installed
# thus it is first tested if this module is available before