Exemple #1
0
// [1] Store the exit code in all equivalent Isolate objects, so that
//     the Isolate.exitCode() method would contine to work after the
//     Task associated with these Isolate objects have vanished.
// [2] Remove all equivalent Isolate objects Task from the
//     seen_isolates lists of all active Tasks.
// [3] Notify all waiters on all equivalent Isolate objects (to complete
//     Isolate.start() or Isolate.waitForExit() calls.
void IsolateObj::mark_equivalent_isolates_as_terminated(JVM_SINGLE_ARG_TRAPS) {
  UsingFastOops fastoops;
  TaskList::Fast tlist = Universe::task_list();
  Task::Fast terminating_task = task();
  const int len = tlist().length();

  // Task 0 reserved for system use
  for (int id = Task::FIRST_TASK; id < len; id++) {
    UsingFastOops fastoops2;
    Task::Fast t (tlist().obj_at(id));
    if (t.is_null()) {
      continue;
    }

    IsolateObj::Fast iso, last;
    for (iso = t().seen_isolates(); iso.not_null(); iso = iso().next()) {
      if (iso().is_equivalent_to(this)) {
        iso().set_priority(terminating_task().priority());
        iso().terminate(terminating_task().exit_code() JVM_CHECK);
        IsolateObj::Raw next_iso = iso().next();
        if (iso.obj() == t().seen_isolates()) {
          t().set_seen_isolates(&next_iso);
        } else {
          last().set_next(&next_iso);
        }
        break;
      }
      last = iso.obj();
    }
  }
}
Exemple #2
0
static void
fl_move(int j)
{
    int i, n, newx, newy;

    for (i = roll0(6), n = 0; n < 6; i = (i + 1) % 6, ++n) {
	newx = new_x(capx[j] + dirx[i]);
	newy = new_y(capy[j] + diry[i]);
	if (iso(j, newx, newy) >= iso(j, capx[j], capy[j])) {
	    capx[j] = newx;
	    capy[j] = newy;
	    return;
	}
    }
}
Exemple #3
0
void IISource::getAnything(StringAccumulator & acc) {
  int type = getType();
  symbolGB y;
  if(type==GBInputNumbers::s_IOSYMBOL) {
    get(y);
    acc.add(y.value().chars());
  } else {
    Alias<ISource> iso(inputFunction(y));
    acc.add(y.value().chars());
    bool first = true;
    while(!iso().eoi()) {
      if(!first) acc.add(',');
      ((IISource &)iso.access()).getAnything(acc);
    };
  };
};
void K3b::DataMultisessionImportDialog::addMedium( const K3b::Medium& medium )
{
    QTreeWidgetItem* mediumItem = new QTreeWidgetItem( d->sessionView );
    QFont fnt( mediumItem->font(0) );
    fnt.setBold( true );
    mediumItem->setText( 0, medium.shortString() );
    mediumItem->setFont( 0, fnt );
    mediumItem->setIcon( 0, QIcon::fromTheme("media-optical-recordable") );

    const K3b::Device::Toc& toc = medium.toc();
    QTreeWidgetItem* sessionItem = 0;
    int lastSession = 0;
    for ( K3b::Device::Toc::const_iterator it = toc.begin(); it != toc.end(); ++it ) {
        const K3b::Device::Track& track = *it;

        if( track.session() != lastSession ) {
            lastSession = track.session();
            QString sessionInfo;
            if ( track.type() == K3b::Device::Track::TYPE_DATA ) {
                K3b::Iso9660 iso( medium.device(), track.firstSector().lba() );
                if ( iso.open() ) {
                    sessionInfo = iso.primaryDescriptor().volumeId;
                }
            }
            else {
                int numAudioTracks = 1;
                while ( it != toc.end()
                        && ( *it ).type() == K3b::Device::Track::TYPE_AUDIO
                        && ( *it ).session() == lastSession ) {
                    ++it;
                    ++numAudioTracks;
                }
                --it;
                sessionInfo = i18np("1 audio track", "%1 audio tracks", numAudioTracks );
            }

            sessionItem = new QTreeWidgetItem( mediumItem, sessionItem );
            sessionItem->setText( 0, i18n( "Session %1", lastSession )
                                     + ( sessionInfo.isEmpty() ? QString() : " (" + sessionInfo + ')' ) );
            if ( track.type() == K3b::Device::Track::TYPE_AUDIO )
                sessionItem->setIcon( 0, QIcon::fromTheme( "audio-x-generic" ) );
            else
                sessionItem->setIcon( 0, QIcon::fromTheme( "application-x-tar" ) );

            d->sessions.insert( sessionItem, SessionInfo( lastSession, medium.device() ) );
        }
    }

    if( 0 == lastSession ) {
        // the medium item in case we have no session info (will always use the last session)
        d->sessions.insert( mediumItem, SessionInfo( 0, medium.device() ) );
    }
    else {
        // we have a session item, there is no need to select the medium as a whole
        mediumItem->setFlags( mediumItem->flags() ^ Qt::ItemIsSelectable );
    }

    mediumItem->setExpanded( true );
}
void transcode::parseSetupFile(const char *fileName)
{
    mde_log(MDE_LOG_DEBUG, "MDE: parsing setup file...\n");
    synchronizedFileBuffer *buffy = new synchronizedFileBuffer(std::string(fileName));
    isom iso((Context *)ctx);
    iso.open(buffy);
    iso.parse(true);
    mde_log(MDE_LOG_DEBUG, "MDE: done parsing setup file...\n");
    delete buffy;
}
  void CompNovoIdentificationBase::initIsotopeDistributions_()
  {
    IsotopeDistribution iso_dist(max_isotope_);
    for (Size i = 1; i <= max_mz_ * 2; ++i)
    {
      iso_dist.estimateFromPeptideWeight((DoubleReal)i);
      iso_dist.renormalize();
      vector<DoubleReal> iso(max_isotope_, 0.0);

      for (Size j = 0; j != iso_dist.size(); ++j)
      {
        iso[j] = iso_dist.getContainer()[j].second;
      }
      isotope_distributions_[i] = iso;
    }
  }
