Example #1
0
 /**
  * Поиск всех точек пересечения поверхностей с плоскостью У, а также поиск пересечений между
  * отрезками получающимися.
  *
  * @param currentY
  */
 private void findAllIntersections(double currentY) {
   drawnSegments.clear();
   pointsList.clear();
   listPointsEvent.map.clear();
   for (Surface surface : drawnSurfaces) {
     Segment segment = surface.getIntersectionWithY(currentY);
     if (segment == null) {
       continue;
     }
     if (segment.getFinish().getX() < segment.getStart().getX()) {
       segment = new Segment(segment.getFinish(), segment.getStart(), surface.getSurfaceColor());
     }
     segments.add(segment);
     pointsList.add(segment.getStart());
     pointsList.add(segment.getFinish());
     listPointsEvent.addEvent(
         new PointEvent(PointEventsList.START, segment.getStart()),
         (int) segment.getStart().getX());
     listPointsEvent.addEvent(
         new PointEvent(PointEventsList.FINISH, segment.getFinish()),
         (int) segment.getFinish().getX());
   }
   for (int i = 0, number = drawnSegments.size(); i < number; i++) {
     for (int j = i + 1; j < number; j++) {
       Point intersection = drawnSegments.get(i).getIntersectionWithSegment(drawnSegments.get(j));
       if (intersection != null) {
         pointsList.add(intersection);
         listPointsEvent.addEvent(
             new PointEvent(PointEventsList.INTERSECTION, intersection),
             (int) intersection.getX());
       }
     }
   }
 }