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

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{%