def projectVsTo3D(this, Vs4D): """ returns an array of 3D vertices. """ # print "projectTo3D_getVs" Vs3D = [] for v in Vs4D: wV = v[3] # print "mapping v:", v if not Geom3D.eq(this.wCamera, wV): scale = this.wCameraDistance / (this.wCamera - wV) Vs3D.append([scale * v[0], scale * v[1], scale * v[2]]) else: Vs3D.append([1e256, 1e256, 1e256]) return Vs3D
def printTrisAngles(this): # TODO: fix this function. Which angles to take (ie which faces) depends # on the triangle alternative. tris = this.triFs[this.edgeAlternative] # for non 1 loose # for i in range(0, len(tris) - 2, 2): d = 2 # for 1 loose: d = 1 for i in range(2): norm0 = Geom3D.Triangle( this.baseShape.Vs[tris[i][0]], this.baseShape.Vs[tris[i][1]], this.baseShape.Vs[tris[i][2]], ).normal(True) print 'norm0 %d: ', norm0 norm1 = Geom3D.Triangle( this.baseShape.Vs[tris[i + d][0]], this.baseShape.Vs[tris[i + d][1]], this.baseShape.Vs[tris[i + d][2]], ).normal(True) print 'norm1 %d: ', norm1 inprod = norm0 * norm1 print 'Tris angle %d: %.6f degrees' % (i, math.acos(inprod) * Geom3D.Rad2Deg) print '------------' # TODO move out
def __init__(this, *args, **kwargs): heptagonsShape = Geom3D.IsometricShape(Vs=[], Fs=[], directIsometries=isometry.A4(), name='FoldedHeptagonsA4') xtraTrisShape = Geom3D.IsometricShape(Vs=[], Fs=[], directIsometries=isometry.A4(), name='xtraTrisA4') trisO3Shape = Geom3D.IsometricShape(Vs=[], Fs=[], directIsometries=isomsO3, colors=[([rgb.cyan[:]], [])], name='o3TrisA4') Heptagons.FldHeptagonShape.__init__( this, [heptagonsShape, xtraTrisShape, trisO3Shape], 3, 3, name='FoldedRegHeptA4') this.heptagonsShape = heptagonsShape this.xtraTrisShape = xtraTrisShape this.trisO3Shape = trisO3Shape this.posAngleMin = -math.pi this.posAngleMax = math.pi this.posAngle = 0 this.setEdgeAlternative(trisAlt.strip_1_loose, trisAlt.strip_1_loose) this.initArrs() this.setV()
def __init__(this, Vs, Cs, Es=[], Ns=[], colors=([], []), name="4DSimpleShape"): """ Cs: and array of cells, consisting of an array of Fs. """ if this.dbgTrace: print '%s.SimpleShape.__init__(%s,..):' % (this.__class__name) this.dimension = 4 this.generateNormals = False this.v = Geom3D.Fields() this.e = Geom3D.Fields() this.f = Geom3D.Fields() this.c = Geom3D.Fields() # SETTINGS similar to Geom3D.SimpleShape: #print 'SimpleShape.Fs', Fs this.name = name if colors[0] == []: colors = ([rgb.gray95[:]], []) # if this.mapToSingeShape = False each cell is mapped to one 3D shape # and the edges are mapped to one shape as well. The disadvantage is # that for each shape glVertexPointer is set, while if # this.mapToSingeShape = True is set to True one vertex array is used. this.mapToSingeShape = True # if useTransparency = False opaque colours are used, even if they # specifically set to transparent colours. this.useTransparency(True) this.setVertexProperties(Vs=Vs, Ns=Ns, radius=-1., color=[1., 1., .8]) this.setFaceProperties(colors=colors, drawFaces=True) this.glInitialised = False # SETTINGS 4D specific: this.setCellProperties(Cs=Cs, colors=colors, drawCells=False, scale=1.0) # For initialisation setCellProperties needs to be called before # setEdgeProperties, since the latter will check the scale value this.setEdgeProperties(Es=Es, radius=-1., color=[0.1, 0.1, 0.1], drawEdges=True, showUnscaled=True) this.setProjectionProperties(11.0, 10.0) # expresses whether the 4D coordinates need to be updated: this.rot4 = None this.projectedTo3D = False if this.dbgPrn: print '%s.__init__(%s,..)' % (this.__class__, this.name) print 'this.colorData:' for i in range(len(this.colorData[0])): print('%d.' % i), this.colorData[0][i] if len(this.colorData[0]) > 1: assert this.colorData[0][1] != [0] print this.colorData[1]
def glDrawSplit(this): if not this.projectedTo3D: try: del this.cells except AttributeError: pass Ns3D = [] if this.rot4 != None: Vs4D = [this.rot4 * v for v in this.Vs] # TODO fix Ns.. if needed.. # if this.Ns != []: # Ns4D = [this.rot4*n for n in this.Ns] else: Vs4D = [v for v in this.Vs] Vs3D = this.projectVsTo3D(Vs4D) #if this.Ns != []: # Ns3D = this.projectVsTo3D(Ns4D) this.cells = [] # Add a cell for just the edges: if this.e.draw: cell = Geom3D.SimpleShape( Vs3D, [], this.Es, [], # Vs , Fs, Es, Ns name='%s_Es' % (this.name)) cell.setVertexProperties(radius=this.v.radius, color=this.v.col) cell.setEdgeProperties(radius=this.e.radius, color=this.e.col, drawEdges=this.e.draw) cell.setFaceProperties(drawFaces=False) cell.glInitialised = True this.cells.append(cell) # Add a shape with faces for each cell for i in xrange(len(this.Cs)): if this.c.draw: colors = (this.c.col[0][this.c.col[1][i]], []) else: colors = (this.f.col[0], this.f.col[1][i]) #print colors cell = Geom3D.SimpleShape( Vs3D, this.Cs[i], [], [], # Vs , Fs, Es, Ns colors, name='%s_%d' % (this.name, i)) # The edges and vertices are drawn through a separate shape below. cell.setVertexProperties(radius=-1) cell.setEdgeProperties(drawEdges=False) cell.setFaceProperties(drawFace=this.f.draw) cell.scale(this.c.scale) cell.glInitialised = True this.cells.append(cell) this.projectedTo3D = True
def __init__(this, *args, **kwargs): heptagonsShape = Geom3D.IsometricShape(Vs=[], Fs=[], directIsometries=isomA5, name='FoldedHeptagonsA5', recreateEdges=False) xtraTrisShape = Geom3D.IsometricShape(Vs=[], Fs=[], directIsometries=isomA5, name='xtraTrisA5', recreateEdges=False) trisO3Shape = Geom3D.SymmetricShape(Vs=[], Fs=[], finalSym=isomA5, stabSym=isomO3, colors=[([rgb.cyan[:]], [])], name='o3TrisA5', recreateEdges=False) trisO5Shape = Geom3D.SymmetricShape(Vs=[], Fs=[], finalSym=isomA5, stabSym=isomO5, colors=[([rgb.cyan[:]], [])], name='o5PentasA5', recreateEdges=False) Heptagons.FldHeptagonShape.__init__( this, [heptagonsShape, xtraTrisShape, trisO3Shape, trisO5Shape], 5, 3, name='FoldedRegHeptA5xI') this.heptagonsShape = heptagonsShape this.xtraTrisShape = xtraTrisShape this.trisO3Shape = trisO3Shape this.trisO5Shape = trisO5Shape this.posAngleMin = -math.pi / 2 this.posAngleMax = math.pi / 2 this.height = 2.7 this.dihedralAngle = Geom3D.Deg2Rad * 119 this.initArrs() this.setTriangleFillPosition(0) this.setEdgeAlternative(trisAlt.strip_II, trisAlt.strip_II) this.setV()
def __init__(this, *args, **kwargs): heptagonsShape = Geom3D.IsometricShape( Vs = [], Fs = [], directIsometries = isomS4, name = 'FoldedHeptagonsS4', recreateEdges = False ) xtraTrisShape = Geom3D.IsometricShape( Vs = [], Fs = [], directIsometries = isomS4, name = 'xtraTrisS4', recreateEdges = False ) trisO3Shape = Geom3D.SymmetricShape( Vs = [], Fs = [], finalSym = isomS4, stabSym = isomO3, colors = [([rgb.cyan[:]], [])], name = 'o3TrisS4', recreateEdges = False ) trisO4Shape = Geom3D.SymmetricShape( Vs = [], Fs = [], finalSym = isomS4, stabSym = isomO4, colors = [([rgb.cyan[:]], [])], name = 'o4SquareS4', recreateEdges = False ) Heptagons.FldHeptagonShape.__init__(this, [heptagonsShape, xtraTrisShape, trisO3Shape, trisO4Shape], 4, 3, name = 'FoldedRegHeptS4xI' ) this.heptagonsShape = heptagonsShape this.xtraTrisShape = xtraTrisShape this.trisO3Shape = trisO3Shape this.trisO4Shape = trisO4Shape this.posAngleMin = -pos_angle_refl_2 this.posAngleMax = pos_angle_refl_2 this.height = 3.9 this.setEdgeAlternative(trisAlt.strip_1_loose, trisAlt.strip_1_loose) this.initArrs() this.setV()
def onApplySymmetry(this, e): print this.GetSize() Vs = this.showGui[this.__VsGuiIndex].get() Fs = this.showGui[this.__FsGuiIndex].get() if Fs == []: this.statusText('No faces defined!', LOG_ERR) return finalSymGui = this.showGui[this.__FinalSymGuiIndex] finalSym = finalSymGui.GetSelected() finalSymIndex = finalSymGui.getSelectedIndex() stabSymGui = this.showGui[this.__StabSymGuiIndex] stabSym = stabSymGui.GetSelected() stabSymIndex = stabSymGui.getSelectedIndex() this.finalSymSetup[finalSymIndex] = finalSym.setup # copy? this.stabSymSetup[finalSymIndex][stabSymIndex] = stabSym.setup # copy? try: this.shape = Geom3D.SymmetricShape(Vs, Fs, finalSym=finalSym, stabSym=stabSym, name=this.name) except isometry.ImproperSubgroupError: this.statusText('Stabiliser not a subgroup of final symmetry!', LOG_ERR) if e != None: e.Skip() return this.FsOrbit = this.shape.getIsometries()['direct'] this.FsOrbitOrg = True this.shape.recreateEdges() this.updateOrientation() this.canvas.panel.setShape(this.shape) updated0 = this.showGui[this.__FinalSymGuiIndex].isSymClassUpdated() updated1 = this.showGui[this.__StabSymGuiIndex].isSymClassUpdated() # Note the functions above need to be called to update the latest # status. I.e. don't call them in the or below, because the second will # not be called if the first is true. if (updated0 or updated1): this.addColourGui() else: this.onNrColsSel(this.colGuis[this.__nrOfColsGuiId]) this.panel.Layout() this.statusText('Symmetry applied: choose colours!', LOG_INFO) try: tst = this.cols except AttributeError: this.cols = [(255, 100, 0)] if e != None: e.Skip()
def projectVsTo3D(this, Vs4D): """ returns an array of 3D vertices. """ #print "projectTo3D_getVs" Vs3D = [] for v in Vs4D: wV = v[3] #print "mapping v:", v if not Geom3D.eq(this.wCamera, wV): scale = this.wCameraDistance / (this.wCamera - wV) Vs3D.append([scale * v[0], scale * v[1], scale * v[2]]) else: Vs3D.append([1e256, 1e256, 1e256]) return Vs3D
def testOrthogonalVectors(R, margin=Geom3D.defaultFloatMargin): if not Geom3D.eq(R.e0 * R.e1, 0.0, margin): printError("in function _setOrthoMatrix: e0.e1 = ", R.e0 * R.e1, "!= 0") if not Geom3D.eq(R.e0 * R.e2, 0.0, margin): printError("in function _setOrthoMatrix: e0.e2 = ", R.e0 * R.e2, "!= 0") if not Geom3D.eq(R.e0 * R.e3, 0.0, margin): printError("in function _setOrthoMatrix: e0.e3 = ", R.e0 * R.e3, "!= 0") if not Geom3D.eq(R.e1 * R.e2, 0.0, margin): printError("in function _setOrthoMatrix: e1.e2 = ", R.e1 * R.e2, "!= 0") if not Geom3D.eq(R.e1 * R.e3, 0.0, margin): printError("in function _setOrthoMatrix: e1.e3 = ", R.e1 * R.e3, "!= 0") if not Geom3D.eq(R.e2 * R.e3, 0.0, margin): printError("in function _setOrthoMatrix: e2.e3 = ", R.e2 * R.e3, "!= 0") print "-----resulting matrix-----" print R.getMatrix() print "--------------------------"
def testOrthogonalVectors(R, margin=Geom3D.defaultFloatMargin): if not Geom3D.eq(R.e0 * R.e1, 0.0, margin): printError('in function _setOrthoMatrix: e0.e1 = ', R.e0 * R.e1, '!= 0') if not Geom3D.eq(R.e0 * R.e2, 0.0, margin): printError('in function _setOrthoMatrix: e0.e2 = ', R.e0 * R.e2, '!= 0') if not Geom3D.eq(R.e0 * R.e3, 0.0, margin): printError('in function _setOrthoMatrix: e0.e3 = ', R.e0 * R.e3, '!= 0') if not Geom3D.eq(R.e1 * R.e2, 0.0, margin): printError('in function _setOrthoMatrix: e1.e2 = ', R.e1 * R.e2, '!= 0') if not Geom3D.eq(R.e1 * R.e3, 0.0, margin): printError('in function _setOrthoMatrix: e1.e3 = ', R.e1 * R.e3, '!= 0') if not Geom3D.eq(R.e2 * R.e3, 0.0, margin): printError('in function _setOrthoMatrix: e2.e3 = ', R.e2 * R.e3, '!= 0') print '-----resulting matrix-----' print R.getMatrix() print '--------------------------'
shape = Geom3D.CompoundShape(simpleShapes=[ Geom3D.SimpleShape(Vs=[ GeomTypes.Vec3([1.0, 1.0, 1.0]), GeomTypes.Vec3([-1.0, 1.0, 1.0]), GeomTypes.Vec3([-1.0, -1.0, 1.0]), GeomTypes.Vec3([1.0, -1.0, 1.0]), GeomTypes.Vec3([1.0, 1.0, -1.0]), GeomTypes.Vec3([-1.0, 1.0, -1.0]), GeomTypes.Vec3([-1.0, -1.0, -1.0]), GeomTypes.Vec3([1.0, -1.0, -1.0]), GeomTypes.Vec3([1.0, 1.0, -2.0]), GeomTypes.Vec3([0.5, 1.0, 1.0]) ], Fs=[[0, 1, 2, 3], [0, 3, 7, 4], [1, 0, 4, 5], [2, 1, 5, 6], [3, 2, 6, 7], [7, 6, 5, 4]], Es=[], colors=([[0.99609400000000003, 0.0, 0.0]], [0, 0, 0, 0, 0, 0]), name="SimpleShape"), Geom3D.SimpleShape(Vs=[ GeomTypes.Vec3([0.0, 0.0, 2.0]), GeomTypes.Vec3([2.0, 0.0, 0.0]), GeomTypes.Vec3([0.0, 2.0, 0.0]), GeomTypes.Vec3([-2.0, 0.0, 0.0]), GeomTypes.Vec3([0.0, -2.0, 0.0]), GeomTypes.Vec3([0.0, 0.0, 2.0]) ], Fs=[[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1], [5, 2, 1], [5, 3, 2], [5, 4, 3], [5, 1, 4]], Es=[], colors=([[0.99609400000000003, 0.0, 0.0]], [0, 0, 0, 0, 0, 0, 0, 0]), name="SimpleShape") ], name="CompoundShape")
def setV(this): # input this.h St = this.h / (4 - tau2 - (4 * this.h / tau2)) # z # ^ # | # ---> y # / # V_ # x # 2 # __..--'-_ # 1 -'' . _"- 3 # \ _-' # \ _-' # \-' # 0 # # The kite above is a 5th of the top face of dodecahedron # standing on 1 face, 2 is a vertex, 1 and 3, centres of two edges # and 0 a face centre. # Vs = [ vec(0.0, 0.0, this.h), # 0 vec(-tau2/2, -w, tau2), vec(2.0*St, 0.0, -tau2*St), vec(-tau2/2, w, tau2) # 3 ] # add heptagons Ns = Vs if this.heptPosAlt: heptN = Heptagons.Kite2Hept(Vs[3], Vs[0], Vs[1], Vs[2]) if heptN == None: return Mr = Rot(angle = GeomTypes.tTurn, axis = Vs[2]) v = Mr*heptN[0][4] if this.triangleAlt: vt = heptN[0][6] xtraEdgeIndex = 15 else: vt = heptN[0][5] xtraEdgeIndex = 14 #print v # One third of regular triangle. RegularTrianglePartV = [ heptN[0][3], heptN[0][4], vec(v[0], v[1], v[2]), ] # vt is the vertex that will be projected by a half turn on the # third vertex of the isosceles triangle. IsoscelesTriangleV = [ heptN[0][5], heptN[0][6], vt ] else: heptN = Heptagons.Kite2Hept(Vs[1], Vs[2], Vs[3], Vs[0]) if heptN == None: return if this.triangleAlt: vt = heptN[0][1] xtraEdgeIndex = 14 else: vt = heptN[0][2] xtraEdgeIndex = 15 # One third of regular pentagon. RegularTrianglePartV = [ heptN[0][3], heptN[0][4], vec(0, 0, heptN[0][3][2]), ] # vt is the vertex that will be projected by a half turn on the # third vertex of the isosceles triangle. IsoscelesTriangleV = [ heptN[0][1], heptN[0][2], vt ] if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return else: this.errorStr = '' H = HalfTurn(Vs[3]) vt = H * vt IsoscelesTriangleV[2] = vt Vs.extend(heptN[0]) # V4 - V10 Vs.extend(RegularTrianglePartV) # V11 - V13 Vs.extend(IsoscelesTriangleV) # V14 - V16 #for V in Vs: print V Ns = [heptN[1] for i in range(11)] RegularTrianglePartN = RegularTrianglePartV[2] Ns.extend([RegularTrianglePartN for i in range(3)]) IsoscelesTriangleN = Geom3D.Triangle( IsoscelesTriangleV[0], IsoscelesTriangleV[1], IsoscelesTriangleV[2] ).normal() Ns.extend([IsoscelesTriangleN for i in range(3)]) this.xtraEs = [] if this.addXtraEdge: this.xtraEs = [xtraEdgeIndex, 16] #this.showBaseOnly = True this.setBaseVertexProperties(Vs = Vs, Ns = Ns) Fs = [] Es = [] colIds = [] if this.showKite: Fs.extend(this.kiteFs) Es.extend(this.kiteEs) colIds.extend(this.kiteColIds) if this.showHepta: Fs.extend(this.heptFs) Es.extend(this.heptEs) colIds.extend(this.heptColIds) if this.showXtra: Fs.extend(this.xtraFs) Es.extend(this.xtraEs) colIds.extend(this.xtraColIds) this.setBaseEdgeProperties(Es = Es) this.setBaseFaceProperties(Fs = Fs, colors = (this.theColors, colIds)) this.Vs = Vs
shape = Geom3D.IsometricShape( Vs=[ GeomTypes.Vec3([1.0, 1.0, 1.0]), GeomTypes.Vec3([-1.0, 1.0, 1.0]), GeomTypes.Vec3([-1.0, -1.0, 1.0]), GeomTypes.Vec3([1.0, -1.0, 1.0]), GeomTypes.Vec3([1.0, 1.0, -1.0]), GeomTypes.Vec3([-1.0, 1.0, -1.0]), GeomTypes.Vec3([-1.0, -1.0, -1.0]), GeomTypes.Vec3([1.0, -1.0, -1.0]), ], Fs=[ [0, 1, 2, 3], [0, 3, 7, 4], [1, 0, 4, 5], [2, 1, 5, 6], [3, 2, 6, 7], [7, 6, 5, 4], ], Es=[ 0, 1, 1, 2, 2, 3, 0, 3, 3, 7, 4, 7, 0, 4, 4, 5, 1, 5, 5, 6, 2, 6, 6, 7 ], colors=[ ([[0.99609400000000003, 0.83984400000000003, 0.0]], []), ([[0.13281200000000001, 0.54296900000000003, 0.13281200000000001]], []), ([[0.54296900000000003, 0.0, 0.0]], []), ([[0.0, 0.74609400000000003, 0.99609400000000003]], []), ([[0.54296900000000003, 0.52343799999999996, 0.30468800000000001]], []), ], directIsometries=[ GeomTypes.Rot3( (GeomTypes.Quat( [-0.809016994375, -0.5, 0.309016994375, -3.08426926158e-14]), GeomTypes.Quat( [-0.809016994375, 0.5, -0.309016994375, 3.08426926158e-14]))), GeomTypes.Rot3( (GeomTypes.Quat( [0.809016994375, -0.309016994375, -4.98739097981e-14, -0.5]), GeomTypes.Quat( [0.809016994375, 0.309016994375, 4.98739097981e-14, 0.5]))), GeomTypes.Rot3( (GeomTypes.Quat([0.5, 0.5, -0.5, -0.5]), GeomTypes.Quat([0.5, -0.5, 0.5, 0.5]))), GeomTypes.Rot3( (GeomTypes.Quat( [0.5, -4.53526105559e-14, -0.309016994375, 0.809016994375]), GeomTypes.Quat( [0.5, 4.53526105559e-14, 0.309016994375, -0.809016994375]))), GeomTypes.Rot3( (GeomTypes.Quat( [4.582785177e-15, -0.5, 0.809016994375, 0.309016994375]), GeomTypes.Quat( [4.582785177e-15, 0.5, -0.809016994375, -0.309016994375]))), ], unfoldOrbit=False, name="5cubes.py", orientation=GeomTypes.Rot3( (GeomTypes.Quat([1.0, 0.0, 0.0, 0.0]), GeomTypes.Quat([1.0, -0.0, -0.0, -0.0]))))
import GeomTypes import Geom3D import isometry shape = Geom3D.SimpleShape(Vs=[ GeomTypes.Vec3([1.0, 1.0, 1.0]), GeomTypes.Vec3([-1.0, 1.0, 1.0]), GeomTypes.Vec3([-1.0, -1.0, 1.0]), GeomTypes.Vec3([1.0, -1.0, 1.0]), GeomTypes.Vec3([1.0, 1.0, -1.0]), GeomTypes.Vec3([-1.0, 1.0, -1.0]), GeomTypes.Vec3([-1.0, -1.0, -1.0]), GeomTypes.Vec3([1.0, -1.0, -1.0]), GeomTypes.Vec3([1.0, 1.0, -2.0]), GeomTypes.Vec3([0.5, 1.0, 1.0]) ], Fs=[[0, 4, 8], [0, 9, 1, 2, 3], [0, 3, 7, 4], [1, 0, 4, 5], [2, 1, 5, 6], [3, 2, 6, 7], [7, 6, 5, 4]], Es=[], colors=([[0.99609400000000003, 0.0, 0.0]], [0, 0, 0, 0, 0, 0, 0]), name="SimpleShape")
def onImport(this, e): wildcard = "OFF shape (*.off)|*.off|Python shape (*.py)|*.py" dlg = wx.FileDialog(this, 'New: Choose a file', this.importDirName, '', wildcard, wx.OPEN) if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetFilename() this.importDirName = dlg.GetDirectory() print "opening file:", filename fd = open(os.path.join(this.importDirName, filename), 'r') if filename[-3:] == '.py': shape = Geom3D.readPyFile(fd) # For Compound derived shapes (isinstance) use merge: try: shape = shape.SimpleShape except AttributeError: # probably a SimpleShape pass else: shape = Geom3D.readOffFile(fd, recreateEdges=False) fd.close() if isinstance(shape, Geom3D.IsometricShape): Vs = shape.baseShape.Vs Fs = shape.baseShape.Fs else: #print 'no isometry' Vs = shape.Vs Fs = shape.Fs print 'read ', len(Vs), ' Vs and ', len(Fs), ' Fs.' this.showGui[this.__VsGuiIndex].set(Vs) this.showGui[this.__FsGuiIndex].set(Fs) # With a python file it is possible to set the other properties as # well: e.g. # finalSym = isometry.S4xI # finalSymSetup = [ [1, 0, 0], [0, 0, 1] ] # stabSym = isometry.C3xI # stabSymSetup = [ [0, 0, 1] ] # rotAxis = [1, 1, 1] # rotAngle = 30 # where the angle is in degrees (floating point) if filename[-3:] == '.py': fd = open(os.path.join(this.importDirName, filename), 'r') ed = {'__name__': 'readPyFile'} exec fd in ed moreSettings = 0 keyErrStr = 'Note: KeyError while looking for' key = 'finalSym' # to prevent accepting keyErrors in other code than ed[key]: keyDefined = False try: finalSym = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.showGui[this.__FinalSymGuiIndex].SetSelectedClass( finalSym) this.showGui[this.__FinalSymGuiIndex].onSetSymmetry(None) key = 'finalSymSetup' keyDefined = False try: symSetup = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.showGui[this.__FinalSymGuiIndex].SetupSymmetry( symSetup) key = 'stabSym' keyDefined = False try: stabSym = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.showGui[this.__StabSymGuiIndex].SetSelectedClass( stabSym) this.showGui[this.__StabSymGuiIndex].onSetSymmetry(None) key = 'stabSymSetup' keyDefined = False try: symSetup = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.showGui[this.__StabSymGuiIndex].SetupSymmetry( symSetup) if moreSettings > 0: this.onApplySymmetry(None) key = 'rotAxis' keyDefined = False try: axis = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.showGui[this.__AxisGuiIndex].SetVertex(axis) key = 'rotAngle' keyDefined = False try: angle = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.showGui[this.__SlideAngleGuiIndex].SetValue(angle) this.showGui[this.__DirAngleGuiIndex].SetValue(angle) this.currentAngle = angle this.onSharedAngleAdjust(None) fd.close() this.name = filename dlg.Destroy()
import Geom3D import GeomTypes import math Vs = [ GeomTypes.Vec3([ 1, 1, 1]), GeomTypes.Vec3([-1, 1, 1]), GeomTypes.Vec3([-1, -1, 1]), GeomTypes.Vec3([ 1, -1, 1]), GeomTypes.Vec3([ 1, 1, -1]), GeomTypes.Vec3([-1, 1, -1]), GeomTypes.Vec3([-1, -1, -1]), GeomTypes.Vec3([ 1, -1, -1]), GeomTypes.Vec3([ 1, 1, -2]), GeomTypes.Vec3([.5, 1, 1]), ] Fs = [ [0, 4, 8], # just a line [0, 9, 1, 2, 3],# first part on line, cannot be used to calc face normal [0, 3, 7, 4], [1, 0, 4, 5], [2, 1, 5, 6], [3, 2, 6, 7], [7, 6, 5, 4] ] shape = Geom3D.SimpleShape(Vs = Vs, Fs = Fs)
def onNrColsSel(this, e): try: this.selColSizer.Clear(True) except AttributeError: this.selColSizer = wx.BoxSizer(wx.VERTICAL) this.colSizer.Add(this.selColSizer, 0, wx.EXPAND) nextPrevColSizer = wx.BoxSizer(wx.HORIZONTAL) this.colGuis.append( wx.Button(this.panel, wx.ID_ANY, "Previous Alternative")) this.panel.Bind(wx.EVT_BUTTON, this.onPrevColAlt, id=this.colGuis[-1].GetId()) nextPrevColSizer.Add(this.colGuis[-1], 0, wx.EXPAND) this.colGuis.append( wx.Button(this.panel, wx.ID_ANY, "Next Alternative")) this.panel.Bind(wx.EVT_BUTTON, this.onNextColAlt, id=this.colGuis[-1].GetId()) nextPrevColSizer.Add(this.colGuis[-1], 0, wx.EXPAND) nextPrevColSizer.Add(wx.BoxSizer(wx.HORIZONTAL), 1, wx.EXPAND) this.colGuis.append( wx.Button(this.panel, wx.ID_ANY, "Reset Colours")) this.panel.Bind(wx.EVT_BUTTON, this.onResetCols, id=this.colGuis[-1].GetId()) nextPrevColSizer.Add(this.colGuis[-1], 0, wx.EXPAND) this.colSizer.Add(nextPrevColSizer, 0, wx.EXPAND) colDivNr = e.GetSelection() this.colAlternative[0] = colDivNr l0 = len(this.orbit.higherOrderStabiliserProps) if colDivNr < l0: this.colFinalSym = this.orbit.final this.colIsoms = this.orbit.higherOrderStabiliser(colDivNr) nrOfCols = this.orbit.higherOrderStabiliserProps[colDivNr]['index'] else: this.colFinalSym = this.orbit.altFinal this.colIsoms = this.orbit.lowerOrderStabiliser(colDivNr - l0) nrOfCols = this.orbit.lowerOrderStabiliserProps[colDivNr - l0]['index'] # now the FsOrbit might contain isometries that are not part of the # colouring isometries. Recreate the shape with isometries that only # have these: if this.FsOrbitOrg: finalSym = this.orbit.altFinal stabSym = this.orbit.altStab Vs = this.shape.getBaseVertexProperties()['Vs'] Fs = this.shape.getBaseFaceProperties()['Fs'] this.shape = Geom3D.SymmetricShape(Vs, Fs, finalSym=finalSym, stabSym=stabSym, name=this.name) this.FsOrbit = this.shape.getIsometries()['direct'] this.shape.recreateEdges() this.canvas.panel.setShape(this.shape) this.FsOrbitOrg = False # and do this only once assert len(this.colIsoms) != 0 this.selColGuis = [] initColour = (255, 255, 255) maxColPerRow = 12 # Add buttons for choosing individual colours: for i in range(nrOfCols): try: col = this.cols[i] except IndexError: col = initColour this.cols.append(col) if i % maxColPerRow == 0: selColSizerRow = wx.BoxSizer(wx.HORIZONTAL) this.selColSizer.Add(selColSizerRow, 0, wx.EXPAND) this.selColGuis.append( wxLibCS.ColourSelect(this.panel, wx.ID_ANY, colour=col)) this.panel.Bind(wxLibCS.EVT_COLOURSELECT, this.onColSel) selColSizerRow.Add(this.selColGuis[-1], 0, wx.EXPAND) this.nrOfCols = nrOfCols # replace invalid index of colour alternative with the last possible if this.colAlternative[1] >= len(this.colIsoms): this.colAlternative[1] = len(this.colIsoms) - 1 this.updatShapeColours() this.panel.Layout()
def setV(this): # input this.h St = this.h / (2*this.h - 1) if this.heptPosAlt: # # z # ^ # | # ---> y # / # V_ # x # # .------------. # ,' 2 _____1,'| # ,' ,' ,'11| # .-----3.----0' | | # | 5| 4|8 | | # | | | ,' | # | +-----+' 10- # | 6 7|9 ,' # | |,' # '------------' # Vs = [ vec(St, St, St), # 0 vec(0.0, 1.0, 1.0), vec(0.0, 0.0, this.h), vec(1.0, 0.0, 1.0), # 3 vec(St, St, St), # 4 vec(1.0, 0.0, 1.0), vec(this.h, 0.0, 0.0), vec(1.0, 1.0, 0.0), # 7 vec(St, St, St), # 8 vec(1.0, 1.0, 0.0), vec(0.0, this.h, 0.0), vec(0.0, 1.0, 1.0) # 11 ] else: # # z # ^ # | # ---> y # / # V_ # x # # .------------. # ,' 0 _____3,'| # ,' ,' ,'|9| # .-----1.----2' | | # | 7| 6|10| | # | | | ,' | # | +-----+' 8 - # | 4 5|11,' # | |,' # '------------' # Vs = [ vec(0.0, 0.0, this.h), # 0 vec(1.0, 0.0, 1.0), vec(St, St, St), vec(0.0, 1.0, 1.0), # 3 vec(this.h, 0.0, 0.0), # 4 vec(1.0, 1.0, 0.0), vec(St, St, St), vec(1.0, 0.0, 1.0), # 7 vec(0.0, this.h, 0.0), # 8 vec(0.0, 1.0, 1.0), vec(St, St, St), vec(1.0, 1.0, 0.0), # 11 ] # add heptagons heptN = Heptagons.Kite2Hept(Vs[3], Vs[2], Vs[1], Vs[0]) if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return else: this.errorStr = '' Vs.extend(heptN[0]) # V12 - V18 Ns = range(33) for i in range(4): Ns[i] = heptN[1] for i in range(12, 19): Ns[i] = heptN[1] heptN = Heptagons.Kite2Hept(Vs[7], Vs[6], Vs[5], Vs[4]) Vs.extend(heptN[0]) # V19 - V25 for i in range(4, 8): Ns[i] = heptN[1] for i in range(19, 26): Ns[i] = heptN[1] heptN = Heptagons.Kite2Hept(Vs[11], Vs[10], Vs[9], Vs[8]) Vs.extend(heptN[0]) # V26 - V32 for i in range(8, 12): Ns[i] = heptN[1] for i in range(26, 33): Ns[i] = heptN[1] xtraEs = [] # add extra faces: if this.heptPosAlt: # Eql triangle Vs.extend([Vs[15], Vs[22], Vs[29]]) # V33 - V35 # Isosceles triangles if this.triangleAlt: Vs.extend([Vs[13], Vs[14], Vs[32]]) # V36 - V38 Vs.extend([Vs[20], Vs[21], Vs[18]]) # V39 - V41 Vs.extend([Vs[27], Vs[28], Vs[25]]) # V42 - V44 else: v = Vs[14] Vs.extend([Vs[13], Vs[14], vec(-v[0], v[1], v[2])]) # V36 - V38 v = Vs[21] Vs.extend([Vs[20], Vs[21], vec( v[0], -v[1], v[2])]) # V39 - V41 v = Vs[28] Vs.extend([Vs[27], Vs[28], vec( v[0], v[1], -v[2])]) # V42 - V44 for i in range(3): Ns.append(Vs[0]) # N33 - N35 # normals for the isosceles triangles: # N36 - N38, N39 - N41 and N42 - N44 for i in range(3): o = 36 + 3*i IsoscelesTriangleN = Geom3D.Triangle( Vs[o], Vs[o+1], Vs[o+2] ).normal() Ns.extend([IsoscelesTriangleN, IsoscelesTriangleN, IsoscelesTriangleN]) xtraFs = [ # Eql triangle [33, 34, 35], # Isosceles triangles [36, 37, 38], [39, 40, 41], [42, 43, 44], ] this.xtraColIds = [2 for i in range(4)] if this.addXtraEdge: if this.triangleAlt: xtraEs = [36, 38, 39, 41, 42, 44] else: xtraEs = [37, 38, 40, 41, 43, 44] else: # The Squares, divided into rectangular isosceles triangles, # because of the sym-op Vs.extend([Vs[15], Vs[16], vec(0, 0, Vs[15][2])]) # V33 - V35 Vs.extend([Vs[22], Vs[23], vec(Vs[22][0], 0, 0)]) # V36 - V38 Vs.extend([Vs[29], Vs[30], vec(0, Vs[29][1], 0)]) # V39 - V41 # add isosceles triangles: if this.triangleAlt: v = Vs[13] Vs.extend([Vs[13], Vs[14], vec(v[0], -v[1], v[2])]) # V42 - V44 v = Vs[20] Vs.extend([Vs[20], Vs[21], vec(v[0], v[1], -v[2])]) # V45 - V47 v = Vs[27] Vs.extend([Vs[27], Vs[28], vec(-v[0], v[1], v[2])]) # V48 - V50 else: Vs.extend([Vs[13], Vs[14], Vs[24]]) # V42 - V44 Vs.extend([Vs[20], Vs[21], Vs[31]]) # V45 - V47 Vs.extend([Vs[27], Vs[28], Vs[17]]) # V48 - V50 # normals for the equilateral triangles: for i in range(3): Ns.append(Vs[0]) # N33 - N35 for i in range(3): Ns.append(Vs[4]) # N36 - N38 for i in range(3): Ns.append(Vs[8]) # N39 - N41 # normals for the isosceles triangles: # N42 - N44, N45 - N47 and N48 - N50 for i in range(3): o = 42 + 3*i IsoscelesTriangleN = Geom3D.Triangle( Vs[o], Vs[o+1], Vs[o+2] ).normal() Ns.extend([IsoscelesTriangleN, IsoscelesTriangleN, IsoscelesTriangleN]) xtraFs = [ # square parts: [33, 34, 35], [36, 37, 38], [39, 40, 41], # isosceles triangles: [42, 43, 44], [45, 46, 47], [48, 49, 50] ] this.xtraColIds = [2 for i in range(6)] if this.addXtraEdge: if this.triangleAlt: xtraEs = [42, 44, 45, 47, 48, 50] else: xtraEs = [43, 44, 46, 47, 49, 50] #this.showBaseOnly = True this.setBaseVertexProperties(Vs = Vs, Ns = Ns) Fs = [] Es = [] colIds = [] if this.showKite: Fs.extend(this.kiteFs) Es.extend(this.kiteEs) colIds.extend(this.kiteColIds) if this.showHepta: Fs.extend(this.heptFs) Es.extend(this.heptEs) colIds.extend(this.heptColIds) if this.showXtra: Fs.extend(xtraFs) Es.extend(xtraEs) colIds.extend(this.xtraColIds) this.setBaseEdgeProperties(Es = Es) this.setBaseFaceProperties(Fs = Fs, colors = (this.theColors, colIds))
def onImport(this, e): wildcard = "OFF shape (*.off)|*.off|Python shape (*.py)|*.py" dlg = wx.FileDialog(this, 'New: Choose a file', this.importDirName, '', wildcard, wx.OPEN) if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetFilename() this.importDirName = dlg.GetDirectory() print "opening file:", filename fd = open(os.path.join(this.importDirName, filename), 'r') if filename[-3:] == '.py': shape = Geom3D.readPyFile(fd) # For Compound derived shapes (isinstance) use merge: try: shape = shape.SimpleShape except AttributeError: # probably a SimpleShape pass else: shape = Geom3D.readOffFile(fd, recreateEdges = False) fd.close() if isinstance(shape, Geom3D.IsometricShape): Vs = shape.baseShape.Vs Fs = shape.baseShape.Fs else: #print 'no isometry' Vs = shape.Vs Fs = shape.Fs print 'read ', len(Vs), ' Vs and ', len(Fs), ' Fs.' this.showGui[this.__VsGuiIndex].set(Vs) this.showGui[this.__FsGuiIndex].set(Fs) # With a python file it is possible to set the other properties as # well: e.g. # finalSym = isometry.S4xI # finalSymSetup = [ [1, 0, 0], [0, 0, 1] ] # stabSym = isometry.C3xI # stabSymSetup = [ [0, 0, 1] ] # rotAxis = [1, 1, 1] # rotAngle = 30 # where the angle is in degrees (floating point) if filename[-3:] == '.py': fd = open(os.path.join(this.importDirName, filename), 'r') ed = {'__name__': 'readPyFile'} exec fd in ed moreSettings = 0 keyErrStr = 'Note: KeyError while looking for' key = 'finalSym' # to prevent accepting keyErrors in other code than ed[key]: keyDefined = False try: finalSym = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.showGui[this.__FinalSymGuiIndex].SetSelectedClass( finalSym ) this.showGui[this.__FinalSymGuiIndex].onSetSymmetry(None) key = 'finalSymSetup' keyDefined = False try: symSetup = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.showGui[this.__FinalSymGuiIndex].SetupSymmetry( symSetup ) key = 'stabSym' keyDefined = False try: stabSym = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.showGui[this.__StabSymGuiIndex].SetSelectedClass( stabSym ) this.showGui[this.__StabSymGuiIndex].onSetSymmetry(None) key = 'stabSymSetup' keyDefined = False try: symSetup = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.showGui[this.__StabSymGuiIndex].SetupSymmetry( symSetup ) if moreSettings > 0: this.onApplySymmetry(None) key = 'rotAxis' keyDefined = False try: axis = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.rotateSizer.set_axis(axis) key = 'rotAngle' keyDefined = False try: angle = ed[key] keyDefined = True except KeyError: print keyErrStr, key pass if keyDefined: moreSettings += 1 this.rotateSizer.set_angle(angle) this.updateOrientation( this.rotateSizer.get_angle(), this.rotateSizer.get_axis()) fd.close() this.name = filename dlg.Destroy()
def setV(this): # input this.h St = this.h / (Dtau2 * V3 * this.h - 3) #print 's', St # # 0 # __..--'-_ # 3 -'' . _"- 1 # \ _-' # \ _-' # \-' # 2 # # z y # ^ 7\ # |/ # ---> x # # # The kite above is a 5th of the top face of dodecahedron # standing on 1 face, 2 is a vertex, 1 and 3, centres of two edges # and 0 a face centre. # Vs = [ vec(0.0, 0.0, this.h), # 0 Rl, vec(0.0, -Dtau2 * St, St), vec(-Rl[0], Rl[1], Rl[2]) # 3 ] # add heptagons H = HalfTurn(Vs[3]) this.errorStr = '' if not this.heptPosAlt: Ns = Vs heptN = Heptagons.Kite2Hept(Vs[3], Vs[0], Vs[1], Vs[2]) if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return Mr = Rot(axis=GeomTypes.Vec3(Vs[2]), angle=GeomTypes.turn(0.2)) # p is a corner of the pentagon inside the pentagram # p is rotated 1/5th turn to form a triangle # together with 2 corners of the pentagram: # 5 of these triangles will cover the pentagram. # this is easier than finding the centre of the pentagram. v3 = heptN[0][3] v4 = heptN[0][4] p = v3 + (v4 - v3) / tau v = Mr * p if this.triangleAlt: vt = heptN[0][6] xtraEdgeIndex = 15 else: vt = heptN[0][5] xtraEdgeIndex = 14 # A part that will form the regular pentagrams (with overlaps). RegularTrianglePartV = [ heptN[0][3], heptN[0][4], vec(v[0], v[1], v[2]), ] RegularTrianglePartN = Vs[2] # vt is the vertex that will be projected by a half turn on the # third vertex of the isosceles triangle. IsoscelesTriangleV = [heptN[0][5], heptN[0][6], vt] else: heptN = Heptagons.Kite2Hept(Vs[1], Vs[2], Vs[3], Vs[0]) if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return if this.triangleAlt: vt = heptN[0][1] xtraEdgeIndex = 14 else: vt = heptN[0][2] xtraEdgeIndex = 15 # One third of regular triangle. RegularTrianglePartV = [ heptN[0][3], heptN[0][4], vec(0, 0, heptN[0][3][2]), ] RegularTrianglePartN = RegularTrianglePartV[2] # vt is the vertex that will be projected by a half turn on the # third vertex of the isosceles triangle. IsoscelesTriangleV = [heptN[0][1], heptN[0][2], vt] if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return else: this.errorStr = '' vt = H * vt # rotate vt by a half turn, IsoscelesTriangleV NOT auto updated. IsoscelesTriangleV[2] = vt Vs.extend(heptN[0]) # V4 - V10, the heptagon Vs.extend(RegularTrianglePartV) # V11 - V13 Vs.extend(IsoscelesTriangleV) # V14 - V16 #for V in Vs: print V #h = heptN[1] #Ns = [[-h[0], -h[1], -h[2]] for i in range(11)] Ns = [heptN[1] for i in range(11)] Ns.extend([RegularTrianglePartN for i in range(3)]) IsoscelesTriangleN = Geom3D.Triangle(IsoscelesTriangleV[0], IsoscelesTriangleV[1], IsoscelesTriangleV[2]).normal() Ns.extend([IsoscelesTriangleN for i in range(3)]) this.xtraEs = [] if this.addXtraEdge: this.xtraEs = [xtraEdgeIndex, 16] #this.showBaseOnly = True this.setBaseVertexProperties(Vs=Vs, Ns=Ns) Fs = [] Es = [] colIds = [] if this.showKite: Fs.extend(this.kiteFs) Es.extend(this.kiteEs) colIds.extend(this.kiteColIds) if this.showHepta: Fs.extend(this.heptFs) Es.extend(this.heptEs) colIds.extend(this.heptColIds) if this.showXtra: Fs.extend(this.xtraFs) Es.extend(this.xtraEs) colIds.extend(this.xtraColIds) this.setBaseEdgeProperties(Es=Es) this.setBaseFaceProperties(Fs=Fs, colors=(this.theColors, colIds)) this.Vs = Vs
def glDrawSingleRemoveUnscaledEdges(this): isScaledDown = not Geom3D.eq(this.c.scale, 1.0, margin=0.001) if not this.projectedTo3D: # print 'reprojecting...' try: del this.cell except AttributeError: pass Ns3D = [] if this.rot4 != None: Vs4D = [this.rot4 * v for v in this.Vs] # TODO fix Ns.. if needed.. # if this.Ns != []:cleanUp # Ns4D = [this.rot4*n for n in this.Ns] else: Vs4D = [v for v in this.Vs] Vs3D = this.projectVsTo3D(Vs4D) # for i in range(0, len(this.Es), 2): # v0 = Vs4D[this.Es[i]] # v1 = Vs4D[this.Es[i+1]] # print 'delta v:', v0 - v1 # print 'Edge [%d, %d]; len:' % (this.Es[i], this.Es[i+1]), (v1-v0).length() # if this.Ns != []: # Ns3D = this.projectVsTo3D(Ns4D) # Now project all to one 3D shape. 1 3D shape is chosen, instean of # projecting each cell to one shape because of different reasons: # - when drawing transparent faces all the opaqe fae should be # drawn first. # - if drawing the cells per shape, the glVertexPointer should be # called for each cell. (Currently SimpleShape will not call this # function unless the vertices have been changed... shapeVs = [] shapeEs = [] shapeFs = [] shapeColIndices = [] if this.c.draw: shapeCols = this.c.col[0] else: shapeCols = this.f.col[0] if this.removeTransparency: shapeCols = [c[0:3] for c in shapeCols] if this.e.draw and (not isScaledDown or this.e.showUnscaled): shapeVs = Vs3D shapeEs = this.Es # Add a shape with faces for each cell for i in xrange(len(this.Cs)): # use a copy, since we will filter (v indices will change): cellFs = [f[:] for f in this.Cs[i]] if this.c.draw: shapeColIndices.extend([this.c.col[1][i] for f in cellFs]) else: shapeColIndices.extend(this.f.col[1][i]) # Now cleanup Vs3D # TODO # if this.e.draw and (not isScaledDown or this.e.showUnscaled): # Then shapeVs = Vs3D already, and the code below is all # unecessary. cellVs = Vs3D[:] nrUsed = glue.cleanUpVsFs(cellVs, cellFs) # Now attaching to current Vs, will change index: offset = len(shapeVs) cellFs = [[vIndex + offset for vIndex in f] for f in cellFs] # Now scale from gravitation centre: if isScaledDown: g = GeomTypes.Vec3([0, 0, 0]) sum = 0 for vIndex in range(len(cellVs)): g = g + nrUsed[vIndex] * GeomTypes.Vec3(cellVs[vIndex]) sum = sum + nrUsed[vIndex] if sum != 0: g = g / sum # print this.name, 'g:', g cellVs = [this.c.scale * (GeomTypes.Vec3(v) - g) + g for v in cellVs] shapeVs.extend(cellVs) shapeFs.extend(cellFs) # for shapeColIndices.extend() see above this.cell = Geom3D.SimpleShape( shapeVs, shapeFs, shapeEs, [], # Vs , Fs, Es, Ns (shapeCols, shapeColIndices), name="%s_projection" % (this.name), ) this.cell.setVertexProperties(radius=this.v.radius, color=this.v.col) this.cell.setEdgeProperties(radius=this.e.radius, color=this.e.col, drawEdges=this.e.draw) this.cell.setFaceProperties(drawFaces=this.f.draw) this.cell.glInitialised = True # done as first step in this func this.projectedTo3D = True this.updateTransparency = False if this.e.draw and isScaledDown: this.cell.recreateEdges() # Don't use, out of performance issues: # cellEs = this.cell.getEdgeProperties()['Es'] # -------------------------- # Bad performance during scaling: # cellEs = this.cell.getEdgeProperties()['Es'] # this.cell.recreateEdges() # cellEs.extend(this.cell.getEdgeProperties()['Es']) # -------end bad perf--------- cellEs = this.cell.Es if this.e.showUnscaled: cellEs.extend(this.Es) this.cell.setEdgeProperties(Es=cellEs) if this.updateTransparency: cellCols = this.cell.getFaceProperties()["colors"] if this.removeTransparency: shapeCols = [c[0:3] for c in cellCols[0]] else: if this.c.draw: shapeCols = this.c.col[0] else: shapeCols = this.f.col[0] cellCols = (shapeCols, cellCols[1]) this.cell.setFaceProperties(colors=cellCols) this.updateTransparency = False
shape = Geom3D.IsometricShape( Vs = [ GeomTypes.Vec3([1.0, 1.0, 1.0]), GeomTypes.Vec3([-1.0, 1.0, 1.0]), GeomTypes.Vec3([-1.0, -1.0, 1.0]), GeomTypes.Vec3([1.0, -1.0, 1.0]), GeomTypes.Vec3([1.0, 1.0, -1.0]), GeomTypes.Vec3([-1.0, 1.0, -1.0]), GeomTypes.Vec3([-1.0, -1.0, -1.0]), GeomTypes.Vec3([1.0, -1.0, -1.0]) ], Fs = [ [0, 1, 2, 3], [0, 3, 7, 4], [1, 0, 4, 5], [2, 1, 5, 6], [3, 2, 6, 7], [7, 6, 5, 4] ], Es = [0, 1, 1, 2, 2, 3, 0, 3, 3, 7, 4, 7, 0, 4, 4, 5, 1, 5, 5, 6, 2, 6, 6, 7], colors = [ ([[0.99609400000000003, 0.83984400000000003, 0.0]], []), ([[0.13281200000000001, 0.54296900000000003, 0.13281200000000001]], []), ([[0.54296900000000003, 0.0, 0.0]], []), ([[0.0, 0.74609400000000003, 0.99609400000000003]], []), ([[0.54296900000000003, 0.0, 0.0]], []), ([[0.13281200000000001, 0.54296900000000003, 0.13281200000000001]], []), ([[0.0, 0.74609400000000003, 0.99609400000000003]], []), ([[0.0, 0.74609400000000003, 0.99609400000000003]], []), ([[0.99609400000000003, 0.83984400000000003, 0.0]], []), ([[0.54296900000000003, 0.0, 0.0]], []), ([[0.13281200000000001, 0.54296900000000003, 0.13281200000000001]], []), ([[0.99609400000000003, 0.83984400000000003, 0.0]], []) ], directIsometries = [ GeomTypes.Rot3(( GeomTypes.Quat([-0.5, 0.5, -0.5, -0.5]), GeomTypes.Quat([-0.5, -0.5, 0.5, 0.5]), )), GeomTypes.Rot3(( GeomTypes.Quat([-0.707106781187, 1.04526690545e-16, -0.707106781187, 4.32963728536e-17]), GeomTypes.Quat([-0.707106781187, -1.04526690545e-16, 0.707106781187, -4.32963728536e-17]), )), GeomTypes.Rot3(( GeomTypes.Quat([-1.22460635382e-16, 6.12303176911e-17, -0.707106781187, -0.707106781187]), GeomTypes.Quat([-1.22460635382e-16, -6.12303176911e-17, 0.707106781187, 0.707106781187]), )), GeomTypes.Rot3(( GeomTypes.Quat([0.707106781187, -0.707106781187, -6.12303176911e-17, -6.12303176911e-17]), GeomTypes.Quat([0.707106781187, 0.707106781187, 6.12303176911e-17, 6.12303176911e-17]), )), GeomTypes.Rot3(( GeomTypes.Quat([-3.33066907388e-16, -0.707106781187, 0.707106781187, 3.08170915002e-16]), GeomTypes.Quat([-3.33066907388e-16, 0.707106781187, -0.707106781187, -3.33066907388e-16]), )), GeomTypes.Rot3(( GeomTypes.Quat([0.5, -0.5, -0.5, -0.5]), GeomTypes.Quat([0.5, 0.5, 0.5, 0.5]), )), GeomTypes.Rot3(( GeomTypes.Quat([-0.5, -0.5, 0.5, -0.5]), GeomTypes.Quat([-0.5, 0.5, -0.5, 0.5]), )), GeomTypes.Rot3(( GeomTypes.Quat([3.74915180456e-33, 0.707106781187, 6.12303176911e-17, -0.707106781187]), GeomTypes.Quat([3.74915180456e-33, -0.707106781187, -6.12303176911e-17, 0.707106781187]), )), GeomTypes.Rot3(( GeomTypes.Quat([-0.707106781187, -0.707106781187, -6.12303176911e-17, 6.12303176911e-17]), GeomTypes.Quat([-0.707106781187, 0.707106781187, 6.12303176911e-17, -6.12303176911e-17]), )), GeomTypes.Rot3(( GeomTypes.Quat([6.12303176911e-17, 0.707106781187, -2.46519032882e-32, 0.707106781187]), GeomTypes.Quat([6.12303176911e-17, -0.707106781187, 2.46519032882e-32, -0.707106781187]), )), GeomTypes.Rot3(( GeomTypes.Quat([3.33066907388e-16, 1.11022302463e-16, -0.707106781187, 0.707106781187]), GeomTypes.Quat([3.33066907388e-16, -1.11022302463e-16, 0.707106781187, -0.707106781187]), )), GeomTypes.Rot3(( GeomTypes.Quat([0.707106781187, 4.32963728536e-17, -0.707106781187, -1.04526690545e-16]), GeomTypes.Quat([0.707106781187, -4.32963728536e-17, 0.707106781187, 1.04526690545e-16]), )) ], unfoldOrbit = False, name = '12cubes.py', orientation = GeomTypes.Rot3(( GeomTypes.Quat([0.953020613871, 0.214186495298, 0.0, 0.214186495298]), GeomTypes.Quat([0.953020613871, -0.214186495298, -0.0, -0.214186495298]), )) )
def setV(this): # input this.h St = this.h / (4*this.h - 1) if this.heptPosAlt: # # z # ^ # | # ---> y # / # V_ # x # # There are vertices with more than one index, because the normals # will differ. # # '-, # / '-, # / -.2 # | 5 -' \ 1, 11 # / 3.-' 0 '- # | / 4 8 __'-10 # / ,-' __--"" # /,=---"" 7 # 6 9 # # For tetrahedral position: 1, 3, and 5 are on the vertices of a # cube and 2, 4, 6, are on the face centres of that cube # Vs = [ vec( St, St, -St), # 0 vec( 0.0, 1.0, 0.0), vec( this.h, this.h, this.h), vec( 1.0, 0.0, 0.0), # 3 vec( St, St, -St), # 4 vec( 1.0, 0.0, 0.0), vec( this.h, -this.h, -this.h), vec( 0.0, 0.0, -1.0), # 7 vec( St, St, -St), # 8 vec( 0.0, 0.0, -1.0), vec(-this.h, this.h, -this.h), vec( 0.0, 1.0, 0.0) # 11 ] # Normals are set below, after calculating the heptagons #this.Ns = this.NsAlt else: # # z # ^ # | # ---> y # / # V_ # x # # There are vertices with more than one index, because the normals # will differ. # # 6 # 9 / # '-, 7 V_ # / '-, # / -.0, 4, 8 # | 10 -' \ 3, 5 # /11,1.-' '- # | / 2 __'- # / ,-' __--"" # /,=---"" # # # For tetrahedral position: 1, 3, and 5 are on the vertices of a # cube and 2, 4, 6, are on the face centres of that cube # Vs = [ vec( this.h, this.h, this.h), # 0 vec( 1.0, 0.0, 0.0), vec( St, St, -St), vec( 0.0, 1.0, 0.0), # 3 vec( this.h, this.h, this.h), # 4 vec( 0.0, 1.0, 0.0), vec(-St, St, St), vec( 0.0, 0.0, 1.0), # 7 vec( this.h, this.h, this.h), # 8 vec( 0.0, 0.0, 1.0), vec( St, -St, St), vec( 1.0, 0.0, 0.0) # 11 ] # Normals are set below, after calculating the heptagons #this.Ns = this.NsPref # add heptagons heptN = Heptagons.Kite2Hept(Vs[3], Vs[2], Vs[1], Vs[0]) if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return else: this.errorStr = '' Vs.extend(heptN[0]) # V12 - V18 Ns = range(33) for i in range(4): Ns[i] = heptN[1] for i in range(12, 19): Ns[i] = heptN[1] heptN = Heptagons.Kite2Hept(Vs[7], Vs[6], Vs[5], Vs[4]) Vs.extend(heptN[0]) # V19 - V25 for i in range(4, 8): Ns[i] = heptN[1] for i in range(19, 26): Ns[i] = heptN[1] heptN = Heptagons.Kite2Hept(Vs[11], Vs[10], Vs[9], Vs[8]) Vs.extend(heptN[0]) # V26 - V32 for i in range(8, 12): Ns[i] = heptN[1] for i in range(26, 33): Ns[i] = heptN[1] # add equilateral triangles: Vs.extend([Vs[15], Vs[22], Vs[29]]) # V33 - V35 # add isosceles triangles: this.xtraEs = [] if this.triangleAlt: Vs.extend([Vs[13], Vs[14], Vs[32]]) # V36 - V38 Vs.extend([Vs[20], Vs[21], Vs[18]]) # V39 - V41 Vs.extend([Vs[27], Vs[28], Vs[25]]) # V42 - V44 if this.addXtraEdge: this.xtraEs = [36, 38, 39, 41, 42, 44] else: Vs.extend([Vs[13], Vs[14], Vs[14]]) # V36 - V38 Vs.extend([Vs[20], Vs[21], Vs[21]]) # V39 - V41 Vs.extend([Vs[27], Vs[28], Vs[28]]) # V42 - V44 if this.heptPosAlt: v = Vs[38] Vs[38] = vec(-v[0], v[1], -v[2]) # Hy * V9 v = Vs[41] Vs[41] = vec( v[0], -v[1], -v[2]) # Hx * V23 else: v = Vs[38] Vs[38] = vec( v[0], -v[1], -v[2]) # Hx * V9 v = Vs[41] Vs[41] = vec(-v[0], v[1], -v[2]) # Hy * V23 v = Vs[44] Vs[44] = vec(-v[0], -v[1], v[2]) # Hz * V16 if this.addXtraEdge: this.xtraEs = [37, 38, 40, 41, 43, 44] # normal of equilateral triangle for i in range(3): Ns.append(Vs[0]) # normal of isosceles triangles for i in range(3): o = 36 + 3*i IsoscelesTriangleN = Geom3D.Triangle( Vs[o], Vs[o+1], Vs[o+2] ).normal() Ns.extend([IsoscelesTriangleN, IsoscelesTriangleN, IsoscelesTriangleN]) this.xtraFs = [ [33, 34, 35], [36, 37, 38], [39, 40, 41], [42, 43, 44] ] this.setBaseVertexProperties(Vs = Vs, Ns = Ns) Fs = [] Es = [] colIds = [] if this.showKite: Fs.extend(this.kiteFs) Es.extend(this.kiteEs) colIds.extend(this.kiteColIds) if this.showHepta: Fs.extend(this.heptFs) Es.extend(this.heptEs) colIds.extend(this.heptColIds) if this.showXtra: Fs.extend(this.xtraFs) Es.extend(this.xtraEs) colIds.extend(this.xtraColIds) this.setBaseEdgeProperties(Es = Es) this.setBaseFaceProperties(Fs = Fs, colors = (this.theColors, colIds))
def printError(str): global NrOfErrorsOcurred print '***** ERROR while testing *****' print ' ', str NrOfErrorsOcurred += 1 v = vec(1, 1, 0, 0) w = vec(0, 3, 4, 0) z = 0.1 * w p = z.isParallel(w) if not p: printError('in function isParallel') t = w.makeOrthogonalTo(v) #print 'check if [-3, 3, 8, 0] ==', w if not (Geom3D.eq(t.x, -3) and Geom3D.eq(t.y, 3) and Geom3D.eq(t.z, 8) and Geom3D.eq(t.w, 0)): printError('in function makeOrthogonalTo') print ' Expected (-3, 3, 8, 0), got', t n = w.normalise() # TODO Move some of these tests to GeomTypes, after cgtypes rm, any relevant? # check if n is still of type vec and not cgtypes.vec4 (which doesn't have # a isParallel) if not n.isParallel(w): printError('in function isParallel after norm') def testOrthogonalVectors(R, margin=Geom3D.defaultFloatMargin): if not Geom3D.eq(R.e0 * R.e1, 0.0, margin):
def Vlen(v0, v1): x = v1[0] - v0[0] y = v1[1] - v0[1] z = v1[2] - v0[2] return (math.sqrt(x * x + y * y + z * z)) # get the col faces array by using a similar shape here, so it is calculated # only once useIsom = isometry.A4() egShape = Geom3D.IsometricShape(Vs=[ GeomTypes.Vec3([0, 0, 1]), GeomTypes.Vec3([0, 1, 1]), GeomTypes.Vec3([1, 1, 1]) ], Fs=[[0, 1, 2]], directIsometries=useIsom, unfoldOrbit=True) #colStabiliser = isometry.C2(setup = {'axis': [0.0, 1.0, 0.0]}) #colStabiliser = isometry.C2(setup = {'axis': [0.0, 0.0, 1.0]}) useSimpleColours = False colStabiliser = isometry.C2(setup={'axis': [1.0, 0.0, 0.0]}) colQuotientSet = useIsom / colStabiliser if useSimpleColours: useRgbCols = [ rgb.gray95, rgb.gray80, rgb.gray65, rgb.gray50, rgb.gray35,
def glDrawSingleRemoveUnscaledEdges(this): isScaledDown = not Geom3D.eq(this.c.scale, 1.0, margin=0.001) if not this.projectedTo3D: # print 'reprojecting...' try: del this.cell except AttributeError: pass Ns3D = [] if this.rot4 != None: Vs4D = [this.rot4 * v for v in this.Vs] # TODO fix Ns.. if needed.. # if this.Ns != []:cleanUp # Ns4D = [this.rot4*n for n in this.Ns] else: Vs4D = [v for v in this.Vs] Vs3D = this.projectVsTo3D(Vs4D) #for i in range(0, len(this.Es), 2): # v0 = Vs4D[this.Es[i]] # v1 = Vs4D[this.Es[i+1]] # print 'delta v:', v0 - v1 # print 'Edge [%d, %d]; len:' % (this.Es[i], this.Es[i+1]), (v1-v0).length() #if this.Ns != []: # Ns3D = this.projectVsTo3D(Ns4D) # Now project all to one 3D shape. 1 3D shape is chosen, instean of # projecting each cell to one shape because of different reasons: # - when drawing transparent faces all the opaqe fae should be # drawn first. # - if drawing the cells per shape, the glVertexPointer should be # called for each cell. (Currently SimpleShape will not call this # function unless the vertices have been changed... shapeVs = [] shapeEs = [] shapeFs = [] shapeColIndices = [] if this.c.draw: shapeCols = this.c.col[0] else: shapeCols = this.f.col[0] if this.removeTransparency: shapeCols = [c[0:3] for c in shapeCols] if this.e.draw and (not isScaledDown or this.e.showUnscaled): shapeVs = Vs3D shapeEs = this.Es # Add a shape with faces for each cell for i in xrange(len(this.Cs)): # use a copy, since we will filter (v indices will change): cellFs = [f[:] for f in this.Cs[i]] if this.c.draw: shapeColIndices.extend([this.c.col[1][i] for f in cellFs]) else: shapeColIndices.extend(this.f.col[1][i]) # Now cleanup Vs3D # TODO # if this.e.draw and (not isScaledDown or this.e.showUnscaled): # Then shapeVs = Vs3D already, and the code below is all # unecessary. cellVs = Vs3D[:] nrUsed = glue.cleanUpVsFs(cellVs, cellFs) # Now attaching to current Vs, will change index: offset = len(shapeVs) cellFs = [[vIndex + offset for vIndex in f] for f in cellFs] # Now scale from gravitation centre: if isScaledDown: g = GeomTypes.Vec3([0, 0, 0]) sum = 0 for vIndex in range(len(cellVs)): g = g + nrUsed[vIndex] * GeomTypes.Vec3(cellVs[vIndex]) sum = sum + nrUsed[vIndex] if sum != 0: g = g / sum #print this.name, 'g:', g cellVs = [ this.c.scale * (GeomTypes.Vec3(v) - g) + g for v in cellVs ] shapeVs.extend(cellVs) shapeFs.extend(cellFs) # for shapeColIndices.extend() see above this.cell = Geom3D.SimpleShape( shapeVs, shapeFs, shapeEs, [], # Vs , Fs, Es, Ns (shapeCols, shapeColIndices), name='%s_projection' % (this.name)) this.cell.setVertexProperties(radius=this.v.radius, color=this.v.col) this.cell.setEdgeProperties(radius=this.e.radius, color=this.e.col, drawEdges=this.e.draw) this.cell.setFaceProperties(drawFaces=this.f.draw) this.cell.glInitialised = True # done as first step in this func this.projectedTo3D = True this.updateTransparency = False if this.e.draw and isScaledDown: this.cell.recreateEdges() # Don't use, out of performance issues: # cellEs = this.cell.getEdgeProperties()['Es'] # -------------------------- # Bad performance during scaling: # cellEs = this.cell.getEdgeProperties()['Es'] # this.cell.recreateEdges() # cellEs.extend(this.cell.getEdgeProperties()['Es']) # -------end bad perf--------- cellEs = this.cell.Es if this.e.showUnscaled: cellEs.extend(this.Es) this.cell.setEdgeProperties(Es=cellEs) if this.updateTransparency: cellCols = this.cell.getFaceProperties()['colors'] if this.removeTransparency: shapeCols = [c[0:3] for c in cellCols[0]] else: if this.c.draw: shapeCols = this.c.col[0] else: shapeCols = this.f.col[0] cellCols = (shapeCols, cellCols[1]) this.cell.setFaceProperties(colors=cellCols) this.updateTransparency = False
def setV(this): this.posHeptagon() Vs = this.heptagon.Vs[:] # 5" = 18 12 = 2" # 6" = 16 10 = 1" # 0 # 5' = 17 o3 o3 11 = 2' # 6 1 # # 6' = 15 9 = 1' # # 5 2 # # # 14 4 3 8 = 0' # # # 2' = 13 7 = 5' Rr = Rot(axis=Vec([1, 1, 1]), angle=GeomTypes.tTurn) Rl = Rot(axis=Vec([-1, 1, 1]), angle=-GeomTypes.tTurn) Vs.append(Vec([-Vs[5][0], -Vs[5][1], Vs[5][2]])) # Vs[7] Vs.append(Rr * Vs[0]) # Vs[8] Vs.append(Rr * Vs[1]) # Vs[9] Vs.append(Rr * Vs[9]) # Vs[10] Vs.append(Rr * Vs[2]) # Vs[11] Vs.append(Rr * Vs[11]) # Vs[12] Vs.append(Vec([-Vs[2][0], -Vs[2][1], Vs[2][2]])) # Vs[13] Vs.append(Rl * Vs[0]) # Vs[14] Vs.append(Rl * Vs[6]) # Vs[15] Vs.append(Rl * Vs[-1]) # Vs[16] Vs.append(Rl * Vs[5]) # Vs[17] Vs.append(Rl * Vs[-1]) # Vs[18] Vs.append(Rr * Vs[8]) # Vs[19] = V0" Vs.append(Rr * Vs[6]) # Vs[20] = V6'" Vs.append(Rr * Vs[5]) # Vs[21] = V5'" Vs.append(Rl * Vs[13]) # Vs[22] = V13' Vs.append(Rl * Vs[-1]) # Vs[23] = V13" this.baseVs = Vs #for i in range(len(Vs)): # print 'Vs[%d]:' % i, Vs[i] Es = [] Fs = [] Fs.extend(this.heptagon.Fs) # use extend to copy the list to Fs Es.extend(this.heptagon.Es) # use extend to copy the list to Fs this.heptagonsShape.setBaseVertexProperties(Vs=Vs) this.heptagonsShape.setBaseEdgeProperties(Es=Es) # comment out this and nvidia driver crashes:... this.heptagonsShape.setBaseFaceProperties(Fs=Fs) this.heptagonsShape.setFaceColors(heptColPerIsom) theShapes = [this.heptagonsShape] if this.addXtraFs: Es = this.o3triEs[this.edgeAlternative][:] Fs = this.o3triFs[this.edgeAlternative][:] Es.extend(this.oppO3triEs[this.oppEdgeAlternative]) Fs.extend(this.oppO3triFs[this.oppEdgeAlternative]) this.trisO3Shape.setBaseVertexProperties(Vs=Vs) this.trisO3Shape.setBaseEdgeProperties(Es=Es) this.trisO3Shape.setBaseFaceProperties(Fs=Fs) theShapes.append(this.trisO3Shape) if (not this.onlyRegFs): # when you use the rot alternative the rot is leading for # choosing the colours. if this.oppEdgeAlternative & Heptagons.rot_bit: eAlt = this.oppEdgeAlternative else: eAlt = this.edgeAlternative Es = this.triEs[this.edgeAlternative][:] if this.edgeAlternative == trisAlt.twist_strip_I: Fs = this.triFs[this.edgeAlternative][ this.inclReflections][:] Fs.extend(this.oppTriFs[this.oppEdgeAlternative][ this.inclReflections]) Es.extend(this.oppTriEs[this.oppEdgeAlternative][ this.inclReflections]) # only draw the folds of the hexagon for the twisted variant # if the hexagon isn't flat. if (not Geom3D.eq( abs(this.posAngle) % (math.pi / 2), math.pi / 4)): Es.extend(this.twistedEs_A4) colIds = this.triColIds[eAlt][this.inclReflections] else: Fs = this.triFs[this.edgeAlternative][:] Fs.extend(this.oppTriFs[this.oppEdgeAlternative]) Es.extend(this.oppTriEs[this.oppEdgeAlternative]) colIds = this.triColIds[eAlt] this.xtraTrisShape.setBaseVertexProperties(Vs=Vs) this.xtraTrisShape.setBaseEdgeProperties(Es=Es) this.xtraTrisShape.setBaseFaceProperties( Fs=Fs, colors=([rgb.darkRed[:], rgb.yellow[:], rgb.magenta[:]], colIds)) theShapes.append(this.xtraTrisShape) for shape in theShapes: shape.showBaseOnly = not this.applySymmetry this.setShapes(theShapes) this.updateShape = False
def printError(str): global NrOfErrorsOcurred print "***** ERROR while testing *****" print " ", str NrOfErrorsOcurred += 1 v = vec(1, 1, 0, 0) w = vec(0, 3, 4, 0) z = 0.1 * w p = z.isParallel(w) if not p: printError("in function isParallel") t = w.makeOrthogonalTo(v) # print 'check if [-3, 3, 8, 0] ==', w if not (Geom3D.eq(t.x, -3) and Geom3D.eq(t.y, 3) and Geom3D.eq(t.z, 8) and Geom3D.eq(t.w, 0)): printError("in function makeOrthogonalTo") print " Expected (-3, 3, 8, 0), got", t n = w.normalise() # TODO Move some of these tests to GeomTypes, after cgtypes rm, any relevant? # check if n is still of type vec and not cgtypes.vec4 (which doesn't have # a isParallel) if not n.isParallel(w): printError("in function isParallel after norm") def testOrthogonalVectors(R, margin=Geom3D.defaultFloatMargin): if not Geom3D.eq(R.e0 * R.e1, 0.0, margin): printError("in function _setOrthoMatrix: e0.e1 = ", R.e0 * R.e1, "!= 0")
GeomTypes.Vec3([-1, -1, -1]), GeomTypes.Vec3([ 1, -1, -1]), GeomTypes.Vec3([ 1, 1, -2]), GeomTypes.Vec3([.5, 1, 1]), ] Fs = [ [0, 1, 2, 3], [0, 3, 7, 4], [1, 0, 4, 5], [2, 1, 5, 6], [3, 2, 6, 7], [7, 6, 5, 4] ] shape0 = Geom3D.SimpleShape(Vs = Vs, Fs = Fs) Vs = [ GeomTypes.Vec3([ 0, 0, 2]), GeomTypes.Vec3([ 2, 0, 0]), GeomTypes.Vec3([ 0, 2, 0]), GeomTypes.Vec3([-2, 0, 0]), GeomTypes.Vec3([ 0, -2, 0]), GeomTypes.Vec3([ 0, 0, 2]), ] Fs = [ [0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1],
def setV(this): this.posHeptagon() Vs = this.heptagon.Vs[:] # 5" = 18 12 = 2" # 6" = 16 10 = 1" # 0 # 5' = 17 o3 o3 11 = 2' # 6 1 # # 6' = 15 9 = 1' # # 5 2 # # # 14 4 3 8 = 0' # # # 2' = 13 7 = 5' Rr = Rot(axis=Vec([1, 1, 1]), angle=GeomTypes.tTurn) Rl = Rot(axis=Vec([-1, 1, 1]), angle=-GeomTypes.tTurn) Vs.append(Vec([-Vs[5][0], -Vs[5][1], Vs[5][2]])) # Vs[7] Vs.append(Rr * Vs[0]) # Vs[8] Vs.append(Rr * Vs[1]) # Vs[9] Vs.append(Rr * Vs[9]) # Vs[10] Vs.append(Rr * Vs[2]) # Vs[11] Vs.append(Rr * Vs[11]) # Vs[12] Vs.append(Vec([-Vs[2][0], -Vs[2][1], Vs[2][2]])) # Vs[13] Vs.append(Rl * Vs[0]) # Vs[14] Vs.append(Rl * Vs[6]) # Vs[15] Vs.append(Rl * Vs[-1]) # Vs[16] Vs.append(Rl * Vs[5]) # Vs[17] Vs.append(Rl * Vs[-1]) # Vs[18] Vs.append(Rr * Vs[8]) # Vs[19] = V0" Vs.append(Rr * Vs[6]) # Vs[20] = V6'" Vs.append(Rr * Vs[5]) # Vs[21] = V5'" Vs.append(Rl * Vs[13]) # Vs[22] = V13' Vs.append(Rl * Vs[-1]) # Vs[23] = V13" this.baseVs = Vs # for i in range(len(Vs)): # print 'Vs[%d]:' % i, Vs[i] Es = [] Fs = [] Fs.extend(this.heptagon.Fs) # use extend to copy the list to Fs Es.extend(this.heptagon.Es) # use extend to copy the list to Fs this.heptagonsShape.setBaseVertexProperties(Vs=Vs) this.heptagonsShape.setBaseEdgeProperties(Es=Es) # comment out this and nvidia driver crashes:... this.heptagonsShape.setBaseFaceProperties(Fs=Fs) this.heptagonsShape.setFaceColors(heptColPerIsom) theShapes = [this.heptagonsShape] if this.addXtraFs: Es = this.o3triEs[this.edgeAlternative][:] Fs = this.o3triFs[this.edgeAlternative][:] Es.extend(this.oppO3triEs[this.oppEdgeAlternative]) Fs.extend(this.oppO3triFs[this.oppEdgeAlternative]) this.trisO3Shape.setBaseVertexProperties(Vs=Vs) this.trisO3Shape.setBaseEdgeProperties(Es=Es) this.trisO3Shape.setBaseFaceProperties(Fs=Fs) theShapes.append(this.trisO3Shape) if not this.onlyRegFs: # when you use the rot alternative the rot is leading for # choosing the colours. if this.oppEdgeAlternative & Heptagons.rot_bit: eAlt = this.oppEdgeAlternative else: eAlt = this.edgeAlternative Es = this.triEs[this.edgeAlternative][:] if this.edgeAlternative == trisAlt.twist_strip_I: Fs = this.triFs[this.edgeAlternative][this.inclReflections][:] Fs.extend(this.oppTriFs[this.oppEdgeAlternative][this.inclReflections]) Es.extend(this.oppTriEs[this.oppEdgeAlternative][this.inclReflections]) # only draw the folds of the hexagon for the twisted variant # if the hexagon isn't flat. if not Geom3D.eq(abs(this.posAngle) % (math.pi / 2), math.pi / 4): Es.extend(this.twistedEs_A4) colIds = this.triColIds[eAlt][this.inclReflections] else: Fs = this.triFs[this.edgeAlternative][:] Fs.extend(this.oppTriFs[this.oppEdgeAlternative]) Es.extend(this.oppTriEs[this.oppEdgeAlternative]) colIds = this.triColIds[eAlt] this.xtraTrisShape.setBaseVertexProperties(Vs=Vs) this.xtraTrisShape.setBaseEdgeProperties(Es=Es) this.xtraTrisShape.setBaseFaceProperties( Fs=Fs, colors=([rgb.darkRed[:], rgb.yellow[:], rgb.magenta[:]], colIds) ) theShapes.append(this.xtraTrisShape) for shape in theShapes: shape.showBaseOnly = not this.applySymmetry this.setShapes(theShapes) this.updateShape = False