Skip to content

Commit

Permalink
Merge branch 'master' into spurs
Browse files Browse the repository at this point in the history
Conflicts:
	SConstruct
	miracle.config
	src/mgl/pather.cc
	src/mgl/regioner.cc
	src/mgl/regioner.h
  • Loading branch information
Joe Sadusk committed Nov 7, 2012
2 parents 80478c1 + 8998a34 commit c99243b
Show file tree
Hide file tree
Showing 108 changed files with 31,580 additions and 2,182 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -14,6 +14,9 @@ nbproject
*.bak
*.pyc

# ignore stl folder
stl/*

#ignore build system files
Makefile.*
/miracle_gui.pro.user
Expand Down Expand Up @@ -47,4 +50,4 @@ bin/*

#ignore editor backups
*~
*#
*#
93 changes: 42 additions & 51 deletions SConstruct
Expand Up @@ -133,16 +133,11 @@ operating_system = sys.platform

print "Operating system: [" + operating_system + "]"

LIBTHING_PATH = 'submodule/libthing/src/main/cpp/'
LIBTHING_INCLUDE = LIBTHING_PATH + 'include'
LIBTHING_SRC = LIBTHING_PATH + 'src/'

default_libs = []
default_includes = ['submodule/json-cpp/include',
'submodule/EzCppLog',
'submodule/optionparser/src',
'../eigen',
LIBTHING_INCLUDE]
'../eigen']

tools = ['default']

Expand Down Expand Up @@ -203,49 +198,46 @@ env.Append(CCFLAGS = ['-Wall', '-Wextra'])
# print "QT modules", qtModules
# env.EnableQt4Modules(qtModules)

libthing_cc = [ LIBTHING_SRC+'Scalar.cc',
LIBTHING_SRC+'Vector2.cc',
LIBTHING_SRC+'Vector3.cc',
LIBTHING_SRC+'Triangle3.cc',
LIBTHING_SRC+"LineSegment2.cc"
]



mgl_cc = [
# 'src/mgl/Edge.cc',
'src/mgl/ScadDebugFile.cc',
'src/mgl/abstractable.cc',
'src/mgl/clipper.cc',
'src/mgl/configuration.cc',
# 'src/mgl/connexity.cc',
'src/mgl/gcoder.cc',
'src/mgl/gcoder_gantry.cc',
'src/mgl/grid.cc',
'src/mgl/insets.cc',
'src/mgl/log.cc',
'src/mgl/loop_path_openpath_impl.cc',
'src/mgl/loop_path_loop_impl.cc',
'src/mgl/loop_path_looppath_impl.cc',
'src/mgl/loop_processor.cc',
'src/mgl/meshy.cc',
'src/mgl/mgl.cc',
'src/mgl/miracle.cc',
'src/mgl/pather.cc',
'src/mgl/pather_layerpaths.cc',
'src/mgl/pather_optimizer.cc',
'src/mgl/pather_optimizer_graph.cc',
'src/mgl/regioner.cc',
'src/mgl/segment.cc',
'src/mgl/segmenter.cc',
'src/mgl/shrinky.cc',
'src/mgl/slicer.cc',
'src/mgl/slicer_loops.cc',
'src/mgl/slicy.cc',
'src/mgl/spacial_data.cc',
'src/mgl/loop_utils.cc',
'src/mgl/dump_restore.cc']

# mgl_cc = [
## 'src/mgl/Edge.cc',
# 'src/mgl/ScadDebugFile.cc',
# 'src/mgl/abstractable.cc',
# 'src/mgl/clipper.cc',
# 'src/mgl/configuration.cc',
# 'src/mgl/connexity.cc',
# 'src/mgl/gcoder.cc',
# 'src/mgl/gcoder_gantry.cc',
# 'src/mgl/grid.cc',
# 'src/mgl/insets.cc',
# 'src/mgl/log.cc',
# 'src/mgl/loop_path_openpath_impl.cc',
# 'src/mgl/loop_path_loop_impl.cc',
# 'src/mgl/loop_path_looppath_impl.cc',
# 'src/mgl/loop_processor.cc',
# 'src/mgl/meshy.cc',
# 'src/mgl/mgl.cc',
# 'src/mgl/miracle.cc',
# 'src/mgl/pather.cc',
# 'src/mgl/pather_layerpaths.cc',
# 'src/mgl/pather_optimizer.cc',
# 'src/mgl/pather_optimizer_graph.cc',
# 'src/mgl/regioner.cc',
# 'src/mgl/segment.cc',
# 'src/mgl/segmenter.cc',
# 'src/mgl/shrinky.cc',
# 'src/mgl/slicer.cc',
# 'src/mgl/slicer_loops.cc',
# 'src/mgl/slicy.cc',
# 'src/mgl/spacial_data.cc',
# 'src/mgl/loop_utils.cc',
## libthing objects go here
# 'src/mgl/Scalar.cc',
# 'src/mgl/Vector2.cc',
# 'src/mgl/Vector3.cc',
# 'src/mgl/LineSegment2.cc',
# 'src/mgl/Triangle3.cc']

mgl_cc = Glob('src/mgl/*.cc')

json_cc = [ 'submodule/json-cpp/src/lib_json/json_reader.cpp',
'submodule/json-cpp/src/lib_json/json_value.cpp',
Expand All @@ -263,7 +255,6 @@ toolpathviz_ui = ['submodule/toolpathviz/mainwindow.ui']

JSON_CPP_BASE = 'submodule/json-cpp/include'

env.Library('./bin/lib/thing', libthing_cc, CPPPATH=[LIBTHING_INCLUDE])
env.Library('./bin/lib/mgl', mgl_cc, CPPPATH=['src', default_includes])
env.Library('./bin/lib/_json', json_cc, CPPPATH=[JSON_CPP_BASE,])

Expand All @@ -272,7 +263,7 @@ unit_test = ['src/unit_tests/UnitTestMain.cc',



default_libs.extend(['mgl', '_json', 'thing'])
default_libs.extend(['mgl', '_json'])

#debug_libs = ['cppunit', 'gcov']
debug_libs = ['cppunit']
Expand Down
37 changes: 23 additions & 14 deletions miracle.config
@@ -1,34 +1,40 @@
{
"infillDensity" : 0.18, // unit: ratio to solid
"infillDensity" : 0.1, // unit: ratio to solid
"numberOfShells" : 2, //Number of shells to print
"insetDistanceMultiplier" : 0.95, // unit: layerW // how far apart are insets from each other
"roofLayerCount" : 4, // nb of extra solid layers for roofs
"floorLayerCount" : 4, // nb of extra solid layers for floor
"layerWidthRatio" : 1.6, //Width over height ratio
"preCoarseness" : 0.01, //coarseness before all processing
"coarseness" : 0.05, // moves shorter than this are combined
"directionWeight" : 0.8,
"gridSpacingMultiplier" : 0.85,

"doOutlines" : false,
"doInfills" : true,
"doInsets" : true,

"doGraphOptimization" : true, // do we want to apply our graph optimization?
"directionWeight" : 1.0, // 0.5 - 1.0 are good, 0.0 might cause zigzags
"iterativeEffort" : 999, // max number of iterations to run after graph, sanity check only

//how fast to move when not extruding
"rapidMoveFeedRateXY" : 100, // mm/sec
"rapidMoveFeedRateXY" : 120, // mm/sec
"rapidMoveFeedRateZ" : 23, //mm/sec

"doRaft" : true,
"raftLayers" : 2, // nb of raft layers (optional)
"raftBaseThickness" : 0.6, // thickness of first raft layer
"raftInterfaceThickness" : 0.3, // thickness of other raft layers
"doRaft" : false,
"raftLayers" : 3, // nb of raft layers (optional)
"raftBaseThickness" : 0.5, // thickness of first raft layer
"raftInterfaceThickness" : 0.25, // thickness of other raft layers
"raftOutset" : 6, // distance to outset rafts
"raftModelSpacing" : 0.0, // distance between topmost raft and bottom of model
"raftDensity" : 0.2,
"raftModelSpacing" : 0.1, // distance between topmost raft and bottom of model
"raftDensity" : 0.23,

"doSupport" : false, //whether or not to build support structures
"supportMargin" : 1.5, //distance between sides of object and the beginning of support: mm
"supportDensity" : 0.2,
"supportMargin" : 2.0, //distance between sides of object and the beginning of support: mm
"supportDensity" : 0.095,

"bedZOffset" : 0.0, //Height to start printing the first layer
"layerHeight" : 0.27, //Height of a layer
"layerHeight" : 0.28, //Height of a layer

//assumed starting position after header gcode is done
"startX" : -110.4,
Expand All @@ -39,6 +45,9 @@
"endGcode" : "default://end_replicator_dual.gcode", // gcode to insert at end of output

"doPrintProgress" : true, // display % complete on bot

"doFanCommand" : true,
"fanLayer" : 5,

"defaultExtruder" : 0,

Expand Down Expand Up @@ -75,11 +84,11 @@
},
"firstlayer": {
"temperature" : 220.0, //temperature in C
"feedrate": 30 //mm/sec
"feedrate": 50 //mm/sec
},
"outlines": {
"temperature" : 220.0, //temperature in C
"feedrate": 35 //mm/sec
"feedrate": 50 //mm/sec
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions scons.bat
@@ -0,0 +1,2 @@
call C:\Python27\Scripts\scons.bat %*
exit /B ERRORLEVEL
File renamed without changes.
11 changes: 11 additions & 0 deletions src/mgl/Exception.h
Expand Up @@ -22,9 +22,20 @@ class Exception : public std::exception {
return error.c_str();
}
~Exception() throw() {}
};

class GeometryException : public mgl::Exception {
public:
template <typename T>
GeometryException(const T& arg) : Exception(arg) {}
};

} /*end namespace mgl; */

