Chemical Data Processing Library C++ API - Version 1.4.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:
57  class Element
58  {
59 
60  public:
68  Element(const Math::Vector3D& pos, double radius, std::size_t color = 0, double hardness = 2.7):
69  position(pos), radius(radius), hardness(hardness), color(color) {}
70 
75  const Math::Vector3D& getPosition() const
76  {
77  return position;
78  }
79 
84  void setPosition(const Math::Vector3D& pos)
85  {
86  position = pos;
87  }
88 
93  double getRadius() const
94  {
95  return radius;
96  }
97 
102  void setRadius(double radius)
103  {
104  this->radius = radius;
105  }
106 
111  std::size_t getColor() const
112  {
113  return color;
114  }
115 
120  void setColor(std::size_t color)
121  {
122  this->color = color;
123  }
124 
129  double getHardness() const
130  {
131  return hardness;
132  }
133 
138  void setHardness(double hardness)
139  {
140  this->hardness = hardness;
141  }
142 
143  private:
144  Math::Vector3D position;
145  double radius;
146  double hardness;
147  std::size_t color;
148  };
149 
150  private:
151  typedef std::vector<Element> ElementList;
152 
153  public:
157  typedef std::shared_ptr<GaussianShape> SharedPointer;
158 
162  typedef ElementList::const_iterator ConstElementIterator;
163 
167  typedef ElementList::iterator ElementIterator;
168 
172  void clear();
173 
178  std::size_t getNumElements() const;
179 
187  void addElement(const Math::Vector3D& pos, double radius, std::size_t color = 0, double hardness = 2.7);
188 
193  void addElement(const Element& elem);
194 
200  void removeElement(std::size_t idx);
201 
208  const Element& getElement(std::size_t idx) const;
209 
216  Element& getElement(std::size_t idx);
217 
223 
229 
235 
241 
247 
253 
259 
265 
266  private:
267  ElementList elements;
268  };
269  } // namespace Shape
270 } // namespace CDPL
271 
272 #endif // CDPL_SHAPE_GAUSSIANSHAPE_HPP
Definition of 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.
Base class providing methods for the storage and lookup of object properties.
Definition: PropertyContainer.hpp:75
Data structure representing a single sphere of the Gaussian shape, characterized by a position,...
Definition: GaussianShape.hpp:58
std::size_t getColor() const
Returns the color attribute of the sphere.
Definition: GaussianShape.hpp:111
void setRadius(double radius)
Sets the sphere radius.
Definition: GaussianShape.hpp:102
void setHardness(double hardness)
Sets the hardness of the Gaussian.
Definition: GaussianShape.hpp:138
const Math::Vector3D & getPosition() const
Returns the position of the sphere center.
Definition: GaussianShape.hpp:75
void setPosition(const Math::Vector3D &pos)
Sets the position of the sphere center.
Definition: GaussianShape.hpp:84
Element(const Math::Vector3D &pos, double radius, std::size_t color=0, double hardness=2.7)
Constructs an Element with the given attributes.
Definition: GaussianShape.hpp:68
double getHardness() const
Returns the hardness of the Gaussian.
Definition: GaussianShape.hpp:129
double getRadius() const
Returns the sphere radius.
Definition: GaussianShape.hpp:93
void setColor(std::size_t color)
Sets the color attribute of the sphere.
Definition: GaussianShape.hpp:120
Data type for the descripton of arbitrary shapes composed of spheres approximated by gaussian functio...
Definition: GaussianShape.hpp:51
Element & getElement(std::size_t idx)
Returns a reference to the element at index idx.
ElementList::iterator ElementIterator
A mutable iterator over the elements of the shape.
Definition: GaussianShape.hpp:167
ConstElementIterator begin() const
Returns a constant iterator pointing to the first element (range-based for support).
ConstElementIterator getElementsBegin() const
Returns a constant iterator pointing to the first element.
ElementIterator begin()
Returns a mutable iterator pointing to the first element (range-based for support).
ConstElementIterator end() const
Returns a constant iterator pointing one past the last element (range-based for support).
ElementIterator end()
Returns a mutable iterator pointing one past the last element (range-based for support).
void removeElement(std::size_t idx)
Removes the element at index idx.
void addElement(const Element &elem)
Adds the given element to the shape.
void addElement(const Math::Vector3D &pos, double radius, std::size_t color=0, double hardness=2.7)
Adds a new element to the shape.
ElementList::const_iterator ConstElementIterator
A constant iterator over the elements of the shape.
Definition: GaussianShape.hpp:162
ElementIterator getElementsBegin()
Returns a mutable iterator pointing to the first element.
ConstElementIterator getElementsEnd() const
Returns a constant iterator pointing one past the last element.
std::size_t getNumElements() const
Returns the number of elements in the shape.
void clear()
Removes all elements from the shape.
const Element & getElement(std::size_t idx) const
Returns a const reference to the element at index idx.
ElementIterator getElementsEnd()
Returns a mutable iterator pointing one past the last element.
std::shared_ptr< GaussianShape > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated GaussianShape instances.
Definition: GaussianShape.hpp:157
CVector< double, 3 > Vector3D
Bounded 3 element vector holding floating point values of type double.
Definition: Vector.hpp:2937
The namespace of the Chemical Data Processing Library.