fix meshtree params

This commit is contained in:
gabryon99 2021-09-16 18:58:41 +02:00
parent 3cd68269fd
commit b98261e29f
2 changed files with 16 additions and 8 deletions

View File

@ -472,7 +472,7 @@ namespace vcg {
AlignGlobal::LOG(elfp,"\nDormant Num: %i\n", DormantNum()); AlignGlobal::LOG(elfp,"\nDormant Num: %i\n", DormantNum());
curr = ChooseDormantWithMostDormantLink(); curr = ChooseDormantWithMostDormantLink();
if (curr == 0) { if (curr == nullptr) {
AlignGlobal::LOG(elfp,"\nFailed ChooseDormantWithMostDormantLink, chosen id:%i\n" ,0); AlignGlobal::LOG(elfp,"\nFailed ChooseDormantWithMostDormantLink, chosen id:%i\n" ,0);
break; // non ci sono piu' componenti connesse composte da piu' di una singola mesh. break; // non ci sono piu' componenti connesse composte da piu' di una singola mesh.
} }
@ -483,7 +483,7 @@ namespace vcg {
curr->Active = true; curr->Active = true;
cursid = curr->sid; cursid = curr->sid;
curr = ChooseDormantWithMostActiveLink (); curr = ChooseDormantWithMostActiveLink ();
if (curr == 0) { if (curr == nullptr) {
AlignGlobal::LOG(elfp, "\nFailed ChooseDormantWithMostActiveLink, chosen id:%i\n", 0); AlignGlobal::LOG(elfp, "\nFailed ChooseDormantWithMostActiveLink, chosen id:%i\n", 0);
} }
else { else {
@ -545,7 +545,7 @@ namespace vcg {
AlignGlobal::Node* ChooseDormantWithMostDormantLink() { AlignGlobal::Node* ChooseDormantWithMostDormantLink() {
int MaxAdjNum = 0; int MaxAdjNum = 0;
AlignGlobal::Node *BestNode = 0; AlignGlobal::Node *BestNode = nullptr;
for (auto li = std::begin(N); li != std::end(N); ++li) { for (auto li = std::begin(N); li != std::end(N); ++li) {
if (!(*li).Active) { if (!(*li).Active) {
@ -557,6 +557,11 @@ namespace vcg {
} }
} }
if (!BestNode){
std::printf("Warning! Unable to find a Node with at least a dormant link!!\n");
return nullptr;
}
assert(BestNode); assert(BestNode);
assert(!BestNode->Queued); assert(!BestNode->Queued);
assert(!BestNode->Active); assert(!BestNode->Active);
@ -567,7 +572,7 @@ namespace vcg {
AlignGlobal::Node* ChooseDormantWithMostActiveLink() { AlignGlobal::Node* ChooseDormantWithMostActiveLink() {
int MaxAdjNum = 0; int MaxAdjNum = 0;
AlignGlobal::Node* BestNode = 0; AlignGlobal::Node* BestNode = nullptr;
for (auto li = std::begin(N); li != std::end(N); ++li) { for (auto li = std::begin(N); li != std::end(N); ++li) {
if (!(*li).Active) { if (!(*li).Active) {
@ -582,7 +587,7 @@ namespace vcg {
if (!BestNode){ if (!BestNode){
// Abbiamo finito di sistemare questa componente connessa. // Abbiamo finito di sistemare questa componente connessa.
std::printf("Warning! Unable to find a Node with at least an active link!!\n"); std::printf("Warning! Unable to find a Node with at least an active link!!\n");
return 0; return nullptr;
} }
assert(BestNode); assert(BestNode);

View File

@ -39,7 +39,7 @@ namespace vcg {
class Param { class Param {
public: public:
int OGSize = 5000; int OGSize = 50000;
float arcThreshold = 0.3f; float arcThreshold = 0.3f;
float recalcThreshold = 0.1f; float recalcThreshold = 0.1f;
}; };
@ -50,12 +50,14 @@ namespace vcg {
vcg::OccupancyGrid<CMeshO, ScalarType> OG{}; vcg::OccupancyGrid<CMeshO, ScalarType> OG{};
vcg::CallBackPos* cb = vcg::DummyCallBackPos; vcg::CallBackPos* cb = vcg::DummyCallBackPos;
MeshTree() = default;
~MeshTree() { clear(); }
MeshType *MM(unsigned int i) { MeshType *MM(unsigned int i) {
return nodeMap[i]->m; return nodeMap[i]->m;
} }
MeshTree() = default;
void clear() { void clear() {
for (auto& ni : nodeMap) { for (auto& ni : nodeMap) {
@ -381,6 +383,7 @@ namespace vcg {
} }
}; };
} }
#endif //VCGLIB_MESHTREE_H #endif //VCGLIB_MESHTREE_H