源玛:
2 F/ b- a* ]5 K$ @" [1 j {' F) \! Q1 ~5 C7 ?5 \ V: M
//////////////////////////////////////////////////////////////////////////////
9 P8 [, e' c# E H//: n- V9 m# i0 o( U% L" j
// create_oper.cpp( E, l; w. O- u( M1 J t P
//) q* Q- N5 M. @1 }3 c
// Description:
7 f4 u' x2 ]; r, Q+ n// Contains Unigraphics entry points for the application.
5 z8 K! S$ m9 a% _ ?, A//
( u1 E. J- @: X$ G4 M* Q% `: f1 d//////////////////////////////////////////////////////////////////////////////, e5 q" O' L f' i( G0 N4 ~
+ k# c# ?4 A% E; ~5 w9 M/ z
// Include files0 q) r' N' ^ S* @( U3 T' o5 J( w
#include <uf.h>
0 S7 _( W5 _" y/ }) u# u#include <uf_exit.h>' H" L" U$ \# U7 n. s4 b
#include <uf_ui.h>" u7 a' H0 I. R2 i R$ l; T3 j- |9 u
#include <uf_oper.h>
/ u& `0 d9 e0 \7 V- I, F#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
4 @: D; W% ` k$ e# include <strstream> D s% ]* `+ ^) G& j
# include <iostream>: g: l6 X5 G4 _1 L* x6 ^9 r
using std: strstream;! S; `/ u7 `& C+ E' @
using std::endl;
: Q9 I) e& K2 w% f) ^ using std::ends;- j O( K4 A- }$ E' a: @9 d
using std::cerr;
/ D& ~- L* U' q6 X#else
7 P, M* b% B7 O# include <strstream.h> Z! S) c+ C F( c' U/ v1 g* c
# include <iostream.h>
7 G7 u$ U- }. K: a. M#endif$ j, k' r; W, {, v6 z% C
#include "create_oper.h"7 ~ E! \) y4 K' C$ Y; q
( o3 Z8 l4 w& f# X# q
//----------------------------------------------------------------------------
; f# @$ }) f7 ]6 n1 ^// Activation Methods+ Q" R( w( B2 u
//----------------------------------------------------------------------------. A- C" Z7 T I! r
- S5 X/ h7 t; E7 z( X// Unigraphics Startup4 r4 d" h: u/ K% }5 t
// This entry point activates the application at Unigraphics startup
- l3 o: _, L, J1 }3 Fextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )) R. ]* U8 ]3 {0 F( Z7 j
{$ f" ^4 }' l/ ^! S5 `
/* Initialize the API environment */' H5 P& g, X1 M ], S' h8 N
int errorCode = UF_initialize();
5 a- _* _+ s! j& g# A+ B9 z. c+ {, ^4 g4 s; z) P8 E3 ~5 H
if ( 0 == errorCode )
: I# W/ G8 U" O' y {8 `! e/ W% O# t* }8 B% f/ a
/* TODO: Add your application code here */
! T# j" m( x& r& d$ v# W2 \
- n# |' ~# d ~( e5 c char *type_name="mill_planar";
' v- h3 o+ H, F, J# ] char *subtype_name="FACE_MILLING_AREA";
4 A$ l( [0 u8 c tag_t oper_tag;
6 g& h3 |. T6 u1 S/ l, {, U. w+ r4 a0 |& o
UF_OPER_create(type_name,subtype_name,&oper_tag);3 K- C7 g) r. M7 F/ v q( T
0 w4 ` a! c7 Y( V. s- X- ~2 r' G j
/ C U" q n1 m( z8 J7 ?! o( }) o% D. Y, ^1 G+ U! H$ m
2 p+ O6 ?2 |1 K6 u: p o5 k
/* Terminate the API environment */5 o5 r3 g4 p: l
errorCode = UF_terminate();
6 l5 [, I' ]/ ]% j9 v% x! g1 O }
: e; |& J2 w/ `- D
) Z! P/ g) {6 [6 n% Z /* Print out any error messages */+ @! D8 Q; s* ^' x" Z* ~
PrintErrorMessage( errorCode );
% P" b" g7 r+ S}9 M' c' Q. O6 y1 ^6 [1 K
* }7 B7 H! `8 J$ t" v5 v
//----------------------------------------------------------------------------% |' k9 X, H2 H! a$ v
// Utilities. I3 ~1 o( ?* a9 O3 r B: f' {4 f! ?% \
//----------------------------------------------------------------------------) L; G4 d6 u* q; `( y
" `' r3 f0 q9 E! I0 t
// Unload Handler& |/ F1 T: \8 O$ b' S s
// This function specifies when to unload your application from Unigraphics.
* j7 Z( o% n+ A" y4 A7 l' b' r// If your application registers a callback (from a MenuScript item or a
, T( Q! v7 @$ U4 j" P$ L// User Defined Object for example), this function MUST return
, c# z6 g, O2 [: {8 r! i; w// "UF_UNLOAD_UG_TERMINATE"./ L* t+ g% O/ V/ {
extern "C" int ufusr_ask_unload( void )9 [/ `' V) ^ `, V! u: ]! l
{) L9 F: _5 G$ J, I4 C4 E7 r
return( UF_UNLOAD_UG_TERMINATE );* ~7 `% [3 n ]" O2 W5 C
}
7 `2 S( S3 H, S2 x2 i, u4 F) ?5 \; a: Y0 c. A& J
/* PrintErrorMessage
% x% O0 X# }: B1 w) V# d) i**
' E: z1 T# F6 ~** Prints error messages to standard error and the Unigraphics status
+ m4 W1 i7 J7 I' ?: K' V** line. */
3 T9 I6 m- r' n, ? l* q astatic void PrintErrorMessage( int errorCode )( f5 b0 M l; e# _4 ~2 P& u
{! c2 _* v! T2 O" y) G$ N+ P
if ( 0 != errorCode )
\ { K, w/ O! w; C {. K0 p" \. M3 I
/* Retrieve the associated error message */
8 D0 W, U- y) y6 s char message[133];
( M9 K) S7 ?: i1 d( s2 } UF_get_fail_message( errorCode, message );/ G+ r8 y1 Y% D$ r* ?# R4 H' r
9 |+ Y/ A! H/ f+ O9 S' A9 e4 c' x
/* Print out the message */
9 n; E( z, P, h# V3 a0 \ UF_UI_set_status( message );/ J+ W( N$ I2 l
, Y* B5 @7 y" m8 j- B* ?
// Construct a buffer to hold the text.
! z2 n# w3 |+ i- v, W% v ostrstream error_message;
% @+ f6 j* D B; F( J; u2 Y! Y3 ^8 x- h: N0 C4 M9 J
// Initialize the buffer with the required text.' A& a# J& ^( Y; j- d
error_message << endl4 `0 K9 y E. g: o5 O/ b
<< "Error:" << endl
" S2 X1 m' x! n& k3 K7 w5 f0 s9 T << message
- O3 D# F8 [- [' t: F << endl << endl << ends;
; G! o3 n1 G r! P O7 f) Q
' K- l5 ~" @, v6 \3 J4 \9 ^ // Write the message to standard error
+ X& {5 F# P& e; {1 J4 J6 u. _ cerr << error_message.str();
0 ?) C$ r: p& }% @( ?) Y }4 ^7 s* w4 p9 j% m2 \5 i* _
} |