X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchAPI%2FSketchAPI_IntersectionPoint.cpp;h=6cc79abd2b1bd5092adc5f6296d8496ec943ab84;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=8e37e08f522472a9a682a07901f1b109e1af87e8;hpb=2532fb2df83ee1ddd9ff3e8b381d3788eaa15b69;p=modules%2Fshaper.git diff --git a/src/SketchAPI/SketchAPI_IntersectionPoint.cpp b/src/SketchAPI/SketchAPI_IntersectionPoint.cpp index 8e37e08f5..6cc79abd2 100644 --- a/src/SketchAPI/SketchAPI_IntersectionPoint.cpp +++ b/src/SketchAPI/SketchAPI_IntersectionPoint.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,12 +12,15 @@ // // 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "SketchAPI_IntersectionPoint.h" +#include "SketchAPI_Point.h" +//-------------------------------------------------------------------------------------- +#include //-------------------------------------------------------------------------------------- #include //-------------------------------------------------------------------------------------- @@ -38,17 +41,17 @@ SketchAPI_IntersectionPoint::SketchAPI_IntersectionPoint( : SketchAPI_SketchEntity(theFeature) { if (initialize()) { - setByExternalLine(theExternal); + setByExternalEdge(theExternal); } } SketchAPI_IntersectionPoint::SketchAPI_IntersectionPoint( const std::shared_ptr & theFeature, - const std::string & theExternalName ) + const std::wstring & theExternalName ) : SketchAPI_SketchEntity(theFeature) { if (initialize()) { - setByExternalLineName(theExternalName); + setByExternalEdgeName(theExternalName); } } @@ -58,20 +61,48 @@ SketchAPI_IntersectionPoint::~SketchAPI_IntersectionPoint() } //-------------------------------------------------------------------------------------- -void SketchAPI_IntersectionPoint::setByExternalLine(const ModelHighAPI_Selection & theExternalLine) +void SketchAPI_IntersectionPoint::setByExternalEdge(const ModelHighAPI_Selection & theExternalLine) { - fillAttribute(theExternalLine, externalLine()); + fillAttribute(theExternalLine, externalFeature()); execute(); } -void SketchAPI_IntersectionPoint::setByExternalLineName(const std::string & theExternalLineName) +void SketchAPI_IntersectionPoint::setByExternalEdgeName(const std::wstring & theExternalLineName) { - fillAttribute(ModelHighAPI_Selection("EDGE", theExternalLineName), externalLine()); + fillAttribute(ModelHighAPI_Selection("EDGE", theExternalLineName), externalFeature()); execute(); } +void SketchAPI_IntersectionPoint::setIncludeToResult(bool theKeepResult) +{ + fillAttribute(theKeepResult, includeToResult()); + execute(true); +} + +//-------------------------------------------------------------------------------------- + +std::list > +SketchAPI_IntersectionPoint::intersectionPoints() const +{ + std::list > anEntities; + + std::list anIntersections = + feature()->reflist(SketchPlugin_IntersectionPoint::INTERSECTION_POINTS_ID())->list(); + for (std::list::iterator anIt = anIntersections.begin(); + anIt != anIntersections.end(); ++anIt) { + FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt); + if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID()) + { + std::shared_ptr anEnt(new SketchAPI_Point(aFeature)); + anEntities.push_back(anEnt); + } + } + + return anEntities; +} + //-------------------------------------------------------------------------------------- void SketchAPI_IntersectionPoint::dump(ModelHighAPI_Dumper& theDumper) const @@ -79,9 +110,21 @@ void SketchAPI_IntersectionPoint::dump(ModelHighAPI_Dumper& theDumper) const FeaturePtr aBase = feature(); const std::string& aSketchName = theDumper.parentName(aBase); - AttributeSelectionPtr aLine = externalLine(); - theDumper << aBase << " = " << - aSketchName << ".addIntersectionPoint(" << aLine << ")" << std::endl; + AttributeSelectionPtr anExternal = externalFeature(); + AttributeBooleanPtr isIncludeToRes = includeToResult(); + theDumper << aBase << " = " << aSketchName << ".addIntersectionPoint(" + << anExternal << ", " << isIncludeToRes << ")" << std::endl; // dump "auxiliary" flag if necessary SketchAPI_SketchEntity::dump(theDumper); + + // Dump variables for a list of intersected points + theDumper << "["; + std::list > aList = intersectionPoints(); + std::list >::const_iterator anIt = aList.begin(); + for (; anIt != aList.end(); ++anIt) { + if (anIt != aList.begin()) + theDumper << ", "; + theDumper << (*anIt)->feature(); + } + theDumper << "] = " << theDumper.name(aBase) << ".intersectionPoints()" << std::endl; }