PhoenixGraph  01.0.0
Set of tools to simplify graph manipulation
Loading...
Searching...
No Matches
PNTreeLight_impl.h
Go to the documentation of this file.
1/***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5****************************************/
6
7#ifndef __PNTREELIGHT_H_IMPL__
8#define __PNTREELIGHT_H_IMPL__
9
10#include <string.h>
11
12#include "PNTreeLight.h"
13
15template<typename T, typename U, unsigned char N>
19
21
25template<typename T, typename U, unsigned char N>
26PNTreeLight<T,U,N>::PNTreeLight(T pos[N], T size[N], T sizeLimit){
27 initialisationPNTreeLight(pos, size, sizeLimit);
28}
29
31
33template<typename T, typename U, unsigned char N>
37
39template<typename T, typename U, unsigned char N>
43
45
48template<typename T, typename U, unsigned char N>
49bool PNTreeLight<T, U, N>::saveGnuplotData(const std::string & fileName){
50 return p_node.saveGnuplotData(fileName, p_pos, p_size);
51}
52
54
58template<typename T, typename U, unsigned char N>
59bool PNTreeLight<T, U, N>::saveGnuplotData(std::ofstream & fs, T height){
60 return p_node.saveGnuplotData(fs, height, p_pos, p_size);
61}
62
64
66template<typename T, typename U, unsigned char N>
68 memcpy(p_pos, pos, N*sizeof(T));
69}
70
72
74template<typename T, typename U, unsigned char N>
76 memcpy(p_size, size, N*sizeof(T));
77}
78
80
82template<typename T, typename U, unsigned char N>
84 p_sizeLimit = limitSize;
85}
86
88
92template<typename T, typename U, unsigned char N>
93bool PNTreeLight<T, U, N>::addElement(T * posData, U * data){
94 return p_node.addElement(posData, data, p_pos, p_size, p_sizeLimit);
95}
96
98
101template<typename T, typename U, unsigned char N>
102const U * PNTreeLight<T, U, N>::getLastData(T * posData) const{
103 return p_node.getLastData(posData, p_pos, p_size);
104}
105
107
110template<typename T, typename U, unsigned char N>
111const U * PNTreeLight<T, U, N>::getCloserData(T * posData) const{
112 unsigned int nbNeighbours(PPower<3, N>::Value);
113 bool tabNeighbour[nbNeighbours];
114 for(unsigned int i(0u); i < nbNeighbours; ++i){
115 tabNeighbour[i] = false;
116 }
117 tabNeighbour[nbNeighbours/2] = true; //The cell of the current node
118 U * closerData = NULL;
119 T distFromCloserData = 0.0;
120 p_node.getCloserData(closerData, distFromCloserData, tabNeighbour, nbNeighbours, posData, p_pos, p_size);
121 return closerData;
122}
123
125
129template<typename T, typename U, unsigned char N>
130const U * PNTreeLight<T, U, N>::getCloserDataDist(T & distFromCloserData, T * posData) const{
131 unsigned int nbNeighbours(PPower<3, N>::Value);
132 bool tabNeighbour[nbNeighbours];
133 for(unsigned int i(0u); i < nbNeighbours; ++i){
134 tabNeighbour[i] = false;
135 }
136 tabNeighbour[nbNeighbours/2] = true; //The cell of the current node
137 U * closerData = NULL;
138 distFromCloserData = 0.0;
139 p_node.getCloserData(closerData, distFromCloserData, tabNeighbour, nbNeighbours, posData, p_pos, p_size);
140 return closerData;
141}
142
144
147template<typename T, typename U, unsigned char N>
152
154
156template<typename T, typename U, unsigned char N>
160
162
166template<typename T, typename U, unsigned char N>
167void PNTreeLight<T,U,N>::initialisationPNTreeLight(T pos[N], T size[N], T sizeLimit){
168 setPosition(pos);
169 setSize(size);
170 p_sizeLimit = sizeLimit;
171}
172
173
174
175
176
177#endif
178
179
180
void setPosition(T pos[N])
Set the position of the PNTreeLight.
virtual ~PNTreeLight()
Destructeur of PNTreeLight.
PNTreeLight & operator=(const PNTreeLight< T, U, N > &other)
Definition of equal operator of PNTreeLight.
PNTreeLight()
Default constructeur of PNTreeLight.
bool saveGnuplotData(const std::string &fileName)
Saves the PNTreeLight into a txt file for gnuplot.
T p_pos[N]
Position of the hyper cube.
Definition PNTreeLight.h:41
T p_sizeLimit
Size limit of the cells.
Definition PNTreeLight.h:45
const U * getLastData(T *posData) const
Get the data of the last node in the N tree.
void copyPNTreeLight(const PNTreeLight< T, U, N > &other)
Copy function of PNTreeLight.
T p_size[N]
Size of the hyper cube.
Definition PNTreeLight.h:43
PNTreeLightNode< T, U, N > p_node
Table of the children of the current node.
Definition PNTreeLight.h:47
const U * getCloserData(T *posData) const
Get the closer data from the given position.
void setSize(T size[N])
Set the size of the PNTreeLight.
const U * getCloserDataDist(T &distFromCloserData, T *posData) const
Get the closer data from the given position.
bool addElement(T *posData, U *data)
Add an element in the PNTreeLightNode.
void setLimitSize(T limitSize)
Set the limit size of the PNTreeLight cells.
void initialisationPNTreeLight(T pos[N], T size[N], T sizeLimit)
Initialisation function of the class PNTreeLight.