Merge branch 'printcpp' of github.com:sapir/Slic3r into sapir-printcpp

Conflicts:
	lib/Slic3r/GCode.pm
	lib/Slic3r/Print.pm
	lib/Slic3r/Print/Object.pm
	lib/Slic3r/Print/Region.pm
This commit is contained in:
Alessandro Ranellucci 2014-06-10 14:46:40 +02:00
commit ba8148f4ad
26 changed files with 1293 additions and 266 deletions

View file

@ -1671,6 +1671,7 @@ src/Flow.hpp
src/GCode.hpp
src/Geometry.cpp
src/Geometry.hpp
src/Layer.cpp
src/Layer.hpp
src/Line.cpp
src/Line.hpp
@ -1680,6 +1681,8 @@ src/MultiPoint.cpp
src/MultiPoint.hpp
src/myinit.h
src/perlglue.hpp
src/PlaceholderParser.cpp
src/PlaceholderParser.hpp
src/Point.cpp
src/Point.hpp
src/poly2tri/common/shapes.cc
@ -1744,10 +1747,12 @@ xsp/ExtrusionLoop.xsp
xsp/ExtrusionPath.xsp
xsp/Flow.xsp
xsp/Geometry.xsp
xsp/Layer.xsp
xsp/Line.xsp
xsp/Model.xsp
xsp/my.map
xsp/mytype.map
xsp/PlaceholderParser.xsp
xsp/Point.xsp
xsp/Polygon.xsp
xsp/Polyline.xsp

View file

