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)
21 myShape(new GeomAPI_Shape()),
22 myMap(new GeomAPI_DataMapOfShapeShape()),
23 myMkShape(new GeomAlgoAPI_MakeShape())
25 build(theSourceShape, theTrsf);
28 //=================================================================================================
29 void GeomAlgoAPI_Transform::build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
30 std::shared_ptr<GeomAPI_Trsf> theTrsf)
32 if(!theSourceShape || !theTrsf) {
36 const TopoDS_Shape& aSourceShape = theSourceShape->impl<TopoDS_Shape>();
37 const gp_Trsf& aTrsf = theTrsf->impl<gp_Trsf>();
39 if(aSourceShape.IsNull()) {
43 BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
48 myDone = aBuilder->IsDone() == Standard_True;
53 TopoDS_Shape aResult = aBuilder->Shape();
55 // Fill data map to keep correct orientation of sub-shapes.
56 for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More(); anExp.Next()) {
57 std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
58 aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
59 myMap->bind(aCurrentShape, aCurrentShape);
62 myMkShape->setImpl(aBuilder);
63 myShape->setImpl(new TopoDS_Shape(aResult));
66 //=================================================================================================
67 const bool GeomAlgoAPI_Transform::isValid() const
69 BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
70 return (aChecker.IsValid() == Standard_True);
73 //=================================================================================================
74 const bool GeomAlgoAPI_Transform::hasVolume() const
76 bool hasVolume(false);
77 if(isValid() && (GeomAlgoAPI_ShapeTools::volume(myShape) > Precision::Confusion())) {
83 //=================================================================================================
84 const std::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Transform::shape() const
89 //=================================================================================================
90 std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_Transform::mapOfShapes() const
95 //=================================================================================================
96 std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_Transform::makeShape() const
101 //=================================================================================================
102 std::shared_ptr<GeomAPI_Trsf> GeomAlgoAPI_Transform::transformation() const