// $Header$
//=============================================================================
//
-using namespace std;
-
#include "GHS3DPlugin_GHS3D.hxx"
#include "GHS3DPlugin_Hypothesis.hxx"
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopoDS.hxx>
//#include <BRepClass_FaceClassifier.hxx>
-//#include <BRepGProp.hxx>
-//#include <GProp_GProps.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
#include "utilities.h"
-#ifndef WIN32
+#ifdef WIN32
+#include <io.h>
+#else
#include <sys/sysinfo.h>
#endif
+using namespace std;
+
//#include <Standard_Stream.hxx>
aPnt = p;
break;
}
- aPnt += p;
+ aPnt += p / nbNode;
}
BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion());
nNotOnSeamEdge = node3;
else
nNotOnSeamEdge = node2;
- gp_XY uv = helper.GetNodeUV( geomFace, node1, nNotOnSeamEdge );
+ bool uvOK;
+ gp_XY uv = helper.GetNodeUV( geomFace, node1, nNotOnSeamEdge, &uvOK );
// check that uv is correct
+ double tol = 1e-6;
+ TopoDS_Shape nodeShape = helper.GetSubShapeByNode( node1, meshDS );
+ if ( !nodeShape.IsNull() )
+ switch ( nodeShape.ShapeType() )
+ {
+ case TopAbs_FACE: tol = BRep_Tool::Tolerance( TopoDS::Face( nodeShape )); break;
+ case TopAbs_EDGE: tol = BRep_Tool::Tolerance( TopoDS::Edge( nodeShape )); break;
+ case TopAbs_VERTEX: tol = BRep_Tool::Tolerance( TopoDS::Vertex( nodeShape )); break;
+ default:;
+ }
BRepAdaptor_Surface surface( geomFace );
- double tol = BRep_Tool::Tolerance( geomFace );
- if ( node1Pnt.Distance( surface.Value( uv.X(), uv.Y() )) > 2 * tol ) {
- GeomAPI_ProjectPointOnSurf projector( node1Pnt, surface.Surface().Surface(), 2 * tol );
- if ( !projector.IsDone() || projector.NbPoints() < 1 || projector.LowerDistance() > 2 * tol)
+ if ( !uvOK || node1Pnt.Distance( surface.Value( uv.X(), uv.Y() )) > 2 * tol )
return invalidID;
- Quantity_Parameter U,V;
- projector.LowerDistanceParameters(U,V);
- if ( node1Pnt.Distance( surface.Value( U, V )) > 2 * tol )
- return invalidID;
- uv.SetCoord( U,V );
- }
+
// normale to geomFace at UV
gp_Vec du, dv;
surface.D1( uv.X(), uv.Y(), node1Pnt, du, dv );
//=======================================================================
static bool readResultFile(const int fileOpen,
+#ifdef WNT
+ const char* fileName,
+#endif
SMESH_Mesh& theMesh,
TopoDS_Shape tabShape[],
double** tabBox,
length = status.st_size;
// Mapping the result file into memory
+#ifdef WNT
+ HANDLE fd = CreateFile(fileName, 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);
if ( nbElems )
cout << nbElems << " tetrahedrons have been associated to " << nbShape << " shapes" << endl;
+#ifdef WNT
+ UnmapViewOfFile(mapPtr);
+ CloseHandle(hMapObject);
+ CloseHandle(fd);
+#else
munmap(mapPtr, length);
+#endif
close(fileOpen);
delete [] tab;
//=======================================================================
static bool readResultFile(const int fileOpen,
+#ifdef WNT
+ const char* fileName,
+#endif
SMESHDS_Mesh* theMeshDS,
TopoDS_Shape aSolid,
vector <const SMDS_MeshNode*>& theNodeByGhs3dId) {
length = status.st_size;
// Mapping the result file into memory
+#ifdef WNT
+ HANDLE fd = CreateFile(fileName, 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);
}
if ( nbElems )
cout << nbElems << " tetrahedrons have been associated to " << nbTriangle << " shapes" << endl;
+#ifdef WNT
+ UnmapViewOfFile(mapPtr);
+ CloseHandle(hMapObject);
+ CloseHandle(fd);
+#else
munmap(mapPtr, length);
+#endif
close(fileOpen);
delete [] tab;
ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out);
Ok =
-#ifdef WIN32
- aFacesFile->is_open() && aPointsFile->is_open();
-#else
aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open();
-#endif
if (!Ok) {
INFOS( "Can't write into " << aFacesFileName);
return error(SMESH_Comment("Can't write into ") << aFacesFileName);
aFacesFile.close();
aPointsFile.close();
-
+
if ( ! Ok ) {
if ( !_keepFiles ) {
removeFile( aFacesFileName );
else {
bool toMeshHoles =
_hyp ? _hyp->GetToMeshHoles(true) : GHS3DPlugin_Hypothesis::DefaultMeshHoles();
- Ok = readResultFile( fileOpen, theMesh, tabShape, tabBox, _nbShape, aGhs3dIdToNodeMap,
+ Ok = readResultFile( fileOpen,
+#ifdef WNT
+ aResultFileName.ToCString(),
+#endif
+ theMesh, tabShape, tabBox, _nbShape, aGhs3dIdToNodeMap,
toMeshHoles );
}
ofstream aFacesFile ( aFacesFileName.ToCString() , ios::out);
ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out);
bool Ok =
-#ifdef WIN32
- aFacesFile->is_open() && aPointsFile->is_open();
-#else
aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open();
-#endif
if (!Ok)
return error( SMESH_Comment("Can't write into ") << aPointsFileName);
Ok = false;
}
else {
- Ok = readResultFile( fileOpen, meshDS, theShape ,aNodeByGhs3dId );
+ Ok = readResultFile( fileOpen,
+#ifdef WNT
+ aResultFileName.ToCString(),
+#endif
+ meshDS, theShape ,aNodeByGhs3dId );
}
// ---------------------
return 0;
}
-