Creating a DeleteBody Function Similar to AddBody in CHPSView

Hello,

I am working with HOOPS Visualize, Exchange, and Parasolid, and I am seeking guidance on creating a DeleteBody function in the CHPSView class, similar to the existing AddBody function, as shown below. The AddBody function enables updating the visualization after Parasolid operations, such as Boolean operations. I would like to implement a DeleteBody function that would allow me to delete a body without manually selecting it, and update the Visualize. I looked at the documentation here Exchange-Parasolid which mentions using " HPS::Component::Delete (for geometry that was deleted, like the tool)" but wasn’t successful in implementation.

I would greatly appreciate any help and guidance.

Thank you!

#ifdef USING_EXCHANGE_PARASOLID

void CHPSView::AddBody(const int body)
{
	HPS::CADModel cadModel = GetDocument()->GetCADModel();
	HPS::Type type = cadModel.Type();

	HPS::Exchange::CADModel exCadModel;
	HPS::Component comp;

	HPS::MatrixKit translation;
	translation.Translate(0.0f, 0.0f, 0.0f);

	if (HPS::Type::ExchangeCADModel != type)
	{
		exCadModel = HPS::Exchange::Factory::CreateCADModel();
		comp = HPS::ExchangeParasolid::File::AddEntity(exCadModel, body, translation);

		// Create PsComponent mapper
		if (NULL != m_psMapper)
			delete m_psMapper;
		m_psMapper = new PsComponentMapper(exCadModel);
	}
	else
	{
		exCadModel = (HPS::Exchange::CADModel)cadModel;
		if (((ExPsProcess*)m_pProcess)->m_bIsPart)
			//comp = HPS::ExchangeParasolid::File::AddEntity(m_addCompPath, body, translation);
			comp = HPS::ExchangeParasolid::File::AddEntity(exCadModel, body, translation);
		else
			comp = HPS::ExchangeParasolid::File::AddEntity(exCadModel, body, translation);

		// PsComponent mapper
		InitPsBodyMap((int)body, comp);
	}

	if (HPS::Type::ExchangeCADModel != type)
	{
		// Create component path for adding body
		HPS::Component::ComponentType compType = comp.GetComponentType();

		while (HPS::Component::ComponentType::ExchangePartDefinition != compType)
		{
			HPS::ComponentArray compArr = comp.GetOwners();
			comp = compArr[0];
			compType = comp.GetComponentType();
		}

		HPS::ComponentArray compPathArr;
		compPathArr.push_back(comp);

		while (HPS::Component::ComponentType::ExchangeModelFile != compType)
		{
			HPS::ComponentArray compArr = comp.GetOwners();
			comp = compArr[0];
			compType = comp.GetComponentType();

			compPathArr.push_back(comp);
		}

		m_addCompPath = HPS::ComponentPath(compPathArr);

		// Set model file
		((ExPsProcess*)m_pProcess)->SetModelFile(exCadModel.GetExchangeEntity());

		// Set model to view
		GetCanvas().GetFrontView().AttachModel(exCadModel.GetModel());

		// Set CAD model
		GetDocument()->SetCADModel(exCadModel.GetModel());

		GetCanvas().GetFrontView().FitWorld();
	}
}