这个ufun方法用来创建面,创建效果图如下:
1、函数结构
int UF_MODL_create_plane
(double origin_point [3],
double plane_normal [3],
tag_t * plane_tag)
2、实例源码
#include <stdio.h>
#include <uf.h>
#include <uf_part.h>
#include <uf_defs.h>
#include <uf_modl.h>
#include <uf_vec.h>
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static int report( char *file, int line, char *call, int irc)
{
if (irc)
{
char messg[133];
printf("%s, line %d: %s\n", file, line, call);
(UF_get_fail_message(irc, messg)) ?
printf(" returned a %d\n", irc) :
printf(" returned error %d: %s\n", irc, messg);
}
return(irc);
}
static void do_ugopen_api(void)
{
char *edge_length[3] = {"5.0", "5.0", "5.0"};
char *prtnam = "planes";
double dot_value;
double magnitude;
double origin[3] = {0.0, 0.0, 0.0};
double origin_point[3];
double pl1_normal[3];
double pl2_normal[3];
double unit_pl2_normal[3];
tag_t block_feat_tag;
tag_t part_tag;
tag_t plane1_tag;
tag_t plane2_tag;
UF_FEATURE_SIGN create = UF_NULLSIGN;
/* Open a new part */
UF_CALL( UF_PART_new(prtnam, METRIC, &part_tag) );
/* Create a block of dimensions 5, 5, 5 */
UF_CALL(UF_MODL_create_block1(create, origin, edge_length, &block_feat_tag));
/* Create the first plane on a face of the block */
origin_point[0] = 0.0;
origin_point[1] = 0.0;
origin_point[2] = 5.0;
pl1_normal[0] = 0.0;
pl1_normal[1] = 0.0;
pl1_normal[2] = 1.0;
UF_CALL(UF_MODL_create_plane(origin_point, pl1_normal, &plane1_tag));
/* Create the second plane on the diagonally opposite face of the block */
origin_point[0] = 5.0;
origin_point[1] = 5.0;
origin_point[2] = 0.0;
pl2_normal[0] = 0.0;
pl2_normal[1] = 0.0;
pl2_normal[2] = 1.0;
UF_CALL(UF_MODL_create_plane(origin_point, pl2_normal, &plane2_tag));
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int param_len)
{
if (!UF_CALL(UF_initialize()))
{
do_ugopen_api();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}