From 477b7b7c83bbdc72658b0561639a253afb8ab62d Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 8 Oct 2012 14:05:59 +0000 Subject: [PATCH] Merge from V6_main (04/10/2012) --- idl/Document.idl | 30 +- idl/Edge.idl | 5 +- idl/Hexa.idl | 5 +- idl/Quad.idl | 5 +- idl/Vertex.idl | 5 +- internal_doc/index.html | 893 ++++----- src/HEXABLOCK/HexCylinder.cxx | 13 +- src/HEXABLOCK/HexDocument_Xml.cxx | 19 +- src/HEXABLOCK/HexEdge.cxx | 15 + src/HEXABLOCK/HexEdge.hxx | 3 +- src/HEXABLOCK/HexElements.cxx | 41 +- src/HEXABLOCK/HexElements_bis.cxx | 51 +- src/HEXABLOCK/HexElements_grid.cxx | 10 +- src/HEXABLOCK/HexElements_piq.cxx | 2 +- src/HEXABLOCK/HexElements_ter.cxx | 11 +- src/HEXABLOCK/HexEltBase.cxx | 48 +- src/HEXABLOCK/HexEltBase.hxx | 7 +- src/HEXABLOCK/HexHexa.cxx | 12 +- src/HEXABLOCK/HexPipe.cxx | 3 + src/HEXABLOCK/HexQuad.cxx | 35 +- src/HEXABLOCK/HexQuad.hxx | 6 +- src/HEXABLOCK/hexa_base.hxx | 2 +- src/HEXABLOCKGUI/CutEdge_QTD.ui | 62 +- src/HEXABLOCKGUI/Cylinder_QTD.ui | 27 +- src/HEXABLOCKGUI/Disconnect_QTD.ui | 217 +-- src/HEXABLOCKGUI/EdgeAssoc_QTD.ui | 122 +- src/HEXABLOCKGUI/Edge_QTD.ui | 119 +- src/HEXABLOCKGUI/Group_QTD.ui | 158 +- src/HEXABLOCKGUI/HEXABLOCKGUI.cxx | 571 +++--- src/HEXABLOCKGUI/HEXABLOCKGUI.hxx | 12 +- .../HEXABLOCKGUI_DocumentDelegate.cxx | 407 +--- .../HEXABLOCKGUI_DocumentDelegate.hxx | 35 +- .../HEXABLOCKGUI_DocumentGraphicView.cxx | 194 +- .../HEXABLOCKGUI_DocumentGraphicView.hxx | 28 +- .../HEXABLOCKGUI_DocumentItem.cxx | 503 ++--- .../HEXABLOCKGUI_DocumentItem.hxx | 221 +-- .../HEXABLOCKGUI_DocumentModel.cxx | 1321 ++++--------- .../HEXABLOCKGUI_DocumentModel.hxx | 19 +- .../HEXABLOCKGUI_DocumentPanel.cxx | 1703 ++++++++++++----- .../HEXABLOCKGUI_DocumentPanel.hxx | 95 +- .../HEXABLOCKGUI_DocumentSelectionModel.cxx | 575 +++--- .../HEXABLOCKGUI_DocumentSelectionModel.hxx | 21 +- src/HEXABLOCKGUI/HEXABLOCKGUI_SalomeTools.cxx | 5 + src/HEXABLOCKGUI/HEXABLOCKGUI_SalomeTools.hxx | 4 + src/HEXABLOCKGUI/HEXABLOCKGUI_Trace.cxx | 2 +- src/HEXABLOCKGUI/Hexa_QTD.ui | 68 +- src/HEXABLOCKGUI/JoinQuad_QTD.ui | 151 +- src/HEXABLOCKGUI/Law_QTD.ui | 14 +- src/HEXABLOCKGUI/MakeCartesian_QTD.ui | 376 ++-- src/HEXABLOCKGUI/MakeCylinder_QTD.ui | 58 +- src/HEXABLOCKGUI/MakeCylinders_QTD.ui | 21 +- src/HEXABLOCKGUI/MakeCylindrical_QTD.ui | 258 ++- src/HEXABLOCKGUI/MakeGrid_QTD.ui | 225 ++- src/HEXABLOCKGUI/MakeHemiSphere_QTD.ui | 106 +- src/HEXABLOCKGUI/MakePipe_QTD.ui | 58 +- src/HEXABLOCKGUI/MakePipes_QTD.ui | 15 +- src/HEXABLOCKGUI/MakeRind_QTD.ui | 143 +- src/HEXABLOCKGUI/MakeSpherical_QTD.ui | 70 +- src/HEXABLOCKGUI/MakeTranslation_QTD.ui | 69 +- src/HEXABLOCKGUI/MergeEdges_QTD.ui | 201 +- src/HEXABLOCKGUI/MergeVertices_QTD.ui | 57 +- src/HEXABLOCKGUI/Merge_QTD.ui | 95 +- src/HEXABLOCKGUI/MyBasicGUI_PointDlg.cxx | 59 +- src/HEXABLOCKGUI/MyBasicGUI_PointDlg.hxx | 4 +- src/HEXABLOCKGUI/MyGEOMBase_Helper.hxx | 18 +- src/HEXABLOCKGUI/MyGEOMBase_Skeleton.cxx | 24 +- src/HEXABLOCKGUI/MyGEOMBase_Skeleton.hxx | 4 +- src/HEXABLOCKGUI/Pipe_QTD.ui | 100 +- src/HEXABLOCKGUI/PrismQuad_QTD.ui | 291 ++- src/HEXABLOCKGUI/Propagation_QTD.ui | 45 +- src/HEXABLOCKGUI/QuadAssoc_QTD.ui | 48 +- src/HEXABLOCKGUI/QuadRevolution_QTD.ui | 76 +- src/HEXABLOCKGUI/Quad_QTD.ui | 151 +- src/HEXABLOCKGUI/RemoveHexa_QTD.ui | 8 +- src/HEXABLOCKGUI/ReplaceHexa_QTD.ui | 219 ++- src/HEXABLOCKGUI/Symmetry_QTD.ui | 111 +- src/HEXABLOCKGUI/Transformation_QTD.ui | 39 +- src/HEXABLOCKGUI/Vector_QTD.ui | 102 +- src/HEXABLOCKGUI/Vertex_QTD.ui | 254 +-- src/HEXABLOCK_I/HEXABLOCK.cxx | 5 +- src/HEXABLOCK_I/HexDocument_impl.cxx | 68 +- src/HEXABLOCK_I/HexDocument_impl.hxx | 12 +- src/HEXABLOCK_I/HexEdge_impl.cxx | 7 +- src/HEXABLOCK_I/HexEdge_impl.hxx | 1 + src/HEXABLOCK_I/HexHexa_impl.cxx | 6 + src/HEXABLOCK_I/HexHexa_impl.hxx | 1 + src/HEXABLOCK_I/HexQuad_impl.cxx | 6 + src/HEXABLOCK_I/HexQuad_impl.hxx | 1 + src/HEXABLOCK_I/HexVertex_impl.cxx | 6 + src/HEXABLOCK_I/HexVertex_impl.hxx | 1 + src/TEST_PY/INTER_3_CYLINDRE.py | 415 ---- src/TEST_PY/Makefile.am | 22 +- src/TEST_PY/TUYAU_COURBE.py | 790 -------- src/TEST_PY/Test_HEXABLOCK.py | 280 --- src/TEST_PY/bielle.py | 545 ------ src/TEST_PY/bielle_variante.py | 248 --- src/TEST_PY/bride.py | 410 ---- src/TEST_PY/foo.py | 4 + src/TEST_PY/recettes/cuve.py | 1145 +++++------ src/TEST_PY/test_BIELLE_bad_assoc.py | 1081 ----------- src/TEST_PY/test_BIELLE_no_assoc.py | 1075 ----------- src/TEST_PY/test_HEXABLOCK.py | 418 ---- src/TEST_PY/test_INTER_3_CYLINDRE_no_assoc.py | 433 ----- src/TEST_PY/test_TUYAU_COURBE_no_assoc.py | 466 ----- src/TEST_PY/test_TUYAU_COURBE_weird_assoc.py | 808 -------- src/TEST_PY/test_distrib.py | 111 -- 106 files changed, 6875 insertions(+), 12670 deletions(-) delete mode 100755 src/TEST_PY/INTER_3_CYLINDRE.py delete mode 100755 src/TEST_PY/TUYAU_COURBE.py delete mode 100755 src/TEST_PY/Test_HEXABLOCK.py delete mode 100644 src/TEST_PY/bielle.py delete mode 100644 src/TEST_PY/bielle_variante.py delete mode 100644 src/TEST_PY/bride.py create mode 100644 src/TEST_PY/foo.py delete mode 100755 src/TEST_PY/test_BIELLE_bad_assoc.py delete mode 100755 src/TEST_PY/test_BIELLE_no_assoc.py delete mode 100755 src/TEST_PY/test_HEXABLOCK.py delete mode 100755 src/TEST_PY/test_INTER_3_CYLINDRE_no_assoc.py delete mode 100755 src/TEST_PY/test_TUYAU_COURBE_no_assoc.py delete mode 100755 src/TEST_PY/test_TUYAU_COURBE_weird_assoc.py delete mode 100755 src/TEST_PY/test_distrib.py diff --git a/idl/Document.idl b/idl/Document.idl index 39de1e2..ae3eed6 100755 --- a/idl/Document.idl +++ b/idl/Document.idl @@ -167,11 +167,11 @@ module HEXABLOCK_ORB Vector addVectorVertices( in Vertex v1, in Vertex v2 ) raises (SALOME::SALOME_Exception); -// long countVector() -// raises (SALOME::SALOME_Exception); -// -// Vector getVector( in long i ) -// raises (SALOME::SALOME_Exception); + long countVector() + raises (SALOME::SALOME_Exception); + + Vector getVector( in long i ) + raises (SALOME::SALOME_Exception); /*! @@ -180,11 +180,11 @@ module HEXABLOCK_ORB Cylinder addCylinder( in Vertex base, in Vector direction, in double radius, in double height ) raises (SALOME::SALOME_Exception); -// long countCylinder() -// raises (SALOME::SALOME_Exception); -// -// Cylinder getCylinder( in long i ) -// raises (SALOME::SALOME_Exception); + long countCylinder() + raises (SALOME::SALOME_Exception); + + Cylinder getCylinder( in long i ) + raises (SALOME::SALOME_Exception); /*! @@ -195,11 +195,11 @@ module HEXABLOCK_ORB in double height ) raises (SALOME::SALOME_Exception); -// long countPipe() -// raises (SALOME::SALOME_Exception); -// -// Pipe getPipe( in long i ) -// raises (SALOME::SALOME_Exception); + long countPipe() + raises (SALOME::SALOME_Exception); + + Pipe getPipe( in long i ) + raises (SALOME::SALOME_Exception); /*! diff --git a/idl/Edge.idl b/idl/Edge.idl index 292d4ed..6b2ef6c 100755 --- a/idl/Edge.idl +++ b/idl/Edge.idl @@ -72,7 +72,10 @@ module HEXABLOCK_ORB // void removeAssociation() // raises (SALOME::SALOME_Exception); - void setScalar( in double val ) //CS_NOT_SPEC + void setColor (in double val) + raises (SALOME::SALOME_Exception); + + void setScalar( in double val ) //CS_NOT_SPEC --> To delete raises (SALOME::SALOME_Exception); }; diff --git a/idl/Hexa.idl b/idl/Hexa.idl index a50704c..bbd8452 100755 --- a/idl/Hexa.idl +++ b/idl/Hexa.idl @@ -43,7 +43,10 @@ module HEXABLOCK_ORB Edge getEdge( in long n ) raises(SALOME::SALOME_Exception); Vertex getVertex( in long n ) raises(SALOME::SALOME_Exception); - void setScalar( in double val ) //CS_NOT_SPEC + void setColor (in double value) + raises (SALOME::SALOME_Exception); + + void setScalar( in double val ) //CS_NOT_SPEC --> To delete raises (SALOME::SALOME_Exception); }; diff --git a/idl/Quad.idl b/idl/Quad.idl index 1248023..b182cd2 100755 --- a/idl/Quad.idl +++ b/idl/Quad.idl @@ -63,7 +63,10 @@ module HEXABLOCK_ORB // void removeAssociation() // raises (SALOME::SALOME_Exception); - void setScalar( in double val ) //CS_NOT_SPEC + void setColor (in double value) + raises (SALOME::SALOME_Exception); + + void setScalar( in double val ) //CS_NOT_SPEC --> To delete raises (SALOME::SALOME_Exception); }; diff --git a/idl/Vertex.idl b/idl/Vertex.idl index e10c993..b1ee130 100755 --- a/idl/Vertex.idl +++ b/idl/Vertex.idl @@ -56,7 +56,10 @@ module HEXABLOCK_ORB void clearAssociation() raises (SALOME::SALOME_Exception); - void setScalar( in double val ) //CS_NOT_SPEC + void setColor (in double value) + raises (SALOME::SALOME_Exception); + + void setScalar( in double val ) //CS_NOT_SPEC --> To delete raises (SALOME::SALOME_Exception); }; diff --git a/internal_doc/index.html b/internal_doc/index.html index 90be523..5a9f598 100755 --- a/internal_doc/index.html +++ b/internal_doc/index.html @@ -1,448 +1,449 @@ - - - - - - - -Projet HEXABLOCK - -  - - - - - - - -
Simply Moira 
-
-
-HexaBlock
-
-Bibliothèque de formes

Documentation interne du moteur

-
-

-Ce document constitue la documentation interne du composant HEXABLOCK.
Ce -document fait partie des sources du projet et est géré en -configuration Pour le mettre à jour, utiliser kompozer, disponible sur -Linux
-
-
-
-

o Table of contents : -
-  -

-
- - - - - - - - - - - - - - -
-
o   Partie 1 : Prévisualisation des éléments créés
-
-
o   Partie 2 : Nouvelles fonctions de construction
-
o   Partie 3 : Bibliothèques de formes
o   Partie 4 : Evolution des associations
-
-

o See also :

- - - - - - - - - - - - -
-
o   Last news
-
o   Last last News : Voir les nouvelles formes
o   Précisions sur las associations par lignes
-
o   Frequently asked questions
-
o   Maintenance
-
-

-
-

-

o Partie 1 : prévisualisation des éléments créés

Pour -que SALOME puisse prévisualiser le "document" en cours de modivication, -il est nécessaire de créer une copie de l'original. L'évolution -majeure du moteur  consiste à implémenter une fonction de -copie. 

Ce qui revient à ajouter dans la classe Document la méthode suivante :

- - - - - - -
Document* copyDocument (); -
-
La valeur rendue est le document copié.
Les éléments copiés sont les éléments -intrinsèques du document : vertices, edges, quadrangles, hexaèdres, -lois. Qui sont aussi ceux sauvegardés dans un texte XML. On ne stocke -pas les éléments intermédiaires de construction (grilles, vecteurs, -etc...).

Cette règle pourra être remise en cause si l'application interactive a besoin d'autres informations.

La copie se déroule ainsi :
Les associations sont copiées lors de la copie de chaque élément.


-Retour au début -
-

-

o - Partie 2 : Nouvelles fonctions de construction

o 2.1 Création d'Hexaèdres

-

Il s'agit de construire un hexaèdre à partir de quadrangles déjà créés dans le -modèle de blocs. Cet hexaèdre est produit à partir des 4 cas suivants :

- -Les points d'entrée sont naturellement :

- - - - - - - - -
Hexa* addHexa2Quads (Quad* q1, Quad* q2);
Hexa* addHexa3Quads (Quad* q1, Quad* q2, Quad* q3);
Hexa* addHexa4Quads (Quad* q1, Quad* q2, Quad* q3, Quad* q4);
Hexa* addHexa5Quads (Quad* q1, Quad* q2, Quad* q3, Quad* q4, Quad* q5);

Chacun des cas amène une discussion. La démarche est la suivante : 

Remarques :
o    Rappel  :  formalisation des Hexaèdres/Quadrangles/Vertex


Pour rappel :
- - - - - -
          -//      z=0   z=1   -y=0   y=1   x=0  x=1
enum EnumHQuad   {Q_A,  Q_B,  Q_C,  Q_D,  Q_E, Q_F,  HQ_MAXI};

La face A est opposée à B, C est opposée à D, E à F. La -position des faces  A, C, E normales à Oz, Oy, Ox est purement -théorique. Elle améliore la visualisation. Les orientations sont en -fait  interchangeables. On peut intervertir les couples (C,D) et -(E,F), on peut intervertir A et B, C et D, E et F, l'essentiel est -d'avoir une cohérence  avec les autres dénominations d'edges (ac, -af, ad ...) ou de sommets (ace, acf, adf ...)  et les -conventions de départ.

L'arête située entre la face X et la face Y est notée xy. Un sommet situé entre les 3 faces X, Y Z est noté xyz :

- - -

       6=bde  +----bd-----+ bdf=7
             -/|          /|
           be |   B    bf |
           /  |        /  |
    4=bce +----bc-----+...|...bcf=5
          |  de     D |   df
          -| E |       | F -|          -z
         ce   | -C     cf  -|           -^
  2=ade...|...+----ad-|---+ adf=3     |   y
          -|  /        |  -/            -|  /
          | -ae    A   | -af            -| /
          -|/          -|/              -|/
    0=ace +----ac-----+ acf=1         +-----> x
  


o    La classe AnaQuads

Cette -classe analyse les relations topologiques existant entre plusieurs -quandrangles. Un objet de ce type est créé au début de chaque fonction -addHexaXQuads.

Le constructeur est :

- - - - - - - - -
AnaQuads (Quad* q1, Quad* q2, Quad* q3=NULL, Quad* q4=NULL, Quad* q5=NULL);

Les champs affectés lors de la construction de l'objet :

MawQuads Constante égale à 5 5
int    nbr_quads;Nombre de quadrangles
int    nbr_aretes;Nombre total d'arêtes
Quad*  tab_quads  [i];Le ième quadrangle passé en argument
int    inter_nbre [i];Nombre d'intersections du ième quadrangle
int    inter_edge [i][j];Nro d'arête de i intersectant le jème quadrangle
int    inter_quad [i][j];Nro de quadrangle présent sur la jème arete du iéme quad

o    La classe Cramer

Cette -classe résout un système linéaire de n équations  à n inconnues. -Quand n est "petit", n<10. Peut être réutilisée sur un autre projet. -
Implémentation : HexCramer.hxx.
Test unitaire : test_cramer dans test_hexa1.cxx


- - - - - - - - -
int test_cramer (int nbargs, cpchar tabargs[])
{
   double matrice [] = { 2, 7, 1,    0, 3, 0,    1, 9, 5 };
   double second_membre  [] = { 1, 1, 1 };
   Hex::Real3  solution;
   Hex::Cramer system(3);   // On dimensionne le système de Cramer à la construction

   int ier = system.resoudre (matrice, second_membre, solution);

   -cout << " Solution  = (" << solution[0] << ", " -<< solution[1] << ", " << solution[2]
        << "), ier = " << ier << endl;
  -                    -           // Pour vérifier :
   Hex::Real3 produit;
   system.multiply (solution, produit);
   -cout << " Produit = (" << produit[0] << ", " -<< produit[1] << ", " << produit[2]
        << ")"  << endl;
   return HOK;
}




o    Création d'un hexaèdre avec deux quadrangles :  

En diedre

Vis a vis
addHexa2Quads avec 2 quadrangles  non reliés.
Fonction : addHexaQuadsAB
addHexa2Quads avec 2 quadrangles   reliés.
Fonction : addHexaQuadsAC

addHexaQuadAB :

Les huits sommets sont présents, il manque quatre arêtes verticales ce, cf, df, de.
La -difficuté consiste à faire correspondre deux à deux les quatre sommets -de chaque quadrangle sans que les arêtes ne se croisent. La situation -est analogue à mergeQuads ou joinQuads, sauf que dans ces cas, on passe -en argument quatre vertex pour déterminer dans ambiguité les sommets -correspondants deux à deux. On a choisi ici -d'automatiser l'association :
Une fois la combinaison optimale établie :
Pour créer le i-ème quadrangle vertical :

addHexaQuadAC :

Deux -faces présentes A et C, une arête commune ac. Il manque deux sommets -bde et bdf à partir desquels on construit les arêtes manquantes bd, -be, de, bf, df. 
On doit s'assurer de la planéité des quadrangles créés.

La -solution n'est pas unique. Il existe une infinité de sommets pouvant -définir un hexaèdre  conforme. On se contente ici d'en choisir une -et de démontrer que l'objet créé est conforme. 

Le point bde (resp bdf) est construit en -sommant les vecteurs ac et ce (resp af et cf), ce qui revient à -définir un parallélogramme. On assure ainsi sa présence dans le plan E -(resp. F). Les faces créées E et F sont donc planaires.

Pour démontrer la planéité de la face B :

- - - - - -
  1. (ae , af)  coplanaires (donnée)
  2. be = ae (construction d'un parallèlogramme)
  3. df = af  (idem)
  4. (1), (2), (3) => (be, bf) coplanaires

On procéderait de la même manière pour établir que la face D est plane.

La fonction s'écrit ainsi :

o    Création d'un hexaèdre avec trois quadrangles :  


En diedre

Trièdre
addHexa2Quads avec 3 quadrangles disposés en U.
Fonction : addHexaQuadsACD
addHexa2Quads avec  quadrangles disposés  en trièdre
Fonction : addHexaQuadsACE


addHexaQuadACD :

Tous les sommets sont présents. Il reste à créer :

La difficulté est d'identifier clairement les arêtes et les sommets à partir des quadrangles existant : 

addHexaQuadACE :

Il -est nécessaire de créer le sommet v_bdf. Il est l'intersection des -plans (B, D, F). Chaque plan est défini par trois points présents sur -les autres quadrangles :

Soit un plan P défini par un point A et un vecteur normal N. Un point M appartient à P si le produit scalaire N.AM est nul

On obtient le système d'équations

- - - - - -
  1. (bdf,bce) . norm_b = 0
  2. (bdf,ade) . norm_d = 0
  3. (bdf,acf) . norm_f = 0
Equivalent à : 
- - - - - -
  1.    norme_b[0]*X + norme_b[1]*Y + norme_b[2]*Z = prod_scalaire (v_bce, norm_b)
  2.    norme_d[0]*X + norme_d[1]*Y + norme_d[2]*Z = prod_scalaire (v_ade, norm_d)
  3.    norme_f[0]*X + norme_f[1]*Y + norme_f[2]*Z = prod_scalaire (v_acf, norm_f)

Ce système de 3 équations à trois inconnues est résolu par la méthode de Cramer au moyen d'une classe du même nom défini dans le nouveau fichier HexCramer.hxx. Notons qu'un test unitaire de la classe Cramer existe dans le fichier test_quads.cxx

Une fois le système résolu ; s'il n'est pas régulier on retourne un vecteur nul, la suite est aisée :

o    Création d'un hexaèdre avec quatre quadrangles :  

En tunnel

En but
addHexa2Quads avec 4 quadrangles  disposés en tunnel.
Fonction : addHexaQuadsABCD
addHexa2Quads avec 4 quadrangles disposés en fauteuil.
Fonction : addHexaQuadsACDE

addHexaQuadABCD :

Le -rôle des quadrangles passés en arguments est symétrique On nommera q_a -le premier trouvé, q_c le premier qui intersecte q_a, q_c le second et -q_d celui qui n'intersecte pas q_a.

Tous les sommets et arêtes sont présents. Il suffit de créer les deux quadrangles E et F:

Les problèmes de détermination des variables se traitent comme dans addHexaQuadABC

addHexaQuadACDE :

Le rôle de q_a et qc est symétrique. Ils ont chacun trois arêtes communes avec les autres. q_e et q_f n'en ont que 2.

Tous les sommets sont présents. Il suffit de créer l'arête e_bf et les deux quadrangles B et F:

Les edges se déterminent aisément grâce aux indices d'intersection fournis par AnaQuads. Il suffit de prendre l'opposé. On utilise la propriété de la classe Quad : l'indice d'une arête opposée à l'arête i vaut i+2.

- - -
   int   nc_ac = strquads.inter_edge[pos_c][pos_a]; // Nro dans  q_c de e_ac
   int   nc_ce = strquads.inter_edge[pos_c][pos_e]; // Nro dans  q_c de e_ce
   int   nd_ad = strquads.inter_edge[pos_d][pos_a]; // Nro dans  q_d de e_ad
   int   nd_de = strquads.inter_edge[pos_d][pos_e]; // Nro dans  q_d de e_de
   int   ne_ae = strquads.inter_edge[pos_e][pos_a]; // Nro dans  q_e de e_ae

   Edge* e_af  = q_a->getEdge ((na_ac + 3) MODULO QUAD4);
   Edge* e_bc  = q_c->getEdge ((nc_ac + 2) MODULO QUAD4);
   Edge* e_cf  = q_c->getEdge ((nc_ce + 2) MODULO QUAD4);
   Edge* e_bd  = q_d->getEdge ((nd_ad + 2) MODULO QUAD4);
   Edge* e_df  = q_d->getEdge ((nd_de + 2) MODULO QUAD4);
   Edge* e_be  = q_e->getEdge ((ne_ae + 2) MODULO QUAD4);

   Vertex* v_bcf = e_cf->opposedVertex (e_cf->commonVertex (e_af));
   Vertex* v_bdf = e_df->opposedVertex (e_df->commonVertex (e_af));

o    Création d'un hexaèdre avec cinq quadrangles : 

Il n'y a pas besoin de dissocier plusieurs cas, le travail est réalisé directement dans la méthode addHexa5Quads().

En but

Ce cas est assez simple : c'est un hexaèdre auquel il manque la face que l'on convient de nommer B.

Retour au début

o 2.2 Génération d'Hexaèdres par révolution

Le pont d'entrée dans la classe Document est :
- - -

- - - - - -
Elements* revolutionQuads (Quads& start, Vertex* center, Vector* axis, vector<double>& angles);

Avec :



En diedre

Trièdre
Avant la revolution : on a coloré les quadrangles à déplacer, ainsi que l'axe de rotation.Résultat de  la revolution.

Retour au début

o 2.3 Substitution d'Hexaèdres

Il -s'agit de remplacer un hexaèdre ou des hexaèdres par une autre série -d'hexaaaèdres. Pour pouvoir effectuer ce remplacement, cette autre -série d'hexaèdres doit vérifier des conditions de collage de faces.
- - -



En diedre

Trièdre
Exemple -: remplacement des 3 hexaèdres jaunes centraux par 3 fois 5 nouveaux -hexaèdres qui sont construits par extrusion des 5 quadrangles marrons -(le motif).Résultat du remplacement. 


La signature de la fonction est la suivante :
- - - - - -
Elements* Document::revolutionQuads (Hexas& pattern, Vertex* p1, Vertex* c1,
  -                    -               Vertex* -p2, Vertex* c2, Vertex* p3, Vertex* c3);

Avec :

Conditions : 

Pour désigner les faces d'un hexaèdres, on utilise les  notations habituelles définies plus haut.

Conventions et orientations :


Retour au début -


-

-

oPartie 3 : Bibliothèque de formes

Cette biblothèque est constituée de quatre nouvelles formes :

Ces formes sont implémentées (et traduites ....) de la façon suivante :

- - - - - -
Elements* makeSphere (Vertex* center, Vector* vx, Vector* vz,
                      double radius, 
double radhole,
                      Vertex* -plorig, 

                      int -nrad, int nang, int nhaut);
Elements* makePartSphere (Vertex* center, Vector* vx, Vector* vz,
                          double  radius,
double radhole,
                          Vertex* -plorig, double angle,
                          int -nrad, int nang, int nhaut);
Elements* makeRind (Vertex* center, Vector* vx, Vector* vz,
                    double  radius, double radint,
double radhole,
                    Vertex* -plorig, 
                    int -nrad, int nang, int nhaut);
Elements* makePartRind (Vertex* center, Vector* vx, Vector* vz,
                       
double  radius, double radint, double radhole,
                        Vertex* -plorig, double angle,
                        int -nrad, int nang, int nhaut);

Remarques :

o 3.1  Aspect visuel (exemples)


Conditions

Demi Sphere trouee

Huitième de sphère
Demi-Sphère trouée (makeSphere ())Huitième de sphère trouée (makePartSphere ())

Ecorce trouée    

Huitième d'ecorce       

Demi écorce trouée (makeRind ())Huitième d'écorce trouée (makePartRind ())

o 3.1  Implémentation

Toutes ces fonctions publiques appellent une seule fonction  de la classe Elements :

- - - -
int makeRind (EnumGrid type, Vertex* center, Vector* vx, Vector* vz,
             
double  radius, double radint, double radhole,
              Vertex* -plorig, double angle,
               int -nrad, int nang, int nhaut);

Une fonction controlRind() vérifie -la cohérence des arguments passés en entrée et calcule les deux extrema -de l'angle d'élévation phi (voir chapitre suivant).
Une boucle à triple indice sur (nrad, nang, nhaut) calcule les coordonnées des sommets par appel de la fonction getCylPoint (nx,ny,nz, px,py,pz).
Ce -calcul se fait sur une sphère de centre O et d'axe Oz, dont les -hexaedres sont comptés à partir de l'axe Ox de façon à remplir le -secteur angulaire theta.. Les coordonnées sont ensuite replacées dans -les coordonnes utilisateur grâce à la fonction transfoVertices(). Edges, quadrangles et hexaèdres sont ensuites assemblés grâce à  la fonction fillGrid().

o 3.2 Détermination de l'angle d'élévation (phi)  

L'angle -d'azimuth theta (longitude) est défini explicitement par l'utilisateur. -L'angle d'élévation phi est délimité par la position du  plan -horizontal et par le diamètre du trou.  Soit :

Sphere

A partir de ces éléments de base, on  définit :
L'angle d'élévation  phi  est encadré par les valeurs suivantes :

Retour au début -


-

-

oPartie 4 : Evolution des associations

Cette tâche est composée de 3 évolutions, au sujet de -l'association, qui sont décrites ci-après.

o 4.1 Nouveaux objets  

- -

Il s'agissait d'ajouter de nouveaux objets -intermédiaires de travail, comme le vecteur ou le cylindre :

- -Il était p aussi associer  -les objets intermédiaires aux objets géométriques venant du -composant GEOM de SALOME :

o 4.2 Associations prédéfinies  

La deuxième évolution consiste à améliorer les associations -des modèles de blocs prédéfinis en calculant automatiquement des associations -implicites, les fonctions concernées sont les suivantes:

- - - -

Pour chaque arête (sphérique) concernée, on associera un arc de cercle.

Il est inutile d'associer les faces, SMESH est capable de mailler si les arêtes sont associées.

Implémentation 

Rappelons que l'objet Shape de HexaBlock est constitué :

Deux opérations sont nécessaires  :

  1.  créer un cercle au moyen de GEOM,
  2. découper ce cercle en arcs de cercle qui seront associés aux arêtes concernées.

Opération 1 : -Le cercle à créer est en fait un arc de cercle orienté de 360 -degrés.  Il est en effet nécessaire de définir une origine. GEOM -permet de générer finir un tel -cercle, à partir duquel HexaBlock définira des arcs au moyen des -paramètres debut et fin des shapes :

Cette action est assurée par la fonction geom_create_circle -qui génère la brep du cercle à partir de son centre, de son rayon, -de son vecteur normal, du  vecteur Ox qui permet de définir son -origine.


- - - -
void geom_create_circle (double* centre, double rayon, Vector* normale,
                         -double* ox, string& brep)
{
   gp_Pnt gp_center (centre [dir_x], centre [dir_y], centre [dir_z]);
   -gp_Vec gp_ox     (ox     -[dir_x], ox     [dir_y], ox     -[dir_z]);
   gp_Vec gp_norm   (normale->getDx(), normale->getDy(), normale->getDz());

   gp_Ax2  gp_axes (gp_center, gp_norm, gp_ox);
   gp_Circ gp_circ (gp_axes,   rayon);

   TopoDS_Edge    geom_circ = BRepBuilderAPI_MakeEdge(gp_circ).Edge();
   ostringstream  stream_shape;
   BRepTools::Write(geom_circ, stream_shape);

   brep = stream_shape.str();
}

GEOM permet de définir un tel cercle (calsse gp_Circ)  à partir d'un systemes d'axes 2D (classe gp_Ax2 )  et d'un rayon. Ce cercle esr ensuite transformé en forme TopoDS_Shape qui est l'objet GEOM que l'on maniplule habituellement losque l'on procède aux associations. Plus précisément en TopoDS_Edge  au moyen de BRepBuilderAPI_MakeEdge. Enfin l'objet est  transformé en chaine de caractères de format Brep via ostringstream.

Opération 2 : -On dispose d'une b-rep  décrivant un arc de cercle de 360 degrés. -Il est aisé de définir proportionnellement pour chacun des edges -constituant la ligne associée à la portion de cercle les paramètres -début et fin par rapport aux angles de départ et d'arrivée de chaque -arc. Cette opération fut d'ailleurs réalisée lors de la préservarion -des associations lors d'un "cut". On réutilisera donc la fonction Elements::cutAssociation(...) moyennant quelques aménagements.

o 4.3 Propagation des associations  


La troisième évolution consiste à améliorer la propagation -automatique des associations, les fonctions concernées sont les suivantes:

- - - -

- -

Ces trois évolutions seront implémentées dans le moteur. -Seule le première évolution (création de sphères ou cercles) sera implémentée -dans la partie interactive.



o    Implémentation :


En -ce qui concerne les associations propagées par les transformations, la -fonction de base de l'implémentation est transfo_brep.
Cette fonction reprend la matrice du modèle de blocs et l'applique à la shape décrite par la brep.

// ====================================================== transfo_brep
void transfo_brep (string& brep, Matrix* matrice, string& trep)
{
   BRep_Builder  builder;
   TopoDS_Shape  shape_orig;
   ostringstream stream_shape;
   gp_Trsf       transfo;

   -double             -a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34;
   matrice->getCoeff (a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34);
   transfo.SetValues (a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34,
                      -Epsil2, Epsil2);

   istringstream stream_brep (brep);
   BRepTools::Read           (shape_orig, stream_brep, builder);
  
   BRepBuilderAPI_Transform brep_transfo (shape_orig, transfo, Standard_True);
   TopoDS_Shape result = brep_transfo.Shape();

   BRepTools::Write (result, stream_shape);
   trep = stream_shape.str();
}


Pour la fonction de prismQuads, on utilise une variante simplifiée :

// ====================================================== translate_brep
void translate_brep (string& brep, double dir[], string& trep)
{
   gp_Trsf       transfo;
   BRep_Builder  builder;
   TopoDS_Shape  orig;
   ostringstream stream_shape;

   -gp_Vec      -vecteur       (dir [dir_x], dir [dir_y], -dir [dir_z]);
   transfo.SetTranslation    (vecteur);
   istringstream stream_brep (brep);
   BRepTools::Read           (orig, stream_brep, builder);
  
   TopLoc_Location  loc_orig   = orig.Location();
   gp_Trsf          trans_orig = loc_orig.Transformation();
   TopLoc_Location  loc_result (transfo * trans_orig);
   TopoDS_Shape     result = orig.Located (loc_result);

   BRepTools::Write (result, stream_shape);
   trep = stream_shape.str();
}


Pour la fonction de prismQuads, on utilise une variante simplifiée :



o    Propagation des associations pour les transformations :


L'exemple donné est makeScale

# ======================================================= make_grid
def make_grid (doc) :
    ori  = doc.addVertex ( 0, 0, 0)
    vz   = doc.addVector ( 0, 0, 1)
    vx   = doc.addVector ( 1 ,0, 0)

    dr = 1
    da = 360
    dl = 1
    nr = 1
    na = 6
    nl = 1
    grid = doc.makeCylindrical (ori, vx,vz, dr,da,dl, nr,na,nl, False)
    return grid

# ======================================================= test_scale
def test_scale () :

    doc  = hexablock.addDocument()
    grid = make_grid (doc)

    dest   = doc.addVertex (15, 0, 0)
    grid2  = doc.makeScale (grid, dest, 0.5)
    return doc


transfo




o    Propagation des associations pour la fonction prismQuads

Pour la fonction prismQuads :


# ========================================================== test_prism
def test_prism () :
    doc  = hexablock.addDocument()
    nr = 1
    na = 6
    nl = 1
    grid = make_grid (doc, nr, na, nl)

    liste = [ ]
    for nx in range (nr) :
        for ny in range (na) :
            cell = grid.getQuadIJ (nx, ny, nl)
            liste.append (cell);

    axis = doc.addVector (1, 1, 1);
    bloc = doc.prismQuads  (liste, axis, 3)
    return doc


- - - -





Prisme





o    Propagation des associations pour la fonction revolutionQuads

Pour la fonction revolutionQuads


# ========================================================== test_revolution
def test_revolution () :
    doc  = hexablock.addDocument()
    nr = 1
    na = 6
    nl = 1
    grid = make_grid (doc, nr, na, nl)

    liste = [ ]
    for nx in range (nr) :
        for ny in range (na) :
            cell = grid.getQuadIJ (nx, ny, nl)
            print " ... cell = ", cell
            liste.append (cell);
ss

    center = doc.addVertex (0, -10, 0);
    axis   = doc.addVector (1, 0, 0);
    angles = [5, 10, 15, 20, 30, 20, 15, 10, 5 ]
ss
    bloc = doc.revolutionQuads  (liste, center, axis, angles);
    return doc


Macaroni

Retour au début

-
-




-  -
-  -
-  -
-  -
-  -

+ + + + + + + +Projet HEXABLOCK + +  + + + + + + + +
Simply Moira 
+
+
+HexaBlock
+
+Bibliothèque de formes

Documentation interne du moteur

+
+

+Ce document constitue la documentation interne du composant HEXABLOCK.
Ce +document fait partie des sources du projet et est géré en +configuration Pour le mettre à jour, utiliser kompozer, disponible sur +Linux
+
+
+
+

o Table of contents : +
+  +

+
+ + + + + + + + + + + + + + +
+
o   Partie 1 : Prévisualisation des éléments créés
+
+
o   Partie 2 : Nouvelles fonctions de construction
+
o   Partie 3 : Bibliothèques de formes
o   Partie 4 : Evolution des associations
+
+

o See also :

+ + + + + + + + + + + + +
+
o   Last news
+
o   Last last News : Voir les nouvelles formes
o   Précisions sur las associations par lignes
+
o   Frequently asked questions
+
o   Maintenance
+
+

+
+

+

o Partie 1 : prévisualisation des éléments créés

Pour +que SALOME puisse prévisualiser le "document" en cours de modivication, +il est nécessaire de créer une copie de l'original. L'évolution +majeure du moteur  consiste à implémenter une fonction de +copie. 

Ce qui revient à ajouter dans la classe Document la méthode suivante :

+ + + + + + +
Document* copyDocument (); +
+
La valeur rendue est le document copié.
Les éléments copiés sont les éléments +intrinsèques du document : vertices, edges, quadrangles, hexaèdres, +lois. Qui sont aussi ceux sauvegardés dans un texte XML. On ne stocke +pas les éléments intermédiaires de construction (grilles, vecteurs, +etc...).

Cette rège pourra être remise en cause si l'application interactive a besoin d'autres informations.

La copie se déroule ainsi :
Les associations sont copiées lors de la copie de chaque élément.


+Retour au début +
+

+

o + Partie 2 : Nouvelles fonctions de construction

o 2.1 Création d'Hexaèdres

+

Il s'agit de construire un hexaèdre à partir de quadrangles déjà créés dans le +modèle de blocs. Cet hexaèdre est produit à partir des 4 cas suivants :

+ +Les points d'entrée sont naturellement :

+ + + + + + + + +
Hexa* addHexa2Quads (Quad* q1, Quad* q2);
Hexa* addHexa3Quads (Quad* q1, Quad* q2, Quad* q3);
Hexa* addHexa4Quads (Quad* q1, Quad* q2, Quad* q3, Quad* q4);
Hexa* addHexa5Quads (Quad* q1, Quad* q2, Quad* q3, Quad* q4, Quad* q5);

Chacun des cas amène une discussion. La démarche est la suivante : 

Remarques :
o    Rappel  :  formalisation des Hexaèdres/Quadrangles/Vertex


Pour rappel :
+ + + + + +
          +//      z=0   z=1   +y=0   y=1   x=0  x=1
enum EnumHQuad   {Q_A,  Q_B,  Q_C,  Q_D,  Q_E, Q_F,  HQ_MAXI};

La face A est opposée à B, C est opposée à D, E à F. La +position des faces  A, C, E normales à Oz, Oy, Ox est purement +théorique. Elle améliore la visualisation. Les orientations sont en +fait  interchangeables. On peut intervertir les couples (C,D) et +(E,F), on peut intervertir A et B, C et D, E et F, l'essentiel est +d'avoir une cohérence  avec les autres dénominations d'edges (ac, +af, ad ...) ou de sommets (ace, acf, adf ...)  et les +conventions de départ.

L'arête située la face X et la face Y est notée xy. Un sommet situé entre les 3 faces X, Y Z est noté xyz :

+ + +

       6=bde  +----bd-----+ bdf=7
             +/|          /|
           be |   B    bf |
           /  |        /  |
    4=bce +----bc-----+...|...bcf=5
          |  de     D |   df
          +| E |       | F +|           +z
         ce   | +    cf  +|           +^
  2=ade...|...+----ad-|---+ adf=3     |   y
          +|  /        |  +/            +|  /
          | +ae    A   | +af            +| /
          +|/          +|/              +|/
    0=ace +----ac-----+ acf=1         +-----> x
  


o    La classe AnaQuads

Cette +classe analyse les relations topologiques existant entre plusieurs +quandrangles. Un objet de ce type est créé au début de chaque fonction +addHexaXQuads.

Le constructeur est :

+ + + + + + + + +
AnaQuads (Quad* q1, Quad* q2, Quad* q3=NULL, Quad* q4=NULL, Quad* q5=NULL);

Les champs affectés lors de la construction de l'objet :

MawQuads Constante égale à 5 5
int    nbr_quads;Nombre de quadrangles
int    nbr_aretes;Nombre total d'arêtes
Quad*  tab_quads  [i];Le ième quadrangle passé en argument
int    inter_nbre [i];Nombre d'intersections du ième quadrangle
int    inter_edge [i][j];Nro d'arête de i intersectant le jème quadrangle
int    inter_quad [i][j];Nro de quadrangle présent sur la jème arete du iéme quad

o    La classe Cramer

Cette +classe résout un système linéaire de n équations  à n inconnues. +Quand n est "petit", n<10. Peut être réutilisée sur un autre projet. +
Implémentation : HexCramer.hxx.
Test unitaire : test_cramer dans test_hexa1.cxx


+ + + + + + + + +
int test_cramer (int nbargs, cpchar tabargs[])
{
   double matrice [] = { 2, 7, 1,    0, 3, 0,    1, 9, 5 };
   double second_membre  [] = { 1, 1, 1 };
   Hex::Real3  solution;
   Hex::Cramer system(3);   // On dimensionne le système de Cramer à la construction

   int ier = system.resoudre (matrice, second_membre, solution);

   +cout << " Solution  = (" << solution[0] << ", " +<< solution[1] << ", " << solution[2]
        << "), ier = " << ier << endl;
  +                    +           // Pour vérifier :
   Hex::Real3 produit;
   system.multiply (solution, produit);
   +cout << " Produit = (" << produit[0] << ", " +<< produit[1] << ", " << produit[2]
        << ")"  << endl;
   return HOK;
}




o    Création d'un hexaèdre avec deux quadrangles :  

En diedre

Vis a vis
addHexa2Quads avec 2 quadrangles  non reliés.
Fonction : addHexaQuadsAB
addHexa2Quads avec 2 quadrangles   reliés.
Fonction : addHexaQuadsAC

addHexaQuadAB :

Les huits sommets sont présents, il manque quatre arêtes verticales ce, cf, df, de.
La +difficuté consiste à faire correspondre deux à deux les quatre sommets +de chaque quadrangle sans que les arêtes ne se croisent. La situation +est analogue à mergeQuads ou joinQuads, sauf que dans ces cas, on passe +en argument quatre vertex pour déterminer dans ambiguité les sommets +correspondants deux à deux. On a choisi ici +d'automatiser l'association :
Une fois la combinaison optimale établie :
Pour créer le i-ème quadrangle vertical :

addHexaQuadAC :

Deux +faces présentes A et C, une arête commune ac. Il manque deux sommets +bde et bdf à partir des quels on construit les arêtes manquantes bd, +be, de, bf, df. 
On doit s'assurer de ma planéité des quadrangles créés.

La +solution n'est pas unique. Il existe une infinité de sommets pouvant +définir un hexaèdre  conforme. On se contente ici d'en choisir une +et de démontrer que l'objet créé est conforme. 

Le point bde (resp bdf) est construit en +sommant les vecteurs ac et ce (resp af et cf), ce qui revient à +définir un parallélogramme. On assure ainsi sa présence dans le plan E +(resp. F). Les faces créées E et F sont donc planaires.

Pour démontrer la planéité de la face B :

+ + + + + +
  1. (ae , af)  coplanaires (donnée)
  2. be = ae (construction d'un parallèlogramme)
  3. df = af  (idem)
  4. (1), (2), (3) => (be, bf) coplanaires

On procéderait de la même manière pour établir que la face D est plane.

La fonction s'écrit ainsi :

o    Création d'un hexaèdre avec trois quadrangles :  


En diedre

Trièdre
addHexa2Quads avec 3 quadrangles disposés en U.
Fonction : addHexaQuadsACD
addHexa2Quads avec  quadrangles disposés  en trièdre
Fonction : addHexaQuadsACE


addHexaQuadACD :

Tous les sommets sont présents. Il reste à créer :

La difficulté est d'identifier clairement les arêtes et les sommets à partir des quadrangles existant : 

addHexaQuadACE :

Il +est nécessaire de créer le sommet v_bdf. Il est l'intersection des +plans (B, D, F). Chaque plan est défini par trois points présents sur +les autres quadrangles :

Soit un plan P défini par un point A et un vecteur normal N. Un point M appartient à P si le produit scalaire N.AM est nul

On obtient le système d'équations

+ + + + + +
  1. (bdf,bce) . norm_b = 0
  2. (bdf,ade) . norm_d = 0
  3. (bdf,acf) . norm_f = 0
Equivalent à : 
+ + + + + +
  1.    norme_b[0]*X + norme_b[1]*Y + norme_b[2]*Z = prod_scalaire (v_bce, norm_b)
  2.    norme_d[0]*X + norme_d[1]*Y + norme_d[2]*Z = prod_scalaire (v_ade, norm_d)
  3.    norme_f[0]*X + norme_f[1]*Y + norme_f[2]*Z = prod_scalaire (v_acf, norm_f)

Ce système de 3 équations à trois inconnues est résolu par la méthode de Cramer au moyen d'une classe du même nom défini dans le nouveau fichier HexCramer.hxx. Notons qu'un test unitaire de la classe Cramer existe dans le fichier test_quads.cxx

Une fois le système résolu ; s'il n'est pas régulier on retourne un vecteur nul, la suite est aisée :

o    Création d'un hexaèdre avec quatre quadrangles :  

En tunnel

En but
addHexa2Quads avec 4 quadrangles  disposés en tunnel.
Fonction : addHexaQuadsABCD
addHexa2Quads avec 4 quadrangles disposés en fauteuil.
Fonction : addHexaQuadsACDE

addHexaQuadABCD :

Le +rôle des quadrangles passés en arguments est symétrique On nommera q_a +le premier trouvé, q_c le premier qui intersecte q_a, q_c le second et +q_d celui qui n'intersecte pas q_a.

Tous les sommets et arêtes sont présents. Il suffit de créer les deux quadrangles E et F:

Les problèmes de détermination des variables se traiotent comme dans addHexaQuadABC

addHexaQuadACDE :

Le rôle de q_a et qc est symétrique. Ils ont chacun trois arêtes communes avec les autres. q_e et q_f n'en ont que 2.

Tous les sommets sont présents. Il suffit de créer l'arête e_bf et les deux quasrangles B et F:

Les edges se déterminent aisément grâce aux indices d'interection fournis par AnaQuads. Il suffiit de prendre l'opposé :et à la propriété de la classe Quad : l'indice d'une arête opposée à l'arête i vaut i+2.

+ + +
   int   nc_ac = strquads.inter_edge[pos_c][pos_a]; // Nro dans  q_c de e_ac
   int   nc_ce = strquads.inter_edge[pos_c][pos_e]; // Nro dans  q_c de e_ce
   int   nd_ad = strquads.inter_edge[pos_d][pos_a]; // Nro dans  q_d de e_ad
   int   nd_de = strquads.inter_edge[pos_d][pos_e]; // Nro dans  q_d de e_de
   int   ne_ae = strquads.inter_edge[pos_e][pos_a]; // Nro dans  q_e de e_ae

   Edge* e_af  = q_a->getEdge ((na_ac + 3) MODULO QUAD4);
   Edge* e_bc  = q_c->getEdge ((nc_ac + 2) MODULO QUAD4);
   Edge* e_cf  = q_c->getEdge ((nc_ce + 2) MODULO QUAD4);
   Edge* e_bd  = q_d->getEdge ((nd_ad + 2) MODULO QUAD4);
   Edge* e_df  = q_d->getEdge ((nd_de + 2) MODULO QUAD4);
   Edge* e_be  = q_e->getEdge ((ne_ae + 2) MODULO QUAD4);

   Vertex* v_bcf = e_cf->opposedVertex (e_cf->commonVertex (e_af));
   Vertex* v_bdf = e_df->opposedVertex (e_df->commonVertex (e_af));

o    Création d'un hexaèdre avec cinq quadrangles : 

Il n'y a pas besoin de dissocier plusieurs cas, le travail est réalisé directement dans la méthode addHexa5Quads().

En but

Ce cas est assez simple : c'est un hexaèdre auquel il manque la face que l'on convient de nommer B.

Retour au début

o 2.2 Génération d'Hexaèdres par révolution

Le pont d'entrée dans la classe Document est :
+ + +

+ + + + + +
Elements* revolutionQuads (Quads& start, Vertex* center, Vector* axis, vector<double>& angles);

Avec :



En diedre

Trièdre
Avant la revolution : on a coloré les quadrangles à déplacer, ainsi que l'axe de rotation.Résultat de  la revolution.

Retour au début

o 2.3 Substitution d'Hexaèdres

Il +s'agit de remplacer un hexaèdre ou des hexaèdres par une autre série +d'hexaaaèdres. Pour pouvoir effectuer ce remplacement, cette autre +série d'hexaèdres doit vérifier des conditions de collage de faces.
+ + +



En diedre

Trièdre
Exemple +: remplacement des 3 hexaèdres jaunes centraux par 3 fois 5 nouveaux +hexaèdres qui sont construits par extrusion des 5 quadrangles marrons +(le motif).Résultat du remplacement. 


La signature de la fonction est la suivante :
+ + + + + +
Elements* Document::revolutionQuads (Hexas& pattern, Vertex* p1, Vertex* c1,
  +                    +               Vertex* +p2, Vertex* c2, Vertex* p3, Vertex* c3);

Avec :

Conditions : 

Pour désigner les faces d'un hexaèdres, on utilise les  notations habituelles définies plus haut.

Conventions et orientations :


  (A suivre ...)


Retour au début +


+

+

oPartie 3 : Bibliothèque de formes

Cette biblothèque est constituée de quatre nouvelles formes :

Ces formes sont implémentées (et traduites ....) de la façon suivante :

+ + + + + +
Elements* makeSphere (Vertex* center, Vector* vx, Vector* vz,
                      double radius, 
double radhole,
                      Vertex* +plorig, 

                      int +nrad, int nang, int nhaut);
Elements* makePartSphere (Vertex* center, Vector* vx, Vector* vz,
                          double  radius,
double radhole,
                          Vertex* +plorig, double angle,
                          int +nrad, int nang, int nhaut);
Elements* makeRind (Vertex* center, Vector* vx, Vector* vz,
                    double  radius, double radint,
double radhole,
                    Vertex* +plorig, 
                    int +nrad, int nang, int nhaut);
Elements* makePartRind (Vertex* center, Vector* vx, Vector* vz,
                       
double  radius, double radint, double radhole,
                        Vertex* +plorig, double angle,
                        int +nrad, int nang, int nhaut);

Remarques :

o 3.1  Aspect visuel (exemples)


Conditions

Demi Sphere trouee

Huitième de sphère
Demi-Sphère trouée (makeSphere ())Huitième de sphère trouée (makePartSphere ())

Ecorce trouée    

Huitième d'ecorce       

Demi écorce trouée (makeRind ())Huitième d'écorce trouée (makePartRind ())

o 3.1  Implémentation

Toutes ces fonctions publiques appellent une seule fonction  de la classe Elements :

+ + + +
int makeRind (EnumGrid type, Vertex* center, Vector* vx, Vector* vz,
             
double  radius, double radint, double radhole,
              Vertex* +plorig, double angle,
               int +nrad, int nang, int nhaut);

Une fonction controlRind() vérifie +la cohérence des arguments passés en entrée et calcule les deux extrema +de l'angle d'élévation phi (voir chapitre suivant).
Une boucle à triple indice sur (nrad, nang, nhaut) calculme les coordonnées des sommets par appel de la fonction getCylPoint (nx,ny,nz, px,py,pz).
Ce +calcul se fait sur une sphère de centre O et d'axe Oz, dont les +hexaedres sont comptés à partir de l'axe Ox de façon à remplir le +secteur angulaire theta.. Les coordonnées sont ensuite replacées dans +les coordonnes utilisateur grâce à la fonction transfoVertices(). Edges, quadrangles et hexaèdres sont ensuites assemblés grâce à  la fonction fillGrid().

o 3.2 Détermination de l'angle d'élévation (phi)  

L'angle +d'azimuth theta (longitude) est défini explicitement par l'utilisateur. +L'angle d'élévation phi est délimité par la position du  plan +horizontal et par le diamètre du trou.  Soit :

Sphere

A partir de ces éléments de base, on  définit :
L'angle d'élévation  phi  est encadré par les valeurs suivantes :

Retour au début +


+

+

oPartie 4 : Evolution des associations

Cette tâche est composée de 3 évolutions, au sujet de +l'association, qui sont décrites ci-après.

o 4.1 Nouveaux objets  

+ +

Il s'agissait d'ajouter de nouveaux objets +intermédiaires de travail, comme le vecteur ou le cylindre :

+ +Il était p aussi associer  +les objets intermédiaires aux objets géométriques venant du +composant GEOM de SALOME :

o 4.2 Associations prédéfinies  

La deuxième évolution consiste à améliorer les associations +des modèles de blocs prédéfinis en calculant automatiquement des associations +implicites, les fonctions concernées sont les suivantes:

+ + + +

Pour chaque arête (sphérique) concernée, on associera un arc de cercle.

Il est inutile d'associer laes faces, SMESH est capable de mailler si les arêtes sont associées.

Implémentation 

Rappelons que l'objet Shape de HexaBlock est constitué :

Deux opérations sont nécessaires  :

  1.  créer un cercle au moyen de GEOM,
  2. découper ce cercle en arcs de cercle qui seront associés aux arêtes concernées.

Opération 1 : +Le cercle à créer est en fait un arc de cercle orienté de 360 +degrés.  Il est en effet nécessaire de définir une origine. GEOM +permet de générer finir un tel +cercle, à partir duquel HexaBlock définira des arcs au moyen des +paramètres debut et fin des shapes :

Cette action est assurée par la fonction geom_create_circle +qui génère la brep du cercle à partir de son centre, de son rayon, +de son vecteur normal, du  vecteur Ox qui permet de définir son +origine.


+ + + +
void geom_create_circle (double* centre, double rayon, Vector* normale,
                         +double* ox, string& brep)
{
   gp_Pnt gp_center (centre [dir_x], centre [dir_y], centre [dir_z]);
   +gp_Vec gp_ox     (ox     +[dir_x], ox     [dir_y], ox     +[dir_z]);
   gp_Vec gp_norm   (normale->getDx(), normale->getDy(), normale->getDz());

   gp_Ax2  gp_axes (gp_center, gp_norm, gp_ox);
   gp_Circ gp_circ (gp_axes,   rayon);

   TopoDS_Edge    geom_circ = BRepBuilderAPI_MakeEdge(gp_circ).Edge();
   ostringstream  stream_shape;
   BRepTools::Write(geom_circ, stream_shape);

   brep = stream_shape.str();
}

GEOM permet de définir un tel cercle (calsse gp_Circ)  à partir d'un systemes d'axes 2D (classe gp_Ax2 )  et d'un rayon. Ce cercle esr ensuite transformé en forme TopoDS_Shape qui est l'objet GEOM que l'on maniplule habituellement losque l'on procède aux associations. Plus précisément en TopoDS_Edge  au moyen de BRepBuilderAPI_MakeEdge. Enfin l'objet est  transformé en chaine de caractères de format Brep via ostringstream.

Opération 2 : +On dispose d'une b-rep  décrivant un arc de cercle de 360 degrés. +Il est aisé de définir proportionnellement pour chacun des edges +constituant la ligne associée à la portion de cercle les paramètres +début et fin par rapport aux angles de départ et d'arrivée de chaque +arc. Cette opération fut d'ailleurs réalisée lors de la préservarion +des associations lors d'un "cut". On réutilisera donc la fonction Elements::cutAssociation(...) moyennant quelques aménagements.

o 4.3 Propagation des associations  


La troisième évolution consiste à améliorer la propagation +automatique des associations, les fonctions concernées sont les suivantes:

+ + + +

+ +

Ces trois évolutions seront implémentées dans le moteur. +Seule le première évolution (création de sphères ou cercles) sera implémentée +dans la partie interactive.



o    Implémentation :


En +ce qui concerne les associations propagées par les transformations, la +fonction de base de l'implémentation est transfo_brep.
Cette fonction reprend la matrice du modèle de blocs et l'applique à la shape décrite par la brep.

// ====================================================== transfo_brep
void transfo_brep (string& brep, Matrix* matrice, string& trep)
{
   BRep_Builder  builder;
   TopoDS_Shape  shape_orig;
   ostringstream stream_shape;
   gp_Trsf       transfo;

   +double             +a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34;
   matrice->getCoeff (a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34);
   transfo.SetValues (a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34,
                      +Epsil2, Epsil2);

   istringstream stream_brep (brep);
   BRepTools::Read           (shape_orig, stream_brep, builder);
  
   BRepBuilderAPI_Transform brep_transfo (shape_orig, transfo, Standard_True);
   TopoDS_Shape result = brep_transfo.Shape();

   BRepTools::Write (result, stream_shape);
   trep = stream_shape.str();
}


Pour la fonction de prismQuads, on utilise une variante simplifiée :

// ====================================================== translate_brep
void translate_brep (string& brep, double dir[], string& trep)
{
   gp_Trsf       transfo;
   BRep_Builder  builder;
   TopoDS_Shape  orig;
   ostringstream stream_shape;

   +gp_Vec      +vecteur       (dir [dir_x], dir [dir_y], +dir [dir_z]);
   transfo.SetTranslation    (vecteur);
   istringstream stream_brep (brep);
   BRepTools::Read           (orig, stream_brep, builder);
  
   TopLoc_Location  loc_orig   = orig.Location();
   gp_Trsf          trans_orig = loc_orig.Transformation();
   TopLoc_Location  loc_result (transfo * trans_orig);
   TopoDS_Shape     result = orig.Located (loc_result);

   BRepTools::Write (result, stream_shape);
   trep = stream_shape.str();
}


Pour la fonction de prismQuads, on utilise une variante simplifiée :



o    Propagation des associations pour les transformations :


L'exemple donné est makeScale

# ======================================================= make_grid
def make_grid (doc) :
    ori  = doc.addVertex ( 0, 0, 0)
    vz   = doc.addVector ( 0, 0, 1)
    vx   = doc.addVector ( 1 ,0, 0)

    dr = 1
    da = 360
    dl = 1
    nr = 1
    na = 6
    nl = 1
    grid = doc.makeCylindrical (ori, vx,vz, dr,da,dl, nr,na,nl, False)
    return grid

# ======================================================= test_scale
def test_scale () :

    doc  = hexablock.addDocument()
    grid = make_grid (doc)

    dest   = doc.addVertex (15, 0, 0)
    grid2  = doc.makeScale (grid, dest, 0.5)
    return doc


transfo

ss


o    Propagation des associations pour la fonction prismQuads

Pour la fonction prismQuads :



# ========================================================== test_prism
def test_prism () :
    doc  = hexablock.addDocument()
    nr = 1
    na = 6
    nl = 1
    grid = make_grid (doc, nr, na, nl)

    liste = [ ]
    for nx in range (nr) :
        for ny in range (na) :
            cell = grid.getQuadIJ (nx, ny, nl)
            liste.append (cell);

    axis = doc.addVector (1, 1, 1);
    bloc = doc.prismQuads  (liste, axis, 3)
    return doc


+ + + +





Prisme






o    Propagation des associations pour la fonction revolutionQuads


Pour la fonction revolutionQuads



# ========================================================== test_revolution
def test_revolution () :
    doc  = hexablock.addDocument()
    nr = 1
    na = 6
    nl = 1
    grid = make_grid (doc, nr, na, nl)

    liste = [ ]
    for nx in range (nr) :
        for ny in range (na) :
            cell = grid.getQuadIJ (nx, ny, nl)
            print " ... cell = ", cell
            liste.append (cell);
ss

    center = doc.addVertex (0, -10, 0);
    axis   = doc.addVector (1, 0, 0);
    angles = [5, 10, 15, 20, 30, 20, 15, 10, 5 ]
ss
    bloc = doc.revolutionQuads  (liste, center, axis, angles);
    return doc




Macaroni





Retour au début

+
+




+  +
+  +
+  +
+  +
+  +

\ No newline at end of file diff --git a/src/HEXABLOCK/HexCylinder.cxx b/src/HEXABLOCK/HexCylinder.cxx index 9851c12..95c9e11 100644 --- a/src/HEXABLOCK/HexCylinder.cxx +++ b/src/HEXABLOCK/HexCylinder.cxx @@ -32,7 +32,7 @@ bool is_out (double val, double orig, double lg); // ======================================================== Constructeur Cylinder::Cylinder(Vertex* b, Vector* v, double r, double h) - : EltBase (b->dad()) + : EltBase (b->dad(), EL_CYLINDER) { c_base = b; c_dir = v; @@ -48,6 +48,17 @@ Cylinder::Cylinder(Vertex* b, Vector* v, double r, double h) HexDump (c_dir); cout << endl; } + + if (c_base==NULL || c_dir==NULL || el_root==NULL) + setError (); + else + { + double tol = el_root->getTolerance (); + double norme = c_dir ->getNorm (); + if (c_radius <= tol || c_height <= tol || norme <= tol) + setError (); + } + } // ======================================================== rdiffers bool rdiffers (double v1, double v2) diff --git a/src/HEXABLOCK/HexDocument_Xml.cxx b/src/HEXABLOCK/HexDocument_Xml.cxx index 30442c8..66700f7 100755 --- a/src/HEXABLOCK/HexDocument_Xml.cxx +++ b/src/HEXABLOCK/HexDocument_Xml.cxx @@ -64,8 +64,15 @@ int get_coords (const string& chaine, double& x, double& y) return HOK; } // ======================================================== parseName -int parseName (XmlTree* node, EltBase* elt) +int parseName (XmlTree* node, const string& nom, EltBase* elt) { + int lg = nom.size(); + int nroid = 0; + for (int nc=1 ; ncsetId (nroid); + const string& name = node->findValue ("name"); if (name=="") return HERR; @@ -185,7 +192,7 @@ int Document::parseXml (XmlTree& xml) get_coords (coords, px, py, pz); Vertex* vertex = addVertex (px, py, pz); - parseName (node, vertex); + parseName (node, nom, vertex); Shape* shape = NULL; if (brep != "" ) { @@ -210,7 +217,7 @@ int Document::parseXml (XmlTree& xml) get_names (vertices, V_TWO, tname); edge = new Edge (t_vertex [tname[0]], t_vertex [tname[1]]); t_edge [nom] = edge; - parseName (node, edge); + parseName (node, nom, edge); } else if (type=="Shape" && edge!=NULL) { @@ -236,7 +243,7 @@ int Document::parseXml (XmlTree& xml) quad = new Quad (t_edge [tname[0]], t_edge [tname[1]], t_edge [tname[2]], t_edge [tname[3]]); t_quad [nom] = quad; - parseName (node, quad); + parseName (node, nom, quad); } else if (type=="Shape" && quad!=NULL) { @@ -259,7 +266,7 @@ int Document::parseXml (XmlTree& xml) t_quad [tname[2]], t_quad [tname[3]], t_quad [tname[4]], t_quad [tname[5]]); t_hexa [nom] = hexa; - parseName (node, hexa); + parseName (node, nom, hexa); } rubrique = xml.findChild ("ListVectors"); @@ -275,7 +282,7 @@ int Document::parseXml (XmlTree& xml) Vector* vector = addVector (px, py, pz); t_vector [nom] = vector; - parseName (node, vector); + parseName (node, nom, vector); } rubrique = xml.findChild ("ListDicretizationLaws"); diff --git a/src/HEXABLOCK/HexEdge.cxx b/src/HEXABLOCK/HexEdge.cxx index 896b0b2..7579acf 100755 --- a/src/HEXABLOCK/HexEdge.cxx +++ b/src/HEXABLOCK/HexEdge.cxx @@ -45,6 +45,19 @@ Edge::Edge (Vertex* va, Vertex* vb) e_law = NULL; e_clone = NULL; + if (isBad()) + return; + else if (BadElement (va) || BadElement (vb)) + { + setError (); + return; + } + else if (va == vb) + { + setError (); + return; + } + majReferences (); } // ======================================================== Constructeur 2 @@ -52,6 +65,8 @@ Edge::Edge (Edge* other) : EltBase (other->dad(), EL_EDGE) { e_vertex [V_AMONT] = e_vertex [V_AVAL ] = NULL; + if (BadElement (other)) + setError (); e_propag = NOTHING; e_way = true; diff --git a/src/HEXABLOCK/HexEdge.hxx b/src/HEXABLOCK/HexEdge.hxx index 5fdfe91..56ee018 100755 --- a/src/HEXABLOCK/HexEdge.hxx +++ b/src/HEXABLOCK/HexEdge.hxx @@ -38,7 +38,8 @@ public: virtual void replaceVertex (Vertex* old, Vertex* nouveau); virtual void clearAssociation () { tab_assoc.clear() ; } virtual void setAssociation (Shape* forme); - int addAssociation (Shape* forme); + virtual bool isAssociated () { return tab_assoc.size() > 0 ; } + virtual int addAssociation (Shape* forme); Edge (Vertex* va, Vertex* vb); Edge (Edge* other); diff --git a/src/HEXABLOCK/HexElements.cxx b/src/HEXABLOCK/HexElements.cxx index 9f8a682..730771f 100755 --- a/src/HEXABLOCK/HexElements.cxx +++ b/src/HEXABLOCK/HexElements.cxx @@ -194,6 +194,15 @@ void Elements::resize (EnumGrid type, int nx, int ny, int nz, int nplus) int Elements::makeCartesianGrid (Vertex* orig, Vector* v1, Vector* v2, Vector* v3, int px, int py, int pz, int mx, int my, int mz) { + if (BadElement (orig) || BadElement(v1) || BadElement(v2) || BadElement(v3) + || px<=0 || py<=0 || pz <= 0 + || v1->getNorm () <= Epsil || v2->getNorm () <= Epsil + || v3->getNorm () <= Epsil) + { + setError (); + return HERR; + } + resize (GR_CARTESIAN, px+mx, py+my, pz+mz); makeCartesianNodes (orig, v1, v2, v3, px, py, pz, mx, my, mz); @@ -205,6 +214,13 @@ int Elements::makeCartesianGrid (Vertex* orig, Vector* v1, Vector* v2, int Elements::makeCylindricalGrid (Vertex* c, Vector* b, Vector* h, double dr, double da, double dl, int nr, int na, int nl, bool fill) { + if (BadElement (c) || BadElement(b) || BadElement(h) + || nr<=0 || na<=0 || nl <= 0 || dr < Epsil || da < Epsil || dl < Epsil + || b->getNorm () <= Epsil || h->getNorm () <= Epsil) + { + setError (); + return HERR; + } resize (GR_CYLINDRIC, nr, na, nl); cyl_closed = da >= 360.0; makeCylindricalNodes (c, b, h, dr, da, dl, nr, na, nl, fill); @@ -215,12 +231,15 @@ int Elements::makeCylindricalGrid (Vertex* c, Vector* b, Vector* h, // ====================================================== makeSphericalGrid int Elements::makeSphericalGrid (Vertex* c, Vector* dv, int nb, double k) { - resize (GR_SPHERIC, nb); - - if (nb<0) - return HERR; - else if (dv->getDx()<=ZEROR || dv->getDy()<=ZEROR || dv->getDz()<=ZEROR) + if (BadElement (c) || BadElement(dv) + || nb<=0 || k < Epsil + || dv->getDx()<=Epsil || dv->getDy()<=Epsil || dv->getDz()<=Epsil) + { + setError (); return HERR; + } + + resize (GR_SPHERIC, nb); Vertex* i_node [HV_MAXI]; // Les noeuds de l'hexa englobant Edge* i_edge [HE_MAXI]; // Les noeuds de l'hexa englobant @@ -436,6 +455,7 @@ int Elements::joinQuads (Quads& orig, int nb, Vertex* v1, Vertex* v2, printf ("\n"); printf (" *** joinQuads : donnees incorrectes\n"); printf (" *** le %deme quadrangle de depart est NULL\n", nro); + setError (); return HERR; } else if (face->getNbrParents()>1) @@ -444,7 +464,8 @@ int Elements::joinQuads (Quads& orig, int nb, Vertex* v1, Vertex* v2, printf (" *** joinQuads : donnees incorrectes\n"); printf (" *** le %deme quadrangle de depart n'est pas une " "face externe\n", nro); - face->dump (); + face->dump (); + setError (); return HERR; } orig [nro]->setMark (nro); @@ -479,12 +500,18 @@ int Elements::joinQuads (Quads& orig, int nb, Vertex* v1, Vertex* v2, } if (e_orig==NULL || e_dest==NULL) + { + setError (); return HERR; + } StrOrient orient (v1, v3, v2, v4); int ier = this ->coupler (0, cible, &orient); if (ier!=HOK) - return HERR; + { + setError (); + return HERR; + } ier = orig[0]->coupler (cible, &orient, this); return ier; } diff --git a/src/HEXABLOCK/HexElements_bis.cxx b/src/HEXABLOCK/HexElements_bis.cxx index 0bfc615..77658c3 100755 --- a/src/HEXABLOCK/HexElements_bis.cxx +++ b/src/HEXABLOCK/HexElements_bis.cxx @@ -43,6 +43,8 @@ void geom_create_circle (double* milieu, double rayon, double* normale, // ====================================================== getHexaIJK Hexa* Elements::getHexaIJK (int nx, int ny, int nz) { + if (isBad()) + return NULL; if (nx<0 || nx>=size_hx || ny<0 || ny>=size_hy || nz<0 || nz>=size_hz) return NULL; else if (grid_nocart) @@ -55,6 +57,8 @@ Hexa* Elements::getHexaIJK (int nx, int ny, int nz) // ====================================================== getQuadIJ Quad* Elements::getQuadIJ (int nx, int ny, int nz) { + if (isBad()) + return NULL; if (nx<0 || nx>=size_qx || ny<0 || ny>=size_qy || nz<0 || nz>=size_qz) return NULL; else if (grid_nocart) @@ -67,6 +71,8 @@ Quad* Elements::getQuadIJ (int nx, int ny, int nz) // ====================================================== getQuadJK Quad* Elements::getQuadJK (int nx, int ny, int nz) { + if (isBad()) + return NULL; if (nx<0 || nx>=size_qx || ny<0 || ny>=size_qy || nz<0 || nz>=size_qz) return NULL; else if (grid_nocart) @@ -79,6 +85,8 @@ Quad* Elements::getQuadJK (int nx, int ny, int nz) // ====================================================== getQuadIK Quad* Elements::getQuadIK (int nx, int ny, int nz) { + if (isBad()) + return NULL; if (nx<0 || nx>=size_qx || ny<0 || ny>=size_qy || nz<0 || nz>=size_qz) return NULL; else if (grid_nocart) @@ -91,6 +99,8 @@ Quad* Elements::getQuadIK (int nx, int ny, int nz) // ====================================================== getEdgeI Edge* Elements::getEdgeI (int nx, int ny, int nz) { + if (isBad()) + return NULL; if (nx<0 || nx>=size_ex || ny<0 || ny>=size_ey || nz<0 || nz>=size_ez) return NULL; else if (grid_nocart) @@ -103,6 +113,8 @@ Edge* Elements::getEdgeI (int nx, int ny, int nz) // ====================================================== getEdgeJ Edge* Elements::getEdgeJ (int nx, int ny, int nz) { + if (isBad()) + return NULL; if (nx<0 || nx>=size_ex || ny<0 || ny>=size_ey || nz<0 || nz>=size_ez) return NULL; else if (grid_nocart) @@ -115,6 +127,8 @@ Edge* Elements::getEdgeJ (int nx, int ny, int nz) // ====================================================== getEdgeK Edge* Elements::getEdgeK (int nx, int ny, int nz) { + if (isBad()) + return NULL; if (nx<0 || nx>=size_ex || ny<0 || ny>=size_ey || nz<0 || nz>=size_ez) return NULL; else if (grid_nocart) @@ -127,6 +141,8 @@ Edge* Elements::getEdgeK (int nx, int ny, int nz) // ====================================================== getVertexIJK Vertex* Elements::getVertexIJK (int nx, int ny, int nz) { + if (isBad()) + return NULL; if (nx<0 || nx>=size_vx || ny<0 || ny>=size_vy || nz<0 || nz>=size_vz) return NULL; else if (grid_nocart) @@ -196,6 +212,13 @@ void Elements::remove () // ====================================================== makeCylinder int Elements::makeCylinder (Cylinder* cyl, Vector* vx, int nr, int na, int nl) { + if (BadElement (cyl) || BadElement (vx) || nr<=0 || na <=3 || nl <=0 + || vx->getNorm () <= Epsil) + { + setError (); + return HERR; + } + Vertex* orig = cyl->getBase (); Vector* dir = cyl->getDirection (); double ray = cyl->getRadius (); @@ -212,6 +235,13 @@ int Elements::makeCylinder (Cylinder* cyl, Vector* vx, int nr, int na, int nl) // ====================================================== makePipe int Elements::makePipe (Cylinder* cyl, Vector* vx, int nr, int na, int nl) { + if (BadElement (cyl) || BadElement (vx) || nr<=0 || na <=3 || nl <=0 + || vx->getNorm () <= Epsil) + { + setError (); + return HERR; + } + Vertex* orig = cyl->getBase (); Vector* dir = cyl->getDirection (); double ray = cyl->getRadius (); @@ -230,6 +260,12 @@ int Elements::makePipe (Cylinder* cyl, Vector* vx, int nr, int na, int nl) // ====================================================== prismQuads int Elements::prismQuads (Quads& tstart, Vector* dir, int nbiter) { + if (BadElement (dir) || dir->getNorm () <= Epsil || nbiter <= 0) + { + setError (); + return HERR; + } + el_root->markAll (NO_USED); int nbcells = tstart.size (); nbr_vertex = 0; @@ -261,8 +297,11 @@ int Elements::prismQuadsVec (Quads& tstart, Vector* dir, RealVector& tlen, int mode) { int nbiter = tlen.size(); - if (nbiter==0) + if (BadElement (dir) || dir->getNorm () <= Epsil || nbiter <= 0) + { + setError (); return HERR; + } el_root->markAll (NO_USED); int nbcells = tstart.size (); @@ -296,12 +335,16 @@ int Elements::prismQuadsVec (Quads& tstart, Vector* dir, RealVector& tlen, int Elements::revolutionQuads (Quads& start, Vertex* center, Vector* axis, RealVector &angles) { - int nbiter = angles.size(); - if (center==NULL || axis==NULL || nbiter==0) + int nbiter = angles.size(); + int nbcells = start.size (); + if (BadElement (center) || BadElement(axis) || nbiter==0 || nbcells==0 + || axis->getNorm () <= Epsil) + { + setError (); return HERR; + } el_root->markAll (NO_USED); - int nbcells = start.size (); nbr_vertex = 0; nbr_edges = 0; diff --git a/src/HEXABLOCK/HexElements_grid.cxx b/src/HEXABLOCK/HexElements_grid.cxx index 389b171..5743c34 100755 --- a/src/HEXABLOCK/HexElements_grid.cxx +++ b/src/HEXABLOCK/HexElements_grid.cxx @@ -496,6 +496,14 @@ int Elements::makeCylindricalGrid (Vertex* orig, Vector* base, Vector* haut, RealVector& tdr, RealVector& tda, RealVector& tdh, bool fill) { + if (BadElement (orig) || BadElement(base) || BadElement(haut) + || base->getNorm () <= Epsil || haut->getNorm () <= Epsil + || tdr.size () <= 0 || tda.size () <= 0 || tdh.size () <= 0) + { + setError (); + return HERR; + } + int nr = tdr.size() - 1; int na = tda.size(); int nl = tdh.size(); @@ -505,7 +513,7 @@ int Elements::makeCylindricalGrid (Vertex* orig, Vector* base, Vector* haut, angle += tda[nro]; resize (GR_CYLINDRIC, nr, na, nl); - cyl_closed = angle >= 360.0; + cyl_closed = angle >= 359.9; int ier = makeBasicCylinder (tdr, tda, tdh, fill); if (ier!=HOK) diff --git a/src/HEXABLOCK/HexElements_piq.cxx b/src/HEXABLOCK/HexElements_piq.cxx index 46bf4a9..603d6c3 100755 --- a/src/HEXABLOCK/HexElements_piq.cxx +++ b/src/HEXABLOCK/HexElements_piq.cxx @@ -442,7 +442,7 @@ int Elements::replaceHexas (Quads& liste, Vertex* p1, Vertex* c1, replaceHexa (nh, &pattern, pil_hexa[nh-1]); } - for (int nh=1 ; nh<=nbh ; nh++) + for (int nh=0 ; nh<=nbh ; nh++) pil_quad[nh]->remove (); extrudeQuad (&pattern); diff --git a/src/HEXABLOCK/HexElements_ter.cxx b/src/HEXABLOCK/HexElements_ter.cxx index a56e79e..cf1a35e 100755 --- a/src/HEXABLOCK/HexElements_ter.cxx +++ b/src/HEXABLOCK/HexElements_ter.cxx @@ -386,12 +386,13 @@ void Elements::assoSphere (Vertex* ori, Edge* t_edge[], Quad* t_quad[]) // ====================================================== makeSphericalGrid int Elements::makeSphericalGrid (Vertex* c, double rayon, int nb, double k) { - resize (GR_SPHERIC, nb); - - if (nb<0) - return HERR; - else if (rayon <=ZEROR) + if (nb<=0 || rayon <=Epsil || k <= Epsil || BadElement (c)) + { + setError (); return HERR; + } + + resize (GR_SPHERIC, nb); Vertex* i_node [HV_MAXI]; // Les noeuds de l'hexa englobant Edge* i_edge [HE_MAXI]; // Les noeuds de l'hexa englobant diff --git a/src/HEXABLOCK/HexEltBase.cxx b/src/HEXABLOCK/HexEltBase.cxx index d77aa8b..8f2acd4 100755 --- a/src/HEXABLOCK/HexEltBase.cxx +++ b/src/HEXABLOCK/HexEltBase.cxx @@ -29,22 +29,30 @@ EltBase::EltBase (Document* doc, EnumElt type) { el_root = doc; el_type = type; - el_id = el_root->doc_nbr_elt [type]; + el_id = 0; el_next = NULL; el_assoc = NULL; el_status = HOK; el_mark = 0; - el_root->doc_nbr_elt [type] ++; - el_root->doc_last_elt [type] -> el_next = this; - el_root->doc_last_elt [type] = this; + // EL_NONE, EL_VERTEX, EL_EDGE, EL_QUAD, EL_HEXA, EL_REMOVED + + if (el_root==NULL) + { + el_name = "NoValid"; + setError (); + return; + } + + el_id = el_root->doc_nbr_elt [el_type]; + el_root->doc_nbr_elt [el_type] ++; + el_root->doc_last_elt [el_type] -> el_next = this; + el_root->doc_last_elt [el_type] = this; el_root->setDeprecated (1); - // EL_NONE, EL_VERTEX, EL_EDGE, EL_QUAD, EL_HEXA, EL_REMOVED char buffer [16]; - sprintf (buffer, "%c%04d", ABR_TYPES[el_type], el_id); - el_name = buffer; + el_name = getName (buffer); } // =================================================== Destructeur EltBase::~EltBase () @@ -139,6 +147,12 @@ void EltBase::setAssociation (Shape* forme) if (el_root->debug (2)) cout << " Vertex " << el_name << " : setAssociation" << endl; } +// ========================================================= addAssociation +int EltBase::addAssociation (Shape* forme) +{ + setAssociation (forme); + return HOK; +} // ========================================================= dumpRef void EltBase::dumpRef () { @@ -163,6 +177,26 @@ void EltBase::dumpRef () printf ("\n"); } +// ========================================================= addAssociation +bool EltBase::canBeAssociated () +{ + bool rep = isValid() && isHere() + && (el_type==EL_VERTEX || el_type==EL_EDGE || el_type==EL_QUAD); + return rep; +} +// ========================================================= addAssociation +void EltBase::setId (int ln) +{ + char buffer [16]; + bool defname = el_name == getName (buffer); + + el_id = ln; + int maxid = std::max (el_root->doc_nbr_elt[el_type], ln+1); + + el_root->doc_nbr_elt[el_type] = maxid; + if (defname) + el_name = getName (buffer); +} END_NAMESPACE_HEXA diff --git a/src/HEXABLOCK/HexEltBase.hxx b/src/HEXABLOCK/HexEltBase.hxx index a95a290..dadda0c 100755 --- a/src/HEXABLOCK/HexEltBase.hxx +++ b/src/HEXABLOCK/HexEltBase.hxx @@ -33,7 +33,7 @@ #define GetClone(elt) ((elt)==NULL ? NULL : elt->getClone()) #define BadElement(elt) (elt)==NULL || (elt)->isBad() -#define ABR_TYPES "xveqhw????" +#define ABR_TYPES "xveqhwgcp????" BEGIN_NAMESPACE_HEXA @@ -56,12 +56,15 @@ public : virtual bool isBad () { return el_status!=HOK; } virtual void setAssociation (Shape* forme); + virtual int addAssociation (Shape* forme); virtual void clearAssociation () { el_assoc = NULL ; } virtual void duplicate () {} virtual Shape* getAssociation () { return el_assoc ; } + virtual bool isAssociated () { return el_assoc != NULL ; } void copyAssociation (EltBase* orig); void replaceAssociation (EltBase* orig); + bool canBeAssociated (); public : virtual void replaceEdge (Edge* old, Edge* nouveau) @@ -82,7 +85,7 @@ public : EltBase* next () { return el_next; } void setNext (EltBase* suivant) { el_next = suivant; } int getId () { return el_id; } - void setId (int ln) { el_id = ln; } + void setId (int ln); Document* dad () { return el_root; } EnumElt getType () { return el_type; } bool isHere () { return el_type!=EL_REMOVED; } diff --git a/src/HEXABLOCK/HexHexa.cxx b/src/HEXABLOCK/HexHexa.cxx index 5ababf1..66d7242 100755 --- a/src/HEXABLOCK/HexHexa.cxx +++ b/src/HEXABLOCK/HexHexa.cxx @@ -170,11 +170,11 @@ void Hexa::controlerFaces () { for (int n1=0 ; n1putError (W_H_NULL_QUAD, el_root->glob->namofHexaQuad (n1)); - el_status = 886; + setError (886); return; } for (int n2=n1+1 ; n2putError (W_H_EQ_QUAD, el_root->glob->namofHexaQuad (n1), el_root->glob->namofHexaQuad (n2)); - el_status = 888; + setError (888); } } } @@ -192,11 +192,11 @@ void Hexa::controlerSommets () { for (int n1=0 ; n1putError (W_H_NULL_QUAD, el_root->glob->namofHexaVertex (n1)); - el_status = 886; + setError (886); return; } for (int n2=n1+1 ; n2putError (W_H_EQ_QUAD, el_root->glob->namofHexaVertex (n1), el_root->glob->namofHexaVertex (n2)); - el_status = 888; + setError (888); } } } diff --git a/src/HEXABLOCK/HexPipe.cxx b/src/HEXABLOCK/HexPipe.cxx index f6e99a6..dbe0755 100755 --- a/src/HEXABLOCK/HexPipe.cxx +++ b/src/HEXABLOCK/HexPipe.cxx @@ -31,6 +31,9 @@ Pipe::Pipe (Vertex* b, Vector* v, double ri, double re, double h) : Cylinder (b, v, re, h) { c_int_radius = ri; + if (isBad () || c_int_radius <= el_root->getTolerance () + || c_int_radius >= c_radius) + setError (); } // ========================================================= saveXml void Pipe::saveXml (XmlWriter* xml) diff --git a/src/HEXABLOCK/HexQuad.cxx b/src/HEXABLOCK/HexQuad.cxx index 987f039..a075aa0 100755 --- a/src/HEXABLOCK/HexQuad.cxx +++ b/src/HEXABLOCK/HexQuad.cxx @@ -45,6 +45,13 @@ Quad::Quad (Vertex* va, Vertex* vb, Vertex* vc, Vertex* vd) { q_edge [nro] = new Edge (q_vertex[nro], q_vertex[(nro+1) MODULO QUAD4]); + + if (BadElement (q_vertex [nro]) || BadElement (q_edge [nro])) + setError (); + else + for (int nv=nro+1 ; nv inter (q_edge[prec]); - if (nc>=0) - node = q_edge[nro]->getVertex (nc); - else - el_status = 888; + + if (BadElement (q_edge[nro])) + setError (); + else + { + for (int nv=nro+1 ; nv inter (q_edge[prec]); + if (nc>=0) + node = q_edge[nro]->getVertex (nc); + else + setError (888); + } q_vertex [prec] = node; } - if (el_status != HOK) + if (isBad()) { printf (" +++++++++++++++++++++++++++++++++++++++++++ \n"); printf (" +++ Quadrangle impossible \n"); @@ -557,4 +573,11 @@ int Quad::setOrientation () printf (" %s = %s\n", el_name.c_str(), t_ori [ q_orientation ]); return q_orientation; } +// ========================================================== setAssociation +void Quad::setAssociation (Shape* forme) +{ + clearAssociation (); + addAssociation (forme); +} END_NAMESPACE_HEXA + diff --git a/src/HEXABLOCK/HexQuad.hxx b/src/HEXABLOCK/HexQuad.hxx index 19ee24d..812c034 100755 --- a/src/HEXABLOCK/HexQuad.hxx +++ b/src/HEXABLOCK/HexQuad.hxx @@ -89,10 +89,14 @@ public: virtual void replaceEdge (Edge* old, Edge* nouveau); virtual void replaceVertex (Vertex* old, Vertex* nouveau); + virtual void setAssociation (Shape* forme); + virtual int addAssociation (Shape* forme); virtual void clearAssociation () { tab_assoc.clear() ; } - int addAssociation (Shape* forme); + virtual bool isAssociated () { return tab_assoc.size() > 0 ; } + const Shapes& getAssociations () { return tab_assoc ; } + virtual void duplicate (); Quad* getClone () { return q_clone ; } diff --git a/src/HEXABLOCK/hexa_base.hxx b/src/HEXABLOCK/hexa_base.hxx index 1fe11fd..20e0cd0 100755 --- a/src/HEXABLOCK/hexa_base.hxx +++ b/src/HEXABLOCK/hexa_base.hxx @@ -114,7 +114,7 @@ BEGIN_NAMESPACE_HEXA enum EnumCoord { dir_x, dir_y, dir_z, DIM3 }; enum EnumElt { EL_NONE, EL_VERTEX, EL_EDGE, EL_QUAD, EL_HEXA, EL_VECTOR, - EL_REMOVED, EL_MAXI }; + EL_GRID, EL_CYLINDER, EL_PIPE, EL_REMOVED, EL_MAXI }; enum EnumGroup { HexaCell, QuadCell, EdgeCell, HexaNode, QuadNode, EdgeNode, VertexNode}; diff --git a/src/HEXABLOCKGUI/CutEdge_QTD.ui b/src/HEXABLOCKGUI/CutEdge_QTD.ui index 8511831..dc68957 100644 --- a/src/HEXABLOCKGUI/CutEdge_QTD.ui +++ b/src/HEXABLOCKGUI/CutEdge_QTD.ui @@ -22,11 +22,43 @@ + + + 0 + 0 + + Arguments - + + + + Edge + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + false + + + + @@ -39,10 +71,10 @@ - + - + 0 0 @@ -55,31 +87,15 @@ - - - - - 127 - 16777215 - - - - false - - - - - - - Edge - - - + + e_le + nb_cut_spb + diff --git a/src/HEXABLOCKGUI/Cylinder_QTD.ui b/src/HEXABLOCKGUI/Cylinder_QTD.ui index 70562e2..1083be8 100644 --- a/src/HEXABLOCKGUI/Cylinder_QTD.ui +++ b/src/HEXABLOCKGUI/Cylinder_QTD.ui @@ -6,7 +6,7 @@ 0 0 - 247 + 221 208 @@ -18,7 +18,7 @@ - 5 + 0 0 @@ -55,14 +55,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -78,14 +78,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -96,9 +96,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -152,6 +158,13 @@ + + name_le + vex_le + vec_le + r_spb + h_spb + diff --git a/src/HEXABLOCKGUI/Disconnect_QTD.ui b/src/HEXABLOCKGUI/Disconnect_QTD.ui index d5dd26d..0711c29 100644 --- a/src/HEXABLOCKGUI/Disconnect_QTD.ui +++ b/src/HEXABLOCKGUI/Disconnect_QTD.ui @@ -6,8 +6,8 @@ 0 0 - 282 - 623 + 270 + 556 @@ -34,7 +34,7 @@ 0 - 50 + 0 @@ -129,12 +129,6 @@ - - QLayout::SetDefaultConstraint - - - QFormLayout::AllNonFixedFieldsGrow - @@ -145,14 +139,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -171,14 +165,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -205,12 +199,6 @@ - - QLayout::SetDefaultConstraint - - - QFormLayout::AllNonFixedFieldsGrow - @@ -221,14 +209,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -247,14 +235,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -297,14 +285,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -323,14 +311,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -353,7 +341,7 @@ 16777215 - 344 + 16777215 @@ -374,7 +362,7 @@ 16777215 - 131 + 16777215 @@ -384,7 +372,7 @@ - + 0 0 @@ -392,7 +380,7 @@ 16777215 - 16777215 + 70 @@ -417,7 +405,7 @@ 16777215 - 131 + 16777215 @@ -427,7 +415,7 @@ - + 0 0 @@ -435,7 +423,7 @@ 16777215 - 16777215 + 70 @@ -449,19 +437,6 @@ - - - - Qt::Vertical - - - - 20 - 10 - - - - @@ -485,40 +460,40 @@ rb1 clicked() - widget_4 + widget hide() - 140 - 40 + 153 + 51 - 167 - 479 + 143 + 109 - rb2 + rb0 clicked() - widget_4 - hide() + widget + show() - 291 - 40 + 61 + 48 - 167 - 479 + 76 + 104 rb3 clicked() - widget_4 - show() + widget + hide() 223 @@ -526,7 +501,7 @@ 167 - 479 + 120 @@ -547,170 +522,170 @@ - rb0 + rb2 clicked() - widget_4 + widget_2 hide() - 58 - 40 + 271 + 46 - 167 - 479 + 268 + 194 - rb2 + rb1 clicked() - widget_3 + widget_2 show() - 258 - 46 + 197 + 48 - 238 - 310 + 218 + 182 - rb2 + rb0 clicked() widget_2 hide() - 271 + 94 46 - 268 - 194 + 181 + 180 - rb0 + rb2 clicked() widget_3 - hide() + show() - 41 - 49 + 258 + 46 - 73 + 238 310 - rb1 + rb0 clicked() - widget + widget_3 hide() - 153 - 51 + 41 + 49 - 143 - 109 + 73 + 310 - rb0 + rb3 clicked() - widget_2 + widget_3 hide() - 94 - 46 + 223 + 40 - 181 - 180 + 167 + 260 - rb0 + rb1 clicked() - widget - show() + widget_3 + hide() - 61 - 48 + 182 + 38 - 76 - 104 + 190 + 310 - rb1 + rb2 clicked() - widget_2 - show() + widget_4 + hide() - 197 - 48 + 291 + 40 - 218 - 182 + 167 + 479 rb1 clicked() - widget_3 + widget_4 hide() - 182 - 38 + 140 + 40 - 190 - 310 + 167 + 479 - rb3 + rb0 clicked() - widget_3 + widget_4 hide() - 223 + 58 40 167 - 260 + 479 rb3 clicked() - widget - hide() + widget_4 + show() 223 @@ -718,7 +693,7 @@ 167 - 120 + 479 diff --git a/src/HEXABLOCKGUI/EdgeAssoc_QTD.ui b/src/HEXABLOCKGUI/EdgeAssoc_QTD.ui index f42defd..50d4589 100644 --- a/src/HEXABLOCKGUI/EdgeAssoc_QTD.ui +++ b/src/HEXABLOCKGUI/EdgeAssoc_QTD.ui @@ -6,8 +6,8 @@ 0 0 - 309 - 789 + 260 + 635 @@ -48,8 +48,8 @@ 0 0 - 287 - 767 + 223 + 620 @@ -105,7 +105,7 @@ Arguments - + @@ -120,33 +120,30 @@ Vertex - - - - - First : - - - - - - - false - - - - - - - Qt::Horizontal - - - - 78 - 20 - - - + + + + + + + First : + + + + + + + + 0 + 0 + + + + false + + + + @@ -168,9 +165,22 @@ Edge of model - - - + + + + + + 0 + 0 + + + + + 16777215 + 58 + + + @@ -186,9 +196,22 @@ Edges of model - - - + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + @@ -204,18 +227,24 @@ Line of the geometry - + - - + + Line : - + + + + 0 + 0 + + false @@ -224,7 +253,14 @@ - + + + + 0 + 0 + + + diff --git a/src/HEXABLOCKGUI/Edge_QTD.ui b/src/HEXABLOCKGUI/Edge_QTD.ui index ade2b3e..7615441 100644 --- a/src/HEXABLOCKGUI/Edge_QTD.ui +++ b/src/HEXABLOCKGUI/Edge_QTD.ui @@ -9,7 +9,7 @@ 0 0 - 294 + 241 322 @@ -90,37 +90,40 @@ Arguments - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Name - - - - - - - - 0 - 0 - - - - - 127 - 16777215 - - - - - + + + + + + + + Name + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + - + @@ -133,14 +136,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -149,18 +152,24 @@ - + Vector - + + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -172,7 +181,7 @@ - + @@ -184,9 +193,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -210,9 +225,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -227,21 +248,17 @@ - - - - Qt::Vertical - - - - 20 - 10 - - - - + + rb0 + rb1 + name_le + vex_le_rb1 + vec_le_rb1 + v0_le_rb0 + v1_le_rb0 + diff --git a/src/HEXABLOCKGUI/Group_QTD.ui b/src/HEXABLOCKGUI/Group_QTD.ui index 808e02c..868bdc7 100644 --- a/src/HEXABLOCKGUI/Group_QTD.ui +++ b/src/HEXABLOCKGUI/Group_QTD.ui @@ -6,12 +6,12 @@ 0 0 - 298 - 306 + 194 + 256 - + 0 0 @@ -39,76 +39,103 @@ - - - - - name : - - - - - - - - 127 - 16777215 - - - - - - - - kind : - - - - - - - - Edge Cell - - - + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + - Quad Cell + name : - - - - Hexa Cell - - - - - Vertex Node + + + + + + + 0 + 0 + - - - - Edge Node - - - - - Quad Node + + + 16777215 + 16777215 + - - + + + + - Hexa Node + kind : - - - - + + + + + + + Edge Cell + + + + + Quad Cell + + + + + Hexa Cell + + + + + Vertex Node + + + + + Edge Node + + + + + Quad Node + + + + + Hexa Node + + + + + + - + + + + 0 + 0 + + + @@ -117,6 +144,11 @@ + + name_le + eltBase_lw + kind_cb + diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI.cxx index 89443f8..4032e1b 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI.cxx @@ -49,6 +49,8 @@ #include #include +#include + #include @@ -113,6 +115,7 @@ #define DW_MINIMUM_WIDTH 50 #define DWINPUT_MINIMUM_HEIGHT 50 +#define DWINPUT_MINIMUM_WIDTH 255 using namespace std; using namespace HEXABLOCK::GUI; @@ -130,6 +133,7 @@ GEOM::GEOM_Gen_var HEXABLOCKGUI::_geomEngine = GEOM::GEOM_Gen::_n SVTK_ViewWindow* HEXABLOCKGUI::currentVtkView = NULL; OCCViewer_ViewWindow* HEXABLOCKGUI::currentOccView = NULL; +bool HEXABLOCKGUI::assocInProgress = false; HEXABLOCKGUI::HEXABLOCKGUI() : SalomeApp_Module( "HEXABLOCK" ), // default name @@ -157,7 +161,9 @@ HEXABLOCKGUI::HEXABLOCKGUI() : _groupsSelectionModel(0), // _documentCnt(0), _isSaved( false ), - _suitVM(0),//, + moduleActivatedOnce(false), + vtkViewManager(0),//, + occViewManager(0), // _selectFromTree( false ) _vertexDiag(0), _edgeDiag(0), @@ -190,7 +196,8 @@ HEXABLOCKGUI::HEXABLOCKGUI() : _computeMeshDiag(0), _replaceHexaDiag(0), _quadRevolutionDiag(0), - _makeHemiSphereDiag(0) + _makeHemiSphereDiag(0), + currentDialog(NULL) { DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI"); // _studyContextMap.clear(); @@ -237,7 +244,9 @@ GEOM::GEOM_Gen_ptr HEXABLOCKGUI::InitGEOMGen( SalomeApp_Application* app, const std::string& container ) { Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( container.c_str(), "GEOM" ); + MESSAGE("INITINITINITINIT comp : " << comp); GEOM::GEOM_Gen_ptr clr = GEOM::GEOM_Gen::_narrow(comp); + MESSAGE("INITINITINITINIT clr 1: " << clr); ASSERT(!CORBA::is_nil(clr)); return clr; } @@ -250,6 +259,7 @@ void HEXABLOCKGUI::initialize( CAM_Application* app ) _hexaEngine = InitHEXABLOCKGen( dynamic_cast( app ) ); _geomEngine = InitGEOMGen( dynamic_cast( app ) ); + MESSAGE("INITINITINITINIT clr 2: " << _geomEngine); QWidget* aParent = application()->desktop(); DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent); @@ -280,7 +290,6 @@ void HEXABLOCKGUI::initialize( CAM_Application* app ) studyActivated(); // add component to study if (createSComponent()) updateObjBrowser(); - } void HEXABLOCKGUI::viewManagers( QStringList& list ) const @@ -294,6 +303,7 @@ void HEXABLOCKGUI::viewManagers( QStringList& list ) const // list.append( SVTK_Viewer::Type() ); } + bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy ) { DEBTRACE("HEXABLOCKGUI::activateModule"); @@ -307,9 +317,9 @@ bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy ) else showAllMenus(); - // showDockWidgets(false); showDockWidgets(true); + if (_dwInputPanel) _dwInputPanel->close(); // // import Python module that manages HEXABLOCK plugins (need to be here because SalomePyQt API uses active module) // PyGILState_STATE gstate = PyGILState_Ensure(); @@ -333,6 +343,7 @@ bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy ) // connect( getApp(), SIGNAL(studyClosed()), _genericGui,SLOT (onCleanOnExit())); +// vtkViewManager = getApp()->getViewManager(SVTK_Viewer::Type(), true); //create the view manager if it doesn't exist LightApp_SelectionMgr* sm = getApp()->selectionMgr(); SUIT_ViewManager* vm; @@ -378,6 +389,9 @@ bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy ) updateObjBrowser(); // objects can be removed } + if (vtkViewManager==NULL || !vtkViewManager->getViewsCount()) newDocument(); + if (_currentGraphicView != NULL) + _currentGraphicView->get_SUIT_ViewWindow()->setFocus(); return bOk; } @@ -386,10 +400,11 @@ bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy ) bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy ) { - DEBTRACE("HEXABLOCKGUI::deactivateModule"); + MESSAGE("HEXABLOCKGUI::deactivateModule"); setMenuShown( false ); setToolShown( false ); + if (_dwInputPanel) _dwInputPanel->close(); showDockWidgets( false ); // QtGuiContext *context = QtGuiContext::getQtCurrent(); // _studyContextMap[theStudy->id()] = context; @@ -406,10 +421,16 @@ bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy ) HEXABLOCKGUI::currentVtkView->SetSelectionMode( ActorSelection ); //default selectionMode in VTKView } -// if (HEXABLOCKGUI::currentOccView) -// { -// //getDisplayer()->globalSelection();//???? //defaut selectionMode in OccView -// } + if (HEXABLOCKGUI::currentOccView != NULL) + { + getApp()->selectionMgr()->clearSelected(); + //defaut selectionMode in OccView + if (currentDialog != NULL) + { + currentDialog->globalSelection(); + currentDialog->localSelection(GEOM::GEOM_Object::_nil(), TopAbs_SHAPE); + } + } // if ( _patternDataSelectionModel ){ @@ -423,11 +444,11 @@ bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy ) qDeleteAll(myOCCSelectors); myOCCSelectors.clear(); - getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() ); + getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() ); qDeleteAll(myVTKSelectors); myVTKSelectors.clear(); - getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() ); + getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() ); return SalomeApp_Module::deactivateModule( theStudy ); } @@ -484,7 +505,6 @@ bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name) return result; } - // --- Default windows void HEXABLOCKGUI::windows( QMap& theMap ) const { @@ -508,8 +528,6 @@ void HEXABLOCKGUI::windows( QMap& theMap ) const // } - - QString HEXABLOCKGUI::engineIOR() const { DEBTRACE("HEXABLOCKGUI::engineIOR"); @@ -557,32 +575,37 @@ void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index) void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw) { - DEBTRACE("HEXABLOCKGUI::onWindowActivated"); - OCCViewer_ViewWindow* anOccVw = dynamic_cast(svw); + DEBTRACE("HEXABLOCKGUI::onWindowActivated"); + MESSAGE("HEXABLOCKGUI::onWindowActivated"); + OCCViewer_ViewWindow* anOccVw = dynamic_cast(svw); - if ( anOccVw != NULL ) - currentOccView = dynamic_cast(svw); -// OCCViewer_Viewer* aModel = dynamic_cast(svw); + if ( anOccVw != NULL) + { + currentOccView->installEventFilter(this); + if (anOccVw != currentOccView) + currentOccView = anOccVw; + } - // we want to switch automatically to the right model - // only VTK view - SVTK_ViewWindow* viewWindow = dynamic_cast(svw); - if (!viewWindow) return; - if (getApp()->activeModule() && getApp()->activeModule()->moduleName().compare("HEXABLOCK") != 0) //CS_TODO? - getApp()->activateModule("HEXABLOCK"); + // we want to switch automatically to the right model + // only VTK view + SVTK_ViewWindow* viewWindow = dynamic_cast(svw); + if (!viewWindow) return; - switchModel( viewWindow ); -} + if (getApp()->activeModule() && getApp()->activeModule()->moduleName().compare("HEXABLOCK") != 0) //CS_TODO? + getApp()->activateModule("HEXABLOCK"); + if (viewWindow != currentVtkView) + { + switchModel( viewWindow ); + currentVtkView = viewWindow; + } +} void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw) { DEBTRACE("HEXABLOCKGUI::onWindowClosed"); } - - - void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm) { DEBTRACE("HEXABLOCKGUI::onViewManagerAdded"); @@ -593,8 +616,8 @@ void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm) // // this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) ); // // connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ), // // this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) ); -// // connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ), -// // this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) ); +// connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ), +// this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) ); // LightApp_SelectionMgr* sm = getApp()->selectionMgr(); // myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) ); // @@ -767,10 +790,16 @@ void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition) QStandardItem *item = _patternDataModel->itemFromIndex ( currentIndex ); - //We don't do anything for single items having no association + //We don't do anything for single items if ( item->type() == VERTEXITEM || item->type() == EDGEITEM || - item->type() == QUADITEM || item->type() == HEXAITEM) return; - + item->type() == QUADITEM || item->type() == HEXAITEM) + return; + + //No associations for HEXA + QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE ); + if ( !treeVariant.isValid() ) return; + int eltType = treeVariant.toInt(); + if (eltType == HEXA_DIR_TREE) return; QMenu menu( _patternDataTreeView ); //Show association(s) @@ -794,12 +823,14 @@ void HEXABLOCKGUI::createAndFillDockWidget() //1) *********** user input panel ( contain user's edit dialog box ) _dwInputPanel = new QDockWidget(aParent); +// QLayout* inputLayout = new QVBoxLayout(aParent); +// _dwInputPanel->setLayout(inputLayout); // _dwInputPanel->setWindowFlags(Qt::FramelessWindowHint); // _dwInputPanel->setWindowFlags(Qt::WindowTitleHint); _dwInputPanel->setVisible(false); _dwInputPanel->setWindowTitle("Input Panel"); // _dwInputPanel->setMinimumHeight(DWINPUT_MINIMUM_HEIGHT); - _dwInputPanel->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display + _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display _dwInputPanel->raise(); // _stacked = new QStackedWidget(_dwInputPanel); @@ -892,8 +923,9 @@ void HEXABLOCKGUI::createAndFillDockWidget() aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwInputPanel ); aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern ); - aParent->tabifyDockWidget( _dwPattern, /*_dwAssociation ); - aParent->tabifyDockWidget( _dwAssociation, */_dwGroups ); +// aParent->tabifyDockWidget( _dwPattern, /*_dwAssociation ); +// aParent->tabifyDockWidget( _dwAssociation, */_dwGroups ); + aParent->tabifyDockWidget( _dwPattern, _dwGroups ); aParent->tabifyDockWidget( _dwGroups, _dwMesh ); @@ -907,8 +939,6 @@ void HEXABLOCKGUI::createAndFillDockWidget() // connect( _dwGroups, SIGNAL( visibilityChanged(bool) ), this, SLOT( showGroupsMenus(bool) ) ); // connect( _dwMesh, SIGNAL( visibilityChanged(bool) ), this, SLOT( showMeshMenus(bool) ) ); - - // popup menu on data tree view _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu); connect(_patternDataTreeView, @@ -1537,10 +1567,10 @@ void HEXABLOCKGUI::switchModel(SUIT_ViewWindow *view) _meshTreeView->setModel(_meshModel); // set selections for each view - if ( _patternDataSelectionModel ) delete _patternDataSelectionModel; - if ( _patternBuilderSelectionModel ) delete _patternBuilderSelectionModel; - if ( _groupsSelectionModel ) delete _groupsSelectionModel; - if ( _meshSelectionModel ) delete _meshSelectionModel; +// if ( _patternDataSelectionModel ) delete _patternDataSelectionModel; +// if ( _patternBuilderSelectionModel ) delete _patternBuilderSelectionModel; +// if ( _groupsSelectionModel ) delete _groupsSelectionModel; +// if ( _meshSelectionModel ) delete _meshSelectionModel; _patternDataSelectionModel = new PatternDataSelectionModel( _patternDataModel ); _patternBuilderSelectionModel = new PatternBuilderSelectionModel( _patternBuilderModel, _patternDataSelectionModel ); @@ -1583,8 +1613,6 @@ void HEXABLOCKGUI::switchModel(SUIT_ViewWindow *view) connect( _meshSelectionModel, SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); - - currentVtkView = dynamic_cast( _currentGraphicView->get_SUIT_ViewWindow() ); } showPatternMenus(true); @@ -1632,29 +1660,54 @@ void HEXABLOCKGUI::showDockWidgets(bool isVisible) DocumentGraphicView* HEXABLOCKGUI::newGraphicView() { MESSAGE("HEXABLOCKGUI::newGraphicView"); - DocumentGraphicView *newGView = 0; + DocumentGraphicView *newGView = NULL; SUIT_ViewWindow *suitVW = NULL; - SUIT_ViewManager *suitVM = getApp()->getViewManager(SVTK_Viewer::Type(), true); - MESSAGE("suitVM->getViewsCount() => " << suitVM->getViewsCount() ); - suitVW = suitVM->getActiveView(); - if ( _documentView.count(suitVW) > 0) - suitVW = suitVM->createViewWindow(); + //For the first time initialize occ view manager + if (_documentView.size() == 0) + { + occViewManager = getApp()->getViewManager( OCCViewer_Viewer::Type(), true ); + occViewManager->getActiveView()->setClosable(false); + currentOccView = dynamic_cast(occViewManager->getActiveView()); + } - if ( suitVW ){ - suitVW->setClosable(false); - newGView = new DocumentGraphicView(getApp(), suitVW, application()->desktop()); - _documentView[suitVW] = newGView; + vtkViewManager = getApp()->getViewManager( SVTK_Viewer::Type(), true ); + if (_documentView.size() == 0) + { + suitVW = vtkViewManager->getActiveView(); + suitVW->setClosable(false); } + else + suitVW = vtkViewManager->createViewWindow(); + currentVtkView = dynamic_cast(suitVW); + currentVtkView->installEventFilter(this); + newGView = new DocumentGraphicView(getApp(), suitVW, application()->desktop()); + _documentView[suitVW] = newGView; return newGView; } - - - - - +//DocumentGraphicView* HEXABLOCKGUI::newGraphicView() +//{ +// MESSAGE("HEXABLOCKGUI::newGraphicView"); +// DocumentGraphicView *newGView = 0; +// SUIT_ViewWindow *suitVW = NULL; +// +// SUIT_ViewManager *vtkViewManager = getApp()->getViewManager(SVTK_Viewer::Type(), true); +// MESSAGE("suitVM->getViewsCount() => " << suitVM->getViewsCount() ); +// suitVW = suitVM->getActiveView(); +// if ( _documentView.count(suitVW) > 0) +// suitVW = suitVM->createViewWindow(); +// +// if ( suitVW ){ +//// suitVW->setClosable(false); +// suitVW->setClosable(true); +// newGView = new DocumentGraphicView(getApp(), suitVW, application()->desktop()); +// _documentView[suitVW] = newGView; +// } +// +// return newGView; +//} void HEXABLOCKGUI::testDocument() @@ -1920,148 +1973,150 @@ void HEXABLOCKGUI::test_association() void HEXABLOCKGUI::newDocument() { - DEBTRACE("HEXABLOCKGUI::newDocument"); - - SUIT_ViewWindow *suitVW = NULL; -// std::stringstream name; -// name << "newDoc_" << ++_documentCnt; -// QString fileName = name.str().c_str(); - QMainWindow *aParent = application()->desktop(); - QWidget *central = aParent->centralWidget(); - if (central) - central->setFocus(); - else - DEBTRACE("No Central Widget"); - -// BasicGUI_PointDlg* aDlg = new BasicGUI_PointDlg( NULL, aParent ); -// aDlg->show(); - - // Create Document from HEXABLOCK ENGINE - // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process - HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); - - HEXA_NS::Document* doc = NULL; - QString docEntry; - - // looking doc impl ( c++ ) - Document_impl* dServant = DownCast( docIn ); - ASSERT( dServant ); - if ( dServant) doc = dServant->GetImpl(); - -// doc->reorderFaces(); //CS_TEST - - // looking for docEntry - if ( !CORBA::is_nil(docIn) ){ - CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn ); - QString docIOR = anIOR.in(); - SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); - if ( !docIOR.isEmpty() ) { - _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) ); - if ( SO ) - docEntry = SO->GetID().c_str(); - } - } - - DEBTRACE("HEXABLOCKGUI::newDocument docEntry "<setHeaderData(0, Qt::Horizontal, tr("HELLOH0")); -// _currentModel->setHeaderData(1, Qt::Horizontal, tr("HELLOH1")); -// _currentModel->setHeaderData(0, Qt::Vertical, tr("HELLOV0")); - _patternDataModel = new PatternDataModel(this); - _patternBuilderModel = new PatternBuilderModel(this); -// _associationsModel = new AssociationsModel(this); - _groupsModel = new GroupsModel(this); - _meshModel = new MeshModel(this); - - _patternDataModel->setSourceModel(_currentModel); - _patternBuilderModel->setSourceModel(_currentModel); -// _associationsModel->setSourceModel(_currentModel); - _groupsModel->setSourceModel(_currentModel); - _meshModel->setSourceModel(_currentModel); - - // --- new Graphic view ( SVTK ) - _currentGraphicView = newGraphicView(); - suitVW = _currentGraphicView->get_SUIT_ViewWindow(); - - // --- setting model - _currentGraphicView->setModel(_currentModel); -// _currentGraphicView->setModel(_patternDataModel); -// connect( _currentModel, SIGNAL(patternDataChanged() ), _currentGraphicView, SLOT ( onPatternDatachanged() ) ); - _patternDataTreeView->setModel(_patternDataModel);//_currentModel; -// _patternDataTreeView->setModel(_currentModel);//; - _patternBuilderTreeView->setModel(_patternBuilderModel);//_currentModel; -// _associationTreeView->setModel(_associationsModel); - _groupsTreeView->setModel(_groupsModel); - _meshTreeView->setModel(_meshModel); - - - // --- setting selection model - if ( _patternDataSelectionModel ) delete _patternDataSelectionModel; - if ( _patternBuilderSelectionModel ) delete _patternBuilderSelectionModel; - if ( _groupsSelectionModel ) delete _groupsSelectionModel; - if ( _meshSelectionModel ) delete _meshSelectionModel; - - _patternDataSelectionModel = new PatternDataSelectionModel(_patternDataModel); - _patternBuilderSelectionModel = new PatternBuilderSelectionModel( _patternBuilderModel, _patternDataSelectionModel ); - _groupsSelectionModel = new GroupsSelectionModel(_groupsModel); - _meshSelectionModel = new MeshSelectionModel(_meshModel); - - _patternDataSelectionModel->setSalomeSelectionMgr( selectionMgr() ); -// _meshSelectionModel->setSalomeSelectionMgr( selectionMgr() ); - - _currentGraphicView->setSelectionModel(_patternDataSelectionModel); - _patternDataTreeView->setSelectionModel(_patternDataSelectionModel); - _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection); //QAbstractItemView::MultiSelection //CS_TEST - _patternBuilderTreeView->setSelectionModel(_patternBuilderSelectionModel); - _groupsTreeView->setSelectionModel(_groupsSelectionModel); - _meshTreeView->setSelectionModel(_meshSelectionModel); - _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection); - - _treeViewDelegate->setDocumentModel( _currentModel ); - _treeViewDelegate->setPatternDataSelectionModel( _patternDataSelectionModel ); - _treeViewDelegate->setPatternBuilderSelectionModel( _patternBuilderSelectionModel ); - _treeViewDelegate->setGroupsSelectionModel( _groupsSelectionModel/*_groupsTreeView->selectionModel()*/ ); - _treeViewDelegate->setMeshSelectionModel( _meshSelectionModel/*_meshTreeView->selectionModel()*/ ); - - - connect( _patternDataSelectionModel, SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), - this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); - connect( _patternBuilderSelectionModel, SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), - this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); - connect( _groupsSelectionModel, SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), - this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); - connect( _meshSelectionModel, SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), - this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); - - - // salome view/object browser/model management - _documentModels[ suitVW ] = _currentModel; - -// _salomeViews[ _currentModel ] = suitVW; -// std::map _salomeViews; - - _salomeViewWindows[docEntry] = suitVW; - currentVtkView = dynamic_cast( _currentGraphicView->get_SUIT_ViewWindow() ); - currentVtkView->raise(); - -// _currentGraphicView->setWindowTitle( _currentModel->getName() ); -// currentVtkView->setWindowTitle( _currentModel->getName() ); -// showDockWidgets(true); -// showPatternMenus -// _dwPattern->setVisible(true); -// _dwPattern->toggleViewAction()->setVisible(true); - _dwPattern->raise(); -// testDocument(); -// test_make_cart_grid(); -// test_make_elmts_transform(); - showAllMenus(); - getApp()->updateObjectBrowser(); + DEBTRACE("HEXABLOCKGUI::newDocument"); + + SUIT_ViewWindow *suitVW = NULL; + // std::stringstream name; + // name << "newDoc_" << ++_documentCnt; + // QString fileName = name.str().c_str(); + QMainWindow *aParent = application()->desktop(); + QWidget *central = aParent->centralWidget(); + if (central) + central->setFocus(); + else + DEBTRACE("No Central Widget"); + + // BasicGUI_PointDlg* aDlg = new BasicGUI_PointDlg( NULL, aParent ); + // aDlg->show(); + + // Create Document from HEXABLOCK ENGINE + // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process + HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); + + HEXA_NS::Document* doc = NULL; + QString docEntry; + + // looking doc impl ( c++ ) + Document_impl* dServant = DownCast( docIn ); + ASSERT( dServant ); + if ( dServant) doc = dServant->GetImpl(); + + // doc->reorderFaces(); //CS_TEST + + // looking for docEntry + if ( !CORBA::is_nil(docIn) ){ + CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn ); + QString docIOR = anIOR.in(); + SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + if ( !docIOR.isEmpty() ) { + _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) ); + if ( SO ) + docEntry = SO->GetID().c_str(); + } + } + DEBTRACE("HEXABLOCKGUI::newDocument docEntry "<setHeaderData(0, Qt::Horizontal, tr("HELLOH0")); + // _currentModel->setHeaderData(1, Qt::Horizontal, tr("HELLOH1")); + // _currentModel->setHeaderData(0, Qt::Vertical, tr("HELLOV0")); + _patternDataModel = new PatternDataModel(this); + _patternBuilderModel = new PatternBuilderModel(this); + // _associationsModel = new AssociationsModel(this); + _groupsModel = new GroupsModel(this); + _meshModel = new MeshModel(this); + + _patternDataModel->setSourceModel(_currentModel); + _patternBuilderModel->setSourceModel(_currentModel); + // _associationsModel->setSourceModel(_currentModel); + _groupsModel->setSourceModel(_currentModel); + _meshModel->setSourceModel(_currentModel); + + // --- new Graphic view ( SVTK ) + _currentGraphicView = newGraphicView(); + suitVW = _currentGraphicView->get_SUIT_ViewWindow(); + + // --- setting model + _currentGraphicView->setModel(_currentModel); + // _currentGraphicView->setModel(_patternDataModel); + // connect( _currentModel, SIGNAL(patternDataChanged() ), _currentGraphicView, SLOT ( onPatternDatachanged() ) ); + _patternDataTreeView->setModel(_patternDataModel);//_currentModel; + // _patternDataTreeView->setModel(_currentModel);//; + _patternBuilderTreeView->setModel(_patternBuilderModel);//_currentModel; + // _associationTreeView->setModel(_associationsModel); + _groupsTreeView->setModel(_groupsModel); + _meshTreeView->setModel(_meshModel); + + + // if ( _patternDataSelectionModel ) delete _patternDataSelectionModel; + // if ( _patternBuilderSelectionModel ) delete _patternBuilderSelectionModel; + // if ( _groupsSelectionModel ) delete _groupsSelectionModel; + // if ( _meshSelectionModel ) delete _meshSelectionModel; + + // --- setting selection model + _patternDataSelectionModel = new PatternDataSelectionModel(_patternDataModel); + _patternBuilderSelectionModel = new PatternBuilderSelectionModel( _patternBuilderModel, _patternDataSelectionModel ); + _groupsSelectionModel = new GroupsSelectionModel(_groupsModel); + _meshSelectionModel = new MeshSelectionModel(_meshModel); + + _patternDataSelectionModel->setSalomeSelectionMgr( selectionMgr() ); + // _meshSelectionModel->setSalomeSelectionMgr( selectionMgr() ); + + _currentGraphicView->setSelectionModel(_patternDataSelectionModel); + _patternDataTreeView->setSelectionModel(_patternDataSelectionModel); + _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection); //QAbstractItemView::MultiSelection //CS_TEST + _patternBuilderTreeView->setSelectionModel(_patternBuilderSelectionModel); + _groupsTreeView->setSelectionModel(_groupsSelectionModel); + _meshTreeView->setSelectionModel(_meshSelectionModel); + _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection); + + _treeViewDelegate->setDocumentModel( _currentModel ); + _treeViewDelegate->setPatternDataSelectionModel( _patternDataSelectionModel ); + _treeViewDelegate->setPatternBuilderSelectionModel( _patternBuilderSelectionModel ); + _treeViewDelegate->setGroupsSelectionModel( _groupsSelectionModel/*_groupsTreeView->selectionModel()*/ ); + _treeViewDelegate->setMeshSelectionModel( _meshSelectionModel/*_meshTreeView->selectionModel()*/ ); + + + connect( _patternDataSelectionModel, SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), + this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); + connect( _patternBuilderSelectionModel, SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), + this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); + connect( _groupsSelectionModel, SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), + this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); + connect( _meshSelectionModel, SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), + this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); + + + // salome view/object browser/model management + _documentModels[ suitVW ] = _currentModel; + + // _salomeViews[ _currentModel ] = suitVW; + // std::map _salomeViews; + + _salomeViewWindows[docEntry] = suitVW; + currentVtkView = dynamic_cast( _currentGraphicView->get_SUIT_ViewWindow() ); + currentVtkView->raise(); + + // _currentGraphicView->setWindowTitle( _currentModel->getName() ); + // currentVtkView->setWindowTitle( _currentModel->getName() ); + // showDockWidgets(true); + // showPatternMenus + // _dwPattern->setVisible(true); + // _dwPattern->toggleViewAction()->setVisible(true); + _dwPattern->raise(); + // testDocument(); + // test_make_cart_grid(); + // test_make_elmts_transform(); + showAllMenus(); + getApp()->updateObjectBrowser(); + + graphicViewIsEmpty[suitVW] = true; } + void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { //std::cout << "HHHHHHHHHHHHHHHHHH Model changed." << std::endl; @@ -2094,14 +2149,15 @@ void HEXABLOCKGUI::loadDocument( const QString &inFile ) if (!selectedFiles.isEmpty()) selectedFile = selectedFiles.first(); } - } else { - selectedFile = inFile; - } + } else + selectedFile = inFile; if (! selectedFile.isEmpty()){ - newDocument(); - _currentModel->load(selectedFile); - renameObject( _currentModel->documentEntry(), _currentModel->getName() ); + if (vtkViewManager==NULL || vtkViewManager->getViewsCount()==0 || !graphicViewIsEmpty[vtkViewManager->getActiveView()]) + newDocument(); + _currentModel->load(selectedFile); + renameObject( _currentModel->documentEntry(), _currentModel->getName() ); + graphicViewIsEmpty[vtkViewManager->getActiveView()] = false; } } @@ -2123,37 +2179,51 @@ void HEXABLOCKGUI::saveDocument() filter, tr( "Save HexaBlock Document" ), false ); - //std::cout<<"HEXABLOCKGUI::saveDocument()"<save( aFilename ); } //CS_TODO save doc } + void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag ) { MESSAGE("HEXABLOCKGUI::_showDialogBox()"); + if (vtkViewManager == NULL || vtkViewManager->getViewsCount() == 0) return; if (!diag) return; MESSAGE("if (!diag) return;"); if (!_dwInputPanel) return; MESSAGE("if (!_dwInputPanel) return;"); + currentDialog = diag; diag->setDocumentModel(_currentModel); diag->setPatternDataSelectionModel(_patternDataSelectionModel); diag->setPatternBuilderSelectionModel(_patternBuilderSelectionModel); diag->setGroupsSelectionModel(_groupsSelectionModel); - diag->setMeshSelectionModel(_meshSelectionModel/*_meshTreeView->selectionModel()*/); + diag->setMeshSelectionModel(_meshSelectionModel); - QWidget* w = _dwInputPanel->widget(); - if (w) w->hide(); + //close the current widget + if (_treeViewDelegate != NULL) + _treeViewDelegate->closeDialog(); - if ( !_dwInputPanel->isVisible() ) _dwInputPanel->setVisible(true); - _dwInputPanel->setWidget(diag); - _dwInputPanel->setWindowTitle(diag->windowTitle()); - diag->show(); -} + if (_dwInputPanel->widget()) + _dwInputPanel->widget()->close(); + //Temporary for debugging EdgeAssoc Faked InfoDialog + if (diag == _edgeAssocDiag) + diag->debugEdgeAssoc = true; + else + diag->debugEdgeAssoc = false; + + if (diag == _quadAssocDiag || diag == _edgeAssocDiag) + assocInProgress = true; + else + assocInProgress = false; + + //show the dialog box in the dockwidget + diag->resetSizeAndShow(_dwInputPanel); + diag->setFocus(); +} void HEXABLOCKGUI::addVertex() { @@ -2171,9 +2241,6 @@ void HEXABLOCKGUI::addEdge() _showDialogBox( _edgeDiag ); } - - - void HEXABLOCKGUI::addQuad() { if ( !_quadDiag ){ @@ -2383,15 +2450,26 @@ void HEXABLOCKGUI::quadRevolution() // NEW HEXA3 void HEXABLOCKGUI::assocVertex() { MESSAGE("HEXABLOCKGUI::assocVertex()"); + if (!_dwInputPanel) return; QWidget* d = dynamic_cast(_dwInputPanel->parent()); + if ( !_vertexAssocDiag ){ _vertexAssocDiag = new VertexAssocDialog( NULL, d ); + if (!_vertexAssocDiag) return; } _vertexAssocDiag->setDocumentModel(_currentModel); _vertexAssocDiag->setPatternDataSelectionModel(_patternDataSelectionModel); + + //close current widget + if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog(); + if (_dwInputPanel->widget()) _dwInputPanel->widget()->close(); + + //add the vertex assoc dialog in the dockwidget + if ( !_dwInputPanel->isVisible() ) _dwInputPanel->setVisible(true); _dwInputPanel->setWidget(_vertexAssocDiag); _dwInputPanel->setWindowTitle(_vertexAssocDiag->windowTitle()); - //_vertexAssocDiag->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + _vertexAssocDiag->adjustSize(); + assocInProgress = true; _vertexAssocDiag->show(); } @@ -2554,15 +2632,10 @@ have the default law.").arg(selected.data().toString()), void HEXABLOCKGUI::setPropagation() { - if (!_dwInputPanel) return; - PropagationDialog* diag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE); - diag->setDocumentModel(_currentModel); - diag->setMeshSelectionModel(_meshSelectionModel); - //diag->setValue(p); - diag->setFocus(); - _dwInputPanel->setWidget(diag); - _dwInputPanel->setWindowTitle( diag->windowTitle() ); - diag->clear(); + if ( !_propagationDiag ){ + _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE); + } + _showDialogBox( _propagationDiag ); } @@ -2586,7 +2659,7 @@ void HEXABLOCKGUI::clearAssociations() _currentModel->clearEltAssociations(iModel); - SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) ); +// SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) ); } void HEXABLOCKGUI::clearAllAssociations() @@ -2648,7 +2721,7 @@ LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr() if( anApp ) return dynamic_cast( anApp->selectionMgr() ); else - return 0; + return NULL; } QStringList HEXABLOCKGUI::getQuickDirList() @@ -2678,14 +2751,6 @@ extern "C" } - - - - - - - - // void HEXABLOCKGUI::newMesh( const std::string& meshName, // int dim, // const std::string& container ) @@ -2802,9 +2867,9 @@ SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen() return myComponentSMESH; }*/ -// bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event) -// { -// if ( event->type() == QEvent::Enter ){//QEvent::Show ){ //QEvent::KeyPress) { + bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event) + { + if ( event->type() == QEvent::Enter ){//QEvent::Show ){ //QEvent::KeyPress) { // showDocumentMenus( false ); // showPatternMenus( false ); // showAssociationMenus( false ); @@ -2822,12 +2887,22 @@ SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen() // // showMeshMenus( true ); // } -// return false; -// } else { -// // standard event processing -// return QObject::eventFilter(obj, event); -// } -// } + OCCViewer_ViewWindow* occWindow = dynamic_cast(obj); + if ( occWindow != NULL ) + { + occWindow->setFocus(); + } + SVTK_ViewWindow* vtkWindow = dynamic_cast(obj); + if (vtkWindow != NULL) + { +// vtkWindow->setFocus(); + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + } // try { // // throw SALOME_Exception(LOCALIZED("assocVertex")); diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI.hxx b/src/HEXABLOCKGUI/HEXABLOCKGUI.hxx index 68cda62..10817e9 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI.hxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI.hxx @@ -144,6 +144,7 @@ public: static SVTK_ViewWindow* currentVtkView; static OCCViewer_ViewWindow* currentOccView; + static bool assocInProgress; //HEXABLOCK::GUI::DocumentModel* @@ -193,6 +194,7 @@ public slots: protected slots: void onWindowActivated( SUIT_ViewWindow* svw); void onWindowClosed( SUIT_ViewWindow* svw); +// void OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ); virtual void onViewManagerAdded( SUIT_ViewManager* ); virtual void onViewManagerRemoved( SUIT_ViewManager* ); @@ -204,9 +206,10 @@ protected: // virtual CAM_DataModel* createDataModel(); bool createSComponent(); // virtual bool isSelectionCompatible(); + virtual bool eventFilter(QObject *obj, QEvent *event); void _showDialogBox( HEXABLOCK::GUI::HexaBaseDialog* diag ); - + HEXABLOCK::GUI::HexaBaseDialog* currentDialog; // bool _selectFromTree; HEXABLOCKGUI_Resource* _myresource; @@ -305,6 +308,7 @@ private: QDockWidget *_dwObjectBrowser; // Salome study QDockWidget *_dwInputPanel; // user Input + // Dialog Box ( to keep persistent values ) HEXABLOCK::GUI::VertexDialog* _vertexDiag; HEXABLOCK::GUI::EdgeDialog* _edgeDiag; @@ -432,17 +436,19 @@ private: HEXABLOCK::GUI::MeshSelectionModel *_meshSelectionModel; // SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME - SUIT_ViewManager *_suitVM; + SUIT_ViewManager *vtkViewManager; + SUIT_ViewManager *occViewManager; std::map _salomeViewWindows; // key = entry // SALOME/QT SALOME/QT SALOME/QT SALOME/QT SALOME/QT SALOME/QT std::map _documentModels; std::map _documentView; - + std::map graphicViewIsEmpty; // static std::map _salomeViews; // int _documentCnt; bool _isSaved; + bool moduleActivatedOnce; void testDocument(); diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentDelegate.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentDelegate.cxx index dcd4f11..1951143 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentDelegate.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentDelegate.cxx @@ -19,19 +19,23 @@ // #include #include +#include +#include +#include #include "utilities.h" +#include "HEXABLOCKGUI.hxx" #include "HEXABLOCKGUI_DocumentDelegate.hxx" -#include "HEXABLOCKGUI_DocumentItem.hxx" -#include "HEXABLOCKGUI_DocumentPanel.hxx" using namespace std; using namespace HEXABLOCK::GUI; +//QWidget* currentEditor = NULL; + DocumentDelegate::DocumentDelegate(QDockWidget *dw, QObject *parent) : QItemDelegate(parent), _dw(dw), @@ -39,7 +43,8 @@ DocumentDelegate::DocumentDelegate(QDockWidget *dw, QObject *parent) _patternDataSelectionModel(0), _patternBuilderSelectionModel(0), _groupsSelectionModel(0), - _meshSelectionModel(0) + _meshSelectionModel(0), + _currentEditor(NULL) { // connect( this, SIGNAL( closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint) ), // this, SLOT( onCloseEditor(QWidget *, QAbstractItemDelegate::EndEditHint) ) ); @@ -48,16 +53,6 @@ DocumentDelegate::DocumentDelegate(QDockWidget *dw, QObject *parent) } -// void DocumentDelegate::commitEditor() -// { -// MESSAGE("DocumentDelegate::commitEditor(){") -// MESSAGE("* sender is: " << sender() ); -// QWidget* editor = qobject_cast(sender()); -// emit commitData(editor); -// // emit closeEditor(editor); -// MESSAGE("}"); -// } - QWidget *DocumentDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const @@ -67,46 +62,67 @@ QWidget *DocumentDelegate::createEditor( QWidget *parent, MESSAGE("* _dw is: " << _dw); MESSAGE("* item is: " << index.data(Qt::DisplayRole).toString().toStdString()); - HexaBaseDialog *editor = 0; + //close current editor if there's one before creating a new one + if (_currentEditor != NULL) + { + delete _currentEditor; + _currentEditor = NULL; + } + + HexaBaseDialog *editor = NULL; + + if (_dw->widget()) _dw->widget()->close(); + if ( !_dw->isVisible() ) _dw->setVisible(true); switch ( index.data(HEXA_TREE_ROLE).toInt() ){ - case VERTEX_TREE : editor = new VertexDialog(parent, HexaBaseDialog::UPDATE_MODE); break; - case EDGE_TREE : editor = new EdgeDialog(parent, /*HexaBaseDialog::NEW_MODE*/HexaBaseDialog::INFO_MODE); break; - case QUAD_TREE : editor = new QuadDialog(parent, HexaBaseDialog::INFO_MODE); break; - case HEXA_TREE : editor = new HexaDialog(parent, HexaBaseDialog::INFO_MODE); break; - case VECTOR_TREE : editor = new VectorDialog(parent, HexaBaseDialog::INFO_MODE); break; - case CYLINDER_TREE : editor = new CylinderDialog(parent, HexaBaseDialog::INFO_MODE); break; - case PIPE_TREE : editor = new PipeDialog(parent, HexaBaseDialog::INFO_MODE); break; + case VERTEX_TREE : editor = new VertexDialog(_dw, HexaBaseDialog::UPDATE_MODE); break; + case EDGE_TREE : editor = new EdgeDialog(_dw, /*HexaBaseDialog::NEW_MODE*/HexaBaseDialog::INFO_MODE); break; + case QUAD_TREE : editor = new QuadDialog(_dw, HexaBaseDialog::INFO_MODE); break; + case HEXA_TREE : editor = new HexaDialog(_dw, HexaBaseDialog::INFO_MODE); break; + case VECTOR_TREE : editor = new VectorDialog(_dw, HexaBaseDialog::INFO_MODE); break; + case CYLINDER_TREE : editor = new CylinderDialog(_dw, HexaBaseDialog::INFO_MODE); break; + case PIPE_TREE : editor = new PipeDialog(_dw, HexaBaseDialog::INFO_MODE); break; // case ELEMENTS_TREE : break; // case CROSSELEMENTS_TREE : break; - case GROUP_TREE : editor = new GroupDialog(parent, HexaBaseDialog::INFO_MODE/*UPDATE_MODE*/); break; - case LAW_TREE : editor = new LawDialog(parent, HexaBaseDialog::UPDATE_MODE); break; - case PROPAGATION_TREE : editor = new PropagationDialog(parent, HexaBaseDialog::INFO_MODE); break; + case GROUP_TREE : editor = new GroupDialog(_dw, HexaBaseDialog::INFO_MODE/*UPDATE_MODE*/); break; + case LAW_TREE : editor = new LawDialog(_dw, HexaBaseDialog::UPDATE_MODE); break; + case PROPAGATION_TREE : editor = new PropagationDialog(_dw, HexaBaseDialog::INFO_MODE); break; } - if ( editor ){ + if ( editor != NULL ){ if ( _documentModel ) editor->setDocumentModel( _documentModel ); - if ( _patternDataSelectionModel ) editor->setPatternDataSelectionModel( _patternDataSelectionModel ); + if ( _patternDataSelectionModel ) + { + editor->setPatternDataSelectionModel( _patternDataSelectionModel ); +// _patternDataSelectionModel->currentDialog = editor; + } if ( _patternBuilderSelectionModel ) editor->setPatternBuilderSelectionModel( _patternBuilderSelectionModel); if ( _groupsSelectionModel ) editor->setGroupsSelectionModel( _groupsSelectionModel ); if ( _meshSelectionModel ) editor->setMeshSelectionModel( _meshSelectionModel); -// QWidget* w = _dw->widget(); -// if (w) w->close(); - if ( !_dw->isVisible() ) _dw->setVisible(true); - _dw->setWidget( editor ); - _dw->setWindowTitle( editor->windowTitle() ); -// connect ( editor, SIGNAL( editingFinished() ), this, SLOT ( commitEditor() ) ); -// editor->exec(); -// editor->show(); -// editor->raise(); -// editor->setFocus(); + HEXABLOCKGUI::assocInProgress = false; + //show the editor in the dockwidget + editor->resetSizeAndShow(_dw); } + else + _dw->close(); MESSAGE("}"); + + _currentEditor = editor; return editor; -// return new QLineEdit(parent); } +//Close the current edition dialog +void DocumentDelegate::closeDialog() +{ + if (_currentEditor!=NULL) + { + _currentEditor->close(); + emit closeEditor(_currentEditor, NoHint); + delete _currentEditor; + _currentEditor = NULL; + } +} void DocumentDelegate::setEditorData( QWidget *editor, const QModelIndex &index) const @@ -118,43 +134,44 @@ void DocumentDelegate::setEditorData( QWidget *editor, switch ( index.data(HEXA_TREE_ROLE).toInt() ){ case VERTEX_TREE : { - HEXA_NS::Vertex *value = index.data( HEXA_DATA_ROLE ).value< HEXA_NS::Vertex* >(); +// HEXA_NS::Vertex *value = index.data( HEXA_DATA_ROLE ).value< HEXA_NS::Vertex* >(); + HEXA_NS::Vertex *value = _documentModel->getHexaPtr(index); VertexDialog *vertexEditor = static_cast(editor); vertexEditor->setValue(value); } break; case EDGE_TREE : { - HEXA_NS::Edge *value = index.data( HEXA_DATA_ROLE ).value< HEXA_NS::Edge* >(); + HEXA_NS::Edge *value = _documentModel->getHexaPtr(index); EdgeDialog *edgeEditor = static_cast(editor); edgeEditor->setValue(value); } break; case QUAD_TREE : { - HEXA_NS::Quad *value = index.data( HEXA_DATA_ROLE ).value< HEXA_NS::Quad* >(); + HEXA_NS::Quad *value = _documentModel->getHexaPtr(index); QuadDialog *quadEditor = static_cast(editor); quadEditor->setValue(value); } break; case HEXA_TREE : { - HEXA_NS::Hexa *value = index.data( HEXA_DATA_ROLE ).value< HEXA_NS::Hexa* >(); + HEXA_NS::Hexa *value = _documentModel->getHexaPtr(index); HexaDialog *hexaEditor = static_cast(editor); hexaEditor->setValue(value); } break; case VECTOR_TREE : { - HEXA_NS::Vector *value = index.data( HEXA_DATA_ROLE ).value< HEXA_NS::Vector* >(); + HEXA_NS::Vector *value = _documentModel->getHexaPtr(index); VectorDialog *vectorEditor = static_cast(editor); vectorEditor->setValue(value); } break; case CYLINDER_TREE : { - HEXA_NS::Cylinder *value = index.data( HEXA_DATA_ROLE ).value< HEXA_NS::Cylinder* >(); + HEXA_NS::Cylinder *value = _documentModel->getHexaPtr(index); CylinderDialog *cylinderEditor = static_cast(editor); cylinderEditor->setValue(value); } break; case PIPE_TREE : { - HEXA_NS::Pipe *value = index.data( HEXA_DATA_ROLE ).value< HEXA_NS::Pipe* >(); + HEXA_NS::Pipe *value = _documentModel->getHexaPtr(index); PipeDialog *pipeEditor= static_cast(editor); pipeEditor->setValue(value); } @@ -181,295 +198,35 @@ void DocumentDelegate::setEditorData( QWidget *editor, break; } -// editor->setFocus(); -// editor->exec(); - MESSAGE("}"); -} - -// void DocumentDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, -// const QModelIndex &index) const -// { -// cout << "//////////////////// CS_BP DocumentDelegate::setModelData BEGIN "<< editor << endl; -// // // QStandardItem *item = 0; -// // // QItemDelegate::setModelData( editor, model,index); -// // -// // // // CS_TODO : simplification? -// // QSortFilterProxyModel *pmodel = dynamic_cast( model ); -// // if ( pmodel ){ -// // QStandardItemModel *smodel = dynamic_cast( pmodel->sourceModel() ); -// // if ( smodel ){ -// // // item = smodel->itemFromIndex(index); -// // QItemDelegate::setModelData( editor, smodel, pmodel->mapToSource(index)); -// // } -// // } else { -// // QStandardItemModel *smodel = dynamic_cast( model ); -// // if ( smodel ){ -// // // item = smodel->itemFromIndex(index); -// // QItemDelegate::setModelData( editor, model,index); -// // } -// // } -// // QItemDelegate::setModelData( editor, model, index); -// cout << "//////////////////// CS_BP DocumentDelegate::setModelData END"<< editor << endl; -// -// } - - -void DocumentDelegate::setModelData( QWidget *editor, - QAbstractItemModel *model, - const QModelIndex &index) const -{ -// cout <<" XXXXXXXXXXXXXX setModelData editor => " << editor << endl; - MESSAGE("DocumentDelegate::setModelData(){"); - MESSAGE("* item is: " << index.data(Qt::DisplayRole).toString().toStdString()); -// HexaDialog *hexaEditor = qobject_cast(editor); -// // PipeDialog *qtcast = qobject_cast(editor); -// // PipeDialog *cppcast = dynamic_cast(editor); -// -// if ( hexaEditor ){ -// HEXA_NS::Hexa *value = hexaEditor->getValue(); -// cout << "XXXXXXXXXXX DocumentDelegate::setModelData value "<< value << endl; -// model->setData( index, QVariant::fromValue( value ), HEXA_DATA_ROLE ); -// model->setData( index, value->getName(), Qt::DisplayRole/*Qt::EditRole*/ ); -// model->setData( index, QString::number( reinterpret_cast(value) ), HEXA_ENTRY_ROLE ); -// } -// editor->show(); -// editor->raise(); - -// cout << "AAAAAAA _dw"<< _dw<< endl; -// cout << "AAAAAAA _dw->widget()"<< _dw->widget() << endl; -// cout << "AAAAAAA isVisible"<< _dw->isVisible() << endl; -// cout << "AAAAAAA editor isVisible"<< editor->isVisible() << endl; -// // editor = new HexaDialog(); -// _dw->setWindowTitle( "HOOOOOOOOOO" ); -// _dw->setWidget(editor); -// _dw->setVisible(false); -// // editor->raise(); -// _dw->raise(); -// _dw->setVisible(true); -// cout << "BBBBBBB _dw"<< _dw<< endl; -// cout << "BBBBBBB _dw->widget()"<< _dw->widget() << endl; -// cout << "BBBBBBB isVisible"<< _dw->isVisible() << endl; -// cout << "BBBBBBB editor isVisible"<< editor->isVisible() << endl; - -// HEXA_NS::Quad *value = quadEditor->getValue(); -// model->setData(index, QVariant::fromValue( value ), HEXA_DATA_ROLE); - MESSAGE("}"); -} - - - - - -void DocumentDelegate::updateEditorGeometry( QWidget *editor, - const QStyleOptionViewItem &option, - const QModelIndex &index ) const -{ - - MESSAGE("DocumentDelegate::updateEditorGeometry(){"); - MESSAGE("* item is: " << index.data(Qt::DisplayRole).toString().toStdString()); -// cout << "CS_BP option.rect.size()"<setGeometry(option.rect); - editor->show(); -// editor->raise(); MESSAGE("}"); } - - - -void DocumentDelegate::setDocumentModel( DocumentModel* m ) -{ - _documentModel = m; -} - -void DocumentDelegate::setPatternDataSelectionModel( PatternDataSelectionModel* s ) -{ - _patternDataSelectionModel = s; -} - -void DocumentDelegate::setPatternBuilderSelectionModel( PatternBuilderSelectionModel* s ) -{ - _patternBuilderSelectionModel = s; -} - -void DocumentDelegate::setGroupsSelectionModel( GroupsSelectionModel* s ) -{ - _groupsSelectionModel = s ; -} - -void DocumentDelegate::setMeshSelectionModel( MeshSelectionModel* s ) -{ - _meshSelectionModel = s; -} - - - bool DocumentDelegate::editorEvent ( QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index ) { - MESSAGE("DocumentDelegate::editorEvent(){"); - MESSAGE("* item is: " << index.data().toString().toStdString()); - MESSAGE("* event is: " << event->type() ); - - Qt::ItemFlags flags = model->flags(index); - if ( flags == Qt::ItemFlags( ~Qt::ItemIsEditable ) ){ - MESSAGE("* you can select it "); - } else { - MESSAGE("* you cannot select it "); - } - - - -// bool r; -// if ( event->type() == 3 ){ -// r = true; -// } else { -// r = QItemDelegate::editorEvent ( event, model, option, index ); -// } -// MESSAGE("* result is: " << r ); -// MESSAGE("}"); -// return r; - - return QItemDelegate::editorEvent ( event, model, option, index ); + MESSAGE("DocumentDelegate::editorEvent(){"); + MESSAGE("* item is: " << index.data().toString().toStdString()); + MESSAGE("* event is: " << event->type() ); + + Qt::ItemFlags flags = model->flags(index); + if ( flags == Qt::ItemFlags( ~Qt::ItemIsEditable ) ){ + MESSAGE("* you can select it "); + } else { + MESSAGE("* you cannot select it "); + } + + //return QItemDelegate::editorEvent ( event, model, option, index ); + return false; } -// void DocumentDelegate::onCloseEditor( QWidget *w, QAbstractItemDelegate::EndEditHint h) -// { -// MESSAGE("DocumentDelegate::onCloseEditor(){"); -// MESSAGE("}"); -// } -// -// -// void DocumentDelegate::onCommitData ( QWidget * editor ) -// { -// MESSAGE("DocumentDelegate::onCommitData(){"); -// MESSAGE("}"); -// } - - -// connect( this, SIGNAL( commitData ( QWidget * ) ), -// this, SLOT( onCommitData ( QWidget * ) ) ); - - -// // virtual bool eventFilter ( QObject * editor, QEvent * event ) -// // { -// // // std::cout << "eventFilter eventFilter " << event->type() << std::endl; -// // // std::cout << std::endl; -// // -// // if (event->type() == QEvent::FocusOut) { -// // // QKeyEvent *keyEvent = static_cast(event); -// // // qDebug() << "Ate key press" << keyEvent->key(); -// // // return true; -// // return false; -// // } else { -// // return QItemDelegate::eventFilter ( editor, event ); -// // // return false; -// // } - - - -// void DocumentDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, -// const QModelIndex &index) const -// { -// cout << "*********************** CS_BP DocumentDelegate::setModelData BEGIN "<< editor << endl; -// QStandardItem *item = 0; -// -// // CS_TODO : simplification? -// QSortFilterProxyModel *pmodel = dynamic_cast( model ); -// if ( pmodel ){ -// QStandardItemModel *smodel = dynamic_cast( pmodel->sourceModel() ); -// if ( smodel ){ -// item = smodel->itemFromIndex(pmodel->mapToSource(index)); -// } -// } else { -// QStandardItemModel *smodel = dynamic_cast( model ); -// if ( smodel ){ -// item = smodel->itemFromIndex(index); -// } -// } -// -// -// if ( item ){ -// // cout << "item " << item->type() << endl; -// if ( item->data().isValid() ) -// cout << "*************** item " << item->data(Qt::DisplayRole).toString().toStdString() << endl; -// switch ( item->type() ){ -// case VERTEXITEM : { -// VertexDialog *vertexEditor = static_cast(editor); -// HEXA_NS::Vertex *value = vertexEditor->getValue(); -// model->setData(index, QVariant::fromValue( value ), HEXA_DATA_ROLE); -// } -// break; -// -// case EDGEITEM : { -// EdgeDialog *edgeEditor = static_cast(editor); -// HEXA_NS::Edge *value = edgeEditor->getValue(); -// model->setData(index, QVariant::fromValue( value ), HEXA_DATA_ROLE); -// } -// break; -// -// case QUADITEM : { -// QuadDialog *quadEditor = static_cast(editor); -// HEXA_NS::Quad *value = quadEditor->getValue(); -// model->setData(index, QVariant::fromValue( value ), HEXA_DATA_ROLE); -// } -// break; -// -// case HEXAITEM : { -// HexaDialog *hexaEditor = static_cast(editor); -// HEXA_NS::Hexa *value = hexaEditor->getValue(); -// model->setData(index, QVariant::fromValue( value ), HEXA_DATA_ROLE); -// } -// break; -// -// case VECTORITEM : { -// VectorDialog *vectorEditor = static_cast(editor); -// HEXA_NS::Vector *value = vectorEditor->getValue(); -// model->setData(index, QVariant::fromValue( value ), HEXA_DATA_ROLE); -// } -// break; -// -// case CYLINDERITEM : { -// CylinderDialog *cylinderEditor = static_cast(editor); -// HEXA_NS::Cylinder *value = cylinderEditor->getValue(); -// model->setData(index, QVariant::fromValue( value ), HEXA_DATA_ROLE); -// } -// break; -// case PIPEITEM : { -// PipeDialog *pipeEditor = static_cast(editor); -// HEXA_NS::Pipe *value = pipeEditor->getValue(); -// model->setData(index, QVariant::fromValue( value ), HEXA_DATA_ROLE); -// } -// break; -// // case ELEMENTSITEM : editor = new ElementsDialog(parent); break; -// // case CROSSELEMENTSITEM : editor = new CrossElementsDialog(parent); break; -// case GROUPITEM :{ -// GroupDialog *groupEditor = static_cast(editor); -// HEXA_NS::Group *value = groupEditor->getValue(); -// model->setData(index, QVariant::fromValue( value ), HEXA_DATA_ROLE); -// } -// break; -// case LAWITEM : { -// LawDialog *lawEditor = static_cast(editor); -// HEXA_NS::Law *value = lawEditor->getValue(); -// model->setData(index, QVariant::fromValue( value ), HEXA_DATA_ROLE); -// } -// break; -// case PROPAGATIONITEM : { -// PropagationDialog *propagationEditor = static_cast(editor); -// HEXA_NS::Propagation *value = propagationEditor->getValue(); -// model->setData(index, QVariant::fromValue( value ), HEXA_DATA_ROLE); -// } -// break; -// -// } -// } -// editor->show(); -// cout << "*********************** CS_BP DocumentDelegate::setModelData END "<< editor << endl; -// } \ No newline at end of file +bool DocumentDelegate::eventFilter ( QObject * editor, QEvent * event ) +{ + if ( event->type() == QEvent::FocusOut ){ + //((QWidget*) editor->parent())->close(); + return true; + } + return false; +} diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentDelegate.hxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentDelegate.hxx index f8e713c..27d4ff0 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentDelegate.hxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentDelegate.hxx @@ -34,6 +34,8 @@ #include "HEXABLOCKGUI_DocumentModel.hxx" #include "HEXABLOCKGUI_DocumentSelectionModel.hxx" +#include "HEXABLOCKGUI_DocumentItem.hxx" +#include "HEXABLOCKGUI_DocumentPanel.hxx" namespace HEXABLOCK { @@ -44,6 +46,7 @@ namespace HEXABLOCK Q_OBJECT public: + void closeDialog(); DocumentDelegate( QDockWidget *dw, QObject *parent = 0); QWidget *createEditor( QWidget *parent, @@ -54,32 +57,34 @@ namespace HEXABLOCK void setModelData( QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index ) const; + const QModelIndex &index ) const {}; - void updateEditorGeometry( QWidget *editor, + virtual void updateEditorGeometry( QWidget *editor, const QStyleOptionViewItem &option, - const QModelIndex &index ) const; + const QModelIndex &index ) const {}; - // can be used by editor - void setDocumentModel( DocumentModel* m ); + //Can be used by editor + void setDocumentModel( DocumentModel* m ){_documentModel = m;} - // selection - void setPatternDataSelectionModel( PatternDataSelectionModel* s ); - void setPatternBuilderSelectionModel( PatternBuilderSelectionModel* s ); - void setGroupsSelectionModel( /*QItemSelectionModel**/ GroupsSelectionModel* s ); - void setMeshSelectionModel( MeshSelectionModel* s ); + //Selections + void setPatternDataSelectionModel( PatternDataSelectionModel* s ){_patternDataSelectionModel = s;} + void setPatternBuilderSelectionModel( PatternBuilderSelectionModel* s ){_patternBuilderSelectionModel = s;} + void setGroupsSelectionModel( GroupsSelectionModel* s ){_groupsSelectionModel = s ;} + void setMeshSelectionModel( MeshSelectionModel* s ){_meshSelectionModel = s;} - virtual bool editorEvent ( QEvent * event, - QAbstractItemModel * model, - const QStyleOptionViewItem & option, - const QModelIndex & index ); + protected: + mutable QWidget* _currentEditor; + virtual bool editorEvent ( QEvent * event, + QAbstractItemModel * model, + const QStyleOptionViewItem & option, const QModelIndex & index ); + virtual bool eventFilter ( QObject * editor, QEvent * event ); public slots: // void onCloseEditor( QWidget *, QAbstractItemDelegate::EndEditHint); // void onCommitData ( QWidget * editor ); private: - QDockWidget *_dw; // editor's container + QDockWidget* _dw; // creator's container // can be used by editor DocumentModel* _documentModel; diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentGraphicView.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentGraphicView.cxx index 3486e03..08ae35a 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentGraphicView.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentGraphicView.cxx @@ -46,7 +46,9 @@ #include #include #include - +#include +#include +#include // test tutorial (sphere) #include #include @@ -98,7 +100,6 @@ using namespace std; using namespace HEXABLOCK::GUI; - Document_Actor::Document_Actor( HEXA_NS::Document* doc, const QString& entry ): SALOME_Actor(), _doc( doc ) @@ -326,12 +327,171 @@ Associate_Actor::Associate_Actor( HEXA_NS::Document* doc, const QString& entry) // SetPointRepresentation(true); } // ===================================================== getUnstructuredGrid + vtkUnstructuredGrid* Associate_Actor::getUnstructuredGrid() { vtkUnstructuredGrid* theGrid = vtkUnstructuredGrid::New(); _doc->reorderFaces(); //CS_TEST + std::map vtkNodeId; + std::map hexaNodeId; + + // Create points + vtkPoints* aPoints = vtkPoints::New(); + int nbVertex = _doc->countVertex(); + aPoints->SetNumberOfPoints( nbVertex ); + + HEXA_NS::Vertex* v = NULL; + int vertexId; + for ( int i=0; i getVertex(i); + aPoints->SetPoint( i, v->getX()+6, v->getY()+6, v->getZ() ); + vertexId = reinterpret_cast(v); //v->getId(); + vtkNodeId [ vertexId ] = i; + hexaNodeId[ i ] = vertexId ; +// vtkNodeId [ vertexId ] = i+1; +// hexaNodeId[ i+1 ] = vertexId ; + } + + theGrid->SetPoints( aPoints ); + aPoints->Delete(); +// theGrid->SetCells( 0, 0, 0, 0, 0 ); + + + // Calculate cells size + int nb0DElement = _doc->countVertex(); + int nbEdge = _doc->countEdge(); + int nbFace = _doc->countQuad(); + int nbVolume = _doc->countHexa(); + + vtkIdType aCellsSize = 2*nb0DElement + 3*nbEdge + ( 4 + 1 )*nbFace + ( 8 + 1 )*nbVolume; + vtkIdType aNbCells = nb0DElement + nbEdge + nbFace + nbVolume; + + // Create cells + vtkCellArray* aConnectivity = vtkCellArray::New(); + aConnectivity->Allocate( aCellsSize, 0 ); + + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); + aCellTypesArray->SetNumberOfComponents( 1 ); + aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() ); + + vtkIdList *anIdList = vtkIdList::New(); + vtkIdType iVtkElem = 0; +// vtkIdType iVtkElem = 1; //CS_TEST + int iHexaElem; + + // VERTEX + for ( int i=0; iSetNumberOfIds( 1 ); + v = _doc->getVertex(i); + iHexaElem = reinterpret_cast(v);//v->getId(); + vtkElemsId[iHexaElem] = iVtkElem; + hexaElemsId[iVtkElem] = iHexaElem; + anIdList->SetId(0, vtkNodeId[iHexaElem]); + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_VERTEX );//getCellType( aType, anElem->IsPoly(), aNbNodes ) ); + ++iVtkElem; + } + + // EDGE + HEXA_NS::Edge* e = NULL; + HEXA_NS::Vertex* vertexElem = NULL; + for ( int i=0; iSetNumberOfIds( 2 ); + e = _doc->getEdge(i); + iHexaElem = reinterpret_cast(e); //e->getId(); + vtkElemsId[iHexaElem] = iVtkElem; + hexaElemsId[iVtkElem] = iHexaElem; + + for( vtkIdType j = 0; j< 2; ++j ){ //j< e->countVertex(); ++j ){ + vertexElem = e->getVertex( j ); + anIdList->SetId( j, vtkNodeId[ reinterpret_cast(vertexElem) ] );//vertexElem->getId() ]); + } + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_LINE );//getCellType( aType, anElem->IsPoly(), aNbNodes ) ); + ++iVtkElem; + } + + // QUAD + HEXA_NS::Quad* q = NULL; + HEXA_NS::Quad* quadElem = NULL; + for ( int i=0; iSetNumberOfIds( 4 ); + q = _doc->getQuad(i); + iHexaElem = reinterpret_cast(q); //q->getId(); + vtkElemsId[iHexaElem] = iVtkElem; + hexaElemsId[iVtkElem] = iHexaElem; + + for( vtkIdType j = 0; j< 4; ++j ){ + vertexElem = q->getVertex( j ); + anIdList->SetId( j, vtkNodeId[ reinterpret_cast(vertexElem) ] );//vertexElem->getId() ]); + } + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_QUAD );//getCellType( aType, anElem->IsPoly(), aNbNodes ) ); + ++iVtkElem; + } + + // HEXA + HEXA_NS::Hexa* h = NULL; + HEXA_NS::Hexa* hexaElem = NULL; + std::map connectivity; + connectivity[0] = 0; + connectivity[1] = 1; + connectivity[2] = 3; + connectivity[3] = 2; + connectivity[4] = 4; + connectivity[5] = 5; + connectivity[6] = 7; + connectivity[7] = 6; + for ( int i=0; iSetNumberOfIds( 8 ); + h = _doc->getHexa(i); + iHexaElem = reinterpret_cast(h); //q->getId(); + vtkElemsId[iHexaElem] = iVtkElem; + hexaElemsId[iVtkElem] = iHexaElem; + + for( vtkIdType j = 0; j< 8; ++j ){ + vertexElem = h->getVertex( j );// ); + anIdList->SetId( connectivity[j], vtkNodeId[ reinterpret_cast(vertexElem) ]);//vertexElem->getId() ]); + } + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_HEXAHEDRON ); + ++iVtkElem; + } + + +// 0 1 2 3 4 5 6 7 +// V_ACE, V_ACF, V_ADE, V_ADF, V_BCE, V_BCF, V_BDE, V_BDF, +// +// 0 1 3 2 4 5 7 6 + + // Insert cells in grid + VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New(); + aCellLocationsArray->SetNumberOfComponents( 1 ); + aCellLocationsArray->SetNumberOfTuples( aNbCells ); +// std::cout << "aNbCells =>" << aNbCells << std::endl; + + aConnectivity->InitTraversal(); + for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ){ + aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); + } + theGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity ); + + aCellLocationsArray->Delete(); + aCellTypesArray->Delete(); + aConnectivity->Delete(); + anIdList->Delete(); + //std::cout << "theGrid->GetNumberOfCells()" << theGrid->GetNumberOfCells() << std::endl; + + return theGrid; +} +/* +{ + vtkUnstructuredGrid* theGrid = vtkUnstructuredGrid::New(); + + _doc->reorderFaces(); //CS_TEST + std::map vtkNodeId; std::map hexaNodeId; @@ -355,7 +515,7 @@ vtkUnstructuredGrid* Associate_Actor::getUnstructuredGrid() int vertexId; for ( int i=0; i getVertex(i); - aPoints->SetPoint( i, v->getX(), v->getY(), v->getZ() ); + aPoints->SetPoint( i, v->getX() + 1, v->getY() + 1, v->getZ() ); vertexId = reinterpret_cast(v); //v->getId(); vtkNodeId [ vertexId ] = i; hexaNodeId[ i ] = vertexId ; @@ -388,8 +548,8 @@ vtkUnstructuredGrid* Associate_Actor::getUnstructuredGrid() // VERTEX for ( int i=0; iSetNumberOfIds( 1 ); - // v = _doc->getVertex(i); // Abu - v = tab_vertex [i]; + v = _doc->getVertex(i); // Abu + // v = tab_vertex [i]; iHexaElem = reinterpret_cast(v);//v->getId(); vtkElemsId[iHexaElem] = iVtkElem; hexaElemsId[iVtkElem] = iHexaElem; @@ -445,6 +605,7 @@ vtkUnstructuredGrid* Associate_Actor::getUnstructuredGrid() return theGrid; } +*/ // =============================================================== Abu : Fin @@ -454,7 +615,8 @@ DocumentGraphicView::DocumentGraphicView( LightApp_Application* app, SUIT_ViewWi _suitView( suitView ), _documentActor( 0 ), _associateActor (NULL), // Abu - _currentChanged( false ) + _currentChanged( false ), + firstUpdate(true) { // MESSAGE("DocumentGraphicView::DocumentGraphicView() app"<AddActor( _documentActor ); + QString autreDocentry = "essai"; // -------------------- Abu debut if (HEXA_NS::special_option()) { @@ -510,15 +673,30 @@ void DocumentGraphicView::update() theVTKViewWindow->RemoveActor( _associateActor ); _associateActor->Delete(); } - _associateActor = new Associate_Actor( theDocumentImpl, theDocumentEntry ); + // _associateActor = new Associate_Actor( theDocumentImpl, theDocumentEntry ); + _associateActor = new Associate_Actor( theDocumentImpl, autreDocentry ); theVTKViewWindow->AddActor( _associateActor ); } // -------------------- Abu fin // display HEXABLOCK document model +// vtkSmartPointer style = vtkSmartPointer::New(); +// theVTKViewWindow->GetInteractor()->PushInteractorStyle(style); +// style->SetCurrentRenderer(theVTKViewWindow->getRenderer()); + +// theVTKViewWindow->SetInteractionStyle(0); +// theVTKViewWindow->SetDynamicPreSelection (true); theVTKViewWindow->getRenderer()->Render(); theVTKViewWindow->Repaint(); - theVTKViewWindow->onFitAll(); + if (firstUpdate) + { + theVTKViewWindow->onFitAll(); + firstUpdate = false; + } +// theVTKViewWindow->GetInteractorStyle()->HighlightProp(_documentActor); +// theVTKViewWindow->getView()->SetPreselectionProp(0., 1., 0., 2.); +// theVTKViewWindow->getView()->SetTransparency(_documentActor->getIO(), 0.2); + // myVTKViewWindow->SetSelectionMode( ActorSelection ); // theVTKViewWindow->SetSelectionMode( NodeSelection ); // myVTKViewWindow->SetSelectionMode( FaceSelection ); diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentGraphicView.hxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentGraphicView.hxx index 9e2bd3d..b0e648d 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentGraphicView.hxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentGraphicView.hxx @@ -26,13 +26,7 @@ // #include #include #include - - - - - - - +#include #include #include @@ -45,7 +39,9 @@ #include #include #include - +#include +#include +#include // class LightApp_Displayer; // class SalomeApp_Application; @@ -68,6 +64,21 @@ namespace HEXABLOCK namespace GUI { + class hexablockInteractorStyle : public SVTK_InteractorStyle + { + public: + hexablockInteractorStyle() {}; + virtual ~hexablockInteractorStyle() {}; + + public: + static hexablockInteractorStyle* New() + { + return new hexablockInteractorStyle; + }; + virtual void HighlightActor2D(vtkActor2D* actor2D) {std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HIGHLIGHT PROP 2D%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << std::endl;}; + virtual void HighlightProp(vtkProp* prop) {std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HIGHLIGHT PROP %%%%%%%%%%%%%%%%%%%%%%%%%%%%" << std::endl;}; + virtual void HighlightProp3D(vtkProp3D* prop3D) {std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HIGHLIGHT PROP 3D%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << std::endl;}; + }; class Document_Actor : public SALOME_Actor { @@ -162,6 +173,7 @@ namespace HEXABLOCK Document_Actor *_documentActor; Associate_Actor *_associateActor; bool _currentChanged; + bool firstUpdate; }; } } diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentItem.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentItem.cxx index 7016d47..4b616ff 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentItem.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentItem.cxx @@ -17,431 +17,181 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - #include "HEXABLOCKGUI_DocumentItem.hxx" #include "HexShape.hxx" #include -/* -#include */ - - -//#define _DEVDEBUG_ - - using namespace std; using namespace HEXABLOCK::GUI; - -// ----------------------- VERTEX - -VertexItem::VertexItem( HEXA_NS::Vertex* hexaVertex ): - QStandardItem(), - _hexaVertex( hexaVertex ) -{ -// char pName[12]; - QString name = _hexaVertex->getName(/*pName*/); -// QString docEntry = model()->invisibleRootItem()->data(HEXA_ENTRY_ROLE).toString(); - setText(name); -// setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );//Qt::ItemIsEditable); - setData( VERTEX_TREE, HEXA_TREE_ROLE ); - setData( QString::number( reinterpret_cast(_hexaVertex) ), HEXA_ENTRY_ROLE ); //_hexaVertex->dad() - - HEXA_NS::Shape* assoc = hexaVertex->getAssociation(); - if ( assoc ){ - QString entry = QString(assoc->ident.c_str()); - setData( entry + ";" , HEXA_ASSOC_ENTRY_ROLE ); - } -} - -int VertexItem::type() const -{ - return VERTEXITEM; -} - - - -QVariant VertexItem::data( int role ) const -{ - if ( role == HEXA_DATA_ROLE ){ - return QVariant::fromValue( _hexaVertex ); - } else if (role == Qt::ForegroundRole ) { - HEXA_NS::Shape* assoc = _hexaVertex->getAssociation(); - if ( assoc ) - return QColor(Qt::darkGreen); - else - return QColor(Qt::black); - } else { - return QStandardItem::data( role ); +// ElementItem -------------------------------------------------- +ElementItem::ElementItem( HEXA_NS::EltBase* docElement, QString entry, HexaType ttype, HexaTreeRole treeRole): +QStandardItem() +{ + m_DocElt = docElement; + m_type = ttype; + + if (m_DocElt != NULL) + setText(m_DocElt->getName()); + setData( treeRole, HEXA_TREE_ROLE ); + setData( entry, HEXA_DOC_ENTRY_ROLE); + setData( IDptr(), HEXA_ENTRY_ROLE ); + + //Init assocs entry + if (m_DocElt!=NULL && m_DocElt->isAssociated()) + { + QString entry; + if (m_type == VERTEXITEM) //Vertex + { + HEXA_NS::Shape* assoc = m_DocElt->getAssociation(); + if ( assoc ){ + entry = QString(assoc->ident.c_str()); + setData( entry + ";" , HEXA_ASSOC_ENTRY_ROLE ); + } + } + else if (m_type == EDGEITEM) + { + QString entries; + const HEXA_NS::Shapes& assocs = ((HEXA_NS::Edge*)m_DocElt)->getAssociations(); + for( HEXA_NS::Shapes::const_iterator anAssoc = assocs.begin(); anAssoc != assocs.end(); ++anAssoc ){ + entry = (*anAssoc)->ident.c_str(); + entries += entry + ";"; + } + if ( !entries.isEmpty() ) + setData( entries, HEXA_ASSOC_ENTRY_ROLE ); + } + else if (m_type == QUADITEM) + { + QString entries; + const HEXA_NS::Shapes& assocs = ((HEXA_NS::Quad*)m_DocElt)->getAssociations(); + for( HEXA_NS::Shapes::const_iterator anAssoc = assocs.begin(); anAssoc != assocs.end(); ++anAssoc ){ + entry = (*anAssoc)->ident.c_str(); + entries += entry + ";"; + } + if ( !entries.isEmpty() ) + setData( entries, HEXA_ASSOC_ENTRY_ROLE ); + } } } -void VertexItem::setData ( const QVariant & value, int role ) -{ - if ( role == HEXA_DATA_ROLE ){ - _hexaVertex = value.value(); - emitDataChanged (); - } else { -// std::cout << " VertexItem::setData( " << role << ", "<< value.toString().toStdString() << " )" <getName(pName); - QString name = _hexaEdge->getName(); -// std::cout << "EdgeItem name : "<< name.toStdString() << std::endl; - setText(name); - setData( EDGE_TREE, HEXA_TREE_ROLE ); - setData( QString::number( reinterpret_cast(_hexaEdge) ), HEXA_ENTRY_ROLE ); - - QString entries, entry; - const HEXA_NS::Shapes& assocs = hexaEdge->getAssociations(); - for( HEXA_NS::Shapes::const_iterator anAssoc = assocs.begin(); anAssoc != assocs.end(); ++anAssoc ){ - entry = (*anAssoc)->ident.c_str(); - entries += entry + ";"; - } - if ( !entries.isEmpty() ) - setData( entries, HEXA_ASSOC_ENTRY_ROLE ); -} - - -int EdgeItem::type() const -{ - return EDGEITEM; -} +//ElementItem::ElementItem( HEXA_NS::EltBase* docElement, HexaType ttype, HexaTreeRole treeRole): +//QStandardItem() +//{ +// m_DocElt = docElement; +// m_type = ttype; +// +// if (m_DocElt != NULL) +// setText(m_DocElt->getName()); +// setData( treeRole, HEXA_TREE_ROLE ); +// setData( IDptr(), HEXA_ENTRY_ROLE ); +// +//// if (m_DocElt->isAssociated()) +//// setData( "Y" , HEXA_ASSOC_ENTRY_ROLE ); +//} -QVariant EdgeItem::data( int role ) const +//--------------------------------------------------------------- +QVariant ElementItem::data( int role ) const { if ( role == HEXA_DATA_ROLE ){ - return QVariant::fromValue( _hexaEdge ); - } else if (role == Qt::ForegroundRole ) { - const HEXA_NS::Shapes& assocs = _hexaEdge->getAssociations(); - if ( assocs.size()>0 ) - return QColor(Qt::darkGreen); - else - return QColor(Qt::black); - } else { - return QStandardItem::data( role ); + switch(m_type) + { + case VERTEXITEM: return QVariant::fromValue( (HEXA_NS::Vertex*)m_DocElt ); + case EDGEITEM: return QVariant::fromValue( (HEXA_NS::Edge*)m_DocElt ); + case QUADITEM: return QVariant::fromValue( (HEXA_NS::Quad*)m_DocElt ); + case HEXAITEM: return QVariant::fromValue( (HEXA_NS::Hexa*)m_DocElt ); + case VECTORITEM: return QVariant::fromValue( (HEXA_NS::Vector*)m_DocElt ); + case CYLINDERITEM: return QVariant::fromValue( (HEXA_NS::Cylinder*)m_DocElt ); + case PIPEITEM: return QVariant::fromValue( (HEXA_NS::Pipe*)m_DocElt ); + case ELEMENTSITEM: return QVariant::fromValue( (HEXA_NS::Elements*)m_DocElt ); + case CROSSELEMENTSITEM: return QVariant::fromValue( (HEXA_NS::CrossElements*)m_DocElt ); + default: return QVariant::fromValue( m_DocElt ); + } } -} -void EdgeItem::setData ( const QVariant & value, int role ) -{ - if ( role == HEXA_DATA_ROLE ){ - _hexaEdge = value.value(); - emitDataChanged (); - } else { - QStandardItem::setData ( value, role ); - } -} - - - - -// ----------------------- QUAD -QuadItem::QuadItem( HEXA_NS::Quad* hexaQuad ): - QStandardItem(), - _hexaQuad( hexaQuad ) -{ -// char pName[12]; - QString name = _hexaQuad->getName(/*pName*/); - setText(name); - setData( QUAD_TREE, HEXA_TREE_ROLE ); - setData( QString::number(reinterpret_cast(_hexaQuad)), HEXA_ENTRY_ROLE ); - - QString entries, entry; - const HEXA_NS::Shapes& assocs = hexaQuad->getAssociations(); - for( HEXA_NS::Shapes::const_iterator anAssoc = assocs.begin(); anAssoc != assocs.end(); ++anAssoc ){ - entry = (*anAssoc)->ident.c_str(); - entries += entry + ";"; - } - if ( !entries.isEmpty() ) - setData( entries, HEXA_ASSOC_ENTRY_ROLE ); -} - - -int QuadItem::type() const -{ - return QUADITEM; -} - -QVariant QuadItem::data( int role ) const -{ - if ( role == HEXA_DATA_ROLE ){ - return QVariant::fromValue( _hexaQuad ); - } else if ( role == Qt::ForegroundRole ) { - const HEXA_NS::Shapes& assocs = _hexaQuad->getAssociations(); - if ( assocs.size()>0 ) + if (role == Qt::ForegroundRole ) { + if ( m_DocElt->isAssociated() ) return QColor(Qt::darkGreen); else return QColor(Qt::black); - } else { - return QStandardItem::data( role ); } + return QStandardItem::data( role ); } -void QuadItem::setData ( const QVariant & value, int role ) -{ - if ( role == HEXA_DATA_ROLE ){ - _hexaQuad = value.value(); - emitDataChanged (); - } else { - QStandardItem::setData ( value, role ); - } -} - - - - - -// ----------------------- HEXA - -HexaItem::HexaItem( HEXA_NS::Hexa* hexaHexa ): - QStandardItem(), - _hexaHexa( hexaHexa ) -{ -// char pName[12]; - QString name = _hexaHexa->getName(/*pName*/); - setText(name); - setData( HEXA_TREE, HEXA_TREE_ROLE ); - setData( QString::number( reinterpret_cast(_hexaHexa)), HEXA_ENTRY_ROLE ); -} - - -int HexaItem::type() const -{ - return HEXAITEM; -} - -QVariant HexaItem::data( int role ) const +//--------------------------------------------------------------- +void ElementItem::setData ( const QVariant& valcont, int role ) { if ( role == HEXA_DATA_ROLE ){ - return QVariant::fromValue( _hexaHexa ); - } - else if ( role == Qt::ForegroundRole ) { - return QColor(Qt::black); - } - else { - return QStandardItem::data( role ); - } -} - -void HexaItem::setData ( const QVariant & value, int role ) -{ - if ( role == HEXA_DATA_ROLE ){ - _hexaHexa = value.value(); - emitDataChanged (); - } else { - QStandardItem::setData ( value, role ); - } -} + m_DocElt = valcont.value(); + emitDataChanged (); - - - - -// ----------------------- VECTOR -VectorItem::VectorItem( HEXA_NS::Vector* hexaVector ): - QStandardItem(), - _hexaVector( hexaVector ) -{ -// char pName[12]; - QString name = _hexaVector->getName(/*pName*/); - setText(name); - setData( VECTOR_TREE, HEXA_TREE_ROLE ); - setData( QString::number(reinterpret_cast(_hexaVector)), HEXA_ENTRY_ROLE ); -} - -int VectorItem::type() const -{ - return VECTORITEM; -} - -QVariant VectorItem::data( int role ) const -{ - if ( role == HEXA_DATA_ROLE ){ - return QVariant::fromValue( _hexaVector ); - } else { - return QStandardItem::data( role ); - } -} - -void VectorItem::setData ( const QVariant & value, int role ) -{ - if ( role == HEXA_DATA_ROLE ){ - _hexaVector = value.value(); - emitDataChanged (); - } else { - QStandardItem::setData ( value, role ); - } -} - - - - -// ----------------------- CYLINDER -CylinderItem::CylinderItem( HEXA_NS::Cylinder* hexaCylinder): - QStandardItem(), - _hexaCylinder( hexaCylinder ) -{ -// char pName[12]; - QString name = _hexaCylinder->getName(/*pName*/); - setText(name); - setData( CYLINDER_TREE, HEXA_TREE_ROLE ); - setData( QString::number(reinterpret_cast(_hexaCylinder)), HEXA_ENTRY_ROLE ); -} - -int CylinderItem::type() const -{ - return CYLINDERITEM; -} - -QVariant CylinderItem::data( int role ) const -{ - if ( role == HEXA_DATA_ROLE ){ - return QVariant::fromValue( _hexaCylinder ); - } else { - return QStandardItem::data( role ); - } -} - -void CylinderItem::setData ( const QVariant & value, int role ) -{ - if ( role == HEXA_DATA_ROLE ){ - _hexaCylinder = value.value(); - emitDataChanged (); - } else { - QStandardItem::setData ( value, role ); - } + } else { + QStandardItem::setData ( valcont, role ); + } } +//--------------------------------------------------------------- +int ElementItem::type () const {return m_type;} +//--------------------------------------------------------------- +bool ElementItem::isAssoc () const {return m_DocElt->isAssociated();} +//--------------------------------------------------------------- +QString ElementItem::IDptr() const { return QString::number( reinterpret_cast(m_DocElt) ); } - - -// ----------------------- PIPE -PipeItem::PipeItem( HEXA_NS::Pipe* hexaPipe ): - QStandardItem(), - _hexaPipe( hexaPipe ) +// ----------------------- VERTEX (DATA) +VertexItem::VertexItem( HEXA_NS::Vertex* hexaVertex, QString entry): + GraphicElementItem(hexaVertex, entry, VERTEXITEM, VERTEX_TREE) { -// char pName[12]; - QString name = _hexaPipe->getName(/*pName*/); - setText(name); - setData( PIPE_TREE, HEXA_TREE_ROLE ); - setData( QString::number(reinterpret_cast(_hexaPipe)), HEXA_ENTRY_ROLE ); } -int PipeItem::type() const +// ----------------------- EDGE (DATA) +EdgeItem::EdgeItem( HEXA_NS::Edge* hexaEdge, QString entry ): + GraphicElementItem(hexaEdge, entry, EDGEITEM, EDGE_TREE) { - return PIPEITEM; -} - -QVariant PipeItem::data( int role ) const -{ - if ( role == HEXA_DATA_ROLE ){ - return QVariant::fromValue( _hexaPipe ); - } else { - return QStandardItem::data( role ); - } } -void PipeItem::setData ( const QVariant & value, int role ) +// ----------------------- QUAD (DATA) +QuadItem::QuadItem( HEXA_NS::Quad* hexaQuad, QString entry): + GraphicElementItem(hexaQuad, entry, QUADITEM, QUAD_TREE) { - if ( role == HEXA_DATA_ROLE ){ - _hexaPipe = value.value(); - emitDataChanged (); - } else { - QStandardItem::setData ( value, role ); - } } - - -// ----------------------- ELEMENTS -ElementsItem::ElementsItem( HEXA_NS::Elements* hexaElements ): - QStandardItem(), - _hexaElements( hexaElements ) +// ----------------------- HEXA (DATA) +HexaItem::HexaItem( HEXA_NS::Hexa* hexaHexa , QString entry): + GraphicElementItem(hexaHexa,entry, HEXAITEM, HEXA_TREE) { -// char pName[12]; - QString name = _hexaElements->getName(/*pName*/); - setText(name); - setData( ELEMENTS_TREE, HEXA_TREE_ROLE ); - setData( QString::number(reinterpret_cast(_hexaElements)), HEXA_ENTRY_ROLE ); } -int ElementsItem::type() const +// ----------------------- VECTOR (BUILDER) +VectorItem::VectorItem( HEXA_NS::Vector* hexaVector, QString entry ): + StandardElementItem(hexaVector, entry, VECTORITEM, VECTOR_TREE) { - return ELEMENTSITEM; } -QVariant ElementsItem::data( int role ) const -{ - if ( role == HEXA_DATA_ROLE ){ - return QVariant::fromValue( _hexaElements ); - } else { - return QStandardItem::data( role ); - } -} - -void ElementsItem::setData ( const QVariant & value, int role ) +// ----------------------- CYLINDER (BUILDER) +CylinderItem::CylinderItem( HEXA_NS::Cylinder* hexaCylinder, QString entry): + StandardElementItem(hexaCylinder, entry, CYLINDERITEM, CYLINDER_TREE) { - if ( role == HEXA_DATA_ROLE ){ - _hexaElements = value.value(); - emitDataChanged (); - } else { - QStandardItem::setData ( value, role ); - } } - - -// ----------------------- CROSSELEMENTS -CrossElementsItem::CrossElementsItem( HEXA_NS::CrossElements* hexaCrossElts ): - QStandardItem(), - _hexaCrossElts( hexaCrossElts ) +// ----------------------- PIPE (BUILDER) +PipeItem::PipeItem( HEXA_NS::Pipe* hexaPipe, QString entry ): + StandardElementItem(hexaPipe, entry, PIPEITEM, PIPE_TREE) { -// char pName[12]; - QString name = _hexaCrossElts->getName(/*pName*/); - setText(name); - setData( CROSSELEMENTS_TREE, HEXA_TREE_ROLE ); - setData( QString::number(reinterpret_cast(_hexaCrossElts)), HEXA_ENTRY_ROLE ); } -int CrossElementsItem::type() const +// ----------------------- ELEMENTS (NOT USED) +ElementsItem::ElementsItem( HEXA_NS::Elements* hexaElements, QString entry ): + StandardElementItem(hexaElements, entry, ELEMENTSITEM, ELEMENTS_TREE) { - return CROSSELEMENTSITEM; } -QVariant CrossElementsItem::data( int role ) const -{ - if ( role == HEXA_DATA_ROLE ){ - return QVariant::fromValue( _hexaCrossElts ); - } else { - return QStandardItem::data( role ); - } -} - -void CrossElementsItem::setData ( const QVariant & value, int role ) +// ----------------------- CROSSELEMENTS (NOT USED) +CrossElementsItem::CrossElementsItem( HEXA_NS::CrossElements* hexaCrossElts, QString entry ): + StandardElementItem(hexaCrossElts, entry, CROSSELEMENTSITEM, CROSSELEMENTS_TREE) { - if ( role == HEXA_DATA_ROLE ){ - _hexaCrossElts = value.value(); - emitDataChanged (); - } else { - QStandardItem::setData ( value, role ); - } } - - // ----------------------- GROUP GroupItem::GroupItem( HEXA_NS::Group* hexaGroup ): QStandardItem(), @@ -459,8 +209,8 @@ int GroupItem::type() const return GROUPITEM; } -QVariant GroupItem::data( int role ) const -{ +QVariant GroupItem::data( int role ) const +{ if ( role == HEXA_DATA_ROLE ){ return QVariant::fromValue( _hexaGroup ); } else { @@ -497,8 +247,8 @@ int LawItem::type() const return LAWITEM; } -QVariant LawItem::data( int role ) const -{ +QVariant LawItem::data( int role ) const +{ if ( role == HEXA_DATA_ROLE ){ return QVariant::fromValue( _hexaLaw); } else { @@ -536,8 +286,8 @@ int PropagationItem::type() const return PROPAGATIONITEM; } -QVariant PropagationItem::data( int role ) const -{ +QVariant PropagationItem::data( int role ) const +{ if ( role == HEXA_DATA_ROLE ){ return QVariant::fromValue( _hexaPropagation ); } else { @@ -554,3 +304,6 @@ void PropagationItem::setData ( const QVariant & value, int role ) QStandardItem::setData ( value, role ); } } +//------------------------------------------------- + + diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentItem.hxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentItem.hxx index b5a16aa..8813de2 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentItem.hxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentItem.hxx @@ -41,6 +41,7 @@ #include #include +#include "vtkActor.h" Q_DECLARE_METATYPE( HEXA_NS::EltBase* ); @@ -67,7 +68,7 @@ namespace HEXABLOCK { namespace GUI { - enum { + enum HexaType { VERTEXITEM = QStandardItem::UserType + 1, EDGEITEM, QUADITEM, @@ -82,7 +83,6 @@ namespace HEXABLOCK GROUPITEM, LAWITEM, PROPAGATIONITEM, - }; enum HexaTreeRole { @@ -129,195 +129,146 @@ namespace HEXABLOCK // QVariant::UserType - class VertexItem : public QStandardItem + //=================================================================================== + class ElementItem : public QStandardItem { public: - VertexItem( HEXA_NS::Vertex* hexaVertex ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) + ElementItem( HEXA_NS::EltBase* docElement, QString entry, HexaType ttype, HexaTreeRole treeRole); + ElementItem( HEXA_NS::EltBase* docElement, HexaType ttype, HexaTreeRole treeRole); + virtual QVariant data( int role ) const; + virtual void setData ( const QVariant& valcont, int role ); + int type () const; + virtual bool isAssoc() const; + virtual QString IDptr() const; + private: - HEXA_NS::Vertex* _hexaVertex; + int m_type; + HEXA_NS::EltBase* m_DocElt; // Vertex and so. }; + //=================================================================================== - class EdgeItem : public QStandardItem + class GraphicElementItem : public ElementItem { public: - EdgeItem( HEXA_NS::Edge* hexaEdge ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) + GraphicElementItem( HEXA_NS::EltBase* docElement, QString entry, HexaType ttype, HexaTreeRole treeRole): + ElementItem( docElement, entry, ttype, treeRole) + { + } + private: - HEXA_NS::Edge* _hexaEdge; + vtkActor* actor; + int IDinActor; }; - class QuadItem : public QStandardItem + class StandardElementItem : public ElementItem { - public: - QuadItem( HEXA_NS::Quad* hexaQuad ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) - private: - HEXA_NS::Quad* _hexaQuad; + public: + StandardElementItem( HEXA_NS::EltBase* docElement, QString entry, HexaType ttype, HexaTreeRole treeRole): + ElementItem( docElement, entry, ttype, treeRole) + { + } }; - - class HexaItem : public QStandardItem + class VertexItem : public GraphicElementItem { public: - HexaItem( HEXA_NS::Hexa* hexaHexa ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) - private: - HEXA_NS::Hexa* _hexaHexa; + VertexItem( HEXA_NS::Vertex* hexaVertex, QString entry="" ); }; - - class VectorItem : public QStandardItem + class EdgeItem : public GraphicElementItem { public: - VectorItem( HEXA_NS::Vector* hexaVector ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) - private: - HEXA_NS::Vector* _hexaVector; + EdgeItem( HEXA_NS::Edge* hexaEdge, QString entry="" ); }; - - - class CylinderItem : public QStandardItem + //----------------------------------------- + class QuadItem : public GraphicElementItem { public: - CylinderItem( HEXA_NS::Cylinder* hexaCyl ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) - private: - HEXA_NS::Cylinder* _hexaCylinder; + QuadItem( HEXA_NS::Quad* hexaQuad, QString entry="" ); }; + //----------------------------------------- + class HexaItem : public GraphicElementItem + { + public: + HexaItem( HEXA_NS::Hexa* hexaHexa, QString entry="" ); + }; + //----------------------------------------- - class PipeItem : public QStandardItem + class VectorItem : public StandardElementItem { public: - PipeItem( HEXA_NS::Pipe* hexaPipe ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) - private: - HEXA_NS::Pipe* _hexaPipe; + VectorItem( HEXA_NS::Vector* hexaVector, QString entry="" ); }; + //----------------------------------------- + class CylinderItem : public StandardElementItem + { + public: + CylinderItem( HEXA_NS::Cylinder* hexaCyl, QString entry="" ); + }; + //----------------------------------------- - class ElementsItem : public QStandardItem + class PipeItem : public StandardElementItem { public: - ElementsItem( HEXA_NS::Elements* hexaElements ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) - private: - HEXA_NS::Elements* _hexaElements; + PipeItem( HEXA_NS::Pipe* hexaPipe, QString entry="" ); }; + //----------------------------------------- - class CrossElementsItem : public QStandardItem + class ElementsItem : public StandardElementItem { public: - CrossElementsItem( HEXA_NS::CrossElements* hexaCrossElts ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) - private: - HEXA_NS::CrossElements* _hexaCrossElts; + ElementsItem( HEXA_NS::Elements* hexaElements, QString entry="" ); + }; + //----------------------------------------- + class CrossElementsItem : public StandardElementItem + { + public: + CrossElementsItem( HEXA_NS::CrossElements* hexaCrossElts, QString entry="" ); }; - + //----------------------------------------- class GroupItem : public QStandardItem { - public: - GroupItem( HEXA_NS::Group* hexaGroup ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) - private: - HEXA_NS::Group* _hexaGroup; + public: + GroupItem( HEXA_NS::Group* hexaGroup ); + virtual int type () const; + virtual QVariant data ( int role ) const; + virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) + private: + HEXA_NS::Group* _hexaGroup; }; class LawItem : public QStandardItem { - public: - LawItem( HEXA_NS::Law* hexaLaw ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) - private: - HEXA_NS::Law* _hexaLaw; + public: + LawItem( HEXA_NS::Law* hexaLaw ); + virtual int type () const; + virtual QVariant data ( int role ) const; + virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) + private: + HEXA_NS::Law* _hexaLaw; }; class PropagationItem : public QStandardItem { - public: - PropagationItem( HEXA_NS::Propagation* hexaPropagation ); - virtual int type () const; - virtual QVariant data ( int role ) const; - virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) - private: - HEXA_NS::Propagation* _hexaPropagation; + public: + PropagationItem( HEXA_NS::Propagation* hexaPropagation ); + virtual int type () const; + virtual QVariant data ( int role ) const; + virtual void setData ( const QVariant & value, int role ); //= Qt::UserRole + 1 ) + private: + HEXA_NS::Propagation* _hexaPropagation; }; + //------------------------------------------------- } } #endif - - - - - -// The QStandardItem class provides an item for use with the QStandardItemModel class. -// -// Items usually contain text, icons, or checkboxes. -// -// Each item can have its own background brush which is set with the setBackground() function. The current background brush can be found with background(). The text label for each item can be rendered with its own font and brush. These are specified with the setFont() and setForeground() functions, and read with font() and foreground(). -// -// By default, items are enabled, editable, selectable, checkable, and can be used both as the source of a drag and drop operation and as a drop target. Each item's flags can be changed by calling setFlags(). Checkable items can be checked and unchecked with the setCheckState() function. The corresponding checkState() function indicates whether the item is currently checked. -// -// You can store application-specific data in an item by calling setData(). -// -// Each item can have a two-dimensional table of child items. This makes it possible to build hierarchies of items. The typical hierarchy is the tree, in which case the child table is a table with a single column (a list). -// -// The dimensions of the child table can be set with setRowCount() and setColumnCount(). Items can be positioned in the child table with setChild(). Get a pointer to a child item with child(). New rows and columns of children can also be inserted with insertRow() and insertColumn(), or appended with appendRow() and appendColumn(). When using the append and insert functions, the dimensions of the child table will grow as needed. -// -// An existing row of children can be removed with removeRow() or takeRow(); correspondingly, a column can be removed with removeColumn() or takeColumn(). -// -// An item's children can be sorted by calling sortChildren(). - - -// Subclassing -// -// When subclassing QStandardItem to provide custom items, it is possible to define new types for them so that they can be distinguished from the base class. The type() function should be reimplemented to return a new type value equal to or greater than UserType. -// -// Reimplement data() and setData() if you want to perform custom handling of data queries and/or control how an item's data is represented. -// -// Reimplement clone() if you want QStandardItemModel to be able to create instances of your custom item class on demand (see QStandardItemModel::setItemPrototype()). -// -// Reimplement read() and write() if you want to control how items are represented in their serialized form. -// -// Reimplement operator<() if you want to control the semantics of item comparison. operator<() determines the sorted order when sorting items with sortChildren() or with QStandardItemModel::sort(). - -// QStandardItemModel model; -// QStandardItem *parentItem = model.invisibleRootItem(); -// for (int i = 0; i < 4; ++i) { -// QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); -// parentItem->appendRow(item); -// parentItem = item; -// } - -// QStandardItem *item = myStandardItemModel->itemFromIndex(index); diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.cxx index 1f1d0d7..3cad03d 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.cxx @@ -19,7 +19,6 @@ //CS_TODO: relever les fonctions qui nécessitent updateData(). // addGroupElement à tester - #include #include @@ -34,11 +33,15 @@ #include "HexVertex.hxx" #include "HexShape.hxx" +#include +#include "HEXABLOCKGUI_SalomeTools.hxx" + #include //#define _DEVDEBUG_ using namespace std; +//using namespace HEXA_NS; using namespace HEXABLOCK::GUI; /***************************************************************** @@ -139,17 +142,68 @@ QString DocumentModel::getName() return _hexaDocument->getName(); } +HEXA_NS::EltBase* DocumentModel::getHexaPtr(const QModelIndex& iElt) +{ + HEXA_NS::EltBase *elt = NULL; + switch ( /*data(iElt, HEXA_TREE_ROLE).toInt()*/iElt.data(HEXA_TREE_ROLE).toInt() ){ + case VERTEX_TREE : elt = getHexaPtr(iElt); break; + case EDGE_TREE : elt = getHexaPtr(iElt); break; + case QUAD_TREE : elt = getHexaPtr(iElt); break; + case HEXA_TREE : elt = getHexaPtr(iElt); break; + case VECTOR_TREE : elt = getHexaPtr(iElt); break; + case CYLINDER_TREE : elt = getHexaPtr(iElt); break; + case PIPE_TREE : elt = getHexaPtr(iElt); break; + case ELEMENTS_TREE : elt = getHexaPtr(iElt); break; + case CROSSELEMENTS_TREE : elt = getHexaPtr(iElt); break; + } + return elt; +} + +DocumentModel::GeomObj* DocumentModel::convertToGeomObj(GEOM::GeomObjPtr geomObjPtr) +{ + TopoDS_Shape aShape; + DocumentModel::GeomObj *res = NULL; + + if ( geomObjPtr && GEOMBase::GetShape(geomObjPtr.get(), aShape) && !aShape.IsNull() ) + { + res = new DocumentModel::GeomObj; + if (res == NULL) return NULL; + QString mainShapeEntry; + int subId = -1; + QString brep; + + if ( geomObjPtr->IsMainShape() ){ + mainShapeEntry = geomObjPtr->GetStudyEntry(); + brep = shape2string( aShape ).c_str(); + } else { + TopoDS_Shape shape; + TopoDS_Shape subshape; + GEOM::GEOM_Object_var mainShape = geomObjPtr->GetMainShape(); + mainShapeEntry = mainShape->GetStudyEntry(); + // CS_TODO : à optimiser + bool okShape = GEOMBase::GetShape( mainShape , shape);//,const TopAbs_ShapeEnum type = TopAbs_SHAPE ); + bool oksubShape = GEOMBase::GetShape( geomObjPtr.get(), subshape );//,const TopAbs_ShapeEnum type = TopAbs_SHAPE ); + if ( okShape && oksubShape ){ + brep = shape2string( subshape ).c_str(); + subId = GEOMBase::GetIndex( subshape, shape ); + } + } + res->name = GEOMBase::GetName( geomObjPtr.get() ); + res->entry = mainShapeEntry; + res->subid = QString::number(subId); + res->brep = brep; + res->start = 0.; + res->end = 1.; + } + + return res; +} + + void DocumentModel::load( const QString& xmlFileName ) // Fill Data { MESSAGE("HEXABLOCKGUI::load() => "<setFile( tmp.toLocal8Bit().constData() ); - // _hexaDocument->loadXml(); - //std::cout << "AAAAAAAAAA name ->" << _hexaDocument->getName() << std::endl; - // _hexaDocument->loadXml(tmp.toLocal8Bit().constData() ); _hexaDocument->loadXml(xmlFileName.toLocal8Bit().constData() ); - //std::cout << "BBBBBBBBB name ->" << _hexaDocument->getName() << std::endl; - //std::cout << "DocumentModel::load ->" << tmp.toStdString() << std::endl; clearAll(); fillData(); @@ -158,9 +212,6 @@ void DocumentModel::load( const QString& xmlFileName ) // Fill Data fillGroups(); fillMesh(); -// tmp = "/tmp/load.vtk"; -// //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); - emit patternDataChanged(); // BUILDER, ASSOCIATION, GROUPS, ... CS_TODO _fillBuilderFrom( _hexaDocument ); @@ -169,27 +220,16 @@ void DocumentModel::load( const QString& xmlFileName ) // Fill Data void DocumentModel::save( const QString& xmlFileName ) { MESSAGE("HEXABLOCKGUI::save() => "<" << xmlFileName.toStdString() << std::endl; - //std::cout << "DocumentModel::save _hexaDocument->" << _hexaDocument << std::endl; -// QString noSuffix = xmlFileName.section('.', 0, 0); - //std::cout << "DocumentModel::save ->" << noSuffix.toStdString() << std::endl; - //_hexaDocument->setFile( noSuffix.toLocal8Bit().constData() ); // Abu - //_hexaDocument->saveFile(); // Abu -// _hexaDocument->save( noSuffix.toLocal8Bit().constData() ); _hexaDocument->save( xmlFileName.toLocal8Bit().constData() ); } void DocumentModel::updateData() { - //std::cout<<"DocumentModel::updateData() begin"<saveVtk( tmp.toLocal8Bit().constData() ); emit patternDataChanged(); - //std::cout<<"DocumentModel::updateData() end"<" << _hexaDocument << std::endl; - // DATA HEXA_NS::Vertex *v = NULL; VertexItem *vItem = NULL; for ( int i=0; i<_hexaDocument->countVertex(); ++i ){ -// /*char pName[12];*/ std::string name; -// HEXA_NS::Shape *aShape = NULL; -// QString shapeIDs; - v = _hexaDocument->getVertex(i); -// name = v->getName(/*pName*/); -// aShape = v->getAssociation(); - - vItem = new VertexItem(v); - vItem->setData( _entry, HEXA_DOC_ENTRY_ROLE ); -// if ( aShape ){ -// shapeIDs = aShape->ident.c_str(); -// shapeIDs += ";"; -// vItem->setData( QVariant::fromValue(shapeIDs), HEXA_ASSOC_ENTRY_ROLE ); -// } + + vItem = new VertexItem(v, _entry); _vertexDirItem->appendRow(vItem); -// std::cout<getAssociation(); -// std::cout<<"assoc->"< assocItems; -// assocItems << new QStandardItem(s->ident.c_str()); -// std::cout<<"assoc id =>"<ident<appendColumn(assocItems); -// } -// - //CS_TEST -// _vertexDirItem->setEditable( false );//CS_TEST } HEXA_NS::Edge *e = NULL; EdgeItem *eItem = NULL; for ( int i=0; i<_hexaDocument->countEdge(); ++i ){ -// /*char pName[12]; */std::string name; -// HEXA_NS::Shapes shapeList; -// QString shapeIDs; - e = _hexaDocument->getEdge(i); -// name = e->getName(pName); -// shapeList = e->getAssociations(); - - eItem = new EdgeItem(e); - eItem->setData( _entry, HEXA_DOC_ENTRY_ROLE ); - -// std::cout << "shapeList.size() => " << shapeList.size() << std::endl; -// -// if ( !shapeList.empty() ){ -// for ( HEXA_NS::Shapes::const_iterator aShape = shapeList.begin(); -// aShape != shapeList.end(); -// ++aShape ){ -// shapeIDs += (*aShape)->ident.c_str(); -// shapeIDs += ";"; -// } -// eItem->setData( QVariant::fromValue(shapeIDs), HEXA_ASSOC_ENTRY_ROLE ); -// } + eItem = new EdgeItem(e, _entry); _edgeDirItem->appendRow(eItem); -// std::cout<countQuad(); ++i ){ -// char pName[12]; std::string name; -// HEXA_NS::Shapes shapeList; -// QString shapeIDs; - q = _hexaDocument->getQuad(i); -// name = q->getName(pName); -// shapeList = q->getAssociations(); - - qItem = new QuadItem(q); - qItem->setData( _entry, HEXA_DOC_ENTRY_ROLE ); -// if ( !shapeList.empty() ){ -// for ( HEXA_NS::Shapes::const_iterator aShape = shapeList.begin(); -// aShape != shapeList.end(); -// ++aShape ){ -// shapeIDs += (*aShape)->ident.c_str(); -// shapeIDs += ";"; -// } -// eItem->setData( QVariant::fromValue(shapeIDs), HEXA_ASSOC_ENTRY_ROLE ); -// } + qItem = new QuadItem(q, _entry); _quadDirItem->appendRow(qItem); -// std::cout<countHexa(); ++i ){ h = _hexaDocument->getHexa(i); - hItem = new HexaItem(h); - hItem->setData( _entry, HEXA_DOC_ENTRY_ROLE ); + hItem = new HexaItem(h, _entry); _hexaDirItem->appendRow(hItem); } - - //std::cout<<"DocumentModel::fillData() end"<countVector(); ++i ){ @@ -365,7 +331,7 @@ void DocumentModel::fillBuilder() CylinderItem *cItem = NULL; for ( int i=0; i<_hexaDocument->countCylinder(); ++i ){ c = _hexaDocument->getCylinder(i); - cItem = new CylinderItem(c); + cItem = new CylinderItem(c, _entry); _cylinderDirItem->appendRow(cItem); } @@ -376,40 +342,50 @@ void DocumentModel::fillBuilder() p = _hexaDocument->getPipe(i); pItem = new PipeItem(p); _pipeDirItem->appendRow(pItem); - - } -// _elementsDirItem CS_TODO : no elements -// HEXA_NS::Elements *e = NULL; -// ElementsItem *eItem = NULL; -// for ( int i=0; i<_hexaDocument->countElements(); ++i ){ -// e = _hexaDocument->getElements(i); -// eItem = new ElementsItem(e); -// _elementsDirItem->appendRow(eItem); -// } - -// _crossElementsDirItem -// HEXA_NS::CrossElements *c = NULL; -// CrossElementsItem *cItem = NULL; -// for ( int i=0; i<_hexaDocument->countCrossElements(); ++i ){ -// c = _hexaDocument->getCrossElements(i); -// cItem = new CrossElementsItem(c); -// _crossElementsDirItem->appendRow(cItem); -// } - + } } - void DocumentModel::fillAssociation() { } +//------------------------------------------- NEW ITEMS +//void DocumentModel::fillGroups() +//{ +// HEXA_NS::Group *g = NULL; +// GroupItem *gItem = NULL; +// for ( int i=0; i<_hexaDocument->countGroup(); ++i ){ +// g = _hexaDocument->getGroup(i); +// gItem = new GroupItem(g, _entry); +// _groupDirItem->appendRow(gItem); +// } +//} +// +//void DocumentModel::fillMesh() +//{ +// HEXA_NS::Law *l = NULL; +// LawItem *lItem = NULL; +// for ( int i=0; i<_hexaDocument->countLaw(); ++i ){ +// l = _hexaDocument->getLaw(i); +// lItem = new LawItem(l); +// _lawDirItem->appendRow(lItem); +// } +// +// HEXA_NS::Propagation *p = NULL; +// PropagationItem *pItem = NULL; +// for ( int i=0; i<_hexaDocument->countPropagation(); ++i ){ +// p = _hexaDocument->getPropagation(i); +// pItem = new PropagationItem(p, _entry); +// pItem->setText(QString("Propagation%1").arg(i) ); +// _propagationDirItem->appendRow(pItem); +// } +//} +//----------------------------------------------- END NEW ITEMS + void DocumentModel::fillGroups() { - //std::cout<<"DocumentModel::fillGroups() begin"< "<< _hexaDocument->countGroup() << std::endl; for ( int i=0; i<_hexaDocument->countGroup(); ++i ){ g = _hexaDocument->getGroup(i); //std::cout<<"getGroup => "<< i << std::endl; @@ -417,7 +393,6 @@ void DocumentModel::fillGroups() gItem->setData( _entry, HEXA_DOC_ENTRY_ROLE ); _groupDirItem->appendRow(gItem); } - //std::cout<<"DocumentModel::fillGroups() end"< "<< _hexaDocument->countLaw() << std::endl; for ( int i=0; i<_hexaDocument->countLaw(); ++i ){ l = _hexaDocument->getLaw(i); - //std::cout<<"getLaw => "<< i << std::endl; lItem = new LawItem(l); _lawDirItem->appendRow(lItem); } @@ -436,10 +409,8 @@ void DocumentModel::fillMesh() // _propagationDirItem HEXA_NS::Propagation *p = NULL; PropagationItem *pItem = NULL; - //std::cout<<"countPropagation => "<< _hexaDocument->countPropagation() << std::endl; for ( int i=0; i<_hexaDocument->countPropagation(); ++i ){ p = _hexaDocument->getPropagation(i); -// std::cout<<"getPropagation => "<< i << std::endl; pItem = new PropagationItem(p); pItem->setText(QString("Propagation%1").arg(i) ); pItem->setData( _entry, HEXA_DOC_ENTRY_ROLE ); @@ -447,62 +418,16 @@ void DocumentModel::fillMesh() } } -// Qt::ItemFlags DocumentModel::flags(const QModelIndex &index) const -// { -// Qt::ItemFlags flags; -// -// if (!index.isValid()){ -// std::cout<<"!index.isValid()"<type() == VERTEXITEM) && (_vertexItemFlags != Qt::NoItemFlags) ){ -// flags = _vertexItemFlags; -// } else if ( (item->type() == EDGEITEM) && (_edgeItemFlags != Qt::NoItemFlags) ){ -// flags = _edgeItemFlags; -// } else if ( (item->type() == QUADITEM) && (_quadItemFlags != Qt::NoItemFlags) ){ -// flags = _quadItemFlags; -// } else if ( (item->type() == HEXAITEM) && (_hexaItemFlags != Qt::NoItemFlags) ){ -// flags = _hexaItemFlags; -// } else if ( (item->type() == VECTORITEM) && (_vectorItemFlags != Qt::NoItemFlags) ){ -// flags = _vectorItemFlags; -// } else if ( (item->type() == CYLINDERITEM) && (_cylinderItemFlags != Qt::NoItemFlags) ){ -// flags = _cylinderItemFlags; -// } else if ( (item->type() == PIPEITEM ) && (_pipeItemFlags != Qt::NoItemFlags) ){ -// flags = _pipeItemFlags; -// } else if ( (item->type() == ELEMENTSITEM) && (_elementsItemFlags != Qt::NoItemFlags) ){ -// flags = _elementsItemFlags; -// } else if ( (item->type() == CROSSELEMENTSITEM) && (_crossElementsItemFlags != Qt::NoItemFlags) ){ -// flags = _crossElementsItemFlags; -// } else if ( (item->type() == GROUPITEM) && (_groupItemFlags != Qt::NoItemFlags) ){ -// flags = _groupItemFlags; -// } else if ( (item->type() == LAWITEM ) && (_lawItemFlags != Qt::NoItemFlags) ){ -// flags = _lawItemFlags; -// } else if ( (item->type() == PROPAGATIONITEM ) && (_propagationItemFlags != Qt::NoItemFlags) ){ -// flags = _propagationItemFlags; -// } else { -// flags = item->flags(); -// } -// -// return flags; -// } +HEXA_NS::Hexa* DocumentModel::getQuadHexa(HEXA_NS::Quad* quad) +{ + HEXA_NS::Hexa* hexa; + for ( int i=0; i<_hexaDocument->countHexa(); ++i ){ + hexa = _hexaDocument->getHexa(i); + if (hexa->findQuad(quad) > -1) return hexa; + } + return NULL; +} -// Qt::ItemFlags DocumentModel::flags(const QModelIndex &index) const -// { -// Qt::ItemFlags flags; -// -// if (!index.isValid()) return Qt::ItemIsEnabled; -// QStandardItem *item = itemFromIndex ( index ); -// if ( _disallowEdition ){ -// flags = Qt::ItemFlags( ~Qt::ItemIsEditable ); -// } else { -// flags = item->flags(); -// } -// -// return flags; -// } Qt::ItemFlags DocumentModel::flags(const QModelIndex &index) const { @@ -531,25 +456,6 @@ void DocumentModel::disallowEdition() MESSAGE("}"); } -// disallowEdition -// void DocumentModel::allowAllSelection() -// { -// _vertexItemFlags = Qt::NoItemFlags; -// _edgeItemFlags = Qt::NoItemFlags; -// _quadItemFlags = Qt::NoItemFlags; -// _hexaItemFlags = Qt::NoItemFlags; -// -// _vectorItemFlags = Qt::NoItemFlags; -// _cylinderItemFlags = Qt::NoItemFlags; -// _pipeItemFlags = Qt::NoItemFlags; -// _elementsItemFlags = Qt::NoItemFlags; -// _crossElementsItemFlags = Qt::NoItemFlags; -// -// _groupItemFlags = Qt::NoItemFlags; -// _lawItemFlags = Qt::NoItemFlags; -// _propagationItemFlags = Qt::NoItemFlags; -// } - void DocumentModel::allowDataSelectionOnly() { _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable ); @@ -568,30 +474,8 @@ void DocumentModel::allowDataSelectionOnly() _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); } -// void DocumentModel::allowVertexSelectionOnly() -// { -// std::cout << "allowVertexSelectionOnly() allowVertexSelectionOnly() allowVertexSelectionOnly() "<< std::endl; -// _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable); -// _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -// _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -// _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -// -// _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -// _cylinderItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -// _pipeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -// _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -// _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -// -// _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -// _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -// _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -// -// // emit layoutChanged(); -// } - void DocumentModel::allowVertexSelectionOnly() { - //std::cout << "allowVertexSelectionOnly() allowVertexSelectionOnly() allowVertexSelectionOnly() "<< std::endl; _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable); _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable ); _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable ); @@ -612,7 +496,6 @@ void DocumentModel::allowVertexSelectionOnly() void DocumentModel::allowEdgeSelectionOnly() { - //std::cout << "allowEdgeSelectionOnly() allowEdgeSelectionOnly() allowEdgeSelectionOnly() "<< std::endl; _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable ); _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); @@ -631,7 +514,6 @@ void DocumentModel::allowEdgeSelectionOnly() void DocumentModel::allowQuadSelectionOnly() { - //std::cout << "allowQuadSelectionOnly() allowQuadSelectionOnly() allowQuadSelectionOnly() "<< std::endl; _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable ); @@ -668,7 +550,6 @@ void DocumentModel::allowHexaSelectionOnly() void DocumentModel::allowVectorSelectionOnly() { - //std::cout << "allowVectorSelectionOnly() allowVectorSelectionOnly() allowVectorSelectionOnly() "<< std::endl; _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); @@ -721,28 +602,8 @@ void DocumentModel::allowPipeSelectionOnly() _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); } -/* -void DocumentModel::allowPipeItemFlags() -{ - _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); - _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); - _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); - _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); - - _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); - _cylinderItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable ); - _pipeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); - _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); - _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); - - _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); - _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); - _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); -}*/ - void DocumentModel::allowElementsSelectionOnly() { - //std::cout << "allowElementsSelectionOnly() allowElementsSelectionOnly() allowElementsSelectionOnly() "<< std::endl; _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); @@ -795,65 +656,37 @@ void DocumentModel::allowLawSelectionOnly() _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled ); } + void DocumentModel::setName( const QModelIndex& iElt, const QString& name ) { - HEXA_NS::EltBase *elt = NULL; - - switch ( data(iElt, HEXA_TREE_ROLE).toInt() ){ - case VERTEX_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Vertex* >(); break; - case EDGE_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Edge* >(); break; - case QUAD_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Quad* >(); break; - case HEXA_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Hexa* >(); break; - case VECTOR_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Vector* >(); break; - case CYLINDER_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Cylinder* >(); break; - case PIPE_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Pipe* >(); break; - case ELEMENTS_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Elements* >(); break; - case CROSSELEMENTS_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::CrossElements* >(); break; - case GROUP_TREE : - { - HEXA_NS::Group* grp = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Group* >(); - grp->setName( name.toLatin1().data() ); - break; - } - case LAW_TREE : - { - HEXA_NS::Law* l = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Law* >(); - l->setName( name.toLatin1().data() ); - break; - } -// case PROPAGATION_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Propagation* >(); break; - } + HEXA_NS::EltBase *elt = NULL; - if ( elt != NULL ) elt->setName( name.toStdString() ); + switch ( data(iElt, HEXA_TREE_ROLE).toInt() ){ + case GROUP_TREE : + { + HEXA_NS::Group* grp = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Group* >(); + grp->setName( name.toLatin1().data() ); + break; + } + case LAW_TREE : + { + HEXA_NS::Law* l = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Law* >(); + l->setName( name.toLatin1().data() ); + break; + } + // case PROPAGATION_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Propagation* >(); break; + default: elt = getHexaPtr(iElt); + } + + if ( elt != NULL ) elt->setName( name.toStdString() ); + setData( iElt, name ); - setData( iElt, name ); } bool DocumentModel::clearEltAssociations( const QModelIndex& iElt ) { bool isOk = false; - HEXA_NS::EltBase *elt = NULL; - - switch ( data(iElt, HEXA_TREE_ROLE).toInt() ){ - case VERTEX_TREE : - { - elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Vertex* >(); - //std::cout<<"VERTEX_TREE:"<(); - //std::cout<<"EDGE_TREE :"<(); - //std::cout<<"QUAD_TREE :"<clearAssociation(); @@ -866,18 +699,12 @@ bool DocumentModel::clearEltAssociations( const QModelIndex& iElt ) QModelIndex DocumentModel::addVertex( double x, double y, double z ) { - //std::cout << "DocumentModel::addVertex() _hexaDocument->" << _hexaDocument << std::endl; QModelIndex vertexIndex; HEXA_NS::Vertex* hv = _hexaDocument->addVertex(x, y, z); if ( hv->isValid() ){ - VertexItem* v = new VertexItem(hv); - v->setData( _entry, HEXA_DOC_ENTRY_ROLE ); + VertexItem* v = new VertexItem(hv, _entry); _vertexDirItem->appendRow(v); -// v->appendRow( new QStandardItem("titi") ); -// QList l; -// l << new QStandardItem("toto"); -// v->appendColumn( l ); vertexIndex = v->index(); emit patternDataChanged(); } else { @@ -891,19 +718,16 @@ QModelIndex DocumentModel::addEdgeVertices (const QModelIndex &i_v0, const QMode { QModelIndex edgeIndex; - HEXA_NS::Vertex* hv0 = data(i_v0, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv1 = data(i_v1, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hv0 = getHexaPtr(i_v0); + HEXA_NS::Vertex* hv1 = getHexaPtr(i_v1); HEXA_NS::Edge* he = _hexaDocument->addEdge( hv0, hv1 ); if ( he->isValid() ){ - EdgeItem* e = new EdgeItem(he); - e->setData( _entry, HEXA_DOC_ENTRY_ROLE ); + EdgeItem* e = new EdgeItem(he, _entry); _edgeDirItem->appendRow(e); edgeIndex = e->index(); emit patternDataChanged(); - QString tmp = "/tmp/addEdgeVertices.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete he; } @@ -914,22 +738,31 @@ QModelIndex DocumentModel::addEdgeVector( const QModelIndex &i_v, const QModelIn { QModelIndex edgeIndex; - HEXA_NS::Vertex* hv = data(i_v, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvec = data(i_vec, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hv = getHexaPtr(i_v); + HEXA_NS::Vector* hvec = getHexaPtr(i_vec); + + if (!hv || !hvec) return edgeIndex; HEXA_NS::Edge* he = _hexaDocument->addEdge( hv, hvec ); + if (!he) return edgeIndex; + HEXA_NS::Vertex* hv2 = he->getAval(); //the new vertex resulting from the creation of the edge + if (!hv2) return edgeIndex; + //ADD the elements in the treeview if ( he->isValid() ){ - EdgeItem* e = new EdgeItem(he); - e->setData( _entry, HEXA_DOC_ENTRY_ROLE ); + //The Edge + EdgeItem* e = new EdgeItem(he, _entry); _edgeDirItem->appendRow(e); + + //The Vertex + VertexItem* v = new VertexItem(hv2, _entry); + _vertexDirItem->appendRow(v); + edgeIndex = e->index(); emit patternDataChanged(); - QString tmp = "/tmp/addEdgeVector.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); - } else { + } else delete he; - } + return edgeIndex; } @@ -938,30 +771,18 @@ QModelIndex DocumentModel::addQuadVertices( const QModelIndex &i_v0, const QMode { //CS_TODO : gestion erreur QModelIndex quadIndex; -// QStandardItem *item_v0 = itemFromIndex(i_v0); -// QStandardItem *item_v1 = itemFromIndex(i_v1); -// QStandardItem *item_v2 = itemFromIndex(i_v2); -// QStandardItem *item_v3 = itemFromIndex(i_v3); - -// HASSERT( item_v0->type() == item_v1->type() -// == item_v2->type() == item_v3->type() -// == VERTEXITEM ); - - HEXA_NS::Vertex* hv0 = data(i_v0, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv1 = data(i_v1, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv2 = data(i_v2, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv3 = data(i_v3, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hv0 = getHexaPtr(i_v0); + HEXA_NS::Vertex* hv1 = getHexaPtr(i_v1); + HEXA_NS::Vertex* hv2 = getHexaPtr(i_v2); + HEXA_NS::Vertex* hv3 = getHexaPtr(i_v3); if ( hv0 and hv1 and hv2 and hv3 ){ HEXA_NS::Quad* hq = _hexaDocument->addQuadVertices( hv0, hv1, hv2, hv3 ); if ( hq->isValid() ){ - QuadItem* q = new QuadItem(hq); - q->setData( _entry, HEXA_DOC_ENTRY_ROLE ); + QuadItem* q = new QuadItem(hq, _entry); _quadDirItem->appendRow(q); quadIndex = q->index(); emit patternDataChanged(); - QString tmp = "/tmp/addQuadVertices.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hq; } @@ -974,21 +795,18 @@ QModelIndex DocumentModel::addQuadEdges( const QModelIndex &e0, const QModelInde { //CS_TODO QModelIndex quadIndex; - HEXA_NS::Edge* he0 = data(e0, HEXA_DATA_ROLE).value(); - HEXA_NS::Edge* he1 = data(e1, HEXA_DATA_ROLE).value(); - HEXA_NS::Edge* he2 = data(e2, HEXA_DATA_ROLE).value(); - HEXA_NS::Edge* he3 = data(e3, HEXA_DATA_ROLE).value(); + HEXA_NS::Edge* he0 = getHexaPtr(e0); + HEXA_NS::Edge* he1 = getHexaPtr(e1); + HEXA_NS::Edge* he2 = getHexaPtr(e2); + HEXA_NS::Edge* he3 = getHexaPtr(e3); if ( he0 and he1 and he2 and he3 ){ - HEXA_NS::Quad* hq = _hexaDocument->addQuad( he0, he1, he2, he3 ); + HEXA_NS::Quad* hq = _hexaDocument->addQuad( he0, he1, he2, he3 ); if ( hq->isValid() ){ - QuadItem* q = new QuadItem(hq); - q->setData( _entry, HEXA_DOC_ENTRY_ROLE ); + QuadItem* q = new QuadItem(hq, _entry); _quadDirItem->appendRow(q); quadIndex = q->index(); emit patternDataChanged(); - QString tmp = "/tmp/addQuadEdges.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hq; } @@ -1004,26 +822,23 @@ QModelIndex DocumentModel::addHexaVertices( { QModelIndex iHexa; - HEXA_NS::Vertex* hv0 = data(iv0, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv1 = data(iv1, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv2 = data(iv2, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv3 = data(iv3, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv4 = data(iv4, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv5 = data(iv5, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv6 = data(iv6, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv7 = data(iv7, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hv0 = getHexaPtr(iv0); + HEXA_NS::Vertex* hv1 = getHexaPtr(iv1); + HEXA_NS::Vertex* hv2 = getHexaPtr(iv2); + HEXA_NS::Vertex* hv3 = getHexaPtr(iv3); + HEXA_NS::Vertex* hv4 = getHexaPtr(iv4); + HEXA_NS::Vertex* hv5 = getHexaPtr(iv5); + HEXA_NS::Vertex* hv6 = getHexaPtr(iv6); + HEXA_NS::Vertex* hv7 = getHexaPtr(iv7); HEXA_NS::Hexa* hh = _hexaDocument->addHexaVertices( hv0, hv1, hv2, hv3, hv4, hv5, hv6, hv7 ); if ( hh->isValid() ){ - HexaItem* h = new HexaItem(hh); - h->setData( _entry, HEXA_DOC_ENTRY_ROLE ); + HexaItem* h = new HexaItem(hh, _entry); _hexaDirItem->appendRow(h); iHexa = h->index(); emit patternDataChanged(); - QString tmp = "/tmp/addHexaVertices.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hh; } @@ -1036,32 +851,22 @@ QModelIndex DocumentModel::addHexaQuad( const QModelIndex &i_q0, const QModelInd { //CS_TODO : gestion erreur QModelIndex hexaIndex; -// QStandardItem *item_v0 = itemFromIndex(i_q0); -// QStandardItem *item_v1 = itemFromIndex(i_q1); -// QStandardItem *item_v2 = itemFromIndex(i_q2); -// QStandardItem *item_v3 = itemFromIndex(i_q3); -// QStandardItem *item_v4 = itemFromIndex(i_q4); -// QStandardItem *item_v5 = itemFromIndex(i_q5); - HEXA_NS::Quad* hq0 = data(i_q0, HEXA_DATA_ROLE).value(); - HEXA_NS::Quad* hq1 = data(i_q1, HEXA_DATA_ROLE).value(); - HEXA_NS::Quad* hq2 = data(i_q2, HEXA_DATA_ROLE).value(); - HEXA_NS::Quad* hq3 = data(i_q3, HEXA_DATA_ROLE).value(); - HEXA_NS::Quad* hq4 = data(i_q4, HEXA_DATA_ROLE).value(); - HEXA_NS::Quad* hq5 = data(i_q5, HEXA_DATA_ROLE).value(); + HEXA_NS::Quad* hq0 = getHexaPtr(i_q0); + HEXA_NS::Quad* hq1 = getHexaPtr(i_q1); + HEXA_NS::Quad* hq2 = getHexaPtr(i_q2); + HEXA_NS::Quad* hq3 = getHexaPtr(i_q3); + HEXA_NS::Quad* hq4 = getHexaPtr(i_q4); + HEXA_NS::Quad* hq5 = getHexaPtr(i_q5); HEXA_NS::Hexa* hh = _hexaDocument->addHexa( hq0, hq1, hq2, hq3, hq4, hq5 ); if ( hh->isValid() ){ - HexaItem* h = new HexaItem(hh); - h->setData( _entry, HEXA_DOC_ENTRY_ROLE ); + HexaItem* h = new HexaItem(hh, _entry); _hexaDirItem->appendRow(h); hexaIndex = h->index(); emit patternDataChanged(); - QString tmp = "/tmp/addHexaQuad.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); - } else { + } else delete hh; - } return hexaIndex; } @@ -1073,36 +878,31 @@ QModelIndex DocumentModel::addHexaQuads( const QModelIndexList &iquads) HEXA_NS::Hexa* hh = NULL; HEXA_NS::Quad* hq0, *hq1, *hq2, *hq3, *hq4, *hq5 = NULL; - hq0 = data( iquads.value(0), HEXA_DATA_ROLE).value(); - hq1 = data( iquads.value(1), HEXA_DATA_ROLE).value(); - hq2 = data( iquads.value(2), HEXA_DATA_ROLE).value(); - hq3 = data( iquads.value(3), HEXA_DATA_ROLE).value(); - hq4 = data( iquads.value(4), HEXA_DATA_ROLE).value(); - hq5 = data( iquads.value(5), HEXA_DATA_ROLE).value(); - - if ( hq0 && hq1 ){ - hh = _hexaDocument->addHexa2Quads( hq0, hq1); - } else if ( hq0 && hq1 && hq2){ - hh = _hexaDocument->addHexa3Quads( hq0, hq1, hq2 ); - } else if ( hq0 && hq1 && hq2 && hq3 ){ - hh = _hexaDocument->addHexa4Quads( hq0, hq1, hq2, hq3 ); - } else if ( hq0 && hq1 && hq2 && hq3 && hq4 ){ - hh = _hexaDocument->addHexa5Quads( hq0, hq1, hq2, hq3, hq4 ); - } else if ( hq0 && hq1 && hq2 && hq3 && hq4 && hq5 ){ - hh = _hexaDocument->addHexa( hq0, hq1, hq2, hq3, hq4, hq5 ); - } + hq0 = getHexaPtr(iquads.value(0)); + hq1 = getHexaPtr(iquads.value(1)); + hq2 = getHexaPtr(iquads.value(2)); + hq3 = getHexaPtr(iquads.value(3)); + hq4 = getHexaPtr(iquads.value(4)); + hq5 = getHexaPtr(iquads.value(5)); + + if ( hq0 && hq1 && hq2 && hq3 && hq4 && hq5 ) + hh = _hexaDocument->addHexa( hq0, hq1, hq2, hq3, hq4, hq5 ); + else if ( hq0 && hq1 && hq2 && hq3 && hq4 ) + hh = _hexaDocument->addHexa5Quads( hq0, hq1, hq2, hq3, hq4 ); + else if ( hq0 && hq1 && hq2 && hq3 ) + hh = _hexaDocument->addHexa4Quads( hq0, hq1, hq2, hq3 ); + else if ( hq0 && hq1 && hq2) + hh = _hexaDocument->addHexa3Quads( hq0, hq1, hq2 ); + else if ( hq0 && hq1 ) + hh = _hexaDocument->addHexa2Quads( hq0, hq1); if ( hh && hh->isValid() ){ - HexaItem* h = new HexaItem(hh); - h->setData( _entry, HEXA_DOC_ENTRY_ROLE ); - _hexaDirItem->appendRow(h); - hexaIndex = h->index(); - emit patternDataChanged(); - QString tmp = "/tmp/addHexaQuads.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); - } else { + updateData(); + unsigned int nbRows = _hexaDirItem->rowCount(); + if (nbRows > 0) + hexaIndex = _hexaDirItem->child(nbRows-1)->index(); + } else delete hh; - } return hexaIndex; } @@ -1111,28 +911,17 @@ QModelIndex DocumentModel::addHexaQuads( const QModelIndexList &iquads) // raises (SALOME::SALOME_Exception); QModelIndex DocumentModel::addVector( double dx, double dy, double dz ) { - //std::cout << "DocumentModel::addVector" << std::endl; QModelIndex vectorIndex; HEXA_NS::Vector* hv = _hexaDocument->addVector(dx, dy, dz); if ( hv->isValid() ){ - //std::cout << "hv->isValid()" << std::endl; VectorItem* v = new VectorItem(hv); _vectorDirItem->appendRow(v); vectorIndex = v->index(); -// QStandardItem *toto = new QStandardItem("Toto"); -// std::cout << "before" << std::endl; -// _vectorDirItem->appendRow(toto); -// std::cout << "after" << std::endl; -// vectorIndex = toto->index(); - QString tmp = "/tmp/addVector.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); - } else { - //std::cout << "delete hv" << std::endl; + } else delete hv; - } return vectorIndex; } @@ -1141,8 +930,8 @@ QModelIndex DocumentModel::addVectorVertices( const QModelIndex &iv0, const QMod { QModelIndex iVec; - HEXA_NS::Vertex* hv0 = data(iv0, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv1 = data(iv1, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hv0 = getHexaPtr(iv0); + HEXA_NS::Vertex* hv1 = getHexaPtr(iv1); HEXA_NS::Vector* hvec = _hexaDocument->addVectorVertices( hv0, hv1 ); @@ -1150,8 +939,6 @@ QModelIndex DocumentModel::addVectorVertices( const QModelIndex &iv0, const QMod VectorItem* vec = new VectorItem(hvec); _vectorDirItem->appendRow(vec); iVec = vec->index(); - QString tmp = "/tmp/addVectorVertices.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hvec; } @@ -1163,8 +950,8 @@ QModelIndex DocumentModel::addCylinder( const QModelIndex &iv, const QModelIndex { QModelIndex iCyl; - HEXA_NS::Vertex* hv = data(iv, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hv = getHexaPtr(iv); + HEXA_NS::Vector* hvec = getHexaPtr(ivec); HEXA_NS::Cylinder* hcyl = _hexaDocument->addCylinder( hv, hvec, r, h ); @@ -1172,8 +959,6 @@ QModelIndex DocumentModel::addCylinder( const QModelIndex &iv, const QModelIndex CylinderItem* cyl = new CylinderItem(hcyl); _cylinderDirItem->appendRow(cyl); iCyl = cyl->index(); - QString tmp = "/tmp/addCylinder.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hcyl; } @@ -1185,8 +970,8 @@ QModelIndex DocumentModel::addPipe( const QModelIndex &iv, const QModelIndex &iv { QModelIndex iPipe; - HEXA_NS::Vertex* hv = data(iv, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hv = getHexaPtr(iv); + HEXA_NS::Vector* hvec = getHexaPtr(ivec); HEXA_NS::Pipe* hPipe = _hexaDocument->addPipe( hv, hvec, ri, re, h ); @@ -1194,8 +979,6 @@ QModelIndex DocumentModel::addPipe( const QModelIndex &iv, const QModelIndex &iv PipeItem* pipe = new PipeItem(hPipe); _pipeDirItem->appendRow(pipe); iPipe = pipe->index(); - QString tmp = "/tmp/addPipe.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hPipe; } @@ -1210,32 +993,22 @@ QModelIndex DocumentModel::makeCartesian( const QModelIndex& i_pt, QModelIndex eltsIndex; //std::cout<<"makeCartesian begin"<(); - HEXA_NS::Vector* hvec_x = data(i_vec_x, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvec_y = data(i_vec_y, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvec_z = data(i_vec_z, HEXA_DATA_ROLE).value(); - - //std::cout<<"hpt "<(i_pt); + HEXA_NS::Vector* hvec_x = getHexaPtr(i_vec_x); + HEXA_NS::Vector* hvec_y = getHexaPtr(i_vec_y); + HEXA_NS::Vector* hvec_z = getHexaPtr(i_vec_z); HEXA_NS::Elements* new_helts = _hexaDocument->makeCartesian( hpt, hvec_x, hvec_y, hvec_z, nx, ny, nz ); if ( new_helts->isValid() ){ - //std::cout<<"makeCartesian OK!!!"<appendRow(eltsItem); eltsIndex = eltsItem->index(); - QString tmp = "/tmp/makeCartesian1.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); - } else { - //std::cout<<"makeCartesian KO!!!"<(); - HEXA_NS::Vector* hVec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hVex = getHexaPtr(ivex); + HEXA_NS::Vector* hVec = getHexaPtr(ivec); HEXA_NS::Elements* hElts = _hexaDocument->makeCartesian( hVex, hVec, @@ -1257,8 +1030,6 @@ QModelIndex DocumentModel::makeCartesian( const QModelIndex& ivex, ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/makeCartesian2.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } @@ -1281,9 +1052,9 @@ QModelIndex DocumentModel::makeCylindrical( const QModelIndex& i_pt, QModelIndex eltsIndex; - HEXA_NS::Vertex* hpt = data(i_pt, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvec_x = data(i_vec_x, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvec_z = data(i_vec_z, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hpt = getHexaPtr(i_pt); + HEXA_NS::Vector* hvec_x = getHexaPtr(i_vec_x); + HEXA_NS::Vector* hvec_z = getHexaPtr(i_vec_z); HEXA_NS::Elements* new_helts = _hexaDocument->makeCylindrical( hpt, hvec_x, hvec_z, dr, da, dl, nr, na, nl, fill ); @@ -1292,8 +1063,6 @@ QModelIndex DocumentModel::makeCylindrical( const QModelIndex& i_pt, ElementsItem* eltsItem = new ElementsItem(new_helts); _elementsDirItem->appendRow(eltsItem); eltsIndex = eltsItem->index(); - QString tmp = "/tmp/makeCylindrical.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete new_helts; } @@ -1308,25 +1077,20 @@ QModelIndex DocumentModel::makeCylindricals( { QModelIndex eltsIndex; - HEXA_NS::Vertex* hcenter = data( icenter, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hbase = data( ibase, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hheight = data( iheight, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hcenter = getHexaPtr(icenter); + HEXA_NS::Vector* hbase =getHexaPtr(ibase); + HEXA_NS::Vector* hheight = getHexaPtr(iheight); // HEXA_NS::Elements* helts; std::vector r = radius.toVector().toStdVector(); std::vector a = angles.toVector().toStdVector(); std::vector h = heights.toVector().toStdVector(); - HEXA_NS::Elements* helts = _hexaDocument->makeCylindricals( + HEXA_NS::Elements* helts = _hexaDocument->makeCylindricals( hcenter, hbase, hheight, r, a, h, fill ); -// HEXA_NS::Elements* helts = _hexaDocument->makeCylindricals( -// hcenter, hbase, hheight, -// radius.toVector().toStdVector(), angles.toVector().toStdVector(), heights.toVector().toStdVector(), -// fill ); - if ( helts->isValid() ){ updateData(); //CS_TODO more or less? ElementsItem* eltsItem = new ElementsItem(helts); @@ -1335,7 +1099,6 @@ QModelIndex DocumentModel::makeCylindricals( } else { delete helts; } - return eltsIndex; } @@ -1343,8 +1106,8 @@ QModelIndex DocumentModel::makeSpherical( const QModelIndex& iv, const QModelInd { QModelIndex iElts; - HEXA_NS::Vertex* hv = data(iv, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hv = getHexaPtr(iv); + HEXA_NS::Vector* hvec = getHexaPtr(ivec); HEXA_NS::Elements* hElts = _hexaDocument->makeSpherical( hv, hvec, nb, k ); @@ -1353,8 +1116,6 @@ QModelIndex DocumentModel::makeSpherical( const QModelIndex& iv, const QModelInd ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/makeSpherical.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } @@ -1366,7 +1127,7 @@ QModelIndex DocumentModel::makeSpherical( const QModelIndex& icenter, double rad { QModelIndex iElts; - HEXA_NS::Vertex* hcenter = data(icenter, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hcenter = getHexaPtr(icenter); HEXA_NS::Elements* helts = _hexaDocument->makeSpherical( hcenter, radius, nb, k ); @@ -1375,8 +1136,6 @@ QModelIndex DocumentModel::makeSpherical( const QModelIndex& icenter, double rad ElementsItem* eltsItem = new ElementsItem(helts); _elementsDirItem->appendRow(eltsItem); iElts = eltsItem->index(); -// QString tmp = "/tmp/makeSpherical.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete helts; } @@ -1389,8 +1148,8 @@ QModelIndex DocumentModel::makeCylinder( const QModelIndex& icyl, const QModelIn { QModelIndex iElts; - HEXA_NS::Cylinder* hcyl = data(icyl, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Cylinder* hcyl = getHexaPtr(icyl); + HEXA_NS::Vector* hvec = getHexaPtr(ivec); HEXA_NS::Elements* hElts = _hexaDocument->makeCylinder( hcyl, hvec, nr, na, nl ); if ( hElts->isValid() ){ @@ -1398,8 +1157,6 @@ QModelIndex DocumentModel::makeCylinder( const QModelIndex& icyl, const QModelIn ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/makeCylinder.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } @@ -1412,8 +1169,8 @@ QModelIndex DocumentModel::makePipe( const QModelIndex& ipipe, const QModelIndex { QModelIndex iElts; - HEXA_NS::Pipe* hPipe = data(ipipe, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hVecx = data(ivecx, HEXA_DATA_ROLE).value(); + HEXA_NS::Pipe* hPipe = getHexaPtr(ipipe); + HEXA_NS::Vector* hVecx = getHexaPtr(ivecx); HEXA_NS::Elements* hElts = _hexaDocument->makePipe( hPipe, hVecx, nr, na, nl ); @@ -1422,8 +1179,6 @@ QModelIndex DocumentModel::makePipe( const QModelIndex& ipipe, const QModelIndex ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/makePipe.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } @@ -1435,8 +1190,8 @@ QModelIndex DocumentModel::makeCylinders(const QModelIndex& icyl1, const QModelI { //CS_TODO QModelIndex iCrossElts; - HEXA_NS::Cylinder* hCyl1 = data(icyl1, HEXA_DATA_ROLE).value(); - HEXA_NS::Cylinder* hCyl2 = data(icyl2, HEXA_DATA_ROLE).value(); + HEXA_NS::Cylinder* hCyl1 = getHexaPtr(icyl1); + HEXA_NS::Cylinder* hCyl2 = getHexaPtr(icyl2); HEXA_NS::CrossElements* hCrossElts = _hexaDocument->makeCylinders( hCyl1, hCyl2 ); @@ -1445,8 +1200,6 @@ QModelIndex DocumentModel::makeCylinders(const QModelIndex& icyl1, const QModelI ElementsItem* crossElts = new ElementsItem(hCrossElts); _crossElementsDirItem->appendRow(crossElts); iCrossElts = crossElts->index(); - QString tmp = "/tmp/makeCylinders.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hCrossElts; } @@ -1459,48 +1212,8 @@ QModelIndex DocumentModel::makePipes( const QModelIndex& ipipe1, const QModelInd { QModelIndex iCrossElts; - HEXA_NS::Pipe* hPipe1 = data(ipipe1, HEXA_DATA_ROLE).value(); - HEXA_NS::Pipe* hPipe2 = data(ipipe2, HEXA_DATA_ROLE).value(); - - -// MESSAGE("DocumentModel::makePipes( "<< ipipe1.data().toString().toStdString() << ","<< ipipe2.data().toString().toStdString() ); -// -// HEXA_NS::Vertex* b1 = hPipe1->getBase(); -// HEXA_NS::Vector* d1 = hPipe1->getDirection(); -// MESSAGE("pipe1 vertex is " << b1->getName() -// <<"("<< b1->getX() -// <<","<< b1->getY() -// <<","<< b1->getZ()<<")" -// ); -// MESSAGE("pipe1 vector is " << d1->getName() -// <<"("<< d1->getDx() -// <<","<< d1->getDy() -// <<","<< d1->getDz()<<")" -// ); -// MESSAGE("pipe1 ir is " << hPipe1->getInternalRadius()); -// MESSAGE("pipe1 er is " << hPipe1->getRadius()); -// MESSAGE("pipe1 h is " << hPipe1->getHeight()); -// -// -// HEXA_NS::Vertex* b2 = hPipe2->getBase(); -// HEXA_NS::Vector* d2 = hPipe2->getDirection(); -// MESSAGE("pipe2 vertex is " << b2->getName() -// <<"("<< b2->getX() -// <<","<< b2->getY() -// <<","<< b2->getZ()<<")" -// ); -// MESSAGE("pipe2 vector is " << d2->getName() -// <<"("<< d2->getDx() -// <<","<< d2->getDy() -// <<","<< d2->getDz()<<")" -// ); -// MESSAGE("pipe2 vertex is " << hPipe2->getBase()->getName() ); -// MESSAGE("pipe2 vector is " << hPipe2->getDirection()->getName()); -// MESSAGE("pipe2 ir is " << hPipe2->getInternalRadius()); -// MESSAGE("pipe2 er is " << hPipe2->getRadius()); -// MESSAGE("pipe2 h is " << hPipe2->getHeight()); - - + HEXA_NS::Pipe* hPipe1 = getHexaPtr(ipipe1); + HEXA_NS::Pipe* hPipe2 = getHexaPtr(ipipe2); HEXA_NS::CrossElements* hCrossElts = _hexaDocument->makePipes( hPipe1, hPipe2 ); @@ -1526,12 +1239,12 @@ QModelIndex DocumentModel::makeRind( const QModelIndex& icenter, { QModelIndex iElts; - HEXA_NS::Vertex* hcenter = data(icenter, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvecx = data(ivecx, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvecz = data(ivecz, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hplorig = data(iplorig, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hcenter = getHexaPtr(icenter); + HEXA_NS::Vector* hvecx = getHexaPtr(ivecx); + HEXA_NS::Vector* hvecz = getHexaPtr(ivecz); + HEXA_NS::Vertex* hplorig = getHexaPtr(iplorig); - HEXA_NS::Elements* hElts = _hexaDocument->makeRind( hcenter, + HEXA_NS::Elements* hElts = _hexaDocument->makeRind( hcenter, hvecx, hvecz, radext, radint, radhole, hplorig, @@ -1557,12 +1270,12 @@ QModelIndex DocumentModel::makePartRind( const QModelIndex& icenter, { QModelIndex iElts; - HEXA_NS::Vertex* hcenter = data(icenter, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvecx = data(ivecx, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvecz = data(ivecz, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hplorig = data(iplorig, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hcenter = getHexaPtr(icenter); + HEXA_NS::Vector* hvecx = getHexaPtr(ivecx); + HEXA_NS::Vector* hvecz = getHexaPtr(ivecz); + HEXA_NS::Vertex* hplorig = getHexaPtr(iplorig); - HEXA_NS::Elements* hElts = _hexaDocument->makePartRind( hcenter, + HEXA_NS::Elements* hElts = _hexaDocument->makePartRind( hcenter, hvecx, hvecz, radext, radint, radhole, hplorig, angle, @@ -1588,12 +1301,12 @@ QModelIndex DocumentModel::makeSphere( const QModelIndex& icenter, { QModelIndex iElts; - HEXA_NS::Vertex* hcenter = data(icenter, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvecx = data(ivecx, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvecz = data(ivecz, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hplorig = data(iplorig, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hcenter = getHexaPtr(icenter); + HEXA_NS::Vector* hvecx = getHexaPtr(ivecx); + HEXA_NS::Vector* hvecz = getHexaPtr(ivecz); + HEXA_NS::Vertex* hplorig = getHexaPtr(iplorig); - HEXA_NS::Elements* hElts = _hexaDocument->makeSphere( hcenter, + HEXA_NS::Elements* hElts = _hexaDocument->makeSphere( hcenter, hvecx, hvecz, radius, radhole, hplorig, @@ -1619,10 +1332,10 @@ QModelIndex DocumentModel::makePartSphere( const QModelIndex& icenter, { QModelIndex iElts; - HEXA_NS::Vertex* hcenter = data(icenter, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvecx = data(ivecx, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hvecz = data(ivecz, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hplorig = data(iplorig, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hcenter = getHexaPtr(icenter); + HEXA_NS::Vector* hvecx = getHexaPtr(ivecx); + HEXA_NS::Vector* hvecz = getHexaPtr(ivecz); + HEXA_NS::Vertex* hplorig = getHexaPtr(iplorig); HEXA_NS::Elements* hElts = _hexaDocument->makePartSphere( hcenter, hvecx, hvecz, @@ -1648,15 +1361,9 @@ bool DocumentModel::updateVertex( const QModelIndex& ivertex, double x, double y { bool ret = false; -// cout << "DocumentModel::updateVertex" << ivertex.data().toString().toStdString() << endl; -// cout << "DocumentModel::updateVertex" << ivertex.data(HEXA_DATA_ROLE).value() << endl; -// cout << "DocumentModel::updateVertex" << ivertex.data(HEXA_TREE_ROLE).toString().toStdString() << endl; -// cout << "DocumentModel::updateVertex" << ivertex.data(HEXA_DOC_ENTRY_ROLE).toString().toStdString() << endl; + //HEXA_NS::Vertex* hVertex = ivertex.data(HEXA_DATA_ROLE).value(); //CS_TODO? pareil pour toutes les autres méthodes du modèle? + HEXA_NS::Vertex* hVertex = getHexaPtr(ivertex); -// HEXA_NS::Vertex* hVertex = data(ivertex, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVertex = ivertex.data(HEXA_DATA_ROLE).value(); //CS_TODO? pareil pour toutes les autres méthodes du modèle? - - cout << "DocumentModel::updateVertex hVertex = " << hVertex << endl; if ( hVertex ){ // hVertex->setName( name.toStdString() ); hVertex->setX ( x ); @@ -1672,13 +1379,12 @@ bool DocumentModel::updateVertex( const QModelIndex& ivertex, double x, double y bool DocumentModel::removeHexa( const QModelIndex& ihexa ) { bool ret = false; - HEXA_NS::Hexa* hHexa = data(ihexa, HEXA_DATA_ROLE).value(); + HEXA_NS::Hexa* hHexa = getHexaPtr(ihexa); + int r = _hexaDocument->removeHexa( hHexa ); if ( r == HOK ){ updateData(); - QString tmp = "/tmp/removeHexa.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); ret = true; } else if ( r == HERR ){ ret = false; @@ -1690,14 +1396,12 @@ bool DocumentModel::removeHexa( const QModelIndex& ihexa ) bool DocumentModel::removeConnectedHexa( const QModelIndex& ihexa ) { bool ret = false; - HEXA_NS::Hexa* hHexa = data(ihexa, HEXA_DATA_ROLE).value(); + HEXA_NS::Hexa* hHexa = getHexaPtr(ihexa); int r = _hexaDocument->removeConnectedHexa( hHexa ); if ( r == HOK ){ updateData(); - QString tmp = "/tmp/removeConnectedHexa.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); ret = true; } else if ( r == HERR ){ ret = false; @@ -1710,8 +1414,8 @@ QModelIndex DocumentModel::prismQuad( const QModelIndex& iquad, const QModelInde { QModelIndex iElts; - HEXA_NS::Quad* hQuad = data(iquad, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hVect = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Quad* hQuad = getHexaPtr(iquad); + HEXA_NS::Vector* hVect = getHexaPtr(ivec); HEXA_NS::Elements* hElts = _hexaDocument->prismQuad( hQuad, hVect, nb ); @@ -1720,8 +1424,6 @@ QModelIndex DocumentModel::prismQuad( const QModelIndex& iquad, const QModelInde ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/prismQuad.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } @@ -1736,10 +1438,10 @@ QModelIndex DocumentModel::prismQuads( const QModelIndexList& iquads, const QMod HEXA_NS::Quads hQuads; HEXA_NS::Quad* hQuad = NULL; foreach( const QModelIndex& iquad, iquads ){ - hQuad = data( iquad, HEXA_DATA_ROLE ).value(); + hQuad = getHexaPtr(iquad); hQuads.push_back( hQuad ); } - HEXA_NS::Vector* hVect = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Vector* hVect = getHexaPtr(ivec); HEXA_NS::Elements* hElts = _hexaDocument->prismQuads( hQuads, hVect, nb ); if ( hElts->isValid() ){ @@ -1747,14 +1449,36 @@ QModelIndex DocumentModel::prismQuads( const QModelIndexList& iquads, const QMod ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/prismQuads.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } return iElts; } +QModelIndex DocumentModel::prismQuads( const QModelIndexList& iquads, const QModelIndex& ivec, std::vector layersSize, int nb) +{ + QModelIndex iElts; + + HEXA_NS::Quads hQuads; + HEXA_NS::Quad* hQuad = NULL; + foreach( const QModelIndex& iquad, iquads ){ + hQuad = getHexaPtr(iquad); + hQuads.push_back( hQuad ); + } + HEXA_NS::Vector* hVect = getHexaPtr(ivec); + + HEXA_NS::Elements* hElts = _hexaDocument->prismQuadsVec( hQuads, hVect, layersSize, nb ); + if ( hElts->isValid() ){ + updateData(); //CS_TODO more or less? + ElementsItem* elts = new ElementsItem(hElts); + _elementsDirItem->appendRow(elts); + iElts = elts->index(); + } else { + delete hElts; + } + return iElts; +} + // QModelIndex DocumentModel::joinQuad( const QModelIndex& iquadstart, const QModelIndex& iquaddest, @@ -1764,13 +1488,13 @@ QModelIndex DocumentModel::joinQuad( { QModelIndex iElts; - HEXA_NS::Quad* hQuadStart = data(iquadstart, HEXA_DATA_ROLE).value(); - HEXA_NS::Quad* hQuadDest = data(iquaddest, HEXA_DATA_ROLE).value(); + HEXA_NS::Quad* hQuadStart = getHexaPtr(iquadstart); + HEXA_NS::Quad* hQuadDest = getHexaPtr(iquaddest); - HEXA_NS::Vertex* hVertex0 = data(iv0, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVertex1 = data(iv1, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVertex2 = data(iv2, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVertex3 = data(iv3, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hVertex0 = getHexaPtr(iv0); + HEXA_NS::Vertex* hVertex1 = getHexaPtr(iv1); + HEXA_NS::Vertex* hVertex2 = getHexaPtr(iv2); + HEXA_NS::Vertex* hVertex3 = getHexaPtr(iv3); HEXA_NS::Elements* hElts = _hexaDocument->joinQuad( hQuadStart, hQuadDest, hVertex0, hVertex1, hVertex2, hVertex3, nb ); @@ -1780,8 +1504,6 @@ QModelIndex DocumentModel::joinQuad( ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/joinQuad.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } @@ -1806,10 +1528,10 @@ QModelIndex DocumentModel::joinQuads( } HEXA_NS::Quad* hQuadDest = data( iquaddest, HEXA_DATA_ROLE ).value(); - HEXA_NS::Vertex* hVertex0 = data(iv0, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVertex1 = data(iv1, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVertex2 = data(iv2, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVertex3 = data(iv3, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hVertex0 = getHexaPtr(iv0); + HEXA_NS::Vertex* hVertex1 = getHexaPtr(iv1); + HEXA_NS::Vertex* hVertex2 = getHexaPtr(iv2); + HEXA_NS::Vertex* hVertex3 = getHexaPtr(iv3); HEXA_NS::Elements* hElts = _hexaDocument->joinQuads( hQuadsStart, hQuadDest, @@ -1821,8 +1543,6 @@ QModelIndex DocumentModel::joinQuads( ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/joinQuads.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } @@ -1834,18 +1554,14 @@ bool DocumentModel::mergeVertices( const QModelIndex &iv0, const QModelIndex &iv { bool ret = false; - HEXA_NS::Vertex* hv0 = data(iv0, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv1 = data(iv1, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hv0 = getHexaPtr(iv0); + HEXA_NS::Vertex* hv1 = getHexaPtr(iv1); int r = _hexaDocument->mergeVertices( hv0, hv1 ); if ( r == HOK ){ updateData(); //CS_TODO more or less? - //std::cout << "DocumentModel:: mergeVertices => OK " << std::endl; - QString tmp = "/tmp/mergeVertices.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); ret = true; } else if ( r == HERR ){ - //std::cout << "DocumentModel:: mergeVertices => KO " << std::endl; ret = false; } @@ -1858,18 +1574,16 @@ bool DocumentModel::mergeEdges( const QModelIndex &ie0, const QModelIndex &ie1, { bool ret = false; - HEXA_NS::Edge* he0 = data(ie0, HEXA_DATA_ROLE).value(); - HEXA_NS::Edge* he1 = data(ie1, HEXA_DATA_ROLE).value(); + HEXA_NS::Edge* he0 = getHexaPtr(ie0); + HEXA_NS::Edge* he1 = getHexaPtr(ie1); - HEXA_NS::Vertex* hv0 = data(iv0, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv1 = data(iv1, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hv0 = getHexaPtr(iv0); + HEXA_NS::Vertex* hv1 = getHexaPtr(iv1); int r = _hexaDocument->mergeEdges( he0, he1, hv0, hv1 ); if ( r == HOK ){ updateData(); ret = true; - QString tmp = "/tmp/mergeEdges.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else if ( r == HERR ){ ret = false; } @@ -1886,17 +1600,15 @@ bool DocumentModel::mergeQuads( const QModelIndex& iquad0, const QModelIndex& iq HEXA_NS::Quad* hquad0 = data(iquad0, HEXA_DATA_ROLE).value(); HEXA_NS::Quad* hquad1 = data(iquad1, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv0 = data(iv0, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv1 = data(iv1, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv2 = data(iv2, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hv3 = data(iv3, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hv0 = getHexaPtr(iv0); + HEXA_NS::Vertex* hv1 = getHexaPtr(iv1); + HEXA_NS::Vertex* hv2 = getHexaPtr(iv2); + HEXA_NS::Vertex* hv3 = getHexaPtr(iv3); int r = _hexaDocument->mergeQuads( hquad0, hquad1, hv0, hv1, hv2, hv3 ); if ( r == HOK ){ updateData(); ret = true; - QString tmp = "/tmp/mergeQuads.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else if ( r == HERR ){ ret = false; } @@ -1909,8 +1621,8 @@ QModelIndex DocumentModel::disconnectVertex( const QModelIndex& ihexa, const QMo { QModelIndex iElts; - HEXA_NS::Hexa* hHexa = data( ihexa, HEXA_DATA_ROLE ).value(); - HEXA_NS::Vertex* hVertex = data( ivertex, HEXA_DATA_ROLE ).value(); + HEXA_NS::Hexa* hHexa = getHexaPtr(ihexa); + HEXA_NS::Vertex* hVertex = getHexaPtr(ivertex); HEXA_NS::Elements* hElts = _hexaDocument->disconnectVertex( hHexa, hVertex ); @@ -1919,8 +1631,6 @@ QModelIndex DocumentModel::disconnectVertex( const QModelIndex& ihexa, const QMo ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/disconnectVertex.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } @@ -1932,8 +1642,8 @@ QModelIndex DocumentModel::disconnectEdge( const QModelIndex& ihexa, const QMode { QModelIndex iElts; - HEXA_NS::Hexa* hHexa = data( ihexa, HEXA_DATA_ROLE ).value(); - HEXA_NS::Edge* hEdge = data( iedge, HEXA_DATA_ROLE ).value(); + HEXA_NS::Hexa* hHexa = getHexaPtr(ihexa); + HEXA_NS::Edge* hEdge = getHexaPtr(iedge); HEXA_NS::Elements* hElts = _hexaDocument->disconnectEdge( hHexa, hEdge ); @@ -1942,8 +1652,6 @@ QModelIndex DocumentModel::disconnectEdge( const QModelIndex& ihexa, const QMode ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/disconnectEdge.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } @@ -1962,14 +1670,14 @@ QModelIndex DocumentModel::disconnectEdges( const QModelIndexList& ihexas, const //Construction de la liste des edges HEXA_NS::Edge* hedge = NULL; foreach( const QModelIndex& iedge, iedges ){ - hedge = data( iedge, HEXA_DATA_ROLE ).value(); + hedge = getHexaPtr(iedge); hEdges.push_back( hedge ); } //Construction de la liste des hexas HEXA_NS::Hexa* hhexa = NULL; foreach( const QModelIndex& ihexa, ihexas ){ - hhexa = data( ihexa, HEXA_DATA_ROLE ).value(); + hhexa = getHexaPtr(ihexa); hHexas.push_back( hhexa ); } @@ -1981,8 +1689,6 @@ QModelIndex DocumentModel::disconnectEdges( const QModelIndexList& ihexas, const ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/disconnectEdges.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } @@ -1995,8 +1701,8 @@ QModelIndex DocumentModel::disconnectQuad( const QModelIndex& ihexa, const QMode { QModelIndex iElts; - HEXA_NS::Hexa* hHexa = data( ihexa, HEXA_DATA_ROLE ).value(); - HEXA_NS::Quad* hQuad = data( iquad, HEXA_DATA_ROLE ).value(); + HEXA_NS::Hexa* hHexa = getHexaPtr(ihexa); + HEXA_NS::Quad* hQuad = getHexaPtr(iquad); HEXA_NS::Elements* hElts = _hexaDocument->disconnectQuad( hHexa, hQuad ); @@ -2005,8 +1711,6 @@ QModelIndex DocumentModel::disconnectQuad( const QModelIndex& ihexa, const QMode ElementsItem* elts = new ElementsItem(hElts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/disconnectQuad.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hElts; } @@ -2020,7 +1724,7 @@ QModelIndex DocumentModel::cutEdge( const QModelIndex &i_e0, int nbcuts ) { QModelIndex iElts; - HEXA_NS::Edge* he0 = data(i_e0, HEXA_DATA_ROLE).value(); + HEXA_NS::Edge* he0 = getHexaPtr(i_e0); HEXA_NS::Elements* helts = _hexaDocument->cut( he0, nbcuts ); if ( helts->isValid() ){ @@ -2028,8 +1732,6 @@ QModelIndex DocumentModel::cutEdge( const QModelIndex &i_e0, int nbcuts ) ElementsItem* elts = new ElementsItem(helts); _elementsDirItem->appendRow(elts); iElts = elts->index(); - QString tmp = "/tmp/cutEdge.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete helts; } @@ -2046,8 +1748,8 @@ QModelIndex DocumentModel::makeTranslation( const QModelIndex& ielts, const QMod { QModelIndex iElts; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hVec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vector* hVec = getHexaPtr(ivec); HEXA_NS::Elements* hNewElts = _hexaDocument->makeTranslation( hElts, hVec ); @@ -2056,8 +1758,6 @@ QModelIndex DocumentModel::makeTranslation( const QModelIndex& ielts, const QMod ElementsItem* eltsItem = new ElementsItem(hNewElts); _elementsDirItem->appendRow(eltsItem); iElts = eltsItem->index(); - QString tmp = "/tmp/makeTranslation.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hNewElts; } @@ -2071,8 +1771,8 @@ QModelIndex DocumentModel::makeScale( const QModelIndex& ielts, const QModelInde { QModelIndex iElts; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVex = data(ivex, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vertex* hVex = getHexaPtr(ivex); HEXA_NS::Elements* hNewElts = _hexaDocument->makeScale( hElts, hVex, k ); @@ -2081,8 +1781,6 @@ QModelIndex DocumentModel::makeScale( const QModelIndex& ielts, const QModelInde ElementsItem* eltsItem = new ElementsItem(hNewElts); _elementsDirItem->appendRow(eltsItem); iElts = eltsItem->index(); - QString tmp = "/tmp/makeScale.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hNewElts; } @@ -2098,9 +1796,9 @@ QModelIndex DocumentModel::makeRotation( const QModelIndex& ielts, { QModelIndex iElts; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVex = data(iv, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hVec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vertex* hVex = getHexaPtr(iv); + HEXA_NS::Vector* hVec = getHexaPtr(ivec); HEXA_NS::Elements* hNewElts = _hexaDocument->makeRotation( hElts, hVex, hVec, angle ); @@ -2109,8 +1807,6 @@ QModelIndex DocumentModel::makeRotation( const QModelIndex& ielts, ElementsItem* eltsItem = new ElementsItem(hNewElts); _elementsDirItem->appendRow(eltsItem); iElts = eltsItem->index(); - QString tmp = "/tmp/makeRotation.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hNewElts; } @@ -2123,8 +1819,8 @@ QModelIndex DocumentModel::makeSymmetryPoint( const QModelIndex& ielts, const QM { QModelIndex iElts; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVex = data(iv, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vertex* hVex = getHexaPtr(iv); HEXA_NS::Elements* hNewElts = _hexaDocument->makeSymmetryPoint (hElts, hVex); @@ -2133,8 +1829,6 @@ QModelIndex DocumentModel::makeSymmetryPoint( const QModelIndex& ielts, const QM ElementsItem* eltsItem = new ElementsItem(hNewElts); _elementsDirItem->appendRow(eltsItem); iElts = eltsItem->index(); - QString tmp = "/tmp/makeSymmetryPoint.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hNewElts; } @@ -2149,9 +1843,10 @@ QModelIndex DocumentModel::makeSymmetryLine( const QModelIndex& ielts, { QModelIndex iElts; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVex = data(iv, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hVec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vertex* hVex = getHexaPtr(iv); + HEXA_NS::Vector* hVec = getHexaPtr(ivec); + HEXA_NS::Elements* hNewElts = _hexaDocument->makeSymmetryLine( hElts, hVex, hVec ); @@ -2160,8 +1855,6 @@ QModelIndex DocumentModel::makeSymmetryLine( const QModelIndex& ielts, ElementsItem* eltsItem = new ElementsItem(hNewElts); _elementsDirItem->appendRow(eltsItem); iElts = eltsItem->index(); - QString tmp = "/tmp/makeSymmetryLine.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hNewElts; } @@ -2174,9 +1867,9 @@ QModelIndex DocumentModel::makeSymmetryPlane( const QModelIndex& ielts, const QM { QModelIndex iElts; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVex = data(iv, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hVec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vertex* hVex = getHexaPtr(iv); + HEXA_NS::Vector* hVec = getHexaPtr(ivec); HEXA_NS::Elements* hNewElts = _hexaDocument->makeSymmetryPlane( hElts, hVex, hVec ); @@ -2185,8 +1878,6 @@ QModelIndex DocumentModel::makeSymmetryPlane( const QModelIndex& ielts, const QM ElementsItem* eltsItem = new ElementsItem(hNewElts); _elementsDirItem->appendRow(eltsItem); iElts = eltsItem->index(); - QString tmp = "/tmp/makeSymmetryPlane.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else { delete hNewElts; } @@ -2199,15 +1890,13 @@ bool DocumentModel::performTranslation( const QModelIndex& ielts, const QModelIn { bool ret = false; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hVec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vector* hVec = getHexaPtr(ivec); int r = _hexaDocument->performTranslation (hElts, hVec); if ( r == HOK ){ updateData(); ret = true; - QString tmp = "/tmp/performTranslation.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else if ( r == HERR ){ ret = false; } @@ -2221,15 +1910,13 @@ bool DocumentModel::performScale( const QModelIndex& ielts, const QModelIndex& i { bool ret = false; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVex = data(ivex, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vertex* hVex = getHexaPtr(ivex); int r = _hexaDocument->performScale (hElts, hVex, k); if ( r == HOK ){ updateData(); ret = true; - QString tmp = "/tmp/performScale.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else if ( r == HERR ){ ret = false; } @@ -2242,16 +1929,14 @@ bool DocumentModel::performRotation( const QModelIndex& ielts, const QModelIndex { bool ret = false; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVex = data(ivex, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hVec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vertex* hVex = getHexaPtr(ivex); + HEXA_NS::Vector* hVec = getHexaPtr(ivec); int r = _hexaDocument-> performRotation( hElts, hVex, hVec, angle ); if ( r == HOK ){ updateData(); ret = true; - QString tmp = "/tmp/performRotation.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else if ( r == HERR ){ ret = false; } @@ -2265,15 +1950,13 @@ bool DocumentModel::performSymmetryPoint( const QModelIndex& ielts, const QModel { bool ret = false; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVex = data(ivex, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vertex* hVex = getHexaPtr(ivex); int r = _hexaDocument->performSymmetryPoint( hElts, hVex ); if ( r == HOK ){ updateData(); ret = true; - QString tmp = "/tmp/performSymmetryPoint.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else if ( r == HERR ){ ret = false; } @@ -2286,16 +1969,14 @@ bool DocumentModel::performSymmetryLine( const QModelIndex& ielts, const QModelI { bool ret = false; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVex = data(ivex, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hVec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vertex* hVex = getHexaPtr(ivex); + HEXA_NS::Vector* hVec = getHexaPtr(ivec); int r = _hexaDocument->performSymmetryLine( hElts, hVex, hVec ); if ( r == HOK ){ updateData(); ret = true; - QString tmp = "/tmp/performSymmetryLine.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else if ( r == HERR ){ ret = false; } @@ -2310,16 +1991,14 @@ bool DocumentModel::performSymmetryPlane( const QModelIndex& ielts, { bool ret = false; - HEXA_NS::Elements* hElts = data(ielts, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hVex = data(ivex, HEXA_DATA_ROLE).value(); - HEXA_NS::Vector* hVec = data(ivec, HEXA_DATA_ROLE).value(); + HEXA_NS::Elements* hElts = getHexaPtr(ielts); + HEXA_NS::Vertex* hVex = getHexaPtr(ivex); + HEXA_NS::Vector* hVec = getHexaPtr(ivec); int r = _hexaDocument->performSymmetryPlane( hElts, hVex, hVec ); if ( r == HOK ){ updateData(); ret = true; - QString tmp = "/tmp/performSymmetryPlane.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else if ( r == HERR ){ ret = false; } @@ -2340,8 +2019,8 @@ QModelIndex DocumentModel::revolutionQuads( const QModelIndexList& istartquads, hquad = data( iquad, HEXA_DATA_ROLE ).value(); hstartquads.push_back( hquad ); } - HEXA_NS::Vertex* hcenter = data( icenter, HEXA_DATA_ROLE ).value(); - HEXA_NS::Vector* haxis = data( ivecaxis, HEXA_DATA_ROLE ).value(); + HEXA_NS::Vertex* hcenter = getHexaPtr(icenter); + HEXA_NS::Vector* haxis = getHexaPtr(ivecaxis); std::vector hangles = angles.toVector().toStdVector(); HEXA_NS::Elements* helts = _hexaDocument->revolutionQuads( hstartquads, hcenter, haxis, hangles ); @@ -2365,17 +2044,17 @@ QModelIndex DocumentModel::replace( const QModelIndexList& iquadsPattern, { QModelIndex ielts; - HEXA_NS::Vertex* hp1 = data(ip1, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hc1 = data(ic1, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hp2 = data(ip2, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hc2 = data(ic2, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hp3 = data(ip3, HEXA_DATA_ROLE).value(); - HEXA_NS::Vertex* hc3 = data(ic3, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hp1 = getHexaPtr(ip1); + HEXA_NS::Vertex* hc1 = getHexaPtr(ic1); + HEXA_NS::Vertex* hp2 = getHexaPtr(ip2); + HEXA_NS::Vertex* hc2 = getHexaPtr(ic2); + HEXA_NS::Vertex* hp3 = getHexaPtr(ip3); + HEXA_NS::Vertex* hc3 = getHexaPtr(ic3); HEXA_NS::Quads hquads; HEXA_NS::Quad* hquad = NULL; foreach( const QModelIndex& iquad, iquadsPattern ){ - hquad = data( iquad, HEXA_DATA_ROLE ).value(); + hquad = getHexaPtr(iquad); hquads.push_back( hquad ); } @@ -2409,13 +2088,13 @@ void DocumentModel::addAssociation( const QModelIndex& iElt, const DocumentModel QString currentAssoc, newAssoc; if ( data(iElt, HEXA_TREE_ROLE) == VERTEX_TREE ){ - HEXA_NS::Vertex* hVex = data(iElt, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex* hVex = getHexaPtr(iElt); hVex->setAssociation( assoc ); } else if ( data(iElt, HEXA_TREE_ROLE) == EDGE_TREE ){ - HEXA_NS::Edge* hEdge = data(iElt, HEXA_DATA_ROLE).value(); + HEXA_NS::Edge* hEdge = getHexaPtr(iElt); hEdge->addAssociation( assoc ); } else if ( data(iElt, HEXA_TREE_ROLE) == QUAD_TREE ){ - HEXA_NS::Quad* hQuad = data(iElt, HEXA_DATA_ROLE).value(); + HEXA_NS::Quad* hQuad = getHexaPtr(iElt); hQuad->addAssociation( assoc ); } @@ -2426,29 +2105,7 @@ void DocumentModel::addAssociation( const QModelIndex& iElt, const DocumentModel newAssoc = assocIn.entry + "," + assocIn.subid + ";"; } - //std::cout << "addAssociation() newAssoc =>" << newAssoc.toStdString() << std::endl; setData( iElt, QVariant::fromValue(newAssoc), HEXA_ASSOC_ENTRY_ROLE ); - - // tree view : -/* - QList assocItems; - QStandardItem *aAssocItem = NULL; - - QStandardItem *item = NULL; - - aAssocItem = new QStandardItem(assocIn.name); - aAssocItem->setData( assocIn.entry + "," + assocIn.subid, HEXA_ENTRY_ROLE ); - - - assocItems << aAssocItem; - item = itemFromIndex(iElt); - item->appendColumn(assocItems); -// appendColumn(assocItems); -// item->appendRow( assocItems ); -// item->appendRow( new QStandardItem(assocIn.name) ); - if ( item->columnCount() > columnCount() ) - setColumnCount( columnCount()+1 ); -*/ } @@ -2461,7 +2118,8 @@ QList DocumentModel::getAssociations( const QModelIndex& //std::cout << "getAssociations() start" << std::endl; if ( data(iElt, HEXA_TREE_ROLE) == VERTEX_TREE ){ MESSAGE("* of a Vertex"); - HEXA_NS::Vertex* hVex = data(iElt, HEXA_DATA_ROLE).value(); +// HEXA_NS::Vertex* hVex = data(iElt, HEXA_DATA_ROLE).value(); + HEXA_NS::Vertex *hVex = getHexaPtr(iElt); HEXA_NS::Shape* hShape = hVex->getAssociation(); QStringList shapeID; if ( hShape != NULL ){ @@ -2485,7 +2143,7 @@ QList DocumentModel::getAssociations( const QModelIndex& } } else if ( data(iElt, HEXA_TREE_ROLE) == EDGE_TREE ){ MESSAGE("* of an Edge"); - HEXA_NS::Edge* hEdge = data(iElt, HEXA_DATA_ROLE).value(); + HEXA_NS::Edge* hEdge = getHexaPtr(iElt); HEXA_NS::Shapes hShapes = hEdge->getAssociations(); QStringList shapeID; for ( HEXA_NS::Shapes::iterator it = hShapes.begin(); it != hShapes.end(); ++it){ @@ -2513,7 +2171,7 @@ QList DocumentModel::getAssociations( const QModelIndex& } } else if ( data(iElt, HEXA_TREE_ROLE) == QUAD_TREE ){ MESSAGE("* of a Quad"); - HEXA_NS::Quad* hQuad = data(iElt, HEXA_DATA_ROLE).value(); + HEXA_NS::Quad* hQuad = getHexaPtr(iElt); HEXA_NS::Shapes hShapes = hQuad->getAssociations(); QStringList shapeID; for ( HEXA_NS::Shapes::iterator it = hShapes.begin(); it != hShapes.end(); ++it){ @@ -2564,7 +2222,7 @@ bool DocumentModel::associateOpenedLine( const QModelIndexList& iedges, HEXA_NS::Edge* hedge = NULL; foreach( const QModelIndex& iedge, iedges ){ - hedge = data( iedge, HEXA_DATA_ROLE ).value(); + hedge = getHexaPtr(iedge); if ( mstart == NULL ){ mstart = hedge; MESSAGE("* mstart" << iedge.data().toString().toStdString() ); @@ -2602,16 +2260,6 @@ bool DocumentModel::associateOpenedLine( const QModelIndexList& iedges, int r = _hexaDocument->associateOpenedLine( mstart, mline, gstart, pstart, gline, pend ); -// HEXA_NS::Edge *e0 = _hexaDocument->getEdge(0); -// HEXA_NS::Edge *e1 = _hexaDocument->getEdge(1); -// HEXA_NS::Shapes mstartAssoc = e0->getAssociations(); -// HEXA_NS::Shapes mlineAssoc = e1->getAssociations(); -// HEXA_NS::Shapes mstartAssoc = mstart->getAssociations(); -// HEXA_NS::Shapes mlineAssoc= mline[0]->getAssociations(); -// std::cout << "DocumentModel:: associateOpenedLine : mstartAssoc.size() => " << mstartAssoc.size() << std::endl; -// std::cout << "DocumentModel:: associateOpenedLine : mstartAssoc[0]->ident=> " << mstartAssoc[0]->ident << std::endl; -// std::cout << "DocumentModel:: associateOpenedLine : mlineAssoc[0]->ident => " << mlineAssoc[0]->ident << std::endl; - if ( r == HOK ){ updateData(); MESSAGE("* DocumentModel:: associateOpenedLine() => OK "); @@ -2632,7 +2280,7 @@ bool DocumentModel::associateClosedLine( const QModelIndex& ivertex, { MESSAGE("DocumentModel::associateClosedLine() "); bool ret = false; - HEXA_NS::Vertex* mfirst = data( ivertex, HEXA_DATA_ROLE ).value(); + HEXA_NS::Vertex* mfirst = getHexaPtr(ivertex); HEXA_NS::Edge* mstart = NULL; HEXA_NS::Edges mline; HEXA_NS::Shape* gstart = NULL; @@ -2642,7 +2290,7 @@ bool DocumentModel::associateClosedLine( const QModelIndex& ivertex, HEXA_NS::Edge* hedge = NULL; foreach( const QModelIndex& iedge, iedges ){ - hedge = data( iedge, HEXA_DATA_ROLE ).value(); + hedge = getHexaPtr(iedge); if ( mstart == NULL ){ mstart = hedge; MESSAGE("* mstart" << iedge.data().toString().toStdString() ); @@ -2680,10 +2328,8 @@ bool DocumentModel::associateClosedLine( const QModelIndex& ivertex, gstart, pstart, inv, gline ); if ( r == HOK ){ updateData(); - //std::cout << "DocumentModel:: associateClosedLine => OK " << std::endl; ret = true; } else if ( r == HERR ){ - //std::cout << "DocumentModel:: associateClosedLine => ERR " << std::endl; ret = false; } return ret; @@ -2701,8 +2347,6 @@ QModelIndex DocumentModel::addGroup( const QString& name, Group kind ) groupItem->setData( _entry, HEXA_DOC_ENTRY_ROLE ); _groupDirItem->appendRow(groupItem); iGroup = groupItem->index(); - QString tmp = "/tmp/addGroup.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); return iGroup; } @@ -2718,13 +2362,17 @@ bool DocumentModel::removeGroup( const QModelIndex& igrp ) if ( r == HOK ){ removeRow( igrp.row(), igrp.parent()); ret = true; - QString tmp = "/tmp/removeGroup.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else if ( r == HERR ){ ret = false; } return ret; } +/* +QModelIndex* DocumentModel::found(eltBase) +{ + TODO_JMD +} +*/ QModelIndexList DocumentModel::getGroupElements( const QModelIndex& iGroup, DocumentModel::Group& kind ) const { @@ -2738,7 +2386,6 @@ QModelIndexList DocumentModel::getGroupElements( const QModelIndex& iGroup, Docu HEXA_NS::EltBase* eltBase = NULL; for ( int nr = 0; nr < g->countElement(); ++nr ){ eltBase = g->getElement( nr ); - //std::cout<< "eltBase"<< eltBase << std::endl; kind = g->getKind(); switch ( kind ){ case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: q = QVariant::fromValue( (HEXA_NS::Hexa *)eltBase ); break; @@ -2767,8 +2414,6 @@ void DocumentModel::setGroupName( const QModelIndex& igrp, const QString& name ) setData(igrp, QVariant::fromValue( name ) ); } - QString tmp = "/tmp/setGroupName.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } bool DocumentModel::addGroupElement( const QModelIndex& igrp, const QModelIndex& ielt ) @@ -2777,26 +2422,20 @@ bool DocumentModel::addGroupElement( const QModelIndex& igrp, const QModelIndex& bool addOk = false; HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value(); - HEXA_NS::EltBase* hElt = NULL; + HEXA_NS::EltBase* hElt = NULL; switch ( hGroup->getKind() ){ - case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: hElt = data(ielt, HEXA_DATA_ROLE).value(); break; - case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: hElt = data(ielt, HEXA_DATA_ROLE).value(); break; - case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: hElt = data(ielt, HEXA_DATA_ROLE).value(); break; - case HEXA_NS::VertexNode: hElt = data(ielt, HEXA_DATA_ROLE).value(); break; + case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: hElt = getHexaPtr(ielt); break; + case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: hElt = getHexaPtr(ielt); break; + case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: hElt = getHexaPtr(ielt); break; + case HEXA_NS::VertexNode: hElt = getHexaPtr(ielt); break; } - //std::cout << "hGroup" << hGroup << std::endl; - //std::cout << "hElt" << hElt << std::endl; - int res = HERR; if ( hGroup and hElt ) res = hGroup->addElement( hElt ); if ( res == HOK ) addOk = true; -// QString tmp = "/tmp/addGroupElement.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); - return addOk; } @@ -2805,10 +2444,11 @@ bool DocumentModel::removeGroupElement( const QModelIndex& igrp, int nro ) HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value(); if ( hGroup ) - hGroup->removeElement( nro ); - - QString tmp = "/tmp/removeGroupElement.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); + { + if (hGroup->removeElement( nro ) == HOK) + return true; + } + return false; } bool DocumentModel::clearGroupElement( const QModelIndex& igrp ) @@ -2816,10 +2456,11 @@ bool DocumentModel::clearGroupElement( const QModelIndex& igrp ) HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value(); if ( hGroup ) + { hGroup->clearElement(); - - QString tmp = "/tmp/clearGroupElement.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); + return true; + } + return false; } // ************ LAWS ************ @@ -2834,8 +2475,6 @@ QModelIndex DocumentModel::addLaw( const QString& name, int nbnodes ) LawItem* lawItem = new LawItem(hLaw); _lawDirItem->appendRow(lawItem); iLaw = lawItem->index(); - QString tmp = "/tmp/addLaw.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); return iLaw; } @@ -2854,8 +2493,6 @@ bool DocumentModel::setLaw( const QModelIndex& ilaw, int nbnodes, double coeff, hLaw->setKind(type); } - QString tmp = "/tmp/setLaw.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); return ret; } @@ -2869,8 +2506,6 @@ bool DocumentModel::removeLaw( const QModelIndex& ilaw ) if ( r == HOK ){ removeRow( ilaw.row(), ilaw.parent()); ret = true; - QString tmp = "/tmp/removeLaw.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else if ( r == HERR ){ ret = false; } @@ -2889,8 +2524,6 @@ bool DocumentModel::setPropagation( const QModelIndex& iPropagation, const QMode if ( r == HOK ){ ret = true; - QString tmp = "/tmp/setPropagation.vtk"; - //_hexaDocument->saveVtk( tmp.toLocal8Bit().constData() ); } else if ( r == HERR ){ ret = false; } @@ -2931,20 +2564,6 @@ QString DocumentModel::documentEntry() return _entry; } -// QModelIndex DocumentModel::indexBy( int role, const QString& value ) -// { -// QModelIndex eltIndex; // element (vertex, edge, quad) of model -// QModelIndexList theIndexes = match( index(0, 0), -// role, -// value, -// 1, -// Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString ); -// if ( theIndexes.count()>0 ) -// eltIndex = theIndexes[0] ; -// return eltIndex; -// } - - // 8.3 Boite: éditer une loi CS_TODO // (idem création) @@ -2992,14 +2611,6 @@ Qt::ItemFlags PatternDataModel::flags(const QModelIndex &index) const if ( m != NULL ){ flags = m->flags( mapToSource(index) ); } - -// if ( flags == Qt::ItemFlags( ~Qt::ItemIsEditable ) ){ -// MESSAGE("* you can select "<< index.data().toString().toStdString() ); -// } else { -// MESSAGE("* you cannot select "<< index.data().toString().toStdString() ); -// } - -// MESSAGE("}"); return flags; } @@ -3013,105 +2624,6 @@ QVariant PatternDataModel::headerData ( int section, Qt::Orientation orientation } } -// QModelIndex PatternDataModel::addVertex( double x, double y, double z ) -// { -// QModelIndex vertexIndex; -// DocumentModel *m = dynamic_cast( sourceModel() ); -// if ( m != NULL ){ -// QModelIndex sourceIndex = m->addVertex( x, y, z ); -// vertexIndex = mapFromSource(sourceIndex); -// } -// return vertexIndex; -// } -// -// void PatternDataModel::updateVertex(const QModelIndex& i_v) -// { -// std::cout << "PatternDataModel::updateVertex()" << std::endl; -// VertexItem *item_v = dynamic_cast(itemFromIndex(i_v)); -// DocumentModel *m = dynamic_cast( sourceModel() ); -// -// if (item_v != NULL) -// { -// std::cout << "updateVertex() : OK" << std::endl; -// m->updateView(item_v); -// -// } -// else -// { -// std::cout << "updateVertex() : NOT OK" << std::endl; -// -// } -// } -// -// -// QModelIndex PatternDataModel::addQuad( const QModelIndex &i_v0, const QModelIndex &i_v1, -// const QModelIndex &i_v2, const QModelIndex &i_v3 ) -// { -// QModelIndex quadIndex; -// DocumentModel *m = dynamic_cast( sourceModel() ); -// if ( m != NULL ){ -// QModelIndex sourceIndex = m->addQuad( mapToSource(i_v0), mapToSource(i_v1), -// mapToSource(i_v2), mapToSource(i_v3) ); -// quadIndex = mapFromSource(sourceIndex); -// } -// return quadIndex; -// } -// -// -// -// QModelIndex PatternDataModel::addHexaFromQuad( const QModelIndex &i_q0, const QModelIndex &i_q1, const QModelIndex &i_q2, -// const QModelIndex &i_q3, const QModelIndex &i_q4, const QModelIndex &i_q5 ) -// { -// QModelIndex hexaIndex; -// DocumentModel *m = dynamic_cast( sourceModel() ); -// if ( m != NULL ){ -// QModelIndex sourceIndex = m->addHexaFromQuad( mapToSource(i_q0), mapToSource(i_q1), mapToSource(i_q2), -// mapToSource(i_q3), mapToSource(i_q4), mapToSource(i_q5) ); -// hexaIndex = mapFromSource(sourceIndex); -// } -// return hexaIndex; -// } -// -// -// -// -// -// -// bool PatternDataModel::mergeVertices( const QModelIndex &i_v0, const QModelIndex &i_v1 ) -// { -// bool ret = false; -// DocumentModel *m = dynamic_cast( sourceModel() ); -// if ( m != NULL ){ -// ret = m->mergeVertices( mapToSource(i_v0), mapToSource(i_v1) ); -// } -// return ret; -// } -// -// bool PatternDataModel::mergeEdges( const QModelIndex &i_e0, const QModelIndex &i_e1, -// const QModelIndex &i_v0, const QModelIndex &i_v1 ) -// { -// bool ret = false; -// DocumentModel *m = dynamic_cast( sourceModel() ); -// if ( m != NULL ){ -// ret = m->mergeEdges( mapToSource(i_e0), mapToSource(i_e1), -// mapToSource(i_v0), mapToSource(i_v1) ); -// } -// return ret; -// } -// -// QModelIndex PatternDataModel::cutEdge( const QModelIndex &i_e0, int nbcuts ) -// { -// QModelIndex elementsIndex; -// DocumentModel *m = dynamic_cast( sourceModel() ); -// if ( m != NULL ){ -// QModelIndex sourceElementsIndex = m->cutEdge( mapToSource(i_e0), nbcuts ); -// std::cout << " sourceElementsIndex.isValid() => " << sourceElementsIndex.isValid() << std::endl; -// elementsIndex = mapFromSource(sourceElementsIndex); -// std::cout << " elementsIndex.isValid() => " << elementsIndex.isValid() << std::endl; -// } -// return elementsIndex; -// } - QStandardItem* PatternDataModel::itemFromIndex ( const QModelIndex & index ) const { @@ -3170,40 +2682,6 @@ QStandardItem* PatternBuilderModel::itemFromIndex ( const QModelIndex & index ) return item; } -// QModelIndex PatternBuilderModel::addVector( double dx, double dy, double dz ) -// { -// std::cout << "PatternBuilderModel::addVector" << std::endl; -// QModelIndex vectorIndex; -// -// DocumentModel *m = dynamic_cast( sourceModel() ); -// if ( m != NULL ){ -// std::cout << "PatternBuilderModel::addVector m != NULL " << std::endl; -// QModelIndex sourceIndex = m->addVector( dx, dy, dz ); -// vectorIndex = mapFromSource(sourceIndex); -// } -// return vectorIndex; -// } -// -// -// QModelIndex PatternBuilderModel::makeCartesian( const QModelIndex& i_pt, -// const QModelIndex& i_vec_x, const QModelIndex& i_vec_y, const QModelIndex& i_vec_z, -// long nx, long ny, long nz) -// { -// std::cout << " PatternBuilderModel::makeCartesian()"<< std::endl; -// QModelIndex elementsIndex; -// DocumentModel *m = dynamic_cast( sourceModel() ); -// if ( m != NULL ){ -// QModelIndex sourceElementsIndex = m->makeCartesian( -// mapToSource(i_pt), -// mapToSource(i_vec_x), mapToSource(i_vec_y), mapToSource(i_vec_z), -// nx, ny, nz ); -// std::cout << " sourceElementsIndex.isValid() => " << sourceElementsIndex.isValid() << std::endl; -// elementsIndex = mapFromSource(sourceElementsIndex); -// std::cout << " elementsIndex.isValid() => " << elementsIndex.isValid() << std::endl; -// } -// return elementsIndex; -// } - AssociationsModel::AssociationsModel( QObject * parent ) : QSortFilterProxyModel( parent ) { @@ -3219,7 +2697,6 @@ AssociationsModel::~AssociationsModel() Qt::ItemFlags AssociationsModel::flags(const QModelIndex &index) const { -// std::cout<<"AssociationsModel::flags()"<( sourceModel() ); @@ -3263,22 +2740,12 @@ GroupsModel::~GroupsModel() Qt::ItemFlags GroupsModel::flags(const QModelIndex &index) const { -// MESSAGE("GroupsModel::flags() "<< index.data().toString().toStdString() ); Qt::ItemFlags flags; DocumentModel *m = dynamic_cast( sourceModel() ); if ( m != NULL ){ -// MESSAGE("* ( m != NULL ) "<< index.data().toString().toStdString() ); flags = m->flags( mapToSource(index) ); - } else { -// MESSAGE("* ( m is NULL ) "<< index.data().toString().toStdString() ); - } -// if ( flags == Qt::ItemFlags( ~Qt::ItemIsEditable ) ){ -// MESSAGE("* flags == Qt::ItemFlags( ~Qt::ItemIsEditable ) "<< index.data().toString().toStdString() ); -// } else { -// MESSAGE("* flags is not Qt::ItemFlags( ~Qt::ItemIsEditable ) "<< index.data().toString().toStdString() ); -// } -// MESSAGE("}"); + } return flags; } @@ -3326,22 +2793,12 @@ MeshModel::~MeshModel() Qt::ItemFlags MeshModel::flags(const QModelIndex &index) const { -// MESSAGE("MeshModel::flags() "<< index.data().toString().toStdString() ); Qt::ItemFlags flags; DocumentModel *m = dynamic_cast( sourceModel() ); if ( m != NULL ){ -// MESSAGE("* ( m != NULL ) "<< index.data().toString().toStdString() ); flags = m->flags( mapToSource(index) ); - } else { -// MESSAGE("* ( m is NULL ) "<< index.data().toString().toStdString() ); - } -// if ( flags == Qt::ItemFlags( ~Qt::ItemIsEditable ) ){ -// MESSAGE("* you can select "<< index.data().toString().toStdString() ); -// } else { -// MESSAGE("* you cannot select "<< index.data().toString().toStdString() ); -// } -// MESSAGE("}"); + } return flags; } diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.hxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.hxx index a16a479..20b3227 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.hxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.hxx @@ -25,6 +25,8 @@ #include #include +#include "GEOM_GenericObjPtr.h" + #include "HEXABLOCKGUI_DocumentItem.hxx" #include "HexDocument.hxx" @@ -65,7 +67,7 @@ namespace HEXABLOCK QString getName(); void load( const QString& xmlFileName ); void save( const QString& xmlFileName ); - + struct GeomObj* convertToGeomObj(GEOM::GeomObjPtr geomObjPtr); void updateData(); void clearAll(); @@ -104,8 +106,19 @@ namespace HEXABLOCK void allowLawSelectionOnly(); + HEXA_NS::EltBase* getHexaPtr(const QModelIndex& iElt); + template + T getHexaPtr(QModelIndex iElt) + { + if (iElt.isValid()) + return iElt.data( HEXA_DATA_ROLE ).value< T >(); + + return NULL; + } + void setName( const QModelIndex& iElt, const QString& name ); bool clearEltAssociations( const QModelIndex& iElt ); + HEXA_NS::Hexa* getQuadHexa(HEXA_NS::Quad* quad); // ************ BUILD HEXABLOCK MODEL ************ QModelIndex addVertex( double x, double y, double z ); @@ -213,7 +226,7 @@ namespace HEXABLOCK // QModelIndex prismQuad( const QModelIndex& quad, const QModelIndex& dv, int nb); QModelIndex prismQuads( const QModelIndexList& quads, const QModelIndex& dv, int nb); - + QModelIndex prismQuads( const QModelIndexList& quads, const QModelIndex& dv, std::vector, int nb=0); // QModelIndex joinQuad( const QModelIndex& start_q, const QModelIndex& dest_q, @@ -240,7 +253,7 @@ namespace HEXABLOCK QModelIndex disconnectVertex( const QModelIndex& h, const QModelIndex& v ); QModelIndex disconnectEdge( const QModelIndex& h, const QModelIndex& e ); QModelIndex disconnectQuad( const QModelIndex& h, const QModelIndex& q ); - QModelIndex disconnectEdges( const QModelIndexList& h, const QModelIndexList& e ); + QModelIndex disconnectEdges( const QModelIndexList& h, const QModelIndexList& e ); // QModelIndex cutEdge( const QModelIndex &e, int nbcuts ); diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.cxx index 91c790c..27203c1 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.cxx @@ -57,6 +57,7 @@ #include "SVTK_Selection.h" #include #include +#include #include @@ -72,9 +73,13 @@ #include "GEOMBase.h" #include "GEOM_Operation.h" - +#define BUTTON_BOX_MIN_WIDTH 5 #define VERTEX_COORD_MIN -1000000 #define VERTEX_COORD_MAX 1000000 +#define SPINBOX_ANGLE_MAX 360 +#define SPINBOX_DOUBLE_MAX 1000000000 +#define SPINBOX_POSITIVE_DOUBLE_MIN 0 +#define NB_DECIMALS 6 using namespace std; @@ -91,7 +96,9 @@ public: QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const{ - return new QDoubleSpinBox( parent ); + QDoubleSpinBox *sb = new QDoubleSpinBox( parent ); + sb->setDecimals(NB_DECIMALS); + return sb; } }; @@ -103,8 +110,9 @@ public: QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const{ QDoubleSpinBox *sb = new QDoubleSpinBox( parent ); - sb->setMinimum(0); - sb->setMaximum(360); + sb->setMinimum(SPINBOX_POSITIVE_DOUBLE_MIN); + sb->setMaximum(SPINBOX_ANGLE_MAX); + sb->setDecimals(NB_DECIMALS); return sb; } }; @@ -118,14 +126,14 @@ public: QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const{ QDoubleSpinBox *sb = new QDoubleSpinBox( parent ); - sb->setMinimum(0); + sb->setMinimum(SPINBOX_POSITIVE_DOUBLE_MIN); /////// sb->setMaximum(1000000000000000); //10e15 Abu : Pb en 32 bits - sb->setMaximum(1000000000); //10e9 + sb->setMaximum(SPINBOX_DOUBLE_MAX); //10e9 + sb->setDecimals(NB_DECIMALS); return sb; } }; - // ======================================================== Constructeur HexaBaseDialog::HexaBaseDialog( QWidget * parent, Mode editmode, Qt::WindowFlags f ): // _model(0), @@ -144,10 +152,12 @@ HexaBaseDialog::HexaBaseDialog( QWidget * parent, Mode editmode, Qt::WindowFlags _vtkVm(0), _occVm(0), _currentObj(0), + currentOCCSelectionMode(TopAbs_SHAPE), _expectedSelection(-1), _selectionMutex( false ), // _applyCloseButton(0), - _applyButton(0) + _applyButton(0), + debugEdgeAssoc(false) { MESSAGE("HexaBaseDialog::HexaBaseDialog() dynamic_cast(parent->parent()) =>" << dynamic_cast(parent->parent()) ); _strHexaWidgetType[VERTEX_TREE] = tr( "VERTEX" ); @@ -164,16 +174,74 @@ HexaBaseDialog::HexaBaseDialog( QWidget * parent, Mode editmode, Qt::WindowFlags _strHexaWidgetType[GROUP_TREE] = tr( "GROUP" ); _strHexaWidgetType[LAW_TREE] = tr( "LAW" ); _strHexaWidgetType[PROPAGATION_TREE]= tr( "PROPAGATION" ); +} + +QModelIndexList HexaBaseDialog::getIndexList(QListWidget* itemsList) +{ + QModelIndexList iItems; + QModelIndex iItem; + QListWidgetItem* item = NULL; + const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); + if (patternDataModel == NULL) return iItems; + + unsigned int nbItems = itemsList->count(); + for ( int r = 0; r < nbItems; ++r){ + item = itemsList->item(r); + iItem = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value() ); + iItems << iItem; + } + return iItems; +} + + +// ============================================================= lockSizeToSizeHint +void HexaBaseDialog::lockSizeToSizeHint() +{ + setMaximumHeight(sizeHint().height()); + setMaximumWidth(sizeHint().width()); +// setMinimumHeight(sizeHint().height()); +// setMinimumWidth(sizeHint().width()); +} + +// ============================================================= unlockSizeModification +void HexaBaseDialog::unlockSizeModification() +{ + setMaximumHeight(MAX_HEIGHT); + setMaximumWidth(MAX_WIDTH); +// setMinimumHeight(MIN_HEIGHT); +// setMinimumWidth(MIN_WIDTH); +} + +// ============================================================= resetSizeAndShow +void HexaBaseDialog::resetSizeAndShow(QDockWidget* parent) +{ + //force the dialog to fit its contain + lockSizeToSizeHint(); + + //set the dialog in the dockwidget + parent->setWidget(this); + parent->setWindowTitle(windowTitle()); + parent->setVisible(true); + show(); + + unlockSizeModification(); +} + +// ============================================================= onCurrentSelectionChanged +void HexaBaseDialog::onCurrentSelectionChanged() +{ + highlightSelectedAssocs(); } -// ============================================================= Destructeur -HexaBaseDialog::~HexaBaseDialog() + +// ============================================================= setFocusToNextField +//Sets focus to the next field of the current object +void HexaBaseDialog::setFocusToNextField() { - // _mgr->clearSelectionCache(); - // _mgr->clearSelected(); - // globalSelection(); - // erasePreview(); + activateWindow (); + _highlightWidget(_currentObj, Qt::white); + if (!debugEdgeAssoc) focusNextPrevChild(true); } // ============================================================== _initButtonBox @@ -184,7 +252,7 @@ QGroupBox* HexaBaseDialog::_initButtonBox( Mode editmode ) //QDialogButtonBox* buttonBox = new QDialogButtonBox(this); QGroupBox* buttonBox = new QGroupBox(); - buttonBox->setMinimumWidth(5); + buttonBox->setMinimumWidth(BUTTON_BOX_MIN_WIDTH); buttonBox->setObjectName(QString::fromUtf8("buttonBox")); //buttonBox->setOrientation(Qt::Horizontal); QHBoxLayout* buttonsHLayout = new QHBoxLayout(); @@ -205,7 +273,7 @@ QGroupBox* HexaBaseDialog::_initButtonBox( Mode editmode ) //buttonsHLayout->addButton( _applyCloseButton ); buttonBox->setLayout(buttonsHLayout); layout()->addWidget(buttonBox); - + buttonBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); return buttonBox; } @@ -222,10 +290,9 @@ void HexaBaseDialog::_initViewManager() { SalomeApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); _mgr = dynamic_cast( anApp->selectionMgr() ); - _vtkVm = anApp->getViewManager( SVTK_Viewer::Type(), true ); _occVm = anApp->getViewManager( OCCViewer_Viewer::Type(), true ); + _vtkVm = anApp->getViewManager( SVTK_Viewer::Type(), true ); SUIT_ViewManager* activeVm = anApp->activeViewManager(); - onWindowActivated ( activeVm ); } @@ -245,7 +312,7 @@ bool HexaBaseDialog::apply() // select and highlight in vtk view the result _selectAndHighlight( iNew ); // reinitialization - _currentObj = NULL; +// _currentObj = NULL; } return applied; } @@ -260,13 +327,34 @@ bool HexaBaseDialog::apply() // } //} +void HexaBaseDialog::clearVTKSelection() +{ + if (HEXABLOCKGUI::currentVtkView == NULL) return; + HEXABLOCKGUI::currentVtkView->unHighlightAll(); + _disallowSelection(); +} + +void HexaBaseDialog::clearOCCSelection() +{ + if (HEXABLOCKGUI::selectionMgr() == NULL || HEXABLOCKGUI::currentOccView == NULL) return; + HEXABLOCKGUI::selectionMgr()->clearSelected(); + globalSelection(); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_SHAPE); +} + // ============================================================== close void HexaBaseDialog::close() { - _currentObj = NULL; - _disallowSelection(); - //resize(300, 350); - QDialog::close(); +// _currentObj = NULL; + + //Clear VTK selection + clearVTKSelection(); + + //Clear OCC selection + clearOCCSelection(); + + //Close the dialog box + if (parentWidget()) parentWidget()->close(); } // ============================================================== onHelpRequested @@ -290,7 +378,32 @@ void HexaBaseDialog::onHelpRequested() arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( _helpFileName ), QObject::tr( "BUT_OK" ) ); } +} + +// ============================================================== highlightSelectedAssocs +void HexaBaseDialog::highlightSelectedAssocs() +{ + if (!_patternDataSelectionModel || !HEXABLOCKGUI::selectionMgr()) return; + HEXABLOCKGUI::selectionMgr()->clearSelected(); + + //highlight vtk selected elts + QModelIndexList vtkAssocs = getAssocsVTK(); + if (!vtkAssocs.isEmpty()) _patternDataSelectionModel->highlightVTKElts(vtkAssocs); + + //highlight geom selected elts + QMultiMap geomAssocs = getAssocsGEOM(); + if (geomAssocs.size() > 0) _patternDataSelectionModel->_highlightGEOM(geomAssocs); +} +// ============================================================== getObjectViewType +HexaBaseDialog::ViewType HexaBaseDialog::getObjectViewType(QObject* obj) +{ + if (obj == NULL) return NONE; + QVariant v = obj->property("HexaWidgetType"); + if ( v.isValid() ) return VTK; + v = obj->property("GeomWidgetType"); + if ( v.isValid() ) return OCC; + return NONE; } // ============================================================== _selectAndHighlight @@ -301,7 +414,6 @@ void HexaBaseDialog::_selectAndHighlight( const QModelIndex& i ) setFocus(); } - // ============================================================== _allowSelection void HexaBaseDialog::_allowSelection() { @@ -325,24 +437,30 @@ void HexaBaseDialog::_disallowSelection() MESSAGE("}"); } +void HexaBaseDialog::setOCCSelectionMode(TopAbs_ShapeEnum mode) +{ + if (HEXABLOCKGUI::selectionMgr() != NULL) + { + HEXABLOCKGUI::selectionMgr()->clearSelected(); + globalSelection(); + localSelection(GEOM::GEOM_Object::_nil(), mode); + currentOCCSelectionMode = mode; + } +} // ============================================================== _allowVTKSelection bool HexaBaseDialog::_allowVTKSelection( QObject* obj ) { - MESSAGE("HexaBaseDialog::_allowModelSelection(){"); + + MESSAGE("HexaBaseDialog::_allowVTKSelection(){"); if ( !_patternDataSelectionModel ) return false; bool isOk = false; - HexaWidgetType wType; +// MESSAGE("* HEXABLOCKGUI::currentVtkView->raise()"); +// HEXABLOCKGUI::currentVtkView->raise(); +// HEXABLOCKGUI::currentVtkView->setFocus(); QVariant v = obj->property("HexaWidgetType"); - if ( !v.isValid() ) { - MESSAGE("* no HexaWidgetType property"); - return false; - } - MESSAGE("* HEXABLOCKGUI::currentVtkView->raise()"); - HEXABLOCKGUI::currentVtkView->raise(); - // HEXABLOCKGUI::currentVtkView->setFocus(); - wType = v.value(); + HexaWidgetType wType = v.value(); MESSAGE("* HexaWidgetType property is " << wType ); switch (wType){ @@ -372,43 +490,29 @@ bool HexaBaseDialog::_allowVTKSelection( QObject* obj ) return isOk; } +void HexaBaseDialog::refreshConnects() +{ + hide(); + show(); +} + // ============================================================== _allowOCCSelection bool HexaBaseDialog::_allowOCCSelection( QObject* obj ) { MESSAGE("HexaBaseDialog::_allowOCCCSelection(){"); - if ( !HEXABLOCKGUI::currentOccView ) return false; - - //We do not allow occ selection when the occ viewer is not activated - SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()); - if (!isOCC) return false; - + if ( HEXABLOCKGUI::currentOccView == NULL) return false; - GeomWidgetType wType; - QVariant v = obj->property("GeomWidgetType"); - if ( !v.isValid() ) { - MESSAGE("* no GeomWidgetType property"); - return false; - } - MESSAGE("* HEXABLOCKGUI::currentOccView->raise()"); - HEXABLOCKGUI::currentOccView->raise(); - wType = v.value(); - MESSAGE("* GeomWidgetType property is " << wType ); - MESSAGE("* TopAbs_VERTEX is " << TopAbs_VERTEX ); - MESSAGE("* TopAbs_EDGE is " << TopAbs_EDGE ); - MESSAGE("* TopAbs_FACE is " << TopAbs_FACE ); - - globalSelection(); // close local contexts, if any - localSelection(GEOM::GEOM_Object::_nil(), wType/*TopAbs_EDGE*/); + QVariant v = obj->property("GeomWidgetType"); + GeomWidgetType wType = v.value(); + setOCCSelectionMode(wType); return true; } - // ============================================================== _getSelector QItemSelectionModel* HexaBaseDialog::_getSelector( QObject* obj ) { QItemSelectionModel* selector = NULL; - MESSAGE("HexaBaseDialog::getSelector(){"); + MESSAGE("HexaBaseDialog::_getSelector(){"); QString objectName = obj->objectName(); QString className = obj->metaObject()->className(); @@ -429,19 +533,15 @@ QItemSelectionModel* HexaBaseDialog::_getSelector( QObject* obj ) case VERTEX_TREE: case EDGE_TREE: case QUAD_TREE: - case HEXA_TREE: - selector = _patternDataSelectionModel; break; + case HEXA_TREE: selector = _patternDataSelectionModel; break; case VECTOR_TREE: case CYLINDER_TREE: case PIPE_TREE: case ELEMENTS_TREE: - case CROSSELEMENTS_TREE: - selector = _patternBuilderSelectionModel; break; - case GROUP_TREE: - selector = _groupsSelectionModel; break; + case CROSSELEMENTS_TREE: selector = _patternBuilderSelectionModel; break; + case GROUP_TREE: selector = _groupsSelectionModel; break; case LAW_TREE: - case PROPAGATION_TREE: - selector = _meshSelectionModel; break; + case PROPAGATION_TREE: selector = _meshSelectionModel; break; default : MESSAGE("NOT YET"); } MESSAGE("}"); @@ -450,7 +550,10 @@ QItemSelectionModel* HexaBaseDialog::_getSelector( QObject* obj ) // ============================================================== _onSelectionChanged - +/* + * Puts elements selected in the model (treeview) in the corresponding + * line edit widget (the one that has the focus) of the current dialog box. + */ bool HexaBaseDialog::_onSelectionChanged( const QItemSelection& sel, QLineEdit* le ) { MESSAGE("HexaBaseDialog::_onSelectionChanged(const QItemSelection& sel, QLineEdit* le)"); @@ -472,20 +575,28 @@ bool HexaBaseDialog::_onSelectionChanged( const QItemSelection& sel, QLineEdit* MESSAGE("* bad selection : " << selType << " is not " << wType ); SUIT_MessageBox::information( 0, tr("HEXA_INFO"), - tr("%1: Bad type selected\nPlease select a %2.").arg(windowTitle()).arg( _strHexaWidgetType[wType]) ); + tr("%1: Bad type selected\nPlease select a %2.").arg(windowTitle()).arg(_strHexaWidgetType[wType])); return false; } //fill the lineEdit if selection is OK - le->setText( selected.data().toString() );// name + le->setText( selected.data().toString() );// namee le->setProperty("QModelIndex", QVariant::fromValue(selected) ); _index[le] = selected; + + QLineEdit* lineEdit = dynamic_cast(_currentObj); + if (selected.isValid() && lineEdit != NULL) + setFocusToNextField(); + MESSAGE("}"); return true; } - // ============================================================== _onSelectionChanged +/* + * Puts elements selected in the model (treeview) in the corresponding list widget + * of the current dialog box. + */ bool HexaBaseDialog::_onSelectionChanged( const QItemSelection& sel, QListWidget* lw ) { MESSAGE("HexaBaseDialog::_onSelectionChanged( const QItemSelection& sel, QListWidget* lw )"); @@ -520,6 +631,7 @@ bool HexaBaseDialog::_onSelectionChanged( const QItemSelection& sel, QListWidget if ( twice.count() == 0 ){ item = new QListWidgetItem( selName ); item->setData( LW_QMODELINDEX_ROLE, QVariant::fromValue(isel) ); + item->setData(LW_DATA_ROLE, isel.data(HEXA_DATA_ROLE)); lw->addItem(item); updateButtonBox(); } @@ -528,52 +640,11 @@ bool HexaBaseDialog::_onSelectionChanged( const QItemSelection& sel, QListWidget return true; } -// ============================================================== onCurrentSelectionChanged -void HexaBaseDialog::onCurrentSelectionChanged() -{ -} - - -// ============================================================== setDocumentModel -void HexaBaseDialog::setDocumentModel(DocumentModel* m) -{ - _documentModel = m; -} - -// ============================================================== clear -void HexaBaseDialog::clear() -{ -} - - -// ============================================================== setPatternDataSelectionModel -void HexaBaseDialog::setPatternDataSelectionModel(PatternDataSelectionModel* s) -{ - _patternDataSelectionModel = s; -} - - -// ============================================================== setPatternBuilderSelectionModel -void HexaBaseDialog::setPatternBuilderSelectionModel(PatternBuilderSelectionModel* s) -{ - _patternBuilderSelectionModel = s; -} - -// ============================================================== setGroupsSelectionModel -void HexaBaseDialog::setGroupsSelectionModel( GroupsSelectionModel* s ) -{ - _groupsSelectionModel = s; -} - - -// ============================================================== setMeshSelectionModel -void HexaBaseDialog::setMeshSelectionModel( MeshSelectionModel* s ) -{ - _meshSelectionModel = s; -} - - // ============================================================== onSelectionChanged +/* + * Puts elements selected in the model in the corresponding widget (list widget or line edit) + * of the current dialog box. + */ void HexaBaseDialog::onSelectionChanged( const QItemSelection& sel, const QItemSelection& unsel ) { MESSAGE( "HexaBaseDialog::onSelectionChanged(){" ); @@ -585,7 +656,7 @@ void HexaBaseDialog::onSelectionChanged( const QItemSelection& sel, const QItemS MESSAGE( "* _groupsSelectionModel : " << _groupsSelectionModel ); MESSAGE( "* _meshSelectionModel : " << _meshSelectionModel ); - +// highlightSelectedAssocs(); QItemSelectionModel* selector = dynamic_cast(sender()); MESSAGE( "* selector : " << selector); @@ -596,14 +667,52 @@ void HexaBaseDialog::onSelectionChanged( const QItemSelection& sel, const QItemS MESSAGE("* unselected : " << iunsel.data().toString().toStdString()); } - if ( _selectionMutex ) - return; + //type of the selected item + QModelIndexList itemsIndexes = sel.indexes(); + if ( itemsIndexes.count() == 0 ) return; + + //type from selection (first) + QModelIndex selected = itemsIndexes[0]; + int selType = selected.data(HEXA_TREE_ROLE).toInt(); + + switch(selType){ + case VERTEX_TREE: + if (currentOCCSelectionMode != TopAbs_VERTEX) + { +// if (HEXABLOCKGUI::currentOccView != NULL) HEXABLOCKGUI::currentOccView->setFocus(); + setOCCSelectionMode(TopAbs_VERTEX); + } + _patternDataSelectionModel->highlightEltsWithAssocs(itemsIndexes); + break; + case EDGE_TREE: + if (currentOCCSelectionMode != TopAbs_EDGE) + { +// if (HEXABLOCKGUI::currentOccView != NULL) HEXABLOCKGUI::currentOccView->setFocus(); + setOCCSelectionMode(TopAbs_EDGE); + } + _patternDataSelectionModel->highlightEltsWithAssocs(itemsIndexes); + break; + case QUAD_TREE: + if (currentOCCSelectionMode != TopAbs_FACE) + { +// if (HEXABLOCKGUI::currentOccView != NULL) HEXABLOCKGUI::currentOccView->setFocus(); + setOCCSelectionMode(TopAbs_FACE); + } + _patternDataSelectionModel->highlightEltsWithAssocs(itemsIndexes); + break; + case HEXA_TREE: + _patternDataSelectionModel->highlightEltsWithAssocs(itemsIndexes); + break; + } + + if ( _selectionMutex ) return; bool selOk = false; - QLineEdit* aLineEdit = 0; - QListWidget* aListWidget = 0; + QLineEdit* aLineEdit = NULL; + QListWidget* aListWidget = NULL; aLineEdit = dynamic_cast(_currentObj); + if ( aLineEdit){ //fill the lineedit with selection selOk = _onSelectionChanged( sel, aLineEdit ); } @@ -619,44 +728,6 @@ void HexaBaseDialog::onSelectionChanged( const QItemSelection& sel, const QItemS MESSAGE("}"); } -// ============================================================== onWindowActivated -void HexaBaseDialog::onWindowActivated( SUIT_ViewManager* vm ) -{ -} - -// ============================================================== hideEvent -void HexaBaseDialog::hideEvent ( QHideEvent * event ) -{ - MESSAGE("HexaBaseDialog::hideEvent(){"); - QString className = metaObject()->className(); - MESSAGE( "* I am : " << className.toStdString() ); - - if ( _patternDataSelectionModel ) - disconnect( _patternDataSelectionModel, SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection &) ), - this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); - if ( _patternBuilderSelectionModel ) - disconnect( _patternBuilderSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ), - this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); - if ( _groupsSelectionModel ) - disconnect( _groupsSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ), - this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); - if ( _meshSelectionModel ) - disconnect( _meshSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ), - this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); - // if ( _mgr ) - // disconnect( _mgr, 0/*SIGNAL(currentSelectionChanged())*/, this, 0/*SLOT(onCurrentSelectionChanged())*/ ); - disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(onCurrentSelectionChanged()) ); - if ( _vtkVm ) - disconnect( _vtkVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) ); - if ( _occVm ) - disconnect( _occVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) ); - - _documentModel->allowEdition(); - - QDialog::hideEvent( event ); - MESSAGE("}"); -} - // ============================================================== showEvent void HexaBaseDialog::showEvent( QShowEvent * event ) { @@ -664,6 +735,7 @@ void HexaBaseDialog::showEvent( QShowEvent * event ) QString className = metaObject()->className(); MESSAGE( "* I am : " << className.toStdString() ); + if ( _editMode == INFO_MODE ){ _documentModel->allowEdition(); } else { @@ -690,25 +762,51 @@ void HexaBaseDialog::showEvent( QShowEvent * event ) connect( _meshSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ), this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); } - if ( _mgr ) - connect( _mgr, SIGNAL(currentSelectionChanged()), this, SLOT(onCurrentSelectionChanged()) ); - if ( _vtkVm ) - connect( _vtkVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) ); - if ( _occVm ) - connect( _occVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) ); + connect( HEXABLOCKGUI::selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(onCurrentSelectionChanged()) ); + connect( _vtkVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) ); + connect( _occVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) ); QDialog::showEvent ( event ); MESSAGE("}"); } +// ============================================================== hideEvent +void HexaBaseDialog::hideEvent ( QHideEvent * event ) +{ + MESSAGE("HexaBaseDialog::hideEvent(){"); + QString className = metaObject()->className(); + MESSAGE( "* I am : " << className.toStdString() ); + + if ( _patternDataSelectionModel!=NULL ) + disconnect( _patternDataSelectionModel, SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection &) ), + this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); + if ( _patternBuilderSelectionModel!=NULL ) + disconnect( _patternBuilderSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ), + this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); + if ( _groupsSelectionModel!=NULL ) + disconnect( _groupsSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ), + this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); + if ( _meshSelectionModel!=NULL) + disconnect( _meshSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ), + this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) ); + disconnect( HEXABLOCKGUI::selectionMgr() , SIGNAL(currentSelectionChanged()), this, SLOT(onCurrentSelectionChanged()) ); + disconnect( _vtkVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) ); + disconnect( _occVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) ); + + _documentModel->allowEdition(); + + QDialog::hideEvent( event ); + MESSAGE("}"); +} // ============================================================== updateButtonBox void HexaBaseDialog::updateButtonBox() { } +// ============================================================== updateButtonBox void HexaBaseDialog::updateName() { if (!_documentModel) return; @@ -731,6 +829,10 @@ void HexaBaseDialog::updateName() // ============================================================== selectElementOfModel + +/*Selects in the model (treeview) elements selected in a listwidget, + * or an element in a line edit.*/ + void HexaBaseDialog::selectElementOfModel() { MESSAGE("HexaBaseDialog::selectElementOfModel()"); @@ -745,35 +847,77 @@ void HexaBaseDialog::selectElementOfModel() QModelIndex index; _patternDataSelectionModel->clearSelection(); foreach ( QListWidgetItem *item, sel ){ - MESSAGE( "* selecting the element : " << index.data().toString().toStdString() ); - index = item->data(LW_QMODELINDEX_ROLE).value(); +// index = item->data(LW_QMODELINDEX_ROLE).value(); //unsafe + index = _patternDataSelectionModel->indexBy(HEXA_DATA_ROLE, item->data(LW_DATA_ROLE)); if ( index.isValid() ) + { + MESSAGE( "* selecting the element : " << index.data().toString().toStdString() ); _patternDataSelectionModel->select( index, QItemSelectionModel::Select ); + } } _selectionMutex = false; MESSAGE("}"); } +// ============================================================== _isLineOrListWidget +/* + * Return true is the widget is a line or a list + * false otherwise. + */ +bool HexaBaseDialog::_isLineOrListWidget(QObject *widget) +{ + if (widget == NULL) return false; + + QLineEdit *lineEdit = dynamic_cast(widget); + QListWidget *listWidget = dynamic_cast(widget); + return (lineEdit != NULL) || (listWidget != NULL); + +}//_isLineOrListWidget + + +// ============================================================== _highlightWidget +/* + * Highlight the given widget with the given color. + */ +void HexaBaseDialog::_highlightWidget(QObject *obj, Qt::GlobalColor clr) +{ + if (!_isLineOrListWidget(obj)) return; + + QWidget *widget = dynamic_cast(obj); //sure it's not NULL (_isLineOrListWidget(obj)) + QPalette palette1 = widget->palette(); + palette1.setColor(widget->backgroundRole(), clr); + widget->setPalette(palette1); + +}//_highlightWidget + + +// ============================================================== _updateCurrentObject +void HexaBaseDialog::_updateCurrentObject(QObject* obj) +{ + _highlightWidget(_currentObj, Qt::white); + _currentObj = obj; + _highlightWidget(obj, Qt::yellow); +} + + // ============================================================== eventFilter +/* + * Handles events from the treeview and the dialog boxes. + */ bool HexaBaseDialog::eventFilter(QObject *obj, QEvent *event) { +// highlightSelectedAssocs(); QLineEdit *lineEdit = dynamic_cast(obj); QListWidget *listWidget = dynamic_cast(obj); HexaBaseDialog *dialog = dynamic_cast(obj); - if ( event->type() == QEvent::FocusIn ){ - QString className = obj->metaObject()->className(); - QString objectName = obj->objectName(); - MESSAGE("QEvent::FocusIn : I am "<< objectName.toStdString() ); - MESSAGE("QEvent::FocusIn : I am "<< className.toStdString() ); - - // Highlight the input widget - if ( lineEdit || listWidget ){ - QWidget* w = dynamic_cast(obj); - QPalette palette1 = w->palette(); - palette1.setColor(w->backgroundRole(), Qt::yellow); - w->setPalette(palette1); + if ( event->type() == QEvent::KeyPress ) + { + if ( ((QKeyEvent*)event)->key() == Qt::Key_Return) + { + setFocusToNextField(); + return true; } } @@ -782,58 +926,77 @@ bool HexaBaseDialog::eventFilter(QObject *obj, QEvent *event) QString objectName = obj->objectName(); MESSAGE("QEvent::FocusOut : I am "<< objectName.toStdString() ); MESSAGE("QEvent::FocusOut : I am "<< className.toStdString() ); - - // UnHighlight the input widget - if ( lineEdit || listWidget ){ - QWidget* w = dynamic_cast(obj); - QPalette palette1 = w->palette(); - palette1.setColor(w->backgroundRole(), Qt::white); - w->setPalette(palette1); - } } - if ( event->type() != QEvent::FocusIn ){ //QEvent::KeyPress) { - return false; - // return QObject::eventFilter(obj, event); + if ( event->type() == QEvent::FocusIn ){ + QString className = obj->metaObject()->className(); + QString objectName = obj->objectName(); + MESSAGE("QEvent::FocusIn : I am "<< objectName.toStdString() ); + MESSAGE("QEvent::FocusIn : I am "<< className.toStdString() ); + } + else return false; + MESSAGE("HexaBaseDialog::eventFilter{"); MESSAGE("* QEvent::FocusIn"); /* ON FOCUS ON A WIDGET*/ + QVariant v; QModelIndex index; - QItemSelectionModel *selector = 0; - _allowVTKSelection( obj ); + + //vtk selection + if (getObjectViewType(obj) == VTK) + _allowVTKSelection( obj ); //geom selection - _allowOCCSelection( obj ); + if (getObjectViewType(obj) == OCC) + _allowOCCSelection( obj ); + + //If the widget is a geom line edit highlight its content in the occ view + if (lineEdit != NULL && _patternDataSelectionModel != NULL && + getObjectViewType(obj) == OCC && !lineEdit->text().isEmpty()) + { + //highlight element in the OCC View + QMultiMap geomElts; + DocumentModel::GeomObj geomObj; + QVariant v = lineEdit->property("GeomObj"); + if ( v.isValid() ) + { + geomObj = v.value(); + geomElts.insert( geomObj.entry, geomObj.subid.toInt() ); + } + _patternDataSelectionModel->_highlightGEOM(geomElts); + } //Depending of focused widget type, get the right selector for it selector = _getSelector( obj ); - if ( !selector ) return false; + if ( selector == NULL ) + { + _updateCurrentObject(obj); + return false; + } - // Highlight the input widget - if ( _currentObj != obj && (lineEdit || listWidget) ){ + if ( _currentObj != obj && (lineEdit || listWidget) ) selector->clearSelection(); - } - _currentObj = obj; + _updateCurrentObject(obj); //If there is a current selection fill the widget with it if ( selector->hasSelection() ){ - QItemSelection currentSelection = selector->selection(); - bool selOk = false; - if ( lineEdit ){ //element can be from lineEdit - selOk = _onSelectionChanged( currentSelection, lineEdit ); - } else if ( listWidget ){ - selOk = _onSelectionChanged( currentSelection, listWidget ); - } - if ( !selOk && ( lineEdit || listWidget ) ){ - selector->clearSelection(); - } +// QItemSelection currentSelection = selector->selection(); +// bool selOk = false; +// if ( lineEdit ){ //element can be from lineEdit +// selOk = _onSelectionChanged( currentSelection, lineEdit ); +// } else if ( listWidget ){ +// selOk = _onSelectionChanged( currentSelection, listWidget ); +// } +// if ( !selOk && ( lineEdit || listWidget ) ){ +// selector->clearSelection(); +// } } else { //If the widget contains an hexa element, select it in model/view if ( lineEdit ){ //element can be from lineEdit @@ -857,7 +1020,6 @@ bool HexaBaseDialog::eventFilter(QObject *obj, QEvent *event) _selectionMutex = false; } - if ( dialog ){ //element can be from a dialog box MESSAGE("* on Dialog"); v = dialog->property("QModelIndex"); @@ -874,7 +1036,7 @@ bool HexaBaseDialog::eventFilter(QObject *obj, QEvent *event) } } - MESSAGE("}"); + MESSAGE("eventFilter}"); return false; } @@ -916,7 +1078,7 @@ void VertexDialog::_initInputWidget( Mode editmode ) name_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) ); name_le->installEventFilter(this); - connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName())); + //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName())); } // ============================================================== clear @@ -960,12 +1122,14 @@ HEXA_NS::Vertex* VertexDialog::getValue() // ============================================================== apply bool VertexDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_documentModel ) return false; if ( !_patternDataSelectionModel ) return false; const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); if ( !patternDataModel ) return false; - _currentObj = NULL; bool isOk = false; @@ -1013,16 +1177,16 @@ EdgeDialog::EdgeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ): setupUi( this ); _initWidget(editmode); - rb0->setFocusProxy( v0_le_rb0 ); - rb1->setFocusProxy( vex_le_rb1 ); - rb0->click(); +// rb0->setFocusProxy( v0_le_rb0 ); +// rb1->setFocusProxy( vex_le_rb1 ); if ( editmode == INFO_MODE ){ setWindowTitle( tr("Edge Information") ); rb1->hide(); } -} + rb0->click(); +} // ============================================================== Destructeur @@ -1057,7 +1221,13 @@ void EdgeDialog::_initInputWidget( Mode editmode ) vex_le_rb1->installEventFilter(this); vec_le_rb1->installEventFilter(this); - connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) ); + v0_le_rb0->setReadOnly(true); + v1_le_rb0->setReadOnly(true); + vex_le_rb1->setReadOnly(true); + vec_le_rb1->setReadOnly(true); + + //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) ); + } @@ -1078,6 +1248,9 @@ void EdgeDialog::setValue(HEXA_NS::Edge* e) { HEXA_NS::Vertex* v0 = e->getVertex(0); HEXA_NS::Vertex* v1 = e->getVertex(1); +// HEXA_NS::EltBase* e0 = e; +// HEXA_NS::EltBase* v0 = e->getVertex(0); +// HEXA_NS::EltBase* v1 = e->getVertex(1); name_le->setText( e->getName() ); v0_le_rb0->setText( v0->getName() ); @@ -1105,6 +1278,9 @@ HEXA_NS::Edge* EdgeDialog::getValue() // ============================================================== apply bool EdgeDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternDataSelectionModel ) return false; @@ -1113,7 +1289,6 @@ bool EdgeDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iEdge; @@ -1157,8 +1332,8 @@ QuadDialog::QuadDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ): _helpFileName = "gui_quadrangle.html"; setupUi( this ); _initWidget(editmode); - rb0->setFocusProxy( v0_le_rb0 ); - rb1->setFocusProxy( e0_le_rb1 ); +// rb0->setFocusProxy( v0_le_rb0 ); +// rb1->setFocusProxy( e0_le_rb1 ); rb0->click(); if ( editmode == INFO_MODE ){ @@ -1212,7 +1387,17 @@ void QuadDialog::_initInputWidget( Mode editmode ) e2_le_rb1->installEventFilter(this); e3_le_rb1->installEventFilter(this); - connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) ); + v0_le_rb0->setReadOnly(true); + v1_le_rb0->setReadOnly(true); + v2_le_rb0->setReadOnly(true); + v3_le_rb0->setReadOnly(true); + + e0_le_rb1->setReadOnly(true); + e1_le_rb1->setReadOnly(true); + e2_le_rb1->setReadOnly(true); + e3_le_rb1->setReadOnly(true); + + //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) ); } @@ -1304,12 +1489,14 @@ HEXA_NS::Quad* QuadDialog::getValue() // ============================================================== apply bool QuadDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternDataSelectionModel ) return false; const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); if ( !patternDataModel ) return false; - _currentObj = NULL; QModelIndex iQuad; @@ -1368,8 +1555,8 @@ HexaDialog::HexaDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ): _helpFileName = "gui_hexahedron.html"; setupUi( this ); _initWidget(editmode); - quads_rb->setFocusProxy( quads_lw ); - vertices_rb->setFocusProxy( vertices_lw ); +// quads_rb->setFocusProxy( quads_lw ); +// vertices_rb->setFocusProxy( vertices_lw ); quads_rb->click(); // quads_rb->setFocus(); @@ -1413,7 +1600,7 @@ void HexaDialog::_initInputWidget( Mode editmode ) connect(delVertexShortcut, SIGNAL(activated()), this, SLOT(deleteVertexItem())); } // edit name - connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) ); + //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) ); // highlight item on model view (VTK) from listwidget connect( quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) ); connect( vertices_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) ); @@ -1427,6 +1614,46 @@ void HexaDialog::clear() vertices_lw->clear(); } +// ============================================================== getAssocsVTK +/* + * Returns elements currently associated to vtk + */ +QModelIndexList HexaDialog::getAssocsVTK() +{ + QModelIndexList assocs; + QModelIndex iQuad, iVertex; + QListWidgetItem* item = NULL; + + if (quads_rb->isChecked()) + { + //ListWidget content + const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); + if ( !patternDataModel ) return assocs; + for ( int r = 0; r < quads_lw->count(); ++r ){ + item = quads_lw->item(r); + iQuad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value() ); + if ( iQuad.isValid() ) + assocs << iQuad; + } + return assocs; + } + else if (vertices_rb->isChecked()) + { + //ListWidget content + const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); + if ( !patternDataModel ) return assocs; + for ( int r = 0; r < vertices_lw->count(); ++r ){ + item = vertices_lw->item(r); + iVertex = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value() ); + if ( iVertex.isValid() ) + assocs << iVertex; + } + return assocs; + } + else return assocs; +} + + // ============================================================== updateButtonBox void HexaDialog::updateButtonBox() { @@ -1533,12 +1760,14 @@ HEXA_NS::Hexa* HexaDialog::getValue() // ============================================================== apply bool HexaDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_documentModel ) return false; if ( !_patternDataSelectionModel ) return false; const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); if ( !patternDataModel ) return false; - _currentObj = NULL; QModelIndex iHexa; @@ -1595,8 +1824,8 @@ VectorDialog::VectorDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ): setupUi( this ); _initWidget(editmode); - rb0->setFocusProxy( dx_spb_rb0 ); - rb1->setFocusProxy( v0_le_rb1 ); +// rb0->setFocusProxy( dx_spb_rb0 ); +// rb1->setFocusProxy( v0_le_rb1 ); rb0->click(); // setFocusProxy( rb0 ); @@ -1637,7 +1866,10 @@ void VectorDialog::_initInputWidget( Mode editmode ) dz_spb_rb0->setReadOnly(true); } - connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) ); + v0_le_rb1->setReadOnly(true); + v1_le_rb1->setReadOnly(true); + + //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) ); } // ============================================================== clear @@ -1675,6 +1907,9 @@ HEXA_NS::Vector* VectorDialog::getValue() // ============================================================== apply bool VectorDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_documentModel ) return false; if ( !_patternDataSelectionModel ) return false; @@ -1683,7 +1918,6 @@ bool VectorDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iVector; @@ -1761,7 +1995,10 @@ void CylinderDialog::_initInputWidget( Mode editmode ) vex_le->installEventFilter(this); vec_le->installEventFilter(this); - connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName())); + vex_le->setReadOnly(true); + vec_le->setReadOnly(true); + + //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName())); } // ============================================================== clear @@ -1811,6 +2048,9 @@ HEXA_NS::Cylinder* CylinderDialog::getValue() // ============================================================== apply bool CylinderDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_documentModel ) return false; if ( !_patternDataSelectionModel ) return false; @@ -1819,7 +2059,6 @@ bool CylinderDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iCyl; QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le] ); @@ -1904,7 +2143,10 @@ void PipeDialog::_initInputWidget( Mode editmode ) h_spb->setReadOnly(true); } - connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName())); + vex_le->setReadOnly(true); + vec_le->setReadOnly(true); + + //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName())); } @@ -1954,6 +2196,9 @@ HEXA_NS::Pipe* PipeDialog::getValue() // ============================================================== apply bool PipeDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternDataSelectionModel ) return false; @@ -1962,7 +2207,6 @@ bool PipeDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iPipe; QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le] ); @@ -2011,9 +2255,9 @@ MakeGridDialog::MakeGridDialog( QWidget* parent, Mode editmode, Qt::WindowFlags _initWidget(editmode); rb0->click();// Default : cartesian grid uniform_rb->click(); - rb0->setFocusProxy( vex_le_rb0 ); - rb1->setFocusProxy( center_le_rb1 ); - rb2->setFocusProxy( vex_le_rb2 ); +// rb0->setFocusProxy( vex_le_rb0 ); +// rb1->setFocusProxy( center_le_rb1 ); +// rb2->setFocusProxy( vex_le_rb2 ); // setFocusProxy( rb0 ); _helpFileName = "creategrids.html#guicartgrid"; @@ -2059,7 +2303,6 @@ void MakeGridDialog::_initInputWidget( Mode editmode ) vex_le_rb2->setValidator( validator ); vex_le_rb2->installEventFilter(this); - if ( editmode != INFO_MODE ){ //Cylindrical radius_lw->setItemDelegate(new HexaPositiveDoubleSpinBoxDelegate(radius_lw)); @@ -2079,8 +2322,16 @@ void MakeGridDialog::_initInputWidget( Mode editmode ) connect( del_height_pb, SIGNAL(clicked()), this, SLOT(delHeightItem()) ); } + vex_le_rb0->setReadOnly(true); + vec_le_rb0->setReadOnly(true); + vex_le_rb2->setReadOnly(true); + center_le_rb1->setReadOnly(true); + base_le_rb1->setReadOnly(true); + height_le_rb1->setReadOnly(true); + } + // ============================================================== clear void MakeGridDialog::clear() { @@ -2209,6 +2460,9 @@ void MakeGridDialog::delHeightItem() // ============================================================== apply bool MakeGridDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternDataSelectionModel ) return false; @@ -2217,7 +2471,6 @@ bool MakeGridDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iNewElts; if ( rb0->isChecked() ){ //cartesian @@ -2256,23 +2509,32 @@ bool MakeGridDialog::apply(QModelIndex& result) } if ( random_rb->isChecked() ){ QListWidgetItem* item = NULL; - QDoubleSpinBox* spb = NULL; +// QDoubleSpinBox* spb = NULL; QList radius; QList angles; QList heights; + double somme = 0.; + for ( int r = 0; r < angle_lw->count(); ++r){ + item = angle_lw->item(r); + angles << item->data(Qt::EditRole).toDouble(); + somme += item->data(Qt::EditRole).toDouble(); + } + if (somme > 360.) + { + SUIT_MessageBox::information( 0, + tr("HEXA_INFO"), + tr("The sum of the picked angles has to be \nless or equal than %1 degrees.").arg(360)); + return false; + } + for ( int r = 0; r < radius_lw->count(); ++r){ item = radius_lw->item(r); //std::cout << "radius : " << item->data(Qt::EditRole).toDouble()<< std::endl; radius << item->data(Qt::EditRole).toDouble(); } - for ( int r = 0; r < angle_lw->count(); ++r){ - item = angle_lw->item(r); - angles << item->data(Qt::EditRole).toDouble(); - } - for ( int r = 0; r < height_lw->count(); ++r){ item = height_lw->item(r); heights << item->data(Qt::EditRole).toDouble(); @@ -2282,7 +2544,6 @@ bool MakeGridDialog::apply(QModelIndex& result) icenter_rb1, ibase_rb1, iheight_rb1, radius, angles, heights, fill ); //NEW HEXA3 - } } @@ -2303,7 +2564,6 @@ bool MakeGridDialog::apply(QModelIndex& result) return false; } - // to select/highlight result result = patternBuilderModel->mapFromSource( iNewElts ); @@ -2342,6 +2602,9 @@ void MakeCylinderDialog::_initInputWidget( Mode editmode ) vec_le->setValidator( validator ); cyl_le->installEventFilter(this); vec_le->installEventFilter(this); + + cyl_le->setReadOnly(true); + vec_le->setReadOnly(true); } // ============================================================== clear @@ -2355,12 +2618,14 @@ void MakeCylinderDialog::clear() // ============================================================== apply bool MakeCylinderDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternBuilderSelectionModel ) return false; const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iElts; QModelIndex icyl = patternBuilderModel->mapToSource( _index[cyl_le] ); @@ -2422,6 +2687,11 @@ void MakePipeDialog::_initInputWidget( Mode editmode ) pipe_le->installEventFilter(this); vec_le->installEventFilter(this); + pipe_le->setReadOnly(true); + vec_le->setReadOnly(true); + + + } // ============================================================== clear @@ -2435,12 +2705,14 @@ void MakePipeDialog::clear() // ============================================================== apply bool MakePipeDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternBuilderSelectionModel ) return false; const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iElts; QModelIndex ipipe = patternBuilderModel->mapToSource( _index[pipe_le] ); @@ -2498,6 +2770,9 @@ void MakeCylindersDialog::_initInputWidget( Mode editmode ) cyl1_le->installEventFilter(this); cyl2_le->installEventFilter(this); + + cyl1_le->setReadOnly(true); + cyl2_le->setReadOnly(true); } // ============================================================== clear @@ -2511,12 +2786,14 @@ void MakeCylindersDialog::clear() // ============================================================== apply bool MakeCylindersDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternBuilderSelectionModel ) return false; const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iCrossElts; QModelIndex icyl1 = patternBuilderModel->mapToSource( _index[cyl1_le] ); @@ -2572,6 +2849,9 @@ void MakePipesDialog::_initInputWidget( Mode editmode ) pipe1_le->installEventFilter(this); pipe2_le->installEventFilter(this); + + pipe1_le->setReadOnly(true); + pipe2_le->setReadOnly(true); } @@ -2586,12 +2866,14 @@ void MakePipesDialog::clear() // ============================================================== apply bool MakePipesDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternBuilderSelectionModel ) return false; const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iCrossElts; QModelIndex ipipe1 = patternBuilderModel->mapToSource( _index[pipe1_le] ); @@ -2639,6 +2921,9 @@ void RemoveHexaDialog::_initInputWidget( Mode editmode ) hexa_le->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) ); hexa_le->setValidator( validator ); hexa_le->installEventFilter(this); + hexa_le->setReadOnly(true); + + } // ============================================================== clear @@ -2651,12 +2936,14 @@ void RemoveHexaDialog::clear() // ============================================================== apply bool RemoveHexaDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternDataSelectionModel ) return false; const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); if ( !patternDataModel ) return false; - _currentObj = NULL; QModelIndex ihexa = patternDataModel->mapToSource( _index[hexa_le] ); @@ -2673,6 +2960,17 @@ bool RemoveHexaDialog::apply(QModelIndex& result) SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT REMOVE HEXA" ) ); return false; } + + + //Update the line edit + QVariant invalid; + hexa_le->setProperty("QModelIndex", invalid ); + + QModelIndex invalidIndex; + _index[hexa_le] = invalidIndex; + + clear(); + return true; } @@ -2687,7 +2985,10 @@ PrismQuadDialog::PrismQuadDialog( QWidget* parent, Mode editmode, Qt::WindowFlag _helpFileName = "gui_prism_join_quad.html#prism-quadrangles"; setupUi( this ); _initWidget(editmode); - setFocusProxy( quads_lw ); +// setFocusProxy( quads_lw ); +// connect( regular_rb, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) ); +// connect( irregular_rb, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) ); + regular_rb->click(); } @@ -2696,6 +2997,28 @@ PrismQuadDialog::~PrismQuadDialog() { } +// ============================================================== getAssocsVTK +/* + * Returns elements currently associated to vtk + */ +QModelIndexList PrismQuadDialog::getAssocsVTK() +{ + QModelIndexList assocs; + QModelIndex iQuad; + QListWidgetItem* item = NULL; + + //ListWidget content + const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); + if ( !patternDataModel ) return assocs; + for ( int r = 0; r < quads_lw->count(); ++r ){ + item = quads_lw->item(r); + iQuad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value() ); + if ( iQuad.isValid() ) + assocs << iQuad; + } + return assocs; +} + // ============================================================== _initInputWidget void PrismQuadDialog::_initInputWidget( Mode editmode ) @@ -2720,7 +3043,13 @@ void PrismQuadDialog::_initInputWidget( Mode editmode ) connect( delQuadShortcut, SIGNAL(activated()), this, SLOT(removeQuad()) ); } + vec_le->setReadOnly(true); + connect( quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) ); + height_lw->setItemDelegate(new HexaPositiveDoubleSpinBoxDelegate(height_lw)); + height_lw->setEditTriggers(QAbstractItemView::DoubleClicked); + connect( add_height_pb, SIGNAL(clicked()), this, SLOT(addHeightItem()) ); + connect( del_height_pb, SIGNAL(clicked()), this, SLOT(delHeightItem()) ); } // ============================================================== clear @@ -2749,10 +3078,38 @@ void PrismQuadDialog::removeQuad() // quads_lw->clear(); // } +// ============================================================== addHeightItem +void PrismQuadDialog::addHeightItem() +{ + QListWidgetItem* previousItem = height_lw->currentItem(); + QListWidgetItem* newItem = new QListWidgetItem(); + + double defaultValue = 0.; + if ( previousItem ) + defaultValue = previousItem->data(Qt::EditRole).toDouble(); + + newItem->setData( Qt::EditRole, QVariant(defaultValue) ); + newItem->setFlags( newItem->flags () | Qt::ItemIsEditable); + height_lw->addItem(newItem); + +// updateButtonBox(); +} + +// ============================================================== delHeightItem +void PrismQuadDialog::delHeightItem() +{ + delete height_lw->currentItem(); +// updateButtonBox(); +} + + // ============================================================== apply bool PrismQuadDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternDataSelectionModel ) return false; @@ -2761,26 +3118,39 @@ bool PrismQuadDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; ///// - QModelIndexList iquads; - QModelIndex iquad; - QListWidgetItem* item = NULL; - for ( int r = 0; r < quads_lw->count(); ++r){ - item = quads_lw->item(r); - iquad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value() ); - iquads << iquad; - } + QModelIndexList iquads = getIndexList(quads_lw); QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le] ); QModelIndex iElts; if ( ivec.isValid() ){ - int nb = nb_spb->value(); - if ( iquads.count() == 1 ){ - iElts = _documentModel->prismQuad( iquads[0], ivec, nb ); - } else if ( iquads.count() > 1 ){ - iElts = _documentModel->prismQuads( iquads, ivec, nb ); + if (regular_rb->isChecked()) + { + int nb = nb_spb->value(); + if ( iquads.count() == 1 ){ + iElts = _documentModel->prismQuad( iquads[0], ivec, nb ); + } else if ( iquads.count() > 1 ){ + iElts = _documentModel->prismQuads( iquads, ivec, nb ); + } + } + else //irregular_rb is checked + { + QVector heights; + QListWidgetItem* item = NULL; + unsigned int nbItems = height_lw->count(); + + for ( int r = 0; r < nbItems; ++r){ + item = height_lw->item(r); + heights << item->data(Qt::EditRole).toDouble(); + } + if (iquads.count() == 0 || heights.size() == 0) + { + SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), + tr( "Parameters are invalid!" ) ); + return false; + } + iElts = _documentModel->prismQuads( iquads, ivec, heights.toStdVector()/*, nb*/ ); } } @@ -2813,6 +3183,28 @@ JoinQuadDialog::~JoinQuadDialog() { } +// ============================================================== getAssocsVTK +/* + * Returns elements currently associated to vtk + */ +QModelIndexList JoinQuadDialog::getAssocsVTK() +{ + QModelIndexList assocs; + QModelIndex iQuad; + QListWidgetItem* item = NULL; + + //ListWidget content + const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); + if ( !patternDataModel ) return assocs; + for ( int r = 0; r < quads_lw->count(); ++r ){ + item = quads_lw->item(r); +// iQuad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value() ); //unsafe + iQuad = _patternDataSelectionModel->indexBy(HEXA_DATA_ROLE, item->data(LW_DATA_ROLE)); + if ( iQuad.isValid() ) assocs << iQuad; + } + return assocs; +} + // ============================================================== _initInputWidget void JoinQuadDialog::_initInputWidget( Mode editmode ) { @@ -2847,6 +3239,15 @@ void JoinQuadDialog::_initInputWidget( Mode editmode ) delQuadShortcut->setContext( Qt::WidgetShortcut ); connect( delQuadShortcut, SIGNAL(activated()), this, SLOT(removeQuad()) ); } + + vex0_le->setReadOnly(true); + vex1_le->setReadOnly(true); + vex2_le->setReadOnly(true); + vex3_le->setReadOnly(true); + quad_dest_le->setReadOnly(true); + + _currentObj = quads_lw; + connect( quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) ); } @@ -2858,7 +3259,6 @@ void JoinQuadDialog::clear() vex0_le->clear(); vex2_le->clear(); - quad_dest_le->clear(); vex1_le->clear(); vex3_le->clear(); @@ -2888,6 +3288,9 @@ void JoinQuadDialog::removeQuad() // ============================================================== apply bool JoinQuadDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternDataSelectionModel ) return false; @@ -2896,7 +3299,6 @@ bool JoinQuadDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; ///// QModelIndexList iquads; @@ -2959,9 +3361,9 @@ MergeDialog::MergeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ) { setupUi( this ); _initWidget(editmode); - rb0->setFocusProxy( v0_le_rb0 ); - rb1->setFocusProxy( e0_le_rb1 ); - rb2->setFocusProxy( q0_le_rb2 ); +// rb0->setFocusProxy( v0_le_rb0 ); +// rb1->setFocusProxy( e0_le_rb1 ); +// rb2->setFocusProxy( q0_le_rb2 ); // setFocusProxy( rb0 ); rb0->click(); @@ -3027,6 +3429,23 @@ void MergeDialog::_initInputWidget( Mode editmode ) v3_le_rb2->installEventFilter(this); q0_le_rb2->installEventFilter(this); q1_le_rb2->installEventFilter(this); + + v0_le_rb0->setReadOnly(true); + v1_le_rb0->setReadOnly(true); + + v0_le_rb1->setReadOnly(true); + v1_le_rb1->setReadOnly(true); + e0_le_rb1->setReadOnly(true); + e1_le_rb1->setReadOnly(true); + + v0_le_rb2->setReadOnly(true); + v1_le_rb2->setReadOnly(true); + v2_le_rb2->setReadOnly(true); + v3_le_rb2->setReadOnly(true); + q0_le_rb2->setReadOnly(true); + q1_le_rb2->setReadOnly(true); + + } @@ -3063,11 +3482,13 @@ void MergeDialog::updateHelpFileName() // ============================================================== apply bool MergeDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_patternDataSelectionModel ) return false; const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); if ( !patternDataModel ) return false; - _currentObj = NULL; bool merged = false; @@ -3129,10 +3550,10 @@ DisconnectDialog::DisconnectDialog( QWidget* parent, Mode editmode, Qt::WindowFl { setupUi( this ); _initWidget(editmode); - rb0->setFocusProxy( v_le_rb0 ); - rb1->setFocusProxy( e_le_rb1 ); - rb2->setFocusProxy( q_le_rb2 ); - rb3->setFocusProxy( d_edges_lw); +// rb0->setFocusProxy( v_le_rb0 ); +// rb1->setFocusProxy( e_le_rb1 ); +// rb2->setFocusProxy( q_le_rb2 ); +// rb3->setFocusProxy( d_edges_lw); rb0->click(); // setFocusProxy( rb0 ); @@ -3193,6 +3614,15 @@ void DisconnectDialog::_initInputWidget( Mode editmode ) delEdgeShortcut->setContext( Qt::WidgetShortcut ); delHexaShortcut->setContext( Qt::WidgetShortcut ); + v_le_rb0->setReadOnly(true); + h_le_rb0->setReadOnly(true); + + e_le_rb1->setReadOnly(true); + h_le_rb1->setReadOnly(true); + + q_le_rb2->setReadOnly(true); + h_le_rb2->setReadOnly(true); + connect( d_edges_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) ); connect( hexas_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) ); connect( delEdgeShortcut, SIGNAL(activated()), this, SLOT(deleteEdgeItem()) ); @@ -3245,6 +3675,9 @@ void DisconnectDialog::updateHelpFileName() // ============================================================== apply bool DisconnectDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_patternDataSelectionModel ) return false; @@ -3253,7 +3686,6 @@ bool DisconnectDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iElts; @@ -3349,6 +3781,8 @@ void CutEdgeDialog::_initInputWidget( Mode editmode ) e_le->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) ); e_le->setValidator( validator ); e_le->installEventFilter(this); + + e_le->setReadOnly(true); } // ============================================================== clear @@ -3361,6 +3795,9 @@ void CutEdgeDialog::clear() // ============================================================== apply bool CutEdgeDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternDataSelectionModel ) return false; @@ -3369,7 +3806,6 @@ bool CutEdgeDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; int nbCut = nb_cut_spb->value(); QModelIndex iedge = patternDataModel->mapToSource( _index[e_le] ); @@ -3389,9 +3825,6 @@ bool CutEdgeDialog::apply(QModelIndex& result) return true; } - - - // // ------------------------- MakeTransformationDialog ---------------------------------- // ============================================================== Constructeur @@ -3401,10 +3834,10 @@ MakeTransformationDialog::MakeTransformationDialog( QWidget* parent, Mode editmo { setupUi( this ); _initWidget(editmode); - rb0->setFocusProxy( elts_le_rb0 ); - rb1->setFocusProxy( elts_le_rb1 ); - rb2->setFocusProxy( elts_le_rb2 ); - setFocusProxy( rb0 ); +// rb0->setFocusProxy( elts_le_rb0 ); +// rb1->setFocusProxy( elts_le_rb1 ); +// rb2->setFocusProxy( elts_le_rb2 ); +// setFocusProxy( rb0 ); rb0->click(); _helpFileName = "gui_make_elmts.html#make-elements-by-translation"; @@ -3452,6 +3885,16 @@ void MakeTransformationDialog::_initInputWidget( Mode editmode ) vec_le_rb2->installEventFilter(this); elts_le_rb2->installEventFilter(this); + vec_le_rb0->setReadOnly(true); + elts_le_rb0->setReadOnly(true); + + vex_le_rb1->setReadOnly(true); + elts_le_rb1->setReadOnly(true); + + vex_le_rb2->setReadOnly(true); + vec_le_rb2->setReadOnly(true); + elts_le_rb2->setReadOnly(true); + } // ============================================================== clear @@ -3482,6 +3925,9 @@ void MakeTransformationDialog::updateHelpFileName() // ============================================================== apply bool MakeTransformationDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_patternDataSelectionModel ) return false; if ( !_patternBuilderSelectionModel ) return false; @@ -3489,7 +3935,6 @@ bool MakeTransformationDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iNewElts; @@ -3532,8 +3977,6 @@ bool MakeTransformationDialog::apply(QModelIndex& result) return true; } - - // // ------------------------- MakeSymmetryDialog ---------------------------------- // ============================================================== Constructeur @@ -3543,9 +3986,9 @@ MakeSymmetryDialog::MakeSymmetryDialog( QWidget* parent, Mode editmode, Qt::Wind { setupUi( this ); _initWidget(editmode); - rb0->setFocusProxy( elts_le_rb0 ); - rb1->setFocusProxy( elts_le_rb1 ); - rb2->setFocusProxy( elts_le_rb2 ); +// rb0->setFocusProxy( elts_le_rb0 ); +// rb1->setFocusProxy( elts_le_rb1 ); +// rb2->setFocusProxy( elts_le_rb2 ); rb0->click(); // setFocusProxy( rb0 ); @@ -3555,7 +3998,6 @@ MakeSymmetryDialog::MakeSymmetryDialog( QWidget* parent, Mode editmode, Qt::Wind connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) ); } - // ============================================================== Destructeur MakeSymmetryDialog::~MakeSymmetryDialog() { @@ -3598,6 +4040,14 @@ void MakeSymmetryDialog::_initInputWidget( Mode editmode ) vec_le_rb2->installEventFilter(this); elts_le_rb2->installEventFilter(this); + vex_le_rb0->setReadOnly(true); + elts_le_rb0->setReadOnly(true); + vex_le_rb1->setReadOnly(true); + vec_le_rb1->setReadOnly(true); + elts_le_rb1->setReadOnly(true); + vex_le_rb2->setReadOnly(true); + vec_le_rb2->setReadOnly(true); + elts_le_rb2->setReadOnly(true); } // ============================================================== clear @@ -3615,7 +4065,6 @@ void MakeSymmetryDialog::clear() elts_le_rb2->clear(); } - // ============================================================== updateHelpFileName void MakeSymmetryDialog::updateHelpFileName() { @@ -3628,10 +4077,12 @@ void MakeSymmetryDialog::updateHelpFileName() } } - // ============================================================== apply bool MakeSymmetryDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_patternDataSelectionModel ) return false; if ( !_patternBuilderSelectionModel ) return false; @@ -3639,18 +4090,18 @@ bool MakeSymmetryDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex iNewElts; if ( rb0->isChecked() ){ QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb0] ); - QModelIndex ivex = patternBuilderModel->mapToSource( _index[vex_le_rb0] ); + QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb0] ); if ( ielts.isValid() && ivex.isValid() ) iNewElts = _documentModel->makeSymmetryPoint( ielts, ivex ); + } else if ( rb1->isChecked() ){ QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb1] ); QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb1] ); @@ -3682,12 +4133,7 @@ bool MakeSymmetryDialog::apply(QModelIndex& result) return true; } - - - - // // ------------------------- PerformTransformationDialog ---------------------------------- - // ============================================================== Constructeur PerformTransformationDialog::PerformTransformationDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ): @@ -3695,9 +4141,9 @@ PerformTransformationDialog::PerformTransformationDialog( QWidget* parent, Mode { setupUi( this ); _initWidget(editmode); - rb0->setFocusProxy( elts_le_rb0 ); - rb1->setFocusProxy( elts_le_rb1 ); - rb2->setFocusProxy( elts_le_rb2 ); +// rb0->setFocusProxy( elts_le_rb0 ); +// rb1->setFocusProxy( elts_le_rb1 ); +// rb2->setFocusProxy( elts_le_rb2 ); // setFocusProxy( rb0 ); rb0->click(); @@ -3707,7 +4153,6 @@ PerformTransformationDialog::PerformTransformationDialog( QWidget* parent, Mode connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) ); } - // ============================================================== Destructeur PerformTransformationDialog::~PerformTransformationDialog() { @@ -3744,6 +4189,14 @@ void PerformTransformationDialog::_initInputWidget( Mode editmode ) vec_le_rb2->installEventFilter(this); elts_le_rb2->installEventFilter(this); + vec_le_rb0->setReadOnly(true); + elts_le_rb0->setReadOnly(true); + vex_le_rb1->setReadOnly(true); + elts_le_rb1->setReadOnly(true); + vex_le_rb2->setReadOnly(true); + vec_le_rb2->setReadOnly(true); + elts_le_rb2->setReadOnly(true); + } // ============================================================== clear @@ -3770,6 +4223,9 @@ void PerformTransformationDialog::updateHelpFileName() // ============================================================== apply bool PerformTransformationDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_patternDataSelectionModel ) return false; if ( !_patternBuilderSelectionModel ) return false; @@ -3777,7 +4233,6 @@ bool PerformTransformationDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; bool performed = false; @@ -3820,9 +4275,6 @@ bool PerformTransformationDialog::apply(QModelIndex& result) } - - - // // ------------------------- PerformSymmetryDialog ---------------------------------- // ============================================================== Constructeur @@ -3832,9 +4284,9 @@ PerformSymmetryDialog::PerformSymmetryDialog( QWidget* parent, Mode editmode, Qt { setupUi( this ); _initWidget( editmode ); - rb0->setFocusProxy( elts_le_rb0 ); - rb1->setFocusProxy( elts_le_rb1 ); - rb2->setFocusProxy( elts_le_rb2 ); +// rb0->setFocusProxy( elts_le_rb0 ); +// rb1->setFocusProxy( elts_le_rb1 ); +// rb2->setFocusProxy( elts_le_rb2 ); // setFocusProxy( rb0 ); rb0->click(); @@ -3883,6 +4335,15 @@ void PerformSymmetryDialog::_initInputWidget( Mode editmode ) vec_le_rb2->installEventFilter(this); elts_le_rb2->installEventFilter(this); + vex_le_rb0->setReadOnly(true); + elts_le_rb0->setReadOnly(true); + vex_le_rb1->setReadOnly(true); + vec_le_rb1->setReadOnly(true); + elts_le_rb1->setReadOnly(true); + vex_le_rb2->setReadOnly(true); + vec_le_rb2->setReadOnly(true); + elts_le_rb2->setReadOnly(true); + } // ============================================================== clear @@ -3908,6 +4369,9 @@ void PerformSymmetryDialog::updateHelpFileName() // ============================================================== apply bool PerformSymmetryDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_patternDataSelectionModel ) return false; if ( !_patternBuilderSelectionModel ) return false; @@ -3915,7 +4379,6 @@ bool PerformSymmetryDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; bool performed = false; @@ -3969,7 +4432,7 @@ EdgeAssocDialog::EdgeAssocDialog( QWidget* parent, Mode editmode, Qt::WindowFlag setupUi( this ); _initWidget(editmode); _initViewManager(); - setFocusProxy( edges_lw ); +// setFocusProxy( edges_lw ); myLine.nullify(); @@ -4015,18 +4478,122 @@ void EdgeAssocDialog::_initInputWidget( Mode editmode ) QShortcut* delEdgeShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X), edges_lw); - QShortcut* delLineShortcut = new QShortcut(QKeySequence(Qt::Key_X), lines_lw); + QShortcut* delLineShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X), lines_lw); delLineShortcut->setContext( Qt::WidgetWithChildrenShortcut ); delEdgeShortcut->setContext( Qt::WidgetWithChildrenShortcut ); pend_spb->setValue(1.); + first_vex_le->setReadOnly(true); + single_edge_le->setReadOnly(true); + single_line_le->setReadOnly(true); + connect( delEdgeShortcut, SIGNAL(activated()), this, SLOT(deleteEdgeItem()) ); connect( delLineShortcut, SIGNAL(activated()), this, SLOT(deleteLineItem()) ); connect( pstart_spb, SIGNAL(valueChanged(double)), this, SLOT( pstartChanged(double)) ); connect( pend_spb, SIGNAL(valueChanged(double)), this, SLOT( pendChanged(double)) ); connect( edges_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) ); + connect( lines_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfGeom()) ); + connect( single_rb, SIGNAL(clicked()), this, SLOT( highlightSelectedAssocs()) ); + connect( multiple_rb, SIGNAL(clicked()), this, SLOT(highlightSelectedAssocs()) ); +} + + +// ============================================================== getAssocsVTK +/* + * Returns elements currently being associated in vtk side + */ +QModelIndexList EdgeAssocDialog::getAssocsVTK() +{ + QModelIndexList assocs; + QModelIndex iEdge; + QListWidgetItem* item = NULL; + + if (single_rb->isChecked()) + { + //LineEdit content + QVariant v = single_edge_le->property("QModelIndex"); + if ( !v.isValid() ) + return assocs; + assocs << v.value(); + return assocs; + } + else if (multiple_rb->isChecked()) + { + //ListWidget content + const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); + if ( !patternDataModel ) return assocs; + for ( int r = 0; r < edges_lw->count(); ++r){ + item = edges_lw->item(r); + iEdge = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value() ); + if ( iEdge.isValid() ) + assocs << iEdge; + } + return assocs; + } + else return assocs; +} + +// ============================================================== getAssocsGEOM +/* + * Returns elements currently being associated in geom side + */ +QMultiMap EdgeAssocDialog::getAssocsGEOM() +{ + QMultiMap assocs; + QListWidgetItem* item = NULL; + DocumentModel::GeomObj geomObj; + + if (single_rb->isChecked()) + { + //LineEdit content + QVariant v = single_line_le->property("GeomObj"); + if ( !v.isValid() ) return assocs; + geomObj = v.value(); + assocs.insert( geomObj.entry, geomObj.subid.toInt() ); + return assocs; + } + else if (multiple_rb->isChecked()) + { + //ListWidget content + unsigned int nbEdges = lines_lw->count(); + for ( int r = 0; r < nbEdges; ++r){ + item = lines_lw->item(r); + geomObj = item->data(LW_ASSOC_ROLE).value(); + assocs.insert( geomObj.entry, geomObj.subid.toInt() ); + } + return assocs; + } + else return assocs; +} + +// ============================================================== selectElementOfGeom + +/*Highlight in the OCC view selected elements in a listwidget, + * or an element in a line edit.*/ + +void EdgeAssocDialog::selectElementOfGeom() +{ + MESSAGE("HexaBaseDialog::selectElementOfGeom()"); + QListWidget* currentListWidget = dynamic_cast( sender() ); + if ( !currentListWidget ) return; + + _selectionMutex = true; + + QMultiMap geomElts; + DocumentModel::GeomObj geomObj; + QList sel = currentListWidget->selectedItems(); + foreach ( QListWidgetItem *item, sel ){ + geomObj = item->data(LW_ASSOC_ROLE).value(); + geomElts.insert( geomObj.entry, geomObj.subid.toInt() ); + } + _selectionMutex = false; + + //highlight geom selected elts + if (geomElts.size() > 0) _patternDataSelectionModel->_highlightGEOM(geomElts); + + MESSAGE("}"); } // ============================================================== clear @@ -4062,11 +4629,28 @@ void EdgeAssocDialog::setGeomEngine( GEOM::GEOM_Gen_var geomEngine ) void EdgeAssocDialog::onWindowActivated(SUIT_ViewManager* vm) { SUIT_ViewWindow* v = vm->getActiveView(); + QString vmType = vm->getType(); if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) ){ - edges_lw->setFocus(); - } else if ( vmType == OCCViewer_Viewer::Type() ){ - lines_lw->setFocus(); + + if (single_rb->isChecked()) + single_edge_le->setFocus(); + else if (multiple_rb->isChecked()) + { + if (close_cb->isChecked()) + first_vex_le->setFocus(); + else + edges_lw->setFocus(); + } + } + else if ( vmType == OCCViewer_Viewer::Type() ){ + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + + if (single_rb->isChecked()) + single_line_le->setFocus(); + else if (multiple_rb->isChecked()) + lines_lw->setFocus(); } } @@ -4127,138 +4711,90 @@ void EdgeAssocDialog::pendChanged( double val ) // ============================================================== onCurrentSelectionChanged void EdgeAssocDialog::onCurrentSelectionChanged() { - if ( !isVisible() ) return; + if ( !isVisible() ) + { + highlightSelectedAssocs(); + return; + } SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); SalomeApp_Study* appStudy = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()); - // bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type()); - - if (!isOCC) return; - + if (!isOCC || !_documentModel) + { + highlightSelectedAssocs(); + return; + } GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_EDGE); - TopoDS_Shape aShape; - - if ( !(aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) ) + DocumentModel::GeomObj * aLine = _documentModel->convertToGeomObj(aSelectedObject); + if ( aLine == NULL ) + { + highlightSelectedAssocs(); return; + } if (single_rb->isChecked()) { - QString aName = GEOMBase::GetName(aSelectedObject.get()); - single_line_le->setText(aName); + single_line_le->setText(aLine->name); + single_line_le->setProperty("GeomObj", QVariant::fromValue(*aLine)); myLine = aSelectedObject; + setFocusToNextField(); } else if( multiple_rb->isChecked() ) { - - DocumentModel::GeomObj aLine; - QListWidgetItem* item = NULL; - QString mainShapeEntry; - int subId = -1; - QString brep; - - if ( aSelectedObject->IsMainShape() ){ - mainShapeEntry = aSelectedObject->GetStudyEntry(); - brep = shape2string( aShape ).c_str(); - } else { - TopoDS_Shape shape; - TopoDS_Shape subshape; - GEOM::GEOM_Object_var mainShape = aSelectedObject->GetMainShape(); - mainShapeEntry = mainShape->GetStudyEntry(); - // CS_TODO : à optimiser - bool okShape = GEOMBase::GetShape( mainShape , shape);//,const TopAbs_ShapeEnum type = TopAbs_SHAPE ); - bool oksubShape = GEOMBase::GetShape( aSelectedObject.get(), subshape );//,const TopAbs_ShapeEnum type = TopAbs_SHAPE ); - if ( okShape && oksubShape ){ - brep = shape2string( subshape ).c_str(); - subId = GEOMBase::GetIndex( subshape, shape ); - } + QList twice = lines_lw->findItems( aLine->name, Qt::MatchExactly); + if ( twice.count() == 0 ){ + QListWidgetItem* item = new QListWidgetItem( aLine->name ); + item->setData( LW_ASSOC_ROLE, QVariant::fromValue(*aLine) ); + item->setData( LW_GEOM_OBJ_ROLE, QVariant::fromValue(aSelectedObject) ); + lines_lw->addItem(item); } - aLine.name = GEOMBase::GetName( aSelectedObject.get() ); - aLine.entry = mainShapeEntry; - aLine.subid = QString::number(subId); - aLine.brep = brep; - aLine.start = 0.; - aLine.end = 1.; - - item = new QListWidgetItem( aLine.name ); - item->setData( LW_ASSOC_ROLE, QVariant::fromValue(aLine) ); - item->setData( LW_GEOM_OBJ_ROLE, QVariant::fromValue(aSelectedObject) ); - lines_lw->addItem(item); } + highlightSelectedAssocs(); } - // ============================================================== apply bool EdgeAssocDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; bool assocOk = false; + highlightSelectedAssocs(); if ( !_patternDataSelectionModel ) return false; const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); if ( !patternDataModel ) return false; - _currentObj = NULL; - - QListWidgetItem* item = NULL; + if (!_documentModel) return false; QModelIndex iEdge; QModelIndexList iEdges; + QListWidgetItem* item = NULL; QList assocs; DocumentModel::GeomObj aLine; + DocumentModel::GeomObj *aLinePtr; if (single_rb->isChecked()){ //Single edge and/or line association - QString mainShapeEntry; - int subId = -1; - QString brep; GEOM::GeomObjPtr aSelectedObject = myLine; - TopoDS_Shape aShape; - - if ( aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull() ){ - if ( aSelectedObject->IsMainShape() ){ - mainShapeEntry = aSelectedObject->GetStudyEntry(); - brep = shape2string( aShape ).c_str(); - } - else { - TopoDS_Shape shape; - TopoDS_Shape subshape; - GEOM::GEOM_Object_var mainShape = aSelectedObject->GetMainShape(); - mainShapeEntry = mainShape->GetStudyEntry(); - // CS_TODO : à optimiser - bool okShape = GEOMBase::GetShape( mainShape , shape);//,const TopAbs_ShapeEnum type = TopAbs_SHAPE ); - bool oksubShape = GEOMBase::GetShape( aSelectedObject.get(), subshape );//,const TopAbs_ShapeEnum type = TopAbs_SHAPE ); - if ( okShape && oksubShape ){ - brep = shape2string( subshape ).c_str(); - subId = GEOMBase::GetIndex( subshape, shape ); - } - } - aLine.name = GEOMBase::GetName( aSelectedObject.get() ); - aLine.entry = mainShapeEntry; - aLine.subid = QString::number(subId); - aLine.brep = brep; - aLine.start = pstart_spb->value(); - aLine.end = pend_spb->value(); - iEdge = patternDataModel->mapToSource( _index[single_edge_le] ); - if (!iEdge.isValid()) return false; - _documentModel->addAssociation(iEdge, aLine); - assocOk = true; - } + aLinePtr = _documentModel->convertToGeomObj(aSelectedObject); + aLinePtr->start = pstart_spb->value(); + aLinePtr->end = pend_spb->value(); + iEdge = patternDataModel->mapToSource( _index[single_edge_le] ); + if (!iEdge.isValid()) return false; + _documentModel->addAssociation(iEdge, *aLinePtr); + assocOk = true; } else { //Multiple edge and/or line association // edges - for ( int r = 0; r < edges_lw->count(); ++r){ - item = edges_lw->item(r); - iEdge = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value() ); - if ( iEdge.isValid() ) - iEdges << iEdge; - } + iEdges = getIndexList(edges_lw); // lines - for ( int r = 0; r < lines_lw->count(); ++r){ + for (int r = 0; r < lines_lw->count(); ++r){ item = lines_lw->item(r); aLine = item->data(LW_ASSOC_ROLE).value(); - //std::cout << " line added : " << aLine.name.toStdString() << std::endl; MESSAGE(" assocs => " << aLine.name.toStdString() ); MESSAGE(" assocs => " << aLine.brep.toStdString() ); assocs << aLine; @@ -4266,30 +4802,25 @@ bool EdgeAssocDialog::apply(QModelIndex& result) if ( close_cb->isChecked() ){ //closed line QModelIndex iFirstVertex = patternDataModel->mapToSource( _index[first_vex_le] ); - // if (inverse_cb->isChecked()) - // assocOk = _documentModel->associateClosedLine( iFirstVertex, iEdges, assocs, pstart_spb->value(), true ); - // else - assocOk = _documentModel->associateClosedLine( iFirstVertex, iEdges, assocs, pstart_spb->value() ); - } else { + bool inv = inverse_cb->isChecked(); + assocOk = _documentModel->associateClosedLine( iFirstVertex, iEdges, assocs, pstart_spb->value(), inv ); + } else //opened line assocOk = _documentModel->associateOpenedLine( iEdges, assocs, pstart_spb->value(), pend_spb->value() ); - } } if ( !assocOk ){ SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE EDGE ASSOCIATION" ) ); + highlightSelectedAssocs(); return false; } + highlightSelectedAssocs(); return true; } - - -// // ------------------------- QuadAssocDialog ---------------------------------- - +// ------------------------- QuadAssocDialog ---------------------------------- // ============================================================== Constructeur - QuadAssocDialog::QuadAssocDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ): HexaBaseDialog(parent, editmode, f) { @@ -4297,7 +4828,7 @@ QuadAssocDialog::QuadAssocDialog( QWidget* parent, Mode editmode, Qt::WindowFlag setupUi( this ); _initWidget(editmode); _initViewManager(); - setFocusProxy( quad_le ); +// setFocusProxy( quad_le ); } // ============================================================== Destructeur @@ -4324,10 +4855,77 @@ void QuadAssocDialog::_initInputWidget( Mode editmode ) _delFaceShortcut = new QShortcut( QKeySequence(Qt::Key_X/*Qt::Key_Delete*/), faces_lw ); _delFaceShortcut->setContext( Qt::WidgetShortcut ); + quad_le->setReadOnly(true); + connect( _delFaceShortcut, SIGNAL(activated()), this, SLOT(deleteFaceItem()) ); + connect( faces_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfGeom()) ); +} + +// ============================================================== getAssocsVTK +/* + * Returns elements currently being associated in vtk side + */ +QModelIndexList QuadAssocDialog::getAssocsVTK() +{ + QModelIndexList assocs; + QModelIndex iQuad; + + //LineEdit content + QVariant v = quad_le->property("QModelIndex"); + if ( !v.isValid() ) + return assocs; + assocs << v.value(); + return assocs; +} + +// ============================================================== getAssocsGEOM +/* + * Returns elements currently being associated in geom side + */ +QMultiMap QuadAssocDialog::getAssocsGEOM() +{ + QMultiMap assocs; + QListWidgetItem* item = NULL; + DocumentModel::GeomObj geomObj; + + //ListWidget content + unsigned int nbFaces = faces_lw->count(); + for ( int r = 0; r < nbFaces; ++r){ + item = faces_lw->item(r); + geomObj = item->data(LW_ASSOC_ROLE).value(); + assocs.insert( geomObj.entry, geomObj.subid.toInt() ); + } + return assocs; +} + +// ============================================================== selectElementOfGeom +/*Highlight in the OCC view selected elements in a listwidget, + * or an element in a line edit.*/ + +void QuadAssocDialog::selectElementOfGeom() +{ + MESSAGE("HexaBaseDialog::selectElementOfGeom()"); + + QListWidget* currentListWidget = dynamic_cast( sender() ); + if ( !currentListWidget ) return; + + _selectionMutex = true; + + QMultiMap geomElts; + DocumentModel::GeomObj geomObj; + QList sel = currentListWidget->selectedItems(); + foreach ( QListWidgetItem *item, sel ){ + geomObj = item->data(LW_ASSOC_ROLE).value(); + geomElts.insert( geomObj.entry, geomObj.subid.toInt() ); + } + _selectionMutex = false; + + //highlight geom selected elts + if (geomElts.size() > 0) _patternDataSelectionModel->_highlightGEOM(geomElts); + + MESSAGE("}"); } -// ============================================================== clear void QuadAssocDialog::clear() { quad_le->clear(); @@ -4337,66 +4935,54 @@ void QuadAssocDialog::clear() // ============================================================== onCurrentSelectionChanged void QuadAssocDialog::onCurrentSelectionChanged() { - - if ( !isVisible() ) return; + if ( !isVisible() ) + { + highlightSelectedAssocs(); + return; + } SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); SalomeApp_Study* appStudy = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()); // bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type()); - - if (!isOCC) return; + if (!isOCC || !_documentModel) + { +// if (HEXABLOCKGUI::currentOccView != NULL) HEXABLOCKGUI::currentOccView->setFocus(); + highlightSelectedAssocs(); + return; + } GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_FACE); - TopoDS_Shape aShape; - - if ( aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull() ){ - DocumentModel::GeomObj aFace; - QListWidgetItem* item = NULL; - QString mainShapeEntry; - int subId = -1; - QString brep; + DocumentModel::GeomObj* aFace = _documentModel->convertToGeomObj(aSelectedObject); + if (aFace == NULL) + { + highlightSelectedAssocs(); + return; + } - if ( aSelectedObject->IsMainShape() ){ - mainShapeEntry = aSelectedObject->GetStudyEntry(); - brep = shape2string( aShape ).c_str(); - } else { - TopoDS_Shape shape; - TopoDS_Shape subshape; - GEOM::GEOM_Object_var mainShape = aSelectedObject->GetMainShape(); - mainShapeEntry = mainShape->GetStudyEntry(); - // CS_TODO : à optimiser - bool okShape = GEOMBase::GetShape( mainShape , shape);//,const TopAbs_ShapeEnum type = TopAbs_SHAPE ); - bool oksubShape = GEOMBase::GetShape( aSelectedObject.get(), subshape );//,const TopAbs_ShapeEnum type = TopAbs_SHAPE ); - if ( okShape && oksubShape ){ - brep = shape2string( subshape ).c_str(); - subId = GEOMBase::GetIndex( subshape, shape ); - } - } - aFace.name = GEOMBase::GetName( aSelectedObject.get() ); - aFace.entry = mainShapeEntry; - aFace.subid = QString::number(subId); - aFace.brep = brep; - aFace.start = 0.; - aFace.end = 1.; - - item = new QListWidgetItem( aFace.name ); - item->setData( LW_ASSOC_ROLE, QVariant::fromValue(aFace) ); + QList twice = faces_lw->findItems( aFace->name, Qt::MatchExactly); + if ( twice.count() == 0 ){ + QListWidgetItem* item = new QListWidgetItem( aFace->name ); + item->setData( LW_ASSOC_ROLE, QVariant::fromValue(*aFace) ); faces_lw->addItem(item); // faces_lw->setCurrentRow( faces_lw->count() - 1 ); } + highlightSelectedAssocs(); } // ============================================================== onWindowActivated void QuadAssocDialog::onWindowActivated(SUIT_ViewManager* vm) { SUIT_ViewWindow* v = vm->getActiveView(); - QString vmType = vm->getType(); - if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) ){ + + QString vmType = vm->getType(); + if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) ) quad_le->setFocus(); - } else if ( vmType == OCCViewer_Viewer::Type() ){ + else if ( vmType == OCCViewer_Viewer::Type() ){ + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE); faces_lw->setFocus(); } } @@ -4411,12 +4997,15 @@ void QuadAssocDialog::deleteFaceItem() // ============================================================== apply bool QuadAssocDialog::apply(QModelIndex& result) { + highlightSelectedAssocs(); + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; //if ( !_documentModel ) return; if ( !_patternDataSelectionModel ) return false; const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); if ( !patternDataModel ) return false; - _currentObj = NULL; // quad QModelIndex iQuad = patternDataModel->mapToSource( _index[quad_le] ); @@ -4432,6 +5021,7 @@ bool QuadAssocDialog::apply(QModelIndex& result) result = patternDataModel->mapFromSource(iQuad); + highlightSelectedAssocs(); return true; } @@ -4464,6 +5054,25 @@ GroupDialog::~GroupDialog() { } +// ============================================================== getAssocsVTK +/* + * Returns elements currently being associated in vtk side + */ +QModelIndexList GroupDialog::getAssocsVTK() +{ + QModelIndexList assocs; + QModelIndex iItem; + QListWidgetItem* item = NULL; + //ListWidget content + const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); + if ( !patternDataModel ) return assocs; + for ( int r = 0; r < eltBase_lw->count(); ++r){ + item = eltBase_lw->item(r); + iItem = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value() ); + if ( iItem.isValid() ) assocs << iItem; + } + return assocs; +} // ============================================================== _initInputWidget void GroupDialog::_initInputWidget( Mode editmode ) @@ -4513,11 +5122,25 @@ void GroupDialog::onKindChanged(int index) // onKind MESSAGE("GroupDialog::onKindChanged(" << index << ") "); switch ( kind_cb->itemData(index).toInt() ){ - case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(HEXA_TREE)); MESSAGE("====>HEXA_TREE"); break; - case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(QUAD_TREE)); MESSAGE("====>QUAD_TREE"); break; - case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(EDGE_TREE)); MESSAGE("====>EDGE_TREE"); break; - case HEXA_NS::VertexNode: eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(VERTEX_TREE)); MESSAGE("====>VERTEX_TREE"); break; - default:Q_ASSERT( false ); + case HEXA_NS::HexaCell: + case HEXA_NS::HexaNode: + eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(HEXA_TREE)); + break; + + case HEXA_NS::QuadCell: + case HEXA_NS::QuadNode: + eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(QUAD_TREE)); + break; + + case HEXA_NS::EdgeCell: + case HEXA_NS::EdgeNode: eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(EDGE_TREE)); + break; + + case HEXA_NS::VertexNode: + eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(VERTEX_TREE)); + break; + + default:Q_ASSERT(false); } eltBase_lw->clear(); eltBase_lw->setFocus(); @@ -4554,7 +5177,7 @@ void GroupDialog::setValue(HEXA_NS::Group* g) case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: v = QVariant::fromValue( (HEXA_NS::Hexa *)eltBase ); break; case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: v = QVariant::fromValue( (HEXA_NS::Quad *)eltBase ); break; case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: v = QVariant::fromValue( (HEXA_NS::Edge *)eltBase ); break; - case HEXA_NS::VertexNode: v = QVariant::fromValue( (HEXA_NS::Vertex *)eltBase ); break; + case HEXA_NS::VertexNode: v = QVariant::fromValue( (HEXA_NS::Vertex *)eltBase ); break; } iEltBase = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, v); if ( iEltBase.isValid() ){ @@ -4590,6 +5213,9 @@ void GroupDialog::removeEltBase() // ============================================================== apply bool GroupDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_documentModel ) return false; @@ -4597,7 +5223,6 @@ bool GroupDialog::apply(QModelIndex& result) if ( !_groupsSelectionModel ) return false; const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); const GroupsModel* groupsModel = dynamic_cast( _groupsSelectionModel->model() ); - _currentObj = NULL; QString grpName = name_le->text(); DocumentModel::Group grpKind = static_cast( kind_cb->itemData( kind_cb->currentIndex() ).toInt()); @@ -4726,11 +5351,13 @@ HEXA_NS::Law* LawDialog::getValue() // ============================================================== apply bool LawDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_documentModel ) return false; if ( !_meshSelectionModel ) return false; - _currentObj = NULL; const MeshModel* meshModel = dynamic_cast( _meshSelectionModel->model() ); QString lawName = name_le->text(); @@ -4788,7 +5415,7 @@ PropagationDialog::PropagationDialog( QWidget* parent, Mode editmode, Qt::Window setupUi( this ); _initWidget(editmode); // setFocusProxy( law_le ); - setFocusProxy( propagations_lw ); +// setFocusProxy( propagations_lw ); if ( editmode == INFO_MODE ){ setWindowTitle( tr("Propagation Information") ); @@ -4830,6 +5457,8 @@ void PropagationDialog::_initInputWidget( Mode editmode ) QShortcut* delPropagationShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X/*Qt::Key_Alt*//*Qt::Key_Space*/), propagations_lw); delPropagationShortcut->setContext( Qt::WidgetShortcut ); + law_le->setReadOnly(true); + connect( delPropagationShortcut, SIGNAL(activated()), this, SLOT(deletePropagationItem()) ); connect( propagations_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) ); } @@ -4859,7 +5488,6 @@ void PropagationDialog::setValue(HEXA_NS::Propagation* p) QModelIndex ip = _meshSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(p) ); setProperty( "QModelIndex", QVariant::fromValue(ip) ); - // law on propagation if ( l != NULL ){ law_le->setText( l->getName() ); @@ -4873,6 +5501,38 @@ void PropagationDialog::setValue(HEXA_NS::Propagation* p) _value = p; } +// ============================================================== selectElementOfModel + +/*Selects in the model (treeview) elements selected in a listwidget, + * or an element in a line edit.*/ + +void PropagationDialog::selectElementOfModel() +{ + MESSAGE("HexaBaseDialog::selectElementOfModel()"); + if (!_meshSelectionModel) return; + + QListWidget* currentListWidget = dynamic_cast( sender() ); + if ( !currentListWidget ) return; + + _selectionMutex = true; + + QList sel = currentListWidget->selectedItems(); + QModelIndex index; + _meshSelectionModel->clearSelection(); + foreach ( QListWidgetItem *item, sel ){ + index = item->data(LW_QMODELINDEX_ROLE).value(); + if ( index.isValid() ) + { + MESSAGE( "* selecting the element : " << index.data().toString().toStdString() ); + _meshSelectionModel->select( index, QItemSelectionModel::Select ); + } + } + _selectionMutex = false; + + MESSAGE("}"); +} + + // ============================================================== getValue HEXA_NS::Propagation* PropagationDialog::getValue() { @@ -4883,11 +5543,13 @@ HEXA_NS::Propagation* PropagationDialog::getValue() // ============================================================== apply bool PropagationDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + bool isOk = false; SUIT_OverrideCursor wc; if ( !_documentModel ) return false; if ( !_meshSelectionModel ) return false; - _currentObj = NULL; const MeshModel* meshModel = dynamic_cast( _meshSelectionModel->model() ); bool way = way_cb->isChecked(); @@ -4993,6 +5655,9 @@ void ComputeMeshDialog::clear() // ============================================================== apply bool ComputeMeshDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; QString command = QString("import hexablock ; %1 = hexablock.mesh(\"%2\", \"%1\", %3, \"%4\")") @@ -5048,7 +5713,7 @@ ReplaceHexaDialog::ReplaceHexaDialog( QWidget* parent, Mode editmode, Qt::Window _helpFileName = "gui_replace_hexa.html"; setupUi( this ); _initWidget(editmode); - setFocusProxy( quads_lw ); +// setFocusProxy( quads_lw ); } // ============================================================== Destructeur @@ -5056,6 +5721,28 @@ ReplaceHexaDialog::~ReplaceHexaDialog() { } +// ============================================================== getAssocsVTK +/* + * Returns elements currently associated to vtk + */ +QModelIndexList ReplaceHexaDialog::getAssocsVTK() +{ + QModelIndexList assocs; + QModelIndex iQuad; + QListWidgetItem* item = NULL; + + //ListWidget content + const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); + if ( !patternDataModel ) return assocs; + for ( int r = 0; r < quads_lw->count(); ++r ){ + item = quads_lw->item(r); +// iQuad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value() ); //unsafe + iQuad = _patternDataSelectionModel->indexBy(HEXA_DATA_ROLE, item->data(LW_DATA_ROLE)); + if ( iQuad.isValid() ) assocs << iQuad; + } + return assocs; +} + // ============================================================== _initInputWidget void ReplaceHexaDialog::_initInputWidget( Mode editmode ) { @@ -5073,6 +5760,7 @@ void ReplaceHexaDialog::_initInputWidget( Mode editmode ) p2_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) ); p3_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) ); + name_le->installEventFilter(this); c1_le->installEventFilter(this); c2_le->installEventFilter(this); c3_le->installEventFilter(this); @@ -5092,6 +5780,14 @@ void ReplaceHexaDialog::_initInputWidget( Mode editmode ) connect( quads_lw, SIGNAL(currentRowChanged(int)), this, SLOT(updateButtonBox(int)) ); } + c1_le->setReadOnly(true); + c2_le->setReadOnly(true); + c3_le->setReadOnly(true); + + p1_le->setReadOnly(true); + p2_le->setReadOnly(true); + p3_le->setReadOnly(true); + connect(quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel())); } @@ -5124,6 +5820,9 @@ void ReplaceHexaDialog::deleteQuadItem() // ============================================================== apply bool ReplaceHexaDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_documentModel ) return false; if ( !_patternDataSelectionModel ) return false; @@ -5132,7 +5831,6 @@ bool ReplaceHexaDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex ielts; //result @@ -5177,6 +5875,13 @@ bool ReplaceHexaDialog::apply(QModelIndex& result) result = patternBuilderModel->mapFromSource(ielts); + //update the list (indexes) + for ( int r = 0; r < quads_lw->count(); ++r ){ + item = quads_lw->item(r); + iquad = _patternDataSelectionModel->indexBy(HEXA_DATA_ROLE, item->data(LW_DATA_ROLE)); + item->setData( LW_QMODELINDEX_ROLE, QVariant::fromValue(iquad) ); + } + return true; } @@ -5193,7 +5898,29 @@ QuadRevolutionDialog::QuadRevolutionDialog( QWidget* parent, Mode editmode, Qt:: _helpFileName = "gui_quad_revolution.html"; setupUi( this ); _initWidget(editmode); - setFocusProxy( quads_lw ); +// setFocusProxy( quads_lw ); +} + +// ============================================================== getAssocsVTK +/* + * Returns elements currently associated to vtk + */ +QModelIndexList QuadRevolutionDialog::getAssocsVTK() +{ + QModelIndexList assocs; + QModelIndex iQuad; + QListWidgetItem* item = NULL; + + //ListWidget content + const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); + if ( !patternDataModel ) return assocs; + for ( int r = 0; r < quads_lw->count(); ++r ){ + item = quads_lw->item(r); + iQuad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value() ); + if ( iQuad.isValid() ) + assocs << iQuad; + } + return assocs; } // ============================================================== Destructeur @@ -5218,6 +5945,7 @@ void QuadRevolutionDialog::_initInputWidget( Mode editmode ) axis_vec_le->setValidator( validator ); // quads_lw->setValidator( validator ); + name_le->installEventFilter(this); center_pt_le->installEventFilter(this); axis_vec_le->installEventFilter(this); quads_lw->installEventFilter(this); @@ -5234,6 +5962,9 @@ void QuadRevolutionDialog::_initInputWidget( Mode editmode ) // connect(clear_pb, SIGNAL(clicked()), this, SLOT(clearQuads())); } + center_pt_le->setReadOnly(true); + axis_vec_le->setReadOnly(true); + connect(quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel())); } @@ -5293,6 +6024,9 @@ void QuadRevolutionDialog::delQuadItem() // ============================================================== apply bool QuadRevolutionDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_documentModel ) return false; if ( !_patternDataSelectionModel ) return false; @@ -5301,7 +6035,6 @@ bool QuadRevolutionDialog::apply(QModelIndex& result) const PatternBuilderModel* patternBuilderModel = dynamic_cast( _patternBuilderSelectionModel->model() ); if ( !patternDataModel ) return false; if ( !patternBuilderModel ) return false; - _currentObj = NULL; QModelIndex ielts; //result QListWidgetItem* item = NULL; @@ -5345,7 +6078,7 @@ bool QuadRevolutionDialog::apply(QModelIndex& result) -// ------------------------- QuadRevolutionDialog ---------------------------------- +// ------------------------- MakeHemiSphereDialog ---------------------------------- // ============================================================== Constructeur @@ -5384,11 +6117,18 @@ void MakeHemiSphereDialog::_initInputWidget( Mode editmode ) radial_vec_le->setValidator( validator ); + name_le->installEventFilter(this); sphere_center_le->installEventFilter(this); cross_pt_le->installEventFilter(this); hole_axis_le->installEventFilter(this); cross_vec_le->installEventFilter(this); radial_vec_le->installEventFilter(this); + + sphere_center_le->setReadOnly(true); + cross_pt_le->setReadOnly(true); + hole_axis_le->setReadOnly(true); + cross_vec_le->setReadOnly(true); + radial_vec_le->setReadOnly(true); } // ============================================================== clear @@ -5399,6 +6139,9 @@ void MakeHemiSphereDialog::clear() // ============================================================== apply bool MakeHemiSphereDialog::apply(QModelIndex& result) { + if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); + _currentObj = NULL; + SUIT_OverrideCursor wc; if ( !_documentModel ) return false; if ( !_patternBuilderSelectionModel ) return false; @@ -5407,7 +6150,6 @@ bool MakeHemiSphereDialog::apply(QModelIndex& result) const PatternDataModel* patternDataModel = dynamic_cast( _patternDataSelectionModel->model() ); if ( !patternBuilderModel ) return false; if ( !patternDataModel ) return false; - _currentObj = NULL; QModelIndex iElts; QModelIndex icenter = patternDataModel->mapToSource( _index[sphere_center_le] ); @@ -5504,6 +6246,9 @@ bool MakeHemiSphereDialog::apply(QModelIndex& result) // // bool MakeRindDialog::apply(QModelIndex& result) // { +// if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white); +// _currentObj = NULL; +// // SUIT_OverrideCursor wc; // if ( !_documentModel ) return false; // if ( !_patternBuilderSelectionModel ) return false; diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.hxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.hxx index b59b2e3..9ecc174 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.hxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentPanel.hxx @@ -31,8 +31,13 @@ #endif +#define MAX_WIDTH 16777215 +#define MAX_HEIGHT 16777215 +#define MIN_WIDTH 0 +#define MIN_HEIGHT 0 #include +#include #include "ui_Vertex_QTD.h" #include "ui_Quad_QTD.h" @@ -86,8 +91,6 @@ #include "klinkitemselectionmodel.hxx" - - Q_DECLARE_METATYPE(QModelIndex); Q_DECLARE_METATYPE(HEXABLOCK::GUI::DocumentModel::GeomObj); Q_DECLARE_METATYPE(GEOM::GeomObjPtr); @@ -110,6 +113,12 @@ namespace HEXABLOCK UPDATE_MODE }; + enum ViewType { + VTK, + OCC, + NONE + }; + // define input widget type => usefull for selection typedef HexaTreeRole HexaWidgetType; typedef TopAbs_ShapeEnum/*int */GeomWidgetType; //CS_TODO @@ -120,23 +129,50 @@ namespace HEXABLOCK enum { LW_QMODELINDEX_ROLE = Qt::UserRole + 1, LW_ASSOC_ROLE, - LW_GEOM_OBJ_ROLE + LW_GEOM_OBJ_ROLE, + LW_DATA_ROLE }; HexaBaseDialog( QWidget * parent = 0, Mode editmode = NEW_MODE, Qt::WindowFlags f = 0 ); - virtual ~HexaBaseDialog(); + virtual ~HexaBaseDialog(){}; // clear all input widget - virtual void clear(); + virtual void clear(){}; + ViewType getObjectViewType(QObject* obj); // model - virtual void setDocumentModel( DocumentModel* m ); + virtual void setDocumentModel( DocumentModel* m ){ _documentModel = m;} // selection - virtual void setPatternDataSelectionModel( PatternDataSelectionModel* s ); - virtual void setPatternBuilderSelectionModel( PatternBuilderSelectionModel* s ); - virtual void setGroupsSelectionModel( GroupsSelectionModel* s ); - virtual void setMeshSelectionModel( MeshSelectionModel* s ); + virtual void setPatternDataSelectionModel( PatternDataSelectionModel* s ) + { _patternDataSelectionModel = s;} + + virtual void setPatternBuilderSelectionModel( PatternBuilderSelectionModel* s ) + { _patternBuilderSelectionModel = s; } + + virtual void setGroupsSelectionModel( GroupsSelectionModel* s ) + { _groupsSelectionModel = s; } + + virtual void setMeshSelectionModel( MeshSelectionModel* s ) + { _meshSelectionModel = s; } + + void resetSizeAndShow(QDockWidget* parent); + void lockSizeToSizeHint(); + void unlockSizeModification(); + virtual QModelIndexList getAssocsVTK() + { + QModelIndexList assocs; + return assocs; + } + virtual QMultiMap getAssocsGEOM() + { + QMultiMap assocs; + return assocs; + } + void clearVTKSelection(); + void clearOCCSelection(); + + bool debugEdgeAssoc; //Temporary public slots: //virtual void accept(); @@ -144,7 +180,6 @@ namespace HEXABLOCK virtual void close(); virtual void onHelpRequested(); - protected: virtual bool eventFilter(QObject *obj, QEvent *event); virtual void hideEvent ( QHideEvent * event ); @@ -154,16 +189,17 @@ namespace HEXABLOCK virtual void _initInputWidget( Mode editmode )=0; //must be implemented on inherited dialog box virtual QGroupBox* _initButtonBox( Mode editmode ); void _initWidget( Mode editmode ); // call _initInputWidget() & _initButtonBox() + QModelIndexList getIndexList(QListWidget* itemsList); void _initViewManager(); - void _allowSelection(); void _disallowSelection(); QItemSelectionModel* _allowSelection( HexaWidgetType wtype ); bool _allowVTKSelection( QObject* obj ); bool _allowOCCSelection( QObject* obj ); + void setOCCSelectionMode(TopAbs_ShapeEnum mode); QItemSelectionModel* _getSelector( QObject* obj ); @@ -172,6 +208,9 @@ namespace HEXABLOCK void _selectAndHighlight( const QModelIndex& i ); + void _highlightWidget(QObject* obj, Qt::GlobalColor clr); + + void setFocusToNextField(); Mode _editMode; @@ -200,13 +239,21 @@ namespace HEXABLOCK QString _helpFileName; + private: + bool _isLineOrListWidget(QObject*); + void _updateCurrentObject(QObject*); + TopAbs_ShapeEnum currentOCCSelectionMode; + void refreshConnects(); + + protected slots: virtual void onSelectionChanged( const QItemSelection& sel, const QItemSelection& unsel ); //from qt model/view selectionManager virtual void onCurrentSelectionChanged();//from salome selectionManager - virtual void onWindowActivated( SUIT_ViewManager* vm ); + virtual void onWindowActivated(SUIT_ViewManager*){}; virtual void updateButtonBox(); void updateName(); - void selectElementOfModel(); + virtual void selectElementOfModel(); + void highlightSelectedAssocs(); }; @@ -306,6 +353,7 @@ namespace HEXABLOCK virtual ~HexaDialog(); void clear(); + virtual QModelIndexList getAssocsVTK(); void setValue(HEXA_NS::Hexa* v); HEXA_NS::Hexa* getValue(); @@ -553,8 +601,8 @@ namespace HEXABLOCK public: PrismQuadDialog( QWidget* = 0, Mode = NEW_MODE, Qt::WindowFlags = Qt::SubWindow );//= 0 ); virtual ~PrismQuadDialog(); - void clear(); + virtual QModelIndexList getAssocsVTK(); public slots: virtual bool apply(QModelIndex& result); @@ -562,6 +610,10 @@ namespace HEXABLOCK protected: void _initInputWidget( Mode editmode ); + protected slots: + void addHeightItem(); + void delHeightItem(); + private slots: void addQuad(); void removeQuad(); @@ -579,6 +631,7 @@ namespace HEXABLOCK virtual ~JoinQuadDialog(); void clear(); + virtual QModelIndexList getAssocsVTK(); public slots: virtual bool apply(QModelIndex& result); @@ -766,6 +819,8 @@ namespace HEXABLOCK EdgeAssocDialog( QWidget* = 0, Mode = NEW_MODE, Qt::WindowFlags = Qt::SubWindow );//= 0 ); virtual ~EdgeAssocDialog(); void clear(); + virtual QModelIndexList getAssocsVTK(); + virtual QMultiMap getAssocsGEOM(); void setGeomEngine( GEOM::GEOM_Gen_var geomEngine ); @@ -783,6 +838,7 @@ namespace HEXABLOCK virtual void onCurrentSelectionChanged(); // void onSelectionChanged( const QItemSelection& sel, const QItemSelection& unsel ); virtual void onWindowActivated(SUIT_ViewManager*); + virtual void selectElementOfGeom(); void deleteEdgeItem(); void deleteLineItem(); @@ -792,6 +848,7 @@ namespace HEXABLOCK void pendChanged( double val ); private: +// QModelIndexList currentAssocList; // Preview in GEOM // GEOM::GeomObjPtr _firstLine; // GEOM::GeomObjPtr _lastLine; @@ -812,6 +869,8 @@ namespace HEXABLOCK QuadAssocDialog( QWidget* = 0, Mode = NEW_MODE, Qt::WindowFlags = Qt::SubWindow );//= 0 ); virtual ~QuadAssocDialog(); void clear(); + virtual QModelIndexList getAssocsVTK(); + virtual QMultiMap getAssocsGEOM(); public slots: virtual bool apply(QModelIndex& result); @@ -825,6 +884,7 @@ namespace HEXABLOCK virtual void onCurrentSelectionChanged(); virtual void onWindowActivated(SUIT_ViewManager*); void deleteFaceItem(); + virtual void selectElementOfGeom(); private: QList _assocs; @@ -844,6 +904,7 @@ namespace HEXABLOCK GroupDialog( QWidget* = 0, Mode = NEW_MODE, Qt::WindowFlags = Qt::SubWindow );//= 0 ); virtual ~GroupDialog(); void clear(); + virtual QModelIndexList getAssocsVTK(); void setValue(HEXA_NS::Group* v); HEXA_NS::Group* getValue(); @@ -916,6 +977,7 @@ namespace HEXABLOCK protected slots: void updateHelpFileName(); void deletePropagationItem(); + virtual void selectElementOfModel(); private: HEXA_NS::Propagation *_value; @@ -962,6 +1024,8 @@ namespace HEXABLOCK ReplaceHexaDialog( QWidget* = 0, Mode = NEW_MODE, Qt::WindowFlags = Qt::SubWindow );//= 0 ); virtual ~ReplaceHexaDialog(); void clear(); + virtual QModelIndexList getAssocsVTK(); + public slots: virtual bool apply(QModelIndex& result); @@ -990,6 +1054,7 @@ namespace HEXABLOCK QuadRevolutionDialog( QWidget* = 0, Mode = NEW_MODE, Qt::WindowFlags = Qt::SubWindow );//= 0 ); virtual ~QuadRevolutionDialog(); void clear(); + virtual QModelIndexList getAssocsVTK(); public slots: virtual bool apply(QModelIndex& result); diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.cxx index 393c908..5627b29 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include "HEXABLOCKGUI_SalomeTools.hxx" @@ -92,6 +93,7 @@ MyGEOMBase_Helper( SUIT_Session::session()->activeApplication()->desktop() ), _theModelSelectionChanged(false), _theVtkSelectionChanged(false), _theGeomSelectionChanged(false), +salomeNothingSelected(true), _selectionFilter(-1), _salomeSelectionMgr(0) { @@ -102,7 +104,6 @@ _salomeSelectionMgr(0) } - PatternDataSelectionModel::~PatternDataSelectionModel() { disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), @@ -115,7 +116,6 @@ PatternDataSelectionModel::~PatternDataSelectionModel() disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) ); } - void PatternDataSelectionModel::setVertexSelection() { MESSAGE("PatternDataSelectionModel::setVertexSelection(){"); @@ -150,7 +150,8 @@ void PatternDataSelectionModel::setQuadSelection() void PatternDataSelectionModel::setHexaSelection() { MESSAGE("PatternDataSelectionModel::setHexaSelection(){"); - SetSelectionMode(VolumeSelection); +// SetSelectionMode(VolumeSelection); + SetSelectionMode(FaceSelection); //temporary for hexa selection debug _selectionFilter = HEXA_TREE; MESSAGE("}"); } @@ -159,6 +160,7 @@ void PatternDataSelectionModel::setHexaSelection() void PatternDataSelectionModel::setAllSelection() { MESSAGE("PatternDataSelectionModel::setAllSelection(){"); + SetSelectionMode(ActorSelection); _selectionFilter = -1; MESSAGE("}"); } @@ -206,11 +208,11 @@ void PatternDataSelectionModel::setSalomeSelectionMgr( LightApp_SelectionMgr* mg void PatternDataSelectionModel::SetSelectionMode(Selection_Mode theMode) { MESSAGE("PatternDataSelectionModel::SetSelectionMode(){"); - SVTK_ViewWindow* aVTKViewWindow = _getVTKViewWindow(); +// SVTK_ViewWindow* aVTKViewWindow = _getVTKViewWindow(); // aViewWindow->clearFilters(); // _salomeSelectionMgr->clearFilters(); - if ( aVTKViewWindow ) - aVTKViewWindow->SetSelectionMode( theMode ); + if ( _getVTKViewWindow() != NULL ) + _getVTKViewWindow()->SetSelectionMode( theMode ); MESSAGE("}"); } @@ -236,49 +238,64 @@ void PatternDataSelectionModel::onCurrentChanged( const QModelIndex & current, c MESSAGE("PatternDataSelectionModel::onCurrentChanged(){"); MESSAGE("* current : " << current.data().toString().toStdString()); MESSAGE("* previous : " << previous.data().toString().toStdString()); + + //Setting the selection mode of the selected item from the treeview + _setVTKSelectionMode( current); + // _selectSalome( current, true ); // _selectSalome( previous, false ); MESSAGE("}"); } - +void PatternDataSelectionModel::highlightEltsWithAssocs(const QModelIndexList& elts) +{ + try { +// if ( HEXABLOCKGUI::selectionMgr() != NULL) HEXABLOCKGUI::selectionMgr()->clearSelected(); + highlightVTKElts(elts); + for( QModelIndexList::const_iterator i_index = elts.begin(); i_index != elts.end(); ++i_index ){ + // _selectVTK( *i_index ); + _highlightGEOM( *i_index ); + } + } catch ( ... ) { + MESSAGE("Unknown exception was cought !!!"); + } +} void PatternDataSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected ) { - MESSAGE("PatternDataSelectionModel::onSelectionChanged(){"); - foreach( const QModelIndex& isel, selected.indexes() ){ - MESSAGE("* selected : " << isel.data().toString().toStdString()); - } - foreach( const QModelIndex& iunsel, deselected.indexes() ){ - MESSAGE("* unselected : " << iunsel.data().toString().toStdString()); - } - - _theModelSelectionChanged = true; - try { - if ( _salomeSelectionMgr == NULL ) return; -// if ( !_theVtkSelectionChanged and !_theGeomSelectionChanged ) return; - - _salomeSelectionMgr->clearSelected(); - // erasePreview(true); - QModelIndexList indexes = selected.indexes(); - for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){ - // std::cout << "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() << std::endl; - if ( !_theVtkSelectionChanged ) _selectVTK( *i_index ); - if ( !_theGeomSelectionChanged ) _highlightGEOM( *i_index ); - } - // CS_BP todo SALOMEGUI_Swig.cxx:370 - // indexes = deselected.indexes(); - // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ) - // _unselectSalome( *i_index); - } catch ( ... ) { - MESSAGE("Unknown exception was cought !!!"); - } - _theModelSelectionChanged = false; - - MESSAGE("}"); +// MESSAGE("PatternDataSelectionModel::onSelectionChanged(){"); +// foreach( const QModelIndex& isel, selected.indexes() ){ +// MESSAGE("* selected : " << isel.data().toString().toStdString()); +// } +// foreach( const QModelIndex& iunsel, deselected.indexes() ){ +// MESSAGE("* unselected : " << iunsel.data().toString().toStdString()); +// } + +// _theModelSelectionChanged = true; +// try { +// if ( _salomeSelectionMgr == NULL ) return; +//// if ( !_theVtkSelectionChanged and !_theGeomSelectionChanged ) return; +// +// _salomeSelectionMgr->clearSelected(); +// // erasePreview(true); +// QModelIndexList indexes = selected.indexes(); +// for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){ +// // std::cout << "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() << std::endl; +// if ( !_theVtkSelectionChanged ) _selectVTK( *i_index ); +// if ( !_theGeomSelectionChanged ) _highlightGEOM( *i_index ); +// } +// // CS_BP todo SALOMEGUI_Swig.cxx:370 +// // indexes = deselected.indexes(); +// // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ) +// // _unselectSalome( *i_index); +// } catch ( ... ) { +// MESSAGE("Unknown exception was cought !!!"); +// } +// _theModelSelectionChanged = false; + +// MESSAGE("}"); } - void PatternDataSelectionModel::salomeSelectionChanged() { MESSAGE("PatternDataSelectionModel::salomeSelectionChanged(){"); @@ -291,11 +308,13 @@ void PatternDataSelectionModel::salomeSelectionChanged() _salomeSelectionMgr->selectedObjects( salomeSelected, NULL, false ); if ( salomeSelected.IsEmpty() ){ MESSAGE("* salomeSelected.IsEmpty()"); + salomeNothingSelected = true; clearSelection(); return; } Handle(SALOME_InteractiveObject) anIObject; + SALOME_ListIteratorOfListIO it(salomeSelected); for( ; it.More(); it.Next()){ anIObject = it.Value(); //anIObject->getName() @@ -308,23 +327,149 @@ void PatternDataSelectionModel::salomeSelectionChanged() MESSAGE("* OK : selection from GEOM"); } } + salomeNothingSelected = false; } catch ( ... ) { MESSAGE("* Unknown exception was cought !!!"); } MESSAGE("}"); } +QModelIndex PatternDataSelectionModel::_geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) +{ + MESSAGE("PatternDataSelectionModel::_geomSelectionChanged(){"); + QModelIndexList assocsIndexes;// elements of the model which is associated to the geom object and that is to be selected + QModelIndex assocIndex; + + if (HEXABLOCKGUI::assocInProgress) return assocIndex; + bool fromGEOM = ( strcmp("GEOM", anIObject->getComponentDataType()) == 0 ); + if ( !fromGEOM ) return assocIndex; + if (!_salomeSelectionMgr) return assocIndex; + + QString aName; + GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject( anIObject ); + + int anIndex = -1; + if ( GEOMBase::IsShape(aGeomObj) ){ + aName = GEOMBase::GetName(aGeomObj); + TColStd_IndexedMapOfInteger anIndexes; + _salomeSelectionMgr->GetIndexes(anIObject, anIndexes); + if ( anIndexes.Extent() == 1 ) + anIndex = anIndexes(1); + QString aGeomObjStudyEntry = aGeomObj->GetStudyEntry(); + QString aGeomObjModelEntry = aGeomObjStudyEntry + "," + QString::number(anIndex) + ";"; + assocsIndexes = _indexListOf( aGeomObjModelEntry, HEXA_ASSOC_ENTRY_ROLE ); + if ( !_theModelSelectionChanged && assocsIndexes.count()>0 && assocsIndexes[0].isValid() ){ // select in model + _theGeomSelectionChanged = true; + setCurrentIndex( assocsIndexes[0], QItemSelectionModel::Clear ); //CS_TEST + setCurrentIndex( assocsIndexes[0], QItemSelectionModel::SelectCurrent ); + _theGeomSelectionChanged = false; + } else { + clearSelection(); + } + } + + MESSAGE("}"); + + if (assocsIndexes.count() > 0) + { +// HEXABLOCKGUI::currentVtkView->setFocus(); + highlightVTKElts(assocsIndexes); + return assocsIndexes[0]; + } + return assocIndex; +} + +QModelIndex PatternDataSelectionModel::_vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) +{ + MESSAGE("PatternDataSelectionModel::_vtkSelectionChanged(){"); + QModelIndex anIOIndex;// // the element of the model which is associated to the Interactive object and that is to be selected + + bool fromVTK = ( strcmp("HEXABLOCK", anIObject->getComponentDataType()) == 0 ); + if ( !fromVTK ) return anIOIndex; + + SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow(); + if ( !currentVTKViewWindow ) return anIOIndex; + if ( !anIObject->hasEntry() ) return anIOIndex; + + QString anIOEntry = anIObject->getEntry(); + Document_Actor *anDocActor = NULL; + int anhexaElemsId; + + QString aText = ""; + if ( GetNameOfSelectedElements( currentVTKViewWindow, anIObject, aText ) <= 0 ) return anIOIndex; + anDocActor = dynamic_cast( findActorByEntry( currentVTKViewWindow, anIOEntry.toLatin1() ) ); + if ( !anDocActor ) return anIOIndex; + anhexaElemsId = anDocActor->hexaElemsId[ aText.toInt() ]; + anIOEntry = QString::number( anhexaElemsId ); + anIOIndex = _indexOf( anIOEntry, HEXA_ENTRY_ROLE ); + + if ( !_theModelSelectionChanged && anIOIndex.isValid() ){ // select in model + _theVtkSelectionChanged = true; + + //Temporary Debug for hexa selection ----------------------------------------------------------------- + if (getSelectionFilter() == HEXA_TREE) + { + DocumentModel *docModel = NULL; + const QSortFilterProxyModel *pModel = dynamic_cast( model() ); + + if ( pModel != NULL){ + docModel = dynamic_cast( pModel->sourceModel() ); + if ( docModel != NULL && anIOIndex.isValid()) + { + //get the selected quad + HEXA_NS::Quad* quad = docModel->getHexaPtr(anIOIndex); + if (quad != NULL) + { + //get the hexa the quad belongs to + HEXA_NS::Hexa* hexa = docModel->getQuadHexa(quad); + if (hexa != NULL) //convert the hexa to a QModelIndex so we can select it in the model + anIOIndex = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(hexa)); + else + { + SUIT_MessageBox::critical( 0, + tr("HexaBlock"), + tr("The Hexahedron This quad belongs to has been deleted!")); + return anIOIndex; + } + } + } + } + }//end if HEXA_TREE------------------------------------------------------------------------------------ + + setCurrentIndex( anIOIndex, QItemSelectionModel::Clear ); + setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent ); + _theVtkSelectionChanged = false; + } else { + clearSelection(); + } + +// if (anIOIndex.isValid()) +// _selectVTK(anIOIndex); + +// if (anIOIndex.isValid()) +// { +// QModelIndexList l; +// l << anIOIndex; +// highlightVTKElts(l); +// _highlightGEOM(anIOIndex); // JMD test à faire +// } + MESSAGE("}"); + return anIOIndex; +} + + SVTK_ViewWindow* PatternDataSelectionModel::_getVTKViewWindow() { - SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView; - return aVtkView; +// SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView; + return HEXABLOCKGUI::currentVtkView; } OCCViewer_ViewWindow* PatternDataSelectionModel::_getOCCViewWindow() { - OCCViewer_ViewWindow* aOccView = HEXABLOCKGUI::currentOccView; - return aOccView; +// OCCViewer_ViewWindow* aOccView = HEXABLOCKGUI::currentOccView; +// MESSAGE(" dans OCCViewer" << aOccView); + return HEXABLOCKGUI::currentOccView; } @@ -344,26 +489,41 @@ QModelIndex PatternDataSelectionModel::_indexOf( const QString& anEntry, int rol } -void PatternDataSelectionModel::_setVTKSelectionMode( const QModelIndex& eltIndex, SVTK_ViewWindow* vtkViewWindow ) +QModelIndexList PatternDataSelectionModel::_indexListOf( const QString& anEntry, int role ) +{ + QModelIndexList theIndexes; // element (vertex, edge, quad) of model + const QAbstractItemModel* theModel = model(); + if ( !theModel ) return theIndexes; + theIndexes = theModel->match( theModel->index(0, 0), + role, + anEntry, + -1, + Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString ); + return theIndexes; +} + + +void PatternDataSelectionModel::_setVTKSelectionMode( const QModelIndex& eltIndex ) { - MESSAGE("PatternDataSelectionModel::_setVTKSelectionMode( "<< eltIndex.data().toString().toStdString() << " ," << vtkViewWindow << " )"); + MESSAGE("PatternDataSelectionModel::_setVTKSelectionMode( "<< eltIndex.data().toString().toStdString() << " )"); QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE ); if ( !treeVariant.isValid() ) return; int eltType = treeVariant.toInt(); - if ( (_selectionFilter != -1) and ( _selectionFilter != eltType ) ) return; +// if ( (_selectionFilter != -1) and ( _selectionFilter != eltType ) ) return; + if ( _selectionFilter == eltType ) return; switch ( eltType ){ case VERTEX_TREE : - case VERTEX_DIR_TREE : vtkViewWindow->SetSelectionMode(NodeSelection); MESSAGE("VERTEX"); break; + case VERTEX_DIR_TREE : setVertexSelection(); MESSAGE("VERTEX"); break; case EDGE_TREE : - case EDGE_DIR_TREE : vtkViewWindow->SetSelectionMode(EdgeSelection); MESSAGE("EDGE"); break; + case EDGE_DIR_TREE : setEdgeSelection(); MESSAGE("EDGE"); break; case QUAD_TREE : - case QUAD_DIR_TREE : vtkViewWindow->SetSelectionMode(FaceSelection); MESSAGE("QUAD"); break; + case QUAD_DIR_TREE : setQuadSelection(); MESSAGE("QUAD"); break; case HEXA_TREE : - case HEXA_DIR_TREE : vtkViewWindow->SetSelectionMode(VolumeSelection); MESSAGE("HEXA"); break; + case HEXA_DIR_TREE : setHexaSelection(); MESSAGE("HEXA"); break; case PROPAGATION_TREE : - case PROPAGATION_DIR_TREE : vtkViewWindow->SetSelectionMode(EdgeSelection); MESSAGE("PROPAGATION"); break; + case PROPAGATION_DIR_TREE : setEdgeSelection(); MESSAGE("PROPAGATION"); break; // CellSelection, // EdgeOfCellSelection, // VolumeSelection, @@ -372,7 +532,6 @@ void PatternDataSelectionModel::_setVTKSelectionMode( const QModelIndex& eltInde } - void PatternDataSelectionModel::highlightVTKElts( const QModelIndexList& elts ) { if (!elts.size()) return; @@ -385,9 +544,11 @@ void PatternDataSelectionModel::highlightVTKElts( const QModelIndexList& elts ) // document selection Document_Actor* docActor = NULL; Handle(SALOME_InteractiveObject) docIO; +// Handle(SALOME_InteractiveObject) docIO2; //JMD // element highlight TColStd_MapOfInteger aMap; +// TColStd_MapOfInteger aMap2; QList::const_iterator anIter; int vtkElemsId; @@ -406,20 +567,77 @@ void PatternDataSelectionModel::highlightVTKElts( const QModelIndexList& elts ) docActor = dynamic_cast( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) ); if ( docActor == NULL) return; + // // Set selection mode in VTK view -// currentVTKViewWindow->SetSelectionMode(EdgeSelection); +// currentVTKViewWindow->SetSelectionMode(VolumeSelection); docIO = docActor->getIO(); + + +// QString autreDocentry = "toti"; +// Associate_Actor* associateActor = dynamic_cast( findActorByEntry( currentVTKViewWindow, autreDocentry.toLatin1() ) ); +// docIO2 = associateActor->getIO(); + // Highlight in vtk view the element from document - QString edgeEntry; + //bool rr = true; + + QString eltEntry; foreach( const QModelIndex& iElt, elts ){ - edgeEntry = iElt.data( HEXA_ENTRY_ROLE ).toString(); - vtkElemsId = docActor->vtkElemsId[ edgeEntry.toInt() ]; + eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString(); + vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ]; if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId ); +// if (rr) { +// if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId ); +// } +// else +// { +// if ( vtkElemsId > 0 ) aMap2.Add( vtkElemsId ); +// } +// rr = ! rr; } - selector->AddOrRemoveIndex( docIO, aMap, false ); + selector->AddOrRemoveIndex( docIO, aMap, false ); //true +// selector->RemoveIObject(docActor); currentVTKViewWindow->highlight( docIO, true, true ); +// Document_Actor* docActor = NULL; +// QVariant docEntryVariant = selected.data( HEXA_DOC_ENTRY_ROLE ); +// if ( docEntryVariant.isValid() ){ +// QString docEntry = docEntryVariant.toString(); +// docActor = dynamic_cast( findActorByEntry( HEXABLOCKGUI::currentVtkView, docEntry.toLatin1() ) ); +// if ( docActor != NULL) HEXABLOCKGUI::currentVtkView->getView()->highlight( docActor->getIO(), false, false ); +// } +// currentVTKViewWindow->getView()->SetColor(docIO, QColor("blue")); + + +// selector->AddOrRemoveIndex( docIO2, aMap2, false ); +// currentVTKViewWindow->highlight( docIO2, true, true ); +} + +//SUIT_ViewManager* PatternDataSelectionModel::initOccViewManager() +//{ +// SalomeApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); +// SUIT_ViewManager* occVm = anApp->getViewManager( OCCViewer_Viewer::Type(), true ); +// SVTK_ViewWindow* viewWindow = dynamic_cast(svw); +// return viewWindow; +//} +SUIT_ViewWindow* PatternDataSelectionModel::initOccViewManager() +{ + SalomeApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); + SUIT_ViewManager* occVm = anApp->getViewManager( OCCViewer_Viewer::Type(), true ); + + QVector viewS = occVm->getViews (); + + int nb = viewS.count(); + + MESSAGE("????HexaBaseDialog::initOccView number of : " << nb); + + if (nb == 1) + { + MESSAGE(" OK ????HexaBaseDialog::initOccView number of : " << nb); + return viewS.first(); + } + + return NULL; } // 1 vertex -> 1 point @@ -428,17 +646,28 @@ void PatternDataSelectionModel::highlightVTKElts( const QModelIndexList& elts ) void PatternDataSelectionModel::_highlightGEOM( const QMultiMap& entrySubIDs ) { MESSAGE("PatternDataSelectionModel::_highlightGEOM( const QMultiMap& entrySubIDs ){"); + MESSAGE("debut entry => "<< entrySubIDs.count()); OCCViewer_ViewWindow* occView = _getOCCViewWindow(); - if ( occView == NULL ) return; - SOCC_Viewer* soccViewer = dynamic_cast( occView->getViewManager()->getViewModel() ); + if ( occView == NULL ) { +// occView = (OCCViewer_ViewWindow*)initOccViewManager(); +// if ( occView == NULL ) + return; + } + MESSAGE("step 1 occView=> " << occView); + + MESSAGE("step 1 entry => "); + SOCC_Viewer* soccViewer = dynamic_cast( occView->getViewManager()->getViewModel() ); if (!soccViewer) return; + MESSAGE("step 2 entry => "); _PTR(Study) aStudy = GetActiveStudyDocument(); if (!aStudy) return; + MESSAGE("step 3 entry => "); CORBA::Object_var aCorbaObj = CORBA::Object::_nil(); GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_nil(); erasePreview(true); + MESSAGE("Avant entry => "<< entrySubIDs.count()); foreach ( QString entry, entrySubIDs.keys() ){ _PTR(SObject) aSChild = aStudy->FindObjectID( entry.toStdString() ); MESSAGE("* entry => "<< entry.toStdString()); @@ -452,7 +681,7 @@ void PatternDataSelectionModel::_highlightGEOM( const QMultiMap& MESSAGE("* !aSh.IsNull() "); TColStd_IndexedMapOfInteger anIndexes; foreach ( int subid, entrySubIDs.values(entry) ){ - if ( subid != -1 ) + if ( subid != -1 ) anIndexes.Add( subid ); } if ( anIndexes.Extent() > 0 ){ // if it's a sub-shape @@ -486,18 +715,21 @@ void PatternDataSelectionModel::_highlightGEOM( const QModelIndex & anEltIndex ) const QSortFilterProxyModel *pModel = dynamic_cast( model() ); if ( !pModel ) return; - docModel = dynamic_cast( pModel->sourceModel() ); + docModel = dynamic_cast( pModel->sourceModel() ); if ( !docModel ) return; assocs = docModel->getAssociations( pModel->mapToSource(anEltIndex) ); foreach( const DocumentModel::GeomObj& anAssoc, assocs ) - assocEntrySubIDs.insert( anAssoc.entry, anAssoc.subid.toInt() ); + { +// MESSAGE(" dedans " << anAssoc.entry.toStdString()); +// MESSAGE(" + " << anAssoc.subid.toInt()); + assocEntrySubIDs.insert( anAssoc.entry, anAssoc.subid.toInt() ); + } _highlightGEOM( assocEntrySubIDs ); MESSAGE("}"); } - void PatternDataSelectionModel::_selectVTK( const QModelIndex& eltIndex ) { MESSAGE("PatternDataSelectionModel::_selectVTK( "<< eltIndex.data().toString().toStdString() << ")"); @@ -539,7 +771,7 @@ void PatternDataSelectionModel::_selectVTK( const QModelIndex& eltIndex ) if ( docActor == NULL ) return; // Set selection mode in VTK view - _setVTKSelectionMode( eltIndex, currentVTKViewWindow ); + //_setVTKSelectionMode( eltIndex, currentVTKViewWindow ); // if ( _salomeSelectionMgr == NULL ) return; // _salomeSelectionMgr->selectedObjects( aList ); @@ -547,8 +779,8 @@ void PatternDataSelectionModel::_selectVTK( const QModelIndex& eltIndex ) // aList.Append(docIO); // _salomeSelectionMgr->setSelectedObjects( aList, true );//false );//true ); //CS_BP false? docIO = docActor->getIO(); - - // Highlight in vtk view the element from document + + // Highlight in vtk view the element from document vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ];// get vtk ids from actor if ( vtkElemsId > 0 ) // CS_BP ?: erreur si 1er elt == vertex (0,0,0) aMap.Add( vtkElemsId ); @@ -561,106 +793,6 @@ void PatternDataSelectionModel::_selectVTK( const QModelIndex& eltIndex ) MESSAGE("}"); } -QModelIndex PatternDataSelectionModel::_geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) -{ - MESSAGE("PatternDataSelectionModel::_geomSelectionChanged(){"); - QModelIndex eltIndex;// the element of the model which is associated to the geom object and that is to be selected - - bool fromGEOM = ( strcmp("GEOM", anIObject->getComponentDataType()) == 0 ); - if ( !fromGEOM ) return eltIndex; - if (!_salomeSelectionMgr) return eltIndex; - - QString aName; - GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject( anIObject ); - - int anIndex = -1; - if ( GEOMBase::IsShape(aGeomObj) ){ - aName = GEOMBase::GetName(aGeomObj); - TColStd_IndexedMapOfInteger anIndexes; - _salomeSelectionMgr->GetIndexes(anIObject, anIndexes); - if ( anIndexes.Extent() == 1 ) - anIndex = anIndexes(1); - QString aGeomObjStudyEntry = aGeomObj->GetStudyEntry(); - QString aGeomObjModelEntry = aGeomObjStudyEntry + "," + QString::number(anIndex) + ";"; - eltIndex = _indexOf( aGeomObjModelEntry, HEXA_ASSOC_ENTRY_ROLE ); - if ( !_theModelSelectionChanged && eltIndex.isValid() ){ // select in model - _theGeomSelectionChanged = true; - // select( newIndex, QItemSelectionModel::ClearAndSelect ); - // select( newIndex, QItemSelectionModel::SelectCurrent ); -// setCurrentIndex( eltIndex, QItemSelectionModel::SelectCurrent ); - setCurrentIndex( eltIndex, QItemSelectionModel::Clear ); //CS_TEST - setCurrentIndex( eltIndex, QItemSelectionModel::SelectCurrent ); - _theGeomSelectionChanged = false; - - } else { - clearSelection(); - } - } - - MESSAGE("}"); - return eltIndex; -} - -QModelIndex PatternDataSelectionModel::_vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) -{ - MESSAGE("PatternDataSelectionModel::_vtkSelectionChanged(){"); - QModelIndex anIOIndex;// // the element of the model which is associated to the Interactive object and that is to be selected - - bool fromVTK = ( strcmp("HEXABLOCK", anIObject->getComponentDataType()) == 0 ); - if ( !fromVTK ) return anIOIndex; - SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow(); - if ( !currentVTKViewWindow ) return anIOIndex; - if ( !anIObject->hasEntry() ) return anIOIndex; - - QString anIOEntry = anIObject->getEntry(); - Document_Actor *anDocActor = NULL; - int anhexaElemsId; - - QString aText = ""; - if ( GetNameOfSelectedElements( currentVTKViewWindow, anIObject, aText ) <= 0 ) return anIOIndex; - anDocActor = dynamic_cast( findActorByEntry( currentVTKViewWindow, anIOEntry.toLatin1() ) ); - if ( !anDocActor ) return anIOIndex; - anhexaElemsId = anDocActor->hexaElemsId[ aText.toInt() ]; - anIOEntry = QString::number( anhexaElemsId ); - anIOIndex = _indexOf( anIOEntry, HEXA_ENTRY_ROLE ); - - if ( !_theModelSelectionChanged && anIOIndex.isValid() ){ // select in model - _theVtkSelectionChanged = true; -// select( anIOIndex, QItemSelectionModel::Clear ); -// select( anIOIndex, QItemSelectionModel::Select ); -// select( anIOIndex, QItemSelectionModel::ClearAndSelect ); -// select( anIOIndex, QItemSelectionModel::SelectCurrent ); -// setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent ); -// setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent ); -// setCurrentIndex( anIOIndex, QItemSelectionModel::ClearAndSelect ); -// setCurrentIndex( anIOIndex, QItemSelectionModel::ClearAndSelect ); - setCurrentIndex( anIOIndex, QItemSelectionModel::Clear ); - setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent ); - _theVtkSelectionChanged = false; - } else { - clearSelection(); - } - -// if (anIOIndex.isValid()) -// _selectVTK(anIOIndex); - - if (anIOIndex.isValid()) - { - QModelIndexList l; - l << anIOIndex; - highlightVTKElts(l); - } - - MESSAGE("}"); - return anIOIndex; -} - - - - - - - GroupsSelectionModel::GroupsSelectionModel( QAbstractItemModel * model ): QItemSelectionModel( model ) { @@ -670,7 +802,6 @@ QItemSelectionModel( model ) this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) ); } - GroupsSelectionModel::~GroupsSelectionModel() { disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), @@ -700,15 +831,15 @@ QModelIndex GroupsSelectionModel::indexBy( int role, const QVariant& var ) SVTK_ViewWindow* GroupsSelectionModel::_getVTKViewWindow() { - SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView; - return aVtkView; +// SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView; + return HEXABLOCKGUI::currentVtkView; } void GroupsSelectionModel::_highlightGroups( const QModelIndex& eltIndex ) { const GroupsModel* m = dynamic_cast( model() ); - + // ---- VTK ---- if ( m == NULL ) return; SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow(); @@ -728,7 +859,7 @@ void GroupsSelectionModel::_highlightGroups( const QModelIndex& eltIndex ) int vtkElemsId; - + // debut ** data from model int eltType; QString docEntry; @@ -736,7 +867,7 @@ void GroupsSelectionModel::_highlightGroups( const QModelIndex& eltIndex ) QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE ); QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE ); - if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){ + if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){ //INFOS("data from model not valid"); return; } @@ -779,86 +910,6 @@ void GroupsSelectionModel::_highlightGroups( const QModelIndex& eltIndex ) } -/* -void GroupsSelectionModel::_highlightAssoc( const QModelIndex& eltIndex ) -{ - const GroupsModel* m = dynamic_cast( model() ); - -// ---- VTK ---- - if ( m == NULL ) return; - SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow(); - if ( currentVTKViewWindow == NULL ) return; - SVTK_Selector* selector = currentVTKViewWindow->GetSelector(); - if ( selector == NULL ) return; - -// ---- vtkActor - // document selection - Document_Actor* docActor = NULL; - Handle(SALOME_InteractiveObject) docIO; - SALOME_ListIO aList; - - // element highlight - TColStd_MapOfInteger aMap; - QList::const_iterator anIter; - int vtkElemsId; - - - - // debut ** data from model - int eltType; - QString docEntry; - - QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE ); - QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE ); - - if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){ - //INFOS("data from model not valid"); - return; - } - - eltType = treeVariant.toInt(); - docEntry = docEntryVariant.toString(); - ){ - //INFOS("bad element typ - if ( eltType != GROUP_TREE ){ - //INFOS("bad element type : not a group item" << eltType ); - return; - } - // fin ** data from model - - // Select the document in Salome - docActor = dynamic_cast( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) ); - if ( docActor == NULL) return; - docIO = docActor->getIO(); - - // Highlight in vtk view the element from document - DocumentModel::Group kind; - QModelIndexList iElements = m->getGroupElements( eltIndex, kind ); - - // Set selection mode in VTK view -/* - switch (kind){ - case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: currentVTKViewWindow->SetSelectionMode(VolumeSelection); break; - case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: currentVTKViewWindow->SetSelectionMode(FaceSelection); break; - case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: currentVTKViewWindow->SetSelectionMode(EdgeSelection); break; - case HEXA_NS::VertexNode: currentVTKViewWindow->SetSelectionMode(NodeSelection); break; - }---/ - - QString eltEntry; - foreach( const QModelIndex& iElt, iElements ){ - eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString(); - vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ]; - if() - if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId ); - } - - selector->AddOrRemoveIndex( docIO, aMap, false ); - currentVTKViewWindow->highlight( docIO, true, true ); - -}*/ - - - void GroupsSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected ) { MESSAGE("GroupsSelectionModel::onSelectionChanged"); @@ -882,12 +933,6 @@ void GroupsSelectionModel::onSelectionChanged( const QItemSelection & selected, } - - - - - - MeshSelectionModel::MeshSelectionModel( QAbstractItemModel * model ): QItemSelectionModel( model ) { @@ -926,8 +971,8 @@ QModelIndex MeshSelectionModel::indexBy( int role, const QVariant& var ) SVTK_ViewWindow* MeshSelectionModel::_getVTKViewWindow() { - SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView; - return aVtkView; +// SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView; + return HEXABLOCKGUI::currentVtkView; } @@ -957,7 +1002,7 @@ void MeshSelectionModel::_highlightPropagation( const QModelIndex& eltIndex ) QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE ); QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE ); - if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){ + if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){ //INFOS("data from model not valid"); return; } @@ -975,10 +1020,10 @@ void MeshSelectionModel::_highlightPropagation( const QModelIndex& eltIndex ) if ( docActor == NULL) return; // // Set selection mode in VTK view - currentVTKViewWindow->SetSelectionMode(EdgeSelection); + currentVTKViewWindow->SetSelectionMode(EdgeSelection); docIO = docActor->getIO(); - - // Highlight in vtk view the element from document + + // Highlight in vtk view the element from document QModelIndexList iEdges = m->getPropagation( eltIndex ); QString edgeEntry; @@ -1018,8 +1063,6 @@ void MeshSelectionModel::onSelectionChanged( const QItemSelection & selected, co } - - // //================================================================================= // // function : activateSelection // // purpose : Activate selection in accordance with myEditCurrentArgument diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.hxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.hxx index 4301931..e2ee8b0 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.hxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.hxx @@ -21,7 +21,6 @@ #define _HEXABLOCKGUI_DOCUMENTSELECTIONMODEL_HXX_ #include - #include #include @@ -69,14 +68,22 @@ namespace HEXABLOCK void setHexaSelection(); void setAllSelection(); void highlightVTKElts( const QModelIndexList& elts ); + void highlightEltsWithAssocs(const QModelIndexList& elts); + void _highlightGEOM( const QMultiMap& entrySubIDs ); + void _highlightGEOM( const QModelIndex & index ); - // QModelIndex indexBy( int role, const QString& value ); QModelIndex indexBy( int role, const QVariant& var ); + int getSelectionFilter() const { return _selectionFilter;} //Salome void setSalomeSelectionMgr( LightApp_SelectionMgr* mgr ); void SetSelectionMode( Selection_Mode theMode ); + QModelIndex _geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ); + QModelIndex _vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ); + + + bool salomeNothingSelected; protected slots: void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous ); @@ -88,21 +95,19 @@ namespace HEXABLOCK OCCViewer_ViewWindow* _getOCCViewWindow(); QModelIndex _indexOf( const QString& anIOEntry, int role ); - void _setVTKSelectionMode( const QModelIndex& eltIndex, SVTK_ViewWindow* vtkViewWindow ); - void _highlightGEOM( const QMultiMap& entrySubIDs ); - void _highlightGEOM( const QModelIndex & index ); + QModelIndexList _indexListOf( const QString& anEntry, int role ); + void _setVTKSelectionMode( const QModelIndex& eltIndex ); void _selectVTK( const QModelIndex & index ); + SUIT_ViewWindow* initOccViewManager(); - QModelIndex _geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ); - QModelIndex _vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ); LightApp_SelectionMgr* _salomeSelectionMgr; int _selectionFilter; + bool _theModelSelectionChanged; bool _theVtkSelectionChanged; bool _theGeomSelectionChanged; - }; diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_SalomeTools.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_SalomeTools.cxx index d046bce..aef9246 100644 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_SalomeTools.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_SalomeTools.cxx @@ -270,16 +270,21 @@ int GetNameOfSelectedElements( SVTK_ViewWindow *theWindow, QString& theName ) { SVTK_Selector* theSelector = theWindow->GetSelector(); + theName = ""; + TColStd_IndexedMapOfInteger aMapIndex; theSelector->GetIndex(theIO,aMapIndex); typedef std::set TIdContainer; + std::set anIdContainer; + for( int i = 1; i <= aMapIndex.Extent(); i++) anIdContainer.insert(aMapIndex(i)); std::set::const_iterator anIter = anIdContainer.begin(); + for( ; anIter != anIdContainer.end(); anIter++) theName += QString(" %1").arg(*anIter); diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_SalomeTools.hxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_SalomeTools.hxx index 71738cc..9b64ae7 100644 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_SalomeTools.hxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_SalomeTools.hxx @@ -46,11 +46,15 @@ namespace HEXABLOCK SALOME_Actor* findActorByEntry( SVTK_ViewWindow *theVtkViewWindow, const char* theEntry ); _PTR(Study) GetActiveStudyDocument(); + CORBA::Object_var corbaObj( _PTR(SObject) theSO ); + CORBA::Object_var corbaObj( const Handle(SALOME_InteractiveObject)& theIO ); + int GetNameOfSelectedElements( SVTK_ViewWindow *theWindow,/* SVTK_Selector* theSelector,*/ const Handle(SALOME_InteractiveObject)& theIO, QString& theName ); + std::string shape2string( const TopoDS_Shape& aShape ); diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_Trace.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_Trace.cxx index 9b7a2e1..c8b563e 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_Trace.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_Trace.cxx @@ -23,11 +23,11 @@ #include "HEXABLOCKGUI_Trace.hxx" - #ifdef WNT #include #define getpid _getpid #else +#include #include #endif diff --git a/src/HEXABLOCKGUI/Hexa_QTD.ui b/src/HEXABLOCKGUI/Hexa_QTD.ui index 85f2389..5b1e818 100755 --- a/src/HEXABLOCKGUI/Hexa_QTD.ui +++ b/src/HEXABLOCKGUI/Hexa_QTD.ui @@ -6,12 +6,12 @@ 0 0 - 217 - 387 + 215 + 412 - + 0 0 @@ -20,15 +20,18 @@ Hexahedron Construction - - QLayout::SetMinimumSize - + + + 0 + 0 + + Result Name - + @@ -39,14 +42,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -66,7 +69,7 @@ Hexa - + @@ -101,12 +104,24 @@ + + + 0 + 0 + + Arguments + + + 0 + 0 + + Select a quad @@ -114,6 +129,12 @@ + + + 0 + 0 + + Select a vertex @@ -124,37 +145,44 @@ + + name_le + quads_lw + vertices_lw + quads_rb + vertices_rb + quads_rb clicked() - quads_lw - show() + vertices_lw + hide() - 74 + 95 45 - 135 - 220 + 173 + 435 quads_rb clicked() - vertices_lw - hide() + quads_lw + show() - 95 + 74 45 - 173 - 435 + 135 + 220 diff --git a/src/HEXABLOCKGUI/JoinQuad_QTD.ui b/src/HEXABLOCKGUI/JoinQuad_QTD.ui index bdd0f8d..da20b11 100644 --- a/src/HEXABLOCKGUI/JoinQuad_QTD.ui +++ b/src/HEXABLOCKGUI/JoinQuad_QTD.ui @@ -6,8 +6,8 @@ 0 0 - 256 - 440 + 259 + 543 @@ -17,7 +17,7 @@ - + 0 0 @@ -25,11 +25,11 @@ From - - + + - + 0 0 @@ -38,83 +38,76 @@ Quadrangle(s) - - + + + + + + + + + + + 0 + 0 + + + + + + + Point a + + + + + - + 0 0 - - + + + 16777215 + 16777215 + + + + false + + + + + + + Point b - - + + + + + + + 0 + 0 + - - + + + 16777215 + 16777215 + - - QAbstractItemView::MultiSelection + + false - - - - Point a - - - - - - - - 0 - 0 - - - - - 127 - 16777215 - - - - false - - - - - - - Point b - - - - - - - - 0 - 0 - - - - - 127 - 16777215 - - - - false - - - @@ -140,7 +133,7 @@ - + 0 0 @@ -160,14 +153,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -186,14 +179,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -233,7 +226,7 @@ - + 0 0 @@ -251,6 +244,14 @@ + + vex0_le + vex2_le + quad_dest_le + vex1_le + vex3_le + nb_spb + diff --git a/src/HEXABLOCKGUI/Law_QTD.ui b/src/HEXABLOCKGUI/Law_QTD.ui index 5e33574..1f9dbd1 100644 --- a/src/HEXABLOCKGUI/Law_QTD.ui +++ b/src/HEXABLOCKGUI/Law_QTD.ui @@ -47,9 +47,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -95,6 +101,12 @@ + + + 0 + 0 + + Uniform diff --git a/src/HEXABLOCKGUI/MakeCartesian_QTD.ui b/src/HEXABLOCKGUI/MakeCartesian_QTD.ui index 6ebaeea..78953b6 100644 --- a/src/HEXABLOCKGUI/MakeCartesian_QTD.ui +++ b/src/HEXABLOCKGUI/MakeCartesian_QTD.ui @@ -6,12 +6,12 @@ 0 0 - 232 - 540 + 219 + 500 - + 0 0 @@ -21,7 +21,7 @@ - QLayout::SetMinimumSize + QLayout::SetDefaultConstraint @@ -75,9 +75,15 @@ + + + 0 + 0 + + - - Qt::AlignJustify|Qt::AlignVCenter + + QFormLayout::AllNonFixedFieldsGrow @@ -88,6 +94,12 @@ + + + 0 + 0 + + 16777215 @@ -108,6 +120,12 @@ + + + 0 + 0 + + 16777215 @@ -119,100 +137,90 @@ - - - + + + + n (x) + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - Qt::AlignJustify|Qt::AlignTop - - - 8 - - - - - n (x) - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - 1000000 - - - 1 - - - - - - - - 0 - 0 - - - - 1000000 - - - 1 - - - - - - - - 0 - 0 - - - - 1000000 - - - 1 - - - - - - - n (y) - - - - - - - n (z) - - - - + + + + + + + 0 + 0 + + + + 1000000 + + + 1 + + + + + + + n (y) + + + + + + + + 0 + 0 + + + + 1000000 + + + 1 + + + + + + + n (z) + + + + + + + + 0 + 0 + + + + 1000000 + + + 1 + + + + + 0 + 0 + + - - Qt::AlignJustify|Qt::AlignVCenter - @@ -222,6 +230,12 @@ + + + 0 + 0 + + 16777215 @@ -242,6 +256,12 @@ + + + 0 + 0 + + 16777215 @@ -262,6 +282,12 @@ + + + 0 + 0 + + 16777215 @@ -282,6 +308,12 @@ + + + 0 + 0 + + 16777215 @@ -293,84 +325,74 @@ - - - - Qt::AlignJustify|Qt::AlignVCenter - - - 8 - - - - - n (x) - - - - - - - - 0 - 0 - - - - 1000000 - - - 1 - - - - - - - - 0 - 0 - - - - 1000000 - - - 1 - - - - - - - - 0 - 0 - - - - 1000000 - - - 1 - - - - - - - n (y) - - - - - - - n (z) - - - - + + + + n (x) + + + + + + + + 0 + 0 + + + + 1000000 + + + 1 + + + + + + + n (y) + + + + + + + + 0 + 0 + + + + 1000000 + + + 1 + + + + + + + n (z) + + + + + + + + 0 + 0 + + + + 1000000 + + + 1 + + @@ -380,6 +402,22 @@ + + rb0 + rb1 + vex_le_rb0 + vec_le_rb0 + vex_le_rb1 + vec_x_le_rb1 + vec_y_le_rb1 + vec_z_le_rb1 + nx_spb_rb0 + ny_spb_rb0 + nz_spb_rb0 + nx_spb_rb1 + ny_spb_rb1 + nz_spb_rb1 + diff --git a/src/HEXABLOCKGUI/MakeCylinder_QTD.ui b/src/HEXABLOCKGUI/MakeCylinder_QTD.ui index 1d6861e..d940909 100644 --- a/src/HEXABLOCKGUI/MakeCylinder_QTD.ui +++ b/src/HEXABLOCKGUI/MakeCylinder_QTD.ui @@ -7,7 +7,7 @@ 0 0 190 - 238 + 196 @@ -53,9 +53,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -73,9 +79,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -84,7 +96,14 @@ - + + + + n (radial) + + + + 1000000 @@ -94,21 +113,14 @@ - - - - n (radial) - - - - - + + - n (heigth) + n (angular) - + 1000000 @@ -118,7 +130,14 @@ - + + + + n (heigth) + + + + 1000000 @@ -128,13 +147,6 @@ - - - - n (angular) - - - diff --git a/src/HEXABLOCKGUI/MakeCylinders_QTD.ui b/src/HEXABLOCKGUI/MakeCylinders_QTD.ui index 38c0d4b..7d4fc63 100644 --- a/src/HEXABLOCKGUI/MakeCylinders_QTD.ui +++ b/src/HEXABLOCKGUI/MakeCylinders_QTD.ui @@ -7,7 +7,7 @@ 0 0 212 - 104 + 106 @@ -26,9 +26,6 @@ Arguments - - QFormLayout::ExpandingFieldsGrow - @@ -38,9 +35,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -58,9 +61,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 diff --git a/src/HEXABLOCKGUI/MakeCylindrical_QTD.ui b/src/HEXABLOCKGUI/MakeCylindrical_QTD.ui index 1e38434..9007a79 100644 --- a/src/HEXABLOCKGUI/MakeCylindrical_QTD.ui +++ b/src/HEXABLOCKGUI/MakeCylindrical_QTD.ui @@ -6,8 +6,8 @@ 0 0 - 245 - 464 + 223 + 428 @@ -22,102 +22,132 @@ + + + 0 + 0 + + Arguments + + + 0 + 0 + + - - - - - - - Vertex - - - - - - - - 127 - 16777215 - - - - false - - - - + + + + + Vertex + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + false + + + + + 0 + 0 + + - - - - - - - Vector(x) - - - - - - - - 127 - 16777215 - - - - false - - - - + + + + + Vector(x) + + - - - - - - Vector(z) - - - - - - - - 127 - 16777215 - - - - false - - - - + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + false + + + + + + + Vector(z) + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + false + + + + + 0 + 0 + + @@ -142,7 +172,14 @@ - + + + + da: + + + + 6 @@ -158,7 +195,14 @@ - + + + + dl: + + + + 6 @@ -171,25 +215,17 @@ - - - - da: - - - - - - - dl: - - - + + + 0 + 0 + + @@ -211,37 +247,37 @@ - - - - 1000000 - - - 6 + + + + na: - - + + 1000000 - 10 + 6 - + - na: + nl: - - - - nl: + + + + 1000000 + + + 10 @@ -260,6 +296,18 @@ + + pt_le + vec_x_le + vec_z_le + dr_spb + da_spb + dl_spb + nr_spb + na_spb + nl_spb + fill_cb + diff --git a/src/HEXABLOCKGUI/MakeGrid_QTD.ui b/src/HEXABLOCKGUI/MakeGrid_QTD.ui index f10ed72..2f0aec6 100644 --- a/src/HEXABLOCKGUI/MakeGrid_QTD.ui +++ b/src/HEXABLOCKGUI/MakeGrid_QTD.ui @@ -6,8 +6,8 @@ 0 0 - 338 - 1042 + 276 + 1083 @@ -18,7 +18,7 @@ - 5 + 276 0 @@ -65,9 +65,9 @@ 0 - -82 - 301 - 1231 + 0 + 254 + 1061 @@ -167,12 +167,6 @@ - - QLayout::SetDefaultConstraint - - - QFormLayout::AllNonFixedFieldsGrow - @@ -182,9 +176,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -202,9 +202,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -279,7 +285,7 @@ - + 0 0 @@ -294,7 +300,7 @@ - + 0 0 @@ -323,7 +329,7 @@ - + 0 0 @@ -353,7 +359,14 @@ - + + + + 0 + 0 + + + @@ -499,7 +512,7 @@ - + 0 0 @@ -508,7 +521,7 @@ - + 0 0 @@ -543,7 +556,14 @@ - + + + + count : + + + + 1 @@ -556,20 +576,13 @@ - - - - count : - - - - + 0 0 @@ -601,7 +614,14 @@ - + + + + count : + + + + 3 @@ -614,20 +634,13 @@ - - - - count : - - - - + 0 0 @@ -656,7 +669,14 @@ - + + + + count : + + + + 1 @@ -669,13 +689,6 @@ - - - - count : - - - @@ -689,19 +702,6 @@ - - - - Qt::Vertical - - - - 20 - 20 - - - - @@ -717,24 +717,24 @@ Cylinder - - QLayout::SetDefaultConstraint - - - QFormLayout::ExpandingFieldsGrow - - + center - + + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -747,18 +747,18 @@ - + base - + - 127 + 16777215 16777215 @@ -770,18 +770,18 @@ - + vector - + - 127 + 16777215 16777215 @@ -823,9 +823,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -844,7 +850,7 @@ - + 0 0 @@ -867,7 +873,7 @@ - + 0 0 @@ -893,7 +899,7 @@ - + 0 0 @@ -909,28 +915,65 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + - - - - Qt::Vertical - - - - 20 - 10 - - - - + + scrollArea + rb0 + rb1 + rb2 + vex_le_rb0 + vec_le_rb0 + center_le_rb1 + base_le_rb1 + height_le_rb1 + vex_le_rb2 + nx_spb_rb0 + ny_spb_rb0 + nz_spb_rb0 + uniform_rb + random_rb + random_param_w + add_radius_pb + del_radius_pb + radius_lw + dr_spb_rb1 + nr_spb_rb1 + da_spb_rb1 + na_spb_rb1 + dl_spb_rb1 + nl_spb_rb1 + fill_cb_rb1 + radius_spb_rb2 + nb_spb_rb2 + k_spb_rb2 + add_angle_pb + add_height_pb + del_angle_pb + del_height_pb + height_lw + angle_lw + diff --git a/src/HEXABLOCKGUI/MakeHemiSphere_QTD.ui b/src/HEXABLOCKGUI/MakeHemiSphere_QTD.ui index 28e7897..99a2e2a 100644 --- a/src/HEXABLOCKGUI/MakeHemiSphere_QTD.ui +++ b/src/HEXABLOCKGUI/MakeHemiSphere_QTD.ui @@ -6,8 +6,8 @@ 0 0 - 367 - 440 + 288 + 742 @@ -16,6 +16,12 @@ 0 + + + 285 + 0 + + HemiSphere Construction @@ -33,11 +39,11 @@ 0 0 - 330 - 688 + 266 + 720 - + @@ -60,14 +66,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -93,7 +99,7 @@ Sphere - + @@ -199,7 +205,7 @@ Hole - + @@ -263,7 +269,7 @@ Cross section - + @@ -292,35 +298,13 @@ - - true - vector - - - true - - - - 0 - 0 - - - - - - - - - - false - - + @@ -336,7 +320,7 @@ Radial section - + @@ -395,7 +379,7 @@ - + partial @@ -419,7 +403,7 @@ Grid - + @@ -501,6 +485,24 @@ + + scrollArea + name_le + sphere_center_le + hole_axis_le + cross_pt_le + cross_vec_le + radial_vec_le + sphere_radext_spb + sphere_radint_spb + sphere_rind_cb + hole_rad_spb + radial_angle_spb + radial_partial_cb + ngrid_rad_spb + ngrid_ang_spb + ngrid_height_spb + @@ -535,38 +537,6 @@ - - hole_axis_le - textChanged(QString) - cross_vec_le - setText(QString) - - - 198 - 265 - - - 198 - 390 - - - - - cross_vec_le - textChanged(QString) - hole_axis_le - setText(QString) - - - 198 - 390 - - - 198 - 265 - - - sphere_rind_cb toggled(bool) diff --git a/src/HEXABLOCKGUI/MakePipe_QTD.ui b/src/HEXABLOCKGUI/MakePipe_QTD.ui index b2b5b9a..ae4834c 100644 --- a/src/HEXABLOCKGUI/MakePipe_QTD.ui +++ b/src/HEXABLOCKGUI/MakePipe_QTD.ui @@ -7,7 +7,7 @@ 0 0 195 - 220 + 196 @@ -38,9 +38,6 @@ Arguments - - QFormLayout::ExpandingFieldsGrow - @@ -50,9 +47,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -68,14 +71,27 @@ - + + + + + 16777215 + 16777215 + + + + false + + + + n (radial) - + @@ -91,14 +107,14 @@ - + n (angular) - + @@ -114,14 +130,14 @@ - + n (heigth) - + @@ -137,24 +153,18 @@ - - - - - 127 - 16777215 - - - - false - - - + + pipe_le + vec_le + nr_spb + na_spb + nl_spb + diff --git a/src/HEXABLOCKGUI/MakePipes_QTD.ui b/src/HEXABLOCKGUI/MakePipes_QTD.ui index 40d7a7e..90fb7a8 100644 --- a/src/HEXABLOCKGUI/MakePipes_QTD.ui +++ b/src/HEXABLOCKGUI/MakePipes_QTD.ui @@ -7,7 +7,7 @@ 0 0 190 - 104 + 106 @@ -26,9 +26,6 @@ Arguments - - QFormLayout::ExpandingFieldsGrow - @@ -38,9 +35,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -60,7 +63,7 @@ - 127 + 16777215 16777215 diff --git a/src/HEXABLOCKGUI/MakeRind_QTD.ui b/src/HEXABLOCKGUI/MakeRind_QTD.ui index 524e775..19797aa 100644 --- a/src/HEXABLOCKGUI/MakeRind_QTD.ui +++ b/src/HEXABLOCKGUI/MakeRind_QTD.ui @@ -6,16 +6,28 @@ 0 0 - 324 - 440 + 272 + 464 + + + 0 + 0 + + Rind Construction + + + 0 + 0 + + Result Name @@ -30,14 +42,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -48,21 +60,47 @@ + + + 0 + 0 + + Arguments - - + + center - + - + + 0 + 0 + + + + false + + + + + + + vx + + + + + + + 0 0 @@ -72,10 +110,17 @@ - + + + + vz + + + + - + 0 0 @@ -85,14 +130,14 @@ - + radext - + 6 @@ -105,14 +150,14 @@ - + radint - + 6 @@ -125,14 +170,14 @@ - + radhole - + 6 @@ -145,17 +190,17 @@ - + plorig - + - + 0 0 @@ -165,14 +210,14 @@ - + nrad - + 1000000 @@ -182,14 +227,14 @@ - + nang - + 1000000 @@ -199,14 +244,14 @@ - + nhaut - + 1000000 @@ -216,7 +261,7 @@ - + false @@ -226,7 +271,7 @@ - + false @@ -242,34 +287,7 @@ - - - - vx - - - - - - - - 0 - 0 - - - - false - - - - - - - vz - - - - + Partial @@ -284,6 +302,21 @@ + + name_le + center_le + vx_le + vz_le + plorig_le + radext_spb + radint_spb + radhole_spb + nrad_spb + nang_spb + nhaut_spb + angle_spb + partial_cb + diff --git a/src/HEXABLOCKGUI/MakeSpherical_QTD.ui b/src/HEXABLOCKGUI/MakeSpherical_QTD.ui index 4564b4a..3b4a2d3 100644 --- a/src/HEXABLOCKGUI/MakeSpherical_QTD.ui +++ b/src/HEXABLOCKGUI/MakeSpherical_QTD.ui @@ -6,16 +6,28 @@ 0 0 - 267 - 217 + 241 + 184 + + + 0 + 0 + + Sphere Construction + + + 0 + 0 + + Arguments @@ -29,9 +41,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -49,9 +67,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -60,20 +84,14 @@ - - - - 6 - - - 1000000000.000000000000000 - - - 1.000000000000000 + + + + nb - + 1000000 @@ -83,17 +101,23 @@ - + k - - - - nb + + + + 6 + + + 1000000000.000000000000000 + + + 1.000000000000000 @@ -102,6 +126,12 @@ + + vex_le + vec_le + nb_spb + k_spb + diff --git a/src/HEXABLOCKGUI/MakeTranslation_QTD.ui b/src/HEXABLOCKGUI/MakeTranslation_QTD.ui index 46d24b4..9603b40 100644 --- a/src/HEXABLOCKGUI/MakeTranslation_QTD.ui +++ b/src/HEXABLOCKGUI/MakeTranslation_QTD.ui @@ -6,34 +6,45 @@ 0 0 - 355 - 295 + 270 + 195 + + + 0 + 0 + + Translation Operation + + + 0 + 0 + + Translate - - - - - - - Elements : - - - - + + + + + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -42,22 +53,24 @@ - - - - - + Vector : - + + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -66,9 +79,16 @@ + + + + Elements : + + + - + Qt::Vertical @@ -96,6 +116,11 @@ + + elt_le + vec_le + buttonBox + diff --git a/src/HEXABLOCKGUI/MergeEdges_QTD.ui b/src/HEXABLOCKGUI/MergeEdges_QTD.ui index 38ecb87..b505f66 100644 --- a/src/HEXABLOCKGUI/MergeEdges_QTD.ui +++ b/src/HEXABLOCKGUI/MergeEdges_QTD.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 431 + 215 + 184 @@ -16,124 +16,107 @@ + + + 0 + 0 + + MergeEdges - - - - - - - Edge 1 - - - - - - - - 127 - 16777215 - - - - false - - - - + + + + + Edge 1 + + - - - - - - Edge 2 - - - - - - - - 127 - 16777215 - - - - false - - - - + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + false + + - - - - - - Vertex 1 - - - - - - - - 127 - 16777215 - - - - false - - - - + + + + + 16777215 + 16777215 + + + + false + + - - - - - - Vertex 2 - - - - - - - - 127 - 0 - - - - - 127 - 16777215 - - - - false - - - - + + + + + 16777215 + 16777215 + + + + false + + - - - - Qt::Vertical + + + + + 127 + 0 + - + - 20 - 220 + 16777215 + 16777215 - + + false + + + + + + + Edge 2 + + + + + + + Vertex 1 + + + + + + + Vertex 2 + + diff --git a/src/HEXABLOCKGUI/MergeVertices_QTD.ui b/src/HEXABLOCKGUI/MergeVertices_QTD.ui index e256ea5..1d80fdd 100644 --- a/src/HEXABLOCKGUI/MergeVertices_QTD.ui +++ b/src/HEXABLOCKGUI/MergeVertices_QTD.ui @@ -6,10 +6,16 @@ 0 0 - 304 - 360 + 242 + 108 + + + 0 + 0 + + Dialog @@ -19,21 +25,27 @@ MergeVertices - - - - + + + + Vertex 1 - + + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -42,22 +54,24 @@ - - - - - + Vertex 2 - + + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -68,19 +82,6 @@ - - - - Qt::Vertical - - - - 261 - 207 - - - - diff --git a/src/HEXABLOCKGUI/Merge_QTD.ui b/src/HEXABLOCKGUI/Merge_QTD.ui index 0f9e932..45adfed 100644 --- a/src/HEXABLOCKGUI/Merge_QTD.ui +++ b/src/HEXABLOCKGUI/Merge_QTD.ui @@ -100,7 +100,7 @@ - 127 + 16777215 16777215 @@ -120,7 +120,7 @@ - 127 + 16777215 16777215 @@ -146,7 +146,7 @@ - 127 + 16777215 16777215 @@ -166,7 +166,7 @@ - 127 + 16777215 16777215 @@ -186,7 +186,7 @@ - 127 + 16777215 16777215 @@ -206,7 +206,7 @@ - 127 + 16777215 16777215 @@ -221,11 +221,18 @@ + + + + quad 1 + + + - 127 + 16777215 16777215 @@ -234,11 +241,18 @@ + + + + quad 2 + + + - 127 + 16777215 16777215 @@ -247,11 +261,18 @@ + + + + vertex 1 + + + - 127 + 16777215 16777215 @@ -260,18 +281,18 @@ - + vertex 2 - + - 127 + 16777215 16777215 @@ -280,18 +301,18 @@ - + vertex 3 - + - 127 + 16777215 16777215 @@ -300,18 +321,18 @@ - + vertex 4 - + - 127 + 16777215 16777215 @@ -320,27 +341,6 @@ - - - - quad 1 - - - - - - - quad 2 - - - - - - - vertex 1 - - - @@ -349,6 +349,23 @@ + + rb0 + rb1 + rb2 + v0_le_rb0 + v1_le_rb0 + e0_le_rb1 + e1_le_rb1 + v0_le_rb1 + v1_le_rb1 + q0_le_rb2 + q1_le_rb2 + v0_le_rb2 + v1_le_rb2 + v2_le_rb2 + v3_le_rb2 + diff --git a/src/HEXABLOCKGUI/MyBasicGUI_PointDlg.cxx b/src/HEXABLOCKGUI/MyBasicGUI_PointDlg.cxx index 327b66f..9c0042e 100644 --- a/src/HEXABLOCKGUI/MyBasicGUI_PointDlg.cxx +++ b/src/HEXABLOCKGUI/MyBasicGUI_PointDlg.cxx @@ -251,10 +251,6 @@ MyBasicGUI_PointDlg::~MyBasicGUI_PointDlg() { } - - - - //================================================================================= // function : Init() // purpose : @@ -314,10 +310,11 @@ void MyBasicGUI_PointDlg::Init() /* signals and slots connections */ if ( myGeomGUI ){ connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(close())); } //connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); +// connect( closeButton, SIGNAL(clicked()), this, SLOT(close()) ); connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int))); @@ -499,7 +496,7 @@ void MyBasicGUI_PointDlg::ClickOnOk() { setIsApplyAndClose(true); if (onAccept()) - ClickOnCancel(); + close(); } //================================================================================= @@ -512,7 +509,11 @@ bool MyBasicGUI_PointDlg::ClickOnApply() return false; initName(); - ConstructorsClicked(getConstructorId()); +// ConstructorsClicked(getConstructorId()); + + //Set selection mode to the last selected mode + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), myNeedType); return true; } @@ -1026,12 +1027,12 @@ void MyBasicGUI_PointDlg::updateParamCoord(bool theIsUpdate) GroupOnCurve->SpinBox_DX->setVisible(isParam || isLength); if (isParam){ initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., 0.1, "parametric_precision"); - GroupOnCurve->SpinBox_DX->setValue(0.5); +// GroupOnCurve->SpinBox_DX->setValue(0.5); GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER")); } else if (isLength){ initSpinBox(GroupOnCurve->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision"); - GroupOnCurve->SpinBox_DX->setValue(0.0); +// GroupOnCurve->SpinBox_DX->setValue(0); GroupOnCurve->TextLabel3->setText(tr("GEOM_LENGTH")); } } @@ -1189,6 +1190,10 @@ void MyBasicGUI_PointDlg::onSelectionChanged( const QItemSelection& sel, const Q foreach( const QModelIndex& iunsel, unsel.indexes() ){ MESSAGE("* unselected : " << iunsel.data().toString().toStdString()); } + + if (_patternDataSelectionModel) + _patternDataSelectionModel->highlightEltsWithAssocs(sel.indexes()); + if ( _selectionMutex ) return; if ( _currentObj != mainFrame()->_vertex_le ) return; @@ -1231,15 +1236,51 @@ void MyBasicGUI_PointDlg::onWindowActivated(SUIT_ViewManager* vm) } } +// ============================================================== _isLineOrListWidget +/* + * Return true is the widget is a line or a list + * false otherwise. + */ +bool MyBasicGUI_PointDlg::_isLineOrListWidget(QObject *widget) +{ + if (widget == NULL) return false; + + QLineEdit *lineEdit = dynamic_cast(widget); + QListWidget *listWidget = dynamic_cast(widget); + return (lineEdit != NULL) || (listWidget != NULL); + +}//_isLineOrListWidget + + + +// ============================================================== _highlightWidget +/* + * Highlight the given widget with the given color. + */ +void MyBasicGUI_PointDlg::_highlightWidget(QObject *obj, Qt::GlobalColor clr) +{ + if (!_isLineOrListWidget(obj)) return; + + QWidget *widget = dynamic_cast(obj); //sure it's not NULL (_isLineOrListWidget(obj)) + QPalette palette1 = widget->palette(); + palette1.setColor(widget->backgroundRole(), clr); + widget->setPalette(palette1); + +}//_highlightWidget bool MyBasicGUI_PointDlg::eventFilter(QObject *obj, QEvent *event) { +// if (event->type() == QEvent::FocusOut) +// _highlightWidget(obj, Qt::white); +// +// else if ( (event->type() != QEvent::FocusIn) or (obj != mainFrame()->_vertex_le) ){ return MyGEOMBase_Skeleton::eventFilter(obj, event); } +// _highlightWidget(obj, Qt::yellow); MESSAGE("MyBasicGUI_PointDlg::eventFilter{"); diff --git a/src/HEXABLOCKGUI/MyBasicGUI_PointDlg.hxx b/src/HEXABLOCKGUI/MyBasicGUI_PointDlg.hxx index ad5ac32..eaed34a 100755 --- a/src/HEXABLOCKGUI/MyBasicGUI_PointDlg.hxx +++ b/src/HEXABLOCKGUI/MyBasicGUI_PointDlg.hxx @@ -140,8 +140,6 @@ private slots: void updateSize(); - - // HEXABLOCK public: void setDocumentModel( HEXABLOCK::GUI::DocumentModel* m ); @@ -156,6 +154,8 @@ protected: virtual void showEvent ( QShowEvent * event ); void _initInputWidget(); void _initViewManager(); + void _highlightWidget(QObject* obj, Qt::GlobalColor clr); + bool _isLineOrListWidget(QObject*); protected slots: void onSelectionChanged( const QItemSelection& sel, const QItemSelection& unsel ); diff --git a/src/HEXABLOCKGUI/MyGEOMBase_Helper.hxx b/src/HEXABLOCKGUI/MyGEOMBase_Helper.hxx index 4bfdab2..ea3bac8 100644 --- a/src/HEXABLOCKGUI/MyGEOMBase_Helper.hxx +++ b/src/HEXABLOCKGUI/MyGEOMBase_Helper.hxx @@ -54,6 +54,12 @@ class GEOMBASE_EXPORT MyGEOMBase_Helper public: MyGEOMBase_Helper( SUIT_Desktop* ); virtual ~MyGEOMBase_Helper(); + GEOM_Displayer* getDisplayer(); + void localSelection( const ObjectList&, const int ); + void localSelection( GEOM::GEOM_Object_ptr, const int ); + void globalSelection( const int = GEOM_ALLOBJECTS, const bool = false ); + void globalSelection( const TColStd_MapOfInteger&, const bool = false ); + void globalSelection( const TColStd_MapOfInteger&, const QList& ,const bool = false ); protected: static GEOM::GEOM_Gen_ptr getGeomEngine(); @@ -87,12 +93,12 @@ protected: const bool = true ); void erasePreview ( const bool = true ); - void localSelection( const ObjectList&, const int ); - void localSelection( GEOM::GEOM_Object_ptr, const int ); +// void localSelection( const ObjectList&, const int ); +// void localSelection( GEOM::GEOM_Object_ptr, const int ); void activate( const int ); - void globalSelection( const int = GEOM_ALLOBJECTS, const bool = false ); - void globalSelection( const TColStd_MapOfInteger&, const bool = false ); - void globalSelection( const TColStd_MapOfInteger&, const QList& ,const bool = false ); +// void globalSelection( const int = GEOM_ALLOBJECTS, const bool = false ); +// void globalSelection( const TColStd_MapOfInteger&, const bool = false ); +// void globalSelection( const TColStd_MapOfInteger&, const QList& ,const bool = false ); void updateViewer (); void prepareSelection( const ObjectList&, const int ); @@ -172,7 +178,7 @@ protected: void SetIsPreview(const bool thePreview) {isPreview = thePreview;} bool IsPreview() {return isPreview;} - GEOM_Displayer* getDisplayer(); +// GEOM_Displayer* getDisplayer(); SUIT_Desktop* getDesktop() const; virtual void setIsApplyAndClose( const bool theFlag ); diff --git a/src/HEXABLOCKGUI/MyGEOMBase_Skeleton.cxx b/src/HEXABLOCKGUI/MyGEOMBase_Skeleton.cxx index b7690c9..b67d1f9 100755 --- a/src/HEXABLOCKGUI/MyGEOMBase_Skeleton.cxx +++ b/src/HEXABLOCKGUI/MyGEOMBase_Skeleton.cxx @@ -111,10 +111,10 @@ void MyGEOMBase_Skeleton::Init() myGeomGUI->SetActiveDialogBox( this ); /* signals and slots connections */ - connect( buttonCancel(), SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ); + connect( buttonCancel(), SIGNAL( clicked() ), this, SLOT( close() ) ); if ( myGeomGUI ) { connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); - connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); + connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( close() ) ); } // connect help button on a private slot that displays help information @@ -199,13 +199,23 @@ void MyGEOMBase_Skeleton::updateAttributes( GEOM::GEOM_Object_ptr theObj, aStringAttrib->SetValue(aValue.c_str()); } + +// ========================================================================== close +// function : close() +// purpose : close the dockwidget //================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void MyGEOMBase_Skeleton::ClickOnCancel() +void MyGEOMBase_Skeleton::close() { - close(); +// _currentObj = NULL; + + //Clear VTK selection +// clearVTKSelection(); + + //Clear OCC selection +// clearOCCSelection(); + + //Close the dialog box + if (parentWidget()) parentWidget()->close(); } //================================================================================= diff --git a/src/HEXABLOCKGUI/MyGEOMBase_Skeleton.hxx b/src/HEXABLOCKGUI/MyGEOMBase_Skeleton.hxx index 76defa6..ebbdf76 100755 --- a/src/HEXABLOCKGUI/MyGEOMBase_Skeleton.hxx +++ b/src/HEXABLOCKGUI/MyGEOMBase_Skeleton.hxx @@ -98,8 +98,10 @@ protected: QButtonGroup* myRBGroup; //!< radio button group MyDlgRef_Skeleton* myMainFrame; //!< dialog box's mainframe widgetx +public slots: + virtual void close(); + protected slots: - virtual void ClickOnCancel(); virtual void processPreview(); void LineEditReturnPressed(); void DeactivateActiveDialog(); diff --git a/src/HEXABLOCKGUI/Pipe_QTD.ui b/src/HEXABLOCKGUI/Pipe_QTD.ui index cd5fa44..b80ef9e 100644 --- a/src/HEXABLOCKGUI/Pipe_QTD.ui +++ b/src/HEXABLOCKGUI/Pipe_QTD.ui @@ -6,7 +6,7 @@ 0 0 - 297 + 226 241 @@ -28,6 +28,12 @@ + + + 0 + 0 + + 5 @@ -38,24 +44,47 @@ Arguments - + + + + Name + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + Point - + - + 0 0 - 127 + 16777215 16777215 @@ -64,18 +93,24 @@ - + Vector - + + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -84,17 +119,17 @@ - + internal radius - + - + 0 0 @@ -110,17 +145,17 @@ - + external radius - + - + 0 0 @@ -136,17 +171,17 @@ - + height - + - + 0 0 @@ -162,34 +197,19 @@ - - - - Name - - - - - - - - 0 - 0 - - - - - 127 - 16777215 - - - - + + name_le + vex_le + vec_le + ir_spb + er_spb + h_spb + diff --git a/src/HEXABLOCKGUI/PrismQuad_QTD.ui b/src/HEXABLOCKGUI/PrismQuad_QTD.ui index daa9ece..7be90fb 100644 --- a/src/HEXABLOCKGUI/PrismQuad_QTD.ui +++ b/src/HEXABLOCKGUI/PrismQuad_QTD.ui @@ -6,12 +6,12 @@ 0 0 - 318 - 381 + 254 + 500 - + 0 0 @@ -22,6 +22,12 @@ 0 + + + 16777215 + 16777215 + + Prism Quad(s) Operation @@ -37,37 +43,71 @@ Arguments - + + + + 0 + 0 + + + + + 16777215 + 16777215 + + Quad(s) - - - + + + + + + 0 + 0 + + + - - - Direction + + + + 16777215 + 50 + + + + QFrame::StyledPanel + + + QFrame::Raised - + - Vector + Direction + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -76,21 +116,159 @@ - - - - nb + + + + + + + + 0 + 0 + + + + Layer(s) + + + + + + + + regular + + + true + + + + + + + irregular + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + nb + + + + + + + 1000000 + + + 1 + + + + - - - - 1000000 + + + + + 16777215 + 169 + + + + QFrame::StyledPanel - - 1 + + QFrame::Raised + + + + + + 0 + 0 + + + + 0 + + + + height + + + + + + true + + + + 0 + 0 + + + + + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + - + + + + + + + Qt::Vertical + + + + 20 + 139 + + + + + + + + + @@ -102,5 +280,70 @@ - + + + regular_rb + clicked() + frame_3 + hide() + + + 77 + 231 + + + 126 + 390 + + + + + regular_rb + clicked() + frame_2 + show() + + + 77 + 231 + + + 126 + 273 + + + + + irregular_rb + clicked() + frame_3 + show() + + + 175 + 231 + + + 126 + 390 + + + + + irregular_rb + clicked() + frame_2 + hide() + + + 175 + 231 + + + 126 + 273 + + + + diff --git a/src/HEXABLOCKGUI/Propagation_QTD.ui b/src/HEXABLOCKGUI/Propagation_QTD.ui index d56c98e..861e900 100644 --- a/src/HEXABLOCKGUI/Propagation_QTD.ui +++ b/src/HEXABLOCKGUI/Propagation_QTD.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -22,16 +22,28 @@ + + + 0 + 0 + + Arguments + + + 0 + 0 + + 16777215 - 131 + 16777215 @@ -39,22 +51,41 @@ - + + + + 0 + 0 + + + + + + 0 + 0 + + Law + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -91,6 +122,12 @@ + + propagations_lw + law_le + way_cb + buttonBox + diff --git a/src/HEXABLOCKGUI/QuadAssoc_QTD.ui b/src/HEXABLOCKGUI/QuadAssoc_QTD.ui index e302fa9..43fe6df 100644 --- a/src/HEXABLOCKGUI/QuadAssoc_QTD.ui +++ b/src/HEXABLOCKGUI/QuadAssoc_QTD.ui @@ -6,40 +6,58 @@ 0 0 - 260 - 280 + 225 + 271 - + 0 0 - 260 + 0 0 + + + 16777215 + 378 + + Quad Association - + - 5 + 0 0 + + + 16777215 + 16777215 + + Arguments - + + + + 0 + 0 + + 16777215 @@ -49,11 +67,11 @@ Quad - - + + - + 0 0 @@ -71,13 +89,13 @@ 16777215 - 156 + 16777215 Face(s) - + @@ -86,6 +104,12 @@ 0 + + + 16777215 + 16777215 + + diff --git a/src/HEXABLOCKGUI/QuadRevolution_QTD.ui b/src/HEXABLOCKGUI/QuadRevolution_QTD.ui index 406af8f..0f90bec 100644 --- a/src/HEXABLOCKGUI/QuadRevolution_QTD.ui +++ b/src/HEXABLOCKGUI/QuadRevolution_QTD.ui @@ -6,8 +6,8 @@ 0 0 - 279 - 451 + 235 + 367 @@ -31,7 +31,7 @@ Result Name - + @@ -42,14 +42,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -70,34 +70,41 @@ Arguments - + Quads : - - + + + + + 0 + 0 + + + - + Center : - + - + 0 0 - 127 + 16777215 16777215 @@ -110,18 +117,24 @@ - + Axis : - + + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -134,7 +147,24 @@ - + + + + Angles : + + + + + + + + 0 + 0 + + + + + true @@ -150,7 +180,7 @@ - + @@ -163,14 +193,7 @@ - - - - Angles : - - - - + Qt::Vertical @@ -183,9 +206,6 @@ - - - diff --git a/src/HEXABLOCKGUI/Quad_QTD.ui b/src/HEXABLOCKGUI/Quad_QTD.ui index dd0c95f..da01b21 100755 --- a/src/HEXABLOCKGUI/Quad_QTD.ui +++ b/src/HEXABLOCKGUI/Quad_QTD.ui @@ -6,19 +6,19 @@ 0 0 - 255 - 437 + 216 + 428 - + 0 0 - 5 + 0 0 @@ -81,6 +81,12 @@ + + + 0 + 0 + + 5 @@ -90,32 +96,44 @@ Arguments - - - - - Name - + + + + + + + + Name + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + - - + + 0 0 - - - 127 - 16777215 - - - - - - @@ -126,9 +144,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -146,9 +170,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -166,9 +196,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -186,15 +222,21 @@ + + + 0 + 0 + + - 127 + 0 0 - 127 + 16777215 16777215 @@ -206,8 +248,14 @@ - + + + + 0 + 0 + + @@ -218,9 +266,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -238,9 +292,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -258,9 +318,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -278,15 +344,21 @@ + + + 0 + 0 + + - 127 + 0 0 - 127 + 16777215 16777215 @@ -303,6 +375,19 @@ + + rb0 + rb1 + name_le + v0_le_rb0 + v1_le_rb0 + v2_le_rb0 + v3_le_rb0 + e0_le_rb1 + e1_le_rb1 + e2_le_rb1 + e3_le_rb1 + diff --git a/src/HEXABLOCKGUI/RemoveHexa_QTD.ui b/src/HEXABLOCKGUI/RemoveHexa_QTD.ui index 703a519..3eedee7 100644 --- a/src/HEXABLOCKGUI/RemoveHexa_QTD.ui +++ b/src/HEXABLOCKGUI/RemoveHexa_QTD.ui @@ -47,9 +47,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 diff --git a/src/HEXABLOCKGUI/ReplaceHexa_QTD.ui b/src/HEXABLOCKGUI/ReplaceHexa_QTD.ui index 12ac32d..038cf13 100644 --- a/src/HEXABLOCKGUI/ReplaceHexa_QTD.ui +++ b/src/HEXABLOCKGUI/ReplaceHexa_QTD.ui @@ -6,8 +6,8 @@ 0 0 - 229 - 459 + 234 + 461 @@ -22,16 +22,22 @@ + + + 0 + 0 + + - 5 + 0 0 Result Name - + @@ -42,14 +48,14 @@ - + 0 0 - 127 + 16777215 16777215 @@ -60,9 +66,15 @@ + + + 0 + 0 + + - 5 + 0 0 @@ -72,93 +84,129 @@ + + + 0 + 0 + + Quad(s) source - - + + - - Select hexa - - - - - - - Point a - - - - - - + 0 0 - - Select vertex - - - - - - false - - - - - - - Point b - - - - - - - - 0 - 0 - + + + 16777215 + 16777215 + - Select vertex - - - - - - false - - - - - - - Point c + Select hexa - - + + - + 0 0 - - Select vertex + + QFrame::StyledPanel - - - - - false + + QFrame::Raised + + + + + Point a + + + + + + + + 0 + 0 + + + + Select vertex + + + + + + false + + + + + + + Point b + + + + + + + + 0 + 0 + + + + Select vertex + + + + + + false + + + + + + + Point c + + + + + + + + 0 + 0 + + + + Select vertex + + + + + + false + + + + @@ -166,13 +214,16 @@ + + + 0 + 0 + + Quad destination - - QFormLayout::ExpandingFieldsGrow - @@ -183,7 +234,7 @@ - + 0 0 @@ -209,7 +260,7 @@ - + 0 0 @@ -235,7 +286,7 @@ - + 0 0 @@ -259,6 +310,16 @@ + + name_le + quads_lw + p1_le + p2_le + p3_le + c1_le + c2_le + c3_le + diff --git a/src/HEXABLOCKGUI/Symmetry_QTD.ui b/src/HEXABLOCKGUI/Symmetry_QTD.ui index 391b69b..80e4e7f 100644 --- a/src/HEXABLOCKGUI/Symmetry_QTD.ui +++ b/src/HEXABLOCKGUI/Symmetry_QTD.ui @@ -6,12 +6,12 @@ 0 0 - 244 - 466 + 234 + 396 - + 0 0 @@ -107,9 +107,6 @@ - - QFormLayout::ExpandingFieldsGrow - @@ -119,9 +116,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -138,23 +141,7 @@ - - - - 0 - 0 - - - - - 127 - 16777215 - - - - false - - + @@ -171,9 +158,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -191,9 +184,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -202,11 +201,24 @@ - + + + + vector + + + + + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -215,13 +227,6 @@ - - - - vector - - - @@ -237,9 +242,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -257,9 +268,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -277,9 +294,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -296,6 +319,18 @@ + + rb0 + rb1 + rb2 + elts_le_rb0 + elts_le_rb1 + vex_le_rb1 + vec_le_rb1 + elts_le_rb2 + vex_le_rb2 + vec_le_rb2 + diff --git a/src/HEXABLOCKGUI/Transformation_QTD.ui b/src/HEXABLOCKGUI/Transformation_QTD.ui index 2a175b9..93fdeb1 100644 --- a/src/HEXABLOCKGUI/Transformation_QTD.ui +++ b/src/HEXABLOCKGUI/Transformation_QTD.ui @@ -6,12 +6,12 @@ 0 0 - 312 - 483 + 239 + 440 - + 0 0 @@ -21,7 +21,7 @@ - QLayout::SetMinimumSize + QLayout::SetDefaultConstraint @@ -95,9 +95,6 @@ - - QFormLayout::ExpandingFieldsGrow - @@ -109,7 +106,7 @@ - 127 + 16777215 16777215 @@ -135,7 +132,7 @@ - 127 + 16777215 16777215 @@ -154,7 +151,7 @@ - 127 + 16777215 16777215 @@ -174,7 +171,7 @@ - 127 + 16777215 16777215 @@ -220,7 +217,7 @@ - 127 + 16777215 16777215 @@ -240,7 +237,7 @@ - 127 + 16777215 16777215 @@ -260,7 +257,7 @@ - 127 + 16777215 16777215 @@ -313,6 +310,20 @@ + + rb0 + rb1 + rb2 + elts_le_rb0 + vec_le_rb0 + elts_le_rb1 + vex_le_rb1 + elts_le_rb2 + vex_le_rb2 + vec_le_rb2 + k_spb + angle_spb + diff --git a/src/HEXABLOCKGUI/Vector_QTD.ui b/src/HEXABLOCKGUI/Vector_QTD.ui index 1b9eef8..f09de3f 100644 --- a/src/HEXABLOCKGUI/Vector_QTD.ui +++ b/src/HEXABLOCKGUI/Vector_QTD.ui @@ -6,12 +6,12 @@ 0 0 - 284 - 359 + 245 + 338 - + 0 0 @@ -21,7 +21,7 @@ - QLayout::SetMinimumSize + QLayout::SetDefaultConstraint @@ -72,33 +72,42 @@ Arguments - - - - - Name - - - - - - - - 0 - 0 - - - - - 127 - 16777215 - - + + + + + + + + Name + + + + + + + true + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + - + - + @@ -115,7 +124,7 @@ - + 0 0 @@ -149,8 +158,11 @@ + + true + - + 0 0 @@ -182,7 +194,7 @@ - + 0 0 @@ -201,7 +213,7 @@ - + @@ -213,9 +225,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -233,9 +251,15 @@ + + + 0 + 0 + + - 127 + 16777215 16777215 @@ -252,6 +276,16 @@ + + rb0 + rb1 + name_le + v0_le_rb1 + v1_le_rb1 + dx_spb_rb0 + dy_spb_rb0 + dz_spb_rb0 + diff --git a/src/HEXABLOCKGUI/Vertex_QTD.ui b/src/HEXABLOCKGUI/Vertex_QTD.ui index 9ec0f48..9727000 100755 --- a/src/HEXABLOCKGUI/Vertex_QTD.ui +++ b/src/HEXABLOCKGUI/Vertex_QTD.ui @@ -6,8 +6,8 @@ 0 0 - 260 - 160 + 210 + 202 @@ -18,7 +18,7 @@ - 260 + 0 0 @@ -31,130 +31,150 @@ Vertex Construction - - - QLayout::SetDefaultConstraint - + Arguments - - - QFormLayout::ExpandingFieldsGrow - - - - - Name - + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Name + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + - - - - - 0 - 0 - - - - - 127 - 16777215 - - - - - - - - - 0 - 0 - - - - x : - - - - - - - - 0 - 0 - - - - 6 - - - 1000000000.000000000000000 - - - - - - - - 0 - 0 - - - - y : - - - - - - - - 0 - 0 - - - - 6 - - - 1000000000.000000000000000 - - - - - - - - 0 - 0 - - - - z : - - - - - - - - 0 - 0 - - - - 6 - - - 1000000000.000000000000000 - + + + + + + + + 0 + 0 + + + + x : + + + + + + + + 0 + 0 + + + + 6 + + + 1000000000.000000000000000 + + + + + + + + 0 + 0 + + + + y : + + + + + + + + 0 + 0 + + + + 6 + + + 1000000000.000000000000000 + + + + + + + + 0 + 0 + + + + z : + + + + + + + + 0 + 0 + + + + 6 + + + 1000000000.000000000000000 + + + + + x_spb + label + x_spb + y_spb + label_2 + z_spb + label_3 + widget + widget_2 + x_spb + label diff --git a/src/HEXABLOCK_I/HEXABLOCK.cxx b/src/HEXABLOCK_I/HEXABLOCK.cxx index 8959a5e..68f09ed 100755 --- a/src/HEXABLOCK_I/HEXABLOCK.cxx +++ b/src/HEXABLOCK_I/HEXABLOCK.cxx @@ -21,8 +21,6 @@ using namespace std; static bool db = false; - - // #include // // #include @@ -747,7 +745,8 @@ char* HEXABLOCK_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, { if (db) cout << " +++++++ Je suis passe par HEXABLOCK_Gen_i::" << "IORToLocalPersistentID" << endl; - static char empty [8] = ""; + /// static char empty [8] = ""; + char* empty = strdup (""); return empty; } // =================================================== LocalPersistentIDToIOR diff --git a/src/HEXABLOCK_I/HexDocument_impl.cxx b/src/HEXABLOCK_I/HexDocument_impl.cxx index 77fb534..f9b5215 100755 --- a/src/HEXABLOCK_I/HexDocument_impl.cxx +++ b/src/HEXABLOCK_I/HexDocument_impl.cxx @@ -462,17 +462,17 @@ Vector_ptr Document_impl::addVectorVertices( Vertex_ptr v0In, Vertex_ptr v1In ) } -// ::CORBA::Long Document_impl::countVector() throw (SALOME::SALOME_Exception) -// { -// return _document_cpp->countVector(); -// } -// -// Vector_ptr Document_impl::getVector(::CORBA::Long i) throw (SALOME::SALOME_Exception) -// { -// HEXA_NS::Vector* h = _document_cpp->getVector(i); -// Vector_impl* servantCorba = new Vector_impl(h); -// return servantCorba->_this(); -// } +::CORBA::Long Document_impl::countVector() throw (SALOME::SALOME_Exception) +{ + return _document_cpp->countVector(); +} + +Vector_ptr Document_impl::getVector(::CORBA::Long i) throw (SALOME::SALOME_Exception) +{ + HEXA_NS::Vector* h = _document_cpp->getVector(i); + Vector_impl* servantCorba = new Vector_impl(h); + return servantCorba->_this(); +} Cylinder_ptr Document_impl::addCylinder( Vertex_ptr baseIn, Vector_ptr directionIn, @@ -499,18 +499,17 @@ throw (SALOME::SALOME_Exception) return result; } -// ::CORBA::Long Document_impl::countCylinder() throw (SALOME::SALOME_Exception) -// { -// return _document_cpp->countCylinder(); -// } -// -// -// Cylinder_ptr Document_impl::getCylinder(::CORBA::Long i) throw (SALOME::SALOME_Exception) -// { -// HEXA_NS::Cylinder* c = _document_cpp->getCylinder(i); -// Cylinder_impl* servantCorba = new Cylinder_impl(c); -// return servantCorba->_this(); -// } +::CORBA::Long Document_impl::countCylinder() throw (SALOME::SALOME_Exception) +{ + return _document_cpp->countCylinder(); +} + +Cylinder_ptr Document_impl::getCylinder(::CORBA::Long i) throw (SALOME::SALOME_Exception) +{ + HEXA_NS::Cylinder* c = _document_cpp->getCylinder(i); + Cylinder_impl* servantCorba = new Cylinder_impl(c); + return servantCorba->_this(); +} Pipe_ptr Document_impl::addPipe( Vertex_ptr baseIn, Vector_ptr directionIn, @@ -538,17 +537,17 @@ throw (SALOME::SALOME_Exception) } -// ::CORBA::Long Document_impl::countPipe() throw (SALOME::SALOME_Exception) -// { -// return _document_cpp->countPipe(); -// } -// -// Pipe_ptr Document_impl::getPipe(::CORBA::Long i) throw (SALOME::SALOME_Exception) -// { -// HEXA_NS::Pipe* p = _document_cpp->getPipe(i); -// Pipe_impl* servantCorba = new Pipe_impl(p); -// return servantCorba->_this(); -// } +::CORBA::Long Document_impl::countPipe() throw (SALOME::SALOME_Exception) +{ + return _document_cpp->countPipe(); +} + +Pipe_ptr Document_impl::getPipe(::CORBA::Long i) throw (SALOME::SALOME_Exception) +{ + HEXA_NS::Pipe* p = _document_cpp->getPipe(i); + Pipe_impl* servantCorba = new Pipe_impl(p); + return servantCorba->_this(); +} ::CORBA::Boolean Document_impl::removeHexa(Hexa_ptr hIn) throw (SALOME::SALOME_Exception) { @@ -1377,7 +1376,6 @@ Group_ptr Document_impl::addEdgeNodeGroup(const char* name) throw (SALOME::SALOM return result; } - Group_ptr Document_impl::addVertexNodeGroup(const char* name) throw (SALOME::SALOME_Exception) { Group_ptr result = Group::_nil(); diff --git a/src/HEXABLOCK_I/HexDocument_impl.hxx b/src/HEXABLOCK_I/HexDocument_impl.hxx index 9e76f11..4f5e54a 100755 --- a/src/HEXABLOCK_I/HexDocument_impl.hxx +++ b/src/HEXABLOCK_I/HexDocument_impl.hxx @@ -72,14 +72,14 @@ public: Hexa_ptr findHexa(Vertex_ptr p1, Vertex_ptr p2) throw (SALOME::SALOME_Exception); Vector_ptr addVector(::CORBA::Double dx, ::CORBA::Double dy, ::CORBA::Double dz) throw (SALOME::SALOME_Exception); Vector_ptr addVectorVertices(Vertex_ptr v1, Vertex_ptr v2) throw (SALOME::SALOME_Exception); -// ::CORBA::Long countVector() throw (SALOME::SALOME_Exception); -// Vector_ptr getVector(::CORBA::Long i) throw (SALOME::SALOME_Exception); +::CORBA::Long countVector() throw (SALOME::SALOME_Exception); +Vector_ptr getVector(::CORBA::Long i) throw (SALOME::SALOME_Exception); Cylinder_ptr addCylinder(Vertex_ptr base, Vector_ptr direction, ::CORBA::Double radius, ::CORBA::Double height) throw (SALOME::SALOME_Exception); -// ::CORBA::Long countCylinder() throw (SALOME::SALOME_Exception); -// Cylinder_ptr getCylinder(::CORBA::Long i) throw (SALOME::SALOME_Exception); +::CORBA::Long countCylinder() throw (SALOME::SALOME_Exception); +Cylinder_ptr getCylinder(::CORBA::Long i) throw (SALOME::SALOME_Exception); Pipe_ptr addPipe(Vertex_ptr base, Vector_ptr direction, ::CORBA::Double int_radius, ::CORBA::Double ext_radius, ::CORBA::Double height) throw (SALOME::SALOME_Exception); -// ::CORBA::Long countPipe() throw (SALOME::SALOME_Exception); -// Pipe_ptr getPipe(::CORBA::Long i) throw (SALOME::SALOME_Exception); +::CORBA::Long countPipe() throw (SALOME::SALOME_Exception); +Pipe_ptr getPipe(::CORBA::Long i) throw (SALOME::SALOME_Exception); ::CORBA::Boolean removeHexa(Hexa_ptr h) throw (SALOME::SALOME_Exception); ::CORBA::Boolean removeConnectedHexa(Hexa_ptr h) throw (SALOME::SALOME_Exception); Elements_ptr makeCartesian(Vertex_ptr pt, Vector_ptr vx, Vector_ptr vy, Vector_ptr vz, ::CORBA::Long nx, ::CORBA::Long ny, ::CORBA::Long nz) throw (SALOME::SALOME_Exception); diff --git a/src/HEXABLOCK_I/HexEdge_impl.cxx b/src/HEXABLOCK_I/HexEdge_impl.cxx index 83fdc57..1f4faea 100755 --- a/src/HEXABLOCK_I/HexEdge_impl.cxx +++ b/src/HEXABLOCK_I/HexEdge_impl.cxx @@ -90,8 +90,11 @@ void Edge_impl::setName(const char* name) _edge_cpp->setName (name); } - - +void Edge_impl::setColor (::CORBA::Double val) + throw (SALOME::SALOME_Exception) +{ + _edge_cpp->setColor (val); +} void Edge_impl::setScalar( ::CORBA::Double val )throw (SALOME::SALOME_Exception) { diff --git a/src/HEXABLOCK_I/HexEdge_impl.hxx b/src/HEXABLOCK_I/HexEdge_impl.hxx index 7c34a44..a0c349c 100755 --- a/src/HEXABLOCK_I/HexEdge_impl.hxx +++ b/src/HEXABLOCK_I/HexEdge_impl.hxx @@ -52,6 +52,7 @@ public: EdgeAssociations* getAssociations () //CS_NOT_SPEC throw (SALOME::SALOME_Exception); + void setColor (::CORBA::Double val) throw (SALOME::SALOME_Exception); void setScalar( ::CORBA::Double val )throw (SALOME::SALOME_Exception); void dump() throw (SALOME::SALOME_Exception); void printName() throw (SALOME::SALOME_Exception); diff --git a/src/HEXABLOCK_I/HexHexa_impl.cxx b/src/HEXABLOCK_I/HexHexa_impl.cxx index 1b5c79c..f11e9b0 100755 --- a/src/HEXABLOCK_I/HexHexa_impl.cxx +++ b/src/HEXABLOCK_I/HexHexa_impl.cxx @@ -77,6 +77,12 @@ Vertex_ptr Hexa_impl::getVertex(::CORBA::Long n) return result; } +void Hexa_impl::setColor (::CORBA::Double val) + throw (SALOME::SALOME_Exception) +{ + _hexa_cpp->setColor (val); +} + void Hexa_impl::setScalar( ::CORBA::Double val )throw (SALOME::SALOME_Exception) { _hexa_cpp->setScalar(val); diff --git a/src/HEXABLOCK_I/HexHexa_impl.hxx b/src/HEXABLOCK_I/HexHexa_impl.hxx index 58e5964..f82a103 100755 --- a/src/HEXABLOCK_I/HexHexa_impl.hxx +++ b/src/HEXABLOCK_I/HexHexa_impl.hxx @@ -39,6 +39,7 @@ public: Edge_ptr getEdge(::CORBA::Long n) throw (SALOME::SALOME_Exception); Vertex_ptr getVertex(::CORBA::Long n) throw (SALOME::SALOME_Exception); + void setColor (::CORBA::Double val) throw (SALOME::SALOME_Exception); void setScalar( ::CORBA::Double val ) throw (SALOME::SALOME_Exception); void dump() throw (SALOME::SALOME_Exception); void printName() throw (SALOME::SALOME_Exception); diff --git a/src/HEXABLOCK_I/HexQuad_impl.cxx b/src/HEXABLOCK_I/HexQuad_impl.cxx index 7ba12d2..c647ecd 100755 --- a/src/HEXABLOCK_I/HexQuad_impl.cxx +++ b/src/HEXABLOCK_I/HexQuad_impl.cxx @@ -156,6 +156,12 @@ GEOM::ListOfGO* Quad_impl::getAssociations() //CS_NOT_SPEC // { // } +void Quad_impl::setColor (::CORBA::Double val) + throw (SALOME::SALOME_Exception) +{ + _quad_cpp->setColor (val); +} + void Quad_impl::setScalar( ::CORBA::Double val )throw (SALOME::SALOME_Exception) { _quad_cpp->setScalar(val); diff --git a/src/HEXABLOCK_I/HexQuad_impl.hxx b/src/HEXABLOCK_I/HexQuad_impl.hxx index c481293..e0aaa8d 100755 --- a/src/HEXABLOCK_I/HexQuad_impl.hxx +++ b/src/HEXABLOCK_I/HexQuad_impl.hxx @@ -48,6 +48,7 @@ public: void clearAssociation() throw (SALOME::SALOME_Exception); + void setColor (::CORBA::Double val) throw (SALOME::SALOME_Exception); void setScalar( ::CORBA::Double val )throw (SALOME::SALOME_Exception); void dump() throw (SALOME::SALOME_Exception); void printName() throw (SALOME::SALOME_Exception); diff --git a/src/HEXABLOCK_I/HexVertex_impl.cxx b/src/HEXABLOCK_I/HexVertex_impl.cxx index 94c5780..dcf0030 100755 --- a/src/HEXABLOCK_I/HexVertex_impl.cxx +++ b/src/HEXABLOCK_I/HexVertex_impl.cxx @@ -116,6 +116,12 @@ void Vertex_impl::clearAssociation() } +void Vertex_impl::setColor (::CORBA::Double val) + throw (SALOME::SALOME_Exception) +{ + _vertex_cpp->setColor (val); +} + void Vertex_impl::setScalar( ::CORBA::Double val )throw (SALOME::SALOME_Exception) { _vertex_cpp->setScalar(val); diff --git a/src/HEXABLOCK_I/HexVertex_impl.hxx b/src/HEXABLOCK_I/HexVertex_impl.hxx index 6d6da51..a1cb8f4 100755 --- a/src/HEXABLOCK_I/HexVertex_impl.hxx +++ b/src/HEXABLOCK_I/HexVertex_impl.hxx @@ -47,6 +47,7 @@ public: GEOM::GEOM_Object_ptr getAssociation() throw (SALOME::SALOME_Exception); void clearAssociation() throw (SALOME::SALOME_Exception); + void setColor (::CORBA::Double val) throw (SALOME::SALOME_Exception); void setScalar( ::CORBA::Double val )throw (SALOME::SALOME_Exception); void dump() throw (SALOME::SALOME_Exception); diff --git a/src/TEST_PY/INTER_3_CYLINDRE.py b/src/TEST_PY/INTER_3_CYLINDRE.py deleted file mode 100755 index 4b0c43d..0000000 --- a/src/TEST_PY/INTER_3_CYLINDRE.py +++ /dev/null @@ -1,415 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -#=============================================== -# By Karima DEBCHI YATAGHENE Nov 2009 at CS -#=============================================== - -import os -import SALOME -import geompy -import smesh -import hexablock -import math - - - -# chemin du fichier BREP contenant la CAO -BREP_PATH = os.path.expandvars("$HEXABLOCK_ROOT_DIR/bin/salome/tees.brep") -#=================================================================== -# LE MODELE: -#=================================================================== - - -#============================= -# PARAMETRES -#============================= - -#============================= -# CREATION DOCUMENT -#============================= -doc = hexablock.addDocument("cylindres") - -#============================= -# CREATION DU MODELE -#============================= -CYL1 = 0 -CYL2 = 1 - - -S_E = 0 -S_NE = 1 -S_N = 2 -S_NW = 3 -S_W = 4 -S_SW = 5 -S_S = 6 -S_SE = 7 -S_MAXI = 8 - -##dy = doc.addVector ( 0, 1, 0 ) -dx1 = doc.addVector( -1, 0, 0 ) -dz1 = doc.addVector( 0, 0, 1 ) - - -c_pte_1 = doc.addVertex ( 190., 0., 220. ) -c_grd_1 = doc.addVertex ( 300., 0., 400. ) -cyl_pte_1 = doc.addCylinder( c_pte_1 , dz1 , 20 , 360 ) #580-220 -cyl_grd_1 = doc.addCylinder( c_grd_1 , dx1 , 50 , 140 ) -cross1 = doc.makeCylinders( cyl_pte_1 , cyl_grd_1 ) - - -dx2 = doc.addVector( -1, 0, 0 ) -dz2 = doc.addVector( 0, 0, 1 ) -c_pte_2 = doc.addVertex( 110. , 0. , 400. ) -c_grd_2 = doc.addVertex( 0. , 0. , 0. ) - -cyl_pte_2 = doc.addCylinder( c_pte_2 , dx2 , 50, 220 ) -cyl_grd_2 = doc.addCylinder( c_grd_2 , dz2 , 100, 800 ) -cross2 = doc.makeCylinders( cyl_pte_2, cyl_grd_2 ) - -# Qq constantes -coul1 = 5 -coul2 = 3 - -# Pour les bicylindres -xhint = 0 # indice x pour les hexa interieurs -xhext = 1 # indice x pour les hexa exterieurs -xvint = 0 # indice x pour les vertex interieurs -xvext = 2 # indice x pour les vertex exterieurs -zbas = 0 -zhhaut1 = 5 # hauteur max quad petit cylindre -zhhaut2 = 3 # hauteur max quad gros cylindre -zvhaut1 = 6 # hauteur max vertex du petit cylindre -zvhaut2 = 4 # hauteur max vertex du gros cylindre - -# La jointure -hQuads = [] -for ny in range(8): - hQuads+=[cross2.getQuadIJ(CYL1, xhext, ny, zbas)] - -for ny in range(4): - hQuads+=[cross2.getQuadIJ(CYL1, xhint, ny, zbas)] - -qstart0 = cross2.getQuadIJ (CYL1, xhext, S_E, zbas) -qtarget = cross1.getQuadIJ (CYL2, xhext, S_S, zvhaut2) - -vb0 = qtarget.getVertex (0) -vb1 = qtarget.getVertex (1) -vh0 = qstart0.getVertex (0) -vh1 = qstart0.getVertex (1) - -hauteur = 3 -joint = doc.joinQuads (hQuads, qtarget, vh0,vb0, vh1,vb1, hauteur) - -# Elimination bout en trop -for ny in range(8): - h = cross2.getHexaIJK (CYL1, xhext, ny, zhhaut1) - doc.removeHexa(h) - if ny<4: - h = cross2.getHexaIJK (CYL1, xhint, ny, zhhaut1) - doc.removeHexa(h) - - -#=================================================================== -# Recuperation edges du model pour l'association -#=================================================================== - -##========================= -## EDGES -##========================= -### BIG CYLINDER -top_BIG = [] -bottom_BIG = [] -for ny in range(8): - bottom_BIG += [ cross2.getEdgeJ(CYL2, 2, ny, 0) ] - -for ny in range(8): - top_BIG += [ cross2.getEdgeJ(CYL2, 2, ny, zvhaut2) ] - -### MEDIUM CYLINDER -left_MEDIUM_BIG = [] -right_MEDIUM = [] - -for ny in range(8): - left_MEDIUM_BIG += [cross2.getEdgeJ (CYL1, 2, ny, 1)] - -for ny in range(8): - right_MEDIUM += [ cross1.getEdgeJ (CYL2, 2, ny, 0) ] - -### SMALL CYLINDER -top_SMALL = [] -top_SMALL_MEDIUM = [] -bottom_SMALL_MEDIUM = [] -bottom_SMALL = [] - -for ny in range(8): - top_SMALL += [ cross1.getEdgeJ(CYL1, 2, ny, zvhaut1) ] -for ny in range(8): - top_SMALL_MEDIUM += [ cross1.getEdgeJ(CYL1, 2, ny, zvhaut1-1) ] -for ny in range(8): - bottom_SMALL_MEDIUM += [ cross1.getEdgeJ(CYL1, 2, ny, 1) ] -for ny in range(8): - bottom_SMALL += [ cross1.getEdgeJ(CYL1, 2, ny, 0) ] - - -#=================================================================== -# LA GEOMETRIE -#=================================================================== - -#=================================================================== -# Recuperation des �l�ments de la geometrie tuyau pour l'association -#=================================================================== -tees_ = geompy.Import(BREP_PATH, "BREP") - -##========================= -## EDGES -##========================= -all_edges_ = geompy.SubShapeAllSorted( tees_ , geompy.ShapeType["EDGE"] ) - -### BIG CYLINDER -top_BIG_ = all_edges_[1] -bottom_BIG_ = all_edges_[0] - -### MEDIUM CYLINDER -left_MEDIUM_BIG_ = [ all_edges_[3], all_edges_[5] , all_edges_[4], all_edges_[2], ] -right_MEDIUM_ = all_edges_[20] - -### SMALL CYLINDER -top_SMALL_ = all_edges_[13] -top_SMALL_MEDIUM_ = [ all_edges_[11], all_edges_[16] ] -bottom_SMALL_MEDIUM_ = [ all_edges_[10], all_edges_[9], all_edges_[14], all_edges_[15] ] -bottom_SMALL_ = all_edges_[12] - - -#========================================================== -# LES ASSOCIATIONS -#========================================================== - -##=========================================== -## EDGES -##=========================================== -def associateEdges( edges, edges_, i_assoc, oppositeWay = False ): - nb_points = float( len(i_assoc) ) - #print "nb_points ", nb_points - for i, i_ in i_assoc.items(): - e = edges[i] - e0 = e.getVertex(0) - e1 = e.getVertex(1) - - if oppositeWay: - u0 = (i_+1.)/nb_points - u1 = i_/nb_points - e.addAssociation( edges_ , u1, u0 ) - else: - u0 = i_/nb_points - u1 = (i_+1.)/nb_points - e.addAssociation( edges_ , u0, u1 ) - - e0_ = geompy.MakeVertexOnCurve( edges_, u0 ) - e1_ = geompy.MakeVertexOnCurve( edges_, u1 ) - e0.setAssociation( e0_ ) - e1.setAssociation( e1_ ) - - - -## BIG CYLINDER -assoc = { 4:0, 5:1, 6:2, 7:3, 0:4, 1:5, 2:6, 3:7 } -associateEdges( top_BIG , top_BIG_, assoc ) -associateEdges( bottom_BIG, bottom_BIG_, assoc ) - -## SMALL CYLINDER -assoc = { 4:6, 5:7, 6:0, 7:1, 0:2, 1:3, 2:4, 3:5 } -associateEdges( top_SMALL , top_SMALL_, assoc ) -associateEdges( bottom_SMALL, bottom_SMALL_, assoc ) - - -## SMALL-MEDIUM CYLINDER - -### Top ( un peu 'touchy' ) -e = top_SMALL_MEDIUM[0] -e_0 = e.getVertex(0) -e_0_ = geompy.MakeVertexOnCurve( top_SMALL_MEDIUM_[0], 0.) -e_0.setAssociation( e_0_ ) -top_SMALL_MEDIUM_0_vertices_ = [ e_0_ ] - -for i, e in enumerate( top_SMALL_MEDIUM[0:6] ): - e_1 = e.getVertex(1) - e_1_ = geompy.MakeVertexOnCurve( top_SMALL_MEDIUM_[0], (i+1.)/6.) - e_1.setAssociation( e_1_ ) - top_SMALL_MEDIUM_0_vertices_ += [ e_1_ ] - -partition_ = geompy.MakePartition( [ top_SMALL_MEDIUM_[0] ], - top_SMALL_MEDIUM_0_vertices_, [], [], geompy.ShapeType["EDGE"], 0, [], 0 ) -top_SMALL_MEDIUM_0_edges_ = geompy.SubShapeAllSorted( partition_, geompy.ShapeType["EDGE"] ) - - -assoc = { 0:2, 1:0, 2:1, 3:3, 4:4, 5:5 } -for i,i_ in assoc.items(): - e = top_SMALL_MEDIUM[i] - e_ = top_SMALL_MEDIUM_0_edges_[i_] - e.addAssociation( e_, 0., 1. ) - -assoc = { 6:0, 7:1 } -associateEdges( top_SMALL_MEDIUM, top_SMALL_MEDIUM_[1], assoc ) - - -### Bottom -assocs = [ { 0:1, 1:0 }, { 2:1, 3:0 }, { 4:0, 5:1 }, { 6:0, 7:1 } ] # 4 edges -associateEdges( bottom_SMALL_MEDIUM, bottom_SMALL_MEDIUM_[0], assocs[0], True ) -associateEdges( bottom_SMALL_MEDIUM, bottom_SMALL_MEDIUM_[1], assocs[1], True ) -associateEdges( bottom_SMALL_MEDIUM, bottom_SMALL_MEDIUM_[2], assocs[2] ) -associateEdges( bottom_SMALL_MEDIUM, bottom_SMALL_MEDIUM_[3], assocs[3] ) - - - -## MEDIUM CYLINDER -assocs = [ { 0:0, 1:1 }, { 2:0, 3:1 }, { 4:1, 5:0 }, { 6:1, 7:0 } ] -associateEdges( left_MEDIUM_BIG, left_MEDIUM_BIG_[0], assocs[0] ) -associateEdges( left_MEDIUM_BIG, left_MEDIUM_BIG_[1], assocs[1] ) -associateEdges( left_MEDIUM_BIG, left_MEDIUM_BIG_[2], assocs[2], True ) -associateEdges( left_MEDIUM_BIG, left_MEDIUM_BIG_[3], assocs[3], True ) - -assoc = { 0:3, 1:2, 2:1, 3:0, 4:7, 5:6, 6:5, 7:4 } -associateEdges( right_MEDIUM, right_MEDIUM_, assoc , True ) - - - -#allfaces_ = geompy.SubShapeAllSorted(tees_, geompy.ShapeType["FACE"]) -#for i,f in enumerate( allfaces_ ): - #geompy.addToStudy( f, "allfaces"+str(i) ) - -#for ny in range(8): - #q = cross2.getQuadJK(CYL2,2,ny,0) - #q.addAssociation( allfaces_[2] ) - -#for ny in range(8): - #q = cross2.getQuadJK(CYL2,2,ny,1) - #if q: - #q.addAssociation( allfaces_[2] ) - - - - -##========================================================== -## LA GEOMETRIE DANS L'ARBRE D'ETUDE SALOME -##========================================================== -geompy.addToStudy( tees_, "Tees" ) - -#### BIG CYLINDER -geompy.addToStudy( top_BIG_, "top_BIG" ) -geompy.addToStudy( bottom_BIG_, "bottom_BIG" ) - -#### SMALL CYLINDER -geompy.addToStudy( top_SMALL_, "top_SMALL" ) -for i,e in enumerate(top_SMALL_MEDIUM_): - geompy.addToStudy( e, "top_SMALL_MEDIUM"+str(i) ) -for i,e in enumerate(top_SMALL_MEDIUM_0_edges_): - geompy.addToStudy( e, "top_SMALL_MEDIUM_0_edges_"+str(i) ) -for i,e in enumerate(bottom_SMALL_MEDIUM_): - geompy.addToStudy( e, "bottom_SMALL_MEDIUM"+str(i) ) -geompy.addToStudy( bottom_SMALL_, "bottom_SMALL" ) - -#### MEDIUM CYLINDER -geompy.addToStudy( right_MEDIUM_, "right_MEDIUM" ) -for i,e in enumerate(left_MEDIUM_BIG_): - geompy.addToStudy( e, "left_MEDIUM_BIG"+str(i) ) - - - -#==================================== -# CREATION GROUPES DU MAILLAGE -#==================================== - -#On definit 3 groupes de mailles - -#groupe d edges (aretes) -Edge_grp = doc.addEdgeGroup("Edge_grp") -Nbr_Edg = doc.countEdge() -for i in range(Nbr_Edg): - Edge_i = doc.getEdge(i) - Edge_grp.addElement(Edge_i) - -# groupe de quads (faces) -Quad_grp = doc.addQuadGroup("Quad_grp") -Nbr_Qad = doc.countQuad() -for i in range(Nbr_Qad): - Quad_i = doc.getQuad(i) - Quad_grp.addElement(Quad_i) - -# groupe d hexas (solids) -Hexa_grp = doc.addHexaGroup("Hexa_grp") -Nbr_Hex = doc.countHexa() -for i in range(Nbr_Hex): - Hexa_i = doc.getHexa(i) - Hexa_grp.addElement(Hexa_i) - -# groupe de noeuds de vertex pour tout le modele -Vertex_Nod_Grp = doc.addVertexNodeGroup("Vertex_Nod_Grp") -Nbr_Vx = doc.countVertex() -for i in range(Nbr_Vx): - Vertex_i = doc.getVertex(i) - Vertex_Nod_Grp.addElement(Vertex_i) - - - -##==================================== -## CREATION MAILLAGE -##==================================== - - -##==================================== -## Definir une loi de discretisation -##==================================== - - -# definir une loi: le choix de la loi reste aux utilisateurs -Law = doc.addLaw( "Uniform" , 4 ) -#Law = doc.addLaw( "Uniform" , 8 ) - -# chercher les propagations du modele -N_Propa = doc.countPropagation() - -for j in range(N_Propa): - Propa = doc.getPropagation(j) - Propa.setLaw( Law )# appliquer la loi de discretisation sur tout le modele et generer le maillage - -try: - mesh = hexablock.mesh(doc, "Inter_3_Cylindre") -# mesh = .hexablock.mesh(doc, "Inter_3_Cylindre:quads", 2) -except SALOME.SALOME_Exception, ex: - print "Mesh computation failed, exception caught:" - print " ", ex.details.text -except: - import traceback - print "Mesh computation failed, exception caught:" - traceback.print_exc() - - -print "Nombre d'hexaedres:", mesh.NbHexas() -print "Nombre de quadrangles:", mesh.NbQuadrangles() -print "Nombre de segments:", mesh.NbEdges() -print "Nombre de noeuds:", mesh.NbNodes() - - - - - - diff --git a/src/TEST_PY/Makefile.am b/src/TEST_PY/Makefile.am index 87385ed..6139168 100755 --- a/src/TEST_PY/Makefile.am +++ b/src/TEST_PY/Makefile.am @@ -25,23 +25,7 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am # =============================================================== # Scripts to be installed -# dist_salomescript_PYTHON = TestHEXA.py -dist_salomescript_PYTHON = \ - bielle.py \ - test_BIELLE_no_assoc.py \ - test_BIELLE_bad_assoc.py \ - TUYAU_COURBE.py \ - test_TUYAU_COURBE_no_assoc.py \ - test_TUYAU_COURBE_weird_assoc.py \ - INTER_3_CYLINDRE.py \ - test_INTER_3_CYLINDRE_no_assoc.py \ - Test_HEXABLOCK.py \ - test_HEXABLOCK.py \ - bride.py \ - test_distrib.py - -dist_salomescript_DATA = \ - tees.brep \ - tuyau.brep \ - crank.stp +# dist_salomescript_PYTHON = foo +dist_salomescript_PYTHON = foo.py +dist_salomescript_DATA = diff --git a/src/TEST_PY/TUYAU_COURBE.py b/src/TEST_PY/TUYAU_COURBE.py deleted file mode 100755 index 51331bf..0000000 --- a/src/TEST_PY/TUYAU_COURBE.py +++ /dev/null @@ -1,790 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -#=============================================== -# By Karima DEBCHI YATAGHENE Nov 2009 at CS -#=============================================== -import os -import geompy -import smesh -import hexablock -import math - -# chemin du fichier BREP contenant la CAO -BREP_PATH = os.path.expandvars("$HEXABLOCK_ROOT_DIR/bin/salome/tuyau.brep") - - - - -#=================================================================== -# LE MODELE: -# (Pour le tuyau on doit creer une grille cylindrique) -#=================================================================== - - -#============================= -# PARAMETRES -#============================= -R = 4.5 -r = 4.5 -r_t = 3.6 -h = 75.0 - - -#================================================= -# Creation du document -#================================================= -doc = hexablock.addDocument("TUYAU_COURBE") - -#================================================= -# Creation du tuyau (grille cylindrique) dans le document -#================================================= -# centre de la grille cylindrique -c = doc.addVertex(0, 0, 0) - -# vecteurs de la grille cylindrique -dx = doc.addVector(h, 0, 0) -dy = doc.addVector(0, h, 0) -dz = doc.addVector(0, 0, h) - -# taille du cylindre -dr = R -da = 360 -dl = h - -nr = 1 -na = 4 -nl = 1 - -model_tuyau_fin = doc.makeCylindrical(c, dx, dz, dr, da, dl, nr, na, nl, False) -# note: on obtient une liste qui contient 4 hexaedres eguaux - - -#=================================================================== -# Recuperation des vertex,edges et quads du model pour l'association -# -# h = haut -# b = bas -# g = grand -# p = petit -# t = trou -#=================================================================== - -#========================= -# VERTEX -#========================= - -# Face du haut -# grand rayon -x_mod_h = doc.findVertex( 2*R , 0 , h ) -y_mod_h = doc.findVertex( 0 , 2*R , h ) -z_mod_h = doc.findVertex( -2*R , 0 , h ) -u_mod_h = doc.findVertex( 0 , -2*R , h ) - -# petit rayon -x_mod_h_t = doc.findVertex( R , 0 , h ) -y_mod_h_t = doc.findVertex( 0 , R , h ) -z_mod_h_t = doc.findVertex( -R , 0 , h ) -u_mod_h_t = doc.findVertex( 0 , -R , h ) - -# Face du bas -# grand rayon -x_mod_b = doc.findVertex( 2*R , 0 , 0 ) -y_mod_b = doc.findVertex( 0 , 2*R , 0 ) -z_mod_b = doc.findVertex( -2*R , 0 , 0 ) -u_mod_b = doc.findVertex( 0 , -2*R , 0 ) - -# petit rayon -x_mod_b_t = doc.findVertex( R , 0 , 0 ) -y_mod_b_t = doc.findVertex( 0 , R , 0 ) -z_mod_b_t = doc.findVertex( -R , 0 , 0 ) -u_mod_b_t = doc.findVertex( 0 , -R , 0 ) - - -# v�rifications -assert x_mod_h -assert y_mod_h -assert z_mod_h -assert u_mod_h - -assert x_mod_h_t -assert y_mod_h_t -assert z_mod_h_t -assert u_mod_h_t - -assert x_mod_b -assert y_mod_b -assert z_mod_b -assert u_mod_b - -assert x_mod_b_t -assert y_mod_b_t -assert z_mod_b_t -assert u_mod_b_t - - -#========================= -# EDGES -#========================= - -# Face du haut - -# grand rayon -edge_mod_face_h_1_1 = doc.findEdge( y_mod_h , z_mod_h ) -edge_mod_face_h_1_2 = doc.findEdge( z_mod_h , u_mod_h ) -edge_mod_face_h_2_1 = doc.findEdge( y_mod_h, x_mod_h ) -edge_mod_face_h_2_2 = doc.findEdge( x_mod_h, u_mod_h ) - -# petit rayon -edge_mod_t_face_h_1_1 = doc.findEdge( y_mod_h_t , z_mod_h_t ) -edge_mod_t_face_h_1_2 = doc.findEdge( z_mod_h_t , u_mod_h_t ) -edge_mod_t_face_h_2_1 = doc.findEdge( y_mod_h_t, x_mod_h_t ) -edge_mod_t_face_h_2_2 = doc.findEdge( x_mod_h_t, u_mod_h_t ) - - -# Face du bas - -# grand rayon -edge_mod_face_b_1_1 = doc.findEdge( y_mod_b , z_mod_b ) -edge_mod_face_b_1_2 = doc.findEdge( z_mod_b , u_mod_b ) -edge_mod_face_b_2_1 = doc.findEdge( y_mod_b, x_mod_b ) -edge_mod_face_b_2_2 = doc.findEdge( x_mod_b, u_mod_b ) - -# petit rayon -edge_mod_t_face_b_1_1 = doc.findEdge( y_mod_b_t , z_mod_b_t ) -edge_mod_t_face_b_1_2 = doc.findEdge( z_mod_b_t , u_mod_b_t ) -edge_mod_t_face_b_2_1 = doc.findEdge( y_mod_b_t, x_mod_b_t ) -edge_mod_t_face_b_2_2 = doc.findEdge( x_mod_b_t, u_mod_b_t ) - - - -# Joignant faces haut et du bas -Edge_Mod_ext_h = doc.findEdge( y_mod_h , y_mod_b ) -Edge_Mod_int_h = doc.findEdge( y_mod_h_t , y_mod_b_t ) - -Edge_Mod_int_b = doc.findEdge( u_mod_h_t , u_mod_b_t ) -Edge_Mod_ext_b = doc.findEdge( u_mod_h , u_mod_b ) - -Edge_Mod_ext_g = doc.findEdge( x_mod_h , x_mod_b ) -Edge_Mod_int_g = doc.findEdge( x_mod_h_t , x_mod_b_t ) - -Edge_Mod_int_d = doc.findEdge( z_mod_h_t , z_mod_b_t ) -Edge_Mod_ext_d = doc.findEdge( z_mod_h , z_mod_b ) - - -# v�rifications -assert edge_mod_face_h_1_1 -assert edge_mod_face_h_1_2 -assert edge_mod_face_h_2_1 -assert edge_mod_face_h_2_2 - -assert edge_mod_t_face_h_1_1 -assert edge_mod_t_face_h_1_2 -assert edge_mod_t_face_h_2_1 -assert edge_mod_t_face_h_2_2 - -assert edge_mod_face_b_1_1 -assert edge_mod_face_b_1_2 -assert edge_mod_face_b_2_1 -assert edge_mod_face_b_2_2 - -assert edge_mod_t_face_b_1_1 -assert edge_mod_t_face_b_1_2 -assert edge_mod_t_face_b_2_1 -assert edge_mod_t_face_b_2_2 - - -assert Edge_Mod_ext_h -assert Edge_Mod_int_h - -assert Edge_Mod_int_b -assert Edge_Mod_ext_b - -assert Edge_Mod_ext_g -assert Edge_Mod_int_g - -assert Edge_Mod_int_d -assert Edge_Mod_ext_d - - - -#========================= -# QUADS -#========================= -Quad_mod_0 = model_tuyau_fin.getQuadJK( 1 , 0 , 0 ) -Quad_mod_1 = model_tuyau_fin.getQuadJK( 1 , 1 , 0 ) -Quad_mod_2 = model_tuyau_fin.getQuadJK( 1 , 2 , 0 ) -Quad_mod_3 = model_tuyau_fin.getQuadJK( 1 , 3 , 0 ) - - - -#=================================================================== -# LA GEOMETRIE -#=================================================================== - -#=================================================================== -# Recuperation des points de la geometrie tuyau pour l'association -# -#=================================================================== -Tuyau_geom = geompy.Import(BREP_PATH, "BREP") -doc.setShape(Tuyau_geom) - -#========================= -# SOMMETS -#========================= -Pt_A = geompy.MakeVertex( h , 20 , 4.5 ) -Pt_B = geompy.MakeVertex( h , 20 , 3.6 ) -Pt_C = geompy.MakeVertex( h , 20 , -4.5 ) -Pt_D = geompy.MakeVertex( h , 20 , -3.6 ) -Pt_E = geompy.MakeVertex( 0 , 0 , 2 ) -Pt_F = geompy.MakeVertex( 0 , 0 , 1.6 ) -Pt_G = geompy.MakeVertex( 0 , 0 , -2 ) -Pt_H = geompy.MakeVertex( 0 , 0 , -1.6 ) - -# Face du bas -Edge_bas_droite_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_E) -Edge_bas_droite_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_F) -Edge_bas_gauche_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_G) -Edge_bas_gauche_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_H) -## Grand rayon -x_b = geompy.MakeVertexOnCurve(Edge_bas_droite_grd, 0.5) -y_b = geompy.MakeVertexOnCurve(Edge_bas_droite_grd, 1) -z_b = geompy.MakeVertexOnCurve(Edge_bas_gauche_grd, 0.5) -u_b = geompy.MakeVertexOnCurve(Edge_bas_gauche_grd, 0) - -## Petit rayon -x_b_t = geompy.MakeVertexOnCurve(Edge_bas_droite_pte, 0.5) -y_b_t = geompy.MakeVertexOnCurve(Edge_bas_droite_pte, 1) -z_b_t = geompy.MakeVertexOnCurve(Edge_bas_gauche_pte, 0.5) -u_b_t = geompy.MakeVertexOnCurve(Edge_bas_gauche_pte, 0) - - -# Face du haut -Edge_haut_droite_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_A) -Edge_haut_droite_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_B) -Edge_haut_gauche_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_C) -Edge_haut_gauche_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_D) -## Grand rayon -x_h = geompy.MakeVertexOnCurve(Edge_haut_droite_grd, 0.5) -y_h = geompy.MakeVertexOnCurve(Edge_haut_droite_grd, 1) -z_h = geompy.MakeVertexOnCurve(Edge_haut_gauche_grd, 0.5) -u_h = geompy.MakeVertexOnCurve(Edge_haut_gauche_grd, 0) - -## Petit rayon -x_h_t = geompy.MakeVertexOnCurve(Edge_haut_droite_pte, 0.5) -y_h_t = geompy.MakeVertexOnCurve(Edge_haut_droite_pte, 1) -z_h_t = geompy.MakeVertexOnCurve(Edge_haut_gauche_pte, 0.5) -u_h_t = geompy.MakeVertexOnCurve(Edge_haut_gauche_pte, 0) - - - -#========================= -# EDGES -#========================= -All_Edges_Tuy_1 = geompy.SubShapeAllSorted( Tuyau_geom , geompy.ShapeType["EDGE"] ) - -# Face du haut -## Grand rayon -edge_face_h_1 = All_Edges_Tuy_1[11] -edge_face_h_2 = All_Edges_Tuy_1[14] -## Petit rayon -edge_t_face_h_1 = All_Edges_Tuy_1[12] -edge_t_face_h_2 = All_Edges_Tuy_1[13] - - -# Face du bas -## Grand rayon -edge_face_b_1 = All_Edges_Tuy_1[1] -edge_face_b_2 = All_Edges_Tuy_1[4] -## Petit rayon -edge_t_face_b_1 = All_Edges_Tuy_1[2] -edge_t_face_b_2 = All_Edges_Tuy_1[3] - - -# Joignant les 2 faces - -## edges compl�tes -Edge_Tuy_ext_h = All_Edges_Tuy_1[6] -Edge_Tuy_int_h = All_Edges_Tuy_1[7] -Edge_Tuy_int_b = All_Edges_Tuy_1[8] -Edge_Tuy_ext_b = All_Edges_Tuy_1[9] - -Pt_Z = geompy.MakeVertex( 75 , 20 , 0 ) -Pt_Z_1 = geompy.MakeVertexWithRef( Pt_Z , 0 , 0 , 10 ) -Pt_Z_2 = geompy.MakeVertexWithRef( Pt_Z , 0 , 0 , -10 ) -Line_Z1_Z2 = geompy.MakeLineTwoPnt( Pt_Z_1 , Pt_Z_2 ) - - -All_Edge_Tuy_ext_h = geompy.SubShapeAllSorted( Edge_Tuy_ext_h , geompy.ShapeType["VERTEX"] ) - -Vx_Edg_Tuy_ext_h_1 = All_Edge_Tuy_ext_h[0] -Vx_Edg_Tuy_ext_h_2 = All_Edge_Tuy_ext_h[1] - -Vx_Edg_Tuy_ext_h_1_trans = geompy.MakeVertexWithRef( Vx_Edg_Tuy_ext_h_1 , -10 , -10 , 0 ) -Vx_Edg_Tuy_ext_h_2_trans = geompy.MakeVertexWithRef( Vx_Edg_Tuy_ext_h_2 , 10 , 0 , 0 ) - -Line_1 = geompy.MakeLineTwoPnt(Vx_Edg_Tuy_ext_h_1, Vx_Edg_Tuy_ext_h_1_trans) -Line_2 = geompy.MakeLineTwoPnt(Vx_Edg_Tuy_ext_h_2, Vx_Edg_Tuy_ext_h_2_trans) - -Wire = geompy.MakeWire([Line_1, Line_2, Edge_Tuy_ext_h]) -Pipe_Z = geompy.MakePipe( Line_Z1_Z2 , Wire ) -Pipe_Ztt = geompy.MakePipe( Line_Z1_Z2 , Edge_Tuy_ext_h ) -Partition_Ztt = geompy.MakePartition([Tuyau_geom], [Pipe_Ztt], [], [], geompy.ShapeType["SOLID"], 0, [], 0) -All_Edges_Tuy_2tt = geompy.SubShapeAllSorted( Partition_Ztt , geompy.ShapeType["EDGE"] ) - -Edge_Tuy_ext_g = All_Edges_Tuy_2tt[12] -Edge_Tuy_int_g = All_Edges_Tuy_2tt[13] -Edge_Tuy_ext_d = All_Edges_Tuy_2tt[10] -Edge_Tuy_int_d = All_Edges_Tuy_2tt[11] - -## une edge en plusieurs(4) morceaux : Edge_Tuy_ext_h -X_pln1 = geompy.MakeVertexWithRef( Pt_Z , -20 , 0 , 0 ) -Vec_X = geompy.MakeVectorDXDYDZ( 1 , 0 , 0 ) - -Plan1 = geompy.MakePlane( X_pln1 , Vec_X , 200 ) -Plan2 = geompy.MakeTranslation( Plan1 , -20 , 0 , 0 ) -Plan3 = geompy.MakeTranslation( Plan1 , -40 , 0 , 0 ) - -Partition_Edge_g_d_h_b = geompy.MakePartition([ - Edge_Tuy_ext_h, - Edge_Tuy_int_h, - Edge_Tuy_ext_b, - Edge_Tuy_int_b, - Edge_Tuy_ext_g, - Edge_Tuy_int_g, - Edge_Tuy_ext_d, - Edge_Tuy_int_d], - [Plan1, Plan2, Plan3], [], [], geompy.ShapeType["EDGE"], 0, [], 0) - -All_Edge_g_d_h_b = geompy.SubShapeAllSorted( Partition_Edge_g_d_h_b , geompy.ShapeType["EDGE"] ) -Edge_Tuy_ext_h_1 = All_Edge_g_d_h_b[0] -Edge_Tuy_ext_h_2 = All_Edge_g_d_h_b[15] -Edge_Tuy_ext_h_3 = All_Edge_g_d_h_b[23] -Edge_Tuy_ext_h_4 = All_Edge_g_d_h_b[31] - - - -#========================= -# FACES -#========================= -All_Faces_Tuy_1 = geompy.SubShapeAllSorted( Tuyau_geom , geompy.ShapeType["FACE"] ) - -Face_Tuy_ext_1 = All_Faces_Tuy_1[4] -Face_Tuy_ext_2 = All_Faces_Tuy_1[5] - -Partition_Face = geompy.MakePartition([ Face_Tuy_ext_1 , Face_Tuy_ext_2 ], [ Plan1 , Plan2 , Plan3 , Pipe_Z ], [], [], geompy.ShapeType["FACE"], 0, [], 0) - - -All_Faces_Partition_Face = geompy.SubShapeAllSorted( Partition_Face , geompy.ShapeType["FACE"] ) - -## ------------------------------------- -Face_0 = All_Faces_Partition_Face[0] -Face_6 = All_Faces_Partition_Face[6] -Face_10 = All_Faces_Partition_Face[10] -Face_14 = All_Faces_Partition_Face[14] - -## ------------------------------------- -Face_1 = All_Faces_Partition_Face[1] -Face_7 = All_Faces_Partition_Face[7] -Face_11 = All_Faces_Partition_Face[11] -Face_15 = All_Faces_Partition_Face[15] - -## ------------------------------------- -Face_2 = All_Faces_Partition_Face[2] -Face_4 = All_Faces_Partition_Face[4] -Face_8 = All_Faces_Partition_Face[8] -Face_12 = All_Faces_Partition_Face[12] - -## ------------------------------------- -Face_3 = All_Faces_Partition_Face[3] -Face_5 = All_Faces_Partition_Face[5] -Face_9 = All_Faces_Partition_Face[9] -Face_13 = All_Faces_Partition_Face[13] - - - - - -#========================================================== -# LES ASSOCIATIONS -#========================================================== - -##=========================================== -## VERTEX -##=========================================== - -# Face du haut - -## Grand rayon -x_mod_h.setAssociation( x_h ) -y_mod_h.setAssociation( y_h ) -z_mod_h.setAssociation( z_h ) -u_mod_h.setAssociation( u_h ) - -## Petit rayon -x_mod_h_t.setAssociation( x_h_t ) -y_mod_h_t.setAssociation( y_h_t ) -z_mod_h_t.setAssociation( z_h_t ) -u_mod_h_t.setAssociation( u_h_t ) - - -# Face du bas - -## Grand rayon -x_mod_b.setAssociation( x_b ) -y_mod_b.setAssociation( y_b ) -z_mod_b.setAssociation( z_b ) -u_mod_b.setAssociation( u_b ) - -## Petit rayon -x_mod_b_t.setAssociation( x_b_t ) -y_mod_b_t.setAssociation( y_b_t ) -z_mod_b_t.setAssociation( z_b_t ) -u_mod_b_t.setAssociation( u_b_t ) - - -##=========================================== -## EDGES -##=========================================== - -# Face du haut - -## Grand rayon -edge_mod_face_h_1_1.addAssociation( edge_face_h_1, 0.5, 1. ) -edge_mod_face_h_1_2.addAssociation( edge_face_h_1, 0., 0.5 ) -edge_mod_face_h_2_1.addAssociation( edge_face_h_2, 0.5, 1. ) -edge_mod_face_h_2_2.addAssociation( edge_face_h_2, 0., 0.5 ) - -## Petit rayon -edge_mod_t_face_h_1_1.addAssociation( edge_t_face_h_1, 0.5, 1. ) -edge_mod_t_face_h_1_2.addAssociation( edge_t_face_h_1, 0., 0.5 ) -edge_mod_t_face_h_2_1.addAssociation( edge_t_face_h_2, 0.5, 1. ) -edge_mod_t_face_h_2_2.addAssociation( edge_t_face_h_2, 0., 0.5 ) - -# Face du bas - -## Grand rayon -edge_mod_face_b_1_1.addAssociation( edge_face_b_1, 0.5, 1. ) -edge_mod_face_b_1_2.addAssociation( edge_face_b_1, 0., 0.5 ) -edge_mod_face_b_2_1.addAssociation( edge_face_b_2, 0.5, 1. ) -edge_mod_face_b_2_2.addAssociation( edge_face_b_2, 0., 0.5 ) - -## Petit rayon -edge_mod_t_face_b_1_1.addAssociation( edge_t_face_b_1, 0.5, 1. ) -edge_mod_t_face_b_1_2.addAssociation( edge_t_face_b_1, 0., 0.5 ) -edge_mod_t_face_b_2_1.addAssociation( edge_t_face_b_2, 0.5, 1. ) -edge_mod_t_face_b_2_2.addAssociation( edge_t_face_b_2, 0., 0.5 ) - - - -# Joignant les 2 faces -#Edge_Mod_ext_h.addAssociation( Edge_Tuy_ext_h, 0., 1. ) -Edge_Mod_ext_h.addAssociation( Edge_Tuy_ext_h_1, 0., 1. ) -Edge_Mod_ext_h.addAssociation( Edge_Tuy_ext_h_2, 0., 1. ) -Edge_Mod_ext_h.addAssociation( Edge_Tuy_ext_h_3, 0., 1. ) -Edge_Mod_ext_h.addAssociation( Edge_Tuy_ext_h_4, 0., 1. ) -Edge_Mod_int_h.addAssociation( Edge_Tuy_int_h, 0., 1. ) - -Edge_Mod_int_b.addAssociation( Edge_Tuy_int_b, 0., 1. ) -Edge_Mod_ext_b.addAssociation( Edge_Tuy_ext_b, 0., 1. ) - -Edge_Mod_ext_g.addAssociation( Edge_Tuy_ext_g, 0., 1. ) -Edge_Mod_int_g.addAssociation( Edge_Tuy_int_g, 0., 1. ) - -Edge_Mod_int_d.addAssociation( Edge_Tuy_int_d, 0., 1. ) -Edge_Mod_ext_d.addAssociation( Edge_Tuy_ext_d, 0., 1. ) - - -#Quad_mod_1.addAssociation( Face_Tuy_ext_1 ) -Quad_mod_1.addAssociation( Face_0 ) -Quad_mod_1.addAssociation( Face_6 ) -Quad_mod_1.addAssociation( Face_10 ) -Quad_mod_1.addAssociation( Face_14 ) - -#Quad_mod_0.addAssociation( Face_Tuy_ext_2 ) -Quad_mod_0.addAssociation( Face_1 ) -Quad_mod_0.addAssociation( Face_7 ) -Quad_mod_0.addAssociation( Face_11 ) -Quad_mod_0.addAssociation( Face_15 ) - -#Quad_mod_2.addAssociation( Face_Tuy_ext_1 ) -Quad_mod_2.addAssociation( Face_2 ) -Quad_mod_2.addAssociation( Face_4 ) -Quad_mod_2.addAssociation( Face_8 ) -Quad_mod_2.addAssociation( Face_12 ) - -#Quad_mod_3.addAssociation( Face_Tuy_ext_2 ) -Quad_mod_3.addAssociation( Face_3 ) -Quad_mod_3.addAssociation( Face_5 ) -Quad_mod_3.addAssociation( Face_9 ) -Quad_mod_3.addAssociation( Face_13 ) - - - -#========================================================== -# LA GEOMETRIE DANS L'ARBRE D'ETUDE SALOME -#========================================================== -#for i,e in enumerate(All_Edges_Tuy_1): geompy.addToStudy( e, "edge_"+str(i) ) -geompy.addToStudy(Tuyau_geom, "Tuyau_geom") -geompy.addToStudy( x_h, "x_h" ) -geompy.addToStudy( y_h, "y_h" ) -geompy.addToStudy( z_h, "z_h" ) -geompy.addToStudy( u_h, "u_h" ) -geompy.addToStudy( x_h_t, "x_h_t") -geompy.addToStudy( y_h_t, "y_h_t" ) -geompy.addToStudy( z_h_t, "z_h_t" ) -geompy.addToStudy( u_h_t, "u_h_t" ) - -geompy.addToStudy( x_b, "x_b") -geompy.addToStudy( y_b, "y_b" ) -geompy.addToStudy( z_b, "z_b" ) -geompy.addToStudy( u_b, "u_b") -geompy.addToStudy( x_b_t, "x_b_t" ) -geompy.addToStudy( y_b_t, "y_b_t" ) -geompy.addToStudy( z_b_t, "z_b_t" ) -geompy.addToStudy( u_b_t, "u_b_t" ) - - -#geompy.addToStudy(Line_Z1_Z2, "Line_Z1_Z2") -#geompy.addToStudy(Pipe_Ztt, "Pipe_Ztt") -#geompy.addToStudy( Partition_Ztt , "Partition_Ztt" ) -geompy.addToStudy( Edge_Tuy_ext_h , "Edge_Tuy_ext_h" ) -geompy.addToStudy( Edge_Tuy_int_h , "Edge_Tuy_int_h" ) -geompy.addToStudy( Edge_Tuy_int_b , "Edge_Tuy_int_b" ) -geompy.addToStudy( Edge_Tuy_ext_b , "Edge_Tuy_ext_b" ) -geompy.addToStudy( Edge_Tuy_ext_g , "Edge_Tuy_ext_g" ) -geompy.addToStudy( Edge_Tuy_int_g , "Edge_Tuy_int_g" ) -geompy.addToStudy( Edge_Tuy_ext_d , "Edge_Tuy_ext_d" ) -geompy.addToStudy( Edge_Tuy_int_d , "Edge_Tuy_int_d" ) -#geompy.addToStudy( Partition_Edge_g_d_h_b , "Partition_Edge_g_d_h_b" ) -geompy.addToStudy( Face_Tuy_ext_1 , "Face_Tuy_ext_1" ) -geompy.addToStudy( Face_Tuy_ext_2 , "Face_Tuy_ext_2" ) -#geompy.addToStudy( Partition_Face , "Partition_Face" ) -geompy.addToStudy( Face_0 , "Face_0" ) -geompy.addToStudy( Face_1 , "Face_1" ) -geompy.addToStudy( Face_2 , "Face_2" ) -geompy.addToStudy( Face_3 , "Face_3" ) -geompy.addToStudy( Face_4 , "Face_4" ) -geompy.addToStudy( Face_5 , "Face_5" ) -geompy.addToStudy( Face_6 , "Face_6" ) -geompy.addToStudy( Face_7 , "Face_7" ) -geompy.addToStudy( Face_8 , "Face_8" ) -geompy.addToStudy( Face_9 , "Face_9" ) -geompy.addToStudy( Face_10 , "Face_10" ) -geompy.addToStudy( Face_11 , "Face_11" ) -geompy.addToStudy( Face_12 , "Face_12" ) -geompy.addToStudy( Face_13 , "Face_13" ) -geompy.addToStudy( Face_14 , "Face_14" ) -geompy.addToStudy( Face_15 , "Face_15" ) - - - - - -#==================================== -# CREATION MAILLAGE -#==================================== - - -##================================================= -## Definir les groupes d'elements pour le maillage -##================================================= - -# groupe de Hexa(volumes) -Hexa_grp = doc.addHexaGroup("Hexa_all_grp") -Nbr_Hex = doc.countHexa() -print "doc.countHexa()->",Nbr_Hex - -for i in range(Nbr_Hex): - Hexa_i = doc.getHexa(i) - Hexa_grp.addElement(Hexa_i) - -#Nbr_elm_hex = Hexa_grp.countElement() -#print "Hexa_all_grp countElement() ->",Nbr_elm_hex - -for i in range(Nbr_Hex): - Hexa_grp = doc.addHexaGroup("Hexa_grp"+str(i)) - Hexa_i = doc.getHexa(i) - Hexa_grp.addElement(Hexa_i) - -# groupe de quads (faces) -Quad_grp_haut = doc.addQuadGroup("Quad_grp_haut") -Quad_h_1 = doc.findQuad( x_mod_h , y_mod_h_t ) -Quad_h_2 = doc.findQuad( y_mod_h_t , z_mod_h ) -Quad_h_3 = doc.findQuad( z_mod_h , u_mod_h_t ) -Quad_h_4 = doc.findQuad( u_mod_h_t , x_mod_h ) - -assert Quad_h_1 -assert Quad_h_2 -assert Quad_h_3 -assert Quad_h_4 - -for Quad_h_i in [ Quad_h_1 , Quad_h_2 , Quad_h_3 , Quad_h_4 ]: - Quad_grp_haut.addElement(Quad_h_i) - - -Quad_grp_bas = doc.addQuadGroup("Quad_grp_bas") -Quad_b_1 = doc.findQuad( x_mod_b , y_mod_b_t ) -Quad_b_2 = doc.findQuad( y_mod_b_t , z_mod_b ) -Quad_b_3 = doc.findQuad( z_mod_b , u_mod_b_t ) -Quad_b_4 = doc.findQuad( u_mod_b_t , x_mod_b ) - - -assert Quad_b_1 -assert Quad_b_2 -assert Quad_b_3 -assert Quad_b_4 - -for Quad_b_i in [ Quad_b_1 , Quad_b_2 , Quad_b_3 , Quad_b_4 ]: - Quad_grp_bas.addElement(Quad_b_i) - -#Nbr_elm_qad_bas = Quad_grp_bas.countElement() -#print "Nbr_elm_qad_bas->",Nbr_elm_qad_bas - - - -# groupe de Edges -Edge_Grp_haut = doc.addEdgeGroup("Edge_Grp_haut") -Edge_Grp_haut.addElement(Edge_Mod_ext_h) -Edge_Grp_haut.addElement(Edge_Mod_int_h) - -Edge_Grp_gauche = doc.addEdgeGroup("Edge_Grp_gauche") -Edge_Grp_gauche.addElement(Edge_Mod_ext_g) -Edge_Grp_gauche.addElement(Edge_Mod_int_g) - -Edge_Grp_bas = doc.addEdgeGroup("Edge_Grp_bas") -Edge_Grp_bas.addElement(Edge_Mod_int_b) -Edge_Grp_bas.addElement(Edge_Mod_ext_b) - -Edge_Grp_droit = doc.addEdgeGroup("Edge_Grp_droit") -Edge_Grp_droit.addElement(Edge_Mod_int_d) -Edge_Grp_droit.addElement(Edge_Mod_ext_d) - - -# groupe de noeuds de Hexa -Hexa_Nod_Grp = doc.addHexaNodeGroup("Hexa_Nod_Grp") -for i in range(Nbr_Hex): - Hexa_i = doc.getHexa(i) - Hexa_Nod_Grp.addElement(Hexa_i) - -# groupe de noeuds de Quad -Quad_Nod_Grp_h_1 = doc.addQuadNodeGroup("Quad_Nod_Grp_h_1") -Quad_Nod_Grp_h_1.addElement(Quad_h_1) - -Quad_Nod_Grp_b_1 = doc.addQuadNodeGroup("Quad_Nod_Grp_b_1") -Quad_Nod_Grp_b_1.addElement(Quad_b_1) - -# groupe de noeuds de Edge -Edge_Nod_Grp_b = doc.addEdgeNodeGroup("Edge_Nod_Grp_b") -Edge_Nod_Grp_b.addElement(Edge_Mod_int_b) -Edge_Nod_Grp_b.addElement(Edge_Mod_ext_b) - -Edge_Nod_Grp_h = doc.addEdgeNodeGroup("Edge_Nod_Grp_h") -Edge_Nod_Grp_h.addElement(Edge_Mod_int_d) -Edge_Nod_Grp_h.addElement(Edge_Mod_ext_d) - - -# groupe de noeuds de vertex pour tout le modele -Vertex_Nod_Grp = doc.addVertexNodeGroup("Vertex_Nod_Grp") -Nbr_Vx = doc.countVertex() -for i in range(Nbr_Vx): - Vertex_i = doc.getVertex(i) - Vertex_Nod_Grp.addElement(Vertex_i) - - -#==================================== -# Definir une loi de discretisation -#==================================== -bp_law = doc.getLaw(0) -bp_law.setNodes(4) - -# definir une loi: le choix de la loi reste aux utilisateurs - -#Law_X = doc.addLaw( "Uniform" , 4 ) -#Law_Y = doc.addLaw( "Arithmetic" , 2 ) -#Law_Z = doc.addLaw( "Geometric" , 3 ) -Law_X = doc.addLaw( "Arithmetic" , 5 ) -Law_X.setKind(hexablock.ARITHMETIC) -Law_X.setCoefficient(0.1) - -Law_Y = doc.addLaw( "Arithmetic" , 3 ) -Law_Y.setKind(hexablock.ARITHMETIC) -Law_Y.setCoefficient(0.1) - -#Law_Z = doc.addLaw( "Geometric" , 4 ) -Law_Z = doc.addLaw( "Arithmetic" , 5 ) -Law_Z.setKind(hexablock.ARITHMETIC) -Law_Z.setCoefficient(0.05) - - -# chercher les propagations du modele -Edge_Law_X = doc.findEdge( x_mod_h , x_mod_h_t ) -Edge_Law_Y = doc.findEdge( y_mod_h , y_mod_h_t ) -Edge_Law_Z = doc.findEdge( y_mod_h , y_mod_b ) - -Propa_X = doc.findPropagation( Edge_Law_X ) -Propa_Y = doc.findPropagation( Edge_Law_Y ) -Propa_Z = doc.findPropagation( Edge_Law_Z ) - -# appliquer la loi de discretisation sur tout le modele et generer le maillage -Propa_X.setLaw( Law_X ) -Propa_Y.setLaw( Law_Y ) -Propa_Z.setLaw( Law_Z ) - -print " --- MAILLAGE HEXAHEDRIQUE --- " -mesh = hexablock.mesh(doc) - -print "Nombre d hexaedres:" , mesh.NbHexas() -print "Nombre de quadrangles:", mesh.NbQuadrangles() -print "Nombre de segments:" , mesh.NbEdges() -print "Nombre de noeuds:" , mesh.NbNodes() - -salome.sg.updateObjBrowser(1) - -#Nombre d hexaedres: 480 -#Nombre de quadrangles: 496 -#Nombre de segments: 160 -#Nombre de noeuds: 700 - -allGroups = mesh.GetGroups() -print " --- GROUPES --- " -for aGroup in allGroups: - print "\nNOM:", aGroup.GetName() - print "IDS:", aGroup.GetIDs() - - - -## -------------------- -## Maillage hexa�drique -## -------------------- -#mesh = mesh.ExportMED( "tuyau.med", 1 ) -#maillages = smesh.CreateMeshesFromMED( "tuyau.med" ) - -#ijk = maillages[0][0] - -#ijk.Hexahedron() - -#ijk.Compute() - -#print " --- MAILLAGE HEXAHEDRIQUE --- " -#print "Nombre d hexaedres:", ijk.NbHexas() -#print "Nombre de quadrangles:", ijk.NbQuadrangles() -#print "Nombre de segments:", ijk.NbEdges() -#print "Nombre de noeuds:", ijk.NbNodes() diff --git a/src/TEST_PY/Test_HEXABLOCK.py b/src/TEST_PY/Test_HEXABLOCK.py deleted file mode 100755 index bbd2843..0000000 --- a/src/TEST_PY/Test_HEXABLOCK.py +++ /dev/null @@ -1,280 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import hexablock - -# ======================================================== test_sphere -def test_sphere(): - doc = hexablock.addDocument ("default") - orig = doc.addVertex (0,0,0) - - ncouches = 1 - k = 0.8 - decal = doc.addVector (1,1,1) - sphere = doc.makeSpherical(orig, decal, ncouches, k) - - sphere.saveVtk ("test_sphere.vtk") - # doc.dump () - print "test_sphere OK" - - -# ======================================================== test_cartesi1 -def test_cartesi1(): - size_x = 15 - size_y = 12 - size_z = 8 - - doc = hexablock.addDocument() - orig = doc.addVertex (0,0,0) - direc= doc.addVector (1,1,1) - grid = doc.makeCartesian1(orig, direc, size_x,size_y,size_z,0,0,0) - grid.saveVtk ("test_cartesi1.vtk") - # doc.dump () - print "test_cartesi1 OK" - - - -#// ======================================================== test_find -def test_find(): - size_x = 2 - size_y = 2 - size_z = 2 - - doc = hexablock.addDocument() - - orig = doc.addVertex(0,0,0) - direc = doc.addVector (1,1,1) - grid = doc.makeCartesian1 (orig, direc, size_x,size_y,size_z,0,0,0) - - grid.saveVtk ("mini1.vtk") - #doc.dump (). - - v00 = doc.findVertex (0, 0, 0) - v02 = doc.findVertex (1, 1, 0) - v06 = doc.findVertex (1, 1, 1) - v08 = doc.findVertex (2, 1, 0) - v10 = doc.findVertex (2, 1, 1) - v22 = doc.findVertex (2, 1, 2) - v26 = doc.findVertex (2, 2, 2) - - assert v00 - assert v02 - assert v06 - assert v08 - assert v10 - assert v22 - assert v26 - - assert doc.findEdge (v06, v10) - assert doc.findEdge (v10, v06) - - assert doc.findQuad (v02, v10) - assert doc.findQuad (v06, v08) - assert not doc.findQuad (v02, v06) #CS_FAILS - - assert doc.findHexa (v00, v06) - assert doc.findHexa (v06, v26) - assert doc.findHexa (v26, v06) - print "test_find OK" - -#// ======================================================== test_joint -def test_joint(): - import HEXA_ORB - dimx = 11 - dimy = 11 - dimz = 2 - - doc = hexablock.addDocument() - - orig1 = doc.addVertex (0,0,0) - direc = doc.addVector (1,1,1) - - grid1 = doc.makeCartesian1(orig1, direc, dimx, dimy, dimz, 0, 0, 0 ) - - orig2 = doc.addVertex (dimx/2.0,0,8) - vectj = doc.addVector (0,1,0) - vecti = doc.addVector (1,0,0) - grid2 = doc.makeCylindrical (orig2, vecti, vectj, 1, 180, 1,dimz,dimy,dimx, False) - - mx = dimx/2 - my = dimy/2 - prems = grid1.getQuad1 (HEXA_ORB.DIR_Z, mx, my, dimz) - cible = grid2.getQuad1 (HEXA_ORB.DIR_X, dimz, mx, my) - - - v1 = prems.getVertex (0) - v2 = cible.getVertex (0) - v3 = prems.getVertex (1) - v4 = cible.getVertex (3) - - liste = [] - miroir = [] - - liste.append(prems) - - for nx in range(dimx): - if ( nx != mx ): - liste.append(grid1.getQuad1 (HEXA_ORB.DIR_Z, nx, my, dimz)) - - #for (int nx=0. nx pose probl�me car les points associ�s par cette m�thode sont -# uniform�ment r�partis sur le contour => �a d�pend de la longueur -# entre les 2 grilles cylindriques. -# REM : a retester apr�s la correction d'Alain pour voir ce que �a -# donne - -# deuxi�me solution : -# 1. 4 associations par ligne fermee pour les trous -# => pour chaque association, 6 edges du modele <-> 1 ligne de la geometrie -# 2. 4 associations par lignes ouvertes pour les contours externes des -# grilles cylindriques -# => pour chaque association, 4 edges du modele <-> 3 lignes de la geometrie -# 3. 4 associations de points restants (mod_x1, mod_x4, mod_y1, mod_y4) - -# => cette solution pose probl�me (� cause de l'association par ligne -# ouverte) - -bielle_geom = geompy.ImportFile(STEP_PATH, "STEP") -doc.setShape(bielle_geom) -geompy.addToStudy(bielle_geom, "bielle_geom") -all_edges_bielle = geompy.SubShapeAllSorted(bielle_geom, geompy.ShapeType["EDGE"]) - - - -# dictionnaire des edges de la g�om�trie : -# key = nom, value = indice dans all_edges_bielle -dic_edge_names = {"edge_ray_pte_b": 0, "edge_ray_pte_h": 1, - "edge_trou_pte_b": 2, "edge_trou_pte_h" :3, - "edge_arr_pte_g_b": 7, "edge_arr_pte_g_h": 8, - "edge_arr_pte_d_b": 9, "edge_arr_pte_d_h": 10, - "edge_arr_grd_g_b": 19, "edge_arr_grd_g_h": 20, - "edge_arr_grd_d_b": 21, "edge_arr_grd_d_h": 22, - "edge_trou_grd_b": 25, "edge_trou_grd_h": 26, - "edge_ray_grd_b": 27, "edge_ray_grd_h": 28, - "edge_long_g_b": 13, "edge_long_g_h": 14, - "edge_long_d_b": 15, "edge_long_d_h": 16 - } - - -all_faces_bielle = geompy.SubShapeAllSorted(bielle_geom, geompy.ShapeType["FACE"]) -# dictionnaire des faces de la geometrie : -# key = nom, value = indice dans all_faces_bielle -dic_face_names = {"face_ray_pte": 0, "face_trou_pte": 1, "face_pte_g": 2, - "face_pte_d": 3, "face_long_g": 4, "face_long_d": 5, - "face_bas": 6, "face_haut": 7, "face_grd_g": 8, - "face_grd_d": 9, "face_trou_grd": 10, - "face_ray_grd": 11 - } - - -# la clef correspond a la geometrie, la valeur a l'indice en z dans le -# modele de bloc (grille cylindrique) -# NOTE : les dictionnaires ordonn�s ne sont pas encore introduits dans -# la version 2.6.6 de python (Salome 6.2). On ne connait donc pas -# l'ordre de bouclage (haut/bas ou bas/haut) mais �a n'a pas -# d'importance : -dico_haut_bas = {"h": 1, "b": 0} - -# 1. lignes internes (trou) haut/bas du petit cylindre -# ==================================================== -for z in dico_haut_bas.iteritems(): - - # REM : la direction de la ligne geometrique est dans le sens anti-trigonometrique - # => on parcourt le modele en sens inverse - -## # modele de blocs : -## mod_start = grille_cyl_pte.getEdgeJ(0, 5, z[1]) -## mod_first = mod_start.getVertex(1) -## # table des edges : -## mod_line = [grille_cyl_pte.getEdgeJ(0, j, z[1]) for j in range(4, -1, -1)] - - # modele de blocs : - mod_start = grille_cyl_pte.getEdgeJ(0, 0, z[1]) - mod_first = mod_start.getVertex(0) - # table des edges : - mod_line = [grille_cyl_pte.getEdgeJ(0, j, z[1]) for j in range(1, 6)] - - - # geometrie : 1 seule ligne - edge_hole_in = all_edges_bielle[dic_edge_names["edge_trou_pte_"+z[0]]] - geo_start = edge_hole_in - par_start = 0.0 - geo_line = [] - - # association : - ier = doc.associateClosedLine(mod_first, mod_start, mod_line, - geo_start, par_start, geo_line) - - -# 2. lignes internes (trou) haut/bas du grand cylindre -# ===================================================== -for z in dico_haut_bas.iteritems(): - - # REM : la direction de la ligne geometrique est dans le sens anti-trigonometrique - # => on parcourt le modele en sens inverse - -## # modele de blocs : -## mod_start = grille_cyl_grd.getEdgeJ(0, 5, z[1]) -## mod_first = mod_start.getVertex(1) -## # table des edges : -## mod_line = [grille_cyl_grd.getEdgeJ(0, j, z[1]) for j in range(4, -1, -1)] - - mod_start = grille_cyl_grd.getEdgeJ(0, 0, z[1]) - mod_first = mod_start.getVertex(1) - # table des edges : - mod_line = [grille_cyl_grd.getEdgeJ(0, j, z[1]) for j in range(1, 6)] - - # geometrie : 1 seule ligne - edge_hole_in = all_edges_bielle[dic_edge_names["edge_trou_grd_"+z[0]]] - geo_start = edge_hole_in - par_start = 0.0 - geo_line = [] - - # association : - ier = doc.associateClosedLine(mod_first, mod_start, mod_line, - geo_start, par_start, geo_line) - - -# 3. lignes externes haut/bas du petit cylindre -# ============================================= -for z in dico_haut_bas.iteritems(): - - # JPL le 08/07/2011 : on utilise ici l'association par ligne - # ouverte. Avec le nouvelle version, les points sont r�partis de - # mani�re �quidistance sur la ligne geometrique form�e par la - # concat�nation des lignes fournies en entr�e. - - # modele de blocs : - mod_start = grille_cyl_pte.getEdgeJ(1, 1, z[1]) - # table des edges : - mod_line = [grille_cyl_pte.getEdgeJ(1, j, z[1]) for j in [2, 3, 4]] - - # geometrie : - # les edges de la geometrie correspondant sont, dans l'ordre (par - # exemple pour le haut) : - # edge_arr_pte_d_h, edge_ray_pte_h, edge_arr_pte_g_h - geo_start = all_edges_bielle[dic_edge_names["edge_arr_pte_d_"+z[0]]] - - geo_line = [] - geo_line.append(all_edges_bielle[dic_edge_names["edge_ray_pte_"+z[0]]]) - geo_line.append(all_edges_bielle[dic_edge_names["edge_arr_pte_g_"+z[0]]]) - - # association : - # la premi�re est la derni�re ligne sont orient�es "dans le - # mauvais sens" => on fournit cette info : - par_start = 0.0 - par_end = 1.0 - ier = doc.associateOpenedLine(mod_start, mod_line, - geo_start, par_start, geo_line, par_end) - - -## # 4. lignes externes haut/bas du grand cylindre -## # ============================================= -for z in dico_haut_bas.iteritems(): - - # JPL le 08/07/2011 : on utilise ici l'association par ligne - # ouverte. Avec le nouvelle version, les points sont r�partis de - # mani�re �quidistance sur la ligne geometrique form�e par la - # concat�nation des lignes fournies en entr�e. - - # modele de blocs : - mod_start = grille_cyl_grd.getEdgeJ(1, 4, z[1]) - # table des edges : - mod_line = [grille_cyl_grd.getEdgeJ(1, j, z[1]) for j in [5, 0, 1]] - - # geometrie : - # les edges de la geometrie correspondant sont, dans l'ordre (par - # exemple pour le haut) : - # edge_arr_grd_g_h, edge_ray_grd_h, edge_arr_grd_d_h - geo_start = all_edges_bielle[dic_edge_names["edge_arr_grd_g_"+z[0]]] - - geo_line = [] - geo_line.append(all_edges_bielle[dic_edge_names["edge_ray_grd_"+z[0]]]) - geo_line.append(all_edges_bielle[dic_edge_names["edge_arr_grd_d_"+z[0]]]) - - # association : - # la premi�re est la derni�re ligne sont orient�es "dans le - # mauvais sens" => on fournit cette info : - par_start = 0.0 - par_end = 1.0 - ier = doc.associateOpenedLine(mod_start, mod_line, - geo_start, par_start, geo_line, par_end) - -# JPL le 26/07/2011 : -# l'association des edges n'est pas necessaire (implicite) - -# 6. association des 4 points restants (x1, x4, y1, y4) : -# ======================================================= - -# NB: -# h = top (haut) -# b = bottom (bas) -# g = big (grand) -# p = small (petit) -# t = hole (trou) - -# JPL le 08/07/2011 : -# seuls 4 points de la geometrie sont n�cessaires (pour l'association -# vertex/point : pour le reste on utilise l'association par lignes) : -# dictionnaire geom_vertices -# il s'agit de points des grilles cylindriques, � l'int�rieur -# de la bielle, ayant servis au joinQuads (ie: mod_x1, mod_x4, mod_y1, mod_y4) - - -## pt_a = geompy.MakeVertex(0, 0, hauteur/2.) -## face_haut = geompy.GetFaceNearPoint(bielle_geom, pt_a) -## pt_b = geompy.MakeVertex(0, 0, -hauteur/2.) -## face_bas = geompy.GetFaceNearPoint(bielle_geom, pt_b) - -face_haut = all_faces_bielle[dic_face_names["face_haut"]] - -edge_haut_droite = geompy.GetEdgesByLength(face_haut, 0.136, 0.137) -edge_haut_gauche = geompy.GetEdgesByLength(face_haut, 0.131, 0.132) - -# 1. grand cylindre : -y_h_g = geompy.MakeVertexOnSurface(face_haut, 1, 0.5) -u_h_g = geompy.MakeVertexOnCurve(edge_haut_droite, 1) -w_h_g = geompy.MakeVertexOnCurve(edge_haut_gauche, 0) -edge_v_grd = geompy.MakeLineTwoPnt(u_h_g, w_h_g) - -geo_y1 = geompy.MakeVertexOnCurve(edge_v_grd, 0.5) -geo_y4 = geompy.MakeVertexWithRef(geo_y1, 0.0, 0.0, -hauteur) - -# vertex cote grande grille cylindrique : -mod_y1.setAssociation(geo_y1) -mod_y4.setAssociation(geo_y4) - -# 2. petit cylindre : -# REM : le modele grand cylindre a ete cree par translation / au petit -# cylindre. -v_h_p = geompy.MakeVertexOnSurface(face_haut, 0, 0.5) -x_h_p = geompy.MakeVertexOnCurve(edge_haut_droite, 0) -z_h_p = geompy.MakeVertexOnCurve(edge_haut_gauche, 1) -edge_v_pte = geompy.MakeLineTwoPnt(x_h_p, z_h_p) - -geo_x1 = geompy.MakeVertexOnCurve(edge_v_pte, 0.5) -geo_x4 = geompy.MakeVertexWithRef(geo_x1, 0.0, 0.0, -hauteur) - -# vertex cote petite grille cylindrique : -mod_x1.setAssociation(geo_x1) -mod_x4.setAssociation(geo_x4) - -# 7. association des faces : -# REM : l'association des faces internes ne semble pas necessaire (cylindres) -# pas d'association des face_ray_XXX : pas necessaire ? De toute -# fa�on, on a pour chaque 2 quads du mod�le... -# les associations de face_haut, face_bas, face_long_g et face_long_d -# ne sont pas necessaires ? - -# a decommenter donc si necessaire : -## quad1 = grille_cyl_pte.getQuadJK(1, 1, 0) -## quad1.addAssociation(all_faces_bielle[dic_face_names["face_pte_d"]]) -## quad2 = grille_cyl_pte.getQuadJK(1, 4, 0) -## quad2.addAssociation(all_faces_bielle[dic_face_names["face_pte_g"]]) -## quad3 = grille_cyl_grd.getQuadJK(1, 1, 0) -## quad3.addAssociation(all_faces_bielle[dic_face_names["face_grd_d"]]) -## quad4 = grille_cyl_grd.getQuadJK(1, 4, 0) -## quad4.addAssociation(all_faces_bielle[dic_face_names["face_grd_g"]]) - - -############################################################################################# -############################################################################################# -# TEST : - -file_name = os.path.join(os.environ['TMP'], 'bielle2.vtk') -doc.saveVtk(file_name) - -# affichage des points des 2 grilles cylindriques avec les -# nouvelles coordonn�es (apres association) - -for k in range(2): - # petite grille cylindrique - i = 0 - for j in range(6): - vertex = grille_cyl_pte.getVertexIJK(i, j, k) - value = " ".join(["i =", str(i), "j =", str(j), - str(vertex.getX()), str(vertex.getY()), str(vertex.getZ()), '\n']) - f_mod_apres.write(str(value)) - pass - - f_mod_apres.write("stop\n") - - i = 1 - # on n'inclut pas les vertex associ�s individuellement (qui ne - # changent pas de coordonn�es...) : => j = 1 -> 5 - for j in range(1, 6): - vertex = grille_cyl_pte.getVertexIJK(i, j, k) - value = " ".join(["i =", str(i), "j =", str(j), - str(vertex.getX()), str(vertex.getY()), str(vertex.getZ()), '\n']) - f_mod_apres.write(str(value)) - pass - - f_mod_apres.write("stop\n") - - # grande grille cylindrique - i = 0 - for j in range(6): - vertex = grille_cyl_grd.getVertexIJK(i, j, k) - value = " ".join(["i =", str(i), "j =", str(j), - str(vertex.getX()), str(vertex.getY()), str(vertex.getZ()), '\n']) - f_mod_apres.write(str(value)) - pass - - f_mod_apres.write("stop\n") - - i = 1 - # on n'inclut pas les vertex associ�s individuellement (qui ne - # changent pas de coordonn�es...) (j = 3) - # on ecrit les points dans le meme ordre que l'association : - for j in [4, 5, 0, 1, 2]: - vertex = grille_cyl_grd.getVertexIJK(i, j, k) - value = " ".join(["i =", str(i), "j =", str(j), - str(vertex.getX()), str(vertex.getY()), str(vertex.getZ()), '\n']) - f_mod_apres.write(str(value)) - pass - # end TEST - - f_mod_apres.write("stop\n") - -############################################################################################# -############################################################################################# - - -## #================================================= -## # VERTEX, EDGES, FACES DANS L'ARBRE D'ETUDE SALOME -## #================================================= - -# vertices : -geompy.addToStudy(geo_x1, 'vertex_x1') -geompy.addToStudy(geo_x4, 'vertex_x4') -geompy.addToStudy(geo_y1, 'vertex_y1') -geompy.addToStudy(geo_y4, 'vertex_y4') - -# edges : -for key, value in dic_edge_names.iteritems(): - geompy.addToStudy(all_edges_bielle[value], key) - -# faces (juste pour les tests) : -for i, face in enumerate(all_faces_bielle): - geompy.addToStudy(face, "face_"+str(i)) - -#==================================== -# CREATION MAILLAGE -#==================================== - - -#================================================= -# Definir les groupes d elements pour le maillage -#================================================= - -# On definit 3 groupes de mailles - -# JPL (le 09/05/2011) : -# @todo a revoir : apres correction des bugs "countXXX()" dans le moteur - -# groupe d edges (arretes) -edge_grp = doc.addEdgeGroup("Edge_grp") -for i in range(doc.countEdge()): - edge_grp.addElement(doc.getEdge(i)) - -# groupe de quads (faces) -quad_grp = doc.addQuadGroup("Quad_grp") -for i in range(doc.countQuad()): - quad_grp.addElement(doc.getQuad(i)) - -# groupe d hexas (solids) -hexa_grp = doc.addHexaGroup("Hexa_grp") -for i in range(doc.countHexa()): - hexa_grp.addElement(doc.getHexa(i)) - -# groupe de noeuds de vertex pour tout le modele -vertex_nod_grp = doc.addVertexNodeGroup("Vertex_Nod_Grp") -for i in range(doc.countVertex()): - vertex_nod_grp.addElement(doc.getVertex(i)) - -#==================================== -# Definir une loi de discretisation -#==================================== -# definir une loi: le choix de la loi reste aux utilisateurs -law = doc.addLaw("Uniform", 4) - -# TEST : pour avoir le mod�le de blocs : -## law = doc.addLaw("Uniform", 0) - -# chercher les propagations du modele -for j in range(doc.countPropagation()): - propa = doc.getPropagation(j) - propa.setLaw(law) # appliquer la loi de discretisation sur tout le modele et generer le maillage - -#==================================== -# G�n�rer des maillages -#==================================== - -print " --- MAILLAGE HEXAHEDRIQUE --- " -mesh_hexas = hexablock.mesh(doc) - -print "Nombre d hexaedres:", mesh_hexas.NbHexas() -print "Nombre de quadrangles:", mesh_hexas.NbQuadrangles() -print "Nombre de segments:", mesh_hexas.NbEdges() -print "Nombre de noeuds:", mesh_hexas.NbNodes() - -# TESTS : -f_mod_apres.close() diff --git a/src/TEST_PY/bielle_variante.py b/src/TEST_PY/bielle_variante.py deleted file mode 100644 index 7d163fd..0000000 --- a/src/TEST_PY/bielle_variante.py +++ /dev/null @@ -1,248 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - - -# Francis KLOSS - 2011 - CEA-Saclay, DEN, DM2S, SFME, LGLS, F-91191 Gif-sur-Yvette, France -# ======================================================================================== - -import geompy -import hexablock - -# Définir les paramètres -# ---------------------- - -nom = "bielle" - -# Construire le modèle de bloc -# ============================ - -doc = hexablock.addDocument(nom) - -# Construire les 2 grilles cylindriques -# ------------------------------------- - -centre_a = doc.addVertex(0, 0, 0) -centre_b = doc.addVertex(6, 0, 0) - -vecteur_a = doc.addVector(1, 1, 0) -vecteur_z = doc.addVector(0, 0, 1) -vecteur_b = doc.addVector(6, 0, 0) - -grille_a = doc.makeCylindrical(centre_a, vecteur_a, vecteur_z, 1, 360, 1, 1, 4, 1, False) - -### grille_b = doc.makeTranslation(grille_a, vecteur_b) -grille_b = doc.makeCylindrical(centre_b, vecteur_a, vecteur_z, 2, 360, 1, 1, 4, 1, False) - -grilles = [ grille_a, grille_b ] - -# Relier les 2 grilles -# -------------------- - -quad_a = grille_a.getQuadJK(1, 3, 0) -quad_b = grille_b.getQuadJK(1, 1, 0) - -point_a1 = grille_a.getVertexIJK(1, 0, 0) -point_a2 = grille_a.getVertexIJK(1, 3, 0) - -point_b1 = grille_b.getVertexIJK(1, 1, 0) -point_b2 = grille_b.getVertexIJK(1, 2, 0) - -prisme = doc.joinQuad(quad_a, quad_b, point_a1, point_b1, point_a2, point_b2, 3) - -# Associer le modèle de bloc avec la géométrie -# ============================================ - -# Charger la géométrie à associer -# ------------------------------- - -bielle = geompy.ImportSTEP("crank.stp") - -doc.setShape(bielle) - -# Extraire les subshapes de la géométrie -# -------------------------------------- - -g_vertices = geompy.SubShapeAllSortedCentres(bielle, geompy.ShapeType["VERTEX"]) -g_edges = geompy.SubShapeAllSortedCentres(bielle, geompy.ShapeType["EDGE" ]) - -sommets = [ [ 8, 6, 9, 7 ], [ 12, 10, 13, 11 ] ] - -cercles = [ [2, 3], [25, 26] ] -arcs_gr = [ [0, 1], [27, 28] ] -arcs_pe = [ [ 9, 7, 10, 8 ], [ 21, 19, 22, 20 ] ] - -# Réparer l'association par ligne fermée -# -------------------------------------- - -def reparer(cercle, grille): - import math - - k = geompy.KindOfShape(cercle) - - centre = geompy.MakeVertex(k[1], k[2], k[3]) - axe = geompy.MakePrismDXDYDZ(centre, k[4], k[5], k[6]) - angle = [ +math.pi/4, -math.pi/4 ][grille] - - if grille==1: - axeY = geompy.MakePrismDXDYDZ(centre, 0, 1, 0) - cercle = geompy.MakeRotation(cercle, axeY, math.pi) - - return geompy.MakeRotation(cercle, axe, angle) - -# Associer les 4 cercles intérieurs -# --------------------------------- - -for k in xrange(0, 2): - for g in xrange(0, 2): - grille = grilles[g] - ve = grille.getVertexIJK(0, g, k) - le = [ grille.getEdgeJ(0, j, k) for j in xrange(0, 4) ] - ed = reparer( g_edges[ cercles[g][k] ], g ) - doc.associateClosedLine(ve, le[0], le[1:], ed, 0.0, []) - -# Associer les 4 grands arcs de cercle extérieurs -# ----------------------------------------------- - -for k in xrange(0, 2): - for g in xrange(0, 2): - grille = grilles[g] - le = [ grille.getEdgeJ(1, j, k) for j in [ [0, 1, 2], [2, 3, 0] ][g] ] - ed = g_edges[ arcs_gr[g][k] ] - doc.associateOpenedLine(le[0], le[1:], ed, 0, [], 1) - -# Associer les 8 sommets des petits arcs de cercle extérieurs -# ----------------------------------------------------------- - -for g, h in [ [0, 1], [1, 2] ]: - hexa = prisme.getHexa(h) - for vi in xrange(0, 4): - vm = hexa.getVertex(vi) - vg = g_vertices[ sommets[g][vi] ] - vm.setAssociation(vg) - -# Associer les 8 petits arcs de cercle extérieurs -# ----------------------------------------------- - -for g, h in [ [0, 0], [1, 2] ]: - hexa = prisme.getHexa(h) - for ei in xrange(0, 4): - em = hexa.getEdge(ei+8) - eg = g_edges[ arcs_pe[g][ei] ] - em.clearAssociation() - em.addAssociation(eg, 0, 1) - -# Associer 4 arcs nouveaux qui complétent les 4 grands arcs de cercle extérieurs -# ------------------------------------------------------------------------------ - -for h, ei, ech in [ [0, 0, 0.9], [0, 1, 0.9], [2, 2, 0.85], [2, 3, 0.85] ]: - hexa = prisme.getHexa(h) - em = hexa.getEdge(ei) - va = em.getVertex(0).getAssociation() - vb = em.getVertex(1).getAssociation() - vax, vay, vaz = geompy.PointCoordinates(va) - vbx, vby, vbz = geompy.PointCoordinates(vb) - vmx = ( vax + vbx ) / 2.0 * ech - vmy = ( vay + vby ) / 2.0 - vmz = ( vaz + vbz ) / 2.0 - vm = geompy.MakeVertex(vmx, vmy, vmz) - eg = geompy.MakeArc(va, vm, vb) - em.clearAssociation() - em.addAssociation(eg, 0, 1) - -# Mailler le modèle de bloc -# ========================= - -# Définir 5 groupes de faces -# -------------------------- - -groupe_trou_p = doc.addQuadGroup("Trou_petit") -groupe_trou_g = doc.addQuadGroup("Trou_grand") -groupe_bas = doc.addQuadGroup("Bas") -groupe_haut = doc.addQuadGroup("Haut") -groupe_contour = doc.addQuadGroup("Contour") - -for i in xrange(4): - groupe_trou_p.addElement(grille_a.getQuadJK(0, i, 0)) - groupe_trou_g.addElement(grille_b.getQuadJK(0, i, 0)) - - groupe_bas.addElement( grille_a.getQuadIJ(0, i, 0)) - groupe_bas.addElement( grille_b.getQuadIJ(0, i, 0)) - groupe_haut.addElement(grille_a.getQuadIJ(0, i, 1)) - groupe_haut.addElement(grille_b.getQuadIJ(0, i, 1)) - -for i in xrange(3): - groupe_contour.addElement(grille_a.getQuadJK(1, i, 0)) - -for i in [0, 2, 3]: - groupe_contour.addElement(grille_b.getQuadJK(1, i, 0)) - -for i in xrange(0, 3): - h = prisme.getHexa(i) - - q = h.getQuad(2) - groupe_bas.addElement(q) - - q = h.getQuad(3) - groupe_haut.addElement(q) - - q = h.getQuad(4) - groupe_contour.addElement(q) - q = h.getQuad(5) - groupe_contour.addElement(q) - -# Définir 3 groupes de volumes -# ---------------------------- - -groupe_cyli_p = doc.addHexaGroup("Cylindre_petit") -groupe_cyli_g = doc.addHexaGroup("Cylindre_grand") -groupe_prisme = doc.addHexaGroup("Prisme") - -for i in xrange(4): - groupe_cyli_p.addElement(grille_a.getHexa(i)) - groupe_cyli_g.addElement(grille_b.getHexa(i)) - -for i in xrange(3): - groupe_prisme.addElement(prisme.getHexa(i)) - -# Mailler le modèle de bloc avec association -# ------------------------------------------ - -l = doc.addLaw("Uniform1", 17) -n = doc.countPropagation() - -for i in xrange(n): - p = doc.getPropagation(i) - p.setLaw(l) - -l = doc.addLaw("Uniform2", 40) -p = doc.getPropagation(11) -p.setLaw(l) - -blocs = hexablock.mesh(doc) - -print "nombre de sommets du modèle de bloc: ", doc.countUsedVertex() -print "nombre d'arêtes du modèle de bloc: ", doc.countUsedEdge() -print "nombre de quadrangles du modèle de bloc: ", doc.countUsedQuad() -print "nombre de blocs du modèle de bloc: ", doc.countUsedHexa() - -print "Nombre de noeuds du maillage: ", blocs.NbNodes() -print "Nombre de segments du maillage: ", blocs.NbEdges() -print "Nombre de quadrangles du maillage: ", blocs.NbQuadrangles() -print "Nombre d'hexaèdres du maillage: ", blocs.NbHexas() diff --git a/src/TEST_PY/bride.py b/src/TEST_PY/bride.py deleted file mode 100644 index b3cb914..0000000 --- a/src/TEST_PY/bride.py +++ /dev/null @@ -1,410 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import os -import GEOM -import geompy -import smesh -import hexablock -import math -import SALOMEDS - -k1 = 1 - -OPT_QUAD_IK = 1 -OPT_FIRST = 2 - -count = 1 -def save_schema(doc): - """ - sauvegarde vtk du modele de bloc - """ - global count - file_name = os.path.join(os.environ['TMP'], 'bride' + str(count) + '.vtk') - doc.saveVtk(file_name) - count += 1 - pass - -def merge_quads(doc, quart, demi, ni1, nj1, ni2, nj2, option=0) : - """ - fusion des quadrangles entre les 2 grilles cylindriques : - """ - - prems = False - if option == OPT_FIRST: - prems = True - - quad_ik = False - if option == OPT_QUAD_IK: - quad_ik = True - - orig = None - if quad_ik: - orig = grille_cyl_quart.getQuadIK(ni1, nj1, k1) - else: - orig = grille_cyl_quart.getQuadJK(ni1, nj1, k1) - - dest = grille_cyl_demi.getQuadJK(ni2, nj2, k1) - - -# JPL le 10/05/2011 : -# closeQuads() n'est pas accessible en python -# a priori fonctionne avec mergeQuads() -## if prems: - if True: - iq1 = 0 - if quad_ik: - iq1 = 1 - iq3 = 1 - iq1 - v1 = dest.getVertex(iq1) - v3 = dest.getVertex(iq3) - - v2 = orig.getVertex(0) - v4 = orig.getVertex(1) - - doc.mergeQuads(dest, orig, v1, v2, v3, v4) - pass - else: -## doc.closeQuads(dest, orig) - print "closeQuads() : not yet implemented" - pass - - return None - -BREP_PATH = os.path.expandvars("$HEXABLOCK_ROOT_DIR/bin/salome/bride.brep") - -#============================= -# CREATION DOCUMENT -#============================= - -doc = hexablock.addDocument("bride") - -#============================= -# PARAMETRES -#============================= - -height = 1.0 - -# cylinder grid 1 : -nr1 = 8 -na1 = 4 -nl1 = 5 -dr1 = 1.0 -da1 = 45.0 # angle -dl1 = height - -# cylinder grid 2 : -nr2 = 3 -na2 = 8 -nl2 = nl1 -dr2 = 0.5 -da2 = 180.0 # angle -dl2 = dl1 - -#============================= -# Creation du modele de blocs -#============================= - -# JPL (le 09/05/2011) -# repris de test_bride_abu.cxx (version la plus a jour dans ~/IHMHEXA/Alain/models): -# et de BRIDE.py (Karima) pour les "vraies" coordonn�es : - -#================================================= -# Creation des centres des grilles cylindriques -#================================================= - -center1 = doc.addVertex(0, 0, height) -center2 = doc.addVertex(6, 0, height) - -dx = doc.addVector(height, 0, 0) -dz = doc.addVector(0, 0, height) - -# Creation des grilles cylindriques initiales -#============================================ - -# 1. 1 ere grille (quart) : -#========================== - -# JPL (le 10/05/2011) : vu la geometrie, on ne remplit pas le centre : -## grille_cyl_quart = doc.makeCylindrical(orig1, dx, dz, dr_q, 45.0, dl, -## nr_q, na_q, dim_z, True) -grille_cyl_quart = doc.makeCylindrical(center1, dx, dz, dr1, da1, dl1, - nr1, na1, nl1, False) - - -# temporaire : sauvegarde du modele de blocs : -save_schema(doc) -# fin temporaire - -# Elagage : -for nk in range(2, nl1): - for nj in range(na1): - ideb = 2 - if nk == nl1 - 1: - ideb = 1 - for ni in range(ideb, nr1): - doc.removeHexa(grille_cyl_quart.getHexaIJK(ni, nj, nk)) - pass - pass - pass - -# temporaire : sauvegarde du modele de blocs : -save_schema(doc) -# fin temporaire - -# Semelle : -k0 = 0 -for nj in range(na1): - for ni in range(2, nr1): - doc.removeHexa(grille_cyl_quart.getHexaIJK(ni, nj, k0)) - pass - pass - -# temporaire : sauvegarde du modele de blocs : -save_schema(doc) -# fin temporaire - -# @todo JPL : peut-on fusionner les edges du haut des hexaedres du haut du deuxieme -# rang ? (cf. GEOM). Si oui revoir aussi l'association - -# 2. 2�me grille (demi) : -#======================== -grille_cyl_demi = doc.makeCylindrical(center2, dx, dz, dr2, da2, dl2, - nr2, na2, nl2, True) - -# temporaire : sauvegarde du modele de blocs : -save_schema(doc) -# fin temporaire - -ni0 = [0, nr2, 2, 1, 0] # en fonction de z (ie : nk) -for nk in range(0, nl2): - for nj in range(na2): # elagage suivant toute la demi-circonference - for ni in range(ni0[nk], nr2): - doc.removeHexa(grille_cyl_demi.getHexaIJK(ni, nj, nk)) - pass - pass - pass - - -# temporaire : sauvegarde du modele de blocs : -save_schema(doc) -# fin temporaire - -# 3. creusement des fondations de demi dans quart : -#================================================== -for nj in range(2): - for ni in range(3, nr1 - 1): - doc.removeHexa(grille_cyl_quart.getHexaIJK(ni, nj, k1)) - pass - pass - -# temporaire : sauvegarde du modele de blocs : -save_schema(doc) -# fin temporaire - -# 4. Fusion des bords : -#====================== -merge_quads(doc, grille_cyl_quart, grille_cyl_demi, 7, 0, nr2, 0, OPT_FIRST) -merge_quads(doc, grille_cyl_quart, grille_cyl_demi, 7, 1, nr2, 1) -for ni1 in range(2, 6): - merge_quads(doc, grille_cyl_quart, grille_cyl_demi, 8 - ni1, 2, nr2, ni1, OPT_QUAD_IK) - pass -merge_quads(doc, grille_cyl_quart, grille_cyl_demi, 3, 1, nr2, 6) -merge_quads(doc, grille_cyl_quart, grille_cyl_demi, 3, 0, nr2, 7) - -# temporaire : sauvegarde du modele de blocs : -save_schema(doc) -# fin temporaire - -########### -# Geometry -########### - -bride_geom = geompy.ImportFile(BREP_PATH, "BREP") - -geompy.addToStudy(bride_geom, "bride_geom") - - -# parametres de la geometrie : - -r1 = 12.0 -r1_t = 7.88 -r2 = 20.0 -r2_t = 2.0 - -############## -# Association -############## - -# association vertex/points de la grille 1 -# (tous les vertex qui ne sont pas fusionnes avec ceux de la grille # -# 2) - -dz_geom = geompy.MakeVectorDXDYDZ(0., 0., 1.) - -# les vertex du cylindre 1 sont crees de bas en haut, en tournant dans -# le sens trigonometrique : - -# 6 vertex sont necessaires / axe z (pour associer aux 6 vertices du -# modele) : - -z_val = [-1, 1.5, 21.5, 34, 46.5] # nl1 + 1 valeurs -for ni in range(nr1 + 1): - # suivant ni, valeurs des x pour les (nl1 + 1) points (selon l'axe z) - x = [] - z = [] - nb_z = 0 # nombre de points suivant l'axe z - if ni == 0: - z = z_val - x = [r1_t] * len(z) - pass - elif ni == 1: - z = z_val - x = [r1_t + 2.77] * len(z) - pass - elif ni == 2: - z = z_val[0:-1] # tout sauf le dernier - x_last = r1_t + 2.77 - x = [24.0, 24.0, 19.0, (19.0 - x_last)/2 + x_last, x_last] # pour le 4 eme point, moyenne - # entre le 3 eme et le 5 eme - pass - elif ni == 3: - z = z_val[1:3] - x = [24.0, 19.0] - pass - elif ni == 4: - z = z_val[1:3] - x = [26.5, 21.0] # a revoir pour le premier point ?? - pass - elif ni == 8: - z = z_val[1:3] - x = [47.5] * 2 - pass - else: # ni = 5, 6, 7 - z = z_val[1:3] - x = [26.5 + (47.5 - 26.5)/4*(ni - 4)] * 2 - pass - pass - - nb_z = len(z) - - # creation des points pour y = 0 : - vert_grid1_xi = [geompy.MakeVertex(xi, 0, zi) for (xi, zi) in \ - zip(x, z)] - - # les points suivants sont crees par rotation de PI/16 suivant - # l'axe z / aux precedents : - angle = math.pi/4.0/na1 # PI/4 (45 degres), divise par 4 - for j in range(na1): - li = [geompy.MakeRotation(v, dz_geom, angle) for v in vert_grid1_xi[-nb_z:]] - vert_grid1_xi.extend(li) - pass - - # ajout des points a l'etude et association : - # les vertex fusionnes ou correspondant a des hexaedres effaces ne - # sont pas pris en compte. - for nj in range(na1 + 1): - for nk in range(nb_z): - if (ni <= 2) or (3 <= ni <= 7 and nj >= na1 - 1) or \ - (ni == 8 and (nj == 0 or nj >= na1 - 1)): - v_mod = grille_cyl_quart.getVertexIJK(ni, nj, nk) - v_geo = vert_grid1_xi[nk + nj*nb_z] - geompy.addToStudy(v_geo, "vert_grid1_x" + str(ni) + "_y" + \ - str(nj) + "_z" + str(nk)) - v_mod.setAssociation(v_geo) - pass - pass - pass - - pass - -# association vertex/points de la grille 2 -# (tous les vertex qui ne sont pas fusionnes avec ceux de la grille # -# 1) -## dz_geom2 = geompy.MakeVectorDXDYDZ(33.5, 0., 1.) -pt_a = geompy.MakeVertex(33.5, 0, 0) -pt_b = geompy.MakeVertex(33.5, 0, 1.) -dz_geom2 = geompy.MakeVector(pt_a, pt_b) - -# les vertex du cylindre 2 sont crees de bas en haut, en tournant dans -# le sens trigonometrique : - -# REM : pour l'instant on met de cote la partie centrale du cylindre -# (6 vertex selon z) => a faire a la fin. Ils sont d'ailleurs ranges -# apres les autres dans le modele - - -# 6 vertex sont necessaires / axe z (pour associer aux 6 vertices du -# modele) : - -z_val = [-1, 1.5, 21.5, 24, 36, 41.5] # nl2 + 1 valeurs -for ni in range(nr2 + 1): - # suivant ni, valeurs des x pour les (nl1 + 1) points (selon l'axe z) - x = [] - z = [] - nb_z = 0 # nombre de points suivant l'axe z - if ni == 0: - z = z_val - x = [39.5] * len(z) - pass - elif ni == 1: - z = z_val[1:-1] # tout sauf le dernier et le premier - x = [42.5] * len(z) - pass - elif ni == 2: - z = z_val[1:-2] # tout sauf les 2 derniers et le premier - x = [46.] * len(z) - pass - elif ni == 3: - z = z_val[1:3] - x = [46.7] * len(z) # valeur a revoir ?? - pass - pass - - nb_z = len(z) - - # creation des points pour y = 0 : - vert_grid2_xi = [geompy.MakeVertex(xi, 0, zi) for (xi, zi) in \ - zip(x, z)] - - # les points suivants sont crees par rotation de PI/16 suivant - # l'axe z / aux precedents : - angle = math.pi/na2 # PI (180 degres), divise par 8 - for j in range(na2): - li = [geompy.MakeRotation(v, dz_geom2, angle) for v in vert_grid2_xi[-nb_z:]] - vert_grid2_xi.extend(li) - pass - - # ajout des points a l'etude et association : - for nj in range(na2 + 1): - for nk in range(nb_z): - v_mod = grille_cyl_demi.getVertexIJK(ni, nj, nk) - v_geo = vert_grid2_xi[nk + nj*nb_z] - geompy.addToStudy(v_geo, "vert_grid2_x" + str(ni) + "_y" + \ - str(nj) + "_z" + str(nk)) - v_mod.setAssociation(v_geo) - pass - pass - - pass - -# association des vertex communs grille1/grille2 -# REM : cette etape n'est pas necessaire ? En effet, les vertex ayant -# ete fusionnes, l'association a ete faite avec la grille 2 diff --git a/src/TEST_PY/foo.py b/src/TEST_PY/foo.py new file mode 100644 index 0000000..9bd924a --- /dev/null +++ b/src/TEST_PY/foo.py @@ -0,0 +1,4 @@ + + +a = 2 +print a diff --git a/src/TEST_PY/recettes/cuve.py b/src/TEST_PY/recettes/cuve.py index dd42eb6..6cf16cb 100644 --- a/src/TEST_PY/recettes/cuve.py +++ b/src/TEST_PY/recettes/cuve.py @@ -1,572 +1,573 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# Francis KLOSS - 2011-2012 - 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) +# -*- coding: latin-1 -*- +# Copyright (C) 2009-2012 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# Francis KLOSS - 2011-2012 - 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) + diff --git a/src/TEST_PY/test_BIELLE_bad_assoc.py b/src/TEST_PY/test_BIELLE_bad_assoc.py deleted file mode 100755 index 507389a..0000000 --- a/src/TEST_PY/test_BIELLE_bad_assoc.py +++ /dev/null @@ -1,1081 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -#=============================================== -# By Karima DEBCHI YATAGHENE Nov 2009 at CS -#=============================================== - - -import os -import GEOM -import geompy -import smesh -import hexablock -import math -import SALOMEDS - - -STEP_PATH = os.path.expandvars("$HEXA_ROOT_DIR/bin/salome/crank.stp") - - -#============================= -# CREATION DOCUMENT -#============================= - -doc = hexablock.addDocument("default") - -#============================= -# CREATION DU MODELE -#============================= - -# Pour la bielle on doit creer deux grilles cylindriques et prismer les quadrangles entre ces deux dernieres - -#============================= -# PARAMETRES -#============================= - -R = 40.0 - -r_grd = R -r_grd_t = R/2 - -r_pte = R -r_pte_t = R/2 - -l = 200.0 -h = 0.019999999553*2 -#h = 40. - -# Taille du grand cylindre -dr_grd = R -da_grd = 360 -dl_grd = h - -nr_grd = 1 -na_grd = 6 -nl_grd = 1 - -# Taille du petit cylindre -dr_pte = R -da_pte = 360 -dl_pte = h - -nr_pte = 1 -na_pte = 6 -nl_pte = 1 - - -#============================= -# Creation des vecteurs -#============================= - -dx = doc.addVector(l, 0, 0) -dy = doc.addVector(0, l, 0) -dz = doc.addVector(0, 0, l) - -#================================================= -# Creation des centres des grilles cylindriques -#================================================= - -c_grd = doc.addVertex(0, 0, 0) -c_pte = doc.addVertex(2*l, 0, 0) -dx_prime = doc.addVectorVertices( c_grd, c_pte ) - -#================================================= -# Creation de la grande grille cylindrique -#================================================= - -grille_cyl_grd = doc.makeCylindrical(c_grd, dx, dz, dr_grd, da_grd, dl_grd, nr_grd, na_grd, nl_grd, False) - -# on obtient une liste qui contient 6 hexaedres eguaux - -# 30 = pi/6 -# 60 = pi/3 -# 45 = pi/4 -# 90 = pi/2 -# 180 = pi - -alpha_x = 2*R*math.cos(math.pi/3) -alpha_y = 2*R*math.sin(math.pi/3) - -x1 = doc.findVertex( 2*R, 0, h ) -x2 = doc.findVertex( alpha_x, alpha_y, 0 ) -x3 = doc.findVertex( alpha_x, -alpha_y, 0 ) -x4 = doc.findVertex( 2*R, 0, 0 ) - -quad_11 = doc.findQuad(x1, x2) -quad_12 = doc.findQuad(x1, x3) - -quad_list = [ quad_11 , quad_12 ] - -#================================================= -# Creation de la petite grille cylindrique -#================================================= - -grille_cyl_pte = doc.makeTranslation( grille_cyl_grd , dx_prime ) - -# on obtient une liste qui contient 6 hexaedres eguaux - -y1 = doc.findVertex( 2*l - 2*R , 0 , h ) -y2 = doc.findVertex( 2*l - alpha_x , alpha_y , 0 ) -y3 = doc.findVertex( 2*l - alpha_x , -alpha_y , 0 ) -y4 = doc.findVertex( 2*l - 2*R , 0 , 0 ) - -quad_21 = doc.findQuad(y1, y2) -quad_22 = doc.findQuad(y1, y3) - -#================================================= -# Assemblage des deux grilles cylindriques -#================================================= -model_biell_fin = doc.joinQuads( quad_list , quad_21 , x1 , y1 , x4 , y4 , 1 ) - - -#=================================================================== -# Recuperation des vertex du model hexa bielle pour l association -#=================================================================== - -# NB: -# h = haut -# b = bas -# g = grand -# p = petit -# t = trou - -alpha_x = 2*R*math.cos(math.pi/3) -alpha_y = 2*R*math.sin(math.pi/3) - -# Face du haut grand trou - -## RQ:On remplace la fonction findVertex par getVertexIJK - -v_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 0 , 1 ) -w_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 1 , 1 ) -z_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 2 , 1 ) - -y_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 3 , 1 ) -x_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 4 , 1 ) -u_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 5 , 1 ) - -v_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 0 , 1 ) -w_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 1 , 1 ) -z_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 2 , 1 ) - -y_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 3 , 1 ) -x_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 4 , 1 ) -u_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 5 , 1 ) - -#----------- -#x_mod_h_g = doc.findVertex( -alpha_x , -alpha_y , h ) -#y_mod_h_g = doc.findVertex( -alpha_x , 0 , h ) -#z_mod_h_g = doc.findVertex( -alpha_x , alpha_y , h ) - -#u_mod_h_g = doc.findVertex( alpha_x , -alpha_y , h ) -#v_mod_h_g = doc.findVertex( alpha_x , 0 , h ) -#w_mod_h_g = doc.findVertex( alpha_x , alpha_y , h ) - -#x_mod_h_g_t = doc.findVertex( -alpha_x/2 , -alpha_y/2 , h ) -#y_mod_h_g_t = doc.findVertex( -alpha_x/2 , 0 , h ) -#z_mod_h_g_t = doc.findVertex( -alpha_x/2 , alpha_y/2 , h ) - -#u_mod_h_g_t = doc.findVertex( alpha_x/2 , -alpha_y/2 , h ) -#v_mod_h_g_t = doc.findVertex( alpha_x/2 , 0 , h ) -#w_mod_h_g_t = doc.findVertex( alpha_x/2 , alpha_y/2 , h ) -#----------- - -assert x_mod_h_g -assert y_mod_h_g -assert z_mod_h_g - -assert u_mod_h_g -assert v_mod_h_g -assert w_mod_h_g - -assert x_mod_h_g_t -assert y_mod_h_g_t # -assert z_mod_h_g_t - -assert u_mod_h_g_t # -assert v_mod_h_g_t -assert w_mod_h_g_t # - - -# Face du haut petit trou - -## RQ:On remplace la fonction findVertex par getVertexIJK -v_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 0 , 1 ) -w_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 1 , 1 ) -z_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 2 , 1 ) - -y_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 3 , 1 ) -x_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 4 , 1 ) -u_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 5 , 1 ) - -v_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 0 , 1 ) -w_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 1 , 1 ) -z_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 2 , 1 ) - -y_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 3 , 1 ) -x_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 4 , 1 ) -u_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 5 , 1 ) - - -#----------- -#x_mod_h_p = doc.findVertex( l + alpha_x , -alpha_y , h ) -#y_mod_h_p = doc.findVertex( l + alpha_x , 0 , h ) -#z_mod_h_p = doc.findVertex( l + alpha_x , alpha_y , h ) - -#u_mod_h_p = doc.findVertex( l - alpha_x , -alpha_y , h ) -#v_mod_h_p = doc.findVertex( l - alpha_x , 0 , h ) -#w_mod_h_p = doc.findVertex( l - alpha_x , alpha_y , h ) - -#x_mod_h_p_t = doc.findVertex( l + (alpha_x/2) , -alpha_y/2 , h ) -#y_mod_h_p_t = doc.findVertex( l + (alpha_x/2) , 0 , h ) -#z_mod_h_p_t = doc.findVertex( l + (alpha_x/2) , alpha_y/2 , h ) - -#u_mod_h_p_t = doc.findVertex( l - (alpha_x/2) , -alpha_y/2 , h ) -#v_mod_h_p_t = doc.findVertex( l - (alpha_x/2) , 0 , h ) -#w_mod_h_p_t = doc.findVertex( l - (alpha_x/2) , alpha_y/2 , h ) -#----------- - -#----------- -assert x_mod_h_p -assert y_mod_h_p -assert z_mod_h_p - -assert u_mod_h_p -assert v_mod_h_p -assert w_mod_h_p - -assert x_mod_h_p_t -assert y_mod_h_p_t -assert z_mod_h_p_t - -assert u_mod_h_p_t -assert v_mod_h_p_t -assert w_mod_h_p_t -#----------- - -# Face du bas grand trou - -## RQ:On remplace la fonction findVertex par getVertexIJK - -v_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 0 , 0 ) -w_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 1 , 0 ) -z_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 2 , 0 ) - -y_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 3 , 0 ) -x_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 4 , 0 ) -u_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 5 , 0 ) - -v_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 0 , 0 ) -w_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 1 , 0 ) -z_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 2 , 0 ) - -y_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 3 , 0 ) -x_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 4 , 0 ) -u_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 5 , 0 ) - -#----------- -#x_mod_b_g = doc.findVertex( -alpha_x , -alpha_y , 0 ) -#y_mod_b_g = doc.findVertex( -alpha_x , 0 , 0 ) -#z_mod_b_g = doc.findVertex( -alpha_x , alpha_y , 0 ) - -#u_mod_b_g = doc.findVertex( alpha_x , -alpha_y , 0 ) -#v_mod_b_g = doc.findVertex( alpha_x , 0 , 0 ) -#w_mod_b_g = doc.findVertex( alpha_x , alpha_y , 0 ) - -#x_mod_b_g_t = doc.findVertex( -alpha_x/2 , -alpha_y/2 , 0 ) -#y_mod_b_g_t = doc.findVertex( -alpha_x/2 , 0 , 0 ) -#z_mod_b_g_t = doc.findVertex( -alpha_x/2 , alpha_y/2 , 0 ) - -#u_mod_b_g_t = doc.findVertex( alpha_x/2 , -alpha_y/2 , 0 ) -#v_mod_b_g_t = doc.findVertex( alpha_x/2 , 0 , 0 ) -#w_mod_b_g_t = doc.findVertex( alpha_x/2 , alpha_y/2 , 0 ) -#----------- - -assert x_mod_b_g -assert y_mod_b_g -assert z_mod_b_g - -assert u_mod_b_g -assert v_mod_b_g -assert w_mod_b_g - -assert x_mod_b_g_t -assert y_mod_b_g_t -assert z_mod_b_g_t - -assert u_mod_b_g_t -assert v_mod_b_g_t -assert w_mod_b_g_t - - -# Face du bas petit trou - - -## RQ:On remplace la fonction findVertex par getVertexIJK - -v_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 0 , 0 ) -w_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 1 , 0 ) -z_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 2 , 0 ) - -y_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 3 , 0 ) -x_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 4 , 0 ) -u_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 5 , 0 ) - -v_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 0 , 0 ) -w_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 1 , 0 ) -z_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 2 , 0 ) - -y_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 3 , 0 ) -x_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 4 , 0 ) -u_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 5 , 0 ) - - -#----------- -#x_mod_b_p = doc.findVertex( l + alpha_x , -alpha_y , 0 ) -#y_mod_b_p = doc.findVertex( l + alpha_x , 0 , 0 ) -#z_mod_b_p = doc.findVertex( l + alpha_x , alpha_y , 0 ) - -#u_mod_b_p = doc.findVertex( l - alpha_x , -alpha_y , 0 ) -#v_mod_b_p = doc.findVertex( l - alpha_x , 0 , 0 ) -#w_mod_b_p = doc.findVertex( l - alpha_x , alpha_y , 0 ) - -#x_mod_b_p_t = doc.findVertex( l + (alpha_x/2) , -alpha_y/2 , 0 ) -#y_mod_b_p_t = doc.findVertex( l + (alpha_x/2) , 0 , 0 ) -#z_mod_b_p_t = doc.findVertex( l + (alpha_x/2) , alpha_y/2 , 0 ) - -#u_mod_b_p_t = doc.findVertex( l - (alpha_x/2) , -alpha_y/2 , 0 ) -#v_mod_b_p_t = doc.findVertex( l - (alpha_x/2) , 0 , 0 ) -#w_mod_b_p_t = doc.findVertex( l - (alpha_x/2) , alpha_y/2 , 0 ) -#----------- - -#----------- -assert x_mod_b_p -assert y_mod_b_p -assert z_mod_b_p - -assert u_mod_b_p -assert v_mod_b_p -assert w_mod_b_p - -assert x_mod_b_p_t -assert y_mod_b_p_t -assert z_mod_b_p_t - -assert u_mod_b_p_t -assert v_mod_b_p_t -assert w_mod_b_p_t -#----------- - - - -#=================================================================== -# Recuperation des points de la geometrie bielle pour l association -#=================================================================== -Bielle_geom = geompy.Import(STEP_PATH, "STEP") - -geompy.addToStudy(Bielle_geom, "Bielle_geom") - -Pt_A = geompy.MakeVertex(0, 0, h/2.) -Face_haut = geompy.GetFaceNearPoint(Bielle_geom, Pt_A) - - -Pt_B = geompy.MakeVertex(0, 0, -h/2.) -Face_bas = geompy.GetFaceNearPoint(Bielle_geom, Pt_B) - - -# NB: -# h = haut -# b = bas -# g = grand -# p = petit -# t = trou - - -y_h_g = geompy.MakeVertexOnSurface(Face_haut, 1, 0.5) -geompy.addToStudy( y_h_g , "y_h_g" ) -y_b_g = geompy.MakeVertexWithRef(y_h_g, 0, 0, -h) -geompy.addToStudy( y_b_g , "y_b_g" ) - -v_h_p = geompy.MakeVertexOnSurface(Face_haut, 0, 0.5) -geompy.addToStudy( v_h_p , "v_h_p" ) -v_b_p = geompy.MakeVertexWithRef(v_h_p, 0, 0, -h) -geompy.addToStudy( v_b_p , "v_b_p" ) - -Edge_haut_grd = geompy.GetEdgeNearPoint(Bielle_geom, y_h_g) -Edge_haut_pte = geompy.GetEdgeNearPoint(Bielle_geom, v_h_p) - - - -x_h_g = geompy.MakeVertexOnCurve(Edge_haut_grd, 0) -geompy.addToStudy( x_h_g , "x_h_g" ) -x_b_g = geompy.MakeVertexWithRef(x_h_g, 0, 0, -h) -geompy.addToStudy( x_b_g , "x_b_g" ) - -z_h_g = geompy.MakeVertexOnCurve(Edge_haut_grd, 1) -geompy.addToStudy( z_h_g , "z_h_g" ) -z_b_g = geompy.MakeVertexWithRef(z_h_g, 0, 0, -h) -geompy.addToStudy( z_b_g , "z_b_g" ) - -w_h_p = geompy.MakeVertexOnCurve(Edge_haut_pte, 0) -geompy.addToStudy( w_h_p , "w_h_p" ) -w_b_p = geompy.MakeVertexWithRef(w_h_p, 0, 0, -h) -geompy.addToStudy( w_b_p , "w_b_p" ) - -u_h_p = geompy.MakeVertexOnCurve(Edge_haut_pte, 1) -geompy.addToStudy( u_h_p , "u_h_p" ) -u_b_p = geompy.MakeVertexWithRef(u_h_p, 0, 0, -h) -geompy.addToStudy( u_b_p , "u_b_p" ) - - - -Edge_haut_grd_trou = geompy.GetEdgesByLength(Face_haut, 0.147, 0.148) - - - -y_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0) -geompy.addToStudy(y_h_g_t, "y_h_g_t") -y_b_g_t = geompy.MakeVertexWithRef(y_h_g_t, 0, 0, -h) -geompy.addToStudy(y_b_g_t, "y_b_g_t") - -z_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0.2) -geompy.addToStudy(z_h_g_t, "z_h_g_t") -z_b_g_t = geompy.MakeVertexWithRef(z_h_g_t, 0, 0, -h) -geompy.addToStudy(z_b_g_t, "z_b_g_t") - -w_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0.35) -geompy.addToStudy(w_h_g_t, "w_h_g_t") -w_b_g_t = geompy.MakeVertexWithRef(w_h_g_t, 0, 0, -h) -geompy.addToStudy(w_b_g_t, "w_b_g_t") - -v_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0.5) -geompy.addToStudy(v_h_g_t, "v_h_g_t") -v_b_g_t = geompy.MakeVertexWithRef(v_h_g_t, 0, 0, -h) -geompy.addToStudy(v_b_g_t, "v_b_g_t") - -u_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0.65) -geompy.addToStudy(u_h_g_t, "u_h_g_t") -u_b_g_t = geompy.MakeVertexWithRef(u_h_g_t, 0, 0, -h) -geompy.addToStudy(u_b_g_t, "u_b_g_t") - -x_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0.8) -geompy.addToStudy(x_h_g_t, "x_h_g_t") -x_b_g_t = geompy.MakeVertexWithRef(x_h_g_t, 0, 0, -h) -geompy.addToStudy(x_b_g_t, "x_b_g_t") - - - -Edge_haut_pte_trou = geompy.GetEdgesByLength(Face_haut, 0.094, 0.095) - -y_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0) -geompy.addToStudy(y_h_p_t, "y_h_p_t") -y_b_p_t = geompy.MakeVertexWithRef(y_h_p_t, 0, 0, -h) -geompy.addToStudy(y_b_p_t, "y_b_p_t") - -z_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0.2) -geompy.addToStudy(z_h_p_t, "z_h_p_t") -z_b_p_t = geompy.MakeVertexWithRef(z_h_p_t, 0, 0, -h) -geompy.addToStudy(z_b_p_t, "z_b_p_t") - -w_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0.35) -geompy.addToStudy(w_h_p_t, "w_h_p_t") -w_b_p_t = geompy.MakeVertexWithRef(w_h_p_t, 0, 0, -h) -geompy.addToStudy(w_b_p_t, "w_b_p_t") - -v_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0.5) -geompy.addToStudy(v_h_p_t, "v_h_p_t") -v_b_p_t = geompy.MakeVertexWithRef(v_h_p_t, 0, 0, -h) -geompy.addToStudy(v_b_p_t, "v_b_p_t") - -u_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0.65) -geompy.addToStudy(u_h_p_t, "u_h_p_t") -u_b_p_t = geompy.MakeVertexWithRef(u_h_p_t, 0, 0, -h) -geompy.addToStudy(u_b_p_t, "u_b_p_t") - -x_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0.8) -geompy.addToStudy(x_h_p_t, "x_h_p_t") -x_b_p_t = geompy.MakeVertexWithRef(x_h_p_t, 0, 0, -h) -geompy.addToStudy(x_b_p_t, "x_b_p_t") - - - -Edge_haut_droite = geompy.GetEdgesByLength(Face_haut, 0.136, 0.137) - -u_h_g = geompy.MakeVertexOnCurve(Edge_haut_droite, 1) -geompy.addToStudy(u_h_g, "u_h_g") - -u_b_g = geompy.MakeVertexWithRef(u_h_g, 0, 0, -h) -geompy.addToStudy(u_b_g, "u_b_g") - -x_h_p = geompy.MakeVertexOnCurve(Edge_haut_droite, 0) -geompy.addToStudy(x_h_p, "x_h_p") -x_b_p = geompy.MakeVertexWithRef(x_h_p, 0, 0, -h) -geompy.addToStudy(x_b_p, "x_b_p") - - -Edge_haut_gauche = geompy.GetEdgesByLength(Face_haut, 0.131, 0.132) - -w_h_g = geompy.MakeVertexOnCurve(Edge_haut_gauche, 0) -geompy.addToStudy(w_h_g, "w_h_g") - -w_b_g = geompy.MakeVertexWithRef(w_h_g, 0, 0, -h) -geompy.addToStudy(w_b_g, "w_b_g") - -z_h_p = geompy.MakeVertexOnCurve(Edge_haut_gauche, 1) -geompy.addToStudy(z_h_p, "z_h_p") -z_b_p = geompy.MakeVertexWithRef(z_h_p, 0, 0, -h) -geompy.addToStudy(z_b_p, "z_b_p") - -Edge_v_grd = geompy.MakeLineTwoPnt(u_h_g, w_h_g) - -v_h_g = geompy.MakeVertexOnCurve(Edge_v_grd, 0.5) -geompy.addToStudy(v_h_g, "v_h_g") -v_b_g = geompy.MakeVertexWithRef(v_h_g, 0, 0, -h) -geompy.addToStudy(v_b_g, "v_b_g") - - -Edge_v_pte = geompy.MakeLineTwoPnt(x_h_p, z_h_p) - -y_h_p = geompy.MakeVertexOnCurve(Edge_v_pte, 0.5) -geompy.addToStudy(y_h_p, "y_h_p") -y_b_p = geompy.MakeVertexWithRef(y_h_p, 0, 0, -h) -geompy.addToStudy(y_b_p, "y_b_p") - - -#======================= -# CREATION ASSOCIATION -#======================= - -#=========================================== -# association des sommets de la face du haut -#=========================================== - -# grand trou - -x_mod_h_g.setAssociation( x_h_g ) -y_mod_h_g.setAssociation( y_h_g ) -z_mod_h_g.setAssociation( z_h_g ) -u_mod_h_g.setAssociation( u_h_g ) -v_mod_h_g.setAssociation( v_h_g ) -w_mod_h_g.setAssociation( w_h_g ) - -x_mod_h_g_t.setAssociation( x_h_g_t ) -y_mod_h_g_t.setAssociation( y_h_g_t ) -z_mod_h_g_t.setAssociation( z_h_g_t ) -u_mod_h_g_t.setAssociation( u_h_g_t ) -v_mod_h_g_t.setAssociation( v_h_g_t ) -w_mod_h_g_t.setAssociation( w_h_g_t ) - -# petit trou - -x_mod_h_p.setAssociation( x_h_p ) -y_mod_h_p.setAssociation( y_h_p ) -z_mod_h_p.setAssociation( z_h_p ) -u_mod_h_p.setAssociation( u_h_p ) -v_mod_h_p.setAssociation( v_h_p ) -w_mod_h_p.setAssociation( w_h_p ) - -x_mod_h_p_t.setAssociation( x_h_p_t ) -y_mod_h_p_t.setAssociation( y_h_p_t ) -z_mod_h_p_t.setAssociation( z_h_p_t ) -u_mod_h_p_t.setAssociation( u_h_p_t ) -v_mod_h_p_t.setAssociation( v_h_p_t ) -w_mod_h_p_t.setAssociation( w_h_p_t ) - - -#=========================================== -# association des sommets de la face du bas -#=========================================== - -# grand trou - -x_mod_b_g.setAssociation( x_b_g ) -y_mod_b_g.setAssociation( y_b_g ) -z_mod_b_g.setAssociation( z_b_g ) -u_mod_b_g.setAssociation( u_b_g ) -v_mod_b_g.setAssociation( v_b_g ) -w_mod_b_g.setAssociation( w_b_g ) - -x_mod_b_g_t.setAssociation( x_b_g_t ) -y_mod_b_g_t.setAssociation( y_b_g_t ) -z_mod_b_g_t.setAssociation( z_b_g_t ) -u_mod_b_g_t.setAssociation( u_b_g_t ) -v_mod_b_g_t.setAssociation( v_b_g_t ) -w_mod_b_g_t.setAssociation( w_b_g_t ) - -# petit trou - -x_mod_b_p.setAssociation( x_b_p ) -y_mod_b_p.setAssociation( y_b_p ) -z_mod_b_p.setAssociation( z_b_p ) -u_mod_b_p.setAssociation( u_b_p ) -v_mod_b_p.setAssociation( v_b_p ) -w_mod_b_p.setAssociation( w_b_p ) - -x_mod_b_p_t.setAssociation( x_b_p_t ) -y_mod_b_p_t.setAssociation( y_b_p_t ) -z_mod_b_p_t.setAssociation( z_b_p_t ) -u_mod_b_p_t.setAssociation( u_b_p_t ) -v_mod_b_p_t.setAssociation( v_b_p_t ) -w_mod_b_p_t.setAssociation( w_b_p_t ) - - - - -#================================= -# Creation association des edges -#================================= - - -All_Edges_Bielle = geompy.SubShapeAllSorted(Bielle_geom, geompy.ShapeType["EDGE"]) - -## recuperer les arrondies du haut de la geometrie - -Edge_Arr_grd_g_h = All_Edges_Bielle[20] -geompy.addToStudy( Edge_Arr_grd_g_h , "Edge_Arr_grd_g_h" ) - -Edge_Arr_grd_g_h_mod = grille_cyl_grd.getEdgeJ( 1 , 1 , 1 ) -Edge_Arr_grd_g_h_mod.addAssociation( Edge_Arr_grd_g_h, 0., 1. ) - - -Edge_Arr_grd_d_h = All_Edges_Bielle[22] -geompy.addToStudy( Edge_Arr_grd_d_h , "Edge_Arr_grd_d_h" ) - -Edge_Arr_grd_d_h_mod = grille_cyl_grd.getEdgeJ( 1 , 4 , 1 ) -Edge_Arr_grd_d_h_mod.addAssociation( Edge_Arr_grd_d_h, 0., 1. ) - - -Edge_Arr_pte_g_h = All_Edges_Bielle[8] -geompy.addToStudy( Edge_Arr_pte_g_h , "Edge_Arr_pte_g_h" ) - -Edge_Arr_pte_g_h_mod = grille_cyl_pte.getEdgeJ( 1 , 1 , 1 ) -Edge_Arr_pte_g_h_mod.addAssociation( Edge_Arr_pte_g_h, 0., 1. ) - -Edge_Arr_pte_d_h = All_Edges_Bielle[10] -geompy.addToStudy( Edge_Arr_pte_d_h , "Edge_Arr_pte_d_h" ) - -Edge_Arr_pte_d_h_mod = grille_cyl_pte.getEdgeJ( 1 , 4 , 1 ) -Edge_Arr_pte_d_h_mod.addAssociation( Edge_Arr_pte_d_h, 0., 1. ) - -# recuperer les arrondies du bas de la geometrie - -Edge_Arr_grd_g_b = All_Edges_Bielle[19] -geompy.addToStudy( Edge_Arr_grd_g_b , "Edge_Arr_grd_g_b" ) - -Edge_Arr_grd_g_b_mod = grille_cyl_grd.getEdgeJ( 1 , 1 , 0 ) -Edge_Arr_grd_g_b_mod.addAssociation( Edge_Arr_grd_g_b, 0., 1. ) - -Edge_Arr_grd_d_b = All_Edges_Bielle[21] -geompy.addToStudy( Edge_Arr_grd_d_b , "Edge_Arr_grd_d_b" ) - -Edge_Arr_grd_d_b_mod = grille_cyl_grd.getEdgeJ( 1 , 4 , 0 ) -Edge_Arr_grd_d_b_mod.addAssociation( Edge_Arr_grd_d_b, 0., 1. ) - -Edge_Arr_pte_g_b = All_Edges_Bielle[7] -geompy.addToStudy( Edge_Arr_pte_g_b , "Edge_Arr_pte_g_b" ) - -Edge_Arr_pte_g_b_mod = grille_cyl_pte.getEdgeJ( 1 , 1 , 0 ) -Edge_Arr_pte_g_b_mod.addAssociation( Edge_Arr_pte_g_b, 0., 1. ) - -Edge_Arr_pte_d_b = All_Edges_Bielle[9] -geompy.addToStudy( Edge_Arr_pte_d_b , "Edge_Arr_pte_d_b" ) - -Edge_Arr_pte_d_b_mod = grille_cyl_pte.getEdgeJ( 1 , 4 , 0 ) -Edge_Arr_pte_d_b_mod.addAssociation( Edge_Arr_pte_d_b, 0., 1. ) - - -# recuperer les grand rayons de la geometrie - -Edge_Ray_grd_g_h = All_Edges_Bielle[28] -geompy.addToStudy( Edge_Ray_grd_g_h , "Edge_Ray_grd_g_h" ) -Edge_Ray_grd_d_h = All_Edges_Bielle[1] -geompy.addToStudy( Edge_Ray_grd_d_h , "Edge_Ray_grd_d_h" ) - -Edge_Ray_grd_g_b = All_Edges_Bielle[27] -geompy.addToStudy( Edge_Ray_grd_g_b , "Edge_Ray_grd_g_b" ) -Edge_Ray_grd_d_b = All_Edges_Bielle[0] -geompy.addToStudy( Edge_Ray_grd_d_b , "Edge_Ray_grd_d_b" ) - - - -X_pln1 = geompy.MakeVertex( 0 , 0 , 0 ) -Vec_X = geompy.MakeVectorDXDYDZ( 0 , 1 , 0 ) -Plan1 = geompy.MakePlane( X_pln1 , Vec_X , 200 ) - -Parti_Grd_Ray = geompy.MakePartition([ Edge_Ray_grd_g_h , Edge_Ray_grd_d_h , Edge_Ray_grd_g_b , Edge_Ray_grd_d_b ], [ Plan1 ], [], [], geompy.ShapeType["EDGE"], 0, [], 0) -geompy.addToStudy( Parti_Grd_Ray , "Parti_Grd_Ray" ) - - -All_Edges_Parti_Grd_Ray = geompy.SubShapeAllSorted(Parti_Grd_Ray, geompy.ShapeType["EDGE"]) - - -Grd_Ray_0 = All_Edges_Parti_Grd_Ray[0] -geompy.addToStudy( Grd_Ray_0 , "Grd_Ray_0" ) - -##Edge_Arr_grd_g_h_mod = grille_cyl_pte.getEdgeJ( 1 , 2 , 0 ) -Edge_Grd_Ray_0_mod = grille_cyl_pte.getEdgeJ( 1 , 0 , 0 ) -Edge_Grd_Ray_0_mod.addAssociation( Grd_Ray_0, 0., 1. ) - - -Grd_Ray_1 = All_Edges_Parti_Grd_Ray[1] -geompy.addToStudy( Grd_Ray_1 , "Grd_Ray_1" ) - -##Edge_Grd_Ray_1_mod = grille_cyl_pte.getEdgeJ( 1 , 2 , 1 ) -Edge_Grd_Ray_1_mod = grille_cyl_pte.getEdgeJ( 1 , 0 , 1 ) -Edge_Grd_Ray_1_mod.addAssociation( Grd_Ray_1, 0., 1. ) - -Grd_Ray_2 = All_Edges_Parti_Grd_Ray[2] -geompy.addToStudy( Grd_Ray_2 , "Grd_Ray_2" ) - -##Edge_Grd_Ray_2_mod = grille_cyl_pte.getEdgeJ( 1 , 3 , 0 ) -Edge_Grd_Ray_2_mod = grille_cyl_pte.getEdgeJ( 1 , 5 , 0 ) -Edge_Grd_Ray_2_mod.addAssociation( Grd_Ray_2, 0., 1. ) - -Grd_Ray_3 = All_Edges_Parti_Grd_Ray[3] -geompy.addToStudy( Grd_Ray_3 , "Grd_Ray_3" ) - -##Edge_Grd_Ray_3_mod = grille_cyl_pte.getEdgeJ( 1 , 3 , 1 ) -Edge_Grd_Ray_3_mod = grille_cyl_pte.getEdgeJ( 1 , 5 , 1 ) -Edge_Grd_Ray_3_mod.addAssociation( Grd_Ray_3, 0., 1. ) - -Grd_Ray_4 = All_Edges_Parti_Grd_Ray[4] -geompy.addToStudy( Grd_Ray_4 , "Grd_Ray_4" ) - -Edge_Grd_Ray_4_mod = grille_cyl_grd.getEdgeJ( 1 , 2 , 0 ) -Edge_Grd_Ray_4_mod.addAssociation( Grd_Ray_4, 0., 1. ) -#Edge_Grd_Ray_4_mod.addAssociation( Edge_Ray_grd_g_b , 0., 1. ) - - -Grd_Ray_5 = All_Edges_Parti_Grd_Ray[5] -geompy.addToStudy( Grd_Ray_5 , "Grd_Ray_5" ) - -Edge_Grd_Ray_5_mod = grille_cyl_grd.getEdgeJ( 1 , 2 , 1 ) -Edge_Grd_Ray_5_mod.addAssociation( Grd_Ray_5, 0., 1. ) - -Grd_Ray_6 = All_Edges_Parti_Grd_Ray[6] -geompy.addToStudy( Grd_Ray_6 , "Grd_Ray_6" ) - -Edge_Grd_Ray_6_mod = grille_cyl_grd.getEdgeJ( 1 , 3 , 0 ) -Edge_Grd_Ray_6_mod.addAssociation( Grd_Ray_6, 0., 1. ) - -Grd_Ray_7 = All_Edges_Parti_Grd_Ray[7] -geompy.addToStudy( Grd_Ray_7 , "Grd_Ray_7" ) - -Edge_Arr_grd_g_h_mod = grille_cyl_grd.getEdgeJ( 1 , 3 , 1 ) -Edge_Arr_grd_g_h_mod.addAssociation( Grd_Ray_7, 0., 1. ) - - -# recuperer les rayons des trous de la bielle de la geometrie - -Edge_Trou_grd_h = All_Edges_Bielle[26] -geompy.addToStudy( Edge_Trou_grd_h , "Edge_Trou_grd_h" ) - -Edge_Trou_grd_b = All_Edges_Bielle[25] -geompy.addToStudy( Edge_Trou_grd_b , "Edge_Trou_grd_b" ) - -Edge_Trou_pte_h = All_Edges_Bielle[3] -geompy.addToStudy( Edge_Trou_pte_h , "Edge_Trou_pte_h" ) - -Edge_Trou_pte_b = All_Edges_Bielle[2] -geompy.addToStudy( Edge_Trou_pte_b , "Edge_Trou_pte_b" ) - -Partition_Trou_grd_haut = geompy.MakePartition([ Edge_Trou_grd_h ], [ z_h_g_t , w_h_g_t , v_h_g_t , u_h_g_t , x_h_g_t ], [], [], geompy.ShapeType["EDGE"], 0, [], 0) -geompy.addToStudy( Partition_Trou_grd_haut , "Partition_Trou_grd_haut" ) - -All_Edge_Partition_Trou_grd_haut = geompy.SubShapeAllSorted(Partition_Trou_grd_haut, geompy.ShapeType["EDGE"]) - -Edge_Trou_grd_h_0 = All_Edge_Partition_Trou_grd_haut[0] -geompy.addToStudy( Edge_Trou_grd_h_0 , "Edge_Trou_grd_h_0" ) - -Edge_Trou_grd_h_0_mod = grille_cyl_grd.getEdgeJ( 0 , 0 , 1 ) -Edge_Trou_grd_h_0_mod.addAssociation( Edge_Trou_grd_h_0, 0., 1. ) - -Edge_Trou_grd_h_2 = All_Edge_Partition_Trou_grd_haut[2] -geompy.addToStudy( Edge_Trou_grd_h_2 , "Edge_Trou_grd_h_2" ) - -Edge_Trou_grd_h_2_mod = grille_cyl_grd.getEdgeJ( 0 , 1 , 1 ) -Edge_Trou_grd_h_2_mod.addAssociation( Edge_Trou_grd_h_2, 0., 1. ) - -Edge_Trou_grd_h_4 = All_Edge_Partition_Trou_grd_haut[4] -geompy.addToStudy( Edge_Trou_grd_h_4 , "Edge_Trou_grd_h_4" ) - -Edge_Trou_grd_h_4_mod = grille_cyl_grd.getEdgeJ( 0 , 2 , 1 ) -Edge_Trou_grd_h_4_mod.addAssociation( Edge_Trou_grd_h_4, 0., 1. ) - -Edge_Trou_grd_h_5 = All_Edge_Partition_Trou_grd_haut[5] -geompy.addToStudy( Edge_Trou_grd_h_5 , "Edge_Trou_grd_h_5" ) - -Edge_Trou_grd_h_5_mod = grille_cyl_grd.getEdgeJ( 0 , 3 , 1 ) -Edge_Trou_grd_h_5_mod.addAssociation( Edge_Trou_grd_h_5, 0., 1. ) - -Edge_Trou_grd_h_3 = All_Edge_Partition_Trou_grd_haut[3] -geompy.addToStudy( Edge_Trou_grd_h_3 , "Edge_Trou_grd_h_3" ) - -Edge_Trou_grd_h_3_mod = grille_cyl_grd.getEdgeJ( 0 , 4 , 1 ) -Edge_Trou_grd_h_3_mod.addAssociation( Edge_Trou_grd_h_3, 0., 1. ) - -Edge_Trou_grd_h_1 = All_Edge_Partition_Trou_grd_haut[1] -geompy.addToStudy( Edge_Trou_grd_h_1 , "Edge_Trou_grd_h_1" ) - -Edge_Trou_grd_h_1_mod = grille_cyl_grd.getEdgeJ( 0 , 5 , 1 ) -Edge_Trou_grd_h_1_mod.addAssociation( Edge_Trou_grd_h_1, 0., 1. ) - - - -Partition_Trou_grd_bas = geompy.MakePartition([ Edge_Trou_grd_b ], [ z_b_g_t , w_b_g_t , v_b_g_t , u_b_g_t , x_b_g_t ], [], [], geompy.ShapeType["EDGE"], 0, [], 0) -geompy.addToStudy( Partition_Trou_grd_bas , "Partition_Trou_grd_bas" ) - - -All_Edge_Partition_Trou_grd_bas = geompy.SubShapeAllSorted(Partition_Trou_grd_bas, geompy.ShapeType["EDGE"]) - -Edge_Trou_grd_b_0 = All_Edge_Partition_Trou_grd_bas[0] -geompy.addToStudy( Edge_Trou_grd_b_0 , "Edge_Trou_grd_b_0" ) - -Edge_Trou_grd_b_0_mod = grille_cyl_grd.getEdgeJ( 0 , 0 , 0 ) -Edge_Trou_grd_b_0_mod.addAssociation( Edge_Trou_grd_b_0, 0., 1. ) - -Edge_Trou_grd_b_2 = All_Edge_Partition_Trou_grd_bas[2] -geompy.addToStudy( Edge_Trou_grd_b_2 , "Edge_Trou_grd_b_2" ) - -Edge_Trou_grd_b_2_mod = grille_cyl_grd.getEdgeJ( 0 , 1 , 0 ) -Edge_Trou_grd_b_2_mod.addAssociation( Edge_Trou_grd_b_2, 0., 1. ) - -Edge_Trou_grd_b_4 = All_Edge_Partition_Trou_grd_bas[4] -geompy.addToStudy( Edge_Trou_grd_b_4 , "Edge_Trou_grd_b_4" ) - -Edge_Trou_grd_b_4_mod = grille_cyl_grd.getEdgeJ( 0 , 2 , 0 ) -Edge_Trou_grd_b_4_mod.addAssociation( Edge_Trou_grd_b_4, 0., 1. ) - -Edge_Trou_grd_b_5 = All_Edge_Partition_Trou_grd_bas[5] -geompy.addToStudy( Edge_Trou_grd_b_5 , "Edge_Trou_grd_b_5" ) - -Edge_Trou_grd_b_5_mod = grille_cyl_grd.getEdgeJ( 0 , 3 , 0 ) -Edge_Trou_grd_b_5_mod.addAssociation( Edge_Trou_grd_b_5, 0., 1. ) - -Edge_Trou_grd_b_3 = All_Edge_Partition_Trou_grd_bas[3] -geompy.addToStudy( Edge_Trou_grd_b_3 , "Edge_Trou_grd_b_3" ) - -Edge_Trou_grd_b_3_mod = grille_cyl_grd.getEdgeJ( 0 , 4 , 0 ) -Edge_Trou_grd_b_3_mod.addAssociation( Edge_Trou_grd_b_3, 0., 1. ) - -Edge_Trou_grd_b_1 = All_Edge_Partition_Trou_grd_bas[1] -geompy.addToStudy( Edge_Trou_grd_b_1 , "Edge_Trou_grd_b_1" ) - -Edge_Trou_grd_b_1_mod = grille_cyl_grd.getEdgeJ( 0 , 5 , 0 ) -Edge_Trou_grd_b_1_mod.addAssociation( Edge_Trou_grd_b_1, 0., 1. ) - - - - - -Partition_Trou_pte_haut = geompy.MakePartition([ Edge_Trou_pte_h ], [ z_h_p_t , w_h_p_t , v_h_p_t , u_h_p_t , x_h_p_t ], [], [], geompy.ShapeType["EDGE"], 0, [], 0) -geompy.addToStudy( Partition_Trou_pte_haut , "Partition_Trou_pte_haut" ) - - -All_Edge_Partition_Trou_pte_haut = geompy.SubShapeAllSorted(Partition_Trou_pte_haut, geompy.ShapeType["EDGE"]) - -Edge_Trou_pte_h_0 = All_Edge_Partition_Trou_pte_haut[0] -geompy.addToStudy( Edge_Trou_pte_h_0 , "Edge_Trou_pte_h_0" ) - -Edge_Trou_pte_h_0_mod = grille_cyl_pte.getEdgeJ( 0 , 0 , 1 ) -Edge_Trou_pte_h_0_mod.addAssociation( Edge_Trou_pte_h_0, 0., 1. ) - -Edge_Trou_pte_h_2 = All_Edge_Partition_Trou_pte_haut[2] -geompy.addToStudy( Edge_Trou_pte_h_2 , "Edge_Trou_pte_h_2" ) - -Edge_Trou_pte_h_2_mod = grille_cyl_pte.getEdgeJ( 0 , 1 , 1 ) -Edge_Trou_pte_h_2_mod.addAssociation( Edge_Trou_pte_h_2, 0., 1. ) - -Edge_Trou_pte_h_4 = All_Edge_Partition_Trou_pte_haut[4] -geompy.addToStudy( Edge_Trou_pte_h_4 , "Edge_Trou_pte_h_4" ) - -Edge_Trou_pte_h_4_mod = grille_cyl_pte.getEdgeJ( 0 , 2 , 1 ) -Edge_Trou_pte_h_4_mod.addAssociation( Edge_Trou_pte_h_4, 0., 1. ) - -Edge_Trou_pte_h_5 = All_Edge_Partition_Trou_pte_haut[5] -geompy.addToStudy( Edge_Trou_pte_h_5 , "Edge_Trou_pte_h_5" ) - -Edge_Trou_pte_h_5_mod = grille_cyl_pte.getEdgeJ( 0 , 3 , 1 ) -Edge_Trou_pte_h_5_mod.addAssociation( Edge_Trou_pte_h_5, 0., 1. ) - -Edge_Trou_pte_h_3 = All_Edge_Partition_Trou_pte_haut[3] -geompy.addToStudy( Edge_Trou_pte_h_3 , "Edge_Trou_pte_h_3" ) - -Edge_Trou_pte_h_3_mod = grille_cyl_pte.getEdgeJ( 0 , 4 , 1 ) -Edge_Trou_pte_h_3_mod.addAssociation( Edge_Trou_pte_h_3, 0., 1. ) - -Edge_Trou_pte_h_1 = All_Edge_Partition_Trou_pte_haut[1] -geompy.addToStudy( Edge_Trou_pte_h_1 , "Edge_Trou_pte_h_1" ) - -Edge_Trou_pte_h_1_mod = grille_cyl_pte.getEdgeJ( 0 , 5 , 1 ) -Edge_Trou_pte_h_1_mod.addAssociation( Edge_Trou_pte_h_1, 0., 1. ) - - - - -Partition_Trou_pte_bas = geompy.MakePartition([ Edge_Trou_pte_b ], [ z_b_p_t , w_b_p_t , v_b_p_t , u_b_p_t , x_b_p_t ], [], [], geompy.ShapeType["EDGE"], 0, [], 0) -geompy.addToStudy( Partition_Trou_pte_bas , "Partition_Trou_pte_bas" ) - - -All_Edge_Partition_Trou_pte_bas = geompy.SubShapeAllSorted(Partition_Trou_pte_bas, geompy.ShapeType["EDGE"]) - -Edge_Trou_pte_b_0 = All_Edge_Partition_Trou_pte_bas[0] -geompy.addToStudy( Edge_Trou_pte_b_0 , "Edge_Trou_pte_b_0" ) - -Edge_Trou_pte_b_0_mod = grille_cyl_pte.getEdgeJ( 0 , 0 , 0 ) -Edge_Trou_pte_b_0_mod.addAssociation( Edge_Trou_pte_b_0, 0., 1. ) - -Edge_Trou_pte_b_2 = All_Edge_Partition_Trou_pte_bas[2] -geompy.addToStudy( Edge_Trou_pte_b_2 , "Edge_Trou_pte_b_2" ) - -Edge_Trou_pte_b_2_mod = grille_cyl_pte.getEdgeJ( 0 , 1 , 0 ) -Edge_Trou_pte_b_2_mod.addAssociation( Edge_Trou_pte_b_2, 0., 1. ) - -Edge_Trou_pte_b_4 = All_Edge_Partition_Trou_pte_bas[4] -geompy.addToStudy( Edge_Trou_pte_b_4 , "Edge_Trou_pte_b_4" ) - -Edge_Trou_pte_b_4_mod = grille_cyl_pte.getEdgeJ( 0 , 2 , 0 ) -Edge_Trou_pte_b_4_mod.addAssociation( Edge_Trou_pte_b_4, 0., 1. ) - -Edge_Trou_pte_b_5 = All_Edge_Partition_Trou_pte_bas[5] -geompy.addToStudy( Edge_Trou_pte_b_5 , "Edge_Trou_pte_b_5" ) - -Edge_Trou_pte_b_5_mod = grille_cyl_pte.getEdgeJ( 0 , 3 , 0 ) -Edge_Trou_pte_b_5_mod.addAssociation( Edge_Trou_pte_b_5, 0., 1. ) - -Edge_Trou_pte_b_3 = All_Edge_Partition_Trou_pte_bas[3] -geompy.addToStudy( Edge_Trou_pte_b_3 , "Edge_Trou_pte_b_3" ) - -Edge_Trou_pte_b_3_mod = grille_cyl_pte.getEdgeJ( 0 , 4 , 0 ) -Edge_Trou_pte_b_3_mod.addAssociation( Edge_Trou_pte_b_3, 0., 1. ) - -Edge_Trou_pte_b_1 = All_Edge_Partition_Trou_pte_bas[1] -geompy.addToStudy( Edge_Trou_pte_b_1 , "Edge_Trou_pte_b_1" ) - -Edge_Trou_pte_b_1_mod = grille_cyl_pte.getEdgeJ( 0 , 5 , 0 ) -Edge_Trou_pte_b_1_mod.addAssociation( Edge_Trou_pte_b_1, 0., 1. ) - -#==================================== -# CREATION DES FACES DES ARRONDIES -#==================================== - -All_Face_Arron_Bielle = geompy.SubShapeAllSorted(Bielle_geom, geompy.ShapeType["FACE"]) - -Face_Arron_1 = All_Face_Arron_Bielle[2] -geompy.addToStudy(Face_Arron_1, "Face_Arron_1") - -Quad_Arron_1 = grille_cyl_pte.getQuadJK( 1 , 1 , 0 ) - -Face_Arron_2 = All_Face_Arron_Bielle[3] -geompy.addToStudy(Face_Arron_2, "Face_Arron_2") - -Quad_Arron_2 = grille_cyl_pte.getQuadJK( 1 , 4 , 0 ) - -Face_Arron_3 = All_Face_Arron_Bielle[8] -geompy.addToStudy(Face_Arron_3, "Face_Arron_3") - -Quad_Arron_3 = grille_cyl_grd.getQuadJK( 1 , 1 , 0 ) - -Face_Arron_4 = All_Face_Arron_Bielle[9] -geompy.addToStudy(Face_Arron_4, "Face_Arron_4") - -Quad_Arron_4 = grille_cyl_grd.getQuadJK( 1 , 4 , 0 ) - - - - - - -#==================================== -# CREATION MAILLAGE -#==================================== - - -#================================================= -# Definir les groupes d elements pour le maillage -#================================================= - -# On definit 3 groupes de mailles - -# groupe d edges (arretes) - -Edge_grp = doc.addEdgeGroup("Edge_grp") -Nbr_Edg = doc.countEdge() -#print Nbr_Edg -for i in range(Nbr_Edg): - Edge_i = doc.getEdge(i) - Edge_grp.addElement(Edge_i) - - -# groupe de quads (faces) -Quad_grp = doc.addQuadGroup("Quad_grp") -Nbr_Qad = doc.countQuad() -#print Nbr_Qad -for i in range(Nbr_Qad): - Quad_i = doc.getQuad(i) - Quad_grp.addElement(Quad_i) - -# groupe d hexas (solids) -Hexa_grp = doc.addHexaGroup("Hexa_grp") -Nbr_Hex = doc.countHexa() -#print Nbr_Hex -for i in range(Nbr_Hex): - Hexa_i = doc.getHexa(i) - Hexa_grp.addElement(Hexa_i) - - - -# groupe de noeuds de vertex pour tout le modele - -Vertex_Nod_Grp = doc.addVertexNodeGroup("Vertex_Nod_Grp") -Nbr_Vx = doc.countVertex() -print Nbr_Vx - -for i in range(Nbr_Vx): - Vertex_i = doc.getVertex(i) - Vertex_Nod_Grp.addElement(Vertex_i) - -#==================================== -# Definir une loi de discretisation -#==================================== -# definir une loi: le choix de la loi reste aux utilisateurs -Law = doc.addLaw( "Uniform" , 4 ) - -#n = doc.countLaw() -#print n - -# chercher les propagations du modele -N_Propa = doc.countPropagation() - -for j in range(N_Propa): - Propa = doc.getPropagation(j) - Propa.setLaw( Law )# appliquer la loi de discretisation sur tout le modele et generer le maillage - -mesh = hexablock.mesh(doc, "test_BIELLE_bad_assoc:hexas") -#mesh = hexablock.mesh(doc, "test_BIELLE_bad_assoc:quads", 2) -#mesh = hexablock.mesh(doc, "test_BIELLE_bad_assoc:edges", 1) -#mesh = hexablock.mesh(doc, "test_BIELLE_bad_assoc:nodes", 0) - -print " --- MAILLAGE HEXAHEDRIQUE --- " -print "Nombre d hexaedres:" , mesh.NbHexas() -print "Nombre de quadrangles:", mesh.NbQuadrangles() -print "Nombre de segments:" , mesh.NbEdges() -print "Nombre de noeuds:" , mesh.NbNodes() diff --git a/src/TEST_PY/test_BIELLE_no_assoc.py b/src/TEST_PY/test_BIELLE_no_assoc.py deleted file mode 100755 index f699d4a..0000000 --- a/src/TEST_PY/test_BIELLE_no_assoc.py +++ /dev/null @@ -1,1075 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -#=============================================== -# By Karima DEBCHI YATAGHENE Nov 2009 at CS -#=============================================== - -import os -import GEOM -import geompy -import smesh -import hexablock -import math -import SALOMEDS - - -#STEP_PATH = os.path.expandvars("$HEXA_ROOT_DIR/bin/salome/crank.stp") - -#============================= -# CREATION DOCUMENT -#============================= - -doc = hexablock.addDocument("default") - -#============================= -# CREATION DU MODELE -#============================= - -# Pour la bielle on doit creer deux grilles cylindriques et prismer les quadrangles entre ces deux dernieres - -#============================= -# PARAMETRES -#============================= - -R = 40.0 - -r_grd = R -r_grd_t = R/2 - -r_pte = R -r_pte_t = R/2 - -l = 200.0 -#h = 0.019999999553*2 -h = 40. - -# Taille du grand cylindre -dr_grd = R -da_grd = 360 -dl_grd = h - -nr_grd = 1 -na_grd = 6 -nl_grd = 1 - -# Taille du petit cylindre -dr_pte = R -da_pte = 360 -dl_pte = h - -nr_pte = 1 -na_pte = 6 -nl_pte = 1 - - -#============================= -# Creation des vecteurs -#============================= - -dx = doc.addVector(l, 0, 0) -dy = doc.addVector(0, l, 0) -dz = doc.addVector(0, 0, l) - -#================================================= -# Creation des centres des grilles cylindriques -#================================================= - -c_grd = doc.addVertex(0, 0, 0) -c_pte = doc.addVertex(2*l, 0, 0) -dx_prime = doc.addVectorVertices( c_grd, c_pte ) - -#================================================= -# Creation de la grande grille cylindrique -#================================================= - -grille_cyl_grd = doc.makeCylindrical(c_grd, dx, dz, dr_grd, da_grd, dl_grd, nr_grd, na_grd, nl_grd, False) - -# on obtient une liste qui contient 6 hexaedres eguaux - -# 30 = pi/6 -# 60 = pi/3 -# 45 = pi/4 -# 90 = pi/2 -# 180 = pi - -alpha_x = 2*R*math.cos(math.pi/3) -alpha_y = 2*R*math.sin(math.pi/3) - -x1 = doc.findVertex( 2*R, 0, h ) -x2 = doc.findVertex( alpha_x, alpha_y, 0 ) -x3 = doc.findVertex( alpha_x, -alpha_y, 0 ) -x4 = doc.findVertex( 2*R, 0, 0 ) - -quad_11 = doc.findQuad(x1, x2) -quad_12 = doc.findQuad(x1, x3) - -quad_list = [ quad_11 , quad_12 ] - -#================================================= -# Creation de la petite grille cylindrique -#================================================= - -grille_cyl_pte = doc.makeTranslation( grille_cyl_grd , dx_prime ) - -# on obtient une liste qui contient 6 hexaedres eguaux - -y1 = doc.findVertex( 2*l - 2*R , 0 , h ) -y2 = doc.findVertex( 2*l - alpha_x , alpha_y , 0 ) -y3 = doc.findVertex( 2*l - alpha_x , -alpha_y , 0 ) -y4 = doc.findVertex( 2*l - 2*R , 0 , 0 ) - -quad_21 = doc.findQuad(y1, y2) -quad_22 = doc.findQuad(y1, y3) - -#================================================= -# Assemblage des deux grilles cylindriques -#================================================= -model_biell_fin = doc.joinQuads( quad_list , quad_21 , x1 , y1 , x4 , y4 , 1 ) - - -#=================================================================== -# Recuperation des vertex du model hexa bielle pour l association -#=================================================================== - -# NB: -# h = haut -# b = bas -# g = grand -# p = petit -# t = trou - -alpha_x = 2*R*math.cos(math.pi/3) -alpha_y = 2*R*math.sin(math.pi/3) - -# Face du haut grand trou - -## RQ:On remplace la fonction findVertex par getVertexIJK - -v_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 0 , 1 ) -w_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 1 , 1 ) -z_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 2 , 1 ) - -y_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 3 , 1 ) -x_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 4 , 1 ) -u_mod_h_g = grille_cyl_grd.getVertexIJK( 1 , 5 , 1 ) - -v_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 0 , 1 ) -w_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 1 , 1 ) -z_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 2 , 1 ) - -y_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 3 , 1 ) -x_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 4 , 1 ) -u_mod_h_g_t = grille_cyl_grd.getVertexIJK( 0 , 5 , 1 ) - -#----------- -#x_mod_h_g = doc.findVertex( -alpha_x , -alpha_y , h ) -#y_mod_h_g = doc.findVertex( -alpha_x , 0 , h ) -#z_mod_h_g = doc.findVertex( -alpha_x , alpha_y , h ) - -#u_mod_h_g = doc.findVertex( alpha_x , -alpha_y , h ) -#v_mod_h_g = doc.findVertex( alpha_x , 0 , h ) -#w_mod_h_g = doc.findVertex( alpha_x , alpha_y , h ) - -#x_mod_h_g_t = doc.findVertex( -alpha_x/2 , -alpha_y/2 , h ) -#y_mod_h_g_t = doc.findVertex( -alpha_x/2 , 0 , h ) -#z_mod_h_g_t = doc.findVertex( -alpha_x/2 , alpha_y/2 , h ) - -#u_mod_h_g_t = doc.findVertex( alpha_x/2 , -alpha_y/2 , h ) -#v_mod_h_g_t = doc.findVertex( alpha_x/2 , 0 , h ) -#w_mod_h_g_t = doc.findVertex( alpha_x/2 , alpha_y/2 , h ) -#----------- - -assert x_mod_h_g -assert y_mod_h_g -assert z_mod_h_g - -assert u_mod_h_g -assert v_mod_h_g -assert w_mod_h_g - -assert x_mod_h_g_t -assert y_mod_h_g_t # -assert z_mod_h_g_t - -assert u_mod_h_g_t # -assert v_mod_h_g_t -assert w_mod_h_g_t # - - -# Face du haut petit trou - -## RQ:On remplace la fonction findVertex par getVertexIJK -v_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 0 , 1 ) -w_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 1 , 1 ) -z_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 2 , 1 ) - -y_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 3 , 1 ) -x_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 4 , 1 ) -u_mod_h_p = grille_cyl_pte.getVertexIJK( 1 , 5 , 1 ) - -v_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 0 , 1 ) -w_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 1 , 1 ) -z_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 2 , 1 ) - -y_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 3 , 1 ) -x_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 4 , 1 ) -u_mod_h_p_t = grille_cyl_pte.getVertexIJK( 0 , 5 , 1 ) - - -#----------- -#x_mod_h_p = doc.findVertex( l + alpha_x , -alpha_y , h ) -#y_mod_h_p = doc.findVertex( l + alpha_x , 0 , h ) -#z_mod_h_p = doc.findVertex( l + alpha_x , alpha_y , h ) - -#u_mod_h_p = doc.findVertex( l - alpha_x , -alpha_y , h ) -#v_mod_h_p = doc.findVertex( l - alpha_x , 0 , h ) -#w_mod_h_p = doc.findVertex( l - alpha_x , alpha_y , h ) - -#x_mod_h_p_t = doc.findVertex( l + (alpha_x/2) , -alpha_y/2 , h ) -#y_mod_h_p_t = doc.findVertex( l + (alpha_x/2) , 0 , h ) -#z_mod_h_p_t = doc.findVertex( l + (alpha_x/2) , alpha_y/2 , h ) - -#u_mod_h_p_t = doc.findVertex( l - (alpha_x/2) , -alpha_y/2 , h ) -#v_mod_h_p_t = doc.findVertex( l - (alpha_x/2) , 0 , h ) -#w_mod_h_p_t = doc.findVertex( l - (alpha_x/2) , alpha_y/2 , h ) -#----------- - -#----------- -assert x_mod_h_p -assert y_mod_h_p -assert z_mod_h_p - -assert u_mod_h_p -assert v_mod_h_p -assert w_mod_h_p - -assert x_mod_h_p_t -assert y_mod_h_p_t -assert z_mod_h_p_t - -assert u_mod_h_p_t -assert v_mod_h_p_t -assert w_mod_h_p_t -#----------- - -# Face du bas grand trou - -## RQ:On remplace la fonction findVertex par getVertexIJK - -v_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 0 , 0 ) -w_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 1 , 0 ) -z_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 2 , 0 ) - -y_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 3 , 0 ) -x_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 4 , 0 ) -u_mod_b_g = grille_cyl_grd.getVertexIJK( 1 , 5 , 0 ) - -v_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 0 , 0 ) -w_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 1 , 0 ) -z_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 2 , 0 ) - -y_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 3 , 0 ) -x_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 4 , 0 ) -u_mod_b_g_t = grille_cyl_grd.getVertexIJK( 0 , 5 , 0 ) - -#----------- -#x_mod_b_g = doc.findVertex( -alpha_x , -alpha_y , 0 ) -#y_mod_b_g = doc.findVertex( -alpha_x , 0 , 0 ) -#z_mod_b_g = doc.findVertex( -alpha_x , alpha_y , 0 ) - -#u_mod_b_g = doc.findVertex( alpha_x , -alpha_y , 0 ) -#v_mod_b_g = doc.findVertex( alpha_x , 0 , 0 ) -#w_mod_b_g = doc.findVertex( alpha_x , alpha_y , 0 ) - -#x_mod_b_g_t = doc.findVertex( -alpha_x/2 , -alpha_y/2 , 0 ) -#y_mod_b_g_t = doc.findVertex( -alpha_x/2 , 0 , 0 ) -#z_mod_b_g_t = doc.findVertex( -alpha_x/2 , alpha_y/2 , 0 ) - -#u_mod_b_g_t = doc.findVertex( alpha_x/2 , -alpha_y/2 , 0 ) -#v_mod_b_g_t = doc.findVertex( alpha_x/2 , 0 , 0 ) -#w_mod_b_g_t = doc.findVertex( alpha_x/2 , alpha_y/2 , 0 ) -#----------- - -assert x_mod_b_g -assert y_mod_b_g -assert z_mod_b_g - -assert u_mod_b_g -assert v_mod_b_g -assert w_mod_b_g - -assert x_mod_b_g_t -assert y_mod_b_g_t -assert z_mod_b_g_t - -assert u_mod_b_g_t -assert v_mod_b_g_t -assert w_mod_b_g_t - - -# Face du bas petit trou - - -## RQ:On remplace la fonction findVertex par getVertexIJK - -v_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 0 , 0 ) -w_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 1 , 0 ) -z_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 2 , 0 ) - -y_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 3 , 0 ) -x_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 4 , 0 ) -u_mod_b_p = grille_cyl_pte.getVertexIJK( 1 , 5 , 0 ) - -v_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 0 , 0 ) -w_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 1 , 0 ) -z_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 2 , 0 ) - -y_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 3 , 0 ) -x_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 4 , 0 ) -u_mod_b_p_t = grille_cyl_pte.getVertexIJK( 0 , 5 , 0 ) - - -#----------- -#x_mod_b_p = doc.findVertex( l + alpha_x , -alpha_y , 0 ) -#y_mod_b_p = doc.findVertex( l + alpha_x , 0 , 0 ) -#z_mod_b_p = doc.findVertex( l + alpha_x , alpha_y , 0 ) - -#u_mod_b_p = doc.findVertex( l - alpha_x , -alpha_y , 0 ) -#v_mod_b_p = doc.findVertex( l - alpha_x , 0 , 0 ) -#w_mod_b_p = doc.findVertex( l - alpha_x , alpha_y , 0 ) - -#x_mod_b_p_t = doc.findVertex( l + (alpha_x/2) , -alpha_y/2 , 0 ) -#y_mod_b_p_t = doc.findVertex( l + (alpha_x/2) , 0 , 0 ) -#z_mod_b_p_t = doc.findVertex( l + (alpha_x/2) , alpha_y/2 , 0 ) - -#u_mod_b_p_t = doc.findVertex( l - (alpha_x/2) , -alpha_y/2 , 0 ) -#v_mod_b_p_t = doc.findVertex( l - (alpha_x/2) , 0 , 0 ) -#w_mod_b_p_t = doc.findVertex( l - (alpha_x/2) , alpha_y/2 , 0 ) -#----------- - -#----------- -assert x_mod_b_p -assert y_mod_b_p -assert z_mod_b_p - -assert u_mod_b_p -assert v_mod_b_p -assert w_mod_b_p - -assert x_mod_b_p_t -assert y_mod_b_p_t -assert z_mod_b_p_t - -assert u_mod_b_p_t -assert v_mod_b_p_t -assert w_mod_b_p_t -#----------- - - - -##=================================================================== -## Recuperation des points de la geometrie bielle pour l association -##=================================================================== -#Bielle_geom = geompy.Import(STEP_PATH, "STEP") - -#geompy.addToStudy(Bielle_geom, "Bielle_geom") - -#Pt_A = geompy.MakeVertex(0, 0, h/2.) -#Face_haut = geompy.GetFaceNearPoint(Bielle_geom, Pt_A) - - -#Pt_B = geompy.MakeVertex(0, 0, -h/2.) -#Face_bas = geompy.GetFaceNearPoint(Bielle_geom, Pt_B) - - -## NB: -## h = haut -## b = bas -## g = grand -## p = petit -## t = trou - - -#y_h_g = geompy.MakeVertexOnSurface(Face_haut, 1, 0.5) -#geompy.addToStudy( y_h_g , "y_h_g" ) -#y_b_g = geompy.MakeVertexWithRef(y_h_g, 0, 0, -h) -#geompy.addToStudy( y_b_g , "y_b_g" ) - -#v_h_p = geompy.MakeVertexOnSurface(Face_haut, 0, 0.5) -#geompy.addToStudy( v_h_p , "v_h_p" ) -#v_b_p = geompy.MakeVertexWithRef(v_h_p, 0, 0, -h) -#geompy.addToStudy( v_b_p , "v_b_p" ) - -#Edge_haut_grd = geompy.GetEdgeNearPoint(Bielle_geom, y_h_g) -#Edge_haut_pte = geompy.GetEdgeNearPoint(Bielle_geom, v_h_p) - - - -#x_h_g = geompy.MakeVertexOnCurve(Edge_haut_grd, 0) -#geompy.addToStudy( x_h_g , "x_h_g" ) -#x_b_g = geompy.MakeVertexWithRef(x_h_g, 0, 0, -h) -#geompy.addToStudy( x_b_g , "x_b_g" ) - -#z_h_g = geompy.MakeVertexOnCurve(Edge_haut_grd, 1) -#geompy.addToStudy( z_h_g , "z_h_g" ) -#z_b_g = geompy.MakeVertexWithRef(z_h_g, 0, 0, -h) -#geompy.addToStudy( z_b_g , "z_b_g" ) - -#w_h_p = geompy.MakeVertexOnCurve(Edge_haut_pte, 0) -#geompy.addToStudy( w_h_p , "w_h_p" ) -#w_b_p = geompy.MakeVertexWithRef(w_h_p, 0, 0, -h) -#geompy.addToStudy( w_b_p , "w_b_p" ) - -#u_h_p = geompy.MakeVertexOnCurve(Edge_haut_pte, 1) -#geompy.addToStudy( u_h_p , "u_h_p" ) -#u_b_p = geompy.MakeVertexWithRef(u_h_p, 0, 0, -h) -#geompy.addToStudy( u_b_p , "u_b_p" ) - - - -#Edge_haut_grd_trou = geompy.GetEdgesByLength(Face_haut, 0.147, 0.148) - - - -#y_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0) -#geompy.addToStudy(y_h_g_t, "y_h_g_t") -#y_b_g_t = geompy.MakeVertexWithRef(y_h_g_t, 0, 0, -h) -#geompy.addToStudy(y_b_g_t, "y_b_g_t") - -#z_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0.2) -#geompy.addToStudy(z_h_g_t, "z_h_g_t") -#z_b_g_t = geompy.MakeVertexWithRef(z_h_g_t, 0, 0, -h) -#geompy.addToStudy(z_b_g_t, "z_b_g_t") - -#w_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0.35) -#geompy.addToStudy(w_h_g_t, "w_h_g_t") -#w_b_g_t = geompy.MakeVertexWithRef(w_h_g_t, 0, 0, -h) -#geompy.addToStudy(w_b_g_t, "w_b_g_t") - -#v_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0.5) -#geompy.addToStudy(v_h_g_t, "v_h_g_t") -#v_b_g_t = geompy.MakeVertexWithRef(v_h_g_t, 0, 0, -h) -#geompy.addToStudy(v_b_g_t, "v_b_g_t") - -#u_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0.65) -#geompy.addToStudy(u_h_g_t, "u_h_g_t") -#u_b_g_t = geompy.MakeVertexWithRef(u_h_g_t, 0, 0, -h) -#geompy.addToStudy(u_b_g_t, "u_b_g_t") - -#x_h_g_t = geompy.MakeVertexOnCurve(Edge_haut_grd_trou, 0.8) -#geompy.addToStudy(x_h_g_t, "x_h_g_t") -#x_b_g_t = geompy.MakeVertexWithRef(x_h_g_t, 0, 0, -h) -#geompy.addToStudy(x_b_g_t, "x_b_g_t") - - - -#Edge_haut_pte_trou = geompy.GetEdgesByLength(Face_haut, 0.094, 0.095) - -#y_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0) -#geompy.addToStudy(y_h_p_t, "y_h_p_t") -#y_b_p_t = geompy.MakeVertexWithRef(y_h_p_t, 0, 0, -h) -#geompy.addToStudy(y_b_p_t, "y_b_p_t") - -#z_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0.2) -#geompy.addToStudy(z_h_p_t, "z_h_p_t") -#z_b_p_t = geompy.MakeVertexWithRef(z_h_p_t, 0, 0, -h) -#geompy.addToStudy(z_b_p_t, "z_b_p_t") - -#w_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0.35) -#geompy.addToStudy(w_h_p_t, "w_h_p_t") -#w_b_p_t = geompy.MakeVertexWithRef(w_h_p_t, 0, 0, -h) -#geompy.addToStudy(w_b_p_t, "w_b_p_t") - -#v_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0.5) -#geompy.addToStudy(v_h_p_t, "v_h_p_t") -#v_b_p_t = geompy.MakeVertexWithRef(v_h_p_t, 0, 0, -h) -#geompy.addToStudy(v_b_p_t, "v_b_p_t") - -#u_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0.65) -#geompy.addToStudy(u_h_p_t, "u_h_p_t") -#u_b_p_t = geompy.MakeVertexWithRef(u_h_p_t, 0, 0, -h) -#geompy.addToStudy(u_b_p_t, "u_b_p_t") - -#x_h_p_t = geompy.MakeVertexOnCurve(Edge_haut_pte_trou, 0.8) -#geompy.addToStudy(x_h_p_t, "x_h_p_t") -#x_b_p_t = geompy.MakeVertexWithRef(x_h_p_t, 0, 0, -h) -#geompy.addToStudy(x_b_p_t, "x_b_p_t") - - - -#Edge_haut_droite = geompy.GetEdgesByLength(Face_haut, 0.136, 0.137) - -#u_h_g = geompy.MakeVertexOnCurve(Edge_haut_droite, 1) -#geompy.addToStudy(u_h_g, "u_h_g") - -#u_b_g = geompy.MakeVertexWithRef(u_h_g, 0, 0, -h) -#geompy.addToStudy(u_b_g, "u_b_g") - -#x_h_p = geompy.MakeVertexOnCurve(Edge_haut_droite, 0) -#geompy.addToStudy(x_h_p, "x_h_p") -#x_b_p = geompy.MakeVertexWithRef(x_h_p, 0, 0, -h) -#geompy.addToStudy(x_b_p, "x_b_p") - - -#Edge_haut_gauche = geompy.GetEdgesByLength(Face_haut, 0.131, 0.132) - -#w_h_g = geompy.MakeVertexOnCurve(Edge_haut_gauche, 0) -#geompy.addToStudy(w_h_g, "w_h_g") - -#w_b_g = geompy.MakeVertexWithRef(w_h_g, 0, 0, -h) -#geompy.addToStudy(w_b_g, "w_b_g") - -#z_h_p = geompy.MakeVertexOnCurve(Edge_haut_gauche, 1) -#geompy.addToStudy(z_h_p, "z_h_p") -#z_b_p = geompy.MakeVertexWithRef(z_h_p, 0, 0, -h) -#geompy.addToStudy(z_b_p, "z_b_p") - -#Edge_v_grd = geompy.MakeLineTwoPnt(u_h_g, w_h_g) - -#v_h_g = geompy.MakeVertexOnCurve(Edge_v_grd, 0.5) -#geompy.addToStudy(v_h_g, "v_h_g") -#v_b_g = geompy.MakeVertexWithRef(v_h_g, 0, 0, -h) -#geompy.addToStudy(v_b_g, "v_b_g") - - -#Edge_v_pte = geompy.MakeLineTwoPnt(x_h_p, z_h_p) - -#y_h_p = geompy.MakeVertexOnCurve(Edge_v_pte, 0.5) -#geompy.addToStudy(y_h_p, "y_h_p") -#y_b_p = geompy.MakeVertexWithRef(y_h_p, 0, 0, -h) -#geompy.addToStudy(y_b_p, "y_b_p") - - -##======================= -## CREATION ASSOCIATION -##======================= - -##=========================================== -## association des sommets de la face du haut -##=========================================== - -## grand trou - -#x_mod_h_g.setAssociation( x_h_g ) -#y_mod_h_g.setAssociation( y_h_g ) -#z_mod_h_g.setAssociation( z_h_g ) -#u_mod_h_g.setAssociation( u_h_g ) -#v_mod_h_g.setAssociation( v_h_g ) -#w_mod_h_g.setAssociation( w_h_g ) - -#x_mod_h_g_t.setAssociation( x_h_g_t ) -#y_mod_h_g_t.setAssociation( y_h_g_t ) -#z_mod_h_g_t.setAssociation( z_h_g_t ) -#u_mod_h_g_t.setAssociation( u_h_g_t ) -#v_mod_h_g_t.setAssociation( v_h_g_t ) -#w_mod_h_g_t.setAssociation( w_h_g_t ) - -## petit trou - -#x_mod_h_p.setAssociation( x_h_p ) -#y_mod_h_p.setAssociation( y_h_p ) -#z_mod_h_p.setAssociation( z_h_p ) -#u_mod_h_p.setAssociation( u_h_p ) -#v_mod_h_p.setAssociation( v_h_p ) -#w_mod_h_p.setAssociation( w_h_p ) - -#x_mod_h_p_t.setAssociation( x_h_p_t ) -#y_mod_h_p_t.setAssociation( y_h_p_t ) -#z_mod_h_p_t.setAssociation( z_h_p_t ) -#u_mod_h_p_t.setAssociation( u_h_p_t ) -#v_mod_h_p_t.setAssociation( v_h_p_t ) -#w_mod_h_p_t.setAssociation( w_h_p_t ) - - -##=========================================== -## association des sommets de la face du bas -##=========================================== - -## grand trou - -#x_mod_b_g.setAssociation( x_b_g ) -#y_mod_b_g.setAssociation( y_b_g ) -#z_mod_b_g.setAssociation( z_b_g ) -#u_mod_b_g.setAssociation( u_b_g ) -#v_mod_b_g.setAssociation( v_b_g ) -#w_mod_b_g.setAssociation( w_b_g ) - -#x_mod_b_g_t.setAssociation( x_b_g_t ) -#y_mod_b_g_t.setAssociation( y_b_g_t ) -#z_mod_b_g_t.setAssociation( z_b_g_t ) -#u_mod_b_g_t.setAssociation( u_b_g_t ) -#v_mod_b_g_t.setAssociation( v_b_g_t ) -#w_mod_b_g_t.setAssociation( w_b_g_t ) - -## petit trou - -#x_mod_b_p.setAssociation( x_b_p ) -#y_mod_b_p.setAssociation( y_b_p ) -#z_mod_b_p.setAssociation( z_b_p ) -#u_mod_b_p.setAssociation( u_b_p ) -#v_mod_b_p.setAssociation( v_b_p ) -#w_mod_b_p.setAssociation( w_b_p ) - -#x_mod_b_p_t.setAssociation( x_b_p_t ) -#y_mod_b_p_t.setAssociation( y_b_p_t ) -#z_mod_b_p_t.setAssociation( z_b_p_t ) -#u_mod_b_p_t.setAssociation( u_b_p_t ) -#v_mod_b_p_t.setAssociation( v_b_p_t ) -#w_mod_b_p_t.setAssociation( w_b_p_t ) - - - - -##================================= -## Creation association des edges -##================================= - - -#All_Edges_Bielle = geompy.SubShapeAllSorted(Bielle_geom, geompy.ShapeType["EDGE"]) - -### recuperer les arrondies du haut de la geometrie - -#Edge_Arr_grd_g_h = All_Edges_Bielle[20] -#geompy.addToStudy( Edge_Arr_grd_g_h , "Edge_Arr_grd_g_h" ) - -#Edge_Arr_grd_g_h_mod = grille_cyl_grd.getEdgeJ( 1 , 1 , 1 ) -#Edge_Arr_grd_g_h_mod.addAssociation( Edge_Arr_grd_g_h, 0., 1. ) - - -#Edge_Arr_grd_d_h = All_Edges_Bielle[22] -#geompy.addToStudy( Edge_Arr_grd_d_h , "Edge_Arr_grd_d_h" ) - -#Edge_Arr_grd_d_h_mod = grille_cyl_grd.getEdgeJ( 1 , 4 , 1 ) -#Edge_Arr_grd_d_h_mod.addAssociation( Edge_Arr_grd_d_h, 0., 1. ) - - -#Edge_Arr_pte_g_h = All_Edges_Bielle[8] -#geompy.addToStudy( Edge_Arr_pte_g_h , "Edge_Arr_pte_g_h" ) - -#Edge_Arr_pte_g_h_mod = grille_cyl_pte.getEdgeJ( 1 , 1 , 1 ) -#Edge_Arr_pte_g_h_mod.addAssociation( Edge_Arr_pte_g_h, 0., 1. ) - -#Edge_Arr_pte_d_h = All_Edges_Bielle[10] -#geompy.addToStudy( Edge_Arr_pte_d_h , "Edge_Arr_pte_d_h" ) - -#Edge_Arr_pte_d_h_mod = grille_cyl_pte.getEdgeJ( 1 , 4 , 1 ) -#Edge_Arr_pte_d_h_mod.addAssociation( Edge_Arr_pte_d_h, 0., 1. ) - -## recuperer les arrondies du bas de la geometrie - -#Edge_Arr_grd_g_b = All_Edges_Bielle[19] -#geompy.addToStudy( Edge_Arr_grd_g_b , "Edge_Arr_grd_g_b" ) - -#Edge_Arr_grd_g_b_mod = grille_cyl_grd.getEdgeJ( 1 , 1 , 0 ) -#Edge_Arr_grd_g_b_mod.addAssociation( Edge_Arr_grd_g_b, 0., 1. ) - -#Edge_Arr_grd_d_b = All_Edges_Bielle[21] -#geompy.addToStudy( Edge_Arr_grd_d_b , "Edge_Arr_grd_d_b" ) - -#Edge_Arr_grd_d_b_mod = grille_cyl_grd.getEdgeJ( 1 , 4 , 0 ) -#Edge_Arr_grd_d_b_mod.addAssociation( Edge_Arr_grd_d_b, 0., 1. ) - -#Edge_Arr_pte_g_b = All_Edges_Bielle[7] -#geompy.addToStudy( Edge_Arr_pte_g_b , "Edge_Arr_pte_g_b" ) - -#Edge_Arr_pte_g_b_mod = grille_cyl_pte.getEdgeJ( 1 , 1 , 0 ) -#Edge_Arr_pte_g_b_mod.addAssociation( Edge_Arr_pte_g_b, 0., 1. ) - -#Edge_Arr_pte_d_b = All_Edges_Bielle[9] -#geompy.addToStudy( Edge_Arr_pte_d_b , "Edge_Arr_pte_d_b" ) - -#Edge_Arr_pte_d_b_mod = grille_cyl_pte.getEdgeJ( 1 , 4 , 0 ) -#Edge_Arr_pte_d_b_mod.addAssociation( Edge_Arr_pte_d_b, 0., 1. ) - - -## recuperer les grand rayons de la geometrie - -#Edge_Ray_grd_g_h = All_Edges_Bielle[28] -#geompy.addToStudy( Edge_Ray_grd_g_h , "Edge_Ray_grd_g_h" ) -#Edge_Ray_grd_d_h = All_Edges_Bielle[1] -#geompy.addToStudy( Edge_Ray_grd_d_h , "Edge_Ray_grd_d_h" ) - -#Edge_Ray_grd_g_b = All_Edges_Bielle[27] -#geompy.addToStudy( Edge_Ray_grd_g_b , "Edge_Ray_grd_g_b" ) -#Edge_Ray_grd_d_b = All_Edges_Bielle[0] -#geompy.addToStudy( Edge_Ray_grd_d_b , "Edge_Ray_grd_d_b" ) - - - -#X_pln1 = geompy.MakeVertex( 0 , 0 , 0 ) -#Vec_X = geompy.MakeVectorDXDYDZ( 0 , 1 , 0 ) -#Plan1 = geompy.MakePlane( X_pln1 , Vec_X , 200 ) - -#Parti_Grd_Ray = geompy.MakePartition([ Edge_Ray_grd_g_h , Edge_Ray_grd_d_h , Edge_Ray_grd_g_b , Edge_Ray_grd_d_b ], [ Plan1 ], [], [], geompy.ShapeType["EDGE"], 0, [], 0) -#geompy.addToStudy( Parti_Grd_Ray , "Parti_Grd_Ray" ) - - -#All_Edges_Parti_Grd_Ray = geompy.SubShapeAllSorted(Parti_Grd_Ray, geompy.ShapeType["EDGE"]) - - -#Grd_Ray_0 = All_Edges_Parti_Grd_Ray[0] -#geompy.addToStudy( Grd_Ray_0 , "Grd_Ray_0" ) - -###Edge_Arr_grd_g_h_mod = grille_cyl_pte.getEdgeJ( 1 , 2 , 0 ) -#Edge_Grd_Ray_0_mod = grille_cyl_pte.getEdgeJ( 1 , 0 , 0 ) -#Edge_Grd_Ray_0_mod.addAssociation( Grd_Ray_0, 0., 1. ) - - -#Grd_Ray_1 = All_Edges_Parti_Grd_Ray[1] -#geompy.addToStudy( Grd_Ray_1 , "Grd_Ray_1" ) - -###Edge_Grd_Ray_1_mod = grille_cyl_pte.getEdgeJ( 1 , 2 , 1 ) -#Edge_Grd_Ray_1_mod = grille_cyl_pte.getEdgeJ( 1 , 0 , 1 ) -#Edge_Grd_Ray_1_mod.addAssociation( Grd_Ray_1, 0., 1. ) - -#Grd_Ray_2 = All_Edges_Parti_Grd_Ray[2] -#geompy.addToStudy( Grd_Ray_2 , "Grd_Ray_2" ) - -###Edge_Grd_Ray_2_mod = grille_cyl_pte.getEdgeJ( 1 , 3 , 0 ) -#Edge_Grd_Ray_2_mod = grille_cyl_pte.getEdgeJ( 1 , 5 , 0 ) -#Edge_Grd_Ray_2_mod.addAssociation( Grd_Ray_2, 0., 1. ) - -#Grd_Ray_3 = All_Edges_Parti_Grd_Ray[3] -#geompy.addToStudy( Grd_Ray_3 , "Grd_Ray_3" ) - -###Edge_Grd_Ray_3_mod = grille_cyl_pte.getEdgeJ( 1 , 3 , 1 ) -#Edge_Grd_Ray_3_mod = grille_cyl_pte.getEdgeJ( 1 , 5 , 1 ) -#Edge_Grd_Ray_3_mod.addAssociation( Grd_Ray_3, 0., 1. ) - -#Grd_Ray_4 = All_Edges_Parti_Grd_Ray[4] -#geompy.addToStudy( Grd_Ray_4 , "Grd_Ray_4" ) - -#Edge_Grd_Ray_4_mod = grille_cyl_grd.getEdgeJ( 1 , 2 , 0 ) -#Edge_Grd_Ray_4_mod.addAssociation( Grd_Ray_4, 0., 1. ) -##Edge_Grd_Ray_4_mod.addAssociation( Edge_Ray_grd_g_b , 0., 1. ) - - -#Grd_Ray_5 = All_Edges_Parti_Grd_Ray[5] -#geompy.addToStudy( Grd_Ray_5 , "Grd_Ray_5" ) - -#Edge_Grd_Ray_5_mod = grille_cyl_grd.getEdgeJ( 1 , 2 , 1 ) -#Edge_Grd_Ray_5_mod.addAssociation( Grd_Ray_5, 0., 1. ) - -#Grd_Ray_6 = All_Edges_Parti_Grd_Ray[6] -#geompy.addToStudy( Grd_Ray_6 , "Grd_Ray_6" ) - -#Edge_Grd_Ray_6_mod = grille_cyl_grd.getEdgeJ( 1 , 3 , 0 ) -#Edge_Grd_Ray_6_mod.addAssociation( Grd_Ray_6, 0., 1. ) - -#Grd_Ray_7 = All_Edges_Parti_Grd_Ray[7] -#geompy.addToStudy( Grd_Ray_7 , "Grd_Ray_7" ) - -#Edge_Arr_grd_g_h_mod = grille_cyl_grd.getEdgeJ( 1 , 3 , 1 ) -#Edge_Arr_grd_g_h_mod.addAssociation( Grd_Ray_7, 0., 1. ) - - -## recuperer les rayons des trous de la bielle de la geometrie - -#Edge_Trou_grd_h = All_Edges_Bielle[26] -#geompy.addToStudy( Edge_Trou_grd_h , "Edge_Trou_grd_h" ) - -#Edge_Trou_grd_b = All_Edges_Bielle[25] -#geompy.addToStudy( Edge_Trou_grd_b , "Edge_Trou_grd_b" ) - -#Edge_Trou_pte_h = All_Edges_Bielle[3] -#geompy.addToStudy( Edge_Trou_pte_h , "Edge_Trou_pte_h" ) - -#Edge_Trou_pte_b = All_Edges_Bielle[2] -#geompy.addToStudy( Edge_Trou_pte_b , "Edge_Trou_pte_b" ) - -#Partition_Trou_grd_haut = geompy.MakePartition([ Edge_Trou_grd_h ], [ z_h_g_t , w_h_g_t , v_h_g_t , u_h_g_t , x_h_g_t ], [], [], geompy.ShapeType["EDGE"], 0, [], 0) -#geompy.addToStudy( Partition_Trou_grd_haut , "Partition_Trou_grd_haut" ) - -#All_Edge_Partition_Trou_grd_haut = geompy.SubShapeAllSorted(Partition_Trou_grd_haut, geompy.ShapeType["EDGE"]) - -#Edge_Trou_grd_h_0 = All_Edge_Partition_Trou_grd_haut[0] -#geompy.addToStudy( Edge_Trou_grd_h_0 , "Edge_Trou_grd_h_0" ) - -#Edge_Trou_grd_h_0_mod = grille_cyl_grd.getEdgeJ( 0 , 0 , 1 ) -#Edge_Trou_grd_h_0_mod.addAssociation( Edge_Trou_grd_h_0, 0., 1. ) - -#Edge_Trou_grd_h_2 = All_Edge_Partition_Trou_grd_haut[2] -#geompy.addToStudy( Edge_Trou_grd_h_2 , "Edge_Trou_grd_h_2" ) - -#Edge_Trou_grd_h_2_mod = grille_cyl_grd.getEdgeJ( 0 , 1 , 1 ) -#Edge_Trou_grd_h_2_mod.addAssociation( Edge_Trou_grd_h_2, 0., 1. ) - -#Edge_Trou_grd_h_4 = All_Edge_Partition_Trou_grd_haut[4] -#geompy.addToStudy( Edge_Trou_grd_h_4 , "Edge_Trou_grd_h_4" ) - -#Edge_Trou_grd_h_4_mod = grille_cyl_grd.getEdgeJ( 0 , 2 , 1 ) -#Edge_Trou_grd_h_4_mod.addAssociation( Edge_Trou_grd_h_4, 0., 1. ) - -#Edge_Trou_grd_h_5 = All_Edge_Partition_Trou_grd_haut[5] -#geompy.addToStudy( Edge_Trou_grd_h_5 , "Edge_Trou_grd_h_5" ) - -#Edge_Trou_grd_h_5_mod = grille_cyl_grd.getEdgeJ( 0 , 3 , 1 ) -#Edge_Trou_grd_h_5_mod.addAssociation( Edge_Trou_grd_h_5, 0., 1. ) - -#Edge_Trou_grd_h_3 = All_Edge_Partition_Trou_grd_haut[3] -#geompy.addToStudy( Edge_Trou_grd_h_3 , "Edge_Trou_grd_h_3" ) - -#Edge_Trou_grd_h_3_mod = grille_cyl_grd.getEdgeJ( 0 , 4 , 1 ) -#Edge_Trou_grd_h_3_mod.addAssociation( Edge_Trou_grd_h_3, 0., 1. ) - -#Edge_Trou_grd_h_1 = All_Edge_Partition_Trou_grd_haut[1] -#geompy.addToStudy( Edge_Trou_grd_h_1 , "Edge_Trou_grd_h_1" ) - -#Edge_Trou_grd_h_1_mod = grille_cyl_grd.getEdgeJ( 0 , 5 , 1 ) -#Edge_Trou_grd_h_1_mod.addAssociation( Edge_Trou_grd_h_1, 0., 1. ) - - - -#Partition_Trou_grd_bas = geompy.MakePartition([ Edge_Trou_grd_b ], [ z_b_g_t , w_b_g_t , v_b_g_t , u_b_g_t , x_b_g_t ], [], [], geompy.ShapeType["EDGE"], 0, [], 0) -#geompy.addToStudy( Partition_Trou_grd_bas , "Partition_Trou_grd_bas" ) - - -#All_Edge_Partition_Trou_grd_bas = geompy.SubShapeAllSorted(Partition_Trou_grd_bas, geompy.ShapeType["EDGE"]) - -#Edge_Trou_grd_b_0 = All_Edge_Partition_Trou_grd_bas[0] -#geompy.addToStudy( Edge_Trou_grd_b_0 , "Edge_Trou_grd_b_0" ) - -#Edge_Trou_grd_b_0_mod = grille_cyl_grd.getEdgeJ( 0 , 0 , 0 ) -#Edge_Trou_grd_b_0_mod.addAssociation( Edge_Trou_grd_b_0, 0., 1. ) - -#Edge_Trou_grd_b_2 = All_Edge_Partition_Trou_grd_bas[2] -#geompy.addToStudy( Edge_Trou_grd_b_2 , "Edge_Trou_grd_b_2" ) - -#Edge_Trou_grd_b_2_mod = grille_cyl_grd.getEdgeJ( 0 , 1 , 0 ) -#Edge_Trou_grd_b_2_mod.addAssociation( Edge_Trou_grd_b_2, 0., 1. ) - -#Edge_Trou_grd_b_4 = All_Edge_Partition_Trou_grd_bas[4] -#geompy.addToStudy( Edge_Trou_grd_b_4 , "Edge_Trou_grd_b_4" ) - -#Edge_Trou_grd_b_4_mod = grille_cyl_grd.getEdgeJ( 0 , 2 , 0 ) -#Edge_Trou_grd_b_4_mod.addAssociation( Edge_Trou_grd_b_4, 0., 1. ) - -#Edge_Trou_grd_b_5 = All_Edge_Partition_Trou_grd_bas[5] -#geompy.addToStudy( Edge_Trou_grd_b_5 , "Edge_Trou_grd_b_5" ) - -#Edge_Trou_grd_b_5_mod = grille_cyl_grd.getEdgeJ( 0 , 3 , 0 ) -#Edge_Trou_grd_b_5_mod.addAssociation( Edge_Trou_grd_b_5, 0., 1. ) - -#Edge_Trou_grd_b_3 = All_Edge_Partition_Trou_grd_bas[3] -#geompy.addToStudy( Edge_Trou_grd_b_3 , "Edge_Trou_grd_b_3" ) - -#Edge_Trou_grd_b_3_mod = grille_cyl_grd.getEdgeJ( 0 , 4 , 0 ) -#Edge_Trou_grd_b_3_mod.addAssociation( Edge_Trou_grd_b_3, 0., 1. ) - -#Edge_Trou_grd_b_1 = All_Edge_Partition_Trou_grd_bas[1] -#geompy.addToStudy( Edge_Trou_grd_b_1 , "Edge_Trou_grd_b_1" ) - -#Edge_Trou_grd_b_1_mod = grille_cyl_grd.getEdgeJ( 0 , 5 , 0 ) -#Edge_Trou_grd_b_1_mod.addAssociation( Edge_Trou_grd_b_1, 0., 1. ) - - - - - -#Partition_Trou_pte_haut = geompy.MakePartition([ Edge_Trou_pte_h ], [ z_h_p_t , w_h_p_t , v_h_p_t , u_h_p_t , x_h_p_t ], [], [], geompy.ShapeType["EDGE"], 0, [], 0) -#geompy.addToStudy( Partition_Trou_pte_haut , "Partition_Trou_pte_haut" ) - - -#All_Edge_Partition_Trou_pte_haut = geompy.SubShapeAllSorted(Partition_Trou_pte_haut, geompy.ShapeType["EDGE"]) - -#Edge_Trou_pte_h_0 = All_Edge_Partition_Trou_pte_haut[0] -#geompy.addToStudy( Edge_Trou_pte_h_0 , "Edge_Trou_pte_h_0" ) - -#Edge_Trou_pte_h_0_mod = grille_cyl_pte.getEdgeJ( 0 , 0 , 1 ) -#Edge_Trou_pte_h_0_mod.addAssociation( Edge_Trou_pte_h_0, 0., 1. ) - -#Edge_Trou_pte_h_2 = All_Edge_Partition_Trou_pte_haut[2] -#geompy.addToStudy( Edge_Trou_pte_h_2 , "Edge_Trou_pte_h_2" ) - -#Edge_Trou_pte_h_2_mod = grille_cyl_pte.getEdgeJ( 0 , 1 , 1 ) -#Edge_Trou_pte_h_2_mod.addAssociation( Edge_Trou_pte_h_2, 0., 1. ) - -#Edge_Trou_pte_h_4 = All_Edge_Partition_Trou_pte_haut[4] -#geompy.addToStudy( Edge_Trou_pte_h_4 , "Edge_Trou_pte_h_4" ) - -#Edge_Trou_pte_h_4_mod = grille_cyl_pte.getEdgeJ( 0 , 2 , 1 ) -#Edge_Trou_pte_h_4_mod.addAssociation( Edge_Trou_pte_h_4, 0., 1. ) - -#Edge_Trou_pte_h_5 = All_Edge_Partition_Trou_pte_haut[5] -#geompy.addToStudy( Edge_Trou_pte_h_5 , "Edge_Trou_pte_h_5" ) - -#Edge_Trou_pte_h_5_mod = grille_cyl_pte.getEdgeJ( 0 , 3 , 1 ) -#Edge_Trou_pte_h_5_mod.addAssociation( Edge_Trou_pte_h_5, 0., 1. ) - -#Edge_Trou_pte_h_3 = All_Edge_Partition_Trou_pte_haut[3] -#geompy.addToStudy( Edge_Trou_pte_h_3 , "Edge_Trou_pte_h_3" ) - -#Edge_Trou_pte_h_3_mod = grille_cyl_pte.getEdgeJ( 0 , 4 , 1 ) -#Edge_Trou_pte_h_3_mod.addAssociation( Edge_Trou_pte_h_3, 0., 1. ) - -#Edge_Trou_pte_h_1 = All_Edge_Partition_Trou_pte_haut[1] -#geompy.addToStudy( Edge_Trou_pte_h_1 , "Edge_Trou_pte_h_1" ) - -#Edge_Trou_pte_h_1_mod = grille_cyl_pte.getEdgeJ( 0 , 5 , 1 ) -#Edge_Trou_pte_h_1_mod.addAssociation( Edge_Trou_pte_h_1, 0., 1. ) - - - - -#Partition_Trou_pte_bas = geompy.MakePartition([ Edge_Trou_pte_b ], [ z_b_p_t , w_b_p_t , v_b_p_t , u_b_p_t , x_b_p_t ], [], [], geompy.ShapeType["EDGE"], 0, [], 0) -#geompy.addToStudy( Partition_Trou_pte_bas , "Partition_Trou_pte_bas" ) - - -#All_Edge_Partition_Trou_pte_bas = geompy.SubShapeAllSorted(Partition_Trou_pte_bas, geompy.ShapeType["EDGE"]) - -#Edge_Trou_pte_b_0 = All_Edge_Partition_Trou_pte_bas[0] -#geompy.addToStudy( Edge_Trou_pte_b_0 , "Edge_Trou_pte_b_0" ) - -#Edge_Trou_pte_b_0_mod = grille_cyl_pte.getEdgeJ( 0 , 0 , 0 ) -#Edge_Trou_pte_b_0_mod.addAssociation( Edge_Trou_pte_b_0, 0., 1. ) - -#Edge_Trou_pte_b_2 = All_Edge_Partition_Trou_pte_bas[2] -#geompy.addToStudy( Edge_Trou_pte_b_2 , "Edge_Trou_pte_b_2" ) - -#Edge_Trou_pte_b_2_mod = grille_cyl_pte.getEdgeJ( 0 , 1 , 0 ) -#Edge_Trou_pte_b_2_mod.addAssociation( Edge_Trou_pte_b_2, 0., 1. ) - -#Edge_Trou_pte_b_4 = All_Edge_Partition_Trou_pte_bas[4] -#geompy.addToStudy( Edge_Trou_pte_b_4 , "Edge_Trou_pte_b_4" ) - -#Edge_Trou_pte_b_4_mod = grille_cyl_pte.getEdgeJ( 0 , 2 , 0 ) -#Edge_Trou_pte_b_4_mod.addAssociation( Edge_Trou_pte_b_4, 0., 1. ) - -#Edge_Trou_pte_b_5 = All_Edge_Partition_Trou_pte_bas[5] -#geompy.addToStudy( Edge_Trou_pte_b_5 , "Edge_Trou_pte_b_5" ) - -#Edge_Trou_pte_b_5_mod = grille_cyl_pte.getEdgeJ( 0 , 3 , 0 ) -#Edge_Trou_pte_b_5_mod.addAssociation( Edge_Trou_pte_b_5, 0., 1. ) - -#Edge_Trou_pte_b_3 = All_Edge_Partition_Trou_pte_bas[3] -#geompy.addToStudy( Edge_Trou_pte_b_3 , "Edge_Trou_pte_b_3" ) - -#Edge_Trou_pte_b_3_mod = grille_cyl_pte.getEdgeJ( 0 , 4 , 0 ) -#Edge_Trou_pte_b_3_mod.addAssociation( Edge_Trou_pte_b_3, 0., 1. ) - -#Edge_Trou_pte_b_1 = All_Edge_Partition_Trou_pte_bas[1] -#geompy.addToStudy( Edge_Trou_pte_b_1 , "Edge_Trou_pte_b_1" ) - -#Edge_Trou_pte_b_1_mod = grille_cyl_pte.getEdgeJ( 0 , 5 , 0 ) -#Edge_Trou_pte_b_1_mod.addAssociation( Edge_Trou_pte_b_1, 0., 1. ) - -##==================================== -## CREATION DES FACES DES ARRONDIES -##==================================== - -#All_Face_Arron_Bielle = geompy.SubShapeAllSorted(Bielle_geom, geompy.ShapeType["FACE"]) - -#Face_Arron_1 = All_Face_Arron_Bielle[2] -#geompy.addToStudy(Face_Arron_1, "Face_Arron_1") - -#Quad_Arron_1 = grille_cyl_pte.getQuadJK( 1 , 1 , 0 ) - -#Face_Arron_2 = All_Face_Arron_Bielle[3] -#geompy.addToStudy(Face_Arron_2, "Face_Arron_2") - -#Quad_Arron_2 = grille_cyl_pte.getQuadJK( 1 , 4 , 0 ) - -#Face_Arron_3 = All_Face_Arron_Bielle[8] -#geompy.addToStudy(Face_Arron_3, "Face_Arron_3") - -#Quad_Arron_3 = grille_cyl_grd.getQuadJK( 1 , 1 , 0 ) - -#Face_Arron_4 = All_Face_Arron_Bielle[9] -#geompy.addToStudy(Face_Arron_4, "Face_Arron_4") - -#Quad_Arron_4 = grille_cyl_grd.getQuadJK( 1 , 4 , 0 ) - - - - - - -#==================================== -# CREATION MAILLAGE -#==================================== - - -#================================================= -# Definir les groupes d elements pour le maillage -#================================================= - -# On definit 3 groupes de mailles - -# groupe d edges (arretes) - -Edge_grp = doc.addEdgeGroup("Edge_grp") -Nbr_Edg = doc.countEdge() -#print Nbr_Edg -for i in range(Nbr_Edg): - Edge_i = doc.getEdge(i) - Edge_grp.addElement(Edge_i) - - -# groupe de quads (faces) -Quad_grp = doc.addQuadGroup("Quad_grp") -Nbr_Qad = doc.countQuad() -#print Nbr_Qad -for i in range(Nbr_Qad): - Quad_i = doc.getQuad(i) - Quad_grp.addElement(Quad_i) - -# groupe d hexas (solids) -Hexa_grp = doc.addHexaGroup("Hexa_grp") -Nbr_Hex = doc.countHexa() -#print Nbr_Hex -for i in range(Nbr_Hex): - Hexa_i = doc.getHexa(i) - Hexa_grp.addElement(Hexa_i) - - - -# groupe de noeuds de vertex pour tout le modele -Vertex_Nod_Grp = doc.addVertexNodeGroup("Vertex_Nod_Grp") -Nbr_Vx = doc.countVertex() -#print Nbr_Vx -for i in range(Nbr_Vx): - Vertex_i = doc.getVertex(i) - Vertex_Nod_Grp.addElement(Vertex_i) - - -#==================================== -# Definir une loi de discretisation -#==================================== -# definir une loi: le choix de la loi reste aux utilisateurs -Law = doc.addLaw( "Uniform" , 4 ) - -#n = doc.countLaw() -#print n - -# chercher les propagations du modele -N_Propa = doc.countPropagation() - -for j in range(N_Propa): - Propa = doc.getPropagation(j) - Propa.setLaw( Law )# appliquer la loi de discretisation sur tout le modele et generer le maillage - -mesh = hexablock.mesh(doc, "test_BIELLE_no_assoc") - -print " --- MAILLAGE HEXAHEDRIQUE --- " -print "Nombre d hexaedres:" , mesh.NbHexas() -print "Nombre de quadrangles:", mesh.NbQuadrangles() -print "Nombre de segments:" , mesh.NbEdges() -print "Nombre de noeuds:" , mesh.NbNodes() diff --git a/src/TEST_PY/test_HEXABLOCK.py b/src/TEST_PY/test_HEXABLOCK.py deleted file mode 100755 index e53d07d..0000000 --- a/src/TEST_PY/test_HEXABLOCK.py +++ /dev/null @@ -1,418 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import hexablock - - -# ======================================================== test_sphere -def test_sphere (): - doc = hexablock.addDocument ("default") - orig = doc.addVertex (0,0,0) - - ncouches = 1 - k = 0.8 - decal = doc.addVector (1,1,1) - sphere = doc.makeSpherical (orig, decal, ncouches, k) - - for nc in range(ncouches): - cell = sphere.getStrate (nc, Q_A) - cell.remove () - - sphere.saveVtk ("sphere.vtk") - print "test_sphere OK" - -# ======================================================== test_cartesi1 -def test_cartesi1 (): - size_x = 15 - size_y = 12 - size_z = 8 - - doc = hexablock.addDocument () - orig = doc.addVertex (0,0,0) - - dirVr = doc.addVector (1,1,1) - grid = doc.makeCartesian1 (orig, dirVr, size_x,size_y,size_z, 0, 0, 0 ) #CS_NOT_SPEC (makeCartesian1) - - #for (int nz=0 nz",j - #print "ok ->",ok - - -## -------------------- -## Maillage hexa�drique -## -------------------- -#mesh = mesh.ExportMED( "3cyl.med", 1 ) -#maillages = smesh.CreateMeshesFromMED( "3cyl.med" ) - -#ijk = maillages[0][0] - -#ijk.Hexahedron() - -#ijk.Compute() - -#print 4*" -- ijk --- " -#print "Nombre d hexaedres:", ijk.NbHexas() -#print "Nombre de quadrangles:", ijk.NbQuadrangles() -#print "Nombre de segments:", ijk.NbEdges() -#print "Nombre de noeuds:", ijk.NbNodes() - - - - - - - - - - - diff --git a/src/TEST_PY/test_TUYAU_COURBE_no_assoc.py b/src/TEST_PY/test_TUYAU_COURBE_no_assoc.py deleted file mode 100755 index b326461..0000000 --- a/src/TEST_PY/test_TUYAU_COURBE_no_assoc.py +++ /dev/null @@ -1,466 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -#=============================================== -# By Karima DEBCHI YATAGHENE Nov 2009 at CS -#=============================================== - -import os -#import GEOM -import geompy -import smesh -import hexablock -import math -#import SALOMEDS - - -BREP_PATH = os.path.expandvars("$HEXABLOCK_ROOT_DIR/bin/salome/tuyau.brep") - -#============================= -# CREATION DOCUMENT -#============================= - -doc = hexablock.addDocument ("default") - -#============================= -# CREATION DU MODELE -#============================= - -# Pour le tuyau on doit creer une grille cylindrique - -#============================= -# PARAMETRES -#============================= - -R = 4.5 - -r = 4.5 -r_t = 3.6 - -h = 75.0 - -# Taille du cylindre -dr = R -da = 360 -dl = h - -nr = 1 -na = 4 -nl = 1 - - -#============================= -# Creation des vecteurs -#============================= - -dx = doc.addVector(h, 0, 0) -dy = doc.addVector(0, h, 0) -dz = doc.addVector(0, 0, h) - - -#================================================= -# Creation du centre de la grille cylindrique -#================================================= - -c = doc.addVertex(0, 0, 0) - -#================================================= -# Creation de la grille cylindrique -#================================================= - -grille_cyl = doc.makeCylindrical(c, dx, dz, dr, da, dl, nr, na, nl, False) - -# on obtient une liste qui contient 4 hexaedres eguaux - -# 30� = pi/6 -# 60� = pi/3 -# 45� = pi/4 -# 90� = pi/2 -# 180� = pi - - -#================================================= -# Model tuyau final -#================================================= - -model_tuyau_fin = grille_cyl - - -#model_tuyau_fin.saveVtk("/tmp/tuyau.vtk") -#grille_cyl.saveVtk("/tmp/grille_cyl.vtk") - - - -#=================================================================== -# Recuperation des vertex du model hexa tuyau pour l'association -#=================================================================== - -## NB: -## h = haut -## b = bas -## g = grand -## p = petit -## t = trou - - -# Face du haut grand rayon - -x_mod_h = doc.findVertex( 2*R , 0 , h ) -y_mod_h = doc.findVertex( 0 , 2*R , h ) -z_mod_h = doc.findVertex( -2*R , 0 , h ) -u_mod_h = doc.findVertex( 0 , -2*R , h ) - -# Face du haut petit rayon - -x_mod_h_t = doc.findVertex( R , 0 , h ) -y_mod_h_t = doc.findVertex( 0 , R , h ) -z_mod_h_t = doc.findVertex( -R , 0 , h ) -u_mod_h_t = doc.findVertex( 0 , -R , h ) - - -# Face du bas grand rayon - -x_mod_b = doc.findVertex( 2*R , 0 , 0 ) -y_mod_b = doc.findVertex( 0 , 2*R , 0 ) -z_mod_b = doc.findVertex( -2*R , 0 , 0 ) -u_mod_b = doc.findVertex( 0 , -2*R , 0 ) - -# Face du bas petit rayon - -x_mod_b_t = doc.findVertex( R , 0 , 0 ) -y_mod_b_t = doc.findVertex( 0 , R , 0 ) -z_mod_b_t = doc.findVertex( -R , 0 , 0 ) -u_mod_b_t = doc.findVertex( 0 , -R , 0 ) - - -#=================================================================== -# Recuperation des points de la geometrie tuyau pour l'association -#=================================================================== -Tuyau_geom = geompy.Import(BREP_PATH, "BREP") -geompy.addToStudy(Tuyau_geom, "Tuyau_geom") - - -Pt_A = geompy.MakeVertex( h , 20 , 4.5 ) -Edge_haut_droite_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_A) - - -Pt_B = geompy.MakeVertex( h , 20 , 3.6 ) -Edge_haut_droite_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_B) - - -Pt_C = geompy.MakeVertex( h , 20 , -4.5 ) -Edge_haut_gauche_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_C) - - - -Pt_D = geompy.MakeVertex( h , 20 , -3.6 ) -Edge_haut_gauche_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_D) - - - -# NB: -# h = haut -# b = bas -# g = grand -# p = petit -# t = trou - -# Face tuyau du haut -x_h = geompy.MakeVertexOnCurve(Edge_haut_droite_grd, 0.5) -y_h = geompy.MakeVertexOnCurve(Edge_haut_droite_grd, 1) -z_h = geompy.MakeVertexOnCurve(Edge_haut_gauche_grd, 0.5) -u_h = geompy.MakeVertexOnCurve(Edge_haut_gauche_grd, 0) - - - -x_h_t = geompy.MakeVertexOnCurve(Edge_haut_droite_pte, 0.5) -y_h_t = geompy.MakeVertexOnCurve(Edge_haut_droite_pte, 1) -z_h_t = geompy.MakeVertexOnCurve(Edge_haut_gauche_pte, 0.5) -u_h_t = geompy.MakeVertexOnCurve(Edge_haut_gauche_pte, 0) - - - -Pt_E = geompy.MakeVertex( 0 , 0 , 2 ) -Edge_bas_droite_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_E) - - -Pt_F = geompy.MakeVertex( 0 , 0 , 1.6 ) -Edge_bas_droite_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_F) - - -Pt_G = geompy.MakeVertex( 0 , 0 , -2 ) -Edge_bas_gauche_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_G) - - - -Pt_H = geompy.MakeVertex( 0 , 0 , -1.6 ) -Edge_bas_gauche_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_H) - - - -# Face tuyau du bas -x_b = geompy.MakeVertexOnCurve(Edge_bas_droite_grd, 0.5) -y_b = geompy.MakeVertexOnCurve(Edge_bas_droite_grd, 1) -z_b = geompy.MakeVertexOnCurve(Edge_bas_gauche_grd, 0.5) -u_b = geompy.MakeVertexOnCurve(Edge_bas_gauche_grd, 0) - - - -x_b_t = geompy.MakeVertexOnCurve(Edge_bas_droite_pte, 0.5) -y_b_t = geompy.MakeVertexOnCurve(Edge_bas_droite_pte, 1) -z_b_t = geompy.MakeVertexOnCurve(Edge_bas_gauche_pte, 0.5) -u_b_t = geompy.MakeVertexOnCurve(Edge_bas_gauche_pte, 0) - - - - -bp_law = doc.getLaw(0) -bp_law.setNodes(4) - -#==================================== -# CREATION MAILLAGE -#==================================== -##================================================= -## Definir les groupes d'elements pour le maillage -##================================================= - -# groupe de Hexa(volumes) -Hexa_grp = doc.addHexaGroup("Hexa_all_grp") -Nbr_Hex = doc.countHexa() -print "doc.countHexa()->",Nbr_Hex - -for i in range(Nbr_Hex): - Hexa_i = doc.getHexa(i) - Hexa_grp.addElement(Hexa_i) - -#Nbr_elm_hex = Hexa_grp.countElement() -#print "Hexa_all_grp countElement() ->",Nbr_elm_hex - -for i in range(Nbr_Hex): - Hexa_grp = doc.addHexaGroup("Hexa_grp"+str(i)) - Hexa_i = doc.getHexa(i) - Hexa_grp.addElement(Hexa_i) - - -# groupe de quads (faces) -Quad_grp_haut = doc.addQuadGroup("Quad_grp_haut") - -Quad_h_1 = doc.findQuad( x_mod_h , y_mod_h_t ) -Quad_h_2 = doc.findQuad( y_mod_h_t , z_mod_h ) -Quad_h_3 = doc.findQuad( z_mod_h , u_mod_h_t ) -Quad_h_4 = doc.findQuad( u_mod_h_t , x_mod_h ) - -assert Quad_h_1 -assert Quad_h_2 -assert Quad_h_3 -assert Quad_h_4 - - -for Quad_h_i in [ Quad_h_1 , Quad_h_2 , Quad_h_3 , Quad_h_4 ]: - Quad_grp_haut.addElement(Quad_h_i) - - - -Nbr_elm_qad_haut = Quad_grp_haut.countElement() -print "Nbr_elm_qad_haut ->",Nbr_elm_qad_haut - - -Quad_grp_bas = doc.addQuadGroup("Quad_grp_bas") - -Quad_b_1 = doc.findQuad( x_mod_b , y_mod_b_t ) -Quad_b_2 = doc.findQuad( y_mod_b_t , z_mod_b ) -Quad_b_3 = doc.findQuad( z_mod_b , u_mod_b_t ) -Quad_b_4 = doc.findQuad( u_mod_b_t , x_mod_b ) - - -assert Quad_b_1 -assert Quad_b_2 -assert Quad_b_3 -assert Quad_b_4 - -for Quad_b_i in [ Quad_b_1 , Quad_b_2 , Quad_b_3 , Quad_b_4 ]: - Quad_grp_bas.addElement(Quad_b_i) - - -Nbr_elm_qad_bas = Quad_grp_bas.countElement() -print "Nbr_elm_qad_bas->",Nbr_elm_qad_bas - - -# groupe de Edges - -Edge_Mod_ext_h = doc.findEdge( y_mod_h , y_mod_b ) -Edge_Mod_int_h = doc.findEdge( y_mod_h_t , y_mod_b_t ) - -Edge_Mod_int_b = doc.findEdge( u_mod_h_t , u_mod_b_t ) -Edge_Mod_ext_b = doc.findEdge( u_mod_h , u_mod_b ) - -Edge_Mod_ext_g = doc.findEdge( x_mod_h , x_mod_b ) -Edge_Mod_int_g = doc.findEdge( x_mod_h_t , x_mod_b_t ) - -Edge_Mod_int_d = doc.findEdge( z_mod_h_t , z_mod_b_t ) -Edge_Mod_ext_d = doc.findEdge( z_mod_h , z_mod_b ) - - -Edge_Grp_haut = doc.addEdgeGroup("Edge_Grp_haut") -Edge_Grp_haut.addElement(Edge_Mod_ext_h) -Edge_Grp_haut.addElement(Edge_Mod_int_h) - -Edge_Grp_gauche = doc.addEdgeGroup("Edge_Grp_gauche") -Edge_Grp_gauche.addElement(Edge_Mod_ext_g) -Edge_Grp_gauche.addElement(Edge_Mod_int_g) - -Edge_Grp_bas = doc.addEdgeGroup("Edge_Grp_bas") -Edge_Grp_bas.addElement(Edge_Mod_int_b) -Edge_Grp_bas.addElement(Edge_Mod_ext_b) - -Edge_Grp_droit = doc.addEdgeGroup("Edge_Grp_droit") -Edge_Grp_droit.addElement(Edge_Mod_int_d) -Edge_Grp_droit.addElement(Edge_Mod_ext_d) - - - -# groupe de noeuds de Hexa -Hexa_Nod_Grp = doc.addHexaNodeGroup("Hexa_Nod_Grp") -for i in range(Nbr_Hex): - Hexa_i = doc.getHexa(i) - Hexa_Nod_Grp.addElement(Hexa_i) - - -# groupe de noeuds de Quad -Quad_Nod_Grp_h_1 = doc.addQuadNodeGroup("Quad_Nod_Grp_h_1") -Quad_Nod_Grp_h_1.addElement(Quad_h_1) - -Quad_Nod_Grp_b_1 = doc.addQuadNodeGroup("Quad_Nod_Grp_b_1") -Quad_Nod_Grp_b_1.addElement(Quad_b_1) - -# groupe de noeuds de Edge -Edge_Nod_Grp_b = doc.addEdgeNodeGroup("Edge_Nod_Grp_b") -Edge_Nod_Grp_b.addElement(Edge_Mod_int_b) -Edge_Nod_Grp_b.addElement(Edge_Mod_ext_b) - -Edge_Nod_Grp_h = doc.addEdgeNodeGroup("Edge_Nod_Grp_h") -Edge_Nod_Grp_h.addElement(Edge_Mod_int_d) -Edge_Nod_Grp_h.addElement(Edge_Mod_ext_d) - - - - -# groupe de noeuds de vertex pour tout le modele -Vertex_Nod_Grp = doc.addVertexNodeGroup("Vertex_Nod_Grp") - -Nbr_Vx = doc.countVertex() -print "doc.countVertex()->",Nbr_Vx - -for i in range(Nbr_Vx): - Vertex_i = doc.getVertex(i) - Vertex_Nod_Grp.addElement(Vertex_i) - - -Nbr_elm_vex = Vertex_Nod_Grp.countElement() - -if Nbr_elm_vex == Nbr_Vx: - print "Vertex node group OK (on group :%s on model : %s)"%(Nbr_elm_vex, Nbr_Vx) -else: - print "Vertex node group KO (on group :%s on model : %s)"%(Nbr_elm_vex, Nbr_Vx) - - -#==================================== -# Definir une loi de discretisation -#==================================== - - -# definir une loi: le choix de la loi reste aux utilisateurs - -#Law_X = doc.addLaw( "Uniform" , 4 ) -#Law_Y = doc.addLaw( "Arithmetic" , 2 ) -#Law_Z = doc.addLaw( "Geometric" , 3 ) - - -Law_X = doc.addLaw( "Arithmetic" , 5 ) -Law_X.setKind(hexablock.ARITHMETIC) -Law_X.setCoefficient(0.1) - -Law_Y = doc.addLaw( "Arithmetic" , 3 ) -Law_Y.setKind(hexablock.ARITHMETIC) -Law_Y.setCoefficient(0.1) - -#Law_Z = doc.addLaw( "Geometric" , 4 ) -Law_Z = doc.addLaw( "Arithmetic" , 5 ) -Law_Z.setKind(hexablock.ARITHMETIC) -Law_Z.setCoefficient(0.05) - - -# chercher les propagations du modele -Edge_Law_X = doc.findEdge( x_mod_h , x_mod_h_t ) -Edge_Law_Y = doc.findEdge( y_mod_h , y_mod_h_t ) -Edge_Law_Z = doc.findEdge( y_mod_h , y_mod_b ) - - -Propa_X = doc.findPropagation( Edge_Law_X ) -Propa_Y = doc.findPropagation( Edge_Law_Y ) -Propa_Z = doc.findPropagation( Edge_Law_Z ) - - - -# appliquer la loi de discretisation sur tout le modele et generer le maillage -Propa_X.setLaw( Law_X ) -Propa_Y.setLaw( Law_Y ) -Propa_Z.setLaw( Law_Z ) - -print " --- MAILLAGE HEXAHEDRIQUE --- " -mesh = hexablock.mesh(doc, "test_TUYAU_COURBE_no_assoc") - -print "Nombre d hexaedres:" , mesh.NbHexas() -print "Nombre de quadrangles:", mesh.NbQuadrangles() -print "Nombre de segments:" , mesh.NbEdges() -print "Nombre de noeuds:" , mesh.NbNodes() - -salome.sg.updateObjBrowser(1) - -#Nombre d hexaedres: 480 -#Nombre de quadrangles: 496 -#Nombre de segments: 160 -#Nombre de noeuds: 700 - -allGroups = mesh.GetGroups() -print " --- GROUPES --- " -for aGroup in allGroups: - print "\nNOM:", aGroup.GetName() - print "IDS:", aGroup.GetIDs() - - - -## -------------------- -## Maillage hexa�drique -## -------------------- -#mesh = mesh.ExportMED( "tuyau.noassoc.med", 1 ) -#maillages = smesh.CreateMeshesFromMED( "tuyau.noassoc.med" ) - -#ijk = maillages[0][0] - -#ijk.Hexahedron() - -#ijk.Compute() - -#print " --- MAILLAGE HEXAHEDRIQUE --- " -#print "Nombre d hexaedres:", ijk.NbHexas() -#print "Nombre de quadrangles:", ijk.NbQuadrangles() -#print "Nombre de segments:", ijk.NbEdges() -#print "Nombre de noeuds:", ijk.NbNodes() diff --git a/src/TEST_PY/test_TUYAU_COURBE_weird_assoc.py b/src/TEST_PY/test_TUYAU_COURBE_weird_assoc.py deleted file mode 100755 index 3df354f..0000000 --- a/src/TEST_PY/test_TUYAU_COURBE_weird_assoc.py +++ /dev/null @@ -1,808 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -#=============================================== -# By Karima DEBCHI YATAGHENE Nov 2009 at CS -#=============================================== -import os -import geompy -import smesh -import hexablock -import math - -# chemin du fichier BREP contenant la CAO -BREP_PATH = os.path.expandvars("$HEXA_ROOT_DIR/bin/salome/tuyau.brep") - - - - -#=================================================================== -# LE MODELE: -# (Pour le tuyau on doit creer une grille cylindrique) -#=================================================================== - - -#============================= -# PARAMETRES -#============================= -R = 4.5 -r = 4.5 -r_t = 3.6 -h = 75.0 - - -#================================================= -# Creation du document -#================================================= -doc = hexablock.addDocument ("default") - -#================================================= -# Creation du tuyau (grille cylindrique) dans le document -#================================================= -# centre de la grille cylindrique -c = doc.addVertex(0, 0, 0) - -# vecteurs de la grille cylindrique -dx = doc.addVector(h, 0, 0) -dy = doc.addVector(0, h, 0) -dz = doc.addVector(0, 0, h) - -# taille du cylindre -dr = R -da = 360 -dl = h - -nr = 1 -na = 4 -nl = 1 - -model_tuyau_fin = doc.makeCylindrical(c, dx, dz, dr, da, dl, nr, na, nl, False) -# note: on obtient une liste qui contient 4 hexaedres eguaux - - -#=================================================================== -# Recuperation des vertex,edges et quads du model pour l'association -# -# h = haut -# b = bas -# g = grand -# p = petit -# t = trou -#=================================================================== - -#========================= -# VERTEX -#========================= - -# Face du haut -# grand rayon -x_mod_h = doc.findVertex( 2*R , 0 , h ) -y_mod_h = doc.findVertex( 0 , 2*R , h ) -z_mod_h = doc.findVertex( -2*R , 0 , h ) -u_mod_h = doc.findVertex( 0 , -2*R , h ) - -# petit rayon -x_mod_h_t = doc.findVertex( R , 0 , h ) -y_mod_h_t = doc.findVertex( 0 , R , h ) -z_mod_h_t = doc.findVertex( -R , 0 , h ) -u_mod_h_t = doc.findVertex( 0 , -R , h ) - -# Face du bas -# grand rayon -x_mod_b = doc.findVertex( 2*R , 0 , 0 ) -y_mod_b = doc.findVertex( 0 , 2*R , 0 ) -z_mod_b = doc.findVertex( -2*R , 0 , 0 ) -u_mod_b = doc.findVertex( 0 , -2*R , 0 ) - -# petit rayon -x_mod_b_t = doc.findVertex( R , 0 , 0 ) -y_mod_b_t = doc.findVertex( 0 , R , 0 ) -z_mod_b_t = doc.findVertex( -R , 0 , 0 ) -u_mod_b_t = doc.findVertex( 0 , -R , 0 ) - - -# v�rifications -assert x_mod_h -assert y_mod_h -assert z_mod_h -assert u_mod_h - -assert x_mod_h_t -assert y_mod_h_t -assert z_mod_h_t -assert u_mod_h_t - -assert x_mod_b -assert y_mod_b -assert z_mod_b -assert u_mod_b - -assert x_mod_b_t -assert y_mod_b_t -assert z_mod_b_t -assert u_mod_b_t - - -#========================= -# EDGES -#========================= - -# Face du haut - -# grand rayon -edge_mod_face_h_1_1 = doc.findEdge( y_mod_h , z_mod_h ) -edge_mod_face_h_1_2 = doc.findEdge( z_mod_h , u_mod_h ) -edge_mod_face_h_2_1 = doc.findEdge( y_mod_h, x_mod_h ) -edge_mod_face_h_2_2 = doc.findEdge( x_mod_h, u_mod_h ) - -# petit rayon -edge_mod_t_face_h_1_1 = doc.findEdge( y_mod_h_t , z_mod_h_t ) -edge_mod_t_face_h_1_2 = doc.findEdge( z_mod_h_t , u_mod_h_t ) -edge_mod_t_face_h_2_1 = doc.findEdge( y_mod_h_t, x_mod_h_t ) -edge_mod_t_face_h_2_2 = doc.findEdge( x_mod_h_t, u_mod_h_t ) - - -# Face du bas - -# grand rayon -edge_mod_face_b_1_1 = doc.findEdge( y_mod_b , z_mod_b ) -edge_mod_face_b_1_2 = doc.findEdge( z_mod_b , u_mod_b ) -edge_mod_face_b_2_1 = doc.findEdge( y_mod_b, x_mod_b ) -edge_mod_face_b_2_2 = doc.findEdge( x_mod_b, u_mod_b ) - -# petit rayon -edge_mod_t_face_b_1_1 = doc.findEdge( y_mod_b_t , z_mod_b_t ) -edge_mod_t_face_b_1_2 = doc.findEdge( z_mod_b_t , u_mod_b_t ) -edge_mod_t_face_b_2_1 = doc.findEdge( y_mod_b_t, x_mod_b_t ) -edge_mod_t_face_b_2_2 = doc.findEdge( x_mod_b_t, u_mod_b_t ) - - - -# Joignant faces haut et du bas -Edge_Mod_ext_h = doc.findEdge( y_mod_h , y_mod_b ) -Edge_Mod_int_h = doc.findEdge( y_mod_h_t , y_mod_b_t ) - -Edge_Mod_int_b = doc.findEdge( u_mod_h_t , u_mod_b_t ) -Edge_Mod_ext_b = doc.findEdge( u_mod_h , u_mod_b ) - -Edge_Mod_ext_g = doc.findEdge( x_mod_h , x_mod_b ) -Edge_Mod_int_g = doc.findEdge( x_mod_h_t , x_mod_b_t ) - -Edge_Mod_int_d = doc.findEdge( z_mod_h_t , z_mod_b_t ) -Edge_Mod_ext_d = doc.findEdge( z_mod_h , z_mod_b ) - - -# v�rifications -assert edge_mod_face_h_1_1 -assert edge_mod_face_h_1_2 -assert edge_mod_face_h_2_1 -assert edge_mod_face_h_2_2 - -assert edge_mod_t_face_h_1_1 -assert edge_mod_t_face_h_1_2 -assert edge_mod_t_face_h_2_1 -assert edge_mod_t_face_h_2_2 - -assert edge_mod_face_b_1_1 -assert edge_mod_face_b_1_2 -assert edge_mod_face_b_2_1 -assert edge_mod_face_b_2_2 - -assert edge_mod_t_face_b_1_1 -assert edge_mod_t_face_b_1_2 -assert edge_mod_t_face_b_2_1 -assert edge_mod_t_face_b_2_2 - - -assert Edge_Mod_ext_h -assert Edge_Mod_int_h - -assert Edge_Mod_int_b -assert Edge_Mod_ext_b - -assert Edge_Mod_ext_g -assert Edge_Mod_int_g - -assert Edge_Mod_int_d -assert Edge_Mod_ext_d - - - -#========================= -# QUADS -#========================= -Quad_mod_0 = model_tuyau_fin.getQuadJK( 1 , 0 , 0 ) -Quad_mod_1 = model_tuyau_fin.getQuadJK( 1 , 1 , 0 ) -Quad_mod_2 = model_tuyau_fin.getQuadJK( 1 , 2 , 0 ) -Quad_mod_3 = model_tuyau_fin.getQuadJK( 1 , 3 , 0 ) - - - -#=================================================================== -# LA GEOMETRIE -#=================================================================== - -#=================================================================== -# Recuperation des points de la geometrie tuyau pour l'association -# -#=================================================================== -Tuyau_geom = geompy.Import(BREP_PATH, "BREP") - - -#========================= -# SOMMETS -#========================= -Pt_A = geompy.MakeVertex( h , 20 , 4.5 ) -Pt_B = geompy.MakeVertex( h , 20 , 3.6 ) -Pt_C = geompy.MakeVertex( h , 20 , -4.5 ) -Pt_D = geompy.MakeVertex( h , 20 , -3.6 ) -Pt_E = geompy.MakeVertex( 0 , 0 , 2 ) -Pt_F = geompy.MakeVertex( 0 , 0 , 1.6 ) -Pt_G = geompy.MakeVertex( 0 , 0 , -2 ) -Pt_H = geompy.MakeVertex( 0 , 0 , -1.6 ) - -# Face du bas -Edge_bas_droite_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_E) -Edge_bas_droite_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_F) -Edge_bas_gauche_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_G) -Edge_bas_gauche_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_H) -## Grand rayon -x_b = geompy.MakeVertexOnCurve(Edge_bas_droite_grd, 0.5) -y_b = geompy.MakeVertexOnCurve(Edge_bas_droite_grd, 1) -z_b = geompy.MakeVertexOnCurve(Edge_bas_gauche_grd, 0.5) -u_b = geompy.MakeVertexOnCurve(Edge_bas_gauche_grd, 0) - -## Petit rayon -x_b_t = geompy.MakeVertexOnCurve(Edge_bas_droite_pte, 0.5) -y_b_t = geompy.MakeVertexOnCurve(Edge_bas_droite_pte, 1) -z_b_t = geompy.MakeVertexOnCurve(Edge_bas_gauche_pte, 0.5) -u_b_t = geompy.MakeVertexOnCurve(Edge_bas_gauche_pte, 0) - - -# Face du haut -Edge_haut_droite_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_A) -Edge_haut_droite_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_B) -Edge_haut_gauche_grd = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_C) -Edge_haut_gauche_pte = geompy.GetEdgeNearPoint(Tuyau_geom, Pt_D) -## Grand rayon -x_h = geompy.MakeVertexOnCurve(Edge_haut_droite_grd, 0.5) -y_h = geompy.MakeVertexOnCurve(Edge_haut_droite_grd, 1) -z_h = geompy.MakeVertexOnCurve(Edge_haut_gauche_grd, 0.5) -u_h = geompy.MakeVertexOnCurve(Edge_haut_gauche_grd, 0) - -## Petit rayon -x_h_t = geompy.MakeVertexOnCurve(Edge_haut_droite_pte, 0.5) -y_h_t = geompy.MakeVertexOnCurve(Edge_haut_droite_pte, 1) -z_h_t = geompy.MakeVertexOnCurve(Edge_haut_gauche_pte, 0.5) -u_h_t = geompy.MakeVertexOnCurve(Edge_haut_gauche_pte, 0) - - - -#========================= -# EDGES -#========================= -All_Edges_Tuy_1 = geompy.SubShapeAllSorted( Tuyau_geom , geompy.ShapeType["EDGE"] ) - -# Face du haut -## Grand rayon -edge_face_h_1 = All_Edges_Tuy_1[11] -edge_face_h_2 = All_Edges_Tuy_1[14] -## Petit rayon -edge_t_face_h_1 = All_Edges_Tuy_1[12] -edge_t_face_h_2 = All_Edges_Tuy_1[13] - - -# Face du bas -## Grand rayon -edge_face_b_1 = All_Edges_Tuy_1[1] -edge_face_b_2 = All_Edges_Tuy_1[4] -## Petit rayon -edge_t_face_b_1 = All_Edges_Tuy_1[2] -edge_t_face_b_2 = All_Edges_Tuy_1[3] - - -# Joignant les 2 faces - -## edges compl�tes -Edge_Tuy_ext_h = All_Edges_Tuy_1[6] -Edge_Tuy_int_h = All_Edges_Tuy_1[7] -Edge_Tuy_int_b = All_Edges_Tuy_1[8] -Edge_Tuy_ext_b = All_Edges_Tuy_1[9] - -Pt_Z = geompy.MakeVertex( 75 , 20 , 0 ) -Pt_Z_1 = geompy.MakeVertexWithRef( Pt_Z , 0 , 0 , 10 ) -Pt_Z_2 = geompy.MakeVertexWithRef( Pt_Z , 0 , 0 , -10 ) -Line_Z1_Z2 = geompy.MakeLineTwoPnt( Pt_Z_1 , Pt_Z_2 ) - - -All_Edge_Tuy_ext_h = geompy.SubShapeAllSorted( Edge_Tuy_ext_h , geompy.ShapeType["VERTEX"] ) - -Vx_Edg_Tuy_ext_h_1 = All_Edge_Tuy_ext_h[0] -Vx_Edg_Tuy_ext_h_2 = All_Edge_Tuy_ext_h[1] - -Vx_Edg_Tuy_ext_h_1_trans = geompy.MakeVertexWithRef( Vx_Edg_Tuy_ext_h_1 , -10 , -10 , 0 ) -Vx_Edg_Tuy_ext_h_2_trans = geompy.MakeVertexWithRef( Vx_Edg_Tuy_ext_h_2 , 10 , 0 , 0 ) - -Line_1 = geompy.MakeLineTwoPnt(Vx_Edg_Tuy_ext_h_1, Vx_Edg_Tuy_ext_h_1_trans) -Line_2 = geompy.MakeLineTwoPnt(Vx_Edg_Tuy_ext_h_2, Vx_Edg_Tuy_ext_h_2_trans) - -Wire = geompy.MakeWire([Line_1, Line_2, Edge_Tuy_ext_h]) -Pipe_Z = geompy.MakePipe( Line_Z1_Z2 , Wire ) -Pipe_Ztt = geompy.MakePipe( Line_Z1_Z2 , Edge_Tuy_ext_h ) -Partition_Ztt = geompy.MakePartition([Tuyau_geom], [Pipe_Ztt], [], [], geompy.ShapeType["SOLID"], 0, [], 0) -All_Edges_Tuy_2tt = geompy.SubShapeAllSorted( Partition_Ztt , geompy.ShapeType["EDGE"] ) - -Edge_Tuy_ext_g = All_Edges_Tuy_2tt[12] -Edge_Tuy_int_g = All_Edges_Tuy_2tt[13] -Edge_Tuy_ext_d = All_Edges_Tuy_2tt[10] -Edge_Tuy_int_d = All_Edges_Tuy_2tt[11] - -## une edge en plusieurs(4) morceaux : Edge_Tuy_ext_h -X_pln1 = geompy.MakeVertexWithRef( Pt_Z , -20 , 0 , 0 ) -Vec_X = geompy.MakeVectorDXDYDZ( 1 , 0 , 0 ) - -Plan1 = geompy.MakePlane( X_pln1 , Vec_X , 200 ) -Plan2 = geompy.MakeTranslation( Plan1 , -20 , 0 , 0 ) -Plan3 = geompy.MakeTranslation( Plan1 , -40 , 0 , 0 ) - -Partition_Edge_g_d_h_b = geompy.MakePartition([ - Edge_Tuy_ext_h, - Edge_Tuy_int_h, - Edge_Tuy_ext_b, - Edge_Tuy_int_b, - Edge_Tuy_ext_g, - Edge_Tuy_int_g, - Edge_Tuy_ext_d, - Edge_Tuy_int_d], - [Plan1, Plan2, Plan3], [], [], geompy.ShapeType["EDGE"], 0, [], 0) - -All_Edge_g_d_h_b = geompy.SubShapeAllSorted( Partition_Edge_g_d_h_b , geompy.ShapeType["EDGE"] ) -Edge_Tuy_ext_h_1 = All_Edge_g_d_h_b[0] -Edge_Tuy_ext_h_2 = All_Edge_g_d_h_b[15] -Edge_Tuy_ext_h_3 = All_Edge_g_d_h_b[23] -Edge_Tuy_ext_h_4 = All_Edge_g_d_h_b[31] - - - -## une edge d�coup�e en plusieurs morceaux n'�pousant pas la g�om�trie: -VX_A = geompy.MakeVertexOnCurve(Edge_Tuy_ext_d, 0.) -VX_B = geompy.MakeVertexOnCurve(Edge_Tuy_ext_d, 1.) -VX_C = geompy.MakeVertexOnCurve(Edge_Tuy_ext_d, 0.25) -#VX_Cbis = geompy.MakeVertexWithRef(VX_C, -10, 10, 0) -VX_Cbis = geompy.MakeVertexWithRef(VX_C, -5, 1, -4) - -weird_part = geompy.MakePartition([Edge_Tuy_ext_d], [VX_C], [], [], geompy.ShapeType["EDGE"]) - -weird_edge0 = geompy.GetEdge(weird_part, VX_C, VX_B) -weird_edge1 = geompy.MakeEdge(VX_Cbis, VX_C ) -weird_edge2 = geompy.MakeEdge(VX_A, VX_Cbis ) - - -#========================= -# FACES -#========================= -All_Faces_Tuy_1 = geompy.SubShapeAllSorted( Tuyau_geom , geompy.ShapeType["FACE"] ) - -Face_Tuy_ext_1 = All_Faces_Tuy_1[4] -Face_Tuy_ext_2 = All_Faces_Tuy_1[5] - -Partition_Face = geompy.MakePartition([ Face_Tuy_ext_1 , Face_Tuy_ext_2 ], [ Plan1 , Plan2 , Plan3 , Pipe_Z ], [], [], geompy.ShapeType["FACE"], 0, [], 0) - - -All_Faces_Partition_Face = geompy.SubShapeAllSorted( Partition_Face , geompy.ShapeType["FACE"] ) - -## ------------------------------------- -Face_0 = All_Faces_Partition_Face[0] -Face_6 = All_Faces_Partition_Face[6] -Face_10 = All_Faces_Partition_Face[10] -Face_14 = All_Faces_Partition_Face[14] - -## ------------------------------------- -Face_1 = All_Faces_Partition_Face[1] -Face_7 = All_Faces_Partition_Face[7] -Face_11 = All_Faces_Partition_Face[11] -Face_15 = All_Faces_Partition_Face[15] - -## ------------------------------------- -Face_2 = All_Faces_Partition_Face[2] -Face_4 = All_Faces_Partition_Face[4] -Face_8 = All_Faces_Partition_Face[8] -Face_12 = All_Faces_Partition_Face[12] - -## ------------------------------------- -Face_3 = All_Faces_Partition_Face[3] -Face_5 = All_Faces_Partition_Face[5] -Face_9 = All_Faces_Partition_Face[9] -Face_13 = All_Faces_Partition_Face[13] - - - - - -#========================================================== -# LES ASSOCIATIONS -#========================================================== - -##=========================================== -## VERTEX -##=========================================== - -# Face du haut - -## Grand rayon -x_mod_h.setAssociation( x_h ) -y_mod_h.setAssociation( y_h ) -z_mod_h.setAssociation( z_h ) -u_mod_h.setAssociation( u_h ) - -## Petit rayon -x_mod_h_t.setAssociation( x_h_t ) -y_mod_h_t.setAssociation( y_h_t ) -z_mod_h_t.setAssociation( z_h_t ) -u_mod_h_t.setAssociation( u_h_t ) - - -# Face du bas - -## Grand rayon -x_mod_b.setAssociation( x_b ) -y_mod_b.setAssociation( y_b ) -z_mod_b.setAssociation( z_b ) -u_mod_b.setAssociation( u_b ) - -## Petit rayon -x_mod_b_t.setAssociation( x_b_t ) -y_mod_b_t.setAssociation( y_b_t ) -z_mod_b_t.setAssociation( z_b_t ) -u_mod_b_t.setAssociation( u_b_t ) - - -##=========================================== -## EDGES -##=========================================== - -# Face du haut - -## Grand rayon -edge_mod_face_h_1_1.addAssociation( edge_face_h_1, 0.5, 1. ) -edge_mod_face_h_1_2.addAssociation( edge_face_h_1, 0., 0.5 ) -edge_mod_face_h_2_1.addAssociation( edge_face_h_2, 0.5, 1. ) -edge_mod_face_h_2_2.addAssociation( edge_face_h_2, 0., 0.5 ) - -## Petit rayon -edge_mod_t_face_h_1_1.addAssociation( edge_t_face_h_1, 0.5, 1. ) -edge_mod_t_face_h_1_2.addAssociation( edge_t_face_h_1, 0., 0.5 ) -edge_mod_t_face_h_2_1.addAssociation( edge_t_face_h_2, 0.5, 1. ) -edge_mod_t_face_h_2_2.addAssociation( edge_t_face_h_2, 0., 0.5 ) - -# Face du bas - -## Grand rayon -edge_mod_face_b_1_1.addAssociation( edge_face_b_1, 0.5, 1. ) -edge_mod_face_b_1_2.addAssociation( edge_face_b_1, 0., 0.5 ) -edge_mod_face_b_2_1.addAssociation( edge_face_b_2, 0.5, 1. ) -edge_mod_face_b_2_2.addAssociation( edge_face_b_2, 0., 0.5 ) - -## Petit rayon -edge_mod_t_face_b_1_1.addAssociation( edge_t_face_b_1, 0.5, 1. ) -edge_mod_t_face_b_1_2.addAssociation( edge_t_face_b_1, 0., 0.5 ) -edge_mod_t_face_b_2_1.addAssociation( edge_t_face_b_2, 0.5, 1. ) -edge_mod_t_face_b_2_2.addAssociation( edge_t_face_b_2, 0., 0.5 ) - - - -# Joignant les 2 faces -#Edge_Mod_ext_h.addAssociation( Edge_Tuy_ext_h, 0., 1. ) -Edge_Mod_ext_h.addAssociation( Edge_Tuy_ext_h_1, 0., 1. ) -Edge_Mod_ext_h.addAssociation( Edge_Tuy_ext_h_2, 0., 1. ) -Edge_Mod_ext_h.addAssociation( Edge_Tuy_ext_h_3, 0., 1. ) -Edge_Mod_ext_h.addAssociation( Edge_Tuy_ext_h_4, 0., 1. ) -Edge_Mod_int_h.addAssociation( Edge_Tuy_int_h, 0., 1. ) - -Edge_Mod_int_b.addAssociation( Edge_Tuy_int_b, 0., 1. ) -Edge_Mod_ext_b.addAssociation( Edge_Tuy_ext_b, 0., 1. ) - -Edge_Mod_ext_g.addAssociation( Edge_Tuy_ext_g, 0., 1. ) -Edge_Mod_int_g.addAssociation( Edge_Tuy_int_g, 0., 1. ) - -Edge_Mod_int_d.addAssociation( Edge_Tuy_int_d, 0., 1. ) -#Edge_Mod_ext_d.addAssociation( Edge_Tuy_ext_d, 0., 1. ) -Edge_Mod_ext_d.addAssociation( weird_edge0, 0., 1. ) -Edge_Mod_ext_d.addAssociation( weird_edge1, 0., 1. ) -Edge_Mod_ext_d.addAssociation( weird_edge2, 0., 1. ) - - - -##=========================================== -## FACES -##=========================================== - -#Quad_mod_1.addAssociation( Face_Tuy_ext_1 ) -Quad_mod_1.addAssociation( Face_0 ) -Quad_mod_1.addAssociation( Face_6 ) -Quad_mod_1.addAssociation( Face_10 ) -Quad_mod_1.addAssociation( Face_14 ) - -#Quad_mod_0.addAssociation( Face_Tuy_ext_2 ) -Quad_mod_0.addAssociation( Face_1 ) -Quad_mod_0.addAssociation( Face_7 ) -Quad_mod_0.addAssociation( Face_11 ) -Quad_mod_0.addAssociation( Face_15 ) - -#Quad_mod_2.addAssociation( Face_Tuy_ext_1 ) -Quad_mod_2.addAssociation( Face_2 ) -Quad_mod_2.addAssociation( Face_4 ) -Quad_mod_2.addAssociation( Face_8 ) -Quad_mod_2.addAssociation( Face_12 ) - -#Quad_mod_3.addAssociation( Face_Tuy_ext_2 ) -Quad_mod_3.addAssociation( Face_3 ) -Quad_mod_3.addAssociation( Face_5 ) -Quad_mod_3.addAssociation( Face_9 ) -Quad_mod_3.addAssociation( Face_13 ) - - - -#========================================================== -# LA GEOMETRIE DANS L'ARBRE D'ETUDE SALOME -#========================================================== -#for i,e in enumerate(All_Edges_Tuy_1): geompy.addToStudy( e, "edge_"+str(i) ) -geompy.addToStudy(Tuyau_geom, "Tuyau_geom") -geompy.addToStudy( x_h, "x_h" ) -geompy.addToStudy( y_h, "y_h" ) -geompy.addToStudy( z_h, "z_h" ) -geompy.addToStudy( u_h, "u_h" ) -geompy.addToStudy( x_h_t, "x_h_t") -geompy.addToStudy( y_h_t, "y_h_t" ) -geompy.addToStudy( z_h_t, "z_h_t" ) -geompy.addToStudy( u_h_t, "u_h_t" ) - -geompy.addToStudy( x_b, "x_b") -geompy.addToStudy( y_b, "y_b" ) -geompy.addToStudy( z_b, "z_b" ) -geompy.addToStudy( u_b, "u_b") -geompy.addToStudy( x_b_t, "x_b_t" ) -geompy.addToStudy( y_b_t, "y_b_t" ) -geompy.addToStudy( z_b_t, "z_b_t" ) -geompy.addToStudy( u_b_t, "u_b_t" ) - - -#geompy.addToStudy(Line_Z1_Z2, "Line_Z1_Z2") -#geompy.addToStudy(Pipe_Ztt, "Pipe_Ztt") -#geompy.addToStudy( Partition_Ztt , "Partition_Ztt" ) -geompy.addToStudy( Edge_Tuy_ext_h , "Edge_Tuy_ext_h" ) -geompy.addToStudy( Edge_Tuy_int_h , "Edge_Tuy_int_h" ) -geompy.addToStudy( Edge_Tuy_int_b , "Edge_Tuy_int_b" ) -geompy.addToStudy( Edge_Tuy_ext_b , "Edge_Tuy_ext_b" ) -geompy.addToStudy( Edge_Tuy_ext_g , "Edge_Tuy_ext_g" ) -geompy.addToStudy( Edge_Tuy_int_g , "Edge_Tuy_int_g" ) -geompy.addToStudy( Edge_Tuy_ext_d , "Edge_Tuy_ext_d" ) -geompy.addToStudy( Edge_Tuy_int_d , "Edge_Tuy_int_d" ) -#geompy.addToStudy( Partition_Edge_g_d_h_b , "Partition_Edge_g_d_h_b" ) -geompy.addToStudy( Face_Tuy_ext_1 , "Face_Tuy_ext_1" ) -geompy.addToStudy( Face_Tuy_ext_2 , "Face_Tuy_ext_2" ) -#geompy.addToStudy( Partition_Face , "Partition_Face" ) -geompy.addToStudy( Face_0 , "Face_0" ) -geompy.addToStudy( Face_1 , "Face_1" ) -geompy.addToStudy( Face_2 , "Face_2" ) -geompy.addToStudy( Face_3 , "Face_3" ) -geompy.addToStudy( Face_4 , "Face_4" ) -geompy.addToStudy( Face_5 , "Face_5" ) -geompy.addToStudy( Face_6 , "Face_6" ) -geompy.addToStudy( Face_7 , "Face_7" ) -geompy.addToStudy( Face_8 , "Face_8" ) -geompy.addToStudy( Face_9 , "Face_9" ) -geompy.addToStudy( Face_10 , "Face_10" ) -geompy.addToStudy( Face_11 , "Face_11" ) -geompy.addToStudy( Face_12 , "Face_12" ) -geompy.addToStudy( Face_13 , "Face_13" ) -geompy.addToStudy( Face_14 , "Face_14" ) -geompy.addToStudy( Face_15 , "Face_15" ) - - - - - -#==================================== -# CREATION MAILLAGE -#==================================== - - -##================================================= -## Definir les groupes d'elements pour le maillage -##================================================= - -# groupe de Hexa(volumes) -Hexa_grp = doc.addHexaGroup("Hexa_grp") -Nbr_Hex = doc.countHexa() - - -for i in range(Nbr_Hex): - Hexa_i = doc.getHexa(i) - Hexa_grp.addElement(Hexa_i) - -Nbr_elm_hex = Hexa_grp.countElement() -print "Hexa_grp.countElement() ->",Nbr_elm_hex - - -# groupe de quads (faces) -Quad_grp_haut = doc.addQuadGroup("Quad_grp_haut") -Quad_h_1 = doc.findQuad( x_mod_h , y_mod_h_t ) -Quad_h_2 = doc.findQuad( y_mod_h_t , z_mod_h ) -Quad_h_3 = doc.findQuad( z_mod_h , u_mod_h_t ) -Quad_h_4 = doc.findQuad( u_mod_h_t , x_mod_h ) - -assert Quad_h_1 -assert Quad_h_2 -assert Quad_h_3 -assert Quad_h_4 - -for Quad_h_i in [ Quad_h_1 , Quad_h_2 , Quad_h_3 , Quad_h_4 ]: - Quad_grp_haut.addElement(Quad_h_i) - - -Quad_grp_bas = doc.addQuadGroup("Quad_grp_bas") -Quad_b_1 = doc.findQuad( x_mod_b , y_mod_b_t ) -Quad_b_2 = doc.findQuad( y_mod_b_t , z_mod_b ) -Quad_b_3 = doc.findQuad( z_mod_b , u_mod_b_t ) -Quad_b_4 = doc.findQuad( u_mod_b_t , x_mod_b ) - - -assert Quad_b_1 -assert Quad_b_2 -assert Quad_b_3 -assert Quad_b_4 - -for Quad_b_i in [ Quad_b_1 , Quad_b_2 , Quad_b_3 , Quad_b_4 ]: - Quad_grp_bas.addElement(Quad_b_i) - -#Nbr_elm_qad_bas = Quad_grp_bas.countElement() -#print "Nbr_elm_qad_bas->",Nbr_elm_qad_bas - - - -# groupe de Edges -Edge_Grp_haut = doc.addEdgeGroup("Edge_Grp_haut") -Edge_Grp_haut.addElement(Edge_Mod_ext_h) -Edge_Grp_haut.addElement(Edge_Mod_int_h) - -Edge_Grp_gauche = doc.addEdgeGroup("Edge_Grp_gauche") -Edge_Grp_gauche.addElement(Edge_Mod_ext_g) -Edge_Grp_gauche.addElement(Edge_Mod_int_g) - -Edge_Grp_bas = doc.addEdgeGroup("Edge_Grp_bas") -Edge_Grp_bas.addElement(Edge_Mod_int_b) -Edge_Grp_bas.addElement(Edge_Mod_ext_b) - -Edge_Grp_droit = doc.addEdgeGroup("Edge_Grp_droit") -Edge_Grp_droit.addElement(Edge_Mod_int_d) -Edge_Grp_droit.addElement(Edge_Mod_ext_d) - - -# groupe de noeuds de Hexa -Hexa_Nod_Grp = doc.addHexaNodeGroup("Hexa_Nod_Grp") -for i in range(Nbr_Hex): - Hexa_i = doc.getHexa(i) - Hexa_Nod_Grp.addElement(Hexa_i) - -# groupe de noeuds de Quad -Quad_Nod_Grp_h_1 = doc.addQuadNodeGroup("Quad_Nod_Grp_h_1") -Quad_Nod_Grp_h_1.addElement(Quad_h_1) - -Quad_Nod_Grp_b_1 = doc.addQuadNodeGroup("Quad_Nod_Grp_b_1") -Quad_Nod_Grp_b_1.addElement(Quad_b_1) - -# groupe de noeuds de Edge -Edge_Nod_Grp_b = doc.addEdgeNodeGroup("Edge_Nod_Grp_b") -Edge_Nod_Grp_b.addElement(Edge_Mod_int_b) -Edge_Nod_Grp_b.addElement(Edge_Mod_ext_b) - -Edge_Nod_Grp_h = doc.addEdgeNodeGroup("Edge_Nod_Grp_h") -Edge_Nod_Grp_h.addElement(Edge_Mod_int_d) -Edge_Nod_Grp_h.addElement(Edge_Mod_ext_d) - - -# groupe de noeuds de vertex pour tout le modele -Vertex_Nod_Grp = doc.addVertexNodeGroup("Vertex_Nod_Grp") -Nbr_Vx = doc.countVertex() -for i in range(Nbr_Vx): - Vertex_i = doc.getVertex(i) - Vertex_Nod_Grp.addElement(Vertex_i) - - -#==================================== -# Definir une loi de discretisation -#==================================== -bp_law = doc.getLaw(0) -bp_law.setNodes(4) - -# definir une loi: le choix de la loi reste aux utilisateurs - -#Law_X = doc.addLaw( "Uniform" , 4 ) -#Law_Y = doc.addLaw( "Arithmetic" , 2 ) -#Law_Z = doc.addLaw( "Geometric" , 3 ) -Law_X = doc.addLaw( "Arithmetic" , 5 ) -Law_X.setKind(hexablock.ARITHMETIC) -Law_X.setCoefficient(0.1) - -Law_Y = doc.addLaw( "Arithmetic" , 3 ) -Law_Y.setKind(hexablock.ARITHMETIC) -Law_Y.setCoefficient(0.1) - -#Law_Z = doc.addLaw( "Geometric" , 4 ) -Law_Z = doc.addLaw( "Arithmetic" , 5 ) -Law_Z.setKind(hexablock.ARITHMETIC) -Law_Z.setCoefficient(0.05) - - -# chercher les propagations du modele -Edge_Law_X = doc.findEdge( x_mod_h , x_mod_h_t ) -Edge_Law_Y = doc.findEdge( y_mod_h , y_mod_h_t ) -Edge_Law_Z = doc.findEdge( y_mod_h , y_mod_b ) - -Propa_X = doc.findPropagation( Edge_Law_X ) -Propa_Y = doc.findPropagation( Edge_Law_Y ) -Propa_Z = doc.findPropagation( Edge_Law_Z ) - -# appliquer la loi de discretisation sur tout le modele et generer le maillage -Propa_X.setLaw( Law_X ) -Propa_Y.setLaw( Law_Y ) -Propa_Z.setLaw( Law_Z ) - -print " --- MAILLAGE HEXAHEDRIQUE --- " -mesh = hexablock.mesh(doc, "test_TUYAU_COURBE_weird_assoc") - -print "Nombre d hexaedres:" , mesh.NbHexas() -print "Nombre de quadrangles:", mesh.NbQuadrangles() -print "Nombre de segments:" , mesh.NbEdges() -print "Nombre de noeuds:" , mesh.NbNodes() - -salome.sg.updateObjBrowser(1) - -#Nombre d hexaedres: 480 -#Nombre de quadrangles: 496 -#Nombre de segments: 160 -#Nombre de noeuds: 700 - -allGroups = mesh.GetGroups() -print " --- GROUPES --- " -for aGroup in allGroups: - print "\nNOM:", aGroup.GetName() - print "IDS:", aGroup.GetIDs() - - - -## -------------------- -## Maillage hexa�drique -## -------------------- -#mesh = mesh.ExportMED( "tuyau.med", 1 ) -#maillages = smesh.CreateMeshesFromMED( "tuyau.med" ) - -#ijk = maillages[0][0] - -#ijk.Hexahedron() - -#ijk.Compute() - -#print " --- MAILLAGE HEXAHEDRIQUE --- " -#print "Nombre d hexaedres:", ijk.NbHexas() -#print "Nombre de quadrangles:", ijk.NbQuadrangles() -#print "Nombre de segments:", ijk.NbEdges() -#print "Nombre de noeuds:", ijk.NbNodes() diff --git a/src/TEST_PY/test_distrib.py b/src/TEST_PY/test_distrib.py deleted file mode 100755 index a62fc88..0000000 --- a/src/TEST_PY/test_distrib.py +++ /dev/null @@ -1,111 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (C) 2009-2012 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# Francis KLOSS - 2010 - CEA-Saclay, DEN, DM2S, SFME, LGLS, F-91191 Gif-sur-Yvette, France -# ======================================================================================== - -import geompy -import hexablock - -# Build the geometry to mesh with hexahedra: a sphere -# --------------------------------------------------- - -name = "Sphere" - -cx = 0 -cy = 0 -cz = 0 - -radius = 5 - -sphere = geompy.MakeSphere(cx, cy, cz, radius) - -geompy.addToStudy(sphere, name) - -# Add a new document -# ------------------ - -doc = hexablock.addDocument(name) - -doc.addShape(sphere) - -# Build the model of blocks: a catesian grid -# ------------------------------------------ - -center = doc.addVertex(cx, cy, cz) - -axis_x = doc.addVector(1, 0, 0) -axis_y = doc.addVector(0, 1, 0) -axis_z = doc.addVector(0, 0, 1) - -doc.makeCartesian(center, axis_x, axis_y, axis_z, 5, 4, 3) - -# Associate the model of block to the geometry -# -------------------------------------------- - -# Define group of all hexahedra -# ----------------------------- - -group_h = doc.addHexaGroup(name+":hexas") -for i in xrange(doc.countHexa()): - e = doc.getHexa(i) - group_h.addElement(e) - -# Define group of all quadrangles -# ------------------------------- - -group_q = doc.addQuadGroup(name+":quadrangles") -for i in xrange(doc.countQuad()): - e = doc.getQuad(i) - group_q.addElement(e) - -# Define the laws for discretization -# ---------------------------------- - -law = doc.addLaw("Uniform" , 3) - -# Set the law on all edges of the model of blocks -# ----------------------------------------------- - -for i in xrange(doc.countPropagation()): - p = doc.getPropagation(i) - p.setLaw(law) - -# Generate the hexehadral mesh on FactoryServer -# --------------------------------------------- - -mesh_1 = hexablock.mesh(doc) - -print "Number of hexaedra :", mesh_1.NbHexas() -print "Number of quadrangles:", mesh_1.NbQuadrangles() -print "Number of segments :", mesh_1.NbEdges() -print "Number de nodes :", mesh_1.NbNodes() - -# Generate the hexehadral mesh on FooBar container -# ------------------------------------------------ - -container = "FooBar" - -mesh_2 = hexablock.mesh(doc, name+":"+container, 3, container) - -print "Number of hexaedra :", mesh_2.NbHexas() -print "Number of quadrangles:", mesh_2.NbQuadrangles() -print "Number of segments :", mesh_2.NbEdges() -print "Number de nodes :", mesh_2.NbNodes() -- 2.39.2