0028452: VIS - MSVC 14 compiler warnings
[occt.git] / src / IVtkVTK / IVtkVTK_ShapeData.cxx
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#include <IVtkVTK_ShapeData.hxx>
a9660929 17
18// prevent disabling some MSVC warning messages by VTK headers
19#ifdef _MSC_VER
20#pragma warning(push)
21#endif
913a4c4a 22#include <vtkCellData.h>
23#include <vtkDoubleArray.h>
a2f76b15 24#include <vtkIdList.h>
913a4c4a 25#include <vtkIdTypeArray.h>
26#include <vtkPoints.h>
27#include <vtkPolyData.h>
a9660929 28#ifdef _MSC_VER
29#pragma warning(pop)
30#endif
913a4c4a 31
92efcf78 32IMPLEMENT_STANDARD_RTTIEXT(IVtkVTK_ShapeData,IVtk_IShapeData)
33
913a4c4a 34const char* const IVtkVTK_ShapeData::ARRNAME_SUBSHAPE_IDS = "SUBSHAPE_IDS";
35
36const char* const IVtkVTK_ShapeData::ARRNAME_MESH_TYPES = "MESH_TYPES";
37
38//! Handle implementation
913a4c4a 39
40
41//================================================================
42// Function : Constructor
43// Purpose :
44//================================================================
45IVtkVTK_ShapeData::IVtkVTK_ShapeData()
913a4c4a 46{
c16915c7 47 myPolyData = vtkSmartPointer<vtkPolyData>::New();
913a4c4a 48 myPolyData->Allocate();
a2f76b15 49 myPolyData->SetPoints (vtkSmartPointer<vtkPoints>::New());
913a4c4a 50
c16915c7 51 mySubShapeIDs = vtkSmartPointer<vtkIdTypeArray>::New();
913a4c4a 52 mySubShapeIDs->SetName (IVtkVTK_ShapeData::ARRNAME_SUBSHAPE_IDS);
53 mySubShapeIDs->SetNumberOfComponents (1);
54 myPolyData->GetCellData()->AddArray (mySubShapeIDs);
55
c16915c7 56 myMeshTypes = vtkSmartPointer<vtkIdTypeArray>::New();
913a4c4a 57 myMeshTypes->SetName (IVtkVTK_ShapeData::ARRNAME_MESH_TYPES);
58 myMeshTypes->SetNumberOfComponents (1);
59 myPolyData->GetCellData()->AddArray (myMeshTypes);
60}
61
62//================================================================
63// Function : Destructor
64// Purpose :
65//================================================================
66IVtkVTK_ShapeData::~IVtkVTK_ShapeData()
67{ }
68
69//================================================================
70// Function : InsertCoordinate
71// Purpose :
72//================================================================
73IVtk_PointId IVtkVTK_ShapeData::InsertCoordinate (double theX,
74 double theY,
75 double theZ)
76{
77 return myPolyData->GetPoints()->InsertNextPoint (theX, theY, theZ);
78}
79
80//================================================================
81// Function : InsertVertex
82// Purpose :
83//================================================================
84void IVtkVTK_ShapeData::InsertVertex (const IVtk_IdType theShapeID,
85 const IVtk_PointId thePointId,
86 const IVtk_MeshType theMeshType)
87{
88 vtkIdType aPointIdVTK = thePointId;
89 myPolyData->InsertNextCell (VTK_VERTEX, 1, &aPointIdVTK);
90 const vtkIdType aShapeIDVTK = theShapeID;
91 mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
92 const vtkIdType aType = theMeshType;
93 myMeshTypes->InsertNextTupleValue (&aType);
94}
95
96//================================================================
97// Function : InsertLine
98// Purpose :
99//================================================================
100void IVtkVTK_ShapeData::InsertLine (const IVtk_IdType theShapeID,
101 const IVtk_PointId thePointId1,
102 const IVtk_PointId thePointId2,
103 const IVtk_MeshType theMeshType)
104{
105 vtkIdType aPoints[2] = { thePointId1, thePointId2 };
106 myPolyData->InsertNextCell (VTK_LINE, 2, aPoints);
107 const vtkIdType aShapeIDVTK = theShapeID;
108 mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
109 const vtkIdType aType = theMeshType;
110 myMeshTypes->InsertNextTupleValue (&aType);
111}
112
113//================================================================
114// Function : InsertLine
115// Purpose :
116//================================================================
117void IVtkVTK_ShapeData::InsertLine (const IVtk_IdType theShapeID,
118 const IVtk_PointIdList* thePointIds,
119 const IVtk_MeshType theMeshType)
120{
121 if (!thePointIds->IsEmpty())
122 {
a2f76b15 123 vtkSmartPointer<vtkIdList> anIdList = vtkSmartPointer<vtkIdList>::New();
913a4c4a 124 // Fill the vtk id list by ids from IVtk_PointIdList.
125 IVtk_PointIdList::Iterator anIterOfIds =
126 IVtk_PointIdList::Iterator(*thePointIds);
127 anIdList->Allocate(thePointIds->Extent());
128 for(; anIterOfIds.More(); anIterOfIds.Next())
129 {
130 anIdList->InsertNextId (anIterOfIds.Value());
131 }
132
133 myPolyData->InsertNextCell (VTK_POLY_LINE, anIdList);
134 const vtkIdType aShapeIDVTK = theShapeID;
135 mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
136 const vtkIdType aType = theMeshType;
137 myMeshTypes->InsertNextTupleValue (&aType);
913a4c4a 138 }
139}
140
141//================================================================
142// Function : InsertTriangle
143// Purpose :
144//================================================================
145void IVtkVTK_ShapeData::InsertTriangle (const IVtk_IdType theShapeID,
146 const IVtk_PointId thePointId1,
147 const IVtk_PointId thePointId2,
148 const IVtk_PointId thePointId3,
149 const IVtk_MeshType theMeshType)
150{
151 vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
152 myPolyData->InsertNextCell (VTK_TRIANGLE, 3, aPoints);
153 const vtkIdType aShapeIDVTK = theShapeID;
154 mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
155 const vtkIdType aType = theMeshType;
156 myMeshTypes->InsertNextTupleValue (&aType);
157}