Esempio n. 1
0
 private void Plan(IEnumerable<IStatement> statements, SymbolTable symbolTable, Transform transform, ComplexElement def)
 {
     foreach (var statement in statements)
     {
         if (statement is ElementDefinition) {
             var anotherDef = (ElementDefinition) statement;
             var ele = new ComplexElement();
             Plan(anotherDef.Statements, symbolTable.Push(), Transform.Identity, ele);
             symbolTable = symbolTable.AddSymbol(anotherDef.Name, ele);
         }
         else if (statement is BuildByIdentifier)
         {
             var build = (BuildByIdentifier) statement;
             var ele = symbolTable[build.Identifier];
             var buildInst = new BuildInstruction(build.Shape, build.Dimension, transform.Adjust(build.Location), ele);
             def.AddBuildInstruction(buildInst);
         }
         else if (statement is BuildByStatements)
         {
             var build = (BuildByStatements) statement;
             var ele = new ComplexElement();
             Plan(build.Statements, symbolTable, Transform.Identity, ele);
             var buildInst = new BuildInstruction(build.Shape, build.Dimension, transform.Adjust(build.Location), ele);
             def.AddBuildInstruction(buildInst);
         }
         else if (statement is OriginTransformStatement)
         {
             var transStatement = (OriginTransformStatement) statement;
             if (transStatement.Instructions is AbsoluteTransformInstructions)
             {
                 var absInstr = (AbsoluteTransformInstructions) transStatement.Instructions;
                 var newTrans = transform.Adjust(absInstr.Direction, absInstr.Degree);
                 Plan(transStatement.Statements,symbolTable,newTrans,def);
             }
             else
             {
                 var absInstr = (RelativeTransformInstructions) transStatement.Instructions;
                 var newTrans = transform.Adjust(absInstr.Direction, def);
                 Plan(transStatement.Statements,symbolTable,newTrans,def);
             }
         }
     }
 }
Esempio n. 2
0
 public void AddBuildInstruction(BuildInstruction instruction)
 {
     BuildInstructions.Add(instruction);
     Width = Math.Max(Width, instruction.Width + instruction.Location.X);
     Depth = Math.Max(Depth, instruction.Depth + instruction.Location.Z);
     Height = Math.Max(Height, instruction.Height + instruction.Location.Y);
 }