源玛:# q" o, I# ^( h( ~, k( n
- T- y, ?' R1 D2 q! ~1 r//////////////////////////////////////////////////////////////////////////////4 Q. ^3 b6 Q6 R, F
//
' j1 K. q& b8 _2 B// create_oper.cpp
4 k1 K. N0 W4 W: A8 I& ^//
7 G9 s2 L3 A8 e$ P O0 U1 q// Description:
+ r. w9 K, F1 m f9 \8 o: y// Contains Unigraphics entry points for the application.
) l8 ]1 k X& n+ R: m//( g M5 R7 ~& h" |5 G
//////////////////////////////////////////////////////////////////////////////5 I" O, p% x8 a- i+ ^" j
: l' l( P) s: y0 u5 D8 K0 v" s2 p
// Include files/ F) B9 ?$ Y5 S) h
#include <uf.h>7 B% T" m1 m0 h
#include <uf_exit.h>; k% M2 _; C k0 U( n; {- w6 [
#include <uf_ui.h>9 d# _7 R; e. d" c
#include <uf_oper.h>
' Q9 d5 v' j4 N7 K#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
$ c+ G7 g& z9 U z* c# U# include <strstream>
+ T# W1 Y" Y/ S& |; z# include <iostream>7 }, S3 Q5 w2 h' W7 E
using std: strstream;
2 U6 X5 [( t' P8 K ^ using std::endl;
! k% L9 q6 y5 }4 g! g using std::ends;
& N9 i* V+ c3 |: g using std::cerr;' c9 p( m& y) X. t
#else
0 y8 Q: W1 E" s3 Y# include <strstream.h>
, f4 a" ]/ U' ^7 ]# include <iostream.h>
: ?7 p1 O* ]# c9 c, D4 J4 I I9 u#endif
& f% o/ f5 a2 h#include "create_oper.h"
3 h. M2 ]6 H1 H, v
4 T6 o$ ^: m' Y8 e, I- c- g/ ~//----------------------------------------------------------------------------
( Y g: m, z5 j. w" D( ]; _// Activation Methods
: Z v' L C; s m8 z1 _//----------------------------------------------------------------------------5 k. d* n1 b& j- O8 M( m
+ A; K `' N d3 a. F8 H6 h
// Unigraphics Startup2 e/ W2 R' j5 B1 T+ y: I* d5 H0 p
// This entry point activates the application at Unigraphics startup
6 J4 [( c# x/ }5 T. e' O3 j- \% Eextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
7 \ b. J- ^, U1 E- N+ D{
# i/ C) f q3 b /* Initialize the API environment */- R( r7 M l! J! r8 }0 w
int errorCode = UF_initialize();$ p( D3 I* Q5 G/ @9 N6 b
9 B- o5 E. u/ x
if ( 0 == errorCode )
- ~& n! T7 t$ q; ^7 X2 t {
2 p+ ~. y4 _' w5 g1 N% t5 \ /* TODO: Add your application code here */
9 M/ I( L2 E) p7 \& i4 i: _" V& M& [; o
char *type_name="mill_planar";
' a2 `1 t- t2 b" x char *subtype_name="FACE_MILLING_AREA";! ~' S5 Z" ~: W+ t1 P
tag_t oper_tag;, o+ K2 l4 y {4 [0 v; J& }
7 p4 U! D; T; \
UF_OPER_create(type_name,subtype_name,&oper_tag);. t$ N+ t% E& D9 T2 @2 T" c
2 w( d# r& p9 I/ k" b$ B( ^5 F8 ]
! ]- z4 y2 N" S1 C, s, t; o1 N0 ^; L' l' w
9 Z% A' g' F/ [( E /* Terminate the API environment */
& e9 ~' Z/ h+ q8 {, c9 S+ `4 ^ errorCode = UF_terminate();
, i' \( [# `4 B0 ]; A! y/ }6 J }
7 y5 c8 c" w. Q, k$ I' R+ u2 i# [! q' I/ d+ S1 ]
/* Print out any error messages */( z2 H( S7 n" P) H8 v
PrintErrorMessage( errorCode );
6 ^( q- |1 B* ?' u6 J, V, E" Z}
, ^9 G% A' ~* u1 E- h- ^0 v+ }9 z8 p. O! i
# F1 x) u* ]8 S' f//----------------------------------------------------------------------------7 D, l' |/ G/ Y2 B# U
// Utilities2 U9 x$ r- x3 P" @! U; h$ _; N, Q
//----------------------------------------------------------------------------: }0 D# B3 d, Y4 t9 |: D) O6 O
) X5 g: t. j/ B: I; h8 V
// Unload Handler
% Q2 C u0 R$ ]% ^4 _// This function specifies when to unload your application from Unigraphics.
# K( Q( n9 I: z, S// If your application registers a callback (from a MenuScript item or a
) a# o- e* c2 N0 o/ E// User Defined Object for example), this function MUST return
" J5 V" ~, w0 s# `# x// "UF_UNLOAD_UG_TERMINATE".
1 `! h' {( n7 J" W" @3 \extern "C" int ufusr_ask_unload( void )
# r8 e+ ^$ }2 d7 p; o3 a! p{
4 W7 b" o7 T2 A8 @7 T7 @ return( UF_UNLOAD_UG_TERMINATE );
" `# _5 {& b7 ?6 Z4 q3 ~}" p i/ _- c" ?$ p# P) ]
( E9 p( A6 Z) B
/* PrintErrorMessage5 P$ X7 T( ^8 R, Q% D
**9 p) ]. S4 O* {) Q2 Y/ Z+ w5 K
** Prints error messages to standard error and the Unigraphics status
0 v- j" U. W+ j* i" T% ?2 m** line. */0 L' r6 a8 C6 z I/ l
static void PrintErrorMessage( int errorCode )
U. Q: n" l( {/ l/ T{
5 J% Q1 Y( s1 Y0 j: E6 M& P0 t* U3 z: r: Z if ( 0 != errorCode )3 a$ w6 b. x6 a5 r
{
( c! ^. b- |3 j2 \ /* Retrieve the associated error message */- z2 P+ k9 E+ K+ n0 c: @6 u4 U7 O
char message[133];
; L% Y" o( ~, S4 c UF_get_fail_message( errorCode, message );
8 B1 |3 a7 P8 A2 Q$ X9 s. W6 ~4 h" C0 h; i
/* Print out the message *// ]- G9 H3 o6 n; N
UF_UI_set_status( message );# V3 k8 X7 O! {" n" a' ~
; E( M* Q J8 b, z
// Construct a buffer to hold the text.! b: O5 c2 F7 ]) J7 H7 a' i
ostrstream error_message;
" h5 u) k. ?9 O; Y0 g" o8 \
1 w: u1 @/ F* [: c) z$ o // Initialize the buffer with the required text.
4 h3 w% z- e0 e3 T! W8 N error_message << endl
) N* V7 P7 a7 p# C- l- q* i/ x << "Error:" << endl
" ^6 R6 L7 m. j a; x << message
4 A( G4 l: o0 V/ w8 Q+ L << endl << endl << ends;4 w8 l5 o, Z; b! T* x: ?8 j' ?
/ X; j' M/ g. ?& A6 M
// Write the message to standard error" G0 T4 V2 _, V7 ]8 @- F
cerr << error_message.str(); f7 X6 M0 H0 L, t
}4 y) a9 J P* M
} |