From: abuhsing Date: Wed, 18 Dec 2013 14:14:44 +0000 (+0000) Subject: Abu : Nouvelle syntaxe geompy X-Git-Tag: V7_4_0a1~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d2653597bfdcbc02089ac248dbee336ab7c01475;p=modules%2Fhexablock.git Abu : Nouvelle syntaxe geompy Modified Files: Tag: V7_main HEXABLOCKGUI/HEXABLOCKGUI.cxx HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.cxx HEXABLOCK_SWIG/hexablock.py HEXABLOCK_SWIG/hexablock_swig.py HEXABLOCK_SWIG/hexablock_swig_wrap.cc TEST_PY/recettes/bielle.py TEST_PY/recettes/cuve.py TEST_PY/recettes/troisCylindres.py TEST_PY/recettes/tuyau.py TEST_PY/recettes/tuyauterie.py TEST_PY/tape_edf/hexa_tape.py TEST_PY/test_unit/asso_grid.py TEST_PY/test_unit/cut_grille.py TEST_PY/test_unit/hexa_quads.py TEST_PY/test_unit/revolution.py TEST_PY/test_unit/test_asso_lines.py TEST_PY/test_unit/test_bugs.py TEST_PY/test_unit/test_carre.py TEST_PY/test_unit/test_cone.py TEST_PY/test_unit/test_cross.py TEST_PY/test_unit/test_cylinders.py TEST_PY/test_unit/test_disco.py TEST_PY/test_unit/test_double_t.py TEST_PY/test_unit/test_perform.py TEST_PY/test_unit/test_piquage.py TEST_PY/test_unit/test_rind.py TEST_PY/test_unit/test_shapes.py TEST_PY/test_unit/test_sphere.py TEST_PY/test_unit/test_transfo.py TEST_PY/test_unit/troisCylindres_v5.py ---------------------------------------------------------------------- --- diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI.cxx index a928adb..c243f38 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI.cxx @@ -236,6 +236,7 @@ HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Appli void HEXABLOCKGUI::initialize( CAM_Application* app ) { + MESSAGE("HEXABLOCKGUI::initialize"); DEBTRACE("HEXABLOCKGUI::initialize"); SalomeApp_Module::initialize( app ); @@ -520,7 +521,7 @@ bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name) docModel->setName( name ); aName->SetValue( name.toLatin1().data() ); getApp()->updateObjectBrowser(); - _dwPattern->setWindowTitle( name ); +// _dwPattern->setWindowTitle( name ); result = true; } } @@ -931,6 +932,7 @@ void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition) void HEXABLOCKGUI::createAndFillDockWidget() { + QMainWindow *aParent = application()->desktop(); // Create dock widget (3 dock) @@ -1001,7 +1003,7 @@ void HEXABLOCKGUI::createAndFillDockWidget() _dwMesh->setWidget(_meshTreeView); _meshTreeView->show(); - QDockWidget *_dwObjectBrowser = 0; +// QDockWidget *_dwObjectBrowser = 0; QWidget* wid = getApp()->objectBrowser()->treeView(); QWidget *w = wid->parentWidget(); while ( w && !_dwObjectBrowser ) { @@ -1013,19 +1015,20 @@ void HEXABLOCKGUI::createAndFillDockWidget() // dock widget position aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser ); -// aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwInputPanel ); aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel ); +// aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser ); +// aParent->tabifyDockWidget( _dwGroups, _dwPattern ); +// aParent->tabifyDockWidget( _dwMesh, _dwGroups ); + aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern ); aParent->tabifyDockWidget( _dwPattern, _dwGroups ); aParent->tabifyDockWidget( _dwGroups, _dwMesh ); - #if QT_VERSION >= 0x040500 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South); #endif - // popup menu on data tree view _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu); connect(_patternDataTreeView, @@ -1968,7 +1971,7 @@ void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview) currentDocGView = dgview; showOnlyActor(); currentDocGView->getDocumentModel()->refresh(); - _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName()); +// _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName()); showAllMenus(); } diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.cxx index 086dd1d..64eb9a6 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.cxx @@ -6756,7 +6756,7 @@ void ModelInfoDialog::hideEvent ( QHideEvent * event ) AddShapeDialog::AddShapeDialog(QWidget* parent, Mode editmode, Qt::WindowFlags wf): HexaBaseDialog(parent, editmode, wf) { - _helpFileName = ""; + _helpFileName = "gui_add_geometry.html#guiaddgeometry"; setupUi( this ); _initWidget(editmode); setWindowTitle(HEXABLOCKGUI::tr("ADD_SHAPE")); diff --git a/src/HEXABLOCK_SWIG/hexablock.py b/src/HEXABLOCK_SWIG/hexablock.py index 5b42284..4948958 100644 --- a/src/HEXABLOCK_SWIG/hexablock.py +++ b/src/HEXABLOCK_SWIG/hexablock.py @@ -2,12 +2,20 @@ # HexaBlock : Module principal import hexablock_swig -import salome -import smesh import HEXABLOCKPlugin -geompy = smesh.geompy +import salome +salome.salome_init() + +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + + +import SMESH +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + component = hexablock_swig.hex_instance () # ======================================================== moduleName @@ -106,28 +114,31 @@ def mesh (doc, name=None, dim=3, container="FactoryServer"): #### shape = geompy.MakeBox(0, 0, 0, 1, 1, 1) #### else : #### shape = doc.getShape (0) - ### shape = geompy.MakeBox(0, 0, 0, 1, 1, 1) - ### stream = doc.getFirstExplicitShape () - ### if stream != None : - ### shape = geompy.RestoreShape (stream) - ### else : - shape = geompy.MakeBox(0, 0, 0, 1, 1, 1) + ### shape = doc.getFirstExplicitShape_else_box(1) + ### the_stream = shape.getBREP() # sort une chaine de caractère + ### geom_object = geompy.RestoreShape(the_stream) + + stream = doc.getFirstExplicitShape () + if stream != None : + shape = geompy.RestoreShape (stream) + else : + shape = geompy.MakeBox(0, 0, 0, 1, 1, 1) - if (name == None) or (name == ""): + if (name == None) or (name == "") : name = docname geompy.addToStudy(shape, name) comp_smesh = salome.lcc.FindOrLoadComponent(container, "SMESH") - comp_smesh.init_smesh(study, geompy.geom) + comp_smesh.init_smesh(study, geomBuilder.geom) meshexa = comp_smesh.Mesh(shape) - so = "libHexaBlockEngine.so" + so = "libHexaBlockPluginEngine.so" - algo = smesh.SMESH._objref_SMESH_Gen.CreateHypothesis(comp_smesh, "HEXABLOCK_3D", so) + algo = SMESH._objref_SMESH_Gen.CreateHypothesis(comp_smesh, "HEXABLOCK_3D", so) meshexa.mesh.AddHypothesis(shape, algo) - hypo = smesh.SMESH._objref_SMESH_Gen.CreateHypothesis(comp_smesh, "HEXABLOCK_Parameters", so) + hypo = SMESH._objref_SMESH_Gen.CreateHypothesis(comp_smesh, "HEXABLOCK_Parameters", so) meshexa.mesh.AddHypothesis(shape, hypo) ### hypo.SetDocument(doc.getXml()) ## Hexa6 TODO et a verifier diff --git a/src/HEXABLOCK_SWIG/hexablock_swig.py b/src/HEXABLOCK_SWIG/hexablock_swig.py index 4453b2f..d982967 100644 --- a/src/HEXABLOCK_SWIG/hexablock_swig.py +++ b/src/HEXABLOCK_SWIG/hexablock_swig.py @@ -840,6 +840,7 @@ class Document(EltBase): def getGroup(*args): return _hexablock_swig.Document_getGroup(*args) def getLaw(*args): return _hexablock_swig.Document_getLaw(*args) def getPropagation(*args): return _hexablock_swig.Document_getPropagation(*args) + def getFirstExplicitShape(*args): return _hexablock_swig.Document_getFirstExplicitShape(*args) def findEdge(*args): return _hexablock_swig.Document_findEdge(*args) def findQuad(*args): return _hexablock_swig.Document_findQuad(*args) def findHexa(*args): return _hexablock_swig.Document_findHexa(*args) diff --git a/src/HEXABLOCK_SWIG/hexablock_swig_wrap.cc b/src/HEXABLOCK_SWIG/hexablock_swig_wrap.cc index fa1932d..17abc16 100644 --- a/src/HEXABLOCK_SWIG/hexablock_swig_wrap.cc +++ b/src/HEXABLOCK_SWIG/hexablock_swig_wrap.cc @@ -24618,6 +24618,28 @@ fail: } +SWIGINTERN PyObject *_wrap_Document_getFirstExplicitShape(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Hex::Document *arg1 = (Hex::Document *) 0 ; + cpchar result; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Document_getFirstExplicitShape",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Hex__Document, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Document_getFirstExplicitShape" "', argument " "1"" of type '" "Hex::Document *""'"); + } + arg1 = reinterpret_cast< Hex::Document * >(argp1); + result = (cpchar)(arg1)->getFirstExplicitShape(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_Document_findVertex__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Hex::Document *arg1 = (Hex::Document *) 0 ; @@ -31774,6 +31796,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"Document_getGroup", _wrap_Document_getGroup, METH_VARARGS, NULL}, { (char *)"Document_getLaw", _wrap_Document_getLaw, METH_VARARGS, NULL}, { (char *)"Document_getPropagation", _wrap_Document_getPropagation, METH_VARARGS, NULL}, + { (char *)"Document_getFirstExplicitShape", _wrap_Document_getFirstExplicitShape, METH_VARARGS, NULL}, { (char *)"Document_findEdge", _wrap_Document_findEdge, METH_VARARGS, NULL}, { (char *)"Document_findQuad", _wrap_Document_findQuad, METH_VARARGS, NULL}, { (char *)"Document_findHexa", _wrap_Document_findHexa, METH_VARARGS, NULL}, diff --git a/src/TEST_PY/recettes/bielle.py b/src/TEST_PY/recettes/bielle.py index df277c4..14a57e3 100644 --- a/src/TEST_PY/recettes/bielle.py +++ b/src/TEST_PY/recettes/bielle.py @@ -22,10 +22,12 @@ # ============================================================================================= import math - -import geompy import hexablock +### import geompy +geompy = hexablock.geompy + + # Construire le modele de bloc # ============================ diff --git a/src/TEST_PY/recettes/cuve.py b/src/TEST_PY/recettes/cuve.py index 218ccc3..110db5f 100644 --- a/src/TEST_PY/recettes/cuve.py +++ b/src/TEST_PY/recettes/cuve.py @@ -1,4 +1,4 @@ -# -*- coding: latin-1 -*- +# -*- coding: latin-1 -*- # Copyright (C) 2009-2013 CEA/DEN, EDF R&D # # This library is free software; you can redistribute it and/or @@ -17,557 +17,558 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # - -# Francis KLOSS - 2011-2013 - CEA-Saclay, DEN, DM2S, SFME, LGLS, F-91191 Gif-sur-Yvette, France -# ============================================================================================= - -import math - -import geompy -import hexablock - -# Charger la géométrie -# ==================== - -nom = "cuve" - -cuve = geompy.ImportBREP(nom+".brep") - -# Sélectionner des sommets de la géométrie -# ----------------------------------------- - -sommets = geompy.SubShapeAllSortedCentres(cuve, geompy.ShapeType["VERTEX"]) - -coin_a = sommets[ 4] -coin_b = sommets[43] -coin_c = sommets[62] -coin_d = sommets[15] - -support_a_o = sommets[ 3] -support_a_x = sommets[ 8] -support_a_y = sommets[ 6] -support_a_d = sommets[10] - -support_b_o = sommets[42] -support_b_x = sommets[36] -support_b_y = sommets[47] -support_b_d = sommets[38] - -support_c_o = sommets[61] -support_c_x = sommets[51] -support_c_y = sommets[59] -support_c_d = sommets[49] - -support_d_o = sommets[14] -support_d_x = sommets[19] -support_d_y = sommets[12] -support_d_d = sommets[17] - -coin_x1, coin_y1, coin_z1 = geompy.PointCoordinates(sommets[ 2]) -coin_x2, coin_y2, coin_z2 = geompy.PointCoordinates(support_a_d) -coin_x3, coin_y3, coin_z3 = geompy.PointCoordinates(support_a_o) -coin_x4, coin_y4, coin_z4 = geompy.PointCoordinates(coin_c) - -base_x, base_y, base_z = geompy.PointCoordinates(sommets[52]) -oppo_x, oppo_y, oppo_z = geompy.PointCoordinates(sommets[57]) - -# Sélectionner des arêtes de la géométrie -# --------------------------------------- - -aretes = geompy.SubShapeAllSortedCentres(cuve, geompy.ShapeType["EDGE"]) - -interne0, interne_x, interne_y, interne_z, interne_dx, interne_dy, interne_dz, interne_rayon = geompy.KindOfShape(aretes[48]) -externe0, externe_x, externe_y, externe_z, externe_dx, externe_dy, externe_dz, externe_rayon = geompy.KindOfShape(aretes[49]) - -cote_a = aretes[41] -cote_b = aretes[91] -cote_c = aretes[59] -cote_d = aretes[12] - -piquage_1_int = aretes[ 0] -piquage_1_ext = aretes[ 1] -piquage_1_feb = aretes[ 36] -piquage_1_feh = aretes[ 38] -piquage_1_eeb = aretes[ 33] -piquage_1_eeh = aretes[ 37] -piquage_1_eib = aretes[ 34] -piquage_1_eih = aretes[ 35] - -piquage_2_int = aretes[103] -piquage_2_ext = aretes[104] -piquage_2_feg = aretes[ 68] -piquage_2_fed = aretes[ 73] -piquage_2_eeg = aretes[ 79] -piquage_2_eed = aretes[ 88] -piquage_2_eig = aretes[ 80] -piquage_2_eid = aretes[ 89] - -support_l, support_a, support_v = geompy.BasicProperties(aretes[43]) -cote_lgr, cote_aire, cote_vol = geompy.BasicProperties(cote_a) - -# Sélectionner des faces de la géométrie -# -------------------------------------- - -faces = geompy.SubShapeAllSortedCentres(cuve, geompy.ShapeType["FACE"]) - -face_cylindrique_int = faces[21] -face_cylindrique_ext = faces[22] - -# Construire le modèle de blocs -# ============================= - -# Créer le document -# ----------------- - -doc = hexablock.addDocument(nom) - -# Calculer l'angle défini par le centre de la cuve et 2 points (projeté dans le plan XY) -# -------------------------------------------------------------------------------------- - -centre_cuve = geompy.MakeVertex(externe_x, externe_y, 0) - -def calculer_angle(point1, point2): - x1, y1, z1 = geompy.PointCoordinates(point1) - x2, y2, z2 = geompy.PointCoordinates(point2) - - p1 = geompy.MakeVertex(x1, y1, 0) - p2 = geompy.MakeVertex(x2, y2, 0) - - a1 = geompy.MakeEdge(centre_cuve, p1) - a2 = geompy.MakeEdge(centre_cuve, p2) - - return geompy.GetAngle(a1, a2) - -# Construire les 8 points de la grille -# ------------------------------------ - -p1_int0, p1_int_x, p1_int_y, p1_int_z, p1_int_dx, p1_int_dy, p1_int_dz, p1_int_rayon = geompy.KindOfShape(piquage_1_int) -p2_int0, p2_int_x, p2_int_y, p2_int_z, p2_int_dx, p2_int_dy, p2_int_dz, p2_int_rayon = geompy.KindOfShape(piquage_2_int) - -p1_int_c = geompy.MakeVertex(p1_int_x, p1_int_y, p1_int_z) -p2_int_c = geompy.MakeVertex(p2_int_x, p2_int_y, p2_int_z) - -p1_int_e = geompy.MakePrismDXDYDZ2Ways(p1_int_c, p1_int_dx*cote_lgr, p1_int_dy*cote_lgr, p1_int_dz*cote_lgr) -p2_int_e = geompy.MakePrismDXDYDZ2Ways(p2_int_c, p2_int_dx*cote_lgr, p2_int_dy*cote_lgr, p2_int_dz*cote_lgr) - -plan_2 = geompy.MakePrismDXDYDZ(p1_int_e, +cote_lgr, +cote_lgr, -cote_lgr) -plan_3 = geompy.MakePrismDXDYDZ(p1_int_e, -cote_lgr, -cote_lgr, -cote_lgr) - -plan_7 = geompy.MakePrismDXDYDZ(p2_int_e, 0, -cote_lgr, -cote_lgr) -plan_8 = geompy.MakePrismDXDYDZ(p2_int_e, 0, +cote_lgr, -cote_lgr) - -part_2 = geompy.MakePartition([piquage_1_eeb], [plan_2], [], [], geompy.ShapeType["VERTEX"]) -part_3 = geompy.MakePartition([piquage_1_eeb], [plan_3], [], [], geompy.ShapeType["VERTEX"]) - -part_7 = geompy.MakePartition([piquage_2_feg], [plan_7], [], [], geompy.ShapeType["VERTEX"]) -part_8 = geompy.MakePartition([piquage_2_fed], [plan_8], [], [], geompy.ShapeType["VERTEX"]) - -point_1 = coin_c -point_2 = geompy.SubShapeAllSortedCentres(part_2, geompy.ShapeType["VERTEX"])[1] -point_3 = geompy.SubShapeAllSortedCentres(part_3, geompy.ShapeType["VERTEX"])[1] -point_4 = geompy.MakeVertexOnCurve(cote_d, 0.55) -point_5 = coin_a -point_6 = coin_b -point_7 = geompy.SubShapeAllSortedCentres(part_7, geompy.ShapeType["VERTEX"])[0] -point_8 = geompy.SubShapeAllSortedCentres(part_8, geompy.ShapeType["VERTEX"])[2] - -# Construire la grille cylindrique -# -------------------------------- - -grille_hauteur = coin_z4-coin_z2 - -centre = doc.addVertex(externe_x, externe_y, externe_z-grille_hauteur) - -grille_x = doc.addVector(1, 1, 0) -grille_z = doc.addVector(0, 0, 1) - -petit_rayon = interne_rayon * 0.2 -grand_rayon = math.sqrt( (coin_x1-externe_x)**2 + (coin_y1-externe_y)**2 ) - -rayons = [ petit_rayon, interne_rayon-petit_rayon, externe_rayon-interne_rayon, grand_rayon-externe_rayon ] - -points = [ point_1, point_2, point_3, point_4, point_5, point_6, point_7, point_8, point_1 ] - -angles = [] -for i in xrange(8): - angle = calculer_angle(points[i], points[i+1]) - angles.append(angle) - -hauteurs = [ grille_hauteur ] - -grille = doc.makeCylindricals(centre, grille_x, grille_z, rayons, angles, hauteurs, False) - -# Ajouter le centre -# ----------------- - -quad_0 = grille.getQuadJK(0, 7, 0) -quad_6 = grille.getQuadJK(0, 0, 0) -quad_7 = grille.getQuadJK(0, 1, 0) - -centre_a = doc.addHexa3Quads(quad_0, quad_6, quad_7) - -quad_2 = grille.getQuadJK(0, 3, 0) -quad_3 = grille.getQuadJK(0, 4, 0) -quad_4 = grille.getQuadJK(0, 5, 0) - -centre_b = doc.addHexa3Quads(quad_2, quad_3, quad_4) - -quad_1 = grille.getQuadJK(0, 2, 0) -quad_5 = grille.getQuadJK(0, 6, 0) - -quad_a = centre_a.getQuad(1) -quad_b = centre_b.getQuad(1) - -centre_c = doc.addHexa4Quads(quad_1, quad_a, quad_5, quad_b) - -# Ajouter l'enceinte -# ------------------ - -plan_0 = geompy.MakePrismDXDYDZ(p1_int_e, +cote_lgr, +cote_lgr, +cote_lgr) -part_0 = geompy.MakePartition([piquage_1_feh], [plan_0], [], [], geompy.ShapeType["VERTEX"]) -point_0 = geompy.SubShapeAllSortedCentres(part_0, geompy.ShapeType["VERTEX"])[1] - -enceinte_quads = [] -for j in xrange(8): - q = grille.getQuadIJ(1, j, 1) - enceinte_quads.append(q) - -point_7x, point_7y, point_7z = geompy.PointCoordinates(point_7) -point_2x, point_2y, point_2z = geompy.PointCoordinates(point_2) -point_0x, point_0y, point_0z = geompy.PointCoordinates(point_0) - -enceinte_h1 = point_7z - base_z -enceinte_h2 = point_2z - base_z -enceinte_h3 = point_0z - base_z -enceinte_h4 = oppo_z - base_z - -enceinte_hauteurs = [ enceinte_h1, enceinte_h2, enceinte_h3, enceinte_h4 ] - -enceinte_pz = doc.addVector(oppo_x - base_x, oppo_y - base_y, enceinte_h4) - -enceinte = doc.prismQuadsVec(enceinte_quads, enceinte_pz, enceinte_hauteurs, 0) - -# Déconnecter via des arêtes, puis prismer, puis compléter (3) ou coller (1) -# -------------------------------------------------------------------------- - -periph_hexas = [] -supports_quads_b = [] -supports_quads_h = [] - -v1 = doc.addVector( 0, +0.1, 0) -v2 = doc.addVector( 0, -0.1, 0) -v3 = doc.addVector(+0.2, -0.1, 0) - -for j, v in [ [0, v1], [1, v1], [4, v2], [5, v3] ]: - h = grille.getHexaIJK(2, j, 0) - a = grille.getEdgeK(3, j, 0) - d = doc.disconnectEdge(h, a) - - q1 = d.getQuad(0) - q2 = grille.getQuadIK(2, j, 0) - if j==1: - h0 = doc.addHexa2Quads(q1, q2) - q3 = grille.getQuadJK(3, j, 0) - q4 = h0.getQuad(3) - h1 = doc.addHexa2Quads(q3, q4) - qb = h1.getQuad(hexablock.Q_E) - qh = h1.getQuad(hexablock.Q_F) - else: - p = doc.prismQuad(q1, v, 2) - - h0 = p.getHexa(0) - q3 = h0.getQuad(5) - h1 = p.getHexa(1) - q4 = h1.getQuad(5) - doc.addHexa3Quads(q2, q3, q4) - periph_hexas.append(h0) - qb = h1.getQuad(hexablock.Q_C) - qh = h1.getQuad(hexablock.Q_D) - - supports_quads_b.append(qb) - supports_quads_h.append(qh) - -# Piquer les 2 tuyaux sur l'enceinte -# ---------------------------------- - -piquage_centre = doc.addVertex(10, 0, 0) - -piquage_vx = doc.addVector(1, 0, 0) -piquage_vz = doc.addVector(0, 0, 1) - -piquage = doc.makeCylindrical(piquage_centre, piquage_vx, piquage_vz, 1, 360, 1, 1, 4, 1, False) - -piquage_quads = [ piquage.getQuadIJ(0, j, 0) for j in xrange(4) ] - -piquage_s1 = piquage.getVertexIJK(1, 0, 0) -piquage_s2 = piquage.getVertexIJK(1, 1, 0) -piquage_s3 = piquage.getVertexIJK(1, 2, 0) - -enceinte_ha = enceinte.getHexa( 6) -enceinte_hb = enceinte.getHexa(25) - -enceinte_s11 = enceinte_ha.getVertex(2) -enceinte_s12 = enceinte_ha.getVertex(3) -enceinte_s13 = enceinte_ha.getVertex(7) - -enceinte_s21 = enceinte_hb.getVertex(2) -enceinte_s22 = enceinte_hb.getVertex(3) -enceinte_s23 = enceinte_hb.getVertex(7) - -piquage_1 = doc.replace(piquage_quads, piquage_s1, enceinte_s11, piquage_s2, enceinte_s12, piquage_s3, enceinte_s13) -piquage_2 = doc.replace(piquage_quads, piquage_s1, enceinte_s21, piquage_s2, enceinte_s22, piquage_s3, enceinte_s23) - -# Nettoyer le template du piquage -# ------------------------------- - -doc.removeElements(piquage) - -# Associer le modèle de blocs avec la géométrie -# ============================================= - -doc.setShape(cuve) - -# Nettoyer les associations implicites du centre et de la périphérie -# ------------------------------------------------------------------ - -for i in xrange(0, 4, 3): - for j in xrange(8): - for k in xrange(2): - e = grille.getEdgeJ(i, j, k) - e.clearAssociation() - -# Associer le centre de l'enceinte -# -------------------------------- - -for j, ig in [ [2, 30], [3, 28], [6, 32], [7, 34] ]: - sm0 = grille.getVertexIJK(0, j, 0) - sg0 = sommets[ig] - sm0.setAssociation(sg0) - - sm1 = grille.getVertexIJK(0, j, 1) - sg1 = geompy.MakeTranslation(sg0, 0, 0, grille_hauteur) - sm1.setAssociation(sg1) - -for j, ig, sens in [ [0, 34, +1], [1, 30, +1], [4, 28, -1], [5, 32, -1] ]: - sm0 = grille.getVertexIJK(0, j, 0) - sg0 = geompy.MakeTranslation(sommets[ig], 0, sens*support_l, 0) - sm0.setAssociation(sg0) - - sm1 = grille.getVertexIJK(0, j, 1) - sg1 = geompy.MakeTranslation(sg0, 0, 0, grille_hauteur) - sm1.setAssociation(sg1) - -# Associer les 16 sommets des 4 supports externes -# ----------------------------------------------- - -supports_points = [ - [ support_c_o, support_c_y, support_c_d, support_c_x ], - [ support_d_d, support_d_y, support_d_o, support_d_x ], - [ support_a_o, support_a_y, support_a_d, support_a_x ], - [ support_b_o, support_b_x, support_b_d, support_b_y ] -] - -for s in xrange(4): - qb = supports_quads_b[s] - qh = supports_quads_h[s] - cs = supports_points[s] - for i in xrange(4): - smb = qb.getVertex(i) - sgb = cs[i] - smb.setAssociation(sgb) - - if s==1: - ind = i - else: - ind = [1, 0, 3, 2][i] - smh = qh.getVertex(ind) - sgh = geompy.MakeTranslation(sgb, 0, 0, grille_hauteur) - smh.setAssociation(sgh) - -# Associer les 7 sommets périphériques de la grille -# ------------------------------------------------- - -par_1 = 0.17 -par_2 = 1 - par_1 - -periph_grille = [ [0, cote_b, par_2], [1, cote_c, 0.22], [3, cote_d, 0.548], [4, cote_d, par_1], [5, cote_a, par_2], [6, cote_b, 0.44], [7, cote_b, 0.555] ] - -for j, ag, p in periph_grille: - smb = grille.getVertexIJK(3, j, 1) - sgb = geompy.MakeVertexOnCurve(ag, p) - smb.setAssociation(sgb) - - smh = grille.getVertexIJK(3, j, 0) - sgh = geompy.MakeTranslation(sgb, 0, 0, -grille_hauteur) - smh.setAssociation(sgh) - -# Associer les 3 sommets liés aux déconnections sur la grille -# ----------------------------------------------------------- - -periph_deco = [ [cote_c, par_2], [cote_a, par_1], [cote_b, par_1] ] - -for i in xrange(3): - hxa = periph_hexas[i] - ag, p = periph_deco[i] - smb = hxa.getVertex(2) - sgb = geompy.MakeVertexOnCurve(ag, p) - smb.setAssociation(sgb) - - smh = hxa.getVertex(0) - sgh = geompy.MakeTranslation(sgb, 0, 0, -grille_hauteur) - smh.setAssociation(sgh) - -# Réparer les piquages -# -------------------- - -piquage_e_base = geompy.MakeVertex(interne_x, interne_y, interne_z) -piquage_e_axe = geompy.MakeVectorDXDYDZ(interne_dx, interne_dy, interne_dz) -piquage_e_cyl = geompy.MakeCylinder(piquage_e_base, piquage_e_axe, interne_rayon, enceinte_h4) - -piquage_1_axe = geompy.MakeVectorDXDYDZ(p1_int_dx, p1_int_dy, p1_int_dz) -piquage_1_cyl = geompy.MakeCylinder(p1_int_c, piquage_1_axe, p1_int_rayon, cote_lgr) - -piquage_2_axe = geompy.MakeVectorDXDYDZ(p2_int_dx, p2_int_dy, p2_int_dz) -piquage_2_cyl = geompy.MakeCylinder(p2_int_c, piquage_2_axe, p2_int_rayon, cote_lgr) - -piquage_1_inter = geompy.SubShapeAllSortedCentres(geompy.MakeSection(piquage_e_cyl, piquage_1_cyl), geompy.ShapeType["EDGE"]) -piquage_2_inter = geompy.SubShapeAllSortedCentres(geompy.MakeSection(piquage_e_cyl, piquage_2_cyl), geompy.ShapeType["EDGE"]) - -piquage_1_fi = piquage_1_inter[0] - -piquage_2_fig = piquage_2_inter[0] -piquage_2_fid = piquage_2_inter[1] - -# Associer les piquages -# --------------------- - -piquages_devant = [ - [ piquage_1, piquage_1_int, 0.375, piquage_1_ext, 0.125 ], - [ piquage_2, piquage_2_int, 0.125, piquage_2_ext, 0.875 ] -] - -for m_piq, a_int, p_int, a_ext, p_ext in piquages_devant: - - i1 = m_piq.getEdge(2) - i2 = m_piq.getEdge(5) - i3 = m_piq.getEdge(7) - i4 = m_piq.getEdge(10) - - doc.associateClosedLine(i1.getVertex(1), i1, [ i2, i3, i4 ], a_int, p_int, True, []) - - e1 = m_piq.getEdge(0) - e2 = m_piq.getEdge(1) - e3 = m_piq.getEdge(9) - e4 = m_piq.getEdge(11) - - doc.associateClosedLine(e1.getVertex(0), e1, [ e2, e3, e4 ], a_ext, p_ext, False, []) - -piquages_milieu = [ - [ piquage_1, piquage_1_eib, piquage_1_eih, 0.30, piquage_1_eeb, piquage_1_eeh, 0.30 ], - [ piquage_2, piquage_2_eid, piquage_2_eig, 0.75, piquage_2_eed, piquage_2_eeg, 0.75 ] -] - -for m_piq, a_int1, a_int2, p_int, a_ext1, a_ext2, p_ext in piquages_milieu: - - i1 = m_piq.getEdge(22) - i2 = m_piq.getEdge(25) - i3 = m_piq.getEdge(27) - i4 = m_piq.getEdge(30) - - doc.associateClosedLine(i1.getVertex(0), i1, [ i4, i3, i2 ], a_int1, p_int, False, [a_int2]) - - e1 = m_piq.getEdge(20) - e2 = m_piq.getEdge(21) - e3 = m_piq.getEdge(29) - e4 = m_piq.getEdge(31) - - doc.associateClosedLine(e1.getVertex(0), e1, [ e2, e3, e4 ], a_ext1, p_ext, False, [a_ext2]) - -piquages_fond = [ - [ piquage_1, piquage_1_fi , [] , 0.125, piquage_1_feb, piquage_1_feh, 0.30 ], - [ piquage_2, piquage_2_fid, [piquage_2_fig], 0.75 , piquage_2_fed, piquage_2_feg, 0.75 ] -] - -for m_piq, a_int1, a_int2, p_int, a_ext1, a_ext2, p_ext in piquages_fond: - - i1 = m_piq.getEdge(42) - i2 = m_piq.getEdge(45) - i3 = m_piq.getEdge(47) - i4 = m_piq.getEdge(50) - - doc.associateClosedLine(i1.getVertex(0), i1, [ i4, i3, i2 ], a_int1, p_int, False, a_int2) - - e1 = m_piq.getEdge(40) - e2 = m_piq.getEdge(41) - e3 = m_piq.getEdge(49) - e4 = m_piq.getEdge(51) - - doc.associateClosedLine(e1.getVertex(1), e1, [ e2, e3, e4 ], a_ext1, p_ext, False, [a_ext2]) - -# Associer quelques faces -# ----------------------- - -for h in [ 2, 5, 7, 10, 21, 24, 26, 29 ]: - enceinte_hc = enceinte.getHexa(h) - - enceinte_qc = enceinte_hc.getQuad(hexablock.Q_C) - enceinte_qc.addAssociation(face_cylindrique_int) - - enceinte_qc = enceinte_hc.getQuad(hexablock.Q_D) - enceinte_qc.addAssociation(face_cylindrique_ext) - -# Primer les 5 supports (finalisation du modèle de blocs) -# ------------------------------------------------------- - -supports_quads_b.append( centre_c.getQuad(hexablock.Q_E) ) - -supports_z = doc.addVector(coin_x1 - coin_x3, coin_y1 - coin_y3, coin_z1 - coin_z3) - -supports = doc.prismQuads(supports_quads_b, supports_z, 1) - -# Mailler le modèle de blocs -# ========================== - -# Définir les groupes volumiques -# ------------------------------ - -groupe_fd = doc.addHexaGroup("fond") -groupe_en = doc.addHexaGroup("enceinte") -groupe_p1 = doc.addHexaGroup("piquage:1") -groupe_p2 = doc.addHexaGroup("piquage:2") -groupe_su = doc.addHexaGroup("supports") - -for i in xrange( doc.countUsedHexa() ): - h = doc.getUsedHexa(i) - groupe_fd.addElement(h) - -for i in xrange( enceinte.countHexa() ): - h = enceinte.getHexa(i) - if h != None: - groupe_en.addElement(h) - groupe_fd.removeElement(h) - -for i in xrange( piquage_1.countHexa() ): - h = piquage_1.getHexa(i) - groupe_p1.addElement(h) - groupe_fd.removeElement(h) - -for i in xrange( piquage_2.countHexa() ): - h = piquage_2.getHexa(i) - groupe_p2.addElement(h) - groupe_fd.removeElement(h) - -for i in xrange( supports.countHexa() ): - h = supports.getHexa(i) - groupe_su.addElement(h) - groupe_fd.removeElement(h) - -# Générer le maillage -# ------------------- - -hexablock.addLaws(doc, 0.015, False) - -maillage = hexablock.mesh(doc) - -muv, mue, muq, muh = hexablock.dump(doc, maillage) - + +# Francis KLOSS - 2011-2013 - CEA-Saclay, DEN, DM2S, SFME, LGLS, F-91191 Gif-sur-Yvette, France +# ============================================================================================= + +import math + +### import geompy +import hexablock +geompy = hexablock.geompy + +# Charger la géométrie +# ==================== + +nom = "cuve" + +cuve = geompy.ImportBREP(nom+".brep") + +# Sélectionner des sommets de la géométrie +# ----------------------------------------- + +sommets = geompy.SubShapeAllSortedCentres(cuve, geompy.ShapeType["VERTEX"]) + +coin_a = sommets[ 4] +coin_b = sommets[43] +coin_c = sommets[62] +coin_d = sommets[15] + +support_a_o = sommets[ 3] +support_a_x = sommets[ 8] +support_a_y = sommets[ 6] +support_a_d = sommets[10] + +support_b_o = sommets[42] +support_b_x = sommets[36] +support_b_y = sommets[47] +support_b_d = sommets[38] + +support_c_o = sommets[61] +support_c_x = sommets[51] +support_c_y = sommets[59] +support_c_d = sommets[49] + +support_d_o = sommets[14] +support_d_x = sommets[19] +support_d_y = sommets[12] +support_d_d = sommets[17] + +coin_x1, coin_y1, coin_z1 = geompy.PointCoordinates(sommets[ 2]) +coin_x2, coin_y2, coin_z2 = geompy.PointCoordinates(support_a_d) +coin_x3, coin_y3, coin_z3 = geompy.PointCoordinates(support_a_o) +coin_x4, coin_y4, coin_z4 = geompy.PointCoordinates(coin_c) + +base_x, base_y, base_z = geompy.PointCoordinates(sommets[52]) +oppo_x, oppo_y, oppo_z = geompy.PointCoordinates(sommets[57]) + +# Sélectionner des arêtes de la géométrie +# --------------------------------------- + +aretes = geompy.SubShapeAllSortedCentres(cuve, geompy.ShapeType["EDGE"]) + +interne0, interne_x, interne_y, interne_z, interne_dx, interne_dy, interne_dz, interne_rayon = geompy.KindOfShape(aretes[48]) +externe0, externe_x, externe_y, externe_z, externe_dx, externe_dy, externe_dz, externe_rayon = geompy.KindOfShape(aretes[49]) + +cote_a = aretes[41] +cote_b = aretes[91] +cote_c = aretes[59] +cote_d = aretes[12] + +piquage_1_int = aretes[ 0] +piquage_1_ext = aretes[ 1] +piquage_1_feb = aretes[ 36] +piquage_1_feh = aretes[ 38] +piquage_1_eeb = aretes[ 33] +piquage_1_eeh = aretes[ 37] +piquage_1_eib = aretes[ 34] +piquage_1_eih = aretes[ 35] + +piquage_2_int = aretes[103] +piquage_2_ext = aretes[104] +piquage_2_feg = aretes[ 68] +piquage_2_fed = aretes[ 73] +piquage_2_eeg = aretes[ 79] +piquage_2_eed = aretes[ 88] +piquage_2_eig = aretes[ 80] +piquage_2_eid = aretes[ 89] + +support_l, support_a, support_v = geompy.BasicProperties(aretes[43]) +cote_lgr, cote_aire, cote_vol = geompy.BasicProperties(cote_a) + +# Sélectionner des faces de la géométrie +# -------------------------------------- + +faces = geompy.SubShapeAllSortedCentres(cuve, geompy.ShapeType["FACE"]) + +face_cylindrique_int = faces[21] +face_cylindrique_ext = faces[22] + +# Construire le modèle de blocs +# ============================= + +# Créer le document +# ----------------- + +doc = hexablock.addDocument(nom) + +# Calculer l'angle défini par le centre de la cuve et 2 points (projeté dans le plan XY) +# -------------------------------------------------------------------------------------- + +centre_cuve = geompy.MakeVertex(externe_x, externe_y, 0) + +def calculer_angle(point1, point2): + x1, y1, z1 = geompy.PointCoordinates(point1) + x2, y2, z2 = geompy.PointCoordinates(point2) + + p1 = geompy.MakeVertex(x1, y1, 0) + p2 = geompy.MakeVertex(x2, y2, 0) + + a1 = geompy.MakeEdge(centre_cuve, p1) + a2 = geompy.MakeEdge(centre_cuve, p2) + + return geompy.GetAngle(a1, a2) + +# Construire les 8 points de la grille +# ------------------------------------ + +p1_int0, p1_int_x, p1_int_y, p1_int_z, p1_int_dx, p1_int_dy, p1_int_dz, p1_int_rayon = geompy.KindOfShape(piquage_1_int) +p2_int0, p2_int_x, p2_int_y, p2_int_z, p2_int_dx, p2_int_dy, p2_int_dz, p2_int_rayon = geompy.KindOfShape(piquage_2_int) + +p1_int_c = geompy.MakeVertex(p1_int_x, p1_int_y, p1_int_z) +p2_int_c = geompy.MakeVertex(p2_int_x, p2_int_y, p2_int_z) + +p1_int_e = geompy.MakePrismDXDYDZ2Ways(p1_int_c, p1_int_dx*cote_lgr, p1_int_dy*cote_lgr, p1_int_dz*cote_lgr) +p2_int_e = geompy.MakePrismDXDYDZ2Ways(p2_int_c, p2_int_dx*cote_lgr, p2_int_dy*cote_lgr, p2_int_dz*cote_lgr) + +plan_2 = geompy.MakePrismDXDYDZ(p1_int_e, +cote_lgr, +cote_lgr, -cote_lgr) +plan_3 = geompy.MakePrismDXDYDZ(p1_int_e, -cote_lgr, -cote_lgr, -cote_lgr) + +plan_7 = geompy.MakePrismDXDYDZ(p2_int_e, 0, -cote_lgr, -cote_lgr) +plan_8 = geompy.MakePrismDXDYDZ(p2_int_e, 0, +cote_lgr, -cote_lgr) + +part_2 = geompy.MakePartition([piquage_1_eeb], [plan_2], [], [], geompy.ShapeType["VERTEX"]) +part_3 = geompy.MakePartition([piquage_1_eeb], [plan_3], [], [], geompy.ShapeType["VERTEX"]) + +part_7 = geompy.MakePartition([piquage_2_feg], [plan_7], [], [], geompy.ShapeType["VERTEX"]) +part_8 = geompy.MakePartition([piquage_2_fed], [plan_8], [], [], geompy.ShapeType["VERTEX"]) + +point_1 = coin_c +point_2 = geompy.SubShapeAllSortedCentres(part_2, geompy.ShapeType["VERTEX"])[1] +point_3 = geompy.SubShapeAllSortedCentres(part_3, geompy.ShapeType["VERTEX"])[1] +point_4 = geompy.MakeVertexOnCurve(cote_d, 0.55) +point_5 = coin_a +point_6 = coin_b +point_7 = geompy.SubShapeAllSortedCentres(part_7, geompy.ShapeType["VERTEX"])[0] +point_8 = geompy.SubShapeAllSortedCentres(part_8, geompy.ShapeType["VERTEX"])[2] + +# Construire la grille cylindrique +# -------------------------------- + +grille_hauteur = coin_z4-coin_z2 + +centre = doc.addVertex(externe_x, externe_y, externe_z-grille_hauteur) + +grille_x = doc.addVector(1, 1, 0) +grille_z = doc.addVector(0, 0, 1) + +petit_rayon = interne_rayon * 0.2 +grand_rayon = math.sqrt( (coin_x1-externe_x)**2 + (coin_y1-externe_y)**2 ) + +rayons = [ petit_rayon, interne_rayon-petit_rayon, externe_rayon-interne_rayon, grand_rayon-externe_rayon ] + +points = [ point_1, point_2, point_3, point_4, point_5, point_6, point_7, point_8, point_1 ] + +angles = [] +for i in xrange(8): + angle = calculer_angle(points[i], points[i+1]) + angles.append(angle) + +hauteurs = [ grille_hauteur ] + +grille = doc.makeCylindricals(centre, grille_x, grille_z, rayons, angles, hauteurs, False) + +# Ajouter le centre +# ----------------- + +quad_0 = grille.getQuadJK(0, 7, 0) +quad_6 = grille.getQuadJK(0, 0, 0) +quad_7 = grille.getQuadJK(0, 1, 0) + +centre_a = doc.addHexa3Quads(quad_0, quad_6, quad_7) + +quad_2 = grille.getQuadJK(0, 3, 0) +quad_3 = grille.getQuadJK(0, 4, 0) +quad_4 = grille.getQuadJK(0, 5, 0) + +centre_b = doc.addHexa3Quads(quad_2, quad_3, quad_4) + +quad_1 = grille.getQuadJK(0, 2, 0) +quad_5 = grille.getQuadJK(0, 6, 0) + +quad_a = centre_a.getQuad(1) +quad_b = centre_b.getQuad(1) + +centre_c = doc.addHexa4Quads(quad_1, quad_a, quad_5, quad_b) + +# Ajouter l'enceinte +# ------------------ + +plan_0 = geompy.MakePrismDXDYDZ(p1_int_e, +cote_lgr, +cote_lgr, +cote_lgr) +part_0 = geompy.MakePartition([piquage_1_feh], [plan_0], [], [], geompy.ShapeType["VERTEX"]) +point_0 = geompy.SubShapeAllSortedCentres(part_0, geompy.ShapeType["VERTEX"])[1] + +enceinte_quads = [] +for j in xrange(8): + q = grille.getQuadIJ(1, j, 1) + enceinte_quads.append(q) + +point_7x, point_7y, point_7z = geompy.PointCoordinates(point_7) +point_2x, point_2y, point_2z = geompy.PointCoordinates(point_2) +point_0x, point_0y, point_0z = geompy.PointCoordinates(point_0) + +enceinte_h1 = point_7z - base_z +enceinte_h2 = point_2z - base_z +enceinte_h3 = point_0z - base_z +enceinte_h4 = oppo_z - base_z + +enceinte_hauteurs = [ enceinte_h1, enceinte_h2, enceinte_h3, enceinte_h4 ] + +enceinte_pz = doc.addVector(oppo_x - base_x, oppo_y - base_y, enceinte_h4) + +enceinte = doc.prismQuadsVec(enceinte_quads, enceinte_pz, enceinte_hauteurs, 0) + +# Déconnecter via des arêtes, puis prismer, puis compléter (3) ou coller (1) +# -------------------------------------------------------------------------- + +periph_hexas = [] +supports_quads_b = [] +supports_quads_h = [] + +v1 = doc.addVector( 0, +0.1, 0) +v2 = doc.addVector( 0, -0.1, 0) +v3 = doc.addVector(+0.2, -0.1, 0) + +for j, v in [ [0, v1], [1, v1], [4, v2], [5, v3] ]: + h = grille.getHexaIJK(2, j, 0) + a = grille.getEdgeK(3, j, 0) + d = doc.disconnectEdge(h, a) + + q1 = d.getQuad(0) + q2 = grille.getQuadIK(2, j, 0) + if j==1: + h0 = doc.addHexa2Quads(q1, q2) + q3 = grille.getQuadJK(3, j, 0) + q4 = h0.getQuad(3) + h1 = doc.addHexa2Quads(q3, q4) + qb = h1.getQuad(hexablock.Q_E) + qh = h1.getQuad(hexablock.Q_F) + else: + p = doc.prismQuad(q1, v, 2) + + h0 = p.getHexa(0) + q3 = h0.getQuad(5) + h1 = p.getHexa(1) + q4 = h1.getQuad(5) + doc.addHexa3Quads(q2, q3, q4) + periph_hexas.append(h0) + qb = h1.getQuad(hexablock.Q_C) + qh = h1.getQuad(hexablock.Q_D) + + supports_quads_b.append(qb) + supports_quads_h.append(qh) + +# Piquer les 2 tuyaux sur l'enceinte +# ---------------------------------- + +piquage_centre = doc.addVertex(10, 0, 0) + +piquage_vx = doc.addVector(1, 0, 0) +piquage_vz = doc.addVector(0, 0, 1) + +piquage = doc.makeCylindrical(piquage_centre, piquage_vx, piquage_vz, 1, 360, 1, 1, 4, 1, False) + +piquage_quads = [ piquage.getQuadIJ(0, j, 0) for j in xrange(4) ] + +piquage_s1 = piquage.getVertexIJK(1, 0, 0) +piquage_s2 = piquage.getVertexIJK(1, 1, 0) +piquage_s3 = piquage.getVertexIJK(1, 2, 0) + +enceinte_ha = enceinte.getHexa( 6) +enceinte_hb = enceinte.getHexa(25) + +enceinte_s11 = enceinte_ha.getVertex(2) +enceinte_s12 = enceinte_ha.getVertex(3) +enceinte_s13 = enceinte_ha.getVertex(7) + +enceinte_s21 = enceinte_hb.getVertex(2) +enceinte_s22 = enceinte_hb.getVertex(3) +enceinte_s23 = enceinte_hb.getVertex(7) + +piquage_1 = doc.replace(piquage_quads, piquage_s1, enceinte_s11, piquage_s2, enceinte_s12, piquage_s3, enceinte_s13) +piquage_2 = doc.replace(piquage_quads, piquage_s1, enceinte_s21, piquage_s2, enceinte_s22, piquage_s3, enceinte_s23) + +# Nettoyer le template du piquage +# ------------------------------- + +doc.removeElements(piquage) + +# Associer le modèle de blocs avec la géométrie +# ============================================= + +doc.setShape(cuve) + +# Nettoyer les associations implicites du centre et de la périphérie +# ------------------------------------------------------------------ + +for i in xrange(0, 4, 3): + for j in xrange(8): + for k in xrange(2): + e = grille.getEdgeJ(i, j, k) + e.clearAssociation() + +# Associer le centre de l'enceinte +# -------------------------------- + +for j, ig in [ [2, 30], [3, 28], [6, 32], [7, 34] ]: + sm0 = grille.getVertexIJK(0, j, 0) + sg0 = sommets[ig] + sm0.setAssociation(sg0) + + sm1 = grille.getVertexIJK(0, j, 1) + sg1 = geompy.MakeTranslation(sg0, 0, 0, grille_hauteur) + sm1.setAssociation(sg1) + +for j, ig, sens in [ [0, 34, +1], [1, 30, +1], [4, 28, -1], [5, 32, -1] ]: + sm0 = grille.getVertexIJK(0, j, 0) + sg0 = geompy.MakeTranslation(sommets[ig], 0, sens*support_l, 0) + sm0.setAssociation(sg0) + + sm1 = grille.getVertexIJK(0, j, 1) + sg1 = geompy.MakeTranslation(sg0, 0, 0, grille_hauteur) + sm1.setAssociation(sg1) + +# Associer les 16 sommets des 4 supports externes +# ----------------------------------------------- + +supports_points = [ + [ support_c_o, support_c_y, support_c_d, support_c_x ], + [ support_d_d, support_d_y, support_d_o, support_d_x ], + [ support_a_o, support_a_y, support_a_d, support_a_x ], + [ support_b_o, support_b_x, support_b_d, support_b_y ] +] + +for s in xrange(4): + qb = supports_quads_b[s] + qh = supports_quads_h[s] + cs = supports_points[s] + for i in xrange(4): + smb = qb.getVertex(i) + sgb = cs[i] + smb.setAssociation(sgb) + + if s==1: + ind = i + else: + ind = [1, 0, 3, 2][i] + smh = qh.getVertex(ind) + sgh = geompy.MakeTranslation(sgb, 0, 0, grille_hauteur) + smh.setAssociation(sgh) + +# Associer les 7 sommets périphériques de la grille +# ------------------------------------------------- + +par_1 = 0.17 +par_2 = 1 - par_1 + +periph_grille = [ [0, cote_b, par_2], [1, cote_c, 0.22], [3, cote_d, 0.548], [4, cote_d, par_1], [5, cote_a, par_2], [6, cote_b, 0.44], [7, cote_b, 0.555] ] + +for j, ag, p in periph_grille: + smb = grille.getVertexIJK(3, j, 1) + sgb = geompy.MakeVertexOnCurve(ag, p) + smb.setAssociation(sgb) + + smh = grille.getVertexIJK(3, j, 0) + sgh = geompy.MakeTranslation(sgb, 0, 0, -grille_hauteur) + smh.setAssociation(sgh) + +# Associer les 3 sommets liés aux déconnections sur la grille +# ----------------------------------------------------------- + +periph_deco = [ [cote_c, par_2], [cote_a, par_1], [cote_b, par_1] ] + +for i in xrange(3): + hxa = periph_hexas[i] + ag, p = periph_deco[i] + smb = hxa.getVertex(2) + sgb = geompy.MakeVertexOnCurve(ag, p) + smb.setAssociation(sgb) + + smh = hxa.getVertex(0) + sgh = geompy.MakeTranslation(sgb, 0, 0, -grille_hauteur) + smh.setAssociation(sgh) + +# Réparer les piquages +# -------------------- + +piquage_e_base = geompy.MakeVertex(interne_x, interne_y, interne_z) +piquage_e_axe = geompy.MakeVectorDXDYDZ(interne_dx, interne_dy, interne_dz) +piquage_e_cyl = geompy.MakeCylinder(piquage_e_base, piquage_e_axe, interne_rayon, enceinte_h4) + +piquage_1_axe = geompy.MakeVectorDXDYDZ(p1_int_dx, p1_int_dy, p1_int_dz) +piquage_1_cyl = geompy.MakeCylinder(p1_int_c, piquage_1_axe, p1_int_rayon, cote_lgr) + +piquage_2_axe = geompy.MakeVectorDXDYDZ(p2_int_dx, p2_int_dy, p2_int_dz) +piquage_2_cyl = geompy.MakeCylinder(p2_int_c, piquage_2_axe, p2_int_rayon, cote_lgr) + +piquage_1_inter = geompy.SubShapeAllSortedCentres(geompy.MakeSection(piquage_e_cyl, piquage_1_cyl), geompy.ShapeType["EDGE"]) +piquage_2_inter = geompy.SubShapeAllSortedCentres(geompy.MakeSection(piquage_e_cyl, piquage_2_cyl), geompy.ShapeType["EDGE"]) + +piquage_1_fi = piquage_1_inter[0] + +piquage_2_fig = piquage_2_inter[0] +piquage_2_fid = piquage_2_inter[1] + +# Associer les piquages +# --------------------- + +piquages_devant = [ + [ piquage_1, piquage_1_int, 0.375, piquage_1_ext, 0.125 ], + [ piquage_2, piquage_2_int, 0.125, piquage_2_ext, 0.875 ] +] + +for m_piq, a_int, p_int, a_ext, p_ext in piquages_devant: + + i1 = m_piq.getEdge(2) + i2 = m_piq.getEdge(5) + i3 = m_piq.getEdge(7) + i4 = m_piq.getEdge(10) + + doc.associateClosedLine(i1.getVertex(1), i1, [ i2, i3, i4 ], a_int, p_int, True, []) + + e1 = m_piq.getEdge(0) + e2 = m_piq.getEdge(1) + e3 = m_piq.getEdge(9) + e4 = m_piq.getEdge(11) + + doc.associateClosedLine(e1.getVertex(0), e1, [ e2, e3, e4 ], a_ext, p_ext, False, []) + +piquages_milieu = [ + [ piquage_1, piquage_1_eib, piquage_1_eih, 0.30, piquage_1_eeb, piquage_1_eeh, 0.30 ], + [ piquage_2, piquage_2_eid, piquage_2_eig, 0.75, piquage_2_eed, piquage_2_eeg, 0.75 ] +] + +for m_piq, a_int1, a_int2, p_int, a_ext1, a_ext2, p_ext in piquages_milieu: + + i1 = m_piq.getEdge(22) + i2 = m_piq.getEdge(25) + i3 = m_piq.getEdge(27) + i4 = m_piq.getEdge(30) + + doc.associateClosedLine(i1.getVertex(0), i1, [ i4, i3, i2 ], a_int1, p_int, False, [a_int2]) + + e1 = m_piq.getEdge(20) + e2 = m_piq.getEdge(21) + e3 = m_piq.getEdge(29) + e4 = m_piq.getEdge(31) + + doc.associateClosedLine(e1.getVertex(0), e1, [ e2, e3, e4 ], a_ext1, p_ext, False, [a_ext2]) + +piquages_fond = [ + [ piquage_1, piquage_1_fi , [] , 0.125, piquage_1_feb, piquage_1_feh, 0.30 ], + [ piquage_2, piquage_2_fid, [piquage_2_fig], 0.75 , piquage_2_fed, piquage_2_feg, 0.75 ] +] + +for m_piq, a_int1, a_int2, p_int, a_ext1, a_ext2, p_ext in piquages_fond: + + i1 = m_piq.getEdge(42) + i2 = m_piq.getEdge(45) + i3 = m_piq.getEdge(47) + i4 = m_piq.getEdge(50) + + doc.associateClosedLine(i1.getVertex(0), i1, [ i4, i3, i2 ], a_int1, p_int, False, a_int2) + + e1 = m_piq.getEdge(40) + e2 = m_piq.getEdge(41) + e3 = m_piq.getEdge(49) + e4 = m_piq.getEdge(51) + + doc.associateClosedLine(e1.getVertex(1), e1, [ e2, e3, e4 ], a_ext1, p_ext, False, [a_ext2]) + +# Associer quelques faces +# ----------------------- + +for h in [ 2, 5, 7, 10, 21, 24, 26, 29 ]: + enceinte_hc = enceinte.getHexa(h) + + enceinte_qc = enceinte_hc.getQuad(hexablock.Q_C) + enceinte_qc.addAssociation(face_cylindrique_int) + + enceinte_qc = enceinte_hc.getQuad(hexablock.Q_D) + enceinte_qc.addAssociation(face_cylindrique_ext) + +# Primer les 5 supports (finalisation du modèle de blocs) +# ------------------------------------------------------- + +supports_quads_b.append( centre_c.getQuad(hexablock.Q_E) ) + +supports_z = doc.addVector(coin_x1 - coin_x3, coin_y1 - coin_y3, coin_z1 - coin_z3) + +supports = doc.prismQuads(supports_quads_b, supports_z, 1) + +# Mailler le modèle de blocs +# ========================== + +# Définir les groupes volumiques +# ------------------------------ + +groupe_fd = doc.addHexaGroup("fond") +groupe_en = doc.addHexaGroup("enceinte") +groupe_p1 = doc.addHexaGroup("piquage:1") +groupe_p2 = doc.addHexaGroup("piquage:2") +groupe_su = doc.addHexaGroup("supports") + +for i in xrange( doc.countUsedHexa() ): + h = doc.getUsedHexa(i) + groupe_fd.addElement(h) + +for i in xrange( enceinte.countHexa() ): + h = enceinte.getHexa(i) + if h != None: + groupe_en.addElement(h) + groupe_fd.removeElement(h) + +for i in xrange( piquage_1.countHexa() ): + h = piquage_1.getHexa(i) + groupe_p1.addElement(h) + groupe_fd.removeElement(h) + +for i in xrange( piquage_2.countHexa() ): + h = piquage_2.getHexa(i) + groupe_p2.addElement(h) + groupe_fd.removeElement(h) + +for i in xrange( supports.countHexa() ): + h = supports.getHexa(i) + groupe_su.addElement(h) + groupe_fd.removeElement(h) + +# Générer le maillage +# ------------------- + +hexablock.addLaws(doc, 0.015, False) + +maillage = hexablock.mesh(doc) + +muv, mue, muq, muh = hexablock.dump(doc, maillage) + diff --git a/src/TEST_PY/recettes/troisCylindres.py b/src/TEST_PY/recettes/troisCylindres.py index 9a6ee9a..091c4ca 100644 --- a/src/TEST_PY/recettes/troisCylindres.py +++ b/src/TEST_PY/recettes/troisCylindres.py @@ -21,8 +21,9 @@ # Francis KLOSS : 2012 : CEA-Saclay, DEN, DM2S, SFME, LGLS, F-91191 Gif-sur-Yvette, France # ======================================================================================== -import geompy import hexablock +#### import geompy +geompy = hexablock.geompy # Charger la geometrie # ==================== diff --git a/src/TEST_PY/recettes/tuyau.py b/src/TEST_PY/recettes/tuyau.py index fcb56ed..dcec34f 100644 --- a/src/TEST_PY/recettes/tuyau.py +++ b/src/TEST_PY/recettes/tuyau.py @@ -21,8 +21,9 @@ # Francis KLOSS : 2012 : CEA-Saclay, DEN, DM2S, SFME, LGLS, F-91191 Gif-sur-Yvette, France # ======================================================================================== -import geompy import hexablock +### import geompy +geompy = hexablock.geompy # Charger la geometrie # ==================== diff --git a/src/TEST_PY/recettes/tuyauterie.py b/src/TEST_PY/recettes/tuyauterie.py index c90aec2..894c478 100644 --- a/src/TEST_PY/recettes/tuyauterie.py +++ b/src/TEST_PY/recettes/tuyauterie.py @@ -22,9 +22,9 @@ # ======================================================================================== import math - -import geompy import hexablock +### import geompy +geompy = hexablock.geompy # Charger la géométrie # ==================== diff --git a/src/TEST_PY/tape_edf/hexa_tape.py b/src/TEST_PY/tape_edf/hexa_tape.py index 2987421..c9800d6 100644 --- a/src/TEST_PY/tape_edf/hexa_tape.py +++ b/src/TEST_PY/tape_edf/hexa_tape.py @@ -2,7 +2,8 @@ # Hexa : Utilitaires de creation de la tape import hexablock -import geompy +### import geompy +geompy = hexablock.geompy nbr_points = 0 diff --git a/src/TEST_PY/test_unit/asso_grid.py b/src/TEST_PY/test_unit/asso_grid.py index 36fd187..69b1039 100644 --- a/src/TEST_PY/test_unit/asso_grid.py +++ b/src/TEST_PY/test_unit/asso_grid.py @@ -20,7 +20,6 @@ # import os -import geompy import hexablock import math diff --git a/src/TEST_PY/test_unit/cut_grille.py b/src/TEST_PY/test_unit/cut_grille.py index c542bad..bfeadd1 100644 --- a/src/TEST_PY/test_unit/cut_grille.py +++ b/src/TEST_PY/test_unit/cut_grille.py @@ -21,8 +21,8 @@ # Francis KLOSS - 2011 - CEA-Saclay, DEN, DM2S, SFME, LGLS, F-91191 Gif-sur-Yvette, France # ======================================================================================== -import geompy import hexablock +geompy = hexablock.geompy # Construire le modèle de blocs # ============================= diff --git a/src/TEST_PY/test_unit/hexa_quads.py b/src/TEST_PY/test_unit/hexa_quads.py index 4e859da..93e19a5 100644 --- a/src/TEST_PY/test_unit/hexa_quads.py +++ b/src/TEST_PY/test_unit/hexa_quads.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 # ================================================================= save_schema diff --git a/src/TEST_PY/test_unit/revolution.py b/src/TEST_PY/test_unit/revolution.py index 5cb154d..bc0f2f2 100644 --- a/src/TEST_PY/test_unit/revolution.py +++ b/src/TEST_PY/test_unit/revolution.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 # ================================================================= save_schema diff --git a/src/TEST_PY/test_unit/test_asso_lines.py b/src/TEST_PY/test_unit/test_asso_lines.py index f2fdf3b..af89394 100644 --- a/src/TEST_PY/test_unit/test_asso_lines.py +++ b/src/TEST_PY/test_unit/test_asso_lines.py @@ -1,4 +1,4 @@ -# -*- coding: latin-1 -*- +# -*- coding: latin-1 -*- # Copyright (C) 2009-2013 CEA/DEN, EDF R&D # # This library is free software; you can redistribute it and/or @@ -18,168 +18,168 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# Hexa : Association par lignes - -import hexablock -import os -import geompy - -#---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 -# -# . ed_nord1 ed_nord2 -# . v_nw v_n v_ne -# v9 v10 v11 -# 1 +----e18----+----e19----+ -# . | | | -# . | | | -# 0 ed_west e13 o e17 ed_est -# . | | | -# . | | | -# -1 +----e14----+----e16----+ -# . v6 v10 v8 -# . v_sw v_s v_se -# . ed_sud1 ed_sud2 -# . -# +..........-2...........0...........2............... - -global ed_west, ed_est, ed_nord1, ed_nord2, ed_sud1, ed_sud2 -global v_sw, v_s , v_se, v_nw, v_n , v_ne -global p_w, p_e, p_n, p_s, p_n1, p_n2, p_s1, p_s2, p_nw, p_sw, p_ne, p_se -global arc_s, arc_e, arc_n, arc_w, arc_n1, arc_n2, arc_s1, arc_s2 - - -# ======================================================= init_globale -def init_globale (name) : - - global ed_west, ed_est, ed_nord1, ed_nord2, ed_sud1, ed_sud2 - global v_sw, v_s , v_se, v_nw, v_n , v_ne - global p_w, p_e, p_n, p_s, p_n1, p_n2, p_s1, p_s2, p_nw, p_sw, p_ne, p_se - global arc_s, arc_e, arc_n, arc_w, arc_n1, arc_n2, arc_s1, arc_s2 - - nom = name - doc = hexablock.addDocument (nom) - - orig = doc.addVertex (-2, -1, -1) - vx = doc.addVector (2,0,0) - vy = doc.addVector (0,2,0) - vz = doc.addVector (0,0,2) - grid = doc.makeCartesian (orig, vx, vy, vz, 2, 1, 1) - - nz = 1 - vz = 1.0 - - ed_west = grid.getEdgeJ (0, 0, nz) - ed_est = grid.getEdgeJ (2, 0, nz) - ed_nord1 = grid.getEdgeI (0, 1, nz) - ed_nord2 = grid.getEdgeI (1, 1, nz) - ed_sud1 = grid.getEdgeI (0, 0, nz) - ed_sud2 = grid.getEdgeI (1, 0, nz) - - v_sw = grid.getVertexIJK (0, 0, nz) - v_s = grid.getVertexIJK (1, 0, nz) - v_se = grid.getVertexIJK (2, 0, nz) - - v_nw = grid.getVertexIJK (0, 1, nz) - v_n = grid.getVertexIJK (1, 1, nz) - v_ne = grid.getVertexIJK (2, 1, nz) - - doc.saveVtk (nom + ".vtk"); - ## ______________________________________________________________ Geom - - p_w = geompy.MakeVertex (-2.55, 0, vz) - p_e = geompy.MakeVertex ( 2.55, 0, vz) - p_n = geompy.MakeVertex ( 0, 2.0, vz) - p_s = geompy.MakeVertex ( 0, -2.0, vz) - - p_n1 = geompy.MakeVertex ( 0.5, 2.0, vz) - p_n2 = geompy.MakeVertex (-0.5, 2.0, vz) - p_s1 = geompy.MakeVertex (-0.5, -2.0, vz) - p_s2 = geompy.MakeVertex ( 0.5, -2.0, vz) - - p_nw = geompy.MakeVertex (-2, 1, vz) - p_sw = geompy.MakeVertex (-2, -1, vz) - p_ne = geompy.MakeVertex ( 2, 1, vz) - p_se = geompy.MakeVertex ( 2, -1, vz) - - arc_s = geompy.MakeArc (p_sw, p_s, p_se) - arc_e = geompy.MakeArc (p_se, p_e, p_ne) - arc_n = geompy.MakeArc (p_ne, p_n, p_nw) - arc_w = geompy.MakeArc (p_nw, p_w, p_sw) - - arc_n1 = geompy.MakeArc (p_ne, p_n1, p_n) - arc_n2 = geompy.MakeArc (p_n, p_n2, p_nw) - arc_s1 = geompy.MakeArc (p_sw, p_s1, p_s) - arc_s2 = geompy.MakeArc (p_s, p_s2, p_se) - - return doc - -# ======================================================= test_asso_mano -def test_asso_mano () : - - doc = init_globale ("asso_mano") - - ed_west.addAssociation (arc_w, 0, 1) - ed_est .addAssociation (arc_e, 0, 1) - - v_n.setAssociation (p_n) - ed_nord2.addAssociation (arc_n1, 0.0, 1.0) - ed_nord1.addAssociation (arc_n2, 0.0, 1.0) - - v_s.setAssociation (p_s) - ## ed_sud1.addAssociation (arc_s, 0.0, 0.5) - ## ed_sud2.addAssociation (arc_s, 0.5, 1.0) - - ed_sud1.addAssociation (arc_s1, 0.0, 1.0) - ed_sud2.addAssociation (arc_s2, 0.0, 1.0) - - return doc - -# ======================================================= test_asso_closed -def test_asso_closed () : - - doc = init_globale ("asso_closed") - - les_edges = [ ed_sud1, ed_sud2, ed_est, ed_nord1, ed_nord2, ed_west ] - les_arcs = [ arc_s1, arc_s2, arc_e, arc_n1, arc_n2, arc_w ] - - doc.associateClosedLine (v_sw, les_edges[0], les_edges[1:], - les_arcs [0], 0.0, False, les_arcs[1:]) - return doc - -# ======================================================= test_asso_closed_inv -def test_asso_closed_inv () : - - doc = init_globale ("asso_closed_inv") - - les_edges = [ ed_sud1, ed_sud2, ed_est, ed_nord1, ed_nord2, ed_west ] - les_arcs = [ arc_s1, arc_s2, arc_e, arc_n1, arc_n2, arc_w ] - - doc.associateClosedLine (v_s , les_edges[0], les_edges[1:], - les_arcs [0], 1.0, True, les_arcs[1:]) - return doc - -# ======================================================= test_asso_opened -def test_asso_opened () : - - doc = init_globale ("asso_opened") - - les_edges = [ ed_sud2, ed_est, ed_nord2 ] - les_arcs = [ arc_s, arc_e, arc_n ] - - doc.associateOpenedLine (les_edges[0], les_edges[1:], - les_arcs [0], 0.5, les_arcs[1:], 0.5) - return doc - -# ================================================================= Begin - -doc = test_asso_closed_inv () - -law = doc.addLaw("Uniform", 3) - -for j in range(doc.countPropagation()): - propa = doc.getPropagation(j) - propa.setLaw(law) - -mesh_hexas = hexablock.mesh (doc) - - +# Hexa : Association par lignes + +import os +import hexablock +geompy = hexablock.geompy + +#---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 +# +# . ed_nord1 ed_nord2 +# . v_nw v_n v_ne +# v9 v10 v11 +# 1 +----e18----+----e19----+ +# . | | | +# . | | | +# 0 ed_west e13 o e17 ed_est +# . | | | +# . | | | +# -1 +----e14----+----e16----+ +# . v6 v10 v8 +# . v_sw v_s v_se +# . ed_sud1 ed_sud2 +# . +# +..........-2...........0...........2............... + +global ed_west, ed_est, ed_nord1, ed_nord2, ed_sud1, ed_sud2 +global v_sw, v_s , v_se, v_nw, v_n , v_ne +global p_w, p_e, p_n, p_s, p_n1, p_n2, p_s1, p_s2, p_nw, p_sw, p_ne, p_se +global arc_s, arc_e, arc_n, arc_w, arc_n1, arc_n2, arc_s1, arc_s2 + + +# ======================================================= init_globale +def init_globale (name) : + + global ed_west, ed_est, ed_nord1, ed_nord2, ed_sud1, ed_sud2 + global v_sw, v_s , v_se, v_nw, v_n , v_ne + global p_w, p_e, p_n, p_s, p_n1, p_n2, p_s1, p_s2, p_nw, p_sw, p_ne, p_se + global arc_s, arc_e, arc_n, arc_w, arc_n1, arc_n2, arc_s1, arc_s2 + + nom = name + doc = hexablock.addDocument (nom) + + orig = doc.addVertex (-2, -1, -1) + vx = doc.addVector (2,0,0) + vy = doc.addVector (0,2,0) + vz = doc.addVector (0,0,2) + grid = doc.makeCartesian (orig, vx, vy, vz, 2, 1, 1) + + nz = 1 + vz = 1.0 + + ed_west = grid.getEdgeJ (0, 0, nz) + ed_est = grid.getEdgeJ (2, 0, nz) + ed_nord1 = grid.getEdgeI (0, 1, nz) + ed_nord2 = grid.getEdgeI (1, 1, nz) + ed_sud1 = grid.getEdgeI (0, 0, nz) + ed_sud2 = grid.getEdgeI (1, 0, nz) + + v_sw = grid.getVertexIJK (0, 0, nz) + v_s = grid.getVertexIJK (1, 0, nz) + v_se = grid.getVertexIJK (2, 0, nz) + + v_nw = grid.getVertexIJK (0, 1, nz) + v_n = grid.getVertexIJK (1, 1, nz) + v_ne = grid.getVertexIJK (2, 1, nz) + + doc.saveVtk (nom + ".vtk"); + ## ______________________________________________________________ Geom + + p_w = geompy.MakeVertex (-2.55, 0, vz) + p_e = geompy.MakeVertex ( 2.55, 0, vz) + p_n = geompy.MakeVertex ( 0, 2.0, vz) + p_s = geompy.MakeVertex ( 0, -2.0, vz) + + p_n1 = geompy.MakeVertex ( 0.5, 2.0, vz) + p_n2 = geompy.MakeVertex (-0.5, 2.0, vz) + p_s1 = geompy.MakeVertex (-0.5, -2.0, vz) + p_s2 = geompy.MakeVertex ( 0.5, -2.0, vz) + + p_nw = geompy.MakeVertex (-2, 1, vz) + p_sw = geompy.MakeVertex (-2, -1, vz) + p_ne = geompy.MakeVertex ( 2, 1, vz) + p_se = geompy.MakeVertex ( 2, -1, vz) + + arc_s = geompy.MakeArc (p_sw, p_s, p_se) + arc_e = geompy.MakeArc (p_se, p_e, p_ne) + arc_n = geompy.MakeArc (p_ne, p_n, p_nw) + arc_w = geompy.MakeArc (p_nw, p_w, p_sw) + + arc_n1 = geompy.MakeArc (p_ne, p_n1, p_n) + arc_n2 = geompy.MakeArc (p_n, p_n2, p_nw) + arc_s1 = geompy.MakeArc (p_sw, p_s1, p_s) + arc_s2 = geompy.MakeArc (p_s, p_s2, p_se) + + return doc + +# ======================================================= test_asso_mano +def test_asso_mano () : + + doc = init_globale ("asso_mano") + + ed_west.addAssociation (arc_w, 0, 1) + ed_est .addAssociation (arc_e, 0, 1) + + v_n.setAssociation (p_n) + ed_nord2.addAssociation (arc_n1, 0.0, 1.0) + ed_nord1.addAssociation (arc_n2, 0.0, 1.0) + + v_s.setAssociation (p_s) + ## ed_sud1.addAssociation (arc_s, 0.0, 0.5) + ## ed_sud2.addAssociation (arc_s, 0.5, 1.0) + + ed_sud1.addAssociation (arc_s1, 0.0, 1.0) + ed_sud2.addAssociation (arc_s2, 0.0, 1.0) + + return doc + +# ======================================================= test_asso_closed +def test_asso_closed () : + + doc = init_globale ("asso_closed") + + les_edges = [ ed_sud1, ed_sud2, ed_est, ed_nord1, ed_nord2, ed_west ] + les_arcs = [ arc_s1, arc_s2, arc_e, arc_n1, arc_n2, arc_w ] + + doc.associateClosedLine (v_sw, les_edges[0], les_edges[1:], + les_arcs [0], 0.0, False, les_arcs[1:]) + return doc + +# ======================================================= test_asso_closed_inv +def test_asso_closed_inv () : + + doc = init_globale ("asso_closed_inv") + + les_edges = [ ed_sud1, ed_sud2, ed_est, ed_nord1, ed_nord2, ed_west ] + les_arcs = [ arc_s1, arc_s2, arc_e, arc_n1, arc_n2, arc_w ] + + doc.associateClosedLine (v_s , les_edges[0], les_edges[1:], + les_arcs [0], 1.0, True, les_arcs[1:]) + return doc + +# ======================================================= test_asso_opened +def test_asso_opened () : + + doc = init_globale ("asso_opened") + + les_edges = [ ed_sud2, ed_est, ed_nord2 ] + les_arcs = [ arc_s, arc_e, arc_n ] + + doc.associateOpenedLine (les_edges[0], les_edges[1:], + les_arcs [0], 0.5, les_arcs[1:], 0.5) + return doc + +# ================================================================= Begin + +doc = test_asso_closed_inv () + +law = doc.addLaw("Uniform", 3) + +for j in range(doc.countPropagation()): + propa = doc.getPropagation(j) + propa.setLaw(law) + +mesh_hexas = hexablock.mesh (doc) + + diff --git a/src/TEST_PY/test_unit/test_bugs.py b/src/TEST_PY/test_unit/test_bugs.py index 187ccdb..b9b5d8d 100644 --- a/src/TEST_PY/test_unit/test_bugs.py +++ b/src/TEST_PY/test_unit/test_bugs.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 diff --git a/src/TEST_PY/test_unit/test_carre.py b/src/TEST_PY/test_unit/test_carre.py index 84dd5b6..d2df2a6 100644 --- a/src/TEST_PY/test_unit/test_carre.py +++ b/src/TEST_PY/test_unit/test_carre.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 diff --git a/src/TEST_PY/test_unit/test_cone.py b/src/TEST_PY/test_unit/test_cone.py index d7341b6..e7716fe 100644 --- a/src/TEST_PY/test_unit/test_cone.py +++ b/src/TEST_PY/test_unit/test_cone.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 diff --git a/src/TEST_PY/test_unit/test_cross.py b/src/TEST_PY/test_unit/test_cross.py index f8cfed5..8fcb4fa 100644 --- a/src/TEST_PY/test_unit/test_cross.py +++ b/src/TEST_PY/test_unit/test_cross.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 diff --git a/src/TEST_PY/test_unit/test_cylinders.py b/src/TEST_PY/test_unit/test_cylinders.py index 480e18a..2e70963 100644 --- a/src/TEST_PY/test_unit/test_cylinders.py +++ b/src/TEST_PY/test_unit/test_cylinders.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 diff --git a/src/TEST_PY/test_unit/test_disco.py b/src/TEST_PY/test_unit/test_disco.py index 34563ba..0c37bc6 100644 --- a/src/TEST_PY/test_unit/test_disco.py +++ b/src/TEST_PY/test_unit/test_disco.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 diff --git a/src/TEST_PY/test_unit/test_double_t.py b/src/TEST_PY/test_unit/test_double_t.py index cf2bf11..801224d 100644 --- a/src/TEST_PY/test_unit/test_double_t.py +++ b/src/TEST_PY/test_unit/test_double_t.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 diff --git a/src/TEST_PY/test_unit/test_perform.py b/src/TEST_PY/test_unit/test_perform.py index 7e4e79f..fd598c8 100644 --- a/src/TEST_PY/test_unit/test_perform.py +++ b/src/TEST_PY/test_unit/test_perform.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 diff --git a/src/TEST_PY/test_unit/test_piquage.py b/src/TEST_PY/test_unit/test_piquage.py index 134ecd2..932ae3d 100644 --- a/src/TEST_PY/test_unit/test_piquage.py +++ b/src/TEST_PY/test_unit/test_piquage.py @@ -20,80 +20,81 @@ # Hexa : Creation d'hexaedres +#### import os import hexablock -import os -import geompy +geompy = hexablock.geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 +use_paraview = False # ======================================================= test_pipes def test_piquage () : - doc = hexablock.addDocument ("default") + name = "piquage" + doc = hexablock.addDocument (name) - orig = doc.addVertex ( 0, 0, 0) + orig = doc.addVertex ( 8, 0, 0) vx = doc.addVector ( 1 ,0, 0) vy = doc.addVector ( 0, 1, 0) vz = doc.addVector ( 0, 0, 1) - size_x = 3 - size_y = 3 - size_z = 3 + size_x = 5 + size_y = 5 + size_z = 3 + size_cyl = 12 - grid = doc.makeCartesian (orig, vx, vy, vz, size_x, size_y, size_z) + rint = 2 + rext = 3 + angle = 360 + haut = 1 + nr = 1 + nh = 1 - c1 = grid.getVertexIJK (1, 2, size_z) - c2 = grid.getVertexIJK (1, 1, size_z) - c3 = grid.getVertexIJK (2, 1, size_z) + grid = doc.makeCartesianTop (size_x, size_y, size_z) + pipe = doc.makePipeUni (orig, vx, vz, rint, rext, angle, + haut, nr, size_cyl, nh) - pa1 = doc.addVertex (-1, -1, 0) - pb1 = doc.addVertex ( 1, -1, 0) - pc1 = doc.addVertex ( 1, 1, 0) - pd1 = doc.addVertex (-1, 1, 0) + c1 = grid.getVertexIJK (2, 1, size_z) + c2 = grid.getVertexIJK (3, 1, size_z) - pa2 = doc.addVertex (-2, -2, 0) - pb2 = doc.addVertex ( 2, -2, 0) - pc2 = doc.addVertex ( 2, 2, 0) - pd2 = doc.addVertex (-2, 2, 0) - - edab1 = doc.addEdge (pa1, pb1) - edbc1 = doc.addEdge (pb1, pc1) - edcd1 = doc.addEdge (pc1, pd1) - edda1 = doc.addEdge (pd1, pa1) - - edab2 = doc.addEdge (pa2, pb2) - edbc2 = doc.addEdge (pb2, pc2) - edcd2 = doc.addEdge (pc2, pd2) - edda2 = doc.addEdge (pd2, pa2) - - edaa = doc.addEdge (pa1, pa2) - edbb = doc.addEdge (pb1, pb2) - edcc = doc.addEdge (pc1, pc2) - eddd = doc.addEdge (pd1, pd2) + p1 = pipe.getVertexIJK (1, 7, 1) + p2 = pipe.getVertexIJK (1, 8, 1) qpattern = [] - qpattern.append (doc.addQuad (edab1, edbc1, edcd1, edda1)) - qpattern.append (doc.addQuad (edab1, edbb, edab2, edaa)) - qpattern.append (doc.addQuad (edbc1, edcc, edbc2, edbb)) - qpattern.append (doc.addQuad (edcd1, eddd, edcd2, edcc)) - qpattern.append (doc.addQuad (edda1, edaa, edda2, eddd)) - - doc.saveVtk ("replace0.vtk") - - doc.replace (qpattern, pd2,c1, pa2,c2, pb2,c3) - - doc.saveVtk ("replace1.vtk") + qtarget = [] + for na in range (size_cyl) : + quad = pipe.getQuadIJ (0, na, 1) + quad.setColor (2) + qpattern.append (quad) + + for ni in range (1, size_x-1) : + for nj in range (1, size_y-1) : + quad = grid.getQuadIJ (ni, nj, size_z) + quad.setColor (2) + qtarget.append (quad) + + c1.setColor (6) + c2.setColor (4) + + p1.setColor (6) + p2.setColor (4) + if use_paraview : + doc.saveVtk ("replace0.vtk") + + doc.replace (qpattern, qtarget, p1,c1, p2,c2) + if use_paraview : + doc.saveVtk ("replace1.vtk") + + pipe.remove() + if use_paraview : + doc.saveVtk ("replace2.vtk") return doc # ================================================================= Begin doc = test_piquage () -law = doc.addLaw("Uniform", 0) - -for j in range(doc.countPropagation()): - propa = doc.getPropagation(j) - propa.setLaw(law) +doc.addLaws (0.9, True) -mesh_hexas = hexablock.mesh(doc, "maillage:hexas") +mesh_hexas = hexablock.mesh (doc, "maillage:hexas") diff --git a/src/TEST_PY/test_unit/test_rind.py b/src/TEST_PY/test_unit/test_rind.py index 5bc4226..d61f77c 100644 --- a/src/TEST_PY/test_unit/test_rind.py +++ b/src/TEST_PY/test_unit/test_rind.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 diff --git a/src/TEST_PY/test_unit/test_shapes.py b/src/TEST_PY/test_unit/test_shapes.py index 747c2c4..82472d7 100644 --- a/src/TEST_PY/test_unit/test_shapes.py +++ b/src/TEST_PY/test_unit/test_shapes.py @@ -22,9 +22,8 @@ # ============================================================================================= import math - -import geompy import hexablock +geompy = hexablock.geompy # Construire le modèle de bloc # ============================ diff --git a/src/TEST_PY/test_unit/test_sphere.py b/src/TEST_PY/test_unit/test_sphere.py index e94a2e8..7eff6f4 100644 --- a/src/TEST_PY/test_unit/test_sphere.py +++ b/src/TEST_PY/test_unit/test_sphere.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 diff --git a/src/TEST_PY/test_unit/test_transfo.py b/src/TEST_PY/test_unit/test_transfo.py index 39c972a..e09e758 100644 --- a/src/TEST_PY/test_unit/test_transfo.py +++ b/src/TEST_PY/test_unit/test_transfo.py @@ -22,7 +22,6 @@ import hexablock import os -import geompy #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 diff --git a/src/TEST_PY/test_unit/troisCylindres_v5.py b/src/TEST_PY/test_unit/troisCylindres_v5.py index 7b13a38..9e42a3e 100644 --- a/src/TEST_PY/test_unit/troisCylindres_v5.py +++ b/src/TEST_PY/test_unit/troisCylindres_v5.py @@ -21,8 +21,8 @@ # Francis KLOSS : 2012 : CEA-Saclay, DEN, DM2S, SFME, LGLS, F-91191 Gif-sur-Yvette, France # ======================================================================================== -import geompy import hexablock +geompy = hexablock.geompy # Charger la geometrie # ====================