源玛:
. D9 g$ V! M8 A' [5 u' J
2 Q, z; ?/ @: ^( e//////////////////////////////////////////////////////////////////////////////
& {+ r( Q2 v3 U: B2 u2 T//
( P2 R: q k; K v// create_oper.cpp; B" l( t3 R1 t0 N
//
5 G J3 f# _1 G% i// Description:+ W2 g v, e- ~5 w; i+ H% r
// Contains Unigraphics entry points for the application.
8 d0 n/ A, V+ j//* F, @( L. S$ w1 a8 u1 G
//////////////////////////////////////////////////////////////////////////////
0 x/ R/ }: I% g/ {
& d7 |: a9 B/ S# f" |9 b/ g// Include files" ]1 @5 W% x& n/ \0 q
#include <uf.h>
8 o2 w7 m$ f& K' \) D7 A! U: s#include <uf_exit.h>
, \, A. x; E- J0 p* e# g9 p9 T#include <uf_ui.h>' U! D* ~/ s, l, U% u2 E$ k
#include <uf_oper.h>
' Q W3 M) J* o) M9 a: v: d& C$ J#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
8 f6 \' s1 [8 `) f# include <strstream>
9 U2 R& m3 r' M. y' B# include <iostream>9 D0 a& ?2 s& Z1 G2 E5 l) v
using std: strstream;4 U2 [- b o' \9 ^& L) I
using std::endl; ( r1 \, o) q- _, h# C, V, Y. I
using std::ends;
4 q1 d& n' m" ]6 k/ v) X* L8 W2 x using std::cerr;3 w1 b' n0 T; P& O
#else
7 j8 c% E7 F# }3 z/ g2 v# include <strstream.h>' S% O$ d* c$ }6 p8 ^! X9 b
# include <iostream.h>- v% Y9 |, L" q
#endif0 `- h$ h: [& v: }6 s
#include "create_oper.h", r. m, D, g( F ^- Q$ h" \3 b
1 x# x9 b: e" R4 q, j//----------------------------------------------------------------------------0 |5 ^+ C' @5 E% k. |7 o
// Activation Methods
# ]% |$ Z! j! j9 n1 @1 A8 J//----------------------------------------------------------------------------7 P; d" `) d i; t
' m' _8 p. W$ U7 L# n
// Unigraphics Startup: h& V# W% t: w* O
// This entry point activates the application at Unigraphics startup
/ v# @* c3 N( C) Jextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen ). N+ |, ~9 r9 V3 ]8 _3 r6 c0 z/ j
{
( Y5 p' V% t# h) r7 c' \0 T) A6 N /* Initialize the API environment */! j3 n5 Z1 p" E: m
int errorCode = UF_initialize();$ x+ \, d" E! R2 ]- b' i
7 j9 F2 I. X0 k o! L ? if ( 0 == errorCode )4 a% U9 W1 r7 W& g; v) _
{
9 H4 t2 n- p- o2 J) K+ M+ ] /* TODO: Add your application code here */) q* K5 Q7 U& x4 |
! t& b# _. b/ t0 `5 n6 t# \; t char *type_name="mill_planar";5 }) O" g3 B- |
char *subtype_name="FACE_MILLING_AREA";$ N' a7 }( T( r: ?7 ^6 [" c
tag_t oper_tag;0 N8 G4 j" v) D- a/ F
% M: x, |$ A5 ^% V4 `! ~9 }
UF_OPER_create(type_name,subtype_name,&oper_tag);
3 Y& ~! q/ _7 U4 P! @! Y1 h4 W8 ~( I) v8 u
; B; C6 ]) h6 i/ n) V# v. v, b9 ?2 \! c# v
2 N& }# s$ a% o' b. s# [0 V6 m /* Terminate the API environment */# g9 z* a3 w1 ~" e8 n
errorCode = UF_terminate();
. ~ x) U9 b$ K$ p7 U }2 U' p4 y# U3 a1 Q, @
! n: m( p; s Y, G* g /* Print out any error messages */
9 h! T$ u" l3 Z- R4 Y& K) v) I PrintErrorMessage( errorCode );9 W9 H0 d" E2 h! L
}* A# i/ c6 Z# b9 Q8 p/ V0 H
4 I. f* r- _( v//----------------------------------------------------------------------------" D+ b( @2 p& k! \2 N1 v
// Utilities
! N9 r0 u# p+ k. j* f//----------------------------------------------------------------------------
, X/ T1 J2 L0 b4 e/ M8 e
# J4 K" v0 l3 n2 n// Unload Handler; j8 f+ i4 f6 r4 j! |. L& V
// This function specifies when to unload your application from Unigraphics.
, G: U/ N; O0 S, e/ F8 P// If your application registers a callback (from a MenuScript item or a5 P7 [; x5 R( n- ?
// User Defined Object for example), this function MUST return
2 ?4 E% z" |) W0 p T4 ]// "UF_UNLOAD_UG_TERMINATE".
$ `2 S2 U0 ]3 ^# o$ q' ?extern "C" int ufusr_ask_unload( void )
5 {0 Z# ~, V" b3 f" V8 y6 \# ^{
9 _' V5 I0 A, W2 [, }4 d/ E return( UF_UNLOAD_UG_TERMINATE );. z% e. U" o Y/ t. e4 {
}( K( `1 W: _) w
) {4 g7 B1 ]9 o
/* PrintErrorMessage
7 x% v4 Q+ B$ T- W**
6 o. z. @) r# Q* W! A7 Z** Prints error messages to standard error and the Unigraphics status/ U) m& d0 p4 U
** line. */
$ x1 v8 j* h( H) y7 N& W0 Ystatic void PrintErrorMessage( int errorCode )' Y0 a2 y$ G$ B6 I H J
{
6 G3 ^: \( e! g if ( 0 != errorCode )
% ]- D- s5 b1 O6 H8 I: Z) Q {! E* _8 H4 @$ `* I* b) N& C; o
/* Retrieve the associated error message */6 f9 A5 u+ w1 Q: c" A
char message[133];
" _. n: e) a/ b; V8 l0 b UF_get_fail_message( errorCode, message );
" @! M4 H* d% \# C; V& U* f6 j$ B. x$ d1 C' Y! L; y4 M* I
/* Print out the message */' T3 a. p: y2 j+ A: A4 H
UF_UI_set_status( message );/ b3 ^- n: l# b' `: G+ V# L i
' }: Q& M0 H! t& H& Y! ]: ?9 t // Construct a buffer to hold the text.3 r' [2 A |" l- V$ N! g
ostrstream error_message;* S, B3 E' z% B/ m
j7 x# r/ @- \+ A: _
// Initialize the buffer with the required text.
4 y% Q( U* D1 h8 }8 ~& a error_message << endl; u! m! @( T5 Z2 R
<< "Error:" << endl
8 a- Q7 I& D9 K/ r << message
* z! }$ V8 {$ c0 q& d << endl << endl << ends;
& n, _0 \- u0 b/ j0 @% D% X4 l+ C$ T$ K, _
// Write the message to standard error
4 K- ?# e' E% U W$ t+ x' F cerr << error_message.str();
! F" C" i& Y2 A }
) s. l# I1 v. _& z- S! S6 Z) ?} |