#define HOLE_ID -1
-typedef const list<const SMDS_MeshFace*> TTriaList;
+typedef const std::list<const SMDS_MeshFace*> TTriaList;
static const char theDomainGroupNamePrefix[] = "Domain_";
_removeLogOnSuccess = true;
_logInStandardOutput = false;
- const list <const SMESHDS_Hypothesis * >& hyps =
+ const std::list <const SMESHDS_Hypothesis * >& hyps =
GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliary=*/false);
- list <const SMESHDS_Hypothesis* >::const_iterator h = hyps.begin();
+ std::list <const SMESHDS_Hypothesis* >::const_iterator h = hyps.begin();
for ( ; h != hyps.end(); ++h )
{
if ( !_hyp )
//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; j<nbNode; j++ ) {
- gp_XYZ p ( aNode[j]->X(), 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; j<nbNode; j++ ) {
+// gp_XYZ p ( aNode[j]->X(), 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;
+// }
//================================================================================
/*!
SMESHDS_Mesh* meshDS = mesh.GetMeshDS();
// face the nodes belong to
- vector<const SMDS_MeshNode *> nodes(3);
+ std::vector<const SMDS_MeshNode *> nodes(3);
nodes[0] = node1;
nodes[1] = node2;
nodes[2] = node3;
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())
SMESH_MesherHelper* theHelper,
std::vector <const SMDS_MeshNode*> & theNodeByHybridId,
std::vector <const SMDS_MeshElement*> & theFaceByHybridId,
- map<const SMDS_MeshNode*,int> & theNodeToHybridIdMap,
+ std::map<const SMDS_MeshNode*,int> & theNodeToHybridIdMap,
std::vector<std::string> & aNodeGroupByHybridId,
std::vector<std::string> & anEdgeGroupByHybridId,
std::vector<std::string> & aFaceGroupByHybridId,
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
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),
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;
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);
}
}
} // loop on elements of one type
break;
} // case ...
+
+ default:;
} // switch (token)
} // loop on tabRef
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;
TIDSortedElemSet anElemSet, theKeptEnforcedEdges, theKeptEnforcedTriangles;
SMDS_ElemIteratorPtr nodeIt;
std::vector <const SMDS_MeshNode*> theEnforcedNodeByHybridId;
- map<const SMDS_MeshNode*,int> anEnforcedNodeToHybridIdMap, anExistingEnforcedNodeToHybridIdMap;
+ std::map<const SMDS_MeshNode*,int> anEnforcedNodeToHybridIdMap, anExistingEnforcedNodeToHybridIdMap;
std::vector< const SMDS_MeshElement* > foundElems;
- map<const SMDS_MeshNode*,TopAbs_State> aNodeToTopAbs_StateMap;
+ std::map<const SMDS_MeshNode*,TopAbs_State> 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();
// 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 ));
}
}
isOK = false;
break;
}
- aNodeToTopAbs_StateMap.insert( make_pair( node, result ));
+ aNodeToTopAbs_StateMap.insert( std::make_pair( node, result ));
}
if (isOK) {
nodeIt = elem->nodesIterator();
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;
isOK = false;
break;
}
- aNodeToTopAbs_StateMap.insert( make_pair( node, result ));
+ aNodeToTopAbs_StateMap.insert( std::make_pair( node, result ));
}
if (isOK) {
nodeIt = elem->nodesIterator();
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;
std::cout << "aNodeToHybridIdMap.size(): "<<aNodeToHybridIdMap.size()<<std::endl;
#endif
theNodeByHybridId.resize( aNodeToHybridIdMap.size() );
- map<const SMDS_MeshNode*,int>::const_iterator n2id = aNodeToHybridIdMap.begin();
+ std::map<const SMDS_MeshNode*,int>::const_iterator n2id = aNodeToHybridIdMap.begin();
for ( ; n2id != aNodeToHybridIdMap.end(); ++ n2id)
{
// std::cout << "n2id->first: "<<n2id->first<<std::endl;
n2id = anEnforcedNodeToHybridIdMap.begin();
for ( ; n2id != anEnforcedNodeToHybridIdMap.end(); ++ n2id)
{
- if (n2id->second > aNodeToHybridIdMap.size()) {
+ if (n2id->second > (int)aNodeToHybridIdMap.size()) {
theEnforcedNodeByHybridId[ n2id->second - aNodeToHybridIdMap.size() - 1 ] = n2id->first; // hybrid ids count from 1
}
}
//========================== NODES ==========================
- vector<const SMDS_MeshNode*> theOrderedNodes, theRequiredNodes;
+ std::vector<const SMDS_MeshNode*> theOrderedNodes, theRequiredNodes;
std::set< std::vector<double> > nodesCoords;
- vector<const SMDS_MeshNode*>::const_iterator hybridNodeIt = theNodeByHybridId.begin();
- vector<const SMDS_MeshNode*>::const_iterator after = theNodeByHybridId.end();
+ std::vector<const SMDS_MeshNode*>::const_iterator hybridNodeIt = theNodeByHybridId.begin();
+ std::vector<const SMDS_MeshNode*>::const_iterator after = theNodeByHybridId.end();
(theNodeByHybridId.size() <= 1) ? tmpStr = " node" : " nodes";
std::cout << theNodeByHybridId.size() << tmpStr << " from mesh ..." << std::endl;
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())
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;
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())
// {
// SMDS_NodeIteratorPtr nIt = smDS->GetNodes();
// while ( nIt->more() )
-// n2nDegen.insert( make_pair( nIt->next(), vNode ));
+// n2nDegen.insert( std::make_pair( nIt->next(), vNode ));
// }
// }
// }
// 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 ));
// }
//
//
// VerTab.push_back(coords);
// VerMap.insert(coords);
// aHybridID++;
-// theNodeId2NodeIndexMap.insert( make_pair( (*enfNodeIt)->GetID(), aHybridID ));
+// theNodeId2NodeIndexMap.insert( std::make_pair( (*enfNodeIt)->GetID(), aHybridID ));
// }
// }
//
// 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)
// 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)
//purpose :
//=======================================================================
-static bool writeFaces (ofstream & theFile,
- const SMESH_ProxyMesh& theMesh,
- const TopoDS_Shape& theShape,
- const map <int,int> & theSmdsToHybridIdMap,
- const map <int,int> & 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<int,int>::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 <int,int> & theSmdsToHybridIdMap,
+// const std::map <int,int> & 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<int,int>::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 <int,int> & theSmdsToHybridIdMap,
- map <int,int> & theEnforcedNodeIdToHybridIdMap,
- map <int,const SMDS_MeshNode*> & 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 <int,int> & theSmdsToHybridIdMap,
+// std::map <int,int> & theEnforcedNodeIdToHybridIdMap,
+// std::map <int,const SMDS_MeshNode*> & 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<int> 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<int> 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<int,double> 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<double> 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<int,double> 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<double> 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 <int,const SMDS_MeshNode*>& theHybridIdToNodeMap,
- std::map <int,int> & 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 <int,const SMDS_MeshNode*>& theHybridIdToNodeMap,
+// std::map <int,int> & 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 <int,const SMDS_MeshNode*>::iterator itOnNode;
+// SMDS_MeshElement* aTet;
+// #ifdef _DEBUG_
+// std::set<int> 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 <int,const SMDS_MeshNode*>::iterator itOnNode;
- SMDS_MeshElement* aTet;
-#ifdef _DEBUG_
- set<int> 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: "<<nbInputNodes);
+// MESSAGE("nbEnforcedVertices: "<<nbEnforcedVertices);
+// MESSAGE("nbEnforcedNodes: "<<nbEnforcedNodes);
+// // Reading the nodeCoor and update the nodeMap
+// for (int iNode=1; iNode <= nbNodes; iNode++) {
+// if(theAlgo->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: "<<nbInputNodes);
- MESSAGE("nbEnforcedVertices: "<<nbEnforcedVertices);
- MESSAGE("nbEnforcedNodes: "<<nbEnforcedNodes);
- // Reading the nodeCoor and update the nodeMap
- for (int iNode=1; iNode <= nbNodes; iNode++) {
- if(theAlgo->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<int,int>::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<int,int>::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; i<nbShape; i++) {
- shapeID = theMeshDS->ShapeToIndex( 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; i<nbShape; i++) {
+// shapeID = theMeshDS->ShapeToIndex( tabShape[i] );
+// if ( shapeIDs.find( shapeID ) == shapeIDs.end() )
+// std::cout << " Solid #" << shapeID << " not found" << std::endl;
+// }
+// }
+// #endif
- return true;
-}
+// return true;
+// }
//=============================================================================
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(("<<enfVertex->coords[0]<<","<<enfVertex->coords[1]<<","<<enfVertex->coords[2]<<"),\""<<enfVertex->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(("<<enfVertex->coords[0]<<","<<enfVertex->coords[1]<<","<<enfVertex->coords[2]<<"),\""<<enfVertex->groupName<<"\"))");
}
else {
// if (!enfVertex->geomEntry.empty()) {
// 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));
// }
// }
//
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(("<<coords[0]<<","<<coords[1]<<","<<coords[2]<<"),\""<<enfVertex->groupName<<"\"))");
+ coordsSizeMap.insert(std::make_pair(coords,enfVertex->size));
+ enfVerticesWithGroup.insert(std::make_pair(coords,enfVertex->groupName));
+// MESSAGE("enfVerticesWithGroup.insert(std::make_pair(("<<coords[0]<<","<<coords[1]<<","<<coords[2]<<"),\""<<enfVertex->groupName<<"\"))");
}
}
}
// make prisms on quadrangles
if ( theMesh.NbQuadrangles() > 0 )
{
- vector<SMESH_ProxyMesh::Ptr> components;
+ std::vector<SMESH_ProxyMesh::Ptr> components;
for (expBox.ReInit(); expBox.More(); expBox.Next())
{
if ( _viscousLayersHyp )
}
INFOS( "Writing ids relation into " << aSmdsToHybridIdMapFileName);
aIdsFile << "Smds Hybrid" << std::endl;
- map <int,int>::const_iterator myit;
+ std::map <int,int>::const_iterator myit;
for (myit=aSmdsToHybridIdMap.begin() ; myit != aSmdsToHybridIdMap.end() ; ++myit) {
aIdsFile << myit->first << " " << myit->second << std::endl;
}
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(("<<enfVertex->coords[0]<<","<<enfVertex->coords[1]<<","<<enfVertex->coords[2]<<"),\""<<enfVertex->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(("<<enfVertex->coords[0]<<","<<enfVertex->coords[1]<<","<<enfVertex->coords[2]<<"),\""<<enfVertex->groupName<<"\"))");
}
else {
// if (!enfVertex->geomEntry.empty()) {
// 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));
// }
// }
//
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(("<<coords[0]<<","<<coords[1]<<","<<coords[2]<<"),\""<<enfVertex->groupName<<"\"))");
+ coordsSizeMap.insert(std::make_pair(coords,enfVertex->size));
+ enfVerticesWithGroup.insert(std::make_pair(coords,enfVertex->groupName));
+// MESSAGE("enfVerticesWithGroup.insert(std::make_pair(("<<coords[0]<<","<<coords[1]<<","<<coords[2]<<"),\""<<enfVertex->groupName<<"\"))");
}
}
}
// 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));
// }
*/
//================================================================================
-static char* getIds( char* ptr, int nbIds, vector<int>& ids )
+static char* getIds( char* ptr, int nbIds, std::vector<int>& ids )
{
ids.clear();
ids.reserve( nbIds );
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];
// look for errors "ERR #"
- set<string> foundErrorStr; // to avoid reporting same error several times
- set<int> elemErrorNums; // not to report different types of errors with bad elements
+ std::set<std::string> foundErrorStr; // to avoid reporting same error several times
+ std::set<int> elemErrorNums; // not to report different types of errors with bad elements
while ( ++ptr < bufEnd )
{
if ( strncmp( ptr, "ERR ", 4 ) != 0 )
continue;
- list<const SMDS_MeshElement*> badElems;
- vector<int> nodeIds;
+ std::list<const SMDS_MeshElement*> badElems;
+ std::vector<int> nodeIds;
ptr += 4;
char* errBeg = ptr;
ptr = getIds(ptr, TRIA, nodeIds);
badElems.push_back( toSmdsConvertor.getElement(nodeIds));
{
- vector<int> edgeNodes( nodeIds.begin(), --nodeIds.end() ); // 01
+ std::vector<int> edgeNodes( nodeIds.begin(), --nodeIds.end() ); // 01
badElems.push_back( toSmdsConvertor.getElement(edgeNodes));
edgeNodes[1] = nodeIds[2]; // 02
badElems.push_back( toSmdsConvertor.getElement(edgeNodes));
// even if all nodes found, volume it most probably invisible,
// add its faces to demonstrate it anyhow
{
- vector<int> faceNodes( nodeIds.begin(), --nodeIds.end() ); // 012
+ std::vector<int> faceNodes( nodeIds.begin(), --nodeIds.end() ); // 012
badElems.push_back( toSmdsConvertor.getElement(faceNodes));
faceNodes[2] = nodeIds[3]; // 013
badElems.push_back( toSmdsConvertor.getElement(faceNodes));
badElems.push_back( toSmdsConvertor.getElement(nodeIds));
// add triangle edges as it most probably has zero area and hence invisible
{
- vector<int> edgeNodes(2);
+ std::vector<int> edgeNodes(2);
edgeNodes[0] = nodeIds[0]; edgeNodes[1] = nodeIds[1]; // 0-1
badElems.push_back( toSmdsConvertor.getElement(edgeNodes));
edgeNodes[1] = nodeIds[2]; // 0-2
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
// store bad elements
//if ( allElemsOk ) {
- list<const SMDS_MeshElement*>::iterator elem = badElems.begin();
+ std::list<const SMDS_MeshElement*>::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";
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. ";
}
}
*/
//================================================================================
-_Ghs2smdsConvertor::_Ghs2smdsConvertor( const map <int,const SMDS_MeshNode*> & ghs2NodeMap)
+_Ghs2smdsConvertor::_Ghs2smdsConvertor( const std::map <int,const SMDS_MeshNode*> & ghs2NodeMap)
:_ghs2NodeMap( & ghs2NodeMap ), _nodeByGhsId( 0 )
{
}
*/
//================================================================================
-_Ghs2smdsConvertor::_Ghs2smdsConvertor( const vector <const SMDS_MeshNode*> & nodeByGhsId)
+_Ghs2smdsConvertor::_Ghs2smdsConvertor( const std::vector <const SMDS_MeshNode*> & nodeByGhsId)
: _ghs2NodeMap( 0 ), _nodeByGhsId( &nodeByGhsId )
{
}
*/
//================================================================================
-const SMDS_MeshElement* _Ghs2smdsConvertor::getElement(const vector<int>& ghsNodes) const
+const SMDS_MeshElement* _Ghs2smdsConvertor::getElement(const std::vector<int>& ghsNodes) const
{
size_t nbNodes = ghsNodes.size();
- vector<const SMDS_MeshNode*> nodes( nbNodes, 0 );
+ std::vector<const SMDS_MeshNode*> nodes( nbNodes, 0 );
for ( size_t i = 0; i < nbNodes; ++i ) {
int ghsNode = ghsNodes[ i ];
if ( _ghs2NodeMap ) {
- map <int,const SMDS_MeshNode*>::const_iterator in = _ghs2NodeMap->find( ghsNode);
+ std::map <int,const SMDS_MeshNode*>::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 ];
}