"Fossies" - the Fresh Open Source Software Archive

Member "mathmod-branches-r508-trunk/pariso/commun.h" (8 Mar 2021, 8750 Bytes) of package /linux/misc/mathmod-11.0-source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "commun.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 10.1_vs_11.0.

    1 /***************************************************************************
    2  *   Copyright (C) 2021 by Abderrahman Taha                                *
    3  *                                                                         *
    4  *                                                                         *
    5  *   This program is free software; you can redistribute it and/or modify  *
    6  *   it under the terms of the GNU General Public License as published by  *
    7  *   the Free Software Foundation; either version 2 of the License, or     *
    8  *   (at your option) any later version.                                   *
    9  *                                                                         *
   10  *   This program is distributed in the hope that it will be useful,       *
   11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   13  *   GNU General Public License for more details.                          *
   14  *                                                                         *
   15  *   You should have received a copy of the GNU General Public License     *
   16  *   along with this program; if not, write to the                         *
   17  *   Free Software Foundation, Inc.,                                       *
   18  *   51 Franklin Street, Fifth Floor,Boston, MA 02110-1301 USA             *
   19  ***************************************************************************/
   20 #include "../fparser/fparser.hh"
   21 #include <qthread.h>
   22 
   23 #define PI (double(314159265) / double(100000000))
   24 #define MAGIC_SCALE 1.5707963f
   25 extern template class FunctionParserBase<double>; // explicit instantiation
   26 // declaration
   27 
   28 struct GlobalParam
   29 {
   30     uint TypeDrawin = 10;
   31     uint TypeDrawinNormStep = 4;
   32     uint PreviousSizeMinimalTopology = 0;
   33     uint NbPolyMinimalTopology = 0;
   34     uint NbVertexTmp = 0;
   35 };
   36 
   37 struct ImplicitStructure
   38 {
   39     std::string fxyz;
   40     std::string xmin;
   41     std::string xmax;
   42     std::string ymin;
   43     std::string ymax;
   44     std::string zmin;
   45     std::string zmax;
   46     std::string grid;
   47     std::string cnd;
   48 };
   49 
   50 extern uint OrignbX, OrignbY, OrignbZ;
   51 extern uint Stack_Factor;
   52 
   53 struct Voxel
   54 {
   55     uint Edge_Points[12]; // reference to the Edge Points
   56     uint Signature;       // From 0 to 255
   57     uint NbEdgePoint;
   58 };
   59 
   60 struct NoiseParemeters
   61 {
   62     int Octaves=4;
   63     float Lacunarity=0.5f;
   64     float Gain=0.5f;
   65     int NoiseType=1; // 0 :Texture ; 1 : Pigments
   66     FunctionParser *RgbtParser;
   67     FunctionParser *VRgbtParser, *GradientParser, *NoiseParser;
   68     uint Nb_vrgbts;
   69     int NoiseShape;
   70     int NoiseActive;
   71 };
   72 
   73 struct ErrorMessage
   74 {
   75     int iErrorIndex;
   76     std::string strError;
   77 };
   78 
   79 // Any modification to this enum must be translated to the same enum in
   80 // fparser.hh
   81 enum EvalErrorType
   82 {
   83     EVAL_ERROR = 0,
   84     DIVISION_BY_ZERO,
   85     COTAN_FUNCT_ERROR,
   86     EXP_FUNCT_ERROR,
   87     ARC_TRIGONOMETRIC_FUNCT_ERROR,
   88     IF_FUNCT_ERROR,
   89     EVAL_NO_ERROR,
   90     VAR_OVERFLOW
   91 };
   92 
   93 enum ScriptErrorType
   94 {
   95     SCRIPT_NO_ERROR = 0,
   96     MAXGRID_OUT_OF_RANGE,
   97     MAXPT_OUT_OF_RANGE,
   98     MAXTRI_OUT_OF_RANGE,
   99     FXYZ_OUT_OF_RANGE,
  100     FX_OUT_OF_RANGE,
  101     XMAX_NBCOMPONENT_MISMATCH,
  102     YMAX_NBCOMPONENT_MISMATCH,
  103     ZMAX_NBCOMPONENT_MISMATCH,
  104     XMIN_NBCOMPONENT_MISMATCH,
  105     YMIN_NBCOMPONENT_MISMATCH,
  106     ZMIN_NBCOMPONENT_MISMATCH,
  107     FY_FX_MISMATCH,
  108     FZ_FX_MISMATCH,
  109     FW_FX_MISMATCH,
  110     UMAX_NBCOMPONENT_MISMATCH,
  111     VMAX_NBCOMPONENT_MISMATCH,
  112     WMAX_NBCOMPONENT_MISMATCH,
  113     UMIN_NBCOMPONENT_MISMATCH,
  114     VMIN_NBCOMPONENT_MISMATCH,
  115     WMIN_NBCOMPONENT_MISMATCH,
  116     GRID_NBCOMPONENT_MISMATCH,
  117     COMPONENT_NBCOMPONENT_MISMATCH,
  118     CND_NBCOMPONENT_MISMATCH,
  119     NBSLIDERS_OUT_OF_RANGE,
  120     NBSLIDERSVALUES_OUT_OF_RANGE,
  121     VERTEX_TAB_MEM_OVERFLOW,
  122     TRIANGLES_TAB_MEM_OVERFLOW,
  123     MINPOLY_TAB_MEM_OVERFLOW,
  124     POLY_TAB_MEM_OVERFLOW,
  125     CND_TAB_MEM_OVERFLOW,
  126     CND_POL_MEM_OVERFLOW,
  127     DEFINED_PARAM_GRID_VERTEX_TAB_OVERFLOW,
  128     DEFINED_PARAM_GRID_TRIANGLE_TAB_OVERFLOW,
  129     GRID_SUPERIOR_TO_GRIDMAX,
  130     VECT_DIMENSION_ERROR,
  131     MEM_OVERFLOW,
  132     EMPTY_MANDATORY_FIELD
  133 };
  134 struct ComponentInfos
  135 {
  136     std::vector<uint> ParisoTriangle;
  137     std::vector<uint> ParisoVertex;
  138     std::vector<uint> NbComponentsType;
  139 
  140     std::vector<bool> ThereisCND;
  141     std::vector<bool> ThereisRGBA;
  142     std::vector<bool> ParisoCondition;
  143     std::vector<bool> ShowParIsoCmp;
  144     uint ParisoNbComponents = 1;
  145     uint ParisoCurrentComponentIndex = 0;
  146 
  147     std::vector<uint> NbTrianglesVerifyCND;
  148     std::vector<uint> NbTrianglesNoCND;
  149     std::vector<uint> NbTrianglesNotVerifyCND;
  150     std::vector<uint> NbTrianglesBorderCND;
  151 
  152     NoiseParemeters NoiseParam[2];
  153     bool Interleave = false;
  154     bool pariso = false;
  155     bool updateviewer = false;
  156 };
  157 
  158 struct ObjectProperties
  159 {
  160     float *ArrayNorVer_localPt;
  161     uint *PolyIndices_localPt;
  162     uint *PolyIndices_localPtMin;
  163     int *TypeSurfaceTriangleListeCND;
  164     uint NbPolygnNbVertexPtMin = 0;
  165     uint NbPolygnNbVertexPtMinSize = 0;
  166     uint PolyNumber = 0;
  167     uint VertxNumber = 0;
  168     uint NbBorderpoints;
  169     struct ComponentInfos componentsinfos;
  170     int IndexCurrentFormula = -1;
  171     bool ShininessValUpdated=true;
  172     bool AmbientValUpdated=true;
  173     bool DiffuseValUpdated=true;
  174     int border = 1;
  175     int anim = -1;
  176     int animxyz = 1;
  177     int animx = -1;
  178     int animy = -1;
  179     int animz = -1;
  180     float animxValue = 0.0;
  181     float animyValue = 0.0;
  182     float animzValue = 0.0;
  183     float animxValueStep = 0.0;
  184     float animyValueStep = 0.0;
  185     float animzValueStep = 0.0;
  186     int slider = -1;
  187     int morph = -1;
  188     int morphstep = -1;
  189     int typedrawing = 1;
  190     int mesh = 1;
  191     int fill = 1;
  192     int transparency = -1;
  193     int boundingbox = -1;
  194     bool activarecnd = true;
  195     bool updategl = true;
  196     int triangles = -1;
  197     int infos = -1;
  198     int frame = -1;
  199     int infosdetails[3]={1, 1, 1};
  200     int line = 1;
  201     int norm = -1;
  202     int plan = 1;
  203     int axe = 1;
  204     int attachwininfos = 1;
  205     int png_ok =  1;
  206     int jpg_ok = -1;
  207     int bmp_ok = -1;
  208     int quality_image = 50;
  209     int colortype = 0;
  210     int colortypeParam = 0;
  211     float specReflection[4]={0.2f, 0.2f, 0.2f, 1.0f};
  212     int threads[3];
  213     int shininess = 110;
  214     float frontcol[4]={0.9f, 0.5f, 0.1f, 1.0f};
  215     float backcol[4] ={0.2f, 0.8f, 0.1f, 1.0f};
  216     float frontcols[40]={0.72f, 0.5f, 0.1f, 1.0f, 0.3f, 0.8f, 0.5f, 1.0f, 0.2f, 0.5f, 0.6f, 1.0f, 0.1f, 0.3f, 0.9f, 1.0f, 0.96f, 0.71f, 0.3f, 1.0f,
  217                           0.4f, 0.4f, 0.9f, 1.0f, 0.99f, 0.1f, 0.843f, 1.0f, 0.16f, 0.91f, 0.73f, 1.0f, 0.8f, 0.9f, 0.0f, 1.0f, 0.9f, 0.91f, 0.3f, 1.0f};
  218     float backcols[40]={0.4f, 0.6f, 0.1f, 1.0f, 0.6f, 0.6f, 0.9f, 1.0f, 0.8f, 0.6f, 0.3f, 1.0f, 0.9f, 0.8f, 0.6f, 1.0f, 0.93f, 0.2f, 0.1f, 1.0f,
  219                         0.3f, 0.72f, 0.63f, 1.0f, 0.1f, 0.5f, 0.73f, 1.0f, 0.9f, 0.5f, 0.3f, 1.0f, 0.8f, 0.8f, 0.6f, 1.0f, 0.7f, 0.9f, 0.93f, 1.0f};
  220     float gridcol[4]  ={0.25f, 0.2f, 0.0f, 0.08f};
  221     float groundcol[4]={0.0f, 0.0f, 0.0f, 1.0f};
  222     float polyfactor= 1.0;
  223     float polyunits= 1.0;
  224     float RotStrength=0;
  225     float oldRotx, oldRoty;
  226     float zminim= -350.0f;
  227     float BoxLimits[3][6];
  228     int viewport[4];
  229     double matrix[16];
  230     double matrixInverse[16];
  231     double ScalCoeff = 1.0;
  232     double axe_x, axe_y, axe_z;
  233     double view_rotx = 90.0, view_roty = 90.0, view_rotz = 1.0;
  234     bool cndoptions[5] = {true, true, true, false, false};
  235     uint vboId_ArrayNorVer_localPt;
  236     uint vboId_PolyIndices_localPt;
  237 };
  238 
  239 class CellNoise
  240 {
  241 public:
  242     float rd[3], featurePoint[4];
  243     const static uint OFFSET_BASIS = 2166136261U;
  244     const static uint FNV_PRIME = 16777619U;
  245 
  246     float CellNoiseFunc(float, float, float, int, int type = 2, int Dist = 0);
  247     float EuclidianDistanceFunc(float, float, float, float, float, float);
  248     float ManhattanDistanceFunc(float, float, float, float, float, float);
  249     float ChebyshevDistanceFunc(float, float, float, float, float, float);
  250     int probLookup(uint);
  251     void insert(float *, float);
  252     int lcgRandom(int);
  253     int hash(int, int, int);
  254 };
  255 
  256 class ImprovedNoise
  257 {
  258 public:
  259     int passes;
  260     float correction;
  261     ImprovedNoise(float, float, float);
  262     float noise(float, float, float);
  263     float fade(float);
  264     float lerp(float, float, float);
  265     float grad(int, float, float, float);
  266     float FractalNoise3D(float, float, float, int, float, float);
  267     float Marble(float, float, float, int);
  268     float lookup(float, float, float);
  269 };
  270 
  271 extern std::vector<float> NormVertexTabVector;
  272 extern std::vector<uint> IndexPolyTabMinVector;
  273 extern std::vector<uint> IndexPolyTabMinVector2;
  274 extern std::vector<uint> IndexPolyTabVector;
  275 static struct ComponentInfos *components = new (struct ComponentInfos);