Sweeping Basics


The function api_sweep_with_options and the associated Scheme extension sweep:law encompass the sweeping functionality.

The api_sweep_with_options function is used to simplify sweeping in C++. Various options to control sweeping may be specified through the sweep_options class and the associated Scheme extension sweep:options. The function api_sweep_with_options has four overloaded instances:

Sweep along a path
The API arguments are: profile, a pointer to a path entity, sweep options, and a pointer to the new body (if applicable).
Sweep a distance
The API arguments are: profile, distance (in the direction of the profile face normal), sweep options, and a pointer to the new body (if applicable).
Sweep along a vector
The API arguments are: profile, vector (to sweep along), sweep options, and a pointer to the new body (if applicable).
Sweep around an axis
The API arguments are: profile, position (of the root of the sweep axis), vector (of the direction of the sweep axis), sweep options, and a pointer to the new body (if applicable).

The first argument to the api_sweep_with_options function is a profile in the form of a pointer to an entity. For example, an edge, a wire body, a face, or a planar sheet body with nonadjacent faces, which may or may not belong to a body, could form the sweeping profile.

The next argument is a path. The path may take the form of an EDGE or WIRE body pointer. The path may be specified as a distance if the profile is a planar face or a planar sheet body with non-adjacent faces. A vector or an axis to sweep around (in the form of a position and a vector) may also be provided as the path. However, defining vector or axis as paths requires the use of the default rail law (without twist).

All other inputs are passed to the API through an instance of the sweep_options class. The sweep options are explained in detail in the next section.

The returned body depends on the profile type:

Face belonging to a body
When the profile is a face that belongs to a body, the owning body is altered, and the new body points to NULL.
Face not belonging to a body
When the profile is a face not belonging to a body, a new body is created and returned. The original face remains separate and available for further independent manipulation or deletion.
Wire body
When the profile is a wire body, the owning body is altered and the new body points to NULL. The altered body can be a solid or a sheet body depending on whether or not the option to make a solid has been set, and whether or not the wire body is closed. It is not necessary or desirable to cover the wires. The default is to make a solid if the wire body is closed.
Edge not belonging to a body
When the profile is an edge or set of independent edges, a new body is created. The original edge may become part of the new body or be deleted. If the edge is closed, by default it makes a solid body; otherwise it makes a sheet body. It is not necessary or desired that the edges be covered.

Profile Location

Locating the profile at the beginning of the sweep path is not always practical and is not a requirement when using sweeping. The profile's location is determined in the following manner:

Planar profile
The profile is located at the nearest intersection point on the path, within the profile plane.
Linear profile
The profile is always located at the beginning of the path.

The plane of the profile must intersect the path in the intended location. If the plane of the profile does not intersect the path at all, the relationship is ambiguous and sweeping may not complete, or may create unintended results. If the plane of the profile intersects the path at an unintended location, this location is used in determining the relationship of profile and the path.

These rules work well when the profile is perpendicular to the path. However, if the given profile is not perpendicular to the path, the path location may not be unique.

For non-planar profiles, the position of the path may be ambiguous and the sweeping code is not recommended. Customers need to be careful when selecting a non-planar profile.

Applications should move the profile to the beginning of the path and use the AS_IS argument for the portion sweep option.

Basic Sweep

The most basic sweep activities are sweeping a planar face, a solid face or a wire along a path or vector, and revolving a face or wire body. The following examples demonstrate those capabilities.

Revolve a Face

Use the Scheme extension sweep:options with the sweep_angle option to revolve a face.

Scheme Example

(define block1 (solid:block (position -10 -10 0)
       (position 25 25 25)))
(define entities (entity:faces block1))
(define face1 (car (cdr (cdr entities))))
(define fix (entity:fix-transform block1))
;; OUTPUT Original

(define opts (sweep:options "sweep_angle" 60))
(define sweep1 (sweep:law face1
       (position -10 -10 -10)
       (gvector 1 0 0) opts))
;; OUTPUT Result

Example. Revolve a Face

Figure. Revolve a Face

Revolve a Wire Body

Use the Scheme extension sweep:options with the sweep_angle option to revolve a wire body.

Scheme Example

(define edge1 (edge:linear (position 0 0 0) (position 20 0 0)))
(define edge2 (edge:linear (position 20 0 0) (position 20 20 0)))
(define edge3 (edge:linear (position 20 20 0) (position 0 20 0)))
(define edge4 (edge:linear (position 0 20 0) (position 0 0 0)))
(define wirebody (wire-body (list edge1 edge2 edge3 edge4)))
; OUTPUT Original

; Create a solid by revolving the wire body.
(define sweep1 (sweep:law wirebody (position 0 0 0)
       (gvector 0 1 0) (sweep:options "sweep_angle" 60)))
:OUTPUT Result

Example. Revolve a Wire Body

Figure. Revolve a Wire Body

Sweep a Planar Face

Use the Scheme extension sweep:options with the draft_angle option to sweep a planar face. Notice the range of sweeps (in each of the three examples) when the sweep:law angle is changed. Also, notice the effects when changing the values for draft_angle from positive to negative. As a side note, this set of examples provides a perfect opportunity to demonstrate some of the uses for the journal commands.

Scheme Example

(journal:on "blub.jrl")
(define block1 (solid:block (position -10 -10 -10)
       (position 30 30 30)))
