SHAPER  9.12.0
SolveSpaceSolver_Storage Class Referenceabstract

Contains all necessary data in SolveSpace format to solve a single group of constraints. More...

Inheritance diagram for SolveSpaceSolver_Storage:
Inheritance graph

Public Member Functions

 SolveSpaceSolver_Storage (const GroupID &theGroup)
 
virtual bool update (ConstraintWrapperPtr theConstraint)
 Update constraint's data. More...
 
virtual bool update (EntityWrapperPtr theEntity)
 Update entity's data. More...
 
virtual bool update (ParameterWrapperPtr theParameter)
 Update parameter's data. More...
 
virtual void refresh (bool theFixedOnly=false) const
 Update SketchPlugin features after resolving constraints. More...
 
virtual void verifyFixed ()
 Check if some parameters or entities are returned to the current group after removing temporary constraints. More...
 
virtual void addCoincidentPoints (EntityWrapperPtr theMaster, EntityWrapperPtr theSlave)
 Mark two points as coincident. More...
 
virtual EntityWrapperPtr calculateMiddlePoint (EntityWrapperPtr theBase, double theCoeff)
 Calculate point on theBase entity. More...
 
void storeWorkplane (EntityWrapperPtr theSketch)
 Obtain and store identifier of sketch. More...
 
Slvs_hParam addParameter (const Slvs_Param &theParam)
 Add new parameter to the current group. More...
 
Slvs_hParam updateParameter (const Slvs_Param &theParam)
 Updates parameter in the current group. More...
 
bool removeParameter (const Slvs_hParam &theParamID)
 Removes the parameter by its ID. More...
 
const Slvs_Param & getParameter (const Slvs_hParam &theParamID) const
 Returns the parameter by its ID. More...
 
Slvs_hEntity addEntity (const Slvs_Entity &theEntity)
 Add new entity to the current group. More...
 
Slvs_hEntity updateEntity (const Slvs_Entity &theEntity)
 Updates entity in the current group. More...
 
bool removeEntity (const Slvs_hEntity &theEntityID)
 Removes the entity by its ID. More...
 
const Slvs_Entity & getEntity (const Slvs_hEntity &theEntityID) const
 Returns the entity by its ID. More...
 
const Slvs_hEntity & entityMaxID () const
 Returns maximal ID of entities in this storage. More...
 
Slvs_hConstraint addConstraint (const Slvs_Constraint &theConstraint)
 Add new constraint to the current group. More...
 
Slvs_hConstraint updateConstraint (const Slvs_Constraint &theConstraint)
 Updates constraint in the current group. More...
 
bool removeConstraint (const Slvs_hConstraint &theConstraintID)
 Removes the constraint by its ID. More...
 
const Slvs_Constraint & getConstraint (const Slvs_hConstraint &theConstraintID) const
 Returns the constraint by its ID. More...
 
size_t nbConstraints () const
 Returns quantity of constraints in this storage. More...
 
virtual bool hasDuplicatedConstraint () const
 Shows the storage has the same constraint twice. More...
 
virtual void initializeSolver (SolverPtr theSolver)
 Initialize constraint solver by the entities collected by current storage. More...
 
virtual void addConstraint (ConstraintPtr theConstraint, ConstraintWrapperPtr theSolverConstraint)
 Change mapping between constraint from SketchPlugin and a constraint applicable for corresponding solver. More...
 
virtual void addMovementConstraint (const ConstraintWrapperPtr &theSolverConstraint)=0
 Add a movement constraint which will be destroyed after the next solving of the set of constraints. More...
 
void addEntity (FeaturePtr theFeature, EntityWrapperPtr theSolverEntity)
 Change mapping feature from SketchPlugin and the entity applicable for corresponding solver. More...
 
void addEntity (AttributePtr theAttribute, EntityWrapperPtr theSolverEntity)
 Change mapping attribute of a feature and the entity applicable for corresponding solver. More...
 
