/[escript]/trunk/pycad/py_src/primitives.py
ViewVC logotype

Diff of /trunk/pycad/py_src/primitives.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 931 by gross, Fri Jan 19 03:06:33 2007 UTC revision 932 by gross, Fri Jan 19 09:27:15 2007 UTC
# Line 774  class CurveLoop(Primitive, PrimitiveBase Line 774  class CurveLoop(Primitive, PrimitiveBase
774                raise TypeError("%s-th argument is not a Manifold1D object."%i)                raise TypeError("%s-th argument is not a Manifold1D object."%i)
775         # for the curves a loop:         # for the curves a loop:
776         used=[ False for i in curves]         used=[ False for i in curves]
777         self.__curves=[curves[0]]         self.__curves=list(curves)
        used[0]=True  
        while not min(used):  
           found=False  
           for i in xrange(len(curves)):  
              if not used[i]:  
                 if self.__curves[-1].getEndPoint() == curves[i].getStartPoint():  
                    self.__curves.append(curves[i])  
                    used[i]=True  
                    found=True  
                    break  
           if not found:  
              raise ValueError("loop is not closed.")  
        if not self.__curves[0].getStartPoint() == self.__curves[-1].getEndPoint():  
           raise ValueError("loop is not closed.")  
778         Primitive.__init__(self)         Primitive.__init__(self)
779         PrimitiveBase.__init__(self)         PrimitiveBase.__init__(self)
780    
# Line 1156  class SurfaceLoop(Primitive, PrimitiveBa Line 1142  class SurfaceLoop(Primitive, PrimitiveBa
1142         for i in range(len(surfaces)):         for i in range(len(surfaces)):
1143             if not isinstance(surfaces[i].getUnderlyingPrimitive(),Manifold2D):             if not isinstance(surfaces[i].getUnderlyingPrimitive(),Manifold2D):
1144                raise TypeError("%s-th argument is not a Manifold2D object."%i)                raise TypeError("%s-th argument is not a Manifold2D object."%i)
1145           self.__surfaces=list(surfaces)
1146         Primitive.__init__(self)         Primitive.__init__(self)
1147         PrimitiveBase.__init__(self)         PrimitiveBase.__init__(self)
        # for the curves a loop:  
        used=[ False for s in surfaces]  
        self.__surfaces=[surfaces[0]]  
        used[0]= True  
        edges=[ e for e in surfaces[0].getBoundary() ]  
        used_edges=[ False for e in surfaces[0].getBoundary() ]  
        while not min(used):  
           found=False  
           for i in xrange(len(surfaces)):  
              if not used[i]:  
                 i_boundary=surfaces[i].getBoundary()  
                 for ib in xrange(len(i_boundary)):    
                     if i_boundary[ib] in edges:  
                          found=True  
                          break  
                 if found:  
                     used[i]=True  
                     self.__surfaces.append(surfaces[i])  
                     for ib in xrange(len(i_boundary)):    
                        if i_boundary[ib] in edges:  
                          if used_edges[edges.index(i_boundary[ib])]:  
                             raise ValueError("boundary segment %s is shared by more than one surface."%str(i_boundary[ib].getUnderlyingPrimitive()))  
                          used_edges[edges.index(i_boundary[ib])]=True  
                        else:  
                          edges.append(i_boundary[ib])  
                          used_edges.append(False)  
                     break  
           if not found:  
                raise ValueError("loop is not closed.")  
        if not min(used_edges):  
           raise ValueError("loop is not closed. Surface is missing.")  
1148      def __len__(self):      def __len__(self):
1149         """         """
1150         return the number of curves in the SurfaceLoop         return the number of curves in the SurfaceLoop

Legend:
Removed from v.931  
changed lines
  Added in v.932

  ViewVC Help
Powered by ViewVC 1.1.26