Skip to content

Commit

Permalink
Merge pull request #185 from rchristie/group_boundary
Browse files Browse the repository at this point in the history
Add graphics boundary mode, enum string conversions
  • Loading branch information
rchristie authored Aug 26, 2021
2 parents 510688f + e962f1c commit aae4748
Show file tree
Hide file tree
Showing 107 changed files with 2,582 additions and 1,241 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Add exception-safe ChangeManager change caching template to C++ API.
Add Materialmodule description json serialisation API.
Add Materialmodule, Fieldmodule getContext API.
Add Context getName API.
Add Graphics BoundaryMode which generalises exterior flag.
Add enum to/from string name APIs. Fix some names to match unique part of enumeration constant.

v3.3.0
Add field parameters interface.
Expand Down
49 changes: 45 additions & 4 deletions src/api/opencmiss/zinc/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,51 @@ Global functions
* Convert a short name into an enum if the name matches any of the members in
* the enum.
*
* @param string string of the short enumerator name
* @return the correct enum type if a match is found.
* @param name Enumeration name string.
* @return Enumeration value or INVALID if not found.
*/
ZINC_API enum cmzn_element_face_type cmzn_element_face_type_enum_from_string(
const char *name);

/**
* Return an allocated short name of the enum type from the provided enum.
* User must call cmzn_deallocate to destroy the successfully returned string.
*
* @param type enum to be converted into string
* @return an allocated string which stored the short name of the enum.
*/
ZINC_API char *cmzn_element_face_type_enum_to_string(
enum cmzn_element_face_type type);

/**
* Convert a short name into an enum if the name matches any of the members in
* the enum.
*
* @param name Enumeration name string.
* @return Enumeration value or INVALID if not found.
*/
ZINC_API enum cmzn_element_point_sampling_mode
cmzn_element_point_sampling_mode_enum_from_string(const char *name);

/**
* Return an allocated short name of the enum type from the provided enum.
* User must call cmzn_deallocate to destroy the successfully returned string.
*
* @param mode enum to be converted into string
* @return an allocated string which stored the short name of the enum.
*/
ZINC_API char *cmzn_element_point_sampling_mode_enum_to_string(
enum cmzn_element_point_sampling_mode mode);

/**
* Convert a short name into an enum if the name matches any of the members in
* the enum.
*
* @param name Enumeration name string.
* @return Enumeration value or INVALID if not found.
*/
ZINC_API enum cmzn_element_shape_type cmzn_element_shape_type_enum_from_string(
const char *string);
const char *name);

/**
* Return an allocated short name of the enum type from the provided enum.
Expand All @@ -53,7 +93,8 @@ ZINC_API enum cmzn_element_shape_type cmzn_element_shape_type_enum_from_string(
* @param type enum to be converted into string
* @return an allocated string which stored the short name of the enum.
*/
ZINC_API char *cmzn_element_shape_type_enum_to_string(enum cmzn_element_shape_type type);
ZINC_API char *cmzn_element_shape_type_enum_to_string(
enum cmzn_element_shape_type type);