virtual bool update (FeaturePtr theFeature, bool theForce=false)=0
 Convert feature to the form applicable for specific solver and map it. More...
 
virtual bool update (AttributePtr theAttribute, bool theForce=false)=0
 Convert attribute to the form applicable for specific solver and map it. More...
 
const ConstraintWrapperPtr & constraint (const ConstraintPtr &theConstraint) const
 Returns constraint related to corresponding constraint. More...
 
const EntityWrapperPtr & entity (const FeaturePtr &theFeature) const
 Returns entity related to corresponding feature. More...
 
const EntityWrapperPtr & entity (const AttributePtr &theAttribute) const
 Returns entity related to corresponding attribute. More...
 
virtual void makeExternal (const EntityWrapperPtr &theEntity)=0
 Make entity external. More...
 
virtual void makeNonExternal (const EntityWrapperPtr &theEntity)=0
 Make entity non-external. More...
 
virtual bool removeConstraint (ConstraintPtr theConstraint)=0
 Removes constraint from the storage. More...
 
void removeFeature (FeaturePtr theFeature)
 Removes feature from the storage. More...
 
void removeAttribute (AttributePtr theAttribute)
 Removes attribute from the storage. More...
 
virtual void removeInvalidEntities ()=0
 Remove all features became invalid. More...
 
bool areFeaturesValid () const
 Check the features have not been removed. More...
 
virtual bool isEmpty () const
 Check the storage has constraints. More...
 
virtual bool isNeedToResolve ()
 Shows the sketch should be resolved. More...
 
void setNeedToResolve (bool theFlag)
 Changes the flag of group to be resolved. More...
 
std::set< ObjectPtr > getConflictingConstraints (SolverPtr theSolver) const
 Return list of conflicting constraints. More...
 
virtual void getUnderconstrainedGeometry (std::set< ObjectPtr > &theFeatures) const =0
 Return list of features which are not fully constrained. More...
 
virtual PlaneGCSSolver_Solver::SolveStatus checkDegeneratedGeometry () const =0
 Verify, the sketch contains degenerated geometry after resolving the set of constraints. More...
 
virtual void refresh () const =0
 Update SketchPlugin features after resolving constraints. More...
 
void blockEvents (bool isBlocked)
 Block or unblock events when refreshing features. More...
 
void subscribeUpdates (SketchSolver_Constraint *theSubscriber, const std::string &theGroup) const
 Subscribe for updates of features. More...
 
void unsubscribeUpdates (SketchSolver_Constraint *theSubscriber) const
 Unsubscribe for updates of features. More...
 
void notify (const FeaturePtr &theFeature) const
 Notify all subscribers about update of the feature. More...
 
virtual void adjustParametrizationOfArcs ()=0
 Make parametrization of arcs consistent. More...
 

Protected Member Functions

virtual bool remove (ConstraintWrapperPtr theConstraint)
 Remove constraint. More...
 
virtual bool remove (EntityWrapperPtr theEntity)
 Remove entity. More...
 
virtual bool remove (ParameterWrapperPtr theParameter)
 Remove parameter. More...
 
virtual void changeGroup (EntityWrapperPtr theEntity, const GroupID &theGroup)
 Update the group for the given entity, its sub-entities and parameters. More...
 
virtual void changeGroup (ParameterWrapperPtr theParam, const GroupID &theGroup)
 Update the group for the given parameter. More...
 

Static Protected Member Functions

static void resultToFeatureOrAttribute (const ObjectPtr &theResult, FeaturePtr &theFeature, AttributePtr &theAttribute)
 Convert result to feature or attribute if theResult is linked to center of circle/arc. More...
 

Protected Attributes

SolverPtr mySketchSolver
 Sketch solver, prepared in corresponding group. More...
 
bool myNeedToResolve
 parameters are changed and group needs to be resolved More...
 
bool myEventsBlocked
 indicates that features do not send events More...
 
std::map< ConstraintPtr, ConstraintWrapperPtr > myConstraintMap
 map SketchPlugin constraint to a list of solver's constraints More...
 
