Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-24 10:31:03

0001 // Created on: 2004-06-10
0002 // Created by: Alexander SOLOVYOV
0003 // Copyright (c) 2004-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 _XSDRAWSTL_DataSource_HeaderFile
0017 #define _XSDRAWSTL_DataSource_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 
0021 #include <Standard_Integer.hxx>
0022 #include <NCollection_Array2.hxx>
0023 #include <NCollection_HArray2.hxx>
0024 #include <MeshVS_DataSource.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <MeshVS_EntityType.hxx>
0027 #include <Poly_Triangulation.hxx>
0028 
0029 //! The sample DataSource for working with STLMesh_Mesh
0030 class XSDRAWSTL_DataSource : public MeshVS_DataSource
0031 {
0032 
0033 public:
0034   //! Constructor
0035   Standard_EXPORT XSDRAWSTL_DataSource(const occ::handle<Poly_Triangulation>& aMesh);
0036 
0037   //! Returns geometry information about node (if IsElement is False) or element (IsElement is True)
0038   //! by coordinates. For element this method must return all its nodes coordinates in the strict
0039   //! order: X, Y, Z and with nodes order is the same as in wire bounding the face or link. NbNodes
0040   //! is number of nodes of element. It is recommended to return 1 for node. Type is an element
0041   //! type.
0042   Standard_EXPORT bool GetGeom(const int                   ID,
0043                                const bool                  IsElement,
0044                                NCollection_Array1<double>& Coords,
0045                                int&                        NbNodes,
0046                                MeshVS_EntityType&          Type) const override;
0047 
0048   //! This method is similar to GetGeom, but returns only element or node type. This method is
0049   //! provided for a fine performance.
0050   Standard_EXPORT bool GetGeomType(const int          ID,
0051                                    const bool         IsElement,
0052                                    MeshVS_EntityType& Type) const override;
0053 
0054   //! This method returns by number an address of any entity which represents element or node data
0055   //! structure.
0056   Standard_EXPORT void* GetAddr(const int ID, const bool IsElement) const override;
0057 
0058   //! This method returns information about what node this element consist of.
0059   Standard_EXPORT bool GetNodesByElement(const int                ID,
0060                                          NCollection_Array1<int>& NodeIDs,
0061                                          int&                     NbNodes) const override;
0062 
0063   //! This method returns map of all nodes the object consist of.
0064   Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllNodes() const override;
0065 
0066   //! This method returns map of all elements the object consist of.
0067   Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllElements() const override;
0068 
0069   //! This method calculates normal of face, which is using for correct reflection presentation.
0070   //! There is default method, for advance reflection this method can be redefined.
0071   Standard_EXPORT bool GetNormal(const int Id,
0072                                  const int Max,
0073                                  double&   nx,
0074                                  double&   ny,
0075                                  double&   nz) const override;
0076 
0077   DEFINE_STANDARD_RTTIEXT(XSDRAWSTL_DataSource, MeshVS_DataSource)
0078 
0079 private:
0080   occ::handle<Poly_Triangulation>          myMesh;
0081   TColStd_PackedMapOfInteger               myNodes;
0082   TColStd_PackedMapOfInteger               myElements;
0083   occ::handle<NCollection_HArray2<int>>    myElemNodes;
0084   occ::handle<NCollection_HArray2<double>> myNodeCoords;
0085   occ::handle<NCollection_HArray2<double>> myElemNormals;
0086 };
0087 
0088 #endif // _XSDRAWSTL_DataSource_HeaderFile