From: ouv Date: Fri, 7 Oct 2005 13:03:13 +0000 (+0000) Subject: Partially fixed bug GVIEW10171 : It is possible to assign to ?Depth of the cursor... X-Git-Tag: BR-D5-38-2003_D2005-12-10~35 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=615933f0c288a0d09ab292404ba5a719ebc85cb7;p=modules%2Fvisu.git Partially fixed bug GVIEW10171 : It is possible to assign to ?Depth of the cursor? value equal to zero, which leads to fatal error --- diff --git a/src/PIPELINE/VISU_ImplicitFunctionWidget.cxx b/src/PIPELINE/VISU_ImplicitFunctionWidget.cxx index 7eade30c..4d714767 100644 --- a/src/PIPELINE/VISU_ImplicitFunctionWidget.cxx +++ b/src/PIPELINE/VISU_ImplicitFunctionWidget.cxx @@ -275,6 +275,9 @@ vtkImplicitFunction* VISU_ImplicitFunctionWidget::ImplicitFunction() //================================================================== void VISU_ImplicitFunctionWidget::SetDistance(const float theDistance) { + if( theDistance <= 0.0 || theDistance == myDistance ) + return; + myDistance=theDistance; // float *origin, *normal, oNew[3], aN2[3]; @@ -997,17 +1000,30 @@ void VISU_ImplicitFunctionWidget::Push(double *p1, double *p2) //================================================================== void VISU_ImplicitFunctionWidget::PushDistance(double *p1, double *p2) { - float v[3], *anOrigin1, *aN1, *anOrigin2, aD; + float v[3], *anOrigin1, *aN1, *anOrigin2, *aN2, aD; //Get the motion vector v[0] = p2[0] - p1[0]; v[1] = p2[1] - p1[1]; v[2] = p2[2] - p1[2]; // - myPlane2->Push( vtkMath::Dot(v, myPlane2->GetNormal())); anOrigin1 = Plane->GetOrigin(); aN1 = Plane->GetNormal(); - vtkMath::Normalize(aN1); anOrigin2 = myPlane2->GetOrigin(); + aN2 = myPlane2->GetNormal(); + + vtkMath::Normalize(aN1); + + float* origin = new float[3]; + double distance = vtkMath::Dot( v, aN2 ); + for( int i = 0; i < 3; i++ ) + origin[i] = anOrigin2[i] + distance * aN2[i]; + float d = DistanceToPlane(origin, aN1, anOrigin1); + delete [] origin; + + if( d <= 0.0 ) + return; + + myPlane2->Push( vtkMath::Dot(v, myPlane2->GetNormal())); aD=DistanceToPlane(anOrigin2, aN1, anOrigin1); // myDistance=aD; @@ -1102,7 +1118,7 @@ void VISU_ImplicitFunctionWidget::PlaceWidget(float bds[6]) (bounds[3]+bounds[2])/2.0, (bounds[5]+bounds[4])/2.0); - static float DIST_COEFF = 0.33; + static float DIST_COEFF = 0.1; SetDistance(this->InitialLength*DIST_COEFF); this->UpdateRepresentation();