1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_Transform.cpp
4 // Created: 29 July 2015
5 // Author: Dmitry Bobylev
7 #include <GeomAlgoAPI_Transform.h>
9 #include <GeomAlgoAPI_ShapeTools.h>
11 #include <BRepBuilderAPI_Transform.hxx>
12 #include <BRepCheck_Analyzer.hxx>
13 #include <Precision.hxx>
14 #include <TopExp_Explorer.hxx>
16 //=================================================================================================
17 GeomAlgoAPI_Transform::GeomAlgoAPI_Transform(std::shared_ptr<GeomAPI_Shape> theSourceShape,
18 std::shared_ptr<GeomAPI_Trsf> theTrsf)
22 build(theSourceShape, theTrsf);
25 //=================================================================================================
26 void GeomAlgoAPI_Transform::build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
27 std::shared_ptr<GeomAPI_Trsf> theTrsf)
29 if(!theSourceShape || !theTrsf) {
33 const TopoDS_Shape& aSourceShape = theSourceShape->impl<TopoDS_Shape>();
34 const gp_Trsf& aTrsf = theTrsf->impl<gp_Trsf>();
36 if(aSourceShape.IsNull()) {
40 BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
44 myMkShape.reset(new GeomAlgoAPI_MakeShape(aBuilder));
46 myDone = aBuilder->IsDone() == Standard_True;
51 TopoDS_Shape aResult = aBuilder->Shape();
53 // Fill data map to keep correct orientation of sub-shapes.
54 myMap.reset(new GeomAPI_DataMapOfShapeShape());
55 for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More(); anExp.Next()) {
56 std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
57 aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
58 myMap->bind(aCurrentShape, aCurrentShape);
61 myShape.reset(new GeomAPI_Shape());
62 myShape->setImpl(new TopoDS_Shape(aResult));
65 //=================================================================================================
66 const bool GeomAlgoAPI_Transform::isValid() const
68 BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
69 return (aChecker.IsValid() == Standard_True);
72 //=================================================================================================
73 const bool GeomAlgoAPI_Transform::hasVolume() const
75 bool hasVolume(false);
76 if(isValid() && (GeomAlgoAPI_ShapeTools::volume(myShape) > Precision::Confusion())) {
82 //=================================================================================================
83 const std::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Transform::shape() const
88 //=================================================================================================
89 std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_Transform::mapOfShapes() const
94 //=================================================================================================
95 std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_Transform::makeShape() const
100 //=================================================================================================
101 std::shared_ptr<GeomAPI_Trsf> GeomAlgoAPI_Transform::transformation() const