/**
* Returns a new handle to the element iterator with reference count incremented.
Expand Down
30 changes: 30 additions & 0 deletions src/api/opencmiss/zinc/element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,36 @@ class Element
return cmzn_element_set_scale_factors(this->id, eft.getId(), valuesCount, valuesIn);
}

static FaceType FaceTypeEnumFromString(const char *name)
{
return static_cast<FaceType>(cmzn_element_face_type_enum_from_string(name));
}

static char *FaceTypeEnumToString(FaceType type)
{
return cmzn_element_face_type_enum_to_string(static_cast<cmzn_element_face_type>(type));
}

static PointSamplingMode PointSamplingModeEnumFromString(const char *name)
{
return static_cast<PointSamplingMode>(cmzn_element_point_sampling_mode_enum_from_string(name));
}

static char *PointSamplingModeEnumToString(PointSamplingMode mode)
{
return cmzn_element_point_sampling_mode_enum_to_string(static_cast<cmzn_element_point_sampling_mode>(mode));
}

static ShapeType ShapeTypeEnumFromString(const char *name)
{
return static_cast<ShapeType>(cmzn_element_shape_type_enum_from_string(name));
}

static char *ShapeTypeEnumToString(ShapeType type)
{
return cmzn_element_shape_type_enum_to_string(static_cast<cmzn_element_shape_type>(type));
}

enum ShapeType getShapeType()
{
return static_cast<ShapeType>(cmzn_element_get_shape_type(id));
Expand Down
8 changes: 4 additions & 4 deletions src/api/opencmiss/zinc/elementbasis.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ Global functions
* Convert a short name into an enum if the name matches any of the members in
* the enum.
*
* @param string string of the short enumerator name
* @return the correct enum type if a match is found.
* @param name Enumeration name string.
* @return Enumeration value or INVALID if not found.
*/
ZINC_API enum cmzn_elementbasis_function_type cmzn_elementbasis_function_type_enum_from_string(
const char *string);
ZINC_API enum cmzn_elementbasis_function_type
cmzn_elementbasis_function_type_enum_from_string(const char *name);

/**
* Return an allocated short name of the enum type from the provided enum.
Expand Down
12 changes: 11 additions & 1 deletion src/api/opencmiss/zinc/elementbasis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,17 @@ class Elementbasis
return cmzn_elementbasis_get_dimension(id);
}

enum FunctionType getFunctionType(int chartComponent)
static FunctionType FunctionTypeEnumFromString(const char *name)
{
return static_cast<FunctionType>(cmzn_elementbasis_function_type_enum_from_string(name));
}

static char *FunctionTypeEnumToString(FunctionType type)
{
return cmzn_elementbasis_function_type_enum_to_string(static_cast<cmzn_elementbasis_function_type>(type));
}

FunctionType getFunctionType(int chartComponent)
{
return static_cast<FunctionType>(cmzn_elementbasis_get_function_type(id, chartComponent));
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/opencmiss/zinc/elementtemplate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ class Elementtemplate
return id;
}

enum Element::ShapeType getElementShapeType()
Element::ShapeType getElementShapeType()
{
return static_cast<Element::ShapeType>(cmzn_elementtemplate_get_element_shape_type(id));
}

int setElementShapeType(enum Element::ShapeType shapeType)
int setElementShapeType(Element::ShapeType shapeType)
{
return cmzn_elementtemplate_set_element_shape_type(id,
static_cast<cmzn_element_shape_type>(shapeType));
Expand Down
28 changes: 24 additions & 4 deletions src/api/opencmiss/zinc/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ Global functions
* Convert a short name into an enum if the name matches any of the members in
* the enum.
*
* @param string string of the short enumerator name
* @return the correct enum type if a match is found.
* @param name Enumeration name string.
* @return Enumeration value or INVALID if not found.
*/
ZINC_API enum cmzn_field_coordinate_system_type
cmzn_field_coordinate_system_type_enum_from_string(const char *string);
cmzn_field_coordinate_system_type_enum_from_string(const char *name);

/**
* Return an allocated short name of the enum type from the provided enum.
Expand All @@ -48,7 +48,27 @@ ZINC_API enum cmzn_field_coordinate_system_type
* @return an allocated string which stored the short name of the enum.
*/
ZINC_API char *cmzn_field_coordinate_system_type_enum_to_string(
enum cmzn_field_coordinate_system_type coordinate_system_type);
enum cmzn_field_coordinate_system_type type);

/**
* Convert a short name into an enum if the name matches any of the members in
* the enum.
*
* @param name Enumeration name string.
* @return Enumeration value or INVALID if not found.
*/
ZINC_API enum cmzn_field_domain_type cmzn_field_domain_type_enum_from_string(
const char *name);

/**
* Return an allocated short name of the enum type from the provided enum.
* User must call cmzn_deallocate to destroy the successfully returned string.
*
* @param type enum to be converted into string
* @return an allocated string of the short name of the enum.
*/
ZINC_API char *cmzn_field_domain_type_enum_to_string(
enum cmzn_field_domain_type type);

