b311480e |
1 | // Created on: 1996-02-13 |
2 | // Created by: Yves FRICAUD |
3 | // Copyright (c) 1996-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 | |
7fd59977 |
18 | #include <BRepOffset_MakeOffset.hxx> |
42cf5bc1 |
19 | #include <BRepOffsetAPI_MakeThickSolid.hxx> |
7fd59977 |
20 | #include <Standard_ConstructionError.hxx> |
7fd59977 |
21 | #include <TopoDS.hxx> |
42cf5bc1 |
22 | #include <TopoDS_Shape.hxx> |
23 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
7fd59977 |
24 | |
8013367c |
25 | |
7fd59977 |
26 | //======================================================================= |
27 | //function : BRepOffsetAPI_MakeThickSolid |
28 | //purpose : |
29 | //======================================================================= |
7fd59977 |
30 | BRepOffsetAPI_MakeThickSolid::BRepOffsetAPI_MakeThickSolid() |
31 | { |
8013367c |
32 | // Build only solids. |
33 | mySimpleOffsetShape.SetBuildSolidFlag(Standard_True); |
7fd59977 |
34 | } |
35 | |
7fd59977 |
36 | //======================================================================= |
37 | //function : BRepOffsetAPI_MakeThickSolid |
38 | //purpose : |
39 | //======================================================================= |
8013367c |
40 | BRepOffsetAPI_MakeThickSolid::BRepOffsetAPI_MakeThickSolid(const TopoDS_Shape& S, |
41 | const TopTools_ListOfShape& ClosingFaces, |
42 | const Standard_Real Offset, |
43 | const Standard_Real Tol, |
44 | const BRepOffset_Mode Mode, |
45 | const Standard_Boolean Intersection, |
46 | const Standard_Boolean SelfInter, |
47 | const GeomAbs_JoinType Join, |
48 | const Standard_Boolean RemoveIntEdges) |
49 | { |
50 | // Build only solids. |
51 | mySimpleOffsetShape.SetBuildSolidFlag(Standard_True); |
52 | |
53 | MakeThickSolidByJoin(S, ClosingFaces, Offset, Tol, |
54 | Mode, Intersection, SelfInter, Join, RemoveIntEdges); |
55 | } |
7fd59977 |
56 | |
8013367c |
57 | //======================================================================= |
58 | //function : MakeThickSolidByJoin |
59 | //purpose : |
60 | //======================================================================= |
61 | void BRepOffsetAPI_MakeThickSolid::MakeThickSolidByJoin |
62 | (const TopoDS_Shape& S, |
7fd59977 |
63 | const TopTools_ListOfShape& ClosingFaces, |
64 | const Standard_Real Offset, |
65 | const Standard_Real Tol, |
66 | const BRepOffset_Mode Mode, |
67 | const Standard_Boolean Intersection, |
68 | const Standard_Boolean SelfInter, |
9b7f3f83 |
69 | const GeomAbs_JoinType Join, |
70 | const Standard_Boolean RemoveIntEdges) |
7fd59977 |
71 | { |
8013367c |
72 | NotDone(); |
73 | myLastUsedAlgo = OffsetAlgo_JOIN; |
74 | |
9b7f3f83 |
75 | myOffsetShape.Initialize (S,Offset,Tol,Mode,Intersection,SelfInter, |
76 | Join, Standard_False, RemoveIntEdges); |
7fd59977 |
77 | TopTools_ListIteratorOfListOfShape it(ClosingFaces); |
8013367c |
78 | for (; it.More(); it.Next()) |
7fd59977 |
79 | myOffsetShape.AddFace(TopoDS::Face(it.Value())); |
8013367c |
80 | |
81 | myOffsetShape.MakeThickSolid(); |
82 | if (!myOffsetShape.IsDone()) |
83 | return; |
84 | |
85 | myShape = myOffsetShape.Shape(); |
86 | Done(); |
7fd59977 |
87 | } |
88 | |
89 | //======================================================================= |
8013367c |
90 | //function : MakeThickSolidBySimple |
7fd59977 |
91 | //purpose : |
92 | //======================================================================= |
8013367c |
93 | void BRepOffsetAPI_MakeThickSolid::MakeThickSolidBySimple(const TopoDS_Shape& theS, |
94 | const Standard_Real theOffsetValue) |
95 | { |
96 | NotDone(); |
97 | myLastUsedAlgo = OffsetAlgo_SIMPLE; |
98 | |
99 | mySimpleOffsetShape.Initialize(theS, theOffsetValue); |
100 | mySimpleOffsetShape.Perform(); |
101 | |
102 | if (!mySimpleOffsetShape.IsDone()) |
103 | return; |
7fd59977 |
104 | |
8013367c |
105 | myShape = mySimpleOffsetShape.GetResultShape(); |
106 | Done(); |
107 | } |
108 | |
109 | //======================================================================= |
110 | //function : Build |
111 | //purpose : |
112 | //======================================================================= |
7fd59977 |
113 | void BRepOffsetAPI_MakeThickSolid::Build() |
114 | { |
7fd59977 |
115 | } |
116 | |
7fd59977 |
117 | //======================================================================= |
118 | //function : Modified |
119 | //purpose : |
120 | //======================================================================= |
8013367c |
121 | const TopTools_ListOfShape& BRepOffsetAPI_MakeThickSolid::Modified (const TopoDS_Shape& F) |
7fd59977 |
122 | { |
123 | myGenerated.Clear(); |
8013367c |
124 | |
125 | if (myLastUsedAlgo == OffsetAlgo_JOIN && myOffsetShape.OffsetFacesFromShapes().HasImage(F)) |
126 | { |
127 | if (myOffsetShape.ClosingFaces().Contains(F)) |
128 | { |
129 | myOffsetShape.OffsetFacesFromShapes().LastImage (F, myGenerated); |
130 | |
131 | // Reverse generated shapes in case of small solids. |
132 | // Useful only for faces without influence on others. |
7fd59977 |
133 | TopTools_ListIteratorOfListOfShape it(myGenerated); |
134 | for (; it.More(); it.Next()) |
8013367c |
135 | it.Value().Reverse(); |
7fd59977 |
136 | } |
137 | } |
8013367c |
138 | else if (myLastUsedAlgo == OffsetAlgo_SIMPLE) |
139 | { |
140 | TopoDS_Shape aModShape = mySimpleOffsetShape.Modified(F); |
141 | if (!aModShape.IsNull()) |
142 | myGenerated.Append(aModShape); |
143 | } |
144 | |
7fd59977 |
145 | return myGenerated; |
146 | } |