protected override void Algorithm(ref Cl3DModel p_Model)
        {
            string name = p_Model.ModelFileFolder + p_Model.ModelFileName + ".curv";

            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
            if (!iter.IsValid())
            {
                throw new Exception("Iterator in the model is not valid");
            }

            using (TextWriter tw = new StreamWriter(name, false))
            {
                tw.WriteLine("@----------------------------------------");
                tw.WriteLine("@     Przemyslaw Szeptycki LIRIS 2008");
                tw.WriteLine("@          Face model curvatures");
                tw.WriteLine("@  Model name: " + p_Model.ModelFileName);
                tw.WriteLine("@----------------------------------------");
                tw.WriteLine("@ (PointID) X Y Z");
                tw.WriteLine("@ \tCurvatureName: value");
                do
                {
                    List <String> SpecValList = iter.GetListOfSpecificValues();
                    string        line        = "(" + iter.PointID.ToString(System.Globalization.CultureInfo.InvariantCulture) + ")" + iter.X.ToString(System.Globalization.CultureInfo.InvariantCulture) + " " + iter.Y.ToString(System.Globalization.CultureInfo.InvariantCulture) + " " + iter.Z.ToString(System.Globalization.CultureInfo.InvariantCulture) + "\n";
                    foreach (String SPV in SpecValList)
                    {
                        double val;
                        iter.GetSpecificValue(SPV, out val);
                        line += "\t" + SPV + ": " + val.ToString(System.Globalization.CultureInfo.InvariantCulture) + "\n";
                    }
                    tw.WriteLine(line);
                } while (iter.MoveToNext());

                tw.Close();
            }
        }
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator CenterPoint = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.NoseTip);


            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
            Cl3DModel.Cl3DModelPointIterator max  = iter.CopyIterator();
            float distanceMax = 0;

            do
            {
                float distance = (float)Math.Sqrt(Math.Pow(iter.U, 2) + Math.Pow(iter.V, 2));
                if (distanceMax < distance)
                {
                    distanceMax = distance;
                }
            } while (iter.MoveToNext());

            Complex z0 = new Complex(CenterPoint.U / distanceMax, CenterPoint.V / distanceMax);

            iter = p_Model.GetIterator();
            do
            {
                Complex newPoint = Mobius(m_Theta, z0, new Complex((iter.U / distanceMax), (iter.V / distanceMax)));
                iter.U = (float)newPoint.Real * distanceMax;
                iter.V = (float)newPoint.Imag * distanceMax;
            } while (iter.MoveToNext());
        }
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();

            if (!iter.MoveToPoint(PointNo))
            {
                throw new Exception("The point does not exist");
            }

            return;

            /*
             * Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
             * double minDistance = 0;
             * if (!iter.GetSpecificValue("AllDistancesXYZ", out minDistance))
             *  return;
             * Cl3DModel.Cl3DModelPointIterator minIter = iter.CopyIterator();
             *
             * iter.MoveToNext();
             * do{
             *
             *  double tmpMin = 0;
             *  if (!iter.GetSpecificValue("AllDistancesXYZ", out tmpMin))
             *      continue;
             *
             *  if(tmpMin < minDistance)
             *  {
             *      minDistance = tmpMin;
             *      minIter = iter.CopyIterator();
             *  }
             * }while(iter.MoveToNext());
             * p_Model.AddSpecificPoint(Cl3DModel.eSpecificPoints.UnspecifiedPoint.ToString(), minIter);
             */
        }
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator NoseTip = null;

            if (!p_Model.GetSpecificPoint(m_NoseTipName, ref NoseTip))
            {
                throw new Exception("Cannot find specific point NoseTip");
            }

            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();

            while (iter.IsValid())
            {
                bool isOk = false;
                if (ClTools.IsItInsideSphere(iter.X, iter.Y, iter.Z, NoseTip.X, NoseTip.Y, NoseTip.Z + m_fBottomSphereNoseTipZoffset, m_fBottomSphereRadious))
                {
                    if (ClTools.IsItInsideSphere(iter.X, iter.Y, iter.Z, NoseTip.X, NoseTip.Y, NoseTip.Z + m_fUpperSphereNoseTipZoffset, m_fUpperSphereRadious))
                    {
                        isOk = true;
                    }
                }

                if (!isOk)
                {
                    iter = p_Model.RemovePointFromModel(iter);
                }
                else
                {
                    if (!iter.MoveToNext())
                    {
                        break;
                    }
                }
            }
        }
