1 // Created on: 2000-06-20
2 // Created by: Sergey MOZOKHIN
3 // Copyright (c) 2000-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 _VrmlAPI_Writer_HeaderFile
17 #define _VrmlAPI_Writer_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
23 #include <VrmlAPI_RepresentationOfShape.hxx>
24 #include <Standard_Real.hxx>
25 #include <Quantity_Length.hxx>
26 #include <Quantity_HArray1OfColor.hxx>
27 #include <Standard_CString.hxx>
28 #include <Standard_Integer.hxx>
29 class VrmlConverter_Drawer;
30 class VrmlConverter_Projector;
35 //! Creates and writes VRML files from Open
36 //! CASCADE shapes. A VRML file can be written to
37 //! an existing VRML file or to a new one.
45 //! Creates a writer object with default parameters.
46 Standard_EXPORT VrmlAPI_Writer();
48 //! Resets all parameters (representation, deflection)
49 //! to their default values..
50 Standard_EXPORT void ResetToDefaults();
52 //! Returns drawer object
53 Standard_EXPORT Handle(VrmlConverter_Drawer) Drawer() const;
55 //! Sets the deflection aDef of
56 //! the mesh algorithm which is used to compute the shaded
57 //! representation of the translated shape. The default
58 //! value is -1. When the deflection value is less than
59 //! 0, the deflection is calculated from the relative
60 //! size of the shaped.
61 Standard_EXPORT void SetDeflection (const Standard_Real aDef);
63 //! Sets the representation of the
64 //! shape aRep which is written to the VRML file. The three options are :
67 //! - both shaded and wireframe (default)
68 //! defined through the VrmlAPI_RepresentationOfShape enumeration.
69 Standard_EXPORT void SetRepresentation (const VrmlAPI_RepresentationOfShape aRep);
71 //! Set transparency to given material
72 Standard_EXPORT void SetTransparencyToMaterial (Handle(Vrml_Material)& aMaterial, const Standard_Real aTransparency);
74 Standard_EXPORT void SetShininessToMaterial (Handle(Vrml_Material)& aMaterial, const Standard_Real aShininess);
76 Standard_EXPORT void SetAmbientColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color);
78 Standard_EXPORT void SetDiffuseColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color);
80 Standard_EXPORT void SetSpecularColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color);
82 Standard_EXPORT void SetEmissiveColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color);
84 //! Returns the representation of the shape which is
85 //! written to the VRML file. Types of representation are set through the
86 //! VrmlAPI_RepresentationOfShape enumeration.
87 Standard_EXPORT VrmlAPI_RepresentationOfShape GetRepresentation() const;
89 Standard_EXPORT Handle(Vrml_Material) GetFrontMaterial() const;
91 Standard_EXPORT Handle(Vrml_Material) GetPointsMaterial() const;
93 Standard_EXPORT Handle(Vrml_Material) GetUisoMaterial() const;
95 Standard_EXPORT Handle(Vrml_Material) GetVisoMaterial() const;
97 Standard_EXPORT Handle(Vrml_Material) GetLineMaterial() const;
99 Standard_EXPORT Handle(Vrml_Material) GetWireMaterial() const;
101 Standard_EXPORT Handle(Vrml_Material) GetFreeBoundsMaterial() const;
103 Standard_EXPORT Handle(Vrml_Material) GetUnfreeBoundsMaterial() const;
105 //! Converts the shape aShape to
106 //! VRML format of the passed version and writes it to the file identified by aFile.
107 Standard_EXPORT void Write (const TopoDS_Shape& aShape, const Standard_CString aFile, const Standard_Integer aVersion = 2) const;
115 //! Converts the shape aShape to VRML format of version 1.0 and writes it
116 //! to the file identified by aFileName using default parameters.
117 Standard_EXPORT void write_v1 (const TopoDS_Shape& aShape, const Standard_CString aFileName) const;
119 //! Converts the shape aShape to VRML format of version 2.0 and writes it
120 //! to the file identified by aFileName using default parameters.
121 Standard_EXPORT void write_v2 (const TopoDS_Shape& aShape, const Standard_CString aFileName) const;
130 VrmlAPI_RepresentationOfShape myRepresentation;
131 Handle(VrmlConverter_Drawer) myDrawer;
132 Standard_Real myDeflection;
133 Handle(VrmlConverter_Projector) myPerespectiveCamera;
134 Handle(VrmlConverter_Projector) myOrthographicCamera;
135 Standard_Real myTransparency;
136 Standard_Real myShininess;
137 Handle(Vrml_Material) myFrontMaterial;
138 Handle(Vrml_Material) myPointsMaterial;
139 Handle(Vrml_Material) myUisoMaterial;
140 Handle(Vrml_Material) myVisoMaterial;
141 Handle(Vrml_Material) myLineMaterial;
142 Handle(Vrml_Material) myWireMaterial;
143 Handle(Vrml_Material) myFreeBoundsMaterial;
144 Handle(Vrml_Material) myUnfreeBoundsMaterial;
151 Quantity_Length Focus;
162 #endif // _VrmlAPI_Writer_HeaderFile