How to: Find a point on the surface of a model given a known window point

As part of the SelectionItem class in HPS, there is the function ShowSelectionPosition():
https://docs.techsoft3d.com/hps/latest/api_ref/cs/class_h_p_s_1_1_selection_item.html?highlight=showselectionposition#function-HPS.SelectionItem.ShowSelectionPosition
Depending on the variant of the function, it will return a WindowPoint or WorldPoint.

To demonstrate getting a WorldPoint, below is a code snippet that can be executed in the hps_mfc_sandbox Visual Studio project found in the directory:
HOOPS_Visualize_202X\samples\mfc_sandbox

void CHPSView::OnUserCode3()
{
	//First load model then run user code
	SegmentKey modelKey = _canvas.GetAttachedLayout().GetAttachedView().GetAttachedModel().GetSegmentKey();
	SegmentKey subsegmentKey = modelKey.Subsegment("sub");
	subsegmentKey.GetVisibilityControl().SetEverything(true);
	View view = _canvas.GetAttachedLayout().GetAttachedView();

	//Set a point in window space, for example, right in the center
	WindowPoint wp0(0, 0);

	SelectionOptionsKit selectionOptions;
	SelectionResults selectionResults;
	size_t numberOfSelectedItems;
	selectionOptions.SetLevel(Selection::Level::Entity).SetRelatedLimit(0).SetSorting(Selection::Sorting::ZSorting);
	numberOfSelectedItems = _canvas.GetWindowKey().GetSelectionControl().SelectByPoint(wp0, selectionOptions, selectionResults);

	SelectionResultsIterator it = selectionResults.GetIterator();
	WorldPoint selectionPosition;

	while (it.IsValid())
	{
		KeyPath selectionPath;
		SelectionItem selection = it.GetItem();

		//Get the position of the selection
		selection.ShowSelectionPosition(selectionPosition);

		it.Next();
	}

	//Insert marker in World space
	subsegmentKey.InsertMarker(selectionPosition);

	_canvas.UpdateWithNotifier().Wait();
}

A short video (with audio narration) demonstrating the code is also available: