源玛:
. e* V& g$ ?1 f2 M# P6 @# o. v/ P. w
//////////////////////////////////////////////////////////////////////////////& V# U% ^2 B) \
//7 n" F0 E8 r8 W
// create_oper.cpp
6 J' {4 D. z, N/ q4 H3 Z7 Y& W//
: ?. y3 p( I' R0 j. r. ~// Description:
0 M5 ^9 M2 @8 \7 p% X// Contains Unigraphics entry points for the application.
* p0 u. h6 ^% `9 O0 r# [/ Q//! C7 e4 V! _- G" U2 z# r
//////////////////////////////////////////////////////////////////////////////, z' Y& |& Z- v5 {& S
" Q2 o( u" ]5 L5 w; I& ?" f) O1 |
// Include files
& T9 E: w b$ A#include <uf.h>
7 c+ h8 A' S) E# g$ c3 ]! j( ?#include <uf_exit.h>* q" U" ~% m7 c+ f
#include <uf_ui.h>/ O) }2 X9 |- ] H/ a, l/ b
#include <uf_oper.h>
) r6 {9 s8 F- P/ A! k9 P. W1 m#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )6 v; U G: z. j- x/ `0 {
# include <strstream>
3 L: \; C! b6 ^- z0 O0 i# include <iostream>
% ^8 F4 |$ r4 D- {! R" ~ using std: strstream;" p8 i; g, p* j+ j1 j- n" {
using std::endl; 1 ^* X( w+ b; x! V+ t
using std::ends;0 M$ t) j$ a/ e
using std::cerr;# k( Z% E# N3 u$ U" U5 s' d h
#else
7 a: ?7 @# p- [; Y# include <strstream.h>
; r: N- ^; \% X1 K# include <iostream.h>
; s4 t! f2 h. N/ W#endif5 ? N8 S: q4 j2 b9 z$ R% F
#include "create_oper.h"
& K7 Y7 M' ~- d5 g! I% D% g& U( p; a, ?; R. ` I! h
//----------------------------------------------------------------------------9 g% ^0 x% f9 g; @9 }% A/ `. u
// Activation Methods' B- |4 U# s4 @ h( h$ M7 |( j
//----------------------------------------------------------------------------' n, q: B7 V. ?
" l' t5 |# u; \: E( e: F// Unigraphics Startup c8 K' o g* p" v6 \, N% _
// This entry point activates the application at Unigraphics startup: _4 _* C/ Y0 o) i6 S
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
2 k3 E5 ?+ \: Q- z. J& z' r# e{ v4 {8 q" Y/ ~$ w2 W5 T
/* Initialize the API environment */
6 l& |+ u* @6 X1 N int errorCode = UF_initialize();; w4 `% n% t/ S7 z. o o9 r
( p' V1 p! r3 t( W+ k$ m if ( 0 == errorCode ) f! [( O$ a( ^! s8 ^- U. O# }/ h. j
{
0 @9 T3 p0 Y8 @% j. S; b /* TODO: Add your application code here */4 |" Y* C7 _0 T( {$ A" g- f7 `. a
8 U4 O8 z; s& ~# v R char *type_name="mill_planar";
, W2 b: N" ]: j. P# W" |* V2 S char *subtype_name="FACE_MILLING_AREA";
" Z. B3 F. s ~ tag_t oper_tag;
% `: d4 I5 p( q* b4 E- ~5 ^$ f5 ^
UF_OPER_create(type_name,subtype_name,&oper_tag);
! ]5 r }. u; o- P& c i8 w
) ], k) F+ ]! ~( v# I! G/ s8 f) ?# {7 w* O$ @
$ [8 y: [% S5 T+ P- D
) p) P& O7 L# @/ s /* Terminate the API environment */
s' O6 Y+ w7 U. u( b9 D errorCode = UF_terminate();
6 h7 {& g, I% m" Q* ]* v% z }
# Y/ K7 O' p' {- X7 h- g
" c5 e$ ?1 [9 `$ | /* Print out any error messages */
* y0 _$ }8 s" u. S4 X& o PrintErrorMessage( errorCode );$ [9 ~/ Q. m* |5 \& ?
}
/ x" ?1 z4 S5 B8 k; K
: Z3 U) O) p, |0 k6 J( M) i//----------------------------------------------------------------------------
8 N/ P, O# P* j7 y/ ^3 Z; P// Utilities' x4 x# E: `) R
//----------------------------------------------------------------------------" C+ B0 Q: ^7 z7 U/ I+ E
* |% B0 C6 ~: b, h) L6 C4 i4 `0 X// Unload Handler2 ^3 ?& s3 \* a* `
// This function specifies when to unload your application from Unigraphics.
) C) Y2 v3 a: u4 ]7 h l( ~// If your application registers a callback (from a MenuScript item or a
4 g0 G0 b- d% n& c* l1 s7 n: B// User Defined Object for example), this function MUST return5 f+ c0 H6 N' X3 F! A; o* X
// "UF_UNLOAD_UG_TERMINATE".
( E2 L8 R7 W3 [& {extern "C" int ufusr_ask_unload( void )
* n# j% Q# P t5 r l{
, w) S( {) m" M7 ? return( UF_UNLOAD_UG_TERMINATE );
1 o \! f& e$ r: l* `: d: a; m}
* E2 K3 n1 |. G/ E, e# G; M1 J3 k. e
/* PrintErrorMessage7 p6 K P9 E6 R* f# Z" M; }3 ]
**4 B. I" v! A4 C# i V3 R; g# h7 V- K
** Prints error messages to standard error and the Unigraphics status$ ~8 L( t; Q: N
** line. */8 K1 | `7 a' O! l$ y8 L* C
static void PrintErrorMessage( int errorCode )
6 u& P; L! {) @5 E{
' u( z9 I6 e" Z) m) @! M* _/ T if ( 0 != errorCode )( w y2 F6 p4 N B/ X& {% |7 Q
{
% [: Y, d0 ]* k3 u /* Retrieve the associated error message */4 y9 p- i9 Q/ r' N7 S
char message[133];& J) J+ {' X: L( y! }7 t* z
UF_get_fail_message( errorCode, message );
& j, B6 D2 `% L4 F S- W# c( i* t3 E" d* |% y7 U" t) m4 e
/* Print out the message */
0 ?6 g. d, y e' g. \6 k7 a UF_UI_set_status( message );
7 w! h- y+ [/ S1 g" ~9 x( D5 B& _8 D) b
// Construct a buffer to hold the text.
( E& Z& M- @3 f5 `1 R: P- i2 U ostrstream error_message;
; O8 H4 ^7 V) V
% S8 ~9 G$ w6 {0 w // Initialize the buffer with the required text.6 |& }: g3 l; }# e$ Q. o( y$ h8 E
error_message << endl, ~2 Y' q3 |( t: I' _2 W+ Z
<< "Error:" << endl
/ q- Z( c, f1 `9 h- N: z << message
8 u7 J0 X1 B+ l" u9 A% T << endl << endl << ends;
7 U; f: I+ ?# v3 F' O* f6 N! K" N- V" P- T. e) A. k- C
// Write the message to standard error
* i t& S9 d2 ^3 \- x7 B$ m- H cerr << error_message.str();; P, @1 f8 J. y& j# ?' X
}
0 k5 y9 n% S' F/ L% v} |