=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/trans/polymake.sm1,v retrieving revision 1.1 retrieving revision 1.8 diff -u -p -r1.1 -r1.8 --- OpenXM/src/kan96xx/trans/polymake.sm1 2003/12/04 07:49:24 1.1 +++ OpenXM/src/kan96xx/trans/polymake.sm1 2013/09/25 07:30:52 1.8 @@ -1,21 +1,30 @@ -% $OpenXM$ +% $OpenXM: OpenXM/src/kan96xx/trans/polymake.sm1,v 1.7 2013/09/22 05:17:17 takayama Exp $ % It is a polymake interface -/polymake.start { +/@@@polymake.ask.which 1 def +/polymake.start { polymake.start.local } def +/polymake.start.local { (ox.k0.loaded) boundp { } - { [(parse) (ox.sm1) pushfile] extension } ifelse - oxk0.ccc [ ] eq { - k0connectr oxk0.ccc oxsetmathcap oxk0.ccc oxmathcap + { [(parse) (ox.sm1) pushfile] extension + /@@@polymake.k0.ccc [ ] def + } ifelse + @@@polymake.k0.ccc [ ] eq { + k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def + @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap } { } ifelse - oxk0.ccc 0 get (closed) eq { - k0connectr oxk0.ccc oxsetmathcap oxk0.ccc oxmathcap + @@@polymake.k0.ccc 0 get (closed) eq { + k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def + @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap } { } ifelse + [(parse) ( 1 )] extension pop % BUG, dummy to avoid bus error on mac.2013.09.21 + @@@polymake.ask.which { [(which) (polymake)] oxshell tag 0 eq { [(export) (PATH) (=) (/usr/local/polymake/bin:${PATH})] oxshell [(which) (polymake)] oxshell tag 0 eq { (Polymake is not installed in this system.) error } { } ifelse } { } ifelse + } { } ifelse [(which) (polymake2tfb)] oxshell tag 0 eq { (polymake2tfb is not installed in this system.) error } { } ifelse @@ -25,16 +34,21 @@ % doPolymake % [ tfb-string tree error] [(doPolymake) -[(It calls polymake to make several construction for polytopes.) +[(It calls polymake via oxshell and ox_k0 to make several construction for polytopes.) ([action data_in_polymake_tfb_format] doPolymake ) ( [result_in_tfb result_in_tree errors]) (polymake, polymake2tfb, ox_k0 must be installed.) + (cf. @@@polymake.k0.ccc, kan96xx/Doc/oxshell.*, kan96xx/trans/polymake.sm1, oxshell ) + (The variable @@@doPolymake.vars keeps session logs with the polymake) + (See also usePolymake.local, usePolymake.OoHG.native and usePolymake.OoHG.curl in cgi.sm1) (Example:) % ( [(export) (PATH) (=) (/usr/local/polymake/bin:${PATH})] oxshell ) - $ [(FACETS) (polymake.data(polymake.POINTS([[1,0,0],[1,1,0],[1,0,1],[1,0,0]])))]$ + $ [(FACETS) (polymake.data(polymake.POINTS([[1,0,0],[1,1,0],[1,0,1],[1,1,1/2]])))]$ ( doPolymake /rr set ) + ( Keys---properties are FACETS, CONE_DIM, LINEARITY_DIM, FEASIBLE, AFFINE_FULL, ... ) ]] putUsages -/doPolymake { +/doPolymake { doPolymake.local } def +/doPolymake.local { /arg1 set [/in-doPolymake /pAction /pData /pNative /ptree /pResult /pError @@ -46,27 +60,59 @@ /pError [ ] def %% step 1: polymake tfb ===> polymake native data - oxk0.ccc ( polymake=Object; ) oxexecutestring - oxk0.ccc ( QuoteMode(1); ) oxexecutestring - oxk0.ccc [pData ( ;)] cat oxexecutestring - oxk0.ccc oxpopcmo /ptree set - oxk0.ccc ( QuoteMode(0); ) oxexecutestring + @@@polymake.k0.ccc ( polymake=Object; ) oxexecutestring + @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring + @@@polymake.k0.ccc [pData ( ;)] cat oxexecutestring + @@@polymake.k0.ccc oxpopcmo /ptree set + @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring [(treeToPolymake) ptree] extension /pNative set + [ptree pNative pAction] /@@@doPolymake.vars set %for debug %% step 2: calling the polymake - [(polymake) (stringInOut://pNative.poly) pAction] addStdoutStderr + [(polymake) (stringInOut://pNative) pAction] addStdoutStderr oxshell pop pError [@@@stdout @@@stderr] append /pError set + @@@doPolymake.vars [pNative @@@stdout] append /@@@doPolymake.vars set %for debug + @@@stdout /pNative set %output file of polymake is XML file. Use old output format. %% step 3: polymake native data to polymake tfb [(polymake2tfb) (<) (stringIn://pNative) (>) (stringOut://pResult) (2>) (stringOut://@@@stderr)] oxshell pop pError [@@@stderr] append /pError set %% step 4: get also tree style data. - oxk0.ccc ( polymake=Object; ) oxexecutestring - oxk0.ccc ( QuoteMode(1); ) oxexecutestring - oxk0.ccc [pResult ( ;)] cat oxexecutestring - oxk0.ccc oxpopcmo /ptree set - oxk0.ccc ( QuoteMode(0); ) oxexecutestring + @@@polymake.k0.ccc ( polymake=Object; ) oxexecutestring + @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring + @@@polymake.k0.ccc [pResult ( ;)] cat oxexecutestring + @@@polymake.k0.ccc oxpopcmo /ptree set + @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring [pResult ptree pError] /arg1 set + ] pop + popVariables + arg1 +} def + +[(tfbToTree) +[(tfb-expression-in-string tfbToTree tree) + (tfbToTree translates expressions in tfb/2 into tree form.) + (Bug: the input is parsed by k0, so the symbol name given agrees with) + ( a k0 symbol, it returns a strange answer.) + $Example: ( C+intpath.circle(0,1/2) ) tfbToTree :: $ +]] putUsages + +/tfbToTree { + /arg1 set + [/in-tfbToTree /pAction /pData /pNative /ptree + /pResult /pError /i + ] pushVariables + [ + arg1 /pData set + polymake.start + + /pError [ ] def +%% tfb ===> CMO tree. + @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring + @@@polymake.k0.ccc [pData ( ;)] cat oxexecutestring + @@@polymake.k0.ccc oxpopcmo /ptree set + @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring + /arg1 ptree def ] pop popVariables arg1