Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:55

0001 // Created on: 2009-12-10
0002 // Created by: Paul SUPRYATKIN
0003 // Copyright (c) 2009-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 _AIS_Triangulation_HeaderFile
0017 #define _AIS_Triangulation_HeaderFile
0018 
0019 #include <TColStd_HArray1OfInteger.hxx>
0020 #include <AIS_InteractiveObject.hxx>
0021 
0022 class Poly_Triangulation;
0023 
0024 DEFINE_STANDARD_HANDLE(AIS_Triangulation, AIS_InteractiveObject)
0025 
0026 //! Interactive object that draws data from  Poly_Triangulation, optionally with colors associated
0027 //! with each triangulation vertex. For maximum efficiency colors are represented as 32-bit integers
0028 //! instead of classic Quantity_Color values.
0029 //! Interactive selection of triangles and vertices is not yet implemented.
0030 class AIS_Triangulation : public AIS_InteractiveObject
0031 {
0032   DEFINE_STANDARD_RTTIEXT(AIS_Triangulation, AIS_InteractiveObject)
0033 public:
0034 
0035   //! Constructs the Triangulation display object
0036   Standard_EXPORT AIS_Triangulation(const Handle(Poly_Triangulation)& aTriangulation);
0037   
0038 
0039   //! Set the color for each node.
0040   //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
0041   //! Order of color components is essential for further usage by OpenGL
0042   Standard_EXPORT void SetColors (const Handle(TColStd_HArray1OfInteger)& aColor);
0043   
0044 
0045   //! Get the color for each node.
0046   //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
0047   Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetColors() const;
0048 
0049   //! Returns true if triangulation has vertex colors.
0050   Standard_Boolean HasVertexColors() const
0051   {
0052     return (myFlagColor == 1);
0053   }
0054   
0055   Standard_EXPORT void SetTriangulation (const Handle(Poly_Triangulation)& aTriangulation);
0056   
0057   //! Returns Poly_Triangulation .
0058   Standard_EXPORT Handle(Poly_Triangulation) GetTriangulation() const;
0059 
0060   //! Sets the value aValue for transparency in the reconstructed compound shape.
0061   Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6) Standard_OVERRIDE;
0062 
0063   //! Removes the setting for transparency in the reconstructed compound shape.
0064   Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
0065 
0066 protected:
0067 
0068   Standard_EXPORT void updatePresentation();
0069 
0070 private:
0071 
0072   Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
0073                                         const Handle(Prs3d_Presentation)& thePrs,
0074                                         const Standard_Integer theMode) Standard_OVERRIDE;
0075 
0076   Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
0077                                                  const Standard_Integer theMode) Standard_OVERRIDE;
0078 
0079   //! Attenuates 32-bit color by a given attenuation factor (0...1):
0080   //! aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
0081   //! All color components are multiplied by aComponent, the result is then packed again as 32-bit integer.
0082   //! Color attenuation is applied to the vertex colors in order to have correct visual result
0083   //! after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and flat.
0084   Standard_EXPORT Graphic3d_Vec4ub attenuateColor (const Standard_Integer theColor, const Standard_Real theComponent);
0085 
0086   Handle(Poly_Triangulation) myTriangulation;
0087   Handle(TColStd_HArray1OfInteger) myColor;
0088   Standard_Integer myFlagColor;
0089   Standard_Integer myNbNodes;
0090   Standard_Integer myNbTriangles;
0091 
0092 };
0093 
0094 #endif // _AIS_Triangulation_HeaderFile