• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ p2函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中p2函数的典型用法代码示例。如果您正苦于以下问题:C++ p2函数的具体用法?C++ p2怎么用?C++ p2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了p2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getTime

std::vector<AlprResult> AlprImpl::recognize(cv::Mat img)
{
  timespec startTime;
  getTime(&startTime);
  


  // Find all the candidate regions
  vector<PlateRegion> plateRegions = plateDetector->detect(img);

  // Get the number of threads specified and make sure the value is sane (cannot be greater than CPU cores or less than 1)
  int numThreads = config->multithreading_cores;
  if (numThreads > tthread::thread::hardware_concurrency())
    numThreads = tthread::thread::hardware_concurrency();
  if (numThreads <= 0)
    numThreads = 1;


  PlateDispatcher dispatcher(plateRegions, &img, 
			     config, stateIdentifier, ocr, 
			     topN, detectRegion, defaultRegion);
    
  // Spawn n threads to process all of the candidate regions and recognize
  list<tthread::thread*> threads;
  for (int i = 0; i < numThreads; i++)
  {
    tthread::thread * t = new tthread::thread(plateAnalysisThread, (void *) &dispatcher);
    threads.push_back(t);
  }
  
  // Wait for all threads to finish
  for(list<tthread::thread *>::iterator i = threads.begin(); i != threads.end(); ++ i)
  {
    tthread::thread* t = *i;
    t->join();
    delete t;
  }

  if (config->debugTiming)
  {
    timespec endTime;
    getTime(&endTime);
    cout << "Total Time to process image: " << diffclock(startTime, endTime) << "ms." << endl;
  }
  
  if (config->debugGeneral && config->debugShowImages)
  {
    for (int i = 0; i < plateRegions.size(); i++)
    {
      rectangle(img, plateRegions[i].rect, Scalar(0, 0, 255), 2);
    }
    
    for (int i = 0; i < dispatcher.getRecognitionResults().size(); i++)
    {
      for (int z = 0; z < 4; z++)
      {
	AlprCoordinate* coords = dispatcher.getRecognitionResults()[i].plate_points;
	Point p1(coords[z].x, coords[z].y);
	Point p2(coords[(z + 1) % 4].x, coords[(z + 1) % 4].y);
	line(img, p1, p2, Scalar(255,0,255), 2);
      }
    }

    
    displayImage(config, "Main Image", img);
    cv::waitKey(1);
    
  }
  
  if (config->debugPauseOnFrame)
  {
    // Pause indefinitely until they press a key
    while ((char) cv::waitKey(50) == -1)
    {}
  }
  
  return dispatcher.getRecognitionResults();
}
开发者ID:jesperhag,项目名称:openalpr,代码行数:78,代码来源:alpr_impl.cpp


示例2: logln


//.........这里部分代码省略.........
    logln((UnicodeString)"MinimumExponentDigits (should be 2) is " + (int8_t) MinimumExponentDigits);
    if(MinimumExponentDigits != 2) {
        errln((UnicodeString)"ERROR: setMinimumExponentDigits() failed");
    }

    // Added by Ken Liu testing set/getRoundingIncrement
    double RoundingIncrement = 0.0;
    pat.setRoundingIncrement(2.0);
    RoundingIncrement = pat.getRoundingIncrement();
    logln((UnicodeString)"RoundingIncrement (should be 2.0) is " + (double) RoundingIncrement);
    if(RoundingIncrement != 2.0) {
        errln((UnicodeString)"ERROR: setRoundingIncrement() failed");
    }
    //end of Ken's Adding

    UnicodeString funkyPat;
    funkyPat = pat.toPattern(funkyPat);
    logln((UnicodeString)"Pattern is " + funkyPat);

    UnicodeString locPat;
    locPat = pat.toLocalizedPattern(locPat);
    logln((UnicodeString)"Localized pattern is " + locPat);

// ======= Test applyPattern()

    logln((UnicodeString)"Testing applyPattern()");

    UnicodeString p1("#,##0.0#;(#,##0.0#)");
    logln((UnicodeString)"Applying pattern " + p1);
    status = U_ZERO_ERROR;
    pat.applyPattern(p1, status);
    if(U_FAILURE(status)) {
        errln((UnicodeString)"ERROR: applyPattern() failed with " + (int32_t) status);
    }
    UnicodeString s2;
    s2 = pat.toPattern(s2);
    logln((UnicodeString)"Extracted pattern is " + s2);
    if(s2 != p1) {
        errln((UnicodeString)"ERROR: toPattern() result did not match pattern applied");
    }

    if(pat.getSecondaryGroupingSize() != 0) {
        errln("FAIL: Secondary Grouping Size should be 0, not %d\n", pat.getSecondaryGroupingSize());
    }

    if(pat.getGroupingSize() != 3) {
        errln("FAIL: Primary Grouping Size should be 3, not %d\n", pat.getGroupingSize());
    }

    UnicodeString p2("#,##,##0.0# FF;(#,##,##0.0# FF)");
    logln((UnicodeString)"Applying pattern " + p2);
    status = U_ZERO_ERROR;
    pat.applyLocalizedPattern(p2, status);
    if(U_FAILURE(status)) {
        errln((UnicodeString)"ERROR: applyPattern() failed with " + (int32_t) status);
    }
    UnicodeString s3;
    s3 = pat.toLocalizedPattern(s3);
    logln((UnicodeString)"Extracted pattern is " + s3);
    if(s3 != p2) {
        errln((UnicodeString)"ERROR: toLocalizedPattern() result did not match pattern applied");
    }

    status = U_ZERO_ERROR;
    UParseError pe;
    pat.applyLocalizedPattern(p2, pe, status);
    if(U_FAILURE(status)) {
        errln((UnicodeString)"ERROR: applyPattern((with ParseError)) failed with " + (int32_t) status);
    }
    UnicodeString s4;
    s4 = pat.toLocalizedPattern(s3);
    logln((UnicodeString)"Extracted pattern is " + s4);
    if(s4 != p2) {
        errln((UnicodeString)"ERROR: toLocalizedPattern(with ParseErr) result did not match pattern applied");
    }

    if(pat.getSecondaryGroupingSize() != 2) {
        errln("FAIL: Secondary Grouping Size should be 2, not %d\n", pat.getSecondaryGroupingSize());
    }

    if(pat.getGroupingSize() != 3) {
        errln("FAIL: Primary Grouping Size should be 3, not %d\n", pat.getGroupingSize());
    }

