1 // Created on: 2003-03-05
2 // Created by: Sergey KUUL
3 // Copyright (c) 2003-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _XCAFDoc_MaterialTool_HeaderFile
17 #define _XCAFDoc_MaterialTool_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
22 #include <TDF_Attribute.hxx>
23 #include <Standard_Boolean.hxx>
24 #include <TDF_LabelSequence.hxx>
25 #include <Standard_Real.hxx>
26 class XCAFDoc_ShapeTool;
29 class TCollection_HAsciiString;
31 class TDF_RelocationTable;
34 class XCAFDoc_MaterialTool;
35 DEFINE_STANDARD_HANDLE(XCAFDoc_MaterialTool, TDF_Attribute)
37 //! Provides tools to store and retrieve attributes (materials)
38 //! of TopoDS_Shape in and from TDocStd_Document
39 //! A Document is intended to hold different
40 //! attributes of ONE shape and it's sub-shapes
41 //! Provide tools for management of Materialss section of document.
42 class XCAFDoc_MaterialTool : public TDF_Attribute
48 Standard_EXPORT XCAFDoc_MaterialTool();
50 //! Creates (if not exist) MaterialTool.
51 Standard_EXPORT static Handle(XCAFDoc_MaterialTool) Set (const TDF_Label& L);
53 Standard_EXPORT static const Standard_GUID& GetID();
55 //! returns the label under which colors are stored
56 Standard_EXPORT TDF_Label BaseLabel() const;
58 //! Returns internal XCAFDoc_ShapeTool tool
59 Standard_EXPORT const Handle(XCAFDoc_ShapeTool)& ShapeTool();
61 //! Returns True if label belongs to a material table and
62 //! is a Material definition
63 Standard_EXPORT Standard_Boolean IsMaterial (const TDF_Label& lab) const;
65 //! Returns a sequence of materials currently stored
66 //! in the material table
67 Standard_EXPORT void GetMaterialLabels (TDF_LabelSequence& Labels) const;
69 //! Adds a Material definition to a table and returns its label
70 Standard_EXPORT TDF_Label AddMaterial (const Handle(TCollection_HAsciiString)& aName, const Handle(TCollection_HAsciiString)& aDescription, const Standard_Real aDensity, const Handle(TCollection_HAsciiString)& aDensName, const Handle(TCollection_HAsciiString)& aDensValType) const;
72 //! Sets a link with GUID
73 Standard_EXPORT void SetMaterial (const TDF_Label& L, const TDF_Label& MatL) const;
75 //! Sets a link with GUID
76 //! Adds a Material as necessary
77 Standard_EXPORT void SetMaterial (const TDF_Label& L, const Handle(TCollection_HAsciiString)& aName, const Handle(TCollection_HAsciiString)& aDescription, const Standard_Real aDensity, const Handle(TCollection_HAsciiString)& aDensName, const Handle(TCollection_HAsciiString)& aDensValType) const;
79 //! Returns Material assigned to <MatL>
80 //! Returns False if no such Material is assigned
81 Standard_EXPORT Standard_Boolean GetMaterial (const TDF_Label& MatL, Handle(TCollection_HAsciiString)& aName, Handle(TCollection_HAsciiString)& aDescription, Standard_Real& aDensity, Handle(TCollection_HAsciiString)& aDensName, Handle(TCollection_HAsciiString)& aDensValType) const;
83 //! Find referred material and return density from it
84 //! if no material --> return 0
85 Standard_EXPORT static Standard_Real GetDensityForShape (const TDF_Label& ShapeL);
87 Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
89 Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
91 Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
93 Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
98 DEFINE_STANDARD_RTTIEXT(XCAFDoc_MaterialTool,TDF_Attribute)
108 Handle(XCAFDoc_ShapeTool) myShapeTool;
119 #endif // _XCAFDoc_MaterialTool_HeaderFile