0024968: Impove BRepMesh_Classifier to cope with intersection of huge number of wires
[occt.git] / src / BRepMesh / BRepMesh_WireInterferenceChecker.hxx
CommitLineData
01a6e62b 1// Created on: 2014-06-18
2// Created by: Oleg AGASHIN
3// Copyright (c) 2011-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 _BRepMesh_WireInterferenceChecker_HeaderFile
17#define _BRepMesh_WireInterferenceChecker_HeaderFile
18
19#include <Standard.hxx>
20#include <Standard_Mutex.hxx>
21#include <BRepMesh_WireChecker.hxx>
22#include <BRepMesh_Status.hxx>
23
24#ifdef HAVE_TBB
25 // paralleling using Intel TBB
26 #include <tbb/blocked_range.h>
27#endif
28
29//! Auxilary class implementing functionality for
30//! checking interference between two discretized wires.
31class BRepMesh_WireInterferenceChecker
32{
33public:
34
35 //! Enumerates states of segments intersection check.
36 enum IntFlag
37 {
38 NoIntersection,
39 Cross,
40 EndPointTouch,
41 PointOnSegment,
42 Glued,
43 Same
44 };
45
46#ifdef HAVE_TBB
47 //! Constructor
48 //! \param theWires wires that should be checked.
49 //! \param theStatus shared flag to set status of the check.
50 //! \param theMutex shared mutex for parallel processing.
51 BRepMesh_WireInterferenceChecker(
52 const std::vector<BRepMesh_WireChecker::SegmentsTree>& theWires,
53 BRepMesh_Status* theStatus,
54 Standard_Mutex* theMutex);
55
56 //! Checker's body.
57 //! \param theWireRange range of wires to be checked.
58 void operator ()(const tbb::blocked_range<Standard_Integer>& theWireRange) const;
59#else
60 //! Constructor
61 //! \param theWires wires that should be checked.
62 //! \param theStatus shared flag to set status of the check.
63 BRepMesh_WireInterferenceChecker(
64 const std::vector<BRepMesh_WireChecker::SegmentsTree>& theWires,
65 BRepMesh_Status* theStatus);
66#endif
67
68 //! Checker's body.
69 //! \param theWireId Id of discretized wire to be checked.
70 void operator ()(const Standard_Integer& theWireId) const;
71
72 //! Checks intersection between the two segments.
73 //! \param theStartPnt1 start point of first segment.
74 //! \param theEndPnt1 end point of first segment.
75 //! \param theStartPnt2 start point of second segment.
76 //! \param theEndPnt2 end point of second segment.
77 //! \param isConsiderEndPointTouch if TRUE EndPointTouch status will be
78 //! returned in case if segments are touching by end points, if FALSE
79 //! returns NoIntersection flag.
80 //! \param isConsiderPointOnSegment if TRUE PointOnSegment status will be
81 //! returned in case if end point of one segment lies onto another one,
82 //! if FALSE returns NoIntersection flag.
83 //! \param[out] theIntPnt point of intersection.
84 //! \return status of intersection check.
85 static IntFlag Intersect(const gp_XY& theStartPnt1,
86 const gp_XY& theEndPnt1,
87 const gp_XY& theStartPnt2,
88 const gp_XY& theEndPnt2,
89 const Standard_Boolean isConsiderEndPointTouch,
90 const Standard_Boolean isConsiderPointOnSegment,
91 gp_Pnt2d& theIntPnt);
92
93private:
94
95 //! Classifies the point in case of coincidence of two vectors.
96 //! \param thePoint1 the start point of a segment (base point).
97 //! \param thePoint2 the end point of a segment.
98 //! \param thePointToCheck the point to classify.
99 //! \return zero value if point is out of segment and non zero value
100 //! if point is between the first and the second point of segment.
101 static Standard_Integer classifyPoint (const gp_XY& thePoint1,
102 const gp_XY& thePoint2,
103 const gp_XY& thePointToCheck);
104private:
105 const BRepMesh_WireChecker::SegmentsTree* myWires;
106 Standard_Integer myWiresNb;
107 BRepMesh_Status* myStatus;
108
109#ifdef HAVE_TBB
110 Standard_Mutex* myMutex;
111#endif
112};
113
114#endif