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


C++ Octree::SetLaplacianConstraints方法代码示例

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


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

示例1: PoissonRecon


//.........这里部分代码省略.........
        //if( kernelDepth>Depth.value )
        //{
        //    fprintf( stderr,"[ERROR] %s can't be greater than %s: %d <= %d\n" , KernelDepth.name , Depth.name , KernelDepth.value , Depth.value );
        //    return EXIT_FAILURE;
        //}
        //
        int pointNumber = pPC->GetPointNumber();
        std::vector<float> posList(pointNumber * 3);
        std::vector<float> norList(pointNumber * 3);
        for (int pIndex = 0; pIndex < pointNumber; pIndex++)
        {
            posList.at(3 * pIndex + 0) = pPC->GetPoint(pIndex)->GetPosition()[0];
            posList.at(3 * pIndex + 1) = pPC->GetPoint(pIndex)->GetPosition()[1];
            posList.at(3 * pIndex + 2) = pPC->GetPoint(pIndex)->GetPosition()[2];
            norList.at(3 * pIndex + 0) = pPC->GetPoint(pIndex)->GetNormal()[0];
            norList.at(3 * pIndex + 1) = pPC->GetPoint(pIndex)->GetNormal()[1];
            norList.at(3 * pIndex + 2) = pPC->GetPoint(pIndex)->GetNormal()[2];
        }
        //
        double maxMemoryUsage;
        t=Time() , tree.maxMemoryUsage=0;
        //int pointCount = tree.setTree( In.value , Depth.value , MinDepth.value , kernelDepth , Real(SamplesPerNode.value) , Scale.value , Confidence.set , PointWeight.value , AdaptiveExponent.value , xForm );
        int pointCount = tree.setTree( posList, norList, Depth.value , MinDepth.value , kernelDepth , Real(SamplesPerNode.value) , Scale.value , Confidence.set , PointWeight.value , AdaptiveExponent.value , xForm );
        tree.ClipTree();
        tree.finalize( IsoDivide.value );

        /*DumpOutput2( comments[commentNum++] , "#             Tree set in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
        DumpOutput( "Input Points: %d\n" , pointCount );
        DumpOutput( "Leaves/Nodes: %d/%d\n" , tree.tree.leaves() , tree.tree.nodes() );
        DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage() )/(1<<20) );*/

        maxMemoryUsage = tree.maxMemoryUsage;
        t=Time() , tree.maxMemoryUsage=0;
        tree.SetLaplacianConstraints();
        /*DumpOutput2( comments[commentNum++] , "#      Constraints set in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
        DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage())/(1<<20) );*/
        maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );

        t=Time() , tree.maxMemoryUsage=0;
        tree.LaplacianMatrixIteration( SolverDivide.value, ShowResidual.set , MinIters.value , SolverAccuracy.value , MaxSolveDepth.value , FixedIters.value );
        /*DumpOutput2( comments[commentNum++] , "# Linear system solved in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
        DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage() )/(1<<20) );*/
        maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );

        CoredFileMeshData< PlyValueVertex< Real > > mesh;

        if( Verbose.set ) tree.maxMemoryUsage=0;
        t=Time();
        isoValue = tree.GetIsoValue();
        //DumpOutput( "Got average in: %f\n" , Time()-t );
        //DumpOutput( "Iso-Value: %e\n" , isoValue );

        if( VoxelGrid.set )
        {
            double t = Time();
            FILE* fp = fopen( VoxelGrid.value , "wb" );
            if( !fp ) fprintf( stderr , "Failed to open voxel file for writing: %s\n" , VoxelGrid.value );
            else
            {
                int res;
                Pointer( Real ) values = tree.GetSolutionGrid( res , isoValue , VoxelDepth.value );
                fwrite( &res , sizeof(int) , 1 , fp );
                if( sizeof(Real)==sizeof(float) ) fwrite( values , sizeof(float) , res*res*res , fp );
                else
                {
                    float *fValues = new float[res*res*res];
开发者ID:jinghuaguo,项目名称:magic3d,代码行数:67,代码来源:PoissonReconstruction.cpp

示例2: Execute

bool Execute(PointStream< Real > *ps, CMeshO &pm, PoissonParam<Real> &pp, vcg::CallBackPos* cb)
{
  Reset< Real >();
  XForm4x4< Real > xForm=XForm4x4< Real >::Identity();

  cb(1,"Running Screened Poisson Reconstruction\n" );

  double t;
  double tt=Time();
  Real isoValue = 0;

  Octree< Real > tree;
  tree.threads = 1;
  if( pp.MaxSolveDepthVal<0 ) pp.MaxSolveDepthVal = pp.MaxDepthVal;

  //    OctNode< TreeNodeData >::SetAllocator( MEMORY_ALLOCATOR_BLOCK_SIZE );
  OctNode< TreeNodeData >::SetAllocator( 0 );

  //    int kernelDepth = KernelDepth.set ?  KernelDepth.value : Depth.value-2;
  if(pp.KernelDepthVal<0) pp.KernelDepthVal =pp.MaxDepthVal-2;
  if( pp.KernelDepthVal>pp.MaxDepthVal )
    return false;

  cb(10,"Creating Tree");
  double maxMemoryUsage;
  t=Time();
  //     tree.maxMemoryUsage=0;
  typename Octree< Real >::PointInfo* pointInfo = new typename Octree< Real >::PointInfo();
  typename Octree< Real >::NormalInfo* normalInfo = new typename Octree< Real >::NormalInfo();
  std::vector< Real >* kernelDensityWeights = new std::vector< Real >();
  std::vector< Real >* centerWeights = new std::vector< Real >();
  //    int SetTree( char* fileName , int minDepth , int maxDepth , int fullDepth , int splatDepth , Real samplesPerNode ,
  //		Real scaleFactor , bool useConfidence , bool useNormalWeight , Real constraintWeight , int adaptiveExponent ,
  //		PointInfo& pointInfo , NormalInfo& normalInfo , std::vector< Real >& kernelDensityWeights , std::vector< Real >& centerWeights ,
  //		int boundaryType=BSplineElements< Degree >::NONE , XForm4x4< Real > xForm=XForm4x4< Real >::Identity , bool makeComplete=false );

  TreeNodeData::NodeCount=0;
  int pointCount = tree.template SetTree< Scalarm >(  0, pp.MinDepthVal , pp.MaxDepthVal , pp.FullDepthVal , pp.KernelDepthVal , pp.SamplesPerNodeVal ,
                                                      pp.ScaleVal , pp.ConfidenceFlag , pp.NormalWeightsFlag , pp.PointWeightVal , pp.AdaptiveExponentVal ,
                                                      *pointInfo , *normalInfo , *kernelDensityWeights , *centerWeights ,
                                                      ps, pp.BoundaryTypeVal , xForm , pp.CompleteFlag );

  DumpOutput("#             Tree set in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
  DumpOutput( "Input Points: %d\n" , pointCount );
  DumpOutput( "Leaves/Nodes: %d/%d\n" , tree.tree.leaves() , tree.tree.nodes() );
  DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage() )/(1<<20) );

  maxMemoryUsage = tree.maxMemoryUsage;
  cb(20,"Settng Constraints");
  t=Time() , tree.maxMemoryUsage=0;
  Pointer( Real ) constraints = tree.SetLaplacianConstraints( *normalInfo );
  delete normalInfo;
  DumpOutput("#      Constraints set in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
  DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage())/(1<<20) );
  maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );

  cb(70,"Solving Linear system");
  t=Time() , tree.maxMemoryUsage=0;
  Pointer( Real ) solution = tree.SolveSystem( *pointInfo , constraints , pp.ShowResidualFlag , pp.ItersVal , pp.MaxSolveDepthVal , pp.CGDepthVal , pp.CSSolverAccuracyVal );
  delete pointInfo;
  FreePointer( constraints );
  DumpOutput( "# Linear system solved in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
  DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage() )/(1<<20) );
  maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );

  CoredFileMeshData< PlyValueVertex< float > > mesh;

  tree.maxMemoryUsage=0;
  t=Time();
  isoValue = tree.GetIsoValue( solution , *centerWeights );
  delete centerWeights;
  DumpOutput( "Got average in: %f\n" , Time()-t );
  DumpOutput( "Iso-Value: %e\n" , isoValue );

  cb(80,"Building Isosurface");
  t = Time() , tree.maxMemoryUsage = 0;
  assert(kernelDensityWeights);
  tree.GetMCIsoSurface(  GetPointer( *kernelDensityWeights ) , solution , isoValue , mesh , true , !pp.NonManifoldFlag , false /*PolygonMesh.set*/ );
  DumpOutput("#        Got triangles in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
  maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );
  DumpOutput( "#             Total Solve: %9.1f (s), %9.1f (MB)\n" , Time()-tt , maxMemoryUsage );

  DumpOutput( "Vertices / Polygons: %d / %d\n" , mesh.outOfCorePointCount()+mesh.inCorePoints.size() , mesh.polygonCount() );
  FreePointer( solution );

  cb(90,"Creating Mesh");
  mesh.resetIterator();
  int vm = mesh.outOfCorePointCount()+mesh.inCorePoints.size();

  vcg::tri::Allocator<CMeshO>::AddVertices(pm,vm);


  int i;
  for (i=0; i < int(mesh.inCorePoints.size()); i++){
    pm.vert[i].P()[0] = mesh.inCorePoints[i].point[0];
    pm.vert[i].P()[1] = mesh.inCorePoints[i].point[1];
    pm.vert[i].P()[2] = mesh.inCorePoints[i].point[2];
    pm.vert[i].Q() = mesh.inCorePoints[i].value;
  }
  for (int ii=0; ii < mesh.outOfCorePointCount(); ii++){
//.........这里部分代码省略.........
开发者ID:HaiJiaoXinHeng,项目名称:meshlab-1,代码行数:101,代码来源:filter_screened_poisson.cpp

示例3: ExecuteMemory


//.........这里部分代码省略.........
    }

    OctNode< TreeNodeData< false > , Real >::SetAllocator( MEMORY_ALLOCATOR_BLOCK_SIZE );

    t=Time();
    int kernelDepth = KernelDepth.set ?  KernelDepth.value : Depth.value-2;

    tree.setBSplineData( Depth.value , BoundaryType.value );
    if( kernelDepth>Depth.value )
    {
        fprintf( stderr,"[ERROR] %s can't be greater than %s: %d <= %d\n" , KernelDepth.name , Depth.name , KernelDepth.value , Depth.value );
        return EXIT_FAILURE;
    }

    double maxMemoryUsage;
    t=Time() , tree.maxMemoryUsage=0;

    //int pointCount = tree.setTree( In.value , Depth.value , MinDepth.value , kernelDepth , Real(SamplesPerNode.value) , Scale.value , Confidence.set , PointWeight.value , AdaptiveExponent.value , xForm );

    // Load data
    MemoryPointStream< Real >* ps = new MemoryPointStream< Real >( &positions, &normals );
    int pointCount = tree.setTreeMemory( ps , Depth.value , MinDepth.value , kernelDepth , Real(SamplesPerNode.value) , Scale.value , Confidence.set , PointWeight.value , AdaptiveExponent.value , xForm );

    tree.ClipTree();
    tree.finalize( IsoDivide.value );

    DumpOutput2( comments[commentNum++] , "#             Tree set in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
    DumpOutput( "Input Points: %d\n" , pointCount );
    DumpOutput( "Leaves/Nodes: %d/%d\n" , tree.tree.leaves() , tree.tree.nodes() );
    DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage() )/(1<<20) );

    maxMemoryUsage = tree.maxMemoryUsage;
    t=Time() , tree.maxMemoryUsage=0;
    tree.SetLaplacianConstraints();
    DumpOutput2( comments[commentNum++] , "#      Constraints set in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
    DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage())/(1<<20) );
    maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );

    t=Time() , tree.maxMemoryUsage=0;
    tree.LaplacianMatrixIteration( SolverDivide.value, ShowResidual.set , MinIters.value , SolverAccuracy.value , MaxSolveDepth.value , FixedIters.value );
    DumpOutput2( comments[commentNum++] , "# Linear system solved in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
    DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage() )/(1<<20) );
    maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );

    CoredFileMeshData< Vertex > mesh;

    if( Verbose.set ) tree.maxMemoryUsage=0;
    t=Time();
    isoValue = tree.GetIsoValue();
    DumpOutput( "Got average in: %f\n" , Time()-t );
    DumpOutput( "Iso-Value: %e\n" , isoValue );

    if( VoxelGrid.set )
    {
        double t = Time();
        FILE* fp = fopen( VoxelGrid.value , "wb" );
        if( !fp ) fprintf( stderr , "Failed to open voxel file for writing: %s\n" , VoxelGrid.value );
        else
        {
            int res;
            Pointer( Real ) values = tree.GetSolutionGrid( res , isoValue , VoxelDepth.value );
            fwrite( &res , sizeof(int) , 1 , fp );
            if( sizeof(Real)==sizeof(float) ) fwrite( values , sizeof(float) , res*res*res , fp );
            else
            {
                float *fValues = new float[res*res*res];
开发者ID:BigkoalaZhu,项目名称:StBl,代码行数:67,代码来源:PoissonRecon.cpp

示例4: Execute

int Execute( int argc , char* argv[] )
{
    Reset< Real >();
    int i;
    int paramNum = sizeof(params)/sizeof(cmdLineReadable*);
    int commentNum=0;
    char **comments;

    comments = new char*[paramNum+7];
    for( i=0 ; i<paramNum+7 ; i++ ) comments[i] = new char[1024];

    if( Verbose.set ) echoStdout=1;

    XForm4x4< Real > xForm , iXForm;
    if( XForm.set )
    {
        FILE* fp = fopen( XForm.value , "r" );
        if( !fp )
        {
            fprintf( stderr , "[WARNING] Could not read x-form from: %s\n" , XForm.value );
            xForm = XForm4x4< Real >::Identity();
        }
        else
        {
            for( int i=0 ; i<4 ; i++ ) for( int j=0 ; j<4 ; j++ )
            {
                float f;
                fscanf( fp , " %f " , &f );
                xForm(i,j) = (Real)f;
            }
            fclose( fp );
        }
    }
    else xForm = XForm4x4< Real >::Identity();
    iXForm = xForm.inverse();

    DumpOutput2( comments[commentNum++] , "Running Screened Poisson Reconstruction (Version 6.13)\n" );
    char str[1024];
    for( int i=0 ; i<paramNum ; i++ )
        if( params[i]->set )
        {
            params[i]->writeValue( str );
            if( strlen( str ) ) DumpOutput2( comments[commentNum++] , "\t--%s %s\n" , params[i]->name , str );
            else                DumpOutput2( comments[commentNum++] , "\t--%s\n" , params[i]->name );
        }

    double t;
    double tt=PTime();
    Real isoValue = 0;

    Octree< Real > tree;
    tree.threads = Threads.value;
    if( !In.set )
    {
        ShowUsage(argv[0]);
        return 0;
    }
    if( !MaxSolveDepth.set ) MaxSolveDepth.value = Depth.value;

    OctNode< TreeNodeData >::SetAllocator( MEMORY_ALLOCATOR_BLOCK_SIZE );

    t=PTime();
    int kernelDepth = KernelDepth.set ?  KernelDepth.value : Depth.value-2;
    if( kernelDepth>Depth.value )
    {
        fprintf( stderr,"[ERROR] %s can't be greater than %s: %d <= %d\n" , KernelDepth.name , Depth.name , KernelDepth.value , Depth.value );
        return EXIT_FAILURE;
    }

    double maxMemoryUsage;
    t=PTime() , tree.maxMemoryUsage=0;
    typename Octree< Real >::PointInfo* pointInfo = new typename Octree< Real >::PointInfo();
    typename Octree< Real >::NormalInfo* normalInfo = new typename Octree< Real >::NormalInfo();
    std::vector< Real >* kernelDensityWeights = new std::vector< Real >();
    std::vector< Real >* centerWeights = new std::vector< Real >();
    PointStream< float >* pointStream;
    char* ext = GetFileExtension( In.value );
    if     ( !strcasecmp( ext , "bnpts" ) ) pointStream = new BinaryPointStream< float >( In.value );
    else if( !strcasecmp( ext , "ply"   ) ) pointStream = new    PLYPointStream< float >( In.value );
    else                                    pointStream = new  ASCIIPointStream< float >( In.value );
    delete[] ext;
    int pointCount = tree.template SetTree< float >( pointStream , MinDepth.value , Depth.value , FullDepth.value , kernelDepth , Real(SamplesPerNode.value) , Scale.value , Confidence.set , NormalWeights.set , PointWeight.value , AdaptiveExponent.value , *pointInfo , *normalInfo , *kernelDensityWeights , *centerWeights , BoundaryType.value , xForm , Complete.set );
    if( !Density.set ) delete kernelDensityWeights , kernelDensityWeights = NULL;

    DumpOutput2( comments[commentNum++] , "#             Tree set in: %9.1f (s), %9.1f (MB)\n" , PTime()-t , tree.maxMemoryUsage );
    DumpOutput( "Input Points: %d\n" , pointCount );
    DumpOutput( "Leaves/Nodes: %d/%d\n" , tree.tree.leaves() , tree.tree.nodes() );
    DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage() )/(1<<20) );

    maxMemoryUsage = tree.maxMemoryUsage;
    t=PTime() , tree.maxMemoryUsage=0;
    Pointer( Real ) constraints = tree.SetLaplacianConstraints( *normalInfo );
    delete normalInfo;
    DumpOutput2( comments[commentNum++] , "#      Constraints set in: %9.1f (s), %9.1f (MB)\n" , PTime()-t , tree.maxMemoryUsage );
    DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage())/(1<<20) );
    maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );

    t=PTime() , tree.maxMemoryUsage=0;
    Pointer( Real ) solution = tree.SolveSystem( *pointInfo , constraints , ShowResidual.set , Iters.value , MaxSolveDepth.value , CGDepth.value , CSSolverAccuracy.value );
    delete pointInfo;
//.........这里部分代码省略.........
开发者ID:GEO-IASS,项目名称:micmac-archeos,代码行数:101,代码来源:PoissonRecon.cpp


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