Skip to content
Open
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
8 changes: 4 additions & 4 deletions examples/c-sharp-examples/GlobalRegistration.dox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public static void Run(string[] args)
input_pointclouds.Add(pc); // Need this to prevent the point-cloud object from dying too early.
MR.MeshOrPointsXf obj = new MR.MeshOrPointsXf(pc, new MR.AffineXf3f());
inputs.PushBack(obj);
maxBBox.Include(obj.Obj.ComputeBoundingBox());
maxBBox.Include(obj.obj.ComputeBoundingBox());
}

MR.MultiwayICPSamplingParameters samplingParams = new();
samplingParams.SamplingVoxelSize = maxBBox.Diagonal() * 0.03f;
samplingParams.samplingVoxelSize = maxBBox.Diagonal() * 0.03f;

MR.MultiwayICP icp = new(inputs, samplingParams);
MR.ICPProperties iCPProperties = new();
Expand All @@ -59,8 +59,8 @@ public static void Run(string[] args)
{
MR.ObjId id = new(i);
var xf = xfs.Index(id);
for (ulong j = 0; j < inputs.Index(id).Obj.Points().Size(); j++)
output.AddPoint(xf.Call(inputs.Index(id).Obj.Points().Index(new MR.VertId(j))));
for (ulong j = 0; j < inputs.Index(id).obj.Points().Size(); j++)
output.AddPoint(xf.Call(inputs.Index(id).obj.Points().Index(new MR.VertId(j))));
}

MR.PointsSave.ToAnySupportedFormat(output, args[args.Length - 1]);
Expand Down
2 changes: 1 addition & 1 deletion examples/c-sharp-examples/MeshBoolean.dox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void Run(string[] args)
MR.BooleanResult res = MR.Boolean(mesh_a, mesh_b, MR.BooleanOperation.Intersection);

