17 #include "eggGroupNode.h"
18 #include "eggPrimitive.h"
19 #include "eggVertex.h"
30 set_program_brief(
"crop geometry in an .egg file");
31 set_program_description
32 (
"egg-crop strips out all parts of an egg file that fall outside of an "
33 "arbitrary bounding volume, specified with a minimum and maximum point "
34 "in world coordinates.");
38 "Specify the minimum point.",
39 &EggCrop::dispatch_double_triple, &_got_min, &_min[0]);
43 "Specify the maximum point.",
44 &EggCrop::dispatch_double_triple, &_got_max, &_max[0]);
59 if (!_got_min || !_got_max) {
60 nout <<
"You must specify both a minimum and a maximum bounds.\n";
74 int num_removed = strip_prims(_data);
75 nout <<
"Removed " << num_removed <<
" primitives.\n";
77 _data->remove_unused_vertices(
true);
94 EggGroupNode::iterator ci;
96 while (ci != group->end()) {
100 if (child->
is_of_type(EggPrimitive::get_class_type())) {
102 EggPrimitive::iterator vi;
103 for (vi = prim->begin(); vi != prim->end() && all_in; ++vi) {
107 all_in = (pos[0] >= _min[0] && pos[0] <= _max[0] &&
108 pos[1] >= _min[1] && pos[1] <= _max[1] &&
109 pos[2] >= _min[2] && pos[2] <= _max[2]);
116 ci = group->erase(ci);
120 if (child->
is_of_type(EggGroupNode::get_class_type())) {
122 num_removed += strip_prims(group_child);
132 int main(
int argc,
char *argv[]) {
A base class for any of a number of kinds of geometry primitives: polygons, point lights...
virtual void parse_command_line(int argc, char **argv)
Dispatches on each of the options on the command line, and passes the remaining parameters to handle_...
A base class for nodes in the hierarchy that are not leaf nodes.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
LVertexd get_pos3() const
Valid if get_num_dimensions() returns 3 or 4.
A program to read an egg file and write an equivalent egg file, possibly performing some minor operat...
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal...
virtual bool post_command_line()
This is called after the command line has been completely processed, and it gives the program a chanc...
void write_egg_file()
Writes out the egg file as the normal result of the program.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
A base class for things that may be directly added into the egg hierarchy.