- MESSAGE( "SMESH_Block::Derivatives()");
- math_Vector F(1,3);
- return Values(XYZ,F,Df);
-}
-
-//=======================================================================
-//function : Values
-//purpose :
-//=======================================================================
-
-Standard_Boolean SMESH_Block::Values(const math_Vector& theXYZ,
- math_Vector& theFxyz,
- math_Matrix& theDf)
-{
-// MESSAGE( endl<<"SMESH_Block::Values( "<<theXYZ(1)<<", "<<theXYZ(2)<<", "<<theXYZ(3)<<")");
-
- gp_XYZ P, params( theXYZ(1), theXYZ(2), theXYZ(3) );
- if ( params.IsEqual( myParam, DBL_MIN )) { // same param
- theFxyz( 1 ) = myValues[ 0 ];
- theDf( 1,1 ) = myValues[ 1 ];
- theDf( 1,2 ) = myValues[ 2 ];
- theDf( 1,3 ) = myValues[ 3 ];
- return true;
- }
-
- ShellPoint( params, P );
- //myNbIterations++; // how many time call ShellPoint()
-
- gp_Vec dP( P - myPoint );
- theFxyz(1) = SQRT_FUNC ? dP.SquareMagnitude() : dP.Magnitude();
- if ( theFxyz(1) < 1e-6 ) {
- myParam = params;
- myValues[ 0 ]= 0;
- theDf( 1,1 ) = 0;
- theDf( 1,2 ) = 0;
- theDf( 1,3 ) = 0;
- return true;
- }
-
- if ( theFxyz(1) < myValues[0] ) // a better guess
- {
- // 3 partial derivatives
- gp_Vec drv[ 3 ];
- for ( int iP = 1; iP <= 3; iP++ ) {
- gp_XYZ Pi;
- params.SetCoord( iP, theXYZ( iP ) + 0.001 );
- ShellPoint( params, Pi );
- params.SetCoord( iP, theXYZ( iP ) ); // restore params
- gp_Vec dPi ( P, Pi );
- double mag = dPi.Magnitude();
- if ( mag > DBL_MIN )
- dPi /= mag;
- drv[ iP - 1 ] = dPi;
- }
- for ( int iP = 0; iP < 3; iP++ ) {
- if ( iP == myFaceIndex )
- theDf( 1, iP + 1 ) = myFaceParam;
- else {
- // 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;
- }
- }
- }
- //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 ));
- }
-
- return true;