// save result to STL file
MR.MeshSave.ToAnySupportedFormat(res.Mesh, "out_boolean.stl");
MR.MeshSave.ToAnySupportedFormat(res.mesh, "out_boolean.stl");
}
catch (Exception e)
{
Expand Down
8 changes: 4 additions & 4 deletions examples/c-sharp-examples/MeshDecimate.dox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public static void Run(string[] args)

// Setup decimate parameters
MR.DecimateSettings ds = new();
ds.Strategy = MR.DecimateStrategy.MinimizeError;
ds.MaxError = 1e-5f * mesh.ComputeBoundingBox().Diagonal();
ds.TinyEdgeLength = 1e-3f;
ds.PackMesh = true;
ds.strategy = MR.DecimateStrategy.MinimizeError;
ds.maxError = 1e-5f * mesh.ComputeBoundingBox().Diagonal();
ds.tinyEdgeLength = 1e-3f;
ds.packMesh = true;

// Decimate mesh
MR.DecimateResult result = MR.DecimateMesh(mesh, ds);
Expand Down
10 changes: 5 additions & 5 deletions examples/c-sharp-examples/MeshExport.dox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ public static void Run(string[] args)
{
MR.Mesh mesh = MR.MakeCube(MR.Vector3f.Diagonal(1), MR.Vector3f.Diagonal(-0.5f));
Console.WriteLine("Vertices coordinates:");
for (ulong i = 0; i < mesh.Points.Size(); ++i)
for (ulong i = 0; i < mesh.points.Size(); ++i)
{
var p = mesh.Points.Index(new MR.VertId(i));
Console.WriteLine("Vertex {0} coordinates: {1}; {2}; {3}", i, p.X, p.Y, p.Z);
var p = mesh.points.Index(new MR.VertId(i));
Console.WriteLine("Vertex {0} coordinates: {1}; {2}; {3}", i, p.x, p.y, p.z);
}

MR.Triangulation tri = mesh.Topology.GetTriangulation();
MR.Triangulation tri = mesh.topology.GetTriangulation();

for (ulong i = 0; i < tri.Size(); ++i)
{
var t = tri.Index(new MR.FaceId(i));
Console.WriteLine("Triangle {0} vertices: {1}; {2}; {3}", i, t.Elems._0.Id, t.Elems._1.Id, t.Elems._2.Id);
Console.WriteLine("Triangle {0} vertices: {1}; {2}; {3}", i, t.elems._0.id, t.elems._1.id, t.elems._2.id);
}
}
catch (Exception e)
Expand Down
4 changes: 2 additions & 2 deletions examples/c-sharp-examples/MeshFillHole.dox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public static void Run(string[] args)

var mesh = MR.MeshLoad.FromAnySupportedFormat(inputFile);

MR.Std.Vector_MREdgeId holes = mesh.Topology.FindHoleRepresentiveEdges();
MR.Std.Vector_MREdgeId holes = mesh.topology.FindHoleRepresentiveEdges();

MR.FillHoleParams fillHoleParams = new();
fillHoleParams.Metric.Assign(MR.GetUniversalMetric(mesh));
fillHoleParams.metric.Assign(MR.GetUniversalMetric(mesh));
MR.FaceBitSet outfaces = new();
// TODO
// fillHoleParams.OutNewFaces = ...
Expand Down
4 changes: 2 additions & 2 deletions examples/c-sharp-examples/MeshFixDegeneracies.dox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public static void Run(string[] args)
var mesh = MR.MeshLoad.FromAnySupportedFormat(inputFile);

MR.FixMeshDegeneraciesParams parameters = new();
parameters.MaxDeviation = mesh.ComputeBoundingBox().Diagonal() * 1e-5f;
parameters.TinyEdgeLength = 1e-3f;
parameters.maxDeviation = mesh.ComputeBoundingBox().Diagonal() * 1e-5f;
parameters.tinyEdgeLength = 1e-3f;

MR.FixMeshDegeneracies(mesh, parameters);
MR.MeshSave.ToAnySupportedFormat(mesh, outputFile);
Expand Down
6 changes: 3 additions & 3 deletions examples/c-sharp-examples/MeshICP.dox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public static void Run()
MR.MeshOrPointsXf mesh_xf_fixed = new(mesh_fixed, new MR.AffineXf3f());

// Prepare ICP parameters
float diagonal = mesh_xf_fixed.Obj.ComputeBoundingBox().Diagonal();
float diagonal = mesh_xf_fixed.obj.ComputeBoundingBox().Diagonal();
float icpSamplingVoxelSize = diagonal * 0.01f; // To sample points from object
MR.ICPProperties icpParams = new();
icpParams.DistThresholdSq = diagonal * diagonal * 0.01f; // Use points pairs with maximum distance specified
icpParams.ExitVal = diagonal * 0.003f; // Stop when distance reached
icpParams.distThresholdSq = diagonal * diagonal * 0.01f; // Use points pairs with maximum distance specified
icpParams.exitVal = diagonal * 0.003f; // Stop when distance reached

// Calculate transformation
MR.ICP icp = new(mesh_xf_floating, mesh_xf_fixed, icpSamplingVoxelSize);
Expand Down
2 changes: 1 addition & 1 deletion examples/c-sharp-examples/MeshOffset.dox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void Run(string[] args)

// Setup parameters
MR.OffsetParameters op = new();
op.VoxelSize = MR.SuggestVoxelSize(mp, 1e6f);
op.voxelSize = MR.SuggestVoxelSize(mp, 1e6f);

// Make offset mesh
var result = MR.OffsetMesh(mp, offsetValue, op);
Expand Down
2 changes: 1 addition & 1 deletion examples/c-sharp-examples/Triangulation.dox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void Run()
// Fix possible issues
MR.OffsetParameters offsetParameters = new();
MR.MeshPart mp = new(triangulated);
offsetParameters.VoxelSize = MR.SuggestVoxelSize(mp, 5e+6f);
offsetParameters.voxelSize = MR.SuggestVoxelSize(mp, 5e+6f);
var offset = MR.OffsetMesh(mp, 0f, offsetParameters);

// Save result
Expand Down
20 changes: 10 additions & 10 deletions source/MRDotNet2Test/src/AffineXffTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ internal class AffineXfTests
public void TestDefaultConstructor()
{
var a = new AffineXf3f();
Assert.That( a.A == new Matrix3f() );
Assert.That( a.B == new Vector3f() );
Assert.That( a.a == new Matrix3f() );
Assert.That( a.b == new Vector3f() );
}

[Test]
Expand All @@ -21,26 +21,26 @@ public void TestConstructor()
var b = new Vector3f( 10, 11, 12 );

var a = new AffineXf3f( A, b );
Assert.That( a.A == A );
Assert.That( a.B == b );
Assert.That( a.a == A );
Assert.That( a.b == b );
}

[Test]
public void TestLinearConstructor()
{
var A = new Matrix3f( new Vector3f( 1, 2, 3 ), new Vector3f( 4, 5, 6 ), new Vector3f( 7, 8, 9 ) );
var a = AffineXf3f.Linear( A );
Assert.That( a.A == A );
Assert.That( a.B == new Vector3f() );
Assert.That( a.a == A );
Assert.That( a.b == new Vector3f() );
}

[Test]
public void TestTranslationConstructor()
{
var b = new Vector3f( 10, 11, 12 );
var a = AffineXf3f.Translation( b );
Assert.That( a.A == new Matrix3f() );
Assert.That( a.B == b );
Assert.That( a.a == new Matrix3f() );
Assert.That( a.b == b );
}

[Test]
Expand All @@ -51,8 +51,8 @@ public void TestMultiplication()
var xf = new AffineXf3f( A, b );

var res = xf * xf;
Assert.That( res.A == A * A );
Assert.That( res.B == A * b + b );
Assert.That( res.a == A * A );
Assert.That( res.b == A * b + b );
}

}
Expand Down
48 changes: 24 additions & 24 deletions source/MRDotNet2Test/src/BooleanTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public void TestOperations()
Matrix3f rotation = new Matrix3f();
for (int i = 0; i < 3; ++i)
if ( ( maskRot & (1 << i) ) > 0 )
rotation = Matrix3f.Rotation( baseAxis[i], angle ) * rotation;
rotation = Matrix3f.Rotation( baseAxis[i], angle ) * rotation;

BooleanParameters parameters = new BooleanParameters();
parameters.RigidB2A = AffineXf3f.Translation(shiftVec) * AffineXf3f.Linear(rotation);
parameters.rigidB2A = AffineXf3f.Translation(shiftVec) * AffineXf3f.Linear(rotation);

Assert.DoesNotThrow(() => Boolean(meshA, meshB, BooleanOperation.Union, parameters));
Assert.DoesNotThrow(() => Boolean(meshA, meshB, BooleanOperation.Intersection, parameters));
Expand All @@ -57,47 +57,47 @@ public void TestMapper()
meshB.Transform(AffineXf3f.Linear(Matrix3f.Rotation(Vector3f.PlusZ(), Vector3f.PlusY())));

var parameters = new BooleanParameters();
parameters.Mapper = new BooleanResultMapper();
parameters.mapper = new BooleanResultMapper();
var booleanResult = Boolean(meshA, meshB, BooleanOperation.Union, parameters);

var validPointsA = meshA.Topology.GetValidVerts();
var validPointsB = meshB.Topology.GetValidVerts();
var validFacesA = meshA.Topology.GetValidFaces();
var validFacesB = meshB.Topology.GetValidFaces();
var validPointsA = meshA.topology.GetValidVerts();
var validPointsB = meshB.topology.GetValidVerts();
var validFacesA = meshA.topology.GetValidFaces();
var validFacesB = meshB.topology.GetValidFaces();

var old2NewVerts = parameters.Mapper.GetMaps(BooleanResultMapper.MapObject.A).Old2newVerts;
var vMapA = parameters.Mapper.Map(validPointsA, BooleanResultMapper.MapObject.A);
var vMapB = parameters.Mapper.Map(validPointsB, BooleanResultMapper.MapObject.B);
var old2NewVerts = parameters.mapper.GetMaps(BooleanResultMapper.MapObject.A).old2newVerts;
var vMapA = parameters.mapper.Map(validPointsA, BooleanResultMapper.MapObject.A);
var vMapB = parameters.mapper.Map(validPointsB, BooleanResultMapper.MapObject.B);

