X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FStdMeshers%2FStdMeshers_Regular_1D.cxx;h=951414c53b7673d1b0d19bfdde8f9ef3d0461053;hb=d8f644ca3d4ce62f2ef41d4aacb52f5bb1221df3;hp=3b5abcbee4b54adbc74d55b999008f90a482bb02;hpb=184f00f38ef65b5d58b798e8c13042c16e030a4f;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_Regular_1D.cxx b/src/StdMeshers/StdMeshers_Regular_1D.cxx index 3b5abcbee..951414c53 100644 --- a/src/StdMeshers/StdMeshers_Regular_1D.cxx +++ b/src/StdMeshers/StdMeshers_Regular_1D.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -19,12 +19,13 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH SMESH : implementaion of SMESH idl descriptions // File : StdMeshers_Regular_1D.cxx // Moved here from SMESH_Regular_1D.cxx // Author : Paul RASCLE, EDF // Module : SMESH - +// #include "StdMeshers_Regular_1D.hxx" #include "StdMeshers_Distribution.hxx" @@ -63,6 +64,7 @@ #include #include +#include using namespace std; @@ -73,22 +75,24 @@ using namespace std; //============================================================================= StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId, int studyId, - SMESH_Gen * gen):SMESH_1D_Algo(hypId, studyId, gen) + SMESH_Gen * gen):SMESH_1D_Algo(hypId, studyId, gen) { - MESSAGE("StdMeshers_Regular_1D::StdMeshers_Regular_1D"); - _name = "Regular_1D"; - _shapeType = (1 << TopAbs_EDGE); - - _compatibleHypothesis.push_back("LocalLength"); - _compatibleHypothesis.push_back("MaxLength"); - _compatibleHypothesis.push_back("NumberOfSegments"); - _compatibleHypothesis.push_back("StartEndLength"); - _compatibleHypothesis.push_back("Deflection1D"); - _compatibleHypothesis.push_back("Arithmetic1D"); - _compatibleHypothesis.push_back("AutomaticLength"); - - _compatibleHypothesis.push_back("QuadraticMesh"); // auxiliary !!! - _compatibleHypothesis.push_back("Propagation"); // auxiliary !!! + MESSAGE("StdMeshers_Regular_1D::StdMeshers_Regular_1D"); + _name = "Regular_1D"; + _shapeType = (1 << TopAbs_EDGE); + _fpHyp = 0; + + _compatibleHypothesis.push_back("LocalLength"); + _compatibleHypothesis.push_back("MaxLength"); + _compatibleHypothesis.push_back("NumberOfSegments"); + _compatibleHypothesis.push_back("StartEndLength"); + _compatibleHypothesis.push_back("Deflection1D"); + _compatibleHypothesis.push_back("Arithmetic1D"); + _compatibleHypothesis.push_back("FixedPoints1D"); + _compatibleHypothesis.push_back("AutomaticLength"); + + _compatibleHypothesis.push_back("QuadraticMesh"); // auxiliary !!! + _compatibleHypothesis.push_back("Propagation"); // auxiliary !!! } //============================================================================= @@ -115,9 +119,8 @@ bool StdMeshers_Regular_1D::CheckHypothesis _hypType = NONE; _quadraticMesh = false; - const bool ignoreAuxiliaryHyps = false; const list & hyps = - GetUsedHypothesis(aMesh, aShape, ignoreAuxiliaryHyps); + GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliaryHyps=*/false); // find non-auxiliary hypothesis const SMESHDS_Hypothesis *theHyp = 0; @@ -218,6 +221,16 @@ bool StdMeshers_Regular_1D::CheckHypothesis aStatus = SMESH_Hypothesis::HYP_OK; } + else if (hypName == "FixedPoints1D") { + _fpHyp = dynamic_cast (theHyp); + ASSERT(_fpHyp); + _hypType = FIXED_POINTS_1D; + + _revEdgesIDs = _fpHyp->GetReversedEdges(); + + aStatus = SMESH_Hypothesis::HYP_OK; + } + else if (hypName == "StartEndLength") { const StdMeshers_StartEndLength * hyp = @@ -312,6 +325,8 @@ static bool computeParamByFunc(Adaptor3d_Curve& C3d, double first, double last, return false; prevU = U; } + if ( theReverse ) + theParams.reverse(); return true; } @@ -361,10 +376,14 @@ static void compensateError(double a1, double an, } double q = dUn / ( nPar - 1 ); - if ( !adjustNeighbors2an ) { - for ( itU = theParams.rbegin(), i = 1; i < nPar; itU++, i++ ) { + if ( !adjustNeighbors2an ) + { + q = Abs( dUn / ( Utgt - Un )); // factor of segment length change + for ( itU = theParams.rbegin(), i = 1; i < nPar; i++ ) { + double prevU = *itU; (*itU) += dUn; - dUn -= q; + ++itU; + dUn = q * (*itU - prevU) * (prevU-U1)/(Un-U1); } } else { @@ -611,7 +630,7 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh, bool computed = sm->IsMeshComputed(); if (!computed) { if (sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) { - sm->ComputeStateEngine(SMESH_subMesh::COMPUTE); + _gen->Compute( theMesh, _mainEdge, /*anUpward=*/true); computed = sm->IsMeshComputed(); } } @@ -715,6 +734,9 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh, double a1 = _value[ BEG_LENGTH_IND ]; double an = _value[ END_LENGTH_IND ]; double q = ( theLength - a1 ) / ( theLength - an ); + if ( q < theLength/1e6 || 1.01*theLength < a1 + an) + return error ( SMESH_Comment("Invalid segment lengths (")< numeric_limits::min() ? ( 1+( an-a1 )/q ) : ( 1+theLength/a1 )); double U1 = theReverse ? l : f; double Un = theReverse ? f : l; @@ -773,6 +798,107 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh, return true; } + case FIXED_POINTS_1D: { + const std::vector& aPnts = _fpHyp->GetPoints(); + const std::vector& nbsegs = _fpHyp->GetNbSegments(); + int i = 0; + TColStd_SequenceOfReal Params; + for(; i0.9999 ) continue; + int j=1; + bool IsExist = false; + for(; j<=Params.Length(); j++) { + if( fabs(aPnts[i]-Params.Value(j)) < 1e-4 ) { + IsExist = true; + break; + } + if( aPnts[i] nbsegs.size()-1 ) ? nbsegs[0] : nbsegs[i]; + segmentSize = Params.Value(i+1)*theLength - currAbscissa; + currAbscissa += segmentSize; + GCPnts_AbscissaPoint APnt(theC3d, sign*segmentSize, par1); + if( !APnt.IsDone() ) + return error( "GCPnts_AbscissaPoint failed"); + par2 = APnt.Parameter(); + eltSize = segmentSize/nbseg; + GCPnts_UniformAbscissa Discret(theC3d, eltSize, par1, par2); + if(theReverse) + Discret.Initialize(theC3d, eltSize, par2, par1); + else + Discret.Initialize(theC3d, eltSize, par1, par2); + if ( !Discret.IsDone() ) + return error( "GCPnts_UniformAbscissa failed"); + int NbPoints = Discret.NbPoints(); + list tmpParams; + for(int i=2; i::iterator itP = tmpParams.begin(); + for(; itP != tmpParams.end(); itP++) { + theParams.push_back( *(itP) ); + } + theParams.push_back( par2 ); + + par1 = par2; + } + // add for last + int nbseg = ( nbsegs.size() > Params.Length() ) ? nbsegs[Params.Length()] : nbsegs[0]; + segmentSize = theLength - currAbscissa; + eltSize = segmentSize/nbseg; + GCPnts_UniformAbscissa Discret; + if(theReverse) + Discret.Initialize(theC3d, eltSize, par1, lp); + else + Discret.Initialize(theC3d, eltSize, lp, par1); + if ( !Discret.IsDone() ) + return error( "GCPnts_UniformAbscissa failed"); + int NbPoints = Discret.NbPoints(); + list tmpParams; + for(int i=2; i::iterator itP = tmpParams.begin(); + for(; itP != tmpParams.end(); itP++) { + theParams.push_back( *(itP) ); + } + + if (theReverse) { + theParams.reverse(); // NPAL18025 + } + return true; + } + case DEFLECTION: { GCPnts_UniformDeflection Discret(theC3d, _value[ DEFLECTION_IND ], f, l, true); @@ -824,17 +950,43 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t if (!idFirst || !idLast) return error( COMPERR_BAD_INPUT_MESH, "No node on vertex"); + // remove elements created by e.g. patern mapping (PAL21999) + // CLEAN event is incorrectly ptopagated seemingly due to Propagation hyp + // so TEMPORARY solution is to clean the submesh manually + //theMesh.GetSubMesh(theShape)->ComputeStateEngine( SMESH_subMesh::CLEAN ); + if (SMESHDS_SubMesh * subMeshDS = meshDS->MeshElements(theShape)) + { + SMDS_ElemIteratorPtr ite = subMeshDS->GetElements(); + while (ite->more()) + meshDS->RemoveFreeElement(ite->next(), subMeshDS); + SMDS_NodeIteratorPtr itn = subMeshDS->GetNodes(); + while (itn->more()) { + const SMDS_MeshNode * node = itn->next(); + if ( node->NbInverseElements() == 0 ) + meshDS->RemoveFreeNode(node, subMeshDS); + else + meshDS->RemoveNode(node); + } + } + if (!Curve.IsNull()) { list< double > params; bool reversed = false; - if ( !_mainEdge.IsNull() ) + if ( theMesh.GetShapeToMesh().ShapeType() >= TopAbs_WIRE ) { + // if the shape to mesh is WIRE or EDGE + reversed = ( EE.Orientation() == TopAbs_REVERSED ); + } + if ( !_mainEdge.IsNull() ) { + // take into account reversing the edge the hypothesis is propagated from reversed = ( _mainEdge.Orientation() == TopAbs_REVERSED ); - else if ( _revEdgesIDs.size() > 0 ) { - for ( int i = 0; i < _revEdgesIDs.size(); i++) - if ( _revEdgesIDs[i] == shapeID ) - reversed = true; + int mainID = meshDS->ShapeToIndex(_mainEdge); + if ( std::find( _revEdgesIDs.begin(), _revEdgesIDs.end(), mainID) != _revEdgesIDs.end()) + reversed = !reversed; } + // take into account this edge reversing + if ( std::find( _revEdgesIDs.begin(), _revEdgesIDs.end(), shapeID) != _revEdgesIDs.end()) + reversed = !reversed; BRepAdaptor_Curve C3d( E ); double length = EdgeLength( E ); @@ -859,7 +1011,6 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t parLast = f; } */ - for (list::iterator itU = params.begin(); itU != params.end(); itU++) { double param = *itU; gp_Pnt P = Curve->Value(param); @@ -952,13 +1103,13 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t //============================================================================= bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh, - const TopoDS_Shape & theShape, - MapShapeNbElems& aResMap) + const TopoDS_Shape & theShape, + MapShapeNbElems& aResMap) { if ( _hypType == NONE ) return false; - SMESHDS_Mesh * meshDS = theMesh.GetMeshDS(); + //SMESHDS_Mesh * meshDS = theMesh.GetMeshDS(); const TopoDS_Edge & EE = TopoDS::Edge(theShape); TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); @@ -973,18 +1124,14 @@ bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh, ASSERT(!VFirst.IsNull()); ASSERT(!VLast.IsNull()); - std::vector aVec(17); - for(int i=0; i<17; i++) aVec[i] = 0; + std::vector aVec(SMDSEntity_Last,0); if (!Curve.IsNull()) { list< double > params; - bool reversed = false; - if ( !_mainEdge.IsNull() ) - reversed = ( _mainEdge.Orientation() == TopAbs_REVERSED ); BRepAdaptor_Curve C3d( E ); double length = EdgeLength( E ); - if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, reversed, true )) { + if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, false, true )) { SMESH_subMesh * sm = theMesh.GetSubMesh(theShape); aResMap.insert(std::make_pair(sm,aVec)); SMESH_ComputeErrorPtr& smError = sm->GetComputeError(); @@ -994,12 +1141,12 @@ bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh, redistributeNearVertices( theMesh, C3d, length, params, VFirst, VLast ); if(_quadraticMesh) { - aVec[0] = 2*params.size() + 1; - aVec[2] = params.size() + 1; + aVec[SMDSEntity_Node] = 2*params.size() + 1; + aVec[SMDSEntity_Quad_Edge] = params.size() + 1; } else { - aVec[0] = params.size(); - aVec[1] = params.size() + 1; + aVec[SMDSEntity_Node] = params.size(); + aVec[SMDSEntity_Edge] = params.size() + 1; } } @@ -1007,12 +1154,12 @@ bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh, //MESSAGE("************* Degenerated edge! *****************"); // Edge is a degenerated Edge : We put n = 5 points on the edge. if(_quadraticMesh) { - aVec[0] = 11; - aVec[2] = 6; + aVec[SMDSEntity_Node] = 11; + aVec[SMDSEntity_Quad_Edge] = 6; } else { - aVec[0] = 5; - aVec[1] = 6; + aVec[SMDSEntity_Node] = 5; + aVec[SMDSEntity_Edge] = 6; } } @@ -1039,10 +1186,9 @@ StdMeshers_Regular_1D::GetUsedHypothesis(SMESH_Mesh & aMesh, SMESH_HypoFilter auxiliaryFilter, compatibleFilter; auxiliaryFilter.Init( SMESH_HypoFilter::IsAuxiliary() ); - const bool ignoreAux = true; - InitCompatibleHypoFilter( compatibleFilter, ignoreAux ); + InitCompatibleHypoFilter( compatibleFilter, /*ignoreAux=*/true ); - // get non-auxiliary assigned to aShape + // get non-auxiliary assigned directly to aShape int nbHyp = aMesh.GetHypotheses( aShape, compatibleFilter, _usedHypList, false ); if (nbHyp == 0 && aShape.ShapeType() == TopAbs_EDGE)