2013-03-27 18:34:23 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Tuomas Vaherkoski <tuomasvaherkoski@gmail.com>
|
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras@wanadoo.fr
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
2014-04-27 13:49:41 +00:00
|
|
|
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-03-27 18:34:23 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file vrmlmodelparser.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <fctsys.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <info3d_visu.h>
|
|
|
|
|
|
|
|
#include "3d_struct.h"
|
|
|
|
#include "modelparsers.h"
|
2013-03-28 16:51:22 +00:00
|
|
|
|
2013-03-27 18:34:23 +00:00
|
|
|
|
2013-03-28 16:51:22 +00:00
|
|
|
VRML_MODEL_PARSER::VRML_MODEL_PARSER( S3D_MASTER* aMaster ) :
|
|
|
|
S3D_MODEL_PARSER( aMaster )
|
|
|
|
{
|
2013-03-27 18:34:23 +00:00
|
|
|
}
|
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
VRML_MODEL_PARSER::~VRML_MODEL_PARSER()
|
2013-03-27 18:34:23 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-13 19:27:25 +00:00
|
|
|
bool VRML_MODEL_PARSER::Load( const wxString& aFilename )
|
2013-03-27 18:34:23 +00:00
|
|
|
{
|
2015-03-13 19:27:25 +00:00
|
|
|
char line[11 + 1];
|
2014-07-30 09:01:25 +00:00
|
|
|
FILE* file;
|
2013-03-27 18:34:23 +00:00
|
|
|
|
2014-08-21 11:59:57 +00:00
|
|
|
//DBG( printf( "Load %s", GetChars( aFilename ) ) );
|
2013-03-27 18:34:23 +00:00
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
file = wxFopen( aFilename, wxT( "rt" ) );
|
2013-03-27 18:34:23 +00:00
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
if( file == NULL )
|
2015-03-13 19:27:25 +00:00
|
|
|
return false;
|
2013-03-27 18:34:23 +00:00
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
if( fgets( line, 11, file ) == NULL )
|
2013-03-27 18:34:23 +00:00
|
|
|
{
|
2014-07-30 09:01:25 +00:00
|
|
|
fclose( file );
|
2015-03-13 19:27:25 +00:00
|
|
|
return false;
|
2013-03-27 18:34:23 +00:00
|
|
|
}
|
2014-08-16 18:01:00 +00:00
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
fclose( file );
|
2014-08-16 18:01:00 +00:00
|
|
|
|
2015-03-28 11:33:56 +00:00
|
|
|
childs.clear();
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
if( stricmp( line, "#VRML V2.0" ) == 0 )
|
2013-03-27 18:34:23 +00:00
|
|
|
{
|
2015-03-28 11:33:56 +00:00
|
|
|
VRML2_MODEL_PARSER *vrml2_parser = new VRML2_MODEL_PARSER( this );
|
2015-03-13 19:27:25 +00:00
|
|
|
vrml2_parser->Load( aFilename );
|
2015-03-05 19:46:38 +00:00
|
|
|
delete vrml2_parser;
|
2015-03-13 19:27:25 +00:00
|
|
|
return true;
|
2013-03-27 18:34:23 +00:00
|
|
|
}
|
2014-08-16 18:01:00 +00:00
|
|
|
else if( stricmp( line, "#VRML V1.0" ) == 0 )
|
2013-03-27 18:34:23 +00:00
|
|
|
{
|
2015-03-28 11:33:56 +00:00
|
|
|
VRML1_MODEL_PARSER *vrml1_parser = new VRML1_MODEL_PARSER( this );
|
2015-03-13 19:27:25 +00:00
|
|
|
vrml1_parser->Load( aFilename );
|
2015-03-05 19:46:38 +00:00
|
|
|
delete vrml1_parser;
|
2015-03-13 19:27:25 +00:00
|
|
|
return true;
|
2013-03-27 18:34:23 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 19:27:25 +00:00
|
|
|
DBG( printf( "Unknown internal VRML file format: %s\n", line ) );
|
|
|
|
return false;
|
2013-03-27 18:34:23 +00:00
|
|
|
}
|