first working version of the plugin

This commit is contained in:
Renaud Nédélec 2014-06-20 11:57:06 +02:00
parent c07b5ec312
commit 4d7ec7e96b
3 changed files with 215 additions and 189 deletions

View File

@ -22,15 +22,21 @@
import salome_pluginsmanager
def t_shape_fluid(context):
activeStudy = context.study
import t_shape_builder
import t_shape_dialog
import xalome
activeStudy = context.study
dialog = t_shape_dialog.TShapeDialog()
# Get the parameter values from a gui dialog box. If the dialog is
# closed using the Ok button, then the data are requested from the
# gui and used to create the shape of the tube.
dialog.exec_()
dialog.getData()
r1, r2, h1, h2 = dialog.getData()
shape = t_shape_builder.build_shape(activeStudy, r1, r2, h1, h2)
entry = xalome.addToStudy(activeStudy, shape, "T_shape_fluid" )
xalome.displayShape(entry)
#if dialog.wasOk():
#radius, length, width = dialog.getData()
#shape = tubebuilder.createGeometry(activeStudy, radius, length, width)

View File

@ -3,38 +3,35 @@
import sys
import salome
salome.salome_init()
theStudy = salome.myStudy
import GEOM
from salome.geom import geomBuilder
import math
import SALOMEDS
geompy = geomBuilder.New(theStudy)
#O = geompy.MakeVertex(0, 0, 0)
#OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
#OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
#OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
#geompy.addToStudy( O, 'O' )
#geompy.addToStudy( OX, 'OX' )
#geompy.addToStudy( OY, 'OY' )
#geompy.addToStudy( OZ, 'OZ' )
#r1 = 100.0
#r2 = 50.0
#h1 = 200.0
#h2 = 200.0
def demidisk(study, r1, a1, roty=0):
geompy = geomBuilder.New(study)
O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
geompy.addToStudy( O, 'O' )
geompy.addToStudy( OX, 'OX' )
geompy.addToStudy( OY, 'OY' )
geompy.addToStudy( OZ, 'OZ' )
r1 = 100.0
r2 = 50.0
h1 = 200.0
h2 = 200.0
a1 = 45.0
seuilmax = 0.1
ratio = float(r2)/float(r1)
if ratio > (1.0 -seuilmax):
a1 = 45.0*(1.0 -ratio)/seuilmax
def demidisk(r1, a1, roty=0):
v=range(8)
l=range(8)
v0 = geompy.MakeVertex(0, 0, 0)
@ -71,7 +68,8 @@ def demidisk(r1, a1, roty=0):
else:
return v, l, arc1, part1
def pointsProjetes(vref, face):
def pointsProjetes(study, vref, face):
geompy = geomBuilder.New(study)
vface = geompy.ExtractShapes(face, geompy.ShapeType["VERTEX"], True)
vord = range(len(vref))
plan = geompy.MakePlaneThreePnt(vref[0], vref[1], vref[-1], 10000)
@ -84,7 +82,8 @@ def pointsProjetes(vref, face):
vord[dist[0][1]] = vface[i]
return vord
def arcsProjetes(vf, face):
def arcsProjetes(study, vf, face):
geompy = geomBuilder.New(study)
lface = geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], True)
lord = range(3)
ends = [vf[1], vf[6], vf[7], vf[3]]
@ -99,10 +98,25 @@ def arcsProjetes(vf, face):
pass
return lord
def build_shape(study, r1, r2, h1, h2):
geompy = geomBuilder.New(study)
O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
a1 = 45.0
seuilmax = 0.1
ratio = float(r2)/float(r1)
if ratio > (1.0 -seuilmax):
a1 = 45.0*(1.0 -ratio)/seuilmax
# --- sections droites des deux demi cylindres avec le partionnement
v1, l1, arc1, part1 = demidisk(r1, a1)
v2, l2, arc2, part2 = demidisk(r2, a1, 90.0)
v1, l1, arc1, part1 = demidisk(study, r1, a1)
v2, l2, arc2, part2 = demidisk(study, r2, a1, 90.0)
geompy.addToStudy(part1, 'part1')
geompy.addToStudy(part2, 'part2')
@ -134,8 +148,8 @@ geompy.addToStudy(sect90, 'sect90')
# --- liste ordonnée des points projetés sur les deux sections
vord45 = pointsProjetes(v1, sect45)
vord90 = pointsProjetes(v2, sect90)
vord45 = pointsProjetes(study, v1, sect45)
vord90 = pointsProjetes(study, v2, sect90)
for i,v in enumerate(vord45):
geompy.addToStudyInFather(sect45, v, 'v%d'%i)
for i,v in enumerate(vord90):
@ -143,8 +157,8 @@ for i,v in enumerate(vord90):
# --- identification des projections des trois arcs de cercle, sur les deux sections.
lord45 = arcsProjetes(vord45, sect45)
lord90 = arcsProjetes(vord90, sect90)
lord45 = arcsProjetes(study, vord45, sect45)
lord90 = arcsProjetes(study, vord90, sect90)
for i,l in enumerate(lord45):
geompy.addToStudyInFather(sect45, l, 'l%d'%i)
for i,l in enumerate(lord90):
@ -264,4 +278,5 @@ geompy.addToStudy(assemblage, "assemblage")
box = geompy.MakeBox(-1, -(r1+r2), -1, h1, r1+r2, h2)
geompy.addToStudy(box, "box")
final = geompy.MakeCommonList([box, assemblage], True)
geompy.addToStudy(final, "final")
return final

View File

@ -40,7 +40,12 @@ class TShapeDialog(QtGui.QDialog):
QtGui.QDialog.accept(self)
def getData(self):
print "DATA : %f"%(self.ui.doubleSpinBox.value())
r1 = self.ui.doubleSpinBox.value()
r2 = self.ui.doubleSpinBox_2.value()
h1 = self.ui.doubleSpinBox_3.value()
h2 = self.ui.doubleSpinBox_4.value()
return r1, r2, h1, h2
#def setupUi(self):
#TShapeDialog_UI.setupUi(self)