Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package_name := mesh_package
all:
@echo "\033[0;36m----- [" ${package_name} "] Installing with the interpreter `which python` (version `python --version | cut -d' ' -f2`)\033[0m"
@pip install --upgrade -r requirements.txt && pip list
@pip install --no-deps --install-option="--boost-location=$$BOOST_INCLUDE_DIRS" --verbose --no-cache-dir .
@pip install --no-deps --config-settings="--boost-location=$$BOOST_INCLUDE_DIRS" --verbose --no-cache-dir .

import_tests:
@echo "\033[0;33m----- [" ${package_name} "] Performing import tests\033[0m"
Expand Down
20 changes: 10 additions & 10 deletions mesh/src/aabb_normals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ aabbtree_normals_compute(PyObject *self, PyObject *args)
return NULL;
}

npy_intp* v_dims = PyArray_DIMS(py_v);
npy_intp* f_dims = PyArray_DIMS(py_f);
npy_intp* v_dims = PyArray_DIMS((PyArrayObject*)py_v);
npy_intp* f_dims = PyArray_DIMS((PyArrayObject*)py_f);

if (v_dims[1] != 3 || f_dims[1] != 3) {
PyErr_SetString(PyExc_ValueError, "Input must be Nx3");
return NULL;
}

double *pV = (double*)PyArray_DATA(py_v);
uint32_t *pF = (uint32_t*)PyArray_DATA(py_f);
double *pV = (double*)PyArray_DATA((PyArrayObject*)py_v);
uint32_t *pF = (uint32_t*)PyArray_DATA((PyArrayObject*)py_f);

size_t P = v_dims[0];
size_t T = f_dims[0];
Expand Down Expand Up @@ -115,8 +115,8 @@ aabbtree_normals_nearest(PyObject *self, PyObject *args)

TreeAndTri *search = (TreeAndTri *) PyCapsule_GetPointer(py_tree, NULL);

npy_intp* v_dims = PyArray_DIMS(py_v);
npy_intp* n_dims = PyArray_DIMS(py_n);
npy_intp* v_dims = PyArray_DIMS((PyArrayObject*)py_v);
npy_intp* n_dims = PyArray_DIMS((PyArrayObject*)py_n);

