From 04e5d833669ff4ac14ac224e38a38d2111797806 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Fri, 24 May 2013 15:13:53 +0430 Subject: [PATCH] Revolution/Groove: Check that rotation axis is coplanar with sketch plane --- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index a4fabb94c..4f0d74c21 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -1009,12 +1009,21 @@ void SketchBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std: dir = Base::Vector3d(0,0,0); // If unchanged signals that no valid axis was found Part::Part2DObject* sketch = getVerifiedSketch(); Base::Placement SketchPlm = sketch->Placement.getValue(); + Base::Vector3d SketchPos = SketchPlm.getPosition(); + Base::Rotation SketchOrientation = SketchPlm.getRotation(); + Base::Vector3d SketchVector(0,0,1); + SketchOrientation.multVec(SketchVector,SketchVector); + gp_Pln sketchplane(gp_Pnt(SketchPos.x, SketchPos.y, SketchPos.z), gp_Dir(SketchVector.x, SketchVector.y, SketchVector.z)); // get reference axis if (pcReferenceAxis->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) { const PartDesign::Line* line = static_cast(pcReferenceAxis); base = line->getBasePoint(); dir = line->getDirection(); + + // Check that axis is co-planar with sketch plane! + if (!sketchplane.Contains(gp_Lin(gp_Pnt(base.x, base.y, base.z), gp_Dir(dir.x, dir.y, dir.z)), Precision::Confusion(), Precision::Confusion())) + throw Base::Exception("Rotation axis must be coplanar with the sketch plane"); } else if (pcReferenceAxis->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId())) { if (subReferenceAxis[0].empty()) throw Base::Exception("No rotation axis reference specified"); @@ -1034,6 +1043,9 @@ void SketchBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std: base = Base::Vector3d(b.X(), b.Y(), b.Z()); gp_Dir d = adapt.Line().Direction(); dir = Base::Vector3d(d.X(), d.Y(), d.Z()); + // Check that axis is co-planar with sketch plane! + if (!sketchplane.Contains(adapt.Line(), Precision::Confusion(), Precision::Confusion())) + throw Base::Exception("Rotation axis must be coplanar with the sketch plane"); } else { throw Base::Exception("Rotation reference must be an edge"); }