源玛:
5 R$ ]: O/ @% q. [7 @# U4 C/ M" F$ M5 U. `
//////////////////////////////////////////////////////////////////////////////
' d7 ?' [, F/ q/ a6 x//
8 K }1 {1 g+ _3 M// create_oper.cpp$ H' k c S: j: o# t; n5 N: Y6 P
//. [& y M# K+ o
// Description:9 z# n( Q* ^9 R8 O7 j4 Z$ D; z. G
// Contains Unigraphics entry points for the application.
, v; W ], v: [) W) U3 C( {//% S# p4 _. U6 ]0 J
//////////////////////////////////////////////////////////////////////////////
4 Q' ?; `# _- v. w; z
' a; G6 }3 V* n5 ]. L! l( z// Include files
5 o) x- d& T" o#include <uf.h>
% T/ F. w. L' S, Z/ O#include <uf_exit.h>/ [) X& G+ K' o2 w
#include <uf_ui.h>
5 ^, v2 J* g. R+ }" U#include <uf_oper.h>' r( I" Z. U, d) c
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
, F( n( G* }- @6 p0 C( Z. U# include <strstream># |+ v: m; |5 ?/ m6 Z
# include <iostream>
, H8 G1 F. ` Q) U# [7 ]+ q. i0 b using std: strstream;9 o2 I# J) ]; m: k
using std::endl;
" z) P( e& [3 O using std::ends;( `: D5 n' l: P1 Y, R1 S
using std::cerr;
/ G0 r' h* O$ g% h#else
# s3 u0 b7 j) s8 d5 g z4 V# include <strstream.h>
0 C1 N4 e9 F( B8 I# include <iostream.h>9 K! X; ~! p) x+ a& j J' |
#endif% Y9 U, K0 w0 j
#include "create_oper.h"
# i5 A% a' y5 V7 Q1 _8 y1 R1 H0 a7 R4 \8 [" ]6 v5 L
//----------------------------------------------------------------------------$ W) B' x1 E8 O& e) o; Q7 V
// Activation Methods4 i4 g i1 V' \/ j& C
//----------------------------------------------------------------------------; g0 g0 M2 u3 H) A0 ?
8 V4 @- r# k6 E' }( p( j
// Unigraphics Startup
8 P/ b# M |' }// This entry point activates the application at Unigraphics startup
% j4 ]: O, L8 X: b: y& k. U( Pextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen ), f8 ]- ?3 K& K" F! d' Z. s! A
{1 e% j: N6 _3 Z8 I
/* Initialize the API environment */, X. d" ~* ^# W9 M
int errorCode = UF_initialize();
. U7 s/ W# r5 o1 L" A1 L! ~7 x, w
9 _2 K5 w2 P$ G. { if ( 0 == errorCode )% X! V H1 E9 | O) ^
{
% r/ d, S; |, _- w) c /* TODO: Add your application code here */
- J3 K& p; g% N9 M7 c6 M' M2 v8 \" ]1 ^
char *type_name="mill_planar";
6 o0 ^. [0 v6 C& e6 K char *subtype_name="FACE_MILLING_AREA";
0 d) f) j7 S. [8 S1 v3 o1 c2 j tag_t oper_tag;* F$ h- E- i5 K' q& ]3 ?
q2 X* F! h& s6 }; y( e, A
UF_OPER_create(type_name,subtype_name,&oper_tag);8 I3 D7 d' r# u# h) M
5 w' U5 K% P' [0 {( D: f# V ?+ k4 c
! v7 s( Z. N. j3 {" \% ^2 i- ?* r: C: C
5 H9 Z9 ~! T1 ^ /* Terminate the API environment */
0 e0 p& c$ o- Y) ~" v7 Y errorCode = UF_terminate();
( ^7 P% ^: V' A: } g1 ~/ d }& b- Y9 [2 \+ v$ T) Z" t/ M5 F! r
7 [1 S) Z: }+ J1 U+ \
/* Print out any error messages */5 N- n8 V' G3 x
PrintErrorMessage( errorCode );
4 x/ p! m' i. C4 n0 h, I}: |* P" s4 N- @" n9 m
\* }7 \6 K% X$ A0 N% T//----------------------------------------------------------------------------
; c8 Y. ?/ M, D, o T! H I7 v0 ^// Utilities
% p6 U; `- w% n1 }/ i//----------------------------------------------------------------------------, _0 n. n4 x; s* n3 v
M( {" ?% f k' L) W* g
// Unload Handler
8 ?5 ]" J" R' x* |* _/ J// This function specifies when to unload your application from Unigraphics.% r' X% ]1 J% _4 B! { `- J
// If your application registers a callback (from a MenuScript item or a3 ? L9 P* |! V8 Y0 Y" e( b. Z
// User Defined Object for example), this function MUST return
; |$ A7 Q. y# t i$ Q1 W2 B// "UF_UNLOAD_UG_TERMINATE".7 M% T" C# `; L$ {0 z0 f
extern "C" int ufusr_ask_unload( void )" d* Q) H! T# l* o0 V: d3 ]! t
{2 ~% Z3 V. z3 z
return( UF_UNLOAD_UG_TERMINATE );
4 b: |& R7 M4 ~, s% I}
8 m" O4 m( t$ k3 y# s% P3 q; {- O) L, o! N; v
/* PrintErrorMessage0 [$ k( R: y9 R1 u6 X- d% K% E' w
**4 }1 W) |9 m3 {+ S2 v
** Prints error messages to standard error and the Unigraphics status
) t9 ?+ I" [; n2 z) g/ [/ p** line. */
0 r* ?0 h8 N' z: Dstatic void PrintErrorMessage( int errorCode )
5 q5 V' f5 F4 f7 }{
( L( V; d" O! B9 d5 X if ( 0 != errorCode )5 L! j! X9 [" ]& a6 T1 K& x
{) q7 ]* n }3 r( g: C4 a: d
/* Retrieve the associated error message */# `* h& D9 [, h3 H
char message[133];4 L* V' s/ A8 X# u, ?3 X
UF_get_fail_message( errorCode, message );
- ^8 J& Q$ t% {. i7 v$ y$ d( r7 ~" K9 I
/* Print out the message */1 a( E# r- u# T+ W; D3 A! i
UF_UI_set_status( message );
) V1 j: B. P! I
7 ~& {0 E8 v9 \( j1 F9 C' V/ Y" @8 ? // Construct a buffer to hold the text.1 v0 U4 d4 I& N5 g: p) t6 ]- c
ostrstream error_message;8 J: U2 i' o- H$ ]0 A& j8 c4 B, S
: ?" q2 p% E* M( ^ O // Initialize the buffer with the required text.. @, }* q8 P1 d+ {
error_message << endl
( }" H( x* ^8 h/ S; Q2 e" ? << "Error:" << endl
3 D6 @* T7 p: k; D << message
" q8 m7 N8 L& x7 x0 S; H << endl << endl << ends;
- I2 I }+ K- r" U! ~5 r
" z$ j: k: L3 p // Write the message to standard error% Z& I# o# C2 |, g
cerr << error_message.str();/ @) q, m; ]0 o
}
2 [; {% l3 H4 C' ^# C7 U' P} |