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/python-examples/GlobalRegistration.dox.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def main(argv):
# the global registration can be applied to meshes and point clouds
# to simplify the sample app, we will work with point clouds only
input_clouds_num = len(file_args) - 1
inputs = []
inputs = mrmeshpy.Vector_MeshOrPointsXf_ObjId()
# as ICP and MultiwayICP classes accept both meshes and point clouds,
# the input data must be converted to special wrapper objects
# NB: the wrapper objects hold *references* to the source data, NOT their copies
max_bbox = None
for i in range(input_clouds_num):
points = mrmeshpy.loadPoints(file_args[i])
# you may also set an affine transformation for each input as a second argument
inputs.append(mrmeshpy.MeshOrPointsXf(points, mrmeshpy.AffineXf3f()))
inputs.push_back(mrmeshpy.MeshOrPointsXf(points, mrmeshpy.AffineXf3f()))

bbox = points.getBoundingBox()
if not max_bbox or bbox.volume() > max_bbox.volume():
Expand All @@ -45,7 +45,7 @@ def main(argv):
# set sampling voxel size
sampling_params.samplingVoxelSize = max_bbox.diagonal() * 0.03

icp = mrmeshpy.MultiwayICP(mrmeshpy.Vector_MeshOrPointsXf_ObjId(inputs), sampling_params)
icp = mrmeshpy.MultiwayICP(inputs, sampling_params)
icp.setParams(mrmeshpy.ICPProperties())

# gather statistics
Expand All @@ -59,7 +59,7 @@ def main(argv):
output = mrmeshpy.PointCloud()
for i in range(input_clouds_num):
xf = xfs.vec[i]
for point in inputs[i].obj.points():
for point in inputs.vec[i].obj.points():
output.addPoint(xf(point))

