Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenMesh
OpenMesh
Commits
229ba743
Commit
229ba743
authored
Nov 27, 2018
by
Jan Möbius
Browse files
Merge branch 'PLY_istream_fix' into 'master'
Ply istream fix Closes #46 See merge request
!192
parents
460db33f
56dc45f0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Doc/changelog.docu
View file @
229ba743
...
...
@@ -18,6 +18,7 @@
<ul>
<li>PLY Reader: Allowing the PLY reader to read custom face ( Thanks to morgan Leborgne for the patch)</li>
<li>PLY Reader: Fixed endless loop on unknown property list type</li>
<li>PLY Reader: Fix hang when reading directly from istream (Thanks to Paul Loré for the patch)</li>
<li>OM Writer/Reader: Update file format version to 2.0. Older files can still be read, but older OpenMesh versions cannot read new format.</li>
<li>OM Writer/Reader: Fixed inconsistent writing/reading of edge properties</li>
<li>OM Writer/Reader: Add option to store status</li>
...
...
src/OpenMesh/Core/IO/reader/PLYReader.cc
View file @
229ba743
...
...
@@ -135,6 +135,14 @@ bool _PLYReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt) {
return
false
;
}
// Reparse the header
if
(
!
can_u_read
(
_in
))
{
omerr
()
<<
"[PLYReader] : Unable to parse header
\n
"
;
return
false
;
}
// filter relevant options for reading
bool
swap
=
_opt
.
check
(
Options
::
Swap
);
...
...
@@ -281,12 +289,6 @@ void _PLYReader_::readCustomProperty(std::istream& _in, BaseImporter& _bi, Handl
bool
_PLYReader_
::
read_ascii
(
std
::
istream
&
_in
,
BaseImporter
&
_bi
,
const
Options
&
_opt
)
const
{
// Reparse the header
if
(
!
can_u_read
(
_in
))
{
omerr
()
<<
"[PLYReader] : Unable to parse header
\n
"
;
return
false
;
}
unsigned
int
i
,
j
,
k
,
l
,
idx
;
unsigned
int
nV
;
OpenMesh
::
Vec3f
v
,
n
;
...
...
@@ -507,12 +509,6 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
bool
_PLYReader_
::
read_binary
(
std
::
istream
&
_in
,
BaseImporter
&
_bi
,
bool
/*_swap*/
,
const
Options
&
_opt
)
const
{
// Reparse the header
if
(
!
can_u_read
(
_in
))
{
omerr
()
<<
"[PLYReader] : Unable to parse header
\n
"
;
return
false
;
}
OpenMesh
::
Vec3f
v
,
n
;
// Vertex
OpenMesh
::
Vec2f
t
;
// TexCoords
BaseImporter
::
VHandles
vhandles
;
...
...
src/Unittests/unittests_read_write_OBJ.cc
View file @
229ba743
...
...
@@ -499,4 +499,88 @@ TEST_F(OpenMeshReadWriteOBJ, ReadWriteReadSimpleOBJ) {
EXPECT_EQ
(
1
,
mesh2
.
normal
(
mesh2
.
vertex_handle
(
7
))[
2
]
)
<<
"Wrong vertex normal at vertex 7 component 2"
;
}
TEST_F
(
OpenMeshReadWriteOBJ
,
FaceTexCoordTest
)
{
mesh_
.
clear
();
mesh_
.
request_vertex_normals
();
mesh_
.
request_halfedge_texcoords2D
();
// Add some vertices
Mesh
::
VertexHandle
vhandle
[
5
];
vhandle
[
0
]
=
mesh_
.
add_vertex
(
Mesh
::
Point
(
0
,
0
,
0
));
vhandle
[
1
]
=
mesh_
.
add_vertex
(
Mesh
::
Point
(
0
,
1
,
0
));
vhandle
[
2
]
=
mesh_
.
add_vertex
(
Mesh
::
Point
(
1
,
1
,
0
));
// Add one face
std
::
vector
<
Mesh
::
VertexHandle
>
face_vhandles
;
face_vhandles
.
push_back
(
vhandle
[
2
]);
face_vhandles
.
push_back
(
vhandle
[
1
]);
face_vhandles
.
push_back
(
vhandle
[
0
]);
Mesh
::
FaceHandle
fh
=
mesh_
.
add_face
(
face_vhandles
);
// 1 --- 2
// | /
// | /
// | /
// 0
mesh_
.
set_normal
(
vhandle
[
0
]
,
Mesh
::
Normal
(
1
,
0
,
0
));
mesh_
.
set_normal
(
vhandle
[
1
]
,
Mesh
::
Normal
(
0
,
1
,
0
));
mesh_
.
set_normal
(
vhandle
[
2
]
,
Mesh
::
Normal
(
0
,
0
,
1
));
float
u
=
8.0
f
;
for
(
auto
he
:
mesh_
.
halfedges
()
)
{
mesh_
.
set_texcoord2D
(
he
,
Mesh
::
TexCoord2D
(
u
,
u
));
u
+=
1.0
;
}
u
=
0.0
f
;
for
(
auto
fh
:
mesh_
.
fh_range
(
fh
)
)
{
mesh_
.
set_texcoord2D
(
fh
,
Mesh
::
TexCoord2D
(
u
,
u
));
u
+=
1.0
f
;
}
OpenMesh
::
IO
::
Options
wopt
;
wopt
+=
OpenMesh
::
IO
::
Options
::
VertexNormal
;
wopt
+=
OpenMesh
::
IO
::
Options
::
FaceTexCoord
;
bool
ok
=
OpenMesh
::
IO
::
write_mesh
(
mesh_
,
"OpenMeshReadWriteOBJ_FaceTexCoordTest.obj"
,
wopt
);
EXPECT_TRUE
(
ok
)
<<
"Unable to write OpenMeshReadWriteOBJ_FaceTexCoordTest.obj"
;
mesh_
.
clear
();
OpenMesh
::
IO
::
Options
ropt
;
ropt
+=
OpenMesh
::
IO
::
Options
::
FaceTexCoord
;
mesh_
.
request_vertex_normals
();
mesh_
.
request_face_normals
();
mesh_
.
request_halfedge_texcoords2D
();
ok
=
OpenMesh
::
IO
::
read_mesh
(
mesh_
,
"OpenMeshReadWriteOBJ_FaceTexCoordTest.obj"
,
ropt
);
EXPECT_TRUE
(
ok
)
<<
"Unable to read back OpenMeshReadWriteOBJ_FaceTexCoordTest.obj"
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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