45#define OCL_MIN_NUM_PRIMITIVES 4096
46#define CH_APP_MIN_NUM_PRIMITIVES 64000
58#if USE_THREAD == 1 && _OPENMP
65 m_oclWorkGroupSize = 0;
66 m_oclDevice =
nullptr;
68 m_oclKernelComputePartialVolumes =
nullptr;
69 m_oclKernelComputeSum =
nullptr;
98 for (
size_t p = 0; p < nCH; ++p)
106 bool Compute(
float const* points,
108 uint32_t
const* triangles,
110 const Parameters& params)
override;
111 bool Compute(
double const* points,
113 uint32_t
const* triangles,
115 const Parameters& params)
override;
117 bool OCLRelease(IUserLogger
const* logger =
nullptr)
override;
135 void Update(
const double stageProgress,
const double operationProgress,
const Parameters& params)
152 memset(
m_rot, 0,
sizeof(
double) * 9);
178 const int32_t convexhullDownsampling,
179 const double progress0,
180 const double progress1,
182 double& minConcavity,
183 const Parameters& params);
186 const uint32_t stridePoints,
187 const uint32_t nPoints,
188 const int32_t*
const triangles,
189 const uint32_t strideTriangles,
190 const uint32_t nTriangles,
202 std::ostringstream msg;
205 msg <<
"+ " <<
m_stage << std::endl;
218 Update(50.0, 100.0, params);
223 msg <<
"\t dim = " <<
m_dim <<
"\t-> " << n <<
" voxels" << std::endl;
231 Update(50.0, 0.0, params);
234 Update(100.0, 100.0, params);
246 const uint32_t stridePoints,
247 const uint32_t nPoints,
248 const int32_t*
const triangles,
249 const uint32_t strideTriangles,
250 const uint32_t nTriangles,
261 std::ostringstream msg;
264 msg <<
"+ " <<
m_stage << std::endl;
270 int32_t iteration = 0;
271 const int32_t maxIteration = 5;
272 double progress = 0.0;
273 while (iteration++ < maxIteration && !
m_cancel)
276 msg <<
"Iteration " << iteration;
279 progress = iteration * 100.0 / maxIteration;
280 Update(progress, 0.0, params);
286 Update(progress, 100.0, params);
292 msg <<
"\t dim = " <<
m_dim <<
"\t-> " << n <<
" voxels" << std::endl;
296 double a = pow((
double)(params.
m_resolution) / n, 0.33);
297 size_t dim_next = (size_t)(
m_dim * a + 0.5);
298 if (n < params.
m_resolution && iteration < maxIteration &&
311 Update(100.0, 100.0, params);
323 const uint32_t nPoints,
324 const uint32_t*
const triangles,
325 const uint32_t nTriangles,
337 AlignMesh(points, 3, nPoints, (int32_t*)triangles, 3, nTriangles, params);
338 VoxelizeMesh(points, 3, nPoints, (int32_t*)triangles, 3, nTriangles, params);
374 cl_device_id* m_oclDevice;
375 cl_context m_oclContext;
376 cl_program m_oclProgram;
377 cl_command_queue* m_oclQueue;
378 cl_kernel* m_oclKernelComputePartialVolumes;
379 cl_kernel* m_oclKernelComputeSum;
380 size_t m_oclWorkGroupSize;
uint32_t m_nTriangles
Definition: VHACD.h:106
double m_volume
Definition: VHACD.h:107
double * m_points
Definition: VHACD.h:103
uint32_t m_nPoints
Definition: VHACD.h:105
std::array< double, 3 > m_center
Definition: VHACD.h:108
uint32_t * m_triangles
Definition: VHACD.h:104
virtual void Update(double overallProgress, double stageProgress, double operationProgress, const std::string &stage, const std::string &operation)=0
virtual void Log(const std::string &msg) const =0
IUserLogger * m_logger
Definition: VHACD.h:140
bool m_projectHullVertices
Definition: VHACD.h:150
uint32_t m_pca
Definition: VHACD.h:145
uint32_t m_resolution
Definition: VHACD.h:141
IUserCallback * m_callback
Definition: VHACD.h:139
uint32_t m_oclAcceleration
Definition: VHACD.h:148
Triangular mesh data structure.
Definition: vhacdMesh.h:80
Definition: vhacdMutex.h:88
void Unlock(void)
Definition: vhacdMutex.h:132
void Lock(void)
Definition: vhacdMutex.h:111
Definition: vhacdVolume.h:59
Definition: vhacdRaycastMesh.h:12
virtual void release(void)=0
static RaycastMesh * createRaycastMesh(uint32_t vcount, const double *vertices, uint32_t tcount, const uint32_t *indices)
Definition: vhacdRaycastMesh.cpp:176
SArray.
Definition: vhacdSArray.h:42
Definition: vhacdTimer.h:97
double GetElapsedTime()
Definition: vhacdTimer.h:103
void Toc()
Definition: vhacdTimer.h:102
void Tic()
Definition: vhacdTimer.h:101
Definition: vhacdVHACD.h:53
size_t m_dim
Definition: vhacdVHACD.h:367
bool OCLInit(void const *oclDevice, VHACD::IVHACD::IUserLogger const *logger=nullptr) override
Definition: VHACD.cpp:234
double m_rot[3][3]
Definition: vhacdVHACD.h:363
RaycastMesh * mRaycastMesh
Definition: vhacdVHACD.h:356
Volume * m_volume
Definition: vhacdVHACD.h:368
void Release() override
Definition: vhacdVHACD.h:105
virtual bool ComputeCenterOfMass(std::array< double, 3 > ¢erOfMass) const override
Definition: VHACD.cpp:1787
void VoxelizeMesh(const T *const points, const uint32_t stridePoints, const uint32_t nPoints, const int32_t *const triangles, const uint32_t strideTriangles, const uint32_t nTriangles, const Parameters ¶ms)
Definition: vhacdVHACD.h:245
double m_volumeCH0
Definition: vhacdVHACD.h:364
void SimplifyConvexHulls(const Parameters ¶ms)
Definition: VHACD.cpp:1744
bool m_cancel
Definition: vhacdVHACD.h:371
void GetConvexHull(uint32_t index, ConvexHull &ch) const override
Definition: vhacdVHACD.h:75
std::string m_operation
Definition: vhacdVHACD.h:359
bool OCLRelease(IUserLogger const *logger=nullptr) override
Definition: VHACD.cpp:382
Mutex m_cancelMutex
Definition: vhacdVHACD.h:370
void SetCancel(bool cancel)
Definition: vhacdVHACD.h:122
bool Compute(float const *points, uint32_t nPoints, uint32_t const *triangles, uint32_t nTriangles, const Parameters ¶ms) override
Definition: VHACD.cpp:521
void Update(const double stageProgress, const double operationProgress, const Parameters ¶ms)
Definition: vhacdVHACD.h:135
double m_operationProgress
Definition: vhacdVHACD.h:362
uint32_t GetNConvexHulls() const override
Definition: vhacdVHACD.h:73
void Cancel() override
Definition: vhacdVHACD.h:74
Timer m_timer
Definition: vhacdVHACD.h:366
SArray< Mesh * > m_convexHulls
Definition: vhacdVHACD.h:357
Vec3< double > m_barycenter
Definition: vhacdVHACD.h:365
void ComputePrimitiveSet(const Parameters ¶ms)
Definition: VHACD.cpp:459
void ComputeACD(const Parameters ¶ms)
Definition: VHACD.cpp:1159
bool ComputeACD(const T *const points, const uint32_t nPoints, const uint32_t *const triangles, const uint32_t nTriangles, const Parameters ¶ms)
Definition: vhacdVHACD.h:322
int32_t m_ompNumProcessors
Definition: vhacdVHACD.h:372
double m_overallProgress
Definition: vhacdVHACD.h:360
PrimitiveSet * m_pset
Definition: vhacdVHACD.h:369
void AlignMesh(const T *const points, const uint32_t stridePoints, const uint32_t nPoints, const int32_t *const triangles, const uint32_t strideTriangles, const uint32_t nTriangles, const Parameters ¶ms)
Definition: vhacdVHACD.h:185
bool GetCancel()
Definition: vhacdVHACD.h:128
std::string m_stage
Definition: vhacdVHACD.h:358
double m_stageProgress
Definition: vhacdVHACD.h:361
void MergeConvexHulls(const Parameters ¶ms)
Definition: VHACD.cpp:1509
void Init()
Definition: vhacdVHACD.h:145
void ComputeBestClippingPlane(const PrimitiveSet *inputPSet, const double volume, const SArray< Plane > &planes, const Vec3< double > &preferredCuttingDirection, const double w, const double alpha, const double beta, const int32_t convexhullDownsampling, const double progress0, const double progress1, Plane &bestPlane, double &minConcavity, const Parameters ¶ms)
Definition: VHACD.cpp:783
void SimplifyConvexHull(Mesh *const ch, const size_t nvertices, const double minVolume)
Definition: VHACD.cpp:1648
VHACD()
Constructor.
Definition: vhacdVHACD.h:56
void Clean() override
Definition: vhacdVHACD.h:88
Vector dim 3.
Definition: vhacdVector.h:37
T & Y()
Definition: vhacdVector.inl:18
T & X()
Definition: vhacdVector.inl:13
T & Z()
Definition: vhacdVector.inl:23
Definition: vhacdVolume.h:232
size_t GetNPrimitivesOnSurf() const
Definition: vhacdVolume.h:265
void Voxelize(const T *const points, const uint32_t stridePoints, const uint32_t nPoints, const int32_t *const triangles, const uint32_t strideTriangles, const uint32_t nTriangles, const size_t dim, const Vec3< double > &barycenter, const double(&rot)[3][3])
Voxelize.
Definition: vhacdVolume.h:361
void AlignToPrincipalAxes(double(&rot)[3][3]) const
Definition: vhacdVolume.cpp:1100
size_t GetNPrimitivesInsideSurf() const
Definition: vhacdVolume.h:266
Definition: polygon_mesh.h:46
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
Definition: bullet_cast_bvh_manager.h:49
Definition: vhacdMesh.h:43
auto mesh
Definition: tesseract_geometry_unit.cpp:25