Skip to content

Commit 4b4fa6b

Browse files
author
pv
committed
CHANGE include of std and remove using statements.
1 parent daf376c commit 4b4fa6b

File tree

3 files changed

+47
-55
lines changed

3 files changed

+47
-55
lines changed

src/compas.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <cmath>
1212
#include <iostream>
1313
#include <limits>
14+
#include <iostream>
1415

1516
// Nanobind includes
1617
#include <nanobind/nanobind.h>

src/patternmap.cpp

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "patternmap.hpp"
22

3-
4-
void iglMesh::loadMesh(vector<vector<double>> &_vertices, vector<vector<int>> &_faces)
3+
void iglMesh::loadMesh(std::vector<std::vector<double>> &_vertices, std::vector<std::vector<int>> &_faces)
54
{
65
//read vertices' coordinates
76
V_ = Eigen::MatrixXd::Zero(_vertices.size() , 3);
@@ -40,8 +39,8 @@ void iglMesh::cleanMesh()
4039
igl::polygons_to_triangles(I_eigen, P, F_, J);
4140

4241
//remove duplicate
43-
MatrixXd SV;
44-
MatrixXi SF;
42+
Eigen::MatrixXd SV;
43+
Eigen::MatrixXi SF;
4544
Eigen::VectorXi SVI, SVJ;
4645
igl::remove_duplicate_vertices(V_, F_, 1e-6f, SV, SVI, SVJ, SF);
4746
F_ = SF;
@@ -56,7 +55,7 @@ void iglMesh::cleanMesh()
5655
}
5756

5857

59-
vector<bool> inList; inList.resize(V_.rows(), false);
58+
std::vector<bool> inList; inList.resize(V_.rows(), false);
6059
for(int id = 0; id < faces_.size(); id++)
6160
{
6261
for(int jd = 0; jd < faces_[id].size(); jd++)
@@ -66,7 +65,7 @@ void iglMesh::cleanMesh()
6665
}
6766

6867
int count = 0;
69-
vector<int> newIndex;
68+
std::vector<int> newIndex;
7069
for(int id = 0; id < inList.size(); id++){
7170
if(inList[id]) {
7271
newIndex.push_back(count++);
@@ -76,7 +75,7 @@ void iglMesh::cleanMesh()
7675
}
7776
}
7877

79-
SV = MatrixXd(count, 3);
78+
SV = Eigen::MatrixXd(count, 3);
8079
for(int id = 0; id < inList.size(); id++){
8180
if(inList[id]){
8281
SV.row(newIndex[id]) = V_.row(id);
@@ -96,28 +95,28 @@ void iglMesh::cleanMesh()
9695

9796
}
9897

99-
vector<vector<double>> iglMesh::getVertices()
98+
std::vector<std::vector<double>> iglMesh::getVertices()
10099
{
101100
//write vertices
102-
vector<vector<double>> vertices;
101+
std::vector<std::vector<double>> vertices;
103102
for(int id = 0; id < V_.rows(); id++){
104-
vector<double> pos;
103+
std::vector<double> pos;
105104
pos.push_back(V_(id, 0));pos.push_back(V_(id, 1));pos.push_back(V_(id, 2));
106105
vertices.push_back(pos);
107106
}
108107
return vertices;
109108
}
110109

111-
vector<vector<int>> iglMesh::getFaces() {
110+
std::vector<std::vector<int>> iglMesh::getFaces() {
112111
return faces_;
113112
}
114113

115-
vector<vector<double>> iglMesh::getUVs()
114+
std::vector<std::vector<double>> iglMesh::getUVs()
116115
{
117116
//write vertices
118-
vector<vector<double>> uvs;
117+
std::vector<std::vector<double>> uvs;
119118
for(int id = 0; id < UV_.rows(); id++){
120-
vector<double> pos;
119+
std::vector<double> pos;
121120
pos.push_back(UV_(id, 0));pos.push_back(UV_(id, 1)); pos.push_back(0);
122121
uvs.push_back(pos);
123122
}
@@ -148,8 +147,8 @@ void iglMesh::parametrization_lscm()
148147
Eigen::VectorXi bnd,b(2);
149148
igl::boundary_loop(F_,bnd);
150149
b(0) = bnd(0);
151-
b(1) = bnd(((int)round(bnd.size() / 2)));
152-
MatrixXd bc(2,2);
150+
b(1) = bnd(((int)std::round(bnd.size() / 2)));
151+
Eigen::MatrixXd bc(2,2);
153152
bc<<0,0,1,0;
154153
igl::lscm(V_,F_,b,bc,UV_);
155154

@@ -198,7 +197,7 @@ void iglMesh::mapMesh3D_simple(iglMesh &baseMesh)
198197
parametrization_simple();
199198
}
200199

201-
vector<bool> inMesh;
200+
std::vector<bool> inMesh;
202201
int count = 0;
203202
for(int id = 0; id < baseMesh.V_.rows(); id++)
204203
{
@@ -217,7 +216,7 @@ void iglMesh::mapMesh3D_simple(iglMesh &baseMesh)
217216
}
218217
}
219218

220-
for(auto it = baseMesh.faces_.begin(); it != baseMesh.faces_.end();)
219+
for(std::vector<std::vector<int>>::iterator it = baseMesh.faces_.begin(); it != baseMesh.faces_.end();)
221220
{
222221
bool all_in_refMesh = true;
223222
for(int jd = 0; jd < (*it).size(); jd++)
@@ -246,12 +245,12 @@ void iglMesh::mapMesh3D_AABB(iglMesh &baseMesh)
246245
parametrization_lscm();
247246
}
248247

249-
igl::AABB<MatrixXd, 2> tree;
248+
igl::AABB<Eigen::MatrixXd, 2> tree;
250249
tree.init(UV_, F_);
251250

252-
vector<bool> inMesh;
251+
std::vector<bool> inMesh;
253252
baseMesh.parametrization_simple();
254-
MatrixXd C;
253+
Eigen::MatrixXd C;
255254
Eigen::VectorXi I;
256255
Eigen::VectorXd sqrD;
257256
tree.squared_distance(UV_, F_, baseMesh.UV_, sqrD, I, C);
@@ -274,7 +273,7 @@ void iglMesh::mapMesh3D_AABB(iglMesh &baseMesh)
274273
}
275274
}
276275

