OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm_edit_impl.cpp File Reference

C API implementation — object deletion and type conversion. More...

#include "openswmm_api_common.hpp"
#include "TypeHelpers.hpp"
#include "../edit/ObjectDeleter.hpp"
#include "../edit/TypeConverter.hpp"
#include "../../../include/openswmm/engine/openswmm_edit.h"
#include <cstring>
#include <cstdlib>
Include dependency graph for openswmm_edit_impl.cpp:

Functions

SWMM_ENGINE_API void swmm_impact_report_free (SWMM_ImpactReport *report)
 Release heap memory owned by an impact report.
 
SWMM_ENGINE_API void swmm_conversion_result_free (SWMM_ConversionResult *result)
 Release heap memory owned by a conversion result.
 
SWMM_ENGINE_API int swmm_node_analyze_impact (SWMM_Engine engine, int idx, SWMM_ImpactReport *report_out)
 Analyse which objects reference a given node, without deleting it.
 
SWMM_ENGINE_API int swmm_link_analyze_impact (SWMM_Engine engine, int idx, SWMM_ImpactReport *report_out)
 Analyse which objects reference a given node, without deleting it.
 
SWMM_ENGINE_API int swmm_subcatch_analyze_impact (SWMM_Engine engine, int idx, SWMM_ImpactReport *report_out)
 Analyse which objects reference a given node, without deleting it.
 
SWMM_ENGINE_API int swmm_gage_analyze_impact (SWMM_Engine engine, int idx, SWMM_ImpactReport *report_out)
 Analyse which objects reference a given node, without deleting it.
 
SWMM_ENGINE_API int swmm_table_analyze_impact (SWMM_Engine engine, int idx, SWMM_ImpactReport *report_out)
 Analyse which objects reference a given node, without deleting it.
 
SWMM_ENGINE_API int swmm_transect_analyze_impact (SWMM_Engine engine, int idx, SWMM_ImpactReport *report_out)
 Analyse which objects reference a given node, without deleting it.
 
SWMM_ENGINE_API int swmm_node_delete (SWMM_Engine engine, int idx, SWMM_ImpactReport *cascade_out)
 Delete a node and cascade-delete or nullify all referencing objects.
 
SWMM_ENGINE_API int swmm_link_delete (SWMM_Engine engine, int idx, SWMM_ImpactReport *cascade_out)
 Delete a link and cascade-delete or nullify all referencing objects.
 
SWMM_ENGINE_API int swmm_subcatch_delete (SWMM_Engine engine, int idx, SWMM_ImpactReport *cascade_out)
 Delete a subcatchment and nullify all referencing objects.
 
SWMM_ENGINE_API int swmm_gage_delete (SWMM_Engine engine, int idx, SWMM_ImpactReport *cascade_out)
 Delete a rain gage and nullify subcatchment gage references.
 
SWMM_ENGINE_API int swmm_table_delete (SWMM_Engine engine, int idx, SWMM_ImpactReport *cascade_out)
 Delete a time series or curve and nullify all referencing objects.
 
SWMM_ENGINE_API int swmm_transect_delete (SWMM_Engine engine, int idx, SWMM_ImpactReport *cascade_out)
 Delete a transect and nullify link xsect_curve references.
 
SWMM_ENGINE_API int swmm_node_convert (SWMM_Engine engine, int idx, int new_type, SWMM_ConversionResult *result_out)
 Convert a node to a different type in-place.
 
SWMM_ENGINE_API int swmm_link_convert (SWMM_Engine engine, int idx, int new_type, SWMM_ConversionResult *result_out)
 Convert a link to a different type in-place.
 

Detailed Description

C API implementation — object deletion and type conversion.

See also
include/openswmm/engine/openswmm_edit.h
Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n MIT License

Function Documentation

◆ swmm_conversion_result_free()

SWMM_ENGINE_API void swmm_conversion_result_free ( SWMM_ConversionResult result)

Release heap memory owned by a conversion result.

Does not free the struct itself. Safe to call on a zero-initialised struct.

◆ swmm_gage_analyze_impact()

SWMM_ENGINE_API int swmm_gage_analyze_impact ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport report_out 
)

Analyse which objects reference a given node, without deleting it.

Parameters
engineEngine handle.
idxZero-based node index.
report_outReceives the impact report (may be NULL if not needed).
Returns
SWMM_OK, SWMM_ERR_BADHANDLE, or SWMM_ERR_BADINDEX.
Here is the call graph for this function:

◆ swmm_gage_delete()

SWMM_ENGINE_API int swmm_gage_delete ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport cascade_out 
)

Delete a rain gage and nullify subcatchment gage references.

Here is the call graph for this function:

◆ swmm_impact_report_free()

SWMM_ENGINE_API void swmm_impact_report_free ( SWMM_ImpactReport report)

Release heap memory owned by an impact report.

Does not free the struct itself (typically stack-allocated by the caller). Safe to call on a zero-initialised struct.

◆ swmm_link_analyze_impact()

SWMM_ENGINE_API int swmm_link_analyze_impact ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport report_out 
)

Analyse which objects reference a given node, without deleting it.

Parameters
engineEngine handle.
idxZero-based node index.
report_outReceives the impact report (may be NULL if not needed).
Returns
SWMM_OK, SWMM_ERR_BADHANDLE, or SWMM_ERR_BADINDEX.
Here is the call graph for this function:

◆ swmm_link_convert()

SWMM_ENGINE_API int swmm_link_convert ( SWMM_Engine  engine,
int  idx,
int  new_type,
SWMM_ConversionResult result_out 
)

Convert a link to a different type in-place.

Common properties (node1, node2, offset1, offset2, q0, q_limit, setting, comments) are preserved. Type-specific fields are cleared and new-type defaults applied.

Parameters
engineEngine handle.
idxZero-based link index.
new_typeTarget SWMM_LinkType value.
result_outIf non-NULL, receives the conversion result.
Returns
SWMM_OK on success, SWMM_ERR_BADPARAM if new_type equals current type, SWMM_ERR_LIFECYCLE, SWMM_ERR_BADHANDLE, SWMM_ERR_BADINDEX.
Here is the call graph for this function:

◆ swmm_link_delete()

SWMM_ENGINE_API int swmm_link_delete ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport cascade_out 
)

Delete a link and cascade-delete or nullify all referencing objects.

Divider node divider_link fields that reference this link are nullified. Inlet usage entries whose link_index equals idx are deleted.

Here is the call graph for this function:

◆ swmm_node_analyze_impact()

SWMM_ENGINE_API int swmm_node_analyze_impact ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport report_out 
)

Analyse which objects reference a given node, without deleting it.

Parameters
engineEngine handle.
idxZero-based node index.
report_outReceives the impact report (may be NULL if not needed).
Returns
SWMM_OK, SWMM_ERR_BADHANDLE, or SWMM_ERR_BADINDEX.
Here is the call graph for this function:

◆ swmm_node_convert()

SWMM_ENGINE_API int swmm_node_convert ( SWMM_Engine  engine,
int  idx,
int  new_type,
SWMM_ConversionResult result_out 
)

Convert a node to a different type in-place.

Common properties (invert_elev, full_depth, init_depth, sur_depth, ponded_area, coordinates) are preserved. Type-specific fields for the old type are cleared and type-specific defaults for the new type are applied. Topology warnings are generated but conversion still proceeds.

Parameters
engineEngine handle.
idxZero-based node index.
new_typeTarget SWMM_NodeType value.
result_outIf non-NULL, receives the conversion result. Caller must free with swmm_conversion_result_free.
Returns
SWMM_OK on success, SWMM_ERR_LIFECYCLE if not BUILDING/OPENED, SWMM_ERR_BADPARAM if new_type is invalid or equals current type, SWMM_ERR_BADHANDLE, or SWMM_ERR_BADINDEX.
Here is the call graph for this function:

◆ swmm_node_delete()

SWMM_ENGINE_API int swmm_node_delete ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport cascade_out 
)

Delete a node and cascade-delete or nullify all referencing objects.

Links that reference the node as node1 or node2 are deleted. Subcatchment outlet_node and inlet_usage node_index references are nullified (set to -1). All remaining integer cross-references whose value is greater than idx are decremented by 1.

Parameters
engineEngine handle.
idxZero-based node index.
cascade_outIf non-NULL, receives the cascade report describing what was deleted or nullified. Caller must free with swmm_impact_report_free.
Returns
SWMM_OK on success, SWMM_ERR_LIFECYCLE if not BUILDING/OPENED, SWMM_ERR_BADHANDLE, or SWMM_ERR_BADINDEX.
Here is the call graph for this function:

◆ swmm_subcatch_analyze_impact()

SWMM_ENGINE_API int swmm_subcatch_analyze_impact ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport report_out 
)

Analyse which objects reference a given node, without deleting it.

Parameters
engineEngine handle.
idxZero-based node index.
report_outReceives the impact report (may be NULL if not needed).
Returns
SWMM_OK, SWMM_ERR_BADHANDLE, or SWMM_ERR_BADINDEX.
Here is the call graph for this function:

◆ swmm_subcatch_delete()

SWMM_ENGINE_API int swmm_subcatch_delete ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport cascade_out 
)

Delete a subcatchment and nullify all referencing objects.

Other subcatchments' outlet_subcatch fields and outfall nodes' outfall_route_to fields that reference this subcatchment are nullified.

Here is the call graph for this function:

◆ swmm_table_analyze_impact()

SWMM_ENGINE_API int swmm_table_analyze_impact ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport report_out 
)

Analyse which objects reference a given node, without deleting it.

Parameters
engineEngine handle.
idxZero-based node index.
report_outReceives the impact report (may be NULL if not needed).
Returns
SWMM_OK, SWMM_ERR_BADHANDLE, or SWMM_ERR_BADINDEX.
Here is the call graph for this function:

◆ swmm_table_delete()

SWMM_ENGINE_API int swmm_table_delete ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport cascade_out 
)

Delete a time series or curve and nullify all referencing objects.

Affected references: gage ts_index, node storage_curve / outfall_param (TIDAL/TIMESERIES) / divider_curve, link pump_curve / xsect_curve.

Here is the call graph for this function:

◆ swmm_transect_analyze_impact()

SWMM_ENGINE_API int swmm_transect_analyze_impact ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport report_out 
)

Analyse which objects reference a given node, without deleting it.

Parameters
engineEngine handle.
idxZero-based node index.
report_outReceives the impact report (may be NULL if not needed).
Returns
SWMM_OK, SWMM_ERR_BADHANDLE, or SWMM_ERR_BADINDEX.
Here is the call graph for this function:

◆ swmm_transect_delete()

SWMM_ENGINE_API int swmm_transect_delete ( SWMM_Engine  engine,
int  idx,
SWMM_ImpactReport cascade_out 
)

Delete a transect and nullify link xsect_curve references.

Links with IRREGULAR cross-section shape whose xsect_curve equals idx have their xsect_curve set to -1 and shape reset to CIRCULAR.

Here is the call graph for this function: