0028789: Visualization, TKV3d - extend API for accessing and assigning BVH builders
[occt.git] / src / BRepExtrema / BRepExtrema_TriangleSet.hxx
CommitLineData
558e68ea 1// Created on: 2014-10-20
2// Created by: Denis BOGOLEPOV
3// Copyright (c) 2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _BRepExtrema_TriangleSet_HeaderFile
17#define _BRepExtrema_TriangleSet_HeaderFile
18
19#include <TopoDS_Face.hxx>
f5b72419 20#include <BVH_PrimitiveSet3d.hxx>
558e68ea 21
22//! List of shapes and their IDs for collision detection.
23typedef NCollection_Vector<TopoDS_Face> BRepExtrema_ShapeList;
24
25//! Triangle set corresponding to specific face.
f5b72419 26class BRepExtrema_TriangleSet : public BVH_PrimitiveSet3d
558e68ea 27{
28public:
29
30 //! Creates empty triangle set.
31 Standard_EXPORT BRepExtrema_TriangleSet();
32
33 //! Creates triangle set from the given face.
34 Standard_EXPORT BRepExtrema_TriangleSet (const BRepExtrema_ShapeList& theFaces);
35
36 //! Releases resources of triangle set.
37 Standard_EXPORT ~BRepExtrema_TriangleSet();
38
39public: //! @name methods implementing BVH set interface
40
41 //! Returns total number of triangles.
79104795 42 Standard_Integer Size() const Standard_OVERRIDE;
558e68ea 43
44 //! Returns AABB of the given triangle.
79104795 45 BVH_Box<Standard_Real, 3> Box (const Standard_Integer theIndex) const Standard_OVERRIDE;
558e68ea 46
201c2208 47 //! Make inherited method Box() visible to avoid CLang warning
f5b72419 48 using BVH_PrimitiveSet3d::Box;
201c2208 49
558e68ea 50 //! Returns centroid position along specified axis.
79104795 51 Standard_Real Center (const Standard_Integer theIndex, const Standard_Integer theAxis) const Standard_OVERRIDE;
558e68ea 52
53 //! Swaps indices of two specified triangles.
79104795 54 void Swap (const Standard_Integer theIndex1, const Standard_Integer theIndex2) Standard_OVERRIDE;
558e68ea 55
56public:
57
58 //! Clears triangle set data.
59 Standard_EXPORT void Clear();
60
61 //! Initializes triangle set.
62 Standard_EXPORT Standard_Boolean Init (const BRepExtrema_ShapeList& theFaces);
63
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;
69
70 //! Returns face ID of the given triangle.
71 Standard_EXPORT Standard_Integer GetFaceID (const Standard_Integer theIndex) const;
72
73protected:
74
75 //! Array of vertex indices.
76 BVH_Array4i myTriangles;
77
78 //! Array of vertex UV params.
79 BVH_Array2d myVertUVArray;
80
81 //! Array of vertex coordinates.
82 BVH_Array3d myVertexArray;
83
ae9a414a 84public:
85
f5b72419 86 DEFINE_STANDARD_RTTIEXT(BRepExtrema_TriangleSet, BVH_PrimitiveSet3d)
ae9a414a 87
558e68ea 88};
89
f5b72419 90DEFINE_STANDARD_HANDLE(BRepExtrema_TriangleSet, BVH_PrimitiveSet3d)
ae9a414a 91
558e68ea 92#endif // _BRepExtrema_TriangleSet_HeaderFile