MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TriangleWall.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 TriangleWall_H
27 #define TriangleWall_H
28 
29 #include <vector>
30 #include "BaseWall.h"
31 #include "InfiniteWall.h"
32 #include "Math/Vector.h"
33 
56 class TriangleWall : public BaseWall
57 {
58 public:
59 
63  TriangleWall() = default;
64 
68  TriangleWall(const TriangleWall& other) = default;
69 
73  ~TriangleWall() override = default;
74 
78  TriangleWall* copy() const override
79  { return new TriangleWall(*this); }
80 
84  std::string getName() const override
85  { return "TriangleWall"; }
86 
90  void read(std::istream& is) override;
91 
95  void write(std::ostream& os) const override;
96 
103  void setVertices(Vec3D A, Vec3D B, Vec3D C);
104 
105  std::array<Vec3D,3> getVertices() const {return vertex_;}
106 
107  void move(const Vec3D& move) override;
108 
113  void setVertices(Vec3D A, Vec3D B, Vec3D C, Vec3D position);
114 
115  void writeVTK(VTKContainer& vtk) const override;
116 
120  const Vec3D& getVertex(unsigned i) const {return vertex_[i];}
121 
126  bool getDistanceAndNormal(const BaseParticle& p, Mdouble& distance, Vec3D& normal_return) const override;
127 
128  void rotate(const Vec3D& angularVelocity) override;
129 
130  bool isLocal(Vec3D& min, Vec3D& max) const override;
131 
132  bool isInsideTriangle(const Vec3D &point) const;
133 
134 private:
135 
136  void updateVertexAndNormal();
137 
141  std::array<Vec3D, 3> vertexInLabFrame_;
146  std::array<Vec3D, 3> vertex_;
147 
153 
157  std::array<Vec3D, 3> edgeNormal_;
158  std::array<Vec3D, 3> edge_;
159  std::array<double, 3> edgeLength_;
160 
165 
166 // /*!
167 // * number of edges that should be treated as edges (instead of ignored)
168 // */
169 // unsigned nEdges = 3;
170 };
171 
172 #endif
A TriangleWall is convex polygon defined as an intersection of InfiniteWall's.
Definition: TriangleWall.h:56
Vec3D faceNormal_
Definition: TriangleWall.h:164
double Mdouble
Definition: GeneralDefine.h:34
std::array< Vec3D, 3 > edge_
Definition: TriangleWall.h:158
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
void updateVertexAndNormal()
This function should be called after setting either position_ or vertexInLabFrame_.
Vec3D vertexMax_
Definition: TriangleWall.h:152
void writeVTK(VTKContainer &vtk) const override
void read(std::istream &is) override
Reads an TriangleWall from an input stream, for example a restart file.
TriangleWall * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Definition: TriangleWall.h:78
std::array< double, 3 > edgeLength_
Definition: TriangleWall.h:159
TriangleWall()=default
Default constructor.
std::array< Vec3D, 3 > getVertices() const
Definition: TriangleWall.h:105
bool isInsideTriangle(const Vec3D &point) const
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...
Definition: TriangleWall.cc:57
Vec3D vertexMin_
Definition: TriangleWall.h:151
void setVertices(Vec3D A, Vec3D B, Vec3D C)
Sets member variables such that the wall represents a triangle with vertices A, B, C.
std::array< Vec3D, 3 > vertex_
Definition: TriangleWall.h:146
void write(std::ostream &os) const override
Writes an TriangleWall to an output stream, for example a restart file.
Basic class for walls.
Definition: BaseWall.h:47
std::string getName() const override
Returns the name of the object, here the string "TriangleWall".
Definition: TriangleWall.h:84
Definition: Vector.h:49
std::array< Vec3D, 3 > edgeNormal_
Definition: TriangleWall.h:157
void move(const Vec3D &move) override
~TriangleWall() override=default
Destructor.
void rotate(const Vec3D &angularVelocity) override
Rotates this BaseInteractable.
std::array< Vec3D, 3 > vertexInLabFrame_
Definition: TriangleWall.h:141
bool isLocal(Vec3D &min, Vec3D &max) const override
const Vec3D & getVertex(unsigned i) const
Returns the position of a vertex.
Definition: TriangleWall.h:120