From 615e23820b78f6378c730027fdacedfbb553324d Mon Sep 17 00:00:00 2001 From: skl Date: Wed, 3 Jun 2009 07:39:16 +0000 Subject: [PATCH] For improvements 20019 and 20324. --- src/BREPImport/BREPImport.cxx | 4 +- src/GEOMImpl/GEOMImpl_IInsertOperations.cxx | 24 ++- src/GEOMImpl/GEOMImpl_ImportDriver.cxx | 7 +- src/GEOMToolsGUI/GEOMToolsGUI.cxx | 31 ++++ src/GEOM_I/GEOM_Gen_i.cc | 189 ++++++++++++++++++-- src/GEOM_I/GEOM_Gen_i.hh | 14 ++ src/GEOM_I/GEOM_IInsertOperations_i.cc | 10 +- src/GEOM_I_Superv/GEOM_Superv_i.cc | 14 ++ src/GEOM_I_Superv/GEOM_Superv_i.hh | 4 + src/GEOM_SWIG/geompyDC.py | 20 +++ src/IGESImport/IGESImport.cxx | 48 ++++- src/STEPImport/STEPImport.cxx | 4 +- 12 files changed, 343 insertions(+), 26 deletions(-) diff --git a/src/BREPImport/BREPImport.cxx b/src/BREPImport/BREPImport.cxx index c34ae95fb..79cc2b648 100644 --- a/src/BREPImport/BREPImport.cxx +++ b/src/BREPImport/BREPImport.cxx @@ -31,6 +31,7 @@ #include #include +#include #ifdef WNT #if defined BREPIMPORT_EXPORTS || defined BREPImport_EXPORTS @@ -61,7 +62,8 @@ extern "C" BREPIMPORT_EXPORT TopoDS_Shape Import (const TCollection_AsciiString& theFileName, const TCollection_AsciiString& /*theFormatName*/, - TCollection_AsciiString& theError) + TCollection_AsciiString& theError, + const TDF_Label&) { MESSAGE("Import BREP from file " << theFileName); TopoDS_Shape aShape; diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx index 5fb461ff7..102ebba74 100644 --- a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx @@ -44,6 +44,11 @@ #include +#include +#include +#include +#include + #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC @@ -206,7 +211,7 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result; Handle(TCollection_HAsciiString) aHLibName; - if (!IsSupported(Standard_True, theFormatName, aHLibName)) { + if (!IsSupported(Standard_True, theFormatName.SubString(1,4), aHLibName)) { return result; } TCollection_AsciiString aLibName = aHLibName->String(); @@ -216,6 +221,7 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import aCI.SetFileName(theFileName); aCI.SetFormatName(theFormatName); aCI.SetPluginName(aLibName); + //cout<<"IIO: theFormatName = "<GetValue(); + TopoDS_Vertex V = TopoDS::Vertex(S); + gp_Pnt P = BRep_Tool::Pnt(V); + double scale = P.X(); + TCollection_AsciiString aUnitName = "UNIT_M"; + if( fabs(scale-0.01) < 1.e-6 ) + aUnitName = "UNIT_CM"; + else if( fabs(scale-0.001) < 1.e-6 ) + aUnitName = "UNIT_MM"; + //cout<<"IIO: aUnitName = "<Find(aMode.ToCString())) { TCollection_AsciiString aFormats (myResMgr->Value(aMode.ToCString())); diff --git a/src/GEOMImpl/GEOMImpl_ImportDriver.cxx b/src/GEOMImpl/GEOMImpl_ImportDriver.cxx index 4a309a0b6..0118c7514 100644 --- a/src/GEOMImpl/GEOMImpl_ImportDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ImportDriver.cxx @@ -53,7 +53,8 @@ typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&, const TCollection_AsciiString&, - TCollection_AsciiString&); + TCollection_AsciiString&, + const TDF_Label&); //======================================================================= //function : GetID @@ -100,14 +101,14 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const fp = (funcPoint)GetProc( anImportLib, "Import" ); if ( !fp ) { - TCollection_AsciiString aMsg = aFormatName; + TCollection_AsciiString aMsg = aFormatName.SubString(1,4); aMsg += " plugin was not installed"; Standard_Failure::Raise(aMsg.ToCString()); } // perform the import TCollection_AsciiString anError; - TopoDS_Shape aShape = fp( aFileName, aFormatName, anError ); + TopoDS_Shape aShape = fp( aFileName, aFormatName, anError, aFunction->GetEntry() ); // unload plugin library // commented by enk: diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index 4945b72e8..c3556b638 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -694,6 +694,7 @@ bool GEOMToolsGUI::Import() continue; } + GEOM_Operation* anOp = new GEOM_Operation( app, aInsOp.in() ); try { app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( SUIT_Tools::file( fileName, /*withExten=*/true ) ) ); @@ -701,6 +702,26 @@ bool GEOMToolsGUI::Import() CORBA::String_var fileN = fileName.toLatin1().constData(); CORBA::String_var fileT = aCurrentType.toLatin1().constData(); + + // skl 29.05.2009 + if( aCurrentType == "IGES" ) { + GEOM::GEOM_Object_var anObj = aInsOp->Import( fileN, "IGES_UNIT" ); + TCollection_AsciiString aUnitName = aInsOp->GetErrorCode(); + //cout<<"GUI: aUnitName = "<desktop(), + "Question",//tr("WRN_WARNING"), + "Length unit in given file is not a 'meter'. Is it needed to scale a model?", + SUIT_MessageBox::Yes | SUIT_MessageBox::No, + SUIT_MessageBox::No) == SUIT_MessageBox::Yes ) { + fileT = "IGES_SCALE"; + } + } + } + } + GEOM::GEOM_Object_var anObj = aInsOp->Import( fileN, fileT ); if ( !anObj->_is_nil() && aInsOp->IsDone() ) { @@ -715,6 +736,16 @@ bool GEOMToolsGUI::Import() objsForDisplay.append( anObj ); + if( aCurrentType == "ACIS" ) { + if( SUIT_MessageBox::question( app->desktop(), + "Question",//tr("WRN_WARNING"), + "Given file contents some names. Is it needed to create groups for named shapes?", + SUIT_MessageBox::Yes | SUIT_MessageBox::No, + SUIT_MessageBox::No) == SUIT_MessageBox::Yes ) { + GeometryGUI::GetGeomGen()->PublishNamedShapesInStudy(aDSStudy, anObj); + } + } + anOp->commit(); } else { diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index 7f9f5cab4..2758bf025 100644 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -39,6 +39,7 @@ #include "GEOM_Object_i.hh" #include "GEOM_Object.hxx" #include "GEOM_Function.hxx" +#include "GEOM_ISubShape.hxx" #include "GEOMImpl_Types.hxx" #include "GEOMImpl_CopyDriver.hxx" @@ -47,9 +48,14 @@ #include #include #include +#include +#include +#include #include #include #include +//#include +#include #include #include "SALOMEDS_Tool.hxx" @@ -248,24 +254,57 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, } //if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag()); //else aShapeName = TCollection_AsciiString(CORBA::string_dup(theName)); + + // try to find existed name for current shape + bool HasName = false; + // recieve current TopoDS shape + CORBA::String_var entry = aShape->GetEntry(); + Handle(GEOM_Object) aGShape = _impl->GetObject(aShape->GetStudyID(), entry); + TopoDS_Shape TopoSh = aGShape->GetValue(); + // find label of main shape + GEOM::GEOM_Object_var aMainShVar = aShape; + GEOM::GEOM_Object_ptr aMainSh = aMainShVar._retn(); + while( !aMainSh->IsMainShape() ) { + aMainSh = aMainSh->GetMainShape(); + } + entry = aMainSh->GetEntry(); + Handle(GEOM_Object) anObj = _impl->GetObject(aMainSh->GetStudyID(), entry); + TDF_Label aMainLbl = anObj->GetEntry(); + // check all named shapes using iterator + TDF_ChildIDIterator anIt(aMainLbl, TNaming_NamedShape::GetID(), Standard_True); + for(; anIt.More(); anIt.Next()) { + Handle(TNaming_NamedShape) anAttr = + Handle(TNaming_NamedShape)::DownCast(anIt.Value()); + if(anAttr.IsNull()) continue; + TopoDS_Shape S = anAttr->Get(); + if( !S.IsEqual(TopoSh) ) continue; + TDF_Label L = anAttr->Label(); + Handle(TDataStd_Name) aName; + if(L.FindAttribute(TDataStd_Name::GetID(),aName)) { + aShapeName = aName->Get(); + HasName = true; + } + } - // asv : 11.11.04 Introducing a more sofisticated method of name creation, just as - // it is done in GUI in GEOMBase::GetDefaultName() - not just add a Tag() == number - // of objects in the study, but compute a number of objects with the same prefix - // and build a new name as Prefix_N+1 - if ( strlen( theName ) == 0 ) { // MOST PROBABLY CALLED FROM BATCHMODE OR SUPERVISOR - int i = 0; // (WITH EMPTY NEW NAME) - SALOMEDS::SObject_var obj; - TCollection_AsciiString aNewShapeName; - do { - aNewShapeName = aShapeName + TCollection_AsciiString(++i); - obj = theStudy->FindObject( aNewShapeName.ToCString() ); + if(!HasName) { + // asv : 11.11.04 Introducing a more sofisticated method of name creation, just as + // it is done in GUI in GEOMBase::GetDefaultName() - not just add a Tag() == number + // of objects in the study, but compute a number of objects with the same prefix + // and build a new name as Prefix_N+1 + if ( strlen( theName ) == 0 ) { // MOST PROBABLY CALLED FROM BATCHMODE OR SUPERVISOR + int i = 0; // (WITH EMPTY NEW NAME) + SALOMEDS::SObject_var obj; + TCollection_AsciiString aNewShapeName; + do { + aNewShapeName = aShapeName + TCollection_AsciiString(++i); + obj = theStudy->FindObject( aNewShapeName.ToCString() ); + } + while ( !obj->_is_nil() ); + aShapeName = aNewShapeName; } - while ( !obj->_is_nil() ); - aShapeName = aNewShapeName; + else // MOST PROBABLY CALLED FROM GEOM GUI (ALREADY WITH VALID NAME) + aShapeName = TCollection_AsciiString((char*)theName); } - else // MOST PROBABLY CALLED FROM GEOM GUI (ALREADY WITH VALID NAME) - aShapeName = TCollection_AsciiString((char*)theName); //Set the study entry as a name of the published GEOM_Object aShape->SetStudyEntry(aResultSO->GetID()); @@ -300,6 +339,126 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, } +//============================================================================ +// function : CreateAndPublishGroup +// purpose : auxilary for PublishNamedShapesInStudy +//============================================================================ +void GEOM_Gen_i::CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy, + GEOM::GEOM_Object_var theMainShape, + const TopTools_IndexedMapOfShape& anIndices, + const TopTools_SequenceOfShape& SeqS, + const TColStd_SequenceOfAsciiString& SeqN, + const Standard_CString& GrName, + GEOM::ListOfGO_var aResList) +{ + CORBA::String_var entry = theMainShape->GetEntry(); + Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry); + Handle(TColStd_HArray1OfInteger) anArray; + if(SeqS.Length()>0) { + // create a group + GEOM::GEOM_IGroupOperations_var GOp = GetIGroupOperations(theStudy->StudyId()); + GEOM::GEOM_Object_ptr GrObj = + GOp->CreateGroup( theMainShape, SeqS.Value(1).ShapeType() ); + AddInStudy(theStudy, GrObj, GrName, theMainShape._retn()); + // add named objects + Handle(GEOM_Object) anObj; + for(int i=1; i<=SeqS.Length(); i++) { + TopoDS_Shape aValue = SeqS.Value(i); + anArray = new TColStd_HArray1OfInteger(1,1); + Standard_Integer anIndex = anIndices.FindIndex(aValue); + anArray->SetValue(1, anIndex); + anObj = GEOM_Engine::GetEngine()->AddObject(aMainShape->GetDocID(), GEOM_SUBSHAPE); + if (anObj.IsNull()) continue; + Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1); + if (aFunction.IsNull()) continue; + GEOM_ISubShape aSSI(aFunction); + aSSI.SetMainShape(aMainShape->GetLastFunction()); + aSSI.SetIndices(anArray); + aFunction->SetValue(aValue); + GOp->UnionIDs(GrObj, anIndex); + SALOMEDS::SObject_var aResultSO; + TCollection_AsciiString anEntry; + TDF_Tool::Entry(anObj->GetEntry(),anEntry); + GEOM::GEOM_Object_var aGObj = GetObject(anObj->GetDocID(), anEntry.ToCString()); + AddInStudy(theStudy, aGObj._retn(), SeqN.Value(i).ToCString(), GrObj); + } + } +} + + +//============================================================================ +// function : PublishNamedShapesInStudy +// purpose : +//============================================================================ +GEOM::ListOfGO* GEOM_Gen_i:: + PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy, + //SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject) +{ + //Unexpect aCatch(SALOME_SalomeException); + GEOM::ListOfGO_var aResList = new GEOM::ListOfGO; + + //CORBA::Object_var theObject = theSObject->GetObject(); + GEOM::GEOM_Object_var theMainShape = GEOM::GEOM_Object::_narrow(theObject); + if(theMainShape->_is_nil()) return aResList._retn(); + + CORBA::String_var entry = theMainShape->GetEntry(); + Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry); + if (aMainShape.IsNull()) return aResList._retn(); + TopoDS_Shape MainSh = aMainShape->GetValue(); + + TDF_Label aMainLbl = aMainShape->GetEntry(); + TopTools_SequenceOfShape SolidSeqS, FaceSeqS, EdgeSeqS, VertSeqS; + TColStd_SequenceOfAsciiString SolidSeqN, FaceSeqN, EdgeSeqN, VertSeqN; + TDF_ChildIDIterator anIt(aMainLbl, TNaming_NamedShape::GetID(), Standard_True); + for(; anIt.More(); anIt.Next()) { + Handle(TNaming_NamedShape) anAttr = + Handle(TNaming_NamedShape)::DownCast(anIt.Value()); + if(anAttr.IsNull()) continue; + TopoDS_Shape S = anAttr->Get(); + TDF_Label L = anAttr->Label(); + //if(S.IsEqual(MainSh)) continue; + Handle(TDataStd_Name) aName; + if(L.FindAttribute(TDataStd_Name::GetID(),aName)) { + TCollection_ExtendedString EName = aName->Get(); + if(S.ShapeType()==TopAbs_SOLID) { + SolidSeqS.Append(S); + SolidSeqN.Append(aName->Get()); + } + else if(S.ShapeType()==TopAbs_FACE) { + FaceSeqS.Append(S); + FaceSeqN.Append(aName->Get()); + } + else if(S.ShapeType()==TopAbs_EDGE) { + EdgeSeqS.Append(S); + EdgeSeqN.Append(aName->Get()); + } + else if(S.ShapeType()==TopAbs_VERTEX) { + VertSeqS.Append(S); + VertSeqN.Append(aName->Get()); + } + } + } + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(MainSh, anIndices); + + CreateAndPublishGroup(theStudy, theMainShape, anIndices, SolidSeqS, SolidSeqN, + "Group_Of_Named_Solids", aResList); + + CreateAndPublishGroup(theStudy, theMainShape, anIndices, FaceSeqS, FaceSeqN, + "Group_Of_Named_Faces", aResList); + + CreateAndPublishGroup(theStudy, theMainShape, anIndices, EdgeSeqS, EdgeSeqN, + "Group_Of_Named_Edges", aResList); + + CreateAndPublishGroup(theStudy, theMainShape, anIndices, VertSeqS, VertSeqN, + "Group_Of_Named_Vertices", aResList); + + return aResList._retn(); +} + + //============================================================================ // function : Save() // purpose : save OCAF/Geom document diff --git a/src/GEOM_I/GEOM_Gen_i.hh b/src/GEOM_I/GEOM_Gen_i.hh index aba3b6aa6..75b56384f 100644 --- a/src/GEOM_I/GEOM_Gen_i.hh +++ b/src/GEOM_I/GEOM_Gen_i.hh @@ -50,6 +50,8 @@ #include "GEOM_IMeasureOperations_i.hh" #include "GEOM_IGroupOperations_i.hh" +#include + //#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC @@ -120,6 +122,9 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi CORBA::Object_ptr theObject, const char* theName) throw (SALOME::SALOME_Exception) ; + GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy, + CORBA::Object_ptr theObject); + CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject); SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID); CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID); @@ -257,6 +262,15 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi GEOM::find_shape_method theFindMethod, CORBA::Boolean theInheritFirstArg); + // auxilary for PublishNamedShapesInStudy + void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy, + GEOM::GEOM_Object_var theMainShape, + const TopTools_IndexedMapOfShape& anIndices, + const TopTools_SequenceOfShape& SeqS, + const TColStd_SequenceOfAsciiString& SeqN, + const Standard_CString& GrName, + GEOM::ListOfGO_var aResList); + private: ::GEOMImpl_Gen* _impl; diff --git a/src/GEOM_I/GEOM_IInsertOperations_i.cc b/src/GEOM_I/GEOM_IInsertOperations_i.cc index 832b8df27..b32b3eb71 100644 --- a/src/GEOM_I/GEOM_IInsertOperations_i.cc +++ b/src/GEOM_I/GEOM_IInsertOperations_i.cc @@ -129,11 +129,19 @@ GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::Import char* aFileName = strdup(theFileName); char* aFormatName = strdup(theFormatName); Handle(GEOM_Object) anObject = GetOperations()->Import(aFileName, aFormatName); + + if( strcmp(aFormatName,"IGES_UNIT")==0 && !anObject.IsNull() ) { + free(aFileName); + free(aFormatName); + return GetObject(anObject); + } + free(aFileName); free(aFormatName); - if (!GetOperations()->IsDone() || anObject.IsNull()) + if (!GetOperations()->IsDone() || anObject.IsNull()) { return aGEOMObject._retn(); + } return GetObject(anObject); } diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index a5e8efb38..f749b8641 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -473,6 +473,20 @@ SALOMEDS::SObject_ptr GEOM_Superv_i::PublishInStudy(SALOMEDS::Study_ptr theStudy return myGeomEngine->PublishInStudy(theStudy, theSObject, theObject, theName); } +//============================================================================ +// function : PublishNamedShapesInStudy +// purpose : +//============================================================================ +GEOM::ListOfGO* +GEOM_Superv_i::PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy, + //SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject) +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + return myGeomEngine->PublishNamedShapesInStudy(theStudy, theObject); +} + //============================================================================ // function : CanCopy() // purpose : diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index da63e2366..1568f0bb1 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -125,6 +125,10 @@ public: CORBA::Object_ptr theObject, const char* theName) throw (SALOME::SALOME_Exception) ; + GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy, + //SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject); + CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject); SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID); CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID); diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index eac732fd8..1cf7bd07f 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -3204,6 +3204,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theFileName The file, containing the shape. # @param theFormatName Specify format for the file reading. # Available formats can be obtained with InsertOp.ImportTranslators() method. + # If format 'IGES_SCALE' is used instead 'IGES' length unit will be + # set to 'meter' and result model will be scaled. # @return New GEOM_Object, containing the imported shape. # # @ref swig_Import_Export "Example" @@ -3227,6 +3229,24 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py return self.Import(theFileName, "IGES") + ## Return length unit from given IGES file + # + # @ref swig_Import_Export "Example" + def GetIGESUnit(self,theFileName): + # Example: see GEOM_TestOthers.py + anObj = self.InsertOp.Import(theFileName, "IGES_UNIT") + #RaiseIfFailed("Import", self.InsertOp) + # recieve name using returned vertex + UnitName = "M" + vertices = self.SubShapeAll(anObj,ShapeType["VERTEX"]) + if len(vertices)>0: + p = self.PointCoordinates(vertices[0]) + if abs(p[0]-0.01) < 1.e-6: + UnitName = "CM" + elif abs(p[0]-0.001) < 1.e-6: + UnitName = "MM" + return UnitName + ## Shortcut to Import() for STEP format # # @ref swig_Import_Export "Example" diff --git a/src/IGESImport/IGESImport.cxx b/src/IGESImport/IGESImport.cxx index 51ed1ebe3..fbbe1c9b4 100644 --- a/src/IGESImport/IGESImport.cxx +++ b/src/IGESImport/IGESImport.cxx @@ -28,9 +28,15 @@ #include #include +#include -#include +#include #include +#include + +#include +#include +#include #ifdef WNT #if defined IGESIMPORT_EXPORTS || defined IGESImport_EXPORTS @@ -60,8 +66,9 @@ extern "C" { IGESIMPORT_EXPORT TopoDS_Shape Import (const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& /*theFormatName*/, - TCollection_AsciiString& theError) + const TCollection_AsciiString& theFormatName, + TCollection_AsciiString& theError, + const TDF_Label&) { IGESControl_Reader aReader; TopoDS_Shape aResShape; @@ -69,6 +76,41 @@ IGESIMPORT_EXPORT IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); if (status == IFSelect_RetDone) { + + if( theFormatName == "IGES_UNIT" ) { + Handle(IGESData_IGESModel) aModel = + Handle(IGESData_IGESModel)::DownCast(aReader.Model()); + 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); + } + } + BRep_Builder B; + TopoDS_Vertex V; + B.MakeVertex(V,P,1.e-7); + aResShape = V; + return aResShape; + } + if( theFormatName == "IGES_SCALE" ) { + //cout<<"need re-scale a model"<GlobalSection(); + aGS.SetUnitFlag(6); + aModel->SetGlobalSection(aGS); + } + } + MESSAGE("ImportIGES : all Geometry Transfer"); //OCC 5.1.2 porting // aReader.Clear(); diff --git a/src/STEPImport/STEPImport.cxx b/src/STEPImport/STEPImport.cxx index 4440aeb87..33e15f524 100644 --- a/src/STEPImport/STEPImport.cxx +++ b/src/STEPImport/STEPImport.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC @@ -68,7 +69,8 @@ extern "C" STEPIMPORT_EXPORT TopoDS_Shape Import (const TCollection_AsciiString& theFileName, const TCollection_AsciiString& /*theFormatName*/, - TCollection_AsciiString& theError) + TCollection_AsciiString& theError, + const TDF_Label&) { MESSAGE("Import STEP model from file " << theFileName.ToCString()); TopoDS_Shape aResShape; -- 2.39.2