mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-12 00:29:17 +05:00
23462: [CEA 2142] Import12D fails
Fix node classification on periodic FACEs and wrong propagation on IN node state
This commit is contained in:
parent
4fa5fdbd44
commit
4a591503f8
@ -4287,6 +4287,7 @@ void ElementsOnShape::SetShape (const TopoDS_Shape& theShape,
|
|||||||
|
|
||||||
if ( shapeChanges )
|
if ( shapeChanges )
|
||||||
{
|
{
|
||||||
|
// find most complex shapes
|
||||||
TopTools_IndexedMapOfShape shapesMap;
|
TopTools_IndexedMapOfShape shapesMap;
|
||||||
TopAbs_ShapeEnum shapeTypes[4] = { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX };
|
TopAbs_ShapeEnum shapeTypes[4] = { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX };
|
||||||
TopExp_Explorer sub;
|
TopExp_Explorer sub;
|
||||||
@ -4329,10 +4330,18 @@ void ElementsOnShape::clearClassifiers()
|
|||||||
|
|
||||||
bool ElementsOnShape::IsSatisfy( long elemId )
|
bool ElementsOnShape::IsSatisfy( long elemId )
|
||||||
{
|
{
|
||||||
const SMDS_Mesh* mesh = myMeshModifTracer.GetMesh();
|
if ( myClassifiers.empty() )
|
||||||
const SMDS_MeshElement* elem =
|
return false;
|
||||||
( myType == SMDSAbs_Node ? mesh->FindNode( elemId ) : mesh->FindElement( elemId ));
|
|
||||||
if ( !elem || myClassifiers.empty() )
|
const SMDS_Mesh* mesh = myMeshModifTracer.GetMesh();
|
||||||
|
if ( myType == SMDSAbs_Node )
|
||||||
|
return IsSatisfy( mesh->FindNode( elemId ));
|
||||||
|
return IsSatisfy( mesh->FindElement( elemId ));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ElementsOnShape::IsSatisfy (const SMDS_MeshElement* elem)
|
||||||
|
{
|
||||||
|
if ( !elem )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool isSatisfy = myAllNodesFlag, isNodeOut;
|
bool isSatisfy = myAllNodesFlag, isNodeOut;
|
||||||
@ -4396,6 +4405,60 @@ bool ElementsOnShape::IsSatisfy( long elemId )
|
|||||||
return isSatisfy;
|
return isSatisfy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ElementsOnShape::IsSatisfy (const SMDS_MeshNode* node,
|
||||||
|
TopoDS_Shape* okShape)
|
||||||
|
{
|
||||||
|
if ( !node )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( !myOctree && myClassifiers.size() > 5 )
|
||||||
|
{
|
||||||
|
myWorkClassifiers.resize( myClassifiers.size() );
|
||||||
|
for ( size_t i = 0; i < myClassifiers.size(); ++i )
|
||||||
|
myWorkClassifiers[ i ] = & myClassifiers[ i ];
|
||||||
|
myOctree = new OctreeClassifier( myWorkClassifiers );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isNodeOut = true;
|
||||||
|
|
||||||
|
if ( okShape || !getNodeIsOut( node, isNodeOut ))
|
||||||
|
{
|
||||||
|
SMESH_NodeXYZ aPnt = node;
|
||||||
|
if ( myOctree )
|
||||||
|
{
|
||||||
|
myWorkClassifiers.clear();
|
||||||
|
myOctree->GetClassifiersAtPoint( aPnt, myWorkClassifiers );
|
||||||
|
|
||||||
|
for ( size_t i = 0; i < myWorkClassifiers.size(); ++i )
|
||||||
|
myWorkClassifiers[i]->SetChecked( false );
|
||||||
|
|
||||||
|
for ( size_t i = 0; i < myWorkClassifiers.size(); ++i )
|
||||||
|
if ( !myWorkClassifiers[i]->IsChecked() &&
|
||||||
|
!myWorkClassifiers[i]->IsOut( aPnt ))
|
||||||
|
{
|
||||||
|
isNodeOut = false;
|
||||||
|
if ( okShape )
|
||||||
|
*okShape = myWorkClassifiers[i]->Shape();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( size_t i = 0; i < myClassifiers.size(); ++i )
|
||||||
|
if ( !myClassifiers[i].IsOut( aPnt ))
|
||||||
|
{
|
||||||
|
isNodeOut = false;
|
||||||
|
if ( okShape )
|
||||||
|
*okShape = myWorkClassifiers[i]->Shape();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setNodeIsOut( node, isNodeOut );
|
||||||
|
}
|
||||||
|
|
||||||
|
return !isNodeOut;
|
||||||
|
}
|
||||||
|
|
||||||
void ElementsOnShape::Classifier::Init( const TopoDS_Shape& theShape,
|
void ElementsOnShape::Classifier::Init( const TopoDS_Shape& theShape,
|
||||||
double theTol,
|
double theTol,
|
||||||
const Bnd_B3d* theBox )
|
const Bnd_B3d* theBox )
|
||||||
|
@ -902,6 +902,8 @@ namespace SMESH{
|
|||||||
bool GetAllNodes() const { return myAllNodesFlag; }
|
bool GetAllNodes() const { return myAllNodesFlag; }
|
||||||
void SetShape (const TopoDS_Shape& theShape,
|
void SetShape (const TopoDS_Shape& theShape,
|
||||||
const SMDSAbs_ElementType theType);
|
const SMDSAbs_ElementType theType);
|
||||||
|
bool IsSatisfy (const SMDS_MeshElement* elem);
|
||||||
|
bool IsSatisfy (const SMDS_MeshNode* node, TopoDS_Shape* okShape=0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "SMESHDS_Group.hxx"
|
#include "SMESHDS_Group.hxx"
|
||||||
#include "SMESHDS_Mesh.hxx"
|
#include "SMESHDS_Mesh.hxx"
|
||||||
#include "SMESH_Comment.hxx"
|
#include "SMESH_Comment.hxx"
|
||||||
|
#include "SMESH_ControlsDef.hxx"
|
||||||
#include "SMESH_Gen.hxx"
|
#include "SMESH_Gen.hxx"
|
||||||
#include "SMESH_Group.hxx"
|
#include "SMESH_Group.hxx"
|
||||||
#include "SMESH_Mesh.hxx"
|
#include "SMESH_Mesh.hxx"
|
||||||
@ -187,8 +188,8 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape &
|
|||||||
SMESHDS_Mesh* tgtMesh = theMesh.GetMeshDS();
|
SMESHDS_Mesh* tgtMesh = theMesh.GetMeshDS();
|
||||||
|
|
||||||
const TopoDS_Face& geomFace = TopoDS::Face( theShape );
|
const TopoDS_Face& geomFace = TopoDS::Face( theShape );
|
||||||
const double faceTol = helper.MaxTolerance( geomFace );
|
const double faceTol = helper.MaxTolerance( geomFace );
|
||||||
const int shapeID = tgtMesh->ShapeToIndex( geomFace );
|
const int shapeID = tgtMesh->ShapeToIndex( geomFace );
|
||||||
const bool toCheckOri = (helper.NbAncestors( geomFace, theMesh, TopAbs_SOLID ) == 1 );
|
const bool toCheckOri = (helper.NbAncestors( geomFace, theMesh, TopAbs_SOLID ) == 1 );
|
||||||
|
|
||||||
|
|
||||||
@ -269,12 +270,25 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape &
|
|||||||
map<TLink, int>::iterator link2Nb;
|
map<TLink, int>::iterator link2Nb;
|
||||||
double minGroupTol = Precision::Infinite();
|
double minGroupTol = Precision::Infinite();
|
||||||
|
|
||||||
|
SMESH::Controls::ElementsOnShape onEdgeClassifier;
|
||||||
|
if ( helper.HasSeam() )
|
||||||
|
{
|
||||||
|
TopoDS_Compound edgesCompound;
|
||||||
|
BRep_Builder builder;
|
||||||
|
builder.MakeCompound( edgesCompound );
|
||||||
|
for ( size_t iE = 0; iE < edges.size(); ++iE )
|
||||||
|
builder.Add( edgesCompound, edges[ iE ]);
|
||||||
|
onEdgeClassifier.SetShape( edgesCompound, SMDSAbs_Node );
|
||||||
|
}
|
||||||
|
|
||||||
// =========================
|
// =========================
|
||||||
// Import faces from groups
|
// Import faces from groups
|
||||||
// =========================
|
// =========================
|
||||||
|
|
||||||
StdMeshers_Import_1D::TNodeNodeMap* n2n;
|
StdMeshers_Import_1D::TNodeNodeMap* n2n;
|
||||||
StdMeshers_Import_1D::TElemElemMap* e2e;
|
StdMeshers_Import_1D::TElemElemMap* e2e;
|
||||||
|
StdMeshers_Import_1D::TNodeNodeMap::iterator n2nIt;
|
||||||
|
pair< StdMeshers_Import_1D::TNodeNodeMap::iterator, bool > it_isnew;
|
||||||
vector<TopAbs_State> nodeState;
|
vector<TopAbs_State> nodeState;
|
||||||
vector<const SMDS_MeshNode*> newNodes; // of a face
|
vector<const SMDS_MeshNode*> newNodes; // of a face
|
||||||
set <const SMDS_MeshNode*> bndNodes; // nodes classified ON
|
set <const SMDS_MeshNode*> bndNodes; // nodes classified ON
|
||||||
@ -297,8 +311,8 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape &
|
|||||||
// S.VResolution( 0.1 * groupTol ));
|
// S.VResolution( 0.1 * groupTol ));
|
||||||
const double clsfTol = BRep_Tool::Tolerance( geomFace );
|
const double clsfTol = BRep_Tool::Tolerance( geomFace );
|
||||||
|
|
||||||
StdMeshers_Import_1D::TNodeNodeMap::iterator n2nIt;
|
if ( helper.HasSeam() )
|
||||||
pair< StdMeshers_Import_1D::TNodeNodeMap::iterator, bool > it_isnew;
|
onEdgeClassifier.SetMesh( srcMesh->GetMeshDS() );
|
||||||
|
|
||||||
SMDS_ElemIteratorPtr srcElems = srcGroup->GetElements();
|
SMDS_ElemIteratorPtr srcElems = srcGroup->GetElements();
|
||||||
while ( srcElems->more() ) // loop on group contents
|
while ( srcElems->more() ) // loop on group contents
|
||||||
@ -356,11 +370,21 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape &
|
|||||||
gp_XY uv( Precision::Infinite(), 0 );
|
gp_XY uv( Precision::Infinite(), 0 );
|
||||||
isOut = ( !helper.CheckNodeUV( geomFace, *node, uv, groupTol, /*force=*/true ) ||
|
isOut = ( !helper.CheckNodeUV( geomFace, *node, uv, groupTol, /*force=*/true ) ||
|
||||||
bndBox2d.IsOut( uv ));
|
bndBox2d.IsOut( uv ));
|
||||||
|
//int iCoo;
|
||||||
if ( !isOut && !isIn ) // classify
|
if ( !isOut && !isIn ) // classify
|
||||||
{
|
{
|
||||||
classifier.Perform( geomFace, uv, clsfTol );
|
classifier.Perform( geomFace, uv, clsfTol );
|
||||||
nodeState[i] = classifier.State();
|
nodeState[i] = classifier.State();
|
||||||
isOut = ( nodeState[i] == TopAbs_OUT );
|
isOut = ( nodeState[i] == TopAbs_OUT );
|
||||||
|
if ( isOut && helper.IsOnSeam( uv ) && onEdgeClassifier.IsSatisfy( (*node)->GetID() ))
|
||||||
|
{
|
||||||
|
// uv.SetCoord( iCoo, helper.GetOtherParam( uv.Coord( iCoo )));
|
||||||
|
// classifier.Perform( geomFace, uv, clsfTol );
|
||||||
|
// nodeState[i] = classifier.State();
|
||||||
|
// isOut = ( nodeState[i] == TopAbs_OUT );
|
||||||
|
nodeState[i] = TopAbs_ON;
|
||||||
|
isOut = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( !isOut ) // create a new node
|
if ( !isOut ) // create a new node
|
||||||
{
|
{
|
||||||
@ -374,13 +398,14 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape &
|
|||||||
}
|
}
|
||||||
if ( nodeState[i] == TopAbs_ON )
|
if ( nodeState[i] == TopAbs_ON )
|
||||||
bndNodes.insert( *node );
|
bndNodes.insert( *node );
|
||||||
else
|
else if ( nodeState[i] != TopAbs_UNKNOWN )
|
||||||
isNodeIn[ newNode->GetID() ] = isIn = true;
|
isNodeIn[ newNode->GetID() ] = isIn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !(newNodes[i] = newNode ) || isOut )
|
if ( !(newNodes[i] = newNode ) || isOut )
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
} // loop on face nodes
|
||||||
|
|
||||||
if ( !newNodes.back() )
|
if ( !newNodes.back() )
|
||||||
continue; // not all nodes of the face lie on theShape
|
continue; // not all nodes of the face lie on theShape
|
||||||
@ -491,23 +516,32 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape &
|
|||||||
medium = newNodes[i+nbCorners];
|
medium = newNodes[i+nbCorners];
|
||||||
link2Nb = linkCount.insert( make_pair( TLink( n1, n2, medium ), 0)).first;
|
link2Nb = linkCount.insert( make_pair( TLink( n1, n2, medium ), 0)).first;
|
||||||
++link2Nb->second;
|
++link2Nb->second;
|
||||||
// if ( link2Nb->second == 1 )
|
|
||||||
// {
|
|
||||||
// // measure link length
|
|
||||||
// double len2 = SMESH_TNodeXYZ( n1 ).SquareDistance( n2 );
|
|
||||||
// if ( len2 < minGroupTol )
|
|
||||||
// minGroupTol = len2;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
} // loop on group contents
|
||||||
|
|
||||||
// Remove OUT nodes from n2n map
|
// Remove OUT nodes from n2n map
|
||||||
for ( n2nIt = n2n->begin(); n2nIt != n2n->end(); )
|
for ( n2nIt = n2n->begin(); n2nIt != n2n->end(); )
|
||||||
if ( !n2nIt->second )
|
if ( !n2nIt->second )
|
||||||
n2n->erase( n2nIt++ );
|
n2n->erase( n2nIt++ );
|
||||||
else
|
else
|
||||||
++n2nIt;
|
++n2nIt;
|
||||||
}
|
|
||||||
|
|
||||||
|
} // loop on src groups
|
||||||
|
|
||||||
|
// remove free nodes created on EDGEs
|
||||||
|
{
|
||||||
|
set<const SMDS_MeshNode*>::iterator node = bndNodes.begin();
|
||||||
|
for ( ; node != bndNodes.end(); ++node )
|
||||||
|
{
|
||||||
|
n2nIt = n2n->find( *node );
|
||||||
|
const SMDS_MeshNode* newNode = n2nIt->second;
|
||||||
|
if ( newNode && newNode->NbInverseElements() == 0 )
|
||||||
|
{
|
||||||
|
tgtMesh->RemoveFreeNode( newNode, 0, false );
|
||||||
|
n2n->erase( n2nIt );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ==========================================================
|
// ==========================================================
|
||||||
// Put nodes on geom edges and create edges on them;
|
// Put nodes on geom edges and create edges on them;
|
||||||
|
Loading…
Reference in New Issue
Block a user