Ejemplo n.º 1
0
    def surface_adaptive(surface, tol=0.01):
        """
        Tessellate a surface using adaptive subdivision.

        :param surface: Surface to tessellate.
        :type surface: :class:`.BezierSurface` or :class:`.NurbsSurface`
        :param float tol: Tolerance to use for flatness criteria.

        :return: Adaptive surface tessellation.
        :rtype: :class:`.SurfaceTessAdaptive`
        """
        if CheckGeom.is_surface(surface):
            return SurfaceTessAdaptive(surface, tol)
        return None
Ejemplo n.º 2
0
    def invert(point, geom, ends=True):
        """
        Return the parameters of the nearest orthogonal projection to the
        geometry.

        :param point: Point to project.
        :type point: :class:`.Point`
        :param geom: Curve or surface entity to find parameters.
        :param bool ends: Option to project point to the nearest end point of a
            curve, or to the nearest boundary curve of a surface if no
            orthogonal projection is found.

        :return: Parameter(s) on the geometry of the nearest orthogonal
            projection. For a curve a single float *u* is returned,
            for a surface a tuple (u, v) is returned.
        :rtype: float or tuple

        .. note::
            *None* is returned if no points are found or the method fails. A
            tuple (*None*, *None*) is returned for a surface.
        """
        point = CheckGeom.to_point(point)
        if not CheckGeom.is_point(point):
            if CheckGeom.is_curve_like(geom):
                return None
            return None, None

        if CheckGeom.is_curve_like(geom):
            proj = ProjectPointToCurve(point, geom, ends)
            if not proj.success:
                return None
            return proj.nearest_param
        if CheckGeom.is_surface(geom):
            proj = ProjectPointToSurface(point, geom, ends)
            if not proj.success:
                return None, None
            return proj.nearest_param
        if CheckGeom.is_plane(geom):
            proj = ProjectPointToPlane(point, geom)
            if not proj.success:
                return None, None
            return proj.nearest_param
        return None
Ejemplo n.º 3
0
    def icurve_by_points(surface, p0, p1, isurf=None, trim=True):
        """
        Create an intersection curve between two points on the surface.

        :param surface:
        :type surface: :class:`.BezierSurface` or :class`.NurbsSurface`
        :param point_like p0: Starting point.
        :param point_like p1: Ending point.
        :param surface_like isurf: Intersection surface. If *None* if
            provided then a plane will be created between the two points using
            the surface normal at *p0*.
        :param bool trim: Option to trim the curve or not.

        :return: Intersection curve between *p0* and *p1*. Returns *None* if
            method fails.
        :rtype: :class:`.ICurve`
        """
        if not CheckGeom.is_surface(surface):
            return None
        if not CheckGeom.is_point_like(p0) or not CheckGeom.is_point_like(p1):
            return None
        return create_icurve_by_points(surface, p0, p1, isurf, trim)
Ejemplo n.º 4
0
    def point(pnt, geom, ends=True, all_pnts=False, update=False):
        """
        Project a point to a curve or surface.

        :param pnt: Point to project.
        :type pnt: :class:`.Point`
        :param geom: Curve or surface entity to project point to.
        :param bool ends: Option to project point to the nearest end point of a
            curve, or to the nearest boundary curve of a surface if no
            orthogonal projection is found.
        :param bool all_pnts: Option to return only the nearest point during
            the subdivision process (*False*), or all points (*True*).
        :param bool update: Option to update the location of the *point*
            rather than returning a projection object. If *True*, then the
            nearest point will be used to update the point location and a
            boolean will be returned indicating a successful *True* or
            unsuccessful *False* projection.

        :return: Projection object depending on *geom* type.
        """
        pnt = CheckGeom.to_point(pnt)

        # Project point to curve.
        if CheckGeom.is_curve_like(geom):
            proj = ProjectPointToCurve(pnt, geom, ends, all_pnts)
            return ProjectGeom._update(pnt, proj, update)

        # Project point to surface.
        if CheckGeom.is_surface(geom):
            proj = ProjectPointToSurface(pnt, geom, ends, all_pnts)
            return ProjectGeom._update(pnt, proj, update)

        # Project point to plane.
        if CheckGeom.is_plane(geom):
            proj = ProjectPointToPlane(pnt, geom)
            return ProjectGeom._update(pnt, proj, update)
        return False
Ejemplo n.º 5
0
 def __init__(self, point, surface, ends=True, all_pnts=False):
     super(ProjectPointToSurface, self).__init__()
     point = CheckGeom.to_point(point)
     if CheckGeom.is_point(point) and CheckGeom.is_surface(surface):
         self._perform(point, surface, ends, all_pnts)
Ejemplo n.º 6
0
 def __init__(self, surface, tol=0.01):
     super(SurfaceTessAdaptive, self).__init__('surface_tessellation')
     self._verts = zeros((0, 3), dtype=float64)
     self._triangles = zeros((0, 3), dtype=int32)
     if CheckGeom.is_surface(surface):
         self._perform(surface, tol)