mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Add OpenVDB to dependencies
* Add Linux openvdb integration * Add Mac openvdb integration and enable in ALL * Create openvdb sandbox to test integration. * Additional fixes in the patches * Remove slabasebed sandbox as it has no relevance now * Provide FindOpenVDB module and fix build issues
This commit is contained in:
		
							parent
							
								
									a7c843d213
								
							
						
					
					
						commit
						4554da29ab
					
				
					 20 changed files with 3199 additions and 275 deletions
				
			
		| 
						 | 
				
			
			@ -1,2 +1,2 @@
 | 
			
		|||
add_subdirectory(slabasebed)
 | 
			
		||||
add_subdirectory(slasupporttree)
 | 
			
		||||
add_subdirectory(openvdb)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								sandboxes/openvdb/CMakeLists.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								sandboxes/openvdb/CMakeLists.txt
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
add_executable(openvdb_example openvdb_example.cpp)
 | 
			
		||||
target_link_libraries(openvdb_example libslic3r)
 | 
			
		||||
							
								
								
									
										37
									
								
								sandboxes/openvdb/openvdb_example.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								sandboxes/openvdb/openvdb_example.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,37 @@
 | 
			
		|||
#include <openvdb/openvdb.h>
 | 
			
		||||
#include <iostream>
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    // Initialize the OpenVDB library.  This must be called at least
 | 
			
		||||
    // once per program and may safely be called multiple times.
 | 
			
		||||
    openvdb::initialize();
 | 
			
		||||
    // Create an empty floating-point grid with background value 0.
 | 
			
		||||
    openvdb::FloatGrid::Ptr grid = openvdb::FloatGrid::create();
 | 
			
		||||
    std::cout << "Testing random access:" << std::endl;
 | 
			
		||||
    // Get an accessor for coordinate-based access to voxels.
 | 
			
		||||
    openvdb::FloatGrid::Accessor accessor = grid->getAccessor();
 | 
			
		||||
    // Define a coordinate with large signed indices.
 | 
			
		||||
    openvdb::Coord xyz(1000, -200000000, 30000000);
 | 
			
		||||
    // Set the voxel value at (1000, -200000000, 30000000) to 1.
 | 
			
		||||
    accessor.setValue(xyz, 1.0);
 | 
			
		||||
    // Verify that the voxel value at (1000, -200000000, 30000000) is 1.
 | 
			
		||||
    std::cout << "Grid" << xyz << " = " << accessor.getValue(xyz) << std::endl;
 | 
			
		||||
    // Reset the coordinates to those of a different voxel.
 | 
			
		||||
    xyz.reset(1000, 200000000, -30000000);
 | 
			
		||||
    // Verify that the voxel value at (1000, 200000000, -30000000) is
 | 
			
		||||
    // the background value, 0.
 | 
			
		||||
    std::cout << "Grid" << xyz << " = " << accessor.getValue(xyz) << std::endl;
 | 
			
		||||
    // Set the voxel value at (1000, 200000000, -30000000) to 2.
 | 
			
		||||
    accessor.setValue(xyz, 2.0);
 | 
			
		||||
    // Set the voxels at the two extremes of the available coordinate space.
 | 
			
		||||
    // For 32-bit signed coordinates these are (-2147483648, -2147483648, -2147483648)
 | 
			
		||||
    // and (2147483647, 2147483647, 2147483647).
 | 
			
		||||
    accessor.setValue(openvdb::Coord::min(), 3.0f);
 | 
			
		||||
    accessor.setValue(openvdb::Coord::max(), 4.0f);
 | 
			
		||||
    std::cout << "Testing sequential access:" << std::endl;
 | 
			
		||||
    // Print all active ("on") voxels by means of an iterator.
 | 
			
		||||
    for (openvdb::FloatGrid::ValueOnCIter iter = grid->cbeginValueOn(); iter; ++iter) {
 | 
			
		||||
        std::cout << "Grid" << iter.getCoord() << " = " << *iter << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
add_executable(slabasebed EXCLUDE_FROM_ALL slabasebed.cpp)
 | 
			
		||||
target_link_libraries(slabasebed libslic3r ${Boost_LIBRARIES} ${TBB_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
 | 
			
		||||
| 
						 | 
				
			
			@ -1,85 +0,0 @@
 | 
			
		|||
#include <iostream>
 | 
			
		||||
#include <fstream>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
#include <libslic3r/libslic3r.h>
 | 
			
		||||
#include <libslic3r/TriangleMesh.hpp>
 | 
			
		||||
#include <libslic3r/Tesselate.hpp>
 | 
			
		||||
#include <libslic3r/ClipperUtils.hpp>
 | 
			
		||||
#include <libslic3r/SLA/SLABasePool.hpp>
 | 
			
		||||
#include <libslic3r/SLA/SLABoilerPlate.hpp>
 | 
			
		||||
#include <libnest2d/tools/benchmark.h>
 | 
			
		||||
 | 
			
		||||
const std::string USAGE_STR = {
 | 
			
		||||
    "Usage: slabasebed stlfilename.stl"
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
namespace Slic3r { namespace sla {
 | 
			
		||||
 | 
			
		||||
Contour3D create_pad(const Polygons &ground_layer,
 | 
			
		||||
                           const ExPolygons &holes = {},
 | 
			
		||||
                           const PadConfig& cfg = PadConfig());
 | 
			
		||||
 | 
			
		||||
Contour3D walls(const Polygon& floor_plate, const Polygon& ceiling,
 | 
			
		||||
                double floor_z_mm, double ceiling_z_mm,
 | 
			
		||||
                double offset_difference_mm, ThrowOnCancel thr);
 | 
			
		||||
 | 
			
		||||
void offset(ExPolygon& sh, coord_t distance);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(const int argc, const char *argv[]) {
 | 
			
		||||
    using namespace Slic3r;
 | 
			
		||||
    using std::cout; using std::endl;
 | 
			
		||||
 | 
			
		||||
    if(argc < 2) {
 | 
			
		||||
        cout << USAGE_STR << endl;
 | 
			
		||||
        return EXIT_SUCCESS;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    TriangleMesh model;
 | 
			
		||||
    Benchmark bench;
 | 
			
		||||
 | 
			
		||||
    model.ReadSTLFile(argv[1]);
 | 
			
		||||
    model.align_to_origin();
 | 
			
		||||
 | 
			
		||||
    ExPolygons ground_slice;
 | 
			
		||||
    sla::pad_plate(model, ground_slice, 0.1f);
 | 
			
		||||
    if(ground_slice.empty()) return EXIT_FAILURE;
 | 
			
		||||
 | 
			
		||||
    ground_slice = offset_ex(ground_slice, 0.5);
 | 
			
		||||
    ExPolygon gndfirst; gndfirst = ground_slice.front();
 | 
			
		||||
    sla::breakstick_holes(gndfirst, 0.5, 10, 0.3);
 | 
			
		||||
 | 
			
		||||
    sla::Contour3D mesh;
 | 
			
		||||
 | 
			
		||||
    bench.start();
 | 
			
		||||
 | 
			
		||||
    sla::PadConfig cfg;
 | 
			
		||||
    cfg.min_wall_height_mm = 0;
 | 
			
		||||
    cfg.edge_radius_mm = 0;
 | 
			
		||||
    mesh = sla::create_pad(to_polygons(ground_slice), {}, cfg);
 | 
			
		||||
 | 
			
		||||
    bench.stop();
 | 
			
		||||
 | 
			
		||||
    cout << "Base pool creation time: " << std::setprecision(10)
 | 
			
		||||
         << bench.getElapsedSec() << " seconds." << endl;
 | 
			
		||||
 | 
			
		||||
    for(auto& trind : mesh.indices) {
 | 
			
		||||
        Vec3d p0 = mesh.points[size_t(trind[0])];
 | 
			
		||||
        Vec3d p1 = mesh.points[size_t(trind[1])];
 | 
			
		||||
        Vec3d p2 = mesh.points[size_t(trind[2])];
 | 
			
		||||
        Vec3d p01 = p1 - p0;
 | 
			
		||||
        Vec3d p02 = p2 - p0;
 | 
			
		||||
        auto a = p01.cross(p02).norm() / 2.0;
 | 
			
		||||
        if(std::abs(a) < 1e-6) std::cout << "degenerate triangle" << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //    basepool.write_ascii("out.stl");
 | 
			
		||||
 | 
			
		||||
    std::fstream outstream("out.obj", std::fstream::out);
 | 
			
		||||
    mesh.to_obj(outstream);
 | 
			
		||||
 | 
			
		||||
    return EXIT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue