00001
00002
#include "2D_bsp.h"
00003
#include "display.h"
00004
#include "draw_line.h"
00005
#include "ddutil.h"
00006
00007
using namespace std;
00008
00009
00010 std::ostream &
operator<<(std::ostream &os,
const cWall &ex)
00011 {
00012
return os << ex.
p0 <<
"-->" << ex.
p1;
00013 };
00014
00015
00016
00017
00018
00019
00020 cWall::cWall()
00021 {
00022
p0 =
cPoint2D(0,0);
00023
p1 = cPoint2D(0,0);
00024 }
00025
00026
00027 cWall::cWall(
cWall& wall)
00028 {
00029
p0=wall.
p0;
00030
p1=wall.
p1;
00031 }
00032
00033
00034 cWall::cWall(
cPoint2D & A,
cPoint2D & B)
00035 {
00036
p0=A;
00037
p1=B;
00038 }
00039
00040
00041 BSP_POSITION_DIVIDER cWall::Get_Position_Divider_And_Split(
cWall & w ,
cWall & w_front ,
cWall & w_back )
00042 {
00043 std::cout <<
"BSP_POSITION_DIVIDER cWall::Get_Position_Divider_And_Split( cWall & w , cWall & w_front , cWall & w_back ) \n";
00044 std::cout <<
"NOT IMPLEMENTED !!!!!!\n";
00045
return DIVIDER_ON;
00046 }
00047
00048
00049 double cWall::Get_Length()
00050 {
00051
return sqrt( (
p0.
Get_X()-
p1.
Get_X()) * (
p0.
Get_X()-
p1.
Get_X())
00052 + (
p0.
Get_Y()-
p1.
Get_Y()) * (
p0.
Get_Y()-
p1.
Get_Y()) );
00053 }
00054
00055
00056
00057 void cWall::Display(
CDisplay * display)
00058 {
00059
Draw_Line( display ,
p0,
p1, 0x20 );
00060
00061 }
00062
00063
00064 BSP_POSITION_DIVIDER cWall::Get_Position_Divider(
cWall & w )
00065 {
00066
BSP_POSITION_POINT pos0 =
Get_Position_Point( w.
p0) ;
00067
BSP_POSITION_POINT pos1 = Get_Position_Point( w.
p1) ;
00068
00069
switch( pos0)
00070 {
00071
case POINT_FRONT:
00072
switch(pos1)
00073 {
00074
case POINT_FRONT:
00075
return DIVIDER_FRONT;
00076
case POINT_BACK:
00077
return DIVIDER_CROSS;
00078
case POINT_ON:
00079
return DIVIDER_FRONT;
00080
default:
00081 cout <<
"ERROR : BSP_POSITION_DIVIDER cWall::Get_Position_Divider( cWall & w )";
00082
return DIVIDER_ON;
00083 }
00084
break;
00085
case POINT_BACK:
00086
switch(pos1)
00087 {
00088
case POINT_FRONT:
00089
return DIVIDER_CROSS;
00090
case POINT_BACK:
00091
return DIVIDER_BACK;
00092
case POINT_ON:
00093
return DIVIDER_BACK;
00094
default:
00095 cout <<
"ERROR : BSP_POSITION_DIVIDER cWall::Get_Position_Divider( cWall & w )";
00096
return DIVIDER_ON;
00097 }
00098
break;
00099
case POINT_ON:
00100
switch(pos1)
00101 {
00102
case POINT_FRONT:
00103
return DIVIDER_ON;
00104
case POINT_BACK:
00105
return DIVIDER_BACK;
00106
case POINT_ON:
00107 cout <<
"ERROR : BSP_POSITION_DIVIDER cWall::Get_Position_Divider( cWall & w )";
00108 cout <<
"les murs parallelles ne sont pas encore gérés ! \n";
00109 cout <<
"cWall :" << w <<
" et " << (*this) <<
" \n";
00110
return DIVIDER_ON;
00111
default:
00112 cout <<
"ERROR : BSP_POSITION_DIVIDER cWall::Get_Position_Divider( cWall & w )";
00113
return DIVIDER_ON;
00114 }
00115
break;
00116
default:
00117 cout <<
"ERROR : BSP_POSITION_DIVIDER cWall::Get_Position_Divider( cWall & w )";
00118
return DIVIDER_ON;
00119 }
00120
00121
00122
00123 };
00124
00125