bool Translator::importCSFDB(const QString& file) { if(FSD_File::IsGoodFileType((Standard_CString)file.toLatin1().constData()) != Storage_VSOk) return false; FSD_File fileDriver; TCollection_AsciiString name((Standard_CString)file.toLatin1().constData()); if(fileDriver.Open(name, Storage_VSRead) != Storage_VSOk) return false; Handle(ShapeSchema) schema = new ShapeSchema(); Handle(Storage_Data) data = schema->Read(fileDriver); if(data->ErrorStatus() != Storage_VSOk) return false; fileDriver.Close(); Handle(Storage_HSeqOfRoot) roots = data->Roots(); for(int i=1; i<=roots->Length(); i++) { Handle(Storage_Root) r = roots->Value(i); Handle(Standard_Persistent) p = r->Object(); Handle(PTopoDS_HShape) pShape = Handle(PTopoDS_HShape)::DownCast(p); if(!pShape.IsNull()) { PTColStd_PersistentTransientMap map; TopoDS_Shape tShape; MgtBRep::Translate(pShape, map, tShape, MgtBRep_WithTriangle); m_doc->insert(tShape, QFileInfo(file).baseName()); } } return true; }
SALOME_WNT_EXPORT int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName, const TCollection_AsciiString& theFormatName) { MESSAGE("Export CSFDB into file " << theFileName.ToCString()); try { if ( theShape.IsNull() ) return 0; FSD_File f; Handle(ShapeSchema) s = new ShapeSchema; Handle(Storage_Data) d = new Storage_Data; d->ClearErrorStatus(); d->SetApplicationName("GEOM CSFDB PLUGIN"); d->SetApplicationVersion("3.2.6"); d->SetDataType("Shapes"); d->AddToUserInfo("Saved from GEOM CSFDB Plugin"); d->AddToComments("Based on GEOM 3.2.6 and Open CAS.CADE 6.2"); Storage_Error err = f.Open(theFileName, Storage_VSWrite); if ( err != Storage_VSOk ) return 0; PTColStd_TransientPersistentMap aMap; TCollection_AsciiString anObjectName("Object"); Handle(PTopoDS_HShape) aPShape = MgtBRep::Translate(theShape, aMap, MgtBRep_WithTriangle); d->AddRoot(anObjectName, aPShape); s->Write( f, d); f.Close(); if ( d->ErrorStatus() != Storage_VSOk ) return 0; return 1; } catch(Standard_Failure) { Standard_Failure::Raise("Could not export in CSFDB format"); } return 0; }