/
nmg.c
140 lines (125 loc) · 4.96 KB
/
nmg.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* N M G . C
* BRL-CAD
*
* Copyright (c) 2015 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this file; see the file named COPYING for more
* information.
*/
/** @file libged/nmg.c
*
* The nmg command.
*
*/
#include "common.h"
#include <stdlib.h>
#include <string.h>
#include "raytrace.h"
#include "rt/geom.h"
#include "wdb.h"
#include "./ged_private.h"
extern int ged_nmg_mm(struct ged *gedp, int argc, const char *argv[]);
extern int ged_nmg_cmface(struct ged *gedp, int argc, const char *argv[]);
extern int ged_nmg_kill_v(struct ged *gedp, int argc, const char *argv[]);
extern int ged_nmg_kill_f(struct ged *gedp, int argc, const char *argv[]);
extern int ged_nmg_move_v(struct ged *gedp, int argc, const char *argv[]);
extern int ged_nmg_make_v(struct ged *gedp, int argc, const char *argv[]);
extern int ged_nmg_make_f(struct ged *gedp, int argc, const char *argv[]);
int
ged_nmg(struct ged *gedp, int argc, const char *argv[])
{
static const char *usage = "nmg object subcommand [V|F|R|S] [suffix]";
const char *subcmd = argv[2];
GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
/* must be wanting help */
if (argc < 3) {
bu_vls_printf(gedp->ged_result_str, "Usage: %s\n\t%s\n", argv[0], usage);
bu_vls_printf(gedp->ged_result_str, "commands:\n");
bu_vls_printf(gedp->ged_result_str, "\tmm - creates a new "
"NMG model structure and fills the appropriate fields. The result "
"is an empty model.\n");
bu_vls_printf(gedp->ged_result_str, "\tcmface - creates a "
"manifold face in the first encountered shell of the NMG "
"object. Vertices are listed as the suffix and define the "
"winding-order of the face.\n");
bu_vls_printf(gedp->ged_result_str, "\tkill V - removes the "
"vertexuse and vertex geometry of the selected vertex (via its "
"coordinates) and higher-order topology containing the vertex. "
"When specifying vertex to be removed, user generally will display "
"vertex coordinates in object via the MGED command labelvert.\n");
bu_vls_printf(gedp->ged_result_str, "\tkill F - removes the "
"faceuse and face geometry of the selected face (via its "
"index). When specifying the face to be removed, user generally "
"will display face indices in object via the MGED command "
"labelface.\n");
bu_vls_printf(gedp->ged_result_str, "\tmove V - moves an existing "
"vertex specified by the coordinates x_initial y_initial "
"z_initial to the position with coordinates x_final y_final "
"z_final.\n");
bu_vls_printf(gedp->ged_result_str, "\tmake V - creates a new "
"vertex in the nmg object.\n");
bu_vls_printf(gedp->ged_result_str, "\tmake F - creates a new "
"face(s) in the nmg object.\n");
return GED_HELP;
}
if (argc < 3) {
bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
return GED_ERROR;
}
/* advance CLI arguments for subcommands */
--argc;
++argv;
if( BU_STR_EQUAL( "mm", subcmd ) ) {
ged_nmg_mm(gedp, argc, argv);
}
else if( BU_STR_EQUAL( "cmface", subcmd ) ) {
ged_nmg_cmface(gedp, argc, argv);
}
else if( BU_STR_EQUAL( "kill", subcmd ) ) {
const char* opt = argv[2];
if ( BU_STR_EQUAL( "V", opt ) ) {
ged_nmg_kill_v(gedp, argc, argv);
} else if ( BU_STR_EQUAL( "F", opt ) ) {
ged_nmg_kill_f(gedp, argc, argv);
}
}
else if( BU_STR_EQUAL( "move", subcmd ) ) {
const char* opt = argv[2];
if ( BU_STR_EQUAL( "V", opt ) ) {
ged_nmg_move_v(gedp, argc, argv);
}
}
else if( BU_STR_EQUAL( "make", subcmd ) ) {
const char* opt = argv[2];
if ( BU_STR_EQUAL( "V", opt ) ) {
ged_nmg_make_v(gedp, argc, argv);
} else if ( BU_STR_EQUAL( "F", opt ) ) {
ged_nmg_make_f(gedp, argc, argv);
}
}
else {
bu_vls_printf(gedp->ged_result_str, "%s is not a subcommand.", subcmd );
return GED_ERROR;
}
return GED_OK;
}
/*
* Local Variables:
* tab-width: 8
* mode: C
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/