Annotation of OpenXM/src/kan96xx/trans/polymake.sm1, Revision 1.4
1.4 ! takayama 1: % $OpenXM: OpenXM/src/kan96xx/trans/polymake.sm1,v 1.3 2003/12/06 02:49:22 takayama Exp $
1.1 takayama 2: % It is a polymake interface
3:
4: /polymake.start {
5: (ox.k0.loaded) boundp { }
1.3 takayama 6: { [(parse) (ox.sm1) pushfile] extension
7: /@@@polymake.k0.ccc [ ] def
8: } ifelse
9: @@@polymake.k0.ccc [ ] eq {
10: k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def
11: @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap
1.1 takayama 12: } { } ifelse
1.3 takayama 13: @@@polymake.k0.ccc 0 get (closed) eq {
14: k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def
15: @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap
1.1 takayama 16: } { } ifelse
17: [(which) (polymake)] oxshell tag 0 eq {
18: [(export) (PATH) (=) (/usr/local/polymake/bin:${PATH})] oxshell
19: [(which) (polymake)] oxshell tag 0 eq {
20: (Polymake is not installed in this system.) error
21: } { } ifelse
22: } { } ifelse
23: [(which) (polymake2tfb)] oxshell tag 0 eq {
24: (polymake2tfb is not installed in this system.) error
25: } { } ifelse
26: } def
27:
28: %[(FACETS) (polymake.data(polymake.POINTS([[1,0,0],[1,1,0],[1,0,1],[1,0,0]])))]
29: % doPolymake
30: % [ tfb-string tree error]
31: [(doPolymake)
1.4 ! takayama 32: [(It calls polymake via oxshell and ox_k0 to make several construction for polytopes.)
1.1 takayama 33: ([action data_in_polymake_tfb_format] doPolymake )
34: ( [result_in_tfb result_in_tree errors])
35: (polymake, polymake2tfb, ox_k0 must be installed.)
1.4 ! takayama 36: (cf. @@@polymake.k0.ccc, kan96xx/Doc/oxshell.*, kan96xx/trans/polymake.sm1, oxshell )
! 37: (The variable @@@doPolymake.vars keeps session logs with the polymake)
1.1 takayama 38: (Example:)
39: % ( [(export) (PATH) (=) (/usr/local/polymake/bin:${PATH})] oxshell )
1.2 takayama 40: $ [(FACETS) (polymake.data(polymake.POINTS([[1,0,0],[1,1,0],[1,0,1],[1,1,1]])))]$
1.1 takayama 41: ( doPolymake /rr set )
42: ]] putUsages
43: /doPolymake {
44: /arg1 set
45: [/in-doPolymake /pAction /pData /pNative /ptree
46: /pResult /pError
47: ] pushVariables
48: [
49: arg1 0 get /pAction set
50: arg1 1 get /pData set
51: polymake.start
52:
53: /pError [ ] def
54: %% step 1: polymake tfb ===> polymake native data
1.3 takayama 55: @@@polymake.k0.ccc ( polymake=Object; ) oxexecutestring
56: @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring
57: @@@polymake.k0.ccc [pData ( ;)] cat oxexecutestring
58: @@@polymake.k0.ccc oxpopcmo /ptree set
59: @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring
1.1 takayama 60: [(treeToPolymake) ptree] extension /pNative set
1.4 ! takayama 61: [pNative pAction] /@@@doPolymake.vars set %for debug
1.1 takayama 62: %% step 2: calling the polymake
1.4 ! takayama 63: [(polymake) (stringInOut://pNative) pAction] addStdoutStderr
1.1 takayama 64: oxshell pop
65: pError [@@@stdout @@@stderr] append /pError set
1.4 ! takayama 66: @@@doPolymake.vars [pNative @@@stdout] append /@@@doPolymake.vars set %for debug
! 67: @@@stdout /pNative set %output file of polymake is XML file. Use old output format.
1.1 takayama 68: %% step 3: polymake native data to polymake tfb
69: [(polymake2tfb) (<) (stringIn://pNative) (>) (stringOut://pResult)
70: (2>) (stringOut://@@@stderr)] oxshell pop
71: pError [@@@stderr] append /pError set
72: %% step 4: get also tree style data.
1.3 takayama 73: @@@polymake.k0.ccc ( polymake=Object; ) oxexecutestring
74: @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring
75: @@@polymake.k0.ccc [pResult ( ;)] cat oxexecutestring
76: @@@polymake.k0.ccc oxpopcmo /ptree set
77: @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring
1.1 takayama 78: [pResult ptree pError] /arg1 set
1.3 takayama 79: ] pop
80: popVariables
81: arg1
82: } def
83:
84: [(tfbToTree)
85: [(tfb-expression-in-string tfbToTree tree)
86: (tfbToTree translates expressions in tfb/2 into tree form.)
87: (Bug: the input is parsed by k0, so the symbol name given agrees with)
88: ( a k0 symbol, it returns a strange answer.)
89: $Example: ( C+intpath.circle(0,1/2) ) tfbToTree :: $
90: ]] putUsages
91:
92: /tfbToTree {
93: /arg1 set
94: [/in-tfbToTree /pAction /pData /pNative /ptree
95: /pResult /pError /i
96: ] pushVariables
97: [
98: arg1 /pData set
99: polymake.start
100:
101: /pError [ ] def
102: %% tfb ===> CMO tree.
103: @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring
104: @@@polymake.k0.ccc [pData ( ;)] cat oxexecutestring
105: @@@polymake.k0.ccc oxpopcmo /ptree set
106: @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring
107: /arg1 ptree def
1.1 takayama 108: ] pop
109: popVariables
110: arg1
111: } def
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>