#include "FITKOCCModelOperCompound.h" // OCC base #include #include #include #include // 倒角/倒圆 #include #include // App #include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h" #include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h" // Geometry #include "FITKOCCVirtualTopoCreator.h" #include #include #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(m_solidCmdId->CmdId); if (comm == nullptr) return false; auto occShape = dynamic_cast(comm->getShapeAgent()); if (occShape == nullptr) return false; builder.Add(comp, *occShape->getShape()); for (int i = 0; i < m_solidCmdIds.size(); ++i) { //数据获取 comm = FITKDATAREPO->getTDataByID(m_solidCmdIds[i]->CmdId); if (comm == nullptr) return false; auto occShape = dynamic_cast(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(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()->getTopoShape()); } if (comp.IsNull()) return false; _occShapeAgent->updateShape(comp); return true; } //@} }