1 // Created on: 1994-12-16
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified by skv - Fri Jul 14 17:03:47 2006 OCC12627
19 #include <Geom2dAdaptor_Curve.hxx>
20 #include <Geom2dHatch_Element.hxx>
21 #include <Geom2dHatch_Elements.hxx>
23 #include <gp_Lin2d.hxx>
24 #include <gp_Pnt2d.hxx>
25 #include <gp_Vec2d.hxx>
26 #include <Standard_DomainError.hxx>
27 #include <Standard_Integer.hxx>
28 #include <Standard_NoSuchObject.hxx>
29 #include <TColStd_MapIntegerHasher.hxx>
30 #include <TopAbs_Orientation.hxx>
32 Geom2dHatch_Elements::Geom2dHatch_Elements(const Geom2dHatch_Elements& )
35 cout<<" Magic Constructor in Geom2dHatch_Elements:: "<<endl;
39 Geom2dHatch_Elements::Geom2dHatch_Elements()
46 void Geom2dHatch_Elements::Clear()
51 Standard_Boolean Geom2dHatch_Elements::IsBound(const Standard_Integer K) const
53 return(myMap.IsBound(K));
56 Standard_Boolean Geom2dHatch_Elements::UnBind(const Standard_Integer K)
58 return(myMap.UnBind(K));
61 Standard_Boolean Geom2dHatch_Elements::Bind(const Standard_Integer K,const Geom2dHatch_Element& I)
63 return(myMap.Bind(K,I));
66 const Geom2dHatch_Element& Geom2dHatch_Elements::Find(const Standard_Integer K) const
68 return(myMap.Find(K));
71 Geom2dHatch_Element& Geom2dHatch_Elements::ChangeFind(const Standard_Integer K)
73 return(myMap.ChangeFind(K));
76 //=======================================================================
77 //function : CheckPoint
79 //=======================================================================
81 Standard_Boolean Geom2dHatch_Elements::CheckPoint(gp_Pnt2d&)
86 //=======================================================================
89 //=======================================================================
91 Standard_Boolean Geom2dHatch_Elements::Reject(const gp_Pnt2d&) const {
92 return Standard_False;
95 //=======================================================================
98 //=======================================================================
100 Standard_Boolean Geom2dHatch_Elements::Segment(const gp_Pnt2d& P,
106 return OtherSegment(P, L, Par);
109 //=======================================================================
112 //=======================================================================
114 Standard_Boolean Geom2dHatch_Elements::OtherSegment(const gp_Pnt2d& P,
118 Geom2dHatch_DataMapIteratorOfMapOfElements Itertemp;
121 for( Itertemp.Initialize(myMap), i = 1; Itertemp.More(); Itertemp.Next(), i++) {
125 void *ptrmyMap = (void *)(&myMap);
126 Geom2dHatch_Element& Item=((Geom2dHatch_MapOfElements*)ptrmyMap)->ChangeFind(Itertemp.Key());
127 Geom2dAdaptor_Curve& E = Item.ChangeCurve();
128 TopAbs_Orientation Or= Item.Orientation();
129 gp_Pnt2d P2 = E.Value
130 ((E.FirstParameter() + E.LastParameter()) *0.5);
131 if ((Or == TopAbs_FORWARD) ||
132 (Or == TopAbs_REVERSED)) {
135 if (Par >= gp::Resolution()) {
138 return Standard_True;
143 if (i == myCurEdge + 1) {
145 L = gp_Lin2d(P,gp_Dir2d(1,0));
148 return Standard_True;
151 return Standard_False;
154 //=======================================================================
155 //function : InitWires
157 //=======================================================================
159 void Geom2dHatch_Elements::InitWires() {
163 //=======================================================================
164 //function : RejectWire NYI
166 //=======================================================================
168 Standard_Boolean Geom2dHatch_Elements::RejectWire(const gp_Lin2d& ,
169 const Standard_Real) const
171 return Standard_False;
174 //=======================================================================
175 //function : InitEdges
177 //=======================================================================
179 void Geom2dHatch_Elements::InitEdges() {
181 Iter.Initialize(myMap);
184 //=======================================================================
185 //function : RejectEdge NYI
187 //=======================================================================
189 Standard_Boolean Geom2dHatch_Elements::RejectEdge(const gp_Lin2d& ,
190 const Standard_Real ) const
192 return Standard_False;
196 //=======================================================================
197 //function : CurrentEdge
199 //=======================================================================
201 void Geom2dHatch_Elements::CurrentEdge(Geom2dAdaptor_Curve& E,
202 TopAbs_Orientation& Or) const
204 void *ptrmyMap = (void *)(&myMap);
205 Geom2dHatch_Element& Item=((Geom2dHatch_MapOfElements*)ptrmyMap)->ChangeFind(Iter.Key());
207 E = Item.ChangeCurve();
208 Or= Item.Orientation();
210 E.Edge() = TopoDS::Edge(myEExplorer.Current());
212 Or = E.Edge().Orientation();
217 //=======================================================================
218 //function : MoreWires
220 //=======================================================================
222 Standard_Boolean Geom2dHatch_Elements::MoreWires() const
224 return (NumWire == 0);
227 //=======================================================================
228 //function : NextWire
230 //=======================================================================
232 void Geom2dHatch_Elements::NextWire() {
236 //=======================================================================
237 //function : MoreEdges
239 //=======================================================================
241 Standard_Boolean Geom2dHatch_Elements::MoreEdges() const {
245 //=======================================================================
246 //function : NextEdge
248 //=======================================================================
250 void Geom2dHatch_Elements::NextEdge() {