summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ThrownTogetherRenderer.cc6
-rw-r--r--src/dxftess-cgal.cc33
-rw-r--r--src/dxftess-glu.cc2
-rw-r--r--src/grid.h27
4 files changed, 38 insertions, 30 deletions
diff --git a/src/ThrownTogetherRenderer.cc b/src/ThrownTogetherRenderer.cc
index 01c7513..336c4c7 100644
--- a/src/ThrownTogetherRenderer.cc
+++ b/src/ThrownTogetherRenderer.cc
@@ -30,6 +30,8 @@
#include "system-gl.h"
+#include <boost/unordered_map.hpp>
+
ThrownTogetherRenderer::ThrownTogetherRenderer(CSGChain *root_chain,
CSGChain *highlights_chain,
CSGChain *background_chain)
@@ -60,9 +62,9 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight,
bool fberror) const
{
glDepthFunc(GL_LEQUAL);
- QHash<QPair<PolySet*,Transform3d*>,int> polySetVisitMark;
+ boost::unordered_map<std::pair<PolySet*,Transform3d*>,int> polySetVisitMark;
for (size_t i = 0; i < chain->polysets.size(); i++) {
- if (polySetVisitMark[QPair<PolySet*,Transform3d*>(chain->polysets[i].get(), &chain->matrices[i])]++ > 0)
+ if (polySetVisitMark[std::make_pair(chain->polysets[i].get(), &chain->matrices[i])]++ > 0)
continue;
const Transform3d &m = chain->matrices[i];
double *c = chain->colors[i];
diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc
index a587987..cf5b75d 100644
--- a/src/dxftess-cgal.cc
+++ b/src/dxftess-cgal.cc
@@ -25,6 +25,8 @@ typedef CDT::Point CDTPoint;
#include <CGAL/Mesh_2/Face_badness.h>
+#include <boost/unordered_map.hpp>
+
template <class T> class DummyCriteria {
public:
typedef double Quality;
@@ -51,7 +53,7 @@ struct point_info_t
double x, y;
int pathidx, pointidx;
int max_pointidx_in_path;
- QList<int> triangles;
+ std::vector<int> triangles;
struct point_info_t *neigh_next;
struct point_info_t *neigh_prev;
@@ -61,10 +63,11 @@ struct point_info_t
point_info_t() : x(0), y(0), pathidx(-1), pointidx(-1), max_pointidx_in_path(-1) { }
};
-typedef QPair<point_info_t*,point_info_t*> edge_t;
+typedef std::pair<point_info_t*,point_info_t*> edge_t;
-void mark_inner_outer(QList<struct triangle> &tri, Grid2d<point_info_t> &point_info,
- QHash<edge_t,int> &edge_to_triangle, QHash<edge_t,int> &edge_to_path, int idx, bool inner)
+void mark_inner_outer(std::vector<struct triangle> &tri, Grid2d<point_info_t> &point_info,
+ boost::unordered_map<edge_t,int> &edge_to_triangle,
+ boost::unordered_map<edge_t,int> &edge_to_path, int idx, bool inner)
{
if (tri[idx].is_marked)
return;
@@ -85,8 +88,8 @@ void mark_inner_outer(QList<struct triangle> &tri, Grid2d<point_info_t> &point_i
};
for (int i = 0; i < 3; i++) {
- if (edge_to_triangle.contains(edges[i])) {
- bool next_inner = edge_to_path.contains(edges[i]) ? !inner : inner;
+ if (edge_to_triangle.find(edges[i]) != edge_to_triangle.end()) {
+ bool next_inner = (edge_to_path.find(edges[i]) != edge_to_path.end()) ? !inner : inner;
mark_inner_outer(tri, point_info, edge_to_triangle, edge_to_path,
edge_to_triangle[edges[i]], next_inner);
}
@@ -97,10 +100,10 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr
{
CDT cdt;
- QList<struct triangle> tri;
+ std::vector<struct triangle> tri;
Grid2d<point_info_t> point_info(GRID_FINE);
- QHash<edge_t,int> edge_to_triangle;
- QHash<edge_t,int> edge_to_path;
+ boost::unordered_map<edge_t,int> edge_to_triangle;
+ boost::unordered_map<edge_t,int> edge_to_path;
CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION);
try {
@@ -177,14 +180,14 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr
continue;
int idx = tri.size();
- tri.append(triangle());
+ tri.push_back(triangle());
point_info_t *pi[3];
for (int i=0; i<3; i++) {
double px = iter->vertex(i)->point()[0];
double py = iter->vertex(i)->point()[1];
pi[i] = &point_info.align(px, py);
- pi[i]->triangles.append(idx);
+ pi[i]->triangles.push_back(idx);
tri[idx].p[i].x = px;
tri[idx].p[i].y = py;
}
@@ -200,7 +203,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr
double far_left_x = 0;
struct point_info_t *far_left_p = NULL;
- for (int i = 0; i < tri.size(); i++)
+ for (size_t i = 0; i < tri.size(); i++)
{
if (tri[i].is_marked)
continue;
@@ -219,7 +222,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr
break;
// find one inner triangle and run recursive marking
- for (int i = 0; i < far_left_p->triangles.size(); i++)
+ for (size_t i = 0; i < far_left_p->triangles.size(); i++)
{
int idx = far_left_p->triangles[i];
@@ -273,7 +276,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr
// far left point is in the middle of a vertical segment
// -> it is ok to use any unmarked triangle connected to this point
- for (int i = 0; i < far_left_p->triangles.size(); i++)
+ for (size_t i = 0; i < far_left_p->triangles.size(); i++)
{
int idx = far_left_p->triangles[i];
@@ -288,7 +291,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr
}
// add all inner triangles to target polyset
- for(int i = 0; i < tri.size(); i++)
+ for(size_t i = 0; i < tri.size(); i++)
{
if (!tri[i].is_inner)
continue;
diff --git a/src/dxftess-glu.cc b/src/dxftess-glu.cc
index 4ad2051..4207bcd 100644
--- a/src/dxftess-glu.cc
+++ b/src/dxftess-glu.cc
@@ -8,6 +8,8 @@
#include "mathc99.h"
#include <QVector>
+#include <QPair>
+#include <QHash>
#ifdef WIN32
# define STDCALL __stdcall
diff --git a/src/grid.h b/src/grid.h
index 74d72f9..2815182 100644
--- a/src/grid.h
+++ b/src/grid.h
@@ -1,7 +1,6 @@
#ifndef GRID_H_
#define GRID_H_
-#include <QHash>
#include "mathc99.h"
#ifdef WIN32
typedef __int64 int64_t;
@@ -9,6 +8,8 @@ typedef __int64 int64_t;
#include <stdint.h>
#endif
#include <stdlib.h>
+#include <boost/unordered_map.hpp>
+#include <utility>
const double GRID_COARSE = 0.001;
const double GRID_FINE = 0.000001;
@@ -18,7 +19,7 @@ class Grid2d
{
public:
double res;
- QHash<QPair<int64_t,int64_t>, T> db;
+ boost::unordered_map<std::pair<int64_t,int64_t>, T> db;
Grid2d(double resolution) {
res = resolution;
@@ -31,11 +32,11 @@ public:
T &align(double &x, double &y) {
int64_t ix = (int64_t)round(x / res);
int64_t iy = (int64_t)round(y / res);
- if (!db.contains(QPair<int64_t,int64_t>(ix, iy))) {
+ if (db.find(std::make_pair(ix, iy)) == db.end()) {
int dist = 10;
for (int64_t jx = ix - 1; jx <= ix + 1; jx++) {
for (int64_t jy = iy - 1; jy <= iy + 1; jy++) {
- if (!db.contains(QPair<int64_t,int64_t>(jx, jy)))
+ if (db.find(std::make_pair(jx, jy)) == db.end())
continue;
int d = abs(int(ix-jx)) + abs(int(iy-jy));
if (d < dist) {
@@ -47,16 +48,16 @@ public:
}
}
x = ix * res, y = iy * res;
- return db[QPair<int64_t,int64_t>(ix, iy)];
+ return db[std::make_pair(ix, iy)];
}
bool has(double x, double y) const {
int64_t ix = (int64_t)round(x / res);
int64_t iy = (int64_t)round(y / res);
- if (db.contains(QPair<int64_t,int64_t>(ix, iy)))
+ if (db.find(std::make_pair(ix, iy)) != db.end())
return true;
for (int64_t jx = ix - 1; jx <= ix + 1; jx++)
for (int64_t jy = iy - 1; jy <= iy + 1; jy++) {
- if (db.contains(QPair<int64_t,int64_t>(jx, jy)))
+ if (db.find(std::make_pair(jx, jy)) != db.end())
return true;
}
return false;
@@ -81,7 +82,7 @@ class Grid3d
{
public:
double res;
- QHash<QPair<QPair<int64_t,int64_t>,int64_t>, T> db;
+ boost::unordered_map<std::pair<std::pair<int64_t,int64_t>,int64_t>, T> db;
Grid3d(double resolution) {
res = resolution;
@@ -90,12 +91,12 @@ public:
int64_t ix = (int64_t)round(x / res);
int64_t iy = (int64_t)round(y / res);
int64_t iz = (int64_t)round(z / res);
- if (!db.contains(QPair<QPair<int64_t,int64_t>,int64_t>(QPair<int64_t,int64_t>(ix, iy), iz))) {
+ if (db.find(std::make_pair(std::make_pair(ix, iy), iz)) == db.end()) {
int dist = 10;
for (int64_t jx = ix - 1; jx <= ix + 1; jx++) {
for (int64_t jy = iy - 1; jy <= iy + 1; jy++) {
for (int64_t jz = iz - 1; jz <= iz + 1; jz++) {
- if (!db.contains(QPair<QPair<int64_t,int64_t>,int64_t>(QPair<int64_t,int64_t>(jx, jy), jz)))
+ if (db.find(std::make_pair(std::make_pair(jx, jy), jz)) == db.end())
continue;
int d = abs(int(ix-jx)) + abs(int(iy-jy)) + abs(int(iz-jz));
if (d < dist) {
@@ -109,18 +110,18 @@ public:
}
}
x = ix * res, y = iy * res, z = iz * res;
- return db[QPair<QPair<int64_t,int64_t>,int64_t>(QPair<int64_t,int64_t>(ix, iy), iz)];
+ return db[std::make_pair(std::make_pair(ix, iy), iz)];
}
bool has(double x, double y, double z) {
int64_t ix = (int64_t)round(x / res);
int64_t iy = (int64_t)round(y / res);
int64_t iz = (int64_t)round(z / res);
- if (db.contains(QPair<QPair<int64_t,int64_t>,int64_t>(QPair<int64_t,int64_t>(ix, iy), iz)))
+ if (db.find(std::make_pair(std::make_pair(ix, iy), iz)) != db.end())
return true;
for (int64_t jx = ix - 1; jx <= ix + 1; jx++)
for (int64_t jy = iy - 1; jy <= iy + 1; jy++)
for (int64_t jz = iz - 1; jz <= iz + 1; jz++) {
- if (db.contains(QPair<QPair<int64_t,int64_t>,int64_t>(QPair<int64_t,int64_t>(jx, jy), jz)))
+ if (db.find(std::make_pair(std::make_pair(jx, jy), jz)) != db.end())
return true;
}
return false;
contact: Jan Huwald // Impressum