summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-04-18 22:42:51 (GMT)
committerMarius Kintel <marius@kintel.net>2013-04-18 22:42:51 (GMT)
commitb06b4f32f8c0fb616ebba6ddbf3a2297bf185436 (patch)
tree3ee23c2bdf95cde59f5ca05a312645cdb3a1bab3 /src
parent442ab618a7eebc871195a764b23fb152950b181a (diff)
parent5cee6b58dd1589848518a628a79c582a7320a92e (diff)
Merge branch 'master' into issue116
Diffstat (limited to 'src')
-rw-r--r--src/boosty.h43
-rw-r--r--src/dxftess-glu.cc17
-rw-r--r--src/highlighter.cc2
3 files changed, 39 insertions, 23 deletions
diff --git a/src/boosty.h b/src/boosty.h
index 8b0c93e..82c765b 100644
--- a/src/boosty.h
+++ b/src/boosty.h
@@ -26,6 +26,7 @@
#include <string>
#include <boost/version.hpp>
#include <boost/filesystem.hpp>
+#include <boost/algorithm/string.hpp>
namespace fs = boost::filesystem;
#include "printutils.h"
@@ -97,29 +98,33 @@ inline fs::path canonical( fs::path p )
inline fs::path canonical( fs::path p, fs::path p2 )
{
- // dotpath: win32/mac builds will be using newer versions of boost
- // so we can treat this as though it is unix only
- const fs::path dot_path(".");
- const fs::path dot_dot_path("..");
+#if defined (__WIN32__) || defined(__APPLE__)
+#error you should be using a newer version of boost on win/mac
+#endif
+ // based on the code in boost
fs::path result;
- if (p=="")
+ if (p=="") p=p2;
+ std::string result_s;
+ std::vector<std::string> resultv, pieces;
+ std::vector<std::string>::iterator pi;
+ std::string tmps = boosty::stringy( p );
+ boost::split( pieces, tmps, boost::is_any_of("/") );
+ for ( pi = pieces.begin(); pi != pieces.end(); ++pi )
+ {
+ if (*pi == "..")
+ resultv.erase( resultv.end() );
+ else
+ resultv.push_back( *pi );
+ }
+ for ( pi = resultv.begin(); pi != resultv.end(); ++pi )
{
- p=p2;
+ if ((*pi).length()>0) result_s = result_s + "/" + *pi;
}
- for (fs::path::iterator itr = p.begin(); itr != p.end(); itr++)
+ result = fs::path( result_s );
+ if (fs::is_symlink(result))
{
- if (*itr == dot_path) continue;
- if (*itr == dot_dot_path)
- {
- result.remove_filename();
- continue;
- }
- result /= *itr;
- if (fs::is_symlink(result))
- {
- PRINT("WARNING: canonical() wrapper can't do symlinks. rebuild openscad with boost >=1.48");
- PRINT("WARNING: or don't use symbolic links");
- }
+ PRINT("WARNING: canonical() wrapper can't do symlinks. rebuild openscad with boost >=1.48");
+ PRINT("WARNING: or don't use symbolic links");
}
return result;
}
diff --git a/src/dxftess-glu.cc b/src/dxftess-glu.cc
index 941dbed..3f87729 100644
--- a/src/dxftess-glu.cc
+++ b/src/dxftess-glu.cc
@@ -185,6 +185,17 @@ static bool point_on_line(double *p1, double *p2, double *p3)
return true;
}
+typedef std::pair<int,int> pair_ii;
+inline void do_emplace( boost::unordered_multimap<int, pair_ii> &tri_by_atan2, int ai, const pair_ii &indexes)
+{
+#if BOOST_VERSION >= 104800
+ tri_by_atan2.emplace(ai, indexes);
+#else
+ std::pair< int, pair_ii > tmp( ai, indexes );
+ tri_by_atan2.insert( tmp );
+#endif
+}
+
/*!
up: true if the polygon is facing in the normal direction (i.e. normal = [0,0,1])
rot: CLOCKWISE rotation around positive Z axis
@@ -280,7 +291,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian
for (int j = 0; j < 3; j++) {
int ai = (int)round(atan2(fabs(tess_tri[i].p[(j+1)%3][0] - tess_tri[i].p[j][0]),
fabs(tess_tri[i].p[(j+1)%3][1] - tess_tri[i].p[j][1])) / 0.001);
- tri_by_atan2.emplace(ai, std::pair<int,int>(i, j));
+ do_emplace( tri_by_atan2, ai, std::pair<int,int>(i, j) );
}
while (added_triangles)
{
@@ -321,13 +332,13 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian
for (int m = 0; m < 2; m++) {
int ai = (int)round(atan2(fabs(tess_tri.back().p[(m+1)%3][0] - tess_tri.back().p[m][0]),
fabs(tess_tri.back().p[(m+1)%3][1] - tess_tri.back().p[m][1])) / 0.001 );
- tri_by_atan2.emplace(ai, std::pair<int,int>(tess_tri.size()-1, m));
+ do_emplace(tri_by_atan2, ai, std::pair<int,int>(tess_tri.size()-1, m));
}
tess_tri[i].p[(k+1)%3] = tess_tri[j].p[l];
for (int m = 0; m < 2; m++) {
int ai = (int)round(atan2(fabs(tess_tri[i].p[(m+1)%3][0] - tess_tri[i].p[m][0]),
fabs(tess_tri[i].p[(m+1)%3][1] - tess_tri[i].p[m][1])) / 0.001 );
- tri_by_atan2.emplace(ai, std::pair<int,int>(i, m));
+ do_emplace(tri_by_atan2, ai, std::pair<int,int>(i, m));
}
added_triangles = true;
}
diff --git a/src/highlighter.cc b/src/highlighter.cc
index 391e3a5..bf80bb4 100644
--- a/src/highlighter.cc
+++ b/src/highlighter.cc
@@ -151,7 +151,7 @@ Highlighter::Highlighter(QTextDocument *parent)
tokentypes["import"] << "include" << "use" << "import_stl" << "import" << "import_dxf" << "dxf_dim" << "dxf_cross";
typeformats["import"].setForeground(Qt::darkYellow);
- tokentypes["special"] << "$children" << "child" << "$fn" << "$fa" << "$fb";
+ tokentypes["special"] << "$children" << "child" << "$fn" << "$fa" << "$fs" << "$t" << "$vpt" << "$vpr";
typeformats["special"].setForeground(Qt::darkGreen);
tokentypes["extrude"] << "linear_extrude" << "rotate_extrude";
contact: Jan Huwald // Impressum