25 glEnable(GL_LIGHTING);
26 glEnable( GL_LIGHT0 );
37 GLfloat DrMatColor [] = {Red,Green,Blue,1.};
38 glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,DrMatColor);
39 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,DrMatColor);
40 glColor4f(Red,Green,Blue,1.);
47 for(
int d=0;d<3;d++) Cm[d] =
pPos(p,d);
60 Cm[d] /= (double)(
Ln[p].NLink+1);
62 glColor4f(.1,.3,1.,1.);
65 glVertex3d(Cm[0]*
InvScaleUn,Cm[1]*InvScaleUn,Cm[2]*InvScaleUn*ScaleFact);
66 glVertex3d((Cm[0]-
pVel(p,0))*InvScaleUn,(Cm[1]-
pVel(p,1))*InvScaleUn,(Cm[2]-
pVel(p,2))*InvScaleUn*ScaleFact);
79 if(link[2] < 0 ) link[2] +=
pNPart();
81 if(link[3] < 0 ) link[3] +=
pNPart();
92 Normals[4][d] = Normals[0][d] + Normals[1][d] + Normals[2][d] + Normals[3][d];
93 Norm += SQR(Normals[4][d]);
97 Normals[4][d] /= Norm;
99 glNormal3d(Normals[4][0],Normals[4][1],Normals[4][2]);
103 glEnable(GL_LIGHTING);
104 glEnable( GL_LIGHT0 );
107 glDisable(GL_LIGHTING);
112 if(NEdge*NEdge !=
pNPart()) NEdge += 1;
114 for(
int p=0;p<
pNPart();p++){
117 glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,Color);
118 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,Color);
121 if((l1%NEdge) == 0)
continue;
122 int l2 = p + NEdge + 1;
123 if(l2 >=
pNPart()-1)
continue;
125 if(l3 >=
pNPart()-1)
continue;
131 glVertex3d(
Pm[l1].Pos[0]*InvScaleUn,
Pm[l1].Pos[1]*InvScaleUn,
Pm[l1].Pos[2]*InvScaleUn*ScaleFact);
133 glVertex3d(
Pm[l2].Pos[0]*InvScaleUn,
Pm[l2].Pos[1]*InvScaleUn,
Pm[l2].Pos[2]*InvScaleUn*ScaleFact);
135 glVertex3d(
Pm[l3].Pos[0]*InvScaleUn,
Pm[l3].Pos[1]*InvScaleUn,
Pm[l3].Pos[2]*InvScaleUn*ScaleFact);
140 glDisable(GL_LIGHTING);
142 #include "ElPolyDrawSurf.h" 144 glEnable(GL_LIGHTING);
145 glEnable( GL_LIGHT0 );
146 glMaterialfv(GL_BACK, GL_AMBIENT, DrAmbientRed);
147 glMaterialfv(GL_BACK, GL_DIFFUSE, DrDiffuseRed);
148 glMaterialfv(GL_FRONT, GL_AMBIENT, DrAmbientBlue);
149 glMaterialfv(GL_FRONT, GL_DIFFUSE, DrDiffuseBlue);
150 glMaterialfv(GL_FRONT, GL_SPECULAR, DrSpecularWhite);
151 glMaterialf( GL_FRONT, GL_SHININESS, 25.0);
153 double EdgeVertex[12][3];
154 double EdgeNormal[12][3];
155 double InvNGrid = 1./(double)NGrid;
158 glBegin(GL_TRIANGLES);
161 for(
int gx=0;gx<NGrid;gx++){
162 Pos[0] = gx*InvNGrid*
pEdge(0);
163 for(
int gy=0;gy<NGrid;gy++){
164 Pos[1] = gy*InvNGrid*
pEdge(1);
165 for(
int gz=0;gz<NGrid;gz++){
166 Pos[2] = gz*InvNGrid*
pEdge(2);
167 for(
int v=0;v<8;v++){
168 for(
int d=0;d<3;d++){
169 Pos1[d] = Pos[d] + VertCube[v][d]*InvNGrid*
pEdge(d);
174 for(
int v=0;v<8;v++){
175 if(CubeDist[v] <= IsoLevel)
178 int CubeShape = CubeTop[Flag];
179 if(CubeShape==0)
continue;
180 for(
int e=0;e<12;e++){
181 if(CubeShape & (1<<e)){
182 double Delta = CubeDist[EdgeConn[e][1]] - CubeDist[EdgeConn[e][0]];
183 double OffSet = (IsoLevel-CubeDist[EdgeConn[e][0]])/Delta;
187 EdgeNormal[e][0] =
NanoDist2(Pos[0]-0.01,Pos[1],Pos[2],nNano)
188 -
NanoDist2(Pos[0]+0.01,Pos[1],Pos[2],nNano);
189 EdgeNormal[e][1] =
NanoDist2(Pos[0],Pos[1]-0.01,Pos[2],nNano)
190 -
NanoDist2(Pos[0],Pos[1]+0.01,Pos[2],nNano);
191 EdgeNormal[e][2] =
NanoDist2(Pos[0],Pos[1],Pos[2]-0.01,nNano)
192 -
NanoDist2(Pos[0],Pos[1],Pos[2]+0.01,nNano);
193 double Norm = sqrt(SQR(EdgeNormal[e][0])+SQR(EdgeNormal[e][1])+SQR(EdgeNormal[e][2]));
194 for(
int d=0;d<3;d++){
195 EdgeVertex[e][d] = Pos[d] + (VertCube[EdgeConn[e][0]][d]+OffSet*EdgeDir[e][d])*InvNGrid*
pEdge(d);
197 EdgeNormal[e][d] *= 1./Norm;
201 for(
int t=0;t<5;t++){
202 if(TrConnTable[Flag][3*t] < 0.)
break;
203 for(
int d=0;d<3;d++){
204 int v = TrConnTable[Flag][3*t+d];
206 glNormal3d(EdgeNormal[v][0],EdgeNormal[v][1],EdgeNormal[v][2]);
207 glVertex3d(EdgeVertex[v][0],EdgeVertex[v][1],EdgeVertex[v][2]);
216 glEnable(GL_LIGHTING);
217 glEnable( GL_LIGHT0 );
223 for(
int p=0;p<
pNPart();p++){
228 for(
int p=0;p<
pNPart();p++){
234 GLfloat DrMatColor [] = {Red,Green,Blue,1.};
235 glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,DrMatColor);
236 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,DrMatColor);
238 glColor4f(Red,Green,Blue,1.);
245 printf(
"%d\n",NDraw);
249 glEnable(GL_LIGHTING);
250 glEnable( GL_LIGHT0 );
256 double Offset = 1./(double)
NEdge;
257 for(
int p=0;p<
pNPart();p+=Incr){
261 GLfloat DrMatColor [] = {Red,Green,Blue,1.};
262 glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,DrMatColor);
263 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,DrMatColor);
265 glColor4f(Red,Green,Blue,1.0);
278 glEnable(GL_LIGHTING);
279 glEnable( GL_LIGHT0 );
285 for(
int p=0;p<
pNPart();p++){
291 Nx = (int)(
pNPart()/(double)Ny);
295 for(
int p=0;p<
pNPart();p++){
299 Min = 1./MIN(fabs(Min),1.);
300 Max = 1./MIN(1.,Max);
301 for(
int p=0;p<
pNPart();p++){
303 if( !(l1%Ny) )
continue;
305 if(l2 >=
pNPart() - 1)
continue;
316 Alpha = MAX(Green-.2,0.);
323 Alpha = MAX(Blue,0.);
327 GLfloat DrMatColor [] = {Red,Green,Blue,Alpha};
328 glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,DrMatColor);
329 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,DrMatColor);
330 glColor4d(Red,Green,Blue,Alpha);
337 glNormal3f(0.,0.,1.);
390 glEnable(GL_LIGHTING);
391 glEnable( GL_LIGHT0 );
394 glDisable(GL_LIGHTING);
398 double Offset = 1./(double)
NEdge;
399 for(
int p=0,c=0,t=0;p<
pNPart();p++){
400 if(
Ln[p].NLink != 3 )
continue;
401 if(c ==
pChain(p))
continue;
408 if(Blue + Red + Green < .08){Blue = 1.; Red = 1.;Green = 1.;Alpha=0.;}
409 GLfloat DrMatColor [] = {Red,Green,Blue,Alpha};
410 glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,DrMatColor);
411 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,DrMatColor);
419 glColor4f(Red,Green,Blue,Alpha);
438 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
439 u = v2-v1;v = v3-v1;vN = u ^ v;
440 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
441 glVertex3d(v4.
x[0],v4.
x[1],v4.
x[2]);
442 u = v1-v2;v = v3-v2;vN = u ^ v;
443 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
444 glVertex3d(v3.
x[0],v3.
x[1],v3.
x[2]);
445 u = v2-v3;v = v4-v3;vN = u ^ v;
446 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
447 glVertex3d(v2.x[0],v2.x[1],v2.x[2]);
448 u = v1-v4;v = v3-v4;vN = u ^ v;
449 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
450 glVertex3d(v1.x[0],v1.x[1],v1.x[2]);
456 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
457 glVertex3d(-v1.x[0],v1.x[1],v1.x[2]);
458 glVertex3d(-v2.x[0],v2.x[1],v2.x[2]);
459 glVertex3d(-v3.x[0],v3.x[1],v3.x[2]);
460 glVertex3d(-v4.x[0],v4.x[1],v4.x[2]);
467 glEnable(GL_LIGHTING);
468 glEnable( GL_LIGHT0 );
470 GLfloat Deltax = 1./(GLfloat) NPoint;
471 PART *PSample = (
PART *)calloc(NPoint*NPoint,
sizeof(
PART));
472 int NSample = (int)sqrt(
pNPart());
473 glColor4f(1.0,.0,1.,1.);
474 glEnableClientState(GL_VERTEX_ARRAY);
475 glEnableClientState(GL_NORMAL_ARRAY);
476 glEnable(GL_VERTEX_ARRAY);
477 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
483 glVertexPointer(3,GL_DOUBLE,
sizeof(
PART),&PSample[0].Pos[0]);
484 glNormalPointer(GL_DOUBLE,
sizeof(
PART),&PSample[0].Vel[0]);
485 vector <GLuint> VecIndices;
486 for(
int i=0;i<NPoint-1;i++){
487 for(
int j=0;j<NPoint-1;j++){
488 VecIndices.push_back(i*NPoint + j);
489 VecIndices.push_back((i+1)*NPoint + j);
490 VecIndices.push_back((i+1)*NPoint + (j+1));
492 VecIndices.push_back(i*NPoint + j);
493 VecIndices.push_back((i+1)*NPoint + (j+1));
494 VecIndices.push_back((i)*NPoint + (j+1));
497 int NIndex = VecIndices.size();
498 GLuint *Indices = (GLuint *)calloc(NIndex,
sizeof(GLuint));
499 for(
int i=0;i<NIndex;i++){
500 Indices[i] = VecIndices[i];
502 glDrawElements(GL_TRIANGLES,NIndex,GL_UNSIGNED_INT,Indices);
510 glBegin(GL_TRIANGLES);
526 glNormal3f(vN->
x[0],vN->
x[1],vN->
x[2]);
527 glVertex3d(v00->
x[0],v00->
x[1],v00->
x[2]);
528 glVertex3d(v01->
x[0],v01->
x[1],v01->
x[2]);
529 glVertex3d(v11->
x[0],v11->
x[1],v11->
x[2]);
535 glBegin(GL_TRIANGLES);
536 glNormal3f(vN->
x[0],vN->
x[1],vN->
x[2]);
537 glVertex3d(v00->
x[0],v00->
x[1],v00->
x[2]);
538 glVertex3d(v11->
x[0],v11->
x[1],v11->
x[2]);
539 glVertex3d(v10->
x[0],v10->
x[1],v10->
x[2]);
547 glBegin(GL_TRIANGLES);
548 glNormal3f(vN->
x[0],vN->
x[1],vN->
x[2]);
549 glVertex3d(v00->
x[0],v00->
x[1],v00->
x[2]);
550 glVertex3d(v01->
x[0],v01->
x[1],v01->
x[2]);
551 glVertex3d(v11->
x[0],v11->
x[1],v11->
x[2]);
558 glVertex3d(v00->
x[0],v00->
x[1],v00->
x[2]);
559 glVertex3d(v01->
x[0],v01->
x[1],v01->
x[2]);
562 glVertex3d(v01->
x[0],v01->
x[1],v01->
x[2]);
563 glVertex3d(v11->
x[0],v11->
x[1],v11->
x[2]);
566 glVertex3d(v11->
x[0],v11->
x[1],v11->
x[2]);
567 glVertex3d(v00->
x[0],v00->
x[1],v00->
x[2]);
573 glEnable(GL_LIGHTING);
574 glEnable( GL_LIGHT0 );
577 glDisable(GL_LIGHTING);
589 double Delta = 1./(Max-Min);
590 for(
int s=0;s<NSample-1;s++){
591 for(
int ss=0;ss<NSample-1;ss++){
592 v00.
x[
CLat1]=(s+.5)*FactC1;
593 v00.
x[
CLat2]=(ss+.5)*FactC2;
594 v00.
x[
CNorm]=Plot[s*NSample+ss]*FactCN;
595 v01.
x[
CLat1]=(s+1.5)*FactC1;
596 v01.
x[
CLat2]=(ss+.5)*FactC2;
597 v01.
x[
CNorm]=Plot[(s+1)*NSample+ss]*FactCN;
598 v11.
x[
CLat1]=(s+1.5)*FactC1;
599 v11.
x[
CLat2]=(ss+1.5)*FactC2;
600 v11.
x[
CNorm]=Plot[(s+1)*NSample+(ss+1)]*FactCN;
601 v10.
x[
CLat1]=(s+.5)*FactC1;
602 v10.
x[
CLat2]=(ss+1.5)*FactC2;
603 v10.
x[
CNorm]=Plot[s*NSample+ss+1]*FactCN;
609 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
612 glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,Color);
613 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,Color);
615 glVertex3d(v00.
x[0],v00.
x[1],v00.
x[2]);
618 glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,Color);
619 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,Color);
621 glVertex3d(v01.
x[0],v01.
x[1],v01.
x[2]);
624 glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,Color);
625 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,Color);
627 glVertex3d(v11.
x[0],v11.
x[1],v11.
x[2]);
630 glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,Color);
631 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,Color);
633 glVertex3d(v10.
x[0],v10.
x[1],v10.
x[2]);
637 glDisable(GL_LIGHTING);
642 printf(
"plane min=%lf av=%lf max=%lf\n",m1.
Min,m1.
Uno,m1.
Max);
653 glDisable(GL_NORMALIZE);
654 double Offset = 1./(double)
NEdge;
663 for(
int p=0,c=0,t=0;p<
pNPart();p++){
664 if(
Ln[p].NLink != 3 )
continue;
665 if(c ==
pChain(p))
continue;
678 glColor4f(Red,Green,Blue,Alpha);
695 glNormal3f(vN.
x[0],vN.
x[1],-vN.
x[2]);
696 glVertex3d(v4.
x[0],v4.
x[1],v4.
x[2]);
697 glVertex3d(v3.
x[0],v3.
x[1],v3.
x[2]);
698 glVertex3d(v2.
x[0],v2.
x[1],v2.
x[2]);
699 glVertex3d(v1.
x[0],v1.
x[1],v1.
x[2]);
707 double Threshold = 0.;
709 double **Plot = (
double **) calloc(NLevel,
sizeof(
double));
710 for(
int l=0;l<NLevel;l++){
711 Plot[l] = (
double *)calloc(NSample*NSample,
sizeof(
double));
713 Stalk(NSample,NLevel,Plot,Threshold);
715 glColorMaterial(GL_FRONT_AND_BACK,GL_EMISSION);
716 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
728 for(
int s=0;s<NSample-1;s++){
729 for(
int ss=0;ss<NSample-1;ss++){
730 for(
int l=0;l<NLevel;l++){
731 if(l==0 || l == 3)
continue;
732 glColor4f((
double)l*.25,.5,.8,1.);
733 v00.
x[
CLat1]=(s+.5)*FactC1;
734 v00.
x[
CLat2]=(ss+.5)*FactC2;
735 v00.
x[
CNorm]=Plot[l][s*NSample+ss]*FactCN;
736 v01.
x[
CLat1]=(s+1.5)*FactC1;
737 v01.
x[
CLat2]=(ss+.5)*FactC2;
738 v01.
x[
CNorm]=Plot[l][(s+1)*NSample+ss]*FactCN;
739 v11.
x[
CLat1]=(s+1.5)*FactC1;
740 v11.
x[
CLat2]=(ss+1.5)*FactC2;
741 v11.
x[
CNorm]=Plot[l][(s+1)*NSample+ss+1]*FactCN;
742 v10.
x[
CLat1]=(s+.5)*FactC1;
743 v10.
x[
CLat2]=(ss+1.5)*FactC2;
744 v10.
x[
CNorm]=Plot[l][s*NSample+ss+1]*FactCN;
745 if(Plot[l][(s)*NSample+ss] <= 0.){
747 v00.
x[
CNorm]=Plot[3][(s)*NSample+ss+1]*FactCN;
749 v00.
x[
CNorm]=Plot[2][(s)*NSample+ss+1]*FactCN;
751 v00.
x[
CNorm]=Plot[1][(s)*NSample+ss+1]*FactCN;
753 v00.
x[
CNorm]=Plot[0][(s)*NSample+ss+1]*FactCN;
754 if(v00.
x[
CNorm] <= 0.)
continue;
756 if(Plot[l][(s+1)*NSample+ss] <= 0.){
758 v01.
x[
CNorm]=Plot[3][(s)*NSample+ss]*FactCN;
760 v01.
x[
CNorm]=Plot[2][(s)*NSample+ss]*FactCN;
762 v01.
x[
CNorm]=Plot[1][(s)*NSample+ss]*FactCN;
764 v01.
x[
CNorm]=Plot[0][(s)*NSample+ss]*FactCN;
765 if(v01.
x[
CNorm] <= 0.)
continue;
767 if(Plot[l][s*NSample+ss+1] <= 0.){
769 v10.
x[
CNorm]=Plot[3][(s)*NSample+ss]*FactCN;
771 v10.
x[
CNorm]=Plot[2][(s)*NSample+ss]*FactCN;
773 v10.
x[
CNorm]=Plot[1][(s)*NSample+ss]*FactCN;
775 v10.
x[
CNorm]=Plot[0][(s)*NSample+ss]*FactCN;
776 if(v10.
x[
CNorm] <= 0.)
continue;
778 if(Plot[l][(s+1)*NSample+(ss+1)] <= 0.){
780 v11.
x[
CNorm]=Plot[3][(s)*NSample+ss+1]*FactCN;
782 v11.
x[
CNorm]=Plot[2][(s)*NSample+ss+1]*FactCN;
784 v11.
x[
CNorm]=Plot[1][(s)*NSample+ss+1]*FactCN;
786 v11.
x[
CNorm]=Plot[0][(s)*NSample+ss+1]*FactCN;
787 if(v11.
x[
CNorm] <= 0.)
continue;
795 for(
int l=0;l<NLevel;l++){
803 double *Plot = (
double *) calloc(SQR(NSample),
sizeof(double));
804 double *PlotR = (
double *) calloc(SQR(NSample),
sizeof(double));
809 double Max = 1000000.;
810 for(
int s=0;s<SQR(NSample);s++){
812 if(Max < Plot[s]) Max = Plot[s];
813 if(Min > Plot[s]) Min = Plot[s];
825 double *Points = (
double *)calloc(NSample,
sizeof(
double));
827 double Max1=0.,Max2=0.;
828 for(
int s=0;s<NSample;s++){
829 if(Max1 < Points[s]){
834 if(Max2 < Points[s]){
839 for(
int s=0;s<NSample;s++){
843 for(
int s=NSample/2;s<NSample-1;s++){
846 glColor4f(1.,0.,1.,1.);
847 glVertex3d((2*s-NSample)*Unity,0.,Points[s]);
848 glVertex3d((2*(s+1)-NSample)*Unity,0.,Points[s+1]);
860 Weight.
a0 = 1.; Weight.
a1 = 0.; Weight.
a2=1.;Weight.
a3=0.;Weight.
a4=0.;
868 for(
int s=1;s<NSample-2;s++){
869 for(
int ss=1;ss<NSample-2;ss++){
872 glColor4f(0.,1.,1.,1.);
873 glBegin(GL_TRIANGLES);
874 glNormal3f(0.,0.,1.);
875 glVertex3d((s+.5)*Unity,(ss+.5)*Unity,Resp->
Val(s,ss)*
InvScaleUn);
876 glVertex3d((s+1.5)*Unity,(ss+.5)*Unity,Resp->
Val(s+1,ss)*
InvScaleUn);
877 glVertex3d((s+1.5)*Unity,(ss+1.5)*Unity,Resp->
Val(s+1,ss+1)*
InvScaleUn);
881 glColor4f(0.5,.0,0.5,1.);
882 glBegin(GL_TRIANGLES);
883 glNormal3f(0.,0.,1.);
884 glVertex3d((s+.5)*Unity,(ss+.5)*Unity,Resp->
Val(s,ss)*
InvScaleUn);
885 glVertex3d((s+1.5)*Unity,(ss+1.5)*Unity,Resp->
Val(s+1,ss+1)*
InvScaleUn);
886 glVertex3d((s+.5)*Unity,(ss+1.5)*Unity,Resp->
Val(s,ss+1)*
InvScaleUn);
896 if(CoordN < 0 || CoordN > 3)
return;
900 double InvIsoipse = 1./(double)NIsoipse;
901 int Coord1 = (CoordN+1)%3;
902 int Coord2 = (CoordN+2)%3;
903 int *Plot = (
int *) calloc(Values*Values*NIsoipse,
sizeof(
int));
904 for(
int p=0;p<
pNPart();p++){
905 int v = (int) (
pPos(p,Coord1)*NIsoipse/
pEdge(Coord1));
906 if( v < 0 || v > Values)
continue;
907 int vv = (int) (
pPos(p,Coord2)*NIsoipse/
pEdge(Coord2));
908 if( vv < 0 || vv > Values)
continue;
909 int i = (int) (
pPos(p,CoordN)*NIsoipse/
pEdge(CoordN));
910 if( i < 0 || i > NIsoipse)
continue;
911 Plot[(v*Values + vv)*NIsoipse + i] = p;
913 for(
int i=0;i<NIsoipse;i++){
915 glNormal3f(0.,0.,1.);
917 for(
int p=0;p<
pNPart();p++){
918 int v = (int) (
pPos(p,CoordN)*NIsoipse/
pEdge(CoordN));
919 if( v != i)
continue;
920 for(
int v=0;v<Values-1;v++){
923 for(
int vv=0;vv<Values;vv++){
924 if(Plot[(v*Values+vv)*NIsoipse+i] == 0 && Plot[(v*Values+vv+1)*NIsoipse+i] != 0)
925 pMin = Plot[(v*Values+vv+1)*NIsoipse+i];
926 if(Plot[(v*Values+vv)*NIsoipse+i] != 0 && Plot[(v*Values+vv+1)*NIsoipse+i] == 0){
927 pMax = Plot[(v*Values+vv)*NIsoipse+i];
932 glVertex3d(
pPos(pMax,Coord1)*InvScaleUn,
pPos(pMax,Coord2)*InvScaleUn,Zed);
942 PART *Pn = (
PART *)calloc(NSample*NSample,
sizeof(
PART));
957 double *Pos = (
double *)calloc(NCell*NDim,
sizeof(
double));
958 for(
int c=0;c<NCell;c++){
959 for(
int d=0;d<NDim;d++){
960 Pos[c*NDim+d] =
Ch[c].
Pos[d];
968 for(
int c=0;c<NCell;c++){
970 glColor4f(.2,.5,.3,1.);
972 glNormal3f(0.,0.,1.);
978 glColor4f(.8,.2,.5,1.);
981 Ch[c].Pos[1]*InvScaleUn,.5*
pEdge(2)*InvScaleUn);
990 int **Triangle = (
int **)calloc(Vertex+1,
sizeof(
int));
991 for(
int v=0;v<Vertex+1;v++){
992 *(Triangle+v) = (
int *)calloc(
pNChain(),
sizeof(
int));
1000 if(!CHAIN_IF_TYPE(Chc,
NChType))
continue;
1002 int l = Triangle[Vertex-1][c];
1003 int l1 = Triangle[0][c];
1008 for(
int v=0;v<Vertex;v++){
1010 if(v<Vertex-1) l1 = Triangle[v+1][c];
1011 else l1 = Triangle[0][c];
1015 double Shift[3] = {0.,0.,0.};
1016 for(
int d=0;d<3;d++) Shift[d] = -floor((
Ch[c].Pos[d]-
Ch[l].Pos[d])/
pEdge(d)+.5)*
pEdge(d);
1019 glNormal3f(0.,0.,1.);
1021 glVertex3f((
Ch[l].Pos[0]-Shift[0])*InvScaleUn,(
Ch[l].Pos[1]-Shift[1])*InvScaleUn,(
Ch[l].Pos[2]-Shift[2])*InvScaleUn*ScaleFact);
1028 glColor4f(1.,1.,0.,1.);
1033 Ch[c].Pos[1]*InvScaleUn,
1035 glColor4f(1.,0.,0.,1.);
1040 glColor3f(1.0,1.0,1.0);
1042 glRasterPos3f(
Ch[c].Pos[0]*InvScaleUn,
1043 Ch[c].Pos[1]*InvScaleUn,
1044 Ch[c].Pos[2]*InvScaleUn*ScaleFact);
1045 char *Numero = (
char*)calloc(20,
sizeof(
char));
1046 sprintf(Numero,
"%d",c);
1047 for(
int i=0;i<strlen(Numero);i++)
1048 glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,Numero[i]);
1069 printf(
"Dx %lf NLat1 %d NLat2 %d %d\n",Dx,NLat1,NLat2,SQR(NLat1) + SQR(NLat2));
1070 if( NLat1*NLat2 !=
pNPart())
return;
1080 for(
int nx = 0;nx<NLat1-2;nx+=2){
1081 for(
int ny = 0;ny<NLat2-2;ny+=2){
1082 int l1 = nx*NLat2 + ny;
1083 int l2 = nx*NLat2 + ny + 1;
1084 int l3 = (nx+1)*NLat2 + ny + 1;
1085 int l4 = (nx+1)*NLat2 + ny;
1106 double VolEl =
pVol()/(double)CUB(NSample);
1107 double *Plot = (
double *)calloc(CUBE(NSample),
sizeof(double));
1111 for(
int p=0;p<
pNPart();p++){
1116 int sx = (int)(Posx*
pInvEdge(0)*NSample);
1117 int sy = (int)(Posy*
pInvEdge(1)*NSample);
1118 int sz = (int)(Posz*
pInvEdge(2)*NSample);
1119 int sTot = (sx*NSample+sy)*NSample+sz;
1120 Plot[sTot] += VolEl;
1121 if(Max < Plot[sTot]) Max = Plot[sTot];
1122 if(Min > Plot[sTot]) Min = Plot[sTot];
1125 printf(
"Min %lf Max %lf Isolevel %lf\n",Min,Max,IsoLevel);
1129 int NVertex = CUBE(2*NSample-1);
1130 double *WeightL = (
double *) calloc(NVertex,
sizeof(
double));
1132 for(
int t=0;t<NTri;t++){
1133 int vRef = Tri[t].
v[0];
1140 for(
int t=0;t<NTri;t++){
1142 int vRef = Tri[t].
v[0];
1143 double Green = WeightL[vRef]*MaxW + .3 + .4*
Mat->
Casuale();
1144 glColor4f(0.1,Green,0.2,1.);
1146 glBegin(GL_TRIANGLES);
1148 Tri[t].n[0].x[1]*InvScaleUn,
1150 glVertex3f(Tri[t].p[0].x[0]*InvScaleUn,
1151 Tri[t].p[0].x[1]*InvScaleUn,
1152 Tri[t].p[0].x[2]*InvScaleUn*ScaleFact);
1153 glNormal3f(Tri[t].n[1].x[0]*InvScaleUn,
1154 Tri[t].n[1].x[1]*InvScaleUn,
1155 Tri[t].n[1].x[2]*InvScaleUn*ScaleFact);
1156 glVertex3f(Tri[t].p[1].x[0]*InvScaleUn,
1157 Tri[t].p[1].x[1]*InvScaleUn,
1158 Tri[t].p[1].x[2]*InvScaleUn*ScaleFact);
1159 glNormal3f(Tri[t].n[2].x[0]*InvScaleUn,
1160 Tri[t].n[2].x[1]*InvScaleUn,
1161 Tri[t].n[2].x[2]*InvScaleUn*ScaleFact);
1162 glVertex3f(Tri[t].p[2].x[0]*InvScaleUn,
1163 Tri[t].p[2].x[1]*InvScaleUn,
1164 Tri[t].p[2].x[2]*InvScaleUn*ScaleFact);
1167 glColor4f(0.1,.3,1.,1.);
1169 glVertex3d(Tri[t].c.x[0]*InvScaleUn,
1170 Tri[t].
c.
x[1]*InvScaleUn,
1171 Tri[t].
c.
x[2]*InvScaleUn*ScaleFact);
1172 glVertex3d((Tri[t].c.x[0]+Tri[t].
n[0].
x[0])*InvScaleUn,
1173 (Tri[t].
c.
x[1]+Tri[t].
n[0].
x[1])*InvScaleUn,
1174 (Tri[t].
c.
x[2]+Tri[t].
n[0].
x[2])*InvScaleUn*ScaleFact);
void DrDensity()
(rad,norm,dens) visualisation
XYZ n[3]
Normal to the vertices.
double a4
a0 + a1*x + a2*x^2 + a3*x^3 + a4^4
CHAIN * Ch
Information on all chains.
void DrSmooth(double *Plot, int NSample, double Min, double Max)
Draw the surface in triangles.
void DrStalk()
Visualize the surface from Stalk.xvl.
double InvScaleUn
Define the shrink factor between the box edges.
int NLink
How many links per particle.
double x[3]
Cartesian coordinates.
double NanoDist2(double *Pos, int n)
Pointer to a generic function.
int Type
Type of the chain (see list CHAIN_)
double pVel(int p, int d)
Return the velocity.
LINKS * Ln
Array of linking between the particles.
Draw provides the basic configuration of the openGL libraries used in every derived program...
void DrIsoipse(int NBin, int NIsoipse, int CoordN)
Draws all the same quotes surfaces.
void DrQuad()
Call a square in every particle position.
void DrCreateStalk()
Visualize the surface calculated in Stalk()
double Normalize()
Normlizes a Vettore.
void DrIsolevel(int NSample, double IsoLevel)
Defines the triangles at the boundaries of the density close to the IsoLevel value.
void DrPolygon()
Every particle is traeted as a vertex.
int pChain(int p)
Return the chain.
Geometrical operations on vectors.
void DrPotential()
Potential function.
void DrDerivative()
Samples the surface, applies a 2d matrix derivative and draws the surface in triangles.
double pInvEdge(int d)
Inverted xyzr edges of the simulation box.
void DrTriaContour(Vettore *v00, Vettore *v01, Vettore *v11)
Draw the contour of three vectors.
int NChType
Type of chain selected.
void DrNormalPoint(int p, int NEdge)
Draw the normal to a point.
MOMENTI SampleSurfaceMem(int NSample)
Allocate and fill PlotMem with the particle average position.
int pType(int p)
Return the type.
int CLat2
lateral coordinate
VAR_TRIANGLE * MarchingCubes(double *Plot, int NSample, double IsoLevel, int *NTri)
Defines the triangles close to the IsoLevel of the 3d density Plot.
void DepthMap(double Val, GLfloat *Color)
Pointer to a generic function.
void DrSample(int NSample)
Samples the surface and draws it in triangles.
double * PlotMem
Particle position/density on the square lattice.
double * x
Where the data are stored.
double ScaleFact
Normal scaling factor (z zooming)
void DrDoubleTria(Vettore *v00, Vettore *v01, Vettore *v11, Vettore *v10, Vettore *vN)
Double triangle defined by four vectors.
void Rescale(double NewLength)
Rescale the total length of the vector.
double pVol()
xyzr edges of the simulation box
int v[3]
Reference for the vectors.
void DrQuad1()
Intensity scheme.
double pEdge(int d)
xyzr edges of the simulation box
double Saturation
Saturation of the color (increase intensity)
double a3
a0 + a1*x + a2*x^2 + a3*x^3 + a4^4
Moments of a distribution.
int NPType
Type of particle selected.
int * Link
with whom is bonded
int NEdge
Number of particles per edge.
double Casuale()
Random uniform number.
double Val(int row)
Returns a value in 1d.
void DrawNano(int n)
Pointer to a generic function.
int IfMaterial
Activate the illumination for a specific material.
void DrVoronoi()
Voronoi tassellation.
void DrSurface()
Draws the surface like a sheet using the chains position.
double ExtParam
External parameter (e.g. for MarchingCubes)
int pNNano()
Number of nanoparticles.
double a2
a0 + a1*x + a2*x^2 + a3*x^3 + a4^4
double a1
a0 + a1*x + a2*x^2 + a3*x^3 + a4^4
GLuint Particles
Refers to the list of the total position of the particles which will be generated in another program...
void Stalk(int NSample, int NLevel, double **Plot, double Threshold)
Following the contour of a stalk.
void DrShell()
Draw the outer shell.
void DrSpectrum()
Calculate the spectrum of the surface and draws it in triangles.
double Pos[4]
xyzr Postion of the chain
void DrInterpSurface()
Boh.
Matrice computes the algebric operations on matrices.
void Spettro2d(double *Points, int NSample, int Type)
1-d spectrum of a surface
void Tile()
Cover a regular square grid of points with tiles.
Matematica * Mat
Implementation of all usefull algorythms.
double pVelMax(int d)
Maximum velocity.
double pPos(int p, int d)
Return back folded position.
int pNChain()
Number of chain.
int CLat1
lateral coordinate
Information of every particle.
int SpatialDerivative(Matrice *Surface, Matrice *Resp, SPLINE Weight, int NSample)
Perform a spatial derivative on a surface.
int Surface(int NBin, int Coord)
Area of a surfuce projected on the coordinate Coord surf.
double a0
a0 + a1*x + a2*x^2 + a3*x^3 + a4^4
void Mult(double Fact)
multiply by a scalar
void DrSquareMesh()
Draw the polygons for a square mesh.
PART * Pm
Particle information of all particle.
void DrTria(Vettore *v00, Vettore *v01, Vettore *v11, Vettore *vN)
single triangle defined by three vectors
void SampleSurface(double *Plot, int NSample, int Type)
Define a normal coordinate for every patch.
void NormalSurf(const Vettore *u, const Vettore *v, const Vettore *w)
Computes the normal to the plane described by u,v,w.
void DrField(int NGrid, double IsoLevel, int nNano, FILE *FWrite)
Draw a scalar field.
int CNorm
Normal coordinate.
int pNPart()
Number of particle.