mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 04:45:57 +08:00
Fixes for Windows
This commit is contained in:
parent
9ddc0ff451
commit
2ad26fc6a7
@ -95,6 +95,7 @@ sub load {
|
||||
|
||||
# legacy syntax of load()
|
||||
my $config = $class->new;
|
||||
|
||||
$config->_load($file);
|
||||
return $config;
|
||||
}
|
||||
|
@ -10,9 +10,11 @@
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/nowide/cenv.hpp>
|
||||
#include <boost/nowide/fstream.hpp>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <string.h>
|
||||
@ -387,7 +389,8 @@ ConfigBase::load(const std::string &file)
|
||||
{
|
||||
namespace pt = boost::property_tree;
|
||||
pt::ptree tree;
|
||||
pt::read_ini(file, tree);
|
||||
boost::nowide::ifstream ifs(file);
|
||||
pt::read_ini(ifs, tree);
|
||||
BOOST_FOREACH(const pt::ptree::value_type &v, tree) {
|
||||
try {
|
||||
t_config_option_key opt_key = v.first;
|
||||
@ -403,8 +406,8 @@ void
|
||||
ConfigBase::save(const std::string &file) const
|
||||
{
|
||||
using namespace std;
|
||||
ofstream c;
|
||||
c.open(file.c_str(), ios::out | ios::trunc);
|
||||
boost::nowide::ofstream c;
|
||||
c.open(file, ios::out | ios::trunc);
|
||||
|
||||
{
|
||||
time_t now;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/nowide/fstream.hpp>
|
||||
|
||||
#define TINYOBJLOADER_IMPLEMENTATION
|
||||
#include "tiny_obj_loader.h"
|
||||
@ -12,7 +13,6 @@ namespace Slic3r { namespace IO {
|
||||
bool
|
||||
STL::read(std::string input_file, TriangleMesh* mesh)
|
||||
{
|
||||
// TODO: encode file name
|
||||
// TODO: check that file exists
|
||||
|
||||
try {
|
||||
@ -81,7 +81,8 @@ OBJ::read(std::string input_file, Model* model)
|
||||
std::vector<tinyobj::shape_t> shapes;
|
||||
std::vector<tinyobj::material_t> materials;
|
||||
std::string err;
|
||||
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, input_file.c_str());
|
||||
boost::nowide::ifstream ifs(input_file);
|
||||
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, &ifs);
|
||||
|
||||
if (!err.empty()) { // `err` may contain warning message.
|
||||
std::cerr << err << std::endl;
|
||||
@ -153,7 +154,7 @@ POV::write(TriangleMesh& mesh, std::string output_file)
|
||||
mesh2.center_around_origin();
|
||||
|
||||
using namespace std;
|
||||
ofstream pov;
|
||||
boost::nowide::ofstream pov;
|
||||
pov.open(output_file.c_str(), ios::out | ios::trunc);
|
||||
for (int i = 0; i < mesh2.stl.stats.number_of_facets; ++i) {
|
||||
const stl_facet &f = mesh2.stl.facet_start[i];
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/nowide/fstream.hpp>
|
||||
#include <boost/nowide/iostream.hpp>
|
||||
#include <expat/expat.h>
|
||||
|
||||
@ -455,7 +456,7 @@ AMF::read(std::string input_file, Model* model)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::fstream fin(input_file.c_str(), std::ios::in);
|
||||
boost::nowide::ifstream fin(input_file, std::ios::in);
|
||||
if (!fin.is_open()) {
|
||||
boost::nowide::cerr << "Cannot open file: " << input_file << std::endl;
|
||||
return false;
|
||||
@ -468,8 +469,9 @@ AMF::read(std::string input_file, Model* model)
|
||||
|
||||
char buff[8192];
|
||||
bool result = false;
|
||||
while (fin.read(buff, sizeof(buff))) {
|
||||
if (fin.fail()) {
|
||||
while (!fin.eof()) {
|
||||
fin.read(buff, sizeof(buff));
|
||||
if (fin.bad()) {
|
||||
printf("AMF parser: Read error\n");
|
||||
break;
|
||||
}
|
||||
@ -498,12 +500,12 @@ AMF::write(Model& model, std::string output_file)
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
ofstream file;
|
||||
boost::nowide::ofstream file;
|
||||
file.open(output_file, ios::out | ios::trunc);
|
||||
|
||||
file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl
|
||||
<< "<amf unit=\"millimeter\">" << endl
|
||||
<< "<metadata type=\"cad\">Slic3r " << SLIC3R_VERSION << "</metadata>" << endl;
|
||||
<< " <metadata type=\"cad\">Slic3r " << SLIC3R_VERSION << "</metadata>" << endl;
|
||||
|
||||
for (const auto &material : model.materials) {
|
||||
if (material.first.empty())
|
||||
@ -597,7 +599,7 @@ AMF::write(Model& model, std::string output_file)
|
||||
<< " <instance objectid=\"" << object_id << "\">" << endl
|
||||
<< " <deltax>" << instance->offset.x + object->origin_translation.x << "</deltax>" << endl
|
||||
<< " <deltay>" << instance->offset.y + object->origin_translation.y << "</deltay>" << endl
|
||||
<< " <rz>%" << instance->rotation << "</rz>" << endl
|
||||
<< " <rz>" << instance->rotation << "</rz>" << endl
|
||||
<< " <scale>" << instance->scaling_factor << "</scale>" << endl
|
||||
<< " </instance>" << endl;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user