// ======= Test getStaticClassID()

    logln((UnicodeString)"Testing getStaticClassID()");

    status = U_ZERO_ERROR;
    NumberFormat *test = new DecimalFormat(status);
    if(U_FAILURE(status)) {
        errln((UnicodeString)"ERROR: Couldn't create a DecimalFormat");
    }

    if(test->getDynamicClassID() != DecimalFormat::getStaticClassID()) {
        errln((UnicodeString)"ERROR: getDynamicClassID() didn't return the expected value");
    }

    delete test;
}
开发者ID:Andproject,项目名称:platform_external_icu4c,代码行数:101,代码来源:dcfmapts.cpp


示例3: p1

//------------------------------------------------------------------------------
bool Rect::lineIntersect (const Point& _p1, const Point& _p2) const
{
	Point p1 (_p1);
	Point p2 (_p2);
	return boundLine (p1,p2);
}
开发者ID:eriser,项目名称:Voltex,代码行数:7,代码来源:frect.cpp


示例4: TEST

TEST(VectorTest, Subtraction) {
  Vector_i p1(1, 2);
  Vector_i p2(4, 4);

  EXPECT_EQ(Vector_i(-3, -2), p1 - p2);
}
开发者ID:braak,项目名称:CppRobots,代码行数:6,代码来源:testVector.cpp


示例5: glBegin

void Sphere::paint(void)
{
    float thetaRange = 2*PI;
    float phiRange   = PI;
    float thetaStart = 0.0;
    float phiStart = -PI/2.0;
    float thetaDelta = thetaRange / mThetaSteps;
    float phiDelta = phiRange / mPhiSteps;

    mMaterial->glSetMaterial();

    int i;
    int j;
    glBegin(GL_QUADS);
    for (i = 0; i < mPhiSteps; i++)
    for (j = 0; j < mThetaSteps; j++)
    {
        // compute appropriate coordinates & normals
        float curPhi = i * phiDelta;
        float curTheta = j * thetaDelta;
        float nextPhi = (i + 1) * phiDelta;
        float nextTheta = (j + 1) * thetaDelta;

        Vec3f p0(mRadius * sin(curTheta) * cos(curPhi),
                 mRadius * sin(curTheta) * sin(curPhi),
                 mRadius * cos(curTheta));

        p0 += mCenterPoint;
        Vec3f n0 = p0 - mCenterPoint;
        n0.Normalize();

        Vec3f p1(mRadius * sin(curTheta) * cos(nextPhi),
                 mRadius * sin(curTheta) * sin(nextPhi),
                 mRadius * cos(curTheta));

        p1 += mCenterPoint;
        Vec3f n1 = p1 - mCenterPoint;
        n1.Normalize();

        Vec3f p2(mRadius * sin(nextTheta) * cos(curPhi),
                 mRadius * sin(nextTheta) * sin(curPhi),
                 mRadius * cos(nextTheta));

        p2 += mCenterPoint;
        Vec3f n2 = p2 - mCenterPoint;
        n2.Normalize();

        Vec3f p3(mRadius * sin(nextTheta) * cos(nextPhi),
                 mRadius * sin(nextTheta) * sin(nextPhi),
                 mRadius * cos(nextTheta));

        p3 += mCenterPoint;
        Vec3f n3 = p3 - mCenterPoint;
        n3.Normalize();

        //Actually, what I have done is just the Gourand shading, four normals for
        //the polygon
        glNormal3f(n0.x(), n0.y(), n0.z());
        glVertex3f(p0.x(), p0.y(), p0.z());

        glNormal3f(n1.x(), n1.y(), n1.z());
        glVertex3f(p1.x(), p1.y(), p1.z());
        
        glNormal3f(n3.x(), n3.y(), n3.z());
        glVertex3f(p3.x(), p3.y(), p3.z());
        
        glNormal3f(n2.x(), n2.y(), n2.z());
        glVertex3f(p2.x(), p2.y(), p2.z());
    }
    glEnd();
}
开发者ID:alexunder,项目名称:X-toys,代码行数:71,代码来源:Sphere.cpp


示例6: memset

