完善主体资料,免费赠送VIP会员!
* 主体类型
* 企业名称
* 信用代码
* 所在行业
* 企业规模
* 所在职位
* 姓名
* 所在行业
* 学历
* 工作性质
请先选择行业
您还可以选择以下福利:
行业福利,领完即止!

下载app免费领取会员

NULL

ad.jpg

Parasolid建模算法-Extrude

发布于:2025-07-27 22:18:02

本节内容要点

  • 什么是Extrude算法
    简要介绍Parasolid、ACIS、CGM中的拉伸算法。
  • Parasolid中的Exturde的特点
    简要说明PK内核对点、线、面拉伸的支持。
  • Parasolid中Extrude算法的高级选项
    详解拉伸边界等参数。

一、Extrude的概念

1.1 什么是Extrude

Extrude通常被称为拉伸,是一种将几何或拓扑体沿某个方向延伸生成一个新的几何或拓扑体的建模技术,是几何内核的一个基础建模算法。

1.2 各几何内核中Extrude算法的实现

OpenCascade中拉伸算法通过BRepPrimAPI_MakePrism类实现;在ACIS中通过api_sweep_with_options函数的一个重载方法实现(被视作Sweep扫掠算法的一种特殊情况);CGM中由CATICGMTopPrims类实现。 

Opencascade中的拉伸算法实现比较简单,而在Parasolid、ACIS、CGM中都支持更多参数(边界等)的设定。

1.3 Extrude与Sweep的区别

与Extrude相似的概念有Sweep,二者之间有如下区别:

特性
Extrude
Sweep
路径类型
单一方向方向(直线)
任意曲线(直线、圆弧、样条曲线)
截面变化
保持不变
可旋转、缩放、变形
计算复杂度
高(需处理路径参数化和截面变换)
结果多样性
规则几何体
复杂几何体(管道、弹簧)

二、Parasolid中的Extrude算法

2.1 Extrude相关接口

Parasolid中的拉伸建模算法接口由PK_BODY_extrude提供,其函数原型为:

PK_ERROR_code_t            PK_BODY_extrude
(
received arguments
PK_BODY_t                  profile,     minimum, wire or sheet profile
                                        to extrude
PK_VECTOR1_t               path,         direction of linear extrusion
const PK_BODY_extrude_o_t *options,     options structure

returned arguments
PK_BODY_t           *const body,         resulting extruded body
PK_TOPOL_track_r_t  *const tracking,     tracking information
PK_TOPOL_local_r_t  *const results       status information
)

从入参上看,PK_BODY_extrude方法接口由PK_BODY_t类型的轮廓、拉伸方向向量path、高级选项options来控制,并返回一个新的BODY。

Parasolid支持对点(Minimum)、线(Wire)、面(Sheet)作为轮廓(profile)进行拉伸,且对WireBody和SheetBody都不要求是平坦的;对MinimumBody的拉伸会生成WireBody,对WireBody拉伸会生成SheetBody,对SheetBody拉伸会形成一个实体(Solid)。



腿腿教学网-Parasolid建模算法-Extrude

PK_BODY_extrude函数接收轮廓参数必须是PK_BODY_t类型,不支持POINT、VERTEX、 CURVE、EDGE、SURF、FACE这些几何和拓扑类型的参数。

虽然PK_BODY_extrude不支持对拓扑实体和几何实体进行拉伸,但Parasolid提供了其他类似的接口来实现让实体沿着某个方向进行"拉伸"。这些接口在命名上都带有Sweep的标识,Parasolid官方将其都视作扫掠(Sweep)的一种,但由于这些接口都是提供了一个向量参数(PK_VECTOR_t或PK_VECTOR1_t)来以线性的方式进行偏移,因此本文擅作主张将这些接口都归类到本节中,接口有以下几个:

  • 对拓扑点进行Sweep 生成一个拓扑边和新的拓扑点
PK_ERROR_code_t         PK_VERTEX_sweep
(
received arguments
PK_VERTEX_t             vertex,         end vertex of wire body
PK_VECTOR_t             path,           translation vector
PK_LOGICAL_t            local_check,   whether local checking will be done

returned arguments
PK_EDGE_t        *const lateral,       new edge
PK_VERTEX_t      *const base,           swept vertex
PK_local_check_t *const check_result   result of local check
)
  • 对几何曲线Sweep生成扫掠曲面
struct PK_SWEPT_sf_s
    {
    PK_CURVE_t            curve;         curve to sweep
    PK_VECTOR1_t          direction;     vector direction to sweep
    };


PK_ERROR_code_t      PK_SWEPT_create
(
received arguments
const PK_SWEPT_sf_t *swept_sf,   swept surf standard form

returned arguments
PK_SWEPT_t    *const swept       swept surf
)
  • 对几何曲线进行Sweep生成几何曲面
PK_ERROR_code_t  PK_CURVE_sweep
(
received arguments
PK_CURVE_t       curve,         curve to sweep
PK_VECTOR1_t     direction,     sweep direction

returned arguments
PK_SURF_t *const surf           swept surface
)

This function sweeps a curve to form a surface.

The curve must be of one of the following classes:
    PK_CLASS_line
    PK_CLASS_circle
    PK_CLASS_ellipse
    PK_CLASS_bcurve
  • 对B样条曲线进行Sweep生成样条曲面
PK_ERROR_code_t   PK_BCURVE_sweep
(
received arguments
PK_BCURVE_t       bcurve,       bcurve
PK_VECTOR_t       path,         translation vector

returned arguments
PK_BSURF_t *const bsurf         resulting bsurf
)
  • 对拓扑面Sweep生成新的拓扑面
