source: src/Shapes/Shape_impl.hpp@ 52575c

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 52575c was c67c65, checked in by Frederik Heber <heber@…>, 13 years ago

Added preliminary getVolume() and getSurfaceArea() implementation to all Shapes.

  • only BaseShapes are truely usable, the rest is mostly marked as TODO.
  • the problem is that intersections are not so easy to handle. Probably, we have to use polygonal intersections there and approximate volume calculations.
  • the functions return -1 when not implemented yet. this is preparatory to start approximate calculations at the top node of the Shape "graph" if -1. is returned from the implementation.
  • Property mode set to 100644
File size: 6.2 KB
Line 
1/*
2 * Shape_impl.hpp
3 *
4 * Created on: Jun 18, 2010
5 * Author: crueger
6 */
7
8#ifndef SHAPE_IMPL_HPP_
9#define SHAPE_IMPL_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16
17#include <limits>
18#include <vector>
19
20#include "CodePatterns/Assert.hpp"
21
22#include "Shapes/Shape.hpp"
23#include "Shapes/ShapeExceptions.hpp"
24#include "Shapes/ShapeType.hpp"
25#include "LinearAlgebra/Line.hpp"
26#include "LinearAlgebra/LinePoint.hpp"
27#include "LinearAlgebra/LineSegment.hpp"
28#include "LinearAlgebra/LineSegmentSet.hpp"
29#include "LinearAlgebra/Vector.hpp"
30
31
32class Shape_impl {
33public:
34 Shape_impl(){};
35 virtual ~Shape_impl(){};
36 virtual bool isInside(const Vector &point) const=0;
37 virtual bool isOnSurface(const Vector &point) const=0;
38 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException)=0;
39 virtual Vector getCenter() const=0;
40 virtual double getRadius() const=0;
41 virtual double getVolume() const=0;
42 virtual double getSurfaceArea() const=0;
43 virtual LineSegmentSet getLineIntersections(const Line&) const=0;
44 virtual std::string toString() const =0;
45 virtual enum ShapeType getType() const =0;
46 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const=0;
47 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const=0;
48};
49
50class Everywhere_impl : public Shape_impl {
51public:
52 virtual bool isInside(const Vector &point) const{
53 return true;
54 }
55 virtual bool isOnSurface(const Vector &point) const{
56 return false;
57 }
58 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException){
59 throw NotOnSurfaceException() << ShapeVector(&point);
60 }
61 virtual Vector getCenter() const {
62 return Vector(0.,0.,0.);
63 }
64 virtual double getRadius() const {
65 return std::numeric_limits<double>::infinity();
66 }
67 virtual double getVolume() const
68 {
69 // TODO
70 return 0.;
71 }
72 virtual double getSurfaceArea() const
73 {
74 // TODO
75 return 0.;
76 }
77 virtual LineSegmentSet getLineIntersections(const Line &line) const{
78 LineSegmentSet res(line);
79 res.insert(LineSegment(line.negEndpoint(),line.posEndpoint()));
80 return res;
81 }
82 virtual std::string toString() const{
83 return "Everywhere()";
84 }
85 virtual enum ShapeType getType() const {
86 return EverywhereType;
87 }
88 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const {
89 std::vector<Vector> PointsOnSurface;
90 return PointsOnSurface;
91 }
92 std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const {
93 ASSERT(0,
94 "Everywhere_impl::getHomogeneousPointsInVolume() - not implemented.");
95 return std::vector<Vector>();
96 }
97};
98
99class Nowhere_impl : public Shape_impl {
100 virtual bool isInside(const Vector &point) const{
101 return false;
102 }
103 virtual bool isOnSurface(const Vector &point) const{
104 return false;
105 }
106 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException){
107 throw NotOnSurfaceException() << ShapeVector(&point);
108 }
109 virtual Vector getCenter() const {
110 return Vector(0.,0.,0.);
111 }
112 virtual double getRadius() const {
113 return 0.;
114 }
115 virtual double getVolume() const
116 {
117 return 0.;
118 }
119 virtual double getSurfaceArea() const
120 {
121 return 0.;
122 }
123 virtual LineSegmentSet getLineIntersections(const Line &line) const{
124 return LineSegmentSet(line);
125 }
126 virtual std::string toString() const{
127 return "Nowhere()";
128 }
129 virtual enum ShapeType getType() const {
130 return NowhereType;
131 }
132 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const {
133 std::vector<Vector> PointsOnSurface;
134 return PointsOnSurface;
135 }
136 std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const {
137 return std::vector<Vector>();
138 }
139};
140
141class AndShape_impl : public Shape_impl {
142public:
143 AndShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&);
144 virtual ~AndShape_impl();
145 virtual bool isInside(const Vector &point) const;
146 virtual bool isOnSurface(const Vector &point) const;
147 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
148 virtual Vector getCenter() const;
149 virtual double getRadius() const;
150 virtual double getVolume() const;
151 virtual double getSurfaceArea() const;
152 virtual LineSegmentSet getLineIntersections(const Line&) const;
153 virtual std::string toString() const;
154 virtual enum ShapeType getType() const;
155 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
156 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
157private:
158 Shape::impl_ptr lhs;
159 Shape::impl_ptr rhs;
160};
161
162class OrShape_impl : public Shape_impl {
163public:
164 OrShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&);
165 virtual ~OrShape_impl();
166 virtual bool isInside(const Vector &point) const;
167 virtual bool isOnSurface(const Vector &point) const;
168 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
169 virtual Vector getCenter() const;
170 virtual double getRadius() const;
171 virtual double getVolume() const;
172 virtual double getSurfaceArea() const;
173 virtual LineSegmentSet getLineIntersections(const Line&) const;
174 virtual std::string toString() const;
175 virtual enum ShapeType getType() const;
176 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
177 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
178private:
179 Shape::impl_ptr lhs;
180 Shape::impl_ptr rhs;
181};
182
183class NotShape_impl : public Shape_impl {
184public:
185 NotShape_impl(const Shape::impl_ptr&);
186 virtual ~NotShape_impl();
187 virtual bool isInside(const Vector &point) const;
188 virtual bool isOnSurface(const Vector &point) const;
189 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
190 virtual Vector getCenter() const;
191 virtual double getRadius() const;
192 virtual double getVolume() const;
193 virtual double getSurfaceArea() const;
194 virtual LineSegmentSet getLineIntersections(const Line&) const;
195 virtual std::string toString() const;
196 virtual enum ShapeType getType() const;
197 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
198 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
199private:
200 Shape::impl_ptr arg;
201};
202
203Shape::impl_ptr getShapeImpl(const Shape&);
204
205#endif /* SHAPE_IMPL_HPP_ */
Note: See TracBrowser for help on using the repository browser.