0024622: Add method to AIS_TexturedShape class to assign texture data directly from...
[occt.git] / src / Graphic3d / Graphic3d_TextureRoot.cxx
index 2b7bfd4..bbef8fa 100644 (file)
@@ -91,6 +91,20 @@ Graphic3d_TextureRoot::Graphic3d_TextureRoot (const TCollection_AsciiString& the
           + TCollection_AsciiString (Standard_Atomic_Increment (&THE_TEXTURE_COUNTER));
 }
 
+// =======================================================================
+// function : Graphic3d_TextureRoot
+// purpose  :
+// =======================================================================
+Graphic3d_TextureRoot::Graphic3d_TextureRoot (const Handle(Image_PixMap)&   thePixMap,
+                                              const Graphic3d_TypeOfTexture theType)
+: myParams (new Graphic3d_TextureParams()),
+  myPixMap (thePixMap),
+  myType   (theType)
+{
+  myTexId = TCollection_AsciiString ("Graphic3d_TextureRoot_")
+          + TCollection_AsciiString (Standard_Atomic_Increment (&THE_TEXTURE_COUNTER));
+}
+
 // =======================================================================
 // function : Destroy
 // purpose  :
@@ -124,6 +138,13 @@ const Handle(Graphic3d_TextureParams)& Graphic3d_TextureRoot::GetParams() const
 // =======================================================================
 Handle(Image_PixMap) Graphic3d_TextureRoot::GetImage() const
 {
+  // Case 1: texture source is specified as pixmap
+  if (!myPixMap.IsNull())
+  {
+    return myPixMap;
+  }
+
+  // Case 2: texture source is specified as path
   TCollection_AsciiString aFilePath;
   myPath.SystemName (aFilePath);
   if (aFilePath.IsEmpty())
@@ -146,6 +167,13 @@ Handle(Image_PixMap) Graphic3d_TextureRoot::GetImage() const
 // =======================================================================
 Standard_Boolean Graphic3d_TextureRoot::IsDone() const
 {
+  // Case 1: texture source is specified as pixmap
+  if (!myPixMap.IsNull())
+  {
+    return !myPixMap->IsEmpty();
+  }
+
+  // Case 2: texture source is specified as path
   OSD_File aTextureFile (myPath);
   return aTextureFile.Exists();
 }