1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_Translation.cpp
4 // Created: 8 June 2015
5 // Author: Dmitry Bobylev
7 #include "GeomAlgoAPI_Translation.h"
9 #include <BRepBuilderAPI_Transform.hxx>
12 //=================================================================================================
13 GeomAlgoAPI_Translation::GeomAlgoAPI_Translation(std::shared_ptr<GeomAPI_Shape> theSourceShape,
14 std::shared_ptr<GeomAPI_Ax1> theAxis,
17 build(theSourceShape, theAxis, theDistance);
20 //=================================================================================================
21 void GeomAlgoAPI_Translation::build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
22 std::shared_ptr<GeomAPI_Ax1> theAxis,
25 if(!theSourceShape || !theAxis) {
29 const TopoDS_Shape& aSourceShape = theSourceShape->impl<TopoDS_Shape>();
30 const gp_Ax1& anAxis = theAxis->impl<gp_Ax1>();
32 if(aSourceShape.IsNull()) {
36 gp_Trsf* aTrsf = new gp_Trsf();
37 aTrsf->SetTranslation(gp_Vec(anAxis.Direction()) * theDistance);
39 // Transform the shape with copying it.
40 BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, *aTrsf, true);
44 this->setImpl(aBuilder);
45 this->setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
47 if(aBuilder->IsDone() != Standard_True) {
50 TopoDS_Shape aResult = aBuilder->Shape();
52 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
53 aShape->setImpl(new TopoDS_Shape(aResult));
54 this->setShape(aShape);