Salome HOME
bos #20256: [CEA 18523] Porting SMESH to int 64 bits
[modules/smesh.git] / src / SMESH / SMESH_Algo.cxx
index 8b2d1c5d2ab0baec4d5a4dab468802f40e656ab7..cb9cc74899e73b46ecf375033938402e4ec4f66a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -263,35 +263,36 @@ SMESH_Algo::GetUsedHypothesis(SMESH_Mesh &         aMesh,
                               const bool           ignoreAuxiliary) const
 {
   SMESH_Algo* me = const_cast< SMESH_Algo* >( this );
+
+  std::list<const SMESHDS_Hypothesis *> savedHyps; // don't delete the list if 
+  savedHyps.swap( me->_usedHypList );              // it does not change (#16578)
+
   me->_usedHypList.clear();
+  me->_assigedShapeList.clear();
   if ( const SMESH_HypoFilter* filter = GetCompatibleHypoFilter( ignoreAuxiliary ))
   {
-    aMesh.GetHypotheses( aShape, *filter, me->_usedHypList, true );
+    aMesh.GetHypotheses( aShape, *filter, me->_usedHypList, true, & me->_assigedShapeList );
     if ( ignoreAuxiliary && _usedHypList.size() > 1 )
+    {
       me->_usedHypList.clear(); //only one compatible hypothesis allowed
+      me->_assigedShapeList.clear();
+    }
   }
+  if ( _usedHypList == savedHyps )
+    savedHyps.swap( me->_usedHypList );
+
   return _usedHypList;
 }
 
-//=============================================================================
+//================================================================================
 /*!
- *  List the relevant hypothesis associated to the shape. Relevant hypothesis
- *  have a name (type) listed in the algorithm. Hypothesis associated to
- *  father shape -are not- taken into account (see GetUsedHypothesis)
+ * Return sub-shape to which hypotheses returned by GetUsedHypothesis() are assigned
  */
-//=============================================================================
+//================================================================================
 
-const list<const SMESHDS_Hypothesis *> &
-SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh &         aMesh,
-                                 const TopoDS_Shape & aShape,
-                                 const bool           ignoreAuxiliary) const
+const std::list < TopoDS_Shape > & SMESH_Algo::GetAssignedShapes() const
 {
-  SMESH_Algo* me = const_cast< SMESH_Algo* >( this );
-  me->_appliedHypList.clear();
-  if ( const SMESH_HypoFilter* filter = GetCompatibleHypoFilter( ignoreAuxiliary ))
-    aMesh.GetHypotheses( aShape, *filter, me->_appliedHypList, false );
-
-  return _appliedHypList;
+  return _assigedShapeList;
 }
 
 //=============================================================================
@@ -517,7 +518,7 @@ GeomAbs_Shape SMESH_Algo::Continuity(const TopoDS_Edge& theE1,
     OCC_CATCH_SIGNALS;
     return BRepLProp::Continuity(C1, C2, u1, u2, tol, angTol);
   }
-  catch (Standard_Failure) {
+  catch (Standard_Failure&) {
   }
   return GeomAbs_C0;
 }
@@ -857,7 +858,7 @@ bool SMESH_Algo::Compute(SMESH_Mesh & /*aMesh*/, SMESH_MesherHelper* /*aHelper*/
 //purpose  : Return true if the algorithm can mesh a given shape
 //=======================================================================
 
-bool SMESH_Algo::IsApplicableToShape(const TopoDS_Shape & shape, bool toCheckAll) const
+bool SMESH_Algo::IsApplicableToShape(const TopoDS_Shape & /*shape*/, bool /*toCheckAll*/) const
 {
   return true;
 }
@@ -949,10 +950,9 @@ void SMESH_Algo::InitComputeError()
 {
   _error = COMPERR_OK;
   _comment.clear();
-  list<const SMDS_MeshElement*>::iterator elem = _badInputElements.begin();
-  for ( ; elem != _badInputElements.end(); ++elem )
-    if ( (*elem)->GetID() < 1 )
-      delete *elem;
+  for ( const SMDS_MeshElement* & elem : _badInputElements )
+    if ( !elem->IsNull() && elem->GetID() < 1 )
+      delete elem;
   _badInputElements.clear();
   _mesh = 0;
 
@@ -1014,6 +1014,7 @@ void SMESH_Algo::addBadInputElements(const SMESHDS_SubMesh* sm,
       SMDS_ElemIteratorPtr eIt = sm->GetElements();
       while ( eIt->more() ) addBadInputElement( eIt->next() );
     }
+    _mesh = sm->GetParent();
   }
 }
 
@@ -1037,12 +1038,12 @@ void SMESH_Algo::addBadInputElements(const SMESHDS_SubMesh* sm,
  */
 //=============================================================================
 
-int SMESH_Algo::NumberOfPoints(SMESH_Mesh& aMesh, const TopoDS_Wire& W)
+smIdType SMESH_Algo::NumberOfPoints(SMESH_Mesh& aMesh, const TopoDS_Wire& W)
 {
-  int nbPoints = 0;
+  smIdType nbPoints = 0;
   for (TopExp_Explorer exp(W,TopAbs_EDGE); exp.More(); exp.Next()) {
     const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
-    int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+    smIdType nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
     if(_quadraticMesh)
       nb = nb/2;
     nbPoints += nb + 1; // internal points plus 1 vertex of 2 (last point ?)
@@ -1254,3 +1255,33 @@ bool SMESH_2D_Algo::FixInternalNodes(const SMESH_ProxyMesh& mesh,
   }
   return true;
 }
+
+//=======================================================================
+//function : IsApplicableToShape
+//purpose  : Return true if the algorithm can mesh a given shape
+//=======================================================================
+
+bool SMESH_1D_Algo::IsApplicableToShape(const TopoDS_Shape & shape, bool /*toCheckAll*/) const
+{
+  return ( !shape.IsNull() && TopExp_Explorer( shape, TopAbs_EDGE ).More() );
+}
+
+//=======================================================================
+//function : IsApplicableToShape
+//purpose  : Return true if the algorithm can mesh a given shape
+//=======================================================================
+
+bool SMESH_2D_Algo::IsApplicableToShape(const TopoDS_Shape & shape, bool /*toCheckAll*/) const
+{
+  return ( !shape.IsNull() && TopExp_Explorer( shape, TopAbs_FACE ).More() );
+}
+
+//=======================================================================
+//function : IsApplicableToShape
+//purpose  : Return true if the algorithm can mesh a given shape
+//=======================================================================
+
+bool SMESH_3D_Algo::IsApplicableToShape(const TopoDS_Shape & shape, bool /*toCheckAll*/) const
+{
+  return ( !shape.IsNull() && TopExp_Explorer( shape, TopAbs_SOLID ).More() );
+}