MercuryDPM  Trunk
 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-2020, 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;
69 
71  Mdouble getDistance(const Vec3D& otherPosition) const;
72 
74  bool getDistanceAndNormal(const BaseParticle& p, Mdouble& distance, Vec3D& normal_return, Mdouble interactionRadius) const;
75  };
76 
81 
85  TriangulatedWall(const TriangulatedWall& other);
86 
90  TriangulatedWall(std::string filename, const ParticleSpecies* species);
91 
92  void readVTK(std::string filename);
93 
94  void writeVTK(VTKContainer& vtk) const override;
95 
99  ~TriangulatedWall() override;
100 
105 
109  TriangulatedWall* copy() const override;
110 
114  bool getDistanceAndNormal(const BaseParticle& p, Mdouble& distance, Vec3D& normal_return) const override;
115 
119  void move(const Vec3D& move) override;
120 
124  void read(std::istream& is) override;
125 
129  void write(std::ostream& os) const override;
130 
134  std::string getName() const override;
135 
139  BaseInteraction* getInteractionWith(BaseParticle* p, unsigned timeStamp,
140  InteractionHandler* interactionHandler) override;
141 
142 private:
146  std::vector<Vec3D> vertex_;
147 
151  std::vector<Face> face_;
152 
153 };
154 
155 
156 #endif
TriangulatedWall()
Default constructor.
double Mdouble
Definition: GeneralDefine.h:34
A TriangulatedWall is a triangulation created from a set of vertices and a n-by-3 connectivity matrix...
BaseInteraction * getInteractionWith(BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
Get the interaction between this TriangulatedWall and given BaseParticle at a given time...
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...
void write(std::ostream &os) const override
Writes an TriangulatedWall to an output stream, for example a restart file.
Stores information about interactions between two interactable objects; often particles but could be ...
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::array< Face *, 3 > neighbor
For each edge, stores the neighboring face (nullptr if none)
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)
std::array< Vec3D, 3 > edgeNormal
For each edge, stores the vector normal to the face normal and the edge direction (vector between the...
void writeVTK(VTKContainer &vtk) const override
Basic class for walls.
Definition: BaseWall.h:47
std::array< Vec3D *, 3 > vertex
defines the three vertices (anticlockwise direction around the normal)
void move(const Vec3D &move) override
Move the TriangulatedWall to a new position, which is a Vec3D from the old position.
std::vector< Face > face_
~TriangulatedWall() override
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
bool getDistanceAndNormal(const BaseParticle &p, Mdouble &distance, Vec3D &normal_return, Mdouble interactionRadius) const
Returns true if contact with the face exists, false if not. If contact exists, then the distance and ...
Definition: Vector.h:49