#include "FITKComponentCreator.h" #include "FITK_Kernel/FITKCore/FITKDataRepo.h" #include "FITK_Interface/FITKInterfaceModel/FITKAbstractModel.h" #include "FITK_Interface/FITKInterfaceModel/FITKModelSet.h" #include "FITK_Interface/FITKInterfaceModel/FITKComponentManager.h" #include "FITK_Interface/FITKInterfaceModel/FITKMeshSurfaceElement.h" namespace Interface { FITKComponentCreator::FITKComponentCreator(FITKComponentManager* manager) :_compManager(manager) { } void FITKComponentCreator::setName(const QString& name) { _name = name; } void FITKComponentCreator::isInternal(const bool internal) { _internal = internal; } FITKModelSet* FITKComponentCreator::createNodeSet(const int &parentID, const QList & member) { //创建集合,不区分类型 auto set = createSet(parentID, member); //设置为节点类型 if(set) set->setModelSetType(Interface::FITKModelEnum::FITKModelSetType::FMSNode); return set; } FITKModelSet* FITKComponentCreator::createEleSet(const int &parentID, const QList & member) { //创建集合,不区分类型 auto set = createSet(parentID, member); //设置为单元类型 if (set) set->setModelSetType(Interface::FITKModelEnum::FITKModelSetType::FMSElem); return set; } FITKMeshSurface* FITKComponentCreator::createEleSurface(QHash& setSurfaceIndex) { if (_compManager == nullptr || setSurfaceIndex.isEmpty()) return nullptr; QList sets = setSurfaceIndex.keys(); FITKMeshSurfaceElement* surf = new FITKMeshSurfaceElement; surf->setModel(_compManager->getMParentDataIDM()); surf->setDataObjectName(_name); for (Interface::FITKModelSet* set :sets) { if(set == nullptr) continue; const int surfIndex = setSurfaceIndex.value(set); if(surfIndex <0) continue; surf->addMeshSet(set->getAbstractModel(), set, surfIndex); } _compManager->appendDataObj(surf); return surf; } FITKModelSet* FITKComponentCreator::createSet(const int &parentID, const QList & member) { //错误判断 if (_compManager == nullptr) return nullptr; Interface::FITKAbstractModel* model = FITKDATAREPO->getTDataByID(parentID); if (model == nullptr) return nullptr; if (member.isEmpty()) return nullptr; //创建集合 Interface::FITKModelSet* set = new Interface::FITKModelSet; set->setDataObjectName(_name); set->setInternal(_internal); set->setModel(parentID); set->setAbsoluteMember(member); //添加到管理器 _compManager->appendDataObj(set); return set; } }