DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testMeshWriter.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/Mesh.h"
#include "DGtal/io/writers/MeshWriter.h"

Go to the source code of this file.

Functions

bool testMeshWriter ()
 
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/08

Functions for testing class MeshWriter.

This file is part of the DGtal library.

Definition in file testMeshWriter.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 113 of file testMeshWriter.cpp.

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}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:154
bool testMeshWriter()

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

◆ testMeshWriter()

bool testMeshWriter ( )

Example of a test. To be completed.

[MeshWriterUseMeshCreation]

[MeshWriterUseMeshCreation] [MeshWriterUseMeshExport]

[MeshWriterUseMeshExport]

Definition at line 53 of file testMeshWriter.cpp.

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}
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:92
static bool export2OBJ(std::ostream &out, const Mesh< TPoint > &aMesh)

References DGtal::Mesh< TPoint >::addQuadFace(), DGtal::Mesh< TPoint >::addVertex(), DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::MeshWriter< TPoint >::export2OBJ(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().