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
4 changes: 2 additions & 2 deletions src/main/java/net/imglib2/mesh/Meshes.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static RealPoint center( final Mesh m )
p.move( v );

for ( int d = 0; d < 3; d++ )
p.setPosition( p.getDoublePosition( d ) / m.vertices().size(), d );
p.setPosition( p.getDoublePosition( d ) / m.vertices().sizel(), d );

return p;
}
Expand Down Expand Up @@ -366,7 +366,7 @@ public static Iterable< BufferMesh > connectedComponents( final Mesh mesh )
public static void scale( final Mesh mesh, final double[] scale )
{
final Vertices vertices = mesh.vertices();
final long nVertices = vertices.size();
final long nVertices = vertices.sizel();
for ( long i = 0; i < nVertices; i++ )
{
final double x = vertices.x( i );
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/net/imglib2/mesh/alg/MeshConnectedComponents.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/**
* Connected components algorithm for meshes.
*
*
* @author Jean-Yves Tinevez
*
*/
Expand All @@ -27,7 +27,7 @@ public class MeshConnectedComponents

/**
* Returns the number of connected components in this mesh.
*
*
* @param mesh
* the mesh.
* @return the number of connected components.
Expand All @@ -36,7 +36,7 @@ public static final int n( final Mesh mesh )
{
final Triangles triangles = mesh.triangles();
final Vertices vertices = mesh.vertices();
final int nVertices = ( int ) vertices.size();
final int nVertices = vertices.size();

final TIntObjectHashMap< TIntArrayList > map = triangleMap( mesh );
final BitSet visited = new BitSet( nVertices );
Expand Down Expand Up @@ -116,15 +116,15 @@ private static final boolean visit( final int v, final BitSet visited, final TIn

/**
* Returns the map of vertex id to the list of triangles they belong to.
*
*
* @param mesh
*/
private static final TIntObjectHashMap< TIntArrayList > triangleMap( final Mesh mesh )
{
final Triangles triangles = mesh.triangles();
final int nTriangles = ( int ) triangles.size();
final int nTriangles = triangles.size();
final Vertices vertices = mesh.vertices();
final int nVertices = ( int ) vertices.size();
final int nVertices = vertices.size();

final TIntObjectHashMap< TIntArrayList > map = new TIntObjectHashMap<>( nVertices );
for ( int tid = 0; tid < nTriangles; tid++ )
Expand Down Expand Up @@ -166,7 +166,7 @@ public MyCCIterator( final Mesh mesh )
{
this.mesh = mesh;
this.map = triangleMap( mesh );
this.nVertices = ( int ) mesh.vertices().size();
this.nVertices = mesh.vertices().size();
this.visited = new BitSet( nVertices );
this.currentStartVertex = 0;
this.next = prefetch();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/imglib2/mesh/alg/MeshCursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public long getLongPosition( final int d )
@Override
public Cursor< T > copyCursor()
{
final BufferMesh dest = new BufferMesh( mesh.vertices().isize(), mesh.triangles().isize() );
final BufferMesh dest = new BufferMesh( mesh.vertices().size(), mesh.triangles().size() );
Meshes.copy( mesh, dest );
return new MeshCursor<>( ra.copyRandomAccess(), dest, cal.clone() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand Down Expand Up @@ -47,7 +47,7 @@ public class RemoveDuplicateVertices
public static Mesh calculate( final Mesh mesh, final int precision )
{
final Map< String, IndexedVertex > vertices = new LinkedHashMap<>();
final int[][] triangles = new int[ ( int ) mesh.triangles().size() ][ 3 ];
final int[][] triangles = new int[ mesh.triangles().size() ][ 3 ];

int trianglesCount = 0;
for ( final net.imglib2.mesh.obj.Triangle triangle : mesh.triangles() )
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/imglib2/mesh/alg/SimplifyMesh.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand Down Expand Up @@ -237,7 +237,7 @@ private void readMesh()
vertices.clear();
refs.clear();

final Point[] meshVerts = new Point[ ( int ) inMesh.vertices().size() ];
final Point[] meshVerts = new Point[ inMesh.vertices().size() ];
final Iterator< net.imglib2.mesh.obj.Vertex > iterator = inMesh.vertices().iterator();
for ( int i = 0; i < inMesh.vertices().size(); i++ )
{
Expand Down Expand Up @@ -288,7 +288,7 @@ private void readMesh()
public Mesh simplify( final float target_percent, final double agressiveness )
{

final int target_count = ( int ) ( inMesh.triangles().size() * target_percent );
final int target_count = ( int ) ( inMesh.triangles().sizel() * target_percent );
return simplify( target_count, agressiveness );
}

Expand All @@ -315,7 +315,7 @@ private Mesh simplify( final int target_count, final double agressiveness )
* System.out.println(String.format("Simplify Target: %d of %d (%d%%)",
* target_count, triangles.size(), target_count * 100 /
* triangles.size()));
*
*
* final long timeStart = System.currentTimeMillis();
*/

Expand Down Expand Up @@ -435,7 +435,7 @@ private Mesh simplify( final int target_count, final double agressiveness )
// ready
/*
* long timeEnd = System.currentTimeMillis();
*
*
* System.out.println(String.
* format("Simplify: %d/%d %d%% removed in %d ms", triangle_count -
* deleted_triangles, triangle_count, deleted_triangles * 100 /
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/net/imglib2/mesh/alg/TaubinSmoothing.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* <p>
* Adapted by the Javascript code of mykolalysenko, MIT license.
* https://github.com/mikolalysenko/taubin-smooth/blob/master/smooth.js
*
*
* @author Jean-Yves Tinevez
* @see <a href="https://doi.org/10.1109/ICCV.1995.466848">Taubin, G. “Curve and
* Surface Smoothing without Shrinkage.” In Proceedings of IEEE
Expand All @@ -26,7 +26,7 @@ public class TaubinSmoothing
/**
* Smooth the specified mesh using the Taubin smoothing algorithm, with
* default parameters.
*
*
* @param mesh
* the mesh to smooth.
* @return a new smoothed mesh.
Expand All @@ -39,7 +39,7 @@ public static final BufferMesh smooth( final Mesh mesh )
/**
* Smooth the specified mesh using the Taubin smoothing algorithm, using
* cotangent weights.
*
*
* @param mesh
* the mesh to smooth.
* @param iters
Expand All @@ -66,7 +66,7 @@ public static final BufferMesh smooth( final Mesh mesh, final int iters, final d

/**
* Smooth the specified mesh using the Taubin smoothing algorithm.
*
*
* @param mesh
* the mesh to smooth.
* @param iters
Expand All @@ -85,8 +85,8 @@ public static final BufferMesh smooth( final Mesh mesh, final int iters, final d
public static final BufferMesh smooth( final Mesh mesh, final int iters, final double lambda, final double mu,
final TaubinWeightType weightType )
{
final int nvs = ( int ) mesh.vertices().size();
final int nts = ( int ) mesh.triangles().size();
final int nvs = mesh.vertices().size();
final int nts = mesh.triangles().size();
final BufferMesh meshA = new BufferMesh( nvs, nts );
Meshes.copy( mesh, meshA );
final BufferMesh meshB = new BufferMesh( nvs, nts );
Expand Down Expand Up @@ -114,7 +114,7 @@ public static final BufferMesh smooth( final Mesh mesh, final int iters, final d
throw new IllegalArgumentException( "Unhandled weight type: " + weightType );
}

final BufferMesh out = new BufferMesh( ( int ) meshA.vertices().size(), ( int ) meshA.triangles().size() );
final BufferMesh out = new BufferMesh( meshA.vertices().size(), meshA.triangles().size() );
Meshes.calculateNormals( meshA, out );
return out;
}
Expand All @@ -123,8 +123,8 @@ private static void smoothStepCotangent( final Triangles triangles, final Buffer
final double[] trace, final double weigth )
{

final int nvs = ( int ) source.vertices().size();
final int nts = ( int ) source.triangles().size();
final int nvs = source.vertices().size();
final int nts = source.triangles().size();

// Zero target.
for ( int i = 0; i < nvs; i++ )
Expand Down Expand Up @@ -205,8 +205,8 @@ private static void smoothStepNaive( final Triangles triangles, final BufferMesh
final double[] trace, final double weigth )
{

final int nvs = ( int ) source.vertices().size();
final int nts = ( int ) source.triangles().size();
final int nvs = source.vertices().size();
final int nts = source.triangles().size();

// Zero target.
for ( int i = 0; i < nvs; i++ )
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/imglib2/mesh/alg/zslicer/ZSlicer.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public static List< Slice > slices( final Mesh mesh, final double[] zs, final do
final Triangles triangles = mesh.triangles();
final Vertices vertices = mesh.vertices();

final double[] minZs = new double[ ( int ) triangles.size() ];
final double[] maxZs = new double[ ( int ) triangles.size() ];
final double[] minZs = new double[ triangles.size() ];
final double[] maxZs = new double[ triangles.size() ];
for ( int t = 0; t < triangles.size(); t++ )
{
final long v0 = triangles.vertex0( t );
Expand Down Expand Up @@ -256,7 +256,7 @@ public static Slice slice( final Mesh mesh, final double z, final double zScale
final Vertices vertices = mesh.vertices();

final TIntArrayList intersecting = new TIntArrayList();
for ( long f = 0; f < triangles.size(); f++ )
for ( long f = 0; f < triangles.sizel(); f++ )
{
final long v0 = triangles.vertex0( f );
final long v1 = triangles.vertex1( f );
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/net/imglib2/mesh/io/ply/PLYMeshIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,17 @@ public static final byte[] writeBinary( final Mesh mesh )
"format binary_little_endian 1.0\n" + //
"comment This binary PLY mesh was created with imagej-mesh.\n";
final String vertexHeader = "" + //
"element vertex " + mesh.vertices().size() + "\n" + //
"element vertex " + mesh.vertices().sizel() + "\n" + //
"property float x\nproperty float y\nproperty float z\n" + //
"property float nx\nproperty float ny\nproperty float nz\n" + //
"property float u\nproperty float v\n";
final String triangleHeader = "element face " + mesh.triangles().size()
final String triangleHeader = "element face " + mesh.triangles().sizel()
+ "\nproperty list uchar int vertex_index\n";
final String endHeader = "end_header\n";
final long bytes = header.getBytes().length + //
vertexHeader.getBytes().length + triangleHeader.getBytes().length + endHeader.getBytes().length
+ mesh.vertices().size() * vertexBytes + //
mesh.triangles().size() * triangleBytes;
+ mesh.vertices().sizel() * vertexBytes + //
mesh.triangles().sizel() * triangleBytes;
if ( bytes > Integer.MAX_VALUE )
throw new IllegalArgumentException( "Mesh data too large: " + bytes );

Expand All @@ -246,12 +246,12 @@ public static final byte[] writeBinary( final Mesh mesh )
buffer.put( endHeader.getBytes() );

// Do not populate file if there are no vertices
if ( mesh.vertices().size() == 0 )
if ( mesh.vertices().sizel() == 0 )
return buffer.array();

// Write vertices
final TLongIntHashMap refToVertId = //
new TLongIntHashMap( ( int ) mesh.vertices().size() );
new TLongIntHashMap( mesh.vertices().size() );
int vertId = 0;
for ( final Vertex v : mesh.vertices() )
{
Expand Down Expand Up @@ -282,21 +282,21 @@ public static final byte[] writeBinary( final Mesh mesh )
public static final byte[] writeAscii( final Mesh mesh ) throws IOException
{
final String header = "ply\nformat ascii 1.0\ncomment This binary PLY mesh was created with imagej-mesh.\n";
final String vertexHeader = "element vertex " + mesh.vertices().size()
final String vertexHeader = "element vertex " + mesh.vertices().sizel()
+ "\nproperty float x\nproperty float y\nproperty float z\nproperty float nx\nproperty float ny\nproperty float nz\nproperty float u\n property float v\n";
final String triangleHeader = "element face " + mesh.triangles().size()
final String triangleHeader = "element face " + mesh.triangles().sizel()
+ "\nproperty list uchar int vertex_index\n";
final String endHeader = "end_header\n";

// TODO: Fail fast more robustly if mesh is too large.
// But need to modify the API to not return a byte[].
if ( mesh.vertices().size() > Integer.MAX_VALUE )
if ( mesh.vertices().sizel() > Integer.MAX_VALUE )
throw new IllegalArgumentException( "Too many vertices: " + //
mesh.vertices().size() );
mesh.vertices().sizel() );

if ( mesh.triangles().size() > Integer.MAX_VALUE )
if ( mesh.triangles().sizel() > Integer.MAX_VALUE )
throw new IllegalArgumentException( "Too many triangles: " + //
mesh.triangles().size() );
mesh.triangles().sizel() );

final ByteArrayOutputStream os = new ByteArrayOutputStream();

Expand All @@ -308,14 +308,14 @@ public static final byte[] writeAscii( final Mesh mesh ) throws IOException
writer.write( endHeader );

// Do not populate file if there are no vertices
if ( mesh.vertices().size() == 0 )
if ( mesh.vertices().sizel() == 0 )
{
writer.flush();
return os.toByteArray();
}

// Write vertices
final TLongIntHashMap refToVertId = new TLongIntHashMap( ( int ) mesh.vertices().size() );
final TLongIntHashMap refToVertId = new TLongIntHashMap( mesh.vertices().size() );
int vertId = 0;
for ( final Vertex v : mesh.vertices() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/imglib2/mesh/io/stl/STLMeshIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static final void read( final Mesh mesh, final byte[] data )
/** Writes the facets into a byte[] that can then be saved into a file */
public static final byte[] write( final Mesh mesh )
{
final long facetCount = mesh == null ? 0 : mesh.triangles().size();
final long facetCount = mesh == null ? 0 : mesh.triangles().sizel();
final long longBytes = HEADER_BYTES + COUNT_BYTES + facetCount * FACET_BYTES;
if ( longBytes > Integer.MAX_VALUE )
{ throw new IllegalArgumentException( "Too many triangles: " + facetCount ); }
Expand Down
Loading