void Copy_Segment (const char *old_seg_name, const char *new_seg_name)
 Completely duplicates a segment. More...

Detailed Description

Function Documentation

◆ Copy_Segment()

HC_KEY Copy_Segment ( const char *  old_seg_name,
const char *  new_seg_name 

Completely duplicates a segment.

old_seg_name- Segment(s) to be Copied. Can contain wildcards.
new_seg_name- New name to use. Can contain a "/*" on the end, but cannot contain any other wildcards (see below).
The key to the new duplicate segment.


Copy_Segment() duplicates the contents of old_seg_name and inserts them into new_seg_name. "Contents" consists of all the attributes, styles, includes, geometry, and subsegments, and all the attributes, styles, includes and geometry in all the subsegments. When Copy_Segment() finishes, the segment tree starting at new_seg_name will be an exact copy of old_seg_name. It is not necessary to use a "..." to get the whole tree copied, because this is HOOPS normal mode.

If you just want the same piece of a picture to appear in two different contexts, you can redraw that piece in the "?Include Library..." segment tree. Then request an Include_Segment() in each place where the piece is needed. Doing it this way helps the system compute displays efficiently and helps you stay organized. (If you find yourself making a copy just because you need to override an attribute setting of the original, consider making a utility segment that has the original's contents, minus the offending attribute(s), and have other parts of the application refer to that utility segment.)

If the new_seg_name specification contains a wildcard on the end, that wildcard gets matched with the lowest-level name on the incoming segment. For example, a copy from "A/B/C" to "D/*" creates a segment named "D/C". More commonly, you would use a wildcard on the new_seg_name segment name only if you were using wildcards on the input name too, such as copying from "A/B/*" to "D/*".


If new_seg_name does not exist, it is created. If new_seg_name existed but was not empty, Copy_Segment() will complain.

If new_seg_name is a blank or null string, a new "nameless" segment (see Open_Segment() ) is created.

If more than one output segment is created, and you used KCopy_Segment() , you will get an error when the system tries to return the key.


See also
Include_Segment, Rename_Segment, Open_Segment, Close_Segment, Delete_Segment.