1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <PlaneGCSSolver_Storage.h>
21 #include <PlaneGCSSolver_Solver.h>
22 #include <PlaneGCSSolver_BooleanWrapper.h>
23 #include <PlaneGCSSolver_ConstraintWrapper.h>
24 #include <PlaneGCSSolver_EdgeWrapper.h>
25 #include <PlaneGCSSolver_PointWrapper.h>
26 #include <PlaneGCSSolver_Tools.h>
28 #include <PlaneGCSSolver_AttributeBuilder.h>
29 #include <PlaneGCSSolver_FeatureBuilder.h>
30 #include <PlaneGCSSolver_EntityDestroyer.h>
32 #include <GeomAPI_Dir2d.h>
33 #include <GeomAPI_Pnt2d.h>
34 #include <GeomAPI_XY.h>
35 #include <GeomDataAPI_Point2D.h>
36 #include <ModelAPI_AttributeRefAttr.h>
37 #include <SketchPlugin_Ellipse.h>
38 #include <SketchPlugin_Projection.h>
43 static void constraintsToSolver(const ConstraintWrapperPtr& theConstraint,
44 const SolverPtr& theSolver)
46 const std::list<GCSConstraintPtr>& aConstraints =
47 std::dynamic_pointer_cast<PlaneGCSSolver_ConstraintWrapper>(theConstraint)->constraints();
48 theSolver->addConstraint(theConstraint->id(), aConstraints);
52 PlaneGCSSolver_Storage::PlaneGCSSolver_Storage(const SolverPtr& theSolver)
53 : SketchSolver_Storage(theSolver),
54 myConstraintLastID(CID_UNKNOWN)
58 void PlaneGCSSolver_Storage::addConstraint(
59 ConstraintPtr theConstraint,
60 ConstraintWrapperPtr theSolverConstraint)
62 SketchSolver_Storage::addConstraint(theConstraint, theSolverConstraint);
64 theSolverConstraint->setId(++myConstraintLastID);
65 constraintsToSolver(theSolverConstraint, mySketchSolver);
68 void PlaneGCSSolver_Storage::addMovementConstraint(
69 const ConstraintWrapperPtr& theSolverConstraint)
71 // before adding movement constraint to solver, re-check its DOF
72 if (mySketchSolver->dof() == 0)
73 mySketchSolver->diagnose();
75 theSolverConstraint->setId(CID_MOVEMENT);
76 constraintsToSolver(theSolverConstraint, mySketchSolver);
80 EntityWrapperPtr PlaneGCSSolver_Storage::createFeature(
81 const FeaturePtr& theFeature,
82 PlaneGCSSolver_EntityBuilder* theBuilder)
84 std::list<AttributePtr> anAttributes = theFeature->data()->attributes(std::string());
85 std::list<AttributePtr>::const_iterator anIt = anAttributes.begin();
86 for (; anIt != anAttributes.end(); ++anIt)
87 createAttribute(*anIt, theBuilder);
89 EntityWrapperPtr aResult = theBuilder->createFeature(theFeature);
91 addEntity(theFeature, aResult);
95 EntityWrapperPtr PlaneGCSSolver_Storage::createAttribute(
96 const AttributePtr& theAttribute,
97 PlaneGCSSolver_EntityBuilder* theBuilder)
99 EntityWrapperPtr aResult = theBuilder->createAttribute(theAttribute);
101 addEntity(theAttribute, aResult);
105 /// \brief Update value
106 static bool updateValue(const double& theSource, double& theDest)
108 static const double aTol = 1000. * tolerance;
109 bool isUpdated = fabs(theSource - theDest) > aTol;
115 /// \brief Update coordinates of the point or scalar using its base attribute
116 static bool updateValues(AttributePtr& theAttribute, EntityWrapperPtr& theEntity)
118 bool isUpdated = false;
120 std::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
121 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theAttribute);
123 const GCSPointPtr& aGCSPoint =
124 std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theEntity)->point();
125 isUpdated = updateValue(aPoint2D->x(), *(aGCSPoint->x)) || isUpdated;
126 isUpdated = updateValue(aPoint2D->y(), *(aGCSPoint->y)) || isUpdated;
128 AttributeDoublePtr aScalar =
129 std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
131 ScalarWrapperPtr aWrapper =
132 std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(theEntity);
133 // There is possible angular value, which is converted between degrees and radians.
134 // So, we use its value instead of using direct pointer to value.
135 double aValue = aWrapper->value();
136 isUpdated = updateValue(aScalar->value(), aValue);
138 aWrapper->setValue(aValue);
140 AttributeBooleanPtr aBoolean =
141 std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(theAttribute);
143 BooleanWrapperPtr aWrapper =
144 std::dynamic_pointer_cast<PlaneGCSSolver_BooleanWrapper>(theEntity);
145 isUpdated = aWrapper->value() != aBoolean->value();
146 aWrapper->setValue(aBoolean->value());
154 static bool hasReference(std::shared_ptr<SketchPlugin_Feature> theFeature,
155 const std::string& theFeatureKind)
157 const std::set<AttributePtr>& aRefs = theFeature->data()->refsToMe();
158 for (std::set<AttributePtr>::const_iterator aRefIt = aRefs.begin();
159 aRefIt != aRefs.end(); ++aRefIt) {
160 FeaturePtr anOwner = ModelAPI_Feature::feature((*aRefIt)->owner());
161 if (anOwner && anOwner->getKind() == theFeatureKind)
167 static bool isCopyFeature(std::shared_ptr<SketchPlugin_Feature> theFeature)
169 return theFeature && theFeature->isCopy();
172 bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce)
174 bool sendNotify = false;
175 bool isUpdated = false;
176 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
177 std::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
178 EntityWrapperPtr aRelated = entity(theFeature);
179 if (aRelated) // send signal to subscribers
181 else { // Feature is not exist, create it
182 bool isCopy = isCopyFeature(aSketchFeature);
183 bool isProjReferred = hasReference(aSketchFeature, SketchPlugin_Projection::ID());
184 // the feature is a copy in "Multi" constraint and does not used in other constraints
185 if (!theForce && (isCopy && !isProjReferred) &&
186 myFeatureMap.find(theFeature) == myFeatureMap.end())
189 // external feature processing
191 (aSketchFeature && (aSketchFeature->isExternal() || isCopy || isProjReferred));
193 PlaneGCSSolver_FeatureBuilder aBuilder(isExternal ? 0 : this);
195 // Reserve the feature in the map of features
196 // (do not want to add several copies of it while adding attributes)
197 aRelated = createFeature(theFeature, &aBuilder);
198 myFeatureMap[theFeature] = aRelated;
199 createAuxiliaryConstraints(aRelated);
203 std::list<AttributePtr> anAttributes = theFeature->data()->attributes(std::string());
204 std::list<AttributePtr>::iterator anAttrIt = anAttributes.begin();
205 for (; anAttrIt != anAttributes.end(); ++anAttrIt)
206 if ((*anAttrIt)->attributeType() == GeomDataAPI_Point2D::typeId() ||
207 (*anAttrIt)->attributeType() == ModelAPI_AttributeDouble::typeId() ||
208 (*anAttrIt)->attributeType() == ModelAPI_AttributeBoolean::typeId())
209 isUpdated = update(*anAttrIt) || isUpdated;
211 // check external attribute is changed
212 bool isExternal = aSketchFeature &&
213 (aSketchFeature->isExternal() || isCopyFeature(aSketchFeature));
214 if (aRelated && isExternal != aRelated->isExternal()) {
216 makeExternal(aRelated);
218 makeNonExternal(aRelated);
222 // send notification to listeners due to at least one attribute is changed
223 if (sendNotify && isUpdated)
229 bool PlaneGCSSolver_Storage::update(AttributePtr theAttribute, bool theForce)
231 if (!theAttribute->isInitialized())
234 AttributePtr anAttribute = theAttribute;
235 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttribute);
237 if (aRefAttr->isObject()) {
239 /// TODO: Check resultToFeatureOrAttribute() precisely.
240 resultToFeatureOrAttribute(aRefAttr->object(), aFeature, anAttribute);
242 return update(aFeature, theForce);
244 anAttribute = aRefAttr->attr();
247 EntityWrapperPtr aRelated = entity(anAttribute);
248 FeaturePtr aFeature = ModelAPI_Feature::feature(anAttribute->owner());
249 if (!aRelated) { // Attribute does not exist, create it.
250 // First of all check if the parent feature exists. If not, add it.
251 if (aFeature && myFeatureMap.find(aFeature) == myFeatureMap.end())
252 return update(aFeature, theForce); // theAttribute has been processed while adding feature
253 return aRelated.get() != 0;
256 bool isUpdated = updateValues(anAttribute, aRelated);
258 setNeedToResolve(true);
264 void PlaneGCSSolver_Storage::makeExternal(const EntityWrapperPtr& theEntity)
266 if (theEntity->isExternal())
269 removeAuxiliaryConstraints(theEntity);
271 GCS::SET_pD aParameters = PlaneGCSSolver_Tools::parameters(theEntity);
272 mySketchSolver->removeParameters(aParameters);
273 theEntity->setExternal(true);
274 myNeedToResolve = true;
277 void PlaneGCSSolver_Storage::makeNonExternal(const EntityWrapperPtr& theEntity)
279 if (!theEntity->isExternal())
282 GCS::SET_pD aParameters = PlaneGCSSolver_Tools::parameters(theEntity);
283 mySketchSolver->addParameters(aParameters);
284 theEntity->setExternal(false);
286 createAuxiliaryConstraints(theEntity);
288 myNeedToResolve = true;
292 static void createArcConstraints(const EntityWrapperPtr& theArc,
293 const SolverPtr& theSolver,
294 const ConstraintID theConstraintID,
295 std::map<EntityWrapperPtr, ConstraintWrapperPtr>& theConstraints)
297 EdgeWrapperPtr anEdge = std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theArc);
298 std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(anEdge->entity());
300 // Additional constaints to fix arc's extra DoF (if the arc is not external):
301 std::list<GCSConstraintPtr> anArcConstraints;
302 // constrain the start point on the arc
303 anArcConstraints.push_back(GCSConstraintPtr(new GCS::ConstraintCurveValue(
304 anArc->start, anArc->start.x, *anArc, anArc->startAngle)));
305 anArcConstraints.push_back(GCSConstraintPtr(new GCS::ConstraintCurveValue(
306 anArc->start, anArc->start.y, *anArc, anArc->startAngle)));
307 // constrain the end point on the arc
308 anArcConstraints.push_back(GCSConstraintPtr(new GCS::ConstraintCurveValue(
309 anArc->end, anArc->end.x, *anArc, anArc->endAngle)));
310 anArcConstraints.push_back(GCSConstraintPtr(new GCS::ConstraintCurveValue(
311 anArc->end, anArc->end.y, *anArc, anArc->endAngle)));
313 ConstraintWrapperPtr aWrapper(
314 new PlaneGCSSolver_ConstraintWrapper(anArcConstraints, CONSTRAINT_UNKNOWN));
315 aWrapper->setId(theConstraintID);
316 constraintsToSolver(aWrapper, theSolver);
318 theConstraints[theArc] = aWrapper;
321 static void createEllipseConstraints(
322 const EntityWrapperPtr& theEllipse,
323 const SolverPtr& theSolver,
324 const ConstraintID theConstraintID,
325 std::map<EntityWrapperPtr, ConstraintWrapperPtr>& theConstraints)
327 EdgeWrapperPtr anEdge = std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEllipse);
328 std::shared_ptr<GCS::Ellipse> anEllipse =
329 std::dynamic_pointer_cast<GCS::Ellipse>(anEdge->entity());
331 // Additional constaints to fix ellipse's extra points
332 std::list<GCSConstraintPtr> anEllipseConstraints;
334 const std::map<std::string, EntityWrapperPtr>& anAttributes = theEllipse->additionalAttributes();
335 for (std::map<std::string, EntityWrapperPtr>::const_iterator anIt = anAttributes.begin();
336 anIt != anAttributes.end(); ++anIt) {
337 std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint =
338 std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(anIt->second);
342 GCS::InternalAlignmentType anAlignmentX, anAlignmentY;
343 if (anIt->first == SketchPlugin_Ellipse::SECOND_FOCUS_ID())
344 anAlignmentX = GCS::EllipseFocus2X;
345 else if (anIt->first == SketchPlugin_Ellipse::MAJOR_AXIS_START_ID())
346 anAlignmentX = GCS::EllipseNegativeMajorX;
347 else if (anIt->first == SketchPlugin_Ellipse::MAJOR_AXIS_END_ID())
348 anAlignmentX = GCS::EllipsePositiveMajorX;
349 else if (anIt->first == SketchPlugin_Ellipse::MINOR_AXIS_START_ID())
350 anAlignmentX = GCS::EllipseNegativeMinorX;
351 else if (anIt->first == SketchPlugin_Ellipse::MINOR_AXIS_END_ID())
352 anAlignmentX = GCS::EllipsePositiveMinorX;
354 anEllipseConstraints.push_back(GCSConstraintPtr(
355 new GCS::ConstraintInternalAlignmentPoint2Ellipse(*anEllipse, *(aPoint->point()), anAlignmentX)));
356 anAlignmentY = (GCS::InternalAlignmentType)((int)anAlignmentX + 1);
357 anEllipseConstraints.push_back(GCSConstraintPtr(
358 new GCS::ConstraintInternalAlignmentPoint2Ellipse(*anEllipse, *(aPoint->point()), anAlignmentY)));
361 // constraint to bind the major radius value
362 std::shared_ptr<PlaneGCSSolver_PointWrapper> aMajorAxisStart =
363 std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(
364 anAttributes.at(SketchPlugin_Ellipse::MAJOR_AXIS_START_ID()));
365 ScalarWrapperPtr aMajorRadius =
366 std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(
367 anAttributes.at(SketchPlugin_Ellipse::MAJOR_RADIUS_ID()));
368 anEllipseConstraints.push_back(GCSConstraintPtr(new GCS::ConstraintP2PDistance(
369 anEllipse->center, *(aMajorAxisStart->point()), aMajorRadius->scalar())));
371 ConstraintWrapperPtr aWrapper(
372 new PlaneGCSSolver_ConstraintWrapper(anEllipseConstraints, CONSTRAINT_UNKNOWN));
373 aWrapper->setId(theConstraintID);
374 constraintsToSolver(aWrapper, theSolver);
376 theConstraints[theEllipse] = aWrapper;
379 void PlaneGCSSolver_Storage::createAuxiliaryConstraints(const EntityWrapperPtr& theEntity)
381 if (!theEntity || theEntity->isExternal())
384 if (theEntity->type() == ENTITY_ARC)
385 createArcConstraints(theEntity, mySketchSolver, ++myConstraintLastID, myAuxConstraintMap);
386 else if (theEntity->type() == ENTITY_ELLIPSE)
387 createEllipseConstraints(theEntity, mySketchSolver, ++myConstraintLastID, myAuxConstraintMap);
390 void PlaneGCSSolver_Storage::removeAuxiliaryConstraints(const EntityWrapperPtr& theEntity)
392 std::map<EntityWrapperPtr, ConstraintWrapperPtr>::iterator
393 aFound = myAuxConstraintMap.find(theEntity);
394 if (aFound != myAuxConstraintMap.end()) {
395 mySketchSolver->removeConstraint(aFound->second->id());
396 myAuxConstraintMap.erase(aFound);
400 void PlaneGCSSolver_Storage::adjustParametrizationOfArcs()
402 std::map<EntityWrapperPtr, ConstraintWrapperPtr>::iterator anIt = myAuxConstraintMap.begin();
403 for (; anIt != myAuxConstraintMap.end(); ++anIt) {
404 EdgeWrapperPtr anEdge = std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(anIt->first);
405 std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(anEdge->entity());
408 // tune start angle of the arc to be in [0, 2PI]
409 while (*anArc->startAngle < -PI)
410 *anArc->startAngle += 2.0 * PI;
411 while (*anArc->startAngle >= PI)
412 *anArc->startAngle -= 2.0 * PI;
413 // adjust end angle of the arc
414 if (anEdge->isReversed()) {
415 while (*anArc->endAngle > *anArc->startAngle)
416 *anArc->endAngle -= 2.0 * PI;
417 while (*anArc->endAngle + 2 * PI < *anArc->startAngle)
418 *anArc->endAngle += 2.0 * PI;
420 while (*anArc->endAngle < *anArc->startAngle)
421 *anArc->endAngle += 2.0 * PI;
422 while (*anArc->endAngle > *anArc->startAngle + 2 * PI)
423 *anArc->endAngle -= 2.0 * PI;
427 // update parameters of Middle point constraint for point on arc
428 std::map<ConstraintPtr, ConstraintWrapperPtr>::iterator aCIt = myConstraintMap.begin();
429 for (; aCIt != myConstraintMap.end(); ++aCIt)
430 if (aCIt->second->type() == CONSTRAINT_MIDDLE_POINT) {
436 bool PlaneGCSSolver_Storage::removeConstraint(ConstraintPtr theConstraint)
438 std::map<ConstraintPtr, ConstraintWrapperPtr>::iterator
439 aFound = myConstraintMap.find(theConstraint);
440 if (aFound != myConstraintMap.end()) {
441 ConstraintWrapperPtr aCW = aFound->second;
442 ConstraintID anID = aCW->id();
444 // Remove solver's constraints
445 mySketchSolver->removeConstraint(anID);
447 // Remove value if exists
448 const ScalarWrapperPtr& aValue = aCW->valueParameter();
450 GCS::SET_pD aParToRemove;
451 aParToRemove.insert(aValue->scalar());
452 removeParameters(aParToRemove);
456 myConstraintMap.erase(aFound);
458 if (anID != CID_MOVEMENT)
459 myNeedToResolve = true;
462 notify(theConstraint);
467 void PlaneGCSSolver_Storage::removeInvalidEntities()
469 PlaneGCSSolver_EntityDestroyer aDestroyer;
471 // Remove invalid constraints
472 std::list<ConstraintPtr> anInvalidConstraints;
473 std::map<ConstraintPtr, ConstraintWrapperPtr>::const_iterator
474 aCIter = myConstraintMap.begin();
475 for (; aCIter != myConstraintMap.end(); ++aCIter)
476 if (!aCIter->first->data() || !aCIter->first->data()->isValid())
477 anInvalidConstraints.push_back(aCIter->first);
478 std::list<ConstraintPtr>::const_iterator anInvCIt = anInvalidConstraints.begin();
479 for (; anInvCIt != anInvalidConstraints.end(); ++anInvCIt)
480 removeConstraint(*anInvCIt);
482 // Remove invalid features
483 std::list<FeaturePtr> anInvalidFeatures;
484 std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFIter = myFeatureMap.begin();
485 for (; aFIter != myFeatureMap.end(); aFIter++)
486 if (!aFIter->first->data() || !aFIter->first->data()->isValid()) {
487 anInvalidFeatures.push_back(aFIter->first);
489 aDestroyer.remove(aFIter->second);
491 // remove invalid arc
492 removeAuxiliaryConstraints(aFIter->second);
494 std::list<FeaturePtr>::const_iterator anInvFIt = anInvalidFeatures.begin();
495 for (; anInvFIt != anInvalidFeatures.end(); ++anInvFIt)
496 removeFeature(*anInvFIt);
498 // Remove invalid attributes
499 std::list<AttributePtr> anInvalidAttributes;
500 std::map<AttributePtr, EntityWrapperPtr>::const_iterator anAttrIt = myAttributeMap.begin();
501 for (; anAttrIt != myAttributeMap.end(); ++anAttrIt) {
502 FeaturePtr anOwner = ModelAPI_Feature::feature(anAttrIt->first->owner());
503 if (!anOwner || !anOwner->data() || !anOwner->data()->isValid()) {
504 anInvalidAttributes.push_back(anAttrIt->first);
505 aDestroyer.remove(anAttrIt->second);
508 std::list<AttributePtr>::const_iterator anInvAtIt = anInvalidAttributes.begin();
509 for (; anInvAtIt != anInvalidAttributes.end(); ++anInvAtIt)
510 removeAttribute(*anInvAtIt);
512 // free memory occupied by parameters
513 removeParameters(aDestroyer.parametersToRemove());
515 /// TODO: Think on optimization of checking invalid features and attributes
520 double* PlaneGCSSolver_Storage::createParameter()
522 return mySketchSolver->createParameter();
525 void PlaneGCSSolver_Storage::removeParameters(const GCS::SET_pD& theParams)
527 mySketchSolver->removeParameters(theParams);
530 // indicates attribute containing in the external feature
531 static bool isExternalAttribute(const AttributePtr& theAttribute)
535 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
536 std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
537 return aSketchFeature.get() && aSketchFeature->isExternal();
540 static void addOwnerToSet(const AttributePtr& theAttribute, std::set<FeaturePtr>& theFeatures)
542 FeaturePtr anOwner = ModelAPI_Feature::feature(theAttribute->owner());
544 theFeatures.insert(anOwner);
547 void PlaneGCSSolver_Storage::refresh() const
549 const double aTol = 1000. * tolerance; // tolerance to prevent frequent updates
551 std::set<FeaturePtr> anUpdatedFeatures;
553 std::map<AttributePtr, EntityWrapperPtr>::const_iterator anIt = myAttributeMap.begin();
554 for (; anIt != myAttributeMap.end(); ++anIt) {
555 if (!anIt->first->isInitialized())
558 // the external feature always should keep the up to date values, so,
559 // refresh from the solver is never needed
560 if (isExternalAttribute(anIt->first))
563 std::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
564 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anIt->first);
566 std::shared_ptr<PlaneGCSSolver_PointWrapper> aPointWrapper =
567 std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(anIt->second);
568 GCSPointPtr aGCSPoint = aPointWrapper->point();
569 if (fabs(aPoint2D->x() - (*aGCSPoint->x)) > aTol ||
570 fabs(aPoint2D->y() - (*aGCSPoint->y)) > aTol) {
571 aPoint2D->setValue(*aGCSPoint->x, *aGCSPoint->y);
572 addOwnerToSet(anIt->first, anUpdatedFeatures);
576 AttributeDoublePtr aScalar = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(anIt->first);
578 ScalarWrapperPtr aScalarWrapper =
579 std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(anIt->second);
580 if (fabs(aScalar->value() - aScalarWrapper->value()) > aTol) {
581 aScalar->setValue(aScalarWrapper->value());
582 addOwnerToSet(anIt->first, anUpdatedFeatures);
588 // notify listeners about features update
589 std::set<FeaturePtr>::const_iterator aFIt = anUpdatedFeatures.begin();
590 for (; aFIt != anUpdatedFeatures.end(); ++aFIt)
594 PlaneGCSSolver_Solver::SolveStatus PlaneGCSSolver_Storage::checkDegeneratedGeometry() const
596 std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFIt = myFeatureMap.begin();
597 for (; aFIt != myFeatureMap.end(); ++aFIt) {
598 EdgeWrapperPtr anEdge = std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(aFIt->second);
599 if (anEdge && anEdge->isDegenerated())
600 return PlaneGCSSolver_Solver::STATUS_DEGENERATED;
602 return PlaneGCSSolver_Solver::STATUS_OK;