1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_Revolution.cpp
4 // Created: 12 May 2015
5 // Author: Dmitry Bobylev
7 #include <GeomAlgoAPI_Revolution.h>
9 #include <GeomAPI_Face.h>
10 #include <GeomAPI_ShapeExplorer.h>
11 #include <GeomAlgoAPI_DFLoader.h>
12 #include <GeomAlgoAPI_MakeShapeList.h>
13 #include <GeomAlgoAPI_Rotation.h>
14 #include <GeomAlgoAPI_ShapeTools.h>
16 #include <BRep_Builder.hxx>
17 #include <BRep_Tool.hxx>
18 #include <BRepAlgoAPI_Cut.hxx>
19 #include <BRepBuilderAPI_MakeEdge.hxx>
20 #include <BRepBuilderAPI_MakeFace.hxx>
21 #include <BRepBuilderAPI_Transform.hxx>
22 #include <BRepBuilderAPI_MakeWire.hxx>
23 #include <BRepCheck_Analyzer.hxx>
24 #include <BRepPrimAPI_MakeRevol.hxx>
25 #include <BRepGProp.hxx>
26 #include <BRepOffsetAPI_MakePipe.hxx>
27 #include <BRepTools.hxx>
28 #include <Geom_Circle.hxx>
29 #include <Geom_Line.hxx>
30 #include <Geom_Plane.hxx>
31 #include <GeomAPI_ProjectPointOnCurve.hxx>
32 #include <GeomLib_IsPlanarSurface.hxx>
33 #include <gp_Circ.hxx>
35 #include <GProp_GProps.hxx>
36 #include <TopExp_Explorer.hxx>
38 #include <TopTools_ListIteratorOfListOfShape.hxx>
40 //=================================================================================================
41 GeomAlgoAPI_Revolution::GeomAlgoAPI_Revolution(std::shared_ptr<GeomAPI_Shape> theBasis,
42 std::shared_ptr<GeomAPI_Ax1> theAxis,
47 build(theBasis, theAxis, std::shared_ptr<GeomAPI_Shape>(), theToAngle, std::shared_ptr<GeomAPI_Shape>(), theFromAngle);
50 //=================================================================================================
51 GeomAlgoAPI_Revolution::GeomAlgoAPI_Revolution(std::shared_ptr<GeomAPI_Shape> theBasis,
52 std::shared_ptr<GeomAPI_Ax1> theAxis,
53 std::shared_ptr<GeomAPI_Shape> theToShape,
55 std::shared_ptr<GeomAPI_Shape> theFromShape,
59 build(theBasis, theAxis, theToShape, theToAngle, theFromShape, theFromAngle);
62 //=================================================================================================
63 TopoDS_Face GeomAlgoAPI_Revolution::makeFaceFromPlane(gp_Pln& thePlane, const gp_Pnt& thePoint)
65 gp_XYZ aVec = thePoint.XYZ() - thePlane.Location().XYZ();
66 double aSign = aVec * thePlane.Axis().Direction().XYZ();
67 if(aSign < 0) thePlane.SetAxis(thePlane.Axis().Reversed());
69 BRepBuilderAPI_MakeFace aMakeFace(thePlane);
70 TopoDS_Face aResultFace = TopoDS::Face(aMakeFace.Shape());
75 //=================================================================================================
76 TopoDS_Solid GeomAlgoAPI_Revolution::makeSolidFromShape(const TopoDS_Shape& theShape)
81 BRep_Builder aBoundingBuilder;
82 if(theShape.ShapeType() == TopAbs_SHELL) {
83 aShell = TopoDS::Shell(theShape);
85 aBoundingBuilder.MakeShell(aShell);
86 aBoundingBuilder.Add(aShell, theShape);
88 aBoundingBuilder.MakeSolid(aSolid);
89 aBoundingBuilder.Add(aSolid, aShell);
94 //=================================================================================================
95 TopoDS_Shape GeomAlgoAPI_Revolution::findClosest(const TopoDS_Shape& theShape, const gp_Pnt& thePoint)
97 TopoDS_Shape aResult = theShape;
99 if(theShape.ShapeType() == TopAbs_COMPOUND) {
100 double aMinDistance = Precision::Infinite();
102 GProp_GProps aGProps;
105 for (TopoDS_Iterator anItr(theShape); anItr.More(); anItr.Next()) {
106 TopoDS_Shape aValue = anItr.Value();
107 BRepGProp::VolumeProperties(aValue, aGProps);
108 aCentr = aGProps.CentreOfMass();
109 aCurDistance = aCentr.Distance(thePoint);
111 if(aCurDistance < aMinDistance) {
112 aMinDistance = aCurDistance;
121 //=================================================================================================
122 void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBasis,
123 const std::shared_ptr<GeomAPI_Ax1>& theAxis,
124 const std::shared_ptr<GeomAPI_Shape>& theToShape,
126 const std::shared_ptr<GeomAPI_Shape>& theFromShape,
129 if(!theBasis || !theAxis ||
130 (((!theFromShape && !theToShape) || (theFromShape && theToShape && theFromShape->isEqual(theToShape)))
131 && (theFromAngle == -theToAngle))) {
135 // Checking that shell is planar.
136 TopoDS_Shape aBasis = theBasis->impl<TopoDS_Shape>();
137 // TODO: fix planar checking
138 //TopExp_Explorer aBasisExp(aBasis, TopAbs_FACE);
139 //for(; aBasisExp.More(); aBasisExp.Next()) {
140 // const TopoDS_Shape& aCurSh = aBasisExp.Current();
143 // Geting base plane.
144 std::shared_ptr<GeomAPI_Face> aBaseFace;
145 if(theBasis->shapeType() == GeomAPI_Shape::FACE) {
146 aBaseFace = std::shared_ptr<GeomAPI_Face>(new GeomAPI_Face(theBasis));
147 } else if(theBasis->shapeType() == GeomAPI_Shape::SHELL) {
148 GeomAPI_ShapeExplorer anExp(theBasis, GeomAPI_Shape::FACE);
150 std::shared_ptr<GeomAPI_Shape> aFaceOnShell = anExp.current();
151 aBaseFace = std::shared_ptr<GeomAPI_Face>(new GeomAPI_Face(aFaceOnShell));
154 if(!aBaseFace.get()) {
157 TopoDS_Face aBasisFace = TopoDS::Face(aBaseFace->impl<TopoDS_Shape>());
158 GeomLib_IsPlanarSurface isBasisPlanar(BRep_Tool::Surface(aBasisFace));
159 gp_Pln aBasisPln = isBasisPlanar.Plan();
160 Geom_Plane aBasisPlane(aBasisPln);
161 gp_Ax1 anAxis = theAxis->impl<gp_Ax1>();
162 if(aBasisPlane.Axis().Angle(anAxis) < Precision::Confusion()) {
165 gp_Lin anAxisLin(anAxis);
167 // Creating circle for pipe.
168 gp_Pnt aBasisCentre = GeomAlgoAPI_ShapeTools::centreOfMass(theBasis)->impl<gp_Pnt>();
169 gp_Pnt aStartPnt = aBasisCentre;
170 const TopoDS_Shape& aBasisShape = theBasis->impl<TopoDS_Shape>();
171 Handle(Geom_Line) anAxisLine = new Geom_Line(anAxis);
172 if(anAxisLin.Contains(aStartPnt, Precision::Confusion())) {
173 aStartPnt.Translate(anAxis.Direction() ^ aBasisPln.Axis().Direction());
175 GeomAPI_ProjectPointOnCurve aProjection(aStartPnt, anAxisLine);
176 if(aProjection.NbPoints() != 1) {
179 Standard_Real aRadius = aProjection.Distance(1);
180 gp_Circ aCircle(gp_Ax2(aProjection.NearestPoint(), anAxis.Direction()), aRadius);
182 TopoDS_Shape aResult;
183 ListOfMakeShape aListOfMakeShape;
184 if(!theFromShape && !theToShape) { // Case 1: When only angles was set.
185 // Rotating base face with the negative value of "from angle".
187 aBaseTrsf.SetRotation(anAxis, -theFromAngle / 180.0 * M_PI);
188 BRepBuilderAPI_Transform* aBaseTransform = new BRepBuilderAPI_Transform(aBasisShape,
191 if(!aBaseTransform || !aBaseTransform->IsDone()) {
194 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aBaseTransform)));
195 TopoDS_Shape aRotatedBaseShape = aBaseTransform->Shape();
197 if(theBasis->shapeType() == GeomAPI_Shape::FACE) {
198 // Making revolution to the angle equal to the sum of "from angle" and "to angle".
199 double anAngle = theFromAngle + theToAngle;
200 BRepPrimAPI_MakeRevol* aRevolBuilder = new BRepPrimAPI_MakeRevol(aRotatedBaseShape,
202 anAngle / 180 * M_PI,
204 aRevolBuilder->Build();
205 if(!aRevolBuilder->IsDone()) {
208 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aRevolBuilder)));
209 aResult = aRevolBuilder->Shape();
212 std::shared_ptr<GeomAPI_Shape> aFSHape(new GeomAPI_Shape);
213 aFSHape->setImpl(new TopoDS_Shape(aRevolBuilder->FirstShape()));
214 myFromFaces.push_back(aFSHape);
215 std::shared_ptr<GeomAPI_Shape> aTSHape(new GeomAPI_Shape);
216 aTSHape->setImpl(new TopoDS_Shape(aRevolBuilder->LastShape()));
217 myToFaces.push_back(aTSHape);
219 gp_Pnt aFromPnt = aStartPnt.Transformed(aBaseTrsf);
220 aCircle = gp_Circ(gp_Ax2(aProjection.NearestPoint(), anAxis.Direction(), gp_Vec(aProjection.NearestPoint(), aFromPnt)),
223 // Making wire for pipe.
224 TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge(aCircle, 0, (theFromAngle + theToAngle) / 180.0 * M_PI);
225 TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire();
228 BRepOffsetAPI_MakePipe* aPipeBuilder = new BRepOffsetAPI_MakePipe(aPipeWire, aRotatedBaseShape);
229 if(!aPipeBuilder || !aPipeBuilder->IsDone()) {
232 std::shared_ptr<GeomAPI_Shape> aWire(new GeomAPI_Shape);
233 std::shared_ptr<GeomAPI_Shape> aBShape(new GeomAPI_Shape);
234 aWire->setImpl(new TopoDS_Shape(aPipeWire));
235 aBShape->setImpl(new TopoDS_Shape(aRotatedBaseShape));
236 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPipeBuilder, aWire, aBShape)));
237 aResult = aPipeBuilder->Shape();
238 TopoDS_Shape aToShape = aPipeBuilder->LastShape();
239 TopoDS_Shape aFromShape = aPipeBuilder->FirstShape();
242 TopExp_Explorer anExp(aToShape, TopAbs_FACE);
243 for(; anExp.More(); anExp.Next()) {
244 std::shared_ptr<GeomAPI_Shape> aTSHape(new GeomAPI_Shape);
245 aTSHape->setImpl(new TopoDS_Shape(anExp.Current()));
246 myToFaces.push_back(aTSHape);
248 anExp.Init(aFromShape, TopAbs_FACE);
249 for(; anExp.More(); anExp.Next()) {
250 std::shared_ptr<GeomAPI_Shape> aFSHape(new GeomAPI_Shape);
251 aFSHape->setImpl(new TopoDS_Shape(anExp.Current()));
252 myFromFaces.push_back(aFSHape);
255 } else if(theFromShape && theToShape) { // Case 2: When both bounding planes were set.
256 // Getting bounding faces.
257 TopoDS_Face aFromFace = TopoDS::Face(theFromShape->impl<TopoDS_Shape>());
258 TopoDS_Face aToFace = TopoDS::Face(theToShape->impl<TopoDS_Shape>());
260 // Getting planes from bounding face.
261 GeomLib_IsPlanarSurface isFromPlanar(BRep_Tool::Surface(aFromFace));
262 GeomLib_IsPlanarSurface isToPlanar(BRep_Tool::Surface(aToFace));
263 if(!isFromPlanar.IsPlanar() || !isToPlanar.IsPlanar()) {// non-planar shapes is not supported for revolution bounding
266 gp_Pln aFromPln = isFromPlanar.Plan();
267 gp_Pln aToPln = isToPlanar.Plan();
269 // Orienting bounding planes properly so that the center of mass of the base face stays
270 // on the result shape after cut.
271 aFromFace = makeFaceFromPlane(aFromPln, aBasisCentre);
272 aToFace = makeFaceFromPlane(aToPln, aBasisCentre);
274 // Making solids from bounding planes and putting them in compound.
275 TopoDS_Shape aFromSolid = makeSolidFromShape(aFromFace);
276 TopoDS_Shape aToSolid = makeSolidFromShape(aToFace);
278 // Rotating bounding planes to the specified angle.
281 double aFromRotAngle = ((aFromPln.Axis().Direction() * aBasisPln.Axis().Direction()) > 0) ? -theFromAngle : theFromAngle;
282 double aToRotAngle = ((aToPln.Axis().Direction() * aBasisPln.Axis().Direction()) > 0) ? -theToAngle : theToAngle;
283 aFromTrsf.SetRotation(anAxis,aFromRotAngle / 180.0 * M_PI);
284 aToTrsf.SetRotation(anAxis, aToRotAngle / 180.0 * M_PI);
285 BRepBuilderAPI_Transform aFromTransform(aFromSolid, aFromTrsf, true);
286 BRepBuilderAPI_Transform aToTransform(aToSolid, aToTrsf, true);
287 TopoDS_Shape aRotatedFromFace = aFromTransform.Modified(aFromFace).First();
288 TopoDS_Shape aRotatedToFace = aToTransform.Modified(aToFace).First();
289 aFromSolid = aFromTransform.Shape();
290 aToSolid = aToTransform.Shape();
292 // Making revolution to the 360 angle.
293 if(theBasis->shapeType() == GeomAPI_Shape::FACE) {
294 BRepPrimAPI_MakeRevol* aRevolBuilder = new BRepPrimAPI_MakeRevol(aBasisShape, anAxis, 2 * M_PI, Standard_True);
295 aRevolBuilder->Build();
296 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aRevolBuilder)));
297 aResult = aRevolBuilder->Shape();
299 // Making wire for pipe.
300 TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge(aCircle, 0, 2 * M_PI);
301 TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire();
304 BRepOffsetAPI_MakePipe* aPipeBuilder = new BRepOffsetAPI_MakePipe(aPipeWire, aBasisShape);
305 if(!aPipeBuilder || !aPipeBuilder->IsDone()) {
308 std::shared_ptr<GeomAPI_Shape> aWire(new GeomAPI_Shape);
309 std::shared_ptr<GeomAPI_Shape> aBShape(new GeomAPI_Shape);
310 aWire->setImpl(new TopoDS_Shape(aPipeWire));
311 aBShape->setImpl(new TopoDS_Shape(aBasisShape));
312 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPipeBuilder, aWire, aBShape)));
313 aResult = aPipeBuilder->Shape();
316 // Cutting revolution with from plane.
317 BRepAlgoAPI_Cut* aFromCutBuilder = new BRepAlgoAPI_Cut(aResult, aFromSolid);
318 aFromCutBuilder->Build();
319 if(!aFromCutBuilder->IsDone()) {
322 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aFromCutBuilder)));
323 aResult = aFromCutBuilder->Shape();
325 // Cutting revolution with to plane.
326 BRepAlgoAPI_Cut* aToCutBuilder = new BRepAlgoAPI_Cut(aResult, aToSolid);
327 aToCutBuilder->Build();
328 if(!aToCutBuilder->IsDone()) {
331 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aToCutBuilder)));
332 aResult = aToCutBuilder->Shape();
334 // If after cut we got more than one solids then take closest to the center of mass of the base face.
335 aResult = findClosest(aResult, aBasisCentre);
338 for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More (); anExp.Next ()) {
339 const TopoDS_Shape& aFaceOnResult = anExp.Current();
340 Handle(Geom_Surface) aFaceSurface = BRep_Tool::Surface(TopoDS::Face(aFaceOnResult));
341 Handle(Geom_Surface) aFromSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedFromFace));
342 Handle(Geom_Surface) aToSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedToFace));
343 if(aFaceSurface == aFromSurface) {
344 std::shared_ptr<GeomAPI_Shape> aFSHape(new GeomAPI_Shape);
345 aFSHape->setImpl(new TopoDS_Shape(aFaceOnResult));
346 myFromFaces.push_back(aFSHape);
348 if(aFaceSurface == aToSurface) {
349 std::shared_ptr<GeomAPI_Shape> aTSHape(new GeomAPI_Shape);
350 aTSHape->setImpl(new TopoDS_Shape(aFaceOnResult));
351 myToFaces.push_back(aTSHape);
354 } else { //Case 3: When only one bounding plane was set.
355 // Getting bounding face.
356 TopoDS_Face aBoundingFace;
357 bool isFromFaceSet = false;
359 aBoundingFace = TopoDS::Face(theFromShape->impl<TopoDS_Shape>());
360 isFromFaceSet = true;
361 } else if(theToShape) {
362 aBoundingFace = TopoDS::Face(theToShape->impl<TopoDS_Shape>());
365 // Getting plane from bounding face.
366 GeomLib_IsPlanarSurface isBoundingPlanar(BRep_Tool::Surface(aBoundingFace));
367 if(!isBoundingPlanar.IsPlanar()) { // non-planar shapes is not supported for revolution bounding
370 gp_Pln aBoundingPln = isBoundingPlanar.Plan();
372 // Orienting bounding plane properly so that the center of mass of the base face stays
373 // on the result shape after cut.
374 gp_Pnt aBasisCentr = GeomAlgoAPI_ShapeTools::centreOfMass(theBasis)->impl<gp_Pnt>();
375 aBoundingFace = makeFaceFromPlane(aBoundingPln, aBasisCentr);
377 // Making solid from bounding plane.
378 TopoDS_Shape aBoundingSolid = makeSolidFromShape(aBoundingFace);
380 // Rotating bounding plane to the specified angle.
381 double aBoundingRotAngle = isFromFaceSet ? theFromAngle : theToAngle;
382 if(aBoundingPln.Axis().IsParallel(aBasisPln.Axis(), Precision::Confusion())) {
383 if(isFromFaceSet) aBoundingRotAngle = -aBoundingRotAngle;
385 double aSign = (aBoundingPln.Axis().Direction() ^ aBasisPln.Axis().Direction()) *
387 if((aSign <= 0 && !isFromFaceSet) || (aSign > 0 && isFromFaceSet)) {
388 aBoundingRotAngle = -aBoundingRotAngle;
391 gp_Trsf aBoundingTrsf;
392 aBoundingTrsf.SetRotation(anAxis, aBoundingRotAngle / 180.0 * M_PI);
393 BRepBuilderAPI_Transform aBoundingTransform(aBoundingSolid, aBoundingTrsf, true);
394 TopoDS_Shape aRotatedBoundingFace = aBoundingTransform.Modified(aBoundingFace).First();
395 aBoundingSolid = aBoundingTransform.Shape();
397 // Making revolution to the 360 angle.
398 if(theBasis->shapeType() == GeomAPI_Shape::FACE) {
399 BRepPrimAPI_MakeRevol* aRevolBuilder = new BRepPrimAPI_MakeRevol(aBasisShape, anAxis, 2 * M_PI, Standard_True);
400 aRevolBuilder->Build();
401 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aRevolBuilder)));
402 aResult = aRevolBuilder->Shape();
404 // Making wire for pipe.
405 TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge(aCircle, 0, 2 * M_PI);
406 TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire();
409 BRepOffsetAPI_MakePipe* aPipeBuilder = new BRepOffsetAPI_MakePipe(aPipeWire, aBasisShape);
410 if(!aPipeBuilder || !aPipeBuilder->IsDone()) {
413 std::shared_ptr<GeomAPI_Shape> aWire(new GeomAPI_Shape);
414 std::shared_ptr<GeomAPI_Shape> aBShape(new GeomAPI_Shape);
415 aWire->setImpl(new TopoDS_Shape(aPipeWire));
416 aBShape->setImpl(new TopoDS_Shape(aBasisShape));
417 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPipeBuilder, aWire, aBShape)));
418 aResult = aPipeBuilder->Shape();
421 // Cutting revolution with bounding plane.
422 BRepAlgoAPI_Cut* aBoundingCutBuilder = new BRepAlgoAPI_Cut(aResult, aBoundingSolid);
423 aBoundingCutBuilder->Build();
424 if(!aBoundingCutBuilder->IsDone()) {
427 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aBoundingCutBuilder)));
428 aResult = aBoundingCutBuilder->Shape();
431 const TopTools_ListOfShape& aBndShapes = aBoundingCutBuilder->Modified(aBoundingFace);
432 for(TopTools_ListIteratorOfListOfShape anIt(aBndShapes); anIt.More(); anIt.Next()) {
433 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
434 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
435 isFromFaceSet ? myFromFaces.push_back(aShape) : myToFaces.push_back(aShape);
438 // Try to cut with base face. If it can not be done then keep result of cut with bounding plane.
441 aMirrorTrsf.SetMirror(aBasisPlane.Position().Ax2());
442 BRepBuilderAPI_Transform aMirrorTransform(aBasis, aMirrorTrsf, true);
443 aBasis = aMirrorTransform.Shape();
446 // Making solid from basis face.
447 TopoDS_Shape aBasisSolid = makeSolidFromShape(aBasis);
449 // Rotating basis face to the specified angle.
451 double aBasisRotAngle = isFromFaceSet ? theToAngle : -theFromAngle;
452 aBasisTrsf.SetRotation(anAxis, aBasisRotAngle / 180.0 * M_PI);
453 BRepBuilderAPI_Transform aBasisTransform(aBasisSolid, aBasisTrsf, true);
454 TopoDS_Shape aRotatedBasis = aBasisTransform.Modified(aBasis).First();
455 aBasisSolid = aBasisTransform.Shape();
457 // Cutting revolution with basis.
458 BRepAlgoAPI_Cut* aBasisCutBuilder = new BRepAlgoAPI_Cut(aResult, aBasisSolid);
459 aBasisCutBuilder->Build();
460 if(aBasisCutBuilder->IsDone()) {
461 TopoDS_Shape aCutResult = aBasisCutBuilder->Shape();
462 TopExp_Explorer anExp(aCutResult, TopAbs_SOLID);
464 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aBasisCutBuilder)));
465 aResult = aCutResult;
469 const TopTools_ListOfShape& aBsShapes = aBasisCutBuilder->Modified(aBoundingFace);
470 for(TopTools_ListIteratorOfListOfShape anIt(aBsShapes); anIt.More(); anIt.Next()) {
471 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
472 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
473 isFromFaceSet ? myToFaces.push_back(aShape) : myFromFaces.push_back(aShape);
476 // If after cut we got more than one solids then take closest to the center of mass of the base face.
477 aResult = findClosest(aResult, aBasisCentr);
480 for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More (); anExp.Next ()) {
481 const TopoDS_Shape& aFaceOnResult = anExp.Current();
482 Handle(Geom_Surface) aFaceSurface = BRep_Tool::Surface(TopoDS::Face(aFaceOnResult));
483 Handle(Geom_Surface) aBoundingSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedBoundingFace));
484 if(aFaceSurface == aBoundingSurface) {
485 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
486 aShape->setImpl(new TopoDS_Shape(aFaceOnResult));
487 isFromFaceSet ? myFromFaces.push_back(aShape) : myToFaces.push_back(aShape);
492 TopExp_Explorer anExp(aResult, TopAbs_SOLID);
496 if(aResult.ShapeType() == TopAbs_COMPOUND) {
497 aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
499 if(aResult.ShapeType() == TopAbs_COMPOUND) {
500 std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
501 aCompound->setImpl(new TopoDS_Shape(aResult));
502 ListOfShape aCompSolids, aFreeSolids;
503 GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
504 if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
505 aResult = aCompSolids.front()->impl<TopoDS_Shape>();
506 } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
507 TopoDS_Compound aResultComp;
508 TopoDS_Builder aBuilder;
509 aBuilder.MakeCompound(aResultComp);
510 for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
511 aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
513 for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
514 aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
516 aResult = aResultComp;
520 // fill data map to keep correct orientation of sub-shapes
521 myMap = std::shared_ptr<GeomAPI_DataMapOfShapeShape>(new GeomAPI_DataMapOfShapeShape());
522 for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
523 std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
524 aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
525 myMap->bind(aCurrentShape, aCurrentShape);
527 myShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
528 myShape->setImpl(new TopoDS_Shape(aResult));
529 myMkShape = std::shared_ptr<GeomAlgoAPI_MakeShapeList>(new GeomAlgoAPI_MakeShapeList(aListOfMakeShape));
533 //=================================================================================================
534 const bool GeomAlgoAPI_Revolution::isDone() const
539 //=================================================================================================
540 const bool GeomAlgoAPI_Revolution::isValid() const
542 BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
543 return (aChecker.IsValid() == Standard_True);
546 //=================================================================================================
547 const bool GeomAlgoAPI_Revolution::hasVolume() const
549 bool hasVolume(false);
551 const TopoDS_Shape& aRShape = myShape->impl<TopoDS_Shape>();
553 BRepGProp::VolumeProperties(aRShape, aGProp);
554 if(aGProp.Mass() > Precision::Confusion())
560 //=================================================================================================
561 const std::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Revolution::shape () const
566 //=================================================================================================
567 const ListOfShape& GeomAlgoAPI_Revolution::fromFaces() const
572 //=================================================================================================
573 const ListOfShape& GeomAlgoAPI_Revolution::toFaces() const
578 //=================================================================================================
579 std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_Revolution::mapOfShapes() const
584 //=================================================================================================
585 std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_Revolution::makeShape() const