Exemple #7
0
static int
stable(void)
{
    int i, isod, d = 0, stab = 1;

    for (i = 0; i < nc; ++i) {
	isod = iso(i, capx[i], capy[i]);
	if (isod > d)
	    d = isod;
    }
    for (i = 0; i < STABLE_CYCLE; ++i)
	if (d != mc[i])
	    stab = 0;
    mc[mcc] = d;
    mcc = (mcc + 1) % STABLE_CYCLE;
    return stab ? d : 0;
}
Exemple #8
0
ISO::ISO(std::string filename)
{
    //  Open file for reading
    std::ifstream iso(filename, std::ios::binary);

    //  Vector to store header information
    std::vector<uint8_t> header(ISO::HeaderSize);

    //  If file didn't open correctly then throw an exception.
    if (!iso.good())
    {
        throw ISOOpenException();
    }

    //  Unset skipws to avoid vector eating spaces
    iso.unsetf(std::ios::skipws);


    try
    {
        //  Start at the default ISO header location
        iso.seekg(ISO::Start, std::ios::beg);

        //  Read header data directly into vector
        iso.read(reinterpret_cast<char *>(&header[0]), ISO::HeaderSize);

        //  Create PrimaryVolume out of header info
        this->primary = std::make_unique<PrimaryVolume>(ref(header));

        //  Print information
        std::cout << *primary;
        std::cin.get();
    }
    catch (std::exception e)
    {
        std::cout << e.what() << std::endl;
    }



    iso.close();
    this->iso_file = filename;
}
Exemple #9
0
bool setup(cloudy::view::Viewer &w,
           std::map<std::string, std::string> &options,
           std::vector<std::string> &parameters)
{
   Data_cloud_ptr cloud (new Data_cloud());

   if (parameters.size() < 1)
   {
      std::cerr << "usage: pcvcloud file.cloud" << std::endl;
      return false;
   }

   std::cerr << parameters[0] << "\n";
   std::ifstream is(parameters[0].c_str());
   cloudy::load_cloud(is, *cloud);

   Scalar_field_ptr weights;

   if (parameters.size() >= 2 && 
       parameters[1].find(".p") != std::string::npos)
     {
       std::ifstream fs(parameters[1].c_str());
       weights = Scalar_field_ptr(new std::vector<double>());
       cloudy::load_data<double>(fs, std::back_inserter(*weights));
     }
   
   w.add_drawer(Drawer_ptr(new Cloud_drawer("cloud", cloud, weights)));

   // temporary
   if (parameters.size() == 2 && 
       parameters[1].find(".off") != std::string::npos)
     {
       std::string meshname = parameters[1];
       cloudy::view::Mesh_ptr mesh (new cloudy::Mesh());
       std::ifstream iso(meshname.c_str());
       mesh->read_off(iso);
       
       w.add_drawer(Drawer_ptr(new Mesh_drawer(meshname, mesh)));
     }

   return true;
}
Exemple #10
0
std::string
Ensemble::getIso8601(std::string c)
{
  // compose ISO-8601 strings
  std::string iso("0000-01-01T00:00:00");

  if( c.size() > 3 )
    iso.replace(0, 4, c, 0, 4);
  if( c.size() > 5 )
    iso.replace(5, 2, c, 4, 2);
  if( c.size() > 7 )
    iso.replace(8, 2, c, 6, 2);
  if( c.size() > 9 )
    iso.replace(11, 2, c, 8, 2);
  if( c.size() > 11 )
    iso.replace(14, 2, c, 10, 2);
  if( c.size() > 13 )
    iso.replace(17, 2, c, 12, 2);

  return iso;
}
void K3b::DataMultisessionImportDialog::slotOk()
{
    Sessions::const_iterator session = d->sessions.constFind( d->sessionView->currentItem() );
    if ( session != d->sessions.constEnd() ) {
        QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );

        K3b::Device::Device* dev = session->device;

        //
        // Mkisofs does not properly import joliet filenames from an old session
        //
        // See bug 79215 for details
        //
        K3b::Iso9660 iso( dev );
        if( iso.open() ) {
            if( iso.firstRRDirEntry() == 0 && iso.jolietLevel() > 0 )
                KMessageBox::sorry( this,
                                    i18n("<p>K3b found session containing Joliet information for long filenames "
                                         "but no Rock Ridge extensions."
                                         "<p>The filenames in the imported session will be converted to a restricted "
                                         "character set in the new session. This character set is based on the ISO 9660 "
                                         "settings in the K3b project. K3b is not able to display these converted filenames yet."),
                                    i18n("Session Import Warning") );
            iso.close();
        }

        if( !d->doc ) {
            d->doc = static_cast<K3b::DataDoc*>( k3bappcore->k3bMainWindow()->slotNewDataDoc() );
        }

        d->doc->setBurner( dev );
        d->doc->importSession( dev, session->sessionNumber );

        QApplication::restoreOverrideCursor();

        done( 0 );
    }
}
Exemple #12
0
void IISource::get(Field& x) {
  int type = getType();
  if(type==GBInputNumbers::s_IOINTEGER) {
    int i;
    ((ISource*)this)->get(i);
    x = Field(i);
  } else if(type==GBInputNumbers::s_IOFUNCTION) {
    int i,j;
    symbolGB y;
    Alias<ISource> iso(inputFunction(y));
    if(y=="Rational") {
      iso.access().get(i);
      iso.access().get(j);
      x = Field(i,j);
    } else {
      TellHead(iso.access());
      DBG(); // Why would the code be here?
    }
  } else {
    TellHead(*this);
    DBG(); // Why would the code be here?
  }
};
Exemple #13
0
std::string
Date::convertFormattedToISO_8601(double f)
{
    // convert YYYYMMDDhhmmss.f formatted str to ISO-8601 where
    // the decimal applies to the last item in the date
    std::string iso("0000-01-01T00:00:00");

    double fInt = static_cast<long int>(f);
    double decim = f - fInt ;

    std::string str( hdhC::double2String(fInt, "p=0|adj,float") );
    size_t sz = str.size();

    if( sz > 3 )
        iso.replace(0, 4, str, 0, 4);
    if( sz > 5 )
        iso.replace(5, 2, str, 4, 2);
    if( sz > 7 )
        iso.replace(8, 2, str, 6, 2);

    if( decim == 0. )
        return iso;

    // convert remainder to hour
    double hour=0.;

    if( sz > 12 )
    {
        double f = hdhC::string2Double(str.substr(12,2)) + decim ;
        decim=0.;
        hour += f/3600.;
    }

    if( sz > 10 )
    {
        double f = hdhC::string2Double(str.substr(10,2)) + decim ;
        decim=0.;
        hour += f/60.;
    }

    if( sz > 8 )
    {
        hour += hdhC::string2Double(str.substr(8,2)) + decim ;
        decim=0.;
    }

    double h, m, s;
    hour /= 24.;
    Date::getDayTime(hour, &h, &m, &s);

    str = hdhC::double2String(h, "w2,f=0,p=0|adj");
    iso.replace(11, 2, str, 0, 2);  // hour

    str = hdhC::double2String(m, "w2,f=0,p=0|adj");
    iso.replace(14, 2, str, 0, 2); // minute

    fInt = static_cast<int>(s);
    str = hdhC::double2String(fInt, "w2,f=0,p=0|adj");
    iso.replace(17, 2, str, 0, 2);  // second

    s -= fInt;

    if( s > 0 )
    {
        str = hdhC::double2String(s,"p=3|adj,float") ;
        if( str[0] == '0' && str[1] == '.' )
            iso += str.substr(1);
        else
            iso += str;
    }

    return iso;
}
Exemple #14
0
void Rmain(char **argv1, char **argv2, char **argv3){


	  /* Check that we have the correct number of files */
	  if(0)// (argc != 4 )
		  printf("ERROR: Correct program useage: ./QtoEcalc [data filelist] [peptide filelist] [parameter file] \n");
	  else
	  {
	    FILE *fp = NULL;
	    FILE *fin = NULL;
	    int i, j, k, ii, nsamples, nreps, zs, cbm, pg;
	    int numpep, newnumpep, missing;
	    float ftmp, ftmp1;
	    int tmp, dtmp, dtmp1;
	    char name[MAX_STRING];

	    int FITPEAKS;
	    double GALIM;
	    double SNRLIM;
	    double FIRSTMASS;
	    double LASTMASS;
	    int CSV;

	    printf("reading parameters from %s\n", argv3[0]);
	    fp = fopen(argv3[0], "r");
	    if (fp == NULL) printf("ERROR: couldn't open parameter file %s\n", argv3[0]);
	    else
	    {
	      tmp = fscanf(fp, "%s %d\n", name, &dtmp);
	      FITPEAKS = dtmp;
	      printf("%s = %d\n",name, FITPEAKS);
	      tmp = fscanf(fp, "%s %f\n", name, &ftmp);
	      GALIM = ftmp;
	      printf("%s = %0.2f\n",name, GALIM);
	      tmp = fscanf(fp, "%s %f\n", name, &ftmp);
	      SNRLIM = ftmp;
	      printf("%s = %0.1f\n",name, SNRLIM);
	      tmp = fscanf(fp, "%s %f\n", name, &ftmp);
	      FIRSTMASS = ftmp;
	      printf("%s = %0.1f\n",name, FIRSTMASS);
	      tmp = fscanf(fp, "%s %f\n", name, &ftmp);
	      LASTMASS = ftmp;
	      printf("%s = %0.1f\n",name, LASTMASS);
	      tmp = fscanf(fp, "%s %d\n", name, &dtmp);
	      CSV = dtmp;
	      printf("%s = %d\n",name, CSV);
	      fclose(fp);
	    }


	    printf("Parameters have loaded correctly\n");


	    /* keepname for output files */
	    char outfilename[1024];
	    strcpy(outfilename, argv1[0]);

	    printf("reading data files from %s\n", argv1[0]);
	    fp = fopen(outfilename, "r");
	    if (fp == NULL)
	    {
	      printf("ERROR: couldn't open file %s\n", argv1[0]);
	    }
	    else
	    {
	      missing = 0;
	      tmp = fscanf(fp, "%d %d\n", &dtmp, &dtmp1);
	      nsamples = dtmp;
	      nreps = dtmp1;
	      int msamples = nsamples/nreps;
	      printf("%d individual samples with %d replicates each of %d samples\n", nsamples, nreps, msamples);

	      /* number of masses to be kept: nmasses = lastmass - firstmass in step m/z units */
	      int nmasses = (int)((LASTMASS - FIRSTMASS)/STEP);

	      SAMPLE *data = NULL;
	      data = (SAMPLE *) malloc (nsamples * sizeof(SAMPLE));
	      for (i = 0; i < nsamples; i++)
	      {
	        data[i].vars = (double *) malloc (nmasses * sizeof(double));
	        data[i].num = (int *) malloc (nmasses * sizeof(int));
	        for (j = 0; j < nmasses; j++)
	        {
	          data[i].vars[j] = 0.0;
	          data[i].num[j] = 0;
	        }
	      }

	      double mult = 1.0/STEP;
	      /* read in filenames */
	      for (i = 0; i < nsamples; i++)
	      {
	        tmp = fscanf(fp, "%s\n", name);
	        fin = fopen(name, "r");
	        if (fin == NULL)
	        {
	          printf("ERROR: couldn't find file %s\n", name);
	          missing ++;
	        }
	        else
	        {
	          printf("%s\n", name);
	          strcpy(data[i].name, name);
	          /* read in data */
	          tmp = 0;
	          while (tmp != EOF)
	          {
	            /* read in mass */
	            if (CSV == 1) tmp = fscanf(fin, "%f,%f\n", &ftmp, &ftmp1);
	            else
	            {
	              tmp = fscanf(fin, "%f %d\n", &ftmp, &dtmp);
	              ftmp1 = (float)dtmp;
	            }
	            if (tmp != EOF)
	            {
	              ii = (int)((ftmp - FIRSTMASS)*mult + 0.5);
	              if ((ii > 0) && (ii < nmasses))
	              {
	                data[i].vars[ii] += ftmp1;
	                data[i].num[ii]++;
		          }
		        }
		      }
	   	      fclose(fin);
		    }
	      }
	      fclose(fp);

	      if (missing > 0) printf("You have %d samples missing\n", missing);
	      if (missing == nsamples) printf("ERROR: couldn't find any of your files!\n");
	      else
	      {
	        for (i = 0; i < nsamples; i++)
	        {
	          for (k = 0; k < nmasses; k++)
	          {
	            if (data[i].num[k] > 0) data[i].vars[k] /= (float) data[i].num[k];
	          }
	        }

	        /* read number of peptides */
	        fin = fopen(argv2[0], "r");
	        if (fin == NULL) printf("ERROR: couldn't open peptide file %s\n", argv2[0]);
	        else
	        {
	          tmp = fscanf(fin, "%d\n", &dtmp);
	          numpep = dtmp;
	          PEPTIDE *pep = NULL;
	          pep = (PEPTIDE *) malloc (numpep * sizeof(PEPTIDE));
	          for (i = 0; i < numpep; i++)
	          {
	            pep[i].sample = (SAMPLEPEP*) malloc (msamples * sizeof(SAMPLEPEP));
	            pep[i].numseq = (int*) malloc (MAXLINE * sizeof(int));
	            for (j = 0; j < msamples; j++)
	            {
	              pep[i].sample[j].peaks = (double*) malloc ((FITPEAKS + 2) * sizeof(double));
	              pep[i].sample[j].found = -1;
	            }
	          }

	          printf("checking %d m/zs:\n", numpep);

	          for (k = 0; k < numpep; k++)
	          {

		    printf("%d m/zs...\n", k);
	            /* read peptide's m/z (this is monoisotopic mass) and number of Qs */
	            tmp = fscanf(fin, "%f %d ", &ftmp, &dtmp);
	            pep[k].nq = dtmp;
	            /* peptide should be observed at monoisotopic mass + 1 (for charge) */
	            pep[k].pepmass = ftmp + 1.0;
	            pep[k].length = getLine(fin, pep[k].numseq, &zs, &pg, &cbm);
	            pep[k].zs = zs;
	            pep[k].pg = pg;
	            pep[k].cbm = cbm;
	            /*printf("%f %d\n", pep[k].pepmass, pep[k].nq);*/
	          }
	          newnumpep = pepfiles(outfilename, data, nsamples, nreps, nmasses, pep, numpep, FITPEAKS, FIRSTMASS, SNRLIM);
	          if (newnumpep > 0)
	          {
	            /* note: this will not be filled for those peptides with pep[i].found = 0 */
	            ISODIST  *dist = NULL;
	            dist = (ISODIST*) malloc (numpep * sizeof(ISODIST));
	            for (k = 0; k < numpep; k++)
	            {
	              dist[k].mass = (double*) malloc (5 * sizeof(double));
	              dist[k].prob = (double*) malloc (5 * sizeof(double));
	            }

	            iso(pep, numpep, dist);

	            /* number of peaks in isotope distribution to be fitted */
	            runga (outfilename, pep, numpep, dist, msamples, FITPEAKS, GALIM);

	            for (k = 0; k < newnumpep; k++)
	            {
	              free (dist[k].mass);
	              free (dist[k].prob);
	            }
	            free (dist);

	          }
	          else printf("none of these peptide found!\n");

	          for (i = 0; i < nsamples; i++)
	          {
	            free (data[i].vars);
	          }
	          free (data);

	          for (i = 0; i < numpep; i++)
	          {
	            for (j = 0; j < msamples; j++)
	            {
	              free (pep[i].sample[j].peaks);
	            }
	            free (pep[i].sample);
	          }
	          free (pep);
	        }
	      }
	    }
	  }
	  //return 0;

	printf("FINISED Q2E\n");



}
Exemple #15
0
 Eigen::Matrix<double, 3, 4> cameraMatrix(const Eigen::Matrix<double, 3, 3> &k,
                                          const Eigen::Matrix<double, 3, 4> &pose)
 {        
     Eigen::AffineCompact3d iso(pose);        
     return k * iso.inverse(Eigen::Isometry).matrix();
 }
