00001 /*************************************************************************** 00002 * Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> * 00003 * * 00004 * This file is part of the FreeCAD CAx development system. * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Library General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU Library General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Library General Public * 00017 * License along with this library; see the file COPYING.LIB. If not, * 00018 * write to the Free Software Foundation, Inc., 59 Temple Place, * 00019 * Suite 330, Boston, MA 02111-1307, USA * 00020 * * 00021 ***************************************************************************/ 00022 00023 00024 #include "PreCompiled.h" 00025 #ifndef _PreComp_ 00026 # include <TopExp_Explorer.hxx> 00027 # include <TopoDS.hxx> 00028 # include <TopoDS_Edge.hxx> 00029 #endif 00030 00031 #include <Mod/Part/App/TopoShape.h> 00032 00033 #include "FeatureChamfer.h" 00034 00035 00036 using namespace PartDesign; 00037 00038 00039 PROPERTY_SOURCE(PartDesign::Chamfer, PartDesign::DressUp) 00040 00041 Chamfer::Chamfer() 00042 { 00043 ADD_PROPERTY(Size,(1.0f)); 00044 } 00045 00046 short Chamfer::mustExecute() const 00047 { 00048 if (Base.isTouched() || Size.isTouched()) 00049 return 1; 00050 if (Base.getValue() && Base.getValue()->isTouched()) 00051 return 1; 00052 return 0; 00053 } 00054 00055 App::DocumentObjectExecReturn *Chamfer::execute(void) 00056 { 00057 /* App::DocumentObject* link = Base.getValue(); 00058 if (!link) 00059 return new App::DocumentObjectExecReturn("No object linked"); 00060 if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) 00061 return new App::DocumentObjectExecReturn("Linked object is not a Part object"); 00062 Part::Feature *base = static_cast<Part::Feature*>(Base.getValue()); 00063 const Part::TopoShape& TopShape = base->Shape.getShape(); 00064 00065 const std::vector<std::string>& SubVals = Base.getSubValuesStartsWith("Edge"); 00066 if (SubVals.size() == 0) 00067 return new App::DocumentObjectExecReturn("No Edges specified"); 00068 00069 float radius = Radius.getValue(); 00070 00071 try { 00072 BRepChamferAPI_MakeChamfer mkChamfer(base->Shape.getValue()); 00073 00074 for (std::vector<std::string>::const_iterator it= SubVals.begin();it!=SubVals.end();++it) { 00075 TopoDS_Edge edge = TopoDS::Edge(TopShape.getSubShape(it->c_str())); 00076 mkChamfer.Add(radius, radius, edge); 00077 } 00078 00079 TopoDS_Shape shape = mkChamfer.Shape(); 00080 if (shape.IsNull()) 00081 return new App::DocumentObjectExecReturn("Resulting shape is null"); 00082 this->Shape.setValue(shape); 00083 return App::DocumentObject::StdReturn; 00084 } 00085 catch (Standard_Failure) { 00086 Handle_Standard_Failure e = Standard_Failure::Caught(); 00087 return new App::DocumentObjectExecReturn(e->GetMessageString()); 00088 }*/ 00089 00090 return App::DocumentObject::StdReturn; 00091 }