Exemplo n.º 1
0
        } // Main(...)

        private static void CreateGeometricModel(CheetahDataSet dataSet, ICollection <long> entIdList)
        {
            // 1. Creating line segments and appending them to the data set

            var line1 = new CheetahLine2D(0.5, -0.5, 8.5, 0.5);
            var line2 = new CheetahLine2D(10.5, 1.5, 9.5, 8.5);
            var line3 = new CheetahLine2D(9.5, 9.5, 0.5, 10.5);
            var line4 = new CheetahLine2D(0.5, 8.5, -0.5, 1.5);

            entIdList.Add(line1.Id);
            entIdList.Add(line2.Id);
            entIdList.Add(line3.Id);
            entIdList.Add(line4.Id);

            // 2. Creating circle arcs and appending them to the data set

            var arc1 = new CheetahArc2D(new CheetahPoint2D(1.5, 1.5), -Math.PI, -Math.PI * 0.5, 1.25);
            var arc2 = new CheetahArc2D(new CheetahPoint2D(9.25, 0.75), -Math.PI * 0.5, 0.0, 0.5);
            var arc3 = new CheetahArc2D(new CheetahPoint2D(9.5, 9.5), Math.PI * 0.1, Math.PI * 0.5, 1.5);
            var arc4 = new CheetahArc2D(new CheetahPoint2D(1.2, 8.5), Math.PI * 0.25, Math.PI, 0.75);

            entIdList.Add(arc1.Id);
            entIdList.Add(arc2.Id);
            entIdList.Add(arc3.Id);
            entIdList.Add(arc4.Id);

            // 3. Creating geometric constraints

            // 3.1. Creating coinsident constraints for the end points of arcs amd line segments

            dataSet.AddCoincidence(arc1, IdentifiableValueReferences.ArcEnd,
                                   line1, IdentifiableValueReferences.LineStart);

            dataSet.AddCoincidence(line1, IdentifiableValueReferences.LineEnd,
                                   arc2, IdentifiableValueReferences.ArcStart);

            dataSet.AddCoincidence(arc2, IdentifiableValueReferences.ArcEnd,
                                   line2, IdentifiableValueReferences.LineStart);

            dataSet.AddCoincidence(line2, IdentifiableValueReferences.LineEnd,
                                   arc3, IdentifiableValueReferences.ArcStart);

            dataSet.AddCoincidence(arc3, IdentifiableValueReferences.ArcEnd,
                                   line3, IdentifiableValueReferences.LineStart);

            dataSet.AddCoincidence(line3, IdentifiableValueReferences.LineEnd,
                                   arc4, IdentifiableValueReferences.ArcStart);

            dataSet.AddCoincidence(arc4, IdentifiableValueReferences.ArcEnd,
                                   line4, IdentifiableValueReferences.LineStart);

            dataSet.AddCoincidence(line4, IdentifiableValueReferences.LineEnd,
                                   arc1, IdentifiableValueReferences.ArcStart);

            // 3.2. Creating perpendicular constraints between line segments 1 and 2

            dataSet.AddPerpendicular(line1, line2);

            // 3.3. Creating two parallel constraints between line segments 1 and 3 and line segments 2 and 4

            dataSet.AddParallel(line1, line3);
            dataSet.AddParallel(line2, line4);

            // 3.4. Creating "equal radius" constraints for all arcs

            dataSet.AddEqual(arc1, arc2);
            dataSet.AddEqual(arc2, arc3);
            dataSet.AddEqual(arc3, arc4);

            // 3.5 Creating tangent constraints on the connection points of arcs and line segments

            dataSet.AddTangent(arc1, line1);
            dataSet.AddTangent(arc2, line1);
            dataSet.AddTangent(arc2, line2);
            dataSet.AddTangent(arc3, line2);
            dataSet.AddTangent(arc3, line3);
            dataSet.AddTangent(arc4, line3);
            dataSet.AddTangent(arc4, line4);
            dataSet.AddTangent(arc1, line4);

            // 4. Geometric model is created, but constraints are not satisfied yet!
        } // CreateGeometricModel(...)
