From a9289f9261c412a9dbf6ded906012270ebc83ad7 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 15 Feb 2016 15:34:44 +0300 Subject: [PATCH] remove "using namespace std" from SMESH headers --- src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx | 1638 +++++++++-------- src/HYBRIDPlugin/HYBRIDPlugin_HYBRID_i.cxx | 2 +- src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx | 6 +- .../HYBRIDPlugin_Hypothesis_i.cxx | 82 +- 4 files changed, 865 insertions(+), 863 deletions(-) diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx index 945ebe2..ab23bb4 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx @@ -92,7 +92,7 @@ extern "C" #define HOLE_ID -1 -typedef const list TTriaList; +typedef const std::list TTriaList; static const char theDomainGroupNamePrefix[] = "Domain_"; @@ -168,9 +168,9 @@ bool HYBRIDPlugin_HYBRID::CheckHypothesis ( SMESH_Mesh& aMesh, _removeLogOnSuccess = true; _logInStandardOutput = false; - const list & hyps = + const std::list & hyps = GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliary=*/false); - list ::const_iterator h = hyps.begin(); + std::list ::const_iterator h = hyps.begin(); for ( ; h != hyps.end(); ++h ) { if ( !_hyp ) @@ -215,59 +215,59 @@ TopoDS_Shape HYBRIDPlugin_HYBRID::entryToShape(std::string entry) //purpose : //======================================================================= -static TopoDS_Shape findShape(const SMDS_MeshNode *aNode[], - TopoDS_Shape aShape, - const TopoDS_Shape shape[], - double** box, - const int nShape, - TopAbs_State * state = 0) -{ - gp_XYZ aPnt(0,0,0); - int j, iShape, nbNode = 4; - - for ( j=0; jX(), aNode[j]->Y(), aNode[j]->Z() ); - if ( aNode[j]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE ) { - aPnt = p; - break; - } - aPnt += p / nbNode; - } +// static TopoDS_Shape findShape(const SMDS_MeshNode *aNode[], +// TopoDS_Shape aShape, +// const TopoDS_Shape shape[], +// double** box, +// const int nShape, +// TopAbs_State * state = 0) +// { +// gp_XYZ aPnt(0,0,0); +// int j, iShape, nbNode = 4; + +// for ( j=0; jX(), aNode[j]->Y(), aNode[j]->Z() ); +// if ( aNode[j]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE ) { +// aPnt = p; +// break; +// } +// aPnt += p / nbNode; +// } - BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion()); - if (state) *state = SC.State(); - if ( SC.State() != TopAbs_IN || aShape.IsNull() || aShape.ShapeType() != TopAbs_SOLID) { - for (iShape = 0; iShape < nShape; iShape++) { - aShape = shape[iShape]; - if ( !( aPnt.X() < box[iShape][0] || box[iShape][1] < aPnt.X() || - aPnt.Y() < box[iShape][2] || box[iShape][3] < aPnt.Y() || - aPnt.Z() < box[iShape][4] || box[iShape][5] < aPnt.Z()) ) { - BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion()); - if (state) *state = SC.State(); - if (SC.State() == TopAbs_IN) - break; - } - } - } - return aShape; -} +// BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion()); +// if (state) *state = SC.State(); +// if ( SC.State() != TopAbs_IN || aShape.IsNull() || aShape.ShapeType() != TopAbs_SOLID) { +// for (iShape = 0; iShape < nShape; iShape++) { +// aShape = shape[iShape]; +// if ( !( aPnt.X() < box[iShape][0] || box[iShape][1] < aPnt.X() || +// aPnt.Y() < box[iShape][2] || box[iShape][3] < aPnt.Y() || +// aPnt.Z() < box[iShape][4] || box[iShape][5] < aPnt.Z()) ) { +// BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion()); +// if (state) *state = SC.State(); +// if (SC.State() == TopAbs_IN) +// break; +// } +// } +// } +// return aShape; +// } //======================================================================= //function : readMapIntLine //purpose : //======================================================================= -static char* readMapIntLine(char* ptr, int tab[]) { - long int intVal; - std::cout << std::endl; +// static char* readMapIntLine(char* ptr, int tab[]) { +// long int intVal; +// std::cout << std::endl; - for ( int i=0; i<17; i++ ) { - intVal = strtol(ptr, &ptr, 10); - if ( i < 3 ) - tab[i] = intVal; - } - return ptr; -} +// for ( int i=0; i<17; i++ ) { +// intVal = strtol(ptr, &ptr, 10); +// if ( i < 3 ) +// tab[i] = intVal; +// } +// return ptr; +// } //================================================================================ /*! @@ -328,7 +328,7 @@ static int findShapeID(SMESH_Mesh& mesh, SMESHDS_Mesh* meshDS = mesh.GetMeshDS(); // face the nodes belong to - vector nodes(3); + std::vector nodes(3); nodes[0] = node1; nodes[1] = node2; nodes[2] = node3; @@ -520,7 +520,7 @@ static void updateMeshGroups(SMESH_Mesh* theMesh, std::set groupsTo if ( !group ) continue; SMESHDS_GroupBase* groupDS = group->GetGroupDS(); if ( !groupDS ) continue; - std::string currentGroupName = (string)group->GetName(); + std::string currentGroupName = (std::string)group->GetName(); if (groupDS->IsEmpty() && groupsToRemove.find(currentGroupName) != groupsToRemove.end()) { // Previous group created by enforced elements MESSAGE("Delete previous group created by removed enforced elements: " << group->GetName()) @@ -620,7 +620,7 @@ static bool readGMFFile(const char* theFile, SMESH_MesherHelper* theHelper, std::vector & theNodeByHybridId, std::vector & theFaceByHybridId, - map & theNodeToHybridIdMap, + std::map & theNodeToHybridIdMap, std::vector & aNodeGroupByHybridId, std::vector & anEdgeGroupByHybridId, std::vector & aFaceGroupByHybridId, @@ -678,7 +678,7 @@ static bool readGMFFile(const char* theFile, MESSAGE("Done "); // Read ids of domains - vector< int > solidIDByDomain; + std::vector< int > solidIDByDomain; if ( hasGeom ) { int solid1; // id used in case of 1 domain or some reading failure @@ -700,7 +700,7 @@ static bool readGMFFile(const char* theFile, GmfGetLin( InpMsh, GmfSubDomainFromGeom, &faceNbNodes, &faceIndex, &orientation, &domainNb); solidIDByDomain[ domainNb ] = 1; - if ( 0 < faceIndex && faceIndex-1 < theFaceByHybridId.size() ) + if ( 0 < faceIndex && faceIndex-1 < (int)theFaceByHybridId.size() ) { const SMDS_MeshElement* face = theFaceByHybridId[ faceIndex-1 ]; const SMDS_MeshNode* nn[3] = { face->GetNode(0), @@ -729,7 +729,7 @@ static bool readGMFFile(const char* theFile, std::vector< const SMDS_MeshElement* > foundVolumes; if ( !hasGeom && theHelper->GetMesh()->NbVolumes() > 0 ) elemSearcher = SMESH_MeshAlgos::GetElementSearcher( *theMeshDS ); - auto_ptr< SMESH_ElementSearcher > elemSearcherDeleter( elemSearcher ); + SMESHUtils::Deleter< SMESH_ElementSearcher > elemSearcherDeleter( elemSearcher ); // IMP 0022172: [CEA 790] create the groups corresponding to domains std::vector< std::vector< const SMDS_MeshElement* > > elemsOfDomain; @@ -807,7 +807,7 @@ static bool readGMFFile(const char* theFile, aGMFID = iElem -nbInitialNodes +1; GMFNode[ aGMFID ] = aGMFNode; - if (aGMFID-1 < aNodeGroupByHybridId.size() && !aNodeGroupByHybridId.at(aGMFID-1).empty()) + if (aGMFID-1 < (int)aNodeGroupByHybridId.size() && !aNodeGroupByHybridId.at(aGMFID-1).empty()) addElemInMeshGroup(theHelper->GetMesh(), aGMFNode, aNodeGroupByHybridId.at(aGMFID-1), groupsToRemove); } } @@ -1042,6 +1042,8 @@ static bool readGMFFile(const char* theFile, } // loop on elements of one type break; } // case ... + + default:; } // switch (token) } // loop on tabRef @@ -1108,7 +1110,7 @@ static bool writeGMFFile(const char* theMesh std::string tmpStr; int idx, idxRequired = 0, idxSol = 0; //tabg each dummyint - const int dummyint = 0; + //const int dummyint = 0; const int dummyint1 = 1; const int dummyint2 = 2; const int dummyint3 = 3; @@ -1121,16 +1123,16 @@ static bool writeGMFFile(const char* theMesh TIDSortedElemSet anElemSet, theKeptEnforcedEdges, theKeptEnforcedTriangles; SMDS_ElemIteratorPtr nodeIt; std::vector theEnforcedNodeByHybridId; - map anEnforcedNodeToHybridIdMap, anExistingEnforcedNodeToHybridIdMap; + std::map anEnforcedNodeToHybridIdMap, anExistingEnforcedNodeToHybridIdMap; std::vector< const SMDS_MeshElement* > foundElems; - map aNodeToTopAbs_StateMap; + std::map aNodeToTopAbs_StateMap; int nbFoundElems; HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap::iterator elemIt; TIDSortedElemSet::iterator elemSetIt; bool isOK; SMESH_Mesh* theMesh = theHelper.GetMesh(); const bool hasGeom = theMesh->HasShapeToMesh(); - auto_ptr< SMESH_ElementSearcher > pntCls + SMESHUtils::Deleter< SMESH_ElementSearcher > pntCls ( SMESH_MeshAlgos::GetElementSearcher(*theMesh->GetMeshDS())); int nbEnforcedVertices = theEnforcedVertices.size(); @@ -1166,7 +1168,7 @@ static bool writeGMFFile(const char* theMesh // find HYBRID ID const SMDS_MeshNode* node = castToNode( nodeIt->next() ); int newId = aNodeToHybridIdMap.size() + 1; // hybrid ids count from 1 - aNodeToHybridIdMap.insert( make_pair( node, newId )); + aNodeToHybridIdMap.insert( std::make_pair( node, newId )); } } @@ -1188,7 +1190,7 @@ static bool writeGMFFile(const char* theMesh isOK = false; break; } - aNodeToTopAbs_StateMap.insert( make_pair( node, result )); + aNodeToTopAbs_StateMap.insert( std::make_pair( node, result )); } if (isOK) { nodeIt = elem->nodesIterator(); @@ -1206,13 +1208,13 @@ static bool writeGMFFile(const char* theMesh if (nbFoundElems ==0) { if ((*aNodeToTopAbs_StateMap.find(node)).second == TopAbs_IN) { newId = aNodeToHybridIdMap.size() + anEnforcedNodeToHybridIdMap.size() + 1; // hybrid ids count from 1 - anEnforcedNodeToHybridIdMap.insert( make_pair( node, newId )); + anEnforcedNodeToHybridIdMap.insert( std::make_pair( node, newId )); } } else if (nbFoundElems ==1) { const SMDS_MeshNode* existingNode = (SMDS_MeshNode*) foundElems.at(0); newId = (*aNodeToHybridIdMap.find(existingNode)).second; - anExistingEnforcedNodeToHybridIdMap.insert( make_pair( node, newId )); + anExistingEnforcedNodeToHybridIdMap.insert( std::make_pair( node, newId )); } else isOK = false; @@ -1243,7 +1245,7 @@ static bool writeGMFFile(const char* theMesh isOK = false; break; } - aNodeToTopAbs_StateMap.insert( make_pair( node, result )); + aNodeToTopAbs_StateMap.insert( std::make_pair( node, result )); } if (isOK) { nodeIt = elem->nodesIterator(); @@ -1260,13 +1262,13 @@ static bool writeGMFFile(const char* theMesh if (nbFoundElems ==0) { if ((*aNodeToTopAbs_StateMap.find(node)).second == TopAbs_IN) { newId = aNodeToHybridIdMap.size() + anEnforcedNodeToHybridIdMap.size() + 1; // hybrid ids count from 1 - anEnforcedNodeToHybridIdMap.insert( make_pair( node, newId )); + anEnforcedNodeToHybridIdMap.insert( std::make_pair( node, newId )); } } else if (nbFoundElems ==1) { const SMDS_MeshNode* existingNode = (SMDS_MeshNode*) foundElems.at(0); newId = (*aNodeToHybridIdMap.find(existingNode)).second; - anExistingEnforcedNodeToHybridIdMap.insert( make_pair( node, newId )); + anExistingEnforcedNodeToHybridIdMap.insert( std::make_pair( node, newId )); } else isOK = false; @@ -1284,7 +1286,7 @@ static bool writeGMFFile(const char* theMesh std::cout << "aNodeToHybridIdMap.size(): "<::const_iterator n2id = aNodeToHybridIdMap.begin(); + std::map::const_iterator n2id = aNodeToHybridIdMap.begin(); for ( ; n2id != aNodeToHybridIdMap.end(); ++ n2id) { // std::cout << "n2id->first: "<first<second > aNodeToHybridIdMap.size()) { + if (n2id->second > (int)aNodeToHybridIdMap.size()) { theEnforcedNodeByHybridId[ n2id->second - aNodeToHybridIdMap.size() - 1 ] = n2id->first; // hybrid ids count from 1 } } //========================== NODES ========================== - vector theOrderedNodes, theRequiredNodes; + std::vector theOrderedNodes, theRequiredNodes; std::set< std::vector > nodesCoords; - vector::const_iterator hybridNodeIt = theNodeByHybridId.begin(); - vector::const_iterator after = theNodeByHybridId.end(); + std::vector::const_iterator hybridNodeIt = theNodeByHybridId.begin(); + std::vector::const_iterator after = theNodeByHybridId.end(); (theNodeByHybridId.size() <= 1) ? tmpStr = " node" : " nodes"; std::cout << theNodeByHybridId.size() << tmpStr << " from mesh ..." << std::endl; @@ -1561,7 +1563,7 @@ static bool writeGMFFile(const char* theMesh while ( nodeIt->more() ) { // find HYBRID ID const SMDS_MeshNode* node = castToNode( nodeIt->next() ); - map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToHybridIdMap.find(node); + std::map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToHybridIdMap.find(node); if (it == anEnforcedNodeToHybridIdMap.end()) { it = anExistingEnforcedNodeToHybridIdMap.find(node); if (it == anEnforcedNodeToHybridIdMap.end()) @@ -1600,7 +1602,7 @@ static bool writeGMFFile(const char* theMesh for ( int j = 0; j < 3; ++j ) { // find HYBRID ID const SMDS_MeshNode* node = castToNode( nodeIt->next() ); - map< const SMDS_MeshNode*,int >::iterator it = aNodeToHybridIdMap.find(node); + std::map< const SMDS_MeshNode*,int >::iterator it = aNodeToHybridIdMap.find(node); if (it == aNodeToHybridIdMap.end()) throw "Node not found"; ntri[index] = it->second; @@ -1620,7 +1622,7 @@ static bool writeGMFFile(const char* theMesh for ( int j = 0; j < 3; ++j ) { // find HYBRID ID const SMDS_MeshNode* node = castToNode( nodeIt->next() ); - map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToHybridIdMap.find(node); + std::map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToHybridIdMap.find(node); if (it == anEnforcedNodeToHybridIdMap.end()) { it = anExistingEnforcedNodeToHybridIdMap.find(node); if (it == anEnforcedNodeToHybridIdMap.end()) @@ -1711,7 +1713,7 @@ static bool writeGMFFile(const char* theMesh // { // SMDS_NodeIteratorPtr nIt = smDS->GetNodes(); // while ( nIt->more() ) -// n2nDegen.insert( make_pair( nIt->next(), vNode )); +// n2nDegen.insert( std::make_pair( nIt->next(), vNode )); // } // } // } @@ -1751,8 +1753,8 @@ static bool writeGMFFile(const char* theMesh // VerTab.push_back(coords); // VerMap.insert(coords); // aHybridID++; -// theSmdsToHybridIdMap.insert( make_pair( node->GetID(), aHybridID )); -// theHybridIdToNodeMap.insert( make_pair( aHybridID, node )); +// theSmdsToHybridIdMap.insert( std::make_pair( node->GetID(), aHybridID )); +// theHybridIdToNodeMap.insert( std::make_pair( aHybridID, node )); // } // // @@ -1781,7 +1783,7 @@ static bool writeGMFFile(const char* theMesh // VerTab.push_back(coords); // VerMap.insert(coords); // aHybridID++; -// theNodeId2NodeIndexMap.insert( make_pair( (*enfNodeIt)->GetID(), aHybridID )); +// theNodeId2NodeIndexMap.insert( std::make_pair( (*enfNodeIt)->GetID(), aHybridID )); // } // } // @@ -1922,7 +1924,7 @@ static bool writeGMFFile(const char* theMesh // VerTab.push_back(coords); // VerMap.insert(coords); // aHybridID++; -// theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aHybridID )); +// theNodeId2NodeIndexMap.insert( std::make_pair( node->GetID(), aHybridID )); // att.push_back(aHybridID); // } // if (isOK) @@ -1970,7 +1972,7 @@ static bool writeGMFFile(const char* theMesh // VerMap.insert(coords); // // aHybridID++; -// theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aHybridID )); +// theNodeId2NodeIndexMap.insert( std::make_pair( node->GetID(), aHybridID )); // aet.push_back(aHybridID); // } // if (isOK) @@ -2098,770 +2100,770 @@ static bool writeGMFFile(const char* theMesh //purpose : //======================================================================= -static bool writeFaces (ofstream & theFile, - const SMESH_ProxyMesh& theMesh, - const TopoDS_Shape& theShape, - const map & theSmdsToHybridIdMap, - const map & theEnforcedNodeIdToHybridIdMap, - HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges, - HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles) -{ - // record structure: - // - // NB_ELEMS DUMMY_INT - // Loop from 1 to NB_ELEMS - // NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT - - TopoDS_Shape aShape; - const SMESHDS_SubMesh* theSubMesh; - const SMDS_MeshElement* aFace; - const char* space = " "; - const int dummyint = 0; - map::const_iterator itOnMap; - SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace; - int nbNodes, aSmdsID; - - TIDSortedElemSet::const_iterator elemIt; - int nbEnforcedEdges = theEnforcedEdges.size(); - int nbEnforcedTriangles = theEnforcedTriangles.size(); - - // count triangles bound to geometry - int nbTriangles = 0; - - TopTools_IndexedMapOfShape facesMap, trianglesMap; - TopExp::MapShapes( theShape, TopAbs_FACE, facesMap ); - - int nbFaces = facesMap.Extent(); - - for ( int i = 1; i <= nbFaces; ++i ) - if (( theSubMesh = theMesh.GetSubMesh( facesMap(i)))) - nbTriangles += theSubMesh->NbElements(); - std::string tmpStr; - (nbFaces == 0 || nbFaces == 1) ? tmpStr = " shape " : tmpStr = " shapes " ; - std::cout << " " << nbFaces << tmpStr << "of 2D dimension"; - int nbEnforcedElements = nbEnforcedEdges+nbEnforcedTriangles; - if (nbEnforcedElements > 0) { - (nbEnforcedElements == 1) ? tmpStr = "shape:" : tmpStr = "shapes:"; - std::cout << " and" << std::endl; - std::cout << " " << nbEnforcedElements - << " enforced " << tmpStr << std::endl; - } - else - std::cout << std::endl; - if (nbEnforcedEdges) { - (nbEnforcedEdges == 1) ? tmpStr = "edge" : tmpStr = "edges"; - std::cout << " " << nbEnforcedEdges << " enforced " << tmpStr << std::endl; - } - if (nbEnforcedTriangles) { - (nbEnforcedTriangles == 1) ? tmpStr = "triangle" : tmpStr = "triangles"; - std::cout << " " << nbEnforcedTriangles << " enforced " << tmpStr << std::endl; - } - std::cout << std::endl; +// static bool writeFaces (ofstream & theFile, +// const SMESH_ProxyMesh& theMesh, +// const TopoDS_Shape& theShape, +// const std::map & theSmdsToHybridIdMap, +// const std::map & theEnforcedNodeIdToHybridIdMap, +// HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges, +// HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles) +// { +// // record structure: +// // +// // NB_ELEMS DUMMY_INT +// // Loop from 1 to NB_ELEMS +// // NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT -// theFile << space << nbTriangles << space << dummyint << std::endl; - std::ostringstream globalStream, localStream, aStream; +// TopoDS_Shape aShape; +// const SMESHDS_SubMesh* theSubMesh; +// const SMDS_MeshElement* aFace; +// const char* space = " "; +// const int dummyint = 0; +// std::map::const_iterator itOnMap; +// SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace; +// int nbNodes, aSmdsID; - for ( int i = 1; i <= facesMap.Extent(); i++ ) - { - aShape = facesMap(i); - theSubMesh = theMesh.GetSubMesh(aShape); - if ( !theSubMesh ) continue; - itOnSubMesh = theSubMesh->GetElements(); - while ( itOnSubMesh->more() ) - { - aFace = itOnSubMesh->next(); - nbNodes = aFace->NbCornerNodes(); +// TIDSortedElemSet::const_iterator elemIt; +// int nbEnforcedEdges = theEnforcedEdges.size(); +// int nbEnforcedTriangles = theEnforcedTriangles.size(); - localStream << nbNodes << space; +// // count triangles bound to geometry +// int nbTriangles = 0; - itOnSubFace = aFace->nodesIterator(); - for ( int j = 0; j < 3; ++j ) { - // find HYBRID ID - aSmdsID = itOnSubFace->next()->GetID(); - itOnMap = theSmdsToHybridIdMap.find( aSmdsID ); - // if ( itOnMap == theSmdsToHybridIdMap.end() ) { - // cout << "not found node: " << aSmdsID << endl; - // return false; - // } - ASSERT( itOnMap != theSmdsToHybridIdMap.end() ); - - localStream << (*itOnMap).second << space ; - } +// TopTools_IndexedMapOfShape facesMap, trianglesMap; +// TopExp::MapShapes( theShape, TopAbs_FACE, facesMap ); + +// int nbFaces = facesMap.Extent(); + +// for ( int i = 1; i <= nbFaces; ++i ) +// if (( theSubMesh = theMesh.GetSubMesh( facesMap(i)))) +// nbTriangles += theSubMesh->NbElements(); +// std::string tmpStr; +// (nbFaces == 0 || nbFaces == 1) ? tmpStr = " shape " : tmpStr = " shapes " ; +// std::cout << " " << nbFaces << tmpStr << "of 2D dimension"; +// int nbEnforcedElements = nbEnforcedEdges+nbEnforcedTriangles; +// if (nbEnforcedElements > 0) { +// (nbEnforcedElements == 1) ? tmpStr = "shape:" : tmpStr = "shapes:"; +// std::cout << " and" << std::endl; +// std::cout << " " << nbEnforcedElements +// << " enforced " << tmpStr << std::endl; +// } +// else +// std::cout << std::endl; +// if (nbEnforcedEdges) { +// (nbEnforcedEdges == 1) ? tmpStr = "edge" : tmpStr = "edges"; +// std::cout << " " << nbEnforcedEdges << " enforced " << tmpStr << std::endl; +// } +// if (nbEnforcedTriangles) { +// (nbEnforcedTriangles == 1) ? tmpStr = "triangle" : tmpStr = "triangles"; +// std::cout << " " << nbEnforcedTriangles << " enforced " << tmpStr << std::endl; +// } +// std::cout << std::endl; - // (NB_NODES + 1) times: DUMMY_INT - for ( int j=0; j<=nbNodes; j++) - localStream << dummyint << space ; +// // theFile << space << nbTriangles << space << dummyint << std::endl; +// std::ostringstream globalStream, localStream, aStream; - localStream << std::endl; - } - } - - globalStream << localStream.str(); - localStream.str(""); +// for ( int i = 1; i <= facesMap.Extent(); i++ ) +// { +// aShape = facesMap(i); +// theSubMesh = theMesh.GetSubMesh(aShape); +// if ( !theSubMesh ) continue; +// itOnSubMesh = theSubMesh->GetElements(); +// while ( itOnSubMesh->more() ) +// { +// aFace = itOnSubMesh->next(); +// nbNodes = aFace->NbCornerNodes(); - // - // FACES : END - // +// localStream << nbNodes << space; -// // -// // ENFORCED EDGES : BEGIN -// // -// -// // Iterate over the enforced edges -// int usedEnforcedEdges = 0; -// bool isOK; -// for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) { -// aFace = (*elemIt); -// isOK = true; -// itOnSubFace = aFace->nodesIterator(); -// aStream.str(""); -// aStream << "2" << space ; -// for ( int j = 0; j < 2; ++j ) { -// aSmdsID = itOnSubFace->next()->GetID(); -// itOnMap = theEnforcedNodeIdToHybridIdMap.find(aSmdsID); -// if (itOnMap != theEnforcedNodeIdToHybridIdMap.end()) -// aStream << (*itOnMap).second << space; -// else { -// isOK = false; -// break; -// } -// } -// if (isOK) { -// for ( int j=0; j<=2; j++) -// aStream << dummyint << space ; -// // aStream << dummyint << space << dummyint; -// localStream << aStream.str() << std::endl; -// usedEnforcedEdges++; -// } -// } -// -// if (usedEnforcedEdges) { -// globalStream << localStream.str(); -// localStream.str(""); -// } -// -// // -// // ENFORCED EDGES : END -// // -// // -// -// // -// // ENFORCED TRIANGLES : BEGIN -// // -// // Iterate over the enforced triangles -// int usedEnforcedTriangles = 0; -// for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) { -// aFace = (*elemIt); -// nbNodes = aFace->NbCornerNodes(); -// isOK = true; -// itOnSubFace = aFace->nodesIterator(); -// aStream.str(""); -// aStream << nbNodes << space ; -// for ( int j = 0; j < 3; ++j ) { -// aSmdsID = itOnSubFace->next()->GetID(); -// itOnMap = theEnforcedNodeIdToHybridIdMap.find(aSmdsID); -// if (itOnMap != theEnforcedNodeIdToHybridIdMap.end()) -// aStream << (*itOnMap).second << space; -// else { -// isOK = false; -// break; +// itOnSubFace = aFace->nodesIterator(); +// for ( int j = 0; j < 3; ++j ) { +// // find HYBRID ID +// aSmdsID = itOnSubFace->next()->GetID(); +// itOnMap = theSmdsToHybridIdMap.find( aSmdsID ); +// // if ( itOnMap == theSmdsToHybridIdMap.end() ) { +// // cout << "not found node: " << aSmdsID << endl; +// // return false; +// // } +// ASSERT( itOnMap != theSmdsToHybridIdMap.end() ); + +// localStream << (*itOnMap).second << space ; // } + +// // (NB_NODES + 1) times: DUMMY_INT +// for ( int j=0; j<=nbNodes; j++) +// localStream << dummyint << space ; + +// localStream << std::endl; // } -// if (isOK) { -// for ( int j=0; j<=3; j++) -// aStream << dummyint << space ; -// localStream << aStream.str() << std::endl; -// usedEnforcedTriangles++; -// } -// } -// -// if (usedEnforcedTriangles) { -// globalStream << localStream.str(); -// localStream.str(""); // } -// + +// globalStream << localStream.str(); +// localStream.str(""); + // // -// // ENFORCED TRIANGLES : END +// // FACES : END // // + +// // // +// // // ENFORCED EDGES : BEGIN +// // // +// // +// // // Iterate over the enforced edges +// // int usedEnforcedEdges = 0; +// // bool isOK; +// // for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) { +// // aFace = (*elemIt); +// // isOK = true; +// // itOnSubFace = aFace->nodesIterator(); +// // aStream.str(""); +// // aStream << "2" << space ; +// // for ( int j = 0; j < 2; ++j ) { +// // aSmdsID = itOnSubFace->next()->GetID(); +// // itOnMap = theEnforcedNodeIdToHybridIdMap.find(aSmdsID); +// // if (itOnMap != theEnforcedNodeIdToHybridIdMap.end()) +// // aStream << (*itOnMap).second << space; +// // else { +// // isOK = false; +// // break; +// // } +// // } +// // if (isOK) { +// // for ( int j=0; j<=2; j++) +// // aStream << dummyint << space ; +// // // aStream << dummyint << space << dummyint; +// // localStream << aStream.str() << std::endl; +// // usedEnforcedEdges++; +// // } +// // } +// // +// // if (usedEnforcedEdges) { +// // globalStream << localStream.str(); +// // localStream.str(""); +// // } +// // +// // // +// // // ENFORCED EDGES : END +// // // +// // // +// // +// // // +// // // ENFORCED TRIANGLES : BEGIN +// // // +// // // Iterate over the enforced triangles +// // int usedEnforcedTriangles = 0; +// // for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) { +// // aFace = (*elemIt); +// // nbNodes = aFace->NbCornerNodes(); +// // isOK = true; +// // itOnSubFace = aFace->nodesIterator(); +// // aStream.str(""); +// // aStream << nbNodes << space ; +// // for ( int j = 0; j < 3; ++j ) { +// // aSmdsID = itOnSubFace->next()->GetID(); +// // itOnMap = theEnforcedNodeIdToHybridIdMap.find(aSmdsID); +// // if (itOnMap != theEnforcedNodeIdToHybridIdMap.end()) +// // aStream << (*itOnMap).second << space; +// // else { +// // isOK = false; +// // break; +// // } +// // } +// // if (isOK) { +// // for ( int j=0; j<=3; j++) +// // aStream << dummyint << space ; +// // localStream << aStream.str() << std::endl; +// // usedEnforcedTriangles++; +// // } +// // } +// // +// // if (usedEnforcedTriangles) { +// // globalStream << localStream.str(); +// // localStream.str(""); +// // } +// // +// // // +// // // ENFORCED TRIANGLES : END +// // // - theFile - << nbTriangles/*+usedEnforcedTriangles+usedEnforcedEdges*/ - << " 0" << std::endl - << globalStream.str(); +// theFile +// << nbTriangles/*+usedEnforcedTriangles+usedEnforcedEdges*/ +// << " 0" << std::endl +// << globalStream.str(); - return true; -} +// return true; +// } //======================================================================= //function : writePoints //purpose : //======================================================================= -static bool writePoints (ofstream & theFile, - SMESH_MesherHelper& theHelper, - map & theSmdsToHybridIdMap, - map & theEnforcedNodeIdToHybridIdMap, - map & theHybridIdToNodeMap, - HYBRIDPlugin_Hypothesis::TID2SizeMap & theNodeIDToSizeMap, - HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexCoordsValues & theEnforcedVertices, - HYBRIDPlugin_Hypothesis::TIDSortedNodeGroupMap & theEnforcedNodes, - HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges, - HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles) -{ - // record structure: - // - // NB_NODES - // Loop from 1 to NB_NODES - // X Y Z DUMMY_INT - - SMESHDS_Mesh * theMeshDS = theHelper.GetMeshDS(); - int nbNodes = theMeshDS->NbNodes(); - if ( nbNodes == 0 ) - return false; +// static bool writePoints (ofstream & theFile, +// SMESH_MesherHelper& theHelper, +// std::map & theSmdsToHybridIdMap, +// std::map & theEnforcedNodeIdToHybridIdMap, +// std::map & theHybridIdToNodeMap, +// HYBRIDPlugin_Hypothesis::TID2SizeMap & theNodeIDToSizeMap, +// HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexCoordsValues & theEnforcedVertices, +// HYBRIDPlugin_Hypothesis::TIDSortedNodeGroupMap & theEnforcedNodes, +// HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges, +// HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles) +// { +// // record structure: +// // +// // NB_NODES +// // Loop from 1 to NB_NODES +// // X Y Z DUMMY_INT + +// SMESHDS_Mesh * theMeshDS = theHelper.GetMeshDS(); +// int nbNodes = theMeshDS->NbNodes(); +// if ( nbNodes == 0 ) +// return false; - int nbEnforcedVertices = theEnforcedVertices.size(); - int nbEnforcedNodes = theEnforcedNodes.size(); +// int nbEnforcedVertices = theEnforcedVertices.size(); +// int nbEnforcedNodes = theEnforcedNodes.size(); - const TopoDS_Shape shapeToMesh = theMeshDS->ShapeToMesh(); +// const TopoDS_Shape shapeToMesh = theMeshDS->ShapeToMesh(); - int aHybridID = 1; - SMDS_NodeIteratorPtr nodeIt = theMeshDS->nodesIterator(); - const SMDS_MeshNode* node; - - // Issue 020674: EDF 870 SMESH: Mesh generated by Netgen not usable by HYBRID - // The problem is in nodes on degenerated edges, we need to skip nodes which are free - // and replace not-free nodes on degenerated edges by the node on vertex - TNodeNodeMap n2nDegen; // map a node on degenerated edge to a node on vertex - TNodeNodeMap::iterator n2nDegenIt; - if ( theHelper.HasDegeneratedEdges() ) - { - set checkedSM; - for (TopExp_Explorer e(theMeshDS->ShapeToMesh(), TopAbs_EDGE ); e.More(); e.Next()) - { - SMESH_subMesh* sm = theHelper.GetMesh()->GetSubMesh( e.Current() ); - if ( checkedSM.insert( sm->GetId() ).second && theHelper.IsDegenShape(sm->GetId() )) - { - if ( SMESHDS_SubMesh* smDS = sm->GetSubMeshDS() ) - { - TopoDS_Shape vertex = TopoDS_Iterator( e.Current() ).Value(); - const SMDS_MeshNode* vNode = SMESH_Algo::VertexNode( TopoDS::Vertex( vertex ), theMeshDS); - { - SMDS_NodeIteratorPtr nIt = smDS->GetNodes(); - while ( nIt->more() ) - n2nDegen.insert( make_pair( nIt->next(), vNode )); - } - } - } - } - nbNodes -= n2nDegen.size(); - } +// int aHybridID = 1; +// SMDS_NodeIteratorPtr nodeIt = theMeshDS->nodesIterator(); +// const SMDS_MeshNode* node; - const bool isQuadMesh = - theHelper.GetMesh()->NbEdges( ORDER_QUADRATIC ) || - theHelper.GetMesh()->NbFaces( ORDER_QUADRATIC ) || - theHelper.GetMesh()->NbVolumes( ORDER_QUADRATIC ); - if ( isQuadMesh ) - { - // descrease nbNodes by nb of medium nodes - while ( nodeIt->more() ) - { - node = nodeIt->next(); - if ( !theHelper.IsDegenShape( node->getshapeId() )) - nbNodes -= int( theHelper.IsMedium( node )); - } - nodeIt = theMeshDS->nodesIterator(); - } +// // Issue 020674: EDF 870 SMESH: Mesh generated by Netgen not usable by HYBRID +// // The problem is in nodes on degenerated edges, we need to skip nodes which are free +// // and replace not-free nodes on degenerated edges by the node on vertex +// TNodeNodeMap n2nDegen; // map a node on degenerated edge to a node on vertex +// TNodeNodeMap::iterator n2nDegenIt; +// if ( theHelper.HasDegeneratedEdges() ) +// { +// std::set checkedSM; +// for (TopExp_Explorer e(theMeshDS->ShapeToMesh(), TopAbs_EDGE ); e.More(); e.Next()) +// { +// SMESH_subMesh* sm = theHelper.GetMesh()->GetSubMesh( e.Current() ); +// if ( checkedSM.insert( sm->GetId() ).second && theHelper.IsDegenShape(sm->GetId() )) +// { +// if ( SMESHDS_SubMesh* smDS = sm->GetSubMeshDS() ) +// { +// TopoDS_Shape vertex = TopoDS_Iterator( e.Current() ).Value(); +// const SMDS_MeshNode* vNode = SMESH_Algo::VertexNode( TopoDS::Vertex( vertex ), theMeshDS); +// { +// SMDS_NodeIteratorPtr nIt = smDS->GetNodes(); +// while ( nIt->more() ) +// n2nDegen.insert( std::make_pair( nIt->next(), vNode )); +// } +// } +// } +// } +// nbNodes -= n2nDegen.size(); +// } - const char* space = " "; - const int dummyint = 0; +// const bool isQuadMesh = +// theHelper.GetMesh()->NbEdges( ORDER_QUADRATIC ) || +// theHelper.GetMesh()->NbFaces( ORDER_QUADRATIC ) || +// theHelper.GetMesh()->NbVolumes( ORDER_QUADRATIC ); +// if ( isQuadMesh ) +// { +// // descrease nbNodes by nb of medium nodes +// while ( nodeIt->more() ) +// { +// node = nodeIt->next(); +// if ( !theHelper.IsDegenShape( node->getshapeId() )) +// nbNodes -= int( theHelper.IsMedium( node )); +// } +// nodeIt = theMeshDS->nodesIterator(); +// } - std::string tmpStr; - (nbNodes == 0 || nbNodes == 1) ? tmpStr = " node" : tmpStr = " nodes"; - // NB_NODES - std::cout << std::endl; - std::cout << "The initial 2D mesh contains :" << std::endl; - std::cout << " " << nbNodes << tmpStr << std::endl; - if (nbEnforcedVertices > 0) { - (nbEnforcedVertices == 1) ? tmpStr = "vertex" : tmpStr = "vertices"; - std::cout << " " << nbEnforcedVertices << " enforced " << tmpStr << std::endl; - } - if (nbEnforcedNodes > 0) { - (nbEnforcedNodes == 1) ? tmpStr = "node" : tmpStr = "nodes"; - std::cout << " " << nbEnforcedNodes << " enforced " << tmpStr << std::endl; - } - std::cout << std::endl; - std::cout << "Start writing in 'points' file ..." << std::endl; +// const char* space = " "; +// const int dummyint = 0; - theFile << nbNodes << std::endl; +// std::string tmpStr; +// (nbNodes == 0 || nbNodes == 1) ? tmpStr = " node" : tmpStr = " nodes"; +// // NB_NODES +// std::cout << std::endl; +// std::cout << "The initial 2D mesh contains :" << std::endl; +// std::cout << " " << nbNodes << tmpStr << std::endl; +// if (nbEnforcedVertices > 0) { +// (nbEnforcedVertices == 1) ? tmpStr = "vertex" : tmpStr = "vertices"; +// std::cout << " " << nbEnforcedVertices << " enforced " << tmpStr << std::endl; +// } +// if (nbEnforcedNodes > 0) { +// (nbEnforcedNodes == 1) ? tmpStr = "node" : tmpStr = "nodes"; +// std::cout << " " << nbEnforcedNodes << " enforced " << tmpStr << std::endl; +// } +// std::cout << std::endl; +// std::cout << "Start writing in 'points' file ..." << std::endl; - // Loop from 1 to NB_NODES +// theFile << nbNodes << std::endl; - while ( nodeIt->more() ) - { - node = nodeIt->next(); - if ( isQuadMesh && theHelper.IsMedium( node )) // Issue 0021238 - continue; - if ( n2nDegen.count( node ) ) // Issue 0020674 - continue; +// // Loop from 1 to NB_NODES + +// while ( nodeIt->more() ) +// { +// node = nodeIt->next(); +// if ( isQuadMesh && theHelper.IsMedium( node )) // Issue 0021238 +// continue; +// if ( n2nDegen.count( node ) ) // Issue 0020674 +// continue; - theSmdsToHybridIdMap.insert( make_pair( node->GetID(), aHybridID )); - theHybridIdToNodeMap.insert( make_pair( aHybridID, node )); - aHybridID++; +// theSmdsToHybridIdMap.insert( std::make_pair( node->GetID(), aHybridID )); +// theHybridIdToNodeMap.insert( std::make_pair( aHybridID, node )); +// aHybridID++; - // X Y Z DUMMY_INT - theFile - << node->X() << space - << node->Y() << space - << node->Z() << space - << dummyint; +// // X Y Z DUMMY_INT +// theFile +// << node->X() << space +// << node->Y() << space +// << node->Z() << space +// << dummyint; - theFile << std::endl; +// theFile << std::endl; - } +// } - // Iterate over the enforced nodes - std::map enfVertexIndexSizeMap; - if (nbEnforcedNodes) { - HYBRIDPlugin_Hypothesis::TIDSortedNodeGroupMap::const_iterator nodeIt = theEnforcedNodes.begin(); - for( ; nodeIt != theEnforcedNodes.end() ; ++nodeIt) { - double x = nodeIt->first->X(); - double y = nodeIt->first->Y(); - double z = nodeIt->first->Z(); - // Test if point is inside shape to mesh - gp_Pnt myPoint(x,y,z); - BRepClass3d_SolidClassifier scl(shapeToMesh); - scl.Perform(myPoint, 1e-7); - TopAbs_State result = scl.State(); - if ( result != TopAbs_IN ) - continue; - std::vector coords; - coords.push_back(x); - coords.push_back(y); - coords.push_back(z); - if (theEnforcedVertices.find(coords) != theEnforcedVertices.end()) - continue; +// // Iterate over the enforced nodes +// std::map enfVertexIndexSizeMap; +// if (nbEnforcedNodes) { +// HYBRIDPlugin_Hypothesis::TIDSortedNodeGroupMap::const_iterator nodeIt = theEnforcedNodes.begin(); +// for( ; nodeIt != theEnforcedNodes.end() ; ++nodeIt) { +// double x = nodeIt->first->X(); +// double y = nodeIt->first->Y(); +// double z = nodeIt->first->Z(); +// // Test if point is inside shape to mesh +// gp_Pnt myPoint(x,y,z); +// BRepClass3d_SolidClassifier scl(shapeToMesh); +// scl.Perform(myPoint, 1e-7); +// TopAbs_State result = scl.State(); +// if ( result != TopAbs_IN ) +// continue; +// std::vector coords; +// coords.push_back(x); +// coords.push_back(y); +// coords.push_back(z); +// if (theEnforcedVertices.find(coords) != theEnforcedVertices.end()) +// continue; -// double size = theNodeIDToSizeMap.find(nodeIt->first->GetID())->second; - // theHybridIdToNodeMap.insert( make_pair( nbNodes + i, (*nodeIt) )); - // MESSAGE("Adding enforced node (" << x << "," << y <<"," << z << ")"); - // X Y Z PHY_SIZE DUMMY_INT - theFile - << x << space - << y << space - << z << space - << -1 << space - << dummyint << space; - theFile << std::endl; - theEnforcedNodeIdToHybridIdMap.insert( make_pair( nodeIt->first->GetID(), aHybridID )); - enfVertexIndexSizeMap[aHybridID] = -1; - aHybridID++; - // else - // MESSAGE("Enforced vertex (" << x << "," << y <<"," << z << ") is not inside the geometry: it was not added "); - } - } +// // double size = theNodeIDToSizeMap.find(nodeIt->first->GetID())->second; +// // theHybridIdToNodeMap.insert( std::make_pair( nbNodes + i, (*nodeIt) )); +// // MESSAGE("Adding enforced node (" << x << "," << y <<"," << z << ")"); +// // X Y Z PHY_SIZE DUMMY_INT +// theFile +// << x << space +// << y << space +// << z << space +// << -1 << space +// << dummyint << space; +// theFile << std::endl; +// theEnforcedNodeIdToHybridIdMap.insert( std::make_pair( nodeIt->first->GetID(), aHybridID )); +// enfVertexIndexSizeMap[aHybridID] = -1; +// aHybridID++; +// // else +// // MESSAGE("Enforced vertex (" << x << "," << y <<"," << z << ") is not inside the geometry: it was not added "); +// } +// } - if (nbEnforcedVertices) { - // Iterate over the enforced vertices - HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexCoordsValues::const_iterator vertexIt = theEnforcedVertices.begin(); - for( ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) { - double x = vertexIt->first[0]; - double y = vertexIt->first[1]; - double z = vertexIt->first[2]; - // Test if point is inside shape to mesh - gp_Pnt myPoint(x,y,z); - BRepClass3d_SolidClassifier scl(shapeToMesh); - scl.Perform(myPoint, 1e-7); - TopAbs_State result = scl.State(); - if ( result != TopAbs_IN ) - continue; - MESSAGE("Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second); - // X Y Z PHY_SIZE DUMMY_INT - theFile - << x << space - << y << space - << z << space - << vertexIt->second << space - << dummyint << space; - theFile << std::endl; - enfVertexIndexSizeMap[aHybridID] = vertexIt->second; - aHybridID++; - } - } +// if (nbEnforcedVertices) { +// // Iterate over the enforced vertices +// HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexCoordsValues::const_iterator vertexIt = theEnforcedVertices.begin(); +// for( ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) { +// double x = vertexIt->first[0]; +// double y = vertexIt->first[1]; +// double z = vertexIt->first[2]; +// // Test if point is inside shape to mesh +// gp_Pnt myPoint(x,y,z); +// BRepClass3d_SolidClassifier scl(shapeToMesh); +// scl.Perform(myPoint, 1e-7); +// TopAbs_State result = scl.State(); +// if ( result != TopAbs_IN ) +// continue; +// MESSAGE("Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second); +// // X Y Z PHY_SIZE DUMMY_INT +// theFile +// << x << space +// << y << space +// << z << space +// << vertexIt->second << space +// << dummyint << space; +// theFile << std::endl; +// enfVertexIndexSizeMap[aHybridID] = vertexIt->second; +// aHybridID++; +// } +// } - std::cout << std::endl; - std::cout << "End writing in 'points' file." << std::endl; +// std::cout << std::endl; +// std::cout << "End writing in 'points' file." << std::endl; - return true; -} +// return true; +// } //======================================================================= //function : readResultFile //purpose : readResultFile with geometry //======================================================================= -static bool readResultFile(const int fileOpen, -#ifdef WIN32 - const char* fileName, -#endif - HYBRIDPlugin_HYBRID* theAlgo, - SMESH_MesherHelper& theHelper, - TopoDS_Shape tabShape[], - double** tabBox, - const int nbShape, - map & theHybridIdToNodeMap, - std::map & theNodeId2NodeIndexMap, - bool toMeshHoles, - int nbEnforcedVertices, - int nbEnforcedNodes, - HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges, - HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles, - bool toMakeGroupsOfDomains) -{ - MESSAGE("HYBRIDPlugin_HYBRID::readResultFile()"); - Kernel_Utils::Localizer loc; - struct stat status; - size_t length; +// static bool readResultFile(const int fileOpen, +// #ifdef WIN32 +// const char* fileName, +// #endif +// HYBRIDPlugin_HYBRID* theAlgo, +// SMESH_MesherHelper& theHelper, +// TopoDS_Shape tabShape[], +// double** tabBox, +// const int nbShape, +// std::map & theHybridIdToNodeMap, +// std::map & theNodeId2NodeIndexMap, +// bool toMeshHoles, +// int nbEnforcedVertices, +// int nbEnforcedNodes, +// HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges, +// HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles, +// bool toMakeGroupsOfDomains) +// { +// MESSAGE("HYBRIDPlugin_HYBRID::readResultFile()"); +// Kernel_Utils::Localizer loc; +// struct stat status; +// size_t length; - std::string tmpStr; - - char *ptr, *mapPtr; - char *tetraPtr; - char *shapePtr; - - SMESHDS_Mesh* theMeshDS = theHelper.GetMeshDS(); - - int nbElems, nbNodes, nbInputNodes; - int nbTriangle; - int ID, shapeID, hybridShapeID; - int IdShapeRef = 1; - int compoundID = - nbShape ? theMeshDS->ShapeToIndex( tabShape[0] ) : theMeshDS->ShapeToIndex( theMeshDS->ShapeToMesh() ); - - int *tab, *tabID, *nodeID, *nodeAssigne; - double *coord; - const SMDS_MeshNode **node; +// std::string tmpStr; + +// char *ptr, *mapPtr; +// char *tetraPtr; +// char *shapePtr; + +// SMESHDS_Mesh* theMeshDS = theHelper.GetMeshDS(); + +// int nbElems, nbNodes, nbInputNodes; +// int nbTriangle; +// int ID, shapeID, hybridShapeID; +// int IdShapeRef = 1; +// int compoundID = +// nbShape ? theMeshDS->ShapeToIndex( tabShape[0] ) : theMeshDS->ShapeToIndex( theMeshDS->ShapeToMesh() ); + +// int *tab, *tabID, *nodeID, *nodeAssigne; +// double *coord; +// const SMDS_MeshNode **node; + +// tab = new int[3]; +// nodeID = new int[4]; +// coord = new double[3]; +// node = new const SMDS_MeshNode*[4]; + +// TopoDS_Shape aSolid; +// SMDS_MeshNode * aNewNode; +// std::map ::iterator itOnNode; +// SMDS_MeshElement* aTet; +// #ifdef _DEBUG_ +// std::set shapeIDs; +// #endif - tab = new int[3]; - nodeID = new int[4]; - coord = new double[3]; - node = new const SMDS_MeshNode*[4]; +// // Read the file state +// fstat(fileOpen, &status); +// length = status.st_size; - TopoDS_Shape aSolid; - SMDS_MeshNode * aNewNode; - map ::iterator itOnNode; - SMDS_MeshElement* aTet; -#ifdef _DEBUG_ - set shapeIDs; -#endif - - // Read the file state - fstat(fileOpen, &status); - length = status.st_size; +// // Mapping the result file into memory +// #ifdef WIN32 +// HANDLE fd = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, +// NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); +// HANDLE hMapObject = CreateFileMapping(fd, NULL, PAGE_READONLY, +// 0, (DWORD)length, NULL); +// ptr = ( char* ) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0 ); +// #else +// ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0); +// #endif +// mapPtr = ptr; - // Mapping the result file into memory -#ifdef WIN32 - HANDLE fd = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - HANDLE hMapObject = CreateFileMapping(fd, NULL, PAGE_READONLY, - 0, (DWORD)length, NULL); - ptr = ( char* ) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0 ); -#else - ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0); -#endif - mapPtr = ptr; +// ptr = readMapIntLine(ptr, tab); +// tetraPtr = ptr; - ptr = readMapIntLine(ptr, tab); - tetraPtr = ptr; +// nbElems = tab[0]; +// nbNodes = tab[1]; +// nbInputNodes = tab[2]; - nbElems = tab[0]; - nbNodes = tab[1]; - nbInputNodes = tab[2]; +// nodeAssigne = new int[ nbNodes+1 ]; - nodeAssigne = new int[ nbNodes+1 ]; +// if (nbShape > 0) +// aSolid = tabShape[0]; - if (nbShape > 0) - aSolid = tabShape[0]; +// // Reading the nodeId +// for (int i=0; i < 4*nbElems; i++) +// strtol(ptr, &ptr, 10); - // Reading the nodeId - for (int i=0; i < 4*nbElems; i++) - strtol(ptr, &ptr, 10); +// MESSAGE("nbInputNodes: "<computeCanceled()) +// return false; +// for (int iCoor=0; iCoor < 3; iCoor++) +// coord[ iCoor ] = strtod(ptr, &ptr); +// nodeAssigne[ iNode ] = 1; +// if ( iNode > (nbInputNodes-(nbEnforcedVertices+nbEnforcedNodes)) ) { +// // Creating SMESH nodes +// // - for enforced vertices +// // - for vertices of forced edges +// // - for hybrid nodes +// nodeAssigne[ iNode ] = 0; +// aNewNode = theMeshDS->AddNode( coord[0],coord[1],coord[2] ); +// theHybridIdToNodeMap.insert(theHybridIdToNodeMap.end(), std::make_pair( iNode, aNewNode )); +// } +// } - MESSAGE("nbInputNodes: "<computeCanceled()) - return false; - for (int iCoor=0; iCoor < 3; iCoor++) - coord[ iCoor ] = strtod(ptr, &ptr); - nodeAssigne[ iNode ] = 1; - if ( iNode > (nbInputNodes-(nbEnforcedVertices+nbEnforcedNodes)) ) { - // Creating SMESH nodes - // - for enforced vertices - // - for vertices of forced edges - // - for hybrid nodes - nodeAssigne[ iNode ] = 0; - aNewNode = theMeshDS->AddNode( coord[0],coord[1],coord[2] ); - theHybridIdToNodeMap.insert(theHybridIdToNodeMap.end(), make_pair( iNode, aNewNode )); - } - } +// // Reading the number of triangles which corresponds to the number of sub-domains +// nbTriangle = strtol(ptr, &ptr, 10); - // Reading the number of triangles which corresponds to the number of sub-domains - nbTriangle = strtol(ptr, &ptr, 10); +// tabID = new int[nbTriangle]; +// for (int i=0; i < nbTriangle; i++) { +// if(theAlgo->computeCanceled()) +// return false; +// tabID[i] = 0; +// // find the solid corresponding to HYBRID sub-domain following +// // the technique proposed in HYBRID manual in chapter +// // "B.4 Subdomain (sub-region) assignment" +// int nodeId1 = strtol(ptr, &ptr, 10); +// int nodeId2 = strtol(ptr, &ptr, 10); +// int nodeId3 = strtol(ptr, &ptr, 10); +// if ( nbTriangle > 1 ) { +// const SMDS_MeshNode* n1 = theHybridIdToNodeMap[ nodeId1 ]; +// const SMDS_MeshNode* n2 = theHybridIdToNodeMap[ nodeId2 ]; +// const SMDS_MeshNode* n3 = theHybridIdToNodeMap[ nodeId3 ]; +// if (!n1 || !n2 || !n3) { +// tabID[i] = HOLE_ID; +// continue; +// } +// try { +// OCC_CATCH_SIGNALS; +// // tabID[i] = findShapeID( theHelper, n1, n2, n3, toMeshHoles ); +// tabID[i] = findShapeID( *theHelper.GetMesh(), n1, n2, n3, toMeshHoles ); +// // -- 0020330: Pb with hybrid as a submesh +// // check that found shape is to be meshed +// if ( tabID[i] > 0 ) { +// const TopoDS_Shape& foundShape = theMeshDS->IndexToShape( tabID[i] ); +// bool isToBeMeshed = false; +// for ( int iS = 0; !isToBeMeshed && iS < nbShape; ++iS ) +// isToBeMeshed = foundShape.IsSame( tabShape[ iS ]); +// if ( !isToBeMeshed ) +// tabID[i] = HOLE_ID; +// } +// // END -- 0020330: Pb with hybrid as a submesh +// #ifdef _DEBUG_ +// std::cout << i+1 << " subdomain: findShapeID() returns " << tabID[i] << std::endl; +// #endif +// } +// catch ( Standard_Failure & ex) +// { +// #ifdef _DEBUG_ +// std::cout << i+1 << " subdomain: Exception caugt: " << ex.GetMessageString() << std::endl; +// #endif +// } +// catch (...) { +// #ifdef _DEBUG_ +// std::cout << i+1 << " subdomain: unknown exception caught " << std::endl; +// #endif +// } +// } +// } - tabID = new int[nbTriangle]; - for (int i=0; i < nbTriangle; i++) { - if(theAlgo->computeCanceled()) - return false; - tabID[i] = 0; - // find the solid corresponding to HYBRID sub-domain following - // the technique proposed in HYBRID manual in chapter - // "B.4 Subdomain (sub-region) assignment" - int nodeId1 = strtol(ptr, &ptr, 10); - int nodeId2 = strtol(ptr, &ptr, 10); - int nodeId3 = strtol(ptr, &ptr, 10); - if ( nbTriangle > 1 ) { - const SMDS_MeshNode* n1 = theHybridIdToNodeMap[ nodeId1 ]; - const SMDS_MeshNode* n2 = theHybridIdToNodeMap[ nodeId2 ]; - const SMDS_MeshNode* n3 = theHybridIdToNodeMap[ nodeId3 ]; - if (!n1 || !n2 || !n3) { - tabID[i] = HOLE_ID; - continue; - } - try { - OCC_CATCH_SIGNALS; -// tabID[i] = findShapeID( theHelper, n1, n2, n3, toMeshHoles ); - tabID[i] = findShapeID( *theHelper.GetMesh(), n1, n2, n3, toMeshHoles ); - // -- 0020330: Pb with hybrid as a submesh - // check that found shape is to be meshed - if ( tabID[i] > 0 ) { - const TopoDS_Shape& foundShape = theMeshDS->IndexToShape( tabID[i] ); - bool isToBeMeshed = false; - for ( int iS = 0; !isToBeMeshed && iS < nbShape; ++iS ) - isToBeMeshed = foundShape.IsSame( tabShape[ iS ]); - if ( !isToBeMeshed ) - tabID[i] = HOLE_ID; - } - // END -- 0020330: Pb with hybrid as a submesh -#ifdef _DEBUG_ - std::cout << i+1 << " subdomain: findShapeID() returns " << tabID[i] << std::endl; -#endif - } - catch ( Standard_Failure & ex) - { -#ifdef _DEBUG_ - std::cout << i+1 << " subdomain: Exception caugt: " << ex.GetMessageString() << std::endl; -#endif - } - catch (...) { -#ifdef _DEBUG_ - std::cout << i+1 << " subdomain: unknown exception caught " << std::endl; -#endif - } - } - } +// shapePtr = ptr; - shapePtr = ptr; +// if ( nbTriangle <= nbShape ) // no holes +// toMeshHoles = true; // not avoid creating tetras in holes - if ( nbTriangle <= nbShape ) // no holes - toMeshHoles = true; // not avoid creating tetras in holes +// // IMP 0022172: [CEA 790] create the groups corresponding to domains +// std::vector< std::vector< const SMDS_MeshElement* > > elemsOfDomain( Max( nbTriangle, nbShape )); - // IMP 0022172: [CEA 790] create the groups corresponding to domains - std::vector< std::vector< const SMDS_MeshElement* > > elemsOfDomain( Max( nbTriangle, nbShape )); - - // Associating the tetrahedrons to the shapes - shapeID = compoundID; - for (int iElem = 0; iElem < nbElems; iElem++) { - if(theAlgo->computeCanceled()) - return false; - for (int iNode = 0; iNode < 4; iNode++) { - ID = strtol(tetraPtr, &tetraPtr, 10); - itOnNode = theHybridIdToNodeMap.find(ID); - node[ iNode ] = itOnNode->second; - nodeID[ iNode ] = ID; - } - // We always run HYBRID with "to mesh holes"==TRUE but we must not create - // tetras within holes depending on hypo option, - // so we first check if aTet is inside a hole and then create it - //aTet = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] ); - hybridShapeID = 0; // domain ID - if ( nbTriangle > 1 ) { - shapeID = HOLE_ID; // negative shapeID means not to create tetras if !toMeshHoles - hybridShapeID = strtol(shapePtr, &shapePtr, 10) - IdShapeRef; - if ( tabID[ hybridShapeID ] == 0 ) { - TopAbs_State state; - aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape, &state); - if ( toMeshHoles || state == TopAbs_IN ) - shapeID = theMeshDS->ShapeToIndex( aSolid ); - tabID[ hybridShapeID ] = shapeID; - } - else - shapeID = tabID[ hybridShapeID ]; - } - else if ( nbShape > 1 ) { - // Case where nbTriangle == 1 while nbShape == 2 encountered - // with compound of 2 boxes and "To mesh holes"==False, - // so there are no subdomains specified for each tetrahedron. - // Try to guess a solid by a node already bound to shape - shapeID = 0; - for ( int i=0; i<4 && shapeID==0; i++ ) { - if ( nodeAssigne[ nodeID[i] ] == 1 && - node[i]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE && - node[i]->getshapeId() > 1 ) - { - shapeID = node[i]->getshapeId(); - } - } - if ( shapeID==0 ) { - aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape); - shapeID = theMeshDS->ShapeToIndex( aSolid ); - } - } - // set new nodes and tetrahedron onto the shape - for ( int i=0; i<4; i++ ) { - if ( nodeAssigne[ nodeID[i] ] == 0 ) { - if ( shapeID != HOLE_ID ) - theMeshDS->SetNodeInVolume( node[i], shapeID ); - nodeAssigne[ nodeID[i] ] = shapeID; - } - } - if ( toMeshHoles || shapeID != HOLE_ID ) { - aTet = theHelper.AddVolume( node[1], node[0], node[2], node[3], - /*id=*/0, /*force3d=*/false); - theMeshDS->SetMeshElementOnShape( aTet, shapeID ); - if ( toMakeGroupsOfDomains ) - { - if ( int( elemsOfDomain.size() ) < hybridShapeID+1 ) - elemsOfDomain.resize( hybridShapeID+1 ); - elemsOfDomain[ hybridShapeID ].push_back( aTet ); - } - } -#ifdef _DEBUG_ - shapeIDs.insert( shapeID ); -#endif - } - if ( toMakeGroupsOfDomains ) - makeDomainGroups( elemsOfDomain, &theHelper ); +// // Associating the tetrahedrons to the shapes +// shapeID = compoundID; +// for (int iElem = 0; iElem < nbElems; iElem++) { +// if(theAlgo->computeCanceled()) +// return false; +// for (int iNode = 0; iNode < 4; iNode++) { +// ID = strtol(tetraPtr, &tetraPtr, 10); +// itOnNode = theHybridIdToNodeMap.find(ID); +// node[ iNode ] = itOnNode->second; +// nodeID[ iNode ] = ID; +// } +// // We always run HYBRID with "to mesh holes"==TRUE but we must not create +// // tetras within holes depending on hypo option, +// // so we first check if aTet is inside a hole and then create it +// //aTet = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] ); +// hybridShapeID = 0; // domain ID +// if ( nbTriangle > 1 ) { +// shapeID = HOLE_ID; // negative shapeID means not to create tetras if !toMeshHoles +// hybridShapeID = strtol(shapePtr, &shapePtr, 10) - IdShapeRef; +// if ( tabID[ hybridShapeID ] == 0 ) { +// TopAbs_State state; +// aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape, &state); +// if ( toMeshHoles || state == TopAbs_IN ) +// shapeID = theMeshDS->ShapeToIndex( aSolid ); +// tabID[ hybridShapeID ] = shapeID; +// } +// else +// shapeID = tabID[ hybridShapeID ]; +// } +// else if ( nbShape > 1 ) { +// // Case where nbTriangle == 1 while nbShape == 2 encountered +// // with compound of 2 boxes and "To mesh holes"==False, +// // so there are no subdomains specified for each tetrahedron. +// // Try to guess a solid by a node already bound to shape +// shapeID = 0; +// for ( int i=0; i<4 && shapeID==0; i++ ) { +// if ( nodeAssigne[ nodeID[i] ] == 1 && +// node[i]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE && +// node[i]->getshapeId() > 1 ) +// { +// shapeID = node[i]->getshapeId(); +// } +// } +// if ( shapeID==0 ) { +// aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape); +// shapeID = theMeshDS->ShapeToIndex( aSolid ); +// } +// } +// // set new nodes and tetrahedron onto the shape +// for ( int i=0; i<4; i++ ) { +// if ( nodeAssigne[ nodeID[i] ] == 0 ) { +// if ( shapeID != HOLE_ID ) +// theMeshDS->SetNodeInVolume( node[i], shapeID ); +// nodeAssigne[ nodeID[i] ] = shapeID; +// } +// } +// if ( toMeshHoles || shapeID != HOLE_ID ) { +// aTet = theHelper.AddVolume( node[1], node[0], node[2], node[3], +// /*id=*/0, /*force3d=*/false); +// theMeshDS->SetMeshElementOnShape( aTet, shapeID ); +// if ( toMakeGroupsOfDomains ) +// { +// if ( int( elemsOfDomain.size() ) < hybridShapeID+1 ) +// elemsOfDomain.resize( hybridShapeID+1 ); +// elemsOfDomain[ hybridShapeID ].push_back( aTet ); +// } +// } +// #ifdef _DEBUG_ +// shapeIDs.insert( shapeID ); +// #endif +// } +// if ( toMakeGroupsOfDomains ) +// makeDomainGroups( elemsOfDomain, &theHelper ); - // Add enforced elements - HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap::const_iterator elemIt; - const SMDS_MeshElement* anElem; - SMDS_ElemIteratorPtr itOnEnfElem; - map::const_iterator itOnMap; - shapeID = compoundID; - // Enforced edges - if (theEnforcedEdges.size()) { - (theEnforcedEdges.size() <= 1) ? tmpStr = " enforced edge" : " enforced edges"; - std::cout << "Add " << theEnforcedEdges.size() << tmpStr << std::endl; - std::vector< const SMDS_MeshNode* > node( 2 ); - // Iterate over the enforced edges - for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) { - anElem = elemIt->first; - bool addElem = true; - itOnEnfElem = anElem->nodesIterator(); - for ( int j = 0; j < 2; ++j ) { - int aNodeID = itOnEnfElem->next()->GetID(); - itOnMap = theNodeId2NodeIndexMap.find(aNodeID); - if (itOnMap != theNodeId2NodeIndexMap.end()) { - itOnNode = theHybridIdToNodeMap.find((*itOnMap).second); - if (itOnNode != theHybridIdToNodeMap.end()) { - node.push_back((*itOnNode).second); -// shapeID =(*itOnNode).second->getshapeId(); - } - else - addElem = false; - } - else - addElem = false; - } - if (addElem) { - aTet = theHelper.AddEdge( node[0], node[1], 0, false); - theMeshDS->SetMeshElementOnShape( aTet, shapeID ); - } - } - } - // Enforced faces - if (theEnforcedTriangles.size()) { - (theEnforcedTriangles.size() <= 1) ? tmpStr = " enforced triangle" : " enforced triangles"; - std::cout << "Add " << theEnforcedTriangles.size() << " enforced triangles" << std::endl; - std::vector< const SMDS_MeshNode* > node( 3 ); - // Iterate over the enforced triangles - for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) { - anElem = elemIt->first; - bool addElem = true; - itOnEnfElem = anElem->nodesIterator(); - for ( int j = 0; j < 3; ++j ) { - int aNodeID = itOnEnfElem->next()->GetID(); - itOnMap = theNodeId2NodeIndexMap.find(aNodeID); - if (itOnMap != theNodeId2NodeIndexMap.end()) { - itOnNode = theHybridIdToNodeMap.find((*itOnMap).second); - if (itOnNode != theHybridIdToNodeMap.end()) { - node.push_back((*itOnNode).second); -// shapeID =(*itOnNode).second->getshapeId(); - } - else - addElem = false; - } - else - addElem = false; - } - if (addElem) { - aTet = theHelper.AddFace( node[0], node[1], node[2], 0, false); - theMeshDS->SetMeshElementOnShape( aTet, shapeID ); - } - } - } +// // Add enforced elements +// HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap::const_iterator elemIt; +// const SMDS_MeshElement* anElem; +// SMDS_ElemIteratorPtr itOnEnfElem; +// std::map::const_iterator itOnMap; +// shapeID = compoundID; +// // Enforced edges +// if (theEnforcedEdges.size()) { +// (theEnforcedEdges.size() <= 1) ? tmpStr = " enforced edge" : " enforced edges"; +// std::cout << "Add " << theEnforcedEdges.size() << tmpStr << std::endl; +// std::vector< const SMDS_MeshNode* > node( 2 ); +// // Iterate over the enforced edges +// for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) { +// anElem = elemIt->first; +// bool addElem = true; +// itOnEnfElem = anElem->nodesIterator(); +// for ( int j = 0; j < 2; ++j ) { +// int aNodeID = itOnEnfElem->next()->GetID(); +// itOnMap = theNodeId2NodeIndexMap.find(aNodeID); +// if (itOnMap != theNodeId2NodeIndexMap.end()) { +// itOnNode = theHybridIdToNodeMap.find((*itOnMap).second); +// if (itOnNode != theHybridIdToNodeMap.end()) { +// node.push_back((*itOnNode).second); +// // shapeID =(*itOnNode).second->getshapeId(); +// } +// else +// addElem = false; +// } +// else +// addElem = false; +// } +// if (addElem) { +// aTet = theHelper.AddEdge( node[0], node[1], 0, false); +// theMeshDS->SetMeshElementOnShape( aTet, shapeID ); +// } +// } +// } +// // Enforced faces +// if (theEnforcedTriangles.size()) { +// (theEnforcedTriangles.size() <= 1) ? tmpStr = " enforced triangle" : " enforced triangles"; +// std::cout << "Add " << theEnforcedTriangles.size() << " enforced triangles" << std::endl; +// std::vector< const SMDS_MeshNode* > node( 3 ); +// // Iterate over the enforced triangles +// for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) { +// anElem = elemIt->first; +// bool addElem = true; +// itOnEnfElem = anElem->nodesIterator(); +// for ( int j = 0; j < 3; ++j ) { +// int aNodeID = itOnEnfElem->next()->GetID(); +// itOnMap = theNodeId2NodeIndexMap.find(aNodeID); +// if (itOnMap != theNodeId2NodeIndexMap.end()) { +// itOnNode = theHybridIdToNodeMap.find((*itOnMap).second); +// if (itOnNode != theHybridIdToNodeMap.end()) { +// node.push_back((*itOnNode).second); +// // shapeID =(*itOnNode).second->getshapeId(); +// } +// else +// addElem = false; +// } +// else +// addElem = false; +// } +// if (addElem) { +// aTet = theHelper.AddFace( node[0], node[1], node[2], 0, false); +// theMeshDS->SetMeshElementOnShape( aTet, shapeID ); +// } +// } +// } - // Remove nodes of tetras inside holes if !toMeshHoles - if ( !toMeshHoles ) { - itOnNode = theHybridIdToNodeMap.find( nbInputNodes ); - for ( ; itOnNode != theHybridIdToNodeMap.end(); ++itOnNode) { - ID = itOnNode->first; - if ( nodeAssigne[ ID ] == HOLE_ID ) - theMeshDS->RemoveFreeNode( itOnNode->second, 0 ); - } - } +// // Remove nodes of tetras inside holes if !toMeshHoles +// if ( !toMeshHoles ) { +// itOnNode = theHybridIdToNodeMap.find( nbInputNodes ); +// for ( ; itOnNode != theHybridIdToNodeMap.end(); ++itOnNode) { +// ID = itOnNode->first; +// if ( nodeAssigne[ ID ] == HOLE_ID ) +// theMeshDS->RemoveFreeNode( itOnNode->second, 0 ); +// } +// } - if ( nbElems ) { - (nbElems <= 1) ? tmpStr = " tetrahedra" : " tetrahedrons"; - cout << nbElems << tmpStr << " have been associated to " << nbShape; - (nbShape <= 1) ? tmpStr = " shape" : " shapes"; - cout << tmpStr << endl; - } -#ifdef WIN32 - UnmapViewOfFile(mapPtr); - CloseHandle(hMapObject); - CloseHandle(fd); -#else - munmap(mapPtr, length); -#endif - close(fileOpen); - - delete [] tab; - delete [] tabID; - delete [] nodeID; - delete [] coord; - delete [] node; - delete [] nodeAssigne; - -#ifdef _DEBUG_ - shapeIDs.erase(-1); - if ( shapeIDs.size() != nbShape ) { - (shapeIDs.size() <= 1) ? tmpStr = " solid" : " solids"; - std::cout << "Only " << shapeIDs.size() << tmpStr << " of " << nbShape << " found" << std::endl; - for (int i=0; iShapeToIndex( tabShape[i] ); - if ( shapeIDs.find( shapeID ) == shapeIDs.end() ) - std::cout << " Solid #" << shapeID << " not found" << std::endl; - } - } -#endif +// if ( nbElems ) { +// (nbElems <= 1) ? tmpStr = " tetrahedra" : " tetrahedrons"; +// cout << nbElems << tmpStr << " have been associated to " << nbShape; +// (nbShape <= 1) ? tmpStr = " shape" : " shapes"; +// cout << tmpStr << endl; +// } +// #ifdef WIN32 +// UnmapViewOfFile(mapPtr); +// CloseHandle(hMapObject); +// CloseHandle(fd); +// #else +// munmap(mapPtr, length); +// #endif +// close(fileOpen); + +// delete [] tab; +// delete [] tabID; +// delete [] nodeID; +// delete [] coord; +// delete [] node; +// delete [] nodeAssigne; + +// #ifdef _DEBUG_ +// shapeIDs.erase(-1); +// if ((int) shapeIDs.size() != nbShape ) { +// (shapeIDs.size() <= 1) ? tmpStr = " solid" : " solids"; +// std::cout << "Only " << shapeIDs.size() << tmpStr << " of " << nbShape << " found" << std::endl; +// for (int i=0; iShapeToIndex( tabShape[i] ); +// if ( shapeIDs.find( shapeID ) == shapeIDs.end() ) +// std::cout << " Solid #" << shapeID << " not found" << std::endl; +// } +// } +// #endif - return true; -} +// return true; +// } //============================================================================= @@ -2948,9 +2950,9 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* enfVertex = (*enfVerIt); // if (enfVertex->geomEntry.empty() && enfVertex->coords.size()) { if (enfVertex->coords.size()) { - coordsSizeMap.insert(make_pair(enfVertex->coords,enfVertex->size)); - enfVerticesWithGroup.insert(make_pair(enfVertex->coords,enfVertex->groupName)); -// MESSAGE("enfVerticesWithGroup.insert(make_pair(("<coords[0]<<","<coords[1]<<","<coords[2]<<"),\""<groupName<<"\"))"); + coordsSizeMap.insert(std::make_pair(enfVertex->coords,enfVertex->size)); + enfVerticesWithGroup.insert(std::make_pair(enfVertex->coords,enfVertex->groupName)); +// MESSAGE("enfVerticesWithGroup.insert(std::make_pair(("<coords[0]<<","<coords[1]<<","<coords[2]<<"),\""<groupName<<"\"))"); } else { // if (!enfVertex->geomEntry.empty()) { @@ -2965,8 +2967,8 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, // coords.push_back(aPnt.Y()); // coords.push_back(aPnt.Z()); // if (coordsSizeMap.find(coords) == coordsSizeMap.end()) { -// coordsSizeMap.insert(make_pair(coords,enfVertex->size)); -// enfVerticesWithGroup.insert(make_pair(coords,enfVertex->groupName)); +// coordsSizeMap.insert(std::make_pair(coords,enfVertex->size)); +// enfVerticesWithGroup.insert(std::make_pair(coords,enfVertex->groupName)); // } // } // @@ -2981,9 +2983,9 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, coords.push_back(aPnt.Y()); coords.push_back(aPnt.Z()); if (coordsSizeMap.find(coords) == coordsSizeMap.end()) { - coordsSizeMap.insert(make_pair(coords,enfVertex->size)); - enfVerticesWithGroup.insert(make_pair(coords,enfVertex->groupName)); -// MESSAGE("enfVerticesWithGroup.insert(make_pair(("<groupName<<"\"))"); + coordsSizeMap.insert(std::make_pair(coords,enfVertex->size)); + enfVerticesWithGroup.insert(std::make_pair(coords,enfVertex->groupName)); +// MESSAGE("enfVerticesWithGroup.insert(std::make_pair(("<groupName<<"\"))"); } } } @@ -3012,7 +3014,7 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, // make prisms on quadrangles if ( theMesh.NbQuadrangles() > 0 ) { - vector components; + std::vector components; for (expBox.ReInit(); expBox.More(); expBox.Next()) { if ( _viscousLayersHyp ) @@ -3062,7 +3064,7 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, } INFOS( "Writing ids relation into " << aSmdsToHybridIdMapFileName); aIdsFile << "Smds Hybrid" << std::endl; - map ::const_iterator myit; + std::map ::const_iterator myit; for (myit=aSmdsToHybridIdMap.begin() ; myit != aSmdsToHybridIdMap.end() ; ++myit) { aIdsFile << myit->first << " " << myit->second << std::endl; } @@ -3254,9 +3256,9 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, enfVertex = (*enfVerIt); // if (enfVertex->geomEntry.empty() && enfVertex->coords.size()) { if (enfVertex->coords.size()) { - coordsSizeMap.insert(make_pair(enfVertex->coords,enfVertex->size)); - enfVerticesWithGroup.insert(make_pair(enfVertex->coords,enfVertex->groupName)); -// MESSAGE("enfVerticesWithGroup.insert(make_pair(("<coords[0]<<","<coords[1]<<","<coords[2]<<"),\""<groupName<<"\"))"); + coordsSizeMap.insert(std::make_pair(enfVertex->coords,enfVertex->size)); + enfVerticesWithGroup.insert(std::make_pair(enfVertex->coords,enfVertex->groupName)); +// MESSAGE("enfVerticesWithGroup.insert(std::make_pair(("<coords[0]<<","<coords[1]<<","<coords[2]<<"),\""<groupName<<"\"))"); } else { // if (!enfVertex->geomEntry.empty()) { @@ -3271,8 +3273,8 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, // coords.push_back(aPnt.Y()); // coords.push_back(aPnt.Z()); // if (coordsSizeMap.find(coords) == coordsSizeMap.end()) { -// coordsSizeMap.insert(make_pair(coords,enfVertex->size)); -// enfVerticesWithGroup.insert(make_pair(coords,enfVertex->groupName)); +// coordsSizeMap.insert(std::make_pair(coords,enfVertex->size)); +// enfVerticesWithGroup.insert(std::make_pair(coords,enfVertex->groupName)); // } // } // @@ -3287,9 +3289,9 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, coords.push_back(aPnt.Y()); coords.push_back(aPnt.Z()); if (coordsSizeMap.find(coords) == coordsSizeMap.end()) { - coordsSizeMap.insert(make_pair(coords,enfVertex->size)); - enfVerticesWithGroup.insert(make_pair(coords,enfVertex->groupName)); -// MESSAGE("enfVerticesWithGroup.insert(make_pair(("<groupName<<"\"))"); + coordsSizeMap.insert(std::make_pair(coords,enfVertex->size)); + enfVerticesWithGroup.insert(std::make_pair(coords,enfVertex->groupName)); +// MESSAGE("enfVerticesWithGroup.insert(std::make_pair(("<groupName<<"\"))"); } } } @@ -3308,7 +3310,7 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, // coords.push_back(enfNode->Y()); // coords.push_back(enfNode->Z()); // if (enfVerticesWithGro -// enfVerticesWithGroup.insert(make_pair(coords,enfNodeIt->second)); +// enfVerticesWithGroup.insert(std::make_pair(coords,enfNodeIt->second)); // } @@ -3465,7 +3467,7 @@ static const char* translateError(const int errNum) */ //================================================================================ -static char* getIds( char* ptr, int nbIds, vector& ids ) +static char* getIds( char* ptr, int nbIds, std::vector& ids ) { ids.clear(); ids.reserve( nbIds ); @@ -3505,7 +3507,7 @@ bool HYBRIDPlugin_HYBRID::storeErrorDescription(const TCollection_AsciiString& l lseek( file, 0, SEEK_SET); // read file - vector< char > buf( length ); + std::vector< char > buf( length ); int nBytesRead = ::read (file, & buf[0], length); ::close (file); char* ptr = & buf[0]; @@ -3536,15 +3538,15 @@ bool HYBRIDPlugin_HYBRID::storeErrorDescription(const TCollection_AsciiString& l // look for errors "ERR #" - set foundErrorStr; // to avoid reporting same error several times - set elemErrorNums; // not to report different types of errors with bad elements + std::set foundErrorStr; // to avoid reporting same error several times + std::set elemErrorNums; // not to report different types of errors with bad elements while ( ++ptr < bufEnd ) { if ( strncmp( ptr, "ERR ", 4 ) != 0 ) continue; - list badElems; - vector nodeIds; + std::list badElems; + std::vector nodeIds; ptr += 4; char* errBeg = ptr; @@ -3564,7 +3566,7 @@ bool HYBRIDPlugin_HYBRID::storeErrorDescription(const TCollection_AsciiString& l ptr = getIds(ptr, TRIA, nodeIds); badElems.push_back( toSmdsConvertor.getElement(nodeIds)); { - vector edgeNodes( nodeIds.begin(), --nodeIds.end() ); // 01 + std::vector edgeNodes( nodeIds.begin(), --nodeIds.end() ); // 01 badElems.push_back( toSmdsConvertor.getElement(edgeNodes)); edgeNodes[1] = nodeIds[2]; // 02 badElems.push_back( toSmdsConvertor.getElement(edgeNodes)); @@ -3651,7 +3653,7 @@ bool HYBRIDPlugin_HYBRID::storeErrorDescription(const TCollection_AsciiString& l // even if all nodes found, volume it most probably invisible, // add its faces to demonstrate it anyhow { - vector faceNodes( nodeIds.begin(), --nodeIds.end() ); // 012 + std::vector faceNodes( nodeIds.begin(), --nodeIds.end() ); // 012 badElems.push_back( toSmdsConvertor.getElement(faceNodes)); faceNodes[2] = nodeIds[3]; // 013 badElems.push_back( toSmdsConvertor.getElement(faceNodes)); @@ -3687,7 +3689,7 @@ bool HYBRIDPlugin_HYBRID::storeErrorDescription(const TCollection_AsciiString& l badElems.push_back( toSmdsConvertor.getElement(nodeIds)); // add triangle edges as it most probably has zero area and hence invisible { - vector edgeNodes(2); + std::vector edgeNodes(2); edgeNodes[0] = nodeIds[0]; edgeNodes[1] = nodeIds[1]; // 0-1 badElems.push_back( toSmdsConvertor.getElement(edgeNodes)); edgeNodes[1] = nodeIds[2]; // 0-2 @@ -3704,7 +3706,7 @@ bool HYBRIDPlugin_HYBRID::storeErrorDescription(const TCollection_AsciiString& l break; } - bool isNewError = foundErrorStr.insert( string( errBeg, ptr )).second; + bool isNewError = foundErrorStr.insert( std::string( errBeg, ptr )).second; if ( !isNewError ) continue; // not to report same error several times @@ -3719,13 +3721,13 @@ bool HYBRIDPlugin_HYBRID::storeErrorDescription(const TCollection_AsciiString& l // store bad elements //if ( allElemsOk ) { - list::iterator elem = badElems.begin(); + std::list::iterator elem = badElems.begin(); for ( ; elem != badElems.end(); ++elem ) addBadInputElement( *elem ); //} // make error text - string text = translateError( errNum ); + std::string text = translateError( errNum ); if ( errDescription.find( text ) == text.npos ) { if ( !errDescription.empty() ) errDescription << "\n"; @@ -3737,13 +3739,13 @@ bool HYBRIDPlugin_HYBRID::storeErrorDescription(const TCollection_AsciiString& l if ( errDescription.empty() ) { // no errors found char msgLic1[] = "connection to server failed"; char msgLic2[] = " Dlim "; - if ( search( &buf[0], bufEnd, msgLic1, msgLic1 + strlen(msgLic1)) != bufEnd || - search( &buf[0], bufEnd, msgLic2, msgLic2 + strlen(msgLic2)) != bufEnd ) + if ( std::search( &buf[0], bufEnd, msgLic1, msgLic1 + strlen(msgLic1)) != bufEnd || + std::search( &buf[0], bufEnd, msgLic2, msgLic2 + strlen(msgLic2)) != bufEnd ) errDescription << "Licence problems."; else { char msg2[] = "SEGMENTATION FAULT"; - if ( search( &buf[0], bufEnd, msg2, msg2 + strlen(msg2)) != bufEnd ) + if ( std::search( &buf[0], bufEnd, msg2, msg2 + strlen(msg2)) != bufEnd ) errDescription << "hybrid: SEGMENTATION FAULT. "; } } @@ -3762,7 +3764,7 @@ bool HYBRIDPlugin_HYBRID::storeErrorDescription(const TCollection_AsciiString& l */ //================================================================================ -_Ghs2smdsConvertor::_Ghs2smdsConvertor( const map & ghs2NodeMap) +_Ghs2smdsConvertor::_Ghs2smdsConvertor( const std::map & ghs2NodeMap) :_ghs2NodeMap( & ghs2NodeMap ), _nodeByGhsId( 0 ) { } @@ -3773,7 +3775,7 @@ _Ghs2smdsConvertor::_Ghs2smdsConvertor( const map & g */ //================================================================================ -_Ghs2smdsConvertor::_Ghs2smdsConvertor( const vector & nodeByGhsId) +_Ghs2smdsConvertor::_Ghs2smdsConvertor( const std::vector & nodeByGhsId) : _ghs2NodeMap( 0 ), _nodeByGhsId( &nodeByGhsId ) { } @@ -3784,20 +3786,20 @@ _Ghs2smdsConvertor::_Ghs2smdsConvertor( const vector & n */ //================================================================================ -const SMDS_MeshElement* _Ghs2smdsConvertor::getElement(const vector& ghsNodes) const +const SMDS_MeshElement* _Ghs2smdsConvertor::getElement(const std::vector& ghsNodes) const { size_t nbNodes = ghsNodes.size(); - vector nodes( nbNodes, 0 ); + std::vector nodes( nbNodes, 0 ); for ( size_t i = 0; i < nbNodes; ++i ) { int ghsNode = ghsNodes[ i ]; if ( _ghs2NodeMap ) { - map ::const_iterator in = _ghs2NodeMap->find( ghsNode); + std::map ::const_iterator in = _ghs2NodeMap->find( ghsNode); if ( in == _ghs2NodeMap->end() ) return 0; nodes[ i ] = in->second; } else { - if ( ghsNode < 1 || ghsNode > _nodeByGhsId->size() ) + if ( ghsNode < 1 || ghsNode > (int)_nodeByGhsId->size() ) return 0; nodes[ i ] = (*_nodeByGhsId)[ ghsNode-1 ]; } diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID_i.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID_i.cxx index db65d8a..91b0c14 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID_i.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID_i.cxx @@ -101,7 +101,7 @@ SMESH::SMESH_Mesh_ptr HYBRIDPlugin_HYBRID_i::importGMFMesh(const char* theGMFFil #else #define SEP '/' #endif - string strFileName (theGMFFileName); + std::string strFileName (theGMFFileName); strFileName = strFileName.substr(strFileName.rfind(SEP)+1); strFileName.erase(strFileName.rfind('.')); smeshGen->SetName(theSMesh, strFileName.c_str()); diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx index 45051c2..7d70c42 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx @@ -817,8 +817,8 @@ bool HYBRIDPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, S const SMDS_MeshElement* elem; const SMDS_MeshNode* node; bool added = true; - pair nodeRet; - pair elemRet; + std::pair nodeRet; + std::pair elemRet; for (;it != theElemSet.end();++it) { @@ -829,7 +829,7 @@ bool HYBRIDPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, S if (node) { nodeRet = _enfNodes.insert(make_pair(node,groupName)); added = added && nodeRet.second; - string msg = added ? "yes":"no"; + std::string msg = added ? "yes":"no"; MESSAGE( "Node (" <X()<<","<Y()<<","<Z()<< ") with ID " << node->GetID() <<" added ? " << msg); } else { diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx index ff11146..c66664a 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx @@ -242,7 +242,7 @@ void HYBRIDPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SA if (!path ) THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM ); - string file(path); + std::string file(path); const char lastChar = *file.rbegin(); #ifdef WIN32 if ( lastChar != '\\' ) file += '\\'; @@ -681,13 +681,13 @@ bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theV THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } - string theVertexEntry = theVertex->GetStudyEntry(); + std::string theVertexEntry = theVertex->GetStudyEntry(); CORBA::Double x = 0, y = 0, z = 0; CORBA::Boolean isCompound = false; GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); if (theVertexEntry.empty()) { - string aName; + std::string aName; if (theVertex->GetShapeType() == GEOM::VERTEX) { aName = "Vertex_"; } @@ -712,7 +712,7 @@ bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theV MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z); } - string theVertexName = theVertex->GetName(); + std::string theVertexName = theVertex->GetName(); MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")"); return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound); @@ -727,13 +727,13 @@ bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } - string theVertexEntry = theVertex->GetStudyEntry(); + std::string theVertexEntry = theVertex->GetStudyEntry(); CORBA::Double x = 0, y = 0, z = 0; CORBA::Boolean isCompound = false; GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); if (theVertexEntry.empty()) { - string aName; + std::string aName; if (theVertex->GetShapeType() == GEOM::VERTEX) { aName = "Vertex_"; } @@ -758,7 +758,7 @@ bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z); } - string theVertexName = theVertex->GetName(); + std::string theVertexName = theVertex->GetName(); MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")"); return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound); @@ -774,7 +774,7 @@ bool HYBRIDPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA:: ::HYBRIDPlugin_Hypothesis::TCoordsHYBRIDEnforcedVertexMap coordsList; ::HYBRIDPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap enfVertexEntryList; - if (string(theVertexEntry).empty()) { + if (std::string(theVertexEntry).empty()) { coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords(); std::vector coords; coords.push_back(x); @@ -798,14 +798,14 @@ bool HYBRIDPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA:: } if (newValue) { - if (string(theVertexName).empty()) { - if (string(theGroupName).empty()) + if (std::string(theVertexName).empty()) { + if (std::string(theGroupName).empty()) SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")"; else SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")"; } else { - if (string(theGroupName).empty()) + if (std::string(theGroupName).empty()) SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")"; else SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")"; @@ -813,7 +813,7 @@ bool HYBRIDPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA:: } } else { -// if (isCompound || (!isCompound && !string(theVertexEntry).empty())) { +// if (isCompound || (!isCompound && !std::string(theVertexEntry).empty())) { enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry(); // ::BLSURFPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry); if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) { @@ -834,7 +834,7 @@ bool HYBRIDPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA:: } if (newValue) { - if (string(theGroupName).empty()) + if (std::string(theGroupName).empty()) SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")"; else SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")"; @@ -888,11 +888,11 @@ CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } - string theVertexEntry = theVertex->GetStudyEntry(); + std::string theVertexEntry = theVertex->GetStudyEntry(); if (theVertexEntry.empty()) { GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); - string aName; + std::string aName; if (theVertex->GetShapeType() == GEOM::VERTEX) aName = "Vertex_"; if (theVertex->GetShapeType() == GEOM::COMPOUND) @@ -905,7 +905,7 @@ CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object if (theVertexEntry.empty()) THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); - string theVertexName = theVertex->GetName(); + std::string theVertexName = theVertex->GetName(); try { bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size; @@ -949,7 +949,7 @@ HYBRIDPlugin::HYBRIDEnforcedVertexList* HYBRIDPlugin_Hypothesis_i::GetEnforcedVe // Coords HYBRIDPlugin::TCoords_var coords = new HYBRIDPlugin::TCoords(); coords->length(currentVertex->coords.size()); - for (int ind = 0; ind < currentVertex->coords.size(); ind++) + for (size_t ind = 0; ind < currentVertex->coords.size(); ind++) coords[ind] = currentVertex->coords[ind]; enfVertex->coords = coords; // Group Name @@ -1003,11 +1003,11 @@ bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr t THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } - string theVertexEntry = theVertex->GetStudyEntry(); + std::string theVertexEntry = theVertex->GetStudyEntry(); if (theVertexEntry.empty()) { GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); - string aName; + std::string aName; if (theVertex->GetShapeType() == GEOM::VERTEX) aName = "Vertex_"; if (theVertex->GetShapeType() == GEOM::COMPOUND) @@ -1200,7 +1200,7 @@ bool HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theS // MESSAGE("Required type is "<GetTypes(); MESSAGE("Available types:"); - for (int i=0;ilength();i++){MESSAGE(types[i]);} + for (CORBA::ULong i=0;ilength();i++){MESSAGE(types[i]);} if ( types->length() >= 1 && types[types->length()-1] < theType) { MESSAGE("Required type not available"); @@ -1212,7 +1212,7 @@ bool HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theS // ExDescription.lineNumber = 840; // throw SALOME::SALOME_Exception(ExDescription); } - + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource); @@ -1221,22 +1221,22 @@ bool HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theS SMESH_Group_i* theGroup_i = SMESH::DownCast( theSource); SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast( theSource); - string enfMeshName = theName; + std::string enfMeshName = theName; if (enfMeshName.empty()) - enfMeshName = SObj->GetName(); + enfMeshName = SObj->GetName(); if (theMesh_i) { try { - bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName); - if (theGroupName != "") { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " - << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )"; - } - else { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " - << theSource << ".GetMesh(), " << theType << " )"; - } + bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName); + if (theGroupName && theGroupName[0]) { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " + << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )"; + } + else { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " + << theSource << ".GetMesh(), " << theType << " )"; + } return res; } @@ -1257,7 +1257,7 @@ bool HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theS MESSAGE("The source is a group") try { bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName); - if (theGroupName != "") { + if (theGroupName && theGroupName[0]) { SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; } @@ -1282,20 +1282,20 @@ bool HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theS else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType) { MESSAGE("The source is a group on geom") - try { + try { bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName); - if (theGroupName != "") { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " + if (theGroupName && theGroupName[0]) { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; } else { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " << theSource << ", " << theType << " )"; } - return res; - } - catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; + return res; + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx"; -- 2.39.2