uses modules: objFigure, [snapshots], [helpMod] For more information see figureInfo.py """ import gf import os import pprint import objFigure try: import snapshots except ImportError: snapshots=None try: import helpMod helpMod.addModule("figureinfo", module_help) helpMod.addPage("info", module_help) except ImportError: pass name=None description=None filePath=None modified=False def onNew(): if snapshots and snapshots.restoringInProgress(): return global name global description global filePath
-optional positivePoint will have positive oriented distance from the hyperplane hyperplanesOfFigure(figure) -returns list of hyperplanes containing the facets of the figure uses modules: algebra, duals, gfUtils, [helpMod] For more information see spaceCuts.py """ import algebra import duals import gfUtils try: import helpMod helpMod.addModule("spacecuts", module_help) except ImportError: pass class WrongAreaError(RuntimeError): def __init__(self): RuntimeError.__init__(self, "Inconsistent or infinite area") pass def figureFromArea(hyperplanes, innerPoint): hyppByDual = dict() dualVertsPos = [innerPoint] # to check whether innerPoint is really inner for h in hyperplanes:
.__iter__ -iterator over all-level bounding figures Vertex(position, gfIndex) -the Vertex object (subclass) .position -tuple of coordinates fromGfFigure(gfFigure) -creates Figure from gf figure toGfFigure(figure) -creates gf figure from Figure figuresIterator(figures) -returns iterator over all-level bounding figures uses modules: [helpMod] For more information see objFigure.py """ try: import helpMod helpMod.addModule("objfigure", module_help) except ImportError: pass # Iterator over the boundaries of (iterable of) figures # Only one iterator can be active at a time def figuresIterator(figures): markObj=object() for figure in figures: figure.markObj=markObj for f in figure: yield f # Takes gf.figure structure, returns set of figures
-the other arguments are optional createConvexObjFigure(vertices) -creates convex hull of the given list of vertices -returns objFigure.Figure object uses modules: objFigure, [figureInfo], [helpMod] For more information see gfUtils.py """ import gf import os try: import helpMod helpMod.addModule("gfutils", module_help) except ImportError: pass try: import figureInfo except ImportError: figureInfo=None # Opens file relatively to the currently opened one in the same folder # offset 1 means next file, offset -1 means previous file def openFileRelative(offset): import figureInfo currPath=figureInfo.getPath() currDir=None currFile=None
map(key) -maps/unmaps random rotation to key set_auto(bool_value) -enables/disables automatic rotation randomRot(allowCameraMoving) -rotation itself uses modules: [helpMod] For more information see randomRot.py """ import gf import random random.seed() try: import helpMod helpMod.addModule("randomrot", module_help) helpMod.addPage("randomrot", module_help) except ImportError: pass mappedTo = None def map(key): global mappedTo if mappedTo: gf.map(mappedTo) if key: gf.map(key, "randomRot.randomRot()") mappedTo = key
into connected (by facets) components -exclude contains facets to be ignored uses modules: algebra, objFigure, spaceCuts, [helpMod] For more information see check.py. """ import objFigure import spaceCuts import algebra import gf try: import helpMod helpMod.addModule("check", module_help) except ImportError: pass def isBoundaryConnected(figure, checkFaces=True): if not isinstance(figure, objFigure.Figure): raise TypeError("objFigure.Figure needed") if checkFaces: for face in figure: if not isBoundaryConnected(face, False): return False return True; else: if figure.dim<2: return True if len(findComponents(figure.boundary))==1:
For more information see figureInfo.py """ import gf import os import pprint import objFigure try: import snapshots except ImportError: snapshots = None try: import helpMod helpMod.addModule("figureinfo", module_help) helpMod.addPage("info", module_help) except ImportError: pass name = None description = None filePath = None modified = False def onNew(): if snapshots and snapshots.restoringInProgress(): return global name global description
-the other arguments are optional createConvexObjFigure(vertices) -creates convex hull of the given list of vertices -returns objFigure.Figure object uses modules: objFigure, [figureInfo], [helpMod] For more information see gfUtils.py """ import gf import os try: import helpMod helpMod.addModule("gfutils", module_help) except ImportError: pass try: import figureInfo except ImportError: figureInfo = None # Opens file relatively to the currently opened one in the same folder # offset 1 means next file, offset -1 means previous file def openFileRelative(offset): import figureInfo currPath = figureInfo.getPath() currDir = None
hyperplaneFromPoints(points, positivePoint) -creates Hyperplane object from points Hyperplane(normal, normalPos) -hyperplane object .normal -normal vector .normalPos -position within the normal vector .orientedDistance(point) -distance in normalized normal .inverse() -creates Hyperplane returning inverse oriented distance uses modules: [helpMod] For more information see algebra.py """ try: import helpMod helpMod.addModule("algebra", module_help) except ImportError: pass def dotProduct(vector1, vector2): return sum(map(lambda z: z[0]*z[1], zip(vector1, vector2))) def vectLen(vector): return sum(map(lambda x: x**2, vector))**0.5 def vectDiff(vector1, vector2): return tuple(map(lambda z:z[0]-z[1], zip(vector1, vector2))) def vectSum(*vectors): return tuple(map(lambda z:sum(z), zip(*vectors)))
randomRot(allowCameraMoving) -rotation itself uses modules: [helpMod] For more information see randomRot.py """ import gf import random random.seed() try: import helpMod helpMod.addModule("randomrot", module_help) helpMod.addPage("randomrot", module_help) except ImportError: pass mappedTo = None def map(key): global mappedTo if mappedTo: gf.map(mappedTo) if key: gf.map(key, "randomRot.randomRot()") mappedTo = key
rightBtnFunc -function called on right button press uses modules: [gfUtils], [helpMod], [randomRot] (deactivates auto) For more information see spaceNavigator.py """ import gf import os import struct import threading import time # gf.time can be used only in the main thread try: import helpMod helpMod.addModule("spacenavigator", module_help) helpMod.addPage("spacenavigator", module_help) except ImportError: pass device="/dev/input/spacenavigator" lock=threading.Lock() buttons=[] sensitivity=0.01 idleTime=0 axes=None try: import gfUtils def leftBtnFunc(): gfUtils.openFileRelative(-1) def rightBtnFunc():
-optional positivePoint will have positive oriented distance from the hyperplane hyperplanesOfFigure(figure) -returns list of hyperplanes containing the facets of the figure uses modules: algebra, duals, gfUtils, [helpMod] For more information see spaceCuts.py """ import algebra import duals import gfUtils try: import helpMod helpMod.addModule("spacecuts", module_help) except ImportError: pass class WrongAreaError(RuntimeError): def __init__(self): RuntimeError.__init__(self, "Inconsistent or infinite area") pass def figureFromArea(hyperplanes, innerPoint): hyppByDual=dict() dualVertsPos=[innerPoint] # to check whether innerPoint is really inner for h in hyperplanes: dualPoint=duals.dualPointFromHyperplane(h, innerPoint) hyppByDual[dualPoint]=h dualVertsPos.append(dualPoint)
For more information see duals.py """ import objFigure from objFigure import Figure, Vertex import gf from operator import attrgetter import algebra import check try: import figureInfo except ImportError: figureInfo=None try: import helpMod helpMod.addModule("duals", module_help) helpMod.addPage("create dual", module_help) except ImportError: pass def dualPointFromHyperplane(hyperplane, centerPoint=None): if not centerPoint: centerPoint=(0,)*len(hyperplane.normal) dist=hyperplane.orientedDistance(centerPoint) if abs(dist) < 0.0001: raise RuntimeError("Hyperplane passing through the center") return algebra.vectSum(algebra.vectMult(-1/dist, hyperplane.normal), centerPoint) def createDual(figure, centerPoint=None): if figure.dim<2: raise RuntimeError("Figure has to have at least 2 dimensions")
hyperplaneFromPoints(points, positivePoint) -creates Hyperplane object from points Hyperplane(normal, normalPos) -hyperplane object .normal -normal vector .normalPos -position within the normal vector .orientedDistance(point) -distance in normalized normal .inverse() -creates Hyperplane returning inverse oriented distance uses modules: [helpMod] For more information see algebra.py """ try: import helpMod helpMod.addModule("algebra", module_help) except ImportError: pass def dotProduct(vector1, vector2): return sum(map(lambda z: z[0] * z[1], zip(vector1, vector2))) def vectLen(vector): return sum(map(lambda x: x**2, vector))**0.5 def vectDiff(vector1, vector2): return tuple(map(lambda z: z[0] - z[1], zip(vector1, vector2)))
isFigureClosed(figure) isFigureConvex(figure) uses modules: algebra, objFigure, spaceCuts, [helpMod] For more information see check.py. """ import objFigure import spaceCuts import algebra import gf try: import helpMod helpMod.addModule("check", module_help) except ImportError: pass def isFigureClosed(figure, checkFaces=True): if not isinstance(figure, objFigure.Figure): raise TypeError("objFigure.Figure needed") if checkFaces: for face in figure: if not isFigureClosed(face, False): return False return True; else: openEdges=set() closedEdges=set() for facet in figure.boundary:
- (un)registers callback function func(oldSnapshotIndex), to be called on restore - oldSnapshotIndex is valid only within the call of func, it can change setClearableProperty(name, clearable=True) - clearable property is set to None after every snapshot, the others are always inherited set_maxcount(count) get_maxcount() - gets/sets the maximum number of snapshots uses modules: [helpMod] For more information see snapshots.py """ try: import helpMod helpMod.addModule("snapshots", module_help) helpMod.addPage("undo", module_help) helpMod.addPage("redo", module_help) helpMod.addPage("snapshots", module_help) except ImportError: pass import gf from time import time snapshots = [dict()] currentIndex = 0 currentState = dict() restoreCallbacks = set() createCallbacks = set() uncommittedChanges = False
uses modules: algebra, objFigure, spaceCuts, [figureInfo], [helpMod] For more information see stellation.py """ import spaceCuts import algebra import objFigure from operator import attrgetter import gf try: import figureInfo except ImportError: figureInfo=None try: import helpMod helpMod.addModule("stellation", module_help) helpMod.addPage("stellate", module_help) except ImportError: pass def stellateFigure(figure): objFigure.updateVerticesLists(figure) objFigure.updateParentsLists(figure) innerPoint=algebra.vectAvg(*[v.position for v in figure.vertices]) for f in figure.boundary: f.hyperplane=spaceCuts.hyperplaneOfFacet(f, innerPoint); f.hyperplane.origFacet=f newFacets=[] for f in figure.boundary:
rightBtnFunc -function called on right button press uses modules: [gfUtils], [helpMod], [randomRot] (deactivates auto) For more information see spaceNavigator.py """ import gf import os import struct import threading import time # gf.time can be used only in the main thread try: import helpMod helpMod.addModule("spacenavigator", module_help) helpMod.addPage("spacenavigator", module_help) except ImportError: pass device = "/dev/input/spacenavigator" lock = threading.Lock() buttons = [] sensitivity = 0.01 idleTime = 0 axes = None try: import gfUtils def leftBtnFunc(): gfUtils.openFileRelative(-1)
import objFigure from objFigure import Figure, Vertex, figuresIterator; import algebra from algebra import Hyperplane; import gf import spaceCuts import check try: import figureInfo except ImportError: figureInfo=None try: import helpMod helpMod.addModule("cuts", module_help) helpMod.addPage("cut", module_help) except ImportError: pass # Cuts Figure object with given Hyperplane, # returns ([Figure negative_parts], [Figure section_parts], [Figure positive_parts]) def cutFigure(wholeFigure, hyperplane): facesAscending=[] queue=[wholeFigure] mark=object() while queue: figure=queue.pop(0) if figure.mark==mark: continue figure.mark=mark
- (un)registers callback function func(oldSnapshotIndex), to be called on restore - oldSnapshotIndex is valid only within the call of func, it can change setClearableProperty(name, clearable=True) - clearable property is set to None after every snapshot, the others are always inherited set_maxcount(count) get_maxcount() - gets/sets the maximum number of snapshots uses modules: [helpMod] For more information see snapshots.py """ try: import helpMod helpMod.addModule("snapshots", module_help) helpMod.addPage("undo", module_help) helpMod.addPage("redo", module_help) helpMod.addPage("snapshots", module_help) except ImportError: pass import gf from time import time snapshots=[dict()] currentIndex=0 currentState=dict() restoreCallbacks=set() createCallbacks=set() uncommittedChanges=False