Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 09:18:22

0001 // Created on: 2003-10-13
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_VectorPrsBuilder_HeaderFile
0017 #define _MeshVS_VectorPrsBuilder_HeaderFile
0018 
0019 #include <Standard_Integer.hxx>
0020 #include <gp_Vec.hxx>
0021 #include <NCollection_DataMap.hxx>
0022 #include <MeshVS_PrsBuilder.hxx>
0023 #include <MeshVS_DisplayModeFlags.hxx>
0024 #include <MeshVS_BuilderPriority.hxx>
0025 #include <gp_Pnt.hxx>
0026 #include <NCollection_Array1.hxx>
0027 
0028 class MeshVS_Mesh;
0029 class Quantity_Color;
0030 class MeshVS_DataSource;
0031 class gp_Trsf;
0032 class Graphic3d_ArrayOfPrimitives;
0033 class gp_Vec;
0034 
0035 //! This class provides methods to create vector data presentation.
0036 //! It store map of vectors assigned with nodes or elements.
0037 //! In simplified mode vectors draws with thickened ends instead of arrows
0038 class MeshVS_VectorPrsBuilder : public MeshVS_PrsBuilder
0039 {
0040 
0041 public:
0042   Standard_EXPORT MeshVS_VectorPrsBuilder(
0043     const occ::handle<MeshVS_Mesh>&       Parent,
0044     const double                          MaxLength,
0045     const Quantity_Color&                 VectorColor,
0046     const MeshVS_DisplayModeFlags&        Flags       = MeshVS_DMF_VectorDataPrs,
0047     const occ::handle<MeshVS_DataSource>& DS          = nullptr,
0048     const int                             Id          = -1,
0049     const MeshVS_BuilderPriority&         Priority    = MeshVS_BP_Vector,
0050     const bool                            IsSimplePrs = false);
0051 
0052   //! Builds vector data presentation
0053   Standard_EXPORT void Build(const occ::handle<Prs3d_Presentation>& Prs,
0054                              const TColStd_PackedMapOfInteger&      IDs,
0055                              TColStd_PackedMapOfInteger&            IDsToExclude,
0056                              const bool                             IsElement,
0057                              const int                              theDisplayMode) const override;
0058 
0059   //! Adds to array of polygons and polylines some primitive representing single vector
0060   Standard_EXPORT void DrawVector(const gp_Trsf&                                  theTrsf,
0061                                   const double                                    Length,
0062                                   const double                                    MaxLength,
0063                                   const NCollection_Array1<gp_Pnt>&               ArrowPoints,
0064                                   const occ::handle<Graphic3d_ArrayOfPrimitives>& Lines,
0065                                   const occ::handle<Graphic3d_ArrayOfPrimitives>& ArrowLines,
0066                                   const occ::handle<Graphic3d_ArrayOfPrimitives>& Triangles) const;
0067 
0068   //! Calculates points of arrow presentation
0069   Standard_EXPORT static double calculateArrow(NCollection_Array1<gp_Pnt>& Points,
0070                                                const double                Length,
0071                                                const double                ArrowPart);
0072 
0073   //! Returns map of vectors assigned with nodes or elements
0074   Standard_EXPORT const NCollection_DataMap<int, gp_Vec>& GetVectors(const bool IsElement) const;
0075 
0076   //! Sets map of vectors assigned with nodes or elements
0077   Standard_EXPORT void SetVectors(const bool                              IsElement,
0078                                   const NCollection_DataMap<int, gp_Vec>& Map);
0079 
0080   //! Returns true, if map isn't empty
0081   Standard_EXPORT bool HasVectors(const bool IsElement) const;
0082 
0083   //! Returns vector assigned with certain node or element
0084   Standard_EXPORT bool GetVector(const bool IsElement, const int ID, gp_Vec& Vect) const;
0085 
0086   //! Sets vector assigned with certain node or element
0087   Standard_EXPORT void SetVector(const bool IsElement, const int ID, const gp_Vec& Vect);
0088 
0089   //! Calculates minimal and maximal length of vectors in map
0090   //! ( nodal, if IsElement = False or elemental, if IsElement = True )
0091   Standard_EXPORT void GetMinMaxVectorValue(const bool IsElement,
0092                                             double&    MinValue,
0093                                             double&    MaxValue) const;
0094 
0095   //! Sets flag that indicates is simple vector arrow mode uses or not
0096   //! default value is False
0097   Standard_EXPORT void SetSimplePrsMode(const bool IsSimpleArrow);
0098 
0099   //! Sets parameters of simple vector arrwo presentation
0100   //! theLineWidthParam - coefficient of vector line width (to draw line instead of arrow)
0101   //! theStartParam and theEndParam parameters of start and end of thickened ends
0102   //! position of thickening calculates according to parameters and maximum vector length
0103   //! default values are:
0104   //! theLineWidthParam = 2.5
0105   //! theStartParam     = 0.85
0106   //! theEndParam       = 0.95
0107   Standard_EXPORT void SetSimplePrsParams(const double theLineWidthParam,
0108                                           const double theStartParam,
0109                                           const double theEndParam);
0110 
0111   DEFINE_STANDARD_RTTIEXT(MeshVS_VectorPrsBuilder, MeshVS_PrsBuilder)
0112 
0113 private:
0114   bool                             myIsSimplePrs;
0115   double                           mySimpleWidthPrm;
0116   double                           mySimpleStartPrm;
0117   double                           mySimpleEndPrm;
0118   NCollection_DataMap<int, gp_Vec> myNodeVectorMap;
0119   NCollection_DataMap<int, gp_Vec> myElemVectorMap;
0120 };
0121 
0122 #endif // _MeshVS_VectorPrsBuilder_HeaderFile