0025398: Modeling Algorithms - Provide shape proximity detector
[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>
20
21#include <BVH_PrimitiveSet.hxx>
22
23//! List of shapes and their IDs for collision detection.
24typedef NCollection_Vector<TopoDS_Face> BRepExtrema_ShapeList;
25
26//! Triangle set corresponding to specific face.
27class BRepExtrema_TriangleSet : public BVH_PrimitiveSet<Standard_Real, 3>
28{
29public:
30
31 //! Creates empty triangle set.
32 Standard_EXPORT BRepExtrema_TriangleSet();
33
34 //! Creates triangle set from the given face.
35 Standard_EXPORT BRepExtrema_TriangleSet (const BRepExtrema_ShapeList& theFaces);
36
37 //! Releases resources of triangle set.
38 Standard_EXPORT ~BRepExtrema_TriangleSet();
39
40public: //! @name methods implementing BVH set interface
41
42 //! Returns total number of triangles.
43 Standard_Integer Size() const;
44
45 //! Returns AABB of the given triangle.
46 BVH_Box<Standard_Real, 3> Box (const Standard_Integer theIndex) const;
47
48 //! Returns centroid position along specified axis.
49 Standard_Real Center (const Standard_Integer theIndex, const Standard_Integer theAxis) const;
50
51 //! Swaps indices of two specified triangles.
52 void Swap (const Standard_Integer theIndex1, const Standard_Integer theIndex2);
53
54public:
55
56 //! Clears triangle set data.
57 Standard_EXPORT void Clear();
58
59 //! Initializes triangle set.
60 Standard_EXPORT Standard_Boolean Init (const BRepExtrema_ShapeList& theFaces);
61
62 //! Returns vertices of the given triangle.
63 Standard_EXPORT void GetVertices (const Standard_Integer theIndex,
64 BVH_Vec3d& theVertex1,
65 BVH_Vec3d& theVertex2,
66 BVH_Vec3d& theVertex3) const;
67
68 //! Returns face ID of the given triangle.
69 Standard_EXPORT Standard_Integer GetFaceID (const Standard_Integer theIndex) const;
70
71protected:
72
73 //! Array of vertex indices.
74 BVH_Array4i myTriangles;
75
76 //! Array of vertex UV params.
77 BVH_Array2d myVertUVArray;
78
79 //! Array of vertex coordinates.
80 BVH_Array3d myVertexArray;
81
82};
83
84#endif // _BRepExtrema_TriangleSet_HeaderFile