63 int CSG_Grid_System::m_Precision = 16;
70 m_Precision = Decimals;
73 return( m_Precision );
79 return( m_Precision );
108 Create(Cellsize, xMin, yMin, xMax, yMax);
114 Create(Cellsize, xMin, yMin, NX, NY);
133 m_NCells = System.m_NCells;
135 m_Cellsize = System.m_Cellsize;
136 m_Cellarea = System.m_Cellarea;
137 m_Diagonal = System.m_Diagonal;
139 m_Extent = System.m_Extent;
140 m_Extent_Cells = System.m_Extent_Cells;
150 int nx = 1 + (int)(0.5 + Extent.
Get_XRange() / Cellsize);
151 int ny = 1 + (int)(0.5 + Extent.
Get_YRange() / Cellsize);
156 return(
Create(Cellsize, x, y, nx, ny) );
173 if( Cellsize > 0. && NX > 0 && NY > 0 )
183 m_NCells = (
sLong)NY * NX;
185 m_Cellsize = Cellsize;
186 m_Cellarea = Cellsize * Cellsize;
187 m_Diagonal = Cellsize * sqrt(2.);
189 m_Extent.
xMin = xMin;
190 m_Extent.
yMin = yMin;
191 m_Extent.
xMax = xMin + (NX - 1.) * Cellsize;
192 m_Extent.
yMax = yMin + (NY - 1.) * Cellsize;
194 m_Extent_Cells = m_Extent;
195 m_Extent_Cells.
Inflate(0.5 * Cellsize,
false);
210 m_Extent .
Assign(0., 0., 0., 0.);
211 m_Extent_Cells .
Assign(0., 0., 0., 0.);
226 {
return(
Create(System) ); }
229 {
return(
Create(Cellsize, Extent) ); }
232 {
return(
Create(Cellsize, xMin, yMin, xMax, yMax) ); }
235 {
return(
Create(Cellsize, xMin, yMin, NX, NY) ); }
245 return( m_Cellsize > 0. );
255 m_Name.
Printf(
"%.*f; %dx %dy; %.*fx %.*fy",
264 m_Name.
Printf(
"%s: %f, %s: %dx/%dy, %s: %fx/%fy",
273 m_Name =
_TL(
"<not set>");
304 return( m_Cellsize == System.m_Cellsize
305 && m_NX == System.m_NX
306 && m_NY == System.m_NY
307 && m_Extent.
xMin == System.m_Extent.
xMin
308 && m_Extent.
yMin == System.m_Extent.
yMin
315 return( m_Cellsize == Cellsize && m_Extent == Extent );
377 Parameters.
Add_Choice(Parent,
"KERNEL_TYPE",
_TL(
"Kernel Type"),
378 _TL(
"The kernel's shape."),
391 Parameters.
Add_Double(
"KERNEL_TYPE",
"KERNEL_INNER" ,
_TL(
"Inner Radius"), Unit_Radius, 0., 0.,
true);
394 Parameters .
Add_Double(
"KERNEL_TYPE",
"KERNEL_RADIUS",
_TL(
"Radius"), Unit_Radius, 1., 0.,
true);
400 Parameters.
Add_Int (
"KERNEL_TYPE",
"KERNEL_INNER" ,
_TL(
"Inner Radius"), Unit_Radius, 0 , 0 ,
true);
403 Parameters .
Add_Int (
"KERNEL_TYPE",
"KERNEL_RADIUS",
_TL(
"Radius"), Unit_Radius, 2 , 0 ,
true);
409 Parameters.
Add_Double(
"KERNEL_TYPE",
"KERNEL_DIRECTION",
_TL(
"Direction"),
_TL(
"degree"), 0., -360.,
true, 360.,
true);
410 Parameters.
Add_Double(
"KERNEL_TYPE",
"KERNEL_TOLERANCE",
_TL(
"Tolerance"),
_TL(
"degree"), 5., 0.,
true, 180.,
true);
416 Parameters(
"KERNEL_TYPE")->is_Enabled() ?
CSG_String(
"KERNEL_TYPE") : Parent
426 if( Type == 0 && Parameters(
"KERNEL_TYPE") )
428 Parameters(
"KERNEL_TYPE")->asChoice()->Get_Data(Type);
435 Parameters(
"KERNEL_RADIUS" )->
asDouble(),
441 Parameters(
"KERNEL_RADIUS" )->
asDouble(),
447 Parameters(
"KERNEL_INNER" )->
asDouble(),
448 Parameters(
"KERNEL_RADIUS" )->
asDouble()
453 Parameters(
"KERNEL_RADIUS" )->
asDouble(),
476 if( Parameters(
"KERNEL_TYPE") )
478 int Type = Parameters(
"KERNEL_TYPE")->asChoice()->Get_Item_Data(Parameters(
"KERNEL_TYPE")->
asInt()).asInt();
496 bool CSG_Grid_Cell_Addressor::_Set_Kernel(
int Type,
double Radius,
double Radius_Inner,
double Direction,
double Tolerance)
502 m_Radius_0 = Radius_Inner;
503 m_Direction = fmod(Direction,
M_PI_360);
if( Direction < 0. ) Direction +=
M_PI_360;
504 m_Tolerance = fmod(Tolerance,
M_PI_180);
if( Tolerance < 0. ) Tolerance +=
M_PI_180;
506 if( m_Radius < 0. || m_Radius < m_Radius_0 )
515 Sector[0] = fmod(Direction - Tolerance,
M_PI_360);
if( Sector[0] < 0. ) Sector[0] +=
M_PI_360;
516 Sector[1] = fmod(Direction + Tolerance,
M_PI_360);
if( Sector[1] < 0. ) Sector[1] +=
M_PI_360;
520 #define ADD_CELL(x, y, Distance) {\
521 CSG_Table_Record &Cell = *Kernel.Add_Record();\
522 Cell.Set_Value(0, x);\
523 Cell.Set_Value(1, y);\
524 Cell.Set_Value(2, Distance);\
525 Cell.Set_Value(3, m_Weighting.Get_Weight(d));\
530 int Size = (int)ceil(m_Radius);
533 for(
int y=-Size; y<=Size; y++)
535 if( abs(y) > m_Radius )
538 for(
int x=-Size; x<=Size; x++)
540 if( abs(x) > m_Radius )
559 if( d <= m_Radius && d >= m_Radius_0 )
576 if( Kernel.Get_Count() < 1 )
583 for(
int i=0; i<Kernel.Get_Count(); i++)
585 m_Kernel.
Add_Record(Kernel.Get_Record_byIndex(i));
600 return( _Set_Kernel(0, Radius, 0., 0., 0.) );
606 return( _Set_Kernel(1, Radius, 0., 0., 0.) );
612 return( _Set_Kernel(2, Radius_Outer, Radius_Inner, 0., 0.) );
618 return( _Set_Kernel(3, Radius, 0., Direction, Tolerance) );