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::SHELL) {
146 GeomAPI_ShapeExplorer anExp(theBasis, GeomAPI_Shape::FACE);
148 std::shared_ptr<GeomAPI_Shape> aFaceOnShell = anExp.current();
149 aBaseFace = std::shared_ptr<GeomAPI_Face>(new GeomAPI_Face(aFaceOnShell));
152 aBaseFace = std::shared_ptr<GeomAPI_Face>(new GeomAPI_Face(theBasis));
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 gp_Pnt aFromPnt = aStartPnt.Transformed(aBaseTrsf);
189 aCircle = gp_Circ(gp_Ax2(aProjection.NearestPoint(), anAxis.Direction(), gp_Vec(aProjection.NearestPoint(), aFromPnt)),
191 BRepBuilderAPI_Transform* aBaseTransform = new BRepBuilderAPI_Transform(aBasisShape,
194 if(!aBaseTransform || !aBaseTransform->IsDone()) {
197 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aBaseTransform)));
198 TopoDS_Shape aRotatedBaseShape = aBaseTransform->Shape();
200 // Making wire for pipe.
201 TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge(aCircle, 0, (theFromAngle + theToAngle) / 180.0 * M_PI);
202 TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire();
205 BRepOffsetAPI_MakePipe* aPipeBuilder = new BRepOffsetAPI_MakePipe(aPipeWire, aRotatedBaseShape);
206 if(!aPipeBuilder || !aPipeBuilder->IsDone()) {
209 std::shared_ptr<GeomAPI_Shape> aWire(new GeomAPI_Shape);
210 std::shared_ptr<GeomAPI_Shape> aBShape(new GeomAPI_Shape);
211 aWire->setImpl(new TopoDS_Shape(aPipeWire));
212 aBShape->setImpl(new TopoDS_Shape(aRotatedBaseShape));
213 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPipeBuilder, aWire, aBShape)));
214 aResult = aPipeBuilder->Shape();
215 TopoDS_Shape aToShape = aPipeBuilder->LastShape();
216 TopoDS_Shape aFromShape = aPipeBuilder->FirstShape();
219 TopExp_Explorer anExp(aToShape, TopAbs_FACE);
220 for(; anExp.More(); anExp.Next()) {
221 std::shared_ptr<GeomAPI_Shape> aTSHape(new GeomAPI_Shape);
222 aTSHape->setImpl(new TopoDS_Shape(anExp.Current()));
223 myToFaces.push_back(aTSHape);
225 anExp.Init(aFromShape, TopAbs_FACE);
226 for(; anExp.More(); anExp.Next()) {
227 std::shared_ptr<GeomAPI_Shape> aFSHape(new GeomAPI_Shape);
228 aFSHape->setImpl(new TopoDS_Shape(anExp.Current()));
229 myFromFaces.push_back(aFSHape);
231 } else if(theFromShape && theToShape) { // Case 2: When both bounding planes were set.
232 // Getting bounding faces.
233 TopoDS_Face aFromFace = TopoDS::Face(theFromShape->impl<TopoDS_Shape>());
234 TopoDS_Face aToFace = TopoDS::Face(theToShape->impl<TopoDS_Shape>());
236 // Getting planes from bounding face.
237 GeomLib_IsPlanarSurface isFromPlanar(BRep_Tool::Surface(aFromFace));
238 GeomLib_IsPlanarSurface isToPlanar(BRep_Tool::Surface(aToFace));
239 if(!isFromPlanar.IsPlanar() || !isToPlanar.IsPlanar()) {// non-planar shapes is not supported for revolution bounding
242 gp_Pln aFromPln = isFromPlanar.Plan();
243 gp_Pln aToPln = isToPlanar.Plan();
245 // Orienting bounding planes properly so that the center of mass of the base face stays
246 // on the result shape after cut.
247 aFromFace = makeFaceFromPlane(aFromPln, aBasisCentre);
248 aToFace = makeFaceFromPlane(aToPln, aBasisCentre);
250 // Making solids from bounding planes and putting them in compound.
251 TopoDS_Shape aFromSolid = makeSolidFromShape(aFromFace);
252 TopoDS_Shape aToSolid = makeSolidFromShape(aToFace);
254 // Rotating bounding planes to the specified angle.
257 double aFromRotAngle = ((aFromPln.Axis().Direction() * aBasisPln.Axis().Direction()) > 0) ? -theFromAngle : theFromAngle;
258 double aToRotAngle = ((aToPln.Axis().Direction() * aBasisPln.Axis().Direction()) > 0) ? -theToAngle : theToAngle;
259 aFromTrsf.SetRotation(anAxis,aFromRotAngle / 180.0 * M_PI);
260 aToTrsf.SetRotation(anAxis, aToRotAngle / 180.0 * M_PI);
261 BRepBuilderAPI_Transform aFromTransform(aFromSolid, aFromTrsf, true);
262 BRepBuilderAPI_Transform aToTransform(aToSolid, aToTrsf, true);
263 TopoDS_Shape aRotatedFromFace = aFromTransform.Modified(aFromFace).First();
264 TopoDS_Shape aRotatedToFace = aToTransform.Modified(aToFace).First();
265 aFromSolid = aFromTransform.Shape();
266 aToSolid = aToTransform.Shape();
268 // Making wire for pipe.
269 TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge(aCircle, 0, 2 * M_PI);
270 TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire();
273 BRepOffsetAPI_MakePipe* aPipeBuilder = new BRepOffsetAPI_MakePipe(aPipeWire, aBasisShape);
274 if(!aPipeBuilder || !aPipeBuilder->IsDone()) {
277 std::shared_ptr<GeomAPI_Shape> aWire(new GeomAPI_Shape);
278 std::shared_ptr<GeomAPI_Shape> aBShape(new GeomAPI_Shape);
279 aWire->setImpl(new TopoDS_Shape(aPipeWire));
280 aBShape->setImpl(new TopoDS_Shape(aBasisShape));
281 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPipeBuilder, aWire, aBShape)));
282 aResult = aPipeBuilder->Shape();
284 // Cutting revolution with from plane.
285 BRepAlgoAPI_Cut* aFromCutBuilder = new BRepAlgoAPI_Cut(aResult, aFromSolid);
286 aFromCutBuilder->Build();
287 if(!aFromCutBuilder->IsDone()) {
290 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aFromCutBuilder)));
291 aResult = aFromCutBuilder->Shape();
293 // Cutting revolution with to plane.
294 BRepAlgoAPI_Cut* aToCutBuilder = new BRepAlgoAPI_Cut(aResult, aToSolid);
295 aToCutBuilder->Build();
296 if(!aToCutBuilder->IsDone()) {
299 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aToCutBuilder)));
300 aResult = aToCutBuilder->Shape();
302 // If after cut we got more than one solids then take closest to the center of mass of the base face.
303 //aResult = findClosest(aResult, aBasisCentre);
306 for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More (); anExp.Next ()) {
307 const TopoDS_Shape& aFaceOnResult = anExp.Current();
308 Handle(Geom_Surface) aFaceSurface = BRep_Tool::Surface(TopoDS::Face(aFaceOnResult));
309 Handle(Geom_Surface) aFromSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedFromFace));
310 Handle(Geom_Surface) aToSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedToFace));
311 if(aFaceSurface == aFromSurface) {
312 std::shared_ptr<GeomAPI_Shape> aFSHape(new GeomAPI_Shape);
313 aFSHape->setImpl(new TopoDS_Shape(aFaceOnResult));
314 myFromFaces.push_back(aFSHape);
316 if(aFaceSurface == aToSurface) {
317 std::shared_ptr<GeomAPI_Shape> aTSHape(new GeomAPI_Shape);
318 aTSHape->setImpl(new TopoDS_Shape(aFaceOnResult));
319 myToFaces.push_back(aTSHape);
322 } else { //Case 3: When only one bounding plane was set.
323 // Getting bounding face.
324 TopoDS_Face aBoundingFace;
325 bool isFromFaceSet = false;
327 aBoundingFace = TopoDS::Face(theFromShape->impl<TopoDS_Shape>());
328 isFromFaceSet = true;
329 } else if(theToShape) {
330 aBoundingFace = TopoDS::Face(theToShape->impl<TopoDS_Shape>());
333 // Getting plane from bounding face.
334 GeomLib_IsPlanarSurface isBoundingPlanar(BRep_Tool::Surface(aBoundingFace));
335 if(!isBoundingPlanar.IsPlanar()) { // non-planar shapes is not supported for revolution bounding
338 gp_Pln aBoundingPln = isBoundingPlanar.Plan();
340 // Orienting bounding plane properly so that the center of mass of the base face stays
341 // on the result shape after cut.
342 gp_Pnt aBasisCentr = GeomAlgoAPI_ShapeTools::centreOfMass(theBasis)->impl<gp_Pnt>();
343 aBoundingFace = makeFaceFromPlane(aBoundingPln, aBasisCentr);
345 // Making solid from bounding plane.
346 TopoDS_Shape aBoundingSolid = makeSolidFromShape(aBoundingFace);
348 // Rotating bounding plane to the specified angle.
349 double aBoundingRotAngle = isFromFaceSet ? theFromAngle : theToAngle;
350 if(aBoundingPln.Axis().IsParallel(aBasisPln.Axis(), Precision::Confusion())) {
351 if(isFromFaceSet) aBoundingRotAngle = -aBoundingRotAngle;
353 double aSign = (aBoundingPln.Axis().Direction() ^ aBasisPln.Axis().Direction()) *
355 if((aSign <= 0 && !isFromFaceSet) || (aSign > 0 && isFromFaceSet)) {
356 aBoundingRotAngle = -aBoundingRotAngle;
359 gp_Trsf aBoundingTrsf;
360 aBoundingTrsf.SetRotation(anAxis, aBoundingRotAngle / 180.0 * M_PI);
361 BRepBuilderAPI_Transform aBoundingTransform(aBoundingSolid, aBoundingTrsf, true);
362 TopoDS_Shape aRotatedBoundingFace = aBoundingTransform.Modified(aBoundingFace).First();
363 aBoundingSolid = aBoundingTransform.Shape();
365 // Making wire for pipe.
366 TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge(aCircle, 0, 2 * M_PI);
367 TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire();
370 BRepOffsetAPI_MakePipe* aPipeBuilder = new BRepOffsetAPI_MakePipe(aPipeWire, aBasisShape);
371 if(!aPipeBuilder || !aPipeBuilder->IsDone()) {
374 std::shared_ptr<GeomAPI_Shape> aWire(new GeomAPI_Shape);
375 std::shared_ptr<GeomAPI_Shape> aBShape(new GeomAPI_Shape);
376 aWire->setImpl(new TopoDS_Shape(aPipeWire));
377 aBShape->setImpl(new TopoDS_Shape(aBasisShape));
378 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPipeBuilder, aWire, aBShape)));
379 aResult = aPipeBuilder->Shape();
381 // Cutting revolution with bounding plane.
382 BRepAlgoAPI_Cut* aBoundingCutBuilder = new BRepAlgoAPI_Cut(aResult, aBoundingSolid);
383 aBoundingCutBuilder->Build();
384 if(!aBoundingCutBuilder->IsDone()) {
387 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aBoundingCutBuilder)));
388 aResult = aBoundingCutBuilder->Shape();
391 const TopTools_ListOfShape& aBndShapes = aBoundingCutBuilder->Modified(aBoundingFace);
392 for(TopTools_ListIteratorOfListOfShape anIt(aBndShapes); anIt.More(); anIt.Next()) {
393 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
394 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
395 isFromFaceSet ? myFromFaces.push_back(aShape) : myToFaces.push_back(aShape);
398 // Try to cut with base face. If it can not be done then keep result of cut with bounding plane.
401 aMirrorTrsf.SetMirror(aBasisPlane.Position().Ax2());
402 BRepBuilderAPI_Transform aMirrorTransform(aBasis, aMirrorTrsf, true);
403 aBasis = aMirrorTransform.Shape();
406 // Making solid from basis face.
407 TopoDS_Shape aBasisSolid = makeSolidFromShape(aBasis);
409 // Rotating basis face to the specified angle.
411 double aBasisRotAngle = isFromFaceSet ? theToAngle : -theFromAngle;
412 aBasisTrsf.SetRotation(anAxis, aBasisRotAngle / 180.0 * M_PI);
413 BRepBuilderAPI_Transform aBasisTransform(aBasisSolid, aBasisTrsf, true);
414 TopoDS_Shape aRotatedBasis = aBasisTransform.Modified(aBasis).First();
415 aBasisSolid = aBasisTransform.Shape();
417 // Cutting revolution with basis.
418 BRepAlgoAPI_Cut* aBasisCutBuilder = new BRepAlgoAPI_Cut(aResult, aBasisSolid);
419 aBasisCutBuilder->Build();
420 if(aBasisCutBuilder->IsDone()) {
421 TopoDS_Shape aCutResult = aBasisCutBuilder->Shape();
422 TopExp_Explorer anExp(aCutResult, TopAbs_SOLID);
424 aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aBasisCutBuilder)));
425 aResult = aCutResult;
429 const TopTools_ListOfShape& aBsShapes = aBasisCutBuilder->Modified(aBoundingFace);
430 for(TopTools_ListIteratorOfListOfShape anIt(aBsShapes); anIt.More(); anIt.Next()) {
431 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
432 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
433 isFromFaceSet ? myToFaces.push_back(aShape) : myFromFaces.push_back(aShape);
436 // If after cut we got more than one solids then take closest to the center of mass of the base face.
437 //aResult = findClosest(aResult, aBasisCentr);
440 for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More (); anExp.Next ()) {
441 const TopoDS_Shape& aFaceOnResult = anExp.Current();
442 Handle(Geom_Surface) aFaceSurface = BRep_Tool::Surface(TopoDS::Face(aFaceOnResult));
443 Handle(Geom_Surface) aBoundingSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedBoundingFace));
444 if(aFaceSurface == aBoundingSurface) {
445 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
446 aShape->setImpl(new TopoDS_Shape(aFaceOnResult));
447 isFromFaceSet ? myFromFaces.push_back(aShape) : myToFaces.push_back(aShape);
452 TopExp_Explorer anExp(aResult, TopAbs_SOLID);
456 if(aResult.ShapeType() == TopAbs_COMPOUND) {
457 aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
459 if(aResult.ShapeType() == TopAbs_COMPOUND) {
460 std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
461 aCompound->setImpl(new TopoDS_Shape(aResult));
462 ListOfShape aCompSolids, aFreeSolids;
463 GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
464 if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
465 aResult = aCompSolids.front()->impl<TopoDS_Shape>();
466 } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
467 TopoDS_Compound aResultComp;
468 TopoDS_Builder aBuilder;
469 aBuilder.MakeCompound(aResultComp);
470 for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
471 aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
473 for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
474 aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
476 aResult = aResultComp;
480 // fill data map to keep correct orientation of sub-shapes
481 myMap = std::shared_ptr<GeomAPI_DataMapOfShapeShape>(new GeomAPI_DataMapOfShapeShape());
482 for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
483 std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
484 aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
485 myMap->bind(aCurrentShape, aCurrentShape);
487 myShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
488 myShape->setImpl(new TopoDS_Shape(aResult));
489 myMkShape = std::shared_ptr<GeomAlgoAPI_MakeShapeList>(new GeomAlgoAPI_MakeShapeList(aListOfMakeShape));
493 //=================================================================================================
494 const bool GeomAlgoAPI_Revolution::isDone() const
499 //=================================================================================================
500 const bool GeomAlgoAPI_Revolution::isValid() const
502 BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
503 return (aChecker.IsValid() == Standard_True);
506 //=================================================================================================
507 const bool GeomAlgoAPI_Revolution::hasVolume() const
509 bool hasVolume(false);
511 const TopoDS_Shape& aRShape = myShape->impl<TopoDS_Shape>();
513 BRepGProp::VolumeProperties(aRShape, aGProp);
514 if(aGProp.Mass() > Precision::Confusion())
520 //=================================================================================================
521 const std::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Revolution::shape () const
526 //=================================================================================================
527 const ListOfShape& GeomAlgoAPI_Revolution::fromFaces() const
532 //=================================================================================================
533 const ListOfShape& GeomAlgoAPI_Revolution::toFaces() const
538 //=================================================================================================
539 std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_Revolution::mapOfShapes() const
544 //=================================================================================================
545 std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_Revolution::makeShape() const