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