Salome HOME
Updated copyright comment
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI_DocumentModel.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 1045efd..5bb5823
@@ -1,9 +1,9 @@
-// Copyright (C) 2009-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2009-2024  CEA, EDF
 //
 // 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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 #include <TopoDS.hxx>
 #include <BRepBuilderAPI_MakeVertex.hxx>
 
-#include <GEOMBase.h>
 #include "HEXABLOCKGUI_SalomeTools.hxx"
 
-#include "GEOM_GEOMBase.hxx"
-
 #include <SALOME_ListIO.hxx>
 #include <SALOMEconfig.h>
 #include <SUIT_ViewWindow.h>
 
 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
 
-
+#include <Geom_Circle.hxx>
+#include <gp_Circ.hxx>
+#include <BRep_Tool.hxx>
+#include <TopoDS_Edge.hxx>
 //#define _DEVDEBUG_
 
 
@@ -171,7 +171,7 @@ HEXA_NS::EltBase* DocumentModel::getHexaPtr(const QModelIndex& iElt)
     case HEXA_TREE : elt = getHexaPtr<HEXA_NS::Hexa*>(iElt); break;
     case VECTOR_TREE : elt = getHexaPtr<HEXA_NS::Vector*>(iElt); break;
     case ELEMENTS_TREE : elt = getHexaPtr<HEXA_NS::Elements*>(iElt); break;
-    case CROSSELEMENTS_TREE : elt = getHexaPtr<HEXA_NS::CrossElements*>(iElt); break;
+//  case CROSSELEMENTS_TREE : elt = getHexaPtr<HEXA_NS::CrossElements*>(iElt); break;
     case GEOMSHAPE_TREE: elt = getHexaPtr<HEXA_NS::NewShape*>(iElt); break;
     case GEOMPOINT_TREE: elt = getHexaPtr<HEXA_NS::VertexShape*>(iElt); break;
     case GEOMEDGE_TREE:  elt = getHexaPtr<HEXA_NS::EdgeShape*>(iElt); break;
@@ -241,6 +241,44 @@ int DocumentModel::getNbrUnusedElt(HEXA_NS::EnumElt eltType)
     return getNbrElt(eltType) - getNbrUsedElt(eltType);
 }
 
+// compute the length of the given edge
+double DocumentModel::getLength(const QModelIndex& iEdge)
+{
+    // * Get the pointer to the edge
+    HEXA_NS::Edge*        edge     = getHexaPtr<HEXA_NS::Edge*>(iEdge);
+    HEXA_NS::EdgeShape*   geomEdge = getHexaPtr<HEXA_NS::EdgeShape*>(iEdge);
+
+    // * The edge can be from VTK or OCC View
+    if (edge != NULL)
+        return edge->getLength();
+    else if (geomEdge != NULL)
+        return geomEdge->getLength();
+    else
+        return 0.;
+}
+
+// Compute the radius of the given edge
+double DocumentModel::getRadius(const QModelIndex& iEdge)
+{
+    // * Get the pointer to the edge
+    // * In our case only an OCC edge can have a radius
+    HEXA_NS::EdgeShape* edge = getHexaPtr<HEXA_NS::EdgeShape*>(iEdge);
+    if (edge == NULL)
+        return 0.;
+
+    return edge->getRadius();
+}
+
+// Compute the angle of the given edge (internal angle)
+double DocumentModel::getAngle(const QModelIndex& iEdge)
+{
+    // * Get the pointer to the edge
+    HEXA_NS::EdgeShape* edge = getHexaPtr<HEXA_NS::EdgeShape*>(iEdge);
+    if (edge == NULL)
+        return 0.;
+
+    return edge->getAngle();
+}
 
 //Load the current Document
 void DocumentModel::load()
@@ -258,7 +296,7 @@ void DocumentModel::load( const QString& xmlFileName ) // Fill Data
     clearAll();
 
     fillData();
-    fillBuilder();
+//    fillBuilder();
     fillGeometry();
     fillAssociation();
     fillGroups();
@@ -316,7 +354,7 @@ void DocumentModel::refresh()
     clearAll();
 
     fillData();
-    fillBuilder();
+//    fillBuilder();
     fillGeometry();
     fillAssociation();
     fillGroups();
