mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0030694: Data Exchange - support non-standard GB2312-encoded STEP files
STEPCAFControl_Reader::SourceCodePage() - added property defining text encoding for converting names within STEPCAFControl_Reader::ReadNames() method. Added associated "read.stepcaf.codepage" parameter, which default value is Resource_UTF8, preserving current behavior. Resource_FormatType enumeration has been extended by UTF8 and SystemLocale values. Resource_Unicode - added conversion methods taking Resource_FormatType as argument. GetName command has been corrected to NOT replace non-Latin symbols.
This commit is contained in:
@@ -69,5 +69,17 @@ Standard_Boolean STEPCAFControl_Controller::Init ()
|
||||
Interface_Static::Init ("stepcaf", "read.stepcaf.subshapes.name", '&', "eval On"); // 1
|
||||
Interface_Static::SetIVal("read.stepcaf.subshapes.name", 0); // Disabled by default
|
||||
|
||||
// STEP file encoding for names translation
|
||||
// Note: the numbers should be consistent with Resource_FormatType enumeration
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", 'e', "");
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "enum 0");
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval SJIS"); // Resource_FormatType_SJIS
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval EUC"); // Resource_FormatType_EUC
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval ANSI"); // Resource_FormatType_ANSI
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval GB"); // Resource_FormatType_GB
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval UTF8"); // Resource_FormatType_UTF8
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval SystemLocale"); // Resource_FormatType_SystemLocale
|
||||
Interface_Static::SetCVal ("read.stepcaf.codepage", "UTF8");
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
@@ -277,6 +277,7 @@
|
||||
#include <Transfer_ActorOfTransientProcess.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <Resource_Unicode.hxx>
|
||||
|
||||
// skl 21.08.2003 for reading G&DT
|
||||
//#include <StepRepr_CompoundItemDefinition.hxx>
|
||||
@@ -315,7 +316,8 @@ TCollection_AsciiString AddrToString(const TopoDS_Shape& theShape)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
STEPCAFControl_Reader::STEPCAFControl_Reader() :
|
||||
STEPCAFControl_Reader::STEPCAFControl_Reader()
|
||||
: mySourceCodePage (Resource_FormatType_UTF8),
|
||||
myColorMode(Standard_True),
|
||||
myNameMode(Standard_True),
|
||||
myLayerMode(Standard_True),
|
||||
@@ -326,6 +328,7 @@ STEPCAFControl_Reader::STEPCAFControl_Reader() :
|
||||
myViewMode(Standard_True)
|
||||
{
|
||||
STEPCAFControl_Controller::Init();
|
||||
mySourceCodePage = (Resource_FormatType )Interface_Static::IVal ("read.stepcaf.codepage");
|
||||
}
|
||||
|
||||
|
||||
@@ -335,7 +338,8 @@ STEPCAFControl_Reader::STEPCAFControl_Reader() :
|
||||
//=======================================================================
|
||||
|
||||
STEPCAFControl_Reader::STEPCAFControl_Reader(const Handle(XSControl_WorkSession)& WS,
|
||||
const Standard_Boolean scratch) :
|
||||
const Standard_Boolean scratch)
|
||||
: mySourceCodePage (Resource_FormatType_UTF8),
|
||||
myColorMode(Standard_True),
|
||||
myNameMode(Standard_True),
|
||||
myLayerMode(Standard_True),
|
||||
@@ -346,6 +350,7 @@ STEPCAFControl_Reader::STEPCAFControl_Reader(const Handle(XSControl_WorkSession)
|
||||
myViewMode(Standard_True)
|
||||
{
|
||||
STEPCAFControl_Controller::Init();
|
||||
mySourceCodePage = (Resource_FormatType )Interface_Static::IVal ("read.stepcaf.codepage");
|
||||
Init(WS, scratch);
|
||||
}
|
||||
|
||||
@@ -363,6 +368,16 @@ void STEPCAFControl_Reader::Init(const Handle(XSControl_WorkSession)& WS,
|
||||
myFiles.Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : convertName
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TCollection_ExtendedString STEPCAFControl_Reader::convertName (const TCollection_AsciiString& theName) const
|
||||
{
|
||||
TCollection_ExtendedString aName;
|
||||
Resource_Unicode::ConvertFormatToUnicode (mySourceCodePage, theName.ToCString(), aName);
|
||||
return aName;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadFile
|
||||
@@ -1158,7 +1173,8 @@ Standard_Boolean STEPCAFControl_Reader::ReadNames(const Handle(XSControl_WorkSes
|
||||
// find proper label
|
||||
L = FindInstance(NAUO, STool, Tool, ShapeLabelMap);
|
||||
if (L.IsNull()) continue;
|
||||
TCollection_ExtendedString str(name->String());
|
||||
|
||||
TCollection_ExtendedString str = convertName (name->String());
|
||||
TDataStd_Name::Set(L, str);
|
||||
}
|
||||
|
||||
@@ -1179,11 +1195,11 @@ Standard_Boolean STEPCAFControl_Reader::ReadNames(const Handle(XSControl_WorkSes
|
||||
name = new TCollection_HAsciiString;
|
||||
L = GetLabelFromPD(PD, STool, TP, PDFileMap, ShapeLabelMap);
|
||||
if (L.IsNull()) continue;
|
||||
TCollection_ExtendedString str(name->String());
|
||||
TCollection_ExtendedString str = convertName (name->String());
|
||||
TDataStd_Name::Set(L, str);
|
||||
}
|
||||
// set a name to the document
|
||||
//TCollection_ExtendedString str ( name->String() );
|
||||
//TCollection_ExtendedString str = convertName (name->String());
|
||||
//TDataStd_Name::Set ( L, str );
|
||||
}
|
||||
|
||||
|
@@ -16,15 +16,9 @@
|
||||
#ifndef _STEPCAFControl_Reader_HeaderFile
|
||||
#define _STEPCAFControl_Reader_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Resource_FormatType.hxx>
|
||||
#include <STEPControl_Reader.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <IFSelect_ReturnStatus.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TDF_LabelSequence.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <STEPCAFControl_DataMapOfShapePD.hxx>
|
||||
@@ -33,6 +27,7 @@
|
||||
#include <TColStd_HSequenceOfTransient.hxx>
|
||||
#include <XCAFDimTolObjects_DatumModifiersSequence.hxx>
|
||||
#include <XCAFDimTolObjects_DatumModifWithValue.hxx>
|
||||
|
||||
class XSControl_WorkSession;
|
||||
class TDocStd_Document;
|
||||
class TCollection_AsciiString;
|
||||
@@ -135,7 +130,14 @@ public:
|
||||
Standard_EXPORT void SetNameMode (const Standard_Boolean namemode);
|
||||
|
||||
Standard_EXPORT Standard_Boolean GetNameMode() const;
|
||||
|
||||
|
||||
//! Return the encoding of STEP file for converting names into UNICODE.
|
||||
//! Initialized from "read.stepcaf.codepage" variable by constructor, which is Resource_UTF8 by default.
|
||||
Resource_FormatType SourceCodePage() const { return mySourceCodePage; }
|
||||
|
||||
//! Return the encoding of STEP file for converting names into UNICODE.
|
||||
void SetSourceCodePage (Resource_FormatType theCode) { mySourceCodePage = theCode; }
|
||||
|
||||
//! Set LayerMode for indicate read Layers or not.
|
||||
Standard_EXPORT void SetLayerMode (const Standard_Boolean layermode);
|
||||
|
||||
@@ -252,8 +254,8 @@ protected:
|
||||
//! are skipped.
|
||||
Standard_EXPORT void ExpandShell (const Handle(StepShape_ConnectedFaceSet)& theShell, TDF_Label& theLab, const Handle(Transfer_TransientProcess)& theTP, const Handle(XCAFDoc_ShapeTool)& theShapeTool) const;
|
||||
|
||||
|
||||
|
||||
//! Convert name into UNICODE text.
|
||||
Standard_EXPORT virtual TCollection_ExtendedString convertName (const TCollection_AsciiString& theName) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -281,6 +283,7 @@ private:
|
||||
|
||||
STEPControl_Reader myReader;
|
||||
NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myFiles;
|
||||
Resource_FormatType mySourceCodePage;
|
||||
Standard_Boolean myColorMode;
|
||||
Standard_Boolean myNameMode;
|
||||
Standard_Boolean myLayerMode;
|
||||
@@ -293,10 +296,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _STEPCAFControl_Reader_HeaderFile
|
||||
|
Reference in New Issue
Block a user