#include "StdMeshers_Regular_1D.hxx"#include "StdMeshers_Distribution.hxx"#include "StdMeshers_Arithmetic1D.hxx"#include "StdMeshers_AutomaticLength.hxx"#include "StdMeshers_Deflection1D.hxx"#include "StdMeshers_LocalLength.hxx"#include "StdMeshers_MaxLength.hxx"#include "StdMeshers_NumberOfSegments.hxx"#include "StdMeshers_Propagation.hxx"#include "StdMeshers_SegmentLengthAroundVertex.hxx"#include "StdMeshers_StartEndLength.hxx"#include "SMESH_Gen.hxx"#include "SMESH_Mesh.hxx"#include "SMESH_HypoFilter.hxx"#include "SMESH_subMesh.hxx"#include "SMESH_subMeshEventListener.hxx"#include "SMESH_Comment.hxx"#include "SMDS_MeshElement.hxx"#include "SMDS_MeshNode.hxx"#include "Utils_SALOME_Exception.hxx"#include "utilities.h"#include <BRepAdaptor_Curve.hxx>#include <BRep_Tool.hxx>#include <GCPnts_AbscissaPoint.hxx>#include <GCPnts_UniformAbscissa.hxx>#include <GCPnts_UniformDeflection.hxx>#include <Precision.hxx>#include <TopExp.hxx>#include <TopExp_Explorer.hxx>#include <TopoDS.hxx>#include <TopoDS_Edge.hxx>#include <string>#include <limits>
Go to the source code of this file.
Functions | |
| static bool | computeParamByFunc (Adaptor3d_Curve &C3d, double first, double last, double length, bool theReverse, int nbSeg, Function &func, list< double > &theParams) |
| static void | compensateError (double a1, double an, double U1, double Un, double length, Adaptor3d_Curve &C3d, list< double > &theParams, bool adjustNeighbors2an=false) |
| adjust internal node parameters so that the last segment length == an | |
| static void compensateError | ( | double | a1, |
| double | an, | ||
| double | U1, | ||
| double | Un, | ||
| double | length, | ||
| Adaptor3d_Curve & | C3d, | ||
| list< double > & | theParams, | ||
| bool | adjustNeighbors2an = false |
||
| ) | [static] |
adjust internal node parameters so that the last segment length == an
| a1 | - the first segment length |
| an | - the last segment length |
| U1 | - the first edge parameter |
| Un | - the last edge parameter |
| length | - the edge length |
| C3d | - the edge curve |
| theParams | - internal node parameters to adjust |
| adjustNeighbors2an | - to adjust length of segments next to the last one and not to remove parameters |
Definition at line 349 of file StdMeshers_Regular_1D.cxx.
References Abs(), and reverse().
Referenced by StdMeshers_Regular_1D.computeInternalParameters(), and StdMeshers_Regular_1D.redistributeNearVertices().
{
int i, nPar = theParams.size();
if ( a1 + an < length && nPar > 1 )
{
bool reverse = ( U1 > Un );
GCPnts_AbscissaPoint Discret(C3d, reverse ? an : -an, Un);
if ( !Discret.IsDone() )
return;
double Utgt = Discret.Parameter(); // target value of the last parameter
list<double>::reverse_iterator itU = theParams.rbegin();
double Ul = *itU++; // real value of the last parameter
double dUn = Utgt - Ul; // parametric error of <an>
if ( Abs(dUn) <= Precision::Confusion() )
return;
double dU = Abs( Ul - *itU ); // parametric length of the last but one segment
if ( adjustNeighbors2an || Abs(dUn) < 0.5 * dU ) { // last segment is a bit shorter than it should
// move the last parameter to the edge beginning
}
else { // last segment is much shorter than it should -> remove the last param and
theParams.pop_back(); nPar--; // move the rest points toward the edge end
dUn = Utgt - theParams.back();
}
double q = dUn / ( nPar - 1 );
if ( !adjustNeighbors2an )
{
q = dUn / ( Utgt - Un ); // (signed) factor of segment length change
for ( itU = theParams.rbegin(), i = 1; i < nPar; i++ ) {
double prevU = *itU;
(*itU) += dUn;
++itU;
dUn = q * (*itU - prevU) * (prevU-U1)/(Un-U1);
}
}
else {
theParams.back() += dUn;
double sign = reverse ? -1 : 1;
double prevU = theParams.back();
itU = theParams.rbegin();
for ( ++itU, i = 2; i < nPar; ++itU, i++ ) {
double newU = *itU + dUn;
if ( newU*sign < prevU*sign ) {
prevU = *itU = newU;
dUn -= q;
}
else { // set U between prevU and next valid param
list<double>::reverse_iterator itU2 = itU;
++itU2;
int nb = 2;
while ( (*itU2)*sign > prevU*sign ) {
++itU2; ++nb;
}
dU = ( *itU2 - prevU ) / nb;
while ( itU != itU2 ) {
*itU += dU; ++itU;
}
break;
}
}
}
}
}
| static bool computeParamByFunc | ( | Adaptor3d_Curve & | C3d, |
| double | first, | ||
| double | last, | ||
| double | length, | ||
| bool | theReverse, | ||
| int | nbSeg, | ||
| Function & | func, | ||
| list< double > & | theParams | ||
| ) | [static] |
Definition at line 278 of file StdMeshers_Regular_1D.cxx.
References buildDistribution(), MESSAGE, and ex13_hole1partial.x.
Referenced by StdMeshers_Regular_1D.computeInternalParameters().
{
// never do this way
//OSD::SetSignal( true );
if (nbSeg <= 0)
return false;
MESSAGE( "computeParamByFunc" );
int nbPnt = 1 + nbSeg;
vector<double> x(nbPnt, 0.);
if (!buildDistribution(func, 0.0, 1.0, nbSeg, x, 1E-4))
return false;
MESSAGE( "Points:\n" );
char buf[1024];
for ( int i=0; i<=nbSeg; i++ )
{
sprintf( buf, "%f\n", float(x[i] ) );
MESSAGE( buf );
}
// apply parameters in range [0,1] to the space of the curve
double prevU = first;
double sign = 1.;
if (theReverse)
{
prevU = last;
sign = -1.;
}
for( int i = 1; i < nbSeg; i++ )
{
double curvLength = length * (x[i] - x[i-1]) * sign;
GCPnts_AbscissaPoint Discret( C3d, curvLength, prevU );
if ( !Discret.IsDone() )
return false;
double U = Discret.Parameter();
if ( U > first && U < last )
theParams.push_back( U );
else
return false;
prevU = U;
}
if ( theReverse )
theParams.reverse();
return true;
}