MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / main

Function main

examples/cpp-examples/ContourTriangulation.dox.cpp:9–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include <iostream>
8
9int main()
10{
11 // load image as distance map
12 auto imageLoadRes = MR::ImageLoad::fromAnySupportedFormat( "logo.jpg" );
13 if ( !imageLoadRes.has_value() )
14 {
15 std::cerr << imageLoadRes.error() << "\n";
16 return 1; // error while loading file
17 }
18 auto dmRes = MR::convertImageToDistanceMap( *imageLoadRes );
19 if ( !dmRes.has_value() )
20 {
21 std::cerr << dmRes.error() << "\n";
22 return 1; // error while converting image to distance map
23 }
24
25 auto pl2 = MR::distanceMapTo2DIsoPolyline( *dmRes, 210.0f );
26 auto triangulationRes = MR::PlanarTriangulation::triangulateContours( pl2.contours() );
27
28 auto saveRes = MR::MeshSave::toAnySupportedFormat( triangulationRes, "LogoMesh.ctm" );
29 if ( !saveRes.has_value() )
30 {
31 std::cerr << saveRes.error() << "\n";
32 return 1; // error while saving file
33 }
34 return 0;
35}

Callers

nothing calls this directly

Calls 7

triangulateContoursFunction · 0.85
errorMethod · 0.80
contoursMethod · 0.80
fromAnySupportedFormatFunction · 0.50
toAnySupportedFormatFunction · 0.50

Tested by

no test coverage detected