1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0026500: Add the possibility to save only part of shapes from XCAF document in IGES/STEP writers

Added public methods for specified labels (shapes) transfer in IGES/STEP writers.
This commit is contained in:
stv 2015-08-13 11:11:07 +03:00 committed by ski
parent f7d7054028
commit 1b44ab4b14
4 changed files with 58 additions and 34 deletions

View File

@ -13,7 +13,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <IGESCAFControl.hxx>
#include <IGESCAFControl_Writer.hxx>
#include <IGESData_IGESEntity.hxx>
@ -151,31 +150,19 @@ Standard_Boolean IGESCAFControl_Writer::Transfer (const Handle(TDocStd_Document)
STool->GetFreeShapes ( labels );
return Transfer (labels);
}
//=======================================================================
//function : Perform
//function : Transfer
//purpose :
//=======================================================================
Standard_Boolean IGESCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc,
const Standard_CString filename)
Standard_Boolean IGESCAFControl_Writer::Transfer (const TDF_Label& label)
{
if ( ! Transfer ( doc ) ) return Standard_False;
return Write ( filename ) == IFSelect_RetDone;
TDF_LabelSequence labels;
labels.Append( label );
return Transfer( labels );
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Standard_Boolean IGESCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc,
const TCollection_AsciiString &filename)
{
if ( ! Transfer ( doc ) ) return Standard_False;
return Write ( filename.ToCString() ) == IFSelect_RetDone;
}
//=======================================================================
//function : Transfer
//purpose :
@ -210,6 +197,30 @@ Standard_Boolean IGESCAFControl_Writer::Transfer (const TDF_LabelSequence& label
return Standard_True;
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Standard_Boolean IGESCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc,
const Standard_CString filename)
{
if ( ! Transfer ( doc ) ) return Standard_False;
return Write ( filename ) == IFSelect_RetDone;
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Standard_Boolean IGESCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc,
const TCollection_AsciiString &filename)
{
if ( ! Transfer ( doc ) ) return Standard_False;
return Write ( filename.ToCString() ) == IFSelect_RetDone;
}
//=======================================================================
//function : WriteAttributes
//purpose :

View File

@ -33,7 +33,6 @@ class TCollection_AsciiString;
class TopoDS_Shape;
class XCAFPrs_Style;
//! Provides a tool to write DECAF document to the
//! IGES file. Besides transfer of shapes (including
//! assemblies) provided by IGESControl, supports also
@ -71,7 +70,15 @@ public:
//! Transfers a document to a IGES model
//! Returns True if translation is OK
Standard_EXPORT Standard_Boolean Transfer (const Handle(TDocStd_Document)& doc);
//! Transfers labels to a IGES model
//! Returns True if translation is OK
Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& labels);
//! Transfers label to a IGES model
//! Returns True if translation is OK
Standard_EXPORT Standard_Boolean Transfer (const TDF_Label& label);
Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc, const TCollection_AsciiString& filename);
//! Transfers a document and writes it to a IGES file
@ -97,12 +104,7 @@ public:
protected:
//! Transfers labels to a IGES model
//! Returns True if translation is OK
Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& labels);
//! Reads colors from DECAF document and assigns them
//! to corresponding IGES entities
Standard_EXPORT Standard_Boolean WriteAttributes (const TDF_LabelSequence& labels);

View File

@ -288,9 +288,9 @@ IFSelect_ReturnStatus STEPCAFControl_Writer::Write (const Standard_CString filen
//purpose :
//=======================================================================
Standard_Boolean STEPCAFControl_Writer::Transfer (const Handle(TDocStd_Document) &doc,
Standard_Boolean STEPCAFControl_Writer::Transfer( const Handle(TDocStd_Document) &doc,
const STEPControl_StepModelType mode,
const Standard_CString multi)
const Standard_CString multi )
{
Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( doc->Main() );
if ( STool.IsNull() ) return Standard_False;
@ -306,15 +306,26 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (const Handle(TDocStd_Document)
//purpose :
//=======================================================================
Standard_Boolean STEPCAFControl_Writer::Transfer (const TDF_Label &L,
Standard_Boolean STEPCAFControl_Writer::Transfer( const TDF_Label& L,
const STEPControl_StepModelType mode,
const Standard_CString multi)
const Standard_CString multi )
{
TDF_LabelSequence labels;
labels.Append ( L );
return Transfer ( myWriter, labels, mode, multi );
}
//=======================================================================
//function : Transfer
//purpose :
//=======================================================================
Standard_Boolean STEPCAFControl_Writer::Transfer( const TDF_LabelSequence& labels,
const STEPControl_StepModelType mode,
const Standard_CString multi )
{
return Transfer( myWriter, labels, mode, multi );
}
//=======================================================================
//function : Perform

View File

@ -73,16 +73,16 @@ public:
//! Provided for use like single-file writer
Standard_EXPORT IFSelect_ReturnStatus Write (const Standard_CString filename);
Standard_EXPORT Standard_Boolean Transfer (const Handle(TDocStd_Document)& doc, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
//! Transfers a document (or single label) to a STEP model
//! The mode of translation of shape is AsIs
//! If multi is not null pointer, it switches to multifile
//! mode (with external refs), and string pointed by <multi>
//! gives prefix for names of extern files (can be empty string)
//! Returns True if translation is OK
Standard_EXPORT Standard_Boolean Transfer (const Handle(TDocStd_Document)& doc, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& L, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
Standard_EXPORT Standard_Boolean Transfer (const TDF_Label& L, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc, const TCollection_AsciiString& filename);
//! Transfers a document and writes it to a STEP file