Skip to content

Commit bda0cc5

Browse files
committed
Merge branch 'dev' into meshsdk
2 parents 1f26a13 + f40f193 commit bda0cc5

File tree

12 files changed

+63
-12
lines changed

12 files changed

+63
-12
lines changed

.github/workflows/build-test-emscripten.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
jobs:
1717
emscripten-build:
1818
timeout-minutes: 40
19-
runs-on: [ self-hosted, linux-arm64, spot ]
19+
runs-on: ubuntu-24.04-arm
2020
container:
2121
image: meshsdk/meshsdk-emscripten-arm64:${{ inputs.docker_image_tag }}
2222
strategy:

.vscode/extensions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"ryu1kn.partial-diff",
66
"ms-vscode.makefile-tools",
77
"llvm-vs-code-extensions.lldb-dap",
8-
"tatsy.vscode-3d-preview",
98
"bierner.emojisense",
109
"ms-vscode.cpptools-extension-pack",
1110
"huizhou.githd",
1211
"streetsidesoftware.code-spell-checker",
1312
"streetsidesoftware.code-spell-checker-british-english",
14-
"streetsidesoftware.code-spell-checker-scientific-terms"
13+
"streetsidesoftware.code-spell-checker-scientific-terms",
14+
"kleinicke.ply-visualizer"
1515
]
1616
}

docker/emscriptenDockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2
7272
WORKDIR /home/
7373
RUN rm -rf meshsdk
7474

75-
# Add a new user "actions-runner" with user id 8877
76-
RUN useradd -u 8877 -m user && \
75+
# Setup non-root user (use 1001 to play nicely with actions/checkout@v4)
76+
# https://github.com/actions/checkout/issues/1014
77+
RUN groupadd -g 1001 user && \
78+
useradd -m -u 1001 -g user -s /bin/bash user && \
7779
sudo chmod -R 777 /emsdk/upstream/emscripten/
7880

7981
# Change to non-root privilege

source/MRDotNetTest/ICPTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void TestMultiwayICP()
4141
var xfs = icp.CalculateTransformations();
4242
Assert.That(icp.GetNumActivePairs(), Is.EqualTo(1748));
4343
Assert.That(icp.GetNumSamples(), Is.EqualTo(1748));
44-
Assert.That(icp.GetMeanSqDistToPoint(), Is.EqualTo(0.00226).Within(1e-5));
44+
Assert.That(icp.GetMeanSqDistToPoint(), Is.EqualTo(0).Within(1e-5));
4545
}
4646

4747
[Test]

source/MRMesh/MRConvexHull.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,12 @@ Contour2f makeConvexHull( Contour2f points )
285285
if ( points.size() < 2 )
286286
return points;
287287

288-
auto minPointIt = std::min_element( points.begin(), points.end(), [] ( auto&& a, auto&& b )
288+
// sort points by coordinates to find a start point and to remove duplicates
289+
std::sort( points.begin(), points.end(), [] ( auto&& a, auto&& b )
289290
{
290291
return std::tie( a.y, a.x ) < std::tie( b.y, b.x );
291292
} );
292-
std::swap( *points.begin(), *minPointIt );
293+
points.erase( std::unique( points.begin(), points.end() ), points.end() );
293294
const auto& minPoint = points.front();
294295

295296
// sort points by polar angle and distance to the start point

source/MRMesh/MRMeshOrPoints.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ void MeshOrPoints::accumulate( PointAccumulator& accum, const AffineXf3f* xf ) c
4949

5050
std::optional<VertBitSet> MeshOrPoints::pointsGridSampling( float voxelSize, size_t maxVoxels, const ProgressCallback & cb ) const
5151
{
52-
assert( voxelSize > 0 );
52+
assert( voxelSize >= 0 );
53+
if ( voxelSize == 0 )
54+
return validPoints();
5355
assert( maxVoxels > 0 );
5456
auto box = computeBoundingBox();
5557
if ( !box.valid() )

source/MRMesh/MRMeshOrPoints.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class MeshOrPoints
4747
/// performs sampling of vertices or points;
4848
/// subdivides bounding box of the object on voxels of approximately given size and returns at most one vertex per voxel;
4949
/// voxelSize is automatically increased to avoid more voxels than \param maxVoxels;
50+
/// if voxelSize == 0 then all valid points are returned;
5051
/// returns std::nullopt if it was terminated by the callback
5152
[[nodiscard]] MRMESH_API std::optional<VertBitSet> pointsGridSampling( float voxelSize, size_t maxVoxels = 500000,
5253
const ProgressCallback & cb = {} ) const;

source/MRMesh/MRMultiwayICP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ bool MultiwayICP::multiwayIter_( bool p2pl )
943943
{
944944
const auto& data = pairs[i][j].vec[idx];
945945
if ( p2pl )
946-
mat.add( int( i ), data.srcPoint, int( j ), data.tgtPoint, ( data.tgtNorm + data.srcNorm ).normalized(), data.weight );
946+
mat.add( int( i ), data.srcPoint, int( j ), data.tgtPoint, data.tgtNorm, data.weight );
947947
else
948948
mat.add( int( i ), data.srcPoint, int( j ), data.tgtPoint, data.weight );
949949
}

source/MRMesh/MRMultiwayICP.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class IICPTreeIndexer
5959
/// Parameters that are used for sampling of the MultiwayICP objects
6060
struct MultiwayICPSamplingParameters
6161
{
62-
/// sampling size of each object
63-
float samplingVoxelSize = 0.0f;
62+
/// sampling size of each object, 0 has special meaning "take all valid points"
63+
float samplingVoxelSize = 0;
6464

6565
/// size of maximum icp group to work with
6666
/// if number of objects exceeds this value, icp is applied in cascade mode
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <MRMesh/MRMultiwayICP.h>
2+
#include <MRMesh/MRTorus.h>
3+
#include <MRMesh/MRMesh.h>
4+
#include <MRMesh/MRAffineXf3.h>
5+
#include <MRMesh/MRGTest.h>
6+
#include <iostream>
7+
8+
namespace MR
9+
{
10+
11+
TEST( MRMesh, MultiwayICPTorus )
12+
{
13+
auto torusRef = makeTorus( 2.5f, 0.7f, 48, 48 );
14+
auto torusMove = torusRef;
15+
16+
auto axis = Vector3f( 1, 0, 0 );
17+
auto trans = Vector3f( 0, 0.2f, 0.105f );
18+
19+
auto xf = AffineXf3f( Matrix3f::rotation( axis, 0.2f ), trans );
20+
21+
ICPObjects objs;
22+
objs.push_back( { torusMove, xf } );
23+
objs.push_back( { torusRef, AffineXf3f{} } );
24+
MultiwayICP icp( objs, MultiwayICPSamplingParameters{} );
25+
26+
ICPProperties props
27+
{
28+
.iterLimit = 20
29+
};
30+
icp.setParams( props );
31+
auto newXfs = icp.calculateTransformations();
32+
EXPECT_EQ( newXfs[ObjId( 1 )], AffineXf3f{} );
33+
std::cout << icp.getStatusInfo() << '\n';
34+
35+
auto newXf = newXfs[ObjId( 0 )];
36+
constexpr float eps = 1e-6f;
37+
EXPECT_NEAR( ( newXf.A - Matrix3f::identity() ).norm(), 0., eps );
38+
EXPECT_NEAR( newXf.b.length(), 0., eps );
39+
}
40+
41+
} //namespace MR

0 commit comments

Comments
 (0)