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