| 1 | // Copyright (c) 2013 OPEN CASCADE SAS |
| 2 | // |
| 3 | // This file is part of Open CASCADE Technology software library. |
| 4 | // |
| 5 | // This library is free software; you can redistribute it and/or modify it under |
| 6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
| 7 | // by the Free Software Foundation, with special exception defined in the file |
| 8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
| 9 | // distribution for complete text of the license and disclaimer of any warranty. |
| 10 | // |
| 11 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 12 | // commercial license or contractual agreement. |
| 13 | |
| 14 | #ifndef _StdPrs_ToolTriangulatedShape_HeaderFile |
| 15 | #define _StdPrs_ToolTriangulatedShape_HeaderFile |
| 16 | |
| 17 | #include <Poly_Triangulation.hxx> |
| 18 | #include <Prs3d_Drawer.hxx> |
| 19 | #include <Standard.hxx> |
| 20 | #include <Standard_Macro.hxx> |
| 21 | #include <TColgp_Array1OfDir.hxx> |
| 22 | |
| 23 | class TopoDS_Face; |
| 24 | class TopLoc_Location; |
| 25 | class TopoDS_Shape; |
| 26 | class Prs3d_Drawer; |
| 27 | class Poly_Triangulation; |
| 28 | class Poly_Connect; |
| 29 | |
| 30 | class StdPrs_ToolTriangulatedShape |
| 31 | { |
| 32 | public: |
| 33 | |
| 34 | //! Similar to BRepTools::Triangulation() but without extra checks. |
| 35 | //! @return true if all faces within shape are triangulated. |
| 36 | Standard_EXPORT static Standard_Boolean IsTriangulated (const TopoDS_Shape& theShape); |
| 37 | |
| 38 | //! Checks back faces visibility for specified shape (to activate back-face culling). <br> |
| 39 | //! @return true if shape is closed manifold Solid or compound of such Solids. <br> |
| 40 | Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Shape& theShape); |
| 41 | |
| 42 | //! Evaluate normals for a triangle of a face. |
| 43 | //! @param theFace [in] the face. |
| 44 | //! @param thePolyConnect [in] the definition of a face triangulation. |
| 45 | //! @param theNormal [out] the array of normals for each triangle. |
| 46 | Standard_EXPORT static void Normal (const TopoDS_Face& theFace, |
| 47 | Poly_Connect& thePolyConnect, |
| 48 | TColgp_Array1OfDir& theNormals); |
| 49 | |
| 50 | //! Checks whether the shape is properly triangulated for a given display settings. |
| 51 | //! @param theShape [in] the shape. |
| 52 | //! @param theDrawer [in] the display settings. |
| 53 | Standard_EXPORT static Standard_Boolean IsTessellated (const TopoDS_Shape& theShape, |
| 54 | const Handle(Prs3d_Drawer)& theDrawer); |
| 55 | |
| 56 | //! Validates triangulation within the shape and performs tessellation if necessary. |
| 57 | //! @param theShape [in] the shape. |
| 58 | //! @param theDrawer [in] the display settings. |
| 59 | //! @return true if tesselation was recomputed and false otherwise. |
| 60 | Standard_EXPORT static Standard_Boolean Tessellate (const TopoDS_Shape& theShape, |
| 61 | const Handle(Prs3d_Drawer)& theDrawer); |
| 62 | |
| 63 | //! If presentation has own deviation coefficient and IsAutoTriangulation() is true, |
| 64 | //! function will compare actual coefficients with previous values and will clear triangulation on their change |
| 65 | //! (regardless actual tessellation quality). |
| 66 | //! Function is placed here for compatibility reasons - new code should avoid using IsAutoTriangulation(). |
| 67 | //! @param theShape [in] the shape |
| 68 | //! @param theDrawer [in] the display settings |
| 69 | //! @param theToResetCoeff [in] updates coefficients in theDrawer to actual state to avoid redundant recomputations |
| 70 | Standard_EXPORT static void ClearOnOwnDeflectionChange (const TopoDS_Shape& theShape, |
| 71 | const Handle(Prs3d_Drawer)& theDrawer, |
| 72 | const Standard_Boolean theToResetCoeff); |
| 73 | |
| 74 | }; |
| 75 | |
| 76 | #endif |