Salome HOME
Use the prefix std:: instead of the directive using namespace std;
[modules/geom.git] / src / GEOM_I / GEOM_IInsertOperations_i.cc
index 832b8df27bef26cff4f9a431d582e4f64e2ac2c5..c5570650e29f0f78075416215f28ca22b108d241 100644 (file)
@@ -35,6 +35,7 @@
 #include "GEOM_Object.hxx"
 
 #include <TColStd_HSequenceOfAsciiString.hxx>
+#include <TDataStd_HArray1OfByte.hxx>
 
 //=============================================================================
 /*!
@@ -129,11 +130,19 @@ GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::Import
   char* aFileName   = strdup(theFileName);
   char* aFormatName = strdup(theFormatName);
   Handle(GEOM_Object) anObject = GetOperations()->Import(aFileName, aFormatName);
+
+  if( strcmp(aFormatName,"IGES_UNIT")==0 && !anObject.IsNull() ) {
+    free(aFileName);
+    free(aFormatName);
+    return GetObject(anObject);
+  }
+
   free(aFileName);
   free(aFormatName);
 
-  if (!GetOperations()->IsDone() || anObject.IsNull())
+  if (!GetOperations()->IsDone() || anObject.IsNull()) {
     return aGEOMObject._retn();
+  }
 
   return GetObject(anObject);
 }
@@ -207,3 +216,52 @@ void GEOM_IInsertOperations_i::ExportTranslators
   theFormats  = aFormatsArray._retn();
   thePatterns = aPatternsArray._retn();
 }
+
+CORBA::Long GEOM_IInsertOperations_i::LoadTexture(const char* theTextureFile)
+{
+  GetOperations()->SetNotDone();
+  return GetOperations()->LoadTexture( theTextureFile );
+}
+
+CORBA::Long GEOM_IInsertOperations_i::AddTexture(CORBA::Long theWidth, CORBA::Long theHeight,
+                                                const SALOMEDS::TMPFile& theTexture)
+{
+  GetOperations()->SetNotDone();
+  Handle(TDataStd_HArray1OfByte) aTexture;
+  if ( theTexture.length() > 0 ) {
+    aTexture = new TDataStd_HArray1OfByte( 1, theTexture.length() );
+    for ( int i = 0; i < theTexture.length(); i++ )
+      aTexture->SetValue( i+1, (Standard_Byte)theTexture[i] );
+  }
+  return GetOperations()->AddTexture( theWidth, theHeight, aTexture );
+}
+
+SALOMEDS::TMPFile* GEOM_IInsertOperations_i::GetTexture(CORBA::Long theID, 
+                                                       CORBA::Long& theWidth,
+                                                       CORBA::Long& theHeight)
+{
+  int aWidth, aHeight;
+  Handle(TDataStd_HArray1OfByte) aTextureImpl = GetOperations()->GetTexture( theID, aWidth, aHeight );
+  theWidth  = aWidth;
+  theHeight = aHeight;
+  SALOMEDS::TMPFile_var aTexture;
+  if ( !aTextureImpl.IsNull() ) {
+    aTexture = new SALOMEDS::TMPFile;
+    aTexture->length( aTextureImpl->Length() );
+    for ( int i = aTextureImpl->Lower(); i <= aTextureImpl->Upper(); i++ )
+      aTexture[i-aTextureImpl->Lower()] = aTextureImpl->Value( i );
+  }
+  return aTexture._retn();
+}
+
+GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures()
+{
+  std::list<int> localIDs = GetOperations()->GetAllTextures();
+  GEOM::ListOfLong_var anIDs = new GEOM::ListOfLong(localIDs.size());
+  anIDs->length(localIDs.size());
+  std::list<int>::const_iterator anIt;
+  int i = 0;
+  for( anIt = localIDs.begin(); anIt != localIDs.end(); ++anIt, i++)
+    anIDs[i] = *anIt;
+  return anIDs._retn();
+}