1 // Created on: 1996-09-03
2 // Created by: Jacques GOUSSARD
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.
17 #include <BRepFeat_MakePipe.ixx>
19 #include <BRepFeat.hxx>
22 //modified by NIZNHY-PKV Thu Mar 21 17:54:27 2002 f
23 //#include <BRepAlgo_Fuse.hxx>
24 //#include <BRepAlgo_Cut.hxx>
25 #include <BRepAlgoAPI_Fuse.hxx>
26 #include <BRepAlgoAPI_Cut.hxx>
27 //modified by NIZNHY-PKV Thu Mar 21 17:54:30 2002 t
31 #include <gp_Pnt2d.hxx>
32 #include <TColgp_SequenceOfPnt.hxx>
33 #include <Geom_Curve.hxx>
34 #include <Geom_Line.hxx>
36 #include <LocOpe_Pipe.hxx>
38 #include <BRep_Tool.hxx>
39 #include <TopExp_Explorer.hxx>
40 #include <TopTools_MapOfShape.hxx>
41 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
42 #include <TopTools_ListIteratorOfListOfShape.hxx>
43 #include <TopTools_MapIteratorOfMapOfShape.hxx>
44 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
46 #include <Bnd_Box.hxx>
47 #include <TopoDS_Face.hxx>
48 #include <TopoDS_Shape.hxx>
51 #include <Standard_ConstructionError.hxx>
54 #include <BRepBndLib.hxx>
57 extern Standard_Boolean BRepFeat_GettraceFEAT();
60 static void MajMap(const TopoDS_Shape&, // base
62 TopTools_DataMapOfShapeListOfShape&, // myMap
63 TopoDS_Shape&, // myFShape
64 TopoDS_Shape&); // myLShape
66 //=======================================================================
69 //=======================================================================
71 void BRepFeat_MakePipe::Init(const TopoDS_Shape& Sbase,
72 const TopoDS_Shape& Pbase,
73 const TopoDS_Face& Skface,
74 const TopoDS_Wire& Spine,
75 const Standard_Integer Mode,
76 const Standard_Boolean Modify)
79 Standard_Boolean trc = BRepFeat_GettraceFEAT();
80 if (trc) cout << "BRepFeat_MakePipe::Init" << endl;
90 myFuse = Standard_False;
91 myJustFeat = Standard_False;
94 myFuse = Standard_True;
95 myJustFeat = Standard_False;
98 myFuse = Standard_True;
99 myJustFeat = Standard_True;
104 myJustGluer = Standard_False;
108 //mySkface.Nullify();
116 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
117 TopTools_ListOfShape thelist;
118 myMap.Bind(exp.Current(), thelist);
119 myMap(exp.Current()).Append(exp.Current());
123 if (myJustFeat) cout << " Just Feature" << endl;
124 if (myFuse) cout << " Fuse" << endl;
125 if (!myFuse) cout << " Cut" << endl;
126 if (!myModify) cout << " Modify = 0" << endl;
132 //=======================================================================
134 //purpose : add faces of gluing
135 //=======================================================================
137 void BRepFeat_MakePipe::Add(const TopoDS_Edge& E,
138 const TopoDS_Face& F)
141 Standard_Boolean trc = BRepFeat_GettraceFEAT();
142 if (trc) cout << "BRepFeat_MakePipe::Add(Edge,face)" << endl;
145 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
146 if (exp.Current().IsSame(F)) {
151 Standard_ConstructionError::Raise();
154 for (exp.Init(myPbase,TopAbs_EDGE);exp.More();exp.Next()) {
155 if (exp.Current().IsSame(E)) {
160 Standard_ConstructionError::Raise();
163 if (!mySlface.IsBound(F)) {
164 TopTools_ListOfShape thelist1;
165 mySlface.Bind(F,thelist1);
167 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
168 for (; itl.More();itl.Next()) {
169 if (itl.Value().IsSame(E)) {
174 mySlface(F).Append(E);
179 //=======================================================================
182 //=======================================================================
184 void BRepFeat_MakePipe::Perform()
187 Standard_Boolean trc = BRepFeat_GettraceFEAT();
188 if (trc) cout << "BRepFeat_MakePipe::Perform()" << endl;
195 myPerfSelection = BRepFeat_NoSelection;
196 PerfSelectionValid();
197 TopoDS_Shape theBase = myPbase;
198 LocOpe_Pipe thePipe(mySpine,theBase);
199 TopoDS_Shape VraiPipe = thePipe.Shape();
200 MajMap(myPbase,thePipe,myMap,myFShape,myLShape);
202 GeneratedShapeValid();
206 if(myGluedF.IsEmpty()) {
208 //modified by NIZNHY-PKV Thu Mar 21 17:53:05 2002 f
209 //BRepAlgo_Fuse f(mySbase, myGShape);
210 //myShape = f.Shape();
211 //UpdateDescendants(f.Builder(), myShape, Standard_False);
212 BRepAlgoAPI_Fuse f(mySbase, myGShape);
214 UpdateDescendants(f, myShape, Standard_False);
215 //modified by NIZNHY-PKV Thu Mar 21 17:53:10 2002 t
218 else if(myFuse == 0) {
219 //modified by NIZNHY-PKV Thu Mar 21 17:53:37 2002 f
220 //BRepAlgo_Cut c(mySbase, myGShape);
221 //myShape = c.Shape();
222 //UpdateDescendants(c.Builder(), myShape, Standard_False);
223 BRepAlgoAPI_Cut c(mySbase, myGShape);
225 UpdateDescendants(c, myShape, Standard_False);
226 //modified by NIZNHY-PKV Thu Mar 21 17:53:50 2002 t
235 myFShape = thePipe.FirstShape();
236 TColgp_SequenceOfPnt spt;
237 LocOpe::SampleEdges(myFShape,spt);
238 myCurves = thePipe.Curves(spt);
239 myBCurve = thePipe.BarycCurve();
245 //=======================================================================
247 //purpose : till shape Until
248 //=======================================================================
250 void BRepFeat_MakePipe::Perform(const TopoDS_Shape& Until)
253 Standard_Boolean trc = BRepFeat_GettraceFEAT();
254 if (trc) cout << "BRepFeat_MakePipe::Perform(Until)" << endl;
256 if (Until.IsNull()) {
257 Standard_ConstructionError::Raise();
259 TopExp_Explorer exp(Until, TopAbs_FACE);
261 Standard_ConstructionError::Raise();
264 myPerfSelection = BRepFeat_SelectionU;
265 PerfSelectionValid();
271 LocOpe_Pipe thePipe(mySpine,myPbase);
272 TopoDS_Shape VraiTuyau = thePipe.Shape();
273 MajMap(myPbase,thePipe,myMap,myFShape,myLShape);
274 myGShape = VraiTuyau;
275 GeneratedShapeValid();
279 myFShape = thePipe.FirstShape();
280 TColgp_SequenceOfPnt spt;
281 LocOpe::SampleEdges(myFShape,spt);
282 myCurves = thePipe.Curves(spt);
283 myBCurve = thePipe.BarycCurve();
288 //=======================================================================
290 //purpose : between From and Until
291 //=======================================================================
293 void BRepFeat_MakePipe::Perform(const TopoDS_Shape& From,
294 const TopoDS_Shape& Until)
297 Standard_Boolean trc = BRepFeat_GettraceFEAT();
298 if (trc) cout << "BRepFeat_MakePipe::Perform(From,Until)" << endl;
300 if (From.IsNull() || Until.IsNull()) {
301 Standard_ConstructionError::Raise();
303 if (!mySkface.IsNull()) {
304 if (From.IsSame(mySkface)) {
308 else if (Until.IsSame(mySkface)) {
314 myPerfSelection = BRepFeat_SelectionFU;
315 PerfSelectionValid();
316 TopExp_Explorer exp(From, TopAbs_FACE);
318 Standard_ConstructionError::Raise();
320 exp.Init(Until, TopAbs_FACE);
322 Standard_ConstructionError::Raise();
330 LocOpe_Pipe thePipe(mySpine,myPbase);
331 TopoDS_Shape VraiTuyau = thePipe.Shape();
332 MajMap(myPbase,thePipe,myMap,myFShape,myLShape);
333 myGShape = VraiTuyau;
334 GeneratedShapeValid();
336 // mySbase, myPbase, mySlface, thePipe, myGluedF);
339 myFShape = thePipe.FirstShape();
340 TColgp_SequenceOfPnt spt;
341 LocOpe::SampleEdges(myFShape,spt);
342 myCurves = thePipe.Curves(spt);
343 myBCurve = thePipe.BarycCurve();
348 //=======================================================================
350 //purpose : curves parallel to the generating wire of the pipe
351 //=======================================================================
353 void BRepFeat_MakePipe::Curves(TColGeom_SequenceOfCurve& scur)
358 //=======================================================================
359 //function : BarycCurve
360 //purpose : pass through the center of mass
361 //=======================================================================
363 Handle(Geom_Curve) BRepFeat_MakePipe::BarycCurve()
368 //=======================================================================
370 //purpose : management of descendants
371 //=======================================================================
373 static void MajMap(const TopoDS_Shape& theB,
375 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
376 TopoDS_Shape& theFShape, // myFShape
377 TopoDS_Shape& theLShape) // myLShape
379 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
381 theFShape = exp.Current();
382 TopTools_ListOfShape thelist2;
383 theMap.Bind(theFShape, thelist2);
384 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
385 theMap(theFShape).Append(exp.Current());
389 exp.Init(theP.LastShape(),TopAbs_WIRE);
391 theLShape = exp.Current();
392 TopTools_ListOfShape thelist3;
393 theMap.Bind(theLShape, thelist3);
394 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
395 theMap(theLShape).Append(exp.Current());
399 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
400 if (!theMap.IsBound(exp.Current())) {
401 TopTools_ListOfShape thelist4;
402 theMap.Bind(exp.Current(), thelist4);
403 theMap(exp.Current()) = theP.Shapes(exp.Current());