源玛:: N4 g7 ~- f$ B% E; \
4 G9 |7 K0 g& _3 \
//////////////////////////////////////////////////////////////////////////////
$ Q1 x7 S6 D( r" _$ _//
9 a& |! f& W4 k: Q// create_oper.cpp
1 k$ b1 k$ o y//
9 R' M4 v/ O; E. ]( _9 T8 q1 U// Description:
3 a, z1 x! {2 S4 F$ R( d6 v// Contains Unigraphics entry points for the application./ y+ c9 x& c! G( Q) T
//: Q* V0 a7 O5 V5 a4 n# {7 Z
//////////////////////////////////////////////////////////////////////////////' n; b( C" A6 M$ W) Z, u1 g `
; w1 p+ s1 w$ R7 F! ]0 R0 v( W// Include files" D6 C1 `7 U8 N+ m- Y
#include <uf.h>5 A( O+ J* M( q: P" J' V( O
#include <uf_exit.h>- `" l; w( H3 O9 I* R
#include <uf_ui.h>
5 M9 S3 t" |! A) H0 I" \; S#include <uf_oper.h>/ A4 r% G" O0 t w* ^0 s
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
: e$ U6 j/ l) ~, g. e& |# include <strstream>
B( Y) I+ E4 j- Q# include <iostream>$ a. r' A) B, w% K
using std: strstream;, e! @: z: J0 H
using std::endl; 2 K$ V- n d( i) _$ z: ^
using std::ends;* n0 a% h" `6 y
using std::cerr;. R! e, S7 l! h/ |# ]
#else
7 ~: {. w t4 ~# include <strstream.h>4 N' |: K* ` Z) X4 r+ [
# include <iostream.h>
* `5 q$ i! B- j, v9 a. ]#endif3 B+ [2 }6 A/ ?3 x
#include "create_oper.h"8 ?/ F/ Q3 V6 U1 k, ]$ W
- B& L! }: h$ I5 l$ ]3 N//----------------------------------------------------------------------------
9 {0 i2 O& F- }// Activation Methods. }" q6 ~0 q$ [+ j9 \
//----------------------------------------------------------------------------
. w. }% [3 m: |. |7 E/ V# [3 O; ?3 A! c' ^" J
// Unigraphics Startup
. w6 I4 W) v: j( C; ~4 Q6 N) P// This entry point activates the application at Unigraphics startup
9 F$ w* E: a4 d, Vextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )+ k5 ?$ x4 P: _+ N N; F( y) t0 n
{+ @! o" T7 D2 ^- {- q
/* Initialize the API environment */( G6 P# r8 b1 I+ N/ H
int errorCode = UF_initialize();
. s! H% }% S7 i4 E) z- ^( K
2 {! X9 |7 w7 b O9 N if ( 0 == errorCode )
" |5 ?% ?+ K* F5 ] {
7 ?7 P3 }+ A+ J" E3 g7 _0 L /* TODO: Add your application code here */
0 F0 y7 u. x/ D& h3 l- M/ O0 m
* f. S1 ~" j; k8 \# k5 Y. _: z char *type_name="mill_planar";
9 N, F0 o6 Q9 m5 o! J- ? _* C' Q char *subtype_name="FACE_MILLING_AREA";
- x' d% c; d) f/ f3 A( @ tag_t oper_tag;+ \- ^# I- f& G3 t* H
k+ U/ P: _3 o
UF_OPER_create(type_name,subtype_name,&oper_tag);
* ^5 f; K1 z8 l9 E7 g7 b1 U
! N0 ~" L7 T) e3 P
! i: g3 v" A" h2 V# V' x0 B c$ s" m3 Y- L. f
/ h6 F! W& ?3 L s
/* Terminate the API environment */
' L) q* |( p6 K! ~/ R# P errorCode = UF_terminate();8 A* m" [7 L( V. E, k
}
5 t) w3 I9 F& V- Y+ o' ^
7 J$ t% P+ V/ ]( L) U) _ /* Print out any error messages */
% V* v) g7 I: a0 g( _ PrintErrorMessage( errorCode );
& o7 n6 e) M& x! o( c% h" p}
+ y4 i+ Q$ G2 C# } q2 r
- k; S6 k- a0 t. H) W/ P0 X//----------------------------------------------------------------------------
: v# h& X/ r5 R// Utilities8 l$ d; D0 \. p8 r8 w3 R. M! z
//----------------------------------------------------------------------------; n4 o; G& F8 o6 f3 |
+ ]/ H- E: m: C9 b$ t- J$ d// Unload Handler
* c) k: ]7 X: J* J6 U) U// This function specifies when to unload your application from Unigraphics.
1 G! G( v9 F ~7 g// If your application registers a callback (from a MenuScript item or a
M2 v9 v9 T- \1 Q// User Defined Object for example), this function MUST return
4 a' G0 W O" Z% B7 |// "UF_UNLOAD_UG_TERMINATE".
; T0 S# ?& }7 N: u1 C/ oextern "C" int ufusr_ask_unload( void )0 d: n6 |; f9 T# E$ ?
{/ H! @& d% V; \8 [, j4 e
return( UF_UNLOAD_UG_TERMINATE ); }7 A+ x, @% v5 @9 y& x S
}
( T0 h. I3 e5 j. W2 y7 d
8 d! c# O" J/ ]9 C& j/* PrintErrorMessage
* ]2 i$ w# {( w+ o# Q# c( K**
4 c0 R5 [' u7 T* A x** Prints error messages to standard error and the Unigraphics status
6 g, N; m( m9 b) W, @ s** line. */+ X: z% s- [( I$ c+ L5 E( _; U& N
static void PrintErrorMessage( int errorCode ): n8 u! }5 d+ b6 f8 a# o
{+ M* E( z1 ? Q
if ( 0 != errorCode )
$ y; B+ j) U, n% Y0 v" ` {
h$ ^! B8 S. |$ _( n /* Retrieve the associated error message */
0 H M, l- N2 d! i2 m char message[133];0 |# O$ z( c, i I$ K0 ~8 o
UF_get_fail_message( errorCode, message );+ f$ S" I) z6 _% K
% C, L7 V: E% @1 Q- a. K
/* Print out the message */$ G: D1 B) F$ o/ `
UF_UI_set_status( message );% j8 }; p) T* Z9 u6 `
, |0 R& Q O% Q. w$ i5 c // Construct a buffer to hold the text.$ p! k5 C; H7 e" M
ostrstream error_message;5 M. O* ^! | j L0 X* j- c5 R7 d
1 H6 U: j1 S9 V, r$ v( h# P2 r A+ ? // Initialize the buffer with the required text.
$ r7 a. g9 n7 i- w error_message << endl9 W9 l l* n9 N& V0 o- w
<< "Error:" << endl
: v+ ^1 W% r" k << message$ R" C9 `2 K1 e0 |2 }, _7 x
<< endl << endl << ends;% R/ l" @) q! V" o
1 u$ @, l7 P: G: C( W
// Write the message to standard error
* `* @$ O& {' w6 n$ K( W M cerr << error_message.str();
! l) y2 p* s$ n6 d2 P. ^ }. ^8 |7 f5 C+ E/ j
} |