Package es.iiia.shapegrammar.shape.guides

Examples of es.iiia.shapegrammar.shape.guides.IntersectionTriplet


        fromIndexes[1] = 1;
        fromIndexes[2] = 2;

        // create left matrix
        // 1st row
        IntersectionTriplet fromTriplet = from.getTriplet();

        A.set(0, 0, from.getIntersection().getX());
        A.set(0, 1, from.getIntersection().getY());
        A.set(0, 2, 1);
        // 2nd
        A.set(1, 3, from.getIntersection().getX());
        A.set(1, 4, from.getIntersection().getY());
        A.set(1, 5, 1);
        // 3rd
        A.set(2, 0, fromTriplet.getPointA().getX());
        A.set(2, 1, fromTriplet.getPointA().getY());
        A.set(2, 2, 1);
        // 4th
        A.set(3, 3, fromTriplet.getPointA().getX());
        A.set(3, 4, fromTriplet.getPointA().getY());
        A.set(3, 5, 1);
        // 5th
        A.set(4, 0, fromTriplet.getPointB().getX());
        A.set(4, 1, fromTriplet.getPointB().getY());
        A.set(4, 2, 1);
        // 6th
        A.set(5, 3, fromTriplet.getPointB().getX());
        A.set(5, 4, fromTriplet.getPointB().getY());
        A.set(5, 5, 1);

        // now find all intersection points in shape with same angle and ratio as original intersection
        IntersectionModel to;
        ArrayList<IntersectionTriplet> intersectionPairs;
        IntersectionTriplet currentPair;

        //Debugger.getInstance().addMessage("Init pair: " + from.getIntersection().toString() + fromTriplet.toString());

        // show markers
        //System.out.println("MARKERS");
        for (MarkerModel model : shape.getMarkers()) {
          Debugger.getInstance().addMessage(model.getLocation().toString());
        }
       
        // get itersections with the same angle
        toIntersections = shape.getIntersections(from.getAngle());     
       
        ExecutionReport.setGoodIntersections(toIntersections.size());
        long triplets = 0;
        for (IntersectionModel intr : toIntersections) {
          ArrayList<IntersectionTriplet> arr = intr.getTriplets(fromTriplet.getRatio());
          if (arr != null) {
            triplets += arr.size();
          }
        }
        ExecutionReport.setTriplets(triplets);
       
        // intersections are ordered by the angle
        // we start with the smallest angle and continue to the top limit
        for (int tos = 0; tos < toIntersections.size(); tos++) {
            ExecutionReport.intersectionTested();
           
          //monitor.setTaskName("Checking " + (tos + 1) + ". intersection");       
            if (monitor.isCanceled()) {
              return subShapes;
            }
           
          // initial validation
            to = toIntersections.get(tos);

            Debugger.getInstance().addMessage("=================================");
            Debugger.getInstance().addMessage("Intersection: " + to.getIntersection());
           
//            // we stop if we've reached bigger angle
//            if (to.getAngle() > from.getAngle()) {
//                break;
//            }
//
//            // we continue to search for the exact angle and ratio
//            if (to.getAngle() < from.getAngle()) {
//                continue;
//            }

            // now we have an intersection with the good angle
            // we will search for all points on carriers that have the same ratio as the
            // initial intersection triplet
            // intersection is defined by point and two carriers
            intersectionPairs = to.getTriplets(fromTriplet.getRatio());
                    
           
            // there exist no triplets on carriers with given ratio
            if (intersectionPairs == null)
                continue;

            // iterate for all found pairs
            for (int pair = 0; pair < intersectionPairs.size(); pair++) {
              ExecutionReport.tripletTested();
             
              //monitor.subTask("Checking intersection triplets");
              if (monitor.isCanceled()) {
                  return subShapes;
                }
             
                // get current pair
                currentPair = intersectionPairs.get(pair);                           
               
                Debugger.getInstance().addMessage("Pair: " + currentPair);             
                Debugger.getInstance().addMessage("TESTING: " + to.getIntersection().toString() + currentPair.toString());
               
                // we test this 2 times (once when we flip pointA and pointB (symmetry))
                // TODO: Test ratio .. if by flip does not change continue
                for (int j = 0; j < 1; j++) {
//                  if (monitor.isCanceled()) {
//                      return subShapes;
//                    }
                 
                  // this counter is to see how much transformations were tested


                    b.set(0, 0, to.getIntersection().getX());
                    b.set(1, 0, to.getIntersection().getY());
                    b.set(2, 0, j == 0 ? currentPair.getPointA().getX() : currentPair.getPointB().getX());
                    b.set(3, 0, j == 0 ? currentPair.getPointA().getY() : currentPair.getPointB().getY());
                    b.set(4, 0, j == 0 ? currentPair.getPointB().getX() : currentPair.getPointA().getX());
                    b.set(5, 0, j == 0 ? currentPair.getPointB().getY() : currentPair.getPointA().getY());

                    // create transformation by solving equation of 6 unknowns
                    try {
                        solution = A.solve(b);
                    }
View Full Code Here


                break;
        }

        double ratio = getRatio(pointA, pointB);

        return new IntersectionTriplet(pointA, pointB, ratio);
    }
View Full Code Here

                if (!this.triplets.containsKey(currentRatio)) {
                    this.triplets.put(currentRatio, new ArrayList<IntersectionTriplet>());
                }

                // now add this triplet to this ratio
                this.triplets.get(currentRatio).add(new IntersectionTriplet(pointA, pointB, currentRatio));
            }
        }
    }
View Full Code Here

TOP

Related Classes of es.iiia.shapegrammar.shape.guides.IntersectionTriplet

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.