📄 cadbase.cpp
字号:
//-- {AddDecl: 653} region.unprotectedFunction [21951..22107]
CBox3D::CBox3D(double ix0,double iy0,double iz0,double ix1,double iy1, double iz1)
{
//## begin CBox3D::CBox3D%7EEFA6BBFEED.body preserve=yes
x0 = ix0; y0=iy0; z0=iz0;x1=ix1; y1=iy1;z1=iz1;
normalize();
//## end CBox3D::CBox3D%7EEFA6BBFEED.body
}
//-- {AddDecl: 654} region.unprotectedFunction [22108..22233]
CBox3D::CBox3D(POINT3D pt0,POINT3D pt1)
{
//## begin CBox3D::CBox3D%11E5914BFEED.body preserve=yes
x0 = pt0.x; y0=pt0.y; z0=pt0.z;x1=pt1.x; y1=pt1.y;z1=pt1.z;
normalize();
//## end CBox3D::CBox3D%11E5914BFEED.body
}
//-- {AddDecl: 655} region.unprotectedFunction [22234..22337]
CBox3D::CBox3D(BOX3D b)
{
//## begin CBox3D::CBox3D%7AE2F31CFEED.body preserve=yes
x0=b.x0; y0=b.y0;z0=b.z0;
x1=b.x1; y1=b.y1;z1=b.z1;
normalize();
//## end CBox3D::CBox3D%7AE2F31CFEED.body
}
//-- {AddDecl: 656} region.unprotectedFunction [22338..22469]
CBox3D::CBox3D(POINT3D p,VECTOR3D v)
{
//## begin CBox3D::CBox3D%71491B59FEED.body preserve=yes
x0=p.x; y0=p.y; z0=p.z;
x1=p.x+v.dx;
y1=p.x+v.dy;
z1=p.x+v.dz;
normalize();
//## end CBox3D::CBox3D%71491B59FEED.body
}
//-- {AddDecl: 657} region.unprotectedFunction [22470..22496]
CBox3D::~CBox3D()
{
//## begin CBox3D::~CBox3D%672AF143FEED.body preserve=yes
//## end CBox3D::~CBox3D%672AF143FEED.body
}
//-- {AddDecl: 658} region.unprotectedFunction [22497..22896]
// operator
//// get the union box of this and box b.
CBox3D CBox3D::operator+(BOX3D b) const
{
//## begin CBox3D::operator +%36C3AB0BFEED.body preserve=yes
CBox3D box = *this;
if( ((CBox3D)b).IsEmpty( ) ) return box;
if( IsEmpty( ) ) return b;
box.x0 = (x0<b.x0)?x0:b.x0;
box.y0 = (y0<b.y0)?y0:b.y0;
box.z0 = (z0<b.z0)?z0:b.z0;
box.x1 = (x1>b.x1)?x1:b.x1;
box.y1 = (y1>b.y1)?y1:b.y1;
box.z1 = (z1>b.z1)?z1:b.z1;
return box;
//## end CBox3D::operator +%36C3AB0BFEED.body
}
//-- {AddDecl: 659} region.unprotectedFunction [22897..23027]
void CBox3D::operator*= ( double sc )
{
//## begin CBox3D::operator *=%B44430E1FEED.body preserve=yes
x0 = x0*sc;
y0 = y0*sc;
z0 = z0*sc;
x1 = x1*sc;
y1 = y1*sc;
z1 = z1*sc;
//## end CBox3D::operator *=%B44430E1FEED.body
}
//-- {AddDecl: 660} region.unprotectedFunction [23028..23204]
CBox3D CBox3D::operator*( const MATRIX3D& matrix ) const
{
//## begin CBox3D::operator *%AFCC35D5FEED.body preserve=yes
CPoint3D p0(x0,y0,z0);
CPoint3D p1(x1,y1,z1);
p0 *= matrix;
p1 *= matrix;
return CBox3D(p0,p1);
//## end CBox3D::operator *%AFCC35D5FEED.body
}
//-- {AddDecl: 661} region.unprotectedFunction [23205..23290]
void CBox3D::operator*=(const MATRIX3D& matrix )
{
//## begin CBox3D::operator *=%19811391FEED.body preserve=yes
(*this) = (*this)*matrix;
//## end CBox3D::operator *=%19811391FEED.body
}
//-- {AddDecl: 662} region.unprotectedFunction [23291..23479]
CBox3D CBox3D::operator*( double sc ) const
{
//## begin CBox3D::operator *%D1F87D62FEED.body preserve=yes
CBox3D box;
box.x0 = x0*sc;
box.y0 = y0*sc;
box.z0 = z0*sc;
box.x1 = x1*sc;
box.y1 = y1*sc;
box.z1 = z1*sc;
return box;
//## end CBox3D::operator *%D1F87D62FEED.body
}
//-- {AddDecl: 663} region.unprotectedFunction [23480..23564]
void CBox3D::operator+=(BOX3D b)
{
//## begin CBox3D::operator +=%CC6DDCD7FEED.body preserve=yes
CBox3D box = (*this)+b;
(*this) = box;
//## end CBox3D::operator +=%CC6DDCD7FEED.body
}
//-- {AddDecl: 664} region.unprotectedFunction [23565..24052]
//// get the intersect box of this and box b.
CBox3D CBox3D::operator&(BOX3D b) const
{
//## begin CBox3D::operator &%A04E4D0FFEED.body preserve=yes
CBox3D box;
if( ((CBox3D)b).IsEmpty( ) || ((CBox3D *)this)->IsEmpty( ) ) return box;
double xx0,yy0,zz0,xx1,yy1,zz1;
xx0 = (x0>b.x0)?x0:b.x0;
yy0 = (y0>b.y0)?y0:b.y0;
zz0 = (z0>b.z0)?z0:b.z0;
xx1 = (x1<b.x1)?x1:b.x1;
yy1 = (y1<b.y1)?y1:b.y1;
zz1 = (z1<b.z1)?z1:b.z1;
if((xx1>xx0) && (yy1>yy0) && (zz1>zz0)){
box = CBox3D(xx0,yy0,zz0,xx1,yy1,zz1);
}
return box;
//## end CBox3D::operator &%A04E4D0FFEED.body
}
//-- {AddDecl: 665} region.unprotectedFunction [24053..24135]
void CBox3D::operator&=(BOX3D b)
{
//## begin CBox3D::operator &=%42CDB177FEED.body preserve=yes
CBox3D box = (*this)&b;
*this = box;
//## end CBox3D::operator &=%42CDB177FEED.body
}
//-- {AddDecl: 666} region.unprotectedFunction [24136..24360]
BOOL CBox3D::operator<<(BOX3D b) const
{
//## begin CBox3D::operator <<%8560E689FEED.body preserve=yes
if( IsEmpty( ) ) return TRUE;
if( (x0 >= b.x0) && (y0 >= b.y0) && (z0 >= b.z0) &&
(x1 <= b.x1) && (y1 <= b.y1) && (z1 <= b.z1) ) return TRUE;
else
return FALSE;
//## end CBox3D::operator <<%8560E689FEED.body
}
//-- {AddDecl: 667} region.unprotectedFunction [24361..24596]
BOOL CBox3D::operator>>(BOX3D b) const
{
//## begin CBox3D::operator >>%3A8508D7FEED.body preserve=yes
if( ((CBox3D)b).IsEmpty( ) ) return TRUE;
if( (x0 >= b.x0) && (y0 >= b.y0) && (z0 >= b.z0) &&
(x1 <= b.x1) && (y1 <= b.y1) && (z1 <= b.z1) ) return FALSE;
else
return TRUE;
//## end CBox3D::operator >>%3A8508D7FEED.body
}
//-- {AddDecl: 668} region.unprotectedFunction [24597..24782]
BOOL CBox3D::operator>>(POINT3D p) const
{
//## begin CBox3D::operator >>%494F3159FEED.body preserve=yes
if( (x0 <= p.x) && (y0 <= p.y) && (z0 <= p.z) &&
(x1 >= p.x) && (y1 >= p.y) && (z1 >= p.z) ) return TRUE;
else
return FALSE;
//## end CBox3D::operator >>%494F3159FEED.body
}
//-- {AddDecl: 669} region.unprotectedFunction [24783..25336]
//// get the intersect box of this and box b.
CBox3D CBox3D::operator|(BOX3D b) const
{
//## begin CBox3D::operator |%F2782F63FEED.body preserve=yes
CBox3D box;
if( ((CBox3D *)this)->IsEmpty( ) ) {
box = b;
return box;
}
if( ((CBox3D)b).IsEmpty( ) ) {
box = *this;
return box;
}
double xx0,yy0,zz0,xx1,yy1,zz1;
xx0 = (x0<b.x0)?x0:b.x0;
yy0 = (y0<b.y0)?y0:b.y0;
zz0 = (z0<b.z0)?z0:b.z0;
xx1 = (x1>b.x1)?x1:b.x1;
yy1 = (y1>b.y1)?y1:b.y1;
zz1 = (z1>b.z1)?z1:b.z1;
if((xx1>=xx0) && (yy1>=yy0) && (zz1>=zz0)){
box = CBox3D(xx0,yy0,zz0,xx1,yy1,zz1);
}
return box;
//## end CBox3D::operator |%F2782F63FEED.body
}
//-- {AddDecl: 670} region.unprotectedFunction [25337..25419]
void CBox3D::operator|=(BOX3D b)
{
//## begin CBox3D::operator |=%3E6AE976FEED.body preserve=yes
CBox3D box = (*this)|b;
*this = box;
//## end CBox3D::operator |=%3E6AE976FEED.body
}
//-- {AddDecl: 671} region.unprotectedFunction [25420..25550]
// get attribs
BOOL CBox3D::IsEmpty() const
{
//## begin CBox3D::IsEmpty%2065BB09FEED.body preserve=yes
return IS_ZERO(Width()) &&
IS_ZERO(Height()) &&
IS_ZERO(Length());
//## end CBox3D::IsEmpty%2065BB09FEED.body
}
//-- {AddDecl: 672} region.unprotectedFunction [25551..25629]
double CBox3D::Width() const // Length of X direction
{
//## begin CBox3D::Width%215E7E76FEED.body preserve=yes
return x1-x0;
//## end CBox3D::Width%215E7E76FEED.body
}
//-- {AddDecl: 673} region.unprotectedFunction [25630..25709]
double CBox3D::Height() const // Length of Z direction
{
//## begin CBox3D::Height%E52BB6DCFEED.body preserve=yes
return z1-z0;
//## end CBox3D::Height%E52BB6DCFEED.body
}
//-- {AddDecl: 674} region.unprotectedFunction [25710..25787]
double CBox3D::Length() const // Length of Z direction
{
//## begin CBox3D::Length%A2D59B91FEED.body preserve=yes
return y1-y0;
//## end CBox3D::Length%A2D59B91FEED.body
}
//-- {AddDecl: 675} region.unprotectedFunction [25788..26043]
// relationship culation
// there may be four cases:
// <enumSeparated,enumIntersected>
UINT CBox3D::GetRelationWith(BOX3D b) const
{
//## begin CBox3D::GetRelationWith%7ABCE344FEED.body preserve=yes
CBox3D box;
box = (*this)&b;
if(box.IsEmpty())
return enumSeparated;
else
return enumIntersected;
//## end CBox3D::GetRelationWith%7ABCE344FEED.body
}
//-- {AddDecl: 676} region.unprotectedFunction [26044..26313]
void CBox3D::normalize()
{
//## begin CBox3D::normalize%F6CDF019FEED.body preserve=yes
double xx0,yy0,xx1,yy1,zz0,zz1;
xx0 = (x0<x1)?x0:x1;
xx1 = (x0>x1)?x0:x1;
yy0 = (y0<y1)?y0:y1;
yy1 = (y0>y1)?y0:y1;
zz0 = (z0<z1)?z0:z1;
zz1 = (z0>z1)?z0:z1;
x0 = xx0; y0 = yy0; x1 = xx1; y1 = yy1;
z0 = zz0; z1 = zz1;
//## end CBox3D::normalize%F6CDF019FEED.body
}
//-- {AddDecl: 677} region.unprotectedFunction [26314..26539]
CBox3D CBox3D::operator+(VECTOR3D vect) const
{
//## begin CBox3D::operator +%FCFB6AD0FEED.body preserve=yes
CBox3D box;
box.x0 = x0+vect.dx;
box.y0 = y0+vect.dy;
box.z0 = z0+vect.dz;
box.x1 = x1+vect.dx;
box.y1 = y1+vect.dy;
box.z1 = z1+vect.dz;
return box;
//## end CBox3D::operator +%FCFB6AD0FEED.body
}
//-- {AddDecl: 678} region.unprotectedFunction [26540..26702]
void CBox3D::operator+=(VECTOR3D vect)
{
//## begin CBox3D::operator +=%9A3FF30FFEED.body preserve=yes
x0 = x0+vect.dx;
y0 = y0+vect.dy;
z0 = z0+vect.dz;
x1 = x1+vect.dx;
y1 = y1+vect.dy;
z1 = z1+vect.dz;
//## end CBox3D::operator +=%9A3FF30FFEED.body
}
//-- {AddDecl: 679} region.unprotectedFunction [26703..26928]
CBox3D CBox3D::operator-(VECTOR3D vect) const
{
//## begin CBox3D::operator -%14ED98A9FEED.body preserve=yes
CBox3D box;
box.x0 = x0-vect.dx;
box.y0 = y0-vect.dy;
box.z0 = z0-vect.dz;
box.x1 = x1-vect.dx;
box.y1 = y1-vect.dy;
box.z1 = z1-vect.dz;
return box;
//## end CBox3D::operator -%14ED98A9FEED.body
}
//-- {AddDecl: 680} region.unprotectedFunction [26929..27090]
void CBox3D::operator-=(VECTOR3D vect)
{
//## begin CBox3D::operator -=%4DE2C5BAFEED.body preserve=yes
x0 = x0-vect.dx;
y0 = y0-vect.dy;
z0 = z0-vect.dz;
x1 = x1-vect.dx;
y1 = y1-vect.dy;
z1 = z1-vect.dz;
//## end CBox3D::operator -=%4DE2C5BAFEED.body
}
//-- {AddDecl: 681} region.unprotectedFunction [27091..27118]
CRect2D::CRect2D()
{
left = -1;
right = -1;
top = -1;
bottom = -1;
//## begin CRect2D::CRect2D%5A0707BAFEED.body preserve=yes
//## end CRect2D::CRect2D%5A0707BAFEED.body
}
//-- {AddDecl: 682} region.unprotectedFunction [27119..27145]
CRect2D::~CRect2D()
{
//## begin CRect2D::~CRect2D%515A0E40FEED.body preserve=yes
//## end CRect2D::~CRect2D%515A0E40FEED.body
}
//-- {AddDecl: 683} region.unprotectedFunction [27146..27232]
double CRect2D::GetWidth()
{
//## begin CRect2D::GetWidth%78EC7FCFFEED.body preserve=yes
ASSERT(right >= left);
return right - left;
//## end CRect2D::GetWidth%78EC7FCFFEED.body
}
//-- {AddDecl: 684} region.unprotectedFunction [27233..27319]
double CRect2D::GetHeight()
{
//## begin CRect2D::GetHeight%30C17643FEED.body preserve=yes
ASSERT( top >= bottom );
return top - bottom;
//## end CRect2D::GetHeight%30C17643FEED.body
}
//-- {AddDecl: 685} region.unprotectedFunction [27320..27408]
CPoint2D CRect2D::GetConter()
{
//## begin CRect2D::GetConter%1F45B576FEED.body preserve=yes
return CPoint2D((right+left)/2,(bottom+top)/2);
//## end CRect2D::GetConter%1F45B576FEED.body
}
//-- {AddDecl: 686} region.unprotectedFunction [27409..27487]
CVector2D CMatrix2D::GetOffset()
{
//## begin CMatrix2D::GetOffset%A7D567DFFEED.body preserve=yes
return CVector2D(A[2][0],A[2][1]);
//## end CMatrix2D::GetOffset%A7D567DFFEED.body
}
//-- {AddDecl: 687} region.unprotectedFunction [27488..27555]
void CMatrix2D::IdenticalOffset()
{
//## begin CMatrix2D::IdenticalOffset%F1023E6AFEED.body preserve=yes
A[2][0] = A[2][1] = 0;
//## end CMatrix2D::IdenticalOffset%F1023E6AFEED.body
}
//-- {AddDecl: 688} region.unprotectedFunction [27556..27672]
CRect2D::CRect2D(double l, double b, double r, double t)
{
//## begin CRect2D::CRect2D%4ED1E1F4FEED.body preserve=yes
left = l;
right = r;
top = t ;
bottom = b;
//## end CRect2D::CRect2D%4ED1E1F4FEED.body
}
//-- {AddDecl: 689} region.unprotectedFunction [27673..27785]
CPoint2D CPoint2D::operator /(const MATRIX2D &matrix)
{
//## begin CPoint2D::operator /%9AE2A6CEFEED.body preserve=yes
CMatrix2D ma(matrix);
return (*this) * (~ma);
//## end CPoint2D::operator /%9AE2A6CEFEED.body
}
//-- {AddDecl: 690} region.unprotectedFunction [27786..28093]
CRect2D::CRect2D(CPoint2D p1, CPoint2D p2)
{
//## begin CRect2D::CRect2D%13514B87FEED.body preserve=yes
double l,b,r,t;
if(p1.x >p2.x)
{
l = p2.x;
r = p1.x;
}
else
{
l = p1.x;
r = p2.x;
}
if(p1.y >p2.y)
{
t = p1.y;
b = p2.y;
}
else
{
t = p2.y;
b = p1.y;
}
left = l;
right = r;
top = t ;
bottom = b;
//## end CRect2D::CRect2D%13514B87FEED.body
}
//-- {AddDecl: 691} region.unprotectedFunction [28094..28311]
void CRect2D::Scale(double scale)
{
//## begin CRect2D::Scale%E3E54969FEED.body preserve=yes
double offsetx = GetWidth()* (1-scale) * 0.5;
double offsety = GetHeight()* (1-scale) * 0.5;
left += offsetx;
right -= offsetx;
top -= offsety;
bottom += offsety;
//## end CRect2D::Scale%E3E54969FEED.body
}
//-- {InsertRegion: 697} module.vulnerableDeclarations [28312..28316]
CRect2D CRect2D::operator + (CRect2D rect) const
{
double l , r , t , b ;
if ( left < 0 )
{
return rect;
}
l = left < rect.left ? left : rect.left;
r = right > rect.right ? right : rect.right;
t = top > rect.top ? top : rect.top;
b = bottom < rect.bottom ? bottom : rect.bottom;
return CRect2D( l , b , r , t );
}
void CRect2D::operator+=(CRect2D rect)
{
if ( left < 0 )
{
left = rect.left;
right = rect.right;
top = rect.top;
bottom = rect.bottom;
return ;
}
left = left < rect.left ? left : rect.left;
right = right > rect.right ? right : rect.right;
top = top > rect.top ? top : rect.top;
bottom = bottom < rect.bottom ? bottom : rect.bottom;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -