From: eap Date: Tue, 23 Oct 2012 07:46:58 +0000 (+0000) Subject: 21680: EDF 2288 SMESH: creation of 0D elements from other elements X-Git-Tag: V6_6_0b1~53 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1ba66cde789c37c4a06b4d0d510b2ca489d48bfc;p=modules%2Fsmesh.git 21680: EDF 2288 SMESH: creation of 0D elements from other elements + void Create0DElementsOnAllNodes( const TIDSortedElemSet& elements, + TIDSortedElemSet& all0DElems); + void CrearLastCreated(); --- diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 9c75f7975..9f7a481f0 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -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 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) { diff --git a/src/SMESH/SMESH_MeshEditor.hxx b/src/SMESH/SMESH_MeshEditor.hxx index 262409388..ce52a9c05 100644 --- a/src/SMESH/SMESH_MeshEditor.hxx +++ b/src/SMESH/SMESH_MeshEditor.hxx @@ -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