1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : StdMeshers_Regular_1D.cxx
24 // Moved here from SMESH_Regular_1D.cxx
25 // Author : Paul RASCLE, EDF
28 #include "StdMeshers_Regular_1D.hxx"
30 #include "SMDS_MeshElement.hxx"
31 #include "SMDS_MeshNode.hxx"
32 #include "SMESHDS_Mesh.hxx"
33 #include "SMESH_Comment.hxx"
34 #include "SMESH_Gen.hxx"
35 #include "SMESH_HypoFilter.hxx"
36 #include "SMESH_Mesh.hxx"
37 #include "SMESH_subMesh.hxx"
38 #include "SMESH_subMeshEventListener.hxx"
39 #include "StdMeshers_Adaptive1D.hxx"
40 #include "StdMeshers_Arithmetic1D.hxx"
41 #include "StdMeshers_AutomaticLength.hxx"
42 #include "StdMeshers_Geometric1D.hxx"
43 #include "StdMeshers_Deflection1D.hxx"
44 #include "StdMeshers_Distribution.hxx"
45 #include "StdMeshers_FixedPoints1D.hxx"
46 #include "StdMeshers_LocalLength.hxx"
47 #include "StdMeshers_MaxLength.hxx"
48 #include "StdMeshers_NumberOfSegments.hxx"
49 #include "StdMeshers_Propagation.hxx"
50 #include "StdMeshers_SegmentLengthAroundVertex.hxx"
51 #include "StdMeshers_StartEndLength.hxx"
53 #include <Utils_SALOME_Exception.hxx>
54 #include <utilities.h>
56 #include <BRepAdaptor_Curve.hxx>
57 #include <BRep_Tool.hxx>
58 #include <GCPnts_AbscissaPoint.hxx>
59 #include <GCPnts_UniformAbscissa.hxx>
60 #include <GCPnts_UniformDeflection.hxx>
61 #include <Precision.hxx>
63 #include <TopExp_Explorer.hxx>
65 #include <TopoDS_Edge.hxx>
66 #include <TopoDS_Vertex.hxx>
72 using namespace StdMeshers;
74 //=============================================================================
78 //=============================================================================
80 StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId,
83 :SMESH_1D_Algo( hypId, studyId, gen )
86 _shapeType = (1 << TopAbs_EDGE);
89 _compatibleHypothesis.push_back("LocalLength");
90 _compatibleHypothesis.push_back("MaxLength");
91 _compatibleHypothesis.push_back("NumberOfSegments");
92 _compatibleHypothesis.push_back("StartEndLength");
93 _compatibleHypothesis.push_back("Deflection1D");
94 _compatibleHypothesis.push_back("Arithmetic1D");
95 _compatibleHypothesis.push_back("GeometricProgression");
96 _compatibleHypothesis.push_back("FixedPoints1D");
97 _compatibleHypothesis.push_back("AutomaticLength");
98 _compatibleHypothesis.push_back("Adaptive1D");
100 _compatibleHypothesis.push_back("QuadraticMesh");
101 _compatibleHypothesis.push_back("Propagation");
102 _compatibleHypothesis.push_back("PropagOfDistribution");
105 //=============================================================================
109 //=============================================================================
111 StdMeshers_Regular_1D::~StdMeshers_Regular_1D()
115 //=============================================================================
119 //=============================================================================
121 bool StdMeshers_Regular_1D::CheckHypothesis( SMESH_Mesh& aMesh,
122 const TopoDS_Shape& aShape,
123 Hypothesis_Status& aStatus )
126 _quadraticMesh = false;
127 _onlyUnaryInput = true;
129 // check propagation in a redefined GetUsedHypothesis()
130 const list <const SMESHDS_Hypothesis * > & hyps =
131 GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliaryHyps=*/false);
133 const SMESH_HypoFilter & propagFilter = StdMeshers_Propagation::GetFilter();
135 // find non-auxiliary hypothesis
136 const SMESHDS_Hypothesis *theHyp = 0;
137 set< string > propagTypes;
138 list <const SMESHDS_Hypothesis * >::const_iterator h = hyps.begin();
139 for ( ; h != hyps.end(); ++h ) {
140 if ( static_cast<const SMESH_Hypothesis*>(*h)->IsAuxiliary() ) {
141 if ( strcmp( "QuadraticMesh", (*h)->GetName() ) == 0 )
142 _quadraticMesh = true;
143 if ( propagFilter.IsOk( static_cast< const SMESH_Hypothesis*>( *h ), aShape ))
144 propagTypes.insert( (*h)->GetName() );
148 theHyp = *h; // use only the first non-auxiliary hypothesis
154 aStatus = SMESH_Hypothesis::HYP_MISSING;
155 return false; // can't work without a hypothesis
158 string hypName = theHyp->GetName();
160 if ( !_mainEdge.IsNull() && _hypType == DISTRIB_PROPAGATION )
162 aStatus = SMESH_Hypothesis::HYP_OK;
164 else if ( hypName == "LocalLength" )
166 const StdMeshers_LocalLength * hyp =
167 dynamic_cast <const StdMeshers_LocalLength * >(theHyp);
169 _value[ BEG_LENGTH_IND ] = hyp->GetLength();
170 _value[ PRECISION_IND ] = hyp->GetPrecision();
171 ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
172 _hypType = LOCAL_LENGTH;
173 aStatus = SMESH_Hypothesis::HYP_OK;
176 else if ( hypName == "MaxLength" )
178 const StdMeshers_MaxLength * hyp =
179 dynamic_cast <const StdMeshers_MaxLength * >(theHyp);
181 _value[ BEG_LENGTH_IND ] = hyp->GetLength();
182 if ( hyp->GetUsePreestimatedLength() ) {
183 if ( int nbSeg = aMesh.GetGen()->GetBoundaryBoxSegmentation() )
184 _value[ BEG_LENGTH_IND ] = aMesh.GetShapeDiagonalSize() / nbSeg;
186 ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
187 _hypType = MAX_LENGTH;
188 aStatus = SMESH_Hypothesis::HYP_OK;
191 else if ( hypName == "NumberOfSegments" )
193 const StdMeshers_NumberOfSegments * hyp =
194 dynamic_cast <const StdMeshers_NumberOfSegments * >(theHyp);
196 _ivalue[ NB_SEGMENTS_IND ] = hyp->GetNumberOfSegments();
197 ASSERT( _ivalue[ NB_SEGMENTS_IND ] > 0 );
198 _ivalue[ DISTR_TYPE_IND ] = (int) hyp->GetDistrType();
199 switch (_ivalue[ DISTR_TYPE_IND ])
201 case StdMeshers_NumberOfSegments::DT_Scale:
202 _value[ SCALE_FACTOR_IND ] = hyp->GetScaleFactor();
203 _revEdgesIDs = hyp->GetReversedEdges();
205 case StdMeshers_NumberOfSegments::DT_TabFunc:
206 _vvalue[ TAB_FUNC_IND ] = hyp->GetTableFunction();
207 _revEdgesIDs = hyp->GetReversedEdges();
209 case StdMeshers_NumberOfSegments::DT_ExprFunc:
210 _svalue[ EXPR_FUNC_IND ] = hyp->GetExpressionFunction();
211 _revEdgesIDs = hyp->GetReversedEdges();
213 case StdMeshers_NumberOfSegments::DT_Regular:
219 if (_ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_TabFunc ||
220 _ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_ExprFunc)
221 _ivalue[ CONV_MODE_IND ] = hyp->ConversionMode();
222 _hypType = NB_SEGMENTS;
223 aStatus = SMESH_Hypothesis::HYP_OK;
226 else if ( hypName == "Arithmetic1D" )
228 const StdMeshers_Arithmetic1D * hyp =
229 dynamic_cast <const StdMeshers_Arithmetic1D * >(theHyp);
231 _value[ BEG_LENGTH_IND ] = hyp->GetLength( true );
232 _value[ END_LENGTH_IND ] = hyp->GetLength( false );
233 ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 );
234 _hypType = ARITHMETIC_1D;
236 _revEdgesIDs = hyp->GetReversedEdges();
238 aStatus = SMESH_Hypothesis::HYP_OK;
241 else if ( hypName == "GeometricProgression" )
243 const StdMeshers_Geometric1D * hyp =
244 dynamic_cast <const StdMeshers_Geometric1D * >(theHyp);
246 _value[ BEG_LENGTH_IND ] = hyp->GetStartLength();
247 _value[ END_LENGTH_IND ] = hyp->GetCommonRatio();
248 ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 );
249 _hypType = GEOMETRIC_1D;
251 _revEdgesIDs = hyp->GetReversedEdges();
253 aStatus = SMESH_Hypothesis::HYP_OK;
256 else if ( hypName == "FixedPoints1D" ) {
257 _fpHyp = dynamic_cast <const StdMeshers_FixedPoints1D*>(theHyp);
259 _hypType = FIXED_POINTS_1D;
261 _revEdgesIDs = _fpHyp->GetReversedEdges();
263 aStatus = SMESH_Hypothesis::HYP_OK;
266 else if ( hypName == "StartEndLength" )
268 const StdMeshers_StartEndLength * hyp =
269 dynamic_cast <const StdMeshers_StartEndLength * >(theHyp);
271 _value[ BEG_LENGTH_IND ] = hyp->GetLength( true );
272 _value[ END_LENGTH_IND ] = hyp->GetLength( false );
273 ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 );
274 _hypType = BEG_END_LENGTH;
276 _revEdgesIDs = hyp->GetReversedEdges();
278 aStatus = SMESH_Hypothesis::HYP_OK;
281 else if ( hypName == "Deflection1D" )
283 const StdMeshers_Deflection1D * hyp =
284 dynamic_cast <const StdMeshers_Deflection1D * >(theHyp);
286 _value[ DEFLECTION_IND ] = hyp->GetDeflection();
287 ASSERT( _value[ DEFLECTION_IND ] > 0 );
288 _hypType = DEFLECTION;
289 aStatus = SMESH_Hypothesis::HYP_OK;
292 else if ( hypName == "AutomaticLength" )
294 StdMeshers_AutomaticLength * hyp = const_cast<StdMeshers_AutomaticLength *>
295 (dynamic_cast <const StdMeshers_AutomaticLength * >(theHyp));
297 _value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
298 ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
299 _hypType = MAX_LENGTH;
300 aStatus = SMESH_Hypothesis::HYP_OK;
302 else if ( hypName == "Adaptive1D" )
304 _adaptiveHyp = dynamic_cast < const StdMeshers_Adaptive1D* >(theHyp);
305 ASSERT(_adaptiveHyp);
307 _onlyUnaryInput = false;
308 aStatus = SMESH_Hypothesis::HYP_OK;
312 aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
315 if ( propagTypes.size() > 1 && aStatus == HYP_OK )
317 // detect concurrent Propagation hyps
318 _usedHypList.clear();
319 list< TopoDS_Shape > assignedTo;
320 if ( aMesh.GetHypotheses( aShape, propagFilter, _usedHypList, true, &assignedTo ) > 1 )
322 // find most simple shape and a hyp on it
323 int simpleShape = TopAbs_COMPOUND;
324 const SMESHDS_Hypothesis* localHyp = 0;
325 list< TopoDS_Shape >::iterator shape = assignedTo.begin();
326 list< const SMESHDS_Hypothesis *>::iterator hyp = _usedHypList.begin();
327 for ( ; shape != assignedTo.end(); ++shape )
328 if ( shape->ShapeType() > simpleShape )
330 simpleShape = shape->ShapeType();
333 // check if there a different hyp on simpleShape
334 shape = assignedTo.begin();
335 hyp = _usedHypList.begin();
336 for ( ; hyp != _usedHypList.end(); ++hyp, ++shape )
337 if ( shape->ShapeType() == simpleShape &&
338 !localHyp->IsSameName( **hyp ))
340 aStatus = HYP_INCOMPAT_HYPS;
341 return error( SMESH_Comment("Hypotheses of both \"")
342 << StdMeshers_Propagation::GetName() << "\" and \""
343 << StdMeshers_PropagOfDistribution::GetName()
344 << "\" types can't be applied to the same edge");
349 return ( aStatus == SMESH_Hypothesis::HYP_OK );
352 static bool computeParamByFunc(Adaptor3d_Curve& C3d,
353 double first, double last, double length,
354 bool theReverse, int nbSeg, Function& func,
355 list<double>& theParams)
358 //OSD::SetSignal( true );
363 int nbPnt = 1 + nbSeg;
364 vector<double> x( nbPnt, 0. );
366 if ( !buildDistribution( func, 0.0, 1.0, nbSeg, x, 1E-4 ))
369 // apply parameters in range [0,1] to the space of the curve
370 double prevU = first;
378 for ( int i = 1; i < nbSeg; i++ )
380 double curvLength = length * (x[i] - x[i-1]) * sign;
381 double tol = Min( Precision::Confusion(), curvLength / 100. );
382 GCPnts_AbscissaPoint Discret( tol, C3d, curvLength, prevU );
383 if ( !Discret.IsDone() )
385 double U = Discret.Parameter();
386 if ( U > first && U < last )
387 theParams.push_back( U );
399 //================================================================================
401 * \brief adjust internal node parameters so that the last segment length == an
402 * \param a1 - the first segment length
403 * \param an - the last segment length
404 * \param U1 - the first edge parameter
405 * \param Un - the last edge parameter
406 * \param length - the edge length
407 * \param C3d - the edge curve
408 * \param theParams - internal node parameters to adjust
409 * \param adjustNeighbors2an - to adjust length of segments next to the last one
410 * and not to remove parameters
412 //================================================================================
414 static void compensateError(double a1, double an,
415 double U1, double Un,
417 Adaptor3d_Curve& C3d,
418 list<double> & theParams,
419 bool adjustNeighbors2an = false)
421 int i, nPar = theParams.size();
422 if ( a1 + an <= length && nPar > 1 )
424 bool reverse = ( U1 > Un );
425 double tol = Min( Precision::Confusion(), 0.01 * an );
426 GCPnts_AbscissaPoint Discret( tol, C3d, reverse ? an : -an, Un );
427 if ( !Discret.IsDone() )
429 double Utgt = Discret.Parameter(); // target value of the last parameter
430 list<double>::reverse_iterator itU = theParams.rbegin();
431 double Ul = *itU++; // real value of the last parameter
432 double dUn = Utgt - Ul; // parametric error of <an>
433 double dU = Abs( Ul - *itU ); // parametric length of the last but one segment
434 if ( Abs(dUn) <= 1e-3 * dU )
436 if ( adjustNeighbors2an || Abs(dUn) < 0.5 * dU ) { // last segment is a bit shorter than it should
437 // move the last parameter to the edge beginning
439 else { // last segment is much shorter than it should -> remove the last param and
440 theParams.pop_back(); nPar--; // move the rest points toward the edge end
441 dUn = Utgt - theParams.back();
444 if ( !adjustNeighbors2an )
446 double q = dUn / ( Utgt - Un ); // (signed) factor of segment length change
447 for ( itU = theParams.rbegin(), i = 1; i < nPar; i++ ) {
451 dUn = q * (*itU - prevU) * (prevU-U1)/(Un-U1);
454 else if ( nPar == 1 )
456 theParams.back() += dUn;
460 double q = dUn / ( nPar - 1 );
461 theParams.back() += dUn;
462 double sign = reverse ? -1 : 1;
463 double prevU = theParams.back();
464 itU = theParams.rbegin();
465 for ( ++itU, i = 2; i < nPar; ++itU, i++ ) {
466 double newU = *itU + dUn;
467 if ( newU*sign < prevU*sign ) {
471 else { // set U between prevU and next valid param
472 list<double>::reverse_iterator itU2 = itU;
475 while ( (*itU2)*sign > prevU*sign ) {
478 dU = ( *itU2 - prevU ) / nb;
479 while ( itU != itU2 ) {
489 //================================================================================
491 * \brief Class used to clean mesh on edges when 0D hyp modified.
492 * Common approach doesn't work when 0D algo is missing because the 0D hyp is
493 * considered as not participating in computation whereas it is used by 1D algo.
495 //================================================================================
497 // struct VertexEventListener : public SMESH_subMeshEventListener
499 // VertexEventListener():SMESH_subMeshEventListener(0) // won't be deleted by submesh
502 // * \brief Clean mesh on edges
503 // * \param event - algo_event or compute_event itself (of SMESH_subMesh)
504 // * \param eventType - ALGO_EVENT or COMPUTE_EVENT (of SMESH_subMesh)
505 // * \param subMesh - the submesh where the event occurs
507 // void ProcessEvent(const int event, const int eventType, SMESH_subMesh* subMesh,
508 // EventListenerData*, const SMESH_Hypothesis*)
510 // if ( eventType == SMESH_subMesh::ALGO_EVENT) // all algo events
512 // subMesh->ComputeStateEngine( SMESH_subMesh::MODIF_ALGO_STATE );
515 // }; // struct VertexEventListener
517 //=============================================================================
519 * \brief Sets event listener to vertex submeshes
520 * \param subMesh - submesh where algo is set
522 * This method is called when a submesh gets HYP_OK algo_state.
523 * After being set, event listener is notified on each event of a submesh.
525 //=============================================================================
527 void StdMeshers_Regular_1D::SetEventListener(SMESH_subMesh* subMesh)
529 StdMeshers_Propagation::SetPropagationMgr( subMesh );
532 //=============================================================================
535 * \param subMesh - restored submesh
537 * This method is called only if a submesh has HYP_OK algo_state.
539 //=============================================================================
541 void StdMeshers_Regular_1D::SubmeshRestored(SMESH_subMesh* subMesh)
545 //=============================================================================
547 * \brief Return StdMeshers_SegmentLengthAroundVertex assigned to vertex
549 //=============================================================================
551 const StdMeshers_SegmentLengthAroundVertex*
552 StdMeshers_Regular_1D::getVertexHyp(SMESH_Mesh & theMesh,
553 const TopoDS_Vertex & theV)
555 static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName("SegmentAroundVertex_0D"));
556 if ( const SMESH_Hypothesis * h = theMesh.GetHypothesis( theV, filter, true ))
558 SMESH_Algo* algo = const_cast< SMESH_Algo* >( static_cast< const SMESH_Algo* > ( h ));
559 const list <const SMESHDS_Hypothesis *> & hypList = algo->GetUsedHypothesis( theMesh, theV, 0 );
560 if ( !hypList.empty() && string("SegmentLengthAroundVertex") == hypList.front()->GetName() )
561 return static_cast<const StdMeshers_SegmentLengthAroundVertex*>( hypList.front() );
566 //================================================================================
568 * \brief Tune parameters to fit "SegmentLengthAroundVertex" hypothesis
569 * \param theC3d - wire curve
570 * \param theLength - curve length
571 * \param theParameters - internal nodes parameters to modify
572 * \param theVf - 1st vertex
573 * \param theVl - 2nd vertex
575 //================================================================================
577 void StdMeshers_Regular_1D::redistributeNearVertices (SMESH_Mesh & theMesh,
578 Adaptor3d_Curve & theC3d,
580 std::list< double > & theParameters,
581 const TopoDS_Vertex & theVf,
582 const TopoDS_Vertex & theVl)
584 double f = theC3d.FirstParameter(), l = theC3d.LastParameter();
585 int nPar = theParameters.size();
586 for ( int isEnd1 = 0; isEnd1 < 2; ++isEnd1 )
588 const TopoDS_Vertex & V = isEnd1 ? theVf : theVl;
589 const StdMeshers_SegmentLengthAroundVertex* hyp = getVertexHyp (theMesh, V );
591 double vertexLength = hyp->GetLength();
592 if ( vertexLength > theLength / 2.0 )
594 if ( isEnd1 ) { // to have a segment of interest at end of theParameters
595 theParameters.reverse();
598 if ( _hypType == NB_SEGMENTS )
600 compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
602 else if ( nPar <= 3 )
605 vertexLength = -vertexLength;
606 double tol = Min( Precision::Confusion(), 0.01 * vertexLength );
607 GCPnts_AbscissaPoint Discret( tol, theC3d, vertexLength, l );
608 if ( Discret.IsDone() ) {
610 theParameters.push_back( Discret.Parameter());
612 double L = GCPnts_AbscissaPoint::Length( theC3d, theParameters.back(), l);
613 if ( vertexLength < L / 2.0 )
614 theParameters.push_back( Discret.Parameter());
616 compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
622 // recompute params between the last segment and a middle one.
623 // find size of a middle segment
624 int nHalf = ( nPar-1 ) / 2;
625 list< double >::reverse_iterator itU = theParameters.rbegin();
626 std::advance( itU, nHalf );
628 double Lm = GCPnts_AbscissaPoint::Length( theC3d, Um, *itU);
629 double L = GCPnts_AbscissaPoint::Length( theC3d, *itU, l);
630 static StdMeshers_Regular_1D* auxAlgo = 0;
632 auxAlgo = new StdMeshers_Regular_1D( _gen->GetANewId(), _studyId, _gen );
633 auxAlgo->_hypType = BEG_END_LENGTH;
635 auxAlgo->_value[ BEG_LENGTH_IND ] = Lm;
636 auxAlgo->_value[ END_LENGTH_IND ] = vertexLength;
637 double from = *itU, to = l;
639 std::swap( from, to );
640 std::swap( auxAlgo->_value[ BEG_LENGTH_IND ], auxAlgo->_value[ END_LENGTH_IND ]);
643 if ( auxAlgo->computeInternalParameters( theMesh, theC3d, L, from, to, params, false ))
645 if ( isEnd1 ) params.reverse();
646 while ( 1 + nHalf-- )
647 theParameters.pop_back();
648 theParameters.splice( theParameters.end(), params );
652 compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
656 theParameters.reverse();
661 //=============================================================================
665 //=============================================================================
666 bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh,
667 Adaptor3d_Curve& theC3d,
671 list<double> & theParams,
672 const bool theReverse,
673 bool theConsiderPropagation)
677 double f = theFirstU, l = theLastU;
679 // Propagation Of Distribution
681 if ( !_mainEdge.IsNull() && _hypType == DISTRIB_PROPAGATION )
683 TopoDS_Edge mainEdge = TopoDS::Edge( _mainEdge ); // should not be a reference!
684 _gen->Compute( theMesh, mainEdge, SMESH_Gen::SHAPE_ONLY_UPWARD );
686 SMESHDS_SubMesh* smDS = theMesh.GetMeshDS()->MeshElements( mainEdge );
688 return error("No mesh on the source edge of Propagation Of Distribution");
689 if ( smDS->NbNodes() < 1 )
690 return true; // 1 segment
692 map< double, const SMDS_MeshNode* > mainEdgeParamsOfNodes;
693 if ( ! SMESH_Algo::GetSortedNodesOnEdge( theMesh.GetMeshDS(), mainEdge, _quadraticMesh,
694 mainEdgeParamsOfNodes, SMDSAbs_Edge ))
695 return error("Bad node parameters on the source edge of Propagation Of Distribution");
696 vector< double > segLen( mainEdgeParamsOfNodes.size() - 1 );
698 BRepAdaptor_Curve mainEdgeCurve( mainEdge );
699 map< double, const SMDS_MeshNode* >::iterator
700 u_n2 = mainEdgeParamsOfNodes.begin(), u_n1 = u_n2++;
701 for ( size_t i = 1; i < mainEdgeParamsOfNodes.size(); ++i, ++u_n1, ++u_n2 )
703 segLen[ i-1 ] = GCPnts_AbscissaPoint::Length( mainEdgeCurve,
706 totalLen += segLen[ i-1 ];
708 for ( size_t i = 0; i < segLen.size(); ++i )
709 segLen[ i ] *= theLength / totalLen;
711 size_t iSeg = theReverse ? segLen.size()-1 : 0;
712 size_t dSeg = theReverse ? -1 : +1;
713 double param = theFirstU;
715 for ( int i = 0, nb = segLen.size()-1; i < nb; ++i, iSeg += dSeg )
717 double tol = Min( Precision::Confusion(), 0.01 * segLen[ iSeg ]);
718 GCPnts_AbscissaPoint Discret( tol, theC3d, segLen[ iSeg ], param );
719 if ( !Discret.IsDone() ) break;
720 param = Discret.Parameter();
721 theParams.push_back( param );
724 if ( nbParams != segLen.size()-1 )
725 return error( SMESH_Comment("Can't divide into ") << segLen.size() << " segments");
727 compensateError( segLen[ theReverse ? segLen.size()-1 : 0 ],
728 segLen[ theReverse ? 0 : segLen.size()-1 ],
729 f, l, theLength, theC3d, theParams, true );
742 if ( _hypType == MAX_LENGTH )
744 double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
746 nbseg = 1; // degenerated edge
747 eltSize = theLength / nbseg * ( 1. - 1e-9 );
748 nbSegments = (int) nbseg;
750 else if ( _hypType == LOCAL_LENGTH )
752 // Local Length hypothesis
753 double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
756 bool isFound = false;
757 if (theConsiderPropagation && !_mainEdge.IsNull()) // propagated from some other edge
759 // Advanced processing to assure equal number of segments in case of Propagation
760 SMESH_subMesh* sm = theMesh.GetSubMeshContaining(_mainEdge);
762 bool computed = sm->IsMeshComputed();
764 if (sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) {
765 _gen->Compute( theMesh, _mainEdge, /*anUpward=*/true);
766 computed = sm->IsMeshComputed();
770 SMESHDS_SubMesh* smds = sm->GetSubMeshDS();
771 int nb_segments = smds->NbElements();
772 if (nbseg - 1 <= nb_segments && nb_segments <= nbseg + 1) {
779 if (!isFound) // not found by meshed edge in the propagation chain, use precision
781 double aPrecision = _value[ PRECISION_IND ];
782 double nbseg_prec = ceil((theLength / _value[ BEG_LENGTH_IND ]) - aPrecision);
783 if (nbseg_prec == (nbseg - 1)) nbseg--;
787 nbseg = 1; // degenerated edge
788 eltSize = theLength / nbseg;
789 nbSegments = (int) nbseg;
793 // Number Of Segments hypothesis
794 nbSegments = _ivalue[ NB_SEGMENTS_IND ];
795 if ( nbSegments < 1 ) return false;
796 if ( nbSegments == 1 ) return true;
798 switch (_ivalue[ DISTR_TYPE_IND ])
800 case StdMeshers_NumberOfSegments::DT_Scale:
802 double scale = _value[ SCALE_FACTOR_IND ];
804 if (fabs(scale - 1.0) < Precision::Confusion()) {
805 // special case to avoid division by zero
806 for (int i = 1; i < nbSegments; i++) {
807 double param = f + (l - f) * i / nbSegments;
808 theParams.push_back( param );
811 // general case of scale distribution
815 double alpha = pow(scale, 1.0 / (nbSegments - 1));
816 double factor = (l - f) / (1.0 - pow(alpha, nbSegments));
818 for (int i = 1; i < nbSegments; i++) {
819 double param = f + factor * (1.0 - pow(alpha, i));
820 theParams.push_back( param );
823 const double lenFactor = theLength/(l-f);
824 const double minSegLen = Min( theParams.front() - f, l - theParams.back() );
825 const double tol = Min( Precision::Confusion(), 0.01 * minSegLen );
826 list<double>::iterator u = theParams.begin(), uEnd = theParams.end();
827 for ( ; u != uEnd; ++u )
829 GCPnts_AbscissaPoint Discret( tol, theC3d, ((*u)-f) * lenFactor, f );
830 if ( Discret.IsDone() )
831 *u = Discret.Parameter();
836 case StdMeshers_NumberOfSegments::DT_TabFunc:
838 FunctionTable func(_vvalue[ TAB_FUNC_IND ], _ivalue[ CONV_MODE_IND ]);
839 return computeParamByFunc(theC3d, f, l, theLength, theReverse,
840 _ivalue[ NB_SEGMENTS_IND ], func,
844 case StdMeshers_NumberOfSegments::DT_ExprFunc:
846 FunctionExpr func(_svalue[ EXPR_FUNC_IND ].c_str(), _ivalue[ CONV_MODE_IND ]);
847 return computeParamByFunc(theC3d, f, l, theLength, theReverse,
848 _ivalue[ NB_SEGMENTS_IND ], func,
852 case StdMeshers_NumberOfSegments::DT_Regular:
853 eltSize = theLength / nbSegments;
860 double tol = Min( Precision::Confusion(), 0.01 * eltSize );
861 GCPnts_UniformAbscissa Discret(theC3d, nbSegments + 1, f, l, tol );
862 if ( !Discret.IsDone() )
863 return error( "GCPnts_UniformAbscissa failed");
864 if ( Discret.NbPoints() < nbSegments + 1 )
865 Discret.Initialize(theC3d, nbSegments + 2, f, l, tol );
867 int NbPoints = Min( Discret.NbPoints(), nbSegments + 1 );
868 for ( int i = 2; i < NbPoints; i++ ) // skip 1st and last points
870 double param = Discret.Parameter(i);
871 theParams.push_back( param );
873 compensateError( eltSize, eltSize, f, l, theLength, theC3d, theParams, true ); // for PAL9899
878 case BEG_END_LENGTH: {
880 // geometric progression: SUM(n) = ( a1 - an * q ) / ( 1 - q ) = theLength
882 double a1 = _value[ BEG_LENGTH_IND ];
883 double an = _value[ END_LENGTH_IND ];
884 double q = ( theLength - a1 ) / ( theLength - an );
885 if ( q < theLength/1e6 || 1.01*theLength < a1 + an)
886 return error ( SMESH_Comment("Invalid segment lengths (")<<a1<<" and "<<an<<") "<<
887 "for an edge of length "<<theLength);
889 double U1 = theReverse ? l : f;
890 double Un = theReverse ? f : l;
892 double eltSize = theReverse ? -a1 : a1;
893 double tol = Min( Precision::Confusion(), 0.01 * Min( a1, an ));
895 // computes a point on a curve <theC3d> at the distance <eltSize>
896 // from the point of parameter <param>.
897 GCPnts_AbscissaPoint Discret( tol, theC3d, eltSize, param );
898 if ( !Discret.IsDone() ) break;
899 param = Discret.Parameter();
900 if ( f < param && param < l )
901 theParams.push_back( param );
906 compensateError( a1, an, U1, Un, theLength, theC3d, theParams );
907 if (theReverse) theParams.reverse(); // NPAL18025
913 // arithmetic progression: SUM(n) = ( an - a1 + q ) * ( a1 + an ) / ( 2 * q ) = theLength
915 double a1 = _value[ BEG_LENGTH_IND ];
916 double an = _value[ END_LENGTH_IND ];
917 if ( 1.01*theLength < a1 + an )
918 return error ( SMESH_Comment("Invalid segment lengths (")<<a1<<" and "<<an<<") "<<
919 "for an edge of length "<<theLength);
921 double q = ( an - a1 ) / ( 2 *theLength/( a1 + an ) - 1 );
922 int n = int(fabs(q) > numeric_limits<double>::min() ? ( 1+( an-a1 )/q ) : ( 1+theLength/a1 ));
924 double U1 = theReverse ? l : f;
925 double Un = theReverse ? f : l;
928 double tol = Min( Precision::Confusion(), 0.01 * Min( a1, an ));
933 while ( n-- > 0 && eltSize * ( Un - U1 ) > 0 ) {
934 // computes a point on a curve <theC3d> at the distance <eltSize>
935 // from the point of parameter <param>.
936 GCPnts_AbscissaPoint Discret( tol, theC3d, eltSize, param );
937 if ( !Discret.IsDone() ) break;
938 param = Discret.Parameter();
939 if ( param > f && param < l )
940 theParams.push_back( param );
945 compensateError( a1, an, U1, Un, theLength, theC3d, theParams );
946 if ( theReverse ) theParams.reverse(); // NPAL18025
953 double a1 = _value[ BEG_LENGTH_IND ], an = 0;
954 double q = _value[ END_LENGTH_IND ];
956 double U1 = theReverse ? l : f;
957 double Un = theReverse ? f : l;
965 // computes a point on a curve <theC3d> at the distance <eltSize>
966 // from the point of parameter <param>.
967 double tol = Min( Precision::Confusion(), 0.01 * eltSize );
968 GCPnts_AbscissaPoint Discret( tol, theC3d, eltSize, param );
969 if ( !Discret.IsDone() ) break;
970 param = Discret.Parameter();
971 if ( f < param && param < l )
972 theParams.push_back( param );
981 if ( Abs( param - Un ) < 0.2 * Abs( param - theParams.back() ))
983 compensateError( a1, Abs(eltSize), U1, Un, theLength, theC3d, theParams );
985 else if ( Abs( Un - theParams.back() ) <
986 0.2 * Abs( theParams.back() - *(++theParams.rbegin())))
988 theParams.pop_back();
989 compensateError( a1, Abs(an), U1, Un, theLength, theC3d, theParams );
992 if (theReverse) theParams.reverse(); // NPAL18025
997 case FIXED_POINTS_1D:
999 const std::vector<double>& aPnts = _fpHyp->GetPoints();
1000 std::vector<int> nbsegs = _fpHyp->GetNbSegments();
1002 // sort normalized params, taking into account theReverse
1003 TColStd_SequenceOfReal Params;
1004 double tol = 1e-7 / theLength; // GCPnts_UniformAbscissa allows u2-u1 > 1e-7
1005 for ( size_t i = 0; i < aPnts.size(); i++ )
1007 if( aPnts[i] < tol || aPnts[i] > 1 - tol )
1009 double u = theReverse ? ( 1 - aPnts[i] ) : aPnts[i];
1011 bool IsExist = false;
1012 for ( ; j <= Params.Length(); j++ ) {
1013 if ( Abs( u - Params.Value(j) ) < tol ) {
1017 if ( u < Params.Value(j) ) break;
1019 if ( !IsExist ) Params.InsertBefore( j, u );
1022 // transform normalized Params into real ones
1023 std::vector< double > uVec( Params.Length() + 2 );
1024 uVec[ 0 ] = theFirstU;
1026 for ( int i = 1; i <= Params.Length(); i++ )
1028 abscissa = Params( i ) * theLength;
1029 tol = Min( Precision::Confusion(), 0.01 * abscissa );
1030 GCPnts_AbscissaPoint APnt( tol, theC3d, abscissa, theFirstU );
1031 if ( !APnt.IsDone() )
1032 return error( "GCPnts_AbscissaPoint failed");
1033 uVec[ i ] = APnt.Parameter();
1035 uVec.back() = theLastU;
1040 if ((int) nbsegs.size() > Params.Length() + 1 )
1041 nbsegs.resize( Params.Length() + 1 );
1042 std::reverse( nbsegs.begin(), nbsegs.end() );
1044 if ( nbsegs.empty() )
1046 nbsegs.push_back( 1 );
1048 Params.InsertBefore( 1, 0.0 );
1049 Params.Append( 1.0 );
1050 double eltSize, segmentSize, par1, par2;
1051 for ( size_t i = 0; i < uVec.size()-1; i++ )
1055 int nbseg = ( i < nbsegs.size() ) ? nbsegs[i] : nbsegs[0];
1058 theParams.push_back( par2 );
1062 segmentSize = ( Params( i+2 ) - Params( i+1 )) * theLength;
1063 eltSize = segmentSize / nbseg;
1064 tol = Min( Precision::Confusion(), 0.01 * eltSize );
1065 GCPnts_UniformAbscissa Discret( theC3d, eltSize, par1, par2, tol );
1066 if ( !Discret.IsDone() )
1067 return error( "GCPnts_UniformAbscissa failed");
1068 if ( Discret.NbPoints() < nbseg + 1 ) {
1069 eltSize = segmentSize / ( nbseg + 0.5 );
1070 Discret.Initialize( theC3d, eltSize, par1, par2, tol );
1072 int NbPoints = Discret.NbPoints();
1073 for ( int i = 2; i <= NbPoints; i++ ) {
1074 double param = Discret.Parameter(i);
1075 theParams.push_back( param );
1079 theParams.pop_back();
1086 GCPnts_UniformDeflection Discret( theC3d, _value[ DEFLECTION_IND ], f, l, true );
1087 if ( !Discret.IsDone() )
1090 int NbPoints = Discret.NbPoints();
1091 for ( int i = 2; i < NbPoints; i++ )
1093 double param = Discret.Parameter(i);
1094 theParams.push_back( param );
1105 //=============================================================================
1109 //=============================================================================
1111 bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & theShape)
1113 if ( _hypType == NONE )
1116 if ( _hypType == ADAPTIVE )
1118 _adaptiveHyp->GetAlgo()->InitComputeError();
1119 _adaptiveHyp->GetAlgo()->Compute( theMesh, theShape );
1120 return error( _adaptiveHyp->GetAlgo()->GetComputeError() );
1123 SMESHDS_Mesh * meshDS = theMesh.GetMeshDS();
1125 const TopoDS_Edge & EE = TopoDS::Edge(theShape);
1126 TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
1127 int shapeID = meshDS->ShapeToIndex( E );
1130 Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
1132 TopoDS_Vertex VFirst, VLast;
1133 TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l
1135 ASSERT(!VFirst.IsNull());
1136 ASSERT(!VLast.IsNull());
1137 const SMDS_MeshNode * nFirst = SMESH_Algo::VertexNode( VFirst, meshDS );
1138 const SMDS_MeshNode * nLast = SMESH_Algo::VertexNode( VLast, meshDS );
1139 if ( !nFirst || !nLast )
1140 return error( COMPERR_BAD_INPUT_MESH, "No node on vertex");
1142 // remove elements created by e.g. pattern mapping (PAL21999)
1143 // CLEAN event is incorrectly ptopagated seemingly due to Propagation hyp
1144 // so TEMPORARY solution is to clean the submesh manually
1145 if (SMESHDS_SubMesh * subMeshDS = meshDS->MeshElements(theShape))
1147 SMDS_ElemIteratorPtr ite = subMeshDS->GetElements();
1149 meshDS->RemoveFreeElement(ite->next(), subMeshDS);
1150 SMDS_NodeIteratorPtr itn = subMeshDS->GetNodes();
1151 while (itn->more()) {
1152 const SMDS_MeshNode * node = itn->next();
1153 if ( node->NbInverseElements() == 0 )
1154 meshDS->RemoveFreeNode(node, subMeshDS);
1156 meshDS->RemoveNode(node);
1160 double length = EdgeLength( E );
1161 if ( !Curve.IsNull() && length > 0 )
1163 list< double > params;
1164 bool reversed = false;
1165 if ( theMesh.GetShapeToMesh().ShapeType() >= TopAbs_WIRE && _revEdgesIDs.empty() ) {
1166 // if the shape to mesh is WIRE or EDGE
1167 reversed = ( EE.Orientation() == TopAbs_REVERSED );
1169 if ( !_mainEdge.IsNull() ) {
1170 // take into account reversing the edge the hypothesis is propagated from
1171 // (_mainEdge.Orientation() marks mutual orientation of EDGEs in propagation chain)
1172 reversed = ( _mainEdge.Orientation() == TopAbs_REVERSED );
1173 if ( _hypType != DISTRIB_PROPAGATION ) {
1174 int mainID = meshDS->ShapeToIndex(_mainEdge);
1175 if ( std::find( _revEdgesIDs.begin(), _revEdgesIDs.end(), mainID) != _revEdgesIDs.end())
1176 reversed = !reversed;
1179 // take into account this edge reversing
1180 if ( std::find( _revEdgesIDs.begin(), _revEdgesIDs.end(), shapeID) != _revEdgesIDs.end())
1181 reversed = !reversed;
1183 BRepAdaptor_Curve C3d( E );
1184 if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, reversed, true )) {
1187 redistributeNearVertices( theMesh, C3d, length, params, VFirst, VLast );
1189 // edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex)
1190 // only internal nodes receive an edge position with param on curve
1192 const SMDS_MeshNode * nPrev = nFirst;
1196 for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++) {
1197 double param = *itU;
1198 gp_Pnt P = Curve->Value(param);
1200 //Add the Node in the DataStructure
1201 SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
1202 meshDS->SetNodeOnEdge(node, shapeID, param);
1204 if(_quadraticMesh) {
1205 // create medium node
1206 double prm = ( parPrev + param )/2;
1207 gp_Pnt PM = Curve->Value(prm);
1208 SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
1209 meshDS->SetNodeOnEdge(NM, shapeID, prm);
1210 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node, NM);
1211 meshDS->SetMeshElementOnShape(edge, shapeID);
1214 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node);
1215 meshDS->SetMeshElementOnShape(edge, shapeID);
1221 if(_quadraticMesh) {
1222 double prm = ( parPrev + parLast )/2;
1223 gp_Pnt PM = Curve->Value(prm);
1224 SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
1225 meshDS->SetNodeOnEdge(NM, shapeID, prm);
1226 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, nLast, NM);
1227 meshDS->SetMeshElementOnShape(edge, shapeID);
1230 SMDS_MeshEdge* edge = meshDS->AddEdge(nPrev, nLast);
1231 meshDS->SetMeshElementOnShape(edge, shapeID);
1236 // Edge is a degenerated Edge : We put n = 5 points on the edge.
1237 const int NbPoints = 5;
1238 BRep_Tool::Range( E, f, l ); // PAL15185
1239 double du = (l - f) / (NbPoints - 1);
1241 gp_Pnt P = BRep_Tool::Pnt(VFirst);
1243 const SMDS_MeshNode * nPrev = nFirst;
1244 for (int i = 2; i < NbPoints; i++) {
1245 double param = f + (i - 1) * du;
1246 SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
1247 if(_quadraticMesh) {
1248 // create medium node
1249 double prm = param - du/2.;
1250 SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z());
1251 meshDS->SetNodeOnEdge(NM, shapeID, prm);
1252 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node, NM);
1253 meshDS->SetMeshElementOnShape(edge, shapeID);
1256 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node);
1257 meshDS->SetMeshElementOnShape(edge, shapeID);
1259 meshDS->SetNodeOnEdge(node, shapeID, param);
1262 if(_quadraticMesh) {
1263 // create medium node
1264 double prm = l - du/2.;
1265 SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z());
1266 meshDS->SetNodeOnEdge(NM, shapeID, prm);
1267 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, nLast, NM);
1268 meshDS->SetMeshElementOnShape(edge, shapeID);
1271 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, nLast);
1272 meshDS->SetMeshElementOnShape(edge, shapeID);
1279 //=============================================================================
1283 //=============================================================================
1285 bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh,
1286 const TopoDS_Shape & theShape,
1287 MapShapeNbElems& theResMap)
1289 if ( _hypType == NONE )
1292 if ( _hypType == ADAPTIVE )
1294 _adaptiveHyp->GetAlgo()->InitComputeError();
1295 _adaptiveHyp->GetAlgo()->Evaluate( theMesh, theShape, theResMap );
1296 return error( _adaptiveHyp->GetAlgo()->GetComputeError() );
1299 const TopoDS_Edge & EE = TopoDS::Edge(theShape);
1300 TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
1303 Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
1305 TopoDS_Vertex VFirst, VLast;
1306 TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l
1308 ASSERT(!VFirst.IsNull());
1309 ASSERT(!VLast.IsNull());
1311 std::vector<int> aVec(SMDSEntity_Last,0);
1313 double length = EdgeLength( E );
1314 if ( !Curve.IsNull() && length > 0 )
1316 list< double > params;
1317 BRepAdaptor_Curve C3d( E );
1318 if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, false, true )) {
1319 SMESH_subMesh * sm = theMesh.GetSubMesh(theShape);
1320 theResMap.insert(std::make_pair(sm,aVec));
1321 SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
1322 smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
1325 redistributeNearVertices( theMesh, C3d, length, params, VFirst, VLast );
1327 if(_quadraticMesh) {
1328 aVec[SMDSEntity_Node ] = 2*params.size() + 1;
1329 aVec[SMDSEntity_Quad_Edge] = params.size() + 1;
1332 aVec[SMDSEntity_Node] = params.size();
1333 aVec[SMDSEntity_Edge] = params.size() + 1;
1338 // Edge is a degenerated Edge : We put n = 5 points on the edge.
1339 if ( _quadraticMesh ) {
1340 aVec[SMDSEntity_Node ] = 11;
1341 aVec[SMDSEntity_Quad_Edge] = 6;
1344 aVec[SMDSEntity_Node] = 5;
1345 aVec[SMDSEntity_Edge] = 6;
1349 SMESH_subMesh * sm = theMesh.GetSubMesh( theShape );
1350 theResMap.insert( std::make_pair( sm, aVec ));
1356 //=============================================================================
1358 * See comments in SMESH_Algo.cxx
1360 //=============================================================================
1362 const list <const SMESHDS_Hypothesis *> &
1363 StdMeshers_Regular_1D::GetUsedHypothesis(SMESH_Mesh & aMesh,
1364 const TopoDS_Shape & aShape,
1365 const bool ignoreAuxiliary)
1367 _usedHypList.clear();
1368 _mainEdge.Nullify();
1370 SMESH_HypoFilter auxiliaryFilter( SMESH_HypoFilter::IsAuxiliary() );
1371 const SMESH_HypoFilter* compatibleFilter = GetCompatibleHypoFilter(/*ignoreAux=*/true );
1373 // get non-auxiliary assigned directly to aShape
1374 int nbHyp = aMesh.GetHypotheses( aShape, *compatibleFilter, _usedHypList, false );
1376 if (nbHyp == 0 && aShape.ShapeType() == TopAbs_EDGE)
1378 // Check, if propagated from some other edge
1379 bool isPropagOfDistribution = false;
1380 _mainEdge = StdMeshers_Propagation::GetPropagationSource( aMesh, aShape,
1381 isPropagOfDistribution );
1382 if ( !_mainEdge.IsNull() )
1384 if ( isPropagOfDistribution )
1385 _hypType = DISTRIB_PROPAGATION;
1386 // Propagation of 1D hypothesis from <aMainEdge> on this edge;
1387 // get non-auxiliary assigned to _mainEdge
1388 nbHyp = aMesh.GetHypotheses( _mainEdge, *compatibleFilter, _usedHypList, true );
1392 if (nbHyp == 0) // nothing propagated nor assigned to aShape
1394 SMESH_Algo::GetUsedHypothesis( aMesh, aShape, ignoreAuxiliary );
1395 nbHyp = _usedHypList.size();
1399 // get auxiliary hyps from aShape
1400 aMesh.GetHypotheses( aShape, auxiliaryFilter, _usedHypList, true );
1402 if ( nbHyp > 1 && ignoreAuxiliary )
1403 _usedHypList.clear(); //only one compatible non-auxiliary hypothesis allowed
1405 return _usedHypList;
1408 //================================================================================
1410 * \brief Pass CancelCompute() to a child algorithm
1412 //================================================================================
1414 void StdMeshers_Regular_1D::CancelCompute()
1416 SMESH_Algo::CancelCompute();
1417 if ( _hypType == ADAPTIVE )
1418 _adaptiveHyp->GetAlgo()->CancelCompute();