Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-03 09:18:12

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_Color.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <NCollection_HArray1.hxx>
0027 #include <Standard_Integer.hxx>
0028 #include <Vrml_Material.hxx>
0029 
0030 class VrmlConverter_Drawer;
0031 class VrmlConverter_Projector;
0032 class TopoDS_Shape;
0033 class TDocStd_Document;
0034 
0035 //! Creates and writes VRML files from Open
0036 //! CASCADE shapes. A VRML file can be written to
0037 //! an existing VRML file or to a new one.
0038 class VrmlAPI_Writer
0039 {
0040 public:
0041   DEFINE_STANDARD_ALLOC
0042 
0043   //! Creates a writer object with default parameters.
0044   Standard_EXPORT VrmlAPI_Writer();
0045 
0046   //! Resets all parameters (representation, deflection)
0047   //! to their default values..
0048   Standard_EXPORT void ResetToDefaults();
0049 
0050   //! Returns drawer object
0051   Standard_EXPORT occ::handle<VrmlConverter_Drawer> Drawer() const;
0052 
0053   //! Sets the deflection aDef of
0054   //! the mesh algorithm which is used to compute the shaded
0055   //! representation of the translated shape. The default
0056   //! value is -1. When the deflection value is less than
0057   //! 0, the deflection is calculated from the relative
0058   //! size of the shaped.
0059   Standard_EXPORT void SetDeflection(const double aDef);
0060 
0061   //! Sets the representation of the
0062   //! shape aRep which is written to the VRML file. The three options are :
0063   //! -      shaded
0064   //! -      wireframe
0065   //! -      both shaded and wireframe (default)
0066   //! defined through the VrmlAPI_RepresentationOfShape enumeration.
0067   Standard_EXPORT void SetRepresentation(const VrmlAPI_RepresentationOfShape aRep);
0068 
0069   //! Returns the representation of the shape which is
0070   //! written to the VRML file. Types of representation are set through the
0071   //! VrmlAPI_RepresentationOfShape enumeration.
0072   Standard_EXPORT VrmlAPI_RepresentationOfShape GetRepresentation() const;
0073 
0074   //! @deprecated Call Vrml_Material::SetTransparency() directly instead.
0075   Standard_DEPRECATED("Call Vrml_Material::SetTransparency() directly instead")
0076   Standard_EXPORT void SetTransparencyToMaterial(occ::handle<Vrml_Material>& aMaterial,
0077                                                  const double                aTransparency);
0078 
0079   //! @deprecated Call Vrml_Material::SetShininess() directly instead.
0080   Standard_DEPRECATED("Call Vrml_Material::SetShininess() directly instead")
0081   Standard_EXPORT void SetShininessToMaterial(occ::handle<Vrml_Material>& aMaterial,
0082                                               const double                aShininess);
0083 
0084   //! @deprecated Call Vrml_Material::SetAmbientColor() directly instead.
0085   Standard_DEPRECATED("Call Vrml_Material::SetAmbientColor() directly instead")
0086   Standard_EXPORT void SetAmbientColorToMaterial(
0087     occ::handle<Vrml_Material>&                             aMaterial,
0088     const occ::handle<NCollection_HArray1<Quantity_Color>>& Color);
0089 
0090   //! @deprecated Call Vrml_Material::SetDiffuseColor() directly instead.
0091   Standard_DEPRECATED("Call Vrml_Material::SetDiffuseColor() directly instead")
0092   Standard_EXPORT void SetDiffuseColorToMaterial(
0093     occ::handle<Vrml_Material>&                             aMaterial,
0094     const occ::handle<NCollection_HArray1<Quantity_Color>>& Color);
0095 
0096   //! @deprecated Call Vrml_Material::SetSpecularColor() directly instead.
0097   Standard_DEPRECATED("Call Vrml_Material::SetSpecularColor() directly instead")
0098   Standard_EXPORT void SetSpecularColorToMaterial(
0099     occ::handle<Vrml_Material>&                             aMaterial,
0100     const occ::handle<NCollection_HArray1<Quantity_Color>>& Color);
0101 
0102   //! @deprecated Call Vrml_Material::SetEmissiveColor() directly instead.
0103   Standard_DEPRECATED("Call Vrml_Material::SetEmissiveColor() directly instead")
0104   Standard_EXPORT void SetEmissiveColorToMaterial(
0105     occ::handle<Vrml_Material>&                             aMaterial,
0106     const occ::handle<NCollection_HArray1<Quantity_Color>>& Color);
0107 
0108   Standard_EXPORT occ::handle<Vrml_Material> GetFrontMaterial() const;
0109 
0110   Standard_EXPORT occ::handle<Vrml_Material> GetPointsMaterial() const;
0111 
0112   Standard_EXPORT occ::handle<Vrml_Material> GetUisoMaterial() const;
0113 
0114   Standard_EXPORT occ::handle<Vrml_Material> GetVisoMaterial() const;
0115 
0116   Standard_EXPORT occ::handle<Vrml_Material> GetLineMaterial() const;
0117 
0118   Standard_EXPORT occ::handle<Vrml_Material> GetWireMaterial() const;
0119 
0120   Standard_EXPORT occ::handle<Vrml_Material> GetFreeBoundsMaterial() const;
0121 
0122   Standard_EXPORT occ::handle<Vrml_Material> GetUnfreeBoundsMaterial() const;
0123 
0124   //! Converts the shape aShape to
0125   //! VRML format of the passed version and writes it to the file identified by aFile.
0126   Standard_EXPORT bool Write(const TopoDS_Shape& aShape,
0127                              const char* const   aFile,
0128                              const int           aVersion = 2) const;
0129 
0130   //! Converts the document to VRML format of the passed version
0131   //! and writes it to the file identified by aFile.
0132   Standard_EXPORT bool WriteDoc(const occ::handle<TDocStd_Document>& theDoc,
0133                                 const char* const                    theFile,
0134                                 const double                         theScale) const;
0135 
0136   //! Converts the shape aShape to
0137   //! VRML format of the passed version and writes it to the given stream.
0138   Standard_EXPORT bool Write(const TopoDS_Shape& aShape,
0139                              Standard_OStream&   theOStream,
0140                              const int           aVersion = 2) const;
0141 
0142   //! Converts the document to VRML format of the passed version
0143   //! and writes it to the given stream.
0144   Standard_EXPORT bool WriteDoc(const occ::handle<TDocStd_Document>& theDoc,
0145                                 Standard_OStream&                    theOStream,
0146                                 const double                         theScale) const;
0147 
0148 protected:
0149   //! Converts the shape aShape to VRML format of version 1.0 and writes it
0150   //! to the given stream using default parameters.
0151   Standard_EXPORT bool write_v1(const TopoDS_Shape& aShape, Standard_OStream& theOStream) const;
0152 
0153   //! Converts the shape aShape to VRML format of version 2.0 and writes it
0154   //! to the given stream using default parameters.
0155   Standard_EXPORT bool write_v2(const TopoDS_Shape& aShape, Standard_OStream& theOStream) const;
0156 
0157 private:
0158   VrmlAPI_RepresentationOfShape        myRepresentation;
0159   occ::handle<VrmlConverter_Drawer>    myDrawer;
0160   double                               myDeflection;
0161   occ::handle<VrmlConverter_Projector> myPerespectiveCamera;
0162   occ::handle<VrmlConverter_Projector> myOrthographicCamera;
0163   double                               myTransparency;
0164   double                               myShininess;
0165   occ::handle<Vrml_Material>           myFrontMaterial;
0166   occ::handle<Vrml_Material>           myPointsMaterial;
0167   occ::handle<Vrml_Material>           myUisoMaterial;
0168   occ::handle<Vrml_Material>           myVisoMaterial;
0169   occ::handle<Vrml_Material>           myLineMaterial;
0170   occ::handle<Vrml_Material>           myWireMaterial;
0171   occ::handle<Vrml_Material>           myFreeBoundsMaterial;
0172   occ::handle<Vrml_Material>           myUnfreeBoundsMaterial;
0173   double                               DX;
0174   double                               DY;
0175   double                               DZ;
0176   double                               XUp;
0177   double                               YUp;
0178   double                               ZUp;
0179   double                               Focus;
0180 };
0181 
0182 #endif // _VrmlAPI_Writer_HeaderFile