Repository navigation
Expand file tree
/
Copy pathextract.py
More file actions
155 lines (122 loc) · 5.88 KB
/
Copy pathextract.py
File metadata and controls
155 lines (122 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# trace generated using paraview version 5.6.0
#
# To ensure correct image size when batch processing, please search
# for and uncomment the line `# renderView*.ViewSize = [*,*]`
#### import the simple module from the paraview
from paraview.simple import *
import sys
import argparse
################# CLI ARGUMENT CONFIG ##################
# Setting up Argument parsing
parser = argparse.ArgumentParser(description='A Utility package to generate STL from PLY file')
parser.add_argument('--input', default=None, type=str, help="Path to your PLY (Model.ply)")
parser.add_argument('--output', default=None, type=str, help="Path to your output STL (Model.stl)");
args = parser.parse_args()
#########################################################
# If arguments are invalid or none then exit the script with error !
if (args.input == None or args.output == None):
parser.print_help()
sys.exit(0)
print("GENERATING STL FROM PLY");
input_file = args.input
output_file = args.output
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# create a new 'PLY Reader'
modelply = PLYReader(FileNames=[input_file])
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1515, 776]
# show data in view
modelplyDisplay = Show(modelply, renderView1)
# trace defaults for the display properties.
modelplyDisplay.Representation = 'Surface'
modelplyDisplay.ColorArrayName = [None, '']
modelplyDisplay.OSPRayScaleArray = 'TCoords'
modelplyDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
modelplyDisplay.SelectOrientationVectors = 'None'
modelplyDisplay.ScaleFactor = 0.024037830531597137
modelplyDisplay.SelectScaleArray = 'None'
modelplyDisplay.GlyphType = 'Arrow'
modelplyDisplay.GlyphTableIndexArray = 'None'
modelplyDisplay.GaussianRadius = 0.0012018915265798568
modelplyDisplay.SetScaleArray = ['POINTS', 'TCoords']
modelplyDisplay.ScaleTransferFunction = 'PiecewiseFunction'
modelplyDisplay.OpacityArray = ['POINTS', 'TCoords']
modelplyDisplay.OpacityTransferFunction = 'PiecewiseFunction'
modelplyDisplay.DataAxesGrid = 'GridAxesRepresentation'
modelplyDisplay.SelectionCellLabelFontFile = ''
modelplyDisplay.SelectionPointLabelFontFile = ''
modelplyDisplay.PolarAxes = 'PolarAxesRepresentation'
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
modelplyDisplay.DataAxesGrid.XTitleFontFile = ''
modelplyDisplay.DataAxesGrid.YTitleFontFile = ''
modelplyDisplay.DataAxesGrid.ZTitleFontFile = ''
modelplyDisplay.DataAxesGrid.XLabelFontFile = ''
modelplyDisplay.DataAxesGrid.YLabelFontFile = ''
modelplyDisplay.DataAxesGrid.ZLabelFontFile = ''
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
modelplyDisplay.PolarAxes.PolarAxisTitleFontFile = ''
modelplyDisplay.PolarAxes.PolarAxisLabelFontFile = ''
modelplyDisplay.PolarAxes.LastRadialAxisTextFontFile = ''
modelplyDisplay.PolarAxes.SecondaryRadialAxesTextFontFile = ''
# reset view to fit data
renderView1.ResetCamera()
# get the material library
materialLibrary1 = GetMaterialLibrary()
# update the view to ensure updated data information
renderView1.Update()
# create a new 'Transform'
transform1 = Transform(Input=modelply)
transform1.Transform = 'Transform'
# Properties modified on transform1.Transform
transform1.Transform.Translate = [0.0, -0.328, -0.0415]
transform1.Transform.Rotate = [180.0, 0.0, 0.0]
# show data in view
transform1Display = Show(transform1, renderView1)
# trace defaults for the display properties.
transform1Display.Representation = 'Surface'
transform1Display.ColorArrayName = [None, '']
transform1Display.OSPRayScaleArray = 'TCoords'
transform1Display.OSPRayScaleFunction = 'PiecewiseFunction'
transform1Display.SelectOrientationVectors = 'None'
transform1Display.ScaleFactor = 0.024037832021713258
transform1Display.SelectScaleArray = 'None'
transform1Display.GlyphType = 'Arrow'
transform1Display.GlyphTableIndexArray = 'None'
transform1Display.GaussianRadius = 0.0012018916010856629
transform1Display.SetScaleArray = ['POINTS', 'TCoords']
transform1Display.ScaleTransferFunction = 'PiecewiseFunction'
transform1Display.OpacityArray = ['POINTS', 'TCoords']
transform1Display.OpacityTransferFunction = 'PiecewiseFunction'
transform1Display.DataAxesGrid = 'GridAxesRepresentation'
transform1Display.SelectionCellLabelFontFile = ''
transform1Display.SelectionPointLabelFontFile = ''
transform1Display.PolarAxes = 'PolarAxesRepresentation'
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
transform1Display.DataAxesGrid.XTitleFontFile = ''
transform1Display.DataAxesGrid.YTitleFontFile = ''
transform1Display.DataAxesGrid.ZTitleFontFile = ''
transform1Display.DataAxesGrid.XLabelFontFile = ''
transform1Display.DataAxesGrid.YLabelFontFile = ''
transform1Display.DataAxesGrid.ZLabelFontFile = ''
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
transform1Display.PolarAxes.PolarAxisTitleFontFile = ''
transform1Display.PolarAxes.PolarAxisLabelFontFile = ''
transform1Display.PolarAxes.LastRadialAxisTextFontFile = ''
transform1Display.PolarAxes.SecondaryRadialAxesTextFontFile = ''
# hide data in view
Hide(modelply, renderView1)
# update the view to ensure updated data information
renderView1.Update()
# save data
SaveData(output_file, proxy=transform1, FileType='Ascii')
#### saving camera placements for all active views
# current camera placement for renderView1
renderView1.CameraPosition = [0.00048365816473960876, -0.013336770236492157, 0.6907360276912337]
renderView1.CameraFocalPoint = [0.00048365816473960876, -0.013336770236492157, -0.0049173831939697266]
renderView1.CameraParallelScale = 0.18004835152761986
#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).