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