Cleanup of some method signatures and of XS return types

This commit is contained in:
Alessandro Ranellucci 2015-01-19 18:53:04 +01:00
parent c9cdae1a96
commit 8791f5a493
39 changed files with 252 additions and 339 deletions

View File

@ -29,7 +29,7 @@ use Slic3r::GUI::Tab;
our $have_OpenGL = eval "use Slic3r::GUI::3DScene; 1"; our $have_OpenGL = eval "use Slic3r::GUI::3DScene; 1";
our $have_LWP = eval "use LWP::UserAgent; 1"; our $have_LWP = eval "use LWP::UserAgent; 1";
$have_OpenGL = 0;
use Wx 0.9901 qw(:bitmap :dialog :icon :id :misc :systemsettings :toplevelwindow use Wx 0.9901 qw(:bitmap :dialog :icon :id :misc :systemsettings :toplevelwindow
:filedialog); :filedialog);
use Wx::Event qw(EVT_IDLE); use Wx::Event qw(EVT_IDLE);

View File

@ -874,8 +874,8 @@ sub schedule_background_process {
if (defined $self->{apply_config_timer}) { if (defined $self->{apply_config_timer}) {
$self->{apply_config_timer}->Start(PROCESS_DELAY, 1); # 1 = one shot $self->{apply_config_timer}->Start(PROCESS_DELAY, 1); # 1 = one shot
$self->{toolpaths2D}->reload_print; $self->{toolpaths2D}->reload_print if $self->{toolpaths2D};
$self->{preview3D}->reload_print; $self->{preview3D}->reload_print if $self->{preview3D};
} }
} }
@ -954,8 +954,8 @@ sub stop_background_process {
$self->statusbar->SetCancelCallback(undef); $self->statusbar->SetCancelCallback(undef);
$self->statusbar->StopBusy; $self->statusbar->StopBusy;
$self->statusbar->SetStatusText(""); $self->statusbar->SetStatusText("");
$self->{toolpaths2D}->reload_print; $self->{toolpaths2D}->reload_print if $self->{toolpaths2D};
$self->{preview3D}->reload_print; $self->{preview3D}->reload_print if $self->{preview3D};
if ($self->{process_thread}) { if ($self->{process_thread}) {
Slic3r::debugf "Killing background process.\n"; Slic3r::debugf "Killing background process.\n";
@ -1079,8 +1079,8 @@ sub on_process_completed {
$self->{process_thread} = undef; $self->{process_thread} = undef;
return if $error; return if $error;
$self->{toolpaths2D}->reload_print; $self->{toolpaths2D}->reload_print if $self->{toolpaths2D};
$self->{preview3D}->reload_print; $self->{preview3D}->reload_print if $self->{preview3D};
# if we have an export filename, start a new thread for exporting G-code # if we have an export filename, start a new thread for exporting G-code
if ($self->{export_gcode_output_file}) { if ($self->{export_gcode_output_file}) {

View File

@ -89,8 +89,7 @@ BridgeDetector::detect_angle()
{ {
Polygons pp = this->expolygon; Polygons pp = this->expolygon;
for (Polygons::const_iterator p = pp.begin(); p != pp.end(); ++p) { for (Polygons::const_iterator p = pp.begin(); p != pp.end(); ++p) {
Lines lines; Lines lines = p->lines();
p->lines(&lines);
for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line) for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line)
angles.push_back(line->direction()); angles.push_back(line->direction());
} }

View File

@ -167,9 +167,11 @@ ExPolygon::medial_axis(double max_width, double min_width, Polylines* polylines)
Slic3r::Geometry::MedialAxis ma(max_width, min_width); Slic3r::Geometry::MedialAxis ma(max_width, min_width);
// populate list of segments for the Voronoi diagram // populate list of segments for the Voronoi diagram
this->contour.lines(&ma.lines); ma.lines = this->contour.lines();
for (Polygons::const_iterator hole = this->holes.begin(); hole != this->holes.end(); ++hole) for (Polygons::const_iterator hole = this->holes.begin(); hole != this->holes.end(); ++hole) {
hole->lines(&ma.lines); Lines lines = hole->lines();
ma.lines.insert(ma.lines.end(), lines.begin(), lines.end());
}
// compute the Voronoi diagram // compute the Voronoi diagram
ma.build(polylines); ma.build(polylines);
@ -384,10 +386,11 @@ ExPolygon::triangulate_p2t(Polygons* polygons) const
Lines Lines
ExPolygon::lines() const ExPolygon::lines() const
{ {
Lines lines; Lines lines = this->contour.lines();
this->contour.lines(&lines); for (Polygons::const_iterator h = this->holes.begin(); h != this->holes.end(); ++h) {
for (Polygons::const_iterator h = this->holes.begin(); h != this->holes.end(); ++h) Lines hole_lines = h->lines();
h->lines(&lines); lines.insert(lines.end(), hole_lines.begin(), hole_lines.end());
}
return lines; return lines;
} }

View File

@ -92,13 +92,13 @@ ExPolygonCollection::simplify(double tolerance)
this->expolygons = expp; this->expolygons = expp;
} }
void Polygon
ExPolygonCollection::convex_hull(Polygon* hull) const ExPolygonCollection::convex_hull() const
{ {
Points pp; Points pp;
for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it) for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it)
pp.insert(pp.end(), it->contour.points.begin(), it->contour.points.end()); pp.insert(pp.end(), it->contour.points.begin(), it->contour.points.end());
Slic3r::Geometry::convex_hull(pp, hull); return Slic3r::Geometry::convex_hull(pp);
} }
Lines Lines

View File

@ -28,7 +28,7 @@ class ExPolygonCollection
template <class T> bool contains(const T &item) const; template <class T> bool contains(const T &item) const;
bool contains_b(const Point &point) const; bool contains_b(const Point &point) const;
void simplify(double tolerance); void simplify(double tolerance);
void convex_hull(Polygon* hull) const; Polygon convex_hull() const;
Lines lines() const; Lines lines() const;
}; };

View File

