ScPovPlot3D/BPatchSurf.inc [ Modules ]

[ Top ] [ Modules ]

AUTHOR

  Janusz Opiła Ph.D.
   jmo@agh.edu.pl, janusz.opila@gmail.com
   Dept. of Applied Informatics
   AGH University of Science & Technology, Cracow, Poland
   Maintained by Janusz Opiła Ph.D.

PURPOSE

New templates for drawing smoothed by Bezier spline surfaces

     
     
     
     
     
     
     

Fig.[BPatchSurf] New, 3D surface modelling system


There is a lot TODO: some automation and so on

COPYRIGHT

  GNU GPL v.3 License
  (c) 2012-now by Janusz Opiła Ph.D.         
  AGH University of Science and Technology

BPatchSurf.inc/DrawAllPatches() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

this helper macro renders all bezier_patch{}'es in single surface its simplicity results from sophisticated data structure. This macro applies default texture to the surface, so one don't need another

SYNOPSIS

365 DrawAllPatches()

INPUTS

  None

SEE ALSO

one should also refer to:

   FunctionSurface(), EvalPatchedSurface(), DrawPatch(), DrawAllPatchesGeo(), 
   DrawAllPatchesWithTexture(), DrawAllPatchesWithMap()


BPatchSurf.inc/DrawAllPatches_UV() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

This macro renders all bezier_patch{}'es in single surface its simplicity results from sophisticated data structure :) The macro applies UV texture to the whole surface.

SYNOPSIS

699 DrawAllPatches_UV(ImageConstants _type, string filename _file)

INPUTS

  ImageConstants _type - indicates format of the bitmap passed to the macro as uv_mapping{}.
  _type = [ _JPG | _BMP | _GIF | _PNG |_TGA | _SYS |_EXR |_HDR |_IFF |_PGM |_PPM |_TIF ]
  string filename - Name of map for the surface
                  - Consult source file for details.

EXAMPLE

706 DrawAllPatches_UV( _PNG, "GriddVividRed.png") // covers surface with copies of "GriddVividRed.png" file

SEE ALSO

one should also refer to:

   FunctionSurface(), EvalPatchedSurface(), DrawPatch(), DrawPatch_UV(), DrawPatch_UV_multi(),
   DrawPatch(), DrawAllPatches(), DrawAllPatchesGeo(), DrawAllPatchesWithTexture()


BPatchSurf.inc/DrawAllPatches_UV_multi() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

this macro renders all bezier_patch{}'es in this surface and applies UV texture to a every single patch by iterative formula

SYNOPSIS

748 DrawAllPatches_UV_multi(ImageConstants _type, string _file, uinteger _max)

INPUTS

  ImageConstants _type    - indicates format of the bitmap passed to the macro as uv_map{}
  _type = [ _JPG | _BMP | _GIF | _PNG |_TGA | _SYS |_EXR |_HDR |_IFF |_PGM |_PPM |_TIF |_TIF ]
  string   _file - constant part of image file name
  uinteger _max     - automatically generated suffix goes from '0' up to '_max-1'. Suffix is then concatenated
                    - with _file and extension defined by _type. Thus final image name is defined.
                    - This image will be used as uv_map for consecutive patches. Calls macro DrawPatch_UV_multi().
                    - _max = 2..100/ parameter of mod(N, _max) operation. Consult source file for details.

EXAMPLE

758 DrawAllPatches_UV_multi(_JPG, "Next", 7)
759 // renders all patches and uses files Next00.jpg through Next06.jpg as maps for consecutive patches

SEE ALSO

one should also refer to:

   FunctionSurface(), EvalPatchedSurface(), DrawPatch(), DrawPatch_UV(), DrawPatch(),
   DrawAllPatches(), DrawAllPatchesGeo(), DrawAllPatchesWithTexture()


BPatchSurf.inc/DrawAllPatches_UVpng() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

This macro renders single bezier_patch{} depicted by given indices. Its simplicity results from sophisticated data structure. This macro applies UV'ed texture to the surface given in _UV_png (PNG format) file.

SYNOPSIS

510 DrawPatch_UVpng(ipy, ipx, _UV_png)

INPUTS

  None

SEE ALSO

one should also refer to:

   FunctionSurface(), EvalPatchedSurface(), DrawPatch(), DrawPatch_UVpng(),
   DrawAllPatches(), DrawAllPatchesGeo(), DrawAllPatchesWithTexture()


BPatchSurf.inc/DrawAllPatchesGeo() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

this macro renders all bezier_patch{}'es in single surface its simplicity results from sophisticated data structure. This macro applies NO texture to the surface, so one MUST aplly it by hand

