Sample Code: Extract cutting plane geometry

Language: C++

Sample code of extracting cutting plane geometry for mfc_sandbox.
Cutting Sections — HOOPS Visualize HPS Documentation 2022.0.0 documentation

:blue_book: Instructions

  1. Open \samples\data\turbine.hsf
  2. Run the user code below
void CHPSView::OnUserCode()
{
	HPS::SegmentKey mySegmentKey = GetCanvas().GetFrontView().GetSegmentKey();

	// enable visibility of cut geometry
	mySegmentKey.GetVisibilityControl().SetCutGeometry(true);

	// set the cutting depth for cutting section
	mySegmentKey.GetCuttingSectionAttributeControl()
		.SetCappingLevel(HPS::CuttingSection::CappingLevel::Segment)
		.SetCuttingLevel(HPS::CuttingSection::CuttingLevel::Global);

	// insert cutting section
	HPS::CuttingSectionKey cutterKey = mySegmentKey.InsertCuttingSection(HPS::Plane(HPS::Vector(1, 0, 0)));

	// Call update
	GetCanvas().GetFrontView().UpdateWithNotifier().Wait();

	// set gather depth
	HPS::CutGeometryGatheringOptionsKit opt;
	opt.SetLevel(CuttingSection::GatheringLevel::Segment);

	// build path
	HPS::SprocketPath sprocket_path(GetCanvas(), GetCanvas().GetAttachedLayout(), GetCanvas().GetFrontView(), GetCanvas().GetFrontView().GetAttachedModel());

	// put cut geometry into subsegment called "caps"
	sprocket_path.GetKeyPath().GatherCutGeometry(mySegmentKey.Subsegment("caps"), opt);

	// delete model to leave just the caps in place (optional)
	GetCanvas().GetFrontView().GetAttachedModel().Delete();

	GetCanvas().Update();
}

You need an update before gathering the cut geometry to get geometries.