mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
Type handling is mainly done using templates. Template Slic3r::ClassTraits is used to store info about exported types (perl class name). Currently only perl class name and refference name is used. Template values are initialized by REGISTER_CLASS macro. This macro is used in .cpp file of class ( it needs to be used exactly for each type). Ref<type> class is used to return value as perl reference. Operator overloading is used to make c++ and XSpp happy, only pointer value should be possible to return. Clone<type> class is used to return copy of value ( using new and copy constructor). Copy is created on assigment, this should be probably improved (memory leak on multiple assignments). It is overloaded to be able to return type, type* and type&. Typechecking in ExtrusionEntityCollection updated to check all passed types.
74 lines
1.4 KiB
C++
74 lines
1.4 KiB
C++
#include "Surface.hpp"
|
|
#ifdef SLIC3RXS
|
|
#include "perlglue.hpp"
|
|
#endif
|
|
|
|
namespace Slic3r {
|
|
|
|
double
|
|
Surface::area() const
|
|
{
|
|
return this->expolygon.area();
|
|
}
|
|
|
|
bool
|
|
Surface::is_solid() const
|
|
{
|
|
return this->surface_type == stTop
|
|
|| this->surface_type == stBottom
|
|
|| this->surface_type == stBottomBridge
|
|
|| this->surface_type == stInternalSolid;
|
|
}
|
|
|
|
bool
|
|
Surface::is_external() const
|
|
{
|
|
return this->surface_type == stTop
|
|
|| this->surface_type == stBottom
|
|
|| this->surface_type == stBottomBridge;
|
|
}
|
|
|
|
bool
|
|
Surface::is_bottom() const
|
|
{
|
|
return this->surface_type == stBottom
|
|
|| this->surface_type == stBottomBridge;
|
|
}
|
|
|
|
bool
|
|
Surface::is_bridge() const
|
|
{
|
|
return this->surface_type == stBottomBridge
|
|
|| this->surface_type == stInternalBridge;
|
|
}
|
|
|
|
#ifdef SLIC3RXS
|
|
|
|
REGISTER_CLASS(Surface, "Surface");
|
|
|
|
void
|
|
Surface::from_SV_check(SV* surface_sv)
|
|
{
|
|
if (!sv_isa(surface_sv, perl_class_name(this)) && !sv_isa(surface_sv, perl_class_name_ref(this)))
|
|
CONFESS("Not a valid %s object", perl_class_name(this));
|
|
// a XS Surface was supplied
|
|
*this = *(Surface *)SvIV((SV*)SvRV( surface_sv ));
|
|
}
|
|
|
|
SV*
|
|
Surface::to_SV_ref() {
|
|
SV* sv = newSV(0);
|
|
sv_setref_pv( sv, perl_class_name_ref(this), (void*)this );
|
|
return sv;
|
|
}
|
|
|
|
SV*
|
|
Surface::to_SV_clone_ref() const {
|
|
SV* sv = newSV(0);
|
|
sv_setref_pv( sv, perl_class_name(this), new Surface(*this) );
|
|
return sv;
|
|
}
|
|
#endif
|
|
|
|
}
|