From 5689e4c13b5f90da61eca4dd5f811014f538ece1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 15 Apr 2017 19:32:49 +0200 Subject: [PATCH] remove superfluous FillType enum --- src/Mod/Surface/App/CMakeLists.txt | 1 - src/Mod/Surface/App/FeatureBSplineSurface.cpp | 2 -- src/Mod/Surface/App/FeatureBezierSurface.cpp | 2 -- src/Mod/Surface/App/FeatureSurface.cpp | 33 ++++++----------- src/Mod/Surface/App/FeatureSurface.h | 4 --- src/Mod/Surface/App/FillType.h | 35 ------------------- src/Mod/Surface/Gui/SurfaceFilling.cpp | 28 +++++++-------- src/Mod/Surface/Gui/SurfaceFilling.h | 1 - 8 files changed, 25 insertions(+), 81 deletions(-) delete mode 100644 src/Mod/Surface/App/FillType.h diff --git a/src/Mod/Surface/App/CMakeLists.txt b/src/Mod/Surface/App/CMakeLists.txt index 97b2f563c6..9b50ff5534 100644 --- a/src/Mod/Surface/App/CMakeLists.txt +++ b/src/Mod/Surface/App/CMakeLists.txt @@ -33,7 +33,6 @@ SET(Surface_SRCS FeatureBezierSurface.h FeatureBSplineSurface.cpp FeatureBSplineSurface.h - FillType.h ) link_directories(${OCC_LIBRARY_DIR}) diff --git a/src/Mod/Surface/App/FeatureBSplineSurface.cpp b/src/Mod/Surface/App/FeatureBSplineSurface.cpp index e7eef619a3..aeeea87454 100644 --- a/src/Mod/Surface/App/FeatureBSplineSurface.cpp +++ b/src/Mod/Surface/App/FeatureBSplineSurface.cpp @@ -57,8 +57,6 @@ BSplineSurface::BSplineSurface() : SurfaceFeature() App::DocumentObjectExecReturn *BSplineSurface::execute(void) { - correcteInvalidFillType(); - try{ std::vector crvs; crvs.reserve(4); diff --git a/src/Mod/Surface/App/FeatureBezierSurface.cpp b/src/Mod/Surface/App/FeatureBezierSurface.cpp index 394bdb7df2..482726fd2b 100644 --- a/src/Mod/Surface/App/FeatureBezierSurface.cpp +++ b/src/Mod/Surface/App/FeatureBezierSurface.cpp @@ -54,8 +54,6 @@ BezierSurface::BezierSurface() : SurfaceFeature() App::DocumentObjectExecReturn *BezierSurface::execute(void) { - correcteInvalidFillType(); - try { std::vector crvs; crvs.reserve(4); diff --git a/src/Mod/Surface/App/FeatureSurface.cpp b/src/Mod/Surface/App/FeatureSurface.cpp index 804dab0469..0796f2a714 100644 --- a/src/Mod/Surface/App/FeatureSurface.cpp +++ b/src/Mod/Surface/App/FeatureSurface.cpp @@ -150,7 +150,7 @@ void ShapeValidator::checkAndAdd(const Part::TopoShape &ts, const char *subName, PROPERTY_SOURCE(Surface::SurfaceFeature, Part::Feature) -const char* SurfaceFeature::FillTypeEnums[] = {"Invalid", "Stretched", "Coons", "Curved", NULL}; +const char* SurfaceFeature::FillTypeEnums[] = {"Stretched", "Coons", "Curved", NULL}; SurfaceFeature::SurfaceFeature(): Feature() { @@ -174,19 +174,17 @@ short SurfaceFeature::mustExecute() const GeomFill_FillingStyle SurfaceFeature::getFillingStyle() { //Identify filling style - int ftype = FillType.getValue(); - if (ftype==StretchStyle) - return GeomFill_StretchStyle; - else if(ftype==CoonsStyle) - return GeomFill_CoonsStyle; - else if(ftype==CurvedStyle) - return GeomFill_CurvedStyle; - else - Standard_Failure::Raise("Filling style must be 1 (Stretch), 2 (Coons), or 3 (Curved)."); - throw; // this is to shut up the compiler + switch (FillType.getValue()) { + case GeomFill_StretchStyle: + case GeomFill_CoonsStyle: + case GeomFill_CurvedStyle: + return static_cast(FillType.getValue()); + default: + Standard_Failure::Raise("Filling style must be 0 (Stretch), 1 (Coons), or 2 (Curved).\n"); + throw; // this is to shut up the compiler + } } - void SurfaceFeature::getWire(TopoDS_Wire& aWire) { Handle(ShapeFix_Wire) aShFW = new ShapeFix_Wire; @@ -214,7 +212,7 @@ void SurfaceFeature::getWire(TopoDS_Wire& aWire) } if (validator.numEdges() < 2 || validator.numEdges() > 4) { - Standard_Failure::Raise("Only 2-4 curves are allowed"); + Standard_Failure::Raise("Only 2-4 curves are allowed\n"); } //Reorder the curves and fix the wire if required @@ -251,12 +249,3 @@ void SurfaceFeature::createFace(const Handle_Geom_BoundedSurface &aSurface) } this->Shape.setValue(aFace); } - -void SurfaceFeature::correcteInvalidFillType() -{ - int ftype = FillType.getValue(); - if(ftype == InvalidStyle) - { - FillType.setValue(StretchStyle); - } -} diff --git a/src/Mod/Surface/App/FeatureSurface.h b/src/Mod/Surface/App/FeatureSurface.h index cf40c8ae11..a6e7023a68 100644 --- a/src/Mod/Surface/App/FeatureSurface.h +++ b/src/Mod/Surface/App/FeatureSurface.h @@ -32,7 +32,6 @@ #include #include #include -#include namespace Surface { @@ -83,9 +82,6 @@ protected: void getWire(TopoDS_Wire& aWire); void createFace(const Handle_Geom_BoundedSurface &aSurface); - // corrects the initially invalid fill type - void correcteInvalidFillType(); - private: static const char* FillTypeEnums[]; }; diff --git a/src/Mod/Surface/App/FillType.h b/src/Mod/Surface/App/FillType.h deleted file mode 100644 index ac173d93d5..0000000000 --- a/src/Mod/Surface/App/FillType.h +++ /dev/null @@ -1,35 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2015 Balázs Bámer * - * * - * 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 * - * * - ***************************************************************************/ - - -#ifndef SURFACE_FILLTYPE_H -#define SURFACE_FILLTYPE_H - -enum FillType_t -{ - InvalidStyle = 0, - StretchStyle, - CoonsStyle, - CurvedStyle -}; - -#endif // SURAFCE_FILLTYPE_H diff --git a/src/Mod/Surface/Gui/SurfaceFilling.cpp b/src/Mod/Surface/Gui/SurfaceFilling.cpp index 0fa8ace9c8..1baf48ac04 100644 --- a/src/Mod/Surface/Gui/SurfaceFilling.cpp +++ b/src/Mod/Surface/Gui/SurfaceFilling.cpp @@ -25,8 +25,8 @@ #include #include #include +#include -#include #include #include #include @@ -149,16 +149,16 @@ SurfaceFilling::~SurfaceFilling() void SurfaceFilling::setEditedObject(Surface::SurfaceFeature* obj) { editedObject = obj; - long curtype = editedObject->FillType.getValue(); + GeomFill_FillingStyle curtype = static_cast(editedObject->FillType.getValue()); switch(curtype) { - case 1: // StretchStyle + case GeomFill_StretchStyle: ui->fillType_stretch->setChecked(true); break; - case 2: // CoonsStyle + case GeomFill_CoonsStyle: ui->fillType_coons->setChecked(true); break; - case 3: // CurvedStyle + case GeomFill_CurvedStyle: ui->fillType_curved->setChecked(true); break; default: @@ -265,9 +265,9 @@ bool SurfaceFilling::reject() void SurfaceFilling::on_fillType_stretch_clicked() { - long curtype = editedObject->FillType.getValue(); - if (curtype != 1) { - editedObject->FillType.setValue(1); + GeomFill_FillingStyle curtype = static_cast(editedObject->FillType.getValue()); + if (curtype != GeomFill_StretchStyle) { + editedObject->FillType.setValue(static_cast(GeomFill_StretchStyle)); editedObject->recomputeFeature(); if (!editedObject->isValid()) { Base::Console().Error("Surface filling: %s", editedObject->getStatusString()); @@ -277,9 +277,9 @@ void SurfaceFilling::on_fillType_stretch_clicked() void SurfaceFilling::on_fillType_coons_clicked() { - long curtype = editedObject->FillType.getValue(); - if (curtype != 2) { - editedObject->FillType.setValue(2); + GeomFill_FillingStyle curtype = static_cast(editedObject->FillType.getValue()); + if (curtype != GeomFill_CoonsStyle) { + editedObject->FillType.setValue(static_cast(GeomFill_CoonsStyle)); editedObject->recomputeFeature(); if (!editedObject->isValid()) { Base::Console().Error("Surface filling: %s", editedObject->getStatusString()); @@ -289,9 +289,9 @@ void SurfaceFilling::on_fillType_coons_clicked() void SurfaceFilling::on_fillType_curved_clicked() { - long curtype = editedObject->FillType.getValue(); - if (curtype != 3) { - editedObject->FillType.setValue(3); + GeomFill_FillingStyle curtype = static_cast(editedObject->FillType.getValue()); + if (curtype != GeomFill_CurvedStyle) { + editedObject->FillType.setValue(static_cast(GeomFill_CurvedStyle)); editedObject->recomputeFeature(); if (!editedObject->isValid()) { Base::Console().Error("Surface filling: %s", editedObject->getStatusString()); diff --git a/src/Mod/Surface/Gui/SurfaceFilling.h b/src/Mod/Surface/Gui/SurfaceFilling.h index bb6f782089..937e04b674 100644 --- a/src/Mod/Surface/Gui/SurfaceFilling.h +++ b/src/Mod/Surface/Gui/SurfaceFilling.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include