0027097: GCC and CLang compiler warnings and errors with -Wpedantic
[occt.git] / src / IVtkTools / IVtkTools_DisplayModeFilter.cxx
CommitLineData
913a4c4a 1// Created on: 2011-11-15
2// Created by: Roman KOZLOV
3// Copyright (c) 2001-2012 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 <IVtkTools_DisplayModeFilter.hxx>
17#include <IVtkVTK_ShapeData.hxx>
18#include <vtkInformation.h>
19#include <vtkInformationVector.h>
20#include <vtkObjectFactory.h>
21
68858c7d 22vtkStandardNewMacro(IVtkTools_DisplayModeFilter)
913a4c4a 23
24//============================================================================
25// Method: Constructor
26// Purpose:
27//============================================================================
28IVtkTools_DisplayModeFilter::IVtkTools_DisplayModeFilter()
29 : myDisplayMode (DM_Wireframe),
30 myDoDisplaySharedVertices (false)
31{
32 // Filter according to values in subshapes types array.
33 myIdsArrayName = IVtkVTK_ShapeData::ARRNAME_MESH_TYPES;
34
35 IVtk_IdTypeMap aTypes;
36
37 aTypes.Add (MT_IsoLine);
38 aTypes.Add (MT_FreeVertex);
39 aTypes.Add (MT_FreeEdge);
40 aTypes.Add (MT_BoundaryEdge);
41 aTypes.Add (MT_SharedEdge);
42 aTypes.Add (MT_WireFrameFace);
43
44 myModesDefinition.Bind (DM_Wireframe, aTypes);
45
46 aTypes.Clear();
47 aTypes.Add (MT_FreeVertex);
48 aTypes.Add (MT_ShadedFace);
49
50 myModesDefinition.Bind (DM_Shading, aTypes);
51}
52
53//============================================================================
54// Method: Destructor
55// Purpose:
56//============================================================================
57IVtkTools_DisplayModeFilter::~IVtkTools_DisplayModeFilter() { }
58
59//============================================================================
60// Method: RequestData
61// Purpose: Filters cells according to the selected display mode by mesh
62// parts types.
63//============================================================================
64int IVtkTools_DisplayModeFilter::RequestData (vtkInformation *theRequest,
65 vtkInformationVector **theInputVector,
66 vtkInformationVector *theOutputVector)
67{
68 SetData (myModesDefinition.Find (myDisplayMode));
69 return Superclass::RequestData (theRequest, theInputVector, theOutputVector);
70}
71
72//============================================================================
73// Method: PrintSelf
74// Purpose:
75//============================================================================
76void IVtkTools_DisplayModeFilter::PrintSelf (std::ostream& theOs, vtkIndent theIndent)
77{
78 this->Superclass::PrintSelf (theOs, theIndent);
79 theOs << theIndent << "IVtkTools_DisplayModeFilter: display mode = ";
80 if (myDisplayMode == DM_Wireframe)
81 {
82 theOs << "Wireframe\n";
83 }
84 else
85 {
86 theOs << "Shading\n";
87 }
88}
89
90//============================================================================
91// Method: SetDisplaySharedVertices
92// Purpose:
93//============================================================================
94void IVtkTools_DisplayModeFilter::SetDisplaySharedVertices (const bool theDoDisplay)
95{
96 if (myDoDisplaySharedVertices != theDoDisplay)
97 {
98 myDoDisplaySharedVertices = theDoDisplay;
99 vtkIdType aVertexType = MT_SharedVertex;
100 NCollection_DataMap<IVtk_DisplayMode, IVtk_IdTypeMap>::Iterator aModes (myModesDefinition);
101 NCollection_DataMap<IVtk_DisplayMode, IVtk_IdTypeMap> aNewModes;
102 IVtk_IdTypeMap aModeTypes;
103 for (; aModes.More(); aModes.Next())
104 {
105 aModeTypes = aModes.Value();
106 if (theDoDisplay && !aModeTypes.Contains(aVertexType))
107 {
108 aModeTypes.Add (aVertexType);
109 }
110 else if (!theDoDisplay && aModeTypes.Contains (aVertexType))
111 {
112 aModeTypes.Remove (aVertexType);
113 }
114 aNewModes.Bind (aModes.Key(), aModeTypes);
115 }
116 myModesDefinition = aNewModes;
117 Modified();
118 }
119}
120
121//============================================================================
122// Method: SetDisplayMode
123// Purpose:
124//============================================================================
125void IVtkTools_DisplayModeFilter::SetDisplayMode(const IVtk_DisplayMode theMode)
126{
127 if (myDisplayMode != theMode)
128 {
129 myDisplayMode = theMode;
130 Modified();
131 }
132}
133
134//============================================================================
135// Method: GetDisplayMode
136// Purpose:
137//============================================================================
c7854818 138IVtk_DisplayMode IVtkTools_DisplayModeFilter::GetDisplayMode () const
913a4c4a 139{
140 return myDisplayMode;
141}
142