FeatureImportIges.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) Jürgen Riegel          (juergen.riegel@web.de) 2002     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #include "PreCompiled.h"
00025 #ifndef _PreComp_
00026 # include <fcntl.h>
00027 # include <TopTools_HSequenceOfShape.hxx>
00028 # include <IGESControl_Writer.hxx>
00029 # include <IGESControl_Reader.hxx>
00030 # include <TopoDS_Shape.hxx>
00031 # include <TFunction_Logbook.hxx>
00032 #endif
00033 
00034 #include <Base/Console.h>
00035 #include <Base/Exception.h>
00036 #include <Base/Sequencer.h>
00037 #include "FeatureImportIges.h"
00038 
00039 
00040 using namespace Import;
00041 
00042 void FeatureImportIges::InitLabel(const TDF_Label &rcLabel)
00043 {
00044         addProperty("String","FileName");
00045 
00046 }
00047 
00048 /*
00049 bool FeaturePartImportStep::MustExecute(void)
00050 {
00051         Base::Console().Log("PartBoxFeature::MustExecute()\n");
00052         return false;
00053 }
00054 */
00055 Standard_Integer FeatureImportIges::Execute(void)
00056 {
00057         Base::Console().Log("FeaturePartImportIges::Execute()\n");
00058 
00059 /*  cout << GetFloatProperty("x") << endl;
00060   cout << GetFloatProperty("y") << endl;
00061   cout << GetFloatProperty("z") << endl;
00062   cout << GetFloatProperty("l") << endl;
00063   cout << GetFloatProperty("h") << endl;
00064   cout << GetFloatProperty("w") << endl;*/
00065 
00066   try{
00067 
00068     IGESControl_Reader aReader;
00069     TopoDS_Shape aShape;
00070 
00071     std::string FileName = getPropertyString("FileName");
00072 
00073     int i=_open(FileName.c_str(),O_RDONLY);
00074           if( i != -1)
00075           {
00076                   _close(i);
00077           }else{
00078       Base::Console().Log("FeaturePartImportIges::Execute() not able to open %s!\n",FileName.c_str());
00079                   return 1;
00080           }
00081 
00082     // just do show the wait cursor when the Gui is up
00083     Base::Sequencer().start("Load IGES", 1);
00084     Base::Sequencer().next();
00085 
00086     // read iges-file
00087     if (aReader.ReadFile((const Standard_CString)FileName.c_str()) != IFSelect_RetDone)
00088       throw Base::Exception("IGES read failed (load file)");
00089   
00090     // check iges-file (memory)
00091     //if (!aReader.Check(Standard_True))
00092     //  Base::Console().Warning( "IGES model contains errors! try loading anyway....\n" );
00093   
00094     // make brep
00095     aReader.TransferRoots();
00096     // one shape, who contain's all subshapes
00097     aShape = aReader.OneShape();
00098 
00099           setShape(aShape);
00100     Base::Sequencer().stop();
00101   }
00102   catch(...){
00103     Base::Sequencer().halt();
00104     Base::Console().Error("FeaturePartImportIges::Execute() failed!");
00105     return 1;
00106   }
00107 
00108   return 0;
00109 }
00110 
00111 /*
00112 void FeatureImportIges::Validate(void)
00113 {
00114         Base::Console().Log("FeaturePartImportStep::Validate()\n");
00115  
00116   // We validate the object label ( Label() ), all the arguments and the results of the object:
00117   log.SetValid(Label(), Standard_True);
00118 
00119 
00120 }
00121 */
00122 
00123 
00124 

Generated on Wed Nov 23 19:00:11 2011 for FreeCAD by  doxygen 1.6.1