Using CGAL for robust planar geometry processing in

Download Report

Transcript Using CGAL for robust planar geometry processing in

Using CGAL
for robust planar
geometry processing
in Agilent ADS
3rd CGAL User Workshop
Nancy, France
Agilent EEsof EDA
Michiel De Wilde
March 17, 2008
Page 1
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Agilent Technologies:
the world’s premier measurement company
$5.4 billion annual revenue
19,100 employees
Customers in 110+ countries
60+ year heritage of
invention and innovation
Page 2
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Agilent’s Core Technologies
Life Sciences/Chemical Analysis
Communications/Electronics
• Measurement science
• Electronic circuit and systems design
• Applications software and solutions integration
• Radio frequency/microwave/wireless
simulation and test
• Digital design validation and test
• Wireline and mobile network analysis
• General purpose instrumentation
• Parametric test solutions
• Manufacturing test solutions
• OSS customer, service and network assurance
•
•
•
•
•
•
•
•
•
Liquid chromatography
Gas chromatography
Mass spectrometry
Atomic force microscopy
Microfluidics
Microarrays
Reagents chemistry
LC and GC columns
Software and informatics
Agilent Laboratories
Page 3
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Agilent EEsof EDA:
Design solutions for high-frequency electronics
Mission: to provide EM modeling solutions tuned to solve
complex physical design challenges in high frequency
electronics.
MMIC
RF SiP
Page 4
RFIC
RF Board
3D
SI
Antenna modeling
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Advanced Design System (ADS)
Advanced Design
System (ADS) is the
industry leader in highfrequency design.
• Multilayer planar layout
– Electromagnetic field
simulation
– Layout verification
• Schematic
– Schematic capture
– Frequency- and
time-domain
circuit simulation
Page 5
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Overview
• Introduction to Agilent ADS
• Using CGAL for
– robust polygon Boolean operations
– layout preprocessing for EM simulation
• Cost of exact arithmetic
• Conclusions
Page 6
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Boolean polygon operations
In ADS, polygon Boolean operations are used to combine
polygons in various ways. Some examples:
Two polygons
Union
Intersection Difference
Symmetric
difference
These are fundamental operations for many operations in ADS,
ranging from layout translation to meshing for EM simulations.
It is critical that they be 100% reliable.
Page 7
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Problems with polygon Boolean operations
Over time we have used 6 different sweep line algorithms
• None of them operated correctly in all cases
• All of them used double-precision floating point coordinates
• In degenerate situations, inside-outside calculations can go wrong
• Degenerate situations are easily detected, but very hard to solve
Observable results: crashes, inverted/disappeared layout
Page 8
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Almost degenerate layout arises often
• Artifacts generated by export & import
• (Nearly) adjoining shapes
Page 9
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Boolean polygon operations with CGAL
Coordinates are exact rational numbers
• Polygon operations are exact
• Correct results even in degenerate cases: they can be solved exactly
Easy-to-use interface for regularized Boolean operations
involving
Simple polygons
Page 10
Simple polygons
with holes
Sets of simple polygons
with holes
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Remaining problems
• What to do with self-intersecting
polygons? CGAL does not
accept them as-is.
(green example)
• How to go back to a fixedresolution representation?
(red result)
Page 11
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Resolving self-intersecting polygons
• A point is “inside” depending on the
number of CCW turns the oriented
boundary makes around the point.
1
e.g. nonzero winding is “in”
1
1
• Efficiently calculating the winding
number of all closed faces?
 use CGAL arrangements
