some cleaning and update of the dialog box

This commit is contained in:
Renaud Nédélec 2014-11-04 16:56:54 +01:00
parent 0939da6429
commit 8a6296ea1a
6 changed files with 146 additions and 74 deletions

29
src/Tools/CMakeLists.txt Normal file
View File

@ -0,0 +1,29 @@
# Copyright (C) 2012-2014 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, or (at your option) any later version.
#
# 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
#
ADD_SUBDIRECTORY(t_shape)
# scripts / static
SET(plugin_SCRIPTS
geom_plugins.py
)
# --- rules ---
SALOME_INSTALL_SCRIPTS("${plugin_SCRIPTS}" ${SALOME_GEOM_INSTALL_PLUGINS})

View File

@ -35,9 +35,9 @@ def t_shape_fluid(context):
# gui and used to create the shape of the tube.
dialog.exec_()
if dialog.wasOk():
r1, r2, h1, h2 = dialog.getData()
r1, r2, h1, h2, thickness = dialog.getData()
#QMessageBox.about(None, "Building in progress", "building shape, please be patient")
shape = t_shape_builder.build_shape(activeStudy, r1, r2, h1, h2)
shape = t_shape_builder.build_shape(activeStudy, r1, r2, h1, h2, thickness)
entry = xalome.addToStudy(activeStudy, shape, "T_shape_fluid" )
xalome.displayShape(entry)
#if dialog.wasOk():

View File

