/[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 4285 by jfenwick, Tue Jan 22 09:30:23 2013 UTC revision 4286 by caltinay, Thu Mar 7 04:28:11 2013 UTC
# Line 281  class Primitive(object): Line 281  class Primitive(object):
281          raise NotImplementedError("collectPrimitiveBases is not implemented.")          raise NotImplementedError("collectPrimitiveBases is not implemented.")
282    
283      def isColocated(self,primitive):      def isColocated(self,primitive):
284         """          """
285         Rreturns True if the two primitives are located at the same position.          Returns True if the two primitives are located at the same position.
286    
287            :note: This method is overwritten by subclasses.
288            """
289            raise NotImplementedError("isCollocated is not implemented.")
290    
        :note: This method is overwritten by subclasses.  
        """  
        raise NotImplementedError("isColocated is not implemented.")  
291      def isReversed(self):      def isReversed(self):
292          """          """
293          returns True is the primitive is a reversed primitive.          returns True is the primitive is a reversed primitive.
# Line 424  class Point(Primitive, PrimitiveBase): Line 425  class Point(Primitive, PrimitiveBase):
425    
426      def getCoordinates(self):      def getCoordinates(self):
427         """         """
428         Returns the coodinates of the point as a ``numpy.ndarray`` object.         Returns the coordinates of the point as a ``numpy.ndarray`` object.
429         """         """
430         return self._x         return self._x
431    
432      def getCoordinatesAsList(self):      def getCoordinatesAsList(self):
433         """         """
434         Returns the coodinates of the point as a ``list`` object.         Returns the coordinates of the point as a ``list`` object.
435         """         """
436         return [self._x[0], self._x[1], self._x[2] ]         return [self._x[0], self._x[1], self._x[2] ]
437    
438      def setCoordinates(self,x):      def setCoordinates(self,x):
439         """         """
440         Sets the coodinates of the point from a ``numpy.ndarray`` object ``x``.         Sets the coordinates of the point from a ``numpy.ndarray`` object ``x``.
441         """         """
442         if not isinstance(x, numpy.ndarray):         if not isinstance(x, numpy.ndarray):
443            self._x=numpy.array(x,_TYPE)            self._x=numpy.array(x,_TYPE)
# Line 451  class Point(Primitive, PrimitiveBase): Line 452  class Point(Primitive, PrimitiveBase):
452    
453      def isColocated(self,primitive):      def isColocated(self,primitive):
454         """         """
455         Returns True if the `Point` ``primitive`` is colocated (has the same         Returns True if the `Point` ``primitive`` is collocated (has the same
456         coordinates) with self. That is, if         coordinates) with self. That is, if
457         *|self - primitive| <= tol * max(\|self\|,|primitive|)*.         *|self - primitive| <= tol * max(\|self\|,|primitive|)*.
458         """         """
# Line 525  class Manifold1D(PrimitiveBase): Line 526  class Manifold1D(PrimitiveBase):
526      def setElementDistribution(self,n,progression=1,createBump=False):      def setElementDistribution(self,n,progression=1,createBump=False):
527          """          """
528          Defines the number of elements on the line. If set it overwrites the local length setting which would be applied.          Defines the number of elements on the line. If set it overwrites the local length setting which would be applied.
529          The progression factor ``progression`` defines the change of element size between naighboured elements. If ``createBump`` is set          The progression factor ``progression`` defines the change of element size between neighboured elements. If ``createBump`` is set
530          progression is applied towards the center of the line.          progression is applied towards the center of the line.
531    
532          :param n: number of elements on the line          :param n: number of elements on the line
# Line 768  class Arc(ArcBase, Primitive): Line 769  class Arc(ArcBase, Primitive):
769         if not isinstance(center,Point): raise TypeError("center needs to be a Point object.")         if not isinstance(center,Point): raise TypeError("center needs to be a Point object.")
770         if not isinstance(end,Point): raise TypeError("end needs to be a Point object.")         if not isinstance(end,Point): raise TypeError("end needs to be a Point object.")
771         if not isinstance(start,Point): raise TypeError("start needs to be a Point object.")         if not isinstance(start,Point): raise TypeError("start needs to be a Point object.")
772         if center.isColocated(end): raise TypeError("center and start point are colocated.")         if center.isColocated(end): raise TypeError("center and start point are collocated.")
773         if center.isColocated(start): raise TypeError("center end end point are colocated.")         if center.isColocated(start): raise TypeError("center end end point are collocated.")
774         if start.isColocated(end): raise TypeError("start and end are colocated.")         if start.isColocated(end): raise TypeError("start and end are collocated.")
775         # TODO: check length of circle.         # TODO: check length of circle.
776         ArcBase.__init__(self)         ArcBase.__init__(self)
777         Primitive.__init__(self)         Primitive.__init__(self)
# Line 889  class Ellipse(EllipseBase, Primitive): Line 890  class Ellipse(EllipseBase, Primitive):
890         if not isinstance(end,Point): raise TypeError("end needs to be a Point object.")         if not isinstance(end,Point): raise TypeError("end needs to be a Point object.")
891         if not isinstance(start,Point): raise TypeError("start needs to be a Point object.")         if not isinstance(start,Point): raise TypeError("start needs to be a Point object.")
892         if not isinstance(point_on_main_axis,Point): raise TypeError("point on main axis needs to be a Point object.")         if not isinstance(point_on_main_axis,Point): raise TypeError("point on main axis needs to be a Point object.")
893         if center.isColocated(end): raise TypeError("center and start point are colocated.")         if center.isColocated(end): raise TypeError("center and start point are collocated.")
894         if center.isColocated(start): raise TypeError("center end end point are colocated.")         if center.isColocated(start): raise TypeError("center end end point are collocated.")
895         if center.isColocated(point_on_main_axis): raise TypeError("center and point on main axis are colocated.")         if center.isColocated(point_on_main_axis): raise TypeError("center and point on main axis are colocated.")
896         if start.isColocated(end): raise TypeError("start and end point are colocated.")         if start.isColocated(end): raise TypeError("start and end point are collocated.")
897         # TODO: check length of circle.         # TODO: check length of circle.
898         EllipseBase.__init__(self)         EllipseBase.__init__(self)
899         Primitive.__init__(self)         Primitive.__init__(self)
# Line 1079  class CurveLoop(Primitive, PrimitiveBase Line 1080  class CurveLoop(Primitive, PrimitiveBase
1080    
1081      def isColocated(self,primitive):      def isColocated(self,primitive):
1082         """         """
1083         Returns True if each curve is colocated with a curve in ``primitive``.         Returns True if each curve is collocated with a curve in ``primitive``.
1084         """         """
1085         if hasattr(primitive,"getUnderlyingPrimitive"):         if hasattr(primitive,"getUnderlyingPrimitive"):
1086            if isinstance(primitive.getUnderlyingPrimitive(),CurveLoop):            if isinstance(primitive.getUnderlyingPrimitive(),CurveLoop):
# Line 1096  class CurveLoop(Primitive, PrimitiveBase Line 1097  class CurveLoop(Primitive, PrimitiveBase
1097    
1098      def getPolygon(self):      def getPolygon(self):
1099         """         """
1100         Returns a list of start/end points of the 1D mainfold form the loop. If not closed and exception is thrown.         Returns a list of start/end points of the 1D manifold from the loop.
1101           If not closed an exception is thrown.
1102         """         """
1103         curves=self.getCurves()         curves=self.getCurves()
1104         s=[curves[0].getStartPoint(), curves[0].getEndPoint()]         s=[curves[0].getStartPoint(), curves[0].getEndPoint()]
# Line 1150  class Manifold2D(PrimitiveBase): Line 1152  class Manifold2D(PrimitiveBase):
1152      """      """
1153      General two-dimensional manifold.      General two-dimensional manifold.
1154    
1155      :ivar LEFT: left element orientation when meshing with transifinite meshing      :ivar LEFT: left element orientation when meshing with transfinite meshing
1156      :ivar RIGHT: right element orientation when meshing with transifinite meshing      :ivar RIGHT: right element orientation when meshing with transfinite meshing
1157      :ivar ALTERNATE: alternate element orientation when meshing with transifinite meshing      :ivar ALTERNATE: alternate element orientation when meshing with transfinite meshing
1158      """      """
1159      LEFT="Left"      LEFT="Left"
1160      RIGHT="Right"      RIGHT="Right"
# Line 1298  class Manifold2D(PrimitiveBase): Line 1300  class Manifold2D(PrimitiveBase):
1300    
1301      def getTransfiniteMeshing(self):      def getTransfiniteMeshing(self):
1302          """          """
1303          returns the transfinite meshing setings. If transfinite meshing is not set, ``None`` is returned.          returns the transfinite meshing settings. If transfinite meshing is not set, ``None`` is returned.
1304                    
1305          :return: a tuple of the tuple of points used to define the transfinite meshing and the orientation. If no points are set the points tuple is returned as ``None``. If no transfinite meshing is not set, ``None`` is returned.          :return: a tuple of the tuple of points used to define the transfinite meshing and the orientation. If no points are set the points tuple is returned as ``None``. If no transfinite meshing is not set, ``None`` is returned.
1306          :rtype: ``tuple`` of a ``tuple`` of `Point` s (or ``None``) and the orientation which is one of the values  `Manifold2D.LEFT` , `Manifold2D.RIGHT` , `Manifold2D.ALTERNATE`          :rtype: ``tuple`` of a ``tuple`` of `Point` s (or ``None``) and the orientation which is one of the values  `Manifold2D.LEFT` , `Manifold2D.RIGHT` , `Manifold2D.ALTERNATE`
# Line 1369  class RuledSurface(Primitive, Manifold2D Line 1371  class RuledSurface(Primitive, Manifold2D
1371    
1372      def isColocated(self,primitive):      def isColocated(self,primitive):
1373         """         """
1374         Returns True if each curve is colocated with a curve in ``primitive``.         Returns True if each curve is collocated with a curve in ``primitive``.
1375         """         """
1376         if hasattr(primitive,"getUnderlyingPrimitive"):         if hasattr(primitive,"getUnderlyingPrimitive"):
1377            if isinstance(primitive.getUnderlyingPrimitive(),RuledSurface):            if isinstance(primitive.getUnderlyingPrimitive(),RuledSurface):
# Line 1481  class PlaneSurface(Primitive, Manifold2D Line 1483  class PlaneSurface(Primitive, Manifold2D
1483    
1484      def isColocated(self,primitive):      def isColocated(self,primitive):
1485         """         """
1486         Returns True if each curve is colocated with a curve in ``primitive``.         Returns True if each curve is collocated with a curve in ``primitive``.
1487         """         """
1488         if hasattr(primitive,"getUnderlyingPrimitive"):         if hasattr(primitive,"getUnderlyingPrimitive"):
1489            if isinstance(primitive.getUnderlyingPrimitive(),PlaneSurface):            if isinstance(primitive.getUnderlyingPrimitive(),PlaneSurface):
# Line 1625  class SurfaceLoop(Primitive, PrimitiveBa Line 1627  class SurfaceLoop(Primitive, PrimitiveBa
1627    
1628      def isColocated(self,primitive):      def isColocated(self,primitive):
1629         """         """
1630         Returns True if each surface is colocated with a curve in ``primitive``         Returns True if each surface is collocated with a curve in ``primitive``
1631         and vice versa.         and vice versa.
1632         """         """
1633         if hasattr(primitive,"getUnderlyingPrimitive"):         if hasattr(primitive,"getUnderlyingPrimitive"):
# Line 1723  class Manifold3D(PrimitiveBase): Line 1725  class Manifold3D(PrimitiveBase):
1725          applies 3D transfinite meshing to the volume and all surface. It requires transfinite meshing          applies 3D transfinite meshing to the volume and all surface. It requires transfinite meshing
1726          on all faces which will be enforced (except if ``orientation`` is equal to ``None``).          on all faces which will be enforced (except if ``orientation`` is equal to ``None``).
1727          :param orientation: sets the orientation of the triangles on the surfaces. It is only relevant if recombination is not used.          :param orientation: sets the orientation of the triangles on the surfaces. It is only relevant if recombination is not used.
1728          If orientation is equal to ``None``, the transinite meshing is not applied to the surfaces but must be set by the user.          If orientation is equal to ``None``, the transfinite meshing is not applied to the surfaces but must be set by the user.
1729          :type orientation: `Manifold2D.LEFT`, `Manifold2D.RIGHT`, `Manifold2D.ALTERNATE`          :type orientation: `Manifold2D.LEFT`, `Manifold2D.RIGHT`, `Manifold2D.ALTERNATE`
1730          :note: Transfinite meshing can not be applied if holes are present.          :note: Transfinite meshing can not be applied if holes are present.
1731          :note: only five or six surfaces may be used.          :note: only five or six surfaces may be used.
# Line 1783  class Manifold3D(PrimitiveBase): Line 1785  class Manifold3D(PrimitiveBase):
1785    
1786      def getTransfiniteMeshing(self):      def getTransfiniteMeshing(self):
1787          """          """
1788          returns the transfinite meshing setings. If transfinite meshing is not set, ``None`` is returned.          returns the transfinite meshing settings. If transfinite meshing is not set, ``None`` is returned.
1789                    
1790          :return: a tuple of the tuple of points used to define the transfinite meshing and the orientation. If no points are set the points tuple is returned as ``None``. If no transfinite meshing is not set, ``None`` is returned.          :return: a tuple of the tuple of points used to define the transfinite meshing and the orientation. If no points are set the points tuple is returned as ``None``. If no transfinite meshing is not set, ``None`` is returned.
1791          :rtype: ``tuple`` of a ``tuple`` of `Point` s (or ``None``) and the orientation which is one of the values  `Manifold2D.LEFT` , `Manifold2D.RIGHT` , `Manifold2D.ALTERNATE`          :rtype: ``tuple`` of a ``tuple`` of `Point` s (or ``None``) and the orientation which is one of the values  `Manifold2D.LEFT` , `Manifold2D.RIGHT` , `Manifold2D.ALTERNATE`
# Line 1848  class Volume(Manifold3D, Primitive): Line 1850  class Volume(Manifold3D, Primitive):
1850    
1851      def isColocated(self,primitive):      def isColocated(self,primitive):
1852         """         """
1853         Returns True if each curve is colocated with a curve in ``primitive``.         Returns True if each curve is collocated with a curve in ``primitive``.
1854         """         """
1855         if hasattr(primitive,"getUnderlyingPrimitive"):         if hasattr(primitive,"getUnderlyingPrimitive"):
1856            if isinstance(primitive.getUnderlyingPrimitive(),Volume):            if isinstance(primitive.getUnderlyingPrimitive(),Volume):

Legend:
Removed from v.4285  
changed lines
  Added in v.4286

  ViewVC Help
Powered by ViewVC 1.1.26