1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_Group.cpp
4 // Created: 27 May 2014
5 // Author: Artem ZHIDKOV
7 #include "SketchSolver_Group.h"
9 #include <SketchSolver_Constraint.h>
10 #include <SketchSolver_ConstraintCoincidence.h>
11 #include <SketchSolver_ConstraintMulti.h>
12 #include <SketchSolver_Error.h>
13 #include <SketchSolver_Manager.h>
15 #include <Events_Error.h>
16 #include <Events_Loop.h>
17 #include <ModelAPI_AttributeString.h>
18 #include <ModelAPI_Events.h>
19 #include <ModelAPI_Session.h>
20 #include <ModelAPI_Validator.h>
22 #include <SketchPlugin_ConstraintAngle.h>
23 #include <SketchPlugin_ConstraintCoincidence.h>
24 #include <SketchPlugin_ConstraintDistance.h>
25 #include <SketchPlugin_ConstraintEqual.h>
26 #include <SketchPlugin_ConstraintHorizontal.h>
27 #include <SketchPlugin_ConstraintLength.h>
28 #include <SketchPlugin_ConstraintFillet.h>
29 #include <SketchPlugin_ConstraintMirror.h>
30 #include <SketchPlugin_ConstraintParallel.h>
31 #include <SketchPlugin_ConstraintPerpendicular.h>
32 #include <SketchPlugin_ConstraintRadius.h>
33 #include <SketchPlugin_ConstraintRigid.h>
34 #include <SketchPlugin_ConstraintTangent.h>
35 #include <SketchPlugin_ConstraintVertical.h>
36 #include <SketchPlugin_MultiRotation.h>
37 #include <SketchPlugin_MultiTranslation.h>
43 /// \brief This class is used to give unique index to the groups
47 /// \brief Return vacant index
48 static GroupID NEW_GROUP() { return ++myGroupIndex; }
49 /// \brief Removes the index
50 static void REMOVE_GROUP(const GroupID& theIndex) {
51 if (myGroupIndex == theIndex)
58 static GroupID myGroupIndex; ///< index of the group
61 GroupID GroupIndexer::myGroupIndex = GID_OUTOFGROUP;
64 static void sendMessage(const char* theMessageName)
66 std::shared_ptr<Events_Message> aMessage = std::shared_ptr<Events_Message>(
67 new Events_Message(Events_Loop::eventByName(theMessageName)));
68 Events_Loop::loop()->send(aMessage);
73 // ========================================================
74 // ========= SketchSolver_Group ===============
75 // ========================================================
77 SketchSolver_Group::SketchSolver_Group(
78 std::shared_ptr<ModelAPI_CompositeFeature> theWorkplane)
79 : myID(GroupIndexer::NEW_GROUP()),
82 // Initialize workplane
83 myWorkplaneID = EID_UNKNOWN;
84 addWorkplane(theWorkplane);
87 SketchSolver_Group::~SketchSolver_Group()
89 myConstraints.clear();
90 GroupIndexer::REMOVE_GROUP(myID);
93 // ============================================================================
94 // Function: isBaseWorkplane
95 // Class: SketchSolver_Group
96 // Purpose: verify the group is based on the given workplane
97 // ============================================================================
98 bool SketchSolver_Group::isBaseWorkplane(CompositeFeaturePtr theWorkplane) const
100 return theWorkplane == mySketch;
103 // ============================================================================
104 // Function: isInteract
105 // Class: SketchSolver_Group
106 // Purpose: verify are there any entities in the group used by given constraint
107 // ============================================================================
108 bool SketchSolver_Group::isInteract(FeaturePtr theFeature) const
110 // Empty group interacts with everything
113 // Check interaction with the storage
114 return myStorage->isInteract(theFeature);
117 // ============================================================================
118 // Function: changeConstraint
119 // Class: SketchSolver_Group
120 // Purpose: create/update the constraint in the group
121 // ============================================================================
122 bool SketchSolver_Group::changeConstraint(
123 std::shared_ptr<SketchPlugin_Constraint> theConstraint)
125 // There is no workplane yet, something wrong
126 if (myWorkplaneID == EID_UNKNOWN)
129 if (!theConstraint || !theConstraint->data())
132 if (!checkFeatureValidity(theConstraint))
135 BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
137 bool isNewConstraint = myConstraints.find(theConstraint) == myConstraints.end();
138 if (isNewConstraint) {
139 // Add constraint to the current group
140 SolverConstraintPtr aConstraint = aBuilder->createConstraint(theConstraint);
143 aConstraint->process(myStorage, getId(), getWorkplaneId());
144 if (!aConstraint->error().empty()) {
145 if (aConstraint->error() == SketchSolver_Error::NOT_INITIALIZED())
146 return false; // some attribute are not initialized yet, don't show message
147 Events_Error::send(aConstraint->error(), this);
149 myConstraints[theConstraint] = aConstraint;
152 myConstraints[theConstraint]->update();
155 if (theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID()) {
156 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
157 theConstraint->attribute(SketchPlugin_ConstraintMirror::ENTITY_A()));
158 if (aRefAttr && aRefAttr->isObject()) {
159 std::shared_ptr<SketchPlugin_Feature> aFeature =
160 std::dynamic_pointer_cast<SketchPlugin_Feature>(
161 ModelAPI_Feature::feature(aRefAttr->object()));
163 SolverConstraintPtr aConstraint = aBuilder->createFixedConstraint(aFeature);
165 aConstraint->process(myStorage, getId(), getWorkplaneId());
166 setTemporary(aConstraint);
175 void SketchSolver_Group::updateConstraints()
177 std::set<SolverConstraintPtr> aPostponed; // postponed constraints Multi-Rotation and Multi-Translation
179 ConstraintConstraintMap::iterator anIt = myConstraints.begin();
180 for (; anIt != myConstraints.end(); ++anIt) {
181 if (myChangedConstraints.find(anIt->first) == myChangedConstraints.end())
183 if (anIt->first->getKind() == SketchPlugin_MultiRotation::ID() ||
184 anIt->first->getKind() == SketchPlugin_MultiTranslation::ID())
185 aPostponed.insert(anIt->second);
187 anIt->second->update();
190 // Update postponed constraints
191 std::set<SolverConstraintPtr>::iterator aSCIter = aPostponed.begin();
192 for (; aSCIter != aPostponed.end(); ++aSCIter)
193 (*aSCIter)->update();
195 myChangedConstraints.clear();
198 bool SketchSolver_Group::updateFeature(FeaturePtr theFeature)
200 if (!checkFeatureValidity(theFeature))
203 myStorage->refresh(true);
204 return myStorage->update(theFeature);
207 void SketchSolver_Group::moveFeature(FeaturePtr theFeature)
209 BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
211 // Firstly, revert changes in the fixed entities
212 myStorage->refresh(true);
214 // Secondly, search attributes of the feature in the list of the Multi constraints and update them
215 ConstraintConstraintMap::iterator aCIt = myConstraints.begin();
216 for (; aCIt != myConstraints.end(); ++aCIt) {
217 if ((aCIt->second->getType() == CONSTRAINT_MULTI_ROTATION ||
218 aCIt->second->getType() == CONSTRAINT_MULTI_TRANSLATION)
219 && aCIt->second->isUsed(theFeature))
220 std::dynamic_pointer_cast<SketchSolver_ConstraintMulti>(aCIt->second)->update(true);
223 // Then, create temporary rigid constraint
224 SolverConstraintPtr aConstraint = aBuilder->createMovementConstraint(theFeature);
227 aConstraint->process(myStorage, getId(), getWorkplaneId());
228 if (aConstraint->error().empty())
229 setTemporary(aConstraint);
232 // ============================================================================
233 // Function: addWorkplane
234 // Class: SketchSolver_Group
235 // Purpose: create workplane for the group
236 // ============================================================================
237 bool SketchSolver_Group::addWorkplane(CompositeFeaturePtr theSketch)
239 if (myWorkplaneID != EID_UNKNOWN || theSketch->getKind() != SketchPlugin_Sketch::ID())
240 return false; // the workplane already exists or the function parameter is not Sketch
242 mySketch = theSketch;
243 if (!updateWorkplane()) {
244 mySketch = CompositeFeaturePtr();
250 // ============================================================================
251 // Function: updateWorkplane
252 // Class: SketchSolver_Group
253 // Purpose: update parameters of workplane
254 // ============================================================================
255 bool SketchSolver_Group::updateWorkplane()
257 BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
258 if (!myStorage) // Create storage if not exists
259 myStorage = aBuilder->createStorage(getId());
261 // sketch should be unchanged, set it out of current group
262 bool isUpdated = myStorage->update(FeaturePtr(mySketch), GID_OUTOFGROUP);
264 EntityWrapperPtr anEntity = myStorage->entity(FeaturePtr(mySketch));
265 myWorkplaneID = anEntity->id();
270 // ============================================================================
271 // Function: resolveConstraints
272 // Class: SketchSolver_Group
273 // Purpose: solve the set of constraints for the current group
274 // ============================================================================
275 bool SketchSolver_Group::resolveConstraints()
277 if (!myChangedConstraints.empty())
280 bool aResolved = false;
281 bool isGroupEmpty = isEmpty();
282 if (myStorage->isNeedToResolve() && !isGroupEmpty) {
284 mySketchSolver = SketchSolver_Manager::instance()->builder()->createSolver();
286 mySketchSolver->setGroup(myID);
287 mySketchSolver->calculateFailedConstraints(false);
288 myStorage->initializeSolver(mySketchSolver);
290 SketchSolver_SolveStatus aResult = STATUS_OK;
292 if (myStorage->hasDuplicatedConstraint())
293 aResult = STATUS_INCONSISTENT;
295 // To avoid overconstraint situation, we will remove temporary constraints one-by-one
296 // and try to find the case without overconstraint
297 bool isLastChance = false;
298 size_t aNbTemp = myStorage->nbTemporary();
300 aResult = mySketchSolver->solve();
301 if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET || isLastChance)
304 // try to update parameters and resolve once again
305 ConstraintConstraintMap::iterator aConstrIt = myConstraints.begin();
306 for (; aConstrIt != myConstraints.end(); ++aConstrIt)
307 aConstrIt->second->update();
310 aNbTemp = myStorage->removeTemporary();
311 mySketchSolver->calculateFailedConstraints(true); // something failed => need to find it
312 myStorage->initializeSolver(mySketchSolver);
316 // Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this);
317 getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::SOLVESPACE_CRASH());
319 // the error message should be changed before sending the message
320 sendMessage(EVENT_SOLVER_FAILED);
321 myPrevSolved = false;
325 if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET) { // solution succeeded, store results into correspondent attributes
326 myStorage->refresh();
328 getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue("");
329 // the error message should be changed before sending the message
330 sendMessage(EVENT_SOLVER_REPAIRED);
333 } else if (!myConstraints.empty()) {
334 // Events_Error::send(SketchSolver_Error::CONSTRAINTS(), this);
335 getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::CONSTRAINTS());
337 // the error message should be changed before sending the message
338 sendMessage(EVENT_SOLVER_FAILED);
339 myPrevSolved = false;
344 } else if (!isGroupEmpty) {
345 // Check there are constraints Fixed. If they exist, update parameters by stored values
346 ConstraintConstraintMap::iterator aCIt = myConstraints.begin();
347 for (; aCIt != myConstraints.end(); ++aCIt)
348 if (aCIt->first->getKind() == SketchPlugin_ConstraintRigid::ID()) {
352 if (aCIt != myConstraints.end())
353 myStorage->refresh();
355 removeTemporaryConstraints();
356 myStorage->setNeedToResolve(false);
360 // ============================================================================
361 // Function: mergeGroups
362 // Class: SketchSolver_Group
363 // Purpose: append specified group to the current group
364 // ============================================================================
365 void SketchSolver_Group::mergeGroups(const SketchSolver_Group& theGroup)
367 // If specified group is empty, no need to merge
368 if (theGroup.isEmpty())
371 std::set<ObjectPtr> aConstraints;
372 ConstraintConstraintMap::const_iterator aConstrIter = theGroup.myConstraints.begin();
373 for (; aConstrIter != theGroup.myConstraints.end(); aConstrIter++)
374 aConstraints.insert(aConstrIter->first);
376 std::list<FeaturePtr> aSortedConstraints = selectApplicableFeatures(aConstraints);
377 std::list<FeaturePtr>::iterator aSCIter = aSortedConstraints.begin();
378 for (; aSCIter != aSortedConstraints.end(); ++aSCIter) {
379 ConstraintPtr aConstr = std::dynamic_pointer_cast<SketchPlugin_Constraint>(*aSCIter);
382 changeConstraint(aConstr);
386 // ============================================================================
387 // Function: splitGroup
388 // Class: SketchSolver_Group
389 // Purpose: divide the group into several subgroups
390 // ============================================================================
391 void SketchSolver_Group::splitGroup(std::list<SketchSolver_Group*>& theCuts)
393 // New storage will be used in trimmed way to store the list of constraint interacted together.
394 StoragePtr aNewStorage = SketchSolver_Manager::instance()->builder()->createStorage(getId());
395 std::list<ConstraintWrapperPtr> aDummyVec; // empty vector to avoid creation of solver's constraints
397 // Obtain constraints, which should be separated
398 std::list<ConstraintPtr> anUnusedConstraints;
399 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
400 for ( ; aCIter != myConstraints.end(); aCIter++) {
401 if (aNewStorage->isInteract(FeaturePtr(aCIter->first)))
402 aNewStorage->addConstraint(aCIter->first, aDummyVec);
404 anUnusedConstraints.push_back(aCIter->first);
407 // Check the unused constraints once again, because they may become interacted with new storage since adding constraints
408 std::list<ConstraintPtr>::iterator aUnuseIt = anUnusedConstraints.begin();
409 while (aUnuseIt != anUnusedConstraints.end()) {
410 if (aNewStorage->isInteract(FeaturePtr(*aUnuseIt))) {
411 aNewStorage->addConstraint(*aUnuseIt, aDummyVec);
412 anUnusedConstraints.erase(aUnuseIt);
413 aUnuseIt = anUnusedConstraints.begin();
419 std::list<SketchSolver_Group*>::iterator aCutsIter;
420 aUnuseIt = anUnusedConstraints.begin();
421 for ( ; aUnuseIt != anUnusedConstraints.end(); ++aUnuseIt) {
422 // Remove unused constraints
423 removeConstraint(*aUnuseIt);
424 // Try to append constraint to already existent group
425 for (aCutsIter = theCuts.begin(); aCutsIter != theCuts.end(); ++aCutsIter)
426 if ((*aCutsIter)->isInteract(*aUnuseIt)) {
427 (*aCutsIter)->changeConstraint(*aUnuseIt);
430 if (aCutsIter == theCuts.end()) {
432 SketchSolver_Group* aGroup = new SketchSolver_Group(mySketch);
433 aGroup->changeConstraint(*aUnuseIt);
434 theCuts.push_back(aGroup);
436 // Find other groups interacting with constraint
437 std::list<SketchSolver_Group*>::iterator aBaseGroupIt = aCutsIter;
438 for (++aCutsIter; aCutsIter != theCuts.end(); ++aCutsIter)
439 if ((*aCutsIter)->isInteract(*aUnuseIt)) {
440 (*aBaseGroupIt)->mergeGroups(**aCutsIter);
441 std::list<SketchSolver_Group*>::iterator aRemoveIt = aCutsIter--;
442 theCuts.erase(aRemoveIt);
448 // ============================================================================
449 // Function: isConsistent
450 // Class: SketchSolver_Group
451 // Purpose: search removed entities and constraints
452 // ============================================================================
453 bool SketchSolver_Group::isConsistent()
455 if (isEmpty()) // no one constraint is initialized yet
458 // Check the features and constraint is the storage are valid
459 bool aResult = myStorage->isConsistent();
461 // additional check of consistency of the Fixed constraint,
462 // because they are not added to the storage
463 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
464 for (; aCIter != myConstraints.end(); ++aCIter)
465 if (aCIter->first->getKind() == SketchPlugin_ConstraintRigid::ID() &&
466 (!aCIter->first->data() || !aCIter->first->data()->isValid())) {
472 // remove invalid constraints
473 std::set<ConstraintPtr> anInvalidConstraints;
474 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
475 for (; aCIter != myConstraints.end(); ++aCIter) {
476 if (!aCIter->first->data() || !aCIter->first->data()->isValid())
477 anInvalidConstraints.insert(aCIter->first);
479 std::set<ConstraintPtr>::const_iterator aRemoveIt = anInvalidConstraints.begin();
480 for (; aRemoveIt != anInvalidConstraints.end(); ++aRemoveIt)
481 removeConstraint(*aRemoveIt);
482 // remove invalid features
483 myStorage->removeInvalidEntities();
488 // ============================================================================
489 // Function: removeTemporaryConstraints
490 // Class: SketchSolver_Group
491 // Purpose: remove all transient SLVS_C_WHERE_DRAGGED constraints after
492 // resolving the set of constraints
493 // ============================================================================
494 void SketchSolver_Group::removeTemporaryConstraints()
496 std::set<SolverConstraintPtr>::iterator aTmpIt = myTempConstraints.begin();
497 for (; aTmpIt != myTempConstraints.end(); ++aTmpIt)
500 size_t aNbTemp = myStorage->nbTemporary();
502 myStorage->removeTemporary(aNbTemp);
504 if (!myTempConstraints.empty())
505 myStorage->verifyFixed();
506 myStorage->setNeedToResolve(false);
507 myTempConstraints.clear();
510 // ============================================================================
511 // Function: removeConstraint
512 // Class: SketchSolver_Group
513 // Purpose: remove constraint and all unused entities
514 // ============================================================================
515 void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint)
517 bool isFullyRemoved = true;
518 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
519 for (; aCIter != myConstraints.end(); aCIter++)
520 if (aCIter->first == theConstraint) {
521 if (!aCIter->second->remove()) // the constraint is not fully removed
522 isFullyRemoved = false;
525 if (aCIter == myConstraints.end())
529 myConstraints.erase(aCIter);
530 else if (aCIter != myConstraints.end() &&
531 aCIter->first->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
532 // Update multicoincidence
533 std::list<ConstraintPtr> aMultiCoinc;
534 SolverConstraintPtr aCoincidence = aCIter->second;
535 while (aCIter != myConstraints.end()) {
536 if (aCIter->second != aCoincidence) {
540 if (aCIter->first != theConstraint)
541 aMultiCoinc.push_back(aCIter->first);
542 aCIter->second->remove();
543 ConstraintConstraintMap::iterator aRemoveIt = aCIter++;
544 myConstraints.erase(aRemoveIt);
547 std::list<ConstraintPtr>::iterator anIt = aMultiCoinc.begin();
548 for (; anIt != aMultiCoinc.end(); ++anIt)
549 changeConstraint(*anIt);
553 // ============================================================================
554 // Function: isComplexConstraint
555 // Class: SketchSolver_Group
556 // Purpose: verifies the constraint is complex, i.e. it needs another constraints to be created before
557 // ============================================================================
558 bool SketchSolver_Group::isComplexConstraint(FeaturePtr theConstraint)
560 return theConstraint->getKind() == SketchPlugin_ConstraintFillet::ID() ||
561 theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID() ||
562 theConstraint->getKind() == SketchPlugin_ConstraintTangent::ID();
565 // ============================================================================
566 // Function: setTemporary
567 // Class: SketchSolver_Group
568 // Purpose: append given constraint to the group of temporary constraints
569 // ============================================================================
570 void SketchSolver_Group::setTemporary(SolverConstraintPtr theConstraint)
572 theConstraint->makeTemporary();
573 myTempConstraints.insert(theConstraint);
577 // ============================================================================
578 // Function: checkFeatureValidity
579 // Class: SketchSolver_Group
580 // Purpose: verifies is the feature valid
581 // ============================================================================
582 bool SketchSolver_Group::checkFeatureValidity(FeaturePtr theFeature)
584 if (!theFeature || !theFeature->data()->isValid())
587 SessionPtr aMgr = ModelAPI_Session::get();
588 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
589 return aFactory->validate(theFeature);
595 // =========== Auxiliary functions ========================================
596 static double featureToVal(FeaturePtr theFeature)
598 if (theFeature->getKind() == SketchPlugin_Sketch::ID())
599 return 0.0; // sketch
600 ConstraintPtr aConstraint = std::dynamic_pointer_cast<SketchPlugin_Constraint>(theFeature);
602 return 1.0; // features (arc, circle, line, point)
604 const std::string& anID = aConstraint->getKind();
605 if (anID == SketchPlugin_ConstraintCoincidence::ID()) {
606 AttributeRefAttrPtr anAttrA = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
607 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
608 AttributeRefAttrPtr anAttrB = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
609 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
610 if (anAttrA && anAttrB && (anAttrA->isObject() || anAttrB->isObject()))
611 return 2.0; // point-on-line and point-on-circle should go before points coincidence constraint
614 if (anID == SketchPlugin_ConstraintDistance::ID() ||
615 anID == SketchPlugin_ConstraintLength::ID() ||
616 anID == SketchPlugin_ConstraintRadius::ID())
618 if (anID == SketchPlugin_ConstraintAngle::ID())
620 if (anID == SketchPlugin_ConstraintHorizontal::ID() ||
621 anID == SketchPlugin_ConstraintVertical::ID() ||
622 anID == SketchPlugin_ConstraintParallel::ID() ||
623 anID == SketchPlugin_ConstraintPerpendicular::ID())
625 if (anID == SketchPlugin_ConstraintEqual::ID())
627 if (anID == SketchPlugin_ConstraintTangent::ID() ||
628 anID == SketchPlugin_ConstraintMirror::ID())
630 if (anID == SketchPlugin_ConstraintRigid::ID())
632 if (anID == SketchPlugin_MultiRotation::ID() ||
633 anID == SketchPlugin_MultiTranslation::ID())
636 // all other constraints are placed between Equal and Tangent constraints
640 static bool isLess(FeaturePtr theFeature1, FeaturePtr theFeature2)
642 return featureToVal(theFeature1) < featureToVal(theFeature2);
645 std::list<FeaturePtr> SketchSolver_Group::selectApplicableFeatures(const std::set<ObjectPtr>& theObjects)
647 std::list<FeaturePtr> aResult;
648 std::list<FeaturePtr>::iterator aResIt;
650 std::set<ObjectPtr>::const_iterator anObjIter = theObjects.begin();
651 for (; anObjIter != theObjects.end(); ++anObjIter) {
652 // Operate sketch itself and SketchPlugin features only.
653 // Also, the Fillet need to be skipped, because there are several separated constraints composing it.
654 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anObjIter);
657 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
658 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
659 if ((aFeature->getKind() != SketchPlugin_Sketch::ID() && !aSketchFeature) ||
660 aFeature->getKind() == SketchPlugin_ConstraintFillet::ID())
663 // Find the place where to insert a feature
664 for (aResIt = aResult.begin(); aResIt != aResult.end(); ++aResIt)
665 if (isLess(aFeature, *aResIt))
667 aResult.insert(aResIt, aFeature);