源玛:
3 f5 ~; @" k# Q( U, B8 G- A, r' V. y9 k+ c% c3 @7 W6 W6 N, Q
//////////////////////////////////////////////////////////////////////////////) R% s2 O3 V0 |2 T1 V5 c+ N
//+ f5 {* q# t# C% o3 X
// create_oper.cpp
* w- C* f3 m4 [9 b( T( d8 A//
+ \) }/ }: B" Q/ t3 m+ Z4 F' i! n// Description:! O/ i# s5 u2 G5 T% \; z
// Contains Unigraphics entry points for the application.! r2 r7 P3 W/ Q s) b/ e8 }6 n {$ d
//+ n% ~3 f( ^& l2 S
//////////////////////////////////////////////////////////////////////////////, z; X+ s2 Q2 Q* T/ P# ]: z
3 M% Z; F" r, [- z& r* D
// Include files+ k' [/ T' C0 I& m3 O2 l5 B
#include <uf.h>
6 X* F( v7 @7 K2 P5 G3 @ r! _6 C#include <uf_exit.h>4 s) h. I3 L6 H* ^. X4 o% k$ s2 K
#include <uf_ui.h>
% K3 B7 \* s$ i% p2 ?#include <uf_oper.h>. @! F+ k* P6 b; o$ F, T- q; M K
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
3 u! ]0 L% {" N6 i3 G6 l2 _# include <strstream>: Y7 ^8 W, h6 D, P3 ^+ W1 _
# include <iostream>
* G6 B2 ~* x/ F( Y; g0 E1 s using std:strstream;+ t% Z1 h" U# D1 v
using std::endl;
& w& L9 F6 R4 e( A* q using std::ends;
5 _) N: ^, W/ ^- j9 Z5 ?& Y" e using std::cerr;! b& h5 E. Y" @& f, B' K# T
#else3 t) Z: J) W- I5 c* P
# include <strstream.h>
' S$ S* D" k; \, p% s2 Y# y# include <iostream.h>, ]7 U0 Y# i5 @+ i/ Q' {
#endif& s3 q& V) ` n5 F
#include "create_oper.h"& h% b1 X5 M& Y: w, L
- Q6 u N3 g9 n) E" a
//----------------------------------------------------------------------------( x: p. G9 ?* T9 u7 A7 Z) Y- J# B
// Activation Methods
+ K' }: P1 @0 P1 P//----------------------------------------------------------------------------0 P& X9 {. `0 D; k5 a& `: `& E: m% K; g
0 y, e1 [; Y' d/ T. @" m% h% a// Unigraphics Startup ]3 |- b5 p: D# y. B8 ]& I
// This entry point activates the application at Unigraphics startup
, E2 Z9 N9 R/ G* {* {* Yextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
# C4 g# D: Z+ V0 `2 Z; }{
; x* u' ?: n4 y) u7 c( F1 w /* Initialize the API environment */
# T3 k! V3 ^# D/ S7 b4 s8 R8 I4 {$ ^ int errorCode = UF_initialize();* @: e+ x/ a9 G4 i9 ?4 Y
8 k& b+ @* u& d! N. s2 ?9 J
if ( 0 == errorCode )3 _4 [! ^6 L( V6 ?9 e
{( k+ u3 M$ J4 F# I
/* TODO: Add your application code here */. ]% @7 S& c/ Y9 L* }9 D* c8 w9 J' F
9 q, O- E- d& t5 d) Y) C char *type_name="mill_planar";
/ J4 I' t7 A# u7 [* O$ E: { char *subtype_name="FACE_MILLING_AREA";
. m* M C# H4 l$ f% X tag_t oper_tag;" `/ W% @& y+ L5 l1 K- {
( N1 D1 q) z7 v# f UF_OPER_create(type_name,subtype_name,&oper_tag);* M. @* k! ^" l' g% g
3 [ ^; J9 S# P t }( P% n r) X* |0 k
/ R4 L4 e; O' m) f4 @+ c% I8 R' l4 F9 |4 K, `2 W
& V" \& j; {/ q! K9 O2 z2 w: I4 u/ I /* Terminate the API environment */
$ |" r- Q9 v7 V {1 k# a errorCode = UF_terminate();; _/ d; n4 n5 W& r! R% ~+ v& q7 ]
}1 j, G; p/ u/ ?
7 d/ _' A, M$ P9 m7 ?# [) } /* Print out any error messages */4 s& V+ k- U/ Z: F3 S1 P3 l
PrintErrorMessage( errorCode );
. u( ] ]# R% q2 @0 K' _. I}
' z8 @. D% l4 O; Y ^
& M2 e9 y# u3 f% l//----------------------------------------------------------------------------0 f0 v* ~1 @# D" G: Z- `
// Utilities/ n- x* z$ X% G0 M) l: E
//----------------------------------------------------------------------------2 [( }8 J$ Q" \& M& m, v
# r @/ Q) G i$ W// Unload Handler6 C% Y1 J8 C2 W: r# h% C- e
// This function specifies when to unload your application from Unigraphics.
0 D' V7 v. W5 B! j9 H% d// If your application registers a callback (from a MenuScript item or a
H3 ~& T( a/ R- j/ V6 ~( A" k9 o// User Defined Object for example), this function MUST return
. g; z" O2 [1 z n// "UF_UNLOAD_UG_TERMINATE".
' q1 ?( d& |# W5 eextern "C" int ufusr_ask_unload( void ), z: ~ J% z- g. Y4 O) |
{
. ?+ q6 \: E, O return( UF_UNLOAD_UG_TERMINATE );
( B% K, Z+ }/ Z1 p" p% J7 B}: L$ [) \ b5 H! |: n! j
! }$ ^+ i- [. u0 ~, a
/* PrintErrorMessage
" S7 {6 ^3 x# m0 z* c. P( d**3 H6 J6 @0 U# A1 q, e* _1 c
** Prints error messages to standard error and the Unigraphics status) N2 \$ b+ `7 y7 a8 v
** line. */
6 B3 U/ R1 i( @( zstatic void PrintErrorMessage( int errorCode )
1 K7 z) p7 }) R) ?/ c1 O{! i. f, p! j. ^; _7 s& I! |9 @
if ( 0 != errorCode )+ {6 @* m' v7 s" f. R: b; a
{
; A4 r, M/ o5 g; e4 M% C /* Retrieve the associated error message */
$ Y8 G L2 {- b9 c& c4 ^/ G7 D& } char message[133];
6 Q- L. W( ]& @ UF_get_fail_message( errorCode, message );
: [/ {: o/ @1 e8 g4 y9 V
' ~6 W5 k" j' I* H; q /* Print out the message */+ X5 H& N; W6 a# `+ W; q% B
UF_UI_set_status( message );5 [2 \6 G+ K1 B7 ^. G- P
( N/ N. U5 e2 o& C. P
// Construct a buffer to hold the text.
- U5 \+ t1 a8 [: P6 H1 { ostrstream error_message;
, t+ q1 P' u# `: ?# C4 I1 w$ M4 x) l
8 x7 @2 w! D8 ]5 M0 s // Initialize the buffer with the required text.1 q( s- G% m5 Q& q
error_message << endl
, k3 c( W7 ^2 q$ P1 d4 Z; {" a << "Error:" << endl' Q: w' y0 p+ x" i. `6 j. O# V
<< message6 S0 W' X2 E, O, E l
<< endl << endl << ends;" N" Y2 v% D+ x; p$ Q) ~
+ A) e% D$ A) r; R% F // Write the message to standard error$ {$ O. c* a v/ c* `3 D
cerr << error_message.str();
( ]9 J, @0 `/ U0 V @ }
2 p& L( ^: h& L8 d# t} |