Salome HOME
Fix regression of viscous_layers_2D_00/A2
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i.cxx
index 9fce23337f80410db0b0cc76714487d90492dd25..eefbc0e88ddeda15c9e9886935d301485c25cb59 100644 (file)
@@ -2613,28 +2613,31 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::ListOfIDSources& theMeshesArray,
 
     // copy elements
 
-    SMESH::array_of_ElementType_var srcElemTypes = theMeshesArray[i]->GetTypes();
-    if ( srcElemTypes->length() == 1 && srcElemTypes[0] == SMESH::NODE ) // group of nodes
-      continue;
     std::vector< const SMDS_MeshElement* > newElems( initMeshDS->NbElements() + 1, 0 );
-    elemIt = initImpl->GetElements( theMeshesArray[i], SMESH::ALL );
-    while ( elemIt->more() )
+    SMESH::array_of_ElementType_var srcElemTypes = theMeshesArray[i]->GetTypes();
+    bool hasElems = (( srcElemTypes->length() > 1 ) ||
+                     ( srcElemTypes->length() == 1 && srcElemTypes[0] != SMESH::NODE ));
+    if ( hasElems )
     {
-      const SMDS_MeshElement* elem = elemIt->next();
-      elemType.myNodes.resize( elem->NbNodes() );
-
-      SMDS_NodeIteratorPtr itNodes = elem->nodeIterator();
-      for ( int k = 0; itNodes->more(); k++)
+      elemIt = initImpl->GetElements( theMeshesArray[i], SMESH::ALL );
+      while ( elemIt->more() )
       {
-        const SMDS_MeshNode* node = itNodes->next();
-        elemType.myNodes[ k ] = static_cast< const SMDS_MeshNode*> ( newNodes[ node->GetID() ]);
-      }
+        const SMDS_MeshElement* elem = elemIt->next();
+        elemType.myNodes.resize( elem->NbNodes() );
+
+        SMDS_NodeIteratorPtr itNodes = elem->nodeIterator();
+        for ( int k = 0; itNodes->more(); k++)
+        {
+          const SMDS_MeshNode* node = itNodes->next();
+          elemType.myNodes[ k ] = static_cast< const SMDS_MeshNode*> ( newNodes[ node->GetID() ]);
+        }
 
-      // creates a corresponding element on existent nodes in new mesh
-      newElems[ elem->GetID() ] =
-        newEditor.AddElement( elemType.myNodes, elemType.Init( elem, /*basicOnly=*/false ));
+        // creates a corresponding element on existent nodes in new mesh
+        newElems[ elem->GetID() ] =
+          newEditor.AddElement( elemType.myNodes, elemType.Init( elem, /*basicOnly=*/false ));
+      }
+      newEditor.ClearLastCreated(); // forget the history
     }
-    newEditor.ClearLastCreated(); // forget the history
 
 
     // create groups of just added elements
@@ -6254,46 +6257,6 @@ void SMESH_Gen_i::Move( const SMESH::sobject_list& what,
       useCaseBuilder->AppendTo( where, sobj );        // append to the end of list
   }
 }
-//================================================================================
-/*!
- * \brief Returns true if algorithm can be used to mesh a given geometry
- *  \param [in] theAlgoType - the algorithm type
- *  \param [in] theLibName - a name of the Plug-in library implementing the algorithm
- *  \param [in] theGeomObject - the geometry to mesh
- *  \param [in] toCheckAll - if \c True, returns \c True if all shapes are meshable,
- *         else, returns \c True if at least one shape is meshable
- *  \return CORBA::Boolean - can or can't
- */
-//================================================================================
-
-CORBA::Boolean SMESH_Gen_i::IsApplicable ( const char*           theAlgoType,
-                                           const char*           theLibName,
-                                           GEOM::GEOM_Object_ptr theGeomObject,
-                                           CORBA::Boolean        toCheckAll)
-{
-  SMESH_TRY;
-
-  std::string aPlatformLibName;
-  GenericHypothesisCreator_i* aCreator =
-    getHypothesisCreator(theAlgoType, theLibName, aPlatformLibName);
-  if (aCreator)
-  {
-    TopoDS_Shape shape = GeomObjectToShape( theGeomObject );
-    const SMESH_Algo::Features& feat = SMESH_Algo::GetFeatures( theAlgoType );
-    return shape.IsNull() || aCreator->IsApplicable( shape, toCheckAll, feat._dim );
-  }
-  else
-  {
-    return false;
-  }
-
-  SMESH_CATCH( SMESH::doNothing );
-
-#ifdef _DEBUG_
-  cout << "SMESH_Gen_i::IsApplicable(): exception in " << ( theAlgoType ? theAlgoType : "") << endl;
-#endif
-  return true;
-}
 
 //================================================================================
 /*!
@@ -6509,3 +6472,47 @@ std::vector<long> SMESH_Gen_i::_GetInside( SMESH::SMESH_IDSource_ptr meshPart,
   }
   return res;
 }
+
+//================================================================================
+/*!
+ * \brief Returns true if algorithm can be used to mesh a given geometry
+ *  \param [in] theAlgoType - the algorithm type
+ *  \param [in] theLibName - a name of the Plug-in library implementing the algorithm
+ *  \param [in] theGeomObject - the geometry to mesh
+ *  \param [in] toCheckAll - if \c True, returns \c True if all shapes are meshable,
+ *         else, returns \c True if at least one shape is meshable
+ *  \return CORBA::Boolean - can or can't
+ */
+//================================================================================
+
+#undef SMY_OWN_CATCH
+#define SMY_OWN_CATCH // prevent re-throwing SALOME::SALOME_Exception in IsApplicable()
+
+CORBA::Boolean SMESH_Gen_i::IsApplicable ( const char*           theAlgoType,
+                                           const char*           theLibName,
+                                           GEOM::GEOM_Object_ptr theGeomObject,
+                                           CORBA::Boolean        toCheckAll)
+{
+  SMESH_TRY;
+
+  std::string aPlatformLibName;
+  GenericHypothesisCreator_i* aCreator =
+    getHypothesisCreator(theAlgoType, theLibName, aPlatformLibName);
+  if (aCreator)
+  {
+    TopoDS_Shape shape = GeomObjectToShape( theGeomObject );
+    const SMESH_Algo::Features& feat = SMESH_Algo::GetFeatures( theAlgoType );
+    return shape.IsNull() || aCreator->IsApplicable( shape, toCheckAll, feat._dim );
+  }
+  else
+  {
+    return false;
+  }
+
+  SMESH_CATCH( SMESH::doNothing );
+
+#ifdef _DEBUG_
+  cout << "SMESH_Gen_i::IsApplicable(): exception in " << ( theAlgoType ? theAlgoType : "") << endl;
+#endif
+  return true;
+}