X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_Import_1D.cxx;h=193448010e2ca3ae596a8d70a97d2678e8215c41;hp=a75c2f5cc472c9e62287e0df4252e94c5b2d1c29;hb=refs%2Ftags%2FV8_3_0a2;hpb=0e557488d2bec8f6dd1d2746219c9bb37e68bd4a diff --git a/src/StdMeshers/StdMeshers_Import_1D.cxx b/src/StdMeshers/StdMeshers_Import_1D.cxx index a75c2f5cc..193448010 100644 --- a/src/StdMeshers/StdMeshers_Import_1D.cxx +++ b/src/StdMeshers/StdMeshers_Import_1D.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // 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 @@ -63,54 +63,12 @@ using namespace std; StdMeshers_Import_1D::StdMeshers_Import_1D(int hypId, int studyId, SMESH_Gen * gen) :SMESH_1D_Algo(hypId, studyId, gen), _sourceHyp(0) { - MESSAGE("StdMeshers_Import_1D::StdMeshers_Import_1D"); _name = "Import_1D"; _shapeType = (1 << TopAbs_EDGE); _compatibleHypothesis.push_back("ImportSource1D"); } -//============================================================================= -/*! - * Check presence of a hypothesis - */ -//============================================================================= - -bool StdMeshers_Import_1D::CheckHypothesis - (SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape, - SMESH_Hypothesis::Hypothesis_Status& aStatus) -{ - _sourceHyp = 0; - - const list &hyps = GetUsedHypothesis(aMesh, aShape); - if ( hyps.size() == 0 ) - { - aStatus = SMESH_Hypothesis::HYP_MISSING; - return false; // can't work with no hypothesis - } - - if ( hyps.size() > 1 ) - { - aStatus = SMESH_Hypothesis::HYP_ALREADY_EXIST; - return false; - } - - const SMESHDS_Hypothesis *theHyp = hyps.front(); - - string hypName = theHyp->GetName(); - - if (hypName == _compatibleHypothesis.front()) - { - _sourceHyp = (StdMeshers_ImportSource1D *)theHyp; - aStatus = SMESH_Hypothesis::HYP_OK; - return true; - } - - aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE; - return true; -} - //================================================================================ namespace // INTERNAL STUFF //================================================================================ @@ -331,7 +289,7 @@ namespace // INTERNAL STUFF //-------------------------------------------------------------------------------- /*! * \brief Remove imported mesh and/or groups if needed - * \param sm - submesh loosing Import algo + * \param sm - submesh losing Import algo * \param data - data holding imported groups */ void _Listener::removeSubmesh( SMESH_subMesh* sm, _ListenerData* data ) @@ -346,14 +304,14 @@ namespace // INTERNAL STUFF bool rmGroups = (d->_copyGroupSubM.erase( sm ) && d->_copyGroupSubM.empty()) || rmMesh; if ( rmMesh ) d->removeImportedMesh( sm->GetFather()->GetMeshDS() ); - if ( rmGroups && data ) + if ( rmGroups && data && data->myType == SRC_HYP ) d->removeGroups( sm, data->_srcHyp ); } } //-------------------------------------------------------------------------------- /*! * \brief Clear _ImportData::_n2n. - * _n2n is usefull within one mesh.Compute() only + * _n2n is useful within one mesh.Compute() only */ void _Listener::clearN2N( SMESH_Mesh* tgtMesh ) { @@ -383,7 +341,7 @@ namespace // INTERNAL STUFF // remove imported mesh and groups d->removeImportedMesh( sm->GetFather()->GetMeshDS() ); - if ( data ) + if ( data && data->myType == SRC_HYP ) d->removeGroups( sm, data->_srcHyp ); // clear the rest submeshes @@ -395,7 +353,7 @@ namespace // INTERNAL STUFF { SMESH_subMesh* subM = *sub; _ListenerData* hypData = (_ListenerData*) subM->GetEventListenerData( get() ); - if ( hypData ) + if ( hypData && hypData->myType == SRC_HYP ) d->removeGroups( sm, hypData->_srcHyp ); subM->ComputeStateEngine( SMESH_subMesh::CLEAN ); @@ -408,7 +366,7 @@ namespace // INTERNAL STUFF if ( sm->GetSubShape().ShapeType() == TopAbs_FACE ) sm->ComputeSubMeshStateEngine( SMESH_subMesh::CLEAN ); } - if ( data ) + if ( data && data->myType == SRC_HYP ) d->trackHypParams( sm, data->_srcHyp ); d->_n2n.clear(); d->_e2e.clear(); @@ -633,6 +591,48 @@ namespace // INTERNAL STUFF } // namespace +//============================================================================= +/*! + * Check presence of a hypothesis + */ +//============================================================================= + +bool StdMeshers_Import_1D::CheckHypothesis + (SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + SMESH_Hypothesis::Hypothesis_Status& aStatus) +{ + _sourceHyp = 0; + + const list &hyps = GetUsedHypothesis(aMesh, aShape); + if ( hyps.size() == 0 ) + { + aStatus = SMESH_Hypothesis::HYP_MISSING; + return false; // can't work with no hypothesis + } + + if ( hyps.size() > 1 ) + { + aStatus = SMESH_Hypothesis::HYP_ALREADY_EXIST; + return false; + } + + const SMESHDS_Hypothesis *theHyp = hyps.front(); + + string hypName = theHyp->GetName(); + + if (hypName == _compatibleHypothesis.front()) + { + _sourceHyp = (StdMeshers_ImportSource1D *)theHyp; + aStatus = _sourceHyp->GetGroups().empty() ? HYP_BAD_PARAMETER : HYP_OK; + if ( aStatus == HYP_BAD_PARAMETER ) + _Listener::waitHypModification( aMesh.GetSubMesh( aShape )); + return aStatus == HYP_OK; + } + + aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE; + return false; +} //============================================================================= /*! @@ -684,7 +684,7 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th // import edges from groups TNodeNodeMap* n2n; TElemElemMap* e2e; - for ( int iG = 0; iG < srcGroups.size(); ++iG ) + for ( size_t iG = 0; iG < srcGroups.size(); ++iG ) { const SMESHDS_GroupBase* srcGroup = srcGroups[iG]->GetGroupDS(); @@ -710,7 +710,7 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th double mytol = a.Distance(edge->GetNode(edge->NbNodes()-1))/25; //mytol = max(1.E-5, 10*edgeTol); // too strict and not necessary //MESSAGE("mytol = " << mytol); - for ( unsigned i = 0; i < newNodes.size(); ++i, ++node ) + for ( size_t i = 0; i < newNodes.size(); ++i, ++node ) { TNodeNodeMap::iterator n2nIt = n2n->insert( make_pair( *node, (SMDS_MeshNode*)0 )).first; if ( n2nIt->second ) @@ -809,7 +809,7 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th // copy meshes vector srcMeshes = _sourceHyp->GetSourceMeshes(); - for ( unsigned i = 0; i < srcMeshes.size(); ++i ) + for ( size_t i = 0; i < srcMeshes.size(); ++i ) importMesh( srcMeshes[i], theMesh, _sourceHyp, theShape ); return true; @@ -840,6 +840,7 @@ void StdMeshers_Import_1D::importMesh(const SMESH_Mesh* srcMesh, // 1. Copy mesh + SMESH_MeshEditor::ElemFeatures elemType; vector newNodes; const SMESHDS_Mesh* srcMeshDS = srcMesh->GetMeshDS(); SMDS_ElemIteratorPtr eIt = srcMeshDS->elementsIterator(); @@ -864,14 +865,14 @@ void StdMeshers_Import_1D::importMesh(const SMESH_Mesh* srcMesh, tgtMeshDS->FindElement( newNodes, elem->GetType(), /*noMedium=*/false ); if ( !newElem ) { - newElem = additor.AddElement( newNodes, elem->GetType(), elem->IsPoly()); + newElem = additor.AddElement( newNodes, elemType.Init( elem, /*basicOnly=*/false )); tgtSubMesh->AddElement( newElem ); } if ( toCopyGroups ) (*e2eIt).second = newElem; } // copy free nodes - if ( srcMeshDS->NbNodes() > n2n->size() ) + if ( srcMeshDS->NbNodes() > (int) n2n->size() ) { SMDS_NodeIteratorPtr nIt = srcMeshDS->nodesIterator(); while( nIt->more() ) @@ -1026,7 +1027,7 @@ bool StdMeshers_Import_1D::Evaluate(SMESH_Mesh & theMesh, // count edges imported from groups int nbEdges = 0, nbQuadEdges = 0; - for ( int iG = 0; iG < srcGroups.size(); ++iG ) + for ( size_t iG = 0; iG < srcGroups.size(); ++iG ) { const SMESHDS_GroupBase* srcGroup = srcGroups[iG]->GetGroupDS(); SMDS_ElemIteratorPtr srcElems = srcGroup->GetElements(); @@ -1055,7 +1056,7 @@ bool StdMeshers_Import_1D::Evaluate(SMESH_Mesh & theMesh, } SMESH_subMesh * sm = theMesh.GetSubMesh(theShape); - aResMap.insert(make_pair(sm,aVec)); + aResMap.insert( make_pair( sm, aVec )); return true; }