Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-09 10:25:47

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 <Standard_Integer.hxx>
0020 #include <NCollection_Array1.hxx>
0021 #include <NCollection_HArray1.hxx>
0022 #include <AIS_InteractiveObject.hxx>
0023 
0024 class Poly_Triangulation;
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   //! Constructs the Triangulation display object
0035   Standard_EXPORT AIS_Triangulation(const occ::handle<Poly_Triangulation>& aTriangulation);
0036 
0037   //! Set the color for each node.
0038   //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
0039   //! Order of color components is essential for further usage by OpenGL
0040   Standard_EXPORT void SetColors(const occ::handle<NCollection_HArray1<int>>& aColor);
0041 
0042   //! Get the color for each node.
0043   //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
0044   Standard_EXPORT occ::handle<NCollection_HArray1<int>> GetColors() const;
0045 
0046   //! Returns true if triangulation has vertex colors.
0047   bool HasVertexColors() const { return (myFlagColor == 1); }
0048 
0049   Standard_EXPORT void SetTriangulation(const occ::handle<Poly_Triangulation>& aTriangulation);
0050 
0051   //! Returns Poly_Triangulation .
0052   Standard_EXPORT occ::handle<Poly_Triangulation> GetTriangulation() const;
0053 
0054   //! Sets the value aValue for transparency in the reconstructed compound shape.
0055   Standard_EXPORT void SetTransparency(const double aValue = 0.6) override;
0056 
0057   //! Removes the setting for transparency in the reconstructed compound shape.
0058   Standard_EXPORT void UnsetTransparency() override;
0059 
0060 protected:
0061   Standard_EXPORT void updatePresentation();
0062 
0063 private:
0064   Standard_EXPORT void Compute(const occ::handle<PrsMgr_PresentationManager>& thePrsMgr,
0065                                const occ::handle<Prs3d_Presentation>&         thePrs,
0066                                const int                                      theMode) override;
0067 
0068   Standard_EXPORT void ComputeSelection(const occ::handle<SelectMgr_Selection>& theSel,
0069                                         const int                               theMode) override;
0070 
0071   //! Attenuates 32-bit color by a given attenuation factor (0...1):
0072   //! aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
0073   //! All color components are multiplied by aComponent, the result is then packed again as 32-bit
0074   //! integer. Color attenuation is applied to the vertex colors in order to have correct visual
0075   //! result after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and
0076   //! flat.
0077   Standard_EXPORT NCollection_Vec4<uint8_t> attenuateColor(const int    theColor,
0078                                                            const double theComponent);
0079 
0080   occ::handle<Poly_Triangulation>       myTriangulation;
0081   occ::handle<NCollection_HArray1<int>> myColor;
0082   int                                   myFlagColor;
0083   int                                   myNbNodes;
0084   int                                   myNbTriangles;
0085 };
0086 
0087 #endif // _AIS_Triangulation_HeaderFile