Let $S$ be a connected subset of $\mathbf{R}^3$. I would like to know if there is any condition on $S$ under which any straight line $p: [0, 1] \rightarrow \mathbf{R}^3$, where $p(0) \in S$ and $p(1) \notin S$, passes through the boundary of $S$ only finitely many times.
Here passing through may be defined as follows.
The curve $p$ is said to enter the boundary $\partial S$ from $A$ at time $t$ if $p(t) \in \partial S$ and there exists $\varepsilon > 0$ such that $p(t - \delta) \in A$ for all $0 < \delta < \varepsilon$.
The curve $p$ is said to leave the boundary $\partial S$ to $A$ at time $t$ if $p(t) \in \partial S$ and there exists $\varepsilon > 0$ such that $p(t + \delta) \in A$ for all $0 < \delta < \varepsilon$.
The curve $p$ passes through $\partial S$ if one of the following happens:
$p$ enters $\partial S$ from ext($S$) at time $t_0$ and leaves $\partial S$ to int($S$) at time $t_1$ where $p(t) \in \partial S, \forall t \in [t_0, t_1]$.
$p$ enters $\partial S$ from int($S$) at time $t_0$ and leaves $\partial S$ to ext($S$) at time $t_1$ where $p(t) \in \partial S, \forall t \in [t_0, t_1]$.
Note that $t_0$ may be equal to $t_1$.
I tried to think of it first in two dimensional. If I have a set $S$ whose boundary has some portion containing infinite wiggles (I think of if as something similar to the topologist's sine curve), there might be a case where a curve $p$, starting inside $S$ and ending outside, passes through the boundary infinitely many times.
What conditions would prevent this situations from happening (in general)? I guess there may be some conditions on some kind of regularity of the boundary of the set $S$. Can anyone point me to some related keywords?
EDIT(1): Added the notion of passing through.
EDIT(2): Added an assumption on $p$.
EDIT(3): Restricted $p$ to be a straight line
EDIT(4): I think differentiability of the boundary curve (in two dimensional case, for example) might be related here. For example, from the figure above, I generated the boundary curve by attaching a segment of curve $y = x\sin(1/x)$, from $x = 0$ to some positive number, to some smooth curves. This boundary curve does not have continuous first derivative. I suspect that other boundaries with these kinds of infinite wiggles (still do know how to address it properly, though) would not have continuous derivative as well. Maybe if the boundary curve is $C^1-$ or $C^2-$continuous (and the path $p$ is a straight line), $p$ will then pass through the boundary of $S$ only finitely many times? Is there any related result? And can this idea be generalized to the three dimensional case as well?