vtkVolumeFromVolume.C 34.1 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
3
* Copyright (c) 2000 - 2014, 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 43 44
// ************************************************************************* //
//                           vtkVolumeFromVolume.C                          //
// ************************************************************************* //

#include <vtkVolumeFromVolume.h>

hrchilds's avatar
hrchilds committed
45
#include <vtkCellArray.h>
hrchilds's avatar
hrchilds committed
46
#include <vtkCellData.h>
hrchilds's avatar
hrchilds committed
47 48
#include <vtkCellType.h>
#include <vtkIdList.h>
hrchilds's avatar
hrchilds committed
49
#include <vtkIdTypeArray.h>
hrchilds's avatar
hrchilds committed
50
#include <vtkIntArray.h>
hrchilds's avatar
hrchilds committed
51 52
#include <vtkPointData.h>
#include <vtkUnstructuredGrid.h>
hrchilds's avatar
hrchilds committed
53
#include <vtkUnsignedCharArray.h>
hrchilds's avatar
hrchilds committed
54

55
#include <vtkAccessors.h>
hrchilds's avatar
hrchilds committed
56

hrchilds's avatar
hrchilds committed
57 58 59 60 61 62
// ****************************************************************************
//  Method: vtkVolumeFromVolume constructor
//
//  Programmer: Hank Childs
//  Creation:   October 21, 2004
//
hrchilds's avatar
hrchilds committed
63 64 65 66 67 68 69
//  Modifications:
//
//    Hank Childs, Sun Oct 24 21:05:03 PDT 2004
//    Change ordering of shapes back to the way it was before all of the 
//    shapes were put in a vector.  This way we won't have to update baseline
//    images.
//
hrchilds's avatar
hrchilds committed
70 71 72
//    Jeremy Meredith, Tue Aug 29 15:47:28 EDT 2006
//    Added lines and vertices.
//
hrchilds's avatar
hrchilds committed
73 74
// ****************************************************************************

75
vtkVolumeFromVolume::vtkVolumeFromVolume(vtkIdType nPts, vtkIdType ptSizeGuess)
hrchilds's avatar
hrchilds committed
76
    : vtkDataSetFromVolume(nPts, ptSizeGuess), nshapes(8)
hrchilds's avatar
hrchilds committed
77
{
hrchilds's avatar
hrchilds committed
78 79 80 81
    shapes[0] = &tets;
    shapes[1] = &pyramids;
    shapes[2] = &wedges;
    shapes[3] = &hexes;
hrchilds's avatar
hrchilds committed
82 83
    shapes[4] = &quads;
    shapes[5] = &tris;
hrchilds's avatar
hrchilds committed
84 85
    shapes[6] = &lines;
    shapes[7] = &vertices;
hrchilds's avatar
hrchilds committed
86 87
}

