From: jfa Date: Fri, 19 Jun 2020 09:59:39 +0000 (+0300) Subject: Sketcher Offset: Select wire, debug. X-Git-Tag: V9_6_0a1~60^2~60 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2f0b4f5a8d12bdb19358bfd09e2aef18d83348ad;p=modules%2Fshaper.git Sketcher Offset: Select wire, debug. --- diff --git a/src/SketchPlugin/SketchPlugin_Offset.cpp b/src/SketchPlugin/SketchPlugin_Offset.cpp index aadc85824..046d79480 100644 --- a/src/SketchPlugin/SketchPlugin_Offset.cpp +++ b/src/SketchPlugin/SketchPlugin_Offset.cpp @@ -106,6 +106,8 @@ void SketchPlugin_Offset::execute() // End points (if any) std::shared_ptr aStartPoint, anEndPoint; SketchPlugin_SegmentationTools::getFeaturePoints(aFeature, aStartPoint, anEndPoint); + std::cout << "aStartPoint = (" << aStartPoint->x() << ", " << aStartPoint->y() << ")" << std::endl; + std::cout << "anEndPoint = (" << anEndPoint->x() << ", " << anEndPoint->y() << ")" << std::endl; std::list aChain; aChain.push_back(aFeature); @@ -149,13 +151,16 @@ bool SketchPlugin_Offset::findWireOneWay (const FeaturePtr& theFirstEdge, if (!theEndPoint) return false; FeaturePtr aNextEdgeFeature; - std::set aCoincFeatures = - SketchPlugin_Tools::findFeaturesCoincidentToPoint(theEndPoint); - int nbFound = 0; - std::set::iterator aCoincIt; - for (aCoincIt = aCoincFeatures.begin(); aCoincIt != aCoincFeatures.end(); ++aCoincIt) { - FeaturePtr aCoincFeature = (*aCoincIt); + + std::set aCoincPoints = + SketchPlugin_Tools::findPointsCoincidentToPoint(theEndPoint); + + std::set::iterator aPointsIt = aCoincPoints.begin(); + for (; aPointsIt != aCoincPoints.end(); aPointsIt++) { + AttributePoint2DPtr aP = (*aPointsIt); + FeaturePtr aCoincFeature = std::dynamic_pointer_cast(aP->owner()); + if (aCoincFeature->getKind() != SketchPlugin_Point::ID()) { if (aCoincFeature != theEdge) { bool isInSet = true; // empty set means all sketch edges @@ -187,8 +192,16 @@ bool SketchPlugin_Offset::findWireOneWay (const FeaturePtr& theFirstEdge, std::shared_ptr aNextStartPoint, aNextEndPoint; SketchPlugin_SegmentationTools::getFeaturePoints(aNextEdgeFeature, aNextStartPoint, aNextEndPoint); if (aNextStartPoint && aNextEndPoint) { - if (aNextEndPoint == theEndPoint) + std::cout << "theEndPoint = (" << theEndPoint->x() << ", " << theEndPoint->y() << ")" << std::endl; + std::cout << "aNextStartPoint = (" << aNextStartPoint->x() << ", " << aNextStartPoint->y() << ")" << std::endl; + std::cout << "aNextEndPoint = (" << aNextEndPoint->x() << ", " << aNextEndPoint->y() << ")" << std::endl; + // Check which end of aNextEdgeFeature should be used to find a next edge + std::shared_ptr anEndPnt = theEndPoint->pnt(); + std::shared_ptr aNextEndPnt = aNextEndPoint->pnt(); + if (aNextEndPnt->isEqual(anEndPnt)) { + std::cout << "aNextEndPoint == theEndPoint" << std::endl; aNextEndPoint = aNextStartPoint; + } return findWireOneWay (theFirstEdge, aNextEdgeFeature, aNextEndPoint, theEdgesSet, theChain); } @@ -267,7 +280,11 @@ void SketchPlugin_Offset::addToSketch(const std::shared_ptr& anOf void SketchPlugin_Offset::attributeChanged(const std::string& theID) { - std::cout << " !!! *** SketchPlugin_Offset::attributeChanged()" << std::endl; + std::cout << " !!! *** SketchPlugin_Offset::attributeChanged() myCreatedFeatures.size() 1 = " + << myCreatedFeatures.size() << std::endl; + ModelAPI_Tools::removeFeaturesAndReferences(myCreatedFeatures); + std::cout << " !!! *** SketchPlugin_Offset::attributeChanged() myCreatedFeatures.size() 2 = " + << myCreatedFeatures.size() << std::endl; } bool SketchPlugin_Offset::customAction(const std::string& theActionId) @@ -316,6 +333,8 @@ bool SketchPlugin_Offset::findWires() // End points (if any) std::shared_ptr aStartPoint, anEndPoint; SketchPlugin_SegmentationTools::getFeaturePoints(aFeature, aStartPoint, anEndPoint); + std::cout << "aStartPoint = (" << aStartPoint->x() << ", " << aStartPoint->y() << ")" << std::endl; + std::cout << "anEndPoint = (" << anEndPoint->x() << ", " << anEndPoint->y() << ")" << std::endl; std::list aChain; aChain.push_back(aFeature); @@ -328,13 +347,13 @@ bool SketchPlugin_Offset::findWires() FeaturePtr aChainFeature = (*aChainIt); anEdgesSet1.insert(aChainFeature); if (aSelectedSet.find(aChainFeature) == aSelectedSet.end()) { - // TODO: add in reflist(EDGES_ID()), update viewer - // ?? ModelHighAPI_Tools::fillAttribute() std::cout << " !!! *** SketchPlugin_Offset::findWires() - Add an edge" << std::endl; + aSelectedEdges->append(aChainFeature->lastResult()); } } } } + // TODO: hilight selection in the viewer return true; } diff --git a/src/SketchPlugin/SketchPlugin_Offset.h b/src/SketchPlugin/SketchPlugin_Offset.h index 678bb4c4c..85e837128 100644 --- a/src/SketchPlugin/SketchPlugin_Offset.h +++ b/src/SketchPlugin/SketchPlugin_Offset.h @@ -110,10 +110,11 @@ private: // Find edges that prolongate theEdgeFeature (in a chain) at theEndPoint // Recursive method. - // \param[in] theEdgeFeature - // \param[in] theEndPoint - // \param[in/out] theAllEdges - // \param[in/out] theChain + // \param[in] theFirstEdge Start edge of wire searching + // \param[in] theEdge Current edge + // \param[in] theEndPoint Point of the Current edge, not belonging to a previous edge + // \param[in/out] theEdgesSet All edges to find among. If empty, all sketch edges assumed. + // \param[in/out] theChain Resulting edges /// \return \c true if the chain is closed bool findWireOneWay (const FeaturePtr& theFirstEdge, const FeaturePtr& theEdge,