if (v_dims[1] != 3) {
PyErr_SetString(PyExc_ValueError, "Input must be Nx3");
Expand All @@ -129,8 +129,8 @@ aabbtree_normals_nearest(PyObject *self, PyObject *args)

size_t S=v_dims[0];

array<double, 3>* m_sample_points=reinterpret_cast<array<double,3>*>(PyArray_DATA(py_v));
array<double, 3>* m_sample_n=reinterpret_cast<array<double,3>*>(PyArray_DATA(py_n));
array<double, 3>* m_sample_points=reinterpret_cast<array<double,3>*>(PyArray_DATA((PyArrayObject*)py_v));
array<double, 3>* m_sample_n=reinterpret_cast<array<double,3>*>(PyArray_DATA((PyArrayObject*)py_n));

#ifdef _OPENMP
omp_set_num_threads(8);
Expand All @@ -151,12 +151,12 @@ aabbtree_normals_nearest(PyObject *self, PyObject *args)

PyObject *result1 = PyArray_SimpleNew(2, result1_dims, NPY_UINT32);

uint32_t* closest_triangles=reinterpret_cast<uint32_t*>(PyArray_DATA(result1));
uint32_t* closest_triangles=reinterpret_cast<uint32_t*>(PyArray_DATA((PyArrayObject*)result1));
array<double,3>* closest_point=NULL;
//if(1) { //nlhs > 1) {
npy_intp result2_dims[] = {S, 3};
PyObject *result2 = PyArray_SimpleNew(2, result2_dims, NPY_DOUBLE);
closest_point=reinterpret_cast<array<double,3>*>(PyArray_DATA(result2));
closest_point=reinterpret_cast<array<double,3>*>(PyArray_DATA((PyArrayObject*)result2));
//}

#pragma omp parallel for
Expand Down
14 changes: 7 additions & 7 deletions mesh/src/py_loadobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,17 @@ loadobj(PyObject *self, PyObject *args, PyObject *keywds)
*/
// The following copy would be faster in C++11 with move semantics
PyObject *py_v = PyArray_SimpleNew(2, v_dims, NPY_DOUBLE);
std::copy(v.begin(), v.end(), reinterpret_cast<double*>(PyArray_DATA(py_v)));
std::copy(v.begin(), v.end(), reinterpret_cast<double*>(PyArray_DATA((PyArrayObject*)py_v)));
PyObject *py_vt = PyArray_SimpleNew(2, vt_dims, NPY_DOUBLE);
std::copy(vt.begin(), vt.end(), reinterpret_cast<double*>(PyArray_DATA(py_vt)));
std::copy(vt.begin(), vt.end(), reinterpret_cast<double*>(PyArray_DATA((PyArrayObject*)py_vt)));
PyObject *py_vn = PyArray_SimpleNew(2, vn_dims, NPY_DOUBLE);
std::copy(vn.begin(), vn.end(), reinterpret_cast<double*>(PyArray_DATA(py_vn)));
std::copy(vn.begin(), vn.end(), reinterpret_cast<double*>(PyArray_DATA((PyArrayObject*)py_vn)));
PyObject *py_f = PyArray_SimpleNew(2, f_dims, NPY_UINT32);
std::copy(f.begin(), f.end(), reinterpret_cast<uint32_t*>(PyArray_DATA(py_f)));
std::copy(f.begin(), f.end(), reinterpret_cast<uint32_t*>(PyArray_DATA((PyArrayObject*)py_f)));
PyObject *py_ft = PyArray_SimpleNew(2, ft_dims, NPY_UINT32);
std::copy(ft.begin(), ft.end(), reinterpret_cast<uint32_t*>(PyArray_DATA(py_ft)));
std::copy(ft.begin(), ft.end(), reinterpret_cast<uint32_t*>(PyArray_DATA((PyArrayObject*)py_ft)));
PyObject *py_fn = PyArray_SimpleNew(2, fn_dims, NPY_UINT32);
std::copy(fn.begin(), fn.end(), reinterpret_cast<uint32_t*>(PyArray_DATA(py_fn)));
std::copy(fn.begin(), fn.end(), reinterpret_cast<uint32_t*>(PyArray_DATA((PyArrayObject*)py_fn)));

PyObject *py_landm = PyDict_New();
for (std::map<std::string, uint32_t>::iterator it=landm.begin(); it!=landm.end(); ++it)
Expand All @@ -230,7 +230,7 @@ loadobj(PyObject *self, PyObject *args, PyObject *keywds)
unsigned n = it->second.size();
npy_intp dims[] = {n};
PyObject *temp = PyArray_SimpleNew(1, dims, NPY_UINT32);
std::copy(it->second.begin(), it->second.end(), reinterpret_cast<uint32_t*>(PyArray_DATA(temp)));
std::copy(it->second.begin(), it->second.end(), reinterpret_cast<uint32_t*>(PyArray_DATA((PyArrayObject*)temp)));
PyDict_SetItemString(py_segm, it->first.c_str(), Py_BuildValue("N", temp));
}

Expand Down
20 changes: 10 additions & 10 deletions mesh/src/py_visibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ npy_intp parse_pyarray(const PyArrayObject *py_arr, const array<CTYPE,3>* &cpp_a
"Array must be of a specific type, and 2 dimensional");
return NULL;
}
npy_intp* dims = PyArray_DIMS(py_arr);
npy_intp* dims = PyArray_DIMS((PyArrayObject*)py_arr);
if (dims[1] != 3) {
PyErr_SetString(PyExc_ValueError, "Array must be Nx3");
return NULL;
}
CTYPE *c_arr = (CTYPE*)PyArray_DATA(py_arr);
CTYPE *c_arr = (CTYPE*)PyArray_DATA((PyArrayObject*)py_arr);
cpp_arr = reinterpret_cast<const array<CTYPE,3>*>(c_arr);
return dims[0];
}
Expand Down Expand Up @@ -161,7 +161,7 @@ visibility_compute(PyObject *self, PyObject *args, PyObject *keywds)
return NULL;
}

npy_intp* cam_dims = PyArray_DIMS(py_cams);
npy_intp* cam_dims = PyArray_DIMS((PyArrayObject*)py_cams);

