源玛:
. ^; B; E. Q+ j+ A# F
" {* r$ N) A, S//////////////////////////////////////////////////////////////////////////////
2 V5 l; S/ b4 v5 f9 |- k6 ` h//6 z8 V# g. I' `) q+ B% }& U
// create_oper.cpp1 v9 z# U# _ P9 Q
//3 h, n+ Q, j9 w% v( ?
// Description:# ~; p+ e( Y6 Z- x, @8 M
// Contains Unigraphics entry points for the application.7 d9 g3 t0 u0 i8 z" ?
//
7 C: l$ S- U8 j//////////////////////////////////////////////////////////////////////////////
' V5 Q% Q+ x; }# ~8 m$ }- I7 P R4 s
# C5 l# X. Z- R, E# f// Include files
. g0 F. |' F ]5 S# S& {* U#include <uf.h>
( X+ s# L4 }- d- g' Y9 F9 p$ P#include <uf_exit.h>
( ]6 u. j# A" n* p: H" L1 q#include <uf_ui.h>
" v8 R7 Q4 ~9 u% R5 b#include <uf_oper.h>6 i) {$ x! J: J# ~) a6 ]
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun ), S6 f4 ]$ A# a! m
# include <strstream>
' y6 y. [$ V3 {3 A& I# include <iostream>
$ O# M6 [) E0 ^# P$ v9 {. ^ using std: strstream;8 k- ^) z1 V+ \ A4 n
using std::endl;
+ K: D1 u5 q* M7 x using std::ends;
) I7 o4 ]) o; P1 V using std::cerr;( d( G: U! h. m& ~ @0 i% N% ]
#else
9 ]% b; T* j; j" K0 f# include <strstream.h>: x C ]! k2 N% ?
# include <iostream.h>3 y2 j) B- N: Y$ `) R
#endif
- @1 }6 w" Q( h+ N3 Z#include "create_oper.h"0 u8 t7 u8 O* L3 s# T3 @
+ e v% E6 c! [$ L9 {' d; B" {" t
//----------------------------------------------------------------------------" t- e* J) r' e
// Activation Methods
% D- r2 D: Q: F0 J' ^//----------------------------------------------------------------------------- b2 v7 y" A% ?% u( g
T' P* @. h( p3 z4 M, {+ D8 m) {
// Unigraphics Startup
) E6 f/ F1 G$ N; X4 j, d// This entry point activates the application at Unigraphics startup
. ^+ c/ L9 k3 M) l' yextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )7 W. _; L. h( C& o9 V, ^/ q
{
$ R* D0 P) W$ F8 }$ s /* Initialize the API environment */
7 U8 C+ j' a( X* m) {5 t% u int errorCode = UF_initialize();
1 `; \% |& w9 d) c5 U3 k( g' l. E2 v' }6 N6 c2 X1 M2 `# P6 |2 T
if ( 0 == errorCode )4 K/ M- ]' i: x
{$ h0 @$ O1 f+ @1 T& ^
/* TODO: Add your application code here */
% i: c; T4 Q& }& c( O5 c! |4 Q1 N- J. B, W' X$ u
char *type_name="mill_planar";
8 h* g% r) X, @- O" d char *subtype_name="FACE_MILLING_AREA";* B0 O5 w2 h! N" Q! c* y5 M: }8 Q
tag_t oper_tag;2 q2 Q; K) |9 C9 _0 Q
' c, N3 ?- l9 U& o UF_OPER_create(type_name,subtype_name,&oper_tag);3 ~/ O, M2 q, V) e5 |* c" F
& ]$ ]' g* U& G! D1 q) z4 O% F7 m. g9 R+ |
4 `3 q' ~( k2 j C
0 y9 a \0 f" A( r$ v /* Terminate the API environment */
/ b9 \! n* N* v7 |* Y+ h errorCode = UF_terminate();
# I! x s# |3 I. Q }
* k' W1 S6 O& B0 R# B B, `8 d' u
! _' p3 p4 |8 b; h. h- U! F/ q, @ /* Print out any error messages */
) z* ]4 s/ o- L PrintErrorMessage( errorCode );
0 v/ Q/ L) `4 i5 I0 _* L8 T0 r- q8 s}
. E0 T8 C6 N; y: ~ h9 {# f
8 p% f' o* x+ k# w; X1 `6 X//----------------------------------------------------------------------------/ h0 L' ^3 X8 p# E
// Utilities6 l9 m4 j3 i) x4 o4 l5 @
//----------------------------------------------------------------------------7 k7 f, @6 s, {( O
6 r# L: X1 X9 }7 G// Unload Handler
' @% k s1 W- A4 W6 s5 {5 F1 e// This function specifies when to unload your application from Unigraphics.8 e' m3 r' n+ \* P1 X5 o. I
// If your application registers a callback (from a MenuScript item or a! C+ t0 l! Z' {* K
// User Defined Object for example), this function MUST return
$ n8 K1 L! R1 F3 F4 s// "UF_UNLOAD_UG_TERMINATE".' v6 V" f: G$ r! h# C. s0 F
extern "C" int ufusr_ask_unload( void )
+ u* D) O6 Y" d: N# E{
$ R( Z( }8 |( ?# v4 ~7 k' y return( UF_UNLOAD_UG_TERMINATE );
) k) \- {8 M& C1 X3 Y) K x/ J |}
! g8 N9 G$ s6 Z* w! |
1 A1 T# E- G0 E; W$ B/* PrintErrorMessage; y( _. |* \& T6 E1 K0 W
**. t* o1 d: R- c/ `7 @/ ^8 u
** Prints error messages to standard error and the Unigraphics status/ A. m- j+ B7 C8 L L/ ]+ l
** line. */# H2 o) \# O) w8 @: h; k! p
static void PrintErrorMessage( int errorCode )# w( n$ D) N) |$ c$ P% Y! ~
{: M8 n0 m9 j E5 v" n- `3 [3 a
if ( 0 != errorCode )$ ~8 R0 E* Y. t7 L. R5 a. Q4 B
{7 e/ z: q2 B- y( h! e$ v2 k
/* Retrieve the associated error message */- _* H4 O/ U- G9 V$ V! G
char message[133];
+ n3 m3 [, K" R# P; a UF_get_fail_message( errorCode, message );4 ^5 M6 M T" J
. V3 L7 K# m" i% ?* ? /* Print out the message */
3 X7 Y8 B- B3 `% g2 | UF_UI_set_status( message );! \( n) \) z' f/ |- W
+ A C$ b/ U; P5 V4 M x/ ]5 j
// Construct a buffer to hold the text.
) |# {0 }* Z. |' Q# f: q ostrstream error_message;
( W( q# x' J3 s _ E" H7 \+ u8 d
% N q2 g( H$ F // Initialize the buffer with the required text.
/ `. N. F0 \. l/ v% x! z8 c( l error_message << endl
; x7 k, }# |, v8 { << "Error:" << endl0 B5 `$ g; I w% D& f2 E
<< message' w3 F* {7 u- O. x4 d1 \. X
<< endl << endl << ends;8 N' p9 `' I+ \: N7 n/ i W4 i
1 y! d2 V- U7 ~% x" K
// Write the message to standard error
! \3 t4 {( D: {" L: l. K5 [ cerr << error_message.str();+ }; t7 @* ?! M: ^# g
}
! |# V& R! K' G$ u( N2 R/ X} |