jw_cad 外部変形 - (1010) gccで円ソリッドを確認する(sc) -

外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。

 

gccで円ソリッドを確認する(sc)

:gccで円ソリッドを確認する(sc)
@echo off
if not exist %~dpn0.exe (
  for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
    more +%%n %0 > %~dpn0.c
    gcc -Os %~dpn0.c -o %~dpn0.exe -s
  )
)
%~dpn0
goto:eof

REM #jww
REM #h1
REM #hc 円ソリッドを選択してください
REM #e

#!この次の行からプログラムを書いてください
#include "jw.h"

struct __sc__
{
    char sc[4];
    double x;
    double y;
    double r;
    double w;
    double d;
    double p1;
    double p3;
    int cflg;
};

int main(void)
{
  FILE *f, *g;
  int i, NF, scn = 0;
  char S_[256], *F[20];
  char SS[256];
  struct __sc__ sc[101];
  int scno[101];
  if ( (f = fopen("jwc_temp.txt", "r")) != NULL) {
    g = fopen("myfiles", "w");
    while (fgets(S_, 256, f) != NULL) {
      strcpy(SS, chomp(S_));
      NF = split(SS, F);
      if (strncmp(S_, "hq", 2) == 0) { 
        fprintf(g, "hd\n");
        continue;
      }
      if (strncmp(S_, "sc", 2) == 0) {
        scn += 1;
        strcpy(sc[scn].sc, F[0]);
        sc[scn].x = atof(F[1]);
        sc[scn].y = atof(F[2]);
        sc[scn].r = atof(F[3]);
        sc[scn].w = atof(F[4]);
        sc[scn].d = atof(F[5]);
        sc[scn].p1 = atof(F[6]);
        sc[scn].p3 = atof(F[7]);
        sc[scn].cflg = atoi(F[8]);
        scno[scn] = NF;
        continue;
      }
    }
  } else {
    exit(MISSING_JWC_TEMP_TXT);
  }
  for (i = 1; i <= scn; i++) {
    fprintf(g, "lc%d\n", (6+i));
    fprintf(g, "sc %.15lg %.15lg %.15lg %.15lg %.15lg %.15lg %.15lg %d\n", 
                sc[i].x, sc[i].y, sc[i].r, sc[i].w, sc[i].d, sc[i].p1, sc[i].p3, sc[i].cflg);
  }
  fclose(g);
  fclose(f);
  remove("jwc_temp.txt");
  rename("myfiles", "jwc_temp.txt");
  return 0;
}