Skip to content

Commit f3b6c03

Browse files
sifakisclaude
andcommitted
Remove trailing whitespace in MeshToGrid.cuh and mesh_to_grid_cuda.cpp
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Efty Sifakis <esifakis@nvidia.com>
1 parent a1b666f commit f3b6c03

2 files changed

Lines changed: 28 additions & 28 deletions

File tree

nanovdb/nanovdb/examples/ex_mesh_to_grid_cuda/mesh_to_grid_cuda.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void readOBJ(const std::string& filename,
3030
std::vector<openvdb::Vec3s>& points,
3131
std::vector<openvdb::Vec3I>& triangles,
3232
std::vector<openvdb::Vec4I>& quads)
33-
{
33+
{
3434
std::ifstream file(filename);
3535
if (!file.is_open()) {
3636
OPENVDB_THROW(openvdb::IoError, "Failed to open OBJ file: " + filename);
@@ -44,52 +44,52 @@ void readOBJ(const std::string& filename,
4444
std::istringstream iss(line);
4545
std::string type;
4646
iss >> type;
47-
47+
4848
if (type == "v") {
4949
float x, y, z;
5050
iss >> x >> y >> z;
5151
points.push_back(openvdb::Vec3s(x, y, z));
5252
} else if (type == "f") {
5353
std::vector<int> faceIndices;
5454
std::string vertexData;
55-
55+
5656
while (iss >> vertexData) {
5757
// Isolate the vertex index (everything before the first slash)
5858
size_t slashPos = vertexData.find('/');
5959
std::string indexStr = vertexData.substr(0, slashPos);
60-
60+
6161
if (indexStr.empty()) continue;
6262

6363
int raw_idx = std::stoi(indexStr);
6464
int actual_idx = 0;
65-
65+
6666
// Handle negative indices: relative to the number of points parsed so far
6767
if (raw_idx < 0) {
68-
actual_idx = points.size() + raw_idx;
68+
actual_idx = points.size() + raw_idx;
6969
} else {
7070
// Standard positive indices: OBJ is 1-based, convert to 0-based for C++
71-
actual_idx = raw_idx - 1;
71+
actual_idx = raw_idx - 1;
7272
}
7373

7474
// Strict bounds checking to prevent segfaults
7575
if (actual_idx < 0 || actual_idx >= points.size()) {
76-
OPENVDB_THROW(openvdb::ValueError,
77-
"OBJ parse error on line " + std::to_string(lineNumber) +
78-
": Face index out of bounds (Raw: " + std::to_string(raw_idx) +
79-
", Computed: " + std::to_string(actual_idx) + ", Total Points: " +
76+
OPENVDB_THROW(openvdb::ValueError,
77+
"OBJ parse error on line " + std::to_string(lineNumber) +
78+
": Face index out of bounds (Raw: " + std::to_string(raw_idx) +
79+
", Computed: " + std::to_string(actual_idx) + ", Total Points: " +
8080
std::to_string(points.size()) + ")");
8181
}
8282

83-
faceIndices.push_back(actual_idx);
83+
faceIndices.push_back(actual_idx);
8484
}
85-
85+
8686
// Add to the appropriate OpenVDB list
8787
if (faceIndices.size() == 3) {
8888
triangles.push_back(openvdb::Vec3I(faceIndices[0], faceIndices[1], faceIndices[2]));
8989
} else if (faceIndices.size() == 4) {
9090
quads.push_back(openvdb::Vec4I(faceIndices[0], faceIndices[1], faceIndices[2], faceIndices[3]));
9191
} else if (faceIndices.size() > 4) {
92-
std::cerr << "Warning on line " << lineNumber << ": Skipping face with "
92+
std::cerr << "Warning on line " << lineNumber << ": Skipping face with "
9393
<< faceIndices.size() << " vertices. Triangulate your mesh!" << std::endl;
9494
}
9595
}
@@ -121,8 +121,8 @@ int main(int argc, char *argv[])
121121
// Read the OBJ file
122122
std::cout << "Reading " << inputFile << "..." << std::endl;
123123
readOBJ(inputFile, openvdb_points, openvdb_triangles, quads);
124-
std::cout << "Loaded " << openvdb_points.size() << " vertices, "
125-
<< openvdb_triangles.size() << " openvdb_triangles, and "
124+
std::cout << "Loaded " << openvdb_points.size() << " vertices, "
125+
<< openvdb_triangles.size() << " openvdb_triangles, and "
126126
<< quads.size() << " quads." << std::endl;
127127

128128
// Initialize OpenVDB
@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
154154
// Cast the raw pointers from the std::vector data
155155
const auto* nano_pts_data = reinterpret_cast<const nanovdb::Vec3f*>(openvdb_points.data());
156156
const auto* nano_tris_data = reinterpret_cast<const nanovdb::Vec3i*>(openvdb_triangles.data());
157-
157+
158158
// Initialize the thrust vectors using the casted pointer ranges
159159
thrust::universal_vector<nanovdb::Vec3f> nanovdb_points(nano_pts_data, nano_pts_data + openvdb_points.size());
160160
thrust::universal_vector<nanovdb::Vec3i> nanovdb_triangles(nano_tris_data, nano_tris_data + openvdb_triangles.size());

nanovdb/nanovdb/tools/cuda/MeshToGrid.cuh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ GridHandle<BufferT>
211211
MeshToGrid<BuildT>::getHandle(const BufferT &pool)
212212
{
213213
cudaStreamSynchronize(mStream);
214-
214+
215215
// Transform triangle data to (floating-point) index space
216216
if (mVerbose==1) mTimer.start("Transforming triangles to grid index space");
217217
transformTriangles();
@@ -331,7 +331,7 @@ struct TransformTrianglesFunctor
331331
const nanovdb::Vec3f* dPoints;
332332
const nanovdb::Vec3i* dTriangleIndices;
333333
Triangle* dXformedTriangles;
334-
nanovdb::Map map;
334+
nanovdb::Map map;
335335

336336
__device__
337337
void operator()(size_t triangleID) const
@@ -378,7 +378,7 @@ struct CountRootBoxesFunctor
378378
{
379379
const Triangle* dXformedTriangles;
380380
uint64_t* dCounts;
381-
float mBandWidth;
381+
float mBandWidth;
382382

383383
__device__
384384
void operator()(size_t triangleID) const
@@ -494,15 +494,15 @@ void MeshToGrid<BuildT>::processRootTrianglePairs()
494494
cudaGetDevice(&device);
495495

496496
// Pass 1: Count intersecting root boxes per triangle
497-
497+
498498
if (mVerbose >= 2) mTimer.restart("[In MeshToGrid::processRootTrianglePairs()] Launching processRootTrianglePairs");
499499

500500
nanovdb::cuda::DeviceBuffer
501501
rootBoxCounts = nanovdb::cuda::DeviceBuffer::create(mTriangleCount * sizeof(uint64_t), nullptr, device, mStream);
502502
if (rootBoxCounts.deviceData() == nullptr) throw std::runtime_error("Failed to allocate root box counts buffer");
503503

504504
util::cuda::lambdaKernel<<<numBlocks(mTriangleCount), mNumThreads, 0, mStream>>>(
505-
mTriangleCount,
505+
mTriangleCount,
506506
topology::detail::CountRootBoxesFunctor<BuildT>{
507507
deviceXformedTriangles(),
508508
static_cast<uint64_t*>(rootBoxCounts.deviceData()),
@@ -512,9 +512,9 @@ void MeshToGrid<BuildT>::processRootTrianglePairs()
512512
cudaCheckError();
513513

514514
// Pass 2: InclusiveSum Scan to compute offsets and total allocations
515-
515+
516516
if (mVerbose >= 2) mTimer.restart("[In MeshToGrid::processRootTrianglePairs()] Prefix sum");
517-
517+
518518
nanovdb::cuda::DeviceBuffer rootBoxOffsets =
519519
nanovdb::cuda::DeviceBuffer::create((mTriangleCount+1)*sizeof(uint64_t), nullptr, device, mStream);
520520
if (rootBoxOffsets.deviceData() == nullptr) throw std::runtime_error("Failed to allocate root box offsets buffer");
@@ -538,7 +538,7 @@ void MeshToGrid<BuildT>::processRootTrianglePairs()
538538
if (mBoxTrianglePairsBuffer.deviceData() == nullptr) throw std::runtime_error("Failed to allocate pairs buffer");
539539

540540
util::cuda::lambdaKernel<<<numBlocks(mTriangleCount), mNumThreads, 0, mStream>>>(
541-
mTriangleCount,
541+
mTriangleCount,
542542
topology::detail::ScatterRootTrianglePairsFunctor<BuildT>{
543543
deviceXformedTriangles(),
544544
static_cast<uint64_t*>(rootBoxOffsets.deviceData()),
@@ -625,7 +625,7 @@ __device__ inline bool testTriangleAABB(
625625
float maxZ = fmaxf(v0[2], fmaxf(v1[2], v2[2]));
626626
if (minZ > boxHalfExtents[2] || maxZ < -boxHalfExtents[2]) return false;
627627

628-
if constexpr (OnlyUseAABB) return true;
628+
if constexpr (OnlyUseAABB) return true;
629629

630630
// --- PHASE 2: SEPARATING AXIS THEOREM (SAT) (10 additional axes) ---
631631
nanovdb::Vec3f f0 = v1 - v0, f1 = v2 - v1, f2 = v0 - v2;
@@ -707,7 +707,7 @@ __global__ void evaluateAndCountSubBoxesKernel(
707707
float centerX = parentPair.origin[0] + i * childScale + (childScale * 0.5f) - 0.5f;
708708
float centerY = parentPair.origin[1] + j * childScale + (childScale * 0.5f) - 0.5f;
709709
float centerZ = parentPair.origin[2] + k * childScale + (childScale * 0.5f) - 0.5f;
710-
710+
711711
nanovdb::Vec3f boxCenter(centerX, centerY, centerZ);
712712
float halfExt = (childScale * 0.5f) + padding;
713713
nanovdb::Vec3f boxHalfExtents(halfExt, halfExt, halfExt);
@@ -960,7 +960,7 @@ void MeshToGrid<BuildT>::processLeafTrianglePairs()
960960

961961
for (int pass = 0; pass < 3; ++pass) {
962962
if (mVerbose >= 2) {
963-
printf("\n--- Subdivision Pass %d (Scale: %d -> %d) ---\n",
963+
printf("\n--- Subdivision Pass %d (Scale: %d -> %d) ---\n",
964964
pass, scale, scale / 8);
965965
}
966966

0 commit comments

Comments
 (0)