Skip to content

Commit

Permalink
Per #2486, update vx_math affine.h/.cc and vx_vector.h/.cc based on R…
Browse files Browse the repository at this point in the history
…andy's versions in jethro:/d1/bullock/codetree/randy/basic/vx_math. Also replace cerr with calls to mlog << Error and add fix std::ostream.
  • Loading branch information
JohnHalleyGotway committed Jan 11, 2024
1 parent 8cd908b commit b5fd8cd
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 56 deletions.
78 changes: 57 additions & 21 deletions src/basic/vx_math/affine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ calc_det();

if ( fabs(Det) < 1.0e-7 ) {

cerr << "\n\n Affine::set_mb() -> determinant nearly zero!\n\n";
mlog << Error << "\nAffine::set_mb() -> "
<< "determinant nearly zero!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -264,6 +265,21 @@ return;
////////////////////////////////////////////////////////////////////////


void Affine::set_b(double _b1, double _b2)

{

TX = _b1;
TY = _b2;

return;

}


////////////////////////////////////////////////////////////////////////


bool Affine::is_conformal() const

{
Expand Down Expand Up @@ -545,7 +561,8 @@ D = x1_from*(y2_from - y3_from)

if ( D == 0.0 ) {

cerr << "\n\n Affine::set_three_points_v1() -> collinear (u, v) points!\n\n";
mlog << Error << "\nAffine::set_three_points_v1() -> "
<< "collinear (u, v) points!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -580,7 +597,8 @@ calc_det();

if ( fabs(Det) < 1.0e-7 ) {

cerr << "\n\n Affine::set_three_points_v1() -> (x, y) points nearly collinear!\n\n";
mlog << Error << "\nAffine::set_three_points_v1() -> "
<< "(x, y) points nearly collinear!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -814,7 +832,8 @@ calc_det();

if ( fabs(Det) < 1.0e-7 ) {

cerr << "\n\n DiagonalAffine::set_mb() -> determinant nearly zero!\n\n";
mlog << Error << "\nDiagonalAffine::set_mb() -> "
<< "determinant nearly zero!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -1152,7 +1171,8 @@ calc_det();

if ( fabs(Det) < 1.0e-7 ) {

cerr << "\n\n DiagonalAffine::set_two_points() -> (x, y) points nearly collinear!\n\n";
mlog << Error << "\nDiagonalAffine::set_two_points() -> "
<< "(x, y) points nearly collinear!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -1422,7 +1442,8 @@ void ConformalAffine::set_scale(double s)

if ( s <= 0.0 ) {

cerr << "\n\n ConformalAffine::set_scale(double) -> scale must be strictly positive!\n\n";
mlog << Error << "\nConformalAffine::set_scale(double) -> "
<< "scale must be strictly positive!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -1903,15 +1924,17 @@ Top = T;

if ( width() < 0.0 ) {

cerr << "\n\n Box::set_lrbt() -> negative width!\n\n";
mlog << Error << "\nBox::set_lrbt() -> "
<< "negative width!\n\n";

exit ( 1 );

}

if ( height() < 0.0 ) {

cerr << "\n\n Box::set_lrbt() -> negative height!\n\n";
mlog << Error << "\nBox::set_lrbt() -> "
<< "negative height!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -2023,7 +2046,8 @@ void Box::scale_from_ll(double s)

if ( s <= 0.0 ) {

cerr << "\n\n Box::scale_from_ll(double) -> scale factor must be strictly positive\n\n";
mlog << Error << "\nBox::scale_from_ll(double) -> "
<< "scale factor must be strictly positive\n\n";

exit ( 1 );

Expand Down Expand Up @@ -2072,7 +2096,8 @@ Bottom -= py;

if ( (width() <= 0.0) || (height() <= 0.0) ) {

cerr << "\n\n Box::pad(double, double) -> width and/or height is negative!\n\n";
mlog << Error << "\nBox::pad(double, double) -> "
<< "width and/or height is negative!\n\n";

exit ( 1 );

Expand All @@ -2092,7 +2117,8 @@ void Box::scale_from_center(double s)

if ( s <= 0.0 ) {

cerr << "\n\n Box::scale_from_center(double) -> scale factor must be strictly positive\n\n";
mlog << Error << "\nBox::scale_from_center(double) -> "
<< "scale factor must be strictly positive\n\n";

exit ( 1 );

Expand Down Expand Up @@ -2132,7 +2158,8 @@ void Box::scale_from_origin(double s)

if ( s <= 0.0 ) {

cerr << "\n\n Box::scale_from_origin(double) -> scale factor must be strictly positive\n\n";
mlog << Error << "\nBox::scale_from_origin(double) -> "
<< "scale factor must be strictly positive\n\n";

exit ( 1 );

Expand Down Expand Up @@ -2163,7 +2190,8 @@ void Box::scale_from_origin(double sx, double sy)

if ( (sx <= 0.0) || (sy <= 0.0) ) {

cerr << "\n\n Box::scale_from_origin(double, double) -> scale factor(s) must be strictly positive\n\n";
mlog << Error << "\nBox::scale_from_origin(double, double) -> "
<< "scale factor(s) must be strictly positive\n\n";

exit ( 1 );

Expand Down Expand Up @@ -2431,7 +2459,8 @@ void Box::set_center(const Box & b)

if ( b.is_empty() ) {

cerr << "\n\n Box::set_center(const Box &) -> given box is empty!\n\n";
mlog << Error << "\nBox::set_center(const Box &) -> "
<< "given box is empty!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -2479,15 +2508,17 @@ double calc_aspect(double width, double height)

if ( (width < 0.0) || (height < 0.0) ) {

cerr << "\n\n calc_aspect() const -> negative box dimensions!\n\n";
mlog << Error << "\ncalc_aspect() const -> "
<< "negative box dimensions!\n\n";

exit ( 1 );

}

if ( height == 0.0 ) {

cerr << "\n\n calc_aspect() const -> zero height!\n\n";
mlog << Error << "\ncalc_aspect() const -> "
<< "zero height!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -2677,7 +2708,8 @@ Box surround(const Box * a, int n_boxes)

if ( n_boxes <= 0 ) {

cerr << "\n\n surround(const Box * a, int n_boxes) -> bad number of boxes ... " << n_boxes << "\n\n";
mlog << Error << "\nsurround(const Box * a, int n_boxes) -> "
<< "bad number of boxes ... " << n_boxes << "\n\n";

exit ( 1 );

Expand Down Expand Up @@ -2737,7 +2769,8 @@ Box surround(const double * x_points, const double * y_points, const int n)

if ( n < 2 ) {

cerr << "\n\n surround(const double * x, const double * y, const int n) -> need at least 2 points!\n\n";
mlog << Error << "\nsurround(const double * x, const double * y, const int n) -> "
<< "need at least 2 points!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -2767,15 +2800,17 @@ for (j=1; j<n; ++j) { // j starts at 1, here

if ( (R - L) <= 0.0 ) {

cerr << "\n\n surround(const double * x, const double * y, const int n) -> bad box width!\n\n";
mlog << Error << "\nsurround(const double * x, const double * y, const int n) -> "
<< "bad box width!\n\n";

exit ( 1 );

}

if ( (T - B) <= 0.0 ) {

cerr << "\n\n surround(const double * x, const double * y, const int n) -> bad box height!\n\n";
mlog << Error << "\nsurround(const double * x, const double * y, const int n) -> "
<< "bad box height!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -2815,7 +2850,8 @@ switch ( g ) {


default:
cerr << "\n\n viewgravity_to_uv() -> bad gravity ... "
mlog << Error << "\nviewgravity_to_uv() -> "
<< "bad gravity ... "
<< viewgravity_to_string(g) << "\n\n";
exit ( 1 );
break;
Expand Down
22 changes: 7 additions & 15 deletions src/basic/vx_math/affine.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@
#define __VX_MATH_AFFINE_H__


////////////////////////////////////////////////////////////////////////


//
// This header file is part of the Verification Group's
//
// Math Library code
//


////////////////////////////////////////////////////////////////////////


Expand Down Expand Up @@ -77,7 +67,7 @@ class AffineInterface {

virtual void clear() = 0;

virtual void dump(ostream &, int depth = 0) const = 0;
virtual void dump(std::ostream &, int depth = 0) const = 0;

//
// set stuff
Expand Down Expand Up @@ -165,7 +155,7 @@ class Affine : public AffineInterface {

void clear(); // set to identity

virtual void dump(ostream &, int depth = 0) const;
virtual void dump(std::ostream &, int depth = 0) const;

//
// set stuff
Expand All @@ -181,6 +171,8 @@ class Affine : public AffineInterface {

void set_m (double _m11, double _m12, double _m21, double _m22); // sets TX = TY = 0.0

void set_b (double _b1, double _b2);

//
// version 1
//
Expand Down Expand Up @@ -311,7 +303,7 @@ class DiagonalAffine : public AffineInterface {

void clear(); // set to identity

virtual void dump(ostream &, int depth = 0) const;
virtual void dump(std::ostream &, int depth = 0) const;

//
// set stuff
Expand Down Expand Up @@ -475,7 +467,7 @@ class ConformalAffine : public AffineInterface {

void clear();

void dump (ostream &, int depth = 0) const;
void dump (std::ostream &, int depth = 0) const;

//
// set stuff
Expand Down Expand Up @@ -624,7 +616,7 @@ class Box {

virtual void clear();

virtual void dump(ostream &, int = 0) const;
virtual void dump(std::ostream &, int = 0) const;

//
// set stuff
Expand Down
Loading

0 comments on commit b5fd8cd

Please sign in to comment.