vtkConnectedTubeFilter.h 6.37 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
bonnell's avatar
bonnell committed
3
* Copyright (c) 2000 - 2016, Lawrence Livermore National Security, LLC
hrchilds's avatar
hrchilds committed
4
* Produced at the Lawrence Livermore National Laboratory
5
* LLNL-CODE-442911
hrchilds's avatar
hrchilds committed
6 7
* All rights reserved.
*
8
* This file is  part of VisIt. For  details, see https://visit.llnl.gov/.  The
hrchilds's avatar
hrchilds committed
9 10 11 12 13 14 15 16 17 18
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution  and  use  in  source  and  binary  forms,  with  or  without
* modification, are permitted provided that the following conditions are met:
*
*  - Redistributions of  source code must  retain the above  copyright notice,
*    this list of conditions and the disclaimer below.
*  - Redistributions in binary form must reproduce the above copyright notice,
*    this  list of  conditions  and  the  disclaimer (as noted below)  in  the
19 20 21
*    documentation and/or other materials provided with the distribution.
*  - Neither the name of  the LLNS/LLNL nor the names of  its contributors may
*    be used to endorse or promote products derived from this software without
hrchilds's avatar
hrchilds committed
22 23 24 25 26
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR  IMPLIED WARRANTIES, INCLUDING,  BUT NOT  LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND  FITNESS FOR A PARTICULAR  PURPOSE
27 28 29
* ARE  DISCLAIMED. IN  NO EVENT  SHALL LAWRENCE  LIVERMORE NATIONAL  SECURITY,
* LLC, THE  U.S.  DEPARTMENT OF  ENERGY  OR  CONTRIBUTORS BE  LIABLE  FOR  ANY
* DIRECT,  INDIRECT,   INCIDENTAL,   SPECIAL,   EXEMPLARY,  OR   CONSEQUENTIAL
hrchilds's avatar
hrchilds committed
30 31 32 33 34 35 36 37 38
* DAMAGES (INCLUDING, BUT NOT  LIMITED TO, PROCUREMENT OF  SUBSTITUTE GOODS OR
* SERVICES; LOSS OF  USE, DATA, OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER
* CAUSED  AND  ON  ANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT
* LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY  WAY
* OUT OF THE  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/

hrchilds's avatar
hrchilds committed
39 40 41 42
#ifndef __vtkConnectedTubeFilter_h
#define __vtkConnectedTubeFilter_h
#include <visit_vtk_exports.h>

43
#include "vtkPolyDataAlgorithm.h"
hrchilds's avatar
hrchilds committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57

class vtkCellArray;
class vtkPoints;

// ****************************************************************************
//  Class:  vtkConnectedTubeFilter
//
//  Purpose:
//    A more suitable implementation of the vtkTubeFilter.  It assumes the
//    lines are all connected (it will return an error otherwise).
//
//  Programmer:  Jeremy Meredith
//  Creation:    November  1, 2002
//
58 59 60 61
//  Modifications:
//    Eric Brugger, Wed Jan  9 11:29:49 PST 2013
//    Modified to inherit from vtkPolyDataAlgorithm.
//
hrchilds's avatar
hrchilds committed
62
// ****************************************************************************
63
class VISIT_VTK_API vtkConnectedTubeFilter : public vtkPolyDataAlgorithm
hrchilds's avatar
hrchilds committed
64 65
{
  public:
66
    vtkTypeMacro(vtkConnectedTubeFilter,vtkPolyDataAlgorithm);
hrchilds's avatar
hrchilds committed
67
    void PrintSelf(ostream& os, vtkIndent indent);
68
    bool BuildConnectivityArrays(vtkPolyData *);
hrchilds's avatar
hrchilds committed
69 70 71 72 73 74 75 76

    // Description:
    // Construct object with radius 0.5, radius variation turned off, the number 
    // of sides set to 3, and radius factor of 10.
    static vtkConnectedTubeFilter *New();

    // Description:
    // Set the minimum tube radius (minimum because the tube radius may vary).
bonnell's avatar
bonnell committed
77
    vtkSetClampMacro(Radius,float,0.0,VTK_FLOAT_MAX);
hrchilds's avatar
hrchilds committed
78 79 80 81
    vtkGetMacro(Radius,float);

    // Description:
    // Set the number of sides for the tube. At a minimum, number of sides is 3.
bonnell's avatar
bonnell committed
82
    vtkSetClampMacro(NumberOfSides,int,3,VTK_INT_MAX);
hrchilds's avatar
hrchilds committed
83 84 85 86 87
    vtkGetMacro(NumberOfSides,int);

    // Description:
    // Set a boolean to control whether to create normals.
    // DefaultNormalOn is set.
bonnell's avatar
bonnell committed
88 89 90
    vtkSetMacro(CreateNormals,bool);
    vtkGetMacro(CreateNormals,bool);
    vtkBooleanMacro(CreateNormals,bool);
hrchilds's avatar
hrchilds committed
91 92 93

    // Description:
    // Turn on/off whether to cap the ends with polygons.
bonnell's avatar
bonnell committed
94 95 96
    vtkSetMacro(Capping,bool);
    vtkGetMacro(Capping,bool);
    vtkBooleanMacro(Capping,bool);
hrchilds's avatar
hrchilds committed
97 98 99 100 101 102 103 104

  protected:
    // ************************************************************************
    //  Class:  PointSequence
    //
    //  Purpose:
    //    Encapsulates a single doubly connected point sequence.
    //
105 106
    //    Jean Favre, Tue May  7 16:38:37 CEST 2013
    //    Used vtkIdType where needed
hrchilds's avatar
hrchilds committed
107 108 109 110
    // ************************************************************************
    struct PointSequence
    {
        int length;
111 112
        vtkIdType *index;
        vtkIdType *cellindex;
hrchilds's avatar
hrchilds committed
113 114 115 116
      public:
        PointSequence();
        ~PointSequence();
        void Init(int maxlen);
117
        void Add(vtkIdType i, vtkIdType ci);
hrchilds's avatar
hrchilds committed
118 119 120 121 122 123 124 125
    };

    // ************************************************************************
    //  Class:  PointSequenceList
    //
    //  Purpose:
    //    Encapsulates a list of separate point sequences.
    //
126 127 128 129
    //  Modifications:
    //    Rich Cook and Hank Childs, Thu Oct  2 16:31:45 PDT 2008
    //    Added data member to support tubing over loops.
    //
130 131
    //    Jean Favre, Tue May  7 16:38:37 CEST 2013
    //    Used vtkIdType where needed
hrchilds's avatar
hrchilds committed
132 133 134 135 136 137
    // ************************************************************************
    class PointSequenceList
    {
      private:
        // connectivity data
        int          len;
138 139 140
        vtkIdType         *numneighbors;
        vtkIdType         *connectivity[2];
        vtkIdType         *cellindex;
bonnell's avatar
bonnell committed
141
        vtkPoints   *pts;
hrchilds's avatar
hrchilds committed
142 143 144

        // traversal variables
        bool  *visited;
145
        vtkIdType    index;
146
        bool   lookforloops;
hrchilds's avatar
hrchilds committed
147 148 149 150 151 152 153 154 155 156 157 158
      public:
        PointSequenceList();
        ~PointSequenceList();
        bool Build(vtkPoints *points, vtkCellArray *lines);
        void InitTraversal();
        bool GetNextSequence(PointSequence &seq);
    };

  protected:
    vtkConnectedTubeFilter();
    ~vtkConnectedTubeFilter();

159 160 161
    virtual int RequestData(vtkInformation *,
                            vtkInformationVector **,
                            vtkInformationVector *);
hrchilds's avatar
hrchilds committed
162

bonnell's avatar
bonnell committed
163 164 165 166
    float Radius;       // minimum radius of tube
    int NumberOfSides;  // number of sides to create tube
    bool CreateNormals; // true to create normals
    bool Capping;       // true to cap ends
hrchilds's avatar
hrchilds committed
167 168 169 170 171 172 173 174 175

    PointSequenceList *pseqlist;

  private:
    vtkConnectedTubeFilter(const vtkConnectedTubeFilter&);  // Not implemented.
    void operator=(const vtkConnectedTubeFilter&);  // Not implemented.
};

#endif