[TD]fix Orientation of Detail of Section of DPG

This commit is contained in:
wandererfan
2019-10-26 13:56:43 -04:00
committed by WandererFan
parent d296e10cb4
commit a6357bc86e
3 changed files with 55 additions and 40 deletions

View File

@@ -115,8 +115,8 @@ DrawViewDetail::DrawViewDetail()
m_fudge = 1.01;
//hide Properties not relevant to DVDetail
Direction.setStatus(App::Property::Hidden,true);
Rotation.setStatus(App::Property::Hidden,true);
Direction.setStatus(App::Property::Hidden,true); //Should be same as BaseView
Rotation.setStatus(App::Property::Hidden,true); //same as BaseView
}
@@ -232,32 +232,34 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
gp_Ax2 vaBase;
viewAxis = dvp->getViewAxis(shapeCenter, dirDetail, true);
copyShape = TechDraw::moveShape(copyShape, //centre on origin
copyShape = TechDraw::moveShape(copyShape, //centre shape on origin
-shapeCenter);
gpCenter = TechDraw::findCentroid(copyShape, //sb origin!
dirDetail);
shapeCenter = Base::Vector3d(gpCenter.X(),gpCenter.Y(),gpCenter.Z());
viewAxis = dvp->getViewAxis(shapeCenter, dirDetail, false); //change view axis to (0,0,0)
anchor = Base::Vector3d(anchor.x,anchor.y, 0.0);
if (dvs != nullptr) {
viewAxis = dvs->getSectionCS(); //this goes through SO
gp_Pnt org(0.0, 0.0, 0.0);
viewAxis.SetLocation(org); //move to origin
shapeCenter = Base::Vector3d(0.0, 0.0, 0.0);
anchor = Base::Vector3d(anchor.x, anchor.y, 0.0);
}
Base::Vector3d anchorOffset3d = DrawUtil::toR3(viewAxis, anchor); //anchor displacement in R3
Bnd_Box bbxSource;
bbxSource.SetGap(0.0);
BRepBndLib::Add(copyShape, bbxSource);
double diag = sqrt(bbxSource.SquareExtent());
Base::Vector3d extentFar,extentNear;
extentFar = shapeCenter + dirDetail * diag;
extentNear = shapeCenter + dirDetail * diag * -1.0;
Base::Vector3d toolPlaneOrigin = anchorOffset3d + dirDetail * diag * -1.0; //center tool about anchor
double extrudeLength = 2.0 * toolPlaneOrigin.Length();
anchor = Base::Vector3d(anchor.x,anchor.y, 0.0);
viewAxis = dvp->getViewAxis(shapeCenter, dirDetail, false); //change view axis to (0,0,0)
Base::Vector3d offsetCenter3D = DrawUtil::toR3(viewAxis, anchor); //displacement in R3
Base::Vector3d stdZ(0.0,0.0,1.0);
if (DrawUtil::checkParallel(dirDetail,stdZ)) {
extentNear = extentNear + offsetCenter3D;
} else {
extentNear = extentNear - offsetCenter3D;
}
gp_Pnt gpnt(extentNear.x,extentNear.y,extentNear.z);
gp_Pnt gpnt(toolPlaneOrigin.x,toolPlaneOrigin.y,toolPlaneOrigin.z);
gp_Dir gdir(dirDetail.x,dirDetail.y,dirDetail.z);
gp_Pln gpln(gpnt,gdir);
double hideToolRadius = radius * 1.0;
@@ -266,7 +268,8 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
if(aProjFace.IsNull()) {
return new App::DocumentObjectExecReturn("DrawViewDetail - Projected face is NULL");
}
Base::Vector3d extrudeVec = dirDetail* (extentFar-extentNear).Length();
Base::Vector3d extrudeVec = dirDetail * extrudeLength;
gp_Vec extrudeDir(extrudeVec.x,extrudeVec.y,extrudeVec.z);
TopoDS_Shape tool = BRepPrimAPI_MakePrism(aProjFace, extrudeDir, false, true).Shape();
@@ -296,7 +299,6 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
testBox.SetGap(0.0);
BRepBndLib::Add(detail, testBox);
if (testBox.IsVoid()) {
// Base::Console().Warning("DrawViewDetail - detail area contains no geometry\n");
TechDraw::GeometryObject* go = getGeometryObject();
if (go != nullptr) {
go->clear();
@@ -316,25 +318,29 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
gp_Pnt inputCenter;
try {
inputCenter = TechDraw::findCentroid(tool,
dirDetail);
dirDetail);
TopoDS_Shape mirroredShape = TechDraw::mirrorShape(detail,
inputCenter,
scale);
viewAxis = dvp->getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),dirDetail);
inputCenter,
scale);
if (dvs != nullptr) {
viewAxis = dvs->getSectionCS();
viewAxis.SetLocation(inputCenter);
} else {
viewAxis = dvp->getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),dirDetail);
}
double shapeRotate = dvp->Rotation.getValue(); //degrees CW?
if (!DrawUtil::fpCompare(shapeRotate,0.0)) {
mirroredShape = TechDraw::rotateShape(mirroredShape,
viewAxis,
shapeRotate);
shapeRotate);
}
inputCenter = TechDraw::findCentroid(mirroredShape,
dirDetail);
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
geometryObject->pruneVertexGeom(Base::Vector3d(0.0,0.0,0.0),Radius.getValue() * scale); //remove vertices beyond clipradius
geometryObject->pruneVertexGeom(Base::Vector3d(0.0,0.0,0.0),
Radius.getValue() * scale); //remove vertices beyond clipradius
#if MOD_TECHDRAW_HANDLE_FACES
if (handleFaces()) {
@@ -355,17 +361,14 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
return new App::DocumentObjectExecReturn(e1.GetMessageString());
}
//add the cosmetic vertices to the geometry vertices list
addCosmeticVertexesToGeom();
//add the cosmetic Edges to geometry Edges list
addCosmeticEdgesToGeom();
//add centerlines to geometry edges list
addCenterLinesToGeom();
requestPaint();
dvp->requestPaint(); //to refresh detail highlight!
return App::DocumentObject::StdReturn;
return DrawView::execute();
}
double DrawViewDetail::getFudgeRadius()

