// Path: src/org/twak/camp/ui/DirectionHeightEvent.java
// public class DirectionHeightEvent implements HeightEvent
// {
//     protected double height;
//     // newAngle is the angle that this edge will turn towards at the above height
//     // length is the distance until the next event (only used for horizontal directions)
//     public double newAngle;
//     Machine machine;
//     public Set<Tag> profileFeatures = new HashSet();
// 
//     public DirectionHeightEvent( Machine machine, double angle )
//     {
//         this( machine, 0, angle );
//     }
// 
//     public double getAngle()
//     {
//         return newAngle;
//     }
// 
//     public DirectionHeightEvent( Machine machine, double height, double angle )
//     {
//         super();
//         this.machine = machine;
//         this.height = height;
//         this.newAngle = angle;
//     }
// 
//     public double getHeight()
//     {
//         return height;
//     }
// 
//     public boolean process( Skeleton skel )
//     {
// //        System.out.println("machine "+machine.toString()+" at "+height+" setting angle "+newAngle );
// 
//         // set the new angle
//         machine.currentAngle = newAngle;
// 
//         SkeletonCapUpdate update = new SkeletonCapUpdate(skel);
// 
//         // add in the output edges for the outgoing face:
//         LoopL<Corner> cap = update.getCap(height);
//         DebugDevice.dump( "cap", cap );
// 
//         CornerClone cc = new CornerClone(cap);
// 
//         // preserve corner information for assigning parents, later
//         DHash<Corner,Corner> nOCorner = cc.nOCorner.shallowDupe();
// 
//         for ( Corner c : cc.output.eIterator() )
//         {
//             // corners are untouched if neither attached edge has this machine
//             if ( c.nextL.machine == machine || c.prevL.machine == machine )
//                 nOCorner.removeA( c );
// 
//             // segments are untouched if they don't contain this machine
//             if ( c.nextL.machine == machine )
//             {
//                 // copy over profile features
//                 // yes, it looks like we add features to an edge we later disable, but it is still referenced in the entire loop and gets used for edge properties.
//                 c.nextL.profileFeatures = profileFeatures;
//                 
//                 cc.nOSegments.removeA( c );
//             }
//         }
// 
//         update.update( cc.output, cc.nOSegments, nOCorner);
// 
//         /**
//          * Must now update the parent field in output for the new edges, so that
//          * we know where a face came from
//          */
//         for ( Corner c : skel.liveCorners )
//         {
//             if ( c.nextL.machine == machine )
//             {
//                 Corner old = update.getOldBaseLookup().get( cc.nOCorner.get( c ));
//                 skel.output.setParent (c.nextL.start, old.nextL.start);
//             }
//         }
// 
//         DebugDevice.dump( "post height "+height, skel);
// 
//         machine.findNextHeight( skel );
//         return true;
//     }
// }


import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.twak.camp.ui.DirectionHeightEvent;

    @Override
    public String toString()
    {
        return description;
    }

    /**
     * Called once after the machine is assigned to it's first edge
     */
    public void addEdge( Edge e, Skeleton skel )
    {
        if ( heightEvent == null )
            findNextHeight( skel );

        // when we're new, or sometimes when we swap a machine out and back in again things get confused
//        if ( seenEdges.add( e ) || e.getAngle() != currentAngle )
//        {
            e.setAngle( currentAngle );
//        }
    }

    public List<Edge> findOurEdges( Skeleton skel )
    {
        List<Edge> edgesToChange = new ArrayList();

        for ( Edge e : skel.liveEdges )
            if (e.machine == this)
                edgesToChange.add(e);
        
// Path: src/org/twak/camp/ui/DirectionHeightEvent.java
// public class DirectionHeightEvent implements HeightEvent
// {
//     protected double height;
//     // newAngle is the angle that this edge will turn towards at the above height
//     // length is the distance until the next event (only used for horizontal directions)
//     public double newAngle;
//     Machine machine;
//     public Set<Tag> profileFeatures = new HashSet();
// 
//     public DirectionHeightEvent( Machine machine, double angle )
//     {
//         this( machine, 0, angle );
//     }
// 
//     public double getAngle()
//     {
//         return newAngle;
//     }
// 
//     public DirectionHeightEvent( Machine machine, double height, double angle )
//     {
//         super();
//         this.machine = machine;
//         this.height = height;
//         this.newAngle = angle;
//     }
// 
//     public double getHeight()
//     {
//         return height;
//     }
// 
//     public boolean process( Skeleton skel )
//     {
// //        System.out.println("machine "+machine.toString()+" at "+height+" setting angle "+newAngle );
// 
//         // set the new angle
//         machine.currentAngle = newAngle;
// 
//         SkeletonCapUpdate update = new SkeletonCapUpdate(skel);
// 
//         // add in the output edges for the outgoing face:
//         LoopL<Corner> cap = update.getCap(height);
//         DebugDevice.dump( "cap", cap );
// 
//         CornerClone cc = new CornerClone(cap);
// 
//         // preserve corner information for assigning parents, later
//         DHash<Corner,Corner> nOCorner = cc.nOCorner.shallowDupe();
// 
//         for ( Corner c : cc.output.eIterator() )
//         {
//             // corners are untouched if neither attached edge has this machine
//             if ( c.nextL.machine == machine || c.prevL.machine == machine )
//                 nOCorner.removeA( c );
// 
//             // segments are untouched if they don't contain this machine
//             if ( c.nextL.machine == machine )
//             {
//                 // copy over profile features
//                 // yes, it looks like we add features to an edge we later disable, but it is still referenced in the entire loop and gets used for edge properties.
//                 c.nextL.profileFeatures = profileFeatures;
//                 
//                 cc.nOSegments.removeA( c );
//             }
//         }
// 
//         update.update( cc.output, cc.nOSegments, nOCorner);
// 
//         /**
//          * Must now update the parent field in output for the new edges, so that
//          * we know where a face came from
//          */
//         for ( Corner c : skel.liveCorners )
//         {
//             if ( c.nextL.machine == machine )
//             {
//                 Corner old = update.getOldBaseLookup().get( cc.nOCorner.get( c ));
//                 skel.output.setParent (c.nextL.start, old.nextL.start);
//             }
//         }
// 
//         DebugDevice.dump( "post height "+height, skel);
// 
//         machine.findNextHeight( skel );
//         return true;
//     }
// }


// Path: src/org/twak/camp/Machine.java
import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.twak.camp.ui.DirectionHeightEvent;


    @Override
    public String toString()
    {
        return description;
    }

    /**
     * Called once after the machine is assigned to it's first edge
     */
    public void addEdge( Edge e, Skeleton skel )
    {
        if ( heightEvent == null )
            findNextHeight( skel );

        // when we're new, or sometimes when we swap a machine out and back in again things get confused
//        if ( seenEdges.add( e ) || e.getAngle() != currentAngle )
//        {
            e.setAngle( currentAngle );
//        }
    }

    public List<Edge> findOurEdges( Skeleton skel )
    {
        List<Edge> edgesToChange = new ArrayList();

        for ( Edge e : skel.liveEdges )
            if (e.machine == this)
                edgesToChange.add(e);
        
        return edgesToChange;