源玛:0 l' {$ K5 F) @+ B
& u3 B2 ~/ V# t; E y//////////////////////////////////////////////////////////////////////////////$ e, e. k* k, @% d3 ?7 p
//
6 a- s# T$ q F0 _. ~% @+ A, Z5 m// create_oper.cpp5 b) d1 N( F; {% ]* \
//% J1 D8 y' x& \3 B1 c) \0 }: ?
// Description:
$ b! k B/ X9 F H// Contains Unigraphics entry points for the application./ W( I; k1 q7 M9 b& T8 Z% b1 F
//
! q9 a! u! g. [; k! C//////////////////////////////////////////////////////////////////////////////
3 |1 |, k; h/ `3 N( `9 [% c1 u0 V! k, ~ y4 L1 p4 p# T+ ?) [
// Include files! d3 _9 z; P8 Y0 u
#include <uf.h>
% Q! w9 J: i. F) j#include <uf_exit.h>. z* J4 f% t2 f# x; @( ^- m' Y
#include <uf_ui.h>
4 Y! O: |+ H5 m4 B$ X. L#include <uf_oper.h>
& u7 b$ }3 X( n: R8 J$ C, Z#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )% _0 S0 z8 A4 l* ^: ^' V0 b, y
# include <strstream>/ Z0 r, U2 h6 c" R
# include <iostream>
5 p: E# T' e; J4 G. x5 d& b using std:strstream;
3 W8 g- H5 l' ^# Q* w using std::endl;
6 ~0 w( \+ w1 t6 E using std::ends;
. ^% I: k1 e; H1 \8 o9 q using std::cerr;
# [/ N* S. R0 [& A; q% a#else
1 E# V3 _0 I9 n4 ^ u6 c+ w# include <strstream.h>' `" c" a& `7 S8 i
# include <iostream.h>$ f# v5 B% A* S
#endif+ w3 A5 c& e5 P$ Z! f" A s
#include "create_oper.h"
% j+ ]) i7 }6 o: o
1 r3 d' `, K+ R- T$ ^" [//----------------------------------------------------------------------------9 J) j; I7 l3 z! g- x% L
// Activation Methods4 P/ H9 M* O- ~/ x- L$ d( z7 U% W
//----------------------------------------------------------------------------
" \% n8 K7 E8 H; ^/ F4 ?0 G6 r# `
9 W9 w* B! d8 g// Unigraphics Startup
$ j6 ` y9 I, t0 `5 t& h' a// This entry point activates the application at Unigraphics startup
6 z2 V4 A: M) ?( t7 C6 sextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
+ r" L @* b: a1 s% O- N2 G/ a( O{
; L* I& x! u0 U& \5 D$ x /* Initialize the API environment */
: \/ [5 I: R$ v" o4 m int errorCode = UF_initialize();
`2 p2 y, r0 Q$ q8 A- k, c% Z' K" E1 s5 c; ~/ e6 }
if ( 0 == errorCode )1 o4 A5 y. G9 G; ~( e1 n+ }
{5 `( S5 @5 E" L0 K0 ]
/* TODO: Add your application code here */
/ i$ I/ {* G+ a/ P: ?. h1 o% Q `* }1 F; i+ |* U: [
char *type_name="mill_planar";: m/ W. R; t3 G. p$ L7 u2 J2 j1 I
char *subtype_name="FACE_MILLING_AREA";
* {1 O m! c7 f9 i tag_t oper_tag;
" q, z1 d6 U5 D& u) M; J/ {
; D( V, m& b8 Q2 I# p! i UF_OPER_create(type_name,subtype_name,&oper_tag);
. Z5 E4 {/ ~ v: x) W( k; H
* S9 s8 t- p9 C) R, Q% ^ y/ ~6 Z) Z/ W1 H9 @
8 X4 \0 @7 L# o% D K' K! D
8 C3 B. S) T( I% N! k /* Terminate the API environment */
# V2 ?) c5 e* ^* E/ S errorCode = UF_terminate();; B. t- E! p* T: p+ i7 k
}
; n. Y: z* }9 e$ R1 }. @
. D. q, C5 G7 u /* Print out any error messages */* Q7 A$ L! i. |) n
PrintErrorMessage( errorCode );9 h( L. ]. _: a7 u! W
}
' z# `' B) O& Y$ u+ [0 S6 r/ `( i; d7 ?
//----------------------------------------------------------------------------( M) D8 n G% g* \& a" o7 |+ \* x
// Utilities j0 x% P0 Z! M5 d5 I$ L
//----------------------------------------------------------------------------
. X* X& I& r/ V& y
! M/ ^* `5 E1 Q! L// Unload Handler" g9 @$ x6 t) o' ?8 B% F }9 b
// This function specifies when to unload your application from Unigraphics.8 H& g# L9 Y; m+ @' o) k
// If your application registers a callback (from a MenuScript item or a
. L" ~2 I: q9 k6 S+ @% P// User Defined Object for example), this function MUST return. |, a2 C' z u8 _7 i
// "UF_UNLOAD_UG_TERMINATE".+ y' G/ b/ K; _- x4 \$ m
extern "C" int ufusr_ask_unload( void )6 {% U4 u8 p4 w9 g2 d! Y& U% Z
{
- f; O6 [: w, N/ S5 h& q return( UF_UNLOAD_UG_TERMINATE );! W+ X$ A3 }- k8 q( m
}
) |2 q1 g8 c5 Z6 i9 t
6 c; Z9 D0 {0 _: C9 z/* PrintErrorMessage" |. T# c) e. r* L- }/ f8 K
**
0 X, g/ m2 D @; b1 f+ l& E" Q' p** Prints error messages to standard error and the Unigraphics status
; M! P- E7 C5 I0 g8 O0 H** line. */
, h h3 i8 j. W4 j3 Hstatic void PrintErrorMessage( int errorCode )8 ~. e9 b" ?( I3 e
{- X' ^ W9 o* F W
if ( 0 != errorCode )7 I& L( ~8 e8 o9 p& Z
{
. x) |# {, ]. w/ c" T( y /* Retrieve the associated error message */
3 _; y2 N9 y. o7 q char message[133];
8 I2 q/ w* Z) X3 W! z UF_get_fail_message( errorCode, message );; m5 h( X1 w2 x5 ]# ]$ [# E* q
( s% ]9 L0 J+ F. P7 Z
/* Print out the message */$ o# W" X; w( B- h' Q" X
UF_UI_set_status( message );
5 \" W; T6 p9 n2 ^2 i
: _9 y1 s# W0 A8 v; ] // Construct a buffer to hold the text.1 }( o" l( w. m$ m
ostrstream error_message;
4 T: k9 S. [% a4 X1 B2 H/ m9 \, ^2 b9 d0 M& z: {; L' H
// Initialize the buffer with the required text.9 J9 n0 V% f9 b' X5 R9 A( {* j7 q0 C
error_message << endl
& Q- D8 J1 g7 u9 H1 d2 _ << "Error:" << endl& B; j2 V9 M) I- b
<< message7 l* Y; \$ V1 y9 u4 \
<< endl << endl << ends; R" I/ Q% J. k- O
2 u1 L. V2 R+ x2 L: O
// Write the message to standard error& c/ B2 }/ g9 B7 O
cerr << error_message.str();
) D+ h) [. P1 t }4 J/ j8 V M5 N' U" q
} |