From: nds Date: Wed, 29 Mar 2017 05:30:54 +0000 (+0300) Subject: Issue #2027 Sketcher Trim Feature: coincidence unit test case X-Git-Tag: V_2.7.0~163 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=256f2a6c7f3d72659a0378be0116c745dfc13dc2;p=modules%2Fshaper.git Issue #2027 Sketcher Trim Feature: coincidence unit test case --- diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h index cbbfcdf55..54f9399c8 100644 --- a/src/SketchPlugin/SketchPlugin_SketchEntity.h +++ b/src/SketchPlugin/SketchPlugin_SketchEntity.h @@ -171,7 +171,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC if (!theResult.get()) { double aDeflection = Config_PropManager::real("Visualization", "construction_deflection"); thePrs->setDeflection(aDeflection); - } + } return isCustomized; } diff --git a/src/SketchPlugin/SketchPlugin_Trim.cpp b/src/SketchPlugin/SketchPlugin_Trim.cpp index c2408c1cc..51b5e9472 100644 --- a/src/SketchPlugin/SketchPlugin_Trim.cpp +++ b/src/SketchPlugin/SketchPlugin_Trim.cpp @@ -211,12 +211,53 @@ void SketchPlugin_Trim::execute() std::map > aBaseRefAttributes; std::list aRefsToFeature; getRefAttributes(aBaseFeature, aBaseRefAttributes, aRefsToFeature); - +#ifdef DEBUG_TRIM + std::cout << "---- getRefAttributes ----" << std::endl; + std::map >::const_iterator + aRefIt = aBaseRefAttributes.begin(), aRefLast = aBaseRefAttributes.end(); + std::cout << std::endl << "References to attributes of base feature [" << + aBaseRefAttributes.size() << "]" << std::endl; + for (; aRefIt != aRefLast; aRefIt++) { + AttributePtr aBaseAttr = aRefIt->first; + std::list aRefAttributes = aRefIt->second; + std::string aRefsInfo; + std::list::const_iterator aRefAttrIt = aRefAttributes.begin(), + aRefAttrLast = aRefAttributes.end(); + for (; aRefAttrIt != aRefAttrLast; aRefAttrIt++) { + if (!aRefsInfo.empty()) + aRefsInfo.append(","); + AttributePtr aRAttr = *aRefAttrIt; + aRefsInfo.append(aRAttr->id()); + FeaturePtr aRFeature = ModelAPI_Feature::feature(aRAttr->owner()); + aRefsInfo.append("(" + aRFeature->name() + ") "); + } + std::shared_ptr aPointAttr = + std::dynamic_pointer_cast(aBaseAttr); + std::cout << aPointAttr->id().c_str() << + ": " << "[" << aRefAttributes.size() << "] " << aRefsInfo << std::endl; + } + std::cout << std::endl; + std::cout << std::endl << "References to base feature [" << + aRefsToFeature.size() << "]" << std::endl; + std::list::const_iterator aRefAttrIt = aRefsToFeature.begin(), + aRefAttrLast = aRefsToFeature.end(); + std::string aRefsInfo; + for (; aRefAttrIt != aRefAttrLast; aRefAttrIt++) { + if (!aRefsInfo.empty()) + aRefsInfo.append(","); + AttributePtr aRAttr = *aRefAttrIt; + aRefsInfo.append(aRAttr->id()); + FeaturePtr aRFeature = ModelAPI_Feature::feature(aRAttr->owner()); + aRefsInfo.append("(" + aRFeature->name() + ") "); + } + std::cout << "[" << aRefsToFeature.size() << "] " << aRefsInfo << std::endl; + std::cout << "---- getRefAttributes:end ----" << std::endl; +#endif // coincidence to result points // find coincidences to the base object, it should be used when attribute is found // in myObjectToPoints - std::map aCoincidencesToBaseFeature; - getCoincidencesToObject(aBaseObject, aCoincidencesToBaseFeature); + //std::map aCoincidencesToBaseFeature; + //getCoincidencesToObject(aBaseObject, aCoincidencesToBaseFeature); std::set aFurtherCoincidences; std::set> aModifiedAttributes; @@ -239,11 +280,11 @@ void SketchPlugin_Trim::execute() } else if (aKind == SketchPlugin_Line::ID()) { - trimLine(aStartShapePoint2d, aLastShapePoint2d, + trimLine(aStartShapePoint2d, aLastShapePoint2d, aBaseRefAttributes, aFurtherCoincidences, aModifiedAttributes); } else if (aKind == SketchPlugin_Arc::ID()) { - trimArc(aStartShapePoint2d, aLastShapePoint2d, + trimArc(aStartShapePoint2d, aLastShapePoint2d, aBaseRefAttributes, aFurtherCoincidences, aModifiedAttributes); } @@ -260,7 +301,7 @@ void SketchPlugin_Trim::execute() std::shared_ptr aPoint2d = aPointAttribute->pnt(); #ifdef DEBUG_TRIM - std::cout << " => " + std::cout << " => " << std::endl << "aPoint2d: [" << aPoint2d->x() << ", " << aPoint2d->y() << "]" << std::endl; if (aStartShapePoint2d.get()) std::cout << "Start Point: [" << aStartShapePoint2d->x() << ", " << aStartShapePoint2d->y() @@ -288,29 +329,6 @@ void SketchPlugin_Trim::execute() break; } } - /*const std::list& anAttributes = anInfo.first; - for (std::list::const_iterator anAttrIt = anAttributes.begin(); - anAttrIt != anAttributes.end(); anAttrIt++) { - AttributePtr anAttribute = *anAttrIt; - if (aCoincidencesToBaseFeature.find(anAttribute) != aCoincidencesToBaseFeature.end()) - { - FeaturePtr anAttrFeature = aCoincidencesToBaseFeature.at(anAttribute); - AttributePtr anOtherAttribute; - if (std::dynamic_pointer_cast - (anAttrFeature->attribute(SketchPlugin_Constraint::ENTITY_A()))->attr() == anAttribute) - anOtherAttribute = anAttrFeature->attribute(SketchPlugin_Constraint::ENTITY_B()); - else if (std::dynamic_pointer_cast - (anAttrFeature->attribute(SketchPlugin_Constraint::ENTITY_B()))->attr() == anAttribute) - anOtherAttribute = anAttrFeature->attribute(SketchPlugin_Constraint::ENTITY_A()); - else - continue; - AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast - (anOtherAttribute); - if (aRefAttr.get()) - aRefAttr->setAttr(aPointAttribute); - } - } - */ const std::list& anObjects = anInfo.second; for (std::list::const_iterator anObjectIt = anObjects.begin(); anObjectIt != anObjects.end(); anObjectIt++) { @@ -330,6 +348,10 @@ void SketchPlugin_Trim::execute() aLast = aRefsToFeature.end(); anIt != aLast; anIt++) { AttributePtr anAttribute = *anIt; + + //if (replaceCoincidenceAttribute(anAttribute, aModifiedAttributes)) + // continue; + if (setCoincidenceToAttribute(anAttribute, aFurtherCoincidences)) continue; @@ -347,24 +369,15 @@ void SketchPlugin_Trim::execute() } } + updateRefAttConstraints(aBaseRefAttributes, aModifiedAttributes, aFeaturesToDelete); + // Wait all constraints being created, then send update events static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); bool isUpdateFlushed = Events_Loop::loop()->isFlushed(anUpdateEvent); if (isUpdateFlushed) Events_Loop::loop()->setFlushed(anUpdateEvent, false); - updateRefAttConstraints(aBaseRefAttributes, aModifiedAttributes, aFeaturesToDelete); - // delete constraints -#ifdef DEBUG_TRIM - std::cout << "remove features and references:" << std::endl; - std::set::const_iterator aDIt = aFeaturesToDelete.begin(), - aDLast = aFeaturesToDelete.end(); - for (; aDIt != aDLast; aDIt++) { - //std::cout << getFeatureInfo(*aDIt, false) << std::endl; - //std::cout << std::endl; - } -#endif ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToDelete); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); @@ -399,31 +412,43 @@ bool SketchPlugin_Trim::setCoincidenceToAttribute(const AttributePtr& theAttribu if (aPoint2d->isEqual(aRefPnt2d)) { AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast( theAttribute); - /*if (theAttribute->id() == SketchPlugin_ConstraintCoincidence::ENTITY_A()) - aRefAttr = std::dynamic_pointer_cast( - aFeature->attribute(SketchPlugin_ConstraintCoincidence::ENTITY_B())); - else if (theAttribute->id() == SketchPlugin_ConstraintCoincidence::ENTITY_B()) - aRefAttr = std::dynamic_pointer_cast( - aFeature->attribute(SketchPlugin_ConstraintCoincidence::ENTITY_A()));*/ if (aRefAttr.get()) { aRefAttr->setAttr(aPointAttribute); aFoundPoint = true; } } } - /*AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(theAttribute); - if (!aRefAttr.get()) - return false; + return aFoundPoint; +} - if (aRefAttr.get()) - aRefAttr->setObject(aReplacingResult);//continue; - else { - //AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(*anIt); - AttributeReferencePtr aReferenceAttr = - std::dynamic_pointer_cast(anAttribute); - }*/ +bool SketchPlugin_Trim::replaceCoincidenceAttribute(const AttributePtr& theCoincidenceAttribute, + const std::set>& theModifiedAttributes) +{ + FeaturePtr aCoincidenceFeature = ModelAPI_Feature::feature(theCoincidenceAttribute->owner()); + if (aCoincidenceFeature->getKind() != SketchPlugin_ConstraintCoincidence::ID()) + return false; - return aFoundPoint; + AttributeRefAttrPtr aCAttrA = std::dynamic_pointer_cast( + aCoincidenceFeature->attribute(SketchPlugin_Constraint::ENTITY_A())); + AttributeRefAttrPtr aCAttrB = std::dynamic_pointer_cast( + aCoincidenceFeature->attribute(SketchPlugin_Constraint::ENTITY_B())); + AttributePtr aCAttrRefA = aCAttrA->attr(); + AttributePtr aCAttrRefB = aCAttrB->attr(); + + bool isProcessed = false; + for (std::set>::const_iterator + anIt = theModifiedAttributes.begin(); anIt != theModifiedAttributes.end(); anIt++) { + AttributePtr anAttributeBefore = anIt->first; + if (anAttributeBefore == aCAttrRefA) { + aCAttrA->setAttr(anIt->second); + isProcessed = true; + } + if (anAttributeBefore == aCAttrRefB) { + aCAttrB->setAttr(anIt->second); + isProcessed = true; + } + } + return isProcessed; } bool SketchPlugin_Trim::isMacro() const @@ -600,7 +625,7 @@ void SketchPlugin_Trim::getRefAttributes(const FeaturePtr& theFeature, } } -void SketchPlugin_Trim::getCoincidencesToObject(const ObjectPtr& theObject, +/*void SketchPlugin_Trim::getCoincidencesToObject(const ObjectPtr& theObject, std::map& theCoincidencesToBaseFeature) { const std::set& aRefsList = theObject->data()->refsToMe(); @@ -636,7 +661,7 @@ void SketchPlugin_Trim::getCoincidencesToObject(const ObjectPtr& theObject, theCoincidencesToBaseFeature[anAttribute] = aRefFeature; } } -} +}*/ void SketchPlugin_Trim::updateRefAttConstraints( const std::map >& theBaseRefAttributes, @@ -660,25 +685,45 @@ void SketchPlugin_Trim::updateRefAttConstraints( aRLast = aRefAttributes.end(); AttributePtr aNewAttribute = anIt->second; - for (; aRefIt != aRLast; aRefIt++) { - AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(*aRefIt); - if (aRefAttr.get()) { - if (aNewAttribute.get()) - aRefAttr->setAttr(aNewAttribute); - else - theFeaturesToDelete.insert(ModelAPI_Feature::feature(aRefAttr->owner())); -#ifdef DEBUG_TRIM - //FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->owner()); - //std::cout << " -" << getFeatureInfo(aFeature) << std::endl; -#endif + if (aNewAttribute.get()) { + for (; aRefIt != aRLast; aRefIt++) { + AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(*aRefIt); + if (aRefAttr.get()) { + aRefAttr->setAttr(aNewAttribute); + } } } } } +void SketchPlugin_Trim::removeReferencesToAttribute(const AttributePtr& theAttribute, + std::map >& theBaseRefAttributes) +{ + /// not found in references + if (theBaseRefAttributes.find(theAttribute) == theBaseRefAttributes.end()) + return; + + std::list aRefAttributes = theBaseRefAttributes.at(theAttribute); + std::list::const_iterator aRefIt = aRefAttributes.begin(), + aRLast = aRefAttributes.end(); + + std::set aFeaturesToDelete; + for (; aRefIt != aRLast; aRefIt++) { + AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(*aRefIt); + if (aRefAttr.get()) { + aFeaturesToDelete.insert(ModelAPI_Feature::feature(aRefAttr->owner())); + } + } + + // delete constraints + ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToDelete); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); +} + void SketchPlugin_Trim::trimLine(const std::shared_ptr& theStartShapePoint, - const std::shared_ptr& theLastShapePoint, - std::set& thePoints, + const std::shared_ptr& theLastShapePoint, + std::map >& theBaseRefAttributes, + std::set& thePoints, std::set>& theModifiedAttributes) { // Check the base objects are initialized. @@ -724,9 +769,14 @@ void SketchPlugin_Trim::trimLine(const std::shared_ptr& theStartS else aPoint = aStartShapePoint.get() ? aStartShapePoint : aLastShapePoint; + // it is important to delete references before the feature modification because + // if deletion will be after the feature modification, solver returns the feature back + removeReferencesToAttribute(aBaseFeature->attribute(aModifiedAttribute), + theBaseRefAttributes); + fillPointAttribute(aBaseFeature->attribute(aModifiedAttribute), aPoint); - theModifiedAttributes.insert( - std::make_pair(aBaseFeature->attribute(aModifiedAttribute), AttributePtr())); + //theModifiedAttributes.insert( + // std::make_pair(aBaseFeature->attribute(aModifiedAttribute), AttributePtr())); thePoints.insert(std::dynamic_pointer_cast (aBaseFeature->attribute(aModifiedAttribute))); @@ -759,8 +809,9 @@ void SketchPlugin_Trim::trimLine(const std::shared_ptr& theStartS } void SketchPlugin_Trim::trimArc(const std::shared_ptr& theStartShapePoint, - const std::shared_ptr& theLastShapePoint, - std::set& thePoints, + const std::shared_ptr& theLastShapePoint, + std::map >& theBaseRefAttributes, + std::set& thePoints, std::set>& theModifiedAttributes) { // Check the base objects are initialized. @@ -783,14 +834,14 @@ void SketchPlugin_Trim::trimArc(const std::shared_ptr& theStartSh #ifdef DEBUG_TRIM std::cout << "Arranged points (to build split between 1st and 2nd points:" << std::endl; if (aStartShapePoint.get()) - std::cout << "Start point: [" << aStartShapePoint->x() << ", " << + std::cout << "Start shape point: [" << aStartShapePoint->x() << ", " << aStartShapePoint->y() << "]" << std::endl; - std::cout << "1st point: [" << aStartArcPoint->x() << ", " << + std::cout << "Start arc attribute point: [" << aStartArcPoint->x() << ", " << aStartArcPoint->y() << "]" << std::endl; if (aLastShapePoint.get()) - std::cout << "2st point: [" << aLastShapePoint->x() << ", " << + std::cout << "Last shape point: [" << aLastShapePoint->x() << ", " << aLastShapePoint->y() << "]" << std::endl; - std::cout << "End point: [" << aLastArcPoint->x() << ", " << + std::cout << "Last arc attribute point: [" << aLastArcPoint->x() << ", " << aLastArcPoint->y() << "]" << std::endl; #endif @@ -806,9 +857,10 @@ void SketchPlugin_Trim::trimArc(const std::shared_ptr& theStartSh else aPoint = aStartShapePoint.get() ? aStartShapePoint : aLastShapePoint; + removeReferencesToAttribute(aBaseFeature->attribute(aModifiedAttribute), + theBaseRefAttributes); + fillPointAttribute(aBaseFeature->attribute(aModifiedAttribute), aPoint); - theModifiedAttributes.insert( - std::make_pair(aBaseFeature->attribute(aModifiedAttribute), AttributePtr())); thePoints.insert(std::dynamic_pointer_cast (aBaseFeature->attribute(aModifiedAttribute))); @@ -840,6 +892,11 @@ void SketchPlugin_Trim::trimArc(const std::shared_ptr& theStartSh createConstraint(SketchPlugin_ConstraintCoincidence::ID(), aBaseFeature->attribute(SketchPlugin_Arc::CENTER_ID()), anArcFeature->attribute(SketchPlugin_Arc::CENTER_ID())); + + std::cout << "Created arc on points:" << std::endl; + std::cout << "Start shape point: [" << aStartShapePoint->x() << ", " << + aStartShapePoint->y() << "]" << std::endl; + } } @@ -941,8 +998,10 @@ void SketchPlugin_Trim::fillPointAttribute(const AttributePtr& theModifiedAttrib aModifiedAttribute->setValue(thePoint); #ifdef DEBUG_TRIM - std::cout << " => Pnt2d - [" << thePoint->x() << ", " - << thePoint->y() << "]" << std::endl; + FeaturePtr aFeature = ModelAPI_Feature::feature(theModifiedAttribute->owner()); + std::cout << "data()->name() << ": " << + theModifiedAttribute->id() << + "]> => Pnt2d - [" << thePoint->x() << ", " << thePoint->y() << "]" << std::endl; #endif } } @@ -990,6 +1049,10 @@ FeaturePtr SketchPlugin_Trim::createLineFeature(const FeaturePtr& theBaseFeature const std::shared_ptr& theFirstPoint, const std::shared_ptr& theSecondPoint) { +#ifdef DEBUG_TRIM + std::cout << "---- createLineFeature ---" << std::endl; +#endif + FeaturePtr aFeature; SketchPlugin_Sketch* aSketch = sketch(); if (!aSketch || !theBaseFeature.get()) @@ -1005,6 +1068,10 @@ FeaturePtr SketchPlugin_Trim::createLineFeature(const FeaturePtr& theBaseFeature aFeature->execute(); // to obtain result +#ifdef DEBUG_TRIM + std::cout << "---- createLineFeature:end ---" << std::endl; +#endif + return aFeature; } @@ -1026,6 +1093,10 @@ FeaturePtr SketchPlugin_Trim::createArcFeature(const FeaturePtr& theBaseFeature, if (aCenterAttributeId.empty()) return aFeature; +#ifdef DEBUG_TRIM + std::cout << "---- createArcFeature ---" << std::endl; +#endif + aFeature = aSketch->addFeature(SketchPlugin_Arc::ID()); // update fillet arc: make the arc correct for sure, so, it is not needed to process // the "attribute updated" @@ -1048,6 +1119,10 @@ FeaturePtr SketchPlugin_Trim::createArcFeature(const FeaturePtr& theBaseFeature, //aFeature->execute(); // to obtain result aFeature->data()->blockSendAttributeUpdated(aWasBlocked); + #ifdef DEBUG_TRIM + std::cout << "---- createArcFeature:end ---" << std::endl; + #endif + return aFeature; } diff --git a/src/SketchPlugin/SketchPlugin_Trim.h b/src/SketchPlugin/SketchPlugin_Trim.h index 6928c3b96..532731b39 100644 --- a/src/SketchPlugin/SketchPlugin_Trim.h +++ b/src/SketchPlugin/SketchPlugin_Trim.h @@ -92,6 +92,9 @@ class SketchPlugin_Trim : public SketchPlugin_Feature, public GeomAPI_IPresentab bool setCoincidenceToAttribute(const AttributePtr& theAttribute, const std::set >& theFurtherCoincidences); + bool replaceCoincidenceAttribute(const AttributePtr& theCoincidenceAttribute, + const std::set>& theModifiedAttributes); + typedef std::map, std::pair >, std::list > > > PointToRefsMap; @@ -134,8 +137,8 @@ private: /// by the coincident attribute /// \param theObject an investigated object /// \param theCoincidencesToBaseFeature a container of list of referenced attributes - void getCoincidencesToObject(const std::shared_ptr& theObject, - std::map& theCoincidencesToBaseFeature); + //void getCoincidencesToObject(const std::shared_ptr& theObject, + // std::map& theCoincidencesToBaseFeature); /// Move constraints from attribute of base feature to attribute after modification /// \param theBaseRefAttributes container of references to the attributes of base feature @@ -146,32 +149,32 @@ private: const std::set >& theModifiedAttributes, std::set>& theFeaturesToDelete); + /// Remove references constraints from attribute of base feature refer to the given attribute + /// \param theAttribute an attribute + /// \param theModifiedAttributes modifiable container of attributes + void removeReferencesToAttribute(const AttributePtr& theAttribute, + std::map >& theBaseRefAttributes); + /// Make the base object is splitted by the point attributes - /// \param theSplitFeature a result split feature - /// \param theBeforeFeature a feature between start point and the 1st point of split feature - /// \param theAfterFeature a feature between last point of split feature and the end point + /// \param theBaseRefAttributes container of references to the attributes of base feature /// \param thePoints a list of points where coincidences will be build /// \param theModifiedAttributes a container of attribute on base /// feature to attribute on new feature void trimLine(const std::shared_ptr& theStartShapePoint, const std::shared_ptr& theLastShapePoint, + std::map >& theBaseRefAttributes, std::set >& thePoints, std::set>& theModifiedAttributes); /// Make the base object is splitted by the point attributes - /// \param theSplitFeature a result split feature - /// \param theBeforeFeature a feature between start point and the 1st point of split feature - /// \param theAfterFeature a feature between last point of split feature and the end point /// \param thePoints a list of points where coincidences will be build void trimArc(const std::shared_ptr& theStartShapePoint, const std::shared_ptr& theLastShapePoint, + std::map >& theBaseRefAttributes, std::set >& thePoints, std::set>& theModifiedAttributes); /// Make the base object is splitted by the point attributes - /// \param theSplitFeature a result split feature - /// \param theBeforeFeature a feature between start point and the 1st point of split feature - /// \param theAfterFeature a feature between last point of split feature and the end point /// \param thePoints a list of points where coincidences will be build FeaturePtr trimCircle(const std::shared_ptr& theStartShapePoint, const std::shared_ptr& theLastShapePoint, diff --git a/src/SketchPlugin/Test/TestTrimArc07.py b/src/SketchPlugin/Test/TestTrimArc07.py new file mode 100644 index 000000000..b94d921b8 --- /dev/null +++ b/src/SketchPlugin/Test/TestTrimArc07.py @@ -0,0 +1,66 @@ +from salome.shaper import model + +from ModelAPI import * +from GeomDataAPI import * +from ModelGeomAlgo import ModelGeomAlgo_Point2D +from salome.shaper import geom +import math + +TOLERANCE = 1.e-7 + +SketchLineId = 'SketchLine' +SketchArcId = 'SketchArc' +SketchConstraintCoincidenceId = 'SketchConstraintCoincidence' +SketchConstraintEqualId = 'SketchConstraintEqual' + +aSession = ModelAPI_Session.get() +model.begin() +partSet = model.moduleDocument() +Part = model.addPart(partSet) +Part_doc = Part.document() + +# Test1:begin split on arc with coincident point and intersection line : smaller part +Sketch = model.addSketch(Part_doc, model.defaultPlane("XOY")) +SketchArc_1 = Sketch.addArc(50, 50, 30, 50, 50, 70, False) +SketchArc_2 = Sketch.addArc(75, 80, 50, 70, 100, 100, True) +SketchLine = Sketch.addLine(60, 31, 60, 130) +SketchLine_2 = Sketch.addLine(10, 40, 90, 40) + +# correct start point of SketchLine to belong the arc for trim +Intersected_Points = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc_1.feature(), FeatureList([SketchLine.feature()])) +assert(len(Intersected_Points) == 2) +if Intersected_Points[0].y() < Intersected_Points[1].y(): + IntersectionPoint = Intersected_Points[0] +else: + IntersectionPoint = Intersected_Points[1] + +SketchLine.startPoint().setValue(IntersectionPoint.x(), IntersectionPoint.y()) + +SketchConstraintCoincidence_1_1 = Sketch.setCoincident(SketchArc_1.endPoint(), SketchArc_2.startPoint()) +SketchConstraintCoincidence_1_2 = Sketch.setCoincident(SketchArc_1.results()[1], SketchLine.startPoint()) +model.do() + + +#find point on arc, where to perform trim +SketchLine_intersecting = Sketch.addLine(50, 50, 100, 0) +Geom_Points = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc_1.feature(), FeatureList([SketchLine_intersecting.feature()])) +assert(len(Geom_Points) == 1) +ModelAPI.removeFeaturesAndReferences(FeatureSet([SketchLine_intersecting.feature()])) +model.do() +GeomPoint = Geom_Points[0] + +model.do() +SketchTrim = Sketch.addTrim(SketchArc_1, Sketch.to2D(GeomPoint)) +SketchTrim.execute() + + +# Another case +#GeomPoint = geom.Pnt2d(60, 50) +#model.do() +#SketchTrim = Sketch.addTrim(SketchArc_1, GeomPoint) +#SketchTrim.execute() + + +model.end() + +#assert(model.checkPythonDump())