-static bool readResult(FILE * theFile,
- SMESHDS_Mesh * theMesh,
- const TopoDS_Shape& theShape,
- map <int,const SMDS_MeshNode*>& theGhs3dIdToNodeMap)
-{
- // structure:
-
- // record 1:
- // NB_ELEMENTS NB_NODES NB_INPUT_NODES (14 DUMMY_INT)
- // record 2:
- // (NB_ELEMENTS * 4) node nbs
- // record 3:
- // (NB_NODES) node XYZ
-
- char aBuffer[ GHS3DPlugin_BUFLENGTH ];
- char * aPtr;
- int aLineNb = 0;
-
- // get shell to set nodes in
- TopExp_Explorer exp( theShape, TopAbs_SHELL );
- TopoDS_Shell aShell = TopoDS::Shell( exp.Current() );
- if ( aShell.IsNull() )
- return false;
+static bool readResultFile(const int fileOpen,
+ SMESHDS_Mesh* theMeshDS,
+ TopoDS_Shape tabShape[],
+ double tabBox[][6],
+ const int nShape,
+ vector <const SMDS_MeshNode*>& theNodeByGhs3dId) {
+
+ struct stat status;
+ size_t length;
+
+ char *ptr, *mapPtr;
+ char *tetraPtr;
+ char *shapePtr;
+
+ int fileStat;
+ int nbElems, nbNodes, nbInputNodes;
+ int nodeId, triangleId;
+ int tab[3]/*, tabID[nShape]*/;
+ int nbTriangle;
+ int ID, shapeID, ghs3dShapeID;
+
+ double coord [3];
+ vector< int > tabID (nShape, 0);
+
+ TopoDS_Shape aSolid;
+ SMDS_MeshNode * aNewNode;
+ const SMDS_MeshNode * node[4];
+ map <int,const SMDS_MeshNode*>::iterator IdNode;
+ SMDS_MeshElement* aTet;
+
+// for (int i=0; i<nShape; i++)
+// tabID[i] = 0;
+
+ // Read the file state
+ fileStat = fstat(fileOpen, &status);
+ length = status.st_size;
+
+ // Mapping the result file into memory
+ ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0);
+ mapPtr = ptr;
+
+ ptr = readMapIntLine(ptr, tab);
+ tetraPtr = ptr;
+
+ nbElems = tab[0];
+ nbNodes = tab[1];
+ nbInputNodes = tab[2];
+
+ theNodeByGhs3dId.resize( nbNodes );
+
+ // Reading the nodeId
+ for (int i=0; i < 4*nbElems; i++)
+ nodeId = strtol(ptr, &ptr, 10);
+
+ // Reading the nodeCoor and update the nodeMap
+ for (int iNode=0; iNode < nbNodes; iNode++) {
+ for (int iCoor=0; iCoor < 3; iCoor++)
+ coord[ iCoor ] = strtod(ptr, &ptr);
+ if ((iNode+1) > nbInputNodes) {
+ aNewNode = theMeshDS->AddNode( coord[0],coord[1],coord[2] );
+ theNodeByGhs3dId[ iNode ] = aNewNode;
+ }
+ }