mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-18 09:50:36 +05:00
0021338: EDF 1926 SMESH: New controls and filters
+ class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate { + class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
This commit is contained in:
parent
a26c2ead1f
commit
3ce7e67ad8
@ -65,6 +65,8 @@
|
||||
#include "SMESHDS_Mesh.hxx"
|
||||
#include "SMESHDS_GroupBase.hxx"
|
||||
|
||||
#include "SMESH_OctreeNode.hxx"
|
||||
|
||||
#include <vtkMeshQuality.h>
|
||||
|
||||
/*
|
||||
@ -2089,6 +2091,128 @@ bool OverConstrainedFace::IsSatisfy(long theElementId )
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Class : CoincidentNodes
|
||||
Description : Predicate of Coincident nodes
|
||||
*/
|
||||
|
||||
CoincidentNodes::CoincidentNodes()
|
||||
{
|
||||
myToler = 1e-5;
|
||||
}
|
||||
|
||||
bool CoincidentNodes::IsSatisfy( long theElementId )
|
||||
{
|
||||
return myCoincidentIDs.Contains( theElementId );
|
||||
}
|
||||
|
||||
SMDSAbs_ElementType CoincidentNodes::GetType() const
|
||||
{
|
||||
return SMDSAbs_Node;
|
||||
}
|
||||
|
||||
void CoincidentNodes::SetMesh( const SMDS_Mesh* theMesh, TIDSortedNodeSet* nodesToCheck )
|
||||
{
|
||||
TIDSortedNodeSet allNodes;
|
||||
if ( !nodesToCheck )
|
||||
{
|
||||
nodesToCheck = &allNodes;
|
||||
SMDS_NodeIteratorPtr nIt = theMesh->nodesIterator(/*idInceasingOrder=*/true);
|
||||
while ( nIt->more() )
|
||||
allNodes.insert( allNodes.end(), nIt->next() );
|
||||
}
|
||||
|
||||
list< list< const SMDS_MeshNode*> > nodeGroups;
|
||||
SMESH_OctreeNode::FindCoincidentNodes ( *nodesToCheck, &nodeGroups, myToler );
|
||||
|
||||
myCoincidentIDs.Clear();
|
||||
list< list< const SMDS_MeshNode*> >::iterator groupIt = nodeGroups.begin();
|
||||
for ( ; groupIt != nodeGroups.end(); ++groupIt )
|
||||
{
|
||||
list< const SMDS_MeshNode*>& coincNodes = *groupIt;
|
||||
list< const SMDS_MeshNode*>::iterator n = coincNodes.begin();
|
||||
for ( ; n != coincNodes.end(); ++n )
|
||||
myCoincidentIDs.Add( (*n)->GetID() );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class : CoincidentElements
|
||||
Description : Predicate of Coincident Elements
|
||||
Note : This class is suitable only for visualization of Coincident Elements
|
||||
*/
|
||||
|
||||
CoincidentElements::CoincidentElements()
|
||||
{
|
||||
myMesh = 0;
|
||||
myElemsToCheck = 0;
|
||||
}
|
||||
|
||||
void CoincidentElements::SetMesh( const SMDS_Mesh* theMesh, TIDSortedElemSet* elemsToCheck )
|
||||
{
|
||||
myMesh = theMesh;
|
||||
|
||||
myCoincidentIDs.Clear();
|
||||
myElemsToCheck = elemsToCheck;
|
||||
|
||||
if ( myElemsToCheck )
|
||||
{
|
||||
TColStd_MapOfInteger coincidentIDs;
|
||||
TIDSortedElemSet::iterator elem = myElemsToCheck->begin();
|
||||
for ( ; elem != myElemsToCheck->end(); ++elem )
|
||||
if ( IsSatisfy( (*elem)->GetID() ))
|
||||
coincidentIDs.Add( (*elem)->GetID() );
|
||||
|
||||
myCoincidentIDs = coincidentIDs;
|
||||
if ( myCoincidentIDs.IsEmpty() )
|
||||
myCoincidentIDs.Add( -1 ); // mark that analysis is already performed
|
||||
|
||||
myElemsToCheck = 0; // not needed anymore
|
||||
}
|
||||
}
|
||||
|
||||
bool CoincidentElements::IsSatisfy( long theElementId )
|
||||
{
|
||||
if ( !myCoincidentIDs.IsEmpty() )
|
||||
return myCoincidentIDs.Contains( theElementId );
|
||||
|
||||
if ( !myMesh ) return false;
|
||||
|
||||
if ( const SMDS_MeshElement* e = myMesh->FindElement( theElementId ))
|
||||
{
|
||||
if ( e->GetType() != GetType() ) return false;
|
||||
set< const SMDS_MeshNode* > elemNodes( e->begin_nodes(), e->end_nodes() );
|
||||
SMDS_ElemIteratorPtr invIt = (*elemNodes.begin())->GetInverseElementIterator( GetType() );
|
||||
while ( invIt->more() )
|
||||
{
|
||||
const SMDS_MeshElement* e2 = invIt->next();
|
||||
if ( e2 == e || e2->NbNodes() != (int)elemNodes.size() ) continue;
|
||||
if ( myElemsToCheck && !myElemsToCheck->count( e2 )) continue;
|
||||
|
||||
bool sameNodes = true;
|
||||
for ( size_t i = 0; i < elemNodes.size() && sameNodes; ++i )
|
||||
sameNodes = ( elemNodes.count( e2->GetNode( i )));
|
||||
if ( sameNodes )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SMDSAbs_ElementType CoincidentElements1D::GetType() const
|
||||
{
|
||||
return SMDSAbs_Edge;
|
||||
}
|
||||
SMDSAbs_ElementType CoincidentElements2D::GetType() const
|
||||
{
|
||||
return SMDSAbs_Face;
|
||||
}
|
||||
SMDSAbs_ElementType CoincidentElements3D::GetType() const
|
||||
{
|
||||
return SMDSAbs_Volume;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Class : FreeBorders
|
||||
Description : Predicate for free borders
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "SMDSAbs_ElementType.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMESH_TypeDefs.hxx"
|
||||
|
||||
#include "SMESH_Controls.hxx"
|
||||
|
||||
@ -116,10 +117,8 @@ namespace SMESH{
|
||||
void SetPrecision( const long thePrecision );
|
||||
double Round( const double & value );
|
||||
|
||||
bool GetPoints(const int theId,
|
||||
TSequenceOfXYZ& theRes) const;
|
||||
static bool GetPoints(const SMDS_MeshElement* theElem,
|
||||
TSequenceOfXYZ& theRes);
|
||||
bool GetPoints(const int theId, TSequenceOfXYZ& theRes) const;
|
||||
static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes);
|
||||
protected:
|
||||
const SMDS_Mesh* myMesh;
|
||||
const SMDS_MeshElement* myCurrElement;
|
||||
@ -319,6 +318,55 @@ namespace SMESH{
|
||||
/*
|
||||
PREDICATES
|
||||
*/
|
||||
/*
|
||||
Class : CoincidentNodes
|
||||
Description : Predicate of Coincident Nodes
|
||||
Note : This class is suitable only for visualization of Coincident Nodes
|
||||
*/
|
||||
class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
|
||||
public:
|
||||
CoincidentNodes();
|
||||
void SetTolerance (const double theToler) { myToler = theToler; }
|
||||
void SetMesh( const SMDS_Mesh* theMesh, TIDSortedNodeSet* nodesToCheck );
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh ) { SetMesh( theMesh, 0 ); }
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
|
||||
private:
|
||||
TColStd_MapOfInteger myCoincidentIDs;
|
||||
double myToler;
|
||||
};
|
||||
|
||||
/*
|
||||
Class : CoincidentElements
|
||||
Description : Predicate of Coincident Elements
|
||||
Note : This class is suitable only for visualization of Coincident Elements
|
||||
*/
|
||||
class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate {
|
||||
public:
|
||||
CoincidentElements();
|
||||
void SetMesh( const SMDS_Mesh* theMesh, TIDSortedElemSet* elemsToCheck );
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh ) { SetMesh( theMesh, 0 ); }
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
|
||||
private:
|
||||
const SMDS_Mesh* myMesh;
|
||||
TIDSortedElemSet* myElemsToCheck;
|
||||
TColStd_MapOfInteger myCoincidentIDs;
|
||||
};
|
||||
class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
|
||||
public:
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
};
|
||||
class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
|
||||
public:
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
};
|
||||
class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
|
||||
public:
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
};
|
||||
|
||||
/*
|
||||
Class : FreeBorders
|
||||
Description : Predicate for free borders
|
||||
|
Loading…
Reference in New Issue
Block a user