source: src/Shapes/Shape_impl.hpp@ 5a8d61

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 5a8d61 was 5a8d61, checked in by Frederik Heber <heber@…>, 13 years ago

Added new function to all Shape: getHomogeneousPointsInVolume().

  • basically it is not implemented except for ShapeOps, yet.
  • there is an initial unit test Shape_HomogeneousPointsUnitTest.
  • Property mode set to 100644
File size: 5.6 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/LineSegment.hpp"
27#include "LinearAlgebra/LineSegmentSet.hpp"
28#include "LinearAlgebra/Vector.hpp"
29
30
31class Shape_impl {
32public:
33 Shape_impl(){};
34 virtual ~Shape_impl(){};
35 virtual bool isInside(const Vector &point) const=0;
36 virtual bool isOnSurface(const Vector &point) const=0;
37 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException)=0;
38 virtual Vector getCenter() const=0;
39 virtual double getRadius() const=0;
40 virtual LineSegmentSet getLineIntersections(const Line&) const=0;
41 virtual std::string toString() const =0;
42 virtual enum ShapeType getType() const =0;
43 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const=0;
44 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const=0;
45};
46
47class Everywhere_impl : public Shape_impl {
48public:
49 virtual bool isInside(const Vector &point) const{
50 return true;
51 }
52 virtual bool isOnSurface(const Vector &point) const{
53 return false;
54 }
55 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException){
56 throw NotOnSurfaceException() << ShapeVector(&point);
57 }
58 virtual Vector getCenter() const {
59 return Vector(0.,0.,0.);
60 }
61 virtual double getRadius() const {
62 return std::numeric_limits<double>::infinity();
63 }
64 virtual LineSegmentSet getLineIntersections(const Line &line) const{
65 LineSegmentSet res(line);
66 res.insert(LineSegment(line.negEndpoint(),line.posEndpoint()));
67 return res;
68 }
69 virtual std::string toString() const{
70 return "Everywhere()";
71 }
72 virtual enum ShapeType getType() const {
73 return EverywhereType;
74 }
75 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const {
76 std::vector<Vector> PointsOnSurface;
77 return PointsOnSurface;
78 }
79 std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const {
80 ASSERT(0,
81 "Everywhere_impl::getHomogeneousPointsInVolume() - not implemented.");
82 return std::vector<Vector>();
83 }
84};
85
86class Nowhere_impl : public Shape_impl {
87 virtual bool isInside(const Vector &point) const{
88 return false;
89 }
90 virtual bool isOnSurface(const Vector &point) const{
91 return false;
92 }
93 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException){
94 throw NotOnSurfaceException() << ShapeVector(&point);
95 }
96 virtual Vector getCenter() const {
97 return Vector(0.,0.,0.);
98 }
99 virtual double getRadius() const {
100 return 0.;
101 }
102 virtual LineSegmentSet getLineIntersections(const Line &line) const{
103 return LineSegmentSet(line);
104 }
105 virtual std::string toString() const{
106 return "Nowhere()";
107 }
108 virtual enum ShapeType getType() const {
109 return NowhereType;
110 }
111 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const {
112 std::vector<Vector> PointsOnSurface;
113 return PointsOnSurface;
114 }
115 std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const {
116 return std::vector<Vector>();
117 }
118};
119
120class AndShape_impl : public Shape_impl {
121public:
122 AndShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&);
123 virtual ~AndShape_impl();
124 virtual bool isInside(const Vector &point) const;
125 virtual bool isOnSurface(const Vector &point) const;
126 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
127 virtual Vector getCenter() const;
128 virtual double getRadius() const;
129 virtual LineSegmentSet getLineIntersections(const Line&) const;
130 virtual std::string toString() const;
131 virtual enum ShapeType getType() const;
132 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
133 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
134private:
135 Shape::impl_ptr lhs;
136 Shape::impl_ptr rhs;
137};
138
139class OrShape_impl : public Shape_impl {
140public:
141 OrShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&);
142 virtual ~OrShape_impl();
143 virtual bool isInside(const Vector &point) const;
144 virtual bool isOnSurface(const Vector &point) const;
145 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
146 virtual Vector getCenter() const;
147 virtual double getRadius() const;
148 virtual LineSegmentSet getLineIntersections(const Line&) const;
149 virtual std::string toString() const;
150 virtual enum ShapeType getType() const;
151 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
152 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
153private:
154 Shape::impl_ptr lhs;
155 Shape::impl_ptr rhs;
156};
157
158class NotShape_impl : public Shape_impl {
159public:
160 NotShape_impl(const Shape::impl_ptr&);
161 virtual ~NotShape_impl();
162 virtual bool isInside(const Vector &point) const;
163 virtual bool isOnSurface(const Vector &point) const;
164 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
165 virtual Vector getCenter() const;
166 virtual double getRadius() const;
167 virtual LineSegmentSet getLineIntersections(const Line&) const;
168 virtual std::string toString() const;
169 virtual enum ShapeType getType() const;
170 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
171 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
172private:
173 Shape::impl_ptr arg;
174};
175
176Shape::impl_ptr getShapeImpl(const Shape&);
177
178#endif /* SHAPE_IMPL_HPP_ */
Note: See TracBrowser for help on using the repository browser.