@ -25,42 +25,45 @@ sort_points (Point a, Point b)
} }
/* This implementation is based on Andrew's monotone chain 2D convex hull algorithm */ /* This implementation is based on Andrew's monotone chain 2D convex hull algorithm */
void Polygon
convex_hull(Points points, Polygon* hull) convex_hull(Points points)
{ {
assert(points.size() >= 3); assert(points.size() >= 3);
// sort input points // sort input points
std::sort(points.begin(), points.end(), sort_points); std::sort(points.begin(), points.end(), sort_points);
int n = points.size(), k = 0; int n = points.size(), k = 0;
hull->points.resize(2*n); Polygon hull;
hull.points.resize(2*n);
// Build lower hull // Build lower hull
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
while (k >= 2 && points[i].ccw(hull->points[k-2], hull->points[k-1]) <= 0) k--; while (k >= 2 && points[i].ccw(hull.points[k-2], hull.points[k-1]) <= 0) k--;
hull->points[k++] = points[i]; hull.points[k++] = points[i];
} }
// Build upper hull // Build upper hull
for (int i = n-2, t = k+1; i >= 0; i--) { for (int i = n-2, t = k+1; i >= 0; i--) {
while (k >= t && points[i].ccw(hull->points[k-2], hull->points[k-1]) <= 0) k--; while (k >= t && points[i].ccw(hull.points[k-2], hull.points[k-1]) <= 0) k--;
hull->points[k++] = points[i]; hull.points[k++] = points[i];
} }
hull->points.resize(k); hull.points.resize(k);
assert( hull->points.front().coincides_with(hull->points.back()) ); assert( hull.points.front().coincides_with(hull.points.back()) );
hull->points.pop_back(); hull.points.pop_back();
return hull;
} }
void Polygon
convex_hull(const Polygons &polygons, Polygon* hull) convex_hull(const Polygons &polygons)
{ {
Points pp; Points pp;
for (Polygons::const_iterator p = polygons.begin(); p != polygons.end(); ++p) { for (Polygons::const_iterator p = polygons.begin(); p != polygons.end(); ++p) {
pp.insert(pp.end(), p->points.begin(), p->points.end()); pp.insert(pp.end(), p->points.begin(), p->points.end());
} }
convex_hull(pp, hull); return convex_hull(pp);
} }
/* accepts an arrayref of points and returns a list of indices /* accepts an arrayref of points and returns a list of indices

View File

@ -11,8 +11,8 @@ using boost::polygon::voronoi_diagram;
namespace Slic3r { namespace Geometry { namespace Slic3r { namespace Geometry {
void convex_hull(Points points, Polygon* hull); Polygon convex_hull(Points points);
void convex_hull(const Polygons &polygons, Polygon* hull); Polygon convex_hull(const Polygons &polygons);
void chained_path(const Points &points, std::vector<Points::size_type> &retval, Point start_near); void chained_path(const Points &points, std::vector<Points::size_type> &retval, Point start_near);
void chained_path(const Points &points, std::vector<Points::size_type> &retval); void chained_path(const Points &points, std::vector<Points::size_type> &retval);
template<class T> void chained_path_items(Points &points, T &items, T &retval); template<class T> void chained_path_items(Points &points, T &items, T &retval);

View File

@ -64,10 +64,10 @@ Line::length() const
return this->a.distance_to(this->b); return this->a.distance_to(this->b);
} }
Point* Point
Line::midpoint() const Line::midpoint() const
{ {
return new Point ((this->a.x + this->b.x) / 2.0, (this->a.y + this->b.y) / 2.0); return Point((this->a.x + this->b.x) / 2.0, (this->a.y + this->b.y) / 2.0);
} }
void void

View File

@ -26,7 +26,7 @@ class Line
void rotate(double angle, const Point &center); void rotate(double angle, const Point &center);
void reverse(); void reverse();
double length() const; double length() const;
Point* midpoint() const; Point midpoint() const;
void point_at(double distance, Point* point) const; void point_at(double distance, Point* point) const;
Point point_at(double distance) const; Point point_at(double distance) const;
bool intersection_infinite(const Line &other, Point* point) const; bool intersection_infinite(const Line &other, Point* point) const;

View File

@ -130,8 +130,7 @@ Model::duplicate_objects_grid(unsigned int x, unsigned int y, coordf_t distance)
ModelObject* object = this->objects.front(); ModelObject* object = this->objects.front();
object->clear_instances(); object->clear_instances();
BoundingBoxf3 bb; BoundingBoxf3 bb = object->bounding_box();
object->bounding_box(&bb);
Sizef3 size = bb.size(); Sizef3 size = bb.size();
for (unsigned int x_copy = 1; x_copy <= x; ++x_copy) { for (unsigned int x_copy = 1; x_copy <= x; ++x_copy) {
@ -174,21 +173,20 @@ Model::add_default_instances()
} }
// this returns the bounding box of the *transformed* instances // this returns the bounding box of the *transformed* instances
void BoundingBoxf3
Model::bounding_box(BoundingBoxf3* bb) Model::bounding_box() const
{ {
BoundingBoxf3 bb;
for (ModelObjectPtrs::const_iterator o = this->objects.begin(); o != this->objects.end(); ++o) { for (ModelObjectPtrs::const_iterator o = this->objects.begin(); o != this->objects.end(); ++o) {
BoundingBoxf3 obb; bb.merge((*o)->bounding_box());
(*o)->bounding_box(&obb);
bb->merge(obb);
} }
return bb;
} }
void void
Model::center_instances_around_point(const Pointf &point) Model::center_instances_around_point(const Pointf &point)
{ {
BoundingBoxf3 bb; BoundingBoxf3 bb = this->bounding_box();
this->bounding_box(&bb);
Sizef3 size = bb.size(); Sizef3 size = bb.size();
double shift_x = -bb.min.x + point.x - size.x/2; double shift_x = -bb.min.x + point.x - size.x/2;
@ -205,8 +203,7 @@ Model::center_instances_around_point(const Pointf &point)
void void
Model::align_instances_to_origin() Model::align_instances_to_origin()
{ {
BoundingBoxf3 bb; BoundingBoxf3 bb = this->bounding_box();
this->bounding_box(&bb);
Pointf new_center = (Pointf)bb.size(); Pointf new_center = (Pointf)bb.size();
new_center.translate(-new_center.x/2, -new_center.y/2); new_center.translate(-new_center.x/2, -new_center.y/2);
@ -222,25 +219,25 @@ Model::translate(coordf_t x, coordf_t y, coordf_t z)
} }
// flattens everything to a single mesh // flattens everything to a single mesh
void TriangleMesh
Model::mesh(TriangleMesh* mesh) const Model::mesh() const
{ {
TriangleMesh mesh;
for (ModelObjectPtrs::const_iterator o = this->objects.begin(); o != this->objects.end(); ++o) { for (ModelObjectPtrs::const_iterator o = this->objects.begin(); o != this->objects.end(); ++o) {
TriangleMesh omesh; mesh.merge((*o)->mesh());
(*o)->mesh(&omesh);
mesh->merge(omesh);
} }
return mesh;
} }
// flattens everything to a single mesh // flattens everything to a single mesh
void TriangleMesh
Model::raw_mesh(TriangleMesh* mesh) const Model::raw_mesh() const
{ {
TriangleMesh mesh;
for (ModelObjectPtrs::const_iterator o = this->objects.begin(); o != this->objects.end(); ++o) { for (ModelObjectPtrs::const_iterator o = this->objects.begin(); o != this->objects.end(); ++o) {
TriangleMesh omesh; mesh.merge((*o)->raw_mesh());
(*o)->raw_mesh(&omesh);
mesh->merge(omesh);
} }
return mesh;
} }
#ifdef SLIC3RXS #ifdef SLIC3RXS
@ -393,11 +390,11 @@ ModelObject::clear_instances()
} }
// this returns the bounding box of the *transformed* instances // this returns the bounding box of the *transformed* instances
void BoundingBoxf3
ModelObject::bounding_box(BoundingBoxf3* bb) ModelObject::bounding_box()
{ {
if (!this->_bounding_box_valid) this->update_bounding_box(); if (!this->_bounding_box_valid) this->update_bounding_box();
*bb = this->_bounding_box; return this->_bounding_box;
} }
void void
@ -409,40 +406,40 @@ ModelObject::invalidate_bounding_box()
void void
ModelObject::update_bounding_box() ModelObject::update_bounding_box()
{ {
TriangleMesh mesh; this->_bounding_box = this->mesh().bounding_box();
this->mesh(&mesh);
mesh.bounding_box(&this->_bounding_box);
this->_bounding_box_valid = true; this->_bounding_box_valid = true;
} }
// flattens all volumes and instances into a single mesh // flattens all volumes and instances into a single mesh
void TriangleMesh
ModelObject::mesh(TriangleMesh* mesh) const ModelObject::mesh() const
{ {
TriangleMesh raw_mesh; TriangleMesh mesh;
this->raw_mesh(&raw_mesh); TriangleMesh raw_mesh = this->raw_mesh();
for (ModelInstancePtrs::const_iterator i = this->instances.begin(); i != this->instances.end(); ++i) { for (ModelInstancePtrs::const_iterator i = this->instances.begin(); i != this->instances.end(); ++i) {
TriangleMesh m = raw_mesh; TriangleMesh m = raw_mesh;
(*i)->transform_mesh(&m); (*i)->transform_mesh(&m);
mesh->merge(m); mesh.merge(m);
} }
return mesh;
} }
void TriangleMesh
ModelObject::raw_mesh(TriangleMesh* mesh) const ModelObject::raw_mesh() const
{ {
TriangleMesh mesh;
for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) { for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) {
if ((*v)->modifier) continue; if ((*v)->modifier) continue;
mesh->merge((*v)->mesh); mesh.merge((*v)->mesh);
} }
return mesh;
} }
void BoundingBoxf3
ModelObject::raw_bounding_box(BoundingBoxf3* bb) const ModelObject::raw_bounding_box() const
{ {
BoundingBoxf3 bb;
for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) { for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) {
if ((*v)->modifier) continue; if ((*v)->modifier) continue;
TriangleMesh mesh = (*v)->mesh; TriangleMesh mesh = (*v)->mesh;
@ -450,22 +447,18 @@ ModelObject::raw_bounding_box(BoundingBoxf3* bb) const
if (this->instances.empty()) CONFESS("Can't call raw_bounding_box() with no instances"); if (this->instances.empty()) CONFESS("Can't call raw_bounding_box() with no instances");
this->instances.front()->transform_mesh(&mesh, true); this->instances.front()->transform_mesh(&mesh, true);
BoundingBoxf3 mbb; bb.merge(mesh.bounding_box());
mesh.bounding_box(&mbb);
bb->merge(mbb);
} }
return bb;
} }
// this returns the bounding box of the *transformed* given instance // this returns the bounding box of the *transformed* given instance
void BoundingBoxf3
ModelObject::instance_bounding_box(size_t instance_idx, BoundingBoxf3* bb) const ModelObject::instance_bounding_box(size_t instance_idx) const
{ {
TriangleMesh mesh; TriangleMesh mesh = this->raw_mesh();
this->raw_mesh(&mesh);
this->instances[instance_idx]->transform_mesh(&mesh); this->instances[instance_idx]->transform_mesh(&mesh);
return mesh.bounding_box();
mesh.bounding_box(bb);
} }
void void
@ -473,12 +466,7 @@ ModelObject::center_around_origin()
{ {
// calculate the displacements needed to // calculate the displacements needed to
// center this object around the origin // center this object around the origin
BoundingBoxf3 bb; BoundingBoxf3 bb = this->raw_mesh().bounding_box();
{
TriangleMesh mesh;
this->raw_mesh(&mesh);
mesh.bounding_box(&bb);
}
// first align to origin on XYZ // first align to origin on XYZ
Vectorf3 vector(-bb.min.x, -bb.min.y, -bb.min.z); Vectorf3 vector(-bb.min.x, -bb.min.y, -bb.min.z);

View File

@ -54,12 +54,12 @@ class Model
// void duplicate(size_t copies_num, coordf_t distance, const BoundingBox &bb); // void duplicate(size_t copies_num, coordf_t distance, const BoundingBox &bb);
bool has_objects_with_no_instances() const; bool has_objects_with_no_instances() const;
bool add_default_instances(); bool add_default_instances();
void bounding_box(BoundingBoxf3* bb); BoundingBoxf3 bounding_box() const;
void center_instances_around_point(const Pointf &point); void center_instances_around_point(const Pointf &point);
void align_instances_to_origin(); void align_instances_to_origin();
void translate(coordf_t x, coordf_t y, coordf_t z); void translate(coordf_t x, coordf_t y, coordf_t z);
void mesh(TriangleMesh* mesh) const; TriangleMesh mesh() const;
void raw_mesh(TriangleMesh* mesh) const; TriangleMesh raw_mesh() const;
// std::string get_material_name(t_model_material_id material_id); // std::string get_material_name(t_model_material_id material_id);
@ -118,13 +118,13 @@ class ModelObject
void delete_last_instance(); void delete_last_instance();
void clear_instances(); void clear_instances();
void bounding_box(BoundingBoxf3* bb); BoundingBoxf3 bounding_box();
void invalidate_bounding_box(); void invalidate_bounding_box();
void mesh(TriangleMesh* mesh) const; TriangleMesh mesh() const;
void raw_mesh(TriangleMesh* mesh) const; TriangleMesh raw_mesh() const;
void raw_bounding_box(BoundingBoxf3* bb) const; BoundingBoxf3 raw_bounding_box() const;
void instance_bounding_box(size_t instance_idx, BoundingBoxf3* bb) const; BoundingBoxf3 instance_bounding_box(size_t instance_idx) const;
void center_around_origin(); void center_around_origin();
void translate(const Vectorf3 &vector); void translate(const Vectorf3 &vector);
void translate(coordf_t x, coordf_t y, coordf_t z); void translate(coordf_t x, coordf_t y, coordf_t z);

View File

@ -82,17 +82,18 @@ MotionPlanner::get_env(size_t island_idx) const
} }
} }
void Polyline
MotionPlanner::shortest_path(const Point &from, const Point &to, Polyline* polyline) MotionPlanner::shortest_path(const Point &from, const Point &to)
{ {
// lazy generation of configuration space // lazy generation of configuration space
if (!this->initialized) this->initialize(); if (!this->initialized) this->initialize();
// if we have an empty configuration space, return a straight move // if we have an empty configuration space, return a straight move
if (this->islands.empty()) { if (this->islands.empty()) {
polyline->points.push_back(from); Polyline p;
polyline->points.push_back(to); p.points.push_back(from);
return; p.points.push_back(to);
return p;
} }
// Are both points in the same island? // Are both points in the same island?
@ -102,9 +103,10 @@ MotionPlanner::shortest_path(const Point &from, const Point &to, Polyline* polyl
// since both points are in the same island, is a direct move possible? // since both points are in the same island, is a direct move possible?
// if so, we avoid generating the visibility environment // if so, we avoid generating the visibility environment
if (island->contains(Line(from, to))) { if (island->contains(Line(from, to))) {
polyline->points.push_back(from); Polyline p;
polyline->points.push_back(to); p.points.push_back(from);
return; p.points.push_back(to);
return p;
} }
island_idx = island - this->islands.begin(); island_idx = island - this->islands.begin();
break; break;
@ -116,9 +118,10 @@ MotionPlanner::shortest_path(const Point &from, const Point &to, Polyline* polyl
if (env.expolygons.empty()) { if (env.expolygons.empty()) {
// if this environment is empty (probably because it's too small), perform straight move // if this environment is empty (probably because it's too small), perform straight move
// and avoid running the algorithms on empty dataset // and avoid running the algorithms on empty dataset
polyline->points.push_back(from); Polyline p;
polyline->points.push_back(to); p.points.push_back(from);
return; // bye bye p.points.push_back(to);
return p; // bye bye
} }
// Now check whether points are inside the environment. // Now check whether points are inside the environment.
@ -137,10 +140,10 @@ MotionPlanner::shortest_path(const Point &from, const Point &to, Polyline* polyl
// perform actual path search // perform actual path search
MotionPlannerGraph* graph = this->init_graph(island_idx); MotionPlannerGraph* graph = this->init_graph(island_idx);
graph->shortest_path(graph->find_node(inner_from), graph->find_node(inner_to), polyline); Polyline polyline = graph->shortest_path(graph->find_node(inner_from), graph->find_node(inner_to));
polyline->points.insert(polyline->points.begin(), from); polyline.points.insert(polyline.points.begin(), from);
polyline->points.push_back(to); polyline.points.push_back(to);
{ {
// grow our environment slightly in order for simplify_by_visibility() // grow our environment slightly in order for simplify_by_visibility()
@ -149,7 +152,7 @@ MotionPlanner::shortest_path(const Point &from, const Point &to, Polyline* polyl
offset(env, &grown_env.expolygons, +SCALED_EPSILON); offset(env, &grown_env.expolygons, +SCALED_EPSILON);
// remove unnecessary vertices // remove unnecessary vertices
polyline->simplify_by_visibility(grown_env); polyline.simplify_by_visibility(grown_env);
} }
/* /*
@ -171,6 +174,8 @@ MotionPlanner::shortest_path(const Point &from, const Point &to, Polyline* polyl
svg.draw(*polyline, "red"); svg.draw(*polyline, "red");
svg.Close(); svg.Close();
*/ */
return polyline;
} }
Point Point
@ -310,11 +315,11 @@ MotionPlannerGraph::find_node(const Point &point) const
return point.nearest_point_index(this->nodes); return point.nearest_point_index(this->nodes);
} }
void Polyline
MotionPlannerGraph::shortest_path(size_t from, size_t to, Polyline* polyline) MotionPlannerGraph::shortest_path(size_t from, size_t to)
{ {
// this prevents a crash in case for some reason we got here with an empty adjacency list // this prevents a crash in case for some reason we got here with an empty adjacency list
if (this->adjacency_list.empty()) return; if (this->adjacency_list.empty()) return Polyline();
const weight_t max_weight = std::numeric_limits<weight_t>::infinity(); const weight_t max_weight = std::numeric_limits<weight_t>::infinity();
@ -379,10 +384,12 @@ MotionPlannerGraph::shortest_path(size_t from, size_t to, Polyline* polyline)
} }
} }
Polyline polyline;
for (node_t vertex = to; vertex != -1; vertex = previous[vertex]) for (node_t vertex = to; vertex != -1; vertex = previous[vertex])
polyline->points.push_back(this->nodes[vertex]); polyline.points.push_back(this->nodes[vertex]);
polyline->points.push_back(this->nodes[from]); polyline.points.push_back(this->nodes[from]);
polyline->reverse(); polyline.reverse();
return polyline;
} }
#ifdef SLIC3RXS #ifdef SLIC3RXS

