TBTK
StateTreeNode.h
Go to the documentation of this file.
1 /* Copyright 2016 Kristofer Bj√∂rnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_STATE_TREE_NODE
24 #define COM_DAFER45_TBTK_STATE_TREE_NODE
25 
26 #include "TBTK/AbstractState.h"
27 #include "TBTK/StateSet.h"
28 
29 namespace TBTK{
30 
39 public:
42  std::initializer_list<double> center,
43  double halfSize,
44  int maxDepth = 10
45  );
46 
49  std::vector<double> center,
50  double halfSize,
51  int maxDepth = 10
52  );
53 
56  const StateSet &stateSet,
57  int maxDepth = 10,
58  double centerShiftMultiplier = 3.14 //Best choice of default number not known. Small integers and common ratios and trancendentals are probably all bad choices.
59  );
60 
63 
65  void add(AbstractState *state);
66 
69  std::vector<const AbstractState*>* getOverlappingStates(
70  std::initializer_list<double> coordinates,
71  double extent
72  ) const;
73 
76  std::vector<const AbstractState*>* getOverlappingStates(
77  std::vector<double> coordinates,
78  double extent
79  ) const;
80 
82  const std::vector<double>& getCoordinates() const;
83 
85  double getRadius() const;
86 private:
88  std::vector<StateTreeNode*> stateTreeNodes;
89 
90  std::vector<AbstractState*> states;
91 
93  std::vector<double> center;
94 
96  double halfSize;
97 
100  static constexpr double ROUNDOFF_MARGIN_MULTIPLIER = 0.99;
101 
103  int maxDepth;
104 
107  const int numSpacePartitions;
108 
114  bool addRecursive(AbstractState* state);
115 
119  void getOverlappingStatesRecursive(
120  std::vector<const AbstractState*>* overlappingStates,
121  std::vector<double> coordinates,
122  double extent
123  ) const;
124 };
125 
126 }; //End namespace TBTK
127 
128 #endif
Definition: StateTreeNode.h:38
StateTreeNode(std::initializer_list< double > center, double halfSize, int maxDepth=10)
std::vector< const AbstractState * > * getOverlappingStates(std::initializer_list< double > coordinates, double extent) const
Abstract state class from which other states inherit.
Container for States.
Definition: AbstractState.h:37
Definition: ModelFactory.h:35
const std::vector< double > & getCoordinates() const
Definition: StateSet.h:30
double getRadius() const
void add(AbstractState *state)