Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Material Object Representation #7

Merged
merged 21 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4a47fc4
added material objects and db I/O functions
treydinges Sep 29, 2021
25b05cd
Merge branch 'main' of github.com:BRL-CAD/brlcad into materials
treydinges Oct 2, 2021
fb5bfe4
added basic material object implementation
treydinges Oct 3, 2021
389b2da
working material object implementation - incomplete property fields
treydinges Oct 4, 2021
1e405db
Merge branch 'main' of github.com:treydinges/brlcad into materials
treydinges Oct 4, 2021
bcea23c
Name for the material is now picked up from the in command 'name'field
treydinges Oct 12, 2021
cf8b083
Add AVS' for materials (WIP).
cdconn00 Oct 14, 2021
448ad14
Merge branch 'materials' of https://github.com/treydinges/brlcad into…
cdconn00 Oct 14, 2021
5432f24
attempting to parse material avs stores
treydinges Oct 15, 2021
39d30a7
Create gltf_read.cpp
volivarez60 Oct 19, 2021
1e50b5c
Material object with AVS store import and export
treydinges Oct 19, 2021
574ee71
Completed AVS store implementation with in command
treydinges Oct 19, 2021
04e8548
mk_material implementation
treydinges Oct 19, 2021
cf4c0b8
Revert "Create gltf_read.cpp"
treydinges Oct 20, 2021
8c4fac5
Merge branch 'BRL-CAD:main' into main
treydinges Oct 20, 2021
60ac20c
typein command updated for material objects
treydinges Oct 26, 2021
561377c
Memory leaks??
treydinges Oct 26, 2021
823a70b
Material object representation ready for main
treydinges Oct 26, 2021
8e422a8
Merge pull request #1 from treydinges/materials
treydinges Oct 28, 2021
3e220cc
fixes for material branch code style/implementation
treydinges Nov 11, 2021
9527359
Merge pull request #2 from treydinges/materials-hotfix
treydinges Nov 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/bu/avs.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ BU_EXPORT extern void bu_avs_merge(struct bu_attribute_value_set *dest,
BU_EXPORT extern const char *bu_avs_get(const struct bu_attribute_value_set *avp,
const char *attribute);

/**
* gets all attributes in an attribute set in "name = value" form,
* using the provided title.
*/
BU_EXPORT extern const char *bu_avs_get_all(const struct bu_attribute_value_set *avp,
const char *title);

/**
* Remove all occurrences of an attribute from the provided attribute
* set.
Expand Down
1 change: 1 addition & 0 deletions include/bu/magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ __BEGIN_DECLS
#define RT_AP_MAGIC 0x4170706c /**< Appl */
#define RT_COMB_MAGIC 0x436f6d49 /**< ComI */
#define RT_CONSTRAINT_MAGIC 0x7063696d /**< pcim */
#define RT_MATERIAL_MAGIC 0x54414d55 /**< TAMU */
#define RT_CTS_MAGIC 0x98989123 /**< ???\# */
#define RT_DB_TRAVERSE_MAGIC 0x64627472 /**< dbtr */
#define RT_DBTS_MAGIC 0x64627473 /**< dbts */
Expand Down
1 change: 1 addition & 0 deletions include/rt/db5.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ struct db5_ondisk_header {
#define DB5_MINORTYPE_BRLCAD_HRT 43
#define DB5_MINORTYPE_BRLCAD_DATUM 44
#define DB5_MINORTYPE_BRLCAD_SCRIPT 45
#define DB5_MINORTYPE_BRLCAD_MATERIAL 46

/* Uniform-array binary */
#define DB5_MINORTYPE_BINU_WID_MASK 0x30
Expand Down
5 changes: 3 additions & 2 deletions include/rt/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
* NOTE: must update the non-geometric object id's below the
* ADD_BELOW_HERE marker
*/
#define ID_MAX_SOLID 46 /**< @brief Maximum defined ID_xxx for solids */
#define ID_MAX_SOLID 47 /**< @brief Maximum defined ID_xxx for solids */

/*
* Non-geometric objects
Expand All @@ -119,6 +119,7 @@
#define ID_BINUNIF 33 /**< @brief Uniform-array binary */
#define ID_UNUSED2 34 /**< @brief UNUSED (placeholder) */
#define ID_CONSTRAINT 39 /**< @brief Constraint object */
#define ID_MATERIAL 46 /**< @brief Material object */

/* - ADD_BELOW_HERE - */
/* superellipsoid should be 31, but is not v5 compatible */
Expand All @@ -132,7 +133,7 @@
#define ID_HRT 43 /**< @brief Heart */
#define ID_DATUM 44 /**< @brief Datum references */
#define ID_SCRIPT 45 /**< @brief Script */
#define ID_MAXIMUM 46 /**< @brief Maximum defined ID_xxx value */
#define ID_MAXIMUM 47 /**< @brief Maximum defined ID_xxx value */

/**
* DEPRECATED: external applications should use other LIBRT API to
Expand Down
17 changes: 17 additions & 0 deletions include/rt/nongeom.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,23 @@ struct rt_constraint_internal {
#define RT_CHECK_CONSTRAINT(_p) BU_CKMAG(_p, RT_CONSTRAINT_MAGIC, "rt_constraint_internal")
#define RT_CK_CONSTRAINT(_p) RT_CHECK_CONSTRAINT(_p)

/**
* In-memory format for database "material" record
*/
struct rt_material_internal {
uint32_t magic;
struct bu_vls name;
struct bu_vls parent;
struct bu_vls source;

struct bu_attribute_value_set physicalProperties;
struct bu_attribute_value_set mechanicalProperties;
struct bu_attribute_value_set opticalProperties;
struct bu_attribute_value_set thermalProperties;
};

#define RT_CHECK_MATERIAL(_p) BU_CKMAG(_p, RT_MATERIAL_MAGIC, "rt_material_internal")
#define RT_CK_MATERIAL(_p) RT_CHECK_MATERIAL(_p)

__END_DECLS

Expand Down
11 changes: 11 additions & 0 deletions include/wdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,17 @@ WDB_EXPORT extern int mk_ars(struct rt_wdb *fp, const char *name, size_t ncurves
WDB_EXPORT extern int mk_constraint(struct rt_wdb *wdbp, const char *name, const char *expr);


WDB_EXPORT extern int mk_material(struct rt_wdb *wdbp,
const char *db_name,
const char *name,
const char *parent,
const char *source,
struct bu_attribute_value_set *physicalProperties,
struct bu_attribute_value_set *mechanicalProperties,
struct bu_attribute_value_set *opticalProperties,
struct bu_attribute_value_set *thermalProperties);


/* FIXME: are the variable-sized types actually necessary? should be
* able to rely on stdint types. the file+nonfile duplication seems
* silly too.
Expand Down
31 changes: 31 additions & 0 deletions src/libbu/avs.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,37 @@ bu_avs_get(const struct bu_attribute_value_set *avsp, const char *name)
return NULL;
}

const char *
bu_avs_get_all(const struct bu_attribute_value_set *avsp, const char *title) {
BU_CK_AVS(avsp);

struct bu_attribute_value_pair *avpp;
size_t i;
struct bu_vls str = BU_VLS_INIT_ZERO;

if (title) {
bu_vls_strcat(&str, title);
bu_vls_strcat(&str, "=\"");
}

avpp = avsp->avp;
for (i = 0; i < avsp->count; i++, avpp++) {
bu_vls_strcat(&str, "\t\t(");
bu_vls_strcat(&str, avpp->name ? avpp->name : "NULL");
bu_vls_strcat(&str, " : ");
bu_vls_strcat(&str, avpp->value ? avpp->value : "NULL");
bu_vls_strcat(&str, ")\n");
}

if (title) {
bu_vls_strcat(&str, "\"");
}

const char * attributes = bu_vls_strgrab(&str);

return attributes;
}


int
bu_avs_remove(struct bu_attribute_value_set *avsp, const char *name)
Expand Down
2 changes: 2 additions & 0 deletions src/libbu/magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ bu_identify_magic(register uint32_t magic)
return "librt rt_comb_internal";
case RT_CONSTRAINT_MAGIC:
return "librt rt_constraint_internal";
case RT_MATERIAL_MAGIC:
return "librt rt_material_internal";
case RT_CTS_MAGIC:
return "librt combined_tree_state";
case RT_DB_TRAVERSE_MAGIC:
Expand Down
Loading