Author of the article: Caspian
Source website: https://blog.csdn.net/WangPaiFeiXingYuan
UF_VEC3_is_parallel
Defined in: uf_vec.h
void UF_VEC3_is_parallel(const double vec1 [ 3 ] , const double vec2 [ 3 ] , double tolerance, int * is_parallel )
overview overview
Determine if vectors are parallel within an input tolerance. If the sine of
the angle between the vec1 and vec2 is less than tolerance then
TRUE is returned. Otherwise a FALSE will be returned. To get an angle
tolerance of x degrees the expected tolerance would be sin(xDEGRA).
Determines whether the vectors are parallel within the input tolerance. Returns TRUE if the sine of the angle between vec1 and vec2 is less than the tolerance. Otherwise, FALSE will be returned. To obtain an angular tolerance of x degrees, the expected tolerance is sin (xDEGRA).
UFUN example
Welcome to subscribe to "Caspian NX Secondary Development 3000 Examples Column" https://blog.csdn.net/wangpaifeixingyuan/category_8840986.html . Click the link to scan the code to subscribe (continuously updated). Hundreds of people have subscribed. The subscription is permanent and can be read indefinitely. If you need help, please send a private message .
parameters parameters
const double | thing1 [ 3 ] | Input | 3D vector 3D vector |
const double | thing2 [ 3 ] | Input | 3D vector 3D vector |
double | tolerance | Input | tolerance tolerance |
int * | is_parallel | Output | = 0 Vectors are not parallel = 1 Vectors are parallel = 0 Vectors are not parallel = 1 Vectors are parallel |
Application and comprehensive analysis of C++ language in UG secondary development
- C++ is an extension of the C language. It can perform procedural programming of the C language, object-based design characterized by abstract data types, and object-oriented programming. C++ is highly adaptable to the scale of problems it handles.
- C++ not only has the practical characteristics of efficient computer operation, but is also committed to improving the programming quality of large-scale programs and the problem description capabilities of programming languages.
In the secondary development of UG, C++ language has the following characteristics
- The C++ language supports multiple programming styles
- Many features of C++ exist in the form of libraries, ensuring the simplicity of the language and the efficiency of development and operation.
- Compared with C language, C++ introduces the concept of object-oriented, making the human-computer interaction interface developed by UG more concise.
- By using the more than 2,000 API functions that come with UG, combined with the high-level language C++ and the programming software Visual Studio, UG can be secondary developed.
- It should be noted that there are many versions of Visual Studio and UG on the market, and not all versions are compatible.
The programming process usually includes the following steps:
- Problem analysis: Conduct an in-depth analysis of the problem to be solved and understand the specific needs and limitations of the problem.
- Requirements definition: Clarify the goals and functions of the program, including user needs, system requirements, etc.
- Design: Design according to needs, including algorithm design, data structure design, interface design, etc.
- Coding: Based on the design results, use a programming language to implement the program code.
- Testing: Ensure the correctness of the program through various testing methods, including unit testing, integration testing, system testing, etc.
- Maintenance: Modifying and improving the program to solve possible problems or meet new needs.
- Document writing: Write program documentation to describe the program's functions, operating methods, precautions, etc.
The following is an example of secondary development to create voxel features (blocks, cylinders, cones, spheres)
#include <stdio.h>
#include <stdarg.h>
#include <uf_modl_primitives.h>
#include <uf_ui_ugopen.h>
#include <uf.h>
#include <uf_defs.h>
//封装打印函数,用于将信息打印到信息窗口
//QQ3123197280
int ECHO(const char* szFormat, ...)
{
char szMsg[5000] = "";
va_list arg_ptr;
va_start(arg_ptr, szFormat);
vsprintf_s(szMsg, szFormat, arg_ptr);
va_end(arg_ptr);
UF_UI_open_listing_window();
UF_UI_write_listing_window(szMsg);
return 0;
}
extern DllExport void ufusr(char* param, int* returnCode, int rlen)
{
UF_initialize();
//创建块
UF_FEATURE_SIGN sign = UF_NULLSIGN;
//块起点相对于ABS
double block_orig[3] = {
0.0,0.0,0.0 };
//方向相对于WCS
char* block_len[3] = {
"10", "30", "10" };
tag_t blk_obj;//体特征
UF_MODL_create_block1(sign, block_orig, block_len, &blk_obj);
int iEdit = 0;
char* size[3];
UF_MODL_ask_block_parms(blk_obj, iEdit, size);
ECHO("%s,%s,%s\n", size[0], size[1], size[2]);//输出: p6=10,p7=30,p8=10
//创建圆柱
UF_FEATURE_SIGN sign1 = UF_NULLSIGN;
double origin[3] = {
10.0,0.0,10.0 };
char height[] = "20";
char diam[] = "10";
double direction[3] = {
0,0,1 };//方向
tag_t cyl_obj_id;
UF_MODL_create_cyl1(sign1, origin, height, diam, direction, &cyl_obj_id);
int iEdit2 = 0;
char* cDiameter;
char* cHeight;
UF_MODL_ask_cylinder_parms(cyl_obj_id, iEdit2, &cDiameter, &cHeight);
ECHO("%s,%s\n", cDiameter, cHeight);//输出:p9=10,p10=20
UF_free(cDiameter);
UF_free(cHeight);
//创建圆锥
UF_FEATURE_SIGN sign2 = UF_NULLSIGN;
double origin2[3] = {
0.0,0.0,10.0 };
char height2[] = "20";
char* diam2[2] = {
"10" ,"5" };
double direction2[3] = {
0,0,1 };//方向
tag_t cone_obj_id;
UF_MODL_create_cone1(sign2, origin2, height2, diam2, direction2, &cone_obj_id);
int iEdit3 = 0;
char* cD1;
char* cD2;
char* cH;
char* cAngle;
UF_MODL_ask_cone_parms(cone_obj_id, iEdit3, &cD1, &cD2, &cH, &cAngle);
ECHO("%s,%s,%s,%s\n", cD1, cD2, cH, cAngle);//输出:p11=10,p12=5,p13=20,p14=7.1250163489018
UF_free(cD1);
UF_free(cD2);
UF_free(cH);
UF_free(cAngle);
//创建球
UF_FEATURE_SIGN sign3 = UF_NULLSIGN;
double douCenter2[3] = {
0.0,0.0,30.0 };
char cDiam[] = "8";
tag_t sphere_obj_id;
UF_MODL_create_sphere1(sign3, douCenter2, cDiam, &sphere_obj_id);
int iEdit4 = 0;
char* cDiam_parm;
UF_MODL_ask_sphere_parms(sphere_obj_id, iEdit4, &cDiam_parm);
ECHO("%s\n", cDiam_parm);//输出:p15=8
UF_free(cDiam_parm);
UF_terminate();
}
extern int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
Effect: