1 // Created on: 2009-12-10
2 // Created by: Paul SUPRYATKIN
3 // Copyright (c) 2009-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _AIS_Triangulation_HeaderFile
17 #define _AIS_Triangulation_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
22 #include <TColStd_HArray1OfInteger.hxx>
23 #include <Standard_Integer.hxx>
24 #include <AIS_InteractiveObject.hxx>
25 #include <PrsMgr_PresentationManager3d.hxx>
26 #include <SelectMgr_Selection.hxx>
27 #include <Standard_Real.hxx>
28 class Poly_Triangulation;
29 class Prs3d_Presentation;
32 class AIS_Triangulation;
33 DEFINE_STANDARD_HANDLE(AIS_Triangulation, AIS_InteractiveObject)
35 //! Interactive object that draws data from Poly_Triangulation, optionally with colors associated
36 //! with each triangulation vertex. For maximum efficiency colors are represented as 32-bit integers
37 //! instead of classic Quantity_Color values.
38 //! Interactive selection of triangles and vertices is not yet implemented.
39 class AIS_Triangulation : public AIS_InteractiveObject
45 //! Constructs the Triangulation display object
46 Standard_EXPORT AIS_Triangulation(const Handle(Poly_Triangulation)& aTriangulation);
49 //! Set the color for each node.
50 //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
51 //! Order of color components is essential for further usage by OpenGL
52 Standard_EXPORT void SetColors (const Handle(TColStd_HArray1OfInteger)& aColor);
55 //! Get the color for each node.
56 //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
57 Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetColors() const;
59 //! Returns true if triangulation has vertex colors.
60 Standard_Boolean HasVertexColors() const
62 return (myFlagColor == 1);
65 Standard_EXPORT void SetTriangulation (const Handle(Poly_Triangulation)& aTriangulation);
67 //! Returns Poly_Triangulation .
68 Standard_EXPORT Handle(Poly_Triangulation) GetTriangulation() const;
70 //! Sets the value aValue for transparency in the reconstructed compound shape.
71 Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6) Standard_OVERRIDE;
73 //! Removes the setting for transparency in the reconstructed compound shape.
74 Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
76 DEFINE_STANDARD_RTTIEXT(AIS_Triangulation,AIS_InteractiveObject)
80 Standard_EXPORT void updatePresentation();
87 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
89 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
91 //! Attenuates 32-bit color by a given attenuation factor (0...1):
92 //! aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
93 //! All color components are multiplied by aComponent, the result is then packed again as 32-bit integer.
94 //! Color attenuation is applied to the vertex colors in order to have correct visual result
95 //! after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and flat.
96 Standard_EXPORT Graphic3d_Vec4ub attenuateColor (const Standard_Integer theColor, const Standard_Real theComponent);
98 Handle(Poly_Triangulation) myTriangulation;
99 Handle(TColStd_HArray1OfInteger) myColor;
100 Standard_Integer myFlagColor;
101 Standard_Integer myNbNodes;
102 Standard_Integer myNbTriangles;
113 #endif // _AIS_Triangulation_HeaderFile