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
OpenMesh
OpenMesh
Commits
460db33f
Commit
460db33f
authored
Nov 27, 2018
by
Jan Möbius
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'persistent_edge_properties' into 'master'
Persistent edge properties See merge request
!184
parents
2daa0b4e
62e822cf
Pipeline
#7917
passed with stages
in 128 minutes and 10 seconds
Changes
17
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
1223 additions
and
50 deletions
+1223
-50
Doc/changelog.docu
Doc/changelog.docu
+3
-0
src/OpenMesh/Core/IO/OMFormat.cc
src/OpenMesh/Core/IO/OMFormat.cc
+13
-0
src/OpenMesh/Core/IO/OMFormat.hh
src/OpenMesh/Core/IO/OMFormat.hh
+2
-0
src/OpenMesh/Core/IO/Options.hh
src/OpenMesh/Core/IO/Options.hh
+6
-1
src/OpenMesh/Core/IO/exporter/BaseExporter.hh
src/OpenMesh/Core/IO/exporter/BaseExporter.hh
+16
-0
src/OpenMesh/Core/IO/exporter/ExporterT.hh
src/OpenMesh/Core/IO/exporter/ExporterT.hh
+59
-0
src/OpenMesh/Core/IO/importer/BaseImporter.hh
src/OpenMesh/Core/IO/importer/BaseImporter.hh
+27
-0
src/OpenMesh/Core/IO/importer/ImporterT.hh
src/OpenMesh/Core/IO/importer/ImporterT.hh
+55
-0
src/OpenMesh/Core/IO/reader/OMReader.cc
src/OpenMesh/Core/IO/reader/OMReader.cc
+158
-24
src/OpenMesh/Core/IO/writer/OMWriter.cc
src/OpenMesh/Core/IO/writer/OMWriter.cc
+127
-19
src/OpenMesh/Core/IO/writer/OMWriter.hh
src/OpenMesh/Core/IO/writer/OMWriter.hh
+2
-2
src/Unittests/TestFiles/cube_poly_version_1_2.om
src/Unittests/TestFiles/cube_poly_version_1_2.om
+0
-0
src/Unittests/TestFiles/cube_poly_version_2_0.om
src/Unittests/TestFiles/cube_poly_version_2_0.om
+0
-0
src/Unittests/TestFiles/cube_tri_version_1_2.om
src/Unittests/TestFiles/cube_tri_version_1_2.om
+0
-0
src/Unittests/TestFiles/cube_tri_version_2_0.om
src/Unittests/TestFiles/cube_tri_version_2_0.om
+0
-0
src/Unittests/TestFiles/cube_tri_version_7_5.om
src/Unittests/TestFiles/cube_tri_version_7_5.om
+0
-0
src/Unittests/unittests_read_write_OM.cc
src/Unittests/unittests_read_write_OM.cc
+755
-4
No files found.
Doc/changelog.docu
View file @
460db33f
...
@@ -18,6 +18,9 @@
...
@@ -18,6 +18,9 @@
<ul>
<ul>
<li>PLY Reader: Allowing the PLY reader to read custom face ( Thanks to morgan Leborgne for the patch)</li>
<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: Fixed endless loop on unknown property list type</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>
</ul>
</ul>
<b>Tools</b>
<b>Tools</b>
...
...
src/OpenMesh/Core/IO/OMFormat.cc
View file @
460db33f
...
@@ -113,6 +113,19 @@ namespace OMFormat {
...
@@ -113,6 +113,19 @@ namespace OMFormat {
return
hdr
;
return
hdr
;
}
}
//-----------------------------------------------------------------------------
std
::
string
as_string
(
uint8
version
)
{
std
::
stringstream
ss
;
ss
<<
major_version
(
version
);
ss
<<
"."
;
ss
<<
minor_version
(
version
);
return
ss
.
str
();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
const
char
*
as_string
(
Chunk
::
Entity
e
)
const
char
*
as_string
(
Chunk
::
Entity
e
)
...
...
src/OpenMesh/Core/IO/OMFormat.hh
View file @
460db33f
...
@@ -469,6 +469,8 @@ namespace OMFormat {
...
@@ -469,6 +469,8 @@ namespace OMFormat {
// ---------------------------------------- convenience functions
// ---------------------------------------- convenience functions
std
::
string
as_string
(
uint8
version
);
const
char
*
as_string
(
Chunk
::
Type
t
);
const
char
*
as_string
(
Chunk
::
Type
t
);
const
char
*
as_string
(
Chunk
::
Entity
e
);
const
char
*
as_string
(
Chunk
::
Entity
e
);
const
char
*
as_string
(
Chunk
::
Dim
d
);
const
char
*
as_string
(
Chunk
::
Dim
d
);
...
...
src/OpenMesh/Core/IO/Options.hh
View file @
460db33f
...
@@ -115,7 +115,8 @@ public:
...
@@ -115,7 +115,8 @@ public:
FaceTexCoord
=
0x0400
,
///< Has (r) / store (w) face texture coordinates
FaceTexCoord
=
0x0400
,
///< Has (r) / store (w) face texture coordinates
ColorAlpha
=
0x0800
,
///< Has (r) / store (w) alpha values for colors
ColorAlpha
=
0x0800
,
///< Has (r) / store (w) alpha values for colors
ColorFloat
=
0x1000
,
///< Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files)
ColorFloat
=
0x1000
,
///< Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files)
Custom
=
0x2000
///< Has (r) custom properties (currently only implemented in PLY Reader ASCII version)
Custom
=
0x2000
,
///< Has (r) custom properties (currently only implemented in PLY Reader ASCII version)
Status
=
0x4000
///< Has (r) / store (w) status properties
};
};
public:
public:
...
@@ -206,10 +207,14 @@ public:
...
@@ -206,10 +207,14 @@ public:
bool
vertex_has_normal
()
const
{
return
check
(
VertexNormal
);
}
bool
vertex_has_normal
()
const
{
return
check
(
VertexNormal
);
}
bool
vertex_has_color
()
const
{
return
check
(
VertexColor
);
}
bool
vertex_has_color
()
const
{
return
check
(
VertexColor
);
}
bool
vertex_has_texcoord
()
const
{
return
check
(
VertexTexCoord
);
}
bool
vertex_has_texcoord
()
const
{
return
check
(
VertexTexCoord
);
}
bool
vertex_has_status
()
const
{
return
check
(
Status
);
}
bool
edge_has_color
()
const
{
return
check
(
EdgeColor
);
}
bool
edge_has_color
()
const
{
return
check
(
EdgeColor
);
}
bool
edge_has_status
()
const
{
return
check
(
Status
);
}
bool
halfedge_has_status
()
const
{
return
check
(
Status
);
}
bool
face_has_normal
()
const
{
return
check
(
FaceNormal
);
}
bool
face_has_normal
()
const
{
return
check
(
FaceNormal
);
}
bool
face_has_color
()
const
{
return
check
(
FaceColor
);
}
bool
face_has_color
()
const
{
return
check
(
FaceColor
);
}
bool
face_has_texcoord
()
const
{
return
check
(
FaceTexCoord
);
}
bool
face_has_texcoord
()
const
{
return
check
(
FaceTexCoord
);
}
bool
face_has_status
()
const
{
return
check
(
Status
);
}
bool
color_has_alpha
()
const
{
return
check
(
ColorAlpha
);
}
bool
color_has_alpha
()
const
{
return
check
(
ColorAlpha
);
}
bool
color_is_float
()
const
{
return
check
(
ColorFloat
);
}
bool
color_is_float
()
const
{
return
check
(
ColorFloat
);
}
...
...
src/OpenMesh/Core/IO/exporter/BaseExporter.hh
View file @
460db33f
...
@@ -104,12 +104,14 @@ public:
...
@@ -104,12 +104,14 @@ public:
virtual
Vec4f
colorAf
(
VertexHandle
_vh
)
const
=
0
;
virtual
Vec4f
colorAf
(
VertexHandle
_vh
)
const
=
0
;
virtual
Vec2f
texcoord
(
VertexHandle
_vh
)
const
=
0
;
virtual
Vec2f
texcoord
(
VertexHandle
_vh
)
const
=
0
;
virtual
Vec2f
texcoord
(
HalfedgeHandle
_heh
)
const
=
0
;
virtual
Vec2f
texcoord
(
HalfedgeHandle
_heh
)
const
=
0
;
virtual
OpenMesh
::
Attributes
::
StatusInfo
status
(
VertexHandle
_vh
)
const
=
0
;
// get face data
// get face data
virtual
unsigned
int
virtual
unsigned
int
get_vhandles
(
FaceHandle
_fh
,
get_vhandles
(
FaceHandle
_fh
,
std
::
vector
<
VertexHandle
>&
_vhandles
)
const
=
0
;
std
::
vector
<
VertexHandle
>&
_vhandles
)
const
=
0
;
///
///
/// \brief getHeh returns the HalfEdgeHandle that belongs to the face
/// \brief getHeh returns the HalfEdgeHandle that belongs to the face
/// specified by _fh and has a toVertexHandle that corresponds to _vh.
/// specified by _fh and has a toVertexHandle that corresponds to _vh.
...
@@ -127,6 +129,7 @@ public:
...
@@ -127,6 +129,7 @@ public:
virtual
Vec4ui
colorAi
(
FaceHandle
_fh
)
const
=
0
;
virtual
Vec4ui
colorAi
(
FaceHandle
_fh
)
const
=
0
;
virtual
Vec3f
colorf
(
FaceHandle
_fh
)
const
=
0
;
virtual
Vec3f
colorf
(
FaceHandle
_fh
)
const
=
0
;
virtual
Vec4f
colorAf
(
FaceHandle
_fh
)
const
=
0
;
virtual
Vec4f
colorAf
(
FaceHandle
_fh
)
const
=
0
;
virtual
OpenMesh
::
Attributes
::
StatusInfo
status
(
FaceHandle
_fh
)
const
=
0
;
// get edge data
// get edge data
virtual
Vec3uc
color
(
EdgeHandle
_eh
)
const
=
0
;
virtual
Vec3uc
color
(
EdgeHandle
_eh
)
const
=
0
;
...
@@ -135,6 +138,15 @@ public:
...
@@ -135,6 +138,15 @@ public:
virtual
Vec4ui
colorAi
(
EdgeHandle
_eh
)
const
=
0
;
virtual
Vec4ui
colorAi
(
EdgeHandle
_eh
)
const
=
0
;
virtual
Vec3f
colorf
(
EdgeHandle
_eh
)
const
=
0
;
virtual
Vec3f
colorf
(
EdgeHandle
_eh
)
const
=
0
;
virtual
Vec4f
colorAf
(
EdgeHandle
_eh
)
const
=
0
;
virtual
Vec4f
colorAf
(
EdgeHandle
_eh
)
const
=
0
;
virtual
OpenMesh
::
Attributes
::
StatusInfo
status
(
EdgeHandle
_eh
)
const
=
0
;
// get halfedge data
virtual
int
get_halfedge_id
(
VertexHandle
_vh
)
=
0
;
virtual
int
get_halfedge_id
(
FaceHandle
_vh
)
=
0
;
virtual
int
get_next_halfedge_id
(
HalfedgeHandle
_heh
)
=
0
;
virtual
int
get_to_vertex_id
(
HalfedgeHandle
_heh
)
=
0
;
virtual
int
get_face_id
(
HalfedgeHandle
_heh
)
=
0
;
virtual
OpenMesh
::
Attributes
::
StatusInfo
status
(
HalfedgeHandle
_heh
)
const
=
0
;
// get reference to base kernel
// get reference to base kernel
virtual
const
BaseKernel
*
kernel
()
{
return
0
;
}
virtual
const
BaseKernel
*
kernel
()
{
return
0
;
}
...
@@ -150,10 +162,14 @@ public:
...
@@ -150,10 +162,14 @@ public:
virtual
bool
is_triangle_mesh
()
const
{
return
false
;
}
virtual
bool
is_triangle_mesh
()
const
{
return
false
;
}
virtual
bool
has_vertex_normals
()
const
{
return
false
;
}
virtual
bool
has_vertex_normals
()
const
{
return
false
;
}
virtual
bool
has_vertex_colors
()
const
{
return
false
;
}
virtual
bool
has_vertex_colors
()
const
{
return
false
;
}
virtual
bool
has_vertex_status
()
const
{
return
false
;
}
virtual
bool
has_vertex_texcoords
()
const
{
return
false
;
}
virtual
bool
has_vertex_texcoords
()
const
{
return
false
;
}
virtual
bool
has_edge_colors
()
const
{
return
false
;
}
virtual
bool
has_edge_colors
()
const
{
return
false
;
}
virtual
bool
has_edge_status
()
const
{
return
false
;
}
virtual
bool
has_halfedge_status
()
const
{
return
false
;
}
virtual
bool
has_face_normals
()
const
{
return
false
;
}
virtual
bool
has_face_normals
()
const
{
return
false
;
}
virtual
bool
has_face_colors
()
const
{
return
false
;
}
virtual
bool
has_face_colors
()
const
{
return
false
;
}
virtual
bool
has_face_status
()
const
{
return
false
;
}
};
};
...
...
src/OpenMesh/Core/IO/exporter/ExporterT.hh
View file @
460db33f
...
@@ -171,6 +171,13 @@ public:
...
@@ -171,6 +171,13 @@ public:
:
Vec2f
(
0.0
f
,
0.0
f
));
:
Vec2f
(
0.0
f
,
0.0
f
));
}
}
OpenMesh
::
Attributes
::
StatusInfo
status
(
VertexHandle
_vh
)
const
{
if
(
mesh_
.
has_vertex_status
())
return
mesh_
.
status
(
_vh
);
return
OpenMesh
::
Attributes
::
StatusInfo
();
}
// get edge data
// get edge data
Vec3uc
color
(
EdgeHandle
_eh
)
const
Vec3uc
color
(
EdgeHandle
_eh
)
const
...
@@ -215,6 +222,47 @@ public:
...
@@ -215,6 +222,47 @@ public:
:
Vec4f
(
0
,
0
,
0
,
0
));
:
Vec4f
(
0
,
0
,
0
,
0
));
}
}
OpenMesh
::
Attributes
::
StatusInfo
status
(
EdgeHandle
_eh
)
const
{
if
(
mesh_
.
has_edge_status
())
return
mesh_
.
status
(
_eh
);
return
OpenMesh
::
Attributes
::
StatusInfo
();
}
// get halfedge data
int
get_halfedge_id
(
VertexHandle
_vh
)
override
{
return
mesh_
.
halfedge_handle
(
_vh
).
idx
();
}
int
get_halfedge_id
(
FaceHandle
_fh
)
override
{
return
mesh_
.
halfedge_handle
(
_fh
).
idx
();
}
int
get_next_halfedge_id
(
HalfedgeHandle
_heh
)
override
{
return
mesh_
.
next_halfedge_handle
(
_heh
).
idx
();
}
int
get_to_vertex_id
(
HalfedgeHandle
_heh
)
override
{
return
mesh_
.
to_vertex_handle
(
_heh
).
idx
();
}
int
get_face_id
(
HalfedgeHandle
_heh
)
override
{
return
mesh_
.
face_handle
(
_heh
).
idx
();
}
OpenMesh
::
Attributes
::
StatusInfo
status
(
HalfedgeHandle
_heh
)
const
{
if
(
mesh_
.
has_halfedge_status
())
return
mesh_
.
status
(
_heh
);
return
OpenMesh
::
Attributes
::
StatusInfo
();
}
// get face data
// get face data
unsigned
int
get_vhandles
(
FaceHandle
_fh
,
unsigned
int
get_vhandles
(
FaceHandle
_fh
,
...
@@ -304,6 +352,13 @@ public:
...
@@ -304,6 +352,13 @@ public:
:
Vec4f
(
0
,
0
,
0
,
0
));
:
Vec4f
(
0
,
0
,
0
,
0
));
}
}
OpenMesh
::
Attributes
::
StatusInfo
status
(
FaceHandle
_fh
)
const
{
if
(
mesh_
.
has_face_status
())
return
mesh_
.
status
(
_fh
);
return
OpenMesh
::
Attributes
::
StatusInfo
();
}
virtual
const
BaseKernel
*
kernel
()
{
return
&
mesh_
;
}
virtual
const
BaseKernel
*
kernel
()
{
return
&
mesh_
;
}
...
@@ -320,9 +375,13 @@ public:
...
@@ -320,9 +375,13 @@ public:
bool
has_vertex_normals
()
const
{
return
mesh_
.
has_vertex_normals
();
}
bool
has_vertex_normals
()
const
{
return
mesh_
.
has_vertex_normals
();
}
bool
has_vertex_colors
()
const
{
return
mesh_
.
has_vertex_colors
();
}
bool
has_vertex_colors
()
const
{
return
mesh_
.
has_vertex_colors
();
}
bool
has_vertex_texcoords
()
const
{
return
mesh_
.
has_vertex_texcoords2D
();
}
bool
has_vertex_texcoords
()
const
{
return
mesh_
.
has_vertex_texcoords2D
();
}
bool
has_vertex_status
()
const
{
return
mesh_
.
has_vertex_status
();
}
bool
has_edge_colors
()
const
{
return
mesh_
.
has_edge_colors
();
}
bool
has_edge_colors
()
const
{
return
mesh_
.
has_edge_colors
();
}
bool
has_edge_status
()
const
{
return
mesh_
.
has_edge_status
();
}
bool
has_halfedge_status
()
const
{
return
mesh_
.
has_halfedge_status
();
}
bool
has_face_normals
()
const
{
return
mesh_
.
has_face_normals
();
}
bool
has_face_normals
()
const
{
return
mesh_
.
has_face_normals
();
}
bool
has_face_colors
()
const
{
return
mesh_
.
has_face_colors
();
}
bool
has_face_colors
()
const
{
return
mesh_
.
has_face_colors
();
}
bool
has_face_status
()
const
{
return
mesh_
.
has_face_status
();
}
private:
private:
...
...
src/OpenMesh/Core/IO/importer/BaseImporter.hh
View file @
460db33f
...
@@ -99,10 +99,16 @@ public:
...
@@ -99,10 +99,16 @@ public:
// add a vertex without coordinate. Use set_point to set the position deferred
// add a vertex without coordinate. Use set_point to set the position deferred
virtual
VertexHandle
add_vertex
()
=
0
;
virtual
VertexHandle
add_vertex
()
=
0
;
// add an edge. Use set_next, set_vertex and set_face to set corresponding entities for halfedges
virtual
HalfedgeHandle
add_edge
(
VertexHandle
_vh0
,
VertexHandle
_vh1
)
=
0
;
// add a face with indices _indices refering to vertices
// add a face with indices _indices refering to vertices
typedef
std
::
vector
<
VertexHandle
>
VHandles
;
typedef
std
::
vector
<
VertexHandle
>
VHandles
;
virtual
FaceHandle
add_face
(
const
VHandles
&
_indices
)
=
0
;
virtual
FaceHandle
add_face
(
const
VHandles
&
_indices
)
=
0
;
// add a face with incident halfedge
virtual
FaceHandle
add_face
(
HalfedgeHandle
_heh
)
=
0
;
// add texture coordinates per face, _vh references the first texcoord
// add texture coordinates per face, _vh references the first texcoord
virtual
void
add_face_texcoords
(
FaceHandle
_fh
,
VertexHandle
_vh
,
const
std
::
vector
<
Vec2f
>&
_face_texcoords
)
=
0
;
virtual
void
add_face_texcoords
(
FaceHandle
_fh
,
VertexHandle
_vh
,
const
std
::
vector
<
Vec2f
>&
_face_texcoords
)
=
0
;
...
@@ -115,6 +121,9 @@ public:
...
@@ -115,6 +121,9 @@ public:
// Set coordinate of the given vertex. Use this function, if you created a vertex without coordinate
// Set coordinate of the given vertex. Use this function, if you created a vertex without coordinate
virtual
void
set_point
(
VertexHandle
_vh
,
const
Vec3f
&
_point
)
=
0
;
virtual
void
set_point
(
VertexHandle
_vh
,
const
Vec3f
&
_point
)
=
0
;
// Set outgoing halfedge for the given vertex.
virtual
void
set_halfedge
(
VertexHandle
_vh
,
HalfedgeHandle
_heh
)
=
0
;
// set vertex normal
// set vertex normal
virtual
void
set_normal
(
VertexHandle
_vh
,
const
Vec3f
&
_normal
)
=
0
;
virtual
void
set_normal
(
VertexHandle
_vh
,
const
Vec3f
&
_normal
)
=
0
;
...
@@ -133,6 +142,15 @@ public:
...
@@ -133,6 +142,15 @@ public:
// set vertex texture coordinate
// set vertex texture coordinate
virtual
void
set_texcoord
(
VertexHandle
_vh
,
const
Vec2f
&
_texcoord
)
=
0
;
virtual
void
set_texcoord
(
VertexHandle
_vh
,
const
Vec2f
&
_texcoord
)
=
0
;
// set vertex status
virtual
void
set_status
(
VertexHandle
_vh
,
const
OpenMesh
::
Attributes
::
StatusInfo
&
_status
)
=
0
;
// set next halfedge handle
virtual
void
set_next
(
HalfedgeHandle
_heh
,
HalfedgeHandle
_next
)
=
0
;
// set incident face handle for given halfedge
virtual
void
set_face
(
HalfedgeHandle
_heh
,
FaceHandle
_fh
)
=
0
;
// set vertex texture coordinate
// set vertex texture coordinate
virtual
void
set_texcoord
(
HalfedgeHandle
_heh
,
const
Vec2f
&
_texcoord
)
=
0
;
virtual
void
set_texcoord
(
HalfedgeHandle
_heh
,
const
Vec2f
&
_texcoord
)
=
0
;
...
@@ -142,6 +160,9 @@ public:
...
@@ -142,6 +160,9 @@ public:
// set 3d vertex texture coordinate
// set 3d vertex texture coordinate
virtual
void
set_texcoord
(
HalfedgeHandle
_heh
,
const
Vec3f
&
_texcoord
)
=
0
;
virtual
void
set_texcoord
(
HalfedgeHandle
_heh
,
const
Vec3f
&
_texcoord
)
=
0
;
// set halfedge status
virtual
void
set_status
(
HalfedgeHandle
_heh
,
const
OpenMesh
::
Attributes
::
StatusInfo
&
_status
)
=
0
;
// set edge color
// set edge color
virtual
void
set_color
(
EdgeHandle
_eh
,
const
Vec3uc
&
_color
)
=
0
;
virtual
void
set_color
(
EdgeHandle
_eh
,
const
Vec3uc
&
_color
)
=
0
;
...
@@ -154,6 +175,9 @@ public:
...
@@ -154,6 +175,9 @@ public:
// set edge color
// set edge color
virtual
void
set_color
(
EdgeHandle
_eh
,
const
Vec4f
&
_color
)
=
0
;
virtual
void
set_color
(
EdgeHandle
_eh
,
const
Vec4f
&
_color
)
=
0
;
// set edge status
virtual
void
set_status
(
EdgeHandle
_eh
,
const
OpenMesh
::
Attributes
::
StatusInfo
&
_status
)
=
0
;
// set face normal
// set face normal
virtual
void
set_normal
(
FaceHandle
_fh
,
const
Vec3f
&
_normal
)
=
0
;
virtual
void
set_normal
(
FaceHandle
_fh
,
const
Vec3f
&
_normal
)
=
0
;
...
@@ -169,6 +193,9 @@ public:
...
@@ -169,6 +193,9 @@ public:
// set face color
// set face color
virtual
void
set_color
(
FaceHandle
_fh
,
const
Vec4f
&
_color
)
=
0
;
virtual
void
set_color
(
FaceHandle
_fh
,
const
Vec4f
&
_color
)
=
0
;
// set face status
virtual
void
set_status
(
FaceHandle
_fh
,
const
OpenMesh
::
Attributes
::
StatusInfo
&
_status
)
=
0
;
// Store a property in the mesh mapping from an int to a texture file
// Store a property in the mesh mapping from an int to a texture file
// Use set_face_texindex to set the index for each face
// Use set_face_texindex to set the index for each face
virtual
void
add_texture_information
(
int
_id
,
std
::
string
_name
)
=
0
;
virtual
void
add_texture_information
(
int
_id
,
std
::
string
_name
)
=
0
;
...
...
src/OpenMesh/Core/IO/importer/ImporterT.hh
View file @
460db33f
...
@@ -107,6 +107,11 @@ public:
...
@@ -107,6 +107,11 @@ public:
return
mesh_
.
new_vertex
();
return
mesh_
.
new_vertex
();
}
}
virtual
HalfedgeHandle
add_edge
(
VertexHandle
_vh0
,
VertexHandle
_vh1
)
override
{
return
mesh_
.
new_edge
(
_vh0
,
_vh1
);
}
virtual
FaceHandle
add_face
(
const
VHandles
&
_indices
)
virtual
FaceHandle
add_face
(
const
VHandles
&
_indices
)
{
{
FaceHandle
fh
;
FaceHandle
fh
;
...
@@ -192,6 +197,13 @@ public:
...
@@ -192,6 +197,13 @@ public:
return
fh
;
return
fh
;
}
}
virtual
FaceHandle
add_face
(
HalfedgeHandle
_heh
)
override
{
auto
fh
=
mesh_
.
new_face
();
mesh_
.
set_halfedge_handle
(
fh
,
_heh
);
return
fh
;
}
// vertex attributes
// vertex attributes
virtual
void
set_point
(
VertexHandle
_vh
,
const
Vec3f
&
_point
)
virtual
void
set_point
(
VertexHandle
_vh
,
const
Vec3f
&
_point
)
...
@@ -199,6 +211,11 @@ public:
...
@@ -199,6 +211,11 @@ public:
mesh_
.
set_point
(
_vh
,
vector_cast
<
Point
>
(
_point
));
mesh_
.
set_point
(
_vh
,
vector_cast
<
Point
>
(
_point
));
}
}
virtual
void
set_halfedge
(
VertexHandle
_vh
,
HalfedgeHandle
_heh
)
override
{
mesh_
.
set_halfedge_handle
(
_vh
,
_heh
);
}
virtual
void
set_normal
(
VertexHandle
_vh
,
const
Vec3f
&
_normal
)
virtual
void
set_normal
(
VertexHandle
_vh
,
const
Vec3f
&
_normal
)
{
{
if
(
mesh_
.
has_vertex_normals
())
if
(
mesh_
.
has_vertex_normals
())
...
@@ -240,6 +257,24 @@ public:
...
@@ -240,6 +257,24 @@ public:
mesh_
.
set_texcoord2D
(
_vh
,
vector_cast
<
TexCoord2D
>
(
_texcoord
));
mesh_
.
set_texcoord2D
(
_vh
,
vector_cast
<
TexCoord2D
>
(
_texcoord
));
}
}
virtual
void
set_status
(
VertexHandle
_vh
,
const
OpenMesh
::
Attributes
::
StatusInfo
&
_status
)
{
if
(
!
mesh_
.
has_vertex_status
())
mesh_
.
request_vertex_status
();
mesh_
.
status
(
_vh
)
=
_status
;
}
virtual
void
set_next
(
HalfedgeHandle
_heh
,
HalfedgeHandle
_next
)
override
{
mesh_
.
set_next_halfedge_handle
(
_heh
,
_next
);
}
virtual
void
set_face
(
HalfedgeHandle
_heh
,
FaceHandle
_fh
)
override
{
mesh_
.
set_face_handle
(
_heh
,
_fh
);
}
virtual
void
set_texcoord
(
HalfedgeHandle
_heh
,
const
Vec2f
&
_texcoord
)
virtual
void
set_texcoord
(
HalfedgeHandle
_heh
,
const
Vec2f
&
_texcoord
)
{
{
if
(
mesh_
.
has_halfedge_texcoords2D
())
if
(
mesh_
.
has_halfedge_texcoords2D
())
...
@@ -258,6 +293,12 @@ public:
...
@@ -258,6 +293,12 @@ public:
mesh_
.
set_texcoord3D
(
_heh
,
vector_cast
<
TexCoord3D
>
(
_texcoord
));
mesh_
.
set_texcoord3D
(
_heh
,
vector_cast
<
TexCoord3D
>
(
_texcoord
));
}
}
virtual
void
set_status
(
HalfedgeHandle
_heh
,
const
OpenMesh
::
Attributes
::
StatusInfo
&
_status
)
{
if
(
!
mesh_
.
has_halfedge_status
())
mesh_
.
request_halfedge_status
();
mesh_
.
status
(
_heh
)
=
_status
;
}
// edge attributes
// edge attributes
...
@@ -285,6 +326,13 @@ public:
...
@@ -285,6 +326,13 @@ public:
mesh_
.
set_color
(
_eh
,
color_cast
<
Color
>
(
_color
));
mesh_
.
set_color
(
_eh
,
color_cast
<
Color
>
(
_color
));
}
}
virtual
void
set_status
(
EdgeHandle
_eh
,
const
OpenMesh
::
Attributes
::
StatusInfo
&
_status
)
{
if
(
!
mesh_
.
has_edge_status
())
mesh_
.
request_edge_status
();
mesh_
.
status
(
_eh
)
=
_status
;
}
// face attributes
// face attributes
virtual
void
set_normal
(
FaceHandle
_fh
,
const
Vec3f
&
_normal
)
virtual
void
set_normal
(
FaceHandle
_fh
,
const
Vec3f
&
_normal
)
...
@@ -317,6 +365,13 @@ public:
...
@@ -317,6 +365,13 @@ public:
mesh_
.
set_color
(
_fh
,
color_cast
<
Color
>
(
_color
));
mesh_
.
set_color
(
_fh
,
color_cast
<
Color
>
(
_color
));
}
}
virtual
void
set_status
(
FaceHandle
_fh
,
const
OpenMesh
::
Attributes
::
StatusInfo
&
_status
)
{
if
(
!
mesh_
.
has_face_status
())
mesh_
.
request_face_status
();
mesh_
.
status
(
_fh
)
=
_status
;
}
virtual
void
add_face_texcoords
(
FaceHandle
_fh
,
VertexHandle
_vh
,
const
std
::
vector
<
Vec2f
>&
_face_texcoords
)
virtual
void
add_face_texcoords
(
FaceHandle
_fh
,
VertexHandle
_vh
,
const
std
::
vector
<
Vec2f
>&
_face_texcoords
)
{
{
// get first halfedge handle
// get first halfedge handle
...
...
src/OpenMesh/Core/IO/reader/OMReader.cc
View file @
460db33f
...
@@ -61,6 +61,7 @@
...
@@ -61,6 +61,7 @@
#include <OpenMesh/Core/Utils/Endian.hh>
#include <OpenMesh/Core/Utils/Endian.hh>
#include <OpenMesh/Core/IO/OMFormat.hh>
#include <OpenMesh/Core/IO/OMFormat.hh>
#include <OpenMesh/Core/IO/reader/OMReader.hh>
#include <OpenMesh/Core/IO/reader/OMReader.hh>
#include <OpenMesh/Core/IO/writer/OMWriter.hh>
//=== NAMESPACES ==============================================================
//=== NAMESPACES ==============================================================
...
@@ -176,6 +177,15 @@ bool _OMReader_::read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt
...
@@ -176,6 +177,15 @@ bool _OMReader_::read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt
bytes_
+=
restore
(
_is
,
header_
,
swap
);
bytes_
+=
restore
(
_is
,
header_
,
swap
);
if
(
header_
.
version_
>
_OMWriter_
::
get_version
())
{
omerr
()
<<
"File uses .om version "
<<
OMFormat
::
as_string
(
header_
.
version_
)
<<
" but reader only "
<<
"supports up to version "
<<
OMFormat
::
as_string
(
_OMWriter_
::
get_version
())
<<
".
\n
"
<<
"Please update your OpenMesh."
<<
std
::
endl
;
return
false
;
}
while
(
!
_is
.
eof
())
{
while
(
!
_is
.
eof
())
{
bytes_
+=
restore
(
_is
,
chunk_header_
,
swap
);
bytes_
+=
restore
(
_is
,
chunk_header_
,
swap
);
...
@@ -294,6 +304,7 @@ bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi,
...
@@ -294,6 +304,7 @@ bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi,
OpenMesh
::
Vec3f
v3f
;
OpenMesh
::
Vec3f
v3f
;
OpenMesh
::
Vec2f
v2f
;
OpenMesh
::
Vec2f
v2f
;
OpenMesh
::
Vec3uc
v3uc
;
// rgb
OpenMesh
::
Vec3uc
v3uc
;
// rgb
OpenMesh
::
Attributes
::
StatusInfo
status
;
OMFormat
::
Chunk
::
PropertyName
custom_prop
;
OMFormat
::
Chunk
::
PropertyName
custom_prop
;
...
@@ -343,6 +354,20 @@ bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi,
...
@@ -343,6 +354,20 @@ bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi,
}
}
break
;
break
;
case
Chunk
::
Type_Status
:
{
assert
(
OMFormat
::
dimensions
(
chunk_header_
)
==
1
);
fileOptions_
+=
Options
::
Status
;
for
(;
vidx
<
header_
.
n_vertices_
&&
!
_is
.
eof
();
++
vidx
)
{
bytes_
+=
restore
(
_is
,
status
,
_swap
);
if
(
fileOptions_
.
vertex_has_status
()
&&
_opt
.
vertex_has_status
())
_bi
.
set_status
(
VertexHandle
(
int
(
vidx
)),
status
);
}
break
;
}
case
Chunk
::
Type_Custom
:
case
Chunk
::
Type_Custom
:
bytes_
+=