Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
CGoGN
Commits
132c1266
Commit
132c1266
authored
Mar 20, 2012
by
Kenneth Vanhoey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import Ply with color encoded as uint8
parent
c94accd2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
17 deletions
+56
-17
include/Algo/Import/import2tablesSurface.hpp
include/Algo/Import/import2tablesSurface.hpp
+21
-4
include/Algo/Import/importPlyData.h
include/Algo/Import/importPlyData.h
+9
-3
src/Algo/Import/importPlyData.cpp
src/Algo/Import/importPlyData.cpp
+26
-10
No files found.
include/Algo/Import/import2tablesSurface.hpp
View file @
132c1266
...
...
@@ -591,6 +591,14 @@ bool MeshTablesSurface<PFP>::importPly(const std::string& filename, std::vector<
return
false
;
}
AttributeHandler
<
typename
PFP
::
VEC3
>
colors
=
m_map
.
template
getAttribute
<
typename
PFP
::
VEC3
>(
VERTEX
,
"color"
)
;
if
(
pid
.
hasColors
())
{
if
(
!
colors
.
isValid
())
colors
=
m_map
.
template
addAttribute
<
typename
PFP
::
VEC3
>(
VERTEX
,
"color"
)
;
attrNames
.
push_back
(
colors
.
name
())
;
}
// lecture des nombres de sommets/aretes/faces
m_nbVertices
=
pid
.
nbVertices
();
m_nbFaces
=
pid
.
nbFaces
();
...
...
@@ -606,6 +614,16 @@ bool MeshTablesSurface<PFP>::importPly(const std::string& filename, std::vector<
unsigned
int
id
=
container
.
insertLine
();
positions
[
id
]
=
pos
;
if
(
pid
.
hasColors
())
{
Geom
::
Vector
<
3
,
unsigned
char
>
col
;
pid
.
vertexColorUint8
(
i
,
col
)
;
colors
[
id
][
0
]
=
col
[
0
]
;
colors
[
id
][
1
]
=
col
[
1
]
;
colors
[
id
][
2
]
=
col
[
2
]
;
colors
[
id
]
/=
255.0
;
}
verticesID
.
push_back
(
id
);
}
...
...
@@ -650,7 +668,6 @@ bool MeshTablesSurface<PFP>::importPly(const std::string& filename, std::vector<
template
<
typename
PFP
>
bool
MeshTablesSurface
<
PFP
>::
importPlySLFgeneric
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
)
{
std
::
cout
<<
"Import PlySLFASCII"
<<
std
::
endl
;
// Open file
std
::
ifstream
fp
(
filename
.
c_str
(),
std
::
ios
::
in
)
;
if
(
!
fp
.
good
())
...
...
@@ -912,13 +929,13 @@ bool MeshTablesSurface<PFP>::importPlySLFgenericBin(const std::string& filename,
positions
[
id
]
=
VEC3
(
properties
[
0
],
properties
[
1
],
properties
[
2
])
;
// position
for
(
unsigned
int
k
=
0
;
k
<
3
;
++
k
)
// frame
for
(
unsigned
int
l
=
0
;
l
<
3
;
++
l
)
frame
[
k
][
id
][
l
]
=
properties
[
3
+
(
3
*
k
+
l
)]
;
frame
[
k
][
id
][
l
]
=
(
typename
PFP
::
REAL
)(
properties
[
3
+
(
3
*
k
+
l
)])
;
for
(
unsigned
int
k
=
0
;
k
<
3
;
++
k
)
// coefficients
for
(
unsigned
int
l
=
0
;
l
<
nbCoefs
;
++
l
)
SLFcoefs
[
l
][
id
][
k
]
=
properties
[
12
+
(
nbCoefs
*
k
+
l
)]
;
SLFcoefs
[
l
][
id
][
k
]
=
(
typename
PFP
::
REAL
)(
properties
[
12
+
(
nbCoefs
*
k
+
l
)])
;
unsigned
int
cur
=
12
+
3
*
nbCoefs
;
for
(
unsigned
int
k
=
0
;
k
<
nbRemainders
;
++
k
)
// remaining data
remainders
[
k
][
id
]
=
properties
[
cur
+
k
]
;
remainders
[
k
][
id
]
=
(
typename
PFP
::
REAL
)(
properties
[
cur
+
k
])
;
}
m_nbVertices
=
verticesID
.
size
()
;
delete
[]
properties
;
...
...
include/Algo/Import/importPlyData.h
View file @
132c1266
...
...
@@ -47,7 +47,10 @@ public:
void
vertexNormal
(
int
i
,
VEC
&
N
)
{
N
[
0
]
=
vlist
[
i
]
->
nx
;
N
[
1
]
=
vlist
[
i
]
->
ny
;
N
[
2
]
=
vlist
[
i
]
->
nz
;}
template
<
typename
VEC
>
void
vertexColor
(
int
i
,
VEC
&
C
)
{
C
[
0
]
=
vlist
[
i
]
->
r
;
C
[
1
]
=
vlist
[
i
]
->
g
;
C
[
2
]
=
vlist
[
i
]
->
b
;}
void
vertexColorUint8
(
int
i
,
VEC
&
C
)
{
C
[
0
]
=
vlist
[
i
]
->
red
;
C
[
1
]
=
vlist
[
i
]
->
green
;
C
[
2
]
=
vlist
[
i
]
->
blue
;}
template
<
typename
VEC
>
void
vertexColorFloat32
(
int
i
,
VEC
&
C
)
{
C
[
0
]
=
vlist
[
i
]
->
r
;
C
[
1
]
=
vlist
[
i
]
->
g
;
C
[
2
]
=
vlist
[
i
]
->
b
;}
int
nbVertices
()
{
return
nverts
;}
...
...
@@ -62,7 +65,9 @@ public:
/**
* each vertex has a color vector
*/
bool
hasColors
()
{
return
per_vertex_color
!=
0
;}
bool
hasColors
()
{
return
hasColorsUint8
()
||
hasColorsFloat32
()
;}
bool
hasColorsUint8
()
{
return
per_vertex_color_uint8
!=
0
;}
bool
hasColorsFloat32
()
{
return
per_vertex_color_float32
!=
0
;}
/**
* get the number of edges of a face
...
...
@@ -88,6 +93,7 @@ protected:
typedef
struct
Vertex
{
float
x
,
y
,
z
;
float
r
,
g
,
b
;
unsigned
char
red
,
green
,
blue
;
float
nx
,
ny
,
nz
;
void
*
other_props
;
/* other properties */
}
Vertex
;
...
...
@@ -113,7 +119,7 @@ protected:
PlyOtherProp
*
vert_other
,
*
face_other
;
int
per_vertex_color
;
int
per_vertex_color
_float32
,
per_vertex_color_uint8
;
int
has_normals
;
};
...
...
src/Algo/Import/importPlyData.cpp
View file @
132c1266
...
...
@@ -37,6 +37,9 @@ PlyProperty PlyImportData::vert_props[] = { /* list of property information for
{(
char
*
)
"x"
,
PLY_Float32
,
PLY_Float32
,
offsetof
(
Vertex
,
x
),
0
,
0
,
0
,
0
},
{(
char
*
)
"y"
,
PLY_Float32
,
PLY_Float32
,
offsetof
(
Vertex
,
y
),
0
,
0
,
0
,
0
},
{(
char
*
)
"z"
,
PLY_Float32
,
PLY_Float32
,
offsetof
(
Vertex
,
z
),
0
,
0
,
0
,
0
},
{(
char
*
)
"red"
,
PLY_Uint8
,
PLY_Uint8
,
offsetof
(
Vertex
,
red
),
0
,
0
,
0
,
0
},
{(
char
*
)
"green"
,
PLY_Uint8
,
PLY_Uint8
,
offsetof
(
Vertex
,
green
),
0
,
0
,
0
,
0
},
{(
char
*
)
"blue"
,
PLY_Uint8
,
PLY_Uint8
,
offsetof
(
Vertex
,
blue
),
0
,
0
,
0
,
0
},
{(
char
*
)
"r"
,
PLY_Float32
,
PLY_Float32
,
offsetof
(
Vertex
,
r
),
0
,
0
,
0
,
0
},
{(
char
*
)
"g"
,
PLY_Float32
,
PLY_Float32
,
offsetof
(
Vertex
,
g
),
0
,
0
,
0
,
0
},
{(
char
*
)
"b"
,
PLY_Float32
,
PLY_Float32
,
offsetof
(
Vertex
,
b
),
0
,
0
,
0
,
0
},
...
...
@@ -57,7 +60,8 @@ PlyImportData::PlyImportData():
flist
(
NULL
),
vert_other
(
NULL
),
face_other
(
NULL
),
per_vertex_color
(
0
),
per_vertex_color_uint8
(
0
),
per_vertex_color_float32
(
0
),
has_normals
(
0
)
{
}
...
...
@@ -126,28 +130,40 @@ bool PlyImportData::read_file(const std::string& filename)
{
PlyProperty
*
prop
;
prop
=
in_ply
->
elems
[
i
]
->
props
[
j
];
if
(
equal_strings
((
char
*
)
"r"
,
prop
->
name
))
{
if
(
equal_strings
((
char
*
)
"r
ed
"
,
prop
->
name
))
{
setup_property_ply
(
in_ply
,
&
vert_props
[
3
]);
per_vertex_color
=
1
;
per_vertex_color
_uint8
=
1
;
}
if
(
equal_strings
((
char
*
)
"g"
,
prop
->
name
))
{
if
(
equal_strings
((
char
*
)
"g
reen
"
,
prop
->
name
))
{
setup_property_ply
(
in_ply
,
&
vert_props
[
4
]);
per_vertex_color
=
1
;
per_vertex_color
_uint8
=
1
;
}
if
(
equal_strings
((
char
*
)
"b"
,
prop
->
name
))
{
if
(
equal_strings
((
char
*
)
"b
lue
"
,
prop
->
name
))
{
setup_property_ply
(
in_ply
,
&
vert_props
[
5
]);
per_vertex_color
=
1
;
per_vertex_color
_uint8
=
1
;
}
if
(
equal_strings
((
char
*
)
"
nx
"
,
prop
->
name
))
{
if
(
equal_strings
((
char
*
)
"
r
"
,
prop
->
name
))
{
setup_property_ply
(
in_ply
,
&
vert_props
[
6
]);
per_vertex_color_float32
=
1
;
}
if
(
equal_strings
((
char
*
)
"g"
,
prop
->
name
))
{
setup_property_ply
(
in_ply
,
&
vert_props
[
7
]);
per_vertex_color_float32
=
1
;
}
if
(
equal_strings
((
char
*
)
"b"
,
prop
->
name
))
{
setup_property_ply
(
in_ply
,
&
vert_props
[
8
]);
per_vertex_color_float32
=
1
;
}
if
(
equal_strings
((
char
*
)
"nx"
,
prop
->
name
))
{
setup_property_ply
(
in_ply
,
&
vert_props
[
9
]);
has_normals
=
1
;
}
if
(
equal_strings
((
char
*
)
"ny"
,
prop
->
name
))
{
setup_property_ply
(
in_ply
,
&
vert_props
[
7
]);
setup_property_ply
(
in_ply
,
&
vert_props
[
10
]);
has_normals
=
1
;
}
if
(
equal_strings
((
char
*
)
"nz"
,
prop
->
name
))
{
setup_property_ply
(
in_ply
,
&
vert_props
[
8
]);
setup_property_ply
(
in_ply
,
&
vert_props
[
11
]);
has_normals
=
1
;
}
}
...
...
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