From: eap Date: Thu, 19 May 2005 07:26:20 +0000 (+0000) Subject: setIJKByNonStructured(): fix index and reverse flag X-Git-Tag: V2_2_0_VISU_improvement_2005-05-27~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=927a19cf1152bcd811a469839dc77c9368eb1c26;p=modules%2Fvisu.git setIJKByNonStructured(): fix index and reverse flag --- diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx index c3facd12..1da1a797 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -926,48 +926,53 @@ void VisuGUI_ClippingDlg::setIJKByNonStructured() float * planeNormal = planeSource->GetNormal(); gp_Dir normal( planeNormal[0], planeNormal[1], planeNormal[2] ); - // find index of an axis most co-directed with plane normal - int i, axId = 0; + // find a grid axis most co-directed with plane normal + // and cartesian axis most co-directed with plane normal + int i, maxAx = 0, gridAxId = 0; + gp_Dir dir, gridDir; double maxDot = 0; const vector *curValues, *values = 0; VISU::Result_i* result = myPrs3d->GetResult(); for ( i = 0; i < 3; ++i ) { VISU::Result_i::TAxis axis = (VISU::Result_i::TAxis) i; - gp_Dir dir; curValues = result->GetAxisInfo(myPrs3d->GetMeshName(), axis, dir); if ( curValues ) { double dot = normal * dir; if ( Abs( dot ) > Abs( maxDot )) { maxDot = dot; - axId = i; + gridDir = dir; values = curValues; + gridAxId = i; } } + if ( Abs ( planeNormal[ maxAx ]) < Abs ( planeNormal[ i ])) + maxAx = i; } + gp_XYZ axDir(0,0,0); + axDir.SetCoord( maxAx + 1, 1. ); + // find index value -// double v = SpinBoxDistance->value(); -// if ( reverse ) -// v = 1. - v; -// for ( i = 0; i < values->size(); ++i ) -// if ( (*values)[ i ] > v ) -// break; -// if ( i == values->size() ) --i; -// cout << "maxDot: " << maxDot -// << " axis: " << axId -// << " index: " << i -// << " planeNormal: " << planeNormal[0]<<" "< v - (*values)[ i - 1] ) { -// --i; -// cout << " Decrease index to " << i << endl; -// } + double v = SpinBoxDistance->value(); + // reverse value? + bool reverse = ( normal * axDir < 0 ); // normal and axis are opposite + if ( gridDir * axDir < 0 ) // grid dir and axis are opposite + reverse = !reverse; + if ( reverse ) + v = 1. - v; + for ( i = 0; i < values->size(); ++i ) + if ( (*values)[ i ] > v ) + break; + if ( i == values->size() ) + --i; + if ( i != 0 && (*values)[ i ] - v > v - (*values)[ i - 1] ) + --i; // set control values myIsSelectPlane = true; - CheckBoxIJKPlaneReverse->setChecked( false ); - SpinBoxIJKIndex->setValue( 0 ); - ButtonGroupIJKAxis->setButton( axId ); - onIJKAxisChanged( axId ); + CheckBoxIJKPlaneReverse->setChecked( normal * axDir < 0 ); + SpinBoxIJKIndex->setValue( i ); + ButtonGroupIJKAxis->setButton( gridAxId ); + onIJKAxisChanged( gridAxId ); // update label and range of index myIsSelectPlane = false; SetCurrentPlaneIJKParam();