use crate::StrError;
pub(crate) const TRITET_SUCCESS: i32 = 0;
pub(crate) const TRITET_ERROR_NULL_DATA: i32 = 10;
pub(crate) const TRITET_ERROR_STRING_CONCAT: i32 = 20;
pub(crate) const TRITET_ERROR_NULL_POINT_LIST: i32 = 100;
pub(crate) const TRITET_ERROR_NULL_SEGMENT_LIST: i32 = 200;
pub(crate) const TRITET_ERROR_NULL_FACET_LIST: i32 = 300;
pub(crate) const TRITET_ERROR_NULL_FACET_POLYGON_LIST: i32 = 400;
pub(crate) const TRITET_ERROR_NULL_REGION_LIST: i32 = 500;
pub(crate) const TRITET_ERROR_NULL_HOLE_LIST: i32 = 600;
pub(crate) const TRITET_ERROR_INVALID_POINT_INDEX: i32 = 1000;
pub(crate) const TRITET_ERROR_INVALID_SEGMENT_INDEX: i32 = 2000;
pub(crate) const TRITET_ERROR_INVALID_SEGMENT_POINT_ID: i32 = 3000;
pub(crate) const TRITET_ERROR_INVALID_FACET_INDEX: i32 = 4000;
pub(crate) const TRITET_ERROR_INVALID_FACET_NUM_POLYGON: i32 = 5000;
pub(crate) const TRITET_ERROR_INVALID_FACET_POINT_INDEX: i32 = 6000;
pub(crate) const TRITET_ERROR_INVALID_FACET_POINT_ID: i32 = 7000;
pub(crate) const TRITET_ERROR_INVALID_REGION_INDEX: i32 = 8000;
pub(crate) const TRITET_ERROR_INVALID_HOLE_INDEX: i32 = 9000;
pub(crate) const TRITET_ERROR_TETGEN_FAIL: i32 = 10000;
pub(crate) fn handle_status(status: i32) -> Result<(), StrError> {
if status == TRITET_SUCCESS {
return Ok(());
}
if status == TRITET_ERROR_NULL_DATA {
return Err("INTERNAL ERROR: found NULL data");
}
if status == TRITET_ERROR_STRING_CONCAT {
return Err("INTERNAL ERROR: cannot write string with commands for TetGen");
}
if status == TRITET_ERROR_NULL_POINT_LIST {
return Err("INTERNAL ERROR: found NULL point list");
}
if status == TRITET_ERROR_NULL_SEGMENT_LIST {
return Err("INTERNAL ERROR: found NULL segment list");
}
if status == TRITET_ERROR_NULL_FACET_LIST {
return Err("INTERNAL ERROR: found NULL facet list");
}
if status == TRITET_ERROR_NULL_FACET_POLYGON_LIST {
return Err("INTERNAL ERROR: found NULL facet polygon list");
}
if status == TRITET_ERROR_NULL_REGION_LIST {
return Err("INTERNAL ERROR: found NULL region list");
}
if status == TRITET_ERROR_NULL_HOLE_LIST {
return Err("INTERNAL ERROR: found NULL hole list");
}
if status == TRITET_ERROR_INVALID_POINT_INDEX {
return Err("index of point is out of bounds");
}
if status == TRITET_ERROR_INVALID_SEGMENT_INDEX {
return Err("index of segment is out of bounds");
}
if status == TRITET_ERROR_INVALID_SEGMENT_POINT_ID {
return Err("id of segment point is out of bounds");
}
if status == TRITET_ERROR_INVALID_FACET_INDEX {
return Err("index of facet is out of bounds");
}
if status == TRITET_ERROR_INVALID_FACET_NUM_POLYGON {
return Err("INTERNAL ERROR: found invalid facet number of polygon");
}
if status == TRITET_ERROR_INVALID_FACET_POINT_INDEX {
return Err("index of facet point is out of bounds");
}
if status == TRITET_ERROR_INVALID_FACET_POINT_ID {
return Err("id of facet point is out of bounds");
}
if status == TRITET_ERROR_INVALID_REGION_INDEX {
return Err("index of region is out of bounds");
}
if status == TRITET_ERROR_INVALID_HOLE_INDEX {
return Err("index of hole is out of bounds");
}
if status == TRITET_ERROR_TETGEN_FAIL {
return Err("TetGen failed: points are probably coplanar");
}
return Err("INTERNAL ERROR: some error occurred");
}
pub(crate) const TRITET_TO_TRIANGLE: [usize; 6] = [0, 1, 2, 5, 3, 4];
pub(crate) const TRITET_TO_TETGEN: [usize; 10] = [0, 1, 2, 3, 6, 7, 9, 5, 8, 4];
pub(crate) const LIGHT_COLORS: [&'static str; 17] = [
"#cbe4f9", "#cdf5f6", "#eff9da", "#f9ebdf", "#f9d8d6", "#d6cdea", "#acddde", "#caf1de", "#e1f8dc", "#fef8dd",
"#ffe7c7", "#f7d8ba", "#d0fffe", "#fffddb", "#e4ffde", "#ffd3fd", "#ffe7d3",
];
pub(crate) const DARK_COLORS: [&'static str; 12] = [
"#2e3d7c", "#282528", "#ba292e", "#e15d3a", "#ffa73c", "#780000", "#540d4d", "#214b14", "#a36032", "#0f4539",
"#2f3b22", "#152d32",
];
pub(crate) const VTK_TRIANGLE: i32 = 5;
pub(crate) const VTK_QUADRATIC_TRIANGLE: i32 = 22;
pub(crate) const VTK_TETRA: i32 = 10;
pub(crate) const VTK_QUADRATIC_TETRA: i32 = 24;