if (cam_dims[1] != 3) {
PyErr_SetString(PyExc_ValueError, "Cams must be Nx3");
Expand All @@ -170,33 +170,33 @@ visibility_compute(PyObject *self, PyObject *args, PyObject *keywds)

double *pN = NULL;
if (py_n != NULL){
npy_intp* n_dims = PyArray_DIMS(py_n);
npy_intp* n_dims = PyArray_DIMS((PyArrayObject*)py_n);
if (n_dims[1] != 3 || n_dims[0] != search->points.size()) {
PyErr_SetString(PyExc_ValueError, "Normals should have same number of rows as vertices, and 3 columns");
return NULL;
}
pN = (double*)PyArray_DATA(py_n);
pN = (double*)PyArray_DATA((PyArrayObject*)py_n);
}

double *pSensors = NULL;
if (use_sensors){
npy_intp* n_dims = PyArray_DIMS(py_sensors);
npy_intp* n_dims = PyArray_DIMS((PyArrayObject*)py_sensors);
if (n_dims[1] != 9 || n_dims[0] != cam_dims[0]) {
PyErr_SetString(PyExc_ValueError, "Sensors should have same number of rows as cameras, 3x3 columns");
return NULL;
}
pSensors = (double*)PyArray_DATA(py_sensors);
pSensors = (double*)PyArray_DATA((PyArrayObject*)py_sensors);
}

double *pCams = (double*)PyArray_DATA(py_cams);
double *pCams = (double*)PyArray_DATA((PyArrayObject*)py_cams);

size_t C = cam_dims[0];

npy_intp result_dims[] = {C,search->points.size()};
PyObject *py_bin_visibility = PyArray_SimpleNew(2, result_dims, NPY_UINT32);
PyObject *py_normal_dot_cam = PyArray_SimpleNew(2, result_dims, NPY_DOUBLE);
uint32_t* visibility = reinterpret_cast<uint32_t*>(PyArray_DATA(py_bin_visibility));
double* normal_dot_cam = reinterpret_cast<double*>(PyArray_DATA(py_normal_dot_cam));
uint32_t* visibility = reinterpret_cast<uint32_t*>(PyArray_DATA((PyArrayObject*)py_bin_visibility));
double* normal_dot_cam = reinterpret_cast<double*>(PyArray_DATA((PyArrayObject*)(PyArrayObject*)py_normal_dot_cam));

_internal_compute(search, pN, pCams, C, use_sensors,
pSensors, min_dist, visibility, normal_dot_cam);
Expand Down
42 changes: 21 additions & 21 deletions mesh/src/spatialsearchmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ spatialsearch_aabbtree_compute(PyObject *self, PyObject *args)
return NULL;
}

npy_intp* v_dims = PyArray_DIMS(py_v);
npy_intp* f_dims = PyArray_DIMS(py_f);
npy_intp* v_dims = PyArray_DIMS((PyArrayObject*)py_v);
npy_intp* f_dims = PyArray_DIMS((PyArrayObject*)py_f);

if (v_dims[1] != 3 || f_dims[1] != 3) {
PyErr_SetString(PyExc_ValueError, "Input must be Nx3");
return NULL;
}

double *pV = (double*)PyArray_DATA(py_v);
uint32_t *pF = (uint32_t*)PyArray_DATA(py_f);
double *pV = (double*)PyArray_DATA((PyArrayObject*)py_v);
uint32_t *pF = (uint32_t*)PyArray_DATA((PyArrayObject*)py_f);

size_t P = v_dims[0];
size_t T = f_dims[0];
Expand Down Expand Up @@ -166,7 +166,7 @@ static PyObject* spatialsearch_aabbtree_nearest(PyObject *self, PyObject *args)
return NULL;
TreeAndTri *search = (TreeAndTri *) PyCapsule_GetPointer(py_tree, NULL);

npy_intp* v_dims = PyArray_DIMS(py_v);
npy_intp* v_dims = PyArray_DIMS((PyArrayObject*)py_v);

