Bug 0020185: EDF SMESH 967 : Anomaly in Merge Nodes.

This commit is contained in:
jfa 2009-04-03 08:54:51 +00:00
parent 7bc441ba31
commit c113b9f92e
4 changed files with 104 additions and 92 deletions

View File

@ -20,11 +20,12 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMESH_Octree : global Octree implementation
//
// File : SMESH_Octree.cxx
// Created : Tue Jan 16 16:00:00 2007
// Author : Nicolas Geimer & Aurélien Motteux(OCC)
// Module : SMESH
//
#include "SMESH_Octree.hxx"
//===========================================================================
@ -150,8 +151,8 @@ void SMESH_Octree::buildChildren()
gp_XYZ minChild;
for (int i = 0; i < 8; i++)
{
// We build the eight boxes, we need 2 points to do that.
// Min, and Mid
// We build the eight boxes, we need 2 points to do that:
// Min and Mid
// In binary, we can write i from 0 to 7
// For instance :
// 5 is 101, it corresponds here in coordinates to ZYX
@ -167,7 +168,7 @@ void SMESH_Octree::buildChildren()
box = new Bnd_B3d(minChild+childHsize,childHsize);
// The child is of the same type than its father (For instance, a SMESH_OctreeNode)
// We allocate the memory we need fot the child
// We allocate the memory we need for the child
myChildren[i] = allocateOctreeChild();
// and we assign to him its box.
myChildren[i]->setBox(box);

View File

@ -20,11 +20,12 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMESH_Octree : global Octree implementation
//
// File : SMESH_Octree.hxx
// Created : Tue Jan 16 16:00:00 2007
// Author : Nicolas Geimer & Aurélien Motteux (OCC)
// Module : SMESH
//
#ifndef _SMESH_OCTREE_HXX_
#define _SMESH_OCTREE_HXX_
@ -96,4 +97,5 @@ protected:
// Tell us if the Octree is a leaf or not (-1 if not initialized)
int myIsLeaf;
};
#endif

View File

