/** Setup fixture */
    corrected_intensity_hardcoded_fixture_v2()
    {
        typedef metric_type::uint_t uint_t;
        typedef metric_type::ushort_t ushort_t;
        ushort_t correctedIntAll1[] = {1213, 966, 960, 1095};
        ushort_t correctedIntCalled1[] = {4070, 4074, 4029, 3972};
        uint_t calledCounts1[] = {0, 698433, 548189, 548712, 646638};
        expected_metrics.push_back(
                metric_type(1, 1104, 25, 1063, 11.9458876f, to_vector(correctedIntCalled1), to_vector(correctedIntAll1),
                            to_vector(calledCounts1)));
        ushort_t correctedIntAll2[] = {1558, 1151, 1158, 1293};
        uint_t calledCounts2[] = {10938, 733661, 537957, 543912, 615504};
        ushort_t correctedIntCalled2[] = {5013, 4983, 4915, 4932};
        expected_metrics.push_back(
                metric_type(1, 1104, 1, 1295, 13.3051805f, to_vector(correctedIntCalled2), to_vector(correctedIntAll2),
                            to_vector(calledCounts2)));
        ushort_t correctedIntAll3[] = {1171, 932, 912, 1069};
        uint_t calledCounts3[] = {0, 706987, 556441, 556067, 653959};
        ushort_t correctedIntCalled3[] = {3931, 3931, 3923, 3878};
        expected_metrics.push_back(
                metric_type(1, 1105, 25, 1025, 11.7396259f, to_vector(correctedIntCalled3), to_vector(correctedIntAll3),
                            to_vector(calledCounts3)));

        int tmp[] = {2, 48, 1, 0, 80, 4, 25, 0, 39, 4, 189, 4, 198, 3, 192, 3, 71, 4, 230, 15, 234, 15, 189, 15, 132,
                     15, 0, 0, 0, 0, 65, 168, 10, 0, 93, 93, 8, 0, 104, 95, 8, 0, 238, 221, 9, 0, 91, 34, 63, 65, 1, 0,
                     80, 4, 1, 0, 15, 5, 22, 6, 127, 4, 134, 4, 13, 5, 149, 19, 119, 19, 51, 19, 68, 19, 186, 42, 0, 0,
                     221, 49, 11, 0, 101, 53, 8, 0, 168, 76, 8, 0, 80, 100, 9, 0, 5, 226, 84, 65, 1, 0, 81, 4, 25, 0, 1,
                     4, 147, 4, 164, 3, 144, 3, 45, 4, 91, 15, 91, 15, 83, 15, 38, 15, 0, 0, 0, 0, 171, 201, 10, 0, 153,
                     125, 8, 0, 35, 124, 8, 0, 135, 250, 9, 0, 130, 213, 59, 65
        };
        setup_hardcoded_binary(tmp, header_type());
    }
