FeatureImportIges.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00050
00051
00052
00053
00054
00055 Standard_Integer FeatureImportIges::Execute(void)
00056 {
00057 Base::Console().Log("FeaturePartImportIges::Execute()\n");
00058
00059
00060
00061
00062
00063
00064
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
00083 Base::Sequencer().start("Load IGES", 1);
00084 Base::Sequencer().next();
00085
00086
00087 if (aReader.ReadFile((const Standard_CString)FileName.c_str()) != IFSelect_RetDone)
00088 throw Base::Exception("IGES read failed (load file)");
00089
00090
00091
00092
00093
00094
00095 aReader.TransferRoots();
00096
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
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124