Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:57

0001 // Created on: 2000-08-17
0002 // Created by: Andrey BETENEV
0003 // Copyright (c) 2000-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _IGESCAFControl_Writer_HeaderFile
0017 #define _IGESCAFControl_Writer_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021 #include <Standard_Handle.hxx>
0022 
0023 #include <IGESControl_Writer.hxx>
0024 #include <Standard_CString.hxx>
0025 #include <TDF_LabelSequence.hxx>
0026 #include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
0027 #include <XCAFPrs_DataMapOfStyleTransient.hxx>
0028 #include <TopTools_MapOfShape.hxx>
0029 class XSControl_WorkSession;
0030 class TDocStd_Document;
0031 class TCollection_AsciiString;
0032 class TopoDS_Shape;
0033 class XCAFPrs_Style;
0034 
0035 //! Provides a tool to write DECAF document to the
0036 //! IGES file. Besides transfer of shapes (including
0037 //! assemblies) provided by IGESControl, supports also
0038 //! colors and part names
0039 //! IGESCAFControl_Writer writer();
0040 //! Methods for writing IGES file:
0041 //! writer.Transfer (Document);
0042 //! writer.Write("filename") or writer.Write(OStream)  or
0043 //! writer.Perform(Document,"filename");
0044 //! Methods for managing the writing of attributes.
0045 //! Colors
0046 //! writer.SetColorMode(colormode);
0047 //! Standard_Boolean colormode = writer.GetColorMode();
0048 //! Layers
0049 //! writer.SetLayerMode(layermode);
0050 //! Standard_Boolean layermode = writer.GetLayerMode();
0051 //! Names
0052 //! writer.SetNameMode(namemode);
0053 //! Standard_Boolean namemode = writer.GetNameMode();
0054 class IGESCAFControl_Writer  : public IGESControl_Writer
0055 {
0056 public:
0057 
0058   DEFINE_STANDARD_ALLOC
0059 
0060   
0061   //! Creates a writer with an empty
0062   //! IGES model and sets ColorMode, LayerMode and NameMode to Standard_True.
0063   Standard_EXPORT IGESCAFControl_Writer();
0064   
0065   //! Creates a reader tool and attaches it to an already existing Session
0066   //! Clears the session if it was not yet set for IGES
0067   Standard_EXPORT IGESCAFControl_Writer(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
0068   
0069   //! Transfers a document to a IGES model
0070   //! Returns True if translation is OK
0071   Standard_EXPORT Standard_Boolean Transfer (const Handle(TDocStd_Document)& doc,
0072                                              const Message_ProgressRange& theProgress = Message_ProgressRange());
0073 
0074   //! Transfers labels to a IGES model
0075   //! Returns True if translation is OK
0076   Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& labels,
0077                                              const Message_ProgressRange& theProgress = Message_ProgressRange());
0078 
0079   //! Transfers label to a IGES model
0080   //! Returns True if translation is OK
0081   Standard_EXPORT Standard_Boolean Transfer (const TDF_Label& label,
0082                                              const Message_ProgressRange& theProgress = Message_ProgressRange());
0083 
0084   Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc,
0085                                             const TCollection_AsciiString& filename,
0086                                             const Message_ProgressRange& theProgress = Message_ProgressRange());
0087   
0088   //! Transfers a document and writes it to a IGES file
0089   //! Returns True if translation is OK
0090   Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc,
0091                                             const Standard_CString filename,
0092                                             const Message_ProgressRange& theProgress = Message_ProgressRange());
0093   
0094   //! Set ColorMode for indicate write Colors or not.
0095   Standard_EXPORT void SetColorMode (const Standard_Boolean colormode);
0096   
0097   Standard_EXPORT Standard_Boolean GetColorMode() const;
0098   
0099   //! Set NameMode for indicate write Name or not.
0100   Standard_EXPORT void SetNameMode (const Standard_Boolean namemode);
0101   
0102   Standard_EXPORT Standard_Boolean GetNameMode() const;
0103   
0104   //! Set LayerMode for indicate write Layers or not.
0105   Standard_EXPORT void SetLayerMode (const Standard_Boolean layermode);
0106   
0107   Standard_EXPORT Standard_Boolean GetLayerMode() const;
0108 
0109 
0110 
0111 
0112 protected:
0113  
0114   //! Reads colors from DECAF document and assigns them
0115   //! to corresponding IGES entities
0116   Standard_EXPORT Standard_Boolean WriteAttributes (const TDF_LabelSequence& labels);
0117   
0118   //! Reads layers from DECAF document and assigns them
0119   //! to corresponding IGES entities
0120   Standard_EXPORT Standard_Boolean WriteLayers (const TDF_LabelSequence& labels);
0121   
0122   //! Recursivile iterates on subshapes and assign names
0123   //! to IGES entity
0124   Standard_EXPORT Standard_Boolean WriteNames (const TDF_LabelSequence& labels);
0125 
0126   //! Finds length units located in root of label
0127   //! If it exists, initializes local length unit from it
0128   //! Else initializes according to Cascade length unit
0129   Standard_EXPORT void prepareUnit(const TDF_Label& theLabel);
0130 
0131 
0132 private:
0133 
0134   
0135   //! Recursively iterates on subshapes and assigns colors
0136   //! to faces and edges (if set)
0137   Standard_EXPORT void MakeColors (const TopoDS_Shape& S, const XCAFPrs_IndexedDataMapOfShapeStyle& settings, XCAFPrs_DataMapOfStyleTransient& colors, TopTools_MapOfShape& Map, const XCAFPrs_Style& inherit);
0138 
0139 
0140   Standard_Boolean myColorMode;
0141   Standard_Boolean myNameMode;
0142   Standard_Boolean myLayerMode;
0143 
0144 
0145 };
0146 
0147 
0148 
0149 
0150 
0151 
0152 
0153 #endif // _IGESCAFControl_Writer_HeaderFile