HOpObjectClash

class HOpObjectClash

The HOpObjectClash class detects and highlights objects that intersect a set of translated objects. The set of objects to be translated, a.k.a. “the part”, is assumed to be selected at the segment level prior to activating this operator. The computation can be done in several ways as described in HOOC_SelectMode but the most important mode that this operator demonstrates is HOOC_Shell. In that mode, shells from the scene, a.k.a “the environment”, are selected and highlighted if their faces cross the part’s faces.

This operator currently makes the (sometimes false) assumption that shells in the part are affected only by modelling matrices in their ancestry, as opposed to via some include path.

HOpObjectClash employs the transform functionality of HOpObjectTranslate to move an object around a scene, and extends two of the mouse event handlers defined on HOpObjectTranslate to perform clash detection. The operation consists of the following steps:

  1. Left Button Down: The operation is initiated. The translation objects are selected.
  2. Left Button Down and Drag: Clashed objects are highlighted.
  3. Left Button Up: The operation is ended. The clashed objects are deselected.

More Detailed Description: see event methods.

Inherits from: HOpObjectTranslate

Enumerations

Methods

int HOpObjectClash::IntersectPolyline(HC_KEY key1, float *transformed_points1)

protected

This method computes the polyline of intersection between two shells.

Parameters

key1: The key of the shell to find intersection with the selection shell.

transformed_points1: The point list of the shell.

Returns

The total number of intersecting line segments.
void HOpObjectClash::ProcessSelectionResults(HC_KEY current_shell = HC_ERROR_KEY, float *transformed_points = 0)

protected

This method loops through the selected object and all of the results from #HC_Find_Related_Selection, and send them to the appropriate HSelectionSet.

Parameters

current_shell: The key of the shell we want to highlight.

transformed_points: The point list of the shell.

int HOpObjectClash::TestEnclosure(HC_KEY current_shell_key, float *transformed_points)

protected

This is a helper function for ProcessSelectionResults(). It tests if the hit object encloses the shell.

Parameters

current_shell_key: The key of the shell that we want to test if it is enclosed by another object.

transformed_points: The point list of the shell.

Returns

An HOOC_Result describing if result of the enclosure test.
int HOpObjectClash::GetScreenVolume(HC_KEY seg, HPoint &min, HPoint &max)

protected

This method gets the screen space volume of the given segment, as seen by driver in the current view.

Parameters

seg: The key of segment in which you want to compute the bounding box.

min: Returns the minimum point of the bounding box volume.

max: Returns the maximum point of the bounding box volume.

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpObjectClash::SelectByScreenVolume(HSmartSelItem *sel_item)

protected virtual

This method finds if a given segment in screen space clashes with any other objects in the scene and then selects them. The selected items will be added to the current view’s selection list and highlighted as usual.

Parameters

seg: The key of the segment to perform clash detection on.

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpObjectClash::SelectByWorldVolume(HSmartSelItem *sel_item)

protected virtual

This method finds if a given segment in world space clashes with any other object in the scene and then selects them. The selected items will be added to the current view’s selection list and highlighted as usual.

Parameters

seg: The key of the segment to select.

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpObjectClash::SelectByEnclosure(HSmartSelItem *sel_item)

protected virtual

This method find if a given segment is fully enclosed by any other objects and then selects them. The selected items will be added to the current view’s selection list and highlighted as usual.

Parameters

seg: The key of the segment to select.

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpObjectClash::SelectByShell(HSmartSelItem *sel_item)

protected virtual

This method finds if a given shell clashes with any other shells and selects them. After selection, the selection list will contain all shells in the model that intersect the faces of the shells in the segment given by “seg”.

Parameters

seg: The key of the segment to check for clashes with other shells.

Returns

An HOperatorReturn indicating the status of the event.
void HOpObjectClash::SetSelectMode(int mode)

protected

This method sets the type of computing selection described in HOOC_SelectMode enum. HOOC_Shell is the default.

Parameters

mode: The mode in which you would like to perform selection and clash detection.
int HOpObjectClash::GetWorldVolume(HC_KEY seg, HPoint &min, HPoint &max)

protected

This method gets the world space volume of the given segment. This is a helper function to SelectByWorldVolume.

Parameters

seg: The key of segment in which you want to compute the bounding box.

min: Returns the minimum point of the bounding box volume.

max: Returns the maximum point of the bounding box volume.

Returns

An HOperatorReturn indicating the status of the event.
void HOpObjectClash::GrabSelectionSet()

protected

This method temporary “steals” the selection set from the HBaseView and replaces it with a new empty one.

void HOpObjectClash::RestoreSelectionSet()

protected

This method restores the selection set back to the HBaseView.

void HOpObjectClash::ClashDetect(HEventInfo &hevent)

protected

This method performs a translation on the selected objects and then highlights objects that intersected with them.

Parameters

hevent: An HEventInfo object containing information about the current event.
HOpObjectClash::HOpObjectClash(HBaseView *view, int doRepeat = 0, int doCapture = 1)

Constructs an HOpObjectClash object.

Parameters

view: A pointer to an HBaseView object,

DoRepeat: An integer denoting whether this is a repeatable operator. This parameter has been deprecated.

DoCapture: An integer denoting whether the mouse state should be captured, which means that all mouse events should be received after a mousedown, even if it leaves the window.

virtual HOpObjectClash::~HOpObjectClash()

virtual

The destructor restores the HBaseView‘s HSelectionSet to its state before this operator was initialized.

virtual char const *HOpObjectClash::GetName()

virtual

Returns

A pointer to a character string denoting the name of the operator which ‘HOpObjectClash‘.
virtual int HOpObjectClash::OnLButtonDown(HEventInfo &hevent)

virtual

OnLButtonDown records the first pointer position and initializes the translation mechanism. It then calls through to ClashDetect. It “steals” the view’s selection set and sets it as a member variable so that the objects with which collisions are detected can be put there.

Parameters

hevent: An HEventInfo object containing information about the current event.

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpObjectClash::OnLButtonDownAndMove(HEventInfo &hevent)

virtual

This method calls through to ClashDetect to do most of its work.

Parameters

hevent: An HEventInfo object containing information about the current event.

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpObjectClash::OnLButtonUp(HEventInfo &hevent)

virtual

OnLButtonUp deselects the highlighted objects.

Parameters

hevent: An HEventInfo object containing information about the current event.

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpObjectClash::OnKeyDown(HEventInfo &hevent)

virtual

This method grabs the following hot keys and then passes the rest to HBaseOperator.

  • d : This hot key puts the operator into screen selection mode where it computes the selections in screen space and looks for bounding box intersections.
  • e : This hot key puts the operator into enclosure selection mode where it detect if the original shell completely encloses the selected shell.
  • p : This hot key toggles on and off the indicate whether to calculate the polylines of intersection between objects that we find clashing.
  • s : This hot key puts the operator into shell selection mode where it looks for shells that intersect the faces of the current selection set in HBaseView. Use shell selection mode for accuracy.
  • w : This hot key puts the operator into world selection mode where it computes the selections in world space prior to camera tranformations and looks for bounding box intersections. Use world selection mode for speed.

Parameters

hevent: An HEventInfo object containing information about the current event.

Returns

An HOperatorReturn indicating the status of the event.
virtual HBaseOperator *HOpObjectClash::Clone()

virtual

Creates a new operator which is a copy of the current operator. The user is responsible for deleting the newly created operator.

Returns

A pointer to the newly created HOpObjectClash object.
virtual void HOpObjectClash::UpdateKeyList(void *data)

virtual

This method is used to update the list of keys to translate when the selection list changes.

Variables

bool HOpObjectClash::m_save_spriting_mode

protected

bool

The spriting mode before this operator started up which is restored on deletion.

HSelectionSet *HOpObjectClash::m_pClashSelection

protected

The set of objects being dragged around.

int HOpObjectClash::m_SelectMode

protected

int

The type of computing selection described in HOOC_SelectMode enum. HOOC_Shell is the default.

int HOpObjectClash::m_IntersectPolylinesVisible

protected

int

A boolean to indicate whether or not to calculate the polylines of intersection between objects that we find clashing.

HC_KEY HOpObjectClash::m_TempSegKey

protected

HC_KEY

The key to the segment into which the text overlay, with a transparent window, is put.