1 // Created on: 1996-02-13
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1996-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 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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <BRepOffset_MakeOffset.hxx>
19 #include <BRepOffsetAPI_MakeThickSolid.hxx>
20 #include <Standard_ConstructionError.hxx>
22 #include <TopoDS_Shape.hxx>
23 #include <TopTools_ListIteratorOfListOfShape.hxx>
26 //=======================================================================
27 //function : BRepOffsetAPI_MakeThickSolid
29 //=======================================================================
30 BRepOffsetAPI_MakeThickSolid::BRepOffsetAPI_MakeThickSolid()
33 mySimpleOffsetShape.SetBuildSolidFlag(Standard_True);
36 //=======================================================================
37 //function : MakeThickSolidByJoin
39 //=======================================================================
40 void BRepOffsetAPI_MakeThickSolid::MakeThickSolidByJoin
41 (const TopoDS_Shape& S,
42 const TopTools_ListOfShape& ClosingFaces,
43 const Standard_Real Offset,
44 const Standard_Real Tol,
45 const BRepOffset_Mode Mode,
46 const Standard_Boolean Intersection,
47 const Standard_Boolean SelfInter,
48 const GeomAbs_JoinType Join,
49 const Standard_Boolean RemoveIntEdges)
52 myLastUsedAlgo = OffsetAlgo_JOIN;
54 myOffsetShape.Initialize (S,Offset,Tol,Mode,Intersection,SelfInter,
55 Join, Standard_False, RemoveIntEdges);
56 TopTools_ListIteratorOfListOfShape it(ClosingFaces);
57 for (; it.More(); it.Next())
58 myOffsetShape.AddFace(TopoDS::Face(it.Value()));
60 myOffsetShape.MakeThickSolid();
61 if (!myOffsetShape.IsDone())
64 myShape = myOffsetShape.Shape();
68 //=======================================================================
69 //function : MakeThickSolidBySimple
71 //=======================================================================
72 void BRepOffsetAPI_MakeThickSolid::MakeThickSolidBySimple(const TopoDS_Shape& theS,
73 const Standard_Real theOffsetValue)
76 myLastUsedAlgo = OffsetAlgo_SIMPLE;
78 mySimpleOffsetShape.Initialize(theS, theOffsetValue);
79 mySimpleOffsetShape.Perform();
81 if (!mySimpleOffsetShape.IsDone())
84 myShape = mySimpleOffsetShape.GetResultShape();
88 //=======================================================================
91 //=======================================================================
92 void BRepOffsetAPI_MakeThickSolid::Build()
96 //=======================================================================
99 //=======================================================================
100 const TopTools_ListOfShape& BRepOffsetAPI_MakeThickSolid::Modified (const TopoDS_Shape& F)
104 if (myLastUsedAlgo == OffsetAlgo_JOIN && myOffsetShape.OffsetFacesFromShapes().HasImage(F))
106 if (myOffsetShape.ClosingFaces().Contains(F))
108 myOffsetShape.OffsetFacesFromShapes().LastImage (F, myGenerated);
110 // Reverse generated shapes in case of small solids.
111 // Useful only for faces without influence on others.
112 TopTools_ListIteratorOfListOfShape it(myGenerated);
113 for (; it.More(); it.Next())
114 it.Value().Reverse();
117 else if (myLastUsedAlgo == OffsetAlgo_SIMPLE)
119 TopoDS_Shape aModShape = mySimpleOffsetShape.Modified(F);
120 if (!aModShape.IsNull())
121 myGenerated.Append(aModShape);