OpenCascade Sweep Algorithm

OpenCascade Sweep Algorithm

[email protected]

Abstract. Sweeps are the objects you obtain by sweeping a profile along a path. Sweep is a very useful modeling algorithm. The paper focus on the introduction of the sweep algorithms in the opencascade. 

Key Words. Sweep, Prism, Revol, Pipe, Frenet Trihedron, 

1. Introduction

With the development and popularization of computer technology, computer-aided design and manufacturing (CAD/CAM) technology has also developed rapidly, and they have promoted the design revolution in many fields. The development and application level of computer-aided design and manufacturing technology has become a measure of a country. One of the important symbols of modernization level.

The recent ZTE incident has aroused extensive discussion in China. Since there is no substitute chip that can be manufactured in China, it is possible to find the gap between it and developed countries. In fact, is this not the case in the field of CAD? However, in terms of general CAD, there are some software manufacturers in China, and there are alternative products. In terms of industry CAD, it has always been the world of foreign software.

It turns out that there are some voices in China that "it is better to buy than to buy, and it is better to rent than to buy", and many foreign software have been introduced. These foreign software are excellent and greatly improve productivity. If you keep buying and don't think ahead, the result should be like ZTE. If you build it yourself, you need to invest a lot of money at first, but the advantages later are self-evident.

The 3D kernels in the world have relatively complete functions at present, and only OpenCASCADE is open source. The relevant domestic kernels have only been seen in the book "Computer Graphics", and have not seen the real thing. There are also foreign kernels acquired by some software vendors. The open source OpenCASCADE is still very good for learning modeling related algorithms. By learning the source code, you can not only know the truth, but also know the reason.

This article mainly introduces the usage of the Sweep sweep algorithm in OpenCASCADE, and it will be used correctly first. Correct use is the basis for studying its realization principle.

The sweep algorithm is a very common modeling algorithm in graphics, which is to sweep the specified profile along a path to obtain the model. Point sweeps get edges; edge sweeps get faces; face sweeps get bodies.

wps_clip_image-23837

Figure 1. Generating a sweep

The class BRepPrimAPI_MakeSweep is the base class of the sweep algorithm, as shown in the following figure:

wps_clip_image-9215

Several classes derived from it are used for:

l BRepPrimAPI_MakePrism: Generate a linear sweep;

l BRepPrimAPI_MakeRevol: Generate rotational sweep;

l BRepOffsetAPI_MakePipeShell: Generate a general sweep;

These situations are described below.

2.Prism

With the class BRepPrimAPI_MakePrism you can create a linear sweep, that is, a stretched body. In Draw Test Harness, you can use the command prism to create extrusions.

polyline p  0 0 0 1 0 0 1 2 0 0 1 0 0 0 0

prism r p 0 0 1

vdisplay p r

Run the above command in Draw Test Harness, you can get a linear stretch body, as shown below:

wps_clip_image-31373

The red is the contour Profile, and the extruded body shown on the right is obtained after linear sweeping.

3.Revol

With the class BRepPrimAPI_MakeRevol, you can create a rotating sweep, that is, a rotating body. In Draw Test Harness you can use the command revol to create a rotating body.

polyline p  0 0 0 1 0 0 1 2 0 0 1 0 0 0 0

revol r p 3 0 0 0 1 0 280

vdisplay p r

Run the above command in Draw Test Harness, you can get a rotating body, as shown below:

wps_clip_image-31096

Among them, the red is the contour Profile, and the rotating body shown on the right is obtained by rotating and sweeping.

4.Pipe Shell

The general sweep algorithm uses the class BRepOffAPI_MakePipeShell, and the following command is used in Draw Test Harness:

l mksweep

l addsweep

l deletesweep

l sestsweep

l buildsweep

The setsweep command has the following options:

setsweep options [arg1 [arg2 [...]]] : options are :

   -FR : Tangent and Normal are given by Frenet trihedron

   -CF : Tangente is given by Frenet, the Normal is computed to minimize the torsion

   -DT : discrete trihedron

   -DX Surf : Tangent and Normal are given by Darboux trihedron,

       Surf have to be a shell or a face

   -CN dx dy dz : BiNormal is given by dx dy dz

   -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed

   -G guide  0|1(Plan|ACR)  0|1|2(no contact|contact|contact on border) : with guide

-FR option: tangent and normal are determined by the Frenet frame;

-CF option: the tangent is specified by the Frenet frame, the normal is determined by calculating the minimum twist;

-DT option: tangent and normal are determined by Darboux frame;

-CN option: the secondary normal direction is determined by the specified dx, dy, dz;

-FT: tangent and normal are fixed;

The following examples illustrate the principles of these frame options in setsweep.

polyline p  0 0 0 1 0 0 1 2 0 0 1 0

circle c 0 0 0 1 0 0 0.2

mkedge e c

wire w e

mksweep p

addsweep w

setsweep -FX 1 0 0

buildsweep r -C

vdisplay p w r

Run the above Draw Test Harness script to get the model shown below:

wps_clip_image-10339

When using setsweep -FX 1 0 0 to move the profile along the sweep path Path, the normal direction is always the X-axis direction.

Set setsweep to FR, even if the Profile uses the Frenet frame when moving along the Path, the changed script is as follows:

mksweep p

addsweep w

setsweep -FR

buildsweep r -C

vdisplay p w r

wps_clip_image-15947

As can be seen from the above figure, when the profile profile moves along the path Path, the normal direction of the profile is always parallel to the path, that is, consistent with the tangent of the path.

Through the comparison of the above commands, you can understand the principle of options in setsweep. For more forms of frames, such as Darboux frames, you can search and learn by yourself.

The buildsweep command has the following options:

buildsweep result [-M/-C/-R] [-S] [tol] : options are

   -M : Discontinuities are treated by Modfication of

        the sweeping mode : it is the default

   -C : Discontinuities are treated like Right Corner

        Treatement is Extent && Intersect

   -R : Discontinuities are treated like Round Corner

        Treatement is Intersect and Fill

   -S : To build a Solid

buildsweep has specified discontinuous processing and whether to generate entities. in

n -C: Process the discontinuous places in the path Path by extending and intersecting;

n -R: The discontinuous places in the path Path are processed by intersection and filling;

The following examples illustrate the usage of options in buildsweep. By running the following Draw script:

polyline p  0 0 0 1 0 0 1 2 0 0 1 0 0 0 0

circle c 0 0 0 1 0 0 0.2

mkedge e c

wire w e

mksweep p

addsweep w

buildsweep r -C

vdisplay p w r

Use the -C option during buildsweep, and the effect is as shown below:

wps_clip_image-25485

Change the buildsweep option in the above script from -C to -R, that is:

buildsweep r -R

The resulting effect is shown in the following figure:

wps_clip_image-4615

From the comparison of the above two results, the -C and -R options of buildsweep can be understood.

5.Conclusion

OpenCASCADE provides algorithms for swept sculpting. For the two special cases of swept modeling, Prism and Revol, classes BrepPrimAPI_MakePrism and BRepPrimAPI_MakeRevol are provided to generate extruded and revolved bodies, respectively.

For the general sweep shape algorithm, the class BRepOffsetAPI_MakePipeShell is provided to generate. When using this class, you need to pay attention to the frame of the profile profile on the sweep path Path and the processing of the sweep path curve discontinuity.

6.References

1. OpenCASCADE Modeling Algorithms.

2. Zhan Haisheng. Li Guangxin. Ma Zhixin. Geometric modeling technology and system development based on ACIS. Tsinghua University Press. 2002

3. Chen Weihuan. Differential Geometry. Peking University Press. 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324899037&siteId=291194637