Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doxygen/examples/Collision.dox
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Following code presents example of finding collision triangles of two meshes
- <b class="tab-title">C#</b>
\include Collision.dox.cs

- <b class="tab-title">JavaScript</b>
\include Collision.dox.js

</div>

*/
3 changes: 3 additions & 0 deletions doxygen/examples/CollisionPrecise.dox
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Following code presents example of finding preceise collision triangles and edge
- <b class="tab-title">C#</b>
\include CollisionPrecise.dox.cs

- <b class="tab-title">JavaScript</b>
\include CollisionPrecise.dox.js

</div>

*/
3 changes: 3 additions & 0 deletions doxygen/examples/CollisionSelf.dox
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Following code presents example of finding self-intersecting triangles of single
- <b class="tab-title">C#</b>
\include CollisionSelf.dox.cs

- <b class="tab-title">JavaScript</b>
\include CollisionSelf.dox.js

</div>

*/
3 changes: 3 additions & 0 deletions doxygen/examples/ExampleFusion.dox
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Example of Fusion.
- <b class="tab-title">C</b>
\include Fusion.dox.c

- <b class="tab-title">JavaScript</b>
\include Fusion.dox.js

</div>

*/
Expand Down
3 changes: 3 additions & 0 deletions doxygen/examples/ExamplePointsToMesh.dox
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Example of generating a triangulation from a pointcloud.
- <b class="tab-title">C</b>
\include PointsToMesh.dox.c

- <b class="tab-title">JavaScript</b>
\include PointsToMesh.dox.js

</div>

*/
Expand Down
3 changes: 3 additions & 0 deletions doxygen/examples/FreeFormDeformation.dox
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Example of using Free Form deformation of the mesh
- <b class="tab-title">C#</b>
\include FreeFormDeformation.dox.cs

- <b class="tab-title">JavaScript</b>
\include FreeFormDeformation.dox.js

</div>

*/
2 changes: 2 additions & 0 deletions doxygen/examples/GlobalRegistration.dox
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Example of Global Registration
\include GlobalRegistration.dox.c
- <b class="tab-title">C#</b>
\include GlobalRegistration.dox.cs
- <b class="tab-title">JavaScript</b>
\include GlobalRegistration.dox.js

</div>

Expand Down
3 changes: 3 additions & 0 deletions doxygen/examples/LaplacianExample.dox
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Example of using Laplacian deformer
- <b class="tab-title">C</b>
\include LaplacianDeformation.dox.c

- <b class="tab-title">JavaScript</b>
\include LaplacianDeformation.dox.js

</div>

*/
7 changes: 7 additions & 0 deletions doxygen/examples/MeshBoolean.dox
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ Source meshes
Boolean intersection
\image html boolean_after.png

- <b class="tab-title">JavaScript</b>
\include MeshBoolean.dox.js
Source meshes
\image html boolean_before.png
Boolean intersection
\image html boolean_after.png

</div>

*/
7 changes: 7 additions & 0 deletions doxygen/examples/MeshDecimate.dox
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ Source mesh
After decimate
\image html decimate_after.png

- <b class="tab-title">JavaScript</b>
\include MeshDecimate.dox.js
Source mesh
\image html decimate_before.png
After decimate
\image html decimate_after.png

</div>

*/
3 changes: 3 additions & 0 deletions doxygen/examples/MeshExport.dox
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ See a more relevant example \ref ExampleNumpy
- <b class="tab-title">C#</b>
\include MeshExport.dox.cs

- <b class="tab-title">JavaScript</b>
\include MeshExport.dox.js

</div>

*/
2 changes: 2 additions & 0 deletions doxygen/examples/MeshExtrude.dox
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Example of extrude faces on mesh
\include MeshExtrude.dox.py
- <b class="tab-title">C</b>
\include MeshExtrude.dox.c
- <b class="tab-title">JavaScript</b>
\include MeshExtrude.dox.js

</div>

Expand Down
2 changes: 2 additions & 0 deletions doxygen/examples/MeshFillHole.dox
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Example of filling holes
\include MeshFillHole.dox.c
- <b class="tab-title">C#</b>
\include MeshFillHole.dox.cs
- <b class="tab-title">JavaScript</b>
\include MeshFillHole.dox.js

</div>

Expand Down
2 changes: 2 additions & 0 deletions doxygen/examples/MeshICP.dox
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Example of mesh ICP (finding transformation to match objects)
\include MeshICP.dox.c
- <b class="tab-title">C#</b>
\include MeshICP.dox.cs
- <b class="tab-title">JavaScript</b>
\include MeshICP.dox.js

</div>

Expand Down
3 changes: 3 additions & 0 deletions doxygen/examples/MeshLoadSave.dox
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Further examples won't check return values for sake of clarity
- <b class="tab-title">C#</b>
\include MeshLoadSave.dox.cs

- <b class="tab-title">JavaScript</b>
\include MeshLoadSave.dox.js

</div>

*/
2 changes: 2 additions & 0 deletions doxygen/examples/MeshModification.dox
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Some examples of mesh modification are presented here
\include MeshModification.dox.py
- <b class="tab-title">C</b>
\include MeshModification.dox.c
- <b class="tab-title">JavaScript</b>
\include MeshModification.dox.js

</div>

Expand Down
7 changes: 7 additions & 0 deletions doxygen/examples/MeshOffset.dox
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ Source mesh
After offset
\image html offset_after.png

- <b class="tab-title">JavaScript</b>
\include MeshOffset.dox.js
Source mesh
\image html offset_before.png
After offset
\image html offset_after.png

</div>

*/
3 changes: 3 additions & 0 deletions doxygen/examples/MeshOffsetWeighted.dox
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Example of mesh weighted offset
- <b class="tab-title">C</b>
\include MeshOffsetWeighted.dox.c

- <b class="tab-title">JavaScript</b>
\include MeshOffsetWeighted.dox.js

</div>

*/
2 changes: 2 additions & 0 deletions doxygen/examples/MeshResolveDegenerations.dox
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Example of fixing degenerated faces
\include MeshFixDegeneracies.dox.c
- <b class="tab-title">C#</b>
\include MeshFixDegeneracies.dox.cs
- <b class="tab-title">JavaScript</b>
\include MeshFixDegeneracies.dox.js

</div>

Expand Down
2 changes: 2 additions & 0 deletions doxygen/examples/MeshStitchHole.dox
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Example of stitching holes (connect two holes with a cylinder)
\include MeshStitchHole.dox.py
- <b class="tab-title">C</b>
\include MeshStitchHole.dox.c
- <b class="tab-title">JavaScript</b>
\include MeshStitchHole.dox.js

</div>

Expand Down
3 changes: 3 additions & 0 deletions doxygen/examples/NoiseDenoiseExample.dox
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
- <b class="tab-title">C</b>
\include NoiseDenoise.dox.c

- <b class="tab-title">JavaScript</b>
\include NoiseDenoise.dox.js

</div>

*/
3 changes: 3 additions & 0 deletions doxygen/examples/SignedDistance.dox
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Example of usage to get signed distance from mesh to mesh
- <b class="tab-title">C</b>
\include SignedDistance.dox.c

- <b class="tab-title">JavaScript</b>
\include SignedDistance.dox.js

</div>

*/
3 changes: 3 additions & 0 deletions doxygen/examples/SignedDistancePointToMesh.dox
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Example of usage to get signed distance from point to mesh
- <b class="tab-title">C</b>
\include SignedDistancePointToMesh.dox.c

- <b class="tab-title">JavaScript</b>
\include SignedDistancePointToMesh.dox.js

</div>

*/
3 changes: 3 additions & 0 deletions doxygen/examples/SignedDistances.dox
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Example of usage to get signed distances from points of mesh to another referenc
- <b class="tab-title">C</b>
\include SignedDistances.dox.c

- <b class="tab-title">JavaScript</b>
\include SignedDistances.dox.js

</div>

*/
3 changes: 3 additions & 0 deletions doxygen/examples/Triangulation.dox
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Simple triangulation
- <b class="tab-title">C</b>
\include Triangulation.dox.c

- <b class="tab-title">JavaScript</b>
\include Triangulation.dox.js

</div>

*/
1 change: 1 addition & 0 deletions examples/js-examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
25 changes: 25 additions & 0 deletions examples/js-examples/Collision.dox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import createMeshLib from '@meshinspector/meshlib';

const ml = await createMeshLib();

using meshA = ml.makeUVSphere(1.0, 16, 16); // make mesh A
using meshB = ml.makeUVSphere(1.0, 16, 16); // make mesh B
// shift mesh B for better demonstration
using shift = ml.AffineXf3f.translation({ x: 0.1, y: 0.1, z: 0.1 });
meshB.transform(shift);

// find each pair of colliding faces
const collidingFacePairs = ml.findCollidingTriangles(meshA, meshB);
for (const { aFace, bFace } of collidingFacePairs)
console.log(`${aFace} ${bFace}`);

