void fromJsonArray(const Json::Value& parent, std::vector<T>& ref, int size) {
  if (parent.size() != size) {
    PRINT_AND_THROW(boost::format("expected list of size size %i. got: %s\n")%size%parent);
  }
  else {
    fromJsonArray(parent, ref);
  }
}
void childFromJson(const Json::Value& parent, T& ref, const char* name) {
  if (parent.isMember(name)) {
    const Json::Value& v = parent[name];
    fromJson(v, ref);
  }
  else {
    PRINT_AND_THROW(boost::format("missing field: %s")%name);
  }
}
Example #3
0
pcl::PointCloud<pcl::PointXYZRGB>::Ptr CloudGrabberImpl::getXYZRGB() {
  if (m_ss == IDLE) {
    printf("start streaming just for this point cloud\n");
    startXYZRGB();
    pcl::PointCloud<pcl::PointXYZRGB>::Ptr out = getXYZRGB();
    stop();
    return out;
  }
  else if (m_ss == XYZRGB) {
    m_rs = PENDING;
    while (m_rs == PENDING) sleep(.01);
    return m_xyzrgb;
  }
  else PRINT_AND_THROW("asked for xyzrgb but currently streaming xyz");
}
pcl::PolygonMesh::Ptr quadricSimplifyVTK(pcl::PolygonMesh& in, float meshDecimationFrac) {
  if (meshDecimationFrac < 0 || meshDecimationFrac > 1) PRINT_AND_THROW("expected 0 <= meshDecimationFrac <= 1");

  vtkSmartPointer<vtkPolyData> inputPolyData =
      vtkSmartPointer<vtkPolyData>::New();
  toVTK(in, *inputPolyData);

  vtkSmartPointer<vtkQuadricDecimation2> decimate = vtkSmartPointer<
      vtkQuadricDecimation2>::New();
  decimate->SetTargetReduction(1-meshDecimationFrac);
  decimate->SetInput(inputPolyData.GetPointer());
  decimate->Update();

  vtkSmartPointer<vtkPolyData> decimated = vtkSmartPointer<vtkPolyData>::New();
  decimated->ShallowCopy(decimate->GetOutput());

  PolygonMesh::Ptr out(new PolygonMesh());
  toPCL(*decimated, *out);
  return out;
}