From c5e3c549f2654ee2b542b2f490263edfcdca6687 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Fri, 9 Dec 2022 17:31:47 -0500 Subject: [PATCH] [TD]fix fail to load CS for some profiles and directions --- src/Mod/TechDraw/App/DrawComplexSection.cpp | 26 +++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawComplexSection.cpp b/src/Mod/TechDraw/App/DrawComplexSection.cpp index 8520c5414870b..e31b6fd0e3608 100644 --- a/src/Mod/TechDraw/App/DrawComplexSection.cpp +++ b/src/Mod/TechDraw/App/DrawComplexSection.cpp @@ -175,7 +175,7 @@ TopoDS_Shape DrawComplexSection::getShapeToCut() TopoDS_Shape DrawComplexSection::makeCuttingTool(double dMax) { - // Base::Console().Message("DCS::makeCuttingTool()\n"); +// Base::Console().Message("DCS::makeCuttingTool()\n"); TopoDS_Wire profileWire = makeProfileWire(); if (profileWire.IsNull()) { throw Base::RuntimeError("Can not make wire from cutting tool (1)"); @@ -282,8 +282,8 @@ TopoDS_Shape DrawComplexSection::prepareShape(const TopoDS_Shape& cutShape, doub void DrawComplexSection::makeSectionCut(TopoDS_Shape& baseShape) { - // Base::Console().Message("DCS::makeSectionCut() - %s - baseShape.IsNull: %d\n", - // getNameInDocument(), baseShape.IsNull()); +// Base::Console().Message("DCS::makeSectionCut() - %s - baseShape.IsNull: %d\n", +// getNameInDocument(), baseShape.IsNull()); if (ProjectionStrategy.getValue() == 0) { //Offset. Use regular section behaviour return DrawViewSection::makeSectionCut(baseShape); @@ -325,7 +325,12 @@ void DrawComplexSection::onSectionCutFinished() //TODO: this process should replace the "makeSectionCut" from DVS void DrawComplexSection::makeAlignedPieces(const TopoDS_Shape& rawShape) { - // Base::Console().Message("DCS::makeAlignedPieces() - rawShape.isNull: %d\n", rawShape.IsNull()); +// Base::Console().Message("DCS::makeAlignedPieces() - rawShape.isNull: %d\n", rawShape.IsNull()); + + if (!canBuild(getSectionCS(), CuttingToolWireObject.getValue())) { + throw Base::RuntimeError("Profile is parallel to Section Normal"); + } + std::vector pieces; std::vector pieceXSizeAll;//size in sectionCS.XDirection (width) std::vector pieceYSizeAll;//size in sectionCS.Direction (depth) @@ -346,13 +351,13 @@ void DrawComplexSection::makeAlignedPieces(const TopoDS_Shape& rawShape) throw Base::RuntimeError("Can not make wire from cutting tool (2)"); } gp_Vec gProfileVec = makeProfileVector(profileWire); + gp_Vec rotateAxis = (getSectionCS().Direction()).Crossed(gProfileVec); + //now we want to know what the profileVector looks like on the page (only X,Y coords) + //so we know if we are going to stack views vertically or horizontally and if the segments + //will occur (left to right or right to left) or (top to bottom or bottom to top) gProfileVec = projectVector(gProfileVec).Normalized(); - if (!canBuild(getSectionCS(), CuttingToolWireObject.getValue())) { - throw Base::RuntimeError("Profile is parallel to Section Normal"); - } - bool isProfileVertical = true; if (fabs(gProfileVec.Dot(gp::OY().Direction().XYZ())) != 1.0) { //profile is not parallel with stdY (paper space Up). @@ -371,11 +376,8 @@ void DrawComplexSection::makeAlignedPieces(const TopoDS_Shape& rawShape) verticalReverser = -1.0; } - gp_Vec rotateAxis = getSectionCS().Direction().Crossed(gProfileVec); - //make a tool for each segment of the toolFaceShape and intersect it with the //raw shape - // TopExp_Explorer expFaces(toolFaceShape, TopAbs_FACE); TopExp_Explorer expFaces(m_toolFaceShape, TopAbs_FACE); for (int iPiece = 0; expFaces.More(); expFaces.Next(), iPiece++) { TopoDS_Face face = TopoDS::Face(expFaces.Current()); @@ -385,7 +387,7 @@ void DrawComplexSection::makeAlignedPieces(const TopoDS_Shape& rawShape) continue; } //we only want to reverse the segment normal if it is not perpendicular to section normal - if (segmentNormal.Dot(-gProjectionUnit) != 0.0 + if (segmentNormal.Dot(gProjectionUnit) != 0.0 && segmentNormal.Angle(gProjectionUnit) <= M_PI_2) { segmentNormal.Reverse(); }