LCOV - code coverage report
Current view: top level - pencil/include/geometry - geometry_dimensions.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 8 33 24.2 %
Date: 2024-04-07 11:14:42 Functions: 3 9 33.3 %

          Line data    Source code
       1             : /* File: geometry_dimensions.inl; Copyright and License: see below */
       2             : 
       3             : #include "u8/u8_trace.h"
       4             : #include "u8/u8_log.h"
       5             : #include <assert.h>
       6             : #include <math.h>
       7             : 
       8         256 : static inline void geometry_dimensions_init ( geometry_dimensions_t *this_, double width, double height )
       9             : {
      10         256 :     (*this_).width = width;
      11         256 :     (*this_).height = height;
      12         256 : }
      13             : 
      14           0 : static inline void geometry_dimensions_reinit ( geometry_dimensions_t *this_, double width, double height )
      15             : {
      16           0 :     (*this_).width = width;
      17           0 :     (*this_).height = height;
      18           0 : }
      19             : 
      20             : static inline void geometry_dimensions_copy ( geometry_dimensions_t *this_, const geometry_dimensions_t *original )
      21             : {
      22             :     assert( NULL != original );
      23             :     (*this_) = (*original);
      24             : }
      25             : 
      26             : static inline void geometry_dimensions_replace ( geometry_dimensions_t *this_, const geometry_dimensions_t *original )
      27             : {
      28             :     assert( NULL != original );
      29             :     (*this_) = (*original);
      30             : }
      31             : 
      32           0 : static inline void geometry_dimensions_init_empty ( geometry_dimensions_t *this_ )
      33             : {
      34           0 :     (*this_).width = 0.0;
      35           0 :     (*this_).height = 0.0;
      36           0 : }
      37             : 
      38             : static inline void geometry_dimensions_reinit_empty ( geometry_dimensions_t *this_ )
      39             : {
      40             :     (*this_).width = 0.0;
      41             :     (*this_).height = 0.0;
      42             : }
      43             : 
      44           0 : static inline void geometry_dimensions_destroy ( geometry_dimensions_t *this_ )
      45             : {
      46           0 : }
      47             : 
      48        1244 : static inline double geometry_dimensions_get_width ( const geometry_dimensions_t *this_ )
      49             : {
      50        1244 :     return (*this_).width;
      51             : }
      52             : 
      53         256 : static inline double geometry_dimensions_get_height ( const geometry_dimensions_t *this_ )
      54             : {
      55         256 :     return (*this_).height;
      56             : }
      57             : 
      58           0 : static inline double geometry_dimensions_get_area ( const geometry_dimensions_t *this_ )
      59             : {
      60           0 :     return (*this_).width * (*this_).height;
      61             : }
      62             : 
      63             : static inline bool geometry_dimensions_is_empty ( const geometry_dimensions_t *this_ )
      64             : {
      65             :     return ( ( (*this_).width < 0.000000001 )||( (*this_).height < 0.000000001 ) );
      66             : }
      67             : 
      68           0 : static inline bool geometry_dimensions_can_contain ( const geometry_dimensions_t *this_, const geometry_dimensions_t *that )
      69             : {
      70           0 :     assert( NULL != that );
      71             : 
      72           0 :     const bool result
      73           0 :         = ( (*this_).width + 0.000000001 > (*that).width )&&( (*this_).height + 0.000000001 > (*that).height );
      74             : 
      75           0 :     return result;
      76             : }
      77             : 
      78           0 : static inline void geometry_dimensions_expand ( geometry_dimensions_t *this_, double delta_width, double delta_height )
      79             : {
      80           0 :     (*this_).width += delta_width;
      81           0 :     if ( (*this_).width < 0.0 )
      82             :     {
      83           0 :         (*this_).width = 0.0;
      84             :     }
      85             : 
      86           0 :     (*this_).height += delta_height;
      87           0 :     if ( (*this_).height < 0.0 )
      88             :     {
      89           0 :         (*this_).height = 0.0;
      90             :     }
      91           0 : }
      92             : 
      93             : static inline void geometry_dimensions_trace ( const geometry_dimensions_t *this_ )
      94             : {
      95             :     U8_TRACE_INFO( "geometry_dimensions_t" );
      96             :     U8_TRACE_INFO_INT( "- width:", (*this_).width );
      97             :     U8_TRACE_INFO_INT( "- height:", (*this_).height );
      98             : }
      99             : 
     100             : 
     101             : /*
     102             : Copyright 2019-2024 Andreas Warnke
     103             : 
     104             : Licensed under the Apache License, Version 2.0 (the "License");
     105             : you may not use this file except in compliance with the License.
     106             : You may obtain a copy of the License at
     107             : 
     108             :     http://www.apache.org/licenses/LICENSE-2.0
     109             : 
     110             : Unless required by applicable law or agreed to in writing, software
     111             : distributed under the License is distributed on an "AS IS" BASIS,
     112             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     113             : See the License for the specific language governing permissions and
     114             : limitations under the License.
     115             : */

Generated by: LCOV version 1.16