| 786 | } |
| 787 | |
| 788 | Expected<void> readFromStream( STEPControl_Reader& reader, std::istream& in ) |
| 789 | { |
| 790 | MR_TIMER; |
| 791 | |
| 792 | #if STEP_READSTREAM_SUPPORTED |
| 793 | if ( reader.ReadStream( "STEP file", in ) != IFSelect_RetDone ) |
| 794 | return unexpected( "Failed to read STEP model" ); |
| 795 | return {}; |
| 796 | #else |
| 797 | std::unique_lock lock( cOpenCascadeTempFileMutex ); |
| 798 | |
| 799 | const auto tempFilePath = getStepTemporaryDirectory() / "tempFile.step"; |
| 800 | std::error_code ec; |
| 801 | MR_FINALLY { |
| 802 | std::filesystem::remove( tempFilePath, ec ); |
| 803 | }; |
| 804 | |
| 805 | { |
| 806 | std::ofstream ofs( tempFilePath, std::ios::binary ); |
| 807 | if ( !ofs ) |
| 808 | return unexpected( std::string( "Cannot open buffer file" ) ); |
| 809 | |
| 810 | ofs << in.rdbuf(); |
| 811 | } |
| 812 | |
| 813 | return readFromFile( reader, tempFilePath ); |
| 814 | #endif |
| 815 | } |
| 816 | |
| 817 | #if !STEP_READER_FIXED |
| 818 | Expected<void> repairStepFile( STEPControl_Reader& reader ) |
no test coverage detected