protected override void SandwormSolveInstance(IGH_DataAccess DA) { SetupLogging(); DA.GetData(0, ref _waterLevel); DA.GetData(1, ref _contourInterval); GetSandwormOptions(DA, 4, 2, 3); SetupKinect(); var depthFrameDataInt = new int[trimmedWidth * trimmedHeight]; var averagedDepthFrameData = new double[trimmedWidth * trimmedHeight]; // Initialize outputs if (keepFrames <= 1 || outputMesh == null) { outputMesh = new List <Mesh>(); // Don't replace prior frames (by clearing array) if using keepFrames } SetupRenderBuffer(depthFrameDataInt, _quadMesh); Core.LogTiming(ref output, timer, "Initial setup"); // Debug Info AverageAndBlurPixels(depthFrameDataInt, ref averagedDepthFrameData); GeneratePointCloud(averagedDepthFrameData); // Produce 1st type of analysis that acts on the pixel array and assigns vertex colors switch (Analysis.AnalysisManager.GetEnabledMeshColoring()) { case None analysis: _vertexColors = analysis.GetColorCloudForAnalysis(); break; case Elevation analysis: _vertexColors = analysis.GetColorCloudForAnalysis(averagedDepthFrameData, sensorElevation); break; case Slope analysis: _vertexColors = analysis.GetColorCloudForAnalysis(averagedDepthFrameData, trimmedWidth, trimmedHeight, depthPixelSize.x, depthPixelSize.y); break; case Aspect analysis: _vertexColors = analysis.GetColorCloudForAnalysis(averagedDepthFrameData, trimmedWidth, trimmedHeight); break; } Core.LogTiming(ref output, timer, "Point cloud analysis"); // Debug Info // Generate the mesh itself _quadMesh = Core.CreateQuadMesh(_quadMesh, allPoints, _vertexColors, trimmedWidth, trimmedHeight); if (keepFrames > 1) { outputMesh.Insert(0, _quadMesh.DuplicateMesh()); // Clone and prepend if keeping frames } else { outputMesh.Add(_quadMesh); } Core.LogTiming(ref output, timer, "Meshing"); // Debug Info // Produce 2nd type of analysis that acts on the mesh and creates new geometry _outputGeometry = new List <GeometryBase>(); foreach (var enabledAnalysis in Analysis.AnalysisManager.GetEnabledMeshAnalytics()) { switch (enabledAnalysis) { case Contours analysis: analysis.GetGeometryForAnalysis(ref _outputGeometry, _contourInterval, _quadMesh); break; case WaterLevel analysis: analysis.GetGeometryForAnalysis(ref _outputGeometry, _waterLevel, _quadMesh); break; } } Core.LogTiming(ref output, timer, "Mesh analysis"); // Debug Info // Trim the outputMesh List to length specified in keepFrames if (keepFrames > 1 && keepFrames < outputMesh.Count) { var framesToRemove = outputMesh.Count - keepFrames; outputMesh.RemoveRange(keepFrames, framesToRemove > 0 ? framesToRemove : 0); } DA.SetDataList(0, outputMesh); DA.SetDataList(1, _outputGeometry); DA.SetDataList(2, output); // For logging/debugging ScheduleSolve(); }