1 // Created on: 2011-11-15
2 // Created by: Roman KOZLOV
3 // Copyright (c) 2001-2012 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 #include <IVtkTools_DisplayModeFilter.hxx>
17 #include <IVtkVTK_ShapeData.hxx>
19 // prevent disabling some MSVC warning messages by VTK headers
23 #include <vtkInformation.h>
24 #include <vtkInformationVector.h>
25 #include <vtkObjectFactory.h>
30 vtkStandardNewMacro(IVtkTools_DisplayModeFilter)
32 //============================================================================
33 // Method: Constructor
35 //============================================================================
36 IVtkTools_DisplayModeFilter::IVtkTools_DisplayModeFilter()
37 : myDisplayMode (DM_Wireframe),
38 myDoDisplaySharedVertices (false),
39 myDrawFaceBoundaries( false )
41 // Filter according to values in subshapes types array.
42 myIdsArrayName = IVtkVTK_ShapeData::ARRNAME_MESH_TYPES();
44 IVtk_IdTypeMap aTypes;
46 aTypes.Add (MT_IsoLine);
47 aTypes.Add (MT_FreeVertex);
48 aTypes.Add (MT_FreeEdge);
49 aTypes.Add (MT_BoundaryEdge);
50 aTypes.Add (MT_SharedEdge);
51 aTypes.Add (MT_SeamEdge);
52 aTypes.Add (MT_WireFrameFace);
54 myModesDefinition[DM_Wireframe] = aTypes;
57 aTypes.Add (MT_FreeVertex);
58 aTypes.Add (MT_ShadedFace);
60 myModesDefinition[DM_Shading] = aTypes;
63 //============================================================================
66 //============================================================================
67 IVtkTools_DisplayModeFilter::~IVtkTools_DisplayModeFilter()
71 //============================================================================
72 // Method: RequestData
73 // Purpose: Filters cells according to the selected display mode by mesh
75 //============================================================================
76 int IVtkTools_DisplayModeFilter::RequestData (vtkInformation *theRequest,
77 vtkInformationVector **theInputVector,
78 vtkInformationVector *theOutputVector)
80 SetData (myModesDefinition[myDisplayMode]);
81 return Superclass::RequestData (theRequest, theInputVector, theOutputVector);
84 //============================================================================
87 //============================================================================
88 void IVtkTools_DisplayModeFilter::PrintSelf (std::ostream& theOs, vtkIndent theIndent)
90 this->Superclass::PrintSelf (theOs, theIndent);
91 theOs << theIndent << "IVtkTools_DisplayModeFilter: display mode = ";
92 if (myDisplayMode == DM_Wireframe)
94 theOs << "Wireframe\n";
102 //============================================================================
103 // Method: SetDisplaySharedVertices
105 //============================================================================
106 void IVtkTools_DisplayModeFilter::SetDisplaySharedVertices (const bool theDoDisplay)
108 if (myDoDisplaySharedVertices != theDoDisplay)
110 myDoDisplaySharedVertices = theDoDisplay;
111 IVtk_IdTypeMap aModeTypes;
112 for (int i = 0; i < 2; i++)
114 aModeTypes = myModesDefinition[i];
115 if (theDoDisplay && !aModeTypes.Contains(MT_SharedVertex))
117 aModeTypes.Add (MT_SharedVertex);
119 else if (!theDoDisplay && aModeTypes.Contains (MT_SharedVertex))
121 aModeTypes.Remove (MT_SharedVertex);
123 myModesDefinition[i] = aModeTypes;
129 //============================================================================
130 // Method: SetDisplayMode
132 //============================================================================
133 void IVtkTools_DisplayModeFilter::SetDisplayMode(const IVtk_DisplayMode theMode)
135 if (myDisplayMode != theMode)
137 myDisplayMode = theMode;
142 //============================================================================
143 // Method: GetDisplayMode
145 //============================================================================
146 IVtk_DisplayMode IVtkTools_DisplayModeFilter::GetDisplayMode () const
148 return myDisplayMode;
151 //============================================================================
152 // Method: meshTypesForMode
154 //============================================================================
155 const IVtk_IdTypeMap& IVtkTools_DisplayModeFilter::MeshTypesForMode(IVtk_DisplayMode theMode) const
157 return myModesDefinition[theMode];
160 //============================================================================
161 // Method: setMeshTypesForMode
163 //============================================================================
164 void IVtkTools_DisplayModeFilter::SetMeshTypesForMode(IVtk_DisplayMode theMode, const IVtk_IdTypeMap& theMeshTypes)
166 myModesDefinition[theMode] = theMeshTypes;
170 //============================================================================
171 // Method: SetFaceBoundaryDraw
173 //============================================================================
174 void IVtkTools_DisplayModeFilter::SetFaceBoundaryDraw(bool theToDraw)
176 myDrawFaceBoundaries = theToDraw;
178 myModesDefinition[DM_Shading].Add(MT_BoundaryEdge);
179 myModesDefinition[DM_Shading].Add(MT_SharedEdge);
182 myModesDefinition[DM_Shading].Remove(MT_BoundaryEdge);
183 myModesDefinition[DM_Shading].Remove(MT_SharedEdge);