#include <BRepGProp.hxx>
#include <GProp_GProps.hxx>
+using namespace std;
+
/*
#include <med.h>
//#include <med_config.h>
int nbVertices=theMesh->NbNodes();
int nbFaces=theMesh->NbFaces(); //triangles or quadrangles
const char* space=" ";
- const int dummyint=1; //nrs,nsd,refnum=1 (for wrap)
+ //const int dummyint=1; //nrs,nsd,refnum=1 (for wrap)
// Writing SMESH points into GHS3DPRL File.points
theFile<<nbVertices<<endl;
}
//=======================================================================
-static bool getInt( int & theValue, char * & theLine )
-{
- char *ptr;
- theValue = strtol( theLine, &ptr, 10 );
- if ( ptr == theLine ||
- // there must not be neither '.' nor ',' nor 'E' ...
- (*ptr != ' ' && *ptr != '\n' && *ptr != '\0'))
- return false;
-
- DUMP( " " << theValue );
- theLine = ptr;
- return true;
-}
+// static bool getInt( int & theValue, char * & theLine )
+// {
+// char *ptr;
+// theValue = strtol( theLine, &ptr, 10 );
+// if ( ptr == theLine ||
+// // there must not be neither '.' nor ',' nor 'E' ...
+// (*ptr != ' ' && *ptr != '\n' && *ptr != '\0'))
+// return false;
+
+// DUMP( " " << theValue );
+// theLine = ptr;
+// return true;
+// }
//=======================================================================
-static bool getDouble( double & theValue, char * & theLine )
-{
- char *ptr;
- theValue = strtod( theLine, &ptr );
- if ( ptr == theLine )
- return false;
-
- DUMP( " " << theValue );
- theLine = ptr;
- return true;
-}
+// static bool getDouble( double & theValue, char * & theLine )
+// {
+// char *ptr;
+// theValue = strtod( theLine, &ptr );
+// if ( ptr == theLine )
+// return false;
+
+// DUMP( " " << theValue );
+// theLine = ptr;
+// return true;
+// }
//=======================================================================
{ aPtr = fgets( aBuf, GHS3DPRLPlugin_BUFLENGTH - 2, aFile ); aLineNb++; DUMP(endl); }
//=======================================================================
-static bool readResult(FILE * theFile,
- SMESHDS_Mesh * theMesh,
- const TopoDS_Shape & theShape,
- map <int,const SMDS_MeshNode*> & theGHS3DPRLIdToNodeMap,
- const TCollection_AsciiString & GHS3DPRL_Out,
- int & nodeRefNumber)
-{
- // ---------------------------------
- // Read generated elements and nodes
- // ---------------------------------
-
- cout << "Reading GHS3DPRL output file : " << GHS3DPRL_Out << endl;
- cout << endl;
-
- char aBuffer[ GHS3DPRLPlugin_BUFLENGTH ];
- char * aPtr;
- int aLineNb = 0;
- int shapeID = theMesh->ShapeToIndex( theShape );
-
- int line = 1, EndOfFile = 0, nbElem = 0, nField = 10, nbRef = 0, aGHS3DPRLNodeID = 0;
- const char * theField;
-
- vector<const char*> tabField = vector<const char*>(nField);
- vector<int> tabRef = vector<int>(nField);
-
- tabField[0] = "MeshVersionFormatted"; tabRef[0] = 0;
- tabField[1] = "Dimension"; tabRef[1] = 0;
- tabField[2] = "Vertices"; tabRef[2] = 3;
- tabField[3] = "Edges"; tabRef[3] = 2;
- tabField[4] = "Triangles"; tabRef[4] = 3;
- tabField[5] = "Quadrilaterals"; tabRef[5] = 4;
- tabField[6] = "Hexahedra"; tabRef[6] = 8;
- tabField[7] = "Corners"; tabRef[7] = 1;
- tabField[8] = "Ridges"; tabRef[0] = 1;
- tabField[9] = "End"; tabRef[0] = 0;
-
- nodeRefNumber += theMesh->NbNodes();
-
- SMDS_NodeIteratorPtr itOnGHS3DPRLInputNode = theMesh->nodesIterator();
- while ( itOnGHS3DPRLInputNode->more() )
- theMesh->RemoveNode( itOnGHS3DPRLInputNode->next() );
-
- while ( EndOfFile == 0 ) {
- GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb );
- for ( int iField = 0; iField < nField; iField++ ) {
- stringstream theMessage;
- theField = tabField[iField];
- if ( strncmp(aPtr, theField, strlen(theField)) == 0 ) {
- if ( strcmp(theField, "End") == 0 ) {
- EndOfFile = 1;
- theMessage << "End of GHS3DPRL output file has been reached";
- }
- else {
- GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb );
- line++;
- getInt( nbElem, aPtr );
-
- if ( strcmp(theField, "MeshVersionFormatted") == 0 )
- theMessage << "GHS3DPRL mesh descriptor : " << theField << " " << nbElem;
- else if ( strcmp(theField, "Dimension") == 0 )
- theMessage << "GHS3DPRL mesh of " << nbElem << "D dimension";
- else if ( strcmp(theField, "Vertices") == 0 ||
- strcmp(theField, "Edges") == 0 ||
- strcmp(theField, "Quadrilaterals") == 0 ||
- strcmp(theField, "Hexahedra") == 0 ) {
- nbRef = tabRef[iField];
- GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb ); // read blank line
-
- if ( strcmp(theField, "Vertices") == 0 ) {
- int aGHS3DPRLID;
- vector<double> coord = vector<double>(nbRef);
- SMDS_MeshNode * aGHS3DPRLNode;
-
- for ( int iElem = 0; iElem < nbElem; iElem++ ) {
- aGHS3DPRLID = iElem + 1 + nodeRefNumber;
- GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb ); // read file lines
- for ( int iCoord = 0; iCoord < 3; iCoord++ )
- getDouble ( coord[ iCoord ], aPtr );
- aGHS3DPRLNode = theMesh->AddNode(coord[0], coord[1], coord[2]);
- theMesh->SetNodeInVolume( aGHS3DPRLNode, shapeID );
- theGHS3DPRLIdToNodeMap[ aGHS3DPRLID ] = aGHS3DPRLNode;
- }
- }
- else {
- vector<const SMDS_MeshNode*> node = vector<const SMDS_MeshNode*>(nbRef);
- SMDS_MeshElement* aGHS3DPRLElement;
- map <int,const SMDS_MeshNode*>::iterator itOnGHS3DPRLNode;
-
- for ( int iElem = 0; iElem < nbElem; iElem++ ) {
- GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb ); // read file lines
- for ( int iRef = 0; iRef < nbRef; iRef++ ) {
- getInt ( aGHS3DPRLNodeID, aPtr ); // read nbRef aGHS3DPRLNodeID
- aGHS3DPRLNodeID += nodeRefNumber;
- itOnGHS3DPRLNode = theGHS3DPRLIdToNodeMap.find( aGHS3DPRLNodeID );
- node[ iRef ] = itOnGHS3DPRLNode->second;
- }
-
- if ( strcmp(theField, "Edges") == 0 ) // create an element
- aGHS3DPRLElement = theMesh->AddEdge( node[0], node[1] );
- else if ( strcmp(theField, "Quadrilaterals") == 0 )
- aGHS3DPRLElement = theMesh->AddFace( node[0], node[1], node[2], node[3] );
- else if ( strcmp(theField, "Hexahedra") == 0 )
- aGHS3DPRLElement = theMesh->AddVolume( node[0], node[1], node[2], node[3], node[4], node[5], node[6], node[7] );
-
- theMesh->SetMeshElementOnShape( aGHS3DPRLElement, shapeID );
- }
- }
- theMessage << nbElem << " " << theField << " created";
- }
- }
- if ( theMessage.str().size() != 0 ) {
- cout << theMessage.str() << endl;
- break;
- }
- }
- }
- }
- cout << endl;
- return true;
-}
+// static bool readResult(FILE * theFile,
+// SMESHDS_Mesh * theMesh,
+// const TopoDS_Shape & theShape,
+// map <int,const SMDS_MeshNode*> & theGHS3DPRLIdToNodeMap,
+// const TCollection_AsciiString & GHS3DPRL_Out,
+// int & nodeRefNumber)
+// {
+// // ---------------------------------
+// // Read generated elements and nodes
+// // ---------------------------------
+
+// cout << "Reading GHS3DPRL output file : " << GHS3DPRL_Out << endl;
+// cout << endl;
+
+// char aBuffer[ GHS3DPRLPlugin_BUFLENGTH ];
+// char * aPtr;
+// int aLineNb = 0;
+// int shapeID = theMesh->ShapeToIndex( theShape );
+
+// int line = 1, EndOfFile = 0, nbElem = 0, nField = 10, nbRef = 0, aGHS3DPRLNodeID = 0;
+// const char * theField;
+
+// vector<const char*> tabField = vector<const char*>(nField);
+// vector<int> tabRef = vector<int>(nField);
+
+// tabField[0] = "MeshVersionFormatted"; tabRef[0] = 0;
+// tabField[1] = "Dimension"; tabRef[1] = 0;
+// tabField[2] = "Vertices"; tabRef[2] = 3;
+// tabField[3] = "Edges"; tabRef[3] = 2;
+// tabField[4] = "Triangles"; tabRef[4] = 3;
+// tabField[5] = "Quadrilaterals"; tabRef[5] = 4;
+// tabField[6] = "Hexahedra"; tabRef[6] = 8;
+// tabField[7] = "Corners"; tabRef[7] = 1;
+// tabField[8] = "Ridges"; tabRef[0] = 1;
+// tabField[9] = "End"; tabRef[0] = 0;
+
+// nodeRefNumber += theMesh->NbNodes();
+
+// SMDS_NodeIteratorPtr itOnGHS3DPRLInputNode = theMesh->nodesIterator();
+// while ( itOnGHS3DPRLInputNode->more() )
+// theMesh->RemoveNode( itOnGHS3DPRLInputNode->next() );
+
+// while ( EndOfFile == 0 ) {
+// GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb );
+// for ( int iField = 0; iField < nField; iField++ ) {
+// stringstream theMessage;
+// theField = tabField[iField];
+// if ( strncmp(aPtr, theField, strlen(theField)) == 0 ) {
+// if ( strcmp(theField, "End") == 0 ) {
+// EndOfFile = 1;
+// theMessage << "End of GHS3DPRL output file has been reached";
+// }
+// else {
+// GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb );
+// line++;
+// getInt( nbElem, aPtr );
+
+// if ( strcmp(theField, "MeshVersionFormatted") == 0 )
+// theMessage << "GHS3DPRL mesh descriptor : " << theField << " " << nbElem;
+// else if ( strcmp(theField, "Dimension") == 0 )
+// theMessage << "GHS3DPRL mesh of " << nbElem << "D dimension";
+// else if ( strcmp(theField, "Vertices") == 0 ||
+// strcmp(theField, "Edges") == 0 ||
+// strcmp(theField, "Quadrilaterals") == 0 ||
+// strcmp(theField, "Hexahedra") == 0 ) {
+// nbRef = tabRef[iField];
+// GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb ); // read blank line
+
+// if ( strcmp(theField, "Vertices") == 0 ) {
+// int aGHS3DPRLID;
+// vector<double> coord = vector<double>(nbRef);
+// SMDS_MeshNode * aGHS3DPRLNode;
+
+// for ( int iElem = 0; iElem < nbElem; iElem++ ) {
+// aGHS3DPRLID = iElem + 1 + nodeRefNumber;
+// GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb ); // read file lines
+// for ( int iCoord = 0; iCoord < 3; iCoord++ )
+// getDouble ( coord[ iCoord ], aPtr );
+// aGHS3DPRLNode = theMesh->AddNode(coord[0], coord[1], coord[2]);
+// theMesh->SetNodeInVolume( aGHS3DPRLNode, shapeID );
+// theGHS3DPRLIdToNodeMap[ aGHS3DPRLID ] = aGHS3DPRLNode;
+// }
+// }
+// else {
+// vector<const SMDS_MeshNode*> node = vector<const SMDS_MeshNode*>(nbRef);
+// SMDS_MeshElement* aGHS3DPRLElement;
+// map <int,const SMDS_MeshNode*>::iterator itOnGHS3DPRLNode;
+
+// for ( int iElem = 0; iElem < nbElem; iElem++ ) {
+// GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb ); // read file lines
+// for ( int iRef = 0; iRef < nbRef; iRef++ ) {
+// getInt ( aGHS3DPRLNodeID, aPtr ); // read nbRef aGHS3DPRLNodeID
+// aGHS3DPRLNodeID += nodeRefNumber;
+// itOnGHS3DPRLNode = theGHS3DPRLIdToNodeMap.find( aGHS3DPRLNodeID );
+// node[ iRef ] = itOnGHS3DPRLNode->second;
+// }
+
+// if ( strcmp(theField, "Edges") == 0 ) // create an element
+// aGHS3DPRLElement = theMesh->AddEdge( node[0], node[1] );
+// else if ( strcmp(theField, "Quadrilaterals") == 0 )
+// aGHS3DPRLElement = theMesh->AddFace( node[0], node[1], node[2], node[3] );
+// else if ( strcmp(theField, "Hexahedra") == 0 )
+// aGHS3DPRLElement = theMesh->AddVolume( node[0], node[1], node[2], node[3], node[4], node[5], node[6], node[7] );
+
+// theMesh->SetMeshElementOnShape( aGHS3DPRLElement, shapeID );
+// }
+// }
+// theMessage << nbElem << " " << theField << " created";
+// }
+// }
+// if ( theMessage.str().size() != 0 ) {
+// cout << theMessage.str() << endl;
+// break;
+// }
+// }
+// }
+// }
+// cout << endl;
+// return true;
+// }
//=============================================================================
// Pass parameters to GHS3DPRL
}*/
}
-//=============================================================================
-ostream & GHS3DPRLPlugin_GHS3DPRL::SaveTo(ostream & save)
-{
- return save;
-}
-
-//=============================================================================
-istream & GHS3DPRLPlugin_GHS3DPRL::LoadFrom(istream & load)
-{
- return load;
-}
-
-//=============================================================================
-ostream & operator << (ostream & save, GHS3DPRLPlugin_GHS3DPRL & hyp)
-{
- return hyp.SaveTo( save );
-}
-
-//=============================================================================
-istream & operator >> (istream & load, GHS3DPRLPlugin_GHS3DPRL & hyp)
-{
- return hyp.LoadFrom( load );
-}
-
-
//=============================================================================
/*!
*