源玛:
# o) V- P. K' b& I X1 Z4 y5 p5 A- H
//////////////////////////////////////////////////////////////////////////////
/ \4 B9 `% S# R% i//
+ b; P7 b a: l1 c// create_oper.cpp0 h" f2 q9 g2 p5 a
//
) {5 C) O/ L, c; y% k3 O) P- c. j. k// Description:' L' ?2 P9 ]% A/ n
// Contains Unigraphics entry points for the application.
: C% R; ^0 ]9 d- `, u//' F+ L) z* ]8 o) _2 _& |
//////////////////////////////////////////////////////////////////////////////
, B# B4 A5 Q( z+ W. b: J `7 w" w% q
// Include files2 H, D, l" i- X' Q4 V+ H: ?
#include <uf.h>$ e7 Z" M; W* K
#include <uf_exit.h>
9 s3 |9 e+ V9 S7 g# `! k#include <uf_ui.h>
5 i* n5 e$ c; Q% O5 i#include <uf_oper.h>7 V( | W( _- j7 H: B/ e
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
( N, t3 C! }8 r1 \% u& j p5 x# include <strstream>. `# s% Z. U4 G
# include <iostream>, p- s+ N# K& i; C; ?& m
using std: strstream;: O& s p3 k7 J, c5 [
using std::endl;
) u& S2 {% ? y. O; C3 V using std::ends; o7 `. e" d: w: T$ @0 s( P
using std::cerr;
1 p- U7 D- h6 q* |* r4 g( L#else
1 ]5 {' U5 W+ `0 d$ a# include <strstream.h>
2 ]. f4 U! X% r3 Z O- ? P( {# include <iostream.h>* ?* p0 X! A7 s/ J/ X
#endif
4 E a0 n$ f2 ^: J7 _8 ?#include "create_oper.h"
8 C9 X+ x8 o7 B# O6 W9 O. p1 B0 n$ z/ i" |% U6 u
//----------------------------------------------------------------------------! z6 I+ p2 m& s8 n3 K8 j
// Activation Methods
& S* d* K4 B# J! `' ?( u) H# M//----------------------------------------------------------------------------
% E. q- c' @" O; l$ l5 w* X9 ~' t G4 F/ f
// Unigraphics Startup; J3 s3 ^5 O0 y, Q s5 Z
// This entry point activates the application at Unigraphics startup
- M! T8 _! q7 O! \extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )3 P( {( B& E* ^/ T) b
{
: K6 {: o2 W( `4 i4 ^, ]+ R /* Initialize the API environment */
* C" o3 R' a& y int errorCode = UF_initialize();
' W' t) O+ Y' A# N9 X; h( W" B t1 ?( C9 F! g
if ( 0 == errorCode )' L; P8 o9 u4 X; B0 D- C- z
{
4 v1 T# A/ i: f* x& d4 W" W /* TODO: Add your application code here */+ A4 x) n# z: w& K
! s4 {/ @8 p4 U" G char *type_name="mill_planar";
8 |( ^# G9 E* ]1 ?7 t2 V& a6 V char *subtype_name="FACE_MILLING_AREA";4 ^- Y: z1 Z% d& w# F+ N, p
tag_t oper_tag;
3 q; o- F) [3 H7 @% @8 B2 m, `
6 Q0 l; ]( O* J6 B% K) B$ M, [. y# D UF_OPER_create(type_name,subtype_name,&oper_tag);
/ J; k0 f- y4 ]+ g* W. U9 S, a( d% l, w$ e4 P/ g2 M$ ^' [
- a+ z2 q% u5 v( H- `
6 y: k" b& V6 l I( _9 |( \+ x' ^7 r7 l; @
/* Terminate the API environment */
9 i! _. m4 P! @ M errorCode = UF_terminate();
" E# v, n. @, S& W }
( ?6 X8 B0 @: k" B+ `" Q, D, O5 u9 |/ `! |
/* Print out any error messages */
; U3 L# d ^: P& ]: y PrintErrorMessage( errorCode );6 I* e& k: K( j' e! }( `" \
}+ H/ L0 d1 N$ C9 d" d
3 N6 U6 S# Y) [4 a @& p/ x//----------------------------------------------------------------------------
# p/ F& c. \& j! u. o0 ]// Utilities
. Z8 ], ]9 h {3 E# Q% ?. v//----------------------------------------------------------------------------
( X8 D- w/ M4 ^, d& d5 \
3 L- }, { |# Z) v E8 ]" E// Unload Handler
( B$ b) ^- g' d; S* l4 q// This function specifies when to unload your application from Unigraphics.
9 ], s; _9 Q7 M( |1 ~// If your application registers a callback (from a MenuScript item or a
& q. [" r$ C7 e, X// User Defined Object for example), this function MUST return3 Q9 {6 s/ l# r O; V
// "UF_UNLOAD_UG_TERMINATE".
2 @8 z1 c6 x4 J$ C- {1 L b$ Xextern "C" int ufusr_ask_unload( void )
4 ~: l; {8 b: s+ J4 ]- e. j{+ ~6 j, [# K( h% F1 T: H* t
return( UF_UNLOAD_UG_TERMINATE );8 s7 i7 y( L" u/ m: p% H
}. G" O b7 l( B$ U
+ {/ M. i/ l# V; c3 k! d. C& r2 U
/* PrintErrorMessage4 a8 X# `" ~( H7 Q, y3 b [
**
. N2 A! U& O( i d9 k- s** Prints error messages to standard error and the Unigraphics status$ h6 u% n7 t1 A2 x* r
** line. */ f7 A* c/ O4 z4 F+ h; K k6 @' t
static void PrintErrorMessage( int errorCode )# G: C8 v& |/ V4 M, y2 O' w
{# @+ v+ d: p- f/ t% g: C! G( }
if ( 0 != errorCode )
; A1 B1 g% W5 ~ {
/ o+ ^) [- |) G3 p* w- L* c8 I /* Retrieve the associated error message */: h; ~3 m% U" }5 s' j
char message[133];: X8 ^, [2 C0 v! V0 }
UF_get_fail_message( errorCode, message );
3 H2 j, c% u, J1 M& }
% y. R- {1 c8 w /* Print out the message */# H+ v* O/ D W
UF_UI_set_status( message );
5 X4 u$ N6 s+ p- h9 k9 ?
& h5 n" m7 l/ a) e // Construct a buffer to hold the text., d \1 p e! [4 Q) r2 ?4 _- C: H
ostrstream error_message;
+ y+ K8 Y- J6 m6 I
8 G0 I* L& C! y // Initialize the buffer with the required text., i. ^" i ^& c) P! G
error_message << endl
8 w+ H3 \/ y8 ~- } << "Error:" << endl
5 z* c& g9 G! \$ `4 N << message& d' y M- h1 r9 o5 z2 s" N
<< endl << endl << ends;9 i! g* r) A% g# [; K6 C m
3 v* i( [0 {6 M5 c& |. B" h+ b
// Write the message to standard error
: T2 ?+ W& B3 E0 ^ cerr << error_message.str();+ ?2 z# O/ w+ U/ p
}
7 q9 }: @9 e& J: n} |