0021543: EDF 1978 SMESH: Viscous layer for 2D meshes

-void FindEqualElements(set<const SMDS_MeshElement*> & theElements,
+void FindEqualElements(TIDSortedElemSet &        theElements,
                        TListOfListOfElementsID & theGroupsOfElementsID)
This commit is contained in:
eap 2012-10-15 13:01:00 +00:00
parent 51782d7575
commit 4605267548
2 changed files with 45 additions and 49 deletions

View File

@ -6103,7 +6103,7 @@ struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher
} }
else if ( tree->NbNodes() ) // put a tree to the treeMap else if ( tree->NbNodes() ) // put a tree to the treeMap
{ {
const Bnd_B3d& box = tree->getBox(); const Bnd_B3d& box = *tree->getBox();
double sqDist = thePnt.SquareDistance( 0.5 * ( box.CornerMin() + box.CornerMax() )); double sqDist = thePnt.SquareDistance( 0.5 * ( box.CornerMin() + box.CornerMax() ));
pair<TDistTreeMap::iterator,bool> it_in = treeMap.insert( make_pair( sqDist, tree )); pair<TDistTreeMap::iterator,bool> it_in = treeMap.insert( make_pair( sqDist, tree ));
if ( !it_in.second ) // not unique distance to box center if ( !it_in.second ) // not unique distance to box center
@ -6115,7 +6115,7 @@ struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher
TDistTreeMap::iterator sqDist_tree = treeMap.begin(); TDistTreeMap::iterator sqDist_tree = treeMap.begin();
if ( treeMap.size() > 5 ) { if ( treeMap.size() > 5 ) {
SMESH_OctreeNode* closestTree = sqDist_tree->second; SMESH_OctreeNode* closestTree = sqDist_tree->second;
const Bnd_B3d& box = closestTree->getBox(); const Bnd_B3d& box = *closestTree->getBox();
double limit = sqrt( sqDist_tree->first ) + sqrt ( box.SquareExtent() ); double limit = sqrt( sqDist_tree->first ) + sqrt ( box.SquareExtent() );
sqLimit = limit * limit; sqLimit = limit * limit;
} }
@ -6200,7 +6200,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
protected: protected:
ElementBndBoxTree():_size(0) {} ElementBndBoxTree():_size(0) {}
SMESH_Octree* allocateOctreeChild() const { return new ElementBndBoxTree; } SMESH_Octree* newChild() const { return new ElementBndBoxTree; }
void buildChildrenData(); void buildChildrenData();
Bnd_B3d* buildRootBox(); Bnd_B3d* buildRootBox();
private: private:
@ -6222,7 +6222,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
//================================================================================ //================================================================================
ElementBndBoxTree::ElementBndBoxTree(const SMDS_Mesh& mesh, SMDSAbs_ElementType elemType, SMDS_ElemIteratorPtr theElemIt, double tolerance) ElementBndBoxTree::ElementBndBoxTree(const SMDS_Mesh& mesh, SMDSAbs_ElementType elemType, SMDS_ElemIteratorPtr theElemIt, double tolerance)
:SMESH_Octree( new SMESH_Octree::Limit( MaxLevel, /*minSize=*/0. )) :SMESH_Octree( new SMESH_TreeLimit( MaxLevel, /*minSize=*/0. ))
{ {
int nbElems = mesh.GetMeshInfo().NbElements( elemType ); int nbElems = mesh.GetMeshInfo().NbElements( elemType );
_elements.reserve( nbElems ); _elements.reserve( nbElems );
@ -6273,7 +6273,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
{ {
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
{ {
if ( !_elements[i]->IsOut( myChildren[j]->getBox() )) if ( !_elements[i]->IsOut( *myChildren[j]->getBox() ))
{ {
_elements[i]->_refCount++; _elements[i]->_refCount++;
((ElementBndBoxTree*)myChildren[j])->_elements.push_back( _elements[i]); ((ElementBndBoxTree*)myChildren[j])->_elements.push_back( _elements[i]);
@ -6304,7 +6304,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
void ElementBndBoxTree::getElementsNearPoint( const gp_Pnt& point, void ElementBndBoxTree::getElementsNearPoint( const gp_Pnt& point,
TIDSortedElemSet& foundElems) TIDSortedElemSet& foundElems)
{ {
if ( getBox().IsOut( point.XYZ() )) if ( getBox()->IsOut( point.XYZ() ))
return; return;
if ( isLeaf() ) if ( isLeaf() )
@ -6329,7 +6329,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
void ElementBndBoxTree::getElementsNearLine( const gp_Ax1& line, void ElementBndBoxTree::getElementsNearLine( const gp_Ax1& line,
TIDSortedElemSet& foundElems) TIDSortedElemSet& foundElems)
{ {
if ( getBox().IsOut( line )) if ( getBox()->IsOut( line ))
return; return;
if ( isLeaf() ) if ( isLeaf() )
@ -6355,7 +6355,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
const double radius, const double radius,
TIDSortedElemSet& foundElems) TIDSortedElemSet& foundElems)
{ {
if ( getBox().IsOut( center, radius )) if ( getBox()->IsOut( center, radius ))
return; return;
if ( isLeaf() ) if ( isLeaf() )
@ -6737,10 +6737,10 @@ SMESH_ElementSearcherImpl::FindClosestTo( const gp_Pnt& point,
if ( suspectElems.empty() && _ebbTree->maxSize() > 0 ) if ( suspectElems.empty() && _ebbTree->maxSize() > 0 )
{ {
gp_Pnt boxCenter = 0.5 * ( _ebbTree->getBox().CornerMin() + gp_Pnt boxCenter = 0.5 * ( _ebbTree->getBox()->CornerMin() +
_ebbTree->getBox().CornerMax() ); _ebbTree->getBox()->CornerMax() );
double radius; double radius;
if ( _ebbTree->getBox().IsOut( point.XYZ() )) if ( _ebbTree->getBox()->IsOut( point.XYZ() ))
radius = point.Distance( boxCenter ) - 0.5 * _ebbTree->maxSize(); radius = point.Distance( boxCenter ) - 0.5 * _ebbTree->maxSize();
else else
radius = _ebbTree->maxSize() / pow( 2., _ebbTree->getHeight()) / 2; radius = _ebbTree->maxSize() / pow( 2., _ebbTree->getHeight()) / 2;
@ -8156,32 +8156,28 @@ private:
//purpose : Return list of group of elements built on the same nodes. //purpose : Return list of group of elements built on the same nodes.
// Search among theElements or in the whole mesh if theElements is empty // Search among theElements or in the whole mesh if theElements is empty
//======================================================================= //=======================================================================
void SMESH_MeshEditor::FindEqualElements(set<const SMDS_MeshElement*> & theElements, void SMESH_MeshEditor::FindEqualElements(TIDSortedElemSet & theElements,
TListOfListOfElementsID & theGroupsOfElementsID) TListOfListOfElementsID & theGroupsOfElementsID)
{ {
myLastCreatedElems.Clear(); myLastCreatedElems.Clear();
myLastCreatedNodes.Clear(); myLastCreatedNodes.Clear();
typedef set<const SMDS_MeshElement*> TElemsSet;
typedef map< SortableElement, int > TMapOfNodeSet; typedef map< SortableElement, int > TMapOfNodeSet;
typedef list<int> TGroupOfElems; typedef list<int> TGroupOfElems;
TElemsSet elems;
if ( theElements.empty() ) if ( theElements.empty() )
{ // get all elements in the mesh { // get all elements in the mesh
SMDS_ElemIteratorPtr eIt = GetMeshDS()->elementsIterator(); SMDS_ElemIteratorPtr eIt = GetMeshDS()->elementsIterator();
while ( eIt->more() ) while ( eIt->more() )
elems.insert( elems.end(), eIt->next()); theElements.insert( theElements.end(), eIt->next());
} }
else
elems = theElements;
vector< TGroupOfElems > arrayOfGroups; vector< TGroupOfElems > arrayOfGroups;
TGroupOfElems groupOfElems; TGroupOfElems groupOfElems;
TMapOfNodeSet mapOfNodeSet; TMapOfNodeSet mapOfNodeSet;
TElemsSet::iterator elemIt = elems.begin(); TIDSortedElemSet::iterator elemIt = theElements.begin();
for ( int i = 0, j=0; elemIt != elems.end(); ++elemIt, ++j ) { for ( int i = 0, j=0; elemIt != theElements.end(); ++elemIt, ++j ) {
const SMDS_MeshElement* curElem = *elemIt; const SMDS_MeshElement* curElem = *elemIt;
SortableElement SE(curElem); SortableElement SE(curElem);
int ind = -1; int ind = -1;
@ -8254,7 +8250,7 @@ void SMESH_MeshEditor::MergeElements(TListOfListOfElementsID & theGroupsOfElemen
void SMESH_MeshEditor::MergeEqualElements() void SMESH_MeshEditor::MergeEqualElements()
{ {
set<const SMDS_MeshElement*> aMeshElements; /* empty input - TIDSortedElemSet aMeshElements; /* empty input ==
to merge equal elements in the whole mesh */ to merge equal elements in the whole mesh */
TListOfListOfElementsID aGroupsOfElementsID; TListOfListOfElementsID aGroupsOfElementsID;
FindEqualElements(aMeshElements, aGroupsOfElementsID); FindEqualElements(aMeshElements, aGroupsOfElementsID);

View File

@ -350,15 +350,6 @@ public:
SMESH_Mesh* theTargetMesh=0); SMESH_Mesh* theTargetMesh=0);
// Move or copy theElements applying theTrsf to their nodes // Move or copy theElements applying theTrsf to their nodes
typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
void FindCoincidentNodes (TIDSortedNodeSet & theNodes,
const double theTolerance,
TListOfListOfNodes & theGroupsOfNodes);
// Return list of group of nodes close to each other within theTolerance.
// Search among theNodes or in the whole mesh if theNodes is empty.
/*! /*!
* \brief Return SMESH_NodeSearcher. The caller is responsible for deleteing it * \brief Return SMESH_NodeSearcher. The caller is responsible for deleteing it
*/ */
@ -369,6 +360,33 @@ public:
*/ */
SMESH_ElementSearcher* GetElementSearcher(); SMESH_ElementSearcher* GetElementSearcher();
SMESH_ElementSearcher* GetElementSearcher( SMDS_ElemIteratorPtr elemIt ); SMESH_ElementSearcher* GetElementSearcher( SMDS_ElemIteratorPtr elemIt );
typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
void FindCoincidentNodes (TIDSortedNodeSet & theNodes,
const double theTolerance,
TListOfListOfNodes & theGroupsOfNodes);
// Return list of group of nodes close to each other within theTolerance.
// Search among theNodes or in the whole mesh if theNodes is empty.
void MergeNodes (TListOfListOfNodes & theNodeGroups);
// In each group, the cdr of nodes are substituted by the first one
// in all elements.
typedef std::list< std::list< int > > TListOfListOfElementsID;
void FindEqualElements(TIDSortedElemSet & theElements,
TListOfListOfElementsID & theGroupsOfElementsID);
// Return list of group of elements build on the same nodes.
// Search among theElements or in the whole mesh if theElements is empty.
void MergeElements(TListOfListOfElementsID & theGroupsOfElementsID);
// In each group remove all but first of elements.
void MergeEqualElements();
// Remove all but one of elements built on the same nodes.
// Return nb of successfully merged groups.
/*! /*!
* \brief Return true if the point is IN or ON of the element * \brief Return true if the point is IN or ON of the element
*/ */
@ -382,24 +400,6 @@ public:
// Split face, defined by <faceNodes>, into several faces by repeating nodes. // Split face, defined by <faceNodes>, into several faces by repeating nodes.
// Is used by MergeNodes() // Is used by MergeNodes()
void MergeNodes (TListOfListOfNodes & theNodeGroups);
// In each group, the cdr of nodes are substituted by the first one
// in all elements.
typedef std::list< std::list< int > > TListOfListOfElementsID;
void FindEqualElements(std::set<const SMDS_MeshElement*> & theElements,
TListOfListOfElementsID & theGroupsOfElementsID);
// Return list of group of elements build on the same nodes.
// Search among theElements or in the whole mesh if theElements is empty.
void MergeElements(TListOfListOfElementsID & theGroupsOfElementsID);
// In each group remove all but first of elements.
void MergeEqualElements();
// Remove all but one of elements built on the same nodes.
// Return nb of successfully merged groups.
static bool CheckFreeBorderNodes(const SMDS_MeshNode* theNode1, static bool CheckFreeBorderNodes(const SMDS_MeshNode* theNode1,
const SMDS_MeshNode* theNode2, const SMDS_MeshNode* theNode2,
const SMDS_MeshNode* theNode3 = 0); const SMDS_MeshNode* theNode3 = 0);