Salome HOME
untabify
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IInsertOperations.cxx
1 //  Copyright (C) 2007-2008  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.
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 #include <Standard_Stream.hxx>
23
24 #include <GEOMImpl_IInsertOperations.hxx>
25
26 #include "utilities.h"
27 #include <OpUtil.hxx>
28 #include <Utils_ExceptHandlers.hxx>
29
30 #include <TFunction_DriverTable.hxx>
31 #include <TFunction_Driver.hxx>
32 #include <TFunction_Logbook.hxx>
33 #include <TDF_Tool.hxx>
34
35 #include <GEOM_Function.hxx>
36 #include <GEOM_PythonDump.hxx>
37
38 #include <GEOMImpl_CopyDriver.hxx>
39 #include <GEOMImpl_ExportDriver.hxx>
40 #include <GEOMImpl_ImportDriver.hxx>
41
42 #include <GEOMImpl_ICopy.hxx>
43 #include <GEOMImpl_IImportExport.hxx>
44
45 #include <GEOMImpl_Types.hxx>
46
47 #include <TopoDS.hxx>
48 #include <TopoDS_Vertex.hxx>
49 #include <BRep_Tool.hxx>
50 #include <gp_Pnt.hxx>
51 #include <TDataStd_HArray1OfByte.hxx>
52
53 #include <Standard_Failure.hxx>
54 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
55
56 //=============================================================================
57 /*!
58  *   constructor:
59  */
60 //=============================================================================
61
62 GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID)
63 : GEOM_IOperations(theEngine, theDocID)
64 {
65   MESSAGE("GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations");
66 }
67
68 //=============================================================================
69 /*!
70  *  destructor
71  */
72 //=============================================================================
73
74 GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations()
75 {
76   MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
77 }
78
79
80
81 //=============================================================================
82 /*!
83  *  MakeCopy
84  */
85 //=============================================================================
86 Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) theOriginal)
87 {
88   SetErrorCode(KO);
89
90   if (theOriginal.IsNull()) return NULL;
91
92   //Add a new Copy object
93   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
94
95   //Add a Copy function for creation a copy object
96   Handle(GEOM_Function) aFunction = aCopy->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITH_REF);
97
98   //Check if the function is set correctly
99   if(aFunction->GetDriverGUID() != GEOMImpl_CopyDriver::GetID()) return NULL;
100
101   GEOMImpl_ICopy aCI(aFunction);
102
103   Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction();
104   if (aRefFunction.IsNull()) return NULL;
105
106   aCI.SetOriginal(aRefFunction);
107
108   //Compute the Copy value
109   try {
110 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
111     OCC_CATCH_SIGNALS;
112 #endif
113     if (!GetSolver()->ComputeFunction(aFunction)) {
114       SetErrorCode("Copy driver failed");
115       return NULL;
116     }
117   }
118   catch (Standard_Failure) {
119     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
120     SetErrorCode(aFail->GetMessageString());
121     return NULL;
122   }
123
124   //Make a Python command
125   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeCopy(" << theOriginal << ")";
126
127   SetErrorCode(OK);
128   return aCopy;
129 }
130
131 //=============================================================================
132 /*!
133  *  Export
134  */
135 //=============================================================================
136 void GEOMImpl_IInsertOperations::Export
137                      (const Handle(GEOM_Object)      theOriginal,
138                       const TCollection_AsciiString& theFileName,
139                       const TCollection_AsciiString& theFormatName)
140 {
141   SetErrorCode(KO);
142
143   if (theOriginal.IsNull()) return;
144
145   Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction();
146   if (aRefFunction.IsNull()) return;  //There is no function which creates an object to be exported
147
148   //Add an Export function
149   Handle(GEOM_Function) aFunction = theOriginal->AddFunction(GEOMImpl_ExportDriver::GetID(), EXPORT_SHAPE);
150   if (aFunction.IsNull()) return;
151
152   //Check if the function is set correctly
153   if (aFunction->GetDriverGUID() != GEOMImpl_ExportDriver::GetID()) return;
154
155   Handle(TCollection_HAsciiString) aHLibName;
156   if (!IsSupported(Standard_False, theFormatName, aHLibName)) {
157     return;
158   }
159   TCollection_AsciiString aLibName = aHLibName->String();
160
161   //Set parameters
162   GEOMImpl_IImportExport aCI (aFunction);
163   aCI.SetOriginal(aRefFunction);
164   aCI.SetFileName(theFileName);
165   aCI.SetFormatName(theFormatName);
166   aCI.SetPluginName(aLibName);
167
168   //Perform the Export
169   try {
170 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
171     OCC_CATCH_SIGNALS;
172 #endif
173     if (!GetSolver()->ComputeFunction(aFunction)) {
174       SetErrorCode("Not enough space on disk, or you haven't permissions to write this directory");
175       return;
176     }
177   }
178   catch (Standard_Failure) {
179     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
180     SetErrorCode(aFail->GetMessageString());
181     return;
182   }
183
184   //Make a Python command
185   GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal << ", \""
186     << theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")";
187
188   SetErrorCode(OK);
189 }
190
191 //=============================================================================
192 /*!
193  *  Import
194  */
195 //=============================================================================
196 Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
197                                  (const TCollection_AsciiString& theFileName,
198                                   const TCollection_AsciiString& theFormatName)
199 {
200   SetErrorCode(KO);
201
202   if (theFileName.IsEmpty() || theFormatName.IsEmpty()) return NULL;
203
204   //Add a new result object
205   Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT);
206
207   //Add an Import function
208   Handle(GEOM_Function) aFunction = result->AddFunction(GEOMImpl_ImportDriver::GetID(), IMPORT_SHAPE);
209   if (aFunction.IsNull()) return result;
210
211   //Check if the function is set correctly
212   if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result;
213
214   Handle(TCollection_HAsciiString) aHLibName;
215   if (!IsSupported(Standard_True, theFormatName.SubString(1,4), aHLibName)) {
216     return result;
217   }
218   TCollection_AsciiString aLibName = aHLibName->String();
219
220   //Set parameters
221   GEOMImpl_IImportExport aCI (aFunction);
222   aCI.SetFileName(theFileName);
223   aCI.SetFormatName(theFormatName);
224   aCI.SetPluginName(aLibName);
225   //cout<<"IIO: theFormatName = "<<theFormatName.ToCString()<<endl;
226
227   //Perform the Import
228   try {
229 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
230     OCC_CATCH_SIGNALS;
231 #endif
232     if (!GetSolver()->ComputeFunction(aFunction)) {
233       SetErrorCode("Import driver failed");
234       return NULL;
235     }
236   }
237   catch (Standard_Failure) {
238     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
239     SetErrorCode(aFail->GetMessageString());
240     return NULL;
241   }
242
243   //Make a Python command
244   if( theFormatName != "IGES_UNIT" ) {
245     GEOM::TPythonDump(aFunction) << result << " = geompy.Import(\""
246       << theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")";
247   }
248
249   SetErrorCode(OK);
250
251   if( theFormatName == "IGES_UNIT" ) {
252     TopoDS_Shape S = aFunction->GetValue();
253     TopoDS_Vertex V = TopoDS::Vertex(S);
254     gp_Pnt P = BRep_Tool::Pnt(V);
255     double scale = P.X();
256     TCollection_AsciiString aUnitName = "UNIT_M";
257     if( fabs(scale-0.01) < 1.e-6 )
258       aUnitName = "UNIT_CM";
259     else if( fabs(scale-0.001) < 1.e-6 )
260       aUnitName = "UNIT_MM";
261     //cout<<"IIO: aUnitName = "<<aUnitName.ToCString()<<endl;
262     SetErrorCode(aUnitName);
263   }
264
265   return result;
266 }
267
268 //=============================================================================
269 /*!
270  *  ImportTranslators
271  */
272 //=============================================================================
273 Standard_Boolean GEOMImpl_IInsertOperations::ImportTranslators
274                      (Handle(TColStd_HSequenceOfAsciiString)& theFormats,
275                       Handle(TColStd_HSequenceOfAsciiString)& thePatterns)
276 {
277   if (theFormats.IsNull())
278     theFormats = new TColStd_HSequenceOfAsciiString;
279   else
280     theFormats->Clear();
281
282   if (thePatterns.IsNull())
283     thePatterns = new TColStd_HSequenceOfAsciiString;
284   else
285     thePatterns->Clear();
286
287   if (!InitResMgr()) return Standard_False;
288
289   // Read Import formats list from install directory
290   if (myResMgr->Find("Import")) {
291     TCollection_AsciiString aFormats (myResMgr->Value("Import"));
292     TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
293     int i = 1;
294     for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) {
295       theFormats->Append(aToken);
296     }
297   }
298
299   // Read Import formats from user directory
300   if (myResMgrUser->Find("Import")) {
301     TCollection_AsciiString aFormats (myResMgrUser->Value("Import"));
302     TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
303     int i = 1;
304     for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) {
305       int aLenFormats = theFormats->Length();
306       bool isFound = false;
307       for(int aInd=1;aInd<=aLenFormats;aInd++){
308         if( theFormats->Value(aInd) == aToken){
309           isFound = true;
310           break;
311         }
312       }
313       if(!isFound)
314         theFormats->Append(aToken);
315     }
316   }
317
318   // Read Patterns for each supported format
319   int j = 1, len = theFormats->Length();
320   for (; j <= len; j++) {
321     TCollection_AsciiString aKey, aPattern;
322     aKey = theFormats->Value(j) + ".ImportPattern";
323     if (myResMgr->Find(aKey.ToCString()))
324       aPattern = myResMgr->Value(aKey.ToCString());
325     else if(myResMgrUser->Find(aKey.ToCString()))
326       aPattern = myResMgrUser->Value(aKey.ToCString());
327     else {
328       aKey = theFormats->Value(j) + ".Pattern";
329       if (myResMgr->Find(aKey.ToCString()))
330         aPattern = myResMgr->Value(aKey.ToCString());
331       else if(myResMgrUser->Find(aKey.ToCString()))
332         aPattern = myResMgrUser->Value(aKey.ToCString());
333       else {
334         aPattern = theFormats->Value(j);
335         aPattern += " Files ( *.* )";
336       }
337     }
338     thePatterns->Append(aPattern);
339   }
340
341   return (!theFormats->IsEmpty());
342 }
343
344 //=============================================================================
345 /*!
346  *  ExportTranslators
347  */
348 //=============================================================================
349 Standard_Boolean GEOMImpl_IInsertOperations::ExportTranslators
350                      (Handle(TColStd_HSequenceOfAsciiString)& theFormats,
351                       Handle(TColStd_HSequenceOfAsciiString)& thePatterns)
352 {
353   if (theFormats.IsNull())
354     theFormats = new TColStd_HSequenceOfAsciiString;
355   else
356     theFormats->Clear();
357
358   if (thePatterns.IsNull())
359     thePatterns = new TColStd_HSequenceOfAsciiString;
360   else
361     thePatterns->Clear();
362
363   if (!InitResMgr()) return Standard_False;
364
365   // Read Export formats list from install directory
366   if (myResMgr->Find("Export")) {
367     TCollection_AsciiString aFormats (myResMgr->Value("Export"));
368     TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
369     int i = 1;
370     for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) {
371       theFormats->Append(aToken);
372     }
373   }
374
375   // Read Export formats list from user directory
376   if (myResMgrUser->Find("Export")) {
377     TCollection_AsciiString aFormats (myResMgrUser->Value("Export"));
378     TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
379     int i = 1;
380     for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) {
381       int aLenFormats = theFormats->Length();
382       bool isFound = false;
383       for(int aInd=1;aInd<=aLenFormats;aInd++){
384         if( theFormats->Value(aInd) == aToken){
385           isFound = true;
386           break;
387         }
388       }
389       if(!isFound)
390         theFormats->Append(aToken);
391     }
392   }
393
394   // Read Patterns for each supported format
395   int j = 1, len = theFormats->Length();
396   for (; j <= len; j++) {
397     TCollection_AsciiString aKey, aPattern;
398     aKey = theFormats->Value(j) + ".ExportPattern";
399     if (myResMgr->Find(aKey.ToCString()))
400       aPattern = myResMgr->Value(aKey.ToCString());
401     else if (myResMgrUser->Find(aKey.ToCString()))
402       aPattern = myResMgrUser->Value(aKey.ToCString());
403     else {
404       aKey = theFormats->Value(j) + ".Pattern";
405       if (myResMgr->Find(aKey.ToCString()))
406         aPattern = myResMgr->Value(aKey.ToCString());
407       else if (myResMgrUser->Find(aKey.ToCString()))
408         aPattern = myResMgrUser->Value(aKey.ToCString());
409       else {
410         aPattern = theFormats->Value(j);
411         aPattern += " Files ( *.* )";
412       }
413     }
414     thePatterns->Append(aPattern);
415   }
416
417   return (!theFormats->IsEmpty());
418 }
419
420 //=============================================================================
421 /*!
422  *  IsSupported
423  */
424 //=============================================================================
425 Standard_Boolean GEOMImpl_IInsertOperations::IsSupported
426                             (const Standard_Boolean isImport,
427                              const TCollection_AsciiString& theFormat,
428                              Handle(TCollection_HAsciiString)& theLibName)
429 {
430   if (!InitResMgr()) return Standard_False;
431
432   // Import/Export mode
433   TCollection_AsciiString aMode;
434   //Standard_CString aMode;
435   if (isImport) aMode = "Import";
436   else aMode = "Export";
437
438   // Read supported formats for the certain mode from install directory
439   if (myResMgr->Find(aMode.ToCString())) {
440     TCollection_AsciiString aFormats (myResMgr->Value(aMode.ToCString()));
441     if (aFormats.Search(theFormat) > -1) {
442       // Read library name for the supported format
443       TCollection_AsciiString aKey (theFormat);
444       aKey += ".";
445       aKey += aMode;
446       if (myResMgr->Find(aKey.ToCString())) {
447         TCollection_AsciiString aLibName (myResMgr->Value(aKey.ToCString()));        
448 #ifndef WNT
449         aLibName += ".so";     
450 #else
451         aLibName += ".dll";
452 #endif
453         theLibName = new TCollection_HAsciiString (aLibName);
454         return Standard_True;
455       }
456     }
457   }
458   
459   // Read supported formats for the certain mode from user directory
460   if (myResMgrUser->Find(aMode.ToCString())) {
461     TCollection_AsciiString aFormats (myResMgrUser->Value(aMode.ToCString()));
462     if (aFormats.Search(theFormat) > -1) {
463       // Read library name for the supported format
464       TCollection_AsciiString aKey (theFormat);
465       aKey += ".";
466       aKey += aMode;
467       if (myResMgrUser->Find(aKey.ToCString())) {
468         TCollection_AsciiString aLibName (myResMgrUser->Value(aKey.ToCString()));
469         theLibName = new TCollection_HAsciiString (aLibName);
470         return Standard_True;
471       }
472     }
473   }
474   
475   return Standard_False;
476 }
477
478 //=============================================================================
479 /*!
480  *  InitResMgr
481  */
482 //=============================================================================
483 Standard_Boolean GEOMImpl_IInsertOperations::InitResMgr()
484 {
485   bool isResourceFound     = false;
486   bool isResourceFoundUser = false;
487   TCollection_AsciiString aUserResDir,aResDir;
488   
489   if (myResMgr.IsNull()) {
490     // Initialize the Resource Manager
491     TCollection_AsciiString aNull;
492     aResDir = TCollection_AsciiString(getenv("GEOM_ROOT_DIR"));
493 #ifdef WNT
494     aResDir += "\\share\\salome\\resources\\geom";
495 #else
496     aResDir += "/share/salome/resources/geom";
497 #endif
498     
499     myResMgr = new Resource_Manager ("ImportExport", aResDir, aNull, Standard_False);
500
501     isResourceFound = true;
502     if (!myResMgr->Find("Import") && !myResMgr->Find("Export")) {
503       // instead of complains in Resource_Manager
504       isResourceFound = false;
505       INFOS("No valid file \"ImportExport\" found in " << aResDir.ToCString());
506     }
507   } else
508     isResourceFound = true;
509
510   if (myResMgrUser.IsNull()) {
511     char * dir = getenv("GEOM_ENGINE_RESOURCES_DIR");
512     TCollection_AsciiString aNull;
513     if ( dir )
514     {
515       aUserResDir = dir;
516     }
517     else
518     {
519       aUserResDir = getenv("HOME");
520 #ifdef WNT
521       aUserResDir += "\\.salome\\resources";
522 #else
523       aUserResDir += "/.salome/resources";
524 #endif
525     }
526
527     myResMgrUser = new Resource_Manager ("ImportExport", aNull, aUserResDir, Standard_False);
528
529     isResourceFoundUser = true;
530     
531     if (!myResMgrUser->Find("Import") && !myResMgrUser->Find("Export")) {
532       // instead of complains in Resource_Manager
533       isResourceFoundUser = false;
534     }
535       
536   } else
537     isResourceFoundUser = true;
538     
539   if(!isResourceFound && !isResourceFoundUser){
540     INFOS("No valid file \"ImportExport\" found in " << aResDir.ToCString());
541     INFOS("No valid file \"ImportExport\" found in " << aUserResDir.ToCString() );
542   }
543
544   return ( myResMgr->Find("Import") || myResMgr->Find("Export") ||
545            myResMgrUser->Find("Import") || myResMgrUser->Find("Export"));
546 }
547
548 int GEOMImpl_IInsertOperations::LoadTexture(const TCollection_AsciiString& theTextureFile)
549 {
550   SetErrorCode(KO);
551
552   if (theTextureFile.IsEmpty()) return 0;
553
554   Handle(TDataStd_HArray1OfByte) aTexture;
555
556   FILE* fp = fopen(theTextureFile.ToCString(), "r");
557   if (!fp) return 0;
558
559   std::list<std::string> lines;
560   char buffer[4096];
561   int maxlen = 0;
562   while (!feof(fp)) {
563     if ((fgets(buffer, 4096, fp)) == NULL) break;
564     int aLen = strlen(buffer);
565     if (buffer[aLen-1] == '\n') buffer[aLen-1] = '\0';
566     lines.push_back(buffer);
567     maxlen = std::max(maxlen, (int)strlen(buffer));
568   }
569
570   fclose(fp);
571
572   int lenbytes = maxlen/8;
573   if (maxlen%8) lenbytes++;
574
575   if (lenbytes == 0 || lines.empty())
576     return 0;
577
578   std::list<unsigned char> bytedata;
579   std::list<std::string>::const_iterator it;
580   for (it = lines.begin(); it != lines.end(); ++it) {
581     std::string line = *it;
582     int lenline = (line.size()/8 + (line.size()%8 ? 1 : 0)) * 8;
583     for (int i = 0; i < lenline/8; i++) {
584       unsigned char byte = 0;
585       for (int j = 0; j < 8; j++)
586         byte = (byte << 1) + ( i*8+j < line.size() && line[i*8+j] != '0' ? 1 : 0 );
587       bytedata.push_back(byte);
588     }
589     for (int i = lenline/8; i < lenbytes; i++)
590       bytedata.push_back((unsigned char)0);
591   }
592
593   if (bytedata.empty() || bytedata.size() != lines.size()*lenbytes)
594     return 0;
595
596   aTexture = new TDataStd_HArray1OfByte(1, lines.size()*lenbytes);
597   std::list<unsigned char>::iterator bdit;
598   int i;
599   for (i = 1, bdit = bytedata.begin(); bdit != bytedata.end(); ++bdit, ++i)
600     aTexture->SetValue(i, (Standard_Byte)(*bdit));
601
602   int aTextureId = GetEngine()->addTexture(GetDocID(), lenbytes*8, lines.size(), aTexture, theTextureFile);
603   if (aTextureId > 0) SetErrorCode(OK);
604   return aTextureId;
605 }
606   
607 int GEOMImpl_IInsertOperations::AddTexture(int theWidth, int theHeight, 
608                                            const Handle(TDataStd_HArray1OfByte)& theTexture)
609 {
610   SetErrorCode(KO);
611   int aTextureId = GetEngine()->addTexture(GetDocID(), theWidth, theHeight, theTexture);
612   if (aTextureId > 0) SetErrorCode(OK);
613   return aTextureId;
614 }
615
616 Handle(TDataStd_HArray1OfByte) GEOMImpl_IInsertOperations::GetTexture(int theTextureId,
617                                                                       int& theWidth, int& theHeight)
618 {
619   SetErrorCode(KO);
620   
621   Handle(TDataStd_HArray1OfByte) aTexture;
622   theWidth = theHeight = 0;
623   TCollection_AsciiString aFileName;
624
625   if (theTextureId <= 0)
626     return aTexture;
627
628   aTexture = GetEngine()->getTexture(GetDocID(), theTextureId, theWidth, theHeight, aFileName);
629
630   if (theWidth > 0 && theHeight > 0 && aTexture->Length() > 0) SetErrorCode(OK);
631
632   return aTexture;
633 }
634
635 std::list<int> GEOMImpl_IInsertOperations::GetAllTextures()
636 {
637   SetErrorCode(KO);
638   std::list<int> id_list = GetEngine()->getAllTextures(GetDocID());
639   SetErrorCode(OK);
640   return id_list;
641 }