示例#1
0
    def discretize(cls, wire, deflection, method='quasi-deflection'):
        """ Convert a wire to points.

        Parameters
        ----------
        deflection: Float or Int
            Maximum deflection allowed if method is 'deflection' or
            'quasi-'defelction' else this is the number of points
        n: Int
            Number of points to use
        methode: Str
            A value of either 'deflection' or 'abissca'
        Returns
        -------
        points: List[Point]
            A list of points that make up the curve

        """
        c = BRepAdaptor_CompCurve(wire)
        start = c.FirstParameter()
        end = c.LastParameter()
        fn = DISCRETIZE_METHODS[method.lower().replace('uniform', '')]
        a = fn(c, deflection, start, end)
        if method.endswith('abscissa'):
            param = lambda i: c.Value(a.Parameter(i))
        else:
            param = lambda i: a.Value(i)
        return [coerce_point(param(i)) for i in range(1, a.NbPoints() + 1)]
示例#2
0
    def discretize(cls, wire, deflection=0.01, quasi=True):
        """ Convert a wire to points.

        Parameters
        ----------
        deflection: Float
            Maximum deflection allowed
        n: Int
            Number of points to use
        quasi: Bool
            If True, use the Quasi variant which is faster but less accurate.

        Returns
        -------
        points: List[Point]
            A list of points that make up the curve

        """
        c = BRepAdaptor_CompCurve(wire)
        start = c.FirstParameter()
        end = c.LastParameter()
        if quasi:
            a = GCPnts_QuasiUniformDeflection(c, deflection, start, end)
        else:
            a = GCPnts_UniformDeflection(c, deflection, start, end)
        return [coerce_point(a.Value(i)) for i in range(1, a.NbPoints() + 1)]
示例#3
0
    def start_point(self):
        """ Get the first / start point of a TopoDS_Wire or TopoDS_Edge

        """
        curve = BRepAdaptor_CompCurve(self.shape)
        return self.get_value_at(curve, curve.FirstParameter())