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_Arc.h>
23 #include <SketchPlugin_ConstraintAngle.h>
24 #include <SketchPlugin_ConstraintCoincidence.h>
25 #include <SketchPlugin_ConstraintDistance.h>
26 #include <SketchPlugin_ConstraintEqual.h>
27 #include <SketchPlugin_ConstraintHorizontal.h>
28 #include <SketchPlugin_ConstraintLength.h>
29 #include <SketchPlugin_ConstraintFillet.h>
30 #include <SketchPlugin_ConstraintMirror.h>
31 #include <SketchPlugin_ConstraintParallel.h>
32 #include <SketchPlugin_ConstraintPerpendicular.h>
33 #include <SketchPlugin_ConstraintRadius.h>
34 #include <SketchPlugin_ConstraintRigid.h>
35 #include <SketchPlugin_ConstraintTangent.h>
36 #include <SketchPlugin_ConstraintVertical.h>
37 #include <SketchPlugin_MultiRotation.h>
38 #include <SketchPlugin_MultiTranslation.h>
44 /// \brief This class is used to give unique index to the groups
48 /// \brief Return vacant index
49 static GroupID NEW_GROUP() { return ++myGroupIndex; }
50 /// \brief Removes the index
51 static void REMOVE_GROUP(const GroupID& theIndex) {
52 if (myGroupIndex == theIndex)
59 static GroupID myGroupIndex; ///< index of the group
62 GroupID GroupIndexer::myGroupIndex = GID_OUTOFGROUP;
65 static void sendMessage(const char* theMessageName)
67 std::shared_ptr<Events_Message> aMessage = std::shared_ptr<Events_Message>(
68 new Events_Message(Events_Loop::eventByName(theMessageName)));
69 Events_Loop::loop()->send(aMessage);
72 static void sendMessage(const char* theMessageName, const std::set<ObjectPtr>& theConflicting)
74 std::shared_ptr<ModelAPI_SolverFailedMessage> aMessage =
75 std::shared_ptr<ModelAPI_SolverFailedMessage>(
76 new ModelAPI_SolverFailedMessage(Events_Loop::eventByName(theMessageName)));
77 aMessage->setObjects(theConflicting);
78 Events_Loop::loop()->send(aMessage);
83 // ========================================================
84 // ========= SketchSolver_Group ===============
85 // ========================================================
87 SketchSolver_Group::SketchSolver_Group(
88 std::shared_ptr<ModelAPI_CompositeFeature> theWorkplane)
89 : myID(GroupIndexer::NEW_GROUP()),
90 myPrevResult(STATUS_UNKNOWN)
92 // Initialize workplane
93 myWorkplaneID = EID_UNKNOWN;
94 addWorkplane(theWorkplane);
97 SketchSolver_Group::~SketchSolver_Group()
99 myConstraints.clear();
100 GroupIndexer::REMOVE_GROUP(myID);
103 // ============================================================================
104 // Function: isBaseWorkplane
105 // Class: SketchSolver_Group
106 // Purpose: verify the group is based on the given workplane
107 // ============================================================================
108 bool SketchSolver_Group::isBaseWorkplane(CompositeFeaturePtr theWorkplane) const
110 return theWorkplane == mySketch;
113 // ============================================================================
114 // Function: isInteract
115 // Class: SketchSolver_Group
116 // Purpose: verify are there any entities in the group used by given constraint
117 // ============================================================================
118 bool SketchSolver_Group::isInteract(FeaturePtr theFeature) const
120 // Empty group interacts with everything
123 // Check interaction with the storage
124 return myStorage->isInteract(theFeature);
127 // ============================================================================
128 // Function: changeConstraint
129 // Class: SketchSolver_Group
130 // Purpose: create/update the constraint in the group
131 // ============================================================================
132 bool SketchSolver_Group::changeConstraint(
133 std::shared_ptr<SketchPlugin_Constraint> theConstraint)
135 // There is no workplane yet, something wrong
136 if (myWorkplaneID == EID_UNKNOWN)
139 if (!theConstraint || !theConstraint->data())
142 if (!checkFeatureValidity(theConstraint))
145 BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
146 myStorage->blockEvents(true);
148 bool isNewConstraint = myConstraints.find(theConstraint) == myConstraints.end();
149 if (isNewConstraint) {
150 // Add constraint to the current group
151 SolverConstraintPtr aConstraint = aBuilder->createConstraint(theConstraint);
154 aConstraint->process(myStorage, getId(), getWorkplaneId());
155 if (!aConstraint->error().empty()) {
156 if (aConstraint->error() == SketchSolver_Error::NOT_INITIALIZED())
157 return false; // some attribute are not initialized yet, don't show message
158 Events_Error::send(aConstraint->error(), this);
160 myConstraints[theConstraint] = aConstraint;
163 myConstraints[theConstraint]->update();
166 if (theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID()) {
167 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
168 theConstraint->attribute(SketchPlugin_ConstraintMirror::ENTITY_A()));
169 if (aRefAttr && aRefAttr->isObject()) {
170 std::shared_ptr<SketchPlugin_Feature> aFeature =
171 std::dynamic_pointer_cast<SketchPlugin_Feature>(
172 ModelAPI_Feature::feature(aRefAttr->object()));
174 SolverConstraintPtr aConstraint = aBuilder->createFixedConstraint(aFeature);
176 aConstraint->process(myStorage, getId(), getWorkplaneId());
177 setTemporary(aConstraint);
185 static void updateMultiConstraints(ConstraintConstraintMap& theConstraints, FeaturePtr theFeature)
187 ConstraintConstraintMap::iterator aCIt = theConstraints.begin();
188 for (; aCIt != theConstraints.end(); ++aCIt) {
189 SketchSolver_ConstraintType aType = aCIt->second->getType();
190 if ((aType == CONSTRAINT_MULTI_ROTATION ||
191 aType == CONSTRAINT_MULTI_TRANSLATION)
192 && aCIt->second->isUsed(theFeature))
193 std::dynamic_pointer_cast<SketchSolver_ConstraintMulti>(aCIt->second)->update(true);
194 else if ((aType == CONSTRAINT_TANGENT_CIRCLE_LINE ||
195 aType == CONSTRAINT_SYMMETRIC)
196 && aCIt->second->isUsed(theFeature))
197 aCIt->second->update();
201 bool SketchSolver_Group::updateFeature(FeaturePtr theFeature)
203 if (!checkFeatureValidity(theFeature))
206 bool isBlocked = myStorage->isEventsBlocked();
208 myStorage->blockEvents(true);
210 myStorage->refresh(true);
211 bool isUpdated = myStorage->update(theFeature);
213 updateMultiConstraints(myConstraints, theFeature);
215 // events were not blocked before, the feature has not been updated,
216 // so it is necessary to revert blocking
217 if (!isUpdated && !isBlocked)
218 myStorage->blockEvents(false);
222 void SketchSolver_Group::moveFeature(FeaturePtr theFeature)
224 BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
226 // Firstly, revert changes in the fixed entities
227 myStorage->blockEvents(true);
228 myStorage->refresh(true);
230 // Then, create temporary Fixed constraint
231 SolverConstraintPtr aConstraint = aBuilder->createMovementConstraint(theFeature);
234 aConstraint->process(myStorage, getId(), getWorkplaneId());
235 if (aConstraint->error().empty())
236 setTemporary(aConstraint);
238 // Secondly, search attributes of the feature in the list of the Multi constraints and update them
239 updateMultiConstraints(myConstraints, theFeature);
241 // Workaround to process arcs.
242 // When move unconstrained arc, add temporary constraint to fix radius.
243 if (theFeature->getKind() == SketchPlugin_Arc::ID()) {
244 SolverConstraintPtr aFixedRadius = aBuilder->createFixedArcRadiusConstraint(theFeature);
246 aFixedRadius->process(myStorage, getId(), getWorkplaneId());
247 if (aFixedRadius->error().empty())
248 setTemporary(aFixedRadius);
253 // ============================================================================
254 // Function: addWorkplane
255 // Class: SketchSolver_Group
256 // Purpose: create workplane for the group
257 // ============================================================================
258 bool SketchSolver_Group::addWorkplane(CompositeFeaturePtr theSketch)
260 if (myWorkplaneID != EID_UNKNOWN || theSketch->getKind() != SketchPlugin_Sketch::ID())
261 return false; // the workplane already exists or the function parameter is not Sketch
263 mySketch = theSketch;
264 if (!updateWorkplane()) {
265 mySketch = CompositeFeaturePtr();
271 // ============================================================================
272 // Function: updateWorkplane
273 // Class: SketchSolver_Group
274 // Purpose: update parameters of workplane
275 // ============================================================================
276 bool SketchSolver_Group::updateWorkplane()
278 BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
279 if (!myStorage) // Create storage if not exists
280 myStorage = aBuilder->createStorage(getId());
282 // sketch should be unchanged, set it out of current group
283 bool isUpdated = myStorage->update(FeaturePtr(mySketch), GID_OUTOFGROUP);
285 EntityWrapperPtr anEntity = myStorage->entity(FeaturePtr(mySketch));
286 myWorkplaneID = anEntity->id();
291 // ============================================================================
292 // Function: resolveConstraints
293 // Class: SketchSolver_Group
294 // Purpose: solve the set of constraints for the current group
295 // ============================================================================
296 bool SketchSolver_Group::resolveConstraints()
298 bool aResolved = false;
299 bool isGroupEmpty = isEmpty() && myStorage->isEmpty();
300 if (myStorage->isNeedToResolve() && !isGroupEmpty) {
302 mySketchSolver = SketchSolver_Manager::instance()->builder()->createSolver();
304 mySketchSolver->setGroup(myID);
305 mySketchSolver->calculateFailedConstraints(false);
306 myStorage->initializeSolver(mySketchSolver);
307 mySketchSolver->prepare();
309 SketchSolver_SolveStatus aResult = STATUS_OK;
311 if (myStorage->hasDuplicatedConstraint())
312 aResult = STATUS_INCONSISTENT;
314 // To avoid overconstraint situation, we will remove temporary constraints one-by-one
315 // and try to find the case without overconstraint
316 bool isLastChance = false;
318 aResult = mySketchSolver->solve();
319 if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET || isLastChance)
321 //// // try to update parameters and resolve once again
322 //// ConstraintConstraintMap::iterator aConstrIt = myConstraints.begin();
323 //// for (; aConstrIt != myConstraints.end(); ++aConstrIt)
324 //// aConstrIt->second->update();
327 removeTemporaryConstraints();
328 mySketchSolver->calculateFailedConstraints(true); // something failed => need to find it
329 myStorage->initializeSolver(mySketchSolver);
333 // Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this);
334 getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::SOLVESPACE_CRASH());
335 if (myPrevResult == STATUS_OK || myPrevResult == STATUS_UNKNOWN) {
336 // the error message should be changed before sending the message
337 sendMessage(EVENT_SOLVER_FAILED);
338 myPrevResult = STATUS_FAILED;
340 mySketchSolver->undo();
343 if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET) { // solution succeeded, store results into correspondent attributes
344 myStorage->refresh();
345 if (myPrevResult != STATUS_OK || myPrevResult == STATUS_UNKNOWN) {
346 getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue("");
347 // the error message should be changed before sending the message
348 sendMessage(EVENT_SOLVER_REPAIRED);
349 myPrevResult = STATUS_OK;
352 mySketchSolver->undo();
353 if (!myConstraints.empty()) {
354 // Events_Error::send(SketchSolver_Error::CONSTRAINTS(), this);
355 getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::CONSTRAINTS());
356 if (myPrevResult != aResult || myPrevResult == STATUS_UNKNOWN) {
357 // Obtain list of conflicting constraints
358 std::set<ObjectPtr> aConflicting = myStorage->getConflictingConstraints(mySketchSolver);
360 // the error message should be changed before sending the message
361 sendMessage(EVENT_SOLVER_FAILED, aConflicting);
362 myPrevResult = aResult;
368 } else if (!isGroupEmpty) {
369 // Check there are constraints Fixed. If they exist, update parameters by stored values
370 ConstraintConstraintMap::iterator aCIt = myConstraints.begin();
371 for (; aCIt != myConstraints.end(); ++aCIt)
372 if (aCIt->first->getKind() == SketchPlugin_ConstraintRigid::ID()) {
376 if (aCIt != myConstraints.end())
377 myStorage->refresh();
379 removeTemporaryConstraints();
380 myStorage->blockEvents(false);
381 myStorage->setNeedToResolve(false);
385 // ============================================================================
386 // Function: mergeGroups
387 // Class: SketchSolver_Group
388 // Purpose: append specified group to the current group
389 // ============================================================================
390 void SketchSolver_Group::mergeGroups(const SketchSolver_Group& theGroup)
392 // If specified group is empty, no need to merge
393 if (theGroup.isEmpty())
396 std::set<ObjectPtr> aConstraints;
397 ConstraintConstraintMap::const_iterator aConstrIter = theGroup.myConstraints.begin();
398 for (; aConstrIter != theGroup.myConstraints.end(); aConstrIter++)
399 aConstraints.insert(aConstrIter->first);
401 std::list<FeaturePtr> aSortedConstraints = selectApplicableFeatures(aConstraints);
402 std::list<FeaturePtr>::iterator aSCIter = aSortedConstraints.begin();
403 for (; aSCIter != aSortedConstraints.end(); ++aSCIter) {
404 ConstraintPtr aConstr = std::dynamic_pointer_cast<SketchPlugin_Constraint>(*aSCIter);
407 changeConstraint(aConstr);
411 // ============================================================================
412 // Function: splitGroup
413 // Class: SketchSolver_Group
414 // Purpose: divide the group into several subgroups
415 // ============================================================================
416 void SketchSolver_Group::splitGroup(std::list<SketchSolver_Group*>& theCuts)
418 // New storage will be used in trimmed way to store the list of constraint interacted together.
419 StoragePtr aNewStorage = SketchSolver_Manager::instance()->builder()->createStorage(getId());
420 std::list<ConstraintWrapperPtr> aDummyVec; // empty vector to avoid creation of solver's constraints
422 // Obtain constraints, which should be separated
423 std::list<ConstraintPtr> anUnusedConstraints;
424 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
425 for ( ; aCIter != myConstraints.end(); aCIter++) {
426 if (aNewStorage->isInteract(FeaturePtr(aCIter->first)))
427 aNewStorage->addConstraint(aCIter->first, aDummyVec);
429 anUnusedConstraints.push_back(aCIter->first);
432 // Check the unused constraints once again, because they may become interacted with new storage since adding constraints
433 std::list<ConstraintPtr>::iterator aUnuseIt = anUnusedConstraints.begin();
434 while (aUnuseIt != anUnusedConstraints.end()) {
435 if (aNewStorage->isInteract(FeaturePtr(*aUnuseIt))) {
436 aNewStorage->addConstraint(*aUnuseIt, aDummyVec);
437 anUnusedConstraints.erase(aUnuseIt);
438 aUnuseIt = anUnusedConstraints.begin();
444 std::list<SketchSolver_Group*>::iterator aCutsIter;
445 aUnuseIt = anUnusedConstraints.begin();
446 for ( ; aUnuseIt != anUnusedConstraints.end(); ++aUnuseIt) {
447 // Remove unused constraints
448 removeConstraint(*aUnuseIt);
449 // Try to append constraint to already existent group
450 for (aCutsIter = theCuts.begin(); aCutsIter != theCuts.end(); ++aCutsIter)
451 if ((*aCutsIter)->isInteract(*aUnuseIt)) {
452 (*aCutsIter)->changeConstraint(*aUnuseIt);
455 if (aCutsIter == theCuts.end()) {
457 SketchSolver_Group* aGroup = new SketchSolver_Group(mySketch);
458 aGroup->changeConstraint(*aUnuseIt);
459 theCuts.push_back(aGroup);
461 // Find other groups interacting with constraint
462 std::list<SketchSolver_Group*>::iterator aBaseGroupIt = aCutsIter;
463 for (++aCutsIter; aCutsIter != theCuts.end(); ++aCutsIter)
464 if ((*aCutsIter)->isInteract(*aUnuseIt)) {
465 (*aBaseGroupIt)->mergeGroups(**aCutsIter);
466 std::list<SketchSolver_Group*>::iterator aRemoveIt = aCutsIter--;
467 theCuts.erase(aRemoveIt);
473 // ============================================================================
474 // Function: isConsistent
475 // Class: SketchSolver_Group
476 // Purpose: search removed entities and constraints
477 // ============================================================================
478 bool SketchSolver_Group::isConsistent()
480 if (isEmpty()) // no one constraint is initialized yet
483 // Check the features and constraint is the storage are valid
484 bool aResult = myStorage->isConsistent();
486 // additional check of consistency of the Fixed constraint,
487 // because they are not added to the storage
488 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
489 for (; aCIter != myConstraints.end(); ++aCIter)
490 if (aCIter->first->getKind() == SketchPlugin_ConstraintRigid::ID() &&
491 (!aCIter->first->data() || !aCIter->first->data()->isValid())) {
497 // remove invalid constraints
498 std::set<ConstraintPtr> anInvalidConstraints;
499 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
500 for (; aCIter != myConstraints.end(); ++aCIter) {
501 if (!aCIter->first->data() || !aCIter->first->data()->isValid())
502 anInvalidConstraints.insert(aCIter->first);
504 std::set<ConstraintPtr>::const_iterator aRemoveIt = anInvalidConstraints.begin();
505 for (; aRemoveIt != anInvalidConstraints.end(); ++aRemoveIt)
506 removeConstraint(*aRemoveIt);
507 // remove invalid features
508 myStorage->removeInvalidEntities();
513 // ============================================================================
514 // Function: removeTemporaryConstraints
515 // Class: SketchSolver_Group
516 // Purpose: remove all transient SLVS_C_WHERE_DRAGGED constraints after
517 // resolving the set of constraints
518 // ============================================================================
519 void SketchSolver_Group::removeTemporaryConstraints()
521 std::set<SolverConstraintPtr>::iterator aTmpIt = myTempConstraints.begin();
522 for (; aTmpIt != myTempConstraints.end(); ++aTmpIt)
525 if (!myTempConstraints.empty())
526 myStorage->verifyFixed();
527 myStorage->setNeedToResolve(false);
528 myTempConstraints.clear();
531 // ============================================================================
532 // Function: removeConstraint
533 // Class: SketchSolver_Group
534 // Purpose: remove constraint and all unused entities
535 // ============================================================================
536 void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint)
538 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
539 for (; aCIter != myConstraints.end(); aCIter++)
540 if (aCIter->first == theConstraint) {
541 aCIter->second->remove(); // the constraint is not fully removed
544 if (aCIter != myConstraints.end())
545 myConstraints.erase(aCIter);
548 // ============================================================================
549 // Function: setTemporary
550 // Class: SketchSolver_Group
551 // Purpose: append given constraint to the group of temporary constraints
552 // ============================================================================
553 void SketchSolver_Group::setTemporary(SolverConstraintPtr theConstraint)
555 myTempConstraints.insert(theConstraint);
559 // ============================================================================
560 // Function: checkFeatureValidity
561 // Class: SketchSolver_Group
562 // Purpose: verifies is the feature valid
563 // ============================================================================
564 bool SketchSolver_Group::checkFeatureValidity(FeaturePtr theFeature)
566 if (!theFeature || !theFeature->data()->isValid())
569 SessionPtr aMgr = ModelAPI_Session::get();
570 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
571 return aFactory->validate(theFeature);
577 // =========== Auxiliary functions ========================================
578 static double featureToVal(FeaturePtr theFeature)
580 if (theFeature->getKind() == SketchPlugin_Sketch::ID())
581 return 0.0; // sketch
582 ConstraintPtr aConstraint = std::dynamic_pointer_cast<SketchPlugin_Constraint>(theFeature);
584 return 1.0; // features (arc, circle, line, point)
586 const std::string& anID = aConstraint->getKind();
587 if (anID == SketchPlugin_ConstraintCoincidence::ID()) {
588 AttributeRefAttrPtr anAttrA = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
589 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
590 AttributeRefAttrPtr anAttrB = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
591 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
592 if (anAttrA && anAttrB && (anAttrA->isObject() || anAttrB->isObject()))
593 return 2.0; // point-on-line and point-on-circle should go before points coincidence constraint
596 if (anID == SketchPlugin_ConstraintDistance::ID() ||
597 anID == SketchPlugin_ConstraintLength::ID() ||
598 anID == SketchPlugin_ConstraintRadius::ID())
600 if (anID == SketchPlugin_ConstraintAngle::ID())
602 if (anID == SketchPlugin_ConstraintHorizontal::ID() ||
603 anID == SketchPlugin_ConstraintVertical::ID() ||
604 anID == SketchPlugin_ConstraintParallel::ID() ||
605 anID == SketchPlugin_ConstraintPerpendicular::ID())
607 if (anID == SketchPlugin_ConstraintEqual::ID())
609 if (anID == SketchPlugin_ConstraintTangent::ID() ||
610 anID == SketchPlugin_ConstraintMirror::ID())
612 if (anID == SketchPlugin_ConstraintRigid::ID())
614 if (anID == SketchPlugin_MultiRotation::ID() ||
615 anID == SketchPlugin_MultiTranslation::ID())
618 // all other constraints are placed between Equal and Tangent constraints
622 static bool isLess(FeaturePtr theFeature1, FeaturePtr theFeature2)
624 return featureToVal(theFeature1) < featureToVal(theFeature2);
627 std::list<FeaturePtr> SketchSolver_Group::selectApplicableFeatures(const std::set<ObjectPtr>& theObjects)
629 std::list<FeaturePtr> aResult;
630 std::list<FeaturePtr>::iterator aResIt;
632 std::set<ObjectPtr>::const_iterator anObjIter = theObjects.begin();
633 for (; anObjIter != theObjects.end(); ++anObjIter) {
634 // Operate sketch itself and SketchPlugin features only.
635 // Also, the Fillet need to be skipped, because there are several separated constraints composing it.
636 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anObjIter);
639 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
640 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
641 if ((aFeature->getKind() != SketchPlugin_Sketch::ID() && !aSketchFeature) ||
642 aFeature->getKind() == SketchPlugin_ConstraintFillet::ID())
645 // Find the place where to insert a feature
646 for (aResIt = aResult.begin(); aResIt != aResult.end(); ++aResIt)
647 if (isLess(aFeature, *aResIt))
649 aResult.insert(aResIt, aFeature);