FBasicCell.hpp 3.19 KB
Newer Older
1
// ===================================================================================
2
3
4
5
6
7
8
9
10
11
12
13
14
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.  
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info". 
// "http://www.gnu.org/licenses".
15
// ===================================================================================
16
17
#ifndef FBASICCELL_HPP
#define FBASICCELL_HPP
18

19
20
#include "../Utils/FGlobal.hpp"
#include "../Containers/FTreeCoordinate.hpp"
21
#include "FAbstractSerializable.hpp"
22
#include "FAbstractSendable.hpp"
BRAMAS Berenger's avatar
BRAMAS Berenger committed
23
24


25
26
27
28
29
30
31
32
33
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FBasicCell
*
* This class defines a basic cell used for examples. It extends
* the mininum, only what is needed by FOctree and FFmmAlgorithm
* to make the things working.
* By using this extension it will implement the FAbstractCell without
* inheriting from it.
BRAMAS Berenger's avatar
BRAMAS Berenger committed
34
35
*
*
36
*/
37
class FBasicCell : public FAbstractSerializable {
38
39
40
    MortonIndex mortonIndex;    ///< Morton index (need by most elements)
    FTreeCoordinate coordinate; ///< The position
    std::size_t level;          ///< Level in tree
41

42
public:
43
44
45
46
    /** Default constructor */
    FBasicCell() : mortonIndex(0) {
    }

47
48
    /** Default destructor */
    virtual ~FBasicCell(){
49
50
51
52
53
54
55
56
57
    }

    std::size_t getLevel() const {
        return this->level;
    }

    void setLevel(std::size_t inLevel) {
        this->level = inLevel;
    }
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

    /** To get the morton index */
    MortonIndex getMortonIndex() const {
        return this->mortonIndex;
    }

    /** To set the morton index */
    void setMortonIndex(const MortonIndex inMortonIndex) {
        this->mortonIndex = inMortonIndex;
    }

    /** To get the position */
    const FTreeCoordinate& getCoordinate() const {
        return this->coordinate;
    }

    /** To set the position */
    void setCoordinate(const FTreeCoordinate& inCoordinate) {
        this->coordinate = inCoordinate;
    }

    /** To set the position from 3 FReals */
    void setCoordinate(const int inX, const int inY, const int inZ) {
        this->coordinate.setX(inX);
        this->coordinate.setY(inY);
        this->coordinate.setZ(inZ);
84
    }
85

86
    /** Save the current cell in a buffer */
BRAMAS Berenger's avatar
BRAMAS Berenger committed
87
88
    template <class BufferWriterClass>
    void save(BufferWriterClass& buffer) const{
89
90
        buffer << mortonIndex;
        coordinate.save(buffer);
91
    }
92
    /** Restore the current cell from a buffer */
BRAMAS Berenger's avatar
BRAMAS Berenger committed
93
94
    template <class BufferReaderClass>
    void restore(BufferReaderClass& buffer){
95
96
        buffer >> mortonIndex;
        coordinate.restore(buffer);
97
    }
98

99
100
    FSize getSavedSize() const {
        return FSize(sizeof(mortonIndex)) +  coordinate.getSavedSize();
101
102
    }

103
104
105
    /** Do nothing */
    void resetToInitialState(){
    }
106
107
108
109
110
};


#endif //FBASICCELL_HPP

111