本文整理汇总了C#中Face.Triangulate方法的典型用法代码示例。如果您正苦于以下问题:C# Face.Triangulate方法的具体用法?C# Face.Triangulate怎么用?C# Face.Triangulate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Face
的用法示例。
在下文中一共展示了Face.Triangulate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitFace
/// <summary>
/// Emit a Revit geometry Face object and
/// return the number of resulting triangles.
/// </summary>
public int EmitFace(Face face, Autodesk.Revit.DB.Color color)
{
++_faceCount;
Mesh mesh = face.Triangulate();
int n = mesh.NumTriangles;
Debug.Print( " {0} mesh triangles", n );
for( int i = 0; i < n; ++i )
{
++_triangleCount;
MeshTriangle t = mesh.get_Triangle( i );
StoreTriangle( t );
}
return n;
}
示例2: DrawSurface
private void DrawSurface(Face f)
{
Mesh mesh;
//Mesh3D helixMesh;
mesh = f.Triangulate() as Mesh;
XYZ vertex0;
XYZ vertex1;
XYZ vertex2;
Point3D ptVis0;
Point3D ptVis1;
Point3D ptVis2;
int lastPointColor = Points.Count() - 1;//master Point list for color assignment
for (int i = 0; i < mesh.NumTriangles - 1; i++)
{
vertex0 = mesh.get_Triangle(i).get_Vertex(0);
vertex1 = mesh.get_Triangle(i).get_Vertex(1);
vertex2 = mesh.get_Triangle(i).get_Vertex(2);
ptVis0 = new Point3D(vertex0.X, vertex0.Y, vertex0.Z);
ptVis1 = new Point3D(vertex1.X, vertex1.Y, vertex1.Z);
ptVis2 = new Point3D(vertex2.X, vertex2.Y, vertex2.Z);
// TriOrQuadFacet
// helixMesh.AddFace(
}
}
示例3: Stream
private void Stream(ArrayList data, Face face)
{
data.Add(new Snoop.Data.ClassSeparator(typeof(Face)));
data.Add(new Snoop.Data.Double("Area", face.Area));
///TODO: Restore: data.Add(new Snoop.Data.Object("Material element", face.MaterialElement));
data.Add(new Snoop.Data.Bool("Is two-sided", face.IsTwoSided));
data.Add(new Snoop.Data.Enumerable("Edge loops", face.EdgeLoops));
data.Add(new Snoop.Data.Object("Triangulate", face.Triangulate()));
data.Add(new Snoop.Data.Object("Reference", face.Reference));
ConicalFace conicalFace = face as ConicalFace;
if (conicalFace != null)
{
Stream(data, conicalFace);
return;
}
CylindricalFace cylFace = face as CylindricalFace;
if (cylFace != null)
{
Stream(data, cylFace);
return;
}
HermiteFace hermiteFace = face as HermiteFace;
if (hermiteFace != null)
{
Stream(data, hermiteFace);
return;
}
PlanarFace planarFace = face as PlanarFace;
if (planarFace != null)
{
Stream(data, planarFace);
return;
}
RevolvedFace revlFace = face as RevolvedFace;
if (revlFace != null)
{
Stream(data, revlFace);
return;
}
RuledFace ruledFace = face as RuledFace;
if (ruledFace != null)
{
Stream(data, ruledFace);
return;
}
}
示例4: DrawFaceTriangleNormals
public void DrawFaceTriangleNormals( Face f )
{
Mesh mesh = f.Triangulate();
int n = mesh.NumTriangles;
string s = "{0} face triangulation returns "
+ "mesh triangle{1} and normal vector{1}:";
Debug.Print(
s, n, Util.PluralSuffix( n ) );
for( int i = 0; i < n; ++i )
{
MeshTriangle t = mesh.get_Triangle( i );
XYZ p = ( t.get_Vertex( 0 )
+ t.get_Vertex( 1 )
+ t.get_Vertex( 2 ) ) / 3;
XYZ v = t.get_Vertex( 1 )
- t.get_Vertex( 0 );
XYZ w = t.get_Vertex( 2 )
- t.get_Vertex( 0 );
XYZ normal = v.CrossProduct( w ).Normalize();
Debug.Print(
"{0} {1} --> {2}", i,
Util.PointString( p ),
Util.PointString( normal ) );
CreateModelLine( p, p + normal );
}
}
示例5: IsVertical
/// <param name="face"></param>
/// <param name="line"></param>
/// <returns>return true when line is perpendicular to the face</returns>
/// <summary>
/// Judge whether the line is perpendicular to the face
/// </summary>
/// <param name="face">the face reference</param>
/// <param name="line">the line reference</param>
/// <param name="faceTrans">the transform for the face</param>
/// <param name="lineTrans">the transform for the line</param>
/// <returns>true if line is perpendicular to the face, otherwise false</returns>
public static bool IsVertical(Face face, Line line,
Transform faceTrans, Transform lineTrans)
{
//get points which the face contains
List<XYZ> points = face.Triangulate().Vertices as List<XYZ>;
if (3 > points.Count) // face's point number should be above 2
{
return false;
}
// get three points from the face points
Autodesk.Revit.DB.XYZ first = points[0];
Autodesk.Revit.DB.XYZ second = points[1];
Autodesk.Revit.DB.XYZ third = points[2];
// get start and end point of line
Autodesk.Revit.DB.XYZ lineStart = line.get_EndPoint(0);
Autodesk.Revit.DB.XYZ lineEnd = line.get_EndPoint(1);
// transForm the three points if necessary
if (null != faceTrans)
{
first = TransformPoint(first, faceTrans);
second = TransformPoint(second, faceTrans);
third = TransformPoint(third, faceTrans);
}
// transform the start and end points if necessary
if (null != lineTrans)
{
lineStart = TransformPoint(lineStart, lineTrans);
lineEnd = TransformPoint(lineEnd, lineTrans);
}
// form two vectors from the face and a vector stand for the line
// Use SubXYZ() method to get the vectors
Autodesk.Revit.DB.XYZ vector1 = SubXYZ(first, second); // first vector of face
Autodesk.Revit.DB.XYZ vector2 = SubXYZ(first, third); // second vector of face
Autodesk.Revit.DB.XYZ vector3 = SubXYZ(lineStart, lineEnd); // line vector
// get two dot products of the face vectors and line vector
double result1 = DotMatrix(vector1, vector3);
double result2 = DotMatrix(vector2, vector3);
// if two dot products are all zero, the line is perpendicular to the face
return (IsEqual(result1, 0) && IsEqual(result2, 0));
}
示例6: GetPoints
/// <summary>
/// get all points proximate to the given face
/// </summary>
/// <param name="face">face to be calculated</param>
/// <returns></returns>
public static List<Autodesk.Revit.DB.XYZ> GetPoints(Face face)
{
List<Autodesk.Revit.DB.XYZ > points = new List<Autodesk.Revit.DB.XYZ >();
List<Autodesk.Revit.DB.XYZ> XYZs = face.Triangulate().Vertices as List<Autodesk.Revit.DB.XYZ>;
foreach (Autodesk.Revit.DB.XYZ point in XYZs)
{
points.Add(point);
}
return points;
}