API Documentation
Loading...
Searching...
No Matches
Cloth.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: NDEVRPCH
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32/*
33 * This source code is about a ground filtering algorithm for airborn LiDAR data
34 * based on physical process simulations, specifically cloth simulation.
35 *
36 * this code is based on a Cloth Simulation Tutorial at the cg.alexandra.dk blog.
37 * Thanks to Jesper Mosegaard (clothTutorial@jespermosegaard.dk)
38 *
39 *
40 *
41 * When applying the cloth simulation to LIDAR point filtering. A lot of features
42 * have been added to the original source code, including
43 * configuration file management
44 * point cloud data read/write
45 * point-to-point collsion detection
46 * nearest point search structure from CGAL
47 * addding a terrain class
48 *
49 *
50 */
51// using discrete steps (drop and pull) to approximate the physical process
52
53#pragma once
54#include "Particle.h"
59// post processing is only for connected component which is large than 50
60#define MAX_PARTICLE_FOR_POSTPROCESSIN 50
61
62
63namespace NDEVR
64{
65
66 class Cloth
67 {
68 private:
69
70 // total number of particles is num_particles_width * num_particles_height
71 uint04 constraint_iterations;
72
73 fltp04 time_step;
74
75 Buffer<Particle> particles; // all particles that are part of this cloth
76
77 fltp04 smoothThreshold;
78 fltp04 heightThreshold;
79 Vector<3, fltp04> m_acceleration;
80 Buffer<RGBColor> m_colors;
81 public:
84 Buffer<fltp04> heightvals; // height values
87 return particles[y * size[X] + x];
88 }
89 const Particle& getParticle(uint04 x, uint04 y) const {
90 return particles[y * size[X] + x];
91 }
92 const RGBColor& getColor(uint04 index)
93 {
94 return m_colors[index];
95 }
96 void setColor(uint04 index, RGBColor color)
97 {
98 m_colors[index] = color;
99 }
101 {
102 return y * size[X] + x;
103 }
105 {
106 return Vector<2, uint04>(index % size[X], index / size[X]);
107 }
109 public:
110
112 return size[X] * size[Y];
113 }
114
115
117 return heightvals;
118 }
119
121 return particles[index];
122 }
123 [[nodiscard]] const Buffer<Particle>& getParticles() const
124 {
125 return particles;
126 }
127 public:
128 Cloth(const Vector<3, fltp04>& origin_pos, const Vector<2, uint04>& size, const Vector<2, fltp04>& step, fltp04 smoothThreshold
129 , fltp04 heightThreshold, uint04 rigidness, fltp04 time_step, bool use_colors);
131
132 /* this is an important methods where the time is progressed one
133 * time step for the entire cloth. This includes calling
134 * satisfyConstraint() for every constraint, and calling
135 * timeStep() for all particles
136 */
137 void timeStep();
138
139 /* used to add gravity (or any other arbitrary vector) to all
140 * particles */
141 void addForce(const Vector<3, fltp04> direction);
142
143 void terrCollision();
144
145 void movableFilter();
146
147 void fillHoles();
149
150 void handle_slop_connected(const Buffer<uint04>& edgePoints, const Buffer<Vector<2, uint04>>& connected, const Buffer<Buffer<uint04>>& neibors);
151 };
152
153
154}
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
Definition Cloth.h:67
Particle & getParticle(uint04 x, uint04 y)
Definition Cloth.h:86
Buffer< fltp04 > & getHeightvals()
Definition Cloth.h:116
Vector< 2, uint04 > size
Definition Cloth.h:85
Buffer< uint04 > findUnmovablePoint(Buffer< Vector< 2, uint04 > > connected)
Definition Cloth.cpp:496
Particle & getParticle1d(uint04 index)
Definition Cloth.h:120
void handle_slop_connected(const Buffer< uint04 > &edgePoints, const Buffer< Vector< 2, uint04 > > &connected, const Buffer< Buffer< uint04 > > &neibors)
Definition Cloth.cpp:583
Vector< 3, fltp04 > getNormalAt(const Vector< 2, uint04 > &index) const
Definition Cloth.cpp:26
Cloth(const Vector< 3, fltp04 > &origin_pos, const Vector< 2, uint04 > &size, const Vector< 2, fltp04 > &step, fltp04 smoothThreshold, fltp04 heightThreshold, uint04 rigidness, fltp04 time_step, bool use_colors)
Definition Cloth.cpp:54
void setColor(uint04 index, RGBColor color)
Definition Cloth.h:96
Vector< 2, uint04 > get2DIndex(uint04 index) const
Definition Cloth.h:104
void timeStep()
Definition Cloth.cpp:114
void fillHoles()
Definition Cloth.cpp:362
void movableFilter()
Definition Cloth.cpp:226
Buffer< fltp04 > heightvals
Definition Cloth.h:84
const Buffer< Particle > & getParticles() const
Definition Cloth.h:123
Vertex< 3, fltp04 > origin_pos
Definition Cloth.h:82
fltp04 step_y
Definition Cloth.h:83
uint04 get1DIndex(uint04 x, uint04 y) const
Definition Cloth.h:100
void adjustParticleByNeighbor(Particle &p1, Particle &p2)
Definition Cloth.cpp:94
void addForce(const Vector< 3, fltp04 > direction)
Definition Cloth.cpp:200
const RGBColor & getColor(uint04 index)
Definition Cloth.h:92
fltp04 step_x
Definition Cloth.h:83
uint04 getSize()
Definition Cloth.h:111
void terrCollision()
Definition Cloth.cpp:212
const Particle & getParticle(uint04 x, uint04 y) const
Definition Cloth.h:89
Definition Particle.h:68
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
A vertex or point. A specific type of Vector used primarily for spacial location information.
Definition Vertex.hpp:48
Definition ACIColor.h:37
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:152
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:115
@ Y
Definition BaseValues.hpp:197
@ X
Definition BaseValues.hpp:195