Skip to content

Commit

Permalink
🦄 refactor: The development of the new OCC module has been essentiall…
Browse files Browse the repository at this point in the history
…y completed
  • Loading branch information
xiangechen committed Oct 2, 2024
1 parent 8406a2d commit eebf9b9
Show file tree
Hide file tree
Showing 37 changed files with 3,840 additions and 456 deletions.
6 changes: 3 additions & 3 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ if (${EMSCRIPTEN})
target_compile_options (${TARGET} PUBLIC
$<$<CONFIG:Release>:-O3>
$<$<CONFIG:Release>:-flto>
-sDISABLE_EXCEPTION_CATCHING=1
$<IF:$<CONFIG:Release>,-sDISABLE_EXCEPTION_CATCHING=1,-sDISABLE_EXCEPTION_CATCHING=0>
-DOCCT_NO_PLUGINS
)

target_link_options (${TARGET} PUBLIC
$<$<CONFIG:Release>:-O3>
$<IF:$<CONFIG:Release>,-O3,-O0>
$<$<CONFIG:Release>:-flto>
-sDISABLE_EXCEPTION_CATCHING=1
$<IF:$<CONFIG:Release>,-sDISABLE_EXCEPTION_CATCHING=1,-sDISABLE_EXCEPTION_CATCHING=0>
-sMODULARIZE=1
-sEXPORT_ES6=1
-sALLOW_MEMORY_GROWTH=1
Expand Down
33 changes: 33 additions & 0 deletions cpp/src/converter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <TopoDS_Shape.hxx>
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>

using namespace emscripten;

class Converter {
public:
static std::string convertToBrep(const TopoDS_Shape& input) {
std::ostringstream oss;
BRepTools::Write(input, oss);
return oss.str();
}

static TopoDS_Shape convertFromBrep(const std::string& input) {
std::istringstream iss(input);
TopoDS_Shape output;
BRep_Builder builder;
BRepTools::Read(output, iss, builder);
return output;
}

};

EMSCRIPTEN_BINDINGS(Converter)
{
class_<Converter>("Converter")
.class_function("convertToBrep", &Converter::convertToBrep)
.class_function("convertFromBrep", &Converter::convertFromBrep)
;
}
Loading

0 comments on commit eebf9b9

Please sign in to comment.