return true;
}
+#if GHS3D_VERSION < 42
//=======================================================================
//function : findShape
//purpose :
}
return ptr;
}
-
+#endif
//=======================================================================
//function : countShape
//purpose :
// return nbShape;
// }
+#if GHS3D_VERSION >= 42
//=======================================================================
//function : readGMFFile
//purpose :
if ( nbFaces == 0 )
return false;
- idx = GmfOpenMesh(theMeshFileName, GmfWrite, 3, 3);
+ idx = GmfOpenMesh(theMeshFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
if (!idx)
return false;
std::cout << "End writting required vertices in GmfRequiredVertices" << std::endl;
std::cout << "Begin writting in sol file" << std::endl;
- idxSol = GmfOpenMesh(theSolFileName, GmfWrite, 3, 3);
+ idxSol = GmfOpenMesh(theSolFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
if (!idxSol) {
GmfCloseMesh(idx);
if (idxRequired)
// if (solSize) {
// std::cout << "Begin writting in sol file" << std::endl;
// GmfSetKwd(idx, GmfRequiredVertices, solSize);
-// idxSol = GmfOpenMesh(theSolFileName, GmfWrite, 3, 3);
+// idxSol = GmfOpenMesh(theSolFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
// if (!idxSol) {
// GmfCloseMesh(idx);
// if (idxRequired)
int usedEnforcedEdges = 0;
if (anEnforcedEdgeSet.size()) {
-// idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, 3, 3);
+// idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
// if (!idxRequired)
// return false;
GmfSetKwd(idx, GmfEdges, anEnforcedEdgeSet.size());
SMDS_NodeIteratorPtr nodeIt;
std::map<int,int> theNodeId2NodeIndexMap;
- idx = GmfOpenMesh(theMeshFileName, GmfWrite, 3, 3);
+ idx = GmfOpenMesh(theMeshFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
if (!idx)
return false;
}
if (solSize) {
- int idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, 3, 3);
+ int idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
if (!idxRequired)
return false;
- int idxSol = GmfOpenMesh(theSolFileName, GmfWrite, 3, 3);
+ int idxSol = GmfOpenMesh(theSolFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
if (!idxSol)
return false;
return true;
}
-/*
-static bool writeGMFHeader (ofstream &theFile,
- int thePrecision)
-{
- theFile << "MeshVersionFormatted " << thePrecision << std::endl;
- theFile << std::endl;
- theFile << "Dimension" << std::endl;
- theFile << "3" << std::endl;
- theFile << std::endl;
- return true;
-}
-
-static bool writeGMFEnd (ofstream &theFile)
-{
- theFile << std::endl;
- theFile << "End" << std::endl;
- return true;
-}
-
-static bool writeGMFVertices (ofstream & theFile,
- ofstream & theSolFile,
- SMESH_MesherHelper& theHelper,
- map <int,int> & theSmdsToGhs3dIdMap,
- map <int,const SMDS_MeshNode*> & theGhs3dIdToNodeMap,
- GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices,
- TIDSortedNodeSet & theEnforcedNodes,
- std::map <int,int>& theNodeId2NodeIndexMap)
-{
- SMESHDS_Mesh * theMeshDS = theHelper.GetMeshDS();
- // NB_NODES
- int nbNodes = theMeshDS->NbNodes();
- if ( nbNodes == 0 )
- return false;
- int nbEnforcedVertices = theEnforcedVertices.size();
- int nbEnforcedNodes = theEnforcedNodes.size();
-
- // Issue 020674: EDF 870 SMESH: Mesh generated by Netgen not usable by GHS3D
- // The problem is in nodes on degenerated edges, we need to skip them
- if ( theHelper.HasDegeneratedEdges() )
- {
- // here we decrease total nb of nodes by nb of nodes on degenerated edges
- 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 ( sm->GetSubMeshDS() )
- nbNodes -= sm->GetSubMeshDS()->NbNodes();
- }
- }
- }
- const char* space = " ";
- const int dummyint = 0;
-
- int aGhs3dID = 1;
- SMDS_NodeIteratorPtr it = theMeshDS->nodesIterator();
- const SMDS_MeshNode* node;
-
-
- std::cout << std::endl;
- std::cout << "The initial 2D mesh contains :" << std::endl;
- std::cout << " " << nbNodes << " nodes" << std::endl;
- if (nbEnforcedVertices > 0)
- std::cout << " " << nbEnforcedVertices << " enforced vertices" << std::endl;
- if (nbEnforcedNodes > 0)
- std::cout << " " << nbEnforcedNodes << " enforced nodes" << std::endl;
-// std::cout << "Start writing vertices in 'mesh' file ..." << std::endl;
- theFile << "Vertices" << std::endl;
- theFile << nbNodes+nbEnforcedVertices+nbEnforcedNodes << std::endl;
-
- // Loop from 1 to NB_NODES
-
- while ( it->more() )
- {
- node = it->next();
- if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_EDGE &&
- theHelper.IsDegenShape( node->getshapeId() )) // Issue 020674
- continue;
-
- theSmdsToGhs3dIdMap.insert( make_pair( node->GetID(), aGhs3dID ));
- theGhs3dIdToNodeMap.insert( make_pair( aGhs3dID, node ));
- aGhs3dID++;
-
- // X Y Z DUMMY_INT
- theFile
- << node->X() << space
- << node->Y() << space
- << node->Z() << space
- << dummyint << space ;
- theFile << std::endl;
- }
-
- // Iterate over the enforced vertices
- GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
- const TopoDS_Shape shapeToMesh = theMeshDS->ShapeToMesh();
- std::map<int,double> enfVertexIndexSizeMap;
- int i = 1;
- for(vertexIt = theEnforcedVertices.begin() ; 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 ) {
-// MESSAGE("Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second);
- // X Y Z PHY_SIZE DUMMY_INT
- theFile
- << x << space
- << y << space
- << z << space
- << dummyint << space;
- theFile << std::endl;
- enfVertexIndexSizeMap[nbNodes + i] = vertexIt->second;
- i++;
- }
-// else
-// MESSAGE("Enforced vertex (" << x << "," << y <<"," << z << ") is not inside the geometry: it was not added ");
- }
- nbNodes = nbNodes + enfVertexIndexSizeMap.size()-1;
-
- // Iterate over the enforced nodes
- TIDSortedNodeSet::const_iterator nodeIt;
- int usedEnforcedNodes = 0;
- for(nodeIt = theEnforcedNodes.begin() ; nodeIt != theEnforcedNodes.end() ; ++nodeIt) {
- double x = (*nodeIt)->X();
- double y = (*nodeIt)->Y();
- double z = (*nodeIt)->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 ) {
-// MESSAGE("Adding enforced node (" << x << "," << y <<"," << z << ")");
- // X Y Z PHY_SIZE DUMMY_INT
- theFile
- << x << space
- << y << space
- << z << space
- << dummyint << space;
- theFile << std::endl;
- enfVertexIndexSizeMap[nbNodes + i] = -1;
- theNodeId2NodeIndexMap.insert( make_pair( (*nodeIt)->GetID(), nbNodes + i ));
- i++;
- usedEnforcedNodes++;
- }
-// else
-// MESSAGE("Enforced vertex (" << x << "," << y <<"," << z << ") is not inside the geometry: it was not added ");
- }
- theFile << std::endl;
-// std::cout << std::endl;
-// std::cout << "End writing vertices in 'mesh' file." << std::endl;
-
- if (!nbEnforcedVertices)
- return true;
-
-// std::cout << "Start writing required vertices in 'mesh' file ..." << std::endl;
- writeGMFHeader(theSolFile, 1);
- theSolFile << "SolAtVertices" << std::endl;
- theSolFile << enfVertexIndexSizeMap.size()-usedEnforcedNodes << std::endl;
- theSolFile << "1 1" << std::endl;
- theFile << std::endl;
- theFile << "RequiredVertices" << std::endl;
- theFile << enfVertexIndexSizeMap.size() << std::endl;
- for (std::map<int,double>::const_iterator it = enfVertexIndexSizeMap.begin();it != enfVertexIndexSizeMap.end();++it) {
- theFile << it->first << std::endl;
- if (it->second != -1)
- theSolFile << it->second << std::endl;
- }
- theFile << std::endl;
- theSolFile << std::endl;
- writeGMFEnd(theSolFile);
-// std::cout << "End writing required vertices in 'mesh' file." << std::endl;
-
- return true;
-}
-
-static bool writeGMFFaces (ofstream & theFile,
- const SMESH_ProxyMesh& theMesh,
- const TopoDS_Shape& theShape,
- const map <int,int> & theSmdsToGhs3dIdMap,
- TIDSortedElemSet & theEnforcedEdges,
- TIDSortedElemSet & theEnforcedTriangles,
- TIDSortedElemSet & theEnforcedQuadrangles,
- std::map <int,int>& theNodeId2NodeIndexMap)
-{
- // record structure:
- //
- // NB_ELEMS DUMMY_INT
- // Loop from 1 to NB_ELEMS
- // NB_NODES NODE_NB_1 NODE_NB_2 ... 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 aSmdsID, aNodeID;
-
- TIDSortedElemSet::const_iterator elemIt;
- int nbEnforcedEdges = theEnforcedEdges.size();
- int nbEnforcedTriangles = theEnforcedTriangles.size();
- int nbEnforcedQuadrangles = theEnforcedQuadrangles.size();
- // count triangles bound to geometry
- int nbTriangles = 0;
- int nbQuadrangles = 0;
- ostringstream aStream,aLocalStream;
- aStream.clear();
- aLocalStream.clear();
-
- TopTools_IndexedMapOfShape facesMap, trianglesMap, quadranglesMap;
- TopExp::MapShapes( theShape, TopAbs_FACE, facesMap );
-
- for ( int i = 1; i <= facesMap.Extent(); ++i )
- if (( theSubMesh = theMesh.GetSubMesh( facesMap(i))))
- {
- SMDS_ElemIteratorPtr it = theSubMesh->GetElements();
- while (it->more())
- {
- const SMDS_MeshElement *elem = it->next();
- if (elem->NbNodes() == 3)
- {
- trianglesMap.Add(facesMap(i));
- nbTriangles ++;
- }
- else if (elem->NbNodes() == 4)
- {
- quadranglesMap.Add(facesMap(i));
- nbQuadrangles ++;
- }
- }
- }
-
- std::cout << " " << facesMap.Extent() << " shapes of 2D dimension:" << std::endl;
- std::cout << " " << nbTriangles << " triangles" << std::endl;
- std::cout << " " << nbQuadrangles << " quadrangles" << std::endl;
- if (nbEnforcedEdges) {
- std::cout << " " << nbEnforcedEdges+nbEnforcedTriangles+nbEnforcedQuadrangles
- << " enforced shapes:" << std::endl;
- std::cout << " " << nbEnforcedEdges << " enforced edges" << std::endl;
- }
- if (nbEnforcedTriangles)
- std::cout << " " << nbEnforcedTriangles << " enforced triangles" << std::endl;
- if (nbEnforcedQuadrangles)
- std::cout << " " << nbEnforcedQuadrangles << " enforced quadrangles" << std::endl;
- std::cout << std::endl;
-
- //
- // EDGES : BEGIN
- //
-
-// std::cout << "Start writing edges in 'mesh' file ..." << std::endl;
-
- // 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.clear();
- while ( itOnSubFace->more() ) {
- aNodeID = itOnSubFace->next()->GetID();
- itOnMap = theNodeId2NodeIndexMap.find(aNodeID);
- if (itOnMap != theNodeId2NodeIndexMap.end())
- aStream << (*itOnMap).second << space;
- else {
- isOK = false;
- break;
- }
- }
- if (isOK) {
- aLocalStream << aStream.str() << dummyint << std::endl;
- usedEnforcedEdges++;
- }
- }
-
- if (usedEnforcedEdges) {
- theFile << std::endl;
- theFile << "Edges" << std::endl;
- theFile << usedEnforcedEdges << std::endl;
- theFile << aLocalStream.str();
- aLocalStream.clear();
-
- theFile << std::endl;
- theFile << "RequiredEdges" << std::endl;
- theFile << usedEnforcedEdges << std::endl;
-
- // Iterate over the enforced edges
- for (int i=0;i<usedEnforcedEdges;i++)
- theFile << i+1 << std::endl;
-
- theFile << std::endl;
- }
-
- //
- // EDGES : END
- //
-
- //
- // TRIANGLES : BEGIN
- //
-// std::cout << "Start writing triangles in 'mesh' file ..." << std::endl;
-
- for ( int i = 1; i <= trianglesMap.Extent(); i++ )
- {
- aShape = trianglesMap(i);
- theSubMesh = theMesh.GetSubMesh(aShape);
- if ( !theSubMesh ) continue;
- itOnSubMesh = theSubMesh->GetElements();
- while ( itOnSubMesh->more() )
- {
- aFace = itOnSubMesh->next();
- if (aFace->NbNodes() != 3)
- continue;
-
- itOnSubFace = aFace->nodesIterator();
- while ( itOnSubFace->more() ) {
- // find GHS3D ID
- aSmdsID = itOnSubFace->next()->GetID();
- itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
- // if ( itOnMap == theSmdsToGhs3dIdMap.end() ) {
- // cout << "not found node: " << aSmdsID << endl;
- // return false;
- // }
- ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
-
- aLocalStream << (*itOnMap).second << space;
- }
- aLocalStream << dummyint << std::endl;
- }
- }
-
- // Iterate over the enforced triangles
- int usedEnforcedTriangles = 0;
- for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) {
- aFace = (*elemIt);
- isOK = true;
- itOnSubFace = aFace->nodesIterator();
- aStream.clear();
- while ( itOnSubFace->more() ) {
- aNodeID = itOnSubFace->next()->GetID();
- itOnMap = theNodeId2NodeIndexMap.find(aNodeID);
- if (itOnMap != theNodeId2NodeIndexMap.end())
- aStream << (*itOnMap).second << space;
- else {
- isOK = false;
- break;
- }
- }
- if (isOK) {
- aLocalStream << aStream.str() << dummyint << std::endl;
- usedEnforcedTriangles++;
- }
- }
- if (nbTriangles+usedEnforcedTriangles) {
- theFile << std::endl;
- theFile << "Triangles" << std::endl;
- theFile << nbTriangles+usedEnforcedTriangles << std::endl;
- theFile << aLocalStream.str();
- aLocalStream.clear();
-
- theFile << std::endl;
- }
-
- //
- // TRIANGLES : END
- //
-
- //
- // QUADRANGLES : BEGIN
- //
-
-// std::cout << "Start writing quadrangles in 'mesh' file ..." << std::endl;
-
- for ( int i = 1; i <= quadranglesMap.Extent(); i++ )
- {
- aShape = quadranglesMap(i);
- theSubMesh = theMesh.GetSubMesh(aShape);
- if ( !theSubMesh ) continue;
- itOnSubMesh = theSubMesh->GetElements();
- while ( itOnSubMesh->more() )
- {
- aFace = itOnSubMesh->next();
- if (aFace->NbNodes() != 4)
- continue;
-
- itOnSubFace = aFace->nodesIterator();
- while ( itOnSubFace->more() ) {
- // find GHS3D ID
- aSmdsID = itOnSubFace->next()->GetID();
- itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
- // if ( itOnMap == theSmdsToGhs3dIdMap.end() ) {
- // cout << "not found node: " << aSmdsID << endl;
- // return false;
- // }
- ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
-
- aLocalStream << (*itOnMap).second << space;
- }
- aLocalStream << dummyint << std::endl;
- }
- }
-
- // Iterate over the enforced quadrangles
- int usedEnforcedQuadrangles = 0;
- for(elemIt = theEnforcedQuadrangles.begin() ; elemIt != theEnforcedQuadrangles.end() ; ++elemIt) {
- aFace = (*elemIt);
- isOK = true;
- itOnSubFace = aFace->nodesIterator();
- aStream.clear();
- while ( itOnSubFace->more() ) {
- aNodeID = itOnSubFace->next()->GetID();
- itOnMap = theNodeId2NodeIndexMap.find(aNodeID);
- if (itOnMap != theNodeId2NodeIndexMap.end())
- aStream << (*itOnMap).second << space;
- else {
- isOK = false;
- break;
- }
- }
- if (isOK) {
- aLocalStream << aStream.str() << dummyint << std::endl;
- usedEnforcedQuadrangles++;
- }
- }
- if (nbQuadrangles+usedEnforcedQuadrangles) {
- theFile << std::endl;
- theFile << "Quadrilaterals" << std::endl;
- theFile << nbQuadrangles+usedEnforcedQuadrangles << std::endl;
- theFile << aLocalStream.str();
- aLocalStream.clear();
-
- theFile << std::endl;
- }
-
- //
- // QUADRANGLES : END
- //
-
- return true;
-}
-*/
+#else
//=======================================================================
//function : writeFaces
return true;
}
+#endif
//=============================================================================
/*!
TCollection_AsciiString aGenericName
= (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str();
- TCollection_AsciiString aFacesFileName, aPointsFileName, aResultFileName;
- TCollection_AsciiString aBadResFileName, aBbResFileName, aLogFileName;
- TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName;
-#ifdef _DEBUG_
- aGMFFileName = aGenericName + ".mesh"; // GMF mesh file
- aRequiredVerticesFileName = aGenericName + "_required.mesh"; // GMF required vertices mesh file
- aSolFileName = aGenericName + "_required.sol"; // GMF solution file
-#else
- aGMFFileName = aGenericName + ".meshb"; // GMF mesh file
- aRequiredVerticesFileName = aGenericName + "_required.meshb"; // GMF required vertices mesh file
- aSolFileName = aGenericName + ".solb"; // GMF solution file
-#endif
+ TCollection_AsciiString aLogFileName, aResultFileName;
+#if GHS3D_VERSION < 42
+ TCollection_AsciiString aFacesFileName, aPointsFileName;
+ TCollection_AsciiString aBadResFileName, aBbResFileName;
aFacesFileName = aGenericName + ".faces"; // in faces
aPointsFileName = aGenericName + ".points"; // in points
aResultFileName = aGenericName + ".noboite";// out points and volumes
// make input files
// -----------------
-// ofstream aGMFFile ( aGMFFileName.ToCString() , ios::out);
-// ofstream aSolFile ( aSolFileName.ToCString() , ios::out);
ofstream aFacesFile ( aFacesFileName.ToCString() , ios::out);
ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out);
Ok =
- aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open()
- /*&& aGMFFile.rdbuf()->is_open()
- && aSolFile.rdbuf()->is_open()*/;
+ aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open();
if (!Ok) {
INFOS( "Can't write into " << aFacesFileName);
return error(SMESH_Comment("Can't write into ") << aFacesFileName);
}
+#else
+ TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName;
+#ifdef _DEBUG_
+ aGMFFileName = aGenericName + ".mesh"; // GMF mesh file
+ aResultFileName = aGenericName + "Vol.mesh"; // GMF mesh file
+ aRequiredVerticesFileName = aGenericName + "_required.mesh"; // GMF required vertices mesh file
+ aSolFileName = aGenericName + "_required.sol"; // GMF solution file
+#else
+ aGMFFileName = aGenericName + ".meshb"; // GMF mesh file
+ aResultFileName = aGenericName + "Vol.meshb"; // GMF mesh file
+ aRequiredVerticesFileName = aGenericName + "_required.meshb"; // GMF required vertices mesh file
+ aSolFileName = aGenericName + ".solb"; // GMF solution file
+#endif
+#endif
map <int,int> aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap;
map <int,const SMDS_MeshNode*> aGhs3dIdToNodeMap;
std::map <int, int> nodeID2nodeIndexMap;
TIDSortedElemSet enforcedQuadrangles = GHS3DPlugin_Hypothesis::GetEnforcedQuadrangles(_hyp);
GHS3DPlugin_Hypothesis::TID2SizeMap nodeIDToSizeMap = GHS3DPlugin_Hypothesis::GetNodeIDToSizeMap(_hyp);
// GHS3DPlugin_Hypothesis::TID2SizeMap elemIDToSizeMap = GHS3DPlugin_Hypothesis::GetElementIDToSizeMap(_hyp);
- int nbEnforcedVertices = enforcedVertices.size();
SMESH_MesherHelper helper( theMesh );
helper.SetSubShape( theShape );
if ( !proxyMesh )
return false;
}
-// #if GHS3D_VERSION >= 42
- Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(),
- helper, *proxyMesh,
- aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap,
- enforcedNodes, enforcedEdges, enforcedTriangles, enforcedQuadrangles,
- enforcedVertices);
-/*
- Ok = (writeGMFHeader( aGMFFile, 1) &&
- writeGMFVertices( aGMFFile, aSolFile, helper,
- aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap,
- enforcedVertices, enforcedNodes, nodeID2nodeIndexMap) &&
- writeGMFFaces( aGMFFile, *proxyMesh, theShape,
- aSmdsToGhs3dIdMap,
- enforcedEdges, enforcedTriangles, enforcedQuadrangles,
- nodeID2nodeIndexMap) &&
- writeGMFEnd( aGMFFile ));
-*/
-// #else
+#if GHS3D_VERSION < 42
Ok = (writePoints( aPointsFile, helper,
aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap, aGhs3dIdToNodeMap,
nodeIDToSizeMap,
writeFaces ( aFacesFile, *proxyMesh, theShape,
aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap,
enforcedEdges, enforcedTriangles, enforcedQuadrangles));
-// #endif
+ int nbEnforcedVertices = enforcedVertices.size();
+ int nbEnforcedNodes = enforcedNodes.size();
+#else
+ Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(),
+ helper, *proxyMesh,
+ aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap,
+ enforcedNodes, enforcedEdges, enforcedTriangles, enforcedQuadrangles,
+ enforcedVertices);
+
+#endif
}
-
- int nbEnforcedNodes = enforcedNodes.size();
-// int nbEnforcedEdges = enforcedEdges.size();
-// int nbEnforcedTriangles = enforcedTriangles.size();
-// int nbEnforcedQuadrangles = enforcedQuadrangles.size();
// Write aSmdsToGhs3dIdMap to temp file
TCollection_AsciiString aSmdsToGhs3dIdMapFileName;
aSmdsToGhs3dIdMapFileName = aGenericName + ".ids"; // ids relation
ofstream aIdsFile ( aSmdsToGhs3dIdMapFileName.ToCString() , ios::out);
- Ok =
- aIdsFile.rdbuf()->is_open();
+ Ok = aIdsFile.rdbuf()->is_open();
if (!Ok) {
INFOS( "Can't write into " << aSmdsToGhs3dIdMapFileName);
return error(SMESH_Comment("Can't write into ") << aSmdsToGhs3dIdMapFileName);
aIdsFile << myit->first << " " << myit->second << std::endl;
}
-// aGMFFile.close();
-// aSolFile.close();
+ aIdsFile.close();
+#if GHS3D_VERSION < 42
aFacesFile.close();
aPointsFile.close();
- aIdsFile.close();
+#endif
if ( ! Ok ) {
if ( !_keepFiles ) {
+#if GHS3D_VERSION < 42
removeFile( aFacesFileName );
removeFile( aPointsFileName );
+#endif
removeFile( aSmdsToGhs3dIdMapFileName );
}
return error(COMPERR_BAD_INPUT_MESH);
// -----------------
TCollection_AsciiString cmd = TCollection_AsciiString((char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() );
-#if GHS3D_VERSION >= 42
+#if GHS3D_VERSION < 42
+ cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read
+#else
cmd += TCollection_AsciiString(" --in ") + aGenericName;
- cmd += TCollection_AsciiString(" --required_vertices ") + aRequiredVerticesFileName;
+// cmd += TCollection_AsciiString(" --required_vertices ") + aRequiredVerticesFileName;
cmd += TCollection_AsciiString(" --out ") + aGenericName;
-#else
- cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read
#endif
cmd += TCollection_AsciiString(" -Om 1>" ) + aLogFileName; // dump into file
// read a result
// --------------
+#if GHS3D_VERSION < 42
// Mapping the result file
int fileOpen;
nbEnforcedVertices, nbEnforcedNodes,
enforcedEdges, enforcedTriangles, enforcedQuadrangles );
}
+#else
+ // TODO
+// Ok = readGMFFile(aResultFileName.ToCString(), theMesh, enforcedNodesFromEnforcedElem, enforcedTriangles, enforcedQuadrangles);
+#endif
// ---------------------
// remove working files
}
if ( !_keepFiles ) {
+#if GHS3D_VERSION < 42
removeFile( aFacesFileName );
removeFile( aPointsFileName );
removeFile( aResultFileName );
removeFile( aBadResFileName );
removeFile( aBbResFileName );
+#endif
removeFile( aSmdsToGhs3dIdMapFileName );
}
std::cout << "<" << aResultFileName.ToCString() << "> GHS3D output file ";
TCollection_AsciiString aGenericName
= (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str();
- TCollection_AsciiString aFacesFileName, aPointsFileName, aResultFileName;
- TCollection_AsciiString aBadResFileName, aBbResFileName, aLogFileName;
- TCollection_AsciiString aGMFFileName, aGMFVolFileName, aRequiredVerticesFileName, aSolFileName;
-#ifdef _DEBUG_
- aGMFFileName = aGenericName + ".mesh"; // GMF mesh file
- aGMFVolFileName = aGenericName + "Vol.mesh"; // GMF mesh file
- aRequiredVerticesFileName = aGenericName + "_required.mesh"; // GMF required vertices mesh file
- aSolFileName = aGenericName + "_required.sol"; // GMF solution file
-#else
- aGMFFileName = aGenericName + ".meshb"; // GMF mesh file
- aGMFVolFileName = aGenericName + "Vol.meshb"; // GMF mesh file
- aRequiredVerticesFileName = aGenericName + "_required.meshb"; // GMF required vertices mesh file
- aSolFileName = aGenericName + ".solb"; // GMF solution file
-#endif
+ TCollection_AsciiString aLogFileName = aGenericName + ".log"; // log
+ TCollection_AsciiString aResultFileName;
+ bool Ok;
+#if GHS3D_VERSION < 42
+ TCollection_AsciiString aFacesFileName, aPointsFileName;
+ TCollection_AsciiString aBadResFileName, aBbResFileName;
aFacesFileName = aGenericName + ".faces"; // in faces
aPointsFileName = aGenericName + ".points"; // in points
aResultFileName = aGenericName + ".noboite";// out points and volumes
aBadResFileName = aGenericName + ".boite"; // out bad result
aBbResFileName = aGenericName + ".bb"; // out vertex stepsize
- aLogFileName = aGenericName + ".log"; // log
// -----------------
// make input files
// -----------------
-// ofstream aGMFFile ( aGMFFileName.ToCString() , ios::out);
-// ofstream aSolFile ( aSolFileName.ToCString() , ios::out);
ofstream aFacesFile ( aFacesFileName.ToCString() , ios::out);
ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out);
- bool Ok =
- aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open();
-
+ Ok = aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open();
if (!Ok) {
INFOS( "Can't write into " << aFacesFileName);
return error( SMESH_Comment("Can't write into ") << aFacesFileName);
}
+#else
+ TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName;
+#ifdef _DEBUG_
+ aGMFFileName = aGenericName + ".mesh"; // GMF mesh file
+ aResultFileName = aGenericName + "Vol.mesh"; // GMF mesh file
+ aRequiredVerticesFileName = aGenericName + "_required.mesh"; // GMF required vertices mesh file
+ aSolFileName = aGenericName + "_required.sol"; // GMF solution file
+#else
+ aGMFFileName = aGenericName + ".meshb"; // GMF mesh file
+ aResultFileName = aGenericName + "Vol.meshb"; // GMF mesh file
+ aRequiredVerticesFileName = aGenericName + "_required.meshb"; // GMF required vertices mesh file
+ aSolFileName = aGenericName + ".solb"; // GMF solution file
+#endif
+#endif
std::map <int, int> nodeID2nodeIndexMap;
GHS3DPlugin_Hypothesis::TEnforcedVertexValues enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp);
TIDSortedElemSet enforcedTriangles = GHS3DPlugin_Hypothesis::GetEnforcedTriangles(_hyp);
TIDSortedElemSet enforcedQuadrangles = GHS3DPlugin_Hypothesis::GetEnforcedQuadrangles(_hyp);
GHS3DPlugin_Hypothesis::TID2SizeMap nodeIDToSizeMap = GHS3DPlugin_Hypothesis::GetNodeIDToSizeMap(_hyp);
- int nbEnforcedVertices = enforcedVertices.size();
vector <const SMDS_MeshNode*> aNodeByGhs3dId, anEnforcedNodeByGhs3dId;
{
aQuad2Trias->Compute( theMesh );
proxyMesh.reset( aQuad2Trias );
}
-
-// #if GHS3D_VERSION >= 42
+#if GHS3D_VERSION < 42
+ Ok = (writeFaces ( aFacesFile, *proxyMesh, &theMesh, aNodeByGhs3dId, anEnforcedNodeByGhs3dId,
+ enforcedEdges, enforcedTriangles, enforcedQuadrangles ) &&
+ writePoints( aPointsFile, &theMesh, aNodeByGhs3dId, anEnforcedNodeByGhs3dId,
+ nodeIDToSizeMap, enforcedVertices, enforcedNodes));
+ int nbEnforcedVertices = enforcedVertices.size();
+ int nbEnforcedNodes = enforcedNodes.size();
+#else
Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(),
*proxyMesh, &theMesh,
aNodeByGhs3dId, anEnforcedNodeByGhs3dId,
enforcedNodes, enforcedEdges, enforcedTriangles, enforcedQuadrangles,
enforcedVertices);
-
-// #else
-
- Ok = (writeFaces ( aFacesFile, *proxyMesh, &theMesh, aNodeByGhs3dId, anEnforcedNodeByGhs3dId,
- enforcedEdges, enforcedTriangles, enforcedQuadrangles ) &&
- writePoints( aPointsFile, &theMesh, aNodeByGhs3dId, anEnforcedNodeByGhs3dId,
- nodeIDToSizeMap, enforcedVertices, enforcedNodes));
-// #endif
- }
+#endif
+ }
TIDSortedNodeSet enforcedNodesFromEnforcedElem;
- int nbEnforcedNodes = enforcedNodes.size();
- for (int i=0;i<anEnforcedNodeByGhs3dId.size();i++) {
+ for (int i=0;i<anEnforcedNodeByGhs3dId.size();i++)
enforcedNodesFromEnforcedElem.insert(anEnforcedNodeByGhs3dId[i]);
-// if (!enforcedNodesFromEnforcedElem.insert(anEnforcedNodeByGhs3dId[i]).second)
-// std::cout << "Node not inserted in enforcedNodesFromEnforcedElem: " << anEnforcedNodeByGhs3dId[i];
-// else
-// std::cout << "GHS3D ID " << i+1 << " " << anEnforcedNodeByGhs3dId[i];
- }
-// int nbEnforcedEdges = enforcedEdges.size();
-// int nbEnforcedTriangles = enforcedTriangles.size();
-// int nbEnforcedQuadrangles = enforcedQuadrangles.size();
-
-// aGMFFile.close();
-// aSolFile.close();
+
+#if GHS3D_VERSION < 42
aFacesFile.close();
aPointsFile.close();
return error(COMPERR_BAD_INPUT_MESH);
}
removeFile( aResultFileName ); // needed for boundary recovery module usage
+#endif
// -----------------
// run ghs3d mesher
// -----------------
TCollection_AsciiString cmd = TCollection_AsciiString((char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp, false ).c_str());
-#if GHS3D_VERSION >= 42
- cmd += TCollection_AsciiString(" --in ") + aGenericName;
- cmd += TCollection_AsciiString(" --required_vertices ") + aRequiredVerticesFileName;
- cmd += TCollection_AsciiString(" --out ") + aGenericName;
+#if GHS3D_VERSION < 42
+ cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read
#else
- cmd += TCollection_AsciiString(" -Om -f ") + aGenericName; // file to read
+ cmd += TCollection_AsciiString(" --in ") + aGenericName;
+// cmd += TCollection_AsciiString(" --required_vertices ") + aRequiredVerticesFileName;
+ cmd += TCollection_AsciiString(" --out ") + aResultFileName;
#endif
cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file
// --------------
// read a result
// --------------
- Ok = readGMFFile(aGMFFileName.ToCString(), aHelper, enforcedNodesFromEnforcedElem, enforcedTriangles, enforcedQuadrangles);
-
- int fileOpen;
- fileOpen = open( aResultFileName.ToCString(), O_RDONLY);
+#if GHS3D_VERSION < 42
+ int fileOpen = open( aResultFileName.ToCString(), O_RDONLY);
if ( fileOpen < 0 ) {
std::cout << std::endl;
std::cout << "Error when opening the " << aResultFileName.ToCString() << " file" << std::endl;
theMesh, theShape ,aNodeByGhs3dId, anEnforcedNodeByGhs3dId,
nbEnforcedVertices, nbEnforcedNodes,
enforcedEdges, enforcedTriangles, enforcedQuadrangles );
-// Ok = readGMFFile(aGMFVolFileName.ToCString(), aHelper, anEnforcedNodeByGhs3dId, enforcedTriangles, enforcedQuadrangles);
}
+#else
+ Ok = readGMFFile(aResultFileName.ToCString(), aHelper, enforcedNodesFromEnforcedElem, enforcedTriangles, enforcedQuadrangles);
+#endif
// ---------------------
// remove working files
INFOS( "GHS3D Error, command '" << cmd.ToCString() << "' failed" );
error(COMPERR_ALGO_FAILED, "ghs3d: command not found" );
}
-
+#if GHS3D_VERSION < 42
if ( !_keepFiles )
{
removeFile( aFacesFileName );
removeFile( aBadResFileName );
removeFile( aBbResFileName );
}
-
+#endif
return Ok;
}