@ -7,6 +7,7 @@ import GEOM
from salome.geom import geomBuilder
import math
import SALOMEDS
import time
def demidisk(study, r1, a1, roty=0, solid_thickness=0):
@ -47,25 +48,30 @@ def demidisk(study, r1, a1, roty=0, solid_thickness=0):
arc1 = geompy.MakeArc(v[1], v7, v[3])
l[0] = geompy.MakeLineTwoPnt(v[1], v[3])
face1 = geompy.MakeFaceWires([arc1, l[0]], 1)
part1 = geompy.MakePartition([face1], [l[2], l[4], l[5], l[6], l[7]], [], [], geompy.ShapeType["FACE"], 0, [], 0, True)
if with_solid:
# Vertices
# Add some faces corresponding to the solid layer outside
# the fluid part
# --- Vertices
v0 = geompy.MakeVertex(0, r1 + solid_thickness, 0)
v1 = geompy.MakeRotation(v0, OX, a1*math.pi/180.0)
v2 = geompy.MakeRotation(v0, OX, math.pi - (a1*math.pi/180.0))
v3 = geompy.MakeRotation(v0, OX, math.pi)
v.extend([v0,v1,v3,v2]) # The order is important for use in pointsProjetes
# --- Lines
l0 = geompy.MakeLineTwoPnt(v[1], v0)
l2 = geompy.MakeRotation(l0, OX, a1*math.pi/180.0)
l3 = geompy.MakeRotation(l0, OX, math.pi - (a1*math.pi/180.0))
# --- Faces
face2 = geompy.MakeRevolution(l0, OX, a1*math.pi/180.0)
face3 = geompy.MakeRevolution(l2, OX, math.pi - 2*a1*math.pi/180.0)
face4 = geompy.MakeRevolution(l3, OX, a1*math.pi/180.0)
part0 = geompy.MakePartition([face1], [l[2], l[4], l[5], l[6], l[7]], [], [], geompy.ShapeType["FACE"], 0, [], 0, True)
compound1 = geompy.MakeCompound([part0, face2, face3, face4])
# --- Compound of the "fluid part" of the divided disk and the additional faces
compound1 = geompy.MakeCompound([part1, face2, face3, face4])
# --- Glue edges
part1 = geompy.MakeGlueEdges(compound1,1e-7)
else:
part1 = geompy.MakePartition([face1], [l[2], l[4], l[5], l[6], l[7]], [], [], geompy.ShapeType["FACE"], 0, [], 0, True)
if roty != 0:
vrot = [ geompy.MakeRotation(vert, OY, roty*math.pi/180.0) for vert in v ]
@ -85,7 +91,6 @@ def pointsProjetes(study, vref, face):
for i,v in enumerate(vproj):
dist = [ (geompy.MinDistance(v, vr), j) for j,vr in enumerate(vref) ]
dist.sort()
#print dist
if dist[0][0] < 1.e-3:
vord[dist[0][1]] = vface[i]
return vord
@ -107,6 +112,8 @@ def arcsProjetes(study, vf, face):
return lord
def build_shape(study, r1, r2, h1, h2, solid_thickness=0):
""" Builds the final shape """
if solid_thickness < 1e-7:
with_solid = False
else:
@ -125,15 +132,12 @@ def build_shape(study, r1, r2, h1, h2, solid_thickness=0):
if ratio > (1.0 -seuilmax):
a1 = 45.0*(1.0 -ratio)/seuilmax
"""
res = geompy.MakeCompound([demicyl1,demicyl2])
return res
"""
# --- creation des faces de la jonction
# --- Creation of the jonction faces
[faci, sect45, arc1, l1, lord90, lord45, edges, arcextru] = jonction(study, r1, r2,\
h1, h2, a1)
if with_solid:
# The same code is executed again with different external radiuses in order
# to get the needed faces and edges to build the solid layer of the pipe
[faci_ext, sect45_ext, arc1_ext, l1_ext, \
lord90_ext, lord45_ext, edges_ext, arcextru_ext] = jonction(study, r1 + solid_thickness, r2 + solid_thickness,\
h1, h2, a1)
@ -149,17 +153,12 @@ def build_shape(study, r1, r2, h1, h2, solid_thickness=0):
geompy.addToStudy(faces_jonction_ext[i], "faci_ext_%d"%i)
# --- extrusion droite des faces de jonction, pour reconstituer les demi cylindres
# TODO : ajouter les faces nécessaires à sect45 dans le cas avec solide
if with_solid:
sect45 = geompy.MakeCompound([sect45]+faces_jonction_ext[-3:])
sect45 = geompy.MakeGlueEdges(sect45, 1e-7)
#return sect45, faces_jonction_ext[-3:]
extru1 = geompy.MakePrismVecH(sect45, OX, h1+10)
#base2 = geompy.MakeCompound(faci[5:])
#base2 = geompy.MakeGlueEdges(base2, 1e-7)
# RNC : perf
faces_coupe = faci[5:]
if with_solid:
faces_coupe = faci[5:]+faces_jonction_ext[:3]
@ -177,22 +176,22 @@ def build_shape(study, r1, r2, h1, h2, solid_thickness=0):
box = geompy.MakeBox(0, -2*(r1+h1), -2*(r1+h1), 2*(r1+h1), 2*(r1+h1), 2*(r1+h1))
rot = geompy.MakeRotation(box, OY, 45*math.pi/180.0)
# NOTE: The following Cut takes almost half of the total execution time
garder = geompy.MakeCutList(demiCylindre, [extru2, rot], True)
geompy.addToStudy(garder,"garder")
faces_coupe = faci[:5]
if with_solid:
faces_coupe.extend(faces_jonction_ext[-7:])
t4=time.time()
raccord = geompy.MakePartition([garder], faces_coupe + [arcextru], [], [], geompy.ShapeType["SOLID"], 0, [], 0, True)
assemblage = geompy.MakeCompound([raccord, extru1, extru2])
assemblage = geompy.MakeGlueFaces(assemblage, 1e-7)
# RNC : perf
#assemblage = geompy.MakePartition([raccord, extru1, extru2], [], [], [], geompy.ShapeType["SOLID"], 0, [], 0, True)
#return extru2, garder, raccord
box = geompy.MakeBox(-1, -(r1+r2+2*solid_thickness), -1, h1, r1+r2+2*solid_thickness, h2)
geompy.addToStudy(box, "box")
# NOTE: This operation takes about 1/4 of the total execution time
final = geompy.MakeCommonList([box, assemblage], True)
# --- Partie inférieure
@ -212,6 +211,9 @@ def build_shape(study, r1, r2, h1, h2, solid_thickness=0):
def jonction(study, r1, r2, h1, h2, a1):
""" Builds the jonction faces and
returns what is needed to build the whole pipe
"""
O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
@ -221,8 +223,6 @@ def jonction(study, r1, r2, h1, h2, a1):
# --- sections droites des deux demi cylindres avec le partionnement
v1, l1, arc1, part1 = demidisk(study, r1, a1, 0.)
v2, l2, arc2, part2 = demidisk(study, r2, a1, 90.0)
#elems_disk1 = [v1, l1, arc1, part1]
#elems_disk2 = [v2, l2, arc2, part2]
# --- extrusion des sections --> demi cylindres de travail, pour en extraire les sections utilisées au niveau du Té
# et enveloppe cylindrique du cylindre principal
@ -265,22 +265,10 @@ def jonction(study, r1, r2, h1, h2, a1):
# --- abaissement des quatre points centraux de la section du cylindre secondaire
#if with_solid:
#dz = -(r2 + solid_thickness)/2.0
#else:
#dz = -r2/2.0
dz = -r2/2.0
for i in (0, 2, 4, 5):
vord90[i] = geompy.TranslateDXDYDZ(vord90[i], 0, 0, dz, True)
geompy.addToStudyInFather(sect90, vord90[i], 'vm%d'%i)
#if with_solid:
#for i in (1, 3, 6, 7):
#vord90[i] = geompy.TranslateDXDYDZ(vord90[i], 0, 0, dz*solid_thickness/(r2+solid_thickness), True)
"""
res=vord90
return res
"""
# --- création des deux arêtes curvilignes sur l'enveloppe cylindrique du cylindre principal, à la jonction
@ -301,9 +289,7 @@ def jonction(study, r1, r2, h1, h2, a1):
secpart = geompy.MakePartition([section], [sect45, sect90], [], [], geompy.ShapeType["EDGE"], 0, [], 0, True)
geompy.addToStudy(secpart, "secpart%d"%i)
lsec = geompy.ExtractShapes(secpart, geompy.ShapeType["EDGE"], True)
#print "len(lsec)", len(lsec)
# TODO : revoir ça dans le cas avec solide
for l in lsec:
pts = geompy.ExtractShapes(l, geompy.ShapeType["VERTEX"], True)
if (((geompy.MinDistance(pts[0], p0) < 0.001) and (geompy.MinDistance(pts[1], p1) < 0.001)) or
@ -311,9 +297,6 @@ def jonction(study, r1, r2, h1, h2, a1):
curv[i+2] =l
print "curv_%d OK"%i
break
# RNC : commente temporairement
#for i,l in enumerate(curv):
# geompy.addToStudyInFather(arcextru, l, "curv%d"%i)
# --- creation des arêtes droites manquantes, des faces et volumes pour les quatre volumes de la jonction

View File

@ -44,8 +44,9 @@ class TShapeDialog(QtGui.QDialog):
r2 = self.ui.doubleSpinBox_2.value()
h1 = self.ui.doubleSpinBox_3.value()
h2 = self.ui.doubleSpinBox_4.value()
thickness = self.ui.doubleSpinBox_5.value()
return r1, r2, h1, h2
return r1, r2, h1, h2, thickness
def reject(self):
self._wasOk = False

View File

@ -6,15 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>321</width>
<height>242</height>
<width>349</width>
<height>283</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_2"/>
@ -58,14 +58,28 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Build solid part</string>
</property>
</widget>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Build solid part</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Solid thickness</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_5"/>
</item>
</layout>
</item>
<item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -86,12 +100,12 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
<x>205</x>
<y>241</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
<y>250</y>
</hint>
</hints>
</connection>
@ -102,12 +116,44 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
<x>205</x>
<y>241</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
<x>214</x>
<y>250</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox</sender>
<signal>clicked(bool)</signal>
<receiver>label_5</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>89</x>
<y>184</y>
</hint>
<hint type="destinationlabel">
<x>107</x>
<y>205</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox</sender>
<signal>clicked(bool)</signal>
<receiver>doubleSpinBox_5</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>140</x>
<y>178</y>
</hint>
<hint type="destinationlabel">
<x>277</x>
<y>212</y>
</hint>
</hints>
</connection>

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 't_shape_dialog.ui'
#
# Created: Thu Jun 19 11:13:43 2014
# Created: Tue Nov 4 16:52:09 2014
# by: PyQt4 UI code generator 4.9.6
#
# WARNING! All changes made in this file will be lost!
@ -26,9 +26,9 @@ except AttributeError:
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(331, 242)
self.verticalLayout = QtGui.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
Dialog.resize(349, 283)
self.gridLayout_3 = QtGui.QGridLayout(Dialog)
self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3"))
self.gridLayout = QtGui.QGridLayout()
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.doubleSpinBox_2 = QtGui.QDoubleSpinBox(Dialog)
@ -55,19 +55,30 @@ class Ui_Dialog(object):
self.label_4 = QtGui.QLabel(Dialog)
self.label_4.setObjectName(_fromUtf8("label_4"))
self.gridLayout.addWidget(self.label_4, 4, 0, 1, 1)
self.verticalLayout.addLayout(self.gridLayout)
self.gridLayout_3.addLayout(self.gridLayout, 0, 0, 1, 1)
self.gridLayout_2 = QtGui.QGridLayout()
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
self.checkBox = QtGui.QCheckBox(Dialog)
self.checkBox.setObjectName(_fromUtf8("checkBox"))
self.verticalLayout.addWidget(self.checkBox)
self.gridLayout_2.addWidget(self.checkBox, 0, 0, 1, 1)
self.label_5 = QtGui.QLabel(Dialog)
self.label_5.setObjectName(_fromUtf8("label_5"))
self.gridLayout_2.addWidget(self.label_5, 1, 0, 1, 1)
self.doubleSpinBox_5 = QtGui.QDoubleSpinBox(Dialog)
self.doubleSpinBox_5.setObjectName(_fromUtf8("doubleSpinBox_5"))
self.gridLayout_2.addWidget(self.doubleSpinBox_5, 1, 1, 1, 1)
self.gridLayout_3.addLayout(self.gridLayout_2, 1, 0, 1, 1)
self.buttonBox = QtGui.QDialogButtonBox(Dialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.verticalLayout.addWidget(self.buttonBox)
self.gridLayout_3.addWidget(self.buttonBox, 2, 0, 1, 1)
self.retranslateUi(Dialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Dialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject)
QtCore.QObject.connect(self.checkBox, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.label_5.setEnabled)
QtCore.QObject.connect(self.checkBox, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.doubleSpinBox_5.setEnabled)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
@ -77,7 +88,7 @@ class Ui_Dialog(object):
self.label_2.setText(_translate("Dialog", "Small pipe radius", None))
self.label_4.setText(_translate("Dialog", "Small pipe height", None))
self.checkBox.setText(_translate("Dialog", "Build solid part", None))
self.label_5.setText(_translate("Dialog", "Solid thickness", None))
if __name__ == "__main__":
import sys
@ -88,3 +99,5 @@ if __name__ == "__main__":
Dialog.show()
sys.exit(app.exec_())