1 // Created on: 1997-10-20
2 // Created by: Olga KOULECHOVA
3 // Copyright (c) 1997-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 <BRepLib_MakeVertex.hxx>
19 #include <BRepSweep_Revol.hxx>
20 #include <BRepTools_Modifier.hxx>
21 #include <BRepTools_TrsfModification.hxx>
22 #include <Geom_Circle.hxx>
23 #include <Geom_Curve.hxx>
25 #include <gp_Circ.hxx>
26 #include <gp_Trsf.hxx>
29 #include <LocOpe_BuildShape.hxx>
30 #include <LocOpe_RevolutionForm.hxx>
31 #include <Precision.hxx>
32 #include <Standard_NoSuchObject.hxx>
33 #include <StdFail_NotDone.hxx>
34 #include <TColgp_SequenceOfPnt.hxx>
36 #include <TopExp_Explorer.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS_Shape.hxx>
40 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
42 //=======================================================================
43 //function : LocOpe_Revol
45 //=======================================================================
46 LocOpe_RevolutionForm::LocOpe_RevolutionForm() : myDone(Standard_False)
51 //=======================================================================
54 //=======================================================================
56 void LocOpe_RevolutionForm::Perform(const TopoDS_Shape& Base,
58 const Standard_Real Angle)
61 myFirstShape.Nullify();
62 myLastShape.Nullify();
69 myIsTrans = Standard_False;
74 //=======================================================================
77 //=======================================================================
79 void LocOpe_RevolutionForm::IntPerf()
81 TopoDS_Shape theBase = myBase;
82 BRepTools_Modifier Modif;
85 T.SetRotation(myAxis,myAngTra);
86 Handle(BRepTools_TrsfModification) modbase =
87 new BRepTools_TrsfModification(T);
89 Modif.Perform(modbase);
90 theBase = Modif.ModifiedShape(theBase);
93 BRepSweep_Revol theRevol(theBase,myAxis,myAngle);
95 myFirstShape = theRevol.FirstShape();
96 myLastShape = theRevol.LastShape();
99 if (theBase.ShapeType() == TopAbs_FACE) {
100 for (exp.Init(theBase,TopAbs_EDGE);exp.More();exp.Next()) {
101 const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
102 if (!myMap.IsBound(edg)) {
103 TopTools_ListOfShape thelist;
104 myMap.Bind(edg, thelist);
105 TopoDS_Shape desc = theRevol.Shape(edg);
106 if (!desc.IsNull()) {
107 myMap(edg).Append(desc);
111 myRes = theRevol.Shape();
116 TopTools_IndexedDataMapOfShapeListOfShape theEFMap;
117 TopExp::MapShapesAndAncestors(theBase,TopAbs_EDGE,TopAbs_FACE,theEFMap);
118 TopTools_ListOfShape lfaces;
119 Standard_Boolean toremove = Standard_False;
120 for (Standard_Integer i=1; i<=theEFMap.Extent(); i++) {
121 const TopoDS_Shape& edg = theEFMap.FindKey(i);
122 TopTools_ListOfShape thelist1;
123 myMap.Bind(edg, thelist1);
124 TopoDS_Shape desc = theRevol.Shape(edg);
125 if (!desc.IsNull()) {
126 if (theEFMap(i).Extent() >= 2) {
127 toremove = Standard_True;
130 myMap(edg).Append(desc);
136 // Rajouter les faces de FirstShape et LastShape
137 for (exp.Init(myFirstShape,TopAbs_FACE);exp.More();exp.Next()) {
138 lfaces.Append(exp.Current());
140 for (exp.Init(myLastShape,TopAbs_FACE);exp.More();exp.Next()) {
141 lfaces.Append(exp.Current());
144 LocOpe_BuildShape BS(lfaces);
148 for (exp.Init(theBase,TopAbs_EDGE);exp.More();exp.Next()) {
149 const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
150 if (!myMap.IsBound(edg)) {
151 TopTools_ListOfShape thelist2;
152 myMap.Bind(edg, thelist2);
153 TopoDS_Shape desc = theRevol.Shape(edg);
154 if (!desc.IsNull()) {
155 myMap(edg).Append(desc);
159 myRes = theRevol.Shape();
164 // m-a-j des descendants
165 TopExp_Explorer anExp;
166 for (anExp.Init(myBase,TopAbs_EDGE); anExp.More(); anExp.Next()) {
167 const TopoDS_Edge& edg = TopoDS::Edge(anExp.Current());
168 const TopoDS_Edge& edgbis = TopoDS::Edge(Modif.ModifiedShape(edg));
169 if (!edgbis.IsSame(edg) && myMap.IsBound(edgbis)) {
170 myMap.Bind(edg,myMap(edgbis));
171 myMap.UnBind(edgbis);
175 myDone = Standard_True;
178 //=======================================================================
181 //=======================================================================
183 const TopoDS_Shape& LocOpe_RevolutionForm::Shape () const
186 throw StdFail_NotDone();
192 //=======================================================================
193 //function : FirstShape
195 //=======================================================================
197 const TopoDS_Shape& LocOpe_RevolutionForm::FirstShape () const
202 //=======================================================================
203 //function : LastShape
205 //=======================================================================
207 const TopoDS_Shape& LocOpe_RevolutionForm::LastShape () const
213 //=======================================================================
216 //=======================================================================
218 const TopTools_ListOfShape& LocOpe_RevolutionForm::Shapes (const TopoDS_Shape& S) const