feeble attempts to get perl working

This commit is contained in:
Michael Kirsch 2019-05-11 11:49:34 +02:00 committed by Joseph Lenox
parent b0702ec00f
commit 545aa3c57f
4 changed files with 17 additions and 23 deletions

View File

@ -1331,8 +1331,7 @@ sub load_object {
my $volume = $model_object->volumes->[$volume_idx];
foreach my $instance_idx (@$instance_idxs) {
my $instance = $model_object->instances->[$instance_idx];
my $instance_trafo = $instance->get_trafo_matrixptr();
my $mesh = $volume->get_transformed_meshptr($instance_trafo);
my $mesh = $volume->transformed_mesh($instance);
my $color_idx;
if ($self->color_by eq 'volume') {

View File

@ -1026,13 +1026,6 @@ ModelVolume::get_transformed_mesh(TransformationMatrix const * additional_trafo)
return mesh;
}
TriangleMesh*
ModelVolume::get_transformed_meshptr(TransformationMatrix const * additional_trafo)
{
this->transformed_mesh = get_transformed_mesh(additional_trafo);
return &(this->transformed_mesh);
}
t_model_material_id
ModelVolume::material_id() const
{
@ -1118,10 +1111,9 @@ TransformationMatrix ModelInstance::get_trafo_matrix(bool dont_translate) const
return trafo;
}
TransformationMatrix* ModelInstance::get_trafo_matrixptr(bool dont_translate)
void ModelInstance::set_local_trafo_matrix(bool dont_translate)
{
this->trafo = this->get_trafo_matrix(dont_translate);
return &(this->trafo);
}
BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mesh, bool dont_translate) const

View File

@ -466,6 +466,8 @@ class ModelVolume
///< Configuration parameters specific to an object model geometry or a modifier volume,
///< overriding the global Slic3r settings and the ModelObject settings.
TriangleMesh transformed_mesh; ///< The transformed mesh only to be used by the perl binding
/// Input file path needed for reloading the volume from disk
std::string input_file; ///< Input file path
int input_file_obj_idx; ///< Input file object index
@ -482,11 +484,6 @@ class ModelVolume
/// \return TriangleMesh the transformed mesh
TriangleMesh get_transformed_mesh(TransformationMatrix const * additional_trafo) const;
/// Get the ModelVolume's mesh as pointer, transformed by the ModelVolume's TransformationMatrix
/// \param additional_trafo additional transformation
/// \return TriangleMesh the transformed mesh
TriangleMesh* get_transformed_meshptr(TransformationMatrix const * additional_trafo);
/// Get the material id of this ModelVolume object
/// \return t_model_material_id the material id string
t_model_material_id material_id() const;
@ -514,8 +511,6 @@ class ModelVolume
///< The id of the this ModelVolume
t_model_material_id _material_id;
TriangleMesh transformed_mesh; ///< The transformed mesh only to be used by the perl binding
/// Constructor
/// \param object ModelObject* pointer to the owner ModelObject
/// \param mesh TriangleMesh the mesh of the new ModelVolume object
@ -546,6 +541,8 @@ class ModelInstance
double scaling_factor; ///< uniform scaling factor.
Pointf offset; ///< offset in unscaled coordinates.
TransformationMatrix trafo; ///< Trafomatrix for perl binding
/// Get the owning ModelObject
/// \return ModelObject* pointer to the owner ModelObject
ModelObject* get_object() const { return this->object; };
@ -561,7 +558,7 @@ class ModelInstance
/// Returns a pointer to TransformationMatrix defined by the instance's Transform an external TriangleMesh to the returned TriangleMesh object
/// \param dont_translate bool whether to translate the mesh or not
TransformationMatrix* get_trafo_matrixptr(bool dont_translate = false);
void set_local_trafo_matrix(bool dont_translate);
/// Calculate a bounding box of a transformed mesh. To be called on an external mesh.
/// \param mesh TriangleMesh* pointer to the the mesh
@ -599,8 +596,6 @@ class ModelInstance
/// Swap attributes between another ModelInstance object
/// \param other ModelInstance& the other instance object
void swap(ModelInstance &other);
TransformationMatrix trafo; ///< Trafomatrix for perl binding
};
}

View File

@ -291,7 +291,12 @@ ModelMaterial::attributes()
Ref<TriangleMesh> mesh()
%code%{ RETVAL = &THIS->mesh; %};
Ref<TriangleMesh> get_transformed_meshptr(TransformationMatrix * additional_trafo = nullptr);
Ref<TriangleMesh> transformed_mesh(ModelInstance * instance)
%code%{
TransformationMatrix trafo = instance->get_trafo_matrix(false);
THIS->transformed_mesh = THIS->get_transformed_mesh(&trafo);
RETVAL = &THIS->transformed_mesh;
%};
bool modifier()
%code%{ RETVAL = THIS->modifier; %};
@ -329,7 +334,10 @@ ModelMaterial::attributes()
void set_offset(Pointf *offset)
%code%{ THIS->offset = *offset; %};
Ref<TransformationMatrix> get_trafo_matrixptr(bool dont_translate);
void set_local_trafo_matrix(bool dont_translate);
Ref<TransformationMatrix> local_trafo()
%code%{ RETVAL = &THIS->trafo; %};
void transform_mesh(TriangleMesh* mesh, bool dont_translate) const;
void transform_polygon(Polygon* polygon) const;