From 2982303b80faa9bed2a7715d2778fd10d8cd0465 Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 1 Mar 2017 09:54:40 +0300 Subject: [PATCH] Simplify sketcher model. Remove obsolete files and classes. --- src/SketchSolver/CMakeLists.txt | 3 - .../PlaneGCSSolver/CMakeLists.txt | 4 +- .../PlaneGCSSolver/PlaneGCSSolver_Builder.h | 92 ------------- .../PlaneGCSSolver/PlaneGCSSolver_Solver.cpp | 6 +- .../PlaneGCSSolver/PlaneGCSSolver_Solver.h | 26 ++-- .../PlaneGCSSolver/PlaneGCSSolver_Storage.cpp | 67 +--------- .../PlaneGCSSolver/PlaneGCSSolver_Storage.h | 9 -- ...r_Builder.cpp => PlaneGCSSolver_Tools.cpp} | 121 ++++++++++-------- .../PlaneGCSSolver/PlaneGCSSolver_Tools.h | 64 +++++++++ src/SketchSolver/SketchSolver_Builder.cpp | 112 ---------------- src/SketchSolver/SketchSolver_Builder.h | 93 -------------- src/SketchSolver/SketchSolver_Constraint.cpp | 7 +- .../SketchSolver_ConstraintCoincidence.cpp | 5 +- .../SketchSolver_ConstraintMirror.cpp | 6 +- .../SketchSolver_ConstraintTangent.cpp | 17 +-- src/SketchSolver/SketchSolver_Group.cpp | 66 ++++------ src/SketchSolver/SketchSolver_Group.h | 5 +- .../SketchSolver_IConstraintWrapper.h | 18 +-- src/SketchSolver/SketchSolver_ISolver.h | 58 --------- src/SketchSolver/SketchSolver_Manager.cpp | 10 -- src/SketchSolver/SketchSolver_Manager.h | 8 -- src/SketchSolver/SketchSolver_Storage.h | 2 +- 22 files changed, 193 insertions(+), 606 deletions(-) delete mode 100644 src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.h rename src/SketchSolver/PlaneGCSSolver/{PlaneGCSSolver_Builder.cpp => PlaneGCSSolver_Tools.cpp} (83%) create mode 100644 src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.h delete mode 100644 src/SketchSolver/SketchSolver_Builder.cpp delete mode 100644 src/SketchSolver/SketchSolver_Builder.h delete mode 100644 src/SketchSolver/SketchSolver_ISolver.h diff --git a/src/SketchSolver/CMakeLists.txt b/src/SketchSolver/CMakeLists.txt index 60fa8f05a..d6b370d79 100644 --- a/src/SketchSolver/CMakeLists.txt +++ b/src/SketchSolver/CMakeLists.txt @@ -19,10 +19,8 @@ SET(SKETCHSOLVER_HEADERS SketchSolver.h SketchSolver_Error.h SketchSolver_Group.h - SketchSolver_Builder.h SketchSolver_IConstraintWrapper.h SketchSolver_IEntityWrapper.h - SketchSolver_ISolver.h SketchSolver_Manager.h SketchSolver_Storage.h ) @@ -46,7 +44,6 @@ SET(SKETCHSOLVER_CONSTRAINT_HEADERS SET(SKETCHSOLVER_SOURCES SketchSolver_Group.cpp - SketchSolver_Builder.cpp SketchSolver_Manager.cpp SketchSolver_Storage.cpp ) diff --git a/src/SketchSolver/PlaneGCSSolver/CMakeLists.txt b/src/SketchSolver/PlaneGCSSolver/CMakeLists.txt index 4866a5b36..91bc90b79 100644 --- a/src/SketchSolver/PlaneGCSSolver/CMakeLists.txt +++ b/src/SketchSolver/PlaneGCSSolver/CMakeLists.txt @@ -5,24 +5,24 @@ FIND_PACKAGE(PlaneGCS REQUIRED) SET(PLANEGCSSOLVER_HEADERS PlaneGCSSolver_Defs.h PlaneGCSSolver_Solver.h - PlaneGCSSolver_Builder.h PlaneGCSSolver_Storage.h PlaneGCSSolver_ConstraintWrapper.h PlaneGCSSolver_EntityWrapper.h PlaneGCSSolver_PointWrapper.h PlaneGCSSolver_ScalarWrapper.h PlaneGCSSolver_AngleWrapper.h + PlaneGCSSolver_Tools.h ) SET(PLANEGCSSOLVER_SOURCES PlaneGCSSolver_Solver.cpp - PlaneGCSSolver_Builder.cpp PlaneGCSSolver_Storage.cpp PlaneGCSSolver_ConstraintWrapper.cpp PlaneGCSSolver_EntityWrapper.cpp PlaneGCSSolver_PointWrapper.cpp PlaneGCSSolver_ScalarWrapper.cpp PlaneGCSSolver_AngleWrapper.cpp + PlaneGCSSolver_Tools.cpp ) SET(PLANEGCSSOLVER_BUILDER_HEADERS diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.h deleted file mode 100644 index caf81eb21..000000000 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PlaneGCSSolver_Builder.h -// Created: 14 Dec 2015 -// Author: Artem ZHIDKOV - -#ifndef PlaneGCSSolver_Builder_H_ -#define PlaneGCSSolver_Builder_H_ - -#include - -#include -#include - -#include - -#include - -/** \class PlaneGCSSolver_Builder - * \ingroup Plugins - * \brief Create bridges between SketchPlugin constraints and PlaneGCS constraints - */ -class PlaneGCSSolver_Builder : public SketchSolver_Builder -{ - /// Default constructor - PlaneGCSSolver_Builder() {} - -public: - /// \brief Returns single instance of builder - static BuilderPtr getInstance(); - - /// \brief Creates a storage specific for used solver - virtual StoragePtr createStorage(const SolverPtr& theSolver) const; - /// \brief Creates specific solver - virtual SolverPtr createSolver() const; - - /// \brief Creates new constraint using given parameters - /// \param theConstraint [in] original constraint - /// \param theType [in] type of constraint - /// \param theValue [in] numeric characteristic of constraint - /// (e.g. distance or radius) if applicable - /// \param theEntity1 [in] first attribute of constraint - /// \param theEntity2 [in] second attribute of constraint - /// \param theEntity3 [in] third attribute of constraint - /// \param theEntity4 [in] fourth attribute of constraint - /// \return Created wrapper of constraints applicable for specific solver. - virtual ConstraintWrapperPtr - createConstraint(ConstraintPtr theConstraint, - const SketchSolver_ConstraintType& theType, - const EntityWrapperPtr& theValue, - const EntityWrapperPtr& theEntity1, - const EntityWrapperPtr& theEntity2 = EntityWrapperPtr(), - const EntityWrapperPtr& theEntity3 = EntityWrapperPtr(), - const EntityWrapperPtr& theEntity4 = EntityWrapperPtr()) const; - - /// \brief Creates new multi-translation or multi-rotation constraint - /// \param theConstraint [in] original constraint - /// \param theType [in] type of constraint - /// \param theValue [in] numeric characteristic of constraint (angle for multi-rotation) - /// if applicable - /// \param theFullValue [in] indicates theValue shows full translation delta/rotation - /// angle or delta/angle between neighbor entities - /// \param thePoint1 [in] center for multi-rotation or start point for multi-translation - /// \param thePoint2 [in] end point for multi-translation (empty for multi-rotation) - /// \param theTrsfEnt [in] list of transformed entities - virtual ConstraintWrapperPtr - createConstraint(ConstraintPtr theConstraint, - const SketchSolver_ConstraintType& theType, - const EntityWrapperPtr& theValue, - const bool theFullValue, - const EntityWrapperPtr& thePoint1, - const EntityWrapperPtr& thePoint2, - const std::list& theTrsfEnt) const; - - /// \brief Convert entity to point - /// \return empty pointer if the entity is not a point - virtual std::shared_ptr point(EntityWrapperPtr theEntity) const; - /// \brief Convert entity to line - /// \return empty pointer if the entity is not a line - virtual std::shared_ptr line(EntityWrapperPtr theEntity) const; - - /// \brief Convert entity to line - /// \return empty pointer if the entity is not a line - virtual std::shared_ptr line(FeaturePtr theFeature) const; - - /// \brief Check if two connected arcs have centers - /// in same direction relatively to connection point - virtual bool isArcArcTangencyInternal(EntityWrapperPtr theArc1, - EntityWrapperPtr theArc2) const; -}; - -#endif diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp index 1193ad357..3e77208aa 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp @@ -4,7 +4,7 @@ // Created: 14 Dec 2014 // Author: Artem ZHIDKOV -#include "PlaneGCSSolver_Solver.h" +#include #include @@ -66,7 +66,7 @@ void PlaneGCSSolver_Solver::removeParameters(const GCS::SET_pD& theParams) } } -SketchSolver_SolveStatus PlaneGCSSolver_Solver::solve() +PlaneGCSSolver_Solver::SolveStatus PlaneGCSSolver_Solver::solve() { // clear list of conflicting constraints if (myConfCollected) { @@ -82,7 +82,7 @@ SketchSolver_SolveStatus PlaneGCSSolver_Solver::solve() GCS::SolveStatus aResult = (GCS::SolveStatus)myEquationSystem->solve(myParameters); Events_LongOp::end(this); - SketchSolver_SolveStatus aStatus; + SolveStatus aStatus; if (aResult == GCS::Success) { myEquationSystem->applySolution(); if (myDOF < 0) diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h index 9c25caf72..0465924cb 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h @@ -7,16 +7,24 @@ #ifndef PlaneGCSSolver_Solver_H_ #define PlaneGCSSolver_Solver_H_ -#include #include #include #include /// \brief The main class that performs the high-level operations for connection to the PlaneGCS. -class PlaneGCSSolver_Solver : public SketchSolver_ISolver +class PlaneGCSSolver_Solver { public: + /// The result of constraints solution + enum SolveStatus { + STATUS_OK, + STATUS_INCONSISTENT, + STATUS_EMPTYSET, + STATUS_FAILED, // set if no one other status is applicable + STATUS_UNKNOWN // set for newly created groups + }; + PlaneGCSSolver_Solver(); ~PlaneGCSSolver_Solver(); @@ -36,20 +44,16 @@ public: /// \brief Solve the set of equations /// \return identifier whether solution succeeded - virtual SketchSolver_SolveStatus solve(); - - /// \brief Prepare for solving. Store initial values of parameters for undo - virtual void prepare() - { /* do nothing */ } + SolveStatus solve(); /// \brief Revert solution to initial values - virtual void undo(); + void undo(); /// \brief Check the constraint is conflicted with others - virtual bool isConflicting(const ConstraintID& theConstraint) const; + bool isConflicting(const ConstraintID& theConstraint) const; /// \brief Degrees of freedom - virtual int dof(); + int dof(); private: void collectConflicting(); @@ -70,4 +74,6 @@ private: int myDOF; ///< degrees of freedom }; +typedef std::shared_ptr SolverPtr; + #endif diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index 67ada8770..62451f130 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -5,7 +5,6 @@ // Author: Artem ZHIDKOV #include -#include #include #include #include @@ -19,6 +18,7 @@ #include #include #include +#include #include #include @@ -266,9 +266,7 @@ bool PlaneGCSSolver_Storage::removeConstraint(ConstraintPtr theConstraint) if (aFound != myConstraintMap.end()) { ConstraintID anID = aFound->second->id(); // Remove solver's constraints - std::shared_ptr aSolver = - std::dynamic_pointer_cast(mySketchSolver); - aSolver->removeConstraint(anID); + mySketchSolver->removeConstraint(anID); // Remove constraint myConstraintMap.erase(aFound); @@ -305,8 +303,7 @@ void PlaneGCSSolver_Storage::removeInvalidEntities() std::map::iterator aFound = myArcConstraintMap.find(aFIter->second); if (aFound != myArcConstraintMap.end()) { - std::dynamic_pointer_cast( - mySketchSolver)->removeConstraint(aFound->second->id()); + mySketchSolver->removeConstraint(aFound->second->id()); myArcConstraintMap.erase(aFound); } } @@ -338,66 +335,12 @@ void PlaneGCSSolver_Storage::removeInvalidEntities() double* PlaneGCSSolver_Storage::createParameter() { - return std::dynamic_pointer_cast(mySketchSolver)->createParameter(); + return mySketchSolver->createParameter(); } void PlaneGCSSolver_Storage::removeParameters(const GCS::SET_pD& theParams) { - std::dynamic_pointer_cast(mySketchSolver)->removeParameters(theParams); -} - - -bool PlaneGCSSolver_Storage::isRedundant( - GCSConstraintPtr theCheckedConstraint, - ConstraintWrapperPtr theParentConstraint, - std::list >& theCoincidentPoints) const -{ - if (theParentConstraint->type() == CONSTRAINT_SYMMETRIC) { - if (theCheckedConstraint->getTypeId() == GCS::Perpendicular) { - BuilderPtr aBuilder = PlaneGCSSolver_Builder::getInstance(); - // check the initial point is placed on the mirror line - std::list aSubs = theParentConstraint->entities(); - std::shared_ptr aPoint = aBuilder->point(aSubs.front()); - std::shared_ptr aLine = aBuilder->line(aSubs.back()); - return aLine->distance(aPoint) < tolerance; - } - } - else if (theParentConstraint->type() == CONSTRAINT_PT_PT_COINCIDENT) { - // Verify that the coincidence between points is already added - GCS::VEC_pD aParams = theCheckedConstraint->params(); - - std::list >::iterator aCoincIt, aFound1, aFound2; - aFound1 = aFound2 = theCoincidentPoints.end(); - for (aCoincIt = theCoincidentPoints.begin(); - aCoincIt != theCoincidentPoints.end(); ++aCoincIt) { - if (aFound1 == theCoincidentPoints.end() && aCoincIt->find(aParams[0]) != aCoincIt->end()) - aFound1 = aCoincIt; - if (aFound2 == theCoincidentPoints.end() && aCoincIt->find(aParams[1]) != aCoincIt->end()) - aFound2 = aCoincIt; - if (aFound1 != theCoincidentPoints.end() && aFound2 != theCoincidentPoints.end()) - break; - } - if (aCoincIt != theCoincidentPoints.end()) { // both point are found - if (aFound1 == aFound2) - return true; - // merge two groups of coincidence - aFound1->insert(aFound2->begin(), aFound2->end()); - theCoincidentPoints.erase(aFound2); - } else { - if (aFound1 != theCoincidentPoints.end()) - aFound1->insert(aParams[1]); - else if (aFound2 != theCoincidentPoints.end()) - aFound2->insert(aParams[0]); - else { - std::set aNewCoincidence; - aNewCoincidence.insert(aParams[0]); - aNewCoincidence.insert(aParams[1]); - theCoincidentPoints.push_back(aNewCoincidence); - } - } - } - - return false; + mySketchSolver->removeParameters(theParams); } // indicates attribute containing in the external feature diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h index ca8fa2221..752651d33 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h @@ -11,7 +11,6 @@ #include #include -#include class PlaneGCSSolver_EntityBuilder; @@ -68,14 +67,6 @@ public: virtual void removeInvalidEntities(); private: - /// \brief Verifies the constraint should not be added into the solver - /// - /// This is a workaround method to avoid some kinds of conflicting constraints: - /// * symmetric of two points placed on the mirror line (do not add perpendicular constraint) - bool isRedundant(GCSConstraintPtr theCheckedConstraint, - ConstraintWrapperPtr theParentConstraint, - std::list >& theCoincidentPoints) const; - /// \brief Convert feature using specified builder. EntityWrapperPtr createFeature(const FeaturePtr& theFeature, PlaneGCSSolver_EntityBuilder* theBuilder); diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp similarity index 83% rename from src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp rename to src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp index fb81a64a2..5f10b68e1 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp @@ -1,21 +1,42 @@ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -// File: PlaneGCSSolver_Builder.cpp -// Created: 14 Dec 2015 +// File: SketchSolver_Builder.cpp +// Created: 25 Mar 2015 // Author: Artem ZHIDKOV -#include -#include +#include #include #include #include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -77,38 +98,54 @@ static ConstraintWrapperPtr -// Initialization of pointer to builder -static BuilderPtr gBuilder = PlaneGCSSolver_Builder::getInstance(); -BuilderPtr PlaneGCSSolver_Builder::getInstance() + +SolverConstraintPtr PlaneGCSSolver_Tools::createConstraint(ConstraintPtr theConstraint) { - static BuilderPtr mySelf; - if (!mySelf) { - mySelf = BuilderPtr(new PlaneGCSSolver_Builder); - SketchSolver_Manager::instance()->setBuilder(mySelf); + if (theConstraint->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintCoincidence(theConstraint)); + } else if (theConstraint->getKind() == SketchPlugin_ConstraintCollinear::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintCollinear(theConstraint)); + } else if (theConstraint->getKind() == SketchPlugin_ConstraintDistance::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintDistance(theConstraint)); + } else if (theConstraint->getKind() == SketchPlugin_ConstraintEqual::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintEqual(theConstraint)); + } else if (theConstraint->getKind() == SketchPlugin_ConstraintLength::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintLength(theConstraint)); + } else if (theConstraint->getKind() == SketchPlugin_ConstraintMiddle::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintMiddle(theConstraint)); + } else if (theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintMirror(theConstraint)); + } else if (theConstraint->getKind() == SketchPlugin_ConstraintTangent::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintTangent(theConstraint)); + } else if (theConstraint->getKind() == SketchPlugin_ConstraintRigid::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintFixed(theConstraint)); + } else if (theConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintMultiTranslation(theConstraint)); + } else if (theConstraint->getKind() == SketchPlugin_MultiRotation::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintMultiRotation(theConstraint)); + } else if (theConstraint->getKind() == SketchPlugin_ConstraintAngle::ID()) { + return SolverConstraintPtr(new SketchSolver_ConstraintAngle(theConstraint)); } - return mySelf; + // All other types of constraints + return SolverConstraintPtr(new SketchSolver_Constraint(theConstraint)); } -StoragePtr PlaneGCSSolver_Builder::createStorage(const SolverPtr& theSolver) const +SolverConstraintPtr PlaneGCSSolver_Tools::createMovementConstraint(FeaturePtr theMovedFeature) { - return StoragePtr(new PlaneGCSSolver_Storage(theSolver)); + return SolverConstraintPtr(new SketchSolver_ConstraintFixed(theMovedFeature)); } -SolverPtr PlaneGCSSolver_Builder::createSolver() const -{ - return SolverPtr(new PlaneGCSSolver_Solver); -} -ConstraintWrapperPtr PlaneGCSSolver_Builder::createConstraint( +ConstraintWrapperPtr PlaneGCSSolver_Tools::createConstraint( ConstraintPtr theConstraint, const SketchSolver_ConstraintType& theType, const EntityWrapperPtr& theValue, const EntityWrapperPtr& thePoint1, const EntityWrapperPtr& thePoint2, const EntityWrapperPtr& theEntity1, - const EntityWrapperPtr& theEntity2) const + const EntityWrapperPtr& theEntity2) { ConstraintWrapperPtr aResult; ScalarWrapperPtr anIntermediate; @@ -188,35 +225,7 @@ ConstraintWrapperPtr PlaneGCSSolver_Builder::createConstraint( return aResult; } -ConstraintWrapperPtr PlaneGCSSolver_Builder::createConstraint( - ConstraintPtr theConstraint, - const SketchSolver_ConstraintType& theType, - const EntityWrapperPtr& theValue, - const bool theFullValue, - const EntityWrapperPtr& thePoint1, - const EntityWrapperPtr& thePoint2, - const std::list& theTrsfEnt) const -{ - if (theType != CONSTRAINT_MULTI_ROTATION && theType != CONSTRAINT_MULTI_TRANSLATION) - return ConstraintWrapperPtr(); - - std::list aConstrAttrList = theTrsfEnt; - if (thePoint2) - aConstrAttrList.push_front(thePoint2); - aConstrAttrList.push_front(thePoint1); - - ScalarWrapperPtr aValue = GCS_SCALAR_WRAPPER(theValue); - - std::shared_ptr aResult( - new PlaneGCSSolver_ConstraintWrapper(std::list(), theType)); - aResult->setEntities(aConstrAttrList); - if (aValue) - aResult->setValueParameter(aValue); - aResult->setIsFullValue(theFullValue); - return aResult; -} - -std::shared_ptr PlaneGCSSolver_Builder::point(EntityWrapperPtr theEntity) const +std::shared_ptr PlaneGCSSolver_Tools::point(EntityWrapperPtr theEntity) { if (theEntity->type() != ENTITY_POINT) return std::shared_ptr(); @@ -227,7 +236,7 @@ std::shared_ptr PlaneGCSSolver_Builder::point(EntityWrapperPtr th return std::shared_ptr(new GeomAPI_Pnt2d(*aPoint->x, *aPoint->y)); } -std::shared_ptr PlaneGCSSolver_Builder::line(EntityWrapperPtr theEntity) const +std::shared_ptr PlaneGCSSolver_Tools::line(EntityWrapperPtr theEntity) { if (theEntity->type() != ENTITY_LINE) return std::shared_ptr(); @@ -239,7 +248,7 @@ std::shared_ptr PlaneGCSSolver_Builder::line(EntityWrapperPtr the new GeomAPI_Lin2d(*(aLine->p1.x), *(aLine->p1.y), *(aLine->p2.x), *(aLine->p2.y))); } -std::shared_ptr PlaneGCSSolver_Builder::line(FeaturePtr theFeature) const +std::shared_ptr PlaneGCSSolver_Tools::line(FeaturePtr theFeature) { if (theFeature->getKind() != SketchPlugin_Line::ID()) return std::shared_ptr(); @@ -513,8 +522,8 @@ ConstraintWrapperPtr createConstraintTangent( return ConstraintWrapperPtr(new PlaneGCSSolver_ConstraintWrapper(aNewConstr, theType)); } -bool PlaneGCSSolver_Builder::isArcArcTangencyInternal( - EntityWrapperPtr theArc1, EntityWrapperPtr theArc2) const +bool PlaneGCSSolver_Tools::isArcArcTangencyInternal( + EntityWrapperPtr theArc1, EntityWrapperPtr theArc2) { std::shared_ptr aCirc1 = std::dynamic_pointer_cast( GCS_ENTITY_WRAPPER(theArc1)->entity()); diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.h new file mode 100644 index 000000000..56dfbbdbb --- /dev/null +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.h @@ -0,0 +1,64 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: PlaneGCSSolver_Tools.h +// Created: 01 Mar 2017 +// Author: Artem ZHIDKOV + +#ifndef PlaneGCSSolver_Tools_H_ +#define PlaneGCSSolver_Tools_H_ + +#include +#include + +#include +#include + +/** \namespace PlaneGCSSolver_Tools + * \ingroup Plugins + * \brief Converter tools + */ +namespace PlaneGCSSolver_Tools +{ + /// \brief Creates a solver's constraint using given SketchPlugin constraint + /// or returns empty pointer if not all attributes are correct + SolverConstraintPtr createConstraint(ConstraintPtr theConstraint); + + /// \brief Creates temporary constraint to fix the feature after movement + SolverConstraintPtr createMovementConstraint(FeaturePtr theMovedFeature); + + /// \brief Creates new constraint using given parameters + /// \param theConstraint [in] original constraint + /// \param theType [in] type of constraint + /// \param theValue [in] numeric characteristic of constraint + /// (e.g. distance or radius) if applicable + /// \param theEntity1 [in] first attribute of constraint + /// \param theEntity2 [in] second attribute of constraint + /// \param theEntity3 [in] third attribute of constraint + /// \param theEntity4 [in] fourth attribute of constraint + /// \return Created wrapper of constraints applicable for specific solver. + ConstraintWrapperPtr createConstraint(ConstraintPtr theConstraint, + const SketchSolver_ConstraintType& theType, + const EntityWrapperPtr& theValue, + const EntityWrapperPtr& theEntity1, + const EntityWrapperPtr& theEntity2 = EntityWrapperPtr(), + const EntityWrapperPtr& theEntity3 = EntityWrapperPtr(), + const EntityWrapperPtr& theEntity4 = EntityWrapperPtr()); + + /// \brief Convert entity to point + /// \return empty pointer if the entity is not a point + std::shared_ptr point(EntityWrapperPtr theEntity); + /// \brief Convert entity to line + /// \return empty pointer if the entity is not a line + std::shared_ptr line(EntityWrapperPtr theEntity); + + /// \brief Convert entity to line + /// \return empty pointer if the entity is not a line + std::shared_ptr line(FeaturePtr theFeature); + + /// \brief Check if two connected arcs have centers + /// in same direction relatively to connection point + bool isArcArcTangencyInternal(EntityWrapperPtr theArc1, + EntityWrapperPtr theArc2); +}; + +#endif diff --git a/src/SketchSolver/SketchSolver_Builder.cpp b/src/SketchSolver/SketchSolver_Builder.cpp deleted file mode 100644 index d5bf71dc9..000000000 --- a/src/SketchSolver/SketchSolver_Builder.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: SketchSolver_Builder.cpp -// Created: 25 Mar 2015 -// Author: Artem ZHIDKOV - -#include "SketchSolver_Builder.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _DEBUG -#include -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -SolverConstraintPtr SketchSolver_Builder::createConstraint(ConstraintPtr theConstraint) const -{ - SolverConstraintPtr aResult; - DataPtr aData = theConstraint->data(); - -#ifdef _DEBUG - // Verify attributes of constraint and generate errors - std::list anAttrList = aData->attributes(std::string()); - std::list::iterator anIter = anAttrList.begin(); - for (; anIter != anAttrList.end(); anIter++) { - AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(*anIter); - if (aRefAttr) { - if (aRefAttr->isObject() && aRefAttr->object()) { - ResultConstructionPtr aRC = - std::dynamic_pointer_cast(aRefAttr->object()); - if (!aRC) - Events_InfoMessage("SketchSolver_Builder", - SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this).send(); - } - continue; - } - AttributeRefListPtr aRefList = std::dynamic_pointer_cast(*anIter); - if (aRefList) { - std::list aList = aRefList->list(); - std::list::iterator aListIter = aList.begin(); - for (; aListIter != aList.end(); aListIter++) { - ResultConstructionPtr aRC = - std::dynamic_pointer_cast(*aListIter); - if (*aListIter && !aRC) - Events_InfoMessage("SketchSolver_Builder", - SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this).send(); - } - } - } -#endif - - if (theConstraint->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintCoincidence(theConstraint)); - } else if (theConstraint->getKind() == SketchPlugin_ConstraintCollinear::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintCollinear(theConstraint)); - } else if (theConstraint->getKind() == SketchPlugin_ConstraintDistance::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintDistance(theConstraint)); - } else if (theConstraint->getKind() == SketchPlugin_ConstraintEqual::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintEqual(theConstraint)); - } else if (theConstraint->getKind() == SketchPlugin_ConstraintLength::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintLength(theConstraint)); - } else if (theConstraint->getKind() == SketchPlugin_ConstraintMiddle::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintMiddle(theConstraint)); - } else if (theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintMirror(theConstraint)); - } else if (theConstraint->getKind() == SketchPlugin_ConstraintTangent::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintTangent(theConstraint)); - } else if (theConstraint->getKind() == SketchPlugin_ConstraintRigid::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintFixed(theConstraint)); - } else if (theConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintMultiTranslation(theConstraint)); - } else if (theConstraint->getKind() == SketchPlugin_MultiRotation::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintMultiRotation(theConstraint)); - } else if (theConstraint->getKind() == SketchPlugin_ConstraintAngle::ID()) { - return SolverConstraintPtr(new SketchSolver_ConstraintAngle(theConstraint)); - } - // All other types of constraints - return SolverConstraintPtr(new SketchSolver_Constraint(theConstraint)); -} - -SolverConstraintPtr SketchSolver_Builder::createMovementConstraint(FeaturePtr theMovedFeature) const -{ - return SolverConstraintPtr(new SketchSolver_ConstraintFixed(theMovedFeature)); -} diff --git a/src/SketchSolver/SketchSolver_Builder.h b/src/SketchSolver/SketchSolver_Builder.h deleted file mode 100644 index 10677a712..000000000 --- a/src/SketchSolver/SketchSolver_Builder.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: SketchSolver_Builder.h -// Created: 25 Mar 2015 -// Author: Artem ZHIDKOV - -#ifndef SketchSolver_Builder_H_ -#define SketchSolver_Builder_H_ - -#include -#include - -#include -#include - -/** \class SketchSolver_Builder - * \ingroup Plugins - * \brief Abstract class for builders of solver's entities - */ -class SketchSolver_Builder -{ -public: - /// \brief Creates a storage specific for used solver - virtual StoragePtr createStorage(const SolverPtr&) const = 0; - /// \brief Creates specific solver - virtual SolverPtr createSolver() const = 0; - - /// \brief Creates a solver's constraint using given SketchPlugin constraint - /// or returns empty pointer if not all attributes are correct - SolverConstraintPtr createConstraint(ConstraintPtr theConstraint) const; - - /// \brief Creates temporary constraint to fix the feature after movement - SolverConstraintPtr createMovementConstraint(FeaturePtr theMovedFeature) const; - - /// \brief Creates new constraint using given parameters - /// \param theConstraint [in] original constraint - /// \param theType [in] type of constraint - /// \param theValue [in] numeric characteristic of constraint - /// (e.g. distance or radius) if applicable - /// \param theEntity1 [in] first attribute of constraint - /// \param theEntity2 [in] second attribute of constraint - /// \param theEntity3 [in] third attribute of constraint - /// \param theEntity4 [in] fourth attribute of constraint - /// \return Created wrapper of constraints applicable for specific solver. - virtual ConstraintWrapperPtr - createConstraint(ConstraintPtr theConstraint, - const SketchSolver_ConstraintType& theType, - const EntityWrapperPtr& theValue, - const EntityWrapperPtr& theEntity1, - const EntityWrapperPtr& theEntity2 = EntityWrapperPtr(), - const EntityWrapperPtr& theEntity3 = EntityWrapperPtr(), - const EntityWrapperPtr& theEntity4 = EntityWrapperPtr()) const = 0; - - /// \brief Creates new multi-translation or multi-rotation constraint - /// \param theConstraint [in] original constraint - /// \param theType [in] type of constraint - /// \param theValue [in] numeric characteristic of constraint (angle for multi-rotation) - /// if applicable - /// \param theFullValue [in] indicates theValue shows full translation delta/rotation angle or - /// delta/angle between neighbor entities - /// \param thePoint1 [in] center for multi-rotation or start point for multi-translation - /// \param thePoint2 [in] end point for multi-translation (empty for multi-rotation) - /// \param theTrsfEnt [in] list of transformed entities - virtual ConstraintWrapperPtr - createConstraint(ConstraintPtr theConstraint, - const SketchSolver_ConstraintType& theType, - const EntityWrapperPtr& theValue, - const bool theFullValue, - const EntityWrapperPtr& thePoint1, - const EntityWrapperPtr& thePoint2, - const std::list& theTrsfEnt) const = 0; - - - /// \brief Convert entity to point - /// \return empty pointer if the entity is not a point - virtual std::shared_ptr point(EntityWrapperPtr theEntity) const = 0; - /// \brief Convert entity to line - /// \return empty pointer if the entity is not a line - virtual std::shared_ptr line(EntityWrapperPtr theEntity) const = 0; - - /// \brief Convert entity to line - /// \return empty pointer if the entity is not a line - virtual std::shared_ptr line(FeaturePtr theFeature) const = 0; - - /// \brief Check if two connected arcs have centers - /// in same direction relatively to connection point - virtual bool isArcArcTangencyInternal(EntityWrapperPtr theArc1, - EntityWrapperPtr theArc2) const = 0; -}; - -typedef std::shared_ptr BuilderPtr; - -#endif diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index 385190514..1a4a59484 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -1,11 +1,10 @@ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D #include -#include #include -#include #include +#include #include #include @@ -114,8 +113,7 @@ void SketchSolver_Constraint::process() if (aConstrType == CONSTRAINT_UNKNOWN) aConstrType = getType(); - BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); - ConstraintWrapperPtr aNewConstraint = aBuilder->createConstraint( + ConstraintWrapperPtr aNewConstraint = PlaneGCSSolver_Tools::createConstraint( myBaseConstraint, aConstrType, aValue, anAttributes[0], anAttributes[1], anAttributes[2], anAttributes[3]); myStorage->addConstraint(myBaseConstraint, aNewConstraint); @@ -183,7 +181,6 @@ void SketchSolver_Constraint::getAttributes( myAttributes.clear(); DataPtr aData = myBaseConstraint->data(); - BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); myType = TYPE(myBaseConstraint); diff --git a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp index c2f35d24e..a2c3357b6 100644 --- a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include void SketchSolver_ConstraintCoincidence::process() @@ -23,8 +23,7 @@ void SketchSolver_ConstraintCoincidence::process() return; } - BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); - mySolverConstraint = aBuilder->createConstraint( + mySolverConstraint = PlaneGCSSolver_Tools::createConstraint( myBaseConstraint, getType(), aValue, anAttributes[0], anAttributes[1], anAttributes[2], anAttributes[3]); diff --git a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp index 6381b2bd3..7dd34c528 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp @@ -2,8 +2,8 @@ #include #include -#include +#include #include #include @@ -99,12 +99,10 @@ void SketchSolver_ConstraintMirror::update() void SketchSolver_ConstraintMirror::adjustConstraint() { - BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); - AttributeRefAttrPtr aMirrLineRefAttr = myBaseConstraint->refattr(SketchPlugin_Constraint::ENTITY_A()); std::shared_ptr aMirrorLine = - aBuilder->line(ModelAPI_Feature::feature(aMirrLineRefAttr->object())); + PlaneGCSSolver_Tools::line(ModelAPI_Feature::feature(aMirrLineRefAttr->object())); AttributeRefListPtr aBaseRefList = myBaseConstraint->reflist(SketchPlugin_Constraint::ENTITY_B()); diff --git a/src/SketchSolver/SketchSolver_ConstraintTangent.cpp b/src/SketchSolver/SketchSolver_ConstraintTangent.cpp index 0df752a29..ab4a27ea7 100644 --- a/src/SketchSolver/SketchSolver_ConstraintTangent.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintTangent.cpp @@ -2,7 +2,8 @@ #include #include -#include + +#include #include #include @@ -34,15 +35,6 @@ static bool hasSingleCoincidence(FeaturePtr theFeature1, FeaturePtr theFeature2) return aCoincidences.size() <= 1; } -/// \brief Check if two connected arcs have centers -/// in same direction relatively to connection point -static bool isInternalTangency(EntityWrapperPtr theEntity1, EntityWrapperPtr theEntity2) -{ - BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); - return aBuilder->isArcArcTangencyInternal(theEntity1, theEntity2); -} - - void SketchSolver_ConstraintTangent::getAttributes( EntityWrapperPtr& theValue, std::vector& theAttributes) @@ -84,7 +76,8 @@ void SketchSolver_ConstraintTangent::getAttributes( } else if (aNbArcs == 2) { myType = CONSTRAINT_TANGENT_ARC_ARC; - isArcArcInternal = isInternalTangency(theAttributes[2], theAttributes[3]); + isArcArcInternal = + PlaneGCSSolver_Tools::isArcArcTangencyInternal(theAttributes[2], theAttributes[3]); } else { myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE(); @@ -116,7 +109,7 @@ void SketchSolver_ConstraintTangent::adjustConstraint() EntityWrapperPtr anEntity2 = myStorage->entity(myBaseConstraint->attribute(SketchPlugin_Constraint::ENTITY_B())); - if (isArcArcInternal != isInternalTangency(anEntity1, anEntity2)) { + if (isArcArcInternal != PlaneGCSSolver_Tools::isArcArcTangencyInternal(anEntity1, anEntity2)) { // fully rebuld constraint, because it is unable to access attributes of PlaneGCS constraint remove(); process(); diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index c5418065b..ce576cdbf 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -9,6 +9,8 @@ #include #include +#include +#include #include #include @@ -40,12 +42,11 @@ static void sendMessage(const char* theMessageName, const std::set& t SketchSolver_Group::SketchSolver_Group(const CompositeFeaturePtr& theWorkplane) : mySketch(theWorkplane), - myPrevResult(STATUS_UNKNOWN), + myPrevResult(PlaneGCSSolver_Solver::STATUS_UNKNOWN), myIsEventsBlocked(false) { - BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); - mySketchSolver = aBuilder->createSolver(); - myStorage = aBuilder->createStorage(mySketchSolver); + mySketchSolver = SolverPtr(new PlaneGCSSolver_Solver); + myStorage = StoragePtr(new PlaneGCSSolver_Storage(mySketchSolver)); } SketchSolver_Group::~SketchSolver_Group() @@ -68,9 +69,8 @@ bool SketchSolver_Group::changeConstraint( { bool isNewConstraint = myConstraints.find(theConstraint) == myConstraints.end(); if (isNewConstraint) { - BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); // Add constraint to the current group - SolverConstraintPtr aConstraint = aBuilder->createConstraint(theConstraint); + SolverConstraintPtr aConstraint = PlaneGCSSolver_Tools::createConstraint(theConstraint); if (!aConstraint) return false; aConstraint->process(myStorage, myIsEventsBlocked); @@ -93,10 +93,8 @@ bool SketchSolver_Group::updateFeature(FeaturePtr theFeature) bool SketchSolver_Group::moveFeature(FeaturePtr theFeature) { - BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); - // Create temporary Fixed constraint - SolverConstraintPtr aConstraint = aBuilder->createMovementConstraint(theFeature); + SolverConstraintPtr aConstraint = PlaneGCSSolver_Tools::createMovementConstraint(theFeature); if (!aConstraint) return false; aConstraint->process(myStorage, myIsEventsBlocked); @@ -118,49 +116,28 @@ bool SketchSolver_Group::resolveConstraints() bool aResolved = false; bool isGroupEmpty = isEmpty() && myStorage->isEmpty(); if (myStorage->isNeedToResolve() && - (!isGroupEmpty || !myConflictingConstraints.empty() || myPrevResult == STATUS_FAILED)) { -//// if (!mySketchSolver) -//// mySketchSolver = SketchSolver_Manager::instance()->builder()->createSolver(); - -//// mySketchSolver->calculateFailedConstraints(false); -//// myStorage->initializeSolver(); -//// mySketchSolver->prepare(); + (!isGroupEmpty || !myConflictingConstraints.empty() || + myPrevResult == PlaneGCSSolver_Solver::STATUS_FAILED)) { - SketchSolver_SolveStatus aResult = STATUS_OK; + PlaneGCSSolver_Solver::SolveStatus aResult = PlaneGCSSolver_Solver::STATUS_OK; try { - if (!isGroupEmpty) { - // To avoid overconstraint situation, we will remove temporary constraints one-by-one - // and try to find the case without overconstraint - bool isLastChance = false; - while (true) { - aResult = mySketchSolver->solve(); - if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET || isLastChance) - break; -//// // try to update parameters and resolve once again -//// ConstraintConstraintMap::iterator aConstrIt = myConstraints.begin(); -//// for (; aConstrIt != myConstraints.end(); ++aConstrIt) -//// aConstrIt->second->update(); - isLastChance = true; - - removeTemporaryConstraints(); - mySketchSolver->calculateFailedConstraints(true); // something failed => need to find it -//// myStorage->initializeSolver(); - } - } + if (!isGroupEmpty) + aResult = mySketchSolver->solve(); } catch (...) { -// Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this); getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR()) ->setValue(SketchSolver_Error::SOLVESPACE_CRASH()); - if (myPrevResult == STATUS_OK || myPrevResult == STATUS_UNKNOWN) { + if (myPrevResult == PlaneGCSSolver_Solver::STATUS_OK || + myPrevResult == PlaneGCSSolver_Solver::STATUS_UNKNOWN) { // the error message should be changed before sending the message sendMessage(EVENT_SOLVER_FAILED); - myPrevResult = STATUS_FAILED; + myPrevResult = PlaneGCSSolver_Solver::STATUS_FAILED; } mySketchSolver->undo(); return false; } // solution succeeded, store results into correspondent attributes - if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET) { + if (aResult == PlaneGCSSolver_Solver::STATUS_OK || + aResult == PlaneGCSSolver_Solver::STATUS_EMPTYSET) { myStorage->setNeedToResolve(false); myStorage->refresh(); //// updateMultiConstraints(myConstraints); @@ -168,11 +145,12 @@ bool SketchSolver_Group::resolveConstraints() //// if (myStorage->isNeedToResolve()) //// resolveConstraints(); - if (myPrevResult != STATUS_OK || myPrevResult == STATUS_UNKNOWN) { + if (myPrevResult != PlaneGCSSolver_Solver::STATUS_OK || + myPrevResult == PlaneGCSSolver_Solver::STATUS_UNKNOWN) { getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(""); std::set aConflicting = myConflictingConstraints; myConflictingConstraints.clear(); - myPrevResult = STATUS_OK; + myPrevResult = PlaneGCSSolver_Solver::STATUS_OK; // the error message should be changed before sending the message sendMessage(EVENT_SOLVER_REPAIRED, aConflicting); } @@ -186,8 +164,8 @@ bool SketchSolver_Group::resolveConstraints() getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR()) ->setValue(SketchSolver_Error::CONSTRAINTS()); if (myPrevResult != aResult || - myPrevResult == STATUS_UNKNOWN || - myPrevResult == STATUS_FAILED) { + myPrevResult == PlaneGCSSolver_Solver::STATUS_UNKNOWN || + myPrevResult == PlaneGCSSolver_Solver::STATUS_FAILED) { // Obtain list of conflicting constraints std::set aConflicting = myStorage->getConflictingConstraints(mySketchSolver); diff --git a/src/SketchSolver/SketchSolver_Group.h b/src/SketchSolver/SketchSolver_Group.h index c795c5e9f..7e8c9424f 100644 --- a/src/SketchSolver/SketchSolver_Group.h +++ b/src/SketchSolver/SketchSolver_Group.h @@ -9,7 +9,8 @@ #include #include -#include + +#include #include @@ -106,7 +107,7 @@ private: SolverPtr mySketchSolver; ///< Solver for set of equations obtained by constraints /// Result of previous solution of the set of constraints - SketchSolver_SolveStatus myPrevResult; + PlaneGCSSolver_Solver::SolveStatus myPrevResult; std::set myConflictingConstraints; ///< List of conflicting constraints bool myIsEventsBlocked; ///< shows the events are blocked for this group diff --git a/src/SketchSolver/SketchSolver_IConstraintWrapper.h b/src/SketchSolver/SketchSolver_IConstraintWrapper.h index 04b7e917f..3fa42f14d 100644 --- a/src/SketchSolver/SketchSolver_IConstraintWrapper.h +++ b/src/SketchSolver/SketchSolver_IConstraintWrapper.h @@ -63,29 +63,13 @@ public: /// \brief Return type of current entity virtual SketchSolver_ConstraintType type() const = 0; - /// \brief Assign list of constrained objects - void setEntities(const std::list& theEntities) - { myConstrained = theEntities; } - /// \brief Return list of constrained objects - const std::list& entities() const - { return myConstrained; } - /// \brief Assign numeric parameter of constraint virtual void setValue(const double& theValue) = 0; /// \brief Return numeric parameter of constraint virtual double value() const = 0; - /// \brief Store a boolean flag for full value using - void setIsFullValue(const bool& theFullValue) - { myIsFullValue = theFullValue; } - /// \brief Return a flag of a full value using - const bool& isFullValue() const - { return myIsFullValue; } - protected: - ConstraintID myID; - std::list myConstrained; - bool myIsFullValue; + ConstraintID myID; }; typedef std::shared_ptr ConstraintWrapperPtr; diff --git a/src/SketchSolver/SketchSolver_ISolver.h b/src/SketchSolver/SketchSolver_ISolver.h deleted file mode 100644 index da9c5041e..000000000 --- a/src/SketchSolver/SketchSolver_ISolver.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: SketchSolver_ISolver.h -// Created: 30 Nov 2015 -// Author: Artem ZHIDKOV - -#ifndef SketchSolver_ISolver_H_ -#define SketchSolver_ISolver_H_ - -#include - -#include - -/// The result of constraints solution -enum SketchSolver_SolveStatus { - STATUS_OK, - STATUS_INCONSISTENT, - STATUS_EMPTYSET, - STATUS_FAILED, // set if no one other status is applicable - STATUS_UNKNOWN // set for newly created groups -}; - - -/** - * Interface providing operations to solve sketches. - */ -class SketchSolver_ISolver -{ -public: - virtual ~SketchSolver_ISolver() {} - - /// \brief Set or unset the flag which allows to find all failed constraints - void calculateFailedConstraints(bool theSic) - { myFindFaileds = theSic; } - - /// \brief Prepare for solving. Store initial values of parameters for undo - virtual void prepare() = 0; - - /// \brief Solve the set of equations - /// \return identifier whether solution succeeded - virtual SketchSolver_SolveStatus solve() = 0; - - /// \brief Revert solution to initial values - virtual void undo() = 0; - - /// \brief Check the constraint is conflicted with others - virtual bool isConflicting(const ConstraintID& theConstraint) const = 0; - - /// \brief Degrees of freedom - virtual int dof() = 0; - -protected: - bool myFindFaileds; ///< flag to find conflicting or inappropriate constraints -}; - -typedef std::shared_ptr SolverPtr; - -#endif diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index 0d20365a4..5571e2927 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -62,16 +62,6 @@ SketchSolver_Manager::~SketchSolver_Manager() myGroups.clear(); } -void SketchSolver_Manager::setBuilder(BuilderPtr theBuilder) -{ - myBuilder = theBuilder; -} - -BuilderPtr SketchSolver_Manager::builder() -{ - return myBuilder; -} - bool SketchSolver_Manager::groupMessages() { return true; diff --git a/src/SketchSolver/SketchSolver_Manager.h b/src/SketchSolver/SketchSolver_Manager.h index 89a9b7acc..7d227dee4 100644 --- a/src/SketchSolver/SketchSolver_Manager.h +++ b/src/SketchSolver/SketchSolver_Manager.h @@ -9,7 +9,6 @@ #include "SketchSolver.h" #include -#include #include #include @@ -43,12 +42,6 @@ public: */ virtual bool groupMessages(); - /// \brief Initialize builder for solver's data structure entities - /// \param theBuilder [in] solver's specific builder - void setBuilder(BuilderPtr theBuilder); - /// \brief Returns the builder specific for the solver - BuilderPtr builder(); - protected: SketchSolver_Manager(); ~SketchSolver_Manager(); @@ -87,7 +80,6 @@ private: private: std::list myGroups; ///< Groups of constraints - BuilderPtr myBuilder; ///< Builder for solver's entities /// true if computation is performed and all "updates" are generated by this algo /// and needs no recomputation bool myIsComputed; diff --git a/src/SketchSolver/SketchSolver_Storage.h b/src/SketchSolver/SketchSolver_Storage.h index 332bd39af..50d30987c 100644 --- a/src/SketchSolver/SketchSolver_Storage.h +++ b/src/SketchSolver/SketchSolver_Storage.h @@ -10,8 +10,8 @@ #include #include #include -#include +#include #include #include -- 2.30.2