Salome HOME
Merge from BR_V5_IMP_P8
[modules/smesh.git] / src / StdMeshers / StdMeshers_Regular_1D.cxx
index f1692228c6be054ec7c997fc738c9124ea3a1b81..ee4aa86e78a1e992e97c3c2a599a9ef13b4105d3 100644 (file)
 //           Moved here from SMESH_Regular_1D.cxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
-//
+
 #include "StdMeshers_Regular_1D.hxx"
 #include "StdMeshers_Distribution.hxx"
 
-#include "StdMeshers_LocalLength.hxx"
-#include "StdMeshers_NumberOfSegments.hxx"
 #include "StdMeshers_Arithmetic1D.hxx"
-#include "StdMeshers_StartEndLength.hxx"
-#include "StdMeshers_Deflection1D.hxx"
 #include "StdMeshers_AutomaticLength.hxx"
-#include "StdMeshers_SegmentLengthAroundVertex.hxx"
+#include "StdMeshers_Deflection1D.hxx"
+#include "StdMeshers_LocalLength.hxx"
+#include "StdMeshers_MaxLength.hxx"
+#include "StdMeshers_NumberOfSegments.hxx"
 #include "StdMeshers_Propagation.hxx"
+#include "StdMeshers_SegmentLengthAroundVertex.hxx"
+#include "StdMeshers_StartEndLength.hxx"
 
 #include "SMESH_Gen.hxx"
 #include "SMESH_Mesh.hxx"
@@ -80,6 +80,7 @@ StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId, int studyId,
        _shapeType = (1 << TopAbs_EDGE);
 
        _compatibleHypothesis.push_back("LocalLength");
+       _compatibleHypothesis.push_back("MaxLength");
        _compatibleHypothesis.push_back("NumberOfSegments");
        _compatibleHypothesis.push_back("StartEndLength");
        _compatibleHypothesis.push_back("Deflection1D");
@@ -145,14 +146,28 @@ bool StdMeshers_Regular_1D::CheckHypothesis
     const StdMeshers_LocalLength * hyp =
       dynamic_cast <const StdMeshers_LocalLength * >(theHyp);
     ASSERT(hyp);
-    //_value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength();
     _value[ BEG_LENGTH_IND ] = hyp->GetLength();
-    _value[ END_LENGTH_IND ] = hyp->GetPrecision();
+    _value[ PRECISION_IND ] = hyp->GetPrecision();
     ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
     _hypType = LOCAL_LENGTH;
     aStatus = SMESH_Hypothesis::HYP_OK;
   }
 
+  else if (hypName == "MaxLength")
+  {
+    const StdMeshers_MaxLength * hyp =
+      dynamic_cast <const StdMeshers_MaxLength * >(theHyp);
+    ASSERT(hyp);
+    _value[ BEG_LENGTH_IND ] = hyp->GetLength();
+    if ( hyp->GetUsePreestimatedLength() ) {
+      if ( int nbSeg = aMesh.GetGen()->GetBoundaryBoxSegmentation() )
+        _value[ BEG_LENGTH_IND ] = aMesh.GetShapeDiagonalSize() / nbSeg;
+    }
+    ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
+    _hypType = MAX_LENGTH;
+    aStatus = SMESH_Hypothesis::HYP_OK;
+  }
+
   else if (hypName == "NumberOfSegments")
   {
     const StdMeshers_NumberOfSegments * hyp =
@@ -225,11 +240,11 @@ bool StdMeshers_Regular_1D::CheckHypothesis
     StdMeshers_AutomaticLength * hyp = const_cast<StdMeshers_AutomaticLength *>
       (dynamic_cast <const StdMeshers_AutomaticLength * >(theHyp));
     ASSERT(hyp);
-    //_value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
-    _value[ BEG_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
-    _value[ END_LENGTH_IND ] = Precision::Confusion(); // ?? or set to zero?
+    _value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
+//     _value[ BEG_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
+//     _value[ END_LENGTH_IND ] = Precision::Confusion(); // ?? or set to zero?
     ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
-    _hypType = LOCAL_LENGTH;
+    _hypType = MAX_LENGTH;
     aStatus = SMESH_Hypothesis::HYP_OK;
   }
   else
@@ -412,11 +427,6 @@ static void compensateError(double a1, double an,
 
 void StdMeshers_Regular_1D::SetEventListener(SMESH_subMesh* subMesh)
 {
-//   static VertexEventListener listener;
-//   SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
-//   while (smIt->more()) {
-//     subMesh->SetEventListener( &listener, 0, smIt->next() );
-//   }
   StdMeshers_Propagation::SetPropagationMgr( subMesh );
 }
 
@@ -566,10 +576,18 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh &     theMesh,
   switch( _hypType )
   {
   case LOCAL_LENGTH:
+  case MAX_LENGTH:
   case NB_SEGMENTS: {
 
     double eltSize = 1;
-    if ( _hypType == LOCAL_LENGTH )
+    if ( _hypType == MAX_LENGTH )
+    {
+      double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
+      if (nbseg <= 0)
+        nbseg = 1;                        // degenerated edge
+      eltSize = theLength / nbseg;
+    }
+    else if ( _hypType == LOCAL_LENGTH )
     {
       // Local Length hypothesis
       double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
@@ -600,7 +618,7 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh &     theMesh,
       }
       if (!isFound) // not found by meshed edge in the propagation chain, use precision
       {
-        double aPrecision = _value[ END_LENGTH_IND ];
+        double aPrecision = _value[ PRECISION_IND ];
         double nbseg_prec = ceil((theLength / _value[ BEG_LENGTH_IND ]) - aPrecision);
         if (nbseg_prec == (nbseg - 1)) nbseg--;
       }