Esempio n. 2
0
 /** Setup fixture */
 tile_metrics_write_read_fixture_v2()
 {
     expected_metrics.push_back(metric_type(7, 1114, 2355119.25f,1158081.50f,6470949,3181956,
                                            metric_type::read_metric_vector(1, metric_type::read_metric_type(3, 2.61630869f, 0.0797112584f/100, 0.119908921f/100))));
     expected_metrics.push_back(metric_type(7, 1214, 2355119.25f,1174757.75f,6470949,3227776,
                                            metric_type::read_metric_vector(1, metric_type::read_metric_type(3, 2.62243795f, 0.129267812f/100, 0.135128692f/100))));
     expected_metrics.push_back(metric_type(7, 2114, 2355119.25f,1211592.38f,6470949,3328983,
                                            metric_type::read_metric_vector(1, metric_type::read_metric_type(3, 2.490309f, 0.11908555f/100, 0.092706576f/100))));
     setup_write_read();
 }
 /** Setup fixture */
 corrected_intensity_write_read_fixture_v3()
 {
     typedef metric_type::uint_t uint_t;
     typedef metric_type::ushort_t ushort_t;
     uint_t calledCounts1[] = {52, 1049523, 654071, 500476, 982989};
     ushort_t correctedIntCalled1[] = {245, 252, 61, 235};
     expected_metrics.push_back(metric_type(7, 1114, 1, to_vector(correctedIntCalled1), to_vector(calledCounts1)));
     uint_t calledCounts2[] = {0, 1063708, 582243, 588028, 953132};
     ushort_t correctedIntCalled2[] = {232, 257, 68, 228};
     expected_metrics.push_back(metric_type(7, 1114, 2, to_vector(correctedIntCalled2), to_vector(calledCounts2)));
     uint_t calledCounts3[] = {0, 1022928, 617523, 594836, 951825};
     ushort_t correctedIntCalled3[] = {227, 268, 68, 229};
     expected_metrics.push_back(metric_type(7, 1114, 3, to_vector(correctedIntCalled3), to_vector(calledCounts3)));
     setup_write_read();
 }
  bool make_statistic::generic_run()
  {
    typedef viennagrid::segmented_mesh<MeshT, SegmentationT> SegmentedMeshType;
    typename viennamesh::result_of::const_parameter_handle<SegmentedMeshType>::type imp = input_mesh.get<SegmentedMeshType>();
    if (imp)
    {
      typedef viennamesh::statistic<double> StatisticType;
      typedef typename viennagrid::result_of::cell<MeshT>::type CellType;
      output_parameter_proxy<StatisticType> osp(output_statistic);

      if (histogram_bins.valid())
      {
        osp().set_histogram( StatisticType::histogram_type::make(histogram_bins().begin(), histogram_bins().end()) );
      }
      else if (histogram_min.valid() && histogram_max.valid() && histogram_bin_count.valid())
      {
        osp().set_histogram( StatisticType::histogram_type::make_uniform(histogram_min(), histogram_max(), histogram_bin_count()) );
      }
      else
      {
        error(1) << "No histogram configuration provided" << std::endl;
        return false;
      }

      try
      {
        if (metric_type() == "aspect_ratio")
          osp()( imp().mesh, viennamesh::aspect_ratio<CellType> );
        else if (metric_type() == "condition_number")
          osp()( imp().mesh, viennamesh::condition_number<CellType> );
        else if (metric_type() == "min_angle")
          osp()( imp().mesh, viennamesh::min_angle<CellType> );
        else if (metric_type() == "max_angle")
          osp()( imp().mesh, viennamesh::max_angle<CellType> );
        else if (metric_type() == "min_dihedral_angle")
          osp()( imp().mesh, viennamesh::min_dihedral_angle<CellType> );
        else if (metric_type() == "radius_edge_ratio")
          osp()( imp().mesh, viennamesh::radius_edge_ratio<CellType> );
        else
        {
          error(1) << "Metric type \"" << metric_type() << "\" is not supported" << std::endl;
          return false;
        }
      }
      catch ( metric_not_implemented_or_supported_exception const & ex )
      {
        error(1) << "Metric type \"" << metric_type() << "\" is not supported" << std::endl;
        error(1) << ex.what() << std::endl;
      }

      info(5) << osp() << std::endl;

      return true;
    }

    return false;
  }
