1 // Created on: 1996-09-04
2 // Created by: Olga PILLOT
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 <BRep_Builder.hxx>
19 #include <BRep_Tool.hxx>
20 #include <BRepLib_MakeEdge.hxx>
21 #include <BRepLib_MakeVertex.hxx>
22 #include <BRepSweep_Prism.hxx>
23 #include <BRepTools_Modifier.hxx>
24 #include <BRepTools_TrsfModification.hxx>
25 #include <Geom_Curve.hxx>
26 #include <Geom_Line.hxx>
27 #include <Geom_TrimmedCurve.hxx>
30 #include <gp_Trsf.hxx>
33 #include <LocOpe_BuildShape.hxx>
34 #include <LocOpe_LinearForm.hxx>
35 #include <Standard_NoSuchObject.hxx>
36 #include <StdFail_NotDone.hxx>
37 #include <TColgp_SequenceOfPnt.hxx>
39 #include <TopExp_Explorer.hxx>
41 #include <TopoDS_Compound.hxx>
42 #include <TopoDS_Edge.hxx>
43 #include <TopoDS_Face.hxx>
44 #include <TopoDS_Shape.hxx>
45 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
46 #include <TopTools_ListIteratorOfListOfShape.hxx>
48 //=======================================================================
51 //=======================================================================
52 void LocOpe_LinearForm::Perform(const TopoDS_Shape& Base,
58 myIsTrans = Standard_False;
60 myFirstShape.Nullify();
61 myLastShape.Nullify();
76 //=======================================================================
79 //=======================================================================
81 void LocOpe_LinearForm::Perform(const TopoDS_Shape& Base,
88 myIsTrans = Standard_True;
91 myFirstShape.Nullify();
92 myLastShape.Nullify();
107 //=======================================================================
110 //=======================================================================
112 void LocOpe_LinearForm::IntPerf()
114 TopoDS_Shape theBase = myBase;
115 BRepTools_Modifier Modif;
119 T.SetTranslation(myTra);
120 Handle(BRepTools_TrsfModification) modbase =
121 new BRepTools_TrsfModification(T);
123 Modif.Perform(modbase);
124 theBase = Modif.ModifiedShape(theBase);
127 BRepSweep_Prism myPrism(theBase, myVec);
129 myFirstShape = myPrism.FirstShape();
130 myLastShape = myPrism.LastShape();
133 if (theBase.ShapeType() == TopAbs_FACE) {
134 for (exp.Init(theBase,TopAbs_EDGE);exp.More();exp.Next()) {
135 const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
136 if (!myMap.IsBound(edg)) {
137 TopTools_ListOfShape thelist;
138 myMap.Bind(edg, thelist);
139 TopoDS_Shape desc = myPrism.Shape(edg);
140 if (!desc.IsNull()) {
141 myMap(edg).Append(desc);
145 myRes = myPrism.Shape();
150 TopTools_IndexedDataMapOfShapeListOfShape theEFMap;
151 TopExp::MapShapesAndAncestors(theBase,TopAbs_EDGE,TopAbs_FACE,theEFMap);
152 TopTools_ListOfShape lfaces;
153 Standard_Boolean toremove = Standard_False;
154 for (Standard_Integer i=1; i<=theEFMap.Extent(); i++) {
155 const TopoDS_Shape& edg = theEFMap.FindKey(i);
156 TopTools_ListOfShape thelist1;
157 myMap.Bind(edg, thelist1);
158 TopoDS_Shape desc = myPrism.Shape(edg);
159 if (!desc.IsNull()) {
160 if (theEFMap(i).Extent() >= 2) {
161 toremove = Standard_True;
164 myMap(edg).Append(desc);
170 // Rajouter les faces de FirstShape et LastShape
171 for (exp.Init(myFirstShape,TopAbs_FACE);exp.More();exp.Next()) {
172 lfaces.Append(exp.Current());
174 for (exp.Init(myLastShape,TopAbs_FACE);exp.More();exp.Next()) {
175 lfaces.Append(exp.Current());
178 LocOpe_BuildShape BS(lfaces);
182 for (exp.Init(theBase,TopAbs_EDGE);exp.More();exp.Next()) {
183 const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
184 if (!myMap.IsBound(edg)) {
185 TopTools_ListOfShape thelist2;
186 myMap.Bind(edg, thelist2);
187 TopoDS_Shape desc = myPrism.Shape(edg);
188 if (!desc.IsNull()) {
189 myMap(edg).Append(desc);
193 myRes = myPrism.Shape();
198 // m-a-j des descendants
199 TopExp_Explorer anExp;
200 for (anExp.Init(myBase,TopAbs_EDGE); anExp.More(); anExp.Next()) {
201 const TopoDS_Edge& edg = TopoDS::Edge(anExp.Current());
202 const TopoDS_Edge& edgbis = TopoDS::Edge(Modif.ModifiedShape(edg));
203 if (!edgbis.IsSame(edg) && myMap.IsBound(edgbis)) {
204 myMap.Bind(edg,myMap(edgbis));
205 myMap.UnBind(edgbis);
210 myDone = Standard_True;
213 //=======================================================================
216 //=======================================================================
218 const TopoDS_Shape& LocOpe_LinearForm::Shape () const
221 StdFail_NotDone::Raise();
227 //=======================================================================
228 //function : FirstShape
230 //=======================================================================
232 const TopoDS_Shape& LocOpe_LinearForm::FirstShape () const
237 //=======================================================================
238 //function : LastShape
240 //=======================================================================
242 const TopoDS_Shape& LocOpe_LinearForm::LastShape () const
248 //=======================================================================
251 //=======================================================================
253 const TopTools_ListOfShape& LocOpe_LinearForm::Shapes (const TopoDS_Shape& S) const