forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkVisibilitySort.cxx
134 lines (105 loc) · 3.93 KB
/
vtkVisibilitySort.cxx
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
/*=========================================================================
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 "vtkIdList.h"
#include "vtkDataSet.h"
#include "vtkMatrix4x4.h"
#include "vtkCamera.h"
#include "vtkGarbageCollector.h"
//-----------------------------------------------------------------------------
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 = NULL;
this->Input = NULL;
this->Direction = vtkVisibilitySort::BACK_TO_FRONT;
this->MaxCellsReturned = VTK_INT_MAX;
}
//-----------------------------------------------------------------------------
vtkVisibilitySort::~vtkVisibilitySort()
{
this->ModelTransform->Delete();
this->InverseModelTransform->Delete();
this->SetCamera(NULL);
this->SetInput(NULL);
}
//-----------------------------------------------------------------------------
void vtkVisibilitySort::Register(vtkObjectBase *o)
{
this->RegisterInternal(o, 1);
}
void vtkVisibilitySort::UnRegister(vtkObjectBase *o)
{
this->UnRegisterInternal(o, 1);
}
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;
}