Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:28:40

0001 // Created on: 2003-10-10
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_DataSource_HeaderFile
0017 #define _MeshVS_DataSource_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_Type.hxx>
0021 
0022 #include <Standard_Transient.hxx>
0023 #include <Standard_Integer.hxx>
0024 #include <MeshVS_EntityType.hxx>
0025 #include <NCollection_Sequence.hxx>
0026 #include <NCollection_Array1.hxx>
0027 #include <NCollection_HArray1.hxx>
0028 #include <TColStd_PackedMapOfInteger.hxx>
0029 #include <gp_Pnt2d.hxx>
0030 class Bnd_Box;
0031 class MeshVS_Mesh;
0032 class TColStd_HPackedMapOfInteger;
0033 class Bnd_Box2d;
0034 
0035 //! The deferred class using for the following tasks:
0036 //! 1) Receiving geometry data about single element of node by its number;
0037 //! 2) Receiving type of element or node by its number;
0038 //! 3) Receiving topological information about links between element and nodes it consist of;
0039 //! 4) Receiving information about what element cover this node;
0040 //! 5) Receiving information about all nodes and elements the object consist of
0041 //! 6) Activation of advanced mesh selection. In the advanced mesh selection mode there is created:
0042 //! - one owner for the whole mesh and for all selection modes
0043 //! - one sensitive entity for the whole mesh and for each selection mode
0044 //! Receiving of IDs of detected entities (nodes and elements) in a viewer is achieved by
0045 //! implementation of a group of methods GetDetectedEntities.
0046 class MeshVS_DataSource : public Standard_Transient
0047 {
0048 
0049 public:
0050   //! Returns geometry information about node or element
0051   //! ID is the numerical identificator of node or element
0052   //! IsElement indicates this ID describe node ( if false ) or element ( if true
0053   //! ) Coords is an array of coordinates of node(s). For node it is only 3 numbers: X, Y, Z in the
0054   //! strict order For element it is 3*n numbers, where n is number of this element vertices The
0055   //! order is strict also: X1, Y1, Z1, X2,...., where Xi, Yi, Zi are coordinates of vertices
0056   //! NbNodes is number of nodes. It is recommended this parameter to be set to 1 for node.
0057   //! Type is type of node or element (from enumeration). It is recommended this parameter to be set
0058   //! to MeshVS_ET_Node for node.
0059   Standard_EXPORT virtual bool GetGeom(const int                   ID,
0060                                        const bool                  IsElement,
0061                                        NCollection_Array1<double>& Coords,
0062                                        int&                        NbNodes,
0063                                        MeshVS_EntityType&          Type) const = 0;
0064 
0065   //! This method is similar to GetGeom, but returns only element or node type.
0066   Standard_EXPORT virtual bool GetGeomType(const int          ID,
0067                                            const bool         IsElement,
0068                                            MeshVS_EntityType& Type) const = 0;
0069 
0070   //! This method returns topology information about 3D-element
0071   //! Returns false if element with ID isn't 3D or because other troubles
0072   Standard_EXPORT virtual bool Get3DGeom(
0073     const int                                                    ID,
0074     int&                                                         NbNodes,
0075     occ::handle<NCollection_HArray1<NCollection_Sequence<int>>>& Data) const;
0076 
0077   //! This method returns pointer which represents element or node data structure.
0078   //! This address will be saved in MeshVS_MeshEntityOwner, so that you can access to data structure
0079   //! fast by the method Owner(). In the redefined method you can return NULL. ID is the numerical
0080   //! identificator of node or element IsElement indicates this ID describe node ( if false
0081   //! ) or element ( if true )
0082   Standard_EXPORT virtual void* GetAddr(const int ID, const bool IsElement) const = 0;
0083 
0084   //! This method returns information about nodes this element consist of.
0085   //! ID is the numerical identificator of element.
0086   //! NodeIDs is the output array of nodes IDs in correct order,
0087   //! the same as coordinates returned by GetGeom().
0088   //! NbNodes is number of nodes (number of items set in NodeIDs).
0089   //! Returns False if element does not exist
0090   Standard_EXPORT virtual bool GetNodesByElement(const int                ID,
0091                                                  NCollection_Array1<int>& NodeIDs,
0092                                                  int&                     NbNodes) const = 0;
0093 
0094   //! This method returns map of all nodes the object consist of.
0095   Standard_EXPORT virtual const TColStd_PackedMapOfInteger& GetAllNodes() const = 0;
0096 
0097   //! This method returns map of all elements the object consist of.
0098   Standard_EXPORT virtual const TColStd_PackedMapOfInteger& GetAllElements() const = 0;
0099 
0100   //! This method calculates normal of face, which is using for correct reflection presentation.
0101   //! There is default method, for advance reflection this method can be redefined.
0102   //! Id is the numerical identificator of only element!
0103   //! Max is maximal number of nodes an element can consist of
0104   //! nx, ny, nz  are values whose represent coordinates of normal (will be returned)
0105   //! In the redefined method you can return normal with length more then 1, but in this case
0106   //! the appearance of element will be more bright than usual. For ordinary brightness you must
0107   //! return normal with length 1
0108   Standard_EXPORT virtual bool GetNormal(const int Id,
0109                                          const int Max,
0110                                          double&   nx,
0111                                          double&   ny,
0112                                          double&   nz) const;
0113 
0114   //! This method return normal of node ranknode of face Id,
0115   //! which is using for smooth shading presentation.
0116   //! Returns false if normal isn't defined.
0117   Standard_EXPORT virtual bool GetNodeNormal(const int ranknode,
0118                                              const int ElementId,
0119                                              double&   nx,
0120                                              double&   ny,
0121                                              double&   nz) const;
0122 
0123   //! This method puts components of normal vectors at each node of a mesh face (at each face of a
0124   //! mesh volume) into the output array. Returns false if some problem was detected during
0125   //! calculation of normals. Id is an identifier of the mesh element. IsNodal, when true, means
0126   //! that normals at mesh element nodes are needed. If nodal normals are not available, or IsNodal
0127   //! is false, or the mesh element is a volume, then the output array contents depend on the
0128   //! element type: face: a normal calculated by GetNormal() is duplicated for each node of the
0129   //! face; volume: normals to all faces of the volume are computed (not for each node!). MaxNodes
0130   //! is maximal number of nodes an element can consist of. Normals contains the result.
0131   Standard_EXPORT virtual bool GetNormalsByElement(
0132     const int                                 Id,
0133     const bool                                IsNodal,
0134     const int                                 MaxNodes,
0135     occ::handle<NCollection_HArray1<double>>& Normals) const;
0136 
0137   //! This method returns map of all groups the object contains.
0138   Standard_EXPORT virtual void GetAllGroups(TColStd_PackedMapOfInteger& Ids) const;
0139 
0140   //! This method returns map of all group elements.
0141   Standard_EXPORT virtual bool GetGroup(const int                   Id,
0142                                         MeshVS_EntityType&          Type,
0143                                         TColStd_PackedMapOfInteger& Ids) const;
0144 
0145   //! This method returns pointer which represents group data structure.
0146   //! This address will be saved in MeshVS_MeshOwner, so that you can access to data structure fast
0147   //! by the method Owner(). In the redefined method you can return NULL.
0148   //! ID is the numerical identificator of group
0149   Standard_EXPORT virtual void* GetGroupAddr(const int ID) const;
0150 
0151   //! Returns True if advanced mesh selection is enabled.
0152   //! Default implementation returns False.
0153   //! It should be redefined to return True for advanced
0154   //! mesh selection activation.
0155   Standard_EXPORT virtual bool IsAdvancedSelectionEnabled() const;
0156 
0157   //! Returns the bounding box of the whole mesh.
0158   //! It is used in advanced selection mode to define roughly
0159   //! the sensitive area of the mesh.
0160   //! It can be redefined to get access to a box computed in advance.
0161   Standard_EXPORT virtual Bnd_Box GetBoundingBox() const;
0162 
0163   //! Returns maps of entities (nodes and elements) detected
0164   //! by mouse click at the point (X,Y) on the current view plane,
0165   //! with the tolerance aTol.
0166   //! DMin - is out argument should return actual detection tolerance.
0167   //! Returns True if something is detected.
0168   //! It should be redefined if the advanced mesh selection is
0169   //! activated. Default implementation returns False.
0170   Standard_EXPORT virtual bool GetDetectedEntities(
0171     const occ::handle<MeshVS_Mesh>&           Prs,
0172     const double                              X,
0173     const double                              Y,
0174     const double                              aTol,
0175     occ::handle<TColStd_HPackedMapOfInteger>& Nodes,
0176     occ::handle<TColStd_HPackedMapOfInteger>& Elements,
0177     double&                                   DMin);
0178 
0179   //! Returns maps of entities (nodes and elements) detected
0180   //! by mouse selection with rectangular box (XMin, YMin, XMax, YMax)
0181   //! on the current view plane, with the tolerance aTol.
0182   //! Returns True if something is detected.
0183   //! It should be redefined if the advanced mesh selection is
0184   //! activated. Default implementation returns False.
0185   Standard_EXPORT virtual bool GetDetectedEntities(
0186     const occ::handle<MeshVS_Mesh>&           Prs,
0187     const double                              XMin,
0188     const double                              YMin,
0189     const double                              XMax,
0190     const double                              YMax,
0191     const double                              aTol,
0192     occ::handle<TColStd_HPackedMapOfInteger>& Nodes,
0193     occ::handle<TColStd_HPackedMapOfInteger>& Elements);
0194 
0195   //! Returns maps of entities (nodes and elements) detected
0196   //! by mouse selection with the polyline <Polyline>
0197   //! on the current view plane, with the tolerance aTol.
0198   //! Returns True if something is detected.
0199   //! It should be redefined if the advanced mesh selection is
0200   //! activated. Default implementation returns False.
0201   Standard_EXPORT virtual bool GetDetectedEntities(
0202     const occ::handle<MeshVS_Mesh>&           Prs,
0203     const NCollection_Array1<gp_Pnt2d>&       Polyline,
0204     const Bnd_Box2d&                          aBox,
0205     const double                              aTol,
0206     occ::handle<TColStd_HPackedMapOfInteger>& Nodes,
0207     occ::handle<TColStd_HPackedMapOfInteger>& Elements);
0208 
0209   //! Filter out the maps of mesh entities so as to keep
0210   //! only the entities that are allowed to be selected
0211   //! according to the current context.
0212   //! Returns True if any of the maps has been changed.
0213   //! It should be redefined if the advanced mesh selection is
0214   //! activated. Default implementation returns False.
0215   Standard_EXPORT virtual bool GetDetectedEntities(
0216     const occ::handle<MeshVS_Mesh>&           Prs,
0217     occ::handle<TColStd_HPackedMapOfInteger>& Nodes,
0218     occ::handle<TColStd_HPackedMapOfInteger>& Elements);
0219 
0220   DEFINE_STANDARD_RTTIEXT(MeshVS_DataSource, Standard_Transient)
0221 };
0222 
0223 #endif // _MeshVS_DataSource_HeaderFile