1 // Copyright (C) 2009-2015 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, or (at your option) any later version.
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"
52 #include <Geom_Circle.hxx>
53 #include <gp_Circ.hxx>
54 #include <BRep_Tool.hxx>
55 #include <TopoDS_Edge.hxx>
60 //using namespace HEXA_NS;
61 using namespace HEXABLOCK::GUI;
63 /*****************************************************************
65 *****************************************************************/
66 // DocumentModel::DocumentModel(QObject * parent):
67 DocumentModel::DocumentModel(HEXA_NS::Document* docIn, const QString& entryIn, QObject * parent):
68 QStandardItemModel(parent),
69 _hexaFile( new QTemporaryFile() ),
70 _hexaDocument( docIn ),
72 // _hexaDocument( new HEXA_NS::Document("/tmp/doc.hex") ), //CS_TODO
74 _vertexDirItem( new QStandardItem(tr("TREE_ITEM_VERTEX")) ),
75 _edgeDirItem( new QStandardItem(tr("TREE_ITEM_EDGE")) ),
76 _quadDirItem( new QStandardItem(tr("TREE_ITEM_QUAD")) ),
77 _hexaDirItem( new QStandardItem(tr("TREE_ITEM_HEXA")) ),
79 _vectorDirItem( new QStandardItem(tr("TREE_ITEM_VECTOR")) ),
80 _elementsDirItem( new QStandardItem(tr("TREE_ITEM_ELEMENT")) ),
81 _crossElementsDirItem( new QStandardItem(tr("TREE_ITEM_CROSSELEMENT")) ),
83 _explicitShapesDirItem( new QStandardItem(tr("TREE_ITEM_EXPSHAPE")) ),
84 _implicitShapesDirItem( new QStandardItem(tr("TREE_ITEM_IMPSHAPE")) ),
85 _cloudOfPointsDirItem( new QStandardItem(tr("TREE_ITEM_CLOUD_OF_POINT")) ),
87 _groupDirItem( new QStandardItem(tr("TREE_ITEM_GROUP")) ),
89 _lawDirItem( new QStandardItem(tr("TREE_ITEM_LAW")) ),
90 _propagationDirItem( new QStandardItem(tr("TREE_ITEM_PROPAGATION")) ),
92 _vertexItemFlags( Qt::NoItemFlags ),
93 _edgeItemFlags( Qt::NoItemFlags ),
94 _quadItemFlags( Qt::NoItemFlags ),
95 _hexaItemFlags( Qt::NoItemFlags ),
96 _vectorItemFlags( Qt::NoItemFlags ),
97 _elementsItemFlags( Qt::NoItemFlags ),
98 _crossElementsItemFlags( Qt::NoItemFlags ),
100 _disallowEdition( false )
102 // setColumnCount( 4 ); //CS_TEST
103 if ( !_hexaDocument && _hexaFile->open() ){
104 _hexaDocument = new HEXA_NS::Document( _hexaFile->fileName().toLatin1() );
105 _hexaDocument->reorderFaces();
108 QStandardItem *parentItem = invisibleRootItem();
109 // parentItem->setData( QString::number( reinterpret_cast<intptr_t>(_hexaDocument) ), HEXA_ENTRY_ROLE );
110 parentItem->setData( _entry, HEXA_ENTRY_ROLE );
112 _vertexDirItem->setData( VERTEX_DIR_TREE, HEXA_TREE_ROLE );
113 _edgeDirItem->setData( EDGE_DIR_TREE, HEXA_TREE_ROLE );
114 _quadDirItem->setData( QUAD_DIR_TREE, HEXA_TREE_ROLE );
115 _hexaDirItem->setData( HEXA_DIR_TREE, HEXA_TREE_ROLE );
117 _vectorDirItem->setData( VECTOR_DIR_TREE, HEXA_TREE_ROLE );
118 _elementsDirItem->setData( ELEMENTS_DIR_TREE, HEXA_TREE_ROLE );
119 _crossElementsDirItem->setData( CROSSELEMENTS_DIR_TREE, HEXA_TREE_ROLE );
121 _explicitShapesDirItem->setData( EXPLICIT_SHAPES_DIR_TREE, HEXA_TREE_ROLE );
122 _implicitShapesDirItem->setData( IMPLICIT_SHAPES_DIR_TREE, HEXA_TREE_ROLE );
123 _cloudOfPointsDirItem->setData( CLOUD_OF_POINTS_DIR_TREE, HEXA_TREE_ROLE );
125 _groupDirItem->setData( GROUP_DIR_TREE, HEXA_TREE_ROLE );
127 //CS_TODO associations
129 _lawDirItem->setData( LAW_DIR_TREE, HEXA_TREE_ROLE );
130 _propagationDirItem->setData( PROPAGATION_DIR_TREE, HEXA_TREE_ROLE );
132 parentItem->appendRow(_vertexDirItem);
133 parentItem->appendRow(_edgeDirItem);
134 parentItem->appendRow(_quadDirItem);
135 parentItem->appendRow(_hexaDirItem);
137 parentItem->appendRow(_vectorDirItem);
138 parentItem->appendRow(_elementsDirItem);
139 parentItem->appendRow(_crossElementsDirItem);
141 parentItem->appendRow(_explicitShapesDirItem);
142 parentItem->appendRow(_implicitShapesDirItem);
144 parentItem->appendRow(_groupDirItem);
145 parentItem->appendRow(_lawDirItem);
146 parentItem->appendRow(_propagationDirItem);
149 DocumentModel::~DocumentModel()
151 if (_hexaDocument != NULL)
152 delete _hexaDocument;
154 if (_hexaFile != NULL)
158 void DocumentModel::setName(const QString& name)
160 _hexaDocument->setName( name.toLocal8Bit().constData() );
161 emit nameChanged(QString(_hexaDocument->getName()));
164 HEXA_NS::EltBase* DocumentModel::getHexaPtr(const QModelIndex& iElt)
166 HEXA_NS::EltBase *elt = NULL;
167 switch ( /*data(iElt, HEXA_TREE_ROLE).toInt()*/iElt.data(HEXA_TREE_ROLE).toInt() ){
168 case VERTEX_TREE : elt = getHexaPtr<HEXA_NS::Vertex*>(iElt); break;
169 case EDGE_TREE : elt = getHexaPtr<HEXA_NS::Edge*>(iElt); break;
170 case QUAD_TREE : elt = getHexaPtr<HEXA_NS::Quad*>(iElt); break;
171 case HEXA_TREE : elt = getHexaPtr<HEXA_NS::Hexa*>(iElt); break;
172 case VECTOR_TREE : elt = getHexaPtr<HEXA_NS::Vector*>(iElt); break;
173 case ELEMENTS_TREE : elt = getHexaPtr<HEXA_NS::Elements*>(iElt); break;
174 // case CROSSELEMENTS_TREE : elt = getHexaPtr<HEXA_NS::CrossElements*>(iElt); break;
175 case GEOMSHAPE_TREE: elt = getHexaPtr<HEXA_NS::NewShape*>(iElt); break;
176 case GEOMPOINT_TREE: elt = getHexaPtr<HEXA_NS::VertexShape*>(iElt); break;
177 case GEOMEDGE_TREE: elt = getHexaPtr<HEXA_NS::EdgeShape*>(iElt); break;
178 case GEOMFACE_TREE: elt = getHexaPtr<HEXA_NS::FaceShape*>(iElt); break;
183 //get the number of elements of type 'eltType' in the document
184 int DocumentModel::getNbrElt(HEXA_NS::EnumElt eltType)
186 if (_hexaDocument == NULL) return 0;
188 return _hexaDocument->getNbrElt(eltType);
191 //get the number of elements of type 'eltType' used in the document
192 int DocumentModel::getNbrUsedElt(HEXA_NS::EnumElt eltType)
194 if (_hexaDocument == NULL) return 0;
197 case HEXA_NS::EL_VERTEX:
198 return _hexaDocument->countUsedVertex();
199 case HEXA_NS::EL_EDGE:
200 return _hexaDocument->countUsedEdge();
201 case HEXA_NS::EL_QUAD:
202 return _hexaDocument->countUsedQuad();
203 case HEXA_NS::EL_HEXA:
204 return _hexaDocument->countUsedHexa();
209 //associate a shape to the current document
210 bool DocumentModel::addShape(TopoDS_Shape& aShape, QString& name, bool publish)
212 if (aShape.IsNull() || name.isEmpty())
214 bool ok = (_hexaDocument != NULL ? _hexaDocument->addShape(aShape, name.toStdString().c_str()) != NULL : false);
216 // * publish the shape in the study
219 HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance();
222 QMap<QString, TopoDS_Shape> topo_shapes;
223 topo_shapes[name] = aShape;
224 module->addInStudy(topo_shapes, docShapesEntry, docShapesName);
235 //get the number of unused elements of type 'eltType' in the document
236 int DocumentModel::getNbrUnusedElt(HEXA_NS::EnumElt eltType)
238 if (_hexaDocument == NULL)
241 return getNbrElt(eltType) - getNbrUsedElt(eltType);
244 // compute the length of the given edge
245 double DocumentModel::getLength(const QModelIndex& iEdge)
247 // * Get the pointer to the edge
248 HEXA_NS::Edge* edge = getHexaPtr<HEXA_NS::Edge*>(iEdge);
249 HEXA_NS::EdgeShape* geomEdge = getHexaPtr<HEXA_NS::EdgeShape*>(iEdge);
251 // * The edge can be from VTK or OCC View
253 return edge->getLength();
254 else if (geomEdge != NULL)
255 return geomEdge->getLength();
260 // Compute the radius of the given edge
261 double DocumentModel::getRadius(const QModelIndex& iEdge)
263 // * Get the pointer to the edge
264 // * In our case only an OCC edge can have a radius
265 HEXA_NS::EdgeShape* edge = getHexaPtr<HEXA_NS::EdgeShape*>(iEdge);
269 return edge->getRadius();
272 // Compute the angle of the given edge (internal angle)
273 double DocumentModel::getAngle(const QModelIndex& iEdge)
275 // * Get the pointer to the edge
276 HEXA_NS::EdgeShape* edge = getHexaPtr<HEXA_NS::EdgeShape*>(iEdge);
280 return edge->getAngle();
283 //Load the current Document
284 void DocumentModel::load()
286 if (_hexaDocument == NULL)
289 load(_hexaDocument->getName());
293 void DocumentModel::load( const QString& xmlFileName ) // Fill Data
295 _hexaDocument->loadXml(xmlFileName.toLocal8Bit().constData() );
305 emit patternDataChanged();
308 bool DocumentModel::isEmpty() const
310 if (_hexaDocument == NULL) return true;
311 return _hexaDocument->isEmpty();
314 void DocumentModel::save( const QString& xmlFileName )
316 _hexaDocument->save( xmlFileName.toLocal8Bit().constData() );
319 QString DocumentModel::getName()
321 return _hexaDocument->getName();
324 void DocumentModel::updateData()
330 emit patternDataChanged();
333 void DocumentModel::updateGeomTree()
339 QModelIndex DocumentModel::addElementsToTree(HEXA_NS::Elements* helts, QStandardItem* tree)
341 QModelIndex eltIndex;
342 if (helts == NULL || tree == NULL)
346 ElementsItem* eltsItem = new ElementsItem(helts);
347 tree->appendRow(eltsItem);
349 return eltsItem->index();
352 void DocumentModel::refresh()
363 emit patternDataChanged();
366 void DocumentModel::clearAll()
376 void DocumentModel::clearData()
378 _vertexDirItem->removeRows( 0, _vertexDirItem->rowCount() );
379 _edgeDirItem->removeRows(0, _edgeDirItem->rowCount() );
380 _quadDirItem->removeRows(0, _quadDirItem->rowCount() );
381 _hexaDirItem->removeRows(0, _hexaDirItem->rowCount() );
383 _vectorDirItem->removeRows(0, _vectorDirItem->rowCount() );
384 _elementsDirItem->removeRows(0, _elementsDirItem->rowCount() );
385 _crossElementsDirItem->removeRows(0, _crossElementsDirItem->rowCount() );
389 //void DocumentModel::clearBuilder()
391 // _vectorDirItem->removeRows(0, _vectorDirItem->rowCount() );
392 // _elementsDirItem->removeRows(0, _elementsDirItem->rowCount() );
393 // _crossElementsDirItem->removeRows(0, _crossElementsDirItem->rowCount() );
396 void DocumentModel::clearGeometry()
398 _explicitShapesDirItem->removeRows(0, _explicitShapesDirItem->rowCount() );
399 _implicitShapesDirItem->removeRows(0, _implicitShapesDirItem->rowCount() );
400 _cloudOfPointsDirItem->removeRows(0, _cloudOfPointsDirItem->rowCount() );
403 void DocumentModel::clearAssociation()
408 void DocumentModel::clearGroups()
410 _groupDirItem->removeRows(0, _groupDirItem->rowCount() );
413 void DocumentModel::clearMesh()
415 _lawDirItem->removeRows(0, _lawDirItem->rowCount() );
416 _propagationDirItem->removeRows(0, _propagationDirItem->rowCount() );
420 void DocumentModel::fillData()
422 PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
425 pdsm->clearHighlightedItems();
428 HEXA_NS::Vertex *v = NULL;
429 VertexItem *vItem = NULL;
430 int nbVertex = _hexaDocument->countVertex();
431 for ( int i=0; i<nbVertex; ++i ){
432 v = _hexaDocument->getVertex(i);
433 vItem = new VertexItem(v, _entry);
434 _vertexDirItem->appendRow(vItem);
437 HEXA_NS::Edge *e = NULL;
438 EdgeItem *eItem = NULL;
439 int nbEdge = _hexaDocument->countEdge();
440 for ( int i=0; i<nbEdge; ++i ){
441 e = _hexaDocument->getEdge(i);
442 eItem = new EdgeItem(e, _entry);
443 _edgeDirItem->appendRow(eItem);
446 HEXA_NS::Quad *q = NULL;
447 QuadItem *qItem = NULL;
448 int nbQuad = _hexaDocument->countQuad();
449 for ( int i=0; i<nbQuad; ++i ){
450 q = _hexaDocument->getQuad(i);
451 qItem = new QuadItem(q, _entry);
452 _quadDirItem->appendRow(qItem);
455 HEXA_NS::Hexa *h = NULL;
456 HexaItem *hItem = NULL;
457 int nbHexa = _hexaDocument->countHexa();
458 for ( int i=0; i<nbHexa; ++i ){
459 h = _hexaDocument->getHexa(i);
460 hItem = new HexaItem(h, _entry);
461 _hexaDirItem->appendRow(hItem);
464 // +++++ Builder ++++++++++++++++++++++++++++++
466 HEXA_NS::Vector *vec = NULL;
467 VectorItem *vecItem = NULL;
468 int nbVector = _hexaDocument->countVector();
469 for ( int i=0; i<nbVector; ++i ){
470 vec = _hexaDocument->getVector(i);
471 vecItem = new VectorItem(vec);
472 _vectorDirItem->appendRow(vecItem);
475 //******* A VOIR AVEC ALAIN POUR LE REMPLISSAGE DE L'ARBRE ELEMENTS ET CROSSELEMENTS (ByCylinder) *******/
476 //******* OU SONT STOCKES LES ELEMENTS ET LES CROSSELEMENTS DANS LE DOCUMENT? ******/
479 // HEXA_NS::Cylinder *c = NULL;
480 // HEXA_NS::Elements* c = NULL;
481 // CylinderItem *cItem = NULL;
482 // ElementsItem* cItem = NULL;
483 // int nbCylinder = _hexaDocument->countCylinder();
484 // for ( int i=0; i<nbCylinder; ++i ){
485 // c = _hexaDocument->getCylinder(i);
486 // cItem = new CylinderItem(c, _entry);
487 // cItem = new ElementsItem(c, _entry);
488 // _cylinderDirItem->appendRow(cItem);
489 // _elementsDirItem->appendRow(cItem);
493 // HEXA_NS::Pipe *p = NULL;
494 // HEXA_NS::Elements* p = NULL;
495 // PipeItem *pItem = NULL;
496 // ElementsItem* pItem = NULL;
497 // int nbPipe = _hexaDocument->countPipe();
498 // for ( int i=0; i<nbPipe; ++i ){
499 // p = _hexaDocument->getPipe(i);
500 // pItem = new PipeItem(p);
501 // pItem = new ElementsItem(p, _entry);
502 // _pipeDirItem->appendRow(pItem);
503 // _elementsDirItem->appendRow(pItem);
505 //********************************************************************************************************
509 //void DocumentModel::fillBuilder()
511 // HEXA_NS::Vector *v = NULL;
512 // VectorItem *vItem = NULL;
513 // int nbVector = _hexaDocument->countVector();
514 // for ( int i=0; i<nbVector; ++i ){
515 // v = _hexaDocument->getVector(i);
516 // vItem = new VectorItem(v);
517 // _vectorDirItem->appendRow(vItem);
520 // //******* A VOIR AVEC ALAIN POUR LE REMPLISSAGE DE L'ARBRE ELEMENTS ET CROSSELEMENTS (ByCylinder) *******/
521 // //******* OU SONT STOCKES LES ELEMENTS ET LES CROSSELEMENTS DANS LE DOCUMENT? ******/
523 // // _cylinderDirItem
524 //// HEXA_NS::Cylinder *c = NULL;
525 //// HEXA_NS::Elements* c = NULL;
526 //// CylinderItem *cItem = NULL;
527 //// ElementsItem* cItem = NULL;
528 //// int nbCylinder = _hexaDocument->countCylinder();
529 //// for ( int i=0; i<nbCylinder; ++i ){
530 //// c = _hexaDocument->getCylinder(i);
531 //// cItem = new CylinderItem(c, _entry);
532 //// cItem = new ElementsItem(c, _entry);
533 //// _cylinderDirItem->appendRow(cItem);
534 //// _elementsDirItem->appendRow(cItem);
538 //// HEXA_NS::Pipe *p = NULL;
539 //// HEXA_NS::Elements* p = NULL;
540 //// PipeItem *pItem = NULL;
541 //// ElementsItem* pItem = NULL;
542 //// int nbPipe = _hexaDocument->countPipe();
543 //// for ( int i=0; i<nbPipe; ++i ){
544 //// p = _hexaDocument->getPipe(i);
545 //// pItem = new PipeItem(p);
546 //// pItem = new ElementsItem(p, _entry);
547 //// _pipeDirItem->appendRow(pItem);
548 //// _elementsDirItem->appendRow(pItem);
550 // //********************************************************************************************************
553 void DocumentModel::fillGeometry()
555 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
556 if (_hexaDocument == NULL /*|| isEmpty()*/ || pgsm == NULL)
559 HEXA_NS::NewShape* shape;
560 HEXA_NS::VertexShape* node;
561 HEXA_NS::EdgeShape* line;
562 HEXA_NS::FaceShape* face;
563 TopoDS_Compound vertexCompound;
564 BRep_Builder compoundBuilder;
566 // * fill the shape tree
569 pgsm->clearHighlightedItems();
570 QMap<QString, TopoDS_Shape> topo_shapes;
571 int nbShapes = _hexaDocument->countShape();
572 for (int i=0; i < nbShapes; ++i)
574 shape = _hexaDocument->getShape(i);
575 QString shapeName = shape->getName();
576 if (!docShapesEntry.contains(shapeName))
578 if (shape->getOrigin() == HEXA_NS::SH_CLOUD)
580 compoundBuilder.MakeCompound(vertexCompound);
581 topo_shapes[shapeName] = vertexCompound;
584 topo_shapes[shapeName] = shape->getShape();
587 GeomShapeItem* shItem = new GeomShapeItem(shape);
588 if (shape->getOrigin() == HEXA_NS::SH_IMPORT)
590 _explicitShapesDirItem->appendRow(shItem);
593 _implicitShapesDirItem->appendRow(shItem);
595 //add vertices to the tree
596 QStandardItem* geomPointDirItem = NULL;
597 if (shape->getOrigin() != HEXA_NS::SH_CLOUD)
599 geomPointDirItem = new QStandardItem(tr("TREE_ITEM_VERTEX"));
600 geomPointDirItem->setData( GEOMPOINT_DIR_TREE, HEXA_TREE_ROLE );
602 if (geomPointDirItem != NULL)
603 shItem->appendRow(geomPointDirItem);
604 int nbVertexShape = shape->countVertex();
605 for (int j=0; j < nbVertexShape; ++j)
607 node = shape->getVertexShape(j);
608 GeomPointItem* gPointItem = new GeomPointItem(node);
609 if (geomPointDirItem != NULL)
610 geomPointDirItem->appendRow(gPointItem);
612 shItem->appendRow(gPointItem);
613 shapeById[shapeName+","+QString::number(node->getIdent())] = node;
615 // * update the compound of vertices
616 if (shape->getOrigin() == HEXA_NS::SH_CLOUD && !vertexCompound.IsNull())
617 compoundBuilder.Add(topo_shapes[shapeName], node->getShape());
620 if (shape->getOrigin() == HEXA_NS::SH_CLOUD)
621 continue; // * it's a cloud of points, there's no edges and no quads to fill
623 //add edges to the tree
624 QStandardItem* geomEdgeDirItem = new QStandardItem(tr("TREE_ITEM_EDGE"));
625 geomEdgeDirItem->setData( GEOMEDGE_DIR_TREE, HEXA_TREE_ROLE );
626 shItem->appendRow(geomEdgeDirItem);
627 int nbEdgeShape = shape->countEdge();
628 for (int j = 0; j < nbEdgeShape; ++j)
630 line = shape->getEdgeShape(j);
631 GeomEdgeItem* gEdgeItem = new GeomEdgeItem(line);
632 geomEdgeDirItem->appendRow(gEdgeItem);
633 shapeById[shapeName+","+QString::number(line->getIdent())] = line;
636 //add faces to the tree
637 QStandardItem* geomFaceDirItem = new QStandardItem(tr("TREE_ITEM_QUAD"));
638 geomFaceDirItem->setData( GEOMFACE_DIR_TREE, HEXA_TREE_ROLE );
639 shItem->appendRow(geomFaceDirItem);
640 int nbFaceShape = shape->countFace();
641 for (int j = 0; j < nbFaceShape; ++j)
643 face = shape->getFaceShape(j);
644 GeomFaceItem* gFaceItem = new GeomFaceItem(face);
645 geomFaceDirItem->appendRow(gFaceItem);
646 shapeById[shapeName+","+QString::number(face->getIdent())] = face;
650 if (topo_shapes.size() == 0)
654 HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance();
656 module->addInStudy(topo_shapes, docShapesEntry, docShapesName);
659 void DocumentModel::fillAssociation()
663 //------------------------------------------- NEW ITEMS
664 //void DocumentModel::fillGroups()
666 // HEXA_NS::Group *g = NULL;
667 // GroupItem *gItem = NULL;
668 // int nbGroup = _hexaDocument->countGroup();
669 // for ( int i=0; i<nbGroup; ++i ){
670 // g = _hexaDocument->getGroup(i);
671 // gItem = new GroupItem(g, _entry);
672 // _groupDirItem->appendRow(gItem);
676 //void DocumentModel::fillMesh()
678 // HEXA_NS::Law *l = NULL;
679 // LawItem *lItem = NULL;
680 // int nbLaw = _hexaDocument->countLaw();
681 // for ( int i=0; i<nbLaw; ++i ){
682 // l = _hexaDocument->getLaw(i);
683 // lItem = new LawItem(l);
684 // _lawDirItem->appendRow(lItem);
687 // HEXA_NS::Propagation *p = NULL;
688 // PropagationItem *pItem = NULL;
689 // int nbPropagation = _hexaDocument->countPropagation();
690 // for ( int i=0; i<nbPropagation; ++i ){
691 // p = _hexaDocument->getPropagation(i);
692 // pItem = new PropagationItem(p, _entry);
693 // pItem->setText(QString("Propagation%1").arg(i) );
694 // _propagationDirItem->appendRow(pItem);
697 //----------------------------------------------- END NEW ITEMS
699 void DocumentModel::fillGroups()
701 HEXA_NS::Group *g = NULL;
702 GroupItem *gItem = NULL;
703 int nbGroup = _hexaDocument->countGroup();
704 for ( int i=0; i<nbGroup; ++i ){
705 g = _hexaDocument->getGroup(i);
706 //std::cout<<"getGroup => "<< i << std::endl;
707 gItem = new GroupItem(g);
708 gItem->setData( _entry, HEXA_DOC_ENTRY_ROLE );
709 _groupDirItem->appendRow(gItem);
713 void DocumentModel::fillMesh()
716 HEXA_NS::Law *l = NULL;
717 LawItem *lItem = NULL;
718 int nbLaw = _hexaDocument->countLaw();
719 for ( int i=0; i<nbLaw; ++i ){
720 l = _hexaDocument->getLaw(i);
721 lItem = new LawItem(l);
722 _lawDirItem->appendRow(lItem);
725 // _propagationDirItem
726 HEXA_NS::Propagation *p = NULL;
727 PropagationItem *pItem = NULL;
728 int nbPropagation = _hexaDocument->countPropagation();
729 for ( int i=0; i<nbPropagation; ++i ){
730 p = _hexaDocument->getPropagation(i);
731 pItem = new PropagationItem(p);
732 pItem->setText(QString("Propagation%1").arg(i) );
733 pItem->setData( _entry, HEXA_DOC_ENTRY_ROLE );
734 _propagationDirItem->appendRow(pItem);
738 HEXA_NS::Hexa* DocumentModel::getQuadHexa(HEXA_NS::Quad* quad)
741 int nbHexa = _hexaDocument->countHexa();
742 for ( int i=0; i<nbHexa; ++i ){
743 hexa = _hexaDocument->getHexa(i);
744 if (hexa->findQuad(quad) > -1) return hexa;
750 Qt::ItemFlags DocumentModel::flags(const QModelIndex &index) const
754 if (!index.isValid()) return Qt::ItemIsEnabled;
756 if ( _disallowEdition ){
757 return QAbstractItemModel::flags(index) | Qt::ItemFlags( ~Qt::ItemIsEditable );
759 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
763 void DocumentModel::allowEdition()
765 _disallowEdition = false;
768 void DocumentModel::disallowEdition()
770 _disallowEdition = true;
773 void DocumentModel::allowDataSelectionOnly()
775 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
776 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
777 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
778 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
780 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
781 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
782 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
784 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
785 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
786 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
789 void DocumentModel::allowVertexSelectionOnly()
791 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable);
792 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
793 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
794 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
796 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
797 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
798 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
800 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
801 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
802 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
804 // emit layoutChanged();
807 void DocumentModel::allowEdgeSelectionOnly()
809 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
810 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
811 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
812 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
814 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
815 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
816 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
818 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
819 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
820 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
823 void DocumentModel::allowQuadSelectionOnly()
825 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
826 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
827 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
828 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
830 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
831 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
832 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
834 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
835 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
836 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
839 void DocumentModel::allowHexaSelectionOnly()
841 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
842 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
843 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
844 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
846 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
847 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
848 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
850 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
851 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
852 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
855 void DocumentModel::allowVectorSelectionOnly()
857 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
858 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
859 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
860 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
862 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
863 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
864 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
866 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
867 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
868 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
871 void DocumentModel::allowCylinderSelectionOnly()
873 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
874 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
875 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
876 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
878 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
879 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
880 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
882 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
883 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
884 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
887 void DocumentModel::allowPipeSelectionOnly()
889 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
890 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
891 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
892 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
894 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
895 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
896 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
898 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
899 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
900 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
903 void DocumentModel::allowElementsSelectionOnly()
905 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
906 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
907 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
908 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
910 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
911 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
912 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
914 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
915 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
916 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
919 /**********************************************************
920 void DocumentModel::allowCrossElementsSelectionOnly()
922 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
923 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
924 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
925 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
927 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
928 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
929 _crossElementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
931 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
932 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
933 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
935 ********************************************************** */
937 void DocumentModel::allowLawSelectionOnly()
939 _vertexItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
940 _edgeItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
941 _quadItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
942 _hexaItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
944 _vectorItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
945 _elementsItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
946 _crossElementsItemFlags = Qt::ItemFlags( Qt::ItemIsEnabled );
948 _groupItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
949 _lawItemFlags = Qt::ItemFlags( ~Qt::ItemIsEditable );
950 _propagationItemFlags = Qt::ItemFlags( ~Qt::ItemIsEnabled );
954 void DocumentModel::setName( const QModelIndex& iElt, const QString& name )
956 HEXA_NS::EltBase *elt = NULL;
958 switch ( data(iElt, HEXA_TREE_ROLE).toInt() ){
961 HEXA_NS::Group* grp = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Group* >();
962 grp->setName( name.toLatin1().data() );
967 HEXA_NS::Law* l = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Law* >();
968 l->setName( name.toLatin1().data() );
971 // case PROPAGATION_TREE : elt = iElt.data( HEXA_DATA_ROLE ).value< HEXA_NS::Propagation* >(); break;
972 default: elt = getHexaPtr(iElt);
975 if ( elt != NULL ) elt->setName( name.toStdString() );
976 setData( iElt, name );
980 bool DocumentModel::clearEltAssociations( const QModelIndex& iElt )
983 HEXA_NS::EltBase *elt = getHexaPtr(iElt);
986 elt->clearAssociation();
987 setData( iElt, QVariant(), HEXA_ASSOC_ENTRY_ROLE );
994 void DocumentModel::clearAssociation(HEXA_NS::EnumElt& eltType)
996 if (_hexaDocument != NULL)
997 _hexaDocument->clearAssociation(eltType);
1000 HEXA_NS::Vertex* vertex;
1001 HEXA_NS::Edge* edge;
1002 HEXA_NS::Quad* quad;
1005 if (HEXABLOCKGUI::currentDocGView == NULL) return;
1006 PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
1007 PatternDataModel* pdm = HEXABLOCKGUI::currentDocGView->getPatternDataModel();
1008 if (pdsm == NULL || pdm == NULL) return;
1010 //update associations in the model
1011 if (eltType == HEXA_NS::EL_VERTEX)
1013 nbElts = _hexaDocument->countVertex();
1014 for (int i = 0; i < nbElts; ++i)
1016 vertex = _hexaDocument->getVertex(i);
1017 iElt = pdm->mapToSource(pdsm->indexBy(HEXA_DATA_ROLE, QVariant::fromValue(vertex)));
1019 setData( iElt, QVariant(), HEXA_ASSOC_ENTRY_ROLE );
1022 else if (eltType == HEXA_NS::EL_EDGE)
1024 nbElts = _hexaDocument->countEdge();
1025 for (int i = 0; i < nbElts; ++i)
1027 edge = _hexaDocument->getEdge(i);
1028 iElt = pdm->mapToSource(pdsm->indexBy(HEXA_DATA_ROLE, QVariant::fromValue(edge)));
1030 setData( iElt, QVariant(), HEXA_ASSOC_ENTRY_ROLE );
1033 else if (eltType == HEXA_NS::EL_QUAD)
1035 nbElts = _hexaDocument->countQuad();
1036 for (int i = 0; i < nbElts; ++i)
1038 quad = _hexaDocument->getQuad(i);
1039 iElt = pdm->mapToSource(pdsm->indexBy(HEXA_DATA_ROLE, QVariant::fromValue(quad)));
1041 setData( iElt, QVariant(), HEXA_ASSOC_ENTRY_ROLE );
1047 QModelIndex DocumentModel::addVertex( double x, double y, double z )
1049 QModelIndex vertexIndex;
1051 HEXA_NS::Vertex* hv = _hexaDocument->addVertex(x, y, z);
1052 if (BadElement(hv)) return vertexIndex;
1054 VertexItem* v = new VertexItem(hv, _entry);
1055 _vertexDirItem->appendRow(v);
1056 vertexIndex = v->index();
1057 emit patternDataChanged();
1062 QModelIndex DocumentModel::addEdgeVertices (const QModelIndex &i_v0, const QModelIndex &i_v1 )
1064 QModelIndex edgeIndex;
1066 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(i_v0);
1067 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(i_v1);
1069 HEXA_NS::Edge* he = _hexaDocument->addEdge( hv0, hv1 );
1070 if ( BadElement(he) ) return edgeIndex;
1072 EdgeItem* e = new EdgeItem(he, _entry);
1073 _edgeDirItem->appendRow(e);
1074 edgeIndex = e->index();
1075 emit patternDataChanged();
1080 QModelIndex DocumentModel::addEdgeVector( const QModelIndex &i_v, const QModelIndex &i_vec )
1082 QModelIndex edgeIndex;
1084 HEXA_NS::Vertex* hv = getHexaPtr<HEXA_NS::Vertex*>(i_v);
1085 HEXA_NS::Vector* hvec = getHexaPtr<HEXA_NS::Vector*>(i_vec);
1087 if (hv == NULL || hvec == NULL) return edgeIndex;
1089 HEXA_NS::Edge* he = _hexaDocument->addEdgeVector( hv, hvec );
1090 if ( BadElement(he) ) return edgeIndex;
1092 HEXA_NS::Vertex* hv2 = he->getAval(); //the new vertex resulting from the creation of the edge
1093 if (hv2 == NULL) return edgeIndex;
1095 //ADD the edge in the treeview
1096 EdgeItem* e = new EdgeItem(he, _entry);
1097 _edgeDirItem->appendRow(e);
1098 edgeIndex = e->index();
1100 //The resulting Vertex
1101 VertexItem* v = new VertexItem(hv2, _entry);
1102 _vertexDirItem->appendRow(v);
1104 emit patternDataChanged();
1109 QModelIndex DocumentModel::addQuadVertices( const QModelIndex &i_v0, const QModelIndex &i_v1,
1110 const QModelIndex &i_v2, const QModelIndex &i_v3 )
1111 { //CS_TODO : gestion erreur
1112 QModelIndex quadIndex;
1114 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(i_v0);
1115 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(i_v1);
1116 HEXA_NS::Vertex* hv2 = getHexaPtr<HEXA_NS::Vertex*>(i_v2);
1117 HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(i_v3);
1119 if ( hv0 && hv1 && hv2 && hv3 ){
1120 HEXA_NS::Quad* hq = _hexaDocument->addQuadVertices( hv0, hv1, hv2, hv3 );
1121 if ( BadElement(hq) ) return quadIndex;
1123 QuadItem* q = new QuadItem(hq, _entry);
1124 _quadDirItem->appendRow(q);
1125 quadIndex = q->index();
1126 emit patternDataChanged();
1132 QModelIndex DocumentModel::addQuadEdges( const QModelIndex &e0, const QModelIndex &e1,
1133 const QModelIndex &e2, const QModelIndex &e3 )
1135 QModelIndex quadIndex;
1137 HEXA_NS::Edge* he0 = getHexaPtr<HEXA_NS::Edge*>(e0);
1138 HEXA_NS::Edge* he1 = getHexaPtr<HEXA_NS::Edge*>(e1);
1139 HEXA_NS::Edge* he2 = getHexaPtr<HEXA_NS::Edge*>(e2);
1140 HEXA_NS::Edge* he3 = getHexaPtr<HEXA_NS::Edge*>(e3);
1142 if ( he0 && he1 && he2 && he3 ){
1144 HEXA_NS::Quad* hq = _hexaDocument->addQuad( he0, he1, he2, he3 );
1145 if ( BadElement(hq) ) return quadIndex;
1147 QuadItem* q = new QuadItem(hq, _entry);
1148 _quadDirItem->appendRow(q);
1149 quadIndex = q->index();
1150 emit patternDataChanged();
1156 QModelIndex DocumentModel::addHexaVertices(
1157 const QModelIndex &iv0, const QModelIndex &iv1,
1158 const QModelIndex &iv2, const QModelIndex &iv3,
1159 const QModelIndex &iv4, const QModelIndex &iv5,
1160 const QModelIndex &iv6, const QModelIndex &iv7 )
1164 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(iv0);
1165 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
1166 HEXA_NS::Vertex* hv2 = getHexaPtr<HEXA_NS::Vertex*>(iv2);
1167 HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(iv3);
1168 HEXA_NS::Vertex* hv4 = getHexaPtr<HEXA_NS::Vertex*>(iv4);
1169 HEXA_NS::Vertex* hv5 = getHexaPtr<HEXA_NS::Vertex*>(iv5);
1170 HEXA_NS::Vertex* hv6 = getHexaPtr<HEXA_NS::Vertex*>(iv6);
1171 HEXA_NS::Vertex* hv7 = getHexaPtr<HEXA_NS::Vertex*>(iv7);
1173 HEXA_NS::Hexa* hh = _hexaDocument->addHexaVertices( hv0, hv1, hv2, hv3,
1174 hv4, hv5, hv6, hv7 );
1176 if ( BadElement(hh) ) return iHexa;
1178 HexaItem* h = new HexaItem(hh, _entry);
1179 _hexaDirItem->appendRow(h);
1181 emit patternDataChanged();
1186 QModelIndex DocumentModel::addHexaQuad( const QModelIndex &i_q0, const QModelIndex &i_q1,
1187 const QModelIndex &i_q2,const QModelIndex &i_q3, const QModelIndex &i_q4, const QModelIndex &i_q5 )
1188 { //CS_TODO : gestion erreur
1189 QModelIndex hexaIndex;
1191 HEXA_NS::Quad* hq0 = getHexaPtr<HEXA_NS::Quad*>(i_q0);
1192 HEXA_NS::Quad* hq1 = getHexaPtr<HEXA_NS::Quad*>(i_q1);
1193 HEXA_NS::Quad* hq2 = getHexaPtr<HEXA_NS::Quad*>(i_q2);
1194 HEXA_NS::Quad* hq3 = getHexaPtr<HEXA_NS::Quad*>(i_q3);
1195 HEXA_NS::Quad* hq4 = getHexaPtr<HEXA_NS::Quad*>(i_q4);
1196 HEXA_NS::Quad* hq5 = getHexaPtr<HEXA_NS::Quad*>(i_q5);
1198 HEXA_NS::Hexa* hh = _hexaDocument->addHexa( hq0, hq1, hq2, hq3, hq4, hq5 );
1199 if ( BadElement(hh) ) return hexaIndex;
1201 HexaItem* h = new HexaItem(hh, _entry);
1202 _hexaDirItem->appendRow(h);
1203 hexaIndex = h->index();
1204 emit patternDataChanged();
1209 QModelIndex DocumentModel::addHexaQuads( const QModelIndexList &iquads)
1211 QModelIndex hexaIndex;
1213 HEXA_NS::Hexa* hh = NULL;
1214 HEXA_NS::Quad* hq0, *hq1, *hq2, *hq3, *hq4, *hq5 = NULL;
1216 hq0 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(0));
1217 hq1 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(1));
1218 hq2 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(2));
1219 hq3 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(3));
1220 hq4 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(4));
1221 hq5 = getHexaPtr<HEXA_NS::Quad*>(iquads.value(5));
1223 if ( hq0 && hq1 && hq2 && hq3 && hq4 && hq5 )
1224 hh = _hexaDocument->addHexa( hq0, hq1, hq2, hq3, hq4, hq5 );
1225 else if ( hq0 && hq1 && hq2 && hq3 && hq4 )
1226 hh = _hexaDocument->addHexa5Quads( hq0, hq1, hq2, hq3, hq4 );
1227 else if ( hq0 && hq1 && hq2 && hq3 )
1228 hh = _hexaDocument->addHexa4Quads( hq0, hq1, hq2, hq3 );
1229 else if ( hq0 && hq1 && hq2)
1230 hh = _hexaDocument->addHexa3Quads( hq0, hq1, hq2 );
1231 else if ( hq0 && hq1 )
1232 hh = _hexaDocument->addHexa2Quads( hq0, hq1);
1234 if ( BadElement(hh) ) return hexaIndex;
1237 unsigned int nbRows = _hexaDirItem->rowCount();
1239 hexaIndex = _hexaDirItem->child(nbRows-1)->index();
1244 QModelIndex DocumentModel::addVector( double dx, double dy, double dz )
1246 QModelIndex vectorIndex;
1248 HEXA_NS::Vector* hv = _hexaDocument->addVector(dx, dy, dz);
1249 if ( BadElement(hv) ) return vectorIndex; //Invalid index
1251 VectorItem* v = new VectorItem(hv);
1252 _vectorDirItem->appendRow(v);
1253 vectorIndex = v->index();
1258 QModelIndex DocumentModel::addVectorVertices( const QModelIndex &iv0, const QModelIndex &iv1 )
1262 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(iv0);
1263 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
1265 HEXA_NS::Vector* hvec = _hexaDocument->addVectorVertices( hv0, hv1 );
1266 if ( BadElement(hvec) ) return iVec;
1268 VectorItem* vec = new VectorItem(hvec);
1269 _vectorDirItem->appendRow(vec);
1270 iVec = vec->index();
1276 // ************ EDIT HEXABLOCK MODEL ************
1278 bool DocumentModel::updateVertex( const QModelIndex& ivertex, double x, double y, double z )
1282 HEXA_NS::Vertex* hVertex = getHexaPtr<HEXA_NS::Vertex*>(ivertex);
1285 // hVertex->setName( name.toStdString() );
1286 hVertex->setX ( x );
1287 hVertex->setY ( y );
1288 hVertex->setZ ( z );
1289 emit patternDataChanged();
1296 bool DocumentModel::removeHexa( const QModelIndex& ihexa )
1298 HEXA_NS::Hexa* hHexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1300 int r = _hexaDocument->removeHexa( hHexa );
1309 bool DocumentModel::removeConnectedHexa( const QModelIndex& ihexa )
1311 HEXA_NS::Hexa* hHexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1313 int r = _hexaDocument->removeConnectedHexa( hHexa );
1322 bool DocumentModel::mergeVertices( const QModelIndex &iv0, const QModelIndex &iv1 ) //CS_TODO : impact sur le model?
1324 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(iv0);
1325 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
1327 int r = _hexaDocument->mergeVertices( hv0, hv1 );
1329 updateData(); //CS_TODO more or less?
1336 bool DocumentModel::mergeEdges( const QModelIndex &ie0, const QModelIndex &ie1,
1337 const QModelIndex &iv0, const QModelIndex &iv1 )
1338 //CS_TODO : impact sur le model?
1340 HEXA_NS::Edge* he0 = getHexaPtr<HEXA_NS::Edge*>(ie0);
1341 HEXA_NS::Edge* he1 = getHexaPtr<HEXA_NS::Edge*>(ie1);
1343 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(iv0);
1344 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
1347 int r = _hexaDocument->mergeEdges( he0, he1, hv0, hv1 );
1356 bool DocumentModel::mergeQuads( const QModelIndex& iquad0, const QModelIndex& iquad1,
1357 const QModelIndex& iv0, const QModelIndex& iv1,
1358 const QModelIndex& iv2, const QModelIndex& iv3 )
1360 HEXA_NS::Quad* hquad0 = data(iquad0, HEXA_DATA_ROLE).value<HEXA_NS::Quad *>();
1361 HEXA_NS::Quad* hquad1 = data(iquad1, HEXA_DATA_ROLE).value<HEXA_NS::Quad *>();
1363 HEXA_NS::Vertex* hv0 = getHexaPtr<HEXA_NS::Vertex*>(iv0);
1364 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
1365 HEXA_NS::Vertex* hv2 = getHexaPtr<HEXA_NS::Vertex*>(iv2);
1366 HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(iv3);
1368 int r = _hexaDocument->mergeQuads( hquad0, hquad1, hv0, hv1, hv2, hv3 );
1378 QModelIndex DocumentModel::disconnectVertex( const QModelIndex& ihexa, const QModelIndex& ivertex )
1382 HEXA_NS::Hexa* hHexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1383 HEXA_NS::Vertex* hVertex = getHexaPtr<HEXA_NS::Vertex*>(ivertex);
1385 HEXA_NS::Elements* hElts = _hexaDocument->disconnectVertex( hHexa, hVertex );
1386 if ( BadElement(hElts) ) return iElts;
1388 updateData(); //CS_TO_CHECK
1389 ElementsItem* elts = new ElementsItem(hElts);
1390 _elementsDirItem->appendRow(elts);
1391 iElts = elts->index();
1396 QModelIndex DocumentModel::disconnectEdge( const QModelIndex& ihexa, const QModelIndex& iedge )
1400 HEXA_NS::Hexa* hHexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1401 HEXA_NS::Edge* hEdge = getHexaPtr<HEXA_NS::Edge*>(iedge);
1403 HEXA_NS::Elements* hElts = _hexaDocument->disconnectEdge( hHexa, hEdge );
1404 if ( BadElement(hElts) ) return iElts;
1406 updateData(); //CS_TO_CHECK
1407 ElementsItem* elts = new ElementsItem(hElts);
1408 _elementsDirItem->appendRow(elts);
1409 iElts = elts->index();
1415 QModelIndex DocumentModel::disconnectEdges( const QModelIndexList& ihexas, const QModelIndexList& iedges )
1419 HEXA_NS::Hexas hHexas;
1420 HEXA_NS::Edges hEdges;
1423 HEXA_NS::Edge* hedge = NULL;
1424 foreach( const QModelIndex& iedge, iedges ){
1425 hedge = getHexaPtr<HEXA_NS::Edge*>(iedge);
1426 hEdges.push_back( hedge );
1430 HEXA_NS::Hexa* hhexa = NULL;
1431 foreach( const QModelIndex& ihexa, ihexas ){
1432 hhexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1433 hHexas.push_back( hhexa );
1437 HEXA_NS::Elements* hElts = _hexaDocument->disconnectEdges( hHexas, hEdges );
1438 if ( BadElement(hElts) ) return iElts;
1440 updateData(); //CS_TO_CHECK
1441 ElementsItem* elts = new ElementsItem(hElts);
1442 _elementsDirItem->appendRow(elts);
1443 iElts = elts->index();
1449 QModelIndex DocumentModel::disconnectQuad( const QModelIndex& ihexa, const QModelIndex& iquad )
1453 HEXA_NS::Hexa* hHexa = getHexaPtr<HEXA_NS::Hexa*>(ihexa);
1454 HEXA_NS::Quad* hQuad = getHexaPtr<HEXA_NS::Quad*>(iquad);
1456 HEXA_NS::Elements* hElts = _hexaDocument->disconnectQuad( hHexa, hQuad );
1457 if ( BadElement(hElts) ) return iElts;
1459 updateData(); //CS_TO_CHECK
1460 ElementsItem* elts = new ElementsItem(hElts);
1461 _elementsDirItem->appendRow(elts);
1462 iElts = elts->index();
1468 QModelIndex DocumentModel::makeTranslation( const QModelIndex& ielts, const QModelIndex& ivec )
1472 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1473 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1475 HEXA_NS::Elements* hNewElts = _hexaDocument->makeTranslation( hElts, hVec );
1476 if ( BadElement(hNewElts) ) return iElts;
1478 updateData(); //CS_TODO more or less?
1479 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1480 _elementsDirItem->appendRow(eltsItem);
1481 iElts = eltsItem->index();
1488 QModelIndex DocumentModel::makeScale( const QModelIndex& ielts, const QModelIndex& ivex, double k )
1492 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1493 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1495 HEXA_NS::Elements* hNewElts = _hexaDocument->makeScale( hElts, hVex, k );
1496 if ( BadElement(hNewElts) ) return iElts;
1498 updateData(); //CS_TODO more or less?
1499 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1500 _elementsDirItem->appendRow(eltsItem);
1501 iElts = eltsItem->index();
1506 QModelIndex DocumentModel::makeRotation( const QModelIndex& ielts,
1507 const QModelIndex& iv,
1508 const QModelIndex& ivec, double angle )
1512 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1513 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(iv);
1514 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1516 HEXA_NS::Elements* hNewElts = _hexaDocument->makeRotation( hElts, hVex, hVec, angle );
1517 if ( BadElement(hNewElts) ) return iElts;
1519 updateData(); //CS_TODO more or less?
1520 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1521 _elementsDirItem->appendRow(eltsItem);
1522 iElts = eltsItem->index();
1528 QModelIndex DocumentModel::makeSymmetryPoint( const QModelIndex& ielts, const QModelIndex& iv )
1532 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1533 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(iv);
1535 HEXA_NS::Elements* hNewElts = _hexaDocument->makeSymmetryPoint (hElts, hVex);
1536 if ( BadElement(hNewElts) ) return iElts;
1538 updateData(); //CS_TODO more or less?
1539 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1540 _elementsDirItem->appendRow(eltsItem);
1541 iElts = eltsItem->index();
1547 QModelIndex DocumentModel::makeSymmetryLine( const QModelIndex& ielts,
1548 const QModelIndex& iv,
1549 const QModelIndex& ivec )
1553 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1554 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(iv);
1555 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1558 HEXA_NS::Elements* hNewElts = _hexaDocument->makeSymmetryLine( hElts, hVex, hVec );
1559 if ( BadElement(hNewElts) ) return iElts;
1561 updateData(); //CS_TODO more or less?
1562 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1563 _elementsDirItem->appendRow(eltsItem);
1564 iElts = eltsItem->index();
1570 QModelIndex DocumentModel::makeSymmetryPlane( const QModelIndex& ielts, const QModelIndex& iv, const QModelIndex& ivec )
1574 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1575 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(iv);
1576 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1578 HEXA_NS::Elements* hNewElts = _hexaDocument->makeSymmetryPlane( hElts, hVex, hVec );
1579 if ( BadElement(hNewElts) ) return iElts;
1581 updateData(); //CS_TODO more or less?
1582 ElementsItem* eltsItem = new ElementsItem(hNewElts);
1583 _elementsDirItem->appendRow(eltsItem);
1584 iElts = eltsItem->index();
1590 bool DocumentModel::performTranslation( const QModelIndex& ielts, const QModelIndex& ivec )
1592 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1593 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1595 int r = _hexaDocument->performTranslation (hElts, hVec);
1596 if ( r == HOK ){ //Job well done?
1606 bool DocumentModel::performScale( const QModelIndex& ielts, const QModelIndex& ivex, double k )
1608 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1609 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1611 int r = _hexaDocument->performScale (hElts, hVex, k);
1621 bool DocumentModel::performRotation( const QModelIndex& ielts, const QModelIndex& ivex, const QModelIndex& ivec, double angle )
1623 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1624 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1625 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1627 int r = _hexaDocument-> performRotation( hElts, hVex, hVec, angle );
1638 bool DocumentModel::performSymmetryPoint( const QModelIndex& ielts, const QModelIndex& ivex )
1640 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1641 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1643 int r = _hexaDocument->performSymmetryPoint( hElts, hVex );
1653 bool DocumentModel::performSymmetryLine( const QModelIndex& ielts, const QModelIndex& ivex, const QModelIndex& ivec )
1655 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1656 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1657 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1659 int r = _hexaDocument->performSymmetryLine( hElts, hVex, hVec );
1669 bool DocumentModel::performSymmetryPlane( const QModelIndex& ielts,
1670 const QModelIndex& ivex,
1671 const QModelIndex& ivec )
1673 HEXA_NS::Elements* hElts = getHexaPtr<HEXA_NS::Elements*>(ielts);
1674 HEXA_NS::Vertex* hVex = getHexaPtr<HEXA_NS::Vertex*>(ivex);
1675 HEXA_NS::Vector* hVec = getHexaPtr<HEXA_NS::Vector*>(ivec);
1677 int r = _hexaDocument->performSymmetryPlane( hElts, hVex, hVec );
1686 QModelIndex DocumentModel::replace( const QModelIndexList& iquads_source,
1687 const QModelIndexList& iquads_dest,
1688 const QModelIndex& ip1_source, const QModelIndex& ic1_dest,
1689 const QModelIndex& ip2_source, const QModelIndex& ic2_dest)
1693 HEXA_NS::Vertex* hp1 = getHexaPtr<HEXA_NS::Vertex*>(ip1_source);
1694 HEXA_NS::Vertex* hp2 = getHexaPtr<HEXA_NS::Vertex*>(ip2_source);
1695 HEXA_NS::Vertex* hc1 = getHexaPtr<HEXA_NS::Vertex*>(ic1_dest);
1696 HEXA_NS::Vertex* hc2 = getHexaPtr<HEXA_NS::Vertex*>(ic2_dest);
1698 HEXA_NS::Quads hquads_source, hquads_dest;
1699 HEXA_NS::Quad* hquad = NULL;
1700 foreach( const QModelIndex& iquad, iquads_source ){
1701 hquad = getHexaPtr<HEXA_NS::Quad*>(iquad);
1702 hquads_source.push_back( hquad );
1705 foreach( const QModelIndex& iquad, iquads_dest) {
1706 hquad = getHexaPtr<HEXA_NS::Quad*>(iquad);
1707 hquads_dest.push_back(hquad);
1710 HEXA_NS::Elements* helts = _hexaDocument->replace( hquads_source,
1712 hp1, hc1, hp2, hc2);
1713 if ( BadElement(helts) )
1717 ElementsItem* eltsItem = new ElementsItem(helts);
1718 _elementsDirItem->appendRow(eltsItem);
1719 ielts = eltsItem->index();
1724 QModelIndex DocumentModel::getGeomModelIndex(QString& id) const
1727 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
1729 // ** get the model index of the geom element having this ID
1730 HEXA_NS::SubShape* eltPtr = getGeomPtr(id);
1731 HEXA_NS::VertexShape* geomVertex = dynamic_cast<HEXA_NS::VertexShape*>(eltPtr);
1732 HEXA_NS::EdgeShape* geomEdge = dynamic_cast<HEXA_NS::EdgeShape*>(eltPtr);
1733 HEXA_NS::FaceShape* geomFace = dynamic_cast<HEXA_NS::FaceShape*>(eltPtr);
1734 if (geomVertex != NULL)
1735 result = pgsm->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(geomVertex));
1736 if (geomEdge != NULL)
1737 result = pgsm->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(geomEdge));
1738 if (geomFace != NULL)
1739 result = pgsm->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(geomFace));
1744 QMultiMap< QString, int > DocumentModel::getAssocShapesIds(const QModelIndex& dataIndex)
1746 QMultiMap< QString, int > result;
1747 HEXA_NS::NewShape* mainShape;
1748 HEXA_NS::VertexShape* node;
1749 HEXA_NS::EdgeShape* line;
1750 HEXA_NS::FaceShape* face;
1754 PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
1755 QModelIndexList assocsInd = pdsm->getGeomAssociations(dataIndex);
1756 foreach( const QModelIndex& anAssoc, assocsInd )
1758 node = getHexaPtr<HEXA_NS::VertexShape*>(anAssoc);
1759 line = getHexaPtr<HEXA_NS::EdgeShape*>(anAssoc);
1760 face = getHexaPtr<HEXA_NS::FaceShape*>(anAssoc);
1764 mainShape = node->getParentShape();
1765 if (mainShape != NULL)
1767 shapeName = mainShape->getName();
1768 subid = node->getIdent();
1771 else if (line != NULL)
1773 mainShape = line->getParentShape();
1774 if (mainShape != NULL)
1776 shapeName = mainShape->getName();
1777 subid = line->getIdent();
1780 else if (face != NULL)
1782 mainShape = face->getParentShape();
1783 if (mainShape != NULL)
1785 shapeName = mainShape->getName();
1786 subid = face->getIdent();
1790 if (!shapeName.isEmpty())
1791 result.insert( shapeName, subid );
1793 shapeName = QString();
1798 bool DocumentModel::setVertexAssociation( const QModelIndex& iVertex, double x, double y, double z)
1800 HEXA_NS::Vertex* vertex = getHexaPtr<HEXA_NS::Vertex *>(iVertex);
1802 if (vertex == NULL || _hexaDocument == NULL || vertex->setAssociation(x, y, z) != HOK)
1805 HEXA_NS::VertexShape* assoc = vertex->getAssociation();
1808 HEXA_NS::NewShape* mainSh = assoc->getParentShape();
1809 setData( iVertex, QVariant::fromValue(QString(mainSh->getName())+","+QString::number(assoc->getIdent())+";"), HEXA_ASSOC_ENTRY_ROLE );
1815 bool DocumentModel::setVertexAssociation( const QModelIndex& iVertex, const QModelIndex& iGeomVertex)
1817 //parameters control
1819 HEXA_NS::Vertex* vertex = getHexaPtr<HEXA_NS::Vertex *>(iVertex);
1820 HEXA_NS::VertexShape* geomVertex = getHexaPtr<HEXA_NS::VertexShape*>(iGeomVertex);
1821 if (_hexaDocument == NULL || vertex == NULL || geomVertex == NULL) return false;
1822 HEXA_NS::NewShape* mainShape = geomVertex->getParentShape();
1823 if (mainShape == NULL) return false;
1826 if (vertex->setAssociation(geomVertex) != HOK)
1829 //update association state in the model
1830 newAssoc = QString(mainShape->getName()) + "," + QString::number(geomVertex->getIdent()) + ";";
1831 setData( iVertex, QVariant::fromValue(newAssoc), HEXA_ASSOC_ENTRY_ROLE );
1836 bool DocumentModel::addEdgeAssociation( const QModelIndex& iEdge, const QModelIndex& iGeomEdge, double start, double end)
1838 //parameters control
1839 QString currentAssoc, newAssoc;
1840 HEXA_NS::Edge* edge = getHexaPtr<HEXA_NS::Edge*>(iEdge);
1841 HEXA_NS::EdgeShape* geomEdge = getHexaPtr<HEXA_NS::EdgeShape*>(iGeomEdge);
1842 if (_hexaDocument == NULL || edge == NULL ||
1843 geomEdge == NULL || start > end) return false;
1844 HEXA_NS::NewShape* mainShape = geomEdge->getParentShape();
1845 if (mainShape == NULL) return false;
1847 //add association in the engine side
1848 if (edge->addAssociation(geomEdge, start, end) != HOK)
1851 //add/update association in the model side (UI)
1852 currentAssoc = data(iEdge, HEXA_ASSOC_ENTRY_ROLE).toString();
1853 newAssoc = QString(mainShape->getName()) + "," + QString::number(geomEdge->getIdent()) + ";";
1854 if (!currentAssoc.isEmpty()) newAssoc = currentAssoc + newAssoc;
1856 setData( iEdge, QVariant::fromValue(newAssoc), HEXA_ASSOC_ENTRY_ROLE );
1862 bool DocumentModel::addQuadAssociation (const QModelIndex& iQuad, const QModelIndex& iGeomFace)
1864 //parameters control
1865 QString currentAssoc, newAssoc;
1866 HEXA_NS::Quad* quad = getHexaPtr<HEXA_NS::Quad*>(iQuad);
1867 HEXA_NS::FaceShape* geomFace = getHexaPtr<HEXA_NS::FaceShape*>(iGeomFace);
1868 if (_hexaDocument == NULL || quad == NULL || geomFace == NULL)
1870 HEXA_NS::NewShape* mainShape = geomFace->getParentShape();
1871 if (mainShape == NULL) return false;
1874 if (quad->addAssociation(geomFace) != HOK)
1877 //update association
1878 currentAssoc = data( iQuad, HEXA_ASSOC_ENTRY_ROLE).toString();
1879 newAssoc = QString(mainShape->getName()) + "," + QString::number(geomFace->getIdent()) + ";";
1880 if (!currentAssoc.isEmpty()) newAssoc = currentAssoc + newAssoc;
1881 setData( iQuad, QVariant::fromValue(newAssoc), HEXA_ASSOC_ENTRY_ROLE );
1887 QModelIndex DocumentModel::getVertexAssociation(const QModelIndex& iVertex)
1889 HEXA_NS::Vertex* vertex = getHexaPtr<HEXA_NS::Vertex*>(iVertex);
1891 return QModelIndex();
1893 //get the associated geom vertex
1894 HEXA_NS::VertexShape* geomVertex = vertex->getAssociation();
1895 if (geomVertex == NULL)
1896 return QModelIndex();
1898 //convert geom vertex to qmodelindex
1899 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
1901 return QModelIndex();
1903 return pgsm->indexBy(HEXA_DATA_ROLE, QVariant::fromValue(geomVertex));
1907 QModelIndexList DocumentModel::getEdgeAssociations(const QModelIndex& iEdge)
1909 QModelIndexList result;
1910 HEXA_NS::Edge* edge = getHexaPtr<HEXA_NS::Edge*>(iEdge);
1911 if (edge == NULL) return result;
1913 HEXA_NS::EdgeShape* geomEdge;
1914 HEXA_NS::AssoEdge* anEdgeAssoc;
1916 PatternGeomSelectionModel* pGSModel = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
1917 int nbAssocs = edge->countAssociation();
1918 for (int i = 0; i < nbAssocs; ++i)
1920 anEdgeAssoc = edge->getAssociation(i);
1921 if (anEdgeAssoc == NULL) continue;
1922 geomEdge = anEdgeAssoc->getEdgeShape();
1923 if (geomEdge == NULL) continue;
1924 result << pGSModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(geomEdge));
1931 QModelIndexList DocumentModel::getQuadAssociations(const QModelIndex& iQuad)
1933 QModelIndexList result;
1934 QModelIndex geomQuadIndex;
1935 HEXA_NS::Quad* quad = getHexaPtr<HEXA_NS::Quad*>(iQuad);
1936 if (quad == NULL) return result;
1938 if (HEXABLOCKGUI::currentDocGView == NULL) return result;
1939 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
1940 PatternGeomModel* pgm = HEXABLOCKGUI::currentDocGView->getPatternGeomModel();
1941 if (pgsm == NULL || pgm == NULL) return result;
1943 HEXA_NS::FaceShape* geomFace;
1945 int nbAssocs = quad->countAssociation();
1946 for (int i = 0; i < nbAssocs; ++i)
1948 geomFace = quad->getAssociation(i);
1949 if (geomFace == NULL) continue;
1951 geomQuadIndex = pgsm->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(geomFace) );
1952 result << geomQuadIndex;
1959 bool DocumentModel::associateOpenedLine( const QModelIndexList& iedges,
1960 HEXA_NS::NewShapes shapes,
1961 HEXA_NS::IntVector subIds,
1966 HEXA_NS::Edges mline;
1968 HEXA_NS::Edge* hedge = NULL;
1969 foreach( const QModelIndex& iedge, iedges ){
1970 hedge = getHexaPtr<HEXA_NS::Edge*>(iedge);
1972 mline.push_back( hedge );
1975 int err = _hexaDocument->associateOpenedLine( mline, shapes, subIds, pstart, pend );
1983 bool DocumentModel::associateClosedLine( const QModelIndex& ivertex,
1984 const QModelIndexList& iedges,
1985 HEXA_NS::NewShapes shapes,
1986 HEXA_NS::IntVector subIds,
1990 HEXA_NS::Vertex* mfirst = getHexaPtr<HEXA_NS::Vertex*>(ivertex);
1991 HEXA_NS::Edges mline;
1993 HEXA_NS::Edge* hedge = NULL;
1994 foreach( const QModelIndex& iedge, iedges ){
1995 hedge = getHexaPtr<HEXA_NS::Edge*>(iedge);
1997 mline.push_back( hedge );
2000 int err = _hexaDocument->associateClosedLine( mfirst, mline, shapes, subIds, pstart, inv);
2008 // ************ GROUPS ************
2010 QModelIndex DocumentModel::addGroup( const QString& name, Group kind )
2014 HEXA_NS::Group* hGroup = _hexaDocument->addGroup( name.toLocal8Bit().constData(), kind );
2015 if ( hGroup == NULL ) return iGroup;
2017 GroupItem* groupItem = new GroupItem(hGroup);
2018 groupItem->setData( _entry, HEXA_DOC_ENTRY_ROLE );
2019 _groupDirItem->appendRow(groupItem);
2020 iGroup = groupItem->index();
2026 bool DocumentModel::removeGroup( const QModelIndex& igrp )
2028 HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
2029 int r = _hexaDocument->removeGroup ( hGroup );
2032 removeRow( igrp.row(), igrp.parent());
2040 QModelIndexList DocumentModel::getGroupElements( const QModelIndex& iGroup, DocumentModel::Group& kind ) const
2042 QModelIndexList iElements;
2044 HEXA_NS::Group* g = iGroup.data(HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
2045 if ( g == NULL ) return iElements;
2047 QModelIndexList iFound;
2049 HEXA_NS::EltBase* eltBase = NULL;
2050 int nbElement = g->countElement();
2051 for ( int nr = 0; nr < nbElement; ++nr ){
2052 eltBase = g->getElement( nr );
2053 kind = g->getKind();
2055 case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: q = QVariant::fromValue( (HEXA_NS::Hexa *)eltBase ); break;
2056 case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: q = QVariant::fromValue( (HEXA_NS::Quad *)eltBase ); break;
2057 case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: q = QVariant::fromValue( (HEXA_NS::Edge *)eltBase ); break;
2058 case HEXA_NS::VertexNode: q = QVariant::fromValue( (HEXA_NS::Vertex *)eltBase ); break;
2060 iFound = match( index(0, 0),
2064 Qt::MatchRecursive );
2065 if ( !iFound.isEmpty() )
2066 iElements << iFound[0];
2071 // 7.4 Boite: éditer un groupe
2072 void DocumentModel::setGroupName( const QModelIndex& igrp, const QString& name )
2074 HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
2077 hGroup->setName( name.toLocal8Bit().constData() );
2078 setData(igrp, QVariant::fromValue( name ) );
2082 bool DocumentModel::addGroupElement( const QModelIndex& igrp, const QModelIndex& ielt )
2084 HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
2085 if (hGroup == NULL) return false;
2087 HEXA_NS::EltBase* hElt = NULL;
2088 switch ( hGroup->getKind() ){
2089 case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: hElt = getHexaPtr<HEXA_NS::Hexa*>(ielt); break;
2090 case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: hElt = getHexaPtr<HEXA_NS::Quad*>(ielt); break;
2091 case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: hElt = getHexaPtr<HEXA_NS::Edge*>(ielt); break;
2092 case HEXA_NS::VertexNode: hElt = getHexaPtr<HEXA_NS::Vertex*>(ielt); break;
2097 res = hGroup->addElement( hElt );
2099 if ( res == HOK ) return true;
2104 bool DocumentModel::removeGroupElement( const QModelIndex& igrp, int nro )
2105 { //CS_TODO : remove child?
2106 HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
2107 if (hGroup == NULL) return false;
2109 if (hGroup->removeElement( nro ) == HOK) return true;
2114 bool DocumentModel::clearGroupElement( const QModelIndex& igrp )
2116 HEXA_NS::Group* hGroup = data(igrp, HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
2118 if ( hGroup != NULL)
2120 hGroup->clearElement();
2126 // ************ LAWS ************
2129 QModelIndex DocumentModel::addLaw( const QString& name, int nbnodes )
2133 HEXA_NS::Law* hLaw = _hexaDocument->addLaw( name.toLocal8Bit().constData(), nbnodes );
2134 if ( BadElement(hLaw) ) return iLaw;
2136 LawItem* lawItem = new LawItem(hLaw);
2137 _lawDirItem->appendRow(lawItem);
2138 iLaw = lawItem->index();
2143 bool DocumentModel::setLaw( const QModelIndex& ilaw, int nbnodes, double coeff, KindLaw type )
2147 HEXA_NS::Law* hLaw = data(ilaw, HEXA_DATA_ROLE).value<HEXA_NS::Law *>();
2151 ok = hLaw->setNodes( nbnodes );
2152 ( ok == HOK) ? ret = true : ret = false;
2153 ok = hLaw->setCoefficient( coeff );
2154 hLaw->setKind(type);
2161 bool DocumentModel::removeLaw( const QModelIndex& ilaw )
2163 HEXA_NS::Law* hLaw = data(ilaw, HEXA_DATA_ROLE).value<HEXA_NS::Law *>();
2164 int r = _hexaDocument->removeLaw( hLaw );
2167 removeRow( ilaw.row(), ilaw.parent());
2174 bool DocumentModel::setPropagation( const QModelIndex& iPropagation, const QModelIndex& iLaw, bool way )
2176 HEXA_NS::Propagation* hPropagation = data(iPropagation, HEXA_DATA_ROLE).value<HEXA_NS::Propagation *>();
2177 HEXA_NS::Law* hLaw = data(iLaw, HEXA_DATA_ROLE).value<HEXA_NS::Law *>();
2179 int r = hPropagation->setLaw( hLaw );
2180 hPropagation->setWay( way );
2182 if ( r == HOK ) return true;
2188 QModelIndexList DocumentModel::getPropagation( const QModelIndex& iPropagation ) const
2190 QModelIndexList iEdges;
2192 QModelIndexList iFound;
2193 HEXA_NS::Propagation* propa = iPropagation.data(HEXA_DATA_ROLE).value<HEXA_NS::Propagation *>();
2194 if ( propa == NULL ) return iEdges;
2196 const HEXA_NS::Edges& edges = propa->getEdges();
2197 for ( HEXA_NS::Edges::const_iterator anEdge = edges.begin(), endIt = edges.end();
2200 iFound = match( index(0, 0),
2202 QVariant::fromValue( *anEdge ),
2204 Qt::MatchRecursive);
2205 if ( !iFound.isEmpty() )
2206 iEdges << iFound[0];
2212 HEXA_NS::Document* DocumentModel::documentImpl()
2214 return _hexaDocument;
2217 QString DocumentModel::documentEntry()
2222 // 8.3 Boite: éditer une loi CS_TODO
2225 /*****************************************************************
2227 *****************************************************************/
2229 PatternDataModel::PatternDataModel( QObject * parent ) :
2230 QSortFilterProxyModel( parent )
2232 QString dataRegExp = QString("(%1|%2|%3|%4|%5|%6|%7|%8|%9|%10|%11|%12)").
2233 arg(VERTEX_TREE).arg(EDGE_TREE).arg(QUAD_TREE).arg(HEXA_TREE).arg(VECTOR_TREE).arg(ELEMENTS_TREE).
2234 arg(VERTEX_DIR_TREE).arg(EDGE_DIR_TREE).arg(QUAD_DIR_TREE).arg(HEXA_DIR_TREE).arg(VECTOR_DIR_TREE).
2235 arg(ELEMENTS_DIR_TREE);
2237 setFilterRole(HEXA_TREE_ROLE);
2238 setFilterRegExp ( QRegExp(dataRegExp) );
2241 // *** Pour suppression des panneaux "Builder" et "Geometry" ****/
2243 //PatternDataModel::PatternDataModel( QObject * parent ) :
2244 // QSortFilterProxyModel( parent )
2246 // 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)").
2247 // arg(VERTEX_TREE).arg(EDGE_TREE).arg(QUAD_TREE).arg(HEXA_TREE).
2248 // arg(VERTEX_DIR_TREE).arg(EDGE_DIR_TREE).arg(QUAD_DIR_TREE).
2249 // arg(HEXA_DIR_TREE).arg(VECTOR_TREE).arg(ELEMENTS_TREE).
2250 // arg(VECTOR_DIR_TREE).arg(ELEMENTS_DIR_TREE).
2251 // arg(IMPLICIT_SHAPES_TREE).arg(EXPLICIT_SHAPES_TREE).arg(CLOUD_OF_POINTS_TREE).
2252 // arg(GEOMSHAPE_TREE).arg(GEOMPOINT_TREE).arg(GEOMEDGE_TREE).arg(GEOMFACE_TREE).
2253 // arg(IMPLICIT_SHAPES_DIR_TREE).arg(EXPLICIT_SHAPES_DIR_TREE).arg(CLOUD_OF_POINTS_DIR_TREE).
2254 // arg(GEOMSHAPE_DIR_TREE).arg(GEOMPOINT_DIR_TREE).arg(GEOMEDGE_DIR_TREE).arg(GEOMFACE_DIR_TREE);
2256 // setFilterRole(HEXA_TREE_ROLE);
2257 // setFilterRegExp ( QRegExp(dataRegExp) );
2262 PatternDataModel::~PatternDataModel()
2266 HEXA_NS::Document* PatternDataModel::documentImpl()
2268 HEXA_NS::Document* doc = NULL;
2269 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2270 if (m) doc = m->documentImpl();
2274 QString PatternDataModel::documentEntry()
2277 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2278 if (m) entry = m->documentEntry();
2282 Qt::ItemFlags PatternDataModel::flags(const QModelIndex &index) const
2284 Qt::ItemFlags flags;
2286 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2288 flags = m->flags( mapToSource(index) );
2294 QVariant PatternDataModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2296 if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
2297 return QVariant( "Data" );
2299 return QSortFilterProxyModel::headerData ( section, orientation, role );
2304 QStandardItem* PatternDataModel::itemFromIndex ( const QModelIndex & index ) const
2306 QStandardItem *item = NULL;
2307 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2309 item = m->itemFromIndex( mapToSource(index) );
2314 //PatternBuilderModel::PatternBuilderModel( QObject * parent ) :
2315 // QSortFilterProxyModel( parent )
2317 // QString builderRegExp =QString("(%1|%2|%3|%4|%5|%6)").
2318 // arg(VECTOR_TREE).arg(ELEMENTS_TREE).
2319 // arg(CROSSELEMENTS_TREE).arg(VECTOR_DIR_TREE).arg(ELEMENTS_DIR_TREE).arg(CROSSELEMENTS_DIR_TREE);
2321 // setFilterRole( HEXA_TREE_ROLE );
2322 // setFilterRegExp ( QRegExp( builderRegExp ) );
2325 //PatternBuilderModel::~PatternBuilderModel()
2329 //Qt::ItemFlags PatternBuilderModel::flags(const QModelIndex &index) const
2331 // Qt::ItemFlags flags;
2333 // DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2334 // if ( m != NULL ){
2335 // flags = m->flags( mapToSource(index) );
2340 //QVariant PatternBuilderModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2342 // if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
2343 // return QVariant( "Builder" );
2345 // return QSortFilterProxyModel::headerData ( section, orientation, role );
2349 //QStandardItem* PatternBuilderModel::itemFromIndex ( const QModelIndex & index ) const
2351 // QStandardItem *item = NULL;
2352 // DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2353 // if ( m != NULL ){
2354 // item = m->itemFromIndex( mapToSource(index) );
2359 //====================================================================
2361 //====================================================================
2362 PatternGeomModel::PatternGeomModel( QObject * parent ) :
2363 QSortFilterProxyModel( parent )
2365 QString builderRegExp =QString("(%1|%2|%3|%4|%5|%6|%7|%8|%9|%10|%11|%12|%13|%14)").
2366 arg(EXPLICIT_SHAPES_TREE).arg(IMPLICIT_SHAPES_TREE).arg(CLOUD_OF_POINTS_TREE).
2367 arg(GEOMSHAPE_TREE).arg(GEOMPOINT_TREE).arg(GEOMEDGE_TREE).arg(GEOMFACE_TREE).
2368 arg(EXPLICIT_SHAPES_DIR_TREE).arg(IMPLICIT_SHAPES_DIR_TREE).arg(CLOUD_OF_POINTS_DIR_TREE).
2369 arg(GEOMSHAPE_DIR_TREE).arg(GEOMPOINT_DIR_TREE).arg(GEOMEDGE_DIR_TREE).arg(GEOMFACE_DIR_TREE);
2371 setFilterRole( HEXA_TREE_ROLE );
2372 setFilterRegExp ( QRegExp(builderRegExp ) );
2375 PatternGeomModel::~PatternGeomModel()
2379 Qt::ItemFlags PatternGeomModel::flags(const QModelIndex &index) const
2381 Qt::ItemFlags flags;
2383 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2385 flags = m->flags( mapToSource(index) );
2390 QVariant PatternGeomModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2392 if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
2393 return QVariant( "Geometry" );
2395 return QSortFilterProxyModel::headerData ( section, orientation, role );
2399 QStandardItem* PatternGeomModel::itemFromIndex ( const QModelIndex & index ) const
2401 QStandardItem *item = NULL;
2402 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2404 item = m->itemFromIndex( mapToSource(index) );
2408 //==============================================================
2411 AssociationsModel::AssociationsModel( QObject * parent ) :
2412 QSortFilterProxyModel( parent )
2414 QString assocRegExp;
2416 setFilterRole( HEXA_TREE_ROLE );
2417 setFilterRegExp ( QRegExp(assocRegExp) );
2420 AssociationsModel::~AssociationsModel()
2424 Qt::ItemFlags AssociationsModel::flags(const QModelIndex &index) const
2426 Qt::ItemFlags flags;
2428 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2430 flags = m->flags( mapToSource(index) );
2435 QVariant AssociationsModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2437 if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
2438 return QVariant( "Associations" );
2440 return QSortFilterProxyModel::headerData ( section, orientation, role );
2444 QStandardItem* AssociationsModel::itemFromIndex ( const QModelIndex & index ) const
2446 QStandardItem *item = NULL;
2447 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2449 item = m->itemFromIndex( mapToSource(index) );
2454 GroupsModel::GroupsModel( QObject * parent ) :
2455 QSortFilterProxyModel( parent )
2457 QString groupsRegExp =QString("(%1|%2)").arg(GROUP_TREE).arg(GROUP_DIR_TREE);
2459 setFilterRole( HEXA_TREE_ROLE );
2460 setFilterRegExp ( QRegExp(groupsRegExp ) );
2463 GroupsModel::~GroupsModel()
2467 Qt::ItemFlags GroupsModel::flags(const QModelIndex &index) const
2469 Qt::ItemFlags flags;
2471 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2473 flags = m->flags( mapToSource(index) );
2478 QVariant GroupsModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2480 if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
2481 return QVariant( "Groups" );
2483 return QSortFilterProxyModel::headerData ( section, orientation, role );
2487 QStandardItem* GroupsModel::itemFromIndex ( const QModelIndex & index ) const
2489 QStandardItem *item = NULL;
2490 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2492 item = m->itemFromIndex( mapToSource(index) );
2497 QModelIndexList GroupsModel::getGroupElements( const QModelIndex& iGroup, DocumentModel::Group& kind ) const
2499 QModelIndexList elements;
2500 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2502 elements = m->getGroupElements( mapToSource(iGroup), kind );
2507 MeshModel::MeshModel( QObject * parent ) :
2508 QSortFilterProxyModel( parent )
2510 QString meshRegExp =QString("(%1|%2|%3|%4)").arg(LAW_TREE).arg(LAW_DIR_TREE) .arg(PROPAGATION_TREE).arg(PROPAGATION_DIR_TREE);
2512 setFilterRole( HEXA_TREE_ROLE );
2513 setFilterRegExp ( QRegExp(meshRegExp) );
2516 MeshModel::~MeshModel()
2520 Qt::ItemFlags MeshModel::flags(const QModelIndex &index) const
2522 Qt::ItemFlags flags;
2524 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2526 flags = m->flags( mapToSource(index) );
2531 QVariant MeshModel::headerData ( int section, Qt::Orientation orientation, int role ) const
2533 if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){
2534 return QVariant( "Mesh" );
2536 return QSortFilterProxyModel::headerData ( section, orientation, role );
2540 QStandardItem* MeshModel::itemFromIndex ( const QModelIndex & index ) const
2542 QStandardItem *item = NULL;
2543 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2545 item = m->itemFromIndex( mapToSource(index) );
2550 QModelIndexList MeshModel::getPropagation( const QModelIndex& iPropagation ) const
2552 QModelIndexList edges;
2553 DocumentModel *m = dynamic_cast<DocumentModel *>( sourceModel() );
2555 edges = m->getPropagation( mapToSource(iPropagation) );
2561 // ================================== NEW ======================================
2563 // ===== CARTESIAN GRID
2565 QModelIndex DocumentModel::makeCartesianTop(int nx, int ny, int nz)
2569 HEXA_NS::Elements* helts = _hexaDocument->makeCartesianTop( nx, ny, nz );
2570 if ( BadElement(helts) )
2573 result = addElementsToTree(helts, _elementsDirItem);
2578 QModelIndex DocumentModel::makeCartesianUni(const QModelIndex& icenter,
2579 const QModelIndex& ibase, const QModelIndex& ivec, const QModelIndex& iaxis,
2580 double lx, double ly, double lz, int nx, int ny, int nz)
2584 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2585 HEXA_NS::Vector* hbase = getHexaPtr<HEXA_NS::Vector*>(ibase);
2586 HEXA_NS::Vector* hvec = getHexaPtr<HEXA_NS::Vector*>(ivec);
2587 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
2589 HEXA_NS::Elements* helts = _hexaDocument->makeCartesianUni( hcenter, hbase, hvec, haxis,
2590 lx, ly, lz, nx, ny, nz);
2591 if ( BadElement(helts) )
2594 result = addElementsToTree(helts, _elementsDirItem);
2599 QModelIndex DocumentModel::makeCartesian(const QModelIndex& icenter,
2600 const QModelIndex& ibase, const QModelIndex& ivec, const QModelIndex& iaxis,
2601 vector<double>& radius, vector<double>& angles, vector<double>& heights)
2605 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2606 HEXA_NS::Vector* hbase = getHexaPtr<HEXA_NS::Vector*>(ibase);
2607 HEXA_NS::Vector* hvec = getHexaPtr<HEXA_NS::Vector*>(ivec);
2608 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
2610 HEXA_NS::Elements* helts = _hexaDocument->makeCartesian( hcenter, hbase, hvec, haxis,
2611 radius, angles, heights);
2612 if ( BadElement(helts) )
2615 result = addElementsToTree(helts, _elementsDirItem);
2623 QModelIndex DocumentModel::makeSphereTop (int nr, int na, int nh)
2627 HEXA_NS::Elements* helts = _hexaDocument->makeSphereTop( nr, na, nh );
2628 if ( BadElement(helts) )
2631 result = addElementsToTree(helts, _elementsDirItem);
2636 QModelIndex DocumentModel::makeSphereUni (QModelIndex& icenter,
2637 QModelIndex& ivec_x, QModelIndex& ivec_z,
2638 double rtrou, double rext, double ang,
2639 QModelIndex& ivplan,
2640 int nr, int na, int nh)
2644 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2645 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2646 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2647 HEXA_NS::Vertex* hvplan = getHexaPtr<HEXA_NS::Vertex*>(ivplan);
2649 HEXA_NS::Elements* helts = _hexaDocument->makeSphereUni( hcenter, hvec_x, hvec_z,
2650 rtrou, rext, ang, hvplan,
2652 result = addElementsToTree(helts, _elementsDirItem);
2657 QModelIndex DocumentModel::makeSphere (QModelIndex& icenter,
2658 QModelIndex& ivec_x, QModelIndex& ivec_z,
2659 vector<double>& tray, vector<double>& tang, vector<double>& thaut)
2663 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2664 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2665 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2667 HEXA_NS::Elements* helts = _hexaDocument->makeSphere( hcenter, hvec_x, hvec_z,
2670 result = addElementsToTree(helts, _elementsDirItem);
2677 QModelIndex DocumentModel::makeSphericalTop (int nbre, int crit)
2681 HEXA_NS::Elements* helts = _hexaDocument->makeSphericalTop(nbre, crit);
2682 if (BadElement(helts))
2685 result = addElementsToTree(helts, _elementsDirItem);
2690 QModelIndex DocumentModel::makeSphericalUni (QModelIndex& icenter,
2691 QModelIndex& ivec_x, QModelIndex& ivec_z,
2697 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2698 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2699 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2701 HEXA_NS::Elements* helts = _hexaDocument->makeSphericalUni(hcenter, hvec_x, hvec_z, rayon, nbre, crit);
2702 if (BadElement(helts))
2705 result = addElementsToTree(helts, _elementsDirItem);
2710 QModelIndex DocumentModel::makeSpherical (QModelIndex& icenter,
2711 QModelIndex& ivec_x, QModelIndex& ivec_z,
2712 vector<double>& rayon,
2717 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2718 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2719 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2721 HEXA_NS::Elements* helts = _hexaDocument->makeSpherical(hcenter, hvec_x, hvec_z, rayon, crit);
2722 if (BadElement(helts))
2725 result = addElementsToTree(helts, _elementsDirItem);
2731 QModelIndex DocumentModel::makeRindTop (int nr, int na, int nh)
2735 HEXA_NS::Elements* helts = _hexaDocument->makeRindTop(nr, na, nh);
2736 if (BadElement(helts))
2739 result = addElementsToTree(helts, _elementsDirItem);
2744 QModelIndex DocumentModel::makeRindUni (QModelIndex& icenter,
2745 QModelIndex& ivec_x, QModelIndex& ivec_z,
2746 double raytrou, double rint, double rext, double ang,
2747 QModelIndex& ivplan,
2748 int nr, int na, int nh)
2752 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2753 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2754 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2755 HEXA_NS::Vertex* hvplan = getHexaPtr<HEXA_NS::Vertex*>(ivplan);
2757 HEXA_NS::Elements* helts = _hexaDocument->makeRindUni(hcenter, hvec_x, hvec_z, raytrou, rint, rext, ang,
2758 hvplan, nr, na, nh);
2759 if (BadElement(helts))
2762 result = addElementsToTree(helts, _elementsDirItem);
2767 QModelIndex DocumentModel::makeRind (QModelIndex& icenter,
2768 QModelIndex& ivec_x, QModelIndex& ivec_z,
2769 vector<double>& tray, vector<double>& tang, vector<double>& thaut)
2773 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
2774 HEXA_NS::Vector* hvec_x = getHexaPtr<HEXA_NS::Vector*>(ivec_x);
2775 HEXA_NS::Vector* hvec_z = getHexaPtr<HEXA_NS::Vector*>(ivec_z);
2777 HEXA_NS::Elements* helts = _hexaDocument->makeRind(hcenter, hvec_x, hvec_z, tray, tang, thaut);
2778 if (BadElement(helts))
2781 result = addElementsToTree(helts, _elementsDirItem);
2786 // ======== Cylinder
2787 QModelIndex DocumentModel::makeCylinderTop(int nr, int na, int nh)
2791 HEXA_NS::Elements* helts = _hexaDocument->makeCylinderTop(nr, na, nh);
2792 if (BadElement(helts))
2795 result = addElementsToTree(helts, _elementsDirItem);
2800 QModelIndex DocumentModel::makeCylinderUni(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz,
2801 double rint, double rext, double angle, double haut,
2802 int nr, int na, int nh)
2806 HEXA_NS::Vertex* horig = getHexaPtr<HEXA_NS::Vertex*>(iorig);
2807 HEXA_NS::Vector* hvecx = getHexaPtr<HEXA_NS::Vector*>(ivecx);
2808 HEXA_NS::Vector* hvecz = getHexaPtr<HEXA_NS::Vector*>(ivecz);
2810 HEXA_NS::Elements* helts = _hexaDocument->makeCylinderUni(horig, hvecx, hvecz,
2811 rint, rext, angle, haut,
2813 if (BadElement(helts))
2816 result = addElementsToTree(helts, _elementsDirItem);
2821 QModelIndex DocumentModel::makeCylinder(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz,
2822 vector<double>& tray, vector<double>& tang, vector<double>& thaut)
2826 HEXA_NS::Vertex* horig = getHexaPtr<HEXA_NS::Vertex*>(iorig);
2827 HEXA_NS::Vector* hvecx = getHexaPtr<HEXA_NS::Vector*>(ivecx);
2828 HEXA_NS::Vector* hvecz = getHexaPtr<HEXA_NS::Vector*>(ivecz);
2830 HEXA_NS::Elements* helts = _hexaDocument->makeCylinder(horig, hvecx, hvecz, tray, tang, thaut);
2831 if (BadElement(helts))
2834 result = addElementsToTree(helts, _elementsDirItem);
2840 // ======== Cylinders
2841 QModelIndex DocumentModel::makeCylinders(QModelIndex& iorig1, QModelIndex& ivecz1, double r1, double h1,
2842 QModelIndex& iorig2, QModelIndex& ivecz2, double r2, double h2)
2846 HEXA_NS::Vertex* horig1 = getHexaPtr<HEXA_NS::Vertex*>(iorig1);
2847 HEXA_NS::Vertex* horig2 = getHexaPtr<HEXA_NS::Vertex*>(iorig2);
2848 HEXA_NS::Vector* hvecz1 = getHexaPtr<HEXA_NS::Vector*>(ivecz1);
2849 HEXA_NS::Vector* hvecz2 = getHexaPtr<HEXA_NS::Vector*>(ivecz2);
2851 HEXA_NS::BiCylinder* helts = _hexaDocument->makeCylinders(horig1, hvecz1, r1, h1,
2852 horig2, hvecz2, r2, h2);
2853 if (BadElement(helts))
2856 result = addElementsToTree(helts, _crossElementsDirItem);
2862 QModelIndex DocumentModel::makePipeTop(int nr, int na, int nh)
2866 HEXA_NS::Elements* helts = _hexaDocument->makePipeTop(nr, na, nh);
2867 if (BadElement(helts))
2870 result = addElementsToTree(helts, _elementsDirItem);
2875 QModelIndex DocumentModel::makePipeUni(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz,
2876 double rint, double rext, double angle, double haut,
2877 int nr, int na, int nh)
2881 HEXA_NS::Vertex* horig = getHexaPtr<HEXA_NS::Vertex*>(iorig);
2882 HEXA_NS::Vector* hvecx = getHexaPtr<HEXA_NS::Vector*>(ivecx);
2883 HEXA_NS::Vector* hvecz = getHexaPtr<HEXA_NS::Vector*>(ivecz);
2885 HEXA_NS::Elements* helts = _hexaDocument->makePipeUni(horig, hvecx, hvecz, rint, rext, angle,
2887 if (BadElement(helts))
2890 result = addElementsToTree(helts, _elementsDirItem);
2895 QModelIndex DocumentModel::makePipe(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz,
2896 vector<double>& tray, vector<double>& tang, vector<double>& thaut)
2900 HEXA_NS::Vertex* horig = getHexaPtr<HEXA_NS::Vertex*>(iorig);
2901 HEXA_NS::Vector* hvecx = getHexaPtr<HEXA_NS::Vector*>(ivecx);
2902 HEXA_NS::Vector* hvecz = getHexaPtr<HEXA_NS::Vector*>(ivecz);
2904 HEXA_NS::Elements* helts = _hexaDocument->makePipe(horig, hvecx, hvecz, tray, tang, thaut);
2905 if (BadElement(helts))
2908 result = addElementsToTree(helts, _elementsDirItem);
2914 QModelIndex DocumentModel::makePipes(QModelIndex& iorig1, QModelIndex& ivecz1, double rint1, double rex1, double h1,
2915 QModelIndex& iorig2, QModelIndex& ivecz2, double rint2, double rex2, double h2)
2919 HEXA_NS::Vertex* horig1 = getHexaPtr<HEXA_NS::Vertex*>(iorig1);
2920 HEXA_NS::Vertex* horig2 = getHexaPtr<HEXA_NS::Vertex*>(iorig2);
2921 HEXA_NS::Vector* hvecz1 = getHexaPtr<HEXA_NS::Vector*>(ivecz1);
2922 HEXA_NS::Vector* hvecz2 = getHexaPtr<HEXA_NS::Vector*>(ivecz2);
2924 HEXA_NS::BiCylinder* helts = _hexaDocument->makePipes(horig1, hvecz1, rint1, rex1, h1,
2925 horig2, hvecz2, rint2, rex2, h2);
2926 if (BadElement(helts))
2929 result = addElementsToTree(helts, _crossElementsDirItem);
2934 // ======== Join Quads
2935 QModelIndex DocumentModel::joinQuadUni(QModelIndex& istart, QModelIndex& idest, QModelIndex& iv1, QModelIndex& iv2,
2936 QModelIndex& iv3, QModelIndex& iv4, int nb)
2940 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
2941 HEXA_NS::Quad* hdest = getHexaPtr<HEXA_NS::Quad*>(idest);
2942 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
2943 HEXA_NS::Vertex* hv2 = getHexaPtr<HEXA_NS::Vertex*>(iv2);
2944 HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(iv3);
2945 HEXA_NS::Vertex* hv4 = getHexaPtr<HEXA_NS::Vertex*>(iv4);
2947 HEXA_NS::Elements* helts = _hexaDocument->joinQuadUni(hstart, hdest, hv1, hv2, hv3, hv4, nb);
2948 if (BadElement(helts))
2951 result = addElementsToTree(helts, _elementsDirItem);
2956 QModelIndex DocumentModel::joinQuad(QModelIndex& istart, QModelIndex& idest, QModelIndex& iva1, QModelIndex& ivb1,
2957 QModelIndex& iva2, QModelIndex& ivb2, vector<double>& tlen)
2961 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
2962 HEXA_NS::Quad* hdest = getHexaPtr<HEXA_NS::Quad*>(idest);
2963 HEXA_NS::Vertex* hva1 = getHexaPtr<HEXA_NS::Vertex*>(iva1);
2964 HEXA_NS::Vertex* hvb1 = getHexaPtr<HEXA_NS::Vertex*>(ivb1);
2965 HEXA_NS::Vertex* hva2 = getHexaPtr<HEXA_NS::Vertex*>(iva2);
2966 HEXA_NS::Vertex* hvb2 = getHexaPtr<HEXA_NS::Vertex*>(ivb2);
2968 HEXA_NS::Elements* helts = _hexaDocument->joinQuad(hstart, hdest, hva1, hvb1, hva2, hvb2, tlen);
2969 if (BadElement(helts))
2972 result = addElementsToTree(helts, _elementsDirItem);
2977 QModelIndex DocumentModel::joinQuadsUni(QModelIndexList& istarts, QModelIndex& idest, QModelIndex& iv1, QModelIndex& iv2,
2978 QModelIndex& iv3, QModelIndex& iv4, int nb)
2982 HEXA_NS::Quads hstarts;
2983 int nbQuads = istarts.size();
2984 for (int i = 0; i < nbQuads; ++i)
2985 hstarts.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
2987 HEXA_NS::Quad* hdest = getHexaPtr<HEXA_NS::Quad*>(idest);
2988 HEXA_NS::Vertex* hv1 = getHexaPtr<HEXA_NS::Vertex*>(iv1);
2989 HEXA_NS::Vertex* hv2 = getHexaPtr<HEXA_NS::Vertex*>(iv2);
2990 HEXA_NS::Vertex* hv3 = getHexaPtr<HEXA_NS::Vertex*>(iv3);
2991 HEXA_NS::Vertex* hv4 = getHexaPtr<HEXA_NS::Vertex*>(iv4);
2993 HEXA_NS::Elements* helts = _hexaDocument->joinQuadsUni(hstarts, hdest, hv1, hv2, hv3, hv4, nb);
2994 if (BadElement(helts))
2997 result = addElementsToTree(helts, _elementsDirItem);
3002 QModelIndex DocumentModel::joinQuads(QModelIndexList& istarts, QModelIndex& idest, QModelIndex& iva1, QModelIndex& ivb1,
3003 QModelIndex& iva2, QModelIndex& ivb2, vector<double>& tlen)
3007 HEXA_NS::Quads hstarts;
3008 int nbQuads = istarts.size();
3009 for (int i = 0; i < nbQuads; ++i)
3010 hstarts.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
3012 HEXA_NS::Quad* hdest = getHexaPtr<HEXA_NS::Quad*>(idest);
3013 HEXA_NS::Vertex* hva1 = getHexaPtr<HEXA_NS::Vertex*>(iva1);
3014 HEXA_NS::Vertex* hvb1 = getHexaPtr<HEXA_NS::Vertex*>(ivb1);
3015 HEXA_NS::Vertex* hva2 = getHexaPtr<HEXA_NS::Vertex*>(iva2);
3016 HEXA_NS::Vertex* hvb2 = getHexaPtr<HEXA_NS::Vertex*>(ivb2);
3018 HEXA_NS::Elements* helts = _hexaDocument->joinQuads(hstarts, hdest, hva1, hvb1, hva2, hvb2, tlen);
3019 if (BadElement(helts))
3022 result = addElementsToTree(helts, _elementsDirItem);
3027 // ======== Quad Revolution
3028 QModelIndex DocumentModel::revolutionQuadUni(QModelIndex& istart, QModelIndex& icenter, QModelIndex& iaxis,
3029 double angle, int nbre)
3033 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
3034 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
3035 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
3037 HEXA_NS::Elements* helts = _hexaDocument->revolutionQuadUni(hstart, hcenter, haxis, angle, nbre);
3038 if (BadElement(helts))
3041 result = addElementsToTree(helts, _elementsDirItem);
3046 QModelIndex DocumentModel::revolutionQuad(QModelIndex& istart, QModelIndex& icenter, QModelIndex& iaxis,
3047 vector<double>& angles)
3051 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
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->revolutionQuad(hstart, hcenter, haxis, angles);
3056 if (BadElement(helts))
3059 result = addElementsToTree(helts, _elementsDirItem);
3064 QModelIndex DocumentModel::revolutionQuadsUni(QModelIndexList& istarts, QModelIndex& icenter, QModelIndex& iaxis,
3065 double angle, int nbre)
3069 HEXA_NS::Quads hstarts;
3070 int nbQuads = istarts.count();
3071 for (int i = 0; i < nbQuads; ++i)
3072 hstarts.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
3074 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
3075 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
3077 HEXA_NS::Elements* helts = _hexaDocument->revolutionQuadsUni(hstarts, hcenter, haxis, angle, nbre);
3078 if (BadElement(helts))
3081 result = addElementsToTree(helts, _elementsDirItem);
3086 QModelIndex DocumentModel::revolutionQuads(QModelIndexList& istarts, QModelIndex& icenter, QModelIndex& iaxis,
3087 vector<double>& angles)
3091 HEXA_NS::Quads hstarts;
3092 int nbQuads = istarts.count();
3093 for (int i = 0; i < nbQuads; ++i)
3094 hstarts.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
3096 HEXA_NS::Vertex* hcenter = getHexaPtr<HEXA_NS::Vertex*>(icenter);
3097 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
3099 HEXA_NS::Elements* helts = _hexaDocument->revolutionQuads(hstarts, hcenter, haxis, angles);
3100 if (BadElement(helts))
3103 result = addElementsToTree(helts, _elementsDirItem);
3109 // ==== PrismQuad or ExtrudeQuad
3110 QModelIndex DocumentModel::extrudeQuadTop(QModelIndex& istart, int nbre)
3114 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
3115 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuadTop(hstart, nbre);
3116 if (BadElement(helts))
3119 result = addElementsToTree(helts, _elementsDirItem);
3124 QModelIndex DocumentModel::extrudeQuadUni(QModelIndex& istart, QModelIndex& dv, double len, int nbre)
3128 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
3129 HEXA_NS::Vector* hvec = getHexaPtr<HEXA_NS::Vector*>(dv);
3131 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuadUni(hstart, hvec, len, nbre);
3132 if (BadElement(helts))
3135 result = addElementsToTree(helts, _elementsDirItem);
3140 QModelIndex DocumentModel::extrudeQuad(QModelIndex& istart, QModelIndex& dv, vector<double>& tlen)
3144 HEXA_NS::Quad* hstart = getHexaPtr<HEXA_NS::Quad*>(istart);
3145 HEXA_NS::Vector* hvec = getHexaPtr<HEXA_NS::Vector*>(dv);
3147 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuad(hstart, hvec, tlen);
3148 if (BadElement(helts))
3150 result = addElementsToTree(helts, _elementsDirItem);
3155 QModelIndex DocumentModel::extrudeQuadsTop (QModelIndexList& istarts, int nbre)
3159 HEXA_NS::Quads hquads;
3160 int nbQuads = istarts.count();
3161 for (int i = 0; i < nbQuads; ++i)
3162 hquads.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
3164 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuadsTop(hquads, nbre);
3165 if (BadElement(helts))
3167 result = addElementsToTree(helts, _elementsDirItem);
3172 QModelIndex DocumentModel::extrudeQuadsUni (QModelIndexList& istarts, QModelIndex& axis, double len, int nbre)
3176 HEXA_NS::Quads hquads;
3177 int nbQuads = istarts.count();
3178 for (int i = 0; i < nbQuads; ++i)
3179 hquads.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
3181 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(axis);
3183 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuadsUni(hquads, haxis, len, nbre);
3184 if (BadElement(helts))
3186 result = addElementsToTree(helts, _elementsDirItem);
3191 QModelIndex DocumentModel::extrudeQuads(QModelIndexList& istarts, QModelIndex& iaxis, vector<double>& tlen)
3195 HEXA_NS::Quads hquads;
3196 int nbQuads = istarts.count();
3197 for (int i=0; i < nbQuads; ++i)
3198 hquads.push_back(getHexaPtr<HEXA_NS::Quad*>(istarts[i]));
3200 HEXA_NS::Vector* haxis = getHexaPtr<HEXA_NS::Vector*>(iaxis);
3202 HEXA_NS::Elements* helts = _hexaDocument->extrudeQuads(hquads, haxis, tlen);
3203 if (BadElement(helts))
3205 result = addElementsToTree(helts, _elementsDirItem);
3211 QModelIndex DocumentModel::cutUni(QModelIndex& iEdge, int nbre)
3215 HEXA_NS::Edge* hedge = getHexaPtr<HEXA_NS::Edge*>(iEdge);
3217 HEXA_NS::Elements* helts = _hexaDocument->cutUni(hedge, nbre);
3218 if (BadElement(helts))
3220 result = addElementsToTree(helts, _elementsDirItem);
3225 QModelIndex DocumentModel::cut(QModelIndex& iEdge, vector<double>& tlen)
3229 HEXA_NS::Edge* hedge = getHexaPtr<HEXA_NS::Edge*>(iEdge);
3231 HEXA_NS::Elements* helts = _hexaDocument->cut(hedge, tlen);
3232 if (BadElement(helts))
3234 result = addElementsToTree(helts, _elementsDirItem);
3239 // ================================== END NEW ==================================