MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TriangulatedWall.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 TriangulatedWall_H
27 #define TriangulatedWall_H
28 
29 #include <vector>
30 #include "BaseWall.h"
31 #include "Math/Vector.h"
32 #include <array>
33 
51 class TriangulatedWall : public BaseWall
52 {
53 public:
54 
59  struct Face
60  {
62  std::array<Vec3D*,3> vertex;
64  std::array<Face*,3> neighbor = {{nullptr}};
66  std::array<Vec3D,3> edgeNormal;
70  Mdouble getDistance(const Vec3D& otherPosition) const;
72  bool getDistanceAndNormal(const BaseParticle &p, Mdouble &distance, Vec3D &normal_return) const;
73  };
74 
79 
83  TriangulatedWall(const TriangulatedWall &other);
84 
88  TriangulatedWall(std::string filename, const ParticleSpecies *species);
89 
90  void readVTK(std::string filename);
91 
92  void writeVTK (VTKContainer& vtk) const override;
93 
97  virtual ~TriangulatedWall();
98 
103 
107  TriangulatedWall *copy() const override;
108 
112  bool getDistanceAndNormal(const BaseParticle &p, Mdouble &distance, Vec3D &normal_return) const override;
113 
117  void move(const Vec3D &move) override;
118 
122  void read(std::istream &is) override;
123 
127  void write(std::ostream &os) const override;
128 
132  std::string getName() const override;
133 
137  std::vector<BaseInteraction*> getInteractionWith(BaseParticle *p, Mdouble timeStamp,
138  InteractionHandler *interactionHandler) override;
139 
140 private:
144  std::vector<Vec3D> vertex_;
145 
149  std::vector<Face> face_;
150 
151 };
152 
153 
154 #endif
TriangulatedWall()
Default constructor.
bool getDistanceAndNormal(const BaseParticle &p, Mdouble &distance, Vec3D &normal_return) const
Returns true if contact with the face exists, false if not. If contact exists, then the distance and ...
A TriangulatedWall is a triangulation created from a set of vertices and a n-by-3 connectivity matrix...
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...
double Mdouble
void write(std::ostream &os) const override
Writes an TriangulatedWall to an output stream, for example a restart file.
std::vector< Vec3D > vertex_
Struct used to store the properties of a face needed for contact detection.
void read(std::istream &is) override
Reads an TriangulatedWall from an input stream, for example a restart file.
TriangulatedWall & operator=(const TriangulatedWall &other)
void readVTK(std::string filename)
std::vector< BaseInteraction * > getInteractionWith(BaseParticle *p, Mdouble timeStamp, InteractionHandler *interactionHandler) override
Get the interaction between this TriangulatedWall and given BaseParticle at a given time...
std::array< Vec3D *, 3 > vertex
defines the three vertices (anticlockwise direction around the normal)
Container to store Interaction objects.
std::string getName() const override
Returns the name of the object, here the string "TriangulatedWall".
Vec3D normal
face normal (vertices are ordered anticlockwise direction around the normal)
void writeVTK(VTKContainer &vtk) const override
Basic class for walls.
Definition: BaseWall.h:44
void move(const Vec3D &move) override
Move the TriangulatedWall to a new position, which is a Vec3D from the old position.
std::array< Vec3D, 3 > edgeNormal
For each edge, stores the vector normal to the face normal and the edge direction (vector between the...
std::vector< Face > face_
virtual ~TriangulatedWall()
Destructor.
TriangulatedWall * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Mdouble getDistance(const Vec3D &otherPosition) const
computes the signed distance to the face in normal direction
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
std::array< Face *, 3 > neighbor
For each edge, stores the neighboring face (nullptr if none)