std::map< FeaturePtr, EntityWrapperPtr > myFeatureMap
 map SketchPlugin feature to solver's entity More...
 
std::map< AttributePtr, EntityWrapperPtr > myAttributeMap
 map attribute to solver's entity More...
 
UpdaterPtr myUpdaters
 

Detailed Description

Contains all necessary data in SolveSpace format to solve a single group of constraints.

Member Function Documentation

◆ update() [1/5]

bool SolveSpaceSolver_Storage::update ( ConstraintWrapperPtr  theConstraint)
virtual

Update constraint's data.

Returns
true if any value is updated

◆ update() [2/5]

bool SolveSpaceSolver_Storage::update ( EntityWrapperPtr  theEntity)
virtual

Update entity's data.

Returns
true if any value is updated

◆ update() [3/5]

bool SolveSpaceSolver_Storage::update ( ParameterWrapperPtr  theParameter)
virtual

Update parameter's data.

Returns
true if the value of parameter is updated

◆ refresh() [1/2]

void SolveSpaceSolver_Storage::refresh ( bool  theFixedOnly = false) const
virtual

Update SketchPlugin features after resolving constraints.

Parameters
theFixedOnly[in] if true the fixed points will be updated only

◆ verifyFixed()

void SolveSpaceSolver_Storage::verifyFixed ( )
virtual

Check if some parameters or entities are returned to the current group after removing temporary constraints.

◆ addCoincidentPoints()

void SolveSpaceSolver_Storage::addCoincidentPoints ( EntityWrapperPtr  theMaster,
EntityWrapperPtr  theSlave 
)
virtual

Mark two points as coincident.

◆ calculateMiddlePoint()

EntityWrapperPtr SolveSpaceSolver_Storage::calculateMiddlePoint ( EntityWrapperPtr  theBase,
double  theCoeff 
)
virtual

Calculate point on theBase entity.

Value theCoeff is in [0.0 .. 1.0] and shows the distance from the start point.

◆ remove() [1/3]

bool SolveSpaceSolver_Storage::remove ( ConstraintWrapperPtr  theConstraint)
protectedvirtual

Remove constraint.

Returns
true if the constraint and all its parameters are removed successfully

◆ remove() [2/3]

bool SolveSpaceSolver_Storage::remove ( EntityWrapperPtr  theEntity)
protectedvirtual

Remove entity.

Returns
true if the entity and all its parameters are removed successfully

◆ remove() [3/3]

bool SolveSpaceSolver_Storage::remove ( ParameterWrapperPtr  theParameter)
protectedvirtual

Remove parameter.

Returns
true if the parameter has been removed

◆ changeGroup() [1/2]

void SolveSpaceSolver_Storage::changeGroup ( EntityWrapperPtr  theEntity,
const GroupID &  theGroup 
)
protectedvirtual

Update the group for the given entity, its sub-entities and parameters.

◆ changeGroup() [2/2]

void SolveSpaceSolver_Storage::changeGroup ( ParameterWrapperPtr  theParam,
const GroupID &  theGroup 
)
protectedvirtual

Update the group for the given parameter.

◆ storeWorkplane()

void SolveSpaceSolver_Storage::storeWorkplane ( EntityWrapperPtr  theSketch)

Obtain and store identifier of sketch.

◆ addParameter()

Slvs_hParam SolveSpaceSolver_Storage::addParameter ( const Slvs_Param &  theParam)

Add new parameter to the current group.

Parameters
[in]theParamSolveSpace parameter
Returns
the ID of added parameter

◆ updateParameter()

Slvs_hParam SolveSpaceSolver_Storage::updateParameter ( const Slvs_Param &  theParam)

Updates parameter in the current group.

If the ID of parameter is zero, the new item will be added

Parameters
[in]theParamSolveSpace parameter
Returns
the ID of updated/added parameter

◆ removeParameter()

bool SolveSpaceSolver_Storage::removeParameter ( const Slvs_hParam &  theParamID)

Removes the parameter by its ID.

Parameters
[in]theParamIDindex of parameter to be removed
Returns
true if the parameter was successfully removed

◆ getParameter()

const Slvs_Param & SolveSpaceSolver_Storage::getParameter ( const Slvs_hParam &  theParamID) const

Returns the parameter by its ID.

◆ addEntity() [1/3]

Slvs_hEntity SolveSpaceSolver_Storage::addEntity ( const Slvs_Entity &  theEntity)

Add new entity to the current group.

Parameters
[in]theEntitySolveSpace entity
Returns
the ID of added entity

◆ updateEntity()

Slvs_hEntity SolveSpaceSolver_Storage::updateEntity ( const Slvs_Entity &  theEntity)

Updates entity in the current group.

If the ID of entity is zero, the new item will be added

Parameters
[in]theEntitySolveSpace entity
Returns
the ID of updated/added entity

◆ removeEntity()

bool SolveSpaceSolver_Storage::removeEntity ( const Slvs_hEntity &  theEntityID)

Removes the entity by its ID.

All parameters used in this entity, and not used in other constraints, will be removed too.

Parameters
[in]theEntityIDindex of entity to be removed
Returns
true if the entity was successfully removed

◆ getEntity()

const Slvs_Entity & SolveSpaceSolver_Storage::getEntity ( const Slvs_hEntity &  theEntityID) const

Returns the entity by its ID.

◆ entityMaxID()

const Slvs_hEntity& SolveSpaceSolver_Storage::entityMaxID ( ) const
inline

Returns maximal ID of entities in this storage.

◆ addConstraint() [1/2]

Slvs_hConstraint SolveSpaceSolver_Storage::addConstraint ( const Slvs_Constraint &  theConstraint)

Add new constraint to the current group.

Parameters
[in]theConstraintSolveSpace's constraint
Returns
the ID of added constraint

◆ updateConstraint()

Slvs_hConstraint SolveSpaceSolver_Storage::updateConstraint ( const Slvs_Constraint &  theConstraint)

Updates constraint in the current group.

If the ID of constraint is zero, the new item will be added

Parameters
[in]theConstraintSolveSpace constraint
Returns
the ID of updated/added constraint

◆ removeConstraint() [1/2]

bool SolveSpaceSolver_Storage::removeConstraint ( const Slvs_hConstraint &  theConstraintID)

Removes the constraint by its ID.

All entities and parameters depending on this constraint, which are not used in other constraints, will be removed too.

Parameters
[in]theConstraintIDindex of constraint to be removed
Returns
true if the constraint was successfully removed

◆ getConstraint()

const Slvs_Constraint & SolveSpaceSolver_Storage::getConstraint ( const Slvs_hConstraint &  theConstraintID) const

Returns the constraint by its ID.

◆ nbConstraints()

size_t SolveSpaceSolver_Storage::nbConstraints ( ) const
inline

Returns quantity of constraints in this storage.

◆ hasDuplicatedConstraint()

virtual bool SolveSpaceSolver_Storage::hasDuplicatedConstraint ( ) const
inlinevirtual

Shows the storage has the same constraint twice.

◆ initializeSolver()

void SolveSpaceSolver_Storage::initializeSolver ( SolverPtr  theSolver)
virtual

Initialize constraint solver by the entities collected by current storage.

◆ addConstraint() [2/2]

void SketchSolver_Storage::addConstraint ( ConstraintPtr  theConstraint,
ConstraintWrapperPtr  theSolverConstraint 
)
virtualinherited

Change mapping between constraint from SketchPlugin and a constraint applicable for corresponding solver.

Parameters
theConstraint[in] original SketchPlugin constraint
theSolverConstraint[in] solver's constraint

Reimplemented in PlaneGCSSolver_Storage.

◆ addMovementConstraint()

virtual void SketchSolver_Storage::addMovementConstraint ( const ConstraintWrapperPtr &  theSolverConstraint)
pure virtualinherited

Add a movement constraint which will be destroyed after the next solving of the set of constraints.

