1 // Created on: 2014-10-20
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _BRepExtrema_TriangleSet_HeaderFile
17 #define _BRepExtrema_TriangleSet_HeaderFile
19 #include <TopoDS_Face.hxx>
20 #include <BVH_PrimitiveSet3d.hxx>
22 //! List of shapes and their IDs for collision detection.
23 typedef NCollection_Vector<TopoDS_Face> BRepExtrema_ShapeList;
25 //! Triangle set corresponding to specific face.
26 class BRepExtrema_TriangleSet : public BVH_PrimitiveSet3d
30 //! Creates empty triangle set.
31 Standard_EXPORT BRepExtrema_TriangleSet();
33 //! Creates triangle set from the given face.
34 Standard_EXPORT BRepExtrema_TriangleSet (const BRepExtrema_ShapeList& theFaces);
36 //! Releases resources of triangle set.
37 Standard_EXPORT ~BRepExtrema_TriangleSet();
39 public: //! @name methods implementing BVH set interface
41 //! Returns total number of triangles.
42 Standard_EXPORT Standard_Integer Size() const Standard_OVERRIDE;
44 //! Returns AABB of the given triangle.
45 Standard_EXPORT BVH_Box<Standard_Real, 3> Box (const Standard_Integer theIndex) const Standard_OVERRIDE;
47 //! Make inherited method Box() visible to avoid CLang warning
48 using BVH_PrimitiveSet3d::Box;
50 //! Returns centroid position along specified axis.
51 Standard_EXPORT Standard_Real Center (const Standard_Integer theIndex, const Standard_Integer theAxis) const Standard_OVERRIDE;
53 //! Swaps indices of two specified triangles.
54 Standard_EXPORT void Swap (const Standard_Integer theIndex1, const Standard_Integer theIndex2) Standard_OVERRIDE;
58 //! Clears triangle set data.
59 Standard_EXPORT void Clear();
61 //! Initializes triangle set.
62 Standard_EXPORT Standard_Boolean Init (const BRepExtrema_ShapeList& theFaces);
64 //! Returns vertices of the given triangle.
65 Standard_EXPORT void GetVertices (const Standard_Integer theIndex,
66 BVH_Vec3d& theVertex1,
67 BVH_Vec3d& theVertex2,
68 BVH_Vec3d& theVertex3) const;
70 //! Returns face ID of the given triangle.
71 Standard_EXPORT Standard_Integer GetFaceID (const Standard_Integer theIndex) const;
75 //! Array of vertex indices.
76 BVH_Array4i myTriangles;
78 //! Array of vertex UV params.
79 BVH_Array2d myVertUVArray;
81 //! Array of vertex coordinates.
82 BVH_Array3d myVertexArray;
86 DEFINE_STANDARD_RTTIEXT(BRepExtrema_TriangleSet, BVH_PrimitiveSet3d)
90 DEFINE_STANDARD_HANDLE(BRepExtrema_TriangleSet, BVH_PrimitiveSet3d)
92 #endif // _BRepExtrema_TriangleSet_HeaderFile