75 wxFileName sourcePath( aFileName );
76 sourcePath.Normalize( wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE | wxPATH_NORM_ENV_VARS );
77 wxString canonicalPath = sourcePath.GetFullPath();
79 if( inlineLoadStack.size() >= 64 )
87 if( std::find( inlineLoadStack.begin(), inlineLoadStack.end(), canonicalPath ) != inlineLoadStack.end() )
95 INLINE_LOAD_GUARD inlineGuard( canonicalPath );
97 std::unique_ptr<VRML_LINE_READER> modelFile;
99 wxString filename = aFileName;
100 wxFileName tmpfilename;
102 if( aFileName.Upper().EndsWith( wxT(
"WRZ" ) ) )
104 wxFFileInputStream ifile( aFileName );
106 cleanup.
path = tmpfilename.GetFullPath();
108 if( cleanup.
path.empty() || !ifile.IsOk() )
116 wxFileOffset size = ifile.GetLength();
118 if( size == wxInvalidOffset )
122 ||
static_cast<std::uint64_t
>( size ) > std::numeric_limits<std::size_t>::max() )
131 wxFFileOutputStream ofile( tmpfilename.GetFullPath() );
136 std::vector<char> buffer(
static_cast<size_t>( size ) );
138 ifile.Read( buffer.data(), size );
140 if( ifile.LastRead() !=
static_cast<size_t>( size ) )
143 std::string expanded;
166 ofile.Write( expanded.data(), expanded.size() );
168 if( ofile.LastWrite() != expanded.size() || !ofile.Close() )
172 filename = tmpfilename.GetFullPath();
179 modelFile = std::make_unique<VRML_LINE_READER>( filename, 0, 8388608, aOptions );
181 catch(
const std::exception& e )
183 wxLogTrace(
traceVrmlPlugin, wxS(
" * [INFO] load failed: %s" ), wxString::FromUTF8Unchecked( e.what() ) );
190 WRLPROC proc( modelFile.get() );
194 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] Processing VRML 1.0 file" ) );
196 auto bp = std::make_unique<WRL1BASE>();
198 if( !bp->Read( proc ) )
206 scene = (
SCENEGRAPH*)bp->TranslateToSG(
nullptr,
nullptr );
211 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] Processing VRML 2.0 file" ) );
213 auto bp = std::make_unique<WRL2BASE>();
221 bp->SetImportOptions( aOptions, aStatus );
223 if( !bp->Read( proc ) )
232 scene = (
SCENEGRAPH*)bp->TranslateToSG(
nullptr );
234 if( bp->HadIncompleteInline() )
238 "VRML Inline dependency was denied or failed; geometry would be incomplete" );
251#if ( defined( DEBUG_VRML1 ) && DEBUG_VRML1 > 3 ) \
252 || ( defined( DEBUG_VRML2 ) && DEBUG_VRML2 > 3 )
255 wxFileName fn( wxString::FromUTF8Unchecked( aFileName ) );
259 output = wxT(
"_vrml1-" );
261 output = wxT(
"_vrml2-" );
263 output.append( fn.GetName() );
264 output.append( wxT(
".wrl") );
MODEL_IMPORT_GZIP_RESULT DecompressBoundedModel(const char *aData, std::size_t aSize, std::uint64_t aMaxExpandedBytes, std::string &aExpanded)
Expand a gzip stream into aExpanded, refusing anything over aMaxExpandedBytes.
SGLIB_API bool WriteVRML(const char *filename, bool overwrite, SGNODE *aTopNode, bool reuse, bool renameNodes)
Write out the given node and its subnodes to a VRML2 file.