DGtal  1.0.0
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 74 of file testMeshReader.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 135 of file testMeshReader.cpp.

136 {
137  trace.beginBlock ( "Testing class MeshReader" );
138  trace.info() << "Args:";
139  for ( int i = 0; i < argc; ++i )
140  trace.info() << " " << argv[ i ];
141  trace.info() << endl;
142 
143  bool res = testMeshReader(); // && ... other tests
144  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
145  trace.endBlock();
146  return res ? 0 : 1;
147 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:144
double endBlock()
std::ostream & emphase()
std::ostream & info()
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  Mesh<Point>::MeshFace aFace2 = a3DMesh2.getFace(0);
120  bool isWellImported2 = (a3DMesh2.nbVertex()==32) && (a3DMesh2.nbFaces()==60) && (aFace2.size()==3) && (aFace2.at(0)==0);
121  nbok+=isWellImported2? 1: 0;
122 
123 
124  trace.info() << "(" << nbok << "/" << nb << ") "
125  << "true == true" << std::endl;
126  trace.endBlock();
127 
128 
129  return nbok == nb;
130 }
void beginBlock(const std::string &keyword="")
std::vector< unsigned int > MeshFace
Definition: Mesh.h:116
Size nbVertex() const
Trace trace
Definition: Common.h:144
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:91
double endBlock()
Size nbFaces() const
const MeshFace & getFace(unsigned int i) const
std::ostream & info()

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().