Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:18:34

0001 // Created on: 1991-07-04
0002 // Created by: Christophe MARION
0003 // Copyright (c) 1991-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _DBRep_DrawableShape_HeaderFile
0018 #define _DBRep_DrawableShape_HeaderFile
0019 
0020 #include <DBRep_Edge.hxx>
0021 #include <NCollection_List.hxx>
0022 #include <DBRep_Face.hxx>
0023 #include <DBRep_HideData.hxx>
0024 #include <Draw_Color.hxx>
0025 #include <Draw_Drawable3D.hxx>
0026 #include <Draw_Interpretor.hxx>
0027 #include <NCollection_DataMap.hxx>
0028 #include <NCollection_DynamicArray.hxx>
0029 #include <Standard_OStream.hxx>
0030 #include <TopoDS_Shape.hxx>
0031 
0032 class Draw_Display;
0033 class Poly_Triangulation;
0034 class gp_Trsf;
0035 
0036 //! Drawable structure to display a shape. Contains a
0037 //! list of edges and a list of faces.
0038 class DBRep_DrawableShape : public Draw_Drawable3D
0039 {
0040   DEFINE_STANDARD_RTTIEXT(DBRep_DrawableShape, Draw_Drawable3D)
0041   Draw_Drawable3D_FACTORY
0042 public:
0043   Standard_EXPORT DBRep_DrawableShape(const TopoDS_Shape& C,
0044                                       const Draw_Color&   FreeCol,
0045                                       const Draw_Color&   ConnCol,
0046                                       const Draw_Color&   EdgeCol,
0047                                       const Draw_Color&   IsosCol,
0048                                       const double        size,
0049                                       const int           nbisos,
0050                                       const int           discret);
0051 
0052   //! Changes the number of isoparametric curves in a shape.
0053   Standard_EXPORT void ChangeNbIsos(const int NbIsos);
0054 
0055   //! Returns the number of isoparametric curves in a shape.
0056   Standard_EXPORT int NbIsos() const;
0057 
0058   //! Changes the number of isoparametric curves in a shape.
0059   Standard_EXPORT void ChangeDiscret(const int Discret);
0060 
0061   //! Returns the discretisation value of curve
0062   Standard_EXPORT int Discret() const;
0063 
0064   //! Return const &
0065   Standard_EXPORT TopoDS_Shape Shape() const;
0066 
0067   //! When True the orientations of the edges and free
0068   //! vertices are displayed.
0069   Standard_EXPORT void DisplayOrientation(const bool D);
0070 
0071   //! When True the triangulations of the faces
0072   //! are displayed even if there is a surface.
0073   Standard_EXPORT void DisplayTriangulation(const bool D);
0074 
0075   //! When True the polygons of the edges
0076   //! are displayed even if there is a geometric curve.
0077   Standard_EXPORT void DisplayPolygons(const bool D);
0078 
0079   //! Performs Hidden lines.
0080   Standard_EXPORT void DisplayHLR(const bool   withHLR,
0081                                   const bool   withRg1,
0082                                   const bool   withRgN,
0083                                   const bool   withHid,
0084                                   const double ang);
0085 
0086   Standard_EXPORT bool DisplayTriangulation() const;
0087 
0088   Standard_EXPORT bool DisplayPolygons() const;
0089 
0090   Standard_EXPORT void GetDisplayHLR(bool&   withHLR,
0091                                      bool&   withRg1,
0092                                      bool&   withRgN,
0093                                      bool&   withHid,
0094                                      double& ang) const;
0095 
0096   Standard_EXPORT void DrawOn(Draw_Display& dis) const override;
0097 
0098   Standard_EXPORT void DisplayHiddenLines(Draw_Display& dis);
0099 
0100   //! For variable copy.
0101   Standard_EXPORT occ::handle<Draw_Drawable3D> Copy() const override;
0102 
0103   //! For variable dump.
0104   Standard_EXPORT void Dump(Standard_OStream& S) const override;
0105 
0106   //! Save drawable into stream.
0107   Standard_EXPORT void Save(Standard_OStream& theStream) const override;
0108 
0109   //! For variable whatis command.
0110   Standard_EXPORT void Whatis(Draw_Interpretor& I) const override;
0111 
0112   //! Returns the subshape touched by the last pick.
0113   //! u,v are the parameters of the closest point.
0114   Standard_EXPORT static void LastPick(TopoDS_Shape& S, double& u, double& v);
0115 
0116 public:
0117   //! Auxiliary method computing nodal normals for presentation purposes.
0118   //! @param[out] theNormals  vector of computed normals (pair of points [from, to])
0119   //! @param[in] theFace      input face
0120   //! @param[in] theLength    normal length
0121   //! @return FALSE if normals can not be computed
0122   Standard_EXPORT static bool addMeshNormals(
0123     NCollection_DynamicArray<std::pair<gp_Pnt, gp_Pnt>>& theNormals,
0124     const TopoDS_Face&                                   theFace,
0125     const double                                         theLength);
0126 
0127   //! Auxiliary method computing nodal normals for presentation purposes.
0128   //! @param[out] theNormals  map of computed normals (grouped per Face)
0129   //! @param[in] theShape     input shape which will be exploded into Faces
0130   //! @param[in] theLength    normal length
0131   Standard_EXPORT static void addMeshNormals(
0132     NCollection_DataMap<TopoDS_Face, NCollection_DynamicArray<std::pair<gp_Pnt, gp_Pnt>>>&
0133                         theNormals,
0134     const TopoDS_Shape& theShape,
0135     const double        theLength);
0136 
0137   //! Auxiliary method computing surface normals distributed within the Face for presentation
0138   //! purposes.
0139   //! @param[out] theNormals   vector of computed normals (pair of points [from, to])
0140   //! @param[in] theFace       input face
0141   //! @param[in] theLength     normal length
0142   //! @param[in] theNbAlongU   number along U
0143   //! @param[in] theNbAlongV   number along V
0144   //! @return FALSE if normals can not be computed
0145   Standard_EXPORT static bool addSurfaceNormals(
0146     NCollection_DynamicArray<std::pair<gp_Pnt, gp_Pnt>>& theNormals,
0147     const TopoDS_Face&                                   theFace,
0148     const double                                         theLength,
0149     const int                                            theNbAlongU,
0150     const int                                            theNbAlongV);
0151 
0152   //! Auxiliary method computing surface normals distributed within the Face for presentation
0153   //! purposes.
0154   //! @param[out] theNormals   map of computed normals (grouped per Face)
0155   //! @param[in] theShape      input shape which will be exploded into Faces
0156   //! @param[in] theLength     normal length
0157   //! @param[in] theNbAlongU   number along U
0158   //! @param[in] theNbAlongV   number along V
0159   //! @return FALSE if normals can not be computed
0160   Standard_EXPORT static void addSurfaceNormals(
0161     NCollection_DataMap<TopoDS_Face, NCollection_DynamicArray<std::pair<gp_Pnt, gp_Pnt>>>&
0162                         theNormals,
0163     const TopoDS_Shape& theShape,
0164     const double        theLength,
0165     const int           theNbAlongU,
0166     const int           theNbAlongV);
0167 
0168 private:
0169   void display(const occ::handle<Poly_Triangulation>& T,
0170                const gp_Trsf&                         tr,
0171                Draw_Display&                          dis) const;
0172 
0173   //! Updates internal data necessary for display
0174   void updateDisplayData() const;
0175 
0176 private:
0177   TopoDS_Shape myShape;
0178 
0179   mutable NCollection_List<occ::handle<DBRep_Edge>> myEdges;
0180   mutable NCollection_List<occ::handle<DBRep_Face>> myFaces;
0181   NCollection_List<DBRep_HideData>                  myHidData;
0182 
0183   double     mySize;
0184   int        myDiscret;
0185   Draw_Color myFreeCol;
0186   Draw_Color myConnCol;
0187   Draw_Color myEdgeCol;
0188   Draw_Color myIsosCol;
0189   int        myNbIsos;
0190   bool       myDispOr;
0191   bool       mytriangulations;
0192   bool       mypolygons;
0193   bool       myHLR;
0194   bool       myRg1;
0195   bool       myRgN;
0196   bool       myHid;
0197   double     myAng;
0198 };
0199 
0200 #endif // _DBRep_DrawableShape_HeaderFile