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 "SMESH_Comment.hxx"
33 #include "SMESH_Gen.hxx"
34 #include "SMESH_HypoFilter.hxx"
35 #include "SMESH_Mesh.hxx"
36 #include "SMESH_subMesh.hxx"
37 #include "SMESH_subMeshEventListener.hxx"
38 #include "StdMeshers_Adaptive1D.hxx"
39 #include "StdMeshers_Arithmetic1D.hxx"
40 #include "StdMeshers_Geometric1D.hxx"
41 #include "StdMeshers_AutomaticLength.hxx"
42 #include "StdMeshers_Deflection1D.hxx"
43 #include "StdMeshers_Distribution.hxx"
44 #include "StdMeshers_FixedPoints1D.hxx"
45 #include "StdMeshers_LocalLength.hxx"
46 #include "StdMeshers_MaxLength.hxx"
47 #include "StdMeshers_NumberOfSegments.hxx"
48 #include "StdMeshers_Propagation.hxx"
49 #include "StdMeshers_SegmentLengthAroundVertex.hxx"
50 #include "StdMeshers_StartEndLength.hxx"
52 #include "Utils_SALOME_Exception.hxx"
53 #include "utilities.h"
55 #include <BRepAdaptor_Curve.hxx>
56 #include <BRep_Tool.hxx>
57 #include <GCPnts_AbscissaPoint.hxx>
58 #include <GCPnts_UniformAbscissa.hxx>
59 #include <GCPnts_UniformDeflection.hxx>
60 #include <Precision.hxx>
62 #include <TopExp_Explorer.hxx>
64 #include <TopoDS_Edge.hxx>
65 #include <TopoDS_Vertex.hxx>
71 using namespace StdMeshers;
73 //=============================================================================
77 //=============================================================================
79 StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId, int studyId,
81 :SMESH_1D_Algo(hypId, studyId, gen)
83 MESSAGE("StdMeshers_Regular_1D::StdMeshers_Regular_1D");
85 _shapeType = (1 << TopAbs_EDGE);
88 _compatibleHypothesis.push_back("LocalLength");
89 _compatibleHypothesis.push_back("MaxLength");
90 _compatibleHypothesis.push_back("NumberOfSegments");
91 _compatibleHypothesis.push_back("StartEndLength");
92 _compatibleHypothesis.push_back("Deflection1D");
93 _compatibleHypothesis.push_back("Arithmetic1D");
94 _compatibleHypothesis.push_back("GeometricProgression");
95 _compatibleHypothesis.push_back("FixedPoints1D");
96 _compatibleHypothesis.push_back("AutomaticLength");
97 _compatibleHypothesis.push_back("Adaptive1D");
99 _compatibleHypothesis.push_back("QuadraticMesh");
100 _compatibleHypothesis.push_back("Propagation");
101 _compatibleHypothesis.push_back("PropagOfDistribution");
104 //=============================================================================
108 //=============================================================================
110 StdMeshers_Regular_1D::~StdMeshers_Regular_1D()
114 //=============================================================================
118 //=============================================================================
120 bool StdMeshers_Regular_1D::CheckHypothesis( SMESH_Mesh& aMesh,
121 const TopoDS_Shape& aShape,
122 Hypothesis_Status& aStatus )
125 _quadraticMesh = false;
126 _onlyUnaryInput = true;
128 const list <const SMESHDS_Hypothesis * > & hyps =
129 GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliaryHyps=*/false);
131 const SMESH_HypoFilter & propagFilter = StdMeshers_Propagation::GetFilter();
133 // find non-auxiliary hypothesis
134 const SMESHDS_Hypothesis *theHyp = 0;
135 set< string > propagTypes;
136 list <const SMESHDS_Hypothesis * >::const_iterator h = hyps.begin();
137 for ( ; h != hyps.end(); ++h ) {
138 if ( static_cast<const SMESH_Hypothesis*>(*h)->IsAuxiliary() ) {
139 if ( strcmp( "QuadraticMesh", (*h)->GetName() ) == 0 )
140 _quadraticMesh = true;
141 if ( propagFilter.IsOk( static_cast< const SMESH_Hypothesis*>( *h ), aShape ))
142 propagTypes.insert( (*h)->GetName() );
146 theHyp = *h; // use only the first non-auxiliary hypothesis
152 aStatus = SMESH_Hypothesis::HYP_MISSING;
153 return false; // can't work without a hypothesis
156 string hypName = theHyp->GetName();
158 if (hypName == "LocalLength")
160 const StdMeshers_LocalLength * hyp =
161 dynamic_cast <const StdMeshers_LocalLength * >(theHyp);
163 _value[ BEG_LENGTH_IND ] = hyp->GetLength();
164 _value[ PRECISION_IND ] = hyp->GetPrecision();
165 ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
166 _hypType = LOCAL_LENGTH;
167 aStatus = SMESH_Hypothesis::HYP_OK;
170 else if (hypName == "MaxLength")
172 const StdMeshers_MaxLength * hyp =
173 dynamic_cast <const StdMeshers_MaxLength * >(theHyp);
175 _value[ BEG_LENGTH_IND ] = hyp->GetLength();
176 if ( hyp->GetUsePreestimatedLength() ) {
177 if ( int nbSeg = aMesh.GetGen()->GetBoundaryBoxSegmentation() )
178 _value[ BEG_LENGTH_IND ] = aMesh.GetShapeDiagonalSize() / nbSeg;
180 ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
181 _hypType = MAX_LENGTH;
182 aStatus = SMESH_Hypothesis::HYP_OK;
185 else if (hypName == "NumberOfSegments")
187 MESSAGE("CheckHypothesis: 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 (hypName == "Adaptive1D")
299 _adaptiveHyp = dynamic_cast < const StdMeshers_Adaptive1D* >(theHyp);
300 ASSERT(_adaptiveHyp);
302 _onlyUnaryInput = false;
303 aStatus = SMESH_Hypothesis::HYP_OK;
307 aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
310 if ( propagTypes.size() > 1 && aStatus == HYP_OK )
312 // detect concurrent Propagation hyps
313 _usedHypList.clear();
314 list< TopoDS_Shape > assignedTo;
315 if ( aMesh.GetHypotheses( aShape, propagFilter, _usedHypList, true, &assignedTo ) > 1 )
317 // find most simple shape and a hyp on it
318 int simpleShape = TopAbs_COMPOUND;
319 const SMESHDS_Hypothesis* localHyp = 0;
320 list< TopoDS_Shape >::iterator shape = assignedTo.begin();
321 list< const SMESHDS_Hypothesis *>::iterator hyp = _usedHypList.begin();
322 for ( ; shape != assignedTo.end(); ++shape )
323 if ( shape->ShapeType() > simpleShape )
325 simpleShape = shape->ShapeType();
328 // check if there a different hyp on simpleShape
329 shape = assignedTo.begin();
330 hyp = _usedHypList.begin();
331 for ( ; hyp != _usedHypList.end(); ++hyp, ++shape )
332 if ( shape->ShapeType() == simpleShape &&
333 !localHyp->IsSameName( **hyp ))
335 aStatus = HYP_INCOMPAT_HYPS;
336 return error( SMESH_Comment("Hypotheses of both \"")
337 << StdMeshers_Propagation::GetName() << "\" and \""
338 << StdMeshers_PropagOfDistribution::GetName()
339 << "\" types can't be applied to the same edge");
344 return ( aStatus == SMESH_Hypothesis::HYP_OK );
347 static bool computeParamByFunc(Adaptor3d_Curve& C3d,
348 double first, double last, double length,
349 bool theReverse, int nbSeg, Function& func,
350 list<double>& theParams)
353 //OSD::SetSignal( true );
358 MESSAGE( "computeParamByFunc" );
360 int nbPnt = 1 + nbSeg;
361 vector<double> x(nbPnt, 0.);
363 if ( !buildDistribution( func, 0.0, 1.0, nbSeg, x, 1E-4 ))
366 // apply parameters in range [0,1] to the space of the curve
367 double prevU = first;
375 for ( int i = 1; i < nbSeg; i++ )
377 double curvLength = length * (x[i] - x[i-1]) * sign;
378 double tol = Min( Precision::Confusion(), curvLength / 100. );
379 GCPnts_AbscissaPoint Discret( tol, C3d, curvLength, prevU );
380 if ( !Discret.IsDone() )
382 double U = Discret.Parameter();
383 if ( U > first && U < last )
384 theParams.push_back( U );
395 //================================================================================
397 * \brief adjust internal node parameters so that the last segment length == an
398 * \param a1 - the first segment length
399 * \param an - the last segment length
400 * \param U1 - the first edge parameter
401 * \param Un - the last edge parameter
402 * \param length - the edge length
403 * \param C3d - the edge curve
404 * \param theParams - internal node parameters to adjust
405 * \param adjustNeighbors2an - to adjust length of segments next to the last one
406 * and not to remove parameters
408 //================================================================================
410 static void compensateError(double a1, double an,
411 double U1, double Un,
413 Adaptor3d_Curve& C3d,
414 list<double> & theParams,
415 bool adjustNeighbors2an = false)
417 int i, nPar = theParams.size();
418 if ( a1 + an <= length && nPar > 1 )
420 bool reverse = ( U1 > Un );
421 GCPnts_AbscissaPoint Discret(C3d, reverse ? an : -an, Un);
422 if ( !Discret.IsDone() )
424 double Utgt = Discret.Parameter(); // target value of the last parameter
425 list<double>::reverse_iterator itU = theParams.rbegin();
426 double Ul = *itU++; // real value of the last parameter
427 double dUn = Utgt - Ul; // parametric error of <an>
428 if ( Abs(dUn) <= Precision::Confusion() )
430 double dU = Abs( Ul - *itU ); // parametric length of the last but one segment
431 if ( adjustNeighbors2an || Abs(dUn) < 0.5 * dU ) { // last segment is a bit shorter than it should
432 // move the last parameter to the edge beginning
434 else { // last segment is much shorter than it should -> remove the last param and
435 theParams.pop_back(); nPar--; // move the rest points toward the edge end
436 dUn = Utgt - theParams.back();
439 if ( !adjustNeighbors2an )
441 double q = dUn / ( Utgt - Un ); // (signed) factor of segment length change
442 for ( itU = theParams.rbegin(), i = 1; i < nPar; i++ ) {
446 dUn = q * (*itU - prevU) * (prevU-U1)/(Un-U1);
449 else if ( nPar == 1 )
451 theParams.back() += dUn;
455 double q = dUn / ( nPar - 1 );
456 theParams.back() += dUn;
457 double sign = reverse ? -1 : 1;
458 double prevU = theParams.back();
459 itU = theParams.rbegin();
460 for ( ++itU, i = 2; i < nPar; ++itU, i++ ) {
461 double newU = *itU + dUn;
462 if ( newU*sign < prevU*sign ) {
466 else { // set U between prevU and next valid param
467 list<double>::reverse_iterator itU2 = itU;
470 while ( (*itU2)*sign > prevU*sign ) {
473 dU = ( *itU2 - prevU ) / nb;
474 while ( itU != itU2 ) {
484 //================================================================================
486 * \brief Class used to clean mesh on edges when 0D hyp modified.
487 * Common approach doesn't work when 0D algo is missing because the 0D hyp is
488 * considered as not participating in computation whereas it is used by 1D algo.
490 //================================================================================
492 // struct VertexEventListener : public SMESH_subMeshEventListener
494 // VertexEventListener():SMESH_subMeshEventListener(0) // won't be deleted by submesh
497 // * \brief Clean mesh on edges
498 // * \param event - algo_event or compute_event itself (of SMESH_subMesh)
499 // * \param eventType - ALGO_EVENT or COMPUTE_EVENT (of SMESH_subMesh)
500 // * \param subMesh - the submesh where the event occures
502 // void ProcessEvent(const int event, const int eventType, SMESH_subMesh* subMesh,
503 // EventListenerData*, const SMESH_Hypothesis*)
505 // if ( eventType == SMESH_subMesh::ALGO_EVENT) // all algo events
507 // subMesh->ComputeStateEngine( SMESH_subMesh::MODIF_ALGO_STATE );
510 // }; // struct VertexEventListener
512 //=============================================================================
514 * \brief Sets event listener to vertex submeshes
515 * \param subMesh - submesh where algo is set
517 * This method is called when a submesh gets HYP_OK algo_state.
518 * After being set, event listener is notified on each event of a submesh.
520 //=============================================================================
522 void StdMeshers_Regular_1D::SetEventListener(SMESH_subMesh* subMesh)
524 StdMeshers_Propagation::SetPropagationMgr( subMesh );
527 //=============================================================================
530 * \param subMesh - restored submesh
532 * This method is called only if a submesh has HYP_OK algo_state.
534 //=============================================================================
536 void StdMeshers_Regular_1D::SubmeshRestored(SMESH_subMesh* subMesh)
540 //=============================================================================
542 * \brief Return StdMeshers_SegmentLengthAroundVertex assigned to vertex
544 //=============================================================================
546 const StdMeshers_SegmentLengthAroundVertex*
547 StdMeshers_Regular_1D::getVertexHyp(SMESH_Mesh & theMesh,
548 const TopoDS_Vertex & theV)
550 static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName("SegmentAroundVertex_0D"));
551 if ( const SMESH_Hypothesis * h = theMesh.GetHypothesis( theV, filter, true ))
553 SMESH_Algo* algo = const_cast< SMESH_Algo* >( static_cast< const SMESH_Algo* > ( h ));
554 const list <const SMESHDS_Hypothesis *> & hypList = algo->GetUsedHypothesis( theMesh, theV, 0 );
555 if ( !hypList.empty() && string("SegmentLengthAroundVertex") == hypList.front()->GetName() )
556 return static_cast<const StdMeshers_SegmentLengthAroundVertex*>( hypList.front() );
561 //================================================================================
563 * \brief Tune parameters to fit "SegmentLengthAroundVertex" hypothesis
564 * \param theC3d - wire curve
565 * \param theLength - curve length
566 * \param theParameters - internal nodes parameters to modify
567 * \param theVf - 1st vertex
568 * \param theVl - 2nd vertex
570 //================================================================================
572 void StdMeshers_Regular_1D::redistributeNearVertices (SMESH_Mesh & theMesh,
573 Adaptor3d_Curve & theC3d,
575 std::list< double > & theParameters,
576 const TopoDS_Vertex & theVf,
577 const TopoDS_Vertex & theVl)
579 double f = theC3d.FirstParameter(), l = theC3d.LastParameter();
580 int nPar = theParameters.size();
581 for ( int isEnd1 = 0; isEnd1 < 2; ++isEnd1 )
583 const TopoDS_Vertex & V = isEnd1 ? theVf : theVl;
584 const StdMeshers_SegmentLengthAroundVertex* hyp = getVertexHyp (theMesh, V );
586 double vertexLength = hyp->GetLength();
587 if ( vertexLength > theLength / 2.0 )
589 if ( isEnd1 ) { // to have a segment of interest at end of theParameters
590 theParameters.reverse();
593 if ( _hypType == NB_SEGMENTS )
595 MESSAGE("redistributeNearVertices NB_SEGMENTS");
596 compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
598 else if ( nPar <= 3 )
601 vertexLength = -vertexLength;
602 GCPnts_AbscissaPoint Discret(theC3d, vertexLength, l);
603 if ( Discret.IsDone() ) {
605 theParameters.push_back( Discret.Parameter());
607 double L = GCPnts_AbscissaPoint::Length( theC3d, theParameters.back(), l);
608 if ( vertexLength < L / 2.0 )
609 theParameters.push_back( Discret.Parameter());
611 compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
617 // recompute params between the last segment and a middle one.
618 // find size of a middle segment
619 int nHalf = ( nPar-1 ) / 2;
620 list< double >::reverse_iterator itU = theParameters.rbegin();
621 std::advance( itU, nHalf );
623 double Lm = GCPnts_AbscissaPoint::Length( theC3d, Um, *itU);
624 double L = GCPnts_AbscissaPoint::Length( theC3d, *itU, l);
625 static StdMeshers_Regular_1D* auxAlgo = 0;
627 auxAlgo = new StdMeshers_Regular_1D( _gen->GetANewId(), _studyId, _gen );
628 auxAlgo->_hypType = BEG_END_LENGTH;
630 auxAlgo->_value[ BEG_LENGTH_IND ] = Lm;
631 auxAlgo->_value[ END_LENGTH_IND ] = vertexLength;
632 double from = *itU, to = l;
634 std::swap( from, to );
635 std::swap( auxAlgo->_value[ BEG_LENGTH_IND ], auxAlgo->_value[ END_LENGTH_IND ]);
638 if ( auxAlgo->computeInternalParameters( theMesh, theC3d, L, from, to, params, false ))
640 if ( isEnd1 ) params.reverse();
641 while ( 1 + nHalf-- )
642 theParameters.pop_back();
643 theParameters.splice( theParameters.end(), params );
647 compensateError(0, vertexLength, f, l, theLength, theC3d, theParameters, true );
651 theParameters.reverse();
656 //=============================================================================
660 //=============================================================================
661 bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh,
662 Adaptor3d_Curve& theC3d,
666 list<double> & theParams,
667 const bool theReverse,
668 bool theConsiderPropagation)
670 MESSAGE("computeInternalParameters");
673 double f = theFirstU, l = theLastU;
675 // Propagation Of Distribution
677 if ( !_mainEdge.IsNull() && _isPropagOfDistribution )
679 TopoDS_Edge mainEdge = TopoDS::Edge( _mainEdge ); // should not be a reference!
680 _gen->Compute( theMesh, mainEdge, /*aShapeOnly=*/true, /*anUpward=*/true);
682 SMESHDS_SubMesh* smDS = theMesh.GetMeshDS()->MeshElements( mainEdge );
684 return error("No mesh on the source edge of Propagation Of Distribution");
685 if ( smDS->NbNodes() < 1 )
686 return true; // 1 segment
688 map< double, const SMDS_MeshNode* > mainEdgeParamsOfNodes;
689 if ( ! SMESH_Algo::GetSortedNodesOnEdge( theMesh.GetMeshDS(), mainEdge, _quadraticMesh,
690 mainEdgeParamsOfNodes, SMDSAbs_Edge ))
691 return error("Bad node parameters on the source edge of Propagation Of Distribution");
692 MESSAGE("mainEdgeParamsOfNodes.size(): " << mainEdgeParamsOfNodes.size());
693 vector< double > segLen( mainEdgeParamsOfNodes.size() - 1 );
695 BRepAdaptor_Curve mainEdgeCurve( mainEdge );
696 map< double, const SMDS_MeshNode* >::iterator
697 u_n2 = mainEdgeParamsOfNodes.begin(), u_n1 = u_n2++;
698 for ( size_t i = 1; i < mainEdgeParamsOfNodes.size(); ++i, ++u_n1, ++u_n2 )
700 segLen[ i-1 ] = GCPnts_AbscissaPoint::Length( mainEdgeCurve,
703 totalLen += segLen[ i-1 ];
705 for ( size_t i = 0; i < segLen.size(); ++i )
706 segLen[ i ] *= theLength / totalLen;
708 size_t iSeg = theReverse ? segLen.size()-1 : 0;
709 size_t dSeg = theReverse ? -1 : +1;
710 double param = theFirstU;
712 for ( int i = 0, nb = segLen.size()-1; i < nb; ++i, iSeg += dSeg )
714 GCPnts_AbscissaPoint Discret( theC3d, segLen[ iSeg ], param );
715 if ( !Discret.IsDone() ) break;
716 param = Discret.Parameter();
717 theParams.push_back( param );
720 if ( nbParams != segLen.size()-1 )
721 return error( SMESH_Comment("Can't divide into ") << segLen.size() << " segments");
723 compensateError( segLen[ theReverse ? segLen.size()-1 : 0 ],
724 segLen[ theReverse ? 0 : segLen.size()-1 ],
725 f, l, theLength, theC3d, theParams, true );
735 MESSAGE("computeInternalParameters: LOCAL_LENGTH MAX_LENGTH NB_SEGMENTS");
738 if ( _hypType == MAX_LENGTH )
740 double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
742 nbseg = 1; // degenerated edge
743 eltSize = theLength / nbseg;
744 nbSegments = (int) nbseg;
746 else if ( _hypType == LOCAL_LENGTH )
748 // Local Length hypothesis
749 double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
752 bool isFound = false;
753 if (theConsiderPropagation && !_mainEdge.IsNull()) // propagated from some other edge
755 // Advanced processing to assure equal number of segments in case of Propagation
756 SMESH_subMesh* sm = theMesh.GetSubMeshContaining(_mainEdge);
758 bool computed = sm->IsMeshComputed();
760 if (sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) {
761 _gen->Compute( theMesh, _mainEdge, /*anUpward=*/true);
762 computed = sm->IsMeshComputed();
766 SMESHDS_SubMesh* smds = sm->GetSubMeshDS();
767 int nb_segments = smds->NbElements();
768 MESSAGE("nb_segments: "<<nb_segments);
769 if (nbseg - 1 <= nb_segments && nb_segments <= nbseg + 1) {
776 if (!isFound) // not found by meshed edge in the propagation chain, use precision
778 double aPrecision = _value[ PRECISION_IND ];
779 double nbseg_prec = ceil((theLength / _value[ BEG_LENGTH_IND ]) - aPrecision);
780 if (nbseg_prec == (nbseg - 1)) nbseg--;
784 nbseg = 1; // degenerated edge
785 eltSize = theLength / nbseg;
786 nbSegments = (int) nbseg;
790 // Number Of Segments hypothesis
791 nbSegments = _ivalue[ NB_SEGMENTS_IND ];
792 if ( nbSegments < 1 ) return false;
793 if ( nbSegments == 1 ) return true;
795 switch (_ivalue[ DISTR_TYPE_IND ])
797 case StdMeshers_NumberOfSegments::DT_Scale:
799 double scale = _value[ SCALE_FACTOR_IND ];
801 if (fabs(scale - 1.0) < Precision::Confusion()) {
802 // special case to avoid division by zero
803 for (int i = 1; i < nbSegments; i++) {
804 double param = f + (l - f) * i / nbSegments;
805 theParams.push_back( param );
808 // general case of scale distribution
812 double alpha = pow(scale, 1.0 / (nbSegments - 1));
813 double factor = (l - f) / (1.0 - pow(alpha, nbSegments));
815 for (int i = 1; i < nbSegments; i++) {
816 double param = f + factor * (1.0 - pow(alpha, i));
817 theParams.push_back( param );
820 const double lenFactor = theLength/(l-f);
821 list<double>::iterator u = theParams.begin(), uEnd = theParams.end();
822 for ( ; u != uEnd; ++u )
824 GCPnts_AbscissaPoint Discret( theC3d, ((*u)-f) * lenFactor, f );
825 if ( Discret.IsDone() )
826 *u = Discret.Parameter();
831 case StdMeshers_NumberOfSegments::DT_TabFunc:
833 FunctionTable func(_vvalue[ TAB_FUNC_IND ], _ivalue[ CONV_MODE_IND ]);
834 return computeParamByFunc(theC3d, f, l, theLength, theReverse,
835 _ivalue[ NB_SEGMENTS_IND ], func,
839 case StdMeshers_NumberOfSegments::DT_ExprFunc:
841 FunctionExpr func(_svalue[ EXPR_FUNC_IND ].c_str(), _ivalue[ CONV_MODE_IND ]);
842 return computeParamByFunc(theC3d, f, l, theLength, theReverse,
843 _ivalue[ NB_SEGMENTS_IND ], func,
847 case StdMeshers_NumberOfSegments::DT_Regular:
848 eltSize = theLength / nbSegments;
849 MESSAGE("eltSize = theLength / nbSegments " << eltSize << " = " << theLength << " / " << nbSegments );
855 GCPnts_UniformAbscissa Discret(theC3d, eltSize, f, l);
856 if ( !Discret.IsDone() )
857 return error( "GCPnts_UniformAbscissa failed");
859 int NbPoints = Min( Discret.NbPoints(), nbSegments + 1 );
860 for ( int i = 2; i < NbPoints; i++ ) // skip 1st and last points
862 double param = Discret.Parameter(i);
863 MESSAGE("computeInternalParameters: theParams " << i << " " << param);
864 theParams.push_back( param );
866 compensateError( eltSize, eltSize, f, l, theLength, theC3d, theParams, true ); // for PAL9899
870 case BEG_END_LENGTH: {
872 // geometric progression: SUM(n) = ( a1 - an * q ) / ( 1 - q ) = theLength
874 double a1 = _value[ BEG_LENGTH_IND ];
875 double an = _value[ END_LENGTH_IND ];
876 double q = ( theLength - a1 ) / ( theLength - an );
877 if ( q < theLength/1e6 || 1.01*theLength < a1 + an)
878 return error ( SMESH_Comment("Invalid segment lengths (")<<a1<<" and "<<an<<") "<<
879 "for an edge of length "<<theLength);
881 double U1 = theReverse ? l : f;
882 double Un = theReverse ? f : l;
884 double eltSize = theReverse ? -a1 : a1;
886 // computes a point on a curve <theC3d> at the distance <eltSize>
887 // from the point of parameter <param>.
888 GCPnts_AbscissaPoint Discret( theC3d, eltSize, param );
889 if ( !Discret.IsDone() ) break;
890 param = Discret.Parameter();
891 if ( f < param && param < l )
892 theParams.push_back( param );
897 compensateError( a1, an, U1, Un, theLength, theC3d, theParams );
898 if (theReverse) theParams.reverse(); // NPAL18025
902 case ARITHMETIC_1D: {
904 // arithmetic progression: SUM(n) = ( an - a1 + q ) * ( a1 + an ) / ( 2 * q ) = theLength
906 double a1 = _value[ BEG_LENGTH_IND ];
907 double an = _value[ END_LENGTH_IND ];
908 if ( 1.01*theLength < a1 + an)
909 return error ( SMESH_Comment("Invalid segment lengths (")<<a1<<" and "<<an<<") "<<
910 "for an edge of length "<<theLength);
912 double q = ( an - a1 ) / ( 2 *theLength/( a1 + an ) - 1 );
913 int n = int(fabs(q) > numeric_limits<double>::min() ? ( 1+( an-a1 )/q ) : ( 1+theLength/a1 ));
915 double U1 = theReverse ? l : f;
916 double Un = theReverse ? f : l;
923 while ( n-- > 0 && eltSize * ( Un - U1 ) > 0 ) {
924 // computes a point on a curve <theC3d> at the distance <eltSize>
925 // from the point of parameter <param>.
926 GCPnts_AbscissaPoint Discret( theC3d, eltSize, param );
927 if ( !Discret.IsDone() ) break;
928 param = Discret.Parameter();
929 if ( param > f && param < l )
930 theParams.push_back( param );
935 compensateError( a1, an, U1, Un, theLength, theC3d, theParams );
936 if (theReverse) theParams.reverse(); // NPAL18025
943 double a1 = _value[ BEG_LENGTH_IND ], an;
944 double q = _value[ END_LENGTH_IND ];
946 double U1 = theReverse ? l : f;
947 double Un = theReverse ? f : l;
955 // computes a point on a curve <theC3d> at the distance <eltSize>
956 // from the point of parameter <param>.
957 GCPnts_AbscissaPoint Discret( theC3d, eltSize, param );
958 if ( !Discret.IsDone() ) break;
959 param = Discret.Parameter();
960 if ( f < param && param < l )
961 theParams.push_back( param );
970 if ( Abs( param - Un ) < 0.2 * Abs( param - theParams.back() ))
972 compensateError( a1, Abs(eltSize), U1, Un, theLength, theC3d, theParams );
974 else if ( Abs( Un - theParams.back() ) <
975 0.2 * Abs( theParams.back() - *(++theParams.rbegin())))
977 theParams.pop_back();
978 compensateError( a1, Abs(an), U1, Un, theLength, theC3d, theParams );
981 if (theReverse) theParams.reverse(); // NPAL18025
986 case FIXED_POINTS_1D: {
987 const std::vector<double>& aPnts = _fpHyp->GetPoints();
988 const std::vector<int>& nbsegs = _fpHyp->GetNbSegments();
989 TColStd_SequenceOfReal Params;
990 for ( size_t i = 0; i < aPnts.size(); i++ )
992 if( aPnts[i]<0.0001 || aPnts[i]>0.9999 ) continue;
994 bool IsExist = false;
995 for(; j<=Params.Length(); j++) {
996 if( fabs(aPnts[i]-Params.Value(j)) < 1e-4 ) {
1000 if( aPnts[i]<Params.Value(j) ) break;
1002 if(!IsExist) Params.InsertBefore(j,aPnts[i]);
1004 double par2, par1, lp;
1013 double eltSize, segmentSize = 0.;
1014 double currAbscissa = 0;
1015 for ( int i = 0; i < Params.Length(); i++ )
1017 int nbseg = ( i > (int)nbsegs.size()-1 ) ? nbsegs[0] : nbsegs[i];
1018 segmentSize = Params.Value(i+1)*theLength - currAbscissa;
1019 currAbscissa += segmentSize;
1020 GCPnts_AbscissaPoint APnt(theC3d, sign*segmentSize, par1);
1021 if( !APnt.IsDone() )
1022 return error( "GCPnts_AbscissaPoint failed");
1023 par2 = APnt.Parameter();
1024 eltSize = segmentSize/nbseg;
1025 GCPnts_UniformAbscissa Discret(theC3d, eltSize, par1, par2);
1027 Discret.Initialize(theC3d, eltSize, par2, par1);
1029 Discret.Initialize(theC3d, eltSize, par1, par2);
1030 if ( !Discret.IsDone() )
1031 return error( "GCPnts_UniformAbscissa failed");
1032 int NbPoints = Discret.NbPoints();
1033 list<double> tmpParams;
1034 for(int i=2; i<NbPoints; i++) {
1035 double param = Discret.Parameter(i);
1036 tmpParams.push_back( param );
1039 compensateError( eltSize, eltSize, par2, par1, segmentSize, theC3d, tmpParams );
1040 tmpParams.reverse();
1043 compensateError( eltSize, eltSize, par1, par2, segmentSize, theC3d, tmpParams );
1045 list<double>::iterator itP = tmpParams.begin();
1046 for(; itP != tmpParams.end(); itP++) {
1047 theParams.push_back( *(itP) );
1049 theParams.push_back( par2 );
1054 int nbseg = ( (int)nbsegs.size() > Params.Length() ) ? nbsegs[Params.Length()] : nbsegs[0];
1055 segmentSize = theLength - currAbscissa;
1056 eltSize = segmentSize/nbseg;
1057 GCPnts_UniformAbscissa Discret;
1059 Discret.Initialize(theC3d, eltSize, par1, lp);
1061 Discret.Initialize(theC3d, eltSize, lp, par1);
1062 if ( !Discret.IsDone() )
1063 return error( "GCPnts_UniformAbscissa failed");
1064 int NbPoints = Discret.NbPoints();
1065 list<double> tmpParams;
1066 for(int i=2; i<NbPoints; i++) {
1067 double param = Discret.Parameter(i);
1068 tmpParams.push_back( param );
1071 compensateError( eltSize, eltSize, lp, par1, segmentSize, theC3d, tmpParams );
1072 tmpParams.reverse();
1075 compensateError( eltSize, eltSize, par1, lp, segmentSize, theC3d, tmpParams );
1077 list<double>::iterator itP = tmpParams.begin();
1078 for(; itP != tmpParams.end(); itP++) {
1079 theParams.push_back( *(itP) );
1083 theParams.reverse(); // NPAL18025
1090 GCPnts_UniformDeflection Discret(theC3d, _value[ DEFLECTION_IND ], f, l, true);
1091 if ( !Discret.IsDone() )
1094 int NbPoints = Discret.NbPoints();
1095 for ( int i = 2; i < NbPoints; i++ )
1097 double param = Discret.Parameter(i);
1098 theParams.push_back( param );
1109 //=============================================================================
1113 //=============================================================================
1115 bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & theShape)
1118 if ( _hypType == NONE )
1121 if ( _hypType == ADAPTIVE )
1123 _adaptiveHyp->GetAlgo()->InitComputeError();
1124 _adaptiveHyp->GetAlgo()->Compute( theMesh, theShape );
1125 return error( _adaptiveHyp->GetAlgo()->GetComputeError() );
1128 SMESHDS_Mesh * meshDS = theMesh.GetMeshDS();
1130 const TopoDS_Edge & EE = TopoDS::Edge(theShape);
1131 TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
1132 int shapeID = meshDS->ShapeToIndex( E );
1135 Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
1137 TopoDS_Vertex VFirst, VLast;
1138 TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l
1140 ASSERT(!VFirst.IsNull());
1141 ASSERT(!VLast.IsNull());
1142 const SMDS_MeshNode * idFirst = SMESH_Algo::VertexNode( VFirst, meshDS );
1143 const SMDS_MeshNode * idLast = SMESH_Algo::VertexNode( VLast, meshDS );
1144 if (!idFirst || !idLast)
1145 return error( COMPERR_BAD_INPUT_MESH, "No node on vertex");
1147 // remove elements created by e.g. patern mapping (PAL21999)
1148 // CLEAN event is incorrectly ptopagated seemingly due to Propagation hyp
1149 // so TEMPORARY solution is to clean the submesh manually
1150 //theMesh.GetSubMesh(theShape)->ComputeStateEngine( SMESH_subMesh::CLEAN );
1151 if (SMESHDS_SubMesh * subMeshDS = meshDS->MeshElements(theShape))
1153 SMDS_ElemIteratorPtr ite = subMeshDS->GetElements();
1155 meshDS->RemoveFreeElement(ite->next(), subMeshDS);
1156 SMDS_NodeIteratorPtr itn = subMeshDS->GetNodes();
1157 while (itn->more()) {
1158 const SMDS_MeshNode * node = itn->next();
1159 if ( node->NbInverseElements() == 0 )
1160 meshDS->RemoveFreeNode(node, subMeshDS);
1162 meshDS->RemoveNode(node);
1166 if (!Curve.IsNull())
1168 list< double > params;
1169 bool reversed = false;
1170 if ( theMesh.GetShapeToMesh().ShapeType() >= TopAbs_WIRE ) {
1171 // if the shape to mesh is WIRE or EDGE
1172 reversed = ( EE.Orientation() == TopAbs_REVERSED );
1174 if ( !_mainEdge.IsNull() ) {
1175 // take into account reversing the edge the hypothesis is propagated from
1176 // (_mainEdge.Orientation() marks mutual orientation of EDGEs in propagation chain)
1177 reversed = ( _mainEdge.Orientation() == TopAbs_REVERSED );
1178 if ( !_isPropagOfDistribution ) {
1179 int mainID = meshDS->ShapeToIndex(_mainEdge);
1180 if ( std::find( _revEdgesIDs.begin(), _revEdgesIDs.end(), mainID) != _revEdgesIDs.end())
1181 reversed = !reversed;
1184 // take into account this edge reversing
1185 if ( std::find( _revEdgesIDs.begin(), _revEdgesIDs.end(), shapeID) != _revEdgesIDs.end())
1186 reversed = !reversed;
1188 BRepAdaptor_Curve C3d( E );
1189 double length = EdgeLength( E );
1190 if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, reversed, true )) {
1193 redistributeNearVertices( theMesh, C3d, length, params, VFirst, VLast );
1195 // edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex)
1196 // only internal nodes receive an edge position with param on curve
1198 const SMDS_MeshNode * idPrev = idFirst;
1211 for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++) {
1212 double param = *itU;
1213 gp_Pnt P = Curve->Value(param);
1215 //Add the Node in the DataStructure
1216 SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
1217 MESSAGE("meshDS->AddNode parameter " << param << " coords=" << "("<< P.X() <<", " << P.Y() << ", " << P.Z() << ")");
1218 meshDS->SetNodeOnEdge(node, shapeID, param);
1220 if(_quadraticMesh) {
1221 // create medium node
1222 double prm = ( parPrev + param )/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(idPrev, node, NM);
1227 meshDS->SetMeshElementOnShape(edge, shapeID);
1230 SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
1231 meshDS->SetMeshElementOnShape(edge, shapeID);
1237 if(_quadraticMesh) {
1238 double prm = ( parPrev + parLast )/2;
1239 gp_Pnt PM = Curve->Value(prm);
1240 SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
1241 meshDS->SetNodeOnEdge(NM, shapeID, prm);
1242 SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast, NM);
1243 meshDS->SetMeshElementOnShape(edge, shapeID);
1246 SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast);
1247 meshDS->SetMeshElementOnShape(edge, shapeID);
1252 //MESSAGE("************* Degenerated edge! *****************");
1254 // Edge is a degenerated Edge : We put n = 5 points on the edge.
1255 const int NbPoints = 5;
1256 BRep_Tool::Range( E, f, l ); // PAL15185
1257 double du = (l - f) / (NbPoints - 1);
1259 gp_Pnt P = BRep_Tool::Pnt(VFirst);
1261 const SMDS_MeshNode * idPrev = idFirst;
1262 for (int i = 2; i < NbPoints; i++) {
1263 double param = f + (i - 1) * du;
1264 SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
1265 if(_quadraticMesh) {
1266 // create medium node
1267 double prm = param - du/2.;
1268 SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z());
1269 meshDS->SetNodeOnEdge(NM, shapeID, prm);
1270 SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node, NM);
1271 meshDS->SetMeshElementOnShape(edge, shapeID);
1274 SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
1275 meshDS->SetMeshElementOnShape(edge, shapeID);
1277 meshDS->SetNodeOnEdge(node, shapeID, param);
1280 if(_quadraticMesh) {
1281 // create medium node
1282 double prm = l - du/2.;
1283 SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z());
1284 meshDS->SetNodeOnEdge(NM, shapeID, prm);
1285 SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast, NM);
1286 meshDS->SetMeshElementOnShape(edge, shapeID);
1289 SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast);
1290 meshDS->SetMeshElementOnShape(edge, shapeID);
1297 //=============================================================================
1301 //=============================================================================
1303 bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh,
1304 const TopoDS_Shape & theShape,
1305 MapShapeNbElems& aResMap)
1307 if ( _hypType == NONE )
1310 if ( _hypType == ADAPTIVE )
1312 _adaptiveHyp->GetAlgo()->InitComputeError();
1313 _adaptiveHyp->GetAlgo()->Evaluate( theMesh, theShape, aResMap );
1314 return error( _adaptiveHyp->GetAlgo()->GetComputeError() );
1317 const TopoDS_Edge & EE = TopoDS::Edge(theShape);
1318 TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
1321 Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
1323 TopoDS_Vertex VFirst, VLast;
1324 TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l
1326 ASSERT(!VFirst.IsNull());
1327 ASSERT(!VLast.IsNull());
1329 std::vector<int> aVec(SMDSEntity_Last,0);
1331 if (!Curve.IsNull()) {
1332 list< double > params;
1334 BRepAdaptor_Curve C3d( E );
1335 double length = EdgeLength( E );
1336 if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, false, true )) {
1337 SMESH_subMesh * sm = theMesh.GetSubMesh(theShape);
1338 aResMap.insert(std::make_pair(sm,aVec));
1339 SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
1340 smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
1343 redistributeNearVertices( theMesh, C3d, length, params, VFirst, VLast );
1345 if(_quadraticMesh) {
1346 aVec[SMDSEntity_Node] = 2*params.size() + 1;
1347 aVec[SMDSEntity_Quad_Edge] = params.size() + 1;
1350 aVec[SMDSEntity_Node] = params.size();
1351 aVec[SMDSEntity_Edge] = params.size() + 1;
1356 //MESSAGE("************* Degenerated edge! *****************");
1357 // Edge is a degenerated Edge : We put n = 5 points on the edge.
1358 if(_quadraticMesh) {
1359 aVec[SMDSEntity_Node] = 11;
1360 aVec[SMDSEntity_Quad_Edge] = 6;
1363 aVec[SMDSEntity_Node] = 5;
1364 aVec[SMDSEntity_Edge] = 6;
1368 SMESH_subMesh * sm = theMesh.GetSubMesh(theShape);
1369 aResMap.insert(std::make_pair(sm,aVec));
1375 //=============================================================================
1377 * See comments in SMESH_Algo.cxx
1379 //=============================================================================
1381 const list <const SMESHDS_Hypothesis *> &
1382 StdMeshers_Regular_1D::GetUsedHypothesis(SMESH_Mesh & aMesh,
1383 const TopoDS_Shape & aShape,
1384 const bool ignoreAuxiliary)
1386 _usedHypList.clear();
1387 _mainEdge.Nullify();
1389 SMESH_HypoFilter auxiliaryFilter( SMESH_HypoFilter::IsAuxiliary() );
1390 const SMESH_HypoFilter* compatibleFilter = GetCompatibleHypoFilter(/*ignoreAux=*/true );
1392 // get non-auxiliary assigned directly to aShape
1393 int nbHyp = aMesh.GetHypotheses( aShape, *compatibleFilter, _usedHypList, false );
1395 if (nbHyp == 0 && aShape.ShapeType() == TopAbs_EDGE)
1397 // Check, if propagated from some other edge
1398 _mainEdge = StdMeshers_Propagation::GetPropagationSource( aMesh, aShape,
1399 _isPropagOfDistribution );
1400 if ( !_mainEdge.IsNull() )
1402 // Propagation of 1D hypothesis from <aMainEdge> on this edge;
1403 // get non-auxiliary assigned to _mainEdge
1404 nbHyp = aMesh.GetHypotheses( _mainEdge, *compatibleFilter, _usedHypList, true );
1408 if (nbHyp == 0) // nothing propagated nor assigned to aShape
1410 SMESH_Algo::GetUsedHypothesis( aMesh, aShape, ignoreAuxiliary );
1411 nbHyp = _usedHypList.size();
1415 // get auxiliary hyps from aShape
1416 aMesh.GetHypotheses( aShape, auxiliaryFilter, _usedHypList, true );
1418 if ( nbHyp > 1 && ignoreAuxiliary )
1419 _usedHypList.clear(); //only one compatible non-auxiliary hypothesis allowed
1421 return _usedHypList;
1424 //================================================================================
1426 * \brief Pass CancelCompute() to a child algorithm
1428 //================================================================================
1430 void StdMeshers_Regular_1D::CancelCompute()
1432 SMESH_Algo::CancelCompute();
1433 if ( _hypType == ADAPTIVE )
1434 _adaptiveHyp->GetAlgo()->CancelCompute();