源玛:
: W5 j: h" q- b4 @% `& R4 m# u& J: y6 {+ k
//////////////////////////////////////////////////////////////////////////////& ^: r. i& M- J& n
//
. R! F8 a; c6 s) F2 A7 `4 d: W// create_oper.cpp
* G: ~0 z9 H! S9 d1 Q- h$ m) X* e//
$ x9 ^* e# f0 l! l6 n// Description:3 W! L. u5 L" l
// Contains Unigraphics entry points for the application.& W" n! Q! [3 m/ ~
//
, {% m8 P" Q' c7 H//////////////////////////////////////////////////////////////////////////////8 d6 v! O3 `$ q7 J J$ ^! T4 m% J
: M2 k/ K- p c/ u, H2 { b" a" P
// Include files
P; c; c. J! [5 x0 O3 O#include <uf.h>
2 M$ V6 |6 e% Q# Y#include <uf_exit.h>; {* z" g/ c% _0 G* l6 s
#include <uf_ui.h>
% \7 n' @ b; o' F% Z5 T& y. b# _#include <uf_oper.h> L* E$ M1 X" A7 P+ z
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )! z3 z( {' `6 w& @ F
# include <strstream>
' G; @ N, d0 l/ U: M# include <iostream>5 l$ K8 s( y% c3 G
using std: strstream;
# n: x* m9 R5 u/ z8 L using std::endl; & ~# P( _4 J; ~7 f: b. B
using std::ends;6 L7 o. V* z& b
using std::cerr;/ y; t1 w- M |7 F* v
#else
' f; C+ T' A, n# include <strstream.h>
* _* H8 }( q' o( k$ p# include <iostream.h>
" r3 \' `) Q" _& G t; S- Y7 _. M#endif2 H0 f0 o2 I+ S+ m
#include "create_oper.h"
2 x3 J0 ], L S, I5 h7 U& ~- H5 A5 \* N" H$ w$ Y5 j
//----------------------------------------------------------------------------1 s0 h/ D0 I! w. {0 ~
// Activation Methods
$ a; o! L* y1 H4 e0 Q1 n0 P* W//----------------------------------------------------------------------------
5 s! L) l3 E, y" Z d z/ l4 z0 F5 y! b) i% X/ |* ~0 s
// Unigraphics Startup3 G: ?( E% U6 @ u& K# C
// This entry point activates the application at Unigraphics startup
( k! f7 g7 k5 A- s0 L) }3 g# h* g; |extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
! B# P7 U. f. F{
o0 v% I& Z+ s2 D9 R9 R' I' t% r /* Initialize the API environment */1 t; u8 z( l; u- F* c n1 [( R+ P
int errorCode = UF_initialize();& j! {6 x% }0 F5 ~% H i0 M
/ p* Z1 Y& ?5 P) G1 }4 f8 C# O
if ( 0 == errorCode )8 ^( \3 v4 l; F D. k
{
% v! u# Q) E3 f+ ]3 i9 `5 f /* TODO: Add your application code here */4 i! b/ y% O$ K# _& p1 Y
9 G& B8 J J/ f; g+ y
char *type_name="mill_planar";( _9 _1 d" \3 w) u- n5 c6 L
char *subtype_name="FACE_MILLING_AREA";' k$ d2 I8 e& \: W" [7 h3 d
tag_t oper_tag;0 z4 U! M' _1 b- U. C
/ C$ t. b) O8 |) f& P) Q: U
UF_OPER_create(type_name,subtype_name,&oper_tag);
8 l L2 _# x3 Z! Z
1 t6 ]) ~8 x4 ]+ @6 V" `) x/ y6 M4 W8 ]8 B" R9 F( ^
' C! q" g2 e: F3 I2 w. j9 L& |/ E, O9 W( G" `! g* _
/* Terminate the API environment */
) F6 Q: o. _0 T" D7 h errorCode = UF_terminate();0 e, x- y7 M# B
}5 s! Q; a! V5 S1 V
( x9 Q9 k' w, ]' ^ I! n
/* Print out any error messages */4 e) o$ K3 D3 a) z
PrintErrorMessage( errorCode );
- z- S) C q' h" W; l' C: Q0 M8 H}
, a1 G) D8 m, p1 V H& k5 K
: j0 o/ S( T! B9 J8 t4 X S//----------------------------------------------------------------------------
- V" n3 q5 j9 E/ v" E5 O// Utilities: \- O4 b8 ~+ d' I
//----------------------------------------------------------------------------
$ k9 _( p/ ~) X; a8 h( }
( ] f+ @' b7 z: d8 ]! C/ n// Unload Handler+ D$ x4 d( T w. ^, P$ [; B, {
// This function specifies when to unload your application from Unigraphics.
# x8 X, l# z- C# o7 W& q2 @# U" H// If your application registers a callback (from a MenuScript item or a8 g' T/ {1 }9 R" e! K/ ?; h
// User Defined Object for example), this function MUST return& i3 c9 k, _# k; ? f
// "UF_UNLOAD_UG_TERMINATE".$ f. r7 K, l% @, A1 t
extern "C" int ufusr_ask_unload( void )
" H* E5 q* N p! z% o* M{
$ R- z/ w* n: K' ^- X7 Y3 r- t5 @ return( UF_UNLOAD_UG_TERMINATE );
& ~ ]3 [0 p2 F, {! C" P4 ^}- d {# G! h6 m2 v2 b
2 v6 E. T) m4 M- [* ~! M9 l( Z" B/* PrintErrorMessage
1 B, l3 h4 O3 a7 B* ^**
+ i$ U+ c, S1 [( v- K9 K** Prints error messages to standard error and the Unigraphics status
' L0 q. w9 z" o, T/ V+ [" F** line. */
- t; u* j. G( k6 P3 vstatic void PrintErrorMessage( int errorCode )4 e) K) D$ b8 j. L! L
{
9 } k, F% Y' q3 U7 A if ( 0 != errorCode )( t l) z3 B- h6 t3 n
{1 z! |6 Y2 D$ O" K3 _
/* Retrieve the associated error message */8 Q# n, n9 [, ?: }
char message[133];! G2 \8 d: j' N3 v9 V
UF_get_fail_message( errorCode, message );
/ P3 k9 m- Y# y& s6 z% P
. f8 d$ \3 y% o5 X /* Print out the message */# A# c1 f, `) h0 x& `; @' x% i
UF_UI_set_status( message );" H- a; ~& |, v
1 }: a% {7 C' d: y' z( v // Construct a buffer to hold the text. ~% {9 \8 p) k' ~+ @: x
ostrstream error_message;
4 ]; y+ \. ]/ ^7 [8 a
: d8 {9 ]5 U! q8 U$ } // Initialize the buffer with the required text.7 C- s* B+ B4 `0 L
error_message << endl" }9 J; I2 H' k# n; p* P( M$ A
<< "Error:" << endl
! o# I- |0 ]. S+ B& R/ i* l << message7 r' A3 j+ j: A# x. h1 S$ _
<< endl << endl << ends;
* `0 Z8 N5 q) k# H9 e9 V A7 ^( _3 ~4 r1 F
// Write the message to standard error
# N. e3 e E. v0 m5 ] cerr << error_message.str();2 y# U" t( Y E# }' T. {
}
! _& P5 u3 n, \* z# s) ]% p4 l; |} |