源玛:
) B; ^+ u2 W) i" e3 h1 I0 L* V4 j8 Y
////////////////////////////////////////////////////////////////////////////// j8 R( a8 J$ s4 a# c2 _ m
//; g" n( G0 m/ U+ u' F. K
// create_oper.cpp6 `: j6 Q$ B1 }
//
8 z$ w( R, |0 K3 D* x1 e// Description:# N1 \# C! X% L- {7 R2 Z' d
// Contains Unigraphics entry points for the application.6 h, H* O0 g8 i( D% p
//
9 T4 ]' O8 R* L; l" Q//////////////////////////////////////////////////////////////////////////////
4 c& g( ^0 C5 t3 M! S/ Z- Z: J8 e0 Y- m
// Include files" t7 W# H8 L1 m3 l. x
#include <uf.h>
) e L1 E2 ^: Z& k#include <uf_exit.h>
4 P* E7 ~& V. Y3 M/ _) F#include <uf_ui.h>7 s# {7 |2 X3 P/ R; @
#include <uf_oper.h>( i! q6 M; o. X1 T0 `- ^8 n
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )) u7 O" y' M+ l. b
# include <strstream>
9 K+ a: y, s! a% {# include <iostream>
q$ ] k' l" L9 T# V& J using std: strstream;; K- ~. O7 d2 H& m6 e; g
using std::endl;
( m* z9 W* N0 q- \ T j using std::ends;+ S! p( @8 l; e3 b8 E
using std::cerr;
0 N4 u! g- c3 S/ s( S#else% S: f. @7 S: ?1 b) h8 O
# include <strstream.h>
6 J1 v Y4 G4 }2 s, {# include <iostream.h>
$ m; H+ c3 e. A5 i0 U/ b3 q#endif# g1 H0 w) @$ b- }" `* `
#include "create_oper.h". @2 Y. O6 v0 f* g3 W
% i& d, M( L6 h6 L6 z//----------------------------------------------------------------------------
" |, Y& m% {, r# t) k% R" J# U6 T// Activation Methods
0 |% }' K G' @8 H% E' p, f9 y3 E//----------------------------------------------------------------------------
3 q9 T$ M+ P# Z& x% s# X g3 D, f" [
// Unigraphics Startup
; s; Y. B; N: A+ @) z3 d: |/ O0 {// This entry point activates the application at Unigraphics startup8 G! O d: t6 ` K# o7 @* b
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
: z% n1 I% H! O+ G+ T- `{
# H: r3 f! W! P! w' F% S3 r9 h9 s /* Initialize the API environment */4 J7 U, n% i& E) T
int errorCode = UF_initialize();
' Y l- \% ?( L1 H
- H: d2 f; h" T if ( 0 == errorCode )
H3 ~; X Q) t/ A; _/ |. C" Y- _ {
, ?& D6 C1 U# c1 { /* TODO: Add your application code here */
8 d8 e* b7 [/ ?8 n3 Z
5 I% p, N$ O6 O$ ~8 b char *type_name="mill_planar";
( F- K6 F! i5 I1 l+ o1 d char *subtype_name="FACE_MILLING_AREA";* @# l: E$ i w0 H" B! h; G
tag_t oper_tag;
8 \" P- l" o) F. H# x; W+ T& O* r0 ]6 b+ ~3 b
UF_OPER_create(type_name,subtype_name,&oper_tag);; `' k4 H9 r( z( n8 Y& x5 [, R
$ F+ c. o9 H4 V0 y& B& ]
8 |: {# s& x# [; f0 ~8 y$ I1 e* Y
# U+ ^3 h, b; J* @ /* Terminate the API environment */; q+ b( }1 n; Q9 K. |/ B C' p
errorCode = UF_terminate();
+ r# C1 @8 j# s+ K, J }
4 O0 Z' c. J4 w# p
5 F' r3 _: D$ L( M /* Print out any error messages */# {( _* `3 g7 s- @
PrintErrorMessage( errorCode );& Z' k+ J$ k2 L5 G
}0 t9 e) k6 M; @* c: A. I0 M
6 q2 f" F2 m0 K! C0 j8 d//----------------------------------------------------------------------------
, U" d8 ^5 [/ i/ i0 B4 w// Utilities6 @5 x: }3 F- p, c+ }# b
//----------------------------------------------------------------------------
: R4 b( P1 ~9 x" e4 ?9 K% N: v {6 F) f2 J
// Unload Handler$ m! i; z6 ^/ p* s3 Q# m
// This function specifies when to unload your application from Unigraphics.
4 }1 Z3 C% y0 Z6 j" a// If your application registers a callback (from a MenuScript item or a: g! K$ c3 [% C1 S0 h
// User Defined Object for example), this function MUST return. D: Y, P. m* r* m2 A
// "UF_UNLOAD_UG_TERMINATE".
) d9 z$ g7 `0 ^% n' mextern "C" int ufusr_ask_unload( void )
( f' T. R& @& ~$ C* ?{
. K) P3 I: I* ~: ]' [ return( UF_UNLOAD_UG_TERMINATE );/ l4 T( e$ A/ G9 u1 H0 E
} u% E0 d4 z) [0 G: Q6 O
! z3 b9 r2 a; h$ Q( h, [* Y/* PrintErrorMessage
6 v3 D; p, I' {$ p' ^; G( t**! Z7 R* q0 c0 p1 s$ X
** Prints error messages to standard error and the Unigraphics status" v6 y% Z* ]- Z/ B' i/ I0 R& Y
** line. */
, x0 n6 P* N& f6 c: a% @. Vstatic void PrintErrorMessage( int errorCode )
/ p% l/ W! H ^$ O: H0 r! {{( M% ~4 q' L% x5 u0 i$ y
if ( 0 != errorCode )9 A* ~, L1 i a" p% ]
{
% W! d2 h3 N: O" G /* Retrieve the associated error message */2 [, Q% d2 Y& _ P$ j
char message[133];4 n/ R( S& D5 V% \
UF_get_fail_message( errorCode, message );1 `$ t. O' D! z: z/ v
: c" T# ]8 V; ~0 n
/* Print out the message */* z5 M1 k9 O; E0 x$ H- F5 k. m+ {/ a
UF_UI_set_status( message );7 g0 Q, q7 m) P1 J, S( C, C- U
5 y0 o0 l$ z* U- g' }. s7 h+ n3 X
// Construct a buffer to hold the text.. Y/ s- e( J: b
ostrstream error_message;, _3 W0 x( q, n
$ p5 k7 g3 R5 @+ D1 ^ r
// Initialize the buffer with the required text.
4 V* J% L) B* }! G: ^/ b% u2 W error_message << endl
- E2 o/ o7 N, Q0 E! h" G# T << "Error:" << endl
0 n+ F: @* d* A1 ? << message
2 c9 e, ^: ]9 W' \8 [ << endl << endl << ends;
7 n5 k7 G* o1 J7 R J: r1 x
' D8 r/ Z9 }1 k5 z0 U // Write the message to standard error1 i9 v" D2 a/ I: _
cerr << error_message.str();9 w1 }7 s2 e' j! S
}+ K2 L+ y) P6 V6 P( D, ]
} |