Parameters
theSolverConstraint[in] solver's constraint

Implemented in PlaneGCSSolver_Storage.

◆ addEntity() [2/3]

void SketchSolver_Storage::addEntity ( FeaturePtr  theFeature,
EntityWrapperPtr  theSolverEntity 
)
inherited

Change mapping feature from SketchPlugin and the entity applicable for corresponding solver.

Parameters
theFeature[in] original SketchPlugin feature
theSolverEntity[in] solver's entity, created outside

◆ addEntity() [3/3]

void SketchSolver_Storage::addEntity ( AttributePtr  theAttribute,
EntityWrapperPtr  theSolverEntity 
)
inherited

Change mapping attribute of a feature and the entity applicable for corresponding solver.

Parameters
theAttribute[in] original attribute
theSolverEntity[in] solver's entity, created outside

◆ update() [4/5]

virtual bool SketchSolver_Storage::update ( FeaturePtr  theFeature,
bool  theForce = false 
)
pure virtualinherited

Convert feature to the form applicable for specific solver and map it.

Parameters
theFeature[in] feature to convert
theForce[in] forced feature creation
Returns
true if the feature has been created or updated

Implemented in PlaneGCSSolver_Storage.

◆ update() [5/5]

virtual bool SketchSolver_Storage::update ( AttributePtr  theAttribute,
bool  theForce = false 
)
pure virtualinherited

Convert attribute to the form applicable for specific solver and map it.

Parameters
theAttribute[in] attribute to convert
theForce[in] forced feature creation
Returns
true if the attribute has been created or updated

Implemented in PlaneGCSSolver_Storage.

◆ constraint()

const ConstraintWrapperPtr & SketchSolver_Storage::constraint ( const ConstraintPtr &  theConstraint) const
inherited

Returns constraint related to corresponding constraint.

◆ entity() [1/2]

const EntityWrapperPtr & SketchSolver_Storage::entity ( const FeaturePtr &  theFeature) const
inherited

Returns entity related to corresponding feature.

◆ entity() [2/2]

const EntityWrapperPtr & SketchSolver_Storage::entity ( const AttributePtr &  theAttribute) const
inherited

Returns entity related to corresponding attribute.

TODO: Check resultToFeatureOrAttribute() precisely. Create additional unit-test

◆ makeExternal()

virtual void SketchSolver_Storage::makeExternal ( const EntityWrapperPtr &  theEntity)
pure virtualinherited

Make entity external.

Implemented in PlaneGCSSolver_Storage.

◆ makeNonExternal()

virtual void SketchSolver_Storage::makeNonExternal ( const EntityWrapperPtr &  theEntity)
pure virtualinherited

Make entity non-external.

Implemented in PlaneGCSSolver_Storage.

◆ removeConstraint() [2/2]

virtual bool SketchSolver_Storage::removeConstraint ( ConstraintPtr  theConstraint)
pure virtualinherited

Removes constraint from the storage.

Returns
true if the constraint and all its parameters are removed successfully

Implemented in PlaneGCSSolver_Storage.

◆ removeFeature()

void SketchSolver_Storage::removeFeature ( FeaturePtr  theFeature)
inherited

Removes feature from the storage.

◆ removeAttribute()

void SketchSolver_Storage::removeAttribute ( AttributePtr  theAttribute)
inherited

Removes attribute from the storage.

◆ removeInvalidEntities()

virtual void SketchSolver_Storage::removeInvalidEntities ( )
pure virtualinherited

Remove all features became invalid.

Implemented in PlaneGCSSolver_Storage.

◆ areFeaturesValid()

bool SketchSolver_Storage::areFeaturesValid ( ) const
inherited

Check the features have not been removed.

◆ isEmpty()

virtual bool SketchSolver_Storage::isEmpty ( ) const
inlinevirtualinherited

Check the storage has constraints.

Reimplemented in PlaneGCSSolver_Storage.

◆ isNeedToResolve()

