源玛: [9 j4 b6 U2 }* J5 G+ t
# J, i2 i& x! e8 w' \$ ]5 o' R2 p//////////////////////////////////////////////////////////////////////////////* o$ S& X% _3 g
//7 o" e: Z# b5 k% M
// create_oper.cpp# v/ Q1 |- C! e2 U ^. |
//
+ _# l5 e [% `: Q' N3 H+ M// Description:
- w; J9 k; V; c7 Q// Contains Unigraphics entry points for the application.
2 X- ?3 }& ?& b. Q& S- K//
, o2 D1 T. z) v7 {0 x//////////////////////////////////////////////////////////////////////////////
1 u e. ?; M9 ]8 A
3 W8 m: Q$ [+ d& y- f// Include files
% |1 a M! C0 r#include <uf.h>7 I! z1 A# o. T1 n! R
#include <uf_exit.h>2 y" S% J& Z; X
#include <uf_ui.h>
; k9 I4 S# m V6 W& B% }) \#include <uf_oper.h>
+ o0 @! y- i& _#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
! i/ {# Z. ^4 X2 _( B# include <strstream>
0 l2 ~0 D" T. `# P& z1 U# include <iostream>- l$ @" j1 K( x
using std: strstream;
5 m- c4 w( ? G w using std::endl;
/ `7 s( D' C; J) f5 {6 M using std::ends;! Q9 I# n8 u- P. m
using std::cerr;
9 x! e: b0 w# f k! ? z- M#else
" N% G3 s4 \$ R7 K9 ]# include <strstream.h>
* f: l8 O6 C# D8 X$ w c0 |# include <iostream.h>8 ^$ a! w! Y6 U7 _) h0 m
#endif
! @ u$ J, t f* G! R* _9 t$ P#include "create_oper.h"
2 i, a' {) }4 g2 L7 H7 u" U" a$ d' a3 \" z9 \) _
//----------------------------------------------------------------------------, x" g' Q, c: N: ?$ d: ~8 {
// Activation Methods5 s; D) T" E' r5 }/ W1 f8 ?
//----------------------------------------------------------------------------
$ ~9 H1 w6 I$ ?3 M% H) B1 O2 j& z; [3 t$ q. I8 X' D
// Unigraphics Startup
) E: U9 U1 ]) e- W1 u5 Q// This entry point activates the application at Unigraphics startup
2 ]+ h3 n; |1 d. @extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
+ w; v5 M% a" j1 h8 R7 q& X9 u8 U5 Y{
) u9 S) f) ?# L) K /* Initialize the API environment */
' F1 e* L1 R, F) o" d9 i int errorCode = UF_initialize();1 r% Y1 p% z7 {7 ?' s
1 V" z: i' r; W- a
if ( 0 == errorCode )
4 y' R5 L/ q9 B {/ X" ?6 w8 L7 M6 O1 r4 A2 h( f
/* TODO: Add your application code here */
" ]/ O Z3 Z: x( \: v! `) j! o @7 R" p2 N
char *type_name="mill_planar";
* `3 \, @& Q- n T' O char *subtype_name="FACE_MILLING_AREA";4 }+ o3 M" N8 z, ?, f' J, E
tag_t oper_tag;) o1 A( s5 L6 r
3 T" j3 K& |5 K+ J: V4 ]3 S UF_OPER_create(type_name,subtype_name,&oper_tag);
# a. C: T' E# l! Q. z$ B3 Z
6 t& c. O0 e9 f. `7 |: a6 }" j6 G9 [; y: J. L$ a4 {- Q
0 l% ]- `; D$ u4 v' k3 X h/ L7 G
; j: @) g1 Y* F% t /* Terminate the API environment */
\, U3 L; A( K, p( j V1 r* p errorCode = UF_terminate();8 J4 a: Q6 ^4 K! m* j) P: t; \
}
8 b4 P% |1 V& w0 `0 e- p3 \' K$ r. Z r8 e b. Z! b# V, m
/* Print out any error messages */1 ~; V$ v3 Y) N. C) t, R# r- M3 w3 _
PrintErrorMessage( errorCode );
9 D1 b/ _! c) u: `}( g4 I. e" B) i$ _; c7 h* `
% o; J ^4 [# O//----------------------------------------------------------------------------& v# Q( F4 V2 k. b3 s
// Utilities
) U) U% T* U g" [//----------------------------------------------------------------------------
$ v1 N9 X: Z, [8 p& [# ~$ K5 x7 E7 {0 K) d: g
// Unload Handler
1 S8 l" n- Y4 K4 f% q0 M// This function specifies when to unload your application from Unigraphics.2 A2 Q ~. A& c! ]& G6 r
// If your application registers a callback (from a MenuScript item or a
% [* B: u: M6 H, E, V// User Defined Object for example), this function MUST return7 Y2 N" h; Q6 C4 H
// "UF_UNLOAD_UG_TERMINATE".' b$ q( S9 U9 s; F
extern "C" int ufusr_ask_unload( void )3 ^0 Z: f0 ~- h9 j2 }, |
{
8 Z* X9 B$ b4 J+ s X/ ?. z1 c9 a& u return( UF_UNLOAD_UG_TERMINATE );
; X$ M' l* u W3 u! n; N/ Y}/ r4 J: t" {9 z/ ?8 N
- h% Z/ c# ^/ h3 z. ?/* PrintErrorMessage( z" o2 ?. g: E7 K
**1 I% s, J) L# m0 g& J+ o9 A
** Prints error messages to standard error and the Unigraphics status
: t$ e J8 W5 {+ [$ }* _4 e** line. */5 ?* M2 p4 _* f
static void PrintErrorMessage( int errorCode )
. s( l# T- y+ ^8 t) q{% T% d1 g T7 ^, d" p6 Y8 {
if ( 0 != errorCode )$ c- X+ O0 m" W
{! r8 y- N' s4 u
/* Retrieve the associated error message */2 q, @: k) z8 \$ ~8 F) m8 F
char message[133];& Z! \% s; M# C4 B: \
UF_get_fail_message( errorCode, message );5 S4 S7 B: g0 d7 U4 y
9 Q( c: r, Y; S4 J. L0 b
/* Print out the message */5 U$ V4 h. S" \8 s" O, u! u
UF_UI_set_status( message );( S! t) o( e2 ?
7 j# h. w4 t+ d; c
// Construct a buffer to hold the text.
" @8 ~+ w) \8 p, d ostrstream error_message;
) }; S- ^; G- j
1 ?* P% b D: w. Q" O* I // Initialize the buffer with the required text.# S8 z/ _1 N6 Y2 \! D v1 U
error_message << endl# S. [+ x) K+ A# ]. A
<< "Error:" << endl6 T8 W4 q* ?* M% ], b
<< message4 l( Z: ]8 h% y A
<< endl << endl << ends;
1 D* d* N- Q( z( k2 |! P+ N9 e3 b" z
// Write the message to standard error% J& l% a Z; j1 l* f- G) b z
cerr << error_message.str();
3 Q2 p J& [# }8 O! ^; t }7 Y0 d9 m7 Y* R* f4 E' n
} |