TriangleWall.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, 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 
109  void setPosition(const Vec3D& position) override;
110 
111  void setOrientation(const Quaternion& orientation) override;
112 
117  void setVertices(Vec3D A, Vec3D B, Vec3D C, Vec3D position);
118 
119  void writeVTK(VTKContainer& vtk) const override;
120 
124  const Vec3D& getVertex(unsigned i) const {return vertex_[i];}
125 
130  bool getDistanceAndNormal(const BaseParticle& p, Mdouble& distance, Vec3D& normal_return) const override;
131 
132  void rotate(const Vec3D& angularVelocity) override;
133 
134  bool isLocal(Vec3D& min, Vec3D& max) const override;
135 
136  bool isInsideTriangle(const Vec3D &point) const;
137 
143  void moveVertex(unsigned index, const Vec3D& dP);
144 
149  void moveVertices(const std::array<Vec3D, 3>& dPs);
150 
151  bool isFaceContact(const Vec3D& normal) const override {
152  return (normal==faceNormal_ or normal == -faceNormal_) ? true : false;
153  }
154 
155 private:
156 
157  void updateVertexAndNormal();
158 
162  std::array<Vec3D, 3> vertexInLabFrame_;
167  std::array<Vec3D, 3> vertex_;
168 
174 
178  std::array<Vec3D, 3> edgeNormal_;
179  std::array<Vec3D, 3> edge_;
180  std::array<double, 3> edgeLength_;
181 
186 
187 // /*!
188 // * number of edges that should be treated as edges (instead of ignored)
189 // */
190 // unsigned nEdges = 3;
191 };
192 
193 #endif
double Mdouble
Definition: GeneralDefine.h:34
@ A
Definition: StatisticsVector.h:42
Definition: BaseParticle.h:54
Basic class for walls.
Definition: BaseWall.h:49
This class contains the 4 components of a quaternion and the standard operators and functions needed ...
Definition: Quaternion.h:63
A TriangleWall is convex polygon defined as an intersection of InfiniteWall's.
Definition: TriangleWall.h:57
Vec3D faceNormal_
Definition: TriangleWall.h:185
bool isFaceContact(const Vec3D &normal) const override
Definition: TriangleWall.h:151
Vec3D vertexMax_
Definition: TriangleWall.h:173
std::array< Vec3D, 3 > getVertices() const
Definition: TriangleWall.h:105
void updateVertexAndNormal()
Definition: TriangleWall.cc:218
TriangleWall(const TriangleWall &other)=default
Copy constructor.
void setVertices(Vec3D A, Vec3D B, Vec3D C)
Sets member variables such that the wall represents a triangle with vertices A, B,...
Definition: TriangleWall.cc:165
void writeVTK(VTKContainer &vtk) const override
Definition: TriangleWall.cc:149
void moveVertex(unsigned index, const Vec3D &dP)
Updates the indexed vertex by a given change in position.
Definition: TriangleWall.cc:265
std::array< Vec3D, 3 > vertexInLabFrame_
Definition: TriangleWall.h:162
std::array< Vec3D, 3 > edgeNormal_
Definition: TriangleWall.h:178
void write(std::ostream &os) const override
Writes an TriangleWall to an output stream, for example a restart file.
Definition: TriangleWall.cc:139
bool isLocal(Vec3D &min, Vec3D &max) const override
Definition: TriangleWall.cc:243
std::array< Vec3D, 3 > vertex_
Definition: TriangleWall.h:167
const Vec3D & getVertex(unsigned i) const
Returns the position of a vertex.
Definition: TriangleWall.h:124
Vec3D vertexMin_
Definition: TriangleWall.h:172
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
void setOrientation(const Quaternion &orientation) override
Sets the orientation of this BaseInteractable.
Definition: TriangleWall.cc:196
TriangleWall()=default
Default constructor.
std::array< double, 3 > edgeLength_
Definition: TriangleWall.h:180
~TriangleWall() override=default
Destructor.
std::string getName() const override
Returns the name of the object, here the string "TriangleWall".
Definition: TriangleWall.h:84
std::array< Vec3D, 3 > edge_
Definition: TriangleWall.h:179
TriangleWall * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Definition: TriangleWall.h:78
void moveVertices(const std::array< Vec3D, 3 > &dPs)
Updates all vertices by the given changes in position.
Definition: TriangleWall.cc:271
void setPosition(const Vec3D &position) override
Sets the position of this BaseInteractable.
Definition: TriangleWall.cc:190
void read(std::istream &is) override
Reads an TriangleWall from an input stream, for example a restart file.
Definition: TriangleWall.cc:123
bool isInsideTriangle(const Vec3D &point) const
Definition: TriangleWall.cc:250
void rotate(const Vec3D &angularVelocity) override
Rotates this BaseInteractable.
Definition: TriangleWall.cc:111
void move(const Vec3D &move) override
Definition: TriangleWall.cc:184
Definition: Vector.h:51
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
Definition: BaseWall.h:38