Salome HOME
21680: EDF 2288 SMESH: creation of 0D elements from other elements
authoreap <eap@opencascade.com>
Tue, 23 Oct 2012 07:46:58 +0000 (07:46 +0000)
committereap <eap@opencascade.com>
Tue, 23 Oct 2012 07:46:58 +0000 (07:46 +0000)
+  void Create0DElementsOnAllNodes( const TIDSortedElemSet& elements,
+                                   TIDSortedElemSet&       all0DElems);

+  void                           CrearLastCreated();

src/SMESH/SMESH_MeshEditor.cxx
src/SMESH/SMESH_MeshEditor.hxx

index 9c75f7975c357adaf2e4e243428ef8a53add488b..9f7a481f0ac1945ceab07ec5cdac15fdc841639e 100644 (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)
 {
index 26240938810e8f3e2e19c5d483ce0a252365569e..ce52a9c051c342ac2a049cb0fa19b1c929982b36 100644 (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