源玛:
& O" x$ z# u% s: F8 Z; ~# Y& K4 o1 G( J9 B
//////////////////////////////////////////////////////////////////////////////# D! Z2 w( m. K3 h3 _8 N
//
1 z5 A! a) X6 J5 Y; s7 T" H, n% V: P// create_oper.cpp9 N5 c6 z# ?( h3 D/ E
//" \ @9 ]) [: w) N/ E
// Description:1 a( t: M* V6 s9 q: U |
// Contains Unigraphics entry points for the application.
0 R& s; g9 A& f) X//
2 H# G' X/ x8 R7 ?& I X//////////////////////////////////////////////////////////////////////////////+ ]6 V+ i( o$ t) E7 ~
+ L3 P5 g: ]& M f8 x6 t# H: j0 ?// Include files: ~8 p. ]+ O1 g& Z8 N5 p) \+ L# Z0 P/ i% F
#include <uf.h>
3 p: |5 ~& N+ o8 f% N4 H+ E: b#include <uf_exit.h>' H! {; y, ^" o, D* m# a
#include <uf_ui.h> q% {8 p4 z5 L
#include <uf_oper.h>! b$ u+ `2 U' ~4 \9 X
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
q/ k/ w v: R/ K; ^. o4 @# include <strstream>; _# E# h3 _2 J2 c) _
# include <iostream>" F7 P5 s3 l7 L+ S+ i; c5 o5 E7 ?
using std: strstream;
& ?9 |: ]. f G0 a% u using std::endl; . Q" F3 H9 g8 V9 }$ i! [
using std::ends;* S: O2 z; @9 w- |& I5 `
using std::cerr;+ {& Z Y- @( B5 l
#else
! s' q' v5 {, o9 u; l- n, Y# include <strstream.h>
# l# ~ e' E# d$ b3 y6 t# include <iostream.h> t- |: f) X" u% F
#endif
/ u L2 U2 {6 v$ C! V( F) }#include "create_oper.h"1 @* [* H* {0 k$ h- o- v
7 T' E; B8 r' f# I+ V! {//----------------------------------------------------------------------------
1 F: g& h( y+ u, i: L% b! z: y% g0 h// Activation Methods1 x. z; N6 S. x% E* K
//----------------------------------------------------------------------------
; ^; h. F$ \' V4 a, B+ |+ T+ M! K0 Z: q" l+ h) g+ I* n) |
// Unigraphics Startup
) n6 E3 j* m% d/ h% `/ X, W4 T// This entry point activates the application at Unigraphics startup
! Q7 i% g1 H6 w* Kextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen ). G7 i6 G: q0 L5 @4 S
{
6 G8 {3 n, I- ` k* B /* Initialize the API environment */8 \# _. u- T/ Y7 \. u; ~
int errorCode = UF_initialize(); X. F5 Q% \! H; `8 p
, W" H7 k" ?4 t1 F$ z! P if ( 0 == errorCode )
) R: h( D' n0 m9 o {
Z M5 t8 U& Z. n+ |8 J3 ~. C' s /* TODO: Add your application code here */
7 {" b2 j/ k9 W
# L& M1 |; a$ C4 \6 E$ n char *type_name="mill_planar";" T. p. o4 }1 Q6 X- l+ X7 d
char *subtype_name="FACE_MILLING_AREA";9 x- V4 P/ E+ I
tag_t oper_tag;" y# [' ~4 B$ M1 q% |4 f3 B/ ~
6 V# w& V9 q1 `& t) c' o UF_OPER_create(type_name,subtype_name,&oper_tag);0 [/ A$ s! r* a' q5 b) B
. C% M7 w& y" K) B* G# N6 ~) o& R- _8 d* M9 U' _5 z) o
* v3 t3 X: a) |7 b# A
& O4 y0 V3 R# A# g
/* Terminate the API environment */! c% I7 x9 x8 Y G1 p: l9 d4 F
errorCode = UF_terminate();
) y, j/ @/ [0 A; [& P6 k }
: _: e, H, [8 g2 b. D, x8 R3 k. z; |# b+ x1 Y% a% `0 d$ V
/* Print out any error messages */% _4 \1 g; P, h3 _9 i0 X$ l2 Z
PrintErrorMessage( errorCode );
% o7 ?" ~, q( X: A5 v}
' b- n6 {! `* v* ^2 t. @) x8 Q2 P+ h$ o7 C- \/ P4 [# c
//----------------------------------------------------------------------------9 w8 O1 a( Z+ `1 x& k( C. S( Z
// Utilities
5 p; z; e0 M- t+ _//----------------------------------------------------------------------------
. u- }7 K+ d4 n, x/ R! q4 T# f [% ]9 j) V
// Unload Handler% O: A" Z1 z+ T! ?
// This function specifies when to unload your application from Unigraphics.
8 o9 J- a: R' H8 j5 v// If your application registers a callback (from a MenuScript item or a
- R8 |5 M, Z0 w) N7 V7 j// User Defined Object for example), this function MUST return* A2 J) I+ t1 S: S. W4 P( \
// "UF_UNLOAD_UG_TERMINATE".
4 v% m2 O0 z: f( H* W! M1 C7 I# ~extern "C" int ufusr_ask_unload( void )
# m# K+ H/ r! n4 _3 L{6 r& h q: V# C9 I* U
return( UF_UNLOAD_UG_TERMINATE );% F; k. @. L* R& W9 @8 W0 |
}
1 A+ k( g# T* d. u. U' Y; T. t9 @) |! H) f
/* PrintErrorMessage
( Y1 C+ v6 k7 C. A. o**
/ b, ?2 h9 F. F& s0 C4 W- m** Prints error messages to standard error and the Unigraphics status8 V$ S9 b3 I( ?9 D$ P
** line. */
3 ?9 u2 V: |% U9 M, |- Xstatic void PrintErrorMessage( int errorCode )8 ?2 h4 k' i! \9 Y. G) d% h
{0 o6 q4 {7 O: T. r w+ @) u
if ( 0 != errorCode )
8 O: [$ [1 w5 n1 z: z9 u { g5 V( {7 o7 X5 r: r# h3 C6 B6 t
/* Retrieve the associated error message */
: q% ^# h: @9 A7 r/ S3 X char message[133];
/ O: D; I; x2 k/ C: z! L" H4 e UF_get_fail_message( errorCode, message );
5 y/ z- r9 e0 ~# I0 s7 J4 Z( s t* H( O: f
/* Print out the message */
6 a) j4 O+ V& g2 h* W3 h UF_UI_set_status( message );; c! I7 o# `8 r8 q
3 z- { S, Y6 x5 a* q/ z3 n' Z7 T // Construct a buffer to hold the text.% r% D6 y$ |6 n0 t
ostrstream error_message;, z- l( G2 g7 q* X
/ X" V) z, ~# y6 b8 z# y // Initialize the buffer with the required text.
8 f, ?* ] C' \5 I4 W error_message << endl( p& `! Q3 Z( s) t3 `$ O
<< "Error:" << endl
- M% Q5 @5 W: V$ Z- S6 N* u! | << message2 `* P4 x) o) ~ T7 X/ d& D/ u4 [
<< endl << endl << ends;) @: i6 ~- A) ^
5 \/ k4 J0 Y6 W& s. E
// Write the message to standard error, B. r2 H) T, R* @- ~5 \/ z
cerr << error_message.str();
* M* D2 u! y9 i0 K" U+ O$ d* b, a }) C/ a" n" L# c: {) h6 a$ l I# S
} |