1#include "CalculateBoundingBox.h"
2#include "Primitive/Primitive3D.h"
6 IMPLEMENT_TCLASS(CalculateBoundingBox, TDataType)
8 typedef typename ::dyno::TOrientedBox3D<Real> Box3D;
10 template<typename TDataType>
11 CalculateBoundingBox<TDataType>::CalculateBoundingBox()
16 template<typename TDataType>
17 CalculateBoundingBox<TDataType>::~CalculateBoundingBox()
22 template<typename Box3D, typename AABB>
23 __global__ void CBB_SetupAABB(
24 DArray<AABB> boundingBox,
26 DArray<Sphere3D> spheres,
28 DArray<Capsule3D> caps,
29 DArray<Triangle3D> tris,
30 ElementOffset elementOffset,
33 uint tId = threadIdx.x + (blockIdx.x * blockDim.x);
34 if (tId >= boundingBox.size()) return;
36 ElementType eleType = elementOffset.checkElementType(tId);
38 boundary_expand = 0.0075f;
45 box = spheres[tId].aabb();
51 box = boxes[tId - elementOffset.boxIndex()].aabb();
57 box = tets[tId - elementOffset.tetIndex()].aabb();
62 box = caps[tId - elementOffset.capsuleIndex()].aabb();
67 boundary_expand = 0.01;
68 box = tris[tId - elementOffset.triangleIndex()].aabb();
75 boundingBox[tId] = box;
78 template<typename TDataType>
79 void CalculateBoundingBox<TDataType>::compute()
81 auto inTopo = this->inDiscreteElements()->getDataPtr();
83 if (this->outAABB()->isEmpty())
84 this->outAABB()->allocate();
86 auto& aabbs = this->outAABB()->getData();
88 int num = inTopo->totalSize();
92 Real margin = Real(0);
94 ElementOffset elementOffset = inTopo->calculateElementOffset();
96 DArray<Box3D>& boxInGlobal = inTopo->boxesInGlobal();
97 DArray<Sphere3D>& sphereInGlobal = inTopo->spheresInGlobal();
98 DArray<Tet3D>& tetInGlobal = inTopo->tetsInGlobal();
99 DArray<Capsule3D>& capsuleInGlobal = inTopo->capsulesInGlobal();
100 DArray<Triangle3D>& triangleInGlobal = inTopo->trianglesInGlobal();
114 DEFINE_CLASS(CalculateBoundingBox);