X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHEXABLOCKGUI%2FHEXABLOCKGUI_DocumentModel.cxx;h=60b97c1334446406a722a75dadbea2e9b93dc755;hb=9c08f98c8b7b687f03b8994451a0cebdd5ca2fad;hp=dfb011bd073f87a27c83f22cdb14bd85becb3f94;hpb=7e372bca8f08bce752e415ebf847d0a93fa703dc;p=modules%2Fhexablock.git diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.cxx old mode 100755 new mode 100644 index dfb011b..60b97c1 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentModel.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2009-2013 CEA/DEN, EDF R&D +// Copyright (C) 2009-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -49,7 +49,10 @@ #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx" - +#include +#include +#include +#include //#define _DEVDEBUG_ @@ -238,6 +241,44 @@ int DocumentModel::getNbrUnusedElt(HEXA_NS::EnumElt eltType) return getNbrElt(eltType) - getNbrUsedElt(eltType); } +// compute the length of the given edge +double DocumentModel::getLength(const QModelIndex& iEdge) +{ + // * Get the pointer to the edge + HEXA_NS::Edge* edge = getHexaPtr(iEdge); + HEXA_NS::EdgeShape* geomEdge = getHexaPtr(iEdge); + + // * The edge can be from VTK or OCC View + if (edge != NULL) + return edge->getLength(); + else if (geomEdge != NULL) + return geomEdge->getLength(); + else + return 0.; +} + +// Compute the radius of the given edge +double DocumentModel::getRadius(const QModelIndex& iEdge) +{ + // * Get the pointer to the edge + // * In our case only an OCC edge can have a radius + HEXA_NS::EdgeShape* edge = getHexaPtr(iEdge); + if (edge == NULL) + return 0.; + + return edge->getRadius(); +} + +// Compute the angle of the given edge (internal angle) +double DocumentModel::getAngle(const QModelIndex& iEdge) +{ + // * Get the pointer to the edge + HEXA_NS::EdgeShape* edge = getHexaPtr(iEdge); + if (edge == NULL) + return 0.; + + return edge->getAngle(); +} //Load the current Document void DocumentModel::load() @@ -512,7 +553,7 @@ void DocumentModel::fillData() void DocumentModel::fillGeometry() { PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel(); - if (_hexaDocument == NULL || isEmpty() || pgsm == NULL) + if (_hexaDocument == NULL /*|| isEmpty()*/ || pgsm == NULL) return; HEXA_NS::NewShape* shape; @@ -1075,7 +1116,7 @@ QModelIndex DocumentModel::addQuadVertices( const QModelIndex &i_v0, const QMode HEXA_NS::Vertex* hv2 = getHexaPtr(i_v2); HEXA_NS::Vertex* hv3 = getHexaPtr(i_v3); - if ( hv0 and hv1 and hv2 and hv3 ){ + if ( hv0 && hv1 && hv2 && hv3 ){ HEXA_NS::Quad* hq = _hexaDocument->addQuadVertices( hv0, hv1, hv2, hv3 ); if ( BadElement(hq) ) return quadIndex; @@ -1098,7 +1139,7 @@ QModelIndex DocumentModel::addQuadEdges( const QModelIndex &e0, const QModelInde HEXA_NS::Edge* he2 = getHexaPtr(e2); HEXA_NS::Edge* he3 = getHexaPtr(e3); - if ( he0 and he1 and he2 and he3 ){ + if ( he0 && he1 && he2 && he3 ){ HEXA_NS::Quad* hq = _hexaDocument->addQuad( he0, he1, he2, he3 ); if ( BadElement(hq) ) return quadIndex; @@ -1462,8 +1503,6 @@ QModelIndex DocumentModel::makeScale( const QModelIndex& ielts, const QModelInde return iElts; } - - QModelIndex DocumentModel::makeRotation( const QModelIndex& ielts, const QModelIndex& iv, const QModelIndex& ivec, double angle ) @@ -1644,30 +1683,35 @@ bool DocumentModel::performSymmetryPlane( const QModelIndex& ielts, return false; } -QModelIndex DocumentModel::replace( const QModelIndexList& iquadsPattern, - const QModelIndex& ip1, const QModelIndex& ic1, - const QModelIndex& ip2, const QModelIndex& ic2, - const QModelIndex& ip3, const QModelIndex& ic3 ) +QModelIndex DocumentModel::replace( const QModelIndexList& iquads_source, + const QModelIndexList& iquads_dest, + const QModelIndex& ip1_source, const QModelIndex& ic1_dest, + const QModelIndex& ip2_source, const QModelIndex& ic2_dest) { QModelIndex ielts; - HEXA_NS::Vertex* hp1 = getHexaPtr(ip1); - HEXA_NS::Vertex* hc1 = getHexaPtr(ic1); - HEXA_NS::Vertex* hp2 = getHexaPtr(ip2); - HEXA_NS::Vertex* hc2 = getHexaPtr(ic2); - HEXA_NS::Vertex* hp3 = getHexaPtr(ip3); - HEXA_NS::Vertex* hc3 = getHexaPtr(ic3); + HEXA_NS::Vertex* hp1 = getHexaPtr(ip1_source); + HEXA_NS::Vertex* hp2 = getHexaPtr(ip2_source); + HEXA_NS::Vertex* hc1 = getHexaPtr(ic1_dest); + HEXA_NS::Vertex* hc2 = getHexaPtr(ic2_dest); - HEXA_NS::Quads hquads; + HEXA_NS::Quads hquads_source, hquads_dest; HEXA_NS::Quad* hquad = NULL; - foreach( const QModelIndex& iquad, iquadsPattern ){ + foreach( const QModelIndex& iquad, iquads_source ){ hquad = getHexaPtr(iquad); - hquads.push_back( hquad ); + hquads_source.push_back( hquad ); } - HEXA_NS::Elements* helts = _hexaDocument->replace( hquads, - hp1, hc1, hp2, hc2, hp3, hc3 ); - if ( BadElement(helts) ) return ielts; + foreach( const QModelIndex& iquad, iquads_dest) { + hquad = getHexaPtr(iquad); + hquads_dest.push_back(hquad); + } + + HEXA_NS::Elements* helts = _hexaDocument->replace( hquads_source, + hquads_dest, + hp1, hc1, hp2, hc2); + if ( BadElement(helts) ) + return ielts; updateData(); ElementsItem* eltsItem = new ElementsItem(helts); @@ -2249,7 +2293,7 @@ Qt::ItemFlags PatternDataModel::flags(const QModelIndex &index) const QVariant PatternDataModel::headerData ( int section, Qt::Orientation orientation, int role ) const { - if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){ + if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){ return QVariant( "Data" ); } else { return QSortFilterProxyModel::headerData ( section, orientation, role ); @@ -2295,7 +2339,7 @@ QStandardItem* PatternDataModel::itemFromIndex ( const QModelIndex & index ) con //QVariant PatternBuilderModel::headerData ( int section, Qt::Orientation orientation, int role ) const //{ -// if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){ +// if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){ // return QVariant( "Builder" ); // } else { // return QSortFilterProxyModel::headerData ( section, orientation, role ); @@ -2345,7 +2389,7 @@ Qt::ItemFlags PatternGeomModel::flags(const QModelIndex &index) const QVariant PatternGeomModel::headerData ( int section, Qt::Orientation orientation, int role ) const { - if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){ + if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){ return QVariant( "Geometry" ); } else { return QSortFilterProxyModel::headerData ( section, orientation, role ); @@ -2390,7 +2434,7 @@ Qt::ItemFlags AssociationsModel::flags(const QModelIndex &index) const QVariant AssociationsModel::headerData ( int section, Qt::Orientation orientation, int role ) const { - if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){ + if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){ return QVariant( "Associations" ); } else { return QSortFilterProxyModel::headerData ( section, orientation, role ); @@ -2433,7 +2477,7 @@ Qt::ItemFlags GroupsModel::flags(const QModelIndex &index) const QVariant GroupsModel::headerData ( int section, Qt::Orientation orientation, int role ) const { - if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){ + if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){ return QVariant( "Groups" ); } else { return QSortFilterProxyModel::headerData ( section, orientation, role ); @@ -2486,7 +2530,7 @@ Qt::ItemFlags MeshModel::flags(const QModelIndex &index) const QVariant MeshModel::headerData ( int section, Qt::Orientation orientation, int role ) const { - if ( section == 0 and orientation == Qt::Horizontal and role == Qt::DisplayRole ){ + if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ){ return QVariant( "Mesh" ); } else { return QSortFilterProxyModel::headerData ( section, orientation, role ); @@ -2554,7 +2598,7 @@ QModelIndex DocumentModel::makeCartesianUni(const QModelIndex& icenter, QModelIndex DocumentModel::makeCartesian(const QModelIndex& icenter, const QModelIndex& ibase, const QModelIndex& ivec, const QModelIndex& iaxis, - vector& radius, vector& angles, vector& heights) + std::vector& radius, std::vector& angles, std::vector& heights) { QModelIndex result; @@ -2612,7 +2656,7 @@ QModelIndex DocumentModel::makeSphereUni (QModelIndex& icenter, QModelIndex DocumentModel::makeSphere (QModelIndex& icenter, QModelIndex& ivec_x, QModelIndex& ivec_z, - vector& tray, vector& tang, vector& thaut) + std::vector& tray, std::vector& tang, std::vector& thaut) { QModelIndex result; @@ -2665,7 +2709,7 @@ QModelIndex DocumentModel::makeSphericalUni (QModelIndex& icenter, QModelIndex DocumentModel::makeSpherical (QModelIndex& icenter, QModelIndex& ivec_x, QModelIndex& ivec_z, - vector& rayon, + std::vector& rayon, int crit) { QModelIndex result; @@ -2722,7 +2766,7 @@ QModelIndex DocumentModel::makeRindUni (QModelIndex& icenter, QModelIndex DocumentModel::makeRind (QModelIndex& icenter, QModelIndex& ivec_x, QModelIndex& ivec_z, - vector& tray, vector& tang, vector& thaut) + std::vector& tray, std::vector& tang, std::vector& thaut) { QModelIndex result; @@ -2775,7 +2819,7 @@ QModelIndex DocumentModel::makeCylinderUni(QModelIndex& iorig, QModelIndex& ivec } QModelIndex DocumentModel::makeCylinder(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz, - vector& tray, vector& tang, vector& thaut) + std::vector& tray, std::vector& tang, std::vector& thaut) { QModelIndex result; @@ -2849,7 +2893,7 @@ QModelIndex DocumentModel::makePipeUni(QModelIndex& iorig, QModelIndex& ivecx, Q } QModelIndex DocumentModel::makePipe(QModelIndex& iorig, QModelIndex& ivecx, QModelIndex& ivecz, - vector& tray, vector& tang, vector& thaut) + std::vector& tray, std::vector& tang, std::vector& thaut) { QModelIndex result; @@ -2910,7 +2954,7 @@ QModelIndex DocumentModel::joinQuadUni(QModelIndex& istart, QModelIndex& idest, } QModelIndex DocumentModel::joinQuad(QModelIndex& istart, QModelIndex& idest, QModelIndex& iva1, QModelIndex& ivb1, - QModelIndex& iva2, QModelIndex& ivb2, vector& tlen) + QModelIndex& iva2, QModelIndex& ivb2, std::vector& tlen) { QModelIndex result; @@ -2956,7 +3000,7 @@ QModelIndex DocumentModel::joinQuadsUni(QModelIndexList& istarts, QModelIndex& i } QModelIndex DocumentModel::joinQuads(QModelIndexList& istarts, QModelIndex& idest, QModelIndex& iva1, QModelIndex& ivb1, - QModelIndex& iva2, QModelIndex& ivb2, vector& tlen) + QModelIndex& iva2, QModelIndex& ivb2, std::vector& tlen) { QModelIndex result; @@ -3000,7 +3044,7 @@ QModelIndex DocumentModel::revolutionQuadUni(QModelIndex& istart, QModelIndex& i } QModelIndex DocumentModel::revolutionQuad(QModelIndex& istart, QModelIndex& icenter, QModelIndex& iaxis, - vector& angles) + std::vector& angles) { QModelIndex result; @@ -3040,7 +3084,7 @@ QModelIndex DocumentModel::revolutionQuadsUni(QModelIndexList& istarts, QModelIn } QModelIndex DocumentModel::revolutionQuads(QModelIndexList& istarts, QModelIndex& icenter, QModelIndex& iaxis, - vector& angles) + std::vector& angles) { QModelIndex result; @@ -3093,7 +3137,7 @@ QModelIndex DocumentModel::extrudeQuadUni(QModelIndex& istart, QModelIndex& dv, return result; } -QModelIndex DocumentModel::extrudeQuad(QModelIndex& istart, QModelIndex& dv, vector& tlen) +QModelIndex DocumentModel::extrudeQuad(QModelIndex& istart, QModelIndex& dv, std::vector& tlen) { QModelIndex result; @@ -3144,7 +3188,7 @@ QModelIndex DocumentModel::extrudeQuadsUni (QModelIndexList& istarts, QModelInde return result; } -QModelIndex DocumentModel::extrudeQuads(QModelIndexList& istarts, QModelIndex& iaxis, vector& tlen) +QModelIndex DocumentModel::extrudeQuads(QModelIndexList& istarts, QModelIndex& iaxis, std::vector& tlen) { QModelIndex result; @@ -3178,7 +3222,7 @@ QModelIndex DocumentModel::cutUni(QModelIndex& iEdge, int nbre) return result; } -QModelIndex DocumentModel::cut(QModelIndex& iEdge, vector& tlen) +QModelIndex DocumentModel::cut(QModelIndex& iEdge, std::vector& tlen) { QModelIndex result;