コード例 #1
0
void MapBuilder<ImgType, ImgProviderType, ImgMatcherType>::writeToFile(string output_prefix,map<size_t,map<size_t,Rat>> &transformMatrix,
	map<size_t,vector<size_t>> &adjacency){

		string outadj = output_prefix+"_adjacency.txt";
		string outtrans = output_prefix+"_ROT.txt";

		cout << "Writing to " << outadj << " ...." << endl;

		ofstream outa(outadj);
		if(!outa.is_open()){
			cerr << "Failed to open " << outadj << " file aborting!" << endl;
			return;
		}
		outa << "n1,adjn_1,...,adjn_n" << endl;
		for(map<size_t,vector<size_t>>::iterator i = adjacency.begin(); i != adjacency.end(); ++i){
			outa << i->first;
			for(vector<size_t>::iterator j = i->second.begin(); j != i->second.end(); ++j){
				if(transformMatrix[i->first][*j].first.empty()) continue;
				outa << "," << *j;
			}
			outa << endl;
		}

		outa.close();

		cout << "Writing to " << outtrans << " ...." << endl;
		ofstream outt(outtrans);
		if(!outt.is_open()){
			cerr << "Failed to open file " << outtrans << endl;
			return;
		}
		outt << "n,adjn,r11,r12,r13,t1,r21,r22,r23,t2,r31,r32,r33,t3" << endl;
		for(map<size_t,map<size_t,Rat>>::iterator i = transformMatrix.begin(); i != transformMatrix.end(); ++i){
			for(map<size_t,Rat>::iterator j = i->second.begin(); j != i->second.end(); ++j){
				if (j == i->second.end()){
					cout << " here" << endl;
					break;
				}
				if(j->second.first.empty()) continue;
				outt << i->first << "," << j->first << ",";
				outt << j->second.first.at<double>(0,0) << "," << j->second.first.at<double>(0,1) << "," << j->second.first.at<double>(0,2) << "," << j->second.second.at<double>(0,0) << ",";
				outt << j->second.first.at<double>(1,0) << "," << j->second.first.at<double>(1,1) << "," << j->second.first.at<double>(1,2) << "," << j->second.second.at<double>(1,0) << ",";
				outt << j->second.first.at<double>(2,0) << "," << j->second.first.at<double>(2,1) << "," << j->second.first.at<double>(2,2) << "," << j->second.second.at<double>(2,0) << endl;
			}
		}
		outt.close();
}
コード例 #2
0
ファイル: connections.cpp プロジェクト: satra/brainbundler
void Connections::writeBinaryVTK(QString filename){
    qDebug() << "writing binary vtk file";

    QFile file(filename);
    file.open(QIODevice::WriteOnly);
    QDataStream out(&file);
    QTextStream outt(&file);

    out.setByteOrder(QDataStream::BigEndian);
    out.setFloatingPointPrecision(QDataStream::SinglePrecision);

    int n = edges.size();
    int m = edges.at(0)->points.size();

    outt << "# vtk DataFile Version 3.0" << endl;
    outt << "I am a header! Yay!" << endl;
    outt << "BINARY" << endl;
    outt << "DATASET POLYDATA" << endl;
    outt << "POINTS " << m*n << " float" << endl;

    for (int e = 0; e<n; e++){
        Edge* ed = edges.at(e);
        for (int p=0; p<ed->points.size(); p++){
            QVector3D po = ed->points.at(p);
            out << (float)po.x() << (float)po.y() << (float)po.z();
        }
    }
    outt << endl;

    outt << "LINES " << n << " " << n*(m+1) << endl;
    int i = 0;
    for (int e = 0; e<n; e++){
        out << m;
        for (int p=0; p<m; p++){
            out << i++;
        }
    }
    outt << endl;

    file.close();
    qDebug() << "file written";
}
コード例 #3
0
ファイル: order.cpp プロジェクト: Aleyasen/Alaki
int main(int argc, char * argv[]) {
	
	
	
	//cout<<"the result is going to be written in blondel.part"<<endl;

	bool value;

	string s;
	string s2;

	if(parse_command_line(value, s, s2, argc, argv)==-1)
		return -1;
	
	static_network luca(s);
	//cout<<"network:: "<<luca.size()<<" nodes and "<<luca.edges()<<" edges;\t average degree = "<<2*luca.edges()/luca.size()<<endl;

	
	luca.draw_consecutive("netconsec.dat", "labelconsec.dat", true);


	int sy= system("./convert -i netconsec.dat -o network.bin -w");
	sy=system("./community network.bin -l -1 -w > network.tree");
	sy = system("./hierarchy network.tree -l 1 > leve1.dat");
	
		

	
		
	deque<deque<int> > one_consec;
	get_partition_from_file_list("leve1.dat", one_consec);
	
	ofstream outt("louvain.part");
	luca.print_id(one_consec, outt);
		
			

	return 0;


}
コード例 #4
0
void	RadonTest::testCircleTransform() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testCircleTransform() begin");
	// create a circle object
	double	radius = 100;
	double	sigma = 10;
	circle	c(radius - 4);

	// create an image with a circle
	Image<double>	*image = new Image<double>(300, 300);
	ImagePtr	imageptr(image);

	// draw a circle of the same radius
	for (int x = 0; x < 300; x++) {
		for (int y = 0; y < 300; y++) {
			double	r = hypot(x - 150, y - 150) - radius;
			image->pixel(x, y) = 1000 * exp(-r * r / sigma);
		}
	}

	// save this image
	io::FITSout	out("tmp/circle.fits");
	out.setPrecious(false);
        out.write(imageptr);

	// apply the circle transform with that circle
	CircleAdapter	ca(*image, c);
	Image<double>	*ctransform = new Image<double>(ca);
	ImagePtr	ctransformptr(ctransform);

	// write the circle transform
	io::FITSout	outt("tmp/circletransform.fits");
	outt.setPrecious(false);
        outt.write(ctransformptr);

	debug(LOG_DEBUG, DEBUG_LOG, 0, "testCircleTransform() end");
}