Пример #5
0
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();

            if (iter.IsValid())
            {
                do
                {
                    double H;
                    double K;
                    double ShapeIndex;

                    if (!iter.GetSpecificValue("Gaussian_25", out K))
                    {
                        continue;
                    }
                    if (!iter.GetSpecificValue("Mean_25", out H))
                    {
                        continue;
                    }

                    if (H < 0 && K > m_ThresholdK) //  Nose
                    {
                        iter.Color = Color.Green;
                    }
                }while (iter.MoveToNext());
            }
        }
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();

            while (iter.IsValid())
            {
                List <Cl3DModel.Cl3DModelPointIterator> neighboors = iter.GetListOfNeighbors();

                foreach (Cl3DModel.Cl3DModelPointIterator neighbor1Ring in neighboors)
                {
                    bool founded = false;
                    foreach (Cl3DModel.Cl3DModelPointIterator neighbor2Ring in neighbor1Ring.GetListOfNeighbors())
                    {
                        foreach (Cl3DModel.Cl3DModelPointIterator neighbor3Ring in neighbor2Ring.GetListOfNeighbors())
                        {
                            if (neighbor3Ring.PointID == iter.PointID)
                            {
                                founded = true;
                                break;
                            }
                        }
                    }
                    if (!founded)
                    {
                        iter.RemoveNeighbor(neighbor1Ring);
                    }
                }

                if (!iter.MoveToNext())
                {
                    break;
                }
            }
        }
        private float CalculateWholeModelArea(Cl3DModel p_Model)
        {
            float Area = 0;
            List <ClTools.ClTriangle> Triangles = null;

            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
            if (iter.IsValid())
            {
                do
                {
                    ClTools.GetListOfTriangles(out Triangles, iter);
                    foreach (ClTools.ClTriangle triangle in Triangles)
                    {
                        if (triangle.AlreadyVisited)
                        {
                            continue;
                        }

                        Area += ClTools.CalculateTriangleArea(triangle);
                        triangle.AlreadyVisited = true;
                    }
                } while (iter.MoveToNext());
            }

            return(Area);
        }