Esempio n. 5
0
 /** Setup fixture */
 tile_metrics_hardcoded_fixture_v2()
 {
     expected_metrics.push_back(metric_type(7, 1114, 2355119.25f,1158081.50f,6470949,3181956,
                                            metric_type::read_metric_vector(1, metric_type::read_metric_type(1, 2.61630869f, 0.0797112584f/100, 0.119908921f/100))));
     expected_metrics.push_back(metric_type(7, 1214, 2355119.25f,1174757.75f,6470949,3227776,
                                            metric_type::read_metric_vector(1, metric_type::read_metric_type(1, 2.62243795f, 0.129267812f/100, 0.135128692f/100))));
     expected_metrics.push_back(metric_type(7, 2114, 2355119.25f,1211592.38f,6470949,3328983,
                                            metric_type::read_metric_vector(1, metric_type::read_metric_type(1, 2.490309f, 0.11908555f/100, 0.092706576f/100))));
     int tmp[] = {
             2,10
             ,7,0,90,4,100,0,-67,-66,15,74
             ,7,0,90,4,102,0,74,122,-59,74
             ,7,0,90,4,101,0,12,94,-115,73
             ,7,0,90,4,103,0,16,54,66,74
             ,7,0,90,4,-56,0,82,-11,80,58
             ,7,0,90,4,-55,0,-62,42,-99,58
             ,7,0,90,4,44,1,-102,113,39,64
             ,7,0,-66,4,100,0,-67,-66,15,74
             ,7,0,-66,4,102,0,74,122,-59,74
             ,7,0,-66,4,101,0,46,103,-113,73
             ,7,0,-66,4,103,0,0,2,69,74
             ,7,0,-66,4,-56,0,21,111,-87,58
             ,7,0,-66,4,-55,0,-86,29,-79,58
             ,7,0,-66,4,44,1,6,-42,39,64
             ,7,0,66,8,100,0,-67,-66,15,74
             ,7,0,66,8,102,0,74,122,-59,74
             ,7,0,66,8,101,0,67,-26,-109,73
             ,7,0,66,8,103,0,92,47,75,74
             ,7,0,66,8,-56,0,123,22,-100,58
             ,7,0,66,8,-55,0,85,6,115,58
             ,7,0,66,8,44,1,57,97,31,64
             ,7,0,66,8,144,1,0,0,0,0   // Test whether control lane accidentally clears data
             ,6,0,66,8,144,1,0,0,0,0   // Test whether control lane for empty tile shows up
     };
     setup_hardcoded_binary(tmp, header_type());
 }
    /** Setup fixture */
    corrected_intensity_hardcoded_fixture_v3()
    {
        typedef metric_type::uint_t uint_t;
        typedef metric_type::ushort_t ushort_t;
        uint_t calledCounts1[] = {52, 1049523, 654071, 500476, 982989};
        ushort_t correctedIntCalled1[] = {245, 252, 61, 235};
        //expected_metrics.push_back(metric_type(7, 1114, 1, to_vector(correctedIntCalled1), to_vector(calledCounts1)));
        expected_metrics.push_back(metric_type(7, 1114, 1, (correctedIntCalled1), (calledCounts1)));
        uint_t calledCounts2[] = {0, 1063708, 582243, 588028, 953132};
        ushort_t correctedIntCalled2[] = {232, 257, 68, 228};
        //expected_metrics.push_back(metric_type(7, 1114, 2, to_vector(correctedIntCalled2), to_vector(calledCounts2)));
        expected_metrics.push_back(metric_type(7, 1114, 2, (correctedIntCalled2), (calledCounts2)));
        uint_t calledCounts3[] = {0, 1022928, 617523, 594836, 951825};
        ushort_t correctedIntCalled3[] = {227, 268, 68, 229};
        expected_metrics.push_back(metric_type(7, 1114, 3, (correctedIntCalled3), (calledCounts3)));
        //expected_metrics.push_back(metric_type(7, 1114, 3, to_vector(correctedIntCalled3), to_vector(calledCounts3)));

        int tmp[] = {3, 34, 7, 0, 90, 4, 1, 0, -11, 0, -4, 0, 61, 0, -21, 0, 52, 0, 0, 0, -77, 3, 16, 0, -9, -6, 9, 0,
                     -4, -94, 7, 0, -51, -1, 14, 0, 7, 0, 90, 4, 2, 0, -24, 0, 1, 1, 68, 0, -28, 0, 0, 0, 0, 0, 28, 59,
                     16, 0, 99, -30, 8, 0, -4, -8, 8, 0, 44, -117, 14, 0, 7, 0, 90, 4, 3, 0, -29, 0, 12, 1, 68, 0, -27,
                     0, 0, 0, 0, 0, -48, -101, 15, 0, 51, 108, 9, 0, -108, 19, 9, 0, 17, -122, 14, 0
        };
        setup_hardcoded_binary(tmp, header_type());
    }
 /** Setup fixture */
 corrected_intensity_write_read_fixture_v2()
 {
     typedef metric_type::uint_t uint_t;
     typedef metric_type::ushort_t ushort_t;
     ushort_t correctedIntAll1[] = {1213, 966, 960, 1095};
     ushort_t correctedIntCalled1[] = {4070, 4074, 4029, 3972};
     uint_t calledCounts1[] = {0, 698433, 548189, 548712, 646638};
     expected_metrics.push_back(
             metric_type(1, 1104, 25, 1063, 11.9458876f, to_vector(correctedIntCalled1), to_vector(correctedIntAll1),
                         to_vector(calledCounts1)));
     ushort_t correctedIntAll2[] = {1558, 1151, 1158, 1293};
     uint_t calledCounts2[] = {10938, 733661, 537957, 543912, 615504};
     ushort_t correctedIntCalled2[] = {5013, 4983, 4915, 4932};
     expected_metrics.push_back(
             metric_type(1, 1104, 1, 1295, 13.3051805f, to_vector(correctedIntCalled2), to_vector(correctedIntAll2),
                         to_vector(calledCounts2)));
     ushort_t correctedIntAll3[] = {1171, 932, 912, 1069};
     uint_t calledCounts3[] = {0, 706987, 556441, 556067, 653959};
     ushort_t correctedIntCalled3[] = {3931, 3931, 3923, 3878};
     expected_metrics.push_back(
             metric_type(1, 1105, 25, 1025, 11.7396259f, to_vector(correctedIntCalled3), to_vector(correctedIntAll3),
                         to_vector(calledCounts3)));
     setup_write_read();
 }
