OpenCascade.js
API ReferenceModelingAlgorithmsTKGeomAlgo

Hatch

OCCT package Hatch: Hatch_Hatcher, Hatch_Line, Hatch_LineForm, Hatch_Parameter.

Hatch_Hatcher

The Hatcher is an algorithm to compute cross hatchings in a 2d plane. It is mainly dedicated to display purpose.
Computing cross hatchings is a 3 steps process :

  1. The users stores in the Hatcher a set of 2d lines to be trimmed. Methods in the "Lines" category.
  2. The user trims the lines with a boundary. The inside of a boundary is on the left side. Methods in the "Trimming" category.
  3. The user reads back the trimmed lines. Methods in the "Results" category.
    The result is a set of parameter intervals on the line. The first parameter of an Interval may be RealFirst() and the last may be RealLast().
    A line can be a line parallel to the axis (X or Y line or a 2D line.
    The Hatcher has two modes :
  • The "Oriented" mode, where the orientation of the trimming curves is considered. The hatch are kept on the left of the trimming curve. In this mode infinite hatch can be computed.
  • The "UnOriented" mode, where the hatch are always finite.

Constructors(1)

  • constructor(Tol: number, Oriented?: boolean): Hatch_Hatcher

    Returns an empty hatcher. <Tol> is the tolerance for intersections.

    Parameters (2)
    • Tol
    • Oriented

Instance methods(21)

  • Tolerance(Tol: number): void
    Parameters (1)
    • Tol
  • Tolerance(): number
  • Add a line <L> to be trimmed. <T> the type is only kept from information. It is not used in the computation.

    Parameters (2)
    • L
    • T
  • AddLine(D: gp_Dir2d, Dist: number): void

    Add an infinite line on direction <D> at distance <Dist> from the origin to be trimmed. <Dist> may be negative.
    If O is the origin of the 2D plane, and V the vector perpendicular to D (in the direct direction).
    A point P is on the line if : OP dot V = Dist The parameter of P on the line is OP dot D

    Parameters (2)
    • D
    • Dist
  • AddXLine(X: number): void

    Add an infinite line parallel to the Y-axis at abciss <X>.

    Parameters (1)
    • X
  • AddYLine(Y: number): void

    Add an infinite line parallel to the X-axis at ordinate <Y>.

    Parameters (1)
    • Y
  • Trim(L: gp_Lin2d, Index: number): void

    Trims the lines at intersections with <L>.

    Parameters (2)
    • L
    • Index
  • Trim(L: gp_Lin2d, Start: number, End: number, Index: number): void

    Trims the lines at intersections with <L> in the parameter range <Start>, <End>.

    Parameters (4)
    • L
    • Start
    • End
    • Index
  • Trim(P1: gp_Pnt2d, P2: gp_Pnt2d, Index: number): void

    Trims the line at intersection with the oriented segment P1,P2.

    Parameters (3)
    • P1
    • P2
    • Index
  • NbIntervals(): number

    Returns the total number of intervals on all the lines.

  • NbIntervals(I: number): number

    Returns the number of intervals on line of index .

    Parameters (1)
    • I
  • NbLines(): number

    Returns the number of lines.

  • Line(I: number): gp_Lin2d

    Returns the line of index .

    Parameters (1)
    • I
  • Returns the type of the line of index .

    Parameters (1)
    • I
  • IsXLine(I: number): boolean

    Returns True if the line of index has a constant X value.

    Parameters (1)
    • I
  • IsYLine(I: number): boolean

    Returns True if the line of index has a constant Y value.

    Parameters (1)
    • I
  • Coordinate(I: number): number

    Returns the X or Y coordinate of the line of index if it is a X or a Y line.

    Parameters (1)
    • I
  • Start(I: number, J: number): number

    Returns the first parameter of interval <J> on line .

    Parameters (2)
    • I
    • J
  • StartIndex(I: number, J: number, Index: number, Par2: number): { Index: number; Par2: number }

    Returns the first Index and Par2 of interval <J> on line .

    Parameters (4)
    • I
    • J
    • Index
    • Par2
    Returns

    A result object with fields:

    • Index: updated value from the call.
    • Par2: updated value from the call.
  • End(I: number, J: number): number

    Returns the last parameter of interval <J> on line .

    Parameters (2)
    • I
    • J
  • EndIndex(I: number, J: number, Index: number, Par2: number): { Index: number; Par2: number }

    Returns the last Index and Par2 of interval <J> on line .

    Parameters (4)
    • I
    • J
    • Index
    • Par2
    Returns

    A result object with fields:

    • Index: updated value from the call.
    • Par2: updated value from the call.

Hatch_Line

Stores a Line in the Hatcher. Represented by:

  • A Lin2d from gp, the geometry of the line.
  • Bounding parameters for the line.
  • A sorted List of Parameters, the intersections on the line.

Constructors(2)

Instance methods(1)

  • AddIntersection(Par1: number, Start: boolean, Index: number, Par2: number, theToler: number): void

    Insert a new intersection in the sorted list.

    Parameters (5)
    • Par1
    • Start
    • Index
    • Par2
    • theToler