Пример #8
0
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            string name = p_Model.ModelFileFolder + p_Model.ModelFileName + m_sFilePostFix + ".Angle";

            Cl3DModel.Cl3DModelPointIterator NoseTip  = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.NoseTip.ToString());
            Cl3DModel.Cl3DModelPointIterator rightEye = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.RightEyeLeftCorner.ToString());
            Cl3DModel.Cl3DModelPointIterator leftEye  = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.LeftEyeRightCorner.ToString());

            float MeanX = (rightEye.X + leftEye.X) / 2;
            float MeanY = (rightEye.Y + leftEye.Y) / 2;

            float rotation = ClTools.GetAngle2D(MeanX, MeanY, 0, 1);

            rotation = rotation * ((float)Math.PI / 180);


            using (TextWriter tw = new StreamWriter(name, false))
            {
                tw.WriteLine(
                    NoseTip.X.ToString(System.Globalization.CultureInfo.InvariantCulture) + " " +
                    NoseTip.Y.ToString(System.Globalization.CultureInfo.InvariantCulture));

                tw.WriteLine(rotation.ToString(System.Globalization.CultureInfo.InvariantCulture));

                tw.Close();
            }
        }
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator leftLipsCorner  = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.LeftCornerOfLips);
            Cl3DModel.Cl3DModelPointIterator rightLipsCorner = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.RightCornerOfLips);

            Cl3DModel.Cl3DModelPointIterator UpperLip  = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.UpperLip);
            Cl3DModel.Cl3DModelPointIterator BottomLip = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.BottomLip);

            Edge[] edges = new Edge[3];

            int Width   = 0;
            int Height  = 0;
            int OffsetX = 0;
            int OffsetY = 0;

            ClTools.CreateGridBasedOnRangeValues(p_Model, out Map, out Width, out Height, out OffsetX, out OffsetY);

            edges[0] = new Edge((int)leftLipsCorner.RangeImageX - OffsetX, (int)leftLipsCorner.RangeImageY - OffsetY, (int)UpperLip.RangeImageX - OffsetX, (int)UpperLip.RangeImageY - OffsetY);
            edges[1] = new Edge((int)UpperLip.RangeImageX - OffsetX, (int)UpperLip.RangeImageY - OffsetY, (int)BottomLip.RangeImageX - OffsetX, (int)BottomLip.RangeImageY - OffsetY);
            edges[2] = new Edge((int)BottomLip.RangeImageX - OffsetX, (int)BottomLip.RangeImageY - OffsetY, (int)leftLipsCorner.RangeImageX - OffsetX, (int)leftLipsCorner.RangeImageY - OffsetY);
            RemoveTriangle(edges);

            edges[0] = new Edge((int)UpperLip.RangeImageX - OffsetX, (int)UpperLip.RangeImageY - OffsetY, (int)rightLipsCorner.RangeImageX - OffsetX, (int)rightLipsCorner.RangeImageY - OffsetY);
            edges[1] = new Edge((int)rightLipsCorner.RangeImageX - OffsetX, (int)rightLipsCorner.RangeImageY - OffsetY, (int)BottomLip.RangeImageX - OffsetX, (int)BottomLip.RangeImageY - OffsetY);
            edges[2] = new Edge((int)BottomLip.RangeImageX - OffsetX, (int)BottomLip.RangeImageY - OffsetY, (int)UpperLip.RangeImageX - OffsetX, (int)UpperLip.RangeImageY - OffsetY);
            RemoveTriangle(edges);
        }
