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
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkVisibilitySort.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.
=========================================================================*/
/*
* Copyright 2003 Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the
* U.S. Government. Redistribution and use in source and binary forms, with
* or without modification, are permitted provided that this Notice and any
* statement of authorship are reproduced on all copies.
*/
#include "vtkVisibilitySort.h"
#include "vtkCamera.h"
#include "vtkDataSet.h"
#include "vtkGarbageCollector.h"
#include "vtkIdList.h"
#include "vtkMatrix4x4.h"
//------------------------------------------------------------------------------
VTK_ABI_NAMESPACE_BEGIN
vtkCxxSetObjectMacro(vtkVisibilitySort, Camera, vtkCamera);
vtkCxxSetObjectMacro(vtkVisibilitySort, Input, vtkDataSet);
//------------------------------------------------------------------------------
vtkVisibilitySort::vtkVisibilitySort()
{
this->ModelTransform = vtkMatrix4x4::New();
this->ModelTransform->Identity();
this->InverseModelTransform = vtkMatrix4x4::New();
this->InverseModelTransform->Identity();
this->Camera = nullptr;
this->Input = nullptr;
this->Direction = vtkVisibilitySort::BACK_TO_FRONT;
this->MaxCellsReturned = VTK_INT_MAX;
}
//------------------------------------------------------------------------------
vtkVisibilitySort::~vtkVisibilitySort()
{
this->ModelTransform->Delete();
this->InverseModelTransform->Delete();
this->SetCamera(nullptr);
this->SetInput(nullptr);
}
//------------------------------------------------------------------------------
void vtkVisibilitySort::ReportReferences(vtkGarbageCollector* collector)
{
this->Superclass::ReportReferences(collector);
vtkGarbageCollectorReport(collector, this->Input, "Input");
}
//------------------------------------------------------------------------------
void vtkVisibilitySort::SetModelTransform(vtkMatrix4x4* mat)
{
// Less efficient than vtkMatrix4x4::DeepCopy, but only sets Modified if
// there is a real change.
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
this->ModelTransform->SetElement(i, j, mat->GetElement(i, j));
}
}
if (this->ModelTransform->GetMTime() > this->InverseModelTransform->GetMTime())
{
this->InverseModelTransform->DeepCopy(this->ModelTransform);
this->InverseModelTransform->Invert();
}
}
//------------------------------------------------------------------------------
void vtkVisibilitySort::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "Input: (" << this->Input << ")" << endl;
os << indent << "Direction: ";
switch (this->Direction)
{
case vtkVisibilitySort::BACK_TO_FRONT:
os << "back to front" << endl;
break;
case vtkVisibilitySort::FRONT_TO_BACK:
os << "front to back" << endl;
break;
default:
os << "unknown" << endl;
break;
}
os << indent << "MaxCellsReturned: " << this->MaxCellsReturned << endl;
os << indent << "ModelTransform:" << endl;
this->ModelTransform->PrintSelf(os, indent.GetNextIndent());
os << indent << "InverseModelTransform:" << endl;
this->InverseModelTransform->PrintSelf(os, indent.GetNextIndent());
os << indent << "Camera: (" << this->Camera << ")" << endl;
}
VTK_ABI_NAMESPACE_END
|