Beispiel #1
0
    def curve_of_wire(wire):
        """
        Get the curve of the wire. The edges are concatenated so the
        resulting curve may be C0 continuous.

        :param OCCT.TopoDS.TopoDS_Wire wire: The wire.

        :return: Concatenated curve of wire.
        :rtype: OCCT.Geom.Geom_BSplineCurve

        :raise RuntimeError: If an unsupported curve type is found.
        """
        geom_convert = GeomConvert_CompCurveToBSplineCurve()
        exp = BRepTools_WireExplorer(wire)
        tol = ExploreShape.global_tolerance(wire, 1)
        while exp.More():
            e = TopoDS.Edge_(exp.Current())
            exp.Next()
            adp_crv = BRepAdaptor_Curve(e)
            geom_convert.Add(adp_crv.BSpline(), tol)
        crv = geom_convert.BSplineCurve()
        if not isinstance(crv, Geom_BSplineCurve):
            msg = 'Unsupported curve type.'
            raise RuntimeError(msg)
        return crv
Beispiel #2
0
 def curve(self):
     """
     :return: The curve formed by concatenating all the underlying curves
         of the edges.
     :rtype: afem.geometry.entities.NurbsCurve
     """
     geom_convert = GeomConvert_CompCurveToBSplineCurve()
     exp = BRepTools_WireExplorer(self.object)
     tol = self.tol_max
     while exp.More():
         e = TopoDS.Edge_(exp.Current())
         exp.Next()
         adp_crv = BRepAdaptor_Curve(e)
         geom_convert.Add(adp_crv.BSpline(), tol)
     geom_curve = geom_convert.BSplineCurve()
     return Curve.wrap(geom_curve)