// Copyright (c) 1999-2012 OPEN CASCADE SAS // // The content of this file is subject to the Open CASCADE Technology Public // License Version 6.5 (the "License"). You may not use the content of this file // except in compliance with the License. Please obtain a copy of the License // at http://www.opencascade.org and read it completely before using this file. // // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. // // The Original Code and all software distributed under the License is // distributed on an "AS IS" basis, without warranty of any kind, and the // Initial Developer hereby disclaims all such warranties, including without // limitation, any warranties of merchantability, fitness for a particular // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include StepSelect_WorkLibrary::StepSelect_WorkLibrary (const Standard_Boolean copymode) : thecopymode (copymode) , thelabmode (0) { SetDumpLevels (1,2); SetDumpHelp (0,"#id + Step Type"); SetDumpHelp (1,"Entity as in file"); SetDumpHelp (2,"Entity + shareds (level 1) as in file"); } // rq : les init sont faits par ailleurs, pas de souci a se faire void StepSelect_WorkLibrary::SetDumpLabel (const Standard_Integer mode) { thelabmode = mode; } Standard_Integer StepSelect_WorkLibrary::ReadFile (const Standard_CString name, Handle(Interface_InterfaceModel)& model, const Handle(Interface_Protocol)& protocol) const { long status = 1; DeclareAndCast(StepData_Protocol,stepro,protocol); if (stepro.IsNull()) return 1; Handle(StepData_StepModel) stepmodel = new StepData_StepModel; model = stepmodel; StepFile_ReadTrace (0); char *pName=(char *)name; status = StepFile_Read (pName,stepmodel,stepro); return status; } Standard_Boolean StepSelect_WorkLibrary::WriteFile (IFSelect_ContextWrite& ctx) const { // Preparation Handle(Message_Messenger) sout = Message::DefaultMessenger(); DeclareAndCast(StepData_StepModel,stepmodel,ctx.Model()); DeclareAndCast(StepData_Protocol,stepro,ctx.Protocol()); if (stepmodel.IsNull() || stepro.IsNull()) return Standard_False; ofstream fout; fout.open(ctx.FileName(),ios::out|ios::trunc); if (!fout || !fout.rdbuf()->is_open()) { ctx.CCheck(0)->AddFail("Step File could not be created"); sout<<" Step File could not be created : " << ctx.FileName() << endl; return 0; } sout << " Step File Name : "<NbEntities()<<" ents) "; // File Modifiers Standard_Integer nbmod = ctx.NbModifiers(); for (Standard_Integer numod = 1; numod <= nbmod; numod ++) { ctx.SetModifier (numod); DeclareAndCast(StepSelect_FileModifier,filemod,ctx.FileModifier()); if (!filemod.IsNull()) filemod->Perform(ctx,SW); // (impressions de mise au point) sout << " .. FileMod." << numod << filemod->Label(); if (ctx.IsForAll()) sout << " (all model)"; else sout << " (" << ctx.NbEntities() << " entities)"; // sout << flush; } // Envoi SW.SendModel(stepro); Interface_CheckIterator chl = SW.CheckList(); for (chl.Start(); chl.More(); chl.Next()) ctx.CCheck(chl.Number())->GetMessages(chl.Value()); sout<<" Write "; Standard_Boolean isGood = SW.Print(fout); sout<<" Done"<Number(entity); if (nument <= 0 || nument > model->NbEntities()) return; Standard_Boolean iserr = model->IsRedefinedContent(nument); Handle(Standard_Transient) ent, con; ent = entity; S<<" --- (STEP) Entity "; model->Print(entity,S); if (iserr) con = model->ReportEntity(nument)->Content(); if (entity.IsNull()) { S<<" Null"<DynamicType()->Name() << endl; if (iserr) S<<" *** NOT WELL LOADED : CONTENT FROM FILE ***"<IsUnknownEntity(nument)) S<<" *** UNKNOWN TYPE ***"<