1
vtk에서 직교 뷰어를 구축 중입니다. 나는 세 개의 렌더러를 가지고 있지만 올바른 이미지를 보여줄 것이고, 다른 하나는 심하게 망가진 이미지를 보여주고, 세 번째 렌더러는 아무 것도 보여주지 않을 것입니다.하나 이상의 축을 표시하는 vtkImageActor를 만드는 방법
카메라 위치를 대각선으로 설정하면 이미지를 볼 수는 있지만 여전히 망가져 있습니다. 이 직각 뷰를 카메라가 보게하려면 내가 놓친 것이 분명해야합니다.
Orientations orientation = Orientations.XY;
switch (index)
{
case 1:
orientation = Orientations.XY;
break;
case 2:
orientation = Orientations.XZ;
break;
case 3:
orientation = Orientations.YZ;
break;
}
switch (orientation)
{
case Orientations.XY:
this.ImageActors[index].SetDisplayExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], this.Slicex, this.Slicex);
break;
case Orientations.YZ:
this.ImageActors[index].SetDisplayExtent(w_ext[0], w_ext[1], this.SliceY, this.SliceY, w_ext[4], w_ext[5]);
break;
case Orientations.XZ:
this.ImageActors[index].SetDisplayExtent(this.SliceZ, this.SliceZ, w_ext[2], w_ext[3], w_ext[4], w_ext[5]);
break;
}
// Figure out the correct clipping range
int xs = 0, ys = 0;
switch (orientation)
{
case Orientations.XY:
default:
xs = w_ext[1] - w_ext[0] + 1;
ys = w_ext[3] - w_ext[2] + 1;
break;
case Orientations.YZ:
xs = w_ext[1] - w_ext[0] + 1;
ys = w_ext[5] - w_ext[4] + 1;
break;
case Orientations.XZ:
xs = w_ext[3] - w_ext[2] + 1;
ys = w_ext[5] - w_ext[4] + 1;
break;
}
if (FirstRun == false)
{
Renderer[index].ResetCamera();
Camera[index].ParallelProjectionOn();
Camera[index].SetParallelScale(xs < 150 ? 75 : (xs - 1)/2.0);
FirstRun = true;
float cX = 0;// (w_ext[1] + w_ext[0])/2;
float cY = 0;// (w_ext[3] + w_ext[2])/2;
float cZ = 0;// (w_ext[5] + w_ext[4])/2;
Camera[index].SetFocalPoint(cX,cY,cZ);
switch (orientation)
{
case Orientations.XY:
{
Camera[index].SetPosition(cX, cY, cZ + 1);//0, 0, 1); // -1 if medical ?
Camera[index].SetViewUp(0, 1, 0);
}
break;
case Orientations.YZ:
{
Camera[index].SetPosition(cX, cY-1, cZ);//0, -1, 0); // -1 if medical ?
Camera[index].SetViewUp(0, 0, 1);
}
break;
case Orientations.XZ:
{
Camera[index].SetPosition(cX-1, cY, cZ);//- 1, 0, 0); // 1 if medical ?
Camera[index].SetViewUp(0, 0, 1);
}
break;
}
}
//if (this.InteractorStyle[index] != null && this.InteractorStyle[index].GetAutoAdjustCameraClippingRange() == 1)
//{
this.Renderer[index].ResetCameraClippingRange();
//}
//else
//{
// if (Camera[index] != null)
// {
// double[] bounds = this.ImageActors[index].GetBounds();
// double spos = bounds[(int)orientation * 2];
// double cpos = Camera[index].GetPosition()[(int)orientation];
// double range = Math.Abs(spos - cpos);
// double[] spacing = DensityGrid.GetSpacing();
// double avg_spacing = (spacing[0] + spacing[1] + spacing[2])/3.0;
// Camera[index].SetClippingRange(range - avg_spacing * 3.0, range + avg_spacing * 3.0);
// }
//}
// Camera[index].SetClippingRange(-200, 200);
RenderWindow[index].Render();