33 #define DISPATCH_BYTESIZE_TO_VOXEL(BYTESIZE, ...) \
35 if (BYTESIZE == sizeof(ColoredVoxel32f)) { \
36 using voxel_t = ColoredVoxel32f; \
37 return __VA_ARGS__(); \
38 } else if (BYTESIZE == sizeof(ColoredVoxel16i)) { \
39 using voxel_t = ColoredVoxel16i; \
40 return __VA_ARGS__(); \
41 } else if (BYTESIZE == sizeof(Voxel32f)) { \
42 using voxel_t = Voxel32f; \
43 return __VA_ARGS__(); \
45 utility::LogError("Unsupported voxel bytesize"); \
76 printf(
"[Voxel32f] should never reach here.\n");
109 float inc_wsum =
static_cast<float>(
weight) + 1;
110 float inv_wsum = 1.0f / inc_wsum;
120 float inc_wsum =
static_cast<float>(
weight) + 1;
121 float inv_wsum = 1.0f / inc_wsum;
123 r =
static_cast<uint16_t
>(
125 g =
static_cast<uint16_t
>(
127 b =
static_cast<uint16_t
>(
152 float inv_wsum = 1.0f / (
weight + 1);
160 float inv_wsum = 1.0f / (
weight + 1);
171 template <
typename voxel_t>
181 int xn = (xo + resolution) % resolution;
182 int yn = (yo + resolution) % resolution;
183 int zn = (zo + resolution) % resolution;
185 int64_t dxb =
Sign(xo - xn);
186 int64_t dyb =
Sign(yo - yn);
187 int64_t dzb =
Sign(zo - zn);
189 int64_t nb_idx = (dxb + 1) + (dyb + 1) * 3 + (dzb + 1) * 9;
192 *nb_block_masks_indexer.
GetDataPtr<
bool>(curr_block_idx, nb_idx);
193 if (!block_mask_i)
return nullptr;
195 int64_t block_idx_i = *nb_block_indices_indexer.
GetDataPtr<int64_t>(
196 curr_block_idx, nb_idx);
198 return blocks_indexer.
GetDataPtr<voxel_t>(xn, yn, zn, block_idx_i);
203 template <
typename voxel_t>
215 auto GetVoxelAt = [&]
OPEN3D_DEVICE(
int xo,
int yo,
int zo) {
216 return DeviceGetVoxelAt<voxel_t>(
217 xo, yo, zo, curr_block_idx, resolution, nb_block_masks_indexer,
218 nb_block_indices_indexer, blocks_indexer);
220 voxel_t* vxp = GetVoxelAt(xo + 1, yo, zo);
221 voxel_t* vxn = GetVoxelAt(xo - 1, yo, zo);
222 voxel_t* vyp = GetVoxelAt(xo, yo + 1, zo);
223 voxel_t* vyn = GetVoxelAt(xo, yo - 1, zo);
224 voxel_t* vzp = GetVoxelAt(xo, yo, zo + 1);
225 voxel_t* vzn = GetVoxelAt(xo, yo, zo - 1);
226 if (vxp && vxn) n[0] = (vxp->GetTSDF() - vxn->GetTSDF()) / (2 * voxel_size);
227 if (vyp && vyn) n[1] = (vyp->GetTSDF() - vyn->GetTSDF()) / (2 * voxel_size);
228 if (vzp && vzn) n[2] = (vzp->GetTSDF() - vzn->GetTSDF()) / (2 * voxel_size);
239 int xn = (xo + resolution) % resolution;
240 int yn = (yo + resolution) % resolution;
241 int zn = (zo + resolution) % resolution;
243 int64_t dxb =
Sign(xo - xn);
244 int64_t dyb =
Sign(yo - yn);
245 int64_t dzb =
Sign(zo - zn);
247 int64_t nb_idx = (dxb + 1) + (dyb + 1) * 3 + (dzb + 1) * 9;
250 *nb_block_masks_indexer.
GetDataPtr<
bool>(curr_block_idx, nb_idx);
251 if (!block_mask_i)
return -1;
254 *nb_block_indices_indexer.
GetDataPtr<
int>(curr_block_idx, nb_idx);
256 return (((block_idx_i * resolution) + zn) * resolution + yn) * resolution +
#define OPEN3D_HOST_DEVICE
Definition: CUDAUtils.h:63
#define OPEN3D_DEVICE
Definition: CUDAUtils.h:64
OPEN3D_HOST_DEVICE int Sign(int x)
Definition: GeometryMacros.h:96
Definition: GeometryIndexer.h:180
OPEN3D_HOST_DEVICE void * GetDataPtr() const
Definition: GeometryIndexer.h:335
OPEN3D_DEVICE int64_t DeviceGetLinearIdx(int xo, int yo, int zo, int curr_block_idx, int resolution, const NDArrayIndexer &nb_block_masks_indexer, const NDArrayIndexer &nb_block_indices_indexer)
Definition: TSDFVoxel.h:232
OPEN3D_DEVICE void DeviceGetNormalAt(int xo, int yo, int zo, int curr_block_idx, float *n, int resolution, float voxel_size, const NDArrayIndexer &nb_block_masks_indexer, const NDArrayIndexer &nb_block_indices_indexer, const NDArrayIndexer &blocks_indexer)
Definition: TSDFVoxel.h:204
OPEN3D_DEVICE voxel_t * DeviceGetVoxelAt(int xo, int yo, int zo, int curr_block_idx, int resolution, const NDArrayIndexer &nb_block_masks_indexer, const NDArrayIndexer &nb_block_indices_indexer, const NDArrayIndexer &blocks_indexer)
Definition: TSDFVoxel.h:172
Definition: PinholeCameraIntrinsic.cpp:35
Definition: TSDFVoxel.h:85
uint16_t g
Definition: TSDFVoxel.h:93
OPEN3D_HOST_DEVICE void Integrate(float dsdf)
Definition: TSDFVoxel.h:108
static bool HasColor()
Definition: TSDFVoxel.h:96
OPEN3D_HOST_DEVICE void Integrate(float dsdf, float dr, float dg, float db)
Definition: TSDFVoxel.h:116
uint16_t b
Definition: TSDFVoxel.h:94
static const uint16_t kMaxUint16
Definition: TSDFVoxel.h:86
OPEN3D_HOST_DEVICE float GetG()
Definition: TSDFVoxel.h:102
OPEN3D_HOST_DEVICE float GetWeight()
Definition: TSDFVoxel.h:98
float tsdf
Definition: TSDFVoxel.h:89
static constexpr float kColorFactor
Definition: TSDFVoxel.h:87
uint16_t weight
Definition: TSDFVoxel.h:90
OPEN3D_HOST_DEVICE float GetR()
Definition: TSDFVoxel.h:99
OPEN3D_HOST_DEVICE float GetTSDF()
Definition: TSDFVoxel.h:97
uint16_t r
Definition: TSDFVoxel.h:92
OPEN3D_HOST_DEVICE float GetB()
Definition: TSDFVoxel.h:105
Definition: TSDFVoxel.h:137
OPEN3D_HOST_DEVICE float GetG()
Definition: TSDFVoxel.h:149
OPEN3D_HOST_DEVICE float GetTSDF()
Definition: TSDFVoxel.h:146
OPEN3D_HOST_DEVICE float GetR()
Definition: TSDFVoxel.h:148
OPEN3D_HOST_DEVICE void Integrate(float dsdf, float dr, float dg, float db)
Definition: TSDFVoxel.h:156
float g
Definition: TSDFVoxel.h:142
float weight
Definition: TSDFVoxel.h:139
OPEN3D_HOST_DEVICE float GetB()
Definition: TSDFVoxel.h:150
static bool HasColor()
Definition: TSDFVoxel.h:145
OPEN3D_HOST_DEVICE void Integrate(float dsdf)
Definition: TSDFVoxel.h:151
OPEN3D_HOST_DEVICE float GetWeight()
Definition: TSDFVoxel.h:147
float b
Definition: TSDFVoxel.h:143
float r
Definition: TSDFVoxel.h:141
float tsdf
Definition: TSDFVoxel.h:138
Definition: TSDFVoxel.h:57
OPEN3D_HOST_DEVICE float GetTSDF()
Definition: TSDFVoxel.h:62
static bool HasColor()
Definition: TSDFVoxel.h:61
OPEN3D_HOST_DEVICE float GetG()
Definition: TSDFVoxel.h:65
OPEN3D_HOST_DEVICE float GetB()
Definition: TSDFVoxel.h:66
float weight
Definition: TSDFVoxel.h:59
OPEN3D_HOST_DEVICE void Integrate(float dsdf, float dr, float dg, float db)
Definition: TSDFVoxel.h:72
OPEN3D_HOST_DEVICE float GetWeight()
Definition: TSDFVoxel.h:63
float tsdf
Definition: TSDFVoxel.h:58
OPEN3D_HOST_DEVICE float GetR()
Definition: TSDFVoxel.h:64
OPEN3D_HOST_DEVICE void Integrate(float dsdf)
Definition: TSDFVoxel.h:68