Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
6fa2f060
Commit
6fa2f060
authored
Apr 07, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatted ttl library to comply with KiCad coding policy.
parent
a0fb4ed0
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
2654 additions
and
2517 deletions
+2654
-2517
hetriang.cpp
common/geometry/hetriang.cpp
+556
-560
hedart.h
include/ttl/halfedge/hedart.h
+108
-67
hetraits.h
include/ttl/halfedge/hetraits.h
+124
-111
hetriang.h
include/ttl/halfedge/hetriang.h
+277
-207
ttl.h
include/ttl/ttl.h
+1510
-1479
ttl_util.h
include/ttl/ttl_util.h
+53
-67
ratsnest_data.cpp
pcbnew/ratsnest_data.cpp
+17
-17
ratsnest_data.h
pcbnew/ratsnest_data.h
+7
-7
ratsnest_viewitem.cpp
pcbnew/ratsnest_viewitem.cpp
+2
-2
No files found.
common/geometry/hetriang.cpp
View file @
6fa2f060
This diff is collapsed.
Click to expand it.
include/ttl/halfedge/hedart.h
View file @
6fa2f060
...
@@ -40,111 +40,152 @@
...
@@ -40,111 +40,152 @@
#ifndef _HALF_EDGE_DART_
#ifndef _HALF_EDGE_DART_
#define _HALF_EDGE_DART_
#define _HALF_EDGE_DART_
#include <ttl/halfedge/hetriang.h>
#include <ttl/halfedge/hetriang.h>
namespace
hed
namespace
hed
{
{
/**
* \class Dart
//------------------------------------------------------------------------------------------------
// Dart class for the half-edge data structure
//------------------------------------------------------------------------------------------------
/** \class Dart
* \brief \b %Dart class for the half-edge data structure.
* \brief \b %Dart class for the half-edge data structure.
*
*
* See \ref api for a detailed description of how the member functions
* See \ref api for a detailed description of how the member functions
* should be implemented.
* should be implemented.
*/
*/
class
DART
{
EDGE_PTR
m_edge
;
class
Dart
{
/// Dart direction: true if dart is counterclockwise in face
bool
m_dir
;
EdgePtr
edge_
;
bool
dir_
;
// true if dart is counterclockwise in face
public
:
public
:
/// Default constructor
/// Default constructor
Dart
()
{
dir_
=
true
;
}
DART
()
{
m_dir
=
true
;
}
/// Constructor
/// Constructor
Dart
(
const
EdgePtr
&
edge
,
bool
dir
=
true
)
{
edge_
=
edge
;
dir_
=
dir
;
}
DART
(
const
EDGE_PTR
&
aEdge
,
bool
aDir
=
true
)
{
m_edge
=
aEdge
;
m_dir
=
aDir
;
}
/// Copy constructor
/// Copy constructor
Dart
(
const
Dart
&
dart
)
{
edge_
=
dart
.
edge_
;
dir_
=
dart
.
dir_
;
}
DART
(
const
DART
&
aDart
)
{
m_edge
=
aDart
.
m_edge
;
m_dir
=
aDart
.
m_dir
;
}
/// Destructor
/// Destructor
~
Dart
()
{}
~
DART
()
{
}
/// Assignment operator
/// Assignment operator
Dart
&
operator
=
(
const
Dart
&
dart
)
{
DART
&
operator
=
(
const
DART
&
aDart
)
if
(
this
==
&
dart
)
{
if
(
this
==
&
aDart
)
return
*
this
;
return
*
this
;
edge_
=
dart
.
edge_
;
dir_
=
dart
.
dir_
;
m_edge
=
aDart
.
m_edge
;
m_dir
=
aDart
.
m_dir
;
return
*
this
;
return
*
this
;
}
}
/// Comparing dart objects
/// Comparing dart objects
bool
operator
==
(
const
Dart
&
dart
)
const
{
bool
operator
==
(
const
DART
&
aDart
)
const
if
(
dart
.
edge_
==
edge_
&&
dart
.
dir_
==
dir_
)
{
return
true
;
return
(
aDart
.
m_edge
==
m_edge
&&
aDart
.
m_dir
==
m_dir
);
return
false
;
}
}
/// Comparing dart objects
/// Comparing dart objects
bool
operator
!=
(
const
Dart
&
dart
)
const
{
bool
operator
!=
(
const
DART
&
aDart
)
const
return
!
(
dart
==*
this
);
{
return
!
(
aDart
==
*
this
);
}
}
/// Maps the dart to a different node
/// Maps the dart to a different node
Dart
&
alpha0
()
{
dir_
=
!
dir_
;
return
*
this
;
}
DART
&
Alpha0
()
{
m_dir
=
!
m_dir
;
return
*
this
;
}
/// Maps the dart to a different edge
/// Maps the dart to a different edge
Dart
&
alpha1
()
{
DART
&
Alpha1
()
if
(
dir_
)
{
{
edge_
=
edge_
->
getNextEdgeInFace
()
->
getNextEdgeInFace
();
if
(
m_dir
)
dir_
=
false
;
{
m_edge
=
m_edge
->
GetNextEdgeInFace
()
->
GetNextEdgeInFace
();
m_dir
=
false
;
}
}
else
{
else
edge_
=
edge_
->
getNextEdgeInFace
();
{
dir_
=
true
;
m_edge
=
m_edge
->
GetNextEdgeInFace
();
m_dir
=
true
;
}
}
return
*
this
;
return
*
this
;
}
}
/// Maps the dart to a different triangle. \b Note: the dart is not changed if it is at the boundary!
/// Maps the dart to a different triangle. \b Note: the dart is not changed if it is at the boundary!
Dart
&
alpha2
()
{
DART
&
Alpha2
()
if
(
edge_
->
getTwinEdge
())
{
{
edge_
=
edge_
->
getTwinEdge
();
if
(
m_edge
->
GetTwinEdge
()
)
dir_
=
!
dir_
;
{
m_edge
=
m_edge
->
GetTwinEdge
();
m_dir
=
!
m_dir
;
}
}
// else, the dart is at the boundary and should not be changed
// else, the dart is at the boundary and should not be changed
return
*
this
;
return
*
this
;
}
}
// Utilities not required by TTL
// -----------------------------
/** @name Utilities not required by TTL */
/** @name Utilities not required by TTL */
//@{
//@{
void
Init
(
const
EDGE_PTR
&
aEdge
,
bool
aDir
=
true
)
{
m_edge
=
aEdge
;
m_dir
=
aDir
;
}
double
X
()
const
{
return
GetNode
()
->
GetX
();
}
void
init
(
const
EdgePtr
&
edge
,
bool
dir
=
true
)
{
edge_
=
edge
;
dir_
=
dir
;
}
double
Y
()
const
{
return
GetNode
()
->
GetY
();
}
double
x
()
const
{
return
getNode
()
->
GetX
();
}
// x-coordinate of source node
bool
IsCCW
()
const
double
y
()
const
{
return
getNode
()
->
GetY
();
}
// y-coordinate of source node
{
return
m_dir
;
}
bool
isCounterClockWise
()
const
{
return
dir_
;
}
const
NODE_PTR
&
GetNode
()
const
{
return
m_dir
?
m_edge
->
GetSourceNode
()
:
m_edge
->
GetTargetNode
();
}
const
NodePtr
&
getNode
()
const
{
return
dir_
?
edge_
->
getSourceNode
()
:
edge_
->
getTargetNode
();
}
const
NODE_PTR
&
GetOppositeNode
()
const
const
NodePtr
&
getOppositeNode
()
const
{
return
dir_
?
edge_
->
getTargetNode
()
:
edge_
->
getSourceNode
();
}
{
EdgePtr
&
getEdge
()
{
return
edge_
;
}
return
m_dir
?
m_edge
->
GetTargetNode
()
:
m_edge
->
GetSourceNode
();
}
//@} // End of Utilities not required by TTL
EDGE_PTR
&
GetEdge
()
{
return
m_edge
;
}
};
//@} // End of Utilities not required by TTL
};
}
;
// End of hed namespace
}
// End of hed namespace
#endif
#endif
include/ttl/halfedge/hetraits.h
View file @
6fa2f060
...
@@ -40,19 +40,13 @@
...
@@ -40,19 +40,13 @@
#ifndef _HALF_EDGE_TRAITS_
#ifndef _HALF_EDGE_TRAITS_
#define _HALF_EDGE_TRAITS_
#define _HALF_EDGE_TRAITS_
#include <ttl/halfedge/hetriang.h>
#include <ttl/halfedge/hetriang.h>
#include <ttl/halfedge/hedart.h>
#include <ttl/halfedge/hedart.h>
namespace
hed
namespace
hed
{
{
/**
* \struct TTLtraits
//------------------------------------------------------------------------------------------------
// Traits class for the half-edge data structure
//------------------------------------------------------------------------------------------------
/** \struct TTLtraits
* \brief \b Traits class (static struct) for the half-edge data structure.
* \brief \b Traits class (static struct) for the half-edge data structure.
*
*
* The member functions are those required by different function templates
* The member functions are those required by different function templates
...
@@ -64,112 +58,131 @@ namespace hed {
...
@@ -64,112 +58,131 @@ namespace hed {
* half-edge data structure.
* half-edge data structure.
*
*
* \see \ref api
* \see \ref api
*
*/
*/
struct
TTLtraits
struct
TTLtraits
{
{
/**
/** The floating point type used in calculations
* The floating point type used in calculations involving scalar products and cross products.
* involving scalar products and cross products.
*/
*/
typedef
double
real_type
;
typedef
double
REAL_TYPE
;
//----------------------------------------------------------------------------------------------
// ------------------------------- Geometric Predicates Group ---------------------------------
//----------------------------------------------------------------------------------------------
/** @name Geometric Predicates */
/** @name Geometric Predicates */
//@{
//@{
/**
//----------------------------------------------------------------------------------------------
* Scalar product between two 2D vectors represented as darts.\n
/** Scalar product between two 2D vectors represented as darts.\n
*
*
* ttl_util::scalarProduct2d can be used.
* ttl_util::scalarProduct2d can be used.
*/
*/
static
real_type
scalarProduct2d
(
const
Dart
&
v1
,
const
Dart
&
v2
)
{
static
REAL_TYPE
ScalarProduct2D
(
const
DART
&
aV1
,
const
DART
&
aV2
)
Dart
v10
=
v1
;
v10
.
alpha0
();
{
Dart
v20
=
v2
;
v20
.
alpha0
();
DART
v10
=
aV1
;
return
ttl_util
::
scalarProduct2d
(
v10
.
x
()
-
v1
.
x
(),
v10
.
y
()
-
v1
.
y
(),
v10
.
Alpha0
();
v20
.
x
()
-
v2
.
x
(),
v20
.
y
()
-
v2
.
y
());
}
DART
v20
=
aV2
;
v20
.
Alpha0
();
//----------------------------------------------------------------------------------------------
return
ttl_util
::
ScalarProduct2D
(
v10
.
X
()
-
aV1
.
X
(),
v10
.
Y
()
-
aV1
.
Y
(),
/** Scalar product between two 2D vectors.
v20
.
X
()
-
aV2
.
X
(),
v20
.
Y
()
-
aV2
.
Y
()
);
}
/**
* Scalar product between two 2D vectors.
* The first vector is represented by a dart \e v, and the second
* The first vector is represented by a dart \e v, and the second
* vector has direction from the source node of \e v to the point \e p.\n
* vector has direction from the source node of \e v to the point \e p.\n
*
*
* ttl_util::scalarProduct2d
can be used.
* ttl_util::ScalarProduct2D
can be used.
*/
*/
static
real_type
scalarProduct2d
(
const
Dart
&
v
,
const
NodePtr
&
p
)
{
static
REAL_TYPE
ScalarProduct2D
(
const
DART
&
aV
,
const
NODE_PTR
&
aP
)
Dart
d0
=
v
;
d0
.
alpha0
();
{
return
ttl_util
::
scalarProduct2d
(
d0
.
x
()
-
v
.
x
(),
d0
.
y
()
-
v
.
y
(),
DART
d0
=
aV
;
p
->
GetX
()
-
v
.
x
(),
p
->
GetY
()
-
v
.
y
());
d0
.
Alpha0
();
}
return
ttl_util
::
ScalarProduct2D
(
d0
.
X
()
-
aV
.
X
(),
d0
.
Y
()
-
aV
.
Y
(),
aP
->
GetX
()
-
aV
.
X
(),
aP
->
GetY
()
-
aV
.
Y
()
);
}
/
/----------------------------------------------------------------------------------------------
/
**
/*
* Cross product between two vectors in the plane represented as darts.
* Cross product between two vectors in the plane represented as darts.
* The z-component of the cross product is returned.\n
* The z-component of the cross product is returned.\n
*
*
* ttl_util::crossProduct2d
can be used.
* ttl_util::CrossProduct2D
can be used.
*/
*/
static
real_type
crossProduct2d
(
const
Dart
&
v1
,
const
Dart
&
v2
)
{
static
REAL_TYPE
CrossProduct2D
(
const
DART
&
aV1
,
const
DART
&
aV2
)
Dart
v10
=
v1
;
v10
.
alpha0
();
{
Dart
v20
=
v2
;
v20
.
alpha0
();
DART
v10
=
aV1
;
return
ttl_util
::
crossProduct2d
(
v10
.
x
()
-
v1
.
x
(),
v10
.
y
()
-
v1
.
y
(),
v10
.
Alpha0
();
v20
.
x
()
-
v2
.
x
(),
v20
.
y
()
-
v2
.
y
());
}
DART
v20
=
aV2
;
v20
.
Alpha0
();
//----------------------------------------------------------------------------------------------
return
ttl_util
::
CrossProduct2D
(
v10
.
X
()
-
aV1
.
X
(),
v10
.
Y
()
-
aV1
.
Y
(),
/** Cross product between two vectors in the plane.
v20
.
X
()
-
aV2
.
X
(),
v20
.
Y
()
-
aV2
.
Y
()
);
}
/**
* Cross product between two vectors in the plane.
* The first vector is represented by a dart \e v, and the second
* The first vector is represented by a dart \e v, and the second
* vector has direction from the source node of \e v to the point \e p.
* vector has direction from the source node of \e v to the point \e p.
* The z-component of the cross product is returned.\n
* The z-component of the cross product is returned.\n
*
*
* ttl_util::c
rossProduct2d can be used.
* ttl_util::C
rossProduct2d can be used.
*/
*/
static
real_type
crossProduct2d
(
const
Dart
&
v
,
const
NodePtr
&
p
)
{
static
REAL_TYPE
CrossProduct2D
(
const
DART
&
aV
,
const
NODE_PTR
&
aP
)
Dart
d0
=
v
;
d0
.
alpha0
();
{
return
ttl_util
::
crossProduct2d
(
d0
.
x
()
-
v
.
x
(),
d0
.
y
()
-
v
.
y
(),
DART
d0
=
aV
;
p
->
GetX
()
-
v
.
x
(),
p
->
GetY
()
-
v
.
y
());
d0
.
Alpha0
();
}
return
ttl_util
::
CrossProduct2D
(
d0
.
X
()
-
aV
.
X
(),
d0
.
Y
()
-
aV
.
Y
(),
aP
->
GetX
()
-
aV
.
X
(),
aP
->
GetY
()
-
aV
.
Y
()
);
}
/
/----------------------------------------------------------------------------------------------
/
**
/*
* Let \e n1 and \e n2 be the nodes associated with two darts, and let \e p
* Let \e n1 and \e n2 be the nodes associated with two darts, and let \e p
* be a point in the plane. Return a positive value if \e n1, \e n2,
* be a point in the plane. Return a positive value if \e n1, \e n2,
* and \e p occur in counterclockwise order; a negative value if they occur
* and \e p occur in counterclockwise order; a negative value if they occur
* in clockwise order; and zero if they are collinear.
* in clockwise order; and zero if they are collinear.
*/
*/
static
real_type
orient2d
(
const
Dart
&
n1
,
const
Dart
&
n2
,
const
NodePtr
&
p
)
{
static
REAL_TYPE
Orient2D
(
const
DART
&
aN1
,
const
DART
&
aN2
,
const
NODE_PTR
&
aP
)
real_type
pa
[
2
];
real_type
pb
[
2
];
real_type
pc
[
2
];
{
pa
[
0
]
=
n1
.
x
();
pa
[
1
]
=
n1
.
y
();
REAL_TYPE
pa
[
2
];
pb
[
0
]
=
n2
.
x
();
pb
[
1
]
=
n2
.
y
();
REAL_TYPE
pb
[
2
];
pc
[
0
]
=
p
->
GetX
();
pc
[
1
]
=
p
->
GetY
();
REAL_TYPE
pc
[
2
];
return
ttl_util
::
orient2dfast
(
pa
,
pb
,
pc
);
pa
[
0
]
=
aN1
.
X
();
pa
[
1
]
=
aN1
.
Y
();
pb
[
0
]
=
aN2
.
X
();
pb
[
1
]
=
aN2
.
Y
();
pc
[
0
]
=
aP
->
GetX
();
pc
[
1
]
=
aP
->
GetY
();
return
ttl_util
::
Orient2DFast
(
pa
,
pb
,
pc
);
}
}
/**
//----------------------------------------------------------------------------------------------
* This is the same predicate as represented with the function above,
/** This is the same predicate as represented with the function above,
* but with a slighty different interface:
* but with a slighty different interface:
* The last parameter is given as a dart where the source node of the dart
* The last parameter is given as a dart where the source node of the dart
* represents a point in the plane.
* represents a point in the plane.
* This function is required for constrained triangulation.
* This function is required for constrained triangulation.
*/
*/
static
real_type
orient2d
(
const
Dart
&
n1
,
const
Dart
&
n2
,
const
Dart
&
p
)
{
static
REAL_TYPE
Orient2D
(
const
DART
&
aN1
,
const
DART
&
aN2
,
const
DART
&
aP
)
real_type
pa
[
2
];
real_type
pb
[
2
];
real_type
pc
[
2
];
{
pa
[
0
]
=
n1
.
x
();
pa
[
1
]
=
n1
.
y
();
REAL_TYPE
pa
[
2
];
pb
[
0
]
=
n2
.
x
();
pb
[
1
]
=
n2
.
y
();
REAL_TYPE
pb
[
2
];
pc
[
0
]
=
p
.
x
();
pc
[
1
]
=
p
.
y
();
REAL_TYPE
pc
[
2
];
return
ttl_util
::
orient2dfast
(
pa
,
pb
,
pc
);
pa
[
0
]
=
aN1
.
X
();
pa
[
1
]
=
aN1
.
Y
();
pb
[
0
]
=
aN2
.
X
();
pb
[
1
]
=
aN2
.
Y
();
pc
[
0
]
=
aP
.
X
();
pc
[
1
]
=
aP
.
Y
();
return
ttl_util
::
Orient2DFast
(
pa
,
pb
,
pc
);
}
}
//@} // End of Geometric Predicates Group
//@} // End of Geometric Predicates Group
};
};
};
// End of hed namespace
};
// End of hed namespace
...
...
include/ttl/halfedge/hetriang.h
View file @
6fa2f060
This diff is collapsed.
Click to expand it.
include/ttl/ttl.h
View file @
6fa2f060
This diff is collapsed.
Click to expand it.
include/ttl/ttl_util.h
View file @
6fa2f060
...
@@ -3,11 +3,11 @@
...
@@ -3,11 +3,11 @@
* Applied Mathematics, Norway.
* Applied Mathematics, Norway.
*
*
* Contact information: E-mail: tor.dokken@sintef.no
* Contact information: E-mail: tor.dokken@sintef.no
* SINTEF ICT, De
partment of Applied Mathematics,
* SINTEF ICT, De
aPArtment of Applied Mathematics,
* P.O. Box 124 Blindern,
* P.O. Box 124 Blindern,
* 0314 Oslo, Norway.
* 0314 Oslo, Norway.
*
*
* This file is
pa
rt of TTL.
* This file is
aPA
rt of TTL.
*
*
* TTL is free software: you can redistribute it and/or modify
* TTL is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* it under the terms of the GNU Affero General Public License as
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
*
*
* TTL is distributed in the hope that it will be useful,
* TTL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A
aPARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public
* You should have received a copy of the GNU Affero General Public
...
@@ -40,28 +40,22 @@
...
@@ -40,28 +40,22 @@
#ifndef _TTL_UTIL_H_
#ifndef _TTL_UTIL_H_
#define _TTL_UTIL_H_
#define _TTL_UTIL_H_
#include <vector>
#include <vector>
#include <algorithm>
#include <algorithm>
#ifdef _MSC_VER
#ifdef _MSC_VER
# if _MSC_VER < 1300
# if _MSC_VER < 1300
# include <minmax.h>
# include <minmax.h>
# endif
# endif
#endif
#endif
//using namespace std;
/** \brief Utilities
/** \brief Utilities
*
*
* This name s
pa
ce contains utility functions for TTL.\n
* This name s
aPA
ce contains utility functions for TTL.\n
*
*
* Point and vector algebra such as scalar product and cross product
* Point and vector algebra such as scalar product and cross product
* between vectors are implemented here.
* between vectors are implemented here.
* These functions are required by functions in the \ref ttl names
pa
ce,
* These functions are required by functions in the \ref ttl names
aPA
ce,
* where they are assumed to be present in the \ref hed::TTLtraits "TTLtraits" class.
* where they are assumed to be present in the \ref hed::TTLtraits "TTLtraits" class.
* Thus, the user can call these functions from the traits class.
* Thus, the user can call these functions from the traits class.
* For efficiency reasons, the user may consider implementing these
* For efficiency reasons, the user may consider implementing these
...
@@ -77,51 +71,41 @@
...
@@ -77,51 +71,41 @@
* ttl and \ref api
* ttl and \ref api
*
*
* \author
* \author
* Øyvind Hjelle, oyvindhj@ifi.uio.no
*
�
yvind Hjelle, oyvindhj@ifi.uio.no
*/
*/
namespace
ttl_util
namespace
ttl_util
{
{
/** @name Computational geometry */
//@{
//------------------------------------------------------------------------------------------------
/** Scalar product between two 2D vectors.
// ------------------------------ Computational Geometry Group ----------------------------------
//------------------------------------------------------------------------------------------------
/** @name Computational geometry */
//@{
//------------------------------------------------------------------------------------------------
/** Scalar product between two 2D vectors.
*
*
* \pa
r Returns:
* \aPA
r Returns:
* \code
* \code
* dx1*dx2 + dy1*dy
2
* aDX1*aDX2 + aDY1*aDY
2
* \endcode
* \endcode
*/
*/
template
<
class
real_type
>
template
<
class
REAL_TYPE
>
real_type
scalarProduct2d
(
real_type
dx1
,
real_type
dy1
,
real_type
dx2
,
real_type
dy2
)
{
REAL_TYPE
ScalarProduct2D
(
REAL_TYPE
aDX1
,
REAL_TYPE
aDY1
,
REAL_TYPE
aDX2
,
REAL_TYPE
aDY2
)
return
dx1
*
dx2
+
dy1
*
dy2
;
{
}
return
aDX1
*
aDX2
+
aDY1
*
aDY2
;
}
//------------------------------------------------------------------------------------------------
/** Cross product between two 2D vectors. (The z-component of the actual cross product.)
/** Cross product between two 2D vectors. (The z-component of the actual cross product.)
*
*
* \pa
r Returns:
* \aPA
r Returns:
* \code
* \code
* dx1*dy2 - dy1*dx
2
* aDX1*aDY2 - aDY1*aDX
2
* \endcode
* \endcode
*/
*/
template
<
class
real_type
>
template
<
class
REAL_TYPE
>
real_type
crossProduct2d
(
real_type
dx1
,
real_type
dy1
,
real_type
dx2
,
real_type
dy2
)
{
REAL_TYPE
CrossProduct2D
(
REAL_TYPE
aDX1
,
REAL_TYPE
aDY1
,
REAL_TYPE
aDX2
,
REAL_TYPE
aDY2
)
return
dx1
*
dy2
-
dy1
*
dx2
;
{
}
return
aDX1
*
aDY2
-
aDY1
*
aDX2
;
}
//------------------------------------------------------------------------------------------------
/** Returns a positive value if the 2D nodes/points \e aPA, \e aPB, and
/** Returns a positive value if the 2D nodes/points \e pa, \e pb, and
* \e aPC occur in counterclockwise order; a negative value if they occur
* \e pc occur in counterclockwise order; a negative value if they occur
* in clockwise order; and zero if they are collinear.
* in clockwise order; and zero if they are collinear.
*
*
* \note
* \note
...
@@ -129,15 +113,17 @@ namespace ttl_util {
...
@@ -129,15 +113,17 @@ namespace ttl_util {
* exact arithmetic schemes by Jonathan Richard Shewchuk. See
* exact arithmetic schemes by Jonathan Richard Shewchuk. See
* http://www-2.cs.cmu.edu/~quake/robust.html
* http://www-2.cs.cmu.edu/~quake/robust.html
*/
*/
template
<
class
real_type
>
template
<
class
REAL_TYPE
>
real_type
orient2dfast
(
real_type
pa
[
2
],
real_type
pb
[
2
],
real_type
pc
[
2
])
{
REAL_TYPE
Orient2DFast
(
REAL_TYPE
aPA
[
2
],
REAL_TYPE
aPB
[
2
],
REAL_TYPE
aPC
[
2
]
)
real_type
acx
=
pa
[
0
]
-
pc
[
0
];
{
real_type
bcx
=
pb
[
0
]
-
pc
[
0
];
REAL_TYPE
acx
=
aPA
[
0
]
-
aPC
[
0
];
real_type
acy
=
pa
[
1
]
-
pc
[
1
];
REAL_TYPE
bcx
=
aPB
[
0
]
-
aPC
[
0
];
real_type
bcy
=
pb
[
1
]
-
pc
[
1
];
REAL_TYPE
acy
=
aPA
[
1
]
-
aPC
[
1
];
REAL_TYPE
bcy
=
aPB
[
1
]
-
aPC
[
1
];
return
acx
*
bcy
-
acy
*
bcx
;
return
acx
*
bcy
-
acy
*
bcx
;
}
}
}
;
// End of ttl_util namespace scope
}
// namespace ttl_util
#endif // _TTL_UTIL_H_
#endif // _TTL_UTIL_H_
pcbnew/ratsnest_data.cpp
View file @
6fa2f060
...
@@ -68,7 +68,7 @@ bool sortDistance( const RN_NODE_PTR& aOrigin, const RN_NODE_PTR& aNode1,
...
@@ -68,7 +68,7 @@ bool sortDistance( const RN_NODE_PTR& aOrigin, const RN_NODE_PTR& aNode1,
bool
sortWeight
(
const
RN_EDGE_PTR
&
aEdge1
,
const
RN_EDGE_PTR
&
aEdge2
)
bool
sortWeight
(
const
RN_EDGE_PTR
&
aEdge1
,
const
RN_EDGE_PTR
&
aEdge2
)
{
{
return
aEdge1
->
getWeight
()
<
aEdge2
->
g
etWeight
();
return
aEdge1
->
GetWeight
()
<
aEdge2
->
G
etWeight
();
}
}
...
@@ -92,7 +92,7 @@ bool operator!=( const RN_NODE_PTR& aFirst, const RN_NODE_PTR& aSecond )
...
@@ -92,7 +92,7 @@ bool operator!=( const RN_NODE_PTR& aFirst, const RN_NODE_PTR& aSecond )
bool
isEdgeConnectingNode
(
const
RN_EDGE_PTR
&
aEdge
,
const
RN_NODE_PTR
&
aNode
)
bool
isEdgeConnectingNode
(
const
RN_EDGE_PTR
&
aEdge
,
const
RN_NODE_PTR
&
aNode
)
{
{
return
aEdge
->
getSourceNode
()
==
aNode
||
aEdge
->
g
etTargetNode
()
==
aNode
;
return
aEdge
->
GetSourceNode
()
==
aNode
||
aEdge
->
G
etTargetNode
()
==
aNode
;
}
}
...
@@ -125,8 +125,8 @@ std::vector<RN_EDGE_PTR>* kruskalMST( RN_LINKS::RN_EDGE_LIST& aEdges,
...
@@ -125,8 +125,8 @@ std::vector<RN_EDGE_PTR>* kruskalMST( RN_LINKS::RN_EDGE_LIST& aEdges,
{
{
RN_EDGE_PTR
&
dt
=
*
aEdges
.
begin
();
RN_EDGE_PTR
&
dt
=
*
aEdges
.
begin
();
int
srcTag
=
tags
[
dt
->
g
etSourceNode
()];
int
srcTag
=
tags
[
dt
->
G
etSourceNode
()];
int
trgTag
=
tags
[
dt
->
g
etTargetNode
()];
int
trgTag
=
tags
[
dt
->
G
etTargetNode
()];
// Check if by adding this edge we are going to join two different forests
// Check if by adding this edge we are going to join two different forests
if
(
srcTag
!=
trgTag
)
if
(
srcTag
!=
trgTag
)
...
@@ -139,7 +139,7 @@ std::vector<RN_EDGE_PTR>* kruskalMST( RN_LINKS::RN_EDGE_LIST& aEdges,
...
@@ -139,7 +139,7 @@ std::vector<RN_EDGE_PTR>* kruskalMST( RN_LINKS::RN_EDGE_LIST& aEdges,
// Move nodes that were marked with old tag to the list marked with the new tag
// Move nodes that were marked with old tag to the list marked with the new tag
cycles
[
srcTag
].
splice
(
cycles
[
srcTag
].
end
(),
cycles
[
trgTag
]
);
cycles
[
srcTag
].
splice
(
cycles
[
srcTag
].
end
(),
cycles
[
trgTag
]
);
if
(
dt
->
g
etWeight
()
==
0
)
// Skip already existing connections (weight == 0)
if
(
dt
->
G
etWeight
()
==
0
)
// Skip already existing connections (weight == 0)
{
{
mstExpectedSize
--
;
mstExpectedSize
--
;
}
}
...
@@ -148,9 +148,9 @@ std::vector<RN_EDGE_PTR>* kruskalMST( RN_LINKS::RN_EDGE_LIST& aEdges,
...
@@ -148,9 +148,9 @@ std::vector<RN_EDGE_PTR>* kruskalMST( RN_LINKS::RN_EDGE_LIST& aEdges,
// Do a copy of edge, but make it RN_EDGE_MST. In contrary to RN_EDGE,
// Do a copy of edge, but make it RN_EDGE_MST. In contrary to RN_EDGE,
// RN_EDGE_MST saves both source and target node and does not require any other
// RN_EDGE_MST saves both source and target node and does not require any other
// edges to exist for getting source/target nodes
// edges to exist for getting source/target nodes
RN_EDGE_MST_PTR
newEdge
=
boost
::
make_shared
<
RN_EDGE_MST
>
(
dt
->
g
etSourceNode
(),
RN_EDGE_MST_PTR
newEdge
=
boost
::
make_shared
<
RN_EDGE_MST
>
(
dt
->
G
etSourceNode
(),
dt
->
g
etTargetNode
(),
dt
->
G
etTargetNode
(),
dt
->
g
etWeight
()
);
dt
->
G
etWeight
()
);
mst
->
push_back
(
newEdge
);
mst
->
push_back
(
newEdge
);
++
mstSize
;
++
mstSize
;
}
}
...
@@ -169,8 +169,8 @@ std::vector<RN_EDGE_PTR>* kruskalMST( RN_LINKS::RN_EDGE_LIST& aEdges,
...
@@ -169,8 +169,8 @@ std::vector<RN_EDGE_PTR>* kruskalMST( RN_LINKS::RN_EDGE_LIST& aEdges,
void
RN_NET
::
validateEdge
(
RN_EDGE_PTR
&
aEdge
)
void
RN_NET
::
validateEdge
(
RN_EDGE_PTR
&
aEdge
)
{
{
RN_NODE_PTR
source
=
aEdge
->
g
etSourceNode
();
RN_NODE_PTR
source
=
aEdge
->
G
etSourceNode
();
RN_NODE_PTR
target
=
aEdge
->
g
etTargetNode
();
RN_NODE_PTR
target
=
aEdge
->
G
etTargetNode
();
bool
valid
=
true
;
bool
valid
=
true
;
// If any of nodes belonging to the edge has the flag set,
// If any of nodes belonging to the edge has the flag set,
...
@@ -280,13 +280,13 @@ void RN_NET::compute()
...
@@ -280,13 +280,13 @@ void RN_NET::compute()
std
::
partial_sort_copy
(
boardNodes
.
begin
(),
boardNodes
.
end
(),
nodes
.
begin
(),
nodes
.
end
()
);
std
::
partial_sort_copy
(
boardNodes
.
begin
(),
boardNodes
.
end
(),
nodes
.
begin
(),
nodes
.
end
()
);
TRIANGULATOR
triangulator
;
TRIANGULATOR
triangulator
;
triangulator
.
c
reateDelaunay
(
nodes
.
begin
(),
nodes
.
end
()
);
triangulator
.
C
reateDelaunay
(
nodes
.
begin
(),
nodes
.
end
()
);
boost
::
scoped_ptr
<
RN_LINKS
::
RN_EDGE_LIST
>
triangEdges
(
triangulator
.
g
etEdges
()
);
boost
::
scoped_ptr
<
RN_LINKS
::
RN_EDGE_LIST
>
triangEdges
(
triangulator
.
G
etEdges
()
);
// Compute weight/distance for edges resulting from triangulation
// Compute weight/distance for edges resulting from triangulation
RN_LINKS
::
RN_EDGE_LIST
::
iterator
eit
,
eitEnd
;
RN_LINKS
::
RN_EDGE_LIST
::
iterator
eit
,
eitEnd
;
for
(
eit
=
(
*
triangEdges
).
begin
(),
eitEnd
=
(
*
triangEdges
).
end
();
eit
!=
eitEnd
;
++
eit
)
for
(
eit
=
(
*
triangEdges
).
begin
(),
eitEnd
=
(
*
triangEdges
).
end
();
eit
!=
eitEnd
;
++
eit
)
(
*
eit
)
->
setWeight
(
getDistance
(
(
*
eit
)
->
getSourceNode
(),
(
*
eit
)
->
g
etTargetNode
()
)
);
(
*
eit
)
->
SetWeight
(
getDistance
(
(
*
eit
)
->
GetSourceNode
(),
(
*
eit
)
->
G
etTargetNode
()
)
);
// Add the currently existing connections list to the results of triangulation
// Add the currently existing connections list to the results of triangulation
std
::
copy
(
boardEdges
.
begin
(),
boardEdges
.
end
(),
std
::
front_inserter
(
*
triangEdges
)
);
std
::
copy
(
boardEdges
.
begin
(),
boardEdges
.
end
(),
std
::
front_inserter
(
*
triangEdges
)
);
...
@@ -508,8 +508,8 @@ void RN_NET::RemoveItem( const TRACK* aTrack )
...
@@ -508,8 +508,8 @@ void RN_NET::RemoveItem( const TRACK* aTrack )
RN_EDGE_PTR
&
edge
=
m_tracks
.
at
(
aTrack
);
RN_EDGE_PTR
&
edge
=
m_tracks
.
at
(
aTrack
);
// Save nodes, so they can be cleared later
// Save nodes, so they can be cleared later
RN_NODE_PTR
aBegin
=
edge
->
g
etSourceNode
();
RN_NODE_PTR
aBegin
=
edge
->
G
etSourceNode
();
RN_NODE_PTR
aEnd
=
edge
->
g
etTargetNode
();
RN_NODE_PTR
aEnd
=
edge
->
G
etTargetNode
();
m_links
.
RemoveConnection
(
edge
);
m_links
.
RemoveConnection
(
edge
);
// Remove nodes associated with the edge. It is done in a safe way, there is a check
// Remove nodes associated with the edge. It is done in a safe way, there is a check
...
@@ -696,8 +696,8 @@ std::list<RN_NODE_PTR> RN_NET::GetNodes( const BOARD_CONNECTED_ITEM* aItem ) con
...
@@ -696,8 +696,8 @@ std::list<RN_NODE_PTR> RN_NET::GetNodes( const BOARD_CONNECTED_ITEM* aItem ) con
const
TRACK
*
track
=
static_cast
<
const
TRACK
*>
(
aItem
);
const
TRACK
*
track
=
static_cast
<
const
TRACK
*>
(
aItem
);
RN_EDGE_PTR
edge
=
m_tracks
.
at
(
track
);
RN_EDGE_PTR
edge
=
m_tracks
.
at
(
track
);
nodes
.
push_back
(
edge
->
g
etSourceNode
()
);
nodes
.
push_back
(
edge
->
G
etSourceNode
()
);
nodes
.
push_back
(
edge
->
g
etTargetNode
()
);
nodes
.
push_back
(
edge
->
G
etTargetNode
()
);
}
}
break
;
break
;
...
...
pcbnew/ratsnest_data.h
View file @
6fa2f060
...
@@ -50,13 +50,13 @@ class ZONE_CONTAINER;
...
@@ -50,13 +50,13 @@ class ZONE_CONTAINER;
class
CPolyPt
;
class
CPolyPt
;
// Preserve KiCad coding style policy
// Preserve KiCad coding style policy
typedef
hed
::
N
ode
RN_NODE
;
typedef
hed
::
N
ODE
RN_NODE
;
typedef
hed
::
N
odePtr
RN_NODE_PTR
;
typedef
hed
::
N
ODE_PTR
RN_NODE_PTR
;
typedef
hed
::
E
dge
RN_EDGE
;
typedef
hed
::
E
DGE
RN_EDGE
;
typedef
hed
::
E
dgePtr
RN_EDGE_PTR
;
typedef
hed
::
E
DGE_PTR
RN_EDGE_PTR
;
typedef
hed
::
E
dgeMST
RN_EDGE_MST
;
typedef
hed
::
E
DGE_MST
RN_EDGE_MST
;
typedef
boost
::
shared_ptr
<
hed
::
EdgeMST
>
RN_EDGE_MST_PT
R
;
typedef
hed
::
TRIANGULATION
TRIANGULATO
R
;
typedef
hed
::
Triangulation
TRIANGULATO
R
;
typedef
boost
::
shared_ptr
<
hed
::
EDGE_MST
>
RN_EDGE_MST_PT
R
;
bool
operator
==
(
const
RN_NODE_PTR
&
aFirst
,
const
RN_NODE_PTR
&
aSecond
);
bool
operator
==
(
const
RN_NODE_PTR
&
aFirst
,
const
RN_NODE_PTR
&
aSecond
);
bool
operator
!=
(
const
RN_NODE_PTR
&
aFirst
,
const
RN_NODE_PTR
&
aSecond
);
bool
operator
!=
(
const
RN_NODE_PTR
&
aFirst
,
const
RN_NODE_PTR
&
aSecond
);
...
...
pcbnew/ratsnest_viewitem.cpp
View file @
6fa2f060
...
@@ -97,8 +97,8 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const
...
@@ -97,8 +97,8 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const
BOOST_FOREACH
(
const
RN_EDGE_PTR
&
edge
,
*
edges
)
BOOST_FOREACH
(
const
RN_EDGE_PTR
&
edge
,
*
edges
)
{
{
const
RN_NODE_PTR
&
sourceNode
=
edge
->
g
etSourceNode
();
const
RN_NODE_PTR
&
sourceNode
=
edge
->
G
etSourceNode
();
const
RN_NODE_PTR
&
targetNode
=
edge
->
g
etTargetNode
();
const
RN_NODE_PTR
&
targetNode
=
edge
->
G
etTargetNode
();
VECTOR2D
source
(
sourceNode
->
GetX
(),
sourceNode
->
GetY
()
);
VECTOR2D
source
(
sourceNode
->
GetX
(),
sourceNode
->
GetY
()
);
VECTOR2D
target
(
targetNode
->
GetX
(),
targetNode
->
GetY
()
);
VECTOR2D
target
(
targetNode
->
GetX
(),
targetNode
->
GetY
()
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment