Пример #1
0
void FileMapInfo::write_space(int i, Metaspace* space, bool read_only) {
  align_file_position();
  size_t used = space->used_bytes_slow(Metaspace::NonClassType);
  size_t capacity = space->capacity_bytes_slow(Metaspace::NonClassType);
  struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
  write_region(i, (char*)space->bottom(), used, capacity, read_only, false);
}
Пример #2
0
// Write the string space. The string space contains one or multiple GC(G1) regions.
// When the total string space size is smaller than one GC region of the dump time,
// only one string region is used for shared strings.
//
// If the total string space size is bigger than one GC region, there would be more
// than one GC regions allocated for shared strings. The first/bottom GC region might
// be a partial GC region with the empty portion at the higher address within that region.
// The non-empty portion of the first region is written into the archive as one string
// region. The rest are consecutive full GC regions if they exist, which can be written
// out in one chunk as another string region.
void FileMapInfo::write_string_regions(GrowableArray<MemRegion> *regions) {
  for (int i = MetaspaceShared::first_string;
           i < MetaspaceShared::first_string + MetaspaceShared::max_strings; i++) {
    char* start = NULL;
    size_t size = 0;
    if (regions->is_nonempty()) {
      if (i == MetaspaceShared::first_string) {
        MemRegion first = regions->first();
        start = (char*)first.start();
        size = first.byte_size();
      } else {
        int len = regions->length();
        if (len > 1) {
          start = (char*)regions->at(1).start();
          size = (char*)regions->at(len - 1).end() - start;
        }
      }
    }
    write_region(i, start, size, size, false, false);
  }
}
Пример #3
0
void FileMapInfo::write_space(int i, CompactibleSpace* space, bool read_only) {
  align_file_position();
  struct FileMapInfo::FileMapHeader::space_info* si = &_header._space[i];
  write_region(i, (char*)space->bottom(), space->used(),
               space->capacity(), read_only, false);
}
void CDoProcess::DoProcess(CMData* pData,SubTestResult *testItem)
{	 
	// Local iconic variables 
	Hobject Image=pData->m_Image;
	Hlong m_thred_low1=m_Parameters.m_thred_low1;
	Hlong m_thred_high1=m_Parameters.m_thred_high1;
	Hlong m_thred_low2=m_Parameters.m_thred_low2;
	Hlong m_thred_high2=m_Parameters.m_thred_high2;

	Hlong m_thred;
	/////////
	if (m_thred_low1>m_thred_high1)
	{
		m_thred=m_thred_low1;
		m_thred_low1=m_thred_high1;
		m_thred_high1=m_thred;
	}
	if (m_thred_low2>m_thred_high2)
	{
		m_thred=m_thred_low2;
		m_thred_low2=m_thred_high2;
		m_thred_high2=m_thred;
	}

	///////////////////////////////////////////////////////
	// Local iconic variables 
	Hobject  Region, ConnectedRegions, SelectedRegions;
	Hobject  RegionUnion, RegionFillUp, Contours, Rectangle1;
	Hobject  Rectangle2, ImageReduced1, ImageReduced2, Region1;
	Hobject  Region2, RegionDilation1, RegionErosion1, RegionDilation2;
	Hobject  RegionErosion2;


	// Local control variables 
	HTuple  ModelID,Area;//Row1, Column1, Radius1;
	HTuple  Row11, Column11, Row12, Column12;
	HTuple  Row21, Column21, Row22, Column22;
	////////////////////////////////////////////////////////////
	// Local control variables 
	HTuple  Row;
	HTuple Column;
	// dev_update_off(...); only in hdevelop
	try
	{
		///Row_model_center = 237.659;
		//Column_model_center = 339.212;

		/*gen_circle(&Circle5, Row, Column,m_Parameters.radius_ext);
		gen_circle(&Circle6, Row, Column,m_Parameters.radius_inner);
		difference(Circle5, Circle6, &RegionDifference_median);
		reduce_domain(Image, RegionDifference_median, &ImageReduced_median);
		intensity(RegionDifference_median, Image, &Mean_median, &Deviation_median);
		fast_threshold(ImageReduced_median, &Region_median, m_Parameters.radius_inner_thred, 255, 1);//Mean_median*1.2
		connection(Region_median, &ConnectedRegions_median);
		select_shape(ConnectedRegions_median, &SelectedRegions_median, "area", "and", m_Parameters.radius_ext_extract_size, 
		99999);
		union1(SelectedRegions_median, &RegionUnion_median);
		area_center(RegionUnion_median, &Area_baoChiJia, &Row_baoChiJia, &Column_baoChiJia);*/

		//**********************************************************
		threshold(Image, &Region, 0,  m_Parameters.radius_inner_thred);
		connection(Region, &ConnectedRegions);
		select_shape(ConnectedRegions, &SelectedRegions, "area", "and", m_Parameters.radius_ext_extract_size, 149999);
		union1(SelectedRegions, &RegionUnion);
		fill_up(RegionUnion, &RegionFillUp);
		area_center(RegionFillUp, &Area, &Row, &Column);
		///////////////////////////////////
		/*if (!_access(m_Parameters.CenterOcrModelRegion.c_str(),0))
		{
			wstring msg = _T("Set Region already Exit.OverWrite or Not?");

			if (MessageBox(NULL,msg.c_str(),_T("ReadFile Error"),MB_OK||MB_CANCELTRYCONTINUE)==IDOK)
			{
				write_region(RegionFillUp,m_Parameters.CenterOcrModelRegion.c_str());
			}

		}
		else*/
			write_region(RegionFillUp,m_Parameters.CenterOcrModelRegion.c_str());
		/////////////////////////////////////////
		gen_contour_region_xld(RegionFillUp, &Contours, "border");

		create_shape_model_xld(Contours, 1, -0.69, 0.79, "auto", "auto", "ignore_local_polarity", 
			5, &ModelID);

		//匹配数据

		/*if (!_access(m_Parameters.CenterOcrModelName.c_str(),0))
		{
			wstring msg = _T("Set Model already Exit.OverWrite or Not?");

			if (MessageBox(NULL,msg.c_str(),_T("ReadFile Error"),MB_OK||MB_CANCELTRYCONTINUE)==IDOK)
			{
				write_shape_model(ModelID,m_Parameters.CenterOcrModelName.c_str());
			}

		}
		else*/
			write_shape_model(ModelID,m_Parameters.CenterOcrModelName.c_str());	



		//*****************************************************************
		Row11=m_Parameters.YMin1;
		Row12=m_Parameters.YMin1+m_Parameters.YMax1;
		Column11=m_Parameters.XMin1;
		Column12=m_Parameters.XMin1+m_Parameters.XMax1;
		Row21=m_Parameters.YMin2;
		Row22=m_Parameters.YMin2+m_Parameters.YMax2;
		Column21=m_Parameters.XMin2;
		Column22=m_Parameters.XMin2+m_Parameters.XMax2;
		gen_rectangle1(&Rectangle1, Row11, Column11, Row12, Column12);

		gen_rectangle1(&Rectangle2, Row21, Column21, Row22, Column22);

		reduce_domain(Image, Rectangle1, &ImageReduced1);


		reduce_domain(Image, Rectangle2, &ImageReduced2);


		threshold(ImageReduced1, &Region1, m_Parameters.m_thred_low1, m_Parameters.m_thred_high1);
		threshold(ImageReduced2, &Region2, m_Parameters.m_thred_low2, m_Parameters.m_thred_high2);
		dilation_circle(Region1, &RegionDilation1, 3.5);
		erosion_circle(RegionDilation1, &RegionErosion1, m_Parameters.region_erosion1_size);

		dilation_circle(Region2, &RegionDilation2, 3.5);
		erosion_circle(RegionDilation2, &RegionErosion2, m_Parameters.region_erosion2_size);

		//创建模板时 保存区域和区域图片。在提取区域时,因为正常运行时每次都要用,不能使用
		/*if (!_access(m_Parameters.CenterOcrModelRegion1.c_str(),0))
		{
			wstring msg = _T("Set Region already Exit.OverWrite or Not?");

			if (MessageBox(NULL,msg.c_str(),_T("ReadFile Error"),MB_OK||MB_CANCELTRYCONTINUE)==IDOK)
			{
				write_region(RegionErosion1,m_Parameters.CenterOcrModelRegion1.c_str());
			}

		}
		else*/
			write_region(RegionErosion1,m_Parameters.CenterOcrModelRegion1.c_str());
		/*if (!_access(m_Parameters.CenterOcrModelRegion2.c_str(),0))
		{
			wstring msg = _T("Set Region already Exit.OverWrite or Not?");

			if (MessageBox(NULL,msg.c_str(),_T("ReadFile Error"),MB_OK||MB_CANCELTRYCONTINUE)==IDOK)
			{
				write_region(RegionErosion2,m_Parameters.CenterOcrModelRegion2.c_str());
			}

		}
		else*/
			write_region(RegionErosion2,m_Parameters.CenterOcrModelRegion2.c_str());
		/////////////////////////////////////////////////
		// Number_QiPao=1;
		if (1)
		{

			//pData->m_isFail= false;
			//testItem->m_bFailSubTest = false;
			pData->m_center_y2=Row[0].D();
			pData->m_center_x2=Column[0].D();
		}
		else
		{

			//testItem->m_ErrorMsg = "Error No Find Center";
			//testItem->m_ErrorY = 250;
			//testItem->m_ErrorX = 350;
			//testItem->m_ErrorR = 55;
			//set_color(pData->m_ShowHWindow,"red");
			//disp_region(SelectedRegions_qiPao_extract,pData->m_ShowHWindow);
			//disp_circle(pData->m_ShowHWindow,Row_center,Column_center,85);
		}
		set_color(pData->m_ShowHWindow,"blue");
		disp_obj(Contours,pData->m_ShowHWindow);
		set_color(pData->m_ShowHWindow,"green");
		disp_region(Rectangle1,pData->m_ShowHWindow);
		disp_region(Rectangle2,pData->m_ShowHWindow);
		disp_region(RegionErosion1,pData->m_ShowHWindow);
		disp_region(RegionErosion2,pData->m_ShowHWindow);
		set_color(pData->m_ShowHWindow,"red");
		///////

	}
	catch (HException &except) 
	{
		pData->m_isFail = true;
		testItem->m_bFailSubTest = true;
		pData->m_orientationPhi=0;
		//testItem->m_ErrorMsg = except.file;
		//testItem->m_ErrorMsg += " ";
		//testItem->m_ErrorMsg += except.line;
		//testItem->m_ErrorMsg += " ";
		//testItem->m_ErrorMsg += except.message;
		testItem->m_ErrorY = 1;
		testItem->m_ErrorX = 1;
		testItem->m_ErrorR = 4;
	}
}
Пример #5
0
void CDoProcess::DoProcess(CMData* pData,SubTestResult *testItem)
{	 
	// Local iconic variables 
	Hobject Image=pData->m_Image;
	Hlong m_contrast_low1=m_Parameters.m_contrast_low;
	Hlong m_contrast_high1=m_Parameters.m_contrast_high;


	Hlong m_thred;
	/////////
	if (m_contrast_low1>m_contrast_high1)
	{
		m_thred=m_contrast_low1;
		m_contrast_low1=m_contrast_high1;
		m_contrast_high1=m_thred;
	}
	if (m_Parameters.radius_inner>m_Parameters.radius_ext)
	{
		m_thred=m_Parameters.radius_inner;
		m_Parameters.radius_inner=m_Parameters.radius_ext;
		m_Parameters.radius_ext=m_thred;
	}
	Hobject  Circle5, Circle6, RegionDifference_median,ModelContours;
	Hobject  ImageReduced_median, Region_median, ConnectedRegions_median;
	Hobject  SelectedRegions_median, RegionUnion_median, ImageReduced_median_extract;
	Hobject  ModelImages, ModelRegions;


	// Local control variables 
	HTuple   Mean_median, Deviation_median;
	HTuple  Area_baoChiJia, Row_baoChiJia, Column_baoChiJia;
	HTuple  ModelID, Row2, Column2, Angle2, Score2;
	// Local control variables 
	HTuple  Row=pData->m_center_y;
	HTuple Column= pData->m_center_x;
	// dev_update_off(...); only in hdevelop
	try
	{
		///Row_model_center = 237.659;
		//Column_model_center = 339.212;

		gen_circle(&Circle5, Row, Column,m_Parameters.radius_ext);
		gen_circle(&Circle6, Row, Column,m_Parameters.radius_inner);
		difference(Circle5, Circle6, &RegionDifference_median);
		reduce_domain(Image, RegionDifference_median, &ImageReduced_median);
		intensity(RegionDifference_median, Image, &Mean_median, &Deviation_median);
		fast_threshold(ImageReduced_median, &Region_median, m_Parameters.radius_inner_thred, 255, 1);//Mean_median*1.2
		connection(Region_median, &ConnectedRegions_median);
		select_shape(ConnectedRegions_median, &SelectedRegions_median, "area", "and", m_Parameters.radius_ext_extract_size, 
			99999);
		union1(SelectedRegions_median, &RegionUnion_median);
		area_center(RegionUnion_median, &Area_baoChiJia, &Row_baoChiJia, &Column_baoChiJia);
		//创建模板时 保存区域和区域图片。在提取区域时,因为正常运行时每次都要用,不能使用
		/*if (!_access(m_Parameters.CenterOcrModelRegion.c_str(),0))
		{
			wstring msg = _T("Set Region already Exit.OverWrite or Not?");

			if (MessageBox(NULL,msg.c_str(),_T("ReadFile Error"),MB_OK||MB_CANCELTRYCONTINUE)==IDOK)
			{
				write_region(RegionUnion_median,m_Parameters.CenterOcrModelRegion.c_str());
			}

		}
		else*/
			write_region(RegionUnion_median,m_Parameters.CenterOcrModelRegion.c_str());

		reduce_domain(Image, RegionUnion_median, &ImageReduced_median_extract);

		//write_image(ImageReduced_median_extract, "bmp", 0, "D:/SLACTST/CH1.101/模板字符区域图片.bmp");
		//
		/*if (!_access(m_Parameters.CenterOcrModelPicture.c_str(),0))
		{
		wstring msg = _T("Set Picture already Exit.OverWrite or Not?");

		if (MessageBox(NULL,msg.c_str(),_T("ReadFile Error"),MB_OK||MB_CANCELTRYCONTINUE)==IDOK)
		{
		write_image(ImageReduced_median_extract, "bmp", 0,m_Parameters.CenterOcrModelPicture.c_str());
		}

		}
		else
		write_image(ImageReduced_median_extract, "bmp", 0,m_Parameters.CenterOcrModelPicture.c_str());	*/
		//匹配数据
		inspect_shape_model(ImageReduced_median_extract, &ModelImages, &ModelRegions, 1, 
			25);
		create_shape_model(ImageReduced_median_extract, 4, 0, HTuple(360).Rad(), "auto", 
			"auto", "use_polarity", m_contrast_high1, m_contrast_low1, &ModelID);
		find_shape_model(Image, ModelID, 0, HTuple(360).Rad(), 0.5, 1, 0.5, "least_squares", 
			0, 0.9, &Row2, &Column2, &Angle2, &Score2);

		/*if (!_access(m_Parameters.CenterOcrModelName.c_str(),0))
		{
			wstring msg = _T("Set Model already Exit.OverWrite or Not?");

			if (MessageBox(NULL,msg.c_str(),_T("ReadFile Error"),MB_OK||MB_CANCELTRYCONTINUE)==IDOK)
			{
				write_shape_model(ModelID,m_Parameters.CenterOcrModelName.c_str());
			}

		}
		else*/
			write_shape_model(ModelID,m_Parameters.CenterOcrModelName.c_str());	
		//*查看模板提取效果
		set_shape_model_origin(ModelID, -Row_baoChiJia, -Column_baoChiJia);
		get_shape_model_contours(&ModelContours, ModelID, 1);
		/////////////////////////////////////////////////*/
		// Number_QiPao=1;
		if (1)
		{

			//pData->m_isFail= false;
			//testItem->m_bFailSubTest = false;
			pData->m_center_y2=Row_baoChiJia[0].D();
			pData->m_center_x2=Column_baoChiJia[0].D();
		}
		else
		{

			//testItem->m_ErrorMsg = "Error No Find Center";
			//testItem->m_ErrorY = 250;
			//testItem->m_ErrorX = 350;
			//testItem->m_ErrorR = 55;
			//set_color(pData->m_ShowHWindow,"red");
			//disp_region(SelectedRegions_qiPao_extract,pData->m_ShowHWindow);
			//disp_circle(pData->m_ShowHWindow,Row_center,Column_center,85);
		}
		set_color(pData->m_ShowHWindow,"blue");
		disp_obj(ModelContours,pData->m_ShowHWindow);
		set_color(pData->m_ShowHWindow,"green");
		disp_region(RegionUnion_median,pData->m_ShowHWindow);
		disp_region(Circle5,pData->m_ShowHWindow);
		disp_region(Circle6,pData->m_ShowHWindow);
		set_color(pData->m_ShowHWindow,"red");
		///////

	}
	catch (HException &except) 
	{
		pData->m_isFail = true;
		testItem->m_bFailSubTest = true;
		pData->m_orientationPhi=0;
		//testItem->m_ErrorMsg = except.file;
		//testItem->m_ErrorMsg += " ";
		//testItem->m_ErrorMsg += except.line;
		//testItem->m_ErrorMsg += " ";
		//testItem->m_ErrorMsg += except.message;
		testItem->m_ErrorY = 1;
		testItem->m_ErrorX = 1;
		testItem->m_ErrorR = 4;
	}
}
Пример #6
0
union tree *
gcv_region_end_mc(struct db_tree_state *tsp, const struct db_full_path *pathp, union tree *curtree, void *client_data)
{
    union tree *tp = NULL;
    struct model *m = NULL;
    struct nmgregion *r = NULL;
    struct shell *s = NULL;
    struct bu_list vhead;

    int empty_region = 0;
    int empty_model = 0;
    int NMG_debug_state = 0;
    int count = 0;

    void (*write_region)(struct nmgregion *, const struct db_full_path *, int, int, float [3]);

    if (!tsp || !pathp || !client_data) {
	bu_log("INTERNAL ERROR: gcv_region_end_mc missing parameters\n");
	return TREE_NULL;
    }

    write_region = ((struct gcv_data *)client_data)->func;
    if (!write_region) {
	bu_log("INTERNAL ERROR: gcv_region_end missing conversion callback function\n");
	return TREE_NULL;
    }

    RT_CK_FULL_PATH(pathp);
    RT_CK_TREE(curtree);
    RT_CK_TESS_TOL(tsp->ts_ttol);
    BN_CK_TOL(tsp->ts_tol);
    NMG_CK_MODEL(*tsp->ts_m);

    BU_LIST_INIT(&vhead);

    /*
      if (curtree->tr_op == OP_NOP)
      return 0;
    */


    /* get a copy to play with as the parameters might get clobbered
     * by a longjmp.  FIXME: db_dup_subtree() doesn't create real copies
     */
    tp = db_dup_subtree(curtree, &rt_uniresource);

    /* FIXME: we can't free curtree until we get a "real" copy form
     * db_dup_subtree().  right now we get a fake copy just so we can
     * keep the compiler quiet about clobbering curtree during longjmp
     */
    /* db_free_tree(curtree, &rt_uniresource); */

    /* Sometimes the NMG library adds debugging bits when it detects
     * an internal error, before bombing.  Stash.
     */
    NMG_debug_state = RTG.NMG_debug;

    m = nmg_mmr();
    r = nmg_mrsv(m);
    s = BU_LIST_FIRST(shell, &r->s_hd);

    if (tsp->ts_rtip == NULL)
	tsp->ts_rtip = rt_new_rti(tsp->ts_dbip);

    count += nmg_mc_evaluate (s, tsp->ts_rtip, pathp, tsp->ts_ttol, tsp->ts_tol);

    /* empty region? */
    if (count == 0) {
	bu_log("Region %s appears to be empty.\n", db_path_to_string(pathp));
	return TREE_NULL;
    }

    /*
      bu_log("Target is shot, %d triangles seen.\n", count);

      bu_log("Fusing\n"); fflush(stdout);
      nmg_model_fuse(m, tsp->ts_tol);
      bu_log("Done\n"); fflush(stdout);
    */

    /* Kill cracks */
    while (BU_LIST_NOT_HEAD(&s->l, &r->s_hd)) {
	struct shell *next_s;

	next_s = BU_LIST_PNEXT(shell, &s->l);
	if (nmg_kill_cracks(s)) {
	    if (nmg_ks(s)) {
		empty_region = 1;
		break;
	    }
	}
	/*
	  nmg_shell_coplanar_face_merge(s, tsp->ts_tol, 42);
	*/
	s = next_s;
    }
    if (empty_region)
	return _gcv_cleanup(NMG_debug_state, tp);

    /* kill zero length edgeuses */
    empty_model = nmg_kill_zero_length_edgeuses(*tsp->ts_m);
    if (empty_model)
	return _gcv_cleanup(NMG_debug_state, tp);

    if (BU_SETJUMP) {
	/* Error, bail out */
	char *sofar;

	/* Relinquish bomb protection */
	BU_UNSETJUMP;

	sofar = db_path_to_string(pathp);
	bu_log("FAILED in triangulator: %s\n", sofar);
	bu_free((char *)sofar, "sofar");

	/* Release any intersector 2d tables */
	nmg_isect2d_final_cleanup();

	/* Get rid of (m)any other intermediate structures */
	if ((*tsp->ts_m)->magic == NMG_MODEL_MAGIC)
	    nmg_km(*tsp->ts_m);
	else
	    bu_log("WARNING: tsp->ts_m pointer corrupted, ignoring it.\n");

	/* Now, make a new, clean model structure for next pass. */
	*tsp->ts_m = nmg_mm();
	nmg_kr(r);

	return _gcv_cleanup(NMG_debug_state, tp);
    } else {
	/* Write the region out */
	write_region(r, pathp, tsp->ts_regionid, tsp->ts_gmater, tsp->ts_mater.ma_color);

    } BU_UNSETJUMP; /* Relinquish bomb protection */

    nmg_kr(r);

    return _gcv_cleanup(NMG_debug_state, tp);
}