0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IVtkVTK / IVtkVTK_ShapeData.hxx
index ee99eea..04ceac3 100644 (file)
 #define __IVTKVTK_SHAPEDATA_H__
 
 #include <IVtk_IShapeData.hxx>
-#include <vtkType.h>
+
+// prevent disabling some MSVC warning messages by VTK headers 
+#ifdef _MSC_VER
+#pragma warning(push)
+#endif
+#include <vtkPolyData.h>
 #include <vtkSmartPointer.h>
+#include <vtkIdTypeArray.h>
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
 
 class vtkIdTypeArray;
-class vtkPolyData;
 
 class IVtkVTK_ShapeData;
 DEFINE_STANDARD_HANDLE( IVtkVTK_ShapeData, IVtk_IShapeData )
 
-// macros to export static field in class
-#if (defined(_WIN32) || defined(__WIN32__))
-  #ifdef __IVtkVTK_DLL
-    #define IVtkVTK_EXPORT __declspec(dllexport)
-  #else
-    #define IVtkVTK_EXPORT __declspec(dllimport)
-  #endif
-#else
-  #define IVtkVTK_EXPORT
-#endif
-
 //! @class IVtkVTK_ShapeData 
 //! @brief IShapeData implementation for VTK.
 //!
@@ -45,8 +42,8 @@ class IVtkVTK_ShapeData : public IVtk_IShapeData
 {
 public:
 
-  IVtkVTK_EXPORT static const char* const ARRNAME_SUBSHAPE_IDS;
-  IVtkVTK_EXPORT static const char* const ARRNAME_MESH_TYPES;
+  static const char* ARRNAME_SUBSHAPE_IDS() { return "SUBSHAPE_IDS"; }
+  static const char* ARRNAME_MESH_TYPES() { return "MESH_TYPES"; }
 
   typedef Handle(IVtkVTK_ShapeData) Handle;
 
@@ -55,14 +52,14 @@ public:
   //! Destructor
   Standard_EXPORT ~IVtkVTK_ShapeData();
 
-  DEFINE_STANDARD_RTTI(IVtkVTK_ShapeData, IVtk_IShapeData)
+  DEFINE_STANDARD_RTTIEXT(IVtkVTK_ShapeData,IVtk_IShapeData)
 
   //! Insert a coordinate
   //! @param [in] theX X coordinate
   //! @param [in] theY Y coordinate
   //! @param [in] theZ Z coordinate
   //! @return id of added point
-  Standard_EXPORT virtual IVtk_PointId InsertCoordinate (double theX, double theY, double theZ);
+  Standard_EXPORT virtual IVtk_PointId InsertCoordinate (double theX, double theY, double theZ) Standard_OVERRIDE;
 
   //! Insert a vertex.
   //! @param [in] theShapeID id of the subshape to which the vertex belongs.
@@ -70,7 +67,7 @@ public:
   //! @param [in] theMeshType mesh type of the subshape (MT_Undefined by default)
   Standard_EXPORT virtual void InsertVertex (const IVtk_IdType   theShapeID,
                                              const IVtk_PointId  thePointId,
-                                             const IVtk_MeshType theMeshType);
+                                             const IVtk_MeshType theMeshType) Standard_OVERRIDE;
 
   //! Insert a line.
   //! @param [in] theShapeID id of the subshape to which the line belongs.
@@ -80,7 +77,7 @@ public:
   Standard_EXPORT virtual void InsertLine (const IVtk_IdType   theShapeID,
                                            const IVtk_PointId  thePointId1,
                                            const IVtk_PointId  thePointId2,
-                                           const IVtk_MeshType theMeshType);
+                                           const IVtk_MeshType theMeshType) Standard_OVERRIDE;
 
   //! Insert a poly-line.
   //! @param [in] theShapeID id of the subshape to which the polyline belongs.
@@ -88,7 +85,7 @@ public:
   //! @param [in] theMeshType mesh type of the subshape (MT_Undefined by default)
   Standard_EXPORT virtual void InsertLine (const IVtk_IdType       theShapeID, 
                                            const IVtk_PointIdList* thePointIds,
-                                           const IVtk_MeshType     theMeshType);
+                                           const IVtk_MeshType     theMeshType) Standard_OVERRIDE;
   //! Insert a triangle
   //! @param [in] theShapeID id of the subshape to which the triangle belongs.
   //! @param [in] thePointId1 id of the first point
@@ -99,17 +96,34 @@ public:
                                                const IVtk_PointId  thePointId1,
                                                const IVtk_PointId  thePointId2,
                                                const IVtk_PointId  thePointId3,
-                                               const IVtk_MeshType theMeshType);
+                                               const IVtk_MeshType theMeshType) Standard_OVERRIDE;
 
 
 public: //! @name Specific methods
 
   //! Get VTK PolyData.
   //! @return VTK PolyData
-  vtkSmartPointer< vtkPolyData > getVtkPolyData() const
+  vtkPolyData* getVtkPolyData() const
   { return myPolyData; }
 
 private:
+
+  //! Wrapper over vtkGenericDataArray::InsertNextTypedTuple().
+  void insertNextSubShapeId (IVtk_IdType theShapeID,
+                             IVtk_MeshType theMeshType)
+  {
+    const vtkIdType aShapeIDVTK = theShapeID;
+    const vtkIdType aType = theMeshType;
+  #if (VTK_MAJOR_VERSION > 7) || (VTK_MAJOR_VERSION == 7 && VTK_MINOR_VERSION >= 1)
+    mySubShapeIDs->InsertNextTypedTuple (&aShapeIDVTK);
+    myMeshTypes->InsertNextTypedTuple (&aType);
+  #else
+    mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
+    myMeshTypes->InsertNextTupleValue (&aType);
+  #endif
+  }
+
+private:
   vtkSmartPointer< vtkPolyData >    myPolyData;    //!< Shape geometry as vtkPolyData
   vtkSmartPointer< vtkIdTypeArray > mySubShapeIDs; //!< Array of sub-shapes ids
   vtkSmartPointer< vtkIdTypeArray > myMeshTypes;   //!< Array of type codes of mesh parts