View File

@ -21,7 +21,7 @@ class MotionPlanner
public: public:
MotionPlanner(const ExPolygons &islands); MotionPlanner(const ExPolygons &islands);
~MotionPlanner(); ~MotionPlanner();
void shortest_path(const Point &from, const Point &to, Polyline* polyline); Polyline shortest_path(const Point &from, const Point &to);
size_t islands_count() const; size_t islands_count() const;
private: private:
@ -58,7 +58,7 @@ class MotionPlannerGraph
//std::map<std::pair<size_t,size_t>, double> edges; //std::map<std::pair<size_t,size_t>, double> edges;
void add_edge(size_t from, size_t to, double weight); void add_edge(size_t from, size_t to, double weight);
size_t find_node(const Point &point) const; size_t find_node(const Point &point) const;
void shortest_path(size_t from, size_t to, Polyline* polyline); Polyline shortest_path(size_t from, size_t to);
}; };
} }

View File

@ -83,10 +83,10 @@ MultiPoint::has_boundary_point(const Point &point) const
return dist < SCALED_EPSILON; return dist < SCALED_EPSILON;
} }
void BoundingBox
MultiPoint::bounding_box(BoundingBox* bb) const MultiPoint::bounding_box() const
{ {
*bb = BoundingBox(this->points); return BoundingBox(this->points);
} }
Points Points

View File

@ -31,7 +31,7 @@ class MultiPoint
bool is_valid() const; bool is_valid() const;
int find_point(const Point &point) const; int find_point(const Point &point) const;
bool has_boundary_point(const Point &point) const; bool has_boundary_point(const Point &point) const;
void bounding_box(BoundingBox* bb) const; BoundingBox bounding_box() const;
static Points _douglas_peucker(const Points &points, const double tolerance); static Points _douglas_peucker(const Points &points, const double tolerance);

View File

@ -14,9 +14,7 @@ Polygon::operator Polygons() const
Polygon::operator Polyline() const Polygon::operator Polyline() const
{ {
Polyline polyline; return this->split_at_first_point();
this->split_at_first_point(&polyline);
return polyline;
} }
Point& Point&
@ -41,55 +39,49 @@ Lines
Polygon::lines() const Polygon::lines() const
{ {
Lines lines; Lines lines;
this->lines(&lines); lines.reserve(this->points.size());
for (Points::const_iterator it = this->points.begin(); it != this->points.end()-1; ++it) {
lines.push_back(Line(*it, *(it + 1)));
}
lines.push_back(Line(this->points.back(), this->points.front()));
return lines; return lines;
} }
void Polyline
Polygon::lines(Lines* lines) const Polygon::split_at_vertex(const Point &point) const
{
lines->reserve(lines->size() + this->points.size());
for (Points::const_iterator it = this->points.begin(); it != this->points.end()-1; ++it) {
lines->push_back(Line(*it, *(it + 1)));
}
lines->push_back(Line(this->points.back(), this->points.front()));
}
void
Polygon::split_at_vertex(const Point &point, Polyline* polyline) const
{ {
// find index of point // find index of point
for (Points::const_iterator it = this->points.begin(); it != this->points.end(); ++it) { for (Points::const_iterator it = this->points.begin(); it != this->points.end(); ++it) {
if (it->coincides_with(point)) { if (it->coincides_with(point)) {
this->split_at_index(it - this->points.begin(), polyline); return this->split_at_index(it - this->points.begin());
return;
} }
} }
CONFESS("Point not found"); CONFESS("Point not found");
return Polyline();
} }
void Polyline
Polygon::split_at_index(int index, Polyline* polyline) const Polygon::split_at_index(int index) const
{
polyline->points.reserve(this->points.size() + 1);
for (Points::const_iterator it = this->points.begin() + index; it != this->points.end(); ++it)
polyline->points.push_back(*it);
for (Points::const_iterator it = this->points.begin(); it != this->points.begin() + index + 1; ++it)
polyline->points.push_back(*it);
}
void
Polygon::split_at_first_point(Polyline* polyline) const
{
this->split_at_index(0, polyline);
}
void
Polygon::equally_spaced_points(double distance, Points* points) const
{ {
Polyline polyline; Polyline polyline;
this->split_at_first_point(&polyline); polyline.points.reserve(this->points.size() + 1);
polyline.equally_spaced_points(distance, points); for (Points::const_iterator it = this->points.begin() + index; it != this->points.end(); ++it)
polyline.points.push_back(*it);
for (Points::const_iterator it = this->points.begin(); it != this->points.begin() + index + 1; ++it)
polyline.points.push_back(*it);
return polyline;
}
Polyline
Polygon::split_at_first_point() const
{
return this->split_at_index(0);
}
Points
Polygon::equally_spaced_points(double distance) const
{
return this->split_at_first_point().equally_spaced_points(distance);
} }
double double
@ -203,8 +195,7 @@ Polygon::centroid() const
double x_temp = 0; double x_temp = 0;
double y_temp = 0; double y_temp = 0;
Polyline polyline; Polyline polyline = this->split_at_first_point();
this->split_at_first_point(&polyline);
for (Points::const_iterator point = polyline.points.begin(); point != polyline.points.end() - 1; ++point) { for (Points::const_iterator point = polyline.points.begin(); point != polyline.points.end() - 1; ++point) {
x_temp += (double)( point->x + (point+1)->x ) * ( (double)point->x*(point+1)->y - (double)(point+1)->x*point->y ); x_temp += (double)( point->x + (point+1)->x ) * ( (double)point->x*(point+1)->y - (double)(point+1)->x*point->y );
y_temp += (double)( point->y + (point+1)->y ) * ( (double)point->x*(point+1)->y - (double)(point+1)->x*point->y ); y_temp += (double)( point->y + (point+1)->y ) * ( (double)point->x*(point+1)->y - (double)(point+1)->x*point->y );
@ -227,55 +218,49 @@ Polygon::wkt() const
} }
// find all concave vertices (i.e. having an internal angle greater than the supplied angle) */ // find all concave vertices (i.e. having an internal angle greater than the supplied angle) */
void Points
Polygon::concave_points(double angle, Points* points) const Polygon::concave_points(double angle) const
{ {
Points points;
angle = 2*PI - angle; angle = 2*PI - angle;
// check whether first point forms a concave angle // check whether first point forms a concave angle
if (this->points.front().ccw_angle(this->points.back(), *(this->points.begin()+1)) <= angle) if (this->points.front().ccw_angle(this->points.back(), *(this->points.begin()+1)) <= angle)
points->push_back(this->points.front()); points.push_back(this->points.front());
// check whether points 1..(n-1) form concave angles // check whether points 1..(n-1) form concave angles
for (Points::const_iterator p = this->points.begin()+1; p != this->points.end()-1; ++p) { for (Points::const_iterator p = this->points.begin()+1; p != this->points.end()-1; ++p) {
if (p->ccw_angle(*(p-1), *(p+1)) <= angle) points->push_back(*p); if (p->ccw_angle(*(p-1), *(p+1)) <= angle) points.push_back(*p);
} }
// check whether last point forms a concave angle // check whether last point forms a concave angle
if (this->points.back().ccw_angle(*(this->points.end()-2), this->points.front()) <= angle) if (this->points.back().ccw_angle(*(this->points.end()-2), this->points.front()) <= angle)
points->push_back(this->points.back()); points.push_back(this->points.back());
}
void return points;
Polygon::concave_points(Points* points) const
{
this->concave_points(PI, points);
} }
// find all convex vertices (i.e. having an internal angle smaller than the supplied angle) */ // find all convex vertices (i.e. having an internal angle smaller than the supplied angle) */
void Points
Polygon::convex_points(double angle, Points* points) const Polygon::convex_points(double angle) const
{ {
Points points;
angle = 2*PI - angle; angle = 2*PI - angle;
// check whether first point forms a convex angle // check whether first point forms a convex angle
if (this->points.front().ccw_angle(this->points.back(), *(this->points.begin()+1)) >= angle) if (this->points.front().ccw_angle(this->points.back(), *(this->points.begin()+1)) >= angle)
points->push_back(this->points.front()); points.push_back(this->points.front());
// check whether points 1..(n-1) form convex angles // check whether points 1..(n-1) form convex angles
for (Points::const_iterator p = this->points.begin()+1; p != this->points.end()-1; ++p) { for (Points::const_iterator p = this->points.begin()+1; p != this->points.end()-1; ++p) {
if (p->ccw_angle(*(p-1), *(p+1)) >= angle) points->push_back(*p); if (p->ccw_angle(*(p-1), *(p+1)) >= angle) points.push_back(*p);
} }
// check whether last point forms a convex angle // check whether last point forms a convex angle
if (this->points.back().ccw_angle(*(this->points.end()-2), this->points.front()) >= angle) if (this->points.back().ccw_angle(*(this->points.end()-2), this->points.front()) >= angle)
points->push_back(this->points.back()); points.push_back(this->points.back());
}
void return points;
Polygon::convex_points(Points* points) const
{
this->convex_points(PI, points);
} }
#ifdef SLIC3RXS #ifdef SLIC3RXS

