protected override void Context() { _model = new Model().WithName(_oldName); _model.Root = new Container().WithName(_oldName); var explicitFormula = new ExplicitFormula("A+B"); _unchangedPath = new FormulaUsablePath(new[] { "A", "B" }); _changedObjectPath = new FormulaUsablePath(new[] { _oldName, "A" }); var rhsFormula = new ExplicitFormula("-C"); _rhsPath = new FormulaUsablePath(new [] { _oldName, "C" }); rhsFormula.AddObjectPath(_rhsPath); explicitFormula.AddObjectPath(_changedObjectPath); explicitFormula.AddObjectPath(_unchangedPath); var parameter = new Parameter().WithName("P1").WithFormula(explicitFormula).WithRHS(rhsFormula); _model.Root.Add(parameter); _model.Neighborhoods = new Container().WithName(Constants.NEIGHBORHOODS); var neighborhood = new Neighborhood().WithName("BLA"); var neighborhoodFormula = new ExplicitFormula("u"); _neighborhoodPath = new FormulaUsablePath(new[] { _oldName, _oldName, "u" }); neighborhoodFormula.AddObjectPath(_neighborhoodPath); var neighborhoodParameter = new Parameter().WithFormula(neighborhoodFormula); neighborhood.Add(neighborhoodParameter); _model.Neighborhoods.Add(neighborhood); sut = new RenameModelCommand(_model, _newName); }
private void GenerateNeighborhoods(string GivenSubset) { List <string> neigh = new List <string>(); StringBuilder sb = new StringBuilder(GivenSubset); neigh.Clear(); switch (settingsInfo.neighborHoodSearchAlg) { case NeighborHoodSearchAlg.AdjacentPairwise: for (int i = 0; i + 1 < GivenSubset.Length; i++) { sb = new StringBuilder(GivenSubset); char ch = sb[i]; sb[i] = sb[i + 1]; sb[i + 1] = ch; if (!isExist(sb.ToString())) { neigh.Add(sb.ToString()); } } break; case NeighborHoodSearchAlg.GeneralPairwise: for (int gap = 1; gap < GivenSubset.Length; gap++) { for (int i = 0; i + gap < GivenSubset.Length; i++) { sb = new StringBuilder(GivenSubset); char ch = sb[i]; sb[i] = sb[i + gap]; sb[i + gap] = ch; if (!isExist(sb.ToString())) { neigh.Add(sb.ToString()); } } } break; case NeighborHoodSearchAlg.TopPriorityUpfront: for (int i = 1; i < GivenSubset.Length; i++) { sb = new StringBuilder(GivenSubset); char ch = sb[0]; sb[0] = sb[i]; sb[i] = ch; if (!isExist(sb.ToString())) { neigh.Add(sb.ToString()); } } break; case NeighborHoodSearchAlg.VariableNeighourhoodGeneration: //********************* this section should be completed ************************ break; } Neighborhood.Add(neigh); }
protected override void Algorithm(ref Cl3DModel p_Model) { //------------------- LeftCornerOfLips ------------------------- Cl3DModel.Cl3DModelPointIterator basicPoint = null; List <Cl3DModel.Cl3DModelPointIterator> Neighborhood; double max = 0; Cl3DModel.Cl3DModelPointIterator NewCorner = null; if (p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.LeftCornerOfLips.ToString(), ref basicPoint)) { ClTools.GetNeighborhoodWithEuclideanDistanceCheckNeighborhood(out Neighborhood, basicPoint, 15); Neighborhood.Add(basicPoint); max = 0; NewCorner = null; foreach (Cl3DModel.Cl3DModelPointIterator point in Neighborhood) { List <Cl3DModel.Cl3DModelPointIterator> PointNeighborhood; ClTools.GetNeighborhoodWithEuclideanDistanceCheckNeighborhood(out PointNeighborhood, point, 10); point.Color = Color.Magenta; double A = 0; double B = 0; double C = 0; double D = 0; double E = 0; double F = 0; double H = 0; double K = 0; double k1 = 0; double k2 = 0; double ShapeIndex = 0; if (!ClTools.CountSurfaceCoefficients(PointNeighborhood, ref A, ref B, ref C, ref D, ref E, ref F)) { continue; } double dx = B + 2 * D * point.X + E * point.Y; double dy = C + E * point.X + 2 * F * point.Y; double dxy = E; double dxx = 2 * D; double dyy = 2 * F; //Mean H = ((((1 + Math.Pow(dy, 2)) * dxx) - (2 * dx * dy * dxy) + ((1 + Math.Pow(dx, 2)) * dyy)) / (2 * Math.Pow((1 + Math.Pow(dx, 2) + Math.Pow(dy, 2)), 3.0d / 2.0d))); //Gaussian K = (((dxx * dyy) - Math.Pow(dxy, 2)) / Math.Pow((1 + Math.Pow(dx, 2) + Math.Pow(dy, 2)), 2)); k1 = H + Math.Sqrt(Math.Pow(H, 2) - K); k2 = H - Math.Sqrt(Math.Pow(H, 2) - K); ShapeIndex = 0.5d - (1 / Math.PI) * Math.Atan((k1 + k2) / (k1 - k2)); if (H > 0 && K > max) { max = K; NewCorner = point.CopyIterator(); } } if (NewCorner != null) { p_Model.AddSpecificPoint(Cl3DModel.eSpecificPoints.LeftCornerOfLips, NewCorner); } } //------------------- RightCornerOfLips ------------------------- if (p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.RightCornerOfLips, ref basicPoint)) { ClTools.GetNeighborhoodWithEuclideanDistanceCheckNeighborhood(out Neighborhood, basicPoint, 15); Neighborhood.Add(basicPoint); max = 0; NewCorner = null; foreach (Cl3DModel.Cl3DModelPointIterator point in Neighborhood) { List <Cl3DModel.Cl3DModelPointIterator> PointNeighborhood; ClTools.GetNeighborhoodWithEuclideanDistanceCheckNeighborhood(out PointNeighborhood, point, 10); point.Color = Color.Magenta; double A = 0; double B = 0; double C = 0; double D = 0; double E = 0; double F = 0; double H = 0; double K = 0; double k1 = 0; double k2 = 0; double ShapeIndex = 0; if (!ClTools.CountSurfaceCoefficients(PointNeighborhood, ref A, ref B, ref C, ref D, ref E, ref F)) { continue; } double dx = B + 2 * D * point.X + E * point.Y; double dy = C + E * point.X + 2 * F * point.Y; double dxy = E; double dxx = 2 * D; double dyy = 2 * F; //Mean H = ((((1 + Math.Pow(dy, 2)) * dxx) - (2 * dx * dy * dxy) + ((1 + Math.Pow(dx, 2)) * dyy)) / (2 * Math.Pow((1 + Math.Pow(dx, 2) + Math.Pow(dy, 2)), 3.0d / 2.0d))); //Gaussian K = (((dxx * dyy) - Math.Pow(dxy, 2)) / Math.Pow((1 + Math.Pow(dx, 2) + Math.Pow(dy, 2)), 2)); k1 = H + Math.Sqrt(Math.Pow(H, 2) - K); k2 = H - Math.Sqrt(Math.Pow(H, 2) - K); ShapeIndex = 0.5d - (1 / Math.PI) * Math.Atan((k1 + k2) / (k1 - k2)); if (H > 0 && K > max) { max = K; NewCorner = point.CopyIterator(); } } if (NewCorner != null) { p_Model.AddSpecificPoint(Cl3DModel.eSpecificPoints.RightCornerOfLips, NewCorner); } } //------------------- LeftCornerOfNose ------------------------- if (p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.LeftCornerOfNose, ref basicPoint)) { ClTools.GetNeighborhoodWithEuclideanDistanceCheckNeighborhood(out Neighborhood, basicPoint, 10); Neighborhood.Add(basicPoint); max = 0; NewCorner = null; foreach (Cl3DModel.Cl3DModelPointIterator point in Neighborhood) { List <Cl3DModel.Cl3DModelPointIterator> PointNeighborhood; ClTools.GetNeighborhoodWithEuclideanDistanceCheckNeighborhood(out PointNeighborhood, point, 10); point.Color = Color.Orchid; double A = 0; double B = 0; double C = 0; double D = 0; double E = 0; double F = 0; double H = 0; double K = 0; double k1 = 0; double k2 = 0; double ShapeIndex = 0; if (!ClTools.CountSurfaceCoefficients(PointNeighborhood, ref A, ref B, ref C, ref D, ref E, ref F)) { continue; } double dx = B + 2 * D * point.X + E * point.Y; double dy = C + E * point.X + 2 * F * point.Y; double dxy = E; double dxx = 2 * D; double dyy = 2 * F; //Mean H = ((((1 + Math.Pow(dy, 2)) * dxx) - (2 * dx * dy * dxy) + ((1 + Math.Pow(dx, 2)) * dyy)) / (2 * Math.Pow((1 + Math.Pow(dx, 2) + Math.Pow(dy, 2)), 3.0d / 2.0d))); //Gaussian K = (((dxx * dyy) - Math.Pow(dxy, 2)) / Math.Pow((1 + Math.Pow(dx, 2) + Math.Pow(dy, 2)), 2)); k1 = H + Math.Sqrt(Math.Pow(H, 2) - K); k2 = H - Math.Sqrt(Math.Pow(H, 2) - K); ShapeIndex = 0.5d - (1 / Math.PI) * Math.Atan((k1 + k2) / (k1 - k2)); if (H > 0 && K > max) { max = K; NewCorner = point.CopyIterator(); } } if (NewCorner != null) { p_Model.AddSpecificPoint(Cl3DModel.eSpecificPoints.LeftCornerOfNose, NewCorner); } } //------------------- RightCornerOfNose ------------------------- if (p_Model.GetSpecificPoint(Cl3DModel.eSpecificPoints.RightCornerOfNose, ref basicPoint)) { ClTools.GetNeighborhoodWithEuclideanDistanceCheckNeighborhood(out Neighborhood, basicPoint, 10); Neighborhood.Add(basicPoint); max = 0; NewCorner = null; foreach (Cl3DModel.Cl3DModelPointIterator point in Neighborhood) { List <Cl3DModel.Cl3DModelPointIterator> PointNeighborhood; ClTools.GetNeighborhoodWithEuclideanDistanceCheckNeighborhood(out PointNeighborhood, point, 10); point.Color = Color.Orchid; double A = 0; double B = 0; double C = 0; double D = 0; double E = 0; double F = 0; double H = 0; double K = 0; double k1 = 0; double k2 = 0; double ShapeIndex = 0; if (!ClTools.CountSurfaceCoefficients(PointNeighborhood, ref A, ref B, ref C, ref D, ref E, ref F)) { continue; } double dx = B + 2 * D * point.X + E * point.Y; double dy = C + E * point.X + 2 * F * point.Y; double dxy = E; double dxx = 2 * D; double dyy = 2 * F; //Mean H = ((((1 + Math.Pow(dy, 2)) * dxx) - (2 * dx * dy * dxy) + ((1 + Math.Pow(dx, 2)) * dyy)) / (2 * Math.Pow((1 + Math.Pow(dx, 2) + Math.Pow(dy, 2)), 3.0d / 2.0d))); //Gaussian K = (((dxx * dyy) - Math.Pow(dxy, 2)) / Math.Pow((1 + Math.Pow(dx, 2) + Math.Pow(dy, 2)), 2)); k1 = H + Math.Sqrt(Math.Pow(H, 2) - K); k2 = H - Math.Sqrt(Math.Pow(H, 2) - K); ShapeIndex = 0.5d - (1 / Math.PI) * Math.Atan((k1 + k2) / (k1 - k2)); if (H > 0 && K > max) { max = K; NewCorner = point.CopyIterator(); } } if (NewCorner != null) { p_Model.AddSpecificPoint(Cl3DModel.eSpecificPoints.RightCornerOfNose, NewCorner); } } }