PK_ERROR_code_t         PK_FACE_sweep
(
received arguments
int                     n_faces,       number of faces
const PK_FACE_t         faces[],       faces
PK_VECTOR_t             path,           translation vector
PK_LOGICAL_t            local_check,   whether local checking will be done

returned arguments
int              *const n_laterals,     number of laterals
PK_FACE_t       const laterals,       new faces (may be NULL)
PK_EDGE_t       const bases,         edges swept into laterals
                                        (may be NULL)
PK_local_check_t *const check_result   result of local check
)

2.2 效果演示

《Parasolid建模算法-孤立点、线框、薄板》一节中创建的复杂线框进行拉伸形成非封闭薄板。



腿腿教学网-Parasolid建模算法-Extrude

《Parasolid建模算法-创建薄板Sheet》一节中创建的带孔洞的薄板进行拉伸形成带孔封闭实体。

  • 代码样例
PK_BODY_extrude_o_t extrude_o;
PK_BODY_extrude_o_m(extrude_o);
extrude_o.end_bound.distance = 30;

PK_TOPOL_track_r_t tracking;
PK_TOPOL_local_r_t results;
PK_BODY_t extrude_body = PK_ENTITY_null;
PK_BODY_extrude(circ_sheet, { 0, 0, 1 }, &extrude_o, &extrude_body, &tracking, &results);
  • 拉伸效果
    腿腿教学网-Parasolid建模算法-Extrude

三、PK_BODY_extrude算法的高级选项

PK_BODY_extrude最简单的用法是将一个轮廓朝指定方向拉伸给定的距离,除此之外还支持设定同时对轮廓两侧进行拉伸、设定拉伸到指定边界,选择保留拉伸模型的内外侧等。 

拉伸选项PK_BODY_extrude_o_s的定义:

struct PK_BODY_extrude_o_s
    {
    int                   o_t_version;        /* options structure version */
    PK_bound_def_t        start_bound;        /* starting bound of swept body */
    PK_bound_def_t        end_bound;          /* ending bound of swept body */
    PK_BODY_t             extruded_body;      /* body to use instead of swept */
    PK_LOGICAL_t          allow_disjoint;     /* swept body can have a disjoint */
    PK_PARAM_consistent_t consistent_params;  /* whether to ensure consistent */
    };
typedef struct PK_BODY_extrude_o_s PK_BODY_extrude_o_t;

PK_bound_def_t的定义:

struct PK_bound_def_s
    {
    PK_bound_t        bound;         /* method of defining bound */
    PK_LOGICAL_t      forward;       /* whether bound in positive sense of path */
    double            distance;      /* extrusion distance */
    PK_ENTITY_t       entity;        /* bounding entity */
    PK_LOGICAL_t      nearest;       /* whether divisions are numbered from */
    int               nth_division;  /* select nth division */
    PK_bound_side_t   side;          /* which side is the first division if */
    };
typedef struct PK_bound_def_s PK_bound_def_t;

使用内置的PK_BODY_extrude_o_m宏来设置默认参数:

#define PK_BODY_extrude_o_m(options)                                          \
    (                                                                         \
       (options).o_t_version              = 5,                                \
       (options).start_bound.bound        = PK_bound_distance_c,              \
       (options).start_bound.forward      = PK_LOGICAL_true,                  \
       (options).start_bound.distance     = 0.0,                              \
       (options).start_bound.entity       = PK_ENTITY_null,                   \
       (options).start_bound.nearest      = PK_LOGICAL_true,                  \
       (options).start_bound.nth_division = 1,                                \
       (options).start_bound.side         = PK_bound_side_both_c,             \
       (options).end_bound  .bound        = PK_bound_distance_c,              \
       (options).end_bound  .forward      = PK_LOGICAL_true,                  \
       (options).end_bound  .distance     = 1.0,                              \
       (options).end_bound  .entity       = PK_ENTITY_null,                   \
       (options).end_bound  .nearest      = PK_LOGICAL_true,                  \
       (options).end_bound  .nth_division = 1,                                \
       (options).end_bound  .side         = PK_bound_side_both_c,             \
       (options).extruded_body            = PK_ENTITY_null,                   \
       (options).allow_disjoint           = PK_LOGICAL_false,                 \
       (options).consistent_params        = PK_PARAM_consistent_unset_c       \
    )

选项主要包括两个PK_bound_def_s类型的参数start_bound和end_bound,可以用来控制拉伸的起始位置(边界)和终止位置(边界) ,PK_bound_def_s的各参数意义如下:

  • PK_bound_t 

    边界类型可设置为指定距离或某种类型的实体,PK_bound_def_s的第四个参数entity需设置为指定类型的实体。

    PK_bound_t类型
    说明
    PK_bound_distance_c
    拉伸指定距离,非负值,start_bound.distance默认值为0,end_bound.distance默认值为为1.0
    PK_bound_surf_c
    几何曲面作为边界
    PK_bound_face_c
    拓扑面作为边界
    PK_bound_body_c
    拓扑体作为边界
    PK_bound_sheet_c
    薄板作为边界
    PK_bound_none_c
    无边界
  • forward: 

    是否跟指定的的拉伸方向一致,否则为反向拉伸。

  • distance:

    拉伸距离,只有当bound为PK_bound_distance_c时生效。

  • entity: 

    边界实体对象,只有当bound为PK_bound_surf_c、PK_bound_face_c、PK_bound_body_c、PK_bound_sheet_c时生效。

  • nearest

    是否将最近的相交实体视为边界,否则使用最远的相交视为边界,与nth_division配合使用。

  • nth_division

    设置拉伸体与边界实体多次相交时的第N次相交视为边界。

  • side

    当拉伸体与边界体相交时,保留二者的交集、差集或保留所有。

  • 效果演示



    腿腿教学网-Parasolid建模算法-Extrude

       



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

未标题-1.jpg

上一篇:没有了

下一篇:没有了