CAA中视图的处理分两种方式:
1、CATICATI3DCamera 俗称照相机,此方法进行视图转换时,附带旋转动作;
2、CAT3DViewpoint 3D视角,此方法进行视图转换时,无转旋转动作。
其中需注意:
vp3d.SetTarget(fOriginalTarget);
vp3d.SetOrigin(fOriginalOrigin);
vp3d.SetSightDirection(fOriginalSightDirection);
vp3d.SetUpDirection(fOriginalUpDirection);
其中SetTarget与SetOrigin顺序的改变会导致转换后视角的位置有所偏差。
全部适应功能:
//获得 main 3D viewpoint:
CAT3DViewpoint &vp3d =pViewer->GetMain3DViewpoint();
//To reframe the view, we also need the representation bounding volume.
CAT3DBagRep * rootBag = (CAT3DBagRep *)(vp3d.GetBag());
if ( NULL == rootBag )
{
return TRUE;
}
//If the bounding element is invalid, let's force its calculation:
if(rootBag->IsInvalid())
rootBag->ComputeBoundingElement(1);
//Retrieving of the bounding element:
const CAT3DBoundingSphere &bs3d = rootBag->GetBoundingElement();
//Retrieving of the bounding element radius:
float radius = bs3d.GetRadius();
if(radius == 0.f)
radius = bs3d.GetRadiusMM();
double dbAngle = vp3d.GetAngle();
double dbRAngle = CATDegreeToRadian*dbAngle;
double focus = 1.05f * (radius/tan(dbRAngle));
float fzoom = vp3d.GetZoom();
CATMathPointf TargetPosition;
if (1 == _found)
{
TargetPosition = Origin;
}
else if (0 == _found)
{
TargetPosition = bs3d.GetCenter();
}
CATMathPointf OriginPosition = TargetPosition- SightDir*(float)focus;
vp3d.SetOrigin(OriginPosition);
vp3d.SetSightDirection(SightDir);
vp3d.SetTarget(TargetPosition);
vp3d.SetUpDirection(upDir);
此功能是获取视图中所有特征的Rep,找取中心,根据Rep的显示大小,确定视角参数,转换视角。