源玛:$ s2 ?3 E1 B+ ^) m9 K+ N
7 Q4 h; V G' v/ M7 |
//////////////////////////////////////////////////////////////////////////////
' j, e0 A+ }% m7 Y' j//
a( a, v+ e& d c# n. v// create_oper.cpp+ u, B: h# j) }5 y. r3 f
//
% s5 a9 K1 q! @. ?- V// Description:$ w8 w; ?( l- a2 a2 {
// Contains Unigraphics entry points for the application.& B: N& S6 U2 j! v: C3 \- `
//
1 b. S$ C: y4 ^- B4 ?, f9 p//////////////////////////////////////////////////////////////////////////////
; O ]5 ?# P$ I5 F: |- y
% S1 m8 e ^! O( G2 ~+ ?// Include files4 K: n& _, T* \7 P3 \, M+ }
#include <uf.h> L* M" j* q4 u
#include <uf_exit.h>+ A: G5 e, T+ _6 B3 l# R
#include <uf_ui.h>2 k' X& u( |5 p% Z
#include <uf_oper.h>% @6 D8 m( Q3 ~7 P
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )* ]; y5 ^$ C, z) q
# include <strstream>
/ V7 v# f5 r5 l% o& B* {% z+ @# include <iostream>
$ F$ x7 ~8 f2 d! U' M" x using std: strstream;2 R9 G0 l% r/ Q X
using std::endl;
1 |) k- ` Y$ U- | _4 H6 J using std::ends;
$ Q5 d! t9 A4 y5 g4 } using std::cerr;
) d0 c9 P* w7 J0 i& ]! R R#else: ]7 g+ G2 ^2 Q+ U0 X( h
# include <strstream.h>
, D) k1 q3 V8 Q# include <iostream.h>
1 o" D5 Q5 e. ^, q K#endif
+ y$ X, p! | s( D2 o5 \' {% G#include "create_oper.h"! f5 e/ s' Q6 b8 ] Y
; }- v- ?: f8 T, C
//----------------------------------------------------------------------------
6 S& M, f( Y) z9 j// Activation Methods$ t6 g$ `, K3 m- U$ [9 A" X- q( \3 ]
//----------------------------------------------------------------------------4 \' |- ~8 s* H" c* l2 b
. p" t" `* q+ U2 |! M
// Unigraphics Startup9 j2 Q( t0 P( O. h1 b$ B
// This entry point activates the application at Unigraphics startup
& V) f+ r. O; d6 g5 x1 I5 r+ vextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )+ W: D/ v$ d$ u% z- Z$ i
{
7 c% C/ J G' |5 i+ r% G" @9 v- ~6 \ /* Initialize the API environment */
- }% P+ `7 L3 ] int errorCode = UF_initialize();6 b: ]( o& d7 ~0 H& m: x5 }
, v$ C( F" ^7 L' L
if ( 0 == errorCode )
: Q( m: t8 n+ T2 y. v9 U8 Y {
% _5 l" S+ h7 [ /* TODO: Add your application code here */
& }0 n4 {# ^2 K* |" m3 H8 s: P, O
+ {% V: b- F' o9 Q! q/ b7 Q char *type_name="mill_planar";5 r" d2 y6 n& o
char *subtype_name="FACE_MILLING_AREA";
8 s* g4 c( @: S% N tag_t oper_tag;% S, E& ^; s- R4 }. Z- C; k& \
( E! ?) u5 S0 x! R6 y, q! T
UF_OPER_create(type_name,subtype_name,&oper_tag);, d/ a$ R7 U# c* I
% |2 _3 \. X. i9 Y7 m# t9 k+ i
* b3 T% Z r+ q
! N4 E* u6 L! z! B
2 @ o& L4 ~# S( `" N- j' f" r6 \ /* Terminate the API environment */7 z9 \9 I& d: N
errorCode = UF_terminate();
, Y) t" M8 ~! u2 m! v" M }! _0 _ ~. I9 a2 K. l3 s1 ^
; ?" U; E- z0 Y7 c) `8 k0 Z
/* Print out any error messages */
. y8 F9 A8 ]( @) d, P/ m PrintErrorMessage( errorCode );
# M0 |, r4 H, b- ~7 s- q}
+ H4 V2 p, p: l4 b, _$ I) i+ X9 ~* H1 e P
//----------------------------------------------------------------------------
; b, l& @8 m/ N6 M1 D; E// Utilities
6 z6 w' v. X2 W) [8 {! t" R//----------------------------------------------------------------------------
$ t) L/ ^, x- U0 ?: k( a
; L& k1 W4 P) q" F1 L// Unload Handler4 c9 B! z! }, U
// This function specifies when to unload your application from Unigraphics.
: w9 `7 q* w+ G: w( p% m// If your application registers a callback (from a MenuScript item or a
$ }2 u2 {7 v& Q! b) ^% K+ u// User Defined Object for example), this function MUST return
) B0 ~5 `0 L& I `- Y// "UF_UNLOAD_UG_TERMINATE".& s! [8 H4 }! R+ M
extern "C" int ufusr_ask_unload( void )
' b1 D" {, f! }0 o{5 D9 v- X' x: Y) t
return( UF_UNLOAD_UG_TERMINATE );
: G4 c" q1 F$ d g S9 p}5 C) J2 P" A( `) E9 q/ P- S" n
6 l4 b& f* l$ p5 {/* PrintErrorMessage( I( R4 L" a0 j) ^
**. p% \/ u" Q7 P
** Prints error messages to standard error and the Unigraphics status8 c7 J. x0 R! i7 W
** line. */
0 h/ d4 L( n$ A9 [- v& Estatic void PrintErrorMessage( int errorCode )6 R4 D% m4 H' a6 G
{+ L/ e# B8 C5 z$ M" \
if ( 0 != errorCode ) l6 }, E# m# ^2 `7 v. z9 i
{
( _8 E- c" s- g# o" w. ~$ ? /* Retrieve the associated error message */
4 s2 [2 T2 A/ _; f2 M, C char message[133];5 }- o- l5 @% k
UF_get_fail_message( errorCode, message );3 B' T0 e% ]/ ?; Q9 G& Q3 q2 i
6 Z$ q c& r; @. B: V$ m1 M! ^1 L2 A* X /* Print out the message */8 d: ^6 T- @9 D3 c5 |+ D! L
UF_UI_set_status( message );
; ]3 w5 c6 d' D+ R. x& E4 }' P2 d* N9 U8 F' R, h; J3 G( j! U: f
// Construct a buffer to hold the text.' j, Y5 G- O' @6 l* e
ostrstream error_message;$ s% f, X% Z/ f2 k6 i" Y. O
& M- }. C1 v" M, ?
// Initialize the buffer with the required text." G) Q) d* X) m9 F; P( H
error_message << endl
, e0 M3 \8 U5 W/ b, B/ a6 Q* w( P* v; g << "Error:" << endl/ ^7 ~1 o/ ]2 _" N7 J$ Y. M; z* b
<< message* I& [% f5 V$ C' v, [% I
<< endl << endl << ends;
6 x- A5 d% e4 v& M3 C; X3 t. Y# V9 l& \* n
// Write the message to standard error
" i0 b* F+ O$ c( Z9 J$ W2 p cerr << error_message.str();$ ^) f$ b& K' ~- l! ?
}* x+ b5 r) L4 |: N5 t
} |