Salome HOME
65b6875199c997886a06a605ee861c22e17bae7b
[modules/shaper.git] / src / Model / Model_ResultBody.cpp
1 // Copyright (C) 2014-2021  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <Model_ResultBody.h>
21
22 #include <Model_Document.h>
23 #include <Model_Objects.h>
24 #include <Model_BodyBuilder.h>
25 #include <Model_Document.h>
26 #include <ModelAPI_Object.h>
27 #include <ModelAPI_Events.h>
28 #include <ModelAPI_Tools.h>
29 #include <Model_Data.h>
30 #include <Events_Loop.h>
31 #include <GeomAPI_ShapeIterator.h>
32 #include <GeomAPI_ShapeExplorer.h>
33 #include <GeomAPI_Face.h>
34 #include <GeomAPI_Pnt.h>
35
36 #include <TopoDS_Shape.hxx>
37 #include <TopExp_Explorer.hxx>
38 #include <TopTools_MapOfShape.hxx>
39 #include <TDataStd_UAttribute.hxx>
40
41 // if this attribute exists, the shape is connected topology
42 Standard_GUID kIsConnectedTopology("e51392e0-3a4d-405d-8e36-bbfe19858ef5");
43 // if this attribute exists, the connected topology flag must be recomputed
44 Standard_GUID kUpdateConnectedTopology("01ef7a45-0bec-4266-b0b4-4aa570921818");
45
46 Model_ResultBody::Model_ResultBody() : ModelAPI_ResultBody()
47 {
48   myBuilder = new Model_BodyBuilder(this);
49   myLastConcealed = false;
50   updateSubs(shape()); // in case of open, etc.
51 }
52
53 Model_ResultBody::~Model_ResultBody()
54 {
55   updateSubs(std::shared_ptr<GeomAPI_Shape>()); // erase sub-results
56   delete myBuilder;
57 }
58
59 bool Model_ResultBody::generated(const GeomShapePtr& theNewShape,
60   const std::string& theName, const bool theCheckIsInResult)
61 {
62   bool aResult = false;
63   if (mySubs.size()) { // consists of subs
64     for (std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
65          aSubIter != mySubs.cend();
66          ++aSubIter)
67     {
68       const ResultBodyPtr& aSub = *aSubIter;
69       if (aSub->generated(theNewShape, theName, theCheckIsInResult))
70         aResult = true;
71     }
72   } else { // do for this directly
73     if (myBuilder->generated(theNewShape, theName, theCheckIsInResult))
74       aResult = true;
75   }
76   return aResult;
77 }
78
79 void Model_ResultBody::loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
80                                            const GeomShapePtr& theOldShape,
81                                            const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
82                                            const std::string& theName,
83                                            const bool theSaveOldIfNotInTree)
84 {
85   if (mySubs.size()) { // consists of subs
86     for (std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
87          aSubIter != mySubs.cend();
88          ++aSubIter)
89     {
90       const ResultBodyPtr& aSub = *aSubIter;
91       aSub->loadGeneratedShapes(
92         theAlgo, theOldShape, theShapeTypeToExplore, theName, theSaveOldIfNotInTree);
93     }
94   } else { // do for this directly
95     myBuilder->loadGeneratedShapes(
96       theAlgo, theOldShape, theShapeTypeToExplore, theName, theSaveOldIfNotInTree);
97   }
98 }
99
100 void Model_ResultBody::loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
101                                           const GeomShapePtr& theOldShape,
102                                           const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
103                                           const std::string& theName)
104 {
105   if (mySubs.size()) { // consists of subs
106     // optimization of getting of new shapes for specific sub-result
107     if (!theAlgo->isNewShapesCollected(theOldShape, theShapeTypeToExplore))
108       theAlgo->collectNewShapes(theOldShape, theShapeTypeToExplore);
109     std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
110     for(; aSubIter != mySubs.cend(); aSubIter++) {
111       (*aSubIter)->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
112     }
113   } else { // do for this directly
114     myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
115   }
116 }
117
118 void Model_ResultBody::loadFirstLevel(GeomShapePtr theShape, const std::string& theName)
119 {
120   if (mySubs.size()) { // consists of subs
121     for (std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
122       aSubIter != mySubs.cend();
123       ++aSubIter)
124     {
125       const ResultBodyPtr& aSub = *aSubIter;
126       aSub->loadFirstLevel(theShape, theName);
127     }
128   } else { // do for this directly
129     myBuilder->loadFirstLevel(theShape, theName);
130   }
131 }
132
133 int Model_ResultBody::numberOfSubs(bool /*forTree*/) const
134 {
135   return int(mySubs.size());
136 }
137
138 ResultBodyPtr Model_ResultBody::subResult(const int theIndex, bool /*forTree*/) const
139 {
140   if (theIndex >= int(mySubs.size()))
141     return ResultBodyPtr();
142   return mySubs.at(theIndex);
143 }
144
145 bool Model_ResultBody::isSub(ObjectPtr theResult, int& theIndex) const
146 {
147   std::map<ObjectPtr, int>::const_iterator aFound = mySubsMap.find(theResult);
148   if (aFound != mySubsMap.end()) {
149     theIndex = aFound->second;
150     return true;
151   }
152   return false;
153 }
154
155 void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& theName,
156   std::string& theDefault)
157 {
158   theSection = "Visualization";
159   theName = "result_body_color";
160   theDefault = DEFAULT_COLOR();
161 }
162
163 bool Model_ResultBody::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
164 {
165   bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag);
166   if (aChanged) { // state is changed, so modifications are needed
167     updateSubs(shape(), false); // to set disabled/enabled
168   }
169   return aChanged;
170 }
171
172 bool Model_ResultBody::isConcealed()
173 {
174   return myLastConcealed;
175 }
176
177 void Model_ResultBody::setIsConcealed(const bool theValue, const bool theForced)
178 {
179   if (ModelAPI_ResultBody::isConcealed() != theValue) {
180     ModelAPI_ResultBody::setIsConcealed(theValue, theForced);
181     updateConcealment();
182   }
183 }
184
185 // recursively check all subs for concealment flag, returns true if everybody have "flag" state,
186 // in theAll returns results with "flag" state
187 static bool checkAllSubs(ResultBodyPtr theParent, bool theFlag, std::list<ResultBodyPtr>& theAll)
188 {
189   if (theParent->isConcealed() != theFlag)
190     theAll.push_back(theParent);
191   bool aResult = theParent->ModelAPI_ResultBody::isConcealed() == theFlag;
192   for(int a = 0; a < theParent->numberOfSubs(); a++) {
193     bool aSubRes = checkAllSubs(theParent->subResult(a), theFlag, theAll);
194     if (theFlag)
195       aResult = aResult || aSubRes; // concealed: one makes concealed everyone
196     else
197       aResult = aResult && aSubRes; // not concealed: all must be not concealed
198   }
199   return aResult;
200 }
201
202 void Model_ResultBody::updateConcealment()
203 {
204   if (myLastConcealed != ModelAPI_ResultBody::isConcealed()) {
205     // check the whole tree of results: if one is concealed, everybody are concealed
206     ResultBodyPtr anOwner = std::dynamic_pointer_cast<ModelAPI_ResultBody>(data()->owner());
207     if (!anOwner.get())
208       return; // "this" is invalid
209     ResultBodyPtr aParent = ModelAPI_Tools::bodyOwner(anOwner);
210     while(aParent.get()) {
211       anOwner = aParent;
212       aParent = ModelAPI_Tools::bodyOwner(anOwner);
213     }
214     // iterate all results and collect all results whose state may be updated
215     std::list<ResultBodyPtr> anUpdated;
216     bool aNewFlag = !myLastConcealed;
217     if (checkAllSubs(anOwner, aNewFlag, anUpdated)) { // state of everyone must be updated
218       std::list<ResultBodyPtr>::iterator aRes = anUpdated.begin();
219       for(; aRes != anUpdated.end(); aRes++) {
220         bool aLastConcealed = (*aRes)->isConcealed();
221         if (aNewFlag != aLastConcealed) {
222           std::dynamic_pointer_cast<Model_ResultBody>(*aRes)->myLastConcealed = aNewFlag;
223           if (aNewFlag) { // become concealed, behaves like removed
224             ModelAPI_EventCreator::get()->sendDeleted(document(), groupName());
225           } else { // become not-concealed, behaves like created
226             static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
227             ModelAPI_EventCreator::get()->sendUpdated(*aRes, anEvent);
228           }
229           static Events_ID EVENT_DISP = // must be redisplayed in any case
230             Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
231           ModelAPI_EventCreator::get()->sendUpdated(*aRes, EVENT_DISP);
232         }
233       }
234     }
235   }
236 }
237
238 void Model_ResultBody::addShapeColor( const std::wstring& theName,std::vector<int>& color) {
239
240   if (myColorsShape.find(theName) == myColorsShape.end())
241     myColorsShape[ theName ] =  color;
242 }
243
244 std::wstring Model_ResultBody::addShapeName(std::shared_ptr<GeomAPI_Shape> theshape,
245                                             const std::wstring& theName ){
246
247   int indice = 1;
248   std::wstringstream aName;
249   aName << theName;
250   while(myNamesShape.find(aName.str()) != myNamesShape.end() ){
251     aName.str(L"");
252     aName << theName << L"__" << indice;
253     indice++;
254   }
255   myNamesShape[ aName.str() ] = theshape;
256
257   return aName.str();
258 }
259
260 std::wstring Model_ResultBody::findShapeName(std::shared_ptr<GeomAPI_Shape> theShape){
261
262   TopoDS_Shape  aShape =  theShape->impl<TopoDS_Shape>();
263   for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it =
264                                                                 myNamesShape.begin();
265         it != myNamesShape.end();
266         ++it)
267   {
268     TopoDS_Shape curSelectedShape = (*it).second->impl<TopoDS_Shape>();
269     if ((aShape.IsSame(curSelectedShape)))  {
270       return (*it).first;
271     }
272   }
273   return  L"material not found" ;
274 }
275
276 void Model_ResultBody::setShapeName(
277                 std::map< std::wstring, std::shared_ptr<GeomAPI_Shape>>& theShapeName,
278                 std::map< std::wstring, std::vector<int>>& theColorsShape)
279 {
280   myNamesShape = theShapeName;
281   myColorsShape = theColorsShape;
282 }
283
284 void Model_ResultBody::clearShapeNameAndColor(){
285   myNamesShape.clear();
286   myColorsShape.clear();
287 }
288
289 void Model_ResultBody::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape,
290                                   const bool theShapeChanged)
291 {
292   static Events_Loop* aLoop = Events_Loop::loop();
293   static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
294   static Events_ID EVENT_UPD = aLoop->eventByName(EVENT_OBJECT_UPDATED);
295   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
296   // erase flag that topology is connected: the shape is new
297   if (theShapeChanged && data().get()) {
298     TDF_Label aDataLab = std::dynamic_pointer_cast<Model_Data>(data())->label();
299     if (!aDataLab.IsNull()) {
300       TDataStd_UAttribute::Set(aDataLab, kUpdateConnectedTopology);
301       isConnectedTopology(); // to store this flag in transaction, #2630
302     }
303   }
304   // iterate all sub-solids of compsolid to make sub-results synchronized with them
305   TopoDS_Shape aThisShape;
306   if (theThisShape.get()) aThisShape = theThisShape->impl<TopoDS_Shape>();
307   if (!aThisShape.IsNull() && (aThisShape.ShapeType() == TopAbs_COMPSOLID ||
308        aThisShape.ShapeType() == TopAbs_COMPOUND)) {
309     bool aWasEmpty = mySubs.empty();
310     Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(document())->objects();
311     unsigned int aSubIndex = 0;
312     TopoDS_Iterator aShapesIter(aThisShape);
313     for(; aShapesIter.More(); aShapesIter.Next(), aSubIndex++) {
314       std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
315       aShape->setImpl(new TopoDS_Shape(aShapesIter.Value()));
316       ResultBodyPtr aSub;
317       if (mySubs.size() <= aSubIndex) { // it is needed to create a new sub-result
318         std::wstring thenameshape = L"";
319         // find shape name read
320         for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it =
321                                                                             myNamesShape.begin();
322            it != myNamesShape.end();
323            ++it)
324         {
325             TopoDS_Shape curSelectedShape = (*it).second->impl<TopoDS_Shape>();
326             if (!(aShapesIter.Value().IsSame(curSelectedShape))) continue;
327             thenameshape = (*it).first;
328             break;
329         }
330         aSub = anObjects->createBody(this->data(), aSubIndex,thenameshape);
331         //finf color read
332         std::map< std::wstring, std::vector<int>>::iterator itColor =
333                                                           myColorsShape.find(thenameshape);
334         if (itColor != myColorsShape.end()){
335             ModelAPI_Tools::setColor(aSub,(*itColor).second);
336         }
337         aSub->setShapeName(myNamesShape,myColorsShape);
338         mySubs.push_back(aSub);
339         mySubsMap[aSub] = int(mySubs.size() - 1);
340         if (isConcealed()) { // for issue #2579 note7
341           aSub->ModelAPI_ResultBody::setIsConcealed(true);
342           std::dynamic_pointer_cast<Model_ResultBody>(aSub)->updateConcealment();
343         }
344
345       } else { // just update shape of this result
346         aSub = mySubs[aSubIndex];
347       }
348       GeomShapePtr anOldSubShape = aSub->shape();
349       if (!aShape->isEqual(anOldSubShape)) {
350         if (myAlgo.get()) {
351           std::list<GeomShapePtr> anOldForSub;
352           computeOldForSub(aShape, myOlds, anOldForSub);
353           myIsGenerated ? aSub->storeGenerated(anOldForSub, aShape, myAlgo) :
354             aSub->storeModified(anOldForSub, aShape, myAlgo);
355         } else {
356           aSub->store(aShape, false);
357         }
358         aECreator->sendUpdated(aSub, EVENT_DISP);
359         aECreator->sendUpdated(aSub, EVENT_UPD);
360       }
361       aSub->setDisabled(aSub, isDisabled());
362     }
363     // erase left, unused results
364     while(mySubs.size() > aSubIndex) {
365       ResultBodyPtr anErased = *(mySubs.rbegin());
366       if (anErased->ModelAPI_ResultBody::isConcealed()) {
367         anErased->ModelAPI_ResultBody::setIsConcealed(false);
368         std::dynamic_pointer_cast<Model_ResultBody>(anErased)->updateConcealment();
369       }
370       anErased->setDisabled(anErased, true);
371       mySubsMap.erase(anErased);
372       mySubs.pop_back();
373     }
374     if (aWasEmpty) { // erase all subs
375       // redisplay this because result with and without subs are displayed differently
376       aECreator->sendUpdated(data()->owner(), EVENT_DISP);
377     }
378     cleanCash();
379   } else if (!mySubs.empty()) { // erase all subs
380     while(!mySubs.empty()) {
381       ResultBodyPtr anErased = *(mySubs.rbegin());
382       if (anErased->ModelAPI_ResultBody::isConcealed()) {
383         anErased->ModelAPI_ResultBody::setIsConcealed(false);
384         std::dynamic_pointer_cast<Model_ResultBody>(anErased)->updateConcealment();
385       }
386       anErased->setDisabled(anErased, true); // even if it is invalid (to erase subs on abort/undo)
387       mySubs.pop_back();
388     }
389     mySubsMap.clear();
390     // redisplay this because result with and without subs are displayed differently
391     aECreator->sendUpdated(data()->owner(), EVENT_DISP);
392   }
393 }
394
395 void Model_ResultBody::updateSubs(
396   const GeomShapePtr& theThisShape, const std::list<GeomShapePtr>& theOlds,
397   const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape, const bool isGenerated)
398 {
399   myAlgo = theMakeShape;
400   myOlds = theOlds;
401   myIsGenerated = isGenerated;
402   // to avoid changing of "isDisabled" flag in the "updateSubs" cycle
403   isDisabled();
404
405   updateSubs(theThisShape, true);
406   myAlgo.reset();
407   myOlds.clear();
408   myHistoryCash.Clear();
409 }
410
411 void  Model_ResultBody::setTextureFile(const std::string & theTextureFile)
412 {
413   ModelAPI_Result::setTextureFile(theTextureFile);
414   for( auto sub : mySubs){
415     sub->setTextureFile(theTextureFile);
416   }
417   for(auto map : mySubsMap){
418     map.first->setTextureFile(theTextureFile);
419   }
420 }
421
422 bool Model_ResultBody::isConnectedTopology()
423 {
424   TDF_Label aDataLab = std::dynamic_pointer_cast<Model_Data>(data())->label();
425   if (!aDataLab.IsNull()) {
426     if (aDataLab.IsAttribute(kUpdateConnectedTopology)) { // recompute state
427       aDataLab.ForgetAttribute(kUpdateConnectedTopology);
428       GeomShapePtr aShape = shape();
429       if (aShape.get() && aShape->isConnectedTopology()) {
430         TDataStd_UAttribute::Set(aDataLab, kIsConnectedTopology);
431       } else {
432         aDataLab.ForgetAttribute(kIsConnectedTopology);
433       }
434     }
435     return aDataLab.IsAttribute(kIsConnectedTopology);
436   }
437   return false; // invalid case
438 }
439
440 void Model_ResultBody::cleanCash()
441 {
442   myBuilder->cleanCash();
443   for (std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
444     aSubIter != mySubs.cend(); ++aSubIter)
445   {
446     const ResultBodyPtr& aSub = *aSubIter;
447     aSub->cleanCash();
448   }
449 }
450
451 // adds to the theSubSubs map all sub-shapes of theSub if it is compound of compsolid
452 static void collectSubs(
453   const GeomShapePtr theSub, TopTools_MapOfShape& theSubSubs, const bool theOneLevelMore)
454 {
455   if (theSub->isNull())
456     return;
457   if (theSubSubs.Add(theSub->impl<TopoDS_Shape>()))  {
458     bool aIsComp = theSub->isCompound() || theSub->isCompSolid();
459     if (aIsComp) {
460       for(GeomAPI_ShapeIterator anIter(theSub); anIter.more(); anIter.next())
461         collectSubs(anIter.current(), theSubSubs, theOneLevelMore);
462     } else if (theOneLevelMore) {
463       GeomAPI_Shape::ShapeType aSubType = GeomAPI_Shape::ShapeType(int(theSub->shapeType()) + 1);
464       if (aSubType == GeomAPI_Shape::SHAPE)
465         return;
466       if (aSubType == GeomAPI_Shape::SHELL)
467         aSubType = GeomAPI_Shape::FACE;
468       if (aSubType == GeomAPI_Shape::WIRE)
469         aSubType = GeomAPI_Shape::EDGE;
470
471       for(GeomAPI_ShapeExplorer anExp(theSub, aSubType); anExp.more(); anExp.next()) {
472         collectSubs(anExp.current(), theSubSubs, false);
473       }
474     }
475   }
476 }
477
478 void Model_ResultBody::computeOldForSub(const GeomShapePtr& theSub,
479   const std::list<GeomShapePtr>& theAllOlds, std::list<GeomShapePtr>& theOldForSub)
480 {
481   // the old can be also used for sub-shape of theSub; collect all subs of compound or compsolid
482   TopTools_MapOfShape aSubSubs;
483   collectSubs(theSub, aSubSubs, false);
484
485   std::list<GeomShapePtr>::const_iterator aRootOlds = theAllOlds.cbegin();
486   for (; aRootOlds != theAllOlds.cend(); aRootOlds++) {
487     // use sub-shapes of olds too if they are compounds or compsolids
488     TopTools_MapOfShape anOldSubs;
489     // iterate one level more (for intersection of solids this is face)
490     collectSubs(*aRootOlds, anOldSubs, true);
491     for (TopTools_MapOfShape::Iterator anOldIter(anOldSubs); anOldIter.More(); anOldIter.Next()) {
492       TopoDS_Shape anOldShape = anOldIter.Value();
493       if (anOldShape.ShapeType() == TopAbs_COMPOUND || anOldShape.ShapeType() == TopAbs_SHELL ||
494           anOldShape.ShapeType() == TopAbs_WIRE || anOldShape.ShapeType() == TopAbs_COMPSOLID)
495         continue; // container old-shapes are not supported by the history, may cause crash
496       GeomShapePtr anOldSub(new GeomAPI_Shape);
497       anOldSub->setImpl<TopoDS_Shape>(new TopoDS_Shape(anOldShape));
498
499       ListOfShape aNews;
500       if (myHistoryCash.IsBound(anOldShape)) {
501         const TopTools_ListOfShape& aList = myHistoryCash.Find(anOldShape);
502         for(TopTools_ListIteratorOfListOfShape anIter(aList); anIter.More(); anIter.Next()) {
503           GeomShapePtr aShape(new GeomAPI_Shape);
504           aShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(anIter.Value()));
505           aNews.push_back(aShape);
506         }
507       } else {
508         myIsGenerated ? myAlgo->generated(anOldSub, aNews) : myAlgo->modified(anOldSub, aNews);
509         // MakeShape may return alone old shape if there is no history information for this input
510         if (aNews.size() == 1 && aNews.front()->isEqual(anOldSub))
511           aNews.clear();
512         // store result in the history
513         TopTools_ListOfShape aList;
514         for (ListOfShape::iterator aNewIter = aNews.begin(); aNewIter != aNews.end(); aNewIter++) {
515           aList.Append((*aNewIter)->impl<TopoDS_Shape>());
516         }
517         myHistoryCash.Bind(anOldShape, aList);
518       }
519
520       for (ListOfShape::iterator aNewIter = aNews.begin(); aNewIter != aNews.end(); aNewIter++) {
521         if (aSubSubs.Contains((*aNewIter)->impl<TopoDS_Shape>())) {
522           // check list already contains this sub
523           std::list<GeomShapePtr>::iterator aResIter = theOldForSub.begin();
524           for(; aResIter != theOldForSub.end(); aResIter++)
525             if ((*aResIter)->isSame(anOldSub))
526               break;
527           if (aResIter == theOldForSub.end())
528             theOldForSub.push_back(anOldSub); // found old used for new theSubShape creation
529           break;
530         }
531       }
532     }
533   }
534 }