Пример #10
0
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator LeftEyeRightCornerPoint = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.LeftEyeRightCorner);
            Cl3DModel.Cl3DModelPointIterator RightEyeLeftCornerPoint = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.RightEyeLeftCorner);

            CalculateDistancesFromPoint("UV_LeftEyeRightCornerDistance", LeftEyeRightCornerPoint.U, LeftEyeRightCornerPoint.V, p_Model);
            CalculateDistancesFromPoint("UV_RightEyeLeftCornerDistance", RightEyeLeftCornerPoint.U, RightEyeLeftCornerPoint.V, p_Model);
            CalculateDistancesFromPoint("UV_NoseTipDistance", 0.0f, 0.0f, p_Model);

            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
            do
            {
                double UV_LeftEyeRightCornerDistance = 0;
                iter.GetSpecificValue("UV_LeftEyeRightCornerDistance", out UV_LeftEyeRightCornerDistance);

                double UV_RightEyeLeftCornerDistance = 0;
                iter.GetSpecificValue("UV_RightEyeLeftCornerDistance", out UV_RightEyeLeftCornerDistance);

                double UV_NoseTipDistance = 0;
                iter.GetSpecificValue("UV_NoseTipDistance", out UV_NoseTipDistance);

                double alldistances = Math.Sqrt(Math.Pow(UV_LeftEyeRightCornerDistance, 2) + Math.Pow(UV_RightEyeLeftCornerDistance, 2) + Math.Pow(UV_NoseTipDistance, 2));
                iter.AddSpecificValue("AllDistancesUV", alldistances);
            } while (iter.MoveToNext());
        }
        private void CalculateGeodesicDistancesFromPoint(string DistanceName, Cl3DModel.Cl3DModelPointIterator p_BasicPoint, Cl3DModel p_Model)
        {
            List <Cl3DModel.Cl3DModelPointIterator> ListToCheck    = null;
            List <Cl3DModel.Cl3DModelPointIterator> NewListToCheck = new List <Cl3DModel.Cl3DModelPointIterator>();

            NewListToCheck.Add(p_BasicPoint);
            p_BasicPoint.AddSpecificValue(DistanceName, 0.0f);

            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
            do
            {
                ListToCheck = NewListToCheck;

                NewListToCheck = new List <Cl3DModel.Cl3DModelPointIterator>();

                foreach (Cl3DModel.Cl3DModelPointIterator PointToCheck in ListToCheck)
                {
                    double PointToCheckDistance = 0;
                    if (!PointToCheck.GetSpecificValue(DistanceName, out PointToCheckDistance))
                    {
                        throw new Exception("Cannot get distance value");
                    }

                    PointToCheck.AlreadyVisited = true;

                    List <Cl3DModel.Cl3DModelPointIterator> Neighbors = PointToCheck.GetListOfNeighbors();
                    foreach (Cl3DModel.Cl3DModelPointIterator NeighboorPoint in Neighbors)
                    {
                        double CurrentDistance = PointToCheck - NeighboorPoint;

                        double newDistance = PointToCheckDistance + CurrentDistance;

                        double NeighborOldDistance = 0;
                        if (NeighboorPoint.GetSpecificValue(DistanceName, out NeighborOldDistance))// if point was already visited, check if we dont have sometimes shorter path to it
                        {
                            if (NeighborOldDistance > newDistance)
                            {
                                NeighboorPoint.AddSpecificValue(DistanceName, newDistance);
                            }
                        }
                        else
                        {
                            NeighboorPoint.AddSpecificValue(DistanceName, newDistance);
                        }

                        if (!NeighboorPoint.AlreadyVisited)
                        {
                            NeighboorPoint.AlreadyVisited = true;
                            NewListToCheck.Add(NeighboorPoint);
                        }
                    }
                }
            } while (NewListToCheck.Count != 0);

            iter = p_Model.GetIterator();
            do
            {
                iter.AlreadyVisited = false;
            } while (iter.MoveToNext());
        }
Пример #12
0
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator nose = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.NoseTip.ToString());

            ClTools.CalculateGeodesicDistanceFromSourcePointToAllPoints(nose, Cl3DModel.Cl3DModelPointIterator.eSpecificValues.GeodesicDistanceToNoseTip.ToString());

            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
            do
            {
                double distance = 0;
                if (iter.GetSpecificValue(Cl3DModel.Cl3DModelPointIterator.eSpecificValues.GeodesicDistanceToNoseTip, out distance))
                {
                    if (distance > m_fDistence)
                    {
                        iter = p_Model.RemovePointFromModel(iter);
                    }
                    else
                    {
                        if (!iter.MoveToNext())
                        {
                            break;
                        }
                    }
                }
                else
                {
                    iter = p_Model.RemovePointFromModel(iter);
                }
            }while(iter.IsValid());
        }
Пример #13
0
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator NoseTip = null;

            if (!p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.NoseTip, ref NoseTip))
            {
                throw new Exception("Cannot find specific point NoseTip");
            }

            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();

            while (iter.IsValid())
            {
                bool isOk = false;
                if (iter.Z < NoseTip.X && iter.Z > NoseTip.Z - m_fPlaneDistanceZ)
                {
                    isOk = true;
                }

                if (!isOk)
                {
                    iter = p_Model.RemovePointFromModel(iter);
                }
                else
                {
                    if (!iter.MoveToNext())
                    {
                        break;
                    }
                }
            }
        }
