Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:31

0001 // Created on: 2000-06-20
0002 // Created by: Sergey MOZOKHIN
0003 // Copyright (c) 2000-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 _VrmlAPI_Writer_HeaderFile
0017 #define _VrmlAPI_Writer_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021 #include <Standard_Handle.hxx>
0022 
0023 #include <VrmlAPI_RepresentationOfShape.hxx>
0024 #include <Quantity_HArray1OfColor.hxx>
0025 #include <Standard_Integer.hxx>
0026 
0027 class VrmlConverter_Drawer;
0028 class VrmlConverter_Projector;
0029 class Vrml_Material;
0030 class TopoDS_Shape;
0031 class TDocStd_Document;
0032 
0033 
0034 //! Creates and writes VRML files from Open
0035 //! CASCADE shapes. A VRML file can be written to
0036 //! an existing VRML file or to a new one.
0037 class VrmlAPI_Writer 
0038 {
0039 public:
0040 
0041   DEFINE_STANDARD_ALLOC
0042 
0043   
0044   //! Creates a writer object with default parameters.
0045   Standard_EXPORT VrmlAPI_Writer();
0046   
0047   //! Resets all parameters (representation, deflection)
0048   //! to their default values..
0049   Standard_EXPORT void ResetToDefaults();
0050   
0051   //! Returns drawer object
0052   Standard_EXPORT Handle(VrmlConverter_Drawer) Drawer() const;
0053   
0054   //! Sets the deflection aDef of
0055   //! the mesh algorithm which is used to compute the shaded
0056   //! representation of the translated shape. The default
0057   //! value is -1. When the deflection value is less than
0058   //! 0, the deflection is calculated from the relative
0059   //! size of the shaped.
0060   Standard_EXPORT void SetDeflection (const Standard_Real aDef);
0061   
0062   //! Sets the representation of the
0063   //! shape aRep which is written to the VRML file. The three options are :
0064   //! -      shaded
0065   //! -      wireframe
0066   //! -      both shaded and wireframe (default)
0067   //! defined through the VrmlAPI_RepresentationOfShape enumeration.
0068   Standard_EXPORT void SetRepresentation (const VrmlAPI_RepresentationOfShape aRep);
0069   
0070   //! Set transparency to given material
0071   Standard_EXPORT void SetTransparencyToMaterial (Handle(Vrml_Material)& aMaterial, const Standard_Real aTransparency);
0072   
0073   Standard_EXPORT void SetShininessToMaterial (Handle(Vrml_Material)& aMaterial, const Standard_Real aShininess);
0074   
0075   Standard_EXPORT void SetAmbientColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color);
0076   
0077   Standard_EXPORT void SetDiffuseColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color);
0078   
0079   Standard_EXPORT void SetSpecularColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color);
0080   
0081   Standard_EXPORT void SetEmissiveColorToMaterial (Handle(Vrml_Material)& aMaterial, const Handle(Quantity_HArray1OfColor)& Color);
0082   
0083   //! Returns the representation of the shape which is
0084   //! written to the VRML file. Types of representation are set through the
0085   //! VrmlAPI_RepresentationOfShape enumeration.
0086   Standard_EXPORT VrmlAPI_RepresentationOfShape GetRepresentation() const;
0087   
0088   Standard_EXPORT Handle(Vrml_Material) GetFrontMaterial() const;
0089   
0090   Standard_EXPORT Handle(Vrml_Material) GetPointsMaterial() const;
0091   
0092   Standard_EXPORT Handle(Vrml_Material) GetUisoMaterial() const;
0093   
0094   Standard_EXPORT Handle(Vrml_Material) GetVisoMaterial() const;
0095   
0096   Standard_EXPORT Handle(Vrml_Material) GetLineMaterial() const;
0097   
0098   Standard_EXPORT Handle(Vrml_Material) GetWireMaterial() const;
0099   
0100   Standard_EXPORT Handle(Vrml_Material) GetFreeBoundsMaterial() const;
0101   
0102   Standard_EXPORT Handle(Vrml_Material) GetUnfreeBoundsMaterial() const;
0103   
0104   //! Converts the shape aShape to
0105   //! VRML format of the passed version and writes it to the file identified by aFile.
0106   Standard_EXPORT Standard_Boolean Write (const TopoDS_Shape& aShape, const Standard_CString aFile,
0107       const Standard_Integer aVersion = 2) const;
0108 
0109   //! Converts the document to VRML format of the passed version
0110   //! and writes it to the file identified by aFile.
0111   Standard_EXPORT Standard_Boolean WriteDoc(
0112     const Handle(TDocStd_Document) &theDoc,
0113     const Standard_CString theFile,
0114     const Standard_Real theScale) const;
0115 
0116 protected:
0117 
0118   //! Converts the shape aShape to VRML format of version 1.0 and writes it
0119   //! to the file identified by aFileName using default parameters.
0120   Standard_EXPORT Standard_Boolean write_v1 (const TopoDS_Shape& aShape, const Standard_CString aFileName) const;
0121   
0122   //! Converts the shape aShape to VRML format of version 2.0 and writes it
0123   //! to the file identified by aFileName using default parameters.
0124   Standard_EXPORT Standard_Boolean write_v2 (const TopoDS_Shape& aShape, const Standard_CString aFileName) const;
0125 
0126 private:
0127 
0128   VrmlAPI_RepresentationOfShape myRepresentation;
0129   Handle(VrmlConverter_Drawer) myDrawer;
0130   Standard_Real myDeflection;
0131   Handle(VrmlConverter_Projector) myPerespectiveCamera;
0132   Handle(VrmlConverter_Projector) myOrthographicCamera;
0133   Standard_Real myTransparency;
0134   Standard_Real myShininess;
0135   Handle(Vrml_Material) myFrontMaterial;
0136   Handle(Vrml_Material) myPointsMaterial;
0137   Handle(Vrml_Material) myUisoMaterial;
0138   Handle(Vrml_Material) myVisoMaterial;
0139   Handle(Vrml_Material) myLineMaterial;
0140   Handle(Vrml_Material) myWireMaterial;
0141   Handle(Vrml_Material) myFreeBoundsMaterial;
0142   Handle(Vrml_Material) myUnfreeBoundsMaterial;
0143   Standard_Real DX;
0144   Standard_Real DY;
0145   Standard_Real DZ;
0146   Standard_Real XUp;
0147   Standard_Real YUp;
0148   Standard_Real ZUp;
0149   Standard_Real Focus;
0150 
0151 };
0152 
0153 #endif // _VrmlAPI_Writer_HeaderFile