-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForce.h
executable file
·66 lines (66 loc) · 2.8 KB
/
Force.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
///////////////////////////////////////////////////////////////////////////////
// This file is part of ShapeOp, a lightweight C++ library
// for static and dynamic geometry processing.
//
// Copyright (C) 2014 Sofien Bouaziz <sofien.bouaziz@gmail.com>
// Copyright (C) 2014 LGG EPFL
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
///////////////////////////////////////////////////////////////////////////////
#ifndef FORCE_H
#define FORCE_H
///////////////////////////////////////////////////////////////////////////////
#include "Types.h"
///////////////////////////////////////////////////////////////////////////////
/** \file
This file contains all the forces (in fact defined as accelerations) of the ShapeOp library.*/
///////////////////////////////////////////////////////////////////////////////
namespace ShapeOp {
///////////////////////////////////////////////////////////////////////////////
/** \brief Base class of any forces. This class defines interface of a ShapeOp force.*/
class SHAPEOP_API Force {
public:
virtual ~Force() {;}
/** \brief Get force vector.*/
virtual Vector3 get(const Matrix3X &positions, int id) const = 0;
};
///////////////////////////////////////////////////////////////////////////////
/** \brief This class defines a constant force for all vertices.*/
class SHAPEOP_API GravityForce : public Force {
public:
/** \brief Constructor taking the gravity vector as parameter.*/
GravityForce(const Vector3 &f);
virtual ~GravityForce() {;}
/** \brief Get gravity vector.*/
virtual Vector3 get(const Matrix3X &/*positions*/, int /*id*/) const override final;
private:
Vector3 f_;
};
///////////////////////////////////////////////////////////////////////////////
/** \brief This class defines a constant force for a unique vertex.*/
class SHAPEOP_API VertexForce : public Force {
public:
/** \brief Constructor taking the force and the vertex id as parameters.*/
VertexForce(const Vector3 &f = Vector3::Zero(), int id = -1);
virtual ~VertexForce() {;}
/** \brief Get force vector.*/
virtual Vector3 get(const Matrix3X &/*position*/, int id) const override final;
/** \brief Set a new vertex id.*/
void setId(int id);
/** \brief Set a new force.*/
void setForce(const Vector3 &f);
private:
Vector3 f_;
int id_;
};
///////////////////////////////////////////////////////////////////////////////
} // namespace ShapeOp
///////////////////////////////////////////////////////////////////////////////
#ifdef SHAPEOP_HEADER_ONLY
#include "Force.cpp"
#endif
///////////////////////////////////////////////////////////////////////////////
#endif // FORCE_H
///////////////////////////////////////////////////////////////////////////////