@@ -328,7 +366,7 @@ void DocumentModel::refresh()
 void DocumentModel::clearAll()
 {
     clearData();
-    clearBuilder();
+//    clearBuilder();
     clearGeometry();
     clearAssociation();
     clearGroups();
@@ -341,16 +379,20 @@ void DocumentModel::clearData()
     _edgeDirItem->removeRows(0, _edgeDirItem->rowCount() );
     _quadDirItem->removeRows(0, _quadDirItem->rowCount() );
     _hexaDirItem->removeRows(0, _hexaDirItem->rowCount() );
-}
-
 
-void DocumentModel::clearBuilder()
-{
     _vectorDirItem->removeRows(0, _vectorDirItem->rowCount() );
     _elementsDirItem->removeRows(0, _elementsDirItem->rowCount() );
     _crossElementsDirItem->removeRows(0, _crossElementsDirItem->rowCount() );
 }
 
+
+//void DocumentModel::clearBuilder()
+//{
+//    _vectorDirItem->removeRows(0, _vectorDirItem->rowCount() );
+//    _elementsDirItem->removeRows(0, _elementsDirItem->rowCount() );
+//    _crossElementsDirItem->removeRows(0, _crossElementsDirItem->rowCount() );
+//}
+
 void DocumentModel::clearGeometry()
 {
     _explicitShapesDirItem->removeRows(0, _explicitShapesDirItem->rowCount() );
@@ -418,57 +460,100 @@ void DocumentModel::fillData()
         hItem = new HexaItem(h, _entry);
         _hexaDirItem->appendRow(hItem);
     }
-}
 
+    // +++++ Builder ++++++++++++++++++++++++++++++
 
-void DocumentModel::fillBuilder()
-{
-    HEXA_NS::Vector *v     = NULL;
-    VectorItem      *vItem = NULL;
+    HEXA_NS::Vector *vec     = NULL;
+    VectorItem      *vecItem = NULL;
     int nbVector = _hexaDocument->countVector();
     for ( int i=0; i<nbVector; ++i ){
-        v = _hexaDocument->getVector(i);
-        vItem = new VectorItem(v);
-        _vectorDirItem->appendRow(vItem);
+        vec = _hexaDocument->getVector(i);
+        vecItem = new VectorItem(vec);
+        _vectorDirItem->appendRow(vecItem);
     }
 
     //******* A VOIR AVEC ALAIN POUR LE REMPLISSAGE DE L'ARBRE ELEMENTS ET CROSSELEMENTS (ByCylinder) *******/
     //******* OU SONT STOCKES LES ELEMENTS ET LES CROSSELEMENTS DANS LE DOCUMENT?                     ******/
 
     //   _cylinderDirItem
-//    HEXA_NS::Cylinder *c     = NULL;
-//    HEXA_NS::Elements* c = NULL;
-//    CylinderItem      *cItem = NULL;
-//    ElementsItem* cItem = NULL;
-//    int nbCylinder = _hexaDocument->countCylinder();
-//    for ( int i=0; i<nbCylinder; ++i ){
-//        c = _hexaDocument->getCylinder(i);
-//        cItem = new CylinderItem(c, _entry);
-//        cItem = new ElementsItem(c, _entry);
-//        _cylinderDirItem->appendRow(cItem);
-//        _elementsDirItem->appendRow(cItem);
-//    }
+    //    HEXA_NS::Cylinder *c     = NULL;
+    //    HEXA_NS::Elements* c = NULL;
+    //    CylinderItem      *cItem = NULL;
+    //    ElementsItem* cItem = NULL;
+    //    int nbCylinder = _hexaDocument->countCylinder();
+    //    for ( int i=0; i<nbCylinder; ++i ){
+    //        c = _hexaDocument->getCylinder(i);
+    //        cItem = new CylinderItem(c, _entry);
+    //        cItem = new ElementsItem(c, _entry);
+    //        _cylinderDirItem->appendRow(cItem);
+    //        _elementsDirItem->appendRow(cItem);
+    //    }
 
     //   _pipeDirItem
-//    HEXA_NS::Pipe *p     = NULL;
-//    HEXA_NS::Elements* p = NULL;
-//    PipeItem      *pItem = NULL;
-//    ElementsItem* pItem = NULL;
-//    int nbPipe = _hexaDocument->countPipe();
-//    for ( int i=0; i<nbPipe; ++i ){
-//        p = _hexaDocument->getPipe(i);
-//        pItem = new PipeItem(p);
-//        pItem = new ElementsItem(p, _entry);
-//        _pipeDirItem->appendRow(pItem);
-//        _elementsDirItem->appendRow(pItem);
-//    }
+    //    HEXA_NS::Pipe *p     = NULL;
+    //    HEXA_NS::Elements* p = NULL;
+    //    PipeItem      *pItem = NULL;
+    //    ElementsItem* pItem = NULL;
+    //    int nbPipe = _hexaDocument->countPipe();
+    //    for ( int i=0; i<nbPipe; ++i ){
+    //        p = _hexaDocument->getPipe(i);
+    //        pItem = new PipeItem(p);
+    //        pItem = new ElementsItem(p, _entry);
+    //        _pipeDirItem->appendRow(pItem);
+    //        _elementsDirItem->appendRow(pItem);
+    //    }
     //********************************************************************************************************
 }
 