View File

@ -24,11 +24,10 @@ class Polygon : public MultiPoint {
explicit Polygon(const Points &points): MultiPoint(points) {}; explicit Polygon(const Points &points): MultiPoint(points) {};
Point last_point() const; Point last_point() const;
Lines lines() const; Lines lines() const;
void lines(Lines* lines) const; Polyline split_at_vertex(const Point &point) const;
void split_at_vertex(const Point &point, Polyline* polyline) const; Polyline split_at_index(int index) const;
void split_at_index(int index, Polyline* polyline) const; Polyline split_at_first_point() const;
void split_at_first_point(Polyline* polyline) const; Points equally_spaced_points(double distance) const;
void equally_spaced_points(double distance, Points* points) const;
double area() const; double area() const;
bool is_counter_clockwise() const; bool is_counter_clockwise() const;
bool is_clockwise() const; bool is_clockwise() const;
@ -41,10 +40,8 @@ class Polygon : public MultiPoint {
void triangulate_convex(Polygons* polygons) const; void triangulate_convex(Polygons* polygons) const;
Point centroid() const; Point centroid() const;
std::string wkt() const; std::string wkt() const;
void concave_points(double angle, Points* points) const; Points concave_points(double angle = PI) const;
void concave_points(Points* points) const; Points convex_points(double angle = PI) const;
void convex_points(double angle, Points* points) const;
void convex_points(Points* points) const;
#ifdef SLIC3RXS #ifdef SLIC3RXS
void from_SV_check(SV* poly_sv); void from_SV_check(SV* poly_sv);

View File

@ -98,10 +98,11 @@ Polyline::extend_start(double distance)
/* this method returns a collection of points picked on the polygon contour /* this method returns a collection of points picked on the polygon contour
so that they are evenly spaced according to the input distance */ so that they are evenly spaced according to the input distance */
void Points
Polyline::equally_spaced_points(double distance, Points* points) const Polyline::equally_spaced_points(double distance) const
{ {
points->push_back(this->first_point()); Points points;
points.push_back(this->first_point());
double len = 0; double len = 0;
for (Points::const_iterator it = this->points.begin() + 1; it != this->points.end(); ++it) { for (Points::const_iterator it = this->points.begin() + 1; it != this->points.end(); ++it) {
@ -110,17 +111,18 @@ Polyline::equally_spaced_points(double distance, Points* points) const
if (len < distance) continue; if (len < distance) continue;
if (len == distance) { if (len == distance) {
points->push_back(*it); points.push_back(*it);
len = 0; len = 0;
continue; continue;
} }
double take = segment_length - (len - distance); // how much we take of this segment double take = segment_length - (len - distance); // how much we take of this segment
Line segment(*(it-1), *it); Line segment(*(it-1), *it);
points->push_back(segment.point_at(take)); points.push_back(segment.point_at(take));
it--; it--;
len = -take; len = -take;
} }
return points;
} }
void void

View File

@ -22,7 +22,7 @@ class Polyline : public MultiPoint {
void clip_start(double distance); void clip_start(double distance);
void extend_end(double distance); void extend_end(double distance);
void extend_start(double distance); void extend_start(double distance);
void equally_spaced_points(double distance, Points* points) const; Points equally_spaced_points(double distance) const;
void simplify(double tolerance); void simplify(double tolerance);
template <class T> void simplify_by_visibility(const T &area); template <class T> void simplify_by_visibility(const T &area);
void split_at(const Point &point, Polyline* p1, Polyline* p2) const; void split_at(const Point &point, Polyline* p1, Polyline* p2) const;

View File

@ -358,8 +358,7 @@ Print::add_model_object(ModelObject* model_object, int idx)
// initialize print object and store it at the given position // initialize print object and store it at the given position
PrintObject* o; PrintObject* o;
{ {
BoundingBoxf3 bb; BoundingBoxf3 bb = model_object->raw_bounding_box();
model_object->raw_bounding_box(&bb);
if (idx != -1) { if (idx != -1) {
// replacing existing object // replacing existing object
PrintObjectPtrs::iterator old_it = this->objects.begin() + idx; PrintObjectPtrs::iterator old_it = this->objects.begin() + idx;
@ -569,14 +568,13 @@ Print::validate() const
Polygons mesh_convex_hulls; Polygons mesh_convex_hulls;
for (size_t i = 0; i < this->regions.size(); ++i) { for (size_t i = 0; i < this->regions.size(); ++i) {
for (std::vector<int>::const_iterator it = object->region_volumes[i].begin(); it != object->region_volumes[i].end(); ++it) { for (std::vector<int>::const_iterator it = object->region_volumes[i].begin(); it != object->region_volumes[i].end(); ++it) {
Polygon hull; Polygon hull = object->model_object()->volumes[*it]->mesh.convex_hull();
object->model_object()->volumes[*it]->mesh.convex_hull(&hull);
mesh_convex_hulls.push_back(hull); mesh_convex_hulls.push_back(hull);
} }
} }
// make a single convex hull for all of them // make a single convex hull for all of them
Slic3r::Geometry::convex_hull(mesh_convex_hulls, &convex_hull); convex_hull = Slic3r::Geometry::convex_hull(mesh_convex_hulls);
} }
// apply the same transformations we apply to the actual meshes when slicing them // apply the same transformations we apply to the actual meshes when slicing them

View File

@ -111,7 +111,7 @@ class PrintObject
bool delete_all_copies(); bool delete_all_copies();
bool set_copies(const Points &points); bool set_copies(const Points &points);
bool reload_model_instances(); bool reload_model_instances();
void bounding_box(BoundingBox* bb) const; BoundingBox bounding_box() const;
// adds region_id, too, if necessary // adds region_id, too, if necessary
void add_region_volume(int region_id, int volume_id); void add_region_volume(int region_id, int volume_id);

View File

@ -110,14 +110,14 @@ PrintObject::reload_model_instances()
return this->set_copies(copies); return this->set_copies(copies);
} }
void BoundingBox
PrintObject::bounding_box(BoundingBox* bb) const PrintObject::bounding_box() const
{ {
// since the object is aligned to origin, bounding box coincides with size // since the object is aligned to origin, bounding box coincides with size
Points pp; Points pp;
pp.push_back(Point(0,0)); pp.push_back(Point(0,0));
pp.push_back(this->size); pp.push_back(this->size);
*bb = BoundingBox(pp); return BoundingBox(pp);
} }
void void

View File

@ -319,8 +319,8 @@ TriangleMesh::merge(const TriangleMesh &mesh)
} }
/* this will return scaled ExPolygons */ /* this will return scaled ExPolygons */
void ExPolygons
TriangleMesh::horizontal_projection(ExPolygons &retval) const TriangleMesh::horizontal_projection() const
{ {
Polygons pp; Polygons pp;
pp.reserve(this->stl.stats.number_of_facets); pp.reserve(this->stl.stats.number_of_facets);
@ -337,11 +337,13 @@ TriangleMesh::horizontal_projection(ExPolygons &retval) const
// the offset factor was tuned using groovemount.stl // the offset factor was tuned using groovemount.stl
offset(pp, &pp, 0.01 / SCALING_FACTOR); offset(pp, &pp, 0.01 / SCALING_FACTOR);
ExPolygons retval;
union_(pp, &retval, true); union_(pp, &retval, true);
return retval;
} }
void Polygon
TriangleMesh::convex_hull(Polygon* hull) TriangleMesh::convex_hull()
{ {
this->require_shared_vertices(); this->require_shared_vertices();
Points pp; Points pp;
@ -350,25 +352,19 @@ TriangleMesh::convex_hull(Polygon* hull)
stl_vertex* v = &this->stl.v_shared[i]; stl_vertex* v = &this->stl.v_shared[i];
pp.push_back(Point(v->x / SCALING_FACTOR, v->y / SCALING_FACTOR)); pp.push_back(Point(v->x / SCALING_FACTOR, v->y / SCALING_FACTOR));
} }
Slic3r::Geometry::convex_hull(pp, hull); return Slic3r::Geometry::convex_hull(pp);
}
void
TriangleMesh::bounding_box(BoundingBoxf3* bb) const
{
bb->min.x = this->stl.stats.min.x;
bb->min.y = this->stl.stats.min.y;
bb->min.z = this->stl.stats.min.z;
bb->max.x = this->stl.stats.max.x;
bb->max.y = this->stl.stats.max.y;
bb->max.z = this->stl.stats.max.z;
} }
BoundingBoxf3 BoundingBoxf3
TriangleMesh::bounding_box() const TriangleMesh::bounding_box() const
{ {
BoundingBoxf3 bb; BoundingBoxf3 bb;
this->bounding_box(&bb); bb.min.x = this->stl.stats.min.x;
bb.min.y = this->stl.stats.min.y;
bb.min.z = this->stl.stats.min.z;
bb.max.x = this->stl.stats.max.x;
bb.max.y = this->stl.stats.max.y;
bb.max.z = this->stl.stats.max.z;
return bb; return bb;
} }

