Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/post/src/modules/transforms.c
3203 views
1
/*****************************************************************************
2
*
3
* Elmer, A Finite Element Software for Multiphysical Problems
4
*
5
* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program (in file fem/GPL-2); if not, write to the
19
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
* Boston, MA 02110-1301, USA.
21
*
22
*****************************************************************************/
23
24
/*******************************************************************************
25
*
26
* Object transformation routines.
27
*
28
*******************************************************************************
29
*
30
* Author: Juha Ruokolainen
31
*
32
* Address: CSC - IT Center for Science Ltd.
33
* Keilaranta 14, P.O. BOX 405
34
* 02101 Espoo, Finland
35
* Tel. +358 0 457 2723
36
* Telefax: +358 0 457 2302
37
* EMail: [email protected]
38
*
39
* Date: 6 Jun 1996
40
*
41
* Modified by:
42
*
43
* Date of modification:
44
*
45
******************************************************************************/
46
47
48
/*
49
* $Id: transforms.c,v 1.3 1999/06/03 14:12:40 jpr Exp $
50
*
51
* $Log: transforms.c,v $
52
* Revision 1.3 1999/06/03 14:12:40 jpr
53
* *** empty log message ***
54
*
55
* Revision 1.2 1998/08/01 12:35:03 jpr
56
*
57
* Added Id, started Log.
58
*
59
*
60
*/
61
62
#include "../elmerpost.h"
63
64
#include <tcl.h>
65
#include <tk.h>
66
67
68
static int TrnPriority(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
69
{
70
static int first=TRUE,n,prior;
71
double x=0,y=0,z=0;
72
73
if ( argc != 2 )
74
{
75
sprintf( interp->result, "cTrnPriority: wrong number of parameters\n" );
76
return TCL_ERROR;
77
}
78
79
n = sscanf( argv[1], "%d", &prior );
80
81
if ( n <= 0 )
82
{
83
sprintf( interp->result, "cTrnPriority: wrong number of parameters\n" );
84
return TCL_ERROR;
85
}
86
87
obj_set_transform_priority( CurrentObject,prior );
88
89
return TCL_OK;
90
}
91
92
static int RotPriority(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
93
{
94
static int first=TRUE,n,prior;
95
double x=0,y=0,z=0;
96
97
if ( argc != 2 )
98
{
99
sprintf( interp->result, "cRotPrioryty: wrong number of parameters\n" );
100
return TCL_ERROR;
101
}
102
103
n = sscanf( argv[1], "%d", &prior );
104
105
if ( n <= 0 )
106
{
107
sprintf( interp->result, "cRotPriority: wrong number of parameters\n" );
108
return TCL_ERROR;
109
}
110
111
if ( prior > 7 )
112
{
113
if ( CurrentObject == &VisualObject )
114
CurrentObject = VisualObject.Next;
115
else
116
CurrentObject = &VisualObject;
117
118
return TCL_OK;
119
}
120
121
obj_set_rotation_priority( CurrentObject,prior );
122
123
return TCL_OK;
124
}
125
126
static int Rotate(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
127
{
128
static int first=TRUE,n;
129
double x=0,y=0,z=0;
130
131
void opengl_draw();
132
133
if ( argc != 4 )
134
{
135
sprintf( interp->result, "cRotate: wrong number of parameters\n" );
136
return TCL_ERROR;
137
}
138
139
n = sscanf( argv[3], "%lf %lf %lf", &x,&y,&z );
140
141
if ( n <= 0 )
142
{
143
sprintf( interp->result, "cRotate: wrong number of parameters\n" );
144
return TCL_ERROR;
145
}
146
147
obj_rotate( CurrentObject,x,y,z,argv[1][0],argv[2][0]=='r' );
148
149
opengl_draw();
150
151
return TCL_OK;
152
}
153
154
static int Scale(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
155
{
156
static int n,first=TRUE;
157
double x,y,z;
158
void opengl_draw();
159
160
if ( argc != 4 )
161
{
162
sprintf( interp->result, "cScale: wrong number of parameters\n" );
163
return TCL_ERROR;
164
}
165
166
if ( (n=sscanf( argv[3], "%lf %lf %lf", &x,&y,&z )) < 3 ) { y = x; z = x; }
167
168
if ( n <= 0 )
169
{
170
sprintf( interp->result, "cScale: wrong number of parameters\n" );
171
return TCL_ERROR;
172
}
173
174
obj_scale( CurrentObject,x,y,z,argv[1][0],argv[2][0]=='r' );
175
176
opengl_draw();
177
178
return TCL_OK;
179
}
180
181
static int Translate(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
182
{
183
static int n,first=TRUE;
184
double x=0,y=0,z=0;
185
void opengl_draw(), obj_translate();
186
187
if ( argc != 4 )
188
{
189
sprintf( interp->result, "cScale: wrong number of parameters\n" );
190
return TCL_ERROR;
191
}
192
193
if ( (n = sscanf( argv[3], "%lf %lf %lf", &x,&y,&z ) ) <= 0 )
194
{
195
sprintf( interp->result, "cScale: wrong number of parameters\n" );
196
return TCL_ERROR;
197
}
198
199
obj_translate( CurrentObject,x,y,z,argv[1][0],argv[2][0]=='r' );
200
201
opengl_draw();
202
203
return TCL_OK;
204
}
205
206
int Transforms_Init( Tcl_Interp *interp )
207
{
208
Tcl_CreateCommand( interp,"cTranslate",(void *)Translate,(ClientData)NULL,(Tcl_CmdDeleteProc *)NULL);
209
Tcl_CreateCommand( interp,"cScale",(void *)Scale,(ClientData)NULL,(Tcl_CmdDeleteProc *)NULL);
210
Tcl_CreateCommand( interp,"cRotate",(void *)Rotate,(ClientData)NULL,(Tcl_CmdDeleteProc *)NULL);
211
Tcl_CreateCommand( interp,"cRotPriority",(void *)RotPriority,(ClientData)NULL,(Tcl_CmdDeleteProc *)NULL);
212
Tcl_CreateCommand( interp,"cTrnPriority",(void *)TrnPriority,(ClientData)NULL,(Tcl_CmdDeleteProc *)NULL);
213
214
return TCL_OK;
215
}
216
217