Attention une mise à jour du serveur va être effectuée le vendredi 16 avril entre 12h et 12h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 43498383 authored by berenger-bramas's avatar berenger-bramas

New class to save a tree in csv format.

git-svn-id: svn+ssh:// 2616d619-271b-44dc-8df4-d4a8f33a7222
parent e88d284f
#include "../Utils/FGlobal.hpp"
#include <cstring>
#include <iostream>
#include <fstream>
/** This class is to export a tree in csv file
template <class OctreeClass, class ContainerClass , class ParticleClass>
class FTreeCsvSaver {
const bool includeHeader; //< To include a line of header
int nbFrames; //< The current frame
char basefile[512]; //< The base file name like "~/OUT/simulation%d.csv"
/** Constructor
* @param inBasefile is the output file name, you must put %d in it
FTreeCsvSaver(const char inBasefile[], const bool inIncludeHeader = false)
: includeHeader(inIncludeHeader), nbFrames(0) {
strcpy(basefile, inBasefile);
/** Virtual destructor
virtual ~FTreeCsvSaver(){
/** to know how many frame has been saved
int getNbFrames() const {
return nbFrames;
/** export a tree
void exportTree(OctreeClass*const tree){
char currentFilename[512];
sprintf(currentFilename, basefile, nbFrames++);
std::ofstream file(currentFilename, std::ofstream::out );
file << "x, y, z, value\n";
typename OctreeClass::Iterator octreeIterator(tree);
typename ContainerClass::BasicIterator iter(*octreeIterator.getCurrentListTargets());
//const bool isUsingTsm = (octreeIterator.getCurrentListTargets() != octreeIterator.getCurrentListSrc());
while( iter.hasNotFinished() ){
file << << "," << << "," << << "," << getValue(& << "\n";
} while(octreeIterator.moveRight());
/** Inherit from this class and customize this function if you need it
virtual FReal getValue(ParticleClass*const part){
return FReal(0);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment