Salome HOME
Add new method DoubleNodeElemGroupsNew which allows to have the group of newly create...
authorgdd <gdd>
Tue, 18 Jan 2011 14:45:18 +0000 (14:45 +0000)
committergdd <gdd>
Tue, 18 Jan 2011 14:45:18 +0000 (14:45 +0000)
idl/SMESH_MeshEditor.idl
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.hxx
src/SMESH_SWIG/smeshDC.py

index e4e504e1ae8f30906d4c03a6f4511cdf6ec57184..f001799cf284c24fc1cacf71c59d3b7b6ca389aa 100644 (file)
@@ -900,12 +900,27 @@ module SMESH
      * \param theAffectedElems - group of elements to which the replicated nodes
      *        should be associated to.
      * \return TRUE if operation has been completed successfully, FALSE otherwise
-     * \sa DoubleNodeGroup(), DoubleNodes()
+     * \sa DoubleNodeGroup(), DoubleNodes(), DoubleNodeElemGroupsNew()
     */
     boolean DoubleNodeElemGroups( in ListOfGroups theElems,
                                   in ListOfGroups theNodesNot,
                                   in ListOfGroups theAffectedElems );
 
+    /*!
+     * \brief Creates a hole in a mesh by doubling the nodes of some particular elements.
+     * Works as DoubleNodeElemGroups() described above, but returns a new group with
+     * newly created elements.
+     * \param theElems - list of groups of elements (edges or faces) to be replicated
+     * \param theNodesNot - list of groups of nodes not to replicated
+     * \param theAffectedElems - group of elements to which the replicated nodes
+     *        should be associated to.
+     * \return a new group with newly created elements
+     * \sa DoubleNodeElemGroups()
+    */
+    SMESH_Group DoubleNodeElemGroupsNew( in ListOfGroups theElems,
+                                         in ListOfGroups theNodesNot,
+                                         in ListOfGroups theAffectedElems );
+
     /*!
      * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
      * This method provided for convenience works as DoubleNodes() described above.
index e62946601f04d7b6de2a0494ddf03c1b8059938f..3ffce11d3239f8634eb0da984f13f18a00c4eca3 100644 (file)
@@ -1194,7 +1194,9 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
     theCommand->SetMethod("FindCoincidentNodesOnPart");
   }
   // DoubleNodeElemGroupNew() -> DoubleNodeElemGroup()
-  if ( !isPyMeshMethod && ( method == "DoubleNodeElemGroupNew" || method == "DoubleNodeGroupNew"))
+  // DoubleNodeGroupNew() -> DoubleNodeGroup()
+  // DoubleNodeElemGroupsNew() -> DoubleNodeElemGroups()
+  if ( !isPyMeshMethod && ( method == "DoubleNodeElemGroupNew" || method == "DoubleNodeGroupNew" || method == "DoubleNodeElemGroupsNew"))
   {
     isPyMeshMethod=true;
     theCommand->SetMethod( method.SubString( 1, method.Length()-3));
index 1e732f9228988bbd9e8a5a2cf35e059e60cb2beb..9d1cf79dd4c24c3a1da8174e1f87f0026a321884 100644 (file)
@@ -5134,7 +5134,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroupInRegion(SMESH::SMESH_Grou
   \param theAffectedElems - group of elements to which the replicated nodes
   should be associated to.
   \return TRUE if operation has been completed successfully, FALSE otherwise
-  \sa DoubleNodeGroup(), DoubleNodes()
+  \sa DoubleNodeGroup(), DoubleNodes(), DoubleNodeElemGroupsNew()
 */
 //================================================================================
 
@@ -5183,6 +5183,60 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroups(const SMESH::ListOfGroup
   return aResult;
 }
 
