Beispiel #1
0
	public override string exportX3D(Object3dEnvironment env) {
		// Step 1: Collect base linepieces that would draw the basic structure
		List<ObjectLinePiece> baseLinePieces = new List<ObjectLinePiece>();		
		foreach (PlaneBorderEnclosedVolume aSubVolume in this.subVolumes) {
			baseLinePieces.AddRange(aSubVolume.getOLPBorderEdges());
			}

		// Step 2: Slice all linepieces that are intersected by other subVolumes
		List<ObjectLinePiece> slicedLinePieces = new List<ObjectLinePiece>();
		foreach (ObjectLinePiece anOLP in baseLinePieces) {
			// Distances/linepieces smaller than "significance" are considered insignificant ignored.
			if(anOLP.lp.getLength() < MainClass.SIGNIFICANTLY_SMALL)
				continue;
			List<ObjectLinePiece> olpChunks = new List<ObjectLinePiece>();
			List<ObjectLinePiece> newOLPChunks = new List<ObjectLinePiece>();
			
			olpChunks.Add(anOLP);
			foreach (PlaneBorderEnclosedVolume aSubVolume in this.subVolumes) {
				newOLPChunks = new List<ObjectLinePiece>();	//create empty new list
				foreach (ObjectLinePiece anOLPChunk in olpChunks) {
					newOLPChunks.AddRange(aSubVolume.sliceObjectLinePiece(anOLPChunk));
					} // end oldChunks
				olpChunks = newOLPChunks;
				} // end subVolumes
			
			slicedLinePieces.AddRange(newOLPChunks);
			} // end anOLP loop
		

		List<ObjectLinePiece> markedSlices = this.markInsideOutsideOLPs(this.cleanupLinePieceList(slicedLinePieces));

		Console.WriteLine("ComplexBorder gridline count: "+markedSlices.Count+" out of "+slicedLinePieces.Count);
		double foo = 0;
		foreach (ObjectLinePiece anOLP in markedSlices) {
			//foo += env.radius/2000;
			anOLP.lp.startingpoint.x= anOLP.lp.startingpoint.x + foo;
			anOLP.lp.endingpoint.x= anOLP.lp.endingpoint.x + foo;
			anOLP.lp.startingpoint.y= anOLP.lp.startingpoint.y + foo;
			anOLP.lp.endingpoint.y= anOLP.lp.endingpoint.y + foo;
			}

		// draw the linepieces after having checked and marked what's inside and outside
		//return LinePiece.drawLinePiecesXML(this.markInsideOutsideOLPs(baseLinePieces)); // <-- show non-sliced pieces only.
		string line_pieces_xml = LinePiece.drawLinePiecesXML(markedSlices);
		if (line_pieces_xml.Length < 1)
			Console.WriteLine("WARNING: the volume {"+this.tag+"} cannot be drawn.");
		return "<!-- ComplexVolume: "+this.tag+" -->"+line_pieces_xml+"<!-- END OF ComplexVolume: "+this.tag+" -->";
		}
Beispiel #2
0
        static public string drawLinePiecesXML(List <LinePiece> linePieces, string colour)
        {
            List <ObjectLinePiece> olps = new List <ObjectLinePiece>();

            foreach (LinePiece lp in linePieces)
            {
                ObjectLinePiece tolp = new ObjectLinePiece();
                tolp.col = colour;
                tolp.lp  = lp;
                olps.Add(tolp);
            }
            return(LinePiece.drawLinePiecesXML(olps));

            /*System.Text.StringBuilder retstr = new System.Text.StringBuilder(5000);
             * foreach (LinePiece lp in linePieces) {
             *      retstr.Append(X3DGridPoint.get_RGBA_Line_XML(lp, colour));
             *      }
             * return retstr.ToString(); */
        }
Beispiel #3
0
	public bool olpDictHasLine(Dictionary<LinePiece, ObjectLinePiece> probeDict, LinePiece aLinePiece, double vectorErrorMargin) {
		if (aLinePiece.startingpoint.distanceTo(aLinePiece.endingpoint) < vectorErrorMargin) {
			//Console.WriteLine("`Zero length` LinePiece found. What does not really exist may be assumed always present, therefor returning true.");
			return true;
			}
		Scientrace.Location[] locs = {aLinePiece.startingpoint, aLinePiece.endingpoint};
		foreach (LinePiece dictLP in probeDict.Keys) {
			for (int iLoc = 0; iLoc <= 1; iLoc++) {
				if (dictLP.startingpoint.distanceTo(locs[iLoc]) < vectorErrorMargin)
					if (dictLP.endingpoint.distanceTo(locs[1-iLoc]) < vectorErrorMargin) {
						//Console.WriteLine("DUPLICATE FOUND: "+dictLP+" overlaps with: "+aLinePiece);
						return true;
						}
				}
			}
		//Console.WriteLine("\nNEW FOUND: "+aLinePiece);
		// No overlapping linepieces found. Returning false.
		return false;
		}
Beispiel #4
0
 public static string get_RGBA_Line_XML(LinePiece anLP, string colorRGBAstring)
 {
     return X3DGridPoint.get_RGBA_Line_XML(anLP.startingpoint, anLP.endingpoint, colorRGBAstring);
 }
 public bool olpDictHasLine(Dictionary<LinePiece, ObjectLinePiece> probeDict, LinePiece aLinePiece, double vectorErrorMargin)
 {
     if (aLinePiece.startingpoint.distanceTo(aLinePiece.endingpoint) < vectorErrorMargin) {
     //Console.WriteLine("`Zero length` LinePiece found. What does not really exist may be assumed always present, therefor returning true.");
     return true;
     }
     Scientrace.Location[] locs = {aLinePiece.startingpoint, aLinePiece.endingpoint};
     foreach (LinePiece dictLP in probeDict.Keys) {
     for (int iLoc = 0; iLoc <= 1; iLoc++) {
         if (dictLP.startingpoint.distanceTo(locs[iLoc]) < vectorErrorMargin)
             if (dictLP.endingpoint.distanceTo(locs[1-iLoc]) < vectorErrorMargin) {
                 //Console.WriteLine("DUPLICATE FOUND: "+dictLP+" overlaps with: "+aLinePiece);
                 return true;
                 }
         }
     }
     //Console.WriteLine("\nNEW FOUND: "+aLinePiece);
     // No overlapping linepieces found. Returning false.
     return false;
 }
        public override string exportX3D(Object3dEnvironment env)
        {
            List <ObjectLinePiece> olps = this.getOLPBorderEdges();

            return(LinePiece.drawLinePiecesXML(olps));
        }
Beispiel #7
0
 public static string get_RGBA_Line_XML(LinePiece anLP, string colorRGBAstring)
 {
     return(X3DGridPoint.get_RGBA_Line_XML(anLP.startingpoint, anLP.endingpoint, colorRGBAstring));
 }