(define block1 (entity:faces block1))
(define faces (entity:faces block1))
(define face1 (car (cdr (cdr faces))))
(journal:off)
(journal:save "blub.jrl")
;; OUTPUT Original

; Create a new solid by sweeping the face along a gvector.
(define sweep1 (sweep:law face1 10.0
       (sweep:options "draft_angle" -45)))
; OUTPUT Result with Negative Draft Angle

; This portion clears the entities, reloads the basic block, and
; runs a new slant on the sweeping/law example.
(part:clear)
(journal:load "blub.jrl")
; Note the change in distance defined to sweep along the face
; normal.
(define sweep1 (sweep:law face1 15.0
       (sweep:options "draft_angle" -45)))
;; Modified Sweep Distance
; OUTPUT Result with Negative Draft Angle

; This portion clears the entities, reloads the basic block, and
; runs a third slant on the sweeping/law example.
(part:clear)
(journal:load "blub.jrl")
; This time notice the effect of a positive draft_angle.
(define sweep1 (sweep:law face1 15.0
       (sweep:options "draft_angle" 45)))
;; Modified "draft_angle"

Example. Sweep a Planar Face

Figure. Sweep a Planar Face

Sweep a Solid Face

Use the Scheme extension sweep:options with a (positive) draft_angle to sweep a solid face. This example identifies a single face of a solid block, uses a gvector to define the extent of the sweep, and further defines the sweep with a 15 degree outward angle.

Scheme Example

; Sweeping a solid face.
(define block1 (solid:block (position -10 -10 -10)
       (position 30 30 30)))
(define faces (entity:faces block1))
(define face2 (car faces))
;; OUTPUT Original

; Create a new solid by sweeping the face along a gvector.
(define sweep2 (sweep:law face2 (gvector 0 0 10)
       (sweep:options "draft_angle" 15)))
;; OUTPUT Result

Example. Sweep a Solid Face

Figure. Sweeping a Face with Positive Draft Angle

Sweep a Wire

Use the Scheme extension sweep:options with the draft_angle option to sweep a wire. This example shows converting four wires into a wire body, creating a path to sweep, and then creating the final solid by sweeping the wire body.

Scheme Example

(define edge_1 (edge:circular (position 0 0 0) 25 0 180))
(define edge_2 (edge:circular (position 0 0 0) 25 180 270))
(define edge_3 (edge:linear (position 0 0 0) (position 25 0 0)))
(define edge_4 (edge:linear (position 0 0 0) (position 0 -25 0)))
(define w_body (wire-body (list edge_4 edge_3 edge_1 edge_2)))
(define path1 (edge:linear (position 0 0 0) (position 0 0 7.5)))
; OUTPUT Original

; Create a solid by sweeping the wire body.
(define sweep1 (sweep:law w_body path1
       (sweep:options "draft_angle" -10)))
; OUTPUT Result

Example. Sweep a Wire

Figure. Sweeping a Wire

Sweep Along a Path

Use the Scheme extension sweep:options with draft_angle and to_face options to sweep along a path. In this example, the face is swept along the path (defined by an edge) onto a surface (defined as a planar face). Watch the effect of the negative draft angle on the sweep. Also note how the sweep terminates at the planar face instead of continuing the path to the end of the linear edge.

Scheme Example

; sweeping a path
(define block1 (solid:block (position -45 -15 -15)
       (position -15 15 15)))
(define facelist (entity:faces block1))
(define profile1 (car (cdr (cdr (cdr (cdr (cdr facelist)))))))
(define edge1 (edge:linear (position -15 0 0)
       (position 20 0 3)))
(define planarface (face:planar-disk
       (position 10 0 0) (gvector -1 0 0) 50))
; OUTPUT Original

(define sweep1 (sweep:law profile1 edge1
       (sweep:options "to_face" planarface "draft_angle" -15)))
; OUTPUT Result

Example. Sweep Along a Path

Figure. Sweep along a Path

Sweep Along a Vector

Use the Scheme extension sweep:options with draft_angle option to sweep along a vector.

Scheme Example

; Sweeping along a vector
(define face1 (face:plane (position -20 10 10) 30 30
       (gvector 10 0 0)))
;; OUTPUT Original

; Sweep a planar face along a vector with draft.
(define sweep1 (sweep:law face1 (gvector 38 0 20)
       (sweep:options "draft_angle" 20)))
;; OUTPUT Result

Example. Sweep along a Vector

Figure. Sweep along a Vector

Sweep Non-Planar Profiles

Non-planar profiles can be swept along a vector, a path or in a revolve operation. The following restrictions apply because of the difficulty in computing these profiles:

Due to of the extreme nature of this operation, the body can result in self-intersecting body. Therefore, care should be taken when choosing a path

Scheme Example

; Sweeping a non-planar face
(part:clear)
(define e1 (edge:linear (position 0 0 0)(position 1 4 0)))
(define e2 (edge:linear (position 1 4 0)(position 3 4 0)))
(define e3 (edge:linear (position 3 4 0)(position 5 0 0)))
(define e4 (edge:ellipse (position 2.5 0 0)(gvector 0 -1 0)(gvector 2.5 0 0)1 0 180))
(define profile (wire-body (list e1 e2 e3 e4)))
(define path (edge:spline (list (position 2.5 5 0)(position 2.5 6 6)(position 2.5 7 10))))
(sweep:law profile path)

Example. Sweep Along a Vector

Figure. Sweep a Non-planar Face

[Top]