0022651: Impossible to build OCC as static library due to using Standard_EXPORT inste...
[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>
a9660929 18
19// prevent disabling some MSVC warning messages by VTK headers
20#ifdef _MSC_VER
21#pragma warning(push)
22#endif
913a4c4a 23#include <vtkInformation.h>
24#include <vtkInformationVector.h>
25#include <vtkObjectFactory.h>
a9660929 26#ifdef _MSC_VER
27#pragma warning(pop)
28#endif
913a4c4a 29
68858c7d 30vtkStandardNewMacro(IVtkTools_DisplayModeFilter)
913a4c4a 31
32//============================================================================
33// Method: Constructor
34// Purpose:
35//============================================================================
36IVtkTools_DisplayModeFilter::IVtkTools_DisplayModeFilter()
37 : myDisplayMode (DM_Wireframe),
38 myDoDisplaySharedVertices (false)
39{
40 // Filter according to values in subshapes types array.
68df8478 41 myIdsArrayName = IVtkVTK_ShapeData::ARRNAME_MESH_TYPES();
913a4c4a 42
43 IVtk_IdTypeMap aTypes;
44
45 aTypes.Add (MT_IsoLine);
46 aTypes.Add (MT_FreeVertex);
47 aTypes.Add (MT_FreeEdge);
48 aTypes.Add (MT_BoundaryEdge);
49 aTypes.Add (MT_SharedEdge);
50 aTypes.Add (MT_WireFrameFace);
51
52 myModesDefinition.Bind (DM_Wireframe, aTypes);
53
54 aTypes.Clear();
55 aTypes.Add (MT_FreeVertex);
56 aTypes.Add (MT_ShadedFace);
57
58 myModesDefinition.Bind (DM_Shading, aTypes);
59}
60
61//============================================================================
62// Method: Destructor
63// Purpose:
64//============================================================================
65IVtkTools_DisplayModeFilter::~IVtkTools_DisplayModeFilter() { }
66
67//============================================================================
68// Method: RequestData
69// Purpose: Filters cells according to the selected display mode by mesh
70// parts types.
71//============================================================================
72int IVtkTools_DisplayModeFilter::RequestData (vtkInformation *theRequest,
73 vtkInformationVector **theInputVector,
74 vtkInformationVector *theOutputVector)
75{
76 SetData (myModesDefinition.Find (myDisplayMode));
77 return Superclass::RequestData (theRequest, theInputVector, theOutputVector);
78}
79
80//============================================================================
81// Method: PrintSelf
82// Purpose:
83//============================================================================
84void IVtkTools_DisplayModeFilter::PrintSelf (std::ostream& theOs, vtkIndent theIndent)
85{
86 this->Superclass::PrintSelf (theOs, theIndent);
87 theOs << theIndent << "IVtkTools_DisplayModeFilter: display mode = ";
88 if (myDisplayMode == DM_Wireframe)
89 {
90 theOs << "Wireframe\n";
91 }
92 else
93 {
94 theOs << "Shading\n";
95 }
96}
97
98//============================================================================
99// Method: SetDisplaySharedVertices
100// Purpose:
101//============================================================================
102void IVtkTools_DisplayModeFilter::SetDisplaySharedVertices (const bool theDoDisplay)
103{
104 if (myDoDisplaySharedVertices != theDoDisplay)
105 {
106 myDoDisplaySharedVertices = theDoDisplay;
107 vtkIdType aVertexType = MT_SharedVertex;
108 NCollection_DataMap<IVtk_DisplayMode, IVtk_IdTypeMap>::Iterator aModes (myModesDefinition);
109 NCollection_DataMap<IVtk_DisplayMode, IVtk_IdTypeMap> aNewModes;
110 IVtk_IdTypeMap aModeTypes;
111 for (; aModes.More(); aModes.Next())
112 {
113 aModeTypes = aModes.Value();
114 if (theDoDisplay && !aModeTypes.Contains(aVertexType))
115 {
116 aModeTypes.Add (aVertexType);
117 }
118 else if (!theDoDisplay && aModeTypes.Contains (aVertexType))
119 {
120 aModeTypes.Remove (aVertexType);
121 }
122 aNewModes.Bind (aModes.Key(), aModeTypes);
123 }
124 myModesDefinition = aNewModes;
125 Modified();
126 }
127}
128
129//============================================================================
130// Method: SetDisplayMode
131// Purpose:
132//============================================================================
133void IVtkTools_DisplayModeFilter::SetDisplayMode(const IVtk_DisplayMode theMode)
134{
135 if (myDisplayMode != theMode)
136 {
137 myDisplayMode = theMode;
138 Modified();
139 }
140}
141
142//============================================================================
143// Method: GetDisplayMode
144// Purpose:
145//============================================================================
c7854818 146IVtk_DisplayMode IVtkTools_DisplayModeFilter::GetDisplayMode () const
913a4c4a 147{
148 return myDisplayMode;
149}
150