-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "NETGENPlugin_SimpleHypothesis_3D.hxx"
#include <SMDS_FaceOfNodes.hxx>
+#include <SMDS_LinearEdge.hxx>
#include <SMDS_MeshElement.hxx>
#include <SMDS_MeshNode.hxx>
#include <SMESHDS_Mesh.hxx>
#include <SMESH_Block.hxx>
#include <SMESH_Comment.hxx>
#include <SMESH_ComputeError.hxx>
+#include <SMESH_ControlPnt.hxx>
#include <SMESH_File.hxx>
#include <SMESH_Gen_i.hxx>
#include <SMESH_Mesh.hxx>
#include <NCollection_Map.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_ProgramError.hxx>
+#include <TColStd_MapOfInteger.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeInteger.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopoDS.hxx>
-#include <OSD_File.hxx>
-#include <OSD_Path.hxx>
// Netgen include files
#ifndef OCCGEOMETRY
extern MeshingParameters mparam;
extern volatile multithreadt multithread;
extern bool merge_solids;
+
+ // values used for occgeo.facemeshstatus
+ enum EFaceMeshStatus { FACE_NOT_TREATED = 0,
+ FACE_FAILED = -1,
+ FACE_MESHED_OK = 1,
+ };
}
#include <vector>
#define NGPOINT_COORDS(p) p(0),p(1),p(2)
+#ifdef _DEBUG_
// dump elements added to ng mesh
//#define DUMP_SEGMENTS
//#define DUMP_TRIANGLES
//#define DUMP_TRIANGLES_SCRIPT "/tmp/trias.py" //!< debug AddIntVerticesInSolids()
+#endif
TopTools_IndexedMapOfShape ShapesWithLocalSize;
std::map<int,double> VertexId2LocalSize;
std::map<int,double> EdgeId2LocalSize;
std::map<int,double> FaceId2LocalSize;
+std::map<int,double> SolidId2LocalSize;
+
+std::vector<SMESHUtils::ControlPnt> ControlPoints;
+std::set<int> ShapesWithControlPoints; // <-- allows calling SetLocalSize() several times w/o recomputing ControlPoints
//=============================================================================
/*!
VertexId2LocalSize.clear();
EdgeId2LocalSize.clear();
FaceId2LocalSize.clear();
+ SolidId2LocalSize.clear();
+ ControlPoints.clear();
+ ShapesWithControlPoints.clear();
}
//================================================================================
*
*/
//=============================================================================
+
void SetLocalSize(TopoDS_Shape GeomShape, double LocalSize)
{
+ if ( GeomShape.IsNull() ) return;
TopAbs_ShapeEnum GeomType = GeomShape.ShapeType();
if (GeomType == TopAbs_COMPOUND) {
for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()) {
EdgeId2LocalSize[key] = LocalSize;
} else if (GeomType == TopAbs_FACE) {
FaceId2LocalSize[key] = LocalSize;
+ } else if (GeomType == TopAbs_SOLID) {
+ SolidId2LocalSize[key] = LocalSize;
}
}
// create elements of second order
mparams.secondorder = hyp->GetSecondOrder() ? 1 : 0;
// quad-dominated surface meshing
- // only triangles are allowed for volumic mesh (before realizing IMP 0021676)
- //if (!_isVolume)
- mparams.quad = hyp->GetQuadAllowed() ? 1 : 0;
+ mparams.quad = hyp->GetQuadAllowed() ? 1 : 0;
_optimize = hyp->GetOptimize();
_fineness = hyp->GetFineness();
mparams.uselocalh = hyp->GetSurfaceCurvature();
netgen::merge_solids = hyp->GetFuseEdges();
- _simpleHyp = NULL;
-
- SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
- CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
- SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
- SALOMEDS::Study_var myStudy = aStudyMgr->GetStudyByID(hyp->GetStudyId());
-
- const NETGENPlugin_Hypothesis::TLocalSize localSizes = hyp->GetLocalSizesAndEntries();
- NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
- for (it ; it != localSizes.end() ; it++)
+ _simpleHyp = NULL;
+ // mesh size file
+ mparams.meshsizefilename= hyp->GetMeshSizeFile().empty() ? 0 : hyp->GetMeshSizeFile().c_str();
+
+ SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
+ CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/Study");
+ SALOMEDS::Study_var myStudy = SALOMEDS::Study::_narrow(anObject);
+ if ( !myStudy->_is_nil() )
+ {
+ const NETGENPlugin_Hypothesis::TLocalSize localSizes = hyp->GetLocalSizesAndEntries();
+ NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
+ for ( ; it != localSizes.end() ; it++)
{
std::string entry = (*it).first;
- double val = (*it).second;
+ double val = (*it).second;
// --
GEOM::GEOM_Object_var aGeomObj;
- TopoDS_Shape S = TopoDS_Shape();
SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
- if (!aSObj->_is_nil()) {
+ if ( !aSObj->_is_nil() ) {
CORBA::Object_var obj = aSObj->GetObject();
aGeomObj = GEOM::GEOM_Object::_narrow(obj);
aSObj->UnRegister();
}
- if ( !aGeomObj->_is_nil() )
- S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
- // --
- SetLocalSize(S, val);
+ TopoDS_Shape S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
+ ::SetLocalSize(S, val);
}
+ }
}
}
int n1, n2;
Link(int _n1, int _n2) : n1(_n1), n2(_n2) {}
Link() : n1(0), n2(0) {}
+ bool Contains( int n ) const { return n == n1 || n == n2; }
+ bool IsConnected( const Link& other ) const
+ {
+ return (( Contains( other.n1 ) || Contains( other.n2 )) && ( this != &other ));
+ }
};
int HashCode(const Link& aLink, int aLimit)
Standard_Boolean IsEqual(const Link& aLink1, const Link& aLink2)
{
- return (aLink1.n1 == aLink2.n1 && aLink1.n2 == aLink2.n2 ||
- aLink1.n1 == aLink2.n2 && aLink1.n2 == aLink2.n1);
+ return (( aLink1.n1 == aLink2.n1 && aLink1.n2 == aLink2.n2 ) ||
+ ( aLink1.n1 == aLink2.n2 && aLink1.n2 == aLink2.n1 ));
}
namespace
// get ordered EDGEs
list< TopoDS_Edge > edges;
list< int > nbEdgesInWire;
- int nbWires = SMESH_Block::GetOrderedEdges( face, edges, nbEdgesInWire);
+ /*int nbWires =*/ SMESH_Block::GetOrderedEdges( face, edges, nbEdgesInWire);
// find <edge> within <edges>
list< TopoDS_Edge >::iterator eItFwd = edges.begin();
// }
// }
}
+ //================================================================================
+ /*!
+ * \brief Returns a medium node either existing in SMESH of created by NETGEN
+ * \param [in] corner1 - corner node 1
+ * \param [in] corner2 - corner node 2
+ * \param [in] defaultMedium - the node created by NETGEN
+ * \param [in] helper - holder of medium nodes existing in SMESH
+ * \return const SMDS_MeshNode* - the result node
+ */
+ //================================================================================
+
+ const SMDS_MeshNode* mediumNode( const SMDS_MeshNode* corner1,
+ const SMDS_MeshNode* corner2,
+ const SMDS_MeshNode* defaultMedium,
+ const SMESH_MesherHelper* helper)
+ {
+ if ( helper )
+ {
+ TLinkNodeMap::const_iterator l2n =
+ helper->GetTLinkNodeMap().find( SMESH_TLink( corner1, corner2 ));
+ if ( l2n != helper->GetTLinkNodeMap().end() )
+ defaultMedium = l2n->second;
+ }
+ return defaultMedium;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Assure that mesh on given shapes is quadratic
+ */
+ //================================================================================
+
+ // void makeQuadratic( const TopTools_IndexedMapOfShape& shapes,
+ // SMESH_Mesh* mesh )
+ // {
+ // for ( int i = 1; i <= shapes.Extent(); ++i )
+ // {
+ // SMESHDS_SubMesh* smDS = mesh->GetMeshDS()->MeshElements( shapes(i) );
+ // if ( !smDS ) continue;
+ // SMDS_ElemIteratorPtr elemIt = smDS->GetElements();
+ // if ( !elemIt->more() ) continue;
+ // const SMDS_MeshElement* e = elemIt->next();
+ // if ( !e || e->IsQuadratic() )
+ // continue;
+
+ // TIDSortedElemSet elems;
+ // elems.insert( e );
+ // while ( elemIt->more() )
+ // elems.insert( elems.end(), elemIt->next() );
+
+ // SMESH_MeshEditor( mesh ).ConvertToQuadratic( /*3d=*/false, elems, /*biQuad=*/false );
+ // }
+ // }
+
+ //================================================================================
+ /*!
+ * \brief Restrict size of elements on the given edge
+ */
+ //================================================================================
+
+ void setLocalSize(const TopoDS_Edge& edge,
+ double size,
+ netgen::Mesh& mesh)
+ {
+ if ( size <= std::numeric_limits<double>::min() )
+ return;
+ Standard_Real u1, u2;
+ Handle(Geom_Curve) curve = BRep_Tool::Curve(edge, u1, u2);
+ if ( curve.IsNull() )
+ {
+ TopoDS_Iterator vIt( edge );
+ if ( !vIt.More() ) return;
+ gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( vIt.Value() ));
+ NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), size );
+ }
+ else
+ {
+ const int nb = (int)( 1.5 * SMESH_Algo::EdgeLength( edge ) / size );
+ Standard_Real delta = (u2-u1)/nb;
+ for(int i=0; i<nb; i++)
+ {
+ Standard_Real u = u1 + delta*i;
+ gp_Pnt p = curve->Value(u);
+ NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), size );
+ netgen::Point3d pi(p.X(), p.Y(), p.Z());
+ double resultSize = mesh.GetH(pi);
+ if ( resultSize - size > 0.1*size )
+ // netgen does restriction iff oldH/newH > 1.2 (localh.cpp:136)
+ NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), resultSize/1.201 );
+ }
+ }
+ }
+} // namespace
+
+//================================================================================
+/*!
+ * \brief Set local size on shapes defined by SetParameters()
+ */
+//================================================================================
+
+void NETGENPlugin_Mesher::SetLocalSize( netgen::OCCGeometry& occgeo,
+ netgen::Mesh& ngMesh )
+{
+ for(std::map<int,double>::const_iterator it=EdgeId2LocalSize.begin(); it!=EdgeId2LocalSize.end(); it++)
+ {
+ int key = (*it).first;
+ double hi = (*it).second;
+ const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
+ setLocalSize( TopoDS::Edge(shape), hi, ngMesh );
+ }
+ for(std::map<int,double>::const_iterator it=VertexId2LocalSize.begin(); it!=VertexId2LocalSize.end(); it++)
+ {
+ int key = (*it).first;
+ double hi = (*it).second;
+ const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
+ gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex(shape) );
+ NETGENPlugin_Mesher::RestrictLocalSize( ngMesh, p.XYZ(), hi );
+ }
+ for(map<int,double>::const_iterator it=FaceId2LocalSize.begin(); it!=FaceId2LocalSize.end(); it++)
+ {
+ int key = (*it).first;
+ double val = (*it).second;
+ const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
+ int faceNgID = occgeo.fmap.FindIndex(shape);
+ if ( faceNgID >= 1 )
+ {
+ occgeo.SetFaceMaxH(faceNgID, val);
+ for ( TopExp_Explorer edgeExp( shape, TopAbs_EDGE ); edgeExp.More(); edgeExp.Next() )
+ setLocalSize( TopoDS::Edge( edgeExp.Current() ), val, ngMesh );
+ }
+ else if ( !ShapesWithControlPoints.count( key ))
+ {
+ SMESHUtils::createPointsSampleFromFace( TopoDS::Face( shape ), val, ControlPoints );
+ ShapesWithControlPoints.insert( key );
+ }
+ }
+ for(map<int,double>::const_iterator it=SolidId2LocalSize.begin(); it!=SolidId2LocalSize.end(); it++)
+ {
+ int key = (*it).first;
+ double val = (*it).second;
+ if ( !ShapesWithControlPoints.count( key ))
+ {
+ const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
+ SMESHUtils::createPointsSampleFromSolid( TopoDS::Solid( shape ), val, ControlPoints );
+ ShapesWithControlPoints.insert( key );
+ }
+ }
+
+ if ( !ControlPoints.empty() )
+ {
+ for ( size_t i = 0; i < ControlPoints.size(); ++i )
+ NETGENPlugin_Mesher::RestrictLocalSize( ngMesh, ControlPoints[i].XYZ(), ControlPoints[i].Size() );
+ }
}
//================================================================================
BRepBndLib::Add (shape, bb);
double x1,y1,z1,x2,y2,z2;
bb.Get (x1,y1,z1,x2,y2,z2);
- MESSAGE("shape bounding box:\n" <<
- "(" << x1 << " " << y1 << " " << z1 << ") " <<
- "(" << x2 << " " << y2 << " " << z2 << ")");
netgen::Point<3> p1 = netgen::Point<3> (x1,y1,z1);
netgen::Point<3> p2 = netgen::Point<3> (x2,y2,z2);
occgeo.boundingbox = netgen::Box<3> (p1,p2);
rootSM.push_back( mesh.GetSubMesh( it.Value() ));
}
+ int totNbFaces = 0;
+
// add subshapes of empty submeshes
list< SMESH_subMesh* >::iterator rootIt = rootSM.begin(), rootEnd = rootSM.end();
for ( ; rootIt != rootEnd; ++rootIt ) {
TopExp::MapShapes(root->GetSubShape(), subShapes);
while ( smIt->more() )
{
- SMESH_subMesh* sm = smIt->next();
+ SMESH_subMesh* sm = smIt->next();
TopoDS_Shape shape = sm->GetSubShape();
+ totNbFaces += ( shape.ShapeType() == TopAbs_FACE );
if ( intern && intern->isShapeToPrecompute( shape ))
continue;
if ( !meshedSM || sm->IsEmpty() )
}
}
}
- occgeo.facemeshstatus.SetSize (occgeo.fmap.Extent());
+ occgeo.facemeshstatus.SetSize (totNbFaces);
occgeo.facemeshstatus = 0;
- occgeo.face_maxh_modified.SetSize(occgeo.fmap.Extent());
+ occgeo.face_maxh_modified.SetSize(totNbFaces);
occgeo.face_maxh_modified = 0;
- occgeo.face_maxh.SetSize(occgeo.fmap.Extent());
+ occgeo.face_maxh.SetSize(totNbFaces);
occgeo.face_maxh = netgen::mparam.maxh;
}
*/
//================================================================================
-void NETGENPlugin_Mesher::RestrictLocalSize(netgen::Mesh& ngMesh, const gp_XYZ& p, const double size)
+void NETGENPlugin_Mesher::RestrictLocalSize(netgen::Mesh& ngMesh,
+ const gp_XYZ& p,
+ double size,
+ const bool overrideMinH)
{
+ if ( size <= std::numeric_limits<double>::min() )
+ return;
if ( netgen::mparam.minh > size )
{
- ngMesh.SetMinimalH( size );
- netgen::mparam.minh = size;
+ if ( overrideMinH )
+ {
+ ngMesh.SetMinimalH( size );
+ netgen::mparam.minh = size;
+ }
+ else
+ {
+ size = netgen::mparam.minh;
+ }
}
netgen::Point3d pi(p.X(), p.Y(), p.Z());
ngMesh.RestrictLocalH( pi, size );
netgen::Mesh& ngMesh,
vector<const SMDS_MeshNode*>& nodeVec,
const list< SMESH_subMesh* > & meshedSM,
+ SMESH_MesherHelper* quadHelper,
SMESH_ProxyMesh::Ptr proxyMesh)
{
TNode2IdMap nodeNgIdMap;
- for ( int i = 1; i < nodeVec.size(); ++i )
+ for ( size_t i = 1; i < nodeVec.size(); ++i )
nodeNgIdMap.insert( make_pair( nodeVec[i], i ));
TopTools_MapOfShape visitedShapes;
bool isForwad = ( fOri == eNotSeam.Orientation() || fOri >= TopAbs_INTERNAL );
// get all nodes from connected <edges>
- bool isQuad = smDS->NbElements() ? smDS->GetElements()->next()->IsQuadratic() : false;
+ const bool isQuad = smDS->IsQuadratic();
StdMeshers_FaceSide fSide( face, edges, _mesh, isForwad, isQuad );
const vector<UVPtStruct>& points = fSide.GetUVPtStruct();
+ if ( points.empty() )
+ return false; // invalid node params?
int i, nbSeg = fSide.NbSegments();
// remember EDGEs of fSide to treat only once
seg.epgeominfo[ 1 ].v = otherSeamParam;
swap (seg.epgeominfo[0].u, seg.epgeominfo[1].u);
}
- swap (seg[0], seg[1]);
- swap (seg.epgeominfo[0].dist, seg.epgeominfo[1].dist);
+ swap( seg[0], seg[1] );
+ swap( seg.epgeominfo[0].dist, seg.epgeominfo[1].dist );
seg.edgenr = ngMesh.GetNSeg() + 1; // segment id
- ngMesh.AddSegment (seg);
+ ngMesh.AddSegment( seg );
#ifdef DUMP_SEGMENTS
cout << "Segment: " << seg.edgenr << endl
<< "\t is SEAM (reverse) of the previous. "
}
else if ( fOri == TopAbs_INTERNAL )
{
- swap (seg[0], seg[1]);
+ swap( seg[0], seg[1] );
swap( seg.epgeominfo[0], seg.epgeominfo[1] );
seg.edgenr = ngMesh.GetNSeg() + 1; // segment id
- ngMesh.AddSegment (seg);
+ ngMesh.AddSegment( seg );
#ifdef DUMP_SEGMENTS
cout << "Segment: " << seg.edgenr << endl << "\t is REVERSE of the previous" << endl;
#endif
}
} // loop on geomEdge ancestors
+ if ( quadHelper ) // remember medium nodes of sub-meshes
+ {
+ SMDS_ElemIteratorPtr edges = smDS->GetElements();
+ while ( edges->more() )
+ {
+ const SMDS_MeshElement* e = edges->next();
+ if ( !quadHelper->AddTLinks( static_cast< const SMDS_MeshEdge*>( e )))
+ break;
+ }
+ }
+
break;
} // case TopAbs_EDGE
solidID1 = occgeom.somap.FindIndex( quadAdaptor->GetShape() );
}
else
- {
+ {
PShapeIteratorPtr solidIt = helper.GetAncestors( geomFace, *sm->GetFather(), TopAbs_SOLID);
while ( const TopoDS_Shape * solid = solidIt->next() )
{
}
// Add ng face descriptors of meshed faces
faceNgID++;
- ngMesh.AddFaceDescriptor (netgen::FaceDescriptor(faceNgID, solidID1, solidID2, 0));
+ ngMesh.AddFaceDescriptor( netgen::FaceDescriptor( faceNgID, solidID1, solidID2, 0 ));
// if second oreder is required, even already meshed faces must be passed to NETGEN
int fID = occgeom.fmap.Add( geomFace );
+ if ( occgeom.facemeshstatus.Size() < fID ) occgeom.facemeshstatus.SetSize( fID );
+ occgeom.facemeshstatus[ fID-1 ] = netgen::FACE_MESHED_OK;
while ( fID < faceNgID ) // geomFace is already in occgeom.fmap, add a copy
+ {
fID = occgeom.fmap.Add( BRepBuilderAPI_Copy( geomFace, /*copyGeom=*/false ));
+ if ( occgeom.facemeshstatus.Size() < fID ) occgeom.facemeshstatus.SetSize( fID );
+ occgeom.facemeshstatus[ fID-1 ] = netgen::FACE_MESHED_OK;
+ }
// Problem with the second order in a quadrangular mesh remains.
- // 1) All quadrangles geberated by NETGEN are moved to an inexistent face
- // by FillSMesh() (find AddFaceDescriptor)
+ // 1) All quadrangles generated by NETGEN are moved to an inexistent face
+ // by FillSMesh() (find "AddFaceDescriptor")
// 2) Temporary triangles generated by StdMeshers_QuadToTriaAdaptor
// are on faces where quadrangles were.
- // Due to these 2 points, wrong geom faces are used while conversion to qudratic
+ // Due to these 2 points, wrong geom faces are used while conversion to quadratic
// of the mentioned above quadrangles and triangles
// Orient the face correctly in solidID1 (issue 0020206)
// Add surface elements
netgen::Element2d tri(3);
- tri.SetIndex ( faceNgID );
-
+ tri.SetIndex( faceNgID );
+ SMESH_TNodeXYZ xyz[3];
#ifdef DUMP_TRIANGLES
cout << "SMESH face " << helper.GetMeshDS()->ShapeToIndex( geomFace )
if ( const TopoDS_Shape * solid = solidIt->next() )
sm = _mesh->GetSubMesh( *solid );
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
- smError.reset( new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH,"Not triangle submesh"));
+ smError.reset( new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH,"Not triangle sub-mesh"));
smError->myBadElements.push_back( f );
return false;
}
for ( int i = 0; i < 3; ++i )
{
const SMDS_MeshNode* node = f->GetNode( i ), * inFaceNode=0;
+ xyz[i].Set( node );
// get node UV on face
int shapeID = node->getshapeId();
if ( helper.IsSeamShape( shapeID ))
+ {
if ( helper.IsSeamShape( f->GetNodeWrap( i+1 )->getshapeId() ))
inFaceNode = f->GetNodeWrap( i-1 );
- else
+ else
inFaceNode = f->GetNodeWrap( i+1 );
+ }
gp_XY uv = helper.GetNodeUV( geomFace, node, inFaceNode );
int ind = reverse ? 3-i : i+1;
tri.PNum (ind) = ngNodeId( node, ngMesh, nodeNgIdMap );
}
+ // pass a triangle size to NG size-map
+ double size = ( ( xyz[0] - xyz[1] ).Modulus() +
+ ( xyz[1] - xyz[2] ).Modulus() +
+ ( xyz[2] - xyz[0] ).Modulus() ) / 3;
+ gp_XYZ gc = ( xyz[0] + xyz[1] + xyz[2] ) / 3;
+ RestrictLocalSize( ngMesh, gc, size, /*overrideMinH=*/false );
+
ngMesh.AddSurfaceElement (tri);
#ifdef DUMP_TRIANGLES
cout << tri << endl;
swap( tri[1], tri[2] );
ngMesh.AddSurfaceElement (tri);
#ifdef DUMP_TRIANGLES
- cout << tri << endl;
+ cout << tri << endl;
#endif
}
}
+
+ if ( quadHelper ) // remember medium nodes of sub-meshes
+ {
+ SMDS_ElemIteratorPtr faces = smDS->GetElements();
+ while ( faces->more() )
+ {
+ const SMDS_MeshElement* f = faces->next();
+ if ( !quadHelper->AddTLinks( static_cast< const SMDS_MeshFace*>( f )))
+ break;
+ }
+ }
+
break;
} // case TopAbs_FACE
while ( const TopoDS_Shape* e = ansIt->next() )
{
SMESH_subMesh* eSub = helper.GetMesh()->GetSubMesh( *e );
- if (( toAdd = eSub->IsEmpty() )) break;
+ if (( toAdd = ( eSub->IsEmpty() && !SMESH_Algo::isDegenerated( TopoDS::Edge( *e )))))
+ break;
}
if ( toAdd )
{
{
// duplicate faces
int i, nbFaces = ngMesh.GetNSE();
- for (int i = 1; i <= nbFaces; ++i)
+ for ( i = 1; i <= nbFaces; ++i)
{
netgen::Element2d elem = ngMesh.SurfaceElement(i);
if ( ngFaceIds.count( elem.GetIndex() ))
}
}
+//================================================================================
+/*!
+ * \brief Tries to heal the mesh on a FACE. The FACE is supposed to be partially
+ * meshed due to NETGEN failure
+ * \param [in] occgeom - geometry
+ * \param [in,out] ngMesh - the mesh to fix
+ * \param [inout] faceID - ID of the FACE to fix the mesh on
+ * \return bool - is mesh is or becomes OK
+ */
+//================================================================================
+
+bool NETGENPlugin_Mesher::FixFaceMesh(const netgen::OCCGeometry& occgeom,
+ netgen::Mesh& ngMesh,
+ const int faceID)
+{
+ // we address a case where the FACE is almost fully meshed except small holes
+ // of usually triangular shape at FACE boundary (IPAL52861)
+
+ // The case appeared to be not simple: holes only look triangular but
+ // indeed are a self intersecting polygon. A reason of the bug was in coincident
+ // NG points on a seam edge. But the code below is very nice, leave it for
+ // another case.
+ return false;
+
+
+ if ( occgeom.fmap.Extent() < faceID )
+ return false;
+ //const TopoDS_Face& face = TopoDS::Face( occgeom.fmap( faceID ));
+
+ // find free links on the FACE
+ NCollection_Map<Link> linkMap;
+ for ( int iF = 1; iF <= ngMesh.GetNSE(); ++iF )
+ {
+ const netgen::Element2d& elem = ngMesh.SurfaceElement(iF);
+ if ( faceID != elem.GetIndex() )
+ continue;
+ int n0 = elem[ elem.GetNP() - 1 ];
+ for ( int i = 0; i < elem.GetNP(); ++i )
+ {
+ int n1 = elem[i];
+ Link link( n0, n1 );
+ if ( !linkMap.Add( link ))
+ linkMap.Remove( link );
+ n0 = n1;
+ }
+ }
+ // add/remove boundary links
+ for ( int iSeg = 1; iSeg <= ngMesh.GetNSeg(); ++iSeg )
+ {
+ const netgen::Segment& seg = ngMesh.LineSegment( iSeg );
+ if ( seg.si != faceID ) // !edgeIDs.Contains( seg.edgenr ))
+ continue;
+ Link link( seg[1], seg[0] ); // reverse!!!
+ if ( !linkMap.Add( link ))
+ linkMap.Remove( link );
+ }
+ if ( linkMap.IsEmpty() )
+ return true;
+ if ( linkMap.Extent() < 3 )
+ return false;
+
+ // make triangles of the links
+
+ netgen::Element2d tri(3);
+ tri.SetIndex ( faceID );
+
+ NCollection_Map<Link>::Iterator linkIt( linkMap );
+ Link link1 = linkIt.Value();
+ // look for a link connected to link1
+ NCollection_Map<Link>::Iterator linkIt2 = linkIt;
+ for ( linkIt2.Next(); linkIt2.More(); linkIt2.Next() )
+ {
+ const Link& link2 = linkIt2.Value();
+ if ( link2.IsConnected( link1 ))
+ {
+ // look for a link connected to both link1 and link2
+ NCollection_Map<Link>::Iterator linkIt3 = linkIt2;
+ for ( linkIt3.Next(); linkIt3.More(); linkIt3.Next() )
+ {
+ const Link& link3 = linkIt3.Value();
+ if ( link3.IsConnected( link1 ) &&
+ link3.IsConnected( link2 ) )
+ {
+ // add a triangle
+ tri[0] = link1.n2;
+ tri[1] = link1.n1;
+ tri[2] = ( link2.Contains( link1.n1 ) ? link2.n1 : link3.n1 );
+ if ( tri[0] == tri[2] || tri[1] == tri[2] )
+ return false;
+ ngMesh.AddSurfaceElement( tri );
+
+ // prepare for the next tria search
+ if ( linkMap.Extent() == 3 )
+ return true;
+ linkMap.Remove( link3 );
+ linkMap.Remove( link2 );
+ linkIt.Next();
+ linkMap.Remove( link1 );
+ link1 = linkIt.Value();
+ linkIt2 = linkIt;
+ break;
+ }
+ }
+ }
+ }
+ return false;
+
+} // FixFaceMesh()
+
namespace
{
//================================================================================
return dist3D;
// start recursion if necessary
- double dist2D = SMESH_MesherHelper::applyIn2D(surf, uv1, uv2, gp_XY_Subtracted, 0).Modulus();
+ double dist2D = SMESH_MesherHelper::ApplyIn2D(surf, uv1, uv2, gp_XY_Subtracted, 0).Modulus();
if ( fabs( dist3D - dist2D ) < dist2D * 1e-10 )
return dist3D; // equal parametrization of a planar surface
vector<const SMDS_MeshNode*>& nodeVec,
NETGENPlugin_Internals& internalShapes)
{
- if ( nodeVec.size() < ngMesh.GetNP() )
+ if ((int) nodeVec.size() < ngMesh.GetNP() )
nodeVec.resize( ngMesh.GetNP(), 0 );
SMESHDS_Mesh* meshDS = internalShapes.getMesh().GetMeshDS();
nodeVec.push_back( nV );
// get node UV
- bool uvOK = false;
+ bool uvOK = true;
vData.uv = helper.GetNodeUV( face, nV, 0, &uvOK );
if ( !uvOK ) helper.CheckNodeUV( face, nV, vData.uv, BRep_Tool::Tolerance(V),/*force=*/1);
{
uv[iEnd].SetCoord( seg.epgeominfo[iEnd].u, seg.epgeominfo[iEnd].v );
if ( ngIdLast == seg[ iEnd ] ) continue;
- dist2 = helper.applyIn2D(surf, uv[iEnd], vData.uv, gp_XY_Subtracted,0).SquareModulus();
+ dist2 = helper.ApplyIn2D(surf, uv[iEnd], vData.uv, gp_XY_Subtracted,0).SquareModulus();
if ( dist2 < closeDist2 )
vData.ngIdClose = seg[ iEnd ], vData.uvClose = uv[iEnd], closeDist2 = dist2;
ngIdLast = seg[ iEnd ];
}
if ( !nbV )
{
- totSegLen2D += helper.applyIn2D(surf, uv[0], uv[1], gp_XY_Subtracted, false).Modulus();
+ totSegLen2D += helper.ApplyIn2D(surf, uv[0], uv[1], gp_XY_Subtracted, false).Modulus();
totNbSeg++;
}
}
for ( int iEnd = 0; iEnd < 2; ++iEnd)
{
uv[iEnd].SetCoord( seg.epgeominfo[iEnd].u, seg.epgeominfo[iEnd].v );
- dist2 = helper.applyIn2D(surf, uv[iEnd], vData.uv, gp_XY_Subtracted,0).SquareModulus();
+ dist2 = helper.ApplyIn2D(surf, uv[iEnd], vData.uv, gp_XY_Subtracted,0).SquareModulus();
if ( dist2 < closeDist2 )
vData.ngIdClose = seg[ iEnd ], vData.uvClose = uv[iEnd], closeDist2 = dist2;
}
// how far from V
double r = min( 0.5, ( hintLenOK ? segLenHint/nodeDist3D : avgSegLen2d/nodeDist2D ));
// direction from V to closet node in 2D
- gp_Dir2d v2n( helper.applyIn2D(surf, uvP, uvV, gp_XY_Subtracted, false ));
+ gp_Dir2d v2n( helper.ApplyIn2D(surf, uvP, uvV, gp_XY_Subtracted, false ));
// new point
uvP = vData.uv + r * nodeDist2D * v2n.XY();
gp_Pnt P = surf->Value( uvP.X(), uvP.Y() ).Transformed( loc );
ngMesh.AddSegment (seg);
// add reverse segment
- swap (seg[0], seg[1]);
+ swap( seg[0], seg[1] );
swap( seg.epgeominfo[0], seg.epgeominfo[1] );
seg.edgenr = ngMesh.GetNSeg() + 1; // segment id
ngMesh.AddSegment (seg);
ofstream py(DUMP_TRIANGLES_SCRIPT);
py << "import SMESH"<< endl
<< "from salome.smesh import smeshBuilder"<<endl
- << "smesh = smeshBuilder.New(salome.myStudy)"
+ << "smesh = smeshBuilder.New(salome.myStudy)"<<endl
<< "m = smesh.Mesh(name='triangles')" << endl;
#endif
- if ( nodeVec.size() < ngMesh.GetNP() )
+ if ((int) nodeVec.size() < ngMesh.GetNP() )
nodeVec.resize( ngMesh.GetNP(), 0 );
SMESHDS_Mesh* meshDS = internalShapes.getMesh().GetMeshDS();
// decide whether to use the closest node and the node with best angle or to create new ones
for ( int isBestAngleN = 0; isBestAngleN < 2; ++isBestAngleN )
{
- bool createNew = !angleOK, distOK = true;
+ bool createNew = !angleOK; //, distOK = true;
double distFromV;
int triInd = isBestAngleN ? 2 : 1;
mp[isBestAngleN] = ngMesh.Point( tri[triInd] );
else
{
double segLenHint = ngMesh.GetH( ngMesh.Point( vData.ngId ));
- bool avgLenOK = ( avgSegLen < 0.75 * distN1 );
- bool hintLenOK = ( segLenHint < 0.75 * distN1 );
+ bool avgLenOK = ( avgSegLen < 0.75 * distN1 );
+ bool hintLenOK = ( segLenHint < 0.75 * distN1 );
createNew = (createNew || avgLenOK || hintLenOK );
// we create a new node not closer than 0.5 to the closest face
// in order not to clash with other close face
ngMesh.AddSurfaceElement (tri);
#ifdef DUMP_TRIANGLES_SCRIPT
- py << "n1 = m.AddNode( "<< mpV.X()<<", "<< mpV.Y()<<", "<< mpV.Z()<<") "<< endl
- << "n2 = m.AddNode( "<< mp[0].X()<<", "<< mp[0].Y()<<", "<< mp[0].Z()<<") "<< endl
- << "n3 = m.AddNode( "<< mp[1].X()<<", "<< mp[1].Y()<<", "<< mp[1].Z()<<" )" << endl
+ py << "n1 = m.AddNode( "<< mpV(0)<<", "<< mpV(1)<<", "<< mpV(2)<<") "<< endl
+ << "n2 = m.AddNode( "<< mp[0](0)<<", "<< mp[0](1)<<", "<< mp[0](2)<<") "<< endl
+ << "n3 = m.AddNode( "<< mp[1](0)<<", "<< mp[1](1)<<", "<< mp[1](2)<<" )" << endl
<< "m.AddFace([n1,n2,n3])" << endl;
#endif
} // loop on internal vertices of a solid
netgen::OCCGeometry& geom,
const TSideVector& wires,
SMESH_MesherHelper& helper,
- vector< const SMDS_MeshNode* > & nodeVec)
+ vector< const SMDS_MeshNode* > & nodeVec,
+ const bool overrideMinH)
{
// ----------------------------
// Check wires and count nodes
// ----------------------------
int nbNodes = 0;
- for ( int iW = 0; iW < wires.size(); ++iW )
+ for ( size_t iW = 0; iW < wires.size(); ++iW )
{
StdMeshers_FaceSidePtr wire = wires[ iW ];
if ( wire->MissVertexNode() )
// (new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH, "Missing nodes on vertices"));
}
const vector<UVPtStruct>& uvPtVec = wire->GetUVPtStruct();
- if ( uvPtVec.size() != wire->NbPoints() )
+ if ((int) uvPtVec.size() != wire->NbPoints() )
return SMESH_ComputeError::New(COMPERR_BAD_INPUT_MESH,
SMESH_Comment("Unexpected nb of points on wire ") << iW
<< ": " << uvPtVec.size()<<" != "<<wire->NbPoints());
if ( !wasNgMeshEmpty ) // fill node2ngID with nodes built by NETGEN
{
set< int > subIDs; // ids of sub-shapes of the FACE
- for ( int iW = 0; iW < wires.size(); ++iW )
+ for ( size_t iW = 0; iW < wires.size(); ++iW )
{
StdMeshers_FaceSidePtr wire = wires[ iW ];
for ( int iE = 0, nbE = wire->NbEdges(); iE < nbE; ++iE )
const int solidID = 0, faceID = geom.fmap.FindIndex( helper.GetSubShape() );
if ( ngMesh.GetNFD() < 1 )
- ngMesh.AddFaceDescriptor (netgen::FaceDescriptor(faceID, solidID, solidID, 0));
+ ngMesh.AddFaceDescriptor( netgen::FaceDescriptor( faceID, solidID, solidID, 0 ));
- for ( int iW = 0; iW < wires.size(); ++iW )
+ for ( size_t iW = 0; iW < wires.size(); ++iW )
{
- StdMeshers_FaceSidePtr wire = wires[ iW ];
+ StdMeshers_FaceSidePtr wire = wires[ iW ];
const vector<UVPtStruct>& uvPtVec = wire->GetUVPtStruct();
- const int nbSegments = wire->NbPoints() - 1;
+ const int nbSegments = wire->NbPoints() - 1;
// assure the 1st node to be in node2ngID, which is needed to correctly
// "close chain of segments" (see below) in case if the 1st node is not
continue;
int ngID1 = ngMesh.GetNP() + 1, ngID2 = ngID1+1;
- if ( onVertex || ( !wasNgMeshEmpty && onEdge ))
+ if ( onVertex || ( !wasNgMeshEmpty && onEdge ) || helper.IsRealSeam( posShapeID ))
ngID1 = node2ngID.insert( make_pair( n, ngID1 )).first->second;
if ( ngID1 > ngMesh.GetNP() )
{
// element size (regression on issue 0020452, note 0010898)
int iPrev = SMESH_MesherHelper::WrapIndex( i-1, nbSegments );
int iNext = SMESH_MesherHelper::WrapIndex( i+1, nbSegments );
- double sunH = segLen[ iPrev ] + segLen[ i ] + segLen[ iNext ];
- int nbSeg = ( int( segLen[ iPrev ] > sunH / 100.) +
- int( segLen[ i ] > sunH / 100.) +
- int( segLen[ iNext ] > sunH / 100.));
+ double sumH = segLen[ iPrev ] + segLen[ i ] + segLen[ iNext ];
+ int nbSeg = ( int( segLen[ iPrev ] > sumH / 100.) +
+ int( segLen[ i ] > sumH / 100.) +
+ int( segLen[ iNext ] > sumH / 100.));
if ( nbSeg > 0 )
- RestrictLocalSize( ngMesh, 0.5*(np1+np2), sunH / nbSeg );
+ RestrictLocalSize( ngMesh, 0.5*(np1+np2), sumH / nbSeg, overrideMinH );
}
if ( isInternalWire )
{
// close chain of segments
if ( nbSegments > 0 )
{
- netgen::Segment& lastSeg = ngMesh.LineSegment( ngMesh.GetNSeg() - int( isInternalWire));
+ netgen::Segment& lastSeg = ngMesh.LineSegment( ngMesh.GetNSeg() - int( isInternalWire ));
const SMDS_MeshNode * lastNode = uvPtVec.back().node;
lastSeg[1] = node2ngID.insert( make_pair( lastNode, lastSeg[1] )).first->second;
if ( lastSeg[1] > ngMesh.GetNP() )
}
}
cout << "Segment: " << seg.edgenr << endl
- << "\tp1: " << seg[0] << endl
- << "\tp2: " << seg[1] << endl
+ << "\tp1: " << seg[0] << " n" << nodeVec[ seg[0]]->GetID() << endl
+ << "\tp2: " << seg[1] << " n" << nodeVec[ seg[1]]->GetID() << endl
<< "\tp0 param: " << seg.epgeominfo[ 0 ].dist << endl
<< "\tp0 uv: " << seg.epgeominfo[ 0 ].u <<", "<< seg.epgeominfo[ 0 ].v << endl
<< "\tp0 edge: " << seg.epgeominfo[ 0 ].edgenr << endl
<< "\tp1 edge: " << seg.epgeominfo[ 1 ].edgenr << endl;
}
cout << "--END WIRE " << iW << endl;
+#else
+ SMESH_Comment __not_unused_variable( prevNbNGSeg );
#endif
} // loop on WIREs of a FACE
* \param initState - bn of entities in netgen mesh before computing
* \param sMesh - SMESH mesh to fill in
* \param nodeVec - vector of nodes in which node index == netgen ID
+ * \param comment - returns problem description
+ * \param quadHelper - holder of medium nodes of sub-meshes
* \retval int - error
*/
//================================================================================
const NETGENPlugin_ngMeshInfo& initState,
SMESH_Mesh& sMesh,
std::vector<const SMDS_MeshNode*>& nodeVec,
- SMESH_Comment& comment)
+ SMESH_Comment& comment,
+ SMESH_MesherHelper* quadHelper)
{
int nbNod = ngMesh.GetNP();
int nbSeg = ngMesh.GetNSeg();
SMESHDS_Mesh* meshDS = sMesh.GetMeshDS();
+ // quadHelper is used for either
+ // 1) making quadratic elements when a lower dimention mesh is loaded
+ // to SMESH before convertion to quadratic by NETGEN
+ // 2) sewing of quadratic elements with quadratic elements of sub-meshes
+ if ( quadHelper && !quadHelper->GetIsQuadratic() && quadHelper->GetTLinkNodeMap().empty() )
+ quadHelper = 0;
+
// -------------------------------------
// Create and insert nodes into nodeVec
// -------------------------------------
gp_Pnt p ( NGPOINT_COORDS(ngPoint) );
for (int iV = i-nbInitNod; aVert.IsNull() && iV <= occgeo.vmap.Extent(); ++iV)
{
- aVert = TopoDS::Vertex( occgeo.vmap( iV ) );
+ aVert = TopoDS::Vertex( occgeo.vmap( iV ));
gp_Pnt pV = BRep_Tool::Pnt( aVert );
if ( p.SquareDistance( pV ) > 1e-20 )
aVert.Nullify();
{
if ( meshDS->FindEdge( nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1])))
continue;
- edge = meshDS->AddEdge(nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1]));
+ if ( quadHelper ) // final mesh must be quadratic
+ edge = quadHelper->AddEdge(nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1]));
+ else
+ edge = meshDS->AddEdge(nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1]));
}
else
{
// from computation of 3D mesh
ngMesh.AddFaceDescriptor (netgen::FaceDescriptor(quadFaceID, /*solid1=*/0, /*solid2=*/0, 0));
+ vector<const SMDS_MeshNode*> nodes;
for (i = nbInitFac+1; i <= nbFac; ++i )
{
const netgen::Element2d& elem = ngMesh.SurfaceElement(i);
- int aGeomFaceInd = elem.GetIndex();
+ const int aGeomFaceInd = elem.GetIndex();
TopoDS_Face aFace;
if (aGeomFaceInd > 0 && aGeomFaceInd <= occgeo.fmap.Extent())
aFace = TopoDS::Face(occgeo.fmap(aGeomFaceInd));
- vector<SMDS_MeshNode*> nodes;
- for (int j=1; j <= elem.GetNP(); ++j)
+ nodes.clear();
+ for ( int j = 1; j <= elem.GetNP(); ++j )
{
int pind = elem.PNum(j);
- if ( pind < 1 || pind >= nodeVec.size() )
+ if ( pind < 1 || pind >= (int) nodeVec.size() )
break;
if ( SMDS_MeshNode* node = nodeVec_ACCESS(pind))
{
- nodes.push_back(node);
+ nodes.push_back( node );
if (!aFace.IsNull() && node->getshapeId() < 1)
{
const netgen::PointGeomInfo& pgi = elem.GeomInfoPi(j);
}
}
}
- if ( nodes.size() != elem.GetNP() )
+ if ((int) nodes.size() != elem.GetNP() )
{
if ( comment.empty() )
comment << "Invalid netgen 2d element #" << i;
switch (elem.GetType())
{
case netgen::TRIG:
- face = meshDS->AddFace(nodes[0],nodes[1],nodes[2]);
+ if ( quadHelper ) // final mesh must be quadratic
+ face = quadHelper->AddFace(nodes[0],nodes[1],nodes[2]);
+ else
+ face = meshDS->AddFace(nodes[0],nodes[1],nodes[2]);
break;
case netgen::QUAD:
- face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[3]);
+ if ( quadHelper ) // final mesh must be quadratic
+ face = quadHelper->AddFace(nodes[0],nodes[1],nodes[2],nodes[3]);
+ else
+ face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[3]);
// exclude qudrangle elements from computation of 3D mesh
const_cast< netgen::Element2d& >( elem ).SetIndex( quadFaceID );
break;
case netgen::TRIG6:
+ nodes[5] = mediumNode( nodes[0],nodes[1],nodes[5], quadHelper );
+ nodes[3] = mediumNode( nodes[1],nodes[2],nodes[3], quadHelper );
+ nodes[4] = mediumNode( nodes[2],nodes[0],nodes[4], quadHelper );
face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[5],nodes[3],nodes[4]);
break;
case netgen::QUAD8:
+ nodes[4] = mediumNode( nodes[0],nodes[1],nodes[4], quadHelper );
+ nodes[7] = mediumNode( nodes[1],nodes[2],nodes[7], quadHelper );
+ nodes[5] = mediumNode( nodes[2],nodes[3],nodes[5], quadHelper );
+ nodes[6] = mediumNode( nodes[3],nodes[0],nodes[6], quadHelper );
face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[3],
nodes[4],nodes[7],nodes[5],nodes[6]);
// exclude qudrangle elements from computation of 3D mesh
MESSAGE("NETGEN created a face of unexpected type, ignoring");
continue;
}
- if (!face)
+ if ( !face )
{
if ( comment.empty() ) comment << "Cannot create a mesh face";
MESSAGE("Cannot create a mesh face");
nbSeg = nbFac = nbVol = 0;
break;
}
- if (!aFace.IsNull())
- meshDS->SetMeshElementOnShape(face, aFace);
+ if ( !aFace.IsNull() )
+ meshDS->SetMeshElementOnShape( face, aFace );
}
// ------------------
// Create tetrahedra
// ------------------
- for (i = 1; i <= nbVol; ++i)
+ for ( i = 1; i <= nbVol; ++i )
{
const netgen::Element& elem = ngMesh.VolumeElement(i);
int aSolidInd = elem.GetIndex();
TopoDS_Solid aSolid;
- if (aSolidInd > 0 && aSolidInd <= occgeo.somap.Extent())
+ if ( aSolidInd > 0 && aSolidInd <= occgeo.somap.Extent() )
aSolid = TopoDS::Solid(occgeo.somap(aSolidInd));
- vector<SMDS_MeshNode*> nodes;
- for (int j=1; j <= elem.GetNP(); ++j)
+ nodes.clear();
+ for ( int j = 1; j <= elem.GetNP(); ++j )
{
int pind = elem.PNum(j);
- if ( pind < 1 || pind >= nodeVec.size() )
+ if ( pind < 1 || pind >= (int)nodeVec.size() )
break;
if ( SMDS_MeshNode* node = nodeVec_ACCESS(pind) )
{
meshDS->SetNodeInVolume(node, aSolid);
}
}
- if ( nodes.size() != elem.GetNP() )
+ if ((int) nodes.size() != elem.GetNP() )
{
if ( comment.empty() )
comment << "Invalid netgen 3d element #" << i;
continue;
}
SMDS_MeshVolume* vol = NULL;
- switch (elem.GetType())
+ switch ( elem.GetType() )
{
case netgen::TET:
vol = meshDS->AddVolume(nodes[0],nodes[1],nodes[2],nodes[3]);
break;
case netgen::TET10:
+ nodes[4] = mediumNode( nodes[0],nodes[1],nodes[4], quadHelper );
+ nodes[7] = mediumNode( nodes[1],nodes[2],nodes[7], quadHelper );
+ nodes[5] = mediumNode( nodes[2],nodes[0],nodes[5], quadHelper );
+ nodes[6] = mediumNode( nodes[0],nodes[3],nodes[6], quadHelper );
+ nodes[8] = mediumNode( nodes[1],nodes[3],nodes[8], quadHelper );
+ nodes[9] = mediumNode( nodes[2],nodes[3],nodes[9], quadHelper );
vol = meshDS->AddVolume(nodes[0],nodes[1],nodes[2],nodes[3],
nodes[4],nodes[7],nodes[5],nodes[6],nodes[8],nodes[9]);
break;
namespace
{
- //================================================================================
- /*!
- * \brief Restrict size of elements on the given edge
- */
- //================================================================================
-
- void setLocalSize(const TopoDS_Edge& edge,
- double size,
- netgen::Mesh& mesh)
- {
- const int nb = 1000;
- Standard_Real u1, u2;
- Handle(Geom_Curve) curve = BRep_Tool::Curve(edge, u1, u2);
- if ( curve.IsNull() )
- {
- TopoDS_Iterator vIt( edge );
- if ( !vIt.More() ) return;
- gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( vIt.Value() ));
- NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), size );
- }
- else
- {
- Standard_Real delta = (u2-u1)/nb;
- for(int i=0; i<nb; i++)
- {
- Standard_Real u = u1 + delta*i;
- gp_Pnt p = curve->Value(u);
- NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), size );
- netgen::Point3d pi(p.X(), p.Y(), p.Z());
- double resultSize = mesh.GetH(pi);
- if ( resultSize - size > 0.1*size )
- // netgen does restriction iff oldH/newH > 1.2 (localh.cpp:136)
- NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), resultSize/1.201 );
- }
- }
- }
-
//================================================================================
/*!
* \brief Convert error into text
return str;
}
+ //================================================================================
+ /*!
+ * \brief Looks for triangles lying on a SOLID
+ */
+ //================================================================================
+
+ bool hasBadElemOnSolid( const list<const SMDS_MeshElement*>& elems,
+ SMESH_subMesh* solidSM )
+ {
+ TopTools_IndexedMapOfShape solidSubs;
+ TopExp::MapShapes( solidSM->GetSubShape(), solidSubs );
+ SMESHDS_Mesh* mesh = solidSM->GetFather()->GetMeshDS();
+
+ list<const SMDS_MeshElement*>::const_iterator e = elems.begin();
+ for ( ; e != elems.end(); ++e )
+ {
+ const SMDS_MeshElement* elem = *e;
+ // if ( elem->GetType() != SMDSAbs_Face ) -- 23047
+ // continue;
+ int nbNodesOnSolid = 0, nbNodes = elem->NbNodes();
+ SMDS_NodeIteratorPtr nIt = elem->nodeIterator();
+ while ( nIt->more() )
+ {
+ const SMDS_MeshNode* n = nIt->next();
+ const TopoDS_Shape& s = mesh->IndexToShape( n->getshapeId() );
+ nbNodesOnSolid += ( !s.IsNull() && solidSubs.Contains( s ));
+ if ( nbNodesOnSolid > 2 ||
+ nbNodesOnSolid == nbNodes)
+ return true;
+ }
+ }
+ return false;
+ }
+
const double edgeMeshingTime = 0.001;
const double faceMeshingTime = 0.019;
const double edgeFaceMeshingTime = edgeMeshingTime + faceMeshingTime;
NETGENPlugin_NetgenLibWrapper ngLib;
netgen::MeshingParameters& mparams = netgen::mparam;
- MESSAGE("Compute with:\n"
- " max size = " << mparams.maxh << "\n"
- " segments per edge = " << mparams.segmentsperedge);
- MESSAGE("\n"
- " growth rate = " << mparams.grading << "\n"
- " elements per radius = " << mparams.curvaturesafety << "\n"
- " second order = " << mparams.secondorder << "\n"
- " quad allowed = " << mparams.quad << "\n"
- " surface curvature = " << mparams.uselocalh << "\n"
- " fuse edges = " << netgen::merge_solids);
SMESH_ComputeErrorPtr error = SMESH_ComputeError::New();
+ SMESH_MesherHelper quadHelper( *_mesh );
+ quadHelper.SetIsQuadratic( mparams.secondorder );
- static string debugFile = "/tmp/ngMesh.py"; /* to call toPython( ngMesh, debugFile )
+ static string debugFile = "/tmp/ngMesh.py"; /* to call toPython( _ngMesh, debugFile )
while debugging netgen */
// -------------------------
// Prepare OCC geometry
{
comment << text(ex);
}
+ catch (netgen::NgException & ex)
+ {
+ comment << text(ex);
+ if ( mparams.meshsizefilename )
+ throw SMESH_ComputeError(COMPERR_BAD_PARMETERS, comment );
+ }
err = 0; //- MESHCONST_ANALYSE isn't so important step
if ( !_ngMesh )
return false;
_ngMesh->ClearFaceDescriptors(); // we make descriptors our-self
+ if ( !mparams.uselocalh ) // mparams.grading is not taken into account yet
+ _ngMesh->LocalHFunction().SetGrading( mparams.grading );
+
if ( _simpleHyp )
{
// Pass 1D simple parameters to NETGEN
}
else // if ( ! _simpleHyp )
{
- // Local size on vertices and edges
- // --------------------------------
- for(std::map<int,double>::const_iterator it=EdgeId2LocalSize.begin(); it!=EdgeId2LocalSize.end(); it++)
- {
- int key = (*it).first;
- double hi = (*it).second;
- const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
- const TopoDS_Edge& e = TopoDS::Edge(shape);
- setLocalSize( e, hi, *_ngMesh );
- }
- for(std::map<int,double>::const_iterator it=VertexId2LocalSize.begin(); it!=VertexId2LocalSize.end(); it++)
- {
- int key = (*it).first;
- double hi = (*it).second;
- const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
- const TopoDS_Vertex& v = TopoDS::Vertex(shape);
- gp_Pnt p = BRep_Tool::Pnt(v);
- NETGENPlugin_Mesher::RestrictLocalSize( *_ngMesh, p.XYZ(), hi );
- }
- for(map<int,double>::const_iterator it=FaceId2LocalSize.begin();
- it!=FaceId2LocalSize.end(); it++)
- {
- int key = (*it).first;
- double val = (*it).second;
- const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
- int faceNgID = occgeo.fmap.FindIndex(shape);
- occgeo.SetFaceMaxH(faceNgID, val);
- for ( TopExp_Explorer edgeExp( shape, TopAbs_EDGE ); edgeExp.More(); edgeExp.Next() )
- setLocalSize( TopoDS::Edge( edgeExp.Current() ), val, *_ngMesh );
- }
+ // Local size on shapes
+ SetLocalSize( occgeo, *_ngMesh );
}
// Precompute internal edges (issue 0020676) in order to
if ( !err )
{
err = ! ( FillNgMesh(occgeo, *_ngMesh, nodeVec, meshedSM[ MeshDim_0D ]) &&
- FillNgMesh(occgeo, *_ngMesh, nodeVec, meshedSM[ MeshDim_1D ]));
+ FillNgMesh(occgeo, *_ngMesh, nodeVec, meshedSM[ MeshDim_1D ], &quadHelper));
}
initState = NETGENPlugin_ngMeshInfo(_ngMesh);
}
// Build viscous layers
- if ( _isViscousLayers2D )
+ if ( _isViscousLayers2D ||
+ StdMeshers_ViscousLayers2D::HasProxyMesh( TopoDS::Face( occgeo.fmap(1) ), *_mesh ))
{
if ( !internals.hasInternalVertexInFace() ) {
FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment );
viscousMesh = StdMeshers_ViscousLayers2D::Compute( *_mesh, F );
if ( !viscousMesh )
return false;
+ if ( viscousMesh->NbProxySubMeshes() == 0 )
+ continue;
// exclude from computation ng segments built on EDGEs of F
for (int i = 1; i <= _ngMesh->GetNSeg(); i++)
{
if ( !err && _isVolume && ( !meshedSM[ MeshDim_2D ].empty() || mparams.quad ))
{
// load SMESH with computed segments and faces
- FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment );
+ FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment, &quadHelper );
// compute pyramids on quadrangles
SMESH_ProxyMesh::Ptr proxyMesh;
quadFaceSM.push_back( _mesh->GetSubMesh( face.Current() ));
meshedSM[ MeshDim_2D ].remove( quadFaceSM.back() );
}
- FillNgMesh(occgeo, *_ngMesh, nodeVec, quadFaceSM, proxyMesh);
+ FillNgMesh(occgeo, *_ngMesh, nodeVec, quadFaceSM, &quadHelper, proxyMesh);
}
}
// fill _ngMesh with faces of sub-meshes
- err = ! ( FillNgMesh(occgeo, *_ngMesh, nodeVec, meshedSM[ MeshDim_2D ]));
+ err = ! ( FillNgMesh(occgeo, *_ngMesh, nodeVec, meshedSM[ MeshDim_2D ], &quadHelper));
initState = NETGENPlugin_ngMeshInfo(_ngMesh);
//toPython( _ngMesh, "/tmp/ngPython.py");
}
{
// store computed faces in SMESH in order not to create SMESH
// faces for ng faces added here
- FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment );
+ FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment, &quadHelper );
// add ng faces to solids with internal vertices
AddIntVerticesInSolids( occgeo, *_ngMesh, nodeVec, internals );
// duplicate mesh faces on internal faces
try
{
OCC_CATCH_SIGNALS;
+ if ( !meshedSM[ MeshDim_1D ].empty() )
+ {
+ // remove segments not attached to geometry (IPAL0052479)
+ for (int i = 1; i <= _ngMesh->GetNSeg(); ++i)
+ {
+ const netgen::Segment & seg = _ngMesh->LineSegment (i);
+ if ( seg.epgeominfo[ 0 ].edgenr == 0 )
+ _ngMesh->DeleteSegment( i );
+ }
+ _ngMesh->Compress();
+ }
+ // convert to quadratic
netgen::OCCRefinementSurfaces ref (occgeo);
ref.MakeSecondOrder (*_ngMesh);
+
+ // care of elements already loaded to SMESH
+ // if ( initState._nbSegments > 0 )
+ // makeQuadratic( occgeo.emap, _mesh );
+ // if ( initState._nbFaces > 0 )
+ // makeQuadratic( occgeo.fmap, _mesh );
}
catch (Standard_Failure& ex)
{
_ticTime = 0.98 / _progressTic;
- int nbNod = _ngMesh->GetNP();
- int nbSeg = _ngMesh->GetNSeg();
+ //int nbNod = _ngMesh->GetNP();
+ //int nbSeg = _ngMesh->GetNSeg();
int nbFac = _ngMesh->GetNSE();
int nbVol = _ngMesh->GetNE();
bool isOK = ( !err && (_isVolume ? (nbVol > 0) : (nbFac > 0)) );
- MESSAGE((err ? "Mesh Generation failure" : "End of Mesh Generation") <<
- ", nb nodes: " << nbNod <<
- ", nb segments: " << nbSeg <<
- ", nb faces: " << nbFac <<
- ", nb volumes: " << nbVol);
-
// Feed back the SMESHDS with the generated Nodes and Elements
if ( true /*isOK*/ ) // get whatever built
- FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment ); //!<
+ {
+ FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment, &quadHelper );
+ if ( quadHelper.GetIsQuadratic() ) // remove free nodes
+ for ( size_t i = 0; i < nodeVec.size(); ++i )
+ if ( nodeVec[i] && nodeVec[i]->NbInverseElements() == 0 )
+ _mesh->GetMeshDS()->RemoveFreeNode( nodeVec[i], 0, /*fromGroups=*/false );
+ }
SMESH_ComputeErrorPtr readErr = ReadErrors(nodeVec);
if ( readErr && !readErr->myBadElements.empty() )
+ {
error = readErr;
-
+ if ( !comment.empty() && !readErr->myComment.empty() ) comment += "\n";
+ comment += readErr->myComment;
+ }
if ( error->IsOK() && ( !isOK || comment.size() > 0 ))
error->myName = COMPERR_ALGO_FAILED;
if ( !comment.empty() )
bool pb2D = false, pb3D = false;
for (int i = 1; i <= occgeo.fmap.Extent(); i++) {
int status = occgeo.facemeshstatus[i-1];
- if (status == 1 ) continue;
+ if (status == netgen::FACE_MESHED_OK ) continue;
if ( SMESH_subMesh* sm = _mesh->GetSubMeshContaining( occgeo.fmap( i ))) {
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
if ( !smError || smError->IsOK() ) {
- if ( status == -1 )
+ if ( status == netgen::FACE_FAILED )
smError.reset( new SMESH_ComputeError( *error ));
else
smError.reset( new SMESH_ComputeError( COMPERR_ALGO_FAILED, "Ignored" ));
{
smError.reset( new SMESH_ComputeError( *error ));
if ( nbVol && SMESH_Algo::GetMeshError( sm ) == SMESH_Algo::MEr_OK )
+ {
smError->myName = COMPERR_WARNING;
+ }
+ else if ( !smError->myBadElements.empty() ) // bad surface mesh
+ {
+ if ( !hasBadElemOnSolid( smError->myBadElements, sm ))
+ smError.reset();
+ }
}
pb3D = pb3D || ( smError && smError->IsKO() );
}
}
else // if ( ! _simpleHyp )
{
- // Local size on vertices and edges
- // --------------------------------
- for(std::map<int,double>::const_iterator it=EdgeId2LocalSize.begin(); it!=EdgeId2LocalSize.end(); it++)
- {
- int key = (*it).first;
- double hi = (*it).second;
- const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
- const TopoDS_Edge& e = TopoDS::Edge(shape);
- setLocalSize( e, hi, *ngMesh );
- }
- for(std::map<int,double>::const_iterator it=VertexId2LocalSize.begin(); it!=VertexId2LocalSize.end(); it++)
- {
- int key = (*it).first;
- double hi = (*it).second;
- const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
- const TopoDS_Vertex& v = TopoDS::Vertex(shape);
- gp_Pnt p = BRep_Tool::Pnt(v);
- NETGENPlugin_Mesher::RestrictLocalSize( *ngMesh, p.XYZ(), hi );
- }
- for(map<int,double>::const_iterator it=FaceId2LocalSize.begin();
- it!=FaceId2LocalSize.end(); it++)
- {
- int key = (*it).first;
- double val = (*it).second;
- const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
- int faceNgID = occgeo.fmap.FindIndex(shape);
- occgeo.SetFaceMaxH(faceNgID, val);
- for ( TopExp_Explorer edgeExp( shape, TopAbs_EDGE ); edgeExp.More(); edgeExp.Next() )
- setLocalSize( TopoDS::Edge( edgeExp.Current() ), val, *ngMesh );
- }
+ // Local size on shapes
+ SetLocalSize( occgeo, *ngMesh );
}
// calculate total nb of segments and length of edges
double fullLen = 0.0;
// << " " << doneTime / _totalTime / _progressTic << endl;
}
}
+
if ( _ticTime > 0 )
progress = Max( *algoProgressTic * _ticTime, *algoProgress );
+
if ( progress > 0 )
{
+ if ( _isVolume &&
+ netgen::multithread.task[0] == 'D'/*elaunay meshing*/ &&
+ progress > voluMeshingTime )
+ {
+ progress = voluMeshingTime;
+ ((double&) _ticTime) = voluMeshingTime / _totalTime / _progressTic;
+ }
((int&) *algoProgressTic )++;
((double&) *algoProgress) = progress;
}
return Min( progress, 0.99 );
}
-//================================================================================
-/*!
- * \brief Remove "test.out" and "problemfaces" files in current directory
- */
-//================================================================================
-
-void NETGENPlugin_Mesher::RemoveTmpFiles()
-{
- bool rm = SMESH_File("test.out").remove() ;
-#ifndef WIN32
- if (rm && netgen::testout)
- {
- delete netgen::testout;
- netgen::testout = 0;
- }
-#endif
- SMESH_File("problemfaces").remove();
- SMESH_File("occmesh.rep").remove();
-}
-
//================================================================================
/*!
* \brief Read mesh entities preventing successful computation from "test.out" file
(COMPERR_BAD_INPUT_MESH, "Some edges multiple times in surface mesh");
SMESH_File file("test.out");
vector<int> two(2);
+ vector<int> three1(3), three2(3);
const char* badEdgeStr = " multiple times in surface mesh";
const int badEdgeStrLen = strlen( badEdgeStr );
+ const int nbNodes = nodeVec.size();
+
while( !file.eof() )
{
if ( strncmp( file, "Edge ", 5 ) == 0 &&
file.getInts( two ) &&
strncmp( file, badEdgeStr, badEdgeStrLen ) == 0 &&
- two[0] < nodeVec.size() && two[1] < nodeVec.size())
+ two[0] < nbNodes && two[1] < nbNodes )
{
err->myBadElements.push_back( new SMDS_LinearEdge( nodeVec[ two[0]], nodeVec[ two[1]] ));
file += badEdgeStrLen;
// openelement 18 with open element 126
// 41 36 38
// 69 70 72
- vector<int> three1(3), three2(3);
file.getLine();
const char* pos = file;
bool ok = ( strncmp( file, "openelement ", 12 ) == 0 );
ok = ok && file.getInts( three1 );
ok = ok && file.getInts( three2 );
for ( int i = 0; ok && i < 3; ++i )
- ok = ( three1[i] < nodeVec.size() && nodeVec[ three1[i]]);
+ ok = ( three1[i] < nbNodes && nodeVec[ three1[i]]);
for ( int i = 0; ok && i < 3; ++i )
- ok = ( three2[i] < nodeVec.size() && nodeVec[ three2[i]]);
+ ok = ( three2[i] < nbNodes && nodeVec[ three2[i]]);
if ( ok )
{
err->myBadElements.push_back( new SMDS_FaceOfNodes( nodeVec[ three1[0]],
++file;
}
}
+
+#ifdef _DEBUG_
+ size_t nbBadElems = err->myBadElements.size();
+ if ( nbBadElems ) nbBadElems++; // avoid warning: variable set but not used
+#endif
+
return err;
}
*/
//================================================================================
-void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh,
- const std::string& pyFile)
+void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh )
{
- ofstream outfile(pyFile.c_str(), ios::out);
+ const char* pyFile = "/tmp/ngMesh.py";
+ ofstream outfile( pyFile, ios::out );
if ( !outfile ) return;
outfile << "import SMESH" << endl
while ( fIt->more() )
{
const SMDS_MeshElement* f = fIt->next();
- int nbNodes = f->NbNodes() / ( f->IsQuadratic() ? 2 : 1 );
+ const int nbNodes = f->NbCornerNodes();
if ( intFaceSM->Contains( f ))
{
for ( int i = 0; i < nbNodes; ++i )
const SMDS_MeshElement* f = *fIt;
bool isBorder = false, linkFound = false, borderLinkFound = false;
list< SMESH_OrientedLink > faceLinks;
- int nbNodes = f->NbNodes() / ( f->IsQuadratic() ? 2 : 1 );
+ int nbNodes = f->NbCornerNodes();
for ( int i = 0; i < nbNodes; ++i )
{
SMESH_OrientedLink link( f->GetNode(i), f->GetNode((i+1)%nbNodes));
return const_cast<SMESH_Mesh&>( _mesh );
}
+//================================================================================
+/*!
+ * \brief Access to a counter of NETGENPlugin_NetgenLibWrapper instances
+ */
+//================================================================================
+
+int& NETGENPlugin_NetgenLibWrapper::instanceCounter()
+{
+ static int theCouner = 0;
+ return theCouner;
+}
+
//================================================================================
/*!
* \brief Initialize netgen library
NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper()
{
- Ng_Init();
-
- // redirect all netgen output (mycout,myerr,cout) to _outputFileName
- _isComputeOk = false;
- _outputFileName = getOutputFileName();
- netgen::mycout = new ofstream ( _outputFileName.c_str() );
- netgen::myerr = netgen::mycout;
- _coutBuffer = std::cout.rdbuf();
+ if ( instanceCounter() == 0 )
+ Ng_Init();
+
+ ++instanceCounter();
+
+ _isComputeOk = false;
+ _coutBuffer = NULL;
+ _ngcout = NULL;
+ _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_
- cout << "NOTE: netgen output is redirected to file " << _outputFileName << endl;
+ cout << "NOTE: netgen output is redirected to file " << _outputFileName << endl;
#else
- std::cout.rdbuf( netgen::mycout->rdbuf() );
+ std::cout.rdbuf( netgen::mycout->rdbuf() );
#endif
+ }
_ngMesh = Ng_NewMesh();
}
NETGENPlugin_NetgenLibWrapper::~NETGENPlugin_NetgenLibWrapper()
{
+ --instanceCounter();
+
Ng_DeleteMesh( _ngMesh );
Ng_Exit();
- NETGENPlugin_Mesher::RemoveTmpFiles();
- std::cout.rdbuf( _coutBuffer );
+ RemoveTmpFiles();
+ if ( _coutBuffer )
+ std::cout.rdbuf( _coutBuffer );
#ifdef _DEBUG_
if( _isComputeOk )
#endif
return aGenericName.ToCString();
}
+//================================================================================
+/*!
+ * \brief Remove "test.out" and "problemfaces" files in current directory
+ */
+//================================================================================
+
+void NETGENPlugin_NetgenLibWrapper::RemoveTmpFiles()
+{
+ bool rm = SMESH_File("test.out").remove() ;
+#ifndef WIN32
+ if ( rm && netgen::testout && instanceCounter() == 0 )
+ {
+ delete netgen::testout;
+ netgen::testout = 0;
+ }
+#endif
+ SMESH_File("problemfaces").remove();
+ SMESH_File("occmesh.rep").remove();
+}
+
//================================================================================
/*!
* \brief Remove file with netgen output
void NETGENPlugin_NetgenLibWrapper::removeOutputFile()
{
- string tmpDir = SALOMEDS_Tool::GetDirFromPath( _outputFileName );
- SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames;
- aFiles->length(1);
- std::string aFileName = SALOMEDS_Tool::GetNameFromPath( _outputFileName ) + ".out";
- aFiles[0] = aFileName.c_str();
- if ( netgen::mycout)
+ if ( !_outputFileName.empty() )
{
- delete netgen::mycout;
- netgen::mycout = 0;
- netgen::myerr = 0;
+ if ( _ngcout )
+ {
+ delete netgen::mycout;
+ netgen::mycout = _ngcout;
+ netgen::myerr = _ngcerr;
+ _ngcout = 0;
+ }
+ string tmpDir = SALOMEDS_Tool::GetDirFromPath ( _outputFileName );
+ string aFileName = SALOMEDS_Tool::GetNameFromPath( _outputFileName ) + ".out";
+ SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames;
+ aFiles->length(1);
+ aFiles[0] = aFileName.c_str();
+
+ SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles.in(), true );
}
-
- SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles.in(), true );
-#ifdef _DEBUG_
- //cout << "NOTE: netgen output log was REMOVED " << _outputFileName << endl;
-#endif
}