1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_Box.cpp
4 // Created: 10 Mar 2016
5 // Author: Clarisse Genrault (CEA)
7 #include <GeomAlgoAPI_Box.h>
9 #include <BRepPrimAPI_MakeBox.hxx>
10 #include <TopoDS_Shape.hxx>
12 //=================================================================================================
13 GeomAlgoAPI_Box::GeomAlgoAPI_Box()
17 //=================================================================================================
18 GeomAlgoAPI_Box::GeomAlgoAPI_Box(const double theDx, const double theDy, const double theDz)
25 //=================================================================================================
26 bool GeomAlgoAPI_Box::check()
28 if (myDx < Precision::Confusion()) {
29 myError = "Box builder with dimensions :: Dx is null.";
31 } else if (myDy < Precision::Confusion()) {
32 myError = "Box builder with dimensions :: Dy is null.";
34 } else if (myDz < Precision::Confusion()) {
35 myError = "Box builder with dimensions :: Dz is null.";
41 //=================================================================================================
42 void GeomAlgoAPI_Box::build()
44 myCreatedFaces.clear();
47 BRepPrimAPI_MakeBox *aBoxMaker = new BRepPrimAPI_MakeBox(myDx, myDy, myDz);
51 if (!aBoxMaker->IsDone()) {
52 myError = "Box builder with dimensions :: algorithm failed.";
56 TopoDS_Shape aResult = aBoxMaker->Shape();
57 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
58 aShape->setImpl(new TopoDS_Shape(aResult));
62 if (!aShape.get() || aShape->isNull()) {
63 myError = "Box builder with dimensions :: resulting shape is null.";
72 //=================================================================================================
73 void GeomAlgoAPI_Box::prepareNamingFaces()
75 BRepPrimAPI_MakeBox aBoxMaker = impl<BRepPrimAPI_MakeBox>();
76 std::shared_ptr<GeomAPI_Shape> aShapeFront(new GeomAPI_Shape);
77 aShapeFront->setImpl(new TopoDS_Shape(aBoxMaker.FrontFace()));
78 myCreatedFaces["Front"] = aShapeFront;
79 std::shared_ptr<GeomAPI_Shape> aShapeBack(new GeomAPI_Shape);
80 aShapeBack->setImpl(new TopoDS_Shape(aBoxMaker.BackFace()));
81 myCreatedFaces["Back"] = aShapeBack;
82 std::shared_ptr<GeomAPI_Shape> aShapeTop(new GeomAPI_Shape);
83 aShapeTop->setImpl(new TopoDS_Shape(aBoxMaker.TopFace()));
84 myCreatedFaces["Top"] = aShapeTop;
85 std::shared_ptr<GeomAPI_Shape> aShapeBottom(new GeomAPI_Shape);
86 aShapeBottom->setImpl(new TopoDS_Shape(aBoxMaker.BottomFace()));
87 myCreatedFaces["Bottom"] = aShapeBottom;
88 std::shared_ptr<GeomAPI_Shape> aShapeLeft(new GeomAPI_Shape);
89 aShapeLeft->setImpl(new TopoDS_Shape(aBoxMaker.LeftFace()));
90 myCreatedFaces["Left"] = aShapeLeft;
91 std::shared_ptr<GeomAPI_Shape> aShapeRight(new GeomAPI_Shape);
92 aShapeRight->setImpl(new TopoDS_Shape(aBoxMaker.RightFace()));
93 myCreatedFaces["Right"] = aShapeRight;