Giter VIP home page Giter VIP logo

Comments (2)

trelau avatar trelau commented on June 12, 2024

Looks like an OCCT bug. When I use a fininte curve (a line is infinite) the intersection works:

circle = CircleByNormal(Point(0, 0, 0), Direction(0, 0, 1), 20).circle
line = LineByVector(Point(0, 0, 0), Direction(0, 1, 0)).line
line = TrimmedCurveByPoints(line, Point(0, -100, 0), Point(0, 100, 0)).curve
points = IntersectCurveCurve(circle, line).points

image

I'll add a unit test for this failing case with a line and hopefully a future OCCT update will fix this case. Until then, are you able to work around it by using a finite curve (either trim the line as shown or interpolate two points using a NURBS curve)?

from afem.

mnesarco avatar mnesarco commented on June 12, 2024

Hi @trelau ,
Yes I have noted that intersections with infinite curves does not work in some cases but i don't know why or when.
I am currently using only NURBS based line segments to do intersections as a workaround.

BTW I am using this code that maybe can be part of AFEM:

class LineSegmentByPoints:
    """
    Create a Line segment between two points.

    :param vector_like p1: Start point.
    :param vector_like p2: End point.
    """

    __slots__ = ('_segment',)

    def __init__(self, p1, p2):
        self._segment = NurbsCurveByInterp([p1, p2]).curve

    @property
    def segment(self):
        return self._segment

... And for Beziers:

class BezierCurve(Curve):
    """
    Bezier curve around ``Geom_BezierCurve``.
    """
    _OCC_TYPE = Geom_BezierCurve

    @classmethod
    def by_data(cls, cp, weights=None):
        """
        Create a Bezier curve by data.

        :param collections.Sequence(point_like) cp: Control points.
        :param collections.Sequence(float) weights: Weights of control points.
        """
        tcol_cp = occ_utils.to_tcolgp_array1_pnt(cp)
        if weights is None:
            weights = [1.] * tcol_cp.Length()
        tcol_weights = occ_utils.to_tcolstd_array1_real(weights)

        geom_crv = Geom_BezierCurve(tcol_cp, tcol_weights)
        return cls(geom_crv)


class BezierCurveByPoints:
    """
    Create a Bezier curve by control points.

    :param collections.Sequence(point_like) qp: Control points.
    :param collections.Sequence(float) weights: Poles weights.
    """

    __slots__ = ('_c',)

    def __init__(self, qp, weights=None):
        self._c = BezierCurve.by_data(qp, weights)

    @property
    def curve(self) -> BezierCurve:
        """
        The Bezier curve.
        """
        return self._c

from afem.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.