X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FIGESImport%2FIGESImport.cxx;h=3eba471083b4dc0dfa027e06af350932b8187a88;hb=48f5c2df5815348d168fd8e80fcc9e52dd69f137;hp=791e3a2ad934b9649f5364c79f61aeb15e043932;hpb=7f46e5fa52cfe13e206ab10e628556e7e393aaf5;p=modules%2Fgeom.git diff --git a/src/IGESImport/IGESImport.cxx b/src/IGESImport/IGESImport.cxx index 791e3a2ad..3eba47108 100644 --- a/src/IGESImport/IGESImport.cxx +++ b/src/IGESImport/IGESImport.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -51,6 +51,8 @@ #include #include +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + #ifdef WNT #if defined IGESIMPORT_EXPORTS || defined IGESImport_EXPORTS #if defined WIN32 @@ -77,37 +79,90 @@ extern "C" { + IGESIMPORT_EXPORT + Handle(TCollection_HAsciiString) GetValue (const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theParameterName, + TCollection_AsciiString& theError) + { + Handle(TCollection_HAsciiString) aValue; + + if (theParameterName != "LEN_UNITS") { + theError = theParameterName + " parameter reading is not supported by IGES plugin"; + return aValue; + } + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + IGESControl_Reader aReader; + + Interface_Static::SetCVal("xstep.cascade.unit","M"); + + try { + OCC_CATCH_SIGNALS; + + IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); + if (status == IFSelect_RetDone) { + Handle(IGESData_IGESModel) aModel = + Handle(IGESData_IGESModel)::DownCast(aReader.Model()); + if (!aModel.IsNull()) { + aValue = aModel->GlobalSection().UnitName(); + + //if (!aValue.IsNull()) { + // Handle(TCollection_HAsciiString) aPrefix = new TCollection_HAsciiString ("UNIT_"); + // aValue->Prepend(aPrefix); + //} + } + } + else { + theError = theFileName + " reading failed"; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + theError = aFail->GetMessageString(); + } + + return aValue; + } + IGESIMPORT_EXPORT TopoDS_Shape Import (const TCollection_AsciiString& theFileName, const TCollection_AsciiString& theFormatName, TCollection_AsciiString& theError, const TDF_Label& theShapeLabel) { + TopoDS_Shape aResShape; + // Set "C" numeric locale to save numbers correctly Kernel_Utils::Localizer loc; IGESControl_Reader aReader; - TopoDS_Shape aResShape; + Interface_Static::SetCVal("xstep.cascade.unit","M"); + try { + OCC_CATCH_SIGNALS; + IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); if (status == IFSelect_RetDone) { + // BEGIN: old code if (theFormatName == "IGES_UNIT") { Handle(IGESData_IGESModel) aModel = Handle(IGESData_IGESModel)::DownCast(aReader.Model()); - gp_Pnt P(1.0,0.0,0.0); + gp_Pnt P (1.0, 0.0, 0.0); if (!aModel.IsNull()) { Handle(TCollection_HAsciiString) aUnitName = aModel->GlobalSection().UnitName(); - //cout<<"aUnitName = "<ToCString()<String()=="CM") { - P = gp_Pnt(0.01,0.0,0.0); + if (!aUnitName.IsNull()) { + if (aUnitName->String()=="MM") { + P = gp_Pnt(0.001,0.0,0.0); + } + else if (aUnitName->String()=="CM") { + P = gp_Pnt(0.01,0.0,0.0); + } } } BRep_Builder B; @@ -116,6 +171,8 @@ IGESIMPORT_EXPORT aResShape = V; return aResShape; } + // END: old code + if (theFormatName == "IGES_SCALE") { //cout<<"need re-scale a model"<