当前位置: 首页>>代码示例>>C++>>正文


C++ AutoAlloc::GetSplineLength方法代码示例

本文整理汇总了C++中AutoAlloc::GetSplineLength方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoAlloc::GetSplineLength方法的具体用法?C++ AutoAlloc::GetSplineLength怎么用?C++ AutoAlloc::GetSplineLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AutoAlloc的用法示例。


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

示例1: ComputeSpline

SplineObject* Voxelify::ComputeSpline(BaseThread* bt, vector<VGrid> grids, LONG longestPercent, GeDynamicArray<GeDynamicArray<Vector> > &splinesAtPoint){
    SplineObject* parentSpline = SplineObject::Alloc(0, SPLINETYPE_BSPLINE);
    
    std::vector<SplinePair >splinePairs;
    
    Real avSplineSize = 0.0, avSplineLength = 0.0;
    GeDynamicArray<GeDynamicArray<LONG> > validPoints(grids.size());
    for (LONG k=0; k < grids.size(); k++){
        validPoints[k] = GeDynamicArray<LONG>(grids[0].points.size());
        validPoints[k].Fill(0,grids[0].points.size(),1);
    }
    
    GeDynamicArray<LONG> indxs;

    for (LONG i = 0; i < grids[0].points.size(); i++) {
        if (grids[0].indices[i] == -1) continue;
        GeDynamicArray<Vector> rawSpline;
        Vector point(grids[0].points[i][0], grids[0].points[i][1], grids[0].points[i][2]);
        indxs.Push(i);
        rawSpline.Push(point);
        splinesAtPoint.Push(rawSpline);
    }

    Real distMin = std::numeric_limits<float>::max();
    Real distMax = 0.;
    AutoAlloc<SplineHelp> splineHelp;
    LONG i, o;
    for (i = 0; i < splinesAtPoint.GetCount(); i++){//iterate points
        bool lastPointCaptured = true;
        LONG indx = indxs[i];
        for (o=0; o < grids.size()-1; o++){ // for each point iterate objects and collect nearest points
            LONG closestIndx = grids[o+1].indices[indx];
            if ( closestIndx == -1){
                GePrint("error finding neighbor "+LongToString(o)+"/"+LongToString(i));
                if (o == grids.size()-1){
                    lastPointCaptured = false;
                }
                continue;
            }
            vector<float> point = grids[o].points[indx];
            vector<float> point1 = grids[o+1].points[indx];
            Real dist = hypot(point[0] - point1[0], hypot(point[1] - point1[1], point[2] - point1[2]));
            distMin = distMin < dist ? distMin : dist;
            distMax = distMax > dist ? distMax : dist;
            
            if (o != grids.size()-1) {
                //if (dist > maxSeg || dist < minSeg) {
                //    continue;
                //}
            }
            validPoints[o][i] = 0;

            Vector clsst(point1[0],point1[1],point1[2]);
            
            if (splinesAtPoint[i].Find(clsst) == NOTOK){
                splinesAtPoint[i].Push(clsst);
            }
        }
        
        if (!lastPointCaptured) continue;
        SplineObject* spline=SplineObject::Alloc(splinesAtPoint[i].GetCount(),SPLINETYPE_BSPLINE);
        if (!spline) continue;
        
        spline->GetDataInstance()->SetBool(SPLINEOBJECT_CLOSED, FALSE);
        
        Vector *padr = spline->GetPointW();
        for (LONG l = 0; l < splinesAtPoint[i].GetCount(); l++){
            padr[l] = splinesAtPoint[i][l];
        }
        
        splineHelp->InitSpline(spline);
        Real splnLength = splineHelp->GetSplineLength();
        if (splnLength > 0.0){
            splinePairs.push_back(SplinePair(spline, splnLength));
            avSplineLength += splnLength;
            avSplineSize += splinesAtPoint[i].GetCount();
        } else {
            SplineObject::Free(spline);
        }
        
        if (i % 5 == 0){
            LONG progress = 10 + (90*i)/splinesAtPoint.GetCount();
            StatusSetBar(progress);
            StatusSetText(LongToString(progress)+"%");
            if (bt && bt->TestBreak()){
                //break; //this break seems to be kicking in randomly killing the loop
            }
        }
    }
    
    LONG splnSize = splinePairs.size();
    GePrint(LongToString(i)+" points "+LongToString(splnSize)+" splines");
    if (splnSize > 0) {
        LONG limit =  splnSize * longestPercent / 100;
        limit = limit == 0 ? 1 : limit;
        
        std::sort(splinePairs.begin(), splinePairs.end(),comparator);
        
        for (int s = 0; s < limit; s++){
            avSplineLength += splinePairs[s].second;
//.........这里部分代码省略.........
开发者ID:eighteight,项目名称:Voxelify,代码行数:101,代码来源:voxelify.cpp


注:本文中的AutoAlloc::GetSplineLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。