mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-13 02:00:35 +05:00
IMP 0021511: EDF 2153 GEOM: Choose to take units into account or not when importing a STEP file.
This commit is contained in:
parent
c314469058
commit
101ba2640b
@ -3211,6 +3211,17 @@ module GEOM
|
||||
*/
|
||||
GEOM_Object ImportFile (in string theFileName, in string theFormatName);
|
||||
|
||||
/*!
|
||||
* \brief Read a value of parameter from a file, containing a shape.
|
||||
* \param theFileName The file, containing the shape.
|
||||
* \param theFormatName Specify format for the file reading.
|
||||
* Available formats can be obtained with <VAR>ImportTranslators()</VAR> method.
|
||||
* \param theParameterName Specify the parameter. For example, pass "LEN_UNITS"
|
||||
* to obtain length units, in which the file is written.
|
||||
* \return Value of requested parameter in form of text string.
|
||||
*/
|
||||
string ReadValue (in string theFileName, in string theFormatName, in string theParameterName);
|
||||
|
||||
/*!
|
||||
* \brief Get the supported import formats and corresponding patterns for File dialog.
|
||||
* \param theFormats Output. List of formats, available for import.
|
||||
|
@ -18,7 +18,6 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
#include <Standard_Stream.hxx>
|
||||
|
||||
@ -61,10 +60,9 @@
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* constructor:
|
||||
* constructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID)
|
||||
: GEOM_IOperations(theEngine, theDocID)
|
||||
{
|
||||
@ -76,20 +74,17 @@ GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, i
|
||||
* destructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations()
|
||||
{
|
||||
MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* MakeCopy
|
||||
*/
|
||||
//=============================================================================
|
||||
Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) theOriginal)
|
||||
Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy (Handle(GEOM_Object) theOriginal)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
|
||||
@ -231,7 +226,6 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
|
||||
aCI.SetFileName(theFileName);
|
||||
aCI.SetFormatName(theFormatName);
|
||||
aCI.SetPluginName(aLibName);
|
||||
//cout<<"IIO: theFormatName = "<<theFormatName.ToCString()<<endl;
|
||||
|
||||
//Perform the Import
|
||||
try {
|
||||
@ -257,7 +251,8 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
|
||||
|
||||
SetErrorCode(OK);
|
||||
|
||||
if( theFormatName == "IGES_UNIT" ) {
|
||||
// OLD CODE: begin
|
||||
if (theFormatName == "IGES_UNIT") {
|
||||
TopoDS_Shape S = aFunction->GetValue();
|
||||
TopoDS_Vertex V = TopoDS::Vertex(S);
|
||||
gp_Pnt P = BRep_Tool::Pnt(V);
|
||||
@ -270,10 +265,42 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
|
||||
//cout<<"IIO: aUnitName = "<<aUnitName.ToCString()<<endl;
|
||||
SetErrorCode(aUnitName);
|
||||
}
|
||||
// OLD CODE: end
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* ReadValue
|
||||
*/
|
||||
//=============================================================================
|
||||
TCollection_AsciiString GEOMImpl_IInsertOperations::ReadValue
|
||||
(const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& theFormatName,
|
||||
const TCollection_AsciiString& theParameterName)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
|
||||
TCollection_AsciiString aValue, anError;
|
||||
|
||||
if (theFileName.IsEmpty() || theFormatName.IsEmpty() || theParameterName.IsEmpty()) return aValue;
|
||||
|
||||
Handle(TCollection_HAsciiString) aHLibName;
|
||||
if (!IsSupported(Standard_True, theFormatName.SubString(1,4), aHLibName)) {
|
||||
return aValue;
|
||||
}
|
||||
TCollection_AsciiString aLibName = aHLibName->String();
|
||||
|
||||
aValue = GEOMImpl_ImportDriver::ReadValue(theFileName, aLibName, theParameterName, anError);
|
||||
if (anError.IsEmpty())
|
||||
SetErrorCode(OK);
|
||||
else
|
||||
SetErrorCode(anError.ToCString());
|
||||
|
||||
return aValue;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* ImportTranslators
|
||||
|
@ -18,7 +18,6 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
#ifndef _GEOMImpl_IInsertOperations_HXX_
|
||||
#define _GEOMImpl_IInsertOperations_HXX_
|
||||
@ -55,6 +54,10 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
|
||||
Standard_EXPORT Handle(GEOM_Object) Import (const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& theFormatType);
|
||||
|
||||
Standard_EXPORT TCollection_AsciiString ReadValue (const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& theFormatType,
|
||||
const TCollection_AsciiString& theParameterName);
|
||||
|
||||
Standard_EXPORT void Export (const Handle(GEOM_Object) theOriginal,
|
||||
const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& theFormatType);
|
||||
|
@ -18,7 +18,6 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
#include <Standard_Stream.hxx>
|
||||
|
||||
@ -27,10 +26,12 @@
|
||||
#include <GEOMImpl_Types.hxx>
|
||||
#include <GEOM_Function.hxx>
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
@ -57,6 +58,10 @@ typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&,
|
||||
TCollection_AsciiString&,
|
||||
const TDF_Label&);
|
||||
|
||||
typedef Handle(TCollection_HAsciiString) (*pGetValue)(const TCollection_AsciiString&,
|
||||
const TCollection_AsciiString&,
|
||||
TCollection_AsciiString&);
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
@ -67,7 +72,6 @@ const Standard_GUID& GEOMImpl_ImportDriver::GetID()
|
||||
return aImportDriver;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GEOMImpl_ImportDriver
|
||||
//purpose :
|
||||
@ -97,6 +101,8 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
|
||||
|
||||
// load plugin library
|
||||
LibHandle anImportLib = LoadLib( aLibName.ToCString() ); //This is workaround of BUG OCC13051
|
||||
|
||||
// Get Import method
|
||||
funcPoint fp = 0;
|
||||
if ( anImportLib )
|
||||
fp = (funcPoint)GetProc( anImportLib, "Import" );
|
||||
@ -129,6 +135,53 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadValue
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString GEOMImpl_ImportDriver::ReadValue(const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& theLibName,
|
||||
const TCollection_AsciiString& theParameterName,
|
||||
TCollection_AsciiString& theError)
|
||||
{
|
||||
TCollection_AsciiString aValue;
|
||||
|
||||
if (theFileName.IsEmpty() || theLibName.IsEmpty() || theParameterName.IsEmpty())
|
||||
return aValue;
|
||||
|
||||
// load plugin library
|
||||
LibHandle anImportLib = LoadLib(theLibName.ToCString()); //This is workaround of BUG OCC13051
|
||||
if (!anImportLib) {
|
||||
theError = theLibName + " library was not installed";
|
||||
return aValue;
|
||||
}
|
||||
|
||||
// Get GetValue method
|
||||
pGetValue pGV = (pGetValue)GetProc(anImportLib, "GetValue");
|
||||
|
||||
if (!pGV) {
|
||||
theError = theLibName + " library doesn't support GetValue method";
|
||||
return aValue;
|
||||
}
|
||||
|
||||
Handle(TCollection_HAsciiString) aHValue = pGV(theFileName, theParameterName, theError);
|
||||
|
||||
if (aHValue.IsNull()) {
|
||||
if (theError.IsEmpty())
|
||||
theError = theFileName + " doesn't contain requested parameter";
|
||||
return aValue;
|
||||
}
|
||||
|
||||
aValue = aHValue->String();
|
||||
|
||||
// unload plugin library
|
||||
// commented by enk:
|
||||
// the bug was occured: using ACIS Import/Export plugin
|
||||
//UnLoadLib( anImportLib ); //This is workaround of BUG OCC13051
|
||||
|
||||
return aValue;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GEOMImpl_ImportDriver_Type_
|
||||
|
@ -18,11 +18,10 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File : GEOMImpl_ImportDriver.ixx
|
||||
// Module : GEOMImpl
|
||||
//
|
||||
|
||||
#ifndef _GEOMImpl_ImportDriver_HeaderFile
|
||||
#define _GEOMImpl_ImportDriver_HeaderFile
|
||||
|
||||
@ -119,6 +118,8 @@ class Handle(GEOMImpl_ImportDriver) : public Handle(TFunction_Driver) {
|
||||
#include <Standard_CString.hxx>
|
||||
#endif
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
class TColStd_SequenceOfExtendedString;
|
||||
|
||||
|
||||
@ -148,6 +149,11 @@ Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { r
|
||||
Standard_EXPORT static const Standard_GUID& GetID();
|
||||
Standard_EXPORT ~GEOMImpl_ImportDriver() {};
|
||||
|
||||
// Static method
|
||||
Standard_EXPORT static TCollection_AsciiString ReadValue (const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& theLibName,
|
||||
const TCollection_AsciiString& theParameterName,
|
||||
TCollection_AsciiString& theError);
|
||||
|
||||
// Type management
|
||||
//
|
||||
|
@ -647,6 +647,42 @@ bool GEOMToolsGUI::Import()
|
||||
CORBA::String_var fileN = fileName.toLatin1().constData();
|
||||
CORBA::String_var fileT = aCurrentType.toLatin1().constData();
|
||||
|
||||
// jfa 21.08.2012 for mantis issue 21511 (STEP file units)
|
||||
CORBA::String_var aUnits = aInsOp->ReadValue(fileN, fileT, "LEN_UNITS");
|
||||
TCollection_AsciiString aUnitsStr (aUnits.in());
|
||||
bool needConvert = true;
|
||||
if (aUnitsStr.IsEmpty() || aUnitsStr == "UNIT_M")
|
||||
needConvert = false;
|
||||
|
||||
if (needConvert) {
|
||||
if (igesAnswer == SUIT_MessageBox::NoToAll) {
|
||||
// converting for all files is already approved
|
||||
fileT = (aCurrentType + "_SCALE").toLatin1().constData();
|
||||
}
|
||||
else if (igesAnswer != SUIT_MessageBox::YesToAll) {
|
||||
SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No;
|
||||
if (i < fileNames.count() - 1) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll;
|
||||
igesAnswer = SUIT_MessageBox::question(app->desktop(),
|
||||
"Question",//tr("WRN_WARNING"),
|
||||
tr("GEOM_SCALE_DIMENSIONS"),
|
||||
btns | SUIT_MessageBox::Cancel,
|
||||
SUIT_MessageBox::No);
|
||||
switch (igesAnswer) {
|
||||
case SUIT_MessageBox::Cancel:
|
||||
return false; // cancel (break) import operation
|
||||
case SUIT_MessageBox::Yes:
|
||||
case SUIT_MessageBox::YesToAll:
|
||||
break; // scaling is confirmed
|
||||
case SUIT_MessageBox::No:
|
||||
case SUIT_MessageBox::NoAll:
|
||||
fileT = (aCurrentType + "_SCALE").toLatin1().constData();
|
||||
default:
|
||||
break; // scaling is rejected
|
||||
} // switch ( igesAnswer )
|
||||
} // if ( igeAnswer != NoToAll )
|
||||
} // if ( needConvert )
|
||||
|
||||
/*
|
||||
// skl 29.05.2009
|
||||
if ( aCurrentType == "IGES" ) {
|
||||
GEOM::GEOM_Object_var anObj = aInsOp->ImportFile( fileN, "IGES_UNIT" );
|
||||
@ -684,6 +720,9 @@ bool GEOMToolsGUI::Import()
|
||||
} // if ( needConvert )
|
||||
} // if ( aCurrentType == "IGES" )
|
||||
else if ( aCurrentType == "ACIS" ) {
|
||||
*/
|
||||
|
||||
if ( aCurrentType == "ACIS" ) {
|
||||
if ( acisAnswer != SUIT_MessageBox::YesToAll && acisAnswer != SUIT_MessageBox::NoToAll ) {
|
||||
SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No;
|
||||
if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll;
|
||||
@ -697,6 +736,7 @@ bool GEOMToolsGUI::Import()
|
||||
} // if ( acisAnswer != YesToAll && acisAnswer != NoToAll )
|
||||
} // else if ( aCurrentType == "ACIS" )
|
||||
|
||||
// IMPORT
|
||||
GEOM::GEOM_Object_var anObj = aInsOp->ImportFile( fileN, fileT );
|
||||
|
||||
if ( !anObj->_is_nil() && aInsOp->IsDone() ) {
|
||||
|
@ -18,7 +18,6 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
#ifdef WNT
|
||||
#pragma warning( disable:4786 )
|
||||
@ -47,7 +46,7 @@
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* constructor:
|
||||
* constructor
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM_IInsertOperations_i::GEOM_IInsertOperations_i (PortableServer::POA_ptr thePOA,
|
||||
@ -155,6 +154,32 @@ GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::ImportFile
|
||||
return GetObject(anObject);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* ReadValue
|
||||
*/
|
||||
//=============================================================================
|
||||
char* GEOM_IInsertOperations_i::ReadValue(const char* theFileName,
|
||||
const char* theFormatName,
|
||||
const char* theParameterName)
|
||||
{
|
||||
//Set a not done flag
|
||||
GetOperations()->SetNotDone();
|
||||
|
||||
char* aFileName = strdup(theFileName);
|
||||
char* aFormatName = strdup(theFormatName);
|
||||
char* aParameterName = strdup(theParameterName);
|
||||
|
||||
TCollection_AsciiString aUnits = GetOperations()->ReadValue
|
||||
(aFileName, aFormatName, aParameterName);
|
||||
|
||||
free(aFileName);
|
||||
free(aFormatName);
|
||||
free(aParameterName);
|
||||
|
||||
return CORBA::string_dup(aUnits.ToCString());
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* ImportTranslators
|
||||
|
@ -18,7 +18,6 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
#ifndef _GEOM_IInsertOperations_i_HeaderFile
|
||||
#define _GEOM_IInsertOperations_i_HeaderFile
|
||||
@ -52,6 +51,10 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i :
|
||||
GEOM::GEOM_Object_ptr ImportFile (const char* theFileName,
|
||||
const char* theFormatName);
|
||||
|
||||
char* ReadValue (const char* theFileName,
|
||||
const char* theFormatName,
|
||||
const char* theParameterName);
|
||||
|
||||
void ImportTranslators (GEOM::string_array_out theFormats,
|
||||
GEOM::string_array_out thePatterns);
|
||||
|
||||
|
@ -51,6 +51,8 @@
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
||||
|
||||
#ifdef WNT
|
||||
#if defined IGESIMPORT_EXPORTS || defined IGESImport_EXPORTS
|
||||
#if defined WIN32
|
||||
@ -77,33 +79,84 @@
|
||||
|
||||
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();
|
||||
if (!aUnitName.IsNull()) {
|
||||
//cout<<"aUnitName = "<<aUnitName->ToCString()<<endl;
|
||||
//cout<<"aUnitFlag = "<<aModel->GlobalSection().UnitFlag()<<endl;
|
||||
if (aUnitName->String()=="MM") {
|
||||
P = gp_Pnt(0.001,0.0,0.0);
|
||||
}
|
||||
@ -111,8 +164,6 @@ IGESIMPORT_EXPORT
|
||||
P = gp_Pnt(0.01,0.0,0.0);
|
||||
}
|
||||
}
|
||||
//else
|
||||
// cout << "aUnitName is NULL !!" << endl;
|
||||
}
|
||||
BRep_Builder B;
|
||||
TopoDS_Vertex V;
|
||||
@ -120,6 +171,8 @@ IGESIMPORT_EXPORT
|
||||
aResShape = V;
|
||||
return aResShape;
|
||||
}
|
||||
// END: old code
|
||||
|
||||
if (theFormatName == "IGES_SCALE") {
|
||||
//cout<<"need re-scale a model"<<endl;
|
||||
// set UnitFlag to 'meter'
|
||||
|
@ -18,7 +18,6 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File: STEPImport.cxx
|
||||
// Created: Wed May 19 14:41:10 2004
|
||||
@ -29,7 +28,12 @@
|
||||
#include <Basics_Utils.hxx>
|
||||
#include <Basics_OCCTVersion.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TDF_ChildIDIterator.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TNaming_Builder.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
|
||||
#include <IFSelect_ReturnStatus.hxx>
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
@ -39,23 +43,23 @@
|
||||
#include <StepBasic_ProductDefinitionFormation.hxx>
|
||||
#include <StepGeom_GeometricRepresentationItem.hxx>
|
||||
#include <StepShape_TopologicalRepresentationItem.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TDF_ChildIDIterator.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TNaming_Builder.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <TransferBRep.hxx>
|
||||
#include <Transfer_Binder.hxx>
|
||||
#include <Transfer_TransientProcess.hxx>
|
||||
#include <XSControl_TransferReader.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TransferBRep.hxx>
|
||||
#include <Transfer_Binder.hxx>
|
||||
#include <Transfer_TransientProcess.hxx>
|
||||
#include <XSControl_TransferReader.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColStd_SequenceOfAsciiString.hxx>
|
||||
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
||||
@ -87,34 +91,134 @@
|
||||
extern "C"
|
||||
{
|
||||
STEPIMPORT_EXPORT
|
||||
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& /*theFormatName*/,
|
||||
TCollection_AsciiString& theError,
|
||||
const TDF_Label& theShapeLabel)
|
||||
Handle(TCollection_HAsciiString) GetValue (const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& theParameterName,
|
||||
TCollection_AsciiString& theError)
|
||||
{
|
||||
MESSAGE("Import STEP model from file " << theFileName.ToCString());
|
||||
Handle(TCollection_HAsciiString) aValue;
|
||||
|
||||
if (theParameterName != "LEN_UNITS") {
|
||||
theError = theParameterName + " parameter reading is not supported by STEP plugin";
|
||||
return aValue;
|
||||
}
|
||||
|
||||
// Set "C" numeric locale to save numbers correctly
|
||||
Kernel_Utils::Localizer loc;
|
||||
TopoDS_Shape aResShape;
|
||||
//VRV: OCC 4.0 migration
|
||||
|
||||
STEPControl_Reader aReader;
|
||||
//VSR: 16/09/09: Convert to METERS
|
||||
|
||||
Interface_Static::SetCVal("xstep.cascade.unit","M");
|
||||
Interface_Static::SetIVal("read.step.ideas", 1);
|
||||
Interface_Static::SetIVal("read.step.nonmanifold", 1);
|
||||
//VRV: OCC 4.0 migration
|
||||
TopoDS_Compound compound;
|
||||
BRep_Builder B;
|
||||
B.MakeCompound(compound);
|
||||
|
||||
try {
|
||||
#if OCC_VERSION_LARGE > 0x06010000
|
||||
OCC_CATCH_SIGNALS;
|
||||
#endif
|
||||
IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString());
|
||||
if (status == IFSelect_RetDone) {
|
||||
TColStd_SequenceOfAsciiString anUnitLengthNames;
|
||||
TColStd_SequenceOfAsciiString anUnitAngleNames;
|
||||
TColStd_SequenceOfAsciiString anUnitSolidAngleNames;
|
||||
aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames);
|
||||
if (anUnitLengthNames.Length() > 0) {
|
||||
TCollection_AsciiString aLenUnits = anUnitLengthNames.First();
|
||||
if (aLenUnits == "millimetre")
|
||||
aValue = new TCollection_HAsciiString ("UNIT_MM");
|
||||
else if (aLenUnits == "centimetre")
|
||||
aValue = new TCollection_HAsciiString ("UNIT_CM");
|
||||
else if (aLenUnits == "metre")
|
||||
aValue = new TCollection_HAsciiString ("UNIT_M");
|
||||
else if (aLenUnits == "INCH")
|
||||
aValue = new TCollection_HAsciiString ("UNIT_INCH");
|
||||
// TODO
|
||||
//else if (aLenUnits == "")
|
||||
// aValue = new TCollection_HAsciiString ("");
|
||||
|
||||
// tmp begin
|
||||
//std::cout << "$$$ --- " << anUnitLengthNames.First();
|
||||
//for (int ii = 2; ii <= anUnitLengthNames.Length(); ii++)
|
||||
// std::cout << ", " << anUnitLengthNames.Value(ii);
|
||||
//std::cout << std::endl;
|
||||
// tmp end
|
||||
}
|
||||
}
|
||||
else {
|
||||
theError = theFileName + " reading failed";
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
||||
theError = aFail->GetMessageString();
|
||||
}
|
||||
|
||||
return aValue;
|
||||
}
|
||||
|
||||
STEPIMPORT_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;
|
||||
|
||||
STEPControl_Reader aReader;
|
||||
|
||||
//VSR: 16/09/09: Convert to METERS
|
||||
Interface_Static::SetCVal("xstep.cascade.unit","M");
|
||||
Interface_Static::SetIVal("read.step.ideas", 1);
|
||||
Interface_Static::SetIVal("read.step.nonmanifold", 1);
|
||||
|
||||
BRep_Builder B;
|
||||
TopoDS_Compound compound;
|
||||
B.MakeCompound(compound);
|
||||
|
||||
try {
|
||||
OCC_CATCH_SIGNALS;
|
||||
|
||||
IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString());
|
||||
|
||||
if (status == IFSelect_RetDone) {
|
||||
|
||||
// Regard or not the model units
|
||||
if (theFormatName == "STEP_SCALE") {
|
||||
// set UnitFlag to units from file
|
||||
TColStd_SequenceOfAsciiString anUnitLengthNames;
|
||||
TColStd_SequenceOfAsciiString anUnitAngleNames;
|
||||
TColStd_SequenceOfAsciiString anUnitSolidAngleNames;
|
||||
aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames);
|
||||
if (anUnitLengthNames.Length() > 0) {
|
||||
TCollection_AsciiString aLenUnits = anUnitLengthNames.First();
|
||||
if (aLenUnits == "millimetre")
|
||||
Interface_Static::SetCVal("xstep.cascade.unit", "MM");
|
||||
else if (aLenUnits == "centimetre")
|
||||
Interface_Static::SetCVal("xstep.cascade.unit", "CM");
|
||||
else if (aLenUnits == "metre")
|
||||
Interface_Static::SetCVal("xstep.cascade.unit", "M");
|
||||
else if (aLenUnits == "INCH")
|
||||
Interface_Static::SetCVal("xstep.cascade.unit", "INCH");
|
||||
else {
|
||||
theError = "The file contains not supported units.";
|
||||
return aResShape;
|
||||
}
|
||||
// TODO
|
||||
//else if (aLenUnits == "")
|
||||
// Interface_Static::SetCVal("xstep.cascade.unit", "");
|
||||
}
|
||||
}
|
||||
else {
|
||||
//cout<<"need re-scale a model"<<endl;
|
||||
// set UnitFlag to 'meter'
|
||||
Interface_Static::SetCVal("xstep.cascade.unit","M");
|
||||
}
|
||||
|
||||
Standard_Boolean failsonly = Standard_False;
|
||||
aReader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity);
|
||||
|
||||
/* Root transfers */
|
||||
Standard_Integer nbr = aReader.NbRootsForTransfer();
|
||||
aReader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity);
|
||||
|
Loading…
Reference in New Issue
Block a user