namespace libthing {

typedef mgl::GeometryException GeometryException;

}

#endif //MGL_EXCEPTION_H_
Expand Up @@ -4,7 +4,7 @@
using namespace mgl;
using namespace Json;
using namespace std;
using namespace libthing;




Expand Down Expand Up @@ -38,7 +38,7 @@ bool JsonConverter::loadVector2FromJson(Vector2& s, Value& input)


bool JsonConverter::loadJsonFromVector3(Value& ,//val,
Vector3&)// input)
Point3Type&)// input)
{
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/mgl/JsonConverter.h
Expand Up @@ -27,8 +27,8 @@ class JsonConverter
public:

bool loadJsonFromScalar(Json::Value& val, Scalar& s);
bool loadJsonFromVector2(Json::Value& val, libthing::Vector2& input);
bool loadJsonFromVector3(Json::Value& val, libthing::Vector3& input);
bool loadJsonFromVector2(Json::Value& val, Point2Type& input);
bool loadJsonFromVector3(Json::Value& val, Point3Type& input);
bool loadJsonFromPolygon(Json::Value& val, Polygon& input);
bool loadJsonFromPolygons(Json::Value& val, Polygons& input);

Expand All @@ -37,7 +37,7 @@ class JsonConverter
bool loadJsonFromSliceData(Json::Value& val, SliceData& input);

bool loadScalarFromJson(Scalar& s, Json::Value& input);
bool loadVector2FromJson(libthing::Vector2& vector,Json::Value& input);
bool loadVector2FromJson(Point2Type& vector,Json::Value& input);
bool loadPolygonFromJson(Polygon& poly,Json::Value& input);
bool loadPolygonsFromJson(Polygons& polys,Json::Value& input);
bool loadPolygonsGroupFromJson(PolygonsGroup& pg, Json::Value& input);
Expand Down
96 changes: 96 additions & 0 deletions src/mgl/LineSegment2.cc
@@ -0,0 +1,96 @@
#include "Vector2.h"
#include "LineSegment2.h"
#include "Exception.h"


namespace libthing {

#ifndef SIGN
#define SIGN(x) ((x)>=0 ? 1 : -1)
#endif

//#include "log.h"

LineSegment2::LineSegment2() {}

LineSegment2::LineSegment2(const LineSegment2& other)
: a(other.a), b(other.b) {}

LineSegment2::LineSegment2(const Vector2 &a, const Vector2 &b)
: a(a), b(b) {}

LineSegment2 & LineSegment2::operator=(const LineSegment2 & other) {
if (this != &other) {
a = other.a;
b = other.b;

}
return *this;
}

Scalar LineSegment2::squaredLength() const {
Vector2 l = b - a;
return l.squaredMagnitude();
}

Scalar LineSegment2::length() const {
Scalar l = squaredLength();
l = sqrt(l);
return l;
}

/**
* @returns a new LineSegment2, elongated to be normalized to a unit vector
*/
LineSegment2 LineSegment2::elongate(const Scalar& dist) const {
LineSegment2 segment(*this);
Vector2 l = segment.b - segment.a;
l.normalise();
l *= dist;
segment.b += l;
return segment;
}

/**
* @returns a new line segment. Of what, I don't know. Wasn't documented.
*/
LineSegment2 LineSegment2::prelongate(const Scalar& dist) const {
LineSegment2 segment(*this);
Vector2 l = segment.a - segment.b;
l.normalise();
l *= dist;
segment.a += l;
return segment;
}

bool LineSegment2::intersects(const LineSegment2& rhs) const {
libthing::Vector2 lhsvec = b - a;
libthing::Vector2 rhsvec = rhs.b - rhs.a;

return SIGN((rhs.b - a).crossProduct(lhsvec)) !=
SIGN((rhs.a - a).crossProduct(lhsvec)) &&
SIGN((b - rhs.a).crossProduct(rhsvec)) !=
SIGN((a - rhs.a).crossProduct(rhsvec));
}

Scalar LineSegment2::testLeft(const Vector2& point) const {
return (b.x - a.x) * (point.y - a.y) - (point.x - a.x) * (b.y - a.y);
}

Scalar LineSegment2::testRight(const Vector2& point) const {
return (a.x - b.x) * (point.y - b.y) - (point.x - b.x) * (a.y - b.y);
}

std::ostream& operator <<(std::ostream &os,
const LineSegment2& /*s*/) {
//os << "[ " << s.a << ", " << s.b << "]";
return os;
}

bool intersects(const LineSegment2& lhs,
const LineSegment2& rhs) {
return lhs.intersects(rhs);
}

}

0 comments on commit c99243b

Please sign in to comment.