mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-22 02:35:37 +05:00
first working version of the plugin
This commit is contained in:
parent
c07b5ec312
commit
4d7ec7e96b
@ -22,15 +22,21 @@
|
|||||||
import salome_pluginsmanager
|
import salome_pluginsmanager
|
||||||
|
|
||||||
def t_shape_fluid(context):
|
def t_shape_fluid(context):
|
||||||
activeStudy = context.study
|
import t_shape_builder
|
||||||
import t_shape_dialog
|
import t_shape_dialog
|
||||||
|
import xalome
|
||||||
|
activeStudy = context.study
|
||||||
|
|
||||||
dialog = t_shape_dialog.TShapeDialog()
|
dialog = t_shape_dialog.TShapeDialog()
|
||||||
|
|
||||||
# Get the parameter values from a gui dialog box. If the dialog is
|
# 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
|
# closed using the Ok button, then the data are requested from the
|
||||||
# gui and used to create the shape of the tube.
|
# gui and used to create the shape of the tube.
|
||||||
dialog.exec_()
|
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():
|
#if dialog.wasOk():
|
||||||
#radius, length, width = dialog.getData()
|
#radius, length, width = dialog.getData()
|
||||||
#shape = tubebuilder.createGeometry(activeStudy, radius, length, width)
|
#shape = tubebuilder.createGeometry(activeStudy, radius, length, width)
|
||||||
|
@ -3,38 +3,35 @@
|
|||||||
import sys
|
import sys
|
||||||
import salome
|
import salome
|
||||||
|
|
||||||
salome.salome_init()
|
|
||||||
theStudy = salome.myStudy
|
|
||||||
|
|
||||||
import GEOM
|
import GEOM
|
||||||
from salome.geom import geomBuilder
|
from salome.geom import geomBuilder
|
||||||
import math
|
import math
|
||||||
import SALOMEDS
|
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)
|
O = geompy.MakeVertex(0, 0, 0)
|
||||||
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
|
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
|
||||||
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
||||||
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
|
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)
|
v=range(8)
|
||||||
l=range(8)
|
l=range(8)
|
||||||
v0 = geompy.MakeVertex(0, 0, 0)
|
v0 = geompy.MakeVertex(0, 0, 0)
|
||||||
@ -71,7 +68,8 @@ def demidisk(r1, a1, roty=0):
|
|||||||
else:
|
else:
|
||||||
return v, l, arc1, part1
|
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)
|
vface = geompy.ExtractShapes(face, geompy.ShapeType["VERTEX"], True)
|
||||||
vord = range(len(vref))
|
vord = range(len(vref))
|
||||||
plan = geompy.MakePlaneThreePnt(vref[0], vref[1], vref[-1], 10000)
|
plan = geompy.MakePlaneThreePnt(vref[0], vref[1], vref[-1], 10000)
|
||||||
@ -84,7 +82,8 @@ def pointsProjetes(vref, face):
|
|||||||
vord[dist[0][1]] = vface[i]
|
vord[dist[0][1]] = vface[i]
|
||||||
return vord
|
return vord
|
||||||
|
|
||||||
def arcsProjetes(vf, face):
|
def arcsProjetes(study, vf, face):
|
||||||
|
geompy = geomBuilder.New(study)
|
||||||
lface = geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], True)
|
lface = geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], True)
|
||||||
lord = range(3)
|
lord = range(3)
|
||||||
ends = [vf[1], vf[6], vf[7], vf[3]]
|
ends = [vf[1], vf[6], vf[7], vf[3]]
|
||||||
@ -99,10 +98,25 @@ def arcsProjetes(vf, face):
|
|||||||
pass
|
pass
|
||||||
return lord
|
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
|
# --- sections droites des deux demi cylindres avec le partionnement
|
||||||
|
|
||||||
v1, l1, arc1, part1 = demidisk(r1, a1)
|
v1, l1, arc1, part1 = demidisk(study, r1, a1)
|
||||||
v2, l2, arc2, part2 = demidisk(r2, a1, 90.0)
|
v2, l2, arc2, part2 = demidisk(study, r2, a1, 90.0)
|
||||||
|
|
||||||
geompy.addToStudy(part1, 'part1')
|
geompy.addToStudy(part1, 'part1')
|
||||||
geompy.addToStudy(part2, 'part2')
|
geompy.addToStudy(part2, 'part2')
|
||||||
@ -134,8 +148,8 @@ geompy.addToStudy(sect90, 'sect90')
|
|||||||
|
|
||||||
# --- liste ordonnée des points projetés sur les deux sections
|
# --- liste ordonnée des points projetés sur les deux sections
|
||||||
|
|
||||||
vord45 = pointsProjetes(v1, sect45)
|
vord45 = pointsProjetes(study, v1, sect45)
|
||||||
vord90 = pointsProjetes(v2, sect90)
|
vord90 = pointsProjetes(study, v2, sect90)
|
||||||
for i,v in enumerate(vord45):
|
for i,v in enumerate(vord45):
|
||||||
geompy.addToStudyInFather(sect45, v, 'v%d'%i)
|
geompy.addToStudyInFather(sect45, v, 'v%d'%i)
|
||||||
for i,v in enumerate(vord90):
|
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.
|
# --- identification des projections des trois arcs de cercle, sur les deux sections.
|
||||||
|
|
||||||
lord45 = arcsProjetes(vord45, sect45)
|
lord45 = arcsProjetes(study, vord45, sect45)
|
||||||
lord90 = arcsProjetes(vord90, sect90)
|
lord90 = arcsProjetes(study, vord90, sect90)
|
||||||
for i,l in enumerate(lord45):
|
for i,l in enumerate(lord45):
|
||||||
geompy.addToStudyInFather(sect45, l, 'l%d'%i)
|
geompy.addToStudyInFather(sect45, l, 'l%d'%i)
|
||||||
for i,l in enumerate(lord90):
|
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)
|
box = geompy.MakeBox(-1, -(r1+r2), -1, h1, r1+r2, h2)
|
||||||
geompy.addToStudy(box, "box")
|
geompy.addToStudy(box, "box")
|
||||||
final = geompy.MakeCommonList([box, assemblage], True)
|
final = geompy.MakeCommonList([box, assemblage], True)
|
||||||
geompy.addToStudy(final, "final")
|
|
||||||
|
return final
|
||||||
|
@ -40,7 +40,12 @@ class TShapeDialog(QtGui.QDialog):
|
|||||||
QtGui.QDialog.accept(self)
|
QtGui.QDialog.accept(self)
|
||||||
|
|
||||||
def getData(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):
|
#def setupUi(self):
|
||||||
#TShapeDialog_UI.setupUi(self)
|
#TShapeDialog_UI.setupUi(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user