Exemplo n.º 1
0
  RJMCMCBase(float *points,int numPoints, float *dimg, const int *dsz, double *voxsize, double cellsize)
    : m_QBallImageData(dimg)
    , datasz(dsz)
    , enc(0)
    , width(dsz[1]*voxsize[0])
    , height(dsz[2]*voxsize[1])
    , depth(dsz[3]*voxsize[2])
    , voxsize(voxsize)
    , m_NumAttributes(0)
    , m_AcceptedProposals(0)
  {
    fprintf(stderr,"Data dimensions (mm) :  %f x %f x %f\n",width,height,depth);
    fprintf(stderr,"Data dimensions (voxel) :  %i x %i x %i\n",datasz[1],datasz[2],datasz[3]);
    fprintf(stderr,"voxel size (mm) :  %lf x %lf x %lf\n",voxsize[0],voxsize[1],voxsize[2]);

    float cellcnt_x = (int)((float)width/cellsize) +1;
    float cellcnt_y = (int)((float)height/cellsize) +1;
    float cellcnt_z = (int)((float)depth/cellsize) +1;
    //int cell_capacity = 2048;
    //int cell_capacity = 64;
    int cell_capacity = 512;

    fprintf(stderr,"grid dimensions :  %f x %f x %f\n",cellcnt_x,cellcnt_y,cellcnt_z);
    fprintf(stderr,"grid cell size (mm) :  %f^3\n",cellsize);
    fprintf(stderr,"cell capacity :  %i\n",cell_capacity);
    fprintf(stderr,"#cells*cellcap :  %.1f K\n",cell_capacity*cellcnt_x*cellcnt_y*cellcnt_z/1000);

    int minsize = 1000000;
    int err = m_ParticleGrid.allocate(((numPoints>minsize)? (numPoints+100000) : minsize), cellcnt_x, cellcnt_y, cellcnt_z, cellsize, cell_capacity);

    if (err == -1)
    {
      fprintf(stderr,"RJMCMCBase: out of Memory!\n");
      return;
    }

    m_NumAttributes = 10;
    for (int k = 0; k < numPoints; k++)
    {
      Particle *p = m_ParticleGrid.newParticle(pVector(points[m_NumAttributes*k], points[m_NumAttributes*k+1],points[m_NumAttributes*k+2]));
      if (p!=0)
      {
        p->N = pVector(points[m_NumAttributes*k+3],points[m_NumAttributes*k+4],points[m_NumAttributes*k+5]);
        p->cap =  points[m_NumAttributes*k+6];
        p->len =  points[m_NumAttributes*k+7];
        p->mID = (int) points[m_NumAttributes*k+8];
        p->pID = (int) points[m_NumAttributes*k+9];
        if (p->mID != -1)
          m_ParticleGrid.concnt++;
        if (p->pID != -1)
          m_ParticleGrid.concnt++;
        p->label = 0;
      }
      else
      {
        fprintf(stderr,"error: cannot allocate particle,  con. indices will be wrong! \n");
      }
    }
    m_ParticleGrid.concnt /= 2;

    m_Iterations = 0;
    m_AcceptedProposals = 0;
  }
