Chemical Data Processing Library C++ API - Version 1.2.0
GaussianShape.hpp
Go to the documentation of this file.
1 /*
2  * GaussianShape.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_SHAPE_GAUSSIANSHAPE_HPP
30 #define CDPL_SHAPE_GAUSSIANSHAPE_HPP
31 
32 #include <cstddef>
33 #include <vector>
34 #include <memory>
35 
36 #include "CDPL/Shape/APIPrefix.hpp"
38 #include "CDPL/Math/Vector.hpp"
39 
40 
41 namespace CDPL
42 {
43 
44  namespace Shape
45  {
46 
51  {
52 
53  public:
54  class Element
55  {
56 
57  public:
58  Element(const Math::Vector3D& pos, double radius, std::size_t color = 0, double hardness = 2.7):
59  position(pos), radius(radius), hardness(hardness), color(color) {}
60 
61  const Math::Vector3D& getPosition() const
62  {
63  return position;
64  }
65 
66  void setPosition(const Math::Vector3D& pos)
67  {
68  position = pos;
69  }
70 
71  double getRadius() const
72  {
73  return radius;
74  }
75 
76  void setRadius(double radius)
77  {
78  this->radius = radius;
79  }
80 
81  std::size_t getColor() const
82  {
83  return color;
84  }
85 
86  void setColor(std::size_t color)
87  {
88  this->color = color;
89  }
90 
91  double getHardness() const
92  {
93  return hardness;
94  }
95 
96  void setHardness(double hardness)
97  {
98  this->hardness = hardness;
99  }
100 
101  private:
102  Math::Vector3D position;
103  double radius;
104  double hardness;
105  std::size_t color;
106  };
107 
108  private:
109  typedef std::vector<Element> ElementList;
110 
111  public:
112  typedef std::shared_ptr<GaussianShape> SharedPointer;
113 
114  typedef ElementList::const_iterator ConstElementIterator;
115  typedef ElementList::iterator ElementIterator;
116 
117  void clear();
118 
119  std::size_t getNumElements() const;
120 
121  void addElement(const Math::Vector3D& pos, double radius, std::size_t color = 0, double hardness = 2.7);
122 
123  void addElement(const Element& elem);
124 
125  void removeElement(std::size_t idx);
126 
127  const Element& getElement(std::size_t idx) const;
128 
129  Element& getElement(std::size_t idx);
130 
132 
134 
136 
138 
140 
142 
144 
146 
147  private:
148  ElementList elements;
149  };
150  } // namespace Shape
151 } // namespace CDPL
152 
153 #endif // CDPL_SHAPE_GAUSSIANSHAPE_HPP
Definition of the class CDPL::Base::PropertyContainer.
Definition of the preprocessor macro CDPL_SHAPE_API.
#define CDPL_SHAPE_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of vector data types.
A class providing methods for the storage and lookup of object properties.
Definition: PropertyContainer.hpp:75
Definition: GaussianShape.hpp:55
std::size_t getColor() const
Definition: GaussianShape.hpp:81
void setRadius(double radius)
Definition: GaussianShape.hpp:76
void setHardness(double hardness)
Definition: GaussianShape.hpp:96
const Math::Vector3D & getPosition() const
Definition: GaussianShape.hpp:61
void setPosition(const Math::Vector3D &pos)
Definition: GaussianShape.hpp:66
Element(const Math::Vector3D &pos, double radius, std::size_t color=0, double hardness=2.7)
Definition: GaussianShape.hpp:58
double getHardness() const
Definition: GaussianShape.hpp:91
double getRadius() const
Definition: GaussianShape.hpp:71
void setColor(std::size_t color)
Definition: GaussianShape.hpp:86
A data type for the descripton of arbitrary shapes composed of spheres approximated by gaussian funct...
Definition: GaussianShape.hpp:51
Element & getElement(std::size_t idx)
ElementList::iterator ElementIterator
Definition: GaussianShape.hpp:115
ConstElementIterator begin() const
ConstElementIterator getElementsBegin() const
ElementIterator begin()
ConstElementIterator end() const
ElementIterator end()
void removeElement(std::size_t idx)
void addElement(const Element &elem)
void addElement(const Math::Vector3D &pos, double radius, std::size_t color=0, double hardness=2.7)
ElementList::const_iterator ConstElementIterator
Definition: GaussianShape.hpp:114
ElementIterator getElementsBegin()
ConstElementIterator getElementsEnd() const
std::size_t getNumElements() const
const Element & getElement(std::size_t idx) const
ElementIterator getElementsEnd()
std::shared_ptr< GaussianShape > SharedPointer
Definition: GaussianShape.hpp:112
CVector< double, 3 > Vector3D
A bounded 3 element vector holding floating point values of type double.
Definition: Vector.hpp:1637
The namespace of the Chemical Data Processing Library.