PeriDyno 1.0.0
Loading...
Searching...
No Matches
AdaptiveVolumeToTriangleSet.cpp
Go to the documentation of this file.
2
4
5namespace dyno
6{
7 template<typename TDataType>
13
14 template<typename TDataType>
19
20 template<typename TDataType>
22 {
23 Real iso = this->varIsoValue()->getValue();
24
25 auto vol = this->ioVolume()->constDataPtr();
26
27 DArray<Coord> ceilVertices;
28
29 vol->getCellVertices0(ceilVertices);
30
31 DArray<Real> sdfs;
32 DArray<Coord> normals;
33
34 vol->getSignDistanceMLS(ceilVertices, sdfs, normals, false);
35 //sv->getSignDistanceKernel(ceilVertices, sdfs);
36
37 //DArray3D<Real> distances(nx + 1, ny + 1, nz + 1);
38 DArray<uint> voxelVertNum(ceilVertices.size() / 8);
39
41 voxelVertNum,
42 ceilVertices,
43 sdfs,
44 iso);
45
46 Reduction<uint> reduce;
47 uint totalVNum = reduce.accumulate(voxelVertNum.begin(), voxelVertNum.size());
48
49 Scan<uint> scan;
50 scan.exclusive(voxelVertNum.begin(), voxelVertNum.size());
51
52 DArray<Coord> triangleVertices(totalVNum);
53
54 DArray<TopologyModule::Triangle> triangles(totalVNum / 3);
55
57 triangleVertices,
58 triangles,
59 voxelVertNum,
60 ceilVertices,
61 sdfs,
62 iso);
63
64 if (this->outTriangleSet()->isEmpty()) {
65 this->outTriangleSet()->allocate();
66 }
67
68 auto triSet = this->outTriangleSet()->getDataPtr();
69 triSet->setPoints(triangleVertices);
70 triSet->setTriangles(triangles);
71 triSet->update();
72
73 sdfs.clear();
74 normals.clear();
75 voxelVertNum.clear();
76 ceilVertices.clear();
77 triangleVertices.clear();
78 triangles.clear();
79
80 return true;
81 }
82
84}
#define DEFINE_CLASS(name)
Definition Object.h:140
static void countVerticeNumberForOctree(DArray< uint > &num, DArray< Coord > &vertices, DArray< Real > &sdfs, Real isoValue)
static void constructTrianglesForOctree(DArray< Coord > &triangleVertices, DArray< TopologyModule::Triangle > &triangles, DArray< uint > &num, DArray< Coord > &cellVertices, DArray< Real > &sdfs, Real isoValue)
T accumulate(const T *val, const uint num)
void exclusive(T *output, const T *input, size_t length, bool bcao=true)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
Array< T, DeviceType::GPU > DArray
Definition Array.inl:89
unsigned int uint
Definition VkProgram.h:14