12 #ifndef ROOT_TPainter3dAlgorithms
13 #define ROOT_TPainter3dAlgorithms
21 const Int_t kCARTESIAN = 1;
22 const Int_t kPOLAR = 2;
23 const Int_t kCYLINDRICAL = 3;
24 const Int_t kSPHERICAL = 4;
25 const Int_t kRAPIDITY = 5;
29 class TPainter3dAlgorithms :
public TObject,
public TAttLine,
public TAttFill {
54 static Int_t fgF3Clipping;
55 static Double_t fgF3XClip;
56 static Double_t fgF3YClip;
57 static Double_t fgF3ZClip;
58 static TF3 *fgCurrentF3;
62 typedef void (TPainter3dAlgorithms::*DrawFaceFunc_t)(Int_t *, Double_t *, Int_t, Int_t *, Double_t *);
63 typedef void (TPainter3dAlgorithms::*LegoFunc_t)(Int_t,Int_t,Int_t&,Double_t*,Double_t*,Double_t*);
64 typedef void (TPainter3dAlgorithms::*SurfaceFunc_t)(Int_t,Int_t,Double_t*,Double_t*);
67 DrawFaceFunc_t fDrawFace;
68 LegoFunc_t fLegoFunction;
69 SurfaceFunc_t fSurfaceFunction;
72 TPainter3dAlgorithms();
73 TPainter3dAlgorithms(Double_t *rmin, Double_t *rmax, Int_t system=1);
74 virtual ~TPainter3dAlgorithms();
75 void BackBox(Double_t ang);
76 void FrontBox(Double_t ang);
77 void DrawFaceGouraudShaded(Int_t *icodes, Double_t xyz[][3], Int_t np, Int_t *iface, Double_t *t);
78 void DrawFaceMode1(Int_t *icodes, Double_t *xyz, Int_t np, Int_t *iface, Double_t *t);
79 void DrawFaceMode2(Int_t *icodes, Double_t *xyz, Int_t np, Int_t *iface, Double_t *t);
80 void DrawFaceMode3(Int_t *icodes, Double_t *xyz, Int_t np, Int_t *iface, Double_t *t);
81 void DrawFaceMove1(Int_t *icodes, Double_t *xyz, Int_t np, Int_t *iface, Double_t *tt);
82 void DrawFaceMove2(Int_t *icodes, Double_t *xyz, Int_t np, Int_t *iface, Double_t *tt);
83 void DrawFaceMove3(Int_t *icodes, Double_t *xyz, Int_t np, Int_t *iface, Double_t *tt);
84 void DrawLevelLines(Int_t *icodes, Double_t *xyz, Int_t np, Int_t *iface, Double_t *tt);
85 void DrawFaceRaster1(Int_t *icodes, Double_t *xyz, Int_t np, Int_t *iface, Double_t *tt);
86 void DrawFaceRaster2(Int_t *icodes, Double_t *xyz, Int_t np, Int_t *iface, Double_t *tt);
87 void GouraudFunction(Int_t ia, Int_t ib, Double_t *f, Double_t *t);
88 void ImplicitFunction(Double_t *rmin, Double_t *rmax, Int_t nx, Int_t ny, Int_t nz,
const char *chopt);
89 void IsoSurface (Int_t ns, Double_t *s, Int_t nx, Int_t ny, Int_t nz, Double_t *x, Double_t *y, Double_t *z,
const char *chopt);
90 void LegoCartesian(Double_t ang, Int_t nx, Int_t ny,
const char *chopt);
91 void LegoFunction(Int_t ia, Int_t ib, Int_t &nv, Double_t *ab, Double_t *vv, Double_t *t);
92 void LegoPolar(Int_t iordr, Int_t na, Int_t nb,
const char *chopt);
93 void LegoCylindrical(Int_t iordr, Int_t na, Int_t nb,
const char *chopt);
94 void LegoSpherical(Int_t ipsdr, Int_t iordr, Int_t na, Int_t nb,
const char *chopt);
95 void SetDrawFace(DrawFaceFunc_t pointer);
96 void SetIsoSurfaceParameters(Double_t fmin, Double_t fmax, Int_t ncolor, Int_t ic1, Int_t ic2, Int_t ic3){fFmin=fmin; fFmax=fmax; fNcolor=ncolor; fIc1=ic1; fIc2=ic2; fIc3=ic3;}
97 void SetLegoFunction(LegoFunc_t pointer);
98 void SetMesh(Int_t mesh=1) {fMesh=mesh;}
99 void SetSurfaceFunction(SurfaceFunc_t pointer);
100 void SetColorDark(Color_t color, Int_t n=0);
101 void SetColorMain(Color_t color, Int_t n=0);
102 void SetEdgeAtt(Color_t color=1, Style_t style=1, Width_t width=1, Int_t n=0);
103 void SideVisibilityDecode(Double_t val, Int_t &iv1, Int_t &iv2, Int_t &iv3, Int_t &iv4, Int_t &iv5, Int_t &iv6, Int_t &ir);
104 void SideVisibilityEncode(Int_t iopt, Double_t phi1, Double_t phi2, Double_t &val);
105 void SurfaceCartesian(Double_t ang, Int_t nx, Int_t ny,
const char *chopt);
106 void SurfacePolar(Int_t iordr, Int_t na, Int_t nb,
const char *chopt);
107 void SurfaceCylindrical(Int_t iordr, Int_t na, Int_t nb,
const char *chopt);
108 void SurfaceFunction(Int_t ia, Int_t ib, Double_t *f, Double_t *t);
109 void SurfaceSpherical(Int_t ipsdr, Int_t iordr, Int_t na, Int_t nb,
const char *chopt);
111 static void SetF3(TF3 *f3);
112 static void SetF3ClippingBoxOff();
113 static void SetF3ClippingBoxOn(Double_t xclip, Double_t yclip, Double_t zclip);
118 void DefineGridLevels(Int_t ndivz);
119 void ColorFunction(Int_t nl, Double_t *fl, Int_t *icl, Int_t &irep);
120 void Spectrum(Int_t nl, Double_t fmin, Double_t fmax, Int_t ic, Int_t idc, Int_t &irep);
121 void FindLevelLines(Int_t np, Double_t *f, Double_t *t);
122 void FindPartEdge(Double_t *p1, Double_t *p2, Double_t f1, Double_t f2, Double_t fmin, Double_t fmax, Int_t &kpp, Double_t *pp);
123 void FillPolygon(Int_t n, Double_t *p, Double_t *f);
126 static const Int_t NumOfColorLevels = 256;
128 Double_t fFunLevel[NumOfColorLevels+1];
129 Int_t fColorLevel[NumOfColorLevels+2];
131 static const Int_t NumOfLevelLines = 200;
133 Int_t fLevelLine[NumOfLevelLines];
134 Double_t fPlines[NumOfLevelLines*6];
139 void LightSource(Int_t nl, Double_t yl, Double_t xscr, Double_t yscr, Double_t zscr, Int_t &irep);
140 void Luminosity(Double_t *anorm, Double_t &flum);
141 void SurfaceProperty(Double_t qqa, Double_t qqd, Double_t qqs, Int_t nnqs, Int_t &irep);
144 static const Int_t NumOfLights = 4;
147 Double_t fYls[NumOfLights];
148 Double_t fVls[NumOfLights*3];
158 void InitMoveScreen(Double_t xmin, Double_t xmax);
159 void FindVisibleDraw(Double_t *r1, Double_t *r2);
160 void ModifyScreen(Double_t *r1, Double_t *r2);
163 static const Int_t MaxNT = 100;
167 Double_t fT[MaxNT*2];
169 static const Int_t NumOfSlices = 2000;
170 Double_t fU[NumOfSlices*2];
171 Double_t fD[NumOfSlices*2];
177 void InitRaster(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Int_t nx, Int_t ny);
179 void FindVisibleLine(Double_t *p1, Double_t *p2, Int_t ntmax, Int_t &nt, Double_t *t);
180 void FillPolygonBorder(Int_t nn, Double_t *xy);
197 void MarchingCube(Double_t fiso, Double_t p[8][3], Double_t f[8], Double_t g[8][3], Int_t &nnod, Int_t &ntria, Double_t xyz[][3], Double_t grad[][3], Int_t itria[][3]);
200 void MarchingCubeCase00(Int_t k1, Int_t k2, Int_t k3, Int_t k4, Int_t k5, Int_t k6, Int_t &nnod, Int_t &ntria, Double_t xyz[52][3], Double_t grad[52][3], Int_t itria[48][3]);
201 void MarchingCubeCase03(Int_t &nnod, Int_t &ntria, Double_t xyz[52][3], Double_t grad[52][3], Int_t itria[48][3]);
202 void MarchingCubeCase04(Int_t &nnod, Int_t &ntria, Double_t xyz[52][3], Double_t grad[52][3], Int_t itria[48][3]);
203 void MarchingCubeCase06(Int_t &nnod, Int_t &ntria, Double_t xyz[52][3], Double_t grad[52][3], Int_t itria[48][3]);
204 void MarchingCubeCase07(Int_t &nnod, Int_t &ntria, Double_t xyz[52][3], Double_t grad[52][3], Int_t itria[48][3]);
205 void MarchingCubeCase10(Int_t &nnod, Int_t &ntria, Double_t xyz[52][3], Double_t grad[52][3], Int_t itria[48][3]);
206 void MarchingCubeCase12(Int_t &nnod, Int_t &ntria, Double_t xyz[52][3], Double_t grad[52][3], Int_t itria[48][3]);
207 void MarchingCubeCase13(Int_t &nnod, Int_t &ntria, Double_t xyz[52][3], Double_t grad[52][3], Int_t itria[48][3]);
208 void MarchingCubeSetTriangles(Int_t ntria, Int_t it[][3], Int_t itria[48][3]);
209 void MarchingCubeMiddlePoint(Int_t nnod, Double_t xyz[52][3], Double_t grad[52][3], Int_t it[][3], Double_t *pxyz, Double_t *pgrad);
210 void MarchingCubeSurfacePenetration(Double_t a00, Double_t a10, Double_t a11, Double_t a01, Double_t b00, Double_t b10, Double_t b11, Double_t b01, Int_t &irep);
211 void MarchingCubeFindNodes(Int_t nnod, Int_t *ie, Double_t xyz[52][3], Double_t grad[52][3]);
221 void ZDepth(Double_t xyz[52][3], Int_t &nface, Int_t iface[48][3], Double_t dface[48][6], Double_t abcd[48][4], Int_t *iorder);
224 void TestEdge(Double_t del, Double_t xyz[52][3], Int_t i1, Int_t i2, Int_t iface[3], Double_t abcd[4], Int_t &irep);
227 ClassDef(TPainter3dAlgorithms,0)