Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Christian Butz
VTK
Commits
42408dac
Commit
42408dac
authored
May 02, 2011
by
David Partyka
Browse files
Merge branch 'move-spiralpoints' into release
parents
d300d7cd
ab17f5ff
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Common/vtkMath.cxx
View file @
42408dac
This diff is collapsed.
Click to expand it.
Common/vtkMath.h
View file @
42408dac
...
...
@@ -928,12 +928,6 @@ public:
// Delta is the error margin along each axis (usually a small number)
static
int
PointIsWithinBounds
(
double
point
[
3
],
double
bounds
[
6
],
double
delta
[
3
]);
// Description:
// Calculate \a num points, at a regular interval, along a parametric
// spiral. Note this spiral is only in two dimensions having a constant
// z value.
static
void
SpiralPoints
(
vtkIdType
num
,
vtkPoints
*
offsets
);
// Description:
// In Euclidean space, there is a unique circle passing through any given
// three non-collinear points P1, P2, and P3. Using Cartesian coordinates
...
...
Graphics/vtkCoincidentPoints.cxx
View file @
42408dac
...
...
@@ -21,6 +21,7 @@
#include "vtkCoincidentPoints.h"
#include "vtkIdList.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkPoints.h"
#include "vtkSmartPointer.h"
...
...
@@ -53,10 +54,10 @@ public:
double
coord
[
3
];
Coord
()
{
this
->
coord
[
0
]
=
-
1.0
;
this
->
coord
[
1
]
=
-
1.0
;
this
->
coord
[
2
]
=
-
1.0
;
{
this
->
coord
[
0
]
=
-
1.0
;
this
->
coord
[
1
]
=
-
1.0
;
this
->
coord
[
2
]
=
-
1.0
;
}
Coord
(
const
Coord
&
src
)
{
...
...
@@ -80,8 +81,8 @@ public:
inline
bool
operator
<
(
const
Coord
&
other
)
const
{
return
this
->
coord
[
0
]
<
other
.
coord
[
0
]
||
(
this
->
coord
[
0
]
==
other
.
coord
[
0
]
&&
(
this
->
coord
[
1
]
<
other
.
coord
[
1
]
||
return
this
->
coord
[
0
]
<
other
.
coord
[
0
]
||
(
this
->
coord
[
0
]
==
other
.
coord
[
0
]
&&
(
this
->
coord
[
1
]
<
other
.
coord
[
1
]
||
(
this
->
coord
[
1
]
==
other
.
coord
[
1
]
&&
this
->
coord
[
2
]
<
other
.
coord
[
2
])));
}
};
...
...
@@ -178,7 +179,7 @@ void vtkCoincidentPoints::RemoveNonCoincidentPoints()
vtkIdList
*
vtkCoincidentPoints
::
GetNextCoincidentPointIds
()
{
vtkIdList
*
rvalue
=
NULL
;
if
(
this
->
Implementation
->
TraversalIterator
!=
if
(
this
->
Implementation
->
TraversalIterator
!=
this
->
Implementation
->
CoordMap
.
end
())
{
rvalue
=
(
*
this
->
Implementation
->
TraversalIterator
).
second
;
...
...
@@ -193,3 +194,38 @@ void vtkCoincidentPoints::InitTraversal()
{
this
->
Implementation
->
TraversalIterator
=
this
->
Implementation
->
CoordMap
.
begin
();
}
//----------------------------------------------------------------------------
// vtkSpiralkVertices - calculate points at a regular interval along a parametric
// spiral.
void
vtkCoincidentPoints
::
SpiralPoints
(
vtkIdType
num
,
vtkPoints
*
offsets
)
{
int
maxIter
=
10
;
double
pi
=
vtkMath
::
Pi
();
double
a
=
1
/
(
4
*
pi
*
pi
);
offsets
->
Initialize
();
offsets
->
SetNumberOfPoints
(
num
);
for
(
vtkIdType
i
=
0
;
i
<
num
;
i
++
)
{
double
d
=
2.0
*
i
/
sqrt
(
3.0
);
// We are looking for points at regular intervals along the parametric spiral
// x = t*cos(2*pi*t)
// y = t*sin(2*pi*t)
// We cannot solve this equation exactly, so we use newton's method.
// Using an Excel trendline, we find that
// t = 0.553*d^0.502
// is an excellent starting point./g
double
t
=
0.553
*
pow
(
d
,
0.502
);
for
(
int
iter
=
0
;
iter
<
maxIter
;
iter
++
)
{
double
r
=
sqrt
(
t
*
t
+
a
*
a
);
double
f
=
pi
*
(
t
*
r
+
a
*
a
*
log
(
t
+
r
))
-
d
;
double
df
=
2
*
pi
*
r
;
t
=
t
-
f
/
df
;
}
double
x
=
t
*
cos
(
2
*
pi
*
t
);
double
y
=
t
*
sin
(
2
*
pi
*
t
);
offsets
->
SetPoint
(
i
,
x
,
y
,
0
);
}
}
Graphics/vtkCoincidentPoints.h
View file @
42408dac
...
...
@@ -20,8 +20,8 @@
// .NAME vtkCoincidentPoints - contains an octree of labels
//
// .SECTION Description
// This class provides a collection of points that is organized such that
// each coordinate is stored with a set of point id's of points that are
// This class provides a collection of points that is organized such that
// each coordinate is stored with a set of point id's of points that are
// all coincident.
#ifndef __vtkCoincidentPoints_h
...
...
@@ -67,7 +67,7 @@ public:
void
RemoveNonCoincidentPoints
();
// Description
// Clear the maps for reuse. This should be called if the caller
// Clear the maps for reuse. This should be called if the caller
// might reuse this class (another executive pass for instance).
void
Clear
();
...
...
@@ -76,6 +76,12 @@ public:
implementation
*
GetImplementation
()
{
return
this
->
Implementation
;
}
//ETX
// Description:
// Calculate \a num points, at a regular interval, along a parametric
// spiral. Note this spiral is only in two dimensions having a constant
// z value.
static
void
SpiralPoints
(
vtkIdType
num
,
vtkPoints
*
offsets
);
protected:
vtkCoincidentPoints
();
virtual
~
vtkCoincidentPoints
();
...
...
Infovis/vtkPerturbCoincidentVertices.cxx
View file @
42408dac
...
...
@@ -58,7 +58,7 @@ void vtkPerturbCoincidentVertices::SpiralPerturbation(vtkGraph *input, vtkGraph
output
->
ShallowCopy
(
input
);
output
->
GetPoints
()
->
DeepCopy
(
input
->
GetPoints
());
vtkPoints
*
points
=
output
->
GetPoints
();
int
numPoints
=
points
->
GetNumberOfPoints
();
double
bounds
[
6
];
// xmin, xmax, ymin, ymax, zmin, zmax
points
->
ComputeBounds
();
...
...
@@ -160,7 +160,7 @@ void vtkPerturbCoincidentVertices::SpiralPerturbation(vtkGraph *input, vtkGraph
// use the smallest metric to scale the spiral vertices.
scale
=
shortestEdge
<
averageDistance
?
shortestEdge
/
4
:
averageDistance
/
4
;
vtkSmartPointer
<
vtkPoints
>
offsets
=
vtkSmartPointer
<
vtkPoints
>::
New
();
coincidentPoints
->
InitTraversal
();
coincidentPointsList
=
coincidentPoints
->
GetNextCoincidentPointIds
();
// Iterate over each coordinate that may have a set of coincident point ids.
...
...
@@ -168,7 +168,7 @@ void vtkPerturbCoincidentVertices::SpiralPerturbation(vtkGraph *input, vtkGraph
{
// Iterate over all coincident point ids and perturb them
numCoincidentPoints
=
coincidentPointsList
->
GetNumberOfIds
();
vtk
Math
::
SpiralPoints
(
numCoincidentPoints
+
1
,
offsets
);
vtk
CoincidentPoints
::
SpiralPoints
(
numCoincidentPoints
+
1
,
offsets
);
for
(
i
=
0
;
i
<
numCoincidentPoints
;
++
i
)
{
Id
=
coincidentPointsList
->
GetId
(
i
);
...
...
@@ -190,7 +190,7 @@ struct Coord
{
double
coord
[
2
];
Coord
()
{
{
}
Coord
(
const
double
src
[
3
]
)
{
...
...
@@ -201,14 +201,14 @@ struct Coord
static
double
distance
(
Coord
x
,
Coord
y
)
{
return
(
(
x
.
coord
[
0
]
-
y
.
coord
[
0
]
)
*
(
x
.
coord
[
0
]
-
y
.
coord
[
0
]
)
return
(
(
x
.
coord
[
0
]
-
y
.
coord
[
0
]
)
*
(
x
.
coord
[
0
]
-
y
.
coord
[
0
]
)
+
(
x
.
coord
[
1
]
-
y
.
coord
[
1
]
)
*
(
x
.
coord
[
1
]
-
y
.
coord
[
1
]
)
);
}
};
//----------------------------------------------------------------------------
void
vtkPerturbCoincidentVertices
::
SimpleSpiralPerturbation
(
vtkGraph
*
input
,
vtkGraph
*
output
,
void
vtkPerturbCoincidentVertices
::
SimpleSpiralPerturbation
(
vtkGraph
*
input
,
vtkGraph
*
output
,
float
perturbFactor
)
{
// The points will be deep copied because they
...
...
@@ -282,7 +282,7 @@ void vtkPerturbCoincidentVertices::SimpleSpiralPerturbation(vtkGraph *input,
// Set the offset distance to be the shortest distance /4 * user setting (perturbFactor)
double
offsetDistance
=
sqrt
(
shortestDistance
)
/
4.0
*
perturbFactor
;
// These store the offsets for a spiral with a certain number of points
vtkSmartPointer
<
vtkPoints
>
offsets
=
vtkSmartPointer
<
vtkPoints
>::
New
();
...
...
@@ -296,7 +296,7 @@ void vtkPerturbCoincidentVertices::SimpleSpiralPerturbation(vtkGraph *input,
{
// Iterate over all coincident point ids and perturb them
numCoincidentPoints
=
coincidentPointsList
->
GetNumberOfIds
();
vtk
Math
::
SpiralPoints
(
numCoincidentPoints
+
1
,
offsets
);
vtk
CoincidentPoints
::
SpiralPoints
(
numCoincidentPoints
+
1
,
offsets
);
for
(
int
i
=
0
;
i
<
numCoincidentPoints
;
++
i
)
{
index
=
coincidentPointsList
->
GetId
(
i
);
...
...
@@ -314,8 +314,8 @@ void vtkPerturbCoincidentVertices::SimpleSpiralPerturbation(vtkGraph *input,
//----------------------------------------------------------------------------
int
vtkPerturbCoincidentVertices
::
RequestData
(
vtkInformation
*
vtkNotUsed
(
request
),
vtkInformationVector
**
inputVector
,
vtkInformation
*
vtkNotUsed
(
request
),
vtkInformationVector
**
inputVector
,
vtkInformationVector
*
outputVector
)
{
vtkGraph
*
input
=
vtkGraph
::
GetData
(
inputVector
[
0
]);
...
...
Rendering/vtkLabelHierarchy.cxx
View file @
42408dac
...
...
@@ -1034,7 +1034,7 @@ bool vtkLabelHierarchyQuadtreeIterator::IsNodeInFrustum( NodePointer node )
* of nodes at level M exist, this means the list of children will be
* (2**D)**(M+1) long.
* For a quadtree, D = 2.
*
*
* Instead of limiting the Queue size, we limit the total number of nodes queued.
* Since nodes are popped off the front of the queue as they are pushed onto the
* back, this is a stricter limit. It is also more closely related to the actual
...
...
@@ -1414,7 +1414,7 @@ bool vtkLabelHierarchyOctreeQueueIterator::IsNodeInFrustum( NodePointer node )
* of nodes at level M exist, this means the list of children will be
* (2**D)**(M+1) long.
* For an octree, D = 3.
*
*
* Instead of limiting the Queue size, we limit the total number of nodes queued.
* Since nodes are popped off the front of the queue as they are pushed onto the
* back, this is a stricter limit. It is also more closely related to the actual
...
...
@@ -1930,13 +1930,13 @@ void vtkLabelHierarchyBuildCoincidenceMap(
setCount = 0;
for( ; setIter != (*mapIter).second.second.end(); ++setIter )
{
impl->CoincidenceMap[(*setIter)] =
impl->CoincidenceMap[(*setIter)] =
lh->GetCenterPts()->InsertNextPoint( point );
lh->GetPoints()->SetPoint( (*setIter),
point[0] + offsets[setCount + 1].first * scale,
point[1] + offsets[setCount + 1].second * scale,
point[2] );
//cout << "Point: " << point[0] + offsets[setCount].first*scale << " " <<
//cout << "Point: " << point[0] + offsets[setCount].first*scale << " " <<
// point[1] + offsets[setCount].second*scale << endl;
++setCount;
}
...
...
@@ -2034,13 +2034,13 @@ void vtkLabelHierarchy::ComputeHierarchy()
{
// Iterate over all coincident point ids and perturb them
numCoincidentPoints
=
coincidentPoints
->
GetNumberOfIds
();
vtk
Math
::
SpiralPoints
(
numCoincidentPoints
+
1
,
offsets
);
vtk
CoincidentPoints
::
SpiralPoints
(
numCoincidentPoints
+
1
,
offsets
);
for
(
int
i
=
0
;
i
<
numCoincidentPoints
;
++
i
)
{
Id
=
coincidentPoints
->
GetId
(
i
);
this
->
Points
->
GetPoint
(
Id
,
point
);
// save center points for drawing spokes.
/*this->Implementation->CoincidenceMap[i] =
/*this->Implementation->CoincidenceMap[i] =
this->CenterPts->InsertNextPoint(point);*/
offsets
->
GetPoint
(
i
+
1
,
spiralPoint
);
this
->
Points
->
SetPoint
(
Id
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment