Salome HOME
0021074: EDF 1682 MESH: Bug with start and end length hypothesis
[modules/smesh.git] / src / StdMeshers / StdMeshers_Regular_1D.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SMESH SMESH : implementaion of SMESH idl descriptions
24 //  File   : StdMeshers_Regular_1D.cxx
25 //           Moved here from SMESH_Regular_1D.cxx
26 //  Author : Paul RASCLE, EDF
27 //  Module : SMESH
28 //
29 #include "StdMeshers_Regular_1D.hxx"
30 #include "StdMeshers_Distribution.hxx"
31
32 #include "StdMeshers_Arithmetic1D.hxx"
33 #include "StdMeshers_AutomaticLength.hxx"
34 #include "StdMeshers_Deflection1D.hxx"
35 #include "StdMeshers_LocalLength.hxx"
36 #include "StdMeshers_MaxLength.hxx"
37 #include "StdMeshers_NumberOfSegments.hxx"
38 #include "StdMeshers_Propagation.hxx"
39 #include "StdMeshers_SegmentLengthAroundVertex.hxx"
40 #include "StdMeshers_StartEndLength.hxx"
41
42 #include "SMESH_Gen.hxx"
43 #include "SMESH_Mesh.hxx"
44 #include "SMESH_HypoFilter.hxx"
45 #include "SMESH_subMesh.hxx"
46 #include "SMESH_subMeshEventListener.hxx"
47 #include "SMESH_Comment.hxx"
48
49 #include "SMDS_MeshElement.hxx"
50 #include "SMDS_MeshNode.hxx"
51
52 #include "Utils_SALOME_Exception.hxx"
53 #include "utilities.h"
54
55 #include <BRepAdaptor_Curve.hxx>
56 #include <BRep_Tool.hxx>
57 #include <GCPnts_AbscissaPoint.hxx>
58 #include <GCPnts_UniformAbscissa.hxx>
59 #include <GCPnts_UniformDeflection.hxx>
60 #include <Precision.hxx>
61 #include <TopExp.hxx>
62 #include <TopExp_Explorer.hxx>
63 #include <TopoDS.hxx>
64 #include <TopoDS_Edge.hxx>
65
66 #include <string>
67 #include <limits>
68
69 using namespace std;
70
71 //=============================================================================
72 /*!
73  *  
74  */
75 //=============================================================================
76
77 StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId, int studyId,
78         SMESH_Gen * gen):SMESH_1D_Algo(hypId, studyId, gen)
79 {
80         MESSAGE("StdMeshers_Regular_1D::StdMeshers_Regular_1D");
81         _name = "Regular_1D";
82         _shapeType = (1 << TopAbs_EDGE);
83         _fpHyp = 0;
84
85         _compatibleHypothesis.push_back("LocalLength");
86         _compatibleHypothesis.push_back("MaxLength");
87         _compatibleHypothesis.push_back("NumberOfSegments");
88         _compatibleHypothesis.push_back("StartEndLength");
89         _compatibleHypothesis.push_back("Deflection1D");
90         _compatibleHypothesis.push_back("Arithmetic1D");
91         _compatibleHypothesis.push_back("FixedPoints1D");
92         _compatibleHypothesis.push_back("AutomaticLength");
93
94         _compatibleHypothesis.push_back("QuadraticMesh"); // auxiliary !!!
95         _compatibleHypothesis.push_back("Propagation"); // auxiliary !!!
96 }
97
98 //=============================================================================
99 /*!
100  *  
101  */
102 //=============================================================================
103
104 StdMeshers_Regular_1D::~StdMeshers_Regular_1D()
105 {
106 }
107
108 //=============================================================================
109 /*!
110  *  
111  */
112 //=============================================================================
113
114 bool StdMeshers_Regular_1D::CheckHypothesis
115                          (SMESH_Mesh&                          aMesh,
116                           const TopoDS_Shape&                  aShape,
117                           SMESH_Hypothesis::Hypothesis_Status& aStatus)
118 {
119   _hypType = NONE;
120   _quadraticMesh = false;
121
122   const bool ignoreAuxiliaryHyps = false;
123   const list <const SMESHDS_Hypothesis * > & hyps =
124     GetUsedHypothesis(aMesh, aShape, ignoreAuxiliaryHyps);
125
126   // find non-auxiliary hypothesis
127   const SMESHDS_Hypothesis *theHyp = 0;
128   list <const SMESHDS_Hypothesis * >::const_iterator h = hyps.begin();
129   for ( ; h != hyps.end(); ++h ) {
130     if ( static_cast<const SMESH_Hypothesis*>(*h)->IsAuxiliary() ) {
131       if ( strcmp( "QuadraticMesh", (*h)->GetName() ) == 0 )
132         _quadraticMesh = true;
133     }
134     else {
135       if ( !theHyp )
136         theHyp = *h; // use only the first non-auxiliary hypothesis
137     }
138   }
139
140   if ( !theHyp )
141   {
142     aStatus = SMESH_Hypothesis::HYP_MISSING;
143     return false;  // can't work without a hypothesis
144   }
145
146   string hypName = theHyp->GetName();
147
148   if (hypName == "LocalLength")
149   {
150     const StdMeshers_LocalLength * hyp =
151       dynamic_cast <const StdMeshers_LocalLength * >(theHyp);
152     ASSERT(hyp);
153     _value[ BEG_LENGTH_IND ] = hyp->GetLength();
154     _value[ PRECISION_IND ] = hyp->GetPrecision();
155     ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
156     _hypType = LOCAL_LENGTH;
157     aStatus = SMESH_Hypothesis::HYP_OK;
158   }
159
160   else if (hypName == "MaxLength")
161   {
162     const StdMeshers_MaxLength * hyp =
163       dynamic_cast <const StdMeshers_MaxLength * >(theHyp);
164     ASSERT(hyp);
165     _value[ BEG_LENGTH_IND ] = hyp->GetLength();
166     if ( hyp->GetUsePreestimatedLength() ) {
167       if ( int nbSeg = aMesh.GetGen()->GetBoundaryBoxSegmentation() )
168         _value[ BEG_LENGTH_IND ] = aMesh.GetShapeDiagonalSize() / nbSeg;
169     }
170     ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
171     _hypType = MAX_LENGTH;
172     aStatus = SMESH_Hypothesis::HYP_OK;
173   }
174
175   else if (hypName == "NumberOfSegments")
176   {
177     const StdMeshers_NumberOfSegments * hyp =
178       dynamic_cast <const StdMeshers_NumberOfSegments * >(theHyp);
179     ASSERT(hyp);
180     _ivalue[ NB_SEGMENTS_IND  ] = hyp->GetNumberOfSegments();
181     ASSERT( _ivalue[ NB_SEGMENTS_IND ] > 0 );
182     _ivalue[ DISTR_TYPE_IND ] = (int) hyp->GetDistrType();
183     switch (_ivalue[ DISTR_TYPE_IND ])
184     {
185     case StdMeshers_NumberOfSegments::DT_Scale:
186       _value[ SCALE_FACTOR_IND ] = hyp->GetScaleFactor();
187       _revEdgesIDs = hyp->GetReversedEdges();
188       break;
189     case StdMeshers_NumberOfSegments::DT_TabFunc:
190       _vvalue[ TAB_FUNC_IND ] = hyp->GetTableFunction();
191       _revEdgesIDs = hyp->GetReversedEdges();
192       break;
193     case StdMeshers_NumberOfSegments::DT_ExprFunc:
194       _svalue[ EXPR_FUNC_IND ] = hyp->GetExpressionFunction();
195       _revEdgesIDs = hyp->GetReversedEdges();
196       break;
197     case StdMeshers_NumberOfSegments::DT_Regular:
198       break;
199     default:
200       ASSERT(0);
201       break;
202     }
203     if (_ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_TabFunc ||
204         _ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_ExprFunc)
205         _ivalue[ CONV_MODE_IND ] = hyp->ConversionMode();
206     _hypType = NB_SEGMENTS;
207     aStatus = SMESH_Hypothesis::HYP_OK;
208   }
209
210   else if (hypName == "Arithmetic1D")
211   {
212     const StdMeshers_Arithmetic1D * hyp =
213       dynamic_cast <const StdMeshers_Arithmetic1D * >(theHyp);
214     ASSERT(hyp);
215     _value[ BEG_LENGTH_IND ] = hyp->GetLength( true );
216     _value[ END_LENGTH_IND ] = hyp->GetLength( false );
217     ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 );
218     _hypType = ARITHMETIC_1D;
219
220     _revEdgesIDs = hyp->GetReversedEdges();
221
222     aStatus = SMESH_Hypothesis::HYP_OK;
223   }
224
225   else if (hypName == "FixedPoints1D") {
226     _fpHyp = dynamic_cast <const StdMeshers_FixedPoints1D*>(theHyp);
227     ASSERT(_fpHyp);
228     _hypType = FIXED_POINTS_1D;
229
230     _revEdgesIDs = _fpHyp->GetReversedEdges();
231
232     aStatus = SMESH_Hypothesis::HYP_OK;
233   }
234
235   else if (hypName == "StartEndLength")
236   {
237     const StdMeshers_StartEndLength * hyp =
238       dynamic_cast <const StdMeshers_StartEndLength * >(theHyp);
239     ASSERT(hyp);
240     _value[ BEG_LENGTH_IND ] = hyp->GetLength( true );
241     _value[ END_LENGTH_IND ] = hyp->GetLength( false );
242     ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 );
243     _hypType = BEG_END_LENGTH;
244
245     _revEdgesIDs = hyp->GetReversedEdges();
246
247     aStatus = SMESH_Hypothesis::HYP_OK;
248   }
249
250   else if (hypName == "Deflection1D")
251   {
252     const StdMeshers_Deflection1D * hyp =
253       dynamic_cast <const StdMeshers_Deflection1D * >(theHyp);
254     ASSERT(hyp);
255     _value[ DEFLECTION_IND ] = hyp->GetDeflection();
256     ASSERT( _value[ DEFLECTION_IND ] > 0 );
257     _hypType = DEFLECTION;
258     aStatus = SMESH_Hypothesis::HYP_OK;
259   }
260
261   else if (hypName == "AutomaticLength")
262   {
263     StdMeshers_AutomaticLength * hyp = const_cast<StdMeshers_AutomaticLength *>
264       (dynamic_cast <const StdMeshers_AutomaticLength * >(theHyp));
265     ASSERT(hyp);
266     _value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
267 //     _value[ BEG_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
268 //     _value[ END_LENGTH_IND ] = Precision::Confusion(); // ?? or set to zero?
269     ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
270     _hypType = MAX_LENGTH;
271     aStatus = SMESH_Hypothesis::HYP_OK;
272   }
273   else
274     aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
275
276   return ( _hypType != NONE );
277 }
278
279 static bool computeParamByFunc(Adaptor3d_Curve& C3d, double first, double last,
280                                double length, bool theReverse,
281                                int nbSeg, Function& func,
282                                list<double>& theParams)
283 {
284   // never do this way
285   //OSD::SetSignal( true );
286
287   if (nbSeg <= 0)
288     return false;
289
290   MESSAGE( "computeParamByFunc" );
291
292   int nbPnt = 1 + nbSeg;
293   vector<double> x(nbPnt, 0.);
294
295   if (!buildDistribution(func, 0.0, 1.0, nbSeg, x, 1E-4))
296      return false;
297
298   MESSAGE( "Points:\n" );
299   char buf[1024];
300   for ( int i=0; i<=nbSeg; i++ )
301   {
302     sprintf(  buf, "%f\n", float(x[i] ) );
303     MESSAGE( buf );
304   }
305
306
307
308   // apply parameters in range [0,1] to the space of the curve
309   double prevU = first;
310   double sign = 1.;
311   if (theReverse)
312   {
313     prevU = last;
314     sign = -1.;
315   }
316   for( int i = 1; i < nbSeg; i++ )
317   {
318     double curvLength = length * (x[i] - x[i-1]) * sign;
319     GCPnts_AbscissaPoint Discret( C3d, curvLength, prevU );
320     if ( !Discret.IsDone() )
321       return false;
322     double U = Discret.Parameter();
323     if ( U > first && U < last )
324       theParams.push_back( U );
325     else
326       return false;
327     prevU = U;
328   }
329   if ( theReverse )
330     theParams.reverse();
331   return true;
332 }
333
334
335 //================================================================================
336 /*!
337  * \brief adjust internal node parameters so that the last segment length == an
338   * \param a1 - the first segment length
339   * \param an - the last segment length
340   * \param U1 - the first edge parameter
341   * \param Un - the last edge parameter
342   * \param length - the edge length
343   * \param C3d - the edge curve
344   * \param theParams - internal node parameters to adjust
345   * \param adjustNeighbors2an - to adjust length of segments next to the last one
346   *  and not to remove parameters
347  */
348 //================================================================================
349
350 static void compensateError(double a1, double an,
351                             double U1, double Un,
352                             double            length,
353                             Adaptor3d_Curve&  C3d,
354                             list<double> &    theParams,
355                             bool              adjustNeighbors2an = false)
356 {
357   int i, nPar = theParams.size();
358   if ( a1 + an < length && nPar > 1 )
359   {
360     bool reverse = ( U1 > Un );
361     GCPnts_AbscissaPoint Discret(C3d, reverse ? an : -an, Un);
362     if ( !Discret.IsDone() )
363       return;
364     double Utgt = Discret.Parameter(); // target value of the last parameter
365     list<double>::reverse_iterator itU = theParams.rbegin();
366     double Ul = *itU++; // real value of the last parameter
367     double dUn = Utgt - Ul; // parametric error of <an>
368     if ( Abs(dUn) <= Precision::Confusion() )
369       return;
370     double dU = Abs( Ul - *itU ); // parametric length of the last but one segment
371     if ( adjustNeighbors2an || Abs(dUn) < 0.5 * dU ) { // last segment is a bit shorter than it should
372       // move the last parameter to the edge beginning
373     }
374     else {  // last segment is much shorter than it should -> remove the last param and
375       theParams.pop_back(); nPar--; // move the rest points toward the edge end
376       dUn = Utgt - theParams.back();
377     }
378
379     double q  = dUn / ( nPar - 1 );
380     if ( !adjustNeighbors2an )
381     {
382       q = Abs( dUn / ( Utgt - Un )); // factor of segment length change
383       for ( itU = theParams.rbegin(), i = 1; i < nPar; i++ ) {
384         double prevU = *itU;
385         (*itU) += dUn;
386         ++itU;
387         dUn = q * (*itU - prevU) * (prevU-U1)/(Un-U1);
388       }
389     }
390     else {
391       theParams.back() += dUn;
392       double sign = reverse ? -1 : 1;
393       double prevU = theParams.back();
394       itU = theParams.rbegin();
395       for ( ++itU, i = 2; i < nPar; ++itU, i++ ) {
396         double newU = *itU + dUn;
397         if ( newU*sign < prevU*sign ) {
398           prevU = *itU = newU;
399           dUn -= q;
400         }
401         else { // set U between prevU and next valid param
402           list<double>::reverse_iterator itU2 = itU;
403           ++itU2;
404           int nb = 2;
405           while ( (*itU2)*sign > prevU*sign ) {
406             ++itU2; ++nb;
407           }
408           dU = ( *itU2 - prevU ) / nb;
409           while ( itU != itU2 ) {
410             *itU += dU; ++itU;
411           }
412           break;
413         }
414       }
415     }
416   }
417 }
418
419 //================================================================================
420 /*!
421  * \brief Class used to clean mesh on edges when 0D hyp modified.
422  * Common approach doesn't work when 0D algo is missing because the 0D hyp is
423  * considered as not participating in computation whereas it is used by 1D algo.
424  */
425 //================================================================================
426
427 // struct VertexEventListener : public SMESH_subMeshEventListener
428 // {
429 //   VertexEventListener():SMESH_subMeshEventListener(0) // won't be deleted by submesh
430 //   {}
431 //   /*!
432 //    * \brief Clean mesh on edges
433 //    * \param event - algo_event or compute_event itself (of SMESH_subMesh)
434 //    * \param eventType - ALGO_EVENT or COMPUTE_EVENT (of SMESH_subMesh)
435 //    * \param subMesh - the submesh where the event occures
436 //    */
437 //   void ProcessEvent(const int event, const int eventType, SMESH_subMesh* subMesh,
438 //                     EventListenerData*, const SMESH_Hypothesis*)
439 //   {
440 //     if ( eventType == SMESH_subMesh::ALGO_EVENT) // all algo events
441 //     {
442 //       subMesh->ComputeStateEngine( SMESH_subMesh::MODIF_ALGO_STATE );
443 //     }
444 //   }
445 // }; // struct VertexEventListener
446
447 //=============================================================================
448 /*!
449  * \brief Sets event listener to vertex submeshes
450  * \param subMesh - submesh where algo is set
451  *
452  * This method is called when a submesh gets HYP_OK algo_state.
453  * After being set, event listener is notified on each event of a submesh.
454  */
455 //=============================================================================
456
457 void StdMeshers_Regular_1D::SetEventListener(SMESH_subMesh* subMesh)
458 {
459   StdMeshers_Propagation::SetPropagationMgr( subMesh );
460 }
461
462 //=============================================================================
463 /*!
464  * \brief Do nothing
465  * \param subMesh - restored submesh
466  *
467  * This method is called only if a submesh has HYP_OK algo_state.
468  */
469 //=============================================================================
470
471 void StdMeshers_Regular_1D::SubmeshRestored(SMESH_subMesh* subMesh)
472 {
473 }
474
475 //=============================================================================
476 /*!
477  * \brief Return StdMeshers_SegmentLengthAroundVertex assigned to vertex
478  */
479 //=============================================================================
480
481 const StdMeshers_SegmentLengthAroundVertex*
482 StdMeshers_Regular_1D::getVertexHyp(SMESH_Mesh &          theMesh,
483                                     const TopoDS_Vertex & theV)
484 {
485   static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName("SegmentAroundVertex_0D"));
486   if ( const SMESH_Hypothesis * h = theMesh.GetHypothesis( theV, filter, true ))
487   {
488     SMESH_Algo* algo = const_cast< SMESH_Algo* >( static_cast< const SMESH_Algo* > ( h ));
489     const list <const SMESHDS_Hypothesis *> & hypList = algo->GetUsedHypothesis( theMesh, theV, 0 );
490     if ( !hypList.empty() && string("SegmentLengthAroundVertex") == hypList.front()->GetName() )
491       return static_cast<const StdMeshers_SegmentLengthAroundVertex*>( hypList.front() );
492   }
493   return 0;
494 }
495
496 //================================================================================
497 /*!
498  * \brief Tune parameters to fit "SegmentLengthAroundVertex" hypothesis
499   * \param theC3d - wire curve
500   * \param theLength - curve length
501   * \param theParameters - internal nodes parameters to modify
502   * \param theVf - 1st vertex
503   * \param theVl - 2nd vertex
504  */
505 //================================================================================
506
507 void StdMeshers_Regular_1D::redistributeNearVertices (SMESH_Mesh &          theMesh,
508                                                       Adaptor3d_Curve &     theC3d,
509                                                       double                theLength,
510                                                       std::list< double > & theParameters,
511                                                       const TopoDS_Vertex & theVf,
512                                                       const TopoDS_Vertex & theVl)
513 {
514   double f = theC3d.FirstParameter(), l = theC3d.LastParameter();
515   int nPar = theParameters.size();
516   for ( int isEnd1 = 0; isEnd1 < 2; ++isEnd1 )
517   {
518     const TopoDS_Vertex & V = isEnd1 ? theVf : theVl;
519     const StdMeshers_SegmentLengthAroundVertex* hyp = getVertexHyp (theMesh, V );
520     if ( hyp ) {
521       double vertexLength = hyp->GetLength();
522       if ( vertexLength > theLength / 2.0 )
523         continue;
524       if ( isEnd1 ) { // to have a segment of interest at end of theParameters
525         theParameters.reverse();
526         std::swap( f, l );
527       }
528       if ( _hypType == NB_SEGMENTS )
529       {
530         compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
531       }
532       else if ( nPar <= 3 )
533       {
534         if ( !isEnd1 )
535           vertexLength = -vertexLength;
536         GCPnts_AbscissaPoint Discret(theC3d, vertexLength, l);
537         if ( Discret.IsDone() ) {
538           if ( nPar == 0 )
539             theParameters.push_back( Discret.Parameter());
540           else {
541             double L = GCPnts_AbscissaPoint::Length( theC3d, theParameters.back(), l);
542             if ( vertexLength < L / 2.0 )
543               theParameters.push_back( Discret.Parameter());
544             else
545               compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
546           }
547         }
548       }
549       else
550       {
551         // recompute params between the last segment and a middle one.
552         // find size of a middle segment
553         int nHalf = ( nPar-1 ) / 2;
554         list< double >::reverse_iterator itU = theParameters.rbegin();
555         std::advance( itU, nHalf );
556         double Um = *itU++;
557         double Lm = GCPnts_AbscissaPoint::Length( theC3d, Um, *itU);
558         double L = GCPnts_AbscissaPoint::Length( theC3d, *itU, l);
559         StdMeshers_Regular_1D algo( *this );
560         algo._hypType = BEG_END_LENGTH;
561         algo._value[ BEG_LENGTH_IND ] = Lm;
562         algo._value[ END_LENGTH_IND ] = vertexLength;
563         double from = *itU, to = l;
564         if ( isEnd1 ) {
565           std::swap( from, to );
566           std::swap( algo._value[ BEG_LENGTH_IND ], algo._value[ END_LENGTH_IND ]);
567         }
568         list<double> params;
569         if ( algo.computeInternalParameters( theMesh, theC3d, L, from, to, params, false ))
570         {
571           if ( isEnd1 ) params.reverse();
572           while ( 1 + nHalf-- )
573             theParameters.pop_back();
574           theParameters.splice( theParameters.end(), params );
575         }
576         else
577         {
578           compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
579         }
580       }
581       if ( isEnd1 )
582         theParameters.reverse();
583     }
584   }
585 }
586
587 //=============================================================================
588 /*!
589  *  
590  */
591 //=============================================================================
592 bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh &     theMesh,
593                                                       Adaptor3d_Curve& theC3d,
594                                                       double           theLength,
595                                                       double           theFirstU,
596                                                       double           theLastU,
597                                                       list<double> &   theParams,
598                                                       const bool       theReverse,
599                                                       bool             theConsiderPropagation)
600 {
601   theParams.clear();
602
603   double f = theFirstU, l = theLastU;
604
605   switch( _hypType )
606   {
607   case LOCAL_LENGTH:
608   case MAX_LENGTH:
609   case NB_SEGMENTS: {
610
611     double eltSize = 1;
612     if ( _hypType == MAX_LENGTH )
613     {
614       double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
615       if (nbseg <= 0)
616         nbseg = 1;                        // degenerated edge
617       eltSize = theLength / nbseg;
618     }
619     else if ( _hypType == LOCAL_LENGTH )
620     {
621       // Local Length hypothesis
622       double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
623
624       // NPAL17873:
625       bool isFound = false;
626       if (theConsiderPropagation && !_mainEdge.IsNull()) // propagated from some other edge
627       {
628         // Advanced processing to assure equal number of segments in case of Propagation
629         SMESH_subMesh* sm = theMesh.GetSubMeshContaining(_mainEdge);
630         if (sm) {
631           bool computed = sm->IsMeshComputed();
632           if (!computed) {
633             if (sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) {
634               _gen->Compute( theMesh, _mainEdge, /*anUpward=*/true);
635               computed = sm->IsMeshComputed();
636             }
637           }
638           if (computed) {
639             SMESHDS_SubMesh* smds = sm->GetSubMeshDS();
640             int nb_segments = smds->NbElements();
641             if (nbseg - 1 <= nb_segments && nb_segments <= nbseg + 1) {
642               isFound = true;
643               nbseg = nb_segments;
644             }
645           }
646         }
647       }
648       if (!isFound) // not found by meshed edge in the propagation chain, use precision
649       {
650         double aPrecision = _value[ PRECISION_IND ];
651         double nbseg_prec = ceil((theLength / _value[ BEG_LENGTH_IND ]) - aPrecision);
652         if (nbseg_prec == (nbseg - 1)) nbseg--;
653       }
654
655       if (nbseg <= 0)
656         nbseg = 1;                        // degenerated edge
657       eltSize = theLength / nbseg;
658     }
659     else
660     {
661       // Number Of Segments hypothesis
662       int NbSegm = _ivalue[ NB_SEGMENTS_IND ];
663       if ( NbSegm < 1 )  return false;
664       if ( NbSegm == 1 ) return true;
665
666       switch (_ivalue[ DISTR_TYPE_IND ])
667       {
668       case StdMeshers_NumberOfSegments::DT_Scale:
669         {
670           double scale = _value[ SCALE_FACTOR_IND ];
671
672           if (fabs(scale - 1.0) < Precision::Confusion()) {
673             // special case to avoid division by zero
674             for (int i = 1; i < NbSegm; i++) {
675               double param = f + (l - f) * i / NbSegm;
676               theParams.push_back( param );
677             }
678           } else {
679             // general case of scale distribution
680             if ( theReverse )
681               scale = 1.0 / scale;
682
683             double alpha = pow(scale, 1.0 / (NbSegm - 1));
684             double factor = (l - f) / (1.0 - pow(alpha, NbSegm));
685
686             for (int i = 1; i < NbSegm; i++) {
687               double param = f + factor * (1.0 - pow(alpha, i));
688               theParams.push_back( param );
689             }
690           }
691           return true;
692         }
693         break;
694       case StdMeshers_NumberOfSegments::DT_TabFunc:
695         {
696           FunctionTable func(_vvalue[ TAB_FUNC_IND ], _ivalue[ CONV_MODE_IND ]);
697           return computeParamByFunc(theC3d, f, l, theLength, theReverse,
698                                     _ivalue[ NB_SEGMENTS_IND ], func,
699                                     theParams);
700         }
701         break;
702       case StdMeshers_NumberOfSegments::DT_ExprFunc:
703         {
704           FunctionExpr func(_svalue[ EXPR_FUNC_IND ].c_str(), _ivalue[ CONV_MODE_IND ]);
705           return computeParamByFunc(theC3d, f, l, theLength, theReverse,
706                                     _ivalue[ NB_SEGMENTS_IND ], func,
707                                     theParams);
708         }
709         break;
710       case StdMeshers_NumberOfSegments::DT_Regular:
711         eltSize = theLength / _ivalue[ NB_SEGMENTS_IND ];
712         break;
713       default:
714         return false;
715       }
716     }
717     GCPnts_UniformAbscissa Discret(theC3d, eltSize, f, l);
718     if ( !Discret.IsDone() )
719       return error( "GCPnts_UniformAbscissa failed");
720
721     int NbPoints = Discret.NbPoints();
722     for ( int i = 2; i < NbPoints; i++ )
723     {
724       double param = Discret.Parameter(i);
725       theParams.push_back( param );
726     }
727     compensateError( eltSize, eltSize, f, l, theLength, theC3d, theParams ); // for PAL9899
728     return true;
729   }
730
731   case BEG_END_LENGTH: {
732
733     // geometric progression: SUM(n) = ( a1 - an * q ) / ( 1 - q ) = theLength
734
735     double a1 = _value[ BEG_LENGTH_IND ];
736     double an = _value[ END_LENGTH_IND ];
737     double q  = ( theLength - a1 ) / ( theLength - an );
738     if ( q < theLength/1e6 || 1.01*theLength < a1 + an)
739       return error ( SMESH_Comment("Invalid segment lengths (")<<a1<<" and "<<an<<") "<<
740                      "for an edge of length "<<theLength);
741
742     double U1 = theReverse ? l : f;
743     double Un = theReverse ? f : l;
744     double param = U1;
745     double eltSize = theReverse ? -a1 : a1;
746     while ( 1 ) {
747       // computes a point on a curve <theC3d> at the distance <eltSize>
748       // from the point of parameter <param>.
749       GCPnts_AbscissaPoint Discret( theC3d, eltSize, param );
750       if ( !Discret.IsDone() ) break;
751       param = Discret.Parameter();
752       if ( f < param && param < l )
753         theParams.push_back( param );
754       else
755         break;
756       eltSize *= q;
757     }
758     compensateError( a1, an, U1, Un, theLength, theC3d, theParams );
759     if (theReverse) theParams.reverse(); // NPAL18025
760     return true;
761   }
762
763   case ARITHMETIC_1D: {
764
765     // arithmetic progression: SUM(n) = ( an - a1 + q ) * ( a1 + an ) / ( 2 * q ) = theLength
766
767     double a1 = _value[ BEG_LENGTH_IND ];
768     double an = _value[ END_LENGTH_IND ];
769     if ( 1.01*theLength < a1 + an)
770       return error ( SMESH_Comment("Invalid segment lengths (")<<a1<<" and "<<an<<") "<<
771                      "for an edge of length "<<theLength);
772
773     double  q = ( an - a1 ) / ( 2 *theLength/( a1 + an ) - 1 );
774     int n = int(fabs(q) > numeric_limits<double>::min() ? ( 1+( an-a1 )/q ) : ( 1+theLength/a1 ));
775
776     double U1 = theReverse ? l : f;
777     double Un = theReverse ? f : l;
778     double param = U1;
779     double eltSize = a1;
780     if ( theReverse ) {
781       eltSize = -eltSize;
782       q = -q;
783     }
784     while ( n-- > 0 && eltSize * ( Un - U1 ) > 0 ) {
785       // computes a point on a curve <theC3d> at the distance <eltSize>
786       // from the point of parameter <param>.
787       GCPnts_AbscissaPoint Discret( theC3d, eltSize, param );
788       if ( !Discret.IsDone() ) break;
789       param = Discret.Parameter();
790       if ( param > f && param < l )
791         theParams.push_back( param );
792       else
793         break;
794       eltSize += q;
795     }
796     compensateError( a1, an, U1, Un, theLength, theC3d, theParams );
797     if (theReverse) theParams.reverse(); // NPAL18025
798
799     return true;
800   }
801
802   case FIXED_POINTS_1D: {
803     const std::vector<double>& aPnts = _fpHyp->GetPoints();
804     const std::vector<int>& nbsegs = _fpHyp->GetNbSegments();
805     int i = 0;
806     TColStd_SequenceOfReal Params;
807     for(; i<aPnts.size(); i++) {
808       if( aPnts[i]<0.0001 || aPnts[i]>0.9999 ) continue;
809       int j=1;
810       bool IsExist = false;
811       for(; j<=Params.Length(); j++) {
812         if( fabs(aPnts[i]-Params.Value(j)) < 1e-4 ) {
813           IsExist = true;
814           break;
815         }
816         if( aPnts[i]<Params.Value(j) ) break;
817       }
818       if(!IsExist) Params.InsertBefore(j,aPnts[i]);
819     }
820     double par2, par1, lp;
821     par1 = f;
822     lp = l;
823     double sign = 1.0;
824     if(theReverse) {
825       par1 = l;
826       lp = f;
827       sign = -1.0;
828     }
829     double eltSize, segmentSize = 0.;
830     double currAbscissa = 0;
831     for(i=0; i<Params.Length(); i++) {
832       int nbseg = ( i > nbsegs.size()-1 ) ? nbsegs[0] : nbsegs[i];
833       segmentSize = Params.Value(i+1)*theLength - currAbscissa;
834       currAbscissa += segmentSize;
835       GCPnts_AbscissaPoint APnt(theC3d, sign*segmentSize, par1);
836       if( !APnt.IsDone() )
837         return error( "GCPnts_AbscissaPoint failed");
838       par2 = APnt.Parameter();
839       eltSize = segmentSize/nbseg;
840       GCPnts_UniformAbscissa Discret(theC3d, eltSize, par1, par2);
841       if(theReverse)
842         Discret.Initialize(theC3d, eltSize, par2, par1);
843       else
844         Discret.Initialize(theC3d, eltSize, par1, par2);
845       if ( !Discret.IsDone() )
846         return error( "GCPnts_UniformAbscissa failed");
847       int NbPoints = Discret.NbPoints();
848       list<double> tmpParams;
849       for(int i=2; i<NbPoints; i++) {
850         double param = Discret.Parameter(i);
851         tmpParams.push_back( param );
852       }
853       if (theReverse) {
854         compensateError( eltSize, eltSize, par2, par1, segmentSize, theC3d, tmpParams );
855         tmpParams.reverse();
856       }
857       else {
858         compensateError( eltSize, eltSize, par1, par2, segmentSize, theC3d, tmpParams );
859       }
860       list<double>::iterator itP = tmpParams.begin();
861       for(; itP != tmpParams.end(); itP++) {
862         theParams.push_back( *(itP) );
863       }
864       theParams.push_back( par2 );
865
866       par1 = par2;
867     }
868     // add for last
869     int nbseg = ( nbsegs.size() > Params.Length() ) ? nbsegs[Params.Length()] : nbsegs[0];
870     segmentSize = theLength - currAbscissa;
871     eltSize = segmentSize/nbseg;
872     GCPnts_UniformAbscissa Discret;
873     if(theReverse)
874       Discret.Initialize(theC3d, eltSize, par1, lp);
875     else
876       Discret.Initialize(theC3d, eltSize, lp, par1);
877     if ( !Discret.IsDone() )
878       return error( "GCPnts_UniformAbscissa failed");
879     int NbPoints = Discret.NbPoints();
880     list<double> tmpParams;
881     for(int i=2; i<NbPoints; i++) {
882       double param = Discret.Parameter(i);
883       tmpParams.push_back( param );
884     }
885     if (theReverse) {
886       compensateError( eltSize, eltSize, lp, par1, segmentSize, theC3d, tmpParams );
887       tmpParams.reverse();
888     }
889     else {
890       compensateError( eltSize, eltSize, par1, lp, segmentSize, theC3d, tmpParams );
891     }
892     list<double>::iterator itP = tmpParams.begin();
893     for(; itP != tmpParams.end(); itP++) {
894       theParams.push_back( *(itP) );
895     }
896
897     if (theReverse) {
898       theParams.reverse(); // NPAL18025
899     }
900     return true;
901   }
902
903   case DEFLECTION: {
904
905     GCPnts_UniformDeflection Discret(theC3d, _value[ DEFLECTION_IND ], f, l, true);
906     if ( !Discret.IsDone() )
907       return false;
908
909     int NbPoints = Discret.NbPoints();
910     for ( int i = 2; i < NbPoints; i++ )
911     {
912       double param = Discret.Parameter(i);
913       theParams.push_back( param );
914     }
915     return true;
916   }
917
918   default:;
919   }
920
921   return false;
922 }
923
924 //=============================================================================
925 /*!
926  *  
927  */
928 //=============================================================================
929
930 bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & theShape)
931 {
932   if ( _hypType == NONE )
933     return false;
934
935   SMESHDS_Mesh * meshDS = theMesh.GetMeshDS();
936
937   const TopoDS_Edge & EE = TopoDS::Edge(theShape);
938   TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
939   int shapeID = meshDS->ShapeToIndex( E );
940
941   double f, l;
942   Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
943
944   TopoDS_Vertex VFirst, VLast;
945   TopExp::Vertices(E, VFirst, VLast);   // Vfirst corresponds to f and Vlast to l
946
947   ASSERT(!VFirst.IsNull());
948   ASSERT(!VLast.IsNull());
949   const SMDS_MeshNode * idFirst = SMESH_Algo::VertexNode( VFirst, meshDS );
950   const SMDS_MeshNode * idLast = SMESH_Algo::VertexNode( VLast, meshDS );
951   if (!idFirst || !idLast)
952     return error( COMPERR_BAD_INPUT_MESH, "No node on vertex");
953
954   // remove elements created by e.g. patern mapping (PAL21999)
955   // CLEAN event is incorrectly ptopagated seemingly due to Propagation hyp
956   // so TEMPORARY solution is to clean the submesh manually
957   //theMesh.GetSubMesh(theShape)->ComputeStateEngine( SMESH_subMesh::CLEAN );
958   if (SMESHDS_SubMesh * subMeshDS = meshDS->MeshElements(theShape))
959   {
960     SMDS_ElemIteratorPtr ite = subMeshDS->GetElements();
961     while (ite->more())
962       meshDS->RemoveFreeElement(ite->next(), subMeshDS);
963     SMDS_NodeIteratorPtr itn = subMeshDS->GetNodes();
964     while (itn->more()) {
965       const SMDS_MeshNode * node = itn->next();
966       if ( node->NbInverseElements() == 0 )
967         meshDS->RemoveFreeNode(node, subMeshDS);
968       else
969         meshDS->RemoveNode(node);
970     }
971   }
972
973   if (!Curve.IsNull())
974   {
975     list< double > params;
976     bool reversed = false;
977     if ( theMesh.GetShapeToMesh().ShapeType() >= TopAbs_WIRE ) {
978       reversed = ( EE.Orientation() == TopAbs_REVERSED );
979     }
980     if ( !_mainEdge.IsNull() ) {
981       reversed = ( _mainEdge.Orientation() == TopAbs_REVERSED );
982     }
983     else if ( _revEdgesIDs.size() > 0 ) {
984       for ( int i = 0; i < _revEdgesIDs.size(); i++) {
985         if ( _revEdgesIDs[i] == shapeID ) {
986           reversed = !reversed;
987         }
988       }
989     }
990
991     BRepAdaptor_Curve C3d( E );
992     double length = EdgeLength( E );
993     if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, reversed, true )) {
994       return false;
995     }
996     redistributeNearVertices( theMesh, C3d, length, params, VFirst, VLast );
997
998     // edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex)
999     // only internal nodes receive an edge position with param on curve
1000
1001     const SMDS_MeshNode * idPrev = idFirst;
1002     double parPrev = f;
1003     double parLast = l;
1004
1005     /* NPAL18025
1006     if (reversed) {
1007       idPrev = idLast;
1008       idLast = idFirst;
1009       idFirst = idPrev;
1010       parPrev = l;
1011       parLast = f;
1012     }
1013     */
1014     for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++) {
1015       double param = *itU;
1016       gp_Pnt P = Curve->Value(param);
1017
1018       //Add the Node in the DataStructure
1019       SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
1020       meshDS->SetNodeOnEdge(node, shapeID, param);
1021
1022       if(_quadraticMesh) {
1023         // create medium node
1024         double prm = ( parPrev + param )/2;
1025         gp_Pnt PM = Curve->Value(prm);
1026         SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
1027         meshDS->SetNodeOnEdge(NM, shapeID, prm);
1028         SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node, NM);
1029         meshDS->SetMeshElementOnShape(edge, shapeID);
1030       }
1031       else {
1032         SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
1033         meshDS->SetMeshElementOnShape(edge, shapeID);
1034       }
1035
1036       idPrev = node;
1037       parPrev = param;
1038     }
1039     if(_quadraticMesh) {
1040       double prm = ( parPrev + parLast )/2;
1041       gp_Pnt PM = Curve->Value(prm);
1042       SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
1043       meshDS->SetNodeOnEdge(NM, shapeID, prm);
1044       SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast, NM);
1045       meshDS->SetMeshElementOnShape(edge, shapeID);
1046     }
1047     else {
1048       SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast);
1049       meshDS->SetMeshElementOnShape(edge, shapeID);
1050     }
1051   }
1052   else
1053   {
1054     //MESSAGE("************* Degenerated edge! *****************");
1055
1056     // Edge is a degenerated Edge : We put n = 5 points on the edge.
1057     const int NbPoints = 5;
1058     BRep_Tool::Range( E, f, l ); // PAL15185
1059     double du = (l - f) / (NbPoints - 1);
1060
1061     gp_Pnt P = BRep_Tool::Pnt(VFirst);
1062
1063     const SMDS_MeshNode * idPrev = idFirst;
1064     for (int i = 2; i < NbPoints; i++) {
1065       double param = f + (i - 1) * du;
1066       SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
1067       if(_quadraticMesh) {
1068         // create medium node
1069         double prm = param - du/2.;
1070         SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z());
1071         meshDS->SetNodeOnEdge(NM, shapeID, prm);
1072         SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node, NM);
1073         meshDS->SetMeshElementOnShape(edge, shapeID);
1074       }
1075       else {
1076         SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
1077         meshDS->SetMeshElementOnShape(edge, shapeID);
1078       }
1079       meshDS->SetNodeOnEdge(node, shapeID, param);
1080       idPrev = node;
1081     }
1082     if(_quadraticMesh) {
1083       // create medium node
1084       double prm = l - du/2.;
1085       SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z());
1086       meshDS->SetNodeOnEdge(NM, shapeID, prm);
1087       SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast, NM);
1088       meshDS->SetMeshElementOnShape(edge, shapeID);
1089     }
1090     else {
1091       SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast);
1092       meshDS->SetMeshElementOnShape(edge, shapeID);
1093     }
1094   }
1095   return true;
1096 }
1097
1098
1099 //=============================================================================
1100 /*!
1101  *  
1102  */
1103 //=============================================================================
1104
1105 bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh,
1106                                      const TopoDS_Shape & theShape,
1107                                      MapShapeNbElems& aResMap)
1108 {
1109   if ( _hypType == NONE )
1110     return false;
1111
1112   //SMESHDS_Mesh * meshDS = theMesh.GetMeshDS();
1113
1114   const TopoDS_Edge & EE = TopoDS::Edge(theShape);
1115   TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
1116   //  int shapeID = meshDS->ShapeToIndex( E );
1117
1118   double f, l;
1119   Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
1120
1121   TopoDS_Vertex VFirst, VLast;
1122   TopExp::Vertices(E, VFirst, VLast);   // Vfirst corresponds to f and Vlast to l
1123
1124   ASSERT(!VFirst.IsNull());
1125   ASSERT(!VLast.IsNull());
1126
1127   std::vector<int> aVec(SMDSEntity_Last,0);
1128
1129   if (!Curve.IsNull()) {
1130     list< double > params;
1131
1132     BRepAdaptor_Curve C3d( E );
1133     double length = EdgeLength( E );
1134     if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, false, true )) {
1135       SMESH_subMesh * sm = theMesh.GetSubMesh(theShape);
1136       aResMap.insert(std::make_pair(sm,aVec));
1137       SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
1138       smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
1139       return false;
1140     }
1141     redistributeNearVertices( theMesh, C3d, length, params, VFirst, VLast );
1142
1143     if(_quadraticMesh) {
1144       aVec[SMDSEntity_Node] = 2*params.size() + 1;
1145       aVec[SMDSEntity_Quad_Edge] = params.size() + 1;
1146     }
1147     else {
1148       aVec[SMDSEntity_Node] = params.size();
1149       aVec[SMDSEntity_Edge] = params.size() + 1;
1150     }
1151     
1152   }
1153   else {
1154     //MESSAGE("************* Degenerated edge! *****************");
1155     // Edge is a degenerated Edge : We put n = 5 points on the edge.
1156     if(_quadraticMesh) {
1157       aVec[SMDSEntity_Node] = 11;
1158       aVec[SMDSEntity_Quad_Edge] = 6;
1159     }
1160     else {
1161       aVec[SMDSEntity_Node] = 5;
1162       aVec[SMDSEntity_Edge] = 6;
1163     }
1164   }
1165
1166   SMESH_subMesh * sm = theMesh.GetSubMesh(theShape);
1167   aResMap.insert(std::make_pair(sm,aVec));
1168
1169   return true;
1170 }
1171
1172
1173 //=============================================================================
1174 /*!
1175  *  See comments in SMESH_Algo.cxx
1176  */
1177 //=============================================================================
1178
1179 const list <const SMESHDS_Hypothesis *> &
1180 StdMeshers_Regular_1D::GetUsedHypothesis(SMESH_Mesh &         aMesh,
1181                                          const TopoDS_Shape & aShape,
1182                                          const bool           ignoreAuxiliary)
1183 {
1184   _usedHypList.clear();
1185   _mainEdge.Nullify();
1186
1187   SMESH_HypoFilter auxiliaryFilter, compatibleFilter;
1188   auxiliaryFilter.Init( SMESH_HypoFilter::IsAuxiliary() );
1189   const bool ignoreAux = true;
1190   InitCompatibleHypoFilter( compatibleFilter, ignoreAux );
1191
1192   // get non-auxiliary assigned to aShape
1193   int nbHyp = aMesh.GetHypotheses( aShape, compatibleFilter, _usedHypList, false );
1194
1195   if (nbHyp == 0 && aShape.ShapeType() == TopAbs_EDGE)
1196   {
1197     // Check, if propagated from some other edge
1198     _mainEdge = StdMeshers_Propagation::GetPropagationSource( aMesh, aShape );
1199     if ( !_mainEdge.IsNull() )
1200     {
1201       // Propagation of 1D hypothesis from <aMainEdge> on this edge;
1202       // get non-auxiliary assigned to _mainEdge
1203       nbHyp = aMesh.GetHypotheses( _mainEdge, compatibleFilter, _usedHypList, true );
1204     }
1205   }
1206
1207   if (nbHyp == 0) // nothing propagated nor assigned to aShape
1208   {
1209     SMESH_Algo::GetUsedHypothesis( aMesh, aShape, ignoreAuxiliary );
1210     nbHyp = _usedHypList.size();
1211   }
1212   else
1213   {
1214     // get auxiliary hyps from aShape
1215     aMesh.GetHypotheses( aShape, auxiliaryFilter, _usedHypList, true );
1216   }
1217   if ( nbHyp > 1 && ignoreAuxiliary )
1218     _usedHypList.clear(); //only one compatible non-auxiliary hypothesis allowed
1219
1220   return _usedHypList;
1221 }