1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkVolumeOutlineSource.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkVolumeOutlineSource.h"
#include "vtkDataSet.h"
#include "vtkDemandDrivenPipeline.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkImageData.h"
#include "vtkPolyData.h"
#include "vtkPoints.h"
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkUnsignedCharArray.h"
#include "vtkVolumeMapper.h"
#include "vtkMath.h"
vtkStandardNewMacro(vtkVolumeOutlineSource);
vtkCxxSetObjectMacro(vtkVolumeOutlineSource,VolumeMapper,vtkVolumeMapper);
//----------------------------------------------------------------------------
vtkVolumeOutlineSource::vtkVolumeOutlineSource ()
{
this->VolumeMapper = 0;
this->GenerateScalars = 0;
this->GenerateOutline = 1;
this->GenerateFaces = 0;
this->ActivePlaneId = -1;
this->Color[0] = 1.0;
this->Color[1] = 0.0;
this->Color[2] = 0.0;
this->ActivePlaneColor[0] = 1.0;
this->ActivePlaneColor[1] = 1.0;
this->ActivePlaneColor[2] = 0.0;
this->SetNumberOfInputPorts(0);
}
//----------------------------------------------------------------------------
vtkVolumeOutlineSource::~vtkVolumeOutlineSource ()
{
if (this->VolumeMapper)
{
this->VolumeMapper->Delete();
this->VolumeMapper = 0;
}
}
//----------------------------------------------------------------------------
void vtkVolumeOutlineSource::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "VolumeMapper: ";
if (this->VolumeMapper)
{
os << this->VolumeMapper << "\n";
}
else
{
os << "(none)\n";
}
os << indent << "GenerateFaces: "
<< (this->GenerateFaces ? "On\n" : "Off\n" );
os << indent << "GenerateOutline: "
<< (this->GenerateOutline ? "On\n" : "Off\n" );
os << indent << "GenerateScalars: "
<< (this->GenerateScalars ? "On\n" : "Off\n" );
os << indent << "Color: " << this->Color[0] << ", "
<< this->Color[1] << ", " << this->Color[2] << "\n";
os << indent << "ActivePlaneId: " << this->ActivePlaneId << "\n";
os << indent << "ActivePlaneColor: " << this->ActivePlaneColor[0] << ", "
<< this->ActivePlaneColor[1] << ", " << this->ActivePlaneColor[2] << "\n";
}
//----------------------------------------------------------------------------
int vtkVolumeOutlineSource::ComputeCubePlanes(
double planes[3][4], double croppingPlanes[6], double bounds[6])
{
// Combine the CroppingRegionPlanes and the Bounds to create
// a single array. For each dimension, store the planes in
// the following order: lo_bound, lo_crop_plane, hi_crop_plane, hi_bound.
// Also do range checking to ensure that the cropping planes
// are clamped to the bound limits.
for (int i = 0; i < 3; i++)
{
int j0 = 2*i;
int j1 = 2*i + 1;
double a = bounds[j0];
double b = croppingPlanes[j0];
double c = croppingPlanes[j1];
double d = bounds[j1];
// Sanity check
if (a > d || b > c)
{
return 0;
}
// Clamp cropping planes to bounds
if (b < a) { b = a; };
if (b > d) { b = d; };
if (c < a) { c = a; };
if (c > d) { c = d; };
planes[i][0] = a;
planes[i][1] = b;
planes[i][2] = c;
planes[i][3] = d;
}
return 1;
}
//----------------------------------------------------------------------------
int vtkVolumeOutlineSource::ComputePipelineMTime(
vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* vtkNotUsed(outputVector),
int vtkNotUsed(requestFromOutputPort),
unsigned long* mtime)
{
unsigned long mTime = this->GetMTime();
if (this->VolumeMapper)
{
unsigned long mapperMTime = this->VolumeMapper->GetMTime();
if (mapperMTime > mTime)
{
mTime = mapperMTime;
}
vtkDemandDrivenPipeline *input =
vtkDemandDrivenPipeline::SafeDownCast(
this->VolumeMapper->GetInputExecutive());
if (input)
{
// Need to do this because we are not formally connected
// to the Mapper's pipeline
input->UpdateInformation();
unsigned long pipelineMTime = input->GetPipelineMTime();
if (pipelineMTime > mTime)
{
mTime = pipelineMTime;
}
}
}
*mtime = mTime;
return 1;
}
//----------------------------------------------------------------------------
int vtkVolumeOutlineSource::RequestInformation(
vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* vtkNotUsed(outputVector))
{
// Get the mapper's input, since this is the most convenient
// place to do so.
if (!this->VolumeMapper)
{
vtkWarningMacro("No VolumeMapper has been set.");
return 1;
}
vtkInformation *mapInfo = this->VolumeMapper->GetInputInformation();
if (!mapInfo)
{
vtkWarningMacro("The VolumeMapper does not have an input set.");
return 1;
}
// Don't have to update mapper's input, since it was done in
// ComputePipelineMTime.
// data->UpdateInformation();
// Don't call GetBounds because we need WholeExtent, while
// GetBounds only returns the bounds for Extent.
double spacing[3];
double origin[3];
int extent[6];
mapInfo->Get(vtkDataObject::SPACING(), spacing);
mapInfo->Get(vtkDataObject::ORIGIN(), origin);
mapInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
extent);
for (int i = 0; i < 3; i++)
{
int j0 = 2*i;
int j1 = j0+1;
if (extent[j0] > extent[j1])
{
vtkMath::UninitializeBounds(this->Bounds);
break;
}
if (spacing[i] > 0)
{
this->Bounds[j0] = origin[i] + spacing[i]*extent[j0];
this->Bounds[j1] = origin[i] + spacing[i]*extent[j1];
}
else
{
this->Bounds[j0] = origin[i] + spacing[i]*extent[j1];
this->Bounds[j1] = origin[i] + spacing[i]*extent[j0];
}
this->CroppingRegionPlanes[j0] = this->Bounds[j0];
this->CroppingRegionPlanes[j1] = this->Bounds[j1];
}
this->CroppingRegionFlags = 0x0002000;
this->Cropping = this->VolumeMapper->GetCropping();
if (this->Cropping)
{
this->CroppingRegionFlags = this->VolumeMapper->GetCroppingRegionFlags();
this->VolumeMapper->GetCroppingRegionPlanes(this->CroppingRegionPlanes);
}
return 1;
}
//----------------------------------------------------------------------------
int vtkVolumeOutlineSource::RequestData(
vtkInformation *vtkNotUsed(request),
vtkInformationVector **vtkNotUsed(inputVector),
vtkInformationVector *outputVector)
{
// get the info object
vtkInformation *outInfo = outputVector->GetInformationObject(0);
// get the output
vtkPolyData *output = vtkPolyData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkDebugMacro(<< "Creating cropping region outline");
// For each of the 3 dimensions, there are 4 planes: two bounding planes
// on the outside, and two cropping region planes inside.
double planes[3][4];
if (!this->VolumeMapper || !this->VolumeMapper->GetInput() ||
!this->ComputeCubePlanes(planes,this->CroppingRegionPlanes,this->Bounds))
{
// If the bounds or the cropping planes are invalid, clear the data
output->SetPoints(0);
output->SetLines(0);
output->GetCellData()->SetScalars(0);
return 1;
}
// Compute the tolerance for considering points or planes to be coincident
double tol = 0;
for (int planeDim = 0; planeDim < 3; planeDim++)
{
double d = planes[planeDim][3] - planes[planeDim][0];
tol += d*d;
}
tol = sqrt(tol)*1e-5;
// Create an array to nudge crop planes over to the bounds if they are
// within tolerance of the bounds
int tolPtId[3][4];
this->NudgeCropPlanesToBounds(tolPtId, planes, tol);
// The all-important cropping flags
int flags = this->CroppingRegionFlags;
// The active plane, which gets a special color for its scalars
int activePlane = this->ActivePlaneId;
if (activePlane > 5) { activePlane = -1; };
// Convert the colors to unsigned char for scalars
unsigned char colors[2][3];
this->CreateColorValues(colors, this->Color, this->ActivePlaneColor);
// Create the scalars used to color the lines
vtkUnsignedCharArray *scalars = 0;
if (this->GenerateScalars)
{
scalars = vtkUnsignedCharArray::New();
scalars->SetNumberOfComponents(3);
}
// Generate all the lines for the outline.
vtkCellArray *lines = 0;
if (this->GenerateOutline)
{
lines = vtkCellArray::New();
this->GenerateLines(lines, scalars, colors, activePlane, flags, tolPtId);
}
// Generate the polys for the outline
vtkCellArray *polys = 0;
if (this->GenerateFaces)
{
polys = vtkCellArray::New();
this->GeneratePolys(polys, scalars, colors, activePlane, flags, tolPtId);
}
// Generate the points that are used by the lines.
vtkPoints *points = vtkPoints::New();
this->GeneratePoints(points, lines, polys, planes, tol);
output->SetPoints(points);
points->Delete();
output->SetPolys(polys);
if (polys)
{
polys->Delete();
}
output->SetLines(lines);
if (lines)
{
lines->Delete();
}
output->GetCellData()->SetScalars(scalars);
if (scalars)
{
scalars->Delete();
}
return 1;
}
//----------------------------------------------------------------------------
void vtkVolumeOutlineSource::GeneratePolys(
vtkCellArray *polys,
vtkUnsignedCharArray *scalars,
unsigned char colors[2][3],
int activePlane,
int flags,
int tolPtId[3][4])
{
// Loop over the three dimensions and create the face rectangles
for (int dim0 = 0; dim0 < 3; dim0++)
{
// Compute the other two dimension indices
int dim1 = (dim0+1)%3;
int dim2 = (dim0+2)%3;
// Indices into the cubes
int idx[3];
// Loop over the "dim+2" dimension
for (int i = 0; i < 4; i++)
{
idx[dim2] = i;
// Loop over the "dim+1" dimension
for (int j = 0; j < 3; j++)
{
idx[dim1] = j;
// Make sure that the rect dim is not less than tolerance
if ((j == 0 && tolPtId[dim1][1] == 0) ||
(j == 2 && tolPtId[dim1][2] == 3))
{
continue;
}
// Loop over rectangle along the "dim" dimension
for (int k = 0; k < 3; k++)
{
idx[dim0] = k;
// Make sure that the rect dim is not less than tolerance
if ((k == 0 && tolPtId[dim0][1] == 0) ||
(k == 2 && tolPtId[dim0][2] == 3))
{
continue;
}
// The points in the rectangle, which are nudged over to the
// volume bounds if the cropping planes are within tolerance
// of the volume bounds.
int pointId[4];
pointId[0] = (tolPtId[2][idx[2]]*16 +
tolPtId[1][idx[1]]*4 +
tolPtId[0][idx[0]]);
idx[dim0] = k + 1;
pointId[1] = (tolPtId[2][idx[2]]*16 +
tolPtId[1][idx[1]]*4 +
tolPtId[0][idx[0]]);
idx[dim1] = j + 1;
pointId[2] = (tolPtId[2][idx[2]]*16 +
tolPtId[1][idx[1]]*4 +
tolPtId[0][idx[0]]);
idx[dim0] = k;
pointId[3] = (tolPtId[2][idx[2]]*16 +
tolPtId[1][idx[1]]*4 +
tolPtId[0][idx[0]]);
idx[dim1] = j;
// Loop through the two cubes adjacent to the rectangle,
// in order to determine whether the rectangle is internal:
// only external faces will be drawn. The "bitCheck"
// holds a bit for each of these two cubes.
int bitCheck = 0;
int cidx[3];
cidx[dim0] = idx[dim0];
cidx[dim1] = idx[dim1];
for (int ii = 0; ii < 2; ii++)
{
// First get idx[dim2]-1, then idx[dim2]
cidx[dim2] = idx[dim2] + ii - 1;
int flagval = 0;
if (cidx[dim2] >= 0 && cidx[dim2] < 3)
{
int flagbit = cidx[2]*9 + cidx[1]*3 + cidx[0];
flagval = ((flags >> flagbit) & 1);
}
bitCheck <<= 1;
bitCheck |= flagval;
}
// Whether we need to create a face depends on bitCheck.
// Values 00, 11 don't need lines, while 01 and 10 do.
// If our rect isn't an internal rect
if (bitCheck != 0x0 && bitCheck != 0x3)
{
// Check if the rect is on our active plane
int active = 0;
if (activePlane >= 0)
{
int planeDim = (activePlane >> 1); // same as "/ 2"
int planeIdx = 1 + (activePlane & 1); // same as "% 2"
if (planeDim == dim2 && i == planeIdx)
{
active = 1;
}
}
// Insert the rectangle with the correct sense
polys->InsertNextCell(4);
if (bitCheck == 0x2)
{
polys->InsertCellPoint(pointId[0]);
polys->InsertCellPoint(pointId[1]);
polys->InsertCellPoint(pointId[2]);
polys->InsertCellPoint(pointId[3]);
}
else // (bitCheck == 0x1)
{
polys->InsertCellPoint(pointId[3]);
polys->InsertCellPoint(pointId[2]);
polys->InsertCellPoint(pointId[1]);
polys->InsertCellPoint(pointId[0]);
}
// Color the face
if (scalars)
{
scalars->InsertNextTupleValue(colors[active]);
}
}
} // loop over k
} // loop over j
} // loop over i
} // loop over dim0
}
//----------------------------------------------------------------------------
void vtkVolumeOutlineSource::GenerateLines(
vtkCellArray *lines,
vtkUnsignedCharArray *scalars,
unsigned char colors[2][3],
int activePlane,
int flags,
int tolPtId[3][4])
{
// Loop over the three dimensions and create the lines
for (int dim0 = 0; dim0 < 3; dim0++)
{
// Compute the other two dimension indices
int dim1 = (dim0+1)%3;
int dim2 = (dim0+2)%3;
// Indices into the cubes
int idx[3];
// Loop over the "dim+2" dimension
for (int i = 0; i < 4; i++)
{
idx[dim2] = i;
// Loop over the "dim+1" dimension
for (int j = 0; j < 4; j++)
{
idx[dim1] = j;
// Loop over line segments along the "dim" dimension
for (int k = 0; k < 3; k++)
{
idx[dim0] = k;
// Make sure that the segment length is not less than tolerance
if ((k == 0 && tolPtId[dim0][1] == 0) ||
(k == 2 && tolPtId[dim0][2] == 3))
{
continue;
}
// The endpoints of the segment, which are nudged over to the
// volume bounds if the cropping planes are within tolerance
// of the volume bounds.
int pointId0 = (tolPtId[2][idx[2]]*16 +
tolPtId[1][idx[1]]*4 +
tolPtId[0][idx[0]]);
idx[dim0] = k + 1;
int pointId1 = (tolPtId[2][idx[2]]*16 +
tolPtId[1][idx[1]]*4 +
tolPtId[0][idx[0]]);
idx[dim0] = k;
// Loop through the four cubes adjacent to the line segment,
// in order to determine whether the line segment is on an
// edge: only the edge lines will be drawn. The "bitCheck"
// holds a bit for each of these four cubes.
int bitCheck = 0;
int cidx[3];
cidx[dim0] = idx[dim0];
for (int ii = 0; ii < 2; ii++)
{
// First get idx[dim1]-1, then idx[dim1]
cidx[dim1] = idx[dim1] + ii - 1;
for (int jj = 0; jj < 2; jj++)
{
// First get idx[dim2]-1, then idx[dim2], but reverse
// the order when ii loop is on its second iteration
cidx[dim2] = idx[dim2] + (ii^jj) - 1;
int flagval = 0;
if (cidx[dim1] >= 0 && cidx[dim1] < 3 &&
cidx[dim2] >= 0 && cidx[dim2] < 3)
{
int flagbit = cidx[2]*9 + cidx[1]*3 + cidx[0];
flagval = ((flags >> flagbit) & 1);
}
bitCheck <<= 1;
bitCheck |= flagval;
}
}
// Whether we need a line depends on the the value of bitCheck.
// Values 0000, 0011, 0110, 1100, 1001, 1111 don't need lines.
// Build a bitfield to check our bitfield values against, each
// set bit in this new bitfield corresponds to a non-edge case.
const int noLineValues = ((1 << 0x0) | (1 << 0x3) | (1 << 0x6) |
(1 << 0x9) | (1 << 0xc) | (1 << 0xf));
// If our line segment is an edge, there is lots of work to do.
if (((noLineValues >> bitCheck) & 1) == 0)
{
// Check if the line segment is on our active plane
int active = 0;
if (activePlane >= 0)
{
int planeDim = (activePlane >> 1); // same as "/ 2"
int planeIdx = 1 + (activePlane & 1); // same as "% 2"
if ((planeDim == dim2 && i == planeIdx) ||
(planeDim == dim1 && j == planeIdx))
{
active = 1;
}
}
// Check to make sure line segment isn't already there
int foundDuplicate = 0;
lines->InitTraversal();
vtkIdType npts, *pts;
for (int cellId = 0; lines->GetNextCell(npts, pts); cellId++)
{
if (pts[0] == pointId0 && pts[1] == pointId1)
{
// Change color if current segment is on active plane
if (scalars && active)
{
scalars->SetTupleValue(cellId, colors[active]);
}
foundDuplicate = 1;
break;
}
}
if (!foundDuplicate)
{
// Insert the line segment
lines->InsertNextCell(2);
lines->InsertCellPoint(pointId0);
lines->InsertCellPoint(pointId1);
// Color the line segment
if (scalars)
{
scalars->InsertNextTupleValue(colors[active]);
}
}
}
} // loop over k
} // loop over j
} // loop over i
} // loop over dim0
}
//----------------------------------------------------------------------------
void vtkVolumeOutlineSource::GeneratePoints(
vtkPoints *points, vtkCellArray *lines, vtkCellArray *polys,
double planes[3][4], double tol)
{
// Use a bitfield to store which of the 64 points we need.
// Two 32-bit ints are a convenient, portable way to do this.
unsigned int pointBits1 = 0;
unsigned int pointBits2 = 0;
vtkIdType npts, *pts;
vtkCellArray *cellArrays[2];
cellArrays[0] = lines;
cellArrays[1] = polys;
for (int arrayId = 0; arrayId < 2; arrayId++)
{
if (cellArrays[arrayId])
{
cellArrays[arrayId]->InitTraversal();
while (cellArrays[arrayId]->GetNextCell(npts, pts))
{
for (int ii = 0; ii < npts; ii++)
{
int pointId = pts[ii];
if (pointId < 32) { pointBits1 |= (1 << pointId); }
else { pointBits2 |= (1 << (pointId - 32)); }
}
}
}
}
// Create the array of up to 64 points, and use the pointBits bitfield
// to find out which points were used. It is also necessary to go through
// and update the cells with the modified point ids.
unsigned int pointBits = pointBits1;
int ptId = 0;
int newPtId = 0;
for (int i = 0; i < 4; i++)
{
// If we're halfway done, switch over to the next 32 bits
if (i == 2) { pointBits = pointBits2; }
for (int j = 0; j < 4; j++)
{
for (int k = 0; k < 4; k++)
{
// Check to see if this point was actually used
if ( (pointBits & 1) )
{
// Add or subtract tolerance as an offset to help depth check
double x = planes[0][k] + tol*(1 - 2*(k < 2));
double y = planes[1][j] + tol*(1 - 2*(j < 2));
double z = planes[2][i] + tol*(1 - 2*(i < 2));
points->InsertNextPoint(x, y, z);
for (int arrayId = 0; arrayId < 2; arrayId++)
{
// Go through the cells, substitute old Id for new Id
if (cellArrays[arrayId])
{
cellArrays[arrayId]->InitTraversal();
while (cellArrays[arrayId]->GetNextCell(npts, pts))
{
for (int ii = 0; ii < npts; ii++)
{
if (pts[ii] == ptId) { pts[ii] = newPtId; }
}
}
}
}
newPtId++;
}
pointBits >>= 1;
ptId++;
}
}
}
}
//----------------------------------------------------------------------------
void vtkVolumeOutlineSource::NudgeCropPlanesToBounds(
int tolPtId[3][4], double planes[3][4], double tol)
{
for (int dim = 0; dim < 3; dim++)
{
tolPtId[dim][0] = 0; tolPtId[dim][1] = 1;
tolPtId[dim][2] = 2; tolPtId[dim][3] = 3;
if (planes[dim][1] - planes[dim][0] < tol) { tolPtId[dim][1] = 0; }
if (planes[dim][3] - planes[dim][2] < tol) { tolPtId[dim][2] = 3; }
}
}
//----------------------------------------------------------------------------
void vtkVolumeOutlineSource::CreateColorValues(
unsigned char colors[2][3], double color1[3], double color2[3])
{
// Convert the two colors to unsigned char
double *dcolors[2];
dcolors[0] = color1;
dcolors[1] = color2;
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
double val = dcolors[i][j];
if (val < 0) { val = 0; }
if (val > 1) { val = 1; }
colors[i][j] = static_cast<unsigned char>(val*255);
}
}
}
|