//=================================================================================================
GeomAlgoAPI_Rotation::GeomAlgoAPI_Rotation(std::shared_ptr<GeomAPI_Shape> theSourceShape,
std::shared_ptr<GeomAPI_Ax1> theAxis,
- double theAngle)
+ double theAngle,
+ bool theSimpleTransform)
: myDone(false),
myShape(new GeomAPI_Shape()),
myMap(new GeomAPI_DataMapOfShapeShape()),
myMkShape(new GeomAlgoAPI_MakeShape())
{
- build(theSourceShape, theAxis, theAngle);
+ build(theSourceShape, theAxis, theAngle, theSimpleTransform);
}
//=================================================================================================
void GeomAlgoAPI_Rotation::build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
std::shared_ptr<GeomAPI_Ax1> theAxis,
- double theAngle)
+ double theAngle,
+ bool theSimpleTransform)
{
if(!theSourceShape || !theAxis) {
return;
gp_Trsf aTrsf;
aTrsf.SetRotation(anAxis, theAngle / 180.0 * M_PI);
+ TopoDS_Shape aResult;
// Transform the shape with copying it.
- BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
- if(!aBuilder) {
- return;
- }
-
- myDone = aBuilder->IsDone() == Standard_True;
-
- if(!myDone) {
- return;
- }
-
- TopoDS_Shape aResult = aBuilder->Shape();
- // Fill data map to keep correct orientation of sub-shapes.
- for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More(); anExp.Next()) {
- std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
- aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
- myMap->bind(aCurrentShape, aCurrentShape);
+ if (theSimpleTransform) {
+ TopLoc_Location aDelta(aTrsf);
+ aResult = aSourceShape.Moved(aDelta);
+ myDone = true; // is OK for sure
+ } else {
+ BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
+ if(!aBuilder) {
+ return;
+ }
+
+ myDone = aBuilder->IsDone() == Standard_True;
+
+ if(!myDone) {
+ return;
+ }
+
+ aResult = aBuilder->Shape();
+ // Fill data map to keep correct orientation of sub-shapes.
+ for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More(); anExp.Next()) {
+ std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+ aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
+ myMap->bind(aCurrentShape, aCurrentShape);
+ }
+ myMkShape->setImpl(aBuilder);
}
myShape->setImpl(new TopoDS_Shape(aResult));
- myMkShape->setImpl(aBuilder);
}
//=================================================================================================