1 // Created on: 1993-07-06
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 #ifndef _BRepMAT2d_BisectingLocus_HeaderFile
18 #define _BRepMAT2d_BisectingLocus_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23 
24 #include <MAT2d_Tool2d.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <MAT2d_DataMapOfBiIntInteger.hxx>
27 #include <Standard_Integer.hxx>
28 #include <MAT_Side.hxx>
29 #include <GeomAbs_JoinType.hxx>
30 #include <MAT_DataMapOfIntegerBasicElt.hxx>
31 class MAT_Graph;
32 class BRepMAT2d_Explorer;
33 class MAT_BasicElt;
34 class Geom2d_Geometry;
35 class gp_Pnt2d;
36 class MAT_Node;
37 class Bisector_Bisec;
38 class MAT_Arc;
39 
40 
41 //! BisectingLocus generates and contains the Bisecting_Locus
42 //! of a set of lines from Geom2d, defined by <ExploSet>.
43 //!
44 //! If the set of lines contains closed lines:
45 //! ------------------------------------------
46 //! These lines cut the plane  in areas.
47 //! One map can  be  computed for each area.
48 //!
49 //! Bisecting locus computes a map in an area.
50 //! The area is defined by a side (MAT_Left,MAT_Right)
51 //! on one of the closed lines.
52 //!
53 //! If the set of lines contains only open lines:
54 //! --------------------------------------------
55 //! the map recovers all the plane.
56 //!
57 //! Warning: Assume the orientation of the   closed  lines  are
58 //! compatible.
59 //!
60 //! Assume the explo contains only lines located in the
61 //! area where the bisecting locus will be computed.
62 //!
63 //! Assume a line don't cross itself or an other line.
64 //!
65 //! Remark:
66 //! the  curves  coming   from   the  explorer can   be
67 //! decomposed in different parts. It  the  case for the
68 //! curves other than circles or lines.
69 //!
70 //! The map of bisecting  locus is described by a graph.
71 //! - The  BasicsElements  correspond  to elements on
72 //! the figure described by the Explorer from BRepMAT2d.
73 //! - The Arcs correspond to the bisectors.
74 //! - The Nodes are the extremities of the arcs.
75 class BRepMAT2d_BisectingLocus
76 {
77 public:
78 
79   DEFINE_STANDARD_ALLOC
80 
81 
82   Standard_EXPORT BRepMAT2d_BisectingLocus();
83 
84   //! Computation of the Bisector_Locus in a set of Lines
85   //! defined in <anExplo>.
86   //! The bisecting locus are computed on the side <aSide>
87   //! from the line <LineIndex> in <anExplo>.
88   Standard_EXPORT void Compute (BRepMAT2d_Explorer& anExplo, const Standard_Integer LineIndex = 1, const MAT_Side aSide = MAT_Left, const GeomAbs_JoinType aJoinType = GeomAbs_Arc, const Standard_Boolean IsOpenResult = Standard_False);
89 
90   //! Returns True if Compute has succeeded.
91   Standard_EXPORT Standard_Boolean IsDone() const;
92 
93   //! Returns <theGraph> of <me>.
94   Standard_EXPORT Handle(MAT_Graph) Graph() const;
95 
96   //! Returns the number of contours.
97   Standard_EXPORT Standard_Integer NumberOfContours() const;
98 
99   //! Returns the number of BasicElts on the line
100   //! <IndLine>.
101   Standard_EXPORT Standard_Integer NumberOfElts (const Standard_Integer IndLine) const;
102 
103   //! Returns the number of sections of a curve.
104   //! this curve is the Indexth curve in the IndLineth contour
105   //! given by anExplo.
106   Standard_EXPORT Standard_Integer NumberOfSections (const Standard_Integer IndLine, const Standard_Integer Index) const;
107 
108   //! Returns the BasicElts located at the position
109   //! <Index> on the contour designed by <IndLine>.
110   //! Remark: the BasicElts on a contour are sorted.
111   Standard_EXPORT Handle(MAT_BasicElt) BasicElt (const Standard_Integer IndLine, const Standard_Integer Index) const;
112 
113   //! Returns the geometry linked to the <BasicElt>.
114   Standard_EXPORT Handle(Geom2d_Geometry) GeomElt (const Handle(MAT_BasicElt)& aBasicElt) const;
115 
116   //! Returns the geometry of  type <gp> linked to
117   //! the <Node>.
118   Standard_EXPORT gp_Pnt2d GeomElt (const Handle(MAT_Node)& aNode) const;
119 
120   //! Returns the  geometry of type <Bissec>
121   //! linked   to the arc <ARC>.
122   //! <Reverse> is False when the FirstNode of <anArc>
123   //! correspond to the first point of geometry.
124   Standard_EXPORT Bisector_Bisec GeomBis (const Handle(MAT_Arc)& anArc, Standard_Boolean& Reverse) const;
125 
126 
127 
128 
129 protected:
130 
131 
132 
133 
134 
135 private:
136 
137 
138   Standard_EXPORT void Fusion();
139 
140   Standard_EXPORT void RenumerationAndFusion (const Standard_Integer IndexLine, const Standard_Integer LengthLine, Standard_Integer& IndexLast, MAT_DataMapOfIntegerBasicElt& NewMap);
141 
142 
143   Handle(MAT_Graph) theGraph;
144   MAT2d_Tool2d theTool;
145   Standard_Boolean isDone;
146   MAT2d_DataMapOfBiIntInteger nbSect;
147   Standard_Integer nbContours;
148 
149 
150 };
151 
152 
153 
154 
155 
156 
157 
158 #endif // _BRepMAT2d_BisectingLocus_HeaderFile
159