def tstTravelSurfOutside( tstFileName, phiFileName=False, tstDataIn=False, phiDataIn=False, borderSize=10): if tstDataIn: #don't want to read in if calling function already did it for us tstD = tstDataIn else: tstD = tstdata.tstData(tstFileName) # read the file into the data structure if phiDataIn: phiData = phiDataIn else: phiData = phi(phiFileName) # read in the phimap if possible #depends on convex hull _only_ to decide how far out to put the border if 'CONVEX_HULL_TRI_POINT_LIST' not in tstD.dict.keys(): print "Run tstConvexHull.py on this tst data file first." sys.exit(1) #these sets are useful to construct convexHullPoints = set() for record in tstD.dict['CONVEX_HULL_TRI_POINT_LIST']: convexHullPoints.update(record[1:]) gridD, mins, maxs = grid.makeTrimmedGridFromPhi( phiData, tstD.dict['POINT_XYZ'], convexHullPoints, 0.6, -2.0, 0, borderSize) gridSize = 1.0/phiData.scale del phiData # no longer needed in this function, so delete this reference #do the biggest disjoint set of tris/points stuff allPoints, allTris, cavPoints, cavTris = cavity.assumeNoCavities( tstD.dict['POINT_XYZ'], tstD.dict['TRIANGLE_POINT'], tstD.dict['POINT_NEIGHBOR']) #here's the (relatively simple) surface travel distance calculation finally # assign following encoding -1 = outside ch, 0 = on border, # pos ints = dist from border, -2 = far inside ms, # other neg ints = -(dist)-3 extraEdges, surfaceEdgeBoxes = grid.findLongSurfEdges( tstD.dict['POINT_XYZ'], tstD.dict['POINT_NEIGHBOR'], gridSize, mins, maxs) for surfaceEdgeBox in surfaceEdgeBoxes.keys(): x, y, z = gridD[surfaceEdgeBox[0]][surfaceEdgeBox[1]][surfaceEdgeBox[2]][1:] gridD[surfaceEdgeBox[0]][surfaceEdgeBox[1]][surfaceEdgeBox[2]] = ( -1., x, y, z) pointTravelDist, traceback, volumePointDepths = \ travelDistNoMesh.calcTravelDist( gridD, tstD.dict['POINT_XYZ'], gridSize, mins, maxs, allPoints, extraEdges, surfaceEdgeBoxes, tstFileName) #transform grid to actual travel distance maxTD = grid.finalizeGridTravelDist(gridD, gridSize) gridMaximaRanking = grid.getMaximaRanking(gridD) #output the grids and the gridmaxima.... phiDataOut = phi() phiDataOut.createFromGrid( gridMaximaRanking, gridSize, toplabel="travel depth maxima rank") phiDataOut.write(tstFileName+".travel.out.max.rank.phi") phiDataOut = phi() phiDataOut.createFromGrid( gridD, gridSize, toplabel="travel depth surf-out", defaultValue=maxTD+1.0) phiDataOut.write(tstFileName+".travel.out.phi") return mins, maxs, gridSize, convexHullPoints, allPoints, allTris, \ extraEdges, surfaceEdgeBoxes, pointTravelDist, traceback, maxTD, gridD, \ gridMaximaRanking
def tstTravelSurfOutsideMesh( tstFileName, phiFileName=None, tstDataIn=False, phiDataIn=None, borderSize=10, threshold="auto"): if tstDataIn: #don't want to read in if calling function already did it for us tstD = tstDataIn else: tstD = tstdata.tstData( tstFileName, necessaryKeys=tstdata.tstData.necessaryKeysForMesh) if phiDataIn is not None: phiData = phiDataIn else: phiData = phi(phiFileName) # read in the phimap if possible if 'CONVEX_HULL_TRI_POINT_LIST' not in tstD.dict.keys(): print "Run tstConvexHull.py on this tst data file first." sys.exit(1) #these sets are useful to construct convexHullPoints = set() for record in tstD.dict['CONVEX_HULL_TRI_POINT_LIST']: convexHullPoints.update(record[1:]) maxPhi = phiData.getMaxValues() if threshold == "auto" and maxPhi == 1.0: threshold = 0.6 if threshold == "auto" and maxPhi == 10.0: threshold = 6.0 gridD, mins, maxs = grid.makeTrimmedGridFromPhi( phiData, tstD.dict['POINT_XYZ'], convexHullPoints, threshold, -2, 0, borderSize) gridSize = 1.0/phiData.scale del phiData # no longer needed in this function, so delete this reference #do the biggest disjoint set of tris/points stuff allPoints, allTris, cavPoints, cavTris = cavity.assumeNoCavities( tstD.dict['POINT_XYZ'], tstD.dict['TRIANGLE_POINT'], tstD.dict['POINT_NEIGHBOR']) #here is where code is mesh-specific meshData = mesh.mesh( gridD, tstD.dict['POINT_XYZ'], tstD.dict['POINT_NEIGHBOR'], gridSize, 0, -2, "X") # no between meshData.calculateTravelDistance("surfout", [3], [0, 2]) #transform grid to actual travel distance maxTD = grid.finalizeGridTravelDist(gridD, gridSize) gridMaximaRanking = grid.getMaximaRanking(gridD) #output the grids and the gridmaxima.... phiDataOut = phi() phiDataOut.createFromGrid( gridMaximaRanking, gridSize, toplabel="travel depth maxima rank") phiDataOut.write(tstFileName + ".mesh.travel.out.max.rank.phi") phiDataOut = phi() phiDataOut.createFromGrid( gridD, gridSize, toplabel="travel depth surf-out", defaultValue=maxTD + 1.0) phiDataOut.write(tstFileName+".mesh.travel.out.phi")