]> OCCT Git - occt.git/commitdiff
0033218: Data Exchange - XCAFPrs_Texture not allow to use classes inherited from...
authorstv <sergey.telkov@opencascade..com>
Thu, 24 Nov 2022 09:48:22 +0000 (12:48 +0300)
committersmoskvin <smoskvin@opencascade.com>
Sun, 4 Dec 2022 10:47:36 +0000 (13:47 +0300)
Type of field XCAFPrs_Texture::myImageSource was changed from Image_Texture to Handle(Image_Texture)

src/XCAFDoc/XCAFDoc_VisMaterial.cxx
src/XCAFPrs/XCAFPrs_Texture.cxx
src/XCAFPrs/XCAFPrs_Texture.hxx

index 9e223b9f5107d01ac37de19d2d8283b9b3350c39..37dd94f40361d3955148acb6a4194edbb3771e70 100644 (file)
@@ -294,23 +294,23 @@ void XCAFDoc_VisMaterial::FillAspect (const Handle(Graphic3d_Aspects)& theAspect
   Handle(Graphic3d_TextureSet) aTextureSet = new Graphic3d_TextureSet (aNbTexUnits);
   if (!aColorTexture.IsNull())
   {
-    aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*aColorTexture, Graphic3d_TextureUnit_BaseColor));
+    aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (aColorTexture, Graphic3d_TextureUnit_BaseColor));
   }
   if (!myPbrMat.EmissiveTexture.IsNull())
   {
-    aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.EmissiveTexture, Graphic3d_TextureUnit_Emissive));
+    aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (myPbrMat.EmissiveTexture, Graphic3d_TextureUnit_Emissive));
   }
   if (!myPbrMat.OcclusionTexture.IsNull())
   {
-    aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.OcclusionTexture, Graphic3d_TextureUnit_Occlusion));
+    aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (myPbrMat.OcclusionTexture, Graphic3d_TextureUnit_Occlusion));
   }
   if (!myPbrMat.NormalTexture.IsNull())
   {
-    aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.NormalTexture, Graphic3d_TextureUnit_Normal));
+    aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (myPbrMat.NormalTexture, Graphic3d_TextureUnit_Normal));
   }
   if (!myPbrMat.MetallicRoughnessTexture.IsNull())
   {
-    aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.MetallicRoughnessTexture, Graphic3d_TextureUnit_MetallicRoughness));
+    aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (myPbrMat.MetallicRoughnessTexture, Graphic3d_TextureUnit_MetallicRoughness));
   }
 
   theAspect->SetTextureSet (aTextureSet);
index 178e28b7b16b76d3f9b75c7d65a6f3e9a9461164..f917c16f01f94ce107ef9fd1d4ff3910a86daa8c 100644 (file)
@@ -21,14 +21,14 @@ IMPLEMENT_STANDARD_RTTIEXT(XCAFPrs_Texture, Graphic3d_Texture2D)
 //function : XCAFPrs_Texture
 //purpose  :
 //=======================================================================
-XCAFPrs_Texture::XCAFPrs_Texture (const Image_Texture& theImageSource,
+XCAFPrs_Texture::XCAFPrs_Texture (const Handle(Image_Texture)& theImageSource,
                                   const Graphic3d_TextureUnit theUnit)
 : Graphic3d_Texture2D (""),
   myImageSource (theImageSource)
 {
-  if (!myImageSource.TextureId().IsEmpty())
+  if (!myImageSource.IsNull() && !myImageSource->TextureId().IsEmpty())
   {
-    myTexId = myImageSource.TextureId();
+    myTexId = myImageSource->TextureId();
   }
   myParams->SetTextureUnit (theUnit);
   myIsColorMap = theUnit == Graphic3d_TextureUnit_BaseColor
@@ -41,7 +41,7 @@ XCAFPrs_Texture::XCAFPrs_Texture (const Image_Texture& theImageSource,
 //=======================================================================
 Handle(Image_CompressedPixMap) XCAFPrs_Texture::GetCompressedImage (const Handle(Image_SupportedFormats)& theSupported)
 {
-  return myImageSource.ReadCompressedImage (theSupported);
+  return !myImageSource.IsNull() ? myImageSource->ReadCompressedImage (theSupported) : Handle(Image_CompressedPixMap)();
 }
 
 //=======================================================================
@@ -50,7 +50,11 @@ Handle(Image_CompressedPixMap) XCAFPrs_Texture::GetCompressedImage (const Handle
 //=======================================================================
 Handle(Image_PixMap) XCAFPrs_Texture::GetImage (const Handle(Image_SupportedFormats)& theSupported)
 {
-  Handle(Image_PixMap) anImage = myImageSource.ReadImage (theSupported);
-  convertToCompatible (theSupported, anImage);
+  Handle(Image_PixMap) anImage;
+  if (!myImageSource.IsNull())
+  {
+    anImage = myImageSource->ReadImage(theSupported);
+    convertToCompatible(theSupported, anImage);
+  }
   return anImage;
 }
index 8c86b526257956017e958c23d17ba02e14de34bd..d0742d772dcf247c693b5926a72533ecc5440b19 100644 (file)
@@ -27,8 +27,8 @@ class XCAFPrs_Texture : public Graphic3d_Texture2D
 public:
 
   //! Constructor.
-  Standard_EXPORT explicit XCAFPrs_Texture (const Image_Texture& theImageSource,
-                                            const Graphic3d_TextureUnit theUnit);
+  Standard_EXPORT XCAFPrs_Texture (const Handle(Image_Texture)& theImageSource,
+                                   const Graphic3d_TextureUnit theUnit);
 
   //! Image reader.
   Standard_EXPORT virtual Handle(Image_CompressedPixMap) GetCompressedImage (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
@@ -37,12 +37,11 @@ public:
   Standard_EXPORT virtual Handle(Image_PixMap) GetImage (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
 
   //! Return image source.
-  const Image_Texture& GetImageSource() const { return myImageSource; }
+  const Handle(Image_Texture)& GetImageSource() const { return myImageSource; }
 
 protected:
 
-  Image_Texture myImageSource;
-
+  Handle(Image_Texture) myImageSource;
 };
 
 #endif // _XCAFPrs_Texture_HeaderFile