Esempio n. 1
0
 /// <summary>
 /// Returns true if two Plane-instances cover the same area
 /// </summary>
 /// <returns><c>true</c> if planes overlap, <c>false</c> otherwise.</returns>
 /// <param name="anotherPlane">the other plane.</param>
 public bool overlapsWithPlane(Scientrace.PlaneBorder anotherPlane)
 {
     if ((this.allowedDirNormal.normalized().toVector() - anotherPlane.allowedDirNormal.normalized().toVector()).length > MainClass.SIGNIFICANTLY_SMALL)
     {
         return(false);        //Normals differ significantly. Nuff said.
     }
     // Normals are considered equal. Are the planes locations in space?
     Scientrace.Location loc1 = (this.lineThroughPlane(new Line(Location.ZeroLoc(), this.getNormal())));
     Scientrace.Location loc2 = (anotherPlane.lineThroughPlane(new Line(Location.ZeroLoc(), this.getNormal())));
     // if these locations are considered the same, the planes overlap.
     return((loc1 - loc2).length < MainClass.SIGNIFICANTLY_SMALL);
 }
        public string exportSVG(Scientrace.PhysicalObject3d anObject, Scientrace.SurfaceSide side, Scientrace.PDPSource pdpSource)
        {
            //Scientrace.Parallelogram surface = anObject.getDistributionSurface();
            //this.spotsize = Math.Sqrt(Math.Pow(surface.u.length,2)+Math.Pow(surface.v.length,2))*this.spotdiagonalfraction;
            this.spotsize = Math.Sqrt(Math.Pow(anObject.svgxsize, 2) + Math.Pow(anObject.svgysize, 2)) * this.spotdiagonalfraction;
            StringBuilder retstr = new StringBuilder(10000000);     // this string may become very big, allocating this amount of memory may help.

            retstr.Append(this.exportSVGOpening(anObject));

            Scientrace.Location loc2d;

            StringBuilder pol_lines   = new StringBuilder("<!-- START OF POLARISATION LINES -->", 300000);
            StringBuilder centerSpots = new StringBuilder("<!-- START OF SPOTS CENTERS -->", 300000);

            //Console.WriteLine("Now writing "+this.spots.Count+" spots");
            //int icount = 0;
            foreach (Scientrace.Spot casualty in this.spots)
            {
                if ((casualty.object3d == anObject) &&
                    (anObject.directedTowardsObjectside(side, casualty.trace)))
                {
                    loc2d = anObject.getSVG2DLoc(casualty.loc);


//				double pol_fac_1 = Math.Pow(casualty.pol_vec_1.length,2)*1.0;//*casualty.pol_vec_1.length * casualty.intensity*3;
//				double pol_fac_2 = Math.Pow(casualty.pol_vec_2.length,2)*1.0;//*casualty.pol_vec_2.length * casualty.intensity*3;

                    double pol_fac_1 = Math.Pow(casualty.pol_vec_1.length, 1) * 1.00 * Math.Sqrt(casualty.intensity);       //*casualty.pol_vec_1.length * casualty.intensity*3;
                    double pol_fac_2 = Math.Pow(casualty.pol_vec_2.length, 1) * 1.00 * Math.Sqrt(casualty.intensity);       //*casualty.pol_vec_2.length * casualty.intensity*3;

                    Scientrace.Vector pol_vec_1_2d = (anObject.get2DLoc(
                                                          casualty.pol_vec_1.projectOnPlaneWithNormal(anObject.getSurfaceNormal()).toLocation()
                                                          ) - anObject.get2DLoc(Location.ZeroLoc())).normaliseIfNotZero() * pol_fac_1;
                    Scientrace.Vector pol_vec_2_2d = (anObject.get2DLoc(
                                                          casualty.pol_vec_2.projectOnPlaneWithNormal(anObject.getSurfaceNormal()).toLocation()
                                                          ) - anObject.get2DLoc(Location.ZeroLoc())).normaliseIfNotZero() * pol_fac_2;

                    if (this.svg_export_photoncloud)
                    {
                        retstr.Append(@"<g>
<circle cx='" + loc2d.x + "' cy='" + (anObject.svgysize - loc2d.y) + "' r='" + (Math.Sqrt(casualty.intensity) * this.spotsize) + "' style='" +
                                      "fill:" + this.getPhotonColourForPDPSource(casualty, pdpSource, anObject)
                                      + @";fill-opacity:0.3;stroke:none'>
<title><!-- Tooltip -->" + this.spotDescriptor(casualty, anObject, true) + @"</title>
</circle>
</g>");
                    }             // end if draw photoncloud (to create the frogg-egg kinda image)

                    centerSpots.Append(@"<g>
<circle cx='" + loc2d.x + "' cy='" + (anObject.svgysize - loc2d.y) + "' r='" + (Math.Sqrt(casualty.intensity) * this.spotsize / (this.svg_export_photoncloud?4:1)) + "' style='" +
                                       "fill:" + this.getPhotonColourForPDPSource(casualty, pdpSource, anObject)
                                       + @";fill-opacity:8;stroke:none'>
<title><!-- Tooltip -->" + this.spotDescriptor(casualty, anObject, false) + @"</title>
</circle>
</g>");
                    pol_lines.Append(@"
 <line x1='" + (loc2d.x - (pol_vec_1_2d.x * this.spotsize)) + "' y1='" + (anObject.svgysize - (loc2d.y - (pol_vec_1_2d.y * this.spotsize))) + "' x2='" + (loc2d.x + (pol_vec_1_2d.x * this.spotsize)) + "' y2='" + (anObject.svgysize - (loc2d.y + (pol_vec_1_2d.y * this.spotsize))) + "' style='stroke:rgb(0,96,192);stroke-width:" + (casualty.intensity * this.spotsize / 5) + @"' />
 <line x1='" + (loc2d.x - (pol_vec_2_2d.x * this.spotsize)) + "' y1='" + (anObject.svgysize - (loc2d.y - (pol_vec_2_2d.y * this.spotsize))) + "' x2='" + (loc2d.x + (pol_vec_2_2d.x * this.spotsize)) + "' y2='" + (anObject.svgysize - (loc2d.y + (pol_vec_2_2d.y * this.spotsize))) + "' style='stroke:rgb(192,96,0);stroke-width:" + (casualty.intensity * this.spotsize / 5) + @"' />
 <line x1='" + (loc2d.x - (pol_vec_1_2d.x * this.spotsize)) + "' y1='" + (anObject.svgysize - (loc2d.y - (pol_vec_1_2d.y * this.spotsize))) + "' x2='" + (loc2d.x + (pol_vec_1_2d.x * this.spotsize)) + "' y2='" + (anObject.svgysize - (loc2d.y + (pol_vec_1_2d.y * this.spotsize))) + "' style='stroke:rgb(256,256,256);stroke-width:" + (casualty.intensity * this.spotsize / 8) + @"' />
 <line x1='" + (loc2d.x - (pol_vec_2_2d.x * this.spotsize)) + "' y1='" + (anObject.svgysize - (loc2d.y - (pol_vec_2_2d.y * this.spotsize))) + "' x2='" + (loc2d.x + (pol_vec_2_2d.x * this.spotsize)) + "' y2='" + (anObject.svgysize - (loc2d.y + (pol_vec_2_2d.y * this.spotsize))) + "' style='stroke:rgb(256,256,256);stroke-width:" + (casualty.intensity * this.spotsize / 8) + @"' />
");
                }                 // end condition for spot to be on the correct object and from the proper direction
            }
            centerSpots.Append("<!-- END OF CENTERSPOTS -->");
            pol_lines.Append("<!-- END OF POLARISATION LINES -->");
            retstr.Append(centerSpots);
            retstr.Append(pol_lines);
            foreach (Scientrace.SurfaceMarker marker in anObject.markers)
            {
                retstr.Append(marker.exportSVG());
            }
            if (this.inline_legend)
            {
                retstr.Append("<!-- Start Legend for " + pdpSource.ToString() + " -->");
                retstr.Append(this.colourLegend(pdpSource));
                retstr.Append("<!-- End Legend for " + pdpSource.ToString() + " -->");
            }
            retstr.Append("</svg> ");
            return(retstr.ToString());
        }