-
Notifications
You must be signed in to change notification settings - Fork 147
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
Geometry class #147
Geometry class #147
Conversation
src/conv/k-g/k_parser.h
Outdated
@@ -25,12 +25,14 @@ | |||
|
|||
#ifndef KPARSER_INCLUDED | |||
#define KPARSER_INCLUDED | |||
#define FIRST_NODE 2 |
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.
? Where is it used?
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.
You see that you are getting into trouble with the primitives names. How about not having a setName()
but setBaseName()
and not getName()
but getNames()
which returns a list of names? In case of the Bot, it would be the base name with a ".bot" attached. In case of the Arbs, it could be a list of base-name + "." + number + ".arb".
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.
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.
You see that you are getting into trouble with the primitives names. How about not having a
setName()
butsetBaseName()
and notgetName()
butgetNames()
which returns a list of names? In case of the Bot, it would be the base name with a ".bot" attached. In case of the Arbs, it could be a list of base-name + "." + number + ".arb".
okay, this seems to be more coherent, I am working on it.
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.
the only problem with setBaseName() is in the case of arbs the elements numbers doesn't have to be consequent starting from (1 to n). so if we want to preserve the number of Hex element we have to keep naming the arbs following the .k file. I will update the pull request and then you can tell me what you think
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 updated with getNames() and setBaseName(), I will change also Arbs::write() and Bot::write().
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.
? Where is it used?
it's not used any more, I was trying to make a loop and I defined it. I will remove it. Edit: it is used in k_parser.cpp to fill the nodes in the vector using a loop
I can just use i_n+2 because it's a fixed format, but this seamed nicer. what do you think?
Okay, that's a reason. However, in this case, it should be kept in k_parser.cpp (declaration/definition) and a const size_t
, e.g.
const size_t FirstNode = 2;
…) so I don't name the arbs twice
…h will cause memory access error
for (std::map<std::string, rt_arb_internal>::iterator it = arbs.begin(); it != arbs.end(); it++) { | ||
std::string arbName = name; | ||
arbName += it->first; |
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.
Maybe, putting a point "." between the base name and the index?
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.
yes it's better , I will update
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.
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.
then I will handle the other arbs and I can clean the code
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.
You need the RT_ARB_INTERNAL_MAGIC here. This is for the rt_arb_internal.
arbn is very different from the arb4 ... arb8.
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.
For the Geometry class, the standard constructor and destructor should do.
src/conv/k-g/k-g.cpp
Outdated
|
||
std::string arbNumber = std::to_string(*itr); | ||
|
||
geometry.addArb(arbNumber.c_str(), point1, point2, point3, point4, point5, point6, point7, point8); |
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.
That's a lot of duplicated code. How about writing a helper function AddArb()
, which gets n1, ..., n8 as parameters?
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.
you are right, working on it.
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 also relized that I made a mistake in the condition for arb4, when the nodes.size()==4 it is also the shell element that we devided into two triangles
src/conv/k-g/arbs.cpp
Outdated
VSET(temp.pt[4], point5[0], point5[1], point5[2]); | ||
VSET(temp.pt[5], point6[0], point6[1], point6[2]); | ||
VSET(temp.pt[6], point7[0], point7[1], point7[2]); | ||
VSET(temp.pt[7], point8[0], point8[1], point8[2]); |
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.
Would it be possible, to use VMOVE() here?
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.
yes it's possible, I updated the code
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 also wrote the function AddArb, let me know what you think about it. for arb4 I will resolve it later, I am trying to undrstand the logic in LS-DYNA Solid elment.
} | ||
else { | ||
bot.addTriangle(point1, point2, point3); | ||
bot.addTriangle(point1, point3, point4); |
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.
Is here an issue with a closing bracket?
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.
No, I don't think so, I have tested the code with a solid element and shell element. I will retest now to see if there is something wrong
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 just tested it, no problems.
src/conv/k-g/region_list.cpp
Outdated
mk_addmember(names[i].c_str(), &(geometry_head.l), NULL, WMOP_UNION); | ||
mk_addmember(names[i].c_str(), &(all_head.l), NULL, WMOP_UNION); | ||
} | ||
mk_lfcomb(wdbp, geometry.getBaseName(), &geometry_head, 0); | ||
|
||
if (region_attributes.size() > 0) { | ||
writeAttributes(wdbp, region_name.c_str(), region_attributes); | ||
} | ||
|
||
mk_addmember(region_name.c_str(), &(all_head.l), NULL, WMOP_UNION); | ||
|
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.
There is a tab in this line, which should not be there.
src/conv/k-g/arbs.h
Outdated
void setName(const char* value); | ||
|
||
void addArb( | ||
const char* arbName, |
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.
Is this line break intentionally? (similar in arbs.cpp)
src/conv/k-g/region_list.cpp
Outdated
|
||
mk_addmember(bot.getName(), &(bot_head.l), NULL, WMOP_UNION); | ||
mk_lfcomb(wdbp, region_name.c_str(), &bot_head, 0); | ||
for (int i = 0; i < names.size(); i++) { |
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'm getting a compilation error on Debian bookworm here:
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/region_list.cpp: In member function ‘void RegionList::create(rt_wdb*)’:
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/region_list.cpp:111:27: error: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Werror=sign-compare]
111 | for (int i = 0; i < names.size(); i++) {
| ~~^~~~~~~~~~~~~~
Changing int
to size_t
solves this.
@@ -140,7 +142,7 @@ Bot& RegionList::getBot | |||
( | |||
const std::string& name | |||
) { | |||
return m_list[name].bot; | |||
return m_list[name].geometry.getBot(); |
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'm getting a compilation error on Debian bookworm here:
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/region_list.cpp: In member function ‘Bot& RegionList::getBot(const std::string&)’:
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/region_list.cpp:145:40: error: cannot bind non-const lvalue reference of type ‘Bot&’ to an rvalue of type ‘Bot’
145 | return m_list[name].geometry.getBot();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
getBot()
doesn't return a reference.
src/conv/k-g/geometry.cpp
Outdated
} | ||
|
||
|
||
Bot Geometry::getBot(void) const{ |
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.
You should change the return type to reference here.
A class to incapsulate the geometry of LS-DYNA part.