Package jmt.engine.jaba.convexHull3d

Examples of jmt.engine.jaba.convexHull3d.HullVertex


      int b = (int) Math
          .round((serviceTimes[i][1][0] * prop * visits[i][1]));
      int c = (int) Math
          .round((serviceTimes[i][2][0] * prop * visits[i][2]));
      // System.out.println(i+": "+a+" "+b+" "+c);
      result.add(new HullVertex(a, b, c, i, stationNames[i]));
    }
    return result;
  }
View Full Code Here


        }
        if (hullEdgesSet.add(e)) {
        }
      }
      for (int j = 0; j < vertices.length; j++) {
        HullVertex v = vertices[j];
        Vector4 worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        Vector4 screenPos = prj.project(worldPos);
        PointData p = new PointData(worldPos, screenPos, v);
        if (isVisible) {
          visibleVerticesSet.add(p);

          // Fix vertices flagged as hidden but actually visible
          if (hiddenVerticesSet.contains(p)) {
            hiddenVerticesSet.remove(p);
          }
        } else if (!visibleVerticesSet.contains(p)) {
          // Add only if no other faces have already claimed the
          // vertex visibility.
          hiddenVerticesSet.add(p);
        }
        if (p.vertex.getID() >= 0 && hullVerticesSet.add(p)) {
          if (v.x() > max[0]) {
            max[0] = v.x();
          }
          if (v.y() > max[1]) {
            max[1] = v.y();
          }
          if (v.z() > max[2]) {
            max[2] = v.z();
          }
          if (v.x() < min[0]) {
            min[0] = v.x();
          }
          if (v.y() < min[1]) {
            min[1] = v.y();
          }
          if (v.z() < min[2]) {
            min[2] = v.z();
          }
        }
      }
    }

    // Centering and scaling
    centroid.x((max[0] + min[0]) * 0.5f * zoomFactor);
    centroid.y((max[1] + min[1]) * 0.5f * zoomFactor);
    centroid.z((max[2] + min[2]) * 0.5f * zoomFactor);
    max[0] -= min[0];
    max[1] -= min[1];
    max[2] -= min[2];
    maxVertexDistance = 0.5f * (float) Math.sqrt(max[0] * max[0] + max[1]
        * max[1] + max[2] * max[2]);
    centroid.divSelf(maxVertexDistance * zoomFactor);

    // Build the verticesInside set.
    verticesInsideSet.clear();
    for (int i = 0; i < allVerticesArray.length; i++) {
      HullVertex v = allVerticesArray[i];
      PointData p = new PointData(null, null, v); // Dummy PointData, just
                            // to check the HashSet
      if (!hullVerticesSet.contains(p)) {
        Vector4 worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        Vector4 screenPos = prj.project(worldPos);
        p = new PointData(worldPos, screenPos, v);
        verticesInsideSet.add(p);
      }
    }
View Full Code Here

        HullFace f = hullFacesArray[fi];
        f.setMarked(false);
      }

      for (int fi = 0; fi < hullFacesArray.length; fi++) {
        HullVertex v = hullVerticesArray[vi].vertex;
        HullFace f = hullFacesArray[fi];

        // Start color propagation
        if (v.getID() == f.getVertex(0).getID()
            || v.getID() == f.getVertex(1).getID()
            || v.getID() == f.getVertex(2).getID()) {
          if (!f.isMarked()) {
            incrementFaceCounter(f);
          }
        }
      }
View Full Code Here

    // Draw hidden faces
    if (enableHiddenFaces) {
      for (int i = 0; i < hiddenFacesArray.length; i++) {
        HullFace f = hiddenFacesArray[i];
        HullVertex v = f.getVertex(0);
        Vector4 worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        Vector4 screenPos = prj.project(worldPos);
        PointData p1 = new PointData(worldPos, screenPos, v);

        v = f.getVertex(1);
        worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        screenPos = prj.project(worldPos);
        PointData p2 = new PointData(worldPos, screenPos, v);

        v = f.getVertex(2);
        worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        screenPos = prj.project(worldPos);
        PointData p3 = new PointData(worldPos, screenPos, v);

        drawFace(g, p1, p2, p3, f);
      }
    }

    // Draw visible faces
    if (enableVisibleFaces) {
      for (int i = 0; i < visibleFacesArray.length; i++) {
        HullFace f = visibleFacesArray[i];
        HullVertex v = f.getVertex(0);
        Vector4 worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        Vector4 screenPos = prj.project(worldPos);
        PointData p1 = new PointData(worldPos, screenPos, v);

        v = f.getVertex(1);
        worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        screenPos = prj.project(worldPos);
        PointData p2 = new PointData(worldPos, screenPos, v);

        v = f.getVertex(2);
        worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        screenPos = prj.project(worldPos);
        PointData p3 = new PointData(worldPos, screenPos, v);

        drawFace(g, p1, p2, p3, f);
      }
    }

    // Draw hidden edges
    if (enableHiddenEdges) {
      for (int i = 0; i < hiddenEdgesArray.length; i++) {
        HullEdge e = hiddenEdgesArray[i];
        HullVertex v = e.getEndPoint(0);
        Vector4 worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        Vector4 screenPos = prj.project(worldPos);
        PointData p1 = new PointData(worldPos, screenPos, v);

        v = e.getEndPoint(1);
        worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        screenPos = prj.project(worldPos);
        PointData p2 = new PointData(worldPos, screenPos, v);

        drawEdge(g, p1, p2, e, false);
      }
    }

    // Draw hidden hull vertices
    for (int i = 0; i < sortedHiddenVertices.length; i++) {
      PointData p = sortedHiddenVertices[i];
      if (p.vertex.getID() >= 0) {
        drawVertex(g, p, false, true);
      }
    }

    // Draws points inside
    for (int i = 0; i < sortedVerticesInside.length; i++) {
      PointData p = sortedVerticesInside[i];
      if (enableInternalVertices || p.vertex.getName().equals(selectedStation) ) {
        drawVertex(g, p, false, false);
      }
    }
   

    drawAxes(g, true);

    // Draw visible hull edges
    if (enableVisibleEdges) {
      for (int i = 0; i < visibleEdgesArray.length; i++) {
        HullEdge e = visibleEdgesArray[i];
        HullVertex v = e.getEndPoint(0);
        Vector4 worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        Vector4 screenPos = prj.project(worldPos);
        PointData p1 = new PointData(worldPos, screenPos, v);

        v = e.getEndPoint(1);
        worldPos = Vector4.createPoint3D(v.x(), v.y(), v.z());
        screenPos = prj.project(worldPos);
        PointData p2 = new PointData(worldPos, screenPos, v);

        drawEdge(g, p1, p2, e, true);
      }
View Full Code Here

TOP

Related Classes of jmt.engine.jaba.convexHull3d.HullVertex

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.