用于处理文件名和vtk网格的快速python包。
GaTools的Python项目详细描述
安装
python3 -m pip install --user GaTools
使用网格工具
from GaTools import MeshTools
meshFile = path_to_vtk_mesh
mt = MeshTools(meshFile)
print(mt)
pos = mt.positions
tetras = mt.tetras
mt.pointData.resize(len(mt.positions))
for i,p in enumerate(mt.positions):
mt.pointData[i] = p[0]
mt.writeVTK("new_mesh.vtk")
使用快速行进法
from GaTools import SofaFMM
fmm = SofaFMM()
# print(fmm.defaultValues)
### Tetrahedral mesh
meshFile = curDir+"/mesh/cube.vtk"
mt = MeshTools(meshFile)
my_parameters = {
"RUNSOFA_PATH" : "path_to_sofa/bin/runSofa",
"MESH" : meshFile,
"BORDER" : "0",
"EXPORT_AT_EACH_STEP" : False,
"EXPORT_PATH" : outputDir+"/fmm.vtk"
}
fmm.setParams(my_parameters)
fmm.run()
使用文件工具
from GaTools import Path
rootDir = Path(path_to_dir)
rootDir.listDir("*.txt")
other_dir = rootDir.makeDir(other_directory)
other_dir.clearDir("*.vtk")
使用图形场景显示
from GaTools import Graph
print(Graph(python_sofa_scene_filename))