1 // Created on: 1993-06-10
2 // Created by: Laurent BOURESCHE
3 // Copyright (c) 1993-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 <BRep_Builder.hxx>
19 #include <BRep_Tool.hxx>
20 #include <BRepAdaptor_Curve.hxx>
21 #include <BRepLProp.hxx>
22 #include <BRepSweep_Iterator.hxx>
23 #include <BRepSweep_Trsf.hxx>
24 #include <GeomAbs_Shape.hxx>
25 #include <Precision.hxx>
26 #include <Sweep_NumShape.hxx>
27 #include <Sweep_NumShapeIterator.hxx>
29 #include <TopLoc_Location.hxx>
31 #include <TopoDS_Face.hxx>
32 #include <TopoDS_Shape.hxx>
33 #include <TopoDS_Vertex.hxx>
34 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
35 #include <TopTools_ListIteratorOfListOfShape.hxx>
37 BRepSweep_Trsf::BRepSweep_Trsf(const BRep_Builder& aBuilder,
38 const TopoDS_Shape& aGenShape,
39 const Sweep_NumShape& aDirWire,
40 const TopLoc_Location& aLocation,
41 const Standard_Boolean aCopy):
42 BRepSweep_NumLinearRegularSweep(aBuilder,aGenShape,aDirWire),
43 myLocation(aLocation),
48 void BRepSweep_Trsf::Init()
51 Sweep_NumShapeIterator It;
52 for(It.Init(myDirWire);It.More();It.Next()){
53 Process(myGenShape,It.Value());
58 Standard_Boolean BRepSweep_Trsf::Process(const TopoDS_Shape& aGenS,
59 const Sweep_NumShape& aDirV)
61 Standard_Boolean dotrsf = (aDirV.Index()==2 && !myDirWire.Closed());
62 Standard_Integer iD = myDirShapeTool.Index(aDirV);
63 Standard_Integer iG = myGenShapeTool.Index(aGenS);
64 if(IsInvariant(aGenS)){
65 myShapes(iG,iD) = aGenS;
66 myBuiltShapes(iG,iD) = Standard_True;
70 BRepSweep_Iterator Jt;
71 Standard_Boolean touch = Standard_False;
72 for(Jt.Init(aGenS);Jt.More();Jt.Next()){
73 if(Process(Jt.Value(),aDirV)) touch = Standard_True;
75 if(!touch || !dotrsf){
76 TopoDS_Shape newShape = aGenS;
77 if(dotrsf) newShape.Move(myLocation);
78 myShapes(iG,iD) = newShape;
79 myBuiltShapes(iG,iD) = Standard_True;
85 //=======================================================================
86 //function : SetContinuity
88 //=======================================================================
90 void BRepSweep_Trsf::SetContinuity(const TopoDS_Shape& aGenS,
91 const Sweep_NumShape& aDirS)
93 Standard_Real tl = Precision::Confusion(), tol3d;
94 //angular etant un peu severe pour les contours sketches.
95 Standard_Real ta = 0.00175;//environ 0.1 degre
97 BRep_Builder B = myBuilder.Builder();
98 if(aGenS.ShapeType() == TopAbs_EDGE){
99 if (HasShape(aGenS,aDirS)){
100 TopoDS_Edge E = TopoDS::Edge(aGenS);
104 TopExp::Vertices(E,d,f);
106 // tol3d = Max(tl,BRep_Tool::Tolerance(d));
107 tol3d = Max(tl,2.*BRep_Tool::Tolerance(d));//IFV 24.05.00 buc60684
109 ud = BRep_Tool::Parameter(d,TopoDS::Edge(aGenS));
110 uf = BRep_Tool::Parameter(f,TopoDS::Edge(aGenS));
111 cont = BRepLProp::Continuity(e,e,ud,uf,tol3d,ta);
113 TopoDS_Shape s_wnt = Shape(d,aDirS);
114 TopoDS_Edge e_wnt = TopoDS::Edge(s_wnt);
115 s_wnt = Shape(aGenS,aDirS);
116 TopoDS_Face f_wnt = TopoDS::Face(s_wnt);
117 B.Continuity(e_wnt,f_wnt,f_wnt,cont);
121 Sweep_NumShape dirv = myDirShapeTool.Shape(2);
122 if(GDDShapeIsToAdd(Shape(aGenS,aDirS),
127 cont = BRep_Tool::Curve(E,Lo,fi,la)->Continuity();
129 TopoDS_Shape s_wnt = Shape(aGenS,dirv);
130 TopoDS_Edge e_wnt = TopoDS::Edge(s_wnt);
131 s_wnt = Shape(aGenS,aDirS);
132 TopoDS_Face f_wnt = TopoDS::Face(s_wnt);
133 B.Continuity(e_wnt,f_wnt,f_wnt,cont);
139 else if(aGenS.ShapeType() == TopAbs_WIRE){
141 BRepAdaptor_Curve e1,e2;
143 TopTools_IndexedDataMapOfShapeListOfShape M;
144 TopExp::MapShapesAndAncestors(aGenS,TopAbs_VERTEX,TopAbs_EDGE,M);
145 TopTools_ListIteratorOfListOfShape It,Jt;
146 for(Standard_Integer i = 1; i <= M.Extent(); i++){
147 TopoDS_Vertex V = TopoDS::Vertex(M.FindKey(i));
148 Standard_Integer j = 1;
149 for(It.Initialize(M.FindFromIndex(i));It.More();It.Next(),j++){
150 Jt.Initialize(M.FindFromIndex(i));
151 for(Standard_Integer k=1; k <= j; k++) { Jt.Next(); }
152 for(;Jt.More();Jt.Next()){
153 E1 = TopoDS::Edge(It.Value());
154 E2 = TopoDS::Edge(Jt.Value());
155 if (!E1.IsSame(E2) && HasShape(E1,aDirS) && HasShape(E2,aDirS)){
156 u1 = BRep_Tool::Parameter(V,E1);
157 u2 = BRep_Tool::Parameter(V,E2);
158 // tol3d = Max(tl,BRep_Tool::Tolerance(V));
159 tol3d = Max(tl,2.*BRep_Tool::Tolerance(V)); //IFV 24.05.00 buc60684
162 cont = BRepLProp::Continuity(e1,e2,u1,u2,tol3d,ta);
164 TopoDS_Shape s_wnt = Shape(V,aDirS);
165 TopoDS_Edge e_wnt = TopoDS::Edge(s_wnt);
166 s_wnt = Shape(E1,aDirS);
167 TopoDS_Face f1_wnt = TopoDS::Face(s_wnt);
168 s_wnt = Shape(E2,aDirS);
169 TopoDS_Face f2_wnt = TopoDS::Face(s_wnt);
170 B.Continuity(e_wnt,f1_wnt,f2_wnt,cont);