当前位置: 首页>>代码示例>>C#>>正文


C# Vertices.getAABB方法代码示例

本文整理汇总了C#中Vertices.getAABB方法的典型用法代码示例。如果您正苦于以下问题:C# Vertices.getAABB方法的具体用法?C# Vertices.getAABB怎么用?C# Vertices.getAABB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vertices的用法示例。


在下文中一共展示了Vertices.getAABB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: execute

		/// <summary>
		/// Implements "A new algorithm for Boolean operations on general polygons" 
		/// available here: http://liama.ia.ac.cn/wiki/_media/user:dong:dong_cg_05.pdf
		/// Merges two polygons, a subject and a clip with the specified operation. Polygons may not be 
		/// self-intersecting.
		/// 
		/// Warning: May yield incorrect results or even crash if polygons contain collinear points.
		/// </summary>
		/// <param name="subject">The subject polygon.</param>
		/// <param name="clip">The clip polygon, which is added, 
		/// substracted or intersected with the subject</param>
		/// <param name="clipType">The operation to be performed. Either
		/// Union, Difference or Intersection.</param>
		/// <param name="error">The error generated (if any)</param>
		/// <returns>A list of closed polygons, which make up the result of the clipping operation.
		/// Outer contours are ordered counter clockwise, holes are ordered clockwise.</returns>
		static List<Vertices> execute( Vertices subject, Vertices clip, PolyClipType clipType, out PolyClipError error )
		{
			Debug.Assert( subject.isSimple() && clip.isSimple(), "Non simple input! Input polygons must be simple (cannot intersect themselves)." );

			// Copy polygons
			Vertices slicedSubject;
			Vertices slicedClip;
			// Calculate the intersection and touch points between
			// subject and clip and add them to both
			calculateIntersections( subject, clip, out slicedSubject, out slicedClip );

			// Translate polygons into upper right quadrant
			// as the algorithm depends on it
			Vector2 lbSubject = subject.getAABB().lowerBound;
			Vector2 lbClip = clip.getAABB().lowerBound;
			Vector2 translate;
			Vector2.Min( ref lbSubject, ref lbClip, out translate );
			translate = Vector2.One - translate;
			if( translate != Vector2.Zero )
			{
				slicedSubject.translate( ref translate );
				slicedClip.translate( ref translate );
			}

			// Enforce counterclockwise contours
			slicedSubject.forceCounterClockWise();
			slicedClip.forceCounterClockWise();

			List<Edge> subjectSimplices;
			List<float> subjectCoeff;
			List<Edge> clipSimplices;
			List<float> clipCoeff;
			// Build simplical chains from the polygons and calculate the
			// the corresponding coefficients
			calculateSimplicalChain( slicedSubject, out subjectCoeff, out subjectSimplices );
			calculateSimplicalChain( slicedClip, out clipCoeff, out clipSimplices );

			List<Edge> resultSimplices;

			// Determine the characteristics function for all non-original edges
			// in subject and clip simplical chain and combine the edges contributing
			// to the result, depending on the clipType
			calculateResultChain( subjectCoeff, subjectSimplices, clipCoeff, clipSimplices, clipType,
								 out resultSimplices );

			List<Vertices> result;
			// Convert result chain back to polygon(s)
			error = buildPolygonsFromChain( resultSimplices, out result );

			// Reverse the polygon translation from the beginning
			// and remove collinear points from output
			translate *= -1f;
			for( int i = 0; i < result.Count; ++i )
			{
				result[i].translate( ref translate );
				SimplifyTools.collinearSimplify( result[i] );
			}
			return result;
		}
开发者ID:prime31,项目名称:Nez,代码行数:75,代码来源:YuPengClipper.cs


注:本文中的Vertices.getAABB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。