From 244d1c40e9722a5ffe66ee6cffdcda049b0af0cd Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 19 Jun 2007 16:49:27 +0000 Subject: [PATCH] PAL16231 (3D Extrusion produced crossing hexahedrons) improve copmuting point parameters by varying square and not function and using parameters hint --- src/SMESH/SMESH_Block.cxx | 185 ++++++++++++++++++++++---------------- src/SMESH/SMESH_Block.hxx | 13 ++- 2 files changed, 118 insertions(+), 80 deletions(-) diff --git a/src/SMESH/SMESH_Block.cxx b/src/SMESH/SMESH_Block.cxx index aca4f4912..6f45ca370 100644 --- a/src/SMESH/SMESH_Block.cxx +++ b/src/SMESH/SMESH_Block.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -55,7 +56,7 @@ using namespace std; -#define SQRT_FUNC 0 +//#define DEBUG_PARAM_COMPUTE //================================================================================ /*! @@ -428,12 +429,12 @@ Standard_Boolean SMESH_Block::Value(const math_Vector& theXYZ, math_Vector& theF { gp_XYZ P, params( theXYZ(1), theXYZ(2), theXYZ(3) ); if ( params.IsEqual( myParam, DBL_MIN )) { // same param - theFxyz( 1 ) = myValues[ 0 ]; + theFxyz( 1 ) = funcValue( myValues[ SQUARE_DIST ]); } else { ShellPoint( params, P ); gp_Vec dP( P - myPoint ); - theFxyz(1) = SQRT_FUNC ? dP.SquareMagnitude() : dP.Magnitude(); + theFxyz(1) = funcValue( dP.SquareMagnitude() ); } return true; } @@ -451,44 +452,52 @@ Standard_Boolean SMESH_Block::Derivatives(const math_Vector& XYZ,math_Matrix& Df } //======================================================================= -//function : Values +//function : Constructor //purpose : //======================================================================= -//#define DEBUG_PARAM_COMPUTE +SMESH_Block::SMESH_Block(): + myNbIterations(0), + mySumDist(0.), + myTolerance(-1.) // to be re-initialized +{ +} + +//======================================================================= +//function : Values +//purpose : +//======================================================================= Standard_Boolean SMESH_Block::Values(const math_Vector& theXYZ, math_Vector& theFxyz, math_Matrix& theDf) { -// MESSAGE( endl<<"SMESH_Block::Values( "< myPoint), P is defined by the 2 other derivative direction -// int iPrev = ( iP ? iP - 1 : 2 ); -// int iNext = ( iP == 2 ? 0 : iP + 1 ); -// gp_Vec plnNorm = drv[ iPrev ].Crossed( drv [ iNext ] ); -// double Direc = plnNorm * drv[ iP ]; -// if ( Abs(Direc) <= DBL_MIN ) -// theDf( 1, iP + 1 ) = dP * drv[ iP ]; -// else { -// double Dis = plnNorm * P - plnNorm * myPoint; -// theDf( 1, iP + 1 ) = Dis/Direc; -// } +#else + // Distance from P to plane passing through myPoint and defined + // by the 2 other derivative directions: + // like IntAna_IntConicQuad::Perform (const gp_Lin& L, const gp_Pln& P) + // where L is (P -> myPoint), P is defined by the 2 other derivative direction + int iPrev = ( iP ? iP - 1 : 2 ); + int iNext = ( iP == 2 ? 0 : iP + 1 ); + gp_Vec plnNorm = drv[ iPrev ].Crossed( drv [ iNext ] ); + double Direc = plnNorm * drv[ iP ]; + if ( Abs(Direc) <= DBL_MIN ) + theDf( 1, iP + 1 ) = dP * drv[ iP ]; + else { + double Dis = plnNorm * P - plnNorm * myPoint; + theDf( 1, iP + 1 ) = Dis/Direc; + } +#endif } #ifdef DEBUG_PARAM_COMPUTE cout << "F = " << theFxyz(1) << " DRV: " << theDf(1,1) << " " << theDf(1,2) << " " << theDf(1,3) << endl; + myNbIterations +=3; // how many times call ShellPoint() #endif - //myNbIterations +=3; // how many time call ShellPoint() // store better values - myParam = params; - myValues[0]= theFxyz(1); - myValues[1]= theDf(1,1); - myValues[2]= theDf(1,2); - myValues[3]= theDf(1,3); - -// SCRUTE( theFxyz(1) ); -// SCRUTE( theDf( 1,1 )); -// SCRUTE( theDf( 1,2 )); -// SCRUTE( theDf( 1,3 )); + myParam = params; + myValues[SQUARE_DIST]= sqDist; + myValues[DRV_1] = theDf(1,DRV_1); + myValues[DRV_2] = theDf(1,DRV_2); + myValues[DRV_3] = theDf(1,DRV_3); } return true; @@ -558,7 +565,8 @@ Standard_Boolean SMESH_Block::Values(const math_Vector& theXYZ, bool SMESH_Block::ComputeParameters(const gp_Pnt& thePoint, gp_XYZ& theParams, - const int theShapeID) + const int theShapeID, + const gp_XYZ& theParamsHint) { if ( VertexParameters( theShapeID, theParams )) return true; @@ -575,19 +583,22 @@ bool SMESH_Block::ComputeParameters(const gp_Pnt& thePoint, return false; } -// MESSAGE( endl<<"SMESH_Block::ComputeParameters( " -// < 1e-1 && nbLoops++ < 10 ) { + while ( distance() > loopTol && nbLoops <= 3 ) + { paramSearch.Perform ( *static_cast(this), start, low, up ); - if ( !paramSearch.IsDone() ) { - //MESSAGE( " !paramSearch.IsDone() " ); - } - else { - //MESSAGE( " NB ITERATIONS: " << paramSearch.NbIterations() ); - } start( 1 ) = myParam.X(); start( 2 ) = myParam.Y(); start( 3 ) = myParam.Z(); - //MESSAGE( "Distance: " << ( SQRT_FUNC ? sqrt(myValues[0]) : myValues[0] )); + mySquareFunc = !mySquareFunc; + nbLoops++; } #ifdef DEBUG_PARAM_COMPUTE - cout << "-------SOLUTION-------: " << endl - << myParam.X() << " " << myParam.Y() << " " << myParam.Z() << endl - << " ------ DIST :" << myValues[0] << endl; + mySumDist += distance(); + cout << " ------ SOLUTION: ( "<< myParam.X() <<" "<< myParam.Y() <<" "<< myParam.Z() <<" )"<= 0 ) - myParam.SetCoord( myFaceIndex + 1, myFaceParam ); +// if ( nbLoops == 0 && hasHint ) +// theParams = theParamsHint; +// else + theParams = myParam; - theParams = myParam; + if ( myFaceIndex >= 0 ) + theParams.SetCoord( myFaceIndex + 1, myFaceParam ); return true; } @@ -741,9 +774,7 @@ bool SMESH_Block::EdgeParameters(const int theEdgeID, const double theU, gp_XYZ& Standard_Integer SMESH_Block::GetStateNumber () { -// MESSAGE( endl<<"SMESH_Block::GetStateNumber( "< TxyzPair; TxyzPair my3x3x3GridNodes[ 27 ]; // to compute the first param guess -- 2.30.2