+
+//void DocumentModel::fillBuilder()
+//{
+//    HEXA_NS::Vector *v     = NULL;
+//    VectorItem      *vItem = NULL;
+//    int nbVector = _hexaDocument->countVector();
+//    for ( int i=0; i<nbVector; ++i ){
+//        v = _hexaDocument->getVector(i);
+//        vItem = new VectorItem(v);
+//        _vectorDirItem->appendRow(vItem);
+//    }
+//
+//    //******* A VOIR AVEC ALAIN POUR LE REMPLISSAGE DE L'ARBRE ELEMENTS ET CROSSELEMENTS (ByCylinder) *******/
+//    //******* OU SONT STOCKES LES ELEMENTS ET LES CROSSELEMENTS DANS LE DOCUMENT?                     ******/
+//
+//    //   _cylinderDirItem
+////    HEXA_NS::Cylinder *c     = NULL;
+////    HEXA_NS::Elements* c = NULL;
+////    CylinderItem      *cItem = NULL;
+////    ElementsItem* cItem = NULL;
+////    int nbCylinder = _hexaDocument->countCylinder();
+////    for ( int i=0; i<nbCylinder; ++i ){
+////        c = _hexaDocument->getCylinder(i);
+////        cItem = new CylinderItem(c, _entry);
+////        cItem = new ElementsItem(c, _entry);
+////        _cylinderDirItem->appendRow(cItem);
+////        _elementsDirItem->appendRow(cItem);
+////    }
+//
+//    //   _pipeDirItem
+////    HEXA_NS::Pipe *p     = NULL;
+////    HEXA_NS::Elements* p = NULL;
+////    PipeItem      *pItem = NULL;
+////    ElementsItem* pItem = NULL;
+////    int nbPipe = _hexaDocument->countPipe();
+////    for ( int i=0; i<nbPipe; ++i ){
+////        p = _hexaDocument->getPipe(i);
+////        pItem = new PipeItem(p);
+////        pItem = new ElementsItem(p, _entry);
+////        _pipeDirItem->appendRow(pItem);
+////        _elementsDirItem->appendRow(pItem);
+////    }
+//    //********************************************************************************************************
+//}
+
 void DocumentModel::fillGeometry()
 {
     PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
-    if (_hexaDocument == NULL || isEmpty() || pgsm == NULL)
+    if (_hexaDocument == NULL /*|| isEmpty()*/ || pgsm == NULL)
         return;
 
     HEXA_NS::NewShape* shape;
@@ -528,7 +613,7 @@ void DocumentModel::fillGeometry()
             shapeById[shapeName+","+QString::number(node->getIdent())] = node;
 
             // * update the compound of vertices
-            if (shape->getOrigin() == HEXA_NS::SH_CLOUD && !vertexCompound.IsNull())
+            if (shape->getOrigin() == HEXA_NS::SH_CLOUD && !vertexCompound.IsNull() && !node->getShape().IsNull())
                 compoundBuilder.Add(topo_shapes[shapeName], node->getShape());
         }
 
@@ -831,6 +916,7 @@ void DocumentModel::allowElementsSelectionOnly()
     _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
 }
 
