21 std::vector<int>& groundIndexes,
22 std::vector<int>& offGroundIndexes,
30 for (
int i = 0; i < pc.size(); i++) {
31 double pc_x = pc[i].x;
32 double pc_z = pc[i].z;
39 int col0 = int(deltaX / cloth.
step_x);
40 int row0 = int(deltaZ / cloth.
step_y);
49 double subdeltaX = (deltaX - col0 * cloth.
step_x) / cloth.
step_x;
50 double subdeltaZ = (deltaZ - row0 * cloth.
step_y) / cloth.
step_y;
62 double height_var = fxy - pc[i].y;
64 groundIndexes.push_back(i);
66 offGroundIndexes.push_back(i);
69 }
catch (
const std::bad_alloc&) {
80 #include <CGAL/Orthogonal_k_neighbor_search.h>
81 #include <CGAL/Search_traits_2.h>
82 #include <CGAL/Simple_cartesian.h>
83 #include <CGAL/point_generators_2.h>
85 typedef CGAL::Simple_cartesian<double> K;
86 typedef K::Point_2 Point_d;
87 typedef CGAL::Search_traits_2<K> TreeTraits;
88 typedef CGAL::Orthogonal_k_neighbor_search<TreeTraits> Neighbor_search;
89 typedef Neighbor_search::Tree Tree;
94 std::vector<int>& groundIndexes,
95 std::vector<int>& offGroundIndexes,
98 std::list<Point_d> points_2d;
99 std::map<std::string, double> mapstring;
102 for (
int i = 0; i < cloth.
getSize(); i++) {
104 std::ostringstream ostrx, ostrz;
105 ostrx << particle.
pos.
x;
106 ostrz << particle.
pos.
z;
107 mapstring.insert(std::pair<std::string, double>(
108 ostrx.str() + ostrz.str(), particle.
pos.
y));
109 points_2d.push_back(Point_d(particle.
pos.
x, particle.
pos.
z));
112 Tree tree(points_2d.begin(), points_2d.end());
114 for (
int i = 0; i < pc.size(); i++) {
115 Point_d query(pc[i].x, pc[i].z);
116 Neighbor_search search(tree, query, N);
117 double search_min = 0;
118 for (Neighbor_search::iterator it = search.begin();
119 it != search.end(); it++) {
120 std::ostringstream ostrx, ostrz;
121 ostrx << it->first.x();
122 ostrz << it->first.y();
123 double y = mapstring[ostrx.str() + ostrz.str()];
124 search_min = search_min + y / N;
131 groundIndexes.push_back(i);
133 offGroundIndexes.push_back(i);
136 }
catch (
const std::bad_alloc&) {
150 #include <SimpleCloud.h>
154 static bool ComputeMeanNeighborAltitude(
156 void** additionalParameters,
159 const Cloth& cloth = *(
const Cloth*)additionalParameters[0];
162 unsigned N = *(
unsigned*)additionalParameters[2];
176 for (
unsigned i = 0; i < pointCount; i++) {
188 double search_min = 0;
189 for (
unsigned k = 0; k < kNN; ++k) {
197 static_cast<ScalarType
>(search_min));
206 std::vector<int>& groundIndexes,
207 std::vector<int>& offGroundIndexes,
209 cloudViewer::SimpleCloud particlePoints;
210 if (!particlePoints.reserve(
static_cast<unsigned>(cloth.
getSize()))) {
214 for (
int i = 0; i < cloth.
getSize(); i++) {
216 particlePoints.addPoint(
221 cloudViewer::SimpleCloud pcPoints;
222 if (!pcPoints.reserve(
static_cast<unsigned>(pc.size())) ||
223 !pcPoints.enableScalarField()) {
227 for (
size_t i = 0; i < pc.size(); i++) {
237 &particlePoints, &pcPoints, particleOctree, cloudOctree,
247 void* additionalParameters[] = {(
void*)(&cloth),
248 (
void*)(particleOctree), (
void*)(&N)};
252 std::max<unsigned>(2, N));
255 octreeLevel, ComputeMeanNeighborAltitude, additionalParameters,
256 true, 0,
"Rasterization", QThread::idealThreadCount());
261 delete particleOctree;
270 for (
unsigned i = 0; i < pcPoints.size(); ++i) {
271 if (
std::fabs(pcPoints.getPointScalarValue(i) - pc[i].y) <
273 groundIndexes.push_back(i);
275 offGroundIndexes.push_back(i);
279 }
catch (
const std::bad_alloc&) {
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
static double class_threshold
Particle & getParticleByIndex(int index)
Particle & getParticle(int x, int y)
static bool Compute(const Cloth &cloth, const wl::PointCloud &pc, double class_threshold, std::vector< int > &groundIndexes, std::vector< int > &offGroundIndexes, unsigned N=3)
The octree structure used throughout the library.
void getCellPos(CellCode code, unsigned char level, Tuple3i &cellPos, bool isCodeTruncated) const
unsigned findNearestNeighborsStartingFromCell(NearestNeighboursSearchStruct &nNSS, bool getOnlyPointsWithValidScalar=false) const
void computeCellCenter(CellCode code, unsigned char level, CCVector3 ¢er, bool isCodeTruncated=false) const
unsigned executeFunctionForAllCellsAtLevel(unsigned char level, octreeCellFunc func, void **additionalParameters, bool multiThread=false, GenericProgressCallback *progressCb=nullptr, const char *functionTitle=nullptr, int maxThreadCount=0)
unsigned char findBestLevelForAGivenPopulationPerCell(unsigned indicativeNumberOfPointsPerCell) const
void setPointScalarValue(unsigned pointIndex, ScalarType value) override
Sets the ith point associated scalar value.
unsigned size() const override
Returns the number of points.
const CCVector3 * getPoint(unsigned index) const override
Returns the ith point.
__host__ __device__ float2 fabs(float2 v)
ReferenceCloud * points
Set of points lying inside this cell.
unsigned char level
Cell level of subdivision.
CellCode truncatedCode
Truncated cell code.