本文整理汇总了C#中UV类的典型用法代码示例。如果您正苦于以下问题:C# UV类的具体用法?C# UV怎么用?C# UV使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UV类属于命名空间,在下文中一共展示了UV类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DistanceBetweenPoints
public static double DistanceBetweenPoints(this Surface surface, UV point1, UV point2)
{
Point A = surface.PointAtParameter(point1.U, point1.V);
Point B = surface.PointAtParameter(point2.U, point2.V);
return A.DistanceTo(B);
}
示例2: GetXIntercept
/// <summary>
/// Determine the X intercept of a polygon edge
/// with a horizontal line at the Y value of the
/// test point.
/// </summary>
public static double GetXIntercept(UV p, UV q, double y)
{
Debug.Assert(0 != (p.V - q.V),
"unexpected horizontal segment");
return q.U
- ((q.V - y)
* ((p.U - q.U) / (p.V - q.V)));
}
示例3: Execute
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
ExternalCommandData cdata = commandData;
Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application;
Document doc = commandData.Application.ActiveUIDocument.Document;
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
SpatialFieldManager sfm = SpatialFieldManager.GetSpatialFieldManager(doc.ActiveView);
if (sfm == null) sfm = SpatialFieldManager.CreateSpatialFieldManager(doc.ActiveView, 1);
IList<Reference> refList = new List<Reference>();
refList = uiDoc.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Face);
foreach (Reference reference in refList)
{
IList<UV> uvPts = new List<UV>();
List<double> doubleList = new List<double>();
IList<ValueAtPoint> valList = new List<ValueAtPoint>();
Face face = doc.GetElement(reference).GetGeometryObjectFromReference(reference)as Face;
BoundingBoxUV bb = face.GetBoundingBox();
UV min = bb.Min;
UV max = bb.Max;
for (double u = min.U; u < max.U; u += (max.U - min.U) / 10)
{
for (double v = min.V; v < max.V; v += (max.V - min.V) / 10)
{
UV uv = new UV(u, v);
if (face.IsInside(uv))
{
uvPts.Add(uv);
doubleList.Add(v + DateTime.Now.Second);
valList.Add(new ValueAtPoint(doubleList));
doubleList.Clear();
}
}
}
FieldDomainPointsByUV pnts = new FieldDomainPointsByUV(uvPts);
FieldValues vals = new FieldValues(valList);
int idx = sfm.AddSpatialFieldPrimitive(reference);
AnalysisResultSchema resultSchema = new AnalysisResultSchema("Schema 1", "Schema 1 Description");
sfm.UpdateSpatialFieldPrimitive(idx, pnts, vals, sfm.RegisterResult(resultSchema));
}
return Result.Succeeded;
}
示例4: Execute
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
Result rc = Result.Failed;
ViewPlan view = commandData.View as ViewPlan;
if( null == view
|| view.ViewType != ViewType.AreaPlan )
{
message = "Please run this command in an area plan view.";
return rc;
}
UIApplication app = commandData.Application;
UIDocument uidoc = app.ActiveUIDocument;
Document doc = uidoc.Document;
Element room = Util.GetSingleSelectedElement( uidoc );
if( null == room || !(room is Room) )
{
room = Util.SelectSingleElement( uidoc, "a room" );
}
if( null == room || !( room is Room ) )
{
message = "Please select a single room element.";
}
else
{
using ( Transaction t = new Transaction( doc ) )
{
t.Start( "Create New Area" );
Location loc = room.Location;
LocationPoint lp = loc as LocationPoint;
XYZ p = lp.Point;
UV q = new UV( p.X, p.Y );
Area area = doc.Create.NewArea( view, q );
rc = Result.Succeeded;
t.Commit();
}
}
return rc;
}
示例5: Execute
public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Application revit = commandData.Application;
Document curDoc = revit.ActiveDocument;
Level createlevel = curDoc.ActiveView.GenLevel;
UV point = new UV(0, 0);
// 利用标高,坐标创建房间对象
Room createdRoom = curDoc.Create.NewRoom(createlevel, ref point);
if (null == createdRoom)
{
message = "Create the wall failed.";
return IExternalCommand.Result.Failed;
}
curDoc.Create.NewRoomTag(createdRoom, ref point);
return IExternalCommand.Result.Succeeded;
}
示例6: PolygonContains
/// <summary>
/// Determine whether given 2D point lies within
/// the polygon.
///
/// Written by Jeremy Tammik, Autodesk, 2009-09-23,
/// based on code that I wrote back in 1996 in C++,
/// which in turn was based on C code from the
/// article "An Incremental Angle Point in Polygon
/// Test" by Kevin Weiler, Autodesk, in "Graphics
/// Gems IV", Academic Press, 1994.
///
/// Copyright (C) 2009 by Jeremy Tammik. All
/// rights reserved.
///
/// This code may be freely used. Please preserve
/// this comment.
/// </summary>
public static bool PolygonContains(List<UV> polygon, UV point)
{
// initialize
Int32 quad = GetQuadrant(
polygon[0], point);
Int32 angle = 0;
// loop on all vertices of polygon
Int32 next_quad, delta;
int n = polygon.Count;
for (int i = 0; i < n; ++i)
{
UV vertex = polygon[i];
UV next_vertex = polygon[(i + 1 < n) ? i + 1 : 0];
// calculate quadrant and delta from last quadrant
next_quad = GetQuadrant(next_vertex, point);
delta = next_quad - quad;
AdjustDelta(
ref delta, vertex, next_vertex, point);
// add delta to total angle sum
angle = angle + delta;
// increment for next step
quad = next_quad;
}
// complete 360 degrees (angle of + 4 or -4 )
// means inside
return (angle == +4) || (angle == -4);
// odd number of windings rule:
// if (angle & 4) return INSIDE; else return OUTSIDE;
// non-zero winding rule:
// if (angle != 0) return INSIDE; else return OUTSIDE;
}
示例7: FindPointsWithinRadius
/// <summary>
/// Find all quadtree points (UVs) in the quadtree within a radius of the given UV location.
/// </summary>
/// <param name="center">The UV at the center of the search area.</param>
/// <param name="radius">The radius of the search area.</param>
/// <returns>A list of UVs.</returns>
public List<UV> FindPointsWithinRadius(UV center, double radius)
{
if (center == null)
{
throw new ArgumentNullException(
"center",
Resources.FindPointsWithinRadiusNullPointMessage);
}
if (radius <= 0.0)
{
throw new ArgumentException(
"radius",
Resources.FindPointsWithinRadiusSearchRadiusMessage);
}
return Root.FindNodesWithinRadius(center, radius)
.Where(n => n.Point != null)
.Select(n => n.Point)
.ToList();
}
示例8: AdjustDelta
public static void AdjustDelta(
ref int delta,
UV vertex,
UV next_vertex,
UV p)
{
switch (delta)
{
// make quadrant deltas wrap around:
case 3: delta = -1; break;
case -3: delta = 1; break;
// check if went around point cw or ccw:
case 2:
case -2:
if (GetXIntercept(vertex, next_vertex, p.V)
> p.U)
{
delta = -delta;
}
break;
}
}
示例9: ProjectPointToPlane
/// <summary>
/// Generates the UV value of a point projected to a plane, given an extrusion direction.
/// </summary>
/// <param name="plane">The plane.</param>
/// <param name="projDir">The projection direction.</param>
/// <param name="point">The point.</param>
/// <returns>The UV value.</returns>
public static UV ProjectPointToPlane(Plane plane, XYZ projDir, XYZ point)
{
XYZ zDir = plane.Normal;
double denom = projDir.DotProduct(zDir);
if (MathUtil.IsAlmostZero(denom))
return null;
XYZ xDir = plane.XVec;
XYZ yDir = plane.YVec;
XYZ orig = plane.Origin;
double distToPlane = ((orig - point).DotProduct(zDir)) / denom;
XYZ pointProj = distToPlane * projDir + point;
XYZ pointProjOffset = pointProj - orig;
UV pointProjUV = new UV(pointProjOffset.DotProduct(xDir), pointProjOffset.DotProduct(yDir));
return pointProjUV;
}
示例10: Evaluate
public override Value Evaluate(FSharpList<Value> args)
{
this.ClearPreviousResults();
//unwrap the values
IEnumerable<double> nvals = ((Value.List)args[0]).Item.Select(q => (double)((Value.Number)q).Item);
var curve = (Curve)((Value.Container)args[1]).Item;
SpatialFieldManager = (Autodesk.Revit.DB.Analysis.SpatialFieldManager)((Value.Container)args[2]).Item;
if (!SpatialFieldManager.IsResultSchemaNameUnique(DYNAMO_TEMP_CURVES_SCHEMA, -1))
{
IList<int> arses = SpatialFieldManager.GetRegisteredResults();
foreach (int i in arses)
{
AnalysisResultSchema arsTest = SpatialFieldManager.GetResultSchema(i);
if (arsTest.Name == DYNAMO_TEMP_CURVES_SCHEMA)
{
schemaId = i;
break;
}
}
}
else
{
var ars = new AnalysisResultSchema(DYNAMO_TEMP_CURVES_SCHEMA, "Temporary curves from Dynamo.");
schemaId = SpatialFieldManager.RegisterResult(ars);
}
Transform trf = Transform.Identity;
//http://thebuildingcoder.typepad.com/blog/2012/09/sphere-creation-for-avf-and-filtering.html#3
var create = dynRevitSettings.Doc.Application.Application.Create;
Transform t = curve.ComputeDerivatives(0, true);
XYZ x = t.BasisX.Normalize();
XYZ y = t.BasisX.IsAlmostEqualTo(XYZ.BasisZ) ?
t.BasisX.CrossProduct(XYZ.BasisY).Normalize() :
t.BasisX.CrossProduct(XYZ.BasisZ).Normalize();
XYZ z = x.CrossProduct(y);
Autodesk.Revit.DB.Ellipse arc1 = dynRevitSettings.Revit.Application.Create.NewEllipse(t.Origin, .1, .1, y,z,-Math.PI, 0);
Autodesk.Revit.DB.Ellipse arc2 = dynRevitSettings.Revit.Application.Create.NewEllipse(t.Origin, .1, .1, y, z, 0, Math.PI);
var pathLoop = new Autodesk.Revit.DB.CurveLoop();
pathLoop.Append(curve);
var profileLoop = new Autodesk.Revit.DB.CurveLoop();
profileLoop.Append(arc1);
profileLoop.Append(arc2);
double curveDomain = curve.get_EndParameter(1) - curve.get_EndParameter(0);
int idx = -1;
var s = GeometryCreationUtilities.CreateSweptGeometry(pathLoop, 0, 0, new List<Autodesk.Revit.DB.CurveLoop>{profileLoop});
foreach (Face face in s.Faces)
{
//divide the V domain by the number of incoming
BoundingBoxUV domain = face.GetBoundingBox();
double vSpan = domain.Max.V - domain.Min.V;
//analysis values
idx = SpatialFieldManager.AddSpatialFieldPrimitive(face, trf);
//a list to hold the analysis points
IList<UV> uvPts = new List<UV>();
//a list to hold the analysis values
IList<ValueAtPoint> valList = new List<ValueAtPoint>();
//int count = nvals.Count();
//this is creating a lot of sample points, but if we used less
//sampling points, AVF would draw the two surfaces as if there was a hard
//edge between them. this provides a better blend.
int count = 10;
for (int i = 0; i < count; i ++)
{
//get a UV point on the face
//find its XYZ location and project to
//the underlying curve. find the value which corresponds
//to the location on the curve
var uv = new UV(domain.Min.U, domain.Min.V + vSpan / count*(double) i);
var uv1 = new UV(domain.Max.U, domain.Min.V + vSpan / count * (double)i);
uvPts.Add(uv);
uvPts.Add(uv1);
XYZ facePt = face.Evaluate(uv);
IntersectionResult ir = curve.Project(facePt);
double curveParam = curve.ComputeNormalizedParameter(ir.Parameter);
if (curveParam < 0)
curveParam = 0;
if (curveParam > 1)
curveParam = 1;
var valueIndex = (int)Math.Floor(curveParam * (double)nvals.Count());
if (valueIndex >= nvals.Count())
//.........这里部分代码省略.........
示例11: CreateClippingFromFaces
/// <summary>
/// Attempts to create a clipping, recess, or opening from a collection of faces.
/// </summary>
/// <param name="exporterIFC">The exporter.</param>
/// <param name="cuttingElement">The cutting element. This will help determine whether to use a clipping or opening in boundary cases.</param>
/// <param name="extrusionBasePlane">The plane of the extrusion base.</param>
/// <param name="extrusionDirection">The extrusion direction.</param>
/// <param name="faces">The collection of faces.</param>
/// <param name="range">The valid range of the extrusion.</param>
/// <param name="origBodyRepHnd">The original body representation.</param>
/// <returns>The new body representation. If the clipping completely clips the extrusion, this will be null. Otherwise, this
/// will be the clipped representation if a clipping was done, or the original representation if not.</returns>
public static IFCAnyHandle CreateClippingFromFaces(ExporterIFC exporterIFC, Element cuttingElement, Plane extrusionBasePlane,
XYZ extrusionDirection, ICollection<Face> faces, IFCRange range, IFCAnyHandle origBodyRepHnd)
{
if (IFCAnyHandleUtil.IsNullOrHasNoValue(origBodyRepHnd))
return null;
bool polygonalOnly = ExporterCacheManager.ExportOptionsCache.ExportAs2x2;
IList<CurveLoop> outerCurveLoops = new List<CurveLoop>();
IList<Plane> outerCurveLoopPlanes = new List<Plane>();
IList<bool> boundaryIsPolygonal = new List<bool>();
bool allPlanes = true;
UV faceOriginUV = new UV(0, 0);
foreach (Face face in faces)
{
FaceBoundaryType faceBoundaryType;
CurveLoop curveLoop = GetOuterFaceBoundary(face, null, polygonalOnly, out faceBoundaryType);
outerCurveLoops.Add(curveLoop);
boundaryIsPolygonal.Add(faceBoundaryType == FaceBoundaryType.Polygonal);
if (face is PlanarFace)
{
PlanarFace planarFace = face as PlanarFace;
XYZ faceOrigin = planarFace.Origin;
XYZ faceNormal = planarFace.ComputeNormal(faceOriginUV);
Plane plane = new Plane(faceNormal, faceOrigin);
outerCurveLoopPlanes.Add(plane);
if (!curveLoop.IsCounterclockwise(faceNormal))
curveLoop.Flip();
}
else
{
outerCurveLoopPlanes.Add(null);
allPlanes = false;
}
}
if (allPlanes)
{
int numFaces = faces.Count;
// Special case: one face is a clip plane.
if (numFaces == 1)
{
return ProcessClippingFace(exporterIFC, outerCurveLoops[0], outerCurveLoopPlanes[0], extrusionBasePlane,
extrusionDirection, range, false, origBodyRepHnd);
}
KeyValuePair<bool, bool> clipsExtrusionEnds = CollectionClipsExtrusionEnds(outerCurveLoops, extrusionDirection, range);
if (clipsExtrusionEnds.Key == true || clipsExtrusionEnds.Value == true)
{
// Don't clip for a door, window or opening.
if (CreateOpeningForCategory(cuttingElement))
throw new Exception("Unhandled opening.");
ICollection<int> facesToSkip = new HashSet<int>();
bool clipStart = (clipsExtrusionEnds.Key == true);
bool clipBoth = (clipsExtrusionEnds.Key == true && clipsExtrusionEnds.Value == true);
if (!clipBoth)
{
for (int ii = 0; ii < numFaces; ii++)
{
double slant = outerCurveLoopPlanes[ii].Normal.DotProduct(extrusionDirection);
if (!MathUtil.IsAlmostZero(slant))
{
if (clipStart && (slant > 0.0))
throw new Exception("Unhandled clip plane direction.");
if (!clipStart && (slant < 0.0))
throw new Exception("Unhandled clip plane direction.");
}
else
{
facesToSkip.Add(ii);
}
}
}
else
{
// If we are clipping both the start and end of the extrusion, we have to make sure all of the clipping
// planes have the same a non-negative dot product relative to one another.
int clipOrientation = 0;
for (int ii = 0; ii < numFaces; ii++)
{
double slant = outerCurveLoopPlanes[ii].Normal.DotProduct(extrusionDirection);
if (!MathUtil.IsAlmostZero(slant))
//.........这里部分代码省略.........
示例12: Stream
private void Stream(ArrayList data, UV UV)
{
data.Add(new Snoop.Data.ClassSeparator(typeof(UV)));
data.Add(new Snoop.Data.Uv("Basis U", UV.BasisU));
data.Add(new Snoop.Data.Uv("Basis V", UV.BasisV));
//data.Add(new Snoop.Data.Bool("Is normalized", UV.IsNormalized));
//data.Add(new Snoop.Data.Bool("Is zero", UV.IsZero));
//data.Add(new Snoop.Data.Double("Length", UV.));
data.Add(new Snoop.Data.Uv("Normalized", UV.Normalize()));
data.Add(new Snoop.Data.Double("U", UV.U));
data.Add(new Snoop.Data.Double("V", UV.V));
data.Add(new Snoop.Data.Uv("Zero", UV.Zero));
}
示例13: Evaluate
//.........这里部分代码省略.........
{
found = true;
break;
}
}
if (!(geobSym is Solid))
continue;
FaceArray solidFaces = ((Solid)geobSym).Faces;
int numFaces = solidFaces.Size;
for (int index = 0; index < numFaces && !found; index++)
{
Autodesk.Revit.DB.Face faceAt = solidFaces.get_Item(index);
if ((thisObject is Autodesk.Revit.DB.Face) && (thisObject == faceAt))
{
found = true;
break;
}
if (thisObject is Edge)
{
var edge = thisObject as Edge;
//use GetFace after r2013 support is dropped
if (faceAt == edge.get_Face(0) || faceAt == edge.get_Face(1))
{
found = true;
break;
}
}
}
}
}
if (found)
{
thisTrf = ginsta.Transform;
break;
}
}
if (thisObject == null)
throw new Exception("could not resolve reference for XYZ on Element");
}
XYZ thisXYZ;
if (_reference.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_SURFACE
&& thisObject is Autodesk.Revit.DB.Face)
{
var face = thisObject as Autodesk.Revit.DB.Face;
if (!_init)
{
_param0 = _reference.UVPoint[0];
_param1 = _reference.UVPoint[1];
_init = true;
}
var uv = new UV(_param0, _param1);
thisXYZ = face.Evaluate(uv);
if (thisTrf != null)
thisXYZ = thisTrf.OfPoint(thisXYZ);
}
else if (_reference.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_LINEAR)
{
Curve curve;
if (thisObject is Edge)
{
var edge = (Edge)SelectedElement.GetGeometryObjectFromReference(_reference);
curve = edge.AsCurve();
}
else
curve = (Curve)SelectedElement.GetGeometryObjectFromReference(_reference);
if (curve != null)
{
if (_init)
thisXYZ = curve.Evaluate(_param0, true);
else
{
XYZ curPoint = _reference.GlobalPoint;
if (thisTrf != null)
{
Autodesk.Revit.DB.Transform inverseTrf = thisTrf.Inverse;
curPoint = inverseTrf.OfPoint(_reference.GlobalPoint);
}
IntersectionResult thisResult = curve.Project(curPoint);
_param0 = curve.ComputeNormalizedParameter(thisResult.Parameter);
_init = true;
}
thisXYZ = curve.Evaluate(_param0, true);
_param1 = -1.0;
}
else
throw new Exception("could not evaluate point on face or edge of the element");
if (thisTrf != null)
thisXYZ = thisTrf.OfPoint(thisXYZ);
}
else
throw new Exception("could not evaluate point on face or edge of the element");
old_refXyz = _reference;
return Value.NewContainer(thisXYZ);
}
示例14: FrameWall
FrameWall( Autodesk.Revit.ApplicationServices.Application rvtApp, Autodesk.Revit.DB.Wall wall, double spacing, FamilySymbol columnType )
{
Document rvtDoc = wall.Document;
LocationCurve loc = (LocationCurve) wall.Location;
XYZ startPt = loc.Curve.GetEndPoint( 0 );
XYZ endPt = loc.Curve.GetEndPoint( 1 );
UV wallVec = new UV( endPt.X - startPt.X, endPt.Y - startPt.Y );
UV axis = new UV( 1.0, 0.0 );
ElementId baseLevelId = wall.get_Parameter( BuiltInParameter.WALL_BASE_CONSTRAINT ).AsElementId();
ElementId topLevelId = wall.get_Parameter( BuiltInParameter.WALL_HEIGHT_TYPE ).AsElementId();
double wallLength = VecLength( wallVec );
wallVec = VecNormalise( wallVec );
int nmax = (int) ( wallLength / spacing );
MessageBox.Show( "Wall Length = " + wallLength + "\nSpacing = " + spacing + "\nMax Number = " + nmax, "Structural Sample", MessageBoxButtons.OK, MessageBoxIcon.Information );
double angle = VecAngle( wallVec, axis );
XYZ loc2 = startPt;
double dx = wallVec.U * spacing;
double dy = wallVec.V * spacing;
for( int i = 0; i < nmax; i++ )
{
PlaceColumn( rvtApp, rvtDoc, loc2, angle, columnType, baseLevelId, topLevelId );
loc2 = new XYZ( startPt.X + dx, startPt.Y + dy, startPt.Z );
}
PlaceColumn( rvtApp, rvtDoc, endPt, angle, columnType, baseLevelId, topLevelId );
}
示例15: GetColorAtParameter
/// <summary>
/// Returns the color in this color range at the specified parameter.
/// </summary>
/// <param name="parameter">A UV between (0.0,0.0) and (1.0,1.0).</param>
/// <returns>A Color.</returns>
public Color GetColorAtParameter(UV parameter)
{
var color = Color.ByARGB(255, 255, 255, 255);
var weightedColors = indexedColors.ToList()
.OrderBy(ic => ic.Parameter.Area(parameter)).Take(4).ToList();
color = Color.Blerp(weightedColors, parameter);
return color;
}