Reputation: 359
I am building a orthogonal viewer in vtk. I have the three renderers going, but only one will show the correct image, one other shows a badly mangled image, and the third does not show anything.
If I set the camera position to diagonals, I can see the images, but it is still mangled. There must be something obvious that I am missing to get the camera to look at these orthogonal views.
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();
Upvotes: 1
Views: 271