You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AppFlow/FITK_Interface/FITKInterfaceModel/FITKComponentCreator.cpp

92 lines
2.9 KiB
C++

#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<int> & member)
{
//创建集合,不区分类型
auto set = createSet(parentID, member);
//设置为节点类型
if(set)
set->setModelSetType(Interface::FITKModelEnum::FITKModelSetType::FMSNode);
return set;
}
FITKModelSet* FITKComponentCreator::createEleSet(const int &parentID, const QList<int> & member)
{
//创建集合,不区分类型
auto set = createSet(parentID, member);
//设置为单元类型
if (set)
set->setModelSetType(Interface::FITKModelEnum::FITKModelSetType::FMSElem);
return set;
}
FITKMeshSurface* FITKComponentCreator::createEleSurface(QHash<Interface::FITKModelSet*, int >& setSurfaceIndex)
{
if (_compManager == nullptr || setSurfaceIndex.isEmpty()) return nullptr;
QList<Interface::FITKModelSet*> 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<int> & member)
{
//错误判断
if (_compManager == nullptr) return nullptr;
Interface::FITKAbstractModel* model = FITKDATAREPO->getTDataByID<Interface::FITKAbstractModel>(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;
}
}