X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchAPI%2FSketchAPI_Projection.cpp;h=6fc8369d66f4ac6ac34e14bf505d31d341cbd98e;hb=77ce6d35ac8d2f0fdaecb4f23e0870bf74e36103;hp=0c5c7f0bea448c2a1087473819aa991ee9a298ee;hpb=63f80d9837b4dcb16e9fafc3b07fac36f6f7b00d;p=modules%2Fshaper.git diff --git a/src/SketchAPI/SketchAPI_Projection.cpp b/src/SketchAPI/SketchAPI_Projection.cpp index 0c5c7f0be..6fc8369d6 100644 --- a/src/SketchAPI/SketchAPI_Projection.cpp +++ b/src/SketchAPI/SketchAPI_Projection.cpp @@ -1,13 +1,40 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -// Name : SketchAPI_Projection.cpp -// Purpose: +// Copyright (C) 2014-2024 CEA, EDF +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// History: -// 16/06/16 - Sergey POKHODENKO - Creation of the file -//-------------------------------------------------------------------------------------- #include "SketchAPI_Projection.h" -//-------------------------------------------------------------------------------------- + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -29,16 +56,6 @@ SketchAPI_Projection::SketchAPI_Projection( } } -SketchAPI_Projection::SketchAPI_Projection( - const std::shared_ptr & theFeature, - const std::string & theExternalName) -: SketchAPI_SketchEntity(theFeature) -{ - if (initialize()) { - setByExternalName(theExternalName); - } -} - SketchAPI_Projection::~SketchAPI_Projection() { @@ -49,23 +66,53 @@ void SketchAPI_Projection::setExternalFeature(const ModelHighAPI_Selection & the { fillAttribute(theExternalFeature, externalFeature()); - execute(); + execute(true); } -void SketchAPI_Projection::setByExternalName(const std::string& theExternalName) +void SketchAPI_Projection::setIncludeToResult(bool theKeepResult) { - fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external()); + fillAttribute(theKeepResult, includeToResult()); + execute(true); +} - execute(); +void SketchAPI_Projection::setKeepReferenceToOriginal(bool theKeepRefToOriginal) +{ + // the Fixed constraint should be assigned explicitly + fillAttribute(false, feature()->boolean(SketchPlugin_Projection::MAKE_FIXED())); + fillAttribute(theKeepRefToOriginal ? "true" : "false", + feature()->string(SketchPlugin_Projection::KEEP_REFERENCE_ID())); + execute(true); } //-------------------------------------------------------------------------------------- -std::shared_ptr SketchAPI_Projection::createdFeature() const +std::shared_ptr SketchAPI_Projection::createdFeature() const { AttributeRefAttrPtr aProjectedRefAttr = projectedFeature(); FeaturePtr aProjectedFeature = ModelAPI_Feature::feature(aProjectedRefAttr->object()); + std::shared_ptr anEntity; + + if(!aProjectedFeature.get()) { + return anEntity; + } + + if (aProjectedFeature->getKind() == SketchPlugin_Line::ID()) + anEntity.reset(new SketchAPI_Line(aProjectedFeature)); + else if (aProjectedFeature->getKind() == SketchPlugin_Circle::ID()) + anEntity.reset(new SketchAPI_Circle(aProjectedFeature)); + else if (aProjectedFeature->getKind() == SketchPlugin_Arc::ID()) + anEntity.reset(new SketchAPI_Arc(aProjectedFeature)); + else if (aProjectedFeature->getKind() == SketchPlugin_Ellipse::ID()) + anEntity.reset(new SketchAPI_Ellipse(aProjectedFeature)); + else if (aProjectedFeature->getKind() == SketchPlugin_EllipticArc::ID()) + anEntity.reset(new SketchAPI_EllipticArc(aProjectedFeature)); + else if (aProjectedFeature->getKind() == SketchPlugin_BSpline::ID()) + anEntity.reset(new SketchAPI_BSpline(aProjectedFeature)); + else if (aProjectedFeature->getKind() == SketchPlugin_BSplinePeriodic::ID()) + anEntity.reset(new SketchAPI_BSplinePeriodic(aProjectedFeature)); + else if (aProjectedFeature->getKind() == SketchPlugin_Point::ID()) + anEntity.reset(new SketchAPI_Point(aProjectedFeature)); - return std::shared_ptr(new ModelHighAPI_Interface(aProjectedFeature)); + return anEntity; } //-------------------------------------------------------------------------------------- @@ -76,13 +123,15 @@ void SketchAPI_Projection::dump(ModelHighAPI_Dumper& theDumper) const const std::string& aSketchName = theDumper.parentName(aBase); AttributeSelectionPtr anExternal = externalFeature(); - theDumper << aBase << " = " << aSketchName << ".addProjection(" << anExternal << ")" << std::endl; + AttributeBooleanPtr isIncludeToRes = includeToResult(); + theDumper << aBase << " = " << aSketchName << ".addProjection(" + << anExternal << ", " << isIncludeToRes << ")" << std::endl; // dump "auxiliary" flag if necessary SketchAPI_SketchEntity::dump(theDumper); // Dump created line feature AttributeRefAttrPtr aProjectedRefAttr = projectedFeature(); FeaturePtr aProjectedFeature = ModelAPI_Feature::feature(aProjectedRefAttr->object()); - std::string aProjectedName = theDumper.name(aProjectedFeature, false); - theDumper << aProjectedName << " = " << theDumper.name(aBase) << ".createdFeature()" << std::endl; + theDumper << aProjectedFeature << " = " + << theDumper.name(aBase) << ".createdFeature()" << std::endl; }