Beispiel #1
0
 public ComplexBorderedVolume(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops, List <List <PlaneBorder> > enclosing_borders) : base(parent, mprops)
 {
     /*foreach (PlaneBorder aBorder in enclosing_borders) {
      *      Console.WriteLine("A border added to PlaneBorderEnclosedVolume: "+aBorder.getNormal().trico()+" @ "+aBorder.getCenterLoc());
      *      }*/
     this.subVolumes = new List <PlaneBorderEnclosedVolume>();
     foreach (List <PlaneBorder> pblist in enclosing_borders)
     {
         PlaneBorderEnclosedVolume pbvol = new PlaneBorderEnclosedVolume(null, mprops, pblist);
         this.subVolumes.Add(pbvol);
         //this.borders = enclosing_borders;
     }
     //Console.WriteLine("Number of subvolumes for {"+this.tag+"}: "+this.subVolumes.Count);
 }
 public ComplexBorderedVolume(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops, List<List<PlaneBorder>> enclosing_borders)
     : base(parent, mprops)
 {
     /*foreach (PlaneBorder aBorder in enclosing_borders) {
     Console.WriteLine("A border added to PlaneBorderEnclosedVolume: "+aBorder.getNormal().trico()+" @ "+aBorder.getCenterLoc());
     }*/
     this.subVolumes = new List<PlaneBorderEnclosedVolume>();
     foreach (List<PlaneBorder> pblist in enclosing_borders) {
     PlaneBorderEnclosedVolume pbvol = new PlaneBorderEnclosedVolume(null, mprops, pblist);
     this.subVolumes.Add(pbvol);
     //this.borders = enclosing_borders;
     }
     //Console.WriteLine("Number of subvolumes for {"+this.tag+"}: "+this.subVolumes.Count);
 }
        public Scientrace.PlaneBorderEnclosedVolume parseXTruncatedPyramid(XElement xTruncatedPyramid)
        {
            // Replaced with below: Scientrace.MaterialProperties materialprops = this.getXMaterial(xToppedPyramid.Element("Material"));
            Scientrace.MaterialProperties materialprops = this.getXMaterialForObject(xTruncatedPyramid);

            if ((xTruncatedPyramid.Name.ToString() != "TruncatedPyramid") && (xTruncatedPyramid.Name.ToString() != "ToppedPyramid"))
            {
                throw new XMLException("TruncatedPyramid does not match its name: " + xTruncatedPyramid.Name.ToString());
            }

            List <Scientrace.Location> front_corners = new List <Scientrace.Location>();

            Scientrace.Vector loc_sum = new Scientrace.Vector(0, 0, 0);
            foreach (XElement xFrontCorner in xTruncatedPyramid.Elements("Corner"))
            {
                Scientrace.Location loc = this.X.getXLocation(xFrontCorner);
                front_corners.Add(loc);
                loc_sum = loc_sum + loc;
            }
            Scientrace.Vector   loc_avg     = loc_sum / front_corners.Count;
            Scientrace.Location virtual_top = this.X.getXLocation(xTruncatedPyramid, "VirtualTop");
            // parsing topping plane data:
            XElement xTopPlane = xTruncatedPyramid.Element("TopPlane");

            if (xTopPlane == null)
            {
                throw new XMLException("TopPlane element not found... " + xTruncatedPyramid.ToString());
            }
            Scientrace.Location      topPlaneLoc    = this.X.getXLocation(xTopPlane, "Location");
            Scientrace.NonzeroVector topPlaneNormal = this.X.getXNzVectorByName(xTopPlane, "Normal");
            if (topPlaneNormal.dotProduct((topPlaneLoc - loc_avg)) > 0)
            {
                topPlaneNormal = topPlaneNormal.negative();
            }
            Scientrace.PlaneBorder topping_plane = new Scientrace.PlaneBorder(topPlaneLoc, topPlaneNormal);

            Scientrace.PlaneBorderEnclosedVolume tRetTruncatedPyramid = Scientrace.PlaneBorderEnclosedVolume.createTruncatedPyramid(this.parentcollection, materialprops,
                                                                                                                                    front_corners, virtual_top, topping_plane);
            return(tRetTruncatedPyramid);
        }