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_Component/FITKGeoOCCIOHDF5/FITKOCCHDF5AdaptorCommand.cpp

176 lines
7.0 KiB
C++

#include "FITKOCCHDF5AdaptorCommand.h"
#include "FITKOCCShapeIO.h"
#include "FITKOCCHDF5AdaptorOperGeometry.h"
#include "FITKOCCHDF5AdaptorBasicGeometryPoint.h"
#include "FITKOCCHDF5AdaptorBasicGeometryCurve.h"
#include "FITKOCCHDF5AdaptorBasicGeometryFace.h"
#include "FITKOCCHDF5AdaptorBasicGeometrySolid.h"
#include "FITK_Interface/FITKInterfaceIO/FITKAbstractHDF5Writer.h"
#include "FITK_Interface/FITKInterfaceIO/FITKAbstractHDF5Reader.h"
// OCC
#include <TopoDS_Shape.hxx>
//Component
#include "FITK_Component/FITKGeoCompOCC/FITKAbstractOCCModel.h"
//Geommtry
#include "FITK_Interface/FITKInterfaceGeometry/FITKAbsGeoModelBox.h"
#include "FITK_Interface/FITKInterfaceGeometry/FITKAbsGeoModelSphere.h"
#include "FITK_Interface/FITKInterfaceGeometry/FITKAbsGeoModelCylinder.h"
namespace IO
{
bool FITKOCCHDF5AdaptorCommand::readVShape(Interface::FITKAbsGeoCommand * comm, H5::Group & h5Group)
{
if (comm == nullptr) return false;
auto occShape = dynamic_cast<OCC::FITKAbstractOCCModel*>(comm->getShapeAgent());
if (occShape == nullptr) return false;
uint len = readIntAttribute(h5Group, "Len");
char* data = new char[len];
if (!readCharDataSet(h5Group, "Shape", data, len)) return false;
if (!FITKOCCIOTool::SetDataToCommand(comm, len, data)) return false;
delete[] data;
return true;
}
bool FITKOCCHDF5AdaptorCommand::writeVShape(Interface::FITKAbsGeoShapeAgent * agent, H5::Group & h5Group)
{
auto occShape = dynamic_cast<OCC::FITKAbstractOCCModel*>(agent);
if (occShape == nullptr) return false;
uint len = -1;
char* data;
if (!FITKOCCIOTool::ShapeToData(occShape->getShape(), len, data)) return false;
writeCharDataSet(h5Group, "Shape", data, len);
writeIntAttribute(h5Group, "Len", &len);
delete[] data;
return true;
}
// Write.
//@{
bool FITKOCCHDF5AdaptorCommand::writeGeometrySkecth(Interface::FITKAbsGeoCommand* comm, H5::Group& h5Group)
{
return false;
}
bool FITKOCCHDF5AdaptorCommand::writeBasicGeometryPoint(Interface::FITKAbsGeoCommand* comm, H5::Group& h5Group)
{
//调用coordinateSystem适配器读写
if (!comm) return false;
auto adaptor = FITKIOADAPTORFACTORY->createT<FITKOCCHDF5AdaptorBasicGeometryPoint>("HDF5", "Interface::FITKAbsGeoModelPoint");
if (adaptor == nullptr) return false;
adaptor->setFileWriter(_writer);
adaptor->setDataObject(comm);
adaptor->setH5GroupData(h5Group);
bool ok = adaptor->adaptW();
delete adaptor;
if (!ok) _writer->consoleMessage(3, QString("Write BasicGeometryPoint Error,File:%1 Line:%2").arg(__FILE__).arg(__LINE__));
return ok;
}
bool FITKOCCHDF5AdaptorCommand::writeBasicGeometryCurve(Interface::FITKAbsGeoCommand* comm, H5::Group& h5Group)
{
//调用coordinateSystem适配器读写
if (!comm) return false;
auto adaptor = FITKIOADAPTORFACTORY->createT<FITKOCCHDF5AdaptorBasicGeometryCurve>("HDF5", "Interface::FITKAbsGeoModelCurve");
if (adaptor == nullptr) return false;
adaptor->setFileWriter(_writer);
adaptor->setDataObject(comm);
adaptor->setH5GroupData(h5Group);
bool ok = adaptor->adaptW();
delete adaptor;
if (!ok) _writer->consoleMessage(3, QString("Write BasicGeometryCurve Error,File:%1 Line:%2").arg(__FILE__).arg(__LINE__));
return ok;
}
bool FITKOCCHDF5AdaptorCommand::writeBasicGeometryFace(Interface::FITKAbsGeoCommand* comm, H5::Group& h5Group)
{
//调用coordinateSystem适配器读写
if (!comm) return false;
auto adaptor = FITKIOADAPTORFACTORY->createT<FITKOCCHDF5AdaptorBasicGeometryFace>("HDF5", "Interface::FITKAbsGeoModelFace");
if (adaptor == nullptr) return false;
adaptor->setFileWriter(_writer);
adaptor->setDataObject(comm);
adaptor->setH5GroupData(h5Group);
bool ok = adaptor->adaptW();
delete adaptor;
if (!ok) _writer->consoleMessage(3, QString("Write BasicGeometryFace Error,File:%1 Line:%2").arg(__FILE__).arg(__LINE__));
return ok;
}
bool FITKOCCHDF5AdaptorCommand::readBasicGeometrySolid(Interface::FITKAbsGeoCommand * comm, H5::Group & h5Group)
{
//调用BasicGeometrySolid适配器读写
if (!comm) return false;
auto adaptor = FITKIOADAPTORFACTORY->createT<FITKOCCHDF5AdaptorBasicGeometrySolid>("HDF5", "Interface::FITKAbsGeoModelBox");
if (adaptor == nullptr) return false;
adaptor->setFileReader(_reader);
adaptor->setDataObject(comm);
adaptor->setH5GroupData(h5Group);
bool ok = adaptor->adaptR();
delete adaptor;
if (!ok) _reader->consoleMessage(3, QString("Read BasicGeometrySolid Error,File:%1 Line:%2").arg(__FILE__).arg(__LINE__));
return ok;
}
bool FITKOCCHDF5AdaptorCommand::writeBasicGeometrySolid(Interface::FITKAbsGeoCommand* comm, H5::Group& h5Group)
{
//调用BasicGeometrySolid适配器读写
if (!comm) return false;
auto adaptor = FITKIOADAPTORFACTORY->createT<FITKOCCHDF5AdaptorBasicGeometrySolid>("HDF5", "Interface::FITKAbsGeoModelBox");
if (adaptor == nullptr) return false;
adaptor->setFileWriter(_writer);
adaptor->setDataObject(comm);
adaptor->setH5GroupData(h5Group);
bool ok = adaptor->adaptW();
delete adaptor;
if (!ok) _writer->consoleMessage(3, QString("Write BasicGeometrySolid Error,File:%1 Line:%2").arg(__FILE__).arg(__LINE__));
return ok;
}
bool FITKOCCHDF5AdaptorCommand::writeOperGeometry(Interface::FITKAbsGeoCommand * comm, H5::Group & h5Group)
{
//调用OperGeometryDelete适配器读写
if (!comm) return false;
auto adaptor = FITKIOADAPTORFACTORY->createT<FITKOCCHDF5AdaptorOperGeometry>("HDF5", "Interface::FITKAbsGeoDelete");
if (adaptor == nullptr) return false;
adaptor->setFileWriter(_writer);
adaptor->setDataObject(comm);
adaptor->setH5GroupData(h5Group);
bool ok = adaptor->adaptW();
delete adaptor;
if (!ok) _writer->consoleMessage(3, QString("Write OperGeometry Error,File:%1 Line:%2").arg(__FILE__).arg(__LINE__));
return ok;
}
bool FITKOCCHDF5AdaptorCommand::writeOperGeometryPoint(Interface::FITKAbsGeoCommand* comm, H5::Group& h5Group)
{
return false;
}
bool FITKOCCHDF5AdaptorCommand::writeOperGeometryCurve(Interface::FITKAbsGeoCommand * comm, H5::Group & h5Group)
{
return false;
}
bool FITKOCCHDF5AdaptorCommand::writeOperGeometryFace(Interface::FITKAbsGeoCommand * comm, H5::Group & h5Group)
{
return false;
}
bool FITKOCCHDF5AdaptorCommand::writeOperGeometrySolid(Interface::FITKAbsGeoCommand * comm, H5::Group & h5Group)
{
return false;
}
bool FITKOCCHDF5AdaptorCommand::writeShapeGeometry(Interface::FITKAbsGeoCommand * comm, H5::Group & h5Group)
{
return false;
}
//@}
} // namespace IO