/*************************************************************************** * Copyright (c) 2020 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; see the file COPYING.LIB. If not, * * write to the Free Software Foundation, Inc., 59 Temple Place, * * Suite 330, Boston, MA 02111-1307, USA * * * ***************************************************************************/ #include "PreCompiled.h" #ifndef _PreComp_ # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include #endif #include #include #include #include #include #include "FeatureExtrude.h" using namespace PartDesign; PROPERTY_SOURCE(PartDesign::FeatureExtrude, PartDesign::ProfileBased) FeatureExtrude::FeatureExtrude() { } short FeatureExtrude::mustExecute() const { if (Placement.isTouched() || Type.isTouched() || Length.isTouched() || Length2.isTouched() || UseCustomVector.isTouched() || Direction.isTouched() || ReferenceAxis.isTouched() || AlongSketchNormal.isTouched() || Offset.isTouched() || UpToFace.isTouched()) return 1; return ProfileBased::mustExecute(); } Base::Vector3d FeatureExtrude::computeDirection(const Base::Vector3d& sketchVector) { Base::Vector3d extrudeDirection; if (!UseCustomVector.getValue()) { if (!ReferenceAxis.getValue()) { // use sketch's normal vector for direction extrudeDirection = sketchVector; AlongSketchNormal.setReadOnly(true); } else { // update Direction from ReferenceAxis App::DocumentObject* pcReferenceAxis = ReferenceAxis.getValue(); const std::vector& subReferenceAxis = ReferenceAxis.getSubValues(); Base::Vector3d base; Base::Vector3d dir; getAxis(pcReferenceAxis, subReferenceAxis, base, dir, ForbiddenAxis::NotPerpendicularWithNormal); switch (addSubType) { case Type::Additive: extrudeDirection = dir; break; case Type::Subtractive: extrudeDirection = -dir; break; } } } else { // use the given vector // if null vector, use sketchVector if ((fabs(Direction.getValue().x) < Precision::Confusion()) && (fabs(Direction.getValue().y) < Precision::Confusion()) && (fabs(Direction.getValue().z) < Precision::Confusion())) { Direction.setValue(sketchVector); } extrudeDirection = Direction.getValue(); } // disable options of UseCustomVector Direction.setReadOnly(!UseCustomVector.getValue()); ReferenceAxis.setReadOnly(UseCustomVector.getValue()); // UseCustomVector allows AlongSketchNormal but !UseCustomVector does not forbid it if (UseCustomVector.getValue()) AlongSketchNormal.setReadOnly(false); // explicitly set the Direction so that the dialog shows also the used direction // if the sketch's normal vector was used Direction.setValue(extrudeDirection); return extrudeDirection; }