View Issue Details

IDProjectCategoryView StatusLast Update
0032350CommunityOCCT:Data Exchangepublic2023-03-19 22:34
Reportermahaidong Assigned Tomahaidong  
PrioritynormalSeverityfeature 
Status closedResolutionfixed 
Target Version7.7.0Fixed in Version7.7.0 
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

Relationships

related to 0027342 closedbugmaster Open CASCADE Data Exchange, STEP - support C++ streams for import 
related to 0032455 closedmkrylova Open CASCADE Data Exchange - replace OSD_OpenStream() usage with OSD_FileSystem::DefaultFileSystem() 
related to 0030844 newdpasukhi Community Data Exchange - Support import from and export to stream for data exchange interface 

Activities

mahaidong

2021-05-10 14:44

reporter   ~0100852

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 );

}

mahaidong

2021-05-13 23:51

reporter   ~0100958

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;
}

git

2021-05-14 09:35

administrator   ~0100962

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

git

2021-05-27 11:52

administrator   ~0101421

Branch CR32350 has been updated forcibly by kgv.

SHA-1: 1f1a69c0a94dbf4cb4ed95ed48ccfebe0ad6a2c6

git

2021-05-27 11:54

administrator   ~0101422

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).

git

2021-05-27 16:33

administrator   ~0101427

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.

git

2021-05-27 16:47

administrator   ~0101428

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.

git

2021-05-27 18:31

administrator   ~0101434

Branch CR32350_1 has been updated forcibly by kgv.

SHA-1: 5a10217fb93a735d0b51762efb1dc274508c1417

kgv

2021-05-27 19:54

developer   ~0101437

Last edited: 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/

git

2022-10-24 10:28

administrator   ~0111726

Branch CR32350_2 has been created by dpasukhi.

SHA-1: 992f6f969cfad6663e8e9da78738e891f04d5bfd


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 commands ReadStep, WriteStep, and testwritestep.

dpasukhi

2022-11-02 13:10

administrator   ~0111842

Dear bugmaster,
please integrate:
OCCT: CR32350_2
PROD: NO

git

2022-11-02 13:53

administrator   ~0111863

Branch CR32350 has been deleted by mnt.

SHA-1: 8242929d3384a78b0fdc56ed5568f37fa087e09c

git

2022-11-02 13:53

administrator   ~0111864

Branch CR32350_1 has been deleted by mnt.

SHA-1: 5a10217fb93a735d0b51762efb1dc274508c1417

git

2022-11-02 13:53

administrator   ~0111865

Branch CR32350_2 has been deleted by mnt.

SHA-1: 992f6f969cfad6663e8e9da78738e891f04d5bfd

Related Changesets

occt: master 3e06b706

2021-05-14 09:35:28

mahaidong


Committer: smoskvin Details Diff
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 commands ReadStep, WriteStep, and testwritestep.
Affected Issues
0032350
mod - src/STEPCAFControl/STEPCAFControl_Reader.cxx Diff File
mod - src/STEPCAFControl/STEPCAFControl_Reader.hxx Diff File
mod - src/STEPCAFControl/STEPCAFControl_Writer.cxx Diff File
mod - src/STEPCAFControl/STEPCAFControl_Writer.hxx Diff File
mod - src/STEPControl/STEPControl_Writer.cxx Diff File
mod - src/STEPControl/STEPControl_Writer.hxx Diff File
mod - src/XDEDRAW/XDEDRAW_Common.cxx Diff File
mod - src/XSDRAWSTEP/XSDRAWSTEP.cxx Diff File
add - tests/bugs/step/bug32350 Diff File

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
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: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
2021-06-18 21:25 kgv Relationship added related to 0032455
2021-10-18 11:12 kgv Relationship added related to 0030844
2021-10-18 11:36 kgv Assigned To gka => dpasukhi
2021-11-01 18:16 szy Target Version 7.6.0 => 7.7.0
2022-10-24 10:28 git Note Added: 0111726
2022-11-02 13:10 dpasukhi Assigned To dpasukhi => bugmaster
2022-11-02 13:10 dpasukhi Status resolved => reviewed
2022-11-02 13:10 dpasukhi Note Added: 0111842
2022-11-02 13:39 smoskvin Status reviewed => tested
2022-11-02 13:46 smoskvin Changeset attached => occt master 3e06b706
2022-11-02 13:46 mahaidong Assigned To bugmaster => mahaidong
2022-11-02 13:46 mahaidong Status tested => verified
2022-11-02 13:46 mahaidong Resolution open => fixed
2022-11-02 13:53 git Note Added: 0111863
2022-11-02 13:53 git Note Added: 0111864
2022-11-02 13:53 git Note Added: 0111865
2023-03-19 22:34 vglukhik Status verified => closed
2023-03-19 22:34 vglukhik Fixed in Version => 7.7.0