SYNOPSIS

543 DrawAllPatchesGeo()

INPUTS

  None

SEE ALSO

one should also check:

   FunctionSurface(), EvalPatchedSurface(), DrawPatch(), DrawAllPatches(), 
   DrawAllPatchesWithTexture(), DrawPatch_UVpng


BPatchSurf.inc/DrawAllPatchesWithMap() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

this macro renders all bezier_patch{}'es in single surface its simplicity results from sophisticated data structure. This macro applies default texture to the surface, so one don't need another

SYNOPSIS

435 DrawAllPatchesWithMap(colormapdef _ThisMap)

INPUTS

  colormapdef _ThisMap - any valid color_map{} definition, uses passed color_map{} object,
                         one from ColorMaps.inc or another self defined

SEE ALSO

one should also refer to:

   FunctionSurface(), EvalPatchedSurface(), DrawPatch(), DrawAllPatches(), 
   DrawAllPatchesGeo(), DrawAllPatchesWithTexture()


BPatchSurf.inc/DrawAllPatchesWithTexture() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

this helper macro renders all bezier_patch{}'es in single surface its simplicity results from sophisticated data structure. This macro applies default texture to the surface, so one don't need another

SYNOPSIS

402 DrawAllPatchesWithTexture(texturedef _MyTexture)

INPUTS

  texturedef _MyTexture - any valid texture definition

SEE ALSO

one should also refer to:

   FunctionSurface(), EvalPatchedSurface(), DrawPatch(), DrawAllPatches(), 
   DrawAllPatchesGeo(), DrawAllPatchesWithMap()


BPatchSurf.inc/DrawPatch() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

this helper macro renders single bezier_patch{}

SYNOPSIS

339 DrawPatch(uinteger ipy, uinteger ipx)

INPUTS

  ipy, ipx - two unsigned integer numbers, indices to array which contains definition of all patches

SEE ALSO

one should also refer to:

   FunctionSurface(), DrawPatch_UV(), EvalPatchedSurface(), DrawAllPatchesGeo(), 
   DrawAllPatchesWithTexture(), DrawAllPatchesWithMap(), source code of this module


BPatchSurf.inc/DrawPatch_UV() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

this macro renders all bezier_patch{}'es in single surface its simplicity results from sophisticated data structure. This macro applies NO texture to the surface, so one MUST aplly it by hand

SYNOPSIS

578 DrawPatch_UV(uinteger ipy, uinteger ipx, ImageConstants _type, string filename _UV_png)

INPUTS

  uinteger ipy   - and  ..
  uinteger ipx   - two unsigned integer numbers, indices to array which contains definition of all patches
  ImageConstants _type    - indicates format of the bitmap passed to the macro as uv_map{}
  _type = [ _JPG | _BMP | _GIF | _PNG |_TGA | _SYS |_EXR |_HDR |_IFF |_PGM |_PPM |_TIF |_TIF ]
  string filename _UV_png - valid filename of bitmap of type declared above
  this bitmap should be perpendicular, preferably rectangular, some images are distributed with the package
  as G00.jpg to G10.jpg as well as Gridd*.jpg files in "./img" subfolder

SEE ALSO

one should also refer to:

   FunctionSurface(), DrawPatch(), EvalPatchedSurface(), DrawPatch(), DrawAllPatches(), 
   DrawAllPatchesGeo(), DrawAllPatchesWithTexture()


BPatchSurf.inc/DrawPatch_UV_multi() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

this macro renders single bezier_patch{} and applies UV texture to it

SYNOPSIS

635 DrawPatch_UV_multi(uinteger ipy, uinteger ipx, ImageConstants _type, string _UV_core, uinteger _max)

INPUTS

  uinteger ipy   - and  ..
  uinteger ipx   - two unsigned integer numbers, indices to array which contains definition of all patches
  ImageConstants _type    - indicates format of the bitmap passed to the macro as uv_map{}
  _type = [ _JPG | _BMP | _GIF | _PNG |_TGA | _SYS |_EXR |_HDR |_IFF |_PGM |_PPM |_TIF |_TIF ]
  string   _UV_core - constant part of image file
  uinteger _max     - automatically generated suffix goes from '0' up to '_max-1'. Suffix is then concatenated
                    - with _UV_core and extension defined by _type. Thus final image name is defined.
                    - This image will be used as uv_map for the given by ipx&ipy indices patch.
                    - Consult source file for details.

EXAMPLE

647 DrawPatch_UV_multi(3, 5, _JPG, "Next", 7)
648 // renders patch 3rd/5th with uv image named: "Next01.jpg"

