Thread: [brlcad-commits] SF.net SVN: brlcad:[55253] brlcad/trunk/src/librt/tests/test_ssi.cpp
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <pho...@us...> - 2013-04-26 09:43:23
|
Revision: 55253 http://sourceforge.net/p/brlcad/code/55253 Author: phoenixyjll Date: 2013-04-26 09:43:20 +0000 (Fri, 26 Apr 2013) Log Message: ----------- Eliminate the compiling problems in Linux. Modified Paths: -------------- brlcad/trunk/src/librt/tests/test_ssi.cpp Modified: brlcad/trunk/src/librt/tests/test_ssi.cpp =================================================================== --- brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-04-26 09:15:14 UTC (rev 55252) +++ brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-04-26 09:43:20 UTC (rev 55253) @@ -103,16 +103,16 @@ ON_SimpleArray<ON_NurbsCurve*> curve_uv; ON_SimpleArray<ON_NurbsCurve*> curve_st; - int i = atoi(argv[4]), j = atoi(argv[5]); - if (i < 0 || i >= brep1->m_S.Count() || j < 0 || j >= brep2->m_S.Count()) { + int a = atoi(argv[4]), b = atoi(argv[5]); + if (a < 0 || a >= brep1->m_S.Count() || b < 0 || b >= brep2->m_S.Count()) { bu_log("Out of range: \n"); bu_log("\t0 <= i <= %d\n", brep1->m_S.Count() - 1); bu_log("\t0 <= j <= %d\n", brep2->m_S.Count() - 1); return -1; } - brep1->m_S[i]->GetNurbForm(surf1); - brep2->m_S[j]->GetNurbForm(surf2); + brep1->m_S[a]->GetNurbForm(surf1); + brep2->m_S[b]->GetNurbForm(surf2); // Run the intersection (max_dis = 0) if (brlcad::surface_surface_intersection(&surf1, &surf2, curve, curve_uv, curve_st, 0)) { @@ -188,15 +188,14 @@ char *name = new char [strlen(intersect_name) + 10]; strcpy(name, intersect_name); char number[10]; - itoa(i, number, 10); + sprintf(number, "%d", i); strcat(name, number); struct bu_external ext; BU_CK_EXTERNAL(&ext); - int flags = db_flags_internal(&intern); struct directory *dp; dp = db_diradd(dbip, name, RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (genptr_t)&intern.idb_type); - int ret = rt_db_put_internal(dp, dbip, &intern, &rt_uniresource); + ret = rt_db_put_internal(dp, dbip, &intern, &rt_uniresource); if (ret) bu_log("ERROR: failure writing [%s] to disk\n", name); else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pho...@us...> - 2013-04-26 10:04:02
|
Revision: 55254 http://sourceforge.net/p/brlcad/code/55254 Author: phoenixyjll Date: 2013-04-26 10:03:58 +0000 (Fri, 26 Apr 2013) Log Message: ----------- Remove the unnecessary conversion and debugging outputs. Modified Paths: -------------- brlcad/trunk/src/librt/tests/test_ssi.cpp Modified: brlcad/trunk/src/librt/tests/test_ssi.cpp =================================================================== --- brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-04-26 09:43:20 UTC (rev 55253) +++ brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-04-26 10:03:58 UTC (rev 55254) @@ -178,7 +178,6 @@ ON_3dPoint p = curve[i]->PointAt(dom.ParameterAt((double) j / (double) plotres)); VSET(ps->pp_coord, p.x, p.y, p.z); - bu_log("%lf %lf %lf\n", p.x, p.y, p.z); ps->pp_id = 50; ps->pp_od = 100; ps->pp_bendradius = 0; @@ -191,8 +190,6 @@ sprintf(number, "%d", i); strcat(name, number); - struct bu_external ext; - BU_CK_EXTERNAL(&ext); struct directory *dp; dp = db_diradd(dbip, name, RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (genptr_t)&intern.idb_type); ret = rt_db_put_internal(dp, dbip, &intern, &rt_uniresource); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2013-04-26 23:53:24
|
Revision: 55261 http://sourceforge.net/p/brlcad/code/55261 Author: starseeker Date: 2013-04-26 23:53:21 +0000 (Fri, 26 Apr 2013) Log Message: ----------- Per Code Conventions section in hacking, don't use straight-up strcpy and strcat. Go with vls strings instead. To run the check for these cases, build the 'regress-repository' target - e.g. 'make regress-repository' Modified Paths: -------------- brlcad/trunk/src/librt/tests/test_ssi.cpp Modified: brlcad/trunk/src/librt/tests/test_ssi.cpp =================================================================== --- brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-04-26 21:52:25 UTC (rev 55260) +++ brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-04-26 23:53:21 UTC (rev 55261) @@ -65,6 +65,7 @@ main(int argc, char** argv) { int ret = 0; + struct bu_vls intersect_name, name; if (argc != 6 && argc != 7) { bu_log("Usage: %s %s\n", argv[0], "<file> <obj1> <obj2> <surf_i> <surf_j> [curve_name]"); @@ -142,17 +143,17 @@ bu_log("%s", str); delete str; */ - char *intersect_name; + bu_vls_init(&intersect_name); if (argc == 7) { - intersect_name = argv[6]; + bu_vls_sprintf(&intersect_name, argv[6]); } else { - intersect_name = new char [strlen(argv[2]) + strlen(argv[3]) + 3]; - strcpy(intersect_name, argv[2]); - strcat(intersect_name, "_"); - strcat(intersect_name, argv[3]); - strcat(intersect_name, "_"); + bu_vls_strcpy(&intersect_name, argv[2]); + bu_vls_strcat(&intersect_name, "_"); + bu_vls_strcat(&intersect_name, argv[3]); + bu_vls_strcat(&intersect_name, "_"); } + bu_vls_init(&name); for (int i = 0; i < curve.Count(); i++) { // Do sampling, and use a pipe primitive to represent a curve struct rt_db_internal intern; @@ -184,19 +185,15 @@ BU_LIST_INSERT(&pi->pipe_segs_head, &ps->l); } - char *name = new char [strlen(intersect_name) + 10]; - strcpy(name, intersect_name); - char number[10]; - sprintf(number, "%d", i); - strcat(name, number); + bu_vls_sprintf(&name, "%s%d", bu_vls_addr(&intersect_name), i); struct directory *dp; - dp = db_diradd(dbip, name, RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (genptr_t)&intern.idb_type); + dp = db_diradd(dbip, bu_vls_addr(&name), RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (genptr_t)&intern.idb_type); ret = rt_db_put_internal(dp, dbip, &intern, &rt_uniresource); if (ret) - bu_log("ERROR: failure writing [%s] to disk\n", name); + bu_log("ERROR: failure writing [%s] to disk\n", bu_vls_addr(&name)); else - bu_log("%s is written to file.\n", name); + bu_log("%s is written to file.\n", bu_vls_addr(&name)); } // Free the memory. @@ -207,6 +204,9 @@ for (int i = 0; i < curve_st.Count(); i++) delete curve_st[i]; + bu_vls_free(&intersect_name); + bu_vls_free(&name); + return ret; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pho...@us...> - 2013-04-30 14:39:00
|
Revision: 55270 http://sourceforge.net/p/brlcad/code/55270 Author: phoenixyjll Date: 2013-04-30 14:38:31 +0000 (Tue, 30 Apr 2013) Log Message: ----------- Use the CVs as vertexes of the pipe, some clean up, and print information of the intersection curves. Modified Paths: -------------- brlcad/trunk/src/librt/tests/test_ssi.cpp Modified: brlcad/trunk/src/librt/tests/test_ssi.cpp =================================================================== --- brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-04-30 13:58:11 UTC (rev 55269) +++ brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-04-30 14:38:31 UTC (rev 55270) @@ -125,37 +125,47 @@ if (curve.Count() == 0) return 0; - // ON_SSX_EVENT cannot give us enough information on the intersections. - /* - ON_SSX_EVENT ssi_event; - ssi_event.m_curve3d = curve[0]; - ssi_event.m_curveA = curve_uv[0]; - ssi_event.m_curveB = curve_st[0]; - ssi_event.m_type = ON_SSX_EVENT::TYPE::ssx_transverse; - ON_wString wstr; - ON_TextLog textlog(wstr); - ssi_event.Dump(textlog); - char *str = new char [wstr.Length() + 1]; - for (int k = 0; k < wstr.Length(); k++) { - str[k] = wstr[k]; - } - str[wstr.Length()] = 0; - bu_log("%s", str); - delete str; */ - bu_vls_init(&intersect_name); if (argc == 7) { - bu_vls_sprintf(&intersect_name, argv[6]); + bu_vls_sprintf(&intersect_name, "%s_", argv[6]); } else { - bu_vls_strcpy(&intersect_name, argv[2]); - bu_vls_strcat(&intersect_name, "_"); - bu_vls_strcat(&intersect_name, argv[3]); - bu_vls_strcat(&intersect_name, "_"); + bu_vls_sprintf(&intersect_name, "%s_%s_", argv[2], argv[3]); } + + // Print the information of an intersection curve, using + // the ON_NurbsCurve::Dump() method. Later, after ON_SSX_EVENT + // is improved, we will use ON_SSX_EVENT::Dump() instead. + bu_log("*** 2D Intersection Curves on Surface A: ***\n"); + for (int i = 0; i < curve_uv.Count(); i++) { + ON_wString wstr; + ON_TextLog textlog(wstr); + curve_uv[i]->Dump(textlog); + ON_String str = ON_String(wstr); + char *c_str = str.Array(); + bu_log("Intersection curve %d:\n %s", i + 1, c_str); + } - bu_vls_init(&name); + bu_log("*** 2D Intersection Curves on Surface B: ***\n"); + for (int i = 0; i < curve_uv.Count(); i++) { + ON_wString wstr; + ON_TextLog textlog(wstr); + curve_st[i]->Dump(textlog); + ON_String str = ON_String(wstr); + char *c_str = str.Array(); + bu_log("Intersection curve %d:\n %s", i + 1, c_str); + } + + bu_log("*** 3D Intersection Curves: ***\n"); for (int i = 0; i < curve.Count(); i++) { - // Do sampling, and use a pipe primitive to represent a curve + ON_wString wstr; + ON_TextLog textlog(wstr); + curve[i]->Dump(textlog); + ON_String str = ON_String(wstr); + char *c_str = str.Array(); + bu_log("Intersection curve %d:\n %s", i + 1, c_str); + + // Use a pipe primitive to represent a curve. + // The CVs of the curve are used as vertexes of the pipe. struct rt_db_internal intern; RT_DB_INTERNAL_INIT(&intern); intern.idb_major_type = DB5_MAJORTYPE_BRLCAD; @@ -168,23 +178,23 @@ pi->pipe_count = curve.Count(); BU_LIST_INIT(&(pi->pipe_segs_head)); struct wdb_pipept *ps; - ON_Interval dom = curve[i]->Domain(); - // use different plotres for different accuracy (resolution) - int plotres = 100; - for (int j = 0; j <= plotres; j++) { + + fastf_t od = curve[i]->BoundingBox().Diagonal().Length() * 0.05; + for (int j = 0; j < curve[i]->CVCount(); j++) { BU_ALLOC(ps, struct wdb_pipept); ps->l.magic = WDB_PIPESEG_MAGIC; ps->l.back = NULL; ps->l.forw = NULL; - ON_3dPoint p = curve[i]->PointAt(dom.ParameterAt((double) j - / (double) plotres)); + ON_3dPoint p; + curve[i]->GetCV(j, p); VSET(ps->pp_coord, p.x, p.y, p.z); - ps->pp_id = 50; - ps->pp_od = 100; + ps->pp_id = 0.0; + ps->pp_od = od; ps->pp_bendradius = 0; BU_LIST_INSERT(&pi->pipe_segs_head, &ps->l); } + bu_vls_init(&name); bu_vls_sprintf(&name, "%s%d", bu_vls_addr(&intersect_name), i); struct directory *dp; @@ -194,6 +204,7 @@ bu_log("ERROR: failure writing [%s] to disk\n", bu_vls_addr(&name)); else bu_log("%s is written to file.\n", bu_vls_addr(&name)); + bu_vls_free(&name); } // Free the memory. @@ -205,7 +216,6 @@ delete curve_st[i]; bu_vls_free(&intersect_name); - bu_vls_free(&name); return ret; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pho...@us...> - 2013-05-01 14:57:35
|
Revision: 55275 http://sourceforge.net/p/brlcad/code/55275 Author: phoenixyjll Date: 2013-05-01 14:57:31 +0000 (Wed, 01 May 2013) Log Message: ----------- Use the sketch primitive to represent 2D intersection curves. Modified Paths: -------------- brlcad/trunk/src/librt/tests/test_ssi.cpp Modified: brlcad/trunk/src/librt/tests/test_ssi.cpp =================================================================== --- brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-05-01 04:08:05 UTC (rev 55274) +++ brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-05-01 14:57:31 UTC (rev 55275) @@ -146,7 +146,7 @@ } bu_log("*** 2D Intersection Curves on Surface B: ***\n"); - for (int i = 0; i < curve_uv.Count(); i++) { + for (int i = 0; i < curve_st.Count(); i++) { ON_wString wstr; ON_TextLog textlog(wstr); curve_st[i]->Dump(textlog); @@ -155,6 +155,62 @@ bu_log("Intersection curve %d:\n %s", i + 1, c_str); } + for (int i = 0; i < curve_uv.Count() + curve_st.Count(); i++) { + ON_NurbsCurve *curve2d = i < curve_uv.Count() ? curve_uv[i] : + curve_st[i - curve_uv.Count()]; + // Use a sketch primitive to represent a 2D curve (polyline curve). + // The CVs of the curve are used as vertexes of the sketch. + struct rt_db_internal intern; + struct rt_sketch_internal *sketch; + int vert_count = curve2d->CVCount(); + RT_DB_INTERNAL_INIT(&intern); + intern.idb_major_type = DB5_MAJORTYPE_BRLCAD; + intern.idb_type = ID_SKETCH; + intern.idb_meth = &rt_functab[ID_SKETCH]; + BU_ALLOC(intern.idb_ptr, struct rt_sketch_internal); + sketch = (struct rt_sketch_internal *)intern.idb_ptr; + sketch->magic = RT_SKETCH_INTERNAL_MAGIC; + VSET(sketch->V, 0.0, 0.0, 0.0); + VSET(sketch->u_vec, 1.0, 0.0, 0.0); + VSET(sketch->v_vec, 0.0, 1.0, 0.0); + sketch->vert_count = vert_count; + sketch->curve.count = vert_count - 1; + + // The memory must be dynamic allocated since they are bu_free'd + // in rt_db_free_internal() + sketch->verts = (point2d_t *)bu_calloc(vert_count, sizeof(point2d_t), "sketch->verts"); + sketch->curve.reverse = (int *)bu_calloc(vert_count - 1, sizeof(int), "sketch->crv->reverse"); + sketch->curve.segment = (genptr_t *)bu_calloc(vert_count - 1, sizeof(genptr_t), "sketch->crv->segments"); + + for (int j = 0; j < vert_count; j++) { + ON_3dPoint CV3d; + curve2d->GetCV(j, CV3d); + sketch->verts[j][0] = CV3d.x; + sketch->verts[j][1] = CV3d.y; + if (j != 0) { + struct line_seg *lsg; + BU_ALLOC(lsg, struct line_seg); + lsg->magic = CURVE_LSEG_MAGIC; + lsg->start = j - 1; + lsg->end = j; + sketch->curve.segment[j - 1] = (genptr_t)lsg; + sketch->curve.reverse[j - 1] = 0; + } + } + + bu_vls_init(&name); + bu_vls_sprintf(&name, "%s2d_%d", bu_vls_addr(&intersect_name), i); + + struct directory *dp; + dp = db_diradd(dbip, bu_vls_addr(&name), RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (genptr_t)&intern.idb_type); + ret = rt_db_put_internal(dp, dbip, &intern, &rt_uniresource); + if (ret) + bu_log("ERROR: failure writing [%s] to disk\n", dp->d_namep); + else + bu_log("%s is written to file.\n", dp->d_namep); + bu_vls_free(&name); + } + bu_log("*** 3D Intersection Curves: ***\n"); for (int i = 0; i < curve.Count(); i++) { ON_wString wstr; @@ -195,15 +251,15 @@ } bu_vls_init(&name); - bu_vls_sprintf(&name, "%s%d", bu_vls_addr(&intersect_name), i); + bu_vls_sprintf(&name, "%s3d_%d", bu_vls_addr(&intersect_name), i); struct directory *dp; dp = db_diradd(dbip, bu_vls_addr(&name), RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (genptr_t)&intern.idb_type); ret = rt_db_put_internal(dp, dbip, &intern, &rt_uniresource); if (ret) - bu_log("ERROR: failure writing [%s] to disk\n", bu_vls_addr(&name)); + bu_log("ERROR: failure writing [%s] to disk\n", dp->d_namep); else - bu_log("%s is written to file.\n", bu_vls_addr(&name)); + bu_log("%s is written to file.\n", dp->d_namep); bu_vls_free(&name); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2013-05-02 15:47:53
|
Revision: 55292 http://sourceforge.net/p/brlcad/code/55292 Author: carlmoore Date: 2013-05-02 15:47:49 +0000 (Thu, 02 May 2013) Log Message: ----------- remove trailing blanks/tabs Modified Paths: -------------- brlcad/trunk/src/librt/tests/test_ssi.cpp Modified: brlcad/trunk/src/librt/tests/test_ssi.cpp =================================================================== --- brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-05-02 14:56:00 UTC (rev 55291) +++ brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-05-02 15:47:49 UTC (rev 55292) @@ -131,7 +131,7 @@ } else { bu_vls_sprintf(&intersect_name, "%s_%s_", argv[2], argv[3]); } - + // Print the information of an intersection curve, using // the ON_NurbsCurve::Dump() method. Later, after ON_SSX_EVENT // is improved, we will use ON_SSX_EVENT::Dump() instead. @@ -234,7 +234,7 @@ pi->pipe_count = curve.Count(); BU_LIST_INIT(&(pi->pipe_segs_head)); struct wdb_pipept *ps; - + fastf_t od = curve[i]->BoundingBox().Diagonal().Length() * 0.05; for (int j = 0; j < curve[i]->CVCount(); j++) { BU_ALLOC(ps, struct wdb_pipept); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pho...@us...> - 2013-07-24 10:04:48
|
Revision: 56198 http://sourceforge.net/p/brlcad/code/56198 Author: phoenixyjll Date: 2013-07-24 10:04:43 +0000 (Wed, 24 Jul 2013) Log Message: ----------- common.h is included twice. Modified Paths: -------------- brlcad/trunk/src/librt/tests/test_ssi.cpp Modified: brlcad/trunk/src/librt/tests/test_ssi.cpp =================================================================== --- brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-07-24 06:04:24 UTC (rev 56197) +++ brlcad/trunk/src/librt/tests/test_ssi.cpp 2013-07-24 10:04:43 UTC (rev 56198) @@ -23,7 +23,6 @@ #include <stdlib.h> #include <iostream> #include <assert.h> -#include "common.h" #include "vmath.h" #include "brep.h" #include "raytrace.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |