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);
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);
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<PlaneGCSSolver_ScalarWrapper>(
new PlaneGCSSolver_ScalarWrapper(theDoubleAttr, aParam));
}
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;
}
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;
}
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;
}
}
case ENTITY_ARC:
case ENTITY_CIRCLE: {
- std::shared_ptr<GCS::Circle> aCirc = std::dynamic_pointer_cast<GCS::Circle>(theEntity->entity());
+ std::shared_ptr<GCS::Circle> aCirc =
+ std::dynamic_pointer_cast<GCS::Circle>(theEntity->entity());
aNewConstr = GCSConstraintPtr(
new GCS::ConstraintP2PDistance(*(thePoint->point()), aCirc->center, aCirc->rad));
break;
aConstrList.push_back(GCSConstraintPtr(new GCS::ConstraintPointOnLine(*aPoint, *aLine)));
double aDist = lineLength(*aLine);
std::shared_ptr<PlaneGCSSolver_ParameterWrapper> aDistance =
- std::dynamic_pointer_cast<PlaneGCSSolver_ParameterWrapper>(createParameter(theGroupID, aDist * 0.5));
+ std::dynamic_pointer_cast<PlaneGCSSolver_ParameterWrapper>(
+ createParameter(theGroupID, aDist * 0.5));
aConstrList.push_back(GCSConstraintPtr(
new GCS::ConstraintP2PDistance(*aPoint, aLine->p1, aDistance->parameter())));
aConstrList.push_back(GCSConstraintPtr(
std::shared_ptr<PlaneGCSSolver_ParameterWrapper> theValue,
std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity)
{
- std::shared_ptr<GCS::Circle> aCircle = std::dynamic_pointer_cast<GCS::Circle>(theEntity->entity());
+ std::shared_ptr<GCS::Circle> aCircle =
+ std::dynamic_pointer_cast<GCS::Circle>(theEntity->entity());
GCSConstraintPtr aNewConstr(new GCS::ConstraintEqual(aCircle->rad, theValue->parameter()));
std::shared_ptr<PlaneGCSSolver_ConstraintWrapper> aResult(
{
GCSConstraintPtr aNewConstr;
if (theType == CONSTRAINT_TANGENT_ARC_LINE || theType == CONSTRAINT_TANGENT_CIRCLE_LINE) {
- std::shared_ptr<GCS::Circle> aCirc = std::dynamic_pointer_cast<GCS::Circle>(theEntity1->entity());
- std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(theEntity2->entity());
+ std::shared_ptr<GCS::Circle> aCirc =
+ std::dynamic_pointer_cast<GCS::Circle>(theEntity1->entity());
+ std::shared_ptr<GCS::Line> aLine =
+ std::dynamic_pointer_cast<GCS::Line>(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<GCS::Circle> aCirc1 = std::dynamic_pointer_cast<GCS::Circle>(theEntity1->entity());
- std::shared_ptr<GCS::Circle> aCirc2 = std::dynamic_pointer_cast<GCS::Circle>(theEntity2->entity());
+ std::shared_ptr<GCS::Circle> aCirc1 =
+ std::dynamic_pointer_cast<GCS::Circle>(theEntity1->entity());
+ std::shared_ptr<GCS::Circle> aCirc2 =
+ std::dynamic_pointer_cast<GCS::Circle>(theEntity2->entity());
double aDX = *(aCirc1->center.x) - *(aCirc2->center.x);
double aDY = *(aCirc1->center.y) - *(aCirc2->center.y);
(*aMIt)->setValue(aCoord[i]);
// update corresponding attribute
- AttributePtr anAttr = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theMirrored)->baseAttribute();
+ AttributePtr anAttr =
+ std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theMirrored)->baseAttribute();
if (anAttr) {
- std::shared_ptr<GeomDataAPI_Point2D> aMirroredPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr);
+ std::shared_ptr<GeomDataAPI_Point2D> aMirroredPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr);
aMirroredPnt->setValue(aCoord[0], aCoord[1]);
}
}
/// \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
/// \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
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
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;
}
}
}
- // 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())
typedef std::map<GCS::Constraint*, SketchSolver_ConstraintType> 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<GCS::System> 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
std::list<EntityWrapperPtr>::const_iterator aSubIt = aSubs.begin();
while ((*aSubIt)->type() == ENTITY_POINT) // search scalar entities
++aSubIt;
- double* aStartAngle = std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(*aSubIt++)->scalar();
- double* aEndAngle = std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(*aSubIt++)->scalar();
- double* aRadius = std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(*aSubIt)->scalar();
+ double* aStartAngle =
+ std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(*aSubIt++)->scalar();
+ double* aEndAngle =
+ std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(*aSubIt++)->scalar();
+ double* aRadius = std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(*aSubIt)->scalar();
std::shared_ptr<SketchPlugin_Feature> anArcFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(theArc->baseFeature());
std::list<std::set<double*> >::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())
theX = anArcPoint[0][0] + anArcPoint[2][0];
theY = anArcPoint[0][1] + anArcPoint[2][1];
} else {
- std::shared_ptr<GeomAPI_Dir2d> aStartDir(new GeomAPI_Dir2d(anArcPoint[1][0], anArcPoint[1][1]));
- std::shared_ptr<GeomAPI_Dir2d> aEndDir(new GeomAPI_Dir2d(anArcPoint[2][0], anArcPoint[2][1]));
+ std::shared_ptr<GeomAPI_Dir2d>
+ aStartDir(new GeomAPI_Dir2d(anArcPoint[1][0], anArcPoint[1][1]));
+ std::shared_ptr<GeomAPI_Dir2d>
+ aEndDir(new GeomAPI_Dir2d(anArcPoint[2][0], anArcPoint[2][1]));
double anAngle = aStartDir->angle(aEndDir);
if (anAngle < 0)
anAngle += 2.0 * PI;
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<PlaneGCSSolver_ParameterWrapper>(aParameters.front())->parameter();
- aPnt->y = std::dynamic_pointer_cast<PlaneGCSSolver_ParameterWrapper>(aParameters.back())->parameter();
+ aPnt->x =
+ std::dynamic_pointer_cast<PlaneGCSSolver_ParameterWrapper>(aParameters.front())->parameter();
+ aPnt->y =
+ std::dynamic_pointer_cast<PlaneGCSSolver_ParameterWrapper>(aParameters.back())->parameter();
EntityWrapperPtr aResult(new PlaneGCSSolver_PointWrapper(AttributePtr(), aPnt));
aResult->setGroup(myGroupID);
EntityID myEntityLastID; ///< identifier of last added entity
ConstraintID myConstraintLastID; ///< identifier of last added constraint
+ /// additional constraints for correct processing of the arcs
std::map<EntityWrapperPtr, std::vector<GCSConstraintPtr> >
- myArcConstraintMap; ///< additional constraints for correct processing of the arcs
+ myArcConstraintMap;
- std::list<GCSConstraintPtr> myRemovedConstraints; ///< list of removed constraints to notify solver
+ /// list of removed constraints to notify solver
+ std::list<GCSConstraintPtr> myRemovedConstraints;
};
#endif
ResultConstructionPtr aRC =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(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;
}
ResultConstructionPtr aRC =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*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();
}
}
}
/// \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
/// \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
/// \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<SketchSolver_Builder> BuilderPtr;
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_Constraint.h>
#include <SketchSolver_Group.h>
#include <SketchSolver_Error.h>
if ((*aCIt)->isUsed(theFeature))
return true;
- std::list<AttributePtr> anAttrList = theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
+ std::list<AttributePtr> anAttrList =
+ theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
std::list<AttributePtr>::const_iterator anAttrIt = anAttrList.begin();
for (; anAttrIt != anAttrList.end(); ++ anAttrIt)
if (isUsed(*anAttrIt))
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
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
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<EntityWrapperPtr> myAttributes; ///< attributes of constraint
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintAngle.h>
#include <SketchSolver_Manager.h>
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintCoincidence.h>
#include <SketchSolver_Error.h>
#include <SketchSolver_Manager.h>
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintCollinear.h>
#include <SketchSolver_Manager.h>
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
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintDistance.h>
#include <SketchSolver_Error.h>
#include <SketchSolver_Manager.h>
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
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintEqual.h>
#include <SketchSolver_Error.h>
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintFixed.h>
#include <SketchSolver_Error.h>
#include <SketchSolver_Manager.h>
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:
/// \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<EntityWrapperPtr>& theAttributes);
+ virtual void getAttributes(ParameterWrapperPtr& theValue,
+ std::vector<EntityWrapperPtr>& theAttributes);
/// \brief Fixed feature basing on its type
/// \param theFeature [in] feature, converted to solver specific format
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintFixedArcRadius.h>
#include <SketchSolver_Error.h>
#include <SketchSolver_Manager.h>
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:
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintLength.h>
#include <SketchSolver_Error.h>
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintMiddle.h>
#include <SketchSolver_Builder.h>
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
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintMirror.h>
#include <SketchSolver_Error.h>
#include <SketchSolver_Manager.h>
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintMovement.h>
#include <SketchSolver_Error.h>
#include <SketchSolver_Manager.h>
for (; anOldIt != anOldSubs.end() && aNewIt != aNewSubs.end(); ++anOldIt, ++aNewIt) {
std::list<EntityWrapperPtr> 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());
{}
/// \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:
/// \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<EntityWrapperPtr>& theAttributes);
+ /// \param[out] theAttributes list of attributes to be filled
+ /// (list of moved entities or attributes)
+ virtual void getAttributes(ParameterWrapperPtr& theValue,
+ std::vector<EntityWrapperPtr>& theAttributes);
private:
std::vector<EntityWrapperPtr> myMovedEntities; ///< list of entities that are moved
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintMulti.h>
#include <SketchSolver_Error.h>
#include <SketchSolver_Manager.h>
FeaturePtr aFeature;
std::list<ObjectPtr> anObjectList = aRefList->list();
std::list<ObjectPtr>::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()) {
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);
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<ModelAPI_AttributeRefList>(
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
bool myAdjusted; ///< the constraint is already adjusted (to not do it several times)
- std::set<FeaturePtr> 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<FeaturePtr> myFeatures;
};
#endif
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintMultiRotation.h>
#include <SketchSolver_Error.h>
#include <SketchSolver_Manager.h>
for (; anEntIt != aBaseEntities.end(); ++anEntIt) {
std::list<ConstraintWrapperPtr> aNewConstraints =
aBuilder->createConstraint(myBaseConstraint, myGroupID, mySketchID, myType,
- myAngle, isFullValue, aRotationCenter, EntityWrapperPtr(), std::list<EntityWrapperPtr>(1, *anEntIt));
+ myAngle, isFullValue, aRotationCenter, EntityWrapperPtr(),
+ std::list<EntityWrapperPtr>(1, *anEntIt));
aRotConstraints.insert(aRotConstraints.end(), aNewConstraints.begin(), aNewConstraints.end());
}
myStorage->addConstraint(myBaseConstraint, aRotConstraints);
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintMultiTranslation.h>
#include <SketchSolver_Error.h>
#include <SketchSolver_Manager.h>
std::list<ConstraintWrapperPtr> aNewConstraints =
aBuilder->createConstraint(myBaseConstraint, myGroupID, mySketchID, myType,
0.0, aFullValue, aStartPoint, aEndPoint, std::list<EntityWrapperPtr>(1, *anEntIt));
- aTransConstraints.insert(aTransConstraints.end(), aNewConstraints.begin(), aNewConstraints.end());
+ aTransConstraints.insert(aTransConstraints.end(),
+ aNewConstraints.begin(), aNewConstraints.end());
}
myStorage->addConstraint(myBaseConstraint, aTransConstraints);
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);
}
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);
}
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
#include <SketchSolver_ConstraintTangent.h>
#include <SketchSolver_Error.h>
#include <SketchSolver_Manager.h>
/// 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
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
}
} 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);
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) {
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<ObjectPtr> aConflicting = myStorage->getConflictingConstraints(mySketchSolver);
{
// 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<ConstraintWrapperPtr> aDummyVec; // empty vector to avoid creation of solver's constraints
+ // empty vector to avoid creation of solver's constraints
+ std::list<ConstraintWrapperPtr> aDummyVec;
// Obtain constraints, which should be separated
std::list<ConstraintPtr> anUnusedConstraints;
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<ConstraintPtr>::iterator aUnuseIt = anUnusedConstraints.begin();
while (aUnuseIt != anUnusedConstraints.end()) {
if (aNewStorage->isInteract(FeaturePtr(*aUnuseIt))) {
AttributeRefAttrPtr anAttrB = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
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() ||
return featureToVal(theFeature1) < featureToVal(theFeature2);
}
-std::list<FeaturePtr> SketchSolver_Group::selectApplicableFeatures(const std::set<ObjectPtr>& theObjects)
+std::list<FeaturePtr> SketchSolver_Group::
+ selectApplicableFeatures(const std::set<ObjectPtr>& theObjects)
{
std::list<FeaturePtr> aResult;
std::list<FeaturePtr>::iterator aResIt;
std::set<ObjectPtr>::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<ModelAPI_Feature>(*anObjIter);
if (!aFeature)
continue;
}
/** \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();
*/
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<SketchSolver_Group*>& theCuts);
CompositeFeaturePtr mySketch; ///< Sketch is equivalent to workplane
ConstraintConstraintMap myConstraints; ///< List of constraints
std::set<SolverConstraintPtr> myTempConstraints; ///< List of temporary constraints
- std::map<AttributePtr, SolverConstraintPtr> myParametricConstraints; ///< List of parametric constraints
+
+ /// List of parametric constraints
+ std::map<AttributePtr, SolverConstraintPtr> 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<ObjectPtr> myConflictingConstraints; ///< List of conflicting constraints
};
const std::shared_ptr<Events_Message>& 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;
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<FeaturePtr> aSketchFeatures = SketchSolver_Group::selectApplicableFeatures(aFeatures);
+ std::list<FeaturePtr> aSketchFeatures =
+ SketchSolver_Group::selectApplicableFeatures(aFeatures);
std::list<FeaturePtr>::iterator aFeatIter = aSketchFeatures.begin();
for (; aFeatIter != aSketchFeatures.end(); ++aFeatIter) {
if ((*aFeatIter)->getKind() == SketchPlugin_Sketch::ID()) {
std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
const std::set<std::string>& 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<std::string>::const_iterator aFGrIter;
for (aFGrIter = aFeatureGroups.begin(); aFGrIter != aFeatureGroups.end(); aFGrIter++)
if (aFGrIter->compare(ModelAPI_ResultConstruction::group()) == 0 ||
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() ||
degreesOfFreedom();
}
-void SketchSolver_Manager::checkConflictingConstraints(const std::shared_ptr<Events_Message>& theMessage)
+void SketchSolver_Manager::
+ checkConflictingConstraints(const std::shared_ptr<Events_Message>& theMessage)
{
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_SOLVER_REPAIRED)) {
std::shared_ptr<ModelAPI_SolverFailedMessage> aMessage =
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<GroupID>::const_iterator aGroupsIter = aGroups.begin();
// Search first group
bool SketchSolver_Manager::resolveConstraints(const std::list<SketchSolver_Group*>& theGroups)
{
bool needToUpdate = false;
- const std::list<SketchSolver_Group*>& aGroupsToResolve = theGroups.empty() ? myGroups : theGroups;
+ const std::list<SketchSolver_Group*>& aGroupsToResolve = theGroups.empty() ?
+ myGroups : theGroups;
std::list<SketchSolver_Group*>::const_iterator aGroupIter = aGroupsToResolve.begin();
for (; aGroupIter != aGroupsToResolve.end(); aGroupIter++)
if ((*aGroupIter)->resolveConstraints())
// Obtain points and their copies for Mirror, Multi-Rotation and Multi-Translation constraints
-static void collectPointsAndCopies(FeaturePtr theConstraint, std::list<std::set<AttributePtr> >& thePoints)
+static void collectPointsAndCopies(FeaturePtr theConstraint,
+ std::list<std::set<AttributePtr> >& thePoints)
{
typedef std::list<std::string> strlist;
static strlist aPointAttributes(1, SketchPlugin_Point::COORD_ID());
if (isSketchValid) {
std::shared_ptr<GeomDataAPI_Dir> aNormal =
- std::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+ std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
isSketchValid = aNormal && aNormal->isInitialized();
}
} 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<AttributePtr, std::set<FeaturePtr> >::iterator
aPtFound = aPointOnLine.find(aCoincPoint[0]);
if (aPtFound != aPointOnLine.end() &&
if (isExternal(anAttr))
continue; // feature is already fixed since it is external
aDoF -= aDoFDelta[anAttr->getKind()];
- std::list<AttributePtr> aPtAttrs = anAttr->data()->attributes(GeomDataAPI_Point2D::typeId());
+ std::list<AttributePtr> aPtAttrs =
+ anAttr->data()->attributes(GeomDataAPI_Point2D::typeId());
aPoints.insert(aPtAttrs.begin(), aPtAttrs.end());
}
}
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();
}
/** \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<SketchSolver_Group*>& theGroups = std::list<SketchSolver_Group*>());
+ bool resolveConstraints(const std::list<SketchSolver_Group*>& theGroups =
+ std::list<SketchSolver_Group*>());
private:
/** \brief Searches list of groups which interact with specified feature
void SketchSolver_Storage::addEntity(AttributePtr theAttribute,
EntityWrapperPtr theSolverEntity)
{
- std::map<AttributePtr, EntityWrapperPtr>::const_iterator aFound = myAttributeMap.find(theAttribute);
+ std::map<AttributePtr, EntityWrapperPtr>::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
std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(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<EntityWrapperPtr> aSubs;
// Reserve the feature in the map of features (do not want to add several copies of it)
// Check attribute of external features
std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(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)
return true;
}
-void SketchSolver_Storage::replaceEntities(const std::map<EntityWrapperPtr, EntityWrapperPtr>& theChange)
+void SketchSolver_Storage::replaceEntities(const std::map<EntityWrapperPtr,
+ EntityWrapperPtr>& theChange)
{
std::set<EntityWrapperPtr> anUpdFeatures;
std::map<EntityWrapperPtr, EntityWrapperPtr>::const_iterator aSubIt;
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;
}
return true;
}
- std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator aCIt = myConstraintMap.begin();
+ std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator aCIt =
+ myConstraintMap.begin();
std::list<ConstraintWrapperPtr>::const_iterator aCWIt;
for (; aCIt != myConstraintMap.end(); ++aCIt) {
if (aCIt->second.empty())
// if the feature has several results, we choose which one is referred
const std::list<ResultPtr>& 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();
/// \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
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
/// map attribute to solver's entity
std::map<AttributePtr, EntityWrapperPtr> 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;
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<ConstraintWrapperPtr>(); // entity is not added into a storage, constraint can not be created
+ return std::list<ConstraintWrapperPtr>();
aConstrAttrList.push_back(anOriginal[i]);
}
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);
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
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;
std::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(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);
AttributeDoublePtr aScalar =
std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(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);
aConstraint->baseConstraint()->boolean(
SketchPlugin_ConstraintAngle::ANGLE_REVERSED_SECOND_LINE_ID())->value()
};
- std::shared_ptr<GeomAPI_Angle2d> anAngle(new GeomAPI_Angle2d(aLine[0], isReversed[0], aLine[1], isReversed[1]));
+ std::shared_ptr<GeomAPI_Angle2d>
+ anAngle(new GeomAPI_Angle2d(aLine[0], isReversed[0], aLine[1], isReversed[1]));
std::shared_ptr<GeomAPI_Pnt2d> aCenter = anAngle->center();
Slvs_Constraint& aSlvsConstraint = aConstraint->changeConstraint();
(*aMIt)->setValue(aCoord[i]);
// update corresponding attribute
- AttributePtr anAttr = std::dynamic_pointer_cast<SolveSpaceSolver_EntityWrapper>(theMirrored)->baseAttribute();
+ AttributePtr anAttr =
+ std::dynamic_pointer_cast<SolveSpaceSolver_EntityWrapper>(theMirrored)->baseAttribute();
if (anAttr) {
- std::shared_ptr<GeomDataAPI_Point2D> aMirroredPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr);
+ std::shared_ptr<GeomDataAPI_Point2D> aMirroredPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr);
aMirroredPnt->setValue(aCoord[0], aCoord[1]);
}
}
/// \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
/// \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
#include <SketchSolver_ISolver.h>
-// 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
/// \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)
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);
theX = anArcPoint[0][0] + anArcPoint[2][0];
theY = anArcPoint[0][1] + anArcPoint[2][1];
} else {
- std::shared_ptr<GeomAPI_Dir2d> aStartDir(new GeomAPI_Dir2d(anArcPoint[1][0], anArcPoint[1][1]));
- std::shared_ptr<GeomAPI_Dir2d> aEndDir(new GeomAPI_Dir2d(anArcPoint[2][0], anArcPoint[2][1]));
+ std::shared_ptr<GeomAPI_Dir2d>
+ aStartDir(new GeomAPI_Dir2d(anArcPoint[1][0], anArcPoint[1][1]));
+ std::shared_ptr<GeomAPI_Dir2d>
+ aEndDir(new GeomAPI_Dir2d(anArcPoint[2][0], anArcPoint[2][1]));
double anAngle = aStartDir->angle(aEndDir);
if (anAngle < 0)
anAngle += 2.0 * PI;
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);
}
}
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())
/** \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
{
///
/// 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);
private:
Slvs_hEntity myWorkplaneID; ///< identifier of workplane
- Slvs_hParam myParamMaxID; ///< current parameter index (may differs with the number of parameters)
- std::vector<Slvs_Param> 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<Slvs_Param> myParameters;
Slvs_hEntity myEntityMaxID; ///< current entity index (may differs with the number of entities)
- std::vector<Slvs_Entity> 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<Slvs_Constraint> 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<Slvs_Entity> 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<Slvs_Constraint> myConstraints;
bool myDuplicatedConstraint; ///< shows the storage has same constraint twice