Skip to content

Commit a3d1a46

Browse files
authored
Merge pull request #9 from alpinebuster/dev
Add supports for #4, #5 and #6
2 parents 9426301 + c37f49f commit a3d1a46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4344
-1197
lines changed

.vscode/settings.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@
112112
"*.lxx": "cpp",
113113
"adolcforward": "cpp",
114114
"cassert": "cpp",
115-
"sparsecholesky": "cpp"
115+
"sparsecholesky": "cpp",
116+
"*.inc": "cpp",
117+
"__node_handle": "cpp",
118+
"queue": "cpp",
119+
"stack": "cpp",
120+
"stacktrace": "cpp",
121+
"target": "cpp",
122+
"barrier": "cpp",
123+
"coroutine": "cpp"
116124
}
117125
}

.vscode/tasks.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"env": {
3232
"MR_EMSCRIPTEN": "ON",
3333
"MR_EMSCRIPTEN_SINGLE": "OFF",
34-
"MR_EMSCRIPTEN_WASM64": "ON"
34+
"MR_EMSCRIPTEN_W64": "ON"
3535
}
3636
},
3737
"command": "./scripts/build_thirdparty.sh",
@@ -76,7 +76,7 @@
7676
"MESHLIB_BUILD_RELEASE": "ON",
7777
"MESHLIB_BUILD_DEBUG": "OFF",
7878
"MR_EMSCRIPTEN_SINGLE": "OFF",
79-
"MR_EMSCRIPTEN_WASM64": "ON"
79+
"MR_EMSCRIPTEN_W64": "ON"
8080
}
8181
},
8282
"command": "./scripts/build_source.sh",
@@ -125,7 +125,7 @@
125125
"MESHLIB_BUILD_RELEASE": "OFF",
126126
"MESHLIB_BUILD_DEBUG": "ON",
127127
"MR_EMSCRIPTEN_SINGLE": "OFF",
128-
"MR_EMSCRIPTEN_WASM64": "ON"
128+
"MR_EMSCRIPTEN_W64": "ON"
129129
}
130130
},
131131
"command": "./scripts/build_source.sh",

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![build-test-distribute](https://github.com/alpinebuster/meshsdk/actions/workflows/build-test-distribute.yml/badge.svg?branch=main)](https://github.com/alpinebuster/meshsdk/actions/workflows/build-test-distribute.yml?branch=main)
22

3-
# MeshSDK with Cross Platform Bindings for MeshLib
3+
# MeshSDK
44

55
The MeshSDK is an open-source library that provides advanced algorithms for 3D data processing. It assists developers and engineers in achieving precise results while delivering significant resource savings. Whether you are working on 3D printing, scanning, inspection, automation, robotics, scientific visualization, or medical devices, our 3D data processing library is ideally suited to meet your needs thanks to its potent capabilities and broad applicability. The SDK provides a robust foundation for 3D data processing, supporting all essential formats like point clouds, meshes, and volumes continuously generated by modern sensors. Our powerful half-edge data structure ensures manifold compliance for precise, reliable mesh representation. Plus, our repository includes clear code samples to help you get started quickly and explore advanced features with ease.
66

examples/web/threejs/editor/js/Sidebar.Object.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,17 @@ function SidebarObject( editor ) {
250250
const floatVec = new editor.mrmesh.StdVectorf();
251251
positionsArr.forEach( v => floatVec.push_back(v) );
252252

253-
// const result = editor.mrmesh.cutMeshWithPolyline( curMeshWrapper.mesh, floatVec );
254-
const result = curMeshWrapper.cutMeshWithPolylineImpl( floatVec );
255-
256-
const newVertices = result.innerMesh.vertices;
257-
const newIndices = new Uint32Array( result.innerMesh.indices );
258-
showMesh( newVertices, newIndices );
253+
const result = editor.mrmesh.cutMeshWithPolylineImpl( curMeshWrapper.mesh, floatVec );
254+
// const result = curMeshWrapper.cutMeshWithPolylineImpl( floatVec );
255+
256+
const innerVertices = result.innerMesh.vertices;
257+
const innerIndices = new Uint32Array(result.innerMesh.indices);
258+
259+
const outerVertices = result.outerMesh.vertices;
260+
const outerIndices = new Uint32Array(result.outerMesh.indices);
261+
262+
showMesh( innerVertices, innerIndices );
263+
showMesh( outerVertices, outerIndices );
259264
break;
260265

261266
case 'wasmOpSegmentByPoints':
@@ -340,7 +345,7 @@ function SidebarObject( editor ) {
340345
const currentUUID = editor.selected.uuid;
341346
if ( currentUUID ) {
342347
if ( editor.wasmObject.hasOwnProperty( currentUUID ) ) {
343-
const newMeshData = editor.wasmObject[currentUUID].fillHoles();
348+
const newMeshData = editor.wasmObject[currentUUID].fillHolesImpl();
344349
const vertices = newMeshData.vertices;
345350
const indices = newMeshData.indices;
346351

@@ -388,9 +393,9 @@ function SidebarObject( editor ) {
388393
-threeWorldDir.z,
389394
)
390395

391-
// const result = editor.mrmesh.fixUndercutsTest( curMeshWrapper.getMesh(), upDir );
396+
const result = editor.mrmesh.fixUndercutsImpl( curMeshWrapper.mesh, upDir, 0.0, 0.0 );
392397
// const result = editor.mrmesh.fixUndercutsTest( curMeshWrapper.mesh, upDir );
393-
const result = curMeshWrapper.fixUndercutsImpl( upDir );
398+
// const result = curMeshWrapper.fixUndercutsImpl( upDir );
394399

395400
const newVertices = result.mesh.vertices;
396401
// const newIndices = new Uint32Array( result.mesh.indices );

examples/web/threejs/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/web/threejs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "three-meshsdk-editor",
3-
"version": "0.6.2",
3+
"version": "0.6.4",
44
"description": "MeshMaster - ThreeJS editor for `meshsdk`.",
55
"keywords": [
66
"threejs",

scripts/build_source.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ echo "Project build script started."
99
echo "You could find output in ${logfile}"
1010

1111
MR_EMSCRIPTEN_SINGLETHREAD=0
12+
MR_EMSCRIPTEN_WASM64=0
1213
if [[ $OSTYPE == "linux"* ]]; then
1314
if [ ! -n "$MR_EMSCRIPTEN" ]; then
1415
read -t 5 -p "Build with emscripten? Press (y) in 5 seconds to build (y/s/l/N) (s - singlethreaded, l - 64-bit)" -rsn 1
@@ -42,13 +43,12 @@ else
4243
MR_EMSCRIPTEN="OFF"
4344
fi
4445
fi
45-
echo "Emscripten ${MR_EMSCRIPTEN}, singlethread ${MR_EMSCRIPTEN_SINGLETHREAD}, 64-bit ${MR_EMSCRIPTEN_WASM64:-0}, SDK only ${MR_EMSCRIPTEN_SDK:-0}"
4646

4747
if [ $MR_EMSCRIPTEN == "ON" ]; then
4848
if [[ $MR_EMSCRIPTEN_SINGLE == "ON" ]]; then
4949
MR_EMSCRIPTEN_SINGLETHREAD=1
5050
fi
51-
if [[ $MR_EMSCRIPTEN_WASM64 == "ON" ]]; then
51+
if [[ $MR_EMSCRIPTEN_W64 == "ON" ]]; then
5252
MR_EMSCRIPTEN_WASM64=1
5353
fi
5454
fi
@@ -75,6 +75,8 @@ if [ ! -n "$MESHLIB_BUILD_DEBUG" ]; then
7575
echo "Debug ${MESHLIB_BUILD_DEBUG}"
7676
fi
7777

78+
echo "Emscripten ${MR_EMSCRIPTEN:-OFF}, singlethread ${MR_EMSCRIPTEN_SINGLE:-OFF}, 64-bit ${MR_EMSCRIPTEN_W64:-OFF}, SDK only ${MR_EMSCRIPTEN_SDK:-OFF}, Release ${MESHLIB_BUILD_RELEASE:-OFF}, Debug ${MESHLIB_BUILD_DEBUG:-OFF}"
79+
7880
# add env options to cmake
7981
MR_CMAKE_OPTIONS="${MR_CMAKE_OPTIONS:-}"
8082

scripts/build_thirdparty.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ else
3333
fi
3434

3535
MR_EMSCRIPTEN_SINGLETHREAD=0
36+
MR_EMSCRIPTEN_WASM64=0
3637
if [[ $OSTYPE == "linux"* ]] && [ "${MR_STATE}" != "DOCKER_BUILD" ]; then
3738
if [ ! -n "$MR_EMSCRIPTEN" ]; then
3839
read -t 5 -p "Build with emscripten? Press (y) in 5 seconds to build (y/s/l/N) (s - singlethreaded, l - 64-bit)" -rsn 1
@@ -55,13 +56,12 @@ else
5556
MR_EMSCRIPTEN="OFF"
5657
fi
5758
fi
58-
echo "Emscripten ${MR_EMSCRIPTEN}, singlethread ${MR_EMSCRIPTEN_SINGLETHREAD}, 64-bit ${MR_EMSCRIPTEN_WASM64:-0}"
5959

6060
if [ $MR_EMSCRIPTEN == "ON" ]; then
6161
if [[ $MR_EMSCRIPTEN_SINGLE == "ON" ]]; then
6262
MR_EMSCRIPTEN_SINGLETHREAD=1
6363
fi
64-
if [[ $MR_EMSCRIPTEN_WASM64 == "ON" ]]; then
64+
if [[ $MR_EMSCRIPTEN_W64 == "ON" ]]; then
6565
MR_EMSCRIPTEN_WASM64=1
6666
fi
6767
elif [ -n "${INSTALL_REQUIREMENTS}" ]; then
@@ -71,6 +71,8 @@ else
7171
echo "Unsupported system. Installing dependencies is your responsibility."
7272
fi
7373

74+
echo "Emscripten ${MR_EMSCRIPTEN:-OFF}, singlethread ${MR_EMSCRIPTEN_SINGLE:-OFF}, 64-bit ${MR_EMSCRIPTEN_W64:-OFF}"
75+
7476
# FIXME: make it optional
7577
rm -rf "${MESHLIB_THIRDPARTY_BUILD_DIR}"
7678
mkdir -p "${MESHLIB_THIRDPARTY_BUILD_DIR}"

source/MRJavaScript/MRAABBTreePoints.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33

44
#include <MRMesh/MRMesh.h>
55
#include <MRMesh/MRMeshFwd.h>
6-
#include <MRMesh/MRAABBTreePoints.h>
6+
#include <MRMesh/MRBitSet.h>
7+
#include <MRMesh/MRBox.h>
78
#include <MRMesh/MRPointCloud.h>
9+
#include <MRMesh/MRAABBTreePoints.h>
810

911
using namespace emscripten;
1012
using namespace MR;
1113

1214
EMSCRIPTEN_BINDINGS( AABBTreePointsModule )
1315
{
14-
register_vector<AABBTreePoints::Point>( "VectorAABBTreePointsPoint" );
15-
register_vector<AABBTreePoints::Node>( "VectorAABBTreePointsNode" );
16-
1716
value_object<AABBTreePoints::Point>( "AABBTreePointsPoint" )
1817
.field( "coord", &AABBTreePoints::Point::coord )
1918
.field( "id", &AABBTreePoints::Point::id );

source/MRJavaScript/MRBuffer.cpp

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,72 +6,75 @@
66
#include <MRMesh/MRId.h>
77
#include <MRMesh/MRBuffer.h>
88

9+
#include "MRBuffer.h"
10+
911
using namespace emscripten;
1012
using namespace MR;
1113

14+
1215
using FaceBMapBuffer = Buffer<FaceId, FaceId>;
1316
using VertBMapBuffer = Buffer<VertId, VertId>;
1417
using EdgeBMapBuffer = Buffer<EdgeId, EdgeId>;
1518
using UndirectedEdgeBMapBuffer = Buffer<UndirectedEdgeId, UndirectedEdgeId>;
1619
using WholeEdgeBMapBuffer = Buffer<EdgeId, UndirectedEdgeId>;
1720

18-
EMSCRIPTEN_BINDINGS( BufferModule )
19-
{
20-
class_<FaceBMapBuffer>( "FaceBMapBuffer" )
21-
.constructor<>()
22-
.constructor<size_t>()
23-
24-
.function( "capacity", &FaceBMapBuffer::capacity )
25-
.function( "size", &FaceBMapBuffer::size )
26-
.function( "empty", &FaceBMapBuffer::empty )
27-
.function( "clear", &FaceBMapBuffer::clear )
28-
.function( "resize", &FaceBMapBuffer::resize )
2921

30-
// FIXME
31-
// .function( "get", select_overload<const FaceId& ( FaceId ) const>( &FaceBMapBuffer::operator[] ) )
32-
// .function( "set", select_overload<FaceId& ( FaceId )>( &FaceBMapBuffer::operator[] ) )
33-
.function("get", optional_override([](const FaceBMapBuffer& buf, FaceId id) -> FaceId {
34-
return buf[id]; // Return copy (avoid references)
35-
}))
36-
.function("set", optional_override([](FaceBMapBuffer& buf, FaceId id, const FaceId& value) {
37-
buf[id] = value;
38-
} ) )
39-
40-
// FIXME
41-
// .function( "data", select_overload<FaceId* ()>( &FaceBMapBuffer::data ), allow_raw_pointers() )
42-
// .function( "dataConst", select_overload<FaceId* () const>( &FaceBMapBuffer::data ), allow_raw_pointers() )
43-
.function( "dataPtr", optional_override( [] ( FaceBMapBuffer& self )
44-
{
45-
return self.data(); // T*
46-
}), allow_raw_pointers())
47-
48-
.function( "beginId", &FaceBMapBuffer::beginId )
49-
.function( "backId", &FaceBMapBuffer::backId )
50-
.function( "endId", &FaceBMapBuffer::endId )
51-
.function( "heapBytes", &FaceBMapBuffer::heapBytes );
22+
namespace MRJS
23+
{
5224

53-
54-
class_<VertBMapBuffer>( "VertBMapBuffer" )
55-
.constructor<>()
56-
.constructor<size_t>();
25+
EMSCRIPTEN_BINDINGS( BufferModule )
26+
{
27+
///
28+
BufferBinding<FaceId, FaceId>( "FaceBMapBuffer" ).init();
29+
BufferBinding<VertId, VertId>( "VertBMapBuffer" ).init();
30+
BufferBinding<EdgeId, EdgeId>( "EdgeBMapBuffer" ).init();
31+
BufferBinding<UndirectedEdgeId, UndirectedEdgeId>( "UndirectedEdgeBMapBuffer" ).init();
32+
BufferBinding<EdgeId, UndirectedEdgeId>( "WholeEdgeBMapBuffer" ).init();
5733

58-
59-
class_<EdgeBMapBuffer>( "EdgeBMapBuffer" )
60-
.constructor<>()
61-
.constructor<size_t>();
34+
BufferBinding<FaceId, size_t>( "FaceIdEdgeIdSizeTBMapBuffer" ).init();
35+
BufferBinding<VertId, size_t>( "VertIdSizeTBMapBuffer" ).init();
36+
BufferBinding<EdgeId, size_t>( "EdgeIdSizeTBMapBuffer" ).init();
37+
BufferBinding<UndirectedEdgeId, size_t>( "UndirectedEdgeIdSizeTBMapBuffer" ).init();
38+
///
6239

63-
64-
class_<UndirectedEdgeBMapBuffer>( "UndirectedEdgeBMapBuffer" )
65-
.constructor<>()
66-
.constructor<size_t>();
6740

68-
69-
class_<WholeEdgeBMapBuffer>( "WholeEdgeBMapBuffer" )
41+
///
42+
class_<PackMapping>( "PackMapping" )
7043
.constructor<>()
71-
.constructor<size_t>();
7244

45+
.function( "getE", optional_override( [] ( PackMapping& self ) -> UndirectedEdgeBMap*
46+
{
47+
return &self.e;
48+
} ), allow_raw_pointers() )
49+
.function( "setE", optional_override( []( PackMapping& self, UndirectedEdgeBMap& newE ) {
50+
self.e = std::move( newE );
51+
} ), allow_raw_pointers() )
52+
.function( "setEWithPtr", optional_override( []( PackMapping& self, UndirectedEdgeBMap* newE ) {
53+
if ( newE ) self.e = std::move( *newE );
54+
} ), allow_raw_pointers() )
55+
56+
.function( "getF", optional_override( [] ( PackMapping& self ) -> FaceBMap*
57+
{
58+
return &self.f;
59+
} ), allow_raw_pointers() )
60+
.function( "setF", optional_override( []( PackMapping& self, FaceBMap& newB ) {
61+
self.f = std::move( newB );
62+
} ), allow_raw_pointers() )
63+
.function( "setFWithPtr", optional_override( []( PackMapping& self, FaceBMap* newB ) {
64+
if ( newB ) self.f = std::move( *newB );
65+
} ), allow_raw_pointers() )
66+
67+
.function( "getV", optional_override( [] ( PackMapping& self ) -> VertBMap*
68+
{
69+
return &self.v;
70+
} ), allow_raw_pointers() )
71+
.function( "setV", optional_override( []( PackMapping& self, VertBMap& newV ) {
72+
self.v = std::move( newV );
73+
} ), allow_raw_pointers() )
74+
.function( "setVWithPtr", optional_override( []( PackMapping& self, VertBMap* newV ) {
75+
if ( newV ) self.v = std::move( *newV );
76+
} ), allow_raw_pointers() );
77+
///
78+
}
7379

74-
// FIXME
75-
class_<PackMapping>( "PackMapping" )
76-
.constructor<>();
7780
}

0 commit comments

Comments
 (0)