def __init__(self): AlgorithmProvider.__init__(self) self.alglist = [SumLines(), PointsInPolygon(), PointsInPolygonWeighted(), PointsInPolygonUnique(), BasicStatisticsStrings(), BasicStatisticsNumbers(), NearestNeighbourAnalysis(), MeanCoords(), LinesIntersection(), UniqueValues(), PointDistance(), ReprojectLayer(), ExportGeometryInfo(), Centroids(), Delaunay(), VoronoiPolygons(), SimplifyGeometries(), DensifyGeometries(), DensifyGeometriesInterval(), MultipartToSingleparts(), SinglePartsToMultiparts(), PolygonsToLines(), LinesToPolygons(), ExtractNodes(), Eliminate(), ConvexHull(), FixedDistanceBuffer(), VariableDistanceBuffer(), Dissolve(), Difference(), Intersection(), Union(), Clip(), ExtentFromLayer(), RandomSelection(), RandomSelectionWithinSubsets(), SelectByLocation(), RandomExtract(), RandomExtractWithinSubsets(), ExtractByLocation(), SpatialJoin(), RegularPoints(), SymetricalDifference(), VectorSplit(), VectorGrid(), DeleteColumn(), DeleteDuplicateGeometries(), TextToFloat(), ExtractByAttribute(), SelectByAttribute(), Grid(), Gridify(), HubDistance(), HubLines(), Merge(), GeometryConvert(), AddTableField(), FieldsCalculator(), SaveSelectedFeatures(), JoinAttributes(), AutoincrementalField(), Explode(), FieldsPyculator(), EquivalentNumField(), PointsLayerFromTable(), StatisticsByCategories(), ConcaveHull(), Polygonize(), RasterLayerStatistics(), PointsDisplacement(), ZonalStatistics(), PointsFromPolygons(), PointsFromLines(), RandomPointsExtent(), RandomPointsLayer(), RandomPointsPolygonsFixed(), RandomPointsPolygonsVariable(), RandomPointsAlongLines(), PointsToPaths(), PostGISExecuteSQL(), ImportIntoPostGIS(), SetVectorStyle(), SetRasterStyle(), SelectByExpression(), HypsometricCurves(), # ------ raster ------ # CreateConstantRaster(), # ------ graphics ------ # VectorLayerHistogram(), VectorLayerScatterplot(), # RasterLayerHistogram(), MeanAndStdDevPlot(), # BarPlot(), PolarPlot() ] folder = os.path.join(os.path.dirname(__file__), 'scripts') scripts = ScriptUtils.loadFromFolder(folder) for script in scripts: script.allowEdit = False self.alglist.extend(scripts) for alg in self.alglist: alg._icon = self._icon
def FindContourss(binary_image): binary_image = flip(binary_image, axis=1) binary_image = rot90(binary_image, 1) Erode_A = zeros_like(binary_image) for i in range(1, binary_image.shape[0] - 1): for j in range(1, binary_image.shape[1] - 1): if (binary_image[i][j] != 0): if (binary_image[i-1][j-1]> 0) \ and (binary_image[i+1][j-1]> 0) \ and (binary_image[i-1][j+1]> 0) \ and (binary_image[i+1][j+1]> 0): Erode_A[i][j] = 1 #Eroded image subtracted to the original image to get the boundaries Contourses = binary_image - Erode_A #Labeling of each boundary labeler = Union() Labeled_image = labeler.labelComponents(Contourses) num_contours = int(maxx(Labeled_image)) # Contours (vertices) for each boundary for i in range(num_contours): vars()['contour' + str(i + 1)] = zeros( (len(Labeled_image[Labeled_image == (i + 1)]), 1, 2), dtype='int32') vars()['contador' + str(i + 1)] = -1 for i in range(binary_image.shape[0]): for j in range(binary_image.shape[1]): for k in range(num_contours): if Labeled_image[i][j] == (k + 1): vars()['contador' + str(k + 1)] = (vars()['contador' + str(k + 1)]) + 1 vars()['contour' + str(k + 1)][(vars()['contador' + str(k + 1)])][0][0] = int(i) vars()['contour' + str(k + 1)][(vars()['contador' + str(k + 1)])][0][1] = int(j) contourseses = [] for i in range(num_contours): contourseses.append(vars()['contour' + str(i + 1)]) return contourseses
def execute(self, enviroment): for hijo in self.hijos: if hijo.nombreNodo == 'SENTENCIA_INSERT': hijo.execute(enviroment) elif hijo.nombreNodo == 'SENTENCIA_UPDATE': hijo.execute(enviroment) elif hijo.nombreNodo == 'SENTENCIA_DELETE': hijo.execute(enviroment) elif hijo.nombreNodo == 'SENTENCIA_SELECT': hijo.execute(enviroment) elif hijo.nombreNodo == 'SENTENCIA_UNION': nuevoUnion = Union() resp = nuevoUnion.execute(hijo) elif hijo.nombreNodo == 'SENTENCIA_UNION_ALL': nuevoUnionAll = UnionAll() resp = nuevoUnionAll.execute(hijo) elif hijo.nombreNodo == 'SENTENCIA_INTERSECT': nuevoIntersect = Intersect() resp = nuevoIntersect.execute(hijo) elif hijo.nombreNodo == 'SENTENCIA_EXCEPT': nuevoExcept = Except() resp = nuevoExcept.execute(hijo) elif hijo.nombreNodo == 'SENTENCIA_ASIGNACION': hijo.execute(enviroment) elif hijo.nombreNodo == 'SENTENCIA_IF': valor = hijo.execute(enviroment) if valor != None: return valor elif hijo.nombreNodo == 'SENTENCIA_RETURN': #print('Vino Return') return hijo.execute(enviroment) pass
def compile(self, enviroment): textoCompile = [] for hijo in self.hijos: if hijo.nombreNodo == 'SENTENCIA_INSERT': textoCompile += hijo.compile().splitlines() textoCompile.append("execute()") elif hijo.nombreNodo == 'SENTENCIA_UPDATE': textoCompile += hijo.compile().splitlines() textoCompile.append("execute()") elif hijo.nombreNodo == 'SENTENCIA_DELETE': textoCompile += hijo.compile().splitlines() textoCompile.append("execute()") elif hijo.nombreNodo == 'SENTENCIA_SELECT': textoCompile += hijo.compile(enviroment) textoCompile.append("execute()") elif hijo.nombreNodo == 'SENTENCIA_UNION': nuevoUnion = Union() #resp = nuevoUnion.execute(hijo) elif hijo.nombreNodo == 'SENTENCIA_UNION_ALL': nuevoUnionAll = UnionAll() #resp = nuevoUnionAll.execute(hijo) elif hijo.nombreNodo == 'SENTENCIA_INTERSECT': nuevoIntersect = Intersect() #resp = nuevoIntersect.execute(hijo) elif hijo.nombreNodo == 'SENTENCIA_EXCEPT': nuevoExcept = Except() #resp = nuevoExcept.execute(hijo) elif hijo.nombreNodo == 'SENTENCIA_ASIGNACION': textoCompile += hijo.compile(enviroment) elif hijo.nombreNodo == 'SENTENCIA_IF': textoCompile += hijo.compile(enviroment) return textoCompile
def unite(blank, tool): from Union import Union return Union(blank, tool)
def __init__(self): AlgorithmProvider.__init__(self) self._icon = QIcon(os.path.join(pluginPath, 'images', 'qgis.png')) self.alglist = [ SumLines(), PointsInPolygon(), PointsInPolygonWeighted(), PointsInPolygonUnique(), BasicStatisticsStrings(), BasicStatisticsNumbers(), NearestNeighbourAnalysis(), MeanCoords(), LinesIntersection(), UniqueValues(), PointDistance(), ReprojectLayer(), ExportGeometryInfo(), Centroids(), Delaunay(), VoronoiPolygons(), SimplifyGeometries(), DensifyGeometries(), DensifyGeometriesInterval(), MultipartToSingleparts(), SinglePartsToMultiparts(), PolygonsToLines(), LinesToPolygons(), ExtractNodes(), Eliminate(), ConvexHull(), FixedDistanceBuffer(), VariableDistanceBuffer(), Dissolve(), Difference(), Intersection(), Union(), Clip(), ExtentFromLayer(), RandomSelection(), RandomSelectionWithinSubsets(), SelectByLocation(), RandomExtract(), DeleteHoles(), RandomExtractWithinSubsets(), ExtractByLocation(), SpatialJoin(), RegularPoints(), SymmetricalDifference(), VectorSplit(), VectorGrid(), DeleteColumn(), DeleteDuplicateGeometries(), TextToFloat(), ExtractByAttribute(), SelectByAttribute(), Grid(), Gridify(), HubDistance(), HubLines(), Merge(), GeometryConvert(), AddTableField(), FieldsCalculator(), SaveSelectedFeatures(), JoinAttributes(), AutoincrementalField(), Explode(), FieldsPyculator(), EquivalentNumField(), PointsLayerFromTable(), StatisticsByCategories(), ConcaveHull(), RasterLayerStatistics(), PointsDisplacement(), ZonalStatistics(), PointsFromPolygons(), PointsFromLines(), RandomPointsExtent(), RandomPointsLayer(), RandomPointsPolygonsFixed(), RandomPointsPolygonsVariable(), RandomPointsAlongLines(), PointsToPaths(), PostGISExecuteSQL(), ImportIntoPostGIS(), SetVectorStyle(), SetRasterStyle(), SelectByExpression(), HypsometricCurves(), SplitLinesWithLines(), CreateConstantRaster(), FieldsMapper(), SelectByAttributeSum(), Datasources2Vrt(), CheckValidity(), OrientedMinimumBoundingBox(), Smooth(), ReverseLineDirection() ] if hasMatplotlib: from VectorLayerHistogram import VectorLayerHistogram from RasterLayerHistogram import RasterLayerHistogram from VectorLayerScatterplot import VectorLayerScatterplot from MeanAndStdDevPlot import MeanAndStdDevPlot from BarPlot import BarPlot from PolarPlot import PolarPlot self.alglist.extend([ VectorLayerHistogram(), RasterLayerHistogram(), VectorLayerScatterplot(), MeanAndStdDevPlot(), BarPlot(), PolarPlot(), ]) if hasShapely: from Polygonize import Polygonize self.alglist.extend([Polygonize()]) if QGis.QGIS_VERSION_INT >= 21400: from ExecuteSQL import ExecuteSQL self.alglist.extend([ExecuteSQL()]) folder = os.path.join(os.path.dirname(__file__), 'scripts') scripts = ScriptUtils.loadFromFolder(folder) for script in scripts: script.allowEdit = False self.alglist.extend(scripts) for alg in self.alglist: alg._icon = self._icon
h = 400 im = Image.new('RGBA', (w, h), (0, 0, 0, 255)) draw = ImageDraw.Draw(im) plane = Plane(Vector3(0, 1, 0), 0) plane.material = CheckerMaterial(0.1, 0.5) sphere1 = Sphere(Vector3(-10, 10, -10), 10) sphere2 = Sphere(Vector3(10, 10, -10), 10) sphere1.material = PhongMaterial(col.red, col.white, 16, 0.25) sphere2.material = PhongMaterial(col.blue, col.white, 16, 0.25) camera = PerspectiveCamera(Vector3(0, 5, 15), Vector3(0, 0, -1), Vector3(0, 1, 0), 90) sphere1.initialize() sphere2.initialize() camera.initialize() union = Union([plane, sphere1, sphere2]) for y in range(0, h): sy = 1 - y / h for x in range(0, w): sx = x / w ray = camera.generateRay(sx, sy) result = union.intersect(ray) color = rayTraceRecursive(union, ray, 3) draw.point((x, y), fill=(int(color.r * 255), int(color.g * 255), int(color.b * 255), 255)) im.show() im.save('out.png', 'png')
for i in range(numberBits): for j in range(i + 1, numberBits): candidates.append(changeBit2(bits, i, j)) return candidates #Load Data & Initialize theFile = open("clustering_big.txt", 'r') lines = theFile.readlines() theFile.close() numberNodes = int(lines[0].split()[0]) numberBits = int(lines[0].split()[1]) lines = lines[1:] nodes = [l.split() for l in lines] unionOfNodes = Union(numberNodes) #Put all nodes in a hashTable nodesHash = {} for counter, n in enumerate(nodes): #counter 0~19999 BitRep = "".join(n) if nodesHash.has_key(BitRep): #In fact,there's some node has the same bit! unionOfNodes.union_sets(counter + 1, nodesHash[BitRep]) else: nodesHash[BitRep] = counter + 1 #Go through all nodes c = 0 for bitSeq in nodesHash.keys(): c += 1 print(c)