From 29f991f0d408d76e2990ba853d5a855de484edcb Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Mon, 26 Jan 2015 18:20:56 +0100 Subject: [PATCH] OctTree is now a full template --- src/CMakeLists.txt | 1 - src/octTree.hpp | 2 ++ src/{octTree.cpp => octTree.tcc} | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) rename src/{octTree.cpp => octTree.tcc} (92%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9737765..e7496e3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,6 @@ SET(CosmoTool_SRCS load_data.cpp loadGadget.cpp loadRamses.cpp - octTree.cpp powerSpectrum.cpp miniargs.cpp growthFactor.cpp diff --git a/src/octTree.hpp b/src/octTree.hpp index e3a3678..87d7dfa 100644 --- a/src/octTree.hpp +++ b/src/octTree.hpp @@ -186,4 +186,6 @@ namespace CosmoTool }; +#include "octTree.tcc" + #endif diff --git a/src/octTree.cpp b/src/octTree.tcc similarity index 92% rename from src/octTree.cpp rename to src/octTree.tcc index 9f1d5f7..e685ea2 100644 --- a/src/octTree.cpp +++ b/src/octTree.tcc @@ -39,8 +39,9 @@ knowledge of the CeCILL license and that you accept its terms. #include "config.hpp" #include "octTree.hpp" +namespace CosmoTool { + using namespace std; -using namespace CosmoTool; //#define VERBOSE @@ -59,7 +60,8 @@ static uint32_t mypow(uint32_t i, uint32_t p) return j*j*i; } -OctTree::OctTree(const FCoordinates *particles, octPtr numParticles, +template +OctTree::OctTree(const FCoordinates *particles, octPtr numParticles, uint32_t maxMeanTreeDepth, uint32_t maxAbsoluteDepth, uint32_t threshold) { @@ -94,7 +96,7 @@ OctTree::OctTree(const FCoordinates *particles, octPtr numParticles, } cout << xMin[0] << " " << xMin[1] << " " << xMin[2] << " lNorm=" << lenNorm << endl; - cells = new OctCell[numCells]; + cells = new OctCell[numCells]; Lbox = (float)(octCoordTypeNorm+1); cells[0].numberLeaves = 0; @@ -110,12 +112,14 @@ OctTree::OctTree(const FCoordinates *particles, octPtr numParticles, //#endif } -OctTree::~OctTree() +template +OctTree::~OctTree() { delete cells; } -void OctTree::buildTree(uint32_t maxAbsoluteDepth) +template +void OctTree::buildTree(uint32_t maxAbsoluteDepth) { for (octPtr i = 0; i < numParticles; i++) { @@ -129,7 +133,8 @@ void OctTree::buildTree(uint32_t maxAbsoluteDepth) } -void OctTree::insertParticle(octPtr node, +template +void OctTree::insertParticle(octPtr node, const OctCoords& icoord, octCoordType halfNodeLength, octPtr particleId, @@ -208,3 +213,5 @@ void OctTree::insertParticle(octPtr node, cells[node].children[octPos] = newNode; } + +};