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

Function main

examples/cpp-examples/CollisionSelf.dox.cpp:8–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include <iostream>
7
8int main()
9{
10 auto mesh = MR::makeTorusWithSelfIntersections(); // make torus with self-intersections
11
12 auto selfCollidingParis = MR::findSelfCollidingTriangles( mesh ); // find self-intersecting faces pairs
13 if ( !selfCollidingParis.has_value() )
14 {
15 // check error
16 std::cerr << selfCollidingParis.error();
17 return 1;
18 }
19 for ( auto [fl, fr] : *selfCollidingParis )
20 std::cout << int( fl ) << " " << int( fr ) << "\n"; // print each pair
21
22 auto selfCollidingBitSet = MR::findSelfCollidingTrianglesBS( mesh ); // find bitset of self-intersecting faces
23 if ( !selfCollidingBitSet.has_value() )
24 {
25 // check error
26 std::cerr << selfCollidingBitSet.error();
27 return 1;
28 }
29 std::cout << selfCollidingBitSet->count() << "\n"; // print number of self-intersecting faces
30
31 auto isSelfColliding = MR::findSelfCollidingTriangles( mesh, nullptr ); // fast check if mesh has self-intersections
32 if ( !isSelfColliding.has_value() )
33 {
34 // check error
35 std::cerr << isSelfColliding.error();
36 return 1;
37 }
38 std::cout << *isSelfColliding << "\n";
39 return 0;
40}

Callers

nothing calls this directly

Calls 5

errorMethod · 0.80
countMethod · 0.80

Tested by

no test coverage detected