# HUtilityBoolean

## Functions

void | `SplitTarget`
HC_KEY | `MakeWindingConsistent`
void | `CutBlock`
HC_KEY | `MakeBoolean`
void | `ProjectShell`
void | `UnProjectShell`
HC_KEY | `DMakeBoolean`
void | `DProjectShell`
void | `DUnProjectShell`
HC_KEY | `DCalculateSilhouette`
HC_KEY | `CalculateSilhouette`
int | `ObjectMovedEvent`
bool | `TestCollision`

## Detailed Description

class HUtilityBoolean

  The HUtilityBoolean class contains a set of utility functions related to the polygonal boolean functionality.

  HUtilityBoolean includes utility functions for using the 3DGS boolean functionality in interactive boolean Applications like n-degree milling.

  Public Static Functions

  static void SplitTarget(HBaseView *view, HC_KEY targetshell)

    Splits a shell in all three dimensions to allow for localization of boolean operations. The newly created geometry will reside in child segments of the segment which contains the original shell.

    Parameters

      - view – Pointer to HBaseView object

      - targetshell – Key of Shell which will be cut

  static HC_KEY MakeWindingConsistent(HC_KEY shellkey)

    Identifies faces with inconsistent handedness inside a shell and “repairs” those faces

    Parameters

      shellkey – Shell Key

    Returns

      new shell with consistent handedness

  static void CutBlock(HBaseView *m_pHView, HC_KEY targetshell, int side, int slicenum)

    Splits a target shell along one of the three major axis

    Parameters

      - targetshell – Shell to split

      - side – 0 to 3 indicating the split axis 0 = x, 1 = y, 2 = z

      - slicenum – Number of cuts along the indicated axis

  static HC_KEY MakeBoolean(HC_KEY s1, HC_KEY s2, char *whattype, bool doTransform = false)

    Performs a boolean operation of one shell with another

    Parameters

      - s1 – Shell Key representing the “Tool” of the boolean operation

      - s2 – Shell Key representing the “Target” of the boolean operation

      - whattype – string passed into HC_Compute_Boolean_Shell function determening the type of boolean operation

      - doTransform – If true the resulting shell is transformed by the modelling matrix of the currently open segment after the operation

    Returns

      Key to shell which represents the result of the boolean operation

  static void ProjectShell(HC_KEY shellkey, int plen, HPoint *points, int flen, int *faces)

    Projects shell by the modelling matrix of its containing segment

    Parameters

      - shelllkey – Key to Shell

      - plen – Length of Point Array which contains the projected points of the shell

      - points – Point Array which contains the projected points of the shell

      - flen – Length of Face List Array

      - faces – Face List Array

  static void UnProjectShell(HC_KEY shellkey)

    Modifies the point list of an existing shell by the inverse of the modelling matrix of its containing segment

    Parameters

      shelllkey – Key to Shell

  static HC_KEY DMakeBoolean(HC_KEY s1, HC_KEY s2, char *whattype, bool doTransform = false)

    Performs a boolean operation of one shell with another using double precision

    Parameters

      - s1 – Shell Key representing the “Tool” of the boolean operation

      - s2 – Shell Key representing the “Target” of the boolean operation

      - whattype – string passed into HC_Compute_Boolean_Shell function determening the type of boolean operation

      - doTransform – If true the resulting shell is transformed by the modelling matrix of the currently open segment after the operation

    Returns

      Key to shell which represents the result of the boolean operation

  static void DProjectShell(HC_KEY shellkey, int plen, HDPoint *points, int flen, int *faces)

    Projects shell by the modelling matrix of its containing segment using double precision

    Parameters

      - shelllkey – Key to Shell

      - plen – Length of Point Array which contains the projected points of the shell

      - points – Point Array which contains the projected points of the shell

      - flen – Length of Face List Array

      - faces – Face List Array

  static void DUnProjectShell(HC_KEY shellkey)

    Modifies the point list of an existing shell by the inverse of the modelling matrix of its containing segment. Uses Double Precision

    Parameters

      shelllkey – Key to Shell

  static HC_KEY DCalculateSilhouette(HC_KEY targetshell, HPoint start, HPoint end)

    Calculates the silhouette for a given shell given the start and end point. The resulting shell will be placed in a segment called “sil” underneath the segment containing the referenced shell. The result shell will be double precision

    Parameters

      - targetshell – Key of shell to calculate the silhouette for

      - start – Start Point for silhouette calculation

      - end – End Point for silhouette calculation

    Returns

      Key of Shell representing the silhouette

  static HC_KEY CalculateSilhouette(HC_KEY targetshell, HPoint start, HPoint end)

    Calculates the silhouette for a given shell given the start and end point. The resulting shell will be placed in a segment called “sil” underneath the segment containing the referenced shell.

    Parameters

      - targetshell – Key of shell to calculate the silhouette for

      - start – Start Point for silhouette calculation

      - end – End Point for silhouette calculation

    Returns

      Key of Shell representing the silhouette

  static int ObjectMovedEvent(HBaseView *view, HC_KEY key, HPoint *p, HPoint posbeforemovedevent)

    This funcion should be called after an ObjectMovedEvent has been triggered from an HObjectManipulationListener

    Parameters

      - view – Pointer to HBaseView object

      - key – Key of moved geometry

      - p – New Position

      - posbeforemovedevent – Old Position

    Returns

      Event Return

  static bool TestCollision(HBaseView *view, HC_KEY key1, HC_KEY key2, bool first, bool doTransform1, bool doTransform2)

    Determines if a collision occured between the bounding boxes of two shells

    Parameters

      - key1 – First shell to determine collision for

      - key2 – Second shell to determine collision for

      - first – If true testcollision is called for the first time and default parameters are calculated

      - doTransform1 – If true perform a projection of first shell

      - doTransform1 – If true perform a projection of second shell

    Returns

      True if collision occured