View File

@@ -36,7 +36,8 @@
#include <BRepPrimAPI_MakePrism.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepAdaptor_Surface.hxx>
# include <BRep_Builder.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
#include <gp_Ax2.hxx>
#include <gp_Ax3.hxx>
#include <gp_Pnt.hxx>
@@ -265,6 +266,10 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
TopoDS_Shape rawShape = mkCut.Shape();
// BRepTools::Write(myShape, "DVSCopy.brep"); //debug
// BRepTools::Write(prism, "DVSTool.brep"); //debug
// BRepTools::Write(rawShape, "DVSResult.brep"); //debug
Bnd_Box testBox;
BRepBndLib::Add(rawShape, testBox);
testBox.SetGap(0.0);
@@ -274,11 +279,14 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
}
m_cutShape = rawShape;
m_cutShape = TechDraw::moveShape(m_cutShape, //centre on origin
-SectionOrigin.getValue());
gp_Pnt inputCenter;
gp_Ax2 viewAxis;
try {
inputCenter = TechDraw::findCentroid(rawShape,
Direction.getValue()); //??
Direction.getValue());
TopoDS_Shape mirroredShape = TechDraw::mirrorShape(rawShape,
inputCenter,
getScale());
@@ -288,7 +296,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
viewAxis,
Rotation.getValue());
}
geometryObject = buildGeometryObject(mirroredShape,viewAxis); //this is original shape after cut by section prism
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
#if MOD_TECHDRAW_HANDLE_FACES
extractFaces();
@@ -302,9 +310,8 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
try {
TopoDS_Compound sectionCompound = findSectionPlaneIntersections(rawShape);
TopoDS_Shape mirroredSection = TechDraw::mirrorShape(sectionCompound,
inputCenter,
getScale());
// gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
inputCenter,
getScale());
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
mirroredSection = TechDraw::rotateShape(mirroredSection,
viewAxis,
@@ -335,11 +342,8 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
return new App::DocumentObjectExecReturn(e2.GetMessageString());
}
//add the cosmetic vertices to the geometry vertices list
addCosmeticVertexesToGeom();
//add the cosmetic Edges to geometry Edges list
addCosmeticEdgesToGeom();
//add centerlines to geometry edges list
addCenterLinesToGeom();
return DrawView::execute();
@@ -589,6 +593,13 @@ Base::Vector3d DrawViewSection::getSectionVector (const std::string sectionName)
return result;
}
//returns current section cs
gp_Ax2 DrawViewSection::getSectionCS(void)
{
std::string dirName = SectionDirection.getValueAsString();
return getSectionCS(dirName);
}
//! calculate the section Projection CS given section direction name
gp_Ax2 DrawViewSection::getSectionCS (const std::string dirName)
{

View File

@@ -94,6 +94,7 @@ public:
Base::Vector3d axis,
double degAngle) ;
gp_Ax2 getSectionCS (const std::string dirName);
gp_Ax2 getSectionCS ();
TechDraw::DrawViewPart* getBaseDVP();
TechDraw::DrawProjGroupItem* getBaseDPGI();