bool save(const Path &path, const std::vector<Vertex> &verts, const std::vector<TriangleI> &tris) { if (path.testExtension("wo3")) return saveWo3(path, verts, tris); else if (path.testExtension("obj")) return saveObj(path, verts, tris); return false; }
int main(int argc, char** argv) { if (argc != 4) { printUsage(argv[0]); return 1; } std::vector<float> verts; std::vector<int> nvertsPerFace; std::vector<int> faceverts; if (!loadOBJ(argv[1], verts, nvertsPerFace, faceverts)) { printf("could not load %s\n", argv[1]); return 1; } saveObj(argv[2]); for (int i = 0; i < 1; i++) { Subd subd(verts.size()/3, &verts[0], nvertsPerFace.size(), &nvertsPerFace[0], &faceverts[0]); // timer t; // for (int i = 0; i < 1; i++) { // subd.subdivide(2); // } // t.stop(); // saveObj(argv[2], &subd, /*limit=*/ 1); int numsamples = atoi(argv[3]); double du = 1.0 / (numsamples-1); double dv = du; for (int f = 0; f < subd.nfaces(); f++) { double u = 0.0; for (int i = 0; i < numsamples; u += du, i++) { double v = 0.0; for (int j = 0; j < numsamples; v += dv, j++) { double p[3], dpdu[3], dpdv[3]; subd.eval(f, u, v, p, dpdu, dpdv); addLine(p, dpdu); addLine(p, dpdv); } } } } return 0; }
void colorRecons(std::string infile, std::string outfile) { sensor_msgs::PointCloud2 cloud_blob; // run this from BodyScanner/build/surface_reconstructor/ pcl::io::loadPCDFile(infile, cloud_blob); pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB> ()); pcl::fromROSMsg(cloud_blob, *cloud); pcl::PointCloud<pcl::PointXYZ>::Ptr filtered_cloud(new pcl::PointCloud<pcl::PointXYZ>()); pcl::PointCloud<pcl::PointXYZRGB>::Ptr filtered_cloud_color(new pcl::PointCloud<pcl::PointXYZRGB>()); int l = 0; for(int j = 0; j < 480; j += 1) { for(int i = j%2; i < 640; i += 2) { int k = i + j*640; pcl::PointXYZRGB& p = (*cloud)[k]; pcl::PointXYZ pp; pcl::PointXYZRGB pc; pc.x = pp.x = p.x; pc.y = pp.y = p.y; pc.z = pp.z = p.z; pc.r = p.r; pc.g = p.g; pc.b = p.b; //pp.nx = 0; pp.ny = 0; pp.nz = 0; //if((i&1 && j&1) // keep 1/4 of the points if(mag(p) < 3) { // keep only points within a close distance to the origin filtered_cloud->push_back(pp); filtered_cloud_color->push_back(pc); } } } // Normal estimation* pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n; pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>); pcl::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::KdTreeFLANN<pcl::PointXYZ>); tree->setInputCloud(filtered_cloud); n.setInputCloud(filtered_cloud); n.setSearchMethod(tree); n.setKSearch(20); n.compute(*normals); // Concatenate the XYZ and normal fields* pcl::PointCloud<pcl::PointNormal>::Ptr filtered_cloud_with_normals(new pcl::PointCloud<pcl::PointNormal>); pcl::concatenateFields(*filtered_cloud, *normals, *filtered_cloud_with_normals); // Create search tree* pcl::KdTree<pcl::PointNormal>::Ptr tree2(new pcl::KdTreeFLANN<pcl::PointNormal>); tree2->setInputCloud(filtered_cloud_with_normals); // Initialize objects pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3; pcl::PolygonMesh triangles; // Set the maximum distance between connected points (maximum edge length) gp3.setSearchRadius(0.1); // Set typical values for the parameters gp3.setMu(2.5); gp3.setMaximumNearestNeighbors(50); // reducing this didn't fix flips setMaximumSurfaceAngle(gp3, M_PI/4); // 45 degrees gp3.setMinimumAngle(M_PI/18); // 10 degrees gp3.setMaximumAngle(2*M_PI/3); // 120 degrees gp3.setNormalConsistency(true); // changing this didn't fix flips // Get result gp3.setInputCloud(filtered_cloud_with_normals); gp3.setSearchMethod(tree2); gp3.reconstruct(triangles); saveObj(outfile, triangles, filtered_cloud_color); }
BOOL CALLBACK GroupObjectProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { OBJECTID hobjGroup ; int Index ; OBJECTID theObj ; switch (message) { case WM_INITDIALOG: AUtlSetTitleFont(OTYPE_GROUP, NULL, GetDlgItem(hDlg, IDD_OBJECT)); AUtlCenterDialog(hDlg, 0); SetWindowLong(hDlg, DWL_USER, lParam) ; hobjGroup = (OBJECTID)lParam ; InitDialog(hDlg, hobjGroup) ; return FALSE ; case WM_COMMAND: if (LOWORD(wParam) >= textB && LOWORD(wParam) <= otherB) { CheckRadioButton (hDlg, textB, otherB, LOWORD(wParam)) ; UpdateObjectList(hDlg, LOWORD(wParam)) ; return TRUE ; } switch (LOWORD(wParam)) { case IDD_OBJECTSLIST: //switch (HIWORD (lParam)) switch(HIWORD(wParam)) { case LBN_SELCHANGE: EnableWindow(GetDlgItem(hDlg, addB), TRUE) ; return TRUE ; case LBN_DBLCLK: AddItem(hDlg) ; return TRUE ; } break ; case IDD_FIELDSLIST: switch (HIWORD (lParam)) { case LBN_SELCHANGE: EnableWindow (GetDlgItem(hDlg, removeB), TRUE) ; //if (SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_GETSELCOUNT, 0, 0L)==1) if (ListBox_GetSelCount (GetDlgItem(hDlg, IDD_FIELDSLIST))==1) EnableWindow (GetDlgItem(hDlg, editB), TRUE) ; else EnableWindow (GetDlgItem(hDlg, editB), FALSE) ; return TRUE ; case LBN_DBLCLK: Index = (int)ListBox_GetCurSel(GetDlgItem(hDlg, IDD_FIELDSLIST)) ; theObj = (OBJECTID)ListBox_GetItemData(GetDlgItem (hDlg,IDD_FIELDSLIST), Index) ; //theObj =(OBJECTID) SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_GETITEMDATA, Index, 0) ; return (AObjEdit(theObj) == A_MODIFIED); } break ; case addB: AddItem(hDlg) ; //EnableWindow (GetDlgItem(hDlg, addB), FALSE) ; return TRUE ; case removeB: RemoveItem(hDlg) ; return TRUE ; case editB: EditItem(hDlg) ; return TRUE ; case IDOK: // save the File object's default extention // save the typeIDs for each object to be stored hobjGroup =(OBJECTID)GetWindowLong (hDlg, DWL_USER) ; saveObj (hDlg, hobjGroup) ; EndDialog (hDlg, TRUE) ; return TRUE ; case IDCANCEL: EndDialog (hDlg, FALSE) ; return TRUE ; case IDHELP: WinHelp (hDlg, "serhelp.hlp", HELP_CONTEXT, HELPID_OBJD_Grup) ; return TRUE ; } } return FALSE ; }