Subject: [OCC Authors Forum]: Re: OCC2618 Date: Thu, 15 May 2003 18:09:02 +0200 From: FranŽois Lauzon Reply-To: webmaster@opencascade.org This message was sent from OCC contributors forum. ---------------------------------------------------------------- Hi Bugmaster, you're telling me it is the default behavior of StartRotation... maybe I didn't explain it correctly, here is a more detailled explanation: void V3d_View::StartRotation(const Standard_Integer X, const Standard_Integer Y, const Quantity_Ratio zRotationThreshold) { sx = X; sy = Y; Standard_Real x,y; Size(x,y); rx = Standard_Real(Convert(x)); ry = Standard_Real(Convert(y)); Gravity(gx,gy,gz); Rotate(0.,0.,0.,gx,gy,gz,Standard_True); #ifdef IMP250900 zRotation = Standard_False; if( zRotationThreshold > 0. ) { Standard_Real dx = Abs(sx - rx/2.); Standard_Real dy = Abs(sy - ry/2.); // if( dx > rx/3. || dy > ry/3. ) zRotation = Standard_True; Standard_Real dd = zRotationThreshold * (rx + ry)/2.; if( dx > dd || dy > dd ) zRotation = Standard_True; } #endif } In the following code, even if I set a center of rotation myself, it is reset by the StartRotation method. It is fine if Gravity return de center of the displayed objects, but the way the center of the displayed objects is computed lead to incorrect result in some case. It could append that Gravity return 0,0,0, imagine you are looking at a 3d model that is dx=300mm, dy=300mm and dz=300mm but is located around 4000, 4000, 9000 in space, so if you see the whole model, the gravity is computed ok and then the rotation is done by a center point near 4000, 4000, 9000, but if you zoom the model, you could end up with a gravity computation of 0,0,0 and THIS become the center of rotation, so you just have to move the mouse a little and you lost your model into space. What I did has a temporary fix since I don't know much about the internal of V3d_View is the following: void V3d_View::StartRotation(const Standard_Integer X, const Standard_Integer Y, const Quantity_Ratio zRotationThreshold) { sx = X; sy = Y; Standard_Real x,y; Size(x,y); rx = Standard_Real(Convert(x)); ry = Standard_Real(Convert(y)); Standard_Real ggx,ggy,ggz; Gravity(ggx,ggy,ggz); if (Abs(ggx)+Abs(ggy)+Abs(ggz)>Precision::Confusion()) { gx=ggx; gy=ggy; gz=ggz; } Rotate(0.,0.,0.,gx,gy,gz,Standard_True); #ifdef IMP250900 zRotation = Standard_False; if( zRotationThreshold > 0. ) { Standard_Real dx = Abs(sx - rx/2.); Standard_Real dy = Abs(sy - ry/2.); // if( dx > rx/3. || dy > ry/3. ) zRotation = Standard_True; Standard_Real dd = zRotationThreshold * (rx + ry)/2.; if( dx > dd || dy > dd ) zRotation = Standard_True; } #endif } I keep the last gravity if the one computed is near 0,0,0, and this is more of a desirable behavior. I have include a small avi file that show the current behavior (currentBehavior.avi) and the one with the fix (fixBehavior.avi) and the brep file you could use to see the problem (model.brep). Thanks, Francois. FranŽois Lauzon, Ing. Stag. Software Development Coordinator DBM Reflex Inc. 1620 boul. Dagenais ouest Laval, QuŻbec Email: Francois.Lauzon@dbmreflex.com ---------------------------------------------------------------- Sent by Open CASCADE Contributors Portal