• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Finding Perimeter of a shape/polygon?

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 143
  • Views 1800
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Finding Perimeter of a shape/polygon?

94d33m
94d33m over 4 years ago

I couldn't find any skillcode already available.....Is there any simple skill code for it?

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    Here's a newer version of my abArea code that you were using (I think the other excerpt you found was just part of the file) where I've restructured it slightly and added a function for computing the perimeter. As before, it's abArea(obj) for the area, and abPerimeter(obj) for the perimeter.

    Andrew

    /* abArea.il
    
    Author     A.D.Beckett
    Group      Structured Custom, Cadence Design Systems Ltd
    Machine    SUN
    Date       May 26, 1994 
    Modified   Mar 05, 2018 
    By         A.D.Beckett
    
    Functions for measuring the area of an object or a list
    of polygon points. Also now includes perimeter calculation
    too (restructured core function slightly in 1.3 to separate
    out area of polygon points; also removed old capacitance
    calculation functions as these only worked in 4.3.X)
    
    ***************************************************
    
    SCCS Info: @(#) abArea.il 03/05/18.11:15:34 1.3
    
    */
    
    
    /***************************************************************
    *                                                              *
    *                       (abArea object)                        *
    *                                                              *
    *               Calculate the area of an object.               *
    *      Currently only works with polygons and rectangles.      *
    *                                                              *
    ***************************************************************/
    
    (procedure (abArea object)
      (let (area corners ll ur dx dy)
        (case (dbGetq object objType)
          ("polygon"
           (setq area (abPolygonArea (dbGetq object points)))
           )
          ("rect"
           (setq corners (dbGetq object bBox))
           (setq ll (lowerLeft corners))
           (setq ur (upperRight corners))
           (setq dx (difference (xCoord ur) (xCoord ll)))
           (setq dy (difference (yCoord ur) (yCoord ll)))
           (setq area (times dx dy))
           )
          )
        area))
    
    /***************************************************************
    *                                                              *
    *                     (abPerimeter object)                     *
    *                                                              *
    *    Calculate the perimeter of an object. Only works with     *
    *                   polygons and rectangles.                   *
    *                                                              *
    ***************************************************************/
    
    (procedure (abPerimeter object)
      (let (perim bBox ll ur dx dy)
        (case (dbGetq object objType)
          ("polygon"
           (setq perim (abPolygonPerimeter (dbGetq object points)))
           )
          ("rect"
           (setq bBox (dbGetq object bBox))
           (setq ll (lowerLeft bBox))
           (setq ur (upperRight bBox))
           (setq dx (difference (xCoord ur) (xCoord ll)))
           (setq dy (difference (yCoord ur) (yCoord ll)))
           (setq perim (times 2 (plus dx dy)))
           )
          )
        perim))
    
    /***************************************************************
    *                                                              *
    *                  (abPolygonArea pointList)                   *
    *                                                              *
    *   Given a list of points in a polygon, calculate the area    *
    *         (effectively integrates around the polygon)          *
    *                                                              *
    ***************************************************************/
    
    (procedure (abPolygonArea pointList)
      (let ((sum 0) firstPt lastPt dx)
        (setq firstPt (setq lastPt (car pointList)))
        (foreach point (cdr pointList)
                 (setq dx (difference (xCoord point) (xCoord lastPt)))
                 (setq sum (plus sum 
                                 (times dx (plus (yCoord point) (yCoord lastPt)))))
                 (setq lastPt point))
        (setq sum (plus sum
                        (times (difference (xCoord firstPt) (xCoord lastPt))
                               (plus (yCoord firstPt) (yCoord lastPt)))))
        (times 0.5 (abs sum))
        ))
    
    /***************************************************************
    *                                                              *
    *                (abPolygonPerimeter pointList)                *
    *                                                              *
    * Given a list of points in a polygon, calculate the perimiter *
    *                                                              *
    ***************************************************************/
    
    (procedure (abPolygonPerimeter pointList)
      (let ((sum 0) firstPt lastPt)
        (setq firstPt (setq lastPt (car pointList)))
        (foreach point (cdr pointList)
                 (setq sum 
                       (plus sum 
                             (sqrt (plus
                                     (expt (difference (xCoord lastPt) (xCoord point)) 2.0)
                                     (expt (difference (yCoord lastPt) (yCoord point)) 2.0)
                                     ))))
                 (setq lastPt point))
        (setq sum (plus sum
                        (sqrt (plus
                                (expt (difference (xCoord lastPt) (xCoord firstPt)) 2.0)
                                (expt (difference (yCoord lastPt) (yCoord firstPt)) 2.0)
                                ))))
        sum
        ))
    
    /*****************************************************************
    *                                                                *
    *                (abGetOverlapTransform overlap)                 *
    *                                                                *
    * Get the transform needed to transform the shape in the overlap *
    *           into the current cell's coordinate system            *
    *                                                                *
    *****************************************************************/
    
    (procedure (abGetOverlapTransform overlap)
      (let (transform)
           (if (listp overlap)
               (setq transform (dbConcatTransform 
                                (abGetOverlapTransform (cadr overlap))
                                (or
                                  (dbGetq (car overlap) transform)
                                  (list (dbGetq (car overlap) origin)
                                        (dbGetq (car overlap) orient)
                                        1.0)
                                  )
                                ))
               (setq transform (list 0:0 "R0" 1.0)))
           transform
           ))
    
    /***************************************************************
    *                                                              *
    *                 (abGetOverlapShape overlap)                  *
    *                                                              *
    *         get hold of the actual shape in the overlap          *
    *                                                              *
    ***************************************************************/
    
    (procedure (abGetOverlapShape overlap)
      (if (listp overlap)
          (abGetOverlapShape (cadr overlap))
          overlap))
    
    /***************************************************************
    *                                                              *
    *             (abDoesOverlapContainMosaic overlap)             *
    *                                                              *
    *       Check to see whether anything down the hierarchy       *
    *          is a mosaic - 'cos it won't work if it is.          *
    *                                                              *
    ***************************************************************/
    
    (procedure (abDoesOverlapContainMosaic overlap)
      (if (listp overlap)
          (if (equal (dbGetq (car overlap) objType) "mosaicInst")
              t
              (abDoesOverlapContainMosaic (cadr overlap)))
          nil))
    
    /***************************************************************
    *                                                              *
    *        (abCopyOverlapsToScratch cellView overlapList)        *
    *                                                              *
    *     Copy the overlaps into the scratch layout, returning     *
    *                  a list of the new objects                   *
    *                                                              *
    ***************************************************************/
    
    (procedure (abCopyOverlapsToScratch cellView overlapList)
      (let (objects)
           (foreach overlap overlapList
                    (unless (abDoesOverlapContainMosaic overlap)
                            (setq objects
                                  (cons (dbCopyFig (abGetOverlapShape overlap)
                                                   cellView
                                                   (abGetOverlapTransform overlap))
                                        objects))))
           objects))
    

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information