-
Notifications
You must be signed in to change notification settings - Fork 342
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
Add new KinBody::ExtraGeometryInfo struture for KinBody::Link::_mapExtraGeometries #1441
Open
zax147
wants to merge
22
commits into
rdiankov:production
Choose a base branch
from
zax147:extra_geometries
base: production
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3b5fbb4
Add missing Boost include
PeterBowman ec22ecf
Merge pull request #1420 from PeterBowman/boost-hash
rdiankov 0258762
add serialization and deserialization of extraGeometries
e898491
tested and updated de/serialization of extraGeometries
64caea0
deserialization support merging based on id
61ef8a6
add extrageometry structure and modify related functions
26573d7
Merge pull request #1448 from zax147/extra_geometries
justism 5ccc302
add extrageometry structure and modify related functions
745c4c8
Merge remote-tracking branch 'origin/production' into extra_geometries
766e991
Merge branch 'extra_geometries' of https://github.com/rdiankov/openra…
564543f
add assertion for setlinkgroupgeometries
5119ad0
Merge pull request #1451 from zax147/extra_geometries
rschlaikjer e800a93
fixed unintialized pointer issue
edeaaa1
Merge pull request #1452 from zax147/extra_geometries
rschlaikjer 0380fa6
change function signature for compatibility
05cb3bf
Merge pull request #1453 from zax147/extra_geometries
justism 48a1991
change function signature for compatibility
4094bce
Merge branch 'extra_geometries' of https://github.com/rdiankov/openra…
eab12ce
Merge branch 'rdiankov-extra_geometries' into extra_geometries
d5dce67
Merge pull request #1454 from zax147/extra_geometries
justism 7a3a9de
clean up comments
07c46b1
changed variable name, change link serialization, and update the para…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,24 +212,27 @@ void KinBody::LinkInfo::SerializeJSON(rapidjson::Value &value, rapidjson::Docume | |
value.AddMember("readableInterfaces", std::move(rReadableInterfaces), allocator); | ||
} | ||
|
||
// if(_mapExtraGeometries.size() > 0 ) { | ||
// rapidjson::Value extraGeometriesValue; | ||
// extraGeometriesValue.SetObject(); | ||
// FOREACHC(im, _mapExtraGeometries) { | ||
// rapidjson::Value geometriesValue; | ||
// geometriesValue.SetArray(); | ||
// FOREACHC(iv, im->second){ | ||
// if(!!(*iv)) | ||
// { | ||
// rapidjson::Value geometryValue; | ||
// (*iv)->SerializeJSON(geometryValue, allocator); | ||
// geometriesValue.PushBack(geometryValue, allocator); | ||
// } | ||
// } | ||
// extraGeometriesValue.AddMember(rapidjson::Value(im->first.c_str(), allocator).Move(), geometriesValue, allocator); | ||
// } | ||
// value.AddMember("extraGeometries", extraGeometriesValue, allocator); | ||
// } | ||
if (_mapExtraGeometries.size() > 0) { | ||
rapidjson::Value extraGeometriesValue; | ||
extraGeometriesValue.SetArray(); | ||
FOREACHC(im, _mapExtraGeometries) { | ||
rapidjson::Value extraGeometryValue; | ||
extraGeometryValue.SetObject(); | ||
orjson::SetJsonValueByKey(extraGeometryValue, "name", im->first, allocator); | ||
rapidjson::Value geometriesValue; | ||
geometriesValue.SetArray(); | ||
FOREACHC(iv, im->second) { | ||
if (!!(*iv)) { | ||
rapidjson::Value geometryValue; | ||
(*iv)->SerializeJSON(geometryValue, allocator, fUnitScale, options); | ||
geometriesValue.PushBack(geometryValue, allocator); | ||
} | ||
} | ||
extraGeometryValue.AddMember("geometries", geometriesValue, allocator); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can just reuse |
||
extraGeometriesValue.PushBack(extraGeometryValue, allocator); | ||
} | ||
value.AddMember("extraGeometries", extraGeometriesValue, allocator); | ||
} | ||
|
||
orjson::SetJsonValueByKey(value, "isStatic", _bStatic, allocator); | ||
orjson::SetJsonValueByKey(value, "isEnabled", _bIsEnabled, allocator); | ||
|
@@ -337,21 +340,30 @@ void KinBody::LinkInfo::DeserializeJSON(const rapidjson::Value &value, dReal fUn | |
} | ||
} | ||
|
||
_mapExtraGeometries.clear(); | ||
// if (value.HasMember("extraGeometries")) { | ||
// for (rapidjson::Value::ConstMemberIterator it = value["extraGeometries"].MemberBegin(); it != value["extraGeometries"].MemberEnd(); ++it) { | ||
// if (_mapExtraGeometries.find(it->name.GetString()) == _mapExtraGeometries.end()) { | ||
// _mapExtraGeometries[it->name.GetString()] = std::vector<GeometryInfoPtr>(); | ||
// } | ||
// std::vector<GeometryInfoPtr>& vgeometries = _mapExtraGeometries[it->name.GetString()]; | ||
// vgeometries.reserve(it->value.Size() + vgeometries.size()); | ||
// size_t iGeometry = 0; | ||
// for(rapidjson::Value::ConstValueIterator im = it->value.Begin(); im != it->value.End(); ++im, ++iGeometry) { | ||
// std::string id = orjson::GetStringJsonValueByKey(*im, "id"); | ||
// UpdateOrCreateInfoWithNameCheck(*im, id, vgeometries, "name", fUnitScale); | ||
// } | ||
// } | ||
// } | ||
if (value.HasMember("extraGeometries") && value["extraGeometries"].IsArray()) { | ||
for (rapidjson::Value::ConstValueIterator it = value["extraGeometries"].Begin(); it != value["extraGeometries"].End(); ++it) { | ||
std::string name; | ||
// has valid extra geometry | ||
if (it->HasMember("name")) { | ||
orjson::LoadJsonValueByKey(*it, "name", name); | ||
} | ||
else { | ||
continue; | ||
} | ||
|
||
if (_mapExtraGeometries.find(name) == _mapExtraGeometries.end()) { | ||
_mapExtraGeometries[name] = std::vector<GeometryInfoPtr>(); | ||
} | ||
|
||
if (it->HasMember("geometries")) { | ||
std::vector<GeometryInfoPtr>& vgeometries = _mapExtraGeometries[name]; | ||
vgeometries.reserve((*it)["geometries"].Size() + vgeometries.size()); | ||
for (rapidjson::Value::ConstValueIterator itGeometry = (*it)["geometries"].Begin(); itGeometry != (*it)["geometries"].End(); ++itGeometry) { | ||
UpdateOrCreateInfoWithNameCheck(*itGeometry, vgeometries, "name", fUnitScale, options); | ||
} | ||
} | ||
} | ||
} | ||
|
||
orjson::LoadJsonValueByKey(value, "isStatic", _bStatic); | ||
orjson::LoadJsonValueByKey(value, "isEnabled", _bIsEnabled); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you missed handling the
id
field here and in deserializationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for offline conversation, I think you can put
id
instead ofname
here.the
key
of thestd::map
is now represented byid
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
talked in person.
It looks we still need both
id
andname
.The user of
id
can handle limited characters.Meanwhile, we want to use the more characters for the key of the
mapExtraGeometries
.In the upcoming safety-related geometry handling (c.f. #1402), we want to define the key based on the
KinBody::GetName
, ...etc. Thus, the supported characters should be the same level asKinBody::GetName
and others.Therefore, we also need
name
field.That means, we need to introduce the new data structure for
mapExtraGeometries
...