Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
David Cazier
CGoGN
Commits
f831db2e
Commit
f831db2e
authored
Jul 13, 2015
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
schnapps: resolve pb of accent in path
parent
ab151030
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
7 deletions
+44
-7
SCHNApps/Plugins/surface_import/src/surface_import.cpp
SCHNApps/Plugins/surface_import/src/surface_import.cpp
+5
-5
SCHNApps/include/plugin.h
SCHNApps/include/plugin.h
+14
-2
SCHNApps/include/schnapps.h
SCHNApps/include/schnapps.h
+6
-0
SCHNApps/src/schnapps.cpp
SCHNApps/src/schnapps.cpp
+19
-0
No files found.
SCHNApps/Plugins/surface_import/src/surface_import.cpp
View file @
f831db2e
...
...
@@ -33,19 +33,20 @@ bool Surface_Import_Plugin::enable()
MapHandlerGen
*
Surface_Import_Plugin
::
importMeshFromFile
(
const
QString
&
nameOfFile
)
{
QString
fileName
=
SCHNApps
::
noBackSlash
(
nameOfFile
);
QFileInfo
fi
(
fileName
);
if
(
fi
.
exists
())
{
MapHandlerGen
*
mhg
=
m_schnapps
->
addMap
(
fi
.
baseName
(),
2
);
MapHandlerGen
*
mhg
=
m_schnapps
->
addMap
(
SCHNApps
::
forceASCII
(
fi
.
baseName
()
)
,
2
);
if
(
mhg
)
{
MapHandler
<
PFP2
>*
mh
=
static_cast
<
MapHandler
<
PFP2
>*>
(
mhg
);
PFP2
::
MAP
*
map
=
mh
->
getMap
();
std
::
vector
<
std
::
string
>
attrNames
;
Algo
::
Surface
::
Import
::
importMesh
<
PFP2
>
(
*
map
,
fileName
.
to
StdString
(),
attrNames
);
Algo
::
Surface
::
Import
::
importMesh
<
PFP2
>
(
*
map
,
SCHNApps
::
nice
StdString
(
fileName
),
attrNames
);
for
(
unsigned
int
orbit
=
VERTEX
;
orbit
<=
VOLUME
;
orbit
++
)
{
...
...
@@ -83,9 +84,7 @@ MapHandlerGen* Surface_Import_Plugin::importImageFromFile(const QString& nameOfF
QFileInfo
fi
(
fileName
);
if
(
fi
.
exists
())
{
pythonRecording
(
"importImageFromFile"
,
fi
.
baseName
(),
fileName
);
MapHandlerGen
*
mhg
=
m_schnapps
->
addMap
(
fi
.
baseName
(),
2
);
MapHandlerGen
*
mhg
=
m_schnapps
->
addMap
(
SCHNApps
::
forceASCII
(
fi
.
baseName
()),
2
);
if
(
mhg
)
{
MapHandler
<
PFP2
>*
mh
=
static_cast
<
MapHandler
<
PFP2
>*>
(
mhg
);
...
...
@@ -122,6 +121,7 @@ MapHandlerGen* Surface_Import_Plugin::importImageFromFile(const QString& nameOfF
mh
->
registerAttribute
(
color
);
}
pythonRecording
(
"importImageFromFile"
,
mhg
->
getName
(),
fileName
);
return
mhg
;
}
else
...
...
SCHNApps/include/plugin.h
View file @
f831db2e
...
...
@@ -89,9 +89,21 @@ inline T pyR_stringify(T v)
template
<
>
inline
QString
pyR_stringify
(
QString
v
)
{
return
"
\"
"
+
v
+
"
\"
"
;
}
// test if v containe non ascii char
bool
needDecode
=
false
;
int
i
=
0
;
while
(
!
needDecode
&&
(
i
<
v
.
size
()))
{
if
(
v
[
i
].
unicode
()
>
127
)
needDecode
=
true
;
++
i
;
}
if
(
needDecode
)
return
"
\"
"
+
v
+
"
\"
.decode('latin-1')"
;
else
return
"
\"
"
+
v
+
"
\"
"
;
}
template
<
typename
T1
>
...
...
SCHNApps/include/schnapps.h
View file @
f831db2e
...
...
@@ -415,6 +415,12 @@ public:
/// replace \ by / in file path for window
static
QString
noBackSlash
(
const
QString
&
name
);
/// transform QString in std::string with
static
std
::
string
niceStdString
(
const
QString
&
qstr
);
/// force QString contain to be ascii (non ascii char are replaced by '_')
static
QString
forceASCII
(
const
QString
&
qstr
);
signals:
void
cameraAdded
(
Camera
*
camera
);
...
...
SCHNApps/src/schnapps.cpp
View file @
f831db2e
...
...
@@ -1084,6 +1084,25 @@ QString SCHNApps::noBackSlash(const QString& name)
#endif
}
std
::
string
SCHNApps
::
niceStdString
(
const
QString
&
qstr
)
{
return
std
::
string
(
qstr
.
toLocal8Bit
().
data
());
}
QString
SCHNApps
::
forceASCII
(
const
QString
&
qstr
)
{
QString
str
(
qstr
);
for
(
QString
::
iterator
it
=
str
.
begin
();
it
!=
str
.
end
();
++
it
)
{
if
(
it
->
unicode
()
>
127
)
*
it
=
'_'
;
}
return
str
;
}
void
SCHNApps
::
setPythonPath
(
const
QString
&
path
)
{
m_pyPathFile
=
SCHNApps
::
noBackSlash
(
path
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment