@@ -31,7 +31,7 @@ function particle2ply(coords::Matrix; output_file::String="coord.ply")
3131 coords = hcat (coords, zeros (size (coords, 1 )))
3232 end
3333 # export .ply file by using trimesh
34- mesh = trimesh[] . Trimesh (vertices= coords)
34+ mesh = trimesh. Trimesh (vertices= coords)
3535 mesh. export (output_file)
3636 # print info
3737 @info """ PLY file ($(size (coords, 1 )) pts) saved at:
@@ -55,7 +55,7 @@ function particle2ply(
5555 output_file = joinpath (args. project_path, args. project_name, filename)
5656 coords = hcat (mp. ξ, zeros (mp. np))
5757 # export .ply file by using trimesh
58- mesh = trimesh[] . Trimesh (vertices= coords)
58+ mesh = trimesh. Trimesh (vertices= coords)
5959 mesh. export (output_file)
6060 # print info
6161 @info """ PLY file ($(size (coords, 1 )) pts) saved at:
@@ -78,7 +78,7 @@ function particle2ply(
7878 filename = args. project_name * " .ply"
7979 output_file = joinpath (args. project_path, args. project_name, filename)
8080 # export .ply file by using trimesh
81- mesh = trimesh[] . Trimesh (vertices= mp. ξ)
81+ mesh = trimesh. Trimesh (vertices= mp. ξ)
8282 mesh. export (output_file)
8383 # print info
8484 @info """ PLY file ($(mp. np) pts) saved at:
@@ -114,7 +114,7 @@ function particle2ply(hdf5_file::String, ply_dir::String)
114114 end
115115 output_file = joinpath (ply_dir, " iteration_$(i) .ply" )
116116 # export .ply file by using trimesh
117- mesh = trimesh[] . Trimesh (vertices= obj)
117+ mesh = trimesh. Trimesh (vertices= obj)
118118 mesh. export (output_file)
119119 next! (p)
120120 end
127127
128128"""
129129 ply2surface(ply_dir, splash_dir, radius, num_threads; cube_size=0.6,
130- surface_threshold=0.6, smoothing_length=1.2)
130+ surface_threshold=0.6, smoothing_length=1.2, splashsurf="nothing" )
131131
132132Description:
133133---
@@ -148,18 +148,49 @@ function ply2surface(
148148 splash_dir,
149149 radius,
150150 num_threads;
151- cube_size = 0.6 ,
152- surface_threshold= 0.6 ,
153- smoothing_length = 1.2
151+ cube_size = 0.6 ,
152+ surface_threshold = 0.6 ,
153+ smoothing_length = 1.2 ,
154+ splashsurf:: String = " nothing"
154155)
156+ if splashsurf == " nothing"
157+ try
158+ run (pipeline (` splashsurf -V` , stdout = devnull , stderr = devnull ))
159+ catch e
160+ if isa (e, Base. IOError) # splashsurf 未安装
161+ @warn """ splashsurf
162+ Cannot find splashsurf on this system. If you need surface reconstruction, please
163+ install it first, and make sure Julia can find it.
164+ Or you can pass the path of splashsurf to ply2surface.
165+ link: https://github.com/InteractiveComputerGraphics/splashsurf
166+ """
167+ end
168+ end
169+ splashsurfcmd = " splashsurf"
170+ else
171+ try
172+ run (pipeline (` $(splashsurf) -V` , stdout = devnull , stderr = devnull ))
173+ catch e
174+ if isa (e, Base. IOError) # splashsurf 未安装
175+ @warn """ invalid splashsurf path
176+ Cannot find splashsurf on this system. If you need surface reconstruction, please
177+ install it first, and make sure Julia can find it.
178+ Or you can pass the path of splashsurf to ply2surface.
179+ link: https://github.com/InteractiveComputerGraphics/splashsurf
180+ """
181+ end
182+ end
183+ splashsurfcmd = splashsurf
184+ end
185+
155186 num_threads = 1 ≤ num_threads ≤ Sys. CPU_THREADS ? num_threads : Sys. CPU_THREADS
156187 splash_dir ≠ ply_dir || throw (ArgumentError (
157188 " The splash output directory should be different from the ply input directory" ))
158189 isdir (splash_dir) || mkpath (splash_dir)
159190 if isfile (ply_dir)
160191 inputs = ply_dir
161192 outputs = joinpath (splash_dir, " surface.vtk" )
162- run (` splashsurf reconstruct $(inputs) --output-file=$(outputs)
193+ run (` $(splashsurfcmd) reconstruct $(inputs) --output-file=$(outputs)
163194 --particle-radius=$(radius* 1.5 )
164195 --cube-size=$(cube_size)
165196 --surface-threshold=$(surface_threshold)
@@ -174,7 +205,7 @@ function ply2surface(
174205 elseif isdir (ply_dir)
175206 inputs = joinpath (ply_dir, " iteration_{}.ply" )
176207 outputs = joinpath (splash_dir, " iteration_{}.vtk" )
177- run (` splashsurf reconstruct $(inputs) --output-file=$(outputs)
208+ run (` $(splashsurfcmd) reconstruct $(inputs) --output-file=$(outputs)
178209 --particle-radius=$(radius* 1.5 )
179210 --cube-size=$(cube_size)
180211 --surface-threshold=$(surface_threshold)
0 commit comments