DGtal  0.9.3
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"
Include dependency graph for testMeshReader.cpp:

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 72 of file testMeshReader.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 139 of file testMeshReader.cpp.

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

140 {
141  trace.beginBlock ( "Testing class MeshReader" );
142  trace.info() << "Args:";
143  for ( int i = 0; i < argc; ++i )
144  trace.info() << " " << argv[ i ];
145  trace.info() << endl;
146 
147  bool res = testMeshReader(); // && ... other tests
148  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
149  trace.endBlock();
150  return res ? 0 : 1;
151 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
std::ostream & emphase()
std::ostream & info()
bool testMeshReader()

◆ testMeshReader()

bool testMeshReader ( )

Example of a test. To be completed.

Definition at line 88 of file testMeshReader.cpp.

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

Referenced by main().

89 {
90  unsigned int nbok = 0;
91  unsigned int nb = 0;
92  trace.beginBlock ( "Testing block ..." );
93  nb++;
94  std::string filenameOFF = testPath + "samples/box.off";
95  Mesh<Point> a3DMesh;
96  bool importOK = a3DMesh << filenameOFF;
97  nbok += importOK ? 1 : 0;
98 
99 
100  nb++;
101  Mesh<Point>::MeshFace aFace = a3DMesh.getFace(0);
102  bool isWellImported = (a3DMesh.nbVertex()==8) && (a3DMesh.nbFaces()==6) && (aFace.size()==4) && (aFace.at(0)==0);
103  nbok+=isWellImported? 1: 0;
104 
105 
106  trace.info() << "(" << nbok << "/" << nb << ") "
107  << "true == true" << std::endl;
108 
109 
110  nb++;
111  std::string filenameOFS = testPath + "samples/testMesh.ofs";
112  Mesh<Point> a3DMesh2;
113  bool importOK2= a3DMesh2 << filenameOFS;
114  nbok += importOK2 ? 1 : 0;
115 
116  nb++;
117  Mesh<Point>::MeshFace aFace2 = a3DMesh2.getFace(0);
118  bool isWellImported2 = (a3DMesh2.nbVertex()==32) && (a3DMesh2.nbFaces()==60) && (aFace2.size()==3) && (aFace2.at(0)==0);
119  nbok+=isWellImported2? 1: 0;
120 
121 
122  trace.info() << "(" << nbok << "/" << nb << ") "
123  << "true == true" << std::endl;
124  trace.endBlock();
125 
126 
127 
128 
129 
130 
131 
132 
133  return nbok == nb;
134 }
void beginBlock(const std::string &keyword="")
std::vector< unsigned int > MeshFace
Definition: Mesh.h:116
Trace trace
Definition: Common.h:137
unsigned int nbVertex() const
unsigned int nbFaces() const
Aim: This class is defined to represent a surface mesh through a set of vertices and faces...
Definition: Mesh.h:91
double endBlock()
const MeshFace & getFace(unsigned int i) const
std::ostream & info()