mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-25 08:50:35 +05:00
#17828 [CEA 17805] Polyhedron Mesh volume calculation and volume orientation criterion
1) Fix BadOrientedVolume criterion to detect invalid polyhedrons 2) Fix SMESH_MeshEditor::Reorient() to correct orientation of polyhedron facets
This commit is contained in:
parent
e67f8c2cab
commit
2cc662ea28
@ -2286,7 +2286,19 @@ bool BadOrientedVolume::IsSatisfy( long theId )
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
SMDS_VolumeTool vTool( myMesh->FindElement( theId ));
|
SMDS_VolumeTool vTool( myMesh->FindElement( theId ));
|
||||||
return !vTool.IsForward();
|
|
||||||
|
bool isOk = true;
|
||||||
|
if ( vTool.IsPoly() )
|
||||||
|
{
|
||||||
|
isOk = true;
|
||||||
|
for ( int i = 0; i < vTool.NbFaces() && isOk; ++i )
|
||||||
|
isOk = vTool.IsFaceExternal( i );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isOk = vTool.IsForward();
|
||||||
|
}
|
||||||
|
return !isOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMDSAbs_ElementType BadOrientedVolume::GetType() const
|
SMDSAbs_ElementType BadOrientedVolume::GetType() const
|
||||||
|
@ -1093,19 +1093,37 @@ bool SMESH_MeshEditor::Reorient (const SMDS_MeshElement * theElem)
|
|||||||
MESSAGE("Warning: bad volumic element");
|
MESSAGE("Warning: bad volumic element");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const int nbFaces = aPolyedre->NbFaces();
|
SMDS_VolumeTool vTool( aPolyedre );
|
||||||
|
const int nbFaces = vTool.NbFaces();
|
||||||
|
vector<int> quantities( nbFaces );
|
||||||
vector<const SMDS_MeshNode *> poly_nodes;
|
vector<const SMDS_MeshNode *> poly_nodes;
|
||||||
vector<int> quantities (nbFaces);
|
|
||||||
|
|
||||||
// reverse each face of the polyedre
|
// check if all facets are oriented equally
|
||||||
for (int iface = 1; iface <= nbFaces; iface++) {
|
bool sameOri = true;
|
||||||
int inode, nbFaceNodes = aPolyedre->NbFaceNodes(iface);
|
vector<int>& facetOri = quantities; // keep orientation in quantities so far
|
||||||
quantities[iface - 1] = nbFaceNodes;
|
for (int iface = 0; iface < nbFaces; iface++)
|
||||||
|
{
|
||||||
for (inode = nbFaceNodes; inode >= 1; inode--) {
|
facetOri[ iface ] = vTool.IsFaceExternal( iface );
|
||||||
const SMDS_MeshNode* curNode = aPolyedre->GetFaceNode(iface, inode);
|
if ( facetOri[ iface ] != facetOri[ 0 ])
|
||||||
poly_nodes.push_back(curNode);
|
sameOri = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reverse faces of the polyhedron
|
||||||
|
int neededOri = sameOri ? 1 - facetOri[0] : 1;
|
||||||
|
poly_nodes.reserve( vTool.NbNodes() );
|
||||||
|
for ( int iface = 0; iface < nbFaces; iface++ )
|
||||||
|
{
|
||||||
|
int nbFaceNodes = vTool.NbFaceNodes( iface );
|
||||||
|
const SMDS_MeshNode** nodes = vTool.GetFaceNodes( iface );
|
||||||
|
bool toReverse = ( facetOri[ iface ] != neededOri );
|
||||||
|
|
||||||
|
quantities[ iface ] = nbFaceNodes;
|
||||||
|
|
||||||
|
if ( toReverse )
|
||||||
|
for ( int inode = nbFaceNodes - 1; inode >= 0; inode-- )
|
||||||
|
poly_nodes.push_back( nodes[ inode ]);
|
||||||
|
else
|
||||||
|
poly_nodes.insert( poly_nodes.end(), nodes, nodes + nbFaceNodes );
|
||||||
}
|
}
|
||||||
return GetMeshDS()->ChangePolyhedronNodes( theElem, poly_nodes, quantities );
|
return GetMeshDS()->ChangePolyhedronNodes( theElem, poly_nodes, quantities );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user