View File

@ -42,9 +42,8 @@ class TriangleMesh
void rotate(double angle, Point* center); void rotate(double angle, Point* center);
TriangleMeshPtrs split() const; TriangleMeshPtrs split() const;
void merge(const TriangleMesh &mesh); void merge(const TriangleMesh &mesh);
void horizontal_projection(ExPolygons &retval) const; ExPolygons horizontal_projection() const;
void convex_hull(Polygon* hull); Polygon convex_hull();
void bounding_box(BoundingBoxf3* bb) const;
BoundingBoxf3 bounding_box() const; BoundingBoxf3 bounding_box() const;
void reset_repair_stats(); void reset_repair_stats();
bool needed_repair() const; bool needed_repair() const;

View File

@ -16,8 +16,7 @@
void scale(double factor); void scale(double factor);
void translate(double x, double y); void translate(double x, double y);
void offset(double delta); void offset(double delta);
Polygon* polygon() Clone<Polygon> polygon();
%code{% RETVAL = new Polygon(); THIS->polygon(RETVAL); %};
Clone<Point> size(); Clone<Point> size();
Clone<Point> center(); Clone<Point> center();
Clone<Point> min_point() %code{% RETVAL = THIS->min; %}; Clone<Point> min_point() %code{% RETVAL = THIS->min; %};

