// Created on: 2000-06-20 // Created by: Sergey MOZOKHIN // Copyright (c) 2000-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #ifndef _VrmlAPI_Writer_HeaderFile #define _VrmlAPI_Writer_HeaderFile #include "Standard.hxx" #include "Standard_DefineAlloc.hxx" #include "Standard_Handle.hxx" #include "VrmlAPI_RepresentationOfShape.hxx" #include "Quantity_Color.hxx" #include "NCollection_Array1.hxx" #include "NCollection_HArray1.hxx" #include "Standard_Integer.hxx" #include "Vrml_Material.hxx" class VrmlConverter_Drawer; class VrmlConverter_Projector; class TopoDS_Shape; class TDocStd_Document; //! Creates and writes VRML files from Open //! CASCADE shapes. A VRML file can be written to //! an existing VRML file or to a new one. class VrmlAPI_Writer { public: DEFINE_STANDARD_ALLOC //! Creates a writer object with default parameters. Standard_EXPORT VrmlAPI_Writer(); //! Resets all parameters (representation, deflection) //! to their default values.. Standard_EXPORT void ResetToDefaults(); //! Returns drawer object Standard_EXPORT occ::handle Drawer() const; //! Sets the deflection aDef of //! the mesh algorithm which is used to compute the shaded //! representation of the translated shape. The default //! value is -1. When the deflection value is less than //! 0, the deflection is calculated from the relative //! size of the shaped. Standard_EXPORT void SetDeflection(const double aDef); //! Sets the representation of the //! shape aRep which is written to the VRML file. The three options are : //! - shaded //! - wireframe //! - both shaded and wireframe (default) //! defined through the VrmlAPI_RepresentationOfShape enumeration. Standard_EXPORT void SetRepresentation(const VrmlAPI_RepresentationOfShape aRep); //! Returns the representation of the shape which is //! written to the VRML file. Types of representation are set through the //! VrmlAPI_RepresentationOfShape enumeration. Standard_EXPORT VrmlAPI_RepresentationOfShape GetRepresentation() const; //! @deprecated Call Vrml_Material::SetTransparency() directly instead. Standard_DEPRECATED("Call Vrml_Material::SetTransparency() directly instead") Standard_EXPORT void SetTransparencyToMaterial(occ::handle& aMaterial, const double aTransparency); //! @deprecated Call Vrml_Material::SetShininess() directly instead. Standard_DEPRECATED("Call Vrml_Material::SetShininess() directly instead") Standard_EXPORT void SetShininessToMaterial(occ::handle& aMaterial, const double aShininess); //! @deprecated Call Vrml_Material::SetAmbientColor() directly instead. Standard_DEPRECATED("Call Vrml_Material::SetAmbientColor() directly instead") Standard_EXPORT void SetAmbientColorToMaterial( occ::handle& aMaterial, const occ::handle>& Color); //! @deprecated Call Vrml_Material::SetDiffuseColor() directly instead. Standard_DEPRECATED("Call Vrml_Material::SetDiffuseColor() directly instead") Standard_EXPORT void SetDiffuseColorToMaterial( occ::handle& aMaterial, const occ::handle>& Color); //! @deprecated Call Vrml_Material::SetSpecularColor() directly instead. Standard_DEPRECATED("Call Vrml_Material::SetSpecularColor() directly instead") Standard_EXPORT void SetSpecularColorToMaterial( occ::handle& aMaterial, const occ::handle>& Color); //! @deprecated Call Vrml_Material::SetEmissiveColor() directly instead. Standard_DEPRECATED("Call Vrml_Material::SetEmissiveColor() directly instead") Standard_EXPORT void SetEmissiveColorToMaterial( occ::handle& aMaterial, const occ::handle>& Color); Standard_EXPORT occ::handle GetFrontMaterial() const; Standard_EXPORT occ::handle GetPointsMaterial() const; Standard_EXPORT occ::handle GetUisoMaterial() const; Standard_EXPORT occ::handle GetVisoMaterial() const; Standard_EXPORT occ::handle GetLineMaterial() const; Standard_EXPORT occ::handle GetWireMaterial() const; Standard_EXPORT occ::handle GetFreeBoundsMaterial() const; Standard_EXPORT occ::handle GetUnfreeBoundsMaterial() const; //! Converts the shape aShape to //! VRML format of the passed version and writes it to the file identified by aFile. Standard_EXPORT bool Write(const TopoDS_Shape& aShape, const char* const aFile, const int aVersion = 2) const; //! Converts the document to VRML format of the passed version //! and writes it to the file identified by aFile. Standard_EXPORT bool WriteDoc(const occ::handle& theDoc, const char* const theFile, const double theScale) const; //! Converts the shape aShape to //! VRML format of the passed version and writes it to the given stream. Standard_EXPORT bool Write(const TopoDS_Shape& aShape, Standard_OStream& theOStream, const int aVersion = 2) const; //! Converts the document to VRML format of the passed version //! and writes it to the given stream. Standard_EXPORT bool WriteDoc(const occ::handle& theDoc, Standard_OStream& theOStream, const double theScale) const; protected: //! Converts the shape aShape to VRML format of version 1.0 and writes it //! to the given stream using default parameters. Standard_EXPORT bool write_v1(const TopoDS_Shape& aShape, Standard_OStream& theOStream) const; //! Converts the shape aShape to VRML format of version 2.0 and writes it //! to the given stream using default parameters. Standard_EXPORT bool write_v2(const TopoDS_Shape& aShape, Standard_OStream& theOStream) const; private: VrmlAPI_RepresentationOfShape myRepresentation; occ::handle myDrawer; double myDeflection; occ::handle myPerespectiveCamera; occ::handle myOrthographicCamera; double myTransparency; double myShininess; occ::handle myFrontMaterial; occ::handle myPointsMaterial; occ::handle myUisoMaterial; occ::handle myVisoMaterial; occ::handle myLineMaterial; occ::handle myWireMaterial; occ::handle myFreeBoundsMaterial; occ::handle myUnfreeBoundsMaterial; double DX; double DY; double DZ; double XUp; double YUp; double ZUp; double Focus; }; #endif // _VrmlAPI_Writer_HeaderFile