[英]Difficulty piping with qhull through python
我在python中通過QHull傳遞命令時遇到麻煩。 我目前正在嘗試這樣做:
input_command = "rbox c " + str(qpoints) + " | qconvex FQ FV n"
command = subprocess.Popen(input_command.split(" "), stdout=subprocess.PIPE)
print command.communicate()[0]
在這里,qpoints的格式設置為使input_command結束為:
rbox c P0,0,0 P0,0,2 P0,2,0 P0,2,2 P2,0,0 P2,0,2 P2,2,0 P2,2,2 | qconvex FQ FV n
但是不幸的是,這只是打印出qconvex的用法:
qconvex- compute the convex hull. Qhull 2012.1 2012/02/18
input (stdin): dimension, number of points, point coordinates
comments start with a non-numeric character
options (qconvex.htm):
Qt - triangulated output
QJ - joggled input instead of merged facets
Tv - verify result: structure, convexity, and point inclusion
. - concise list of all options
- - one-line description of all options
output options (subset):
s - summary of results (default)
i - vertices incident to each facet
n - normals with offsets
p - vertex coordinates (includes coplanar points if 'Qc')
Fx - extreme points (convex hull vertices)
FA - report total area and volume
FS - compute total area and volume
o - OFF format (dim, n, points, facets)
G - Geomview output (2-d, 3-d, and 4-d)
m - Mathematica output (2-d and 3-d)
QVn - print facets that include point n, -n if not
TO file- output results to file, may be enclosed in single quotes
examples:
rbox c D2 | qconvex s n rbox c D2 | qconvex i
rbox c D2 | qconvex o rbox 1000 s | qconvex s Tv FA
rbox c d D2 | qconvex s Qc Fx rbox y 1000 W0 | qconvex s n
rbox y 1000 W0 | qconvex s QJ rbox d G1 D12 | qconvex QR0 FA Pp
rbox c D7 | qconvex FA TF1000
我已經在線閱讀了一些在python調用中包含管道時必須采取的額外步驟的示例。 但是我無法獲得它們的任何示例,而且幾乎沒有任何解釋。 有人可以在這里向我解釋一個有效的代碼段,以及為什么有效嗎?
我也嘗試從文件中讀取一個函數的結果。 例如,我嘗試從文件讀取rbox的結果:
python代碼:
input_command = "qconvex FQ FV n < rbox.txt"
command = subprocess.Popen(input_command.split(" "), shell=True)
result = command.communicate()
return result
數據:
3 rbox c P1,1,1 P1,1,3 P1,3,1 P1,3,3 P3,1,1 P3,1,3 P3,3,1 P3,3,3
16
1 1 1
1 1 3
1 3 1
1 3 3
3 1 1
3 1 3
3 3 1
3 3 3
-0.5 -0.5 -0.5
-0.5 -0.5 0.5
-0.5 0.5 -0.5
-0.5 0.5 0.5
0.5 -0.5 -0.5
0.5 -0.5 0.5
0.5 0.5 -0.5
0.5 0.5 0.5
盡管這仍然只打印出QConvex描述。 奇怪的是,這在命令行上可以很好地工作,而不是通過python。 即使無法使管道正常工作,我也絕對需要從文件讀入才能工作。 有誰知道調用此函數的訣竅是什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.