View File

@ -26,6 +26,7 @@
void simplify(double tolerance); void simplify(double tolerance);
Polygons polygons() Polygons polygons()
%code{% RETVAL = *THIS; %}; %code{% RETVAL = *THIS; %};
Clone<Polygon> convex_hull();
%{ %{
ExPolygonCollection* ExPolygonCollection*
@ -76,13 +77,5 @@ ExPolygonCollection::append(...)
THIS->expolygons.push_back(expolygon); THIS->expolygons.push_back(expolygon);
} }
Polygon*
ExPolygonCollection::convex_hull()
CODE:
RETVAL = new Polygon ();
THIS->convex_hull(RETVAL);
OUTPUT:
RETVAL
%} %}
}; };

View File

@ -15,8 +15,8 @@
bool make_counter_clockwise(); bool make_counter_clockwise();
Clone<Point> first_point(); Clone<Point> first_point();
Clone<Point> last_point(); Clone<Point> last_point();
Polygon* polygon() Clone<Polygon> polygon()
%code{% RETVAL = new Polygon (*THIS); %}; %code{% RETVAL = Polygon(*THIS); %};
void append(ExtrusionPath* path) void append(ExtrusionPath* path)
%code{% THIS->paths.push_back(*path); %}; %code{% THIS->paths.push_back(*path); %};
double length(); double length();

View File

@ -29,12 +29,11 @@ directions_parallel_within(angle1, angle2, max_diff)
OUTPUT: OUTPUT:
RETVAL RETVAL
Polygon* Clone<Polygon>
convex_hull(points) convex_hull(points)
Points points Points points
CODE: CODE:
RETVAL = new Polygon (); RETVAL = Slic3r::Geometry::convex_hull(points);
Slic3r::Geometry::convex_hull(points, RETVAL);
OUTPUT: OUTPUT:
RETVAL RETVAL

View File

@ -26,8 +26,8 @@
Ref<ExtrusionEntityCollection> fills() Ref<ExtrusionEntityCollection> fills()
%code%{ RETVAL = &THIS->fills; %}; %code%{ RETVAL = &THIS->fills; %};
Flow* flow(FlowRole role, bool bridge = false, double width = -1) Clone<Flow> flow(FlowRole role, bool bridge = false, double width = -1)
%code%{ RETVAL = new Flow(THIS->flow(role, bridge, width)); %}; %code%{ RETVAL = THIS->flow(role, bridge, width); %};
void merge_slices(); void merge_slices();
}; };

View File

@ -28,7 +28,7 @@
bool parallel_to(double angle); bool parallel_to(double angle);
bool parallel_to_line(Line* line) bool parallel_to_line(Line* line)
%code{% RETVAL = THIS->parallel_to(*line); %}; %code{% RETVAL = THIS->parallel_to(*line); %};
Point* midpoint(); Clone<Point> midpoint();
Clone<Point> point_at(double distance); Clone<Point> point_at(double distance);
Clone<Point> intersection_infinite(Line* other) Clone<Point> intersection_infinite(Line* other)
%code{% %code{%
@ -37,8 +37,8 @@
if (!res) CONFESS("Intersection failed"); if (!res) CONFESS("Intersection failed");
RETVAL = p; RETVAL = p;
%}; %};
Polyline* as_polyline() Clone<Polyline> as_polyline()
%code{% RETVAL = new Polyline(*THIS); %}; %code{% RETVAL = Polyline(*THIS); %};
Clone<Point> normal(); Clone<Point> normal();
Clone<Point> vector(); Clone<Point> vector();
%{ %{

View File

@ -59,19 +59,13 @@
// void duplicate(size_t copies_num, coordf_t distance, const BoundingBox &bb); // void duplicate(size_t copies_num, coordf_t distance, const BoundingBox &bb);
bool has_objects_with_no_instances(); bool has_objects_with_no_instances();
bool add_default_instances(); bool add_default_instances();
BoundingBoxf3* bounding_box() Clone<BoundingBoxf3> bounding_box();
%code%{
RETVAL = new BoundingBoxf3();
THIS->bounding_box(RETVAL);
%};
void center_instances_around_point(Pointf* point) void center_instances_around_point(Pointf* point)
%code%{ THIS->center_instances_around_point(*point); %}; %code%{ THIS->center_instances_around_point(*point); %};
void align_instances_to_origin(); void align_instances_to_origin();
void translate(double x, double y, double z); void translate(double x, double y, double z);
TriangleMesh* mesh() Clone<TriangleMesh> mesh();
%code%{ RETVAL = new TriangleMesh(); THIS->mesh(RETVAL); %}; Clone<TriangleMesh> raw_mesh();
TriangleMesh* raw_mesh()
%code%{ RETVAL = new TriangleMesh(); THIS->raw_mesh(RETVAL); %};
// void split_meshes(); // void split_meshes();
// std::string get_material_name(t_model_material_id material_id); // std::string get_material_name(t_model_material_id material_id);
@ -119,20 +113,10 @@ ModelMaterial::attributes()
void invalidate_bounding_box(); void invalidate_bounding_box();
void update_bounding_box(); void update_bounding_box();
TriangleMesh* mesh() Clone<TriangleMesh> mesh();
%code%{ RETVAL = new TriangleMesh(); THIS->mesh(RETVAL); %}; Clone<TriangleMesh> raw_mesh();
TriangleMesh* raw_mesh() Clone<BoundingBoxf3> raw_bounding_box();
%code%{ RETVAL = new TriangleMesh(); THIS->raw_mesh(RETVAL); %}; Clone<BoundingBoxf3> instance_bounding_box(int idx);
BoundingBoxf3* raw_bounding_box()
%code%{
RETVAL = new BoundingBoxf3();
THIS->raw_bounding_box(RETVAL);
%};
BoundingBoxf3* instance_bounding_box(int idx)
%code%{
RETVAL = new BoundingBoxf3();
THIS->instance_bounding_box(idx, RETVAL);
%};
Ref<BoundingBoxf3> _bounding_box(BoundingBoxf3* new_bbox = NULL) Ref<BoundingBoxf3> _bounding_box(BoundingBoxf3* new_bbox = NULL)
%code{% %code{%
@ -147,11 +131,7 @@ ModelMaterial::attributes()
RETVAL = &THIS->_bounding_box; RETVAL = &THIS->_bounding_box;
%}; %};
BoundingBoxf3* bounding_box() Clone<BoundingBoxf3> bounding_box();
%code%{
RETVAL = new BoundingBoxf3();
THIS->bounding_box(RETVAL);
%};
%name{_add_volume} Ref<ModelVolume> add_volume(TriangleMesh* mesh) %name{_add_volume} Ref<ModelVolume> add_volume(TriangleMesh* mesh)
%code%{ RETVAL = THIS->add_volume(*mesh); %}; %code%{ RETVAL = THIS->add_volume(*mesh); %};

View File

@ -10,6 +10,6 @@
~MotionPlanner(); ~MotionPlanner();
int islands_count(); int islands_count();
Polyline* shortest_path(Point* from, Point* to) Clone<Polyline> shortest_path(Point* from, Point* to)
%code%{ RETVAL = new Polyline(); THIS->shortest_path(*from, *to, RETVAL); %}; %code%{ RETVAL = THIS->shortest_path(*from, *to); %};
}; };

