mirror of https://github.com/CGAL/cgal
Finish tests BGL/stream_support
This commit is contained in:
parent
b2419e5f98
commit
b6d4a9a372
|
|
@ -140,7 +140,10 @@ public:
|
|||
|
||||
face_descriptor f = CGAL::Euler::add_face(face, g);
|
||||
if(f == boost::graph_traits<FaceGraph>::null_face())
|
||||
{
|
||||
clear(g);
|
||||
return false; // @fixme clear the graph?
|
||||
}
|
||||
|
||||
if(has_face_colors)
|
||||
put(fcm, f, face_colors[i]);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,11 @@
|
|||
OFF
|
||||
4 4 0
|
||||
|
||||
# 4 vertices
|
||||
# ------------------------------------------
|
||||
|
||||
|
||||
0 0 0 -1 0 0 255 0 0 0 0
|
||||
1 0 0 1 0 0 0 255 0 1 0
|
||||
0 1 0 0 1 0 0 0 255 0.5 0.5
|
||||
0 0 1 0
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
ply
|
||||
format ascii 1.0
|
||||
element vertex 4
|
||||
property double x
|
||||
property double y
|
||||
property double z
|
||||
property double nx
|
||||
property double ny
|
||||
property double nz
|
||||
property uchar red
|
||||
property uchar green
|
||||
property uchar blue
|
||||
property int id
|
||||
element face 4
|
||||
property list uchar int vertex_indices
|
||||
property uchar red
|
||||
property uchar green
|
||||
property uchar blue
|
||||
property int label
|
||||
element edge 6
|
||||
property int v0
|
||||
property int v1
|
||||
property float confidence
|
||||
end_header
|
||||
0 0 0 -0.5 -0.5 -0.5 255 255 0 0
|
||||
0 0 1 -0.5 -0.5 0 0 255 255 1
|
||||
0 1 0 -0.5 0 -0.5 128 0 255 2
|
||||
1 0 0 0 -0.5 -0.5 255 128 0 3
|
||||
3 0 1 2 255 0 0 -1
|
||||
3 0 3 1 0 255 0 1
|
||||
3 1 3 2 0 0 255 -1
|
||||
3 0 2 3 255 0 255 0
|
||||
0 1 0.1
|
||||
0 2 0.2
|
||||
0 3 0.3
|
||||
1
|
||||
|
|
@ -0,0 +1,254 @@
|
|||
solid
|
||||
facet normal 0.45463017720314342 -0.19906014641748687 -0.86815117352019233
|
||||
outer loop
|
||||
vertex 0.33766584136292238 -0.3981511963346705 -0.85291113513304562
|
||||
vertex 0.35682208977308993 0 -0.93417235896271578
|
||||
vertex 0.6442221683309296 -0.20868896680211613 -0.73581703769759277
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.41352099631704892 -0.73560707902607358 -0.53654693260858666
|
||||
outer loop
|
||||
vertex -0.3981511963346705 -0.85291113513304562 -0.33766584136292238
|
||||
vertex -0.57735026918962584 -0.57735026918962584 -0.57735026918962584
|
||||
vertex -0.20868896680211613 -0.73581703769759277 -0.6442221683309296
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.41352099631704881 -0.73560707902607358 0.53654693260858655
|
||||
outer loop
|
||||
vertex -0.20868896680211613 -0.73581703769759277 0.6442221683309296
|
||||
vertex -0.57735026918962584 -0.57735026918962584 0.57735026918962584
|
||||
vertex -0.3981511963346705 -0.85291113513304562 0.33766584136292238
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.4546301772031433 -0.19906014641748651 0.86815117352019255
|
||||
outer loop
|
||||
vertex 0.6442221683309296 -0.20868896680211613 0.73581703769759277
|
||||
vertex 0.35682208977308999 0 0.93417235896271555
|
||||
vertex 0.33766584136292238 -0.3981511963346705 0.85291113513304562
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.99117710981172991 0.13254409449411944 -0
|
||||
outer loop
|
||||
vertex 0.98188800969385182 0 -0.18946222953255437
|
||||
vertex 0.93417235896271555 0.35682208977308993 0
|
||||
vertex 0.98188800969385182 0 0.18946222953255437
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.45463017720314342 -0.19906014641748684 -0.86815117352019233
|
||||
outer loop
|
||||
vertex -0.6442221683309296 -0.20868896680211613 -0.73581703769759277
|
||||
vertex -0.35682208977308988 0 -0.93417235896271578
|
||||
vertex -0.33766584136292238 -0.3981511963346705 -0.85291113513304562
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.53654693260858666 0.41352099631704892 -0.73560707902607358
|
||||
outer loop
|
||||
vertex 0.33766584136292238 0.3981511963346705 -0.85291113513304562
|
||||
vertex 0.57735026918962584 0.57735026918962584 -0.57735026918962584
|
||||
vertex 0.6442221683309296 0.20868896680211613 -0.73581703769759277
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.7356070790260737 0.53654693260858666 0.41352099631704892
|
||||
outer loop
|
||||
vertex 0.73581703769759277 0.6442221683309296 0.20868896680211613
|
||||
vertex 0.57735026918962584 0.57735026918962584 0.57735026918962584
|
||||
vertex 0.85291113513304562 0.33766584136292238 0.3981511963346705
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.13254409449411941 0 0.99117710981172991
|
||||
outer loop
|
||||
vertex 0 0.1894622295325544 0.98188800969385182
|
||||
vertex -0.35682208977308999 0 0.93417235896271555
|
||||
vertex 0 -0.1894622295325544 0.98188800969385182
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.86815117352019266 -0.4546301772031433 0.19906014641748643
|
||||
outer loop
|
||||
vertex -0.85291113513304562 -0.33766584136292238 0.3981511963346705
|
||||
vertex -0.93417235896271555 -0.35682208977308993 0
|
||||
vertex -0.73581703769759277 -0.6442221683309296 0.20868896680211613
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.45463017720314342 0.19906014641748682 -0.86815117352019233
|
||||
outer loop
|
||||
vertex -0.33766584136292238 0.3981511963346705 -0.85291113513304562
|
||||
vertex -0.35682208977308988 0 -0.93417235896271578
|
||||
vertex -0.6442221683309296 0.20868896680211613 -0.73581703769759277
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.41352099631704892 0.73560707902607358 -0.53654693260858666
|
||||
outer loop
|
||||
vertex 0.3981511963346705 0.85291113513304562 -0.33766584136292238
|
||||
vertex 0.57735026918962584 0.57735026918962584 -0.57735026918962584
|
||||
vertex 0.20868896680211613 0.73581703769759277 -0.6442221683309296
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.41352099631704881 0.73560707902607358 0.53654693260858655
|
||||
outer loop
|
||||
vertex 0.20868896680211613 0.73581703769759277 0.6442221683309296
|
||||
vertex 0.57735026918962584 0.57735026918962584 0.57735026918962584
|
||||
vertex 0.3981511963346705 0.85291113513304562 0.33766584136292238
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.82301416068358291 -0.56802085464734264 -0
|
||||
outer loop
|
||||
vertex -0.73581703769759277 -0.6442221683309296 0.20868896680211613
|
||||
vertex -0.93417235896271555 -0.35682208977308993 0
|
||||
vertex -0.73581703769759277 -0.6442221683309296 -0.20868896680211613
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.99117710981172991 -0.13254409449411944 0
|
||||
outer loop
|
||||
vertex -0.98188800969385182 0 -0.1894622295325544
|
||||
vertex -0.93417235896271555 -0.35682208977308993 0
|
||||
vertex -0.98188800969385182 0 0.1894622295325544
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.53654693260858666 -0.41352099631704892 -0.73560707902607358
|
||||
outer loop
|
||||
vertex -0.33766584136292238 -0.3981511963346705 -0.85291113513304562
|
||||
vertex -0.57735026918962584 -0.57735026918962584 -0.57735026918962584
|
||||
vertex -0.6442221683309296 -0.20868896680211613 -0.73581703769759277
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.45463017720314353 0.19906014641748693 -0.86815117352019233
|
||||
outer loop
|
||||
vertex 0.6442221683309296 0.20868896680211613 -0.73581703769759277
|
||||
vertex 0.35682208977308993 0 -0.93417235896271578
|
||||
vertex 0.33766584136292238 0.3981511963346705 -0.85291113513304562
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.86815117352019266 0.4546301772031433 0.19906014641748643
|
||||
outer loop
|
||||
vertex 0.85291113513304562 0.33766584136292238 0.3981511963346705
|
||||
vertex 0.93417235896271555 0.35682208977308993 0
|
||||
vertex 0.73581703769759277 0.6442221683309296 0.20868896680211613
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.13254409449411941 -0 0.99117710981172991
|
||||
outer loop
|
||||
vertex 0 -0.1894622295325544 0.98188800969385182
|
||||
vertex 0.35682208977308999 0 0.93417235896271555
|
||||
vertex 0 0.1894622295325544 0.98188800969385182
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.7356070790260737 -0.53654693260858666 0.41352099631704892
|
||||
outer loop
|
||||
vertex -0.73581703769759277 -0.6442221683309296 0.20868896680211613
|
||||
vertex -0.57735026918962584 -0.57735026918962584 0.57735026918962584
|
||||
vertex -0.85291113513304562 -0.33766584136292238 0.3981511963346705
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.86815117352019255 -0.4546301772031433 -0.19906014641748648
|
||||
outer loop
|
||||
vertex 0.85291113513304562 -0.33766584136292238 -0.3981511963346705
|
||||
vertex 0.93417235896271555 -0.35682208977308999 0
|
||||
vertex 0.73581703769759277 -0.6442221683309296 -0.20868896680211613
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.19906014641748682 -0.86815117352019233 -0.45463017720314342
|
||||
outer loop
|
||||
vertex 0.3981511963346705 -0.85291113513304562 -0.33766584136292238
|
||||
vertex 0 -0.93417235896271578 -0.35682208977308988
|
||||
vertex 0.20868896680211613 -0.73581703769759277 -0.6442221683309296
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.41352099631704881 -0.73560707902607358 -0.53654693260858655
|
||||
outer loop
|
||||
vertex 0.20868896680211613 -0.73581703769759277 -0.6442221683309296
|
||||
vertex 0.57735026918962584 -0.57735026918962584 -0.57735026918962584
|
||||
vertex 0.3981511963346705 -0.85291113513304562 -0.33766584136292238
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0 -0.99117710981172991 0.13254409449411883
|
||||
outer loop
|
||||
vertex 0.18946222953255437 -0.98188800969385182 0
|
||||
vertex 0 -0.93417235896271578 0.35682208977308993
|
||||
vertex -0.18946222953255437 -0.98188800969385182 0
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0 -0.99117710981172991 -0.13254409449411883
|
||||
outer loop
|
||||
vertex -0.18946222953255437 -0.98188800969385182 0
|
||||
vertex 0 -0.93417235896271578 -0.35682208977308988
|
||||
vertex 0.18946222953255437 -0.98188800969385182 0
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.41352099631704892 -0.73560707902607358 0.53654693260858666
|
||||
outer loop
|
||||
vertex 0.3981511963346705 -0.85291113513304562 0.33766584136292238
|
||||
vertex 0.57735026918962584 -0.57735026918962584 0.57735026918962584
|
||||
vertex 0.20868896680211613 -0.73581703769759277 0.6442221683309296
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.19906014641748693 -0.86815117352019233 0.45463017720314353
|
||||
outer loop
|
||||
vertex 0.20868896680211613 -0.73581703769759277 0.6442221683309296
|
||||
vertex 0 -0.93417235896271578 0.35682208977308993
|
||||
vertex 0.3981511963346705 -0.85291113513304562 0.33766584136292238
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.86815117352019255 -0.4546301772031433 0.19906014641748651
|
||||
outer loop
|
||||
vertex 0.73581703769759277 -0.6442221683309296 0.20868896680211613
|
||||
vertex 0.93417235896271555 -0.35682208977308999 0
|
||||
vertex 0.85291113513304562 -0.33766584136292238 0.3981511963346705
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.73560707902607358 -0.53654693260858666 0.41352099631704892
|
||||
outer loop
|
||||
vertex 0.85291113513304562 -0.33766584136292238 0.3981511963346705
|
||||
vertex 0.57735026918962584 -0.57735026918962584 0.57735026918962584
|
||||
vertex 0.73581703769759277 -0.6442221683309296 0.20868896680211613
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.7356070790260737 -0.53654693260858666 -0.41352099631704892
|
||||
outer loop
|
||||
vertex 0.73581703769759277 -0.6442221683309296 -0.20868896680211613
|
||||
vertex 0.57735026918962584 -0.57735026918962584 -0.57735026918962584
|
||||
vertex 0.85291113513304562 -0.33766584136292238 -0.3981511963346705
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.19906014641748684 -0.86815117352019233 -0.45463017720314342
|
||||
outer loop
|
||||
vertex -0.20868896680211613 -0.73581703769759277 -0.6442221683309296
|
||||
vertex 0 -0.93417235896271578 -0.35682208977308988
|
||||
vertex -0.3981511963346705 -0.85291113513304562 -0.33766584136292238
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.86815117352019255 -0.4546301772031433 -0.19906014641748646
|
||||
outer loop
|
||||
vertex -0.73581703769759277 -0.6442221683309296 -0.20868896680211613
|
||||
vertex -0.93417235896271555 -0.35682208977308993 0
|
||||
vertex -0.85291113513304562 -0.33766584136292238 -0.3981511963346705
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.53654693260858655 -0.41352099631704881 -0.73560707902607358
|
||||
outer loop
|
||||
vertex 0.6442221683309296 -0.20868896680211613 -0.73581703769759277
|
||||
vertex 0.57735026918962584 -0.57735026918962584 -0.57735026918962584
|
||||
vertex 0.33766584136292238 -0.3981511963346705 -0.85291113513304562
|
||||
endloop
|
||||
endfacet
|
||||
facet normal -0.13254409449411883 0 -0.99117710981172991
|
||||
outer loop
|
||||
vertex 0 -0.1894622295325544 -0.98188800969385182
|
||||
vertex -0.35682208977308988 0 -0.93417235896271578
|
||||
vertex 0 0.18946222953255437 -0.98188800969385182
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.99117710981172991 -0.13254409449411941 0
|
||||
outer loop
|
||||
vertex 0.98188800969385182 0 0.18946222953255437
|
||||
vertex 0.93417235896271555 -0.35682208977308999 0
|
||||
vertex 0.98188800969385182 0 -0.18946222953255437
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.73560707902607358 0.53654693260858666 -0.41352099631704892
|
||||
outer loop
|
||||
vertex 0.85291113513304562 0.33766584136292238 -0.3981511963346705
|
||||
vertex 0.57735026918962584 0.57735026918962584 -0.57735026918962584
|
||||
vertex 0.73581703769759277 0.6442221683309296 -0.20868896680211613
|
||||
endloop
|
||||
endfacet
|
||||
facet normal 0.53654693260858666 -0.41352099631704892 0.73
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
GOCAD TSurf 1
|
||||
HEADER {
|
||||
name:small
|
||||
*solid*color:0.501961 0.501961 0.501961 1
|
||||
ivolmap:false
|
||||
imap:false
|
||||
last_selected_folder:Graphic
|
||||
TSurfIsoAssociation:true
|
||||
}
|
||||
GOCAD_ORIGINAL_COORDINATE_SYSTEM
|
||||
NAME Default
|
||||
AXIS_NAME "X" "Y" "Z"
|
||||
AXIS_UNIT "m" "m" "m"
|
||||
ZPOSITIVE Depth
|
||||
END_ORIGINAL_COORDINATE_SYSTEM
|
||||
PROPERTY_CLASS_HEADER Z {
|
||||
is_z:on
|
||||
}
|
||||
TFACE
|
||||
VRTX 1 0.001 0.00 0.0
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,19 @@
|
|||
NOFF
|
||||
4 4 0
|
||||
|
||||
# 4 vertices
|
||||
# ------------------------------------------
|
||||
|
||||
|
||||
0 0 0
|
||||
1 0 0
|
||||
0 1 0
|
||||
0 0 1
|
||||
|
||||
# 4 facets
|
||||
# ------------------------------------------
|
||||
|
||||
3 0 1 2
|
||||
3 3 1 0
|
||||
3 3 2 1
|
||||
3 3 0 2
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
facet normal 0.45463017720314342 -0.19906014641748687 -0.86815117352019233
|
||||
outer loop
|
||||
vertex 0.33766584136292238 -0.3981511963346705 -0.85291113513304562
|
||||
vertex 0.35682208977308993 0 -0.93417235896271578
|
||||
vertex 0.6442221683309296 -0.20868896680211613 -0.73581703769759277
|
||||
endloop
|
||||
endfacet
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
HEADER {
|
||||
name:small
|
||||
*solid*color: 0.501961 0.501961 0.501961 1
|
||||
ivolmap:false
|
||||
imap:false
|
||||
last_selected_folder:Graphic
|
||||
TSurfIsoAssociation:true
|
||||
}
|
||||
GOCAD_ORIGINAL_COORDINATE_SYSTEM
|
||||
NAME Default
|
||||
AXIS_NAME "X" "Y" "Z"
|
||||
AXIS_UNIT "m" "m" "m"
|
||||
ZPOSITIVE Depth
|
||||
END_ORIGINAL_COORDINATE_SYSTEM
|
||||
PROPERTY_CLASS_HEADER Z {
|
||||
is_z:on
|
||||
}
|
||||
|
||||
VRTX 1 0.001 0.00 0.000005
|
||||
VRTX 2 1.001 0.00 0.000005
|
||||
VRTX 3 0.001 1.00 0.000005
|
||||
TRGL 1 2 3
|
||||
END
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,13 @@
|
|||
OFF
|
||||
5 4 0
|
||||
|
||||
0 0 0
|
||||
1 0 0
|
||||
0 1 0
|
||||
0 0 1
|
||||
|
||||
|
||||
3 0 1 2
|
||||
3 3 1 0
|
||||
3 3 2 1
|
||||
3 3 0 2
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
ply
|
||||
format ascii 1.0
|
||||
element vertex 4
|
||||
property double x
|
||||
property double y
|
||||
property double z
|
||||
property double nx
|
||||
property double ny
|
||||
property double nz
|
||||
property uchar red
|
||||
property uchar green
|
||||
property uchar blue
|
||||
property int id
|
||||
element face 4
|
||||
property list uchar int vertex_indices
|
||||
property uchar red
|
||||
property uchar green
|
||||
property uchar blue
|
||||
property int label
|
||||
element edge 6
|
||||
property int v0
|
||||
property int v1
|
||||
property float confidence
|
||||
end_header
|
||||
0 0 0 -0.5 -0.5 -0.5 0
|
||||
0 0 1 -0.5 -0.5 0 1
|
||||
0 1 0 -0.5 0 -0.5 2
|
||||
1 0 0 0 -0.5 -0.5 3
|
||||
3 0 1 2 255 0 0 -1
|
||||
3 0 3 1 0 255 0 1
|
||||
3 1 3 2 0 0 255 -1
|
||||
3 0 2 3 255 0 255 0
|
||||
0 1 0.1
|
||||
0 2 0.2
|
||||
0 3 0.3
|
||||
1 2 0.4
|
||||
1 3 0.5
|
||||
2 3 0.6
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#this is a comment
|
||||
# this is a second comment
|
||||
NOFF
|
||||
8 4 0
|
||||
|
||||
-1 -1 0 0.9 0.0 0.0 #com
|
||||
0 -1 0 0.0 0.0 0.9 #com
|
||||
1 -1 0 0.9 0 0#com
|
||||
|
||||
1 0 0 0 0 0.9
|
||||
1 1 0 0.9 0 0
|
||||
0 1 0 0 0 0.9
|
||||
|
||||
-1 1 0 0.9 0 0 #com
|
||||
-1 0 0 0 0 0.9 #blue
|
||||
|
||||
|
||||
|
||||
3 0 1 7 0.9 0 0 #com
|
||||
3 1 2 3 0.9 0 0#com
|
||||
3 5 6 7 0.9 0 0
|
||||
|
||||
5 1 3 4 5 7 0 0 0.9
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
|
@ -347,6 +347,7 @@ void test_bgl_OFF(const char* filename)
|
|||
assert(get(fcm2, f) != CGAL::Color());
|
||||
}
|
||||
}
|
||||
//@todo test multi objects in a single file
|
||||
|
||||
// test wrong inputs
|
||||
std::cerr<<"Error text is expected to follow."<<std::endl;
|
||||
|
|
@ -397,65 +398,49 @@ void test_bgl_OBJ(const std::string filename)
|
|||
assert(ok);
|
||||
assert(are_equal_meshes(fg, fg2));
|
||||
}
|
||||
|
||||
// Test NPs
|
||||
typedef typename boost::property_map<Mesh, CGAL::dynamic_vertex_property_t<Vector> >::type VertexNormalMap;
|
||||
|
||||
clear(fg);
|
||||
VertexNormalMap vnm = get(CGAL::dynamic_vertex_property_t<Vector>(), fg);
|
||||
|
||||
ok = CGAL::read_OBJ("data/sphere.obj", fg, CGAL::parameters::vertex_normal_map(vnm));
|
||||
ok = CGAL::read_OBJ("data/sphere.obj", fg);
|
||||
assert(ok);
|
||||
assert(num_vertices(fg) == 162 && num_faces(fg) == 320);
|
||||
|
||||
for(const auto v : vertices(fg))
|
||||
assert(get(vnm, v) != CGAL::NULL_VECTOR);
|
||||
|
||||
// write with OBJ
|
||||
{
|
||||
std::ofstream os("tmp.obj");
|
||||
ok = CGAL::write_OBJ("tmp.obj", fg, CGAL::parameters::vertex_normal_map(vnm));
|
||||
ok = CGAL::write_OBJ("tmp.obj", fg);
|
||||
assert(ok);
|
||||
|
||||
Mesh fg2;
|
||||
VertexNormalMap vnm2 = get(CGAL::dynamic_vertex_property_t<Vector>(), fg2);
|
||||
|
||||
ok = CGAL::read_polygon_mesh("tmp.obj", fg2, CGAL::parameters::vertex_normal_map(vnm2));
|
||||
ok = CGAL::read_polygon_mesh("tmp.obj", fg2);
|
||||
assert(ok);
|
||||
assert(are_equal_meshes(fg, fg2));
|
||||
|
||||
for(const auto v : vertices(fg2))
|
||||
assert(get(vnm2, v) != CGAL::NULL_VECTOR);
|
||||
}
|
||||
|
||||
// write with PM
|
||||
{
|
||||
ok = CGAL::write_polygon_mesh("tmp.obj", fg, CGAL::parameters::vertex_normal_map(vnm));
|
||||
ok = CGAL::write_polygon_mesh("tmp.obj", fg);
|
||||
assert(ok);
|
||||
|
||||
Mesh fg2;
|
||||
VertexNormalMap vnm2 = get(CGAL::dynamic_vertex_property_t<Vector>(), fg2);
|
||||
|
||||
ok = CGAL::read_polygon_mesh("tmp.obj", fg2, CGAL::parameters::vertex_normal_map(vnm2));
|
||||
ok = CGAL::read_polygon_mesh("tmp.obj", fg2);
|
||||
assert(ok);
|
||||
assert(are_equal_meshes(fg, fg2));
|
||||
|
||||
for(const auto v : vertices(fg2))
|
||||
assert(get(vnm2, v) != CGAL::NULL_VECTOR);
|
||||
}
|
||||
|
||||
// test wrong inputs
|
||||
std::cerr<<"Error text is expected to follow."<<std::endl;
|
||||
ok = CGAL::read_OBJ("data/mesh_that_doesnt_exist.obj", fg);
|
||||
assert(!ok);
|
||||
ok = CGAL::read_OBJ("data/invalid_cut.obj", fg); // invalid vertex ids
|
||||
assert(!ok);
|
||||
VertexNormalMap vnm3 = get(CGAL::dynamic_vertex_property_t<Vector>(), fg);
|
||||
ok = CGAL::read_OBJ("data/invalid_nv.obj", fg, CGAL::parameters::vertex_normal_map(vnm3)); // not enough nv
|
||||
assert(!ok);
|
||||
ok = CGAL::read_OBJ("data/genus3.off", fg); // wrong extension
|
||||
assert(!ok);
|
||||
ok = CGAL::read_OBJ("data/pig.stl", fg);
|
||||
assert(!ok);
|
||||
std::cerr<<"No more error text from here."<<std::endl;
|
||||
}
|
||||
|
||||
template<class Mesh>
|
||||
|
|
@ -870,7 +855,6 @@ int main(int argc, char** argv)
|
|||
test_bgl_OBJ<OMesh>(obj_file);
|
||||
#endif
|
||||
|
||||
|
||||
// PLY
|
||||
const char* ply_file_ascii = (argc > 3) ? argv[3] : "data/colored_tetra.ply";
|
||||
test_bgl_PLY<Polyhedron>(ply_file_ascii, false);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ bool read_GOCAD(std::istream& is,
|
|||
{
|
||||
if(!is)
|
||||
{
|
||||
std::cerr<<"File doesn't exist."<<std::endl;
|
||||
if(verbose)
|
||||
std::cerr<<"File doesn't exist."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
typedef typename boost::range_value<PointRange>::type Point;
|
||||
|
|
@ -99,7 +100,7 @@ bool read_GOCAD(std::istream& is,
|
|||
if(line.find("GOCAD ") != std::string::npos) //the whitespace matters, it is used to define a gocad type, but not in the coord system keyword, for example.
|
||||
nb_gocad++;
|
||||
|
||||
if((line[0] == 'V') || (line[0] == 'P'))
|
||||
if((line.find("VRTX") != std::string::npos))
|
||||
{
|
||||
int i;
|
||||
if(!(iss >> s >> i >> p))
|
||||
|
|
|
|||
|
|
@ -35,16 +35,18 @@ namespace CGAL {
|
|||
namespace IO {
|
||||
namespace internal {
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename VertexNormalOutputIterator>
|
||||
template <typename PointRange, typename PolygonRange, typename VertexNormalOutputIterator, typename VertexTextureOutputIterator>
|
||||
bool read_OBJ(std::istream& is,
|
||||
PointRange& points,
|
||||
PolygonRange& faces,
|
||||
VertexNormalOutputIterator vn_out,
|
||||
VertexNormalOutputIterator,
|
||||
VertexTextureOutputIterator,
|
||||
bool verbose = true)
|
||||
{
|
||||
if(!is.good())
|
||||
{
|
||||
std::cerr<<"File doesn't exist"<<std::endl;
|
||||
if(verbose)
|
||||
std::cerr<<"File doesn't exist."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
typedef typename boost::range_value<PointRange>::type Point;
|
||||
|
|
@ -58,6 +60,7 @@ bool read_OBJ(std::istream& is,
|
|||
Point p;
|
||||
|
||||
std::string line;
|
||||
bool tex_found(false), norm_found(false);
|
||||
while(getline(is, line))
|
||||
{
|
||||
if(line.empty())
|
||||
|
|
@ -80,21 +83,11 @@ bool read_OBJ(std::istream& is,
|
|||
}
|
||||
else if(s == "vt")
|
||||
{
|
||||
// @todo vertex textures
|
||||
tex_found = true;
|
||||
}
|
||||
else if(s == "vn")
|
||||
{
|
||||
double nx, ny, nz; // @fixme double?
|
||||
if(iss >> nx >> ny >> nz)
|
||||
{
|
||||
*vn_out++ = Normal(nx, ny, nz); // @fixme check that every vertex has a normal?
|
||||
}
|
||||
else
|
||||
{
|
||||
if(verbose)
|
||||
std::cerr << "error while reading OBJ vertex normal." << std::endl;
|
||||
return false;
|
||||
}
|
||||
norm_found = true;
|
||||
}
|
||||
else if(s == "f")
|
||||
{
|
||||
|
|
@ -129,6 +122,10 @@ bool read_OBJ(std::istream& is,
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if(norm_found && verbose)
|
||||
std::cout<<"WARNING: normals were found in this file, but were discarded."<<std::endl;
|
||||
if(tex_found && verbose)
|
||||
std::cout<<"WARNING: textures were found in this file, but were discarded."<<std::endl;
|
||||
|
||||
if(maxi == -1 && mini == 1)
|
||||
{
|
||||
|
|
@ -150,21 +147,18 @@ bool read_OBJ(std::istream& is,
|
|||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
// @todo could have point_map too (same for other readers)
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OBJ(std::istream& is,
|
||||
PointRange& points,
|
||||
PolygonRange& faces,
|
||||
const CGAL_BGL_NP_CLASS& np,
|
||||
const CGAL_BGL_NP_CLASS&,
|
||||
bool verbose = true)
|
||||
{
|
||||
using parameters::choose_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
return IO::internal::read_OBJ(is, points, faces,
|
||||
choose_parameter(get_parameter(np, internal_np::vertex_normal_output_iterator),
|
||||
CGAL::Emptyset_iterator()),
|
||||
verbose);
|
||||
return IO::internal::read_OBJ(is, points, faces, CGAL::Emptyset_iterator(),
|
||||
CGAL::Emptyset_iterator(), verbose);
|
||||
}
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ bool read_OFF(std::istream& is,
|
|||
CGAL_USE(verbose);
|
||||
|
||||
if(!is.good()){
|
||||
std::cerr<<"File doesn't exist."<<std::endl;
|
||||
if(verbose)
|
||||
std::cerr<<"File doesn't exist."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,11 +37,12 @@ bool read_STL(std::istream& is,
|
|||
PointRange& points,
|
||||
TriangleRange& facets,
|
||||
const CGAL_BGL_NP_CLASS& /*np*/, // might become useful one day for face normals
|
||||
bool verbose = false)
|
||||
bool verbose = true)
|
||||
{
|
||||
if(!is.good())
|
||||
{
|
||||
std::cerr<<"File doesn't exist"<<std::endl;
|
||||
if(verbose)
|
||||
std::cerr<<"File doesn't exist."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue