def _init_primitives_trans(self): self.init_primitives() # must be implemented in every subclass dr_origin = DSimplePolygon([DPoint(0, 0)]) if (self.DCplxTrans_init is not None): # constructor trans displacement dCplxTrans_temp = DCplxTrans(1, 0, False, self.DCplxTrans_init.disp) for element in self.primitives.values(): element.make_trans(dCplxTrans_temp) dr_origin.transform(dCplxTrans_temp) self._update_connections(dCplxTrans_temp) self._update_alpha(dCplxTrans_temp) # rest of the constructor trans functions dCplxTrans_temp = self.DCplxTrans_init.dup() dCplxTrans_temp.disp = DPoint(0, 0) for element in self.primitives.values(): element.make_trans(dCplxTrans_temp) dr_origin.transform(dCplxTrans_temp) self._update_connections(dCplxTrans_temp) self._update_alpha(dCplxTrans_temp) dCplxTrans_temp = DCplxTrans(1, 0, False, self.origin) for element in self.primitives.values(): element.make_trans(dCplxTrans_temp) # move to the origin self._update_connections(dCplxTrans_temp) self._update_alpha(dCplxTrans_temp) self.origin += dr_origin.point(0) # FOLLOWING CYCLE GIVES WRONG INFO ABOUT FILLED AND ERASED AREAS for element in self.primitives.values(): self.metal_region += element.metal_region self.empty_region += element.empty_region
def _update_alpha( self, dCplxTrans ): if( dCplxTrans is not None ): dCplxTrans_temp = dCplxTrans.dup() dCplxTrans_temp.disp = DPoint(0,0) for i,alpha in enumerate(self.angle_connections): poly_temp = DSimplePolygon( [DPoint( cos(alpha), sin(alpha) )] ) poly_temp.transform( dCplxTrans_temp ) pt = poly_temp.point( 0 ) self.angle_connections[i] = atan2( pt.y, pt.x )
def _update_connections( self, dCplxTrans ): if( dCplxTrans is not None ): # the problem is, if k construct polygon with multiple points # their order in poly_temp.each_point() doesn't coinside with the # order of the list that was passed to the polygon constructor # so, when k perform transformation and try to read new values through poly_temp.each_point() # they values are rearranged # solution is: k need to create polygon for each point personally, and the initial order presists for i,pt in enumerate(self.connections): poly_temp = DSimplePolygon( [pt] ) poly_temp.transform( dCplxTrans ) self.connections[i] = poly_temp.point( 0 )
def _init_regions_trans( self ): self.init_regions() # must be implemented in every subclass dr_origin = DSimplePolygon( [DPoint(0,0)] ) if( self.DCplxTrans_init is not None ): # constructor trans displacement dCplxTrans_temp = DCplxTrans( 1,0,False, self.DCplxTrans_init.disp ) self.make_trans( dCplxTrans_temp ) dr_origin.transform( dCplxTrans_temp ) # rest of the constructor trans functions dCplxTrans_temp = self.DCplxTrans_init.dup() dCplxTrans_temp.disp = DPoint(0,0) self.make_trans( dCplxTrans_temp ) dr_origin.transform( dCplxTrans_temp ) # translation to the old origin (self.connections are alredy contain proper values) self.make_trans( DCplxTrans( 1,0,False, self.origin ) ) # move to the origin self.origin += dr_origin.point( 0 )
def init_primitives_gnd_trans( self ): dr_origin = DSimplePolygon( [DPoint(0,0)] ) if( self.DCplxTrans_init is not None ): # constructor trans displacement dCplxTrans_temp = DCplxTrans( 1,0,False, self.DCplxTrans_init.disp ) for element in self.primitives_gnd.values(): element.make_trans( dCplxTrans_temp ) dr_origin.transform( dCplxTrans_temp ) # rest of the constructor trans functions dCplxTrans_temp = self.DCplxTrans_init.dup() dCplxTrans_temp.disp = DPoint(0,0) for element in self.primitives_gnd.values(): element.make_trans( dCplxTrans_temp ) dr_origin.transform( dCplxTrans_temp ) dCplxTrans_temp = DCplxTrans( 1,0,False, self.origin ) for element in self.primitives_gnd.values(): element.make_trans( dCplxTrans_temp ) # move to the origin
def init_regions(self): self.connections = [DPoint(0, 0), DPoint(self.dr.abs(), 0)] self.angle_connections = [0, 0] alpha = atan2(self.dr.y, self.dr.x) self.angle_connections = [alpha, alpha] alpha_trans = DCplxTrans(1, alpha * 180 / pi, False, 0, 0) m_poly = DSimplePolygon([ DPoint(0, -self.Z0.width / 2), DPoint(self.dr.abs(), -self.Z1.width / 2), DPoint(self.dr.abs(), self.Z1.width / 2), DPoint(0, self.Z0.width / 2) ]) e_poly1 = DSimplePolygon([ DPoint(0, -self.Z0.b / 2), DPoint(self.dr.abs(), -self.Z1.b / 2), DPoint(self.dr.abs(), -self.Z1.width / 2), DPoint(0, -self.Z0.width / 2) ]) e_poly2 = DSimplePolygon([ DPoint(0, self.Z0.b / 2), DPoint(self.dr.abs(), self.Z1.b / 2), DPoint(self.dr.abs(), self.Z1.width / 2), DPoint(0, self.Z0.width / 2) ]) m_poly.transform(alpha_trans) e_poly1.transform(alpha_trans) e_poly2.transform(alpha_trans) self.metal_region.insert(SimplePolygon.from_dpoly(m_poly)) self.empty_region.insert(SimplePolygon.from_dpoly(e_poly1)) self.empty_region.insert(SimplePolygon.from_dpoly(e_poly2))
def _update_origin( self, dCplxTrans ): if( dCplxTrans is not None ): poly_temp = DSimplePolygon( [self.origin] ) poly_temp.transform( dCplxTrans ) self.origin = poly_temp.point( 0 )