LCOV - code coverage report
Current view: top level - pencil/include/geometry - geometry_dimensions.inl (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.71.2_covts Lines: 100.0 % 55 55
Test Date: 2026-08-22 19:47:36 Functions: 100.0 % 15 15

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

Generated by: LCOV version 2.0-1