1#include "CalculateNormalSDF.h"
5 IMPLEMENT_TCLASS(CalculateNormalSDF, TDataType)
8 template<typename Real, typename Coord, typename Tetrahedron>
9 __global__ void K_UpdateNormalSDF(
11 DArray<Tetrahedron> tets,
12 DArray<Real> distance,
13 DArray<Coord> normalTet)
15 int pId = threadIdx.x + (blockIdx.x * blockDim.x);
16 if (pId >= tets.size()) return;
18 Coord posCenter = (posArr[tets[pId][0]] + posArr[tets[pId][1]] + posArr[tets[pId][2]] + posArr[tets[pId][3]]) / 4.0f;
20 for (int i = 0; i < 4; i++)
22 dir += distance[tets[pId][i]] * (posArr[tets[pId][i]] - posCenter) / (posArr[tets[pId][i]] - posCenter).norm();
24 if (dir.norm() > EPSILON)
31 template<typename TDataType>
32 void CalculateNormalSDF<TDataType>::compute()
34 cuExecute(this->inTets()->size(),
36 this->inPosition()->getData(),
37 this->inTets()->getData(),
38 this->inDisranceSDF()->getData(),
39 this->inNormalSDF()->getData()
43 /*template<typename TDataType>
44 void CalculateNormalSDF<TDataType>::resetStates()
49 DEFINE_CLASS(CalculateNormalSDF);