Package ca.eandb.util

Examples of ca.eandb.util.IntegerArray


  private synchronized void computeOffsets() {
    if (offsets != null) {
      return;
    }
    IntegerArray newOffsets = new IntegerArray();
    int offset = 0;
    for (int i = 0, n = children.size(); i < n; i++) {
      newOffsets.add(offset);
      offset += children.get(i).getNumPrimitives();
    }
    offsets = newOffsets;
  }
View Full Code Here


      return;
    }

    assert(isAbove && isBelow);

    IntegerArray indices = new IntegerArray();
    int ia = -1;
    int ofs = 0;
    int n = face.vertexIndex.size();
    while (!vertices.get(face.vertexIndex.get(ofs)).flag) {
      ofs++;
    }
    for (int j = 0; j < n; j++) {
      int i = (j + ofs) % n;
      int i1 = face.vertexIndex.get(i);
      int i2 = face.vertexIndex.get((i + 1) % n);
      int i3 = face.vertexIndex.get((i + (n - 1)) % n);
      Vertex v1 = vertices.get(i1);
      Vertex v2 = vertices.get(i2);
      Vertex v3 = vertices.get(i3);
      if (v1.flag) {
        indices.add(i1);
      } else { // !v1.isAbove
        if (v3.flag) {
          Edge edge = new Edge(i3, i1);
          Edge edgeRev = edge.reverse();
          if (splitMap.containsKey(edgeRev)) {
            int index = splitMap.get(edgeRev);
            ia = index;
            indices.add(index);
          } else {
            assert(!splitMap.containsKey(edge));
            Ray3 ray = new Ray3(v1.position, v3.position);
            Point3 p = ray.pointAt(plane.intersect(ray));
            int index = addVertex(p);
            ia = index;
            vertices.get(index).tempInt = -1;
            vertices.get(index).flag = true;
            indices.add(index);
            splitMap.put(edge, index);
          }
        }
        if (v2.flag) {
          Edge edge = new Edge(i1, i2);
          Edge edgeRev = edge.reverse();
          if (splitMap.containsKey(edgeRev)) {
            int index = splitMap.get(edgeRev);
            assert(ia >= 0);
            vertices.get(index).tempInt = ia;
            ia = -1;
            indices.add(index);
          } else {
            assert(!splitMap.containsKey(edge));
            Ray3 ray = new Ray3(v1.position, v2.position);
            Point3 p = ray.pointAt(plane.intersect(ray));
            int index = addVertex(p);
            assert(ia >= 0);
            if (ia < 0) {
              ia = -1;
            }
            vertices.get(index).tempInt = ia;
            ia = -1;
            vertices.get(index).flag = true;
            indices.add(index);
            splitMap.put(edge, index);
          }
        }
      }
    }

    assert(!indices.isEmpty());

    face.vertexIndex.clear();
    face.vertexIndex.addAll(indices);

    face.flag = true;
