Modified leading underscores into trailing underscores

This commit is contained in:
Geert-Jan Giezeman 1999-07-02 06:49:15 +00:00
parent 55491a8e34
commit 4f7bd64ab9
2 changed files with 110 additions and 111 deletions

View File

@ -670,7 +670,7 @@ CGAL_END_NAMESPACE
Line_2_Triangle_2_pair<R> *ncthis =
(Line_2_Triangle_2_pair<R> *) this;
ncthis->_known = true;
_Straight_2<R> straight(*_line);
Straight_2_<R> straight(*_line);
Line_2<R> l(_trian->vertex(0), _trian->vertex(1));
if (l.oriented_side(_trian->vertex(2)) == ON_POSITIVE_SIDE) {
// if (_trian->is_counterclockwise()) {
@ -689,15 +689,15 @@ if (l.oriented_side(_trian->vertex(2)) == ON_POSITIVE_SIDE) {
Line_2<R>(_trian->vertex(0), _trian->vertex(2)));
}
switch (straight.current_state()) {
case _Straight_2<R>::EMPTY:
case Straight_2_<R>::EMPTY:
ncthis->_result = NO;
return _result;
case _Straight_2<R>::POINT: {
case Straight_2_<R>::POINT: {
straight.current(ncthis->_intersection_point);
ncthis->_result = POINT;
return _result;
}
case _Straight_2<R>::SEGMENT: {
case Straight_2_<R>::SEGMENT: {
Segment_2<R> seg;
straight.current(seg);
ncthis->_intersection_point = seg.start();
@ -914,7 +914,7 @@ CGAL_END_NAMESPACE
Ray_2_Triangle_2_pair<R> *ncthis =
(Ray_2_Triangle_2_pair<R> *) this;
ncthis->_known = true;
_Straight_2<R> straight(*_ray);
Straight_2_<R> straight(*_ray);
Line_2<R> l(_trian->vertex(0), _trian->vertex(1));
if (l.oriented_side(_trian->vertex(2)) == ON_POSITIVE_SIDE) {
// if (_trian->is_counterclockwise()) {
@ -933,15 +933,15 @@ if (l.oriented_side(_trian->vertex(2)) == ON_POSITIVE_SIDE) {
Line_2<R>(_trian->vertex(0), _trian->vertex(2)));
}
switch (straight.current_state()) {
case _Straight_2<R>::EMPTY:
case Straight_2_<R>::EMPTY:
ncthis->_result = NO;
return _result;
case _Straight_2<R>::POINT: {
case Straight_2_<R>::POINT: {
straight.current(ncthis->_intersection_point);
ncthis->_result = POINT;
return _result;
}
case _Straight_2<R>::SEGMENT: {
case Straight_2_<R>::SEGMENT: {
Segment_2<R> seg;
straight.current(seg);
ncthis->_intersection_point = seg.start();
@ -1156,7 +1156,7 @@ CGAL_END_NAMESPACE
Segment_2_Triangle_2_pair<R> *ncthis =
(Segment_2_Triangle_2_pair<R> *) this;
ncthis->_known = true;
_Straight_2<R> straight(*_seg);
Straight_2_<R> straight(*_seg);
Line_2<R> l(_trian->vertex(0), _trian->vertex(1));
if (l.oriented_side(_trian->vertex(2)) == ON_POSITIVE_SIDE) {
straight.cut_right_off(
@ -1174,15 +1174,15 @@ if (l.oriented_side(_trian->vertex(2)) == ON_POSITIVE_SIDE) {
Line_2<R>(_trian->vertex(0), _trian->vertex(2)));
}
switch (straight.current_state()) {
case _Straight_2<R>::EMPTY:
case Straight_2_<R>::EMPTY:
ncthis->_result = NO;
return _result;
case _Straight_2<R>::POINT: {
case Straight_2_<R>::POINT: {
straight.current(ncthis->_intersection_point);
ncthis->_result = POINT;
return _result;
}
case _Straight_2<R>::SEGMENT: {
case Straight_2_<R>::SEGMENT: {
Segment_2<R> seg;
straight.current(seg);
ncthis->_intersection_point = seg.start();

View File

@ -4,27 +4,27 @@
CGAL_BEGIN_NAMESPACE
class _Straight_2_base {
class Straight_2_base_ {
public:
enum states {EMPTY, POINT, SEGMENT, RAY, LINE};
protected:
enum bound_states {NO_UNBOUNDED=0, MIN_UNBOUNDED=1, MAX_UNBOUNDED=2,
BOTH_UNBOUNDED = 3, LINE_EMPTY = 4};
_Straight_2_base() ;
int _main_dir; // _support is x or y directed (0/1).
int _dir_sign; // sign of main direction coord.
unsigned int _bound_state; // 0, 1, 2, 3, 4.
Straight_2_base_() ;
int main_dir_; // support_ is x or y directed (0/1).
int dir_sign_; // sign of main direction coord.
unsigned int bound_state_; // 0, 1, 2, 3, 4.
};
template <class R>
class _Straight_2: public _Straight_2_base {
class Straight_2_: public Straight_2_base_ {
public:
_Straight_2() ;
_Straight_2(Point_2<R> const &point) ;
_Straight_2(Line_2<R> const &line) ;
_Straight_2(Ray_2<R> const &ray) ;
_Straight_2(Segment_2<R> const &seg) ;
~_Straight_2() {}
Straight_2_() ;
Straight_2_(Point_2<R> const &point) ;
Straight_2_(Line_2<R> const &line) ;
Straight_2_(Ray_2<R> const &ray) ;
Straight_2_(Segment_2<R> const &seg) ;
~Straight_2_() {}
void cut_right_off(Line_2<R> const & cutter) ;
int collinear_order(Point_2<R> const & p1,
Point_2<R> const &p2) const ;
@ -34,9 +34,9 @@ public:
void current(Point_2<R> &point) const;
states current_state() const;
protected:
Line_2<R> _support; // The supporting line.
Point_2<R> _min;
Point_2<R> _max;
Line_2<R> support_; // The supporting line.
Point_2<R> min_;
Point_2<R> max_;
};
CGAL_END_NAMESPACE
@ -52,25 +52,25 @@ CGAL_END_NAMESPACE
CGAL_BEGIN_NAMESPACE
inline
_Straight_2_base::
_Straight_2_base()
Straight_2_base_::
Straight_2_base_()
{
_bound_state = LINE_EMPTY;
bound_state_ = LINE_EMPTY;
}
template <class R>
_Straight_2_base::states
_Straight_2<R>::
Straight_2_base_::states
Straight_2_<R>::
current_state() const
{
switch (_bound_state) {
switch (bound_state_) {
case BOTH_UNBOUNDED:
return LINE;
case MIN_UNBOUNDED:
case MAX_UNBOUNDED:
return RAY;
case NO_UNBOUNDED:
return (collinear_order(_min, _max) == 0) ? POINT : SEGMENT;
return (collinear_order(min_, max_) == 0) ? POINT : SEGMENT;
case LINE_EMPTY:
default:
return EMPTY;
@ -78,104 +78,103 @@ current_state() const
}
template <class R>
_Straight_2<R>::
_Straight_2()
Straight_2_<R>::
Straight_2_()
{
_bound_state = LINE_EMPTY;
bound_state_ = LINE_EMPTY;
}
template <class R>
_Straight_2<R>::
_Straight_2(Line_2<R> const &line)
Straight_2_<R>::
Straight_2_(Line_2<R> const &line)
{
_support = line;
Vector_2<R> const &dir(_support.direction().vector());
_main_dir = (abs(dir.x()) > abs(dir.y()) ) ? 0 : 1;
_dir_sign = sign(_support.direction().vector().cartesian(_main_dir));
_bound_state = BOTH_UNBOUNDED;
support_ = line;
Vector_2<R> const &dir = support_.direction().vector();
main_dir_ = (abs(dir.x()) > abs(dir.y()) ) ? 0 : 1;
dir_sign_ = sign(support_.direction().vector().cartesian(main_dir_));
bound_state_ = BOTH_UNBOUNDED;
}
template <class R>
_Straight_2<R>::
_Straight_2(Point_2<R> const &point)
Straight_2_<R>::
Straight_2_(Point_2<R> const &point)
{
_support = Line_2<R>(point, Direction_2<R>(R::RT(1),R::RT(0)));
_main_dir = 0;
_dir_sign = 1;
_bound_state = NO_UNBOUNDED;
_min = point;
_max = point;
support_ = Line_2<R>(point, Direction_2<R>(R::RT(1),R::RT(0)));
main_dir_ = 0;
dir_sign_ = 1;
bound_state_ = NO_UNBOUNDED;
min_ = point;
max_ = point;
}
template <class R>
_Straight_2<R>::
_Straight_2(Ray_2<R> const &ray)
Straight_2_<R>::
Straight_2_(Ray_2<R> const &ray)
{
_support = ray.supporting_line();
Vector_2<R> const &dir(ray.direction().vector());
// _main_dir = (abs(dir.hx()) > abs(dir.hy()) ) ? 0 : 1;
_main_dir = (abs(dir.x()) > abs(dir.y()) ) ? 0 : 1;
_dir_sign = sign(_support.direction().vector().cartesian(_main_dir));
_bound_state = MAX_UNBOUNDED;
_min = ray.start();
support_ = ray.supporting_line();
Vector_2<R> const &dir = ray.direction().vector();
// main_dir_ = (abs(dir.hx()) > abs(dir.hy()) ) ? 0 : 1;
main_dir_ = (abs(dir.x()) > abs(dir.y()) ) ? 0 : 1;
dir_sign_ = sign(support_.direction().vector().cartesian(main_dir_));
bound_state_ = MAX_UNBOUNDED;
min_ = ray.start();
}
template <class R>
_Straight_2<R>::
_Straight_2(Segment_2<R> const &seg)
Straight_2_<R>::
Straight_2_(Segment_2<R> const &seg)
{
_support = seg.supporting_line();
Vector_2<R> const &dir(_support.direction().vector());
// _main_dir = (abs(dir.hx()) > abs(dir.hy()) ) ? 0 : 1;
_main_dir = (abs(dir.x()) > abs(dir.y()) ) ? 0 : 1;
_dir_sign = sign(_support.direction().vector().cartesian(_main_dir));
_bound_state = NO_UNBOUNDED;
_min = seg.start();
_max = seg.end();
support_ = seg.supporting_line();
Vector_2<R> const &dir = support_.direction().vector();
main_dir_ = (abs(dir.x()) > abs(dir.y()) ) ? 0 : 1;
dir_sign_ = sign(support_.direction().vector().cartesian(main_dir_));
bound_state_ = NO_UNBOUNDED;
min_ = seg.start();
max_ = seg.end();
}
template <class R>
void
_Straight_2<R>::
Straight_2_<R>::
current(Line_2<R> &line) const
{
CGAL_kernel_assertion(_bound_state == BOTH_UNBOUNDED);
line = _support;
CGAL_kernel_assertion(bound_state_ == BOTH_UNBOUNDED);
line = support_;
}
template <class R>
void
_Straight_2<R>::
Straight_2_<R>::
current(Ray_2<R> &ray) const
{
CGAL_kernel_assertion(_bound_state == MIN_UNBOUNDED
|| _bound_state == MAX_UNBOUNDED);
if (_bound_state == MIN_UNBOUNDED) {
ray = Ray_2<R>(_max, -_support.direction());
CGAL_kernel_assertion(bound_state_ == MIN_UNBOUNDED
|| bound_state_ == MAX_UNBOUNDED);
if (bound_state_ == MIN_UNBOUNDED) {
ray = Ray_2<R>(max_, -_support.direction());
} else {
ray = Ray_2<R>(_min, _support.direction());
ray = Ray_2<R>(min_, support_.direction());
}
}
template <class R>
void
_Straight_2<R>::
Straight_2_<R>::
current(Segment_2<R> &seg) const
{
CGAL_kernel_assertion(_bound_state == NO_UNBOUNDED
&& collinear_order(_min, _max) != 0);
seg = Segment_2<R>(_min, _max);
CGAL_kernel_assertion(bound_state_ == NO_UNBOUNDED
&& collinear_order(min_, max_) != 0);
seg = Segment_2<R>(min_, max_);
}
template <class R>
void
_Straight_2<R>::
Straight_2_<R>::
current(Point_2<R> &pt) const
{
CGAL_kernel_assertion(_bound_state == NO_UNBOUNDED
&& collinear_order(_min, _max) == 0);
pt = _min;
CGAL_kernel_assertion(bound_state_ == NO_UNBOUNDED
&& collinear_order(min_, max_) == 0);
pt = min_;
}
/*
@ -233,59 +232,59 @@ sign_of_cross(Direction_2<R> const &dir1,
template <class R>
void
_Straight_2<R>::
Straight_2_<R>::
cut_right_off(Line_2<R> const & cutter)
// cut off any part of this straight that is to the right of the cutter.
{
if (_bound_state == LINE_EMPTY)
if (bound_state_ == LINE_EMPTY)
return;
Point_2<R> ispoint;
bool new_point;
Line_2_Line_2_pair<R> pair(&_support, &cutter);
switch (pair.intersection_type()) {
case Line_2_Line_2_pair<R>::NO:
if (cutter.has_on_negative_side(_support.point()))
_bound_state = LINE_EMPTY;
if (cutter.has_on_negative_side(support_.point()))
bound_state_ = LINE_EMPTY;
break;
case Line_2_Line_2_pair<R>::LINE:
break;
case Line_2_Line_2_pair<R>::POINT:
pair.intersection(ispoint);
new_point = false;
switch (sign_of_cross(_support.direction(), cutter.direction())) {
switch (sign_of_cross(support_.direction(), cutter.direction())) {
case -1: // new minimum.
if (_bound_state & MIN_UNBOUNDED) {
if (bound_state_ & MIN_UNBOUNDED) {
new_point = true;
_bound_state ^= MIN_UNBOUNDED; // exclusive or removes flag.
bound_state_ ^= MIN_UNBOUNDED; // exclusive or removes flag.
} else {
if (collinear_order(ispoint, _min) == -1)
if (collinear_order(ispoint, min_) == -1)
new_point = true;
}
if (new_point) {
if (!(_bound_state & MAX_UNBOUNDED)
&& collinear_order(ispoint, _max) == -1)
_bound_state = LINE_EMPTY;
if (!(bound_state_ & MAX_UNBOUNDED)
&& collinear_order(ispoint, max_) == -1)
bound_state_ = LINE_EMPTY;
else
_min = ispoint;
min_ = ispoint;
}
break;
case 0: // should not happen
CGAL_kernel_warning_msg(false, "Internal CGAL error.");
break;
case 1: // new maximum
if (_bound_state & MAX_UNBOUNDED) {
if (bound_state_ & MAX_UNBOUNDED) {
new_point = true;
_bound_state ^= MAX_UNBOUNDED; // exclusive or removes flag.
bound_state_ ^= MAX_UNBOUNDED; // exclusive or removes flag.
} else {
if (collinear_order(ispoint, _max) == 1)
if (collinear_order(ispoint, max_) == 1)
new_point = true;
}
if (new_point) {
if (!(_bound_state & MIN_UNBOUNDED)
&& collinear_order(ispoint, _min) == 1)
_bound_state = LINE_EMPTY;
if (!(bound_state_ & MIN_UNBOUNDED)
&& collinear_order(ispoint, min_) == 1)
bound_state_ = LINE_EMPTY;
else
_max = ispoint;
max_ = ispoint;
}
break;
}
@ -295,18 +294,18 @@ cut_right_off(Line_2<R> const & cutter)
template <class R>
int
_Straight_2<R>::
Straight_2_<R>::
collinear_order(Point_2<R> const &pt1, Point_2<R> const & pt2) const
// Compare two points on the _support line.
// Compare two points on the support_ line.
// If the second point lies in the direction of the direction vector from
// the first point, the result is 1.
// Other results are -1 (other side) and 0 (coincidence).
{
int diffsign;
diffsign = sign(pt2.cartesian(_main_dir)-pt1.cartesian(_main_dir));
diffsign = sign(pt2.cartesian(main_dir_)-pt1.cartesian(main_dir_));
if (diffsign == 0)
return 0;
return (diffsign == _dir_sign) ? 1 : -1;
return (diffsign == dir_sign_) ? 1 : -1;
}
CGAL_END_NAMESPACE