コード例 #1
0
ファイル: MojDbKindState.cpp プロジェクト: feniksa/indb8
MojErr MojDbKindState::writeIds(const MojChar* key, const MojObject& obj, MojDbReq& req, MojRefCountedPtr<MojDbStorageItem>& oldItem)
{
	MojErr err = writeObj(key, obj, m_kindEngine->indexIdDb(), req.txn(), oldItem);
	MojErrCheck(err);

	return MojErrNone;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: Christoopher/FLIP3D
void
runManySurfaceReconstructions(int frame_begin, int frame_end)
{
	Particles particles;
	TRIANGLE * tri;
	int nrofTriangles;

	tri = new TRIANGLE[1];

	for(int currFrame = frame_begin; currFrame <= frame_end; ++currFrame)
	{
		read_paricle_pos_binary(particles, currFrame);

		//if(reset)
		//{
			std::cout << "setting changed: press \'s\' to genereate surface \n";
			calcmesh = true;
		//}
		reset = false;

		//if(step || play)
		//{
			mesh(particles,dimx, dimy, dimz, gridh, 1, nrofTriangles, tri);
		//}
		writeObj(tri,nrofTriangles, currFrame);
		std::cout << "Wrote frame: " << currFrame << "\n\n\n";
	}
	
}
コード例 #3
0
ファイル: kinect.cpp プロジェクト: jiehanwang/3DDrawing
void Kinect::writeDataContent(string filePathWithoutFilesuffix, int kinectDataContent)
{
	if (kinectDataContent & KINECT_RGB)
	{	
		string filePath;
		filePath = filePathWithoutFilesuffix + ".jpg";
		if(!mRgb.empty()) 
			imwrite(filePath,mRgb);
	}

	if (kinectDataContent & KINECT_ORI_DEPTH)
	{
		string filePath;
		filePath = filePathWithoutFilesuffix + ".png";
		if(!mDepth.empty()) 
			imwrite(filePath,mDepth);
	}

	if (kinectDataContent & KINECT_MONOCOLOR_DEPTH)
	{
		string filePath;
		filePath = filePathWithoutFilesuffix + "_md.jpg";
		if(!mDepthMonoColor.empty()) 
			imwrite(filePath,mDepthMonoColor);
	}

	if (kinectDataContent & KINECT_COLOR_DEPTH)
	{
		string filePath;
		filePath = filePathWithoutFilesuffix + "_cd.jpg";
		if(!mDepthColorful.empty()) 
			imwrite(filePath,mDepthColorful);
	}

	if (kinectDataContent & KINECTmPointCloud)
	{
		// smooth
		Depth frame(mDepth);
		//frame.smooth();
		frame.smooth();
		mDepth = frame.data();
		// retrieve cloud
		retrievePointCloud(mDepth);
#ifdef MODELTYPE_PLY
		writePly(mPointCloud, mRgb, filePathWithoutFilesuffix, 1000);
#else 
		writeObj(mPointCloud, filePathWithoutFilesuffix, 1000);
#endif
	}
}
コード例 #4
0
ファイル: MojDbKindState.cpp プロジェクト: feniksa/indb8
MojErr MojDbKindState::writeTokens(const MojObject& tokensObj)
{
	MojAssert(m_kindEngine);
	MojAssertMutexLocked(m_lock);

	MojDbStorageDatabase* db = m_kindEngine->kindDb();
	MojRefCountedPtr<MojDbStorageTxn> txn;
	MojErr err = db->beginTxn(txn);
	MojErrCheck(err);
	MojAssert(txn.get());
	err = writeObj(TokensKey, tokensObj, db, txn.get(), m_oldTokensItem);
	MojErrCheck(err);
	err = txn->commit();
	MojErrCheck(err);

	return MojErrNone;
}
コード例 #5
0
ファイル: main.cpp プロジェクト: Christoopher/FLIP3D
void
runSurfaceReconstruction(int frame)
{
	Particles particles;
	TRIANGLE * tri;
	int nrofTriangles;
	
	OpenGl_initViewer(600, 600, dimx, dimy, dimz, gridh);

	tri = new TRIANGLE[1];
	read_paricle_pos_binary(particles, frame);


	OpenGl_initParticles(&particles.pos[0], &particles.pos[0], sizeof(vec3f)*particles.currnp, particles.currnp);	
	
	while(running) {

		
		if(reset)
		{
			std::cout << "setting changed: press \'s\' to genereate surface \n";
			calcmesh = true;
		}
		reset = false;

		OpenGl_drawAndUpdate(running);

		if(step || play)
		{
			mesh(particles,dimx, dimy, dimz, gridh, 1, nrofTriangles, tri);
			openGl_setMesh(tri, nrofTriangles);
		}
	}
	
	writeObj(tri,nrofTriangles, frame);
	TerminateViewer();

}
コード例 #6
0
ファイル: main.cpp プロジェクト: AiYong/OpenSubdiv
//------------------------------------------------------------------------------
static int checkMesh( shaperec const & r, int levels ) {

    int count=0;

    float deltaAvg[3] = {0.0f, 0.0f, 0.0f},
          deltaCnt[3] = {0.0f, 0.0f, 0.0f};

    xyzmesh * mesh = simpleHbr<xyzVV>(r.data.c_str(), r.scheme, 0);

    int firstface=0, lastface=mesh->GetNumFaces(),
        firstvert=0, lastvert=mesh->GetNumVertices(), nverts;

    static char const * schemes[] = { "Bilinear", "Catmark", "Loop" };

    printf("- %-25s ( %-8s ): ", r.name.c_str(), schemes[r.scheme]);

    for (int l=0; l<levels; ++l ) {

        int errcount=0;

        std::stringstream fname;

        fname << g_baseline_path <<  r.name << "_level" << l << ".obj";


        Shape * sh = readShape( fname.str().c_str(), r.scheme );
        assert(sh);

        // subdivide up to current level
        for (int i=firstface; i<lastface; ++i) {
            xyzface * f = mesh->GetFace(i);
            f->Refine();
        }

        firstface = lastface;
        lastface = mesh->GetNumFaces();
        //nfaces = lastface - firstface;

        firstvert = lastvert;
        lastvert = mesh->GetNumVertices();
        nverts = lastvert - firstvert;

        for (int i=firstvert; i<lastvert; ++i) {
            const float * apos = mesh->GetVertex(i)->GetData().GetPos(),
                        * bpos = &sh->verts[(i-firstvert)*3];

            if ( apos[0] != bpos[0] )
                deltaCnt[0]++;
            if ( apos[1] != bpos[1] )
                deltaCnt[1]++;
            if ( apos[2] != bpos[2] )
                deltaCnt[2]++;

            float delta[3] = { apos[0] - bpos[0],
                               apos[1] - bpos[1],
                               apos[2] - bpos[2] };

            deltaAvg[0]+=delta[0];
            deltaAvg[1]+=delta[1];
            deltaAvg[2]+=delta[2];

            float dist = sqrtf( delta[0]*delta[0]+delta[1]*delta[1]+delta[2]*delta[2]);
            if ( dist > STRICT_PRECISION ) {
                if(dist < WEAK_PRECISION and g_allowWeakRegression) {
                    g_strictRegressionFailure=true;
                } else {
                    if (g_verbose) {
                        printf("\n// HbrVertex<T> %d fails : dist=%.10f "
                            "(%.10f %.10f %.10f) (%.10f %.10f %.10f)", i, dist,
                                    apos[0], apos[1], apos[2],
                                        bpos[0], bpos[1], bpos[2] );
                    }
                    ++errcount;
                }
            }
        }

        if (errcount) {

            std::stringstream errfile;
            errfile << r.name << "_level" << l << "_error.obj";

            writeObj(errfile.str().c_str(), mesh,
                firstface, lastface, firstvert, lastvert);

            printf("\n  wrote: %s\n", errfile.str().c_str());
        }

        delete sh;
        count += errcount;
    }

    if (deltaCnt[0])
        deltaAvg[0]/=deltaCnt[0];
    if (deltaCnt[1])
        deltaAvg[1]/=deltaCnt[1];
    if (deltaCnt[2])
        deltaAvg[2]/=deltaCnt[2];

    if (g_verbose) {
        printf("\n  delta ratio : (%d/%d %d/%d %d/%d)", (int)deltaCnt[0], nverts,
                                                        (int)deltaCnt[1], nverts,
                                                        (int)deltaCnt[2], nverts );
        printf("\n  average delta : (%.10f %.10f %.10f)", deltaAvg[0],
                                                          deltaAvg[1],
                                                          deltaAvg[2] );
    }

    if (count==0) {
        printf(" success !\n");
    } else
        printf(" failed !\n");

    delete mesh;

    return count;
}