|
|
|
|
#include "FITKOCCModelOperCompound.h"
|
|
|
|
|
|
|
|
|
|
// OCC base
|
|
|
|
|
#include <TopoDS.hxx>
|
|
|
|
|
#include <TopoDS_Solid.hxx>
|
|
|
|
|
#include <TopoDS_Builder.hxx>
|
|
|
|
|
#include <TopoDS_Compound.hxx>
|
|
|
|
|
|
|
|
|
|
// 倒角/倒圆
|
|
|
|
|
#include <BRepFilletAPI_MakeChamfer.hxx>
|
|
|
|
|
#include <BRepFilletAPI_MakeFillet.hxx>
|
|
|
|
|
|
|
|
|
|
// App
|
|
|
|
|
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
|
|
|
|
|
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
|
|
|
|
|
|
|
|
|
|
// Geometry
|
|
|
|
|
#include "FITKOCCVirtualTopoCreator.h"
|
|
|
|
|
#include <FITK_Interface/FITKInterfaceGeometry/FITKGeoEnum.h>
|
|
|
|
|
#include <FITK_Interface/FITKInterfaceGeometry/FITKVirtualTopoManager.h>
|
|
|
|
|
#include "FITK_Interface/FITKInterfaceGeometry/FITKGeoCommandList.h"
|
|
|
|
|
#include "FITK_Interface/FITKInterfaceGeometry/FITKGeoInterfaceFactory.h"
|
|
|
|
|
|
|
|
|
|
// Global data
|
|
|
|
|
#include "FITK_Kernel/FITKCore/FITKDataRepo.h"
|
|
|
|
|
|
|
|
|
|
#include "FITKOCCVirtualTopoCreator.h"
|
|
|
|
|
namespace OCC
|
|
|
|
|
{
|
|
|
|
|
// 基类构造。
|
|
|
|
|
//@{
|
|
|
|
|
FITKOCCModelOperCompound::FITKOCCModelOperCompound() : OCCShapeAgent(this)
|
|
|
|
|
{
|
|
|
|
|
_shapeAgent = _occShapeAgent;
|
|
|
|
|
}
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
// 复合体对象添加。
|
|
|
|
|
//@{
|
|
|
|
|
FITKOCCModelOperAddCompound::FITKOCCModelOperAddCompound()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
bool FITKOCCModelOperAddCompound::update()
|
|
|
|
|
{
|
|
|
|
|
TopoDS_Builder builder;
|
|
|
|
|
TopoDS_Compound comp;
|
|
|
|
|
builder.MakeCompound(comp);
|
|
|
|
|
|
|
|
|
|
if (m_solidCmdIds.size() < 1 || m_solidCmdId == nullptr) return false;
|
|
|
|
|
|
|
|
|
|
FITKAbsGeoCommand* comm = FITKDATAREPO->getTDataByID<FITKAbsGeoCommand>(m_solidCmdId->CmdId);
|
|
|
|
|
if (comm == nullptr) return false;
|
|
|
|
|
|
|
|
|
|
auto occShape = dynamic_cast<OCC::FITKAbstractOCCModel*>(comm->getShapeAgent());
|
|
|
|
|
if (occShape == nullptr) return false;
|
|
|
|
|
builder.Add(comp, *occShape->getShape());
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < m_solidCmdIds.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
//数据获取
|
|
|
|
|
comm = FITKDATAREPO->getTDataByID<FITKAbsGeoCommand>(m_solidCmdIds[i]->CmdId);
|
|
|
|
|
if (comm == nullptr) return false;
|
|
|
|
|
auto occShape = dynamic_cast<OCC::FITKAbstractOCCModel*>(comm->getShapeAgent());
|
|
|
|
|
if (occShape == nullptr) return false;
|
|
|
|
|
|
|
|
|
|
builder.Add(comp, *occShape->getShape());
|
|
|
|
|
}
|
|
|
|
|
_occShapeAgent->updateShape(comp);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// 复合体对象添加。
|
|
|
|
|
//@{
|
|
|
|
|
FITKOCCModelOperRemoveCompound::FITKOCCModelOperRemoveCompound()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FITKOCCModelOperRemoveCompound::update()
|
|
|
|
|
{
|
|
|
|
|
if (m_solidCmdIds.size() < 1 || m_solidCmdId == nullptr) return false;
|
|
|
|
|
|
|
|
|
|
TopoDS_Builder builder;
|
|
|
|
|
TopoDS_Compound comp;
|
|
|
|
|
builder.MakeCompound(comp);
|
|
|
|
|
|
|
|
|
|
Interface::FITKAbsVirtualTopo* vTopo = FITKDATAREPO->getTDataByID<Interface::FITKAbsVirtualTopo>(m_solidCmdId->VirtualTopoId);
|
|
|
|
|
if (vTopo == nullptr) return false;
|
|
|
|
|
int count = vTopo->getSubTopoCount();
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
auto vTopoShape = vTopo->getSubTopo(i);
|
|
|
|
|
if (vTopoShape == nullptr) return false;
|
|
|
|
|
bool isEqual = false;
|
|
|
|
|
for (int j = 0; j < m_solidCmdIds.size(); j++)
|
|
|
|
|
{
|
|
|
|
|
if (m_solidCmdIds[j]->VirtualTopoId != vTopoShape->getDataObjectID()) isEqual = true;
|
|
|
|
|
}
|
|
|
|
|
if (isEqual)
|
|
|
|
|
builder.Add(comp, vTopoShape->getShapeT<OCC::FITKOCCTopoShape>()->getTopoShape());
|
|
|
|
|
}
|
|
|
|
|
if (comp.IsNull()) return false;
|
|
|
|
|
_occShapeAgent->updateShape(comp);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
//@}
|
|
|
|
|
}
|