Tweak Faces

From DocR25

Jump to: navigation, search


Tweak Face(s)

The Tweak Face functionality essentially replaces a face's surface with a tool surface that you have applied. Specific faces can be selected, or an array of faces. In this example, the top face of the wiggle is tweaked to the red planar tool surface.

Scheme Example
; --- make the main body
(define wiggle (solid:wiggle 40 40 40 1 -1 2 -2))
; --- make the tool surface
(define tool_face (face:plane (position -10 -10 22) 20 20 (gvector 0 0 1)))
(entity:set-color tool_face RED)
; --- define the face to be tweaked
(define tweak_face (list-ref (entity:faces wiggle) 0))
(entity:set-color tweak_face BLUE)
; --- do the tweak
(lop:tweak-faces tweak_face tool_face #f)
; --- delete the tool surface
(entity:delete tool_face)

Pre-specifying Laminar Edges and Tangent Vertices

The example below shows how to replace an existing laminar edge with a new curve. Care must be taken, that the original curve has the same direction as the tool curve. If the new curve is going to be tangent to its neighboring curves, it can cause problems for the tweak algorithm as is the case in the second example. New locations for changing vertices are generally found by doing either a series of curve surface intersections or curve curve intersections. Calling curve curve intersections on two tangent curves can produce bad results, therefore it is better to pre-specify the two tangent vertices as shown in the Scheme script.

(define sb (sheet:face (face:plane (position -10 -10 0) 20 20 (gvector 0 0 1))))
;; sb
(define tweakface (car (entity:faces sb)))
;; tweakface
(define toolface (face:plane (position -20 -20 0) 60 40 (gvector 0 0 1)))
;; toolface
(ray:queue 35.8781 -49.8533 36.6788 -0.373806 0.756287 -0.536935 1)
(define tweakedge (pick-edge))
;; tweakedge
(define w (wire-body (edge:linear (position 30 -15 0) (position 30 15 0))))
;; w
(define tooledge (car (entity:edges w)))
;; tooledge
(lop:tweak-faces-edges-vertices tweakface toolface #f tweakedge tooledge)
Before Tweak
After Tweak
(define sb (sheet:face (face:plane (position -10 -10 0) 20 20 (gvector 0 0 1))))
(define tweakface (car (entity:faces sb)))
;; tweakface
(define toolface (face:plane (position -20 -20 0) 40 40 (gvector 0 0 1)))
;; toolface
(ray:queue 20.2999 26.6592 15.9911 -0.622594 -0.568422 -0.537841 1)
(define tweakedge (pick-edge))
;; tweakedge
(define w (wire-body (edge:spline (list (position 10 10 0) (position -10 10 0))(gvector 0.1 10 0) (gvector 0.1 -10 0))))
(define tooledge (car (entity:edges w)))
;; tooledge
(ray:queue 13.0005 30.8592 20.0019 -0.622594 -0.568422 -0.537841 1)
(define vert1 (pick-vertex))
(ray:queue 25.1584 23.9329 13.2484 -0.622594 -0.568422 -0.537841 1)
(define vert2 (pick-vertex))
(define vertlist (list vert1 vert2))
;; vertlist
(define toolvert1 (vertex:from-position (vertex:position vert1)))
(define toolvert2 (vertex:from-position (vertex:position vert2)))
(define toolvertlist (list toolvert1 toolvert2))
;; toolvertlist
(lop:tweak-faces-edges-vertices tweakface toolface #f tweakedge tooledge vertlist toolvertlist)
Before Tweak
After Tweak

Tweak Faces and Surface Extensions

In order to successfully complete a Tweak operation, you may need to extend the surfaces to be tweaked. Tweak will not do this for you; it is your responsibility to ensure the surfaces are large enough by calling api_tweak_extend_faces before calling api_tweak_faces. The Scheme command lop:tweak-faces-extend is an implementation of the tweak faces functionality which first calls the extension API.

Tweak Faces Interface

api_tweak_faces has two signatures. The primary signature for api_tweak_faces takes a list of tweak faces and corresponding list of tools surfaces as input. This interface also takes, in addition to the tweak faces and tool surfaces, a list of reverse bits for the surfaces and a general 3D bounding box for the intersection calculations. The bounding box has a default which equates to model space. A secondary signature for api_tweak_faces allows you to specify edge and vertex solutions in the case in which the tool surface meets tangentially with any of the tweak face's neighboring surfaces (effectively causing a near tangent surface / surface intersection).

C++ Scheme Description
api_tweak_faces lop:tweak-faces Tweaks the specified face(s) to the tool surface(s).
api_tweak_faces lop:tweak-faces-edges-vertices Tweaks the specified face(s) to the tool surface(s) with edge and vertex solutions given by the caller.
api_tweak_extend_faces lop:tweak-extend-faces Extend lateral surfaces as necessary for a tweak operation; however, no tweak operation is performed.
lop_options lop:options Controls the behavior of Local Operations.

Note: lop:tweak-faces-extend is a Scheme command which first extends the surfaces and then performs the tweak and is not to be confused with lop:tweak-extend-faces which only extends the surfaces.

An alternative interface allows you to perform an interactive tweak faces operation. Using this interface you may select one of multiple solutions for a given edge. The API functions and Scheme extensions corresponding to the four stages of an interactive operation are listed below.

C++ Scheme Description
api_tweak_faces_init lop:tweak-faces-init Performs the initial stage of a tweak operation in which attributes are added to edges.
api_tweak_query_edge_solutions lop:tweak-query-edge-solutions Allows you to obtain a list of the possible solutions for a given edge.
api_tweak_pick_edge_solution lop:tweak-pick-edge-solution Allows you to specify which of the multiple solutions for the given edge the tweak operation will use.
api_tweak_faces lop:tweak-faces Completes the tweak operation.


Main article: Limitations of Local Operations

Various limitations exist with the Tweak operation.

Topology Changes

Main article: Topology Changes in Local Operations

The Tweak operation is capable of handling a wide variety of topology changes.

Error Codes

Main article: Tweak Operation Error Codes

Refer to the main article for a list of Tweak operation error codes and their descriptions.


Personal tools