+ myResMgrUser->Find("Import") || myResMgrUser->Find("Export"));
+}
+
+int GEOMImpl_IInsertOperations::LoadTexture(const TCollection_AsciiString& theTextureFile)
+{
+ SetErrorCode(KO);
+
+ if (theTextureFile.IsEmpty()) return 0;
+
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+ Handle(TColStd_HArray1OfByte) aTexture;
+#else
+ Handle(TDataStd_HArray1OfByte) aTexture;
+#endif
+
+ FILE* fp = fopen(theTextureFile.ToCString(), "r");
+ if (!fp) return 0;
+
+ std::list<std::string> lines;
+ char buffer[4096];
+ int maxlen = 0;
+ while (!feof(fp)) {
+ if ((fgets(buffer, 4096, fp)) == NULL) break;
+ int aLen = strlen(buffer);
+ if (buffer[aLen-1] == '\n') buffer[aLen-1] = '\0';
+ lines.push_back(buffer);
+ maxlen = std::max(maxlen, (int)strlen(buffer));
+ }
+
+ fclose(fp);
+
+ int lenbytes = maxlen/8;
+ if (maxlen%8) lenbytes++;
+
+ if (lenbytes == 0 || lines.empty())
+ return 0;
+
+ std::list<unsigned char> bytedata;
+ std::list<std::string>::const_iterator it;
+ for (it = lines.begin(); it != lines.end(); ++it) {
+ std::string line = *it;
+ int lenline = (line.size()/8 + (line.size()%8 ? 1 : 0)) * 8;
+ for (int i = 0; i < lenline/8; i++) {
+ unsigned char byte = 0;
+ for (int j = 0; j < 8; j++)
+ byte = (byte << 1) + ( i*8+j < line.size() && line[i*8+j] != '0' ? 1 : 0 );
+ bytedata.push_back(byte);
+ }
+ for (int i = lenline/8; i < lenbytes; i++)
+ bytedata.push_back((unsigned char)0);
+ }
+
+ if (bytedata.empty() || bytedata.size() != lines.size()*lenbytes)
+ return 0;
+
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+ aTexture = new TColStd_HArray1OfByte (1, lines.size()*lenbytes);
+#else
+ aTexture = new TDataStd_HArray1OfByte (1, lines.size()*lenbytes);
+#endif
+
+ std::list<unsigned char>::iterator bdit;
+ int i;
+ for (i = 1, bdit = bytedata.begin(); bdit != bytedata.end(); ++bdit, ++i)
+ aTexture->SetValue(i, (Standard_Byte)(*bdit));
+
+ int aTextureId = GetEngine()->addTexture(GetDocID(), lenbytes*8, lines.size(), aTexture, theTextureFile);
+ if (aTextureId > 0) SetErrorCode(OK);
+ return aTextureId;
+}
+
+int GEOMImpl_IInsertOperations::AddTexture(int theWidth, int theHeight,
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+ const Handle(TColStd_HArray1OfByte)& theTexture)
+#else
+ const Handle(TDataStd_HArray1OfByte)& theTexture)
+#endif
+{
+ SetErrorCode(KO);
+ int aTextureId = GetEngine()->addTexture(GetDocID(), theWidth, theHeight, theTexture);
+ if (aTextureId > 0) SetErrorCode(OK);
+ return aTextureId;
+}
+
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+Handle(TColStd_HArray1OfByte) GEOMImpl_IInsertOperations::GetTexture(int theTextureId,
+#else
+Handle(TDataStd_HArray1OfByte) GEOMImpl_IInsertOperations::GetTexture(int theTextureId,
+#endif
+ int& theWidth, int& theHeight)
+{
+ SetErrorCode(KO);
+
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+ Handle(TColStd_HArray1OfByte) aTexture;
+#else
+ Handle(TDataStd_HArray1OfByte) aTexture;
+#endif
+
+ theWidth = theHeight = 0;
+ TCollection_AsciiString aFileName;
+
+ if (theTextureId <= 0)
+ return aTexture;
+
+ aTexture = GetEngine()->getTexture(GetDocID(), theTextureId, theWidth, theHeight, aFileName);
+
+ if (theWidth > 0 && theHeight > 0 && aTexture->Length() > 0) SetErrorCode(OK);
+
+ return aTexture;
+}
+
+std::list<int> GEOMImpl_IInsertOperations::GetAllTextures()
+{
+ SetErrorCode(KO);
+ std::list<int> id_list = GetEngine()->getAllTextures(GetDocID());
+ SetErrorCode(OK);
+ return id_list;