1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //CS_TODO: relever les fonctions qui nécessitent updateData().
21 // addGroupElement à tester
25 #include "utilities.h"
27 #include "HEXABLOCKGUI_DocumentModel.hxx"
28 #include "HEXABLOCKGUI_DocumentItem.hxx"
30 #include "HEXABLOCKGUI.hxx"
31 #include "HEXABLOCKGUI_Trace.hxx"
33 #include "HexVertex.hxx"
34 #include "HexShape.hxx"
35 #include "HexSubShape.hxx"
36 #include "HexAssoEdge.hxx"
37 #include "HexBiCylinder.hxx"
40 #include <BRepBuilderAPI_MakeVertex.hxx>
42 #include "HEXABLOCKGUI_SalomeTools.hxx"
44 #include <SALOME_ListIO.hxx>
45 #include <SALOMEconfig.h>
46 #include <SUIT_ViewWindow.h>
50 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
57 //using namespace HEXA_NS;
58 using namespace HEXABLOCK::GUI;
60 /*****************************************************************
62 *****************************************************************/
63 // DocumentModel::DocumentModel(QObject * parent):
64 DocumentModel::DocumentModel(HEXA_NS::Document* docIn, const QString& entryIn, QObject * parent):
65 QStandardItemModel(parent),
66 _hexaFile( new QTemporaryFile() ),
67 _hexaDocument( docIn ),
69 // _hexaDocument( new HEXA_NS::Document("/tmp/doc.hex") ), //CS_TODO
71 _vertexDirItem( new QStandardItem(tr("TREE_ITEM_VERTEX")) ),
72 _edgeDirItem( new QStandardItem(tr("TREE_ITEM_EDGE")) ),
73 _quadDirItem( new QStandardItem(tr("TREE_ITEM_QUAD")) ),
74 _hexaDirItem( new QStandardItem(tr("TREE_ITEM_HEXA")) ),
76 _vectorDirItem( new QStandardItem(tr("TREE_ITEM_VECTOR")) ),
77 _elementsDirItem( new QStandardItem(tr("TREE_ITEM_ELEMENT")) ),
78 _crossElementsDirItem( new QStandardItem(tr("TREE_ITEM_CROSSELEMENT")) ),
80 _explicitShapesDirItem( new QStandardItem(tr("TREE_ITEM_EXPSHAPE")) ),
81 _implicitShapesDirItem( new QStandardItem(tr("TREE_ITEM_IMPSHAPE")) ),
82 _cloudOfPointsDirItem( new QStandardItem(tr("TREE_ITEM_CLOUD_OF_POINT")) ),
84 _groupDirItem( new QStandardItem(tr("TREE_ITEM_GROUP")) ),
86 _lawDirItem( new QStandardItem(tr("TREE_ITEM_LAW")) ),
87 _propagationDirItem( new QStandardItem(tr("TREE_ITEM_PROPAGATION")) ),
89 _vertexItemFlags( Qt::NoItemFlags ),
90 _edgeItemFlags( Qt::NoItemFlags ),
91 _quadItemFlags( Qt::NoItemFlags ),
92 _hexaItemFlags( Qt::NoItemFlags ),
93 _vectorItemFlags( Qt::NoItemFlags ),
94 _elementsItemFlags( Qt::NoItemFlags ),
95 _crossElementsItemFlags( Qt::NoItemFlags ),
97 _disallowEdition( false )
99 // setColumnCount( 4 ); //CS_TEST
100 if ( !_hexaDocument && _hexaFile->open() ){
101 _hexaDocument = new HEXA_NS::Document( _hexaFile->fileName().toLatin1() );
102 _hexaDocument->reorderFaces();
105 QStandardItem *parentItem = invisibleRootItem();
106 // parentItem->setData( QString::number( reinterpret_cast<intptr_t>(_hexaDocument) ), HEXA_ENTRY_ROLE );
107 parentItem->setData( _entry, HEXA_ENTRY_ROLE );
109 _vertexDirItem->setData( VERTEX_DIR_TREE, HEXA_TREE_ROLE );
110 _edgeDirItem->setData( EDGE_DIR_TREE, HEXA_TREE_ROLE );
111 _quadDirItem->setData( QUAD_DIR_TREE, HEXA_TREE_ROLE );
112 _hexaDirItem->setData( HEXA_DIR_TREE, HEXA_TREE_ROLE );
114 _vectorDirItem->setData( VECTOR_DIR_TREE, HEXA_TREE_ROLE );
115 _elementsDirItem->setData( ELEMENTS_DIR_TREE, HEXA_TREE_ROLE );
116 _crossElementsDirItem->setData( CROSSELEMENTS_DIR_TREE, HEXA_TREE_ROLE );
118 _explicitShapesDirItem->setData( EXPLICIT_SHAPES_DIR_TREE, HEXA_TREE_ROLE );
119 _implicitShapesDirItem->setData( IMPLICIT_SHAPES_DIR_TREE, HEXA_TREE_ROLE );
120 _cloudOfPointsDirItem->setData( CLOUD_OF_POINTS_DIR_TREE, HEXA_TREE_ROLE );
122 _groupDirItem->setData( GROUP_DIR_TREE, HEXA_TREE_ROLE );
124 //CS_TODO associations
126 _lawDirItem->setData( LAW_DIR_TREE, HEXA_TREE_ROLE );
127 _propagationDirItem->setData( PROPAGATION_DIR_TREE, HEXA_TREE_ROLE );
129 parentItem->appendRow(_vertexDirItem);
130 parentItem->appendRow(_edgeDirItem);
131 parentItem->appendRow(_quadDirItem);
132 parentItem->appendRow(_hexaDirItem);
134 parentItem->appendRow(_vectorDirItem);
135 parentItem->appendRow(_elementsDirItem);
136 parentItem->appendRow(_crossElementsDirItem);
138 parentItem->appendRow(_explicitShapesDirItem);
139 parentItem->appendRow(_implicitShapesDirItem);
141 parentItem->appendRow(_groupDirItem);
142 parentItem->appendRow(_lawDirItem);
143 parentItem->appendRow(_propagationDirItem);
146 DocumentModel::~DocumentModel()
148 if (_hexaDocument != NULL)
149 delete _hexaDocument;
151 if (_hexaFile != NULL)
155 void DocumentModel::setName(const QString& name)
157 _hexaDocument->setName( name.toLocal8Bit().constData() );
158 emit nameChanged(QString(_hexaDocument->getName()));
161 HEXA_NS::EltBase* DocumentModel::getHexaPtr(const QModelIndex& iElt)
163 HEXA_NS::EltBase *elt = NULL;
164 switch ( /*data(iElt, HEXA_TREE_ROLE).toInt()*/iElt.data(HEXA_TREE_ROLE).toInt() ){
165 case VERTEX_TREE : elt = getHexaPtr<HEXA_NS::Vertex*>(iElt); break;
166 case EDGE_TREE : elt = getHexaPtr<HEXA_NS::Edge*>(iElt); break;
167 case QUAD_TREE : elt = getHexaPtr<HEXA_NS::Quad*>(iElt); break;
168 case HEXA_TREE : elt = getHexaPtr<HEXA_NS::Hexa*>(iElt); break;
169 case VECTOR_TREE : elt = getHexaPtr<HEXA_NS::Vector*>(iElt); break;
170 case ELEMENTS_TREE : elt = getHexaPtr<HEXA_NS::Elements*>(iElt); break;
171 // case CROSSELEMENTS_TREE : elt = getHexaPtr<HEXA_NS::CrossElements*>(iElt); break;
172 case GEOMSHAPE_TREE: elt = getHexaPtr<HEXA_NS::NewShape*>(iElt); break;
173 case GEOMPOINT_TREE: elt = getHexaPtr<HEXA_NS::VertexShape*>(iElt); break;
174 case GEOMEDGE_TREE: elt = getHexaPtr<HEXA_NS::EdgeShape*>(iElt); break;
175 case GEOMFACE_TREE: elt = getHexaPtr<HEXA_NS::FaceShape*>(iElt); break;
180 //get the number of elements of type 'eltType' in the document
181 int DocumentModel::getNbrElt(HEXA_NS::EnumElt eltType)
183 if (_hexaDocument == NULL) return 0;
185 return _hexaDocument->getNbrElt(eltType);
188 //get the number of elements of type 'eltType' used in the document
189 int DocumentModel::getNbrUsedElt(HEXA_NS::EnumElt eltType)
191 if (_hexaDocument == NULL) return 0;
194 case HEXA_NS::EL_VERTEX:
195 return _hexaDocument->countUsedVertex();
196 case HEXA_NS::EL_EDGE:
197 return _hexaDocument->countUsedEdge();
198 case HEXA_NS::EL_QUAD:
199 return _hexaDocument->countUsedQuad();
200 case HEXA_NS::EL_HEXA:
201 return _hexaDocument->countUsedHexa();
206 //associate a shape to the current document
207 bool DocumentModel::addShape(TopoDS_Shape& aShape, QString& name, bool publish)
209 if (aShape.IsNull() || name.isEmpty())
211 bool ok = (_hexaDocument != NULL ? _hexaDocument->addShape(aShape, name.toStdString().c_str()) != NULL : false);
213 // * publish the shape in the study
216 HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance();
219 QMap<QString, TopoDS_Shape> topo_shapes;
220 topo_shapes[name] = aShape;
221 module->addInStudy(topo_shapes, docShapesEntry, docShapesName);
232 //get the number of unused elements of type 'eltType' in the document
233 int DocumentModel::getNbrUnusedElt(HEXA_NS::EnumElt eltType)
235 if (_hexaDocument == NULL)
238 return getNbrElt(eltType) - getNbrUsedElt(eltType);
242 //Load the current Document
243 void DocumentModel::load()
245 if (_hexaDocument == NULL)
248 load(_hexaDocument->getName());
252 void DocumentModel::load( const QString& xmlFileName ) // Fill Data
254 _hexaDocument->loadXml(xmlFileName.toLocal8Bit().constData() );
264 emit patternDataChanged();
267 bool DocumentModel::isEmpty() const
269 if (_hexaDocument == NULL) return true;
270 return _hexaDocument->isEmpty();
273 void DocumentModel::save( const QString& xmlFileName )
275 _hexaDocument->save( xmlFileName.toLocal8Bit().constData() );
278 QString DocumentModel::getName()
280 return _hexaDocument->getName();
283 void DocumentModel::updateData()
289 emit patternDataChanged();
292 void DocumentModel::updateGeomTree()
298 QModelIndex DocumentModel::addElementsToTree(HEXA_NS::Elements* helts, QStandardItem* tree)
300 QModelIndex eltIndex;
301 if (helts == NULL || tree == NULL)
305 ElementsItem* eltsItem = new ElementsItem(helts);
306 tree->appendRow(eltsItem);
308 return eltsItem->index();
311 void DocumentModel::refresh()
322 emit patternDataChanged();
325 void DocumentModel::clearAll()
335 void DocumentModel::clearData()
337 _vertexDirItem->removeRows( 0, _vertexDirItem->rowCount() );
338 _edgeDirItem->removeRows(0, _edgeDirItem->rowCount() );
339 _quadDirItem->removeRows(0, _quadDirItem->rowCount() );
340 _hexaDirItem->removeRows(0, _hexaDirItem->rowCount() );
342 _vectorDirItem->removeRows(0, _vectorDirItem->rowCount() );
343 _elementsDirItem->removeRows(0, _elementsDirItem->rowCount() );
344 _crossElementsDirItem->removeRows(0, _crossElementsDirItem->rowCount() );
348 //void DocumentModel::clearBuilder()
350 // _vectorDirItem->removeRows(0, _vectorDirItem->rowCount() );
351 // _elementsDirItem->removeRows(0, _elementsDirItem->rowCount() );
352 // _crossElementsDirItem->removeRows(0, _crossElementsDirItem->rowCount() );
355 void DocumentModel::clearGeometry()
357 _explicitShapesDirItem->removeRows(0, _explicitShapesDirItem->rowCount() );
358 _implicitShapesDirItem->removeRows(0, _implicitShapesDirItem->rowCount() );
359 _cloudOfPointsDirItem->removeRows(0, _cloudOfPointsDirItem->rowCount() );
362 void DocumentModel::clearAssociation()
367 void DocumentModel::clearGroups()
369 _groupDirItem->removeRows(0, _groupDirItem->rowCount() );
372 void DocumentModel::clearMesh()
374 _lawDirItem->removeRows(0, _lawDirItem->rowCount() );
375 _propagationDirItem->removeRows(0, _propagationDirItem->rowCount() );
379 void DocumentModel::fillData()
381 PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
384 pdsm->clearHighlightedItems();
387 HEXA_NS::Vertex *v = NULL;
388 VertexItem *vItem = NULL;
389 int nbVertex = _hexaDocument->countVertex();
390 for ( int i=0; i<nbVertex; ++i ){
391 v = _hexaDocument->getVertex(i);
392 vItem = new VertexItem(v, _entry);
393 _vertexDirItem->appendRow(vItem);
396 HEXA_NS::Edge *e = NULL;
397 EdgeItem *eItem = NULL;
398 int nbEdge = _hexaDocument->countEdge();
399 for ( int i=0; i<nbEdge; ++i ){
400 e = _hexaDocument->getEdge(i);
401 eItem = new EdgeItem(e, _entry);
402 _edgeDirItem->appendRow(eItem);
405 HEXA_NS::Quad *q = NULL;
406 QuadItem *qItem = NULL;
407 int nbQuad = _hexaDocument->countQuad();
408 for ( int i=0; i<nbQuad; ++i ){
409 q = _hexaDocument->getQuad(i);
410 qItem = new QuadItem(q, _entry);
411 _quadDirItem->appendRow(qItem);
414 HEXA_NS::Hexa *h = NULL;
415 HexaItem *hItem = NULL;
416 int nbHexa = _hexaDocument->countHexa();
417 for ( int i=0; i<nbHexa; ++i ){
418 h = _hexaDocument->getHexa(i);
419 hItem = new HexaItem(h, _entry);
420 _hexaDirItem->appendRow(hItem);
423 // +++++ Builder ++++++++++++++++++++++++++++++
425 HEXA_NS::Vector *vec = NULL;
426 VectorItem *vecItem = NULL;
427 int nbVector = _hexaDocument->countVector();
428 for ( int i=0; i<nbVector; ++i ){
429 vec = _hexaDocument->getVector(i);
430 vecItem = new VectorItem(vec);
431 _vectorDirItem->appendRow(vecItem);
434 //******* A VOIR AVEC ALAIN POUR LE REMPLISSAGE DE L'ARBRE ELEMENTS ET CROSSELEMENTS (ByCylinder) *******/
435 //******* OU SONT STOCKES LES ELEMENTS ET LES CROSSELEMENTS DANS LE DOCUMENT? ******/
438 // HEXA_NS::Cylinder *c = NULL;
439 // HEXA_NS::Elements* c = NULL;
440 // CylinderItem *cItem = NULL;
441 // ElementsItem* cItem = NULL;
442 // int nbCylinder = _hexaDocument->countCylinder();
443 // for ( int i=0; i<nbCylinder; ++i ){
444 // c = _hexaDocument->getCylinder(i);
445 // cItem = new CylinderItem(c, _entry);
446 // cItem = new ElementsItem(c, _entry);
447 // _cylinderDirItem->appendRow(cItem);
448 // _elementsDirItem->appendRow(cItem);
452 // HEXA_NS::Pipe *p = NULL;
453 // HEXA_NS::Elements* p = NULL;
454 // PipeItem *pItem = NULL;
455 // ElementsItem* pItem = NULL;
456 // int nbPipe = _hexaDocument->countPipe();
457 // for ( int i=0; i<nbPipe; ++i ){
458 // p = _hexaDocument->getPipe(i);
459 // pItem = new PipeItem(p);
460 // pItem = new ElementsItem(p, _entry);
461 // _pipeDirItem->appendRow(pItem);
462 // _elementsDirItem->appendRow(pItem);
464 //********************************************************************************************************
468 //void DocumentModel::fillBuilder()
470 // HEXA_NS::Vector *v = NULL;
471 // VectorItem *vItem = NULL;
472 // int nbVector = _hexaDocument->countVector();
473 // for ( int i=0; i<nbVector; ++i ){
474 // v = _hexaDocument->getVector(i);
475 // vItem = new VectorItem(v);
476 // _vectorDirItem->appendRow(vItem);
479 // //******* A VOIR AVEC ALAIN POUR LE REMPLISSAGE DE L'ARBRE ELEMENTS ET CROSSELEMENTS (ByCylinder) *******/
480 // //******* OU SONT STOCKES LES ELEMENTS ET LES CROSSELEMENTS DANS LE DOCUMENT? ******/
482 // // _cylinderDirItem
483 //// HEXA_NS::Cylinder *c = NULL;
484 //// HEXA_NS::Elements* c = NULL;
485 //// CylinderItem *cItem = NULL;
486 //// ElementsItem* cItem = NULL;
487 //// int nbCylinder = _hexaDocument->countCylinder();
488 //// for ( int i=0; i<nbCylinder; ++i ){
489 //// c = _hexaDocument->getCylinder(i);
490 //// cItem = new CylinderItem(c, _entry);
491 //// cItem = new ElementsItem(c, _entry);
492 //// _cylinderDirItem->appendRow(cItem);
493 //// _elementsDirItem->appendRow(cItem);
497 //// HEXA_NS::Pipe *p = NULL;
498 //// HEXA_NS::Elements* p = NULL;
499 //// PipeItem *pItem = NULL;
500 //// ElementsItem* pItem = NULL;
501 //// int nbPipe = _hexaDocument->countPipe();
502 //// for ( int i=0; i<nbPipe; ++i ){
503 //// p = _hexaDocument->getPipe(i);
504 //// pItem = new PipeItem(p);
505 //// pItem = new ElementsItem(p, _entry);
506 //// _pipeDirItem->appendRow(pItem);
507 //// _elementsDirItem->appendRow(pItem);
509 // //********************************************************************************************************
512 void DocumentModel::fillGeometry()
514 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
515 if (_hexaDocument == NULL || isEmpty() || pgsm == NULL)
518 HEXA_NS::NewShape* shape;
519 HEXA_NS::VertexShape* node;
520 HEXA_NS::EdgeShape* line;
521 HEXA_NS::FaceShape* face;
522 TopoDS_Compound vertexCompound;
523 BRep_Builder compoundBuilder;
525 // * fill the shape tree
528 pgsm->clearHighlightedItems();
529 QMap<QString, TopoDS_Shape> topo_shapes;
530 int nbShapes = _hexaDocument->countShape();
531 for (int i=0; i < nbShapes; ++i)
533 shape = _hexaDocument->getShape(i);
534 QString shapeName = shape->getName();
535 if (!docShapesEntry.contains(shapeName))
537 if (shape->getOrigin() == HEXA_NS::SH_CLOUD)
539 compoundBuilder.MakeCompound(vertexCompound);
540 topo_shapes[shapeName] = vertexCompound;
543 topo_shapes[shapeName] = shape->getShape();
546 GeomShapeItem* shItem = new GeomShapeItem(shape);
547 if (shape->getOrigin() == HEXA_NS::SH_IMPORT)
549 _explicitShapesDirItem->appendRow(shItem);
552 _implicitShapesDirItem->appendRow(shItem);
554 //add vertices to the tree
555 QStandardItem* geomPointDirItem = NULL;
556 if (shape->getOrigin() != HEXA_NS::SH_CLOUD)
558 geomPointDirItem = new QStandardItem(tr("TREE_ITEM_VERTEX"));
559 geomPointDirItem->setData( GEOMPOINT_DIR_TREE, HEXA_TREE_ROLE );
561 if (geomPointDirItem != NULL)
562 shItem->appendRow(geomPointDirItem);
563 int nbVertexShape = shape->countVertex();
564 for (int j=0; j < nbVertexShape; ++j)
566 node = shape->getVertexShape(j);
567 GeomPointItem* gPointItem = new GeomPointItem(node);
568 if (geomPointDirItem != NULL)
569 geomPointDirItem->appendRow(gPointItem);
571 shItem->appendRow(gPointItem);
572 shapeById[shapeName+","+QString::number(node->getIdent())] = node;
574 // * update the compound of vertices
575 if (shape->getOrigin() == HEXA_NS::SH_CLOUD && !vertexCompound.IsNull())
576 compoundBuilder.Add(topo_shapes[shapeName], node->getShape());
579 if (shape->getOrigin() == HEXA_NS::SH_CLOUD)
580 continue; // * it's a cloud of points, there's no edges and no quads to fill
582 //add edges to the tree
583 QStandardItem* geomEdgeDirItem = new QStandardItem(tr("TREE_ITEM_EDGE"));
584 geomEdgeDirItem->setData( GEOMEDGE_DIR_TREE, HEXA_TREE_ROLE );
585 shItem->appendRow(geomEdgeDirItem);
586 int nbEdgeShape = shape->countEdge();
587 for (int j = 0; j < nbEdgeShape; ++j)
589 line = shape->getEdgeShape(j);
590 GeomEdgeItem* gEdgeItem = new GeomEdgeItem(line);
591 geomEdgeDirItem->appendRow(gEdgeItem);
592 shapeById[shapeName+","+QString::number(line->getIdent())] = line;
595 //add faces to the tree
596 QStandardItem* geomFaceDirItem = new QStandardItem(tr("TREE_ITEM_QUAD"));
597 geomFaceDirItem->setData( GEOMFACE_DIR_TREE, HEXA_TREE_ROLE );
598 shItem->appendRow(geomFaceDirItem);
599 int nbFaceShape = shape->countFace();
600 for (int j = 0; j < nbFaceShape; ++j)
602 face = shape->getFaceShape(j);
603 GeomFaceItem* gFaceItem = new GeomFaceItem(face);
604 geomFaceDirItem->appendRow(gFaceItem);
605 shapeById[shapeName+","+QString::number(face->getIdent())] = face;
609 if (topo_shapes.size() == 0)
613 HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance();
615 module->addInStudy(topo_shapes, docShapesEntry, docShapesName);
618 void DocumentModel::fillAssociation()
622 //------------------------------------------- NEW ITEMS
623 //void DocumentModel::fillGroups()
625 // HEXA_NS::Group *g = NULL;
626 // GroupItem *gItem = NULL;
627 // int nbGroup = _hexaDocument->countGroup();
628 // for ( int i=0; i<nbGroup; ++i ){
629 // g = _hexaDocument->getGroup(i);
630 // gItem = new GroupItem(g, _entry);
631 // _groupDirItem->appendRow(gItem);
635 //void DocumentModel::fillMesh()
637 // HEXA_NS::Law *l = NULL;
638 // LawItem *lItem = NULL;
639 // int nbLaw = _hexaDocument->countLaw();
640 // for ( int i=0; i<nbLaw; ++i ){
641 // l = _hexaDocument->getLaw(i);
642 // lItem = new LawItem(l);
643 // _lawDirItem->appendRow(lItem);
646 // HEXA_NS::Propagation *p = NULL;
647 // PropagationItem *pItem = NULL;
648 // int nbPropagation = _hexaDocument->countPropagation();
649 // for ( int i=0; i<nbPropagation; ++i ){
650 // p = _hexaDocument->getPropagation(i);
651 // pItem = new PropagationItem(p, _entry);
652 // pItem->setText(QString("Propagation%1").arg(i) );
653 // _propagationDirItem->appendRow(pItem);
656 //----------------------------------------------- END NEW ITEMS
658 void DocumentModel::fillGroups()
660 HEXA_NS::Group *g = NULL;
661 GroupItem *gItem = NULL;
662 int nbGroup = _hexaDocument->countGroup();
663 for ( int i=0; i<nbGroup; ++i ){
664 g = _hexaDocument->getGroup(i);
665 //std::cout<<"getGroup => "<< i << std::endl;
666 gItem = new GroupItem(g);
667 gItem->setData( _entry, HEXA_DOC_ENTRY_ROLE );
668 _groupDirItem->appendRow(gItem);
672 void DocumentModel::fillMesh()
675 HEXA_NS::Law *l = NULL;
676 LawItem *lItem = NULL;
677 int nbLaw = _hexaDocument->countLaw();
678 for ( int i=0; i<nbLaw; ++i ){
679 l = _hexaDocument->getLaw(i);
680 lItem = new LawItem(l);
681 _lawDirItem->appendRow(lItem);
684 // _propagationDirItem
685 HEXA_NS::Propagation *p = NULL;
686 PropagationItem *pItem = NULL;
687 int nbPropagation = _hexaDocument->countPropagation();
688 for ( int i=0; i<nbPropagation; ++i ){
689 p = _hexaDocument->getPropagation(i);
690 pItem = new PropagationItem(p);
691 pItem->setText(QString("Propagation%1").arg(i) );
692 pItem->setData( _entry, HEXA_DOC_ENTRY_ROLE );
693 _propagationDirItem->appendRow(pItem);
697 HEXA_NS::Hexa* DocumentModel::getQuadHexa(HEXA_NS::Quad* quad)
700 int nbHexa = _hexaDocument->countHexa();
701 for ( int i=0; i<nbHexa; ++i ){
702 hexa = _hexaDocument->getHexa(i);
703 if (hexa->findQuad(quad) > -1) return hexa;
709 Qt::ItemFlags DocumentModel::flags(const QModelIndex &index) const
713 if (!index.isValid()) return Qt::ItemIsEnabled;
715 if ( _disallowEdition ){
716 return QAbstractItemModel::flags(index) | Qt::ItemFlags( ~Qt::ItemIsEditable );
718 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
722 void DocumentModel::allowEdition()
724 _disallowEdition = false;
727 void DocumentModel::disallowEdition()
729 _disallowEdition = true;
732 void DocumentModel::allowDataSelectionOnly()
734 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
735 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
736 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
737 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
739 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
740 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
741 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
743 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
744 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
745 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
748 void DocumentModel::allowVertexSelectionOnly()
750 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable);
751 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
752 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
753 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
755 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
756 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
757 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
759 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
760 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
761 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
763 // emit layoutChanged();
766 void DocumentModel::allowEdgeSelectionOnly()
768 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
769 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
770 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
771 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
773 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
774 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
775 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
777 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
778 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
779 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
782 void DocumentModel::allowQuadSelectionOnly()
784 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
785 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
786 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
787 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
789 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
790 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
791 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
793 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
794 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
795 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
798 void DocumentModel::allowHexaSelectionOnly()
800 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
801 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
802 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
803 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
805 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
806 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
807 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
809 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
810 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
811 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
814 void DocumentModel::allowVectorSelectionOnly()
816 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
817 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
818 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
819 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
821 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
822 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
823 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
825 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
826 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
827 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
830 void DocumentModel::allowCylinderSelectionOnly()
832 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
833 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
834 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
835 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
837 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
838 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
839 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
841 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
842 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
843 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
846 void DocumentModel::allowPipeSelectionOnly()
848 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
849 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
850 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
851 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
853 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
854 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
855 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
857 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
858 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
859 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
862 void DocumentModel::allowElementsSelectionOnly()
864 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
865 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
866 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
867 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
869 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
870 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
871 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
873 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
874 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
875 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
878 /**********************************************************
879 void DocumentModel::allowCrossElementsSelectionOnly()
881 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
882 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
883 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
884 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
886 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
887 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
888 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
890 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
891 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
892 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
894 ********************************************************** */
896 void DocumentModel::allowLawSelectionOnly()
898 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
899 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
900 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
901 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
903 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
904 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
905 _crossElementsItemFlags = Qt::ItemFlags( Qt::ItemIsEnabled );
907 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
908 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
909 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
913 void DocumentModel::setName( const QModelIndex& iElt, const QString& name )
915 HEXA_NS::EltBase *elt = NULL;
917 switch ( data(iElt, HEXA_TREE_ROLE).toInt() ){
920 HEXA_NS::Group* grp = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Group* >();
921 grp->setName( name.toLatin1().data() );
926 HEXA_NS::Law* l = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Law* >();
927 l->setName( name.toLatin1().data() );
930 // case PROPAGATION_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Propagation* >(); break;
931 default: elt = getHexaPtr(iElt);
934 if ( elt != NULL ) elt->setName( name.toStdString() );
935 setData( iElt, name );
939 bool DocumentModel::clearEltAssociations( const QModelIndex& iElt )
942 HEXA_NS::EltBase *elt = getHexaPtr(iElt);
945 elt->clearAssociation();
946 setData( iElt, QVariant(), HEXA_ASSOC_ENTRY_ROLE );
953 void DocumentModel::clearAssociation(HEXA_NS::EnumElt& eltType)
955 if (_hexaDocument != NULL)
956 _hexaDocument->clearAssociation(eltType);
959 HEXA_NS::Vertex* vertex;
964 if (HEXABLOCKGUI::currentDocGView == NULL) return;
965 PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
966 PatternDataModel* pdm = HEXABLOCKGUI::currentDocGView->getPatternDataModel();
967 if (pdsm == NULL || pdm == NULL) return;
969 //update associations in the model
970 if (eltType == HEXA_NS::EL_VERTEX)
972 nbElts = _hexaDocument->countVertex();
973 for (int i = 0; i < nbElts; ++i)
975 vertex = _hexaDocument->getVertex(i);
976 iElt = pdm->mapToSource(pdsm->indexBy(HEXA_DATA_ROLE, QVariant::fromValue(vertex)));
978 setData( iElt, QVariant(), HEXA_ASSOC_ENTRY_ROLE );
981 else if (eltType == HEXA_NS::EL_EDGE)
983 nbElts = _hexaDocument->countEdge();
984 for (int i = 0; i < nbElts; ++i)
986 edge = _hexaDocument->getEdge(i);
987 iElt = pdm->mapToSource(pdsm->indexBy(HEXA_DATA_ROLE, QVariant::fromValue(edge)));
989 setData( iElt, QVariant(), HEXA_ASSOC_ENTRY_ROLE );
992 else if (eltType == HEXA_NS::EL_QUAD)
994 nbElts = _hexaDocument->countQuad();
995 for (int i = 0; i < nbElts; ++i)
997 quad = _hexaDocument->getQuad(i);
998 iElt = pdm->mapToSource(pdsm->indexBy(HEXA_DATA_ROLE, QVariant::fromValue(quad)));
1000 setData( iElt, QVariant(), HEXA_ASSOC_ENTRY_ROLE );
1006 QModelIndex DocumentModel::addVertex( double x, double y, double z )
1008 QModelIndex vertexIndex;
1010 HEXA_NS::Vertex* hv = _hexaDocument->addVertex(x, y, z);
1011 if (BadElement(hv)) return vertexIndex;
1013 VertexItem* v = new VertexItem(hv, _entry);
1014 _vertexDirItem->appendRow(v);
1015 vertexIndex = v->index();
1016 emit patternDataChanged();
1021 QModelIndex DocumentModel::addEdgeVertices (const QModelIndex &i_v0, const QModelIndex &i_v1 )
1023 QModelIndex edgeIndex;
1025 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(i_v0);
1026 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(i_v1);
1028 HEXA_NS::Edge* he = _hexaDocument->addEdge( hv0, hv1 );
1029 if ( BadElement(he) ) return edgeIndex;
1031 EdgeItem* e = new EdgeItem(he, _entry);
1032 _edgeDirItem->appendRow(e);
1033 edgeIndex = e->index();
1034 emit patternDataChanged();
1039 QModelIndex DocumentModel::addEdgeVector( const QModelIndex &i_v, const QModelIndex &i_vec )
1041 QModelIndex edgeIndex;
1043 HEXA_NS::Vertex* hv = getHexaPtr<HEXA_NS::Vertex*>(i_v);
1044 HEXA_NS::Vector* hvec = getHexaPtr<HEXA_NS::Vector*>(i_vec);
1046 if (hv == NULL || hvec == NULL) return edgeIndex;
1048 HEXA_NS::Edge* he = _hexaDocument->addEdgeVector( hv, hvec );
1049 if ( BadElement(he) ) return edgeIndex;
1051 HEXA_NS::Vertex* hv2 = he->getAval(); //the new vertex resulting from the creation of the edge
1052 if (hv2 == NULL) return edgeIndex;
1054 //ADD the edge in the treeview
1055 EdgeItem* e = new EdgeItem(he, _entry);
1056 _edgeDirItem->appendRow(e);
1057 edgeIndex = e->index();
1059 //The resulting Vertex
1060 VertexItem* v = new VertexItem(hv2, _entry);
1061 _vertexDirItem->appendRow(v);
1063 emit patternDataChanged();
1068 QModelIndex DocumentModel::addQuadVertices( const QModelIndex &i_v0, const QModelIndex &i_v1,
1069 const QModelIndex &i_v2, const QModelIndex &i_v3 )
1070 { //CS_TODO : gestion erreur
1071 QModelIndex quadIndex;
1073 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(i_v0);
1074 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(i_v1);
1075 HEXA_NS::Vertex* hv2 = getHexaPtr<HEXA_NS::Vertex*>(i_v2);
1076 HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(i_v3);
1078 if ( hv0 and hv1 and hv2 and hv3 ){
1079 HEXA_NS::Quad* hq = _hexaDocument->addQuadVertices( hv0, hv1, hv2, hv3 );
1080 if ( BadElement(hq) ) return quadIndex;
1082 QuadItem* q = new QuadItem(hq, _entry);
1083 _quadDirItem->appendRow(q);
1084 quadIndex = q->index();
1085 emit patternDataChanged();
1091 QModelIndex DocumentModel::addQuadEdges( const QModelIndex &e0, const QModelIndex &e1,
1092 const QModelIndex &e2, const QModelIndex &e3 )
1094 QModelIndex quadIndex;
1096 HEXA_NS::Edge* he0 = getHexaPtr<HEXA_NS::Edge*>(e0);
1097 HEXA_NS::Edge* he1 = getHexaPtr<HEXA_NS::Edge*>(e1);
1098 HEXA_NS::Edge* he2 = getHexaPtr<HEXA_NS::Edge*>(e2);
1099 HEXA_NS::Edge* he3 = getHexaPtr<HEXA_NS::Edge*>(e3);
1101 if ( he0 and he1 and he2 and he3 ){
1103 HEXA_NS::Quad* hq = _hexaDocument->addQuad( he0, he1, he2, he3 );
1104 if ( BadElement(hq) ) return quadIndex;
1106 QuadItem* q = new QuadItem(hq, _entry);
1107 _quadDirItem->appendRow(q);
1108 quadIndex = q->index();
1109 emit patternDataChanged();
1115 QModelIndex DocumentModel::addHexaVertices(
1116 const QModelIndex &iv0, const QModelIndex &iv1,
1117 const QModelIndex &iv2, const QModelIndex &iv3,
1118 const QModelIndex &iv4, const QModelIndex &iv5,
1119 const QModelIndex &iv6, const QModelIndex &iv7 )
1123 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(iv0);
1124 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
1125 HEXA_NS::Vertex* hv2 = getHexaPtr<HEXA_NS::Vertex*>(iv2);
1126 HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(iv3);
1127 HEXA_NS::Vertex* hv4 = getHexaPtr<HEXA_NS::Vertex*>(iv4);
1128 HEXA_NS::Vertex* hv5 = getHexaPtr<HEXA_NS::Vertex*>(iv5);
1129 HEXA_NS::Vertex* hv6 = getHexaPtr<HEXA_NS::Vertex*>(iv6);
1130 HEXA_NS::Vertex* hv7 = getHexaPtr<HEXA_NS::Vertex*>(iv7);
1132 HEXA_NS::Hexa* hh = _hexaDocument->addHexaVertices( hv0, hv1, hv2, hv3,
1133 hv4, hv5, hv6, hv7 );
1135 if ( BadElement(hh) ) return iHexa;
1137 HexaItem* h = new HexaItem(hh, _entry);
1138 _hexaDirItem->appendRow(h);
1140 emit patternDataChanged();
1145 QModelIndex DocumentModel::addHexaQuad( const QModelIndex &i_q0, const QModelIndex &i_q1,
1146 const QModelIndex &i_q2,const QModelIndex &i_q3, const QModelIndex &i_q4, const QModelIndex &i_q5 )
1147 { //CS_TODO : gestion erreur
1148 QModelIndex hexaIndex;
1150 HEXA_NS::Quad* hq0 = getHexaPtr<HEXA_NS::Quad*>(i_q0);
1151 HEXA_NS::Quad* hq1 = getHexaPtr<HEXA_NS::Quad*>(i_q1);
1152 HEXA_NS::Quad* hq2 = getHexaPtr<HEXA_NS::Quad*>(i_q2);
1153 HEXA_NS::Quad* hq3 = getHexaPtr<HEXA_NS::Quad*>(i_q3);
1154 HEXA_NS::Quad* hq4 = getHexaPtr<HEXA_NS::Quad*>(i_q4);
1155 HEXA_NS::Quad* hq5 = getHexaPtr<HEXA_NS::Quad*>(i_q5);
1157 HEXA_NS::Hexa* hh = _hexaDocument->addHexa( hq0, hq1, hq2, hq3, hq4, hq5 );
1158 if ( BadElement(hh) ) return hexaIndex;
1160 HexaItem* h = new HexaItem(hh, _entry);
1161 _hexaDirItem->appendRow(h);
1162 hexaIndex = h->index();
1163 emit patternDataChanged();
1168 QModelIndex DocumentModel::addHexaQuads( const QModelIndexList &iquads)
1170 QModelIndex hexaIndex;
1172 HEXA_NS::Hexa* hh = NULL;
1173 HEXA_NS::Quad* hq0, *hq1, *hq2, *hq3, *hq4, *hq5 = NULL;
1175 hq0 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(0));
1176 hq1 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(1));
1177 hq2 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(2));
1178 hq3 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(3));
1179 hq4 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(4));
1180 hq5 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(5));
1182 if ( hq0 && hq1 && hq2 && hq3 && hq4 && hq5 )
1183 hh = _hexaDocument->addHexa( hq0, hq1, hq2, hq3, hq4, hq5 );
1184 else if ( hq0 && hq1 && hq2 && hq3 && hq4 )
1185 hh = _hexaDocument->addHexa5Quads( hq0, hq1, hq2, hq3, hq4 );
1186 else if ( hq0 && hq1 && hq2 && hq3 )
1187 hh = _hexaDocument->addHexa4Quads( hq0, hq1, hq2, hq3 );
1188 else if ( hq0 && hq1 && hq2)
1189 hh = _hexaDocument->addHexa3Quads( hq0, hq1, hq2 );
1190 else if ( hq0 && hq1 )
1191 hh = _hexaDocument->addHexa2Quads( hq0, hq1);
1193 if ( BadElement(hh) ) return hexaIndex;
1196 unsigned int nbRows = _hexaDirItem->rowCount();
1198 hexaIndex = _hexaDirItem->child(nbRows-1)->index();
1203 QModelIndex DocumentModel::addVector( double dx, double dy, double dz )
1205 QModelIndex vectorIndex;
1207 HEXA_NS::Vector* hv = _hexaDocument->addVector(dx, dy, dz);
1208 if ( BadElement(hv) ) return vectorIndex; //Invalid index
1210 VectorItem* v = new VectorItem(hv);
1211 _vectorDirItem->appendRow(v);
1212 vectorIndex = v->index();
1217 QModelIndex DocumentModel::addVectorVertices( const QModelIndex &iv0, const QModelIndex &iv1 )
1221 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(iv0);
1222 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
1224 HEXA_NS::Vector* hvec = _hexaDocument->addVectorVertices( hv0, hv1 );
1225 if ( BadElement(hvec) ) return iVec;
1227 VectorItem* vec = new VectorItem(hvec);
1228 _vectorDirItem->appendRow(vec);
1229 iVec = vec->index();
1235 // ************ EDIT HEXABLOCK MODEL ************
1237 bool DocumentModel::updateVertex( const QModelIndex& ivertex, double x, double y, double z )
1241 HEXA_NS::Vertex* hVertex = getHexaPtr<HEXA_NS::Vertex*>(ivertex);
1244 // hVertex->setName( name.toStdString() );
1245 hVertex->setX ( x );
1246 hVertex->setY ( y );
1247 hVertex->setZ ( z );
1248 emit patternDataChanged();
1255 bool DocumentModel::removeHexa( const QModelIndex& ihexa )
1257 HEXA_NS::Hexa* hHexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1259 int r = _hexaDocument->removeHexa( hHexa );
1268 bool DocumentModel::removeConnectedHexa( const QModelIndex& ihexa )
1270 HEXA_NS::Hexa* hHexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1272 int r = _hexaDocument->removeConnectedHexa( hHexa );
1281 bool DocumentModel::mergeVertices( const QModelIndex &iv0, const QModelIndex &iv1 ) //CS_TODO : impact sur le model?
1283 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(iv0);
1284 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
1286 int r = _hexaDocument->mergeVertices( hv0, hv1 );
1288 updateData(); //CS_TODO more or less?
1295 bool DocumentModel::mergeEdges( const QModelIndex &ie0, const QModelIndex &ie1,
1296 const QModelIndex &iv0, const QModelIndex &iv1 )
1297 //CS_TODO : impact sur le model?
1299 HEXA_NS::Edge* he0 = getHexaPtr<HEXA_NS::Edge*>(ie0);
1300 HEXA_NS::Edge* he1 = getHexaPtr<HEXA_NS::Edge*>(ie1);
1302 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(iv0);
1303 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
1306 int r = _hexaDocument->mergeEdges( he0, he1, hv0, hv1 );
1315 bool DocumentModel::mergeQuads( const QModelIndex& iquad0, const QModelIndex& iquad1,
1316 const QModelIndex& iv0, const QModelIndex& iv1,
1317 const QModelIndex& iv2, const QModelIndex& iv3 )
1319 HEXA_NS::Quad* hquad0 = data(iquad0, HEXA_DATA_ROLE).value<HEXA_NS::Quad *>();
1320 HEXA_NS::Quad* hquad1 = data(iquad1, HEXA_DATA_ROLE).value<HEXA_NS::Quad *>();
1322 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(iv0);
1323 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
1324 HEXA_NS::Vertex* hv2 = getHexaPtr<HEXA_NS::Vertex*>(iv2);
1325 HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(iv3);
1327 int r = _hexaDocument->mergeQuads( hquad0, hquad1, hv0, hv1, hv2, hv3 );
1337 QModelIndex DocumentModel::disconnectVertex( const QModelIndex& ihexa, const QModelIndex& ivertex )
1341 HEXA_NS::Hexa* hHexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1342 HEXA_NS::Vertex* hVertex = getHexaPtr<HEXA_NS::Vertex*>(ivertex);
1344 HEXA_NS::Elements* hElts = _hexaDocument->disconnectVertex( hHexa, hVertex );
1345 if ( BadElement(hElts) ) return iElts;
1347 updateData(); //CS_TO_CHECK
1348 ElementsItem* elts = new ElementsItem(hElts);
1349 _elementsDirItem->appendRow(elts);
1350 iElts = elts->index();
1355 QModelIndex DocumentModel::disconnectEdge( const QModelIndex& ihexa, const QModelIndex& iedge )
1359 HEXA_NS::Hexa* hHexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1360 HEXA_NS::Edge* hEdge = getHexaPtr<HEXA_NS::Edge*>(iedge);
1362 HEXA_NS::Elements* hElts = _hexaDocument->disconnectEdge( hHexa, hEdge );
1363 if ( BadElement(hElts) ) return iElts;
1365 updateData(); //CS_TO_CHECK
1366 ElementsItem* elts = new ElementsItem(hElts);
1367 _elementsDirItem->appendRow(elts);
1368 iElts = elts->index();
1374 QModelIndex DocumentModel::disconnectEdges( const QModelIndexList& ihexas, const QModelIndexList& iedges )
1378 HEXA_NS::Hexas hHexas;
1379 HEXA_NS::Edges hEdges;
1382 HEXA_NS::Edge* hedge = NULL;
1383 foreach( const QModelIndex& iedge, iedges ){
1384 hedge = getHexaPtr<HEXA_NS::Edge*>(iedge);
1385 hEdges.push_back( hedge );
1389 HEXA_NS::Hexa* hhexa = NULL;
1390 foreach( const QModelIndex& ihexa, ihexas ){
1391 hhexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1392 hHexas.push_back( hhexa );
1396 HEXA_NS::Elements* hElts = _hexaDocument->disconnectEdges( hHexas, hEdges );
1397 if ( BadElement(hElts) ) return iElts;
1399 updateData(); //CS_TO_CHECK
1400 ElementsItem* elts = new ElementsItem(hElts);
1401 _elementsDirItem->appendRow(elts);
1402 iElts = elts->index();
1408 QModelIndex DocumentModel::disconnectQuad( const QModelIndex& ihexa, const QModelIndex& iquad )
1412 HEXA_NS::Hexa* hHexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1413 HEXA_NS::Quad* hQuad = getHexaPtr<HEXA_NS::Quad*>(iquad);
1415 HEXA_NS::Elements* hElts = _hexaDocument->disconnectQuad( hHexa, hQuad );
1416 if ( BadElement(hElts) ) return iElts;
1418 updateData(); //CS_TO_CHECK
1419 ElementsItem* elts = new ElementsItem(hElts);
1420 _elementsDirItem->appendRow(elts);
1421 iElts = elts->index();
1427 QModelIndex DocumentModel::makeTranslation( const QModelIndex& ielts, const QModelIndex& ivec )
1431 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1432 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1434 HEXA_NS::Elements* hNewElts = _hexaDocument->makeTranslation( hElts, hVec );
1435 if ( BadElement(hNewElts) ) return iElts;
1437 updateData(); //CS_TODO more or less?
1438 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1439 _elementsDirItem->appendRow(eltsItem);
1440 iElts = eltsItem->index();
1447 QModelIndex DocumentModel::makeScale( const QModelIndex& ielts, const QModelIndex& ivex, double k )
1451 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1452 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1454 HEXA_NS::Elements* hNewElts = _hexaDocument->makeScale( hElts, hVex, k );
1455 if ( BadElement(hNewElts) ) return iElts;
1457 updateData(); //CS_TODO more or less?
1458 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1459 _elementsDirItem->appendRow(eltsItem);
1460 iElts = eltsItem->index();
1467 QModelIndex DocumentModel::makeRotation( const QModelIndex& ielts,
1468 const QModelIndex& iv,
1469 const QModelIndex& ivec, double angle )
1473 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1474 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(iv);
1475 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1477 HEXA_NS::Elements* hNewElts = _hexaDocument->makeRotation( hElts, hVex, hVec, angle );
1478 if ( BadElement(hNewElts) ) return iElts;
1480 updateData(); //CS_TODO more or less?
1481 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1482 _elementsDirItem->appendRow(eltsItem);
1483 iElts = eltsItem->index();
1489 QModelIndex DocumentModel::makeSymmetryPoint( const QModelIndex& ielts, const QModelIndex& iv )
1493 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1494 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(iv);
1496 HEXA_NS::Elements* hNewElts = _hexaDocument->makeSymmetryPoint (hElts, hVex);
1497 if ( BadElement(hNewElts) ) return iElts;
1499 updateData(); //CS_TODO more or less?
1500 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1501 _elementsDirItem->appendRow(eltsItem);
1502 iElts = eltsItem->index();
1508 QModelIndex DocumentModel::makeSymmetryLine( const QModelIndex& ielts,
1509 const QModelIndex& iv,
1510 const QModelIndex& ivec )
1514 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1515 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(iv);
1516 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1519 HEXA_NS::Elements* hNewElts = _hexaDocument->makeSymmetryLine( hElts, hVex, hVec );
1520 if ( BadElement(hNewElts) ) return iElts;
1522 updateData(); //CS_TODO more or less?
1523 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1524 _elementsDirItem->appendRow(eltsItem);
1525 iElts = eltsItem->index();
1531 QModelIndex DocumentModel::makeSymmetryPlane( const QModelIndex& ielts, const QModelIndex& iv, const QModelIndex& ivec )
1535 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1536 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(iv);
1537 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1539 HEXA_NS::Elements* hNewElts = _hexaDocument->makeSymmetryPlane( hElts, hVex, hVec );
1540 if ( BadElement(hNewElts) ) return iElts;
1542 updateData(); //CS_TODO more or less?
1543 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1544 _elementsDirItem->appendRow(eltsItem);
1545 iElts = eltsItem->index();
1551 bool DocumentModel::performTranslation( const QModelIndex& ielts, const QModelIndex& ivec )
1553 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1554 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1556 int r = _hexaDocument->performTranslation (hElts, hVec);
1557 if ( r == HOK ){ //Job well done?
1567 bool DocumentModel::performScale( const QModelIndex& ielts, const QModelIndex& ivex, double k )
1569 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1570 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1572 int r = _hexaDocument->performScale (hElts, hVex, k);
1582 bool DocumentModel::performRotation( const QModelIndex& ielts, const QModelIndex& ivex, const QModelIndex& ivec, double angle )
1584 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1585 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1586 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1588 int r = _hexaDocument-> performRotation( hElts, hVex, hVec, angle );
1599 bool DocumentModel::performSymmetryPoint( const QModelIndex& ielts, const QModelIndex& ivex )
1601 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1602 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1604 int r = _hexaDocument->performSymmetryPoint( hElts, hVex );
1614 bool DocumentModel::performSymmetryLine( const QModelIndex& ielts, const QModelIndex& ivex, const QModelIndex& ivec )
1616 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1617 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1618 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1620 int r = _hexaDocument->performSymmetryLine( hElts, hVex, hVec );
1630 bool DocumentModel::performSymmetryPlane( const QModelIndex& ielts,
1631 const QModelIndex& ivex,
1632 const QModelIndex& ivec )
1634 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1635 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1636 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1638 int r = _hexaDocument->performSymmetryPlane( hElts, hVex, hVec );
1647 QModelIndex DocumentModel::replace( const QModelIndexList& iquadsPattern,
1648 const QModelIndex& ip1, const QModelIndex& ic1,
1649 const QModelIndex& ip2, const QModelIndex& ic2,
1650 const QModelIndex& ip3, const QModelIndex& ic3 )
1654 HEXA_NS::Vertex* hp1 = getHexaPtr<HEXA_NS::Vertex*>(ip1);
1655 HEXA_NS::Vertex* hc1 = getHexaPtr<HEXA_NS::Vertex*>(ic1);
1656 HEXA_NS::Vertex* hp2 = getHexaPtr<HEXA_NS::Vertex*>(ip2);
1657 HEXA_NS::Vertex* hc2 = getHexaPtr<HEXA_NS::Vertex*>(ic2);
1658 HEXA_NS::Vertex* hp3 = getHexaPtr<HEXA_NS::Vertex*>(ip3);
1659 HEXA_NS::Vertex* hc3 = getHexaPtr<HEXA_NS::Vertex*>(ic3);
1661 HEXA_NS::Quads hquads;
1662 HEXA_NS::Quad* hquad = NULL;
1663 foreach( const QModelIndex& iquad, iquadsPattern ){
1664 hquad = getHexaPtr<HEXA_NS::Quad*>(iquad);
1665 hquads.push_back( hquad );
1668 HEXA_NS::Elements* helts = _hexaDocument->replace( hquads,
1669 hp1, hc1, hp2, hc2, hp3, hc3 );
1670 if ( BadElement(helts) ) return ielts;
1673 ElementsItem* eltsItem = new ElementsItem(helts);
1674 _elementsDirItem->appendRow(eltsItem);
1675 ielts = eltsItem->index();
1680 QModelIndex DocumentModel::getGeomModelIndex(QString& id) const
1683 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
1685 // ** get the model index of the geom element having this ID
1686 HEXA_NS::SubShape* eltPtr = getGeomPtr(id);
1687 HEXA_NS::VertexShape* geomVertex = dynamic_cast<HEXA_NS::VertexShape*>(eltPtr);
1688 HEXA_NS::EdgeShape* geomEdge = dynamic_cast<HEXA_NS::EdgeShape*>(eltPtr);
1689 HEXA_NS::FaceShape* geomFace = dynamic_cast<HEXA_NS::FaceShape*>(eltPtr);
1690 if (geomVertex != NULL)
1691 result = pgsm->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(geomVertex));
1692 if (geomEdge != NULL)
1693 result = pgsm->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(geomEdge));
1694 if (geomFace != NULL)
1695 result = pgsm->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(geomFace));
1700 QMultiMap< QString, int > DocumentModel::getAssocShapesIds(const QModelIndex& dataIndex)
1702 QMultiMap< QString, int > result;
1703 HEXA_NS::NewShape* mainShape;
1704 HEXA_NS::VertexShape* node;
1705 HEXA_NS::EdgeShape* line;
1706 HEXA_NS::FaceShape* face;
1710 PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
1711 QModelIndexList assocsInd = pdsm->getGeomAssociations(dataIndex);
1712 foreach( const QModelIndex& anAssoc, assocsInd )
1714 node = getHexaPtr<HEXA_NS::VertexShape*>(anAssoc);
1715 line = getHexaPtr<HEXA_NS::EdgeShape*>(anAssoc);
1716 face = getHexaPtr<HEXA_NS::FaceShape*>(anAssoc);
1720 mainShape = node->getParentShape();
1721 if (mainShape != NULL)
1723 shapeName = mainShape->getName();
1724 subid = node->getIdent();
1727 else if (line != NULL)
1729 mainShape = line->getParentShape();
1730 if (mainShape != NULL)
1732 shapeName = mainShape->getName();
1733 subid = line->getIdent();
1736 else if (face != NULL)
1738 mainShape = face->getParentShape();
1739 if (mainShape != NULL)
1741 shapeName = mainShape->getName();
1742 subid = face->getIdent();
1746 if (!shapeName.isEmpty())
1747 result.insert( shapeName, subid );
1749 shapeName = QString();
1754 bool DocumentModel::setVertexAssociation( const QModelIndex& iVertex, double x, double y, double z)
1756 HEXA_NS::Vertex* vertex = getHexaPtr<HEXA_NS::Vertex *>(iVertex);
1758 if (vertex == NULL || _hexaDocument == NULL || vertex->setAssociation(x, y, z) != HOK)
1761 HEXA_NS::VertexShape* assoc = vertex->getAssociation();
1764 HEXA_NS::NewShape* mainSh = assoc->getParentShape();
1765 setData( iVertex, QVariant::fromValue(QString(mainSh->getName())+","+QString::number(assoc->getIdent())+";"), HEXA_ASSOC_ENTRY_ROLE );
1771 bool DocumentModel::setVertexAssociation( const QModelIndex& iVertex, const QModelIndex& iGeomVertex)
1773 //parameters control
1775 HEXA_NS::Vertex* vertex = getHexaPtr<HEXA_NS::Vertex *>(iVertex);
1776 HEXA_NS::VertexShape* geomVertex = getHexaPtr<HEXA_NS::VertexShape*>(iGeomVertex);
1777 if (_hexaDocument == NULL || vertex == NULL || geomVertex == NULL) return false;
1778 HEXA_NS::NewShape* mainShape = geomVertex->getParentShape();
1779 if (mainShape == NULL) return false;
1782 if (vertex->setAssociation(geomVertex) != HOK)
1785 //update association state in the model
1786 newAssoc = QString(mainShape->getName()) + "," + QString::number(geomVertex->getIdent()) + ";";
1787 setData( iVertex, QVariant::fromValue(newAssoc), HEXA_ASSOC_ENTRY_ROLE );
1792 bool DocumentModel::addEdgeAssociation( const QModelIndex& iEdge, const QModelIndex& iGeomEdge, double start, double end)
1794 //parameters control
1795 QString currentAssoc, newAssoc;
1796 HEXA_NS::Edge* edge = getHexaPtr<HEXA_NS::Edge*>(iEdge);
1797 HEXA_NS::EdgeShape* geomEdge = getHexaPtr<HEXA_NS::EdgeShape*>(iGeomEdge);
1798 if (_hexaDocument == NULL || edge == NULL ||
1799 geomEdge == NULL || start > end) return false;
1800 HEXA_NS::NewShape* mainShape = geomEdge->getParentShape();
1801 if (mainShape == NULL) return false;
1803 //add association in the engine side
1804 if (edge->addAssociation(geomEdge, start, end) != HOK)
1807 //add/update association in the model side (UI)
1808 currentAssoc = data(iEdge, HEXA_ASSOC_ENTRY_ROLE).toString();
1809 newAssoc = QString(mainShape->getName()) + "," + QString::number(geomEdge->getIdent()) + ";";
1810 if (!currentAssoc.isEmpty()) newAssoc = currentAssoc + newAssoc;
1812 setData( iEdge, QVariant::fromValue(newAssoc), HEXA_ASSOC_ENTRY_ROLE );
1818 bool DocumentModel::addQuadAssociation (const QModelIndex& iQuad, const QModelIndex& iGeomFace)
1820 //parameters control
1821 QString currentAssoc, newAssoc;
1822 HEXA_NS::Quad* quad = getHexaPtr<HEXA_NS::Quad*>(iQuad);
1823 HEXA_NS::FaceShape* geomFace = getHexaPtr<HEXA_NS::FaceShape*>(iGeomFace);
1824 if (_hexaDocument == NULL || quad == NULL || geomFace == NULL)
1826 HEXA_NS::NewShape* mainShape = geomFace->getParentShape();
1827 if (mainShape == NULL) return false;
1830 if (quad->addAssociation(geomFace) != HOK)
1833 //update association
1834 currentAssoc = data( iQuad, HEXA_ASSOC_ENTRY_ROLE).toString();
1835 newAssoc = QString(mainShape->getName()) + "," + QString::number(geomFace->getIdent()) + ";";
1836 if (!currentAssoc.isEmpty()) newAssoc = currentAssoc + newAssoc;
1837 setData( iQuad, QVariant::fromValue(newAssoc), HEXA_ASSOC_ENTRY_ROLE );
1843 QModelIndex DocumentModel::getVertexAssociation(const QModelIndex& iVertex)
1845 HEXA_NS::Vertex* vertex = getHexaPtr<HEXA_NS::Vertex*>(iVertex);
1847 return QModelIndex();
1849 //get the associated geom vertex
1850 HEXA_NS::VertexShape* geomVertex = vertex->getAssociation();
1851 if (geomVertex == NULL)
1852 return QModelIndex();
1854 //convert geom vertex to qmodelindex
1855 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
1857 return QModelIndex();
1859 return pgsm->indexBy(HEXA_DATA_ROLE, QVariant::fromValue(geomVertex));
1863 QModelIndexList DocumentModel::getEdgeAssociations(const QModelIndex& iEdge)
1865 QModelIndexList result;
1866 HEXA_NS::Edge* edge = getHexaPtr<HEXA_NS::Edge*>(iEdge);
1867 if (edge == NULL) return result;
1869 HEXA_NS::EdgeShape* geomEdge;
1870 HEXA_NS::AssoEdge* anEdgeAssoc;
1872 PatternGeomSelectionModel* pGSModel = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
1873 int nbAssocs = edge->countAssociation();
1874 for (int i = 0; i < nbAssocs; ++i)
1876 anEdgeAssoc = edge->getAssociation(i);
1877 if (anEdgeAssoc == NULL) continue;
1878 geomEdge = anEdgeAssoc->getEdgeShape();
1879 if (geomEdge == NULL) continue;
1880 result << pGSModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(geomEdge));
1887 QModelIndexList DocumentModel::getQuadAssociations(const QModelIndex& iQuad)
1889 QModelIndexList result;
1890 QModelIndex geomQuadIndex;
1891 HEXA_NS::Quad* quad = getHexaPtr<HEXA_NS::Quad*>(iQuad);
1892 if (quad == NULL) return result;
1894 if (HEXABLOCKGUI::currentDocGView == NULL) return result;
1895 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
1896 PatternGeomModel* pgm = HEXABLOCKGUI::currentDocGView->getPatternGeomModel();
1897 if (pgsm == NULL || pgm == NULL) return result;
1899 HEXA_NS::FaceShape* geomFace;
1901 int nbAssocs = quad->countAssociation();
1902 for (int i = 0; i < nbAssocs; ++i)
1904 geomFace = quad->getAssociation(i);
1905 if (geomFace == NULL) continue;
1907 geomQuadIndex = pgsm->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(geomFace) );
1908 result << geomQuadIndex;
1915 bool DocumentModel::associateOpenedLine( const QModelIndexList& iedges,
1916 HEXA_NS::NewShapes shapes,
1917 HEXA_NS::IntVector subIds,
1922 HEXA_NS::Edges mline;
1924 HEXA_NS::Edge* hedge = NULL;
1925 foreach( const QModelIndex& iedge, iedges ){
1926 hedge = getHexaPtr<HEXA_NS::Edge*>(iedge);
1928 mline.push_back( hedge );
1931 int err = _hexaDocument->associateOpenedLine( mline, shapes, subIds, pstart, pend );
1939 bool DocumentModel::associateClosedLine( const QModelIndex& ivertex,
1940 const QModelIndexList& iedges,
1941 HEXA_NS::NewShapes shapes,
1942 HEXA_NS::IntVector subIds,
1946 HEXA_NS::Vertex* mfirst = getHexaPtr<HEXA_NS::Vertex*>(ivertex);
1947 HEXA_NS::Edges mline;
1949 HEXA_NS::Edge* hedge = NULL;
1950 foreach( const QModelIndex& iedge, iedges ){
1951 hedge = getHexaPtr<HEXA_NS::Edge*>(iedge);
1953 mline.push_back( hedge );
1956 int err = _hexaDocument->associateClosedLine( mfirst, mline, shapes, subIds, pstart, inv);
1964 // ************ GROUPS ************
1966 QModelIndex DocumentModel::addGroup( const QString& name, Group kind )
1970 HEXA_NS::Group* hGroup = _hexaDocument->addGroup( name.toLocal8Bit().constData(), kind );
1971 if ( hGroup == NULL ) return iGroup;
1973 GroupItem* groupItem = new GroupItem(hGroup);
1974 groupItem->setData( _entry, HEXA_DOC_ENTRY_ROLE );
1975 _groupDirItem->appendRow(groupItem);
1976 iGroup = groupItem->index();
1982 bool DocumentModel::removeGroup( const QModelIndex& igrp )
1984 HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
1985 int r = _hexaDocument->removeGroup ( hGroup );
1988 removeRow( igrp.row(), igrp.parent());
1996 QModelIndexList DocumentModel::getGroupElements( const QModelIndex& iGroup, DocumentModel::Group& kind ) const
1998 QModelIndexList iElements;
2000 HEXA_NS::Group* g = iGroup.data(HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
2001 if ( g == NULL ) return iElements;
2003 QModelIndexList iFound;
2005 HEXA_NS::EltBase* eltBase = NULL;
2006 int nbElement = g->countElement();
2007 for ( int nr = 0; nr < nbElement; ++nr ){
2008 eltBase = g->getElement( nr );
2009 kind = g->getKind();
2011 case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: q = QVariant::fromValue( (HEXA_NS::Hexa *)eltBase ); break;
2012 case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: q = QVariant::fromValue( (HEXA_NS::Quad *)eltBase ); break;
2013 case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: q = QVariant::fromValue( (HEXA_NS::Edge *)eltBase ); break;
2014 case HEXA_NS::VertexNode: q = QVariant::fromValue( (HEXA_NS::Vertex *)eltBase ); break;
2016 iFound = match( index(0, 0),
2020 Qt::MatchRecursive );
2021 if ( !iFound.isEmpty() )
2022 iElements << iFound[0];
2027 // 7.4 Boite: éditer un groupe
2028 void DocumentModel::setGroupName( const QModelIndex& igrp, const QString& name )
2030 HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
2033 hGroup->setName( name.toLocal8Bit().constData() );
2034 setData(igrp, QVariant::fromValue( name ) );
2038 bool DocumentModel::addGroupElement( const QModelIndex& igrp, const QModelIndex& ielt )
2040 HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
2041 if (hGroup == NULL) return false;
2043 HEXA_NS::EltBase* hElt = NULL;
2044 switch ( hGroup->getKind() ){
2045 case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: hElt = getHexaPtr<HEXA_NS::Hexa*>(ielt); break;
2046 case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: hElt = getHexaPtr<HEXA_NS::Quad*>(ielt); break;
2047 case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: hElt = getHexaPtr<HEXA_NS::Edge*>(ielt); break;
2048 case HEXA_NS::VertexNode: hElt = getHexaPtr<HEXA_NS::Vertex*>(ielt); break;
2053 res = hGroup->addElement( hElt );
2055 if ( res == HOK ) return true;
2060 bool DocumentModel::removeGroupElement( const QModelIndex& igrp, int nro )
2061 { //CS_TODO : remove child?
2062 HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
2063 if (hGroup == NULL) return false;
2065 if (hGroup->removeElement( nro ) == HOK) return true;
2070 bool DocumentModel::clearGroupElement( const QModelIndex& igrp )
2072 HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
2074 if ( hGroup != NULL)
2076 hGroup->clearElement();
2082 // ************ LAWS ************
2085 QModelIndex DocumentModel::addLaw( const QString& name, int nbnodes )
2089 HEXA_NS::Law* hLaw = _hexaDocument->addLaw( name.toLocal8Bit().constData(), nbnodes );
2090 if ( BadElement(hLaw) ) return iLaw;
2092 LawItem* lawItem = new LawItem(hLaw);
2093 _lawDirItem->appendRow(lawItem);
2094 iLaw = lawItem->index();
2099 bool DocumentModel::setLaw( const QModelIndex& ilaw, int nbnodes, double coeff, KindLaw type )
2103 HEXA_NS::Law* hLaw = data(ilaw, HEXA_DATA_ROLE).value<HEXA_NS::Law *>();
2107 ok = hLaw->setNodes( nbnodes );
2108 ( ok == HOK) ? ret = true : ret = false;
2109 ok = hLaw->setCoefficient( coeff );
2110 hLaw->setKind(type);
2117 bool DocumentModel::removeLaw( const QModelIndex& ilaw )
2119 HEXA_NS::Law* hLaw = data(ilaw, HEXA_DATA_ROLE).value<HEXA_NS::Law *>();
2120 int r = _hexaDocument->removeLaw( hLaw );
2123 removeRow( ilaw.row(), ilaw.parent());
2130 bool DocumentModel::setPropagation( const QModelIndex& iPropagation, const QModelIndex& iLaw, bool way )
2132 HEXA_NS::Propagation* hPropagation = data(iPropagation, HEXA_DATA_ROLE).value<HEXA_NS::Propagation *>();
2133 HEXA_NS::Law* hLaw = data(iLaw, HEXA_DATA_ROLE).value<HEXA_NS::Law *>();
2135 int r = hPropagation->setLaw( hLaw );
2136 hPropagation->setWay( way );
2138 if ( r == HOK ) return true;
2144 QModelIndexList DocumentModel::getPropagation( const QModelIndex& iPropagation ) const
2146 QModelIndexList iEdges;
2148 QModelIndexList iFound;
2149 HEXA_NS::Propagation* propa = iPropagation.data(HEXA_DATA_ROLE).value<HEXA_NS::Propagation *>();
2150 if ( propa == NULL ) return iEdges;
2152 const HEXA_NS::Edges& edges = propa->getEdges();
2153 for ( HEXA_NS::Edges::const_iterator anEdge = edges.begin(), endIt = edges.end();
2156 iFound = match( index(0, 0),
2158 QVariant::fromValue( *anEdge ),
2160 Qt::MatchRecursive);
2161 if ( !iFound.isEmpty() )
2162 iEdges << iFound[0];
2168 HEXA_NS::Document* DocumentModel::documentImpl()
2170 return _hexaDocument;
2173 QString DocumentModel::documentEntry()
2178 // 8.3 Boite: éditer une loi CS_TODO
2181 /*****************************************************************
2183 *****************************************************************/
2185 PatternDataModel::PatternDataModel( QObject * parent ) :
2186 QSortFilterProxyModel( parent )
2188 QString dataRegExp = QString("(%1|%2|%3|%4|%5|%6|%7|%8|%9|%10|%11|%12)").
2189 arg(VERTEX_TREE).arg(EDGE_TREE).arg(QUAD_TREE).arg(HEXA_TREE).arg(VECTOR_TREE).arg(ELEMENTS_TREE).
2190 arg(VERTEX_DIR_TREE).arg(EDGE_DIR_TREE).arg(QUAD_DIR_TREE).arg(HEXA_DIR_TREE).arg(VECTOR_DIR_TREE).
2191 arg(ELEMENTS_DIR_TREE);
2193 setFilterRole(HEXA_TREE_ROLE);
2194 setFilterRegExp ( QRegExp(dataRegExp) );
2197 // *** Pour suppression des panneaux "Builder" et "Geometry" ****/
2199 //PatternDataModel::PatternDataModel( QObject * parent ) :
2200 // QSortFilterProxyModel( parent )
2202 // QString dataRegExp = QString("(%1|%2|%3|%4|%5|%6|%7|%8|%9|%10|%11|%12|%13|%14|%15|%16|%17|%18|%19|%20|%21|%22|%23|%24|%25|%26)").
2203 // arg(VERTEX_TREE).arg(EDGE_TREE).arg(QUAD_TREE).arg(HEXA_TREE).
2204 // arg(VERTEX_DIR_TREE).arg(EDGE_DIR_TREE).arg(QUAD_DIR_TREE).
2205 // arg(HEXA_DIR_TREE).arg(VECTOR_TREE).arg(ELEMENTS_TREE).
2206 // arg(VECTOR_DIR_TREE).arg(ELEMENTS_DIR_TREE).
2207 // arg(IMPLICIT_SHAPES_TREE).arg(EXPLICIT_SHAPES_TREE).arg(CLOUD_OF_POINTS_TREE).
2208 // arg(GEOMSHAPE_TREE).arg(GEOMPOINT_TREE).arg(GEOMEDGE_TREE).arg(GEOMFACE_TREE).
2209 // arg(IMPLICIT_SHAPES_DIR_TREE).arg(EXPLICIT_SHAPES_DIR_TREE).arg(CLOUD_OF_POINTS_DIR_TREE).
2210 // arg(GEOMSHAPE_DIR_TREE).arg(GEOMPOINT_DIR_TREE).arg(GEOMEDGE_DIR_TREE).arg(GEOMFACE_DIR_TREE);
2212 // setFilterRole(HEXA_TREE_ROLE);
2213 // setFilterRegExp ( QRegExp(dataRegExp) );
2218 PatternDataModel::~PatternDataModel()
2222 HEXA_NS::Document* PatternDataModel::documentImpl()
2224 HEXA_NS::Document* doc = NULL;
2225 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2226 if (m) doc = m->documentImpl();
2230 QString PatternDataModel::documentEntry()
2233 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2234 if (m) entry = m->documentEntry();
2238 Qt::ItemFlags PatternDataModel::flags(const QModelIndex &index) const
2240 Qt::ItemFlags flags;
2242 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2244 flags = m->flags( mapToSource(index) );
2250 QVariant PatternDataModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2252 if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
2253 return QVariant( "Data" );
2255 return QSortFilterProxyModel::headerData ( section, orientation, role );
2260 QStandardItem* PatternDataModel::itemFromIndex ( const QModelIndex & index ) const
2262 QStandardItem *item = NULL;
2263 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2265 item = m->itemFromIndex( mapToSource(index) );
2270 //PatternBuilderModel::PatternBuilderModel( QObject * parent ) :
2271 // QSortFilterProxyModel( parent )
2273 // QString builderRegExp =QString("(%1|%2|%3|%4|%5|%6)").
2274 // arg(VECTOR_TREE).arg(ELEMENTS_TREE).
2275 // arg(CROSSELEMENTS_TREE).arg(VECTOR_DIR_TREE).arg(ELEMENTS_DIR_TREE).arg(CROSSELEMENTS_DIR_TREE);
2277 // setFilterRole( HEXA_TREE_ROLE );
2278 // setFilterRegExp ( QRegExp( builderRegExp ) );
2281 //PatternBuilderModel::~PatternBuilderModel()
2285 //Qt::ItemFlags PatternBuilderModel::flags(const QModelIndex &index) const
2287 // Qt::ItemFlags flags;
2289 // DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2290 // if ( m != NULL ){
2291 // flags = m->flags( mapToSource(index) );
2296 //QVariant PatternBuilderModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2298 // if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
2299 // return QVariant( "Builder" );
2301 // return QSortFilterProxyModel::headerData ( section, orientation, role );
2305 //QStandardItem* PatternBuilderModel::itemFromIndex ( const QModelIndex & index ) const
2307 // QStandardItem *item = NULL;
2308 // DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2309 // if ( m != NULL ){
2310 // item = m->itemFromIndex( mapToSource(index) );
2315 //====================================================================
2317 //====================================================================
2318 PatternGeomModel::PatternGeomModel( QObject * parent ) :
2319 QSortFilterProxyModel( parent )
2321 QString builderRegExp =QString("(%1|%2|%3|%4|%5|%6|%7|%8|%9|%10|%11|%12|%13|%14)").
2322 arg(EXPLICIT_SHAPES_TREE).arg(IMPLICIT_SHAPES_TREE).arg(CLOUD_OF_POINTS_TREE).
2323 arg(GEOMSHAPE_TREE).arg(GEOMPOINT_TREE).arg(GEOMEDGE_TREE).arg(GEOMFACE_TREE).
2324 arg(EXPLICIT_SHAPES_DIR_TREE).arg(IMPLICIT_SHAPES_DIR_TREE).arg(CLOUD_OF_POINTS_DIR_TREE).
2325 arg(GEOMSHAPE_DIR_TREE).arg(GEOMPOINT_DIR_TREE).arg(GEOMEDGE_DIR_TREE).arg(GEOMFACE_DIR_TREE);
2327 setFilterRole( HEXA_TREE_ROLE );
2328 setFilterRegExp ( QRegExp(builderRegExp ) );
2331 PatternGeomModel::~PatternGeomModel()
2335 Qt::ItemFlags PatternGeomModel::flags(const QModelIndex &index) const
2337 Qt::ItemFlags flags;
2339 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2341 flags = m->flags( mapToSource(index) );
2346 QVariant PatternGeomModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2348 if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
2349 return QVariant( "Geometry" );
2351 return QSortFilterProxyModel::headerData ( section, orientation, role );
2355 QStandardItem* PatternGeomModel::itemFromIndex ( const QModelIndex & index ) const
2357 QStandardItem *item = NULL;
2358 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2360 item = m->itemFromIndex( mapToSource(index) );
2364 //==============================================================
2367 AssociationsModel::AssociationsModel( QObject * parent ) :
2368 QSortFilterProxyModel( parent )
2370 QString assocRegExp;
2372 setFilterRole( HEXA_TREE_ROLE );
2373 setFilterRegExp ( QRegExp(assocRegExp) );
2376 AssociationsModel::~AssociationsModel()
2380 Qt::ItemFlags AssociationsModel::flags(const QModelIndex &index) const
2382 Qt::ItemFlags flags;
2384 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2386 flags = m->flags( mapToSource(index) );
2391 QVariant AssociationsModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2393 if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
2394 return QVariant( "Associations" );
2396 return QSortFilterProxyModel::headerData ( section, orientation, role );
2400 QStandardItem* AssociationsModel::itemFromIndex ( const QModelIndex & index ) const
2402 QStandardItem *item = NULL;
2403 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2405 item = m->itemFromIndex( mapToSource(index) );
2410 GroupsModel::GroupsModel( QObject * parent ) :
2411 QSortFilterProxyModel( parent )
2413 QString groupsRegExp =QString("(%1|%2)").arg(GROUP_TREE).arg(GROUP_DIR_TREE);
2415 setFilterRole( HEXA_TREE_ROLE );
2416 setFilterRegExp ( QRegExp(groupsRegExp ) );
2419 GroupsModel::~GroupsModel()
2423 Qt::ItemFlags GroupsModel::flags(const QModelIndex &index) const
2425 Qt::ItemFlags flags;
2427 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2429 flags = m->flags( mapToSource(index) );
2434 QVariant GroupsModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2436 if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
2437 return QVariant( "Groups" );
2439 return QSortFilterProxyModel::headerData ( section, orientation, role );
2443 QStandardItem* GroupsModel::itemFromIndex ( const QModelIndex & index ) const
2445 QStandardItem *item = NULL;
2446 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2448 item = m->itemFromIndex( mapToSource(index) );
2453 QModelIndexList GroupsModel::getGroupElements( const QModelIndex& iGroup, DocumentModel::Group& kind ) const
2455 QModelIndexList elements;
2456 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2458 elements = m->getGroupElements( mapToSource(iGroup), kind );
2463 MeshModel::MeshModel( QObject * parent ) :
2464 QSortFilterProxyModel( parent )
2466 QString meshRegExp =QString("(%1|%2|%3|%4)").arg(LAW_TREE).arg(LAW_DIR_TREE) .arg(PROPAGATION_TREE).arg(PROPAGATION_DIR_TREE);
2468 setFilterRole( HEXA_TREE_ROLE );
2469 setFilterRegExp ( QRegExp(meshRegExp) );
2472 MeshModel::~MeshModel()
2476 Qt::ItemFlags MeshModel::flags(const QModelIndex &index) const
2478 Qt::ItemFlags flags;
2480 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2482 flags = m->flags( mapToSource(index) );
2487 QVariant MeshModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2489 if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){
2490 return QVariant( "Mesh" );
2492 return QSortFilterProxyModel::headerData ( section, orientation, role );
2496 QStandardItem* MeshModel::itemFromIndex ( const QModelIndex & index ) const
2498 QStandardItem *item = NULL;
2499 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2501 item = m->itemFromIndex( mapToSource(index) );
2506 QModelIndexList MeshModel::getPropagation( const QModelIndex& iPropagation ) const
2508 QModelIndexList edges;
2509 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2511 edges = m->getPropagation( mapToSource(iPropagation) );
2517 // ================================== NEW ======================================
2519 // ===== CARTESIAN GRID
2521 QModelIndex DocumentModel::makeCartesianTop(int nx, int ny, int nz)
2525 HEXA_NS::Elements* helts = _hexaDocument->makeCartesianTop( nx, ny, nz );
2526 if ( BadElement(helts) )
2529 result = addElementsToTree(helts, _elementsDirItem);
2534 QModelIndex DocumentModel::makeCartesianUni(const QModelIndex& icenter,
2535 const QModelIndex& ibase, const QModelIndex& ivec, const QModelIndex& iaxis,
2536 double lx, double ly, double lz, int nx, int ny, int nz)
2540 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2541 HEXA_NS::Vector* hbase = getHexaPtr<HEXA_NS::Vector*>(ibase);
2542 HEXA_NS::Vector* hvec = getHexaPtr<HEXA_NS::Vector*>(ivec);
2543 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
2545 HEXA_NS::Elements* helts = _hexaDocument->makeCartesianUni( hcenter, hbase, hvec, haxis,
2546 lx, ly, lz, nx, ny, nz);
2547 if ( BadElement(helts) )
2550 result = addElementsToTree(helts, _elementsDirItem);
2555 QModelIndex DocumentModel::makeCartesian(const QModelIndex& icenter,
2556 const QModelIndex& ibase, const QModelIndex& ivec, const QModelIndex& iaxis,
2557 vector<double>& radius, vector<double>& angles, vector<double>& heights)
2561 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2562 HEXA_NS::Vector* hbase = getHexaPtr<HEXA_NS::Vector*>(ibase);
2563 HEXA_NS::Vector* hvec = getHexaPtr<HEXA_NS::Vector*>(ivec);
2564 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
2566 HEXA_NS::Elements* helts = _hexaDocument->makeCartesian( hcenter, hbase, hvec, haxis,
2567 radius, angles, heights);
2568 if ( BadElement(helts) )
2571 result = addElementsToTree(helts, _elementsDirItem);
2579 QModelIndex DocumentModel::makeSphereTop (int nr, int na, int nh)
2583 HEXA_NS::Elements* helts = _hexaDocument->makeSphereTop( nr, na, nh );
2584 if ( BadElement(helts) )
2587 result = addElementsToTree(helts, _elementsDirItem);
2592 QModelIndex DocumentModel::makeSphereUni (QModelIndex& icenter,
2593 QModelIndex& ivec_x, QModelIndex& ivec_z,
2594 double rtrou, double rext, double ang,
2595 QModelIndex& ivplan,
2596 int nr, int na, int nh)
2600 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2601 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2602 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2603 HEXA_NS::Vertex* hvplan = getHexaPtr<HEXA_NS::Vertex*>(ivplan);
2605 HEXA_NS::Elements* helts = _hexaDocument->makeSphereUni( hcenter, hvec_x, hvec_z,
2606 rtrou, rext, ang, hvplan,
2608 result = addElementsToTree(helts, _elementsDirItem);
2613 QModelIndex DocumentModel::makeSphere (QModelIndex& icenter,
2614 QModelIndex& ivec_x, QModelIndex& ivec_z,
2615 vector<double>& tray, vector<double>& tang, vector<double>& thaut)
2619 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2620 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2621 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2623 HEXA_NS::Elements* helts = _hexaDocument->makeSphere( hcenter, hvec_x, hvec_z,
2626 result = addElementsToTree(helts, _elementsDirItem);
2633 QModelIndex DocumentModel::makeSphericalTop (int nbre, int crit)
2637 HEXA_NS::Elements* helts = _hexaDocument->makeSphericalTop(nbre, crit);
2638 if (BadElement(helts))
2641 result = addElementsToTree(helts, _elementsDirItem);
2646 QModelIndex DocumentModel::makeSphericalUni (QModelIndex& icenter,
2647 QModelIndex& ivec_x, QModelIndex& ivec_z,
2653 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2654 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2655 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2657 HEXA_NS::Elements* helts = _hexaDocument->makeSphericalUni(hcenter, hvec_x, hvec_z, rayon, nbre, crit);
2658 if (BadElement(helts))
2661 result = addElementsToTree(helts, _elementsDirItem);
2666 QModelIndex DocumentModel::makeSpherical (QModelIndex& icenter,
2667 QModelIndex& ivec_x, QModelIndex& ivec_z,
2668 vector<double>& rayon,
2673 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2674 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2675 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2677 HEXA_NS::Elements* helts = _hexaDocument->makeSpherical(hcenter, hvec_x, hvec_z, rayon, crit);
2678 if (BadElement(helts))
2681 result = addElementsToTree(helts, _elementsDirItem);
2687 QModelIndex DocumentModel::makeRindTop (int nr, int na, int nh)
2691 HEXA_NS::Elements* helts = _hexaDocument->makeRindTop(nr, na, nh);
2692 if (BadElement(helts))
2695 result = addElementsToTree(helts, _elementsDirItem);
2700 QModelIndex DocumentModel::makeRindUni (QModelIndex& icenter,
2701 QModelIndex& ivec_x, QModelIndex& ivec_z,
2702 double raytrou, double rint, double rext, double ang,
2703 QModelIndex& ivplan,
2704 int nr, int na, int nh)
2708 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2709 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2710 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2711 HEXA_NS::Vertex* hvplan = getHexaPtr<HEXA_NS::Vertex*>(ivplan);
2713 HEXA_NS::Elements* helts = _hexaDocument->makeRindUni(hcenter, hvec_x, hvec_z, raytrou, rint, rext, ang,
2714 hvplan, nr, na, nh);
2715 if (BadElement(helts))
2718 result = addElementsToTree(helts, _elementsDirItem);
2723 QModelIndex DocumentModel::makeRind (QModelIndex& icenter,
2724 QModelIndex& ivec_x, QModelIndex& ivec_z,
2725 vector<double>& tray, vector<double>& tang, vector<double>& thaut)
2729 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2730 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2731 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2733 HEXA_NS::Elements* helts = _hexaDocument->makeRind(hcenter, hvec_x, hvec_z, tray, tang, thaut);
2734 if (BadElement(helts))
2737 result = addElementsToTree(helts, _elementsDirItem);
2742 // ======== Cylinder
2743 QModelIndex DocumentModel::makeCylinderTop(int nr, int na, int nh)
2747 HEXA_NS::Elements* helts = _hexaDocument->makeCylinderTop(nr, na, nh);
2748 if (BadElement(helts))
2751 result = addElementsToTree(helts, _elementsDirItem);
2756 QModelIndex DocumentModel::makeCylinderUni(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz,
2757 double rint, double rext, double angle, double haut,
2758 int nr, int na, int nh)
2762 HEXA_NS::Vertex* horig = getHexaPtr<HEXA_NS::Vertex*>(iorig);
2763 HEXA_NS::Vector* hvecx = getHexaPtr<HEXA_NS::Vector*>(ivecx);
2764 HEXA_NS::Vector* hvecz = getHexaPtr<HEXA_NS::Vector*>(ivecz);
2766 HEXA_NS::Elements* helts = _hexaDocument->makeCylinderUni(horig, hvecx, hvecz,
2767 rint, rext, angle, haut,
2769 if (BadElement(helts))
2772 result = addElementsToTree(helts, _elementsDirItem);
2777 QModelIndex DocumentModel::makeCylinder(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz,
2778 vector<double>& tray, vector<double>& tang, vector<double>& thaut)
2782 HEXA_NS::Vertex* horig = getHexaPtr<HEXA_NS::Vertex*>(iorig);
2783 HEXA_NS::Vector* hvecx = getHexaPtr<HEXA_NS::Vector*>(ivecx);
2784 HEXA_NS::Vector* hvecz = getHexaPtr<HEXA_NS::Vector*>(ivecz);
2786 HEXA_NS::Elements* helts = _hexaDocument->makeCylinder(horig, hvecx, hvecz, tray, tang, thaut);
2787 if (BadElement(helts))
2790 result = addElementsToTree(helts, _elementsDirItem);
2796 // ======== Cylinders
2797 QModelIndex DocumentModel::makeCylinders(QModelIndex& iorig1, QModelIndex& ivecz1, double r1, double h1,
2798 QModelIndex& iorig2, QModelIndex& ivecz2, double r2, double h2)
2802 HEXA_NS::Vertex* horig1 = getHexaPtr<HEXA_NS::Vertex*>(iorig1);
2803 HEXA_NS::Vertex* horig2 = getHexaPtr<HEXA_NS::Vertex*>(iorig2);
2804 HEXA_NS::Vector* hvecz1 = getHexaPtr<HEXA_NS::Vector*>(ivecz1);
2805 HEXA_NS::Vector* hvecz2 = getHexaPtr<HEXA_NS::Vector*>(ivecz2);
2807 HEXA_NS::BiCylinder* helts = _hexaDocument->makeCylinders(horig1, hvecz1, r1, h1,
2808 horig2, hvecz2, r2, h2);
2809 if (BadElement(helts))
2812 result = addElementsToTree(helts, _crossElementsDirItem);
2818 QModelIndex DocumentModel::makePipeTop(int nr, int na, int nh)
2822 HEXA_NS::Elements* helts = _hexaDocument->makePipeTop(nr, na, nh);
2823 if (BadElement(helts))
2826 result = addElementsToTree(helts, _elementsDirItem);
2831 QModelIndex DocumentModel::makePipeUni(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz,
2832 double rint, double rext, double angle, double haut,
2833 int nr, int na, int nh)
2837 HEXA_NS::Vertex* horig = getHexaPtr<HEXA_NS::Vertex*>(iorig);
2838 HEXA_NS::Vector* hvecx = getHexaPtr<HEXA_NS::Vector*>(ivecx);
2839 HEXA_NS::Vector* hvecz = getHexaPtr<HEXA_NS::Vector*>(ivecz);
2841 HEXA_NS::Elements* helts = _hexaDocument->makePipeUni(horig, hvecx, hvecz, rint, rext, angle,
2843 if (BadElement(helts))
2846 result = addElementsToTree(helts, _elementsDirItem);
2851 QModelIndex DocumentModel::makePipe(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz,
2852 vector<double>& tray, vector<double>& tang, vector<double>& thaut)
2856 HEXA_NS::Vertex* horig = getHexaPtr<HEXA_NS::Vertex*>(iorig);
2857 HEXA_NS::Vector* hvecx = getHexaPtr<HEXA_NS::Vector*>(ivecx);
2858 HEXA_NS::Vector* hvecz = getHexaPtr<HEXA_NS::Vector*>(ivecz);
2860 HEXA_NS::Elements* helts = _hexaDocument->makePipe(horig, hvecx, hvecz, tray, tang, thaut);
2861 if (BadElement(helts))
2864 result = addElementsToTree(helts, _elementsDirItem);
2870 QModelIndex DocumentModel::makePipes(QModelIndex& iorig1, QModelIndex& ivecz1, double rint1, double rex1, double h1,
2871 QModelIndex& iorig2, QModelIndex& ivecz2, double rint2, double rex2, double h2)
2875 HEXA_NS::Vertex* horig1 = getHexaPtr<HEXA_NS::Vertex*>(iorig1);
2876 HEXA_NS::Vertex* horig2 = getHexaPtr<HEXA_NS::Vertex*>(iorig2);
2877 HEXA_NS::Vector* hvecz1 = getHexaPtr<HEXA_NS::Vector*>(ivecz1);
2878 HEXA_NS::Vector* hvecz2 = getHexaPtr<HEXA_NS::Vector*>(ivecz2);
2880 HEXA_NS::BiCylinder* helts = _hexaDocument->makePipes(horig1, hvecz1, rint1, rex1, h1,
2881 horig2, hvecz2, rint2, rex2, h2);
2882 if (BadElement(helts))
2885 result = addElementsToTree(helts, _crossElementsDirItem);
2890 // ======== Join Quads
2891 QModelIndex DocumentModel::joinQuadUni(QModelIndex& istart, QModelIndex& idest, QModelIndex& iv1, QModelIndex& iv2,
2892 QModelIndex& iv3, QModelIndex& iv4, int nb)
2896 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
2897 HEXA_NS::Quad* hdest = getHexaPtr<HEXA_NS::Quad*>(idest);
2898 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
2899 HEXA_NS::Vertex* hv2 = getHexaPtr<HEXA_NS::Vertex*>(iv2);
2900 HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(iv3);
2901 HEXA_NS::Vertex* hv4 = getHexaPtr<HEXA_NS::Vertex*>(iv4);
2903 HEXA_NS::Elements* helts = _hexaDocument->joinQuadUni(hstart, hdest, hv1, hv2, hv3, hv4, nb);
2904 if (BadElement(helts))
2907 result = addElementsToTree(helts, _elementsDirItem);
2912 QModelIndex DocumentModel::joinQuad(QModelIndex& istart, QModelIndex& idest, QModelIndex& iva1, QModelIndex& ivb1,
2913 QModelIndex& iva2, QModelIndex& ivb2, vector<double>& tlen)
2917 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
2918 HEXA_NS::Quad* hdest = getHexaPtr<HEXA_NS::Quad*>(idest);
2919 HEXA_NS::Vertex* hva1 = getHexaPtr<HEXA_NS::Vertex*>(iva1);
2920 HEXA_NS::Vertex* hvb1 = getHexaPtr<HEXA_NS::Vertex*>(ivb1);
2921 HEXA_NS::Vertex* hva2 = getHexaPtr<HEXA_NS::Vertex*>(iva2);
2922 HEXA_NS::Vertex* hvb2 = getHexaPtr<HEXA_NS::Vertex*>(ivb2);
2924 HEXA_NS::Elements* helts = _hexaDocument->joinQuad(hstart, hdest, hva1, hvb1, hva2, hvb2, tlen);
2925 if (BadElement(helts))
2928 result = addElementsToTree(helts, _elementsDirItem);
2933 QModelIndex DocumentModel::joinQuadsUni(QModelIndexList& istarts, QModelIndex& idest, QModelIndex& iv1, QModelIndex& iv2,
2934 QModelIndex& iv3, QModelIndex& iv4, int nb)
2938 HEXA_NS::Quads hstarts;
2939 int nbQuads = istarts.size();
2940 for (int i = 0; i < nbQuads; ++i)
2941 hstarts.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
2943 HEXA_NS::Quad* hdest = getHexaPtr<HEXA_NS::Quad*>(idest);
2944 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
2945 HEXA_NS::Vertex* hv2 = getHexaPtr<HEXA_NS::Vertex*>(iv2);
2946 HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(iv3);
2947 HEXA_NS::Vertex* hv4 = getHexaPtr<HEXA_NS::Vertex*>(iv4);
2949 HEXA_NS::Elements* helts = _hexaDocument->joinQuadsUni(hstarts, hdest, hv1, hv2, hv3, hv4, nb);
2950 if (BadElement(helts))
2953 result = addElementsToTree(helts, _elementsDirItem);
2958 QModelIndex DocumentModel::joinQuads(QModelIndexList& istarts, QModelIndex& idest, QModelIndex& iva1, QModelIndex& ivb1,
2959 QModelIndex& iva2, QModelIndex& ivb2, vector<double>& tlen)
2963 HEXA_NS::Quads hstarts;
2964 int nbQuads = istarts.size();
2965 for (int i = 0; i < nbQuads; ++i)
2966 hstarts.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
2968 HEXA_NS::Quad* hdest = getHexaPtr<HEXA_NS::Quad*>(idest);
2969 HEXA_NS::Vertex* hva1 = getHexaPtr<HEXA_NS::Vertex*>(iva1);
2970 HEXA_NS::Vertex* hvb1 = getHexaPtr<HEXA_NS::Vertex*>(ivb1);
2971 HEXA_NS::Vertex* hva2 = getHexaPtr<HEXA_NS::Vertex*>(iva2);
2972 HEXA_NS::Vertex* hvb2 = getHexaPtr<HEXA_NS::Vertex*>(ivb2);
2974 HEXA_NS::Elements* helts = _hexaDocument->joinQuads(hstarts, hdest, hva1, hvb1, hva2, hvb2, tlen);
2975 if (BadElement(helts))
2978 result = addElementsToTree(helts, _elementsDirItem);
2983 // ======== Quad Revolution
2984 QModelIndex DocumentModel::revolutionQuadUni(QModelIndex& istart, QModelIndex& icenter, QModelIndex& iaxis,
2985 double angle, int nbre)
2989 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
2990 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2991 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
2993 HEXA_NS::Elements* helts = _hexaDocument->revolutionQuadUni(hstart, hcenter, haxis, angle, nbre);
2994 if (BadElement(helts))
2997 result = addElementsToTree(helts, _elementsDirItem);
3002 QModelIndex DocumentModel::revolutionQuad(QModelIndex& istart, QModelIndex& icenter, QModelIndex& iaxis,
3003 vector<double>& angles)
3007 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
3008 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
3009 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
3011 HEXA_NS::Elements* helts = _hexaDocument->revolutionQuad(hstart, hcenter, haxis, angles);
3012 if (BadElement(helts))
3015 result = addElementsToTree(helts, _elementsDirItem);
3020 QModelIndex DocumentModel::revolutionQuadsUni(QModelIndexList& istarts, QModelIndex& icenter, QModelIndex& iaxis,
3021 double angle, int nbre)
3025 HEXA_NS::Quads hstarts;
3026 int nbQuads = istarts.count();
3027 for (int i = 0; i < nbQuads; ++i)
3028 hstarts.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
3030 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
3031 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
3033 HEXA_NS::Elements* helts = _hexaDocument->revolutionQuadsUni(hstarts, hcenter, haxis, angle, nbre);
3034 if (BadElement(helts))
3037 result = addElementsToTree(helts, _elementsDirItem);
3042 QModelIndex DocumentModel::revolutionQuads(QModelIndexList& istarts, QModelIndex& icenter, QModelIndex& iaxis,
3043 vector<double>& angles)
3047 HEXA_NS::Quads hstarts;
3048 int nbQuads = istarts.count();
3049 for (int i = 0; i < nbQuads; ++i)
3050 hstarts.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
3052 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
3053 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
3055 HEXA_NS::Elements* helts = _hexaDocument->revolutionQuads(hstarts, hcenter, haxis, angles);
3056 if (BadElement(helts))
3059 result = addElementsToTree(helts, _elementsDirItem);
3065 // ==== PrismQuad or ExtrudeQuad
3066 QModelIndex DocumentModel::extrudeQuadTop(QModelIndex& istart, int nbre)
3070 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
3071 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuadTop(hstart, nbre);
3072 if (BadElement(helts))
3075 result = addElementsToTree(helts, _elementsDirItem);
3080 QModelIndex DocumentModel::extrudeQuadUni(QModelIndex& istart, QModelIndex& dv, double len, int nbre)
3084 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
3085 HEXA_NS::Vector* hvec = getHexaPtr<HEXA_NS::Vector*>(dv);
3087 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuadUni(hstart, hvec, len, nbre);
3088 if (BadElement(helts))
3091 result = addElementsToTree(helts, _elementsDirItem);
3096 QModelIndex DocumentModel::extrudeQuad(QModelIndex& istart, QModelIndex& dv, vector<double>& tlen)
3100 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
3101 HEXA_NS::Vector* hvec = getHexaPtr<HEXA_NS::Vector*>(dv);
3103 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuad(hstart, hvec, tlen);
3104 if (BadElement(helts))
3106 result = addElementsToTree(helts, _elementsDirItem);
3111 QModelIndex DocumentModel::extrudeQuadsTop (QModelIndexList& istarts, int nbre)
3115 HEXA_NS::Quads hquads;
3116 int nbQuads = istarts.count();
3117 for (int i = 0; i < nbQuads; ++i)
3118 hquads.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
3120 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuadsTop(hquads, nbre);
3121 if (BadElement(helts))
3123 result = addElementsToTree(helts, _elementsDirItem);
3128 QModelIndex DocumentModel::extrudeQuadsUni (QModelIndexList& istarts, QModelIndex& axis, double len, int nbre)
3132 HEXA_NS::Quads hquads;
3133 int nbQuads = istarts.count();
3134 for (int i = 0; i < nbQuads; ++i)
3135 hquads.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
3137 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(axis);
3139 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuadsUni(hquads, haxis, len, nbre);
3140 if (BadElement(helts))
3142 result = addElementsToTree(helts, _elementsDirItem);
3147 QModelIndex DocumentModel::extrudeQuads(QModelIndexList& istarts, QModelIndex& iaxis, vector<double>& tlen)
3151 HEXA_NS::Quads hquads;
3152 int nbQuads = istarts.count();
3153 for (int i=0; i < nbQuads; ++i)
3154 hquads.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
3156 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
3158 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuads(hquads, haxis, tlen);
3159 if (BadElement(helts))
3161 result = addElementsToTree(helts, _elementsDirItem);
3167 QModelIndex DocumentModel::cutUni(QModelIndex& iEdge, int nbre)
3171 HEXA_NS::Edge* hedge = getHexaPtr<HEXA_NS::Edge*>(iEdge);
3173 HEXA_NS::Elements* helts = _hexaDocument->cutUni(hedge, nbre);
3174 if (BadElement(helts))
3176 result = addElementsToTree(helts, _elementsDirItem);
3181 QModelIndex DocumentModel::cut(QModelIndex& iEdge, vector<double>& tlen)
3185 HEXA_NS::Edge* hedge = getHexaPtr<HEXA_NS::Edge*>(iEdge);
3187 HEXA_NS::Elements* helts = _hexaDocument->cut(hedge, tlen);
3188 if (BadElement(helts))
3190 result = addElementsToTree(helts, _elementsDirItem);
3195 // ================================== END NEW ==================================