// find bitsets of colliding faces
const bitsets = ml.findCollidingTriangleBitsets(meshA, meshB);
using collidingFacesA = bitsets.a;
using collidingFacesB = bitsets.b;
console.log(collidingFacesA.count()); // number of colliding faces from mesh A
console.log(collidingFacesB.count()); // number of colliding faces from mesh B

// fast check whether mesh A and mesh B collide
const isColliding = ml.findCollidingTriangles(meshA, meshB, true).length > 0;
console.log(isColliding);
21 changes: 21 additions & 0 deletions examples/js-examples/CollisionPrecise.dox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import createMeshLib from '@meshinspector/meshlib';

const ml = await createMeshLib();

using meshA = ml.makeUVSphere(1.0, 16, 16); // make mesh A
using meshB = ml.makeUVSphere(1.0, 16, 16); // make mesh B
// shift mesh B for better demonstration
using shift = ml.AffineXf3f.translation({ x: 0.1, y: 0.1, z: 0.1 });
meshB.transform(shift);

// create converters to integer field (needed for absolute precision predicates)
using converters = ml.getVectorConverters(meshA, meshB);
// find each intersecting edge/triangle pair
using collidingFaceEdges = ml.findCollidingEdgeTrisPrecise(meshA, meshB, converters);
for (let i = 0; i < collidingFaceEdges.size(); ++i) {
using vet = collidingFaceEdges.get(i);
if (vet.isEdgeATriB())
console.log(`edgeA: ${vet.edge}, triB: ${vet.tri()}`);
else
console.log(`triA: ${vet.tri()}, edgeB: ${vet.edge}`);
}
14 changes: 14 additions & 0 deletions examples/js-examples/CollisionSelf.dox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import createMeshLib from '@meshinspector/meshlib';

const ml = await createMeshLib();

using mesh = ml.makeTorusWithSelfIntersections(1.0, 0.1, 16, 16); // make torus with self-intersections

// find self-intersecting face pairs (throws if the search is cancelled)
const selfCollidingPairs = ml.findSelfCollidingTriangles(mesh);
for (const { aFace, bFace } of selfCollidingPairs)
console.log(`${aFace} ${bFace}`);

// find the union of self-intersecting faces
using selfCollidingFaces = ml.findSelfCollidingTrianglesBS(mesh);
console.log(selfCollidingFaces.count()); // number of self-intersecting faces
33 changes: 33 additions & 0 deletions examples/js-examples/FreeFormDeformation.dox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import createMeshLib from '@meshinspector/meshlib';

const ml = await createMeshLib();

// Load mesh
using mesh = ml.MeshLoad.fromAnySupportedFormat('mesh.stl');

// Construct the deformer on the mesh (the JS binding takes the mesh directly)
using ffDeformer = new ml.FreeFormDeformer(mesh);

// Compute mesh bounding box
using box = mesh.computeBoundingBox();

// Init deformer with a 3x3x3 grid on the mesh box
ffDeformer.init({ x: 3, y: 3, z: 3 }, box);

// Move some control points of the grid to the center
const center = box.center();
ffDeformer.setRefGridPointPosition({ x: 1, y: 1, z: 0 }, center);
ffDeformer.setRefGridPointPosition({ x: 1, y: 1, z: 2 }, center);
ffDeformer.setRefGridPointPosition({ x: 0, y: 1, z: 1 }, center);
ffDeformer.setRefGridPointPosition({ x: 2, y: 1, z: 1 }, center);
ffDeformer.setRefGridPointPosition({ x: 1, y: 0, z: 1 }, center);
ffDeformer.setRefGridPointPosition({ x: 1, y: 2, z: 1 }, center);

// Apply the deformation to the mesh vertices
ffDeformer.apply();

// Invalidate the mesh because of the external vertex changes
mesh.invalidateCaches();

// Save deformed mesh
ml.MeshSave.toAnySupportedFormat(mesh, 'deformed_mesh.stl');
15 changes: 15 additions & 0 deletions examples/js-examples/Fusion.dox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import createMeshLib from '@meshinspector/meshlib';

const ml = await createMeshLib();

using pointCloud = ml.PointsLoad.fromAnySupportedFormat('Points.ply');

using bbox = pointCloud.computeBoundingBox();
using params = new ml.PointsToMeshParameters();
params.voxelSize = bbox.diagonal() * 0.01;
params.sigma = Math.max(params.voxelSize, ml.findAvgPointsRadius(pointCloud, 50));
params.minWeight = 1;

using mesh = ml.pointsToMeshFusion(pointCloud, params);

ml.MeshSave.toAnySupportedFormat(mesh, 'Mesh.ply');
Loading
Loading