TBTK
Need a break? Support the development by playing Polarity Puzzles
Geometry.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_GEOMETRY
24 #define COM_DAFER45_TBTK_GEOMETRY
25 
26 #include "TBTK/IndexedDataTree.h"
27 #include "TBTK/Serializable.h"
28 #include "TBTK/SerializableVector.h"
29 
30 namespace TBTK{
31  class FileReader;
32 
34 class Geometry : public Serializable{
35 public:
37  Geometry();
38 
45  Geometry(
46  const std::string &serialization,
47  Mode mode
48  );
49 
51  virtual ~Geometry();
52 
59  void setCoordinate(
60  const Index &index,
61  const std::vector<double> &coordinate
62  );
63 
68  const std::vector<double>& getCoordinate(const Index &index) const;
69 
74  int getDimensions() const;
75 
79  void translate(const std::vector<double> &translation);
80 
82  std::string serialize(Mode mode) const;
83 private:
85  int dimensions;
86 
89 
91  friend class FileReader;
92 };
93 
95  const Index &index,
96  const std::vector<double> &coordinate
97 ){
98  if(dimensions == -1)
99  dimensions = coordinate.size();
100 
101  TBTKAssert(
102  coordinate.size() == (unsigned int)dimensions,
103  "Geometry::setCoordinate()",
104  "Incompatible dimensions. A coordinate with dimension '"
105  << dimensions << "' has already been added, which is"
106  << " incompatible with the current coordinate dimension of '"
107  << coordinate.size() << "'.",
108  ""
109  );
110 
111  coordinates.add(coordinate, index);
112 }
113 
114 inline const std::vector<double>& Geometry::getCoordinate(
115  const Index &index
116 ) const{
117  return coordinates.get(index);
118 }
119 
120 inline int Geometry::getDimensions() const{
121  return dimensions;
122 }
123 
124 }; //End of namespace TBTK
125 
126 #endif
TBTK::IndexedDataTree
Definition: IndexedDataTree.h:45
TBTK::IndexedDataTree::add
void add(const Data &data, const Index &index)
Definition: IndexedDataTree.h:355
TBTK::Geometry::getDimensions
int getDimensions() const
Definition: Geometry.h:120
TBTK::Geometry::getCoordinate
const std::vector< double > & getCoordinate(const Index &index) const
Definition: Geometry.h:114
IndexedDataTree.h
Data structure for storing data associated with an index.
TBTK::FileReader
Definition: FileReader.h:50
TBTK::IndexedDataTree::get
bool get(Data &data, const Index &index) const
Definition: IndexedDataTree.h:467
TBTK::Serializable
Definition: Serializable.h:43
TBTK::Geometry
Contains geometric information about a Model.
Definition: Geometry.h:34
Serializable.h
Abstract base class for serializable objects.
TBTK::Geometry::translate
void translate(const std::vector< double > &translation)
TBTK::Geometry::setCoordinate
void setCoordinate(const Index &index, const std::vector< double > &coordinate)
Definition: Geometry.h:94
TBTK::Geometry::Geometry
Geometry()
TBTK::Geometry::serialize
std::string serialize(Mode mode) const
TBTK::Serializable::Mode
Mode
Definition: Serializable.h:47
TBTK::Geometry::~Geometry
virtual ~Geometry()
TBTK::Index
Physical index.
Definition: Index.h:44