Modifies a topology element.
int
tpm_editmodelem(
ade_id tpm_id,
ade_id elem_id,
struct resbuf *new_val);
Returns RTNORM or an error code.
| tpm_id | The topology ID |
| elem_id | The ID of the desired element. |
| new_val | A list consisting of a code for the property to modify and a new value for the property. See Properties and Values below. |
The following code constructs a resbuf for a new_val point argument:
ads_point newpoint;
newpoint[X] = 1.0;
newpoint[Y] = 1.0;
newpoint[Z] = 0.0;
struct resbuf* new_val = ads_buildlist (
RTLB,
RTSHORT, 10,
RTPOINT, newpoint,
RTLE,
0);
Note The dotted pair is not supported for point data.
The following examples of build resbuf data structures for the new_val argument.
// For a point value, given a point, p rb = acutBuildList( RTLB, RTSHORT, 10, RTPOINT, p, RTLE, 0); // For an integer value rb = acutBuildList( RTLB, RTSHORT, code, RTSHORT, value, RTDOTE, 0); // For a real value rb = acutBuildList( RTLB, RTSHORT, code, RTREAL, value, RTDOTE, 0);
You must release the resbuf.
| (10 . point) | New coordinates of node or centroid (RTPOINT) |
| (40 . f_res) | Resistance of node (RTREAL), or forward resistance of link |
| (41 . r_res) | Reverse resistance of link (RTREAL) |
| (70 . dir) | Link direction (RTSHORT): -1 Reverse 0 Bidirectional 1 Forward |
The following example modifies the direction variable on a link element in the "MyNetworkTopo" topology. The topology is first loaded into memory using tpm_acload(), then opened for write using tpm_acopen(). A resbuf is constructed containing the property/value pair associated with link direction. After calling tpm_editmodelem() with all required parameters, the returnCode is evaluated and an appropriate message is displayed. The resbuf is then released as required.
char* pszTopoName = "NetTopo";
int topoWriteAccess = 1;
int returnCode = tpm_acload(pszTopoName, NULL);
ade_id topoId = tpm_acopen(pszTopoName, topoWriteAccess);
int elementType = 2;
long elementIndex = 1;
ade_id elementID = tpm_elemid(topoId, elementType, elementIndex);
struct resbuf* pModElementRb = acutBuildList(
RTLB,
RTSHORT, 70,
RTSHORT, -1,
RTDOTE,
0);
returnCode = tpm_editmodelem(topoId, elementID, pModElementRb);
if (RTNORM == returnCode){
acutPrintf(
"\nThe element modification was successful.");
}
else {
acutPrintf(
"\nThe element modification was not successful.");
}
acutRelRb(pModElementRb);
tpm_acclose(topoId);
tpm_acunload(pszTopoName);


