#include "SMESH_MeshEditor.hxx"
-#include "SMESH_ControlsDef.hxx"
-
#include "SMDS_FaceOfNodes.hxx"
#include "SMDS_VolumeTool.hxx"
#include "SMESHDS_Group.hxx"
#include "SMESHDS_Mesh.hxx"
#include "SMESH_subMesh.hxx"
+#include "SMESH_ControlsDef.hxx"
+
+#include "utilities.h"
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <map>
-#include "utilities.h"
-
using namespace std;
-using namespace SMESH::Controls;
typedef map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
typedef map<const SMDS_MeshNode*, list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
static double getBadRate (const SMDS_MeshElement* theElem,
SMESH::Controls::NumericalFunctorPtr& theCrit)
{
- TSequenceOfXYZ P;
+ SMESH::Controls::TSequenceOfXYZ P;
if ( !theElem || !theCrit->GetPoints( theElem, P ))
return 1e100;
return theCrit->GetBadRate( theCrit->GetValue( P ), theElem->NbNodes() );
}
//=======================================================================
-//function : addToSameGroups
+//function : AddToSameGroups
//purpose : add elemToAdd to the groups the elemInGroups belongs to
//=======================================================================
-static void addToSameGroups (const SMDS_MeshElement* elemToAdd,
- const SMDS_MeshElement* elemInGroups,
- SMESHDS_Mesh * aMesh)
+void SMESH_MeshEditor::AddToSameGroups (const SMDS_MeshElement* elemToAdd,
+ const SMDS_MeshElement* elemInGroups,
+ SMESHDS_Mesh * aMesh)
{
const set<SMESHDS_GroupBase*>& groups = aMesh->GetGroups();
set<SMESHDS_GroupBase*>::const_iterator grIt = groups.begin();
if ( aShapeId )
aMesh->SetMeshElementOnShape( newElem, aShapeId );
- addToSameGroups( newElem, elem, aMesh );
+ AddToSameGroups( newElem, elem, aMesh );
}
return true;
double angle = 2*PI; // bad angle
// get normals
- TSequenceOfXYZ P1, P2;
+ SMESH::Controls::TSequenceOfXYZ P1, P2;
if ( !SMESH::Controls::NumericalFunctor::GetPoints( tr1, P1 ) ||
!SMESH::Controls::NumericalFunctor::GetPoints( tr2, P2 ))
return angle;
nbElems++;
gp_XYZ elemCenter(0.,0.,0.);
- TSequenceOfXYZ aNodePoints;
+ SMESH::Controls::TSequenceOfXYZ aNodePoints;
SMDS_ElemIteratorPtr itN = elem->nodesIterator();
while ( itN->more() )
{
const SMDS_MeshElement* elem = (*itElem);
if ( !elem || elem->GetType() != SMDSAbs_Face )
continue;
- TSequenceOfXYZ aPoints;
+ SMESH::Controls::TSequenceOfXYZ aPoints;
if ( aQualityFunc.GetPoints( elem, aPoints )) {
double aValue = aQualityFunc.GetValue( aPoints );
if ( aValue > maxRatio )
//=======================================================================
//function : FindCoincidentNodes
//purpose : 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 SMESH_MeshEditor::FindCoincidentNodes (const double theTolerance,
- TListOfListOfNodes & theGroupsOfNodes)
+void SMESH_MeshEditor::FindCoincidentNodes (set<const SMDS_MeshNode*> & theNodes,
+ const double theTolerance,
+ TListOfListOfNodes & theGroupsOfNodes)
{
double tol2 = theTolerance * theTolerance;
list<const SMDS_MeshNode*> nodes;
- SMDS_NodeIteratorPtr nIt = GetMeshDS()->nodesIterator();
- while ( nIt->more() )
- nodes.push_back( nIt->next() );
+ if ( theNodes.empty() )
+ { // get all nodes in the mesh
+ SMDS_NodeIteratorPtr nIt = GetMeshDS()->nodesIterator();
+ while ( nIt->more() )
+ nodes.push_back( nIt->next() );
+ }
+ else
+ {
+ nodes.insert( nodes.end(), theNodes.begin(), theNodes.end() );
+ }
list<const SMDS_MeshNode*>::iterator it2, it1 = nodes.begin();
for ( ; it1 != nodes.end(); it1++ )
nodeNodeMap.insert( TNodeNodeMap::value_type( nToRemove, nToKeep ));
if ( nToRemove != nToKeep ) {
rmNodeIds.push_back( nToRemove->GetID() );
- addToSameGroups( nToKeep, nToRemove, aMesh );
+ AddToSameGroups( nToKeep, nToRemove, aMesh );
}
SMDS_ElemIteratorPtr invElemIt = nToRemove->GetInverseElementIterator();
typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
- void FindCoincidentNodes (const double theTolerance,
- TListOfListOfNodes & theGroupsOfNodes);
- // Return list of group of nodes close to each other within theTolerance
+ void FindCoincidentNodes (std::set<const SMDS_MeshNode*> & 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
int theNodeIds[] );
// Set 8 nodes of a hexahedron in a good order.
// Return success status
-
+
+ static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
+ const SMDS_MeshElement* elemInGroups,
+ SMESHDS_Mesh * aMesh);
+ // Add elemToAdd to the groups the elemInGroups belongs to
int FindShape (const SMDS_MeshElement * theElem);
// Return an index of the shape theElem is on