예제 #1
0
        void SetInitalLayer()
        {
            activeLayerIndex = 0;
            if (loadedGCode.Count > 0)
            {
                int     firstExtrusionIndex = 0;
                Vector3 lastPosition        = loadedGCode.Instruction(0).Position;
                double  ePosition           = loadedGCode.Instruction(0).EPosition;
                // let's find the first layer that has extrusion if possible and go to that
                for (int i = 1; i < loadedGCode.Count; i++)
                {
                    PrinterMachineInstruction currentInstruction = loadedGCode.Instruction(i);
                    if (currentInstruction.EPosition > ePosition && lastPosition != currentInstruction.Position)
                    {
                        firstExtrusionIndex = i;
                        break;
                    }

                    lastPosition = currentInstruction.Position;
                }

                if (firstExtrusionIndex > 0)
                {
                    for (int layerIndex = 0; layerIndex < loadedGCode.NumChangesInZ; layerIndex++)
                    {
                        if (firstExtrusionIndex < loadedGCode.GetInstructionIndexAtLayer(layerIndex))
                        {
                            activeLayerIndex = Math.Max(0, layerIndex - 1);
                            break;
                        }
                    }
                }
            }
        }
예제 #2
0
 public override int GetInstructionIndexAtLayer(int layerIndex)
 {
     return(source.GetInstructionIndexAtLayer(layerIndex));
 }