myDz = theDz;
}
+//=================================================================================================
+GeomAlgoAPI_Translation::GeomAlgoAPI_Translation(std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Pnt> theStartPoint,
+ std::shared_ptr<GeomAPI_Pnt> theEndPoint)
+{
+ myMethodType = BY_POINTS;
+ mySourceShape = theSourceShape;
+ myStartPoint = theStartPoint;
+ myEndPoint = theEndPoint;
+}
+
//=================================================================================================
bool GeomAlgoAPI_Translation::check()
{
myError = "Translation builder :: axis is invalid.";
return false;
}
- // TODO : verification de la distance
if (!mySourceShape) {
myError = "Translation builder :: source shape is invalid.";
return false;
return true;
}
case BY_DIM: {
- if ((fabs(myDx) < Precision::Confusion()) &&
- (fabs(myDy) < Precision::Confusion()) &&
- (fabs(myDz) < Precision::Confusion())) {
- myError = "Translation builder :: Dx, Dy and Dz are null.";
+ if (!mySourceShape) {
+ myError = "Translation builder :: source shape is invalid.";
+ return false;
+ }
+ return true;
+ }
+ case BY_POINTS: {
+ if (!myStartPoint) {
+ myError = "Translation builder :: start point is invalid.";
+ return false;
+ }
+ if (!myEndPoint) {
+ myError = "Translation builder :: start point is invalid.";
return false;
}
if (!mySourceShape) {
aTrsf->SetTranslation(gp_Vec(myDx, myDy, myDz));
break;
}
+ case BY_POINTS: {
+ const gp_Pnt& aStartPoint = myStartPoint->impl<gp_Pnt>();
+ const gp_Pnt& aEndPoint = myEndPoint->impl<gp_Pnt>();
+ aTrsf->SetTranslation(aStartPoint, aEndPoint);
+ break;
+ }
default: {
myError = "Translation builder :: method not supported";
return;
// Transform the shape while copying it.
BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, *aTrsf, true);
if(!aBuilder) {
- myError = "Translation builder :: source shape does not contain any actual shape.";
+ myError = "Translation builder :: transform initialization failed.";
return;
}
setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
if(!aBuilder->IsDone()) {
- myError = "Translation builder :: source shape does not contain any actual shape.";
+ myError = "Translation builder :: algorithm failed.";
return;
}