From ca373e15b18045f79fcff7fc7e6fbb789648d7f4 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 29 Dec 2015 16:57:39 +0300 Subject: [PATCH] Update processing coincidence between origin and a line's attribute (issue #1181) --- src/SketchSolver/SketchSolver_Builder.cpp | 2 ++ src/SketchSolver/SketchSolver_Storage.cpp | 10 ++++++++++ .../SolveSpaceSolver/SolveSpaceSolver_Builder.cpp | 7 +++++-- .../SolveSpaceSolver/SolveSpaceSolver_Storage.cpp | 7 +++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/SketchSolver/SketchSolver_Builder.cpp b/src/SketchSolver/SketchSolver_Builder.cpp index c01e8817a..ff3413649 100644 --- a/src/SketchSolver/SketchSolver_Builder.cpp +++ b/src/SketchSolver/SketchSolver_Builder.cpp @@ -119,6 +119,8 @@ std::shared_ptr SketchSolver_Builder::point(EntityWrapperPtr theE { if (theEntity->type() != ENTITY_POINT) return std::shared_ptr(); + if (theEntity->subEntities().size() == 1) // SketchPlugin_Point wrapper + return point(theEntity->subEntities().front()); double aXY[2]; std::list aParams = theEntity->parameters(); diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index e54aec7e4..e606f44c1 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -153,6 +153,11 @@ bool SketchSolver_Storage::update(FeaturePtr theFeature, const GroupID& theGroup // Secondly, convert feature BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); GroupID aGroup = theGroup != GID_UNKNOWN ? theGroup : myGroupID; + // Check external feature + std::shared_ptr aSketchFeature = + std::dynamic_pointer_cast(theFeature); + if (aSketchFeature && aSketchFeature->isExternal()) + aGroup = GID_OUTOFGROUP; aRelated = aBuilder->createFeature(theFeature, aSubs, aGroup); if (!aRelated) return false; @@ -194,6 +199,11 @@ bool SketchSolver_Storage::update(AttributePtr theAttribute, const GroupID& theG } BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); GroupID aGroup = theGroup != GID_UNKNOWN ? theGroup : myGroupID; + // Check attribute of external features + std::shared_ptr aSketchFeature = + std::dynamic_pointer_cast(theAttribute->owner()); + if (aSketchFeature && aSketchFeature->isExternal()) + aGroup = GID_OUTOFGROUP; aRelated = aBuilder->createAttribute(anAttribute, aGroup); if (!aRelated) return false; diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp index 68ce5aaf3..704b4b0d5 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp @@ -308,13 +308,16 @@ EntityWrapperPtr SolveSpaceSolver_Builder::createFeature( AttributePtr aPoint = theFeature->attribute(SketchPlugin_Point::COORD_ID()); if (!aPoint->isInitialized()) return aDummy; - EntityWrapperPtr aSub = createAttribute(aPoint, theGroupID, theSketchID); + EntityWrapperPtr aSub = theAttributes.empty() ? createAttribute(aPoint, theGroupID, theSketchID) : + theAttributes.front(); if (!aSub) return aDummy; const Slvs_Entity& aSubEnt = std::dynamic_pointer_cast(aSub)->entity(); - return EntityWrapperPtr(new SolveSpaceSolver_EntityWrapper(theFeature, aPoint, aSubEnt)); + EntityWrapperPtr aResult(new SolveSpaceSolver_EntityWrapper(theFeature, aPoint, aSubEnt)); + aResult->setSubEntities(theAttributes); + return aResult; } // wrong entity diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index 7a185c8af..e065fd245 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -274,6 +274,13 @@ void SolveSpaceSolver_Storage::addCoincidentPoints( { if (theMaster->type() != ENTITY_POINT || theSlave->type() != ENTITY_POINT) return; + if (!theMaster->subEntities().empty() || !theSlave->subEntities().empty()) { + EntityWrapperPtr aSubMaster = theMaster->subEntities().empty() ? + theMaster : theMaster->subEntities().front(); + EntityWrapperPtr aSubSlave = theSlave->subEntities().empty() ? + theSlave : theSlave->subEntities().front(); + return addCoincidentPoints(aSubMaster, aSubSlave); + } // Search available coincidence CoincidentPointsMap::iterator aMasterFound = myCoincidentPoints.find(theMaster); -- 2.39.2