You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.5 KiB
C

1 month ago
//////////////////////////////////////////////////////////////////////////////
//<2F>ļ<EFBFBD>: SegY<67>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>:
//
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д: 2011-4-21
//
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "rowcol.h"
#include "TInterval.h"
namespace NCube
{
//<2F>ߵ<EFBFBD><DFB5>ŷ<EFBFBD>Χ<EFBFBD><EFBFBD>û<EFBFBD><C3BB>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5>Ų<EFBFBD><C5B2><EFBFBD>
//<2F><><EFBFBD><EFBFBD>2D<32><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>ʱ<EFBFBD><CAB1><EFBFBD>ߺŽ<DFBA><C5BD><EFBFBD><EFBFBD><EFBFBD>
class AFX_EXT_CLASS CRowColRange
{
public:
CRowColRange(void);
~CRowColRange(void);
TIntervalStep<int> getInlRange();
TIntervalStep<int> getCrlRange();
void setInlRange(const TIntervalStep<int>& inl);
void setCrlRange(const TIntervalStep<int>& crl);
void getRange(TIntervalStep<int>& inl, TIntervalStep<int>& crl) const;
int getInlWidth() { return (stop.row-start.row)/step.row + 1; }
int getCrlWidth() { return (stop.col-start.col)/step.col + 1; }
int atInlIndex( int idx ) { return start.row + step.row * idx; }
int atCrlIndex( int idx ) { return start.col + step.col * idx; }
int nearestInlIndex( const double& t ) const;
int nearestCrlIndex( const double& t ) const;
int snapInl( const double& t );
int snapCrl( const double& t );
void Normalise(); //!< Makes sure start<stop and steps are non-zero
bool Next(CRowCol& rc, bool bFirstPos=false); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD>
//!< Returns false if intersection is empty
bool getIntersection(const CRowColRange& in_range, CRowColRange& out_range);
bool operator==( const CRowColRange& hs ) const;
bool operator!=( const CRowColRange& hs ) const { return !(hs==*this); }
inline bool IsIncludes( const CRowCol& rc ) const { return IsInlineOK(rc.row) && IsCrosslineOK(rc.col); }
inline bool IsInlineOK( int inl ) const { return inl >= start.row && inl <= stop.row && !( (inl-start.row) % step.row ); }
inline bool IsCrosslineOK( int crl ) const { return crl >= start.col && crl <= stop.col && !( (crl-start.col) % step.col ); }
inline bool IsInlineOK( float inl ) const
{
if(inl<start.row || inl>stop.row)
return false;
return true;
}
inline bool IsCrosslineOK( float crl ) const
{
if(crl<start.col || crl>stop.col)
return false;
return true;
}
protected:
bool Intersect(
int start1, int stop1, int step1,
int start2, int stop2, int step2,
int& outstart, int& outstop, int& outstep );
public:
CRowCol start;
CRowCol stop;
CRowCol step;
};
//<2F><><EFBFBD><EFBFBD><EFBFBD>Χ
class AFX_EXT_CLASS CCubeRange : public CRowColRange
{
public:
CCubeRange();
~CCubeRange();
void Normalise(); //!< Makes sure start<stop and steps are non-zero
//!< Returns false if intersection is empty
bool getIntersection(const CCubeRange& in_cr, CCubeRange& out_cr);
bool operator==( const CCubeRange& cs ) const;
bool operator!=( const CCubeRange& cs ) const { return !(cs==*this); }
CPoint3D getCenterPoint(bool bSnap);
float atIndexZ( int idx ) { return zRange.atIndex(idx); }
int nearestIndexZ( const double& t ) { return zRange.nearestIndex(t); }
float snapZ( const double& t ) { return zRange.snap(t); }
bool IsZRangeOK( float z ) const;
int getZWidth() { return (int)( (zRange.stop - zRange.start)/zRange.step ) + 1; }
void Write(CFile& fw, const short &ver);
int Read(CFile& fr, const short &ver);
void Serialize(CArchive& ar, const short &ver);
protected:
bool IntersectF(
float start1, float stop1, float step1,
float start2, float stop2, float step2,
float& outstart, float& outstop, float& outstep );
bool inSeries( float v, float start, float step );
public:
TIntervalStep<float> zRange;
};
}//namespace
using namespace NCube;