]> SALOME platform Git repositories - modules/smesh.git/blob - src/StdMeshers/StdMeshers_Regular_1D.cxx
Salome HOME
d3d92f9ea20d8a66a327c83c04ee3208f5623fbc
[modules/smesh.git] / src / StdMeshers / StdMeshers_Regular_1D.cxx
1 //  SMESH SMESH : implementaion of SMESH idl descriptions
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : StdMeshers_Regular_1D.cxx
25 //           Moved here from SMESH_Regular_1D.cxx
26 //  Author : Paul RASCLE, EDF
27 //  Module : SMESH
28 //  $Header$
29
30 using namespace std;
31
32 #include "StdMeshers_Regular_1D.hxx"
33 #include "StdMeshers_Distribution.hxx"
34 #include "SMESH_Gen.hxx"
35 #include "SMESH_Mesh.hxx"
36 #include "SMESH_HypoFilter.hxx"
37 #include "SMESH_subMesh.hxx"
38
39 #include <OSD.hxx>
40
41 #include "StdMeshers_LocalLength.hxx"
42 #include "StdMeshers_NumberOfSegments.hxx"
43 #include "StdMeshers_Arithmetic1D.hxx"
44 #include "StdMeshers_StartEndLength.hxx"
45 #include "StdMeshers_Deflection1D.hxx"
46 #include "StdMeshers_AutomaticLength.hxx"
47
48 #include "SMDS_MeshElement.hxx"
49 #include "SMDS_MeshNode.hxx"
50 #include "SMDS_EdgePosition.hxx"
51
52 #include "Utils_SALOME_Exception.hxx"
53 #include "utilities.h"
54
55 #include <BRep_Tool.hxx>
56 #include <TopoDS_Edge.hxx>
57 #include <TopoDS_Shape.hxx>
58 #include <TopTools_ListIteratorOfListOfShape.hxx>
59 #include <GeomAdaptor_Curve.hxx>
60 #include <GCPnts_AbscissaPoint.hxx>
61 #include <GCPnts_UniformAbscissa.hxx>
62 #include <GCPnts_UniformDeflection.hxx>
63 #include <Standard_ErrorHandler.hxx>
64 #include <Precision.hxx>
65 #include <Expr_GeneralExpression.hxx>
66 #include <Expr_NamedUnknown.hxx>
67 #include <Expr_Array1OfNamedUnknown.hxx>
68 #include <TColStd_Array1OfReal.hxx>
69 #include <ExprIntrp_GenExp.hxx>
70
71 #include <string>
72 #include <math.h>
73
74 //=============================================================================
75 /*!
76  *  
77  */
78 //=============================================================================
79
80 StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId, int studyId,
81         SMESH_Gen * gen):SMESH_1D_Algo(hypId, studyId, gen)
82 {
83         MESSAGE("StdMeshers_Regular_1D::StdMeshers_Regular_1D");
84         _name = "Regular_1D";
85         _shapeType = (1 << TopAbs_EDGE);
86
87         _compatibleHypothesis.push_back("LocalLength");
88         _compatibleHypothesis.push_back("NumberOfSegments");
89         _compatibleHypothesis.push_back("StartEndLength");
90         _compatibleHypothesis.push_back("Deflection1D");
91         _compatibleHypothesis.push_back("Arithmetic1D");
92         _compatibleHypothesis.push_back("AutomaticLength");
93 }
94
95 //=============================================================================
96 /*!
97  *  
98  */
99 //=============================================================================
100
101 StdMeshers_Regular_1D::~StdMeshers_Regular_1D()
102 {
103 }
104
105 //=============================================================================
106 /*!
107  *  
108  */
109 //=============================================================================
110
111 bool StdMeshers_Regular_1D::CheckHypothesis
112                          (SMESH_Mesh& aMesh,
113                           const TopoDS_Shape& aShape,
114                           SMESH_Hypothesis::Hypothesis_Status& aStatus)
115 {
116   _hypType = NONE;
117
118   const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
119   if (hyps.size() == 0)
120   {
121     aStatus = SMESH_Hypothesis::HYP_MISSING;
122     return false;  // can't work without a hypothesis
123   }
124
125   // use only the first hypothesis
126   const SMESHDS_Hypothesis *theHyp = hyps.front();
127
128   string hypName = theHyp->GetName();
129
130   if (hypName == "LocalLength")
131   {
132     const StdMeshers_LocalLength * hyp =
133       dynamic_cast <const StdMeshers_LocalLength * >(theHyp);
134     ASSERT(hyp);
135     _value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength();
136     ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
137     _hypType = LOCAL_LENGTH;
138     aStatus = SMESH_Hypothesis::HYP_OK;
139   }
140
141   else if (hypName == "NumberOfSegments")
142   {
143     const StdMeshers_NumberOfSegments * hyp =
144       dynamic_cast <const StdMeshers_NumberOfSegments * >(theHyp);
145     ASSERT(hyp);
146     _ivalue[ NB_SEGMENTS_IND  ] = hyp->GetNumberOfSegments();
147     ASSERT( _ivalue[ NB_SEGMENTS_IND ] > 0 );
148     _ivalue[ DISTR_TYPE_IND ] = (int) hyp->GetDistrType();
149     switch (_ivalue[ DISTR_TYPE_IND ])
150     {
151     case StdMeshers_NumberOfSegments::DT_Scale:
152       _value[ SCALE_FACTOR_IND ] = hyp->GetScaleFactor();
153       break;
154     case StdMeshers_NumberOfSegments::DT_TabFunc:
155       _vvalue[ TAB_FUNC_IND ] = hyp->GetTableFunction();
156       break;
157     case StdMeshers_NumberOfSegments::DT_ExprFunc:
158       _svalue[ EXPR_FUNC_IND ] = hyp->GetExpressionFunction();
159       break;
160     case StdMeshers_NumberOfSegments::DT_Regular:
161       break;
162     default:
163       ASSERT(0);
164       break;
165     }
166     if (_ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_TabFunc ||
167         _ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_ExprFunc)
168         _ivalue[ CONV_MODE_IND ] = hyp->ConversionMode();
169     _hypType = NB_SEGMENTS;
170     aStatus = SMESH_Hypothesis::HYP_OK;
171   }
172
173   else if (hypName == "Arithmetic1D")
174   {
175     const StdMeshers_Arithmetic1D * hyp =
176       dynamic_cast <const StdMeshers_Arithmetic1D * >(theHyp);
177     ASSERT(hyp);
178     _value[ BEG_LENGTH_IND ] = hyp->GetLength( true );
179     _value[ END_LENGTH_IND ] = hyp->GetLength( false );
180     ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 );
181     _hypType = ARITHMETIC_1D;
182     aStatus = SMESH_Hypothesis::HYP_OK;
183   }
184
185   else if (hypName == "StartEndLength")
186   {
187     const StdMeshers_StartEndLength * hyp =
188       dynamic_cast <const StdMeshers_StartEndLength * >(theHyp);
189     ASSERT(hyp);
190     _value[ BEG_LENGTH_IND ] = hyp->GetLength( true );
191     _value[ END_LENGTH_IND ] = hyp->GetLength( false );
192     ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 );
193     _hypType = BEG_END_LENGTH;
194     aStatus = SMESH_Hypothesis::HYP_OK;
195   }
196
197   else if (hypName == "Deflection1D")
198   {
199     const StdMeshers_Deflection1D * hyp =
200       dynamic_cast <const StdMeshers_Deflection1D * >(theHyp);
201     ASSERT(hyp);
202     _value[ DEFLECTION_IND ] = hyp->GetDeflection();
203     ASSERT( _value[ DEFLECTION_IND ] > 0 );
204     _hypType = DEFLECTION;
205     aStatus = SMESH_Hypothesis::HYP_OK;
206   }
207
208   else if (hypName == "AutomaticLength")
209   {
210     StdMeshers_AutomaticLength * hyp = const_cast<StdMeshers_AutomaticLength *>
211       (dynamic_cast <const StdMeshers_AutomaticLength * >(theHyp));
212     ASSERT(hyp);
213     _value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
214     ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
215     _hypType = LOCAL_LENGTH;
216     aStatus = SMESH_Hypothesis::HYP_OK;
217   }
218   else
219     aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
220
221   return ( _hypType != NONE );
222 }
223
224 //=======================================================================
225 //function : compensateError
226 //purpose  : adjust theParams so that the last segment length == an
227 //=======================================================================
228
229 static void compensateError(double a1, double an,
230                             double U1, double Un,
231                             double             length,
232                             GeomAdaptor_Curve& C3d,
233                             list<double> &     theParams)
234 {
235   int i, nPar = theParams.size();
236   if ( a1 + an < length && nPar > 1 )
237   {
238     list<double>::reverse_iterator itU = theParams.rbegin();
239     double Ul = *itU++;
240     // dist from the last point to the edge end <Un>, it should be equal <an>
241     double Ln = GCPnts_AbscissaPoint::Length( C3d, Ul, Un );
242     double dLn = an - Ln; // error of <an>
243     if ( Abs( dLn ) <= Precision::Confusion() )
244       return;
245     double dU = Abs( Ul - *itU ); // parametric length of the last but one segment
246     double dUn = dLn * Abs( Un - U1 ) / length; // parametric error of <an>
247     if ( dUn < 0.5 * dU ) { // last segment is a bit shorter than it should
248       dUn = -dUn; // move the last parameter to the edge beginning
249     }
250     else {  // last segment is much shorter than it should -> remove the last param and
251       theParams.pop_back(); nPar--; // move the rest points toward the edge end
252       Ln = GCPnts_AbscissaPoint::Length( C3d, theParams.back(), Un );
253       dUn = ( an - Ln ) * Abs( Un - U1 ) / length;
254       if ( dUn < 0.5 * dU )
255         dUn = -dUn;
256     }
257     if ( U1 > Un )
258       dUn = -dUn;
259     double q  = dUn / ( nPar - 1 );
260     for ( itU = theParams.rbegin(), i = 1; i < nPar; itU++, i++ ) {
261       (*itU) += dUn;
262       dUn -= q;
263     }
264   }
265 }
266
267 static bool computeParamByFunc(Adaptor3d_Curve& C3d, double first, double last,
268                                double length, bool theReverse, 
269                                int nbSeg, Function& func,
270                                list<double>& theParams)
271 {
272   OSD::SetSignal( true );
273
274   if( nbSeg<=0 )
275     return false;
276
277   MESSAGE( "computeParamByFunc" );
278
279   int nbPnt = 1 + nbSeg;
280   vector<double> x(nbPnt, 0.);
281
282   if( !buildDistribution( func, 0.0, 1.0, nbSeg, x, 1E-4 ) )
283      return false;
284
285   MESSAGE( "Points:\n" );
286   char buf[1024];
287   for( int i=0; i<=nbSeg; i++ )
288   {
289     sprintf(  buf, "%f\n", float(x[i] ) );
290     MESSAGE( buf );
291   }
292     
293
294
295   // apply parameters in range [0,1] to the space of the curve
296   double prevU = first;
297   double sign = 1.;
298   if (theReverse)
299   {
300     prevU = last;
301     sign = -1.;
302   }
303   for( int i = 1; i < nbSeg; i++ )
304   {
305     double curvLength = length * (x[i] - x[i-1]) * sign;
306     GCPnts_AbscissaPoint Discret( C3d, curvLength, prevU );
307     if ( !Discret.IsDone() )
308       return false;
309     double U = Discret.Parameter();
310     if ( U > first && U < last )
311       theParams.push_back( U );
312     else
313       return false;
314     prevU = U;
315   }
316   return true;
317 }
318
319 //=============================================================================
320 /*!
321  *  
322  */
323 //=============================================================================
324 bool StdMeshers_Regular_1D::computeInternalParameters(const TopoDS_Edge& theEdge,
325                                                       list<double> &     theParams,
326                                                       const bool         theReverse) const
327 {
328   theParams.clear();
329
330   double f, l;
331   Handle(Geom_Curve) Curve = BRep_Tool::Curve(theEdge, f, l);
332   GeomAdaptor_Curve C3d(Curve);
333
334   double length = EdgeLength(theEdge);
335
336   switch( _hypType )
337   {
338   case LOCAL_LENGTH:
339   case NB_SEGMENTS: {
340
341     double eltSize = 1;
342     if ( _hypType == LOCAL_LENGTH )
343     {
344       // Local Length hypothesis
345       double nbseg = ceil(length / _value[ BEG_LENGTH_IND ]); // integer sup
346       if (nbseg <= 0)
347         nbseg = 1;                        // degenerated edge
348       eltSize = length / nbseg;
349     }
350     else
351     {
352       // Number Of Segments hypothesis
353       switch (_ivalue[ DISTR_TYPE_IND ])
354       {
355       case StdMeshers_NumberOfSegments::DT_Scale:
356         {
357           double scale = _value[ SCALE_FACTOR_IND ];
358           if ( theReverse )
359             scale = 1. / scale;
360           double alpha = pow( scale , 1.0 / (_ivalue[ NB_SEGMENTS_IND ] - 1));
361           double factor = (l - f) / (1 - pow( alpha,_ivalue[ NB_SEGMENTS_IND ]));
362
363           int i, NbPoints = 1 + _ivalue[ NB_SEGMENTS_IND ];
364           for ( i = 2; i < NbPoints; i++ )
365           {
366             double param = f + factor * (1 - pow(alpha, i - 1));
367             theParams.push_back( param );
368           }
369           return true;
370         }
371         break;
372       case StdMeshers_NumberOfSegments::DT_TabFunc:
373         {
374           FunctionTable func(_vvalue[ TAB_FUNC_IND ], _ivalue[ CONV_MODE_IND ]);
375           return computeParamByFunc(C3d, f, l, length, theReverse,
376                                     _ivalue[ NB_SEGMENTS_IND ], func,
377                                     theParams);
378         }
379         break;
380       case StdMeshers_NumberOfSegments::DT_ExprFunc:
381         {
382           FunctionExpr func(_svalue[ EXPR_FUNC_IND ].c_str(), _ivalue[ CONV_MODE_IND ]);
383           return computeParamByFunc(C3d, f, l, length, theReverse,
384                                     _ivalue[ NB_SEGMENTS_IND ], func,
385                                     theParams);
386         }
387         break;
388       case StdMeshers_NumberOfSegments::DT_Regular:
389         eltSize = length / _ivalue[ NB_SEGMENTS_IND ];
390         break;
391       default:
392         return false;
393       }
394     }
395
396     GCPnts_UniformAbscissa Discret(C3d, eltSize, f, l);
397     if ( !Discret.IsDone() )
398       return false;
399
400     int NbPoints = Discret.NbPoints();
401     for ( int i = 2; i < NbPoints; i++ )
402     {
403       double param = Discret.Parameter(i);
404       theParams.push_back( param );
405     }
406     compensateError( eltSize, eltSize, f, l, length, C3d, theParams ); // for PAL9899
407     return true;
408   }
409
410   case BEG_END_LENGTH: {
411
412     // geometric progression: SUM(n) = ( a1 - an * q ) / ( 1 - q ) = length
413
414     double a1 = _value[ BEG_LENGTH_IND ];
415     double an = _value[ END_LENGTH_IND ];
416     double q  = ( length - a1 ) / ( length - an );
417
418     double U1 = theReverse ? l : f;
419     double Un = theReverse ? f : l;
420     double param = U1;
421     double eltSize = theReverse ? -a1 : a1;
422     while ( 1 ) {
423       // computes a point on a curve <C3d> at the distance <eltSize>
424       // from the point of parameter <param>.
425       GCPnts_AbscissaPoint Discret( C3d, eltSize, param );
426       if ( !Discret.IsDone() ) break;
427       param = Discret.Parameter();
428       if ( param > f && param < l )
429         theParams.push_back( param );
430       else
431         break;
432       eltSize *= q;
433     }
434     compensateError( a1, an, U1, Un, length, C3d, theParams );
435     return true;
436   }
437
438   case ARITHMETIC_1D: {
439
440     // arithmetic progression: SUM(n) = ( an - a1 + q ) * ( a1 + an ) / ( 2 * q ) = length
441
442     double a1 = _value[ BEG_LENGTH_IND ];
443     double an = _value[ END_LENGTH_IND ];
444
445     double  q = ( an - a1 ) / ( 2 *length/( a1 + an ) - 1 );
446     int     n = int( 1 + ( an - a1 ) / q );
447
448     double U1 = theReverse ? l : f;
449     double Un = theReverse ? f : l;
450     double param = U1;
451     double eltSize = a1;
452     if ( theReverse ) {
453       eltSize = -eltSize;
454       q = -q;
455     }
456     while ( n-- > 0 && eltSize * ( Un - U1 ) > 0 ) {
457       // computes a point on a curve <C3d> at the distance <eltSize>
458       // from the point of parameter <param>.
459       GCPnts_AbscissaPoint Discret( C3d, eltSize, param );
460       if ( !Discret.IsDone() ) break;
461       param = Discret.Parameter();
462       if ( param > f && param < l )
463         theParams.push_back( param );
464       else
465         break;
466       eltSize += q;
467     }
468     compensateError( a1, an, U1, Un, length, C3d, theParams );
469
470     return true;
471   }
472
473   case DEFLECTION: {
474
475     GCPnts_UniformDeflection Discret(C3d, _value[ DEFLECTION_IND ], true);
476     if ( !Discret.IsDone() )
477       return false;
478
479     int NbPoints = Discret.NbPoints();
480     for ( int i = 2; i < NbPoints; i++ )
481     {
482       double param = Discret.Parameter(i);
483       theParams.push_back( param );
484     }
485     return true;
486     
487   }
488
489   default:;
490   }
491
492   return false;
493 }
494
495 //=============================================================================
496 /*!
497  *  
498  */
499 //=============================================================================
500
501 bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
502 {
503   MESSAGE("StdMeshers_Regular_1D::Compute");
504
505   if ( _hypType == NONE )
506     return false;
507
508   SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
509   aMesh.GetSubMesh(aShape);
510
511   // quardatic mesh required?
512   SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "QuadraticMesh" ));
513   bool isQuadraticMesh = aMesh->GetHypothesis( aShape, filter, true );
514
515   const TopoDS_Edge & EE = TopoDS::Edge(aShape);
516   TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
517   int shapeID = meshDS->ShapeToIndex( E );
518
519   double f, l;
520   Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
521
522   TopoDS_Vertex VFirst, VLast;
523   TopExp::Vertices(E, VFirst, VLast);   // Vfirst corresponds to f and Vlast to l
524
525   ASSERT(!VFirst.IsNull());
526   SMDS_NodeIteratorPtr lid= aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
527   if (!lid->more())
528   {
529     MESSAGE (" NO NODE BUILT ON VERTEX ");
530     return false;
531   }
532   const SMDS_MeshNode * idFirst = lid->next();
533
534   ASSERT(!VLast.IsNull());
535   lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
536   if (!lid->more())
537   {
538     MESSAGE (" NO NODE BUILT ON VERTEX ");
539     return false;
540   }
541   const SMDS_MeshNode * idLast = lid->next();
542
543   if (!Curve.IsNull())
544   {
545     list< double > params;
546     bool reversed = false;
547     if ( !_mainEdge.IsNull() )
548       reversed = aMesh.IsReversedInChain( EE, _mainEdge );
549     try {
550       if ( ! computeInternalParameters( E, params, reversed ))
551         return false;
552     }
553     catch ( Standard_Failure ) {
554       return false;
555     }
556
557     // edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex)
558     // only internal nodes receive an edge position with param on curve
559
560     const SMDS_MeshNode * idPrev = idFirst;
561     
562     for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++)
563     {
564       double param = *itU;
565       gp_Pnt P = Curve->Value(param);
566
567       //Add the Node in the DataStructure
568       SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
569       meshDS->SetNodeOnEdge(node, shapeID, param);
570
571       SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
572       meshDS->SetMeshElementOnShape(edge, shapeID);
573       idPrev = node;
574     }
575     SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast);
576     meshDS->SetMeshElementOnShape(edge, shapeID);
577   }
578   else
579   {
580     // Edge is a degenerated Edge : We put n = 5 points on the edge.
581     int NbPoints = 5;
582     BRep_Tool::Range(E, f, l);
583     double du = (l - f) / (NbPoints - 1);
584     //MESSAGE("************* Degenerated edge! *****************");
585
586     TopoDS_Vertex V1, V2;
587     TopExp::Vertices(E, V1, V2);
588     gp_Pnt P = BRep_Tool::Pnt(V1);
589
590     const SMDS_MeshNode * idPrev = idFirst;
591     for (int i = 2; i < NbPoints; i++)
592     {
593       double param = f + (i - 1) * du;
594       SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
595       meshDS->SetNodeOnEdge(node, shapeID, param);
596
597       SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
598       meshDS->SetMeshElementOnShape(edge, shapeID);
599       idPrev = node;
600     }
601     SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast);
602     meshDS->SetMeshElementOnShape(edge, shapeID);
603   }
604   return true;
605 }
606
607 //=============================================================================
608 /*!
609  *  See comments in SMESH_Algo.cxx
610  */
611 //=============================================================================
612
613 const list <const SMESHDS_Hypothesis *> & StdMeshers_Regular_1D::GetUsedHypothesis(
614         SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
615 {
616   _usedHypList.clear();
617   _usedHypList = GetAppliedHypothesis(aMesh, aShape);   // copy
618   int nbHyp = _usedHypList.size();
619   _mainEdge.Nullify();
620   if (nbHyp == 0)
621   {
622     // Check, if propagated from some other edge
623     if (aShape.ShapeType() == TopAbs_EDGE &&
624         aMesh.IsPropagatedHypothesis(aShape, _mainEdge))
625     {
626       // Propagation of 1D hypothesis from <aMainEdge> on this edge
627       //_usedHypList = GetAppliedHypothesis(aMesh, _mainEdge);  // copy
628       // use a general method in order not to nullify _mainEdge
629       _usedHypList = SMESH_Algo::GetUsedHypothesis(aMesh, _mainEdge);   // copy
630       nbHyp = _usedHypList.size();
631     }
632   }
633   if (nbHyp == 0)
634   {
635     TopTools_ListIteratorOfListOfShape ancIt( aMesh.GetAncestors( aShape ));
636     for (; ancIt.More(); ancIt.Next())
637     {
638       const TopoDS_Shape& ancestor = ancIt.Value();
639       _usedHypList = GetAppliedHypothesis(aMesh, ancestor);     // copy
640       nbHyp = _usedHypList.size();
641       if (nbHyp == 1)
642         break;
643     }
644   }
645   if (nbHyp > 1)
646     _usedHypList.clear();       //only one compatible hypothesis allowed
647   return _usedHypList;
648 }
649
650 //=============================================================================
651 /*!
652  *  
653  */
654 //=============================================================================
655
656 ostream & StdMeshers_Regular_1D::SaveTo(ostream & save)
657 {
658   return save;
659 }
660
661 //=============================================================================
662 /*!
663  *  
664  */
665 //=============================================================================
666
667 istream & StdMeshers_Regular_1D::LoadFrom(istream & load)
668 {
669   return load;
670 }
671
672 //=============================================================================
673 /*!
674  *  
675  */
676 //=============================================================================
677
678 ostream & operator <<(ostream & save, StdMeshers_Regular_1D & hyp)
679 {
680   return hyp.SaveTo( save );
681 }
682
683 //=============================================================================
684 /*!
685  *  
686  */
687 //=============================================================================
688
689 istream & operator >>(istream & load, StdMeshers_Regular_1D & hyp)
690 {
691   return hyp.LoadFrom( load );
692 }