DGtal
1.3.beta
tests
io
writers
testMeshWriter.cpp
Go to the documentation of this file.
1
30
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "DGtal/helpers/StdDefs.h"
35
#include "DGtal/shapes/Mesh.h"
36
#include "DGtal/io/writers/MeshWriter.h"
39
40
using namespace
std;
41
using namespace
DGtal
;
42
using namespace
Z3i;
43
45
// Functions for testing class MeshWriter.
47
48
53
bool
testMeshWriter
()
54
{
55
unsigned
int
nbok = 0;
56
unsigned
int
nb = 0;
58
// Constructing the mesh to export in OFF format
59
Mesh<Point>
aMesh(
true
);
60
vector<Point> vectVertex;
61
Point
p1(0, 0, 0);
62
Point
p2(1, 0, 0);
63
Point
p3(1, 1, 0);
64
Point
p4(0, 1, 0);
65
Point
p11(0, 0, 1);
66
Point
p21(1, 0, 1);
67
Point
p31(1, 1, 1);
68
Point
p41(0, 1, 1);
69
aMesh.
addVertex
(p1);
70
aMesh.
addVertex
(p2);
71
aMesh.
addVertex
(p3);
72
aMesh.
addVertex
(p4);
73
aMesh.
addVertex
(p11);
74
aMesh.
addVertex
(p21);
75
aMesh.
addVertex
(p31);
76
aMesh.
addVertex
(p41);
77
78
vector<DGtal::Color> vectColor;
79
DGtal::Color
col (250,0,0, 200);
80
DGtal::Color
col2 (250,250,0, 200);
81
82
aMesh.
addQuadFace
(0,1,2,3, col);
83
aMesh.
addQuadFace
(4,5,6,7, col2);
84
aMesh.
addQuadFace
(0,1,5,4, col);
85
88
bool
isOK = aMesh >>
"test.off"
;
90
nb++;
91
bool
isOK2 = aMesh >>
"testColor.obj"
;
92
nb++;
93
std::fstream exportObj;
94
exportObj.open(
"test.obj"
, std::fstream::out);
95
bool
isOK3 =
MeshWriter<Point>::export2OBJ
(exportObj, aMesh);
96
97
nb++;
98
99
trace
.
beginBlock
(
"Testing block ..."
);
100
nbok += isOK ? 1 : 0;
101
nbok += isOK2 ? 1 : 0;
102
nbok += isOK3 ? 1 : 0;
103
104
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
105
<<
"true == true"
<< std::endl;
106
trace
.
endBlock
();
107
return
nbok == nb;
108
}
109
111
// Standard services - public :
112
113
int
main
(
int
argc,
char
** argv )
114
{
115
trace
.
beginBlock
(
"Testing class MeshWriter"
);
116
trace
.
info
() <<
"Args:"
;
117
for
(
int
i = 0; i < argc; ++i )
118
trace
.
info
() <<
" "
<< argv[ i ];
119
trace
.
info
() << endl;
120
121
bool
res =
testMeshWriter
();
// && ... other tests
122
trace
.
emphase
() << ( res ?
"Passed."
:
"Error."
) << endl;
123
trace
.
endBlock
();
124
return
res ? 0 : 1;
125
}
126
// //
128
129
DGtal::Trace::endBlock
double endBlock()
testMeshWriter
bool testMeshWriter()
Definition:
testMeshWriter.cpp:53
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition:
Color.h:67
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::trace
Trace trace
Definition:
Common.h:154
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Mesh::addVertex
void addVertex(const TPoint &vertex)
DGtal::Trace::info
std::ostream & info()
DGtal::Mesh
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition:
Mesh.h:91
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
main
int main(int argc, char **argv)
Definition:
testMeshWriter.cpp:113
DGtal::PointVector< dim, Integer >
DGtal::MeshWriter
Aim: Export a Mesh (Mesh object) in different format as OFF and OBJ).
Definition:
MeshWriter.h:76
DGtal::Mesh::addQuadFace
void addQuadFace(unsigned int indexVertex1, unsigned int indexVertex2, unsigned int indexVertex3, unsigned int indexVertex4, const DGtal::Color &aColor=DGtal::Color::White)
Generated on Thu May 19 2022 18:08:52 for DGtal by
1.8.17