hrchilds's avatar
hrchilds committed
88 89 90 91 92 93 94
vtkVolumeFromVolume::CentroidPointList::CentroidPointList()
{
    listSize = 4096;
    pointsPerList = 1024;
 
    list = new CentroidPointEntry*[listSize];
    list[0] = new CentroidPointEntry[pointsPerList];
95
    for (vtkIdType i = 1 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
96 97 98 99 100 101 102 103 104
        list[i] = NULL;
 
    currentList = 0;
    currentPoint = 0;
}
 
 
vtkVolumeFromVolume::CentroidPointList::~CentroidPointList()
{
105
    for (vtkIdType i = 0 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
106 107 108 109 110 111 112 113 114 115
    {
        if (list[i] != NULL)
            delete [] list[i];
        else
            break;
    }
    delete [] list;
}


116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
void
vtkVolumeFromVolume::CentroidPointList::Clear()
{
    for (vtkIdType i = 0 ; i < listSize ; i++)
    {
        if (list[i] != NULL)
        {
            delete [] list[i];
            list[i] = NULL;
        }
        else
            break;
    }
    list[0] = new CentroidPointEntry[pointsPerList];

    currentList = 0;
    currentPoint = 0;
}


136 137
vtkIdType
vtkVolumeFromVolume::CentroidPointList::GetList(vtkIdType listId,
hrchilds's avatar
hrchilds committed
138 139 140 141 142 143 144 145 146 147 148 149 150
                                    const CentroidPointEntry *&outlist) const
{
    if (listId < 0 || listId > currentList)
    {
        outlist = NULL;
        return 0;
    }
 
    outlist = list[listId];
    return (listId == currentList ? currentPoint : pointsPerList);
}
 
 
151
vtkIdType
hrchilds's avatar
hrchilds committed
152 153 154 155 156 157
vtkVolumeFromVolume::CentroidPointList::GetNumberOfLists(void) const
{
    return currentList+1;
}
 
 
158
vtkIdType
hrchilds's avatar
hrchilds committed
159 160
vtkVolumeFromVolume::CentroidPointList::GetTotalNumberOfPoints(void) const
{
161 162
    vtkIdType numFullLists = currentList;  // actually currentList-1+1
    vtkIdType numExtra = currentPoint;  // again, currentPoint-1+1
hrchilds's avatar
hrchilds committed
163 164 165 166 167
 
    return numFullLists*pointsPerList + numExtra;
}


hrchilds's avatar
hrchilds committed
168 169 170 171
//
//    Mark C. Miller, Sun Dec  3 12:20:11 PST 2006
//    Fixed off-by-one error in test to resize list
//
hrchilds's avatar
hrchilds committed
172 173 174 175
//    Sean Ahern, Mon Mar  5 15:35:00 EST 2007
//    Fixed test for resizing list.  You really do need the +1.
//    Initialized new entries.
//
176 177
vtkIdType
vtkVolumeFromVolume::CentroidPointList::AddPoint(vtkIdType npts, const vtkIdType *pts)
hrchilds's avatar
hrchilds committed
178 179 180
{
    if (currentPoint >= pointsPerList)
    {
hrchilds's avatar
hrchilds committed
181
        if ((currentList+1) >= listSize)
hrchilds's avatar
hrchilds committed
182 183
        {
            CentroidPointEntry **tmpList = new CentroidPointEntry*[2*listSize];
184
            for (vtkIdType i = 0 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
185
                tmpList[i] = list[i];
186
            for (vtkIdType i = listSize ; i < listSize*2 ; i++)
hrchilds's avatar
hrchilds committed
187
                tmpList[i] = NULL;
hrchilds's avatar
hrchilds committed
188 189 190 191 192 193 194 195 196 197 198
            listSize *= 2;
            delete [] list;
            list = tmpList;
        }
 
        currentList++;
        list[currentList] = new CentroidPointEntry[pointsPerList];
        currentPoint = 0;
    }
 
    list[currentList][currentPoint].nPts = npts;
199
    for (vtkIdType i = 0 ; i < npts ; i++)
hrchilds's avatar
hrchilds committed
200 201 202 203 204 205 206 207 208
    {
        list[currentList][currentPoint].ptIds[i] = pts[i];
    }
    currentPoint++;
 
    return (GetTotalNumberOfPoints()-1);
}


209
vtkVolumeFromVolume::ShapeList::ShapeList(vtkIdType size)
hrchilds's avatar
hrchilds committed
210 211 212 213 214
{
    shapeSize = size;
    listSize = 4096;
    shapesPerList = 1024;
 
215 216 217
    list = new vtkIdType*[listSize];
    list[0] = new vtkIdType[(shapeSize+1)*shapesPerList];
    for (vtkIdType i = 1 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
218 219 220 221 222 223 224 225 226
        list[i] = NULL;
 
    currentList = 0;
    currentShape = 0;
}
 
 
vtkVolumeFromVolume::ShapeList::~ShapeList()
{
227
    for (vtkIdType i = 0 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
228 229 230 231 232 233 234 235 236 237
    {
        if (list[i] != NULL)
            delete [] list[i];
        else
            break;
    }
    delete [] list;
}
 
 
238 239
vtkIdType
vtkVolumeFromVolume::ShapeList::GetList(vtkIdType listId, const vtkIdType *&outlist)
hrchilds's avatar
hrchilds committed
240 241 242 243 244 245 246 247 248 249 250 251 252
    const
{
    if (listId < 0 || listId > currentList)
    {
        outlist = NULL;
        return 0;
    }
 
    outlist = list[listId];
    return (listId == currentList ? currentShape : shapesPerList);
}
 
 
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
vtkIdType
vtkVolumeFromVolume::ShapeList::GetList(vtkIdType listId, vtkIdType *&outlist)
    const
{
    if (listId < 0 || listId > currentList)
    {
        outlist = NULL;
        return 0;
    }
 
    outlist = list[listId];
    return (listId == currentList ? currentShape : shapesPerList);
}
 
 
268
vtkIdType
hrchilds's avatar
hrchilds committed
269 270 271 272 273 274
vtkVolumeFromVolume::ShapeList::GetNumberOfLists(void) const
{
    return currentList+1;
}


275
vtkIdType
hrchilds's avatar
hrchilds committed
276 277
vtkVolumeFromVolume::ShapeList::GetTotalNumberOfShapes(void) const
{
278 279
    vtkIdType numFullLists = currentList;  // actually currentList-1+1
    vtkIdType numExtra = currentShape;  // again, currentShape-1+1
hrchilds's avatar
hrchilds committed
280 281 282 283 284 285 286 287 288 289 290 291 292 293
 
    return numFullLists*shapesPerList + numExtra;
}

vtkVolumeFromVolume::HexList::HexList()
    : vtkVolumeFromVolume::ShapeList(8)
{
}
 

vtkVolumeFromVolume::HexList::~HexList()
{
}
 
hrchilds's avatar
hrchilds committed
294 295 296 297 298 299
// ****************************************************************************
//  Modifications:
//
//    Hank Childs, Thu Oct 21 15:32:07 PDT 2004
//    Fix bug where we run out of memory.
//
hrchilds's avatar
hrchilds committed
300 301
//    Mark C. Miller, Sun Dec  3 12:20:11 PST 2006
//    Fixed off-by-one error in test to resize list
hrchilds's avatar
hrchilds committed
302 303 304 305
//    
//    Sean Ahern, Mon Mar  5 15:43:19 EST 2007
//    Fixed test for resizing list.  You really do need the +1.
//    Initialized new entries.
hrchilds's avatar
hrchilds committed
306
//
hrchilds's avatar
hrchilds committed
307 308
// ****************************************************************************

hrchilds's avatar
hrchilds committed
309
void
310 311 312
vtkVolumeFromVolume::HexList::AddHex(vtkIdType cellId,
    vtkIdType v1, vtkIdType v2, vtkIdType v3, vtkIdType v4,
    vtkIdType v5, vtkIdType v6, vtkIdType v7, vtkIdType v8)
hrchilds's avatar
hrchilds committed
313 314 315
{
    if (currentShape >= shapesPerList)
    {
hrchilds's avatar
hrchilds committed
316
        if ((currentList+1) >= listSize)
hrchilds's avatar
hrchilds committed
317
        {
318 319
            vtkIdType **tmpList = new vtkIdType*[2*listSize];
            for (vtkIdType i = 0 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
320
                tmpList[i] = list[i];
321
            for (vtkIdType i = listSize ; i < listSize*2 ; i++)
hrchilds's avatar
hrchilds committed
322 323
                tmpList[i] = NULL;

hrchilds's avatar
hrchilds committed
324 325 326 327 328 329
            listSize *= 2;
            delete [] list;
            list = tmpList;
        }
 
        currentList++;
330
        list[currentList] = new vtkIdType[(shapeSize+1)*shapesPerList];
hrchilds's avatar
hrchilds committed
331 332 333
        currentShape = 0;
    }
 
334
    vtkIdType idx = (shapeSize+1)*currentShape;
hrchilds's avatar
hrchilds committed
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
    list[currentList][idx+0] = cellId;
    list[currentList][idx+1] = v1;
    list[currentList][idx+2] = v2;
    list[currentList][idx+3] = v3;
    list[currentList][idx+4] = v4;
    list[currentList][idx+5] = v5;
    list[currentList][idx+6] = v6;
    list[currentList][idx+7] = v7;
    list[currentList][idx+8] = v8;
    currentShape++;
}

vtkVolumeFromVolume::WedgeList::WedgeList()
    : vtkVolumeFromVolume::ShapeList(6)
{
}
 

vtkVolumeFromVolume::WedgeList::~WedgeList()
{
}
 
hrchilds's avatar
hrchilds committed
357 358 359 360 361 362
// ****************************************************************************
//  Modifications:
//
//    Hank Childs, Thu Oct 21 15:32:07 PDT 2004
//    Fix bug where we run out of memory.
//
hrchilds's avatar
hrchilds committed
363 364 365
//    Mark C. Miller, Sun Dec  3 12:20:11 PST 2006
//    Fixed off-by-one error in test to resize list
//
hrchilds's avatar
hrchilds committed
366 367 368 369
//    Sean Ahern, Mon Mar  5 15:44:05 EST 2007
//    Fixed test for resizing list.  You really do need the +1.
//    Initialized new entries.
//
hrchilds's avatar
hrchilds committed
370 371
// ****************************************************************************

hrchilds's avatar
hrchilds committed
372
void
373 374 375
vtkVolumeFromVolume::WedgeList::AddWedge(vtkIdType cellId,
    vtkIdType v1, vtkIdType v2, vtkIdType v3,
    vtkIdType v4, vtkIdType v5, vtkIdType v6)
hrchilds's avatar
hrchilds committed
376 377 378
{
    if (currentShape >= shapesPerList)
    {
hrchilds's avatar
hrchilds committed
379
        if ((currentList+1) >= listSize)
hrchilds's avatar
hrchilds committed
380
        {
381 382
            vtkIdType **tmpList = new vtkIdType*[2*listSize];
            for (vtkIdType i = 0 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
383
                tmpList[i] = list[i];
384
            for (vtkIdType i = listSize ; i < listSize*2 ; i++)
hrchilds's avatar
hrchilds committed
385
                tmpList[i] = NULL;
hrchilds's avatar
hrchilds committed
386 387 388 389 390 391
            listSize *= 2;
            delete [] list;
            list = tmpList;
        }
 
        currentList++;
392
        list[currentList] = new vtkIdType[(shapeSize+1)*shapesPerList];
hrchilds's avatar
hrchilds committed
393 394 395
        currentShape = 0;
    }
 
396
    vtkIdType idx = (shapeSize+1)*currentShape;
hrchilds's avatar
hrchilds committed
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
    list[currentList][idx+0] = cellId;
    list[currentList][idx+1] = v1;
    list[currentList][idx+2] = v2;
    list[currentList][idx+3] = v3;
    list[currentList][idx+4] = v4;
    list[currentList][idx+5] = v5;
    list[currentList][idx+6] = v6;
    currentShape++;
}

vtkVolumeFromVolume::PyramidList::PyramidList()
    : vtkVolumeFromVolume::ShapeList(5)
{
}
 

vtkVolumeFromVolume::PyramidList::~PyramidList()
{
}
 
hrchilds's avatar
hrchilds committed
417 418 419 420 421 422
// ****************************************************************************
//  Modifications:
//
//    Hank Childs, Thu Oct 21 15:32:07 PDT 2004
//    Fix bug where we run out of memory.
//
hrchilds's avatar
hrchilds committed
423 424 425
//    Mark C. Miller, Sun Dec  3 12:20:11 PST 2006
//    Fixed off-by-one error in test to resize list
//
hrchilds's avatar
hrchilds committed
426 427 428 429
//    Sean Ahern, Mon Mar  5 15:44:05 EST 2007
//    Fixed test for resizing list.  You really do need the +1.
//    Initialized new entries.
//
hrchilds's avatar
hrchilds committed
430 431
// ****************************************************************************

hrchilds's avatar
hrchilds committed
432
void
433 434
vtkVolumeFromVolume::PyramidList::AddPyramid(vtkIdType cellId,
    vtkIdType v1, vtkIdType v2, vtkIdType v3, vtkIdType v4, vtkIdType v5)
hrchilds's avatar
hrchilds committed
435 436 437
{
    if (currentShape >= shapesPerList)
    {
hrchilds's avatar
hrchilds committed
438
        if ((currentList+1) >= listSize)
hrchilds's avatar
hrchilds committed
439
        {
440 441
            vtkIdType **tmpList = new vtkIdType*[2*listSize];
            for (vtkIdType i = 0 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
442
                tmpList[i] = list[i];
443
            for (vtkIdType i = listSize ; i < listSize*2 ; i++)
hrchilds's avatar
hrchilds committed
444
                tmpList[i] = NULL;
hrchilds's avatar
hrchilds committed
445 446 447 448 449 450
            listSize *= 2;
            delete [] list;
            list = tmpList;
        }
 
        currentList++;
451
        list[currentList] = new vtkIdType[(shapeSize+1)*shapesPerList];
hrchilds's avatar
hrchilds committed
452 453 454
        currentShape = 0;
    }
 
455
    vtkIdType idx = (shapeSize+1)*currentShape;
hrchilds's avatar
hrchilds committed
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
    list[currentList][idx+0] = cellId;
    list[currentList][idx+1] = v1;
    list[currentList][idx+2] = v2;
    list[currentList][idx+3] = v3;
    list[currentList][idx+4] = v4;
    list[currentList][idx+5] = v5;
    currentShape++;
}

vtkVolumeFromVolume::TetList::TetList()
    : vtkVolumeFromVolume::ShapeList(4)
{
}
 

vtkVolumeFromVolume::TetList::~TetList()
{
}
 
hrchilds's avatar
hrchilds committed
475 476 477 478 479 480
// ****************************************************************************
//  Modifications:
//
//    Hank Childs, Thu Oct 21 15:32:07 PDT 2004
//    Fix bug where we run out of memory.
//
hrchilds's avatar
hrchilds committed
481 482 483
//    Mark C. Miller, Sun Dec  3 12:20:11 PST 2006
//    Fixed off-by-one error in test to resize list
//
hrchilds's avatar
hrchilds committed
484 485 486 487
//    Sean Ahern, Mon Mar  5 15:44:05 EST 2007
//    Fixed test for resizing list.  You really do need the +1.
//    Initialized new entries.
//
hrchilds's avatar
hrchilds committed
488 489
// ****************************************************************************

hrchilds's avatar
hrchilds committed
490
void
491 492
vtkVolumeFromVolume::TetList::AddTet(vtkIdType cellId,
    vtkIdType v1,vtkIdType v2,vtkIdType v3,vtkIdType v4)
hrchilds's avatar
hrchilds committed
493 494 495
{
    if (currentShape >= shapesPerList)
    {
hrchilds's avatar
hrchilds committed
496
        if ((currentList+1) >= listSize)
hrchilds's avatar
hrchilds committed
497
        {
498 499
            vtkIdType **tmpList = new vtkIdType*[2*listSize];
            for (vtkIdType i = 0 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
500
                tmpList[i] = list[i];
501
            for (vtkIdType i = listSize ; i < listSize*2 ; i++)
hrchilds's avatar
hrchilds committed
502
                tmpList[i] = NULL;
hrchilds's avatar
hrchilds committed
503 504 505 506 507 508
            listSize *= 2;
            delete [] list;
            list = tmpList;
        }
 
        currentList++;
509
        list[currentList] = new vtkIdType[(shapeSize+1)*shapesPerList];
hrchilds's avatar
hrchilds committed
510 511 512
        currentShape = 0;
    }
 
513
    vtkIdType idx = (shapeSize+1)*currentShape;
hrchilds's avatar
hrchilds committed
514 515 516 517 518 519 520 521
    list[currentList][idx+0] = cellId;
    list[currentList][idx+1] = v1;
    list[currentList][idx+2] = v2;
    list[currentList][idx+3] = v3;
    list[currentList][idx+4] = v4;
    currentShape++;
}

hrchilds's avatar
hrchilds committed
522 523 524 525 526 527 528 529 530 531
vtkVolumeFromVolume::QuadList::QuadList()
    : vtkVolumeFromVolume::ShapeList(4)
{
}
 

vtkVolumeFromVolume::QuadList::~QuadList()
{
}
 
hrchilds's avatar
hrchilds committed
532 533 534 535 536 537
// ****************************************************************************
//  Modifications:
//
//    Hank Childs, Thu Oct 21 15:32:07 PDT 2004
//    Fix bug where we run out of memory.
//
hrchilds's avatar
hrchilds committed
538 539 540
//    Mark C. Miller, Sun Dec  3 12:20:11 PST 2006
//    Fixed off-by-one error in test to resize list
//
hrchilds's avatar
hrchilds committed
541 542 543 544
//    Sean Ahern, Mon Mar  5 15:44:05 EST 2007
//    Fixed test for resizing list.  You really do need the +1.
//    Initialized new entries.
//
hrchilds's avatar
hrchilds committed
545 546
// ****************************************************************************

hrchilds's avatar
hrchilds committed
547
void
548 549
vtkVolumeFromVolume::QuadList::AddQuad(vtkIdType cellId,
    vtkIdType v1,vtkIdType v2,vtkIdType v3,vtkIdType v4)
hrchilds's avatar
hrchilds committed
550 551 552
{
    if (currentShape >= shapesPerList)
    {
hrchilds's avatar
hrchilds committed
553
        if ((currentList+1) >= listSize)
hrchilds's avatar
hrchilds committed
554
        {
555 556
            vtkIdType **tmpList = new vtkIdType*[2*listSize];
            for (vtkIdType i = 0 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
557
                tmpList[i] = list[i];
558
            for (vtkIdType i = listSize ; i < listSize*2 ; i++)
hrchilds's avatar
hrchilds committed
559
                tmpList[i] = NULL;
hrchilds's avatar
hrchilds committed
560 561 562 563 564 565
            listSize *= 2;
            delete [] list;
            list = tmpList;
        }
 
        currentList++;
566
        list[currentList] = new vtkIdType[(shapeSize+1)*shapesPerList];
hrchilds's avatar
hrchilds committed
567 568 569
        currentShape = 0;
    }
 
570
    vtkIdType idx = (shapeSize+1)*currentShape;
hrchilds's avatar
hrchilds committed
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588
    list[currentList][idx+0] = cellId;
    list[currentList][idx+1] = v1;
    list[currentList][idx+2] = v2;
    list[currentList][idx+3] = v3;
    list[currentList][idx+4] = v4;
    currentShape++;
}

vtkVolumeFromVolume::TriList::TriList()
    : vtkVolumeFromVolume::ShapeList(3)
{
}
 

vtkVolumeFromVolume::TriList::~TriList()
{
}
 
hrchilds's avatar
hrchilds committed
589 590 591 592 593 594
// ****************************************************************************
//  Modifications:
//
//    Hank Childs, Thu Oct 21 15:32:07 PDT 2004
//    Fix bug where we run out of memory.
//
hrchilds's avatar
hrchilds committed
595 596 597
//    Mark C. Miller, Sun Dec  3 12:20:11 PST 2006
//    Fixed off-by-one error in test to resize list
//
hrchilds's avatar
hrchilds committed
598 599 600 601
//    Sean Ahern, Mon Mar  5 15:44:05 EST 2007
//    Fixed test for resizing list.  You really do need the +1.
//    Initialized new entries.
//
hrchilds's avatar
hrchilds committed
602 603
// ****************************************************************************

hrchilds's avatar
hrchilds committed
604
void
605 606
vtkVolumeFromVolume::TriList::AddTri(vtkIdType cellId,
    vtkIdType v1,vtkIdType v2,vtkIdType v3)
hrchilds's avatar
hrchilds committed
607 608 609
{
    if (currentShape >= shapesPerList)
    {
hrchilds's avatar
hrchilds committed
610
        if ((currentList+1) >= listSize)
hrchilds's avatar
hrchilds committed
611
        {
612 613
            vtkIdType **tmpList = new vtkIdType*[2*listSize];
            for (vtkIdType i = 0 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
614
                tmpList[i] = list[i];
615
            for (vtkIdType i = listSize ; i < listSize*2 ; i++)
hrchilds's avatar
hrchilds committed
616
                tmpList[i] = NULL;
hrchilds's avatar
hrchilds committed
617 618 619 620 621 622
            listSize *= 2;
            delete [] list;
            list = tmpList;
        }
 
        currentList++;
623
        list[currentList] = new vtkIdType[(shapeSize+1)*shapesPerList];
hrchilds's avatar
hrchilds committed
624 625 626
        currentShape = 0;
    }
 
627
    vtkIdType idx = (shapeSize+1)*currentShape;
hrchilds's avatar
hrchilds committed
628 629 630 631 632 633
    list[currentList][idx+0] = cellId;
    list[currentList][idx+1] = v1;
    list[currentList][idx+2] = v2;
    list[currentList][idx+3] = v3;
    currentShape++;
}
hrchilds's avatar
hrchilds committed
634 635


hrchilds's avatar
hrchilds committed
636 637 638 639 640 641 642 643 644 645
vtkVolumeFromVolume::LineList::LineList()
    : vtkVolumeFromVolume::ShapeList(2)
{
}
 

vtkVolumeFromVolume::LineList::~LineList()
{
}
 
hrchilds's avatar
hrchilds committed
646 647 648 649
//
//    Mark C. Miller, Sun Dec  3 12:20:11 PST 2006
//    Fixed off-by-one error in test to resize list
//
hrchilds's avatar
hrchilds committed
650 651 652 653
//    Sean Ahern, Mon Mar  5 15:44:05 EST 2007
//    Fixed test for resizing list.  You really do need the +1.
//    Initialized new entries.
//
hrchilds's avatar
hrchilds committed
654
void
655 656
vtkVolumeFromVolume::LineList::AddLine(vtkIdType cellId,
    vtkIdType v1,vtkIdType v2)
hrchilds's avatar
hrchilds committed
657 658 659
{
    if (currentShape >= shapesPerList)
    {
hrchilds's avatar
hrchilds committed
660
        if ((currentList+1) >= listSize)
hrchilds's avatar
hrchilds committed
661
        {
662 663
            vtkIdType **tmpList = new vtkIdType*[2*listSize];
            for (vtkIdType i = 0 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
664
                tmpList[i] = list[i];
665
            for (vtkIdType i = listSize ; i < listSize*2 ; i++)
hrchilds's avatar
hrchilds committed
666
                tmpList[i] = NULL;
hrchilds's avatar
hrchilds committed
667 668 669 670 671 672
            listSize *= 2;
            delete [] list;
            list = tmpList;
        }
 
        currentList++;
673
        list[currentList] = new vtkIdType[(shapeSize+1)*shapesPerList];
hrchilds's avatar
hrchilds committed
674 675 676
        currentShape = 0;
    }
 
677
    vtkIdType idx = (shapeSize+1)*currentShape;
hrchilds's avatar
hrchilds committed
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694
    list[currentList][idx+0] = cellId;
    list[currentList][idx+1] = v1;
    list[currentList][idx+2] = v2;
    currentShape++;
}


vtkVolumeFromVolume::VertexList::VertexList()
    : vtkVolumeFromVolume::ShapeList(1)
{
}
 

vtkVolumeFromVolume::VertexList::~VertexList()
{
}
 
hrchilds's avatar
hrchilds committed
695 696 697 698
//
//    Mark C. Miller, Sun Dec  3 12:20:11 PST 2006
//    Fixed off-by-one error in test to resize list
//
hrchilds's avatar
hrchilds committed
699 700 701 702
//    Sean Ahern, Mon Mar  5 15:44:05 EST 2007
//    Fixed test for resizing list.  You really do need the +1.
//    Initialized new entries.
//
hrchilds's avatar
hrchilds committed
703
void
704
vtkVolumeFromVolume::VertexList::AddVertex(vtkIdType cellId, vtkIdType v1)
hrchilds's avatar
hrchilds committed
705 706 707
{
    if (currentShape >= shapesPerList)
    {
hrchilds's avatar
hrchilds committed
708
        if ((currentList+1) >= listSize)
hrchilds's avatar
hrchilds committed
709
        {
710 711
            vtkIdType **tmpList = new vtkIdType*[2*listSize];
            for (vtkIdType i = 0 ; i < listSize ; i++)
hrchilds's avatar
hrchilds committed
712
                tmpList[i] = list[i];
713
            for (vtkIdType i = listSize ; i < listSize*2 ; i++)
hrchilds's avatar
hrchilds committed
714
                tmpList[i] = NULL;
hrchilds's avatar
hrchilds committed
715 716 717 718 719 720
            listSize *= 2;
            delete [] list;
            list = tmpList;
        }
 
        currentList++;
721
        list[currentList] = new vtkIdType[(shapeSize+1)*shapesPerList];
hrchilds's avatar
hrchilds committed
722 723 724
        currentShape = 0;
    }
 
725
    vtkIdType idx = (shapeSize+1)*currentShape;
hrchilds's avatar
hrchilds committed
726 727 728 729 730
    list[currentList][idx+0] = cellId;
    list[currentList][idx+1] = v1;
    currentShape++;
}

hrchilds's avatar
hrchilds committed
731
// ****************************************************************************
732
//  Method: ConstructDataSetHelper
hrchilds's avatar
hrchilds committed
733 734 735 736 737 738 739 740 741 742 743
//
//  Purpose:
//      Constructs the output dataset.
//
//  Notes:  The code for this function use to be located in the two functions
//          written by Jeremy Meredith.  I unified them here and made some
//          additional enhancements.
//
//  Programmer: Hank Childs
//  Creation:   October 21, 2004
//
hrchilds's avatar
hrchilds committed
744
//  Modifications:
hrchilds's avatar
hrchilds committed
745 746 747 748
//
//    Hank Childs, Thu Oct 21 07:23:55 PDT 2004
//    Only create points in the output that will actually be referenced.  Also
//    generalized the shape list to reduce code.
hrchilds's avatar
hrchilds committed
749
//
hrchilds's avatar
hrchilds committed
750 751 752
//    Kathleen Bonnell, Mon May  1 08:50:46 PDT 2006 
//    Don't interpolate avtOriginalNodeNumbers, use value from closest node
//    instead. 
hrchilds's avatar
hrchilds committed
753 754 755 756 757 758 759 760 761 762 763 764 765
//
//    Mark C. Miller, Tue Nov  7 20:35:07 PST 2006
//    Through emperical analysis running the code and printing values, I
//    discovered that for centroid points, the point indices that were
//    getting assigned were too large by 1. Apparently, centroid points
//    are initially identified using negative point ids (see AddCentroidPoint)
//    starting from -1. This -1 offset was not being taken into account when
//    doing the index arithmetic for the cases involving centroid points.
//    There were two lines of code that were modified tagged with '-1 offset'
//    in-line comments. This corrected a slew of cases I discovered. However,
//    even after making this change, I have encountered some cases where I
//    still see the too large by 1 problem but with very low probablility of
//    occurance.
hrchilds's avatar
hrchilds committed
766
//    
hrchilds's avatar
hrchilds committed
767 768
//    Mark C. Miller, Tue Dec  5 18:14:58 PST 2006
//    Undid above change 
769 770 771 772
//
//    Brad Whitlock, Thu Mar 22 14:11:31 PDT 2012
//    I turned the method into a template helper function.
//
hrchilds's avatar
hrchilds committed
773
// ****************************************************************************
hrchilds's avatar
hrchilds committed
774

775
template <typename PointGetter>
hrchilds's avatar
hrchilds committed
776
void
777 778 779 780 781 782
ConstructDataSetHelper(vtkPointData *inPD, vtkCellData *inCD, vtkUnstructuredGrid *output,
    int dataType, vtkIdType numPrevPts, 
    vtkVolumeFromVolume::ShapeList *shapes[8], int nshapes,
    vtkVolumeFromVolume::PointList &pt_list,
    vtkVolumeFromVolume::CentroidPointList &centroid_list,
    const PointGetter &pointGetter)
hrchilds's avatar
hrchilds committed
783 784 785 786
{
    vtkPointData *outPD = output->GetPointData();
    vtkCellData  *outCD = output->GetCellData();

hrchilds's avatar
hrchilds committed
787 788 789
    vtkIntArray *newOrigNodes = NULL;
    vtkIntArray *origNodes = vtkIntArray::SafeDownCast(
              inPD->GetArray("avtOriginalNodeNumbers"));
hrchilds's avatar
hrchilds committed
790 791 792 793 794 795
    //
    // If the isovolume only affects a small part of the dataset, we can save
    // on memory by only bringing over the points from the original dataset
    // that are used with the output.  Determine which points those are here.
    //
    int *ptLookup = new int[numPrevPts];
796
    for (vtkIdType i = 0 ; i < numPrevPts ; i++)
hrchilds's avatar
hrchilds committed
797 798
        ptLookup[i] = -1;
    int numUsed = 0;
799
    for (int i = 0 ; i < nshapes ; i++)
hrchilds's avatar
hrchilds committed
800
    {
801
        vtkIdType nlists = shapes[i]->GetNumberOfLists();
hrchilds's avatar
hrchilds committed
802
        int npts_per_shape = shapes[i]->GetShapeSize();
803
        for (vtkIdType j = 0 ; j < nlists ; j++)
hrchilds's avatar
hrchilds committed
804
        {
805 806 807
            const vtkIdType *list;
            vtkIdType listSize = shapes[i]->GetList(j, list);
            for (vtkIdType k = 0 ; k < listSize ; k++)
hrchilds's avatar
hrchilds committed
808 809
            {
                list++; // skip the cell id entry
810
                for (vtkIdType l = 0 ; l < npts_per_shape ; l++)
hrchilds's avatar
hrchilds committed
811 812 813 814 815 816 817 818 819 820 821
                {
                    int pt = *list;
                    list++;
                    if (pt >= 0 && pt < numPrevPts)
                        if (ptLookup[pt] == -1)
                            ptLookup[pt] = numUsed++;
                }
            }
        }
    }

hrchilds's avatar
hrchilds committed
822 823 824
    //
    // Set up the output points and its point data.
    //
825 826 827
    vtkPoints *outPts = vtkPoints::New(dataType);
    vtkIdType centroidStart = numUsed + pt_list.GetTotalNumberOfPoints();
    vtkIdType nOutPts = centroidStart + centroid_list.GetTotalNumberOfPoints();
hrchilds's avatar
hrchilds committed
828 829
    outPts->SetNumberOfPoints(nOutPts);
    outPD->CopyAllocate(inPD, nOutPts);
hrchilds's avatar
hrchilds committed
830 831 832 833 834 835 836
    if (origNodes != NULL)
    {
        newOrigNodes = vtkIntArray::New();
        newOrigNodes->SetNumberOfComponents(origNodes->GetNumberOfComponents());
        newOrigNodes->SetNumberOfTuples(nOutPts);
        newOrigNodes->SetName(origNodes->GetName());
    }
hrchilds's avatar
hrchilds committed
837

hrchilds's avatar
hrchilds committed
838 839 840 841
    //
    // Copy over all the points from the input that are actually used in the
    // output.
    //
842
    for (vtkIdType i = 0 ; i < numPrevPts ; i++)
hrchilds's avatar
hrchilds committed
843
    {
hrchilds's avatar
hrchilds committed
844 845 846
        if (ptLookup[i] == -1)
            continue;

847 848 849
        double pt[3];
        pointGetter.GetPoint(i, pt);
        outPts->SetPoint(ptLookup[i], pt);
hrchilds's avatar
hrchilds committed
850 851

        outPD->CopyData(inPD, i, ptLookup[i]);
hrchilds's avatar
hrchilds committed
852 853
        if (newOrigNodes)
            newOrigNodes->SetTuple(ptLookup[i], origNodes->GetTuple(i));
hrchilds's avatar
hrchilds committed
854
    }
855
    vtkIdType ptIdx = numUsed;
hrchilds's avatar
hrchilds committed
856

hrchilds's avatar
hrchilds committed
857 858 859 860
    //
    // Now construct all the points that are along edges and new and add 
    // them to the points list.
    //
861 862
    vtkIdType nLists = pt_list.GetNumberOfLists();
    for (vtkIdType i = 0 ; i < nLists ; i++)
hrchilds's avatar
hrchilds committed
863
    {
864 865 866
        const vtkVolumeFromVolume::PointEntry *pe_list = NULL;
        vtkIdType nPts = pt_list.GetList(i, pe_list);
        for (vtkIdType j = 0 ; j < nPts ; j++)
hrchilds's avatar
hrchilds committed
867
        {
868 869 870 871 872
            const vtkVolumeFromVolume::PointEntry &pe = pe_list[j];
            double pt[3], pt1[3], pt2[3];

            pointGetter.GetPoint(pe.ptIds[0], pt1);
            pointGetter.GetPoint(pe.ptIds[1], pt2);
hrchilds's avatar
hrchilds committed
873 874

            // Now that we have the original points, calculate the new one.
875 876
            double p  = pe.percent;
            double bp = 1. - p;
hrchilds's avatar
hrchilds committed
877 878 879 880 881
            pt[0] = pt1[0]*p + pt2[0]*bp;
            pt[1] = pt1[1]*p + pt2[1]*bp;
            pt[2] = pt1[2]*p + pt2[2]*bp;
            outPts->SetPoint(ptIdx, pt);
            outPD->InterpolateEdge(inPD, ptIdx, pe.ptIds[0], pe.ptIds[1], bp);
hrchilds's avatar
hrchilds committed
882 883
            if (newOrigNodes)
            {
884
                vtkIdType id = (bp <= 0.5 ? pe.ptIds[0] : pe.ptIds[1]);
hrchilds's avatar
hrchilds committed
885 886
                newOrigNodes->SetTuple(ptIdx, origNodes->GetTuple(id));
            }
hrchilds's avatar
hrchilds committed
887 888 889 890
            ptIdx++;
        }
    }

hrchilds's avatar
hrchilds committed
891 892 893
    // 
    // Now construct the new "centroid" points and add them to the points list.
    //
hrchilds's avatar
hrchilds committed
894
    nLists = centroid_list.GetNumberOfLists();
hrchilds's avatar
hrchilds committed
895
    vtkIdList *idList = vtkIdList::New();
896
    for (vtkIdType i = 0 ; i < nLists ; i++)
hrchilds's avatar
hrchilds committed
897
    {
898 899 900
        const vtkVolumeFromVolume::CentroidPointEntry *ce_list = NULL;
        vtkIdType nPts = centroid_list.GetList(i, ce_list);
        for (vtkIdType j = 0 ; j < nPts ; j++)
hrchilds's avatar
hrchilds committed
901
        {
902
            const vtkVolumeFromVolume::CentroidPointEntry &ce = ce_list[j];
hrchilds's avatar
hrchilds committed
903
            idList->SetNumberOfIds(ce.nPts);
hrchilds's avatar
hrchilds committed
904 905
            double pts[8][3];
            double weights[8];
906 907
            double pt[3] = {0., 0., 0.};
            double weight_factor = 1. / ce.nPts;
hrchilds's avatar
hrchilds committed
908 909
            for (int k = 0 ; k < ce.nPts ; k++)
            {
hrchilds's avatar
hrchilds committed
910
                weights[k] = 1.0 * weight_factor;
911
                vtkIdType id = 0;
hrchilds's avatar
hrchilds committed
912
                if (ce.ptIds[k] < 0)
hrchilds's avatar
hrchilds committed
913
                    id = centroidStart-1 - ce.ptIds[k];
hrchilds's avatar
hrchilds committed
914 915 916 917 918
                else if (ce.ptIds[k] >= numPrevPts)
                    id = numUsed + (ce.ptIds[k] - numPrevPts);
                else
                    id = ptLookup[ce.ptIds[k]];
                idList->SetId(k, id);
hrchilds's avatar
hrchilds committed
919 920 921 922 923
                outPts->GetPoint(id, pts[k]);
                pt[0] += pts[k][0];
                pt[1] += pts[k][1];
                pt[2] += pts[k][2];
            }
hrchilds's avatar
hrchilds committed
924 925 926
            pt[0] *= weight_factor;
            pt[1] *= weight_factor;
            pt[2] *= weight_factor;
hrchilds's avatar
hrchilds committed
927 928 929

            outPts->SetPoint(ptIdx, pt);
            outPD->InterpolatePoint(outPD, ptIdx, idList, weights);
hrchilds's avatar
hrchilds committed
930 931 932 933 934 935
            if (newOrigNodes)
            {
                // these 'created' nodes have no original designation
                for (int z = 0; z < newOrigNodes->GetNumberOfComponents(); z++)
                    newOrigNodes->SetComponent(ptIdx, z, -1);
            }
hrchilds's avatar
hrchilds committed
936 937 938
            ptIdx++;
        }
    }
hrchilds's avatar
hrchilds committed
939
    idList->Delete();
hrchilds's avatar
hrchilds committed
940

hrchilds's avatar
hrchilds committed
941 942 943 944
    //
    // We are finally done constructing the points list.  Set it with our
    // output and clean up memory.
    //
hrchilds's avatar
hrchilds committed
945 946 947
    output->SetPoints(outPts);
    outPts->Delete();

hrchilds's avatar
hrchilds committed
948 949 950 951 952 953 954 955
    if (newOrigNodes)
    {
        // AddArray will overwrite an already existing array with 
        // the same name, exactly what we want here.
        outPD->AddArray(newOrigNodes);
        newOrigNodes->Delete();
    }

hrchilds's avatar
hrchilds committed
956 957 958
    //
    // Now set up the shapes and the cell data.
    //
959 960
    vtkIdType cellId = 0;
    vtkIdType nlists;
hrchilds's avatar
hrchilds committed
961

962 963 964
    vtkIdType ncells = 0;
    vtkIdType conn_size = 0;
    for (int i = 0 ; i < nshapes ; i++)
hrchilds's avatar
hrchilds committed
965
    {
966
        vtkIdType ns = shapes[i]->GetTotalNumberOfShapes();
hrchilds's avatar
hrchilds committed
967 968
        ncells += ns;
        conn_size += (shapes[i]->GetShapeSize()+1)*ns;
hrchilds's avatar
hrchilds committed
969 970
    }

hrchilds's avatar
hrchilds committed
971
    outCD->CopyAllocate(inCD, ncells);
hrchilds's avatar
hrchilds committed
972

hrchilds's avatar
hrchilds committed
973 974 975
    vtkIdTypeArray *nlist = vtkIdTypeArray::New();
    nlist->SetNumberOfValues(conn_size);
    vtkIdType *nl = nlist->GetPointer(0);
hrchilds's avatar
hrchilds committed
976

hrchilds's avatar
hrchilds committed
977 978 979
    vtkUnsignedCharArray *cellTypes = vtkUnsignedCharArray::New();
    cellTypes->SetNumberOfValues(ncells);
    unsigned char *ct = cellTypes->GetPointer(0);
hrchilds's avatar
hrchilds committed
980

hrchilds's avatar
hrchilds committed
981
    vtkIdTypeArray *cellLocations = vtkIdTypeArray::New();
hrchilds's avatar
hrchilds committed
982
    cellLocations->SetNumberOfValues(ncells);
983
    vtkIdType *cl = cellLocations->GetPointer(0);
hrchilds's avatar
hrchilds committed
984

hrchilds's avatar
hrchilds committed
985
    vtkIdType ids[1024]; // 8 (for hex) should be max, but...
986 987
    vtkIdType current_index = 0;
    for (int i = 0 ; i < nshapes ; i++)
hrchilds's avatar
hrchilds committed
988
    {
989
        const vtkIdType *list;
hrchilds's avatar
hrchilds committed
990 991 992
        nlists = shapes[i]->GetNumberOfLists();
        int shapesize = shapes[i]->GetShapeSize();
        int vtk_type = shapes[i]->GetVTKType();
993
        for (vtkIdType j = 0 ; j < nlists ; j++)
hrchilds's avatar
hrchilds committed
994
        {
hrchilds's avatar
hrchilds committed
995
            int listSize = shapes[i]->GetList(j, list);
996
            for (vtkIdType k = 0 ; k < listSize ; k++)
hrchilds's avatar
hrchilds committed
997 998
            {
                outCD->CopyData(inCD, list[0], cellId);
999
                for (int l = 0 ; l < shapesize ; l++)
hrchilds's avatar
hrchilds committed
1000 1001
                {
                    if (list[l+1] < 0)
hrchilds's avatar
hrchilds committed
1002
                        ids[l] = centroidStart-1 - list[l+1];
hrchilds's avatar
hrchilds committed
1003 1004 1005 1006 1007 1008 1009 1010 1011
                    else if (list[l+1] >= numPrevPts)
                        ids[l] = numUsed + (list[l+1] - numPrevPts);
                    else
                        ids[l] = ptLookup[list[l+1]];
                }
                list += shapesize+1;
                *nl++ = shapesize;
                *cl++ = current_index;
                *ct++ = vtk_type;
1012
                for (int l = 0 ; l < shapesize ; l++)
hrchilds's avatar
hrchilds committed
1013 1014 1015 1016 1017
                    *nl++ = ids[l];
                current_index += shapesize+1;
                //output->InsertNextCell(vtk_type, shapesize, ids);
                cellId++;
            }
hrchilds's avatar
hrchilds committed
1018 1019
        }
    }
hrchilds's avatar
hrchilds committed
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032

    vtkCellArray *cells = vtkCellArray::New();
    cells->SetCells(ncells, nlist);
    nlist->Delete();

    output->SetCells(cellTypes, cellLocations, cells);
    cellTypes->Delete();
    cellLocations->Delete();
    cells->Delete();

    delete [] ptLookup;
}

1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
// ****************************************************************************
//  Modifications:
//    Jeremy Meredith, Mon Feb 16 19:11:34 PST 2004
//    Added polygonal cell support.
//
//    Hank Childs, Thu Oct 21 07:52:31 PDT 2004
//    Instead of duplicating code, just call a common function.
//    (Moved whole routine to new ConstructDataSet method with 
//     CommonPointsStructure in signature).
//
//    Brad Whitlock, Thu Mar 22 12:36:10 PDT 2012
//    Call ConstructDataSetHelper.
//
// ****************************************************************************
void
vtkVolumeFromVolume::ConstructDataSet(vtkPointData *inPD, vtkCellData *inCD,
                                      vtkUnstructuredGrid *output,
                                      vtkPoints *pts)
hrchilds's avatar
hrchilds committed
1051
{
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066
    if(pts->GetDataType() == VTK_FLOAT)
        ConstructDataSetHelper(inPD, inCD, output, VTK_FLOAT, this->numPrevPts,
                               this->shapes, this->nshapes, 
                               this->pt_list, this->centroid_list,
                               vtkPointAccessor<float>(pts));
    else if(pts->GetDataType() == VTK_DOUBLE)
        ConstructDataSetHelper(inPD, inCD, output, VTK_DOUBLE, this->numPrevPts,
                               this->shapes, this->nshapes, 
                               this->pt_list, this->centroid_list, 
                               vtkPointAccessor<double>(pts));
    else
        ConstructDataSetHelper(inPD, inCD, output, VTK_FLOAT, this->numPrevPts,
                               this->shapes, this->nshapes,
                               this->pt_list, this->centroid_list, 
                               vtkGeneralPointAccessor(pts));
hrchilds's avatar
hrchilds committed
1067
}
hrchilds's avatar
hrchilds committed
1068 1069


1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
// ****************************************************************************
//  Modifications:
//    Jeremy Meredith, Mon Feb 16 19:11:34 PST 2004
//    Added polygonal cell support.
//
//    Hank Childs, Thu Oct 21 07:52:31 PDT 2004
//    Instead of duplicating code, just call a common function.
//    (Moved whole routine to new ConstructDataSet method with 
//     CommonPointsStructure in signature).
//
//    Brad Whitlock, Thu Mar 22 12:36:10 PDT 2012
//    Call ConstructDataSetHelper.
//
// ****************************************************************************
void
vtkVolumeFromVolume::ConstructDataSet(vtkPointData *inPD, vtkCellData *inCD,
                                      vtkUnstructuredGrid *output,
                                      const int *dims, vtkDataArray *X, vtkDataArray *Y, vtkDataArray *Z)
{
    int tx = X->GetDataType();
    int ty = Y->GetDataType();
    int tz = Z->GetDataType();
    bool same = tx == ty && ty == tz;
    if(same && tx == VTK_FLOAT)
        ConstructDataSetHelper(inPD, inCD, output, VTK_FLOAT, this->numPrevPts,
                               this->shapes, this->nshapes, 
                               this->pt_list, this->centroid_list, 
                               vtkRectPointAccessor<float>(dims, X, Y, Z));
    else if(same && tx == VTK_DOUBLE)
        ConstructDataSetHelper(inPD, inCD, output, VTK_DOUBLE, this->numPrevPts, 
                               this->shapes, this->nshapes, 
                               this->pt_list, this->centroid_list, 
                               vtkRectPointAccessor<double>(dims, X, Y, Z));
    else
        ConstructDataSetHelper(inPD, inCD, output, VTK_FLOAT, this->numPrevPts,
                               this->shapes, this->nshapes, 
                               this->pt_list, this->centroid_list, 
                               vtkGeneralRectPointAccessor(dims, X, Y, Z));
}