源玛:' V! i' k! e3 f# E* b/ R
+ v5 I( ?5 u& V" p- F" Y, @; P
//////////////////////////////////////////////////////////////////////////////
. _4 ^- M @3 w( o1 G% h; T//1 [$ }5 x; W I/ O3 J, d, `$ G
// create_oper.cpp
% [' h f6 L1 w+ j4 l# W! O) k//7 H1 X& y! e! @9 J
// Description:$ N/ t' ]& _! q4 I- k
// Contains Unigraphics entry points for the application.
: _2 c. [4 @9 ?9 }//4 O* b- e; ?( M1 c* `
//////////////////////////////////////////////////////////////////////////////. l7 r. ?! _0 B
0 y: @# H K; v, {2 P8 m# @; N) R
// Include files M0 x8 O; n" x {
#include <uf.h>0 r7 `4 U5 L' T: R! M
#include <uf_exit.h>( r: Y/ l, K" d" L
#include <uf_ui.h>( z* O7 q& [0 j, b7 p" f* {
#include <uf_oper.h>( s7 W4 Z% ^. v9 @9 D! h/ s$ @
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
0 f9 E1 y2 d! d5 n0 g; w, v1 Y# include <strstream>
3 z6 d0 X8 Q( O; H# include <iostream>: m+ u0 r& Z1 D
using std: strstream;
0 g- Y0 V1 V' M' ]/ y6 J, ?7 t5 S/ C using std::endl; 8 p6 { Y0 O, ^0 d
using std::ends;$ t3 B3 V) B2 u! c/ V1 u1 f e
using std::cerr;
2 M! s0 G% m: z: l9 h#else- q4 Q; Y/ b8 F: `" k
# include <strstream.h>
+ D% Z0 m N/ V7 |- i$ z+ ^% ~# include <iostream.h>, P/ P8 {: M# A2 X) k( k. \' q& T
#endif
% [: n; O) b: H/ }8 x6 r0 m$ a#include "create_oper.h"
6 }: z4 L7 S4 p0 g* P! {
! H! x7 F" F& z; i; L//----------------------------------------------------------------------------
# {( _1 ?- @- f/ t( G9 x// Activation Methods3 a; ?; D+ _7 Q
//----------------------------------------------------------------------------
# P9 {& s3 ]( m, f4 j
4 W! S! q1 T0 c( T" Z( c// Unigraphics Startup
# E3 A! Q4 m/ }6 F u( O) ?! i( |// This entry point activates the application at Unigraphics startup1 r, |, M! q$ G% w/ K: s5 |0 [' `
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen ). D+ U; p7 ^# ~. X# W- x# y2 z) W
{( ^# K: E$ \: m7 o: U- E* s; _
/* Initialize the API environment */
1 Z2 v9 V# W+ v5 k! E6 x# D( A int errorCode = UF_initialize();) n5 u* ^4 [, X2 b+ J/ y
# Q& P3 m1 W- T
if ( 0 == errorCode )$ e1 B% A& N' T7 D" Q( j4 o# g! e
{
& ]" l4 V$ T) V+ B* S; F0 {/ H /* TODO: Add your application code here */; ]8 v6 o# G. L7 N* B, m
2 D2 F" q0 m$ \2 G3 ~. e9 P; M
char *type_name="mill_planar";% n1 I/ l& J* j% z7 S% g
char *subtype_name="FACE_MILLING_AREA";
. v9 F ^+ k8 d tag_t oper_tag;) b, ^/ ^/ i5 x- \8 j; s9 l
0 [! L7 e% Z( F1 P
UF_OPER_create(type_name,subtype_name,&oper_tag);
- P. h3 y( T8 F/ O$ t) u% ~1 `4 x' p% f7 a/ M) T4 @
1 S* D1 e, X" c/ `
& A, |! @6 P$ R( R
% n1 D8 G, G* @. v" j* Y /* Terminate the API environment */
* F8 h; g9 N6 ?3 D' q/ {; [ errorCode = UF_terminate();5 p4 l) o1 {5 q
}6 B* a, f' M3 f! S! s$ s! t
! D& J% d6 V" T# X/ c2 m9 e /* Print out any error messages */1 j2 c. Q; F% {" J/ @
PrintErrorMessage( errorCode );0 a7 C# D* g g: Z% @
}9 \. q+ C6 L0 r; M
( r7 g4 }2 l. W' q+ x//----------------------------------------------------------------------------
j0 }8 j% [) ]9 \// Utilities
- W$ T Q6 ?, V9 o//----------------------------------------------------------------------------3 z" R3 ?, f8 {' r) Y
, x5 [! m6 X% R# p+ y8 i
// Unload Handler$ r n$ `/ \; y, _2 s' P" x+ B
// This function specifies when to unload your application from Unigraphics.
% J& I4 y. Z$ q: L// If your application registers a callback (from a MenuScript item or a
; @- Y# i% R% J: Q( i% W$ G: p( q& Y// User Defined Object for example), this function MUST return
- ^ E3 R4 g: B# J: W, G// "UF_UNLOAD_UG_TERMINATE".0 t! p. j8 W' y7 N! a9 |3 a
extern "C" int ufusr_ask_unload( void )
% b/ }+ r" p# P- a/ q. Z- J{, n& J% m+ [) _! P* a
return( UF_UNLOAD_UG_TERMINATE );. R8 ^" W9 T z
}; t G) z# @# W! U! t" S
# C, J/ a: n" P( W8 k
/* PrintErrorMessage1 r6 J4 o( j2 X0 b! k
**1 D! d1 A& M+ c3 Y
** Prints error messages to standard error and the Unigraphics status8 l& e# t7 n1 H
** line. */: N0 I$ A; }5 v5 t7 m; o1 K
static void PrintErrorMessage( int errorCode )8 ^5 t9 n0 h5 N
{
6 S* g$ j" i/ N/ ~ if ( 0 != errorCode )
9 Q* T A7 y8 V. r1 h* v {
' L* Z* h# S E6 o7 z/ d9 E /* Retrieve the associated error message */
" s( ^5 X6 ?4 L: |7 q6 }+ G. u, \ char message[133];& t* s* Q4 J% @3 M: h8 P
UF_get_fail_message( errorCode, message );0 i @5 f6 V5 i |" L1 g' Z0 T
5 ?. _7 X. b* V, z2 E4 x4 ] /* Print out the message */
, D4 S$ D+ P2 \! e) h UF_UI_set_status( message );* m) a; d+ ~* e* ^$ T7 t
. `: z1 l0 F' i/ j. ?* D( a# q5 i // Construct a buffer to hold the text.
6 e* w8 H$ S# U+ Y, d% Z3 _ ostrstream error_message;2 X8 c8 Q( u2 o3 w6 W" T' @7 U# w
- z7 O6 h# m" ?8 T
// Initialize the buffer with the required text.9 w1 f. U2 l+ z) y
error_message << endl
4 n. b0 w$ A2 q* W << "Error:" << endl
+ R( i8 _! F# Q5 r4 Y* x << message
K" P q# K# [. ~( o6 q. R* [ << endl << endl << ends;
( D$ ~+ z8 O. y# J. ^8 P. o8 _
- C3 s W, G# Z& P! T // Write the message to standard error3 z, T# {; q7 {/ x
cerr << error_message.str();
1 `. I2 l6 p0 d9 Q( \ }- c- o4 `: E( G8 H
} |