Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • adfc2e5
  • /
  • ScorerLib
  • /
  • ConnectivityScorer.cpp
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:cfd00469ce310da1ef08bfe18504fcd8cfe6ff8f
directory badge Iframe embedding
swh:1:dir:c635832c07bb0f28337c2b5951f21be98346eb63

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
ConnectivityScorer.cpp
#include "ConnectivityScorer.h"

double ConnectivityScorer::computeDeviationByDistance(Eigen::MatrixXd& m1, Structure::Node *n2)
{
	double deviation, mean_dist, max_dist;
	Eigen::MatrixXd m2 = node2matrix(n2, this->pointLevel_);					
	distanceBetween(m1, m2, deviation, mean_dist, max_dist);
	return deviation;
}

double ConnectivityScorer::evaluate(QVector<QVector<PairRelation> > &connectPairs, QVector<PART_LANDMARK> &corres)
{	
	if (logLevel_>0 ) 
	{
		logStream_ << "normalize coeff is: " << this->normalizeCoef_ << "\n";
	}

	double maxDeviation(0.0); int num(0);
	double deviation(0.0);
	int k(0);
	for ( int j = 0; j < connectPairs.size(); ++j)
	{
		QVector<PairRelation>& pairs = connectPairs[j];
		for ( int i = 0; i < pairs.size(); ++i)
		{
			PairRelation& prb = pairs[i];

			std::vector<Structure::Node*> nodes1 = findNodesInB(prb.n1->id, graph_, corres, j==0);
			std::vector<Structure::Node*> nodes2 = findNodesInB(prb.n2->id, graph_, corres, j==0);

			
			for ( int i1 = 0; i1 < (int) nodes1.size(); ++i1)
			{
				Eigen::MatrixXd m1 = node2matrix(nodes1[i1], this->pointLevel_);

				for ( int i2 = 0; i2 < (int) nodes2.size(); ++i2)
				{					
					Structure::Link* link = RelationDetector::findLink(nodes1[i1], nodes2[i2], this->graph_);	
					if ( this->isUseLink_)
						deviation = RelationDetector::computeDeviationByLink(link);
					else
						deviation = computeDeviationByDistance(m1, nodes2[i2]);

					deviation = deviation/this->normalizeCoef_;
					deviation = deviation - prb.deviation;
					++num;
					if ( deviation > maxDeviation)
					{
						maxDeviation = deviation;
						k = num;
					}

					if (logLevel_>0 ) 
					{
						logStream_ << num << "\n";
						if ( j == 0 )
							logStream_ << "connected pairs in source shape \n";
						else
							logStream_ << "connected pairs in target shape \n";

						logStream_ << prb << "correspond to: \n";
						logStream_ << "<" << nodes1[i1]->id << ", " << nodes2[i2]->id << ">\n";
						
						if ( link !=0)
						{
							SurfaceMesh::Vector3 p1 = link->position(link->n1->id);
							SurfaceMesh::Vector3 p2 = link->position(link->n2->id);
							logStream_ << "<" << p1.x() << ", " << p1.y() << ", " << p1.z() << "; " << p2.x() << ", " << p2.y() << ", " << p2.z() << ">\n";
						}
						if (link==0)
							this->logStream_ << "link does not exist, distance: ";
						else
							this->logStream_ << "link distance: "; 

						this->logStream_ << deviation + prb.deviation << " with deviation improved by:" << deviation << "\n\n";
					}
				}//for ( int i2 = 0; i2 < (int) nodes2.size(); ++i2)
			}
		}
	}

	if (logLevel_>0 )
	{
		logStream_ << "pair: " << k << " with max deviation: "<< maxDeviation << " leads to score: " << 1/(1+maxDeviation) << "\n";		
	}
	return 1/(1+maxDeviation);
}

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API