277-
for(vector<vector<int>>::iterator it = baseMesh.faces_.begin(); it != baseMesh.faces_.end();)
276+
for(std::vector<std::vector<int>>::iterator it = baseMesh.faces_.begin(); it != baseMesh.faces_.end();)
278277
{
279278
bool all_in_refMesh = true;
280279
for(int jd = 0; jd < (*it).size(); jd++)
@@ -301,9 +300,9 @@ void iglMesh::getTriFace(int faceID, Eigen::MatrixXd &V, Eigen::MatrixXd &A, Eig
301300
{
302301
if(0 <= faceID && faceID < F_.rows())
303302
{
304-
A = MatrixXd(1, 3);
305-
B = MatrixXd(1, 3);
306-
C = MatrixXd(1, 3);
303+
A = Eigen::MatrixXd(1, 3);
304+
B = Eigen::MatrixXd(1, 3);
305+
C = Eigen::MatrixXd(1, 3);
307306
if(V.cols() == 2)
308307
{
309308
A << V(F_(faceID, 0), 0), V(F_(faceID, 0), 1), 0;
@@ -323,11 +322,11 @@ void iglMesh::getTriFace(int faceID, Eigen::MatrixXd &V, Eigen::MatrixXd &A, Eig
323322
iglMesh iglMesh::saveWireFrame(double thickness, int cylinder_pts)
324323
{
325324

326-
MatrixXi E;
325+
Eigen::MatrixXi E;
327326
igl::edges(F_, E);
328327

329328

330-
vector<vector<int>> vv;
329+
std::vector<std::vector<int>> vv;
331330
vv.resize(V_.rows());
332331
for(int id = 0; id < faces_.size(); id++){
333332
for(int jd = 0; jd < faces_[id].size(); jd++){
@@ -338,30 +337,30 @@ iglMesh iglMesh::saveWireFrame(double thickness, int cylinder_pts)
338337
}
339338
}
340339

341-
vector<vector<double>> vers;
342-
vector<vector<int>> faces;
340+
std::vector<std::vector<double>> vers;
341+
std::vector<std::vector<int>> faces;
343342
for(int id = 0; id < E.rows(); id++)
344343
{
345344
int sta = E(id, 0);
346345
int end = E(id, 1);
347-
Vector3d staPt = V_.row(sta);
348-
Vector3d endPt = V_.row(end);
346+
Eigen::Vector3d staPt = V_.row(sta);
347+
Eigen::Vector3d endPt = V_.row(end);
349348

350349
if(std::any_of(vv[sta].begin(), vv[sta].end(), [=](int a){return a == end;}))
351350
{
352-
Vector3d z_axis = endPt - staPt; z_axis /= (z_axis).norm();
353-
Vector3d x_axis = Vector3d(0, 1, 0).cross(z_axis);
354-
if(x_axis.norm() < 1e-4) x_axis = Vector3d(1, 0, 0).cross(z_axis); x_axis /= z_axis.norm();
355-
Vector3d y_axis = z_axis.cross(x_axis); y_axis /= y_axis.norm();
351+
Eigen::Vector3d z_axis = endPt - staPt; z_axis /= (z_axis).norm();
352+
Eigen::Vector3d x_axis = Eigen::Vector3d(0, 1, 0).cross(z_axis);
353+
if(x_axis.norm() < 1e-4) x_axis = Eigen::Vector3d(1, 0, 0).cross(z_axis); x_axis /= z_axis.norm();
354+
Eigen::Vector3d y_axis = z_axis.cross(x_axis); y_axis /= y_axis.norm();
356355

357356
for(int id = 0; id < cylinder_pts; id++)
358357
{
359358
float angle0 = 2 * 3.1415926/cylinder_pts * id;
360359
float angle1 = 2 * 3.1415926/cylinder_pts * (id + 1);
361-
Vector3d v_sta0 = staPt + x_axis * thickness * cos(angle0) + y_axis * thickness * sin(angle0);
362-
Vector3d v_sta1 = staPt + x_axis * thickness * cos(angle1) + y_axis * thickness * sin(angle1);
363-
Vector3d v_end0 = v_sta0 + (endPt - staPt);
364-
Vector3d v_end1 = v_sta1 + (endPt - staPt);
360+
Eigen::Vector3d v_sta0 = staPt + x_axis * thickness * std::cos(angle0) + y_axis * thickness * std::sin(angle0);
361+
Eigen::Vector3d v_sta1 = staPt + x_axis * thickness * std::cos(angle1) + y_axis * thickness * std::sin(angle1);
362+
Eigen::Vector3d v_end0 = v_sta0 + (endPt - staPt);
363+
Eigen::Vector3d v_end1 = v_sta1 + (endPt - staPt);
365364
int f = vers.size();
366365
vers.push_back({v_sta0(0),v_sta0(1), v_sta0(2)});
367366
vers.push_back({v_sta1(0),v_sta1(1), v_sta1(2)});

src/patternmap.hpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#include "compas.hpp"
44

55
#include <Eigen/Dense>
6-
#include <vector>
7-
#include <iostream>
86

97
// #include <igl/polygon_mesh_to_triangle_mesh.h>
108
#include <igl/polygons_to_triangles.h>
@@ -14,33 +12,27 @@
1412
#include <igl/boundary_loop.h>
1513
#include <igl/AABB.h>
1614
#include <igl/edges.h>
17-
#include <algorithm>
18-
19-
using std::vector;
20-
using Eigen::MatrixXd;
21-
using Eigen::MatrixXi;
22-
using Eigen::Vector3d;
2315

2416
class iglMesh {
2517
public:
2618

27-
MatrixXd V_;
19+
Eigen::MatrixXd V_;
2820

29-
vector<vector<int>> faces_; //polygonal Mesh
30-
MatrixXi F_; //triangle Mesh
21+
std::vector<std::vector<int>> faces_; //polygonal Mesh
22+
Eigen::MatrixXi F_; //triangle Mesh
3123

32-
MatrixXd UV_; //uv
24+
Eigen::MatrixXd UV_; //uv
3325
public:
3426

3527
iglMesh(){};
3628

37-
void loadMesh(vector<vector<double>> &_vertices, vector<vector<int>>& _faces);
29+
void loadMesh(std::vector<std::vector<double>> &_vertices, std::vector<std::vector<int>>& _faces);
3830

39-
vector<vector<double>> getVertices();
31+
std::vector<std::vector<double>> getVertices();
4032

41-
vector<vector<double>> getUVs();
33+
std::vector<std::vector<double>> getUVs();
4234

43-
vector<vector<int>> getFaces();
35+
std::vector<std::vector<int>> getFaces();
4436

4537
public:
4638

0 commit comments

Comments
 (0)