use of uk.ac.sussex.gdsc.core.utils.LocalList in project GDSC-SMLM by aherbert.
the class Shape3DHelper method createSolidOutline.
/**
* Creates the solid with the defined faces and vertices on a unit sphere.
*
* @param vertices the vertices
* @param normalise the normalise
* @return the list of vertices for the triangles
*/
private static List<Point3f> createSolidOutline(float[][] vertices, boolean normalise) {
final List<Point3f> ps = new LocalList<>();
for (int i = 0; i < vertices.length; i++) {
ps.add(new Point3f(vertices[i]));
}
// Make continuous
ps.add(new Point3f(vertices[0]));
if (normalise) {
normalise(ps);
}
return ps;
}
use of uk.ac.sussex.gdsc.core.utils.LocalList in project GDSC-SMLM by aherbert.
the class CustomContentHelper method createIndexedObject.
/**
* Creates an indexed object from a list of triangle vertices.
*
* @param list the list of triangle vertices
* @return the vertices and faces of the the object
*/
public static Pair<Point3f[], int[]> createIndexedObject(List<Point3f> list) {
// Compact the vertices to a set of vertices and faces
final TObjectIntHashMap<Point3f> map = new TObjectIntHashMap<>(list.size(), 0.5f, -1);
final LocalList<Point3f> vertices = new LocalList<>(list.size());
final TIntArrayList faces = new TIntArrayList(list.size());
int index = 0;
// Process triangles
for (int i = 0; i < list.size(); i += 3) {
index = addFace(map, vertices, faces, list.get(i), index);
index = addFace(map, vertices, faces, list.get(i + 1), index);
index = addFace(map, vertices, faces, list.get(i + 2), index);
}
return Pair.of(vertices.toArray(new Point3f[0]), faces.toArray());
}
use of uk.ac.sussex.gdsc.core.utils.LocalList in project GDSC-SMLM by aherbert.
the class ItemMesh method createGeometryArray.
/**
* Creates the geometry array.
*
* @param sourceGa the source geometry array
* @param format the format
* @return the geometry array
*/
protected GeometryArray createGeometryArray(GeometryArray sourceGa, int format) {
// Create using reflection
final GeometryArray ga;
try {
final Class<?> clazz = sourceGa.getClass();
// clazz = clazz.asSubclass(clazz);
final LocalList<Class<?>> paramTypes = new LocalList<>(4);
final LocalList<Object> paramValues = new LocalList<>(4);
paramTypes.add(int.class);
paramTypes.add(int.class);
paramValues.add(vertexCount * points.length);
paramValues.add(vertexFormat | format);
if (isIndexGeometryArray()) {
paramTypes.add(int.class);
paramValues.add(indexCount * points.length);
}
// Handle strips
int numStrips = 0;
int[] objectStripCounts = null;
int[] allStripCounts = null;
if (sourceGa instanceof IndexedGeometryStripArray) {
final IndexedGeometryStripArray igsa = (IndexedGeometryStripArray) sourceGa;
numStrips = igsa.getNumStrips();
objectStripCounts = new int[numStrips];
igsa.getStripIndexCounts(objectStripCounts);
} else if (sourceGa instanceof GeometryStripArray) {
final GeometryStripArray gsa = (GeometryStripArray) sourceGa;
numStrips = gsa.getNumStrips();
objectStripCounts = new int[numStrips];
gsa.getStripVertexCounts(objectStripCounts);
}
if (objectStripCounts != null) {
allStripCounts = new int[numStrips * points.length];
duplicate(objectStripCounts, 0, numStrips, points.length, allStripCounts, 0);
paramTypes.add(int[].class);
paramValues.add(allStripCounts);
}
final Class<?>[] paramTypes2 = paramTypes.toArray(new Class<?>[0]);
final Object[] paramValues2 = paramValues.toArray();
ga = (GeometryArray) clazz.getConstructor(paramTypes2).newInstance(paramValues2);
} catch (final Exception ex) {
ex.printStackTrace();
return null;
}
ga.setCapability(GeometryArray.ALLOW_COUNT_WRITE);
ga.setCapability(GeometryArray.ALLOW_COUNT_READ);
ga.setCapability(GeometryArray.ALLOW_FORMAT_READ);
ga.setCapability(Geometry.ALLOW_INTERSECT);
return ga;
}
use of uk.ac.sussex.gdsc.core.utils.LocalList in project GDSC-SMLM by aherbert.
the class TcPalmAnalysis method createBurstLocalisations.
/**
* Creates the burst localisations using the ranges of the current bursts.
*
* @param clusters the clusters
* @param bursts the bursts
* @return the burst localisations
*/
private static LocalList<LocalList<PeakResult>> createBurstLocalisations(LocalList<ClusterData> clusters, LocalList<int[]> bursts) {
final LocalList<LocalList<PeakResult>> burstsLocalisations = new LocalList<>();
// TODO: Make more efficient. Order clusters by frame and burst by frame
// Do a single sweep over the clusters and extract the peaks within the burst ranges.
bursts.forEach(range -> {
final int min = range[0];
final int max = range[1];
final LocalList<PeakResult> list = new LocalList<>();
// Build from the current selection
clusters.forEach(cluster -> {
cluster.results.forEach(peak -> {
final int t = peak.getFrame();
if (t >= min && t <= max) {
list.add(peak);
}
});
});
burstsLocalisations.add(list);
});
return burstsLocalisations;
}
use of uk.ac.sussex.gdsc.core.utils.LocalList in project GDSC-SMLM by aherbert.
the class TcPalmAnalysis method runBurstAnalysis.
/**
* Run the burst analysis on the activation counts. Identifies continuous bursts of activations
* that are connected within the dark time tolerance and above the minimum cluster size.
*
* @param settings the settings
*/
private static LocalList<int[]> runBurstAnalysis(TcPalmAnalysisSettings settings, CumulativeCountData data) {
final LocalList<int[]> bursts = new LocalList<>();
final int[] frames = data.frames;
final int[] counts = data.counts;
if (frames.length != 0) {
final int gap = settings.getDarkTimeTolerance() + 1;
final int size = settings.getMinClusterSize();
int start = frames[0];
int end = start;
int count = counts[0];
for (int i = 1; i < frames.length; i++) {
final int t = frames[i];
if (t - end > gap) {
// Save the burst
if (count >= size) {
bursts.add(new int[] { start, end });
}
start = end = t;
count = counts[i];
} else {
end = t;
count += counts[i];
}
}
if (count >= size) {
bursts.add(new int[] { start, end });
}
}
return bursts;
}
Aggregations