Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Junghyeon Park
VTK
Commits
14e43216
Commit
14e43216
authored
5 years ago
by
Yohann Bearzi (Kitware)
Browse files
Options
Downloads
Patches
Plain Diff
Added const on double* in vtkBox::IntersectBox
Also add of IntersectWithInfiniteLine in vtkBox
parent
3cf63a50
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Common/DataModel/vtkBox.cxx
+64
-1
64 additions, 1 deletion
Common/DataModel/vtkBox.cxx
Common/DataModel/vtkBox.h
+15
-2
15 additions, 2 deletions
Common/DataModel/vtkBox.h
with
79 additions
and
3 deletions
Common/DataModel/vtkBox.cxx
+
64
−
1
View file @
14e43216
...
...
@@ -20,6 +20,7 @@
#include
<algorithm>
// for sorting
#include
<cassert>
#include
<limits>
// for IntersectWithInfiniteLine
#include
<vector>
// for IntersectWithPlane
vtkStandardNewMacro
(
vtkBox
);
...
...
@@ -319,7 +320,7 @@ void vtkBox::EvaluateGradient(double x[3], double n[3])
// coordinate along line. (Notes: the intersection ray dir[3] is NOT
// normalized. Valid intersections will only occur between 0<=t<=1.)
char
vtkBox
::
IntersectBox
(
double
bounds
[
6
],
const
double
origin
[
3
],
double
dir
[
3
],
double
coord
[
3
],
double
&
t
)
const
double
bounds
[
6
],
const
double
origin
[
3
],
const
double
dir
[
3
],
double
coord
[
3
],
double
&
t
)
{
bool
inside
=
true
;
char
quadrant
[
3
];
...
...
@@ -523,6 +524,68 @@ int vtkBox::IntersectWithLine(const double bounds[6], const double p1[3], const
return
1
;
}
//----------------------------------------------------------------------------
bool
vtkBox
::
IntersectWithInfiniteLine
(
const
double
bounds
[
6
],
const
double
p1
[
3
],
const
double
p2
[
3
],
double
&
t1
,
double
&
t2
,
double
x1
[
3
],
double
x2
[
3
],
int
&
plane1
,
int
&
plane2
)
{
plane1
=
-
1
;
plane2
=
-
1
;
t1
=
-
std
::
numeric_limits
<
double
>::
infinity
();
t2
=
std
::
numeric_limits
<
double
>::
infinity
();
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
for
(
int
k
=
0
;
k
<
2
;
k
++
)
{
// Compute distances of p1 and p2 from the plane along the plane normal
int
i
=
2
*
j
+
k
;
double
t
=
std
::
abs
(
bounds
[
i
]
-
p1
[
j
])
<
VTK_DBL_MIN
?
0.0
:
(
bounds
[
i
]
-
p1
[
j
])
/
(
p2
[
j
]
-
p1
[
j
]);
double
xface
=
p1
[(
j
+
1
)
%
3
]
+
t
*
(
p2
[(
j
+
1
)
%
3
]
-
p1
[(
j
+
1
)
%
3
]),
yface
=
p1
[(
j
+
2
)
%
3
]
+
t
*
(
p2
[(
j
+
2
)
%
3
]
-
p1
[(
j
+
2
)
%
3
]);
// if (xface, yface) is inside the current face
if
(
xface
>=
bounds
[(
2
*
j
+
2
)
%
6
]
&&
xface
<=
bounds
[(
2
*
j
+
3
)
%
6
]
&&
yface
>=
bounds
[(
2
*
j
+
4
)
%
6
]
&&
yface
<=
bounds
[(
2
*
j
+
5
)
%
6
])
{
if
(
t1
==
-
std
::
numeric_limits
<
double
>::
infinity
())
{
t1
=
t
;
plane1
=
2
*
j
+
k
;
}
else
if
(
t
>=
t1
)
{
t2
=
t
;
plane2
=
2
*
j
+
k
;
break
;
}
else
{
t2
=
t1
;
t1
=
t
;
plane2
=
plane1
;
plane1
=
2
*
j
+
k
;
break
;
}
}
}
}
if
(
x1
)
{
x1
[
0
]
=
p1
[
0
]
+
t1
*
(
p2
[
0
]
-
p1
[
0
]);
x1
[
1
]
=
p1
[
1
]
+
t1
*
(
p2
[
1
]
-
p1
[
1
]);
x1
[
2
]
=
p1
[
2
]
+
t1
*
(
p2
[
2
]
-
p1
[
2
]);
}
if
(
x2
)
{
x2
[
0
]
=
p1
[
0
]
+
t2
*
(
p2
[
0
]
-
p1
[
0
]);
x2
[
1
]
=
p1
[
1
]
+
t2
*
(
p2
[
1
]
-
p1
[
1
]);
x2
[
2
]
=
p1
[
2
]
+
t2
*
(
p2
[
2
]
-
p1
[
2
]);
}
return
t1
!=
-
std
::
numeric_limits
<
double
>::
infinity
();
}
//----------------------------------------------------------------------------
vtkTypeBool
vtkBox
::
IntersectWithPlane
(
double
bounds
[
6
],
double
origin
[
3
],
double
normal
[
3
])
{
...
...
This diff is collapsed.
Click to expand it.
Common/DataModel/vtkBox.h
+
15
−
2
View file @
14e43216
...
...
@@ -96,8 +96,8 @@ public:
* dir[3] is NOT normalized. Valid intersections will only occur between
* 0<=t<=1.)
*/
static
char
IntersectBox
(
double
bounds
[
6
],
const
double
origin
[
3
],
double
dir
[
3
],
double
coord
[
3
],
double
&
t
);
static
char
IntersectBox
(
const
double
bounds
[
6
],
const
double
origin
[
3
],
const
double
dir
[
3
],
double
coord
[
3
],
double
&
t
);
/**
* Intersect a line with the box. Give the endpoints of the line in
...
...
@@ -114,6 +114,19 @@ public:
static
int
IntersectWithLine
(
const
double
bounds
[
6
],
const
double
p1
[
3
],
const
double
p2
[
3
],
double
&
t1
,
double
&
t2
,
double
x1
[
3
],
double
x2
[
3
],
int
&
plane1
,
int
&
plane2
);
/**
* Same method as vtkBox::IntersectWithLine, except that t1 and t2 can be outside of [0,1].
* t1 is the distance of x1 to p1 in parametric coordinates, and t2 is the distance of x2 to p1
* in parametric coordinates as well.
* In vtkBox::IntersectWithInLine, it is assumed that [p1,p2] is a segment, here, it is
* assumed that it is a line with no ends.
* t1 <= t2, which means that x1 is always "before" x2 on the line parameterized by [p1,p2].
* x1 and x2 can be set to nullptr without crash.
*/
static
bool
IntersectWithInfiniteLine
(
const
double
bounds
[
6
],
const
double
p1
[
3
],
const
double
p2
[
3
],
double
&
t1
,
double
&
t2
,
double
x1
[
3
],
double
x2
[
3
],
int
&
plane1
,
int
&
plane2
);
/**
* Plane intersection with the box. The plane is infinite in extent and
* defined by an origin and normal. The function indicates whether the
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment