Ejemplo n.º 1
0
void LandmarkCapturePlugin::EndEdit(MeshModel &m, GLArea *gla )
{
    Log("end on mesh : %s",m.shortName());
    //gla->md()->updateMeshSelected();
   //m.updateMeshSelected();
     Log("landmark size: %d",m.cm.selVertVector.size());

  //gla->repaint();
     //gla->updateMeshSelected();
}
Ejemplo n.º 2
0
QString PickedPoints::getSuggestedPickedPointsFileName(const MeshModel &meshModel){
    QString outputFileName(meshModel.shortName());
	
	//remove postfix
	outputFileName.truncate(outputFileName.length()-4);
				
	//add new postfix
	outputFileName.append("_picked_points" + fileExtension);
	
	return outputFileName;
}
Ejemplo n.º 3
0
bool LandmarkCapturePlugin::StartEdit(MeshModel &m, GLArea *gla )
{
  curFacePtr=0;
  curVertPtr=0;
    gla->setCursor(Qt::PointingHandCursor);
	
	Log("point: %d %d",cur.x(),gla->height() - cur.y());
	
	MeshDocument *md = m.parent;
	for(int ii = 0; ii < md->meshList.size();++ii)
	{
		 MeshModel* mm = md->meshList[ii];
	}
	//md->setCurrentMesh(1);			
    Log("start on mesh : %s",m.shortName());

    m.cm.selVertVector.clear();
    m.cm.selFaceVector.clear();
    //ComponentVector.clear();
	return true;
}
Ejemplo n.º 4
0
void EditPointPlugin::Decorate(MeshModel &m, GLArea * gla, QPainter *p)
{
  this->RealTimeLog("Point Selection",m.shortName(),
                    "<table>"
                    "<tr><td width=50> Hop Thr:</td><td width=100 align=right><b >%8.3f </b></td><td><i> (Wheel to change it)</i> </td></tr>"
                    "<tr><td>          Radius: </td><td width=70 align=right><b> %8.3f </b></td><td><i> (Drag or Alt+Wheel to change it)</i></td></tr>"
                    "</table>",this->maxHop,this->dist);

    /* When the user first click we have to find the point under the mouse pointer.
       At the same time we need to compute the Dijkstra algorithm over the knn-graph in order
       to find the distance between the selected point and the others. */
    if(haveToPick)
    {
        glPushMatrix();
        glMultMatrix(m.cm.Tr);
        vector<CMeshO::VertexPointer> NewSel;
        GLPickTri<CMeshO>::PickVert(cur.x(), gla->height() - cur.y(), m.cm, NewSel);
        if(NewSel.size() > 0) {
            startingVertex = NewSel.front();

            tri::ComponentFinder<CMeshO>::Dijkstra(m.cm, *startingVertex, K, this->maxHop, this->NotReachableVector);

            ComponentVector.push_back(startingVertex);
        }

        haveToPick = false;
        glPopMatrix();
    }

    /* When at least a point is selected we need to draw the selection */
    if (startingVertex != NULL) {
        glPushMatrix();
        glMultMatrix(m.cm.Tr);

        glPushAttrib(GL_ENABLE_BIT );
        glDisable(GL_LIGHTING);
        glDisable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
        glDepthRange (0.0, 0.9999);
        glDepthFunc(GL_LEQUAL);
        glPointSize(6.f);

        tri::UpdateSelection<CMeshO>::VertexClear(m.cm);

        /* In OldComponentVector we find all the points selected until the last click of the mouse.
           The other points are saved in ComponentVector. With two different structures for old and new
           selection we can add or subtract one from each other. */
        switch (composingSelMode) {
        case SMSub:
            for(vector<CMeshO::VertexPointer>::iterator vi = OldComponentVector.begin(); vi != OldComponentVector.end(); ++vi) {
                (*vi)->SetS();
            }
            for(vector<CMeshO::VertexPointer>::iterator vi = ComponentVector.begin(); vi != ComponentVector.end(); ++vi) {
                (*vi)->ClearS();
            }
            break;

        case SMAdd:
            for(vector<CMeshO::VertexPointer>::iterator vi = OldComponentVector.begin(); vi != OldComponentVector.end(); ++vi) {
                (*vi)->SetS();
            }
            for(vector<CMeshO::VertexPointer>::iterator vi = ComponentVector.begin(); vi != ComponentVector.end(); ++vi) {
                (*vi)->SetS();
            }
            break;

        case SMClear:
            for(vector<CMeshO::VertexPointer>::iterator vi = ComponentVector.begin(); vi != ComponentVector.end(); ++vi) {
                (*vi)->SetS();
            }
            break;
        }

        /* The actual selection is drawn in red (instead of the automatic drawing of selected vertex
           of MeshLab) */
        glBegin(GL_POINTS);
        glColor4f(1,0,0,.5f);

        for (CMeshO::VertexIterator vi = m.cm.vert.begin(); vi != m.cm.vert.end(); vi++) {
            if (vi->IsS()) glVertex(vi->cP());
        }

        glEnd();

        /* Borders points are drawn in yellow. */
        glBegin(GL_POINTS);
        glColor4f(1,1,0,.5f);

        for(vector<CMeshO::VertexPointer>::iterator vi = BorderVector.begin(); vi != BorderVector.end(); ++vi)
        {
            if ((*vi)->IsS()) glVertex((*vi)->cP());
        }

        glEnd();

        /* If the "fitting plane" plugin is selected we draw a light blue circle to visualize the
           actual plane found by the algorithm (and the fitted points). */
        if (editType == SELECT_FITTING_PLANE_MODE) {
            fittingCircle.Clear();
            vcg::tri::OrientedDisk<CMeshO>(fittingCircle, 192, fittingPlane.Projection(startingVertex->cP()), fittingPlane.Direction(), this->fittingRadius);

            glBegin(GL_TRIANGLE_FAN);
            glColor4f(0.69,0.93,0.93,.7f);

            CMeshO::VertexIterator vi;
            for (vi = fittingCircle.vert.begin(); vi != fittingCircle.vert.end(); vi++) {
                glVertex(vi->cP());
            }
            vi = fittingCircle.vert.begin();
            vi++;
            glVertex(vi->cP());

            glEnd();
        }

        glPopAttrib();
        glPopMatrix();
    }
}