int bldgs_setrec ( octant_t *leaf, double ticksize, edata_t *edata, etree_t *cvm,double xoriginm, double yoriginm, double zoriginm) { int res; double z_m; cvmpayload_t props; res = bldgs_search( leaf, ticksize, edata ); if ( res > 0 ) { props = get_props( res, z_m ); edata->Vp = props.Vp; edata->Vs = props.Vs; edata->rho = props.rho; return 1; } z_m = leaf->lz * ticksize; if ( z_m < theSurfaceShift ) { get_airprops( leaf, ticksize, edata, cvm,xoriginm,yoriginm,zoriginm); return 1; } return 0; }
/* Kiírja a gráfot egy dot fájlba. */ void print (std::string fname) { std::ofstream file(fname); file << "digraph\n"; file << "{\n"; file << "\tgraph[outputorder=edgesfirst, layout=twopi, overlap=false]" << std::endl; file << "\tnode[style=filled]" << std::endl; for (auto f: flags) { file << "\t\"" << f.first << "\" [" << get_props(f.second) << "]\n"; } file << std::endl; for (auto p: LUT) { std::string src = p.first; for (auto dst: p.second) { file << "\t\"" << src << "\" -> \"" << dst << "\";" << std::endl; } } file << "}"; file.close(); std::cout << LUT.size() << std::endl; }
//Get the handle for certain data type. //If the returned handle is null, means that data type is not on the //properties. Or that the GET_DATA_TYPE_NAME_SYMBOL function was not implemented void* MP_data_type_handle(MP_args_p args, short in_out_id, char* data_type_name){ void* handle = NULL; if(in_out_id == INPUT_OUTPUT_PROPS){//We are checking on inputs and outputs handle = MP_data_type_handle(args,INPUT_PROPS,data_type_name); //First on inputs if(handle == NULL){ //If we were not successful we check on outputs handle = MP_data_type_handle(args,OUTPUT_PROPS,data_type_name); } } else{ mepinta_props* props = get_props(args,in_out_id); ASSERT_RETURN(props!=NULL,NULL); int i; for(i=0; i < props->size; ++i){ if(strcmp(data_type_name,MP_data_type_name(props->handles[i])) == 0){ handle = props->handles[i]; break; } } } return handle; }
//Get the amount of properties int MP_props_size (MP_args_p args, short in_out_id){ mepinta_props* props = get_props(args,in_out_id); ASSERT_RETURN(props!=NULL,0); return props->size; }
void csg_comb_func(struct db_i *dbip, struct directory *dp, void *UNUSED(ptr)) { struct rt_db_internal intern; struct rt_comb_internal *comb; struct iges_properties props; int comb_len; size_t i; int dependent = 1; int *de_pointers; int id; /* when this is called in facet mode, we only want groups */ if (mode == FACET_MODE && (dp->d_flags & RT_DIR_REGION)) return; /* check if already written */ if (dp->d_uses < 0) return; for (i = 0; i < no_of_indeps; i++) { if (!bu_strncmp(dp->d_namep, independent[i], NAMESIZE+1)) { dependent = 0; break; } } id = rt_db_get_internal(&intern, dp, dbip, (matp_t)NULL, &rt_uniresource); if (id < 0) return; if (id != ID_COMBINATION) { bu_log("Directory/Database mismatch! is %s a combination or not?\n", dp->d_namep); return; } comb = (struct rt_comb_internal *)intern.idb_ptr; RT_CK_COMB(comb); if (verbose) bu_log("Combination - %s\n", dp->d_namep); if (!comb->tree) { bu_log("Warning: empty combination (%s)\n", dp->d_namep); dp->d_uses = 0; return; } comb_len = db_tree_nleaves(comb->tree); de_pointers = (int *)bu_calloc(comb_len, sizeof(int), "csg_comb_func"); comb_form = 0; de_pointer_number = 0; if (get_de_pointers(comb->tree, dp, comb_len, de_pointers)) { bu_log("Error in combination %s\n", dp->d_namep); bu_free((char *)de_pointers, "csg_comb_func de_pointers"); rt_db_free_internal(&intern); return; } bu_strlcpy(props.name, dp->d_namep, NAMESIZE+1); props.material_name[0] = '\0'; props.material_params[0] = '\0'; props.region_flag = ' '; props.ident = 0; props.air_code = 0; props.material_code = 0; props.los_density = 0; props.color[0] = 0; props.color[1] = 0; props.color[2] = 0; get_props(&props, comb); dp->d_uses = (-comb_to_iges(comb, comb_len, dependent, &props, de_pointers, fp_dir, fp_param)); if (!dp->d_uses) { comb_error++; bu_log("g-iges: combination (%s) not written to iges file\n", dp->d_namep); } rt_db_free_internal(&intern); bu_free((char *)de_pointers, "csg_comb_func de_pointers"); }
/* Produce a diff between two arbitrary files at LOCAL_ABSPATH1 and * LOCAL_ABSPATH2, using the diff callbacks from CALLBACKS. * Use PATH as the name passed to diff callbacks. * FILE1_IS_EMPTY and FILE2_IS_EMPTY are used as hints which diff callback * function to use to compare the files (added/deleted/changed). * * If ORIGINAL_PROPS_OVERRIDE is not NULL, use it as original properties * instead of reading properties from LOCAL_ABSPATH1. This is required when * a file replaces a directory, where LOCAL_ABSPATH1 is an empty file that * file content must be diffed against, but properties to diff against come * from the replaced directory. */ static svn_error_t * do_arbitrary_files_diff(const char *local_abspath1, const char *local_abspath2, const char *path, svn_boolean_t file1_is_empty, svn_boolean_t file2_is_empty, apr_hash_t *original_props_override, const svn_wc_diff_callbacks4_t *callbacks, void *diff_baton, svn_client_ctx_t *ctx, apr_pool_t *scratch_pool) { apr_hash_t *original_props; apr_hash_t *modified_props; apr_array_header_t *prop_changes; svn_string_t *original_mime_type = NULL; svn_string_t *modified_mime_type = NULL; if (ctx->cancel_func) SVN_ERR(ctx->cancel_func(ctx->cancel_baton)); /* Try to get properties from either file. It's OK if the files do not * have properties, or if they are unversioned. */ if (original_props_override) original_props = original_props_override; else SVN_ERR(get_props(&original_props, local_abspath1, ctx->wc_ctx, scratch_pool, scratch_pool)); SVN_ERR(get_props(&modified_props, local_abspath2, ctx->wc_ctx, scratch_pool, scratch_pool)); SVN_ERR(svn_prop_diffs(&prop_changes, modified_props, original_props, scratch_pool)); /* Try to determine the mime-type of each file. */ original_mime_type = svn_hash_gets(original_props, SVN_PROP_MIME_TYPE); if (!file1_is_empty && !original_mime_type) { const char *mime_type; SVN_ERR(svn_io_detect_mimetype2(&mime_type, local_abspath1, ctx->mimetypes_map, scratch_pool)); if (mime_type) original_mime_type = svn_string_create(mime_type, scratch_pool); } modified_mime_type = svn_hash_gets(modified_props, SVN_PROP_MIME_TYPE); if (!file2_is_empty && !modified_mime_type) { const char *mime_type; SVN_ERR(svn_io_detect_mimetype2(&mime_type, local_abspath1, ctx->mimetypes_map, scratch_pool)); if (mime_type) modified_mime_type = svn_string_create(mime_type, scratch_pool); } /* Produce the diff. */ if (file1_is_empty && !file2_is_empty) SVN_ERR(callbacks->file_added(NULL, NULL, NULL, path, local_abspath1, local_abspath2, /* ### TODO get real revision info * for versioned files? */ SVN_INVALID_REVNUM, SVN_INVALID_REVNUM, original_mime_type ? original_mime_type->data : NULL, modified_mime_type ? modified_mime_type->data : NULL, /* ### TODO get copyfrom? */ NULL, SVN_INVALID_REVNUM, prop_changes, original_props, diff_baton, scratch_pool)); else if (!file1_is_empty && file2_is_empty) SVN_ERR(callbacks->file_deleted(NULL, NULL, path, local_abspath1, local_abspath2, original_mime_type ? original_mime_type->data : NULL, modified_mime_type ? modified_mime_type->data : NULL, original_props, diff_baton, scratch_pool)); else { svn_stream_t *file1; svn_stream_t *file2; svn_boolean_t same; svn_string_t *val; /* We have two files, which may or may not be the same. ### Our caller assumes that we should ignore symlinks here and handle them as normal paths. Perhaps that should change? */ SVN_ERR(svn_stream_open_readonly(&file1, local_abspath1, scratch_pool, scratch_pool)); SVN_ERR(svn_stream_open_readonly(&file2, local_abspath2, scratch_pool, scratch_pool)); /* Wrap with normalization, etc. if necessary */ if (original_props) { val = svn_hash_gets(original_props, SVN_PROP_EOL_STYLE); if (val) { svn_subst_eol_style_t style; const char *eol; svn_subst_eol_style_from_value(&style, &eol, val->data); /* ### Ignoring keywords */ if (eol) file1 = svn_subst_stream_translated(file1, eol, TRUE, NULL, FALSE, scratch_pool); } } if (modified_props) { val = svn_hash_gets(modified_props, SVN_PROP_EOL_STYLE); if (val) { svn_subst_eol_style_t style; const char *eol; svn_subst_eol_style_from_value(&style, &eol, val->data); /* ### Ignoring keywords */ if (eol) file2 = svn_subst_stream_translated(file2, eol, TRUE, NULL, FALSE, scratch_pool); } } SVN_ERR(svn_stream_contents_same2(&same, file1, file2, scratch_pool)); if (! same || prop_changes->nelts > 0) { /* ### We should probably pass the normalized data we created using the subst streams as that is what diff users expect */ SVN_ERR(callbacks->file_changed(NULL, NULL, NULL, path, same ? NULL : local_abspath1, same ? NULL : local_abspath2, /* ### TODO get real revision info * for versioned files? */ SVN_INVALID_REVNUM /* rev1 */, SVN_INVALID_REVNUM /* rev2 */, original_mime_type ? original_mime_type->data : NULL, modified_mime_type ? modified_mime_type->data : NULL, prop_changes, original_props, diff_baton, scratch_pool)); } } return SVN_NO_ERROR; }
/* Produce a diff of depth DEPTH for the directory at LOCAL_ABSPATH, * using information from the arbitrary_diff_walker_baton B. * LOCAL_ABSPATH is the path being crawled and can be on either side * of the diff depending on baton->recursing_within_added_subtree. */ static svn_error_t * arbitrary_diff_this_dir(struct arbitrary_diff_walker_baton *b, const char *local_abspath, svn_depth_t depth, apr_pool_t *scratch_pool) { const char *local_abspath1; const char *local_abspath2; svn_node_kind_t kind1; svn_node_kind_t kind2; const char *child_relpath; apr_hash_t *dirents1; apr_hash_t *dirents2; apr_hash_t *merged_dirents; apr_array_header_t *sorted_dirents; int i; apr_pool_t *iterpool; if (b->recursing_within_adm_dir) { if (svn_dirent_skip_ancestor(b->adm_dir_abspath, local_abspath)) return SVN_NO_ERROR; else { b->recursing_within_adm_dir = FALSE; b->adm_dir_abspath = NULL; } } else if (svn_wc_is_adm_dir(svn_dirent_basename(local_abspath, NULL), scratch_pool)) { b->recursing_within_adm_dir = TRUE; b->adm_dir_abspath = apr_pstrdup(b->pool, local_abspath); return SVN_NO_ERROR; } if (b->recursing_within_added_subtree) child_relpath = svn_dirent_skip_ancestor(b->root2_abspath, local_abspath); else child_relpath = svn_dirent_skip_ancestor(b->root1_abspath, local_abspath); if (!child_relpath) return SVN_NO_ERROR; local_abspath1 = svn_dirent_join(b->root1_abspath, child_relpath, scratch_pool); SVN_ERR(svn_io_check_resolved_path(local_abspath1, &kind1, scratch_pool)); local_abspath2 = svn_dirent_join(b->root2_abspath, child_relpath, scratch_pool); SVN_ERR(svn_io_check_resolved_path(local_abspath2, &kind2, scratch_pool)); if (depth > svn_depth_empty) { if (kind1 == svn_node_dir) SVN_ERR(svn_io_get_dirents3(&dirents1, local_abspath1, TRUE, /* only_check_type */ scratch_pool, scratch_pool)); else dirents1 = apr_hash_make(scratch_pool); } if (kind2 == svn_node_dir) { apr_hash_t *original_props; apr_hash_t *modified_props; apr_array_header_t *prop_changes; /* Show any property changes for this directory. */ SVN_ERR(get_props(&original_props, local_abspath1, b->ctx->wc_ctx, scratch_pool, scratch_pool)); SVN_ERR(get_props(&modified_props, local_abspath2, b->ctx->wc_ctx, scratch_pool, scratch_pool)); SVN_ERR(svn_prop_diffs(&prop_changes, modified_props, original_props, scratch_pool)); if (prop_changes->nelts > 0) SVN_ERR(b->callbacks->dir_props_changed(NULL, NULL, child_relpath, FALSE /* was_added */, prop_changes, original_props, b->diff_baton, scratch_pool)); if (depth > svn_depth_empty) { /* Read directory entries. */ SVN_ERR(svn_io_get_dirents3(&dirents2, local_abspath2, TRUE, /* only_check_type */ scratch_pool, scratch_pool)); } } else if (depth > svn_depth_empty) dirents2 = apr_hash_make(scratch_pool); if (depth <= svn_depth_empty) return SVN_NO_ERROR; /* Compare dirents1 to dirents2 and show added/deleted/changed files. */ merged_dirents = apr_hash_merge(scratch_pool, dirents1, dirents2, NULL, NULL); sorted_dirents = svn_sort__hash(merged_dirents, svn_sort_compare_items_as_paths, scratch_pool); iterpool = svn_pool_create(scratch_pool); for (i = 0; i < sorted_dirents->nelts; i++) { svn_sort__item_t elt = APR_ARRAY_IDX(sorted_dirents, i, svn_sort__item_t); const char *name = elt.key; svn_io_dirent2_t *dirent1; svn_io_dirent2_t *dirent2; const char *child1_abspath; const char *child2_abspath; svn_pool_clear(iterpool); if (b->ctx->cancel_func) SVN_ERR(b->ctx->cancel_func(b->ctx->cancel_baton)); if (strcmp(name, SVN_WC_ADM_DIR_NAME) == 0) continue; dirent1 = svn_hash_gets(dirents1, name); if (!dirent1) { dirent1 = svn_io_dirent2_create(iterpool); dirent1->kind = svn_node_none; } dirent2 = svn_hash_gets(dirents2, name); if (!dirent2) { dirent2 = svn_io_dirent2_create(iterpool); dirent2->kind = svn_node_none; } child1_abspath = svn_dirent_join(local_abspath1, name, iterpool); child2_abspath = svn_dirent_join(local_abspath2, name, iterpool); if (dirent1->special) SVN_ERR(svn_io_check_resolved_path(child1_abspath, &dirent1->kind, iterpool)); if (dirent2->special) SVN_ERR(svn_io_check_resolved_path(child1_abspath, &dirent2->kind, iterpool)); if (dirent1->kind == svn_node_dir && dirent2->kind == svn_node_dir) { if (depth == svn_depth_immediates) { /* Not using the walker, so show property diffs on these dirs. */ SVN_ERR(do_arbitrary_dirs_diff(child1_abspath, child2_abspath, b->root1_abspath, b->root2_abspath, svn_depth_empty, b->callbacks, b->diff_baton, b->ctx, iterpool)); } else { /* Either the walker will visit these directories (with * depth=infinity) and they will be processed as 'this dir' * later, or we're showing file children only (depth=files). */ continue; } } /* Files that exist only in dirents1. */ if (dirent1->kind == svn_node_file && (dirent2->kind == svn_node_dir || dirent2->kind == svn_node_none)) SVN_ERR(do_arbitrary_files_diff(child1_abspath, b->empty_file_abspath, svn_relpath_join(child_relpath, name, iterpool), FALSE, TRUE, NULL, b->callbacks, b->diff_baton, b->ctx, iterpool)); /* Files that exist only in dirents2. */ if (dirent2->kind == svn_node_file && (dirent1->kind == svn_node_dir || dirent1->kind == svn_node_none)) { apr_hash_t *original_props; SVN_ERR(get_props(&original_props, child1_abspath, b->ctx->wc_ctx, scratch_pool, scratch_pool)); SVN_ERR(do_arbitrary_files_diff(b->empty_file_abspath, child2_abspath, svn_relpath_join(child_relpath, name, iterpool), TRUE, FALSE, original_props, b->callbacks, b->diff_baton, b->ctx, iterpool)); } /* Files that exist in dirents1 and dirents2. */ if (dirent1->kind == svn_node_file && dirent2->kind == svn_node_file) SVN_ERR(do_arbitrary_files_diff(child1_abspath, child2_abspath, svn_relpath_join(child_relpath, name, iterpool), FALSE, FALSE, NULL, b->callbacks, b->diff_baton, b->ctx, scratch_pool)); /* Directories that only exist in dirents2. These aren't crawled * by this walker so we have to crawl them separately. */ if (depth > svn_depth_files && dirent2->kind == svn_node_dir && (dirent1->kind == svn_node_file || dirent1->kind == svn_node_none)) SVN_ERR(do_arbitrary_dirs_diff(child1_abspath, child2_abspath, b->root1_abspath, b->root2_abspath, depth <= svn_depth_immediates ? svn_depth_empty : svn_depth_infinity , b->callbacks, b->diff_baton, b->ctx, iterpool)); } svn_pool_destroy(iterpool); return SVN_NO_ERROR; }