Exemplo n.º 1
0
 public PlanarMesher(List<String> tErrorContainer, WingedMesh tWingMesh, Mesh tRhinoMesh, int tNumPanels, int metric, GH_PreviewUtil tPreview)
 {
     errorContainer = tErrorContainer;
     wingMesh = tWingMesh;
     rhinoMesh = tRhinoMesh;
     numPanels = tNumPanels;
     currentPartition = new Partition(wingMesh.faces.Count, this);
     preview = tPreview;
     metricRef = metric;
 }
Exemplo n.º 2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //container for errors/messages passed by controller, partition, etc.
            List<String> errorContainer = new List<String>();

            GH_PreviewUtil preview = new GH_PreviewUtil(true);

            //declare placeholder variables and assign initial empty mesh
            Mesh baseMesh = new Rhino.Geometry.Mesh();
            int errorMetricIdentifer = -1;
            int numPanels = -1;

            //Retrieve input data
            if (!DA.GetData(0, ref baseMesh)) { return; }
            if (!DA.GetData(1, ref errorMetricIdentifer)) { return; }
            if (!DA.GetData(2, ref numPanels)) { return; }

            if (baseMesh.DisjointMeshCount > 1)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Problem with mesh input - disjoint mesh");
            }
            else
            {
                //compute and unify normal
                baseMesh.Normals.ComputeNormals();
                baseMesh.UnifyNormals();

                //create wingedmesh from rhinomesh
                WingedMesh myMesh = new WingedMesh(errorContainer, baseMesh);

                PlanarMesher controller = new PlanarMesher(errorContainer, myMesh, baseMesh, numPanels, errorMetricIdentifer, preview);

                controller.createFirstCluster();

                for (int i = 0; i < 40; i++)
                {
                    controller.iterateCluster();
                    //controller.currentPartition.drawProxies(preview);
                }

                controller.createConnectivityMesh();

                //creating voronoi
                WingedMesh voronoiMesh = new WingedMesh(errorContainer, controller.currentPartition.proxyToMesh.convertWingedMeshToPolylines());

                //set all the output data
                DA.SetDataList(0, voronoiMesh.convertWingedMeshToPolylines());
            }

            foreach (var item in errorContainer)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, item);
            }
        }
Exemplo n.º 3
0
        public OffsetBrepMesh(WingedMesh tRefMesh, float tThickness, float tMinimumDistance, float tHingeWidth, float tHingeDepth)
        {
            refMesh         = tRefMesh;
            thickness       = tThickness;
            minimumDistance = tMinimumDistance;
            hingeWidth      = tHingeWidth;
            hingeDepth      = tHingeDepth;

            offsetEdgeValues = calculateOffsetEdgeValues();
            offsetEdges      = calculateOffsetEdges();
            offsetSolids     = calculateOffsetSolids();
        }
Exemplo n.º 4
0
 public Face(int tIndex, List<Vertex> tFaceVerts, Vector3f tNormal, Point3f tFaceCentre, WingedMesh tMesh)
     //add something which stops you ever sending in only 1 or 2 verts?
 {
     index = tIndex;
     faceVerts = tFaceVerts;
     faceNormal = tNormal;
     faceNormal.Unitize();
     faceCentre = tFaceCentre;
     faceEdges = new List<Edge>();
     refMesh = tMesh;
     initialiseEdges();
 }
Exemplo n.º 5
0
        public OffsetBrepMesh(WingedMesh tRefMesh, float tThickness, float tMinimumDistance, float tHingeWidth, float tHingeDepth)
        {
            refMesh = tRefMesh;
            thickness = tThickness;
            minimumDistance = tMinimumDistance;
            hingeWidth = tHingeWidth;
            hingeDepth = tHingeDepth;

            offsetEdgeValues = calculateOffsetEdgeValues();
            offsetEdges = calculateOffsetEdges();
            offsetSolids = calculateOffsetSolids();
        }
Exemplo n.º 6
0
 public Face(int tIndex, List <Vertex> tFaceVerts, Vector3f tNormal, Point3f tFaceCentre, WingedMesh tMesh)
 //add something which stops you ever sending in only 1 or 2 verts?
 {
     index      = tIndex;
     faceVerts  = tFaceVerts;
     faceNormal = tNormal;
     faceNormal.Unitize();
     faceCentre = tFaceCentre;
     faceEdges  = new List <Edge>();
     refMesh    = tMesh;
     initialiseEdges();
 }
