92 |
""" |
""" |
93 |
returns a deep copy of the object |
returns a deep copy of the object |
94 |
""" |
""" |
95 |
return Primitive() |
return self.substitute({}) |
96 |
|
|
97 |
|
|
98 |
def modifyBy(self,transformation): |
def modifyBy(self,transformation): |
174 |
|
|
175 |
def apply(self,transformation): |
def apply(self,transformation): |
176 |
""" |
""" |
177 |
returns a new object by applying the transformation |
returns a new L{Point} by applying the transformation |
178 |
""" |
""" |
179 |
raise NotImplementedError("apply is not implemented for this class %s."%self.__class__.__name__) |
out=self.copy() |
180 |
|
out.modifyBy(transformation) |
181 |
|
return out |
182 |
|
|
183 |
def isColocated(self,primitive): |
def isColocated(self,primitive): |
184 |
""" |
""" |
186 |
""" |
""" |
187 |
raise NotImplementedError("isColocated is not implemented for this class %s."%self.__class__.__name__) |
raise NotImplementedError("isColocated is not implemented for this class %s."%self.__class__.__name__) |
188 |
|
|
189 |
|
def substitute(self,sub_dict): |
190 |
|
""" |
191 |
|
returns a copy of self with substitutes for the primitives used to construct it given by the dictionary C{sub_dict}. |
192 |
|
If a substitute for the object is given by C{sub_dict} the value is returned, otherwise a new instance |
193 |
|
with substituted arguments is returned. |
194 |
|
""" |
195 |
|
if not sub_dict.has_key(self): |
196 |
|
sub_dict[self]=self.__class__() |
197 |
|
return sub_dict[self] |
198 |
|
|
199 |
class Point(Primitive): |
class Point(Primitive): |
200 |
""" |
""" |
201 |
a three dimensional point |
a three dimensional point |
253 |
else: |
else: |
254 |
return False |
return False |
255 |
|
|
256 |
def copy(self): |
def substitute(self,sub_dict): |
257 |
""" |
""" |
258 |
returns a deep copy of the point |
returns a copy of self with substitutes for the primitives used to construct it given by the dictionary C{sub_dict}. |
259 |
""" |
If a substitute for the object is given by C{sub_dict} the value is returned, otherwise a new instance |
260 |
c=self.getCoordinates() |
with substituted arguments is returned. |
261 |
return Point(c[0],c[1],c[2],local_scale=self.getLocalScale()) |
""" |
262 |
|
if not sub_dict.has_key(self): |
263 |
|
c=self.getCoordinates() |
264 |
|
sub_dict[self]=Point(c[0],c[1],c[2],local_scale=self.getLocalScale()) |
265 |
|
return sub_dict[self] |
266 |
|
|
267 |
def modifyBy(self,transformation): |
def modifyBy(self,transformation): |
268 |
""" |
""" |
270 |
""" |
""" |
271 |
self.setCoordinates(transformation(self.getCoordinates())) |
self.setCoordinates(transformation(self.getCoordinates())) |
272 |
|
|
|
def apply(self,transformation): |
|
|
""" |
|
|
returns a new L{Point} by applying the transformation |
|
|
""" |
|
|
new_p=self.copy() |
|
|
new_p.modifyBy(transformation) |
|
|
return new_p |
|
273 |
|
|
274 |
def getGmshCommand(self, local_scaling_factor=1.): |
def getGmshCommand(self, local_scaling_factor=1.): |
275 |
""" |
""" |
338 |
out.add(self) |
out.add(self) |
339 |
return list(out) |
return list(out) |
340 |
|
|
341 |
def copy(self): |
def substitute(self,sub_dict): |
|
""" |
|
|
returns a deep copy |
|
|
""" |
|
|
new_p=[] |
|
|
for p in self.getControlPoints(): new_p.append(p.copy()) |
|
|
return self.__class__(*tuple(new_p)) |
|
|
|
|
|
|
|
|
def apply(self,transformation): |
|
342 |
""" |
""" |
343 |
applies transformation |
returns a copy of self with substitutes for the primitives used to construct it given by the dictionary C{sub_dict}. |
344 |
""" |
If a substitute for the object is given by C{sub_dict} the value is returned, otherwise a new instance |
345 |
new_p=[] |
with substituted arguments is returned. |
346 |
for p in self.getControlPoints(): new_p.append(p.apply(transformation)) |
""" |
347 |
return self.__class__(*tuple(new_p)) |
if not sub_dict.has_key(self): |
348 |
|
new_p=[] |
349 |
|
for p in self.getControlPoints(): new_p.append(p.substitute(sub_dict)) |
350 |
|
sub_dict[self]=self.__class__(*tuple(new_p)) |
351 |
|
return sub_dict[self] |
352 |
|
|
353 |
def isColocated(self,primitive): |
def isColocated(self,primitive): |
354 |
""" |
""" |
492 |
""" |
""" |
493 |
return "Circle(%s) = {%s, %s, %s};"%(self.getID(),self.getStartPoint().getID(),self.getCenterPoint().getID(),self.getEndPoint().getID()) |
return "Circle(%s) = {%s, %s, %s};"%(self.getID(),self.getStartPoint().getID(),self.getCenterPoint().getID(),self.getEndPoint().getID()) |
494 |
|
|
495 |
def copy(self): |
def substitute(self,sub_dict): |
|
""" |
|
|
returns a deep copy |
|
|
""" |
|
|
return Arc(self.getCenterPoint().copy(),self.getStartPoint().copy(),self.getEndPoint().copy()) |
|
|
|
|
|
def apply(self,transformation): |
|
|
""" |
|
|
applies transformation |
|
496 |
""" |
""" |
497 |
return Arc(self.getCenterPoint().apply(transformation),self.getStartPoint().apply(transformation),self.getEndPoint().apply(transformation)) |
returns a copy of self with substitutes for the primitives used to construct it given by the dictionary C{sub_dict}. |
498 |
|
If a substitute for the object is given by C{sub_dict} the value is returned, otherwise a new instance |
499 |
|
with substituted arguments is returned. |
500 |
|
""" |
501 |
|
if not sub_dict.has_key(self): |
502 |
|
sub_dict[self]=Arc(self.getCenterPoint().substitute(sub_dict),self.getStartPoint().substitute(sub_dict),self.getEndPoint().substitute(sub_dict)) |
503 |
|
return sub_dict[self] |
504 |
|
|
505 |
def isColocated(self,primitive): |
def isColocated(self,primitive): |
506 |
""" |
""" |
562 |
returns the curves defining the CurveLoop |
returns the curves defining the CurveLoop |
563 |
""" |
""" |
564 |
return self.__curves |
return self.__curves |
565 |
|
|
566 |
def __len__(self): |
def __len__(self): |
567 |
""" |
""" |
568 |
return the number of curves in the CurveLoop |
return the number of curves in the CurveLoop |
578 |
out.add(self) |
out.add(self) |
579 |
return list(out) |
return list(out) |
580 |
|
|
581 |
def copy(self): |
def substitute(self,sub_dict): |
|
""" |
|
|
returns a deep copy |
|
|
""" |
|
|
new_c=[] |
|
|
for c in self.getCurves(): new_c.append(c.copy()) |
|
|
return CurveLoop(*tuple(new_c)) |
|
|
|
|
|
|
|
|
def apply(self,transformation): |
|
|
""" |
|
|
applies transformation |
|
582 |
""" |
""" |
583 |
new_c=[] |
returns a copy of self with substitutes for the primitives used to construct it given by the dictionary C{sub_dict}. |
584 |
for c in self.getCurves(): new_c.append(c.apply(transformation)) |
If a substitute for the object is given by C{sub_dict} the value is returned, otherwise a new instance |
585 |
return CurveLoop(*tuple(new_c)) |
with substituted arguments is returned. |
586 |
|
""" |
587 |
|
if not sub_dict.has_key(self): |
588 |
|
new_c=[] |
589 |
|
for c in self.getCurves(): new_c.append(c.substitute(sub_dict)) |
590 |
|
sub_dict[self]=CurveLoop(*tuple(new_c)) |
591 |
|
return sub_dict[self] |
592 |
|
|
593 |
|
|
594 |
def isColocated(self,primitive): |
def isColocated(self,primitive): |
595 |
""" |
""" |
601 |
cp1=primitive.getCurves() |
cp1=primitive.getCurves() |
602 |
for c0 in cp0: |
for c0 in cp0: |
603 |
collocated = False |
collocated = False |
604 |
for c1 in cp1: collocated = collocated or c0.isColocated(c1) |
for c1 in cp1: |
605 |
|
collocated = collocated or c0.isColocated(c1) |
606 |
if not collocated: return False |
if not collocated: return False |
607 |
return True |
return True |
608 |
else: |
else: |