Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenMesh
openmesh-python
Commits
1154c68b
Commit
1154c68b
authored
Jun 12, 2018
by
Alexander Dielen
Browse files
added texture index functions
parent
2f35a035
Pipeline
#7197
passed with stages
in 5 minutes and 57 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/InputOutput.cc
View file @
1154c68b
...
...
@@ -22,6 +22,7 @@ void def_read_mesh(py::module& m, const char *_name) {
bool
_edge_color
,
bool
_face_normal
,
bool
_face_color
,
bool
_face_texture_index
,
bool
_color_alpha
,
bool
_color_float
)
...
...
@@ -66,11 +67,14 @@ void def_read_mesh(py::module& m, const char *_name) {
options
+=
OM
::
IO
::
Options
::
FaceColor
;
mesh
.
request_face_colors
();
}
if
(
_face_texture_index
)
{
mesh
.
request_face_texture_index
();
}
if
(
_color_alpha
)
options
+=
OM
::
IO
::
Options
::
ColorAlpha
;
if
(
_color_float
)
options
+=
OM
::
IO
::
Options
::
ColorFloat
;
const
bool
ok
=
OM
::
IO
::
read_mesh
(
mesh
,
_filename
,
options
);
const
bool
ok
=
OM
::
IO
::
read_mesh
(
mesh
,
_filename
,
options
);
if
(
!
ok
)
{
const
std
::
string
msg
=
"File could not be read: "
+
_filename
;
...
...
@@ -120,6 +124,7 @@ void def_read_mesh(py::module& m, const char *_name) {
py
::
arg
(
"edge_color"
)
=
false
,
py
::
arg
(
"face_normal"
)
=
false
,
py
::
arg
(
"face_color"
)
=
false
,
py
::
arg
(
"face_texture_index"
)
=
false
,
py
::
arg
(
"color_alpha"
)
=
false
,
py
::
arg
(
"color_float"
)
=
false
);
...
...
src/Mesh.hh
View file @
1154c68b
...
...
@@ -469,6 +469,7 @@ void expose_mesh(py::module& m, const char *_name) {
typedef
typename
Mesh
::
TexCoord1D
TexCoord1D
;
typedef
typename
Mesh
::
TexCoord2D
TexCoord2D
;
typedef
typename
Mesh
::
TexCoord3D
TexCoord3D
;
typedef
typename
Mesh
::
TextureIndex
TextureIndex
;
//======================================================================
// KernelT Function Pointers
...
...
@@ -801,6 +802,33 @@ void expose_mesh(py::module& m, const char *_name) {
.
def
(
"sedges"
,
sedges
)
.
def
(
"sfaces"
,
sfaces
)
.
def
(
"texture_index"
,
[](
Mesh
&
_self
,
OM
::
FaceHandle
_h
)
{
if
(
!
_self
.
has_face_texture_index
())
_self
.
request_face_texture_index
();
return
_self
.
texture_index
(
_h
);
})
.
def
(
"set_texture_index"
,
[](
Mesh
&
_self
,
OM
::
FaceHandle
_h
,
TextureIndex
_idx
)
{
if
(
!
_self
.
has_face_texture_index
())
_self
.
request_face_texture_index
();
_self
.
set_texture_index
(
_h
,
_idx
);
})
.
def
(
"texture_name"
,
[](
Mesh
&
_self
,
TextureIndex
_idx
)
{
OM
::
MPropHandleT
<
std
::
map
<
TextureIndex
,
std
::
string
>
>
prop
;
if
(
_self
.
get_property_handle
(
prop
,
"TextureMapping"
))
{
const
auto
map
=
_self
.
property
(
prop
);
if
(
map
.
count
(
_idx
)
==
0
)
{
throw
py
::
index_error
();
}
else
{
return
map
.
at
(
_idx
);
}
}
else
{
PyErr_SetString
(
PyExc_RuntimeError
,
"Mesh has no textures."
);
throw
py
::
error_already_set
();
}
})
//======================================================================
// BaseKernel
//======================================================================
...
...
Write
Preview
Supports
Markdown
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