首页/工业设计

Parasolid建模算法-孤立点、线框、薄板

发布于:2025-07-21 20:53:42
889人 分享

腿腿教学网-Parasolid建模算法-孤立点、线框、薄板

1.3 Sheet Body

Sheet:薄板,由若干连接的拓扑面组成。薄板同样可以作为拉伸、放样、扫掠算法的轮廓,与Wire不同的是,Wire通常形成非封闭的薄壁结构,而Sheet形成封闭实体对象。



腿腿教学网-Parasolid建模算法-孤立点、线框、薄板

1.4 Wire和Sheet运算的区别

腿腿教学网-Parasolid建模算法-孤立点、线框、薄板




二、创建Minimum,Wire,Sheet

2.1 Minimum Body的创建

从PK_POINT_sf_t创建PK_POINT_t,再从PK_POINT_t创建PK_BODY_t,最终创建的结果minimum_body中只有一个拓扑点。

  • 接口描述
PK_ERROR_code_t  PK_POINT_make_minimum_body
(
--- received arguments ---
PK_POINT_t       point,     --- point

--- returned arguments ---
PK_BODY_t *const body       --- created body
)
  • 创建代玛
PK_POINT_sf_t point_sf;
point_sf.position = { 3,4,5 };

PK_POINT_t point_t = PK_ENTITY_null;
PK_ERROR_code_t err_code = PK_POINT_create(&point_sf, &point_t);

PK_BODY_t minimum_body = PK_ENTITY_null;
err_code = PK_POINT_make_minimum_body(point_t, &minimum_body);

2.2 Wire Body的创建

线框可从一条或多条几何曲线进行创建,也可直接从若干拓扑边进行创建。 在创建线框实体前,我们得先明确,在Parasolid中几何实体在数学上是无限延伸的,即几何线和几何面是没有界限的,因此由几何曲线创建拓扑边(线框)时,必须使用参数区间(INTERVAL)解限定拓扑边的范围,及起终点。 Parasolid不支持直接从几何曲线创建拓扑边(ACIS,OCCT等内核支持),而是一步到位直接创建包含了拓扑边的BODY。

2.2.1 几何曲线创建线框

Parasolid中提供了两个几何曲线创建线框的接口,分别是PK_CURVE_make_wire_body和PK_CURVE_make_wire_body_2,PK_CURVE_make_wire_body在较新的版本中已被声明为弃用并被后者取代。通常情况下使用PK_CURVE_make_wire_body不会由问题,但不保证对后期新版本更新的曲线实体类型生效(PLINE使用PK_CURVE_make_wire_body会报错),因此建议直接使用PK_CURVE_make_wire_body_2

  • PK_CURVE_make_wire_body的接口描述