SEE ALSO

one should also refer to:

   FunctionSurface(), DrawPatch(), DrawPatch_UV(), EvalPatchedSurface(), DrawPatch(), 
   DrawAllPatches(), DrawAllPatchesGeo(), DrawAllPatchesWithTexture()


BPatchSurf.inc/DrawPatch_UVpng() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

This macro renders single bezier_patch{} depicted by given indices. Its simplicity results from sophisticated data structure. This macro applies UV'ed texture to the surface given in _UV_png (PNG format) file.

SYNOPSIS

474 DrawPatch_UVpng(ipy, ipx, _UV_png)

INPUTS

  None

SEE ALSO

one should also refer to:

   FunctionSurface(), EvalPatchedSurface(), DrawPatch(), DrawAllPatches_UVpng(),
   DrawAllPatches(), DrawAllPatchesGeo(), DrawAllPatchesWithTexture()


BPatchSurf.inc/FunctionSurface() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

Draws surface defined by z=Func(x,y) function, defined in real world parameters

SYNOPSIS

925 FunctionSurface(pfunction Func, float x1, float x2, integer Nxx, float y1, float y2, integer Nyy )

INPUTS

  pfunction Func -> inline f(x,y) => #declare abc=function(x,y){x-y} function declared in real x,y,z coordinates
  float x1, float x2, integer Nxx => x-min, x-max, num. of cardinal (exact value) points
  float y1, float y2, integer Nyy => the same but for y axis

EXAMPLE

931 #declare SinCos3 = function(i, j){ 2*sin(pi/2*i)+cos(pi/3*j)+i*j/400 }
932 FunctionSurface(SinCos3, 0, 4*pi, 20, 0, 4*pi, 20) // prepare SinCos3(x,y) surface over rectangle
933                                                    // extending from 0 to 4*Pi on X and Y axis
934 DrawAllPatches()                    // and then render it

SEE ALSO

one should also refer to:

   MatrixFileSurface(), EvalPatchedSurface(), DrawPatch(), DrawPatch_UV(), DrawPatch(),
   DrawAllPatches(), DrawAllPatchesGeo(), DrawAllPatchesWithTexture()


BPatchSurf.inc/MatrixFileSurface() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

Imports data from file InFileName, prepares data structure for EvalPatchedSurf() macro and eventually calls it.

    Format of input file (like matrix - Cx is for Column, Ry for Row):
    +------> [ rows mapped along X real] >----->     +------> [ X real] >----->
    |  C1R1, C2R1, C3R3, ...........                 |  z(x1y1), z(x2y1), z(x3y3), .....
    |  C1R2,                                         |  z(x1y2), z(x2y2),
    |  C1R3,                                         |  z(x1y3)),
    v   . .                                          v   . .
    [column mapped along Y real]                     [Y real]

Macro is provided for drawing data in real coordinates. Data in a row have the same y coordinate but sequencial x's. Only 'z' (height) values are given, values for x&y are calculated from values given in the header of the input file. Watching at the data file you see resulting surface like seeing it vertically from bottom of the coordinate system, having X axis oriented toward right hand, and Y axis beforehand.

SYNOPSIS

801 MatrixFileSurface(string_fn InFileName)

INPUTS

  string_fn filename InFileName - valid filename eg. "InSurfData.dat". Extension is not required nor fixed.

EXAMPLE

805 MatrixFileSurface("InSurfData.dat") // import data..
806 DrawAllPatches()                    // and then render all patches

SEE ALSO

one should also refer to:

   FunctionSurface(), EvalPatchedSurface(), DrawPatch(), DrawPatch_UV(), DrawPatch(),
   DrawAllPatches(), DrawAllPatchesGeo(), DrawAllPatchesWithTexture()


BPatchSurf.inc/RawDataSurfaceExt(), RawDataSurface() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

RawDataSurfaceExt() is just wrapper for RawDataSurface() function

SYNOPSIS

INPUTS

EXAMPLE

1027 RawDataSurfaceExt("SSurfA.dat", Gauss, Gauss, 0, 10, 20, 0, 10, 20) //
1028 DrawAllPatches()                    // and then render it
1029 
1030 OR
1031 
1032 RawDataSurface("SSurfA.dat", Gauss, Gauss, 2.0,  0, 10, 20, 0, 10, 20) //
1033 DrawAllPatches()                    // and then render it

SEE ALSO

one should also refer to:

   RawDataSurface(), MatrixFileSurface(), EvalPatchedSurface(), DrawPatch(), DrawPatch_UV(), DrawPatch(),
   ScatterDataSurfaceExp(), DrawAllPatches(), 
   DrawAllPatchesGeo(), DrawAllPatchesWithTexture()


BPatchSurf.inc/ScatterDataSurfaceExp() [ Main macros ]

[ Top ] [ BPatchSurf.inc ] [ Main macros ]

PURPOSE

ScatterDataSurfaceExp()

SYNOPSIS

INPUTS

EXAMPLE

1204 ScatterDataSurfaceExp()
1205 DrawAllPatches()            // and then render it

SEE ALSO

one should also refer to:

   RawDataSurface(), MatrixFileSurface(), EvalPatchedSurface(), DrawPatch(), DrawPatch_UV(), DrawPatch(),
   DrawAllPatches(), DrawAllPatchesGeo(), DrawAllPatchesWithTexture()


BPatchSurf.inc/DrawCardPoints() [ Helper macros ]

[ Top ] [ BPatchSurf.inc ] [ Helper macros ]

PURPOSE

this helper macro renders all "cardinal" ie. corner points of bicubic patches in the scene as spheres it is possible due to proper data structure. Macro renders pure geomtry, one have to define texture in #declare/object{} construct

SYNOPSIS

306 DrawCardPoints(float R)

INPUTS

  float R - radius of cardinal point

EXAMPLE

310 #declare PPP = object{DrawCardPoints(.2)};
311 object{ PPP
312         texture {valid texture definition}
313 }

SEE ALSO

one should also refer to:

   object{} description


BPatchSurf.inc/Inline functions() [ Helper macros ]

[ Top ] [ BPatchSurf.inc ] [ Helper macros ]

PURPOSE

helper functions applicable to macro: FunctionSurface(Func, x1, x2, Nxx, y1, y2, Nyy) used to draw surface by equation z=Func( x, y)

SYNOPSIS

250 #declare fId = function(i, j){ ..single nonconditional statement.. }; see example

INPUTS

  i, j - two float numbers for x, y argument values respectively, note that 'x' and 'y' symbols are predefined in POVRay as coord's system vectors

EXAMPLE

254 #declare SinCos3 = function(i, j){ 2*sin(pi/2*i)+cos(pi/3*j)+i*j/400 }
255 FunctionSurface(SinCos3, 0, 10, 11, 0, 10, 11)
256 DrawAllPatches()

SEE ALSO

one should also refer to:

   FunctionSurface(), DrawPatch(), DrawAllPatchesGeo(), DrawAllPatches(), 
   DrawAllPatchesWithTexture(), DrawAllPatchesWithMap(), POVRay function pointers

SOURCE */


BPatchSurf.inc/Inline kriging functions() [ Helper macros ]

[ Top ] [ BPatchSurf.inc ] [ Helper macros ]

PURPOSE

helper functions applicable to macro: smoothing & kriging functions: f=Func(float d)

SYNOPSIS

272 #declare fId = function(i, j){ ..single nonconditional statement.. }; // see example below

INPUTS

  i, j - two float numbers for x,y argument values respectively, note that 'x' and 'y' symbols are predefined in POVRay as coord's system vectors

EXAMPLE

276 #declare Newton  = function (d) { 1/d      }      // named after potential function
277 RawDataSurface("AnyFiled.dat", Newton, Llimiter, .5, 0, 10, 20, 0, 10, 20)
278 DrawAllPatches()

SEE ALSO

one should also refer to:

   FunctionSurface(), DrawPatch(), DrawAllPatchesGeo(), DrawAllPatches(), 
   DrawAllPatchesWithTexture(), DrawAllPatchesWithMap(), POVRay function pointers

SOURCE

285 #declare Newton  = function (d) { 1/d      }      // named after newtonian potential function
286 #declare Limiter = function (d) { 1/DZero  }      // this function is called when d<DZero
287 #declare Exponent= function (d) { exp(-d)  }
288 #declare Gauss   = function (d) { exp(-pow(d,2))} // resembles gauss PDF distribution function
289 
290 // simple kriging - more general example, which needs  */
291 // two input values, interpreted as 'distance' and 'power' respectively*/
292 #declare SKrig   = function (d, pw) { 1/(1.0+pow(d, pw)) }  // SKrig(distance, power)
293 
294 // ======[ specialised function ]======
295 #declare SKrig1  = function (d) { 1/(1.0+d) }
296 #declare SKrig2  = function (d) { 1/(1.0+pow(d,2)) }
297 #declare SKrig4  = function (d) { 1/(1.0+pow(d,4)) }

BPatchSurf.inc/SetDZero() [ Helper macros ]

[ Top ] [ BPatchSurf.inc ] [ Helper macros ]

PURPOSE

minimal minimal float number assumed not being equal zero meaning of this variable depends on algorithm employed

SYNOPSIS

176 SetDZero(float)

INPUTS

  float number for new DZero value

SEE ALSO

one should also refer to:

   DZero


BPatchSurf.inc/SetInterior() [ Helper macros ]

[ Top ] [ BPatchSurf.inc ] [ Helper macros ]

PURPOSE

declares interior section for enabled items and sets DeclareLevel on '2'

SYNOPSIS

142 SetTexture( interiordef tInt)

INPUTS

   tInt - variable declared as fully defined valid texture

EXAMPLE

146 #declare TInterior = interior { // for details of 'interior' definition consult POVRay documentation
147                         ior 1.5
148                         fade_power 1001
149                         fade_distance 0.9
150                         fade_color <Nodes[CountY][CountX]/DscMaxY,.5,1-Nodes[CountY][CountX]/DscMaxY>
151                       };
152 SetInterior(TInterior)

BPatchSurf.inc/SetRGBFTColor() [ Helper macros ]

[ Top ] [ BPatchSurf.inc ] [ Helper macros ]

PURPOSE

Sets default color stored in tmpColor internal variable: Sets DeclareLevel to '0' (basic level)

SYNOPSIS

109 SetRGBFTColor( float RR, float RG, float BB, float FF, float TT) for RGBFT definition

INPUTS

   RR - red component
   GG - green component
   BB - blue component
   FF - filter amount
   TT - transparency level

BPatchSurf.inc/SetTexture() [ Helper macros ]

[ Top ] [ BPatchSurf.inc ] [ Helper macros ]

PURPOSE

declares texure for the enabled items and sets DeclareLevel on '2'

SYNOPSIS

126 SetTexture( texturedef FullTexture)

INPUTS

   FullTexture - variable declared as fully defined valid texture

EXAMPLE

130 #declare MyTexture = texture{pigment{color rgb <0,0,1>}};
131 SetTexture(MyTexture)

BPatchSurf.inc/SetVScale() [ Helper macros ]

[ Top ] [ BPatchSurf.inc ] [ Helper macros ]

PURPOSE

Sets factor for enhancement along vertical axis (negative values allowed ;)

SYNOPSIS

203 SetVScale(float)

INPUTS

  float number for new VScale value

SEE ALSO

one should also refer to:

   VScale


BPatchSurf.inc/SetVShift() [ Helper macros ]

[ Top ] [ BPatchSurf.inc ] [ Helper macros ]

PURPOSE

macro and variable, explanation: due to limitations of bicubic interpolation algorithm, unexpected micro bulges are sometimes observed. This can cause inconsistences of gradient mapping. To overcome this difficulty one can shift whole surface up or down by applying this macro. Values in range of 10^-4 are usually sufficient

SYNOPSIS

233 SetVShift(float)

INPUTS

  float number for new VShift value

SEE ALSO

one should also refer to:

   VShift

SOURCE


BPatchSurf.inc/ImageConstants [ Constants ]

[ Top ] [ BPatchSurf.inc ] [ Constants ]

PURPOSE

this enumerated constant are for DrawPatch_UV###() macro and defines Types of UV_map file. For details of UV mapping consult please POVRay documentation. Following image formats are defined:


BPatchSurf.inc/DeclareLevel [ Variables ]

[ Top ] [ BPatchSurf.inc ] [ Variables ]

PURPOSE

DeclareLevel determines what is defined:

this value is valid until next "Set...()" declaration is met SOURCE */


BPatchSurf.inc/DZero [ Variables ]

[ Top ] [ BPatchSurf.inc ] [ Variables ]

PURPOSE

minimal minimal float number assumed not being equal zero meaning of this variable depends on algorithm employed

SEE ALSO

one should also refer to:

   SetDZero(float)

SOURCE

168 #declare DZero = 1E-4;

BPatchSurf.inc/VScale [ Variables ]

[ Top ] [ BPatchSurf.inc ] [ Variables ]

PURPOSE

minimal distance between grid & random point, this value is valid until "SetVScale()"

SEE ALSO

one should also refer to:

   SetVScale()

SOURCE

196 #declare VScale = 1.0;    // Surface enhancement along vertical axis (negative values allowed ;)

BPatchSurf.inc/VShift [ Variables ]

[ Top ] [ BPatchSurf.inc ] [ Variables ]

PURPOSE

see SetVShift() macro

SEE ALSO

one should also refer to:

   SetVShift()

SOURCE

222 #declare VShift=0;