MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0032350Community[OCCT] OCCT:Data Exchangepublic2021-05-09 09:252021-05-27 19:55
Reportermahaidong 
Assigned Togka 
PrioritynormalSeverityfeature 
StatusresolvedResolutionopen 
PlatformOSOS Version
Product Version 
Target Version[OCCT] 7.6.0*Fixed in Version 
Summary0032350: Data Exchange - STEPControl_Writer.writeStream(std::ostream)
Descriptionstep write to std::ostream as mentioned as this one:

 https://dev.opencascade.org/content/load-step-memory-instead-file [^]

some code like this:
std::ostream theOStream;
STEPControl_Writer stepWriter;
StepData_StepWriter theDumper(stepWriter.Model());
Handle_StepAP214_Protocol protocol = new StepAP214_Protocol();
theDumper.SendModel( protocol );
theDumper.Print( theOStream );
TagsNo tags attached.
Test case number
Attached Files

- Relationships
related to 0027342closedbugmaster Open CASCADE Data Exchange, STEP - support C++ streams for import 

-  Notes
(0100852)
mahaidong (reporter)
2021-05-10 14:44

can I add this code to repos? such as add a function

STEPControl_Writer.WriteStream( std::ostream& theOStream )
{
StepData_StepWriter theDumper(this->Model());
Handle_StepData_Protocol protocol = Handle_StepData_Protocol::DownCast( stepModel->Protocol());
theDumper.SendModel( protocol );
theDumper.Print( theOStream );

}
(0100958)
mahaidong (reporter)
2021-05-13 23:51

or can rewrite this function: from StepSelect/StepSelect_WorkLibrary.cxx

Standard_Boolean StepSelect_WorkLibrary::WriteFile
  (IFSelect_ContextWrite& ctx) const
{
// Preparation
  Message_Messenger::StreamBuffer sout = Message::SendInfo();
  DeclareAndCast(StepData_StepModel,stepmodel,ctx.Model());
  DeclareAndCast(StepData_Protocol,stepro,ctx.Protocol());
  if (stepmodel.IsNull() || stepro.IsNull()) return Standard_False;

  std::ofstream fout;
  OSD_OpenStream(fout,ctx.FileName(),std::ios::out|std::ios::trunc);

  if (!fout || !fout.is_open()) {
    ctx.CCheck(0)->AddFail("Step File could not be created");
    sout<<" Step File could not be created : " << ctx.FileName() << std::endl; return 0;
  }
  sout << " Step File Name : "<<ctx.FileName();
  StepData_StepWriter SW(stepmodel);
  sout<<"("<<stepmodel->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 << std::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"<<std::endl;
      
  errno = 0;
  fout.close();
  isGood = fout.good() && isGood && !errno;
  if(errno)
    sout << strerror(errno) << std::endl;
  return isGood;
}
(0100962)
git (administrator)
2021-05-14 09:35

Branch CR32350 has been created by mahaidong.

SHA-1: 60870a832b11bece8c1c20ab3551f994468cacac


Detailed log of new commits:

Author: mahaidong
Date: Fri May 14 14:35:28 2021 +0800

    stepcontrol write stream
(0101421)
git (administrator)
2021-05-27 11:52

Branch CR32350 has been updated forcibly by kgv.

SHA-1: 1f1a69c0a94dbf4cb4ed95ed48ccfebe0ad6a2c6
(0101422)
git (administrator)
2021-05-27 11:54

Branch CR32350 has been updated by kgv.

SHA-1: bf352805bbdf3465b20ca3b1b632e73dbaf6b2a9


Detailed log of new commits:

Author: kgv
Date: Thu May 27 11:54:41 2021 +0300

    STEPCAFControl_Reader::ReadStream() - added stream reading method (similar to STEPControl_Reader::ReadStream()).
    
    Added option -stream to ReadStep command (similar to testreadstep command).

(0101427)
git (administrator)
2021-05-27 16:33

Branch CR32350 has been updated by kgv.

SHA-1: 8242929d3384a78b0fdc56ed5568f37fa087e09c


Detailed log of new commits:

Author: kgv
Date: Thu May 27 16:13:07 2021 +0300

    STEPCAFControl_Writer::WriteStream() - added interface for writing into stream.
    
    Added argument -stream to commands WriteStep, testwritestep for testing purposes.

(0101428)
git (administrator)
2021-05-27 16:47

Branch CR32350_1 has been created by kgv.

SHA-1: 8d698ea272906f66def83de9dea2661377a263dd


Detailed log of new commits:

Author: mahaidong
Date: Fri May 14 14:35:28 2021 +0800

    0032350: Data Exchange - STEPControl_Writer.writeStream(std::ostream)
    
    STEPCAFControl_Writer::WriteStream(), STEPControl_Writer::WriteStream() - added interface for writing into stream.
    STEPCAFControl_Reader::ReadStream() - added stream reading method (similar to STEPControl_Reader::ReadStream()).
    
    Added option -stream to commadns ReadStep, WriteStep, and testwritestep.
(0101434)
git (administrator)
2021-05-27 18:31

Branch CR32350_1 has been updated forcibly by kgv.

SHA-1: 5a10217fb93a735d0b51762efb1dc274508c1417
(0101437)
kgv (developer)
2021-05-27 19:54
edited on: 2021-05-27 19:55

Galina,

I confirm that STEPControl_Writer::WriteStream() within the patch does save STEP file via std::ostream close to STEPControl_Writer::Write(), although I don't quite understand how it works as implementations look very different.
Have no idea to which inconsistencies these differences may lead.
On a couple of tested files, I see only different numbers within "NEXT_ASSEMBLY_USAGE_OCCURRENCE" in result STEP files.

The patch has been extended to introduce methods ReadStream()/WriteStream() to CAF interfaces, and to allow testing new functionality via commands ReadStep, WriteStep, testwritestep, testreadstep by providing "-stream" argument.

http://jenkins-test-occt/view/CR32350_1-master-KGV/ [^]


- Issue History
Date Modified Username Field Change
2021-05-09 09:25 mahaidong New Issue
2021-05-09 09:25 mahaidong Assigned To => kgv
2021-05-09 11:30 kgv Relationship added related to 0027342
2021-05-09 22:11 kgv Summary STEPControl_Writer.writeStream(std::ostream) => Data Exchange - STEPControl_Writer.writeStream(std::ostream)
2021-05-09 22:11 kgv Description Updated View Revisions
2021-05-09 22:11 kgv Assigned To kgv => gka
2021-05-10 14:44 mahaidong Note Added: 0100852
2021-05-13 23:51 mahaidong Note Added: 0100958
2021-05-14 00:23 mahaidong Assigned To gka => mahaidong
2021-05-14 09:35 git Note Added: 0100962
2021-05-14 09:36 mahaidong Assigned To mahaidong => gka
2021-05-27 11:52 git Note Added: 0101421
2021-05-27 11:54 git Note Added: 0101422
2021-05-27 16:33 git Note Added: 0101427
2021-05-27 16:47 git Note Added: 0101428
2021-05-27 18:31 git Note Added: 0101434
2021-05-27 19:47 kgv Relationship added child of 0026700
2021-05-27 19:54 kgv Note Added: 0101437
2021-05-27 19:54 kgv Status new => resolved
2021-05-27 19:54 kgv Target Version => 7.6.0*
2021-05-27 19:55 kgv Note Edited: 0101437 View Revisions


Copyright © 2000 - 2021 MantisBT Team
Powered by Mantis Bugtracker