Salome HOME
Merge branch 'OCCT780'
[modules/geom.git] / src / GEOMImpl / GEOMImpl_PartitionDriver.cxx
1 // Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include <GEOMImpl_PartitionDriver.hxx>
24 #include <GEOMImpl_IPartition.hxx>
25 #include <GEOMImpl_Types.hxx>
26 #include <GEOMUtils.hxx>
27 #include <GEOM_Object.hxx>
28 #include <GEOM_Function.hxx>
29 #include <GEOMAlgo_Splitter.hxx>
30
31 #include <TDataStd_IntegerArray.hxx>
32 #include <TNaming_CopyShape.hxx>
33
34 #include <TopAbs.hxx>
35 #include <TopExp.hxx>
36 #include <TopoDS_Shape.hxx>
37 #include <TopoDS_Iterator.hxx>
38 #include <TopTools_MapOfShape.hxx>
39 #include <TopTools_IndexedMapOfShape.hxx>
40 #include <TopTools_ListIteratorOfListOfShape.hxx>
41 #include <TopTools_DataMapOfShapeShape.hxx>
42
43 #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
44 #include <Standard_NullObject.hxx>
45 #include <StdFail_NotDone.hxx>
46 #include <BOPAlgo_CheckerSI.hxx>
47 #include <BOPAlgo_Alerts.hxx>
48 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
49 #include <TopTools_ListOfShape.hxx>
50 #include <BOPDS_DS.hxx>
51 #include <BRepTools_History.hxx>
52
53 // Depth of self-intersection check (see BOPAlgo_CheckerSI::SetLevelOfCheck() for more details)
54 // Default value for BOPAlgo_CheckerSI gives very long computation when checking face-to-face intersections;
55 // here check level is decreased to more appropriate value to avoid problems with performance).
56 #define BOP_SELF_INTERSECTIONS_LEVEL 4
57
58 //=======================================================================
59 //function : GetID
60 //purpose  :
61 //=======================================================================
62 const Standard_GUID& GEOMImpl_PartitionDriver::GetID()
63 {
64   static Standard_GUID aPartitionDriver("FF1BBB22-5D14-4df2-980B-3A668264EA16");
65   return aPartitionDriver;
66 }
67
68
69 //=======================================================================
70 //function : GEOMImpl_PartitionDriver
71 //purpose  :
72 //=======================================================================
73 GEOMImpl_PartitionDriver::GEOMImpl_PartitionDriver()
74 {
75 }
76
77 //=======================================================================
78 //function : SimplifyCompound
79 //purpose  :
80 //=======================================================================
81 static void PrepareShapes (const TopoDS_Shape&   theShape,
82                            Standard_Integer      theType,
83                            TopTools_ListOfShape& theSimpleList)
84 {
85   if (theType == PARTITION_NO_SELF_INTERSECTIONS ||
86       theShape.ShapeType() != TopAbs_COMPOUND) {
87     theSimpleList.Append(theShape);
88     return;
89   }
90
91   // explode compound on simple shapes to allow their intersections
92   TopoDS_Iterator It (theShape, Standard_True, Standard_True);
93   TopTools_MapOfShape mapShape;
94   for (; It.More(); It.Next()) {
95     if (mapShape.Add(It.Value())) {
96       TopoDS_Shape curSh = It.Value();
97       PrepareShapes(curSh, theType, theSimpleList);
98     }
99   }
100 }
101
102 static void CheckSelfIntersection(const TopoDS_Shape &theShape)
103 {
104   BOPAlgo_CheckerSI aCSI;  // checker of self-interferences
105   TopTools_ListOfShape aList;
106
107   aList.Append(theShape);
108   aCSI.SetLevelOfCheck(BOP_SELF_INTERSECTIONS_LEVEL);
109   aCSI.SetArguments(aList);
110   aCSI.Perform();
111   if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) {
112     StdFail_NotDone::Raise("Partition operation will not be performed, because argument shape is self-intersected");
113   }
114 }
115
116 //=======================================================================
117 //function : Execute
118 //purpose  :
119 //=======================================================================
120 Standard_Integer GEOMImpl_PartitionDriver::Execute(Handle(TFunction_Logbook)& log) const
121 {
122   if (Label().IsNull()) return 0;
123   Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
124
125   GEOMImpl_IPartition aCI (aFunction);
126   Standard_Integer aType = aFunction->GetType();
127   const Standard_Boolean isCheckSelfInte = aCI.GetCheckSelfIntersection();
128   const Standard_Real    aFuzzyParam     = aCI.GetFuzzyParameter();
129
130   TopoDS_Shape aShape;
131   GEOMAlgo_Splitter PS;
132
133   TopTools_DataMapOfShapeShape aCopyMap;
134   TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
135
136   if (aType == PARTITION_PARTITION || aType == PARTITION_NO_SELF_INTERSECTIONS)
137   {
138     Handle(TColStd_HSequenceOfTransient) aShapes  = aCI.GetShapes();
139     Handle(TColStd_HSequenceOfTransient) aTools   = aCI.GetTools();
140     Handle(TColStd_HSequenceOfTransient) aKeepIns = aCI.GetKeepIns();
141     Handle(TColStd_HSequenceOfTransient) aRemIns  = aCI.GetRemoveIns();
142     Handle(TColStd_HArray1OfInteger) aMaterials   = aCI.GetMaterials();
143     //skl Standard_Boolean DoRemoveWebs = !aMaterials.IsNull();
144
145     int ind;
146     //unsigned int ind, nbshapes = 0;
147     //nbshapes += aShapes->Length() + aTools->Length();
148     //nbshapes += aKeepIns->Length() + aRemIns->Length();
149     //TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes);
150     TopTools_MapOfShape ShapesMap, ToolsMap;
151
152     // add object shapes that are in ListShapes;
153     for (ind = 1; ind <= aShapes->Length(); ind++) {
154       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind));
155       TopoDS_Shape aShape_i = aRefShape->GetValue();
156       if (aShape_i.IsNull()) {
157         Standard_NullObject::Raise("In Partition a shape is null");
158       }
159
160       // Check self-intersection.
161       if (isCheckSelfInte && aType == PARTITION_NO_SELF_INTERSECTIONS) {
162         CheckSelfIntersection(aShape_i);
163       }
164
165       TopoDS_Shape aShape_i_copy;
166       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
167
168       // fill aCopyMap for history
169       TopTools_IndexedMapOfShape aShape_i_inds;
170       TopTools_IndexedMapOfShape aShape_i_copy_inds;
171       TopExp::MapShapes(aShape_i, aShape_i_inds);
172       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
173       Standard_Integer nbInds = aShape_i_inds.Extent();
174       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
175         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
176       }
177       //
178       TopTools_ListOfShape aSimpleShapes;
179       //PrepareShapes(aShape_i, aType, aSimpleShapes);
180       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
181       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
182       for (; aSimpleIter.More(); aSimpleIter.Next()) {
183         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
184         if (ShapesMap.Add(aSimpleSh)) {
185           PS.AddArgument(aSimpleSh);
186           //skl if (DoRemoveWebs) {
187           //skl if (aMaterials->Length() >= ind)
188           //skl PS.SetMaterial(aSimpleSh, aMaterials->Value(ind));
189           //skl }
190         }
191       }
192     }
193
194     // add tool shapes that are in ListTools and not in ListShapes;
195     for (ind = 1; ind <= aTools->Length(); ind++) {
196       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aTools->Value(ind));
197       TopoDS_Shape aShape_i = aRefShape->GetValue();
198       if (aShape_i.IsNull()) {
199         Standard_NullObject::Raise("In Partition a tool shape is null");
200       }
201
202       // Check self-intersection.
203       if (isCheckSelfInte && aType == PARTITION_NO_SELF_INTERSECTIONS) {
204         CheckSelfIntersection(aShape_i);
205       }
206
207       //
208       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
209       TopoDS_Shape aShape_i_copy;
210       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
211       //if (aCopyTool.IsDone())
212       //  aShape_i_copy = aCopyTool.Shape();
213       //else
214       //  Standard_NullObject::Raise("Bad shape detected");
215       //
216       // fill aCopyMap for history
217       TopTools_IndexedMapOfShape aShape_i_inds;
218       TopTools_IndexedMapOfShape aShape_i_copy_inds;
219       TopExp::MapShapes(aShape_i, aShape_i_inds);
220       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
221       Standard_Integer nbInds = aShape_i_inds.Extent();
222       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
223         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
224       }
225       //
226       TopTools_ListOfShape aSimpleShapes;
227       //PrepareShapes(aShape_i, aType, aSimpleShapes);
228       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
229       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
230       for (; aSimpleIter.More(); aSimpleIter.Next()) {
231         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
232         if (!ShapesMap.Contains(aSimpleSh) && ToolsMap.Add(aSimpleSh)) {
233           PS.AddTool(aSimpleSh);
234         }
235       }
236     }
237
238     // add shapes that are in ListKeepInside, as object shapes;
239     for (ind = 1; ind <= aKeepIns->Length(); ind++) {
240       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
241       TopoDS_Shape aShape_i = aRefShape->GetValue();
242       if (aShape_i.IsNull()) {
243         Standard_NullObject::Raise("In Partition a Keep Inside shape is null");
244       }
245       //
246       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
247       TopoDS_Shape aShape_i_copy;
248       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
249       //if (aCopyTool.IsDone())
250       //  aShape_i_copy = aCopyTool.Shape();
251       //else
252       //  Standard_NullObject::Raise("Bad shape detected");
253       //
254       // fill aCopyMap for history
255       TopTools_IndexedMapOfShape aShape_i_inds;
256       TopTools_IndexedMapOfShape aShape_i_copy_inds;
257       TopExp::MapShapes(aShape_i, aShape_i_inds);
258       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
259       Standard_Integer nbInds = aShape_i_inds.Extent();
260       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
261         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
262       }
263       //
264       TopTools_ListOfShape aSimpleShapes;
265       //PrepareShapes(aShape_i, aType, aSimpleShapes);
266       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
267       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
268       for (; aSimpleIter.More(); aSimpleIter.Next()) {
269         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
270         if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
271           PS.AddArgument(aSimpleSh);
272       }
273     }
274
275     // add shapes that are in ListRemoveInside, as object shapes;
276     for (ind = 1; ind <= aRemIns->Length(); ind++) {
277       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
278       TopoDS_Shape aShape_i = aRefShape->GetValue();
279       if (aShape_i.IsNull()) {
280         Standard_NullObject::Raise("In Partition a Remove Inside shape is null");
281       }
282       //
283       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
284       TopoDS_Shape aShape_i_copy;
285       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
286       //if (aCopyTool.IsDone())
287       //  aShape_i_copy = aCopyTool.Shape();
288       //else
289       //  Standard_NullObject::Raise("Bad shape detected");
290       //
291       // fill aCopyMap for history
292       TopTools_IndexedMapOfShape aShape_i_inds;
293       TopTools_IndexedMapOfShape aShape_i_copy_inds;
294       TopExp::MapShapes(aShape_i, aShape_i_inds);
295       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
296       Standard_Integer nbInds = aShape_i_inds.Extent();
297       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
298         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
299       }
300       //
301       TopTools_ListOfShape aSimpleShapes;
302       //PrepareShapes(aShape_i, aType, aSimpleShapes);
303       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
304       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
305       for (; aSimpleIter.More(); aSimpleIter.Next()) {
306         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
307         if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
308           PS.AddArgument(aSimpleSh);
309       }
310     }
311
312     PS.SetLimitMode(aCI.GetKeepNonlimitShapes());
313     PS.SetLimit((TopAbs_ShapeEnum)aCI.GetLimit());
314
315     if (aFuzzyParam > 0) {
316       PS.SetFuzzyValue(aFuzzyParam);
317     }
318
319     // Set parallel processing mode (default is false)
320     Standard_Boolean bRunParallel = Standard_True;
321     PS.SetRunParallel(bRunParallel);
322
323     PS.Perform();
324
325     //skl PS.Compute();
326     //skl PS.SetRemoveWebs(!DoRemoveWebs);
327     //skl PS.Build((TopAbs_ShapeEnum) aCI.GetLimit());
328     /*skl
329     // suppress result outside of shapes in KInsideMap
330     for (ind = 1; ind <= aKeepIns->Length(); ind++) {
331       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
332       TopoDS_Shape aShape_i = aRefShape->GetValue();
333       PS.KeepShapesInside(aShape_i);
334     }
335
336     // suppress result inside of shapes in RInsideMap
337     for (ind = 1; ind <= aRemIns->Length(); ind++) {
338       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
339       TopoDS_Shape aShape_i = aRefShape->GetValue();
340       PS.RemoveShapesInside(aShape_i);
341     }
342     */
343   }
344   else if (aType == PARTITION_HALF)
345   {
346     Handle(GEOM_Function) aRefShape = aCI.GetShape();
347     Handle(GEOM_Function) aRefPlane = aCI.GetPlane();
348     TopoDS_Shape aShapeArg = aRefShape->GetValue();
349     TopoDS_Shape aPlaneArg = aRefPlane->GetValue();
350
351     if (aShapeArg.IsNull() || aPlaneArg.IsNull()) {
352       Standard_NullObject::Raise("In Half Partition a shape or a plane is null");
353     }
354
355     TopoDS_Shape aShapeArg_copy;
356     TopoDS_Shape aPlaneArg_copy;
357     {
358       TNaming_CopyShape::CopyTool(aShapeArg, aMapTShapes, aShapeArg_copy);
359       //BRepBuilderAPI_Copy aCopyTool (aShapeArg);
360       //if (aCopyTool.IsDone())
361       //  aShapeArg_copy = aCopyTool.Shape();
362       //else
363       //  Standard_NullObject::Raise("Bad shape detected");
364       //
365       // fill aCopyMap for history
366       TopTools_IndexedMapOfShape aShapeArg_inds;
367       TopTools_IndexedMapOfShape aShapeArg_copy_inds;
368       TopExp::MapShapes(aShapeArg, aShapeArg_inds);
369       TopExp::MapShapes(aShapeArg_copy, aShapeArg_copy_inds);
370       Standard_Integer nbInds = aShapeArg_inds.Extent();
371       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
372         aCopyMap.Bind(aShapeArg_inds.FindKey(ie), aShapeArg_copy_inds.FindKey(ie));
373       }
374     }
375     {
376       TNaming_CopyShape::CopyTool(aPlaneArg, aMapTShapes, aPlaneArg_copy);
377       //BRepBuilderAPI_Copy aCopyTool (aPlaneArg);
378       //if (aCopyTool.IsDone())
379       //  aPlaneArg_copy = aCopyTool.Shape();
380       //else
381       //  Standard_NullObject::Raise("Bad shape detected");
382       //
383       // fill aCopyMap for history
384       TopTools_IndexedMapOfShape aPlaneArg_inds;
385       TopTools_IndexedMapOfShape aPlaneArg_copy_inds;
386       TopExp::MapShapes(aPlaneArg, aPlaneArg_inds);
387       TopExp::MapShapes(aPlaneArg_copy, aPlaneArg_copy_inds);
388       Standard_Integer nbInds = aPlaneArg_inds.Extent();
389       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
390         aCopyMap.Bind(aPlaneArg_inds.FindKey(ie), aPlaneArg_copy_inds.FindKey(ie));
391       }
392     }
393
394     // add object shapes that are in ListShapes;
395     TopTools_ListOfShape aSimpleShapes;
396     TopTools_MapOfShape aShapesMap;
397
398     PrepareShapes(aShapeArg_copy, aType, aSimpleShapes);
399
400     TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
401
402     for (; aSimpleIter.More(); aSimpleIter.Next()) {
403       const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
404
405       if (aShapesMap.Add(aSimpleSh)) {
406         PS.AddArgument(aSimpleSh);
407       }
408     }
409
410     // add tool shapes that are in ListTools and not in ListShapes;
411     PS.AddTool(aPlaneArg_copy);
412     //PS.AddTool(aPlaneArg);
413
414     if (aFuzzyParam > 0) {
415       PS.SetFuzzyValue(aFuzzyParam);
416     }
417
418     //skl PS.Compute();
419     PS.Perform();
420     //PS.SetRemoveWebs(Standard_False);
421     //PS.Build(aShapeArg.ShapeType());
422
423   } else {
424   }
425
426   aShape = PS.Shape();
427   if (aShape.IsNull()) {
428     // Mantis issue 22009
429     if (PS.HasError(STANDARD_TYPE(BOPAlgo_AlertTooFewArguments)) && PS.Tools().Extent() == 0 && PS.Arguments().Extent() == 1)
430       aShape = PS.Arguments().First();
431     else
432       return 0;
433   }
434
435   if (aShape.ShapeType() != TopAbs_VERTEX) {
436     //Alternative case to check not valid partition IPAL21418
437     TopoDS_Iterator It (aShape, Standard_True, Standard_True);
438     int nbSubshapes = 0;
439     for (; It.More(); It.Next())
440       nbSubshapes++;
441     if (!nbSubshapes)
442       Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
443     //end of IPAL21418
444   }
445
446   if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) )
447     Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
448
449   aFunction->SetValue(aShape);
450
451   // Fill history to be used by GetInPlace functionality
452   TopTools_IndexedMapOfShape aResIndices;
453   TopExp::MapShapes(aShape, aResIndices);
454
455   // history for all argument shapes
456   // be sure to use aCopyMap
457   TDF_LabelSequence aLabelSeq;
458   aFunction->GetDependency(aLabelSeq);
459   Standard_Integer nbArg = aLabelSeq.Length();
460
461   for (Standard_Integer iarg = 1; iarg <= nbArg; iarg++) {
462
463     TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg);
464
465     Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel);
466     TopoDS_Shape anArgumentShape = anArgumentObject->GetValue();
467
468     TopTools_IndexedMapOfShape anArgumentIndices;
469     TopExp::MapShapes(anArgumentShape, anArgumentIndices);
470     Standard_Integer nbArgumentEntities = anArgumentIndices.Extent();
471
472     // Find corresponding label in history
473     TDF_Label anArgumentHistoryLabel =
474       aFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_True);
475
476     for (Standard_Integer ie = 1; ie <= nbArgumentEntities; ie++) {
477       TopoDS_Shape anEntity = anArgumentIndices.FindKey(ie);
478       if (!BRepTools_History::IsSupportedType(anEntity))
479         continue;
480
481       // be sure to use aCopyMap here
482       if (aCopyMap.IsBound(anEntity))
483         anEntity = aCopyMap.Find(anEntity);
484       //
485       if (PS.IsDeleted(anEntity))
486         // The shape has been deleted
487         continue;
488
489       // Check if the shape has been modified during the operation.
490       // If it was - use its splits, otherwise use the shape itself
491       const TopTools_ListOfShape *pModified;
492       TopTools_ListOfShape aLItself;
493       const TopTools_ListOfShape& aPSModified = PS.Modified(anEntity);
494       if (!aPSModified.IsEmpty())
495         pModified = &aPSModified;
496       else
497       {
498         aLItself.Append(anEntity);
499         pModified = &aLItself;
500       }
501         
502       TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(ie, Standard_True);
503       Handle(TDataStd_IntegerArray) anAttr =
504         TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, pModified->Extent());
505
506       int ih = 1;
507       TopTools_ListIteratorOfListOfShape itM (*pModified);
508       for (; itM.More(); itM.Next(), ++ih) {
509         int id = aResIndices.FindIndex(itM.Value());
510         anAttr->SetValue(ih, id);
511       }
512     }
513   }
514
515   log->SetTouched(Label());
516
517   return 1;
518 }
519
520 //================================================================================
521 /*!
522  * \brief Returns a name of creation operation and names and values of creation parameters
523  */
524 //================================================================================
525
526 bool GEOMImpl_PartitionDriver::
527 GetCreationInformation(std::string&             theOperationName,
528                        std::vector<GEOM_Param>& theParams)
529 {
530   if (Label().IsNull()) return 0;
531   Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
532
533   GEOMImpl_IPartition aCI( function );
534   Standard_Integer aType = function->GetType();
535   Standard_Real aFuzzyParam = aCI.GetFuzzyParameter();
536
537   theOperationName = "PARTITION";
538
539   switch ( aType ) {
540   case PARTITION_PARTITION:
541   case PARTITION_NO_SELF_INTERSECTIONS:
542     AddParam( theParams, "Objects", aCI.GetShapes() );
543     AddParam( theParams, "Tool objects", aCI.GetTools() );
544     {
545       Handle(TColStd_HSequenceOfTransient) objSeq = aCI.GetKeepIns();
546       if ( !objSeq.IsNull() && objSeq->Length() > 0 )
547         AddParam( theParams, "Objects to keep inside", objSeq );
548       objSeq = aCI.GetRemoveIns();
549       if ( !objSeq.IsNull() && objSeq->Length() > 0 )
550         AddParam( theParams, "Objects to remove inside", objSeq );
551       Handle(TColStd_HArray1OfInteger) intSeq = aCI.GetMaterials();
552       if ( !intSeq.IsNull() && intSeq->Length() > 0 )
553         AddParam( theParams, "Materials", aCI.GetMaterials() );
554     }
555     AddParam( theParams, "Resulting type", (TopAbs_ShapeEnum) aCI.GetLimit());
556     AddParam( theParams, "Keep shapes of lower type", aCI.GetKeepNonlimitShapes());
557     AddParam( theParams, "No object intersections", ( aType == PARTITION_NO_SELF_INTERSECTIONS ));
558
559     if (aType == PARTITION_NO_SELF_INTERSECTIONS) {
560       AddParam( theParams, "Check self-intersections", aCI.GetCheckSelfIntersection());
561     }
562     break;
563   case PARTITION_HALF:
564     AddParam( theParams, "Object", aCI.GetShape() );
565     AddParam( theParams, "Plane", aCI.GetPlane() );
566     break;
567   default:
568     return false;
569   }
570
571   if (aFuzzyParam > 0)
572     AddParam( theParams, "Fuzzy Parameter", aFuzzyParam );
573   
574   return true;
575 }
576
577 IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_PartitionDriver,GEOM_BaseDriver)