Skip to content

Commit

Permalink
Merge pull request #17 from Aksem/rebase-master
Browse files Browse the repository at this point in the history
  • Loading branch information
Aksem authored Mar 3, 2024
2 parents d296a4c + 2291a4b commit 51f9fbf
Show file tree
Hide file tree
Showing 20 changed files with 1,332 additions and 651 deletions.
927 changes: 635 additions & 292 deletions cola/Doxyfile

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cola/bindings/webassembly/libavoid-js
Submodule libavoid-js updated 60 files
+6 −1 .github/workflows/ci.yml
+1 −1 api_docs_build/AStarPath.html
+1 −1 api_docs_build/ActionInfo.html
+1 −1 api_docs_build/Box.html
+1 −1 api_docs_build/Checkpoint.html
+1 −1 api_docs_build/ConnEnd.html
+1 −1 api_docs_build/ConnRef.html
+1 −1 api_docs_build/EdgeInf.html
+1 −1 api_docs_build/HyperedgeImprover.html
+1 −1 api_docs_build/HyperedgeNewAndDeletedObjectLists.html
+1 −1 api_docs_build/HyperedgeRerouter.html
+1 −1 api_docs_build/HyperedgeTreeEdge.html
+1 −1 api_docs_build/HyperedgeTreeNode.html
+1 −1 api_docs_build/JunctionRef.html
+1 −1 api_docs_build/LineRep.html
+1 −1 api_docs_build/MinimumTerminalSpanningTree.html
+1 −1 api_docs_build/Obstacle.html
+1 −1 api_docs_build/Point.html
+1 −1 api_docs_build/Polygon.html
+1 −1 api_docs_build/PolygonInterface.html
+1 −1 api_docs_build/Rectangle.html
+1 −1 api_docs_build/Router.html
+128 −1 api_docs_build/ShapeConnectionPin.html
+1 −1 api_docs_build/ShapeRef.html
+1 −1 api_docs_build/VertID.html
+1 −1 api_docs_build/VertInf.html
+1 −1 api_docs_build/VoidPtr.html
+1 −1 api_docs_build/global.html
+1 −1 api_docs_build/index.html
+4 −4 build.js
+17 −0 dist/index-node.d.ts
+2 −2 dist/index-node.mjs
+3 −3 dist/index-node.mjs.map
+17 −0 dist/index.d.ts
+2 −2 dist/index.js
+3 −3 dist/index.js.map
+0 −3 dist/index.mjs
+0 −7 dist/index.mjs.map
+ dist/libavoid.wasm
+13 −9 examples/debug-dist/index.js
+13 −9 examples/debug-dist/index.mjs
+ examples/debug-dist/libavoid.wasm
+1 −1 examples/debug-dist/libavoid.wasm.map
+14 −7 examples/debug-src/generated/libavoid.js
+ examples/debug-src/generated/libavoid.wasm
+1 −1 examples/debug-src/generated/libavoid.wasm.map
+3 −0 examples/dist/index-node.mjs
+7 −0 examples/dist/index-node.mjs.map
+2 −2 examples/dist/index.js
+3 −3 examples/dist/index.js.map
+0 −3 examples/dist/index.mjs
+0 −7 examples/dist/index.mjs.map
+ examples/dist/libavoid.wasm
+1 −1 package.json
+148 −136 src/generated/libavoid.js
+148 −136 src/generated/libavoid.mjs
+ src/generated/libavoid.wasm
+5 −3 tools/generate.py
+17 −0 typings/libavoid.d.ts
+1 −0 webidl_definitions/libavoid/connectionpin.idl
929 changes: 636 additions & 293 deletions cola/libavoid/Doxyfile

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions cola/libavoid/doc/header.html

This file was deleted.

