Rotate DrawViewPart around part centroid
This commit is contained in:
@@ -249,6 +249,11 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
inputCenter,
|
||||
scale);
|
||||
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
mirroredShape = TechDrawGeometry::rotateShape(mirroredShape,
|
||||
viewAxis,
|
||||
Rotation.getValue());
|
||||
}
|
||||
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
|
||||
geometryObject->pruneVertexGeom(Base::Vector3d(0.0,0.0,0.0),Radius.getValue() * scale); //remove vertices beyond clipradius
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
|
||||
#include "Geometry.h"
|
||||
#include "GeometryObject.h"
|
||||
#include "DrawUtil.h"
|
||||
#include "DrawViewMulti.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
@@ -179,6 +180,11 @@ App::DocumentObjectExecReturn *DrawViewMulti::execute(void)
|
||||
inputCenter,
|
||||
getScale());
|
||||
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
mirroredShape = TechDrawGeometry::rotateShape(mirroredShape,
|
||||
viewAxis,
|
||||
Rotation.getValue());
|
||||
}
|
||||
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
|
||||
|
||||
#if MOD_TECHDRAW_HANDLE_FACES
|
||||
|
||||
@@ -218,6 +218,11 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
getScale());
|
||||
|
||||
gp_Ax2 viewAxis = getViewAxis(shapeCentroid,Direction.getValue());
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
mirroredShape = TechDrawGeometry::rotateShape(mirroredShape,
|
||||
viewAxis,
|
||||
Rotation.getValue());
|
||||
}
|
||||
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
|
||||
|
||||
#if MOD_TECHDRAW_HANDLE_FACES
|
||||
|
||||
@@ -260,6 +260,11 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
inputCenter,
|
||||
getScale());
|
||||
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
mirroredShape = TechDrawGeometry::rotateShape(mirroredShape,
|
||||
viewAxis,
|
||||
Rotation.getValue());
|
||||
}
|
||||
geometryObject = buildGeometryObject(mirroredShape,viewAxis); //this is original shape after cut by section prism
|
||||
|
||||
#if MOD_TECHDRAW_HANDLE_FACES
|
||||
@@ -276,6 +281,12 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
TopoDS_Shape mirroredSection = TechDrawGeometry::mirrorShape(sectionCompound,
|
||||
inputCenter,
|
||||
getScale());
|
||||
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
mirroredSection = TechDrawGeometry::rotateShape(mirroredSection,
|
||||
viewAxis,
|
||||
Rotation.getValue());
|
||||
}
|
||||
|
||||
sectionFaceWires.clear();
|
||||
TopoDS_Compound newFaces;
|
||||
|
||||
@@ -561,6 +561,32 @@ TopoDS_Shape TechDrawGeometry::mirrorShape(const TopoDS_Shape &input,
|
||||
return transShape;
|
||||
}
|
||||
|
||||
//!rotates a shape about a viewAxis
|
||||
TopoDS_Shape TechDrawGeometry::rotateShape(const TopoDS_Shape &input,
|
||||
gp_Ax2& viewAxis,
|
||||
double rotAngle)
|
||||
{
|
||||
TopoDS_Shape transShape;
|
||||
if (input.IsNull()) {
|
||||
return transShape;
|
||||
}
|
||||
|
||||
gp_Ax1 rotAxis = viewAxis.Axis();
|
||||
double rotation = rotAngle * M_PI/180.0;
|
||||
|
||||
try {
|
||||
gp_Trsf tempTransform;
|
||||
tempTransform.SetRotation(rotAxis,rotation);
|
||||
BRepBuilderAPI_Transform mkTrf(input, tempTransform);
|
||||
transShape = mkTrf.Shape();
|
||||
}
|
||||
catch (...) {
|
||||
Base::Console().Log("GeometryObject::rotateShape - rotate failed.\n");
|
||||
return transShape;
|
||||
}
|
||||
return transShape;
|
||||
}
|
||||
|
||||
//!scales a shape about a origin
|
||||
TopoDS_Shape TechDrawGeometry::scaleShape(const TopoDS_Shape &input,
|
||||
double scale)
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/BoundBox.h>
|
||||
@@ -55,6 +56,10 @@ TopoDS_Shape TechDrawExport mirrorShape(const TopoDS_Shape &input,
|
||||
double scale = 1.0);
|
||||
TopoDS_Shape TechDrawExport scaleShape(const TopoDS_Shape &input,
|
||||
double scale);
|
||||
TopoDS_Shape TechDrawExport rotateShape(const TopoDS_Shape &input,
|
||||
gp_Ax2& viewAxis,
|
||||
double rotAngle);
|
||||
|
||||
|
||||
//! Returns the centroid of shape, as viewed according to direction
|
||||
gp_Pnt TechDrawExport findCentroid(const TopoDS_Shape &shape,
|
||||
|
||||
Reference in New Issue
Block a user