0020918: EDF 1447 SMESH: Mesh common borders (note 0010726)
1) in Compute(), fix error that points corresponding to free nodes on vertices are not added to netgen mesh 2) in FillSMesh(), remove unnecessary data - NCollection_Map<int> pindMap; - NCollection_Map<Link> linkMap;
This commit is contained in:
parent
2456aacf6c
commit
c62bdcf082
@ -84,9 +84,9 @@ using namespace nglib;
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#ifdef _DEBUG_
|
#ifdef _DEBUG_
|
||||||
#define nodeVec_ACCESS(index) (SMDS_MeshNode*) nodeVec.at((index))
|
#define nodeVec_ACCESS(index) ((SMDS_MeshNode*) nodeVec.at((index)))
|
||||||
#else
|
#else
|
||||||
#define nodeVec_ACCESS(index) (SMDS_MeshNode*) nodeVec[index]
|
#define nodeVec_ACCESS(index) ((SMDS_MeshNode*) nodeVec[index])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NETGEN_NEW
|
#ifdef NETGEN_NEW
|
||||||
@ -1294,8 +1294,6 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo,
|
|||||||
|
|
||||||
SMESHDS_Mesh* meshDS = sMesh.GetMeshDS();
|
SMESHDS_Mesh* meshDS = sMesh.GetMeshDS();
|
||||||
|
|
||||||
// map of nodes assigned to submeshes
|
|
||||||
NCollection_Map<int> pindMap;
|
|
||||||
// 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;
|
||||||
@ -1320,30 +1318,20 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo,
|
|||||||
node = const_cast<SMDS_MeshNode*>( SMESH_Algo::VertexNode( aVert, meshDS ));
|
node = const_cast<SMDS_MeshNode*>( SMESH_Algo::VertexNode( aVert, meshDS ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node) // node found on vertex
|
if (!node) // node not found on vertex
|
||||||
pindMap.Add(i);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
node = meshDS->AddNode( NGPOINT_COORDS( ngPoint ));
|
node = meshDS->AddNode( NGPOINT_COORDS( ngPoint ));
|
||||||
if (!aVert.IsNull())
|
if (!aVert.IsNull())
|
||||||
{
|
|
||||||
// point on vertex
|
|
||||||
meshDS->SetNodeOnVertex(node, aVert);
|
meshDS->SetNodeOnVertex(node, aVert);
|
||||||
pindMap.Add(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
nodeVec[i] = node;
|
nodeVec[i] = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create mesh segments along geometric edges
|
// create mesh segments along geometric edges
|
||||||
NCollection_Map<Link> linkMap;
|
|
||||||
int nbInitSeg = initState._nbSegments;
|
int nbInitSeg = initState._nbSegments;
|
||||||
for (i = nbInitSeg+1; i <= nbSeg; ++i )
|
for (i = nbInitSeg+1; i <= nbSeg; ++i )
|
||||||
{
|
{
|
||||||
const netgen::Segment& seg = ngMesh.LineSegment(i);
|
const netgen::Segment& seg = ngMesh.LineSegment(i);
|
||||||
Link link(seg[0], seg[1]);
|
|
||||||
if (!linkMap.Add(link))
|
|
||||||
continue;
|
|
||||||
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] };
|
||||||
@ -1355,7 +1343,8 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo,
|
|||||||
for (int j=0; j < 3; ++j)
|
for (int j=0; j < 3; ++j)
|
||||||
{
|
{
|
||||||
int pind = pinds[j];
|
int pind = pinds[j];
|
||||||
if (pind <= 0) continue;
|
if (pind <= 0 || !nodeVec_ACCESS(pind))
|
||||||
|
break;
|
||||||
++nbp;
|
++nbp;
|
||||||
double param;
|
double param;
|
||||||
if (j < 2)
|
if (j < 2)
|
||||||
@ -1369,31 +1358,46 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo,
|
|||||||
param = seg.epgeominfo[j].dist;
|
param = seg.epgeominfo[j].dist;
|
||||||
param2 += param;
|
param2 += param;
|
||||||
}
|
}
|
||||||
else
|
else // middle point
|
||||||
|
{
|
||||||
param = param2 * 0.5;
|
param = param2 * 0.5;
|
||||||
if (pind <= nbInitNod || pindMap.Contains(pind))
|
}
|
||||||
continue;
|
if (!aEdge.IsNull() && nodeVec_ACCESS(pind)->getshapeId() < 1)
|
||||||
if (!aEdge.IsNull())
|
|
||||||
{
|
{
|
||||||
meshDS->SetNodeOnEdge(nodeVec_ACCESS(pind), aEdge, param);
|
meshDS->SetNodeOnEdge(nodeVec_ACCESS(pind), aEdge, param);
|
||||||
pindMap.Add(pind);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SMDS_MeshEdge* edge;
|
if ( nbp > 1 )
|
||||||
if (nbp < 3) // second order ?
|
|
||||||
edge = meshDS->AddEdge(nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1]));
|
|
||||||
else
|
|
||||||
edge = meshDS->AddEdge(nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1]),
|
|
||||||
nodeVec_ACCESS(pinds[2]));
|
|
||||||
if (!edge)
|
|
||||||
{
|
{
|
||||||
if ( !comment.size() ) comment << "Cannot create a mesh edge";
|
SMDS_MeshEdge* edge = 0;
|
||||||
MESSAGE("Cannot create a mesh edge");
|
if (nbp == 2) // second order ?
|
||||||
nbSeg = nbFac = nbVol = 0;
|
{
|
||||||
break;
|
if ( meshDS->FindEdge( nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1])))
|
||||||
|
continue;
|
||||||
|
edge = meshDS->AddEdge(nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( meshDS->FindEdge( nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1]),
|
||||||
|
nodeVec_ACCESS(pinds[2])))
|
||||||
|
continue;
|
||||||
|
edge = meshDS->AddEdge(nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1]),
|
||||||
|
nodeVec_ACCESS(pinds[2]));
|
||||||
|
}
|
||||||
|
if (!edge)
|
||||||
|
{
|
||||||
|
if ( comment.empty() ) comment << "Cannot create a mesh edge";
|
||||||
|
MESSAGE("Cannot create a mesh edge");
|
||||||
|
nbSeg = nbFac = nbVol = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( !aEdge.IsNull() && edge->getshapeId() < 1 )
|
||||||
|
meshDS->SetMeshElementOnShape(edge, aEdge);
|
||||||
|
}
|
||||||
|
else if ( comment.empty() )
|
||||||
|
{
|
||||||
|
comment << "Invalid netgen segment #" << i;
|
||||||
}
|
}
|
||||||
if (!aEdge.IsNull())
|
|
||||||
meshDS->SetMeshElementOnShape(edge, aEdge);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create mesh faces along geometric faces
|
// create mesh faces along geometric faces
|
||||||
@ -1409,17 +1413,24 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo,
|
|||||||
for (int j=1; j <= elem.GetNP(); ++j)
|
for (int j=1; j <= elem.GetNP(); ++j)
|
||||||
{
|
{
|
||||||
int pind = elem.PNum(j);
|
int pind = elem.PNum(j);
|
||||||
SMDS_MeshNode* node = nodeVec_ACCESS(pind);
|
if ( pind < 1 || pind >= nodeVec.size() )
|
||||||
nodes.push_back(node);
|
break;
|
||||||
if (pind <= nbInitNod || pindMap.Contains(pind))
|
if ( SMDS_MeshNode* node = nodeVec_ACCESS(pind))
|
||||||
continue;
|
|
||||||
if (!aFace.IsNull())
|
|
||||||
{
|
{
|
||||||
const netgen::PointGeomInfo& pgi = elem.GeomInfoPi(j);
|
nodes.push_back(node);
|
||||||
meshDS->SetNodeOnFace(node, aFace, pgi.u, pgi.v);
|
if (!aFace.IsNull() && node->getshapeId() < 1)
|
||||||
pindMap.Add(pind);
|
{
|
||||||
|
const netgen::PointGeomInfo& pgi = elem.GeomInfoPi(j);
|
||||||
|
meshDS->SetNodeOnFace(node, aFace, pgi.u, pgi.v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( nodes.size() != elem.GetNP() )
|
||||||
|
{
|
||||||
|
if ( comment.empty() )
|
||||||
|
comment << "Invalid netgen 2d element #" << i;
|
||||||
|
continue; // bad node ids
|
||||||
|
}
|
||||||
SMDS_MeshFace* face = NULL;
|
SMDS_MeshFace* face = NULL;
|
||||||
switch (elem.GetType())
|
switch (elem.GetType())
|
||||||
{
|
{
|
||||||
@ -1442,7 +1453,7 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo,
|
|||||||
}
|
}
|
||||||
if (!face)
|
if (!face)
|
||||||
{
|
{
|
||||||
if ( !comment.size() ) comment << "Cannot create a mesh face";
|
if ( comment.empty() ) comment << "Cannot create a mesh face";
|
||||||
MESSAGE("Cannot create a mesh face");
|
MESSAGE("Cannot create a mesh face");
|
||||||
nbSeg = nbFac = nbVol = 0;
|
nbSeg = nbFac = nbVol = 0;
|
||||||
break;
|
break;
|
||||||
@ -1452,7 +1463,7 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create tetrahedra
|
// create tetrahedra
|
||||||
for (i = 1; i <= nbVol/* && isOK*/; ++i)
|
for (i = 1; i <= nbVol; ++i)
|
||||||
{
|
{
|
||||||
const netgen::Element& elem = ngMesh.VolumeElement(i);
|
const netgen::Element& elem = ngMesh.VolumeElement(i);
|
||||||
int aSolidInd = elem.GetIndex();
|
int aSolidInd = elem.GetIndex();
|
||||||
@ -1463,17 +1474,21 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo,
|
|||||||
for (int j=1; j <= elem.GetNP(); ++j)
|
for (int j=1; j <= elem.GetNP(); ++j)
|
||||||
{
|
{
|
||||||
int pind = elem.PNum(j);
|
int pind = elem.PNum(j);
|
||||||
SMDS_MeshNode* node = nodeVec_ACCESS(pind);
|
if ( pind < 1 || pind >= nodeVec.size() )
|
||||||
nodes.push_back(node);
|
break;
|
||||||
if (pind <= nbInitNod || pindMap.Contains(pind))
|
if ( SMDS_MeshNode* node = nodeVec_ACCESS(pind) )
|
||||||
continue;
|
|
||||||
if (!aSolid.IsNull())
|
|
||||||
{
|
{
|
||||||
// point in solid
|
nodes.push_back(node);
|
||||||
meshDS->SetNodeInVolume(node, aSolid);
|
if ( !aSolid.IsNull() && node->getshapeId() < 1 )
|
||||||
pindMap.Add(pind);
|
meshDS->SetNodeInVolume(node, aSolid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( nodes.size() != elem.GetNP() )
|
||||||
|
{
|
||||||
|
if ( comment.empty() )
|
||||||
|
comment << "Invalid netgen 3d element #" << i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
SMDS_MeshVolume* vol = NULL;
|
SMDS_MeshVolume* vol = NULL;
|
||||||
switch (elem.GetType())
|
switch (elem.GetType())
|
||||||
{
|
{
|
||||||
@ -1490,7 +1505,7 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo,
|
|||||||
}
|
}
|
||||||
if (!vol)
|
if (!vol)
|
||||||
{
|
{
|
||||||
if ( !comment.size() ) comment << "Cannot create a mesh volume";
|
if ( comment.empty() ) comment << "Cannot create a mesh volume";
|
||||||
MESSAGE("Cannot create a mesh volume");
|
MESSAGE("Cannot create a mesh volume");
|
||||||
nbSeg = nbFac = nbVol = 0;
|
nbSeg = nbFac = nbVol = 0;
|
||||||
break;
|
break;
|
||||||
@ -1756,7 +1771,8 @@ bool NETGENPlugin_Mesher::Compute()
|
|||||||
if ( !err )
|
if ( !err )
|
||||||
{
|
{
|
||||||
_faceDescriptors.clear();
|
_faceDescriptors.clear();
|
||||||
err = ! ( fillNgMesh(occgeo, *ngMesh, nodeVec, meshedSM[ MeshDim_1D ]));
|
err = ! ( fillNgMesh(occgeo, *ngMesh, nodeVec, meshedSM[ MeshDim_0D ]) &&
|
||||||
|
fillNgMesh(occgeo, *ngMesh, nodeVec, meshedSM[ MeshDim_1D ]));
|
||||||
}
|
}
|
||||||
initState = NETGENPlugin_ngMeshInfo(ngMesh);
|
initState = NETGENPlugin_ngMeshInfo(ngMesh);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user