Fix a conflict with predefined macro "_B" in Hurricane::Diagonal.

This commit is contained in:
Jean-Paul Chaput 2023-03-07 17:21:08 +01:00
parent 1e8c304ac5
commit aafec8c64c
2 changed files with 25 additions and 29 deletions

View File

@ -50,7 +50,7 @@ namespace Hurricane {
, _source(source)
, _target(target)
, _width (width)
, _B (0)
, _dWidth(0)
{
_updateB();
}
@ -175,16 +175,16 @@ namespace Hurricane {
void Diagonal::_updateB ()
{
_B = (DbU::Unit)( (float)(_width)/sqrt(2) ) - _width/2;
if (_B % DbU::getPolygonStep()) {
_B += DbU::getPolygonStep() - (_B % DbU::getPolygonStep());
_dWidth = (DbU::Unit)( (float)(_width)/sqrt(2) ) - _width/2;
if (_dWidth % DbU::getPolygonStep()) {
_dWidth += DbU::getPolygonStep() - (_dWidth % DbU::getPolygonStep());
}
if (_B > _width/2) {
if (_dWidth > _width/2) {
cerr << Error( "Diagonal::_updateB(): Width is too small invalid polygon on,\n"
" %s"
, getString(this).c_str() ) << endl;
_B = _width/2;
_dWidth = _width/2;
}
}
@ -206,30 +206,30 @@ namespace Hurricane {
Point t = (dx > 0) ? _target : _source;
switch ( i ) {
case 0: return Point( s.getX()- A, s.getY()-_B );
case 1: return Point( s.getX()-_B, s.getY()- A );
case 2: return Point( s.getX()+_B, s.getY()- A );
case 3: return Point( t.getX()+ A, t.getY()-_B );
case 4: return Point( t.getX()+ A, t.getY()+_B );
case 5: return Point( t.getX()+_B, t.getY()+ A );
case 6: return Point( t.getX()-_B, t.getY()+ A );
case 0: return Point( s.getX()- A, s.getY()-_dWidth );
case 1: return Point( s.getX()-_dWidth, s.getY()- A );
case 2: return Point( s.getX()+_dWidth, s.getY()- A );
case 3: return Point( t.getX()+ A, t.getY()-_dWidth );
case 4: return Point( t.getX()+ A, t.getY()+_dWidth );
case 5: return Point( t.getX()+_dWidth, t.getY()+ A );
case 6: return Point( t.getX()-_dWidth, t.getY()+ A );
default:
case 7: return Point( s.getX()- A, s.getY()+_B );
case 7: return Point( s.getX()- A, s.getY()+_dWidth );
}
} else {
Point s = (dx > 0) ? _source : _target;
Point t = (dx > 0) ? _target : _source;
switch ( i ) {
case 0: return Point( s.getX()- A, s.getY()-_B );
case 1: return Point( t.getX()-_B, t.getY()- A );
case 2: return Point( t.getX()+_B, t.getY()- A );
case 3: return Point( t.getX()+ A, t.getY()-_B );
case 4: return Point( t.getX()+ A, t.getY()+_B );
case 5: return Point( s.getX()+_B, s.getY()+ A );
case 6: return Point( s.getX()-_B, s.getY()+ A );
case 0: return Point( s.getX()- A, s.getY()-_dWidth );
case 1: return Point( t.getX()-_dWidth, t.getY()- A );
case 2: return Point( t.getX()+_dWidth, t.getY()- A );
case 3: return Point( t.getX()+ A, t.getY()-_dWidth );
case 4: return Point( t.getX()+ A, t.getY()+_dWidth );
case 5: return Point( s.getX()+_dWidth, s.getY()+ A );
case 6: return Point( s.getX()-_dWidth, s.getY()+ A );
default:
case 7: return Point( s.getX()- A, s.getY()+_B );
case 7: return Point( s.getX()- A, s.getY()+_dWidth );
}
}
}

View File

@ -1,6 +1,6 @@
// -*- C++ -*-
//
// Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
// Copyright (c) BULL S.A. 2000-2023, All Rights Reserved
//
// This file is part of Hurricane.
//
@ -29,9 +29,7 @@
// +-----------------------------------------------------------------+
#ifndef HURRICANE_DIAGONAL_H
#define HURRICANE_DIAGONAL_H
#pragma once
#include "hurricane/Component.h"
@ -85,7 +83,7 @@ namespace Hurricane {
Point _source;
Point _target;
DbU::Unit _width;
DbU::Unit _B; // octagon half Y.
DbU::Unit _dWidth; // octagon half Y.
};
@ -105,5 +103,3 @@ namespace Hurricane {
INSPECTOR_P_SUPPORT(Hurricane::Diagonal);
#endif // HURRICANE_DIAGONAL_H