DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
io/display3DToOFF.cpp

Example of OFF generation from a Display3D object.

See also:
Export 3D mesh in OFF and OBJ format
visuDisplay3DToOFF.png
Visualisation of the Display3D mesh export using MeshLab software ( http://meshlab.sourceforge.net).
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/Display3D.h"
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"
using namespace std;
using namespace DGtal;
int main( int /*argc*/, char** /*argv*/ )
{
std::string inputFilename = examplesPath + "samples/Al.100.vol";
Display3D viewer;
Image image = VolReader<Image>::importVol(inputFilename);
Z3i::DigitalSet set3d (image.domain());
SetFromImage<Z3i::DigitalSet>::append<Image>(set3d, image, 0,255);
viewer << set3d ;
viewer >> "exportMeshToOFF.off";
// Alternatively the viewer can be exported also towards an output stream but exclusively in OFF format:
// ofstream out;
// out.open( "exportMeshToOFF.off");
// viewer>> out;
// out.close();
return 0;
}