-// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
+#include <Basics_OCCTVersion.hxx>
// Netgen include files
#ifndef OCCGEOMETRY
#define OCCGEOMETRY
//================================================================================
/*!
- * \brief Restrict size of elements on the given edge
+ * \brief Restrict size of elements on the given edge
*/
//================================================================================
} // namespace
+
+
//=============================================================================
/*!
*
_fineness = NETGENPlugin_Hypothesis::GetDefaultFineness();
mparams.uselocalh = NETGENPlugin_Hypothesis::GetDefaultSurfaceCurvature();
netgen::merge_solids = NETGENPlugin_Hypothesis::GetDefaultFuseEdges();
+ // Unused argument but set 0 to initialise it
+ mparams.elementorder = 0;
#ifdef NETGEN_V6
- mparams.nthreads = std::thread::hardware_concurrency();
+ mparams.nthreads = NETGENPlugin_Hypothesis::GetDefaultNbThreads();
+ if ( getenv( "SALOME_NETGEN_DISABLE_MULTITHREADING" ))
+ {
+ mparams.nthreads = 1;
+ mparams.parallel_meshing = false;
+ }
#endif
}
+
//=============================================================================
/*!
* Pass parameters to NETGEN
#ifdef NETGEN_V6
// std::string
mparams.meshsizefilename = hyp->GetMeshSizeFile();
+ mparams.nthreads = hyp->GetNbThreads();
#else
// const char*
mparams.meshsizefilename= hyp->GetMeshSizeFile().empty() ? 0 : hyp->GetMeshSizeFile().c_str();
{
Standard_Integer n1,n2,n3;
triangulation->Triangles()(i).Get( n1,n2,n3 );
+#if OCC_VERSION_LARGE < 0x07060000
p [0] = triangulation->Nodes()(n1).Transformed(loc).XYZ();
p [1] = triangulation->Nodes()(n2).Transformed(loc).XYZ();
p [2] = triangulation->Nodes()(n3).Transformed(loc).XYZ();
uv[0] = triangulation->UVNodes()(n1).XY();
uv[1] = triangulation->UVNodes()(n2).XY();
uv[2] = triangulation->UVNodes()(n3).XY();
+#else
+ p[0] = triangulation->Node(n1).Transformed(loc).XYZ();
+ p[1] = triangulation->Node(n2).Transformed(loc).XYZ();
+ p[2] = triangulation->Node(n3).Transformed(loc).XYZ();
+ uv[0] = triangulation->UVNode(n1).XY();
+ uv[1] = triangulation->UVNode(n2).XY();
+ uv[2] = triangulation->UVNode(n3).XY();
+#endif
surfProp.SetParameters( uv[0].X(), uv[0].Y() );
if ( !surfProp.IsCurvatureDefined() )
break;
BRep_Tool::Triangulation ( TopoDS::Face( fExp.Current() ), loc);
if ( triangulation.IsNull() ) continue;
const double fTol = BRep_Tool::Tolerance( TopoDS::Face( fExp.Current() ));
- const TColgp_Array1OfPnt& points = triangulation->Nodes();
+#if OCC_VERSION_HEX < 0x070600
+ const TColgp_Array1OfPnt& points = triangulation->Nodes();
+#else
+ auto points = [&triangulation](Standard_Integer index) {
+ return triangulation->Node(index);
+ };
+#endif
+
const Poly_Array1OfTriangle& trias = triangulation->Triangles();
for ( int iT = trias.Lower(); iT <= trias.Upper(); ++iT )
{
NETGENPlugin_Internals& internalShapes)
{
SMESHDS_Mesh* meshDS = internalShapes.getMesh().GetMeshDS();
-
+
// find ng indices of internal faces
set<int> ngFaceIds;
for ( int ngFaceID = 1; ngFaceID <= occgeom.fmap.Extent(); ++ngFaceID )
double dist3D = surf->Value( uv1.X(), uv1.Y() ).Distance( surf->Value( uv2.X(), uv2.Y() ));
if ( stopHandler == 0 ) // stop recursion
return dist3D;
-
+
// start recursion if necessary
double dist2D = SMESH_MesherHelper::ApplyIn2D(surf, uv1, uv2, gp_XY_Subtracted, 0).Modulus();
if ( fabs( dist3D - dist2D ) < dist2D * 1e-10 )
* \param wires - data of nodes on FACE boundary
* \param helper - mesher helper holding the FACE
* \param nodeVec - vector of nodes in which node index == netgen ID
- * \retval SMESH_ComputeErrorPtr - error description
+ * \retval SMESH_ComputeErrorPtr - error description
*/
//================================================================================
for ( int i = 1; i <= nbVol; ++i )
{
- const netgen::Element& elem = ngMesh.VolumeElement(i);
+ const netgen::Element& elem = ngMesh.VolumeElement(i);
int aSolidInd = elem.GetIndex();
TopoDS_Solid aSolid;
if ( aSolidInd > 0 && aSolidInd <= occgeo.somap.Extent() )
// vector of nodes in which node index == netgen ID
vector< const SMDS_MeshNode* > nodeVec;
-
+
{
// ----------------
// compute 1D mesh
const int hugeNb = std::numeric_limits<int>::max() / 100;
// ----------------
- // evaluate 1D
+ // evaluate 1D
// ----------------
// pass 1D simple parameters to NETGEN
if ( _simpleHyp )
return false;
// ----------------
- // evaluate 2D
+ // evaluate 2D
// ----------------
if ( _simpleHyp ) {
if ( double area = _simpleHyp->GetMaxElementArea() ) {
}
else if ( strncmp( file, "Intersecting: ", 14 ) == 0 )
{
-// Intersecting:
+// Intersecting:
// openelement 18 with open element 126
-// 41 36 38
+// 41 36 38
// 69 70 72
file.getLine();
const char* pos = file;
#else //////// V 5
PointIndex pi;
- for (pi = PointIndex::BASE;
+ for (pi = PointIndex::BASE;
pi < ngMesh->GetNP()+PointIndex::BASE; pi++)
{
outfile << "mesh.AddNode( ";
//================================================================================
NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper():
- _ngMesh(0)
+ _ngMesh(0),_tmpDir(SALOMEDS_Tool::GetTmpDir())
{
if ( instanceCounter() == 0 )
{
_ngcerr = NULL;
if ( !getenv( "KEEP_NETGEN_OUTPUT" ))
{
- // redirect all netgen output (mycout,myerr,cout) to _outputFileName
- _outputFileName = getOutputFileName();
- _ngcout = netgen::mycout;
- _ngcerr = netgen::myerr;
- netgen::mycout = new ofstream ( _outputFileName.c_str() );
- netgen::myerr = netgen::mycout;
- _coutBuffer = std::cout.rdbuf();
-#ifdef _DEBUG_
- std::cout << "NOTE: netgen output is redirected to file " << _outputFileName << std::endl;
-#else
- std::cout.rdbuf( netgen::mycout->rdbuf() );
-#endif
+ setOutputFile(getOutputFileName());
}
setMesh( Ng_NewMesh() );
if ( !ngMesh )
ngMesh = new netgen::Mesh;
+ // To dump mparam
+ // netgen::mparam.Print(std::cerr);
+
#ifdef NETGEN_V6
ngMesh->SetGeometry( shared_ptr<netgen::NetgenGeometry>( &occgeo, &NOOP_Deleter ));
return aGenericName.ToCString();
}
+//================================================================================
+/*!
+ * \brief Set output file name for netgen log
+ */
+//================================================================================
+
+void NETGENPlugin_NetgenLibWrapper::setOutputFile(std::string outputfile)
+{
+ // redirect all netgen output (mycout,myerr,cout) to _outputFileName
+ _outputFileName = outputfile;
+ _ngcout = netgen::mycout;
+ _ngcerr = netgen::myerr;
+ netgen::mycout = new ofstream ( _outputFileName.c_str() );
+ netgen::myerr = netgen::mycout;
+ _coutBuffer = std::cout.rdbuf();
+#ifdef _DEBUG_
+ std::cout << "NOTE: netgen output is redirected to file " << _outputFileName << std::endl;
+#else
+ std::cout.rdbuf( netgen::mycout->rdbuf() );
+#endif
+}
//================================================================================
/*!