@ -21,11 +21,12 @@
//
// SMESH SMESH_OctreeNode : Octree with Nodes set
// inherites global class SMESH_Octree
//
// File : SMESH_OctreeNode.cxx
// Created : Tue Jan 16 16:00:00 2007
// Author : Nicolas Geimer & Aurélien Motteux (OCC)
// Module : SMESH
//
#include "SMESH_OctreeNode.hxx"
#include "SMDS_MeshNode.hxx"
@ -52,7 +53,9 @@ SMESH_OctreeNode::SMESH_OctreeNode (const set<const SMDS_MeshNode*> & theNodes,
// We need to compute the first bounding box via a special method
computeBoxForFather();
myNbNodes = myNodes.size();
myIsLeaf = (myLevel == myMaxLevel)||(myNbNodes<=myMaxNbNodes)||(myMinBoxSize>=maxSize(myBox));
myIsLeaf = ((myLevel == myMaxLevel) ||
(myNbNodes <= myMaxNbNodes) ||
(maxSize(myBox) <= myMinBoxSize));
// All the children (Boxes and Data) are computed in Compute()
Compute();
}
@ -74,8 +77,6 @@ SMESH_Octree* SMESH_OctreeNode::allocateOctreeChild()
return theOctree;
}
//======================================
/*!
* \brief Compute the first bounding box
@ -127,7 +128,6 @@ const bool SMESH_OctreeNode::isInside(const SMDS_MeshNode * Node, const double p
return !(Out);
}
//================================================
/*!
* \brief Set the data of the children
@ -155,7 +155,9 @@ void SMESH_OctreeNode::buildChildrenData()
{
SMESH_OctreeNode* myChild = dynamic_cast<SMESH_OctreeNode*> (myChildren[i]);
myChild->myNbNodes = (myChild->myNodes).size();
myChild->myIsLeaf = (myChild->myLevel == myMaxLevel)||(myChild->myNbNodes<=myMaxNbNodes)||(myMinBoxSize>=maxSize(myChild->myBox));
myChild->myIsLeaf = ((myChild->myLevel == myMaxLevel) ||
(myChild->myNbNodes <= myMaxNbNodes) ||
(maxSize(myChild->myBox) <= myMinBoxSize));
}
}
@ -168,7 +170,8 @@ void SMESH_OctreeNode::buildChildrenData()
*/
//====================================================================
void SMESH_OctreeNode::NodesAround (const SMDS_MeshNode * Node,
list<const SMDS_MeshNode*>* Result, const double precision)
list<const SMDS_MeshNode*>* Result,
const double precision)
{
if (isInside(Node,precision))
{
@ -187,60 +190,60 @@ void SMESH_OctreeNode::NodesAround( const SMDS_MeshNode * Node,
}
}
//=============================
/*!
* \brief Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance
* Search for all the nodes in nodes
* Search for all the nodes in theSetOfNodes
* Static Method : no need to create an SMESH_OctreeNode
* \param nodes - set of nodes we look at, modified during research
* \param theSetOfNodes - set of nodes we look at, modified during research
* \param theGroupsOfNodes - list of nodes closed to each other returned
* \param theTolerance - Precision used, default value is 0.00001
* \param maxLevel - Maximum level for SMESH_OctreeNode constructed, default value is -1 (Infinite)
* \param maxNbNodes - maximum Nodes in a Leaf of the SMESH_OctreeNode constructed, default value is 5
*/
//=============================
void SMESH_OctreeNode::FindCoincidentNodes ( set<const SMDS_MeshNode*> nodes,
void SMESH_OctreeNode::FindCoincidentNodes (set<const SMDS_MeshNode*> theSetOfNodes,
list< list< const SMDS_MeshNode*> >* theGroupsOfNodes,
const double theTolerance, const int maxLevel,
const double theTolerance,
const int maxLevel,
const int maxNbNodes)
{
SMESH_OctreeNode* theOctreeNode = new SMESH_OctreeNode(nodes, maxLevel, maxNbNodes, theTolerance);
theOctreeNode->FindCoincidentNodes (&nodes, theTolerance, theGroupsOfNodes);
SMESH_OctreeNode* theOctreeNode = new SMESH_OctreeNode(theSetOfNodes, maxLevel, maxNbNodes, theTolerance);
theOctreeNode->FindCoincidentNodes (&theSetOfNodes, theTolerance, theGroupsOfNodes);
delete theOctreeNode;
}
//=============================
/*!
* \brief Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance
* Search for all the nodes in nodes
* \param nodes - set of nodes we look at, modified during research
* Search for all the nodes in theSetOfNodes
* \note The Octree itself is also modified by this method
* \param theSetOfNodes - set of nodes we look at, modified during research
* \param theTolerance - Precision used
* \param theGroupsOfNodes - list of nodes closed to each other returned
*/
//=============================
void SMESH_OctreeNode::FindCoincidentNodes ( set<const SMDS_MeshNode*>* nodes,
void SMESH_OctreeNode::FindCoincidentNodes ( set<const SMDS_MeshNode*>* theSetOfNodes,
const double theTolerance,
list< list< const SMDS_MeshNode*> >* theGroupsOfNodes)
{
set<const SMDS_MeshNode*>::iterator it1 = nodes->begin();
set<const SMDS_MeshNode*>::iterator it1 = theSetOfNodes->begin();
list<const SMDS_MeshNode*>::iterator it2;
while (it1 != nodes->end())
while (it1 != theSetOfNodes->end())
{
const SMDS_MeshNode * n1 = *it1;
list<const SMDS_MeshNode*> ListofCoincidentNodes;// Initialize the lists via a declaration, it's enough
list<const SMDS_MeshNode*> ListOfCoincidentNodes;// Initialize the lists via a declaration, it's enough
list<const SMDS_MeshNode*> * groupPtr = 0;
// Searching for Nodes around n1 and put them in ListofCoincidentNodes
FindCoincidentNodes(n1, nodes, &ListofCoincidentNodes, theTolerance);
// Searching for Nodes around n1 and put them in ListofCoincidentNodes.
// Found nodes are also erased from theSetOfNodes
FindCoincidentNodes(n1, theSetOfNodes, &ListOfCoincidentNodes, theTolerance);
// We build a list {n1 + his neigbours} and add this list in theGroupsOfNodes
for (it2=ListofCoincidentNodes.begin();it2 != ListofCoincidentNodes.end(); it2++)
for (it2 = ListOfCoincidentNodes.begin(); it2 != ListOfCoincidentNodes.end(); it2++)
{
const SMDS_MeshNode* n2 = *it2;
if ( !groupPtr )
@ -257,14 +260,15 @@ void SMESH_OctreeNode::FindCoincidentNodes ( set<const SMDS_MeshNode*>* nodes,
if (groupPtr != 0)
groupPtr->sort();
nodes->erase(it1);
it1=nodes->begin();
theSetOfNodes->erase(it1);
it1 = theSetOfNodes->begin();
}
}
//======================================================================================
/*!
* \brief Return a list of nodes closed to Node and remove it from SetOfNodes
* \note The Octree itself is also modified by this method
* \param Node - We're searching the nodes next to him.
* \param SetOfNodes - set of nodes in which we erase the found nodes
* \param Result - list of nodes closed to Node
@ -294,7 +298,9 @@ void SMESH_OctreeNode::FindCoincidentNodes( const SMDS_MeshNode * Node,
{
const SMDS_MeshNode* n2 = *it;
// We're only looking at nodes with a superior Id.
if(Node->GetID() < n2->GetID())
// JFA: Why?
//if (Node->GetID() < n2->GetID())
if (Node->GetID() != n2->GetID()) // JFA: for bug 0020185
{
gp_Pnt p2 (n2->X(), n2->Y(), n2->Z());
// Distance optimized computation
@ -308,10 +314,12 @@ void SMESH_OctreeNode::FindCoincidentNodes( const SMDS_MeshNode * Node,
myNodes.erase( n2 );
}
}
myNodesCopy.erase( it );
it = myNodesCopy.begin();
//myNodesCopy.erase( it );
//it = myNodesCopy.begin();
it++;
}
if (Result->size() > 0)
myNodes.erase(Node); // JFA: for bug 0020185
}
else
{
@ -330,7 +338,6 @@ void SMESH_OctreeNode::FindCoincidentNodes( const SMDS_MeshNode * Node,
* \brief Return iterator over children
*/
//================================================================================
SMESH_OctreeNodeIteratorPtr SMESH_OctreeNode::GetChildrenIterator()
{
return SMESH_OctreeNodeIteratorPtr
@ -343,7 +350,6 @@ SMESH_OctreeNodeIteratorPtr SMESH_OctreeNode::GetChildrenIterator()
* \brief Return nodes iterator
*/
//================================================================================
SMDS_NodeIteratorPtr SMESH_OctreeNode::GetNodeIterator()
{
return SMDS_NodeIteratorPtr

View File

@ -21,11 +21,12 @@
//
// SMESH SMESH_OctreeNode : Octree with Nodes set
// inherites global class SMESH_Octree
//
// File : SMESH_OctreeNode.hxx
// Created : Tue Jan 16 16:00:00 2007
// Author : Nicolas Geimer & Aurélien Motteux (OCC)
// Module : SMESH
//
#ifndef _SMESH_OCTREENODE_HXX_
#define _SMESH_OCTREENODE_HXX_
@ -65,7 +66,8 @@ public:
virtual const bool isInside(const SMDS_MeshNode * Node, const double precision = 0.);
// Return in Result a list of Nodes potentials to be near Node
void NodesAround( const SMDS_MeshNode * Node , std::list<const SMDS_MeshNode*>* Result,
void NodesAround(const SMDS_MeshNode * Node,
std::list<const SMDS_MeshNode*>* Result,
const double precision = 0.);
// Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance
@ -126,4 +128,5 @@ protected:
// The number of nodes I have inside the box
int myNbNodes;
};
#endif