Пример #14
0
 private void CalculateDistancesFromPoint(string DistanceName, float U, float V, Cl3DModel p_Model)
 {
     Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
     do
     {
         double distance = Math.Sqrt(Math.Pow(U - iter.U, 2) + Math.Pow(V - iter.V, 2));
         iter.AddSpecificValue(DistanceName, distance);
     } while (iter.MoveToNext());
 }
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            List <Cl3DModel.Cl3DModelPointIterator>[,] Map = null;

            int   width        = 0;
            int   heinght      = 0;
            float MinusXoffset = 0.0f;
            float MinusYoffset = 0.0f;

            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
            do
            {
                foreach (Cl3DModel.Cl3DModelPointIterator neighbor in iter.GetListOfNeighbors())
                {
                    iter.RemoveNeighbor(neighbor);
                }
            } while (iter.MoveToNext());

            ClTools.CreateGridBasedOnRealXY(p_Model, out Map, out width, out heinght, out MinusXoffset, out MinusYoffset);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < heinght; y++)
                {
                    if (Map[x, y] != null)
                    {
                        float MeanValue = ClTools.CalculateMeanValue(Map[x, y]);

                        Cl3DModel.Cl3DModelPointIterator Point = Map[x, y][0];

                        foreach (Cl3DModel.Cl3DModelPointIterator pt in Map[x, y])
                        {
                            string label = "";
                            if (pt.IsLabeled(out label))
                            {
                                Point = pt;
                                break;
                            }
                        }
                        foreach (Cl3DModel.Cl3DModelPointIterator pt in Map[x, y])
                        {
                            if (pt.PointID != Point.PointID)
                            {
                                p_Model.RemovePointFromModel(pt);
                                //         Map[x, y].Remove(pt);
                            }
                        }

                        Point.RangeImageX = x;
                        Point.RangeImageY = y;
                        Point.Z           = MeanValue;
                        Point.X           = x + MinusXoffset;
                        Point.Y           = y + MinusYoffset;
                    }
                }
            }
        }
 private void CalculateEuclideanDistancesFromPoint(string DistanceName, Cl3DModel.Cl3DModelPointIterator point, Cl3DModel p_Model)
 {
     Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
     do
     {
         double distance = Math.Sqrt(Math.Pow(point.X - iter.X, 2) + Math.Pow(point.Y - iter.Y, 2) + Math.Pow(point.Z - iter.Z, 2));
         iter.AddSpecificValue(DistanceName, distance);
     } while (iter.MoveToNext());
 }
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();

            if (iter.IsValid())
            {
                do
                {
                    List <float> points = new List <float>();
                    List <Cl3DModel.Cl3DModelPointIterator> Neighbors = iter.GetListOfNeighbors();

                    foreach (Cl3DModel.Cl3DModelPointIterator neighbor in Neighbors)
                    {
                        points.Add(neighbor.Z);
                    }
                    points.Add(iter.Z);

                    points.Sort();

                    float result = 0;
                    if (points.Count % 2 == 0)// even
                    {
                        int first = (int)(points.Count / 2);
                        result = (points[first - 1] + points[first]) / 2;
                    }
                    else // odd
                    {
                        int element = (int)(points.Count / 2);
                        result = points[element];
                    }

                    if (m_bDecision)
                    {
                        float diff = Math.Abs(iter.Z - result);
                        if (diff >= m_SpikeThreshold)
                        {
                            iter = p_Model.RemovePointFromModel(iter);
                        }
                        else
                        if (!iter.MoveToNext())
                        {
                            break;
                        }
                    }
                    else
                    {
                        iter.Z = result;
                        if (!iter.MoveToNext())
                        {
                            break;
                        }
                    }
                } while (iter.IsValid());
            }
        }
