源玛:& g. I, [+ |% v% K7 w) A2 u
6 x S- @+ P( ? B, o
//////////////////////////////////////////////////////////////////////////////* @3 R3 |/ c1 Y0 F% x/ P
//4 d8 Z. V8 ?8 j. N
// create_oper.cpp8 q, c/ x* t8 C
//
7 E0 e, P9 l- a' a// Description:! |( S6 m1 K4 y0 v6 L: |
// Contains Unigraphics entry points for the application., d9 Y! z/ ] a- D! G
//
) j- N1 ]* Z; d7 m# w7 l//////////////////////////////////////////////////////////////////////////////# w( j: F6 h# T/ Y" u; ^
( i2 Q8 B& P4 W3 Q, L* }// Include files5 ?- w- V: J9 h4 `9 A
#include <uf.h>+ Q0 C. I+ b5 Y: h. D1 F1 l, q
#include <uf_exit.h>
# e1 n' {; z; J8 L' G! X#include <uf_ui.h>8 r8 h' J% y y5 L
#include <uf_oper.h>
" h, P% O3 {! }1 I" x" a9 X#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )2 ?" v( e9 J$ n. E! T+ K9 z
# include <strstream># V. b. T, ?4 |, L0 K) D
# include <iostream>
$ Y/ w9 s1 t# O" j! _# a6 o using std: strstream;
; K' X6 O# x8 T5 k# F using std::endl; ) O5 K7 y M6 Q' i+ X
using std::ends;
/ ]7 G. D( P4 M) k; Y using std::cerr;
; K% q( r, B( H#else' E4 J3 L, a& ^& f8 g5 O
# include <strstream.h>; O, f$ g% E* [9 T( Q( F
# include <iostream.h>& D+ s( Z: F8 z4 X; \3 W. ~
#endif8 u( H( e2 |9 ~" A
#include "create_oper.h"
. j1 O+ ?, q* ^5 i6 t8 L5 Y' t+ K; L' m9 A! M; ^# i
//----------------------------------------------------------------------------+ e+ L* S* w4 B1 u. H2 {
// Activation Methods
8 M1 a q" c' r1 ^ r8 r0 J//----------------------------------------------------------------------------5 D" J! h9 ?! U9 [8 x# Z3 Y
2 N8 R2 H5 J8 H$ S) o2 t7 x
// Unigraphics Startup Z" O: c6 t. Y3 x6 k6 t% ~0 _1 m
// This entry point activates the application at Unigraphics startup
7 P" m+ T4 y* y2 C. a2 Z8 w1 jextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
7 _" C/ Q( |# P, C( p* L{, u+ D6 j6 s5 S. ]
/* Initialize the API environment */
1 E. X E' Z" _ int errorCode = UF_initialize();: f; O' z! b4 s6 j6 f1 r0 ?& P
5 A& o! m( t2 C: ] if ( 0 == errorCode )
7 q2 [, O/ h) A {
0 j' g; ~6 v" a6 T+ h# k. Y1 I( R /* TODO: Add your application code here */
9 I. A; ^6 L) P/ E5 \& [0 F+ [ @& c9 V& C- |4 i
char *type_name="mill_planar";
# c- O; V2 G# y2 L. j; ^; ^' G char *subtype_name="FACE_MILLING_AREA";
/ t5 ~4 v# }; ~ tag_t oper_tag;" N! E9 o3 r$ t3 N; Y, e
- {4 n# I/ R" {+ D K* d
UF_OPER_create(type_name,subtype_name,&oper_tag);4 X# Z% r+ R5 ?' G; q) c7 m `
8 P2 Y. A, F8 s- S& U5 U
* V3 s( x% m, r9 D. H* x* I) b
# H9 J4 _: ^/ p1 y6 {( i
5 Q5 Q& Q' C6 c; D: E7 L0 e /* Terminate the API environment */
9 i0 B1 Y# h' u3 o7 Z% O. i errorCode = UF_terminate();( @% e3 O' e' _- W% y/ i8 x
}
' l! ?% a( m$ ], w/ y v* x4 N* W! M2 u
/* Print out any error messages */) k, ~4 [- x: v5 Y& G. Z6 C. Y0 u
PrintErrorMessage( errorCode );3 c, g3 F: p% T2 U# M( k; l
}! B; d3 u$ a2 Y# q/ ?
* D5 p: u% n$ }3 z* T" q' R( y
//----------------------------------------------------------------------------
; d! Y. z |* }// Utilities' E" ]$ {, O7 N7 q; i' J7 D
//----------------------------------------------------------------------------8 o# Y0 j3 y. Y( ~ |
1 g1 f* D7 H- J9 G, M// Unload Handler( ]$ u3 o6 y& S |; U, M
// This function specifies when to unload your application from Unigraphics.
: Q' d; I% u/ @' ]/ S// If your application registers a callback (from a MenuScript item or a
6 q7 u3 e2 Z3 H// User Defined Object for example), this function MUST return
]: j. J. H3 g$ d% f0 u+ i6 n4 G// "UF_UNLOAD_UG_TERMINATE".9 a$ P' U! {6 j* h
extern "C" int ufusr_ask_unload( void )0 U& I! @- K$ u! [* T
{
8 _5 Z: H0 v2 i! i5 i return( UF_UNLOAD_UG_TERMINATE );
( ]( p3 s# ]& D( z}1 P4 N6 A! ^5 @4 Q U
3 z/ G9 l2 d R) T( v* X/* PrintErrorMessage
5 j# i j% Z4 g4 h2 W**
' R+ U) {8 q3 ]- j) W** Prints error messages to standard error and the Unigraphics status$ p/ i+ V9 f7 D7 V
** line. */1 n$ S' S9 N6 x8 ?
static void PrintErrorMessage( int errorCode ): X: Q$ r4 e6 Y+ X. e
{
9 v4 T2 e8 y1 u4 I: ]! l* v8 { if ( 0 != errorCode )9 }, O: g8 w# `1 ]0 C& z' `4 a
{8 P& h6 x4 ?7 S/ R
/* Retrieve the associated error message */
- c2 Y7 f% D+ Z) t2 Q u8 A char message[133];
1 y. A5 B+ _6 R UF_get_fail_message( errorCode, message );
8 u% K; O* r0 ^9 W0 U
2 c# Z* k% j- E" ] /* Print out the message */2 T. Q7 U/ U& F/ f
UF_UI_set_status( message );2 a5 B4 D! V$ `- ^
8 L4 ` X2 g! Y
// Construct a buffer to hold the text.
) F- A" r8 a6 V$ { ostrstream error_message;
% e( {; z1 z# G' q: `3 h5 t5 O
& p5 q; _* l; H; z. [- b4 ~( z u4 u // Initialize the buffer with the required text.2 J5 p2 u& I& y# x+ ]% h( U- a9 F% q
error_message << endl& Z2 l5 L" a. }1 A" t0 H
<< "Error:" << endl0 P% H) A: j: s/ t" B
<< message* Q; I; M' c# h/ Z
<< endl << endl << ends;
/ I3 Q$ k2 G3 E8 Z5 \
$ c& F7 J5 f3 u8 x // Write the message to standard error
. X S1 f; u- P8 q cerr << error_message.str();
6 e9 Y2 ^2 z% R) ]5 M }# D) a- V4 c9 o5 W
} |