//=================================================================================================
GeomAlgoAPI_Box::GeomAlgoAPI_Box(std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
std::shared_ptr<GeomAPI_Pnt> theSecondPoint)
-:GeomAlgoAPI_Box()
{
myFirstPoint = theFirstPoint;
mySecondPoint = theSecondPoint;
{
if (myMethodType == MethodType::BOX_DIM) {
if (myDx < Precision::Confusion()) {
- myError = "Box builder with dimensions :: Dx is null.";
+ myError = "Box builder with dimensions :: Dx is null or negative.";
return false;
} else if (myDy < Precision::Confusion()) {
- myError = "Box builder with dimensions :: Dy is null.";
+ myError = "Box builder with dimensions :: Dy is null or negative.";
return false;
} else if (myDz < Precision::Confusion()) {
- myError = "Box builder with dimensions :: Dz is null.";
+ myError = "Box builder with dimensions :: Dz is null or negative.";
return false;
}
} else if (myMethodType == MethodType::BOX_POINTS) {
if (!myFirstPoint.get()) {
- myError = "Box builder with points :: the first point is not a correct";
+ myError = "Box builder with points :: the first point is not valid.";
return false;
}
if (!mySecondPoint.get()) {
- myError = "Box builder with points :: the second point is not a correct";
+ myError = "Box builder with points :: the second point is not valid.";
return false;
}
if (myFirstPoint->distance(mySecondPoint) < Precision::Confusion()) {
if (fabs(aDiffX) < Precision::Confusion() ||
fabs(aDiffY) < Precision::Confusion() ||
fabs(aDiffZ) < Precision::Confusion()) {
- myError = "The points belong both to one of the OXY, OYZ or OZX planes";
+ myError =
+ "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.";
return false;
}
} else {
void GeomAlgoAPI_Box::buildWithDimensions()
{
myCreatedFaces.clear();
-
+
// Construct the box
BRepPrimAPI_MakeBox *aBoxMaker = new BRepPrimAPI_MakeBox(myDx, myDy, myDz);
aBoxMaker->Build();
-
+
// Test the algorithm
if (!aBoxMaker->IsDone()) {
myError = "Box builder with dimensions :: algorithm failed.";
return;
}
-
+
TopoDS_Shape aResult = aBoxMaker->Shape();
std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(aResult));
setShape(aShape);
-
+
// Test on the shapes
if (!aShape.get() || aShape->isNull()) {
myError = "Box builder with dimensions :: resulting shape is null.";
return;
}
-
+
setImpl(aBoxMaker);
-
+
setDone(true);
}
-
//=================================================================================================
void GeomAlgoAPI_Box::buildWithPoints()
{
myCreatedFaces.clear();
-
+
const gp_Pnt& aFirstPoint = myFirstPoint->impl<gp_Pnt>();
const gp_Pnt& aSecondPoint = mySecondPoint->impl<gp_Pnt>();
// Construct the box
BRepPrimAPI_MakeBox *aBoxMaker = new BRepPrimAPI_MakeBox(aFirstPoint, aSecondPoint);
aBoxMaker->Build();
-
+
// Test the algorithm
if(!aBoxMaker->IsDone()) {
myError = "Box builder with two points :: algorithm failed.";
return;
}
-
+
TopoDS_Shape aResult = aBoxMaker->Shape();
-
+
std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(aResult));
setShape(aShape);
-
+
// Tests on the shape
if (!aShape.get() || aShape->isNull()) {
myError = "Box builder with two points :: resulting shape is null.";
return;
}
-
+
setImpl(aBoxMaker);
-
+
setDone(true);
}
std::shared_ptr<GeomAPI_Shape> aShapeBack(new GeomAPI_Shape);
aShapeBack->setImpl(new TopoDS_Shape(aBoxMaker.BackFace()));
myCreatedFaces["Back"] = aShapeBack;
- std::shared_ptr<GeomAPI_Shape> aShapeTop(new GeomAPI_Shape);
+ std::shared_ptr<GeomAPI_Shape> aShapeTop(new GeomAPI_Shape);
aShapeTop->setImpl(new TopoDS_Shape(aBoxMaker.TopFace()));
myCreatedFaces["Top"] = aShapeTop;
- std::shared_ptr<GeomAPI_Shape> aShapeBottom(new GeomAPI_Shape);
+ std::shared_ptr<GeomAPI_Shape> aShapeBottom(new GeomAPI_Shape);
aShapeBottom->setImpl(new TopoDS_Shape(aBoxMaker.BottomFace()));
myCreatedFaces["Bottom"] = aShapeBottom;
- std::shared_ptr<GeomAPI_Shape> aShapeLeft(new GeomAPI_Shape);
+ std::shared_ptr<GeomAPI_Shape> aShapeLeft(new GeomAPI_Shape);
aShapeLeft->setImpl(new TopoDS_Shape(aBoxMaker.LeftFace()));
myCreatedFaces["Left"] = aShapeLeft;
- std::shared_ptr<GeomAPI_Shape> aShapeRight(new GeomAPI_Shape);
+ std::shared_ptr<GeomAPI_Shape> aShapeRight(new GeomAPI_Shape);
aShapeRight->setImpl(new TopoDS_Shape(aBoxMaker.RightFace()));
myCreatedFaces["Right"] = aShapeRight;
}