if (v_dims[1] != 3) {
PyErr_SetString(PyExc_ValueError, "Input must be Nx3");
Expand All @@ -175,7 +175,7 @@ static PyObject* spatialsearch_aabbtree_nearest(PyObject *self, PyObject *args)

size_t S=v_dims[0];

array<double, 3>* m_sample_points=reinterpret_cast<array<double,3>*>(PyArray_DATA(py_v));
array<double, 3>* m_sample_points=reinterpret_cast<array<double,3>*>(PyArray_DATA((PyArrayObject*)py_v));

#ifdef _OPENMP
omp_set_num_threads(8);
Expand All @@ -192,12 +192,12 @@ static PyObject* spatialsearch_aabbtree_nearest(PyObject *self, PyObject *args)
PyObject *result1 = PyArray_SimpleNew(2, result1_dims, NPY_UINT32);
PyObject *result2 = PyArray_SimpleNew(2, result1_dims, NPY_UINT32);

uint32_t* closest_triangles=reinterpret_cast<uint32_t*>(PyArray_DATA(result1));
uint32_t* closest_part=reinterpret_cast<uint32_t*>(PyArray_DATA(result2));
uint32_t* closest_triangles=reinterpret_cast<uint32_t*>(PyArray_DATA((PyArrayObject*)result1));
uint32_t* closest_part=reinterpret_cast<uint32_t*>(PyArray_DATA((PyArrayObject*)result2));

npy_intp result3_dims[] = {S, 3};
PyObject *result3 = PyArray_SimpleNew(2, result3_dims, NPY_DOUBLE);
array<double,3>* closest_point = reinterpret_cast<array<double,3>*>(PyArray_DATA(result3));
array<double,3>* closest_point = reinterpret_cast<array<double,3>*>(PyArray_DATA((PyArrayObject*)result3));


#ifdef HAVE_TBB
Expand All @@ -220,8 +220,8 @@ static PyObject* spatialsearch_aabbtree_nearest_alongnormal(PyObject *self, PyOb
return NULL;
TreeAndTri *search = (TreeAndTri *) PyCapsule_GetPointer(py_tree, NULL);

npy_intp* p_dims = PyArray_DIMS(py_p);
npy_intp* n_dims = PyArray_DIMS(py_p);
npy_intp* p_dims = PyArray_DIMS((PyArrayObject*)py_p);
npy_intp* n_dims = PyArray_DIMS((PyArrayObject*)py_p);

if (p_dims[1] != 3 || n_dims[1] != 3 || p_dims[0] != n_dims[0]) {
PyErr_SetString(PyExc_ValueError, "Points and normals must be Nx3");
Expand All @@ -230,8 +230,8 @@ static PyObject* spatialsearch_aabbtree_nearest_alongnormal(PyObject *self, PyOb

size_t S=p_dims[0];

array<double, 3>* p_arr = reinterpret_cast<array<double,3>*>(PyArray_DATA(py_p));
array<double, 3>* n_arr = reinterpret_cast<array<double,3>*>(PyArray_DATA(py_n));
array<double, 3>* p_arr = reinterpret_cast<array<double,3>*>(PyArray_DATA((PyArrayObject*)py_p));
array<double, 3>* n_arr = reinterpret_cast<array<double,3>*>(PyArray_DATA((PyArrayObject*)py_n));

#ifdef _OPENMP
omp_set_num_threads(8);
Expand All @@ -250,14 +250,14 @@ static PyObject* spatialsearch_aabbtree_nearest_alongnormal(PyObject *self, PyOb

PyObject *result1 = PyArray_SimpleNew(1, result1_dims, NPY_DOUBLE);

double* distance = reinterpret_cast<double*>(PyArray_DATA(result1));
double* distance = reinterpret_cast<double*>(PyArray_DATA((PyArrayObject*)result1));

PyObject *result2 = PyArray_SimpleNew(1, result1_dims, NPY_UINT32);
uint32_t* closest_triangles = reinterpret_cast<uint32_t*>(PyArray_DATA(result2));
uint32_t* closest_triangles = reinterpret_cast<uint32_t*>(PyArray_DATA((PyArrayObject*)result2));

npy_intp result3_dims[] = {S, 3};
PyObject *result3 = PyArray_SimpleNew(2, result3_dims, NPY_DOUBLE);
array<double,3>* closest_point = reinterpret_cast<array<double,3>*>(PyArray_DATA(result3));
array<double,3>* closest_point = reinterpret_cast<array<double,3>*>(PyArray_DATA((PyArrayObject*)result3));

#ifdef HAVE_OPENMP
#pragma omp parallel for
Expand Down Expand Up @@ -344,16 +344,16 @@ static PyObject * spatialsearch_aabbtree_intersections_indices(PyObject *self, P
}

// QUERY MESH STRUCTURE
npy_intp* qv_dims = PyArray_DIMS(py_qv);
npy_intp* qf_dims = PyArray_DIMS(py_qf);
npy_intp* qv_dims = PyArray_DIMS((PyArrayObject*)py_qv);
npy_intp* qf_dims = PyArray_DIMS((PyArrayObject*)py_qf);

if (qv_dims[1] != 3 || qf_dims[1] != 3) {
PyErr_SetString(PyExc_ValueError, "Input must be Nx3");
return NULL;
}

double *pQV = (double*)PyArray_DATA(py_qv);
uint32_t *pQF = (uint32_t*)PyArray_DATA(py_qf);
double *pQV = (double*)PyArray_DATA((PyArrayObject*)py_qv);
uint32_t *pQF = (uint32_t*)PyArray_DATA((PyArrayObject*)py_qf);

size_t q_n_verts = qv_dims[0];
size_t q_n_faces = qf_dims[0];
Expand Down Expand Up @@ -396,7 +396,7 @@ static PyObject * spatialsearch_aabbtree_intersections_indices(PyObject *self, P
npy_intp result_dims[] = {mesh_intersections.size()};
PyObject *result = PyArray_SimpleNew(1, result_dims, NPY_UINT32);

uint32_t* mesh_intersections_arr = reinterpret_cast<uint32_t*>(PyArray_DATA(result));
uint32_t* mesh_intersections_arr = reinterpret_cast<uint32_t*>(PyArray_DATA((PyArrayObject*)result));
std::copy(mesh_intersections.begin(), mesh_intersections.end(),mesh_intersections_arr);

return Py_BuildValue("N",result);
Expand Down