public CompareIntriniscAttribute( CompareKind intrinsicKind, CompareFlags intrinsicFlags) { IntrinsicKind = intrinsicKind; IntrinsicFlags = intrinsicFlags; }
private FilterInfo createFilter(CompareFlags compareAs) { FilterInfo filterInfo = null; if (SelectedColumn != null && SelectedOrder != null) { if (SelectedColumn is DataGridBoundColumn) { var col = SelectedColumn as DataGridBoundColumn; Binding binding = (Binding)col.Binding; //filterInfo = new FilterInfo(SelectedOrder, binding.Path.Path, col); filterInfo = new FilterInfo(SelectedOrder, binding.Path.Path); filterInfo.CompareAs = compareAs; if (compareAs != CompareFlags.CompareNone) { _filters.Add(filterInfo); } } //hardcoded reactors property for now if (SelectedColumn is DataGridTemplateColumn) { //filterInfo = new FilterInfo(SelectedOrder, binding.Path.Path, col); filterInfo = new FilterInfo(SelectedOrder, "Reactors"); filterInfo.CompareAs = compareAs; if (compareAs != CompareFlags.CompareNone) { _filters.Add(filterInfo); } } } return(filterInfo); }
/// <summary> /// Resolves a compare operation. /// </summary> /// <param name="kind">The compare kind.</param> /// <param name="flags">The compare flags.</param> /// <param name="type">The type to compare.</param> /// <returns>The resolved compare operation.</returns> public static string GetCompareOperation( CompareKind kind, CompareFlags flags, ArithmeticBasicValueType type) { var unorderedFloatComparison = type.IsFloat() && flags.HasFlag(CompareFlags.UnsignedOrUnordered); if (unorderedFloatComparison) { if (CompareUnorderedFloatOperations.TryGetValue( (kind, type), out string operation)) { return(operation); } } else { if (CompareOperations.TryGetValue((kind, type), out string operation)) { return(operation); } } throw new NotSupportedIntrinsicException(kind.ToString()); }
//-------------------------------------------------------------------------------------------------- internal static bool CompareShape(Shape shape, string brepFile, CompareFlags flags = CompareFlags.CompareProperties) { // Get OCC Shape var shape1 = shape.GetTransformedBRep(); Assert.That(shape1, Is.Not.Null); return(CompareShape(shape1, brepFile, flags)); }
/// <summary> /// Inverts the given compare kind. /// </summary> /// <param name="kind">The compare kind to invert.</param> /// <param name="leftType">The basic value type of the left operand..</param> /// <param name="rightType">The basic value type of the right operand.</param> /// <param name="flags">The compare flags that might be adjusted.</param> /// <returns>The inverted compare kind.</returns> public static CompareKind Invert( CompareKind kind, BasicValueType leftType, BasicValueType rightType, ref CompareFlags flags) => UpdateFlags( kind, Inverted[(int)kind], leftType, rightType, ref flags);
/// <summary> /// Creates a compare instruction of the given type. /// </summary> /// <param name="compareKind">The comparison kind.</param> /// <param name="flags">The comparison flags.</param> private Value CreateCompare(CompareKind compareKind, CompareFlags flags) { var right = Block.PopCompareValue(Location, ConvertFlags.None); var left = Block.PopCompareValue(Location, ConvertFlags.None); return(CreateCompare( left, right, compareKind, flags)); }
/// <summary> /// Adjusts the given compare kind and the associated flags for swapping the /// operands of a compare operation. /// </summary> /// <param name="kind">The compare kind to invert.</param> /// <param name="leftType">The basic value type of the left operand..</param> /// <param name="rightType">The basic value type of the right operand.</param> /// <param name="flags">The compare flags that might be adjusted.</param> /// <returns>The adjusted compare kind.</returns> public static CompareKind SwapOperands( CompareKind kind, BasicValueType leftType, BasicValueType rightType, ref CompareFlags flags) => UpdateFlags( kind, Swapped[(int)kind], leftType, rightType, ref flags);
/// <summary> /// Creates a compare instruction of the given type. /// </summary> /// <param name="block">The current basic block.</param> /// <param name="builder">The current builder.</param> /// <param name="compareKind">The comparison kind.</param> /// <param name="flags">The comparison flags.</param> private static Value CreateCompare( Block block, IRBuilder builder, CompareKind compareKind, CompareFlags flags) { var right = block.PopCompareValue(ConvertFlags.None); var left = block.PopCompareValue(ConvertFlags.None); return(CreateCompare(builder, left, right, compareKind, flags)); }
/// <summary> /// Constructs a new compare value. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="left">The left operand.</param> /// <param name="right">The right operand.</param> /// <param name="kind">The operation kind.</param> /// <param name="flags">The operation flags.</param> internal CompareValue( IRContext context, BasicBlock basicBlock, ValueReference left, ValueReference right, CompareKind kind, CompareFlags flags) : base(ValueKind.Compare, basicBlock, ComputeType(context)) { Kind = kind; Flags = flags; Seal(ImmutableArray.Create(left, right)); }
/// <summary> /// Updates the compare flags according to the potentially updated operation /// kind. /// </summary> /// <param name="kind">The current operation kind.</param> /// <param name="newKind">The new (potentially updated) operation kind.</param> /// <param name="leftType">The left basic value type.</param> /// <param name="rightType">The right basic value type.</param> /// <param name="flags">The current flags to be updated.</param> /// <returns>The value of <paramref name="newKind"/>.</returns> private static CompareKind UpdateFlags( CompareKind kind, CompareKind newKind, BasicValueType leftType, BasicValueType rightType, ref CompareFlags flags) { // If the comparison was swapped or inverted, and we are comparing floats, // toggle between ordered/unordered float comparisons if (kind != newKind && leftType.IsFloat() && rightType.IsFloat()) { flags ^= CompareFlags.UnsignedOrUnordered; } return(newKind); }
/// <summary> /// Creates a compare instruction of the given type. /// </summary> /// <param name="left">The left operand.</param> /// <param name="right">The right operand.</param> /// <param name="builder">The current builder.</param> /// <param name="compareKind">The comparison kind.</param> /// <param name="flags">The comparison flags.</param> private static Value CreateCompare( IRBuilder builder, Value left, Value right, CompareKind compareKind, CompareFlags flags) { var convertFlags = ConvertFlags.None; if ((flags & CompareFlags.UnsignedOrUnordered) == CompareFlags.UnsignedOrUnordered) { convertFlags = ConvertFlags.SourceUnsigned; } right = CreateConversion(builder, right, left.Type, convertFlags); left = CreateConversion(builder, left, right.Type, convertFlags); Debug.Assert(left.BasicValueType == right.BasicValueType); return(builder.CreateCompare(left, right, compareKind, flags)); }
private bool compareStrTest( string sLeftStr, bool bLeftWild, string sRightStr, bool bRightWild, CompareFlags compareFlags, bool bExpectedEqual, DbSystem dbSystem) { int iCmp; beginTest("Compare Strings, Str1: \"" + sLeftStr + "\", Str2: \"" + sRightStr + "\""); try { iCmp = dbSystem.compareStrings(sLeftStr, bLeftWild, sRightStr, bRightWild, compareFlags, Languages.FLM_US_LANG); } catch (XFlaimException ex) { endTest(false, ex, "calling compareStrings"); return(false); } if ((bExpectedEqual && iCmp != 0) || (!bExpectedEqual && iCmp == 0)) { endTest(false, false); System.Console.WriteLine("Expected Equal [{0}] != Result [{1}]", bExpectedEqual, iCmp); System.Console.WriteLine("Compare Flags: {0}", compareFlags); System.Console.WriteLine("Left Wild: {0}", bLeftWild); System.Console.WriteLine("Right Wild: {0}", bRightWild); } endTest(false, true); return(true); }
public PropVariantComparer(CompareUnit unit, CompareFlags flags) { _compareUnit = unit; _compareFlags = flags; }
public PropVariantComparer(CompareFlags flags) { _compareFlags = flags; }
public CompareIntriniscAttribute(CompareKind kind, CompareFlags flags) { IntrinsicKind = kind; IntrinsicFlags = flags; }
public static void TestTransferMotionToConstraint <T>(T constraint, RigBuilder rigBuilder, AnimationClip clip, IList <Transform> targetTransforms, CompareFlags flags) where T : MonoBehaviour, IRigConstraint { Animator animator = rigBuilder.GetComponent <Animator>(); int numberOfFrames = 60; float dt = 1f / numberOfFrames; var defaultPoseClip = CreateDefaultPose(rigBuilder.gameObject); #if DEBUG_BAKE_TO_CONSTRAINT AssetDatabase.CreateAsset(clip, "Assets/bakeToConstraintBefore.anim"); clip = UnityEngine.Object.Instantiate(clip) as AnimationClip; #endif // Evaluate clip without constraint and take snapshots. var translationsBeforeBaking = new Vector3[targetTransforms.Count, numberOfFrames + 1]; var rotationsBeforeBaking = new Quaternion[targetTransforms.Count, numberOfFrames + 1]; using (var graph = new EvaluationGraph(rigBuilder.GetComponent <Animator>(), clip)) { graph.Evaluate(0f); for (int transformIndex = 0; transformIndex < targetTransforms.Count; ++transformIndex) { translationsBeforeBaking[transformIndex, 0] = targetTransforms[transformIndex].position; rotationsBeforeBaking[transformIndex, 0] = targetTransforms[transformIndex].rotation; } for (int frame = 1; frame <= numberOfFrames; ++frame) { graph.Evaluate(dt); for (int transformIndex = 0; transformIndex < targetTransforms.Count; ++transformIndex) { translationsBeforeBaking[transformIndex, frame] = targetTransforms[transformIndex].position; rotationsBeforeBaking[transformIndex, frame] = targetTransforms[transformIndex].rotation; } } } RestoreDefaultPose(animator, defaultPoseClip); // Bake and inverse solve to constraint. var bakeParameters = BakeUtils.FindBakeParameters(constraint); Assert.That(bakeParameters, Is.Not.Null); var bindings = bakeParameters.GetSourceCurveBindings(rigBuilder, constraint); AnimationMode.StartAnimationMode(); BakeUtils.BakeToConstraint(constraint, clip, defaultPoseClip, bindings, k_DefaultCurveFilterOptions); AnimationMode.StopAnimationMode(); #if DEBUG_BAKE_TO_CONSTRAINT AssetDatabase.CreateAsset(clip, "Assets/bakeToConstraintAfter.anim"); #endif RestoreDefaultPose(animator, defaultPoseClip); // Evaluate again with constraint active and take snapshots. var translationsAfterBaking = new Vector3[targetTransforms.Count, numberOfFrames + 1]; var rotationsAfterBaking = new Quaternion[targetTransforms.Count, numberOfFrames + 1]; using (var graph = new EvaluationGraph(rigBuilder, clip)) { graph.Evaluate(0f); for (int transformIndex = 0; transformIndex < targetTransforms.Count; ++transformIndex) { translationsAfterBaking[transformIndex, 0] = targetTransforms[transformIndex].position; rotationsAfterBaking[transformIndex, 0] = targetTransforms[transformIndex].rotation; } for (int frame = 1; frame <= numberOfFrames; ++frame) { graph.Evaluate(dt); for (int transformIndex = 0; transformIndex < targetTransforms.Count; ++transformIndex) { translationsAfterBaking[transformIndex, frame] = targetTransforms[transformIndex].position; rotationsAfterBaking[transformIndex, frame] = targetTransforms[transformIndex].rotation; } } } RestoreDefaultPose(animator, defaultPoseClip); if ((flags & CompareFlags.Rotation) != 0) { // Compare rotations var quaternionComparer = new RuntimeRiggingTestFixture.QuaternionEqualityComparer(k_RotationEpsilon); for (int transformIndex = 0; transformIndex < targetTransforms.Count; ++transformIndex) { for (int frame = 0; frame <= numberOfFrames; ++frame) { Assert.That(rotationsAfterBaking[transformIndex, frame], Is.EqualTo(rotationsBeforeBaking[transformIndex, frame]).Using(quaternionComparer), String.Format("Transform '{0}' rotation is set to {1} at frame {2}, but was expected to be {3}", targetTransforms[transformIndex].name, rotationsAfterBaking[transformIndex, frame].eulerAngles, frame, rotationsBeforeBaking[transformIndex, frame].eulerAngles)); } } } if ((flags & CompareFlags.Translation) != 0) { // Compare translations var positionComparer = new RuntimeRiggingTestFixture.Vector3EqualityComparer(k_Epsilon); for (int transformIndex = 0; transformIndex < targetTransforms.Count; ++transformIndex) { for (int frame = 0; frame <= numberOfFrames; ++frame) { Assert.That(translationsAfterBaking[transformIndex, frame], Is.EqualTo(translationsBeforeBaking[transformIndex, frame]).Using(positionComparer), String.Format("Transform '{0}' position is set to {1} at frame {2}, but was expected to be {3}", targetTransforms[transformIndex].name, translationsAfterBaking[transformIndex, frame], frame, translationsBeforeBaking[transformIndex, frame])); } } } }
/// <summary> /// Creates a compare operation. /// </summary> /// <param name="left">The left operand.</param> /// <param name="right">The right operand.</param> /// <param name="kind">The operation kind.</param> /// <param name="flags">Operation flags.</param> /// <returns>A node that represents the compare operation.</returns> public ValueReference CreateCompare( Value left, Value right, CompareKind kind, CompareFlags flags) { Debug.Assert(left != null, "Invalid left node"); Debug.Assert(right != null, "Invalid right node"); if (UseConstantPropagation) { var leftValue = left as PrimitiveValue; var rightValue = right as PrimitiveValue; if (leftValue != null && rightValue != null) { return(CompareFoldConstants(leftValue, rightValue, kind, flags)); } if (leftValue != null) { return(CreateCompare( right, left, CompareValue.InvertIfNonCommutative(kind), flags)); } if (left.Type is PrimitiveType leftType && leftType.BasicValueType == BasicValueType.Int1) { // Bool comparison -> convert to logical operation if (rightValue != null) { if (kind == CompareKind.Equal) { if (rightValue.Int1Value) { return(left); } return(CreateArithmetic(left, UnaryArithmeticKind.Not)); } else { if (rightValue.Int1Value) { return(CreateArithmetic(left, UnaryArithmeticKind.Not)); } return(left); } } } } return(Append(new CompareValue( Context, BasicBlock, left, right, kind, flags))); }
//----------------------------------------------------------------------------- // addSortKey //----------------------------------------------------------------------------- /// <summary> /// Add a sort key to the query. /// </summary> /// <param name="pvSortKeyContext"> /// Context that the current sort key is to be added relative to - either /// as a child or a sibling. If this is the first sort key, a zero should /// be passed in here. Otherwise, the value returned from a previous call /// to addSortKey should be passed in. /// </param> /// <param name="bChildToContext"> /// Indicates whether this sort key should be added as a child or a sibling /// to the sort key context that was passed in the pSortKeyContext parameter. /// NOTE: If ulSortKeyContext is zero, then the bChildToContext parameter is ignored. /// </param> /// <param name="bElement"> /// Indicates whether the current key component is an element or an attribute. /// </param> /// <param name="uiNameId"> /// Name ID of the current key component. /// </param> /// <param name="compareFlags"> /// Flags for doing string comparisons when sorting for this sort key component. /// Should be logical ORs of the members of <see cref="CompareFlags"/>. This /// parameter is only used if the component is a string element or attribute. /// </param> /// <param name="uiLimit"> /// Limit on the size of the key component. If the component is a string element /// or attribute, it is the number of characters. If the component is a binary /// element or attribute, it is the number of bytes. /// </param> /// <param name="uiKeyComponent"> /// Specifies which key component this sort key component is. A value of zero /// indicates that it is not a key component, but simply a context component for /// other key components. /// </param> /// <param name="bSortDescending"> /// Indicates that this key component should be sorted in descending order. /// </param> /// <param name="bSortMissingHigh"> /// Indicates that when the value for this key component is missing, it should /// be sorted high instead of low. /// </param> /// <returns> /// Returns a value that can be passed back into subsequent calls to addSortKey /// when this component needs to be used as a context for subsequent components. /// </returns> public IntPtr addSortKey( IntPtr pvSortKeyContext, bool bChildToContext, bool bElement, uint uiNameId, CompareFlags compareFlags, uint uiLimit, uint uiKeyComponent, bool bSortDescending, bool bSortMissingHigh) { RCODE rc; IntPtr pvContext; if ((rc = xflaim_Query_addSortKey( m_pQuery, pvSortKeyContext, (int)(bChildToContext ? 1 : 0), (int)(bElement ? 1 : 0), uiNameId, compareFlags, uiLimit, uiKeyComponent, (int)(bSortDescending ? 1 : 0), (int)(bSortMissingHigh ? 1 : 0), out pvContext)) != 0) { throw new XFlaimException( rc); } return( pvContext); }
//-------------------------------------------------------------------------------------------------- internal static bool CompareShape(TopoDS_Shape shape, string brepFile, CompareFlags flags = CompareFlags.CompareProperties) { // Get OCC Shape Assert.IsNotNull(shape); // Save to BREP ASCII var bytes = Occt.Helper.BRepExchange.WriteASCII(shape, flags.HasFlag(CompareFlags.SaveTriangulation)); Assert.IsNotNull(bytes); Assert.IsNotEmpty(bytes); // Read file to compare var referenceBytes = TestData.GetTestData(brepFile + ".brep"); if (referenceBytes == null) { TestData.WriteTestResult(bytes, brepFile + "_TestResult.brep"); Assume.That(false, $"{brepFile}: Reference shape file not found."); return(false); } // Possible additions: TopTools::Dump if (flags.HasFlag(CompareFlags.CompareBytes) && !bytes.SequenceEqual(referenceBytes)) { TestData.WriteTestResult(bytes, brepFile + "_TestResult.brep"); TestContext.WriteLine($"{brepFile}: Shape not equal to reference"); return(false); } if (flags.HasFlag(CompareFlags.CompareText)) { TestData.WriteTestResult(bytes, brepFile + "_TestResult.brep"); AssertHelper.IsSameText(referenceBytes, bytes, AssertHelper.TextCompareFlags.IgnoreFloatPrecision); return(true); } if (flags.HasFlag(CompareFlags.CompareProperties)) { var shape2 = Occt.Helper.BRepExchange.ReadASCII(referenceBytes); // Check transformation var trsf1 = shape.Location().Transformation(); var trsf2 = shape2.Location().Transformation(); for (int row = 1; row <= 3; row++) { for (int col = 1; col <= 4; col++) { if (!trsf2.Value(row, col).IsEqual(trsf1.Value(row, col), 0.00000000001)) { TestData.WriteTestResult(bytes, brepFile + "_TestResult.brep"); TestContext.WriteLine($"{brepFile}: Transformation is different at {col},{row}"); return(false); } } } string message; if (_CompareLinearProperties(shape, shape2, out message) || _CompareVolumeProperties(shape, shape2, out message) || _CompareSurfaceProperties(shape, shape2, out message)) { TestData.WriteTestResult(bytes, brepFile + "_TestResult.brep"); TestContext.WriteLine($"{brepFile}: {message}"); return(false); } } // Test was ok, delete result file if any left TestData.DeleteTestResult(brepFile + "_TestResult.brep"); return(true); }
private bool compareStrTest( string sLeftStr, bool bLeftWild, string sRightStr, bool bRightWild, CompareFlags compareFlags, bool bExpectedEqual, DbSystem dbSystem) { int iCmp; beginTest( "Compare Strings, Str1: \"" + sLeftStr + "\", Str2: \"" + sRightStr + "\""); try { iCmp = dbSystem.compareStrings( sLeftStr, bLeftWild, sRightStr, bRightWild, compareFlags, Languages.FLM_US_LANG); } catch (XFlaimException ex) { endTest( false, ex, "calling compareStrings"); return( false); } if ((bExpectedEqual && iCmp != 0) || (!bExpectedEqual && iCmp == 0)) { endTest( false, false); System.Console.WriteLine( "Expected Equal [{0}] != Result [{1}]", bExpectedEqual, iCmp); System.Console.WriteLine( "Compare Flags: {0}", compareFlags); System.Console.WriteLine( "Left Wild: {0}", bLeftWild); System.Console.WriteLine( "Right Wild: {0}", bRightWild); } endTest( false, true); return( true); }
// // - Methods - // /// <summary> /// Obsolete class, use the classes in the namespace DvtkHighLevelInterface.Common.Compare instead. /// <br></br> /// Do a static compare for the attribute sets supplied. /// /// Note that the parameters attributeSets and attributeSetDescriptions must have the same size and /// must be at least size 2. /// </summary> /// <param name="tableDescription">Description of the table.</param> /// <param name="attributeSets">The attribute sets to compare with each other.</param> /// <param name="attributeSetDescriptions">The descriptions of the attribute sets.</param> /// <param name="compareFlags"> /// The compare flags that may be supplied. The following combination of flags may be supplied (using bitwise Or): /// - CompareFlags.None: when only supplying this flag, the attributes are only displayed and no compare is performed. /// - CompareFlags.Compare_present: a check is performed if all attributes with the same tag are present. /// - CompareFlags.Compare_values: a check is performed if all attributes with the same tag have the same values. /// - CompareFlags.Compare_VR: a check is performed if all attributes with the same tag have the same VR. /// /// The compare flags are applied to all supplied attribute sets. /// </param> /// <returns>The results of the static compare presented as a table (that may be converted to HTML).</returns> public CompareResults CompareAttributeSets(String tableDescription, ArrayList attributeSets, StringCollection attributeSetDescriptions, CompareFlags compareFlags) { ArrayList compareFlagsForAttributeSets = new ArrayList(); // Use the supplied compare flags for all supplied attribute sets. for (int index = 0; index < attributeSets.Count; index++) { compareFlagsForAttributeSets.Add(compareFlags); } // Do a sanity check for the supplied parameters and do the actual compare. return(CompareAttributeSets(tableDescription, attributeSets, attributeSetDescriptions, compareFlagsForAttributeSets)); }
private static extern RCODE xflaim_Query_addOperator( IntPtr pQuery, eQueryOperators eOperator, CompareFlags eCompareFlags);
//----------------------------------------------------------------------------- // compareStrings //----------------------------------------------------------------------------- /// <summary> /// Compare two strings. /// </summary> /// <param name="sLeftString"> /// This is the string on the left side of the comparison operation. /// </param> /// <param name="bLeftWild"> /// This flag, if true, specifies that wildcard characters /// found in sLeftString should be treated as wildcard characters instead of /// literal characters to compare. If false, the wildcard character (*) is /// treated like a normal character. /// </param> /// <param name="sRightString"> /// This is the string on the right side of the comparison operation. /// </param> /// <param name="bRightWild"> /// This flag, if true, specifies that wildcard characters /// found in sRightString should be treated as wildcard characters instead of /// literal characters to compare. If false, the wildcard character (*) is /// treated like a normal character. /// </param> /// <param name="eCompareFlags"> /// Flags for doing string comparisons. Should be logical ORs of the members /// of <see cref="CompareFlags"/>. /// </param> /// <param name="eLanguage"> /// Language to use for doing collation of strings. /// </param> /// <returns> /// Returns a value indicating whether sLeftString is less than, equal to, /// or greater than sRightString. A value of -1 means sLeftString < sRightString. /// A value of 0 means the strings are equal. A value of 1 means that /// sLeftString > sRightString. /// </returns> public int compareStrings( string sLeftString, bool bLeftWild, string sRightString, bool bRightWild, CompareFlags eCompareFlags, Languages eLanguage) { RCODE rc; int iResult; if ((rc = xflaim_DbSystem_compareStrings( m_pDbSystem, sLeftString, (int)(bLeftWild ? 1 : 0), sRightString, (int)(bRightWild ? 1 : 0), eCompareFlags, eLanguage, out iResult)) != 0) { throw new XFlaimException( rc); } return( iResult); }
private static extern RCODE xflaim_Query_addSortKey( IntPtr pQuery, IntPtr pvSortKeyContext, int bChildToContext, int bElement, uint uiNameId, CompareFlags compareFlags, uint uiLimit, uint uiKeyComponent, int bSortDescending, int bSortMissingHigh, out IntPtr ppvContext);
/// <summary> /// Creates a compare operation. /// </summary> /// <param name="location">The current location.</param> /// <param name="left">The left operand.</param> /// <param name="right">The right operand.</param> /// <param name="kind">The operation kind.</param> /// <param name="flags">Operation flags.</param> /// <returns>A node that represents the compare operation.</returns> public ValueReference CreateCompare( Location location, Value left, Value right, CompareKind kind, CompareFlags flags) { var leftValue = left as PrimitiveValue; var rightValue = right as PrimitiveValue; if (leftValue != null && rightValue != null) { return(CompareFoldConstants( location, leftValue, rightValue, kind, flags)); } // Check whether we should move constants to the RHS if (leftValue != null) { // Adjust the compare kind and flags for swapping both operands kind = CompareValue.SwapOperands( kind, left.BasicValueType, right.BasicValueType, ref flags); // Create a new compare value using the updated kind and flags return(CreateCompare( location, right, left, kind, flags)); } if (left.Type is PrimitiveType leftType && leftType.BasicValueType == BasicValueType.Int1) { // Bool comparison -> convert to logical operation if (rightValue != null) { return(kind == CompareKind.Equal ? rightValue.Int1Value ? (ValueReference)left : CreateArithmetic( location, left, UnaryArithmeticKind.Not) : rightValue.Int1Value ? CreateArithmetic( location, left, UnaryArithmeticKind.Not) : (ValueReference)left); } } return(Append(new CompareValue( GetInitializer(location), left, right, kind, flags))); }
/// <summary> /// Obsolete class, use the classes in the namespace DvtkHighLevelInterface.Common.Compare instead. /// </summary> /// <param name="dicomAttributesToValidate">-</param> /// <param name="zeroBasedIndex">-</param> private void AddAttributeInformationForAttribute(DicomAttributesToValidate dicomAttributesToValidate, int zeroBasedIndex) { bool isAttributePresent = false; DicomAttributeToValidate dicomAttributeToValidate = dicomAttributesToValidate[zeroBasedIndex] as DicomAttributeToValidate; CompareFlags compareFlags = dicomAttributeToValidate.ValidationRuleDicomAttribute.CompareFlags; DicomAttributeFlags dicomAttributeFlags = dicomAttributeToValidate.ValidationRuleDicomAttribute.DicomAttributeFlags; if (dicomAttributeToValidate.Attribute is ValidAttribute) { isAttributePresent = true; } else { isAttributePresent = false; } // Attribute Tag column. if (this.displayAttributeTag) { if (isAttributePresent) { if (dicomAttributeToValidate.ValidationRuleDicomAttribute.DisplayFullTagSequence) { ArrayList tags = (dicomAttributeToValidate.Attribute as ValidAttribute).TagSequence.Tags; for (int tagIndex = 0; tagIndex < tags.Count; tagIndex++) { Tag tag = tags[tagIndex] as Tag; if (tag.ContainsIndex) { SetCellOK((int)this.columnIndexAttributeTag[zeroBasedIndex], "".PadRight(tagIndex, '>') + tag.DicomNotation + "(" + tag.IndexNumber + ")"); } else { SetCellOK((int)this.columnIndexAttributeTag[zeroBasedIndex], "".PadRight(tagIndex, '>') + tag.DicomNotation); } } } else { SetCellOK((int)this.columnIndexAttributeTag[zeroBasedIndex], ((ValidAttribute)dicomAttributeToValidate.Attribute).TagSequence.DicomNotation); } } else { if (dicomAttributeToValidate.ValidationRuleDicomAttribute.TagSequence == "") { SetCellNotApplicable((int)this.columnIndexAttributeTag[zeroBasedIndex]); } else { TagSequence tagSequence = new TagSequence(dicomAttributeToValidate.ValidationRuleDicomAttribute.TagSequence); ArrayList tags = tagSequence.Tags; for (int tagIndex = 0; tagIndex < tags.Count; tagIndex++) { Tag tag = tags[tagIndex] as Tag; if (tag.ContainsIndex) { SetCellOK((int)this.columnIndexAttributeTag[zeroBasedIndex], "".PadRight(tagIndex, '>') + tag.DicomNotation + "(" + tag.IndexNumber + ")"); } else { SetCellOK((int)this.columnIndexAttributeTag[zeroBasedIndex], "".PadRight(tagIndex, '>') + tag.DicomNotation); } } } } } // Attribute Name column. if (this.displayAttributeName) { if (isAttributePresent) { SetCellOK((int)this.columnIndexAttributeName[zeroBasedIndex], GetAttributeName(dicomAttributeToValidate.Attribute)); } else { if (dicomAttributeToValidate.ValidationRuleDicomAttribute.TagSequence == "") { SetCellNotApplicable((int)this.columnIndexAttributeName[zeroBasedIndex]); } else { SetCellOK((int)this.columnIndexAttributeName[zeroBasedIndex], "-"); } } } // Attribute Present column. if (this.displayAttributePresent) { if (dicomAttributeToValidate.ValidationRuleDicomAttribute.TagSequence == "") { SetCellNotApplicable((int)this.columnIndexAttributePresent[zeroBasedIndex]); } else { String presentString = ""; bool containsError = false; if (isAttributePresent) { presentString = "+"; } else { presentString = "-"; } if ((compareFlags & CompareFlags.Compare_present) == CompareFlags.Compare_present) { if (dicomAttributesToValidate.ContainsComparePresentErrors) { containsError = true; } } if ((dicomAttributeFlags & DicomAttributeFlags.Present) == DicomAttributeFlags.Present) { if (!isAttributePresent) { containsError = true; } } if ((dicomAttributeFlags & DicomAttributeFlags.Not_present) == DicomAttributeFlags.Not_present) { if (isAttributePresent) { containsError = true; } } if (containsError) { SetCellError((int)this.columnIndexAttributePresent[zeroBasedIndex], presentString); } else { SetCellOK((int)this.columnIndexAttributePresent[zeroBasedIndex], presentString); } } } // Attribute VR column. if (this.displayAttributeVR) { if (isAttributePresent) { bool containsError = false; if ((compareFlags & CompareFlags.Compare_VR) == CompareFlags.Compare_VR) { if (dicomAttributesToValidate.ContainsCompareVRErrors) { containsError = true; } } if (containsError) { SetCellError((int)this.columnIndexAttributeVR[zeroBasedIndex], dicomAttributeToValidate.Attribute.VR.ToString()); } else { SetCellOK((int)this.columnIndexAttributeVR[zeroBasedIndex], dicomAttributeToValidate.Attribute.VR.ToString()); } } else { SetCellNotApplicable((int)this.columnIndexAttributeVR[zeroBasedIndex]); } } // Attribute Values column. if (this.displayAttributeValues) { int columnIndex = (int)this.columnIndexAttributeValues[zeroBasedIndex]; if (isAttributePresent) { if (dicomAttributeToValidate.Attribute.VR == VR.SQ) { SetCellNotApplicable(columnIndex); } else { bool containsError = false; if ((compareFlags & CompareFlags.Compare_values) == CompareFlags.Compare_values) { if (dicomAttributesToValidate.ContainsCompareValuesErrors) { containsError = true; } } if ((dicomAttributeFlags & DicomAttributeFlags.Values) == DicomAttributeFlags.Values) { if (dicomAttributeToValidate.Attribute.Values.Count == 0) { containsError = true; } } if ((dicomAttributeFlags & DicomAttributeFlags.No_values) == DicomAttributeFlags.No_values) { if (dicomAttributeToValidate.Attribute.Values.Count > 0) { containsError = true; } } if (containsError) { SetCellError(columnIndex, dicomAttributeToValidate.Attribute.Values.ToString()); } else { SetCellOK(columnIndex, dicomAttributeToValidate.Attribute.Values.ToString()); } } } else { SetCellNotApplicable(columnIndex); } } }
/// <summary> /// Creates a compare operation. /// </summary> /// <param name="location">The current location.</param> /// <param name="left">The left operand.</param> /// <param name="right">The right operand.</param> /// <param name="kind">The operation kind.</param> /// <param name="flags">Operation flags.</param> /// <returns>A node that represents the compare operation.</returns> public ValueReference CreateCompare( Location location, Value left, Value right, CompareKind kind, CompareFlags flags) { if (UseConstantPropagation) { var leftValue = left as PrimitiveValue; var rightValue = right as PrimitiveValue; if (leftValue != null && rightValue != null) { return(CompareFoldConstants( location, leftValue, rightValue, kind, flags)); } if (leftValue != null) { // If the comparison was inverted, and we are comparing floats, // toggle between ordered/unordered float comparison. var compareKind = CompareValue.InvertIfNonCommutative(kind); var compareFlags = flags; if (compareKind != kind && left.BasicValueType.IsFloat() && right.BasicValueType.IsFloat()) { compareFlags ^= CompareFlags.UnsignedOrUnordered; } return(CreateCompare( location, right, left, compareKind, compareFlags)); } if (left.Type is PrimitiveType leftType && leftType.BasicValueType == BasicValueType.Int1) { // Bool comparison -> convert to logical operation if (rightValue != null) { return(kind == CompareKind.Equal ? rightValue.Int1Value ? (ValueReference)left : CreateArithmetic( location, left, UnaryArithmeticKind.Not) : rightValue.Int1Value ? CreateArithmetic( location, left, UnaryArithmeticKind.Not) : (ValueReference)left); } } } return(Append(new CompareValue( GetInitializer(location), left, right, kind, flags))); }
private static extern RCODE xflaim_DbSystem_compareStrings( IntPtr pDbSystem, [MarshalAs(UnmanagedType.LPWStr), In] string sLeftString, int bLeftWild, [MarshalAs(UnmanagedType.LPWStr), In] string sRightString, int bRightWild, CompareFlags eCompareRules, Languages eLanguage, out int piResult);
//----------------------------------------------------------------------------- // addOperator //----------------------------------------------------------------------------- /// <summary> /// Add an operator to a query's criteria. /// </summary> /// <param name="eOperator"> /// Operator to be added. /// </param> /// <param name="eCompareFlags"> /// Flags for doing string comparisons. Should be logical ORs of the /// enums in <see cref="CompareFlags"/>. These flags are only used /// when comparing string operands. /// </param> public void addOperator( eQueryOperators eOperator, CompareFlags eCompareFlags) { RCODE rc = 0; if ((rc = xflaim_Query_addOperator( m_pQuery, eOperator, eCompareFlags)) != 0) { throw new XFlaimException( rc); } }