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