21680: EDF 2288 SMESH: creation of 0D elements from other elements

+  void Create0DElementsOnAllNodes( const TIDSortedElemSet& elements,
+                                   TIDSortedElemSet&       all0DElems);

+  void                           CrearLastCreated();
This commit is contained in:
eap 2012-10-23 07:46:58 +00:00
parent 2726a6e3da
commit 1ba66cde78
2 changed files with 59 additions and 0 deletions

View File

@ -120,6 +120,19 @@ SMESH_MeshEditor::SMESH_MeshEditor( SMESH_Mesh* theMesh )
{
}
//================================================================================
/*!
* \brief Clears myLastCreatedNodes and myLastCreatedElems
*/
//================================================================================
void SMESH_MeshEditor::CrearLastCreated()
{
myLastCreatedNodes.Clear();
myLastCreatedElems.Clear();
}
//=======================================================================
/*!
* \brief Add element
@ -389,6 +402,44 @@ int SMESH_MeshEditor::Remove (const list< int >& theIDs,
return removed;
}
//================================================================================
/*!
* \brief Create 0D elements on all nodes of the given object except those
* nodes on which a 0D element already exists.
* \param elements - Elements on whose nodes to create 0D elements; if empty,
* the all mesh is treated
* \param all0DElems - returns all 0D elements found or created on nodes of \a elements
*/
//================================================================================
void SMESH_MeshEditor::Create0DElementsOnAllNodes( const TIDSortedElemSet& elements,
TIDSortedElemSet& all0DElems )
{
typedef SMDS_SetIterator<const SMDS_MeshElement*, TIDSortedElemSet::iterator> TSetIterator;
SMDS_ElemIteratorPtr elemIt;
if ( elements.empty() )
elemIt = GetMeshDS()->elementsIterator( SMDSAbs_Node );
else
elemIt = SMDS_ElemIteratorPtr( new TSetIterator( elements.begin(), elements.end() ));
while ( elemIt->more() )
{
const SMDS_MeshElement* e = elemIt->next();
SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
while ( nodeIt->more() )
{
const SMDS_MeshNode* n = cast2Node( nodeIt->next() );
SMDS_ElemIteratorPtr it0D = n->GetInverseElementIterator( SMDSAbs_0DElement );
if ( it0D->more() )
all0DElems.insert( it0D->next() );
else {
myLastCreatedElems.Append( GetMeshDS()->Add0DElement( n ));
all0DElems.insert( myLastCreatedElems.Last() );
}
}
}
}
//=======================================================================
//function : FindShape
//purpose : Return an index of the shape theElem is on
@ -8156,6 +8207,7 @@ private:
//purpose : Return list of group of elements built on the same nodes.
// Search among theElements or in the whole mesh if theElements is empty
//=======================================================================
void SMESH_MeshEditor::FindEqualElements(TIDSortedElemSet & theElements,
TListOfListOfElementsID & theGroupsOfElementsID)
{

View File

@ -116,6 +116,7 @@ public:
const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; }
const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; }
void CrearLastCreated();
SMESH_ComputeErrorPtr & GetError() { return myError; }
@ -139,6 +140,12 @@ public:
// Remove a node or an element.
// Modify a compute state of sub-meshes which become empty
void Create0DElementsOnAllNodes( const TIDSortedElemSet& elements,
TIDSortedElemSet& all0DElems);
// Create 0D elements on all nodes of the given object except those
// nodes on which a 0D element already exists. \a all0DElems returns
// all 0D elements found or created on nodes of \a elements
bool InverseDiag (const SMDS_MeshElement * theTria1,
const SMDS_MeshElement * theTria2 );
// Replace two neighbour triangles with ones built on the same 4 nodes