Exemplo n.º 1
0
    def __init__(self, crv1, crv2, itol=1.0e-7):
        super(IntersectCurveCurve, self).__init__(crv1, crv2)

        # Build edges from curve
        e1 = BRepBuilderAPI_MakeEdge(crv1.object).Edge()
        e2 = BRepBuilderAPI_MakeEdge(crv2.object).Edge()

        # Set tolerance to be half intersection tolerance
        shp_tol = ShapeFix_ShapeTolerance()
        tol = itol / 2.
        shp_tol.SetTolerance(e1, tol)
        shp_tol.SetTolerance(e2, tol)

        # Perform edge-edge intersection
        cci = IntTools_EdgeEdge(e1, e2)
        cci.Perform()

        # Gather results of point intersection only
        results = []
        common_parts = cci.CommonParts()
        for i in range(1, common_parts.Length() + 1):
            common_part = common_parts.Value(i)
            if not common_part.Type() == TopAbs_VERTEX:
                continue
            u1 = common_part.VertexParameter1()
            u2 = common_part.VertexParameter2()
            p1 = crv1.eval(u1)
            p2 = crv2.eval(u2)
            pi = mean([p1, p2], axis=0)
            pi = Point(*pi)
            results.append([(u1, u2), pi])

        npts = len(results)
        self._set_results(npts, results)
Exemplo n.º 2
0
 def cg(self):
     """
     :return: The center of gravity.
     :rtype: afem.geometry.entities.Point
     """
     gp_pnt = self._props.CentreOfMass()
     return Point(gp_pnt.X(), gp_pnt.Y(), gp_pnt.Z())
Exemplo n.º 3
0
 def point(self):
     """
     :return: A point at vertex location.
     :rtype: afem.geometry.entities.Point
     """
     gp_pnt = BRep_Tool.Pnt_(self.object)
     return Point(gp_pnt.X(), gp_pnt.Y(), gp_pnt.Z())
Exemplo n.º 4
0
 def point_iter(self):
     """
     :return: Yield nodes of the element as points. The corner points will
         be first followed by medium points if quadratic.
     :rtype: collections.Iterable(afem.geometry.entities.Point)
     """
     for n in self.node_iter:
         yield Point(n.x, n.y, n.z)
Exemplo n.º 5
0
 def pmax(self):
     """
     :return: Upper corner of bounding box. *None* if empty.
     :rtype: afem.geometry.entities.Point
     """
     if self.is_void:
         return None
     return Point(self.CornerMax().XYZ())
Exemplo n.º 6
0
    def is_point_like(entity):
        """
        Check if the entity is point_like.

        :param entity: An entity.

        :return: *True* if the entity is point_like, *False* if not.
        :rtype: bool
        """
        return Point.is_point_like(entity)
Exemplo n.º 7
0
    def point_on_shape2(self, n=1):
        """
        The point for the *n-th* solution on the second shape.

        :param int n: The index.

        :return: The point.
        :rtype: afem.geometry.entities.Point
        """
        gp_pnt = self._tool.PointOnShape2(n)
        return Point(gp_pnt.X(), gp_pnt.Y(), gp_pnt.Z())
Exemplo n.º 8
0
    def to_point(geom):
        """
        Convert entity to a :class:`.Point` if possible.

        :param geom: An entity.

        :return: The entity if already a Point, or a new Point if it is
            point_like.
        :rtype: afem.geometry.entities.Point

        :raise TypeError: If entity cannot be converted to a Point.
        """
        return Point.to_point(geom)
Exemplo n.º 9
0
    def eval(self, u):
        """
        Evaluate a point on the curve.

        :param float u: Curve parameter.

        :return: Curve point.
        :rtype: afem.geometry.entities.Point
        """
        from afem.geometry.entities import Point

        p = Point()
        self.object.D0(u, p)
        return p
Exemplo n.º 10
0
    def eval(self, u=0., v=0.):
        """
        Evaluate a point on the surface.

        :param float u: Surface u-parameter.
        :param float v: Surface v-parameter.

        :return: Surface point.
        :rtype: afem.geometry.entities.Point
        """
        from afem.geometry.entities import Point

        p = Point()
        self.object.D0(u, v, p)
        return p
Exemplo n.º 11
0
    def __init__(self, crv, srf):
        super(IntersectCurveSurface, self).__init__(crv, srf)

        # Perform

        # OCC intersection.
        csi = GeomAPI_IntCS(crv.object, srf.object)
        results = []
        for i in range(1, csi.NbPoints() + 1):
            u, v, t = csi.Parameters(i, 0., 0., 0.)
            pc = crv.eval(t)
            ps = srf.eval(u, v)
            pi = mean([pc, ps], axis=0)
            pi = Point(*pi)
            results.append([(t, u, v), pi])

        npts = len(results)
        self._set_results(npts, results)