42cf5bc1 |
1 | // Created on: 2000-06-20 |
2 | // Created by: Sergey MOZOKHIN |
3 | // Copyright (c) 2000-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
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. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _VrmlAPI_Writer_HeaderFile |
17 | #define _VrmlAPI_Writer_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_DefineAlloc.hxx> |
21 | #include <Standard_Handle.hxx> |
22 | |
23 | #include <VrmlAPI_RepresentationOfShape.hxx> |
42cf5bc1 |
24 | #include <Quantity_HArray1OfColor.hxx> |
42cf5bc1 |
25 | #include <Standard_Integer.hxx> |
a3506de7 |
26 | |
42cf5bc1 |
27 | class VrmlConverter_Drawer; |
28 | class VrmlConverter_Projector; |
29 | class Vrml_Material; |
30 | class TopoDS_Shape; |
53f46612 |
31 | class TDocStd_Document; |
42cf5bc1 |
32 | |
33 | |
34 | //! Creates and writes VRML files from Open |
35 | //! CASCADE shapes. A VRML file can be written to |
36 | //! an existing VRML file or to a new one. |
37 | class VrmlAPI_Writer |
38 | { |
39 | public: |
40 | |
41 | DEFINE_STANDARD_ALLOC |
42 | |
43 | |
44 | //! Creates a writer object with default parameters. |
45 | Standard_EXPORT VrmlAPI_Writer(); |
46 | |
47 | //! Resets all parameters (representation, deflection) |
48 | //! to their default values.. |
49 | Standard_EXPORT void ResetToDefaults(); |
50 | |
51 | //! Returns drawer object |
52 | Standard_EXPORT Handle(VrmlConverter_Drawer) Drawer() const; |
53 | |
54 | //! Sets the deflection aDef of |
55 | //! the mesh algorithm which is used to compute the shaded |
56 | //! representation of the translated shape. The default |
57 | //! value is -1. When the deflection value is less than |
58 | //! 0, the deflection is calculated from the relative |
59 | //! size of the shaped. |
60 | Standard_EXPORT void SetDeflection (const Standard_Real aDef); |
61 | |
62 | //! Sets the representation of the |
63 | //! shape aRep which is written to the VRML file. The three options are : |
64 | //! - shaded |
65 | //! - wireframe |
66 | //! - both shaded and wireframe (default) |
67 | //! defined through the VrmlAPI_RepresentationOfShape enumeration. |
68 | Standard_EXPORT void SetRepresentation (const VrmlAPI_RepresentationOfShape aRep); |
69 | |
70 | //! Set transparency to given material |
71 | Standard_EXPORT void SetTransparencyToMaterial (Handle(Vrml_Material)& aMaterial, const Standard_Real aTransparency); |
72 | |
73 | Standard_EXPORT void SetShininessToMaterial (Handle(Vrml_Material)& aMaterial, const Standard_Real aShininess); |
74 | |
75 | Standard_EXPORT void SetAmbientColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color); |
76 | |
77 | Standard_EXPORT void SetDiffuseColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color); |
78 | |
79 | Standard_EXPORT void SetSpecularColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color); |
80 | |
81 | Standard_EXPORT void SetEmissiveColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color); |
82 | |
83 | //! Returns the representation of the shape which is |
84 | //! written to the VRML file. Types of representation are set through the |
85 | //! VrmlAPI_RepresentationOfShape enumeration. |
86 | Standard_EXPORT VrmlAPI_RepresentationOfShape GetRepresentation() const; |
87 | |
88 | Standard_EXPORT Handle(Vrml_Material) GetFrontMaterial() const; |
89 | |
90 | Standard_EXPORT Handle(Vrml_Material) GetPointsMaterial() const; |
91 | |
92 | Standard_EXPORT Handle(Vrml_Material) GetUisoMaterial() const; |
93 | |
94 | Standard_EXPORT Handle(Vrml_Material) GetVisoMaterial() const; |
95 | |
96 | Standard_EXPORT Handle(Vrml_Material) GetLineMaterial() const; |
97 | |
98 | Standard_EXPORT Handle(Vrml_Material) GetWireMaterial() const; |
99 | |
100 | Standard_EXPORT Handle(Vrml_Material) GetFreeBoundsMaterial() const; |
101 | |
102 | Standard_EXPORT Handle(Vrml_Material) GetUnfreeBoundsMaterial() const; |
103 | |
104 | //! Converts the shape aShape to |
105 | //! VRML format of the passed version and writes it to the file identified by aFile. |
c42ef165 |
106 | Standard_EXPORT Standard_Boolean Write (const TopoDS_Shape& aShape, const Standard_CString aFile, |
a3506de7 |
107 | const Standard_Integer aVersion = 2) const; |
108 | |
109 | //! Converts the document to VRML format of the passed version |
110 | //! and writes it to the file identified by aFile. |
c42ef165 |
111 | Standard_EXPORT Standard_Boolean WriteDoc( |
a3506de7 |
112 | const Handle(TDocStd_Document) &theDoc, |
113 | const Standard_CString theFile, |
114 | const Standard_Real theScale) const; |
42cf5bc1 |
115 | |
42cf5bc1 |
116 | protected: |
117 | |
42cf5bc1 |
118 | //! Converts the shape aShape to VRML format of version 1.0 and writes it |
119 | //! to the file identified by aFileName using default parameters. |
c42ef165 |
120 | Standard_EXPORT Standard_Boolean write_v1 (const TopoDS_Shape& aShape, const Standard_CString aFileName) const; |
42cf5bc1 |
121 | |
122 | //! Converts the shape aShape to VRML format of version 2.0 and writes it |
123 | //! to the file identified by aFileName using default parameters. |
c42ef165 |
124 | Standard_EXPORT Standard_Boolean write_v2 (const TopoDS_Shape& aShape, const Standard_CString aFileName) const; |
42cf5bc1 |
125 | |
42cf5bc1 |
126 | private: |
127 | |
42cf5bc1 |
128 | VrmlAPI_RepresentationOfShape myRepresentation; |
129 | Handle(VrmlConverter_Drawer) myDrawer; |
130 | Standard_Real myDeflection; |
131 | Handle(VrmlConverter_Projector) myPerespectiveCamera; |
132 | Handle(VrmlConverter_Projector) myOrthographicCamera; |
133 | Standard_Real myTransparency; |
134 | Standard_Real myShininess; |
135 | Handle(Vrml_Material) myFrontMaterial; |
136 | Handle(Vrml_Material) myPointsMaterial; |
137 | Handle(Vrml_Material) myUisoMaterial; |
138 | Handle(Vrml_Material) myVisoMaterial; |
139 | Handle(Vrml_Material) myLineMaterial; |
140 | Handle(Vrml_Material) myWireMaterial; |
141 | Handle(Vrml_Material) myFreeBoundsMaterial; |
142 | Handle(Vrml_Material) myUnfreeBoundsMaterial; |
09324e85 |
143 | Standard_Real DX; |
144 | Standard_Real DY; |
145 | Standard_Real DZ; |
146 | Standard_Real XUp; |
147 | Standard_Real YUp; |
148 | Standard_Real ZUp; |
149 | Standard_Real Focus; |
42cf5bc1 |
150 | |
151 | }; |
152 | |
42cf5bc1 |
153 | #endif // _VrmlAPI_Writer_HeaderFile |