SCI Seg3D Mailing List

Text archives Help


[Seg3D] doing something to a data volume


Chronological Thread 
  • From: Ramón Casero Cañas <ramon.casero@comlab.ox.ac.uk>
  • To: seg3d@sci.utah.edu
  • Subject: [Seg3D] doing something to a data volume
  • Date: Mon, 12 Oct 2009 13:58:50 +0100


Hi,

I'm trying to do something trivial to a loaded data volume in Seg3D, but I don't seem to be able to even duplicate an existing one.

I'm mostly reusing code from the CropTool, that I have put into a new TestTool. This TestTool is described in the following link in detail,

http://paracommunications.org/wiki/index.php/Adding_a_new_filter_to_Seg3D

but in short, it's simply a spinner box with 2 buttons (Start and Stop).

Right now, I am just trying to clone the active volume in the same way that CropTool does, but without any cropping.


The code compiles and runs, but when I click the "Start" button (that propagates an event to TestTool::finish()), the application crashes with the error:

<SCREEN>
$ GUI: Start button clicked
GUI: Start button clicked

Thread "main" (id: 140318509385760, pid: 19974)
        caught signal SIGSEGV at address 0x30 (segmentation violation)
        ...handle_abort_signals...
niceAbort
Backtrace:
1. ./Seg3D
  in SCIRun::handle_abort_signals(int, siginfo*, void*)
2. /lib/libc.so.6 [0x7f9e6de70040]
3. ./Seg3D
  in SCIRun::DenseMatrix::get(long long, long long) const
4. ./Seg3D
  in SCIRun::NrrdVolume::build_index_to_world_matrix()
5. ./Seg3D
  in SCIRun::NrrdVolume::set_nrrd(SCIRun::LockingHandle<SCIRun::NrrdData>&)
6. ./Seg3D
in SCIRun::NrrdVolume::NrrdVolume(SCIRun::Painter*, std::string const&, SCIRun::LockingHandle<SCIRun::NrrdData>&, unsigned int)
7. ./Seg3D
  in SCIRun::TestTool::finish()
8. ./Seg3D
in SCIRun::TestTool::process_event(SCIRun::LockingHandle<SCIRun::BaseEvent>)
9. ./Seg3D
in SCIRun::ToolManager::propagate_event(SCIRun::LockingHandle<SCIRun::BaseEvent>)
a. ./Seg3D
  in SCIRun::Painter::FinishTool(SCIRun::LockingHandle<SCIRun::BaseEvent>&)
b. ./Seg3D
in SCIRun::Skinner::CallbackT<SCIRun::Painter>::operator()(SCIRun::LockingHandle<SCIRun::BaseEvent>&)
c. ./Seg3D
in SCIRun::Skinner::SignalThrower::throw_signal(std::list<SCIRun::Skinner::Callback*, std::allocator<SCIRun::Skinner::Callback*> >&, SCIRun::LockingHandle<SCIRun::BaseEvent>&)
d. ./Seg3D
in SCIRun::Skinner::SignalThrower::throw_signal(std::map<std::string, std::list<SCIRun::Skinner::Callback*, std::allocator<SCIRun::Skinner::Callback*> >, std::less<std::string>, std::allocator<std::pair<std::string const, std::list<SCIRun::Skinner::Callback*, std::allocator<SCIRun::Skinner::Callback*> > > > >&, SCIRun::LockingHandle<SCIRun::BaseEvent>&)
e. ./Seg3D
  in SCIRun::Skinner::Drawable::throw_signal(std::string const&)
f. ./Seg3D
in SCIRun::Painter::ThrowSkinnerSignal(SCIRun::ThrowSkinnerSignalEvent*, bool)
10. ./Seg3D
  in SCIRun::Painter::ThrowSkinnerSignal(std::string const&, bool)
11. ./Seg3D
  in TestToolPanel::OnStartButtonClick(wxCommandEvent&)
12. ./Seg3D
in wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)
13. ./Seg3D
  in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
14. ./Seg3D
  in wxEvtHandler::ProcessEvent(wxEvent&)
15. ./Seg3D
  in wxWindowBase::TryParent(wxEvent&)
