use of java.util.TreeSet in project jmonkeyengine by jMonkeyEngine.
the class GeneratedTexture method triangulate.
/**
* This method triangulates the texture. In the result we get a set of small
* flat textures for each face of the given mesh. This can be later merged
* into one flat texture.
*
* @param mesh
* the mesh we create the texture for
* @param geometriesOMA
* the old memory address of the geometries group that the given
* mesh belongs to (required for bounding box calculations)
* @param coordinatesType
* the types of UV coordinates
* @param blenderContext
* the blender context
* @return triangulated texture
*/
public TriangulatedTexture triangulate(Mesh mesh, Long geometriesOMA, UVCoordinatesType coordinatesType, BlenderContext blenderContext) {
TemporalMesh geometries = (TemporalMesh) blenderContext.getLoadedFeature(geometriesOMA, LoadedDataType.TEMPORAL_MESH);
int[] coordinatesSwappingIndexes = new int[] { ((Number) mTex.getFieldValue("projx")).intValue(), ((Number) mTex.getFieldValue("projy")).intValue(), ((Number) mTex.getFieldValue("projz")).intValue() };
List<Vector3f> uvs = UVCoordinatesGenerator.generateUVCoordinatesFor3DTexture(mesh, coordinatesType, coordinatesSwappingIndexes, geometries);
Vector3f[] uvsArray = uvs.toArray(new Vector3f[uvs.size()]);
BoundingBox boundingBox = UVCoordinatesGenerator.getBoundingBox(geometries);
Set<TriangleTextureElement> triangleTextureElements = new TreeSet<TriangleTextureElement>(new Comparator<TriangleTextureElement>() {
public int compare(TriangleTextureElement o1, TriangleTextureElement o2) {
return o1.faceIndex - o2.faceIndex;
}
});
int[] indices = new int[3];
for (int i = 0; i < mesh.getTriangleCount(); ++i) {
mesh.getTriangle(i, indices);
triangleTextureElements.add(new TriangleTextureElement(i, boundingBox, this, uvsArray, indices, blenderContext));
}
return new TriangulatedTexture(triangleTextureElements, blenderContext);
}
use of java.util.TreeSet in project mapdb by jankotek.
the class TreeSetTest method set5.
/**
* Returns a new set of first 5 ints.
*/
private TreeSet set5() {
TreeSet q = new TreeSet();
assertTrue(q.isEmpty());
q.add(one);
q.add(two);
q.add(three);
q.add(four);
q.add(five);
assertEquals(5, q.size());
return q;
}
use of java.util.TreeSet in project mapdb by jankotek.
the class TreeSetTest method testPollFirst.
/**
* pollFirst succeeds unless empty
*/
public void testPollFirst() {
TreeSet q = populatedSet(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.pollFirst());
}
assertNull(q.pollFirst());
}
use of java.util.TreeSet in project mapdb by jankotek.
the class TreeSetTest method testContains.
/**
* contains(x) reports true when elements added but not yet removed
*/
public void testContains() {
TreeSet q = populatedSet(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertTrue(q.contains(new Integer(i)));
q.pollFirst();
assertFalse(q.contains(new Integer(i)));
}
}
use of java.util.TreeSet in project mapdb by jankotek.
the class TreeSetTest method testTailSetContents.
/**
* tailSet returns set with keys in requested range
*/
public void testTailSetContents() {
TreeSet set = set5();
SortedSet sm = set.tailSet(two);
assertFalse(sm.contains(one));
assertTrue(sm.contains(two));
assertTrue(sm.contains(three));
assertTrue(sm.contains(four));
assertTrue(sm.contains(five));
Iterator i = sm.iterator();
Object k;
k = (Integer) (i.next());
assertEquals(two, k);
k = (Integer) (i.next());
assertEquals(three, k);
k = (Integer) (i.next());
assertEquals(four, k);
k = (Integer) (i.next());
assertEquals(five, k);
assertFalse(i.hasNext());
SortedSet ssm = sm.tailSet(four);
assertEquals(four, ssm.first());
assertEquals(five, ssm.last());
assertTrue(ssm.remove(four));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, set.size());
}
Aggregations