源玛:
1 q t* |6 `) m# w2 f3 ]: J, ?. t
: j1 _% p; S* _* L! [/////////////////////////////////////////////////////////////////////////////// o& s) D- A) R0 c0 ]# L2 u1 ~, o
//% W& @. d" V3 ` \* Z5 G5 j
// create_oper.cpp% X- d% U% a) d2 f
//% ~6 G/ U8 ^ l% g, f
// Description:0 Y: c& [; X9 P3 \- h$ k. z1 k1 b
// Contains Unigraphics entry points for the application.
9 G6 L9 q, ~6 _* M0 y//. f; l) j! I1 g( h2 O
//////////////////////////////////////////////////////////////////////////////- Y3 z. T( Z$ S! ^/ [' a
" j t+ M' n m5 j1 Y3 \// Include files5 V! \6 F' A4 [+ w2 O. I! J
#include <uf.h>
& F2 U5 ]/ k+ R1 t#include <uf_exit.h># m9 f5 A7 [8 N* _6 p' r9 {
#include <uf_ui.h>4 [, n$ n, J* B$ c0 A9 O/ m6 G* C
#include <uf_oper.h>' `% E0 q+ n+ ^6 R3 _) |" Y
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )+ L* x6 t: Q2 g6 ~" L) D, d
# include <strstream>
1 B/ N! k ]2 ^( E9 J/ b1 J# include <iostream>
1 _( L9 }8 \2 W( ?2 u using std:strstream;/ m9 Z9 u6 r- U: o3 \3 O5 ~
using std::endl;
. B8 G& A1 {! l! _6 R using std::ends;7 h- V. @2 i8 }8 r
using std::cerr;8 h2 [# K& s( I0 H: J
#else1 c' N% @ Y( ~5 T5 m2 x
# include <strstream.h>. i) }0 H/ e- t3 l' W/ u
# include <iostream.h>7 Y$ y4 G" D. j. g8 f
#endif
6 {9 `" S0 Z' \/ {: m# N/ C#include "create_oper.h") t4 N# A0 k. o) e# o5 c7 X* {/ W, p
$ I( d* e( g5 z8 l7 B//----------------------------------------------------------------------------! L9 _1 h# b C
// Activation Methods
6 ^1 v9 b3 t3 y D ~//----------------------------------------------------------------------------" E7 v5 P$ D( m7 m1 c8 u
& Y1 p8 ^3 b9 F: x% U( A// Unigraphics Startup& p7 j. w0 N, |+ W
// This entry point activates the application at Unigraphics startup9 T; I2 X! h2 G% a
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
5 `. a y( H ^0 X, l{( G3 P: D- T5 y
/* Initialize the API environment */) b/ S4 N) [& G9 i) l& j
int errorCode = UF_initialize();
1 X' x9 o2 H3 U# v. a* `1 `. J
) v/ Q9 M. h$ Q1 X if ( 0 == errorCode )/ g7 I" `# n+ } {
{, ?4 K/ T. B2 \/ \: S! i
/* TODO: Add your application code here */
H& i3 S) D2 T
2 x. s. v; J& @& ?: A, P char *type_name="mill_planar";* k. O5 Q! n) c5 U" ^9 l" @4 @( M
char *subtype_name="FACE_MILLING_AREA";- [& q3 C) Y5 t1 \5 n. y
tag_t oper_tag;& X: p3 t( y6 f
3 U5 ?+ d& Q9 i9 s- F @5 m
UF_OPER_create(type_name,subtype_name,&oper_tag);! P5 p" R: T# \! s. f
! A `- \" n; [2 q- Q. E6 t) l% g' m2 a' W& r* c0 [( h5 E
& T' |. G$ z& t( E o# e
3 `7 b7 u0 Q& @9 R; [6 D P
/* Terminate the API environment */( `/ G/ l( D: C) Y8 C% A b# Z
errorCode = UF_terminate();' U g& F/ H8 P! q9 k5 O$ j+ C8 X
}
2 Z- p8 F0 A8 t" V# a i4 _# Z& N. C. r7 f
/* Print out any error messages */
! n6 D" V$ Z4 T9 p! x PrintErrorMessage( errorCode );6 a3 e5 T; s* R. o7 x+ I
}
5 R* x4 D# ^3 C3 ?) B: |
; x7 R3 e2 `6 [4 s* g# i. x//----------------------------------------------------------------------------8 N( R% P0 d* T l4 e% t
// Utilities
( {$ l! D2 U' @' f D' M( O//----------------------------------------------------------------------------# g# O* k" I+ i0 T
1 U; q" r0 T8 {+ G
// Unload Handler
, p6 K+ i& y ^9 A// This function specifies when to unload your application from Unigraphics.% }0 g; B; r8 R2 R
// If your application registers a callback (from a MenuScript item or a6 B5 l, E/ t0 c% `& B
// User Defined Object for example), this function MUST return7 X! G/ p# F1 W& M, ]7 ?, k
// "UF_UNLOAD_UG_TERMINATE". h: @# [& X% W5 A6 F! V
extern "C" int ufusr_ask_unload( void )
+ `' L/ e1 t% \2 n{
; ^" ^* v7 R! [6 t- I/ S# h return( UF_UNLOAD_UG_TERMINATE );
4 C. S B. N9 V4 q5 w6 c/ ^}
$ |9 g7 X U, L. O: H1 l2 Q) F. ~5 _) y) d
/* PrintErrorMessage5 _" N) m: @+ e0 M0 O
**5 o. ~7 g+ [0 d1 Z D& _
** Prints error messages to standard error and the Unigraphics status
# O: L7 O/ @- w$ d5 X** line. */4 W; w, X6 q% i, m$ Y$ @1 {7 k9 W
static void PrintErrorMessage( int errorCode )
' s2 w( k4 F' i- s6 w; A{0 g. z. U( c% z+ v; J+ \
if ( 0 != errorCode )2 x0 D% `0 j5 E: ]1 o
{3 h/ x1 ]' g8 y' x2 f
/* Retrieve the associated error message */7 V# @: B0 ^4 a9 [' X9 ~ ]- ^2 E
char message[133];
' W: S9 d6 J7 j6 i# G UF_get_fail_message( errorCode, message );% D! O5 g# M; i9 B
3 D/ n$ X/ Q6 {/ k3 l# N
/* Print out the message */1 ]" c* ^& k2 s( E
UF_UI_set_status( message );
% D" q4 q4 w4 U. y/ x) T
3 }. p B$ b+ e // Construct a buffer to hold the text.
2 A$ `" d( x/ { I( T# m! J ostrstream error_message;
+ S& E0 e8 |9 R+ \" H8 c. Y- E+ B \8 Z
// Initialize the buffer with the required text.6 k! l+ \" h9 _. `# j+ f) ^
error_message << endl+ e+ J- U6 g- P; B4 I
<< "Error:" << endl
z: d' O, u+ B << message
" J( t- R; ?( _ << endl << endl << ends;. @0 d8 `! {7 h% r8 ^
9 t# u3 a4 q( ]8 v. h0 ?3 r // Write the message to standard error
, g! C3 d9 @. u% u cerr << error_message.str();
8 g! Z- h( |) ^- N) A! w$ I9 s7 I }
3 k. I* e! B0 a$ L9 [} |