Пример #18
0
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator NoseTip = null;
            if (!p_Model.GetSpecificPoint(m_point, ref NoseTip))
            {
                throw new Exception("Cannot get point " + m_point);
            }

            //   p_Model.RemoveAllSpecificPoints();
            p_Model.RemovePointFromModel(NoseTip);
        }
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel ConformalModel = new Cl3DModel();

            ConformalModel.LoadModel(p_Model.ModelFileFolder + ConformalMapFolder + "\\" + p_Model.ModelFileName + ".m_Out.pos.m");

            Cl3DModel.Cl3DModelPointIterator iter      = p_Model.GetIterator();
            List <ClTools.ClTriangle>        Triangles = null;

            float ModelArea = CalculateWholeModelArea(p_Model);

            float ConformalMapArea = CalculateWholeModelArea(ConformalModel);

            if (iter.IsValid())
            {
                do
                {
                    float area3D = 0;
                    ClTools.GetListOfTriangles(out Triangles, iter);

                    //    if (Triangles.Count != 6)
                    //       continue;

                    foreach (ClTools.ClTriangle triangle in Triangles)
                    {
                        area3D += ClTools.CalculateTriangleArea(triangle);
                    }

                    area3D /= Triangles.Count;

                    iter.AddSpecificValue("ConnectedTrianglesArea", area3D);

                    Cl3DModel.Cl3DModelPointIterator ConformalIter = ConformalModel.GetIterator();
                    if (!ConformalIter.MoveToPoint(iter.PointID))
                    {
                        continue;//throw new Exception("Cannot find on conformal model point with no: " + iter.PointID.ToString());
                    }
                    float area2D = 0;
                    ClTools.GetListOfTriangles(out Triangles, ConformalIter);
                    foreach (ClTools.ClTriangle triangle in Triangles)
                    {
                        area2D += ClTools.CalculateTriangleArea(triangle);
                    }

                    area2D /= Triangles.Count;

                    float ConformalFactor = (area3D / ModelArea) / (area2D / ConformalMapArea);

                    ConformalIter.AddSpecificValue("ConformalFactor", ConformalFactor);
                } while (iter.MoveToNext());
            }

            p_Model = ConformalModel;
        }
Пример #20
0
        //     public override void SetProperitis(string p_sProperity, string p_sValue)
        //     {
        //     }

        //     public override List<KeyValuePair<string, string>> GetProperitis()
        //     {
        //     }

        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();

            do
            {
                iter.X = iter.U;
                iter.Y = iter.V;
                iter.Z = 0;
            } while (iter.MoveToNext());
        }
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            string name = p_Model.ModelFileFolder + p_Model.ModelFileName + m_sFilePostFix;


            if (m_bBinaryMode)
            {
                p_Model.SaveModel(name);
            }
            else
            {
                name += ".model";
                Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
                if (!iter.IsValid())
                {
                    throw new Exception("Iterator in the model is not valid");
                }

                using (TextWriter tw = new StreamWriter(name, false))
                {
                    tw.WriteLine("@----------------------------------------");
                    tw.WriteLine("@     Przemyslaw Szeptycki LIRIS 2008");
                    tw.WriteLine("@                Face model");
                    tw.WriteLine("@  Model name: " + p_Model.ModelFileName);
                    tw.WriteLine("@----------------------------------------");
                    tw.WriteLine("@ PointID X Y Z (TextureX TextureY) (Neighbors PointID)");
                    do
                    {
                        string line = iter.PointID.ToString(System.Globalization.CultureInfo.InvariantCulture) + " " + iter.X.ToString(System.Globalization.CultureInfo.InvariantCulture) + " " + iter.Y.ToString(System.Globalization.CultureInfo.InvariantCulture) + " " + iter.Z.ToString(System.Globalization.CultureInfo.InvariantCulture) + " ( " + iter.RangeImageX.ToString(System.Globalization.CultureInfo.InvariantCulture) + " " + iter.RangeImageY.ToString(System.Globalization.CultureInfo.InvariantCulture) + " ) ( ";
                        List <Cl3DModel.Cl3DModelPointIterator> neighbors = iter.GetListOfNeighbors();
                        foreach (Cl3DModel.Cl3DModelPointIterator neighbor in neighbors)
                        {
                            line += neighbor.PointID.ToString(System.Globalization.CultureInfo.InvariantCulture) + " ";
                        }
                        line += ")";

                        tw.WriteLine(line);
                    } while (iter.MoveToNext());

                    int nop = p_Model.GetAllSpecificPoints().Count;
                    if (nop != 0)
                    {
                        tw.WriteLine("Landmark points (ptID): " + nop.ToString());
                        foreach (KeyValuePair <string, Cl3DModel.Cl3DModelPointIterator> specificPoint in p_Model.GetAllSpecificPoints())
                        {
                            tw.WriteLine(specificPoint.Key + " " + specificPoint.Value.PointID.ToString());
                        }
                    }

                    tw.Close();
                }
            }
        }
