From: vsv Date: Wed, 2 Nov 2016 14:49:41 +0000 (+0300) Subject: Issue #1834: Fix length of lines X-Git-Tag: V_2.6.0~128 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c3aeb6b898054376c1047071ea9fea61abdc9e99;p=modules%2Fshaper.git Issue #1834: Fix length of lines --- diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp index fd02a9d20..dd044ca69 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp @@ -387,7 +387,8 @@ std::list PlaneGCSSolver_Builder::createMirror( aResult.insert(aResult.end(), aMrrList.begin(), aMrrList.end()); } else if (theEntity1->type() == ENTITY_ARC) { - // Do not allow mirrored arc recalculate its position until coordinated of all points recalculated + // Do not allow mirrored arc recalculate its position until + // coordinated of all points recalculated FeaturePtr aMirrArc = theEntity2->baseFeature(); aMirrArc->data()->blockSendAttributeUpdated(true); @@ -403,7 +404,8 @@ std::list PlaneGCSSolver_Builder::createMirror( aMrrList = createMirror(theConstraint, theGroupID, theSketchID, *anIt1, *anIt2, theMirrorLine); aResult.insert(aResult.end(), aMrrList.begin(), aMrrList.end()); - // make symmetric last point of original arc and first point of mirrored arc without additional constraint + // make symmetric last point of original arc and first point of + // mirrored arc without additional constraint ++anIt1; --anIt2; makeMirrorPoints(*anIt1, *anIt2, theMirrorLine); @@ -620,7 +622,8 @@ std::shared_ptr createScalar( const GroupID& theGroupID, AttributeDoublePtr theDoubleAttr) { - ParameterWrapperPtr aParam = createParameter(theGroupID, theDoubleAttr ? theDoubleAttr->value() : 0.0); + ParameterWrapperPtr aParam = + createParameter(theGroupID, theDoubleAttr ? theDoubleAttr->value() : 0.0); return std::shared_ptr( new PlaneGCSSolver_ScalarWrapper(theDoubleAttr, aParam)); } @@ -660,7 +663,8 @@ EntityWrapperPtr createLine(FeaturePtr theFeature, aLine->p2 = *(aEndEnt->point()); aNewEntity = EntityWrapperPtr(new PlaneGCSSolver_EntityWrapper(theFeature, aLine)); - aNewEntity->setGroup(theGroupID); // sub-entities should not change their groups, therefore they are added later + // sub-entities should not change their groups, therefore they are added later + aNewEntity->setGroup(theGroupID); aNewEntity->setSubEntities(aSubs); return aNewEntity; } @@ -697,7 +701,8 @@ EntityWrapperPtr createCircle(FeaturePtr theFeature, aCircle->rad = aRadiusEnt->scalar(); aNewEntity = EntityWrapperPtr(new PlaneGCSSolver_EntityWrapper(theFeature, aCircle)); - aNewEntity->setGroup(theGroupID); // sub-entities should not change their groups, therefore they are added later + // sub-entities should not change their groups, therefore they are added later + aNewEntity->setGroup(theGroupID); aNewEntity->setSubEntities(aSubs); return aNewEntity; } @@ -753,7 +758,8 @@ EntityWrapperPtr createArc(FeaturePtr theFeature, anArc->rad = aRadius->scalar(); aNewEntity = EntityWrapperPtr(new PlaneGCSSolver_EntityWrapper(theFeature, anArc)); - aNewEntity->setGroup(theGroupID); // sub-entities should not change their groups, therefore they are added later + // sub-entities should not change their groups, therefore they are added later + aNewEntity->setGroup(theGroupID); aNewEntity->setSubEntities(aSubs); return aNewEntity; } @@ -807,7 +813,8 @@ ConstraintWrapperPtr createConstraintPointOnEntity( } case ENTITY_ARC: case ENTITY_CIRCLE: { - std::shared_ptr aCirc = std::dynamic_pointer_cast(theEntity->entity()); + std::shared_ptr aCirc = + std::dynamic_pointer_cast(theEntity->entity()); aNewConstr = GCSConstraintPtr( new GCS::ConstraintP2PDistance(*(thePoint->point()), aCirc->center, aCirc->rad)); break; @@ -856,7 +863,8 @@ ConstraintWrapperPtr createConstraintMiddlePoint( aConstrList.push_back(GCSConstraintPtr(new GCS::ConstraintPointOnLine(*aPoint, *aLine))); double aDist = lineLength(*aLine); std::shared_ptr aDistance = - std::dynamic_pointer_cast(createParameter(theGroupID, aDist * 0.5)); + std::dynamic_pointer_cast( + createParameter(theGroupID, aDist * 0.5)); aConstrList.push_back(GCSConstraintPtr( new GCS::ConstraintP2PDistance(*aPoint, aLine->p1, aDistance->parameter()))); aConstrList.push_back(GCSConstraintPtr( @@ -931,7 +939,8 @@ ConstraintWrapperPtr createConstraintRadius( std::shared_ptr theValue, std::shared_ptr theEntity) { - std::shared_ptr aCircle = std::dynamic_pointer_cast(theEntity->entity()); + std::shared_ptr aCircle = + std::dynamic_pointer_cast(theEntity->entity()); GCSConstraintPtr aNewConstr(new GCS::ConstraintEqual(aCircle->rad, theValue->parameter())); std::shared_ptr aResult( @@ -1111,13 +1120,18 @@ ConstraintWrapperPtr createConstraintTangent( { GCSConstraintPtr aNewConstr; if (theType == CONSTRAINT_TANGENT_ARC_LINE || theType == CONSTRAINT_TANGENT_CIRCLE_LINE) { - std::shared_ptr aCirc = std::dynamic_pointer_cast(theEntity1->entity()); - std::shared_ptr aLine = std::dynamic_pointer_cast(theEntity2->entity()); + std::shared_ptr aCirc = + std::dynamic_pointer_cast(theEntity1->entity()); + std::shared_ptr aLine = + std::dynamic_pointer_cast(theEntity2->entity()); - aNewConstr = GCSConstraintPtr(new GCS::ConstraintP2LDistance(aCirc->center, *aLine, aCirc->rad)); + aNewConstr = + GCSConstraintPtr(new GCS::ConstraintP2LDistance(aCirc->center, *aLine, aCirc->rad)); } else { - std::shared_ptr aCirc1 = std::dynamic_pointer_cast(theEntity1->entity()); - std::shared_ptr aCirc2 = std::dynamic_pointer_cast(theEntity2->entity()); + std::shared_ptr aCirc1 = + std::dynamic_pointer_cast(theEntity1->entity()); + std::shared_ptr aCirc2 = + std::dynamic_pointer_cast(theEntity2->entity()); double aDX = *(aCirc1->center.x) - *(aCirc2->center.x); double aDY = *(aCirc1->center.y) - *(aCirc2->center.y); @@ -1160,9 +1174,11 @@ void makeMirrorPoints(EntityWrapperPtr theOriginal, (*aMIt)->setValue(aCoord[i]); // update corresponding attribute - AttributePtr anAttr = std::dynamic_pointer_cast(theMirrored)->baseAttribute(); + AttributePtr anAttr = + std::dynamic_pointer_cast(theMirrored)->baseAttribute(); if (anAttr) { - std::shared_ptr aMirroredPnt = std::dynamic_pointer_cast(anAttr); + std::shared_ptr aMirroredPnt = + std::dynamic_pointer_cast(anAttr); aMirroredPnt->setValue(aCoord[0], aCoord[1]); } } diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.h index a1402237c..5f59b6a25 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.h +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.h @@ -40,7 +40,8 @@ public: /// \param theGroupID [in] group the constraint belongs to /// \param theSketchID [in] sketch the constraint belongs to /// \param theType [in] type of constraint - /// \param theValue [in] numeric characteristic of constraint (e.g. distance or radius) if applicable + /// \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 @@ -64,8 +65,10 @@ public: /// \param theGroupID [in] group the constraint belongs to /// \param theSketchID [in] sketch the constraint belongs to /// \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 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 diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EntityWrapper.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EntityWrapper.h index cb107b7d7..976299a60 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EntityWrapper.h +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EntityWrapper.h @@ -16,7 +16,8 @@ class PlaneGCSSolver_EntityWrapper : public SketchSolver_IEntityWrapper { public: - PlaneGCSSolver_EntityWrapper(const FeaturePtr theFeature, const GCSCurvePtr theEntity = GCSCurvePtr()); + PlaneGCSSolver_EntityWrapper(const FeaturePtr theFeature, + const GCSCurvePtr theEntity = GCSCurvePtr()); /// \brief Return PlaneGCS geometric entity const GCSCurvePtr& entity() const diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp index 01aa0da38..7522367f6 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp @@ -91,7 +91,8 @@ SketchSolver_SolveStatus PlaneGCSSolver_Solver::solve() GCS::VEC_I aRedundantID; - // Workaround: the system with tangent constraint may fail if the tangent entities are connected smoothly. + // Workaround: the system with tangent constraint + // may fail if the tangent entities are connected smoothly. // Investigate this situation and move constraints to redundant list if (aResult == GCS::Failed && !myTangent.empty()) { GCS::VEC_I aConflictingID; @@ -127,7 +128,8 @@ SketchSolver_SolveStatus PlaneGCSSolver_Solver::solve() } } } - // The system with tangent constraints may show redundant constraints if the entities are coupled smoothly. + // The system with tangent constraints may show redundant constraints + // if the entities are coupled smoothly. // Sometimes tangent constraints are fall to both conflicting and redundant constraints. // Need to check if there are redundant constraints without these tangencies. if (!aRedundantID.empty()) diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h index c3b4b6110..b9016ceca 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h @@ -79,13 +79,18 @@ private: typedef std::map ConstraintMap; GCS::VEC_pD myParameters; ///< list of unknowns - ConstraintMap myConstraints; ///< list of constraints already processed by the system + + /// list of constraints already processed by the system + ConstraintMap myConstraints; std::shared_ptr myEquationSystem; ///< set of equations for solving in FreeGCS GCS::SET_I myConflictingIDs; ///< list of IDs of conflicting constraints - bool myConfCollected; ///< specifies the conflicting constraints are already collected - GCS::SET_I myTangent; ///< list of tangent IDs to check incorrect redundant constraints + /// specifies the conflicting constraints are already collected + bool myConfCollected; + + /// list of tangent IDs to check incorrect redundant constraints + GCS::SET_I myTangent; }; #endif diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index 2b83759b8..79341324d 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -390,9 +390,11 @@ void PlaneGCSSolver_Storage::processArc(const EntityWrapperPtr& theArc) std::list::const_iterator aSubIt = aSubs.begin(); while ((*aSubIt)->type() == ENTITY_POINT) // search scalar entities ++aSubIt; - double* aStartAngle = std::dynamic_pointer_cast(*aSubIt++)->scalar(); - double* aEndAngle = std::dynamic_pointer_cast(*aSubIt++)->scalar(); - double* aRadius = std::dynamic_pointer_cast(*aSubIt)->scalar(); + double* aStartAngle = + std::dynamic_pointer_cast(*aSubIt++)->scalar(); + double* aEndAngle = + std::dynamic_pointer_cast(*aSubIt++)->scalar(); + double* aRadius = std::dynamic_pointer_cast(*aSubIt)->scalar(); std::shared_ptr anArcFeature = std::dynamic_pointer_cast(theArc->baseFeature()); @@ -573,7 +575,8 @@ bool PlaneGCSSolver_Storage::isRedundant( std::list >::iterator aCoincIt, aFound1, aFound2; aFound1 = aFound2 = theCoincidentPoints.end(); - for (aCoincIt = theCoincidentPoints.begin(); aCoincIt != theCoincidentPoints.end(); ++aCoincIt) { + 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()) @@ -773,8 +776,10 @@ EntityWrapperPtr PlaneGCSSolver_Storage::calculateMiddlePoint( theX = anArcPoint[0][0] + anArcPoint[2][0]; theY = anArcPoint[0][1] + anArcPoint[2][1]; } else { - std::shared_ptr aStartDir(new GeomAPI_Dir2d(anArcPoint[1][0], anArcPoint[1][1])); - std::shared_ptr aEndDir(new GeomAPI_Dir2d(anArcPoint[2][0], anArcPoint[2][1])); + std::shared_ptr + aStartDir(new GeomAPI_Dir2d(anArcPoint[1][0], anArcPoint[1][1])); + std::shared_ptr + aEndDir(new GeomAPI_Dir2d(anArcPoint[2][0], anArcPoint[2][1])); double anAngle = aStartDir->angle(aEndDir); if (anAngle < 0) anAngle += 2.0 * PI; @@ -795,8 +800,10 @@ EntityWrapperPtr PlaneGCSSolver_Storage::calculateMiddlePoint( aParameters.push_back(aBuilder->createParameter(myGroupID, aMidPoint->y())); // Create entity (parameters are not filled) GCSPointPtr aPnt(new GCS::Point); - aPnt->x = std::dynamic_pointer_cast(aParameters.front())->parameter(); - aPnt->y = std::dynamic_pointer_cast(aParameters.back())->parameter(); + aPnt->x = + std::dynamic_pointer_cast(aParameters.front())->parameter(); + aPnt->y = + std::dynamic_pointer_cast(aParameters.back())->parameter(); EntityWrapperPtr aResult(new PlaneGCSSolver_PointWrapper(AttributePtr(), aPnt)); aResult->setGroup(myGroupID); diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h index 75e0b725e..882cffa12 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h @@ -117,10 +117,12 @@ private: EntityID myEntityLastID; ///< identifier of last added entity ConstraintID myConstraintLastID; ///< identifier of last added constraint + /// additional constraints for correct processing of the arcs std::map > - myArcConstraintMap; ///< additional constraints for correct processing of the arcs + myArcConstraintMap; - std::list myRemovedConstraints; ///< list of removed constraints to notify solver + /// list of removed constraints to notify solver + std::list myRemovedConstraints; }; #endif diff --git a/src/SketchSolver/SketchSolver_Builder.cpp b/src/SketchSolver/SketchSolver_Builder.cpp index 451e2141f..7cb7425fe 100644 --- a/src/SketchSolver/SketchSolver_Builder.cpp +++ b/src/SketchSolver/SketchSolver_Builder.cpp @@ -61,7 +61,8 @@ SolverConstraintPtr SketchSolver_Builder::createConstraint(ConstraintPtr theCons ResultConstructionPtr aRC = std::dynamic_pointer_cast(aRefAttr->object()); if (!aRC) - Events_InfoMessage("SketchSolver_Builder", SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this).send(); + Events_InfoMessage("SketchSolver_Builder", + SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this).send(); } continue; } @@ -73,7 +74,8 @@ SolverConstraintPtr SketchSolver_Builder::createConstraint(ConstraintPtr theCons ResultConstructionPtr aRC = std::dynamic_pointer_cast(*aListIter); if (*aListIter && !aRC) - Events_InfoMessage("SketchSolver_Builder", SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this).send(); + Events_InfoMessage("SketchSolver_Builder", + SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this).send(); } } } diff --git a/src/SketchSolver/SketchSolver_Builder.h b/src/SketchSolver/SketchSolver_Builder.h index fe34cb06e..f7775ea91 100644 --- a/src/SketchSolver/SketchSolver_Builder.h +++ b/src/SketchSolver/SketchSolver_Builder.h @@ -43,7 +43,8 @@ public: /// \param theGroupID [in] group the constraint belongs to /// \param theSketchID [in] sketch the constraint belongs to /// \param theType [in] type of constraint - /// \param theValue [in] numeric characteristic of constraint (e.g. distance or radius) if applicable + /// \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 @@ -67,8 +68,10 @@ public: /// \param theGroupID [in] group the constraint belongs to /// \param theSketchID [in] sketch the constraint belongs to /// \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 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 @@ -116,8 +119,8 @@ public: /// \brief Check if two connected arcs have centers /// in same direction relatively to connection point - SKETCHSOLVER_EXPORT virtual bool isArcArcTangencyInternal(EntityWrapperPtr theArc1, EntityWrapperPtr theArc2) const - { return false; } + SKETCHSOLVER_EXPORT virtual bool isArcArcTangencyInternal(EntityWrapperPtr theArc1, + EntityWrapperPtr theArc2) const { return false; } }; typedef std::shared_ptr BuilderPtr; diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index c402ec7dd..13396b8cf 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include @@ -256,7 +258,8 @@ bool SketchSolver_Constraint::isUsed(FeaturePtr theFeature) const if ((*aCIt)->isUsed(theFeature)) return true; - std::list anAttrList = theFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); + std::list anAttrList = + theFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); std::list::const_iterator anAttrIt = anAttrList.begin(); for (; anAttrIt != anAttrList.end(); ++ anAttrIt) if (isUsed(*anAttrIt)) diff --git a/src/SketchSolver/SketchSolver_Constraint.h b/src/SketchSolver/SketchSolver_Constraint.h index dbb647623..2b4a30b0d 100644 --- a/src/SketchSolver/SketchSolver_Constraint.h +++ b/src/SketchSolver/SketchSolver_Constraint.h @@ -47,7 +47,8 @@ public: SKETCHSOLVER_EXPORT virtual void update(); /// \brief Tries to remove constraint - /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence) + /// \return \c false, if current constraint contains another SketchPlugin constraints + /// (like for multiple coincidence) SKETCHSOLVER_EXPORT virtual bool remove(); /// \brief Obtain a type of SketchPlugin constraint @@ -67,8 +68,8 @@ public: virtual bool isUsed(AttributePtr theAttribute) const; /// \brief Notify constraint, that coincidence appears or removed - virtual void notifyCoincidenceChanged(EntityWrapperPtr theCoincAttr1, EntityWrapperPtr theCoincAttr2) - { /* implement in derived class */ } + virtual void notifyCoincidenceChanged(EntityWrapperPtr theCoincAttr1, + EntityWrapperPtr theCoincAttr2) { /* implement in derived class */ } /// \brief Shows error message const std::string& error() const @@ -96,7 +97,9 @@ protected: GroupID myGroupID; ///< identifier of the group, the constraint belongs to EntityID mySketchID; ///< identifier of the sketch, the constraint belongs to ConstraintPtr myBaseConstraint; ///< base SketchPlugin constraint - StoragePtr myStorage; ///< storage, which contains all information about entities and constraints + + /// storage, which contains all information about entities and constraints + StoragePtr myStorage; SketchSolver_ConstraintType myType; ///< type of constraint std::list myAttributes; ///< attributes of constraint diff --git a/src/SketchSolver/SketchSolver_ConstraintAngle.cpp b/src/SketchSolver/SketchSolver_ConstraintAngle.cpp index 6138e3062..7a6a4ac0f 100644 --- a/src/SketchSolver/SketchSolver_ConstraintAngle.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintAngle.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include diff --git a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp index 934966b52..18594018c 100644 --- a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include diff --git a/src/SketchSolver/SketchSolver_ConstraintCollinear.cpp b/src/SketchSolver/SketchSolver_ConstraintCollinear.cpp index 682782624..194d47aa0 100644 --- a/src/SketchSolver/SketchSolver_ConstraintCollinear.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintCollinear.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include diff --git a/src/SketchSolver/SketchSolver_ConstraintCollinear.h b/src/SketchSolver/SketchSolver_ConstraintCollinear.h index 6299740dd..6e06053ae 100644 --- a/src/SketchSolver/SketchSolver_ConstraintCollinear.h +++ b/src/SketchSolver/SketchSolver_ConstraintCollinear.h @@ -22,7 +22,8 @@ public: virtual ~SketchSolver_ConstraintCollinear() {} /// \brief Notify constraint, that coincidence appears or removed - virtual void notifyCoincidenceChanged(EntityWrapperPtr theCoincAttr1, EntityWrapperPtr theCoincAttr2); + virtual void notifyCoincidenceChanged(EntityWrapperPtr theCoincAttr1, + EntityWrapperPtr theCoincAttr2); }; #endif diff --git a/src/SketchSolver/SketchSolver_ConstraintDistance.cpp b/src/SketchSolver/SketchSolver_ConstraintDistance.cpp index 5bbcd7919..afe792932 100644 --- a/src/SketchSolver/SketchSolver_ConstraintDistance.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintDistance.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include diff --git a/src/SketchSolver/SketchSolver_ConstraintDistance.h b/src/SketchSolver/SketchSolver_ConstraintDistance.h index b11e0a8a5..9448b3c5d 100644 --- a/src/SketchSolver/SketchSolver_ConstraintDistance.h +++ b/src/SketchSolver/SketchSolver_ConstraintDistance.h @@ -38,7 +38,9 @@ protected: private: double myPrevValue; ///< previous value of distance (for correct calculation of a distance sign) - bool myIsNegative; ///< \c true, if the point if placed rightside of line direction (SLVS_C_PT_LINE_DISTANCE only) + + /// \c true, if the point if placed rightside of line direction (SLVS_C_PT_LINE_DISTANCE only) + bool myIsNegative; }; #endif diff --git a/src/SketchSolver/SketchSolver_ConstraintEqual.cpp b/src/SketchSolver/SketchSolver_ConstraintEqual.cpp index a6120533e..33cb9f5dd 100644 --- a/src/SketchSolver/SketchSolver_ConstraintEqual.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintEqual.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include diff --git a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp index 73c1a5220..ca14864cb 100644 --- a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include diff --git a/src/SketchSolver/SketchSolver_ConstraintFixed.h b/src/SketchSolver/SketchSolver_ConstraintFixed.h index 87bdd6d35..57f2d50d8 100644 --- a/src/SketchSolver/SketchSolver_ConstraintFixed.h +++ b/src/SketchSolver/SketchSolver_ConstraintFixed.h @@ -29,7 +29,8 @@ public: SketchSolver_ConstraintFixed(FeaturePtr theFeature); /// \brief Tries to remove constraint - /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence) + /// \return \c false, if current constraint contains another + /// SketchPlugin constraints (like for multiple coincidence) virtual bool remove(); protected: @@ -39,7 +40,8 @@ protected: /// \brief Generate list of attributes of constraint in order useful for constraints /// \param[out] theValue numerical characteristic of constraint (e.g. distance) /// \param[out] theAttributes list of attributes to be filled - virtual void getAttributes(ParameterWrapperPtr& theValue, std::vector& theAttributes); + virtual void getAttributes(ParameterWrapperPtr& theValue, + std::vector& theAttributes); /// \brief Fixed feature basing on its type /// \param theFeature [in] feature, converted to solver specific format diff --git a/src/SketchSolver/SketchSolver_ConstraintFixedArcRadius.cpp b/src/SketchSolver/SketchSolver_ConstraintFixedArcRadius.cpp index 05f071f4f..af32f1943 100644 --- a/src/SketchSolver/SketchSolver_ConstraintFixedArcRadius.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintFixedArcRadius.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include diff --git a/src/SketchSolver/SketchSolver_ConstraintFixedArcRadius.h b/src/SketchSolver/SketchSolver_ConstraintFixedArcRadius.h index f4fc805c3..70f6e8295 100644 --- a/src/SketchSolver/SketchSolver_ConstraintFixedArcRadius.h +++ b/src/SketchSolver/SketchSolver_ConstraintFixedArcRadius.h @@ -21,7 +21,8 @@ public: SketchSolver_ConstraintFixedArcRadius(FeaturePtr theFeature); /// \brief Tries to remove constraint - /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence) + /// \return \c false, if current constraint contains another SketchPlugin constraints + /// (like for multiple coincidence) virtual bool remove(); protected: diff --git a/src/SketchSolver/SketchSolver_ConstraintLength.cpp b/src/SketchSolver/SketchSolver_ConstraintLength.cpp index 5c3bbc088..714fe0cce 100644 --- a/src/SketchSolver/SketchSolver_ConstraintLength.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintLength.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include diff --git a/src/SketchSolver/SketchSolver_ConstraintMiddle.cpp b/src/SketchSolver/SketchSolver_ConstraintMiddle.cpp index 362bc58cc..69de3881e 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMiddle.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMiddle.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include diff --git a/src/SketchSolver/SketchSolver_ConstraintMiddle.h b/src/SketchSolver/SketchSolver_ConstraintMiddle.h index b86e714f5..6ab5400fb 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMiddle.h +++ b/src/SketchSolver/SketchSolver_ConstraintMiddle.h @@ -22,7 +22,8 @@ public: virtual ~SketchSolver_ConstraintMiddle() {} /// \brief Notify constraint, that coincidence appears or removed - virtual void notifyCoincidenceChanged(EntityWrapperPtr theCoincAttr1, EntityWrapperPtr theCoincAttr2); + virtual void notifyCoincidenceChanged(EntityWrapperPtr theCoincAttr1, + EntityWrapperPtr theCoincAttr2); }; #endif diff --git a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp index 63867f1c3..c91121d76 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include diff --git a/src/SketchSolver/SketchSolver_ConstraintMovement.cpp b/src/SketchSolver/SketchSolver_ConstraintMovement.cpp index 7f4c8d78b..110741c56 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMovement.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMovement.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include @@ -49,7 +51,8 @@ static std::list movedEntities( for (; anOldIt != anOldSubs.end() && aNewIt != aNewSubs.end(); ++anOldIt, ++aNewIt) { std::list aMovedSubs = movedEntities( *anOldIt, theOldStorage, *aNewIt, theNewStorage); - if ((*anOldIt)->type() == ENTITY_POINT && // check only the points to be moved (because arcs in PlaneGCS have scalar subs too) + // check only the points to be moved (because arcs in PlaneGCS have scalar subs too) + if ((*anOldIt)->type() == ENTITY_POINT && (aMovedSubs.size() != 1 || aMovedSubs.front() != *anOldIt)) isFullyMoved = false; aMoved.insert(aMoved.end(), aMovedSubs.begin(), aMovedSubs.end()); diff --git a/src/SketchSolver/SketchSolver_ConstraintMovement.h b/src/SketchSolver/SketchSolver_ConstraintMovement.h index 93b2ea001..484b7bb56 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMovement.h +++ b/src/SketchSolver/SketchSolver_ConstraintMovement.h @@ -29,7 +29,8 @@ public: {} /// \brief Tries to remove constraint - /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence) + /// \return \c false, if current constraint contains another SketchPlugin + /// constraints (like for multiple coincidence) virtual bool remove(); protected: @@ -38,8 +39,10 @@ protected: /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints /// \param[out] theValue numerical characteristic of constraint (e.g. distance) - /// \param[out] theAttributes list of attributes to be filled (list of moved entities or attributes) - virtual void getAttributes(ParameterWrapperPtr& theValue, std::vector& theAttributes); + /// \param[out] theAttributes list of attributes to be filled + /// (list of moved entities or attributes) + virtual void getAttributes(ParameterWrapperPtr& theValue, + std::vector& theAttributes); private: std::vector myMovedEntities; ///< list of entities that are moved diff --git a/src/SketchSolver/SketchSolver_ConstraintMulti.cpp b/src/SketchSolver/SketchSolver_ConstraintMulti.cpp index 0ee95310f..bd0a82ad3 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMulti.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMulti.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include @@ -35,7 +37,8 @@ void SketchSolver_ConstraintMulti::getEntities(std::list& theE FeaturePtr aFeature; std::list anObjectList = aRefList->list(); std::list::iterator anObjIt = anObjectList.begin(); - if ((myNumberOfCopies + 1) * myNumberOfObjects != aRefList->size()) // execute for the feature is not called yet + // execute for the feature is not called yet + if ((myNumberOfCopies + 1) * myNumberOfObjects != aRefList->size()) myNumberOfCopies = aRefList->size() / myNumberOfObjects - 1; while (anObjIt != anObjectList.end()) { @@ -43,7 +46,8 @@ void SketchSolver_ConstraintMulti::getEntities(std::list& theE if (!aFeature) continue; - if (!myStorage->update(aFeature)) // the entity is not created, so it is a copy in "multi" constraint, force its creation + // the entity is not created, so it is a copy in "multi" constraint, force its creation + if (!myStorage->update(aFeature)) myStorage->update(aFeature, myGroupID, true); theEntities.push_back(myStorage->entity(aFeature)); myFeatures.insert(aFeature); @@ -75,7 +79,8 @@ void SketchSolver_ConstraintMulti::update(bool isForce) AttributeIntegerPtr aNbObjects = myBaseConstraint->integer(nameNbObjects()); if (!anInitialRefList || !aNbObjects) return; // the "Multi" constraint is in queue to remove - bool isUpdated= anInitialRefList->size() != myNumberOfObjects || aNbObjects->value()-1 != myNumberOfCopies; + bool isUpdated = + anInitialRefList->size() != myNumberOfObjects || aNbObjects->value()-1 != myNumberOfCopies; if (!isUpdated) { // additional check that the features and their copies are changed AttributeRefListPtr aRefList = std::dynamic_pointer_cast( diff --git a/src/SketchSolver/SketchSolver_ConstraintMulti.h b/src/SketchSolver/SketchSolver_ConstraintMulti.h index 5dfc0c1a7..820d47821 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMulti.h +++ b/src/SketchSolver/SketchSolver_ConstraintMulti.h @@ -34,7 +34,8 @@ public: void update(bool isForce); /// \brief Tries to remove constraint - /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence) + /// \return \c false, if current constraint contains another SketchPlugin + /// constraints (like for multiple coincidence) virtual bool remove(); /// \brief Check the feature is a source or a copy of Multi-constraint @@ -80,7 +81,8 @@ protected: bool myAdjusted; ///< the constraint is already adjusted (to not do it several times) - std::set myFeatures; ///< list of features and their copies to find whether some of them are disappeared + /// list of features and their copies to find whether some of them are disappeared + std::set myFeatures; }; #endif diff --git a/src/SketchSolver/SketchSolver_ConstraintMultiRotation.cpp b/src/SketchSolver/SketchSolver_ConstraintMultiRotation.cpp index bd53679d9..524b29a14 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMultiRotation.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMultiRotation.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include @@ -55,7 +57,8 @@ void SketchSolver_ConstraintMultiRotation::process() for (; anEntIt != aBaseEntities.end(); ++anEntIt) { std::list aNewConstraints = aBuilder->createConstraint(myBaseConstraint, myGroupID, mySketchID, myType, - myAngle, isFullValue, aRotationCenter, EntityWrapperPtr(), std::list(1, *anEntIt)); + myAngle, isFullValue, aRotationCenter, EntityWrapperPtr(), + std::list(1, *anEntIt)); aRotConstraints.insert(aRotConstraints.end(), aNewConstraints.begin(), aNewConstraints.end()); } myStorage->addConstraint(myBaseConstraint, aRotConstraints); diff --git a/src/SketchSolver/SketchSolver_ConstraintMultiTranslation.cpp b/src/SketchSolver/SketchSolver_ConstraintMultiTranslation.cpp index 2bea9a217..32f55074a 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMultiTranslation.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMultiTranslation.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include @@ -60,7 +62,8 @@ void SketchSolver_ConstraintMultiTranslation::process() std::list aNewConstraints = aBuilder->createConstraint(myBaseConstraint, myGroupID, mySketchID, myType, 0.0, aFullValue, aStartPoint, aEndPoint, std::list(1, *anEntIt)); - aTransConstraints.insert(aTransConstraints.end(), aNewConstraints.begin(), aNewConstraints.end()); + aTransConstraints.insert(aTransConstraints.end(), + aNewConstraints.begin(), aNewConstraints.end()); } myStorage->addConstraint(myBaseConstraint, aTransConstraints); @@ -111,7 +114,8 @@ void SketchSolver_ConstraintMultiTranslation::updateLocal() aSLast = aConstraintEntities.end(); EntityWrapperPtr aStartEntity = *aSIt++; if (aStartPointChanged) { - AttributePtr aStartPointAttr = aData->attribute(SketchPlugin_MultiTranslation::START_POINT_ID()); + AttributePtr aStartPointAttr = + aData->attribute(SketchPlugin_MultiTranslation::START_POINT_ID()); myStorage->update(aStartPointAttr); aStartEntity = myStorage->entity(aStartPointAttr); } @@ -119,7 +123,8 @@ void SketchSolver_ConstraintMultiTranslation::updateLocal() EntityWrapperPtr anEndEntity = *aSIt++; if (anEndPointChanged) { - AttributePtr anEndPointAttr = aData->attribute(SketchPlugin_MultiTranslation::END_POINT_ID()); + AttributePtr anEndPointAttr = + aData->attribute(SketchPlugin_MultiTranslation::END_POINT_ID()); myStorage->update(anEndPointAttr); anEndEntity = myStorage->entity(anEndPointAttr); } diff --git a/src/SketchSolver/SketchSolver_ConstraintTangent.cpp b/src/SketchSolver/SketchSolver_ConstraintTangent.cpp index 29744ea32..1a257a530 100644 --- a/src/SketchSolver/SketchSolver_ConstraintTangent.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintTangent.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include diff --git a/src/SketchSolver/SketchSolver_Error.h b/src/SketchSolver/SketchSolver_Error.h index 2e1431454..148e5de06 100644 --- a/src/SketchSolver/SketchSolver_Error.h +++ b/src/SketchSolver/SketchSolver_Error.h @@ -20,13 +20,15 @@ class SketchSolver_Error /// The value parameter for the constraint inline static const std::string& CONSTRAINTS() { - static const std::string MY_ERROR_VALUE("The constraint is conflicting with others. To fix this, you can either undo your operation or remove a conflicting constraint."); + static const std::string MY_ERROR_VALUE("The constraint is conflicting with others. \ + To fix this, you can either undo your operation or remove a conflicting constraint."); return MY_ERROR_VALUE; } /// Constraints should use objects instead of features as attributes inline static const std::string& NEED_OBJECT_NOT_FEATURE() { - static const std::string MY_ERROR_VALUE("Constraint should be based on object instead of feature"); + static const std::string + MY_ERROR_VALUE("Constraint should be based on object instead of feature"); return MY_ERROR_VALUE; } /// The entities need to have shared point, but they have not @@ -65,10 +67,12 @@ class SketchSolver_Error static const std::string MY_ERROR_VALUE("Entity already fixed"); return MY_ERROR_VALUE; } - /// Tangency constraint has been built with wrong attributes (for example, line and arc have two coincident points) + /// Tangency constraint has been built with wrong attributes + /// (for example, line and arc have two coincident points) inline static const std::string& TANGENCY_FAILED() { - static const std::string MY_ERROR_VALUE("Unable to create tangency constraint on given attributes"); + static const std::string + MY_ERROR_VALUE("Unable to create tangency constraint on given attributes"); return MY_ERROR_VALUE; } /// Crash in SolveSpace diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 5a1ff49fb..67e0d6ccc 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -378,7 +378,8 @@ bool SketchSolver_Group::resolveConstraints() } } catch (...) { // Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this); - getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::SOLVESPACE_CRASH()); + getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR()) + ->setValue(SketchSolver_Error::SOLVESPACE_CRASH()); if (myPrevResult == STATUS_OK || myPrevResult == STATUS_UNKNOWN) { // the error message should be changed before sending the message sendMessage(EVENT_SOLVER_FAILED); @@ -387,11 +388,13 @@ bool SketchSolver_Group::resolveConstraints() mySketchSolver->undo(); return false; } - if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET) { // solution succeeded, store results into correspondent attributes + // solution succeeded, store results into correspondent attributes + if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET) { myStorage->setNeedToResolve(false); myStorage->refresh(); updateMultiConstraints(myConstraints); - if (myStorage->isNeedToResolve()) // multi-constraints updated some parameters, need to store them + // multi-constraints updated some parameters, need to store them + if (myStorage->isNeedToResolve()) resolveConstraints(); if (myPrevResult != STATUS_OK || myPrevResult == STATUS_UNKNOWN) { @@ -406,8 +409,11 @@ bool SketchSolver_Group::resolveConstraints() mySketchSolver->undo(); if (!myConstraints.empty()) { // the error message should be changed before sending the message - getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::CONSTRAINTS()); - if (myPrevResult != aResult || myPrevResult == STATUS_UNKNOWN || myPrevResult == STATUS_FAILED) { + getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR()) + ->setValue(SketchSolver_Error::CONSTRAINTS()); + if (myPrevResult != aResult || + myPrevResult == STATUS_UNKNOWN || + myPrevResult == STATUS_FAILED) { // Obtain list of conflicting constraints std::set aConflicting = myStorage->getConflictingConstraints(mySketchSolver); @@ -482,7 +488,8 @@ void SketchSolver_Group::splitGroup(std::list& theCuts) { // New storage will be used in trimmed way to store the list of constraint interacted together. StoragePtr aNewStorage = SketchSolver_Manager::instance()->builder()->createStorage(getId()); - std::list aDummyVec; // empty vector to avoid creation of solver's constraints + // empty vector to avoid creation of solver's constraints + std::list aDummyVec; // Obtain constraints, which should be separated std::list anUnusedConstraints; @@ -494,7 +501,8 @@ void SketchSolver_Group::splitGroup(std::list& theCuts) anUnusedConstraints.push_back(aCIter->first); } - // Check the unused constraints once again, because they may become interacted with new storage since adding constraints + // Check the unused constraints once again, + // because they may become interacted with new storage since adding constraints std::list::iterator aUnuseIt = anUnusedConstraints.begin(); while (aUnuseIt != anUnusedConstraints.end()) { if (aNewStorage->isInteract(FeaturePtr(*aUnuseIt))) { @@ -675,7 +683,8 @@ static double featureToVal(FeaturePtr theFeature) AttributeRefAttrPtr anAttrB = std::dynamic_pointer_cast( aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B())); if (anAttrA && anAttrB && (anAttrA->isObject() || anAttrB->isObject())) - return 2.0; // point-on-line and point-on-circle should go before points coincidence constraint + // point-on-line and point-on-circle should go before points coincidence constraint + return 2.0; return 2.5; } if (anID == SketchPlugin_ConstraintDistance::ID() || @@ -709,7 +718,8 @@ static bool isLess(FeaturePtr theFeature1, FeaturePtr theFeature2) return featureToVal(theFeature1) < featureToVal(theFeature2); } -std::list SketchSolver_Group::selectApplicableFeatures(const std::set& theObjects) +std::list SketchSolver_Group:: + selectApplicableFeatures(const std::set& theObjects) { std::list aResult; std::list::iterator aResIt; @@ -717,7 +727,8 @@ std::list SketchSolver_Group::selectApplicableFeatures(const std::se std::set::const_iterator anObjIter = theObjects.begin(); for (; anObjIter != theObjects.end(); ++anObjIter) { // Operate sketch itself and SketchPlugin features only. - // Also, the Fillet and Split need to be skipped, because there are several separated constraints composing it. + // Also, the Fillet and Split need to be skipped, + // because there are several separated constraints composing it. FeaturePtr aFeature = std::dynamic_pointer_cast(*anObjIter); if (!aFeature) continue; diff --git a/src/SketchSolver/SketchSolver_Group.h b/src/SketchSolver/SketchSolver_Group.h index ea22b03d0..9312c6a5a 100644 --- a/src/SketchSolver/SketchSolver_Group.h +++ b/src/SketchSolver/SketchSolver_Group.h @@ -104,7 +104,8 @@ class SketchSolver_Group } /** \brief Update parameters of workplane. Should be called when Update event is coming. - * \return \c true if workplane updated successfully, \c false if workplane parameters are not consistent + * \return \c true if workplane updated successfully, + * \c false if workplane parameters are not consistent */ bool updateWorkplane(); @@ -118,7 +119,8 @@ class SketchSolver_Group */ void mergeGroups(const SketchSolver_Group& theGroup); - /** \brief Cut from the group several subgroups, which are not connected to the current one by any constraint + /** \brief Cut from the group several subgroups, which are not connected to + * the current one by any constraint * \param[out] theCuts enlarge this list by newly created groups */ void splitGroup(std::list& theCuts); @@ -166,13 +168,16 @@ private: CompositeFeaturePtr mySketch; ///< Sketch is equivalent to workplane ConstraintConstraintMap myConstraints; ///< List of constraints std::set myTempConstraints; ///< List of temporary constraints - std::map myParametricConstraints; ///< List of parametric constraints + + /// List of parametric constraints + std::map myParametricConstraints; StoragePtr myStorage; ///< Container for the set of SolveSpace constraints and their entities SolverPtr mySketchSolver; ///< Solver for set of equations obtained by constraints - SketchSolver_SolveStatus myPrevResult; ///< Result of previous solution of the set of constraints + /// Result of previous solution of the set of constraints + SketchSolver_SolveStatus myPrevResult; std::set myConflictingConstraints; ///< List of conflicting constraints }; diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index 2449d61c0..52499a876 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -116,7 +116,8 @@ void SketchSolver_Manager::processEvent( const std::shared_ptr& theMessage) { static const Events_ID aSketchPreparedEvent = Events_Loop::eventByName(EVENT_SKETCH_PREPARED); - // sketch is prepared for resolve: all the needed events are collected and must be processed by the solver + // sketch is prepared for resolve: all the needed events + // are collected and must be processed by the solver if (theMessage->eventID() == aSketchPreparedEvent) { flushGrouped(anUpdateEvent); return; @@ -153,12 +154,14 @@ void SketchSolver_Manager::processEvent( hasProperFeature = true; } } - if (!hasProperFeature) // in this iteration it will compute nothing, so, no problem with recursion - // it is important that solver flushes signal updated after processing move signal as there is - // optimization that relies on this update, might be found by key "optimization" + if (!hasProperFeature) + // in this iteration it will compute nothing, so, no problem with recursion + // it is important that solver flushes signal updated after processing move signal as there + // is optimization that relies on this update, might be found by key "optimization" myIsComputed = false; } else { - std::list aSketchFeatures = SketchSolver_Group::selectApplicableFeatures(aFeatures); + std::list aSketchFeatures = + SketchSolver_Group::selectApplicableFeatures(aFeatures); std::list::iterator aFeatIter = aSketchFeatures.begin(); for (; aFeatIter != aSketchFeatures.end(); ++aFeatIter) { if ((*aFeatIter)->getKind() == SketchPlugin_Sketch::ID()) { @@ -195,7 +198,8 @@ void SketchSolver_Manager::processEvent( std::dynamic_pointer_cast(theMessage); const std::set& aFeatureGroups = aDeleteMsg->groups(); - // Find SketchPlugin_Sketch::ID() in groups. The constraint groups should be updated when an object removed from Sketch + // Find SketchPlugin_Sketch::ID() in groups. + // The constraint groups should be updated when an object removed from Sketch std::set::const_iterator aFGrIter; for (aFGrIter = aFeatureGroups.begin(); aFGrIter != aFeatureGroups.end(); aFGrIter++) if (aFGrIter->compare(ModelAPI_ResultConstruction::group()) == 0 || @@ -214,7 +218,8 @@ void SketchSolver_Manager::processEvent( myGroups.erase(aRemoveIt); continue; } - if (!(*aGroupIter)->isConsistent()) { // some constraints were removed, try to split the group + if (!(*aGroupIter)->isConsistent()) { + // some constraints were removed, try to split the group (*aGroupIter)->splitGroup(aSeparatedGroups); if (!(*aGroupIter)->getWorkplane()->string( SketchPlugin_Sketch::SOLVER_ERROR())->value().empty() || @@ -239,7 +244,8 @@ void SketchSolver_Manager::processEvent( degreesOfFreedom(); } -void SketchSolver_Manager::checkConflictingConstraints(const std::shared_ptr& theMessage) +void SketchSolver_Manager:: + checkConflictingConstraints(const std::shared_ptr& theMessage) { if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_SOLVER_REPAIRED)) { std::shared_ptr aMessage = @@ -340,7 +346,8 @@ bool SketchSolver_Manager::changeFeature(std::shared_ptr t return (*aGroupIter)->updateFeature(theFeature); return (*aGroupIter)->changeConstraint(aConstraint); } - } else if (aGroups.size() > 1) { // Several groups applicable for this feature => need to merge them + } else if (aGroups.size() > 1) { + // Several groups applicable for this feature => need to merge them std::set::const_iterator aGroupsIter = aGroups.begin(); // Search first group @@ -490,7 +497,8 @@ std::shared_ptr SketchSolver_Manager bool SketchSolver_Manager::resolveConstraints(const std::list& theGroups) { bool needToUpdate = false; - const std::list& aGroupsToResolve = theGroups.empty() ? myGroups : theGroups; + const std::list& aGroupsToResolve = theGroups.empty() ? + myGroups : theGroups; std::list::const_iterator aGroupIter = aGroupsToResolve.begin(); for (; aGroupIter != aGroupsToResolve.end(); aGroupIter++) if ((*aGroupIter)->resolveConstraints()) @@ -500,7 +508,8 @@ bool SketchSolver_Manager::resolveConstraints(const std::list >& thePoints) +static void collectPointsAndCopies(FeaturePtr theConstraint, + std::list >& thePoints) { typedef std::list strlist; static strlist aPointAttributes(1, SketchPlugin_Point::COORD_ID()); @@ -625,7 +634,8 @@ void SketchSolver_Manager::degreesOfFreedom() if (isSketchValid) { std::shared_ptr aNormal = - std::dynamic_pointer_cast(aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); + std::dynamic_pointer_cast( + aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); isSketchValid = aNormal && aNormal->isInitialized(); } @@ -711,7 +721,8 @@ void SketchSolver_Manager::degreesOfFreedom() } else { aDoF -= 1; if (aCoincPoint[0] && aCoincLine) { - // if the point is already coincident to a line (by middle point constraint), do not decrease DoF + // if the point is already coincident to a line + // (by middle point constraint), do not decrease DoF std::map >::iterator aPtFound = aPointOnLine.find(aCoincPoint[0]); if (aPtFound != aPointOnLine.end() && @@ -765,7 +776,8 @@ void SketchSolver_Manager::degreesOfFreedom() if (isExternal(anAttr)) continue; // feature is already fixed since it is external aDoF -= aDoFDelta[anAttr->getKind()]; - std::list aPtAttrs = anAttr->data()->attributes(GeomDataAPI_Point2D::typeId()); + std::list aPtAttrs = + anAttr->data()->attributes(GeomDataAPI_Point2D::typeId()); aPoints.insert(aPtAttrs.begin(), aPtAttrs.end()); } } @@ -811,9 +823,11 @@ void SketchSolver_Manager::degreesOfFreedom() anAttrName = SketchPlugin_Constraint::ENTITY_B(); else { if (aFeature->getKind() == SketchPlugin_MultiRotation::ID()) - aNbCopies = aFeature->integer(SketchPlugin_MultiRotation::NUMBER_OF_OBJECTS_ID())->value() - 1; + aNbCopies = + aFeature->integer(SketchPlugin_MultiRotation::NUMBER_OF_OBJECTS_ID())->value() - 1; else if (aFeature->getKind() == SketchPlugin_MultiTranslation::ID()) - aNbCopies = aFeature->integer(SketchPlugin_MultiTranslation::NUMBER_OF_OBJECTS_ID())->value() - 1; + aNbCopies = + aFeature->integer(SketchPlugin_MultiTranslation::NUMBER_OF_OBJECTS_ID())->value() - 1; anAttrName = SketchPlugin_Constraint::ENTITY_A(); } diff --git a/src/SketchSolver/SketchSolver_Manager.h b/src/SketchSolver/SketchSolver_Manager.h index 51581b987..5eab8bc9e 100644 --- a/src/SketchSolver/SketchSolver_Manager.h +++ b/src/SketchSolver/SketchSolver_Manager.h @@ -91,9 +91,11 @@ protected: /** \brief Goes through the list of groups and solve the constraints * \param[in] theGroups list of groups to be resolved (if empty list, all groups are resolved) - * \return \c true, if groups are resolved, and features should be updated (send the Update event) + * \return \c true, if groups are resolved, and features should be updated + * (send the Update event) */ - bool resolveConstraints(const std::list& theGroups = std::list()); + bool resolveConstraints(const std::list& theGroups = + std::list()); private: /** \brief Searches list of groups which interact with specified feature diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index c85b10a4a..5af9d5043 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -138,7 +138,8 @@ void SketchSolver_Storage::addEntity(FeaturePtr theFeature, void SketchSolver_Storage::addEntity(AttributePtr theAttribute, EntityWrapperPtr theSolverEntity) { - std::map::const_iterator aFound = myAttributeMap.find(theAttribute); + std::map::const_iterator aFound = + myAttributeMap.find(theAttribute); if (aFound == myAttributeMap.end() || !aFound->second || (theSolverEntity && !aFound->second->isEqual(theSolverEntity))) setNeedToResolve(true); // the entity is new or modified @@ -186,8 +187,9 @@ bool SketchSolver_Storage::update(FeaturePtr theFeature, const GroupID& theGroup std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(theFeature); bool isCopy = isCopyInMulti(aSketchFeature, myConstraintMap); + // the feature is a copy in "Multi" constraint and does not used in other constraints if (!theForce && isCopy && myFeatureMap.find(theFeature) == myFeatureMap.end()) - return false; // the feature is a copy in "Multi" constraint and does not used in other constraints + return false; std::list aSubs; // Reserve the feature in the map of features (do not want to add several copies of it) @@ -271,7 +273,8 @@ bool SketchSolver_Storage::update(AttributePtr theAttribute, const GroupID& theG // Check attribute of external features std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(anAttribute->owner()); - if (aSketchFeature && (aSketchFeature->isExternal() || isCopyInMulti(aSketchFeature, myConstraintMap))) + if (aSketchFeature && (aSketchFeature->isExternal() || + isCopyInMulti(aSketchFeature, myConstraintMap))) aGroup = GID_OUTOFGROUP; aRelated = aBuilder->createAttribute(anAttribute, aGroup); if (!aRelated) @@ -655,7 +658,8 @@ bool SketchSolver_Storage::removeCoincidence(ConstraintWrapperPtr theConstraint) return true; } -void SketchSolver_Storage::replaceEntities(const std::map& theChange) +void SketchSolver_Storage::replaceEntities(const std::map& theChange) { std::set anUpdFeatures; std::map::const_iterator aSubIt; @@ -696,7 +700,8 @@ bool SketchSolver_Storage::remove(ConstraintWrapperPtr theConstraint) if (aBaseFeature) isFullyRemoved = SketchSolver_Storage::removeEntity(aBaseFeature) && isFullyRemoved; else - isFullyRemoved = SketchSolver_Storage::removeEntity((*anIt)->baseAttribute()) && isFullyRemoved; + isFullyRemoved = + SketchSolver_Storage::removeEntity((*anIt)->baseAttribute()) && isFullyRemoved; } return isFullyRemoved; } @@ -812,7 +817,8 @@ bool SketchSolver_Storage::isFixed(EntityWrapperPtr theEntity) const return true; } - std::map >::const_iterator aCIt = myConstraintMap.begin(); + std::map >::const_iterator aCIt = + myConstraintMap.begin(); std::list::const_iterator aCWIt; for (; aCIt != myConstraintMap.end(); ++aCIt) { if (aCIt->second.empty()) @@ -982,7 +988,8 @@ void resultToFeatureOrAttribute(const ObjectPtr& theResult, // if the feature has several results, we choose which one is referred const std::list& aResults = aFeature->results(); if (aResults.size() > 1 && theResult != aFeature->lastResult()) { - // actually, the attribute refers to center of arc or circle, but not the edge, get correct attributes + // actually, the attribute refers to center of arc or circle, + // but not the edge, get correct attributes std::string anAttrName; if (aFeature->getKind() == SketchPlugin_Arc::ID()) anAttrName = SketchPlugin_Arc::CENTER_ID(); diff --git a/src/SketchSolver/SketchSolver_Storage.h b/src/SketchSolver/SketchSolver_Storage.h index c8b1e7688..6a1b1b2e8 100644 --- a/src/SketchSolver/SketchSolver_Storage.h +++ b/src/SketchSolver/SketchSolver_Storage.h @@ -62,13 +62,16 @@ public: /// \param theGroup [in] id of the group where the feature should be placed /// \param theForce [in] forced feature creation /// \return \c true if the feature has been created or updated - SKETCHSOLVER_EXPORT bool update(FeaturePtr theFeature, const GroupID& theGroup = GID_UNKNOWN, bool theForce = false); + SKETCHSOLVER_EXPORT bool update(FeaturePtr theFeature, + const GroupID& theGroup = GID_UNKNOWN, bool theForce = false); + /// \brief Convert attribute to the form applicable for specific solver and map it /// \param theAttribute [in] attribute to convert /// \param theGroup [in] id of the group where the feature should be placed /// \param theForce [in] forced feature creation /// \return \c true if the attribute has been created or updated - SKETCHSOLVER_EXPORT bool update(AttributePtr theAttribute, const GroupID& theGroup = GID_UNKNOWN, bool theForce = false); + SKETCHSOLVER_EXPORT bool update(AttributePtr theAttribute, + const GroupID& theGroup = GID_UNKNOWN, bool theForce = false); /// \brief Returns constraint related to corresponding constraint SKETCHSOLVER_EXPORT @@ -166,7 +169,8 @@ protected: void addEntity(FeaturePtr theFeature, EntityWrapperPtr theSolverEntity); - /// \brief Change mapping attribute of a feature and the entity applicable for corresponding solver. + /// \brief Change mapping attribute of a feature and the entity + /// applicable for corresponding solver. /// \param theAttribute [in] original attribute /// \param theSolverEntity [in] solver's entity, created outside SKETCHSOLVER_EXPORT @@ -230,7 +234,8 @@ protected: /// map attribute to solver's entity std::map myAttributeMap; - CoincidentPointsMap myCoincidentPoints; ///< lists of coincident points (first is a master point, second is a set of slaves) + /// lists of coincident points (first is a master point, second is a set of slaves) + CoincidentPointsMap myCoincidentPoints; // to be able to update entities from constraints friend class SketchSolver_ConstraintDistance; diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp index b3fc9272e..3d0e38842 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp @@ -141,8 +141,9 @@ std::list SolveSpaceSolver_Builder::createConstraint( if (!anOriginal[i]) continue; aSlvsEntities[i] = (Slvs_hEntity)anOriginal[i]->id(); + // entity is not added into a storage, constraint can not be created if (aSlvsEntities[i] == SLVS_E_UNKNOWN) - return std::list(); // entity is not added into a storage, constraint can not be created + return std::list(); aConstrAttrList.push_back(anOriginal[i]); } @@ -256,7 +257,8 @@ std::list SolveSpaceSolver_Builder::createMirror( aResult.insert(aResult.end(), aMrrList.begin(), aMrrList.end()); } else if (theEntity1->type() == ENTITY_ARC) { - // Do not allow mirrored arc recalculate its position until coordinated of all points recalculated + // Do not allow mirrored arc recalculate its position until + // coordinated of all points recalculated FeaturePtr aMirrArc = theEntity2->baseFeature(); aMirrArc->data()->blockSendAttributeUpdated(true); @@ -276,7 +278,8 @@ std::list SolveSpaceSolver_Builder::createMirror( anIt1 = aBaseArcPoints.begin(); anIt2 = aMirrorArcPoints.begin(); for (; anIt1 != aBaseArcPoints.end(); ++anIt1, ++anIt2) { - aMrrList = createMirror(theConstraint, theGroupID, theSketchID, *anIt1, *anIt2, theMirrorLine); + aMrrList = + createMirror(theConstraint, theGroupID, theSketchID, *anIt1, *anIt2, theMirrorLine); aResult.insert(aResult.end(), aMrrList.begin(), aMrrList.end()); } // Restore event sending @@ -337,7 +340,8 @@ EntityWrapperPtr SolveSpaceSolver_Builder::createFeature( AttributePtr aPoint = theFeature->attribute(SketchPlugin_Point::COORD_ID()); if (!aPoint->isInitialized()) return aDummy; - EntityWrapperPtr aSub = theAttributes.empty() ? createAttribute(aPoint, theGroupID, theSketchID) : + EntityWrapperPtr aSub = theAttributes.empty() ? + createAttribute(aPoint, theGroupID, theSketchID) : theAttributes.front(); if (!aSub) return aDummy; @@ -388,8 +392,10 @@ EntityWrapperPtr SolveSpaceSolver_Builder::createAttribute( std::shared_ptr aPoint2D = std::dynamic_pointer_cast(theAttribute); if (aPoint2D) { - aParameters.push_back(createParameter(theGroupID, aPoint2D->x(), !aPoint2D->textX().empty())); - aParameters.push_back(createParameter(theGroupID, aPoint2D->y(), !aPoint2D->textY().empty())); + aParameters.push_back(createParameter(theGroupID, aPoint2D->x(), + !aPoint2D->textX().empty())); + aParameters.push_back(createParameter(theGroupID, aPoint2D->y(), + !aPoint2D->textY().empty())); // Create entity (parameters are not filled) anEntity = Slvs_MakePoint2d(SLVS_E_UNKNOWN, (Slvs_hGroup)theGroupID, (Slvs_hEntity)theSketchID, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN); @@ -398,7 +404,8 @@ EntityWrapperPtr SolveSpaceSolver_Builder::createAttribute( AttributeDoublePtr aScalar = std::dynamic_pointer_cast(theAttribute); if (aScalar) { - aParameters.push_back(createParameter(theGroupID, aScalar->value(), !aScalar->text().empty())); + aParameters.push_back(createParameter(theGroupID, aScalar->value(), + !aScalar->text().empty())); // Create entity (parameter is not filled) anEntity = Slvs_MakeDistance(SLVS_E_UNKNOWN, (Slvs_hGroup)theGroupID, (Slvs_hEntity)theSketchID, SLVS_E_UNKNOWN); @@ -693,7 +700,8 @@ void adjustAngle(ConstraintWrapperPtr theConstraint) aConstraint->baseConstraint()->boolean( SketchPlugin_ConstraintAngle::ANGLE_REVERSED_SECOND_LINE_ID())->value() }; - std::shared_ptr anAngle(new GeomAPI_Angle2d(aLine[0], isReversed[0], aLine[1], isReversed[1])); + std::shared_ptr + anAngle(new GeomAPI_Angle2d(aLine[0], isReversed[0], aLine[1], isReversed[1])); std::shared_ptr aCenter = anAngle->center(); Slvs_Constraint& aSlvsConstraint = aConstraint->changeConstraint(); @@ -738,9 +746,11 @@ void makeMirrorPoints(EntityWrapperPtr theOriginal, (*aMIt)->setValue(aCoord[i]); // update corresponding attribute - AttributePtr anAttr = std::dynamic_pointer_cast(theMirrored)->baseAttribute(); + AttributePtr anAttr = + std::dynamic_pointer_cast(theMirrored)->baseAttribute(); if (anAttr) { - std::shared_ptr aMirroredPnt = std::dynamic_pointer_cast(anAttr); + std::shared_ptr aMirroredPnt = + std::dynamic_pointer_cast(anAttr); aMirroredPnt->setValue(aCoord[0], aCoord[1]); } } diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.h b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.h index d71a5662d..def1ae81a 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.h +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.h @@ -38,7 +38,8 @@ public: /// \param theGroupID [in] group the constraint belongs to /// \param theSketchID [in] sketch the constraint belongs to /// \param theType [in] type of constraint - /// \param theValue [in] numeric characteristic of constraint (e.g. distance or radius) if applicable + /// \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 @@ -62,8 +63,10 @@ public: /// \param theGroupID [in] group the constraint belongs to /// \param theSketchID [in] sketch the constraint belongs to /// \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 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 diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.h b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.h index b80421707..b1734a71e 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.h +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.h @@ -9,7 +9,8 @@ #include -// Need to be defined before including SolveSpace to avoid additional dependences on Windows platform +// Need to be defined before including SolveSpace to avoid additional +// dependences on Windows platform #if defined(WIN32) && !defined(HAVE_C99_INTEGER_TYPES) typedef unsigned int UINT32; #else diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index 805e458dd..6cae2a9b7 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -36,7 +36,8 @@ static bool IsNotEqual(const Slvs_Param& theParam1, const Slvs_Param& theParam2) /// \brief Compare two entities to be different static bool IsNotEqual(const Slvs_Entity& theEntity1, const Slvs_Entity& theEntity2); /// \brief Compare two constraints to be different -static bool IsNotEqual(const Slvs_Constraint& theConstraint1, const Slvs_Constraint& theConstraint2); +static bool IsNotEqual(const Slvs_Constraint& theConstraint1, + const Slvs_Constraint& theConstraint2); SolveSpaceSolver_Storage::SolveSpaceSolver_Storage(const GroupID& theGroup) @@ -210,7 +211,8 @@ bool SolveSpaceSolver_Storage::update(ParameterWrapperPtr theParameter) return false; Slvs_Param aParamToUpd = aParameter->parameter(); if (aParamToUpd.group == SLVS_G_UNKNOWN) - aParamToUpd.group = aParameter->isParametric() ? (Slvs_hGroup)GID_OUTOFGROUP : (Slvs_hGroup)myGroupID; + aParamToUpd.group = aParameter->isParametric() ? (Slvs_hGroup)GID_OUTOFGROUP : + (Slvs_hGroup)myGroupID; Slvs_hParam anID = updateParameter(aParamToUpd); if (aParam.h == SLVS_E_UNKNOWN) // new parameter aParameter->changeParameter() = getParameter(anID); @@ -557,8 +559,10 @@ EntityWrapperPtr SolveSpaceSolver_Storage::calculateMiddlePoint( theX = anArcPoint[0][0] + anArcPoint[2][0]; theY = anArcPoint[0][1] + anArcPoint[2][1]; } else { - std::shared_ptr aStartDir(new GeomAPI_Dir2d(anArcPoint[1][0], anArcPoint[1][1])); - std::shared_ptr aEndDir(new GeomAPI_Dir2d(anArcPoint[2][0], anArcPoint[2][1])); + std::shared_ptr + aStartDir(new GeomAPI_Dir2d(anArcPoint[1][0], anArcPoint[1][1])); + std::shared_ptr + aEndDir(new GeomAPI_Dir2d(anArcPoint[2][0], anArcPoint[2][1])); double anAngle = aStartDir->angle(aEndDir); if (anAngle < 0) anAngle += 2.0 * PI; @@ -821,7 +825,8 @@ Slvs_hConstraint SolveSpaceSolver_Storage::updateConstraint(const Slvs_Constrain Slvs_Entity aNewLine2 = Slvs_MakeLineSegment(SLVS_E_UNKNOWN, (Slvs_hGroup)myGroupID, myWorkplaneID, aLine.point[1], aConstraint.ptA); aNewLine2.h = addEntity(aNewLine2); - aConstraint = Slvs_MakeConstraint(SLVS_E_UNKNOWN, (Slvs_hGroup)myGroupID, SLVS_C_EQUAL_LENGTH_LINES, + aConstraint = Slvs_MakeConstraint(SLVS_E_UNKNOWN, (Slvs_hGroup)myGroupID, + SLVS_C_EQUAL_LENGTH_LINES, myWorkplaneID, 0.0, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN, aNewLine1.h, aNewLine2.h); } } @@ -856,7 +861,8 @@ bool SolveSpaceSolver_Storage::removeConstraint(const Slvs_hConstraint& theConst return true; } -const Slvs_Constraint& SolveSpaceSolver_Storage::getConstraint(const Slvs_hConstraint& theConstraintID) const +const Slvs_Constraint& SolveSpaceSolver_Storage:: + getConstraint(const Slvs_hConstraint& theConstraintID) const { int aPos = Search(theConstraintID, myConstraints); if (aPos >= 0 && aPos < (int)myConstraints.size()) diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.h b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.h index 24cb9f323..de15a1cd5 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.h +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.h @@ -19,7 +19,8 @@ typedef std::list< std::set > SameConstraintMa /** \class SolveSpaceSolver_Storage * \ingroup Plugins - * \brief Contains all necessary data in SolveSpace format to solve a single group of constraints + * \brief Contains all necessary data in SolveSpace format to solve a single + * group of constraints */ class SolveSpaceSolver_Storage : public SketchSolver_Storage { @@ -158,7 +159,8 @@ private: /// /// These constraints may be different and become the same after the substitution /// of point coincidence. - void addSameConstraints(ConstraintWrapperPtr theConstraint1, ConstraintWrapperPtr theConstraint2); + void addSameConstraints(ConstraintWrapperPtr theConstraint1, + ConstraintWrapperPtr theConstraint2); /// \brief Search constraint equal to the given in terms of SolveSpace notation bool findSameConstraint(ConstraintWrapperPtr theConstraint); @@ -166,12 +168,21 @@ private: private: Slvs_hEntity myWorkplaneID; ///< identifier of workplane - Slvs_hParam myParamMaxID; ///< current parameter index (may differs with the number of parameters) - std::vector myParameters; ///< list of parameters used in the current group of constraints (sorted by the identifier) + /// current parameter index (may differs with the number of parameters) + Slvs_hParam myParamMaxID; + + /// list of parameters used in the current group of constraints (sorted by the identifier) + std::vector myParameters; Slvs_hEntity myEntityMaxID; ///< current entity index (may differs with the number of entities) - std::vector myEntities; ///< list of entities used in the current group of constraints (sorted by the identifier) - Slvs_hConstraint myConstrMaxID; ///< current constraint index (may differs with the number of constraints) - std::vector myConstraints; ///< list of constraints used in the current group (sorted by the identifier) + + /// list of entities used in the current group of constraints (sorted by the identifier) + std::vector myEntities; + + /// current constraint index (may differs with the number of constraints) + Slvs_hConstraint myConstrMaxID; + + /// list of constraints used in the current group (sorted by the identifier) + std::vector myConstraints; bool myDuplicatedConstraint; ///< shows the storage has same constraint twice