2
0
1
1
Number of counterclockwise turns
Page 12
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Behind the scenes of polygon operations:
CGAL arrangements
v1
• Arrangements provide topological
navigation within a set of nonintersecting curves (segments)
v2
he1
• Primitives:
v3
f5
– Vertices
v7
v6
f1
f6
• Incremental changes are fast
(e.g. adding/removing a single edge)
v9
Page 13
v5
v4
f4
f2
– Halfedges
– Faces
f3
v8
f7
v10
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Resolving self-intersecting polygons using
arrangements
• Store with each edge the
incremental winding contribution
(each arrow is a “+1 CCW”)
f3:?
f3:1
• Store with each face the total
number of CCW turns
• CGAL and its Boost Graph library
support allows visiting all faces
with a tree starting from f1
• Remove non-boundary edges
• Conversion to CGAL’s polygon
set is then straightforward
Page 14
f4:1
f4:?
f2:1
f2:?
f5:2
f5:?
f2:1
f1:0
f6:?
f6:1
f7:1
f7:?
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Advanced examples of polygon resolution
Page 15
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Remaining problems
• What to do with self-intersecting
polygons? CGAL does not
accept them as-is.
(green example)
• How to go back to a fixedresolution representation?
(red result)
Page 16
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
How to go back to a fixed-resolution
representation?
Trivial solution: snap all segment endpoints to a fixed grid
This won’t work: it can lead to new intersections
off-grid
on-grid
(grid points are at the center of the boxes)
Page 17
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
CGAL support for fixed resolution arrangements
CGAL 2D snap rounding package:
• Smart snapping of segment endpoints to the grid
• No off-grid intersections in the end result [Hobby, 99]
(picture from
CGAL’s manual)
Arrangement
before snap
rounding
Page 18
Arrangement
after snap
rounding
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Using snap rounding for polygons
• Closeby segments become (partly) identical after snapping
– Merge the incremental winding contributions of the original segments
– Use the resolution procedure again to get the final polygon set
off-grid polygon set
Page 19
on-grid polygon set
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Overview
• Introduction to Agilent ADS
• Using CGAL for
– robust polygon Boolean operations
– layout preprocessing for EM simulation
• Cost of exact arithmetic
• Conclusions
Page 20
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Momentum 3D-Planar Electromagnetic Simulator
Physical Structure
z
Air
3D planar
metallization
H(r)
multilayered medium
Layer [1]
e1 , m1 , s1
Layer [2]
e 2 , m 2 , s 2 h2
Layer [3]
e 3 , m 3 , s3
E(r)
source
Port 1
h1
h3
Gnd
source
w
load
[S]
Js(r)
Port 2
load
S-parameters
Your “Virtual Network
Analyzer”
Page 21
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Geometric manipulations for EM simulation
2D layout view
3D view
• All metallic shapes need to be meshed
• Layout preprocessing: on each layer
– The layout contains very many independent shapes (often with overlap)
– We need to combine them into one topology
– To this end, construct a CGAL arrangement of all these shapes
Page 22
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Layout healing during preprocessing
• Imported layouts often contain very small gaps between shapes
• To get rid of them:
– We construct the arrangement of one layer one segment at a time
– We let new segments snap to other segments in close proximity
– This requires a neighborhood search structure
that can be updated incrementally (after each segment)
– CGAL has many different efficient search trees but always off-line
Page 23
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Many shapes in one arrangement
• Different shapes can be made of different materials
 we must keep this information for the EM simulator
• Use an approach similar to self-intersecting polygon resolution
• In the edges, simultaneously maintain incremental and total winding
contributions for different original shapes
• Resolve overlap according to some priority criterion
f2:1
f4:1,1
f3:1
f1:no winding
Page 24
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Overview
• Introduction to Agilent ADS
• Using CGAL for
– robust polygon Boolean operations
– layout preprocessing for EM simulation
• Cost of exact arithmetic
• Conclusions
Page 25
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Cost of exact arithmetic
• Exact rational computation is several 10x slower than using doubles
• We use a filtered exact number type. This combines
– The exact rational number
– An interval of doubles containing the number
• We have rewritten our own frequently used predicates to be independent of
the number type
– typename <NT> bool my_predicate(const NT& a, const NT& b);
– CGAL tries first to evaluate the predicate using the interval,
failing this, the calculation is restarted using the exact type
• End result: only a few times slower than using doubles (but it works!).
Page 26
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008
Conclusions
CGAL’s Unique Selling Proposition
• Exact arithmetic when needed, approximations where possible
CGAL packages used by Agilent EEsof EDA
• 2D Polygon operations
• 2D Arrangements
• (2D Snap rounding)  own incremental reimplementation
Requests/Usability opportunities
• Native support for self-intersecting polygons in the 2D Polygon package
• Native snap rounding support for polygons
• Search structures that can be fully incrementally maintained
Page 27
CGAL usage in Agilent ADS
Agilent Public
March 17, 2008