Пример #1
0
        /* END CONSTRUCTORS */

        public override bool directedTowardsObjectside(Scientrace.SurfaceSide side, Trace aTrace)
        {
            Scientrace.NonzeroVector traceline_direction = aTrace.traceline.direction;
            switch (side)
            {
            case Scientrace.SurfaceSide.Back:             // == SurfaceSide.Inside
                // Vector is directed TOWARDS (so in the contrary direction) of the surface normal
//				if (aVector.dotProduct(this.front_normal_direction)>0)

                /*Console.WriteLine(aTrace.traceid+" analysing: "+traceline_direction.tricon()+" from: "+aTrace.traceline.startingpoint.tricon()+
                 *      aTrace.parent.intensityFraction()+" = intensity \n"+
                 *      " DISTANCE: "+(aTrace.endloc-aTrace.traceline.startingpoint).length +" direction along: "+this.front_normal_direction.trico()+ " @"+aTrace.currentObject.GetType()); */
                return(traceline_direction.dotProduct(this.front_normal_direction) > 0);

            //break;
            case Scientrace.SurfaceSide.Front:
                // Vector is directed AWAY FROM (so along the direction) of the surface normal
                return(traceline_direction.dotProduct(this.front_normal_direction) < 0);

            //break;
            case Scientrace.SurfaceSide.Both:
                return(true);

            //break;
            default:
                throw new NotImplementedException("Side " + side.ToString() + " not implemented");
                //break;
            }
        }
Пример #2
0
        public virtual bool directedTowardsObjectside(Scientrace.SurfaceSide side, Scientrace.Trace aTrace)
        {
            switch (side)
            {
            case Scientrace.SurfaceSide.Back:             // == SurfaceSide.Inside
                throw new NotImplementedException("Side " + side.ToString() + " not implemented for class" + this.GetType().ToString());

            //break;
            case Scientrace.SurfaceSide.Front:
                throw new NotImplementedException("Side " + side.ToString() + " not implemented for class" + this.GetType().ToString());

            //break;
            case Scientrace.SurfaceSide.Both:
                return(true);

            //break;
            default:
                throw new NotImplementedException("Side " + side.ToString() + " not implemented");
                //break;
            }
        }
        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());
        }