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/FITKInterfaceGeoIOHDF5/FITKInterfaceHDF5AdaptorCom...

517 lines
27 KiB
C++

#include "FITKInterfaceHDF5AdaptorCommand.h"
#include "FITK_Interface/FITKInterfaceGeometry/FITKGeoCommandList.h"
#include <QMetaEnum>
namespace IO
{
// Base.
//@{
QString FITKInterfaceHDF5AdaptorCommand::getAdaptorClass()
{
return "FITKInterfaceHDF5AdaptorCommand";
}
bool FITKInterfaceHDF5AdaptorCommand::adaptR()
{
auto comm = dynamic_cast<Interface::FITKAbsGeoCommand*>(_dataObj);
if (!_reader || !comm || !_h5Group) return false;
return read(comm, *_h5Group);
}
bool FITKInterfaceHDF5AdaptorCommand::adaptW()
{
auto comm = dynamic_cast<Interface::FITKAbsGeoCommand*>(_dataObj);
if (!_writer || !comm || !_h5Group) return false;
return write(comm, *_h5Group);
}
bool FITKInterfaceHDF5AdaptorCommand::read(Interface::FITKAbsGeoCommand* comm, H5::Group& h5Group)
{
if (comm == nullptr || h5Group.getLocId() == -1) return false;
//获取命令类型
auto commType = comm->getGeometryCommandType();
if (!readCommand(comm, h5Group)) return false;
auto parameterGroup = h5Group.openGroup("Parameter");
switch (commType)
{
case Interface::FITKGeoEnum::FGTPoint:
case Interface::FITKGeoEnum::FGTCurveEnd:
case Interface::FITKGeoEnum::FGTCurveEndDistance:
case Interface::FITKGeoEnum::FGTCurveRadio:
case Interface::FITKGeoEnum::FGTPointProjectionOnCurve:
case Interface::FITKGeoEnum::FGTTwoCurveIntersectPoint:
case Interface::FITKGeoEnum::FGTPointProjectionOnSurface:
case Interface::FITKGeoEnum::FGTCurveIntersectSurface:
return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelPoint");
//Oper Point
case Interface::FITKGeoEnum::FGTSurfaceIntersectSurface:
return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelPoint");
//curve
case Interface::FITKGeoEnum::FGTLine:
case Interface::FITKGeoEnum::FGTSegment:
case Interface::FITKGeoEnum::FGTWire:
case Interface::FITKGeoEnum::FGTCircle:
case Interface::FITKGeoEnum::FGTCircleArc:
case Interface::FITKGeoEnum::FGTEllipse:
case Interface::FITKGeoEnum::FGTEllipseArc:
case Interface::FITKGeoEnum::FGTHyperbola:
case Interface::FITKGeoEnum::FGTHyperbolaArc:
case Interface::FITKGeoEnum::FGTParabola:
case Interface::FITKGeoEnum::FGTParabolaArc:
case Interface::FITKGeoEnum::FGTOffsetCurve:
//Bezier Bspline
case Interface::FITKGeoEnum::FGTBezierByControlPoints:
case Interface::FITKGeoEnum::FGTBezierByThroughPoints:
case Interface::FITKGeoEnum::FGTBSplineByControlPoints:
case Interface::FITKGeoEnum::FGTBSplineByThroughPoints:
//ThreePoints
case Interface::FITKGeoEnum::FGTThreePointsCircle:
case Interface::FITKGeoEnum::FGTThreePointsEllipse:
case Interface::FITKGeoEnum::FGTThreePointsHyperbola:
case Interface::FITKGeoEnum::FGTThreePointsParabola:
case Interface::FITKGeoEnum::FGTCurveFromSurface:
case Interface::FITKGeoEnum::FGTCurveProjectionOnSurface:
return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelCurve");
//Oper Line
case Interface::FITKGeoEnum::FGTMergeLine:
case Interface::FITKGeoEnum::FGTSplitByMiddlePositionLine:
case Interface::FITKGeoEnum::FGTSplitByAngleLine:
case Interface::FITKGeoEnum::FGTDeleteFloatingEdge:
case Interface::FITKGeoEnum::FGTBridgeCurve:
return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelOperLine");
//Face
case Interface::FITKGeoEnum::FGTBridgeSurface:
case Interface::FITKGeoEnum::FGTSurfaceFromSolid:
case Interface::FITKGeoEnum::FGTMultiSectionSurface:
case Interface::FITKGeoEnum::FGTSweepSurface:
case Interface::FITKGeoEnum::FGTRevolSurface:
case Interface::FITKGeoEnum::FGTExtrudeSurface:
case Interface::FITKGeoEnum::FGTOffsetSurface:
case Interface::FITKGeoEnum::FGTClosedWireSurface:
return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelSurface");
//Oper Face
case Interface::FITKGeoEnum::FGTRectangularTrimmedSurface: return false;
//Solid
case Interface::FITKGeoEnum::FGTBox: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelBox");
case Interface::FITKGeoEnum::FGTSphere: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelSphere");
case Interface::FITKGeoEnum::FGTCylinder: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelCylinder");
//oper solid
case Interface::FITKGeoEnum::FGTChamferSolid: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelChamferSolid");
case Interface::FITKGeoEnum::FGTRemoveChamfer: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelRemoveChamferSolid");
case Interface::FITKGeoEnum::FGTFilletSolid: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelFilletSolid");
case Interface::FITKGeoEnum::FGTRemoveFillet: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelRemoveFilletSolid");
case Interface::FITKGeoEnum::FGTDefeature: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelDefeatureSolid");
case Interface::FITKGeoEnum::FGTFillHole: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelFillHoleSolid");
case Interface::FITKGeoEnum::FGTClosedSurfaceSolid: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelClosedSurfaceSolid");
case Interface::FITKGeoEnum::FGTExtrudeSolid: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelExtrudeSolid");
case Interface::FITKGeoEnum::FGTRevolSolid: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelRevolSolid");
case Interface::FITKGeoEnum::FGTSweepSolid: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelSweepSolid");
case Interface::FITKGeoEnum::FGTMultiSectionSolid: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelMultiSectionSolid");
//oper
case Interface::FITKGeoEnum::FGTDelete: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoDelete");
//Bool
case Interface::FITKGeoEnum::FGTBool: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoOperBool");
//Oper Solid
case Interface::FITKGeoEnum::FGTImprintSolid: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelOperImprintSolid");
case Interface::FITKGeoEnum::FGTFillGapsFace: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelOperFace");
case Interface::FITKGeoEnum::FGTImport: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelImport");
case Interface::FITKGeoEnum::FGTExport: return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelExport");
case Interface::FITKGeoEnum::FGTTrimmed: return false;
//Oper Face
case Interface::FITKGeoEnum::FGTFillHolesFace: return false;
case Interface::FITKGeoEnum::FGTImprintMapPointToFace: return false;
case Interface::FITKGeoEnum::FGTImprintMapLineToFace: return false;
//Oper Compound
case Interface::FITKGeoEnum::FGTCompoundAppendShape:
case Interface::FITKGeoEnum::FGTCompoundRemoveShape:
return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelOperCompound");
//Skecth
case Interface::FITKGeoEnum::FGTSketch2D:
return readGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoSketch2D");
default: return false;
}
return false;
}
bool FITKInterfaceHDF5AdaptorCommand::write(Interface::FITKAbsGeoCommand* comm, H5::Group& h5Group)
{
if (comm == nullptr || h5Group.getLocId() == -1) return false;
//获取命令类型
auto commType = comm->getGeometryCommandType();
if (commType == Interface::FITKGeoEnum::FITKGeometryComType::FGTNone) return false;
if (!writeCommand(comm, h5Group)) return false;
auto parameterGroup = _h5CreateGroup.createGroup("Parameter");
switch (commType)
{
case Interface::FITKGeoEnum::FGTPoint:
case Interface::FITKGeoEnum::FGTCurveEnd:
case Interface::FITKGeoEnum::FGTCurveEndDistance:
case Interface::FITKGeoEnum::FGTCurveRadio:
case Interface::FITKGeoEnum::FGTPointProjectionOnCurve:
case Interface::FITKGeoEnum::FGTTwoCurveIntersectPoint:
case Interface::FITKGeoEnum::FGTPointProjectionOnSurface:
case Interface::FITKGeoEnum::FGTCurveIntersectSurface:
return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelPoint");
//Oper Point
case Interface::FITKGeoEnum::FGTSurfaceIntersectSurface:
return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelPoint");
//curve
case Interface::FITKGeoEnum::FGTLine:
case Interface::FITKGeoEnum::FGTSegment:
case Interface::FITKGeoEnum::FGTWire:
case Interface::FITKGeoEnum::FGTCircle:
case Interface::FITKGeoEnum::FGTCircleArc:
case Interface::FITKGeoEnum::FGTEllipse:
case Interface::FITKGeoEnum::FGTEllipseArc:
case Interface::FITKGeoEnum::FGTHyperbola:
case Interface::FITKGeoEnum::FGTHyperbolaArc:
case Interface::FITKGeoEnum::FGTParabola:
case Interface::FITKGeoEnum::FGTParabolaArc:
case Interface::FITKGeoEnum::FGTOffsetCurve:
//Bezier Bspline
case Interface::FITKGeoEnum::FGTBezierByControlPoints:
case Interface::FITKGeoEnum::FGTBezierByThroughPoints:
case Interface::FITKGeoEnum::FGTBSplineByControlPoints:
case Interface::FITKGeoEnum::FGTBSplineByThroughPoints:
//ThreePoints
case Interface::FITKGeoEnum::FGTThreePointsCircle:
case Interface::FITKGeoEnum::FGTThreePointsEllipse:
case Interface::FITKGeoEnum::FGTThreePointsHyperbola:
case Interface::FITKGeoEnum::FGTThreePointsParabola:
case Interface::FITKGeoEnum::FGTCurveFromSurface:
case Interface::FITKGeoEnum::FGTCurveProjectionOnSurface:
return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelCurve");
//Oper Line
case Interface::FITKGeoEnum::FGTMergeLine:
case Interface::FITKGeoEnum::FGTSplitByMiddlePositionLine:
case Interface::FITKGeoEnum::FGTSplitByAngleLine:
case Interface::FITKGeoEnum::FGTDeleteFloatingEdge:
case Interface::FITKGeoEnum::FGTBridgeCurve:
return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelOperLine");
//Face
case Interface::FITKGeoEnum::FGTBridgeSurface:
case Interface::FITKGeoEnum::FGTSurfaceFromSolid:
case Interface::FITKGeoEnum::FGTMultiSectionSurface:
case Interface::FITKGeoEnum::FGTSweepSurface:
case Interface::FITKGeoEnum::FGTRevolSurface:
case Interface::FITKGeoEnum::FGTExtrudeSurface:
case Interface::FITKGeoEnum::FGTOffsetSurface:
case Interface::FITKGeoEnum::FGTClosedWireSurface:
return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelSurface");
//Oper Face
case Interface::FITKGeoEnum::FGTRectangularTrimmedSurface: return false;
//Solid
case Interface::FITKGeoEnum::FGTBox: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelBox");
case Interface::FITKGeoEnum::FGTSphere: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelSphere");
case Interface::FITKGeoEnum::FGTCylinder: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelCylinder");
//oper solid
case Interface::FITKGeoEnum::FGTChamferSolid: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelChamferSolid");
case Interface::FITKGeoEnum::FGTRemoveChamfer: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelRemoveChamferSolid");
case Interface::FITKGeoEnum::FGTFilletSolid: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelFilletSolid");
case Interface::FITKGeoEnum::FGTRemoveFillet: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelRemoveFilletSolid");
case Interface::FITKGeoEnum::FGTDefeature: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelDefeatureSolid");
case Interface::FITKGeoEnum::FGTFillHole: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelFillHoleSolid");
case Interface::FITKGeoEnum::FGTClosedSurfaceSolid: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelClosedSurfaceSolid");
case Interface::FITKGeoEnum::FGTExtrudeSolid: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelExtrudeSolid");
case Interface::FITKGeoEnum::FGTRevolSolid: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelRevolSolid");
case Interface::FITKGeoEnum::FGTSweepSolid: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelSweepSolid");
case Interface::FITKGeoEnum::FGTMultiSectionSolid: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelMultiSectionSolid");
//oper
case Interface::FITKGeoEnum::FGTDelete: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoDelete");
//Bool
case Interface::FITKGeoEnum::FGTBool: return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoOperBool");
//Oper Solid
case Interface::FITKGeoEnum::FGTImprintSolid:
return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelOperImprintSolid");
case Interface::FITKGeoEnum::FGTFillGapsFace:
return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelOperFace");
case Interface::FITKGeoEnum::FGTImport:
return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelImport");
case Interface::FITKGeoEnum::FGTExport:
return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelExport");
case Interface::FITKGeoEnum::FGTTrimmed: return false;
//Oper Face
case Interface::FITKGeoEnum::FGTFillHolesFace: return false;
case Interface::FITKGeoEnum::FGTImprintMapPointToFace: return false;
case Interface::FITKGeoEnum::FGTImprintMapLineToFace: return false;
//Oper Compound
case Interface::FITKGeoEnum::FGTCompoundAppendShape:
case Interface::FITKGeoEnum::FGTCompoundRemoveShape:
return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoModelOperCompound");
//Skecth
case Interface::FITKGeoEnum::FGTSketch2D:
return writeGeometryAdaptor(comm, parameterGroup, "Interface::FITKAbsGeoSketch2D");
default: return false;
}
return false;
}
bool FITKInterfaceHDF5AdaptorCommand::readCommand(Interface::FITKAbsGeoCommand* comm, H5::Group& h5Group)
{
if (!comm) return false;
if (!readNDataObject(comm, h5Group)) return false;
std::string str = readStrAttribute(h5Group, "CommandStatus");
if (str.empty()) return false;
QMetaEnum metaEnum = QMetaEnum::fromType<Interface::FITKGeoEnum::FITKGeoStatus>();
Interface::FITKGeoEnum::FITKGeoStatus status = (Interface::FITKGeoEnum::FITKGeoStatus)metaEnum.keyToValue(str.c_str());
comm->setCommandStatus(status);
int modifiedCmdID = readIntAttribute(h5Group, "ModifiedCmdID");
comm->setModifiedCmdID(modifiedCmdID);
int referenceCmdCount = readIntAttribute(h5Group, "ReferenceCmdCount");
//打开子节点
auto _h5ReferenceCmdIDGroup = h5Group.openGroup("ReferenceCmdID");
auto _h5ReferenceCmdTypeGroup = h5Group.openGroup("ReferenceCmdType");
for (int i = 0; i < referenceCmdCount; i++)
{
int refID = readIntAttribute(_h5ReferenceCmdIDGroup, std::to_string(i));
comm->addReferenceCmdID(refID);
}
bool reference = readBoolAttribute(h5Group, "EnableReferenceList");
comm->enableReferenceList(reference);
return readChildVirtualShape(comm, h5Group);
}
bool FITKInterfaceHDF5AdaptorCommand::writeCommand(Interface::FITKAbsGeoCommand* comm, H5::Group& h5Group)
{
QMetaEnum metaEnum;
if (!comm) return false;
std::string groupName = createParentAttribute(comm, h5Group);
if (groupName.empty())return false;
_h5CreateGroup = h5Group.createGroup(groupName);
bool isW = writeNDataObject(comm, _h5CreateGroup);
metaEnum = QMetaEnum::fromType<Interface::FITKGeoEnum::FITKGeoStatus>();
std::string str = metaEnum.valueToKey(comm->getCommandStatus());
if (str.empty()) return false;
writeStrAttribute(_h5CreateGroup, "CommandStatus", str);
metaEnum = QMetaEnum::fromType<Interface::FITKGeoEnum::FITKGeometryComType>();
str = metaEnum.valueToKey(comm->getGeometryCommandType());
if (str.empty()) return false;
writeStrAttribute(_h5CreateGroup, "GeometryCommandType", str);
int modifiedCmdID = comm->getModifiedCmdID();
writeIntAttribute(_h5CreateGroup, "ModifiedCmdID", &modifiedCmdID);
int referenceCmdCount = comm->getReferenceCmdCount();
writeIntAttribute(_h5CreateGroup, "ReferenceCmdCount", &referenceCmdCount);
//创建子节点
auto _h5ReferenceCmdIDGroup = _h5CreateGroup.createGroup("ReferenceCmdID");
auto _h5ReferenceCmdTypeGroup = _h5CreateGroup.createGroup("ReferenceCmdType");
for (int i = 0; i < referenceCmdCount; i++)
{
auto refComm = comm->getReferenceCmdByIndex(i);
if (refComm == nullptr) return false; //判断异常
int refID = refComm->getDataObjectID();
writeIntAttribute(_h5ReferenceCmdIDGroup, std::to_string(i), &refID);
//写出类型
//metaEnum = QMetaEnum::fromType<Interface::FITKGeoEnum::FITKGeometryComType>();
//str = metaEnum.valueToKey(refComm->getGeometryCommandType());
//if (str.empty()) return false; //判断异常
//writeStrAttribute(_h5ReferenceCmdTypeGroup, "GeometryCommandType", str);
}
bool reference = comm->getEnableReferenceList();
writeBoolAttribute(_h5CreateGroup, "EnableReferenceList", &reference);
isW &= writeChildVirtualShape(comm, _h5CreateGroup);
return isW;
}
bool FITKInterfaceHDF5AdaptorCommand::readChildVirtualShape(Interface::FITKAbsGeoCommand * comm, H5::Group & h5Group, bool isSaveShape)
{
if (comm == nullptr) return false;
auto agent = comm->getShapeAgent();
if (agent == nullptr) return true;
auto manager = agent->getVirtualTopoManager();
if (manager == nullptr) return true;
QMetaEnum m = QMetaEnum::fromType<Interface::FITKGeoEnum::VTopoShapeType>();
int vTopoShapeTypeCount = m.keyCount();
//实际存储类型
int shapeTypeCount = 0;
auto vTopoShapeManagerGroup = h5Group.openGroup("vTopoShapeManager");
int virtualTopoManagerRootID = readIntAttribute(h5Group, "VirtualTopoManagerRootID");
for (int i = vTopoShapeTypeCount - 1; i > 0; i--)
{
auto shapeManager = manager->getShapeVirtualTopoManager((Interface::FITKGeoEnum::VTopoShapeType)i);
if (shapeManager == nullptr) return false;
std::string vTopoTypeStr = readStrAttribute(vTopoShapeManagerGroup, std::to_string(i - 1));
if (!vTopoShapeManagerGroup.nameExists(vTopoTypeStr)) continue;
auto vTopoTypeGroup = vTopoShapeManagerGroup.openGroup(vTopoTypeStr);
int count = readIntAttribute(vTopoTypeGroup, "Count");
for (int j = 0; j < count; j++)
{
auto vTopoShapeGroup = vTopoTypeGroup.openGroup(std::to_string(j));
auto vIndexLabelTopoShapeGroup = vTopoShapeGroup.openGroup("IndexLabel");
Interface::FITKAbsVirtualTopo* vt = new Interface::FITKAbsVirtualTopo();
vt->setShapeType((Interface::FITKGeoEnum::VTopoShapeType)i);
if (!readDataObject(vt, vTopoShapeGroup))
{
delete vt;
return false;
}
int indexLabel = readIntAttribute(vIndexLabelTopoShapeGroup, "LndexLabel");
qDebug() << 1 << vt << "" << indexLabel;
vt->setIndexLabel(indexLabel);
shapeManager->appendDataObj(vt);
//设置根节点
int dataObjectID = readIntAttribute(vTopoShapeGroup, "DataObjectID");
if (dataObjectID == virtualTopoManagerRootID)
{
manager->setRootObj(vt);
}
}
}
for (int i = vTopoShapeTypeCount - 1; i > 0; i--)
{
auto shapeManager = manager->getShapeVirtualTopoManager((Interface::FITKGeoEnum::VTopoShapeType)i);
if (shapeManager == nullptr) return false;
auto vTopoShapeManagerGroup = h5Group.openGroup("vTopoShapeManager");
std::string vTopoTypeStr = readStrAttribute(vTopoShapeManagerGroup, std::to_string(i - 1));
if (!vTopoShapeManagerGroup.nameExists(vTopoTypeStr)) continue;
auto vTopoTypeGroup = vTopoShapeManagerGroup.openGroup(vTopoTypeStr);
int typeCount = readIntAttribute(vTopoTypeGroup, "Count");
for (int j = 0; j < typeCount; j++)
{
auto vTopoShapeGroup = vTopoTypeGroup.openGroup(std::to_string(j));
auto vChildTopoShapeTypeGroup = vTopoShapeGroup.openGroup("ChildVTopo");
int dataObjectID = readIntAttribute(vTopoShapeGroup, "DataObjectID");
auto vTopo = shapeManager->getDataByID(dataObjectID);
if (vTopo == nullptr) return false;
//添加对象
int subTopoCount = readIntAttribute(vChildTopoShapeTypeGroup, "Count");
for (int k = 0; k < subTopoCount; k++)
{
int vChildTopoID = readIntAttribute(vChildTopoShapeTypeGroup, std::to_string(k));
auto subTopo = manager->findDownInternal(vChildTopoID, (Interface::FITKGeoEnum::VTopoShapeType)i);
if (subTopo == nullptr) return false;
vTopo->addSubTopo(subTopo);
}
}
}
//读取shape
auto shapeGroup = h5Group.openGroup("Shape");
if (!readVShape(comm, shapeGroup)) return false;
return true;
}
bool FITKInterfaceHDF5AdaptorCommand::writeChildVirtualShape(Interface::FITKAbsGeoCommand* comm, H5::Group& h5Group, bool isSaveShape)
{
auto agent = comm->getShapeAgent();
if (agent == nullptr) return true;
auto manager = agent->getVirtualTopoManager();
if (manager == nullptr) return true;
auto vTopoShapeManager = h5Group.createGroup("vTopoShapeManager");
QMetaEnum m = QMetaEnum::fromType<Interface::FITKGeoEnum::VTopoShapeType>();
int vTopoShapeTypeCount = m.keyCount();
//实际存储类型
int shapeTypeCount = 0;
for (int i = 1; i < vTopoShapeTypeCount; i++)
{
auto shapeManager = manager->getShapeVirtualTopoManager((Interface::FITKGeoEnum::VTopoShapeType)i);
if (shapeManager == nullptr) continue;
shapeTypeCount++;
std::string name = m.valueToKey(i);
auto vTopoShapeTypeGroup = vTopoShapeManager.createGroup(name);
int shapeManagerCount = shapeManager->getDataCount();
writeIntAttribute(vTopoShapeTypeGroup, "Count", &shapeManagerCount);
for (int j = 0; j < shapeManager->getDataCount(); j++)
{
auto vTopoShapeGroup = vTopoShapeTypeGroup.createGroup(std::to_string(j));
auto vParentTopoShapeTypeGroup = vTopoShapeGroup.createGroup("ParentVTopo");
auto vChildTopoShapeTypeGroup = vTopoShapeGroup.createGroup("ChildVTopo");
auto vIndexLabelTopoShapeGroup = vTopoShapeGroup.createGroup("IndexLabel");
//写出每个节点的dataObject信息
auto vTopo = shapeManager->getDataByIndex(j);
if (!writeDataObject(vTopo, vTopoShapeGroup)) return false;
int parentTopoCount = vTopo->getParentTopoCount();
writeIntAttribute(vParentTopoShapeTypeGroup, "Count", &parentTopoCount);
for (int k = 0; k < parentTopoCount; k++)
{
int vParentTopoID = vTopo->getParentTopo(k)->getDataObjectID();
writeIntAttribute(vParentTopoShapeTypeGroup, std::to_string(k), &vParentTopoID);
}
int subTopoCount = vTopo->getSubTopoCount();
writeIntAttribute(vChildTopoShapeTypeGroup, "Count", &subTopoCount);
for (int k = 0; k < subTopoCount; k++)
{
int vChildTopoID = vTopo->getSubTopo(k)->getDataObjectID();
writeIntAttribute(vChildTopoShapeTypeGroup, std::to_string(k), &vChildTopoID);
}
int indexLabel = vTopo->getIndexLabel();
writeIntAttribute(vIndexLabelTopoShapeGroup, "LndexLabel", &indexLabel);
}
//存储名称的链表 用index作为属性名称添加
int numAttrCount = vTopoShapeManager.getNumAttrs();
writeStrAttribute(vTopoShapeManager, std::to_string(numAttrCount), name);
}
writeIntAttribute(vTopoShapeManager, "Count", &shapeTypeCount);
//写出根节点ID
if (manager->getRootObj() != nullptr)
{
int virtualTopoManagerRootID = manager->getRootObj()->getDataObjectID();
writeIntAttribute(h5Group, "VirtualTopoManagerRootID", &virtualTopoManagerRootID);
}
//写出shape
auto shapeGroup = h5Group.createGroup("Shape");
if (!writeVShape(agent, shapeGroup)) return false;
return true;
}
//@}
} // namespace IO