Skip to content

Commit

Permalink
fixfileio
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed Jun 29, 2022
1 parent 1871788 commit 913be16
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
28 changes: 14 additions & 14 deletions projects/Rigid/RigidTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ struct PrimitiveConvexDecompositionV : zeno::INode {

unsigned int nConvexHulls = interfaceVHACD->GetNConvexHulls();
//std::cout<< "Generate output:" << nConvexHulls << " convex-hulls" << std::endl;
log_debugf("Generate output: %d convex-hulls \n", nConvexHulls);
printf("Generate output: %d convex-hulls \n", nConvexHulls);

bool good_ch_flag = true;
VHACD::IVHACD::ConvexHull ch;
Expand Down Expand Up @@ -334,11 +334,11 @@ struct PrimitiveConvexDecomposition : zeno::INode {
auto listPrim = std::make_shared<zeno::ListObject>();
listPrim->arr.clear();

log_debugf("hacd got %d clusters\n", nClusters);
printf("hacd got %d clusters\n", nClusters);
for (size_t c = 0; c < nClusters; c++) {
size_t nPoints = hacd.GetNPointsCH(c);
size_t nTriangles = hacd.GetNTrianglesCH(c);
log_debugf("hacd cluster %d have %d points, %d triangles\n",
printf("hacd cluster %d have %d points, %d triangles\n",
c, nPoints, nTriangles);

points.clear();
Expand Down Expand Up @@ -1490,7 +1490,7 @@ ZENDEFNODE(BulletWorldRemoveObject, {
struct BulletWorldSetObjList : zeno::INode {
virtual void apply() override {
auto world = get_input<BulletWorld>("world");
auto objList = get_input<ListObject>("objList")->get<std::shared_ptr<BulletObject>>();
auto objList = get_input<ListObject>("objList")->get<std::decay_t<BulletObject>>();
world->setObjectList(std::move(objList));
set_output("world", get_input("world"));
}
Expand Down Expand Up @@ -1538,7 +1538,7 @@ ZENDEFNODE(BulletWorldRemoveConstraint, {
struct BulletWorldSetConsList : zeno::INode {
virtual void apply() override {
auto world = get_input<BulletWorld>("world");
auto consList = get_input<ListObject>("consList")->get<std::shared_ptr<BulletConstraint>>();
auto consList = get_input<ListObject>("consList")->get<std::decay_t<BulletConstraint>>();
world->setConstraintList(std::move(consList));
set_output("world", get_input("world"));
}
Expand Down Expand Up @@ -2026,7 +2026,7 @@ struct BulletMultiBodyPDControl : zeno::INode {
if (has_input("qDesiredList")){
{
auto numericObjs = get_input<zeno::ListObject>(
"qDesiredList")->get<std::shared_ptr<NumericObject>>();
"qDesiredList")->get<std::decay_t<NumericObject>>();
for (auto &&no: numericObjs)
qDesiredArray.push_back(no->get<float>());
}
Expand All @@ -2038,7 +2038,7 @@ struct BulletMultiBodyPDControl : zeno::INode {
if (has_input("dqDesiredList")) {
{
auto numericObjs = get_input<zeno::ListObject>(
"dqDesiredList")->get<std::shared_ptr<NumericObject>>();
"dqDesiredList")->get<std::decay_t<NumericObject>>();
for (auto &&no: numericObjs)
qdDesiredArray.push_back(no->get<float>());
}
Expand Down Expand Up @@ -2308,7 +2308,7 @@ struct BulletCalcInverseKinematics : zeno::INode {
std::vector<int> endEffectorLinkIndices;
{
auto numericObjs = get_input<zeno::ListObject>(
"endEffectorLinkIndices")->get<std::shared_ptr<NumericObject>>();
"endEffectorLinkIndices")->get<std::decay_t<NumericObject>>();
for (auto &&no: numericObjs)
endEffectorLinkIndices.push_back(no->get<int>());
}
Expand All @@ -2318,14 +2318,14 @@ struct BulletCalcInverseKinematics : zeno::INode {
std::vector<vec3f> targetPositions;
{
auto numericObjs = get_input<zeno::ListObject>(
"targetPositions")->get<std::shared_ptr<NumericObject>>();
"targetPositions")->get<std::decay_t<NumericObject>>();
for (auto &&no: numericObjs)
targetPositions.push_back(no->get<vec3f>());
}

std::vector<vec4f> targetOrientations;
{
auto numericObjs = get_input<zeno::ListObject>("targetOrientations")->get<std::shared_ptr<NumericObject>>();
auto numericObjs = get_input<zeno::ListObject>("targetOrientations")->get<std::decay_t<NumericObject>>();
for (auto &&no : numericObjs)
targetOrientations.push_back(no->get<vec4f>());
}
Expand Down Expand Up @@ -2942,23 +2942,23 @@ struct BulletMultiBodyCalculateJacobian : zeno::INode {
std::vector<float> jointPositionsQ;
{
auto numericObjs = get_input<zeno::ListObject>("jointPositionsQ")
->get<std::shared_ptr<NumericObject>>();
->get<std::decay_t<NumericObject>>();
for (auto &&no : numericObjs)
jointPositionsQ.push_back(no->get<float>());
}

std::vector<float> jointVelocitiesQd;
{
auto numericObjs = get_input<zeno::ListObject>("jointVelocitiesQd")
->get<std::shared_ptr<NumericObject>>();
->get<std::decay_t<NumericObject>>();
for (auto &&no : numericObjs)
jointVelocitiesQd.push_back(no->get<float>());
}

std::vector<float> jointAccelerations;
{
auto numericObjs = get_input<zeno::ListObject>("jointAccelerations")
->get<std::shared_ptr<NumericObject>>();
->get<std::decay_t<NumericObject>>();
for (auto &&no : numericObjs)
jointAccelerations.push_back(no->get<float>());
}
Expand Down Expand Up @@ -3141,7 +3141,7 @@ struct BulletMultiBodyCalculateMassMatrix : zeno::INode {
std::vector<float> jointPositionsQ;
{
auto numericObjs = get_input<zeno::ListObject>("jointPositionsQ")
->get<std::shared_ptr<NumericObject>>();
->get<std::decay_t<NumericObject>>();
for (auto &&no : numericObjs)
jointPositionsQ.push_back(no->get<float>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ btCollisionShape* BulletURDFImporter::convertURDFToCollisionShape(const UrdfColl
else
{
std::vector<std::shared_ptr<zeno::PrimitiveObject>> shapes;
auto singleObj = wenqiang_parse_obj(file_get_binary(collision->m_geometry.m_meshFileName)); // TODO: fake multi-group here, implement later.
auto singleObj = wenqiang_parse_obj(zeno::file_get_binary(collision->m_geometry.m_meshFileName)); // TODO: fake multi-group here, implement later.
shapes.push_back(std::move(singleObj));
//create a convex hull for each shape, and store it in a btCompoundShape
shape = createConvexHullFromShapes(shapes, collision->m_geometry.m_meshScale, m_data->m_flags);
Expand Down
5 changes: 3 additions & 2 deletions projects/Rigid/bullet3/src/URDFImporter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/../../../zeno/include
${BULLET_PHYSICS_SOURCE_DIR}/../../../zeno/tpls/include
)

SET(URDF_SRCS
Expand Down Expand Up @@ -30,13 +31,13 @@ SET(URDF_HDRS
ShapeData.h
ReadObjPrim.h b3ImportMeshUtility.h URDFImporterInterface.h)

ADD_LIBRARY(URDFImporter ${URDF_SRCS} ${URDF_HDRS})
ADD_LIBRARY(URDFImporter STATIC ${URDF_SRCS} ${URDF_HDRS})
TARGET_INCLUDE_DIRECTORIES(
URDFImporter PUBLIC .
)

IF (BUILD_SHARED_LIBS)
TARGET_LINK_LIBRARIES(URDFImporter BulletCollision LinearMath Zeno)
TARGET_LINK_LIBRARIES(URDFImporter BulletCollision LinearMath)
ENDIF (BUILD_SHARED_LIBS)

IF (NOT MSVC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool b3ImportMeshUtility::loadAndRegisterMeshFromFileInternal(const std::string&
btVector3 shift(0, 0, 0);

std::string path = relativeFileName;
std::shared_ptr<zeno::PrimitiveObject> shape = wenqiang_parse_obj(file_get_binary(path));
std::shared_ptr<zeno::PrimitiveObject> shape = wenqiang_parse_obj(zeno::file_get_binary(path));

{
// TODO: handle texture later
Expand Down
5 changes: 3 additions & 2 deletions zeno/include/zeno/utils/fileio.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string>
#include <fstream>
#include <cstdio>
#include <vector>

namespace zeno {

Expand All @@ -25,7 +26,7 @@ static bool file_exists(std::string const &path) {
return (bool)fin;
}

template <class Arr>
template <class Arr = std::vector<char>>
static Arr file_get_binary(std::string const &path) {
char const *filename = path.c_str();
FILE *fp = fopen(filename, "rb");
Expand Down Expand Up @@ -82,7 +83,7 @@ static bool file_put_binary(char const *arr_data, size_t arr_size, std::string c
return true;
}

template <class Arr>
template <class Arr = std::vector<char>>
static bool file_put_binary(Arr const &arr, std::string const &path) {
return file_put_binary(std::data(arr), std::size(arr), path);
}
Expand Down

0 comments on commit 913be16

Please sign in to comment.