Assert.That(vMapA.Size(), Is.EqualTo(60) );
Assert.That(vMapA.Count(), Is.EqualTo(60));
Assert.That(vMapB.Size(), Is.EqualTo(204) );
Assert.That(vMapB.Count(), Is.EqualTo(48));


var fMapA = parameters.Mapper.Map(validFacesA, BooleanResultMapper.MapObject.A);
var fMapB = parameters.Mapper.Map(validFacesB, BooleanResultMapper.MapObject.B);
var fMapA = parameters.mapper.Map(validFacesA, BooleanResultMapper.MapObject.A);
var fMapB = parameters.mapper.Map(validFacesB, BooleanResultMapper.MapObject.B);

Assert.That(fMapA.Size(), Is.EqualTo(224) );
Assert.That(fMapA.Count(), Is.EqualTo(224));
Assert.That(fMapB.Size(), Is.EqualTo(416) );
Assert.That(fMapB.Count(), Is.EqualTo(192));

var newFaces = parameters.Mapper.NewFaces();
var newFaces = parameters.mapper.NewFaces();
Assert.That(newFaces.Size(), Is.EqualTo(416) );
Assert.That(newFaces.Count(), Is.EqualTo(252));

var mapsA = parameters.Mapper.GetMaps( BooleanResultMapper.MapObject.A );
Assert.That(!mapsA.Identity);
Assert.That( mapsA.Old2newVerts.Size(), Is.EqualTo(160) );
Assert.That( mapsA.Cut2newFaces.Size(), Is.EqualTo(348) );
Assert.That( mapsA.Cut2origin.Size(), Is.EqualTo(348) );

var mapsB = parameters.Mapper.GetMaps( BooleanResultMapper.MapObject.B );
Assert.That(!mapsB.Identity);
Assert.That( mapsB.Old2newVerts.Size(), Is.EqualTo(160) );
Assert.That( mapsB.Cut2newFaces.Size(), Is.EqualTo(384) );
Assert.That( mapsB.Cut2origin.Size(), Is.EqualTo(384) );
var mapsA = parameters.mapper.GetMaps( BooleanResultMapper.MapObject.A );
Assert.That(!mapsA.identity);
Assert.That( mapsA.old2newVerts.Size(), Is.EqualTo(160) );
Assert.That( mapsA.cut2newFaces.Size(), Is.EqualTo(348) );
Assert.That( mapsA.cut2origin.Size(), Is.EqualTo(348) );

var mapsB = parameters.mapper.GetMaps( BooleanResultMapper.MapObject.B );
Assert.That(!mapsB.identity);
Assert.That( mapsB.old2newVerts.Size(), Is.EqualTo(160) );
Assert.That( mapsB.cut2newFaces.Size(), Is.EqualTo(384) );
Assert.That( mapsB.cut2origin.Size(), Is.EqualTo(384) );
}
}
}
26 changes: 13 additions & 13 deletions source/MRDotNet2Test/src/Box3Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using static MR;

