Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:16

0001 // Created on: 2003-11-12
0002 // Created by: Alexander SOLOVYOV
0003 // Copyright (c) 2003-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 _MeshVS_NodalColorPrsBuilder_HeaderFile
0017 #define _MeshVS_NodalColorPrsBuilder_HeaderFile
0018 
0019 #include <MeshVS_DataMapOfIntegerColor.hxx>
0020 #include <Aspect_SequenceOfColor.hxx>
0021 #include <TColStd_DataMapOfIntegerReal.hxx>
0022 #include <Quantity_Color.hxx>
0023 #include <MeshVS_PrsBuilder.hxx>
0024 #include <MeshVS_DisplayModeFlags.hxx>
0025 #include <MeshVS_BuilderPriority.hxx>
0026 #include <TColStd_PackedMapOfInteger.hxx>
0027 #include <MeshVS_HArray1OfSequenceOfInteger.hxx>
0028 #include <TColStd_Array1OfInteger.hxx>
0029 #include <TColStd_Array1OfReal.hxx>
0030 
0031 class MeshVS_Mesh;
0032 class MeshVS_DataSource;
0033 class Graphic3d_Texture2D;
0034 class Graphic3d_ArrayOfPrimitives;
0035 
0036 DEFINE_STANDARD_HANDLE(MeshVS_NodalColorPrsBuilder, MeshVS_PrsBuilder)
0037 
0038 //! This class provides methods to create presentation of nodes with assigned color.
0039 //! There are two ways of presentation building
0040 //! 1. Without using texture.
0041 //! In this case colors of nodes are specified with DataMapOfIntegerColor and presentation
0042 //! is built with gradient fill between these nodes (default behaviour)
0043 //! 2. Using texture.
0044 //! In this case presentation is built with spectrum filling between nodes. For example, if
0045 //! one node has blue color and second one has violet color, parameters of this class may be
0046 //! set to fill presentation between nodes with solar spectrum.
0047 //! Methods:
0048 //! UseTexture - activates/deactivates this way
0049 //! SetColorMap - sets colors used for generation of texture
0050 //! SetColorindices - specifies correspondence between node IDs and indices of colors from color map
0051 class MeshVS_NodalColorPrsBuilder : public MeshVS_PrsBuilder
0052 {
0053 
0054 public:
0055 
0056   
0057   Standard_EXPORT MeshVS_NodalColorPrsBuilder(const Handle(MeshVS_Mesh)& Parent, const MeshVS_DisplayModeFlags& Flags = MeshVS_DMF_NodalColorDataPrs, const Handle(MeshVS_DataSource)& DS = 0, const Standard_Integer Id = -1, const MeshVS_BuilderPriority& Priority = MeshVS_BP_NodalColor);
0058   
0059   //! Builds presentation of nodes with assigned color.
0060   Standard_EXPORT virtual void Build (const Handle(Prs3d_Presentation)& Prs, const TColStd_PackedMapOfInteger& IDs, TColStd_PackedMapOfInteger& IDsToExclude, const Standard_Boolean IsElement, const Standard_Integer DisplayMode) const Standard_OVERRIDE;
0061   
0062   //! Returns map of colors assigned to nodes.
0063   Standard_EXPORT const MeshVS_DataMapOfIntegerColor& GetColors() const;
0064   
0065   //! Sets map of colors assigned to nodes.
0066   Standard_EXPORT void SetColors (const MeshVS_DataMapOfIntegerColor& Map);
0067   
0068   //! Returns true, if map isn't empty
0069   Standard_EXPORT Standard_Boolean HasColors() const;
0070   
0071   //! Returns color assigned to single node
0072   Standard_EXPORT Standard_Boolean GetColor (const Standard_Integer ID, Quantity_Color& theColor) const;
0073   
0074   //! Sets color assigned to single node
0075   Standard_EXPORT void SetColor (const Standard_Integer ID, const Quantity_Color& theColor);
0076   
0077   //! Specify whether texture must be used to build presentation
0078   Standard_EXPORT void UseTexture (const Standard_Boolean theToUse);
0079   
0080   //! Verify whether texture is used to build presentation
0081   Standard_EXPORT Standard_Boolean IsUseTexture() const;
0082   
0083   //! Set colors to be used for texrture presentation
0084   //! theColors - colors for valid coordinates (laying in range [0, 1])
0085   Standard_EXPORT void SetColorMap (const Aspect_SequenceOfColor& theColors);
0086   
0087   //! Return colors used for texrture presentation
0088   Standard_EXPORT const Aspect_SequenceOfColor& GetColorMap() const;
0089   
0090   //! Set color representing invalid texture coordinate
0091   //! (laying outside range [0, 1])
0092   Standard_EXPORT void SetInvalidColor (const Quantity_Color& theInvalidColor);
0093   
0094   //! Return color representing invalid texture coordinate
0095   //! (laying outside range [0, 1])
0096   Standard_EXPORT Quantity_Color GetInvalidColor() const;
0097   
0098   //! Specify correspondence between node IDs and texture coordinates (range [0, 1])
0099   Standard_EXPORT void SetTextureCoords (const TColStd_DataMapOfIntegerReal& theMap);
0100   
0101   //! Get correspondence between node IDs and texture coordinates (range [0, 1])
0102   Standard_EXPORT const TColStd_DataMapOfIntegerReal& GetTextureCoords() const;
0103   
0104   //! Specify correspondence between node ID and texture coordinate (range [0, 1])
0105   Standard_EXPORT void SetTextureCoord (const Standard_Integer theID, const Standard_Real theCoord);
0106   
0107   //! Return correspondence between node IDs and texture coordinate (range [0, 1])
0108   Standard_EXPORT Standard_Real GetTextureCoord (const Standard_Integer theID);
0109   
0110   //! Add to array polygons or polylines representing volume
0111   Standard_EXPORT void AddVolumePrs (const Handle(MeshVS_HArray1OfSequenceOfInteger)& theTopo, const TColStd_Array1OfInteger& theNodes, const TColStd_Array1OfReal& theCoords, const Handle(Graphic3d_ArrayOfPrimitives)& theArray, const Standard_Boolean theIsShaded, const Standard_Integer theNbColors, const Standard_Integer theNbTexColors, const Standard_Real theColorRatio) const;
0112 
0113 
0114 
0115 
0116   DEFINE_STANDARD_RTTIEXT(MeshVS_NodalColorPrsBuilder,MeshVS_PrsBuilder)
0117 
0118 protected:
0119 
0120 
0121 
0122 
0123 private:
0124 
0125   
0126   //! Create texture in accordance with myTextureColorMap
0127   Standard_EXPORT Handle(Graphic3d_Texture2D) CreateTexture() const;
0128 
0129   MeshVS_DataMapOfIntegerColor myNodeColorMap;
0130   Standard_Boolean myUseTexture;
0131   Aspect_SequenceOfColor myTextureColorMap;
0132   TColStd_DataMapOfIntegerReal myTextureCoords;
0133   Quantity_Color myInvalidColor;
0134 
0135 
0136 };
0137 
0138 
0139 
0140 
0141 
0142 
0143 
0144 #endif // _MeshVS_NodalColorPrsBuilder_HeaderFile