Exemplo n.º 7
0
        internal void convertProxiesToWingMesh()
        {
            proxyToMesh = new WingedMesh(controller.errorContainer);
            verticesForMesh = new List<int>();
            for (int i = 0; i < controller.wingMesh.vertices.Count; i++)//set array of vertices to add - the index will equal the new index and the value will equal the old one
            {
                {
                    if (controller.wingMesh.vertices[i].boundaryVert)
                    {
                        if (vertexProxyConnectivity[i].Count > 1)
                        {
                            verticesForMesh.Add(i);
                        }
                    }
                    else
                    {
                        if (vertexProxyConnectivity[i].Count > 2)
                        {
                            verticesForMesh.Add(i);
                        }
                    }
                }
            }

            for (int i=0;i<verticesForMesh.Count;i++) {
                proxyToMesh.addVertex(controller.wingMesh.vertices[verticesForMesh[i]].position);
            }

            for (int i = 0; i < proxies.Count; i++)
            {
                List<int> faceVertsInOrder = proxies[i].cornerVertsInOrder;
                List<int> faceVertIndicesForNewMesh = new List<int>();

                if (faceVertsInOrder.Count == 2)
                {
                    //seems to be too many of these happening!
                    verticesForMesh.Add(proxies[i].addBoundaryVerts());
                }

                for (int j = 0; j < faceVertsInOrder.Count; j++)
                {
                    for (int k = 0; k < verticesForMesh.Count; k++)
                    {
                        if (faceVertsInOrder[j] == verticesForMesh[k])
                        {
                            faceVertIndicesForNewMesh.Add(k);
                            break;
                        }
                    }
                }

                int[] arrayOfIndices = new int[faceVertIndicesForNewMesh.Count];

                for (int j = 0; j < faceVertIndicesForNewMesh.Count; j++)
                {
                    arrayOfIndices[j] = faceVertIndicesForNewMesh[j];
                }
                proxyToMesh.addFaceNoNormalsOrCentre(arrayOfIndices);
            }

            proxyToMesh.setSurroundingBoundaryAndOrdering();
        }
Exemplo n.º 8
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //container for errors/messages
            List<String> errorContainer = new List<String>();

            GH_PreviewUtil preview = new GH_PreviewUtil(true);

            //declare placeholder variables and assign initial empty mesh
            Mesh baseMesh = new Rhino.Geometry.Mesh();
            int errorMetricIdentifer = -1;
            int numPanels = -1;
            Boolean run = false;

            //Retrieve input data
            if (!DA.GetData(0, ref baseMesh)) { return; }
            if (!DA.GetData(1, ref errorMetricIdentifer)) { return; }
            if (!DA.GetData(2, ref numPanels)) { return; }
            if (!DA.GetData(3, ref run)) { return; }

            if (run)
            {

                if (baseMesh.DisjointMeshCount > 1)
                {
                    errorContainer.Add("Problem with mesh input - disjoint mesh");
                }
                else
                {
                    //compute and unify normal
                    baseMesh.Normals.ComputeNormals();
                    baseMesh.UnifyNormals();

                    //create wingedmesh from rhinomesh
                    WingedMesh myMesh = new WingedMesh(errorContainer, baseMesh);

                    PlanarMesher controller = new PlanarMesher(errorContainer, myMesh, baseMesh, numPanels, errorMetricIdentifer, preview);

                    controller.createFirstCluster();

                    for (int i = 0; i < 40; i++)
                    {
                        controller.iterateCluster();
                        controller.currentPartition.drawProxies(preview);
                    }

                    controller.createConnectivityMesh();

                    //creating voronoi
                    WingedMesh voronoiMesh = new WingedMesh(errorContainer, controller.currentPartition.proxyToMesh.convertWingedMeshToPolylines());

                    controller.planariseConnectivityMesh();

                    //convert faces edges to polylines for viewing
                    List<Polyline> boundaryEdges = controller.currentPartition.proxyToMesh.convertWingedMeshToPolylines();

                    List<Plane> proxyPlanes = new List<Plane>();
                    foreach (Proxy proxy in controller.currentPartition.proxies)
                    {
                        proxyPlanes.Add(proxy.rhinoPlane);
                    }
                    List<Mesh> proxyMeshes = new List<Mesh>();
                    foreach (Proxy proxy in controller.currentPartition.proxies)
                    {
                        proxyMeshes.Add(proxy.proxyAsMesh);
                    }

                    List<Vector3d> faceNormals = new List<Vector3d>();
                    List<Point3d> faceCentres = new List<Point3d>();
                    for (int i = 0; i < controller.currentPartition.proxyToMesh.faces.Count; i++)
                    {
                        faceNormals.Add(new Vector3d(controller.currentPartition.proxyToMesh.faces[i].faceNormal));
                        faceCentres.Add(new Point3d(controller.currentPartition.proxyToMesh.faces[i].faceCentre));
                    }

                    //set all the output data
                    DA.SetDataList(1, proxyPlanes);
                    DA.SetDataList(2, boundaryEdges);
                    DA.SetData(3, controller.currentPartition.proxyToMesh);
                    DA.SetDataList(4, faceNormals);
                    DA.SetDataList(5, faceCentres);
                    DA.SetDataList(6, voronoiMesh.convertWingedMeshToPolylines());
                }
                DA.SetDataList(0, errorContainer);
            }
        }
