TBTK
Need a break? Support the development by playing Polarity Puzzles
StateTreeNode.h
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 
17 
24 #ifndef COM_DAFER45_TBTK_STATE_TREE_NODE
25 #define COM_DAFER45_TBTK_STATE_TREE_NODE
26 
27 #include "TBTK/AbstractState.h"
28 #include "TBTK/StateSet.h"
29 
30 namespace TBTK{
31 
39 class StateTreeNode{
40 public:
42  StateTreeNode(
43  std::initializer_list<double> center,
44  double halfSize,
45  int maxDepth = 10
46  );
47 
49  StateTreeNode(
50  std::vector<double> center,
51  double halfSize,
52  int maxDepth = 10
53  );
54 
56  StateTreeNode(
57  const StateSet &stateSet,
58  int maxDepth = 10,
59  double centerShiftMultiplier = 3.14 //Best choice of default number not known. Small integers and common ratios and trancendentals are probably all bad choices.
60  );
61 
63  ~StateTreeNode();
64 
66  void add(AbstractState *state);
67 
70  std::vector<const AbstractState*>* getOverlappingStates(
71  std::initializer_list<double> coordinates,
72  double extent
73  ) const;
74 
77  std::vector<const AbstractState*>* getOverlappingStates(
78  std::vector<double> coordinates,
79  double extent
80  ) const;
81 
83  const std::vector<double>& getCoordinates() const;
84 
86  double getRadius() const;
87 private:
89  std::vector<StateTreeNode*> stateTreeNodes;
90 
91  std::vector<AbstractState*> states;
92 
94  std::vector<double> center;
95 
97  double halfSize;
98 
101  static constexpr double ROUNDOFF_MARGIN_MULTIPLIER = 0.99;
102 
104  int maxDepth;
105 
108  const int numSpacePartitions;
109 
115  bool addRecursive(AbstractState* state);
116 
120  void getOverlappingStatesRecursive(
121  std::vector<const AbstractState*>* overlappingStates,
122  std::vector<double> coordinates,
123  double extent
124  ) const;
125 };
126 
127 }; //End namespace TBTK
128 
129 #endif
130 
Definition: Boolean.h:32