1 // Created on: 1994-07-12
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1994-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_Pipe.hxx>
19 #include <BRepOffsetAPI_MakePipe.hxx>
20 #include <TopAbs_ShapeEnum.hxx>
21 #include <TopExp.hxx>
22 #include <TopExp_Explorer.hxx>
23 #include <TopoDS.hxx>
24 #include <TopoDS_Edge.hxx>
25 #include <TopoDS_Face.hxx>
26 #include <TopoDS_Shape.hxx>
27 #include <TopoDS_Vertex.hxx>
28 #include <TopoDS_Wire.hxx>
29 #include <TopTools_IndexedMapOfShape.hxx>
30
31 //=======================================================================
32 //function : BRepOffsetAPI_MakePipe
33 //purpose : constructor
34 //=======================================================================
BRepOffsetAPI_MakePipe(const TopoDS_Wire & Spine,const TopoDS_Shape & Profile)35 BRepOffsetAPI_MakePipe::BRepOffsetAPI_MakePipe(const TopoDS_Wire& Spine ,
36 const TopoDS_Shape& Profile)
37 : myPipe(Spine, Profile)
38 {
39 Build();
40 }
41
42 //=======================================================================
43 //function : BRepOffsetAPI_MakePipe
44 //purpose : constructor
45 // Set the mode of sweeping
46 // It can be:
47 // - Frenet
48 // - Corrected Frenet
49 // - Discrete Trihedron
50 // Also set the flag that indicates attempt to approximate
51 // a C1-continuous surface if a swept surface proved
52 // to be C0.
53 //=======================================================================
54
BRepOffsetAPI_MakePipe(const TopoDS_Wire & Spine,const TopoDS_Shape & Profile,const GeomFill_Trihedron aMode,const Standard_Boolean ForceApproxC1)55 BRepOffsetAPI_MakePipe::BRepOffsetAPI_MakePipe(const TopoDS_Wire& Spine ,
56 const TopoDS_Shape& Profile,
57 const GeomFill_Trihedron aMode,
58 const Standard_Boolean ForceApproxC1)
59 : myPipe(Spine, Profile, aMode, ForceApproxC1)
60 {
61 Build();
62 }
63
64 //=======================================================================
65 //function : Pipe
66 //purpose :
67 //=======================================================================
68
Pipe() const69 const BRepFill_Pipe& BRepOffsetAPI_MakePipe::Pipe() const
70 {
71 return myPipe;
72 }
73
74
75 //=======================================================================
76 //function : Build
77 //purpose :
78 //=======================================================================
79
Build(const Message_ProgressRange &)80 void BRepOffsetAPI_MakePipe::Build(const Message_ProgressRange& /*theRange*/)
81 {
82 myShape = myPipe.Shape();
83 //Check for emptiness of result
84 TopTools_IndexedMapOfShape theMap;
85 TopExp::MapShapes(myShape, theMap);
86 if (theMap.Extent() == 1)
87 NotDone();
88 else
89 Done();
90 }
91
92
93 //=======================================================================
94 //function : FirstShape
95 //purpose :
96 //=======================================================================
97
FirstShape()98 TopoDS_Shape BRepOffsetAPI_MakePipe::FirstShape()
99 {
100 return myPipe.FirstShape();
101 }
102
103
104 //=======================================================================
105 //function : LastShape
106 //purpose :
107 //=======================================================================
108
LastShape()109 TopoDS_Shape BRepOffsetAPI_MakePipe::LastShape()
110 {
111 return myPipe.LastShape();
112 }
113
114 //=======================================================================
115 //function : Generated
116 //purpose : standard method
117 //=======================================================================
Generated(const TopoDS_Shape & S)118 const TopTools_ListOfShape& BRepOffsetAPI_MakePipe::Generated(const TopoDS_Shape& S)
119 {
120 myPipe.Generated(S, myGenerated);
121 return myGenerated;
122 }
123
124 //=======================================================================
125 //function : Generated
126 //purpose : returns generated elementary subshape
127 //=======================================================================
128
Generated(const TopoDS_Shape & SSpine,const TopoDS_Shape & SProfile)129 TopoDS_Shape BRepOffsetAPI_MakePipe::Generated(const TopoDS_Shape& SSpine,
130 const TopoDS_Shape& SProfile)
131 {
132 if (SProfile.ShapeType () == TopAbs_EDGE) {
133 return myPipe.Face (TopoDS::Edge (SSpine), TopoDS::Edge (SProfile));
134 }
135 else if (SProfile.ShapeType () == TopAbs_VERTEX) {
136 return myPipe.Edge (TopoDS::Edge (SSpine), TopoDS::Vertex (SProfile));
137 }
138
139 //POP pour NT
140 TopoDS_Shape bid;
141 return bid;
142 }
143
144 //=======================================================================
145 //function : ErrorOnSurface
146 //purpose :
147 //=======================================================================
148
ErrorOnSurface() const149 Standard_Real BRepOffsetAPI_MakePipe::ErrorOnSurface() const
150 {
151 return myPipe.ErrorOnSurface();
152 }
153