Exemplo n.º 9
0
 public Window(WingedMesh inputMesh, float offsetDistance)
 {
 }
Exemplo n.º 10
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //container for errors/messages passed by controller, partition, etc.
            List<String> errorContainer = new List<String>();

            GH_PreviewUtil preview = new GH_PreviewUtil(true);

            //declare placeholder variables and assign initial empty mesh
            List<Curve> baseCurves = new List<Curve>();

            //Retrieve input data
            if (!DA.GetDataList(0, baseCurves))
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Couldn't infer list of polyline face boundaries from input");
                return;
            }
            //if (!DA.GetData(1, ref run)) { return; }

            List<Polyline> baseMesh = new List<Polyline>();
            for (int i = 0; i < baseCurves.Count; i++)
	        {
                 Polyline pl;
		         if (baseCurves[i].TryGetPolyline(out pl))
                 {
                     baseMesh.Add(pl);
                 }
                 else
                 {
                     this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Couldn't get a polyline from boundary curve #" + i.ToString());
                 }
	        }

            try // catch any unexpected errors
            {
                // TODO: disjoint mesh check

                //create wingedmesh from rhinomesh
                WingedMesh myMesh = new WingedMesh(errorContainer, baseMesh);
                myMesh.calculateNormals();

                PlanarMesher controller = new PlanarMesher(errorContainer, myMesh, null, myMesh.faces.Count, -1, preview);

                controller.CreateFromInputMesh();
                controller.createConnectivityMesh();
                controller.planariseConnectivityMesh();

                //convert faces edges to polylines for viewing
                List<Polyline> boundaryEdges = controller.currentPartition.proxyToMesh.convertWingedMeshToPolylines();

                List<Plane> proxyPlanes = new List<Plane>();
                foreach (Proxy proxy in controller.currentPartition.proxies)
                {
                    proxyPlanes.Add(proxy.rhinoPlane);
                }
                List<Mesh> proxyMeshes = new List<Mesh>();
                foreach (Proxy proxy in controller.currentPartition.proxies)
                {
                    proxyMeshes.Add(proxy.proxyAsMesh);
                }

                //set all the output data
                DA.SetDataList(0, proxyPlanes);
                DA.SetDataList(1, boundaryEdges);
            }
            catch (Exception e)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.StackTrace);
            }

            foreach (var item in errorContainer)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, item);
            }
        }
Exemplo n.º 11
0
 public Face(int tIndex, List<Vertex> tFaceVerts, WingedMesh tMesh)
     : this(tIndex, tFaceVerts, new Vector3f(0.0f, 0.0f, 0.0f), calculateCentre(tFaceVerts), tMesh)
 {
     //just calls the other one.  the normal is not correct - perhaps implement a normal calculation but as it is n-gon there is no proper normall..
 }
Exemplo n.º 12
0
        public Window(WingedMesh inputMesh, float offsetDistance) {

        }
Exemplo n.º 13
0
 public Face(int tIndex, List <Vertex> tFaceVerts, WingedMesh tMesh)
     : this(tIndex, tFaceVerts, new Vector3f(0.0f, 0.0f, 0.0f), calculateCentre(tFaceVerts), tMesh)
 {
     //just calls the other one.  the normal is not correct - perhaps implement a normal calculation but as it is n-gon there is no proper normall..
 }