16. ./Seg3D [0xcc29b6]
17. /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x16d) [0x7f9e70c5d27d]
18. /usr/lib/libgobject-2.0.so.0 [0x7f9e70c733bc]
19. /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x7e2) [0x7f9e70c74432]
1a. /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x83) [0x7f9e70c74953]
1b. /usr/lib/libgtk-x11-2.0.so.0 [0x7f9e721b17dd]
1c. /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x16d) [0x7f9e70c5d27d]
1d. /usr/lib/libgobject-2.0.so.0 [0x7f9e70c72723]
1e. /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x7e2) [0x7f9e70c74432]
1f. /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x83) [0x7f9e70c74953]
20. /usr/lib/libgtk-x11-2.0.so.0 [0x7f9e721b046d]
21. /usr/lib/libgtk-x11-2.0.so.0 [0x7f9e7225bdf8]
22. /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x16d) [0x7f9e70c5d27d]
23. /usr/lib/libgobject-2.0.so.0 [0x7f9e70c72b1e]
24. /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x66d) [0x7f9e70c742bd]
25. /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x83) [0x7f9e70c74953]
26. /usr/lib/libgtk-x11-2.0.so.0 [0x7f9e7236409e]
27. /usr/lib/libgtk-x11-2.0.so.0(gtk_propagate_event+0xe3) [0x7f9e72254693]
28. /usr/lib/libgtk-x11-2.0.so.0(gtk_main_do_event+0x2e3) [0x7f9e722557b3]
29. /usr/lib/libgdk-x11-2.0.so.0 [0x7f9e71ecef3c]
2a. /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x24a) [0x7f9e703b420a]
2b. /usr/lib/libglib-2.0.so.0 [0x7f9e703b78e0]
2c. /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x1cd) [0x7f9e703b7dad]
2d. /usr/lib/libgtk-x11-2.0.so.0(gtk_main+0xa7) [0x7f9e72255bc7]
2e. ./Seg3D
  in wxEventLoop::Run()
2f. ./Seg3D
  in wxAppBase::MainLoop()
30. ./Seg3D
  in wxEntry(int&, char**)
31. ./Seg3D(main+0x12) [0x733eb2]
32. /lib/libc.so.6(__libc_start_main+0xe6) [0x7f9e6de5b5a6]
33. ./Seg3D [0x733d39]
140318509385760:main( RUNNING, List: )
140318297213264:Seg3D Event Processor(detached, BLOCKING, Timed wait, List: )
140318296947024:Seg3D Redraw( BLOCKING, Timed wait, List: )
140318295894352:Event Manager( BLOCKING, EventManager, List: )

Abort signalled by pid: 19974
Occured for thread: "main"
Exiting
</SCREEN>


The code I have put in finish() is

<CODE>
BaseTool::propagation_state_e
TestTool::finish()
{
  if (!painter_->current_volume_.get_rep())
    {
      painter_->set_status("Test tool requires an active volume.");
      return STOP_E;
    }

  // create new NRRD volume for the data
  NrrdDataHandle nout_handle = new NrrdData();

  // make a new volume similar to the old volume.
  NrrdVolumeHandle newvol =
    new NrrdVolume(painter_, painter_->current_volume_->name_,
                   nout_handle, painter_->current_volume_->label_);
  if (newvol->label_)
  {
    newvol->set_label_color(painter_->current_volume_->get_label_color());
  }

  // replace the old volume with the new volume.
  NrrdVolumeHandle oldvol = painter_->current_volume_;
  size_t loc = painter_->remove_volume(painter_->current_volume_, false);
  loc = loc + 1; // We're off by one for some reason.
  painter_->insert_volume(newvol, loc);
  painter_->current_volume_ = newvol;

  // Reset the volume rendering.
  if (painter_->current_volume_ == painter_->current_vrender_target_ &&
      !painter_->current_vrender_target_deferred_)
  {
    LoadVolumeEvent *lve =
      new LoadVolumeEvent(painter_->current_vrender_target_->nrrd_handle_,
                          "", false);
    EventManager::add_event(lve);
  }

  // Push this undo item.
  UndoHandle undo = new UndoReplaceLayer(painter_, "Undo Test",
                                         oldvol, newvol, loc);
  painter_->push_undo(undo);

  // Center the probe on the new cropped volume.
  const Point center = painter_->current_volume_->center();
  for (unsigned int i = 0; i < painter_->windows_.size(); ++ i) {
    painter_->windows_[i]->center_ = center;
  }

  // Reset the slices to match the new volume.
  painter_->rebuild_layer_buttons();
  painter_->extract_all_window_slices();
  painter_->redraw_all();

  // Autoview to the cropped volume.
  event_handle_t empty;
  painter_->Autoview(empty);

  painter_->hide_tool_panel();

  std::cout << "TestTool::finish(): I have been told to finish" <<
  std::endl;

  return CONTINUE_E;
}
</CODE>


Do I need to do something to the NrrdDataHandle before passing it to the NrrdVolumeHandle?

Any help would be very much appreciated, thanks.

Best regards,

Ramon.

--
Ramón Casero Cañas, DPhil

Computational Biology, Computing Laboratory
University of Oxford
Wolfson Building, Parks Rd
Oxford OX1 3QD

tlf     +44 (0) 1865 610807
web     http://web.comlab.ox.ac.uk/people/Ramon.CaseroCanas
photos  http://www.flickr.com/photos/rcasero/



Archive powered by MHonArc 2.6.16.

Top of page