X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Pattern.cxx;h=f08831acd341ae80ffd05961a73e798127c94a6b;hb=21af9b3a2c317f5693f228cd8ed55c2bb44b0a07;hp=f92b56bf9a1383f909208e0de99036a4e5b6aa2f;hpb=44cfe3f661cf16b7253c2635368807ea332a4cc5;p=modules%2Fsmesh.git diff --git a/src/SMESH/SMESH_Pattern.cxx b/src/SMESH/SMESH_Pattern.cxx index f92b56bf9..f08831acd 100644 --- a/src/SMESH/SMESH_Pattern.cxx +++ b/src/SMESH/SMESH_Pattern.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 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 @@ -256,7 +256,7 @@ int loadVE( const list< TopoDS_Edge > & eList, //purpose : //======================================================================= -SMESH_Pattern::SMESH_Pattern () +SMESH_Pattern::SMESH_Pattern (): myToKeepNodes(false) { } @@ -267,8 +267,6 @@ SMESH_Pattern::SMESH_Pattern () bool SMESH_Pattern::Load (const char* theFileContents) { - MESSAGE("Load( file ) "); - Kernel_Utils::Localizer loc; // file structure: @@ -413,8 +411,6 @@ bool SMESH_Pattern::Load (const char* theFileContents) bool SMESH_Pattern::Save (ostream& theFile) { - MESSAGE(" ::Save(file) " ); - Kernel_Utils::Localizer loc; if ( !IsLoaded() ) { @@ -499,7 +495,7 @@ static gp_XY project (const SMDS_MeshNode* theNode, MESSAGE( "SMESH_Pattern: point projection FAILED"); return gp_XY(0.,0.); } - double u, v, minVal = DBL_MAX; + double u =0, v =0, minVal = DBL_MAX; for ( int i = theProjectorPS.NbExt(); i > 0; i-- ) if ( theProjectorPS.SquareDistance( i ) < minVal ) { minVal = theProjectorPS.SquareDistance( i ); @@ -565,11 +561,12 @@ static bool isMeshBoundToShape(SMESHDS_Mesh * aMeshDS, bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, const TopoDS_Face& theFace, bool theProject, - TopoDS_Vertex the1stVertex) + TopoDS_Vertex the1stVertex, + bool theKeepNodes) { - MESSAGE(" ::Load(face) " ); Clear(); myIs2D = true; + myToKeepNodes = theKeepNodes; SMESHDS_Mesh * aMeshDS = theMesh->GetMeshDS(); SMESHDS_SubMesh * fSubMesh = aMeshDS->MeshElements( theFace ); @@ -614,45 +611,31 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, if ( needProject ) { - MESSAGE("Project the submesh"); // --------------------------------------------------------------- // The case where the submesh is projected to theFace // --------------------------------------------------------------- // get all faces - list< const SMDS_MeshElement* > faces; - if ( nbElems > 0 ) { - SMDS_ElemIteratorPtr fIt = fSubMesh->GetElements(); - while ( fIt->more() ) { - const SMDS_MeshElement* f = fIt->next(); - if ( f && f->GetType() == SMDSAbs_Face ) - faces.push_back( f ); - } - } - else { - SMDS_FaceIteratorPtr fIt = aMeshDS->facesIterator(); - while ( fIt->more() ) - faces.push_back( fIt->next() ); - } + SMDS_ElemIteratorPtr fIt; + if ( nbElems > 0 ) + fIt = fSubMesh->GetElements(); + else + fIt = aMeshDS->elementsIterator( SMDSAbs_Face ); // put nodes of all faces into the nodePointIDMap and fill myElemPointIDs - list< const SMDS_MeshElement* >::iterator fIt = faces.begin(); - for ( ; fIt != faces.end(); ++fIt ) + while ( fIt->more() ) { + const SMDS_MeshElement* face = fIt->next(); myElemPointIDs.push_back( TElemDef() ); TElemDef& elemPoints = myElemPointIDs.back(); - int nbNodes = (*fIt)->NbCornerNodes(); + int nbNodes = face->NbCornerNodes(); for ( int i = 0;i < nbNodes; ++i ) { - const SMDS_MeshElement* node = (*fIt)->GetNode( i ); + const SMDS_MeshElement* node = face->GetNode( i ); TNodePointIDMap::iterator nIdIt = nodePointIDMap.insert( make_pair( node, -1 )).first; if ( nIdIt->second == -1 ) - { - elemPoints.push_back( iPoint ); nIdIt->second = iPoint++; - } - else - elemPoints.push_back( (*nIdIt).second ); + elemPoints.push_back( (*nIdIt).second ); } } myPoints.resize( iPoint ); @@ -673,7 +656,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, const TopoDS_Vertex v = TopoDS::Vertex( vExp.Current() ); gp_Pnt2d uv = BRep_Tool::Parameters( v, face ); double minDist = DBL_MAX; - int index; + int index = 0; vector< TPoint >::const_iterator pVecIt = myPoints.begin(); for ( iPoint = 0; pVecIt != myPoints.end(); pVecIt++, iPoint++ ) { double dist = uv.SquareDistance( (*pVecIt).myInitUV ); @@ -805,7 +788,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, double u = epos->GetUParameter(); paramNodeMap.insert( make_pair( u, node )); } - if ( paramNodeMap.size() != eSubMesh->NbNodes() ) { + if ((int) paramNodeMap.size() != eSubMesh->NbNodes() - nbMeduimNodes ) { // wrong U on edge, project Extrema_ExtPC proj; BRepAdaptor_Curve aCurve( edge ); @@ -831,7 +814,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, } //rnv : To fix the bug IPAL21999 Pattern Mapping - New - collapse of pattern mesh - if ( paramNodeMap.size() != eSubMesh->NbNodes() - nbMeduimNodes ) + if ((int) paramNodeMap.size() != eSubMesh->NbNodes() - nbMeduimNodes ) return setErrorCode(ERR_UNEXPECTED); } @@ -979,6 +962,19 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, myIsBoundaryPointsFound = true; } + if ( myToKeepNodes ) + { + myInNodes.resize( nodePointIDMap.size() + closeNodePointIDMap.size() ); + + TNodePointIDMap::iterator nIdIt = nodePointIDMap.begin(); + for ( ; nIdIt != nodePointIDMap.end(); nIdIt++ ) + myInNodes[ nIdIt->second ] = smdsNode( nIdIt->first ); + + nIdIt = closeNodePointIDMap.begin(); + for ( ; nIdIt != closeNodePointIDMap.end(); nIdIt++ ) + myInNodes[ nIdIt->second ] = smdsNode( nIdIt->first ); + } + // Assure that U range is proportional to V range Bnd_Box2d bndBox; @@ -1102,10 +1098,10 @@ static bool intersectIsolines(const gp_XY& uv11, const gp_XY& uv12, const double // resUV /= 2.; // } - if ( isDeformed ) { - MESSAGE("intersectIsolines(), d1 = " << d1 << ", d2 = " << d2 << ", delta = " << delta << - ", " << (loc1 - loc2).SquareModulus() << " > " << delta * delta); - } + // if ( isDeformed ) { + // MESSAGE("intersectIsolines(), d1 = " << d1 << ", d2 = " << d2 << ", delta = " << delta << + // ", " << (loc1 - loc2).SquareModulus() << " > " << delta * delta); + // } return true; } @@ -1219,7 +1215,7 @@ struct TIsoNode { TIsoNode* myNext[4]; // order: (iDir=0,isForward=0), (1,0), (0,1), (1,1) TIsoNode* myBndNodes[4]; // order: (iDir=0,i=0), (1,0), (0,1), (1,1) TIsoNode(double initU, double initV): - myInitUV( initU, initV ), myUV( 1e100, 1e100 ), myIsMovable(true) + myIsMovable(true), myInitUV( initU, initV ), myUV( 1e100, 1e100 ) { myNext[0] = myNext[1] = myNext[2] = myNext[3] = 0; } bool IsUVComputed() const { return myUV.X() != 1e100; } @@ -1900,7 +1896,7 @@ bool SMESH_Pattern:: list < TIsoNode* > internNodes; bool needIteration = true; if ( startNodes.empty() ) { - MESSAGE( " Starting UV by compUVByIsoIntersection()"); + //MESSAGE( " Starting UV by compUVByIsoIntersection()"); needIteration = false; map < double, TIsoLine >& isos = isoMap[ 0 ]; map < double, TIsoLine >::iterator isoIt = isos.begin(); @@ -2120,7 +2116,7 @@ bool SMESH_Pattern:: #endif } while ( maxMove > 1e-8 && nbIter++ < maxNbIter ); - MESSAGE( "compUVByElasticIsolines(): Nb iterations " << nbIter << " dist: " << sqrt( maxMove )); + //MESSAGE( "compUVByElasticIsolines(): Nb iterations " << nbIter << " dist: " << sqrt( maxMove )); if ( nbIter >= maxNbIter && sqrt(maxMove) > minUvSize * 0.05 ) { MESSAGE( "compUVByElasticIsolines() failed: "<"<) " ); - if ( !IsLoaded() ) { MESSAGE( "Pattern not loaded" ); return setErrorCode( ERR_APPL_NOT_LOADED ); @@ -3117,7 +3110,7 @@ bool SMESH_Pattern::Apply (std::set & theVolumes, // to find point index map< TPoint*, int > pointIndex; - for ( int i = 0; i < myPoints.size(); i++ ) + for ( size_t i = 0; i < myPoints.size(); i++ ) pointIndex.insert( make_pair( & myPoints[ i ], i )); int ind1 = 0; // lowest point index for an element @@ -3194,11 +3187,12 @@ bool SMESH_Pattern::Apply (std::set & theVolumes, //======================================================================= bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, - const TopoDS_Shell& theBlock) + const TopoDS_Shell& theBlock, + bool theKeepNodes) { - MESSAGE(" ::Load(volume) " ); Clear(); myIs2D = false; + myToKeepNodes = theKeepNodes; SMESHDS_SubMesh * aSubMesh; const bool isQuadMesh = theMesh->NbVolumes( ORDER_QUADRATIC ); @@ -3232,7 +3226,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, SMDS_NodeIteratorPtr nIt = aSubMesh->GetNodes(); if ( !nIt->more() ) continue; - // store a node and a point + // store a node and a point while ( nIt->more() ) { const SMDS_MeshNode* node = smdsNode( nIt->next() ); if ( isQuadMesh && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Volume )) @@ -3310,6 +3304,14 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, myIsBoundaryPointsFound = true; + if ( myToKeepNodes ) + { + myInNodes.resize( nodePointIDMap.size() ); + TNodePointIDMap::iterator nIdIt = nodePointIDMap.begin(); + for ( ; nIdIt != nodePointIDMap.end(); nIdIt++ ) + myInNodes[ nIdIt->second ] = smdsNode( nIdIt->first ); + } + return setErrorCode( ERR_OK ); } @@ -3351,8 +3353,6 @@ bool SMESH_Pattern::Apply (const TopoDS_Shell& theBlock, const TopoDS_Vertex& theVertex000, const TopoDS_Vertex& theVertex001) { - MESSAGE(" ::Apply(volume) " ); - if (!findBoundaryPoints() || // bind ID to points !setShapeToMesh( theBlock )) // check theBlock is a suitable shape return false; @@ -3412,8 +3412,6 @@ bool SMESH_Pattern::Apply (const SMDS_MeshVolume* theVolume, const int theNode000Index, const int theNode001Index) { - //MESSAGE(" ::Apply(MeshVolume) " ); - if (!findBoundaryPoints()) // bind ID to points return false; @@ -4004,7 +4002,6 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh, const bool toCreatePolygons, const bool toCreatePolyedrs) { - MESSAGE(" ::MakeMesh() " ); if ( !myIsComputed ) return setErrorCode( ERR_MAKEM_NOT_COMPUTED ); @@ -4027,7 +4024,7 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh, for ( ; i_node != myXYZIdToNodeMap.end(); i_node++ ) { nodesVector[ i_node->first ] = i_node->second; } - for ( int i = 0; i < myXYZ.size(); ++i ) { + for ( size_t i = 0; i < myXYZ.size(); ++i ) { if ( !nodesVector[ i ] && isDefined( myXYZ[ i ] ) ) nodesVector[ i ] = aMeshDS->AddNode (myXYZ[ i ].X(), myXYZ[ i ].Y(), @@ -4157,6 +4154,9 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh, aMeshDS->compactMesh(); + if ( myToKeepNodes ) + myOutNodes.swap( nodesVector ); + // const map& sm = aMeshDS->SubMeshes(); // map::const_iterator i_sm = sm.begin(); // for ( ; i_sm != sm.end(); i_sm++ ) @@ -4197,7 +4197,7 @@ void SMESH_Pattern::createElements(SMESH_Mesh* theMes groups.resize( theElements.size() ); const set& allGroups = aMeshDS->GetGroups(); set::const_iterator grIt; - for ( int i = 0; i < theElements.size(); i++ ) + for ( size_t i = 0; i < theElements.size(); i++ ) { shapeIDs[ i ] = editor.FindShape( theElements[ i ] ); for ( grIt = allGroups.begin(); grIt != allGroups.end(); grIt++ ) { @@ -4239,7 +4239,7 @@ void SMESH_Pattern::createElements(SMESH_Mesh* theMes TElemDef::const_iterator id = elemNodeInd.begin(); int nbNodes; for ( nbNodes = 0; id != elemNodeInd.end(); id++ ) { - if ( *id < theNodesVector.size() ) + if ( *id < (int) theNodesVector.size() ) nodes[ nbNodes++ ] = theNodesVector[ *id ]; else nodes[ nbNodes++ ] = myXYZIdToNodeMap[ *id ]; @@ -4338,7 +4338,7 @@ void SMESH_Pattern::createElements(SMESH_Mesh* theMes } if ( onMeshElements ) { list< int > elemIDs; - for ( int i = 0; i < theElements.size(); i++ ) + for ( size_t i = 0; i < theElements.size(); i++ ) { subMesh = theMesh->GetSubMeshContaining( shapeIDs[ i ] ); if ( subMesh ) @@ -4367,7 +4367,7 @@ bool SMESH_Pattern::isReversed(const SMDS_MeshNode* theFirstNode, gp_Pnt P[2]; list::const_iterator id = theIdsList.begin(); for ( int i = 0; i < 2; ++i, ++id ) { - if ( *id < myXYZ.size() ) + if ( *id < (int) myXYZ.size() ) P[ i ] = myXYZ[ *id ]; else { map< int, const SMDS_MeshNode*>::const_iterator i_n; @@ -4537,8 +4537,6 @@ bool SMESH_Pattern::findBoundaryPoints() { if ( myIsBoundaryPointsFound ) return true; - MESSAGE(" findBoundaryPoints() "); - myNbKeyPntInBoundary.clear(); if ( myIs2D ) @@ -4803,7 +4801,7 @@ bool SMESH_Pattern::setShapeToMesh(const TopoDS_Shape& theShape) // check nb of vertices TopTools_IndexedMapOfShape vMap; TopExp::MapShapes( theShape, TopAbs_VERTEX, vMap ); - if ( vMap.Extent() + nbNodeOnSeamEdge != myKeyPointIDs.size() ) { + if ( vMap.Extent() + nbNodeOnSeamEdge != (int)myKeyPointIDs.size() ) { MESSAGE( myKeyPointIDs.size() + nbNodeOnSeamEdge << " != " << vMap.Extent() ); return setErrorCode( ERR_APPL_BAD_NB_VERTICES ); }