View Full Code Here

              Box2 cell = new Box2(x0, y0, x1, y1);

              if (GeometryUtil.boxIntersectsTriangle(cell, a, b, c)) {
                int cellIndex = j * triangleLookupGridSize + i;
                int triIndex = fi * maximumTrianglesPerFace + tri / 3;
                IntegerArray list = triangleLookup.get(cellIndex);
                if (list == null) {
                  list = new IntegerArray();
                  triangleLookup.put(cellIndex, list);
                }
                list.add(triIndex);
              }
            }
          }
        }
      }
    }

    int count = 0;
    for (IntegerArray list : triangleLookup.values()) {
      int n = list.size();
      for (int i = 1; i < n; i++) {
        int tri1 = list.get(i);
        int fi1 = tri1 / maximumTrianglesPerFace;
        int ti1 = (tri1 % maximumTrianglesPerFace) * 3;
        Face f1 = faces.get(fi1);
        Point2 a1 = texCoords.get(f1.texIndices[f1.decomp[ti1]]);
        Point2 b1 = texCoords.get(f1.texIndices[f1.decomp[ti1 + 1]]);
        Point2 c1 = texCoords.get(f1.texIndices[f1.decomp[ti1 + 2]]);

        for (int j = 0; j < i; j++) {
          int tri2 = list.get(j);
          int fi2 = tri2 / maximumTrianglesPerFace;
          int ti2 = (tri2 % maximumTrianglesPerFace) * 3;
          Face f2 = faces.get(fi2);
          Point2 a2 = texCoords.get(f2.texIndices[f2.decomp[ti2]]);
          Point2 b2 = texCoords.get(f2.texIndices[f2.decomp[ti2 + 1]]);
View Full Code Here

    int i = MathUtil.clamp((int) Math.floor(x * (double) triangleLookupGridSize), 0, triangleLookupGridSize - 1);
    int j = MathUtil.clamp((int) Math.floor(y * (double) triangleLookupGridSize), 0, triangleLookupGridSize - 1);

    int cellIndex = j * triangleLookupGridSize + i;
    IntegerArray list = triangleLookup.get(cellIndex);
    if (list != null) {
      for (int triIndex : list) {
        int fi = triIndex / maximumTrianglesPerFace;
        int ti = triIndex % maximumTrianglesPerFace;

View Full Code Here

  public PolygonMask2(List<Point2> vertices, int gridSize) {
    this.vertices = vertices.toArray(new Point2[vertices.size()]);
    this.lookup = new IntegerArray[gridSize];

    for (int i = 0; i < gridSize; i++) {
      lookup[i] = new IntegerArray();
    }

    BoundingBoxBuilder2 builder = new BoundingBoxBuilder2();
    for (int i = 0; i < this.vertices.length; i++) {
      builder.add(this.vertices[i]);
View Full Code Here

   */
  private PlyProperty readList(int count, DataReader reader)
      throws IOException {
    switch (dataType) {
    case CHAR: {
      IntegerArray values = new IntegerArray(count);
      for (int i = 0; i < count; i++) {
        values.add(reader.readChar());
      }
      return new PlyIntegralListProperty(values, this);
    }
    case SHORT: {
      IntegerArray values = new IntegerArray(count);
      for (int i = 0; i < count; i++) {
        values.add(reader.readShort());
      }
      return new PlyIntegralListProperty(values, this);
    }
    case INT: {
      IntegerArray values = new IntegerArray(count);
      for (int i = 0; i < count; i++) {
        values.add(reader.readInt());
      }
      return new PlyIntegralListProperty(values, this);
    }
    case UCHAR: {
      IntegerArray values = new IntegerArray(count);
      for (int i = 0; i < count; i++) {
        values.add(reader.readUnsignedChar());
      }
      return new PlyIntegralListProperty(values, this);
    }
    case USHORT: {
      IntegerArray values = new IntegerArray(count);
      for (int i = 0; i < count; i++) {
        values.add(reader.readUnsignedShort());
      }
      return new PlyIntegralListProperty(values, this);
    }
    case UINT: {
      IntegerArray values = new IntegerArray(count);
      for (int i = 0; i < count; i++) {
        values.add((int) reader.readUnsignedInt());
      }
      return new PlyIntegralListProperty(values, this);
    }
    case FLOAT: {
      DoubleArray values = new DoubleArray(count);
      for (int i = 0; i < count; i++) {
        values.add(reader.readFloat());
      }
      return new PlyFloatListProperty(values, this);
    }
    case DOUBLE: {
      DoubleArray values = new DoubleArray(count);
      for (int i = 0; i < count; i++) {
        values.add(reader.readDouble());
      }
      return new PlyFloatListProperty(values, this);
    }
    default:
      throw new UnexpectedException(String.format(
View Full Code Here

TOP

Related Classes of ca.eandb.util.IntegerArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.