源玛: j0 O9 Z. S& C& w
7 w' P/ q. x7 q9 I# j; ~: u' T' m//////////////////////////////////////////////////////////////////////////////* [$ I2 T5 L% I& \) ^' W
/// v6 u% N9 d4 S5 O! d) w# |
// create_oper.cpp
9 D: b4 {! \" N$ h// Z/ ^* \& N# H4 A- k" r& v
// Description:2 U p% c& }1 ?! z- I! ]# {
// Contains Unigraphics entry points for the application.
5 L/ }+ _5 Z( e' b, J//9 L& ~0 g% s) b9 p+ M- q& [! Q. s! W Y
//////////////////////////////////////////////////////////////////////////////
( A6 x8 ~1 p3 A* ^
5 b. {1 J: \0 p5 `// Include files4 `! z7 a. k3 Y9 }
#include <uf.h>: L h! ^ ^% t* Y
#include <uf_exit.h>0 O& ^, j F, O+ [( T+ H9 r
#include <uf_ui.h>
7 Z9 i% W6 U8 W- {1 v* p; \#include <uf_oper.h>! B5 e( X4 E, \
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun ). T7 s* E6 m7 j( j
# include <strstream>3 j4 h3 d& |. E+ I h, J3 d; t6 P6 N
# include <iostream>
Q* m( X) m- q* l" | using std: strstream;
) T1 I: N6 r- b5 b! T+ b- P using std::endl; * P$ r. ~4 G/ R8 ^
using std::ends;7 y. l: @+ G6 T* G; l. ] }) l$ F9 }
using std::cerr;; G' @# A! j! I- ?
#else
% H: r9 N9 {: r7 D" |8 O# include <strstream.h>9 a3 L) t: B {* R
# include <iostream.h>0 m1 X8 g4 ^- w6 Y) l: d
#endif
& H, p- i' T% d. Q#include "create_oper.h"1 u. M1 ?! G% s7 \( A$ F5 M4 a
6 n9 k: h1 K: l- P' P1 c
//----------------------------------------------------------------------------& w6 P& d3 E5 E2 a
// Activation Methods
1 {. V1 Z! T A/ \; e//----------------------------------------------------------------------------* L' P5 Q3 m/ _
! d6 F, {8 T5 e. b, `$ r// Unigraphics Startup
. e( g4 {) z$ ?6 K// This entry point activates the application at Unigraphics startup" J) y5 [ n. t# K
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
+ r0 R- L# ^% N{
0 V" B P( f3 f! ?1 i7 y /* Initialize the API environment */
( R8 C) o" d! R5 Z) b int errorCode = UF_initialize();2 c/ o* Y" u" W7 z6 v! t
- S/ c* {/ d! X/ u if ( 0 == errorCode )
% ]; t W: e5 h1 d! ~ d {
: Z5 s& C4 W2 Y2 w: O& O0 _. L /* TODO: Add your application code here */
) ?$ {3 S; c; P- D3 q7 j4 Q1 a$ w/ }% J& h4 X: L0 q, T7 p
char *type_name="mill_planar";) V: R% m5 @% I9 F1 g
char *subtype_name="FACE_MILLING_AREA";
/ _% j" k i1 ]: R# F: [ } tag_t oper_tag;
. C2 N/ s: `+ f1 s
' u; {) b7 H3 F% I5 A UF_OPER_create(type_name,subtype_name,&oper_tag);' F1 E, y5 }% I: `, r
! T# p4 y2 i8 h/ x) S' B' t
$ g! D8 P7 H |8 `3 ~$ q5 X6 ^3 J) v- o$ w8 N' p. h
: I2 T: ^- p% m1 q1 A( _5 u* t /* Terminate the API environment */
5 G( |0 O% S, O/ U( D errorCode = UF_terminate();* e6 R/ L2 Y* z$ f8 x
}; n6 J! s+ ? f' f2 `* p- L
! k( L( V6 o% N4 M
/* Print out any error messages */
6 z" ^% N+ d H" j1 I6 P! D PrintErrorMessage( errorCode );
7 v$ @' g! l" t( o' C}# T) Q& L% x [: F! z
6 ]; d v8 ]7 `& |! w# G
//----------------------------------------------------------------------------
3 _7 l- v* k% n7 b" R( \3 S// Utilities
! c* T6 N3 I* _: M, Y F; p//----------------------------------------------------------------------------' }/ O4 {, r& g; U2 E
W( W v* I. v// Unload Handler
' M. V- U6 c/ \* a2 U// This function specifies when to unload your application from Unigraphics.0 c7 ~ m0 W+ i+ H; ?& O7 T8 J
// If your application registers a callback (from a MenuScript item or a
8 A F% X! U- A' }2 o// User Defined Object for example), this function MUST return
9 Y/ c& g) C' G. u// "UF_UNLOAD_UG_TERMINATE".
$ D' w s7 A5 ^; U1 g5 jextern "C" int ufusr_ask_unload( void ) N; v6 X* H: P; }. O5 q3 |5 A
{5 _! h4 B; I& w" ~( \9 K
return( UF_UNLOAD_UG_TERMINATE );
. b6 { i, X9 B* w}
9 K" j, ^! M7 r! w; ?; W1 U. U: j/ ~% j) ~8 D. ~9 G- W: H+ h
/* PrintErrorMessage. x2 C+ v: {* y4 u0 Q' [
**
; C8 L% Z) O( a+ z: n4 w0 ~** Prints error messages to standard error and the Unigraphics status: d) A8 V4 W; Z4 g3 I
** line. */
3 [& D- e+ B7 m6 B( k# o: S8 y# _) istatic void PrintErrorMessage( int errorCode )
. {5 E# |. |6 u0 i4 W0 A{
7 G; a" b ~3 e' N if ( 0 != errorCode )2 L* T2 _8 D, S" i7 E3 h k4 P
{5 c8 x+ ^. h6 J* g5 Z6 d
/* Retrieve the associated error message */
6 V7 @2 u9 m! t7 C4 P char message[133];( D8 {: I& A4 B, n0 R0 F- o2 q0 }
UF_get_fail_message( errorCode, message );
) ^9 g3 h8 Q8 g2 ?. K5 t! }9 ~9 J' W9 r3 F7 x7 i
/* Print out the message */0 D4 `7 ]( H4 |6 j
UF_UI_set_status( message );
2 o8 N( Q; ~% K7 e/ O: q, u. W- k; T& n0 s
// Construct a buffer to hold the text.
+ O7 h8 J1 d. T+ f" ?% s$ b, L3 w8 R ostrstream error_message;
+ T8 t/ J' j3 M% H9 f I. @" M8 `; A: k9 `5 Q$ a1 K! b
// Initialize the buffer with the required text.6 A" |8 z: y- g! _+ ~: ]( n# I
error_message << endl
! T7 H8 E7 [% L9 b" ]% ^) B0 g! D8 g << "Error:" << endl$ ~% n2 U) G" M/ u! b; H7 o
<< message
% X! Z' h7 n' p, \* Q$ |' P2 j9 Z << endl << endl << ends;3 N0 I# f- f8 ~! ~' Z& R
# }, d5 X0 Q e$ [* z9 b9 F+ ^
// Write the message to standard error) x5 U' W5 q4 u; U& `9 Y: r5 e4 Q
cerr << error_message.str(); R/ r0 j* V3 n" R) a
}. J5 i& c% c& m4 e6 P
} |