예제 #1
0
    def __init__(self, *args, **kargs):
        #     def __init__(self, points=None, role=None, parent=None, name=''):
        self.spline = None
        dump = self.DEFAULT.copy()
        """Constructeur vide Polyline3D()"""
        """Constructeur recopie Polyline3D(une_instance_de_Polyline3D, name=..)"""
        if len(args) > 1:
            msg = """
    Un seul argument non nommé autorisé, doit être de type Polyline3D.
        pour constructeur recopie.
        Ici, on a %d arguments non nommés de types : %s"""\
            %(len(args),[className(a) for a in args])
            raise TypeError(msg)
        elif len(args) == 1:
            #Un seul args, de type Polyline3D => constructeur recopie
            if isinstance(args[0], Polyline3D):
                dump.update(args[0].toDump())
            else:
                msg = """
    Un seul argument non nomme autorisé, doit etre de type Polyline3D (pour constructeur recopie.)
        Ici, 1 argument non nommé de type %s""" % (className(args[0]))
                debug(msg)
                raise TypeError
#         else :#len(args)==0
        dump.update(kargs)
        self.load(dump)
        #         if not kargs and not args:

        #         else :
        #         self.load(dump)
        #         self.name = name
        #         self.parent = parent
        if self.points.shape[0] > 2: self.update()
예제 #2
0
 def __isub__(self, v):
     if not isinstance(V, Vecteur):
         raise TypeError('On ne sait pas faire %s - %s' %
                         (className(self), className(V)))
     self.x -= V.x
     self.y -= V.y
     self.z -= V.z
     return self
예제 #3
0
 def __iadd__(self, V):
     """:returns : Point self, auquel on rajoute V
     >>> self += Vecteur(1,1,1) <=> self.__iadd__(Vecteur(1,1,1))"""
     if not isinstance(V, Vecteur):
         raise TypeError('On ne sait pas faire %s + %s' %
                         (className(self), className(V)))
     self.x += V.x
     self.y += V.y
     self.z += V.z
     return self
예제 #4
0
 def __isub__(self, v):
     """
     soustraction
     >>> self -= v <=> self.__isub__(v)
     """
     if isinstance(v, Vecteur):
         self.x -= v.x
         self.y -= v.y
         self.z -= v.z
         return self
     else:
         raise TypeError('On ne sait pas faire %s + %s' %
                         (className(self), className(v)))
예제 #5
0
    def __sub__(self, v):
        """
        soustraction
        >>> self - v <=> self.__sub__(v)
        """
        if isinstance(v, Vecteur):
            return self.copy().__isub__(v)
#             return Vecteur(self.x - v.x,
#                            self.y - v.y,
#                            self.z - v.z)
        else:
            raise TypeError('On ne sait pas faire %s + %s' %
                            (className(self), className(v)))
예제 #6
0
 def __iadd__(self, v):
     """
     Addition
     >>> self += v <=> self.__iadd__(v)
     """
     if isinstance(v, Vecteur):
         self.x += v.x
         self.y += v.y
         self.z += v.z
     else:
         raise TypeError('On ne sait pas faire %s + %s' %
                         (className(self), className(v)))
     return self
예제 #7
0
    def __add__(self, v):
        """
        Addition
        >>> self + v <=> self.__add__(v)
        """
        if isinstance(v, Vecteur):
            return self.copy().__iadd__(v)
#
#             return Vecteur(self.x + v.x,
#                            self.y + v.y,
#                            self.z + v.z)
        else:
            raise TypeError('On ne sait pas faire %s + %s' %
                            (className(self), className(v)))
예제 #8
0
 def __isub__(self, other):
     """self -= other <==> self.__isub__(other)"""
     if not isinstance(other, Torseur):
         raise TypeError('Torseur + %s : opération interdite' %
                         className(other))
     if other.A != self.A:
         other = other.copy(self.A)  #T += T1 ne doit pas modifier ni T1
     self._R -= other.R
     self.__M -= other.M
     return self
예제 #9
0
 def __add__(self, other):
     """self += other <==> self.__iadd__(other)"""
     if not isinstance(other, Torseur):
         raise TypeError('Torseur + %s : opération interdite' %
                         className(other))
     T = self.copy()
     #         debug(T,'\n',self)
     T += other
     #         debug(T,'\n',self)
     #         mexit()
     return T