mrmeshpy.PointsSave.toAnySupportedFormat(output, file_args[-1])
Expand Down
8 changes: 4 additions & 4 deletions source/MRDotNet2Test/src/ICPTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ internal class ICPTests
[Test]
public void TestMultiwayICP()
{
var inputs = new Std.Vector_MRMeshOrPointsXf();
var inputs = new Vector_MRMeshOrPointsXf_MRObjId();
Box3f maxBBox = new Box3f();

inputs.pushBack( new MeshOrPointsXf(makeSphere(new SphereParams(1.0f, 1000)), new AffineXf3f()));
Box3f bbox = inputs[0].obj.getObjBoundingBox();
Box3f bbox = inputs[new ObjId(0)].obj.getObjBoundingBox();
if (!maxBBox.valid() || bbox.volume() > maxBBox.volume())
maxBBox = bbox;

inputs.pushBack(new MeshOrPointsXf(makeSphere(new SphereParams(1.0f, 1000)), AffineXf3f.linear(Matrix3f.rotation(Vector3f.plusZ(), 0.1f))));
bbox = inputs[1].obj.getObjBoundingBox();
bbox = inputs[new ObjId(1)].obj.getObjBoundingBox();
if (!maxBBox.valid() || bbox.volume() > maxBBox.volume())
maxBBox = bbox;

MultiwayICPSamplingParameters samplingParams = new MultiwayICPSamplingParameters();
samplingParams.samplingVoxelSize = maxBBox.diagonal() * 0.03f;

MultiwayICP icp = new MultiwayICP(new Vector_MRMeshOrPointsXf_MRObjId(Misc.Move(inputs)), samplingParams);
MultiwayICP icp = new MultiwayICP(inputs, samplingParams);
ICPProperties iCPProperties = new ICPProperties();
icp.setParams(iCPProperties);
icp.updateAllPointPairs();
Expand Down
46 changes: 23 additions & 23 deletions source/MRMesh/MRCylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ namespace MR

Mesh makeCylinder( float radius, float length, int resolution )
{
std::vector<Vector3f> points(2 * resolution + 2);
VertCoords points(2 * resolution + 2);
auto step = 2.0f * PI_F / float(resolution);

for (int h = 0; h < 2; ++h)
{
points[h] = Vector3f(0.0f, 0.0f, float(h)*length);
points[VertId( h )] = Vector3f(0.0f, 0.0f, float(h)*length);
for (int anglei = 0; anglei < resolution; ++anglei)
{
float angle = anglei * step;
auto ind = anglei + resolution * h + 2;
points[ind].x = radius * cosf(angle);
points[ind].y = radius * sinf(angle);
points[ind].z = h * length;
points[VertId( ind )].x = radius * cosf(angle);
points[VertId( ind )].y = radius * sinf(angle);
points[VertId( ind )].z = h * length;
}
}

Expand All @@ -40,7 +40,7 @@ Mesh makeCylinder( float radius, float length, int resolution )

Mesh makeOpenCylinder( float radius, float z1, float z2, int numCircleSegments )
{
std::vector<Vector3f> points( 2 * numCircleSegments );
VertCoords points( 2 * numCircleSegments );

for ( bool side : { false, true } )
{
Expand All @@ -50,9 +50,9 @@ Mesh makeOpenCylinder( float radius, float z1, float z2, int numCircleSegments )
{
float angle = i * 2 * PI_F / numCircleSegments;
int index = i + numCircleSegments * side;
points[index].x = radius * std::cos( angle );
points[index].y = radius * std::sin( angle );
points[index].z = z;
points[VertId( index )].x = radius * std::cos( angle );
points[VertId( index )].y = radius * std::sin( angle );
points[VertId( index )].z = z;
}
}

Expand All @@ -74,16 +74,16 @@ Mesh makeOpenCylinder( float radius, float z1, float z2, int numCircleSegments )

Mesh makeOpenCone( float radius, float zApex, float zBase, int numCircleSegments )
{
std::vector<Vector3f> points( numCircleSegments + 1 );
VertCoords points( numCircleSegments + 1 );

for ( int i = 0; i < numCircleSegments; ++i )
{
float angle = i * 2 * PI_F / numCircleSegments;
points[i].x = radius * std::cos( angle );
points[i].y = radius * std::sin( angle );
points[i].z = zBase;
points[VertId( i )].x = radius * std::cos( angle );
points[VertId( i )].y = radius * std::sin( angle );
points[VertId( i )].z = zBase;
}
points[numCircleSegments] = Vector3f( 0, 0, zApex );
points[VertId( numCircleSegments )] = Vector3f( 0, 0, zApex );

Triangulation t;
t.reserve( 2 * numCircleSegments );
Expand Down Expand Up @@ -127,28 +127,28 @@ Mesh makeCylinderAdvanced( float radius0, float radius1, float start_angle,
slice = true;
}

std::vector<Vector3f> points(cap0 + cap1 + 2);
VertCoords points(cap0 + cap1 + 2);
auto step = arc_size / float(resolution);
int ver_id = 0;

points[ver_id++] = Vector3f(0.0f, 0.0f, 0.0f);
points[ver_id++] = Vector3f(0.0f, 0.0f, length);
points[VertId( ver_id++ )] = Vector3f(0.0f, 0.0f, 0.0f);
points[VertId( ver_id++ )] = Vector3f(0.0f, 0.0f, length);

for (int anglei = 0; anglei < cap0; ++anglei)
{
float angle = start_angle + anglei * step;
points[ver_id].x = radius0 * cosf(angle);
points[ver_id].y = radius0 * sinf(angle);
points[ver_id].z = 0;
points[VertId( ver_id )].x = radius0 * cosf(angle);
points[VertId( ver_id )].y = radius0 * sinf(angle);
points[VertId( ver_id )].z = 0;
++ver_id;
}

for (int anglei = 0; anglei < cap1; ++anglei)
{
float angle = start_angle + anglei * step;
points[ver_id].x = radius1 * cosf(angle);
points[ver_id].y = radius1 * sinf(angle);
points[ver_id].z = length;
points[VertId( ver_id )].x = radius1 * cosf(angle);
points[VertId( ver_id )].y = radius1 * sinf(angle);
points[VertId( ver_id )].z = length;
++ver_id;
}

Expand Down
4 changes: 3 additions & 1 deletion source/MRMesh/MRDelaunayTriangulationXY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@ static Expected<Mesh> delaunayTriangulationXY( VertCoords points, const VertBitS

Expected<Mesh> delaunayTriangulationXY( std::vector<Vector3f> points, const ProgressCallback& cb )
{
return delaunayTriangulationXY( VertCoords( std::move( points ) ), nullptr, cb );
VertCoords vertCoords;
vertCoords.vec = std::move( points );
return delaunayTriangulationXY( std::move( vertCoords ), nullptr, cb );
}

Expected<Mesh> delaunayTriangulationXY( const PointCloud& cloud, const ProgressCallback& cb )
Expand Down
20 changes: 10 additions & 10 deletions source/MRMesh/MRMakeSphereMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,30 @@ Mesh makeUVSphere(float radius, int horisontalResolution, int verticalResolution

int vertexCount = horisontalResolution * verticalResolution + 2;

std::vector<Vector3f> points(vertexCount);
VertCoords points(vertexCount);

k = 0;
for (j = 0; j < verticalResolution; ++j) {
a = PI_F * ((float)(j + 1) / (verticalResolution + 1) - 0.5f);
for (i = 0; i < horisontalResolution; ++i) {
b = 2 * i * PI_F / horisontalResolution;

points[k].x = (float)(radius * cos(a) * sin(b));
points[k].y = (float)(radius * cos(a) * cos(b));
points[k].z = (float)(radius * sin(a));
points[VertId( k )].x = (float)(radius * cos(a) * sin(b));
points[VertId( k )].y = (float)(radius * cos(a) * cos(b));
points[VertId( k )].z = (float)(radius * sin(a));
++k;
}
}

points[k].x = 0;
points[k].y = 0;
points[k].z = -radius;
points[VertId( k )].x = 0;
points[VertId( k )].y = 0;
points[VertId( k )].z = -radius;
bottom_cap = k;
++k;

points[k].x = 0;
points[k].y = 0;
points[k].z = radius;
points[VertId( k )].x = 0;
points[VertId( k )].y = 0;
points[VertId( k )].z = radius;
top_cap = k;

Triangulation t;
Expand Down
4 changes: 2 additions & 2 deletions source/MRMesh/MRMeshLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ Expected<Mesh> fromOff( std::istream& in, const MeshLoadSettings& settings /*= {
}
}

std::vector<Vector3f> pointsBlocks( numPoints );
VertCoords pointsBlocks( numPoints );

std::atomic<bool> forseStop = false;
bool keepGoing = ParallelFor( pointsBlocks, [&] ( size_t numPoint )
Expand All @@ -472,7 +472,7 @@ Expected<Mesh> fromOff( std::istream& in, const MeshLoadSettings& settings /*= {
const std::string_view line( &buf[splitLines[numLine]], splitLines[numLine + 1] - splitLines[numLine] );
Vector3d temp;
auto result = parseTextCoordinate( line, temp );
pointsBlocks[numPoint] = Vector3f( temp );
pointsBlocks[VertId( numPoint )] = Vector3f( temp );

if ( !result.has_value() )
{
Expand Down
6 changes: 3 additions & 3 deletions source/MRMesh/MRMeshNormals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FaceNormals computePerFaceNormals( const Mesh & mesh )
FaceNormals computePerFaceNormals( const MeshTopology & topology, const VertCoords & points )
{
MR_TIMER;
std::vector<Vector3f> res( topology.faceSize() );
FaceNormals res( topology.faceSize() );
BitSetParallelFor( topology.getValidFaces(), [&]( FaceId f )
{
res[f] = normal( topology, points, f );
Expand All @@ -43,7 +43,7 @@ void computePerFaceNormals4( const Mesh & mesh, Vector4f* faceNormals, size_t si
VertNormals computePerVertNormals( const Mesh & mesh )
{
MR_TIMER;
std::vector<Vector3f> res( mesh.topology.vertSize() );
VertNormals res( mesh.topology.vertSize() );
BitSetParallelFor( mesh.topology.getValidVerts(), [&] ( VertId v )
{
res[v] = mesh.normal( v );
Expand All @@ -54,7 +54,7 @@ VertNormals computePerVertNormals( const Mesh & mesh )
VertNormals computePerVertPseudoNormals( const Mesh & mesh )
{
MR_TIMER;
std::vector<Vector3f> res( mesh.topology.vertSize() );
VertNormals res( mesh.topology.vertSize() );
BitSetParallelFor( mesh.topology.getValidVerts(), [&] ( VertId v )
{
res[v] = mesh.pseudonormal( v );
Expand Down
4 changes: 2 additions & 2 deletions source/MRMesh/MRMeshSave3mf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ template<typename I>
Vector<int, I> makePalette( const Vector<Color, I>& colors, const TypedBitSet<I>& validColors, std::ostream& out )
{
Vector<int, I> res;
res = makePalette( colors.vec, validColors, out );
res.vec = makePalette( colors.vec, validColors, out );
return res;
}

Expand Down Expand Up @@ -104,7 +104,7 @@ Expected<void> toModel3mf( const Mesh & mesh, std::ostream & out, const SaveSett
}
else if ( savePrimColors )
{
facePalette = makePalette( *settings.primitiveColors, mesh.topology.getValidFaces(), out );
facePalette.vec = makePalette( *settings.primitiveColors, mesh.topology.getValidFaces(), out );
out << " <object id=\"2\" type=\"model\">\n";
}
else if ( settings.solidColor )
Expand Down
4 changes: 2 additions & 2 deletions source/MRMesh/MRSolidOfRevolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Mesh makeSolidOfRevolution( const Contour2f& profile, int resolution )
const auto isClosed = ( profile.front() == profile.back() );
const auto profileSize = profile.size() - int( isClosed );

std::vector<Vector3f> points( profileSize * resolution );
VertCoords points( profileSize * resolution );
ParallelFor( points, [&] ( size_t index )
{
const auto angle = 2.f * PI_F * (float)( index / profileSize ) / (float)resolution;
const auto x = std::cos( angle ), y = std::sin( angle );

const auto& pp = profile[index % profileSize];
points[index] = {
points[VertId( index )] = {
pp.x * x,
pp.x * y,
pp.y,
Expand Down
Loading
Loading