Example #1
0
  output_params_type const *
  control_type::
get_output_params( ) const
{
    d_assert( not_busy( ));
    if ( p_worker_ && ! is_going_down( ) ) {
        return & (p_worker_->get_output_params( ));
    }
    return 0;
}
Example #2
0
// Display a given error code on a dialog in the middle of the screen
void DisplayError(const char * pFormatStr, ...)
{
   char     FormatStrBuffer[100] = { 0 };
   va_list  msgArgs;

   /* Convert the parameters to an actual message and write it into
    * FormatStrBuffer. */
   va_start (msgArgs, pFormatStr);
   vsprintf (FormatStrBuffer, pFormatStr, msgArgs);
   va_end (msgArgs);

//   printf("Error - %s",FormatStrBuffer);
   not_busy();
   alert("Error", FormatStrBuffer, NULL, "Continue", NULL, 0, 0);
}
Example #3
0
int sprite_bank_minus(DIALOG *d)
{
    int sbank = currentGfxBank;

    if (GfxBanks == NULL) return D_REDRAW;

    set_Gfx_bank(currentGfxBank-1);

    if (sbank != currentGfxBank) {
        busy();
	SwitchGraphicsBank(sbank, currentGfxBank);

	if(GfxBankExtraInfo[sbank].planes != 
	   GfxBankExtraInfo[currentGfxBank].planes)
	    palette_reset(); // fix for bug 03

	not_busy();

	return D_REDRAW;
    } else
	return D_O_K;
}
Example #4
0
void Volume::display_marchin_cube()
{
#ifdef CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE
  if(m_surface_mc.empty())
  {
    QTime total_time;
    total_time.start();

    values_list->save_values(fileinfo.absoluteFilePath());

    unsigned int nx = m_image.xdim();
    unsigned int ny = m_image.ydim();
    unsigned int nz = m_image.zdim();
    if(nx * ny * nz == 0)
    {
      status_message("No volume loaded.");
      return;
    }

    mc_timer.reset();
    busy();
    status_message("Marching cubes...");

    mc_timer.start();
    m_surface_mc.clear();

    if(mc.ntrigs()!=0)
      mc.clean_all();
    mc.set_resolution(nx,ny,nz);
    mc.init_all();
    mc.set_ext_data(static_cast<unsigned char*>(m_image.image()->data));

    nbs_of_mc_triangles.resize(values_list->numberOfValues());

    for(int value_id = 0; 
        value_id < values_list->numberOfValues();
        ++value_id)
    {
      status_message(tr("Marching cubes, isovalue #%1...").arg(value_id));

      // set data
//       for(unsigned int i=0;i<nx;i++)
//         for(unsigned int j=0;j<ny;j++)
//           for(unsigned int k=0;k<nz;k++)
//           {
//             const float& value = m_image.value(i,j,k);
//             mc.set_data(value,i,j,k);
//           }
      // compute scaling ratio
      if(value_id > 0)
        mc.init_temps();
      mc.run(values_list->value(value_id),
             m_image.vx(),
             m_image.vy(),
             m_image.vz());
      mc.clean_temps();

      std::vector<double> facets;
      mc.get_facets(facets);

      mc_timer.stop();
      const unsigned int begin = value_id == 0 ? 0 : nbs_of_mc_triangles[value_id-1];
      const unsigned int nbt = facets.size() / 9;
      for(unsigned int i=begin;i<nbt;i++)
      {
        const Point a(facets[9*i],   facets[9*i+1], facets[9*i+2]);
        const Point b(facets[9*i+3], facets[9*i+4], facets[9*i+5]);
        const Point c(facets[9*i+6], facets[9*i+7], facets[9*i+8]);
        const Triangle_3 t(a,b,c);
        const Vector u = t[1] - t[0];
        const Vector v = t[2] - t[0];
        Vector n = CGAL::cross_product(u,v);
        n = n / std::sqrt(n*n);
        m_surface_mc.push_back(Facet(t,n,values_list->item(value_id)));
      }
      nbs_of_mc_triangles[value_id]=m_surface_mc.size();
      mc_timer.start();
    }
    mc_timer.stop();
    not_busy();
    mc_total_time = total_time.elapsed();

    // invalidate the display list
    lists_draw_surface_mc_is_valid = false;
    list_draw_marching_cube_is_valid = false;
  }
  CGAL::Bbox_3 bbox(0,0,0,0,0,0);
  for(std::vector<Facet>::const_iterator
        it = m_surface_mc.begin(), end = m_surface_mc.end();
      it != end; ++it)
  {
    bbox = bbox + it->get<0>().bbox();
  }

  m_view_mc = true;
  m_view_surface = false;
  Q_EMIT changed();
  if(!m_surface_mc.empty())
  {
    Q_EMIT new_bounding_box(bbox.xmin(),
                          bbox.ymin(),
                          bbox.zmin(),
                          bbox.xmax(),
                          bbox.ymax(),
                          bbox.zmax());
  }
  status_message(tr("Marching cubes done. %2 facets in %1s (CPU time), total time is %3s.")
                 .arg(mc_timer.time())
                 .arg(m_surface_mc.size())
                 .arg(mc_total_time/1000.));

  save_image_settings(fileinfo.absoluteFilePath());
#endif // CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE
}
Example #5
0
  void
  control_type::
calc_next
 (  sheet_type const &  src_sheet
  , sheet_type       &  trg_sheet
  , sheet_type       &  extra_sheet
  , bool                are_extra_passes_disabled
)
{
    // Runs in the master thread.
    // The worker thread may not even be created yet.
    d_assert( QThread::currentThread( ) != p_worker_);

    // We should not be processing this message after we have exited.
    if ( is_going_down( ) ) {
        d_assert( false);
        return;
    }

    // We will be busy until we process the "finish" message from the worker thread.
    d_assert( not_busy( ));
    is_busy_ = true;

    // If p_worker_ is zero then we still have to create the worker thread object.
    if ( 0 == p_worker_ ) {
        // Create the thread.
        // We give the worker-thread object no parent (zero pointer) so that signals sent between
        // the master and worker threads are queued instead of dispatched.
        // The ctor for the worker thread runs in the master thread, during creation below.
        // And that ctor starts the worker thread and waits for it to settle.
        p_worker_ = new worker_thread_type( 0);

        // Worker is now running.
        d_assert( p_worker_ && p_worker_->isRunning( ));

        // The parent serves these purposes:
        //   It auto-deletes the object at the end of its life.
        //   When you send a message to an object, Qt has to decide in which thread the message should run.
        //     If the target object has a parent, we use that thread that owns the target object.
        //     If the target object has no parent, we use p_trg->thread( ), which is initially the thread
        //       where the target was created. But we set it below.
        //
        // Since we want messages to p_worker_ to process in that thread, we have to create p_worker_ with
        // no parent (or set it to zero later) and then set the thread.
        //
        // Instead of setting the thread, we could try setting the worker-thread object to be its own parent.
        // It'd look like this:
        //   p_worker_->setParent( p_worker_);
        // This compiles and runs, tho it's not clear what it means for auto-delete.
        // And this doesn't work, even if you follow it with:
        //   p_worker_->moveToThread( p_worker_);
        // The messages to p_worker_ still get dispatched in the master thread.

        // Right now worker_->thread( ) is this (master) thread. And the parent is not set.
        d_assert( p_worker_->thread( ) == QThread::currentThread( ));
        d_assert( p_worker_->parent( ) == 0);

        // Change the thread. You MUST do this from the thread that currently owns the object (this master thread).
        // This will let the signal/slot mechanism work across threads.
        p_worker_->moveToThread( p_worker_);
        // This does not set the parent, so auto-delete is disabled. The worker thread does not delete itself
        // after we call p_worker_->quit( ).
        d_assert( p_worker_->parent( ) == 0);
        // Now messages sent to p_worker_ from the master thread are queued and processed in the worker thread.

        // The worker thread is now awaiting instructions.
        // We use the following 2 async connections, plus ->quit( ), to control it.

        // This is a Qt::QueuedConnection. It is sent from the master and processed in the worker thread.
        // The target (p_worker_ in this case) determines where the message is processed.
          d_verify(
        connect(
            p_worker_, SIGNAL( start__master_to_worker( )),
            p_worker_, SLOT( run__in_worker_thread( )))
          );

        // This is a Qt::QueuedConnection. It is sent from the worker to the master thread.
          d_verify(
        connect(
            p_worker_, SIGNAL( finished__worker_to_master( double)),
            this, SLOT( finished__from_worker_thread( double)))
          );
    }