void Import::SetSmoothingGroups (Mesh& maxMesh)
{
    struct FaceAdjecency
    {
        int m_count;
        int m_adjacentFace[9];
    };


    int edgeCount;
    int faceIndexPool[1024 * 8];
    int triangleCount = maxMesh.getNumFaces();

    maxMesh.InvalidateTopologyCache();
    maxMesh.InvalidateGeomCache();
    Edge* const edgeList = maxMesh.MakeEdgeList(&edgeCount);

    FaceAdjecency* const adjacency = new FaceAdjecency [triangleCount];
    dVector* const faceNormals = new dVector[triangleCount];

    memset (adjacency, 0, triangleCount * sizeof (FaceAdjecency));
    for (int i = 0; i < edgeCount; i ++) {
        int face0 = edgeList[i].f[0];
        int face1 = edgeList[i].f[1];
        if ((face0 != -1) && (face1 != -1)) {
            _ASSERTE (face0 < triangleCount);
            _ASSERTE (face1 < triangleCount);

            adjacency[face0].m_adjacentFace[adjacency[face0].m_count] = face1;
            adjacency[face1].m_adjacentFace[adjacency[face1].m_count] = face0;

            adjacency[face0].m_count += 1;
            adjacency[face1].m_count += 1;

            _ASSERTE (adjacency[face0].m_count <= sizeof (adjacency[0].m_adjacentFace) / sizeof (adjacency[0].m_adjacentFace[0]));
            _ASSERTE (adjacency[face1].m_count <= sizeof (adjacency[0].m_adjacentFace) / sizeof (adjacency[0].m_adjacentFace[0]));
        }
    }

    for (int i = 0; i < triangleCount; i ++) {
        Face* face;
        face = &maxMesh.faces[i];
        dVector p0 (maxMesh.verts[face->v[0]].x, maxMesh.verts[face->v[0]].y, maxMesh.verts[face->v[0]].z, 0.0f);
        dVector p1 (maxMesh.verts[face->v[1]].x, maxMesh.verts[face->v[1]].y, maxMesh.verts[face->v[1]].z, 0.0f);
        dVector p2 (maxMesh.verts[face->v[2]].x, maxMesh.verts[face->v[2]].y, maxMesh.verts[face->v[2]].z, 0.0f);

        dVector normal ((p1 - p0) * (p2 - p0));
        faceNormals[i] = normal.Scale (1.0f / dSqrt (normal % normal));
    }


    unsigned group = 1;
    for (int i = 0; i < triangleCount; i ++) {
        Face* const face = &maxMesh.faces[i];
        if (!face->smGroup) {

            face->setSmGroup(group);
            faceIndexPool[0] = i;
            int stack = 1;

            while (stack) {
                stack --;
                int index = faceIndexPool[stack];

                dVector& n0 = faceNormals[index];
                for (int j = 0; j < adjacency[index].m_count; j ++) {
                    int adjacentFaceIndex = adjacency[index].m_adjacentFace[j];
                    Face* const adjacentFace = &maxMesh.faces[adjacentFaceIndex];

                    if (!adjacentFace->smGroup) {
                        dVector& n1 = faceNormals[adjacentFaceIndex];

                        float dot = n0 % n1;
                        if (dot > 0.86f) {
                            if (stack < sizeof (faceIndexPool) / sizeof (faceIndexPool[0])) {
                                adjacentFace->setSmGroup(group);
                                faceIndexPool[stack] = adjacentFaceIndex;
                                stack ++;
                            }
                        }
                    }
                }
            }

            group = group * 2;
            if (!group) {
                group = 1;
            }
        }
    }


    delete[] faceNormals;
    delete[] adjacency;

    maxMesh.buildNormals();
}
开发者ID:Naddiseo,项目名称:Newton-Dynamics-fork,代码行数:97,代码来源:Import.cpp


