Urgent!Serializing /deserializing VTK classes

View: New views
1 Messages — Rating Filter:   Alert me  

Urgent!Serializing /deserializing VTK classes

by shu gao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,
I am using XStream (http://xstream.codehaus.org/) to serialize/deserilize
some classes.But I always met an error as follows if serializating an object
in one class and deserializing it in another class:
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x10046fd7, pid=3548,
tid=1456
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode, sharing)
# Problematic frame:
# C  [vtkCommonJava.dll+0x46fd7]
#
#An error report file with more information is saved as hs_err_pid1132.log
#
#If you would like to submit a bug report,please visit:
#http://java.sun.com/webapps/bugreport/crash.jsp

The sample is in the attachment,which is slightly modified from
Medical1.java in VTK Examples
(http://ij-plugins.sourceforge.net/vtk-examples/index.html ).And I found if
I defined an object like this:

vtkVolume16Reader vv16 = new vtkVolume16Reader();
  vv16.SetDataDimensions(64, 64);
  vv16.SetDataByteOrderToLittleEndian();
  v16.SetFilePrefix(VtkUtil.getVtkDataRoot() + "/Data/headsq/quarter");
  vv16.SetImageRange(1, 93);
  vv16.SetDataSpacing(3.2, 3.2, 1.5);

The result of serializing it is like this:

<vtk.vtkVolume16Reader>

<vtkId>4</vtkId>

</vtk.vtkVolume16Reader>

It is so simple.What does <vtkId> mean?Where is the data in the object ,such
as Dimension,ImageRange and so on.And I guess some "context" is hiden in
some

other place.And the error above will be made if  serializating the object in
one class and deserializing it in another class.  How to solve it? Any
suggestion will be helpful.Many thanks in advance.

Kind regards,
Gao S.

_________________________________________________________________
Windows LiveĀ™ Messenger has arrived. Click here to download it for free!
http://imagine-msn.com/messenger/launch80/?locale=en-gb

[Medical1.java]


import vtk.util.VtkPanelContainer;
import vtk.util.VtkPanelUtil;
import vtk.util.VtkUtil;
import vtk.*;

import javax.swing.*;
import java.awt.*;
import com.thoughtworks.xstream.*;


public class Medical1 extends JComponent
 {

  public Medical1(vtkPanel renWin,vtkActor sskin,vtkActor ooutline) {

      vtkCamera aCamera = new vtkCamera();
      aCamera.SetViewUp(0, 0, -1);
      aCamera.SetPosition(0, 1, 0);
      aCamera.SetFocalPoint(0, 0, 0);
      aCamera.ComputeViewPlaneNormal();
      // Actors are added to the renderer. An initial camera view is created.
      // The Dolly() method moves the camera towards the FocalPoint,
      // thereby enlarging the image.

     System.out.println("Dispimage  after camera  ");

      renWin.GetRenderer().AddActor(ooutline);
      renWin.GetRenderer().AddActor(sskin);


      renWin.GetRenderer().SetActiveCamera(aCamera);
      renWin.GetRenderer().ResetCamera();
      aCamera.Dolly(1.5);

      // Set a background color for the renderer and set the size of the
      // render window (expressed in pixels).
      renWin.GetRenderer().SetBackground(1, 1, 1);
      VtkPanelUtil.setSize(renWin, 640, 480);


      renWin.GetRenderer().ResetCameraClippingRange();

      // Setup panel
      setLayout(new BorderLayout());

      add(renWin, BorderLayout.CENTER);

    }

  public static  void main(String s[]) {

          XStream xstream=new XStream();

  vtkPanel renWin = new vtkPanel();

readfile rf;
String rfret;

 rf=new readfile();
     rfret=rf.p1();

  filter ft=new filter();
  String ftret=ft.p2(rfret);
  vtkActor sskin=(vtkActor)xstream.fromXML(ftret);

  filtercontext fc=new filtercontext();
   String fcret=fc.p3(rfret);
   vtkActor ooutline=(vtkActor)xstream.fromXML(fcret);

    Medical1 panel = new Medical1(renWin,sskin,ooutline);

    JFrame frame = new JFrame("Medical1");

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add("Center", panel);

    frame.pack();
    frame.setVisible(true);
  }

}


class readfile
{
  String p1(){
//vtkPanel renWin=new vtkPanel();
  String xml;
   XStream xstream=new XStream();

   vtkVolume16Reader vv16 = new vtkVolume16Reader();
   vv16.SetDataDimensions(64, 64);
   vv16.SetDataByteOrderToLittleEndian();
   vv16.SetFilePrefix(VtkUtil.getVtkDataRoot() + "/Data/headsq/quarter");

   vv16.SetImageRange(1, 93);
   vv16.SetDataSpacing(3.2, 3.2, 1.5);
////////////////////////////////

      xml =xstream.toXML(vv16);
    //  vtkVolume16Reader vv16=(vtkVolume16Reader)xstream.fromXML(xml);

  System.out.println("\n in p1  v16     "+xml);

  return (xml);

    }
}
class filter{

    String p2(String xml)
    {

      XStream xstream=new XStream();

  vtkVolume16Reader vv16=(vtkVolume16Reader)xstream.fromXML(xml);
  vtkContourFilter skinExtractor = new vtkContourFilter();
     skinExtractor.SetInput(vv16.GetOutput());
     skinExtractor.SetValue(0, 500);

     vtkPolyDataNormals skinNormals = new vtkPolyDataNormals();
     skinNormals.SetInput(skinExtractor.GetOutput());
     skinNormals.SetFeatureAngle(60.0);

     vtkPolyDataMapper skinMapper = new vtkPolyDataMapper();
     skinMapper.SetInput(skinNormals.GetOutput());
     skinMapper.ScalarVisibilityOff();

     vtkActor skin = new vtkActor();
     skin.SetMapper(skinMapper);

     xml =xstream.toXML(skin);
      return(xml);
    }

  }

class filtercontext{
   String p3(String xml){
     XStream xstream=new XStream();

        System.out.println("begin of p3");
     vtkVolume16Reader vv16=(vtkVolume16Reader)xstream.fromXML(xml);

     vtkOutlineFilter outlineData = new vtkOutlineFilter();
      outlineData.SetInput(vv16.GetOutput());


      vtkPolyDataMapper mapOutline = new vtkPolyDataMapper();
      mapOutline.SetInput(outlineData.GetOutput());

      vtkActor outline = new vtkActor();
      outline.SetMapper(mapOutline);
      outline.GetProperty().SetColor(0, 0, 0);

   String   pxml =xstream.toXML(outline);

      return(pxml);
   }


  }





-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Ij-plugins-users mailing list
Ij-plugins-users@...
https://lists.sourceforge.net/lists/listinfo/ij-plugins-users