Skip to content

Commit 8987646

Browse files
committed
removed dr_cpp import
1 parent 3ffe0c7 commit 8987646

File tree

7 files changed

+45
-48
lines changed

7 files changed

+45
-48
lines changed

src/compas/geometry/algorithms/_smoothing_cpp/src/main.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
#include <stdio.h>
2-
#include <stdlib.h>
3-
#include <math.h>
4-
#include <time.h>
5-
#include <array>
61
#include <vector>
72

83
// cd _smoothing_cpp
@@ -19,13 +14,14 @@ extern "C"
1914

2015
void smooth_centroid(int v, int *nbrs, int *fixed, double **vertices, int **neighbours, int kmax, callback_smoothing func)
2116
{
22-
int i, j, n, k;
17+
int k;
18+
int i;
19+
int j, n;
2320
double cx, cy, cz;
2421
double c;
2522

2623
vector< vector<double> > xyz(v, vector<double>(3, 0.0));
2724

28-
2925
for (k = 0; k < kmax; k++) {
3026

3127
for (i = 0; i < v; i++) {
@@ -35,27 +31,26 @@ void smooth_centroid(int v, int *nbrs, int *fixed, double **vertices, int **neig
3531
}
3632

3733
for (i = 0; i < v; i++) {
34+
35+
if (fixed[i]) {
36+
continue;
37+
}
38+
3839
cx = 0.0;
3940
cy = 0.0;
4041
cz = 0.0;
4142

42-
c = 0.0;
43-
4443
for (j = 0; j < nbrs[i]; j++) {
4544
n = neighbours[i][j];
4645

4746
cx += xyz[n][0];
4847
cy += xyz[n][1];
4948
cz += xyz[n][2];
50-
51-
c += 1.0;
5249
}
5350

54-
if (! fixed[i]) {
55-
vertices[i][0] = cx / c;
56-
vertices[i][1] = cy / c;
57-
vertices[i][2] = cz / c;
58-
}
51+
vertices[i][0] = cx / nbrs[i];
52+
vertices[i][1] = cy / nbrs[i];
53+
vertices[i][2] = cz / nbrs[i];
5954
}
6055

6156
func(k);

src/compas/geometry/algorithms/planarisation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ def mesh_planarize_faces_shapeop(mesh,
279279
vertex = key_index[key]
280280
solver.add_closeness_constraint(vertex, 1.0)
281281

282+
solver.init()
283+
282284
for k in range(kmax):
283285
# solve
284286
solver.solve(1)
@@ -360,10 +362,12 @@ def mesh_circularize_faces_shapeop(mesh,
360362
vertex = key_index[key]
361363
solver.add_closeness_constraint(vertex, 1.0)
362364

365+
solver.init()
366+
363367
for k in range(kmax):
364368
# solve
365369
solver.solve(1)
366-
# update the points array
370+
# # update the points array
367371
points = solver.get_points()
368372
# update
369373
for index, (key, attr) in enumerate(mesh.vertices(True)):

src/compas/geometry/algorithms/smoothing_cpp.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def smooth_centroid_cpp(vertices, adjacency, fixed, kmax=100, callback=None, cal
6060

6161
def wrapper(k):
6262
print(k)
63-
c_vertices.cdata[18][0] = 0.01 * k
63+
if k < kmax - 1:
64+
c_vertices.cdata[18][0] = 0.1 * (k + 1)
6465
callback(c_vertices.pydata)
6566

6667
smooth_centroid.smooth_centroid.argtypes = [
@@ -119,13 +120,11 @@ def wrapper(k):
119120
fixed = list(mesh.vertices_where({'is_fixed': True}))
120121
adjacency = [mesh.vertex_neighbours(key) for key in mesh.vertices()]
121122

122-
print(fixed)
123-
124123
# make a plotter for (dynamic) visualization
125124
# and define a callback function
126125
# for plotting the intermediate configurations
127126

128-
plotter = MeshPlotter(mesh, figsize=(10, 6))
127+
plotter = MeshPlotter(mesh, figsize=(10, 7))
129128

130129
def callback(xyz):
131130
plotter.update_vertices()

src/compas/hpc/geometry/basic.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
__all__ = [
21-
'sum_vectors_numba',
21+
# 'sum_vectors_numba',
2222
'norm_vector_numba',
2323
'norm_vectors_numba',
2424
'length_vector_numba',
@@ -69,18 +69,19 @@
6969

7070
# ==============================================================================
7171

72-
@jit(float64[:](float64[:, :], int64), nogil=True, nopython=True)
73-
def sum_vectors_numba(a, axis=0):
74-
""" Calculate the sum of an array of vectors along the specified axis.
7572

76-
Parameters:
77-
a (array): Array of vectors (m x 3).
78-
axis (int): Dimension to sum through.
73+
# @jit(float64[:](float64[:, :], int64), nogil=True, nopython=True)
74+
# def sum_vectors_numba(a, axis=0):
75+
# """ Calculate the sum of an array of vectors along the specified axis.
7976

80-
Returns:
81-
array: The summed values according to the axis of choice.
82-
"""
83-
return sum(a, axis=axis)
77+
# Parameters:
78+
# a (array): Array of vectors (m x 3).
79+
# axis (int): Dimension to sum through.
80+
81+
# Returns:
82+
# array: The summed values according to the axis of choice.
83+
# """
84+
# return sum(a, axis=axis)
8485

8586

8687
@jit(float64(float64[:]), nogil=True, nopython=True)
@@ -167,6 +168,7 @@ def length_vector_sqrd_xy_numba(a):
167168

168169
# ==============================================================================
169170

171+
170172
@jit(float64[:](float64[:], float64), nogil=True, nopython=True)
171173
def scale_vector_numba(a, factor):
172174
""" Scale a vector by a given factor.
@@ -356,6 +358,7 @@ def square_vectors_numba(a):
356358

357359
# ==============================================================================
358360

361+
359362
@jit(float64[:](float64[:], float64[:]), nogil=True, nopython=True)
360363
def add_vectors_numba(u, v):
361364
""" Add two vectors.
@@ -470,6 +473,7 @@ def divide_vectors_xy_numba(u, v):
470473

471474
# ==============================================================================
472475

476+
473477
@jit(float64[:](float64[:], float64[:]), nogil=True, nopython=True)
474478
def cross_vectors_numba(u, v):
475479
""" Compute the cross product of two vectors.
@@ -532,6 +536,7 @@ def dot_vectors_xy_numba(u, v):
532536

533537
# ==============================================================================
534538

539+
535540
@jit(float64[:, :](float64[:, :], float64[:, :]), nogil=True, nopython=True)
536541
def multiply_matrices_numba(A, B):
537542
""" The multiplication of matrices.
@@ -585,7 +590,7 @@ def multiply_matrix_vector_numba(A, b):
585590
e = array([[1., 2.], [0., 2.]])
586591
f = array([[4., 5.], [1., 2.]])
587592

588-
print(sum_vectors_numba(c, axis=1))
593+
# print(sum_vectors_numba(c, axis=1))
589594
print(norm_vector_numba(u))
590595
print(norm_vectors_numba(c))
591596
print(length_vector_numba(u))

src/compas/interop/shapeop/_shapeop.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def delete(self):
7171

7272
def solve(self, kmax=1):
7373
self.kmax = kmax
74-
self.init()
7574
shapeopPython.shapeop_solve(self.solver, self.kmax)
7675

7776
def set_points(self, xyz):
@@ -85,18 +84,15 @@ def get_points(self):
8584

8685
def add_plane_constraint(self, vertices, weight):
8786
vertices_array = int_array(vertices)
88-
constraint_id = shapeopPython.shapeop_addConstraint(self.solver, 'Plane', vertices_array, len(vertices), weight)
89-
return constraint_id
87+
return shapeopPython.shapeop_addConstraint(self.solver, 'Plane', vertices_array, len(vertices), weight)
9088

9189
def add_circle_constraint(self, vertices, weight):
9290
vertices_array = int_array(vertices)
93-
constraint_id = shapeopPython.shapeop_addConstraint(self.solver, 'Circle', vertices_array, len(vertices), weight)
94-
return constraint_id
91+
return shapeopPython.shapeop_addConstraint(self.solver, 'Circle', vertices_array, len(vertices), weight)
9592

9693
def add_closeness_constraint(self, vertex, weight):
9794
vertices_array = int_array([vertex])
98-
constraint_id = shapeopPython.shapeop_addConstraint(self.solver, 'Closeness', vertices_array, 1, weight)
99-
return constraint_id
95+
return shapeopPython.shapeop_addConstraint(self.solver, 'Closeness', vertices_array, 1, weight)
10096

10197

10298
# ==============================================================================

src/compas/numerical/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
:nosignatures:
3030
3131
descent
32-
devo
32+
devo_numpy
3333
ga
3434
lma
3535
mma
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
from .dr import *
2-
from .dr_cpp import *
32
from .dr_numpy import *
43
from .drx_numpy import *
54
from .fd_numpy import *
65
from .pca_numpy import *
76

87
from .dr import __all__ as a
9-
from .dr_cpp import __all__ as b
10-
from .dr_numpy import __all__ as c
11-
from .drx_numpy import __all__ as d
12-
from .fd_numpy import __all__ as e
13-
from .pca_numpy import __all__ as f
8+
from .dr_numpy import __all__ as b
9+
from .drx_numpy import __all__ as c
10+
from .fd_numpy import __all__ as d
11+
from .pca_numpy import __all__ as e
1412

15-
__all__ = a + b + c + d + e + f
13+
__all__ = a + b + c + d + e

0 commit comments

Comments
 (0)