[MOAB-dev] Detecting file types

Jason Kraftcheck kraftche at cae.wisc.edu
Tue Dec 1 09:07:07 CST 2009


Tim Tautges wrote:
> It would help if we documented the following:
> 
> - given an extension name or file name, get the name or actual
> reader/writer which can handle it
> 
> - get the extensions a given reader/writer handles and possibly all the
> readers/writers registered
> 
> After looking again at MBReaderWriterSet and MBCore::query_interface, I
> think all this is already possible, it's just not always clear how
> they're used.  I'll put in a documentation ticket on this.
> 


But MOAB's choice of which reader to use is more complicated that just
selecting one based on extension.  If it doesn't recognize the extension, it
will try them all until one succeeds.  That is a good solution, as there is
no better test of the type of a file then actually looking at the contents.
 We do provide the information you describe above, as it is useful in some
cases (e.g. constructing a file dialog in verdict), but I don't think
utilizing this functionality is the correct solution to Steve's problem.

- jason



> - tim
> 
> Jason Kraftcheck wrote:
>> Steve Jackson wrote:
>>> On Nov 30, 2009, at 15:36 , Jason Kraftcheck wrote:
>>>> So you don't need to know the file type.  You need to know whether
>>>> or not
>>>> the file contained geometry that was read into CGM.  Why not just
>>>> query CGM
>>>> to see if it has any geometry?
>>>
>>> Fair enough.  That seemed to me like a roundabout way of coming at
>>> the problem, but it sounds like the simplest fix.
>>>
>>
>> Well, the direct solution would be to determine whether or not MOAB
>> used the ReadCGM class to read the file.  But asking about the file
>> type is equally indirect, as CGM can read a variety of file formats as
>> well.  If we do want to proved the string name of the reader, then I
>> think the way to do this is to use a file set.  The MOAB load_file
>> function allows an optional EntitySet handle to be passed.  If that
>> handle is provided, the contents of the file will be added to the
>> set.  MOAB should hang pertinent data in tags on that set (file name,
>> file reader name/file type, etc.)
>>
>> - jason
>>
> 


-- 
"A foolish consistency is the hobgoblin of little minds" - Ralph Waldo Emerson



More information about the moab-dev mailing list