1 // Created on: 1995-06-22
2 // Created by: Flore Lantheaume
3 // Copyright (c) 1995-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.
18 #include <BRepFilletAPI_MakeChamfer.hxx>
19 #include <ChFiDS_Spine.hxx>
20 #include <StdFail_NotDone.hxx>
21 #include <TopExp_Explorer.hxx>
22 #include <TopoDS_Edge.hxx>
23 #include <TopoDS_Face.hxx>
24 #include <TopoDS_Shape.hxx>
25 #include <TopoDS_Vertex.hxx>
26 #include <TopOpeBRepBuild_HBuilder.hxx>
27 #include <TopOpeBRepDS_HDataStructure.hxx>
28 #include <TopTools_ListIteratorOfListOfShape.hxx>
30 //=======================================================================
31 //function : BRepFilletAPI_MakeChamfer
33 //=======================================================================
34 BRepFilletAPI_MakeChamfer::BRepFilletAPI_MakeChamfer(const TopoDS_Shape &S):myBuilder(S)
40 //=======================================================================
43 //=======================================================================
45 void BRepFilletAPI_MakeChamfer::Add(const TopoDS_Edge &E )
52 //=======================================================================
55 //=======================================================================
57 void BRepFilletAPI_MakeChamfer::Add(const Standard_Real Dis,
60 myBuilder.Add(Dis, E);
64 //=======================================================================
67 //=======================================================================
69 void BRepFilletAPI_MakeChamfer::SetDist(const Standard_Real Dis,
70 const Standard_Integer IC,
73 myBuilder.SetDist(Dis, IC, F);
76 //=======================================================================
79 //================================================================
81 void BRepFilletAPI_MakeChamfer::GetDist(const Standard_Integer IC,
82 Standard_Real& Dis) const
84 myBuilder.GetDist(IC, Dis);
88 //=======================================================================
91 //=======================================================================
93 void BRepFilletAPI_MakeChamfer::Add(const Standard_Real Dis1,
94 const Standard_Real Dis2,
98 myBuilder.Add(Dis1,Dis2,E,F);
102 //=======================================================================
103 //function : SetDists
105 //=======================================================================
107 void BRepFilletAPI_MakeChamfer::SetDists(const Standard_Real Dis1,
108 const Standard_Real Dis2,
109 const Standard_Integer IC,
110 const TopoDS_Face &F)
112 myBuilder.SetDists(Dis1,Dis2,IC,F);
115 //=======================================================================
118 //================================================================
120 void BRepFilletAPI_MakeChamfer::Dists(const Standard_Integer IC,
122 Standard_Real& Dis2) const
124 Standard_Real temp1, temp2;
125 myBuilder.Dists(IC,temp1,temp2);
132 //=======================================================================
135 //=======================================================================
137 void BRepFilletAPI_MakeChamfer::AddDA(const Standard_Real Dis,
138 const Standard_Real Angle,
139 const TopoDS_Edge &E,
140 const TopoDS_Face &F)
142 myBuilder.AddDA(Dis, Angle, E, F);
145 //=======================================================================
148 //=======================================================================
150 void BRepFilletAPI_MakeChamfer::SetDistAngle(const Standard_Real Dis,
151 const Standard_Real Angle,
152 const Standard_Integer IC,
153 const TopoDS_Face &F)
155 myBuilder.SetDistAngle(Dis, Angle, IC, F);
158 //=======================================================================
159 //function : GetDistAngle
161 //================================================================
163 void BRepFilletAPI_MakeChamfer::GetDistAngle(const Standard_Integer IC,
165 Standard_Real& Angle) const
167 myBuilder.GetDistAngle(IC, Dis, Angle);
170 //=======================================================================
173 //=======================================================================
175 void BRepFilletAPI_MakeChamfer::SetMode(const ChFiDS_ChamfMode theMode)
177 myBuilder.SetMode(theMode);
180 //=======================================================================
181 //function : IsSymetric
183 //===============================================================
185 Standard_Boolean BRepFilletAPI_MakeChamfer::IsSymetric(const Standard_Integer IC) const
187 ChFiDS_ChamfMethod ChamfMeth = myBuilder.IsChamfer(IC);
188 Standard_Boolean ret = Standard_False;
190 if (ChamfMeth == ChFiDS_Sym) ret = Standard_True;
196 //=======================================================================
197 //function : IsTwoDistances
199 //===============================================================
201 Standard_Boolean BRepFilletAPI_MakeChamfer::IsTwoDistances(const Standard_Integer IC) const
203 ChFiDS_ChamfMethod ChamfMeth = myBuilder.IsChamfer(IC);
204 Standard_Boolean ret = Standard_False;
206 if (ChamfMeth == ChFiDS_TwoDist) ret = Standard_True;
213 //=======================================================================
214 //function : IsDistanceAngle
216 //===============================================================
218 Standard_Boolean BRepFilletAPI_MakeChamfer::IsDistanceAngle(const Standard_Integer IC) const
220 ChFiDS_ChamfMethod ChamfMeth = myBuilder.IsChamfer(IC);
221 Standard_Boolean ret = Standard_False;
223 if (ChamfMeth == ChFiDS_DistAngle) ret = Standard_True;
230 //=======================================================================
231 //function : ResetContour
233 //===============================================================
235 void BRepFilletAPI_MakeChamfer::ResetContour(const Standard_Integer IC)
237 myBuilder.ResetContour(IC);
241 //=======================================================================
242 //function : NbContours
244 //=======================================================================
246 Standard_Integer BRepFilletAPI_MakeChamfer::NbContours()const
248 return myBuilder.NbElements();
253 //=======================================================================
256 //=======================================================================
258 Standard_Integer BRepFilletAPI_MakeChamfer::Contour(const TopoDS_Edge &E)const
260 return myBuilder.Contains(E);
265 //=======================================================================
268 //=======================================================================
270 Standard_Integer BRepFilletAPI_MakeChamfer::NbEdges(const Standard_Integer I)const
273 const Handle(ChFiDS_Spine)& Spine = myBuilder.Value(I);
274 return (Spine->NbEdges());
278 //=======================================================================
281 //=======================================================================
283 const TopoDS_Edge& BRepFilletAPI_MakeChamfer::Edge(const Standard_Integer I,
284 const Standard_Integer J)const
286 const Handle(ChFiDS_Spine)& Spine = myBuilder.Value(I);
287 const TopoDS_Edge& E = Spine->Edges(J);
291 //=======================================================================
294 //=======================================================================
296 void BRepFilletAPI_MakeChamfer::Remove(const TopoDS_Edge& E)
301 //=======================================================================
304 //=======================================================================
306 Standard_Real BRepFilletAPI_MakeChamfer::Length(const Standard_Integer IC)const
308 return myBuilder.Length(IC);
311 //=======================================================================
312 //function : FirstVertex
314 //=======================================================================
316 TopoDS_Vertex BRepFilletAPI_MakeChamfer::FirstVertex(const Standard_Integer IC)const
318 return myBuilder.FirstVertex(IC);
322 //=======================================================================
323 //function : LastVertex
325 //=======================================================================
327 TopoDS_Vertex BRepFilletAPI_MakeChamfer::LastVertex(const Standard_Integer IC)const
329 return myBuilder.LastVertex(IC);
333 //=======================================================================
334 //function : Abscissa
336 //=======================================================================
338 Standard_Real BRepFilletAPI_MakeChamfer::Abscissa(const Standard_Integer IC,
339 const TopoDS_Vertex& V)const
341 return myBuilder.Abscissa(IC,V);
345 //=======================================================================
346 //function : RelativeAbscissa
348 //=======================================================================
350 Standard_Real BRepFilletAPI_MakeChamfer::RelativeAbscissa(const Standard_Integer IC,
351 const TopoDS_Vertex& V)const
353 return myBuilder.RelativeAbscissa(IC,V);
356 //=======================================================================
357 //function : ClosedAndTangent
359 //=======================================================================
361 Standard_Boolean BRepFilletAPI_MakeChamfer::ClosedAndTangent
362 (const Standard_Integer IC)const
364 return myBuilder.ClosedAndTangent(IC);
368 //=======================================================================
371 //=======================================================================
373 Standard_Boolean BRepFilletAPI_MakeChamfer::Closed
374 (const Standard_Integer IC)const
376 return myBuilder.Closed(IC);
379 //=======================================================================
382 //=======================================================================
384 Handle(TopOpeBRepBuild_HBuilder) BRepFilletAPI_MakeChamfer::Builder()const
386 return myBuilder.Builder();
389 //=======================================================================
392 //=======================================================================
394 void BRepFilletAPI_MakeChamfer::Build()
397 if (myBuilder.IsDone()){
399 myShape = myBuilder.Shape();
401 //creation of the Map.
403 for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
404 myMap.Add(ex.Current());
409 //=======================================================================
412 //=======================================================================
414 void BRepFilletAPI_MakeChamfer::Reset()
421 //=======================================================================
422 //function : Generated
424 //=======================================================================
426 const TopTools_ListOfShape& BRepFilletAPI_MakeChamfer::Generated
427 (const TopoDS_Shape& EorV)
429 return myBuilder.Generated(EorV);
432 //=======================================================================
433 //function : Modified
435 //=======================================================================
437 const TopTools_ListOfShape& BRepFilletAPI_MakeChamfer::Modified
438 (const TopoDS_Shape& F)
442 if (myBuilder.Builder()->IsSplit(F, TopAbs_OUT)) {
443 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_OUT));
444 for(;It.More();It.Next()) {
445 myGenerated.Append(It.Value());
448 if (myBuilder.Builder()->IsSplit(F, TopAbs_IN)) {
449 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_IN));
450 for(;It.More();It.Next()) {
451 myGenerated.Append(It.Value());
454 if (myBuilder.Builder()->IsSplit(F, TopAbs_ON)) {
455 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_ON));
456 for(;It.More();It.Next()) {
457 myGenerated.Append(It.Value());
463 //=======================================================================
464 //function : IsDeleted
466 //=======================================================================
468 Standard_Boolean BRepFilletAPI_MakeChamfer::IsDeleted(const TopoDS_Shape& F)
470 if (myMap.Contains(F) ||
471 myBuilder.Builder()->IsSplit (F, TopAbs_OUT) ||
472 myBuilder.Builder()->IsSplit (F, TopAbs_IN) ||
473 myBuilder.Builder()->IsSplit (F, TopAbs_ON))
474 return Standard_False;
476 return Standard_True;
479 //=======================================================================
480 //function : Simulate
482 //=======================================================================
484 void BRepFilletAPI_MakeChamfer::Simulate(const Standard_Integer IC)
486 myBuilder.Simulate(IC);
490 //=======================================================================
493 //=======================================================================
495 Standard_Integer BRepFilletAPI_MakeChamfer::NbSurf(const Standard_Integer IC)const
497 return myBuilder.NbSurf(IC);
501 //=======================================================================
504 //=======================================================================
506 Handle(ChFiDS_SecHArray1) BRepFilletAPI_MakeChamfer::Sect(const Standard_Integer IC,
507 const Standard_Integer IS)const
509 return myBuilder.Sect(IC, IS);