DGtal 1.3.0
Loading...
Searching...
No Matches
Typedefs | Functions
testMeshReader.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/shapes/Mesh.h"
#include "DGtal/io/readers/MeshReader.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigTest.h"

Go to the source code of this file.

Typedefs

typedef Point3D Point
 

Functions

bool testMeshReader ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2012/07/04

Functions for testing class MeshReader.

This file is part of the DGtal library.

Definition in file testMeshReader.cpp.

Typedef Documentation

◆ Point

typedef Point3D Point

Definition at line 74 of file testMeshReader.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 157 of file testMeshReader.cpp.

158{
159 trace.beginBlock ( "Testing class MeshReader" );
160 trace.info() << "Args:";
161 for ( int i = 0; i < argc; ++i )
162 trace.info() << " " << argv[ i ];
163 trace.info() << endl;
164
165 bool res = testMeshReader(); // && ... other tests
166 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
167 trace.endBlock();
168 return res ? 0 : 1;
169}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:154
bool testMeshReader()

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testMeshReader(), and DGtal::trace.

◆ testMeshReader()

bool testMeshReader ( )

Example of a test. To be completed.

Definition at line 90 of file testMeshReader.cpp.

91{
92 unsigned int nbok = 0;
93 unsigned int nb = 0;
94 trace.beginBlock ( "Testing block ..." );
95 nb++;
96 std::string filenameOFF = testPath + "samples/box.off";
97 Mesh<Point> a3DMesh;
98 bool importOK = a3DMesh << filenameOFF;
99 nbok += importOK ? 1 : 0;
100
101
102 nb++;
103 Mesh<Point>::MeshFace aFace = a3DMesh.getFace(0);
104 bool isWellImported = (a3DMesh.nbVertex()==8) && (a3DMesh.nbFaces()==6) && (aFace.size()==4) && (aFace.at(0)==0);
105 nbok+=isWellImported? 1: 0;
106
107
108 trace.info() << "(" << nbok << "/" << nb << ") "
109 << "true == true" << std::endl;
110
111
112 nb++;
113 std::string filenameOFS = testPath + "samples/testMesh.ofs";
114 Mesh<Point> a3DMesh2;
115 bool importOK2= a3DMesh2 << filenameOFS;
116 nbok += importOK2 ? 1 : 0;
117
118 nb++;
119 std::string filenameOBJ = testPath + "samples/testObj.obj";
120 Mesh<Point> a3DMesh3;
121 bool importOK3= a3DMesh3 << filenameOBJ;
122 nbok += importOK3 ? 1 : 0;
123
124 nb++;
125 bool importOK4 = a3DMesh3.getFaceColor(0) == DGtal::Color::Red &&
126 a3DMesh3.getFaceColor(5) == DGtal::Color::Purple;
127 nbok += importOK4 ? 1 : 0;
128
129 nb++;
130 Mesh<Point>::MeshFace aFace2 = a3DMesh2.getFace(0);
131 bool isWellImported2 = (a3DMesh2.nbVertex()==32) && (a3DMesh2.nbFaces()==60) && (aFace2.size()==3) && (aFace2.at(0)==0);
132 nbok+=isWellImported2? 1: 0;
133
134 nb++;
135 std::string filenameOBJrel = testPath + "samples/testObjRel.obj";
136 Mesh<Point> a3DMesh4;
137 bool importOK5 = a3DMesh4 << filenameOBJrel;
138 nbok += importOK5 ? 1 : 0;
139
140 nb++;
141 bool importOK6 = a3DMesh4.getFaceColor(0) == DGtal::Color::Red &&
142 a3DMesh4.getFaceColor(5) == DGtal::Color::Purple;
143 nbok += importOK6 ? 1 : 0;
144
145
146 trace.info() << "(" << nbok << "/" << nb << ") "
147 << "true == true" << std::endl;
148 trace.endBlock();
149
150
151 return nbok == nb;
152}
static const Color Purple
Definition: Color.h:424
static const Color Red
Definition: Color.h:416
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:92
const Color & getFaceColor(Index i) const
Size nbFaces() const
Size nbVertex() const
const MeshFace & getFace(Index i) const
std::vector< Index > MeshFace
Definition: Mesh.h:126

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Mesh< TPoint >::getFace(), DGtal::Mesh< TPoint >::getFaceColor(), DGtal::Trace::info(), DGtal::Mesh< TPoint >::nbFaces(), DGtal::Mesh< TPoint >::nbVertex(), DGtal::Color::Purple, DGtal::Color::Red, and DGtal::trace.

Referenced by main().