Пример #22
0
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            string name = p_Model.ModelFileName;

            string FileName = p_Model.ModelFileFolder + name + ".gav";

            string line = "";
            List <ClTools.MainPoint3D> points = new List <ClTools.MainPoint3D>();

            using (StreamReader FileStream = File.OpenText(FileName))
            {
                while ((line = FileStream.ReadLine()) != null)
                {
                    string[] coordinates = line.Split('\t');
                    if (coordinates[0].Contains("@"))
                    {
                        continue;
                    }

                    if (coordinates.Length != 4)
                    {
                        throw new Exception("Incorrect format, less than 3 coordinates for a landmark (landmekName x y z)");
                    }


                    points.Add(new ClTools.MainPoint3D(Single.Parse(coordinates[1].Split(' ')[1], System.Globalization.CultureInfo.InvariantCulture),
                                                       Single.Parse(coordinates[2].Split(' ')[1], System.Globalization.CultureInfo.InvariantCulture),
                                                       Single.Parse(coordinates[3].Split(' ')[1], System.Globalization.CultureInfo.InvariantCulture),
                                                       coordinates[0]));
                }
            }


            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
            if (!iter.IsValid())
            {
                throw new Exception("Iterator in the model is not valid!");
            }

            do
            {
                foreach (ClTools.MainPoint3D pts in points)
                {
                    pts.CheckClosest(iter);
                }
            } while (iter.MoveToNext());

            foreach (ClTools.MainPoint3D pts in points)
            {
                p_Model.AddSpecificPoint(pts.Name, pts.ClosestPoint);
            }
        }
Пример #23
0
 protected override void Algorithm(ref Cl3DModel p_Model)
 {
     Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
     do
     {
         if (iter.NormalVector != null)
         {
             iter.Color = Color.FromArgb((int)Math.Abs((iter.NormalVector[0]) * 255),
                                         (int)Math.Abs((iter.NormalVector[1]) * 255),
                                         (int)Math.Abs((iter.NormalVector[2]) * 255));
         }
     } while (iter.MoveToNext());
 }
Пример #24
0
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();

            float maxX = iter.X;
            float minX = iter.X;
            float maxY = iter.Y;
            float minY = iter.Y;
            float maxZ = iter.Z;
            float minZ = iter.Z;

            do
            {
                if (maxX < iter.X)
                {
                    maxX = iter.X;
                }
                if (maxY < iter.Y)
                {
                    maxY = iter.Y;
                }
                if (maxZ < iter.Z)
                {
                    maxZ = iter.Z;
                }


                if (minX > iter.X)
                {
                    minX = iter.X;
                }
                if (minY > iter.Y)
                {
                    minY = iter.Y;
                }
                if (minZ > iter.Z)
                {
                    minZ = iter.Z;
                }
            } while (iter.MoveToNext());

            iter = p_Model.GetIterator();
            do
            {
                int R = (int)(((iter.X - minX) / (maxX - minX)) * 255);
                int G = (int)(((iter.Y - minY) / (maxY - minY)) * 255);
                int B = (int)(((iter.Z - minZ) / (maxZ - minZ)) * 255);

                iter.Color = Color.FromArgb(R, G, B);
            } while (iter.MoveToNext());
        }
