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 const list <const SMESHDS_Hypothesis * > & hyps =
130 GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliaryHyps=*/false);
132 const SMESH_HypoFilter & propagFilter = StdMeshers_Propagation::GetFilter();
134 // find non-auxiliary hypothesis
135 const SMESHDS_Hypothesis *theHyp = 0;
136 set< string > propagTypes;
137 list <const SMESHDS_Hypothesis * >::const_iterator h = hyps.begin();
138 for ( ; h != hyps.end(); ++h ) {
139 if ( static_cast<const SMESH_Hypothesis*>(*h)->IsAuxiliary() ) {
140 if ( strcmp( "QuadraticMesh", (*h)->GetName() ) == 0 )
141 _quadraticMesh = true;
142 if ( propagFilter.IsOk( static_cast< const SMESH_Hypothesis*>( *h ), aShape ))
143 propagTypes.insert( (*h)->GetName() );
147 theHyp = *h; // use only the first non-auxiliary hypothesis
153 aStatus = SMESH_Hypothesis::HYP_MISSING;
154 return false; // can't work without a hypothesis
157 string hypName = theHyp->GetName();
159 if ( hypName == "LocalLength" )
161 const StdMeshers_LocalLength * hyp =
162 dynamic_cast <const StdMeshers_LocalLength * >(theHyp);
164 _value[ BEG_LENGTH_IND ] = hyp->GetLength();
165 _value[ PRECISION_IND ] = hyp->GetPrecision();
166 ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
167 _hypType = LOCAL_LENGTH;
168 aStatus = SMESH_Hypothesis::HYP_OK;
171 else if ( hypName == "MaxLength" )
173 const StdMeshers_MaxLength * hyp =
174 dynamic_cast <const StdMeshers_MaxLength * >(theHyp);
176 _value[ BEG_LENGTH_IND ] = hyp->GetLength();
177 if ( hyp->GetUsePreestimatedLength() ) {
178 if ( int nbSeg = aMesh.GetGen()->GetBoundaryBoxSegmentation() )
179 _value[ BEG_LENGTH_IND ] = aMesh.GetShapeDiagonalSize() / nbSeg;
181 ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
182 _hypType = MAX_LENGTH;
183 aStatus = SMESH_Hypothesis::HYP_OK;
186 else if ( hypName == "NumberOfSegments" )
188 const StdMeshers_NumberOfSegments * hyp =
189 dynamic_cast <const StdMeshers_NumberOfSegments * >(theHyp);
191 _ivalue[ NB_SEGMENTS_IND ] = hyp->GetNumberOfSegments();
192 ASSERT( _ivalue[ NB_SEGMENTS_IND ] > 0 );
193 _ivalue[ DISTR_TYPE_IND ] = (int) hyp->GetDistrType();
194 switch (_ivalue[ DISTR_TYPE_IND ])
196 case StdMeshers_NumberOfSegments::DT_Scale:
197 _value[ SCALE_FACTOR_IND ] = hyp->GetScaleFactor();
198 _revEdgesIDs = hyp->GetReversedEdges();
200 case StdMeshers_NumberOfSegments::DT_TabFunc:
201 _vvalue[ TAB_FUNC_IND ] = hyp->GetTableFunction();
202 _revEdgesIDs = hyp->GetReversedEdges();
204 case StdMeshers_NumberOfSegments::DT_ExprFunc:
205 _svalue[ EXPR_FUNC_IND ] = hyp->GetExpressionFunction();
206 _revEdgesIDs = hyp->GetReversedEdges();
208 case StdMeshers_NumberOfSegments::DT_Regular:
214 if (_ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_TabFunc ||
215 _ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_ExprFunc)
216 _ivalue[ CONV_MODE_IND ] = hyp->ConversionMode();
217 _hypType = NB_SEGMENTS;
218 aStatus = SMESH_Hypothesis::HYP_OK;
221 else if ( hypName == "Arithmetic1D" )
223 const StdMeshers_Arithmetic1D * hyp =
224 dynamic_cast <const StdMeshers_Arithmetic1D * >(theHyp);
226 _value[ BEG_LENGTH_IND ] = hyp->GetLength( true );
227 _value[ END_LENGTH_IND ] = hyp->GetLength( false );
228 ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 );
229 _hypType = ARITHMETIC_1D;
231 _revEdgesIDs = hyp->GetReversedEdges();
233 aStatus = SMESH_Hypothesis::HYP_OK;
236 else if ( hypName == "GeometricProgression" )
238 const StdMeshers_Geometric1D * hyp =
239 dynamic_cast <const StdMeshers_Geometric1D * >(theHyp);
241 _value[ BEG_LENGTH_IND ] = hyp->GetStartLength();
242 _value[ END_LENGTH_IND ] = hyp->GetCommonRatio();
243 ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 );
244 _hypType = GEOMETRIC_1D;
246 _revEdgesIDs = hyp->GetReversedEdges();
248 aStatus = SMESH_Hypothesis::HYP_OK;
251 else if ( hypName == "FixedPoints1D" ) {
252 _fpHyp = dynamic_cast <const StdMeshers_FixedPoints1D*>(theHyp);
254 _hypType = FIXED_POINTS_1D;
256 _revEdgesIDs = _fpHyp->GetReversedEdges();
258 aStatus = SMESH_Hypothesis::HYP_OK;
261 else if ( hypName == "StartEndLength" )
263 const StdMeshers_StartEndLength * hyp =
264 dynamic_cast <const StdMeshers_StartEndLength * >(theHyp);
266 _value[ BEG_LENGTH_IND ] = hyp->GetLength( true );
267 _value[ END_LENGTH_IND ] = hyp->GetLength( false );
268 ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 );
269 _hypType = BEG_END_LENGTH;
271 _revEdgesIDs = hyp->GetReversedEdges();
273 aStatus = SMESH_Hypothesis::HYP_OK;
276 else if ( hypName == "Deflection1D" )
278 const StdMeshers_Deflection1D * hyp =
279 dynamic_cast <const StdMeshers_Deflection1D * >(theHyp);
281 _value[ DEFLECTION_IND ] = hyp->GetDeflection();
282 ASSERT( _value[ DEFLECTION_IND ] > 0 );
283 _hypType = DEFLECTION;
284 aStatus = SMESH_Hypothesis::HYP_OK;
287 else if ( hypName == "AutomaticLength" )
289 StdMeshers_AutomaticLength * hyp = const_cast<StdMeshers_AutomaticLength *>
290 (dynamic_cast <const StdMeshers_AutomaticLength * >(theHyp));
292 _value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
293 ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
294 _hypType = MAX_LENGTH;
295 aStatus = SMESH_Hypothesis::HYP_OK;
297 else if ( !_mainEdge.IsNull() && _hypType == DISTRIB_PROPAGATION ) // !!! before "Adaptive1D"
299 aStatus = SMESH_Hypothesis::HYP_OK;
301 else if ( hypName == "Adaptive1D" )
303 _adaptiveHyp = dynamic_cast < const StdMeshers_Adaptive1D* >(theHyp);
304 ASSERT(_adaptiveHyp);
306 _onlyUnaryInput = false;
307 aStatus = SMESH_Hypothesis::HYP_OK;
311 aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
314 if ( propagTypes.size() > 1 && aStatus == HYP_OK )
316 // detect concurrent Propagation hyps
317 _usedHypList.clear();
318 list< TopoDS_Shape > assignedTo;
319 if ( aMesh.GetHypotheses( aShape, propagFilter, _usedHypList, true, &assignedTo ) > 1 )
321 // find most simple shape and a hyp on it
322 int simpleShape = TopAbs_COMPOUND;
323 const SMESHDS_Hypothesis* localHyp = 0;
324 list< TopoDS_Shape >::iterator shape = assignedTo.begin();
325 list< const SMESHDS_Hypothesis *>::iterator hyp = _usedHypList.begin();
326 for ( ; shape != assignedTo.end(); ++shape )
327 if ( shape->ShapeType() > simpleShape )
329 simpleShape = shape->ShapeType();
332 // check if there a different hyp on simpleShape
333 shape = assignedTo.begin();
334 hyp = _usedHypList.begin();
335 for ( ; hyp != _usedHypList.end(); ++hyp, ++shape )
336 if ( shape->ShapeType() == simpleShape &&
337 !localHyp->IsSameName( **hyp ))
339 aStatus = HYP_INCOMPAT_HYPS;
340 return error( SMESH_Comment("Hypotheses of both \"")
341 << StdMeshers_Propagation::GetName() << "\" and \""
342 << StdMeshers_PropagOfDistribution::GetName()
343 << "\" types can't be applied to the same edge");
348 return ( aStatus == SMESH_Hypothesis::HYP_OK );
351 static bool computeParamByFunc(Adaptor3d_Curve& C3d,
352 double first, double last, double length,
353 bool theReverse, int nbSeg, Function& func,
354 list<double>& theParams)
357 //OSD::SetSignal( true );
362 int nbPnt = 1 + nbSeg;
363 vector<double> x( nbPnt, 0. );
365 if ( !buildDistribution( func, 0.0, 1.0, nbSeg, x, 1E-4 ))
368 // apply parameters in range [0,1] to the space of the curve
369 double prevU = first;
377 for ( int i = 1; i < nbSeg; i++ )
379 double curvLength = length * (x[i] - x[i-1]) * sign;
380 double tol = Min( Precision::Confusion(), curvLength / 100. );
381 GCPnts_AbscissaPoint Discret( tol, C3d, curvLength, prevU );
382 if ( !Discret.IsDone() )
384 double U = Discret.Parameter();
385 if ( U > first && U < last )
386 theParams.push_back( U );
397 //================================================================================
399 * \brief adjust internal node parameters so that the last segment length == an
400 * \param a1 - the first segment length
401 * \param an - the last segment length
402 * \param U1 - the first edge parameter
403 * \param Un - the last edge parameter
404 * \param length - the edge length
405 * \param C3d - the edge curve
406 * \param theParams - internal node parameters to adjust
407 * \param adjustNeighbors2an - to adjust length of segments next to the last one
408 * and not to remove parameters
410 //================================================================================
412 static void compensateError(double a1, double an,
413 double U1, double Un,
415 Adaptor3d_Curve& C3d,
416 list<double> & theParams,
417 bool adjustNeighbors2an = false)
419 int i, nPar = theParams.size();
420 if ( a1 + an <= length && nPar > 1 )
422 bool reverse = ( U1 > Un );
423 double tol = Min( Precision::Confusion(), 0.01 * an );
424 GCPnts_AbscissaPoint Discret( tol, C3d, reverse ? an : -an, Un );
425 if ( !Discret.IsDone() )
427 double Utgt = Discret.Parameter(); // target value of the last parameter
428 list<double>::reverse_iterator itU = theParams.rbegin();
429 double Ul = *itU++; // real value of the last parameter
430 double dUn = Utgt - Ul; // parametric error of <an>
431 double dU = Abs( Ul - *itU ); // parametric length of the last but one segment
432 if ( Abs(dUn) <= 1e-3 * dU )
434 if ( adjustNeighbors2an || Abs(dUn) < 0.5 * dU ) { // last segment is a bit shorter than it should
435 // move the last parameter to the edge beginning
437 else { // last segment is much shorter than it should -> remove the last param and
438 theParams.pop_back(); nPar--; // move the rest points toward the edge end
439 dUn = Utgt - theParams.back();
442 if ( !adjustNeighbors2an )
444 double q = dUn / ( Utgt - Un ); // (signed) factor of segment length change
445 for ( itU = theParams.rbegin(), i = 1; i < nPar; i++ ) {
449 dUn = q * (*itU - prevU) * (prevU-U1)/(Un-U1);
452 else if ( nPar == 1 )
454 theParams.back() += dUn;
458 double q = dUn / ( nPar - 1 );
459 theParams.back() += dUn;
460 double sign = reverse ? -1 : 1;
461 double prevU = theParams.back();
462 itU = theParams.rbegin();
463 for ( ++itU, i = 2; i < nPar; ++itU, i++ ) {
464 double newU = *itU + dUn;
465 if ( newU*sign < prevU*sign ) {
469 else { // set U between prevU and next valid param
470 list<double>::reverse_iterator itU2 = itU;
473 while ( (*itU2)*sign > prevU*sign ) {
476 dU = ( *itU2 - prevU ) / nb;
477 while ( itU != itU2 ) {
487 //================================================================================
489 * \brief Class used to clean mesh on edges when 0D hyp modified.
490 * Common approach doesn't work when 0D algo is missing because the 0D hyp is
491 * considered as not participating in computation whereas it is used by 1D algo.
493 //================================================================================
495 // struct VertexEventListener : public SMESH_subMeshEventListener
497 // VertexEventListener():SMESH_subMeshEventListener(0) // won't be deleted by submesh
500 // * \brief Clean mesh on edges
501 // * \param event - algo_event or compute_event itself (of SMESH_subMesh)
502 // * \param eventType - ALGO_EVENT or COMPUTE_EVENT (of SMESH_subMesh)
503 // * \param subMesh - the submesh where the event occures
505 // void ProcessEvent(const int event, const int eventType, SMESH_subMesh* subMesh,
506 // EventListenerData*, const SMESH_Hypothesis*)
508 // if ( eventType == SMESH_subMesh::ALGO_EVENT) // all algo events
510 // subMesh->ComputeStateEngine( SMESH_subMesh::MODIF_ALGO_STATE );
513 // }; // struct VertexEventListener
515 //=============================================================================
517 * \brief Sets event listener to vertex submeshes
518 * \param subMesh - submesh where algo is set
520 * This method is called when a submesh gets HYP_OK algo_state.
521 * After being set, event listener is notified on each event of a submesh.
523 //=============================================================================
525 void StdMeshers_Regular_1D::SetEventListener(SMESH_subMesh* subMesh)
527 StdMeshers_Propagation::SetPropagationMgr( subMesh );
530 //=============================================================================
533 * \param subMesh - restored submesh
535 * This method is called only if a submesh has HYP_OK algo_state.
537 //=============================================================================
539 void StdMeshers_Regular_1D::SubmeshRestored(SMESH_subMesh* subMesh)
543 //=============================================================================
545 * \brief Return StdMeshers_SegmentLengthAroundVertex assigned to vertex
547 //=============================================================================
549 const StdMeshers_SegmentLengthAroundVertex*
550 StdMeshers_Regular_1D::getVertexHyp(SMESH_Mesh & theMesh,
551 const TopoDS_Vertex & theV)
553 static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName("SegmentAroundVertex_0D"));
554 if ( const SMESH_Hypothesis * h = theMesh.GetHypothesis( theV, filter, true ))
556 SMESH_Algo* algo = const_cast< SMESH_Algo* >( static_cast< const SMESH_Algo* > ( h ));
557 const list <const SMESHDS_Hypothesis *> & hypList = algo->GetUsedHypothesis( theMesh, theV, 0 );
558 if ( !hypList.empty() && string("SegmentLengthAroundVertex") == hypList.front()->GetName() )
559 return static_cast<const StdMeshers_SegmentLengthAroundVertex*>( hypList.front() );
564 //================================================================================
566 * \brief Tune parameters to fit "SegmentLengthAroundVertex" hypothesis
567 * \param theC3d - wire curve
568 * \param theLength - curve length
569 * \param theParameters - internal nodes parameters to modify
570 * \param theVf - 1st vertex
571 * \param theVl - 2nd vertex
573 //================================================================================
575 void StdMeshers_Regular_1D::redistributeNearVertices (SMESH_Mesh & theMesh,
576 Adaptor3d_Curve & theC3d,
578 std::list< double > & theParameters,
579 const TopoDS_Vertex & theVf,
580 const TopoDS_Vertex & theVl)
582 double f = theC3d.FirstParameter(), l = theC3d.LastParameter();
583 int nPar = theParameters.size();
584 for ( int isEnd1 = 0; isEnd1 < 2; ++isEnd1 )
586 const TopoDS_Vertex & V = isEnd1 ? theVf : theVl;
587 const StdMeshers_SegmentLengthAroundVertex* hyp = getVertexHyp (theMesh, V );
589 double vertexLength = hyp->GetLength();
590 if ( vertexLength > theLength / 2.0 )
592 if ( isEnd1 ) { // to have a segment of interest at end of theParameters
593 theParameters.reverse();
596 if ( _hypType == NB_SEGMENTS )
598 compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
600 else if ( nPar <= 3 )
603 vertexLength = -vertexLength;
604 double tol = Min( Precision::Confusion(), 0.01 * vertexLength );
605 GCPnts_AbscissaPoint Discret( tol, theC3d, vertexLength, l );
606 if ( Discret.IsDone() ) {
608 theParameters.push_back( Discret.Parameter());
610 double L = GCPnts_AbscissaPoint::Length( theC3d, theParameters.back(), l);
611 if ( vertexLength < L / 2.0 )
612 theParameters.push_back( Discret.Parameter());
614 compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
620 // recompute params between the last segment and a middle one.
621 // find size of a middle segment
622 int nHalf = ( nPar-1 ) / 2;
623 list< double >::reverse_iterator itU = theParameters.rbegin();
624 std::advance( itU, nHalf );
626 double Lm = GCPnts_AbscissaPoint::Length( theC3d, Um, *itU);
627 double L = GCPnts_AbscissaPoint::Length( theC3d, *itU, l);
628 static StdMeshers_Regular_1D* auxAlgo = 0;
630 auxAlgo = new StdMeshers_Regular_1D( _gen->GetANewId(), _studyId, _gen );
631 auxAlgo->_hypType = BEG_END_LENGTH;
633 auxAlgo->_value[ BEG_LENGTH_IND ] = Lm;
634 auxAlgo->_value[ END_LENGTH_IND ] = vertexLength;
635 double from = *itU, to = l;
637 std::swap( from, to );
638 std::swap( auxAlgo->_value[ BEG_LENGTH_IND ], auxAlgo->_value[ END_LENGTH_IND ]);
641 if ( auxAlgo->computeInternalParameters( theMesh, theC3d, L, from, to, params, false ))
643 if ( isEnd1 ) params.reverse();
644 while ( 1 + nHalf-- )
645 theParameters.pop_back();
646 theParameters.splice( theParameters.end(), params );
650 compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
654 theParameters.reverse();
659 //=============================================================================
663 //=============================================================================
664 bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh,
665 Adaptor3d_Curve& theC3d,
669 list<double> & theParams,
670 const bool theReverse,
671 bool theConsiderPropagation)
675 double f = theFirstU, l = theLastU;
677 // Propagation Of Distribution
679 if ( !_mainEdge.IsNull() && _hypType == DISTRIB_PROPAGATION )
681 TopoDS_Edge mainEdge = TopoDS::Edge( _mainEdge ); // should not be a reference!
682 _gen->Compute( theMesh, mainEdge, SMESH_Gen::SHAPE_ONLY_UPWARD );
684 SMESHDS_SubMesh* smDS = theMesh.GetMeshDS()->MeshElements( mainEdge );
686 return error("No mesh on the source edge of Propagation Of Distribution");
687 if ( smDS->NbNodes() < 1 )
688 return true; // 1 segment
690 map< double, const SMDS_MeshNode* > mainEdgeParamsOfNodes;
691 if ( ! SMESH_Algo::GetSortedNodesOnEdge( theMesh.GetMeshDS(), mainEdge, _quadraticMesh,
692 mainEdgeParamsOfNodes, SMDSAbs_Edge ))
693 return error("Bad node parameters on the source edge of Propagation Of Distribution");
694 vector< double > segLen( mainEdgeParamsOfNodes.size() - 1 );
696 BRepAdaptor_Curve mainEdgeCurve( mainEdge );
697 map< double, const SMDS_MeshNode* >::iterator
698 u_n2 = mainEdgeParamsOfNodes.begin(), u_n1 = u_n2++;
699 for ( size_t i = 1; i < mainEdgeParamsOfNodes.size(); ++i, ++u_n1, ++u_n2 )
701 segLen[ i-1 ] = GCPnts_AbscissaPoint::Length( mainEdgeCurve,
704 totalLen += segLen[ i-1 ];
706 for ( size_t i = 0; i < segLen.size(); ++i )
707 segLen[ i ] *= theLength / totalLen;
709 size_t iSeg = theReverse ? segLen.size()-1 : 0;
710 size_t dSeg = theReverse ? -1 : +1;
711 double param = theFirstU;
713 for ( int i = 0, nb = segLen.size()-1; i < nb; ++i, iSeg += dSeg )
715 double tol = Min( Precision::Confusion(), 0.01 * segLen[ iSeg ]);
716 GCPnts_AbscissaPoint Discret( tol, theC3d, segLen[ iSeg ], param );
717 if ( !Discret.IsDone() ) break;
718 param = Discret.Parameter();
719 theParams.push_back( param );
722 if ( nbParams != segLen.size()-1 )
723 return error( SMESH_Comment("Can't divide into ") << segLen.size() << " segments");
725 compensateError( segLen[ theReverse ? segLen.size()-1 : 0 ],
726 segLen[ theReverse ? 0 : segLen.size()-1 ],
727 f, l, theLength, theC3d, theParams, true );
740 if ( _hypType == MAX_LENGTH )
742 double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
744 nbseg = 1; // degenerated edge
745 eltSize = theLength / nbseg * ( 1. - 1e-9 );
746 nbSegments = (int) nbseg;
748 else if ( _hypType == LOCAL_LENGTH )
750 // Local Length hypothesis
751 double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
754 bool isFound = false;
755 if (theConsiderPropagation && !_mainEdge.IsNull()) // propagated from some other edge
757 // Advanced processing to assure equal number of segments in case of Propagation
758 SMESH_subMesh* sm = theMesh.GetSubMeshContaining(_mainEdge);
760 bool computed = sm->IsMeshComputed();
762 if (sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) {
763 _gen->Compute( theMesh, _mainEdge, /*anUpward=*/true);
764 computed = sm->IsMeshComputed();
768 SMESHDS_SubMesh* smds = sm->GetSubMeshDS();
769 int nb_segments = smds->NbElements();
770 if (nbseg - 1 <= nb_segments && nb_segments <= nbseg + 1) {
777 if (!isFound) // not found by meshed edge in the propagation chain, use precision
779 double aPrecision = _value[ PRECISION_IND ];
780 double nbseg_prec = ceil((theLength / _value[ BEG_LENGTH_IND ]) - aPrecision);
781 if (nbseg_prec == (nbseg - 1)) nbseg--;
785 nbseg = 1; // degenerated edge
786 eltSize = theLength / nbseg;
787 nbSegments = (int) nbseg;
791 // Number Of Segments hypothesis
792 nbSegments = _ivalue[ NB_SEGMENTS_IND ];
793 if ( nbSegments < 1 ) return false;
794 if ( nbSegments == 1 ) return true;
796 switch (_ivalue[ DISTR_TYPE_IND ])
798 case StdMeshers_NumberOfSegments::DT_Scale:
800 double scale = _value[ SCALE_FACTOR_IND ];
802 if (fabs(scale - 1.0) < Precision::Confusion()) {
803 // special case to avoid division by zero
804 for (int i = 1; i < nbSegments; i++) {
805 double param = f + (l - f) * i / nbSegments;
806 theParams.push_back( param );
809 // general case of scale distribution
813 double alpha = pow(scale, 1.0 / (nbSegments - 1));
814 double factor = (l - f) / (1.0 - pow(alpha, nbSegments));
816 for (int i = 1; i < nbSegments; i++) {
817 double param = f + factor * (1.0 - pow(alpha, i));
818 theParams.push_back( param );
821 const double lenFactor = theLength/(l-f);
822 const double minSegLen = Min( theParams.front() - f, l - theParams.back() );
823 const double tol = Min( Precision::Confusion(), 0.01 * minSegLen );
824 list<double>::iterator u = theParams.begin(), uEnd = theParams.end();
825 for ( ; u != uEnd; ++u )
827 GCPnts_AbscissaPoint Discret( tol, theC3d, ((*u)-f) * lenFactor, f );
828 if ( Discret.IsDone() )
829 *u = Discret.Parameter();
834 case StdMeshers_NumberOfSegments::DT_TabFunc:
836 FunctionTable func(_vvalue[ TAB_FUNC_IND ], _ivalue[ CONV_MODE_IND ]);
837 return computeParamByFunc(theC3d, f, l, theLength, theReverse,
838 _ivalue[ NB_SEGMENTS_IND ], func,
842 case StdMeshers_NumberOfSegments::DT_ExprFunc:
844 FunctionExpr func(_svalue[ EXPR_FUNC_IND ].c_str(), _ivalue[ CONV_MODE_IND ]);
845 return computeParamByFunc(theC3d, f, l, theLength, theReverse,
846 _ivalue[ NB_SEGMENTS_IND ], func,
850 case StdMeshers_NumberOfSegments::DT_Regular:
851 eltSize = theLength / nbSegments;
858 double tol = Min( Precision::Confusion(), 0.01 * eltSize );
859 GCPnts_UniformAbscissa Discret(theC3d, nbSegments + 1, f, l, tol );
860 if ( !Discret.IsDone() )
861 return error( "GCPnts_UniformAbscissa failed");
862 if ( Discret.NbPoints() < nbSegments + 1 )
863 Discret.Initialize(theC3d, nbSegments + 2, f, l, tol );
865 int NbPoints = Min( Discret.NbPoints(), nbSegments + 1 );
866 for ( int i = 2; i < NbPoints; i++ ) // skip 1st and last points
868 double param = Discret.Parameter(i);
869 theParams.push_back( param );
871 compensateError( eltSize, eltSize, f, l, theLength, theC3d, theParams, true ); // for PAL9899
876 case BEG_END_LENGTH: {
878 // geometric progression: SUM(n) = ( a1 - an * q ) / ( 1 - q ) = theLength
880 double a1 = _value[ BEG_LENGTH_IND ];
881 double an = _value[ END_LENGTH_IND ];
882 double q = ( theLength - a1 ) / ( theLength - an );
883 if ( q < theLength/1e6 || 1.01*theLength < a1 + an)
884 return error ( SMESH_Comment("Invalid segment lengths (")<<a1<<" and "<<an<<") "<<
885 "for an edge of length "<<theLength);
887 double U1 = theReverse ? l : f;
888 double Un = theReverse ? f : l;
890 double eltSize = theReverse ? -a1 : a1;
891 double tol = Min( Precision::Confusion(), 0.01 * Min( a1, an ));
893 // computes a point on a curve <theC3d> at the distance <eltSize>
894 // from the point of parameter <param>.
895 GCPnts_AbscissaPoint Discret( tol, theC3d, eltSize, param );
896 if ( !Discret.IsDone() ) break;
897 param = Discret.Parameter();
898 if ( f < param && param < l )
899 theParams.push_back( param );
904 compensateError( a1, an, U1, Un, theLength, theC3d, theParams );
905 if (theReverse) theParams.reverse(); // NPAL18025
911 // arithmetic progression: SUM(n) = ( an - a1 + q ) * ( a1 + an ) / ( 2 * q ) = theLength
913 double a1 = _value[ BEG_LENGTH_IND ];
914 double an = _value[ END_LENGTH_IND ];
915 if ( 1.01*theLength < a1 + an )
916 return error ( SMESH_Comment("Invalid segment lengths (")<<a1<<" and "<<an<<") "<<
917 "for an edge of length "<<theLength);
919 double q = ( an - a1 ) / ( 2 *theLength/( a1 + an ) - 1 );
920 int n = int(fabs(q) > numeric_limits<double>::min() ? ( 1+( an-a1 )/q ) : ( 1+theLength/a1 ));
922 double U1 = theReverse ? l : f;
923 double Un = theReverse ? f : l;
926 double tol = Min( Precision::Confusion(), 0.01 * Min( a1, an ));
931 while ( n-- > 0 && eltSize * ( Un - U1 ) > 0 ) {
932 // computes a point on a curve <theC3d> at the distance <eltSize>
933 // from the point of parameter <param>.
934 GCPnts_AbscissaPoint Discret( tol, theC3d, eltSize, param );
935 if ( !Discret.IsDone() ) break;
936 param = Discret.Parameter();
937 if ( param > f && param < l )
938 theParams.push_back( param );
943 compensateError( a1, an, U1, Un, theLength, theC3d, theParams );
944 if ( theReverse ) theParams.reverse(); // NPAL18025
951 double a1 = _value[ BEG_LENGTH_IND ], an = 0;
952 double q = _value[ END_LENGTH_IND ];
954 double U1 = theReverse ? l : f;
955 double Un = theReverse ? f : l;
963 // computes a point on a curve <theC3d> at the distance <eltSize>
964 // from the point of parameter <param>.
965 double tol = Min( Precision::Confusion(), 0.01 * eltSize );
966 GCPnts_AbscissaPoint Discret( tol, theC3d, eltSize, param );
967 if ( !Discret.IsDone() ) break;
968 param = Discret.Parameter();
969 if ( f < param && param < l )
970 theParams.push_back( param );
979 if ( Abs( param - Un ) < 0.2 * Abs( param - theParams.back() ))
981 compensateError( a1, Abs(eltSize), U1, Un, theLength, theC3d, theParams );
983 else if ( Abs( Un - theParams.back() ) <
984 0.2 * Abs( theParams.back() - *(++theParams.rbegin())))
986 theParams.pop_back();
987 compensateError( a1, Abs(an), U1, Un, theLength, theC3d, theParams );
990 if (theReverse) theParams.reverse(); // NPAL18025
995 case FIXED_POINTS_1D:
997 const std::vector<double>& aPnts = _fpHyp->GetPoints();
998 std::vector<int> nbsegs = _fpHyp->GetNbSegments();
1000 // sort normalized params, taking into account theReverse
1001 TColStd_SequenceOfReal Params;
1002 double tol = 1e-7 / theLength; // GCPnts_UniformAbscissa allows u2-u1 > 1e-7
1003 for ( size_t i = 0; i < aPnts.size(); i++ )
1005 if( aPnts[i] < tol || aPnts[i] > 1 - tol )
1007 double u = theReverse ? ( 1 - aPnts[i] ) : aPnts[i];
1009 bool IsExist = false;
1010 for ( ; j <= Params.Length(); j++ ) {
1011 if ( Abs( u - Params.Value(j) ) < tol ) {
1015 if ( u < Params.Value(j) ) break;
1017 if ( !IsExist ) Params.InsertBefore( j, u );
1020 // transform normalized Params into real ones
1021 std::vector< double > uVec( Params.Length() + 2 );
1022 uVec[ 0 ] = theFirstU;
1024 for ( int i = 1; i <= Params.Length(); i++ )
1026 abscissa = Params( i ) * theLength;
1027 tol = Min( Precision::Confusion(), 0.01 * abscissa );
1028 GCPnts_AbscissaPoint APnt( tol, theC3d, abscissa, theFirstU );
1029 if ( !APnt.IsDone() )
1030 return error( "GCPnts_AbscissaPoint failed");
1031 uVec[ i ] = APnt.Parameter();
1033 uVec.back() = theLastU;
1038 if ((int) nbsegs.size() > Params.Length() + 1 )
1039 nbsegs.resize( Params.Length() + 1 );
1040 std::reverse( nbsegs.begin(), nbsegs.end() );
1042 if ( nbsegs.empty() )
1044 nbsegs.push_back( 1 );
1046 Params.InsertBefore( 1, 0.0 );
1047 Params.Append( 1.0 );
1048 double eltSize, segmentSize, par1, par2;
1049 for ( size_t i = 0; i < uVec.size()-1; i++ )
1053 int nbseg = ( i < nbsegs.size() ) ? nbsegs[i] : nbsegs[0];
1056 theParams.push_back( par2 );
1060 segmentSize = ( Params( i+2 ) - Params( i+1 )) * theLength;
1061 eltSize = segmentSize / nbseg;
1062 tol = Min( Precision::Confusion(), 0.01 * eltSize );
1063 GCPnts_UniformAbscissa Discret( theC3d, eltSize, par1, par2, tol );
1064 if ( !Discret.IsDone() )
1065 return error( "GCPnts_UniformAbscissa failed");
1066 if ( Discret.NbPoints() < nbseg + 1 ) {
1067 eltSize = segmentSize / ( nbseg + 0.5 );
1068 Discret.Initialize( theC3d, eltSize, par1, par2, tol );
1070 int NbPoints = Discret.NbPoints();
1071 for ( int i = 2; i <= NbPoints; i++ ) {
1072 double param = Discret.Parameter(i);
1073 theParams.push_back( param );
1077 theParams.pop_back();
1084 GCPnts_UniformDeflection Discret( theC3d, _value[ DEFLECTION_IND ], f, l, true );
1085 if ( !Discret.IsDone() )
1088 int NbPoints = Discret.NbPoints();
1089 for ( int i = 2; i < NbPoints; i++ )
1091 double param = Discret.Parameter(i);
1092 theParams.push_back( param );
1103 //=============================================================================
1107 //=============================================================================
1109 bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & theShape)
1111 if ( _hypType == NONE )
1114 if ( _hypType == ADAPTIVE )
1116 _adaptiveHyp->GetAlgo()->InitComputeError();
1117 _adaptiveHyp->GetAlgo()->Compute( theMesh, theShape );
1118 return error( _adaptiveHyp->GetAlgo()->GetComputeError() );
1121 SMESHDS_Mesh * meshDS = theMesh.GetMeshDS();
1123 const TopoDS_Edge & EE = TopoDS::Edge(theShape);
1124 TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
1125 int shapeID = meshDS->ShapeToIndex( E );
1128 Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
1130 TopoDS_Vertex VFirst, VLast;
1131 TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l
1133 ASSERT(!VFirst.IsNull());
1134 ASSERT(!VLast.IsNull());
1135 const SMDS_MeshNode * nFirst = SMESH_Algo::VertexNode( VFirst, meshDS );
1136 const SMDS_MeshNode * nLast = SMESH_Algo::VertexNode( VLast, meshDS );
1137 if ( !nFirst || !nLast )
1138 return error( COMPERR_BAD_INPUT_MESH, "No node on vertex");
1140 // remove elements created by e.g. patern mapping (PAL21999)
1141 // CLEAN event is incorrectly ptopagated seemingly due to Propagation hyp
1142 // so TEMPORARY solution is to clean the submesh manually
1143 if (SMESHDS_SubMesh * subMeshDS = meshDS->MeshElements(theShape))
1145 SMDS_ElemIteratorPtr ite = subMeshDS->GetElements();
1147 meshDS->RemoveFreeElement(ite->next(), subMeshDS);
1148 SMDS_NodeIteratorPtr itn = subMeshDS->GetNodes();
1149 while (itn->more()) {
1150 const SMDS_MeshNode * node = itn->next();
1151 if ( node->NbInverseElements() == 0 )
1152 meshDS->RemoveFreeNode(node, subMeshDS);
1154 meshDS->RemoveNode(node);
1158 double length = EdgeLength( E );
1159 if ( !Curve.IsNull() && length > 0 )
1161 list< double > params;
1162 bool reversed = false;
1163 if ( theMesh.GetShapeToMesh().ShapeType() >= TopAbs_WIRE && _revEdgesIDs.empty() ) {
1164 // if the shape to mesh is WIRE or EDGE
1165 reversed = ( EE.Orientation() == TopAbs_REVERSED );
1167 if ( !_mainEdge.IsNull() ) {
1168 // take into account reversing the edge the hypothesis is propagated from
1169 // (_mainEdge.Orientation() marks mutual orientation of EDGEs in propagation chain)
1170 reversed = ( _mainEdge.Orientation() == TopAbs_REVERSED );
1171 if ( _hypType != DISTRIB_PROPAGATION ) {
1172 int mainID = meshDS->ShapeToIndex(_mainEdge);
1173 if ( std::find( _revEdgesIDs.begin(), _revEdgesIDs.end(), mainID) != _revEdgesIDs.end())
1174 reversed = !reversed;
1177 // take into account this edge reversing
1178 if ( std::find( _revEdgesIDs.begin(), _revEdgesIDs.end(), shapeID) != _revEdgesIDs.end())
1179 reversed = !reversed;
1181 BRepAdaptor_Curve C3d( E );
1182 if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, reversed, true )) {
1185 redistributeNearVertices( theMesh, C3d, length, params, VFirst, VLast );
1187 // edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex)
1188 // only internal nodes receive an edge position with param on curve
1190 const SMDS_MeshNode * nPrev = nFirst;
1194 for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++) {
1195 double param = *itU;
1196 gp_Pnt P = Curve->Value(param);
1198 //Add the Node in the DataStructure
1199 SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
1200 meshDS->SetNodeOnEdge(node, shapeID, param);
1202 if(_quadraticMesh) {
1203 // create medium node
1204 double prm = ( parPrev + param )/2;
1205 gp_Pnt PM = Curve->Value(prm);
1206 SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
1207 meshDS->SetNodeOnEdge(NM, shapeID, prm);
1208 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node, NM);
1209 meshDS->SetMeshElementOnShape(edge, shapeID);
1212 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node);
1213 meshDS->SetMeshElementOnShape(edge, shapeID);
1219 if(_quadraticMesh) {
1220 double prm = ( parPrev + parLast )/2;
1221 gp_Pnt PM = Curve->Value(prm);
1222 SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
1223 meshDS->SetNodeOnEdge(NM, shapeID, prm);
1224 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, nLast, NM);
1225 meshDS->SetMeshElementOnShape(edge, shapeID);
1228 SMDS_MeshEdge* edge = meshDS->AddEdge(nPrev, nLast);
1229 meshDS->SetMeshElementOnShape(edge, shapeID);
1234 // Edge is a degenerated Edge : We put n = 5 points on the edge.
1235 const int NbPoints = 5;
1236 BRep_Tool::Range( E, f, l ); // PAL15185
1237 double du = (l - f) / (NbPoints - 1);
1239 gp_Pnt P = BRep_Tool::Pnt(VFirst);
1241 const SMDS_MeshNode * nPrev = nFirst;
1242 for (int i = 2; i < NbPoints; i++) {
1243 double param = f + (i - 1) * du;
1244 SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
1245 if(_quadraticMesh) {
1246 // create medium node
1247 double prm = param - du/2.;
1248 SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z());
1249 meshDS->SetNodeOnEdge(NM, shapeID, prm);
1250 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node, NM);
1251 meshDS->SetMeshElementOnShape(edge, shapeID);
1254 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node);
1255 meshDS->SetMeshElementOnShape(edge, shapeID);
1257 meshDS->SetNodeOnEdge(node, shapeID, param);
1260 if(_quadraticMesh) {
1261 // create medium node
1262 double prm = l - du/2.;
1263 SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z());
1264 meshDS->SetNodeOnEdge(NM, shapeID, prm);
1265 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, nLast, NM);
1266 meshDS->SetMeshElementOnShape(edge, shapeID);
1269 SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, nLast);
1270 meshDS->SetMeshElementOnShape(edge, shapeID);
1277 //=============================================================================
1281 //=============================================================================
1283 bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh,
1284 const TopoDS_Shape & theShape,
1285 MapShapeNbElems& aResMap)
1287 if ( _hypType == NONE )
1290 if ( _hypType == ADAPTIVE )
1292 _adaptiveHyp->GetAlgo()->InitComputeError();
1293 _adaptiveHyp->GetAlgo()->Evaluate( theMesh, theShape, aResMap );
1294 return error( _adaptiveHyp->GetAlgo()->GetComputeError() );
1297 const TopoDS_Edge & EE = TopoDS::Edge(theShape);
1298 TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
1301 Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
1303 TopoDS_Vertex VFirst, VLast;
1304 TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l
1306 ASSERT(!VFirst.IsNull());
1307 ASSERT(!VLast.IsNull());
1309 std::vector<int> aVec(SMDSEntity_Last,0);
1311 double length = EdgeLength( E );
1312 if ( !Curve.IsNull() && length > 0 )
1314 list< double > params;
1315 BRepAdaptor_Curve C3d( E );
1316 if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, false, true )) {
1317 SMESH_subMesh * sm = theMesh.GetSubMesh(theShape);
1318 aResMap.insert(std::make_pair(sm,aVec));
1319 SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
1320 smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
1323 redistributeNearVertices( theMesh, C3d, length, params, VFirst, VLast );
1325 if(_quadraticMesh) {
1326 aVec[SMDSEntity_Node] = 2*params.size() + 1;
1327 aVec[SMDSEntity_Quad_Edge] = params.size() + 1;
1330 aVec[SMDSEntity_Node] = params.size();
1331 aVec[SMDSEntity_Edge] = params.size() + 1;
1336 // Edge is a degenerated Edge : We put n = 5 points on the edge.
1337 if ( _quadraticMesh ) {
1338 aVec[SMDSEntity_Node] = 11;
1339 aVec[SMDSEntity_Quad_Edge] = 6;
1342 aVec[SMDSEntity_Node] = 5;
1343 aVec[SMDSEntity_Edge] = 6;
1347 SMESH_subMesh * sm = theMesh.GetSubMesh(theShape);
1348 aResMap.insert(std::make_pair(sm,aVec));
1354 //=============================================================================
1356 * See comments in SMESH_Algo.cxx
1358 //=============================================================================
1360 const list <const SMESHDS_Hypothesis *> &
1361 StdMeshers_Regular_1D::GetUsedHypothesis(SMESH_Mesh & aMesh,
1362 const TopoDS_Shape & aShape,
1363 const bool ignoreAuxiliary)
1365 _usedHypList.clear();
1366 _mainEdge.Nullify();
1368 SMESH_HypoFilter auxiliaryFilter( SMESH_HypoFilter::IsAuxiliary() );
1369 const SMESH_HypoFilter* compatibleFilter = GetCompatibleHypoFilter(/*ignoreAux=*/true );
1371 // get non-auxiliary assigned directly to aShape
1372 int nbHyp = aMesh.GetHypotheses( aShape, *compatibleFilter, _usedHypList, false );
1374 if (nbHyp == 0 && aShape.ShapeType() == TopAbs_EDGE)
1376 // Check, if propagated from some other edge
1377 bool isPropagOfDistribution = false;
1378 _mainEdge = StdMeshers_Propagation::GetPropagationSource( aMesh, aShape,
1379 isPropagOfDistribution );
1380 if ( !_mainEdge.IsNull() )
1382 if ( isPropagOfDistribution )
1383 _hypType = DISTRIB_PROPAGATION;
1384 // Propagation of 1D hypothesis from <aMainEdge> on this edge;
1385 // get non-auxiliary assigned to _mainEdge
1386 nbHyp = aMesh.GetHypotheses( _mainEdge, *compatibleFilter, _usedHypList, true );
1390 if (nbHyp == 0) // nothing propagated nor assigned to aShape
1392 SMESH_Algo::GetUsedHypothesis( aMesh, aShape, ignoreAuxiliary );
1393 nbHyp = _usedHypList.size();
1397 // get auxiliary hyps from aShape
1398 aMesh.GetHypotheses( aShape, auxiliaryFilter, _usedHypList, true );
1400 if ( nbHyp > 1 && ignoreAuxiliary )
1401 _usedHypList.clear(); //only one compatible non-auxiliary hypothesis allowed
1403 return _usedHypList;
1406 //================================================================================
1408 * \brief Pass CancelCompute() to a child algorithm
1410 //================================================================================
1412 void StdMeshers_Regular_1D::CancelCompute()
1414 SMESH_Algo::CancelCompute();
1415 if ( _hypType == ADAPTIVE )
1416 _adaptiveHyp->GetAlgo()->CancelCompute();