Esempio n. 8
0
    bool make_statistic::run(viennamesh::algorithm_handle &)
    {
        info(1) << "make_statistic started:" << std::endl;

        mesh_handle input_mesh = get_required_input<mesh_handle>("mesh");

        /*original mesh for comparison statistics (hausdorff distance, curvature difference...)*/
        mesh_handle original_mesh = get_input<mesh_handle>("original_mesh");

        /*All provided cell quality metric types are implemented as header files, which are located in statistics/metrics.
         * Note that most metrics are only implemented for triangles*/
        data_handle<viennamesh_string> metric_type = get_required_input<viennamesh_string>("metric_type");

        /*Decision threshold for triangle qualitity classification
         * E.g., radius_ratio < 1.5
         * Whether '<' or '>' is used for comparison is deduced from metric_ordering_tag*/
        data_handle<viennagrid_numeric> good_element_threshold = get_input<viennagrid_numeric>("good_element_threshold");

        /* comprehensive mesh quality metric is defined as
             alpha * (1 - good_elements_counted/count) + beta * min_dist_rms + gamma * mean_curvature + delta * volume_deviation;
        */
        data_handle<viennagrid_numeric> alpha = get_input<viennagrid_numeric>("alpha");
        data_handle<viennagrid_numeric> beta = get_input<viennagrid_numeric>("beta");
        data_handle<viennagrid_numeric> gamma = get_input<viennagrid_numeric>("gamma");
        data_handle<viennagrid_numeric> delta = get_input<viennagrid_numeric>("delta");

#if HIST
        data_handle<viennagrid_numeric> histogram_bins = get_input<viennagrid_numeric>("histogram_bin");
        data_handle<viennagrid_numeric> histogram_min = get_input<viennagrid_numeric>("histogram_min");
        data_handle<viennagrid_numeric> histogram_max = get_input<viennagrid_numeric>("histogram_max");
        data_handle<int> histogram_bin_count = get_input<int>("histogram_bin_count");
#endif


        typedef viennagrid::mesh                                  MeshType;
        typedef viennagrid::result_of::element<MeshType>::type    ElementType; //=Triangle or Tetrahedron

        typedef viennamesh::statistic<viennagrid_numeric>         StatisticType;
        StatisticType statistic;

#if HIST
        typedef StatisticType::histogram_type                     HistogramType;


        if (histogram_bins.valid())
        {
            std::vector<viennagrid_numeric> bins;
            for (int i = 0; i != histogram_bins.size(); ++i)
                bins.push_back( histogram_bins(i) );

            statistic.set_histogram( StatisticType::histogram_type::make(bins.begin(), bins.end()) );
        }
        else if (histogram_min.valid() && histogram_max.valid() && histogram_bin_count.valid())
        {
            statistic.set_histogram( StatisticType::histogram_type::make_uniform(histogram_min(), histogram_max(), histogram_bin_count()) );
        }
        else
        {
            //If histograms are about to be added again, returing false here will prevent the basic statistics features from working!
            error(1) << "No histogram configuration provided" << std::endl;
            return false;
        }
#endif





        //Good element threshold input was set, call statistics with the appropriate metric
        if(good_element_threshold.valid())
        {
            viennamesh::LoggingStack stack( std::string("High quality cell counter with metric type \"") + metric_type() + "\"" );

            if (metric_type() == "aspect_ratio")
                statistic.cell_quality_count<viennamesh::aspect_ratio_tag>( input_mesh(), viennamesh::aspect_ratio<ElementType>, good_element_threshold());
            else if (metric_type() == "min_angle")
                statistic.cell_quality_count<viennamesh::min_angle_tag>( input_mesh(), viennamesh::min_angle<ElementType>, good_element_threshold());
            else if (metric_type() == "max_angle")
                statistic.cell_quality_count<viennamesh::max_angle_tag>( input_mesh(), viennamesh::max_angle<ElementType>, good_element_threshold());
            else if (metric_type() == "min_dihedral_angle")
                statistic.cell_quality_count<viennamesh::min_dihedral_angle_tag>( input_mesh(), viennamesh::min_dihedral_angle<ElementType>, good_element_threshold());
            else if (metric_type() == "radius_edge_ratio")
                statistic.cell_quality_count<viennamesh::radius_edge_ratio_tag>( input_mesh(), viennamesh::radius_edge_ratio<ElementType>, good_element_threshold());
            else if (metric_type() == "radius_ratio")
                statistic.cell_quality_count<viennamesh::radius_ratio_tag>( input_mesh(), viennamesh::radius_ratio<ElementType>, good_element_threshold());
            else if (metric_type() == "perimeter_inradius_ratio")
                statistic.cell_quality_count<viennamesh::perimeter_inradius_ratio_tag>( input_mesh(), viennamesh::perimeter_inradius_ratio<ElementType>, good_element_threshold());
            else if (metric_type() == "edge_ratio")
                statistic.cell_quality_count<viennamesh::edge_ratio_tag>( input_mesh(), viennamesh::edge_ratio<ElementType>, good_element_threshold());
            else if (metric_type() == "circum_perimeter_ratio")
                statistic.cell_quality_count<viennamesh::circum_perimeter_ratio_tag>( input_mesh(), viennamesh::circum_perimeter_ratio<ElementType>, good_element_threshold());
            else if (metric_type() == "stretch")
                statistic.cell_quality_count<viennamesh::stretch_tag>( input_mesh(), viennamesh::stretch<ElementType>, good_element_threshold());
            else if (metric_type() == "skewness")
                statistic.cell_quality_count<viennamesh::skewness_tag>( input_mesh(), viennamesh::skewness<ElementType>, good_element_threshold());
            else
            {
                error(1) << "Metric type \"" << metric_type() << "\" is not supported for cell quality classifaction" << std::endl;
                return false;
            }
        }
        else //no triangle classifiction takes place
        {
            viennamesh::LoggingStack stack( std::string("Cell statistics with metric type \"") + metric_type() + "\"" );

            if (metric_type() == "aspect_ratio")
                statistic.cell_stats( input_mesh(), viennamesh::aspect_ratio<ElementType> );
            else if (metric_type() == "min_angle")
                statistic.cell_stats( input_mesh(), viennamesh::min_angle<ElementType> );
            else if (metric_type() == "max_angle")
                statistic.cell_stats( input_mesh(), viennamesh::max_angle<ElementType> );
            else if (metric_type() == "min_dihedral_angle")
                statistic.cell_stats( input_mesh(), viennamesh::min_dihedral_angle<ElementType> );
            else if (metric_type() == "radius_edge_ratio")
                statistic.cell_stats( input_mesh(), viennamesh::radius_edge_ratio<ElementType> );
            else if (metric_type() == "radius_ratio")
                statistic.cell_stats( input_mesh(), viennamesh::radius_ratio<ElementType> );
            else if (metric_type() == "perimeter_inradius_ratio")
                statistic.cell_stats( input_mesh(), viennamesh::perimeter_inradius_ratio<ElementType> );
            else if (metric_type() == "edge_ratio")
                statistic.cell_stats( input_mesh(), viennamesh::edge_ratio<ElementType> );
            else if (metric_type() == "circum_perimeter_ratio")
                statistic.cell_stats( input_mesh(), viennamesh::circum_perimeter_ratio<ElementType> );
            else if (metric_type() == "stretch")
                statistic.cell_stats( input_mesh(), viennamesh::stretch<ElementType> );
            else if (metric_type() == "skewness")
                statistic.cell_stats( input_mesh(), viennamesh::skewness<ElementType> );
            else
            {
                error(1) << "Metric type \"" << metric_type() << "\" is not supported" << std::endl;
                return false;
            }
        }

        if(original_mesh.valid())//a second mesh is set, calculate mesh comparison measures
        {
            viennamesh::LoggingStack stack( std::string("Calculation of Mesh Comparison Measures") );

            statistic.mesh_comparison_quality(input_mesh(), original_mesh());



            ConstTriangleRange tr_orig(original_mesh());
            ConstTriangleRange tr(input_mesh());

            StatisticType statistic_orig;
            statistic_orig.cell_stats( original_mesh(), viennamesh::aspect_ratio<ElementType> );


            //use median of orig mesh for input mesh triangle shape characterization
            statistic.cell_quality_count<viennamesh::aspect_ratio_tag>( input_mesh(), viennamesh::aspect_ratio<ElementType>, statistic_orig.median());

            if(alpha.valid() && beta.valid() && gamma.valid() && delta.valid() )
            {
                statistic.set_mesh_quality_weights(alpha(), beta(), gamma(), delta());
                info(5) << "values for comprehensive mesh quality metric: alpha = " << alpha()
                        << ", beta = " << beta() << ", gamma = " << gamma() << ", delta = "<< delta() <<  std::endl;

            }
            else
            {
                info(5) << "default values for comprehensive mesh quality metric used: alpha = 0.25, beta = 20, gamma = 1.0, delta = 1.3" << std::endl;
            }

            set_output("minimum_distance_rms", statistic.min_dist_rms());
            set_output("mean_curvature_difference", statistic.mean_curvature());
            set_output("area_deviation", statistic.volume_deviation());
            set_output("triangle_shape", statistic.good_elements()/statistic.count());
            set_output("mesh_quality_metric", statistic.mesh_quality_metric());
        }


        info(5) << statistic << "\n";

#if HIST
        statistic.normalize();
        std::vector<viennagrid_numeric> bins;
        for (HistogramType::const_iterator bit = statistic.histogram().begin(); bit != statistic.histogram().end(); ++bit)
            bins.push_back( (*bit).second );
        bins.push_back( statistic.histogram().overflow_bin() );

        data_handle<viennagrid_numeric> output_bins = make_data<viennagrid_numeric>();
        output_bins.set( bins );
        set_output( "bins", output_bins );
#endif

        set_output( "min", statistic.min() );
        set_output( "max", statistic.max() );
        set_output( "mean", statistic.mean() );
        set_output( "median", statistic.median());

        return true;
    }