UG二次开发---UF_MODL_create_fitted_spline();函数的应用

ruihuzhou@163.com 2015-03-09 08:47:41
UG二次开发,VC6.0 UG6.0 通过点生成样条曲线 采用函数UF_MODL_create_fitted_spline(SPLINE_FIT_p_t spline_data,double *max_err,int *max_err_pt ,tag_p_t obj_id)。
但是SPLINE_FIT_p_t 这种数据结构不会用,请指导。
附录 源程序
// 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

//
// Note!
//
// If this DLL is dynamically linked against the MFC
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
//
// 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;
//spdata坐标的注释
// 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[i]=pt[i]; //这个不会用? 求指导
}

//通过点的样条曲线
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 );
}
}
...全文
724 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
mxway 2015-03-09
  • 打赏
  • 举报
回复
找nx的二次开发文档,看里面有没有例子。如果没有还可以用nx的录制功能,录制出nxopen的代码来做。不一定非要用这个函数。
ruihuzhou@163.com 2015-03-09
  • 打赏
  • 举报
回复
看过帮助文档,只有函数说明,没有给出实例。谢谢

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