protected override Size ArrangeOverride(Size arrangeSize) { var internalChild = InternalChild; if (internalChild != null) { var desiredSize = internalChild.DesiredSize; var oldScale = currentScale; currentScale = ComputeScaleFactor(arrangeSize, desiredSize, Stretch, StretchDirection); if (InternalTransform == null) { InternalTransform = new ScaleTransform(currentScale.Width, currentScale.Height); } else { scaleXAnimation.From = oldScale.Width; scaleXAnimation.To = currentScale.Width; scaleYAnimation.From = oldScale.Height; scaleYAnimation.To = currentScale.Height; InternalTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleXAnimation); InternalTransform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleYAnimation); } internalChild.Arrange(new Rect(default(Point), internalChild.DesiredSize)); arrangeSize.Width = currentScale.Width * desiredSize.Width; arrangeSize.Height = currentScale.Height * desiredSize.Height; } return(arrangeSize); }
public new void Tessellate(IRenderPackage package, TessellationParameters parameters) { //Ensure that the object is still alive if (!IsAlive) { return; } //Location Point DB.LocationPoint locPoint = InternalElement.Location as DB.LocationPoint; GeometryPrimitiveConverter.ToPoint(InternalTransform.OfPoint(locPoint.Point)).Tessellate(package, parameters); package.ApplyPointVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, 255, 0, 0, 0)); //Boundaries foreach (DB.BoundarySegment segment in InternalBoundarySegments) { Curve crv = RevitToProtoCurve.ToProtoType(segment.GetCurve().CreateTransformed(InternalTransform)); crv.Tessellate(package, parameters); if (package.LineVertexCount > 0) { package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, 255, 0, 0, 0)); } } }
/// <summary> /// Return a grid of points in the space /// </summary> /// <param name="step">Lenght between two points</param> public List <Point> Grid(double step) { step = UnitConverter.DynamoToHostFactor(DB.UnitType.UT_Length) * step; List <Point> grid = new List <Point>(); DB.BoundingBoxXYZ bb = InternalElement.get_BoundingBox(null); for (double x = bb.Min.X; x < bb.Max.X;) { for (double y = bb.Min.Y; y < bb.Max.Y;) { DB.XYZ point = new DB.XYZ(x, y, bb.Min.Z); if (InternalSpace.IsPointInSpace(point)) { grid.Add(GeometryPrimitiveConverter.ToPoint(InternalTransform.OfPoint(point))); } y = y + step; } x = x + step; } return(grid); }
/// <summary> /// Creates an IDataTransform from an IDataView. /// </summary> internal IDataTransform MakeDataTransform(IDataView input) => InternalTransform.MakeDataTransform(input);
/// <summary> /// Creates a row mapper from Schema. /// </summary> internal IStatefulRowMapper MakeRowMapper(DataViewSchema schema) => InternalTransform.MakeRowMapper(schema);
private protected virtual void SaveModel(ModelSaveContext ctx) { InternalTransform.SaveThis(ctx); }
/// <summary> /// Initialize a transformer which will do lambda transfrom on input data in prediction engine. No actual transformations happen here, just schema validation. /// </summary> public IDataView Transform(IDataView input) => InternalTransform.Transform(input);
/// <summary> /// Schema propagation for transformers. /// Returns the output schema of the data, if the input schema is like the one provided. /// </summary> public DataViewSchema GetOutputSchema(DataViewSchema inputSchema) => InternalTransform.GetOutputSchema(inputSchema);
/// <summary> /// Create a clone of the transformer. Used for taking the snapshot of the state. /// </summary> IStatefulTransformer IStatefulTransformer.Clone() => InternalTransform.Clone();
internal SsaChangePointDetector(IHostEnvironment env, Options options) : base(new BaseArguments(options), LoaderSignature, env) { switch (InternalTransform.Martingale) { case MartingaleType.None: InternalTransform.AlertThreshold = Double.MaxValue; break; case MartingaleType.Power: InternalTransform.AlertThreshold = Math.Exp(InternalTransform.WindowSize * InternalTransform.LogPowerMartigaleBettingFunc(1 - options.Confidence / 100, InternalTransform.PowerMartingaleEpsilon)); break; case MartingaleType.Mixture: InternalTransform.AlertThreshold = Math.Exp(InternalTransform.WindowSize * InternalTransform.LogMixtureMartigaleBettingFunc(1 - options.Confidence / 100)); break; default: InternalTransform.Host.Assert(!Enum.IsDefined(typeof(MartingaleType), InternalTransform.Martingale)); throw InternalTransform.Host.ExceptUserArg(nameof(options.Martingale), "Value not defined."); } }
/// <summary> /// For saving a model into a repository. /// </summary> public virtual void Save(ModelSaveContext ctx) => InternalTransform.SaveThis(ctx);
/// <summary> /// Constructs a row-to-row mapper based on an input schema. If <see cref="IsRowToRowMapper"/> /// is <c>false</c>, then an exception should be thrown. If the input schema is in any way /// unsuitable for constructing the mapper, an exception should likewise be thrown. /// </summary> /// <param name="inputSchema">The input schema for which we should get the mapper.</param> /// <returns>The row to row mapper.</returns> public IRowToRowMapper GetRowToRowMapper(Schema inputSchema) => InternalTransform.GetRowToRowMapper(inputSchema);
/// <summary> /// Schema propagation for transformers. /// Returns the output schema of the data, if the input schema is like the one provided. /// </summary> public Schema GetOutputSchema(Schema inputSchema) => InternalTransform.GetOutputSchema(inputSchema);
internal IidChangePointDetector(IHostEnvironment env, Options options) : base(new BaseArguments(options), LoaderSignature, env) { switch (InternalTransform.Martingale) { case MartingaleType.None: InternalTransform.AlertThreshold = Double.MaxValue; break; case MartingaleType.Power: InternalTransform.AlertThreshold = Math.Exp(InternalTransform.WindowSize * InternalTransform.LogPowerMartigaleBettingFunc(1 - options.Confidence / 100, InternalTransform.PowerMartingaleEpsilon)); break; case MartingaleType.Mixture: InternalTransform.AlertThreshold = Math.Exp(InternalTransform.WindowSize * InternalTransform.LogMixtureMartigaleBettingFunc(1 - options.Confidence / 100)); break; default: throw InternalTransform.Host.ExceptParam(nameof(options.Martingale), "The martingale type can be only (0) None, (1) Power or (2) Mixture."); } }
/* * this function creates a HumanDescription given the parameters for your character * required: * GameObject character: the GameObject that will be your character * optional: * string skeletonfile: text file name (minus the extension) in the Resources folder that describes a mapping from your bone names to Unity's bone names * string tposefile: text file name (minus extension) that contains the transforms that put your character in tpose. can use AvatarUtils to do this * bool useLocalPositionAndScale: if you are using multiple characters with the same rig but potentially different sizes, you'll want to set this to true * effectively this uses the tposefile rotations only, ignoring the position and rotation */ private HumanDescription setupHumanDescription(GameObject character, string skeletonfile = "", string tposefile = "", bool useLocalPositionAndScale = true) { HumanDescription desc = new HumanDescription(); //first load in the bone mapping from the file, if that file is provided List <HumanBone> mappedBones = new List <HumanBone>(); List <SkeletonBone> allBones = new List <SkeletonBone>(); if (skeletonfile != "") { loadSkeletonCorrespondences(character, skeletonfile, ref mappedBones, ref allBones); } //then load in the tpose mapping that transforms your character's skeleton to the tpose, if that file is provided Dictionary <string, InternalTransform> tposeTransforms = new Dictionary <string, InternalTransform>(); if (tposefile != "") { loadTposeMapping(tposefile, ref tposeTransforms); } //Set up the parameters for the human description //the human bone array is the list we've already composed using the loadSkeletonCorrespondences function HumanBone[] human = mappedBones.ToArray(); //we have to do some extra work for the skeleton bones since this is where the tpose transform is stored and we haven't //yet read that in from a file (if it exists) SkeletonBone[] sk = allBones.ToArray(); //for all the bones in the skeleton for (int i = 0; i < sk.Length; i++) { string mappedName = ""; //When Unity loads in the character from file, it automatically affixes a "(Clone)" on the end of the filename //the way my skeletons are set up, the parent of the hip bone is named the name of the file //but because each character's name is different but my skeleton file stays the same, in the mapping file //I call it "root", while in the hierarchy it's called whatever the filename is //this little if-statement sequence resolves that if (sk[i].name == character.name.Substring(0, character.name.IndexOf('('))) { mappedName = "root"; } else { mappedName = sk[i].name; } //we need to add in the transform information to make it into t-pose //get the transforms that came from the file InternalTransform fileTransform; if (tposeTransforms.ContainsKey(mappedName)) { fileTransform = tposeTransforms[mappedName]; } //warn if there was a tpose file but it did not contain any transform else { if (tposefile != "") { Debug.LogWarning("Warning: tpose mapping for bone " + sk[i].name + " not found in tpose file " + tposefile + ". Defaulting back to the local transforms."); } fileTransform = new InternalTransform(recursiveSearch(sk[i].name, character.transform)); } //get the transforms that come from the local skeleton Transform foundTransform = recursiveSearch(sk[i].name, character.transform); InternalTransform localTransform; //if we didn't find a transform for that bone name if (foundTransform == null) { //warn and default to 0,0,0 Debug.Log("Did not find bone transform " + sk[i].name + " in hierarchy. Defaulting to empty transform."); localTransform = new InternalTransform(); } else { //otherwise assign that transform that was found in the gameobject hierarchy localTransform = new InternalTransform(foundTransform); } ///once you've found the transforms go ahead and assign them to the skeleton bone attributes /// rotation always comes from the tpose file (which of course falls back to the local rotation if not set) sk[i].rotation = new Quaternion(fileTransform.localRotation.x, fileTransform.localRotation.y, fileTransform.localRotation.z, fileTransform.localRotation.w); //if the user wanted to use the existing local scale and position do that if (useLocalPositionAndScale) { sk[i].position = new Vector3(localTransform.localPosition.x, localTransform.localPosition.y, localTransform.localPosition.z); sk[i].scale = new Vector3(localTransform.localScale.x, localTransform.localScale.y, localTransform.localScale.z); } //otherwise grab what was loaded in from the tpose file else { sk[i].position = new Vector3(fileTransform.localPosition.x, fileTransform.localPosition.y, fileTransform.localPosition.z); sk[i].scale = new Vector3(fileTransform.localScale.x, fileTransform.localScale.y, fileTransform.localScale.z); } /* * you could uncomment this to set the character to t-pose * recursiveSearch(sk[i].name, character.transform).localPosition = sk[i].position; * recursiveSearch(sk[i].name, character.transform).localRotation = sk[i].rotation; * recursiveSearch(sk[i].name, character.transform).localScale = sk[i].scale; * */ } //set the bone arrays right desc.human = human; desc.skeleton = sk; //set the default values for the rest of the human descriptor parameters desc.upperArmTwist = 0.5f; desc.lowerArmTwist = 0.5f; desc.upperLegTwist = 0.5f; desc.lowerLegTwist = 0.5f; desc.armStretch = 0.05f; desc.legStretch = 0.05f; desc.feetSpacing = 0.0f; //return the human description return(desc); }