Skip to content

Commit 0d217d7

Browse files
committed
added msvc support
1 parent 2406d4c commit 0d217d7

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ th/gpu/build
1010
doc/generated_doc/
1111
example/**/*.pyc
1212
example/**/*.ply
13-
13+
.vscode/

core/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ set(OCTREE_CPU_SRCS
6060
src/volumetric_upsampling.cpp
6161
)
6262

63+
if(MSVC)
64+
add_library(octnet_core STATIC ${OCTREE_CPU_SRCS})
65+
else(MSVC)
6366
add_library(octnet_core SHARED ${OCTREE_CPU_SRCS})
64-
67+
endif(MSVC)
6568
add_executable(test_octree test/test_octree.cpp)
6669
target_link_libraries(test_octree octnet_core)
6770

core/include/octnet/core/core.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@
3636
#include <cstdio>
3737
#include <cmath>
3838

39+
#ifdef _MSC_VER
40+
#include <intrin.h>
41+
#else
3942
#include <smmintrin.h>
40-
43+
#endif
4144

4245
#ifdef __CUDA_ARCH__
4346
#define OCTREE_FUNCTION __host__ __device__

core/src/io.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,11 @@ void octree_read_batch_cpu(int n_paths, char** paths, int n_threads, octree* gri
305305
// for(int path_idx = 0; path_idx < n_paths; ++path_idx) {
306306
// printf(" path: '%s'\n", paths[path_idx]);
307307
// }
308-
308+
309309
//determine necessary memory
310310
ot_size_t n;
311-
ot_size_t n_leafs[n_paths];
312-
ot_size_t n_blocks[n_paths];
311+
std::vector<ot_size_t> n_leafs(n_paths);
312+
std::vector<ot_size_t> n_blocks(n_paths);
313313

314314
FILE* fp = fopen(paths[0], "rb");
315315
int magic_number = -1;
@@ -323,7 +323,7 @@ void octree_read_batch_cpu(int n_paths, char** paths, int n_threads, octree* gri
323323
sfread(&(grid_h->grid_height), sizeof(ot_size_t), 1, fp);
324324
sfread(&(grid_h->grid_width), sizeof(ot_size_t), 1, fp);
325325
sfread(&(grid_h->feature_size), sizeof(ot_size_t), 1, fp);
326-
sfread(n_leafs, sizeof(ot_size_t), 1, fp);
326+
sfread(n_leafs.data(), sizeof(ot_size_t), 1, fp);
327327
n_blocks[0] = n * grid_h->grid_depth * grid_h->grid_height * grid_h->grid_width;
328328
fclose(fp);
329329

@@ -347,7 +347,7 @@ void octree_read_batch_cpu(int n_paths, char** paths, int n_threads, octree* gri
347347
sfread(&(tmp_grid_height), sizeof(ot_size_t), 1, fp);
348348
sfread(&(tmp_grid_width), sizeof(ot_size_t), 1, fp);
349349
sfread(&(tmp_feature_size), sizeof(ot_size_t), 1, fp);
350-
sfread(n_leafs + path_idx, sizeof(ot_size_t), 1, fp);
350+
sfread(n_leafs.data() + path_idx, sizeof(ot_size_t), 1, fp);
351351
fclose(fp);
352352

353353
n += tmp_n;
@@ -419,7 +419,7 @@ void dense_read_prealloc_batch_cpu(int n_paths, char** paths, int n_threads, int
419419
offset *= dims[dim_idx];
420420
}
421421

422-
int dims_single[n_dim];
422+
std::vector<int> dims_single(n_dim);
423423
dims_single[0] = 1;
424424
for(int dim_idx = 1; dim_idx < n_dim; ++dim_idx) {
425425
dims_single[dim_idx] = dims[dim_idx];
@@ -430,7 +430,7 @@ void dense_read_prealloc_batch_cpu(int n_paths, char** paths, int n_threads, int
430430
#endif
431431
#pragma omp parallel for
432432
for(int path_idx = 0; path_idx < n_paths; ++path_idx) {
433-
dense_read_prealloc_cpu(paths[path_idx], n_dim, dims_single, data + path_idx * offset);
433+
dense_read_prealloc_cpu(paths[path_idx], n_dim, dims_single.data(), data + path_idx * offset);
434434
}
435435
}
436436

core/test/test_octree.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
#include <sstream>
2828
#include <vector>
2929
#include <string.h>
30-
30+
#ifdef _MSC_VER
31+
#include <time.h>
32+
#endif
3133
#include "octnet/test/objects.h"
3234

3335
#include "octnet/cpu/cpu.h"
@@ -201,7 +203,7 @@ void test_split_rec_surf() {
201203
}
202204

203205
int main() {
204-
srand(time(NULL));
206+
srand((unsigned)time(NULL));
205207

206208
test_split_grid_idx();
207209
test_cdhw_to_octree();

0 commit comments

Comments
 (0)