0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / BRepExtrema / BRepExtrema_OverlapTool.hxx
CommitLineData
ae9a414a 1// Created on: 2015-04-26
2// Created by: Denis BOGOLEPOV
3// Copyright (c) 2015 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_OverlapTool_HeaderFile
17#define _BRepExtrema_OverlapTool_HeaderFile
18
19#include <BVH_Geometry.hxx>
20#include <BRepExtrema_TriangleSet.hxx>
21#include <BRepExtrema_ElementFilter.hxx>
22#include <BRepExtrema_MapOfIntegerPackedMapOfInteger.hxx>
23
24//! Enables storing of individual overlapped triangles (useful for debug).
25// #define OVERLAP_TOOL_OUTPUT_TRIANGLES
26
27//! Tool class for for detection of overlapping of two BVH primitive sets.
28//! This tool is not intended to be used independently, and is integrated
29//! in other classes, implementing algorithms based on shape tessellation
30//! (BRepExtrema_ShapeProximity and BRepExtrema_SelfIntersection).
31//!
32//! Note that input element sets may correspond to different shapes or to
33//! the same shape. In first case, tessellations of two given shapes will
34//! be tested for intersection (or overlapping, if tolerance is not zero).
35//! In second case, tessellation of single shape will be tested for self-
36//! intersections. Please note that algorithm results are approximate and
37//! depend greatly on the quality of input tessellation(s).
38class BRepExtrema_OverlapTool
39{
40public:
41
42 //! Creates new unitialized overlap tool.
43 BRepExtrema_OverlapTool();
44
45 //! Creates new overlap tool for the given element sets.
46 BRepExtrema_OverlapTool (const Handle(BRepExtrema_TriangleSet)& theSet1,
47 const Handle(BRepExtrema_TriangleSet)& theSet2);
48
49public:
50
51 //! Loads the given element sets into the overlap tool.
52 void LoadTriangleSets (const Handle(BRepExtrema_TriangleSet)& theSet1,
53 const Handle(BRepExtrema_TriangleSet)& theSet2);
54
55 //! Performs searching of overlapped mesh elements.
56 void Perform (const Standard_Real theTolerance = 0.0);
57
58 //! Is overlap test completed?
59 Standard_Boolean IsDone() const { return myIsDone; }
60
61 //! Marks test results as outdated.
62 void MarkDirty() { myIsDone = Standard_False; }
63
64 //! Returns set of overlapped sub-shapes of 1st shape (currently only faces are detected).
65 const BRepExtrema_MapOfIntegerPackedMapOfInteger& OverlapSubShapes1() const { return myOverlapSubShapes1; }
66
67 //! Returns set of overlapped sub-shapes of 2nd shape (currently only faces are detected).
68 const BRepExtrema_MapOfIntegerPackedMapOfInteger& OverlapSubShapes2() const { return myOverlapSubShapes2; }
69
70#ifdef OVERLAP_TOOL_OUTPUT_TRIANGLES
71 //! Returns set of overlapped triangles from the 1st shape (for debug).
72 const TColStd_PackedMapOfInteger& OverlapTriangles1() const { return myOverlapTriangles1; }
73
74 //! Returns set of overlapped triangles from the 2nd shape (for debug).
75 const TColStd_PackedMapOfInteger& OverlapTriangles2() const { return myOverlapTriangles2; }
76#endif
77
78 //! Sets filtering tool for preliminary checking pairs of mesh elements.
79 void SetElementFilter (BRepExtrema_ElementFilter* theFilter) { myFilter = theFilter; }
80
81protected:
82
83 //! Performs narrow-phase of overlap test (exact intersection).
84 void intersectTriangleRangesExact (const BVH_Vec4i& theLeaf1,
85 const BVH_Vec4i& theLeaf2);
86
87 //! Performs narrow-phase of overlap test (intersection with non-zero tolerance).
88 void intersectTriangleRangesToler (const BVH_Vec4i& theLeaf1,
89 const BVH_Vec4i& theLeaf2,
90 const Standard_Real theToler);
91
92private:
93
94 //! Set of all mesh elements (triangles) of the 1st shape.
95 Handle(BRepExtrema_TriangleSet) mySet1;
96 //! Set of all mesh elements (triangles) of the 2nd shape.
97 Handle(BRepExtrema_TriangleSet) mySet2;
98
99 //! Filter for preliminary checking pairs of mesh elements.
100 BRepExtrema_ElementFilter* myFilter;
101
102 //! Resulted set of overlapped sub-shapes of 1st shape (only faces).
103 BRepExtrema_MapOfIntegerPackedMapOfInteger myOverlapSubShapes1;
104 //! Resulted set of overlapped sub-shapes of 2nd shape (only faces).
105 BRepExtrema_MapOfIntegerPackedMapOfInteger myOverlapSubShapes2;
106
107#ifdef OVERLAP_TOOL_OUTPUT_TRIANGLES
108 //! Set of overlapped elements from the 1st shape (only triangles).
109 TColStd_PackedMapOfInteger myOverlapTriangles1;
110 //! Set of overlapped elements from the 2nd shape (only triangles).
111 TColStd_PackedMapOfInteger myOverlapTriangles2;
112#endif
113
114 //! Is overlap test test completed?
115 Standard_Boolean myIsDone;
116};
117
118#endif // _BRepExtrema_OverlapTool_HeaderFile