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


C++ ScalarField::placeIteratorAtBegining方法代码示例

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


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

示例1: saveToFile

CC_FILE_ERROR LASFilter::saveToFile(ccHObject* entity, const char* filename)
{
   if (!entity || !filename)
      return CC_FERR_BAD_ARGUMENT;

   ccHObject::Container clouds;
   if (entity->isKindOf(CC_POINT_CLOUD))
      clouds.push_back(entity);
   else
      entity->filterChildren(clouds, true, CC_POINT_CLOUD);

   if (clouds.empty())
   {
      ccConsole::Error("No point cloud in input selection!");
      return CC_FERR_BAD_ENTITY_TYPE;
   }
   else if (clouds.size()>1)
   {
      ccConsole::Error("Can't save more than one cloud per LAS file!");
      return CC_FERR_BAD_ENTITY_TYPE;
   }

   //the cloud to save
   ccGenericPointCloud* theCloud = static_cast<ccGenericPointCloud*>(clouds[0]);
   unsigned numberOfPoints = theCloud->size();

   if (numberOfPoints==0)
   {
      ccConsole::Error("Cloud is empty!");
      return CC_FERR_BAD_ENTITY_TYPE;
   }

   //colors
   bool hasColor = theCloud->hasColors();

   //classification (as a scalar field)
   CCLib::ScalarField* classifSF = 0;
   if (theCloud->isA(CC_POINT_CLOUD))
   {
      ccPointCloud* pc = static_cast<ccPointCloud*>(theCloud);
      int sfIdx = pc->getScalarFieldIndexByName(CC_LAS_CLASSIFICATION_FIELD_NAME);
      if (sfIdx>=0)
      {
         classifSF = pc->getScalarField(sfIdx);
         if (/*classifSF->getMax()>(ScalarType)liblas::Classification::class_table_size ||*/ classifSF->getMin()<0)
         {
            ccConsole::Warning("[LASFilter] Found a 'classification' scalar field, but its values outbounds LAS specifications (0-255)...");
            classifSF = 0;
         }
         else
         {
            //we check that it's only integer values!
            unsigned i,count=classifSF->currentSize();
            classifSF->placeIteratorAtBegining();
            double integerPart = 0.0;
            for (i=0;i<count;++i)
            {
               if (modf(classifSF->getCurrentValue(),&integerPart) != 0.0)
               {
                  ccConsole::Warning("[LASFilter] Found a 'classification' scalar field, but its values are not pure integers...");
                  classifSF = 0;
                  break;
               }
            }
         }
      }
   }

   //open binary file for writing
   std::ofstream ofs;
   ofs.open(filename, std::ios::out | std::ios::binary);

   if (ofs.fail())
      return CC_FERR_WRITING;

   const double* shift = theCloud->getOriginalShift();

   liblas::Writer* writer = 0;
   try
   {
      liblas::Header header;

      //LAZ support based on extension!
      if (QFileInfo(filename).suffix().toUpper() == "LAZ")
      {
         header.SetCompressed(true);
      }

      //header.SetDataFormatId(liblas::ePointFormat3);
      ccBBox bBox = theCloud->getBB();
      if (bBox.isValid())
      {
         header.SetMin(-shift[0]+(double)bBox.minCorner().x,-shift[1]+(double)bBox.minCorner().y,-shift[2]+(double)bBox.minCorner().z);
         header.SetMax(-shift[0]+(double)bBox.maxCorner().x,-shift[1]+(double)bBox.maxCorner().y,-shift[2]+(double)bBox.maxCorner().z);
         CCVector3 diag = bBox.getDiagVec();

         //Set offset & scale, as points will be stored as boost::int32_t values (between 0 and 4294967296)
         //int_value = (double_value-offset)/scale
         header.SetOffset(-shift[0]+(double)bBox.minCorner().x,-shift[1]+(double)bBox.minCorner().y,-shift[2]+(double)bBox.minCorner().z);
         header.SetScale(1.0e-9*std::max<double>(diag.x,ZERO_TOLERANCE), //result must fit in 32bits?!
//.........这里部分代码省略.........
开发者ID:tidyup,项目名称:trunk,代码行数:101,代码来源:LASFilter.cpp


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