예제 #10
0
    def plot(self, show=True, filename=None):
        data = []
        points = self.points.view()
        points.shape = (-1, 3)
        X, Y, Z = XYZ(points)
        mode = self.prefs.mode
        marker = self.prefs.marker
        line = self.prefs.line

        goP = go.Scatter3d(dict(x=X, y=Y, z=Z, text=list(range(len(X)))),
                           mode=mode[self.role],
                           marker=marker[self.role],
                           line=line[self.role],
                           name=self.role,
                           hoverinfo='name',
                           showlegend=True)
        data.append(goP)
        if show:
            layout = go.Layout(width=1800,
                               height=1200,
                               title=self.name,
                               legend=dict(x=0.2, y=0.2),
                               hovermode='closest')
            if filename is None:
                try:
                    filename = self.pjdir / self.session + className(
                        self) + '.html'
                except:
                    filename = RUNS_DIR / 'trash' / className(self) + '.html'
            figure = go.Figure(data=data, layout=layout)
            plot(figure,
                 show_link=True,
                 link_text='Exporter vers plot.ly (pour édition)',
                 filename=filename)
            try:
                self.files.add(filename)
            except:
                pass
            return filename
        else:
            return data
예제 #11
0
    def __iadd__(self, other):
        """self += other <==> self.__iadd__(other)"""
        if not isinstance(other, Torseur):
            raise TypeError('Torseur + %s : opération interdite' %
                            className(other))
#         if other.A != self.A :

#         debug(other,'\n',self)
        cother = other.copy(self.A)  #T += T1 ne doit pas modifier ni T1
        #         debug(cother,'\n',self)
        #             mexit()
        self._R += cother._R
        self.__M += cother.__M
        return self
예제 #12
0
 def __str__(self):
     D = self.getAxeCentral()
     inv = self.invariant()
     info = [('Origine (O)', self.A), ('Résultante(R)', self.R),
             ('Moment en O (M)', self.M), ('Axe central', D),
             ('invariant', inv)]
     if inv == 0: info.append(('glisseur', True))
     if 1:
         info.append(('ids', 'self:%d ; A:%d ; R:%d ; M:%d' % (
             id(self),
             id(self.A),
             id(self.R),
             id(self.M),
         )))
     return '<%s>\n' % className(self) + '\n'.join(
         ['    %15s : %s' % (k, v) for (k, v) in info])
예제 #13
0
 def rotate(self, alfa=None, centre=None, axe=None, rot=None):
     """
     Effectue, IN-SITU, une rotation (de centre C='centre', d'axe u='axe', d'angle a='alfa'),
         pour tous les points de X='points'.
         ou bien la rotation rot
     :param alfa: float, l'angle en radians
     :param centre : list de 3 reels [x,y,z] ou ndarray((1,3)) ou ndarray((3,1))
         c'est le centre de la rotation
     :param axe: list de 3 reels [x,y,z] ou ndarray de shape (1,3) ou (3,1),
         est l'axe de la rotation, non normalisé.
     Retourne la Rotation.
     --------
     """
     if rot is None:
         rot = Rotation(alfa, centre, axe)
     elif not isinstance(rot, Rotation):
         msg = self.__doc__ + """
         le parametre 'rot' est de type %s, il doit etre de type Rotation.
         sinon, precisez les trois parametres 'alfa' , 'centre' et 'axe'
         de la rotation""" % (className(rot))
         raise TypeError(msg)
     self.points = rot(self.points)
     self.update()
     return rot
예제 #14
0
 def __repr__(self):
     return className(self) + "(" + str(self.x) + ", " + str(
         self.y) + ", " + str(self.z) + ")"
예제 #15
0
 def setCoord(self, x):
     raise NotImplementedError(className(self))
     raise NotImplementedError
예제 #16
0
 def __sub__(self, x):
     raise NotImplementedError(className(self))
     raise NotImplementedError
예제 #17
0
 def __neg__(self):
     raise NotImplementedError(className(self))
     raise NotImplementedError
예제 #18
0
 def copy(self):
     raise NotImplementedError(className(self))
     raise NotImplementedError
예제 #19
0
 def __init__(self, *args, **kargs):
     raise NotImplementedError(className(self))
예제 #20
0
 def __sub__(self, other):
     """self += other <==> self.__iadd__(other)"""
     if not isinstance(other, Torseur):
         raise TypeError('Torseur + %s : opération interdite' %
                         className(other))
     return self.copy(self.A).__isub__(other)
예제 #21
0
 def __repr__(self):
     return '%s(A=%r, R=%r, M=%r)' % (className(self), self.A, self.R,
                                      self.M)