MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IntersectionOfWalls.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef INTERSECTIONOFWALLS_H
27 #define INTERSECTIONOFWALLS_H
28 
29 #include <vector>
30 #include "BaseWall.h"
31 #include "InfiniteWall.h"
32 #include "Math/Vector.h"
33 
56 {
57 public:
61  };
62 
67 
72 
76  IntersectionOfWalls(std::vector<normalAndPosition> walls, const ParticleSpecies* species);
77 
81  virtual ~IntersectionOfWalls();
82 
87 
91  IntersectionOfWalls* copy() const override;
92 
98  void clear() override;
99 
101  void setSpecies(const ParticleSpecies* species);
102 
103  void setHandler(WallHandler* wallHandler) override;
104 
108  void addObject(Vec3D normal, Vec3D point);
109 
115  void addObject(Vec3D normal, Mdouble position);
116 
120  void createOpenPrism(std::vector<Vec3D> points, Vec3D prismAxis);
121 
125  void createPrism(std::vector<Vec3D> points, Vec3D prismAxis);
126 
130  void createOpenPrism(std::vector<Vec3D> points);
131 
135  void createPrism(std::vector<Vec3D> points);
136 
140  bool getDistanceAndNormal(const BaseParticle& p, Mdouble& distance, Vec3D& normal_return) const override;
141 
145  bool getDistanceAndNormal(const Vec3D& postition, Mdouble wallInteractionRadius, Mdouble& distance, Vec3D& normal_return) const;
146 
150  void move(const Vec3D& move) override;
151 
155  void read(std::istream& is) override;
156 
160  void write(std::ostream& os) const override;
161 
165  std::string getName() const override;
166 
167  void writeVTK (VTKContainer& vtk) const override;
168 
169 protected:
176  std::vector<InfiniteWall> wallObjects_;
177 
178 private:
184  std::vector<Vec3D> A_;
185 
191  std::vector<Vec3D> AB_;
192 
198  std::vector<Vec3D> C_;
199 };
200 
201 #endif
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
void writeVTK(VTKContainer &vtk) const override
void read(std::istream &is) override
Reads an IntersectionOfWalls from an input stream, for example a restart file.
double Mdouble
bool getDistanceAndNormal(const BaseParticle &p, Mdouble &distance, Vec3D &normal_return) const override
Compute the distance from the wall for a given BaseParticle and return if there is a collision...
std::string getName() const override
Returns the name of the object, here the string "IntersectionOfWalls".
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given an outward normal vector s.t. normal*x=normal*point.
#define MERCURY_DEPRECATED
Definition: GeneralDefine.h:37
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
void createOpenPrism(std::vector< Vec3D > points, Vec3D prismAxis)
Creates an open prism which is a polygon between the points, except the first and last point...
void setSpecies(const ParticleSpecies *species)
sets species of subwalls as well
IntersectionOfWalls()
Default constructor.
MERCURY_DEPRECATED void clear() override
Removes all parts of the walls.
std::vector< Vec3D > C_
A vector that stores the intersection point of three different InfiniteWall.
std::vector< Vec3D > A_
A vector that stores a point for each intersecting line between two different InfiniteWall.
Basic class for walls.
Definition: BaseWall.h:44
void move(const Vec3D &move) override
Move the IntersectionOfWalls to a new position, which is a Vec3D from the old position.
IntersectionOfWalls * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Container to store all BaseWall.
Definition: WallHandler.h:42
std::vector< Vec3D > AB_
A vector that stores the direction of the intersecting lines between two different InfiniteWall...
void createPrism(std::vector< Vec3D > points, Vec3D prismAxis)
Creates an open prism which is a polygon between the points and extends infinitely in the PrismAxis d...
virtual ~IntersectionOfWalls()
Destructor.
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
IntersectionOfWalls & operator=(const IntersectionOfWalls &other)
void setHandler(WallHandler *wallHandler) override
A function which sets the WallHandler for this BaseWall.
void write(std::ostream &os) const override
Writes an IntersectionOfWalls to an output stream, for example a restart file.