Exemplo n.º 2
0
	RJMCMCBase(REAL *points,int numPoints, REAL *vfmap, REAL *dimg, const int *dsz, double *voxsize, double cellsize, REAL *cellsize2, REAL len, int numcores)
	{

		dataimg = dimg;
		datasz = dsz;
        this->vfmap = vfmap;
        
		width = datasz[2]*voxsize[0];
		height = datasz[3]*voxsize[1];   
		depth = datasz[4]*voxsize[2];

		this->voxsize = voxsize;
        this->numcores = numcores;

		fprintf(stderr,"Data dimensions (mm) :  %f x %f x %f\n",width,height,depth);
		fprintf(stderr,"Data dimensions (voxel) :  %i x %i x %i\n",datasz[2],datasz[3],datasz[4]);
		fprintf(stderr,"Data directions (sizeLUT * dirs) : %i * %i\n",datasz[0],datasz[1]);
		fprintf(stderr,"voxel size (mm) :  %f x %f x %f\n",voxsize[0],voxsize[1],voxsize[2]);
	

        ////// dimensions of the particle grid
        // the one to find connection partners
		REAL cellcnt_x = (int)((REAL)width/cellsize) +2;
		REAL cellcnt_y = (int)((REAL)height/cellsize) +2;
		REAL cellcnt_z = (int)((REAL)depth/cellsize) +2;
		int cell_capacity = 2048;
        // for finding partners whithn the same voxel
		REAL cellcnt_x2 = (int)((REAL)width/cellsize2[0]) +2;
		REAL cellcnt_y2 = (int)((REAL)height/cellsize2[1]) +2;
		REAL cellcnt_z2 = (int)((REAL)depth/cellsize2[2]) +2;
		int cell_capacity2 = 20; 

		fprintf(stderr,"grid dimensions :  %f x %f x %f\n",cellcnt_x,cellcnt_y,cellcnt_z);
		fprintf(stderr,"grid cell size (mm) :  %f^3\n",cellsize);
		fprintf(stderr,"grid2 dimensions :  %f x %f x %f\n",cellcnt_x2,cellcnt_y2,cellcnt_z2);
		fprintf(stderr,"grid2 cell size (mm) :  %fx%fx%f\n",cellsize2[0],cellsize2[1],cellsize2[2]);
    	fprintf(stderr,"cell capacity :  %i\n",cell_capacity);
    	fprintf(stderr,"#cells*cellcap :  %.1f K\n",cell_capacity*cellcnt_x*cellcnt_y*cellcnt_z/1000);
        #ifdef PARALLEL_OPENMP
		fprintf(stderr,"#threads :  %i/%i\n",numcores,omp_get_max_threads());
        #endif
        
        // allocate the particle grid
		int minsize = 100000;
		int err = pcontainer.allocate(((numPoints>minsize)? (numPoints+100000) : minsize), 
                cellcnt_x, cellcnt_y, cellcnt_z, cellsize,cell_capacity,
                cellcnt_x2, cellcnt_y2, cellcnt_z2, cellsize2,cell_capacity2,len);
        if (err == -1)
        {
            fprintf(stderr,"RJMCMCBase: out of Memory!\n");
            return;
        }
        
        // read the data from MATLAB into our structure
		attrcnt = 15;
		for (int k = 0; k < numPoints; k++)
			{
				Particle *p = pcontainer.newParticle(pVector(points[attrcnt*k  ], points[attrcnt*k+1],points[attrcnt*k+2]),
                                                     pVector(points[attrcnt*k+3], points[attrcnt*k+4],points[attrcnt*k+5]));
				if (p!=0) 
				{
					p->N = pVector(points[attrcnt*k+3],points[attrcnt*k+4],points[attrcnt*k+5]);				
					p->len =  points[attrcnt*k+7];	
					p->mID = (int) points[attrcnt*k+8];				
					p->pID = (int) points[attrcnt*k+9];	
					p->Di =  points[attrcnt*k+10];	
					p->Da =  points[attrcnt*k+11];	
					p->Dp =  points[attrcnt*k+12];	
					p->w =  points[attrcnt*k+13];	
					p->q =  points[attrcnt*k+14];	
                    p->label = 0;
                    p->active = true;
                    
					if (p->mID != -1)
                    {
                        pcontainer.removeFromGrid(1,p);
						pcontainer.concnt++;				
                    }
					if (p->pID != -1)
                    {
                        pcontainer.removeFromGrid(0,p);
						pcontainer.concnt++;		
                    }					
				}
				else
				{
					fprintf(stderr,"error: cannot allocate particle,  con. indices will be wrong! \n");
				}
			}
		pcontainer.concnt /= 2;
   


		itmax = 0;
        accepted = 0;

	}