push/pop 操作

语法

  • [ operations ]

参数

  1. operations
    要执行的一系列 CGA 操作。

说明

[ 操作用于将当前形状压入形状堆栈的顶部。 它必须与随后的 ] 操作匹配,后者用于取出位于形状堆栈顶部的形状并将其删除。

相关内容

示例

旋转

在此示例中,拉伸的形状旋转三次并分配给新形状 (X)。 旋转基于彼此构建。

Lot-->
	extrude(15)
    
	r(scopeCenter, 0, 22.5, 0) X 
	r(scopeCenter, 0, 22.5, 0) X
	r(scopeCenter, 0, 22.5, 0) X
带旋转的拉伸形状

如果使用 push/pop 对封装旋转和“创建形状”操作,则所有 X 会重合。 旋转彼此独立。

Lot-->
	extrude(15)
    
	[ r(scopeCenter, 0, 22.5, 0) X ]
	[ r(scopeCenter, 0, 22.5, 0) X ]
	[ r(scopeCenter, 0, 22.5, 0) X ]
使用 createShape 且带旋转的拉伸形状

房屋

这两个规则生成的结果相同。 在第二个规则中,会先使用 push/pop 操作生成屋顶。

House -->
    extrude(10)
    comp(f) { top : roofHip(45) Roof. | all = House.}
	
House -->
    [ t(0,10,0) roofHip(45) Roof. ]
    extrude(10)
    comp(f) { top : NIL | all = House. }
房屋规则

平移

圆柱资产插入五次。 每个范围会基于初始形状的范围进行平移。

House-->
    Cylinder
    [ t(  0, 0, ' 1) Cylinder ]
    [ t(  0, 0, '-1) Cylinder ]
    [ t(' 1, 0,   0) Cylinder ]
    [ t('-1, 0,   0) Cylinder ]

Cylinder -->
    primitiveCylinder(16, 1, 2)
圆柱资产

条件

条件和随机语句不得具有前置操作。 使用 push 和 pop 封装大小写切换。

Lot -->
    s(1,1,1)
    [ case scope.sx == 1 : primitiveCube() Cube.
      else : primitiveCylinder() Cylinder. ]
条件切换

在本主题中