Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-13 08:30:41

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   Standard_EXPORT MeshVS_NodalColorPrsBuilder(
0056     const Handle(MeshVS_Mesh)&       Parent,
0057     const MeshVS_DisplayModeFlags&   Flags    = MeshVS_DMF_NodalColorDataPrs,
0058     const Handle(MeshVS_DataSource)& DS       = 0,
0059     const Standard_Integer           Id       = -1,
0060     const MeshVS_BuilderPriority&    Priority = MeshVS_BP_NodalColor);
0061 
0062   //! Builds presentation of nodes with assigned color.
0063   Standard_EXPORT virtual void Build(const Handle(Prs3d_Presentation)& Prs,
0064                                      const TColStd_PackedMapOfInteger& IDs,
0065                                      TColStd_PackedMapOfInteger&       IDsToExclude,
0066                                      const Standard_Boolean            IsElement,
0067                                      const Standard_Integer DisplayMode) const Standard_OVERRIDE;
0068 
0069   //! Returns map of colors assigned to nodes.
0070   Standard_EXPORT const MeshVS_DataMapOfIntegerColor& GetColors() const;
0071 
0072   //! Sets map of colors assigned to nodes.
0073   Standard_EXPORT void SetColors(const MeshVS_DataMapOfIntegerColor& Map);
0074 
0075   //! Returns true, if map isn't empty
0076   Standard_EXPORT Standard_Boolean HasColors() const;
0077 
0078   //! Returns color assigned to single node
0079   Standard_EXPORT Standard_Boolean GetColor(const Standard_Integer ID,
0080                                             Quantity_Color&        theColor) const;
0081 
0082   //! Sets color assigned to single node
0083   Standard_EXPORT void SetColor(const Standard_Integer ID, const Quantity_Color& theColor);
0084 
0085   //! Specify whether texture must be used to build presentation
0086   Standard_EXPORT void UseTexture(const Standard_Boolean theToUse);
0087 
0088   //! Verify whether texture is used to build presentation
0089   Standard_EXPORT Standard_Boolean IsUseTexture() const;
0090 
0091   //! Set colors to be used for texrture presentation
0092   //! theColors - colors for valid coordinates (laying in range [0, 1])
0093   Standard_EXPORT void SetColorMap(const Aspect_SequenceOfColor& theColors);
0094 
0095   //! Return colors used for texrture presentation
0096   Standard_EXPORT const Aspect_SequenceOfColor& GetColorMap() const;
0097 
0098   //! Set color representing invalid texture coordinate
0099   //! (laying outside range [0, 1])
0100   Standard_EXPORT void SetInvalidColor(const Quantity_Color& theInvalidColor);
0101 
0102   //! Return color representing invalid texture coordinate
0103   //! (laying outside range [0, 1])
0104   Standard_EXPORT Quantity_Color GetInvalidColor() const;
0105 
0106   //! Specify correspondence between node IDs and texture coordinates (range [0, 1])
0107   Standard_EXPORT void SetTextureCoords(const TColStd_DataMapOfIntegerReal& theMap);
0108 
0109   //! Get correspondence between node IDs and texture coordinates (range [0, 1])
0110   Standard_EXPORT const TColStd_DataMapOfIntegerReal& GetTextureCoords() const;
0111 
0112   //! Specify correspondence between node ID and texture coordinate (range [0, 1])
0113   Standard_EXPORT void SetTextureCoord(const Standard_Integer theID, const Standard_Real theCoord);
0114 
0115   //! Return correspondence between node IDs and texture coordinate (range [0, 1])
0116   Standard_EXPORT Standard_Real GetTextureCoord(const Standard_Integer theID);
0117 
0118   //! Add to array polygons or polylines representing volume
0119   Standard_EXPORT void AddVolumePrs(const Handle(MeshVS_HArray1OfSequenceOfInteger)& theTopo,
0120                                     const TColStd_Array1OfInteger&                   theNodes,
0121                                     const TColStd_Array1OfReal&                      theCoords,
0122                                     const Handle(Graphic3d_ArrayOfPrimitives)&       theArray,
0123                                     const Standard_Boolean                           theIsShaded,
0124                                     const Standard_Integer                           theNbColors,
0125                                     const Standard_Integer                           theNbTexColors,
0126                                     const Standard_Real theColorRatio) const;
0127 
0128   DEFINE_STANDARD_RTTIEXT(MeshVS_NodalColorPrsBuilder, MeshVS_PrsBuilder)
0129 
0130 protected:
0131 private:
0132   //! Create texture in accordance with myTextureColorMap
0133   Standard_EXPORT Handle(Graphic3d_Texture2D) CreateTexture() const;
0134 
0135   MeshVS_DataMapOfIntegerColor myNodeColorMap;
0136   Standard_Boolean             myUseTexture;
0137   Aspect_SequenceOfColor       myTextureColorMap;
0138   TColStd_DataMapOfIntegerReal myTextureCoords;
0139   Quantity_Color               myInvalidColor;
0140 };
0141 
0142 #endif // _MeshVS_NodalColorPrsBuilder_HeaderFile