virtual bool SketchSolver_Storage::isNeedToResolve ( )
inlinevirtualinherited

Shows the sketch should be resolved.

◆ setNeedToResolve()

void SketchSolver_Storage::setNeedToResolve ( bool  theFlag)
inlineinherited

Changes the flag of group to be resolved.

◆ getConflictingConstraints()

std::set< ObjectPtr > SketchSolver_Storage::getConflictingConstraints ( SolverPtr  theSolver) const
inherited

Return list of conflicting constraints.

◆ getUnderconstrainedGeometry()

virtual void SketchSolver_Storage::getUnderconstrainedGeometry ( std::set< ObjectPtr > &  theFeatures) const
pure virtualinherited

Return list of features which are not fully constrained.

Implemented in PlaneGCSSolver_Storage.

◆ checkDegeneratedGeometry()

virtual PlaneGCSSolver_Solver::SolveStatus SketchSolver_Storage::checkDegeneratedGeometry ( ) const
pure virtualinherited

Verify, the sketch contains degenerated geometry after resolving the set of constraints.

Returns
STATUS_OK if the geometry is valid, STATUS_DEGENERATED otherwise.

Implemented in PlaneGCSSolver_Storage.

◆ refresh() [2/2]

virtual void SketchSolver_Storage::refresh ( ) const
pure virtualinherited

Update SketchPlugin features after resolving constraints.

Implemented in PlaneGCSSolver_Storage.

◆ blockEvents()

void SketchSolver_Storage::blockEvents ( bool  isBlocked)
inherited

Block or unblock events when refreshing features.

◆ subscribeUpdates()

void SketchSolver_Storage::subscribeUpdates ( SketchSolver_Constraint theSubscriber,
const std::string &  theGroup 
) const
inherited

Subscribe for updates of features.

Parameters
theSubscriber[in] object which wants to revceive notifications
theGroup[in] group of updates features to be send

◆ unsubscribeUpdates()

void SketchSolver_Storage::unsubscribeUpdates ( SketchSolver_Constraint theSubscriber) const
inherited

Unsubscribe for updates of features.

Parameters
theSubscriber[in] object which does not want to revceive notifications anymore

◆ notify()

void SketchSolver_Storage::notify ( const FeaturePtr &  theFeature) const
inherited

Notify all subscribers about update of the feature.

◆ adjustParametrizationOfArcs()

virtual void SketchSolver_Storage::adjustParametrizationOfArcs ( )
pure virtualinherited

Make parametrization of arcs consistent.

Forward arcs should have the last parameter greater than the first parameter. Reversed arcs should have the last parameter lesser than the first parameter.

Implemented in PlaneGCSSolver_Storage.

◆ resultToFeatureOrAttribute()

void SketchSolver_Storage::resultToFeatureOrAttribute ( const ObjectPtr &  theResult,
FeaturePtr &  theFeature,
AttributePtr &  theAttribute 
)
staticprotectedinherited

Convert result to feature or attribute if theResult is linked to center of circle/arc.

Field Documentation

◆ mySketchSolver

SolverPtr SketchSolver_Storage::mySketchSolver
protectedinherited

Sketch solver, prepared in corresponding group.

◆ myNeedToResolve

bool SketchSolver_Storage::myNeedToResolve
protectedinherited

parameters are changed and group needs to be resolved

◆ myEventsBlocked

bool SketchSolver_Storage::myEventsBlocked
protectedinherited

indicates that features do not send events

◆ myConstraintMap

std::map<ConstraintPtr, ConstraintWrapperPtr> SketchSolver_Storage::myConstraintMap
protectedinherited

map SketchPlugin constraint to a list of solver's constraints

◆ myFeatureMap

std::map<FeaturePtr, EntityWrapperPtr> SketchSolver_Storage::myFeatureMap
protectedinherited

map SketchPlugin feature to solver's entity

◆ myAttributeMap

std::map<AttributePtr, EntityWrapperPtr> SketchSolver_Storage::myAttributeMap
protectedinherited

map attribute to solver's entity