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 \brief The data and operations for performing bare earth using Cloth simulation.
67 **/
68 class Cloth
69 {
70 private:
71
72 // total number of particles is num_particles_width * num_particles_height
73 uint04 constraint_iterations;
74
75 fltp04 time_step;
76
77 Buffer<Particle> particles; // all particles that are part of this cloth
78
79 fltp04 smoothThreshold;
80 fltp04 heightThreshold;
81 Vector<3, fltp04> m_acceleration;
82 Buffer<RGBColor> m_colors;
83 public:
86 Buffer<fltp04> heightvals; // height values
89 return particles[y * size[X] + x];
90 }
91 const Particle& getParticle(uint04 x, uint04 y) const {
92 return particles[y * size[X] + x];
93 }
94 const RGBColor& getColor(uint04 index)
95 {
96 return m_colors[index];
97 }
98 void setColor(uint04 index, RGBColor color)
99 {
100 m_colors[index] = color;
101 }
103 {
104 return y * size[X] + x;
105 }
107 {
108 return Vector<2, uint04>(index % size[X], index / size[X]);
109 }
111 public:
112
114 return size[X] * size[Y];
115 }
116
117
119 return heightvals;
120 }
121
123 return particles[index];
124 }
125 [[nodiscard]] const Buffer<Particle>& getParticles() const
126 {
127 return particles;
128 }
129 public:
131 , fltp04 heightThreshold, uint04 rigidness, fltp04 time_step, bool use_colors);
133
134 /* this is an important methods where the time is progressed one
135 * time step for the entire cloth. This includes calling
136 * satisfyConstraint() for every constraint, and calling
137 * timeStep() for all particles
138 */
139 void timeStep();
140
141 /* used to add gravity (or any other arbitrary vector) to all
142 * particles */
143 void addForce(const Vector<3, fltp04> direction);
144
146
148
149 void fillHoles();
151
152 void handle_slop_connected(const Buffer<uint04>& edgePoints, const Buffer<Vector<2, uint04>>& connected, const Buffer<Buffer<uint04>>& neibors);
153 };
154
155
156}
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
The data and operations for performing bare earth using Cloth simulation.
Definition Cloth.h:69
Particle & getParticle(uint04 x, uint04 y)
Definition Cloth.h:88
Buffer< fltp04 > & getHeightvals()
Definition Cloth.h:118
Vector< 2, uint04 > size
Definition Cloth.h:87
Buffer< uint04 > findUnmovablePoint(Buffer< Vector< 2, uint04 > > connected)
Particle & getParticle1d(uint04 index)
Definition Cloth.h:122
void handle_slop_connected(const Buffer< uint04 > &edgePoints, const Buffer< Vector< 2, uint04 > > &connected, const Buffer< Buffer< uint04 > > &neibors)
Vector< 3, fltp04 > getNormalAt(const Vector< 2, uint04 > &index) const
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)
void setColor(uint04 index, RGBColor color)
Definition Cloth.h:98
Vector< 2, uint04 > get2DIndex(uint04 index) const
Definition Cloth.h:106
void timeStep()
void fillHoles()
void movableFilter()
Buffer< fltp04 > heightvals
Definition Cloth.h:86
const Buffer< Particle > & getParticles() const
Definition Cloth.h:125
Vertex< 3, fltp04 > origin_pos
Definition Cloth.h:84
fltp04 step_y
Definition Cloth.h:85
uint04 get1DIndex(uint04 x, uint04 y) const
Definition Cloth.h:102
void adjustParticleByNeighbor(Particle &p1, Particle &p2)
void addForce(const Vector< 3, fltp04 > direction)
const RGBColor & getColor(uint04 index)
Definition Cloth.h:94
fltp04 step_x
Definition Cloth.h:85
uint04 getSize()
Definition Cloth.h:113
void terrCollision()
const Particle & getParticle(uint04 x, uint04 y) const
Definition Cloth.h:91
Used with CSF Cloth, The particle class represents a particle of mass that can move around in 3D spac...
Definition Particle.h:69
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:54
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 Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
@ Y
Definition BaseValues.hpp:169
@ X
Definition BaseValues.hpp:167