Exemple #1
0
        }//selectMeshVertex

        public void selectMeshEdges(Quad2d q)
        {
            HalfEdge[] guideLines = this.mesh.Edges;
            double[]   vertexPos  = this.mesh.VertexPos;
            for (int i = 0; i < guideLines.Length; ++i)
            {
                int      fromIdx = guideLines[i].FromIndex;
                int      toIdx   = guideLines[i].ToIndex;
                Vector3d vf      = new Vector3d(vertexPos[fromIdx * 3],
                                                vertexPos[fromIdx * 3 + 1],
                                                vertexPos[fromIdx * 3 + 2]);
                Vector3d vt = new Vector3d(vertexPos[toIdx * 3],
                                           vertexPos[toIdx * 3 + 1],
                                           vertexPos[toIdx * 3 + 2]);
                Vector3d screenFrom = this.projectToScreen(vf);
                Vector3d screenTo   = this.projectToScreen(vt);
                if (Quad2d.isPointInQuad(new Vector2d(screenFrom.x, screenFrom.y), q) ||
                    Quad2d.isPointInQuad(new Vector2d(screenTo.x, screenTo.y), q))
                {
                    if (!this.unSelect)
                    {
                        if (!this.selectedEdges.Contains(i))
                        {
                            this.selectedEdges.Add(i);
                        }
                    }
                    else
                    {
                        this.selectedEdges.Remove(i);
                    }
                }
            }
        }//selectMeshEdges
Exemple #2
0
        }//selectMeshEdges

        public void selectMeshFaces(Quad2d q)
        {
            fixed(double *vertexPos = this.mesh.VertexPos)
            {
                fixed(int *faceIndex = this.mesh.FaceVertexIndex)
                {
                    for (int i = 0, j = 0; i < this.mesh.FaceCount; ++i, j += 3)
                    {
                        Vector3d[] verts = { new Vector3d(vertexPos[faceIndex[j] * 3],
                                                          vertexPos[faceIndex[j] * 3 + 1],
                                                          vertexPos[faceIndex[j] * 3 + 2]),
                                             new Vector3d(vertexPos[faceIndex[j + 1] * 3],
                                                          vertexPos[faceIndex[j + 1] * 3 + 1],
                                                          vertexPos[faceIndex[j + 1] * 3 + 2]),
                                             new Vector3d(vertexPos[faceIndex[j + 2] * 3],
                                                          vertexPos[faceIndex[j + 2] * 3 + 1],
                                                          vertexPos[faceIndex[j + 2] * 3 + 2]) };
                        for (int k = 0; k < 3; ++k)
                        {
                            Vector3d v3     = this.projectToScreen(verts[k]);
                            Vector2d screen = new Vector2d(v3.x, v3.y);
                            if (Quad2d.isPointInQuad(screen, q))
                            {
                                if (!this.unSelect)
                                {
                                    if (!this.selectedFaces.Contains(i))
                                    {
                                        this.selectedFaces.Add(i);
                                    }
                                    break;
                                }
                                else
                                {
                                    this.selectedFaces.Remove(i);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }//selectMeshFaces
Exemple #3
0
 public void selectMeshVertex(Quad2d q)
 {
     double[] vertexPos = this.mesh.VertexPos;
     for (int i = 0, j = 0; i < this.mesh.VertexCount; ++i, j += 3)
     {
         Vector3d screen = this.projectToScreen(new Vector3d(vertexPos[j], vertexPos[j + 1], vertexPos[j + 2]));
         if (Quad2d.isPointInQuad(new Vector2d(screen.x, screen.y), q))
         {
             if (!this.unSelect)
             {
                 if (!this.selectedVertices.Contains(i))
                 {
                     this.selectedVertices.Add(i);
                 }
             }
             else
             {
                 this.selectedVertices.Remove(i);
             }
         }
     }
 }//selectMeshVertex