View File

@ -27,8 +27,8 @@
void set_y(long val) void set_y(long val)
%code{% THIS->y = val; %}; %code{% THIS->y = val; %};
int nearest_point_index(Points points); int nearest_point_index(Points points);
Point* nearest_point(Points points) Clone<Point> nearest_point(Points points)
%code{% RETVAL = new Point(); THIS->nearest_point(points, RETVAL); %}; %code{% Point p; THIS->nearest_point(points, &p); RETVAL = p; %};
double distance_to(Point* point) double distance_to(Point* point)
%code{% RETVAL = THIS->distance_to(*point); %}; %code{% RETVAL = THIS->distance_to(*point); %};
double distance_to_line(Line* line) double distance_to_line(Line* line)

View File

@ -19,14 +19,11 @@
void translate(double x, double y); void translate(double x, double y);
void reverse(); void reverse();
Lines lines(); Lines lines();
Polyline* split_at_vertex(Point* point) Clone<Polyline> split_at_vertex(Point* point)
%code{% RETVAL = new Polyline(); THIS->split_at_vertex(*point, RETVAL); %}; %code{% RETVAL = THIS->split_at_vertex(*point); %};
Polyline* split_at_index(int index) Clone<Polyline> split_at_index(int index);
%code{% RETVAL = new Polyline(); THIS->split_at_index(index, RETVAL); %}; Clone<Polyline> split_at_first_point();
Polyline* split_at_first_point() Points equally_spaced_points(double distance);
%code{% RETVAL = new Polyline(); THIS->split_at_first_point(RETVAL); %};
Points equally_spaced_points(double distance)
%code{% THIS->equally_spaced_points(distance, &RETVAL); %};
double length(); double length();
double area(); double area();
bool is_counter_clockwise(); bool is_counter_clockwise();
@ -41,16 +38,10 @@
Polygons triangulate_convex() Polygons triangulate_convex()
%code{% THIS->triangulate_convex(&RETVAL); %}; %code{% THIS->triangulate_convex(&RETVAL); %};
Clone<Point> centroid(); Clone<Point> centroid();
BoundingBox* bounding_box() Clone<BoundingBox> bounding_box();
%code{%
RETVAL = new BoundingBox();
THIS->bounding_box(RETVAL);
%};
std::string wkt(); std::string wkt();
Points concave_points(double angle) Points concave_points(double angle);
%code{% THIS->concave_points(angle, &RETVAL); %}; Points convex_points(double angle);
Points convex_points(double angle)
%code{% THIS->convex_points(angle, &RETVAL); %};
%{ %{
Polygon* Polygon*

View File

@ -23,8 +23,7 @@
Lines lines(); Lines lines();
Clone<Point> first_point(); Clone<Point> first_point();
Clone<Point> last_point(); Clone<Point> last_point();
Points equally_spaced_points(double distance) Points equally_spaced_points(double distance);
%code{% THIS->equally_spaced_points(distance, &RETVAL); %};
double length(); double length();
bool is_valid(); bool is_valid();
void clip_end(double distance); void clip_end(double distance);
@ -37,11 +36,7 @@
void split_at(Point* point, Polyline* p1, Polyline* p2) void split_at(Point* point, Polyline* p1, Polyline* p2)
%code{% THIS->split_at(*point, p1, p2); %}; %code{% THIS->split_at(*point, p1, p2); %};
bool is_straight(); bool is_straight();
BoundingBox* bounding_box() Clone<BoundingBox> bounding_box();
%code{%
RETVAL = new BoundingBox();
THIS->bounding_box(RETVAL);
%};
std::string wkt(); std::string wkt();
%{ %{

View File

@ -35,8 +35,8 @@ _constant()
%code%{ RETVAL = &THIS->config; %}; %code%{ RETVAL = &THIS->config; %};
Ref<Print> print(); Ref<Print> print();
Flow* flow(FlowRole role, double layer_height, bool bridge, bool first_layer, double width, PrintObject* object) Clone<Flow> flow(FlowRole role, double layer_height, bool bridge, bool first_layer, double width, PrintObject* object)
%code%{ RETVAL = new Flow(THIS->flow(role, layer_height, bridge, first_layer, width, *object)); %}; %code%{ RETVAL = THIS->flow(role, layer_height, bridge, first_layer, width, *object); %};
}; };
@ -61,11 +61,7 @@ _constant()
%code%{ RETVAL = THIS->layer_height_ranges; %}; %code%{ RETVAL = THIS->layer_height_ranges; %};
Ref<Point3> size() Ref<Point3> size()
%code%{ RETVAL = &THIS->size; %}; %code%{ RETVAL = &THIS->size; %};
BoundingBox* bounding_box() Clone<BoundingBox> bounding_box();
%code{%
RETVAL = new BoundingBox();
THIS->bounding_box(RETVAL);
%};
Ref<Point> _copies_shift() Ref<Point> _copies_shift()
%code%{ RETVAL = &THIS->_copies_shift; %}; %code%{ RETVAL = &THIS->_copies_shift; %};

View File

@ -31,19 +31,11 @@
TriangleMeshPtrs split(); TriangleMeshPtrs split();
void merge(TriangleMesh* mesh) void merge(TriangleMesh* mesh)
%code{% THIS->merge(*mesh); %}; %code{% THIS->merge(*mesh); %};
ExPolygons horizontal_projection() ExPolygons horizontal_projection();
%code{% THIS->horizontal_projection(RETVAL); %}; Clone<Polygon> convex_hull();
BoundingBoxf3* bounding_box() Clone<BoundingBoxf3> bounding_box();
%code{% Clone<Pointf3> center()
RETVAL = new BoundingBoxf3(); %code{% RETVAL = THIS->bounding_box().center(); %};
THIS->bounding_box(RETVAL);
%};
Pointf3* center()
%code{%
BoundingBoxf3 bb;
THIS->bounding_box(&bb);
RETVAL = new Pointf3(bb.center());
%};
int facets_count(); int facets_count();
void reset_repair_stats(); void reset_repair_stats();
%{ %{
@ -196,14 +188,6 @@ TriangleMesh::bb3()
OUTPUT: OUTPUT:
RETVAL RETVAL
Polygon*
TriangleMesh::convex_hull()
CODE:
RETVAL = new Polygon ();
THIS->convex_hull(RETVAL);
OUTPUT:
RETVAL
%} %}
}; };

View File

@ -454,7 +454,6 @@ T_ARRAYREF
for (${type}::const_iterator it = $var.begin(); it != $var.end(); ++it) { for (${type}::const_iterator it = $var.begin(); it != $var.end(); ++it) {
av_store(av, i++, perl_to_SV_clone_ref(*it)); av_store(av, i++, perl_to_SV_clone_ref(*it));
} }
$var.clear();
T_ARRAYREF_PTR T_ARRAYREF_PTR
AV* av = newAV(); AV* av = newAV();