check for profile segments that are almost, but not quite in the same direction as the section normal direction. this often indicates a problem with the direction being slightly wrong. see https://forum.freecad.org/viewtopic.php?t=79017&sid=612a62a60f5db955ee071a7aaa362dbb
| 804 | // as the section normal direction. this often indicates a problem with the direction |
| 805 | // being slightly wrong. see https://forum.freecad.org/viewtopic.php?t=79017&sid=612a62a60f5db955ee071a7aaa362dbb |
| 806 | bool DrawComplexSection::validateOffsetProfile(const TopoDS_Wire& profile, Base::Vector3d direction, double angleThresholdDeg) const |
| 807 | { |
| 808 | constexpr double HalfCircleDegrees{180.0}; |
| 809 | double angleThresholdRad = angleThresholdDeg * std::numbers::pi / HalfCircleDegrees; |
| 810 | TopExp_Explorer explEdges(profile, TopAbs_EDGE); |
| 811 | for (; explEdges.More(); explEdges.Next()) { |
| 812 | std::pair<Base::Vector3d, Base::Vector3d> segmentEnds = getSegmentEnds(TopoDS::Edge(explEdges.Current())); |
| 813 | Base::Vector3d segmentDir = segmentEnds.second - segmentEnds.first; |
| 814 | double angleRad = segmentDir.GetAngle(direction); |
| 815 | if (angleRad < angleThresholdRad && |
| 816 | angleRad > 0.0) { |
| 817 | // profile segment is slightly skewed. possible bad SectionNormal? |
| 818 | Base::Console().warning("%s profile is slightly skewed. Check SectionNormal low decimal places\n", |
| 819 | getNameInDocument()); |
| 820 | return false; |
| 821 | } |
| 822 | } |
| 823 | return true; |
| 824 | } |
| 825 | |
| 826 | |
| 827 | // next two methods could be templated (??) to handle edge/wire |