return meshDS->ShapeToIndex( solids(2) );
}
-// //=======================================================================
-// //function : countShape
-// //purpose :
-// //=======================================================================
-//
-// template < class Mesh, class Shape >
-// static int countShape( Mesh* mesh, Shape shape ) {
-// TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape );
-// TopTools_MapOfShape mapShape;
-// int nbShape = 0;
-// for ( ; expShape.More(); expShape.Next() ) {
-// if (mapShape.Add(expShape.Current())) {
-// nbShape++;
-// }
-// }
-// return nbShape;
-// }
-//
-// //=======================================================================
-// //function : getShape
-// //purpose :
-// //=======================================================================
-//
-// template < class Mesh, class Shape, class Tab >
-// void getShape(Mesh* mesh, Shape shape, Tab *t_Shape) {
-// TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape );
-// TopTools_MapOfShape mapShape;
-// for ( int i=0; expShape.More(); expShape.Next() ) {
-// if (mapShape.Add(expShape.Current())) {
-// t_Shape[i] = expShape.Current();
-// i++;
-// }
-// }
-// return;
-// }
-//
-// // //=======================================================================
-// // //function : findEdgeID
-// // //purpose :
-// // //=======================================================================
-//
-// static int findEdgeID(const SMDS_MeshNode* aNode,
-// const SMESHDS_Mesh* theMesh,
-// const int nEdge,
-// const TopoDS_Shape* t_Edge) {
-//
-// TopoDS_Shape aPntShape, foundEdge;
-// TopoDS_Vertex aVertex;
-// gp_Pnt aPnt( aNode->X(), aNode->Y(), aNode->Z() );
-//
-// int foundInd, ind;
-// double nearest = RealLast(), *t_Dist;
-// double epsilon = Precision::Confusion();
-//
-// t_Dist = new double[ nEdge ];
-// aPntShape = BRepBuilderAPI_MakeVertex( aPnt ).Shape();
-// aVertex = TopoDS::Vertex( aPntShape );
-//
-// for ( ind=0; ind < nEdge; ind++ ) {
-// BRepExtrema_DistShapeShape aDistance ( aVertex, t_Edge[ind] );
-// t_Dist[ind] = aDistance.Value();
-// if ( t_Dist[ind] < nearest ) {
-// nearest = t_Dist[ind];
-// foundEdge = t_Edge[ind];
-// foundInd = ind;
-// if ( nearest < epsilon )
-// ind = nEdge;
-// }
-// }
-//
-// delete [] t_Dist;
-// return theMesh->ShapeToIndex( foundEdge );
-// }
-//
-//
-// // =======================================================================
-// // function : readGMFFile
-// // purpose : read GMF file with geometry associated to mesh
-// // =======================================================================
-//
-// static bool readGMFFile(const int fileOpen,
-// const char* theFileName,
-// SMESH_Mesh& theMesh,
-// const int nbShape,
-// const TopoDS_Shape* tabShape,
-// double** tabBox,
-// map <int,const SMDS_MeshNode*>& theHybridIdToNodeMap,
-// bool toMeshHoles,
-// int nbEnforcedVertices,
-// int nbEnforcedNodes)
-// {
-// TopoDS_Shape aShape;
-// TopoDS_Vertex aVertex;
-// SMESHDS_Mesh* theMeshDS = theMesh.GetMeshDS();
-// int nbElem = 0, nbRef = 0, IdShapeRef = 1;
-// int *tabID;
-// int aGMFNodeID = 0;
-// int compoundID =
-// nbShape ? theMeshDS->ShapeToIndex( tabShape[0] ) : theMeshDS->ShapeToIndex( theMeshDS->ShapeToMesh() );
-// int tetraShapeID = compoundID;
-// double epsilon = Precision::Confusion();
-// int *nodeAssigne, *GMFNodeAssigne;
-// SMDS_MeshNode** GMFNode;
-// TopoDS_Shape *tabCorner, *tabEdge;
-// std::map <GmfKwdCod,int> tabRef;
-//
-//
-// int ver, dim;
-// MESSAGE("Read " << theFileName << " file");
-// int InpMsh = GmfOpenMesh(theFileName, GmfRead, &ver, &dim);
-// if (!InpMsh)
-// return false;
-//
-// // ===========================
-// // Fill the tabID array: BEGIN
-// // ===========================
-//
-// /*
-// The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2)
-// */
-// Kernel_Utils::Localizer loc;
-// struct stat status;
-// size_t length;
-//
-// char *ptr, *mapPtr;
-// char *tetraPtr;
-// int *tab = new int[3];
-//
-// // Read the file state
-// fstat(fileOpen, &status);
-// length = status.st_size;
-//
-// // Mapping the result file into memory
-// #ifdef WIN32
-// HANDLE fd = CreateFile(theFileName, GENERIC_READ, FILE_SHARE_READ,
-// NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-// HANDLE hMapObject = CreateFileMapping(fd, NULL, PAGE_READONLY,
-// 0, (DWORD)length, NULL);
-// ptr = ( char* ) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0 );
-// #else
-// ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0);
-// #endif
-// mapPtr = ptr;
-//
-// ptr = readMapIntLine(ptr, tab);
-// tetraPtr = ptr;
-//
-// nbElem = tab[0];
-// int nbNodes = tab[1];
-//
-// for (int i=0; i < 4*nbElem; i++)
-// strtol(ptr, &ptr, 10);
-//
-// for (int iNode=1; iNode <= nbNodes; iNode++)
-// for (int iCoor=0; iCoor < 3; iCoor++)
-// strtod(ptr, &ptr);
-//
-//
-// // Reading the number of triangles which corresponds to the number of sub-domains
-// int nbTriangle = strtol(ptr, &ptr, 10);
-//
-//
-// // The keyword does not exist yet => to update when it is created
-// // int nbSubdomains = GmfStatKwd(InpMsh, GmfSubdomain);
-// // int id_tri[3];
-//
-//
-// tabID = new int[nbTriangle];
-// for (int i=0; i < nbTriangle; i++) {
-// tabID[i] = 0;
-// int nodeId1, nodeId2, nodeId3;
-// // find the solid corresponding to HYBRID sub-domain following
-// // the technique proposed in HYBRID manual in chapter
-// // "B.4 Subdomain (sub-region) assignment"
-//
-// nodeId1 = strtol(ptr, &ptr, 10);
-// nodeId2 = strtol(ptr, &ptr, 10);
-// nodeId3 = strtol(ptr, &ptr, 10);
-//
-// // // The keyword does not exist yet => to update when it is created
-// // GmfGetLin(InpMsh, GmfSubdomain, &id_tri[0], &id_tri[1], &id_tri[2]);
-// // nodeId1 = id_tri[0];
-// // nodeId2 = id_tri[1];
-// // nodeId3 = id_tri[2];
-//
-// if ( nbTriangle > 1 ) {
-// // get the nodes indices
-// const SMDS_MeshNode* n1 = theHybridIdToNodeMap[ nodeId1 ];
-// const SMDS_MeshNode* n2 = theHybridIdToNodeMap[ nodeId2 ];
-// const SMDS_MeshNode* n3 = theHybridIdToNodeMap[ nodeId3 ];
-// try {
-// OCC_CATCH_SIGNALS;
-// tabID[i] = findShapeID( theMesh, n1, n2, n3, toMeshHoles );
-// // -- 0020330: Pb with hybrid as a submesh
-// // check that found shape is to be meshed
-// if ( tabID[i] > 0 ) {
-// const TopoDS_Shape& foundShape = theMeshDS->IndexToShape( tabID[i] );
-// bool isToBeMeshed = false;
-// for ( int iS = 0; !isToBeMeshed && iS < nbShape; ++iS )
-// isToBeMeshed = foundShape.IsSame( tabShape[ iS ]);
-// if ( !isToBeMeshed )
-// tabID[i] = HOLE_ID;
-// }
-// // END -- 0020330: Pb with hybrid as a submesh
-// #ifdef _DEBUG_
-// std::cout << i+1 << " subdomain: findShapeID() returns " << tabID[i] << std::endl;
-// #endif
-// }
-// catch ( Standard_Failure & ex)
-// {
-// #ifdef _DEBUG_
-// std::cout << i+1 << " subdomain: Exception caugt: " << ex.GetMessageString() << std::endl;
-// #endif
-// }
-// catch (...) {
-// #ifdef _DEBUG_
-// std::cout << i+1 << " subdomain: unknown exception caught " << std::endl;
-// #endif
-// }
-// }
-// }
-//
-// // ===========================
-// // Fill the tabID array: END
-// // ===========================
-//
-//
-// tabRef[GmfVertices] = 3;
-// tabRef[GmfCorners] = 1;
-// tabRef[GmfEdges] = 2;
-// tabRef[GmfRidges] = 1;
-// tabRef[GmfTriangles] = 3;
-// // tabRef[GmfQuadrilaterals] = 4;
-// tabRef[GmfTetrahedra] = 4;
-// // tabRef[GmfHexahedra] = 8;
-//
-// SMDS_NodeIteratorPtr itOnGMFInputNode = theMeshDS->nodesIterator();
-// while ( itOnGMFInputNode->more() )
-// theMeshDS->RemoveNode( itOnGMFInputNode->next() );
-//
-//
-// int nbVertices = GmfStatKwd(InpMsh, GmfVertices);
-// int nbCorners = max(countShape( theMeshDS, TopAbs_VERTEX ) , GmfStatKwd(InpMsh, GmfCorners));
-// int nbShapeEdge = countShape( theMeshDS, TopAbs_EDGE );
-//
-// tabCorner = new TopoDS_Shape[ nbCorners ];
-// tabEdge = new TopoDS_Shape[ nbShapeEdge ];
-// nodeAssigne = new int[ nbVertices + 1 ];
-// GMFNodeAssigne = new int[ nbVertices + 1 ];
-// GMFNode = new SMDS_MeshNode*[ nbVertices + 1 ];
-//
-// getShape(theMeshDS, TopAbs_VERTEX, tabCorner);
-// getShape(theMeshDS, TopAbs_EDGE, tabEdge);
-//
-// std::map <GmfKwdCod,int>::const_iterator it = tabRef.begin();
-// for ( ; it != tabRef.end() ; ++it)
-// {
-// // int dummy;
-// GmfKwdCod token = it->first;
-// nbRef = it->second;
-//
-// nbElem = GmfStatKwd(InpMsh, token);
-// if (nbElem > 0) {
-// GmfGotoKwd(InpMsh, token);
-// std::cout << "Read " << nbElem;
-// }
-// else
-// continue;
-//
-// int id[nbElem*tabRef[token]];
-// int hybridShapeID[nbElem];
-//
-// if (token == GmfVertices) {
-// std::cout << " vertices" << std::endl;
-// int aGMFID;
-//
-// float VerTab_f[nbElem][3];
-// double VerTab_d[nbElem][3];
-// SMDS_MeshNode * aGMFNode;
-//
-// for ( int iElem = 0; iElem < nbElem; iElem++ ) {
-// aGMFID = iElem + 1;
-// if (ver == GmfFloat) {
-// GmfGetLin(InpMsh, token, &VerTab_f[nbElem][0], &VerTab_f[nbElem][1], &VerTab_f[nbElem][2], &hybridShapeID[iElem]);
-// aGMFNode = theMeshDS->AddNode(VerTab_f[nbElem][0], VerTab_f[nbElem][1], VerTab_f[nbElem][2]);
-// }
-// else {
-// GmfGetLin(InpMsh, token, &VerTab_d[nbElem][0], &VerTab_d[nbElem][1], &VerTab_d[nbElem][2], &hybridShapeID[iElem]);
-// aGMFNode = theMeshDS->AddNode(VerTab_d[nbElem][0], VerTab_d[nbElem][1], VerTab_d[nbElem][2]);
-// }
-// GMFNode[ aGMFID ] = aGMFNode;
-// nodeAssigne[ aGMFID ] = 0;
-// GMFNodeAssigne[ aGMFID ] = 0;
-// }
-// }
-// else if (token == GmfCorners && nbElem > 0) {
-// std::cout << " corners" << std::endl;
-// for ( int iElem = 0; iElem < nbElem; iElem++ )
-// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]);
-// }
-// else if (token == GmfRidges && nbElem > 0) {
-// std::cout << " ridges" << std::endl;
-// for ( int iElem = 0; iElem < nbElem; iElem++ )
-// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]);
-// }
-// else if (token == GmfEdges && nbElem > 0) {
-// std::cout << " edges" << std::endl;
-// for ( int iElem = 0; iElem < nbElem; iElem++ )
-// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &hybridShapeID[iElem]);
-// }
-// else if (token == GmfTriangles && nbElem > 0) {
-// std::cout << " triangles" << std::endl;
-// for ( int iElem = 0; iElem < nbElem; iElem++ )
-// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &hybridShapeID[iElem]);
-// }
-// // else if (token == GmfQuadrilaterals && nbElem > 0) {
-// // std::cout << " Quadrilaterals" << std::endl;
-// // for ( int iElem = 0; iElem < nbElem; iElem++ )
-// // GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], &hybridShapeID[iElem]);
-// // }
-// else if (token == GmfTetrahedra && nbElem > 0) {
-// std::cout << " Tetrahedra" << std::endl;
-// for ( int iElem = 0; iElem < nbElem; iElem++ )
-// GmfGetLin(InpMsh, token,
-// &id[iElem*tabRef[token]],
-// &id[iElem*tabRef[token]+1],
-// &id[iElem*tabRef[token]+2],
-// &id[iElem*tabRef[token]+3],
-// &hybridShapeID[iElem]);
-// }
-// // else if (token == GmfHexahedra && nbElem > 0) {
-// // std::cout << " Hexahedra" << std::endl;
-// // for ( int iElem = 0; iElem < nbElem; iElem++ )
-// // GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3],
-// // &id[iElem*tabRef[token]+4], &id[iElem*tabRef[token]+5], &id[iElem*tabRef[token]+6], &id[iElem*tabRef[token]+7], &hybridShapeID[iElem]);
-// // }
-//
-// switch (token) {
-// case GmfCorners:
-// case GmfRidges:
-// case GmfEdges:
-// case GmfTriangles:
-// // case GmfQuadrilaterals:
-// case GmfTetrahedra:
-// // case GmfHexahedra:
-// {
-// int nodeDim, shapeID, *nodeID;
-// const SMDS_MeshNode** node;
-// // std::vector< SMDS_MeshNode* > enfNode( nbRef );
-// SMDS_MeshElement * aGMFElement;
-//
-// node = new const SMDS_MeshNode*[nbRef];
-// nodeID = new int[ nbRef ];
-//
-// for ( int iElem = 0; iElem < nbElem; iElem++ )
-// {
-// for ( int iRef = 0; iRef < nbRef; iRef++ )
-// {
-// aGMFNodeID = id[iElem*tabRef[token]+iRef]; // read nbRef aGMFNodeID
-// node [ iRef ] = GMFNode[ aGMFNodeID ];
-// nodeID[ iRef ] = aGMFNodeID;
-// }
-//
-// switch (token)
-// {
-// case GmfCorners: {
-// nodeDim = 1;
-// gp_Pnt GMFPnt ( node[0]->X(), node[0]->Y(), node[0]->Z() );
-// for ( int i=0; i<nbElem; i++ ) {
-// aVertex = TopoDS::Vertex( tabCorner[i] );
-// gp_Pnt aPnt = BRep_Tool::Pnt( aVertex );
-// if ( aPnt.Distance( GMFPnt ) < epsilon )
-// break;
-// }
-// break;
-// }
-// case GmfEdges: {
-// nodeDim = 2;
-// aGMFElement = theMeshDS->AddEdge( node[0], node[1] );
-// int iNode = 1;
-// if ( GMFNodeAssigne[ nodeID[0] ] == 0 || GMFNodeAssigne[ nodeID[0] ] == 2 )
-// iNode = 0;
-// shapeID = findEdgeID( node[iNode], theMeshDS, nbShapeEdge, tabEdge );
-// break;
-// }
-// case GmfRidges:
-// break;
-// case GmfTriangles: {
-// nodeDim = 3;
-// aGMFElement = theMeshDS->AddFace( node[0], node[1], node[2]);
-// shapeID = -1;
-// break;
-// }
-// // case GmfQuadrilaterals: {
-// // nodeDim = 4;
-// // aGMFElement = theMeshDS->AddFace( node[0], node[1], node[2], node[3] );
-// // shapeID = -1;
-// // break;
-// // }
-// case GmfTetrahedra: {
-//
-// // IN WORK
-// TopoDS_Shape aSolid;
-// // We always run HYBRID with "to mesh holes"==TRUE but we must not create
-// // tetras within holes depending on hypo option,
-// // so we first check if aTet is inside a hole and then create it
-// if ( nbTriangle > 1 ) {
-// tetraShapeID = HOLE_ID; // negative tetraShapeID means not to create tetras if !toMeshHoles
-// int aHybridShapeID = hybridShapeID[iElem] - IdShapeRef;
-// if ( tabID[ aHybridShapeID ] == 0 ) {
-// TopAbs_State state;
-// aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape, &state);
-// if ( toMeshHoles || state == TopAbs_IN )
-// tetraShapeID = theMeshDS->ShapeToIndex( aSolid );
-// tabID[ aHybridShapeID ] = tetraShapeID;
-// }
-// else
-// tetraShapeID = tabID[ aHybridShapeID ];
-// }
-// else if ( nbShape > 1 ) {
-// // Case where nbTriangle == 1 while nbShape == 2 encountered
-// // with compound of 2 boxes and "To mesh holes"==False,
-// // so there are no subdomains specified for each tetrahedron.
-// // Try to guess a solid by a node already bound to shape
-// tetraShapeID = 0;
-// for ( int i=0; i<4 && tetraShapeID==0; i++ ) {
-// if ( nodeAssigne[ nodeID[i] ] == 1 &&
-// node[i]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE &&
-// node[i]->getshapeId() > 1 )
-// {
-// tetraShapeID = node[i]->getshapeId();
-// }
-// }
-// if ( tetraShapeID==0 ) {
-// aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape);
-// tetraShapeID = theMeshDS->ShapeToIndex( aSolid );
-// }
-// }
-// // set new nodes and tetrahedron onto the shape
-// for ( int i=0; i<4; i++ ) {
-// if ( nodeAssigne[ nodeID[i] ] == 0 ) {
-// if ( tetraShapeID != HOLE_ID )
-// theMeshDS->SetNodeInVolume( node[i], tetraShapeID );
-// nodeAssigne[ nodeID[i] ] = tetraShapeID;
-// }
-// }
-// if ( toMeshHoles || tetraShapeID != HOLE_ID ) {
-// aGMFElement = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] );
-// theMeshDS->SetMeshElementOnShape( aGMFElement, tetraShapeID );
-// }
-//
-// // IN WORK
-//
-// nodeDim = 5;
-// break;
-// }
-// // case GmfHexahedra: {
-// // nodeDim = 6;
-// // aGMFElement = theMeshDS->AddVolume( node[0], node[3], node[2], node[1],
-// // node[4], node[7], node[6], node[5] );
-// // break;
-// // }
-// default: continue;
-// }
-// if (token != GmfRidges)
-// {
-// for ( int i=0; i<nbRef; i++ ) {
-// if ( GMFNodeAssigne[ nodeID[i] ] == 0 ) {
-// if ( token == GmfCorners ) theMeshDS->SetNodeOnVertex( node[0], aVertex );
-// else if ( token == GmfEdges ) theMeshDS->SetNodeOnEdge( node[i], shapeID );
-// else if ( token == GmfTriangles ) theMeshDS->SetNodeOnFace( node[i], shapeID );
-// GMFNodeAssigne[ nodeID[i] ] = nodeDim;
-// }
-// }
-// if ( token != "Corners" )
-// theMeshDS->SetMeshElementOnShape( aGMFElement, shapeID );
-// }
-// } // for
-//
-// if ( !toMeshHoles ) {
-// map <int,const SMDS_MeshNode*>::iterator itOnNode = theHybridIdToNodeMap.find( nbVertices-(nbEnforcedVertices+nbEnforcedNodes) );
-// for ( ; itOnNode != theHybridIdToNodeMap.end(); ++itOnNode) {
-// if ( nodeAssigne[ itOnNode->first ] == HOLE_ID )
-// theMeshDS->RemoveFreeNode( itOnNode->second, 0 );
-// }
-// }
-//
-// delete [] node;
-// delete [] nodeID;
-// break;
-// } // case GmfTetrahedra
-// } // switch(token)
-// } // for
-// cout << std::endl;
-//
-// #ifdef WIN32
-// UnmapViewOfFile(mapPtr);
-// CloseHandle(hMapObject);
-// CloseHandle(fd);
-// #else
-// munmap(mapPtr, length);
-// #endif
-// close(fileOpen);
-//
-// delete [] tabID;
-// delete [] tabCorner;
-// delete [] tabEdge;
-// delete [] nodeAssigne;
-// delete [] GMFNodeAssigne;
-// delete [] GMFNode;
-//
-// return true;
-// }
-
//=======================================================================
//function : addElemInMeshGroup