NuTo
Numerics Tool
CollidableBase.h
Go to the documentation of this file.
1 /*
2  * CollidableBase.h
3  *
4  * Created on: 17 Jan 2014
5  * Author: ttitsche
6  */
7 
8 #pragma once
9 
10 #include <vector>
11 
12 namespace NuTo
13 {
14 class CollidableParticleSphere;
15 class CollidableWallBase;
16 class SubBox;
17 class Event;
18 
19 typedef std::vector<Event*> LocalEvents;
20 
23 {
25  friend class Event;
26 
27 public:
28  typedef std::vector<CollidableParticleSphere*> ParticleContainer;
29 
32  CollidableBase(int rIndex);
33 
35  virtual ~CollidableBase();
36 
38  int GetIndex() const;
39 
42  virtual void PerformCollision(CollidableBase& rCollidable) = 0;
43 
46  virtual void PerformCollision(CollidableParticleSphere& rSphere) = 0;
47 
50  virtual void PerformCollision(CollidableWallBase& rWall) = 0;
51 
56  virtual double PredictCollision(CollidableBase& rCollidable, int& rType) = 0;
57 
62  virtual double PredictCollision(CollidableParticleSphere& rSphere, int& rType) = 0;
63 
68  virtual double PredictCollision(CollidableWallBase& rWall, int& rType) = 0;
69 
72  void AddBox(SubBox& rBox);
73 
76  void RemoveBox(SubBox& rBox);
77 
80  virtual void MoveAndGrow(double rTime) = 0;
81 
82 
85  virtual void GetLocalEventsToDelete(LocalEvents& rEventsToDelete) const = 0;
86 
88  void PrintLocalEvents() const;
89 
91  const std::vector<SubBox*>& GetSubBoxes() const;
92 
93 #ifndef SWIG
94  friend std::ostream& operator<<(std::ostream& rOutStream, const CollidableBase* rCollidable);
99 #endif
100  virtual void Print(std::ostream& rReturnStream) const = 0;
103 
104 protected:
106  int mIndex;
107 
110  std::vector<SubBox*> mBoxes;
111 
116  LocalEvents mLocalEvents;
117 };
118 
119 } /* namespace NuTo */
LocalEvents mLocalEvents
local event list adding single event: through EventBase::AddLocalEvents() remove single event: throug...
Definition: CollidableBase.h:116
virtual void Print(std::ostream &rReturnStream) const =0
prints information based on derived class type.
virtual double PredictCollision(CollidableBase &rCollidable, int &rType)=0
collision prediction between (this) and collision partner
class for spherical collidables
Definition: CollidableParticleSphere.h:28
const std::vector< SubBox * > & GetSubBoxes() const
returns all the SubBoxes of this collidable
Definition: CollidableBase.cpp:40
virtual void PerformCollision(CollidableBase &rCollidable)=0
collision handling, resolve double dispatch
class for sub box handing -> improves the performance without changing the physics ...
Definition: SubBox.h:20
virtual void MoveAndGrow(double rTime)=0
updates this collidable in time
virtual void GetLocalEventsToDelete(LocalEvents &rEventsToDelete) const =0
returns all old events, that need to be deleted
class for storing events
Definition: Event.h:22
void RemoveBox(SubBox &rBox)
removes a SubBox from this collidable
Definition: CollidableBase.cpp:51
virtual ~CollidableBase()
destructor
Definition: CollidableBase.cpp:23
std::vector< CollidableParticleSphere * > ParticleContainer
Definition: CollidableBase.h:28
void PrintLocalEvents() const
prints the local event list
Definition: CollidableBase.cpp:32
int mIndex
index, just a name for each collidable, multiple collidables with the same index possible ...
Definition: CollidableBase.h:106
Base class for all collidables.
Definition: CollidableBase.h:22
friend std::ostream & operator<<(std::ostream &rOutStream, const CollidableBase *rCollidable)
standard output for all collidables, calls Print(...) for polymorph behaviour
Definition: CollidableBase.cpp:64
Definition: Exception.h:6
base class for walls
Definition: CollidableWallBase.h:23
int GetIndex() const
getter for collidable index
Definition: CollidableBase.cpp:27
std::vector< SubBox * > mBoxes
list of SubBoxes in which this collidable is inside if the collidable is passing a virutal sub box wa...
Definition: CollidableBase.h:110
std::vector< Event * > LocalEvents
Definition: CollidableBase.h:17
CollidableBase(int rIndex)
constructor, initialized with an index
Definition: CollidableBase.cpp:18
void AddBox(SubBox &rBox)
adds a SubBox to this collidable
Definition: CollidableBase.cpp:46