本文整理汇总了C++中volmagick::Volume::ZSpan方法的典型用法代码示例。如果您正苦于以下问题:C++ Volume::ZSpan方法的具体用法?C++ Volume::ZSpan怎么用?C++ Volume::ZSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类volmagick::Volume
的用法示例。
在下文中一共展示了Volume::ZSpan方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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;
}
//.........这里部分代码省略.........
示例2: main
int main(int argc, char **argv)
{
if(argc < 6)
{
std:: cerr <<
"Usage: " << argv[0] <<
" <first volume> <second volume> < threshold> <output volume left> <output volume masked> \n";
std::cerr<<"second volume (son) is subset of first volume (mother), threshold is in [0,255], output masked is the volume in first volume with > threshold in the second volume. output volume left is the first volume - output volume masked. " << std::endl;
return 1;
}
try
{
VolMagick::Volume inputVol;
VolMagick::Volume inputVol2;
VolMagick::readVolumeFile(inputVol,argv[1]); ///first argument is input volume
VolMagick::readVolumeFile(inputVol2, argv[2]); /// second argument is mask volume
float threshold = atof(argv[3]);
VolMagick::Volume outputLeft;
VolMagick::Volume outputMasked;
if(!inputVol2.boundingBox().isWithin(inputVol.boundingBox()) )
throw VolMagick::SubVolumeOutOfBounds("The mask volume bounding box must be within the mother volume's bounding box.");
outputLeft.voxelType(inputVol.voxelType());
outputLeft.dimension(inputVol.dimension());
outputLeft.boundingBox(inputVol.boundingBox());
outputMasked.voxelType(inputVol.voxelType());
outputMasked.dimension(inputVol.dimension());
outputMasked.boundingBox(inputVol.boundingBox());
float x, y, z;
float fvalue;
float minvalue = (float)inputVol2.min();
float maxvalue = (float)inputVol2.max();
for( int kz = 0; kz<inputVol.ZDim(); kz++)
{
for( int jy = 0; jy<inputVol.YDim(); jy++)
{
for( int ix = 0; ix<inputVol.XDim(); ix++)
{
z = inputVol.ZMin() + kz*inputVol.ZSpan();
y = inputVol.YMin() + jy*inputVol.YSpan();
x = inputVol.XMin() + ix*inputVol.XSpan();
if((z >= (float)inputVol2.ZMin()) && (z <= (float)inputVol2.ZMax()) && ( y >=(float)inputVol2.YMin()) && (y <= (float)inputVol2.YMax()) &&(x >= (float)inputVol2.XMin()) && (x <= (float)inputVol2.XMax()) )
{
fvalue = 255.0*(inputVol2.interpolate(x,y,z)-minvalue)/(maxvalue-minvalue);
if(fvalue > threshold)
{
outputMasked(ix,jy,kz, inputVol(ix,jy,kz));
outputLeft(ix,jy,kz, inputVol.min());
}
else
{
outputMasked(ix,jy,kz, inputVol.min());
outputLeft(ix,jy,kz, inputVol(ix,jy,kz));
}
}
else
{
outputMasked(ix,jy,kz, inputVol.min());
outputLeft(ix,jy,kz, inputVol(ix,jy,kz));
}
}
}
}
VolMagick::createVolumeFile(outputLeft, argv[4]);
VolMagick::createVolumeFile(outputMasked, argv[5]);
std::cout<<"done!"<<std::endl;
}
catch(VolMagick::Exception &e)
{
std:: cerr << e.what() << std::endl;
}
catch(std::exception &e)
//.........这里部分代码省略.........
示例3: main
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;
}
示例4: main
int main(int argc, char **argv)
{
if(argc < 6)
{
std:: cerr <<
"Usage: " << argv[0] <<
" <first volume> <xmin> <ymin> <zmin> <output volume> \n";
return 1;
}
try
{
VolMagick::Volume inputVol;
VolMagick::readVolumeFile(inputVol,argv[1]); ///first argument is input volume
VolMagick::Volume outputVol;
VolMagick::VolumeFileInfo volinfo1;
volinfo1.read(argv[1]);
std::cout << volinfo1.filename() << ":" <<std::endl;
std::cout<<"minVol1 , maxVol1: "<<volinfo1.min()<<" "<<volinfo1.max()<<std::endl;;
float span[3];
span[0]=inputVol.XSpan();
span[1]=inputVol.YSpan();
span[2]=inputVol.ZSpan();
VolMagick::BoundingBox bbox;
bbox.minx = atof(argv[2]);
bbox.miny = atof(argv[3]);
bbox.minz = atof(argv[4]);
bbox.maxx = bbox.minx + volinfo1.XMax()-volinfo1.XMin();
bbox.maxy = bbox.miny + volinfo1.YMax()-volinfo1.YMin();
bbox.maxz = bbox.minz + volinfo1.ZMax()-volinfo1.ZMin();
/* VolMagick::Dimension dim;
dim.xdim = (int) ((bbox.maxx-bbox.minx)/ span[0])+1;
dim.ydim = (int) ((bbox.maxy-bbox.miny)/ span[1])+1;
dim.zdim = (int) ((bbox.maxz-bbox.minz)/ span[2])+1;
*/
outputVol.voxelType(inputVol.voxelType());
outputVol.dimension(volinfo1.dimension());
outputVol.boundingBox(bbox);
/* float temp;
int i, j, k;
int xsh = (int)((bbox.minx - inputVol.XMin())/span[0]);
int ysh = (int)((bbox.miny - inputVol.YMin())/span[1]);
int zsh = (int)((bbox.minz - inputVol.ZMin())/span[2]);
*/
for( int kz = 0; kz<outputVol.ZDim(); kz++)
for( int jy = 0; jy<outputVol.YDim(); jy++)
for( int ix = 0; ix<outputVol.XDim(); ix++)
{
// i = ix + xsh;
// j = jy + ysh;
// k = kz + zsh;
// cout <<"ijk "<< i <<" " << j <<" " <<k <<endl;
// if(i<0 || i >= inputVol.XDim()|| j<0 || j>= inputVol.YDim() || k <0 || k>=inputVol.ZDim()) outputVol(ix, jy, kz, 0.0);
// else
outputVol(ix,jy,kz, inputVol(ix,jy,kz) );
}
// stringstream s;
// s<<argv[3]<< num <<".rawiv";
VolMagick::createVolumeFile(outputVol, argv[5]);
std::cout<<"done!"<<std::endl;
}
catch(VolMagick::Exception &e)
{
std:: cerr << e.what() << std::endl;
}
catch(std::exception &e)
{
std::cerr << e.what() << std::endl;
}
return 0;
}
示例5: signedDistanceFunction
VolMagick::Volume signedDistanceFunction(const boost::shared_ptr<Geometry>& geom,
const VolMagick::Dimension& dim,
const VolMagick::BoundingBox& bbox)
{
int dimx = dim[0], dimy = dim[1], dimz = dim[2];
// read the annotated input file and
Mesh mesh;
cerr << "Reading input mesh ";
read_labeled_mesh(mesh, geom);
cerr << "done." << endl;
// build a bounding box around the input and store the
// origin, span etc.
// vector<double> bbox;
// construct_bbox(mesh, bbox);
VolMagick::BoundingBox box(bbox);
if(box.isNull())
{
geom->GetReadyToDrawWire(); //make sure we have calculated extents for this geometry already
box[0] = geom->m_Min[0];
box[1] = geom->m_Min[1];
box[2] = geom->m_Min[2];
box[3] = geom->m_Max[0];
box[4] = geom->m_Max[1];
box[5] = geom->m_Max[2];
}
// construct a kd-tree of all the non-isolated mesh_vertices.
vector<VECTOR3> points;
vector<Point> pts;
for(int i = 0; i < mesh.get_nv(); i ++)
{
if( mesh.vert_list[i].iso() ) continue;
Point p = mesh.vert_list[i].point();
pts.push_back(p);
points.push_back(VECTOR3(CGAL::to_double(p.x()),
CGAL::to_double(p.y()),
CGAL::to_double(p.z())));
}
KdTree kd_tree(points, 20);
kd_tree.setNOfNeighbours(1);
// Now perform a reconstruction to build a tetrahedralized solid
// with in-out marked.
Triangulation triang;
recon(pts, triang);
// assign weight to each triangle.
vector<double> weights;
// assign_sdf_weight(mesh, weights); // comment out for uniform weight.
VolMagick::Volume vol;
cerr << "SDF " << endl;
try
{
vol.dimension(VolMagick::Dimension(dimx,dimy,dimz));
vol.voxelType(VolMagick::Float);
vol.boundingBox(box);
for(unsigned int k=0; k<vol.ZDim(); k++)
{
for(unsigned int j=0; j<vol.YDim(); j++)
{
for(unsigned int i=0; i<vol.XDim(); i++)
{
double x = vol.XMin() + i*vol.XSpan();
double y = vol.YMin() + j*vol.YSpan();
double z = vol.ZMin() + k*vol.ZSpan();
double fn_val = sdf(Point(x,y,z), mesh, weights, kd_tree, triang);
vol(i,j,k, fn_val);
}
}
fprintf(stderr,
"%5.2f %%\r",
(float(k)/float(vol.ZDim()-1))*100.0);
}
vol.desc("multi_sdf");
}
catch(VolMagick::Exception &e)
{
cerr << e.what() << endl;
}
catch(std::exception &e)
{
cerr << e.what() << endl;
}
cerr << endl << "done." << endl;
return vol;
}
示例6: main
int main(int argc, char **argv) {
// Initialize log4cplus
std::ifstream testfile("log4cplus.properties");
if (testfile) {
testfile.close();
log4cplus::PropertyConfigurator::doConfigure("log4cplus.properties");
}
else {
log4cplus::BasicConfigurator::doConfigure();
}
if(argc < 9) {
std::cerr << "Usage: " << argv[0] << " <first volume>" <<
"<xmin> <ymin> <zmin> <xmax> <ymax> <zmax> <output volume> \n";
return 1;
}
try {
VolMagick::Volume inputVol;
VolMagick::readVolumeFile(inputVol,argv[1]); ///first argument is input volume
VolMagick::Volume outputVol;
VolMagick::VolumeFileInfo volinfo1;
volinfo1.read(argv[1]);
std::cout << volinfo1.filename() << ":" <<std::endl;
std::cout << "minVol1 , maxVol1: " << volinfo1.min() << " " <<
volinfo1.max() << std::endl;;
float span[3];
span[0]=inputVol.XSpan();
span[1]=inputVol.YSpan();
span[2]=inputVol.ZSpan();
VolMagick::BoundingBox bbox;
bbox.minx = atof(argv[2]);
bbox.miny = atof(argv[3]);
bbox.minz = atof(argv[4]);
bbox.maxx = atof(argv[5]);
bbox.maxy = atof(argv[6]);
bbox.maxz = atof(argv[7]);
VolMagick::Dimension dim;
dim.xdim = (int) ((bbox.maxx-bbox.minx)/ span[0])+1;
dim.ydim = (int) ((bbox.maxy-bbox.miny)/ span[1])+1;
dim.zdim = (int) ((bbox.maxz-bbox.minz)/ span[2])+1;
bbox.maxx = bbox.minx + (dim.xdim-1)*span[0];
bbox.maxy = bbox.miny + (dim.ydim-1)*span[1];
bbox.maxz = bbox.minz + (dim.zdim-1)*span[2];
outputVol.voxelType(inputVol.voxelType());
outputVol.dimension(dim);
outputVol.boundingBox(bbox);
float temp;
int i, j, k;
int xsh = (int)((bbox.minx - inputVol.XMin())/span[0]);
int ysh = (int)((bbox.miny - inputVol.YMin())/span[1]);
int zsh = (int)((bbox.minz - inputVol.ZMin())/span[2]);
for( int kz = 0; kz<outputVol.ZDim(); kz++) {
for( int jy = 0; jy<outputVol.YDim(); jy++) {
for( int ix = 0; ix<outputVol.XDim(); ix++) {
i = ix + xsh;
j = jy + ysh;
k = kz + zsh;
if (i<0 || i >= inputVol.XDim()|| j<0 || j>= inputVol.YDim() || k <0 || k>=inputVol.ZDim()) {
outputVol(ix, jy, kz, 0.0);
} else {
outputVol(ix,jy,kz, inputVol(i,j,k));
}
}
}
}
std::cout << "creating volume file..." << std::endl;
VolMagick::createVolumeFile(outputVol, argv[8]);
std::cout << "done!" << std::endl;
} catch(VolMagick::Exception &e) {
std:: cerr << e.what() << std::endl;
} catch(std::exception &e) {
std::cerr << e.what() << std::endl;
}
return 0;
}