0024157: Parallelization of assembly part of BO
[occt.git] / src / TopOpeBRepTool / TopOpeBRepTool_face.cxx
1 // Created on: 1999-01-14
2 // Created by: Prestataire Xuan PHAM PHU
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23 #include <TopOpeBRepTool_face.ixx>
24 #include <TopOpeBRepTool_define.hxx>
25 #include <Standard_Failure.hxx>
26 #include <TopoDS.hxx>
27 #include <BRep_Tool.hxx>
28 #include <Precision.hxx>
29 #include <BRep_Builder.hxx>
30 #include <TopoDS_Iterator.hxx>
31 #include <BRepTopAdaptor_FClass2d.hxx>
32
33 //=======================================================================
34 //function : TopOpeBRepTool_face
35 //purpose  : 
36 //=======================================================================
37
38 TopOpeBRepTool_face::TopOpeBRepTool_face()
39 {
40 }
41
42 static void FUN_reverse(const TopoDS_Face& f, TopoDS_Face& frev)
43 {
44   BRep_Builder B; 
45   TopoDS_Shape aLocalShape = f.EmptyCopied();
46   frev = TopoDS::Face(aLocalShape);
47 //  frev = TopoDS::Face(f.EmptyCopied());
48   TopoDS_Iterator it(f);
49   while (it.More()) {
50     B.Add(frev,it.Value().Reversed());
51     it.Next();
52   }    
53 }
54
55 //=======================================================================
56 //function : Init
57 //purpose  : 
58 //=======================================================================
59
60 Standard_Boolean TopOpeBRepTool_face::Init(const TopoDS_Wire& W, const TopoDS_Face& Fref)
61 {
62   myFfinite.Nullify();
63   myW = W;
64
65   // fres : 
66 //  TopoDS_Face fres;
67 //  Handle(Geom_Surface) su = BRep_Tool::Surface(Fref);  
68 //  BRep_Builder B; B.MakeFace(fres,su,Precision::Confusion());
69   TopoDS_Shape aLocalShape = Fref.EmptyCopied();
70   TopoDS_Face fres = TopoDS::Face(aLocalShape);
71 //  TopoDS_Face fres = TopoDS::Face(Fref.EmptyCopied());
72   BRep_Builder B; B.Add(fres,W);
73   B.NaturalRestriction(fres,Standard_True);
74
75   // <myfinite> :
76   BRepTopAdaptor_FClass2d FClass(fres,0.);
77   Standard_Boolean infinite = ( FClass.PerformInfinitePoint() == TopAbs_IN);
78   myfinite = !infinite;
79
80   // <myFfinite> : 
81   if (myfinite) myFfinite = fres;
82   else          FUN_reverse(fres,myFfinite);
83   return Standard_True;
84 }
85
86 //=======================================================================
87 //function : IsDone
88 //purpose  : 
89 //=======================================================================
90
91 Standard_Boolean TopOpeBRepTool_face::IsDone() const
92 {
93   return (!myFfinite.IsNull());
94 }
95
96 //=======================================================================
97 //function : Finite
98 //purpose  : 
99 //=======================================================================
100
101 Standard_Boolean TopOpeBRepTool_face::Finite() const
102 {
103   if (!IsDone()) Standard_Failure::Raise("TopOpeBRepTool_face NOT DONE");
104   return myfinite;
105 }
106
107 //=======================================================================
108 //function : Ffinite
109 //purpose  : 
110 //=======================================================================
111
112 const TopoDS_Face& TopOpeBRepTool_face::Ffinite() const
113 {
114   if (!IsDone()) Standard_Failure::Raise("TopOpeBRepTool_face NOT DONE");
115   return myFfinite;
116 }
117
118 //=======================================================================
119 //function : W
120 //purpose  : 
121 //=======================================================================
122
123 const TopoDS_Wire& TopOpeBRepTool_face::W() const
124 {
125   return myW;
126 }
127
128 //=======================================================================
129 //function : TopoDS_Face&
130 //purpose  : 
131 //=======================================================================
132
133 TopoDS_Face TopOpeBRepTool_face::RealF() const
134 {
135   if (myfinite) return myFfinite;
136   TopoDS_Face realf; FUN_reverse(myFfinite,realf);
137   return realf;
138 }
139
140