sweep:law
List of: Scheme Extensions
Subjects: Laws, Sweeping
Contents: Sweeping

Action: Creates a surface or solid by sweeping a profile along a path.

Filename: swp/swp_scm/swp_scm.cxx

APIs: api_check_wire_self_inters, api_sweep_with_options

Syntax: (sweep:law profile {path | distance | vector | axis}


[sweep-options])

Arg Types: profile wire-body | face | edge

path wire-body | edge

distance real

vector gvector

axis position . vector

sweep-options Sweep_Options

Returns: entity

Errors: An error is reported if the result of the sweep operation is incomplete lateral faces or invalid topology.

Description: The sweep:law extension creates a sheet body or solid body from a profile and a path. The path can be defined as a path, a distance, a vector, or an axis (position and vector).


The argument profile is a pointer to a wire-body, a face, or an edge, which in turn, defines the sweep geometry and becomes the base of the solid or the edge of the surface.


The argument path is a wire-body or an edge along which the profile is swept. path can be defined as a distance if profile is a planar face. path can be defined as a vector if rail_law is used (no twist). path can be defined as a axis (defined as position and vector) if rail_law is used (no twist).


The distance argument defines the distance to sweep along the face normal.


The vector argument defines the direction and distance to sweep.


The axis argument is a position and vector that defines the axis to revolve around. The amount to revolve is controlled by the sweep:angle option.


sweep-options is an optional argument that contains the Sweep_Options data structure. This data structure is created by sweep:options. If sweep-options is not specified, default sweep option values are used. The defaults are as follows:


- Create a solid.

- Draft angle is 0.

- Gap type is 2 (natural).

- Twist angle is 0.

- Rail law is minimum rotation.


If you set the option sweep_selfint to TRUE, the code checks to see if the sweep path intersects itself. If it does, the sweep errors out. But, it allows the sweep path to intersect with the original body and that causes self_intersections.


The sweep:law extension is complicated, but not difficult. We have presented, explained, and provided examples for a variety of scenarios and option combinations to get you started, but can not provide every one. There are also some that will simply fail (causes self-intersections). It is up to you to experiment and explore whatever remaining scenarios and option combinations you can design.


Numerous additional sweep:law Scheme examples are provided in the theory chapter.

Example: ; sweep:law - Example 1

; Sweeping an edge along a vector

(define edge1 (edge:linear (position 10 0 0)


(position 10 10 0)))

;; edge1

; OUTPUT Original


(define sweep1 (sweep:law edge1 (gvector 0 0 10)))

;; sweep1

; Convert the single-sided entity into double-sided.

(define 2dconvert (sheet:2d sweep1))

;; 2dconvert

; OUTPUT Result



Figure 2-4. sweep:law - Example 1 - Sweep an edge along a Vector


; sweep:law - Example 2

; Sweeping a face a distance

(part:clear)

;; #t

(define face2 (face:plane (position 0 20 0)


10 10 (gvector 0 0 1)))

;; face2

; OUTPUT Original


(define sweep3 (sweep:law face2 5))

;; sweep3

; OUTPUT Result



Figure 2-5. sweep:law - Example 2 - Sweep a Face


; sweep:law - Example 3

; Revolving a face.

(part:clear)

;; #t

; Create a solid block.

(define block1 (solid:block (position -10 -10 0)


(position 25 25 25)))

;; block1

; Separate faces from block1.

(define entities (entity:faces block1))

;; entities

; Extract a single planar face.

(define face1 (car (cdr (cdr entities))))

;; face1

; Verify transform applied.

(define fix (entity:fix-transform block1))

;; fix

; OUTPUT Original


; Define extent of sweep.

(define opts (sweep:options "sweep_angle" 60))

;; opts

; Revolve the planar face by a gvector around a

; position.

(define sweep1 (sweep:law face1


(position -10 -10 -10)


(gvector 1 0 0) opts))

;; sweep1

; OUTPUT Result



Figure 2-6. sweep:law - Example 3 - Revolving a Face


; sweep:law - Example 4

; Revolving a wire.

(part:clear)

;; #t

; Create 4 linear edges.

(define edge1 (edge:linear (position 0 0 0)


(position 20 0 0)))

;; edge1

(define edge2 (edge:linear (position 20 0 0)


(position 20 20 0)))

;; edge2

(define edge3 (edge:linear (position 20 20 0)


(position 0 20 0)))

;; edge3

(define edge4 (edge:linear (position 0 20 0)


(position 0 0 0)))

;; edge4

; Create a wirebody from the 4 edges.

(define wirebody (wire-body


(list edge1 edge2 edge3 edge4)))

;; wirebody

; 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)))

;; sweep1

; OUTPUT Result



Figure 2-7. sweep:law - Example 4 - Revolving a Wire


; sweep:law - Example 5

; Sweeping a Planar Face.

(part:clear)

;; #t

; Create a solid block.

(define block1 (solid:block (position -10 -10 -10)


(position 30 30 30)))

;; block1

; Get a list of the solid block's faces.

(define faces (entity:faces block1))

;; faces

; Select a single face to sweep

(define face (car (cdr (cdr faces))))

;; face

; OUTPUT Original


; Create a new solid by sweeping the face along a

; gvector.

(define sweep1 (sweep:law face 7.5


(sweep:options "draft_angle" -45)))

;; sweep1

; OUTPUT Result



Figure 2-8. sweep:law - Example 5 - Sweeping a Planar Face
PDF/SWP/02SC.PDF
HTM/DATA/SWP/SWP/02SC/0005.HTM