File: Particle.h

package info (click to toggle)
cloudcompare 2.13.2%2Bgit20240821%2Bds-1
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 151,152 kB
  • sloc: cpp: 687,217; ansic: 165,269; python: 31,109; xml: 25,906; sh: 940; makefile: 509; java: 229; asm: 204; fortran: 160; javascript: 73; perl: 18
file content (113 lines) | stat: -rw-r--r-- 4,933 bytes parent folder | download | duplicates (2)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#pragma once

//#######################################################################################
//#                                                                                     #
//#                              CLOUDCOMPARE PLUGIN: qCSF                              #
//#                                                                                     #
//#        This program is free software; you can redistribute it and/or modify         #
//#        it under the terms of the GNU General Public License as published by         #
//#        the Free Software Foundation; version 2 or later of the License.             #
//#                                                                                     #
//#        This program is distributed in the hope that it will be useful,              #
//#        but WITHOUT ANY WARRANTY; without even the implied warranty of               #
//#        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                 #
//#        GNU General Public License for more details.                                 #
//#                                                                                     #
//#        Please cite the following paper, If you use this plugin in your work.        #
//#                                                                                     #
//#  Zhang W, Qi J, Wan P, Wang H, Xie D, Wang X, Yan G. An Easy-to-Use Airborne LiDAR  #
//#  Data Filtering Method Based on Cloth Simulation. Remote Sensing. 2016; 8(6):501.   #
//#                                                                                     #
//#                                     Copyright                                      #
//#               RAMM laboratory, School of Geography, Beijing Normal University       #
//#                               (http://ramm.bnu.edu.cn/)                             #
//#                                                                                     #
//#                      Wuming Zhang; Jianbo Qi; Peng Wan; Hongtao Wang                #
//#                                                                                     #
//#                      contact us: 2009zwm@gmail.com; wpqjbzwm@126.com                #
//#                                                                                     #
//#######################################################################################

#include <vector>
#include <limits>

#include "Vec3.h"

/* The particle class represents a particle that can move around in 3D space*/
class Particle
{
private:
	bool movable; // can the particle move or not ? used to pin parts of the cloth
	//double mass; // the mass of the particle (is always 1 in this example)
	double acceleration; // the current acceleration of the particle (along Y) - DGM: already multiplied by dt^
	//double time_step2; // square time step

	Vec3 pos; // the current position of the particle in 3D space
	double old_pos_y; // the altitude of the particle at the previous time step, used as part of the verlet numerical integration scheme
public:
	//these members are used in the process of edge smoothing after the cloth simulation step.
	bool isVisited;
	int pos_x; // X position in the cloth grid
	int pos_y; // Y position in the cloth grid
	int c_pos; // position in the group of movable points

	//for constraint computation
	std::vector<Particle*> neighborsList; //record all the neighbors in cloth grid

	//for rasterization
	//std::vector<int> correspondingLidarPointList; // the correspoinding lidar point list (DGM: not used)
	//std::size_t nearestPointIndex; // nearest lidar point (DGM: not used)
	double nearestPointHeight; // the height(y) of the nearest lidar point
	double nearestPointDist; // only for internal computation

public:

	Particle()
		: movable(true)
		//, mass(1.0)
		, acceleration(0)
		//, time_step2(0)
		, isVisited(false)
		, pos_x(0)
		, pos_y(0)
		, c_pos(0)
		, pos(0, 0, 0)
		, old_pos_y(0)
		, nearestPointHeight(std::numeric_limits<double>::lowest())
		, nearestPointDist(std::numeric_limits<double>::max())
	{}
	
	Particle(const Vec3& posVec/*, double squareTimeStep*/)
		: Particle()
	{
		pos = posVec;
		old_pos_y = posVec.y;
		//time_step2 = squareTimeStep;
	}

	inline const Vec3& getPos() const { return pos; }
	inline double getPreviousY() const { return old_pos_y; }

	/* This is one of the important methods, where the time is progressed a single step size (TIME_STEPSIZE)
	The method is called by Cloth.time_step()*/
	void timeStep();

	inline bool isMovable() const { return movable; }

	inline void addForce(double f) { acceleration += f/*/ mass*/; }

	inline void resetAcceleration() { acceleration = 0; }

	inline void offsetPos(double dy)
	{
		if (movable)
		{
			pos.y += dy;
		}
	}

	inline void makeUnmovable() { movable = false; }

	//do constraint
	void satisfyConstraintSelf(int constraintTimes);
};