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
9 // under the terms of the GNU Lesser General Public 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 #include <BRepFilletAPI_MakeChamfer.ixx>
18 #include <TopOpeBRepDS_HDataStructure.hxx>
19 #include <TopTools_ListIteratorOfListOfShape.hxx>
20 #include <ChFiDS_Spine.hxx>
21 #include <TopExp_Explorer.hxx>
25 //=======================================================================
26 //function : BRepFilletAPI_MakeChamfer
28 //=======================================================================
29 BRepFilletAPI_MakeChamfer::BRepFilletAPI_MakeChamfer(const TopoDS_Shape &S):myBuilder(S)
35 //=======================================================================
38 //=======================================================================
40 void BRepFilletAPI_MakeChamfer::Add(const TopoDS_Edge &E )
47 //=======================================================================
50 //=======================================================================
52 void BRepFilletAPI_MakeChamfer::Add(const Standard_Real Dis,
56 myBuilder.Add(Dis, E, F);
60 //=======================================================================
63 //=======================================================================
65 void BRepFilletAPI_MakeChamfer::SetDist(const Standard_Real Dis,
66 const Standard_Integer IC,
69 myBuilder.SetDist(Dis, IC, F);
72 //=======================================================================
75 //================================================================
77 void BRepFilletAPI_MakeChamfer::GetDist(const Standard_Integer IC,
78 Standard_Real& Dis) const
80 myBuilder.GetDist(IC, Dis);
84 //=======================================================================
87 //=======================================================================
89 void BRepFilletAPI_MakeChamfer::Add(const Standard_Real Dis1,
90 const Standard_Real Dis2,
94 myBuilder.Add(Dis1,Dis2,E,F);
98 //=======================================================================
101 //=======================================================================
103 void BRepFilletAPI_MakeChamfer::SetDists(const Standard_Real Dis1,
104 const Standard_Real Dis2,
105 const Standard_Integer IC,
106 const TopoDS_Face &F)
108 myBuilder.SetDists(Dis1,Dis2,IC,F);
111 //=======================================================================
114 //================================================================
116 void BRepFilletAPI_MakeChamfer::Dists(const Standard_Integer IC,
118 Standard_Real& Dis2) const
120 Standard_Real temp1, temp2;
121 myBuilder.Dists(IC,temp1,temp2);
128 //=======================================================================
131 //=======================================================================
133 void BRepFilletAPI_MakeChamfer::AddDA(const Standard_Real Dis,
134 const Standard_Real Angle,
135 const TopoDS_Edge &E,
136 const TopoDS_Face &F)
138 myBuilder.AddDA(Dis, Angle, E, F);
141 //=======================================================================
144 //=======================================================================
146 void BRepFilletAPI_MakeChamfer::SetDistAngle(const Standard_Real Dis,
147 const Standard_Real Angle,
148 const Standard_Integer IC,
149 const TopoDS_Face &F)
151 myBuilder.SetDistAngle(Dis, Angle, IC, F);
154 //=======================================================================
155 //function : GetDistAngle
157 //================================================================
159 void BRepFilletAPI_MakeChamfer::GetDistAngle(const Standard_Integer IC,
161 Standard_Real& Angle,
162 Standard_Boolean& DisOnFace1) const
164 myBuilder.GetDistAngle(IC, Dis, Angle, DisOnFace1);
168 //=======================================================================
169 //function : IsSymetric
171 //===============================================================
173 Standard_Boolean BRepFilletAPI_MakeChamfer::IsSymetric(const Standard_Integer IC) const
175 ChFiDS_ChamfMethod ChamfMeth = myBuilder.IsChamfer(IC);
176 Standard_Boolean ret = Standard_False;
178 if (ChamfMeth == ChFiDS_Sym) ret = Standard_True;
184 //=======================================================================
185 //function : IsTwoDistances
187 //===============================================================
189 Standard_Boolean BRepFilletAPI_MakeChamfer::IsTwoDistances(const Standard_Integer IC) const
191 ChFiDS_ChamfMethod ChamfMeth = myBuilder.IsChamfer(IC);
192 Standard_Boolean ret = Standard_False;
194 if (ChamfMeth == ChFiDS_TwoDist) ret = Standard_True;
201 //=======================================================================
202 //function : IsDistanceAngle
204 //===============================================================
206 Standard_Boolean BRepFilletAPI_MakeChamfer::IsDistanceAngle(const Standard_Integer IC) const
208 ChFiDS_ChamfMethod ChamfMeth = myBuilder.IsChamfer(IC);
209 Standard_Boolean ret = Standard_False;
211 if (ChamfMeth == ChFiDS_DistAngle) ret = Standard_True;
218 //=======================================================================
219 //function : ResetContour
221 //===============================================================
223 void BRepFilletAPI_MakeChamfer::ResetContour(const Standard_Integer IC)
225 myBuilder.ResetContour(IC);
229 //=======================================================================
230 //function : NbContours
232 //=======================================================================
234 Standard_Integer BRepFilletAPI_MakeChamfer::NbContours()const
236 return myBuilder.NbElements();
241 //=======================================================================
244 //=======================================================================
246 Standard_Integer BRepFilletAPI_MakeChamfer::Contour(const TopoDS_Edge &E)const
248 return myBuilder.Contains(E);
253 //=======================================================================
256 //=======================================================================
258 Standard_Integer BRepFilletAPI_MakeChamfer::NbEdges(const Standard_Integer I)const
261 const Handle(ChFiDS_Spine)& Spine = myBuilder.Value(I);
262 return (Spine->NbEdges());
266 //=======================================================================
269 //=======================================================================
271 const TopoDS_Edge& BRepFilletAPI_MakeChamfer::Edge(const Standard_Integer I,
272 const Standard_Integer J)const
274 const Handle(ChFiDS_Spine)& Spine = myBuilder.Value(I);
275 const TopoDS_Edge& E = Spine->Edges(J);
279 //=======================================================================
282 //=======================================================================
284 void BRepFilletAPI_MakeChamfer::Remove(const TopoDS_Edge& E)
289 //=======================================================================
292 //=======================================================================
294 Standard_Real BRepFilletAPI_MakeChamfer::Length(const Standard_Integer IC)const
296 return myBuilder.Length(IC);
299 //=======================================================================
300 //function : FirstVertex
302 //=======================================================================
304 TopoDS_Vertex BRepFilletAPI_MakeChamfer::FirstVertex(const Standard_Integer IC)const
306 return myBuilder.FirstVertex(IC);
310 //=======================================================================
311 //function : LastVertex
313 //=======================================================================
315 TopoDS_Vertex BRepFilletAPI_MakeChamfer::LastVertex(const Standard_Integer IC)const
317 return myBuilder.LastVertex(IC);
321 //=======================================================================
322 //function : Abscissa
324 //=======================================================================
326 Standard_Real BRepFilletAPI_MakeChamfer::Abscissa(const Standard_Integer IC,
327 const TopoDS_Vertex& V)const
329 return myBuilder.Abscissa(IC,V);
333 //=======================================================================
334 //function : RelativeAbscissa
336 //=======================================================================
338 Standard_Real BRepFilletAPI_MakeChamfer::RelativeAbscissa(const Standard_Integer IC,
339 const TopoDS_Vertex& V)const
341 return myBuilder.RelativeAbscissa(IC,V);
344 //=======================================================================
345 //function : ClosedAndTangent
347 //=======================================================================
349 Standard_Boolean BRepFilletAPI_MakeChamfer::ClosedAndTangent
350 (const Standard_Integer IC)const
352 return myBuilder.ClosedAndTangent(IC);
356 //=======================================================================
359 //=======================================================================
361 Standard_Boolean BRepFilletAPI_MakeChamfer::Closed
362 (const Standard_Integer IC)const
364 return myBuilder.Closed(IC);
367 //=======================================================================
370 //=======================================================================
372 Handle(TopOpeBRepBuild_HBuilder) BRepFilletAPI_MakeChamfer::Builder()const
374 return myBuilder.Builder();
377 //=======================================================================
380 //=======================================================================
382 void BRepFilletAPI_MakeChamfer::Build()
385 if (myBuilder.IsDone()){
387 myShape = myBuilder.Shape();
389 //creation of the Map.
391 for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
392 myMap.Add(ex.Current());
397 //=======================================================================
400 //=======================================================================
402 void BRepFilletAPI_MakeChamfer::Reset()
409 //=======================================================================
410 //function : Generated
412 //=======================================================================
414 const TopTools_ListOfShape& BRepFilletAPI_MakeChamfer::Generated
415 (const TopoDS_Shape& EorV)
417 return myBuilder.Generated(EorV);
420 //=======================================================================
421 //function : Modified
423 //=======================================================================
425 const TopTools_ListOfShape& BRepFilletAPI_MakeChamfer::Modified
426 (const TopoDS_Shape& F)
430 if (myBuilder.Builder()->IsSplit(F, TopAbs_OUT)) {
431 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_OUT));
432 for(;It.More();It.Next()) {
433 myGenerated.Append(It.Value());
436 if (myBuilder.Builder()->IsSplit(F, TopAbs_IN)) {
437 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_IN));
438 for(;It.More();It.Next()) {
439 myGenerated.Append(It.Value());
442 if (myBuilder.Builder()->IsSplit(F, TopAbs_ON)) {
443 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_ON));
444 for(;It.More();It.Next()) {
445 myGenerated.Append(It.Value());
451 //=======================================================================
452 //function : IsDeleted
454 //=======================================================================
456 Standard_Boolean BRepFilletAPI_MakeChamfer::IsDeleted(const TopoDS_Shape& F)
458 if (myMap.Contains(F) ||
459 myBuilder.Builder()->IsSplit (F, TopAbs_OUT) ||
460 myBuilder.Builder()->IsSplit (F, TopAbs_IN) ||
461 myBuilder.Builder()->IsSplit (F, TopAbs_ON))
462 return Standard_False;
464 return Standard_True;
467 //=======================================================================
468 //function : Simulate
470 //=======================================================================
472 void BRepFilletAPI_MakeChamfer::Simulate(const Standard_Integer IC)
474 myBuilder.Simulate(IC);
478 //=======================================================================
481 //=======================================================================
483 Standard_Integer BRepFilletAPI_MakeChamfer::NbSurf(const Standard_Integer IC)const
485 return myBuilder.NbSurf(IC);
489 //=======================================================================
492 //=======================================================================
494 Handle(ChFiDS_SecHArray1) BRepFilletAPI_MakeChamfer::Sect(const Standard_Integer IC,
495 const Standard_Integer IS)const
497 return myBuilder.Sect(IC, IS);