MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / validateOffsetProfile

Method validateOffsetProfile

src/Mod/TechDraw/App/DrawComplexSection.cpp:806–824  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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
806bool 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

Callers

nothing calls this directly

Calls 5

EdgeClass · 0.50
MoreMethod · 0.45
NextMethod · 0.45
GetAngleMethod · 0.45
warningMethod · 0.45

Tested by

no test coverage detected