source: src/Shapes/Shape_impl.hpp@ a636f8

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 a636f8 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
RevLine 
[997784]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
[56f73b]11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16
[6acc2f3]17#include <limits>
[c5186e]18#include <vector>
19
[5a8d61]20#include "CodePatterns/Assert.hpp"
21
[997784]22#include "Shapes/Shape.hpp"
[b94634]23#include "Shapes/ShapeExceptions.hpp"
[b92e4a]24#include "Shapes/ShapeType.hpp"
[6c438f]25#include "LinearAlgebra/Line.hpp"
[7672551]26#include "LinearAlgebra/LinePoint.hpp"
[6c438f]27#include "LinearAlgebra/LineSegment.hpp"
28#include "LinearAlgebra/LineSegmentSet.hpp"
29#include "LinearAlgebra/Vector.hpp"
[c6f395]30
[997784]31
32class Shape_impl {
33public:
[e09b70]34 Shape_impl(){};
35 virtual ~Shape_impl(){};
[735940]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;
[6acc2f3]39 virtual Vector getCenter() const=0;
40 virtual double getRadius() const=0;
[c67c65]41 virtual double getVolume() const=0;
42 virtual double getSurfaceArea() const=0;
[735940]43 virtual LineSegmentSet getLineIntersections(const Line&) const=0;
[b92e4a]44 virtual std::string toString() const =0;
45 virtual enum ShapeType getType() const =0;
[9c1c89]46 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const=0;
[5a8d61]47 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const=0;
[997784]48};
49
50class Everywhere_impl : public Shape_impl {
51public:
[735940]52 virtual bool isInside(const Vector &point) const{
[997784]53 return true;
54 }
[735940]55 virtual bool isOnSurface(const Vector &point) const{
[5de9da]56 return false;
57 }
[735940]58 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException){
[b94634]59 throw NotOnSurfaceException() << ShapeVector(&point);
[5de9da]60 }
[6acc2f3]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 }
[c67c65]67 virtual double getVolume() const
68 {
69 // TODO
70 return 0.;
71 }
72 virtual double getSurfaceArea() const
73 {
74 // TODO
75 return 0.;
76 }
[735940]77 virtual LineSegmentSet getLineIntersections(const Line &line) const{
[c6f395]78 LineSegmentSet res(line);
79 res.insert(LineSegment(line.negEndpoint(),line.posEndpoint()));
80 return res;
81 }
[b92e4a]82 virtual std::string toString() const{
[cfda65]83 return "Everywhere()";
84 }
[b92e4a]85 virtual enum ShapeType getType() const {
86 return EverywhereType;
87 }
[9c1c89]88 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const {
[c5186e]89 std::vector<Vector> PointsOnSurface;
90 return PointsOnSurface;
91 }
[5a8d61]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 }
[997784]97};
98
99class Nowhere_impl : public Shape_impl {
[735940]100 virtual bool isInside(const Vector &point) const{
[997784]101 return false;
102 }
[735940]103 virtual bool isOnSurface(const Vector &point) const{
[5de9da]104 return false;
105 }
[735940]106 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException){
[b94634]107 throw NotOnSurfaceException() << ShapeVector(&point);
[5de9da]108 }
[6acc2f3]109 virtual Vector getCenter() const {
110 return Vector(0.,0.,0.);
111 }
112 virtual double getRadius() const {
113 return 0.;
114 }
[c67c65]115 virtual double getVolume() const
116 {
117 return 0.;
118 }
119 virtual double getSurfaceArea() const
120 {
121 return 0.;
122 }
[735940]123 virtual LineSegmentSet getLineIntersections(const Line &line) const{
[c6f395]124 return LineSegmentSet(line);
125 }
[b92e4a]126 virtual std::string toString() const{
[cfda65]127 return "Nowhere()";
128 }
[b92e4a]129 virtual enum ShapeType getType() const {
130 return NowhereType;
131 }
[9c1c89]132 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const {
[c5186e]133 std::vector<Vector> PointsOnSurface;
134 return PointsOnSurface;
135 }
[5a8d61]136 std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const {
137 return std::vector<Vector>();
138 }
[997784]139};
140
141class AndShape_impl : public Shape_impl {
142public:
143 AndShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&);
144 virtual ~AndShape_impl();
[735940]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);
[6acc2f3]148 virtual Vector getCenter() const;
149 virtual double getRadius() const;
[c67c65]150 virtual double getVolume() const;
151 virtual double getSurfaceArea() const;
[735940]152 virtual LineSegmentSet getLineIntersections(const Line&) const;
[b92e4a]153 virtual std::string toString() const;
154 virtual enum ShapeType getType() const;
[9c1c89]155 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
[5a8d61]156 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
[997784]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();
[735940]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);
[6acc2f3]169 virtual Vector getCenter() const;
170 virtual double getRadius() const;
[c67c65]171 virtual double getVolume() const;
172 virtual double getSurfaceArea() const;
[735940]173 virtual LineSegmentSet getLineIntersections(const Line&) const;
[b92e4a]174 virtual std::string toString() const;
175 virtual enum ShapeType getType() const;
[9c1c89]176 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
[5a8d61]177 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
[997784]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();
[735940]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);
[6acc2f3]190 virtual Vector getCenter() const;
191 virtual double getRadius() const;
[c67c65]192 virtual double getVolume() const;
193 virtual double getSurfaceArea() const;
[735940]194 virtual LineSegmentSet getLineIntersections(const Line&) const;
[b92e4a]195 virtual std::string toString() const;
196 virtual enum ShapeType getType() const;
[9c1c89]197 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
[5a8d61]198 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
[997784]199private:
200 Shape::impl_ptr arg;
201};
202
[e09b70]203Shape::impl_ptr getShapeImpl(const Shape&);
204
[997784]205#endif /* SHAPE_IMPL_HPP_ */
Note: See TracBrowser for help on using the repository browser.