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