本文整理匯總了Python中Polygon.Polygon.isHole方法的典型用法代碼示例。如果您正苦於以下問題:Python Polygon.isHole方法的具體用法?Python Polygon.isHole怎麽用?Python Polygon.isHole使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Polygon.Polygon
的用法示例。
在下文中一共展示了Polygon.isHole方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: set_shape
# 需要導入模塊: from Polygon import Polygon [as 別名]
# 或者: from Polygon.Polygon import isHole [as 別名]
def set_shape(self, shape):
if not import_check("Polygon"):
return
# shape can be a Polygon object or a simple list of points
# Construct a pointer array with this integer format:
# (number of contours,closed), where closed=1 for shape=Polygon object
# but closed=0 for shape=list of points with final != initial.
# In both Polygon and list cases if final == initial, final is discarded
# (length of 1st contour, offset in array to data for 1st contour)
# (length of 2nd contour, offset in array to data for 2nd contour)
# .....
# Construct a contour array with this float format:
# (x,y) data for 1st contour
# (x,y) data for 2nd contour
# .....
datalist = []
if isinstance(shape, str):
shape = shapes.text(text=shape, align='center')
else:
try:
shape.pos # could be a paths.xxx object, a list of vectors
s = []
for v in shape.pos:
s.append((v.x, -v.z))
shape = Polygon(s)
except:
pass
try:
for i in range(len(shape)):
s = list(shape.contour(i))
if s[-1] == s[0]: # discard final point if same as initial
s = s[:-1]
c = self.xycurl(s) # positive if CCW
# Require hole contours to run CCW, external contours CW
if (shape.isHole(i) and (c < 0) or
(not shape.isHole(i)) and (c > 0)):
# Need to reverse the order of points in this contour
s.reverse()
datalist.append(s)
closed = True
isPolygon = True
except:
s = shape
# Require (external) closed contour to run clockwise (curl > 0)
if self.xycurl(s) > 0: # Need to reverse the order of points in this contour
s.reverse()
if s[-1] == s[0]: # discard final point if same as initial, mark closed
s = s[:-1]
closed = True
else:
closed = False
isPolygon = False
datalist = array([s], float)
contours, pcontours = self.make_shapedata(datalist, closed)
if isPolygon:
strips, pstrips = self.make_shapedata(shape.triStrip(), closed)
else:
strips = array([(0,0)])
pstrips = array([(0,0)])
# Send pointers, contour data, and shape.triStrip data to Visual
self.set_contours(contours, pcontours, strips, pstrips)