how to filter objects by modifier?

Hi!

I want to "filter" a radiance scene by modifier. E.g. I want to remove all
objects with modifier "invisible_mod". I know that I could simply alias them
to void, however, I don't want to keep geometry in my rather large scenes
when not necessary.

I found that some translators (e.g. obj2rad) have such features during
import, however, I can't use the tool-for-everything mgfilt here and don't
know any other way to filter radiance scenes which have already been
imported.

The background for this question: I have windows objects as instances in my
scene. These are complete models of the windows including frames and glass
panes. I want to use mkillum to have the glass as light source, but as
illums cannot been instanced, I have to treat the glass panes different. My
idea was to filter the glasspanes out, the create the octree for the
instance (replamrks -i), than filter out everything except the glass pane
and place theses "objects" (in fact all the glass panes of one window) with
replmark -x. I know that I could simply have to rad-files per object for
that (one with the glass panes and one with the frame), but I have to stay
close to my CAD-files here, as the whole project consists of quite a lot of
objects.

So is there any known way to filter radiance scenes? Or should I just forget
about this and use replmarks -x for all the windows? Will add some MB to my
scene...

TIA, CU and happy easter,

Lars.

Hi Lars,

you might have a look at some basic UNIX text-stream processing tools, like e.g. 'sed'. This allows to perform a lot of manipulations on any text file.

-cb

Hi Carsten,

yes, I guess that is the most promising way to go. I hesitated because the
fact that the name of the modifier can appear in different contexts (not
only to modify geometry, but also e.g. to modify a material type etc) made
me prefer some tool built on top of a real radiance scene parser. However,
it should be possible to achieve that with sed, too (maybe even grep can do
it).

I was always afraid of sed so far, so it's time to start that now :wink:

Thanks, CU Lars.

Hi again,

so there is a real problem now... I had forgotten that there are not only
4liners as objects in radiance. So e.g. a polygon may be described on 5 or
more lines, depending on the number of points, and that's where I have to
write some kind of a parser to filter the complete objects :frowning: At least I
will have to get the first integer in a line, read n1 objects, than the
first integer on the line following the last objects, again read n2
objects, and so on... a pretty difficult task for someone new to sed and
awk... Will have a look at O'Reilly's "Awk and Sed" book now.

CU Lars.

Hi!

I have written a little bash script that will filter radiance scene files by modifier. It has two modes, -i and -e (similar to rpict). -i <modifier> will write ONLY geometry modified by <modifier> to STDOUT, -e <modifier> will output everything but geometry modified by <modifier>. This is a rather simple script, using sed and awk, and as I am not very good in using the text utilities, there is certainly a lot of overhead. However, it is useable, and can be found here:

http://130.83.168.34/lars/rad/rad_filter.sh.gz

CU Lars.

Here's my contribution to the Radiance community. It looked like you guys needed the help of a good Perl programmer :slight_smile:

It's not heavily tested, I only threw it together in a few hours. I've put in little comments to help anyone trying to follow the code. I know that Perl has a bad reputation, but I try to make my perl code neat and consistent.
*sigh* back in the day I was actually paid to code perl...

I added the feature of "following" modifiers with the -s option. When this option is specified, non-surface primitives (i.e materials, textures, patterns, or mixtures) will be matched by their modifier and their id will be added to the list of modifiers that are being matched. Make sense? This will allow the user to specify the name of one modifier that is then "modified" by other materials, etc.

Anyway, let me know how it goes. I've probably screwed up somewhere.
bye

rad_filter.pl.gz (1.27 KB)

After a problem report from Lars, here's an updated version of the filter script. It wasn't handling the rare alias declaration. I've tested it against a few scene files in the standard distribution, both virtual/illumoff.rad and cabin/lvfurn.rad. The second one put a spanner in the works because it contained this:

alberta_image alias alberta_photo
         photo_paper

So there's extra logic to handle having the reference on the following line. How lenient is the Radiance parser with respect to newlines? Can regular primitives also contain newlines in odd places, or is it just with aliases?

e.g
white sphere
  ball <== is this accepted as well??
0
4 0 0 0
  1

I really hope that isn't allowed. Otherwise my perl code will become really ugly... :frowning:

bye

rad_filter.pl.gz (1.36 KB)