0020776: EDF 1329 NETGENPLUGIN : Create Group from Geometry issue
* Prevent setting a wrong node on vertex in case if there are equal vertices in the shape
This commit is contained in:
parent
1d3a5a5454
commit
6dbabf8a00
@ -369,13 +369,7 @@ bool NETGENPlugin_Mesher::fillNgMesh(netgen::OCCGeometry& occgeom,
|
|||||||
continue; // meshed face
|
continue; // meshed face
|
||||||
|
|
||||||
// find out orientation of geomEdge within face
|
// find out orientation of geomEdge within face
|
||||||
TopAbs_Orientation fOri;
|
TopAbs_Orientation fOri = helper.GetSubShapeOri( face, geomEdge );
|
||||||
for ( TopExp_Explorer exp( face, TopAbs_EDGE ); exp.More(); exp.Next() ) {
|
|
||||||
if ( geomEdge.IsSame( exp.Current() )) {
|
|
||||||
fOri = exp.Current().Orientation();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get all nodes from geomEdge
|
// get all nodes from geomEdge
|
||||||
bool isForwad = ( fOri == geomEdge.Orientation() );
|
bool isForwad = ( fOri == geomEdge.Orientation() );
|
||||||
@ -591,55 +585,54 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo,
|
|||||||
// create and insert nodes into nodeVec
|
// create and insert nodes into nodeVec
|
||||||
nodeVec.resize( nbNod + 1 );
|
nodeVec.resize( nbNod + 1 );
|
||||||
int i, nbInitNod = initState._nbNodes;
|
int i, nbInitNod = initState._nbNodes;
|
||||||
for (i = nbInitNod+1; i <= nbNod /*&& isOK*/; ++i )
|
for (i = nbInitNod+1; i <= nbNod; ++i )
|
||||||
{
|
{
|
||||||
const netgen::MeshPoint& ngPoint = ngMesh.Point(i);
|
const netgen::MeshPoint& ngPoint = ngMesh.Point(i);
|
||||||
SMDS_MeshNode* node = NULL;
|
SMDS_MeshNode* node = NULL;
|
||||||
bool newNodeOnVertex = false;
|
|
||||||
TopoDS_Vertex aVert;
|
TopoDS_Vertex aVert;
|
||||||
if (i-nbInitNod <= occgeo.vmap.Extent())
|
// First, netgen creates nodes on vertices in occgeo.vmap,
|
||||||
|
// so node index corresponds to vertex index
|
||||||
|
// but (isuue 0020776) netgen does not create nodes with equal coordinates
|
||||||
|
if ( i-nbInitNod <= occgeo.vmap.Extent() )
|
||||||
{
|
{
|
||||||
// point on vertex
|
#ifdef NETGEN_NEW
|
||||||
aVert = TopoDS::Vertex(occgeo.vmap(i-nbInitNod));
|
gp_Pnt p (ngPoint(0), ngPoint(1), ngPoint(2));
|
||||||
SMESHDS_SubMesh * submesh = meshDS->MeshElements(aVert);
|
#else
|
||||||
if (submesh)
|
gp_Pnt p (ngPoint.X(), ngPoint.Y(), ngPoint.Z());
|
||||||
|
#endif
|
||||||
|
for (int iV = i-nbInitNod; aVert.IsNull() && iV <= occgeo.vmap.Extent(); ++iV)
|
||||||
{
|
{
|
||||||
SMDS_NodeIteratorPtr it = submesh->GetNodes();
|
aVert = TopoDS::Vertex( occgeo.vmap( iV ) );
|
||||||
if (it->more())
|
gp_Pnt pV = BRep_Tool::Pnt( aVert );
|
||||||
{
|
if ( p.SquareDistance( pV ) > 1e-20 )
|
||||||
node = const_cast<SMDS_MeshNode*> (it->next());
|
aVert.Nullify();
|
||||||
|
else
|
||||||
|
node = const_cast<SMDS_MeshNode*>( SMESH_Algo::VertexNode( aVert, meshDS ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (node) // node found on vertex
|
||||||
pindMap.Add(i);
|
pindMap.Add(i);
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
if (!node)
|
|
||||||
newNodeOnVertex = true;
|
|
||||||
}
|
|
||||||
if (!node)
|
|
||||||
#ifdef NETGEN_NEW
|
#ifdef NETGEN_NEW
|
||||||
node = meshDS->AddNode(ngPoint(0), ngPoint(1), ngPoint(2));
|
node = meshDS->AddNode(ngPoint(0), ngPoint(1), ngPoint(2));
|
||||||
#else
|
#else
|
||||||
node = meshDS->AddNode(ngPoint.X(), ngPoint.Y(), ngPoint.Z());
|
node = meshDS->AddNode(ngPoint.X(), ngPoint.Y(), ngPoint.Z());
|
||||||
#endif
|
#endif
|
||||||
if (!node)
|
if (!aVert.IsNull())
|
||||||
{
|
|
||||||
MESSAGE("Cannot create a mesh node");
|
|
||||||
if ( !comment.size() ) comment << "Cannot create a mesh node";
|
|
||||||
nbSeg = nbFac = nbVol = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
nodeVec_ACCESS(i) = node;
|
|
||||||
if (newNodeOnVertex)
|
|
||||||
{
|
{
|
||||||
// point on vertex
|
// point on vertex
|
||||||
meshDS->SetNodeOnVertex(node, aVert);
|
meshDS->SetNodeOnVertex(node, aVert);
|
||||||
pindMap.Add(i);
|
pindMap.Add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nodeVec_ACCESS(i) = node;
|
||||||
|
}
|
||||||
|
|
||||||
// create mesh segments along geometric edges
|
// create mesh segments along geometric edges
|
||||||
NCollection_Map<Link> linkMap;
|
NCollection_Map<Link> linkMap;
|
||||||
int nbInitSeg = initState._nbSegments;
|
int nbInitSeg = initState._nbSegments;
|
||||||
for (i = nbInitSeg+1; i <= nbSeg/* && isOK*/; ++i )
|
for (i = nbInitSeg+1; i <= nbSeg; ++i )
|
||||||
{
|
{
|
||||||
const netgen::Segment& seg = ngMesh.LineSegment(i);
|
const netgen::Segment& seg = ngMesh.LineSegment(i);
|
||||||
#ifdef NETGEN_NEW
|
#ifdef NETGEN_NEW
|
||||||
@ -647,9 +640,8 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo,
|
|||||||
#else
|
#else
|
||||||
Link link(seg.p1, seg.p2);
|
Link link(seg.p1, seg.p2);
|
||||||
#endif
|
#endif
|
||||||
if (linkMap.Contains(link))
|
if (!linkMap.Add(link))
|
||||||
continue;
|
continue;
|
||||||
linkMap.Add(link);
|
|
||||||
TopoDS_Edge aEdge;
|
TopoDS_Edge aEdge;
|
||||||
#ifdef NETGEN_NEW
|
#ifdef NETGEN_NEW
|
||||||
int pinds[3] = { seg.pnums[0], seg.pnums[1], seg.pnums[2] };
|
int pinds[3] = { seg.pnums[0], seg.pnums[1], seg.pnums[2] };
|
||||||
@ -875,7 +867,8 @@ bool NETGENPlugin_Mesher::Compute()
|
|||||||
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
|
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
|
||||||
if (err) comment << "Error in netgen::OCCGenerateMesh() at MESHCONST_ANALYSE step";
|
if (err) comment << "Error in netgen::OCCGenerateMesh() at MESHCONST_ANALYSE step";
|
||||||
|
|
||||||
// precompute internal edges (issue 0020676)
|
// precompute internal edges (issue 0020676) in order to
|
||||||
|
// add mesh on them correctly (twice) to netgen mesh
|
||||||
if ( !err && !internalEdge2Face.IsEmpty() )
|
if ( !err && !internalEdge2Face.IsEmpty() )
|
||||||
{
|
{
|
||||||
netgen::OCCGeometry intEdgeOccgeo;
|
netgen::OCCGeometry intEdgeOccgeo;
|
||||||
|
Loading…
Reference in New Issue
Block a user