Exemple #1
0
            public virtual bool Regen()
            {
                if (geometry != null)
                {
                    if (!BeginRegen())
                    {
                        return(false);
                    }

                    if (geometry.IsValid)
                    {
                        if (geometry is Mesh mesh)
                        {
                            vertexBuffer = ToVertexBuffer(mesh, part, out vertexFormatBits);
                            vertexCount  = part.VertexCount;

                            triangleBuffer = ToTrianglesBuffer(mesh, part, out triangleCount);
                            linesBuffer    = ToEdgeBuffer(mesh, part, out linesCount);
                        }
                        else if (geometry is Curve curve)
                        {
                            using (var polyline = curve.ToPolyline(Revit.ShortCurveTolerance * Revit.ModelUnits, Revit.AngleTolerance * 100.0, Revit.ShortCurveTolerance * Revit.ModelUnits, 0.0))
                            {
                                var pline = polyline.ToPolyline();

                                // Reduce too complex polylines.
                                {
                                    var tol = Revit.VertexTolerance * Revit.ModelUnits;
                                    while (pline.Count > 0x4000)
                                    {
                                        tol *= 2.0;
                                        if (pline.ReduceSegments(tol) == 0)
                                        {
                                            break;
                                        }
                                    }
                                }

                                linesCount = ToPolylineBuffer(pline, out vertexFormatBits, out vertexBuffer, out vertexCount, out linesBuffer);
                            }
                        }
                        else if (geometry is Point point)
                        {
                            linesCount = -ToPointsBuffer(point, out vertexFormatBits, out vertexBuffer, out vertexCount, out linesBuffer);
                        }
                        else if (geometry is PointCloud pointCloud)
                        {
                            linesCount = -ToPointsBuffer(pointCloud, part, out vertexFormatBits, out vertexBuffer, out vertexCount, out linesBuffer);
                        }

                        vertexFormat = new DB3D.VertexFormat(vertexFormatBits);
                    }

                    geometry = null;

                    EndRegen();
                }

                return(true);
            }
Exemple #2
0
 void IDisposable.Dispose()
 {
     effectInstance?.Dispose(); effectInstance = null;
     if (linesBuffer != indexLinesBuffer && linesBuffer != indexPointsBuffer)
     {
         linesBuffer?.Dispose();
     }
     linesBuffer = null; linesCount = 0;
     triangleBuffer?.Dispose(); triangleBuffer = null; triangleCount = 0;
     vertexFormat?.Dispose();   vertexFormat   = null;
     vertexBuffer?.Dispose();   vertexBuffer   = null; vertexCount = 0;
 }