more clang warnings enabled, performance measuring

Succesfull build on mingw-w64


fix sandboxes


Mingw fixes and full parallel support tree gen.
This commit is contained in:
tamasmeszaros 2019-08-16 16:17:37 +02:00
parent 7d25d8c677
commit 7e0199746e
27 changed files with 1393 additions and 1148 deletions

View File

@ -54,6 +54,12 @@ endif ()
if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(IS_CLANG_CL TRUE)
# clang-cl can interpret SYSTEM header paths if -imsvc is used
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-imsvc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall \
-Wno-old-style-cast -Wno-reserved-id-macro -Wno-c++98-compat-pedantic")
else ()
set(IS_CLANG_CL FALSE)
endif ()
@ -68,6 +74,10 @@ if (MSVC)
add_compile_options(-bigobj -Zm520 /Zi)
endif ()
if (MINGW)
add_compile_options(-Wa,-mbig-obj)
endif ()
# Display and check CMAKE_PREFIX_PATH
message(STATUS "SLIC3R_STATIC: ${SLIC3R_STATIC}")
if (NOT "${CMAKE_PREFIX_PATH}" STREQUAL "")
@ -155,7 +165,9 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
endif()
if (NOT MSVC AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
if (NOT MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" )
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder" )
# On GCC and Clang, no return from a non-void function is a warning only. Here, we make it an error.
@ -201,9 +213,12 @@ include_directories(${LIBDIR_BIN}/platform)
include_directories(${LIBDIR}/clipper ${LIBDIR}/polypartition)
if(WIN32)
add_definitions(-D_USE_MATH_DEFINES -D_WIN32 -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
if(MSVC)
# BOOST_ALL_NO_LIB: Avoid the automatic linking of Boost libraries on Windows. Rather rely on explicit linking.
add_definitions(-D_USE_MATH_DEFINES -D_WIN32 -DBOOST_ALL_NO_LIB -DBOOST_USE_WINAPI_VERSION=0x601 -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
endif()
add_definitions(-DBOOST_ALL_NO_LIB -DBOOST_USE_WINAPI_VERSION=0x601 )
endif(MSVC)
endif(WIN32)
add_definitions(-DwxUSE_UNICODE -D_UNICODE -DUNICODE -DWXINTL_NO_GETTEXT_MACRO)
@ -234,7 +249,7 @@ if(SLIC3R_STATIC)
# set(Boost_USE_STATIC_RUNTIME ON)
endif()
#set(Boost_DEBUG ON)
# set(Boost_COMPILER "-vc120")
# set(Boost_COMPILER "-mgw81")
if(NOT WIN32)
# boost::process was introduced first in version 1.64.0
set(MINIMUM_BOOST_VERSION "1.64.0")

3
deps/CMakeLists.txt vendored
View File

@ -76,6 +76,9 @@ elseif (APPLE)
endif ()
include("deps-macos.cmake")
elseif (MINGW)
message(STATUS "Building for MinGW...")
include("deps-mingw.cmake")
else()
include("deps-linux.cmake")
endif()

76
deps/deps-mingw.cmake vendored Normal file
View File

@ -0,0 +1,76 @@
set(DEP_CMAKE_OPTS "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
set(DEP_BOOST_TOOLSET "gcc")
set(DEP_BITS 64)
find_package(Git REQUIRED)
# TODO make sure to build tbb with -flifetime-dse=1
include("deps-unix-common.cmake")
ExternalProject_Add(dep_boost
EXCLUDE_FROM_ALL 1
URL "https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz"
URL_HASH SHA256=882b48708d211a5f48e60b0124cf5863c1534cd544ecd0664bb534a4b5d506e9
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND bootstrap.bat
BUILD_COMMAND b2.exe
-j "${NPROC}"
--with-system
--with-filesystem
--with-thread
--with-log
--with-locale
--with-regex
"--prefix=${DESTDIR}/usr/local"
"address-model=${DEPS_BITS}"
"toolset=${DEP_BOOST_TOOLSET}"
link=static
define=BOOST_USE_WINAPI_VERSION=0x0502
variant=release
threading=multi
boost.locale.icu=off
"${DEP_BOOST_DEBUG}" release install
INSTALL_COMMAND "" # b2 does that already
)
ExternalProject_Add(dep_libcurl
EXCLUDE_FROM_ALL 1
URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz"
URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115
CMAKE_ARGS
-DBUILD_SHARED_LIBS=OFF
-DBUILD_TESTING=OFF
-DCURL_STATICLIB=ON
-DCURL_STATIC_CRT=ON
-DENABLE_THREADED_RESOLVER=ON
-DCURL_DISABLE_FTP=ON
-DCURL_DISABLE_LDAP=ON
-DCURL_DISABLE_LDAPS=ON
-DCURL_DISABLE_TELNET=ON
-DCURL_DISABLE_DICT=ON
-DCURL_DISABLE_FILE=ON
-DCURL_DISABLE_TFTP=ON
-DCURL_DISABLE_RTSP=ON
-DCURL_DISABLE_POP3=ON
-DCURL_DISABLE_IMAP=ON
-DCURL_DISABLE_SMTP=ON
-DCURL_DISABLE_GOPHER=ON
-DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
${DEP_CMAKE_OPTS}
)
ExternalProject_Add(dep_wxwidgets
EXCLUDE_FROM_ALL 1
GIT_REPOSITORY "https://github.com/prusa3d/wxWidgets"
GIT_TAG v3.1.1-patched
# URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2"
# URL_HASH SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e
# PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}\\wxwidgets-pngprefix.h" src\\png\\pngprefix.h
CMAKE_ARGS
-DBUILD_SHARED_LIBS=OFF
-DwxUSE_LIBPNG=builtin
-DwxUSE_ZLIB=builtin
-DwxUSE_OPENGL=ON
-DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
${DEP_CMAKE_OPTS}
)

View File

@ -1,6 +1,12 @@
# The unix common part expects DEP_CMAKE_OPTS to be set
if (MINGW)
set(TBB_MINGW_WORKAROUND "-flifetime-dse=1")
else ()
set(TBB_MINGW_WORKAROUND "")
endif ()
ExternalProject_Add(dep_tbb
EXCLUDE_FROM_ALL 1
URL "https://github.com/wjakob/tbb/archive/a0dc9bf76d0120f917b641ed095360448cabc85b.tar.gz"
@ -8,6 +14,7 @@ ExternalProject_Add(dep_tbb
CMAKE_ARGS
-DTBB_BUILD_SHARED=OFF
-DTBB_BUILD_TESTS=OFF
-DCMAKE_CXX_FLAGS=${TBB_MINGW_WORKAROUND}
-DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
${DEP_CMAKE_OPTS}
)

View File

@ -1 +1,2 @@
add_subdirectory(slabasebed)
add_subdirectory(slasupporttree)

View File

@ -5,6 +5,7 @@
#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>
@ -16,7 +17,7 @@ const std::string USAGE_STR = {
namespace Slic3r { namespace sla {
Contour3D create_base_pool(const Polygons &ground_layer,
const Polygons &holes = {},
const ExPolygons &holes = {},
const PoolConfig& cfg = PoolConfig());
Contour3D walls(const Polygon& floor_plate, const Polygon& ceiling,
@ -43,22 +44,22 @@ int main(const int argc, const char *argv[]) {
model.ReadSTLFile(argv[1]);
model.align_to_origin();
Polygons ground_slice;
ExPolygons ground_slice;
sla::base_plate(model, ground_slice, 0.1f);
if(ground_slice.empty()) return EXIT_FAILURE;
Polygon gndfirst; gndfirst = ground_slice.front();
sla::offset_with_breakstick_holes(gndfirst, 0.5, 10, 0.3);
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::PoolConfig cfg;
cfg.min_wall_height_mm = 0;
cfg.edge_radius_mm = 0;
mesh = sla::create_base_pool(ground_slice, {}, cfg);
mesh = sla::create_base_pool(to_polygons(ground_slice), {}, cfg);
bench.stop();

View File

@ -0,0 +1,2 @@
add_executable(slasupporttree slasupporttree.cpp)
target_link_libraries(slasupporttree libslic3r ${Boost_LIBRARIES} ${TBB_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})

View File

@ -0,0 +1,42 @@
#include <iostream>
#include <fstream>
#include <string>
#include <libslic3r/libslic3r.h>
#include <libslic3r/Model.hpp>
#include <libslic3r/Tesselate.hpp>
#include <libslic3r/ClipperUtils.hpp>
#include <libslic3r/SLA/SLAAutoSupports.hpp>
#include <libslic3r/SLA/SLASupportTree.hpp>
#include <libslic3r/SLAPrint.hpp>
#include <libslic3r/MTUtils.hpp>
#include <tbb/parallel_for.h>
#include <tbb/mutex.h>
#include <future>
const std::string USAGE_STR = {
"Usage: slasupporttree stlfilename.stl"
};
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;
}
DynamicPrintConfig config;
Model model = Model::read_from_file(argv[1], &config);
SLAPrint print;
print.apply(model, config);
print.process();
return EXIT_SUCCESS;
}

View File

@ -47,7 +47,7 @@ if (SLIC3R_GUI)
endif ()
endif ()
else ()
find_package(wxWidgets 3.1 REQUIRED COMPONENTS base core adv html gl)
find_package(wxWidgets 3.1 REQUIRED COMPONENTS html adv gl core base)
endif ()
if(UNIX)
@ -56,6 +56,9 @@ if (SLIC3R_GUI)
include(${wxWidgets_USE_FILE})
# list(REMOVE_ITEM wxWidgets_LIBRARIES oleacc)
message(STATUS "wx libs: ${wxWidgets_LIBRARIES}")
add_subdirectory(slic3r)
endif()
@ -65,12 +68,18 @@ endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/msw/PrusaSlicer.rc.in ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer.rc @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/msw/PrusaSlicer.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer.manifest @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/osx/Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist @ONLY)
if (MSVC)
if (WIN32)
add_library(PrusaSlicer SHARED PrusaSlicer.cpp PrusaSlicer.hpp)
else ()
add_executable(PrusaSlicer PrusaSlicer.cpp PrusaSlicer.hpp)
endif ()
if (NOT MSVC)
if (MINGW)
target_link_options(PrusaSlicer PUBLIC "-Wl,-allow-multiple-definition")
set_target_properties(PrusaSlicer PROPERTIES PREFIX "")
endif (MINGW)
if (NOT WIN32)
# Binary name on unix like systems (OSX, Linux)
set_target_properties(PrusaSlicer PROPERTIES OUTPUT_NAME "prusa-slicer")
endif ()
@ -91,11 +100,12 @@ endif ()
# Add the Slic3r GUI library, libcurl, OpenGL and GLU libraries.
if (SLIC3R_GUI)
# target_link_libraries(PrusaSlicer ws2_32 uxtheme setupapi libslic3r_gui ${wxWidgets_LIBRARIES})
target_link_libraries(PrusaSlicer libslic3r_gui ${wxWidgets_LIBRARIES})
# Configure libcurl and its dependencies OpenSSL & zlib
find_package(CURL REQUIRED)
if (NOT MSVC)
if (NOT WIN32)
# Required by libcurl
find_package(ZLIB REQUIRED)
endif()
@ -123,7 +133,7 @@ if (SLIC3R_GUI)
target_link_options(PrusaSlicer PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>")
target_link_libraries(PrusaSlicer user32.lib Setupapi.lib OpenGL32.Lib GlU32.Lib)
elseif (MINGW)
target_link_libraries(PrusaSlicer -lopengl32)
target_link_libraries(PrusaSlicer opengl32 ws2_32 uxtheme setupapi)
elseif (APPLE)
target_link_libraries(PrusaSlicer "-framework OpenGL")
else ()
@ -133,10 +143,16 @@ endif ()
# On Windows, a shim application is required to produce a console / non console version of the Slic3r application.
# Also the shim may load the Mesa software OpenGL renderer if the default renderer does not support OpenGL 2.0 and higher.
if (MSVC)
if (WIN32)
if (MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode")
endif()
add_executable(PrusaSlicer_app_gui WIN32 PrusaSlicer_app_msvc.cpp ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer.rc)
# Generate debug symbols even in release mode.
if(MSVC)
target_link_options(PrusaSlicer_app_gui PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>")
endif()
target_compile_definitions(PrusaSlicer_app_gui PRIVATE -DSLIC3R_WRAPPER_NOCONSOLE)
add_dependencies(PrusaSlicer_app_gui PrusaSlicer)
set_target_properties(PrusaSlicer_app_gui PROPERTIES OUTPUT_NAME "prusa-slicer")
@ -144,7 +160,9 @@ if (MSVC)
add_executable(PrusaSlicer_app_console PrusaSlicer_app_msvc.cpp ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer.rc)
# Generate debug symbols even in release mode.
if (MSVC)
target_link_options(PrusaSlicer_app_console PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>")
endif ()
target_compile_definitions(PrusaSlicer_app_console PRIVATE -DSLIC3R_WRAPPER_CONSOLE)
add_dependencies(PrusaSlicer_app_console PrusaSlicer)
set_target_properties(PrusaSlicer_app_console PROPERTIES OUTPUT_NAME "prusa-slicer-console")
@ -152,7 +170,7 @@ if (MSVC)
endif ()
# Link the resources dir to where Slic3r GUI expects it
if (MSVC)
if (WIN32)
if (CMAKE_CONFIGURATION_TYPES)
foreach (CONF ${CMAKE_CONFIGURATION_TYPES})
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${CONF}" WIN_CONF_OUTPUT_DIR)

View File

@ -651,7 +651,7 @@ std::string CLI::output_filepath(const Model &model, IO::ExportFormat format) co
return proposed_path.string();
}
#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__MINGW32__)
extern "C" {
__declspec(dllexport) int __stdcall slic3r_main(int argc, wchar_t **argv)
{

View File

@ -205,6 +205,8 @@ extern "C" {
Slic3rMainFunc slic3r_main = nullptr;
}
extern "C" {
#ifdef SLIC3R_WRAPPER_NOCONSOLE
int APIENTRY wWinMain(HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, PWSTR /* lpCmdLine */, int /* nCmdShow */)
{
@ -298,3 +300,4 @@ int wmain(int argc, wchar_t **argv)
// argc minus the trailing nullptr of the argv
return slic3r_main((int)argv_extended.size() - 1, argv_extended.data());
}
}

View File

@ -74,6 +74,10 @@ if (MSVC)
windows/unistd.cpp
windows/getopt.c
)
elseif (MINGW)
set(AVRDUDE_SOURCES ${AVRDUDE_SOURCES}
windows/utf8.c
)
endif()
add_executable(avrdude-conf-gen conf-generate.cpp)
@ -98,5 +102,7 @@ target_link_libraries(avrdude-slic3r avrdude)
if (WIN32)
target_compile_definitions(avrdude PRIVATE WIN32NATIVE=1)
if(MSVC)
target_include_directories(avrdude SYSTEM PRIVATE windows) # So that sources find the getopt.h windows drop-in
endif(MSVC)
endif()

View File

@ -30,7 +30,7 @@
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(_MSC_VER)
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.

View File

@ -38,6 +38,10 @@ struct ArgvUtf8 : std::vector<char*>
}
};
#endif
#ifdef _MSC_VER
int wmain(int argc_w, wchar_t *argv_w[])
{
ArgvUtf8 argv_utf8(argc_w, argv_w);

View File

@ -63,7 +63,7 @@ extern "C" {
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#ifdef _MSC_VER
#if defined(_MSC_VER) && defined(__clang__)
#include <stdint.h>
struct timezone;
struct timeval;

View File

@ -26,34 +26,30 @@ namespace igl
SortableRow(const T & data):data(data){};
bool operator<(const SortableRow & that) const
{
// Get reference so that I can use parenthesis
const SortableRow<T> & THIS = *this;
// Lexicographical
int minc = (THIS.data.size() < that.data.size()?
THIS.data.size() : that.data.size());
int minc = (this->data.size() < that.data.size()?
this->data.size() : that.data.size());
// loop over columns
for(int i = 0;i<minc;i++)
{
if(THIS.data(i) == that.data(i))
if(this->data(i) == that.data(i))
{
continue;
}
return THIS.data(i) < that.data(i);
return this->data(i) < that.data(i);
}
// All characters the same, comes done to length
return THIS.data.size()<that.data.size();
return this->data.size()<that.data.size();
};
bool operator==(const SortableRow & that) const
{
// Get reference so that I can use parenthesis
const SortableRow<T> & THIS = *this;
if(THIS.data.size() != that.data.size())
if(this->data.size() != that.data.size())
{
return false;
}
for(int i = 0;i<THIS.data.size();i++)
for(int i = 0;i<this->data.size();i++)
{
if(THIS.data(i) != that.data(i))
if(this->data(i) != that.data(i))
{
return false;
}

View File

@ -337,7 +337,15 @@ merge(const TMultiShape<PolygonImpl>& shapes)
//#define DISABLE_BOOST_SERIALIZE
//#define DISABLE_BOOST_UNSERIALIZE
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4244)
#pragma warning(disable: 4267)
#endif
// All other operators and algorithms are implemented with boost
#include <libnest2d/utils/boost_alg.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif // CLIPPER_BACKEND_HPP

View File

@ -133,8 +133,18 @@ protected:
PConfig m_pconf; // Placement configuration
TBin m_bin;
double m_bin_area;
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4244)
#pragma warning(disable: 4267)
#endif
SpatIndex m_rtree; // spatial index for the normal (bigger) objects
SpatIndex m_smallsrtree; // spatial index for only the smaller items
#ifdef _MSC_VER
#pragma warning(pop)
#endif
double m_norm; // A coefficient to scale distances
MultiPolygon m_merged_pile; // The already merged pile (vector of items)
Box m_pilebb; // The bounding box of the merged pile.

View File

@ -5,6 +5,10 @@ include(PrecompiledHeader)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libslic3r_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/libslic3r_version.h @ONLY)
if (MINGW)
add_compile_options(-Wa,-mbig-obj)
endif ()
add_library(libslic3r STATIC
pchheader.cpp
pchheader.hpp

View File

@ -123,10 +123,25 @@ public:
// For a multi-material print, the printing extruders are ordered in the order they shall be primed.
const std::vector<unsigned int>& all_extruders() const { return m_all_printing_extruders; }
template<class Self> static auto tools_for_layer(Self& self, coordf_t print_z) -> decltype (*self.m_layer_tools.begin())
{
auto it_layer_tools = std::lower_bound(self.m_layer_tools.begin(), self.m_layer_tools.end(), LayerTools(print_z - EPSILON));
assert(it_layer_tools != self.m_layer_tools.end());
coordf_t dist_min = std::abs(it_layer_tools->print_z - print_z);
for (++ it_layer_tools; it_layer_tools != self.m_layer_tools.end(); ++it_layer_tools) {
coordf_t d = std::abs(it_layer_tools->print_z - print_z);
if (d >= dist_min)
break;
dist_min = d;
}
-- it_layer_tools;
assert(dist_min < EPSILON);
return *it_layer_tools;
}
// Find LayerTools with the closest print_z.
LayerTools& tools_for_layer(coordf_t print_z);
const LayerTools& tools_for_layer(coordf_t print_z) const
{ return *const_cast<const LayerTools*>(&const_cast<const ToolOrdering*>(this)->tools_for_layer(print_z)); }
LayerTools& tools_for_layer(coordf_t print_z) { return tools_for_layer(*this, print_z); }
const LayerTools& tools_for_layer(coordf_t print_z) const { return tools_for_layer(*this, print_z); }
const LayerTools& front() const { return m_layer_tools.front(); }
const LayerTools& back() const { return m_layer_tools.back(); }

View File

@ -3282,7 +3282,7 @@ CLIMiscConfigDef::CLIMiscConfigDef()
def->tooltip = L("Messages with severity lower or eqal to the loglevel will be printed out. 0:trace, 1:debug, 2:info, 3:warning, 4:error, 5:fatal");
def->min = 0;
#if defined(_MSC_VER) && defined(SLIC3R_GUI)
#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(SLIC3R_GUI)
def = this->add("sw_renderer", coBool);
def->label = L("Render with a software renderer");
def->tooltip = L("Render with a software renderer. The bundled MESA software renderer is loaded instead of the default OpenGL driver.");

View File

@ -1,5 +1,5 @@
#include "igl/random_points_on_mesh.h"
#include "igl/AABB.h"
//#include "igl/random_points_on_mesh.h"
//#include "igl/AABB.h"
#include <tbb/parallel_for.h>

View File

@ -85,7 +85,7 @@ using Portion = std::tuple<double, double>;
// Set this to true to enable full parallelism in this module.
// Only the well tested parts will be concurrent if this is set to false.
const constexpr bool USE_FULL_CONCURRENCY = false;
const constexpr bool USE_FULL_CONCURRENCY = true;
template<bool> struct _ccr {};
@ -948,6 +948,8 @@ public:
{
if (meshcache_valid) return meshcache;
std::cout << "merging mesh" << std::endl;
Contour3D merged;
for (auto &head : m_heads) {
@ -1194,7 +1196,7 @@ class SLASupportTree::Algorithm {
// Now a and b vectors are perpendicular to v and to each other.
// Together they define the plane where we have to iterate with the
// given angles in the 'phis' vector
ccr_par::enumerate(phis.begin(), phis.end(),
ccr_seq::enumerate(phis.begin(), phis.end(),
[&hits, &m, sd, r_pin, r_back, s, a, b, c]
(double phi, size_t i)
{
@ -1297,7 +1299,7 @@ class SLASupportTree::Algorithm {
// Hit results
std::array<HitResult, SAMPLES> hits;
ccr_par::enumerate(phis.begin(), phis.end(),
ccr_seq::enumerate(phis.begin(), phis.end(),
[&m, a, b, sd, dir, r, s, ins_check, &hits]
(double phi, size_t i)
{
@ -2448,7 +2450,7 @@ public:
}
}
void merge_result() { m_result.merge_and_cleanup(); }
void merge_result() { /*m_result.merge_and_cleanup();*/ }
};
bool SLASupportTree::generate(const std::vector<SupportPoint> &support_points,
@ -2588,7 +2590,7 @@ SLASupportTree::SLASupportTree(double gnd_lvl): m_impl(new Impl()) {
const TriangleMesh &SLASupportTree::merged_mesh() const
{
return get().merged_mesh();
return m_impl->merged_mesh();
}
void SLASupportTree::merged_mesh_with_pad(TriangleMesh &outmesh) const {

View File

@ -306,6 +306,7 @@ PointSet normals(const PointSet& points,
PointSet ret(range.size(), 3);
// for (size_t ridx = 0; ridx < range.size(); ++ridx)
tbb::parallel_for(size_t(0), range.size(),
[&ret, &range, &mesh, &points, thr, eps](size_t ridx)
{

View File

@ -16,6 +16,12 @@
// For geometry algorithms with native Clipper types (no copies and conversions)
#include <libnest2d/backends/clipper/geometries.hpp>
#define SLAPRINT_DO_BENCHMARK
#ifdef SLAPRINT_DO_BENCHMARK
#include <libnest2d/tools/benchmark.h>
#endif
//#include <tbb/spin_mutex.h>//#include "tbb/mutex.h"
#include "I18N.hpp"
@ -948,20 +954,20 @@ void SLAPrint::process()
throw_if_canceled();
// Create the unified mesh
auto rc = SlicingStatus::RELOAD_SCENE;
// auto rc = SlicingStatus::RELOAD_SCENE;
// This is to prevent "Done." being displayed during merged_mesh()
m_report_status(*this, -1, L("Visualizing supports"));
po.m_supportdata->support_tree_ptr->merged_mesh();
// m_report_status(*this, -1, L("Visualizing supports"));
// po.m_supportdata->support_tree_ptr->merged_mesh();
BOOST_LOG_TRIVIAL(debug) << "Processed support point count "
<< po.m_supportdata->support_points.size();
// Check the mesh for later troubleshooting.
if(po.support_mesh().empty())
BOOST_LOG_TRIVIAL(warning) << "Support mesh is empty";
// if(po.support_mesh().empty())
// BOOST_LOG_TRIVIAL(warning) << "Support mesh is empty";
m_report_status(*this, -1, L("Visualizing supports"), rc);
// m_report_status(*this, -1, L("Visualizing supports"), rc);
};
// This step generates the sla base pad
@ -970,6 +976,10 @@ void SLAPrint::process()
// and before the supports had been sliced. (or the slicing has to be
// repeated)
std::cout << "Should only merge mesh after this" << std::endl;
po.m_supportdata->support_tree_ptr->merged_mesh();
m_report_status(*this, -1, L("Visualizing supports"), SlicingStatus::RELOAD_SCENE);
if(po.m_config.pad_enable.getBool())
{
// Get the distilled pad configuration from the config
@ -1429,7 +1439,7 @@ void SLAPrint::process()
if(canceled()) return;
// Sequential version (for testing)
// for(unsigned l = 0; l < lvlcnt; ++l) process_level(l);
// for(unsigned l = 0; l < lvlcnt; ++l) lvlfn(l);
// Print all the layers in parallel
tbb::parallel_for<unsigned, decltype(lvlfn)>(0, lvlcnt, lvlfn);
@ -1446,44 +1456,48 @@ void SLAPrint::process()
using slaposFn = std::function<void(SLAPrintObject&)>;
using slapsFn = std::function<void(void)>;
std::array<slaposFn, slaposCount> pobj_program =
slaposFn pobj_program[] =
{
slice_model,
support_points,
support_tree,
base_pool,
slice_supports
slice_model, support_points, support_tree, base_pool, slice_supports
};
std::array<slapsFn, slapsCount> print_program =
{
merge_slices_and_eval_stats,
rasterize
// We want to first process all objects...
std::vector<SLAPrintObjectStep> level1_obj_steps = {
slaposObjectSlice, slaposSupportPoints, slaposSupportTree, slaposBasePool
};
// and then slice all supports to allow preview to be displayed ASAP
std::vector<SLAPrintObjectStep> level2_obj_steps = {
slaposSliceSupports
};
slapsFn print_program[] = { merge_slices_and_eval_stats, rasterize };
SLAPrintStep print_steps[] = { slapsMergeSlicesAndEval, slapsRasterize };
double st = min_objstatus;
unsigned incr = 0;
BOOST_LOG_TRIVIAL(info) << "Start slicing process.";
// TODO: this loop could run in parallel but should not exhaust all the CPU
// power available
// Calculate the support structures first before slicing the supports,
// so that the preview will get displayed ASAP for all objects.
std::vector<SLAPrintObjectStep> step_ranges = {slaposObjectSlice,
slaposSliceSupports,
slaposCount};
#ifdef SLAPRINT_DO_BENCHMARK
Benchmark bench;
#else
struct {
void start() {} void stop() {} double getElapsedSec() { return .0; }
} bench;
#endif
for (size_t idx_range = 0; idx_range + 1 < step_ranges.size(); ++idx_range) {
std::array<double, slaposCount + slapsCount> step_times {};
auto apply_steps_on_objects =
[this, &st, ostepd, &pobj_program, &step_times, &bench]
(const std::vector<SLAPrintObjectStep> &steps)
{
unsigned incr = 0;
for (SLAPrintObject *po : m_objects) {
BOOST_LOG_TRIVIAL(info)
<< "Slicing object " << po->model_object()->name;
for (SLAPrintObjectStep currentstep : steps) {
for (int s = int(step_ranges[idx_range]);
s < int(step_ranges[idx_range + 1]);
++s) {
auto currentstep = static_cast<SLAPrintObjectStep>(s);
Benchmark bench;
// Cancellation checking. Each step will check for
// cancellation on its own and return earlier gracefully.
@ -1493,12 +1507,12 @@ void SLAPrint::process()
st += incr * ostepd;
if (po->m_stepmask[currentstep]
&& po->set_started(currentstep)) {
m_report_status(*this,
st,
OBJ_STEP_LABELS(currentstep));
if (po->m_stepmask[currentstep] && po->set_started(currentstep)) {
m_report_status(*this, st, OBJ_STEP_LABELS(currentstep));
bench.start();
pobj_program[currentstep](*po);
bench.stop();
step_times[currentstep] += bench.getElapsedSec();
throw_if_canceled();
po->set_done(currentstep);
}
@ -1506,26 +1520,27 @@ void SLAPrint::process()
incr = OBJ_STEP_LEVELS[currentstep];
}
}
}
std::array<SLAPrintStep, slapsCount> printsteps = {
slapsMergeSlicesAndEval, slapsRasterize
};
apply_steps_on_objects(level1_obj_steps);
apply_steps_on_objects(level2_obj_steps);
SLAPrintStep printsteps[] = { slapsMergeSlicesAndEval, slapsRasterize };
// this would disable the rasterization step
// m_stepmask[slapsRasterize] = false;
// std::fill(m_stepmask.begin(), m_stepmask.end(), false);
double pstd = (100 - max_objstatus) / 100.0;
st = max_objstatus;
for(size_t s = 0; s < print_program.size(); ++s) {
auto currentstep = printsteps[s];
for(SLAPrintStep currentstep : printsteps) {
throw_if_canceled();
if(m_stepmask[currentstep] && set_started(currentstep))
{
if (m_stepmask[currentstep] && set_started(currentstep)) {
m_report_status(*this, st, PRINT_STEP_LABELS(currentstep));
bench.start();
print_program[currentstep]();
bench.stop();
step_times[slaposCount + currentstep] += bench.getElapsedSec();
throw_if_canceled();
set_done(currentstep);
}
@ -1535,6 +1550,21 @@ void SLAPrint::process()
// If everything vent well
m_report_status(*this, 100, L("Slicing done"));
#ifdef SLAPRINT_DO_BENCHMARK
std::string csvbenchstr;
for (size_t i = 0; i < size_t(slaposCount); ++i)
csvbenchstr += OBJ_STEP_LABELS(i) + ";";
for (size_t i = 0; i < size_t(slapsCount); ++i)
csvbenchstr += PRINT_STEP_LABELS(i) + ";";
csvbenchstr += "\n";
for (double t : step_times) csvbenchstr += std::to_string(t) + ";";
std::cout << "Performance stats: \n" << csvbenchstr << std::endl;
#endif
}
bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_option_key> &opt_keys, bool &invalidate_all_model_objects)

View File

@ -11,6 +11,7 @@
#include <wx/sizer.h>
#include <wx/slider.h>
#include <wx/menu.h>
#include <wx/wx.h>
#include <vector>
#include <set>

View File

@ -2,7 +2,7 @@
#define slic3r_Utils_Time_hpp_
#include <string>
#include <time.h>
#include <ctime>
namespace Slic3r {
namespace Utils {