/**
* Get the number of components of the field.
Expand Down
20 changes: 20 additions & 0 deletions src/api/opencmiss/zinc/field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ class Field
return cmzn_field_set_coordinate_system_focus(id, focus);
}

static CoordinateSystemType CoordinateSystemTypeEnumFromString(const char *name)
{
return static_cast<CoordinateSystemType>(cmzn_field_coordinate_system_type_enum_from_string(name));
}

static char *CoordinateSystemTypeEnumToString(CoordinateSystemType type)
{
return cmzn_field_coordinate_system_type_enum_to_string(static_cast<cmzn_field_coordinate_system_type>(type));
}

CoordinateSystemType getCoordinateSystemType()
{
return static_cast<CoordinateSystemType>(
Expand All @@ -195,6 +205,16 @@ class Field
static_cast<cmzn_field_coordinate_system_type>(coordinateSystemType));
}

static DomainType DomainTypeEnumFromString(const char *name)
{
return static_cast<DomainType>(cmzn_field_domain_type_enum_from_string(name));
}

static char *DomainTypeEnumToString(DomainType type)
{
return cmzn_field_domain_type_enum_to_string(static_cast<cmzn_field_domain_type>(type));
}

inline Fieldparameters getFieldparameters();

int getNumberOfComponents()
Expand Down
8 changes: 4 additions & 4 deletions src/api/opencmiss/zinc/fieldfiniteelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,17 +379,17 @@ ZINC_API int cmzn_field_find_mesh_location_set_search_mesh(
* Convert a short name into an enum if the name matches any of the members in
* the enum.
*
* @param string string of the short enumerator name
* @return the correct enum type if a match is found.
* @param name Enumeration name string.
* @return Enumeration value or INVALID if not found.
*/
ZINC_API enum cmzn_field_find_mesh_location_search_mode
cmzn_field_find_mesh_location_search_mode_enum_from_string(const char *string);
cmzn_field_find_mesh_location_search_mode_enum_from_string(const char *name);

/**
* Return an allocated short name of the enum type from the provided enum.
* User must call cmzn_deallocate to destroy the successfully returned string.
*
* @param format enum to be converted into string
* @param mode enum to be converted into string
* @return an allocated string which stored the short name of the enum.
*/
ZINC_API char *cmzn_field_find_mesh_location_search_mode_enum_to_string(
Expand Down
10 changes: 10 additions & 0 deletions src/api/opencmiss/zinc/fieldfiniteelement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ class FieldFindMeshLocation : public Field
return Mesh(cmzn_field_find_mesh_location_get_mesh(this->getDerivedId()));
}

static SearchMode SearchModeEnumFromString(const char *name)
{
return static_cast<SearchMode>(cmzn_field_find_mesh_location_search_mode_enum_from_string(name));
}

static char *SearchModeEnumToString(SearchMode mode)
{
return cmzn_field_find_mesh_location_search_mode_enum_to_string(static_cast<cmzn_field_find_mesh_location_search_mode>(mode));
}

Mesh getSearchMesh() const
{
return Mesh(cmzn_field_find_mesh_location_get_search_mesh(this->getDerivedId()));
Expand Down
2 changes: 1 addition & 1 deletion src/api/opencmiss/zinc/fieldgroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class FieldGroup : public Field
int setSubelementHandlingMode(SubelementHandlingMode mode)
{
return cmzn_field_group_set_subelement_handling_mode(getDerivedId(),
static_cast<enum cmzn_field_group_subelement_handling_mode>(mode));
static_cast<cmzn_field_group_subelement_handling_mode>(mode));
}

FieldGroup createSubregionFieldGroup(const Region& region)
Expand Down
24 changes: 12 additions & 12 deletions src/api/opencmiss/zinc/fieldimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ extern "C" {
* Convert a short name into an enum if the name matches any of the members in
* the enum.
*
* @param string string of the short enumerator name
* @return the correct enum type if a match is found.
* @param name Enumeration name string.
* @return Enumeration value or INVALID if not found.
*/
ZINC_API enum cmzn_field_image_combine_mode
cmzn_field_image_combine_mode_enum_from_string(const char *string);
cmzn_field_image_combine_mode_enum_from_string(const char *name);

/**
* Return an allocated short name of the enum type from the provided enum.
Expand All @@ -45,11 +45,11 @@ ZINC_API char *cmzn_field_image_combine_mode_enum_to_string(
* Convert a short name into an enum if the name matches any of the members in
* the enum.
*
* @param string string of the short enumerator name
* @return the correct enum type if a match is found.
* @param name Enumeration name string.
* @return Enumeration value or INVALID if not found.
*/
ZINC_API enum cmzn_field_image_hardware_compression_mode
cmzn_field_image_hardware_compression_mode_enum_from_string(const char *string);
cmzn_field_image_hardware_compression_mode_enum_from_string(const char *name);

/**
* Return an allocated short name of the enum type from the provided enum.
Expand All @@ -65,11 +65,11 @@ ZINC_API char *cmzn_field_image_hardware_compression_mode_enum_to_string(
* Convert a short name into an enum if the name matches any of the members in
* the enum.
*
* @param string string of the short enumerator name
* @return the correct enum type if a match is found.
* @param name Enumeration name string.
* @return Enumeration value or INVALID if not found.
*/
ZINC_API enum cmzn_field_image_filter_mode cmzn_field_image_filter_mode_enum_from_string(
const char *string);
const char *name);

/**
* Return an allocated short name of the enum type from the provided enum.
Expand All @@ -85,11 +85,11 @@ ZINC_API char *cmzn_field_image_filter_mode_enum_to_string(
* Convert a short name into an enum if the name matches any of the members in
* the enum.
*
* @param string string of the short enumerator name
* @return the correct enum type if a match is found.
* @param name Enumeration name string.
* @return Enumeration value or INVALID if not found.
*/
ZINC_API enum cmzn_field_image_wrap_mode
cmzn_field_image_wrap_mode_enum_from_string(const char *string);
cmzn_field_image_wrap_mode_enum_from_string(const char *name);

/**
* Return an allocated short name of the enum type from the provided enum.
Expand Down
2 changes: 1 addition & 1 deletion src/api/opencmiss/zinc/fieldimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class FieldImage : public Field

PixelFormat getPixelFormat()
{
return static_cast<enum PixelFormat>(cmzn_field_image_get_pixel_format(getDerivedId()));
return static_cast<PixelFormat>(cmzn_field_image_get_pixel_format(getDerivedId()));
}

int setPixelFormat(PixelFormat imagePixelFormat)
Expand Down
2 changes: 1 addition & 1 deletion src/api/opencmiss/zinc/fieldimageprocessing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class FieldImagefilterThreshold : public Field
CONDITION_OUTSIDE = CMZN_FIELD_IMAGEFILTER_THRESHOLD_CONDITION_OUTSIDE
};

enum Condition getCondition()
Condition getCondition()
{
return static_cast<Condition>(cmzn_field_imagefilter_threshold_get_condition(
reinterpret_cast<cmzn_field_imagefilter_threshold_id>(id)));
Expand Down
2 changes: 1 addition & 1 deletion src/api/opencmiss/zinc/fieldmodule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class Fieldmodule

inline Fieldsmoothing createFieldsmoothing();

Elementbasis createElementbasis(int dimension, enum Elementbasis::FunctionType functionType)
Elementbasis createElementbasis(int dimension, Elementbasis::FunctionType functionType)
{
return Elementbasis(cmzn_fieldmodule_create_elementbasis(
id, dimension, static_cast<cmzn_elementbasis_function_type>(functionType)));
Expand Down
2 changes: 1 addition & 1 deletion src/api/opencmiss/zinc/font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Font
return cmzn_font_set_point_size(id, size);
}

enum RenderType getRenderType()
RenderType getRenderType()
{
return static_cast<RenderType>(cmzn_font_get_render_type(id));
}
Expand Down
Loading

0 comments on commit aae4748

Please sign in to comment.