源玛:
* [& E: d4 e6 L% R1 ~+ i% F9 b5 K3 O+ N) X
//////////////////////////////////////////////////////////////////////////////
6 e% o9 g; U5 a//) j) ^. j2 | c/ S* J5 Q% ^' T, v
// create_oper.cpp
) S; j/ H6 B* z8 k" \" ~! ?) N3 |! a//
" z7 t) D7 p: X0 D' R/ K// Description:
* W* C0 ?8 [+ w# t7 _2 _// Contains Unigraphics entry points for the application./ L: H' V6 W5 v4 y$ f* n
//9 T, D: i! l9 D B( v
//////////////////////////////////////////////////////////////////////////////
- _' H: v$ ]# k6 ^2 B7 M, v" d3 _* U0 W$ s% Q2 v
// Include files* B% _) t m( B* S+ S- n% M
#include <uf.h>
" X, ]" X3 u1 s7 u# P#include <uf_exit.h>
* B2 C) D; j" c/ W- E) {#include <uf_ui.h>
7 m! D: U3 t2 Y5 J- Y$ Y- C# g" z#include <uf_oper.h>( q# j& z/ E% m! Q* y
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
/ q/ @) W# Z, t' @. c7 k2 _4 S3 f# include <strstream>& g% k9 S( J& P& P) Y
# include <iostream>
0 @. o; a, z1 z3 p6 l% j2 t* x using std: strstream;
, U4 h. g9 C6 e8 D% i: }6 j using std::endl; & O' r8 u/ b" ?0 E* } U/ r5 D
using std::ends;8 z+ A$ [6 P+ m$ t5 y! i4 x7 b
using std::cerr;
0 g1 U7 a7 n# c9 @6 X#else7 H- [6 ^& c& Q
# include <strstream.h>
' V; k$ [6 h9 {# M1 C' a8 i# include <iostream.h>
_8 m# T o6 T. F% E. a# q#endif% u9 {; ^- T0 J' n" Y
#include "create_oper.h"' k( N+ r1 Z0 b r2 E' W
6 }0 L- r# `% h. u8 E
//----------------------------------------------------------------------------9 f: }: {3 s' f3 G' Z. X$ t
// Activation Methods
6 F. D/ Q3 _* m//----------------------------------------------------------------------------5 w$ B9 ~. a: i( S" }7 N/ s- G6 m Z# i
* e. b' H$ q! H
// Unigraphics Startup
+ p# q9 V& B3 r: b! z+ w// This entry point activates the application at Unigraphics startup
- r. ~# n/ ], H8 A- f/ ^& ?- k/ zextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
- I( F9 a0 a0 H3 D) ]- X{5 H0 T" A9 y9 Y/ l6 F. M
/* Initialize the API environment */
! z4 i1 X8 c% C! H0 H+ _ int errorCode = UF_initialize();( b" k* z0 p$ |$ {
* [; r# s W9 F# H& O. Q
if ( 0 == errorCode )+ I1 q* K* o, G1 l7 ?6 F9 o
{
2 F6 M+ ^9 B5 E /* TODO: Add your application code here */
6 l% E, q. g8 H W9 b. R2 {3 G
5 b- W: G& N+ ^; l" [7 z( C char *type_name="mill_planar";3 d$ x1 [ Z6 W7 @
char *subtype_name="FACE_MILLING_AREA";6 E3 m! k1 W) X$ x& E, o' ^
tag_t oper_tag;
9 Y7 ]2 l9 M6 y. W
" p! ~/ r# D- O" U UF_OPER_create(type_name,subtype_name,&oper_tag);
: q5 z$ d* {8 K$ q! a- M! C/ [, x9 O# }; r/ F
& P) @5 u. _0 e
$ F) u4 A. d6 { N' f2 a. l$ F0 [0 a% q/ H% t
/* Terminate the API environment */
- U$ i4 s9 g6 n6 {' o errorCode = UF_terminate();6 B, P' Z2 O( K- q5 T
}$ v! D2 O- R) P& H$ W! w
Z$ H+ [% ^% q$ ^6 m8 w% Q /* Print out any error messages */* W9 C8 S+ M, h4 I5 v
PrintErrorMessage( errorCode );
+ q1 b. O5 G' k& p- j; o9 X}) ^" P. \9 Y. R* c8 _0 y( H
9 e2 Q) T" @3 A: E: j3 c8 z( c; o6 d
//----------------------------------------------------------------------------
' G/ f3 y7 a! C; s) R8 W// Utilities( h3 N# q. c( t3 N2 c; P! P
//----------------------------------------------------------------------------- Q+ s( ?2 g y! x8 ?
- O5 y9 e( z' J \4 ]& q// Unload Handler
5 c- R) C0 \8 e+ Z, D// This function specifies when to unload your application from Unigraphics.
- } g7 j- E5 _5 ~; j* H3 S- y! a// If your application registers a callback (from a MenuScript item or a
2 @% P0 N1 @; A k// User Defined Object for example), this function MUST return
# l' u% w( G! y8 V6 f// "UF_UNLOAD_UG_TERMINATE".1 E5 p/ |! R" J4 z0 @- U8 l
extern "C" int ufusr_ask_unload( void )
7 f4 c+ T" ]4 ?{2 M( U' I( `4 b; \; z" ~' q
return( UF_UNLOAD_UG_TERMINATE );, z5 ]( N# r8 \. L8 w/ t
}
s6 Z- Z% P+ y1 z& |. P+ \$ Z2 _% M# ^( o! C, u
/* PrintErrorMessage4 h M' Y$ f& X
**' Z1 S! \3 O9 [) E( x% \4 n
** Prints error messages to standard error and the Unigraphics status
5 j6 d. h% J3 ?- o** line. */' S; }& X( K% t# a0 }( U; a0 u/ ` e
static void PrintErrorMessage( int errorCode ): s# `6 Z8 ~! E* i7 C, o- R q
{0 L# }: [4 ? z0 X
if ( 0 != errorCode )
' b. D8 Y! C- |- w {
5 k! [$ D; | S6 U9 |) f4 v /* Retrieve the associated error message */# E, o$ o, e' ~* a( m1 m* A4 i) q
char message[133];7 m& H- B6 z% m! }) y+ @5 F3 F
UF_get_fail_message( errorCode, message );* R' Q4 [4 B* c- a2 o( k' E
4 S ?/ F( P( e; c# @3 N2 O /* Print out the message */
2 d3 R# ~) O9 d5 k. s% Z5 K UF_UI_set_status( message );/ X; Y; c- F7 F4 b0 G9 w
7 K& a: L- Z+ {7 Y! t) A // Construct a buffer to hold the text.- v( a. B) c' i c$ w6 M
ostrstream error_message;
- N' q$ k+ E7 q
. d) d, [7 ]7 U4 j1 J$ X/ G // Initialize the buffer with the required text.+ b" ?/ y; ?- ]8 X* c5 H0 v
error_message << endl
u3 ^. ~% r1 ^% k, K2 G3 i5 s1 B << "Error:" << endl
2 Z7 T- \/ e* U" ^) U1 i0 N << message
( H% ~& T( T; e* ~3 a% s8 S << endl << endl << ends;
, O3 M6 _6 H/ M3 _9 h6 v# n3 B
D4 H ?: R0 ~% @2 j // Write the message to standard error
. g' d+ x* X% f2 R- v cerr << error_message.str();
& m4 @5 Y5 U/ k2 ~1 W8 Z8 c2 ] }( C. n; g1 ^1 x& t
} |