def triToTst(triName, tstName): '''reads a tri file, writes the tstfile''' pdbD, triLineToNum, triPoints = readTri(triName) #print pdbD, triLineToNum, triPoints tstD = tstdata.tstDataWritable(False) # empty, now add stuff to it tstD.dict['PDB_RECORD'] = pdbD.rawData # this one is easy tstD.dict['POINT_XYZ'] = makePointXyz(triLineToNum) tstD.dict['TRIANGLE_POINT'] = makeTriPoints(triPoints) tstD.dict['TRIANGLE_NEIGHBOR'] = makeFakeTriNeighbors( tstD.dict['TRIANGLE_POINT']) tstD.dict['POINT_PDB_RECORD'] = nearbyPoints(tstD.dict['POINT_XYZ'], pdbD) tstD.dict['TRIANGLE_PDB_RECORD'] = nearbyTriangles( tstD.dict['POINT_PDB_RECORD'], tstD.dict['TRIANGLE_POINT']) pointTriDict, triPointDict = makeDicts(tstD.dict['TRIANGLE_POINT']) tstD.dict['POINT_TRIANGLE'], tstD.dict['POINT_NEIGHBOR'] = \ makePointTriAndNeighbor(pointTriDict, triPointDict) tstD.dict['NORM_XYZ'] = calcNormals( tstD.dict['POINT_XYZ'], triPointDict, pointTriDict) tstD.dict['CURVATURE_XYZ'] = fakeForNow(tstD.dict['POINT_XYZ']) tstD.dict['PROPERTY_XYZ'] = fakeForNow(tstD.dict['POINT_XYZ']) #print tstD.dict.keys() tstD.write(tstName)
def tstCavityRemoval( tstFileName, tstFileNameOut, phiFileName=False, phiFileNameOut=False): oldTst = tstdata.tstDataWritable(tstFileName) # read the file into the struct allPoints, allTris, cavPoints, cavTris = findBiggestDisjointSets( oldTst.dict['POINT_XYZ'], oldTst.dict['TRIANGLE_POINT'], oldTst.dict['POINT_NEIGHBOR']) #print len(allPoints), len(allTris), len(cavPoints), len(cavTris) #debug #now remove everything that isn't allPoints and allTris #first generate maps from old numbering to new numbering mapPoints = makeMapLists(oldTst.dict['POINT_XYZ'], allPoints) mapTris = makeMapLists(oldTst.dict['TRIANGLE_POINT'], allTris) #ugh. phi map. phiData = sharp_phi.phi(phiFileName) # read in the phimap if possible gridD = grid.makeGridFromPhi(phiData, False) #the False just makes it copy values mins, maxs = phiData.getMinsMaxs() maxVal = phiData.getMaxValues() gridSize = 1.0/phiData.scale #this function marks cavities as interior cavTriTuples = geometry.cacheTriangle( oldTst.dict['TRIANGLE_POINT'], oldTst.dict['POINT_XYZ'], cavTris) #have to do this now before oldTst gets modified orstHelper.decideInside( gridD, cavTriTuples, cavPoints, oldTst.dict['POINT_TRIANGLE'], oldTst.dict['POINT_XYZ'], oldTst.dict['TRIANGLE_POINT'], maxVal) #change anything inside cavities to max.. #now piece-by-piece fix each entry newTN = replaceEntry( oldTst.dict['TRIANGLE_NEIGHBOR'], mapTris, [mapTris, mapTris, mapTris]) oldTst.dict['TRIANGLE_NEIGHBOR'] = newTN newPX = replaceEntry( oldTst.dict['POINT_XYZ'], mapPoints, [False, False, False]) oldTst.dict['POINT_XYZ'] = newPX newTP = replaceEntry( oldTst.dict['TRIANGLE_POINT'], mapTris, [mapPoints, mapPoints, mapPoints]) oldTst.dict['TRIANGLE_POINT'] = newTP newPT = replaceEntry( oldTst.dict['POINT_TRIANGLE'], mapPoints, [False, mapTris], extendToEnd=True) oldTst.dict['POINT_TRIANGLE'] = newPT newPN = replaceEntry( oldTst.dict['POINT_NEIGHBOR'], mapPoints, [False, mapPoints], extendToEnd=True) oldTst.dict['POINT_NEIGHBOR'] = newPN newNX = replaceEntry( oldTst.dict['NORM_XYZ'], mapPoints, [False, False, False]) oldTst.dict['NORM_XYZ'] = newNX newPPR = replaceEntry(oldTst.dict['POINT_PDB_RECORD'], mapPoints, [False]) oldTst.dict['POINT_PDB_RECORD'] = newPPR newTPR = replaceEntry(oldTst.dict['TRIANGLE_PDB_RECORD'], mapTris, [False]) oldTst.dict['TRIANGLE_PDB_RECORD'] = newTPR #don't touch PDB_RECORD... newCX = replaceEntry(oldTst.dict['CURVATURE_XYZ'], mapPoints, [False]) oldTst.dict['CURVATURE_XYZ'] = newCX newPX = replaceEntry(oldTst.dict['PROPERTY_XYZ'], mapPoints, [False]) oldTst.dict['PROPERTY_XYZ'] = newPX #now write it back out...should probably tag it somehow....hmmm oldTst.write(tstFileNameOut) #write phi map phiDataOut = sharp_phi.phi() phiDataOut.createFromGrid( gridD, gridSize, toplabel=phiData.toplabel, head=phiData.head, title=phiData.title, botlabel=phiData.botlabel) phiDataOut.write(phiFileNameOut)