@ -18,6 +18,11 @@ use overload
'@{}' => sub { $_[0]->arrayref },
'fallback' => 1;
package Slic3r::Point3;
use overload
'@{}' => sub { [ $_[0]->x, $_[0]->y, $_[0]->z ] }, #,
'fallback' => 1;
package Slic3r::Pointf;
use overload
'@{}' => sub { [ $_[0]->x, $_[0]->y ] }, #,
@ -176,12 +181,24 @@ use overload
package main;
for my $class (qw(
Slic3r::Config
Slic3r::Config::Full
Slic3r::Config::Print
Slic3r::Config::PrintObject
Slic3r::Config::PrintRegion
Slic3r::ExPolygon
Slic3r::ExPolygon::Collection
Slic3r::Extruder
Slic3r::ExtrusionLoop
Slic3r::ExtrusionPath
Slic3r::ExtrusionPath::Collection
Slic3r::Flow
Slic3r::GCode::PlaceholderParser
Slic3r::Geometry::BoundingBox
Slic3r::Geometry::BoundingBoxf
Slic3r::Geometry::BoundingBoxf3
Slic3r::Layer
Slic3r::Layer::Region
Slic3r::Layer::Support
Slic3r::Line
Slic3r::Model
Slic3r::Model::Instance
@ -189,11 +206,18 @@ for my $class (qw(
Slic3r::Model::Object
Slic3r::Model::Volume
Slic3r::Point
Slic3r::Point3
Slic3r::Pointf
Slic3r::Pointf3
Slic3r::Polygon
Slic3r::Polyline
Slic3r::Polyline::Collection
Slic3r::Print
Slic3r::Print::Object
Slic3r::Print::Region
Slic3r::Print::State
Slic3r::Surface
Slic3r::Surface::Collection
Slic3r::TriangleMesh
))
{

132
xs/src/Layer.cpp Normal file
View file

@ -0,0 +1,132 @@
#include "Layer.hpp"
namespace Slic3r {
LayerRegion::LayerRegion(Layer *layer, PrintRegion *region)
: _layer(layer),
_region(region)
{
}
LayerRegion::~LayerRegion()
{
}
Layer*
LayerRegion::layer()
{
return this->_layer;
}
PrintRegion*
LayerRegion::region()
{
return this->_region;
}
#ifdef SLIC3RXS
REGISTER_CLASS(LayerRegion, "Layer::Region");
#endif
Layer::Layer(int id, PrintObject *object, coordf_t height, coordf_t print_z,
coordf_t slice_z)
: _id(id),
_object(object),
upper_layer(NULL),
lower_layer(NULL),
regions(),
slicing_errors(false),
slice_z(slice_z),
print_z(print_z),
height(height),
slices()
{
}
Layer::~Layer()
{
// remove references to self
if (NULL != this->upper_layer) {
this->upper_layer->lower_layer = NULL;
}
if (NULL != this->lower_layer) {
this->lower_layer->upper_layer = NULL;
}
this->clear_regions();
}
int
Layer::id()
{
return this->_id;
}
PrintObject*
Layer::object()
{
return this->_object;
}
size_t
Layer::region_count()
{
return this->regions.size();
}
void
Layer::clear_regions()
{
for (int i = this->regions.size()-1; i >= 0; --i)
this->delete_region(i);
}
LayerRegion*
Layer::get_region(int idx)
{
return this->regions.at(idx);
}
LayerRegion*
Layer::add_region(PrintRegion* print_region)
{
LayerRegion* region = new LayerRegion(this, print_region);
this->regions.push_back(region);
return region;
}
void
Layer::delete_region(int idx)
{
LayerRegionPtrs::iterator i = this->regions.begin() + idx;
LayerRegion* item = *i;
this->regions.erase(i);
delete item;
}
#ifdef SLIC3RXS
REGISTER_CLASS(Layer, "Layer");
#endif
SupportLayer::SupportLayer(int id, PrintObject *object, coordf_t height,
coordf_t print_z, coordf_t slice_z)
: Layer(id, object, height, print_z, slice_z)
{
}
SupportLayer::~SupportLayer()
{
}
#ifdef SLIC3RXS
REGISTER_CLASS(SupportLayer, "Layer::Support");
#endif
}

View file

@ -2,12 +2,118 @@
#define slic3r_Layer_hpp_
#include <myinit.h>
#include "SurfaceCollection.hpp"
#include "ExtrusionEntityCollection.hpp"
#include "ExPolygonCollection.hpp"
#include "PolylineCollection.hpp"
namespace Slic3r {
typedef std::pair<coordf_t,coordf_t> t_layer_height_range;
typedef std::map<t_layer_height_range,coordf_t> t_layer_height_ranges;
class Layer;
class PrintRegion;
class PrintObject;
// TODO: make stuff private
class LayerRegion
{
friend class Layer;
public:
Layer* layer();
PrintRegion* region();
// collection of surfaces generated by slicing the original geometry
// divided by type top/bottom/internal
SurfaceCollection slices;
// collection of extrusion paths/loops filling gaps
ExtrusionEntityCollection thin_fills;
// collection of surfaces for infill generation
SurfaceCollection fill_surfaces;
// collection of expolygons representing the bridged areas (thus not
// needing support material)
ExPolygonCollection bridged;
// collection of polylines representing the unsupported bridge edges
PolylineCollection unsupported_bridge_edges;
// ordered collection of extrusion paths/loops to build all perimeters
ExtrusionEntityCollection perimeters;
// ordered collection of extrusion paths to fill surfaces
ExtrusionEntityCollection fills;
private:
Layer *_layer;
PrintRegion *_region;
LayerRegion(Layer *layer, PrintRegion *region);
~LayerRegion();
};
typedef std::vector<LayerRegion*> LayerRegionPtrs;
class Layer {
friend class PrintObject;
public:
int id();
PrintObject* object();
Layer *upper_layer;
Layer *lower_layer;
LayerRegionPtrs regions;
bool slicing_errors;
coordf_t slice_z; // Z used for slicing in unscaled coordinates
coordf_t print_z; // Z used for printing in unscaled coordinates
coordf_t height; // layer height in unscaled coordinates
// collection of expolygons generated by slicing the original geometry;
// also known as 'islands' (all regions and surface types are merged here)
ExPolygonCollection slices;
size_t region_count();
LayerRegion* get_region(int idx);
LayerRegion* add_region(PrintRegion* print_region);
protected:
int _id; // sequential number of layer, 0-based
PrintObject *_object;
Layer(int id, PrintObject *object, coordf_t height, coordf_t print_z,
coordf_t slice_z);
virtual ~Layer();
void clear_regions();
void delete_region(int idx);
};
class SupportLayer : public Layer {
friend class PrintObject;
public:
ExPolygonCollection support_islands;
ExtrusionEntityCollection support_fills;
ExtrusionEntityCollection support_interface_fills;
protected:
SupportLayer(int id, PrintObject *object, coordf_t height, coordf_t print_z,
coordf_t slice_z);
virtual ~SupportLayer();
};
}
#endif

View file

@ -0,0 +1,25 @@
#include "PlaceholderParser.hpp"
#ifdef SLIC3RXS
#include "perlglue.hpp"
#endif
namespace Slic3r {
PlaceholderParser::PlaceholderParser()
{
// TODO: port these methods to C++, then call them here
// this->apply_env_variables();
// this->update_timestamp();
}
PlaceholderParser::~PlaceholderParser()
{
}
#ifdef SLIC3RXS
REGISTER_CLASS(PlaceholderParser, "GCode::PlaceholderParser");
#endif
}

View file

@ -0,0 +1,24 @@
#ifndef slic3r_PlaceholderParser_hpp_
#define slic3r_PlaceholderParser_hpp_
#include <myinit.h>
#include <map>
#include <string>
namespace Slic3r {
class PlaceholderParser
{
public:
std::map<std::string, std::string> _single;
std::map<std::string, std::string> _multiple;
PlaceholderParser();
~PlaceholderParser();
};
}
#endif

View file

@ -243,6 +243,9 @@ Point::from_SV_check(SV* point_sv)
}
}
REGISTER_CLASS(Point3, "Point3");
#endif
void

View file

@ -1,4 +1,5 @@
#include "Print.hpp"
#include "BoundingBox.hpp"
namespace Slic3r {
@ -44,4 +45,275 @@ PrintState::invalidate_all()
REGISTER_CLASS(PrintState, "Print::State");
#endif
PrintRegion::PrintRegion(Print* print)
: config(), _print(print)
{
}
PrintRegion::~PrintRegion()
{
}
Print*
PrintRegion::print()
{
return this->_print;
}
PrintConfig &
PrintRegion::print_config()
{
return this->_print->config;
}
#ifdef SLIC3RXS
REGISTER_CLASS(PrintRegion, "Print::Region");
#endif
PrintObject::PrintObject(Print* print, int id, ModelObject* model_object,
const BoundingBoxf3 &modobj_bbox)
: _print(print),
_id(id),
_model_object(model_object)
{
region_volumes.resize(this->_print->regions.size());
// Compute the translation to be applied to our meshes so that we work with smaller coordinates
{
// Translate meshes so that our toolpath generation algorithms work with smaller
// XY coordinates; this translation is an optimization and not strictly required.
// A cloned mesh will be aligned to 0 before slicing in _slice_region() since we
// don't assume it's already aligned and we don't alter the original position in model.
// We store the XY translation so that we can place copies correctly in the output G-code
// (copies are expressed in G-code coordinates and this translation is not publicly exposed).
this->_copies_shift = Point(
scale_(modobj_bbox.min.x), scale_(modobj_bbox.min.y));
// TODO: $self->_trigger_copies;
// Scale the object size and store it
Pointf3 size = modobj_bbox.size();
this->size = Point3(scale_(size.x), scale_(size.y), scale_(size.z));
}
}
PrintObject::~PrintObject()
{
}
Print*
PrintObject::print()
{
return this->_print;
}
int
PrintObject::id()
{
return this->_id;
}
ModelObject*
PrintObject::model_object()
{
return this->_model_object;
}
void
PrintObject::add_region_volume(int region_id, int volume_id)
{
if (region_id >= region_volumes.size()) {
region_volumes.resize(region_id + 1);
}
region_volumes[region_id].push_back(volume_id);
}
size_t
PrintObject::layer_count()
{
return this->layers.size();
}
void
PrintObject::clear_layers()
{
for (int i = this->layers.size()-1; i >= 0; --i)
this->delete_layer(i);
}
Layer*
PrintObject::get_layer(int idx)
{
return this->layers.at(idx);
}
Layer*
PrintObject::add_layer(int id, coordf_t height, coordf_t print_z,
coordf_t slice_z)
{
Layer* layer = new Layer(id, this, height, print_z, slice_z);
layers.push_back(layer);
return layer;
}
void
PrintObject::delete_layer(int idx)
{
LayerPtrs::iterator i = this->layers.begin() + idx;
Layer* item = *i;
this->layers.erase(i);
delete item;
}
size_t
PrintObject::support_layer_count()
{
return this->support_layers.size();
}
void
PrintObject::clear_support_layers()
{
for (int i = this->support_layers.size()-1; i >= 0; --i)
this->delete_support_layer(i);
}
SupportLayer*
PrintObject::get_support_layer(int idx)
{
return this->support_layers.at(idx);
}
SupportLayer*
PrintObject::add_support_layer(int id, coordf_t height, coordf_t print_z,
coordf_t slice_z)
{
SupportLayer* layer = new SupportLayer(id, this, height, print_z, slice_z);
support_layers.push_back(layer);
return layer;
}
void
PrintObject::delete_support_layer(int idx)
{
SupportLayerPtrs::iterator i = this->support_layers.begin() + idx;
SupportLayer* item = *i;
this->support_layers.erase(i);
delete item;
}
#ifdef SLIC3RXS
REGISTER_CLASS(PrintObject, "Print::Object");
#endif
Print::Print()
: total_used_filament(0),
total_extruded_volume(0)
{
}
Print::~Print()
{
clear_objects();
clear_regions();
}
void
Print::clear_objects()
{
for (int i = this->objects.size()-1; i >= 0; --i)
this->delete_object(i);
this->clear_regions();
this->_state.invalidate(psSkirt);
this->_state.invalidate(psBrim);
}
PrintObject*
Print::get_object(int idx)
{
return objects.at(idx);
}
PrintObject*
Print::add_object(ModelObject *model_object,
const BoundingBoxf3 &modobj_bbox)
{
PrintObject *object = new PrintObject(this,
this->objects.size(), model_object, modobj_bbox);
objects.push_back(object);
return object;
}
PrintObject*
Print::set_new_object(size_t idx, ModelObject *model_object,
const BoundingBoxf3 &modobj_bbox)
{
if (idx < 0 || idx >= this->objects.size()) throw "bad idx";
PrintObjectPtrs::iterator old_it = this->objects.begin() + idx;
delete *old_it;
PrintObject *object = new PrintObject(this, idx, model_object, modobj_bbox);
this->objects[idx] = object;
return object;
}
void
Print::delete_object(int idx)
{
PrintObjectPtrs::iterator i = this->objects.begin() + idx;
PrintObject* item = *i;
this->objects.erase(i);
delete item;
// TODO: purge unused regions
this->_state.invalidate(psSkirt);
this->_state.invalidate(psBrim);
}
void
Print::clear_regions()
{
for (int i = this->regions.size()-1; i >= 0; --i)
this->delete_region(i);
}
PrintRegion*
Print::get_region(int idx)
{
return regions.at(idx);
}
PrintRegion*
Print::add_region()
{
PrintRegion *region = new PrintRegion(this);
regions.push_back(region);
return region;
}
void
Print::delete_region(int idx)
{
PrintRegionPtrs::iterator i = this->regions.begin() + idx;
PrintRegion* item = *i;
this->regions.erase(i);
delete item;
}
#ifdef SLIC3RXS
REGISTER_CLASS(Print, "Print");
#endif
}

View file

@ -3,9 +3,19 @@
#include <myinit.h>
#include <set>
#include <vector>
#include "PrintConfig.hpp"
#include "Point.hpp"
#include "Layer.hpp"
#include "PlaceholderParser.hpp"
namespace Slic3r {
class Print;
class ModelObject;
enum PrintStep {
psInitExtruders, psSlice, psPerimeters, prPrepareInfill,
psInfill, psSupportMaterial, psSkirt, psBrim,
@ -26,6 +36,134 @@ class PrintState
void invalidate_all();
};
// TODO: make stuff private
// A PrintRegion object represents a group of volumes to print
// sharing the same config (including the same assigned extruder(s))
class PrintRegion
{
friend class Print;
public:
PrintRegionConfig config;
Print* print();
PrintConfig &print_config();
private:
Print* _print;
PrintRegion(Print* print);
virtual ~PrintRegion();
};
typedef std::vector<Layer*> LayerPtrs;
typedef std::vector<SupportLayer*> SupportLayerPtrs;
class BoundingBoxf3; // TODO: for temporary constructor parameter
class PrintObject
{
friend class Print;
public:
// vector of (vectors of volume ids), indexed by region_id
std::vector<std::vector<int> > region_volumes;
Points copies; // Slic3r::Point objects in scaled G-code coordinates
PrintObjectConfig config;
t_layer_height_ranges layer_height_ranges;
Point3 size; // XYZ in scaled coordinates
// scaled coordinates to add to copies (to compensate for the alignment
// operated when creating the object but still preserving a coherent API
// for external callers)
Point _copies_shift;
// Slic3r::Point objects in scaled G-code coordinates in our coordinates
Points _shifted_copies;
LayerPtrs layers;
SupportLayerPtrs support_layers;
// TODO: Fill* fill_maker => (is => 'lazy');
PrintState _state;
Print* print();
int id();
ModelObject* model_object();
// adds region_id, too, if necessary
void add_region_volume(int region_id, int volume_id);
size_t layer_count();
void clear_layers();
Layer* get_layer(int idx);
Layer* add_layer(int id, coordf_t height, coordf_t print_z,
coordf_t slice_z);
void delete_layer(int idx);
size_t support_layer_count();
void clear_support_layers();
SupportLayer* get_support_layer(int idx);
SupportLayer* add_support_layer(int id, coordf_t height, coordf_t print_z,
coordf_t slice_z);
void delete_support_layer(int idx);
private:
Print* _print;
int _id;
ModelObject* _model_object;
// TODO: call model_object->get_bounding_box() instead of accepting
// parameter
PrintObject(Print* print, int id, ModelObject* model_object,
const BoundingBoxf3 &modobj_bbox);
virtual ~PrintObject();
};
typedef std::vector<PrintObject*> PrintObjectPtrs;
typedef std::vector<PrintRegion*> PrintRegionPtrs;
class Print
{
public:
PrintConfig config;
PrintObjectConfig default_object_config;
PrintRegionConfig default_region_config;
PrintObjectPtrs objects;
PrintRegionPtrs regions;
PlaceholderParser placeholder_parser;
// TODO: status_cb
double total_used_filament;
double total_extruded_volume;
PrintState _state;
// ordered collection of extrusion paths to build skirt loops
ExtrusionEntityCollection skirt;
// ordered collection of extrusion paths to build a brim
ExtrusionEntityCollection brim;
Print();
virtual ~Print();
void clear_objects();
PrintObject* get_object(int idx);
PrintObject* add_object(ModelObject *model_object,
const BoundingBoxf3 &modobj_bbox);
PrintObject* set_new_object(size_t idx, ModelObject *model_object,
const BoundingBoxf3 &modobj_bbox);
void delete_object(int idx);
PrintRegion* get_region(int idx);
PrintRegion* add_region();
private:
void clear_regions();
void delete_region(int idx);
};
}
#endif

101
xs/xsp/Layer.xsp Normal file
View file

@ -0,0 +1,101 @@
%module{Slic3r::XS};
%{
#include <myinit.h>
#include "Layer.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::Layer::Region} class LayerRegion {
// owned by Layer, no constructor/destructor
Ref<Layer> layer();
Ref<PrintRegion> region();
Ref<SurfaceCollection> slices()
%code%{ RETVAL = &THIS->slices; %};
Ref<ExtrusionEntityCollection> thin_fills()
%code%{ RETVAL = &THIS->thin_fills; %};
Ref<SurfaceCollection> fill_surfaces()
%code%{ RETVAL = &THIS->fill_surfaces; %};
Ref<ExPolygonCollection> bridged()
%code%{ RETVAL = &THIS->bridged; %};
Ref<PolylineCollection> unsupported_bridge_edges()
%code%{ RETVAL = &THIS->unsupported_bridge_edges; %};
Ref<ExtrusionEntityCollection> perimeters()
%code%{ RETVAL = &THIS->perimeters; %};
Ref<ExtrusionEntityCollection> fills()
%code%{ RETVAL = &THIS->fills; %};
};
%name{Slic3r::Layer} class Layer {
// owned by PrintObject, no constructor/destructor
int id();
Ref<PrintObject> object();
Ref<Layer> upper_layer()
%code%{ RETVAL = THIS->upper_layer; %};
Ref<Layer> lower_layer()
%code%{ RETVAL = THIS->lower_layer; %};
bool slicing_errors()
%code%{ RETVAL = THIS->slicing_errors; %};
coordf_t slice_z()
%code%{ RETVAL = THIS->slice_z; %};
coordf_t print_z()
%code%{ RETVAL = THIS->print_z; %};
coordf_t height()
%code%{ RETVAL = THIS->height; %};
void set_upper_layer(Layer *layer)
%code%{ THIS->upper_layer = layer; %};
void set_lower_layer(Layer *layer)
%code%{ THIS->lower_layer = layer; %};
size_t region_count();
Ref<LayerRegion> get_region(int idx);
Ref<LayerRegion> add_region(PrintRegion* print_region);
Ref<ExPolygonCollection> slices()
%code%{ RETVAL = &THIS->slices; %};
};
%name{Slic3r::Layer::Support} class SupportLayer {
// owned by PrintObject, no constructor/destructor
Ref<ExPolygonCollection> support_islands()
%code%{ RETVAL = &THIS->support_islands; %};
Ref<ExtrusionEntityCollection> support_fills()
%code%{ RETVAL = &THIS->support_fills; %};
Ref<ExtrusionEntityCollection> support_interface_fills()
%code%{ RETVAL = &THIS->support_interface_fills; %};
// copies of some Layer methods, because the parameter wrapper code
// gets confused about getting a Layer::Support instead of a Layer
int id();
Ref<PrintObject> object();
Ref<SupportLayer> upper_layer()
%code%{ RETVAL = (SupportLayer*)THIS->upper_layer; %};
Ref<SupportLayer> lower_layer()
%code%{ RETVAL = (SupportLayer*)THIS->lower_layer; %};
bool slicing_errors()
%code%{ RETVAL = THIS->slicing_errors; %};
coordf_t slice_z()
%code%{ RETVAL = THIS->slice_z; %};
coordf_t print_z()
%code%{ RETVAL = THIS->print_z; %};
coordf_t height()
%code%{ RETVAL = THIS->height; %};
void set_upper_layer(SupportLayer *layer)
%code%{ THIS->upper_layer = layer; %};
void set_lower_layer(SupportLayer *layer)
%code%{ THIS->lower_layer = layer; %};
size_t region_count();
Ref<LayerRegion> get_region(int idx);
Ref<LayerRegion> add_region(PrintRegion* print_region);
Ref<ExPolygonCollection> slices()
%code%{ RETVAL = &THIS->slices; %};
};

View file

@ -0,0 +1,40 @@
%module{Slic3r::XS};
%{
#include <myinit.h>
#include <vector>
#include "PlaceholderParser.hpp"
%}
%name{Slic3r::GCode::PlaceholderParser} class PlaceholderParser {
%name{_new} PlaceholderParser();
~PlaceholderParser();
void _single_set(std::string k, std::string v)
%code%{ THIS->_single[k] = v; %};
void _multiple_set(std::string k, std::string v)
%code%{ THIS->_multiple[k] = v; %};
std::string _single_get(std::string k)
%code%{ RETVAL = THIS->_single[k]; %};
std::string _multiple_get(std::string k)
%code%{ RETVAL = THIS->_multiple[k]; %};
std::vector<std::string> _single_keys()
%code{%
for (std::map<std::string, std::string>::iterator i = THIS->_single.begin();
i != THIS->_single.end(); ++i)
{
RETVAL.push_back(i->first);
}
%};
std::vector<std::string> _multiple_keys()
%code{%
for (std::map<std::string, std::string>::iterator i = THIS->_multiple.begin();
i != THIS->_multiple.end(); ++i)
{
RETVAL.push_back(i->first);
}
%};
};

View file

@ -63,6 +63,19 @@ Point::coincides_with(point_sv)
};
%name{Slic3r::Point3} class Point3 {
Point3(long _x = 0, long _y = 0, long _z = 0);
~Point3();
Clone<Point3> clone()
%code{% RETVAL = THIS; %};
long x()
%code{% RETVAL = THIS->x; %};
long y()
%code{% RETVAL = THIS->y; %};
long z()
%code{% RETVAL = THIS->z; %};
};
%name{Slic3r::Pointf} class Pointf {
Pointf(double _x = 0, double _y = 0);
~Pointf();

View file

@ -4,6 +4,7 @@
#include <myinit.h>
#include "BoundingBox.hpp"
#include "Polygon.hpp"
#include "BoundingBox.hpp"
%}
%name{Slic3r::Polygon} class Polygon {

View file

@ -3,6 +3,7 @@
%{
#include <myinit.h>
#include "Print.hpp"
#include "PlaceholderParser.hpp"
%}
%name{Slic3r::Print::State} class PrintState {
@ -40,3 +41,133 @@ _constant()
%}
%name{Slic3r::Print::Region} class PrintRegion {
// owned by Print, no constructor/destructor
Ref<PrintRegionConfig> config()
%code%{ RETVAL = &THIS->config; %};
Ref<Print> print();
Ref<PrintConfig> print_config()
%code%{ RETVAL = &THIS->print_config(); %};
};
%name{Slic3r::Print::Object} class PrintObject {
// owned by Print, no constructor/destructor
void add_region_volume(int region_id, int volume_id);
std::vector<int> get_region_volumes(int region_id)
%code%{
if (0 <= region_id && region_id < THIS->region_volumes.size())
RETVAL = THIS->region_volumes[region_id];
%};
int region_count()
%code%{ RETVAL = THIS->print()->regions.size(); %};
Ref<Print> print();
int id();
Ref<ModelObject> model_object();
Ref<PrintObjectConfig> config()
%code%{ RETVAL = &THIS->config; %};
Points copies()
%code%{ RETVAL = THIS->copies; %};
t_layer_height_ranges layer_height_ranges()
%code%{ RETVAL = THIS->layer_height_ranges; %};
Ref<PrintState> _state()
%code%{ RETVAL = &THIS->_state; %};
Ref<Point3> size()
%code%{ RETVAL = &THIS->size; %};
Ref<Point> _copies_shift()
%code%{ RETVAL = &THIS->_copies_shift; %};
Points _shifted_copies()
%code%{ RETVAL = THIS->_shifted_copies; %};
void set_shifted_copies(Points value)
%code%{ THIS->_shifted_copies = value; %};
void set_copies(Points copies)
%code%{ THIS->copies = copies; %};
void set_layer_height_ranges(t_layer_height_ranges layer_height_ranges)
%code%{ THIS->layer_height_ranges = layer_height_ranges; %};
size_t layer_count();
void clear_layers();
Ref<Layer> get_layer(int idx);
Ref<Layer> add_layer(int id, coordf_t height, coordf_t print_z,
coordf_t slice_z);
void delete_layer(int idx);
size_t support_layer_count();
void clear_support_layers();
Ref<SupportLayer> get_support_layer(int idx);
Ref<SupportLayer> add_support_layer(int id, coordf_t height, coordf_t print_z,
coordf_t slice_z);
void delete_support_layer(int idx);
};
%name{Slic3r::Print} class Print {
%name{_new} Print();
~Print();
Ref<PrintConfig> config()
%code%{ RETVAL = &THIS->config; %};
Ref<PrintObjectConfig> default_object_config()
%code%{ RETVAL = &THIS->default_object_config; %};
Ref<PrintRegionConfig> default_region_config()
%code%{ RETVAL = &THIS->default_region_config; %};
Ref<PlaceholderParser> placeholder_parser()
%code%{ RETVAL = &THIS->placeholder_parser; %};
// TODO: status_cb
Ref<PrintState> _state()
%code%{ RETVAL = &THIS->_state; %};
Ref<ExtrusionEntityCollection> skirt()
%code%{ RETVAL = &THIS->skirt; %};
Ref<ExtrusionEntityCollection> brim()
%code%{ RETVAL = &THIS->brim; %};
PrintObjectPtrs* objects()
%code%{ RETVAL = &THIS->objects; %};
void clear_objects();
Ref<PrintObject> get_object(int idx);
Ref<PrintObject> add_object(ModelObject* model_object,
BoundingBoxf3 *modobj_bbox)
%code%{ RETVAL = THIS->add_object(model_object, *modobj_bbox); %};
Ref<PrintObject> set_new_object(size_t idx, ModelObject* model_object,
BoundingBoxf3 *modobj_bbox)
%code%{ RETVAL = THIS->set_new_object(idx, model_object, *modobj_bbox); %};
void delete_object(int idx);
size_t object_count()
%code%{ RETVAL = THIS->objects.size(); %};
PrintRegionPtrs* regions()
%code%{ RETVAL = &THIS->regions; %};
Ref<PrintRegion> get_region(int idx);
Ref<PrintRegion> add_region();
size_t region_count()
%code%{ RETVAL = THIS->regions.size(); %};
%{
double
Print::total_used_filament(...)
CODE:
if (items > 1) {
THIS->total_used_filament = (double)SvNV(ST(1));
}
RETVAL = THIS->total_used_filament;
OUTPUT:
RETVAL
double
Print::total_extruded_volume(...)
CODE:
if (items > 1) {
THIS->total_extruded_volume = (double)SvNV(ST(1));
}
RETVAL = THIS->total_extruded_volume;
OUTPUT:
RETVAL
%}
};

View file

@ -18,10 +18,19 @@ Clone<BoundingBoxf3> O_OBJECT_SLIC3R_T
DynamicPrintConfig* O_OBJECT_SLIC3R
Ref<DynamicPrintConfig> O_OBJECT_SLIC3R_T
PrintObjectConfig* O_OBJECT_SLIC3R
Ref<PrintObjectConfig> O_OBJECT_SLIC3R_T
PrintRegionConfig* O_OBJECT_SLIC3R
Ref<PrintRegionConfig> O_OBJECT_SLIC3R_T
PrintConfig* O_OBJECT_SLIC3R
Ref<PrintConfig> O_OBJECT_SLIC3R_T
FullPrintConfig* O_OBJECT_SLIC3R
Ref<FullPrintConfig> O_OBJECT_SLIC3R_T
ZTable* O_OBJECT
TriangleMesh* O_OBJECT_SLIC3R
@ -32,6 +41,10 @@ Point* O_OBJECT_SLIC3R
Ref<Point> O_OBJECT_SLIC3R_T
Clone<Point> O_OBJECT_SLIC3R_T
Point3* O_OBJECT_SLIC3R
Ref<Point3> O_OBJECT_SLIC3R_T
Clone<Point3> O_OBJECT_SLIC3R_T
Pointf* O_OBJECT_SLIC3R
Ref<Pointf> O_OBJECT_SLIC3R_T
Clone<Pointf> O_OBJECT_SLIC3R_T
@ -81,12 +94,14 @@ Ref<Flow> O_OBJECT_SLIC3R_T
Clone<Flow> O_OBJECT_SLIC3R_T
PrintState* O_OBJECT_SLIC3R
Ref<PrintState> O_OBJECT_SLIC3R_T
Surface* O_OBJECT_SLIC3R
Ref<Surface> O_OBJECT_SLIC3R_T
Clone<Surface> O_OBJECT_SLIC3R_T
SurfaceCollection* O_OBJECT_SLIC3R
Ref<SurfaceCollection> O_OBJECT_SLIC3R_T
Extruder* O_OBJECT_SLIC3R
@ -110,6 +125,29 @@ ModelInstance* O_OBJECT_SLIC3R
Ref<ModelInstance> O_OBJECT_SLIC3R_T
Clone<ModelInstance> O_OBJECT_SLIC3R_T
PrintRegion* O_OBJECT_SLIC3R
Ref<PrintRegion> O_OBJECT_SLIC3R_T
PrintObject* O_OBJECT_SLIC3R
Ref<PrintObject> O_OBJECT_SLIC3R_T
Print* O_OBJECT_SLIC3R
Ref<Print> O_OBJECT_SLIC3R_T
Clone<Print> O_OBJECT_SLIC3R_T
LayerRegion* O_OBJECT_SLIC3R
Ref<LayerRegion> O_OBJECT_SLIC3R_T
Layer* O_OBJECT_SLIC3R
Ref<Layer> O_OBJECT_SLIC3R_T
SupportLayer* O_OBJECT_SLIC3R
Ref<SupportLayer> O_OBJECT_SLIC3R_T
PlaceholderParser* O_OBJECT_SLIC3R
Ref<PlaceholderParser> O_OBJECT_SLIC3R_T
Clone<PlaceholderParser> O_OBJECT_SLIC3R_T
ExtrusionLoopRole T_UV
ExtrusionRole T_UV
@ -132,10 +170,14 @@ Surfaces T_ARRAYREF
# we return these types whenever we want the items to be returned
# by reference and marked ::Ref because they're contained in another
# Perl object
Polygons* T_ARRAYREF_PTR
ModelObjectPtrs* T_PTR_ARRAYREF_PTR
ModelVolumePtrs* T_PTR_ARRAYREF_PTR
ModelInstancePtrs* T_PTR_ARRAYREF_PTR
Polygons* T_ARRAYREF_PTR
ModelObjectPtrs* T_PTR_ARRAYREF_PTR
ModelVolumePtrs* T_PTR_ARRAYREF_PTR
ModelInstancePtrs* T_PTR_ARRAYREF_PTR
PrintRegionPtrs* T_PTR_ARRAYREF_PTR
PrintObjectPtrs* T_PTR_ARRAYREF_PTR
LayerPtrs* T_PTR_ARRAYREF_PTR
SupportLayerPtrs* T_PTR_ARRAYREF_PTR
# we return these types whenever we want the items to be returned
# by reference and not marked ::Ref because they're newly allocated
@ -224,10 +266,14 @@ T_LAYER_HEIGHT_RANGES
OUTPUT
# return object from pointer
O_OBJECT_SLIC3R
if ($var == NULL)
XSRETURN_UNDEF;
sv_setref_pv( $arg, perl_class_name($var), (void*)$var );
# return value handled by template class
O_OBJECT_SLIC3R_T
if ($var == NULL)
XSRETURN_UNDEF;
sv_setref_pv( $arg, $type\::CLASS(), (void*)$var );

View file

@ -16,6 +16,9 @@
%typemap{Point*};
%typemap{Ref<Point>}{simple};
%typemap{Clone<Point>}{simple};
%typemap{Point3*};
%typemap{Ref<Point3>}{simple};
%typemap{Clone<Point3>}{simple};
%typemap{Pointf*};
%typemap{Ref<Pointf>}{simple};
%typemap{Clone<Pointf>}{simple};
@ -31,9 +34,13 @@
%typemap{DynamicPrintConfig*};
%typemap{Ref<DynamicPrintConfig>}{simple};
%typemap{PrintObjectConfig*};
%typemap{Ref<PrintObjectConfig>}{simple};
%typemap{PrintRegionConfig*};
%typemap{Ref<PrintRegionConfig>}{simple};
%typemap{PrintConfig*};
%typemap{Ref<PrintConfig>}{simple};
%typemap{FullPrintConfig*};
%typemap{Ref<FullPrintConfig>}{simple};
%typemap{ExPolygon*};
%typemap{Ref<ExPolygon>}{simple};
%typemap{Clone<ExPolygon>}{simple};
@ -68,18 +75,45 @@
%typemap{Ref<PolylineCollection>}{simple};
%typemap{Clone<PolylineCollection>}{simple};
%typemap{PrintState*};
%typemap{Ref<PrintState>}{simple};
%typemap{PrintRegion*};
%typemap{Ref<PrintRegion>}{simple};
%typemap{PrintObject*};
%typemap{Ref<PrintObject>}{simple};
%typemap{Print*};
%typemap{Ref<Print>}{simple};
%typemap{Clone<Print>}{simple};
%typemap{LayerRegion*};
%typemap{Ref<LayerRegion>}{simple};
%typemap{Layer*};
%typemap{Ref<Layer>}{simple};
%typemap{SupportLayer*};
%typemap{Ref<SupportLayer>}{simple};
%typemap{PlaceholderParser*};
%typemap{Ref<PlaceholderParser>}{simple};
%typemap{Clone<PlaceholderParser>}{simple};
%typemap{Points};
%typemap{Pointfs};
%typemap{Lines};
%typemap{Polygons};
%typemap{Polylines};
%typemap{PrintState};
%typemap{ExPolygons};
%typemap{ExtrusionPaths};
%typemap{Surfaces};
%typemap{Polygons*};
%typemap{TriangleMesh*};
%typemap{TriangleMeshPtrs};
%typemap{Ref<SurfaceCollection>}{simple};
%typemap{Extruder*};
%typemap{Model*};
%typemap{Ref<Model>}{simple};
@ -106,6 +140,12 @@
%typemap{Ref<ModelInstancePtrs>}{simple};
%typemap{Clone<ModelInstancePtrs>}{simple};
%typemap{PrintRegionPtrs*};
%typemap{PrintObjectPtrs*};
%typemap{LayerPtrs*};
%typemap{SupportLayerPtrs*};
%typemap{SurfaceType}{parsed}{
%cpp_type{SurfaceType};
%precall_code{%