issue #1027 use unicode filepaths

This commit is contained in:
Sebastian Hoogen
2014-09-21 23:45:32 +02:00
committed by wmayer
parent 7db2cdc008
commit 01cf0f5872
28 changed files with 396 additions and 243 deletions

View File

@@ -143,13 +143,15 @@ extern const char* BRepBuilderAPI_FaceErrorText(BRepBuilderAPI_FaceError fe);
/* module functions */
static PyObject * open(PyObject *self, PyObject *args)
{
const char* Name;
if (!PyArg_ParseTuple(args, "s",&Name))
return NULL;
char* Name;
if (!PyArg_ParseTuple(args, "et","utf-8",&Name))
return NULL;
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
PY_TRY {
//Base::Console().Log("Open in Part with %s",Name);
Base::FileInfo file(Name);
Base::FileInfo file(EncodedName.c_str());
// extract ending
if (file.extension() == "")
@@ -159,7 +161,7 @@ static PyObject * open(PyObject *self, PyObject *args)
// create new document and add Import feature
App::Document *pcDoc = App::GetApplication().newDocument("Unnamed");
#if 1
ImportStepParts(pcDoc,Name);
ImportStepParts(pcDoc,EncodedName.c_str());
#else
Part::ImportStep *pcFeature = (Part::ImportStep *)pcDoc->addObject("Part::ImportStep",file.fileNamePure().c_str());
pcFeature->FileName.setValue(Name);
@@ -169,14 +171,14 @@ static PyObject * open(PyObject *self, PyObject *args)
#if 1
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
App::Document *pcDoc = App::GetApplication().newDocument("Unnamed");
ImportIgesParts(pcDoc,Name);
ImportIgesParts(pcDoc,EncodedName.c_str());
pcDoc->recompute();
}
#endif
else {
try {
TopoShape shape;
shape.read(Name);
shape.read(EncodedName.c_str());
// create new document set loaded shape
App::Document *pcDoc = App::GetApplication().newDocument(file.fileNamePure().c_str());
@@ -197,14 +199,16 @@ static PyObject * open(PyObject *self, PyObject *args)
/* module functions */
static PyObject * insert(PyObject *self, PyObject *args)
{
const char* Name;
char* Name;
const char* DocName;
if (!PyArg_ParseTuple(args, "ss",&Name,&DocName))
return NULL;
if (!PyArg_ParseTuple(args, "ets","utf-8",&Name,&DocName))
return NULL;
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
PY_TRY {
//Base::Console().Log("Insert in Part with %s",Name);
Base::FileInfo file(Name);
Base::FileInfo file(EncodedName.c_str());
// extract ending
if (file.extension() == "")
@@ -216,7 +220,7 @@ static PyObject * insert(PyObject *self, PyObject *args)
if (file.hasExtension("stp") || file.hasExtension("step")) {
#if 1
ImportStepParts(pcDoc,Name);
ImportStepParts(pcDoc,EncodedName.c_str());
#else
// add Import feature
Part::ImportStep *pcFeature = (Part::ImportStep *)pcDoc->addObject("Part::ImportStep",file.fileNamePure().c_str());
@@ -226,14 +230,14 @@ static PyObject * insert(PyObject *self, PyObject *args)
}
#if 1
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
ImportIgesParts(pcDoc,Name);
ImportIgesParts(pcDoc,EncodedName.c_str());
pcDoc->recompute();
}
#endif
else {
try {
TopoShape shape;
shape.read(Name);
shape.read(EncodedName.c_str());
Part::Feature *object = static_cast<Part::Feature *>(pcDoc->addObject
("Part::Feature",file.fileNamePure().c_str()));
@@ -253,9 +257,11 @@ static PyObject * insert(PyObject *self, PyObject *args)
static PyObject * exporter(PyObject *self, PyObject *args)
{
PyObject* object;
const char* filename;
if (!PyArg_ParseTuple(args, "Os",&object,&filename))
char* Name;
if (!PyArg_ParseTuple(args, "Oet",&object,"utf-8",&Name))
return NULL;
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
BRep_Builder builder;
TopoDS_Compound comp;
@@ -280,7 +286,7 @@ static PyObject * exporter(PyObject *self, PyObject *args)
}
TopoShape shape(comp);
shape.write(filename);
shape.write(EncodedName.c_str());
} PY_CATCH_OCC;
@@ -290,12 +296,14 @@ static PyObject * exporter(PyObject *self, PyObject *args)
/* module functions */
static PyObject * read(PyObject *self, PyObject *args)
{
const char* Name;
if (!PyArg_ParseTuple(args, "s",&Name))
return NULL;
char* Name;
if (!PyArg_ParseTuple(args, "et","utf-8",&Name))
return NULL;
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
PY_TRY {
TopoShape* shape = new TopoShape();
shape->read(Name);
shape->read(EncodedName.c_str());
return new TopoShapePy(shape);
} PY_CATCH_OCC;
}