0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IVtkVTK / IVtkVTK_ShapeData.hxx
CommitLineData
913a4c4a 1// Created on: 2011-10-14
2// Created by: Roman KOZLOV
3// Copyright (c) 2011-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef __IVTKVTK_SHAPEDATA_H__
17#define __IVTKVTK_SHAPEDATA_H__
18
19#include <IVtk_IShapeData.hxx>
a9660929 20
21// prevent disabling some MSVC warning messages by VTK headers
22#ifdef _MSC_VER
23#pragma warning(push)
24#endif
a2f76b15 25#include <vtkPolyData.h>
913a4c4a 26#include <vtkSmartPointer.h>
e607bd3e 27#include <vtkIdTypeArray.h>
a9660929 28#ifdef _MSC_VER
29#pragma warning(pop)
30#endif
913a4c4a 31
32class vtkIdTypeArray;
913a4c4a 33
c04c30b3 34class IVtkVTK_ShapeData;
913a4c4a 35DEFINE_STANDARD_HANDLE( IVtkVTK_ShapeData, IVtk_IShapeData )
36
913a4c4a 37//! @class IVtkVTK_ShapeData
38//! @brief IShapeData implementation for VTK.
39//!
40//! Contains the shape geometry information as vtkPolyData.
41class IVtkVTK_ShapeData : public IVtk_IShapeData
42{
43public:
44
68df8478 45 static const char* ARRNAME_SUBSHAPE_IDS() { return "SUBSHAPE_IDS"; }
46 static const char* ARRNAME_MESH_TYPES() { return "MESH_TYPES"; }
913a4c4a 47
48 typedef Handle(IVtkVTK_ShapeData) Handle;
49
50 //! Constructor
51 Standard_EXPORT IVtkVTK_ShapeData();
52 //! Destructor
53 Standard_EXPORT ~IVtkVTK_ShapeData();
54
92efcf78 55 DEFINE_STANDARD_RTTIEXT(IVtkVTK_ShapeData,IVtk_IShapeData)
913a4c4a 56
57 //! Insert a coordinate
58 //! @param [in] theX X coordinate
59 //! @param [in] theY Y coordinate
60 //! @param [in] theZ Z coordinate
61 //! @return id of added point
c7854818 62 Standard_EXPORT virtual IVtk_PointId InsertCoordinate (double theX, double theY, double theZ) Standard_OVERRIDE;
913a4c4a 63
64 //! Insert a vertex.
65 //! @param [in] theShapeID id of the subshape to which the vertex belongs.
66 //! @param [in] thePointId id of the point that defines the coordinates of the vertex
67 //! @param [in] theMeshType mesh type of the subshape (MT_Undefined by default)
68 Standard_EXPORT virtual void InsertVertex (const IVtk_IdType theShapeID,
69 const IVtk_PointId thePointId,
c7854818 70 const IVtk_MeshType theMeshType) Standard_OVERRIDE;
913a4c4a 71
72 //! Insert a line.
73 //! @param [in] theShapeID id of the subshape to which the line belongs.
74 //! @param [in] thePointId1 id of the first point
75 //! @param [in] thePointId2 id of the second point
76 //! @param [in] theMeshType mesh type of the subshape (MT_Undefined by default)
77 Standard_EXPORT virtual void InsertLine (const IVtk_IdType theShapeID,
78 const IVtk_PointId thePointId1,
79 const IVtk_PointId thePointId2,
c7854818 80 const IVtk_MeshType theMeshType) Standard_OVERRIDE;
913a4c4a 81
82 //! Insert a poly-line.
83 //! @param [in] theShapeID id of the subshape to which the polyline belongs.
84 //! @param [in] thePointIds vector of point ids
85 //! @param [in] theMeshType mesh type of the subshape (MT_Undefined by default)
86 Standard_EXPORT virtual void InsertLine (const IVtk_IdType theShapeID,
87 const IVtk_PointIdList* thePointIds,
c7854818 88 const IVtk_MeshType theMeshType) Standard_OVERRIDE;
913a4c4a 89 //! Insert a triangle
90 //! @param [in] theShapeID id of the subshape to which the triangle belongs.
91 //! @param [in] thePointId1 id of the first point
92 //! @param [in] thePointId2 id of the second point
93 //! @param [in] thePointId3 id of the third point
94 //! @param [in] theMeshType mesh type of the subshape (MT_Undefined by default)
95 Standard_EXPORT virtual void InsertTriangle (const IVtk_IdType theShapeID,
96 const IVtk_PointId thePointId1,
97 const IVtk_PointId thePointId2,
98 const IVtk_PointId thePointId3,
c7854818 99 const IVtk_MeshType theMeshType) Standard_OVERRIDE;
913a4c4a 100
101
102public: //! @name Specific methods
103
104 //! Get VTK PolyData.
105 //! @return VTK PolyData
a2f76b15 106 vtkPolyData* getVtkPolyData() const
913a4c4a 107 { return myPolyData; }
108
109private:
e607bd3e 110
111 //! Wrapper over vtkGenericDataArray::InsertNextTypedTuple().
112 void insertNextSubShapeId (IVtk_IdType theShapeID,
113 IVtk_MeshType theMeshType)
114 {
115 const vtkIdType aShapeIDVTK = theShapeID;
116 const vtkIdType aType = theMeshType;
117 #if (VTK_MAJOR_VERSION > 7) || (VTK_MAJOR_VERSION == 7 && VTK_MINOR_VERSION >= 1)
118 mySubShapeIDs->InsertNextTypedTuple (&aShapeIDVTK);
119 myMeshTypes->InsertNextTypedTuple (&aType);
120 #else
121 mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
122 myMeshTypes->InsertNextTupleValue (&aType);
123 #endif
124 }
125
126private:
913a4c4a 127 vtkSmartPointer< vtkPolyData > myPolyData; //!< Shape geometry as vtkPolyData
128 vtkSmartPointer< vtkIdTypeArray > mySubShapeIDs; //!< Array of sub-shapes ids
129 vtkSmartPointer< vtkIdTypeArray > myMeshTypes; //!< Array of type codes of mesh parts
130};
131
132#endif // __IVTKVTK_SHAPEDATA_H__