+/**********************************************************
 void DocumentModel::allowCrossElementsSelectionOnly()
 {
     _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
@@ -846,6 +932,7 @@ void DocumentModel::allowCrossElementsSelectionOnly()
     _lawItemFlags   = Qt::ItemFlags( ~Qt::ItemIsEnabled );
     _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
 }
+ ********************************************************** */
 
 void DocumentModel::allowLawSelectionOnly()
 {
@@ -990,6 +1077,35 @@ QModelIndex DocumentModel::addEdgeVertices (const QModelIndex &i_v0, const QMode
     return edgeIndex;
 }
 
+QModelIndex DocumentModel::addEdgeVector( const QModelIndex &i_v, const QModelIndex &i_vec )
+{
+    QModelIndex edgeIndex;
+
+    HEXA_NS::Vertex* hv   = getHexaPtr<HEXA_NS::Vertex*>(i_v);
+    HEXA_NS::Vector* hvec = getHexaPtr<HEXA_NS::Vector*>(i_vec);
+
+    if (hv == NULL || hvec == NULL) return edgeIndex;
+
+    HEXA_NS::Edge* he = _hexaDocument->addEdgeVector( hv, hvec );
+    if ( BadElement(he) ) return edgeIndex;
+
+    HEXA_NS::Vertex* hv2 = he->getAval(); //the new vertex resulting from the creation of the edge
+    if (hv2 == NULL) return edgeIndex;
+
+    //ADD the edge in the treeview
+    EdgeItem* e = new EdgeItem(he, _entry);
+    _edgeDirItem->appendRow(e);
+    edgeIndex = e->index();
+
+    //The resulting Vertex
+    VertexItem* v = new VertexItem(hv2, _entry);
+    _vertexDirItem->appendRow(v);
+
+    emit patternDataChanged();
+
+    return edgeIndex;
+}
+
 QModelIndex DocumentModel::addQuadVertices( const QModelIndex &i_v0, const QModelIndex &i_v1,
         const QModelIndex &i_v2, const QModelIndex &i_v3 )
 { //CS_TODO : gestion erreur
@@ -1000,7 +1116,7 @@ QModelIndex DocumentModel::addQuadVertices( const QModelIndex &i_v0, const QMode
     HEXA_NS::Vertex* hv2 = getHexaPtr<HEXA_NS::Vertex*>(i_v2);
     HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(i_v3);
 
-    if ( hv0 and hv1 and hv2 and hv3 ){
+    if ( hv0 && hv1 && hv2 && hv3 ){
         HEXA_NS::Quad* hq = _hexaDocument->addQuadVertices( hv0, hv1, hv2, hv3 );
         if ( BadElement(hq) ) return quadIndex;
 
@@ -1023,7 +1139,7 @@ QModelIndex DocumentModel::addQuadEdges( const QModelIndex &e0, const QModelInde
     HEXA_NS::Edge* he2 = getHexaPtr<HEXA_NS::Edge*>(e2);
     HEXA_NS::Edge* he3 = getHexaPtr<HEXA_NS::Edge*>(e3);
 
-    if ( he0 and he1 and he2 and he3 ){
+    if ( he0 && he1 && he2 && he3 ){
 
         HEXA_NS::Quad* hq = _hexaDocument->addQuad( he0, he1, he2, he3 );
         if ( BadElement(hq) ) return quadIndex;
@@ -1387,8 +1503,6 @@ QModelIndex DocumentModel::makeScale( const QModelIndex& ielts, const QModelInde
     return iElts;
 }
 
-
-
 QModelIndex DocumentModel::makeRotation( const QModelIndex& ielts,
         const QModelIndex& iv,
         const QModelIndex& ivec, double angle )
@@ -1569,30 +1683,35 @@ bool DocumentModel::performSymmetryPlane( const QModelIndex& ielts,
     return false;
 }
 
-QModelIndex DocumentModel::replace( const QModelIndexList& iquadsPattern,
-        const QModelIndex& ip1, const QModelIndex& ic1,
-        const QModelIndex& ip2, const QModelIndex& ic2,
-        const QModelIndex& ip3, const QModelIndex& ic3 )
+QModelIndex DocumentModel::replace( const QModelIndexList& iquads_source,
+                                    const QModelIndexList& iquads_dest,
+                                    const QModelIndex& ip1_source, const QModelIndex& ic1_dest,
+                                    const QModelIndex& ip2_source, const QModelIndex& ic2_dest)
 {
     QModelIndex ielts;
 
-    HEXA_NS::Vertex* hp1 = getHexaPtr<HEXA_NS::Vertex*>(ip1);
-    HEXA_NS::Vertex* hc1 = getHexaPtr<HEXA_NS::Vertex*>(ic1);
-    HEXA_NS::Vertex* hp2 = getHexaPtr<HEXA_NS::Vertex*>(ip2);
-    HEXA_NS::Vertex* hc2 = getHexaPtr<HEXA_NS::Vertex*>(ic2);
-    HEXA_NS::Vertex* hp3 = getHexaPtr<HEXA_NS::Vertex*>(ip3);
-    HEXA_NS::Vertex* hc3 = getHexaPtr<HEXA_NS::Vertex*>(ic3);
+    HEXA_NS::Vertex* hp1 = getHexaPtr<HEXA_NS::Vertex*>(ip1_source);
+    HEXA_NS::Vertex* hp2 = getHexaPtr<HEXA_NS::Vertex*>(ip2_source);
+    HEXA_NS::Vertex* hc1 = getHexaPtr<HEXA_NS::Vertex*>(ic1_dest);
+    HEXA_NS::Vertex* hc2 = getHexaPtr<HEXA_NS::Vertex*>(ic2_dest);
 
-    HEXA_NS::Quads   hquads;
+    HEXA_NS::Quads   hquads_source, hquads_dest;
     HEXA_NS::Quad*   hquad = NULL;
-    foreach( const QModelIndex& iquad, iquadsPattern ){
+    foreach( const QModelIndex& iquad, iquads_source ){
         hquad = getHexaPtr<HEXA_NS::Quad*>(iquad);
-        hquads.push_back( hquad );
+        hquads_source.push_back( hquad );
     }
 
-    HEXA_NS::Elements* helts = _hexaDocument->replace( hquads,
-            hp1, hc1, hp2, hc2, hp3, hc3 );
-    if ( BadElement(helts) ) return ielts;
+    foreach( const QModelIndex& iquad, iquads_dest) {
+        hquad = getHexaPtr<HEXA_NS::Quad*>(iquad);
+        hquads_dest.push_back(hquad);
+    }
+
+    HEXA_NS::Elements* helts = _hexaDocument->replace( hquads_source,
+                                                            hquads_dest,
+                                                            hp1, hc1, hp2, hc2);
+    if ( BadElement(helts) )
+        return ielts;
 
     updateData();
     ElementsItem* eltsItem = new ElementsItem(helts);
@@ -2110,9 +2229,10 @@ QString DocumentModel::documentEntry()
 PatternDataModel::PatternDataModel( QObject * parent ) :
                               QSortFilterProxyModel( parent )
 {
-    QString dataRegExp = QString("(%1|%2|%3|%4|%5|%6|%7|%8)").
-            arg(VERTEX_TREE).arg(EDGE_TREE).arg(QUAD_TREE).arg(HEXA_TREE).
-            arg(VERTEX_DIR_TREE).arg(EDGE_DIR_TREE).arg(QUAD_DIR_TREE).arg(HEXA_DIR_TREE);
+    QString dataRegExp = QString("(%1|%2|%3|%4|%5|%6|%7|%8|%9|%10|%11|%12)").
+            arg(VERTEX_TREE).arg(EDGE_TREE).arg(QUAD_TREE).arg(HEXA_TREE).arg(VECTOR_TREE).arg(ELEMENTS_TREE).
+            arg(VERTEX_DIR_TREE).arg(EDGE_DIR_TREE).arg(QUAD_DIR_TREE).arg(HEXA_DIR_TREE).arg(VECTOR_DIR_TREE).
+            arg(ELEMENTS_DIR_TREE);
 
     setFilterRole(HEXA_TREE_ROLE);
     setFilterRegExp ( QRegExp(dataRegExp) );
@@ -2173,7 +2293,7 @@ Qt::ItemFlags PatternDataModel::flags(const QModelIndex &index) const
 
 QVariant PatternDataModel::headerData ( int section, Qt::Orientation orientation, int role ) const
 {
-    if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
+    if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
         return QVariant( "Data" );
     } else {
         return QSortFilterProxyModel::headerData ( section, orientation, role );
@@ -2191,50 +2311,50 @@ QStandardItem* PatternDataModel::itemFromIndex ( const QModelIndex & index ) con
     return item;
 }
 
-PatternBuilderModel::PatternBuilderModel( QObject * parent ) :
-                              QSortFilterProxyModel( parent )
-{
-    QString builderRegExp =QString("(%1|%2|%3|%4|%5|%6)").
-            arg(VECTOR_TREE).arg(ELEMENTS_TREE).
-            arg(CROSSELEMENTS_TREE).arg(VECTOR_DIR_TREE).arg(ELEMENTS_DIR_TREE).arg(CROSSELEMENTS_DIR_TREE);
-
-    setFilterRole( HEXA_TREE_ROLE );
-    setFilterRegExp ( QRegExp( builderRegExp ) );
-}
-
-PatternBuilderModel::~PatternBuilderModel()
-{
-}
+//PatternBuilderModel::PatternBuilderModel( QObject * parent ) :
+//                              QSortFilterProxyModel( parent )
+//{
+//    QString builderRegExp =QString("(%1|%2|%3|%4|%5|%6)").
+//            arg(VECTOR_TREE).arg(ELEMENTS_TREE).
+//            arg(CROSSELEMENTS_TREE).arg(VECTOR_DIR_TREE).arg(ELEMENTS_DIR_TREE).arg(CROSSELEMENTS_DIR_TREE);
+//
+//    setFilterRole( HEXA_TREE_ROLE );
+//    setFilterRegExp ( QRegExp( builderRegExp ) );
+//}
 
-Qt::ItemFlags PatternBuilderModel::flags(const QModelIndex &index) const
-{
-    Qt::ItemFlags flags;
+//PatternBuilderModel::~PatternBuilderModel()
+//{
+//}
 
-    DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
-    if ( m != NULL ){
-        flags = m->flags( mapToSource(index) );
-    }
-    return flags;
-}
+//Qt::ItemFlags PatternBuilderModel::flags(const QModelIndex &index) const
+//{
+//    Qt::ItemFlags flags;
+//
+//    DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
+//    if ( m != NULL ){
+//        flags = m->flags( mapToSource(index) );
+//    }
+//    return flags;
+//}
 
-QVariant PatternBuilderModel::headerData ( int section, Qt::Orientation orientation, int role ) const
-{
-    if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
-        return QVariant( "Builder" );
-    } else {
-        return QSortFilterProxyModel::headerData ( section, orientation, role );
-    }
-}
+//QVariant PatternBuilderModel::headerData ( int section, Qt::Orientation orientation, int role ) const
+//{
+//    if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
+//        return QVariant( "Builder" );
+//    } else {
+//        return QSortFilterProxyModel::headerData ( section, orientation, role );
+//    }
+//}
 
-QStandardItem* PatternBuilderModel::itemFromIndex ( const QModelIndex & index ) const
-{
-    QStandardItem *item = NULL;
-    DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
-    if ( m != NULL ){
-        item = m->itemFromIndex( mapToSource(index) );
-    }
-    return item;
-}
+//QStandardItem* PatternBuilderModel::itemFromIndex ( const QModelIndex & index ) const
+//{
+//    QStandardItem *item = NULL;
+//    DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
+//    if ( m != NULL ){
+//        item = m->itemFromIndex( mapToSource(index) );
+//    }
+//    return item;
+//}
 
 //====================================================================
 //              PatternGeomModel
@@ -2269,7 +2389,7 @@ Qt::ItemFlags PatternGeomModel::flags(const QModelIndex &index) const
 
 QVariant PatternGeomModel::headerData ( int section, Qt::Orientation orientation, int role ) const
 {
-    if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
+    if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
         return QVariant( "Geometry" );
     } else {
         return QSortFilterProxyModel::headerData ( section, orientation, role );
@@ -2314,7 +2434,7 @@ Qt::ItemFlags AssociationsModel::flags(const QModelIndex &index) const
 
 QVariant AssociationsModel::headerData ( int section, Qt::Orientation orientation, int role ) const
 {
-    if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
+    if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
         return QVariant( "Associations" );
     } else {
         return QSortFilterProxyModel::headerData ( section, orientation, role );
@@ -2357,7 +2477,7 @@ Qt::ItemFlags GroupsModel::flags(const QModelIndex &index) const
 
 QVariant GroupsModel::headerData ( int section, Qt::Orientation orientation, int role ) const
 {
-    if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
+    if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
         return QVariant( "Groups" );
     } else {
         return QSortFilterProxyModel::headerData ( section, orientation, role );
@@ -2410,7 +2530,7 @@ Qt::ItemFlags MeshModel::flags(const QModelIndex &index) const
 
 QVariant MeshModel::headerData ( int section, Qt::Orientation orientation, int role ) const
 {
-    if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
+    if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
         return QVariant( "Mesh" );
     } else {
         return QSortFilterProxyModel::headerData ( section, orientation, role );
@@ -2478,7 +2598,7 @@ QModelIndex DocumentModel::makeCartesianUni(const QModelIndex& icenter,
 
 QModelIndex DocumentModel::makeCartesian(const QModelIndex& icenter,
                                          const QModelIndex& ibase, const QModelIndex& ivec, const QModelIndex& iaxis,
-                                         vector<double>& radius, vector<double>& angles, vector<double>& heights)
+                                         std::vector<double>& radius, std::vector<double>& angles, std::vector<double>& heights)
 {
     QModelIndex result;
 
@@ -2536,7 +2656,7 @@ QModelIndex DocumentModel::makeSphereUni (QModelIndex& icenter,
 
 QModelIndex DocumentModel::makeSphere    (QModelIndex& icenter,
                                           QModelIndex& ivec_x, QModelIndex& ivec_z,
-                                          vector<double>& tray, vector<double>& tang, vector<double>& thaut)
+                                          std::vector<double>& tray, std::vector<double>& tang, std::vector<double>& thaut)
 {
     QModelIndex result;
 
@@ -2589,7 +2709,7 @@ QModelIndex DocumentModel::makeSphericalUni (QModelIndex& icenter,
 
 QModelIndex DocumentModel::makeSpherical    (QModelIndex& icenter,
                                              QModelIndex& ivec_x, QModelIndex& ivec_z,
-                                             vector<double>& rayon,
+                                             std::vector<double>& rayon,
                                              int crit)
 {
     QModelIndex result;
@@ -2646,7 +2766,7 @@ QModelIndex DocumentModel::makeRindUni (QModelIndex& icenter,
 
 QModelIndex DocumentModel::makeRind    (QModelIndex& icenter,
                                         QModelIndex& ivec_x, QModelIndex& ivec_z,
-                                        vector<double>& tray, vector<double>& tang, vector<double>& thaut)
+                                        std::vector<double>& tray, std::vector<double>& tang, std::vector<double>& thaut)
 {
     QModelIndex result;
 
@@ -2699,7 +2819,7 @@ QModelIndex DocumentModel::makeCylinderUni(QModelIndex& iorig, QModelIndex& ivec
 }
 
 QModelIndex DocumentModel::makeCylinder(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz,
-                                        vector<double>& tray, vector<double>& tang, vector<double>& thaut)
+                                        std::vector<double>& tray, std::vector<double>& tang, std::vector<double>& thaut)
 {
     QModelIndex result;
 
@@ -2773,7 +2893,7 @@ QModelIndex DocumentModel::makePipeUni(QModelIndex& iorig, QModelIndex& ivecx, Q
 }
 
 QModelIndex DocumentModel::makePipe(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz,
-                                    vector<double>& tray, vector<double>& tang, vector<double>& thaut)
+                                    std::vector<double>& tray, std::vector<double>& tang, std::vector<double>& thaut)
 {
     QModelIndex result;
 
@@ -2824,7 +2944,9 @@ QModelIndex DocumentModel::joinQuadUni(QModelIndex&  istart, QModelIndex& idest,
     HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(iv3);
     HEXA_NS::Vertex* hv4 = getHexaPtr<HEXA_NS::Vertex*>(iv4);
 
-    HEXA_NS::Elements* helts = _hexaDocument->joinQuadUni(hstart, hdest, hv1, hv2, hv3, hv4, nb);
+    // Be careful, the order of vertices is not the same in joinQuadUni of HexDocument_v6.cxx
+    // and corresponding python dump
+    HEXA_NS::Elements* helts = _hexaDocument->joinQuadUni(hstart, hdest, hv1, hv3, hv2, hv4, nb);
     if (BadElement(helts))
         return result;
 
@@ -2834,7 +2956,7 @@ QModelIndex DocumentModel::joinQuadUni(QModelIndex&  istart, QModelIndex& idest,
 }
 
 QModelIndex DocumentModel::joinQuad(QModelIndex&  istart, QModelIndex& idest, QModelIndex& iva1, QModelIndex& ivb1,
-                     QModelIndex& iva2, QModelIndex& ivb2, vector<double>& tlen)
+                     QModelIndex& iva2, QModelIndex& ivb2, std::vector<double>& tlen)
 {
     QModelIndex result;
 
@@ -2845,7 +2967,9 @@ QModelIndex DocumentModel::joinQuad(QModelIndex&  istart, QModelIndex& idest, QM
     HEXA_NS::Vertex* hva2 = getHexaPtr<HEXA_NS::Vertex*>(iva2);
     HEXA_NS::Vertex* hvb2 = getHexaPtr<HEXA_NS::Vertex*>(ivb2);
 
-    HEXA_NS::Elements* helts = _hexaDocument->joinQuad(hstart, hdest, hva1, hvb1, hva2, hvb2, tlen);
+    // Be careful, the order of vertices is not the same in joinQuadUni of HexDocument_v6.cxx
+    // and corresponding python dump
+    HEXA_NS::Elements* helts = _hexaDocument->joinQuad(hstart, hdest, hva1, hva2, hvb1, hvb2, tlen);
     if (BadElement(helts))
         return result;
 
@@ -2870,7 +2994,9 @@ QModelIndex DocumentModel::joinQuadsUni(QModelIndexList& istarts, QModelIndex& i
     HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(iv3);
     HEXA_NS::Vertex* hv4 = getHexaPtr<HEXA_NS::Vertex*>(iv4);
 
-    HEXA_NS::Elements* helts = _hexaDocument->joinQuadsUni(hstarts, hdest, hv1, hv2, hv3, hv4, nb);
+    // Be careful, the order of vertices is not the same in joinQuadUni of HexDocument_v6.cxx
+    // and corresponding python dump
+    HEXA_NS::Elements* helts = _hexaDocument->joinQuadsUni(hstarts, hdest, hv1, hv3, hv2, hv4, nb);
     if (BadElement(helts))
         return result;
 
@@ -2880,7 +3006,7 @@ QModelIndex DocumentModel::joinQuadsUni(QModelIndexList& istarts, QModelIndex& i
 }
 
 QModelIndex DocumentModel::joinQuads(QModelIndexList& istarts, QModelIndex& idest, QModelIndex& iva1, QModelIndex& ivb1,
-                                     QModelIndex& iva2, QModelIndex& ivb2, vector<double>& tlen)
+                                     QModelIndex& iva2, QModelIndex& ivb2, std::vector<double>& tlen)
 {
     QModelIndex result;
 
@@ -2895,7 +3021,9 @@ QModelIndex DocumentModel::joinQuads(QModelIndexList& istarts, QModelIndex& ides
     HEXA_NS::Vertex* hva2 = getHexaPtr<HEXA_NS::Vertex*>(iva2);
     HEXA_NS::Vertex* hvb2 = getHexaPtr<HEXA_NS::Vertex*>(ivb2);
 
-    HEXA_NS::Elements* helts = _hexaDocument->joinQuads(hstarts, hdest, hva1, hvb1, hva2, hvb2, tlen);
+    // Be careful, the order of vertices is not the same in joinQuadUni of HexDocument_v6.cxx
+    // and corresponding python dump
+    HEXA_NS::Elements* helts = _hexaDocument->joinQuads(hstarts, hdest, hva1, hva2, hvb1, hvb2, tlen);
     if (BadElement(helts))
         return result;
 
@@ -2924,7 +3052,7 @@ QModelIndex DocumentModel::revolutionQuadUni(QModelIndex& istart, QModelIndex& i
 }
 
 QModelIndex DocumentModel::revolutionQuad(QModelIndex& istart, QModelIndex& icenter, QModelIndex& iaxis,
-                                          vector<double>& angles)
+                                          std::vector<double>& angles)
 {
     QModelIndex result;
 
@@ -2964,7 +3092,7 @@ QModelIndex DocumentModel::revolutionQuadsUni(QModelIndexList& istarts, QModelIn
 }
 
 QModelIndex DocumentModel::revolutionQuads(QModelIndexList& istarts, QModelIndex& icenter, QModelIndex& iaxis,
-                                           vector<double>& angles)
+                                           std::vector<double>& angles)
 {
     QModelIndex result;
 
@@ -3017,7 +3145,7 @@ QModelIndex DocumentModel::extrudeQuadUni(QModelIndex& istart, QModelIndex& dv,
     return result;
 }
 
-QModelIndex DocumentModel::extrudeQuad(QModelIndex& istart, QModelIndex& dv, vector<double>& tlen)
+QModelIndex DocumentModel::extrudeQuad(QModelIndex& istart, QModelIndex& dv, std::vector<double>& tlen)
 {
     QModelIndex result;
 
@@ -3068,7 +3196,7 @@ QModelIndex DocumentModel::extrudeQuadsUni (QModelIndexList& istarts, QModelInde
     return result;
 }
 
-QModelIndex DocumentModel::extrudeQuads(QModelIndexList& istarts, QModelIndex& iaxis, vector<double>& tlen)
+QModelIndex DocumentModel::extrudeQuads(QModelIndexList& istarts, QModelIndex& iaxis, std::vector<double>& tlen)
 {
     QModelIndex result;
 
@@ -3102,7 +3230,7 @@ QModelIndex DocumentModel::cutUni(QModelIndex& iEdge, int nbre)
     return result;
 }
 
-QModelIndex DocumentModel::cut(QModelIndex& iEdge, vector<double>& tlen)
+QModelIndex DocumentModel::cut(QModelIndex& iEdge, std::vector<double>& tlen)
 {
     QModelIndex result;