mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	New Slic3r::TriangleMesh::XS->ToPerl() method
This commit is contained in:
		
							parent
							
								
									ecdc2f077b
								
							
						
					
					
						commit
						d30b4f0310
					
				
					 4 changed files with 49 additions and 1 deletions
				
			
		| 
						 | 
					@ -70,3 +70,40 @@ TriangleMesh::WriteOBJFile(char* output_file) {
 | 
				
			||||||
    stl_generate_shared_vertices(&stl);
 | 
					    stl_generate_shared_vertices(&stl);
 | 
				
			||||||
    stl_write_obj(&stl, output_file);
 | 
					    stl_write_obj(&stl, output_file);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					AV*
 | 
				
			||||||
 | 
					TriangleMesh::ToPerl() {
 | 
				
			||||||
 | 
					    int i;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    stl_generate_shared_vertices(&stl);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    // vertices
 | 
				
			||||||
 | 
					    AV* vertices = newAV();
 | 
				
			||||||
 | 
					    av_extend(vertices, stl.stats.shared_vertices);
 | 
				
			||||||
 | 
					    for (i = 0; i < stl.stats.shared_vertices; i++) {
 | 
				
			||||||
 | 
					        AV* vertex = newAV();
 | 
				
			||||||
 | 
					        av_store(vertices, i, newRV_noinc((SV*)vertex));
 | 
				
			||||||
 | 
					        av_extend(vertex, 2);
 | 
				
			||||||
 | 
					        av_store(vertex, 0, newSVnv(stl.v_shared[i].x));
 | 
				
			||||||
 | 
					        av_store(vertex, 1, newSVnv(stl.v_shared[i].y));
 | 
				
			||||||
 | 
					        av_store(vertex, 2, newSVnv(stl.v_shared[i].z));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    // facets
 | 
				
			||||||
 | 
					    AV* facets = newAV();
 | 
				
			||||||
 | 
					    av_extend(facets, stl.stats.number_of_facets);
 | 
				
			||||||
 | 
					    for (i = 0; i < stl.stats.number_of_facets; i++) {
 | 
				
			||||||
 | 
					        AV* facet = newAV();
 | 
				
			||||||
 | 
					        av_store(facets, i, newRV_noinc((SV*)facet));
 | 
				
			||||||
 | 
					        av_extend(facet, 2);
 | 
				
			||||||
 | 
					        av_store(facet, 0, newSVnv(stl.v_indices[i].vertex[0]));
 | 
				
			||||||
 | 
					        av_store(facet, 1, newSVnv(stl.v_indices[i].vertex[1]));
 | 
				
			||||||
 | 
					        av_store(facet, 2, newSVnv(stl.v_indices[i].vertex[2]));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    AV* result = newAV();
 | 
				
			||||||
 | 
					    av_extend(result, 1);
 | 
				
			||||||
 | 
					    av_store(result, 0, newRV_noinc((SV*)vertices));
 | 
				
			||||||
 | 
					    av_store(result, 1, newRV_noinc((SV*)facets));
 | 
				
			||||||
 | 
					    return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,12 @@
 | 
				
			||||||
#include <admesh/stl.h>
 | 
					#include <admesh/stl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#include "EXTERN.h"
 | 
				
			||||||
 | 
					#include "perl.h"
 | 
				
			||||||
 | 
					#include "XSUB.h"
 | 
				
			||||||
 | 
					#include "ppport.h"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TriangleMesh
 | 
					class TriangleMesh
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
| 
						 | 
					@ -8,6 +15,7 @@ class TriangleMesh
 | 
				
			||||||
    void ReadSTLFile(char* input_file);
 | 
					    void ReadSTLFile(char* input_file);
 | 
				
			||||||
    void Repair();
 | 
					    void Repair();
 | 
				
			||||||
    void WriteOBJFile(char* output_file);
 | 
					    void WriteOBJFile(char* output_file);
 | 
				
			||||||
 | 
					    AV* ToPerl();
 | 
				
			||||||
    private:
 | 
					    private:
 | 
				
			||||||
    stl_file stl;
 | 
					    stl_file stl;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@
 | 
				
			||||||
    void ReadSTLFile(char* input_file);
 | 
					    void ReadSTLFile(char* input_file);
 | 
				
			||||||
    void Repair();
 | 
					    void Repair();
 | 
				
			||||||
    void WriteOBJFile(char* output_file);
 | 
					    void WriteOBJFile(char* output_file);
 | 
				
			||||||
 | 
					    AV* ToPerl();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
%package{Slic3r::TriangleMesh::XS};
 | 
					%package{Slic3r::TriangleMesh::XS};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,2 +1,4 @@
 | 
				
			||||||
%typemap{std::string};
 | 
					%typemap{std::string};
 | 
				
			||||||
%typemap{std::vector<unsigned int>*};
 | 
					%typemap{std::vector<unsigned int>*};
 | 
				
			||||||
 | 
					%typemap{SV*};
 | 
				
			||||||
 | 
					%typemap{AV*};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue