# How to specify the level value in isosurface drawing with TF3 and GL?

**URL:** <https://root-forum.cern.ch/t/how-to-specify-the-level-value-in-isosurface-drawing-with-tf3-and-gl/32179>\
**Category:** ROOT\
**Tags:** graphics\
**Created:** [January 6, 2019, 7:57am UTC](https://root-forum.cern.ch/t/how-to-specify-the-level-value-in-isosurface-drawing-with-tf3-and-gl/32179 "2019-01-06T07:57:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredo.faure](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/fredo.faure/32/26062_2.png) [@fredo.faure](https://root-forum.cern.ch/u/fredo.faure)\
**Post date:** [January 6, 2019, 7:57am UTC](https://root-forum.cern.ch/t/how-to-specify-the-level-value-in-isosurface-drawing-with-tf3-and-gl/32179/1 "2019-01-06T07:57:02Z")

</div>

Hello,  
the following example shows that isosurface drawing with TF3 and GL seems to draw the surface level  
f(x,y,z)=-0.2 whereas without GL options it draws the surface level f(x,y,z)=0.  
Here i take for example f(x,y,z)=x_y_z.  
Do i miss the correct way to specify the value of the function?  
Thanks,  
Frédéric Faure.

![glc](https://root-forum.cern.ch/uploads/default/original/3X/a/e/ae35e5c85d3c77f6599f4c19b2acf895db82f0d6.png)

![glc](https://root-forum.cern.ch/uploads/default/original/3X/e/5/e5578c540ce42e2d3ec94cd804de9c4f458aeb4a.png)

![c2](https://root-forum.cern.ch/uploads/default/original/3X/1/e/1e0dd71a170d6b52c7563bf85230f7ac06a0dda5.png)

```auto
#include <TApplication.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TPaveLabel.h>
#include <TFormula.h>
#include <TF3.h>
#include <TText.h>
//-----------------------------
main ()
{
	TApplication theApp("App", nullptr, nullptr);

	//----- With GL ---------
    //.... prepare the 3D window
	gStyle->SetCanvasPreferGL(1);
	TCanvas *cnv = new TCanvas("glc", "TF3: Surface", 200, 10, 600, 600);
	TPad *tf3Pad = new TPad("box", "box",0,0,1,1);
	tf3Pad->Draw();
    //.... define and draw the 3D object

	TF3 *tf3 = new TF3("Surface","x*y*z+0.2", -1,1,-1,1,-1,1);
	
	tf3->SetFillColor(kRed);
	tf3Pad->cd();
	tf3->Draw("gl");

	TText *texte=new TText(0.2,0.9,"f(x,y,z)= x*y*z+0.2");
	texte->Draw();
	
	//----- Without GL ---------

	auto c2 = new TCanvas("c2","c2", 1000, 1000);

	TF3 *tf3bis = new TF3("Surface","x*y*z", -1,1,-1,1,-1,1);
	tf3bis->Draw("FBBB");

	//------------------------
	theApp.Run();
} 

```

\_\_  
_ROOT Version:_ Not Provided  
_Platform:_ Not Provided  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 7, 2019, 2:38pm UTC](https://root-forum.cern.ch/t/how-to-specify-the-level-value-in-isosurface-drawing-with-tf3-and-gl/32179/2 "2019-01-07T14:38:54Z")

</div>

yes i can see the same with the following macro:

```auto
void tf3gl (int gl=1)
{
   if (gl==1) gStyle->SetCanvasPreferGL(true);
   auto c = new TCanvas("c", "TF3: Surface", 0, 0, 600, 600);

   if (gl==1) {
      TF3 *tf3 = new TF3("Surface","x*y*z+0.2", -1,1,-1,1,-1,1);
      tf3->Draw("glfbbb");
   } else {
      TF3 *tf3 = new TF3("Surface","x*y*z", -1,1,-1,1,-1,1);
      tf3->Draw("FBBB");
   }
}

```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 7, 2019, 2:57pm UTC](https://root-forum.cern.ch/t/how-to-specify-the-level-value-in-isosurface-drawing-with-tf3-and-gl/32179/3 "2019-01-07T14:57:36Z")

</div>

In the file `graf3d/gl/src/TGLTF3Painter.cxx` in the method `Bool_t TGLTF3Painter::InitGeometry()` I see the line:

```auto
   builder.BuildMesh(fF3, geom, &fMesh, 0.2);

```

if I replace 0.2 by 0. on that line then the gl and non gl version behave the same.

May be @tpochep (the author if this code) has an idea why there is an hardcoded 0.2 there ?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 8, 2019, 9:18am UTC](https://root-forum.cern.ch/t/how-to-specify-the-level-value-in-isosurface-drawing-with-tf3-and-gl/32179/6 "2019-01-08T09:18:25Z")

</div>

I have done this change in the ROOT master.  
The GL and non-GL version are the same now.  
Thanks to have seen this mismatch.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [January 22, 2019, 9:18am UTC](https://root-forum.cern.ch/t/how-to-specify-the-level-value-in-isosurface-drawing-with-tf3-and-gl/32179/7 "2019-01-22T09:18:27Z")

</div>

Closed on January 22, 2019, 9:18am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
