1 // Created on: 2011-10-27
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 __IVTKTOOLS_SHAPEOBJECT_H__
17 #define __IVTKTOOLS_SHAPEOBJECT_H__
19 #include <IVtkTools.hxx>
20 #include <IVtkOCC_Shape.hxx>
22 // prevent disabling some MSVC warning messages by VTK headers
26 #include <vtkDataObject.h>
27 #include <vtkSetGet.h>
28 #include <vtkWeakPointer.h>
35 class vtkInformationObjectBaseKey;
36 class IVtkTools_ShapeDataSource;
40 #pragma warning(disable: 4251) // avoid warning C4251: "class needs to have dll-interface..."
43 //! @class IVtkTools_ShapeObject
44 //! @brief VTK holder class for OCC shapes to pass them through pipelines.
46 //! It is descendent of vtkObject (data). Logically it is a one of milestones of VTK pipeline.
47 //! It stores data of OCC shape (the OccShape instance) in vtkInformation object of vtkDataObject.
48 //! Then pass it to the actors through pipelines,
49 //! so selection logic can access OccShape easily given the actor instance.
50 class Standard_EXPORT IVtkTools_ShapeObject : public vtkDataObject
53 vtkTypeMacro (IVtkTools_ShapeObject, vtkDataObject)
55 static IVtkTools_ShapeObject* New();
57 //! Get OCC shape source from VTK data from actor's information object by key.
58 static vtkSmartPointer<IVtkTools_ShapeDataSource> GetShapeSource (vtkActor* theActor);
60 //! Get OCC shape from VTK data from actor's information object by key.
61 static IVtkOCC_Shape::Handle GetOccShape (vtkActor* theActor);
63 //! Static method to set OCC shape source to VTK dataset in information object
65 static void SetShapeSource (IVtkTools_ShapeDataSource* theDataSource, vtkDataSet* theData);
67 //! Static method to set OCC shape source to VTK actor in information object
69 static void SetShapeSource (IVtkTools_ShapeDataSource* theDataSource, vtkActor* theActor);
71 typedef vtkInformationObjectBaseKey* KeyPtr;
73 //! Static method used by shape selection logic in order to establish
74 //! a connection from vtkActor to OccShape instance.
75 //! @return vtkInformationKey for retrieving OccShape instance from the actor
76 static KeyPtr getKey();
78 //! OCC shape source setter.
79 void SetShapeSource (IVtkTools_ShapeDataSource* theDataSource);
81 //! OCC shape source getter.
82 IVtkTools_ShapeDataSource* GetShapeSource() const;
85 IVtkTools_ShapeObject();
86 virtual ~IVtkTools_ShapeObject();
88 private: // not copyable
89 IVtkTools_ShapeObject (const IVtkTools_ShapeObject&);
90 IVtkTools_ShapeObject& operator= (const IVtkTools_ShapeObject&);
93 vtkWeakPointer<IVtkTools_ShapeDataSource> myShapeSource;
102 #endif // __IVTKTOOLS_SHAPEOBJECT_H__