Skip to content

Commit 039d4f8

Browse files
committed
clean up c++
1 parent 9f7136f commit 039d4f8

15 files changed

+101
-106
lines changed

src/booleans.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#include "booleans.h"
2-
32
#include <CGAL/Polygon_mesh_processing/corefinement.h>
43

4+
55
namespace PMP = CGAL::Polygon_mesh_processing;
6-
namespace params = PMP::parameters;
7-
namespace py = pybind11;
6+
87

98
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
109
pmp_boolean_union(
@@ -26,6 +25,7 @@ pmp_boolean_union(
2625
return R;
2726
};
2827

28+
2929
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
3030
pmp_boolean_difference(
3131
Eigen::Ref<const compas::RowMatrixXd> &VA,
@@ -46,6 +46,7 @@ pmp_boolean_difference(
4646
return R;
4747
};
4848

49+
4950
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
5051
pmp_boolean_intersection(
5152
Eigen::Ref<const compas::RowMatrixXd> &VA,
@@ -66,31 +67,32 @@ pmp_boolean_intersection(
6667
return R;
6768
};
6869

69-
void init_booleans(py::module &m)
70+
71+
void init_booleans(pybind11::module &m)
7072
{
71-
py::module submodule = m.def_submodule("booleans");
73+
pybind11::module submodule = m.def_submodule("booleans");
7274

7375
submodule.def(
7476
"boolean_union",
7577
&pmp_boolean_union,
76-
py::arg("VA").noconvert(),
77-
py::arg("FA").noconvert(),
78-
py::arg("VB").noconvert(),
79-
py::arg("FB").noconvert());
78+
pybind11::arg("VA").noconvert(),
79+
pybind11::arg("FA").noconvert(),
80+
pybind11::arg("VB").noconvert(),
81+
pybind11::arg("FB").noconvert());
8082

8183
submodule.def(
8284
"boolean_difference",
8385
&pmp_boolean_difference,
84-
py::arg("VA").noconvert(),
85-
py::arg("FA").noconvert(),
86-
py::arg("VB").noconvert(),
87-
py::arg("FB").noconvert());
86+
pybind11::arg("VA").noconvert(),
87+
pybind11::arg("FA").noconvert(),
88+
pybind11::arg("VB").noconvert(),
89+
pybind11::arg("FB").noconvert());
8890

8991
submodule.def(
9092
"boolean_intersection",
9193
&pmp_boolean_intersection,
92-
py::arg("VA").noconvert(),
93-
py::arg("FA").noconvert(),
94-
py::arg("VB").noconvert(),
95-
py::arg("FB").noconvert());
94+
pybind11::arg("VA").noconvert(),
95+
pybind11::arg("FA").noconvert(),
96+
pybind11::arg("VB").noconvert(),
97+
pybind11::arg("FB").noconvert());
9698
};

src/booleans.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,29 @@
33

44
#include <compas.h>
55

6+
67
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
78
pmp_boolean_union(
89
Eigen::Ref<const compas::RowMatrixXd> &VA,
910
Eigen::Ref<const compas::RowMatrixXi> &FA,
1011
Eigen::Ref<const compas::RowMatrixXd> &VB,
1112
Eigen::Ref<const compas::RowMatrixXi> &FB);
1213

14+
1315
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
1416
pmp_boolean_difference(
1517
Eigen::Ref<const compas::RowMatrixXd> &VA,
1618
Eigen::Ref<const compas::RowMatrixXi> &FA,
1719
Eigen::Ref<const compas::RowMatrixXd> &VB,
1820
Eigen::Ref<const compas::RowMatrixXi> &FB);
1921

22+
2023
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
2124
pmp_boolean_intersection(
2225
Eigen::Ref<const compas::RowMatrixXd> &VA,
2326
Eigen::Ref<const compas::RowMatrixXi> &FA,
2427
Eigen::Ref<const compas::RowMatrixXd> &VB,
2528
Eigen::Ref<const compas::RowMatrixXi> &FB);
2629

30+
2731
#endif /* COMPAS_BOOLEANS_H */

