1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_BoxPoints.cpp
4 // Created: 17 Mar 2016
5 // Author: Clarisse Genrault (CEA)
7 #include <GeomAlgoAPI_BoxPoints.h>
9 #include <BRepPrimAPI_MakeBox.hxx>
10 #include <TopoDS_Shape.hxx>
14 //=================================================================================================
15 GeomAlgoAPI_BoxPoints::GeomAlgoAPI_BoxPoints(std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
16 std::shared_ptr<GeomAPI_Pnt> theSecondPoint)
19 myFirstPoint = theFirstPoint;
20 mySecondPoint = theSecondPoint;
23 //=================================================================================================
24 bool GeomAlgoAPI_BoxPoints::check()
26 // The distance between myFirstPoint and mySecondPoint must not be null.
27 if (myFirstPoint->distance(mySecondPoint) < Precision::Confusion())
32 //=================================================================================================
33 void GeomAlgoAPI_BoxPoints::build()
35 myCreatedFaces.clear();
37 const gp_Pnt& aFirstPoint = myFirstPoint->impl<gp_Pnt>();
38 const gp_Pnt& aSecondPoint = mySecondPoint->impl<gp_Pnt>();
41 BRepPrimAPI_MakeBox *aBoxMaker = new BRepPrimAPI_MakeBox(aFirstPoint, aSecondPoint);
45 if(!aBoxMaker->IsDone()) {
46 myError = "Box builder with two points :: algorithm failed.";
50 TopoDS_Shape aResult = aBoxMaker->Shape();
52 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
53 aShape->setImpl(new TopoDS_Shape(aResult));
57 if (!aShape.get() || aShape->isNull()) {
58 myError = "Box builder with two points :: resulting shape is null.";