本文整理汇总了C#中Face.ComputeDerivatives方法的典型用法代码示例。如果您正苦于以下问题:C# Face.ComputeDerivatives方法的具体用法?C# Face.ComputeDerivatives怎么用?C# Face.ComputeDerivatives使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Face
的用法示例。
在下文中一共展示了Face.ComputeDerivatives方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buttonOK_Click
/// <summary>
/// OK button click event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonOK_Click(object sender, EventArgs e)
{
DeleteLines();
if (!UpdateData(false))
{
return;
}
m_outputInfo.Clear();
m_stopWatch.Start();
Transaction transaction = new Transaction(m_doc, "RayTraceBounce");
transaction.Start();
m_LineCount = 0;
m_RayCount = 0;
// Start Find References By Direction
Autodesk.Revit.DB.XYZ startpt = m_origin;
m_outputInfo.Add("Start Find References By Direction: ");
for (int ctr = 1; ctr <= rayLimit; ctr++)
{
IList<ReferenceWithContext> references = m_doc.FindReferencesWithContextByDirection(startpt, m_direction, m_view);
m_rClosest = null;
FindClosestReference(references);
if (m_rClosest == null)
{
string info = "Ray " + ctr + " aborted. No closest face reference found. ";
m_outputInfo.Add(info);
if (ctr == 1)
{
MessageBox.Show(info);
}
break;
}
else
{
Reference reference = m_rClosest.GetReference();
Element referenceElement = m_doc.GetElement(reference);
GeometryObject referenceObject = referenceElement.GetGeometryObjectFromReference(reference);
Autodesk.Revit.DB.XYZ endpt = reference.GlobalPoint;
if (startpt.IsAlmostEqualTo(endpt))
{
m_outputInfo.Add("Start and end points are equal. Ray " + ctr + " aborted\n" + startpt.X + ", " + startpt.Y + ", " + startpt.Z);
break;
}
else
{
MakeLine(startpt, endpt, m_direction, "bounce");
m_RayCount = m_RayCount + 1;
string info = "Intersected Element Type: [" + referenceElement.GetType().ToString() + "] ElementId: [" + referenceElement.Id.IntegerValue.ToString();
m_face = referenceObject as Face;
if (m_face.MaterialElementId != ElementId.InvalidElementId)
{
Material materialElement = m_doc.get_Element(m_face.MaterialElementId) as Material;
info += "] Face MaterialElement Name: [" + materialElement.Name + "] Shininess: [" + materialElement.Shininess;
}
else
{
info += "] Face.MaterialElement is null [" + referenceElement.Category.Name;
}
info += "]";
m_outputInfo.Add(info);
Autodesk.Revit.DB.UV endptUV = reference.UVPoint;
Autodesk.Revit.DB.XYZ FaceNormal = m_face.ComputeDerivatives(endptUV).BasisZ; // face normal where ray hits
FaceNormal = m_rClosest.GetInstanceTransform().OfVector(FaceNormal); // transformation to get it in terms of document coordinates instead of the parent symbol
Autodesk.Revit.DB.XYZ directionMirrored = m_direction - 2 * m_direction.DotProduct(FaceNormal) * FaceNormal; //http://www.fvastro.org/presentations/ray_tracing.htm
m_direction = directionMirrored; // get ready to shoot the next ray
startpt = endpt;
}
}
}
transaction.Commit();
m_stopWatch.Stop();
TimeSpan ts = m_stopWatch.Elapsed;
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
m_outputInfo.Add(elapsedTime + "\n" + "Lines = " + m_LineCount + "\n" + "Rays = " + m_RayCount);
m_stopWatch.Reset();
OutputInformation();
}
示例2: Evaluate
public override void Evaluate(FSharpList<FScheme.Value> args, Dictionary<PortData, FScheme.Value> outPuts)
{
var origin = (XYZ)((FScheme.Value.Container)args[0]).Item;
var direction = (XYZ)((FScheme.Value.Container)args[1]).Item;
var rayLimit = ((FScheme.Value.Number)args[2]).Item;
var view = (View3D)((FScheme.Value.Container)args[3]).Item;
XYZ startpt = origin;
int rayCount = 0;
var bouncePts = FSharpList<FScheme.Value>.Empty;
var bounceElements = FSharpList<FScheme.Value>.Empty;
bouncePts = FSharpList<FScheme.Value>.Cons(FScheme.Value.NewContainer(origin), bouncePts);
for (int ctr = 1; ctr <= rayLimit; ctr++)
{
var referenceIntersector = new ReferenceIntersector(view);
IList<ReferenceWithContext> references = referenceIntersector.Find(startpt, direction);
ReferenceWithContext rClosest = null;
rClosest = FindClosestReference(references);
if (rClosest == null)
{
break;
}
else
{
var reference = rClosest.GetReference();
var referenceElement = dynRevitSettings.Doc.Document.GetElement(reference);
bounceElements = FSharpList<FScheme.Value>.Cons(FScheme.Value.NewContainer(referenceElement), bounceElements);
var referenceObject = referenceElement.GetGeometryObjectFromReference(reference);
var endpt = reference.GlobalPoint;
if (startpt.IsAlmostEqualTo(endpt))
{
break;
}
else
{
rayCount = rayCount + 1;
currFace = referenceObject as Face;
var endptUV = reference.UVPoint;
var FaceNormal = currFace.ComputeDerivatives(endptUV).BasisZ; // face normal where ray hits
FaceNormal = rClosest.GetInstanceTransform().OfVector(FaceNormal); // transformation to get it in terms of document coordinates instead of the parent symbol
var directionMirrored = direction - 2 * direction.DotProduct(FaceNormal) * FaceNormal; //http://www.fvastro.org/presentations/ray_tracing.htm
direction = directionMirrored; // get ready to shoot the next ray
startpt = endpt;
bouncePts = FSharpList<FScheme.Value>.Cons(FScheme.Value.NewContainer(endpt), bouncePts);
}
}
}
bouncePts.Reverse();
bounceElements.Reverse();
outPuts[intersections] = FScheme.Value.NewList(bouncePts);
outPuts[elements] = FScheme.Value.NewList(bounceElements);
}