# Copyright 2007 (c) Pointwise, Inc. # All rights reserved. # # This sample Gridgen script is not supported by Pointwise, Inc. # It is provided freely for demonstration purposes only. # SEE THE WARRANTY DISCLAIMER AT THE BOTTOM OF THIS FILE. # # Glyph script to swap domains in an unstructured block # It leaves the old block in place but builds a new block with the domains # listed in the variable, oldDoms, replaced with the domains listed in the # variable, newDoms. # # User must define the following variables before running the script: # myBlock - the block the domains will be substituted in # oldDoms - the domains you want to replace # newDoms - the domains to replace them with # set scriptDir [file dirname [info script]] set fname "SwapFaceDomains.out" set fullname [file join $scriptDir $fname] set fileID [open $fullname w] puts $fileID "Old domains to replace: $oldDoms" puts $fileID "New domains to add: $newDoms" set faces [gg::blkGetFace $myBlock] set faceNumber 0 foreach face $faces { # take old domains out of face list incr faceNumber puts $fileID "Face number $faceNumber" puts $fileID "Old face domains: $face" set faceCons [list] foreach dom $oldDoms { set ix [lsearch -exact $face $dom] if {$ix >= 0} { set face [lreplace $face $ix $ix] gg::domReport $dom diag REFERENCE set faceCons [concat $faceCons $diag(refCons)] } } # determine which new domains belong in this face # if a new domain has one connector in common with a domain removed from # this face, we'll say it belongs as a replacement in the face. foreach dom $newDoms { gg::domReport $dom diag REFERENCE set thisDomCons $diag(refCons) foreach con $thisDomCons { set ix [lsearch -exact $faceCons $con] if {$ix >= 0} { lappend face $dom break } } } lappend newFaces $face puts $fileID "New face domains: $face" } gg::blkBegin -type UNSTRUCTURED foreach face $newFaces { gg::faceBegin gg::faceAddDom $face gg::faceEnd } set newBlock [gg::blkEnd] # DISCLAIMER: # TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, POINTWISE DISCLAIMS # ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED # TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE, WITH REGARD TO THIS SCRIPT. TO THE MAXIMUM EXTENT PERMITTED # BY APPLICABLE LAW, IN NO EVENT SHALL POINTWISE BE LIABLE TO ANY PARTY # FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES # WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF # BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE # USE OF OR INABILITY TO USE THIS SCRIPT EVEN IF POINTWISE HAS BEEN # ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE # FAULT OR NEGLIGENCE OF POINTWISE.