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