namespace MRTest
{
{
[TestFixture]
internal class Box3Tests
{
Expand All @@ -17,23 +17,23 @@ public void TestDefaultConstructor()
public void TestBox()
{
var box = new Box3f(new Vector3f(1, 2, 3), new Vector3f(4, 5, 6));
Assert.That(box.Min.X == 1);
Assert.That(box.Min.Y == 2);
Assert.That(box.Min.Z == 3);
Assert.That(box.min.x == 1);
Assert.That(box.min.y == 2);
Assert.That(box.min.z == 3);

Assert.That(box.Max.X == 4);
Assert.That(box.Max.Y == 5);
Assert.That(box.Max.Z == 6);
Assert.That(box.max.x == 4);
Assert.That(box.max.y == 5);
Assert.That(box.max.z == 6);

var center = box.Center();
Assert.That(center.X == 2.5);
Assert.That(center.Y == 3.5);
Assert.That(center.Z == 4.5);
Assert.That(center.x == 2.5);
Assert.That(center.y == 3.5);
Assert.That(center.z == 4.5);

var size = box.Size();
Assert.That(size.X == 3);
Assert.That(size.Y == 3);
Assert.That(size.Z == 3);
Assert.That(size.x == 3);
Assert.That(size.y == 3);
Assert.That(size.z == 3);

float diagonal = box.Diagonal();
Assert.That(diagonal, Is.EqualTo(5.19).Within(0.01));
Expand Down
4 changes: 2 additions & 2 deletions source/MRDotNet2Test/src/ConvexHullTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public void TestConvexHull()
var meshA = MakeCube(Vector3f.Diagonal(1), Vector3f.Diagonal(-0.5f));
var meshB = MakeCube(Vector3f.Diagonal(1), Vector3f.Diagonal(0.0f));
var union = Boolean(meshA, meshB, BooleanOperation.Union);
var convexHull = MakeConvexHull(union.Mesh);
var convexHull = MakeConvexHull(union.mesh);

Assert.That(convexHull.Points.Size() == 14);
Assert.That(convexHull.points.Size() == 14);
}
}
}
20 changes: 10 additions & 10 deletions source/MRDotNet2Test/src/DecimateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ public void TestDecimate()
{
Mesh sphere = MakeSphere( new SphereParams( 0.5f, 30000 ) );

var savedRegion = new FaceBitSet((Const_BitSet)sphere.Topology.GetValidFaces());
var savedRegion = new FaceBitSet((Const_BitSet)sphere.topology.GetValidFaces());

var parameters = new DecimateSettings();
var region = new FaceBitSet((Const_BitSet)sphere.Topology.GetValidFaces());
var region = new FaceBitSet((Const_BitSet)sphere.topology.GetValidFaces());
if ( region is not null )
parameters.Region = region;
parameters.region = region;

parameters.MaxTriangleAspectRatio = 80;
parameters.maxTriangleAspectRatio = 80;

var decimateResult = DecimateMesh(sphere, parameters);
Assert.That(parameters.Region is not null && !parameters.Region.Equals( savedRegion ) );
Assert.That(decimateResult.FacesDeleted > 0);
Assert.That(decimateResult.VertsDeleted > 0);
Assert.That(parameters.region is not null && !parameters.region.Equals( savedRegion ) );
Assert.That(decimateResult.facesDeleted > 0);
Assert.That(decimateResult.vertsDeleted > 0);
}

[Test]
public void TestRemesh()
{
var sphere = MakeSphere( new SphereParams( 0.5f, 300 ) );
Assert.That(sphere.Topology.GetValidFaces().Count(), Is.EqualTo(596));
Assert.That(sphere.topology.GetValidFaces().Count(), Is.EqualTo(596));
var parameters = new RemeshSettings();
parameters.TargetEdgeLen = 0.1f;
parameters.targetEdgeLen = 0.1f;
var remeshResult = Remesh(sphere, parameters);
Assert.That(sphere.Topology.GetValidFaces().Count(), Is.EqualTo(716));
Assert.That(sphere.topology.GetValidFaces().Count(), Is.EqualTo(716));
}
}
}
12 changes: 6 additions & 6 deletions source/MRDotNet2Test/src/ExpandShrink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ internal class ExpandShrinkTests
public void TestExpandShrink()
{
var mesh = MakeSphere(new SphereParams(1.0f, 3000));
var region = Expand(mesh.Topology, new FaceId(0), 3);
var region = Expand(mesh.topology, new FaceId(0), 3);
Assert.That(region.Count, Is.EqualTo(75));
Expand(mesh.Topology, region, 3);
Expand(mesh.topology, region, 3);
Assert.That(region.Count, Is.GreaterThan(75));
Shrink(mesh.Topology, region, 3);
Shrink(mesh.topology, region, 3);
Assert.That(region.Count, Is.EqualTo(75));
}

[Test]
public void TestExpandShrinkVerts()
{
var mesh = MakeSphere(new SphereParams(1.0f, 3000));
var region = Expand(mesh.Topology, new VertId(0), 3);
var region = Expand(mesh.topology, new VertId(0), 3);
Assert.That(region.Count, Is.EqualTo(37));
Expand(mesh.Topology, region, 3);
Expand(mesh.topology, region, 3);
Assert.That(region.Count, Is.GreaterThan(37));
Shrink(mesh.Topology, region, 3);
Shrink(mesh.topology, region, 3);
Assert.That(region.Count, Is.EqualTo(37));
}

Expand Down
Loading
Loading