首页/技术分享

arasolid建模算法-创建基本三维拓扑实体

发布于:2025-07-20 22:15:44
798人 分享

Parasolid内核的功能可以总结为对实体和非实体对象增(创建)删改查、校验修复、管理(场景,内存)、文件导入导出等,本节内容以创建基本三维实体作为开始,后续更新章节将逐步由浅入深涉及各部分内容。

一、Parasolid中的基本三维拓扑实体

Parasolid提供现成、简单、易用的API来创建以下几种基本三维Solid实体:

  • 长方体
  • 圆锥
  • 圆柱
  • 棱台
  • 圆球
  • 圆环 

基本三维实体本质也可以通过其他方式来创建,如将一个矩形、正多边形、圆形轮廓的薄板进行拉伸可创建一个立方体、棱台、圆柱;将一个圆形薄板绕某个轴进行旋转可创建球体或圆环,但这些接口操作起来稍微有些繁琐,因此对于一些常见的基本三维实体,大部分几何内核 (ACIS,CGM,OCC)都会直接提供简单的接口以供使用。

二、基本三维实体的创建方法

三维实体的创建结果均保存在PK_BODY_t中。 basis_set可控制立方体底部中心点位置以及长宽高三条边的朝向,basis_set如果为空(nullptr),则直接使用世界坐标系进行创建。

2.1 长方体

可控制长方体长宽高的尺寸以及长宽高三条边的朝向。

  • 接口描述
PK_ERROR_code_t      PK_BODY_create_solid_block
(
--- received arguments ---
double               x,         --- block extent in local x direction (>0)
double               y,         --- block extent in local y direction (>0)
double               z,         --- block extent in local z direction (>0)
const PK_AXIS2_sf_t *basis_set, --- position and orientation (may be NULL)

--- returned arguments ---
PK_BODY_t     *const body       --- solid body returned
)
  • 创建方法
PK_AXIS2_sf_t axis;
axis.location = { -15, 10, 0 };
axis.axis = { 0,0,1};
axis.ref_direction = { 1,0,0 };

PK_BODY_t cube = PK_ENTITY_null;
PK_ERROR_code_t err = PK_BODY_create_solid_block(7,10,15, &axis, &cube);

2.2 圆锥

圆锥和圆台的创建使用同一个接口,radius控制圆台上底面的半径,当radius为0时为圆锥。

  • 接口描述
PK_ERROR_code_t      PK_BODY_create_solid_cone
(
--- received arguments ---
double               radius,    --- cone radius (may be 0)
double               height,    --- cone height (>0)
double               semi_angle,--- semi-vertex angle (>0, <Pi/2)
const PK_AXIS2_sf_t *basis_set, --- position and orientation (may be NULL)

--- returned arguments ---
PK_BODY_t     *const body       --- solid body returned
)

  • 创建方法
PK_AXIS2_sf_t axis;
axis.location = { 20, 10, 10 };
axis.axis = { 0, 0, -1 };
axis.ref_direction = { 0, 1, 0 };

PK_BODY_t cone = PK_ENTITY_null;
PK_ERROR_code_t err = PK_BODY_create_solid_cone(5, 10, 3.1415926 / 8, &axis, &cone);

2.3 圆柱

  • 接口描述
PK_ERROR_code_t      PK_BODY_create_solid_cyl
(
--- received arguments ---
double               radius,    --- cylinder radius (>0)
double               height,    --- cylinder height (>0)
const PK_AXIS2_sf_t *basis_set, --- position and orientation (may be NULL)

--- returned arguments ---
PK_BODY_t     *const body       --- solid body returned
)

  • 创建方法
PK_AXIS2_sf_t axis;
axis.location = { 0, 10, 0 };
axis.axis = { 0, 0, 1 };
axis.ref_direction = { 0, 1, 0 };

PK_BODY_t cly = PK_ENTITY_null;
PK_ERROR_code_t err = PK_BODY_create_solid_cyl(6, 15, &axis, &cly);

2.4 棱台

radius为棱台底面轮廓外接圆的半径。

  • 接口描述
PK_ERROR_code_t      PK_BODY_create_solid_prism
(
--- received arguments ---
double               radius,    --- prism radius (>0)
double               height,    --- prism height (>0)
int                  n_sides,   --- number of sides (>2)
const PK_AXIS2_sf_t *basis_set, --- position and orientation (may be NULL)

--- returned arguments ---
PK_BODY_t     *const body       --- solid body returned
)
  • 创建方法
PK_AXIS2_sf_t axis;
axis.location = { -15, -10, 0 };
axis.axis = { 0, 0, -1 };
axis.ref_direction = { 0, 1, 0 };

PK_BODY_t prism = PK_ENTITY_null;
PK_ERROR_code_t err = PK_BODY_create_solid_prism(4, 5, 6, &axis, &prism);

2.5 球体

  • 接口描述
PK_ERROR_code_t      PK_BODY_create_solid_sphere
(
--- received arguments ---
double               radius,    --- sphere radius (>0)
const PK_AXIS2_sf_t *basis_set, --- position and orientation (may be NULL)

--- returned arguments ---
PK_BODY_t     *const body       --- solid body returned
)

  • 创建方法
PK_AXIS2_sf_t axis;
axis.location = { 20, -10, 0 };
axis.axis = { 0, 0, -1 };
axis.ref_direction = { 0, 1, 0 };

PK_BODY_t sphere = PK_ENTITY_null;
PK_ERROR_code_t err = PK_BODY_create_solid_sphere(5, &axis, &sphere);

2.6 圆环

major_radius为圆环中心线的半径 minor_radius为环宽的一半

  • 接口描述
PK_ERROR_code_t      PK_BODY_create_solid_torus
(
--- received arguments ---
double               major_radius, --- torus major radius
double               minor_radius, --- torus minor radius (> 0)
const PK_AXIS2_sf_t *basis_set,    --- position and orientation (may be NULL)

--- returned arguments ---
PK_BODY_t     *const body          --- solid body returned
)

  • 创建方法
PK_AXIS2_sf_t axis;
axis.location = { 0, -10, 0 };
axis.axis = { 0, 0, -1 };
axis.ref_direction = { 0, 1, 0 };

PK_BODY_t torus = PK_ENTITY_null;
PK_ERROR_code_t err = PK_BODY_create_solid_torus(8, 3, &axis, &torus);

2.7 创建结果预览

image.png

转载请注明来源本文地址:https://www.tuituisoft/blog/89074.html

上一篇:

专家征集 | 涉及BIM,湖南省住建厅官方征集全省城市更新和住房保障专家库专家专家征集 | 涉及BIM,湖南省住建厅官方征集全省城市更新和住房保障专家库专家

下一篇:

行业新闻 | 科技创新 平台赋能 产业集群 长沙推动智能建造产业高质量发展