PeriDyno 1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PoissonDiskSampling.h
Go to the documentation of this file.
1
16
17#pragma once
18#include "Node.h"
19
21#include "Topology/PointSet.h"
22#include "Samplers/Sampler.h"
23#include "FilePath.h"
25#include <Volume/VolumeOctree.h>
26#include "SdfSampler.h"
27namespace dyno
28{
29 struct GridIndex
30 {
31 int i, j, k;
32 };
33
34 template<typename TDataType>
35 class PoissonDiskSampling : public SdfSampler<TDataType>
36 {
38
39 public:
40 typedef typename TDataType::Real Real;
41 typedef typename TDataType::Coord Coord;
43
45
47 bool collisionJudge(Coord point);
48
49 std::shared_ptr<DistanceField3D<TDataType>> loadSdf();
50
51 DEF_VAR(Coord, Box_a, 0.0f, "Lower boudary of the sampling area");
52 DEF_VAR(Coord, Box_b, 0.1f, "Upper boundary of the sampling area");
53
54 //.SDF file
55 DEF_VAR(FilePath, SdfFileName, "", "");
56
57 Real lerp(Real a, Real b, Real alpha);
58
59 Real getDistanceFromSDF(const Coord& p, Coord& normal);
60
61 std::shared_ptr<DistanceField3D<TDataType>> getSDF() {
62 return inputSDF;
63 }
64
66
67 private:
68
69 protected:
70
71 void resetStates() override;
72
74 int indexTransform(int i, int j, int k);
75
77
78 std::vector<int> m_grid;
79
80 int gnum; //total number of grids
81 int nx, ny, nz; //grid number
82
84
85 Coord seed_point; // Initial point
86
87 Real dx; //resolution of grid
88
89 std::vector<Coord> points;
90
91 unsigned int desired_points;
92
94
95 unsigned int attempted_Times = 10;
96
97 std::shared_ptr<DistanceField3D<TDataType>> inputSDF;
98
99 bool SDF_flag = false;
100
102
103
104 //SDF in host.
108
109 };
110
111
112
113
115
116}
GPU supported signed distance field.
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
bool collisionJudge(Coord point)
Real lerp(Real a, Real b, Real alpha)
std::shared_ptr< DistanceField3D< TDataType > > getSDF()
std::shared_ptr< DistanceField3D< TDataType > > loadSdf()
int indexTransform(int i, int j, int k)
DEF_VAR(Coord, Box_a, 0.0f, "Lower boudary of the sampling area")
DEF_VAR(Coord, Box_b, 0.1f, "Upper boundary of the sampling area")
DECLARE_TCLASS(PoissonDiskSampling, TDataType)
bool collisionJudge2D(Coord point)
DEF_VAR(FilePath, SdfFileName, "", "")
Real getDistanceFromSDF(const Coord &p, Coord &normal)
std::shared_ptr< DistanceField3D< TDataType > > inputSDF
std::vector< Coord > points
void resetStates() override
GridIndex searchGrid(Coord point)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
Array< T, DeviceType::GPU > DArray
Definition Array.inl:89
Array3D< T, DeviceType::CPU > CArray3D
Definition Array3D.h:136