示例7: run

    void run ()
    {
        beast::Journal const j;

        beast::manual_clock <std::chrono::seconds> clock;
        clock.set (0);

        typedef int Key;
        typedef std::string Value;
        typedef TaggedCache <Key, Value> Cache;
        
        Cache c ("test", 1, 1, clock, j);

        // Insert an item, retrieve it, and age it so it gets purged.
        {
            expect (c.getCacheSize() == 0);
            expect (c.getTrackSize() == 0);
            expect (! c.insert (1, "one"));
            expect (c.getCacheSize() == 1);
            expect (c.getTrackSize() == 1);

            {
                std::string s;
                expect (c.retrieve (1, s));
                expect (s == "one");
            }

            ++clock;
            c.sweep ();
            expect (c.getCacheSize () == 0);
            expect (c.getTrackSize () == 0);
        }

        // Insert an item, maintain a strong pointer, age it, and
        // verify that the entry still exists.
        {
            expect (! c.insert (2, "two"));
            expect (c.getCacheSize() == 1);
            expect (c.getTrackSize() == 1);

            {
                Cache::mapped_ptr p (c.fetch (2));
                expect (p != nullptr);
                ++clock;
                c.sweep ();
                expect (c.getCacheSize() == 0);
                expect (c.getTrackSize() == 1);
            }

            // Make sure its gone now that our reference is gone
            ++clock;
            c.sweep ();
            expect (c.getCacheSize() == 0);
            expect (c.getTrackSize() == 0);
        }

        // Insert the same key/value pair and make sure we get the same result
        {
            expect (! c.insert (3, "three"));

            {
                Cache::mapped_ptr const p1 (c.fetch (3));
                Cache::mapped_ptr p2 (std::make_shared <Value> ("three"));
                c.canonicalize (3, p2);
                expect (p1.get() == p2.get());
            }
            ++clock;
            c.sweep ();
            expect (c.getCacheSize() == 0);
            expect (c.getTrackSize() == 0);
        }

        // Put an object in but keep a strong pointer to it, advance the clock a lot,
        // then canonicalize a new object with the same key, make sure you get the
        // original object.
        {
            // Put an object in
            expect (! c.insert (4, "four"));
            expect (c.getCacheSize() == 1);
            expect (c.getTrackSize() == 1);

            {
                // Keep a strong pointer to it
                Cache::mapped_ptr p1 (c.fetch (4));
                expect (p1 != nullptr);
                expect (c.getCacheSize() == 1);
                expect (c.getTrackSize() == 1);
                // Advance the clock a lot
                ++clock;
                c.sweep ();
                expect (c.getCacheSize() == 0);
                expect (c.getTrackSize() == 1);
                // Canonicalize a new object with the same key
                Cache::mapped_ptr p2 (std::make_shared <std::string> ("four"));
                expect (c.canonicalize (4, p2, false));
                expect (c.getCacheSize() == 1);
                expect (c.getTrackSize() == 1);
                // Make sure we get the original object
                expect (p1.get() == p2.get());
            }
//.........这里部分代码省略.........
开发者ID:CCJY,项目名称:rippled,代码行数:101,代码来源:TaggedCache.cpp


示例8: p1

bool EntityWithMetadataFS::hasMetadata() const {
    bfs::path p1(location()), p2("metadata");
    return bfs::exists(p1/p2);
}
开发者ID:G-Node,项目名称:nix,代码行数:4,代码来源:EntityWithMetadataFS.cpp


示例9: main

int main()
{
    {
        printf("Should create one |TestObject|:\n");
        nsAutoPtr<TestObject> pobj( new TestObject() );
        printf("Should destroy one |TestObject|:\n");
    }

    {
        printf("Should create one |TestObject|:\n");
        nsAutoPtr<TestObject> pobj( new TestObject() );
        printf("Should create one |TestObject| and then destroy one:\n");
        pobj = new TestObject();
        printf("Should destroy one |TestObject|:\n");
    }

    {
        printf("Should create 3 |TestObject|s:\n");
        nsAutoArrayPtr<TestObject> pobj( new TestObject[3] );
        printf("Should create 5 |TestObject|s and then destroy 3:\n");
        pobj = new TestObject[5];
        printf("Should destroy 5 |TestObject|s:\n");
    }

    {
        printf("Should create and AddRef one |TestRefObject|:\n");
        nsRefPtr<TestRefObject> pobj( new TestRefObject() );
        printf("Should Release and destroy one |TestRefObject|:\n");
    }

    {
        printf("Should create and AddRef one |TestRefObject|:\n");
        nsRefPtr<TestRefObject> pobj( new TestRefObject() );
        printf("Should create and AddRef one |TestRefObject| and then Release and destroy one:\n");
        pobj = new TestRefObject();
        printf("Should Release and destroy one |TestRefObject|:\n");
    }

    {
        printf("Should create and AddRef one |TestRefObject|:\n");
        nsRefPtr<TestRefObject> p1( new TestRefObject() );
        printf("Should AddRef one |TestRefObject|:\n");
        nsRefPtr<TestRefObject> p2( p1 );
        printf("Should Release twice and destroy one |TestRefObject|:\n");
    }

    printf("\nTesting equality (with all const-ness combinations):\n");

    {
        nsRefPtr<TestRefObject> p1( new TestRefObject() );
        nsRefPtr<TestRefObject> p2( p1 );
        printf("equality %s.\n",
               ((p1 == p2) && !(p1 != p2)) ? "OK" : "broken");
    }

    {
        const nsRefPtr<TestRefObject> p1( new TestRefObject() );
        nsRefPtr<TestRefObject> p2( p1 );
        printf("equality %s.\n",
               ((p1 == p2) && !(p1 != p2)) ? "OK" : "broken");
    }

    {
        nsRefPtr<TestRefObject> p1( new TestRefObject() );
        const nsRefPtr<TestRefObject> p2( p1 );
        printf("equality %s.\n",
               ((p1 == p2) && !(p1 != p2)) ? "OK" : "broken");
    }

    {
        const nsRefPtr<TestRefObject> p1( new TestRefObject() );
        const nsRefPtr<TestRefObject> p2( p1 );
        printf("equality %s.\n",
               ((p1 == p2) && !(p1 != p2)) ? "OK" : "broken");
    }

    {
        nsRefPtr<TestRefObject> p1( new TestRefObject() );
        TestRefObject * p2 = p1;
        printf("equality %s.\n",
               ((p1 == p2) && !(p1 != p2) && (p2 == p1) && !(p2 != p1)) ? "OK" : "broken");
    }

    {
        const nsRefPtr<TestRefObject> p1( new TestRefObject() );
        TestRefObject * p2 = p1;
        printf("equality %s.\n",
               ((p1 == p2) && !(p1 != p2) && (p2 == p1) && !(p2 != p1)) ? "OK" : "broken");
    }

#if 0 /* MSVC++ 6.0 can't be coaxed to accept this */
    {
        nsRefPtr<TestRefObject> p1( new TestRefObject() );
        TestRefObject * const p2 = p1;
        printf("equality %s.\n",
               ((p1 == p2) && !(p1 != p2) && (p2 == p1) && !(p2 != p1)) ? "OK" : "broken");
    }

    {
        const nsRefPtr<TestRefObject> p1( new TestRefObject() );
//.........这里部分代码省略.........
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:101,代码来源:TestAutoPtr.cpp


示例10: split_convex

static void split_convex(const std::vector<DPoint>& in,
                         std::vector<DPoint>& out, std::vector<size_t>& cvx)
{
    // initialization
    std::vector<DPoint>::const_iterator p=in.begin(), pmax = in.end();
    bool is_closed = (in.front()==in.back());

    if(in.size()<4) {
        while(p!=pmax)
            out.push_back(*p++);
        cvx.push_back( out.size() );
        return;
    }

    int ni = 0;
    DPoint p1(*p++),p2(*p++),p3(*p++);
    out.push_back(p1);
    int d2 = dir(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);

    // MAIN LOOP : d1=angle(P1-P2-P3) and d2=angle(P2-P3-P4)

    bool ok = true;
    std::vector<DPoint>::const_iterator first=in.begin();

    while (ok) {
        int d1 = d2;
        DPoint p4=*p++;
        d2 = dir(p2.x, p2.y, p3.x, p3.y, p4.x, p4.y);

        if(d1*d2>0) { // convex part: store point and increment p
            out.push_back(p1=p2);
            p2 = p3;
            p3 = p4;
        }
        else if(d1*d2<0) { // split curve
            out.push_back(p2);
            DPoint m = .5*(p2+p3);
            out.push_back(m);
            cvx.push_back( out.size() );
            if(p==first)
                ok=false;
            if(first==in.begin())
                first=p;
            if(ok) {
                if(is_closed && !ni) {
                    out.clear();
                    cvx.clear();
                    cvx.push_back(0);
                }
                out.push_back(m);
                ni++;
                p1 = p2;
                p2 = p3;
                p3 = p4;
            }
        } else { // undefined sign: remove one point
            if(d1==0 || d2==0) {
                if(d1==0)
                    p2 = p3;
                p3 = p4;
                d2 = dir(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);
            } else
                assert(false); // NaN in curve?
        }

        // test end of loop
        if(ok && p==pmax) {
            if (is_closed)
                p = in.begin()+1;
            else
                ok=false;
        }

        // stop for convex closed curves
        if(p==in.begin()+3 && ni==0)
            ok=false;
    }
    // END OF MAIN LOOP

    if (!is_closed) {
        out.push_back(p2);
        out.push_back(p3);
        cvx.push_back( out.size() );
    } else if(ni==0) { // convex closed curve */
        if (out.end() == out.begin()+1)
            out.push_back( out.front() );
        else
            out[0] = out.back();
        cvx.push_back( out.size() );
    }
}
开发者ID:pmonasse,项目名称:microCurv,代码行数:91,代码来源:gass.cpp


示例11: get_graphics

CubitStatus
SimplifyTool::weighted_average_normal(RefFace* ref_face,
                                      CubitVector &normal, 
                                      double &weight )
{
    GMem g_mem;
    unsigned short norm_tol = 30;
    double dist_tol = -1.0;

    ref_face->get_geometry_query_engine()->
        get_graphics(ref_face->get_surface_ptr(), &g_mem, norm_tol, dist_tol );

    if(g_mem.fListCount < 1)
    {
        // Decrease tolerance and try again (we can get this for small features)
        norm_tol /= 2;
        ref_face->get_geometry_query_engine()->
            get_graphics(ref_face->get_surface_ptr(), &g_mem, norm_tol, dist_tol );
    }

    if(g_mem.fListCount < 1)
    {
        // Lets give up 
        PRINT_ERROR( "Unable to find average normal of a surface\n" );
        return CUBIT_FAILURE;
    }

    // Initialize
    weight = 0.0;
    normal.set( 0.0, 0.0, 0.0 );

    // Loop through the triangles
    double tri_weight, A, B, C;
    GPoint p[3];
    GPoint* plist = g_mem.point_list();
    int* facet_list = g_mem.facet_list();
    int c = 0;
    for( ;c<g_mem.fListCount; )
    {
        p[0] = plist[facet_list[++c]];
        p[2] = plist[facet_list[++c]];
        p[1] = plist[facet_list[++c]]; 
        c++;

        // Get centroid
        CubitVector p1( p[0].x, p[0].y, p[0].z );
        CubitVector p2( p[2].x, p[2].y, p[2].z );
        CubitVector p3( p[1].x, p[1].y, p[1].z );

        CubitVector center = (p1 + p2 + p3)/3.0;

        CubitVector norm(ref_face->normal_at(center));

        // Get triangle area
        A = p1.y() * p2.z() + p1.z() * p3.y() + p2.y() * p3.z() -
            p2.z() * p3.y() - p1.y() * p3.z() - p1.z() * p2.y();

        B = p1.z() * p2.x() + p1.x() * p3.z() + p2.z() * p3.x() -
            p2.x() * p3.z() - p1.z() * p3.x() - p1.x() * p2.z();

        C = p1.x() * p2.y() + p1.y() * p3.x() + p2.x() * p3.y() -
            p2.y() * p3.x() - p1.x() * p3.y() - p1.y() * p2.x();

        //Note: triangle area = 0.5*(sqrt(A*A+B*B+C*C));

        tri_weight = 0.5*(A*A+B*B+C*C);

        normal += tri_weight * norm;

        weight += tri_weight;

    }

    normal.normalize();

    return CUBIT_SUCCESS;
}
开发者ID:chrismullins,项目名称:cgma,代码行数:77,代码来源:SimplifyTool.cpp


示例12: main

int main(int argc, char* argv[])
{
	CS325Graphics window(argc, argv);

	float delta = 0.1;

	Point2D p1(CS325Graphics::X_MIN, CS325Graphics::Y_MAX / 4.5);
	Point2D p2(CS325Graphics::X_MAX, CS325Graphics::Y_MAX / 4.5);
	Point2D p3(CS325Graphics::X_MIN, CS325Graphics::Y_MIN);
	Point2D p4(CS325Graphics::X_MAX, CS325Graphics::Y_MAX);

	//Points 41, 42, 45, 46 control the sandbox. DON"T MESS WITH THEM!

	Point3D p30(0.5,  0.5,-3.5);
	Point3D p31(0.5, -0.5,-3.5);
	Point3D p32(-0.5,-0.5,-3.5);
	Point3D p33(-0.5, 0.5,-3.5);
	Point3D p34(0.5,  0.5,-1.5);
	Point3D p35(0.5, -0.5,-1.5);
	Point3D p36(-0.5,-0.5,-1.5);
	Point3D p37(-0.5, 0.5,-1.5);

	Point3D p40( -70.8, 28.8, -50.8);
	Point3D p41( 50.8,-2.8,  50.8);
	Point3D p42(-50.8,-2.8,  50.8);
	Point3D p43(-58.8, 25.8,  50.8);
	Point3D p44( 50.8, 50.8, -50.8);
	Point3D p45( 50.8,-2.8, -50.8);
	Point3D p46(-50.8,-2.8, -50.8);
	Point3D p47(-84.8,-2.8, -50.8);
	Point3D p49(-8.5,22.0, 50.8);
	Point3D p48(70,20,50.8);

	Point3D p50(3.5,  0.5,-3.5);
	Point3D p51(3.5, -0.5,-3.5);
	Point3D p52(2.5,-0.5,-3.5);
	Point3D p53(2.5, 0.5,-3.5);
	Point3D p54(3.5,  0.5,-1.5);
	Point3D p55(3.5, -0.5,-1.5);
	Point3D p56(2.5,-0.5,-1.5);
	Point3D p57(2.5, 0.5,-1.5);

	Point3D p60(3.5,  0.5, 13.5);
	Point3D p61(3.5, -0.5, 13.5);
	Point3D p62(2.5,-0.5,  13.5);
	Point3D p63(2.5, 0.5,  13.5);
	Point3D p64(3.5,  0.5, 16.5);
	Point3D p65(3.5, -0.5, 16.5);
	Point3D p66(2.5,-0.5,  16.5);
	Point3D p67(2.5, 0.5,  16.5);

	

	Point2D viewPos;
	Vector2D viewDir;
	Vector3D deltaV;
	viewDir.setAngle(0);


	// move view position

	for(int i = 0; i < MOVE_TEST; i){
		/*window.DrawLineOnScreen(p1, p2);*/
		//window.DrawLineOnScreen(p4, p3);

		window.DrawLineInSpace(p30, p31);
		window.DrawLineInSpace(p31, p32);
		window.DrawLineInSpace(p32, p33);
		window.DrawLineInSpace(p33, p30);
		window.DrawLineInSpace(p34, p35);
		window.DrawLineInSpace(p35, p36);
		window.DrawLineInSpace(p36, p37);
		window.DrawLineInSpace(p37, p34);
		window.DrawLineInSpace(p30, p34);
		window.DrawLineInSpace(p31, p35);
		window.DrawLineInSpace(p32, p36);
		window.DrawLineInSpace(p33, p37);

		window.DrawLineInSpace(p50, p51);
		window.DrawLineInSpace(p51, p52);
		window.DrawLineInSpace(p52, p53);
		window.DrawLineInSpace(p53, p50);
		window.DrawLineInSpace(p54, p55);
		window.DrawLineInSpace(p55, p56);
		window.DrawLineInSpace(p56, p57);
		window.DrawLineInSpace(p57, p54);
		window.DrawLineInSpace(p50, p54);
		window.DrawLineInSpace(p51, p55);
		window.DrawLineInSpace(p52, p56);
		window.DrawLineInSpace(p53, p57);

		window.DrawLineInSpace(p60, p61);
		window.DrawLineInSpace(p61, p62);
		window.DrawLineInSpace(p62, p63);
		window.DrawLineInSpace(p63, p60);
		window.DrawLineInSpace(p64, p65);
		window.DrawLineInSpace(p65, p66);
		window.DrawLineInSpace(p66, p67);
		window.DrawLineInSpace(p67, p64);
		window.DrawLineInSpace(p60, p64);
//.........这里部分代码省略.........
开发者ID:laughingMan,项目名称:CS-325,代码行数:101,代码来源:cs325graphicsdriver.cpp


示例13: testController

void testController(){
	MemRepository* repo=new MemRepository();
	Controller c(repo);
	string errors="";
	Expense p(1, 21, 92, "clothing");
	c.add(p);
	assert(c.size()==1);
	Expense p1(2, 23, 440, "telephone");
	c.add(p1);
	assert(c.size()==2);
	Expense p2(3, 2, 9, "pizza");
	try{
		c.add(p2);
	}
	catch(RepositoryException& s)
	{
		errors+=s.getMsg();
	}
	assert(c.size()==2);
	assert(errors!="");

	errors="";
	Expense p3(3, 34, 29, "others");
	try{
		c.add(p2);
	}
	catch(RepositoryException& s)
	{
		errors+=s.getMsg();
	}
	assert(c.size()==2);
	assert(errors!="");

	Expense p4(1, 23, 440, "others");
	c.update(1,p4);
	vector<Expense*> all=c.getAll();
	assert(all.at(0)->getDay()==23);
	assert(c.size()==2);
	errors="";
	try{
		c.update(1,p3);
	}
	catch (RepositoryException& s1)
	{
		errors+=s1.getMsg();
	}
	assert(errors!="");

	c.remove(1);
	assert (c.size()==1);
	errors="";
	try{
		c.remove(7);
	}
	catch (RepositoryException& s1)
	{
		errors+=s1.getMsg();
	}
	assert(errors!="");
	assert (c.size()==1);

	c.add(p);
	all=c.filterByDay(23);
	assert(all.size()==1);
	all=c.filterByAmount(440);
	assert(all.size()==1);

	all=c.sortByAmountA();
	assert(all.at(0)->getId()==1);
	all=c.sortByAmountD();
	assert(all.at(0)->getId()==2);
	all=c.sortByTypeA();
	assert(all.at(0)->getId()==1);
	all=c.sortByTypeD();
	assert(all.at(0)->getId()==2);
}
开发者ID:VladutZzZ,项目名称:Labs,代码行数:76,代码来源:testController.cpp


示例14: Statistics

	static void Statistics (
		dgSphere &sphere,
		dgVector &eigenValues,
		dgVector &scaleVector,
		const dgFloat32 vertex[], 
		const dgInt32 faceIndex[],
		dgInt32 indexCount,
		dgInt32 stride)
	{
/*
		dgInt32 i;
		dgInt32 j;
		dgFloat32 *ptr;
		dgFloat32 x;
		dgFloat32 z;
		dgFloat32 y;
		dgFloat64 k;
		dgFloat64 Ixx;
		dgFloat64 Iyy;
		dgFloat64 Izz;
		dgFloat64 Ixy;
		dgFloat64 Ixz;
		dgFloat64 Iyz;
		
		dgBigVector massCenter (0, 0, 0, 0);
		dgBigVector var (0, 0, 0, 0);
		dgBigVector cov (0, 0, 0, 0);
	
		ptr = (dgFloat32*)vertex;
		for (i = 0; i < indexCount; i ++) {
			j = index[i] * stride;
			x = ptr[j + 0] * scaleVector.m_x;
			y = ptr[j + 1] * scaleVector.m_y;
			z = ptr[j + 2] * scaleVector.m_z;
			massCenter += dgBigVector (x, y, z, 0);
			var += dgBigVector (x * x, y * y, z * z, 0);
			cov += dgBigVector (x * y, x * z, y * z, 0);
		}
	
		k = 1.0 / indexCount;
		var = var.Scale (k);
		cov = cov.Scale (k);
		massCenter = massCenter.Scale (k);
	
		Ixx = var.m_x - massCenter.m_x * massCenter.m_x;
		Iyy = var.m_y - massCenter.m_y * massCenter.m_y;
		Izz = var.m_z - massCenter.m_z * massCenter.m_z;
	
		Ixy = cov.m_x - massCenter.m_x * massCenter.m_y;
		Ixz = cov.m_y - massCenter.m_x * massCenter.m_z;
		Iyz = cov.m_z - massCenter.m_y * massCenter.m_z;
	
		sphere.m_front = dgVector (dgFloat32(Ixx), dgFloat32(Ixy), dgFloat32(Ixz), dgFloat32 (0.0f));
		sphere.m_up	   = dgVector (dgFloat32(Ixy), dgFloat32(Iyy), dgFloat32(Iyz), dgFloat32 (0.0f));
		sphere.m_right = dgVector (dgFloat32(Ixz), dgFloat32(Iyz), dgFloat32(Izz), dgFloat32 (0.0f));
		sphere.EigenVectors (eigenValues);
*/

		const dgFloat32 *ptr;
		dgFloat64 K;
		dgFloat64 Ixx;
		dgFloat64 Iyy;
		dgFloat64 Izz;
		dgFloat64 Ixy;
		dgFloat64 Ixz;
		dgFloat64 Iyz;
		dgFloat64 area;
		dgFloat64 totalArea;
//		const dgFace *Face;

		dgVector var (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
		dgVector cov (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
		dgVector centre (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
		dgVector massCenter (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));

		totalArea = dgFloat32 (0.0f);
		ptr = vertex;
		for (dgInt32 i = 0; i < indexCount; i += 3) {
//			Face = &face[i];
			dgInt32 index;

			index = faceIndex[i] * stride;
			dgVector p0 (&ptr[index]);
			p0 = p0.CompProduct (scaleVector);

			index = faceIndex[i + 1] * stride;;
			dgVector p1 (&ptr[index]);
			p1 = p1.CompProduct (scaleVector);

			index = faceIndex[i + 2] * stride;;
			dgVector p2 (&ptr[index]);
			p2 = p2.CompProduct (scaleVector);

			dgVector normal ((p1 - p0) * (p2 - p0));

			area = dgFloat32 (0.5f) * sqrt (normal % normal);

			centre = p0 + p1 + p2;
			centre = centre.Scale (dgFloat32  (1.0f / 3.0f));

//.........这里部分代码省略.........
开发者ID:mmozeiko,项目名称:Squares3D-Android,代码行数:101,代码来源:dgSphere.cpp


示例15: assert


//.........这里部分代码省略.........
		m_app->dispToConsole(QString("[PoissonRecon] Job finished (%1 triangles, %2 vertices)").arg(nr_faces).arg(nr_vertices),ccMainAppInterface::STD_CONSOLE_MESSAGE);

		ccPointCloud* newPC = new ccPointCloud("vertices");
		ccMesh* newMesh = new ccMesh(newPC);
		newMesh->addChild(newPC);
	
		if (newPC->reserve(nr_vertices) && newMesh->reserve(nr_faces))
		{
			ccScalarField* densitySF = 0;
			if (s_params.density)
			{
				densitySF = new ccScalarField("Density");
				if (!densitySF->reserve(nr_vertices))
				{
					m_app->dispToConsole(QString("[PoissonRecon] Failed to allocate memory for storing density!"),ccMainAppInterface::WRN_CONSOLE_MESSAGE);
					densitySF->release();
					densitySF = 0;
				}
			}

			if (s_coloredMesh)
			{
				bool importColors = newPC->reserveTheRGBTable();
				if (!importColors)
				{
					if (m_app)
						m_app->dispToConsole("Not enough memory to import colors!", ccMainAppInterface::ERR_CONSOLE_MESSAGE);
				}
				//add 'in core' points
				{
					for (unsigned i=0; i<nic; i++)
					{
						ColoredVertex& p = s_coloredMesh->inCorePoints[i];
						CCVector3 p2(	static_cast<PointCoordinateType>(p.point.coords[0]),
										static_cast<PointCoordinateType>(p.point.coords[1]),
										static_cast<PointCoordinateType>(p.point.coords[2]) );
						newPC->addPoint(p2);

						if (importColors)
						{
							newPC->addRGBColor(p.color);
						}

						if (densitySF)
						{
							ScalarType sf = static_cast<ScalarType>(p.value);
							densitySF->addElement(sf);
						}
					}
				}
				//add 'out of core' points
				{
					for (unsigned i=0; i<noc; i++)
					{
						ColoredVertex p;
						s_coloredMesh->nextOutOfCorePoint(p);
						CCVector3 p2(	static_cast<PointCoordinateType>(p.point.coords[0]),
										static_cast<PointCoordinateType>(p.point.coords[1]),
										static_cast<PointCoordinateType>(p.point.coords[2]) );
						newPC->addPoint(p2);

						if (importColors)
						{
							newPC->addRGBColor(p.color);
						}
开发者ID:FrankHXW,项目名称:trunk,代码行数:66,代码来源:qPoissonRecon.cpp


示例16: TEST

TEST(GrayPixel, OperatorGT) {
  GrayPixel p1(3);
  GrayPixel p2(234);
  ASSERT_TRUE(p2 > p1);
  ASSERT_FALSE(p1 > p2);
}
开发者ID:danieleambrosino,项目名称:ImageTemplate,代码行数:6,代码来源:TestGrayPixel.cpp


示例17: templateAppDraw


//.........这里部分代码省略.........
		direction.x =  s * move_delta.y + c * move_delta.x;
		direction.y =  c * move_delta.y - s * move_delta.x;

		player->btrigidbody->setAngularVelocity( 2*btVector3( -direction.y * ( move_delta.z * 6.7f ),
															  -direction.x * ( move_delta.z * 6.7f ),
															  0.0f ) );


		player->btrigidbody->setActivationState( ACTIVE_TAG );
	}*/

	//console_print("player_x: %3.f player_y: %3.f\n",player->location.x,player->location.y);

	next_eye.x = player->location.x +
					 distance *
					 cosf( roty * DEG_TO_RAD ) *
					 sinf( rotz * DEG_TO_RAD );

	next_eye.y = player->location.y -
					 distance *
					 cosf( roty * DEG_TO_RAD ) *
					 cosf( rotz * DEG_TO_RAD );


	next_eye.z = player->location.z +
					       distance *
					      sinf( roty * DEG_TO_RAD );
		

	btVector3 p1(   player->location.x,
					 player->location.y,
					 player->location.z ),

			     p2( next_eye.x,
					 next_eye.y,
					 next_eye.z );

	ClosestNotMeRayResultCallback back_ray( player->btrigidbody,
											   p1,
											   p2 );
	dynamicsworld->rayTest( p1,
							p2,
							back_ray );

	if( back_ray.hasHit() )
	{

		back_ray.m_hitNormalWorld.normalize();

		next_eye.x =   back_ray.m_hitPointWorld.x() +
					   ( back_ray.m_hitNormalWorld.x() * 0.1f );

		next_eye.y =   back_ray.m_hitPointWorld.y() +
					   ( back_ray.m_hitNormalWorld.y()* 0.1f );

		next_eye.z =   back_ray.m_hitPointWorld.z() +
					   ( back_ray.m_hitNormalWorld.z()* 0.1f );
	}



	roty = roty * 0.9f + next_roty * 0.1f;
	rotz = rotz * 0.9f + next_rotz * 0.1f;

	eye.x = eye.x * 0.95f + next_eye.x * 0.05f;
	eye.y = eye.y * 0.95f + next_eye.y * 0.05f;
开发者ID:psstoyanov,项目名称:EICG699,代码行数:67,代码来源:templateApp.cpp


示例18: QWidget

MenuExample::MenuExample( QWidget *parent, const char *name )
    : QWidget( parent, name )
{
    QPixmap p1( p1_xpm );
    QPixmap p2( p2_xpm );
    QPixmap p3( p3_xpm );

    QPopupMenu *print = new QPopupMenu( this );
    CHECK_PTR( print );
    print->insertTearOffHandle();
    print->insertItem( "&Print to printer", this, SLOT(printer()) );
    print->insertItem( "Print to &file", this, SLOT(file()) );
    print->insertItem( "Print to fa&x", this, SLOT(fax()) );
    print->insertSeparator();
    print->insertItem( "Printer &Setup", this, SLOT(printerSetup()) );

    QPopupMenu *file = new QPopupMenu( this );
    CHECK_PTR( file );
    file->insertItem( p1, "&Open",  this, SLOT(open()), CTRL+Key_O );
    file->insertItem( p2, "&New", this, SLOT(news()), CTRL+Key_N );
    file->insertItem( p3, "&Save", this, SLOT(save()), CTRL+Key_S );
    file->insertItem( "&Close", this, SLOT(closeDoc()), CTRL+Key_W );
    file->insertSeparator();
    file->insertItem( "&Print", print, CTRL+Key_P );
    file->insertSeparator();
    file->insertItem( "E&xit",  qApp, SLOT(quit()), CTRL+Key_Q );

    QPopupMenu *edit = new QPopupMenu( this );
    CHECK_PTR( edit );
    int undoID = edit->insertItem( "&Undo", this, SLOT(undo()) );
    int redoID = edit->insertItem( "&Redo", this, SLOT(redo()) );
    edit->setItemEnabled( undoID, FALSE );
    edit->setItemEnabled( redoID, FALSE );

    QPopupMenu* options = new QPopupMenu( this );
    CHECK_PTR( options );
    options->insertTearOffHandle();
    options->setCaption("Options");
    options->insertItem( "&Normal Font", this, SLOT(normal()) );
    options->insertSeparator();

    options->polish(); // adjust system settings 
    QFont f = options->font();
    f.setBold( TRUE );
    boldID = options->insertItem( new MyMenuItem( "&Bold", f ) );
    options->setAccel( CTRL+Key_B, boldID );
    options->connectItem( boldID, this, SLOT(bold()) );
    f = font();
    f.setUnderline( TRUE );
    underlineID = options->insertItem( new MyMenuItem( "&Underline", f ) );
    options->setAccel( CTRL+Key_U, underlineID );
    options->connectItem( underlineID, this, SLOT(underline()) );

    isBold = FALSE;
    isUnderline = FALSE;
    options->setCheckable( TRUE );


    QPopupMenu *help = new QPopupMenu( this );
    CHECK_PTR( help );
    help->insertItem( "&About", this, SLOT(about()), CTRL+Key_H );
    help->insertItem( "About &Qt", this, SLOT(aboutQt()) );

    menu = new QMenuBar( this );
    CHECK_PTR( menu );
    menu->insertItem( "&File", file );
    menu->insertItem( "&Edit", edit );
    menu->insertItem( "&Options", options );
    menu->insertSeparator();
    menu->insertItem( "&Help", help );
    menu->setSeparator( QMenuBar::InWindowsStyle );

    label = new QLabel( this );
    CHECK_PTR( label );
    label->setGeometry( 20, rect().center().y()-20, width()-40, 40 );
    label->setFrameStyle( QFrame::Box | QFrame::Raised );
    label->setLineWidth( 1 );
    label->setAlignment( AlignCenter );

    connect( this,  SIGNAL(explain(const QString&)),
	     label, SLOT(setText(const QString&)) );

    setMinimumSize( 100, 80 );
}
开发者ID:kthxbyte,项目名称:QT2-Linaro,代码

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ p2i函数代码示例发布时间:2022-05-30
下一篇:
C++ p1275_cmd_direct函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap