@@ -219,19 +219,26 @@ void Rings::makeShapes(const Shape::ShapeTreeMap& other_shapes)
219219 single_layer_ring = true ;
220220 }
221221
222+ using LayerPair = std::pair<Layer*, Layer*>;
223+ const std::array<LayerPair, 2 > build_layers{
224+ LayerPair{&layers_[0 ], &layers_[1 ]}, LayerPair{&layers_[1 ], &layers_[0 ]}};
225+
222226 bool processed_horizontal = false ;
223- for (const auto & layer_def : layers_) {
224- auto * layer = layer_def.layer ;
225- const int width = layer_def.width ;
226- const int pitch = layer_def.spacing + width;
227+ for (const auto & [layer_def, layer_other] : build_layers) {
228+ auto * layer = layer_def->layer ;
229+ const int width = layer_def->width ;
230+ const int pitch = layer_def->spacing + width;
231+
232+ const int other_width = layer_other->width ;
233+ const int other_pitch = layer_other->spacing + other_width;
227234 if ((single_layer_ring && !processed_horizontal)
228235 || (!single_layer_ring
229236 && layer->getDirection () == odb::dbTechLayerDir::HORIZONTAL)) {
230237 processed_horizontal = true ;
231238
232239 // bottom
233- int x_start = core.xMin () - width ;
234- int x_end = core.xMax () + width ;
240+ int x_start = core.xMin () - other_width ;
241+ int x_end = core.xMax () + other_width ;
235242 if (extend_to_boundary_) {
236243 x_start = boundary.xMin ();
237244 x_end = boundary.xMax ();
@@ -244,16 +251,16 @@ void Rings::makeShapes(const Shape::ShapeTreeMap& other_shapes)
244251 odb::Rect (x_start, y_start, x_end, y_end),
245252 odb::dbWireShapeType::RING));
246253 if (!extend_to_boundary_) {
247- x_start -= pitch ;
248- x_end += pitch ;
254+ x_start -= other_pitch ;
255+ x_end += other_pitch ;
249256 }
250257 y_start -= pitch;
251258 y_end -= pitch;
252259 }
253260 // top
254261 if (!extend_to_boundary_) {
255- x_start = core.xMin () - width ;
256- x_end = core.xMax () + width ;
262+ x_start = core.xMin () - other_width ;
263+ x_end = core.xMax () + other_width ;
257264 }
258265 y_start = core.yMax ();
259266 y_end = y_start + width;
@@ -263,8 +270,8 @@ void Rings::makeShapes(const Shape::ShapeTreeMap& other_shapes)
263270 odb::Rect (x_start, y_start, x_end, y_end),
264271 odb::dbWireShapeType::RING));
265272 if (!extend_to_boundary_) {
266- x_start -= pitch ;
267- x_end += pitch ;
273+ x_start -= other_pitch ;
274+ x_end += other_pitch ;
268275 }
269276 y_start += pitch;
270277 y_end += pitch;
@@ -273,8 +280,8 @@ void Rings::makeShapes(const Shape::ShapeTreeMap& other_shapes)
273280 // left
274281 int x_start = core.xMin () - width;
275282 int x_end = core.xMin ();
276- int y_start = core.yMin () - width ;
277- int y_end = core.yMax () + width ;
283+ int y_start = core.yMin () - other_width ;
284+ int y_end = core.yMax () + other_width ;
278285 if (extend_to_boundary_) {
279286 y_start = boundary.yMin ();
280287 y_end = boundary.yMax ();
@@ -287,16 +294,16 @@ void Rings::makeShapes(const Shape::ShapeTreeMap& other_shapes)
287294 x_start -= pitch;
288295 x_end -= pitch;
289296 if (!extend_to_boundary_) {
290- y_start -= pitch ;
291- y_end += pitch ;
297+ y_start -= other_pitch ;
298+ y_end += other_pitch ;
292299 }
293300 }
294301 // right
295302 x_start = core.xMax ();
296303 x_end = x_start + width;
297304 if (!extend_to_boundary_) {
298- y_start = core.yMin () - width ;
299- y_end = core.yMax () + width ;
305+ y_start = core.yMin () - other_width ;
306+ y_end = core.yMax () + other_width ;
300307 }
301308 for (auto net : nets) {
302309 addShape (new Shape (layer,
@@ -306,8 +313,8 @@ void Rings::makeShapes(const Shape::ShapeTreeMap& other_shapes)
306313 x_start += pitch;
307314 x_end += pitch;
308315 if (!extend_to_boundary_) {
309- y_start -= pitch ;
310- y_end += pitch ;
316+ y_start -= other_pitch ;
317+ y_end += other_pitch ;
311318 }
312319 }
313320 }
0 commit comments