+//================================================================================
+/*!
+ * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+ * Works as DoubleNodeElemGroups(), but returns a new group with newly created elements.
+  \param theElems - list of groups of elements (edges or faces) to be replicated
+  \param theNodesNot - list of groups of nodes not to replicated
+  \param theAffectedElems - group of elements to which the replicated nodes
+  should be associated to.
+ * \return a new group with newly created elements
+ * \sa DoubleNodeElemGroups()
+ */
+//================================================================================
+
+SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupsNew(const SMESH::ListOfGroups& theElems,
+                                                                   const SMESH::ListOfGroups& theNodesNot,
+                                                                   const SMESH::ListOfGroups& theAffectedElems)
+{
+  SMESH::SMESH_Group_var aNewGroup;
+  
+  initData();
+
+  ::SMESH_MeshEditor aMeshEditor( myMesh );
+
+  SMESHDS_Mesh* aMeshDS = GetMeshDS();
+  TIDSortedElemSet anElems, aNodes, anAffected;
+  listOfGroupToSet(theElems, aMeshDS, anElems, false );
+  listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
+  listOfGroupToSet(theAffectedElems, aMeshDS, anAffected, false );
+
+  bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
+
+  storeResult( aMeshEditor) ;
+
+  myMesh->GetMeshDS()->Modified();
+  if ( aResult ) {
+    myMesh->SetIsModified( true );
+
+    // Create group with newly created elements
+    SMESH::long_array_var anIds = GetLastCreatedElems();
+    if (anIds->length() > 0) {
+      SMESH::ElementType aGroupType = myMesh_i->GetElementType(anIds[0], true);
+      string anUnindexedName (theElems[0]->GetName());
+      string aNewName = generateGroupName(anUnindexedName + "_double");
+      aNewGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str());
+      aNewGroup->Add(anIds);
+    }
+  }
+
+  // Update Python script
+  TPythonDump() << "createdElems = " << this << ".DoubleNodeElemGroupsNew( " << &theElems << ", "
+                << &theNodesNot << ", " << &theAffectedElems << " )";
+  return aNewGroup._retn();
+}
+
 //================================================================================
 /*!
   \brief Creates a hole in a mesh by doubling the nodes of some particular elements
index e90fe857eca44396a104d03fc362d1f90810bb95..ea8f3014261247207bb89607b57cf850f9890ead 100644 (file)
@@ -607,7 +607,7 @@ public:
    * \param theAffectedElems - group of elements to which the replicated nodes
    *        should be associated to.
    * \return TRUE if operation has been completed successfully, FALSE otherwise
-   * \sa DoubleNodes(), DoubleNodeGroups()
+   * \sa DoubleNodes(), DoubleNodeGroups(), DoubleNodeElemGroupNew()
    */
   CORBA::Boolean DoubleNodeElemGroup( SMESH::SMESH_GroupBase_ptr theElems,
                                       SMESH::SMESH_GroupBase_ptr theNodesNot,
@@ -649,12 +649,26 @@ public:
    * \param theAffectedElems - group of elements to which the replicated nodes
    *        should be associated to.
    * \return TRUE if operation has been completed successfully, FALSE otherwise
-   * \sa DoubleNodeGroup(), DoubleNodes()
+   * \sa DoubleNodeGroup(), DoubleNodes(), DoubleNodeElemGroupsNew()
    */
   CORBA::Boolean DoubleNodeElemGroups( const SMESH::ListOfGroups& theElems,
                                        const SMESH::ListOfGroups& theNodesNot,
                                        const SMESH::ListOfGroups& theAffectedElems );
 
+  /*!
+   * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+   * Works as DoubleNodeElemGroups(), but returns a new group with newly created elements.
+   * \param theElems - list of groups of elements (edges or faces) to be replicated
+   * \param theNodesNot - list of groups of nodes not to replicated
+   * \param theAffectedElems - group of elements to which the replicated nodes
+   *        should be associated to.
+   * \return a new group with newly created elements
+   * \sa DoubleNodeElemGroups()
+   */
+  SMESH::SMESH_Group_ptr DoubleNodeElemGroupsNew( const SMESH::ListOfGroups& theElems,
+                                                  const SMESH::ListOfGroups& theNodesNot,
+                                                  const SMESH::ListOfGroups& theAffectedElems );
+
 
   /*!
    * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
index de05f11d8f9e8693356a1064bbf217738f54e947..5fa6cc4b40f59bc61106a5f7a94b1b55142937eb 100644 (file)
@@ -4064,6 +4064,8 @@ class Mesh:
     #  @param theAffectedElems - group of elements to which the replicated nodes
     #         should be associated to.
     #  @param theMakeGroup forces the generation of a group containing new elements.
+    #  @return TRUE or a created group if operation has been completed successfully,
+    #          FALSE or None otherwise
     #  @ingroup l2_modif_edit
     def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
         if theMakeGroup:
@@ -4087,9 +4089,13 @@ class Mesh:
     #  @param theNodesNot - list of groups of nodes not to replicated
     #  @param theAffectedElems - group of elements to which the replicated nodes
     #         should be associated to.
-    #  @return TRUE if operation has been completed successfully, FALSE otherwise
+    #  @param theMakeGroup forces the generation of a group containing new elements.
+    #  @return TRUE or a created group if operation has been completed successfully,
+    #          FALSE or None otherwise
     #  @ingroup l2_modif_edit
-    def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
+    def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
+        if theMakeGroup:
+            return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
         return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
 
     ## Creates a hole in a mesh by doubling the nodes of some particular elements