예제 #1
0
        void DrawHemiCubeTextures(AAFace radSourceFace, SatComponent radSource)
        {
            // Set camera position on radition source face
            Vector3 Position = radSource.GetFaceCenter(radSourceFace);
            // Get List of camera orientations
            List <AAFace> CameraDirections = HemiCube.GetFaceList(radSourceFace);

            for (int i = 0; i < CameraDirections.Count; i++)
            {
                // Orient camera
                Vector3 CameraPointingTarget = radSource.GetFaceDirection(Position, CameraDirections[i]);
                CamHemiCube.SetPositionTarget(Position, CameraPointingTarget, true);

                // Prepare rendertarget
                GraphicsDevice.SetRenderTarget(HemiCube.RTIndividual[i]);
                GraphicsDevice.Clear(Color.Black);

                // Render complete model without source
                if (Settings.f_DrawCompleteModel)
                {
                    Model.DrawCompleteModel(CamHemiCube, false, Color.White);
                }
                // Render only currently active radiation source (single face)
                else
                {
                    // Draw black bounding boxes for complete model
                    Model.DrawCompleteModel(CamHemiCube, true, Color.Black);
                    // Draw single bounding box face
                    //Model.Components[RadTargetIdx].DrawBoundingBoxFace(CamHemiCube, radTargetFace, Color.White);
                    Model.Components[RadTargetIdx].DrawMesh(CamHemiCube, Color.White);
                }
            }
        }
예제 #2
0
        void ComputeViewFactor()
        {
            // Components
            SatComponent Source     = Model.Components[RadSourceIdx];
            SatComponent Target     = Model.Components[RadTargetIdx];
            AAFace       SourceFace = FaceList[RadSourceFaceIdx];
            // Areas
            float SourceArea      = Source.GetBBoxTotalArea();
            float SourceFaceArea  = Source.GetBBoxFaceArea(SourceFace);
            float TargetArea      = Target.GetBBoxTotalArea();
            float AreaRatioSource = SourceFaceArea / SourceArea;
            // Adjust for large sources (since only looking from one position)
            float AreaRatioSourceTarget = SourceArea / TargetArea > 1 ? SourceArea / TargetArea : 1;
            // View factor F_s->t
            float Factor = GetPixelSum(RTViewFactor) / AreaRatioSourceTarget;
            // Area-weighted view factors
            float WeightedFactor = Factor * AreaRatioSource; // * AreaRatioTarget;
                                                             // Save results
            string SourceName = Source.Name;
            string TargetName = Target.Name;

            VFPerFace.Add(new ViewFactorPerFace(SourceName, TargetName, SourceFace, WeightedFactor));
            // Text output
            if (!Settings.f_ComputationRunning || Settings.f_Verbose)
            {
                Console.Write("From (" + SourceName + "," + SourceFace + ")");
                Console.WriteLine(" to (" + TargetName + ")");
                Console.Write("\t Weighted view factor = " + WeightedFactor.ToString("F6", Settings.Format));
                Console.WriteLine(" (" + Factor.ToString("F3", Settings.Format) + ")");
                Console.WriteLine("\t Source area ratio = " + AreaRatioSource.ToString("F4", Settings.Format));
            }
            Settings.f_ComputeArea = false;
            // Save values for verification
            if (f_StartVerification)
            {
                v_Results.Add(v_StepNum * v_DistStep, Factor);
            }
            // Progress
            if (Settings.f_ComputationRunning)
            {
                if ((CurrentCalc % (int)Math.Ceiling(MaxCalc / 10.0f)) == 0)
                {
                    Console.Write('.');
                }
            }
        }
예제 #3
0
        Dictionary <ViewFactorCoordinate, float> FindInconsistencies(Dictionary <ViewFactorCoordinate, float> toCheck)
        {
            Dictionary <ViewFactorCoordinate, float> Results = new Dictionary <ViewFactorCoordinate, float>();

            foreach (KeyValuePair <ViewFactorCoordinate, float> p in toCheck)
            {
                // If zero value, check reciprocal
                if (p.Value == 0)
                {
                    ViewFactorCoordinate CRec = p.Key.Swap();
                    if (toCheck.TryGetValue(CRec, out float VFRec))
                    {
                        SatComponent Source = Model.Components.Find(x => string.Compare(x.Name, p.Key.SourceName, true) == 0);
                        SatComponent Target = Model.Components.Find(x => string.Compare(x.Name, p.Key.TargetName, true) == 0);

                        if (Source != null && Target != null)
                        {
                            float AreaSource = Source.GetBBoxTotalArea();
                            float AreaTarget = Target.GetBBoxTotalArea();

                            try
                            {
                                VFRec = AreaTarget / AreaSource * VFRec;
                                if (Settings.f_Verbose)
                                {
                                    Console.WriteLine("\tChanging VF from " + p.Value.ToString("F4", Settings.Format) + " to " + VFRec.ToString("F4", Settings.Format));
                                }
                            }
                            catch
                            {
                                VFRec = p.Value;
                            }
                        }
                    }
                    Results.Add(p.Key, VFRec);
                }
                else
                {
                    Results.Add(p.Key, p.Value);
                }
            }
            return(Results);
        }