Exemplo n.º 2
0
        } // Main(...)

        private static void CreateGeometricModel(CheetahDataSet dataSet, ICollection<long> entIdList)
        {
            // 1. Creating line segments and appending them to the data set

            var line1 = new CheetahLine2D(0.5, -0.5, 8.5, 0.5);
            var line2 = new CheetahLine2D(10.5, 1.5, 9.5, 8.5);
            var line3 = new CheetahLine2D(9.5, 9.5, 0.5, 10.5);
            var line4 = new CheetahLine2D(0.5, 8.5, -0.5, 1.5);

            entIdList.Add(line1.Id);
            entIdList.Add(line2.Id);
            entIdList.Add(line3.Id);
            entIdList.Add(line4.Id);

            // 2. Creating circle arcs and appending them to the data set

            var arc1 = new CheetahArc2D(new CheetahPoint2D(1.5, 1.5), -Math.PI, -Math.PI * 0.5, 1.25);
            var arc2 = new CheetahArc2D(new CheetahPoint2D(9.25, 0.75), -Math.PI * 0.5, 0.0, 0.5);
            var arc3 = new CheetahArc2D(new CheetahPoint2D(9.5, 9.5), Math.PI * 0.1, Math.PI * 0.5, 1.5);
            var arc4 = new CheetahArc2D(new CheetahPoint2D(1.2, 8.5), Math.PI * 0.25, Math.PI, 0.75);

            entIdList.Add(arc1.Id);
            entIdList.Add(arc2.Id);
            entIdList.Add(arc3.Id);
            entIdList.Add(arc4.Id);

            // 3. Creating geometric constraints

            // 3.1. Creating coinsident constraints for the end points of arcs amd line segments

            dataSet.AddCoincidence(arc1, IdentifiableValueReferences.ArcEnd,
                line1, IdentifiableValueReferences.LineStart);

            dataSet.AddCoincidence(line1, IdentifiableValueReferences.LineEnd,
                arc2, IdentifiableValueReferences.ArcStart);

            dataSet.AddCoincidence(arc2, IdentifiableValueReferences.ArcEnd,
                line2, IdentifiableValueReferences.LineStart);

            dataSet.AddCoincidence(line2, IdentifiableValueReferences.LineEnd,
                arc3, IdentifiableValueReferences.ArcStart);

            dataSet.AddCoincidence(arc3, IdentifiableValueReferences.ArcEnd,
                line3, IdentifiableValueReferences.LineStart);

            dataSet.AddCoincidence(line3, IdentifiableValueReferences.LineEnd,
                arc4, IdentifiableValueReferences.ArcStart);

            dataSet.AddCoincidence(arc4, IdentifiableValueReferences.ArcEnd,
                line4, IdentifiableValueReferences.LineStart);

            dataSet.AddCoincidence(line4, IdentifiableValueReferences.LineEnd,
                arc1, IdentifiableValueReferences.ArcStart);

            // 3.2. Creating perpendicular constraints between line segments 1 and 2

            dataSet.AddPerpendicular(line1, line2);

            // 3.3. Creating two parallel constraints between line segments 1 and 3 and line segments 2 and 4 

            dataSet.AddParallel(line1, line3);
            dataSet.AddParallel(line2, line4);

            // 3.4. Creating "equal radius" constraints for all arcs

            dataSet.AddEqual(arc1, arc2);
            dataSet.AddEqual(arc2, arc3);
            dataSet.AddEqual(arc3, arc4);

            // 3.5 Creating tangent constraints on the connection points of arcs and line segments

            dataSet.AddTangent(arc1, line1);
            dataSet.AddTangent(arc2, line1);
            dataSet.AddTangent(arc2, line2);
            dataSet.AddTangent(arc3, line2);
            dataSet.AddTangent(arc3, line3);
            dataSet.AddTangent(arc4, line3);
            dataSet.AddTangent(arc4, line4);
            dataSet.AddTangent(arc1, line4);

            // 4. Geometric model is created, but constraints are not satisfied yet!
            
        } // CreateGeometricModel(...)