private vtkImageData CreateVtkVolume() { vtkImageData vtkVolume = new vtkImageData(); VtkHelper.RegisterVtkErrorEvents(vtkVolume); vtkVolume.SetDimensions(ArrayDimensions.Width, ArrayDimensions.Height, ArrayDimensions.Depth); vtkVolume.SetOrigin(Origin.X, Origin.Y, Origin.Z); vtkVolume.SetSpacing(VoxelSpacing.X, VoxelSpacing.Y, VoxelSpacing.Z); if (!this.Signed) { vtkVolume.SetScalarTypeToUnsignedShort(); vtkVolume.GetPointData().SetScalars( VtkHelper.ConvertToVtkUnsignedShortArray(_volumeDataUInt16)); } else { vtkVolume.SetScalarTypeToShort(); vtkVolume.GetPointData().SetScalars( VtkHelper.ConvertToVtkShortArray(_volumeDataInt16)); } // This call is necessary to ensure vtkImageData data's info is correct (e.g. updates WholeExtent values) vtkVolume.UpdateInformation(); return(vtkVolume); }
private static vtkImageData CreateVtkVolume(short[] data, int width, int height, int depth) { var vtkVolume = new vtkImageData(); RegisterVtkErrorEvents(vtkVolume); vtkVolume.SetDimensions(width, height, depth); vtkVolume.SetOrigin(0, 0, 0); vtkVolume.SetSpacing(1.0, 1.0, 1.0); using (var array = ConvertToVtkShortArray(data)) { vtkVolume.SetScalarTypeToShort(); vtkVolume.GetPointData().SetScalars(array); // This call is necessary to ensure vtkImageData data's info is correct (e.g. updates WholeExtent values) vtkVolume.UpdateInformation(); } return(vtkVolume); }
private static vtkImageData CreateVtkVolume(short[] data, int width, int height, int depth) { var vtkVolume = new vtkImageData(); RegisterVtkErrorEvents(vtkVolume); vtkVolume.SetDimensions(width, height, depth); vtkVolume.SetOrigin(0, 0, 0); vtkVolume.SetSpacing(1.0, 1.0, 1.0); using (var array = ConvertToVtkShortArray(data)) { vtkVolume.SetScalarTypeToShort(); vtkVolume.GetPointData().SetScalars(array); // This call is necessary to ensure vtkImageData data's info is correct (e.g. updates WholeExtent values) vtkVolume.UpdateInformation(); } return vtkVolume; }
private vtkImageData CreateVtkVolume() { vtkImageData vtkVolume = new vtkImageData(); VtkHelper.RegisterVtkErrorEvents(vtkVolume); vtkVolume.SetDimensions(ArrayDimensions.Width, ArrayDimensions.Height, ArrayDimensions.Depth); vtkVolume.SetOrigin(Origin.X, Origin.Y, Origin.Z); vtkVolume.SetSpacing(VoxelSpacing.X, VoxelSpacing.Y, VoxelSpacing.Z); if (!this.Signed) { vtkVolume.SetScalarTypeToUnsignedShort(); vtkVolume.GetPointData().SetScalars( VtkHelper.ConvertToVtkUnsignedShortArray(_volumeDataUInt16)); } else { vtkVolume.SetScalarTypeToShort(); vtkVolume.GetPointData().SetScalars( VtkHelper.ConvertToVtkShortArray(_volumeDataInt16)); } // This call is necessary to ensure vtkImageData data's info is correct (e.g. updates WholeExtent values) vtkVolume.UpdateInformation(); return vtkVolume; }
private static vtkImageData CreateVtkVolume(Volume volume) { var vtkVolume = new vtkImageData(); vtkVolume.RegisterVtkErrorEvents(); vtkVolume.SetDimensions(volume.ArrayDimensions.Width, volume.ArrayDimensions.Height, volume.ArrayDimensions.Depth); vtkVolume.SetOrigin(0, 0, 0); vtkVolume.SetSpacing(volume.VoxelSpacing.X, volume.VoxelSpacing.Y, volume.VoxelSpacing.Z); if (volume.BitsPerVoxel == 16) { if (!volume.Signed) { using (var array = new vtkUnsignedShortArray()) { array.SetArray((ushort[]) volume.Array, (VtkIdType) volume.ArrayLength, 1); vtkVolume.SetScalarTypeToUnsignedShort(); vtkVolume.GetPointData().SetScalars(array); } } else { using (var array = new vtkShortArray()) { array.SetArray((short[]) volume.Array, (VtkIdType) volume.ArrayLength, 1); vtkVolume.SetScalarTypeToShort(); vtkVolume.GetPointData().SetScalars(array); } } } else if (volume.BitsPerVoxel == 8) { if (!volume.Signed) { using (var array = new vtkUnsignedCharArray()) { array.SetArray((byte[]) volume.Array, (VtkIdType) volume.ArrayLength, 1); vtkVolume.SetScalarTypeToUnsignedChar(); vtkVolume.GetPointData().SetScalars(array); } } else { using (var array = new vtkSignedCharArray()) { array.SetArray((sbyte[]) volume.Array, (VtkIdType) volume.ArrayLength, 1); vtkVolume.SetScalarTypeToSignedChar(); vtkVolume.GetPointData().SetScalars(array); } } } else { throw new NotSupportedException("Unsupported volume scalar type."); } // This call is necessary to ensure vtkImageData data's info is correct (e.g. updates WholeExtent values) vtkVolume.UpdateInformation(); return vtkVolume; }
private static vtkImageData CreateVtkVolume(Volume volume) { var vtkVolume = new vtkImageData(); vtkVolume.RegisterVtkErrorEvents(); vtkVolume.SetDimensions(volume.ArrayDimensions.Width, volume.ArrayDimensions.Height, volume.ArrayDimensions.Depth); vtkVolume.SetOrigin(0, 0, 0); vtkVolume.SetSpacing(volume.VoxelSpacing.X, volume.VoxelSpacing.Y, volume.VoxelSpacing.Z); if (volume.BitsPerVoxel == 16) { if (!volume.Signed) { using (var array = new vtkUnsignedShortArray()) { array.SetArray((ushort[])volume.Array, (VtkIdType)volume.ArrayLength, 1); vtkVolume.SetScalarTypeToUnsignedShort(); vtkVolume.GetPointData().SetScalars(array); } } else { using (var array = new vtkShortArray()) { array.SetArray((short[])volume.Array, (VtkIdType)volume.ArrayLength, 1); vtkVolume.SetScalarTypeToShort(); vtkVolume.GetPointData().SetScalars(array); } } } else if (volume.BitsPerVoxel == 8) { if (!volume.Signed) { using (var array = new vtkUnsignedCharArray()) { array.SetArray((byte[])volume.Array, (VtkIdType)volume.ArrayLength, 1); vtkVolume.SetScalarTypeToUnsignedChar(); vtkVolume.GetPointData().SetScalars(array); } } else { using (var array = new vtkSignedCharArray()) { array.SetArray((sbyte[])volume.Array, (VtkIdType)volume.ArrayLength, 1); vtkVolume.SetScalarTypeToSignedChar(); vtkVolume.GetPointData().SetScalars(array); } } } else { throw new NotSupportedException("Unsupported volume scalar type."); } // This call is necessary to ensure vtkImageData data's info is correct (e.g. updates WholeExtent values) vtkVolume.UpdateInformation(); return(vtkVolume); }