MapOfShape from TopTools,
WorkSession from XSControl,
Document from TDocStd,
+ LabelSequence from TDF,
Style from XCAFPrs,
DataMapOfShapeStyle from XCAFPrs,
DataMapOfStyleTransient from XCAFPrs
---Scope: Internal methods
- WriteAttributes (me: in out; doc: Document from TDocStd)
+ Transfer (me : in out; labels: LabelSequence from TDF)
+ returns Boolean is protected;
+ ---Purpose: Transfers labels to a IGES model
+ -- Returns True if translation is OK
+
+ WriteAttributes (me: in out; labels: LabelSequence from TDF)
returns Boolean is protected;
---Purpose: Reads colors from DECAF document and assigns them
-- to corresponding IGES entities
---Purpose: Recursively iterates on subshapes and assigns colors
-- to faces and edges (if set)
- WriteLayers (me: in out; doc: Document from TDocStd)
+ WriteLayers (me: in out; labels: LabelSequence from TDF)
returns Boolean is protected;
---Purpose: Reads layers from DECAF document and assigns them
-- to corresponding IGES entities
- WriteNames (me: in out; doc: Document from TDocStd)
+ WriteNames (me: in out; labels: LabelSequence from TDF)
returns Boolean is protected;
---Purpose: Recursivile iterates on subshapes and assign names
-- to IGES entity
{
// translate free top-level shapes of the DECAF document
Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( doc->Main() );
- TDF_LabelSequence shapes;
- STool->GetFreeShapes ( shapes );
- if ( shapes.Length() <=0 ) return Standard_False;
- for ( Standard_Integer i=1; i <= shapes.Length(); i++ ) {
- TopoDS_Shape shape = STool->GetShape ( shapes.Value(i) );
- if ( ! shape.IsNull() )
- AddShape ( shape );
-// IGESControl_Writer::Transfer ( shape );
- }
-
- // write colors
- if ( GetColorMode() )
- WriteAttributes ( doc );
+ if ( STool.IsNull() ) return Standard_False;
- // write layers
- if ( GetLayerMode() )
- WriteLayers ( doc );
-
- // write names
- if ( GetNameMode() )
- WriteNames( doc );
-
- // refresh graph
-// WS()->ComputeGraph ( Standard_True );
- ComputeModel();
+ TDF_LabelSequence labels;
+ STool->GetFreeShapes ( labels );
+ return Transfer (labels);
+}
- return Standard_True;
-}
-
//=======================================================================
//function : Perform
//purpose :
return Write ( filename.ToCString() ) == IFSelect_RetDone;
}
+//=======================================================================
+//function : Transfer
+//purpose :
+//=======================================================================
+
+Standard_Boolean IGESCAFControl_Writer::Transfer (const TDF_LabelSequence& labels)
+{
+ if ( labels.Length() <=0 ) return Standard_False;
+ for ( Standard_Integer i=1; i <= labels.Length(); i++ ) {
+ TopoDS_Shape shape = XCAFDoc_ShapeTool::GetShape ( labels.Value(i) );
+ if ( ! shape.IsNull() )
+ AddShape ( shape );
+// IGESControl_Writer::Transfer ( shape );
+ }
+
+ // write colors
+ if ( GetColorMode() )
+ WriteAttributes ( labels );
+
+ // write layers
+ if ( GetLayerMode() )
+ WriteLayers ( labels );
+
+ // write names
+ if ( GetNameMode() )
+ WriteNames( labels );
+
+ // refresh graph
+// WS()->ComputeGraph ( Standard_True );
+ ComputeModel();
+
+ return Standard_True;
+}
+
//=======================================================================
//function : WriteAttributes
//purpose :
//=======================================================================
-Standard_Boolean IGESCAFControl_Writer::WriteAttributes (const Handle(TDocStd_Document)& Doc)
+Standard_Boolean IGESCAFControl_Writer::WriteAttributes (const TDF_LabelSequence& labels)
{
- // Iterate on shapes in the document
- Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
-
- TDF_LabelSequence labels;
- STool->GetFreeShapes ( labels );
+ // Iterate on labels
if ( labels.Length() <=0 ) return Standard_False;
for ( Standard_Integer i=1; i <= labels.Length(); i++ ) {
TDF_Label L = labels.Value(i);
// get a target shape and try to find corresponding context
// (all the colors set under that label will be put into that context)
TopoDS_Shape S;
- if ( ! STool->GetShape ( L, S ) ) continue;
+ if ( ! XCAFDoc_ShapeTool::GetShape ( L, S ) ) continue;
// iterate on subshapes and create IGES styles
XCAFPrs_DataMapOfStyleTransient colors;
//purpose :
//=======================================================================
-Standard_Boolean IGESCAFControl_Writer::WriteLayers (const Handle(TDocStd_Document)& Doc)
+Standard_Boolean IGESCAFControl_Writer::WriteLayers (const TDF_LabelSequence& labels)
{
- Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
+ if ( labels.Length() <=0 ) return Standard_False;
+ Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( labels(1) );
if ( STool.IsNull() ) return Standard_False;
- Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool( Doc->Main() );
+ Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool( labels(1) );
if ( LTool.IsNull() ) return Standard_False;
Standard_Integer globalIntName = 0;
//purpose :
//=======================================================================
-Standard_Boolean IGESCAFControl_Writer::WriteNames (const Handle(TDocStd_Document)& Doc)
+Standard_Boolean IGESCAFControl_Writer::WriteNames (const TDF_LabelSequence& labels)
{
- Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
+ if ( labels.Length() <=0 ) return Standard_False;
+ Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( labels(1) );
if ( STool.IsNull() ) return Standard_False;
TDF_ChildIterator labelShIt(STool->BaseLabel() , Standard_True);
for (; labelShIt.More(); labelShIt.Next() ) {