0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / BRepOffsetAPI / BRepOffsetAPI_MakeEvolved.cxx
1 // Created on: 1995-09-18
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <BRepFill.hxx>
19 #include <BRepFill_Evolved.hxx>
20 #include <BRepOffsetAPI_MakeEvolved.hxx>
21 #include <gp_Ax3.hxx>
22 #include <TopoDS_Face.hxx>
23 #include <TopoDS_Shape.hxx>
24 #include <TopoDS_Wire.hxx>
25 #include <TopoDS_Iterator.hxx>
26 #include <TopoDS.hxx>
27 #include <Standard_NotImplemented.hxx>
28
29 static const TopTools_ListOfShape anEmptyList;
30
31 //=======================================================================
32 //function : Constructor
33 //purpose  : 
34 //=======================================================================
35 BRepOffsetAPI_MakeEvolved::BRepOffsetAPI_MakeEvolved()
36 {
37 }
38
39 //=======================================================================
40 //function : Constructor
41 //purpose  : 
42 //=======================================================================
43 BRepOffsetAPI_MakeEvolved::BRepOffsetAPI_MakeEvolved(const TopoDS_Shape&    Spine,
44                                                      const TopoDS_Wire&     Profil,
45                                                      const GeomAbs_JoinType Join,
46                                                      const Standard_Boolean AxeProf,
47                                                      const Standard_Boolean Solid,
48                                                      const Standard_Boolean ProfOnSpine,
49                                                      const Standard_Real    Tol,
50                                                      const Standard_Boolean theIsVolume,
51                                                      const Standard_Boolean theRunInParallel)
52   : myIsVolume (theIsVolume)
53 {
54   if (Spine.ShapeType() != TopAbs_WIRE && Spine.ShapeType() != TopAbs_FACE)
55   {
56     Standard_TypeMismatch::Raise ("BRepOffsetAPI_MakeEvolved: face or wire is expected as a spine");
57   }
58   if (theIsVolume)
59   {
60     myVolume.SetParallelMode(theRunInParallel);
61     TopoDS_Wire aSpine;
62     if (Spine.ShapeType() == TopAbs_WIRE)
63     {
64       aSpine = TopoDS::Wire(Spine);
65     }
66     else
67     {
68       aSpine = TopoDS::Wire(TopoDS_Iterator(Spine).Value());
69     }
70     myVolume.Perform(aSpine, Profil, Tol, Solid);
71     if (!myVolume.IsDone())
72     {
73       return;
74     }
75   }
76   else
77   {
78     gp_Ax3 Axis(gp::Origin(), gp::DZ(), gp::DX());
79
80     if (!AxeProf)
81     {
82       Standard_Boolean POS;
83       BRepFill::Axe(Spine, Profil, Axis, POS, Max(Tol, Precision::Confusion()));
84       if (ProfOnSpine && !POS) return;
85     }
86     if (Spine.ShapeType() == TopAbs_WIRE)
87     {
88       myEvolved.Perform(TopoDS::Wire(Spine), Profil, Axis, Join, Solid);
89     }
90     else
91     {
92       myEvolved.Perform(TopoDS::Face(Spine), Profil, Axis, Join, Solid);
93     }
94   }
95
96   Build();
97 }
98
99 //=======================================================================
100 //function : BRepFill_Evolved&
101 //purpose  : 
102 //=======================================================================
103
104 const BRepFill_Evolved& BRepOffsetAPI_MakeEvolved::Evolved() const
105 {
106   if (myIsVolume)
107   {
108     Standard_TypeMismatch::Raise ("BRepOffsetAPI_MakeEvolved: myEvolved is accessed while in volume mode");
109   }
110   return myEvolved;
111 }
112
113 //=======================================================================
114 //function : Build
115 //purpose  : 
116 //=======================================================================
117 void BRepOffsetAPI_MakeEvolved::Build()
118 {
119   if (myEvolved.IsDone())
120   {
121     myShape = myEvolved.Shape();
122   }
123   else if (myVolume.IsDone())
124   {
125     myShape = myVolume.Shape();
126   }
127   
128   Done();
129 }
130
131 //=======================================================================
132 //function : Top
133 //purpose  : 
134 //=======================================================================
135 const TopoDS_Shape&  BRepOffsetAPI_MakeEvolved::Top() const 
136 {
137   return myEvolved.Top();
138 }
139
140 //=======================================================================
141 //function : Bottom
142 //purpose  : 
143 //=======================================================================
144 const TopoDS_Shape&  BRepOffsetAPI_MakeEvolved::Bottom() const 
145 {
146   return myEvolved.Bottom();
147 }
148
149 //=======================================================================
150 //function : GeneratedShapes
151 //purpose  : 
152 //=======================================================================
153 const TopTools_ListOfShape&
154         BRepOffsetAPI_MakeEvolved::GeneratedShapes(const TopoDS_Shape& SpineShape,
155                                                    const TopoDS_Shape& ProfShape) const 
156 {
157   if (!myEvolved.IsDone())
158     return anEmptyList;
159
160   return myEvolved.GeneratedShapes(SpineShape,ProfShape);
161 }