|
采用UG二次开发,UG6.0 VC6.0 采用MFC进入应用程序向导。通过点生成样条曲线,
使用UF_MODL_create_fitted_spline(SPLINE_FIT_p_tspline_data,double *max_err,int *max_err_pt ,tag_p_t obj_id)函数
主要是 spline_data这项参数不会用,UG里面不能生成曲线。
希望大侠给出一个具体实例,这方面的参考资料太少了。
附录源程序:
- // ugopen.cpp : Defines the initialization routines for the DLL.
- //
- #include "stdafx.h"
- #include "ugopen.h"
- #include <stdio.h>
- #include <uf.h>
- #include <uf_ui.h>
- #include <uf_curve.h>
- #include<uf_modl.h> //建模
- #define NUMBER_POINTS 5
- #define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- //
- // For example:
- //
- // extern "C" BOOL PASCAL EXPORT ExportedFunction()
- // {
- // AFX_MANAGE_STATE(AfxGetStaticModuleState());
- // // normal function body here
- // }
- //
- // It is very important that this macro appear in each
- // function, prior to any calls into MFC. This means that
- // it must appear as the first statement within the
- // function, even before any object variable declarations
- // as their constructors may generate calls into the MFC
- // DLL.
- //
- // Please see MFC Technical Notes 33 and 58 for additional
- // details.
- //
- /////////////////////////////////////////////////////////////////////////////
- // CUgopenApp
- BEGIN_MESSAGE_MAP(CUgopenApp, CWinApp)
- //{{AFX_MSG_MAP(CUgopenApp)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CUgopenApp construction
- CUgopenApp::CUgopenApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CUgopenApp object
- CUgopenApp theApp;
- // ufusr()是直接激活的用户出口
- // param retcode 是输出参数,rlen是指参数param的长度,由NX系统自动处理
- //给出了一个函数的范例 可以写成子函数的形式 也方便调试 自己先定义一个子函数
- static void do_ugopen_api(void)
- {
- SPLINE_FIT_p_t spdata; //截面点数据
-
- double sp1;
-
- double pt[15]={1.1000, 0.5320, 2.0000,
- 1.5240, 0.6789, 2.3000,
- 2.0000, 0.9000, 3.5956,
- 2.3456, 1.3456, 3.7890,
- 3.1000, 2.4567, 3.3214};
- int err_pt;
- int i;
- tag_p_t curved_id;
- spdata->degree=3;
- spdata->num_of_points=5;
- spdata->num_of_segments=1;
- // points
- // double *
- //
- // coordinates for the points to be fitted.
- // points[0~2] = (x, y, z) for the 1st point,
- // points[3~5] = (x, y, z) for the 2nd point,
- // ...
-
-
- for(i=0;i<15;i++)
- {
- spdata->points=pt;
- }
-
- //通过点的样条曲线
- UF_MODL_create_fitted_spline(spdata,&sp1,&err_pt,curved_id);
- }
- extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
- {
- /* Initialize the API environment */
- int errorCode = UF_initialize(); //初始化 获得权限
-
- if ( 0 == errorCode )
- {
- /* TODO: Add your application code here 添加如下代码*/
- AFX_MANAGE_STATE(AfxGetStaticModuleState()); //切换模块状态
- do_ugopen_api(); //调用该程序
- /* Terminate the API environment */
- errorCode = UF_terminate(); //释放NX执行许可权限
- }
- /* Print out any error messages */
- PrintErrorMessage( errorCode );
- }
- /*****************************************************************************
- ** Utilities
- *****************************************************************************/
- /* Unload Handler
- ** This function specifies when to unload your application from Unigraphics.
- ** If your application registers a callback (from a MenuScript item or a
- ** User Defined Object for example), this function MUST return
- ** "UF_UNLOAD_UG_TERMINATE". */
- extern int ufusr_ask_unload( void ) //卸载函数
- {
- return( UF_UNLOAD_IMMEDIATELY );
- }
- /* PrintErrorMessage
- **
- ** Prints error messages to standard error and the Unigraphics status
- ** line. */
- static void PrintErrorMessage( int errorCode ) //错误输出
- {
- if ( 0 != errorCode )
- {
- /* Retrieve the associated error message */
- char message[133];
- UF_get_fail_message( errorCode, message );
- /* Print out the message */
- UF_UI_set_status( message );
- fprintf( stderr, "%s\n", message );
- }
- }
复制代码
|
|