github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/LPOP_placement.go (about)

     1  //This file is part of EESLISM.
     2  //
     3  //Foobar is free software : you can redistribute itand /or modify
     4  //it under the terms of the GNU General Public License as published by
     5  //the Free Software Foundation, either version 3 of the License, or
     6  //(at your option) any later version.
     7  //
     8  //Foobar is distributed in the hope that it will be useful,
     9  //but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
    11  //GNU General Public License for more details.
    12  //
    13  //You should have received a copy of the GNU General Public License
    14  //along with Foobar.If not, see < https://www.gnu.org/licenses/>.
    15  
    16  /*
    17  
    18   LPとOPの位置をCGで確認するための入力ファイルを作成する
    19   FILE=LPOP_placement.c
    20   Create Date=2006.11.4
    21  */
    22  package eeslism
    23  
    24  import (
    25  	"fmt"
    26  	"os"
    27  )
    28  
    29  func HOUSING_PLACE(lpn, mpn int, lp, mp []P_MENN, RET string) {
    30  
    31  	mlpn := lpn + mpn
    32  
    33  	NAMAE1 := RET + "_placeLP.gchi"
    34  	fp1, err := os.Create(NAMAE1)
    35  	if err != nil {
    36  		fmt.Println("File not open _placeLP.gchi")
    37  		os.Exit(1)
    38  	}
    39  	defer fp1.Close()
    40  
    41  	NAMAE2 := RET + "_placeOP.gchi"
    42  	fp2, err := os.Create(NAMAE2)
    43  	if err != nil {
    44  		fmt.Println("File not open _placeOP.gchi")
    45  		os.Exit(1)
    46  	}
    47  	defer fp2.Close()
    48  
    49  	NAMAE3 := RET + "_placeALL.gchi"
    50  	fp3, err := os.Create(NAMAE3)
    51  	if err != nil {
    52  		fmt.Println("File not open _placeALL.gchi")
    53  		os.Exit(1)
    54  	}
    55  	defer fp3.Close()
    56  
    57  	fmt.Fprintf(fp1, "%d ", lpn)
    58  	fmt.Fprintf(fp3, "%d ", mlpn)
    59  	for i := 0; i < lpn; i++ {
    60  		fmt.Fprintf(fp1, "%s %d\n", lp[i].opname, lp[i].polyd)
    61  		fmt.Fprintf(fp3, "%s %d\n", lp[i].opname, lp[i].polyd)
    62  		fmt.Fprintf(fp1, "%f %f %f\n", lp[i].rgb[0], lp[i].rgb[1], lp[i].rgb[2])
    63  		fmt.Fprintf(fp3, "%f %f %f\n", lp[i].rgb[0], lp[i].rgb[1], lp[i].rgb[2])
    64  		for j := 0; j < lp[i].polyd; j++ {
    65  			fmt.Fprintf(fp1, "%f %f %f\n", lp[i].P[j].X, lp[i].P[j].Y, lp[i].P[j].Z)
    66  			fmt.Fprintf(fp3, "%f %f %f\n", lp[i].P[j].X, lp[i].P[j].Y, lp[i].P[j].Z)
    67  		}
    68  	}
    69  
    70  	fmt.Fprintf(fp2, "%d ", mpn)
    71  	for i := 0; i < mpn; i++ {
    72  		fmt.Fprintf(fp2, "%s %d\n", mp[i].opname, mp[i].polyd)
    73  		fmt.Fprintf(fp3, "%s %d\n", mp[i].opname, mp[i].polyd)
    74  		fmt.Fprintf(fp2, "%f %f %f\n", mp[i].rgb[0], mp[i].rgb[1], mp[i].rgb[2])
    75  		fmt.Fprintf(fp3, "%f %f %f\n", mp[i].rgb[0], mp[i].rgb[1], mp[i].rgb[2])
    76  		for j := 0; j < mp[i].polyd; j++ {
    77  			fmt.Fprintf(fp2, "%f %f %f\n", mp[i].P[j].X, mp[i].P[j].Y, mp[i].P[j].Z)
    78  			fmt.Fprintf(fp3, "%f %f %f\n", mp[i].P[j].X, mp[i].P[j].Y, mp[i].P[j].Z)
    79  		}
    80  	}
    81  }