Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def addPolyline(self , polyline , name = None):
if not isinstance(polyline , CPolyline):
polyline = CPolyline( init_points = polyline , name = name)
else:
if not name is None:
raise ValueError("The name keyword argument can only be supplied when add not CPOlyline object")
name = polyline.getName()
if name and name in self:
raise KeyError("The polyline collection already has an object:%s" % name)
if polyline.isReference():
self._add_polyline( polyline , False)
else:
polyline.convertToCReference( self )
self._add_polyline( polyline , True)
def __init_polyline(self):
pl = CPolyline()
for (i,j) in self.getIJPolyline():
x,y,z = self.__grid.getNodeXYZ(i, j, self.__k)
pl.addPoint(x, y)
self.__polyline = pl
def addPolyline(self , polyline , name = None):
if not isinstance(polyline , CPolyline):
polyline = CPolyline( init_points = polyline , name = name)
else:
if not name is None:
raise ValueError("The name keyword argument can only be supplied when add not CPOlyline object")
name = polyline.getName()
if name and name in self:
raise KeyError("The polyline collection already has an object:%s" % name)
if polyline.isReference():
self._add_polyline( polyline , False)
else:
polyline.convertToCReference( self )
self._add_polyline( polyline , True)
def select_outside_polygon( self , points , intersect = False):
"""
Will select all points outside polygon.
See select_inside_polygon for more docuemntation.
"""
self._select_outside_polygon( CPolyline( init_points = points ))
def deselect_inside_polygon( self , points ):
"""
Will select all points outside polygon.
See select_inside_polygon for more docuemntation.
"""
self._deselect_inside_polygon( CPolyline( init_points = points ))
p0 = fault_polyline[1]
p1 = fault_polyline[0]
else:
p0 = fault_polyline[-2]
p1 = fault_polyline[-1]
ray_dir = GeometryTools.lineToRay(p0,p1)
intersections = GeometryTools.rayPolygonIntersections(p1, ray_dir, bbox)
if intersections:
p2 = intersections[0][1]
if self.getName():
name = "Extend:%s" % self.getName()
else:
name = None
return CPolyline(name=name, init_points=[(p1[0], p1[1]), p2])
else:
raise Exception("Logical error - must intersect with bounding box")
def get_polyline(self, name=None):
polyline = CPolyline(name=name)
for fl in self:
polyline += fl.getPolyline()
return polyline
p0 = fault_polyline[1]
p1 = fault_polyline[0]
else:
p0 = fault_polyline[-2]
p1 = fault_polyline[-1]
ray_dir = GeometryTools.lineToRay(p0,p1)
intersections = GeometryTools.rayPolygonIntersections(p1, ray_dir, bbox)
if intersections:
p2 = intersections[0][1]
if self.getName():
name = "Extend:%s" % self.getName()
else:
name = None
return CPolyline(name=name, init_points=[(p1[0], p1[1]), p2])
else:
raise Exception("Logical error - must intersect with bounding box")
def deselect_outside_polygon( self , points ):
"""
Will select all points outside polygon.
See select_inside_polygon for more docuemntation.
"""
self._deselect_outside_polygon( CPolyline( init_points = points ))