GeoGen Development snapshot a3

ggen_data_2d.h

00001 /*
00002 
00003     This file is part of GeoGen.
00004 
00005     GeoGen is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     GeoGen is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with GeoGen.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 */
00019 #pragma once
00020 
00021 #include "ggen_support.h"
00022 #include "ggen_path.h"
00023 #include <iostream>
00024 #include <set>
00025 
00026 using namespace std;
00027 
00031 class GGen_Data_2D{
00032           protected:
00033                     static uint16 num_instances;
00034                     static set<GGen_Data_2D*> instances;
00035 
00036           public:
00037                     GGen_Height* data;
00038                     GGen_Size width;
00039                     GGen_Size height;
00040                     GGen_TotalSize length;
00041 
00048                     GGen_Data_2D(GGen_Size width, GGen_Size height, GGen_Height value);
00049                     
00050                     ~GGen_Data_2D();
00051 
00056                     GGen_Data_2D* Clone();
00057 
00062                     GGen_Size GetWidth();
00063                     
00068                     GGen_Size GetHeight();
00069 
00075                     GGen_Index GetLength();
00076 
00081                     GGen_Distance GetMaxDistance();
00082 
00089                     void SetValue(GGen_Coord x, GGen_Coord y, GGen_Height value);
00090                     
00099                     void SetValueInRect(GGen_Coord x1, GGen_Coord y1, GGen_Coord x2, GGen_Coord y2, GGen_Height value);
00100                     
00107                     GGen_Height GetValue(GGen_Coord x, GGen_Coord y);
00108 
00118                     GGen_Height GetValueInterpolated(GGen_Coord x, GGen_Coord y, GGen_Size scale_to_width, GGen_Size scale_to_height);
00119 
00124                     void Add(GGen_Height value);
00125 
00130                     void AddMap(GGen_Data_2D* addend);
00131 
00138                     void AddTo(GGen_Data_2D* addend, GGen_CoordOffset offset_x, GGen_CoordOffset offset_y);
00139                     
00147                     void AddMapMasked(GGen_Data_2D* addend, GGen_Data_2D* mask, bool relative);
00148 
00156                     void AddMasked(GGen_Height value, GGen_Data_2D* mask, bool relative);
00157                     
00162                     void Multiply(double factor);
00163 
00168                     void MultiplyMap(GGen_Data_2D* factor);
00169 
00173                     void Invert();
00174 
00181                     void Scale(double ratio, bool scale_values);
00182 
00190                     void ScaleTo(GGen_Size new_width, GGen_Size new_height, bool scale_values);
00191                     
00197                     void ScaleValuesTo(GGen_Height new_min, GGen_Height new_max);
00198                     
00207                     void ResizeCanvas(GGen_Size new_width, GGen_Size new_height, GGen_CoordOffset new_zero_x, GGen_CoordOffset new_zero_y);
00208                     
00213                     void Fill(GGen_Height value);
00214 
00222                     void FillMasked(GGen_Height value, GGen_Data_2D* mask, bool relative);
00223 
00229                     void Clamp(GGen_Height min, GGen_Height max);
00230 
00236                     void CropValues(GGen_Height min, GGen_Height max);
00237 
00242                     GGen_Height Min();
00243 
00248                     GGen_Height Max();
00249 
00254                     void Intersection(GGen_Data_2D* victim);
00255 
00262                     void IntersectionTo(GGen_Data_2D* victim, GGen_CoordOffset offset_x, GGen_CoordOffset offset_y);
00263 
00268                     void Union(GGen_Data_2D* victim);
00269 
00276                     void UnionTo(GGen_Data_2D* victim, GGen_CoordOffset offset_x, GGen_CoordOffset offset_y);
00277 
00286                     void Combine(GGen_Data_2D* victim, GGen_Data_2D* mask, bool relative);
00287 
00293                     void ReplaceValue(GGen_Height needle, GGen_Height replace);
00294                     
00298                     void Abs();
00299 
00306                     void Shift(GGen_Data_1D* profile, GGen_Direction direction, GGen_Overflow_Mode mode);
00307 
00313                     void Project(GGen_Data_1D* profile, GGen_Direction direction);
00314 
00320                     GGen_Data_1D* GetProfile(GGen_Direction direction, GGen_Coord coordinate);
00321 
00333                     void Gradient(GGen_Coord from_x, GGen_Coord from_y, GGen_Coord to_x, GGen_Coord to_y, GGen_Height from_value, GGen_Height to_value, bool fill_outside);
00334 
00345                     void GradientFromProfile(GGen_Coord from_x, GGen_Coord from_y, GGen_Coord to_x, GGen_Coord to_y, GGen_Data_1D* profile, bool fill_outside);
00346                     
00357                     void RadialGradient(GGen_Coord center_x, GGen_Coord center_y, GGen_Coord radius, GGen_Height from_value, GGen_Height to_value, bool fill_outside);
00358                     
00368                     void RadialGradientFromProfile(GGen_Coord center_x, GGen_Coord center_y, GGen_Distance radius, GGen_Data_1D* profile, bool fill_outside);
00369                     
00376                     void Noise(GGen_Size min_feature_size, GGen_Size max_feature_size, GGen_Amplitudes* amplitudes);
00377 
00386                     void VoronoiNoise(GGen_Size cell_size, uint8 points_per_cell, GGen_Voronoi_Noise_Mode mode);
00387 
00393                     void SmoothDirection(GGen_Distance radius, GGen_Direction direction);
00394                     
00399                     void Smooth(GGen_Distance radius);
00400                     
00405                     void Flood(double land_amount);
00406 
00411                     void Pattern(GGen_Data_2D* pattern);
00412 
00417                     void Monochrome(GGen_Height threshold);
00418 
00423                     void SelectValue(GGen_Height value);
00424                     
00428                     void SlopeMap();
00429 
00435                     void Scatter(bool relative);
00436 
00445                     void TransformValues(GGen_Data_1D* profile, bool relative);
00446                     
00451                     void Normalize(GGen_Normalization_Mode mode);
00452 
00458                     void NormalizeDirection(GGen_Direction direction, GGen_Normalization_Mode mode);
00459                     
00470                     void Transform(double a11, double a12, double a21, double a22, bool preserve_size);
00471 
00477                     void Rotate(int32 angle, bool preserve_size);
00478                     
00486                     void Shear(int32 horizontal_shear, int32 vertical_shear, bool preserve_size);
00487 
00492                     void Flip(GGen_Direction direction);
00493 
00498                     void ReturnAs(const GGen_String& label);
00499 
00506                     void FillPolygon(GGen_Path* path, GGen_Height value);
00507 
00516                     void StrokePath(GGen_Path* path, GGen_Data_1D* brush, GGen_Distance radius, bool fill_outside);
00517 
00518                     void FloodFillBase(GGen_Coord start_x, GGen_Coord start_y, GGen_Height fill_value, GGen_Comparison_Mode mode, GGen_Height threshold, bool select_only);         
00519 
00530                     void FloodFill(GGen_Coord start_x, GGen_Coord start_y, GGen_Height fill_value, GGen_Comparison_Mode mode, GGen_Height threshold);
00531 
00541                     void FloodSelect(GGen_Coord start_x, GGen_Coord start_y, GGen_Comparison_Mode mode, GGen_Height threshold);
00542 
00543                     GGen_Height GetValueOnPathBase(GGen_Path* path, bool max);
00544 
00550                     GGen_Height GetMaxValueOnPath(GGen_Path* path);
00551 
00557                     GGen_Height GetMinValueOnPath(GGen_Path* path);
00558 
00559                     void ExpandShrinkDirectionBase(GGen_Distance distance, GGen_Direction direction, bool shrink);
00560 
00566                     void ExpandDirection(GGen_Distance distance, GGen_Direction direction);
00567 
00573                     void ShrinkDirection(GGen_Distance distance, GGen_Direction direction);
00574 
00579                     void Expand(GGen_Distance distance);
00580 
00585                     void Shrink(GGen_Distance distance);
00586 
00593                     void Outline(GGen_Comparison_Mode mode, GGen_Height threshold, GGen_Outline_Mode outlineMode);
00594 
00599                     void ConvexityMap(GGen_Distance radius);
00600 
00606                     void Distort(GGen_Size waveLength, GGen_Distance amplitude);
00607 
00612                     void NormalMap();
00613 
00619                     void NormalDifferenceMap(int32 angle);
00620 
00621                     void CreateRiver();
00622 
00629                     GGen_Height GetNormal(GGen_Coord x, GGen_Coord y);          
00630 
00631                     static void FreeAllInstances(){
00632                               while(GGen_Data_2D::instances.begin() != GGen_Data_2D::instances.end()){
00633                                         delete (*GGen_Data_2D::instances.begin());
00634                               }
00635                     };
00636 };
00637