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

Creating basic type command for VDB #89

Open
wants to merge 21 commits into
base: vdb
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1718390
created id, magic number, internal structure and make command to crea…
cjsb Jul 26, 2023
2cc02d9
fixing unnecessary indentation
cjsb Jul 31, 2023
2dbae76
adding function to table of the vdb, at the moment it has only a boun…
cjsb Jul 31, 2023
84e1149
fixing rt_vdb_shot method - now it is showing something in the ray tr…
cjsb Aug 24, 2023
2a23f83
adjusting cmakelist to add vdb.c file
cjsb Sep 7, 2023
203d497
adding includes for openvdb and ray tracing a vdb structure - very sl…
cjsb Sep 8, 2023
bbe83dc
loading vdb on prep method and adjusting CMakeList to add vdb.cpp
cjsb Sep 12, 2023
5f6dd18
getting the normal for the hit, there is something wrong, it is not g…
cjsb Sep 12, 2023
96cbd50
loading nvdb file working
cjsb Sep 15, 2023
bb53683
loading from file name - changed from make to in - need to remove mak…
cjsb Sep 17, 2023
08716b5
fixing cmakelist to work on release
cjsb Sep 19, 2023
e270334
adjusting cmakelist with debug lib and removing empty files to avoid …
cjsb Sep 20, 2023
a3cf433
adjusting cmakelist from librt to remove vdb.c
cjsb Sep 20, 2023
2d44086
adding plot functio to vdb primitive
cjsb Sep 23, 2023
e7c4455
removing old make function for vdb (now it is only created by using i…
cjsb Sep 27, 2023
3e4936e
code refactoring and cmakelist adjustments
cjsb Oct 5, 2023
278b1d6
adding files and changing cmakelists to build correctly
Oct 6, 2023
cfdc624
more adjustments on cmakelists
Oct 6, 2023
7ec838d
adjustments on cmaklists file for librt to copy dll in the end
cjsb Oct 6, 2023
1c2a949
fixing parsing problem
cjsb Oct 6, 2023
c271e5d
fixing librt cmakelists for debug
cjsb Oct 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions include/bu/magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ __BEGIN_DECLS
#define RT_TGC_INTERNAL_MAGIC 0xaabbdd87 /**< ???? */
#define RT_TOR_INTERNAL_MAGIC 0x9bffed87 /**< ???? */
#define RT_VOL_INTERNAL_MAGIC 0x987ba1d0 /**< ?{?? */
#define RT_VDB_INTERNAL_MAGIC 0xa7a3d52a /**< vdb */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all the macro name corresponds to ASCII representation of the hex numbers which gives a hint of what they means. For e.g. below 706e7473 means pnts. So similarly you can change vdb to 76646220.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I will do that.

#define RT_PNTS_INTERNAL_MAGIC 0x706e7473 /**< pnts */
#define RT_ANNOT_INTERNAL_MAGIC 0x616e6e6f /**< anno */
#define RT_HRT_INTERNAL_MAGIC 0x6872743f /**< hrt? */
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 47 /**< @brief Maximum defined ID_xxx for solids */
#define ID_MAX_SOLID 48 /**< @brief Maximum defined ID_xxx for solids */

/*
* Non-geometric objects
Expand All @@ -133,7 +133,8 @@
#define ID_HRT 43 /**< @brief Heart */
#define ID_DATUM 44 /**< @brief Datum references */
#define ID_SCRIPT 45 /**< @brief Script */
#define ID_MAXIMUM 47 /**< @brief Maximum defined ID_xxx value */
#define ID_VDB 47
#define ID_MAXIMUM 48 /**< @brief Maximum defined ID_xxx value */

/**
* DEPRECATED: external applications should use other LIBRT API to
Expand Down
16 changes: 15 additions & 1 deletion include/rt/geom.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include "../nmg.h" /* (temporarily?) needed for knot_vector */
#include "brep.h"


__BEGIN_DECLS

#define NAMELEN 16 /* NAMESIZE from db.h (can't call it NAMESIZE!!!!!) */
Expand Down Expand Up @@ -368,6 +367,21 @@ struct rt_vol_internal {
unsigned char *map;
};
#define RT_VOL_CK_MAGIC(_p) BU_CKMAG(_p, RT_VOL_INTERNAL_MAGIC, "rt_vol_internal")

/** @addtogroup rt_vdb */
/** @{ */
/*
* ID_VOL
*/
#define RT_VDB_NAME_LEN 128
struct rt_vdb_internal {
uint32_t magic;
char name[RT_VDB_NAME_LEN];
void *vdb; // @pointer to void (to go from c to cpp code). It will point to the vdb handle in the import method.
};
#define RT_VDB_CK_MAGIC(_p) BU_CKMAG(_p, RT_VDB_INTERNAL_MAGIC, "rt_vdb_internal")


/** @} */

/** @addtogroup rt_hf */
Expand Down
16 changes: 16 additions & 0 deletions src/libged/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,28 @@ set(GED_LOCAL_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/../libbg
${CMAKE_CURRENT_BINARY_DIR}
)

# include for openvdb
include_directories(
${CMAKE_SOURCE_DIR}/src/other/openVDB/openvdb
${CMAKE_SOURCE_DIR}/src/other/openVDB/nanovdb
${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb
${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb
)

BRLCAD_LIB_INCLUDE_DIRS(ged GED_INCLUDE_DIRS GED_LOCAL_INCLUDE_DIRS)

BRLCAD_ADDLIB(libged "${LIBGED_SOURCES}" "libwdb;liboptical;librt;libbrep;libnmg;libbv;libbg;libbn;libbu;libicv;libanalyze;${PNG_LIBRARIES};${REGEX_LIBRARIES};${WINSOCK_LIB};${M_LIBRARY}")
SET_TARGET_PROPERTIES(libged PROPERTIES VERSION 20.0.1 SOVERSION 20)

target_link_libraries(libged debug ${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Debug/openvdb.lib)
target_link_libraries(libged optimized ${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Release/openvdb.lib)
target_link_libraries(libged debug ${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Debug/tbb12_debug.lib)
target_link_libraries(libged optimized ${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Release/tbb12.lib)

set_property(TARGET libged PROPERTY CXX_STANDARD 17)
set_property(TARGET libged-static PROPERTY CXX_STANDARD 17)

add_subdirectory(tests)
add_subdirectory(simulate/tests)

Expand Down
1 change: 1 addition & 0 deletions src/libged/garbage_collect/garbage_collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <set>
#include <string>
#include <vector>
#include <iterator>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set library already has member type iterator that is used here in line 76 std::set<std::string>::iterator s_it;. So no need to include iterator library.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that because I was getting an error on line 261 and 262: error C2039: 'inserter': is not a member of 'std'.

That was fixed by adding the include.


#include "bu/app.h"
#include "bu/cmd.h"
Expand Down
4 changes: 3 additions & 1 deletion src/libged/make/make.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ ged_make_core(struct ged *gedp, int argc, const char *argv[])
struct rt_arbn_internal *arbn_ip;
struct rt_superell_internal *superell_ip;
struct rt_metaball_internal *metaball_ip;
struct rt_vdb_internal *vdb_ip;
struct rt_pnts_internal *pnts_ip;
struct rt_cline_internal *cline_ip;
struct rt_brep_internal *brep_ip;
Expand Down Expand Up @@ -792,7 +793,8 @@ ged_make_core(struct ged *gedp, int argc, const char *argv[])
superell_ip->e = 1.0;
fprintf(stdout, "superell being made with %f and %f\n", superell_ip->n, superell_ip->e);

} else if (BU_STR_EQUAL(argv[bu_optind+1], "cline")) {
}
else if (BU_STR_EQUAL(argv[bu_optind+1], "cline")) {

internal.idb_major_type = DB5_MAJORTYPE_BRLCAD;
internal.idb_type = ID_CLINE;
Expand Down
35 changes: 34 additions & 1 deletion src/libged/typein/typein.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ static const char *p_vol[] = {
"Enter Z dimension of a cell: ",
};

static const char *p_vdb[] = {
"Enter file path: "
};


static const char *p_bot[] = {
"Enter number of vertices: ",
Expand Down Expand Up @@ -1039,6 +1043,30 @@ vol_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
return BRLCAD_OK;
}

static int
vdb_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
{
struct rt_vdb_internal *vdb_ip;

BU_ALLOC(vdb_ip, struct rt_vdb_internal);
intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
intern->idb_type = ID_VDB;
intern->idb_meth = &OBJ[ID_VDB];
intern->idb_ptr = (void *)vdb_ip;
//vdb_ip = (struct rt_vdb_internal *)intern->idb_ptr;
vdb_ip->magic = RT_VDB_INTERNAL_MAGIC;
bu_strlcpy(vdb_ip->name, cmd_argvs[3], sizeof(vdb_ip->name));
//VSET(vdb_ip->minBB, -1, -1, -1);
//VSET(vdb_ip->maxBB, 1, 1, 1);
/*char message[200] = "";
strcat(message, cmd_argvs[3]);
strcat(message, " being made \n");
fprintf(stdout, message);*/

//bu_log(message);

return BRLCAD_OK;
}

static int
bot_in(struct ged *gedp, int argc, const char **argv, struct rt_db_internal *intern, const char **prompt)
Expand Down Expand Up @@ -3432,7 +3460,12 @@ ged_in_core(struct ged *gedp, int argc, const char *argv[])
nvals = 10;
menu = p_vol;
fn_in = vol_in;
} else if (BU_STR_EQUAL(argv[2], "hf")) {
} else if (BU_STR_EQUAL(argv[2], "vdb")) {
nvals = 1;
menu = p_vdb;
fn_in = vdb_in;

} else if (BU_STR_EQUAL(argv[2], "hf")) {
if (db_version(gedp->dbip) < 5) {
nvals = 19;
menu = p_hf;
Expand Down
83 changes: 82 additions & 1 deletion src/librt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ set(RT_LOCAL_INCLUDE_DIRS
# ${CMAKE_CURRENT_SOURCE_DIR}/../../../MaterialXSource/source


# include for openvdb
include_directories(
${CMAKE_SOURCE_DIR}/src/other/openVDB/openvdb
${CMAKE_SOURCE_DIR}/src/other/openVDB/nanovdb
${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb
${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb
)

BRLCAD_LIB_INCLUDE_DIRS(rt RT_INCLUDE_DIRS RT_LOCAL_INCLUDE_DIRS)

# FIXME: needs materialX
Expand Down Expand Up @@ -219,6 +227,7 @@ set(LIBRT_SOURCES
primitives/vol/vol_brep.cpp
primitives/vol/vol_mirror.c
primitives/xxx/xxx.c
primitives/vdb/vdb.cpp
reduce.c
reduce_db.cpp
regionfix.c
Expand Down Expand Up @@ -384,6 +393,79 @@ BRLCAD_ADDLIB(librt "${LIBRT_SOURCES}" "${OPENCL_LIBS};libbrep;libnmg;libbg;libb
# set(MATERIALX_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/../../../MaterialXSource/lib/MaterialXCore.lib;${CMAKE_CURRENT_SOURCE_DIR}/../../../MaterialXSource/lib/MaterialXFormat.lib;${CMAKE_CURRENT_SOURCE_DIR}/../../../MaterialXSource/lib/MaterialXGenOsl.lib;${CMAKE_CURRENT_SOURCE_DIR}/../../../MaterialXSource/lib/MaterialXGenShader.lib)
# BRLCAD_ADDLIB(librt "${LIBRT_SOURCES}" "${MATERIALX_LIBS};${OPENCL_LIBS};libbrep;libnmg;libbg;libbv;libbn;libbu;${OPENNURBS_LIBRARIES};${REGEX_LIBRARIES};${WINSOCK_LIB};${RPCRT_LIB};${STDCXX_LIBRARIES}")

target_link_libraries(librt debug ${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Debug/openvdb.lib)
target_link_libraries(librt optimized ${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Release/openvdb.lib)

target_link_libraries(librt debug ${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Debug/tbb12_debug.lib)
target_link_libraries(librt optimized ${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Release/tbb12.lib)

set_property(TARGET librt PROPERTY CXX_STANDARD 17)
set_property(TARGET librt-static PROPERTY CXX_STANDARD 17)

# create a list of files to copy
SET( THIRD_PARTY_DLLS
blosc.dll
openvdb.dll
zstd.dll
)

SET(VDB_DLL_PATH
"$<$<CONFIG:Debug>:" "${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Debug" ">"
"$<$<NOT:$<CONFIG:Debug>>:" "${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Release" ">"
)

SET(VDB_BIN_PATH
"$<$<CONFIG:Debug>:" "${CMAKE_BINARY_DIR}/Debug/bin/" ">"
"$<$<NOT:$<CONFIG:Debug>>:" "${CMAKE_BINARY_DIR}/Release/bin/" ">"
)

string(REPLACE ";" "" VDB_DLL_PATH ${VDB_DLL_PATH})
string(REPLACE ";" "" VDB_BIN_PATH ${VDB_BIN_PATH})
# do the copying
foreach( file_i ${THIRD_PARTY_DLLS})
add_custom_command(
TARGET librt
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${VDB_DLL_PATH}/${file_i}
${VDB_BIN_PATH}
)
endforeach( file_i )


ADD_CUSTOM_COMMAND(TARGET librt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<$<CONFIG:Debug>:${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Debug/lz4d.dll>"
"$<$<NOT:$<CONFIG:Debug>>:${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Release/lz4.dll>"
"$<$<CONFIG:Debug>:${CMAKE_BINARY_DIR}/Debug/bin/>"
"$<$<NOT:$<CONFIG:Debug>>:${CMAKE_BINARY_DIR}/Release/bin/>" )

ADD_CUSTOM_COMMAND(TARGET librt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<$<CONFIG:Debug>:${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Debug/tbb12_debug.dll>"
"$<$<NOT:$<CONFIG:Debug>>:${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Release/tbb12.dll>"
"$<$<CONFIG:Debug>:${CMAKE_BINARY_DIR}/Debug/bin/>"
"$<$<NOT:$<CONFIG:Debug>>:${CMAKE_BINARY_DIR}/Release/bin/>" )

ADD_CUSTOM_COMMAND(TARGET librt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<$<CONFIG:Debug>:${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Debug/zlibd1.dll>"
"$<$<NOT:$<CONFIG:Debug>>:${CMAKE_SOURCE_DIR}/src/other/openVDB/build/openvdb/openvdb/openvdb/Release/zlib1.dll>"
"$<$<CONFIG:Debug>:${CMAKE_BINARY_DIR}/Debug/bin/>"
"$<$<NOT:$<CONFIG:Debug>>:${CMAKE_BINARY_DIR}/Release/bin/>" )

if (MSVC)
#add_compile_options(/bigobj)
target_compile_options(librt PRIVATE /bigobj)
target_compile_options(librt-static PRIVATE /bigobj)
else ()
#add_compile_options(-Wa,-mbig-obj)
target_compile_options(librt PRIVATE -Wa)
target_compile_options(librt PRIVATE -mbig-obj)

target_compile_options(librt-static PRIVATE -Wa)
target_compile_options(librt-static PRIVATE -mbig-obj)
endif ()

set_target_properties(librt PROPERTIES VERSION 20.0.1 SOVERSION 20)
if(HIDE_INTERNAL_SYMBOLS)
Expand Down Expand Up @@ -457,4 +539,3 @@ CMAKEFILES(
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8

48 changes: 48 additions & 0 deletions src/librt/primitives/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ RT_DECLARE_INTERFACE(cline);
RT_DECLARE_INTERFACE(bot);
RT_DECLARE_INTERFACE(superell);
RT_DECLARE_INTERFACE(metaball);
RT_DECLARE_INTERFACE(vdb);
RT_DECLARE_INTERFACE(hyp);
RT_DECLARE_INTERFACE(revolve);
RT_DECLARE_INTERFACE(constraint);
Expand Down Expand Up @@ -2422,6 +2423,53 @@ const struct rt_functab OBJ[] = {
NULL /* label */
},

{
/* 47 */
RT_FUNCTAB_MAGIC, "ID_VDB", "vdb",
0, /* ft_use_rpp */
RTFUNCTAB_FUNC_PREP_CAST(rt_vdb_prep),
RTFUNCTAB_FUNC_SHOT_CAST(rt_vdb_shot),
NULL, /* print */
RTFUNCTAB_FUNC_NORM_CAST(rt_vdb_norm),
NULL, /* piece_shot */
NULL, /* piece_hitsegs */
NULL, /* uv */
NULL, /* curve */
NULL, /* classify */
NULL, /* free */
RTFUNCTAB_FUNC_PLOT_CAST(rt_vdb_plot),
NULL, /* adaptive_plot */
NULL, /* vshot */
NULL, /* tess */
NULL, /* tnurb */
NULL, /* brep */
RTFUNCTAB_FUNC_IMPORT5_CAST(rt_vdb_import5),
RTFUNCTAB_FUNC_EXPORT5_CAST(rt_vdb_export5),
NULL, /* import4 */
NULL, /* export4 */
NULL, /* ifree */
NULL, /* describe */
RTFUNCTAB_FUNC_XFORM_CAST(rt_generic_xform),
NULL, /* parse */
sizeof(struct rt_vdb_internal), /* sizeof(internal) */
RT_VDB_INTERNAL_MAGIC, /* magic */
RTFUNCTAB_FUNC_GET_CAST(rt_generic_get),
RTFUNCTAB_FUNC_ADJUST_CAST(rt_generic_adjust),
RTFUNCTAB_FUNC_FORM_CAST(rt_generic_form),
NULL, /* make */
NULL, /* params */
RTFUNCTAB_FUNC_BBOX_CAST(rt_vdb_bbox),
NULL, /* volume */
NULL, /* surf_area */
NULL, /* centroid */
NULL, /* oriented_bbox */
NULL, /* find_selections */
NULL, /* evaluate_selection */
NULL, /* process_selection */
NULL, /* serialize */
NULL /* label */
},

{
/* this entry for sanity only */
0L, ">ID_MAXIMUM", ">id_max",
Expand Down
Loading