Example #1
0
int main(int argc,char *argv[])
{
  VolMagick::Volume v;
  VolMagick::readVolumeFile(v,argv[1]);

  UniformGrid ugrid(1,1,1);
  ugrid.importVolume(v);
  Point min,max;
  min.x=v.XMin();
  min.y=v.YMin();
  min.z=v.ZMin();
  max.x=v.XMax();
  max.y=v.YMax();
  max.z=v.ZMax();

//generateGridFile(min,max,v.XDim(),v.YDim(),v.ZDim());

  Mesh *mesh=new Mesh();

  float iso_val=atof(argv[2]);

  Mesher mesher;

  mesher.setGrid((Grid &)(ugrid));
  mesher.setMesh(mesh);

  mesher.generateMesh(iso_val);

 // mesh->correctNormals();
  mesher.saveMesh(string(argv[3]),&v);
  delete mesh;
  
  return 0;
}
Example #2
0
int main(int argc, char **argv)
{
  if(argc != 6)
    {
      cerr << "Usage: " << argv[0] << " <input Original volume file> <input cutvolume> <input seed file ><Rotate Num> <output seed file>" << endl;
      return 1;
    }

  try
    {
      VolMagickOpStatus status;
      VolMagick::setDefaultMessenger(&status);

      VolMagick::Volume inputVol;
	  VolMagick::VolumeFileInfo inputVol2info;

      VolMagick::readVolumeFile(inputVol, argv[1]);
	  inputVol2info.read(argv[2]);
	//  fstream fs;
//	  fs.open(argv[3]);

	  ifstream fs;
	  fs.open(argv[3], ios::in);
	  readUntilNewline(fs);
	  readUntilNewline(fs);
	  readUntilNewline(fs);

	  string s1, s2;

	  int seeda, seedb, seedc;
	  int Num = atoi(argv[4]);


	 float cx = (inputVol.XMin()+inputVol.XMax())*0.5;
	 float cy = (inputVol.YMin() + inputVol.YMax())*0.5;
	 
	 int ni, nj, nk;
	 float x, y;
    
         vector<vector<int> > seed(Num);
	  // vector <int>  seed[Num];
  
	 float x0, y0, z0;
	 
	while(fs>>s1>>seedb>>seedc>>s2){
  		seeda = atoi(s1.erase(0,7).c_str());
	//	cout<<seeda<< " "<< seedb<<" " <<seedc<<" " <<endl;
	    x0 = inputVol2info.XMin() + seeda * inputVol2info.XSpan();
		y0 = inputVol2info.YMin() + seedb * inputVol2info.YSpan();
	    z0 = inputVol2info.ZMin() + seedc * inputVol2info.ZSpan();


		 for(int num=0; num<Num; num ++)
		 {	
	 	 	float  nx = cos(2.0*Pi*(float)num/(float)Num)*(x0-cx) - sin(2.0*Pi*(float)num/(float)Num)*(y0-cy) + cx;
			float  ny = sin(2.0*Pi*(float)num/(float)Num)*(x0-cx) + cos(2.0*Pi*(float)num/(float)Num)*(y0-cy) + cy;
			ni = (int)((nx-inputVol.XMin())/inputVol.XSpan()+0.5);
			nj = (int)((ny-inputVol.YMin())/inputVol.YSpan()+0.5);
            nk = (int)((z0-inputVol.ZMin())/inputVol.ZSpan()+0.5);
			if(ni>=inputVol.XDim()||nj >= inputVol.YDim()|| nk >= inputVol.ZDim()|| ni<0 || nj <0 || nk <0) continue;
			else
			{
			   seed[num].push_back(ni);
			   seed[num].push_back(nj);
			   seed[num].push_back(nk);
			}
		 }
	  }
	  fs.close();

	  fstream fs1;
	  fs1.open(argv[5], ios::out);
	  fs1<<"<!DOCTYPE pointclassdoc>"<<endl;
	  fs1<<"<pointclassdoc>" <<endl;

	  string str[13]={"ffff00", "ff0000","00ff00","ff00ff","0000ff","ff5500","336699", "00ffff", "c0c0c0","800000", "800080", "808000", "008080"};
	  
	  if(Num>13) cout<<"You need add more colors." <<endl;
	  for(int num=0; num< Num; num++)
	  {
	  	 fs1<<" <pointclass timestep=\"0\" name=\"Class "<<num<<"\" color="<<"\"#"<<str[num]<<"\" variable=\"0\" >"<<endl;
		 for(int j = 0; j < seed[num].size()/3; j++)
		  fs1<<"  <point>" <<seed[num][3*j] <<" "<< seed[num][3*j+1] <<" "<<seed[num][3*j+2]<<"</point>"<<endl;
		 fs1<<" </pointclass>"<<endl;
	  }
	  fs1<<"</pointclassdoc>"<<endl;

	  fs1.close();

     cout<<"done !" <<endl;

	}
  catch(VolMagick::Exception &e)
    {
      cerr << e.what() << endl;
    }
  catch(std::exception &e)
    {
      cerr << e.what() << endl;
    }

  return 0;
}
Example #3
0
int main(int argc, char **argv)
{
    if(argc < 3)
    {
        std:: cerr <<
                   "Usage: " << argv[0] <<


                   "  <first volume>  <output volume>.   \n";

        return 1;
    }

    try
    {
        VolMagick::Volume inputVol;


        VolMagick::Volume outputVol;

        VolMagick::readVolumeFile(inputVol,argv[1]); ///first argument is input volume

        VolMagick::VolumeFileInfo volinfo1;
        volinfo1.read(argv[1]);
        std::cout << volinfo1.filename() << ":" <<std::endl;


        std::cout<<"minVol1 , maxVol1: "<<volinfo1.min()<<" "<<volinfo1.max()<<std::endl;;


        VolMagick::BoundingBox bbox;
        bbox.minx = inputVol.XMin();
        bbox.maxx = inputVol.XMax();
        bbox.miny = inputVol.YMin();
        bbox.maxy = inputVol.YMax();
        bbox.minz = 2.0*inputVol.ZMin() - inputVol.ZMax();
        bbox.maxz = inputVol.ZMax();

        VolMagick::Dimension dim;
        dim.xdim = inputVol.XDim();
        dim.ydim = inputVol.YDim();
        dim.zdim = (int)((bbox.maxz -bbox.minz)/inputVol.ZSpan())+1;


//	 cout<<bbox.minz <<" " << bbox.maxz<<" "<< bbox.maxy <<endl;
//	 cout<<dim.zdim <<" " << dim.ydim << endl;

        outputVol.voxelType(inputVol.voxelType());
        outputVol.dimension(dim);
        outputVol.boundingBox(bbox);





        for( int kz = 0; kz<outputVol.ZDim()/2; kz++)
            for( int jy = 0; jy<inputVol.YDim(); jy++)
                for( int ix = 0; ix<inputVol.XDim(); ix++)
                    outputVol(ix, jy, kz, inputVol(inputVol.XDim()-1-ix, inputVol.YDim()-1-jy, inputVol.ZDim()-1-kz));

        for( int kz=outputVol.ZDim()/2; kz < outputVol.ZDim(); kz++)
            for( int jy = 0; jy<inputVol.YDim(); jy++)
                for( int ix = 0; ix<inputVol.XDim(); ix++)
                    outputVol(ix, jy, kz, inputVol(ix, jy, kz+1-inputVol.ZDim()));








        VolMagick::createVolumeFile(outputVol, argv[2]);


        cout<<"done!"<<endl;

    }

    catch(VolMagick::Exception &e)
    {
        std:: cerr << e.what() << std::endl;
    }
    catch(std::exception &e)
    {
        std::cerr << e.what() << std::endl;
    }

    return 0;
}
int main(int argc, char **argv)
{
  if(argc < 3)
    {
      std:: cerr << 
	"Usage: " << argv[0] << 

	
	"  <first volume>  <output volume> [ bool 0/1 ].   \n"; 
	cerr<<"bool 1 keeps the original volume, bool 0 only the reflection, default 0."  << endl;

      return 1;
    }

  try
    {
      VolMagick::Volume inputVol;

      
      VolMagick::Volume outputVol;

      VolMagick::readVolumeFile(inputVol,argv[1]); ///first argument is input volume
      
      VolMagick::VolumeFileInfo volinfo1;
      volinfo1.read(argv[1]);
      std::cout << volinfo1.filename() << ":" <<std::endl;

       
      std::cout<<"minVol1 , maxVol1: "<<volinfo1.min()<<" "<<volinfo1.max()<<std::endl;;

  
      VolMagick::BoundingBox bbox;
	  bbox.minx = inputVol.XMin();
	  bbox.maxx = inputVol.XMax();
	  bbox.miny = inputVol.YMin();
	  bbox.maxy = inputVol.YMax();
	  bbox.minz = inputVol.ZMin();
	  bbox.maxz = inputVol.ZMax();

	  VolMagick::Dimension dim;
	  dim.xdim = inputVol.XDim();
	  dim.ydim = inputVol.YDim();
	  dim.zdim = inputVol.ZDim();


//	 cout<<bbox.minz <<" " << bbox.maxz<<" "<< bbox.maxy <<endl;
//	 cout<<dim.zdim <<" " << dim.ydim << endl;
      
      outputVol.voxelType(inputVol.voxelType());
      outputVol.dimension(dim);
      outputVol.boundingBox(bbox);

	
      
   
      //Works for GroEL4.2
      for( int kz = 0; kz<outputVol.ZDim(); kz++)
	   for( int jy = 0; jy<inputVol.YDim(); jy++)
	      for( int ix = 0; ix<inputVol.XDim(); ix++)
		       {
			        float temp=0.0;
					if(inputVol.ZDim() >= kz && inputVol.ZDim() - kz < inputVol.ZDim()
					&& inputVol.YDim() >= jy && inputVol.YDim() - jy < inputVol.YDim() )
					temp = inputVol(ix, inputVol.YDim()-jy, inputVol.ZDim()-kz);
	  				outputVol(ix, jy, kz, temp);
			   }	
	 
	 if(argc==4 && atoi(argv[3])== 1)
	 {
      for( int kz = 0; kz<inputVol.ZDim(); kz++)
	   for( int jy = 0; jy<inputVol.YDim(); jy++)
	      for( int ix = 0; ix<inputVol.XDim(); ix++)
		       {
			   		outputVol(ix, jy, kz, outputVol(ix,jy,kz)+inputVol(ix,jy,kz));
			   }		  
	 }
		  
			  
		 
	      

      VolMagick::createVolumeFile(outputVol, argv[2]);


      cout<<"done!"<<endl;

    }

  catch(VolMagick::Exception &e)
    {
      std:: cerr << e.what() << std::endl;
    }
  catch(std::exception &e)
    {
      std::cerr << e.what() << std::endl;
    }

  return 0;
}