8 changes: 4 additions & 4 deletions cola/libcola/cc_nonoverlapconstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ void NonOverlapConstraints::computeOverlapForShapePairInfo(ShapePairInfo& info,
{
COLA_ASSERT(shape1.halfDim[0] == 0);
COLA_ASSERT(shape1.halfDim[1] == 0);
COLA_ASSERT(info.varIndex1 + 1 < vs[0].size());
COLA_ASSERT(info.varIndex1 + 1U < vs[0].size());
right1 = vs[0][info.varIndex1 + 1]->finalPosition;
COLA_ASSERT(info.varIndex1 + 1 < vs[1].size());
COLA_ASSERT(info.varIndex1 + 1U < vs[1].size());
top1 = vs[1][info.varIndex1 + 1]->finalPosition;
left1 -= shape1.rectPadding.min(XDIM);
bottom1 -= shape1.rectPadding.min(YDIM);
Expand All @@ -218,9 +218,9 @@ void NonOverlapConstraints::computeOverlapForShapePairInfo(ShapePairInfo& info,
{
COLA_ASSERT(shape2.halfDim[0] == 0);
COLA_ASSERT(shape2.halfDim[1] == 0);
COLA_ASSERT(info.varIndex2 + 1 < vs[0].size());
COLA_ASSERT(info.varIndex2 + 1U < vs[0].size());
right2 = vs[0][info.varIndex2 + 1]->finalPosition;
COLA_ASSERT(info.varIndex2 + 1 < vs[1].size());
COLA_ASSERT(info.varIndex2 + 1U < vs[1].size());
top2 = vs[1][info.varIndex2 + 1]->finalPosition;
left2 -= shape2.rectPadding.min(XDIM);
bottom2 -= shape2.rectPadding.min(YDIM);
Expand Down
4 changes: 2 additions & 2 deletions cola/libdialect/chains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ BendSequences Chain::computePossibleBendSequences(void) const {
try {
CardinalDir dIn = m_graph->getSepMatrix().getCardinalDir(A->id(), b->id());
inDirs.push_back(dIn);
} catch (std::runtime_error) {
} catch (std::runtime_error const&) {
// In this case the left anchor edge is not yet aligned, so we get to consider
// both possible non-aggressive alignments of it.
inDirs = possibleCardinalDirections(A, b);
Expand All @@ -438,7 +438,7 @@ BendSequences Chain::computePossibleBendSequences(void) const {
try {
CardinalDir dOut = m_graph->getSepMatrix().getCardinalDir(y->id(), Z->id());
outDirs.push_back(dOut);
} catch (std::runtime_error) {
} catch (std::runtime_error const&) {
outDirs = possibleCardinalDirections(y, Z);
}
// Now we can look up the possible bend sequences.
Expand Down
8 changes: 6 additions & 2 deletions cola/libdialect/constraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ SepDir dialect::negateSepDir(SepDir sd) {
return SepDir::RIGHT;
case SepDir::UP:
return SepDir::DOWN;
default :
COLA_ASSERT(false);
}
}

Expand Down Expand Up @@ -112,6 +114,8 @@ SepDir dialect::cardinalDirToSepDir(CardinalDir dir) {
return SepDir::WEST;
case CardinalDir::NORTH:
return SepDir::NORTH;
default:
COLA_ASSERT(false);
}
}

Expand Down Expand Up @@ -317,8 +321,8 @@ string SepPair::writeTglf(std::map<id_type, unsigned> id2ext, const SepMatrix &m
ygtStr = ygt == GapType::BDRY ? "B" : "C";
// Prepare indices.
unsigned src, tgt;
try { src = id2ext.at(this->src); } catch (std::out_of_range) { src = this->src; }
try { tgt = id2ext.at(this->tgt); } catch (std::out_of_range) { tgt = this->tgt; }
try { src = id2ext.at(this->src); } catch (std::out_of_range const&) { src = this->src; }
try { tgt = id2ext.at(this->tgt); } catch (std::out_of_range const&) { tgt = this->tgt; }
std::ostringstream ss;
// Vertically aligned
if (xgt == GapType::CENTRE && xst == SepType::EQ && xgap == 0) {
Expand Down
7 changes: 5 additions & 2 deletions cola/libdialect/graphs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ LineSegment_SP BoundingBox::buildSideSegment(CardinalDir side) const {
return std::make_shared<LineSegment>(Point(x, Y), Point(X, Y));
case CardinalDir::NORTH:
return std::make_shared<LineSegment>(Point(x, y), Point(X, y));
default:
COLA_ASSERT(false);

}
}

Expand Down Expand Up @@ -826,7 +829,7 @@ bool Graph::hasSameLayoutAs(const Graph &other, double tol, id_map *idMap) const
++it; ++jt;
}
}
} catch (std::out_of_range) {
} catch (std::out_of_range const&) {
// We invoke the .at() method of various maps, above.
// If any of these fails, the two Graphs do not have the same layout.
return false;
Expand Down Expand Up @@ -1055,7 +1058,7 @@ bool Graph::applyProjSeq(const ColaOptions &opts, ProjSeq &ps, int accept) {
double iel = opts.idealEdgeLength;
if (iel == 0) iel = getIEL();
// Do stress computations iff iel >= 0.
double lastStress;
double lastStress = 0.0;
if (iel >= 0) lastStress = computeStress();
// We will check whether all projections work.
bool allOK = true;
Expand Down
15 changes: 9 additions & 6 deletions cola/libdialect/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@ Graph_SP dialect::buildGraphFromTglf(istream &in) {
COLA_ASSERT(iss >> i1 >> i2 >> gtc >> dir >> rel1 >> rel2 >> gap);
id_type j1 = nodesByExternalId[i1]->id(),
j2 = nodesByExternalId[i2]->id();
GapType gt;
SepDir sd;
SepType st;
GapType gt{};
SepDir sd{};
SepType st{};
switch(gtc) {
case 'B': gt=GapType::BDRY; break;
case 'C': gt=GapType::CENTRE; break;
COLA_ASSERT(false);
default:
COLA_ASSERT(false);
}
switch(dir) {
case 'E': sd=SepDir::EAST; break;
Expand All @@ -127,12 +128,14 @@ Graph_SP dialect::buildGraphFromTglf(istream &in) {
case 'U': sd=SepDir::UP; break;
case 'X': sd=SepDir::RIGHT; break;
case 'Y': sd=SepDir::DOWN; break;
COLA_ASSERT(false);
default:
COLA_ASSERT(false);
}
switch(rel1) {
case '=': st=SepType::EQ; break;
case '>': st=SepType::INEQ; break;
COLA_ASSERT(false);
default:
COLA_ASSERT(false);
}
graph->getSepMatrix().addSep(j1, j2, gt, sd, st, gap);
break;
Expand Down
6 changes: 6 additions & 0 deletions cola/libdialect/ortho.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ Point Compass::vectorSigns(CompassDir d) {
case CompassDir::NW: return Point(-1, -1);
case CompassDir::NORTH: return Point( 0, -1);
case CompassDir::NE: return Point( 1, -1);
default:
COLA_ASSERT(false);
}
}

Expand Down Expand Up @@ -249,6 +251,8 @@ std::string Compass::dirToString(CompassDir d) {
case CompassDir::SW: return "SW";
case CompassDir::NW: return "NW";
case CompassDir::NE: return "NE";
default :
COLA_ASSERT(false);
}
}

Expand All @@ -258,6 +262,8 @@ std::string Compass::cardToString(CardinalDir d) {
case CardinalDir::SOUTH: return "SOUTH";
case CardinalDir::WEST: return "WEST";
case CardinalDir::NORTH: return "NORTH";
default:
COLA_ASSERT(false);
}
}

Expand Down
4 changes: 2 additions & 2 deletions cola/libdialect/quadaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ string Assignment::toString() const {
return s;
}

Quad::Quad(unsigned num) : num(num) {
Quad::Quad(unsigned int num) : num(num) {
// The only valid num's for quadrants are 0, 1, 2, 3.
COLA_ASSERT(0 <= num && num <= 3);
COLA_ASSERT(num <= 3);
}

void Quad::sortAndComputeCosts() {
Expand Down
2 changes: 1 addition & 1 deletion cola/libdialect/quadaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct Quad {
//! @brief Standard constructor.
//!
//! @param[in] num The number of this quadrant in {0, 1, 2, 3}
Quad(unsigned num);
Quad(unsigned int num);

//! @brief Add a neighbour.
void addNbr(const Nbr_SP &nbr) { nbrs.push_back(nbr); }
Expand Down
6 changes: 4 additions & 2 deletions cola/libdialect/routing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ void RoutingAdapter::recordRoutes(bool refine) {
// in the window are within epsilon of one another (in both dimensions),
// we will skip both.
vector<Point> refined_pts;
size_t N = pts.size() - 2; // the number of interior points
size_t M = pts.size();
// We expect that there are at least two route points.
COLA_ASSERT(N >= 0);
COLA_ASSERT( M >= 2);
// the number of interior points:
size_t N = M - 2;
size_t i = 0;
// We always keep the first route point.
refined_pts.push_back(pts[0]);
Expand Down
2 changes: 1 addition & 1 deletion cola/libdialect/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct Matrix2d {
std::string toString() const {
std::string s = "";
s += "\n ";
char buffer [10];
char buffer [21];
for (int j=0; j<cols; j++) {
sprintf(buffer," %2d",j);
s += std::string(buffer);
Expand Down
6 changes: 3 additions & 3 deletions cola/libtopology/topology_constraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ struct buildRoute {
};
void TopologyConstraints::
constraints(std::vector<TopologyConstraint*>& ts) const {
for_each(edges.begin(),edges.end(),bind2nd(
mem_fun(&Edge::getTopologyConstraints),&ts));
for_each(edges.begin(),edges.end(),bind(
&Edge::getTopologyConstraints,std::placeholders::_1,&ts));
}

struct PrintEdgePoint {
Expand Down Expand Up @@ -324,7 +324,7 @@ bool TopologyConstraints::
assertFeasible() const {
vector<TopologyConstraint*> ts;
constraints(ts);
for_each(ts.begin(),ts.end(),mem_fun(&TopologyConstraint::assertFeasible));
for_each(ts.begin(),ts.end(),mem_fn(&TopologyConstraint::assertFeasible));
return true;
}
bool TopologyConstraints::solve() {
Expand Down
4 changes: 2 additions & 2 deletions cola/libtopology/topology_constraints_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,8 @@ TopologyConstraints::TopologyConstraints(const vpsc::Dim axisDim, Nodes& nodes,
TopologyConstraints::
~TopologyConstraints() {
for(Edges::const_iterator i=edges.begin(),e=edges.end();i!=e;++i) {
(*i)->forEach(mem_fun(&EdgePoint::deleteBendConstraint),
mem_fun(&Segment::deleteStraightConstraints),true);
(*i)->forEach(mem_fn(&EdgePoint::deleteBendConstraint),
mem_fn(&Segment::deleteStraightConstraints),true);
}
}
} // namespace topology
10 changes: 5 additions & 5 deletions cola/libtopology/topology_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Segment* EdgePoint::prune(vpsc::Dim scanDim) {
// transfer each StraightConstraint from inSegment and outSegment
// to new Segment s.
Segment::TransferStraightConstraint transfer =
bind1st(mem_fun(&Segment::transferStraightConstraint),s);
std::bind(&Segment::transferStraightConstraint,s,std::placeholders::_1);
inSegment->forEachStraightConstraint(transfer);
outSegment->forEachStraightConstraint(transfer);

Expand Down Expand Up @@ -295,7 +295,7 @@ bool EdgePoint::assertConvexBend() const {
COLA_ASSERT(false);
}
}
} catch(runtime_error e) {
} catch(runtime_error & e) {
printf(" convexity bend point test failed: %s, dx=%f, dy=%f, cp=%f:\n",e.what(),dx,dy,cp);
printf(" (nid=%d,ri=%d):u={%f,%f}\n",
u->node->id,u->rectIntersect,u->posX(),u->posY());
Expand Down Expand Up @@ -380,7 +380,7 @@ double Edge::pathLength() const {
return totalLength;
}
bool Edge::assertConvexBends() const {
forEachEdgePoint(mem_fun(&EdgePoint::assertConvexBend),true);
forEachEdgePoint(mem_fn(&EdgePoint::assertConvexBend),true);
return true;
}
struct PointToString {
Expand Down Expand Up @@ -426,7 +426,7 @@ void Edge::getPath(ConstEdgePoints& vs) const {
forEachEdgePoint(buildPath(vs));
}
bool assertConvexBends(const Edges& es) {
for_each(es.begin(),es.end(),mem_fun(&Edge::assertConvexBends));
for_each(es.begin(),es.end(),mem_fn(&Edge::assertConvexBends));
return true;
}
#ifndef NDEBUG
Expand Down Expand Up @@ -482,7 +482,7 @@ bool assertNoSegmentRectIntersection(
}
bool assertNoZeroLengthEdgeSegments(const Edges& es) {
for(Edges::const_iterator e=es.begin();e!=es.end();++e) {
(*e)->forEachSegment(mem_fun(&Segment::assertNonZeroLength));
(*e)->forEachSegment(mem_fn(&Segment::assertNonZeroLength));
}
return true;
}
Expand Down
14 changes: 6 additions & 8 deletions cola/libtopology/topology_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <functional>
#include <vector>

#include <functional>
#include "libvpsc/assertions.h"
#include "libvpsc/rectangle.h"

Expand Down Expand Up @@ -240,9 +240,7 @@ namespace topology {
* this typedef can be used to declare a wrapper functor
* for transferStraightConstraint
*/
typedef std::binder1st<
std::mem_fun1_t<void, Segment, StraightConstraint*>
> TransferStraightConstraint;
typedef std::function<void(StraightConstraint*)> TransferStraightConstraint;
/*
* TransferStraightConstraint might for example be applied to
* forEachStraightConstraint
Expand Down Expand Up @@ -516,10 +514,10 @@ namespace topology {
void getTopologyConstraints(std::vector<TopologyConstraint*>* ts)
const {
forEach(
std::bind2nd(
std::mem_fun(&EdgePoint::getBendConstraint),ts),
std::bind2nd(
std::mem_fun(&Segment::getStraightConstraints),ts),
std::bind(
&EdgePoint::getBendConstraint,std::placeholders::_1,ts),
std::bind(
&Segment::getStraightConstraints,std::placeholders::_1,ts),
true);
}
bool assertConvexBends() const;
Expand Down
1 change: 1 addition & 0 deletions cola/libvpsc/rectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ inline bool checkIntersection(
ri.intersects=side=true;
sideX=intersection.x_;
sideY=intersection.y_;
return true;
case LineSegment::PARALLEL:
case LineSegment::NOT_INTERSECTING:
return true;
Expand Down
9 changes: 3 additions & 6 deletions cola/libvpsc/rectangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,10 @@ class Rectangle {
*/
Rectangle(double x, double X, double y, double Y,
bool allowOverlap = false);
Rectangle(Rectangle const &Other)
: minX(Other.minX)
, maxX(Other.maxX)
, minY(Other.minY)
, maxY(Other.maxY)
, overlap(Other.overlap) { }
Rectangle(const Rectangle &Other) = default;
Rectangle();
~Rectangle() {}

bool isValid(void) const;
Rectangle unionWith(const Rectangle& rhs) const;
/*
Expand Down

0 comments on commit 51f9fbf

Please sign in to comment.