0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[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
f5b72419 19#include <BVH_PrimitiveSet3d.hxx>
78aade75 20#include <TColgp_Array1OfPnt.hxx>
21#include <TColStd_DataMapOfIntegerInteger.hxx>
22#include <TopoDS_Edge.hxx>
23#include <TopoDS_Face.hxx>
558e68ea 24
25//! List of shapes and their IDs for collision detection.
78aade75 26typedef NCollection_Vector<TopoDS_Shape> BRepExtrema_ShapeList;
558e68ea 27
28//! Triangle set corresponding to specific face.
f5b72419 29class BRepExtrema_TriangleSet : public BVH_PrimitiveSet3d
558e68ea 30{
31public:
32
33 //! Creates empty triangle set.
34 Standard_EXPORT BRepExtrema_TriangleSet();
35
36 //! Creates triangle set from the given face.
37 Standard_EXPORT BRepExtrema_TriangleSet (const BRepExtrema_ShapeList& theFaces);
38
39 //! Releases resources of triangle set.
40 Standard_EXPORT ~BRepExtrema_TriangleSet();
41
42public: //! @name methods implementing BVH set interface
43
44 //! Returns total number of triangles.
b09d8636 45 Standard_EXPORT Standard_Integer Size() const Standard_OVERRIDE;
558e68ea 46
47 //! Returns AABB of the given triangle.
b09d8636 48 Standard_EXPORT BVH_Box<Standard_Real, 3> Box (const Standard_Integer theIndex) const Standard_OVERRIDE;
558e68ea 49
201c2208 50 //! Make inherited method Box() visible to avoid CLang warning
f5b72419 51 using BVH_PrimitiveSet3d::Box;
201c2208 52
558e68ea 53 //! Returns centroid position along specified axis.
b09d8636 54 Standard_EXPORT Standard_Real Center (const Standard_Integer theIndex, const Standard_Integer theAxis) const Standard_OVERRIDE;
558e68ea 55
56 //! Swaps indices of two specified triangles.
b09d8636 57 Standard_EXPORT void Swap (const Standard_Integer theIndex1, const Standard_Integer theIndex2) Standard_OVERRIDE;
558e68ea 58
59public:
60
61 //! Clears triangle set data.
62 Standard_EXPORT void Clear();
63
64 //! Initializes triangle set.
78aade75 65 Standard_EXPORT Standard_Boolean Init (const BRepExtrema_ShapeList& theShapes);
66
67 //! Returns all vertices.
68 Standard_EXPORT const BVH_Array3d& GetVertices() const { return myVertexArray; }
558e68ea 69
70 //! Returns vertices of the given triangle.
71 Standard_EXPORT void GetVertices (const Standard_Integer theIndex,
72 BVH_Vec3d& theVertex1,
73 BVH_Vec3d& theVertex2,
74 BVH_Vec3d& theVertex3) const;
75
78aade75 76 //! Returns vertex indices of the given triangle.
77 Standard_EXPORT void GetVtxIndices (const Standard_Integer theIndex,
78 NCollection_Array1<Standard_Integer>& theVtxIndices) const;
79
558e68ea 80 //! Returns face ID of the given triangle.
81 Standard_EXPORT Standard_Integer GetFaceID (const Standard_Integer theIndex) const;
82
78aade75 83 //! Returns shape ID of the given vertex index.
84 Standard_EXPORT Standard_Integer GetShapeIDOfVtx (const Standard_Integer theIndex) const;
85
86 //! Returns vertex index in tringulation of the shape, which vertex belongs,
87 //! with the given vtx ID in whole set.
88 Standard_EXPORT Standard_Integer GetVtxIdxInShape (const Standard_Integer theIndex) const;
89
90 //! Returns triangle index (before swapping) in tringulation of the shape, which triangle belongs,
91 //! with the given trg ID in whole set (after swapping).
92 Standard_EXPORT Standard_Integer GetTrgIdxInShape (const Standard_Integer theIndex) const;
93
94private:
95
96 //! Initializes triangle set from the face
97 Standard_Boolean initFace (const TopoDS_Face& theFace, const Standard_Integer theIndex);
98
99 //! Initializes polygon from the edge
100 Standard_Boolean initEdge (const TopoDS_Edge& theEdge, const Standard_Integer theIndex);
101
102 //! Initializes nodes
103 void initNodes (const TColgp_Array1OfPnt& theNodes,
104 const gp_Trsf& theTrsf,
105 const Standard_Integer theIndex);
106
558e68ea 107protected:
108
109 //! Array of vertex indices.
110 BVH_Array4i myTriangles;
111
558e68ea 112 //! Array of vertex coordinates.
113 BVH_Array3d myVertexArray;
114
78aade75 115 //! Vector of shapes' indices where index of item corresponds to index of vertex,
116 //! belonging to this shape.
117 NCollection_Vector<Standard_Integer> myShapeIdxOfVtxVec;
118
119 //! Vector of vertexes' number belonging to shape which index corresponds item's index.
120 NCollection_Vector<Standard_Integer> myNumVtxInShapeVec;
121
122 //! Vector of triangles' number belonging to shape which index corresponds item's index.
123 NCollection_Vector<Standard_Integer> myNumTrgInShapeVec;
124
125 //! Map of triangles' indices after (key) and before (value) swapping.
126 TColStd_DataMapOfIntegerInteger myTrgIdxMap;
127
ae9a414a 128public:
129
f5b72419 130 DEFINE_STANDARD_RTTIEXT(BRepExtrema_TriangleSet, BVH_PrimitiveSet3d)
ae9a414a 131
558e68ea 132};
133
f5b72419 134DEFINE_STANDARD_HANDLE(BRepExtrema_TriangleSet, BVH_PrimitiveSet3d)
ae9a414a 135
558e68ea 136#endif // _BRepExtrema_TriangleSet_HeaderFile