파이썬으로 QHull을 통해 명령을 파이핑하는 데 문제가 있습니다. 나는 현재이 같은 일을하려고 해요 : 그 input_command과 같이 바람이 있도록파이썬을 통해 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를 포맷 : 불행하게도
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
온라인으로 파이썬 호출에서 파이핑을 포함 할 때 수행해야하는 추가 단계의 예를 읽었습니다. 그러나 나는 일할 수있는 예를 얻을 수 없으며, 무슨 일이 벌어지고 있는지 거의 설명하지 않고있다. 누군가가 나에게 여기에서 코드 스 니펫을 설명하고 작동하는 이유를 설명 할 수 있습니까?
나는 하나의 함수 결과를 파일에서 읽으려고 시도했다. 예를 들어, 내가 파일에서 rbox의 결과를 읽는 시도 :
파이썬 코드 :
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 설명을 출력합니다. 이상한 것은 이것이 파이썬을 통하지 않고 명령 행에서 완벽하게 작동한다는 것입니다. 배관이 작동하지 않을지라도 필자는 파일을 읽고 작업해야합니다. 누구든지 트릭이 함수 호출을 만드는 것입니다 알아?
답장을 보내 주셔서 감사합니다. 지금 그것을 확인하십시오! – user650261
설명과 링크를 위해 고맙습니다. – user650261