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 | #ifndef __IVTKTOOLS_SHAPEDATASOURCE_H__ |
17 | #define __IVTKTOOLS_SHAPEDATASOURCE_H__ |
18 | |
19 | #include <IVtkTools.hxx> |
20 | #include <IVtkOCC_Shape.hxx> |
21 | #include <IVtkVTK_ShapeData.hxx> |
22 | #include <vtkInformationIdTypeKey.h> |
23 | #include <vtkPolyDataAlgorithm.h> |
24 | #include <vtkType.h> |
25 | #include <vtkSmartPointer.h> |
26 | |
27 | class vtkIdTypeArray; |
28 | class vtkPolyData; |
29 | |
30 | //! @class IVtkTools_ShapeDataSource. |
31 | //! @brief VTK data source for OCC shapes polygonal data. |
32 | class IVtkTools_EXPORT IVtkTools_ShapeDataSource : public vtkPolyDataAlgorithm |
33 | { |
34 | public: |
35 | |
68858c7d |
36 | vtkTypeMacro(IVtkTools_ShapeDataSource, vtkPolyDataAlgorithm) |
37 | |
913a4c4a |
38 | static IVtkTools_ShapeDataSource* New(); |
39 | |
40 | |
41 | public: //! @name Initialization |
42 | |
43 | //! Set the source OCCT shape. |
44 | //! @param theOccShape [in] OCCT shape wrapper. |
45 | void SetShape(const IVtkOCC_Shape::Handle& theOccShape); |
46 | |
47 | //! Get the source OCCT shape. |
48 | //! @return occShape OCCT shape wrapper. |
49 | IVtkOCC_Shape::Handle GetShape(); |
50 | inline void FastTransformModeOn() { myIsFastTransformMode = true; } |
51 | inline void FastTransformModeOff() { myIsFastTransformMode = false; } |
52 | |
53 | public: //! @name Data accessors |
54 | |
55 | //! Returns ID of the shape used as a topological input for this data source. |
56 | //! @return requested ID. |
57 | IVtk_IdType GetId() const; |
58 | |
59 | //! Checks if the internal OccShape pointer is the same the argument. |
60 | //! @param [in] shape OccShape pointer to be checked. |
61 | //! @return true if the two OccShape instances are the same, and false otherwise. |
62 | Standard_Boolean Contains (const IVtkOCC_Shape::Handle& theOccShape) const; |
63 | |
64 | //! Access to the shape's sub-shape ids array |
65 | //! @returns the array cast to vtkIdTypeArray |
66 | vtkSmartPointer<vtkIdTypeArray> SubShapeIDs(); |
67 | |
68 | protected: //! @name Interface to override |
69 | |
70 | //! This is called by the superclass. |
71 | //! This is the method you should override if you use this class as ancestor. |
72 | //! Build output polygonal data set from the shape wrapper. |
73 | //! @param theRequest [in] information about data object. |
74 | //! In current implementation it is ignored. |
75 | //! @param theInputVector [in] the input data. As adata source is the start |
76 | //! stage of the VTK pipeline, theInputVector is empty and not used (no input port). |
77 | //! @param theOutputVector [in] the pointer to output data, that is filled in this method. |
78 | virtual int RequestData(vtkInformation* theRequest, |
79 | vtkInformationVector** theInputVector, |
80 | vtkInformationVector* theOutputVector); |
81 | |
82 | protected: //! @name Internals |
83 | |
84 | //! Transforms the passed polygonal data by the given OCCT transformation |
85 | //! matrix. |
86 | //! @param theSource [in] source polygonal data to transform. |
87 | //! @param theTrsf [in] transformation to apply. |
88 | //! @return resulting polygonal data (transformed copy of source). |
89 | vtkSmartPointer<vtkPolyData> transform (vtkPolyData* theSource, const gp_Trsf& theTrsf) const; |
90 | |
91 | protected: |
92 | |
93 | IVtkTools_ShapeDataSource(); |
94 | ~IVtkTools_ShapeDataSource(); |
95 | |
96 | private: |
97 | |
98 | IVtkTools_ShapeDataSource (const IVtkTools_ShapeDataSource&); |
99 | IVtkTools_ShapeDataSource& operator= (const IVtkTools_ShapeDataSource&); |
100 | |
101 | private: |
102 | |
103 | IVtkOCC_Shape::Handle myOccShape; //!< Shape wrapper used as an input. |
104 | IVtkVTK_ShapeData::Handle myPolyData; //!< Polygonal representation of shape. |
105 | |
106 | //! Indicates whether light-weighted processing for transformed shapes is |
107 | //! enabled. If so, data source does not re-compute the discrete model for |
108 | //! the input topological shape. It rather uses the already existing one |
109 | //! and applies the necessary transformation to it. |
110 | Standard_Boolean myIsFastTransformMode; |
111 | |
112 | //! Internal flag indicating that the current working shape is just a |
113 | //! transformed copy of the previously processed one. This flag is used in |
114 | //! a couple with "fast transformation" mode flag. |
115 | Standard_Boolean myIsTransformOnly; |
116 | |
117 | }; |
118 | |
119 | #endif // __IVTKTOOLS_SHAPEDATA_H__ |