1 // Created on: 2011-10-14
2 // Created by: Roman KOZLOV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef __IVTKVTK_SHAPEDATA_H__
17 #define __IVTKVTK_SHAPEDATA_H__
19 #include <IVtk_IShapeData.hxx>
21 // prevent disabling some MSVC warning messages by VTK headers
22 #include <Standard_WarningsDisable.hxx>
23 #include <vtkPolyData.h>
24 #include <vtkSmartPointer.h>
25 #include <vtkIdTypeArray.h>
26 #include <Standard_WarningsRestore.hxx>
30 class IVtkVTK_ShapeData;
31 DEFINE_STANDARD_HANDLE( IVtkVTK_ShapeData, IVtk_IShapeData )
33 //! @class IVtkVTK_ShapeData
34 //! @brief IShapeData implementation for VTK.
36 //! Contains the shape geometry information as vtkPolyData.
37 class IVtkVTK_ShapeData : public IVtk_IShapeData
41 static const char* ARRNAME_SUBSHAPE_IDS() { return "SUBSHAPE_IDS"; }
42 static const char* ARRNAME_MESH_TYPES() { return "MESH_TYPES"; }
44 typedef Handle(IVtkVTK_ShapeData) Handle;
47 Standard_EXPORT IVtkVTK_ShapeData();
49 Standard_EXPORT ~IVtkVTK_ShapeData();
51 DEFINE_STANDARD_RTTIEXT(IVtkVTK_ShapeData,IVtk_IShapeData)
53 //! Insert a coordinate
54 //! @param [in] theX X coordinate
55 //! @param [in] theY Y coordinate
56 //! @param [in] theZ Z coordinate
57 //! @return id of added point
58 Standard_EXPORT virtual IVtk_PointId InsertCoordinate (double theX, double theY, double theZ) Standard_OVERRIDE;
61 //! @param [in] theShapeID id of the subshape to which the vertex belongs.
62 //! @param [in] thePointId id of the point that defines the coordinates of the vertex
63 //! @param [in] theMeshType mesh type of the subshape (MT_Undefined by default)
64 Standard_EXPORT virtual void InsertVertex (const IVtk_IdType theShapeID,
65 const IVtk_PointId thePointId,
66 const IVtk_MeshType theMeshType) Standard_OVERRIDE;
69 //! @param [in] theShapeID id of the subshape to which the line belongs.
70 //! @param [in] thePointId1 id of the first point
71 //! @param [in] thePointId2 id of the second point
72 //! @param [in] theMeshType mesh type of the subshape (MT_Undefined by default)
73 Standard_EXPORT virtual void InsertLine (const IVtk_IdType theShapeID,
74 const IVtk_PointId thePointId1,
75 const IVtk_PointId thePointId2,
76 const IVtk_MeshType theMeshType) Standard_OVERRIDE;
78 //! Insert a poly-line.
79 //! @param [in] theShapeID id of the subshape to which the polyline belongs.
80 //! @param [in] thePointIds vector of point ids
81 //! @param [in] theMeshType mesh type of the subshape (MT_Undefined by default)
82 Standard_EXPORT virtual void InsertLine (const IVtk_IdType theShapeID,
83 const IVtk_PointIdList* thePointIds,
84 const IVtk_MeshType theMeshType) Standard_OVERRIDE;
86 //! @param [in] theShapeID id of the subshape to which the triangle belongs.
87 //! @param [in] thePointId1 id of the first point
88 //! @param [in] thePointId2 id of the second point
89 //! @param [in] thePointId3 id of the third point
90 //! @param [in] theMeshType mesh type of the subshape (MT_Undefined by default)
91 Standard_EXPORT virtual void InsertTriangle (const IVtk_IdType theShapeID,
92 const IVtk_PointId thePointId1,
93 const IVtk_PointId thePointId2,
94 const IVtk_PointId thePointId3,
95 const IVtk_MeshType theMeshType) Standard_OVERRIDE;
98 public: //! @name Specific methods
100 //! Get VTK PolyData.
101 //! @return VTK PolyData
102 vtkPolyData* getVtkPolyData() const
103 { return myPolyData; }
107 //! Wrapper over vtkGenericDataArray::InsertNextTypedTuple().
108 void insertNextSubShapeId (IVtk_IdType theShapeID,
109 IVtk_MeshType theMeshType)
111 const vtkIdType aShapeIDVTK = theShapeID;
112 const vtkIdType aType = theMeshType;
113 #if (VTK_MAJOR_VERSION > 7) || (VTK_MAJOR_VERSION == 7 && VTK_MINOR_VERSION >= 1)
114 mySubShapeIDs->InsertNextTypedTuple (&aShapeIDVTK);
115 myMeshTypes->InsertNextTypedTuple (&aType);
117 mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
118 myMeshTypes->InsertNextTupleValue (&aType);
123 vtkSmartPointer< vtkPolyData > myPolyData; //!< Shape geometry as vtkPolyData
124 vtkSmartPointer< vtkIdTypeArray > mySubShapeIDs; //!< Array of sub-shapes ids
125 vtkSmartPointer< vtkIdTypeArray > myMeshTypes; //!< Array of type codes of mesh parts
128 #endif // __IVTKVTK_SHAPEDATA_H__