• 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. Any known limitations of geIsPointInsidePolygon or CCSP...

Stats

  • Replies 11
  • Subscribers 142
  • Views 274
  • Members are here 0

Any known limitations of geIsPointInsidePolygon or CCSPointInPolygon

RK56
RK56 11 hours ago

Hi,

I'm trying to find if a point is inside a polygon as shown in the image below.  Both the functions (geIsPointInsidePolygon & CCSPointInPolygon) fail to test correctly the pink locations in the image for inside. To check if it is due to the polygon, I chopped the lower half to simplify and then the functions test correctly. While I can infer that such complicated polygons are not supported, I could not find what kind of polygons are acceptable.

Can someone here help me to find?

I'm using IC23.1-64b Version of Virtusos

Thanks

Ram

  • Cancel
  • Sign in to reply
Parents
  • Andrew Beckett
    Andrew Beckett 11 hours ago

    Ram,

    Could you please select the polygon and then report:

    sstatus(fullPrecision t)
    car(geGetSelSet())~>points

    and then give me some test coordinates that are failing when you call these functions? Then I can check.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • RK56
    RK56 10 hours ago in reply to Andrew Beckett

    Andrew,

    Edited. Thanks for the quick reply. The test points and point list are here,


    Test points along top side 45deg bend: 

    (147.83275 61.66425)
    (149.03275 62.86425)
    (150.23275 64.06425)
    (151.43275 65.26425)
    (144.23275 58.06425)
    (145.43275 59.26425)
    (146.63275 60.46425)

    -------------------------------

    (149.59675 57.50025)
    (150.79675 58.70025)
    (151.99675 59.90025)
    (153.19675 61.10025)
    (148.39675 56.30025)

    Test points along bottom side 45deg bend: 

    (185.03275 24.46425)
    (186.23275 25.66425)
    (187.43275 26.86425)
    (188.63275 28.06425)
    (189.83275 29.26425)

    -------------------------------

    (186.79675 20.30025)
    (187.99675 21.50025)
    (189.19675 22.70025)
    (190.39675 23.90025)
    (191.59675 25.10025)
    (192.79675 26.30025)
    (193.99675 27.50025)
    (195.19675 28.70025)

    ----------------------------------

    Polygon point List :

    ((233.67275 14.102)
    (228.383 19.39175)
    (228.383 19.392)
    (227.54725 20.22775)
    (212.85375 20.22775)
    (212.85375 63.55375)
    (201.39925 75.00825)
    (146.05125 75.00825)
    (134.59675 63.55375)
    (134.59675 21.37575)
    (145.3065 10.666)
    (151.389 10.666)
    (151.389 -2.193)
    (150.116 -2.193)
    (150.116 -5.793)
    (155.889 -5.793)
    (155.889 15.166)
    (147.1705 15.166)
    (139.09675 23.23975)
    (139.09675 61.68975)
    (147.91525 70.50825)
    (199.53525 70.50825)
    (208.35375 61.68975)
    (208.35375 20.22775)
    (206.8675 20.22775)
    (203.88175 23.2135)
    (203.88175 55.58575)
    (193.36275 66.10475)
    (151.99375 66.10475)
    (143.7225 57.8335)
    (143.7225 25.2195)
    (149.21625 19.72575)
    (166.40625 19.72575)
    (182.24875 3.88325)
    (182.24875 -9.99775)
    (186.74875 -9.99775)
    (186.74875 -4.4025)
    (186.752 -4.4025)
    (186.752 0.516)
    (186.74875 0.516)
    (186.74875 5.74725)
    (172.77025 19.72575)
    (186.35625 19.72575)
    (195.38175 28.75125)
    (195.38175 49.2185)
    (190.88175 53.7185)
    (190.88175 30.61525)
    (184.49225 24.22575)
    (168.27025 24.22575)
    (165.2225 27.2735)
    (165.2225 28.16)
    (181.5675 28.16)
    (186.88175 33.47425)
    (186.88175 43.50575)
    (182.38175 48.00575)
    (182.38175 35.33825)
    (179.7035 32.66)
    (165.2225 32.66)
    (165.2225 42.469)
    (167.35825 44.60475)
    (179.41875 44.60475)
    (182.38175 41.64175)
    (182.38175 48.00575)
    (181.28275 49.10475)
    (165.49425 49.10475)
    (160.7225 44.333)
    (160.7225 32.66)
    (158.546 32.66)
    (156.7225 34.4835)
    (156.7225 49.57775)
    (160.2495 53.10475)
    (185.1315 53.10475)
    (190.88175 47.3545)
    (190.88175 53.7185)
    (186.9955 57.60475)
    (158.3855 57.60475)
    (152.2225 51.44175)
    (152.2225 32.6195)
    (156.682 28.16)
    (160.7225 28.16)
    (160.7225 25.4095)
    (161.90625 24.22575)
    (151.08025 24.22575)
    (148.2225 27.0835)
    (148.2225 55.9695)
    (153.85775 61.60475)
    (191.49875 61.60475)
    (199.38175 53.72175)
    (199.38175 21.3495)
    (205.0035 15.72775)
    (208.35375 15.72775)
    (208.35375 15.7245)
    (212.85375 15.7245)
    (212.85375 15.72775)
    (226.39 15.72775)
    (229.67275 12.445)
    (229.67275 8.69725)
    (233.67275 8.69725)
    )

    ---x---x---x----

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • RK56
    RK56 10 hours ago in reply to Andrew Beckett

    Andrew,

    Edited. Thanks for the quick reply. The test points and point list are here,


    Test points along top side 45deg bend: 

    (147.83275 61.66425)
    (149.03275 62.86425)
    (150.23275 64.06425)
    (151.43275 65.26425)
    (144.23275 58.06425)
    (145.43275 59.26425)
    (146.63275 60.46425)

    -------------------------------

    (149.59675 57.50025)
    (150.79675 58.70025)
    (151.99675 59.90025)
    (153.19675 61.10025)
    (148.39675 56.30025)

    Test points along bottom side 45deg bend: 

    (185.03275 24.46425)
    (186.23275 25.66425)
    (187.43275 26.86425)
    (188.63275 28.06425)
    (189.83275 29.26425)

    -------------------------------

    (186.79675 20.30025)
    (187.99675 21.50025)
    (189.19675 22.70025)
    (190.39675 23.90025)
    (191.59675 25.10025)
    (192.79675 26.30025)
    (193.99675 27.50025)
    (195.19675 28.70025)

    ----------------------------------

    Polygon point List :

    ((233.67275 14.102)
    (228.383 19.39175)
    (228.383 19.392)
    (227.54725 20.22775)
    (212.85375 20.22775)
    (212.85375 63.55375)
    (201.39925 75.00825)
    (146.05125 75.00825)
    (134.59675 63.55375)
    (134.59675 21.37575)
    (145.3065 10.666)
    (151.389 10.666)
    (151.389 -2.193)
    (150.116 -2.193)
    (150.116 -5.793)
    (155.889 -5.793)
    (155.889 15.166)
    (147.1705 15.166)
    (139.09675 23.23975)
    (139.09675 61.68975)
    (147.91525 70.50825)
    (199.53525 70.50825)
    (208.35375 61.68975)
    (208.35375 20.22775)
    (206.8675 20.22775)
    (203.88175 23.2135)
    (203.88175 55.58575)
    (193.36275 66.10475)
    (151.99375 66.10475)
    (143.7225 57.8335)
    (143.7225 25.2195)
    (149.21625 19.72575)
    (166.40625 19.72575)
    (182.24875 3.88325)
    (182.24875 -9.99775)
    (186.74875 -9.99775)
    (186.74875 -4.4025)
    (186.752 -4.4025)
    (186.752 0.516)
    (186.74875 0.516)
    (186.74875 5.74725)
    (172.77025 19.72575)
    (186.35625 19.72575)
    (195.38175 28.75125)
    (195.38175 49.2185)
    (190.88175 53.7185)
    (190.88175 30.61525)
    (184.49225 24.22575)
    (168.27025 24.22575)
    (165.2225 27.2735)
    (165.2225 28.16)
    (181.5675 28.16)
    (186.88175 33.47425)
    (186.88175 43.50575)
    (182.38175 48.00575)
    (182.38175 35.33825)
    (179.7035 32.66)
    (165.2225 32.66)
    (165.2225 42.469)
    (167.35825 44.60475)
    (179.41875 44.60475)
    (182.38175 41.64175)
    (182.38175 48.00575)
    (181.28275 49.10475)
    (165.49425 49.10475)
    (160.7225 44.333)
    (160.7225 32.66)
    (158.546 32.66)
    (156.7225 34.4835)
    (156.7225 49.57775)
    (160.2495 53.10475)
    (185.1315 53.10475)
    (190.88175 47.3545)
    (190.88175 53.7185)
    (186.9955 57.60475)
    (158.3855 57.60475)
    (152.2225 51.44175)
    (152.2225 32.6195)
    (156.682 28.16)
    (160.7225 28.16)
    (160.7225 25.4095)
    (161.90625 24.22575)
    (151.08025 24.22575)
    (148.2225 27.0835)
    (148.2225 55.9695)
    (153.85775 61.60475)
    (191.49875 61.60475)
    (199.38175 53.72175)
    (199.38175 21.3495)
    (205.0035 15.72775)
    (208.35375 15.72775)
    (208.35375 15.7245)
    (212.85375 15.7245)
    (212.85375 15.72775)
    (226.39 15.72775)
    (229.67275 12.445)
    (229.67275 8.69725)
    (233.67275 8.69725)
    )

    ---x---x---x----

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • Andrew Beckett
    Andrew Beckett 10 hours ago in reply to RK56

    First of all, what is the DBUPerUU in your technology? You can find this with geGetEditCellView()~>DBUPerUU . Based on the resolution of the coordinates you showed, it's probably 20000 (which is pretty fine resolution - this is unusual - maybe it's finer than that in your case?).

    I then used this code to construct a new shape (adjust the layer names as you see fit) and to create "dot" objects either on Via2 (orange) or Via3 (purple) if inside or outside (respectively) the polygon. I added an extra point outside just to be sure.

    ptlist='((233.67275 14.102)
    (228.383 19.39175)
    (228.383 19.392)
    (227.54725 20.22775)
    (212.85375 20.22775)
    (212.85375 63.55375)
    (201.39925 75.00825)
    (146.05125 75.00825)
    (134.59675 63.55375)
    (134.59675 21.37575)
    (145.3065 10.666)
    (151.389 10.666)
    (151.389 -2.193)
    (150.116 -2.193)
    (150.116 -5.793)
    (155.889 -5.793)
    (155.889 15.166)
    (147.1705 15.166)
    (139.09675 23.23975)
    (139.09675 61.68975)
    (147.91525 70.50825)
    (199.53525 70.50825)
    (208.35375 61.68975)
    (208.35375 20.22775)
    (206.8675 20.22775)
    (203.88175 23.2135)
    (203.88175 55.58575)
    (193.36275 66.10475)
    (151.99375 66.10475)
    (143.7225 57.8335)
    (143.7225 25.2195)
    (149.21625 19.72575)
    (166.40625 19.72575)
    (182.24875 3.88325)
    (182.24875 -9.99775)
    (186.74875 -9.99775)
    (186.74875 -4.4025)
    (186.752 -4.4025)
    (186.752 0.516)
    (186.74875 0.516)
    (186.74875 5.74725)
    (172.77025 19.72575)
    (186.35625 19.72575)
    (195.38175 28.75125)
    (195.38175 49.2185)
    (190.88175 53.7185)
    (190.88175 30.61525)
    (184.49225 24.22575)
    (168.27025 24.22575)
    (165.2225 27.2735)
    (165.2225 28.16)
    (181.5675 28.16)
    (186.88175 33.47425)
    (186.88175 43.50575)
    (182.38175 48.00575)
    (182.38175 35.33825)
    (179.7035 32.66)
    (165.2225 32.66)
    (165.2225 42.469)
    (167.35825 44.60475)
    (179.41875 44.60475)
    (182.38175 41.64175)
    (182.38175 48.00575)
    (181.28275 49.10475)
    (165.49425 49.10475)
    (160.7225 44.333)
    (160.7225 32.66)
    (158.546 32.66)
    (156.7225 34.4835)
    (156.7225 49.57775)
    (160.2495 53.10475)
    (185.1315 53.10475)
    (190.88175 47.3545)
    (190.88175 53.7185)
    (186.9955 57.60475)
    (158.3855 57.60475)
    (152.2225 51.44175)
    (152.2225 32.6195)
    (156.682 28.16)
    (160.7225 28.16)
    (160.7225 25.4095)
    (161.90625 24.22575)
    (151.08025 24.22575)
    (148.2225 27.0835)
    (148.2225 55.9695)
    (153.85775 61.60475)
    (191.49875 61.60475)
    (199.38175 53.72175)
    (199.38175 21.3495)
    (205.0035 15.72775)
    (208.35375 15.72775)
    (208.35375 15.7245)
    (212.85375 15.7245)
    (212.85375 15.72775)
    (226.39 15.72775)
    (229.67275 12.445)
    (229.67275 8.69725)
    (233.67275 8.69725)
    )
    
    polygon=dbCreatePolygon(geGetEditCellView() "Poly" ptlist)
    
    testPoints='(
    (147.83275 61.66425)
    (149.03275 62.86425)
    (150.23275 64.06425)
    (151.43275 65.26425)
    (144.23275 58.06425)
    (145.43275 59.26425)
    (146.63275 60.46425)
    (149.59675 57.50025)
    (150.79675 58.70025)
    (151.99675 59.90025)
    (153.19675 61.10025)
    (148.39675 56.30025)
    ; bottom side 45 deg bend
    (185.03275 24.46425)
    (186.23275 25.66425)
    (187.43275 26.86425)
    (188.63275 28.06425)
    (189.83275 29.26425)
    (186.79675 20.30025)
    (187.99675 21.50025)
    (189.19675 22.70025)
    (190.39675 23.90025)
    (191.59675 25.10025)
    (192.79675 26.30025)
    (193.99675 27.50025)
    (195.19675 28.70025)
    ; extra point just to check code (this is outside)
    (147.58 61.91)
    )
    
    let((inside (cv geGetEditCellView()))
      foreach(pt testPoints
        ; works OK for me too
        inside=CCSpointInPolygon(pt polygon~>points)
        ; works with t or nil as last argument
        ;inside=geIsPointInsidePolygon(cv pt polygon~>points t)
        dbCreateDot(cv if(inside "Via2" "Via3") pt)
      )
    )

    The dots will be shown by using Options→Display and turning on "Dot Pins". Then I get:

    Zoomed in:

    This is all behaving as I'd expect. This gives the same results whether I use CCSpointInPolygon (which I wrote) or geIsPointInsidePolygon.

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • RK56
    RK56 7 hours ago in reply to Andrew Beckett

    This returns 4000.0 for my database. It is not 20000 as you guessed. How is the DBUU is related to the problem?

    Your script produces same result as you mentioned. I wonder why


    I will add more details to what I'm doing. You can mention if any of these prior steps cause this. I have these smaller rectangles in layout which are created through script. I test all the four corners of the rectangle of the rectangle for inside of the polygon.

    procedure(testInside(shapeBBox region @optional (check t))
       forall(pt bBoxToPolygonPts(shapeBBox check) CCSpointInPolygon(pt region))
    )

    procedure(bBoxToPolygonPts(bBox @optional (check t))
       case(check
          ("centerBox" list(centerBox(bBox)))
          ("lowerLeft" list(lowerLeft(bBox)))
          ("upperRight" list(upperRight(bBox)))
          (t list(lowerLeft(bBox) rightEdge(bBox):bottomEdge(bBox) upperRight(bBox) leftEdge(bBox):topEdge(bBox)) )
          (nil printf("Valid options are centerBox, lowerLeft, upperRight or t\n"))
       )
    )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Aurel B
    Aurel B 7 hours ago in reply to RK56

    Are you checking the vertices of those rectangles or the points defined by their bBox?

    This is just a guess, but if you are using the bBox edges, some corners would appear as inside the polygon.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 7 hours ago in reply to RK56
    RK56 said:
    This returns 4000.0 for my database. It is not 20000 as you guessed. How is the DBUU is related to the problem?

    Apologies - I didn't notice that all your points would work with 4000 as the DBUperUU (i.e. they are all multiples of 0.00025 rather than 0.00005). I was trying to imagine what might make a difference - anyway, it's not this, it seems.

    RK56 said:
    I have these smaller rectangles in layout which are created through script. I test all the four corners of the rectangle of the rectangle for inside of the polygon.

    In that case, I'd need to know how these rectangles are created - how big are they (as your code doesn't show that part)? If they are big enough, maybe one of the points is outside of the polygon...

    In my example I am just checking the points as you gave them, not four additional points derived from the points you specified.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • RK56
    RK56 7 hours ago in reply to Aurel B
    Aurel B said:

    Are you checking the vertices of those rectangles or the points defined by their bBox?

    I have a bBoxToPolygonPts function to take all 4 vertices of the rectangle.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Aurel B
    Aurel B 7 hours ago in reply to RK56

    My bad, I thought the diamonds from the picture were the rectangles and thus their bbox would be bigger than the polygons.

    Then, as Andrew said, if you don't detail the rectangles, it's hard to understand what's going on.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 7 hours ago in reply to Aurel B
    Aurel B said:
    My bad, I thought the diamonds from the picture were the rectangles and thus their bbox would be bigger than the polygons.

    In fact the diamonds were from my pictures (because I was using "dot" objects). Looking again at Ram's original screenshot, you can clearly see that the rectangles straddle the edges and hence it's hardly surprising that a check that is checking that all four vertices are within the polygon will return false. This must be because the rectangles are large enough to straddle the edge.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • RK56
    RK56 7 hours ago in reply to Aurel B

    Apologies Andrew and Aurel. I had overlooked the "forall" behavior.  Forall returns AND of all test results which I knew, but I used it for a case where any 4 vertices should not overlap the polygon.

    A peer review would have helped. You guys became my peer. Thanks a lot and sorry again.

    PS: Before posting here, I did some coordinate-based test and convinced myself that there is a problem. Now I cannot reproduce.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Aurel B
    Aurel B 7 hours ago in reply to RK56

    Another solution that might work as well is to use ABE functions (boolean operations).

    You can build ABE layers using abeLayerFromCellView to get all shapes from a layer in a cell view.

    Or you can use abeNewLayer and abeLayerOrPtArray to create a layer from polygons.

    Then you can use abeLayerInside (you can also do many other checks: abeLayerAndNot, abeLayerXor, ...)

    Then you just have to check if the resulting layer area is 0.

    It might be easier to debug, as you can always display the result of any generated layer into a highlight set.

    It requires some ABE knowledge and to write a bit of of wrapping code but it's definitely worth it.

    Be aware that it is limited to 45° angles (which seems to be OK in your case)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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