src/compas.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <compas.h>
22
#include <pybind11/pybind11.h>
33

4-
namespace py = pybind11;
54

65
Mesh
76
compas::mesh_from_vertices_and_faces(
@@ -32,6 +31,7 @@ compas::mesh_from_vertices_and_faces(
3231
return mesh;
3332
}
3433

34+
3535
Mesh
3636
compas::ngon_from_vertices_and_faces(
3737
const compas::RowMatrixXd & V,
@@ -57,9 +57,9 @@ compas::ngon_from_vertices_and_faces(
5757
}
5858

5959
return mesh;
60-
6160
}
6261

62+
6363
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
6464
compas::mesh_to_vertices_and_faces(
6565
const Mesh & mesh)
@@ -90,6 +90,7 @@ compas::mesh_to_vertices_and_faces(
9090
return result;
9191
}
9292

93+
9394
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
9495
compas::quadmesh_to_vertices_and_faces(
9596
const Mesh & mesh)
@@ -120,12 +121,12 @@ compas::quadmesh_to_vertices_and_faces(
120121
return result;
121122
}
122123

124+
123125
// TODO: rename to ResultMesh
124126
// construct a result mesh
125127
// from a CGAL surface mesh
126128
compas::Result
127-
compas::result_from_mesh(
128-
const Mesh & mesh)
129+
compas::result_from_mesh(const Mesh & mesh)
129130
{
130131
int v = mesh.number_of_vertices();
131132
int f = mesh.number_of_faces();
@@ -156,12 +157,12 @@ compas::result_from_mesh(
156157
return R;
157158
}
158159

160+
159161
// construct a set of result polylines
160162
// from CGAL polylines
161163
// the CGAL polylines are a list of vectors of points
162164
std::vector<compas::RowMatrixXd>
163-
compas::result_from_polylines(
164-
Polylines polylines)
165+
compas::result_from_polylines(Polylines polylines)
165166
{
166167
std::vector<compas::RowMatrixXd> pointsets;
167168

src/compas_cgal.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
#include <pybind11/pybind11.h>
22
#include <compas.h>
33

4-
namespace py = pybind11;
54

6-
void init_meshing(py::module&);
7-
void init_booleans(py::module&);
8-
void init_slicer(py::module&);
9-
void init_intersections(py::module&);
10-
void init_measure(py::module&);
11-
void init_triangulations(py::module&);
12-
void init_subdivision(py::module&);
5+
// here all modules of "_cgal" are declared.
6+
void init_meshing(pybind11::module&);
7+
void init_booleans(pybind11::module&);
8+
void init_slicer(pybind11::module&);
9+
void init_intersections(pybind11::module&);
10+
void init_measure(pybind11::module&);
11+
void init_triangulations(pybind11::module&);
12+
void init_subdivision(pybind11::module&);
13+
1314

1415
// the first parameter here ("_cgal") will be the name of the "so" or "pyd" file that will be produced by PyBind11
1516
// which is the entry point from where all other modules will be accessible.
1617
PYBIND11_MODULE(_cgal, m) {
1718
m.doc() = "";
1819

19-
py::class_<compas::Result>(m, "Result")
20+
// register Result as a Python class
21+
pybind11::class_<compas::Result>(m, "Result")
2022
.def_readonly("vertices", &compas::Result::vertices)
2123
.def_readonly("faces", &compas::Result::faces);
2224

src/intersections.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#include "intersections.h"
22
#include <CGAL/Polygon_mesh_processing/intersection.h>
33

4+
45
namespace PMP = CGAL::Polygon_mesh_processing;
5-
namespace params = PMP::parameters;
6-
namespace py = pybind11;
76

87

98
std::vector<compas::RowMatrixXd>
@@ -26,15 +25,15 @@ pmp_intersection_mesh_mesh(
2625
};
2726

2827

29-
void init_intersections(py::module & m) {
30-
py::module submodule = m.def_submodule("intersections");
28+
void init_intersections(pybind11::module & m) {
29+
pybind11::module submodule = m.def_submodule("intersections");
3130

3231
submodule.def(
3332
"intersection_mesh_mesh",
3433
&pmp_intersection_mesh_mesh,
35-
py::arg("VA").noconvert(),
36-
py::arg("FA").noconvert(),
37-
py::arg("VB").noconvert(),
38-
py::arg("FB").noconvert()
34+
pybind11::arg("VA").noconvert(),
35+
pybind11::arg("FA").noconvert(),
36+
pybind11::arg("VB").noconvert(),
37+
pybind11::arg("FB").noconvert()
3938
);
4039
}

src/intersections.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <compas.h>
55

6+
67
std::vector<compas::RowMatrixXd>
78
pmp_intersection_mesh_mesh(
89
Eigen::Ref<const compas::RowMatrixXd> & VA,

src/measure.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "measure.h"
2-
32
#include <CGAL/Polygon_mesh_processing/measure.h>
43

4+
55
namespace PMP = CGAL::Polygon_mesh_processing;
6-
namespace py = pybind11;
6+
77

88
double
99
pmp_volume(
@@ -17,13 +17,14 @@ pmp_volume(
1717
return volume;
1818
};
1919

20-
void init_measure(py::module & m) {
21-
py::module submodule = m.def_submodule("measure");
20+
21+
void init_measure(pybind11::module & m) {
22+
pybind11::module submodule = m.def_submodule("measure");
2223

2324
submodule.def(
2425
"volume",
2526
&pmp_volume,
26-
py::arg("V").noconvert(),
27-
py::arg("F").noconvert()
27+
pybind11::arg("V").noconvert(),
28+
pybind11::arg("F").noconvert()
2829
);
2930
};

src/measure.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
#include <compas.h>
55

6+
67
double
78
pmp_volume(
89
Eigen::Ref<const compas::RowMatrixXd> & V,
910
Eigen::Ref<const compas::RowMatrixXi> & F);
1011

12+
1113
#endif /* COMPAS_MEASURE_H */

src/meshing.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include "meshing.h"
2-
32
#include <CGAL/Polygon_mesh_processing/remesh.h>
43
#include <CGAL/Polygon_mesh_processing/detect_features.h>
54

5+
66
namespace PMP = CGAL::Polygon_mesh_processing;
7-
namespace params = PMP::parameters;
8-
namespace py = pybind11;
7+
98

109
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
1110
pmp_remesh(
@@ -27,7 +26,7 @@ pmp_remesh(
2726
faces(mesh),
2827
target_edge_length,
2928
mesh,
30-
params::number_of_iterations(number_of_iterations).do_project(do_project));
29+
PMP::parameters::number_of_iterations(number_of_iterations).do_project(do_project));
3130

3231
mesh.collect_garbage();
3332

@@ -38,16 +37,17 @@ pmp_remesh(
3837
return R;
3938
};
4039

41-
void init_meshing(py::module & m) {
42-
py::module submodule = m.def_submodule("meshing");
40+
41+
void init_meshing(pybind11::module & m) {
42+
pybind11::module submodule = m.def_submodule("meshing");
4343

4444
submodule.def(
4545
"remesh",
4646
&pmp_remesh,
47-
py::arg("V").noconvert(),
48-
py::arg("F").noconvert(),
49-
py::arg("target_edge_length"),
50-
py::arg("number_of_iterations") = 10,
51-
py::arg("do_project") = true
47+
pybind11::arg("V").noconvert(),
48+
pybind11::arg("F").noconvert(),
49+
pybind11::arg("target_edge_length"),
50+
pybind11::arg("number_of_iterations") = 10,
51+
pybind11::arg("do_project") = true
5252
);
5353
};

src/meshing.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <compas.h>
55

6+
67
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
78
pmp_remesh(
89
Eigen::Ref<const compas::RowMatrixXd> & V,
@@ -11,4 +12,5 @@ pmp_remesh(
1112
unsigned int number_of_iterations = 10,
1213
bool do_project = true);
1314

15+
1416
#endif /* COMPAS_MESHING_H */

0 commit comments

Comments
 (0)