PeriDyno 0.9.2
Loading...
Searching...
No Matches
SphereSampler.cpp
Go to the documentation of this file.
1#include "SphereSampler.h"
2
4
5namespace dyno
6{
7 template<typename TDataType>
10 {
11 this->varSamplingDistance()->setRange(0.001, 1.0);
12 }
13
14 template<typename TDataType>
16 {
17 auto box = this->inSphere()->getData();
18
19 Real r = box.radius;
20 Coord center = box.center;
21 Real distance = this->varSamplingDistance()->getValue();
22
23 std::vector<Coord> points;
24 for (Real x = center[0] - r; x < center[0] + r; x += distance) {
25 for (Real y = center[1] - r; y < center[1] + r; y += distance) {
26 for (Real z = center[2] - r; z < center[2] + r; z += distance)
27 {
28 Real h = (Coord(x, y, z) - center).norm();
29 if (h < r)
30 {
31 points.push_back(Coord(x, y, z));
32 }
33 }
34 }
35 }
36
37 auto ptSet = this->statePointSet()->getDataPtr();
38 ptSet->setPoints(points);
39 points.clear();
40
41 }
42
44}
#define DEFINE_CLASS(name)
Definition Object.h:140
TDataType::Coord Coord
TDataType::Real Real
void resetStates() override
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:24
ArrayMap< T, DeviceType::GPU > DArrayMap
Definition ArrayMap.inl:80