| 13 | using namespace MR; |
| 14 | |
| 15 | EMSCRIPTEN_BINDINGS( meshlib_boolean ) |
| 16 | { |
| 17 | emscripten::enum_<BooleanOperation>( "BooleanOperation" ) |
| 18 | .value( "InsideA", BooleanOperation::InsideA ) |
| 19 | .value( "InsideB", BooleanOperation::InsideB ) |
| 20 | .value( "OutsideA", BooleanOperation::OutsideA ) |
| 21 | .value( "OutsideB", BooleanOperation::OutsideB ) |
| 22 | .value( "Union", BooleanOperation::Union ) |
| 23 | .value( "Intersection", BooleanOperation::Intersection ) |
| 24 | .value( "DifferenceBA", BooleanOperation::DifferenceBA ) |
| 25 | .value( "DifferenceAB", BooleanOperation::DifferenceAB ); |
| 26 | |
| 27 | emscripten::class_<BooleanResult>( "BooleanResult" ) |
| 28 | .property( "errorString", &BooleanResult::errorString ) |
| 29 | .property( "mesh", +[]( const BooleanResult& r ) { return std::make_shared<Mesh>( r.mesh ); } ) |
| 30 | .function( "valid", &BooleanResult::valid ); |
| 31 | |
| 32 | emscripten::function( "boolean", +[]( std::shared_ptr<Mesh> a, std::shared_ptr<Mesh> b, BooleanOperation op ) |
| 33 | { |
| 34 | return boolean( *a, *b, op ); |
| 35 | } ); |
| 36 | |
| 37 | emscripten::enum_<BooleanResultMapper::MapObject>( "BooleanMapObject" ) |
| 38 | .value( "A", BooleanResultMapper::MapObject::A ) |
| 39 | .value( "B", BooleanResultMapper::MapObject::B ); |
| 40 | |
| 41 | emscripten::class_<BooleanResultMapper>( "BooleanResultMapper" ) |
| 42 | .constructor<>() |
| 43 | .function( "mapFaces", +[]( const BooleanResultMapper& m, const FaceBitSet& bs, BooleanResultMapper::MapObject obj ) |
| 44 | { |
| 45 | return m.map( bs, obj ); |
| 46 | } ) |
| 47 | .function( "mapVerts", +[]( const BooleanResultMapper& m, const VertBitSet& bs, BooleanResultMapper::MapObject obj ) |
| 48 | { |
| 49 | return m.map( bs, obj ); |
| 50 | } ) |
| 51 | .function( "newFaces", +[]( const BooleanResultMapper& m ) { return m.newFaces(); } ) |
| 52 | .function( "filteredOldFaceBitSet", +[]( const BooleanResultMapper& m, const FaceBitSet& bs, BooleanResultMapper::MapObject obj ) |
| 53 | { |
| 54 | return m.filteredOldFaceBitSet( bs, obj ); |
| 55 | } ) |
| 56 | .function( "getNew2OldFaceMap", +[]( const BooleanResultMapper& m, BooleanResultMapper::MapObject obj ) |
| 57 | { |
| 58 | return m.getNew2OldFaceMap( obj ); |
| 59 | } ); |
| 60 | |
| 61 | emscripten::function( "boolean", +[]( std::shared_ptr<Mesh> a, std::shared_ptr<Mesh> b, BooleanOperation op, BooleanResultMapper& mapper ) |
| 62 | { |
| 63 | return boolean( *a, *b, op, nullptr, &mapper ); |
| 64 | } ); |
| 65 | } |
nothing calls this directly
no test coverage detected