b311480e |
1 | // Created on: 1999-01-14 |
2 | // Created by: Prestataire Xuan PHAM PHU |
3 | // Copyright (c) 1999-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <BRep_Builder.hxx> |
7fd59977 |
19 | #include <BRep_Tool.hxx> |
42cf5bc1 |
20 | #include <BRepTopAdaptor_FClass2d.hxx> |
7fd59977 |
21 | #include <Precision.hxx> |
42cf5bc1 |
22 | #include <Standard_Failure.hxx> |
23 | #include <TopoDS.hxx> |
24 | #include <TopoDS_Face.hxx> |
7fd59977 |
25 | #include <TopoDS_Iterator.hxx> |
42cf5bc1 |
26 | #include <TopoDS_Wire.hxx> |
27 | #include <TopOpeBRepTool_define.hxx> |
28 | #include <TopOpeBRepTool_face.hxx> |
7fd59977 |
29 | |
30 | //======================================================================= |
31 | //function : TopOpeBRepTool_face |
32 | //purpose : |
33 | //======================================================================= |
7fd59977 |
34 | TopOpeBRepTool_face::TopOpeBRepTool_face() |
35 | { |
36 | } |
37 | |
38 | static void FUN_reverse(const TopoDS_Face& f, TopoDS_Face& frev) |
39 | { |
40 | BRep_Builder B; |
41 | TopoDS_Shape aLocalShape = f.EmptyCopied(); |
42 | frev = TopoDS::Face(aLocalShape); |
43 | // frev = TopoDS::Face(f.EmptyCopied()); |
44 | TopoDS_Iterator it(f); |
45 | while (it.More()) { |
46 | B.Add(frev,it.Value().Reversed()); |
47 | it.Next(); |
48 | } |
49 | } |
50 | |
51 | //======================================================================= |
52 | //function : Init |
53 | //purpose : |
54 | //======================================================================= |
55 | |
56 | Standard_Boolean TopOpeBRepTool_face::Init(const TopoDS_Wire& W, const TopoDS_Face& Fref) |
57 | { |
58 | myFfinite.Nullify(); |
59 | myW = W; |
60 | |
61 | // fres : |
62 | // TopoDS_Face fres; |
63 | // Handle(Geom_Surface) su = BRep_Tool::Surface(Fref); |
64 | // BRep_Builder B; B.MakeFace(fres,su,Precision::Confusion()); |
65 | TopoDS_Shape aLocalShape = Fref.EmptyCopied(); |
66 | TopoDS_Face fres = TopoDS::Face(aLocalShape); |
67 | // TopoDS_Face fres = TopoDS::Face(Fref.EmptyCopied()); |
68 | BRep_Builder B; B.Add(fres,W); |
69 | B.NaturalRestriction(fres,Standard_True); |
70 | |
71 | // <myfinite> : |
72 | BRepTopAdaptor_FClass2d FClass(fres,0.); |
73 | Standard_Boolean infinite = ( FClass.PerformInfinitePoint() == TopAbs_IN); |
74 | myfinite = !infinite; |
75 | |
76 | // <myFfinite> : |
77 | if (myfinite) myFfinite = fres; |
78 | else FUN_reverse(fres,myFfinite); |
79 | return Standard_True; |
80 | } |
81 | |
82 | //======================================================================= |
83 | //function : IsDone |
84 | //purpose : |
85 | //======================================================================= |
86 | |
87 | Standard_Boolean TopOpeBRepTool_face::IsDone() const |
88 | { |
89 | return (!myFfinite.IsNull()); |
90 | } |
91 | |
92 | //======================================================================= |
93 | //function : Finite |
94 | //purpose : |
95 | //======================================================================= |
96 | |
97 | Standard_Boolean TopOpeBRepTool_face::Finite() const |
98 | { |
9775fa61 |
99 | if (!IsDone()) throw Standard_Failure("TopOpeBRepTool_face NOT DONE"); |
7fd59977 |
100 | return myfinite; |
101 | } |
102 | |
103 | //======================================================================= |
104 | //function : Ffinite |
105 | //purpose : |
106 | //======================================================================= |
107 | |
108 | const TopoDS_Face& TopOpeBRepTool_face::Ffinite() const |
109 | { |
9775fa61 |
110 | if (!IsDone()) throw Standard_Failure("TopOpeBRepTool_face NOT DONE"); |
7fd59977 |
111 | return myFfinite; |
112 | } |
113 | |
114 | //======================================================================= |
115 | //function : W |
116 | //purpose : |
117 | //======================================================================= |
118 | |
119 | const TopoDS_Wire& TopOpeBRepTool_face::W() const |
120 | { |
121 | return myW; |
122 | } |
123 | |
124 | //======================================================================= |
125 | //function : TopoDS_Face& |
126 | //purpose : |
127 | //======================================================================= |
128 | |
129 | TopoDS_Face TopOpeBRepTool_face::RealF() const |
130 | { |
131 | if (myfinite) return myFfinite; |
132 | TopoDS_Face realf; FUN_reverse(myFfinite,realf); |
133 | return realf; |
134 | } |
135 | |
136 | |