예제 #1
0
파일: nodestats.cpp 프로젝트: kenhys/gecode
 void
 NodeStatInspector::node(const VisualNode::NodeAllocator& na,
                         VisualNode* n, const Statistics&, bool) {
   if (isVisible()) {
     int nd = -1;
     for (VisualNode* p = n; p != NULL; p = p->getParent(na))
       nd++;
     nodeDepthLabel->setPlainText(QString("%1").arg(nd));;
     StatCursor sc(n,na);
     PreorderNodeVisitor<StatCursor> pnv(sc);
     pnv.run();
     
     subtreeDepthLabel->setPlainText(
       QString("%1").arg(pnv.getCursor().depth));
     solvedLabel->setPlainText(QString("%1").arg(pnv.getCursor().solved));
     solvedLabel->setPos(78-solvedLabel->document()->size().width()/2,120);
     failedLabel->setPlainText(QString("%1").arg(pnv.getCursor().failed));
     failedLabel->setPos(44-failedLabel->document()->size().width(),120);
     choicesLabel->setPlainText(QString("%1").arg(pnv.getCursor().choice));
     choicesLabel->setPos(66-choicesLabel->document()->size().width(),57);
     openLabel->setPlainText(QString("%1").arg(pnv.getCursor().open));
   }
 }
예제 #2
0
bool SargassoNode::creatRestShape(const MObject & m)
{
    MStatus stat;
    MFnMesh fmesh(m, &stat);
    if(!stat) {
        MGlobal::displayInfo("val is not mesh");
        return false;
    }
    MObject thisObj = thisMObject();
    MPlug pnv(thisObj, atargetNv);
    const int restNv = pnv.asInt();
    
    if(restNv != fmesh.numVertices()) {
        MGlobal::displayInfo("target nv not match");
        return false;
    }
    
    MPlug pntriv(thisObj, atargetNt);
    const int restNtriv = pntriv.asInt();
    
    MIntArray triangleCounts, triangleVertices;
	fmesh.getTriangles(triangleCounts, triangleVertices);
	
    if(restNtriv != triangleVertices.length()) {
        MGlobal::displayInfo("target ntri not match");
        return false;
    }
    
    m_mesh->create(restNv, restNtriv/3);
    
    MPlug prestp(thisObj, atargetRestP);
    MObject orestp;
    prestp.getValue(orestp);
    MFnPointArrayData frestp(orestp);
    MPointArray restPArray = frestp.array();	
    
    if(restPArray.length() != restNv) {
        MGlobal::displayInfo("cached target nv not match");
        return false;
    }
    
    Vector3F * p = m_mesh->points();
    unsigned i=0;
    for(;i<restNv;i++) p[i].set(restPArray[i].x, restPArray[i].y, restPArray[i].z);
    
    MPlug presttri(thisObj, atargetTri);
    MObject oresttri;
    presttri.getValue(oresttri);
    MFnIntArrayData fresttri(oresttri);
    MIntArray restTriArray = fresttri.array();	
    
    if(restTriArray.length() != restNtriv) {
        MGlobal::displayInfo("cached target ntri not match");
        return false;
    }
    
    unsigned * ind = m_mesh->indices();
    for(i=0;i<restNtriv;i++) ind[i] = restTriArray[i];
    
    const BoundingBox box = ((AGenericMesh *)m_mesh)->calculateBBox();
    AHelper::Info<BoundingBox>("target mesh box", box);
    
    m_diff = new TriangleDifference(m_mesh);
    
    MPlug ptargetbind(thisObj, atargetBind);
    MObject otargetbind;
    ptargetbind.getValue(otargetbind);
    MFnIntArrayData ftargetbind(otargetbind);
    MIntArray targetBindArray = ftargetbind.array();
    const unsigned nbind = targetBindArray.length();
    AHelper::Info<unsigned>("n binded triangles", nbind);
    
    std::vector<unsigned> vbind;
    for(i=0;i<nbind;i++) vbind.push_back(targetBindArray[i]);
    m_diff->requireQ(vbind);
    vbind.clear();
    
    MPlug pobjLocal(thisObj, aobjLocal);
    MObject oobjLocal;
    pobjLocal.getValue(oobjLocal);
    MFnVectorArrayData fobjLocal(oobjLocal);
    MVectorArray localPArray = fobjLocal.array();
    m_numObjects = localPArray.length();
    AHelper::Info<unsigned>("n constrained objects", m_numObjects);
    
    m_localP->create(m_numObjects * 12);
    
    Vector3F * lp = localP();
    for(i=0;i<m_numObjects;i++) lp[i].set(localPArray[i].x, localPArray[i].y, localPArray[i].z);
    
    m_triId->create(m_numObjects * 4);
    
    MPlug pobjtri(thisObj, aobjTri);
    MObject oobjtri;
    pobjtri.getValue(oobjtri);
    MFnIntArrayData fobjtri(oobjtri);
    MIntArray objtriArray = fobjtri.array();
    
    unsigned * tri = objectTriangleInd();
    for(i=0;i<m_numObjects;i++) tri[i] = objtriArray[i];
        
    return true;
}