Пример #25
0
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator RightEye = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.RightEyeLeftCorner.ToString());
            Cl3DModel.Cl3DModelPointIterator LeftEye  = p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.LeftEyeRightCorner.ToString());

            Cl3DModel.Cl3DModelPointIterator[,] Map = null;
            int Width, Height, Xoffset, Yoffset;

            ClTools.CreateGridBasedOnRangeValues(p_Model, out Map, out Width, out Height, out Xoffset, out Yoffset);

            int RightEyeX = RightEye.RangeImageX - Xoffset;
            int RightEyeY = RightEye.RangeImageY - Yoffset;
            int LeftEyeX  = LeftEye.RangeImageX - Xoffset;
            int LeftEyeY  = LeftEye.RangeImageY - Yoffset;

            int MiddleX = (RightEyeX + LeftEyeX) / 2;
            int MiddleY = (RightEyeY + LeftEyeY) / 2;

            Cl3DModel.Cl3DModelPointIterator MiddlePoint = Map[MiddleX, MiddleY];
            p_Model.AddSpecificPoint(Cl3DModel.eSpecificPoints.UnspecifiedPoint, MiddlePoint);

            List <Cl3DModel.Cl3DModelPointIterator> Neighborhood = null;

            ClTools.GetNeighborhoodWithGeodesicDistance(out Neighborhood, MiddlePoint, m_fEyesPartRadious);
            foreach (Cl3DModel.Cl3DModelPointIterator point in Neighborhood)
            {
                point.AlreadyVisited = true;
            }

            MiddlePoint.AlreadyVisited = true;

            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
            do
            {
                if (!iter.IsValid())
                {
                    break;
                }

                if (!iter.AlreadyVisited)
                {
                    iter = p_Model.RemovePointFromModel(iter);
                }
                else
                if (!iter.MoveToNext())
                {
                    break;
                }
            } while (true);
        }
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();

            List <KeyValuePair <string, Cl3DModel.Cl3DModelPointIterator> > list = p_Model.GetAllSpecificPoints();

            foreach (KeyValuePair <string, Cl3DModel.Cl3DModelPointIterator> point in list)
            {
                List <Cl3DModel.Cl3DModelPointIterator> NeighborhoodList = null;
                ClTools.GetNeighborhoodWithEuclideanDistanceCheckNeighborhood(out NeighborhoodList, point.Value, 2.0f);
                foreach (Cl3DModel.Cl3DModelPointIterator ppoint in NeighborhoodList)
                {
                    ppoint.Color = Color.Red;
                }
            }
        }
Пример #27
0
 private Cl3DModel.Cl3DModelPointIterator GetRandomUnseenPointOfHole(ref Cl3DModel p_Model)
 {
     Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();
     if (!iter.IsValid())
     {
         return(null);
     }
     do
     {
         if (iter.GetListOfNeighbors().Count < 8 && !iter.AlreadyVisited)
         {
             return(iter);
         }
     } while (iter.MoveToNext());
     return(null);
 }
Пример #28
0
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();

            while (iter.IsValid())
            {
                iter.X = iter.X * m_fScale;
                iter.Y = iter.Y * m_fScale;
                iter.Z = iter.Z * m_fScale;

                if (!iter.MoveToNext())
                {
                    break;
                }
            }
        }
Пример #29
0
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator NoseTip = null;
            if (!p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.NoseTip.ToString(), ref NoseTip))
            {
                throw new Exception("Cannot get Nose Tip");
            }

            List <Cl3DModel.Cl3DModelPointIterator> Neighborhood = null;

            ClTools.GetNeighborhoodWithGeodesicDistance(out Neighborhood, NoseTip, m_NeighborhoodSize);

            foreach (Cl3DModel.Cl3DModelPointIterator point in Neighborhood)
            {
                point.Color = Color.Red;
            }
        }
        protected override void Algorithm(ref Cl3DModel p_Model)
        {
            Cl3DModel.Cl3DModelPointIterator iter = p_Model.GetIterator();

            // uint no = (uint)p_Model.ModelPointsCount / 2;

            //  if (!iter.MoveToPoint(no))
            //      throw new Exception("Cannot find point no: " + no.ToString());

            List <Cl3DModel.Cl3DModelPointIterator> PointNeighborhood;

            ClTools.GetNeighborhoodWithGeodesicDistance(out PointNeighborhood, iter, m_SphereSize);
            foreach (Cl3DModel.Cl3DModelPointIterator p in PointNeighborhood)
            {
                p_Model.RemovePointFromModel(p);
            }
            p_Model.RemovePointFromModel(iter);
        }