Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-11 09:19:44

0001 // Created on: 2003-03-05
0002 // Created by: Sergey KUUL
0003 // Copyright (c) 2003-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 _XCAFDoc_MaterialTool_HeaderFile
0017 #define _XCAFDoc_MaterialTool_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_Type.hxx>
0021 
0022 #include <TDataStd_GenericEmpty.hxx>
0023 #include <Standard_Boolean.hxx>
0024 #include <TDF_Label.hxx>
0025 #include <NCollection_Sequence.hxx>
0026 #include <Standard_Real.hxx>
0027 class XCAFDoc_ShapeTool;
0028 class TDF_Label;
0029 class Standard_GUID;
0030 class TCollection_HAsciiString;
0031 
0032 //! Provides tools to store and retrieve attributes (materials)
0033 //! of TopoDS_Shape in and from TDocStd_Document
0034 //! A Document is intended to hold different
0035 //! attributes of ONE shape and it's sub-shapes
0036 //! Provide tools for management of Materialss section of document.
0037 class XCAFDoc_MaterialTool : public TDataStd_GenericEmpty
0038 {
0039 
0040 public:
0041   Standard_EXPORT XCAFDoc_MaterialTool();
0042 
0043   //! Creates (if not exist) MaterialTool.
0044   Standard_EXPORT static occ::handle<XCAFDoc_MaterialTool> Set(const TDF_Label& L);
0045 
0046   Standard_EXPORT static const Standard_GUID& GetID();
0047 
0048   //! returns the label under which colors are stored
0049   Standard_EXPORT TDF_Label BaseLabel() const;
0050 
0051   //! Returns internal XCAFDoc_ShapeTool tool
0052   Standard_EXPORT const occ::handle<XCAFDoc_ShapeTool>& ShapeTool();
0053 
0054   //! Returns True if label belongs to a material table and
0055   //! is a Material definition
0056   Standard_EXPORT bool IsMaterial(const TDF_Label& lab) const;
0057 
0058   //! Returns a sequence of materials currently stored
0059   //! in the material table
0060   Standard_EXPORT void GetMaterialLabels(NCollection_Sequence<TDF_Label>& Labels) const;
0061 
0062   //! Adds a Material definition to a table and returns its label
0063   Standard_EXPORT TDF_Label
0064     AddMaterial(const occ::handle<TCollection_HAsciiString>& aName,
0065                 const occ::handle<TCollection_HAsciiString>& aDescription,
0066                 const double                                 aDensity,
0067                 const occ::handle<TCollection_HAsciiString>& aDensName,
0068                 const occ::handle<TCollection_HAsciiString>& aDensValType) const;
0069 
0070   //! Sets a link with GUID
0071   Standard_EXPORT void SetMaterial(const TDF_Label& L, const TDF_Label& MatL) const;
0072 
0073   //! Sets a link with GUID
0074   //! Adds a Material as necessary
0075   Standard_EXPORT void SetMaterial(const TDF_Label&                             L,
0076                                    const occ::handle<TCollection_HAsciiString>& aName,
0077                                    const occ::handle<TCollection_HAsciiString>& aDescription,
0078                                    const double                                 aDensity,
0079                                    const occ::handle<TCollection_HAsciiString>& aDensName,
0080                                    const occ::handle<TCollection_HAsciiString>& aDensValType) const;
0081 
0082   //! Returns Material assigned to <MatL>
0083   //! Returns False if no such Material is assigned
0084   Standard_EXPORT static bool GetMaterial(const TDF_Label&                       MatL,
0085                                           occ::handle<TCollection_HAsciiString>& aName,
0086                                           occ::handle<TCollection_HAsciiString>& aDescription,
0087                                           double&                                aDensity,
0088                                           occ::handle<TCollection_HAsciiString>& aDensName,
0089                                           occ::handle<TCollection_HAsciiString>& aDensValType);
0090 
0091   //! Find referred material and return density from it
0092   //! if no material --> return 0
0093   Standard_EXPORT static double GetDensityForShape(const TDF_Label& ShapeL);
0094 
0095   Standard_EXPORT const Standard_GUID& ID() const override;
0096 
0097   //! Dumps the content of me into the stream
0098   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override;
0099 
0100   DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_MaterialTool, TDataStd_GenericEmpty)
0101 
0102 private:
0103   occ::handle<XCAFDoc_ShapeTool> myShapeTool;
0104 };
0105 
0106 #endif // _XCAFDoc_MaterialTool_HeaderFile