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()
49 myDone(Standard_False),
50 myIsTrans(Standard_False)
55 //=======================================================================
58 //=======================================================================
60 void LocOpe_RevolutionForm::Perform(const TopoDS_Shape& Base,
62 const Standard_Real Angle)
65 myFirstShape.Nullify();
66 myLastShape.Nullify();
73 myIsTrans = Standard_False;
78 //=======================================================================
81 //=======================================================================
83 void LocOpe_RevolutionForm::IntPerf()
85 TopoDS_Shape theBase = myBase;
86 BRepTools_Modifier Modif;
89 T.SetRotation(myAxis,myAngTra);
90 Handle(BRepTools_TrsfModification) modbase =
91 new BRepTools_TrsfModification(T);
93 Modif.Perform(modbase);
94 theBase = Modif.ModifiedShape(theBase);
97 BRepSweep_Revol theRevol(theBase,myAxis,myAngle);
99 myFirstShape = theRevol.FirstShape();
100 myLastShape = theRevol.LastShape();
103 if (theBase.ShapeType() == TopAbs_FACE) {
104 for (exp.Init(theBase,TopAbs_EDGE);exp.More();exp.Next()) {
105 const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
106 if (!myMap.IsBound(edg)) {
107 TopTools_ListOfShape thelist;
108 myMap.Bind(edg, thelist);
109 TopoDS_Shape desc = theRevol.Shape(edg);
110 if (!desc.IsNull()) {
111 myMap(edg).Append(desc);
115 myRes = theRevol.Shape();
120 TopTools_IndexedDataMapOfShapeListOfShape theEFMap;
121 TopExp::MapShapesAndAncestors(theBase,TopAbs_EDGE,TopAbs_FACE,theEFMap);
122 TopTools_ListOfShape lfaces;
123 Standard_Boolean toremove = Standard_False;
124 for (Standard_Integer i=1; i<=theEFMap.Extent(); i++) {
125 const TopoDS_Shape& edg = theEFMap.FindKey(i);
126 TopTools_ListOfShape thelist1;
127 myMap.Bind(edg, thelist1);
128 TopoDS_Shape desc = theRevol.Shape(edg);
129 if (!desc.IsNull()) {
130 if (theEFMap(i).Extent() >= 2) {
131 toremove = Standard_True;
134 myMap(edg).Append(desc);
140 // Rajouter les faces de FirstShape et LastShape
141 for (exp.Init(myFirstShape,TopAbs_FACE);exp.More();exp.Next()) {
142 lfaces.Append(exp.Current());
144 for (exp.Init(myLastShape,TopAbs_FACE);exp.More();exp.Next()) {
145 lfaces.Append(exp.Current());
148 LocOpe_BuildShape BS(lfaces);
152 for (exp.Init(theBase,TopAbs_EDGE);exp.More();exp.Next()) {
153 const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
154 if (!myMap.IsBound(edg)) {
155 TopTools_ListOfShape thelist2;
156 myMap.Bind(edg, thelist2);
157 TopoDS_Shape desc = theRevol.Shape(edg);
158 if (!desc.IsNull()) {
159 myMap(edg).Append(desc);
163 myRes = theRevol.Shape();
168 // m-a-j des descendants
169 TopExp_Explorer anExp;
170 for (anExp.Init(myBase,TopAbs_EDGE); anExp.More(); anExp.Next()) {
171 const TopoDS_Edge& edg = TopoDS::Edge(anExp.Current());
172 const TopoDS_Edge& edgbis = TopoDS::Edge(Modif.ModifiedShape(edg));
173 if (!edgbis.IsSame(edg) && myMap.IsBound(edgbis)) {
174 myMap.Bind(edg,myMap(edgbis));
175 myMap.UnBind(edgbis);
179 myDone = Standard_True;
182 //=======================================================================
185 //=======================================================================
187 const TopoDS_Shape& LocOpe_RevolutionForm::Shape () const
190 throw StdFail_NotDone();
196 //=======================================================================
197 //function : FirstShape
199 //=======================================================================
201 const TopoDS_Shape& LocOpe_RevolutionForm::FirstShape () const
206 //=======================================================================
207 //function : LastShape
209 //=======================================================================
211 const TopoDS_Shape& LocOpe_RevolutionForm::LastShape () const
217 //=======================================================================
220 //=======================================================================
222 const TopTools_ListOfShape& LocOpe_RevolutionForm::Shapes (const TopoDS_Shape& S) const