PK_ERROR_code_t  PK_CURVE_make_wire_body
(
--- received arguments ---
PK_CURVE_t       curve,     --- curve
PK_INTERVAL_t    range,     --- extent of curve

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

  • PK_CURVE_make_wire_body_2的接口描述
    curves:几何曲线集合,可以是任意的几何曲线实体(但多段线不能与其他线进行组合)。
    bounds:几何曲线对应的参数范围集合。
    options:参数选项,查看下方对PK_CURVE_make_wire_body_o_t的相关描述。
    body:创建的结果即WireBody。
    edges:创建的若干拓扑边,只有当PK_CURVE_make_wire_body_o_t中的want_edges设置为PK_LOGICAL_true才会返回有效值,edges实际已经存储在WireBody中。
    edge_index:创建的若干拓扑边在WireBody中的索引位置。
PK_linkage_m PK_ERROR_code_t PK_CURVE_make_wire_body_2
(
/* received */
int                                   /*n_curves*/,     /* number of curves (ie, */
const PK_CURVE_t                      /*curves*/[],     /* curves to create a wire */
const PK_INTERVAL_t                   /*bounds*/[],     /* bounds of each curve */
const PK_CURVE_make_wire_body_o_t   * /*options*/,      /* options structure */
/* returned */
PK_BODY_t                     *const  /*body*/,         /* the created wire body */
int                           *const  /*n_new_edges*/,  /* number of new edges */
PK_EDGE_t                    **const  /*new_edges*/,    /* new edges */
int                          **const  /*edge_index*/    /* pos in original array */
);
/*
This function creates a wire body from an array of curves and intervals. The
curves do not need to be ordered (unless specified otherwise) or directed.
*/
  • PK_CURVE_make_wire_body_o_t的数据结构 PK_CURVE_make_wire_body_o_t通常使用宏PK_CURVE_make_wire_body_o_m来设定默认初始值。allow_disjoint:是否允许创建分离的WireBody,如果为PK_LOGICAL_false且PK_CURVE_make_wire_body_2方法中传入的曲线中出现分离不衔接的情况,则会创建失败。
    want_edges、want_indices:是否输出拓扑边和边的索引。
struct PK_CURVE_make_wire_body_o_s
    {
    int             o_t_version;     /* version number of option structure */
    double          tolerance;       /* max separation between any two curve */
    PK_LOGICAL_t    allow_disjoint;  /* is the wire body allowed to be */
    PK_LOGICAL_t    check;           /* check the body for errors? */
    PK_LOGICAL_t    want_edges;      /* return the new edges in new_edges? */
    PK_LOGICAL_t    want_indices;    /* return the edge indices in edge_index? */
    PK_CURVE_sequential_t
                    sequential;      /* whether the curves are supplied in the */
    };

typedef struct PK_CURVE_make_wire_body_o_s PK_CURVE_make_wire_body_o_t;
  • 代玛样例 

    以创建一个包含直线、圆、圆弧、椭圆、样条曲线多条曲线的线框模型为例。



    腿腿教学网-Parasolid建模算法-孤立点、线框、薄板

Ⅰ.创建直线line1

PK_ERROR_code_t err = PK_ERROR_ok;

PK_LINE_sf_t line1_sf;
line1_sf.basis_set.location = { -10,10,0 };
line1_sf.basis_set.axis = { 0,1,0 };
PK_LINE_t line1 = PK_ENTITY_null;
err = PK_LINE_create(&line1_sf, &line1);

Ⅱ.创建直线line2

PK_LINE_sf_t line2_sf;
line2_sf.basis_set.location = { 10,10,0 };
line2_sf.basis_set.axis = { 0,1,0 };
PK_LINE_t line2 = PK_ENTITY_null;
err = PK_LINE_create(&line2_sf, &line2);

Ⅲ.创建半圆half_circ

PK_CIRCLE_sf_t half_circ_sf;
half_circ_sf.radius = 10;
half_circ_sf.basis_set.location = { 0,20,0 };
half_circ_sf.basis_set.axis = { 0,0,1 };
half_circ_sf.basis_set.ref_direction = { 1,0,0 };
PK_CIRCLE_t half_circ = PK_ENTITY_null;
err = PK_CIRCLE_create(&half_circ_sf, &half_circ);

Ⅳ.创建样条曲线spline

PK_VECTOR_t spline_vertices[4];
spline_vertices[0] = { 10,10,0 };
spline_vertices[1] = { 8,0,0 };
spline_vertices[2] = { -8,0,0 };
spline_vertices[3] = { -10,10,0 };
PK_BCURVE_create_spline_2_o_t spline_o;
PK_BCURVE_create_spline_2_o_m(spline_o);
PK_BCURVE_spline_r_t results;
err = PK_BCURVE_create_spline_2(4, spline_vertices, &spline_o, &results);
PK_BCURVE_t spline = results.bcurves->bcurve;

Ⅴ.创建完整圆circ

PK_CIRCLE_sf_t circ_sf;
circ_sf.radius = 8;
circ_sf.basis_set.location = { 0,20,0 };
circ_sf.basis_set.axis = { 0,0,1 };
circ_sf.basis_set.ref_direction = { 1,0,0 };
PK_CIRCLE_t circ = PK_ENTITY_null;
err = PK_CIRCLE_create(&circ_sf, &circ);

Ⅵ.创建椭圆ellipse

PK_ELLIPSE_sf_t ellipse_sf;
ellipse_sf.R1 = 5;
ellipse_sf.R2 = 3;
ellipse_sf.basis_set.location = { 0,5,0 };
ellipse_sf.basis_set.axis = { 0,0,1 };
ellipse_sf.basis_set.ref_direction = { 1,0,0 };
PK_ELLIPSE_t ellipse = PK_ENTITY_null;
err = PK_ELLIPSE_create(&ellipse_sf, &ellipse);

Ⅶ.设置各曲线参数区间 对于各曲线的参数区间:

PK_LINE_t:表示location点的曲线参数为0,沿axis方向前进的距离正,反向为负值,直至达到Parasolid的最大空间范围(-10000,10000)。

PK_CIRCLE_t和PK_ELLIPSE_t:参数区间为0~2PI,参数为0的点位置为ref_direction的指向。

PK_BCURVE_t:参数区间为0-1。

PK_PLINE_t:参数区间为0至多段线的长度。

PK_INTERVAL_t line1_interval = { 0,10 };
PK_INTERVAL_t line2_interval = { 0,10 };
PK_INTERVAL_t half_circ_interval = { 0,M_PI };
PK_INTERVAL_t spline_interval;
PK_CURVE_ask_interval(spline, &spline_interval);
PK_INTERVAL_t circ_interval = { 0,2 * M_PI };
PK_INTERVAL_t ellipse_interval = { 0,2 * M_PI };

PK_INTERVAL_t intervals[6] = { line1_interval,line2_interval,half_circ_interval,spline_interval ,circ_interval,ellipse_interval };
PK_CURVE_t curves[6] = { line1,line2,half_circ,spline,circ ,ellipse };

Ⅷ.创建线框

PK_CURVE_make_wire_body_o_t wire_body_o;
PK_CURVE_make_wire_body_o_m(wire_body_o);
wire_body_o.allow_disjoint = true;
wire_body_o.want_edges = true;
wire_body_o.want_indices = true;

PK_BODY_t ret_wire_body = PK_ENTITY_null;
int n_new_edges = 0;
PK_EDGE_t* new_edges = nullptr;
int* edge_index = nullptr;

err = PK_CURVE_make_wire_body_2(6,
curves,
intervals,
&wire_body_o,
&ret_wire_body,
&n_new_edges,
&new_edges,
&edge_index);

Ⅸ.获取结果 

ret_wire_body即最终创建的线框模型,PK_CURVE_make_wire_body_2会返回PK_ERROR_code_t类型的错误玛,如果不为0,则表示存在错误。

new_edges和edge_index为线框中的边及边在线框中的索引位置,在本例中,edge_index的结果为:0,2,1,3,4,5,可以看到,即使传入的曲线不是按照头尾交接的排序方式传参且方向并不一致的情况下,算法会自动调整顺序和方向。

2.2.2 由Edge创建Wire

注意事项:

  • 由Edge创建Wire时需确保Edge不属于任意拓扑实体。

  • 在Parasolid中进行拉伸、放样、扫掠等操作时,轮廓和路径参数都不能是Edge,因此最终还是要回到将Edge转成WireBody上来。

  • 接口描述

PK_ERROR_code_t                   PK_EDGE_make_wire_body
(
--- received arguments ---
int                               n_edges,  --- number of edges
const PK_EDGE_t                   edges[],  --- edges
const PK_EDGE_make_wire_body_o_t *options,  --- options

--- returned arguments ---
PK_BODY_t                  *const body,     --- created body
PK_TOPOL_track_r_t         *const tracking  --- tracking
)

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

上一篇:没有了 下一篇:没有了