1 /* --------------------------------------------------------------------  */
2 /*                          CALCULIX                                     */
3 /*                   - GRAPHICAL INTERFACE -                             */
4 /*                                                                       */
5 /*     A 3-dimensional pre- and post-processor for finite elements       */
6 /*              Copyright (C) 1996 Klaus Wittig                          */
7 /*                                                                       */
8 /*     This program is free software; you can redistribute it and/or     */
9 /*     modify it under the terms of the GNU General Public License as    */
10 /*     published by the Free Software Foundation; version 2 of           */
11 /*     the License.                                                      */
12 /*                                                                       */
13 /*     This program is distributed in the hope that it will be useful,   */
14 /*     but WITHOUT ANY WARRANTY; without even the implied warranty of    */
15 /*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      */
16 /*     GNU General Public License for more details.                      */
17 /*                                                                       */
18 /*     You should have received a copy of the GNU General Public License */
19 /*     along with this program; if not, write to the Free Software       */
20 /*     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         */
21 /* --------------------------------------------------------------------  */
22 
23 #include <cgx.h>
24 
25 #define MAX_GSUR_PARAMERTER 7
26 extern SpecialSet specialset[1];
27 extern Eqal eqal;
28 extern Psets     *pset;
29 
writebp(char * setname,Summen * anz,SumGeo * anzGeo,Points * pnt,Sets * set)30 int writebp(char *setname, Summen *anz, SumGeo *anzGeo, Points *pnt, Sets *set )
31 {
32   FILE *handle1;
33   FILE *handle2;
34   int  i, j, k, n, p;
35   char string[MAX_LINE_LENGTH], datout[2][MAX_LINE_LENGTH], buffer[MAX_LINE_LENGTH];
36   int length, setNr;
37 
38   setNr=getSetNr(setname);
39   if (setNr<0)
40   {
41     printf (" ERROR: set:%s does not exist\n", setname);
42     return (-1);
43   }
44 
45   length=sword( setname, string);
46   string[length]='.';
47   string[length+1]='b';
48   string[length+2]='p';
49   string[length+3]='\0';
50   strcpy( datout[0], string);
51   string[length+1]='s';
52   string[length+2]='t';
53   string[length+3]='p';
54   string[length+4]='\0';
55   strcpy( datout[1], string);
56 
57 
58   /* Open the files and check to see that it was opened correctly */
59   /* bp-file for cad department */
60   handle1 = fopen (datout[0], "w+b");
61   if (handle1==NULL) { printf ("\nThe output file \"%s\" could not be opened.\n\n", datout[0]); return(-1);}
62   else  printf ("\n%s opened\n",datout[0]);
63 
64   /* step-file for cad department */
65   handle2 = fopen (datout[1], "w+b");
66   if (handle2==NULL) { printf ("\nThe output file \"%s\" could not be opened.\n\n", datout[1]); return(-1);}
67   else  printf ("\n%s opened\n",datout[1]);
68 
69   printf ("\n write bp (bulk-point)\n The common points of the specified set and all sets matching 'SS<nr>' will be written\n");
70   printf (" continue with: 'stp2vda <set>.stp up|do' 'tomeshvl' etc.\n\n");
71   delSet(specialset->tmp);
72 
73   fprintf (handle1, "written by cgx\n");
74   fprintf (handle2, "HEADER;\n/* written by cgx to be used by stp2vda, file does not conform to any norm */\n");
75 
76   k=0;
77   for(n=0; n<anz->sets; n++)
78   {
79     if (set[n].name!= (char *)NULL)
80     for(j=0; j<100; j++)
81     {
82       sprintf(buffer,"SS%d", j);
83       if (strlen(set[n].name)==strlen(buffer)) if( compare( set[n].name, buffer, strlen(set[n].name))==strlen(buffer)) k++;
84     }
85   }
86   fprintf (handle1, "%5i\n",k);
87 
88   for(n=0; n<anz->sets; n++)
89   {
90     if (set[n].name!= (char *)NULL)
91     for(j=0; j<100; j++)
92     {
93       sprintf(buffer,"SS%d", j);
94       if (strlen(set[n].name)==strlen(buffer)) if( compare( set[n].name, buffer, strlen(set[n].name))==strlen(buffer))
95       {
96         printf("%s %s\n",set[n].name,buffer );
97         k=0;
98         for (i=0; i<set[n].anz_p; i++)
99 	{
100           if( getIndex(&set[setNr].pnt,set[setNr].anz_p,set[n].pnt[i]) >-1) k++;
101 	}
102         printf ("%5i pnts written\n",k);
103         fprintf (handle1, "%5i    3    1   10\n",k);
104         for (p=0; p<set[n].anz_p; p++)
105 	{
106           if( getIndex(&set[setNr].pnt,set[setNr].anz_p,set[n].pnt[p]) >-1)
107 	  {
108             i=set[n].pnt[p];
109             if( pnt[i].name != (char *)NULL )
110 	    {
111               fprintf (handle1, "%10.4lf%10.4lf%10.4lf\n", pnt[i].px,pnt[i].py,pnt[i].pz);
112               fprintf (handle2, "#%d=CARTESIAN_POINT\(\'%s\',\(%10.4lf,%10.4lf,%10.4lf\)\);\n", i+1,set[n].name,pnt[i].px,pnt[i].py,pnt[i].pz);
113 	      //#484=CARTESIAN_POINT('',(40.695580000019,176.223812949467,0.));
114 	    }
115           }
116         }
117       }
118     }
119   }
120 
121 
122   fprintf (handle1, "\n");
123   fclose(handle1);
124   fclose(handle2);
125 
126   /* create an empty  hdr file for prg tomeshvl */
127   system("touch hdr");
128   return (1);
129 }
130 
131 
132 
133 
134 
135