//
#include "GHS3DPlugin_GHS3D.hxx"
#include "GHS3DPlugin_Hypothesis.hxx"
-
+extern "C"
+{
+ #include "libmesh5.h"
+}
#include <Basics_Utils.hxx>
#define HOLE_ID -1
+#ifndef GHS3D_VERSION
+#define GHS3D_VERSION 41
+#endif
+
typedef const list<const SMDS_MeshFace*> TTriaList;
static void removeFile( const TCollection_AsciiString& fileName )
if ( i < 3 )
tab[i] = intVal;
}
- return ptr;
-}
+ return ptr;
+}
+
+//=======================================================================
+//function : countShape
+//purpose :
+//=======================================================================
+
+// template < class Mesh, class Shape >
+// static int countShape( Mesh* mesh, Shape shape ) {
+// TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape );
+// int nbShape = 0;
+// for ( ; expShape.More(); expShape.Next() ) {
+// nbShape++;
+// }
+// return nbShape;
+// }
+// Ok = writeGMFFile(aGMFFileName, aRequiredVerticesFileName, aSolFileName, &theMesh, *proxyMesh,
+// aNodeByGhs3dId,
+// enforcedNodes, enforcedEdges, enforcedTriangles, enforcedQuadrangles,
+// enforcedVertices);
+
+static bool writeGMFFile(const TCollection_AsciiString& theMeshFileName,
+ const TCollection_AsciiString& theRequiredVerticesFileName,
+ const TCollection_AsciiString& theSolFileName,
+ const SMESH_ProxyMesh& theProxyMesh,
+ SMESH_Mesh * theMesh,
+ vector <const SMDS_MeshNode*> & theNodeByGhs3dId,
+ vector <const SMDS_MeshNode*> & theEnforcedNodeByGhs3dId,
+ TIDSortedNodeSet & theEnforcedNodes,
+ TIDSortedElemSet & theEnforcedEdges,
+ TIDSortedElemSet & theEnforcedTriangles,
+ TIDSortedElemSet & theEnforcedQuadrangles,
+ GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices)
+{
+ MESSAGE("writeGMFFile");
+ int idx;
+ const int dummyint = 0;
+ GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
+ std::vector<double> enfVertexSizes;
+ const SMDS_MeshElement* elem;
+ TIDSortedElemSet anElemSet, anEnforcedEdgeSet, anEnforcedTriangleSet, anEnforcedQuadrangleSet;
+ SMDS_ElemIteratorPtr nodeIt;
+ map<const SMDS_MeshNode*,int> aNodeToGhs3dIdMap, anEnforcedNodeToGhs3dIdMap;
+ TIDSortedElemSet::iterator elemIt;
+ bool isOK;
+ auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher());
+
+ int nbEnforcedVertices = theEnforcedVertices.size();
+ int nbEnforcedNodes = theEnforcedNodes.size();
+ int nbEnforcedEdges = theEnforcedEdges.size();
+ int nbEnforcedTriangles = theEnforcedTriangles.size();
+ int nbEnforcedQuadrangles = theEnforcedQuadrangles.size();
+
+ // count faces
+ int nbFaces = theProxyMesh.NbFaces();
+
+ if ( nbFaces == 0 )
+ return false;
+
+ idx = GmfOpenMesh(theMeshFileName.ToCString(), GmfWrite, 3, 3);
+ if (!idx)
+ return false;
+
+ /* ========================== FACES ========================== */
+ /* TRIANGLES ========================== */
+ SMDS_ElemIteratorPtr eIt = theProxyMesh.GetFaces();
+ while ( eIt->more() )
+ {
+ elem = eIt->next();
+ anElemSet.insert(elem);
+ // NODE_NB_1 NODE_NB_2 ...
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() )
+ {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ int newId = aNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1
+ aNodeToGhs3dIdMap.insert( make_pair( node, newId ));
+ }
+ }
+
+ /* EDGES ========================== */
+
+ // Iterate over the enforced edges
+ for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) {
+ elem = (*elemIt);
+ isOK = true;
+ nodeIt = elem->nodesIterator();
+
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ // Test if point is inside shape to mesh
+ gp_Pnt myPoint(node->X(),node->Y(),node->Z());
+ TopAbs_State result = pntCls->GetPointState( myPoint );
+ if ( result != TopAbs_IN ) {
+ isOK = false;
+ break;
+ }
+ }
+ if (isOK) {
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ int newId = aNodeToGhs3dIdMap.size() + anEnforcedNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1
+ anEnforcedNodeToGhs3dIdMap.insert( make_pair( node, newId ));
+ }
+ anEnforcedEdgeSet.insert(elem);
+ }
+ }
+
+ /* ENFORCED TRIANGLES ========================== */
+
+ // Iterate over the enforced triangles
+ for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) {
+ elem = (*elemIt);
+ isOK = true;
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ // Test if point is inside shape to mesh
+ gp_Pnt myPoint(node->X(),node->Y(),node->Z());
+ TopAbs_State result = pntCls->GetPointState( myPoint );
+ if ( result != TopAbs_IN ) {
+ isOK = false;
+ break;
+ }
+ }
+ if (isOK) {
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ int newId = aNodeToGhs3dIdMap.size() + anEnforcedNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1
+ anEnforcedNodeToGhs3dIdMap.insert( make_pair( node, newId ));
+ }
+ anEnforcedTriangleSet.insert(elem);
+ }
+ }
+
+ /* ENFORCED QUADRANGLES ========================== */
+
+ // Iterate over the enforced quadrangles
+ for(elemIt = theEnforcedQuadrangles.begin() ; elemIt != theEnforcedQuadrangles.end() ; ++elemIt) {
+ elem = (*elemIt);
+ isOK = true;
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ // Test if point is inside shape to mesh
+ gp_Pnt myPoint(node->X(),node->Y(),node->Z());
+ TopAbs_State result = pntCls->GetPointState( myPoint );
+ if ( result != TopAbs_IN ) {
+ isOK = false;
+ break;
+ }
+ }
+ if (isOK) {
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ int newId = aNodeToGhs3dIdMap.size() + anEnforcedNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1
+ anEnforcedNodeToGhs3dIdMap.insert( make_pair( node, newId ));
+ }
+ anEnforcedQuadrangleSet.insert(elem);
+ }
+ }
+
+
+ // put nodes to theNodeByGhs3dId vector
+ std::cout << "aNodeToGhs3dIdMap.size(): "<<aNodeToGhs3dIdMap.size()<<std::endl;
+ theNodeByGhs3dId.resize( aNodeToGhs3dIdMap.size() );
+ map<const SMDS_MeshNode*,int>::const_iterator n2id = aNodeToGhs3dIdMap.begin();
+ for ( ; n2id != aNodeToGhs3dIdMap.end(); ++ n2id)
+ {
+// std::cout << "n2id->first: "<<n2id->first<<std::endl;
+ theNodeByGhs3dId[ n2id->second - 1 ] = n2id->first; // ghs3d ids count from 1
+ }
+
+ // put nodes to anEnforcedNodeToGhs3dIdMap vector
+ std::cout << "anEnforcedNodeToGhs3dIdMap.size(): "<<anEnforcedNodeToGhs3dIdMap.size()<<std::endl;
+ theEnforcedNodeByGhs3dId.resize( anEnforcedNodeToGhs3dIdMap.size() );
+ n2id = anEnforcedNodeToGhs3dIdMap.begin();
+ for ( ; n2id != anEnforcedNodeToGhs3dIdMap.end(); ++ n2id)
+ {
+// std::cout << "n2id->first: "<<n2id->first<<std::endl;
+ theEnforcedNodeByGhs3dId[ n2id->second - aNodeToGhs3dIdMap.size() - 1 ] = n2id->first; // ghs3d ids count from 1
+ }
+
+
+ /* ========================== NODES ========================== */
+ vector<const SMDS_MeshNode*> theOrderedNodes;
+ std::set< std::vector<double> > nodesCoords;
+ vector<const SMDS_MeshNode*>::const_iterator ghs3dNodeIt = theNodeByGhs3dId.begin();
+ vector<const SMDS_MeshNode*>::const_iterator after = theNodeByGhs3dId.end();
+
+ std::cout << theNodeByGhs3dId.size() << " nodes from mesh ..." << std::endl;
+ for ( ; ghs3dNodeIt != after; ++ghs3dNodeIt )
+ {
+ const SMDS_MeshNode* node = *ghs3dNodeIt;
+ std::vector<double> coords;
+ coords.push_back(node->X());
+ coords.push_back(node->Y());
+ coords.push_back(node->Z());
+ nodesCoords.insert(coords);
+ theOrderedNodes.push_back(node);
+ }
+
+ // Iterate over the enforced nodes
+ TIDSortedNodeSet::const_iterator enfNodeIt;
+ std::cout << theEnforcedNodes.size() << " nodes from enforced nodes ..." << std::endl;
+ for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt)
+ {
+ const SMDS_MeshNode* node = *enfNodeIt;
+ std::vector<double> coords;
+ coords.push_back(node->X());
+ coords.push_back(node->Y());
+ coords.push_back(node->Z());
+
+ if (nodesCoords.find(coords) != nodesCoords.end()) {
+ std::cout << "Node at " << node->X()<<", " <<node->Y()<<", " <<node->Z() << " found" << std::endl;
+ continue;
+ }
+
+ if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
+ continue;
+
+ // Test if point is inside shape to mesh
+ gp_Pnt myPoint(node->X(),node->Y(),node->Z());
+ TopAbs_State result = pntCls->GetPointState( myPoint );
+ if ( result != TopAbs_IN )
+ continue;
+
+ nodesCoords.insert(coords);
+ theOrderedNodes.push_back(node);
+ }
+ // Iterate over the enforced nodes given by enforced elements
+ ghs3dNodeIt = theEnforcedNodeByGhs3dId.begin();
+ after = theEnforcedNodeByGhs3dId.end();
+ std::cout << theEnforcedNodes.size() << " nodes from enforced elements ..." << std::endl;
+ for ( ; ghs3dNodeIt != after; ++ghs3dNodeIt )
+ {
+ const SMDS_MeshNode* node = *ghs3dNodeIt;
+ std::vector<double> coords;
+ coords.push_back(node->X());
+ coords.push_back(node->Y());
+ coords.push_back(node->Z());
+
+ if (nodesCoords.find(coords) != nodesCoords.end()) {
+ std::cout << "Node at " << node->X()<<", " <<node->Y()<<", " <<node->Z() << " found" << std::endl;
+ continue;
+ }
+
+ if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
+ continue;
+
+ nodesCoords.insert(coords);
+ theOrderedNodes.push_back(node);
+ }
+
+
+ GmfSetKwd(idx, GmfVertices, theOrderedNodes.size());
+// std::set< std::vector<double> >::const_iterator coordsIt = nodesCoords.begin();
+ for (ghs3dNodeIt = theOrderedNodes.begin();ghs3dNodeIt != theOrderedNodes.end();++ghs3dNodeIt)
+ GmfSetLin(idx, GmfVertices, (*ghs3dNodeIt)->X(), (*ghs3dNodeIt)->Y(), (*ghs3dNodeIt)->Z(), dummyint);
+
+ int nedge[2], ntri[3], nquad[4];
+
+ if (anEnforcedEdgeSet.size()) {
+ GmfSetKwd(idx, GmfEdges, anEnforcedEdgeSet.size());
+ for(elemIt = anEnforcedEdgeSet.begin() ; elemIt != anEnforcedEdgeSet.end() ; ++elemIt) {
+ elem = (*elemIt);
+ nodeIt = elem->nodesIterator();
+ int index=0;
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToGhs3dIdMap.find(node);
+ if (it == anEnforcedNodeToGhs3dIdMap.end())
+ throw "Node not found";
+ nedge[index] = it->second;
+ index++;
+ }
+ GmfSetLin(idx, GmfEdges, nedge[0], nedge[1], dummyint);
+ }
+ }
+
+ if (anElemSet.size()+anEnforcedTriangleSet.size()) {
+ GmfSetKwd(idx, GmfTriangles, anElemSet.size()+anEnforcedTriangleSet.size());
+ for(elemIt = anElemSet.begin() ; elemIt != anElemSet.end() ; ++elemIt) {
+ elem = (*elemIt);
+ nodeIt = elem->nodesIterator();
+ int index=0;
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ map< const SMDS_MeshNode*,int >::iterator it = aNodeToGhs3dIdMap.find(node);
+ if (it == aNodeToGhs3dIdMap.end())
+ throw "Node not found";
+ ntri[index] = it->second;
+ index++;
+ }
+ GmfSetLin(idx, GmfTriangles, ntri[0], ntri[1], ntri[2], dummyint);
+ }
+ for(elemIt = anEnforcedTriangleSet.begin() ; elemIt != anEnforcedTriangleSet.end() ; ++elemIt) {
+ elem = (*elemIt);
+ nodeIt = elem->nodesIterator();
+ int index=0;
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToGhs3dIdMap.find(node);
+ if (it == anEnforcedNodeToGhs3dIdMap.end())
+ throw "Node not found";
+ ntri[index] = it->second;
+ index++;
+ }
+ GmfSetLin(idx, GmfTriangles, ntri[0], ntri[1], ntri[2], dummyint);
+ }
+ }
+
+ if (anEnforcedQuadrangleSet.size()) {
+ GmfSetKwd(idx, GmfQuadrilaterals, anEnforcedQuadrangleSet.size());
+ for(elemIt = anEnforcedQuadrangleSet.begin() ; elemIt != anEnforcedQuadrangleSet.end() ; ++elemIt) {
+ elem = (*elemIt);
+ nodeIt = elem->nodesIterator();
+ int index=0;
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToGhs3dIdMap.find(node);
+ if (it == anEnforcedNodeToGhs3dIdMap.end())
+ throw "Node not found";
+ nquad[index] = it->second;
+ index++;
+ }
+ GmfSetLin(idx, GmfQuadrilaterals, nquad[0], nquad[1], nquad[2], nquad[3], dummyint);
+ }
+ }
+
+ GmfCloseMesh(idx);
+
+ if (nbEnforcedVertices) {
+ std::vector<std::vector<double> > ReqVerTab;
+ ReqVerTab.clear();
+ std::vector<double> enfVertexSizes;
+ int solSize = 0;
+ std::cout << theEnforcedVertices.size() << " nodes from enforced vertices ..." << std::endl;
+ // Iterate over the enforced vertices
+ 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);
+ TopAbs_State result = pntCls->GetPointState( myPoint );
+ if ( result != TopAbs_IN )
+ continue;
+ std::vector<double> coords;
+ coords.push_back(x);
+ coords.push_back(y);
+ coords.push_back(z);
+ ReqVerTab.push_back(coords);
+ enfVertexSizes.push_back(vertexIt->second);
+ solSize++;
+ }
+
+ if (solSize) {
+ int idxRequired = GmfOpenMesh(theRequiredVerticesFileName.ToCString(), GmfWrite, 3, 3);
+ if (!idxRequired)
+ return false;
+ int idxSol = GmfOpenMesh(theSolFileName.ToCString(), GmfWrite, 3, 3);
+ if (!idxSol)
+ return false;
+
+ int TypTab[] = {GmfSca};
+ GmfSetKwd(idxRequired, GmfVertices, solSize);
+ GmfSetKwd(idxSol, GmfSolAtVertices, solSize, 1, TypTab);
+
+ for (int i=0;i<solSize;i++) {
+ double solTab[] = {enfVertexSizes.at(i)};
+ GmfSetLin(idxRequired, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
+ GmfSetLin(idxSol, GmfSolAtVertices, solTab);
+ }
+ GmfCloseMesh(idxRequired);
+ GmfCloseMesh(idxSol);
+ }
+ }
+
+
+ return true;
+
+}
+
+static bool writeGMFFile(const TCollection_AsciiString& theMeshFileName,
+ const TCollection_AsciiString& theRequiredVerticesFileName,
+ const TCollection_AsciiString& theSolFileName,
+ SMESH_MesherHelper& theHelper,
+ const SMESH_ProxyMesh& theProxyMesh,
+ map <int,int> & theSmdsToGhs3dIdMap,
+ map <int,const SMDS_MeshNode*> & theGhs3dIdToNodeMap,
+ TIDSortedNodeSet & theEnforcedNodes,
+ TIDSortedElemSet & theEnforcedEdges,
+ TIDSortedElemSet & theEnforcedTriangles,
+ TIDSortedElemSet & theEnforcedQuadrangles,
+ GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices)
+{
+ int idx, nbv, nbev, nben, aGhs3dID = 0;
+ const int dummyint = 0;
+ GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
+ std::vector<double> enfVertexSizes;
+ TIDSortedNodeSet::const_iterator enfNodeIt;
+ const SMDS_MeshNode* node;
+ SMDS_NodeIteratorPtr nodeIt;
+ std::map<int,int> theNodeId2NodeIndexMap;
+
+ idx = GmfOpenMesh(theMeshFileName.ToCString(), GmfWrite, 3, 3);
+ if (!idx)
+ return false;
+
+ SMESHDS_Mesh * theMeshDS = theHelper.GetMeshDS();
+
+ /* ========================== NODES ========================== */
+ // NB_NODES
+ nbv = theMeshDS->NbNodes();
+ if ( nbv == 0 )
+ return false;
+ nbev = theEnforcedVertices.size();
+ nben = 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() )
+ nbv -= sm->GetSubMeshDS()->NbNodes();
+ }
+ }
+ }
+
+ std::vector<std::vector<double> > VerTab;
+ VerTab.clear();
+ std::vector<double> aVerTab;
+ nodeIt = theMeshDS->nodesIterator();
+ // Loop from 1 to NB_NODES
+
+ while ( nodeIt->more() )
+ {
+ node = nodeIt->next();
+ if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_EDGE &&
+ theHelper.IsDegenShape( node->getshapeId() )) // Issue 020674
+ continue;
+
+ aVerTab.clear();
+ aVerTab.push_back(node->X());
+ aVerTab.push_back(node->Y());
+ aVerTab.push_back(node->Z());
+ VerTab.push_back(aVerTab);
+ aGhs3dID++;
+ theSmdsToGhs3dIdMap.insert( make_pair( node->GetID(), aGhs3dID ));
+ theGhs3dIdToNodeMap.insert( make_pair( aGhs3dID, node ));
+ }
+
+ /* ENFORCED NODES ========================== */
+ if (nben) {
+ for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt) {
+ double x = (*enfNodeIt)->X();
+ double y = (*enfNodeIt)->Y();
+ double z = (*enfNodeIt)->Z();
+ // Test if point is inside shape to mesh
+ gp_Pnt myPoint(x,y,z);
+ BRepClass3d_SolidClassifier scl(theMeshDS->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;
+ aVerTab.clear();
+ aVerTab.push_back(x);
+ aVerTab.push_back(y);
+ aVerTab.push_back(z);
+ VerTab.push_back(aVerTab);
+ aGhs3dID++;
+ theNodeId2NodeIndexMap.insert( make_pair( (*enfNodeIt)->GetID(), aGhs3dID ));
+ }
+ }
+
+ /* Write vertices number */
+ MESSAGE("Number of vertices: "<<aGhs3dID);
+ MESSAGE("Size of vector: "<<VerTab.size());
+ GmfSetKwd(idx, GmfVertices, aGhs3dID);
+ for (int i=0;i<aGhs3dID;i++)
+ GmfSetLin(idx, GmfVertices, VerTab[i][0], VerTab[i][1], VerTab[i][2], dummyint);
+
+
+ /* ENFORCED VERTICES ========================== */
+ if (nbev) {
+ std::vector<std::vector<double> > ReqVerTab;
+ ReqVerTab.clear();
+ std::vector<double> aReqVerTab;
+ int solSize = 0;
+ 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(theMeshDS->ShapeToMesh());
+ scl.Perform(myPoint, 1e-7);
+ TopAbs_State result = scl.State();
+ if ( result != TopAbs_IN )
+ continue;
+ enfVertexSizes.push_back(vertexIt->second);
+ aReqVerTab.clear();
+ aReqVerTab.push_back(x);
+ aReqVerTab.push_back(y);
+ aReqVerTab.push_back(z);
+ ReqVerTab.push_back(aReqVerTab);
+ solSize++;
+ }
+
+ if (solSize) {
+ int idxRequired = GmfOpenMesh(theRequiredVerticesFileName.ToCString(), GmfWrite, 3, 3);
+ if (!idxRequired)
+ return false;
+ int idxSol = GmfOpenMesh(theSolFileName.ToCString(), GmfWrite, 3, 3);
+ if (!idxSol)
+ return false;
+
+ int TypTab[] = {GmfSca};
+ GmfSetKwd(idxRequired, GmfVertices, solSize);
+ GmfSetKwd(idxSol, GmfSolAtVertices, solSize, 1, TypTab);
+
+ for (int i=0;i<solSize;i++) {
+ double solTab[] = {enfVertexSizes.at(i)};
+ GmfSetLin(idxRequired, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
+ GmfSetLin(idxSol, GmfSolAtVertices, solTab);
+ }
+ GmfCloseMesh(idxRequired);
+ GmfCloseMesh(idxSol);
+ }
+ }
+
+ /* ========================== EDGES ========================== */
+
+
+
+ /* ========================== FACES ========================== */
+
+ int nbTriangles = 0, nbQuadrangles = 0, aSmdsID;
+ TopTools_IndexedMapOfShape facesMap, trianglesMap, quadranglesMap;
+ TIDSortedElemSet::const_iterator elemIt;
+ const SMESHDS_SubMesh* theSubMesh;
+ TopoDS_Shape aShape;
+ SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace;
+ const SMDS_MeshElement* aFace;
+ map<int,int>::const_iterator itOnMap;
+ std::vector<std::vector<int> > tt, qt;
+ tt.clear();
+ qt.clear();
+ std::vector<int> att, aqt;
+
+ TopExp::MapShapes( theMeshDS->ShapeToMesh(), TopAbs_FACE, facesMap );
+
+ for ( int i = 1; i <= facesMap.Extent(); ++i )
+ if (( theSubMesh = theProxyMesh.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 ++;
+ }
+ }
+ }
+
+ /* TRIANGLES ========================== */
+ if (nbTriangles) {
+ for ( int i = 1; i <= trianglesMap.Extent(); i++ )
+ {
+ aShape = trianglesMap(i);
+ theSubMesh = theProxyMesh.GetSubMesh(aShape);
+ if ( !theSubMesh ) continue;
+ itOnSubMesh = theSubMesh->GetElements();
+ while ( itOnSubMesh->more() )
+ {
+ aFace = itOnSubMesh->next();
+ itOnSubFace = aFace->nodesIterator();
+ att.clear();
+ while ( itOnSubFace->more() ) {
+ // find GHS3D ID
+ aSmdsID = itOnSubFace->next()->GetID();
+ itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
+ ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
+ att.push_back((*itOnMap).second);
+ }
+ tt.push_back(att);
+ }
+ }
+ }
+
+ int nbEnforcedTriangles = theEnforcedTriangles.size();
+ if (nbEnforcedTriangles) {
+ // Iterate over the enforced triangles
+ for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) {
+ aFace = (*elemIt);
+ bool isOK = true;
+ itOnSubFace = aFace->nodesIterator();
+ att.clear();
+ while ( itOnSubFace->more() ) {
+ int aNodeID = itOnSubFace->next()->GetID();
+ itOnMap = theNodeId2NodeIndexMap.find(aNodeID);
+ if (itOnMap != theNodeId2NodeIndexMap.end())
+ att.push_back((*itOnMap).second);
+ else {
+ isOK = false;
+ break;
+ }
+ }
+ if (isOK)
+ tt.push_back(att);
+ }
+ }
+
+ if (tt.size()) {
+ GmfSetKwd(idx, GmfTriangles, tt.size());
+ for (int i=0;i<tt.size();i++)
+ GmfSetLin(idx, GmfTriangles, tt[i][0], tt[i][1], tt[i][2], dummyint);
+ }
+
+ /* QUADRANGLES ========================== */
+ if (nbQuadrangles) {
+ for ( int i = 1; i <= quadranglesMap.Extent(); i++ )
+ {
+ aShape = quadranglesMap(i);
+ theSubMesh = theProxyMesh.GetSubMesh(aShape);
+ if ( !theSubMesh ) continue;
+ itOnSubMesh = theSubMesh->GetElements();
+ while ( itOnSubMesh->more() )
+ {
+ aFace = itOnSubMesh->next();
+ itOnSubFace = aFace->nodesIterator();
+ aqt.clear();
+ while ( itOnSubFace->more() ) {
+ // find GHS3D ID
+ aSmdsID = itOnSubFace->next()->GetID();
+ itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
+ ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
+ aqt.push_back((*itOnMap).second);
+ }
+ qt.push_back(aqt);
+ }
+ }
+ }
+
+ int nbEnforcedQuadrangles = theEnforcedQuadrangles.size();
+ if (nbEnforcedQuadrangles) {
+ // Iterate over the enforced triangles
+ for(elemIt = theEnforcedQuadrangles.begin() ; elemIt != theEnforcedQuadrangles.end() ; ++elemIt) {
+ aFace = (*elemIt);
+ bool isOK = true;
+ itOnSubFace = aFace->nodesIterator();
+ aqt.clear();
+ while ( itOnSubFace->more() ) {
+ int aNodeID = itOnSubFace->next()->GetID();
+ itOnMap = theNodeId2NodeIndexMap.find(aNodeID);
+ if (itOnMap != theNodeId2NodeIndexMap.end())
+ aqt.push_back((*itOnMap).second);
+ else {
+ isOK = false;
+ break;
+ }
+ }
+ if (isOK)
+ qt.push_back(att);
+ }
+ }
+
+ if (qt.size()) {
+ GmfSetKwd(idx, GmfQuadrilaterals, qt.size());
+ for (int i=0;i<qt.size();i++)
+ GmfSetLin(idx, GmfQuadrilaterals, qt[i][0], qt[i][1], qt[i][2], qt[i][3], dummyint);
+ }
+
+
+ GmfCloseMesh(idx);
+ 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;
+ }
-//=======================================================================
-//function : countShape
-//purpose :
-//=======================================================================
+ //
+ // QUADRANGLES : END
+ //
-// template < class Mesh, class Shape >
-// static int countShape( Mesh* mesh, Shape shape ) {
-// TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape );
-// int nbShape = 0;
-// for ( ; expShape.More(); expShape.Next() ) {
-// nbShape++;
-// }
-// return nbShape;
-// }
+ return true;
+}
+*/
//=======================================================================
//function : writeFaces
static bool writeFaces (ofstream & theFile,
const SMESH_ProxyMesh& theMesh,
const TopoDS_Shape& theShape,
- const map <int,int> & theSmdsToGhs3dIdMap)
+ const map <int,int> & theSmdsToGhs3dIdMap,
+ const map <int,int> & theEnforcedNodeIdToGhs3dIdMap,
+ TIDSortedElemSet & theEnforcedEdges,
+ TIDSortedElemSet & theEnforcedTriangles,
+ TIDSortedElemSet & theEnforcedQuadrangles)
{
// record structure:
//
SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace;
int nbNodes, aSmdsID;
+ TIDSortedElemSet::const_iterator elemIt;
+ int nbEnforcedEdges = theEnforcedEdges.size();
+ int nbEnforcedTriangles = theEnforcedTriangles.size();
+ int nbEnforcedQuadrangles = theEnforcedQuadrangles.size();
// count triangles bound to geometry
int nbTriangles = 0;
- TopTools_IndexedMapOfShape facesMap;
+ 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))))
nbTriangles += theSubMesh->NbElements();
- std::cout << " " << facesMap.Extent() << " shapes of 2D dimension" << std::endl;
+ std::cout << " " << facesMap.Extent() << " shapes of 2D dimension and" << std::endl;
+ if (nbEnforcedEdges+nbEnforcedTriangles+nbEnforcedQuadrangles)
+ std::cout << " " << nbEnforcedEdges+nbEnforcedTriangles+nbEnforcedQuadrangles
+ << " enforced shapes:" << std::endl;
+ if (nbEnforcedEdges)
+ 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;
- theFile << space << nbTriangles << space << dummyint << std::endl;
+// theFile << space << nbTriangles << space << dummyint << std::endl;
+ std::ostringstream globalStream, localStream, aStream;
+ //
+ // FACES : BEGIN
+ //
+
for ( int i = 1; i <= facesMap.Extent(); i++ )
{
aShape = facesMap(i);
aFace = itOnSubMesh->next();
nbNodes = aFace->NbNodes();
- theFile << space << nbNodes;
+ localStream << nbNodes << space;
itOnSubFace = aFace->nodesIterator();
while ( itOnSubFace->more() ) {
// }
ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
- theFile << space << (*itOnMap).second;
+ localStream << (*itOnMap).second << space ;
}
// (NB_NODES + 1) times: DUMMY_INT
for ( int j=0; j<=nbNodes; j++)
- theFile << space << dummyint;
+ localStream << dummyint << space ;
- theFile << std::endl;
+ localStream << std::endl;
+ }
+ }
+
+ globalStream << localStream.str();
+ localStream.str("");
+
+ //
+ // 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 ;
+ while ( itOnSubFace->more() ) {
+ aSmdsID = itOnSubFace->next()->GetID();
+ itOnMap = theEnforcedNodeIdToGhs3dIdMap.find(aSmdsID);
+ if (itOnMap != theEnforcedNodeIdToGhs3dIdMap.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);
+ isOK = true;
+ itOnSubFace = aFace->nodesIterator();
+ aStream.str("");
+ aStream << "3" << space ;
+ while ( itOnSubFace->more() ) {
+ aSmdsID = itOnSubFace->next()->GetID();
+ itOnMap = theEnforcedNodeIdToGhs3dIdMap.find(aSmdsID);
+ if (itOnMap != theEnforcedNodeIdToGhs3dIdMap.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
+ //
+
+ //
+ // ENFORCED QUADRANGLES : BEGIN
+ //
+ // Iterate over the enforced quadrangles
+ int usedEnforcedQuadrangles = 0;
+ for(elemIt = theEnforcedQuadrangles.begin() ; elemIt != theEnforcedQuadrangles.end() ; ++elemIt) {
+ aFace = (*elemIt);
+ isOK = true;
+ itOnSubFace = aFace->nodesIterator();
+ aStream.str("");
+ aStream << "4" << space ;
+ while ( itOnSubFace->more() ) {
+ aSmdsID = itOnSubFace->next()->GetID();
+ itOnMap = theEnforcedNodeIdToGhs3dIdMap.find(aSmdsID);
+ if (itOnMap != theEnforcedNodeIdToGhs3dIdMap.end())
+ aStream << (*itOnMap).second << space;
+ else {
+ isOK = false;
+ break;
+ }
}
+ if (isOK) {
+ for ( int j=0; j<=4; j++)
+ aStream << dummyint << space ;
+ localStream << aStream.str() << std::endl;
+ usedEnforcedQuadrangles++;
+ }
+ }
+
+ if (usedEnforcedQuadrangles) {
+ globalStream << localStream.str();
+ localStream.str("");
}
+ //
+ // ENFORCED QUADRANGLES : END
+ //
+
+ theFile
+ << nbTriangles+usedEnforcedQuadrangles+usedEnforcedTriangles+usedEnforcedEdges
+ << " 0" << std::endl
+ << globalStream.str();
return true;
}
//=======================================================================
static bool writeFaces (ofstream & theFile,
- const SMESH_ProxyMesh& theMesh,
- vector <const SMDS_MeshNode*> & theNodeByGhs3dId)
+ const SMESH_ProxyMesh& theProxyMesh,
+ SMESH_Mesh * theMesh,
+ vector <const SMDS_MeshNode*> & theNodeByGhs3dId,
+ vector <const SMDS_MeshNode*> & theEnforcedNodeByGhs3dId,
+ TIDSortedElemSet & theEnforcedEdges,
+ TIDSortedElemSet & theEnforcedTriangles,
+ TIDSortedElemSet & theEnforcedQuadrangles)
{
+ MESSAGE("writeFaces");
// record structure:
//
// NB_ELEMS DUMMY_INT
// NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT
int nbNodes, nbTriangles = 0;
- map< const SMDS_MeshNode*,int >::iterator it;
SMDS_ElemIteratorPtr nodeIt;
- const SMDS_MeshElement* elem;
const char* space = " ";
const int dummyint = 0;
+ int nbEnforcedEdges = theEnforcedEdges.size();
+ int nbEnforcedTriangles = theEnforcedTriangles.size();
+ int nbEnforcedQuadrangles = theEnforcedQuadrangles.size();
// count faces
- nbTriangles = theMesh.NbFaces();
+ nbTriangles = theProxyMesh.NbFaces();
if ( nbTriangles == 0 )
return false;
- std::cout << "The initial 2D mesh contains " << nbTriangles << " faces and ";
+ std::cout << "Start writing in 'faces' file ..." << std::endl;
+ std::cout << std::endl;
+ std::cout << "The initial 2D mesh contains " << nbTriangles << " shapes of 2D dimension and " << std::endl;
+ if (nbEnforcedEdges+nbEnforcedTriangles+nbEnforcedQuadrangles)
+ std::cout << " " << nbEnforcedEdges+nbEnforcedTriangles+nbEnforcedQuadrangles
+ << " enforced shapes:" << std::endl;
+ if (nbEnforcedEdges)
+ 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;
// NB_ELEMS DUMMY_INT
- theFile << space << nbTriangles << space << dummyint << std::endl;
+// theFile << nbTriangles << space << dummyint << std::endl;
+
+ map<const SMDS_MeshNode*,int> aNodeToGhs3dIdMap, anEnforcedNodeToGhs3dIdMap;
+ map< const SMDS_MeshNode*,int >::iterator it;
+ TIDSortedElemSet anElemSet, anEnforcedElemSet;
+ TIDSortedElemSet::iterator elemIt;
+ const SMDS_MeshElement* elem;
+ auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher());
+ bool isOK;
+ const SMDS_MeshNode* node;
+ int usedEnforcedEdges = 0;
+ int usedEnforcedTriangles = 0;
+ int usedEnforcedQuadrangles = 0;
- map<const SMDS_MeshNode*,int> aNodeToGhs3dIdMap;
+ //
+ // FACES : BEGIN
+ //
// Loop from 1 to NB_ELEMS
- SMDS_ElemIteratorPtr eIt = theMesh.GetFaces();
+ SMDS_ElemIteratorPtr eIt = theProxyMesh.GetFaces();
while ( eIt->more() )
{
elem = eIt->next();
- // NB_NODES PER FACE
- nbNodes = elem->NbNodes();
- theFile << space << nbNodes;
-
+ anElemSet.insert(elem);
// NODE_NB_1 NODE_NB_2 ...
nodeIt = elem->nodesIterator();
while ( nodeIt->more() )
// find GHS3D ID
const SMDS_MeshNode* node = castToNode( nodeIt->next() );
int newId = aNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1
- it = aNodeToGhs3dIdMap.insert( make_pair( node, newId )).first;
- theFile << space << it->second;
+ aNodeToGhs3dIdMap.insert( make_pair( node, newId ));
}
+ }
- // (NB_NODES + 1) times: DUMMY_INT
- for ( int i=0; i<=nbNodes; i++)
- theFile << space << dummyint;
- theFile << std::endl;
+ //
+ // FACES : END
+ //
+
+
+ //
+ // ENFORCED EDGES : BEGIN
+ //
+
+ // Iterate over the enforced edges
+ for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) {
+ elem = (*elemIt);
+ isOK = true;
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ node = castToNode( nodeIt->next() );
+ // Test if point is inside shape to mesh
+ gp_Pnt myPoint(node->X(),node->Y(),node->Z());
+ TopAbs_State result = pntCls->GetPointState( myPoint );
+ if ( result != TopAbs_IN ) {
+ isOK = false;
+ break;
+ }
+ }
+ if (isOK) {
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ int newId = aNodeToGhs3dIdMap.size() + anEnforcedNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1
+ anEnforcedNodeToGhs3dIdMap.insert( make_pair( node, newId ));
+ }
+ anEnforcedElemSet.insert(elem);
+ usedEnforcedEdges++;
+ }
+ }
+
+ //
+ // ENFORCED EDGES : END
+ //
+ //
+
+
+ //
+ // ENFORCED TRIANGLES : BEGIN
+ //
+ // Iterate over the enforced triangles
+ for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) {
+ elem = (*elemIt);
+ isOK = true;
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ // Test if point is inside shape to mesh
+ gp_Pnt myPoint(node->X(),node->Y(),node->Z());
+ TopAbs_State result = pntCls->GetPointState( myPoint );
+ if ( result != TopAbs_IN ) {
+ isOK = false;
+ break;
+ }
+ }
+ if (isOK) {
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ int newId = aNodeToGhs3dIdMap.size() + anEnforcedNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1
+ anEnforcedNodeToGhs3dIdMap.insert( make_pair( node, newId ));
+ }
+ anEnforcedElemSet.insert(elem);
+ usedEnforcedTriangles++;
+ }
+ }
+
+ //
+ // ENFORCED TRIANGLES : END
+ //
+
+ //
+ // ENFORCED QUADRANGLES : BEGIN
+ //
+ // Iterate over the enforced quadrangles
+ for(elemIt = theEnforcedQuadrangles.begin() ; elemIt != theEnforcedQuadrangles.end() ; ++elemIt) {
+ elem = (*elemIt);
+ isOK = true;
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ // Test if point is inside shape to mesh
+ gp_Pnt myPoint(node->X(),node->Y(),node->Z());
+ TopAbs_State result = pntCls->GetPointState( myPoint );
+ if ( result != TopAbs_IN ) {
+ isOK = false;
+ break;
+ }
+ }
+ if (isOK) {
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+ int newId = aNodeToGhs3dIdMap.size() + anEnforcedNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1
+ anEnforcedNodeToGhs3dIdMap.insert( make_pair( node, newId ));
+ }
+ anEnforcedElemSet.insert(elem);
+ usedEnforcedQuadrangles++;
+ }
}
+ //
+ // ENFORCED QUADRANGLES : END
+ //
+
+
// put nodes to theNodeByGhs3dId vector
+ std::cout << "aNodeToGhs3dIdMap.size(): "<<aNodeToGhs3dIdMap.size()<<std::endl;
theNodeByGhs3dId.resize( aNodeToGhs3dIdMap.size() );
map<const SMDS_MeshNode*,int>::const_iterator n2id = aNodeToGhs3dIdMap.begin();
for ( ; n2id != aNodeToGhs3dIdMap.end(); ++ n2id)
{
+// std::cout << "n2id->first: "<<n2id->first<<std::endl;
theNodeByGhs3dId[ n2id->second - 1 ] = n2id->first; // ghs3d ids count from 1
}
+ // put nodes to theNodeByGhs3dId vector
+ std::cout << "anEnforcedNodeToGhs3dIdMap.size(): "<<anEnforcedNodeToGhs3dIdMap.size()<<std::endl;
+ theEnforcedNodeByGhs3dId.resize( anEnforcedNodeToGhs3dIdMap.size() );
+ n2id = anEnforcedNodeToGhs3dIdMap.begin();
+ for ( ; n2id != anEnforcedNodeToGhs3dIdMap.end(); ++ n2id)
+ {
+// std::cout << "n2id->first: "<<n2id->first<<std::endl;
+ theEnforcedNodeByGhs3dId[ n2id->second - aNodeToGhs3dIdMap.size() - 1 ] = n2id->first; // ghs3d ids count from 1
+ }
+
+ std::cout << "anElemSet.size(): " << anElemSet.size() << std::endl;
+ std::cout << "anEnforcedElemSet.size(): " << anEnforcedElemSet.size() << std::endl;
+ theFile << anElemSet.size() + anEnforcedElemSet.size() << space << "0" << std::endl;
+ for(elemIt = anElemSet.begin() ; elemIt != anElemSet.end() ; ++elemIt) {
+ elem = (*elemIt);
+ theFile << elem->NbNodes() << space ;
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ node = castToNode( nodeIt->next() );
+ it = aNodeToGhs3dIdMap.find(node);
+ if (it == aNodeToGhs3dIdMap.end())
+ throw "Node not found";
+
+ theFile << it->second << space ;
+ }
+ for ( int j=0; j<=elem->NbNodes(); j++)
+ theFile << dummyint << space ;
+ theFile << std::endl;
+ }
+ for(elemIt = anEnforcedElemSet.begin() ; elemIt != anEnforcedElemSet.end() ; ++elemIt) {
+ elem = (*elemIt);
+ theFile << elem->NbNodes() << space ;
+ nodeIt = elem->nodesIterator();
+ while ( nodeIt->more() ) {
+ // find GHS3D ID
+ node = castToNode( nodeIt->next() );
+ it = anEnforcedNodeToGhs3dIdMap.find(node);
+ if (it == anEnforcedNodeToGhs3dIdMap.end())
+ throw "Node not found";
+
+ theFile << it->second << space ;
+ }
+ for ( int j=0; j<=elem->NbNodes(); j++)
+ theFile << dummyint << space ;
+ theFile << std::endl;
+ }
+
return true;
}
+
//=======================================================================
//function : writePoints
//purpose :
static bool writePoints (ofstream & theFile,
SMESH_MesherHelper& theHelper,
map <int,int> & theSmdsToGhs3dIdMap,
+ map <int,int> & theEnforcedNodeIdToGhs3dIdMap,
map <int,const SMDS_MeshNode*> & theGhs3dIdToNodeMap,
- map<vector<double>,double> & theEnforcedVertices)
+ GHS3DPlugin_Hypothesis::TID2SizeMap & theNodeIDToSizeMap,
+ GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices,
+ TIDSortedNodeSet & theEnforcedNodes)
{
// record structure:
//
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
std::cout << std::endl;
std::cout << "The initial 2D mesh contains :" << std::endl;
std::cout << " " << nbNodes << " nodes" << std::endl;
- if (nbEnforcedVertices > 0) {
+ if (nbEnforcedVertices > 0)
std::cout << " " << nbEnforcedVertices << " enforced vertices" << std::endl;
- }
- std::cout << std::endl;
- std::cout << "Start writing in 'points' file ..." << std::endl;
- theFile << space << nbNodes << std::endl;
+ if (nbEnforcedNodes > 0)
+ std::cout << " " << nbEnforcedNodes << " enforced nodes" << std::endl;
+
+// std::cout << std::endl;
+// std::cout << "Start writing in 'points' file ..." << std::endl;
+ theFile << nbNodes << space << std::endl;
// Loop from 1 to NB_NODES
// X Y Z DUMMY_INT
theFile
- << space << node->X()
- << space << node->Y()
- << space << node->Z()
- << space << dummyint;
-
+ << 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 = theMesh->ShapeToMesh();
- 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
- << space << x
- << space << y
- << space << z
- << space << vertexIt->second
- << space << dummyint;
-
- theFile << std::endl;
+ // Iterate over the enforced nodes
+ TIDSortedNodeSet::const_iterator nodeIt;
+ std::map<int,double> enfVertexIndexSizeMap;
+ if (nbEnforcedNodes) {
+ 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(theMesh->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)->GetID())->second;
+ // theGhs3dIdToNodeMap.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
+ << size << space
+ << dummyint << space;
+ theFile << std::endl;
+ theEnforcedNodeIdToGhs3dIdMap.insert( make_pair( (*nodeIt)->GetID(), aGhs3dID ));
+ enfVertexIndexSizeMap[aGhs3dID] = -1;
+ aGhs3dID++;
+ // else
+ // MESSAGE("Enforced vertex (" << x << "," << y <<"," << z << ") is not inside the geometry: it was not added ");
+ }
+ }
+
+ if (nbEnforcedVertices) {
+ // Iterate over the enforced vertices
+ GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
+// 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(theMesh->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[aGhs3dID] = vertexIt->second;
+ aGhs3dID++;
+
+ // else
+ // MESSAGE("Enforced vertex (" << x << "," << y <<"," << z << ") is not inside the geometry: it was not added ");
}
- 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 in 'points' file." << std::endl;
+// std::cout << std::endl;
+// std::cout << "End writing in 'points' file." << std::endl;
return true;
}
static bool writePoints (ofstream & theFile,
SMESH_Mesh * theMesh,
const vector <const SMDS_MeshNode*> & theNodeByGhs3dId,
- map<vector<double>,double> & theEnforcedVertices)
+ const vector <const SMDS_MeshNode*> & theEnforcedNodeByGhs3dId,
+ GHS3DPlugin_Hypothesis::TID2SizeMap & theNodeIDToSizeMap,
+ GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices,
+ TIDSortedNodeSet & theEnforcedNodes)
{
// record structure:
//
return false;
int nbEnforcedVertices = theEnforcedVertices.size();
+ int nbEnforcedNodes = theEnforcedNodes.size();
const char* space = " ";
const int dummyint = 0;
const SMDS_MeshNode* node;
+ std::set< std::vector<double> > nodesCoords;
// NB_NODES
- std::cout << std::endl;
- std::cout << "The initial 2D mesh contains :" << std::endl;
+// std::cout << std::endl;
+// std::cout << "The initial 2D mesh contains :" << std::endl;
std::cout << " " << nbNodes << " nodes" << std::endl;
- std::cout << " " << nbEnforcedVertices << " enforced vertices" << std::endl;
+ if (nbEnforcedVertices > 0)
+ std::cout << " " << nbEnforcedVertices << " enforced vertices" << std::endl;
+ if (nbEnforcedNodes > 0)
+ std::cout << " " << nbEnforcedNodes << " enforced nodes" << std::endl;
std::cout << std::endl;
std::cout << "Start writing in 'points' file ..." << std::endl;
- theFile << space << nbNodes << std::endl;
+ theFile << nbNodes << space << std::endl;
// Loop from 1 to NB_NODES
vector<const SMDS_MeshNode*>::const_iterator nodeIt = theNodeByGhs3dId.begin();
vector<const SMDS_MeshNode*>::const_iterator after = theNodeByGhs3dId.end();
+
+ std::cout << theNodeByGhs3dId.size() << " nodes from mesh ..." << std::endl;
for ( ; nodeIt != after; ++nodeIt )
{
node = *nodeIt;
// X Y Z DUMMY_INT
theFile
- << space << node->X()
- << space << node->Y()
- << space << node->Z()
- << space << dummyint;
+ << node->X() << space
+ << node->Y() << space
+ << node->Z() << space
+ << dummyint << std::endl;
+
+ std::vector<double> coords;
+ coords.push_back(node->X());
+ coords.push_back(node->Y());
+ coords.push_back(node->Z());
+ nodesCoords.insert(coords);
+ }
+
+ if (nbEnforcedNodes) {
+ std::cout << theEnforcedNodes.size() << " nodes from enforced nodes ..." << std::endl;
+ // Iterate over the enforced nodes
+ TIDSortedNodeSet::const_iterator enfNodeIt;
+ auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher());
+ for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt)
+ {
+ node = *enfNodeIt;
+
+ std::vector<double> coords;
+ coords.push_back(node->X());
+ coords.push_back(node->Y());
+ coords.push_back(node->Z());
+
+ if (nodesCoords.find(coords) != nodesCoords.end()) {
+ std::cout << "Node at " << node->X()<<", " <<node->Y()<<", " <<node->Z() << " found" << std::endl;
+ continue;
+ }
- theFile << std::endl;
+ if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
+ continue;
+ // Test if point is inside shape to mesh
+ gp_Pnt myPoint(node->X(),node->Y(),node->Z());
+ TopAbs_State result = pntCls->GetPointState( myPoint );
+ if ( result != TopAbs_IN )
+ continue;
+ // X Y Z DUMMY_INT
+ theFile
+ << node->X() << space
+ << node->Y() << space
+ << node->Z() << space
+ << theNodeIDToSizeMap.find(node->GetID())->second << space
+ << dummyint << std::endl;
+
+ nodesCoords.insert(coords);
+ }
}
- // Iterate over the enforced vertices
- GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
- auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher());
- 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);
- TopAbs_State result = pntCls->GetPointState( myPoint );
- if ( result == TopAbs_IN ) {
- std::cout << "Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second << std::endl;
-
- // X Y Z PHY_SIZE DUMMY_INT
- theFile
- << space << x
- << space << y
- << space << z
- << space << vertexIt->second
- << space << dummyint;
+ if (theEnforcedNodeByGhs3dId.size()) {
+ std::cout << theEnforcedNodeByGhs3dId.size() << " nodes from enforced elements ..." << std::endl;
+ // Iterate over the enforced nodes given by enforced elements
+ nodeIt = theEnforcedNodeByGhs3dId.begin();
+ after = theEnforcedNodeByGhs3dId.end();
+ for ( ; nodeIt != after; ++nodeIt )
+ {
+ node = *nodeIt;
+
+ std::vector<double> coords;
+ coords.push_back(node->X());
+ coords.push_back(node->Y());
+ coords.push_back(node->Z());
+
+ if (nodesCoords.find(coords) != nodesCoords.end()) {
+ std::cout << "Node at " << node->X()<<", " <<node->Y()<<", " <<node->Z() << " found" << std::endl;
+ continue;
+ }
+
+ if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
+ continue;
+
+ // X Y Z DUMMY_INT
+ theFile
+ << node->X() << space
+ << node->Y() << space
+ << node->Z() << space
+ << theNodeIDToSizeMap.find(node->GetID())->second << space
+ << dummyint << std::endl;
+
+ nodesCoords.insert(coords);
+ }
+ }
+
+ if (nbEnforcedVertices) {
+ std::cout << theEnforcedVertices.size() << " nodes from enforced vertices ..." << std::endl;
+ // Iterate over the enforced vertices
+ GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
+ auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher());
+ 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);
+ TopAbs_State result = pntCls->GetPointState( myPoint );
+ if ( result != TopAbs_IN )
+ continue;
+ std::cout << "Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second << std::endl;
+
+ // X Y Z PHY_SIZE DUMMY_INT
+ theFile
+ << x << space
+ << y << space
+ << z << space
+ << vertexIt->second << space
+ << dummyint << std::endl;
+
+ std::vector<double> coords;
+ coords.push_back(x);
+ coords.push_back(y);
+ coords.push_back(z);
+ nodesCoords.insert(coords);
- theFile << std::endl;
}
}
+
std::cout << std::endl;
std::cout << "End writing in 'points' file." << std::endl;
const int nbShape,
map <int,const SMDS_MeshNode*>& theGhs3dIdToNodeMap,
bool toMeshHoles,
- int nbEnforcedVertices)
+ int nbEnforcedVertices,
+ int nbEnforcedNodes,
+ TIDSortedElemSet & theEnforcedEdges,
+ TIDSortedElemSet & theEnforcedTriangles,
+ TIDSortedElemSet & theEnforcedQuadrangles)
{
MESSAGE("GHS3DPlugin_GHS3D::readResultFile()");
Kernel_Utils::Localizer loc;
for (int i=0; i < 4*nbElems; i++)
nodeId = strtol(ptr, &ptr, 10);
- MESSAGE("nbInputNodes: "<<nbInputNodes);
- MESSAGE("nbEnforcedVertices: "<<nbEnforcedVertices);
// Reading the nodeCoor and update the nodeMap
for (int iNode=1; iNode <= nbNodes; iNode++) {
for (int iCoor=0; iCoor < 3; iCoor++)
coord[ iCoor ] = strtod(ptr, &ptr);
nodeAssigne[ iNode ] = 1;
- if ( iNode > (nbInputNodes-nbEnforcedVertices) ) {
+ if ( iNode > (nbInputNodes-(nbEnforcedVertices+nbEnforcedNodes)) ) {
// Creating SMESH nodes
// - for enforced vertices
// - for vertices of forced edges
SMESH_Mesh& theMesh,
TopoDS_Shape aSolid,
vector <const SMDS_MeshNode*>& theNodeByGhs3dId,
- int nbEnforcedVertices)
+ vector <const SMDS_MeshNode*>& theEnforcedNodeByGhs3dId,
+ int nbEnforcedVertices,
+ int nbEnforcedNodes,
+ TIDSortedElemSet & theEnforcedEdges,
+ TIDSortedElemSet & theEnforcedTriangles,
+ TIDSortedElemSet & theEnforcedQuadrangles)
{
SMESHDS_Mesh* theMeshDS = theMesh.GetMeshDS();
for (int iNode=0; iNode < nbNodes; iNode++) {
for (int iCoor=0; iCoor < 3; iCoor++)
coord[ iCoor ] = strtod(ptr, &ptr);
- if ((iNode+1) > (nbInputNodes-nbEnforcedVertices)) {
+ if ((iNode+1) > (nbInputNodes-(nbEnforcedVertices+nbEnforcedNodes+theEnforcedNodeByGhs3dId.size()))) {
// Issue 0020682. Avoid creating nodes and tetras at place where
// volumic elements already exist
if ( elemSearcher &&
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
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();
+ aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open()
+ /*&& aGMFFile.rdbuf()->is_open()
+ && aSolFile.rdbuf()->is_open()*/;
if (!Ok) {
INFOS( "Can't write into " << aFacesFileName);
return error(SMESH_Comment("Can't write into ") << aFacesFileName);
}
- map <int,int> aSmdsToGhs3dIdMap;
+ map <int,int> aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap;
map <int,const SMDS_MeshNode*> aGhs3dIdToNodeMap;
- map<vector<double>,double> enforcedVertices;
- int nbEnforcedVertices = 0;
- try {
- enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp);
- nbEnforcedVertices = enforcedVertices.size();
- }
- catch(...) {
- }
+ std::map <int, int> nodeID2nodeIndexMap;
+ GHS3DPlugin_Hypothesis::TEnforcedVertexValues enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp);
+ TIDSortedNodeSet enforcedNodes = GHS3DPlugin_Hypothesis::GetEnforcedNodes(_hyp);
+ TIDSortedElemSet enforcedEdges = GHS3DPlugin_Hypothesis::GetEnforcedEdges(_hyp);
+ TIDSortedElemSet enforcedTriangles = GHS3DPlugin_Hypothesis::GetEnforcedTriangles(_hyp);
+ 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;
}
-
- Ok = (writePoints( aPointsFile, helper, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap, enforcedVertices)
+// #if GHS3D_VERSION >= 42
+ Ok = writeGMFFile(aGMFFileName, aRequiredVerticesFileName, aSolFileName, 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
+ Ok = (writePoints( aPointsFile, helper,
+ aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap, aGhs3dIdToNodeMap,
+ nodeIDToSizeMap,
+ enforcedVertices, enforcedNodes)
&&
- writeFaces ( aFacesFile, *proxyMesh, theShape, aSmdsToGhs3dIdMap ));
+ writeFaces ( aFacesFile, *proxyMesh, theShape,
+ aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap,
+ enforcedEdges, enforcedTriangles, enforcedQuadrangles));
+// #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;
aIdsFile << myit->first << " " << myit->second << std::endl;
}
+// aGMFFile.close();
+// aSolFile.close();
aFacesFile.close();
aPointsFile.close();
aIdsFile.close();
// run ghs3d mesher
// -----------------
- TCollection_AsciiString cmd( (char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() );
+ TCollection_AsciiString cmd = TCollection_AsciiString((char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() );
+#if GHS3D_VERSION >= 42
+ cmd += TCollection_AsciiString(" --in ") + aGenericName;
+ cmd += TCollection_AsciiString(" --required_vertices ") + aRequiredVerticesFileName;
+ cmd += TCollection_AsciiString(" --out ") + aGenericName;
+#else
cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read
- cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file
+#endif
+ cmd += TCollection_AsciiString(" -Om 1>" ) + aLogFileName; // dump into file
std::cout << std::endl;
std::cout << "Ghs3d execution..." << std::endl;
aResultFileName.ToCString(),
#endif
theMesh, tabShape, tabBox, _nbShape, aGhs3dIdToNodeMap,
- toMeshHoles, nbEnforcedVertices );
+ toMeshHoles,
+ nbEnforcedVertices, nbEnforcedNodes,
+ enforcedEdges, enforcedTriangles, enforcedQuadrangles );
}
// ---------------------
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
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);
bool Ok =
- aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open();
+ aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open()
+ /*&& aGMFFile.rdbuf()->is_open()
+ && aSolFile.rdbuf()->is_open()*/;
- if (!Ok)
- return error( SMESH_Comment("Can't write into ") << aPointsFileName);
-
- GHS3DPlugin_Hypothesis::TEnforcedVertexValues enforcedVertices;
- int nbEnforcedVertices = 0;
- try {
- enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp);
- nbEnforcedVertices = enforcedVertices.size();
- }
- catch(...) {
+ if (!Ok) {
+ INFOS( "Can't write into " << aFacesFileName);
+ return error( SMESH_Comment("Can't write into ") << aFacesFileName);
}
+
+ std::map <int, int> nodeID2nodeIndexMap;
+ GHS3DPlugin_Hypothesis::TEnforcedVertexValues enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp);
+ TIDSortedNodeSet enforcedNodes = GHS3DPlugin_Hypothesis::GetEnforcedNodes(_hyp);
+ TIDSortedElemSet enforcedEdges = GHS3DPlugin_Hypothesis::GetEnforcedEdges(_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;
+
+ vector <const SMDS_MeshNode*> aNodeByGhs3dId, anEnforcedNodeByGhs3dId;
{
SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh ));
if ( theMesh.NbQuadrangles() > 0 )
proxyMesh.reset( aQuad2Trias );
}
- Ok = (writeFaces ( aFacesFile, *proxyMesh, aNodeByGhs3dId ) &&
- writePoints( aPointsFile, &theMesh, aNodeByGhs3dId,enforcedVertices));
+// #if GHS3D_VERSION >= 42
+ Ok = writeGMFFile(aGMFFileName, aRequiredVerticesFileName, aSolFileName, *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
}
+
+ int nbEnforcedNodes = enforcedNodes.size();
+ int nbEnforcedEdges = enforcedEdges.size();
+ int nbEnforcedTriangles = enforcedTriangles.size();
+ int nbEnforcedQuadrangles = enforcedQuadrangles.size();
+
+// aGMFFile.close();
+// aSolFile.close();
aFacesFile.close();
aPointsFile.close();
// run ghs3d mesher
// -----------------
- TCollection_AsciiString cmd =
- (char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp, false ).c_str();
+ 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;
+#else
cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read
- cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file
+#endif
+ cmd += TCollection_AsciiString(" -Om 1>" ) + aLogFileName; // dump into file
+
+ std::cout << std::endl;
+ std::cout << "Ghs3d execution..." << std::endl;
+ std::cout << cmd << std::endl;
system( cmd.ToCString() ); // run
+ std::cout << std::endl;
+ std::cout << "End of Ghs3d execution !" << std::endl;
+
// --------------
// read a result
// --------------
#ifdef WNT
aResultFileName.ToCString(),
#endif
- theMesh, theShape ,aNodeByGhs3dId, nbEnforcedVertices );
+ theMesh, theShape ,aNodeByGhs3dId, anEnforcedNodeByGhs3dId,
+ nbEnforcedVertices, nbEnforcedNodes,
+ enforcedEdges, enforcedTriangles, enforcedQuadrangles );
}
// ---------------------