difference_closed_polygons_xld(Polygons, Sub : PolygonsDifference : : ) 
函数计算Polygons, Sub 所包含区域的差集,返回判令的轮廓,保存于PolygonsDifference 
如果单个输入多边形没有闭合,则通过连接它们的起点和终点自动使之闭合。 
计算时首先确认Polygons, Sub对应的闭合区域,再计算区域的差集。 
 
两组输入多边形被称为边界集。 
边界集由任意数量的边界组成。 
每个边界可以是凸凹自交的。 
边界嵌套可形成内孔。 
 
 
这种边界集所包围的区域由所谓的偶奇规则定义。 
因此,它由具有以下性质的所有点组成: 
由该点与位于区域外的另一个参考点连接而成的线具有奇数个带有边界的交叉点。 
 
 
更具描述性的是, 
这意味着如果一个边界完全位于另一个边界所包围的区域内, 
则该边界定义了该区域内的一个洞。 
同样,将一个边界集的两个单独边界的重叠区域作为一个“孔”, 
即,它不属于这两个边界所围合的区域。 
注意,被边界包围的区域并不取决于边界的方向。 
 
 
自交边界可以在交点处分割, 
也可以重新排序, 
使其在交点处接触自身。 
产生的边界被视为单独的边界。 
 
 
 
 
例程 
* This example shows the usage of the operator difference_closed_polygons_xld 
*  
* First, two closed polygons are created. They both enclose a circular region. 
* These two regions overlap each other. 
gen_ellipse_contour_xld (Contour1, 200, 200, 0, 100, 100, 0, 6.28318, 'positive', 1.5) 
gen_polygons_xld (Contour1, Polygon1, 'ramer', 10) 
gen_ellipse_contour_xld (Contour2, 200, 300, 0, 100, 100, 0, 6.28318, 'positive', 1.5) 
gen_polygons_xld (Contour2, Polygon2, 'ramer', 10) 
*  
* Now, the second region is subtracted from the first one. 
difference_closed_polygons_xld (Polygon1, Polygon2, PolygonsDifference) 
*  
* Visualization of the result 
dev_clear_window () 
dev_set_line_width (5) 
dev_set_color ('green') 
dev_display (Polygon1) 
dev_set_color ('red') 
dev_display (Polygon2) 
dev_set_line_width (3) 
dev_set_color ('blue') 
dev_display (PolygonsDifference) 
stop () 
dev_clear_window () 
dev_set_line_width (1) 
dev_set_color ('white') 
*  
* Now, boundary sets that define regions with holes are created. 
gen_ellipse_contour_xld (Boundary1, 200, 200, 0, 100, 100, 0, 6.28318, 'positive', 1.5) 
gen_polygons_xld (Boundary1, Boundary1Poly, 'ramer', 10) 
gen_ellipse_contour_xld (Hole1, 200, 200, 0, 75, 75, 0, 6.28318, 'positive', 1.5) 
gen_polygons_xld (Hole1, Hole1Poly, 'ramer', 10) 
concat_obj (Boundary1Poly, Hole1Poly, BoundarySet1) 
gen_ellipse_contour_xld (Boundary2, 200, 300, 0, 100, 100, 0, 6.28318, 'positive', 1.5) 
gen_polygons_xld (Boundary2, Boundary2Poly, 'ramer', 10) 
gen_ellipse_contour_xld (Hole2, 200, 300, 0, 75, 75, 0, 6.28318, 'positive', 1.5) 
gen_polygons_xld (Hole2, Hole2Poly, 'ramer', 10) 
concat_obj (Boundary2Poly, Hole2Poly, BoundarySet2) 
*  
* Now, the second region is subtracted from the first one. 
difference_closed_polygons_xld (BoundarySet1, BoundarySet2, PolygonsDifference) 
*  
* Visualization of the result 
dev_clear_window () 
dev_set_line_width (5) 
dev_set_color ('green') 
dev_display (BoundarySet1) 
dev_set_color ('red') 
dev_display (BoundarySet2) 
dev_set_line_width (3) 
dev_set_color ('blue') 
dev_display (PolygonsDifference) 
 
 
 
 |