///<summary>This gets the entire set of lines for one perio row for one sequence type. The allowed types are GM, MGJ, and CAL. Each LineSimple is a series of connected lines. But the result could have interruptions, so we return a list, each item in the list being continuous. There may be zero items in the list. Each line in the list is guaranteed to have at least 2 points in it.</summary> public List<LineSimple> GetHorizontalLines(PerioSequenceType sequenceType,bool isMaxillary,bool isBuccal) { List<LineSimple> retVal=new List<LineSimple>(); int startTooth=1; int stopTooth=17;//doesn't perform a loop for 17. if(!isMaxillary) { startTooth=32;//We still go Left to Right, even on mand. stopTooth=16; } LineSimple line=new LineSimple(); Vertex3f vertex; int val1=-1; int val2=-1; int val3=-1; int t=startTooth; PerioSurf surf1; PerioSurf surf2; PerioSurf surf3; while(t!=stopTooth){ if(!ListToothGraphics[t.ToString()].Visible && !ListToothGraphics[t.ToString()].IsImplant) { //stop any existing line. if(line.Vertices.Count==1) {//if there is already one point, then clear it, because a line can't have one point. line.Vertices.Clear(); } if(line.Vertices.Count>1) {//if 2 or more points in the line, then add the line to the result. retVal.Add(line); line=new LineSimple();//and initialize a new line for future points. } //increment to next tooth if(isMaxillary) { t++; } else { t--; } continue; } //We are considering 3 points per tooth. Reinitialize for the new tooth. val1=-1; val2=-1; val3=-1; surf1=PerioSurf.None; surf2=PerioSurf.None; surf3=PerioSurf.None; for(int i=0;i<ListPerioMeasure.Count;i++) { if(ListPerioMeasure[i].IntTooth!=t) { continue; } if(ListPerioMeasure[i].SequenceType!=sequenceType) { continue; } //so we are now on the specific PerioMeasure for this sequence and tooth. It contains 6 values, and we will use 3. PerioMeasure pmGM=null; //We need to draw MGJ as dist from GM, not CEJ if(sequenceType==PerioSequenceType.MGJ) {//we only care about this if we are trying to calculate MGJ for(int m=0;m<ListPerioMeasure.Count;m++) { if(ListPerioMeasure[m].IntTooth==t && ListPerioMeasure[m].SequenceType==PerioSequenceType.GingMargin) { pmGM=ListPerioMeasure[m];//get the GM for this same tooth. break; } } } if(isBuccal) { if(ToothGraphic.IsRight(t.ToString())) { val1=ListPerioMeasure[i].DBvalue; val2=ListPerioMeasure[i].Bvalue; val3=ListPerioMeasure[i].MBvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.DBvalue!=-1) { val1+=PerioMeasures.AdjustGMVal(pmGM.DBvalue); } if(pmGM.Bvalue!=-1) { val2+=PerioMeasures.AdjustGMVal(pmGM.Bvalue); } if(pmGM.MBvalue!=-1) { val3+=PerioMeasures.AdjustGMVal(pmGM.MBvalue); } } surf1=PerioSurf.DB; surf2=PerioSurf.B; surf3=PerioSurf.MB; } else {//for UL and LL val1=ListPerioMeasure[i].MBvalue; val2=ListPerioMeasure[i].Bvalue; val3=ListPerioMeasure[i].DBvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.MBvalue!=-1) { val1+=PerioMeasures.AdjustGMVal(pmGM.MBvalue); } if(pmGM.Bvalue!=-1) { val2+=PerioMeasures.AdjustGMVal(pmGM.Bvalue); } if(pmGM.DBvalue!=-1) { val3+=PerioMeasures.AdjustGMVal(pmGM.DBvalue); } } surf1=PerioSurf.MB; surf2=PerioSurf.B; surf3=PerioSurf.DB; } } else {//lingual if(ToothGraphic.IsRight(t.ToString())) { val1=ListPerioMeasure[i].DLvalue; val2=ListPerioMeasure[i].Lvalue; val3=ListPerioMeasure[i].MLvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.DLvalue!=-1) { val1+=PerioMeasures.AdjustGMVal(pmGM.DLvalue); } if(pmGM.Lvalue!=-1) { val2+=PerioMeasures.AdjustGMVal(pmGM.Lvalue); } if(pmGM.MLvalue!=-1) { val3+=PerioMeasures.AdjustGMVal(pmGM.MLvalue); } } surf1=PerioSurf.DL; surf2=PerioSurf.L; surf3=PerioSurf.ML; } else {//for UL and LL val1=ListPerioMeasure[i].MLvalue; val2=ListPerioMeasure[i].Lvalue; val3=ListPerioMeasure[i].DLvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.MLvalue!=-1) { val1+=PerioMeasures.AdjustGMVal(pmGM.MLvalue); } if(pmGM.Lvalue!=-1) { val2+=PerioMeasures.AdjustGMVal(pmGM.Lvalue); } if(pmGM.DLvalue!=-1) { val3+=PerioMeasures.AdjustGMVal(pmGM.DLvalue); } } surf1=PerioSurf.ML; surf2=PerioSurf.L; surf3=PerioSurf.DL; } } } //We have now filled our 3 points with values and need to evaluate those values. //Any or all of the values may still be -1. if(val1==-1) { //we won't add a point to this line if(line.Vertices.Count==1) {//if there is already one point, then clear it, because a line can't have one point. line.Vertices.Clear(); } if(line.Vertices.Count>1) {//if 2 or more points in the line, then add the line to the result. retVal.Add(line); line=new LineSimple();//and initialize a new line for future points. } } else {//just add a point to the current line. vertex=new Vertex3f(); vertex.Z=0;//we don't use z if(isMaxillary) { //this is safe to run on all sequence types because -1 has already been handled and because other types wouldn't have values > 100. //Also safe to process on the vals that are MGJ, calculated above, because if they are ever negative, //it would be an obvious entry error, and the MGJ line would just harmlessly disappear for -1 vals. vertex.Y=PerioMeasures.AdjustGMVal(val1); } else { vertex.Y=-PerioMeasures.AdjustGMVal(val1); } vertex.X=GetXShiftPerioSite(t,surf1)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //val2-------------------------- if(val2==-1) { if(line.Vertices.Count==1) { line.Vertices.Clear(); } if(line.Vertices.Count>1) { retVal.Add(line); line=new LineSimple(); } } else { vertex=new Vertex3f(); vertex.Z=0; if(isMaxillary) { vertex.Y=PerioMeasures.AdjustGMVal(val2); } else { vertex.Y=-PerioMeasures.AdjustGMVal(val2); } vertex.X=GetXShiftPerioSite(t,surf2)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //val3------------------------- if(val3==-1) { if(line.Vertices.Count==1) { line.Vertices.Clear(); } if(line.Vertices.Count>1) { retVal.Add(line); line=new LineSimple(); } } else { vertex=new Vertex3f(); vertex.Z=0; if(isMaxillary) { vertex.Y=PerioMeasures.AdjustGMVal(val3); } else { vertex.Y=-PerioMeasures.AdjustGMVal(val3); } vertex.X=GetXShiftPerioSite(t,surf3)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //increment to next tooth if(isMaxillary) { t++; } else { t--; } } if(line.Vertices.Count>1) { retVal.Add(line); } return retVal; }
private List <Vector3> LineSimpleToVector3List(LineSimple lineSimple){ List <Vector3> vectorList=new List<Vector3> (); for(int p=0;p<lineSimple.Vertices.Count;p++){ vectorList.Add(new Vector3(lineSimple.Vertices[p].X,lineSimple.Vertices[p].Y,lineSimple.Vertices[p].Z)); } return vectorList; }
///<summary>For any given tooth, there may only be one line in the returned list, or some teeth might have a few lines representing the root canals.</summary> public List<LineSimple> GetRctLines() { List<LineSimple> retVal=new List<LineSimple>(); LineSimple line; if(toothID=="1") { line=new LineSimple( -.7f,9.6f,1.6f, .6f,8,1.6f , 1.2f,5.8f,1.6f , .8f,0,.9f); retVal.Add(line); line=new LineSimple( -1.8f,9.5f,1.6f, -1.6f,8,1.6f, -1.6f,5.8f,1.6f, -.9f,0,.9f); retVal.Add(line); } if(toothID=="16") { line=new LineSimple( .7f,9.6f,1.6f, -.6f,8,1.6f, -1.2f,5.8f,1.6f, -.8f,0,.9f); retVal.Add(line); line=new LineSimple( 1.8f,9.5f,1.6f , 1.6f,8,1.6f , 1.6f,5.8f,1.6f , .9f,0,.9f ); retVal.Add(line); } if(toothID=="2") { line=new LineSimple( .3f,10.6f,3.4f , 1.4f,8,3.2f , 1.7f,5,1.9f , .9f,0,1f); retVal.Add(line); line=new LineSimple( -1.8f,10.5f,3.4f , -2,7,3.2f , -1.7f,4,1.9f , -1,0,1.1f ); retVal.Add(line); line=new LineSimple( -2,11.5f,-3.7f , -.6f,6.3f,-4 , 0,0,-2.3f); retVal.Add(line); } if(toothID=="15") { line=new LineSimple( -.3f,10.6f,3.4f , -1.4f,8,3.2f , -1.7f,5,1.9f , -.9f,0,1f ); retVal.Add(line); line=new LineSimple( 1.8f,10.5f,3.4f , 2,7,3.2f , 1.7f,4,1.9f , 1,0,1.1f); retVal.Add(line); line=new LineSimple( 2,11.5f,-3.7f , .6f,6.3f,-4 , 0,0,-2.3f ); retVal.Add(line); } if(toothID=="3") { line=new LineSimple( 1.4f,11.5f,3.4f , 2.2f,9.4f,3.2f , 2.4f,6.7f,3.2f , 1.2f,0,1.1f); retVal.Add(line); line=new LineSimple( -2.7f,11.5f,3.4f , -2.9f,9,3.2f , -2.6f,5,3.2f , -1.2f,0,1.1f ); retVal.Add(line); line=new LineSimple( 0,12.5f,-4.3f, 0,9.4f,-4.3f , 0,0,-2.2f ); retVal.Add(line); } if(toothID=="14") { line=new LineSimple( -1.4f,11.5f,3.4f, -2.2f,9.4f,3.2f , -2.4f,6.7f,3.2f , -1.2f,0,1.1f); retVal.Add(line); line=new LineSimple( 2.7f,11.5f,3.4f , 2.9f,9,3.2f , 2.6f,5,3.2f , 1.2f,0,1.1f ); retVal.Add(line); line=new LineSimple( 0,12.5f,-4.3f , 0,9.4f,-4.3f , 0,0,-2.2f ); retVal.Add(line); } if(toothID=="4") { line=new LineSimple( 0,13.5f,1.2f , -.2f,10,.6f , 0,0,0 ); retVal.Add(line); } if(toothID=="13") { line=new LineSimple( 0,13.5f,1.2f , .2f,10,.6f , 0,0,0 ); retVal.Add(line); } if(toothID=="5") { line=new LineSimple( -1.1f,13.5f,1.6f , 0,6,1.6f , 0,0,1 ); retVal.Add(line); } if(toothID=="12") { line=new LineSimple( 1.1f,13.5f,1.6f , 0,6,1.6f , 0,0,1); retVal.Add(line); } if(toothID=="6") { line=new LineSimple( -.4f,16.5f,0 , 0,11,0 , 0,0,0); retVal.Add(line); } if(toothID=="11") { line=new LineSimple( .4f,16.5f,0 , 0,11,0, 0,0,0); retVal.Add(line); } if(toothID=="7") { line=new LineSimple( -.8f,12.5f,.6f , -.3f,10,0 , 0,0,0); retVal.Add(line); } if(toothID=="10") { line=new LineSimple( .8f,12.5f,.6f , .3f,10,0 , 0,0,0); retVal.Add(line); } if(toothID=="8"){ line=new LineSimple( 0,12.6f,0 , 0,0,0 ); retVal.Add(line); } if(toothID=="9") { line=new LineSimple( 0,12.6f,0 , 0,0,0 ); retVal.Add(line); } if(toothID=="25" || toothID=="26") { line=new LineSimple( -.5f,-12,0 , -.2f,-9,0 , 0,0,0 ); retVal.Add(line); } if(toothID=="24" || toothID=="23") { line=new LineSimple( .5f,-12,0 , .2f,-9,0 , 0,0,0 ); retVal.Add(line); } if(toothID=="27") { line=new LineSimple( -.5f,-15.5f,0, -.1f,-13,0 , 0,0,0 ); retVal.Add(line); } if(toothID=="22") { line=new LineSimple( .5f,-15.5f,0 , .1f,-13,0 , 0,0,0 ); retVal.Add(line); } if(toothID=="28") { line=new LineSimple( -.2f,-13.5f,0 , 0,0,0 ); retVal.Add(line); } if(toothID=="21") { line=new LineSimple( .2f,-13.5f,0 , 0,0,0 ); retVal.Add(line); } if(toothID=="29") { line=new LineSimple( -.3f,-14,0 , 0,-12,0 , 0,0,0 ); retVal.Add(line); } if(toothID=="20") { line=new LineSimple( .3f,-14,0 , 0,-12,0 , 0,0,0 ); retVal.Add(line); } if(toothID=="30") { line=new LineSimple( .9f,-13.5f,0 , 2.2f,-10,0 , 2.6f,-7,0 , 1.7f,0,0); retVal.Add(line); line=new LineSimple( -4.3f,-13.5f,0 , -4f,-9,0 , -3.3f,-5,0 , -1.7f,0,0 ); retVal.Add(line); } if(toothID=="19") { line=new LineSimple( -.9f,-13.5f,0 , -2.2f,-10,0 , -2.6f,-7,0 , -1.7f,0,0 ); retVal.Add(line); line=new LineSimple( 4.3f,-13.5f,0 , 4f,-9,0 , 3.3f,-5,0 , 1.7f,0,0 ); retVal.Add(line); } if(toothID=="31") { line=new LineSimple( 0,-12.5f,0 , 1.8f,-7.5f,0 , 2.2f,-4,0 , 1.7f,0,0); retVal.Add(line); line=new LineSimple( -3.4f,-12.5f,0 , -3.4f,-8,0 , -3f,-5,0 , -1.7f,0,0); retVal.Add(line); } if(toothID=="18") { line=new LineSimple( 0,-12.5f,0 , -1.8f,-7.5f,0 , -2.2f,-4,0 , -1.7f,0,0 ); retVal.Add(line); line=new LineSimple( 3.4f,-12.5f,0 , 3.4f,-8,0 , 3f,-5,0 , 1.7f,0,0 ); retVal.Add(line); } if(toothID=="32") { line=new LineSimple( -.7f,-10.5f,0 , .8f,-7.5f,0 , 1.7f,-4,0 , 1.6f,0,0 ); retVal.Add(line); line=new LineSimple( -3.2f,-10.5f,0 , -3.4f,-8,0 , -3f,-5,0 , -1.7f,0,0 ); retVal.Add(line); } if(toothID=="17") { line=new LineSimple( .7f,-10.5f,0 , -.8f,-7.5f,0 , -1.7f,-4,0 , -1.6f,0,0); retVal.Add(line); line=new LineSimple( 3.2f,-10.5f,0 , 3.4f,-8,0 , 3f,-5,0 , 1.7f,0,0); retVal.Add(line); } return retVal; }
///<summary>This gets the entire set of lines for one perio row for one sequence type. The allowed types are GM, MGJ, and CAL. Each LineSimple is a series of connected lines. But the result could have interruptions, so we return a list, each item in the list being continuous. There may be zero items in the list. Each line in the list is guaranteed to have at least 2 points in it.</summary> public List<LineSimple> GetHorizontalLines(PerioSequenceType sequenceType,bool isMaxillary,bool isBuccal) { List<LineSimple> retVal=new List<LineSimple>(); int startTooth=1; int stopTooth=17;//doesn't perform a loop for 17. if(!isMaxillary) { startTooth=32;//We still go Left to Right, even on mand. stopTooth=16; } LineSimple line=new LineSimple(); Vertex3f vertex; int val1=-1; int val2=-1; int val3=-1; int t=startTooth; PerioSurf surf1; PerioSurf surf2; PerioSurf surf3; while(t!=stopTooth){ if(!ListToothGraphics[t.ToString()].Visible && !ListToothGraphics[t.ToString()].IsImplant) { //stop any existing line. if(line.Vertices.Count==1) {//if there is already one point, then clear it, because a line can't have one point. line.Vertices.Clear(); } if(line.Vertices.Count>1) {//if 2 or more points in the line, then add the line to the result. retVal.Add(line); line=new LineSimple();//and initialize a new line for future points. } //increment to next tooth if(isMaxillary) { t++; } else { t--; } continue; } //We are considering 3 points per tooth. Reinitialize for the new tooth. val1=-1; val2=-1; val3=-1; surf1=PerioSurf.None; surf2=PerioSurf.None; surf3=PerioSurf.None; for(int i=0;i<ListPerioMeasure.Count;i++) { if(ListPerioMeasure[i].IntTooth!=t) { continue; } if(ListPerioMeasure[i].SequenceType!=sequenceType) { continue; } PerioMeasure pmGM=null; //We need to draw MGJ as dist from GM, not CEJ if(sequenceType==PerioSequenceType.MGJ) { for(int m=0;m<ListPerioMeasure.Count;m++) { if(ListPerioMeasure[m].IntTooth==t && ListPerioMeasure[m].SequenceType==PerioSequenceType.GingMargin) { pmGM=ListPerioMeasure[m]; break; } } } if(isBuccal) { if(ToothGraphic.IsRight(t.ToString())) { val1=ListPerioMeasure[i].DBvalue; val2=ListPerioMeasure[i].Bvalue; val3=ListPerioMeasure[i].MBvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.DBvalue!=-1) { val1+=pmGM.DBvalue; } if(pmGM.Bvalue!=-1) { val2+=pmGM.Bvalue; } if(pmGM.MBvalue!=-1) { val3+=pmGM.MBvalue; } } surf1=PerioSurf.DB; surf2=PerioSurf.B; surf3=PerioSurf.MB; } else {//for UL and LL val1=ListPerioMeasure[i].MBvalue; val2=ListPerioMeasure[i].Bvalue; val3=ListPerioMeasure[i].DBvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.MBvalue!=-1) { val1+=pmGM.MBvalue; } if(pmGM.Bvalue!=-1) { val2+=pmGM.Bvalue; } if(pmGM.DBvalue!=-1) { val3+=pmGM.DBvalue; } } surf1=PerioSurf.MB; surf2=PerioSurf.B; surf3=PerioSurf.DB; } } else {//lingual if(ToothGraphic.IsRight(t.ToString())) { val1=ListPerioMeasure[i].DLvalue; val2=ListPerioMeasure[i].Lvalue; val3=ListPerioMeasure[i].MLvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.DLvalue!=-1) { val1+=pmGM.DLvalue; } if(pmGM.Lvalue!=-1) { val2+=pmGM.Lvalue; } if(pmGM.MLvalue!=-1) { val3+=pmGM.MLvalue; } } surf1=PerioSurf.DL; surf2=PerioSurf.L; surf3=PerioSurf.ML; } else {//for UL and LL val1=ListPerioMeasure[i].MLvalue; val2=ListPerioMeasure[i].Lvalue; val3=ListPerioMeasure[i].DLvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.MLvalue!=-1) { val1+=pmGM.MLvalue; } if(pmGM.Lvalue!=-1) { val2+=pmGM.Lvalue; } if(pmGM.DLvalue!=-1) { val3+=pmGM.DLvalue; } } surf1=PerioSurf.ML; surf2=PerioSurf.L; surf3=PerioSurf.DL; } } } //We have now filled our 3 points with values and need to evaluate those values. //Any or all of the values may still be -1. if(val1==-1) { //we won't add a point to this line if(line.Vertices.Count==1) {//if there is already one point, then clear it, because a line can't have one point. line.Vertices.Clear(); } if(line.Vertices.Count>1) {//if 2 or more points in the line, then add the line to the result. retVal.Add(line); line=new LineSimple();//and initialize a new line for future points. } } else {//just add a point to the current line. vertex=new Vertex3f(); vertex.Z=0;//we don't use z if(isMaxillary) { vertex.Y=val1; } else { vertex.Y=-val1; } vertex.X=GetXShiftPerioSite(t,surf1)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //val2-------------------------- if(val2==-1) { if(line.Vertices.Count==1) { line.Vertices.Clear(); } if(line.Vertices.Count>1) { retVal.Add(line); line=new LineSimple(); } } else { vertex=new Vertex3f(); vertex.Z=0; if(isMaxillary) { vertex.Y=val2; } else { vertex.Y=-val2; } vertex.X=GetXShiftPerioSite(t,surf2)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //val3------------------------- if(val3==-1) { if(line.Vertices.Count==1) { line.Vertices.Clear(); } if(line.Vertices.Count>1) { retVal.Add(line); line=new LineSimple(); } } else { vertex=new Vertex3f(); vertex.Z=0; if(isMaxillary) { vertex.Y=val3; } else { vertex.Y=-val3; } vertex.X=GetXShiftPerioSite(t,surf3)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //increment to next tooth if(isMaxillary) { t++; } else { t--; } } if(line.Vertices.Count>1) { retVal.Add(line); } return retVal; }