Skip to content

Commit ec5f92c

Browse files
committed
Start working on testing code for TOR editing. Once patterns are established, will make it more general.
1 parent 5134214 commit ec5f92c

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

src/librt/tests/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ brlcad_addexec(rt_bv_poly_sketch bv_poly_sketch.c "librt;libbv" TEST)
7878
brlcad_addexec(rt_arb8 arb8_tests.c "librt" TEST)
7979
#brlcad_add_test(NAME rt_arb8_tests COMMAND rt_arb8)
8080

81+
# Tests for primitive editing
82+
add_subdirectory(edit)
8183

8284
set(
8385
distcheck_files

src/librt/tests/edit/CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
brlcad_addexec(rt_edit_test_tor tor.c "librt" TEST)
2+
3+
set(
4+
distcheck_files
5+
CMakeLists.txt
6+
)
7+
8+
cmakefiles(${distcheck_files})
9+
10+
# Local Variables:
11+
# tab-width: 8
12+
# mode: cmake
13+
# indent-tabs-mode: t
14+
# End:
15+
# ex: shiftwidth=2 tabstop=8

src/librt/tests/edit/tor.cpp

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/* T O R . C P P
2+
* BRL-CAD
3+
*
4+
* Copyright (c) 2025 United States Government as represented by
5+
* the U.S. Army Research Laboratory.
6+
*
7+
* This library is free software; you can redistribute it and/or
8+
* modify it under the terms of the GNU Lesser General Public License
9+
* version 2.1 as published by the Free Software Foundation.
10+
*
11+
* This library is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this file; see the file named COPYING for more
18+
* information.
19+
*/
20+
/** @file tor.cpp
21+
*
22+
* Test editing of TOR primitive parameters.
23+
*/
24+
25+
#include "common.h"
26+
27+
#include "vmath.h"
28+
#include "bu/app.h"
29+
#include "bu/avs.h"
30+
#include "bu/env.h"
31+
#include "bu/malloc.h"
32+
#include "bu/process.h"
33+
#include "bu/str.h"
34+
#include "raytrace.h"
35+
36+
int
37+
main(int ac, char *av[])
38+
{
39+
const char *usage = "rt_edit_test_tor file.g testnum";
40+
long test_num = 0;
41+
const char *objname = "tor.s"
42+
bu_setprogname(av[0]);
43+
ac--; av++;
44+
45+
if (ac < 2)
46+
bu_exit(1, "%s", usage);
47+
48+
struct db_i *dbip = db_open(argv[1], DB_OPEN_READWRITE);
49+
if (dbip == DBI_NULL)
50+
bu_exit(1, "ERROR: Unable to read from %s\n", argv[1]);
51+
52+
if (db_dirbuild(dbip) < 0)
53+
bu_exit(1, "ERROR: Unable to read from %s\n", argv[1]);
54+
55+
db_update_nref(dbip, &rt_uniresource);
56+
57+
struct directory *dp = db_lookup(dbip, objname, LOOKUP_QUIET);
58+
if (dp == RT_DIR_NULL)
59+
bu_exit(1, "ERROR: Unable to look up object %s\n", objname);
60+
61+
struct rt_db_internal intern;
62+
rt_db_get_internal(&intern, dp, dbip, NULL, &rt_uniresource);
63+
64+
if (intern.idb_type != ID_TOR)
65+
bu_exit(1, "ERROR: %s - incorrect object type %d\n", objname, intern.idb_type);
66+
67+
68+
// Set up rt_solid_edit container
69+
70+
71+
// Get test number
72+
bu_sscanf(av[1], "%ld", &test_num);
73+
74+
switch (test_num) {
75+
case 1:
76+
break;
77+
case 2:
78+
break;
79+
case 3:
80+
break;
81+
case 4:
82+
break;
83+
default:
84+
bu_exit(1, "ERROR: unknown test number %d\n", test_num);
85+
break;
86+
}
87+
88+
return 0;
89+
}
90+
91+
// Local Variables:
92+
// tab-width: 8
93+
// mode: C++
94+
// c-basic-offset: 4
95+
// indent-tabs-mode: t
96+
// c-file-style: "stroustrup"
97+
// End:
98+
// ex: shiftwidth=4 tabstop=8
99+

0 commit comments

Comments
 (0)