Exemple #16
0
void IISource::get(GroebnerRule & x) {
  Alias<ISource> iso(inputNamedFunction("Rule"));
  iso.access().get(x.LHS());
  iso.access().get(x.RHS());
};
void ccRasterizeTool::generateContours()
{
	if (!m_grid.isValid() || !m_rasterCloud)
	{
		ccLog::Error("Need a valid raster/cloud to compute contours!");
		return;
	}

	ccScalarField* activeLayer = m_rasterCloud->getCurrentDisplayedScalarField();
	if (!activeLayer)
	{
		ccLog::Error("No valid/active layer!");
		return;
	}

	double startValue = contourStartDoubleSpinBox->value();
	if (startValue > activeLayer->getMax())
	{
		ccLog::Error("Start value is above the layer maximum value!");
		return;
	}
	double step = contourStepDoubleSpinBox->value();
	assert(step > 0);
	unsigned levelCount = 1 + static_cast<unsigned>(floor((activeLayer->getMax()-startValue)/step));

	removeContourLines();
	bool ignoreBorders = ignoreContourBordersCheckBox->isChecked();

	unsigned xDim = m_grid.width;
	unsigned yDim = m_grid.height;
	int margin = 0;
	if (!ignoreBorders)
	{
		margin = 1;
		xDim += 2;
		yDim += 2;
	}
	std::vector<double> grid;
	try
	{
		grid.resize(xDim * yDim, 0);
	}
	catch (const std::bad_alloc&)
	{
		ccLog::Error("Not enough memory!");
		if (m_window)
			m_window->redraw();
		return;
	}

	//fill grid
	{
		bool sparseLayer = (activeLayer->currentSize() != m_grid.height * m_grid.width);
		double emptyCellsValue = activeLayer->getMin()-1.0;

		unsigned layerIndex = 0;
		for (unsigned j=0; j<m_grid.height; ++j)
		{
			RasterCell* cell = m_grid.data[j];
			double* row = &(grid[(j+margin)*xDim + margin]);
			for (unsigned i=0; i<m_grid.width; ++i)
			{
				if (cell[i].nbPoints || !sparseLayer)
				{
					ScalarType value = activeLayer->getValue(layerIndex++);
					row[i] = ccScalarField::ValidValue(value) ? value : emptyCellsValue;
				}
				else
				{
					row[i] = emptyCellsValue;
				}
			}
		}
	}

	bool memoryError = false;

	try
	{
		Isolines<double> iso(static_cast<int>(xDim),static_cast<int>(yDim));
		if (!ignoreBorders)
			iso.createOnePixelBorder(&(grid.front()),activeLayer->getMin()-1.0);
		//bounding box
		ccBBox box = getCustomBBox();
		assert(box.isValid());

		//vertical dimension
		const unsigned char Z = getProjectionDimension();
		assert(Z >= 0 && Z <= 2);
		const unsigned char X = Z == 2 ? 0 : Z +1;
		const unsigned char Y = X == 2 ? 0 : X +1;

		int minVertexCount = minVertexCountSpinBox->value();
		assert(minVertexCount >= 3);

		ccProgressDialog pDlg(true,this);
		pDlg.setMethodTitle("Contour plot");
		pDlg.setInfo(qPrintable(QString("Levels: %1\nCells: %2 x %3").arg(levelCount).arg(m_grid.width).arg(m_grid.height)));
		pDlg.start();
		pDlg.show();
		QApplication::processEvents();
		CCLib::NormalizedProgress nProgress(&pDlg,levelCount);

		int lineWidth = contourWidthSpinBox->value();
		bool colorize = colorizeContoursCheckBox->isChecked();

		double v = startValue;
		while (v <= activeLayer->getMax() && !memoryError)
		{
			//extract contour lines for the current level
			iso.setThreshold(v);
			int lineCount = iso.find(&(grid.front()));

			ccLog::PrintDebug(QString("[Rasterize][Isolines] value=%1 : %2 lines").arg(v).arg(lineCount));

			//convert them to poylines
			int realCount = 0;
			for (int i=0; i<lineCount; ++i)
			{
				int vertCount = iso.getContourLength(i);
				if (vertCount >= minVertexCount)
				{
					ccPointCloud* vertices = new ccPointCloud("vertices");
					ccPolyline* poly = new ccPolyline(vertices);
					poly->addChild(vertices);
					bool isClosed = iso.isContourClosed(i);
					if (poly->reserve(vertCount) && vertices->reserve(vertCount))
					{
						unsigned localIndex = 0;
						for (int vi=0; vi<vertCount; ++vi)
						{
							double x = iso.getContourX(i,vi) - margin + 0.5;
							double y = iso.getContourY(i,vi) - margin + 0.5;

							CCVector3 P;
							P.u[X] = static_cast<PointCoordinateType>(x * m_grid.gridStep + box.minCorner().u[X]);
							P.u[Y] = static_cast<PointCoordinateType>(y * m_grid.gridStep + box.minCorner().u[Y]);
							P.u[Z] = static_cast<PointCoordinateType>(v);

							vertices->addPoint(P);
							assert(localIndex < vertices->size());
							poly->addPointIndex(localIndex++);
						}

						assert(poly);
						if (poly->size() > 1)
						{
							poly->setName(QString("Contour line value=%1 (#%2)").arg(v).arg(++realCount));
							poly->setGlobalScale(m_cloud->getGlobalScale());
							poly->setGlobalShift(m_cloud->getGlobalShift());
							poly->setWidth(lineWidth);
							poly->setClosed(isClosed); //if we have less vertices, it means we have 'chopped' the original contour
							poly->setColor(ccColor::darkGrey);
							if (colorize)
							{
								const ColorCompType* col = activeLayer->getColor(v);
								if (col)
									poly->setColor(ccColor::Rgb(col));
							}
							poly->showColors(true);
							vertices->setEnabled(false);
							//add the 'const altitude' meta-data as well
							poly->setMetaData(ccPolyline::MetaKeyConstAltitude(),QVariant(v));
						
							if (m_window)
								m_window->addToOwnDB(poly);

							m_contourLines.push_back(poly);
						}
						else
						{
							delete poly;
							poly = 0;
						}
					}
					else
					{
						delete poly;
						poly = 0;
						ccLog::Error("Not enough memory!");
						memoryError = true; //early stop
						break;
					}
				}
			}
			v += step;

			if (!nProgress.oneStep())
			{
				//process cancelled by user
				break;
			}
		}
	}
	catch (const std::bad_alloc&)
	{
		ccLog::Error("Not enough memory!");
	}

	ccLog::Print(QString("[Rasterize] %1 iso-lines generated (%2 levels)").arg(m_contourLines.size()).arg(levelCount));

	if (!m_contourLines.empty())
	{
		if (memoryError)
		{
			removeContourLines();
		}
		else
		{
			exportContoursPushButton->setEnabled(true);
			clearContoursPushButton->setEnabled(true);
		}
	}

	if (m_window)
		m_window->redraw();
}
Exemple #18
0
int main(int argc, char* argv[])
{
    try
    {
        if (argc != 2)
        {
            std::cerr << "Usage: uniso (archive)" << std::endl;
            return 1;
        }

        std::setlocale(LC_ALL, "");

        ar::iso_file_source iso(argv[1]);

        typedef std::vector<ar::iso::volume_desc> descs_type;
        const descs_type& descs = iso.volume_descs();

        descs_type::const_iterator rr = std::find_if(
            descs.begin(), descs.end(),
            std::mem_fun_ref(&ar::iso::volume_desc::is_rock_ridge)
        );

        descs_type::const_iterator jol = std::find_if(
            descs.begin(), descs.end(),
            std::mem_fun_ref(&ar::iso::volume_desc::is_joliet)
        );

        if (rr != descs.end())
            iso.select_volume_desc(rr - descs.begin());
        else if (jol != descs.end())
            iso.select_volume_desc(jol - descs.begin());
        else
            iso.select_volume_desc(0);

        while (iso.next_entry())
        {
            const ar::iso::header& head = iso.header();

            std::cout << head.path.string() << '\n';

            if (head.is_symlink())
                std::cout << "-> " << head.link_path.string() << '\n';
            else if (head.is_directory())
                fs::create_directories(head.path);
            else if (head.is_regular())
            {
                if (::has_parent_path(head.path))
                    fs::create_directories(head.path.branch_path());

                io::copy(
                    iso,
                    io_ex::file_sink(
                        head.path.file_string(), std::ios_base::binary)
                );
            }
        }

        return 0;
    }
    catch (const std::exception& e)
    {
        std::cerr << "Error: " << e.what() << std::endl;
    }
    return 1;
}
Exemple #19
0
int main()
{
 int d;
 SA<2> iso(d);
 return 0;
}
Exemple #20
0
void ISO::directories()
{
    //  Root directory offset is provided by the directory in the
    //  header times the logical block size (usually 2kb | 0x800)
    uint64_t root_dir = this->primary->root->location * this->primary->logical_block_size;

    std::cout << "Root Directory Listing:" << std::endl;

    uint32_t offset = 0;
    std::unique_ptr<ISOEntry> dir;
    std::vector<uint8_t> data(this->primary->root->data_length);

    std::ifstream iso(this->iso_file, std::ios::binary);

    if (!iso.good())
    {
        throw ISOOpenException();
    }
    std::cout << "Calling " << std::endl;
    this->primary->root->contents(iso, this->primary->logical_block_size);

    /*
    iso.seekg(root_dir, std::ios::beg);
    iso.read(reinterpret_cast<char *>(&data[0]), this->primary->root->data_length);

    while (offset < this->primary->root->data_length)
    {
      dir = std::make_unique<Directory>(ref(data), offset);
      offset += dir->size;

      if (dir->flags & FileFlag::Directory)
      {
        std::cout << "DIR: " << dir->identifier << std::endl;
      }
      else if (dir->flags & FileFlag::Associated)
      {
        std::cout << "FILE: " << dir->identifier << "     - " << dir->data_length << " bytes" << std::endl;

        if (dir->extension == "CNF")// || dir->extension == "CFG")
        {
          uint64_t location = dir->location * this->primary->logical_block_size;
          uint32_t size = dir->data_length;
          std::vector<uint8_t> file_data(size);

          iso.seekg(location, std::ios::beg);
          iso.read(reinterpret_cast<char *>(&file_data[0]), size);

          for (auto& byte : file_data)
          {
            std::cout << static_cast<char>(byte);
          }
        }
      }
      else
      {
        std::cout << "UNKNOWN: " << dir->identifier << " [F: " << static_cast<int>(dir->flags) << "]" << std::endl;
      }
    }
    */

    iso.close();
}
Exemple #21
0
main()
{
	iso();
}