1 // Copyright (c) 2013 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _StdPrs_ToolTriangulatedShape_HeaderFile
15 #define _StdPrs_ToolTriangulatedShape_HeaderFile
17 #include <Poly_Connect.hxx>
18 #include <Poly_Triangulation.hxx>
19 #include <Prs3d_Drawer.hxx>
20 #include <Standard.hxx>
21 #include <Standard_Macro.hxx>
22 #include <TColgp_Array1OfDir.hxx>
25 class TopLoc_Location;
28 class Poly_Triangulation;
31 class StdPrs_ToolTriangulatedShape
35 //! Similar to BRepTools::Triangulation() but without extra checks.
36 //! @return true if all faces within shape are triangulated.
37 Standard_EXPORT static Standard_Boolean IsTriangulated (const TopoDS_Shape& theShape);
39 //! Checks back faces visibility for specified shape (to activate back-face culling). <br>
40 //! @return true if shape is closed manifold Solid or compound of such Solids. <br>
41 Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Shape& theShape);
43 //! Computes nodal normals for Poly_Triangulation structure using UV coordinates and surface.
44 //! Does nothing if triangulation already defines normals.
45 //! @param theFace [in] the face
46 //! @param theTris [in] the definition of a face triangulation
47 static void ComputeNormals (const TopoDS_Face& theFace,
48 const Handle(Poly_Triangulation)& theTris)
50 Poly_Connect aPolyConnect;
51 ComputeNormals (theFace, theTris, aPolyConnect);
54 //! Computes nodal normals for Poly_Triangulation structure using UV coordinates and surface.
55 //! Does nothing if triangulation already defines normals.
56 //! @param theFace [in] the face
57 //! @param theTris [in] the definition of a face triangulation
58 //! @param thePolyConnect [in,out] optional, initialized tool for exploring triangulation
59 Standard_EXPORT static void ComputeNormals (const TopoDS_Face& theFace,
60 const Handle(Poly_Triangulation)& theTris,
61 Poly_Connect& thePolyConnect);
63 //! Evaluate normals for a triangle of a face.
64 //! @param theFace [in] the face.
65 //! @param thePolyConnect [in] the definition of a face triangulation.
66 //! @param theNormal [out] the array of normals for each triangle.
67 Standard_EXPORT static void Normal (const TopoDS_Face& theFace,
68 Poly_Connect& thePolyConnect,
69 TColgp_Array1OfDir& theNormals);
71 //! Checks whether the shape is properly triangulated for a given display settings.
72 //! @param theShape [in] the shape.
73 //! @param theDrawer [in] the display settings.
74 Standard_EXPORT static Standard_Boolean IsTessellated (const TopoDS_Shape& theShape,
75 const Handle(Prs3d_Drawer)& theDrawer);
77 //! Validates triangulation within the shape and performs tessellation if necessary.
78 //! @param theShape [in] the shape.
79 //! @param theDrawer [in] the display settings.
80 //! @return true if tesselation was recomputed and false otherwise.
81 Standard_EXPORT static Standard_Boolean Tessellate (const TopoDS_Shape& theShape,
82 const Handle(Prs3d_Drawer)& theDrawer);
84 //! If presentation has own deviation coefficient and IsAutoTriangulation() is true,
85 //! function will compare actual coefficients with previous values and will clear triangulation on their change
86 //! (regardless actual tessellation quality).
87 //! Function is placed here for compatibility reasons - new code should avoid using IsAutoTriangulation().
88 //! @param theShape [in] the shape
89 //! @param theDrawer [in] the display settings
90 //! @param theToResetCoeff [in] updates coefficients in theDrawer to actual state to avoid redundant recomputations
91 Standard_EXPORT static void ClearOnOwnDeflectionChange (const TopoDS_Shape& theShape,
92 const Handle(Prs3d_Drawer)& theDrawer,
93 const Standard_Boolean theToResetCoeff);