Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Pries, Jason
Oersted
Commits
1e23efd2
Commit
1e23efd2
authored
Nov 26, 2016
by
JasonPries
Browse files
Cleanup of Sketch and reorganization of dependencies
parent
2312e40b
Changes
63
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
1e23efd2
...
...
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.2)
project
(
Oersted
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=
c
++14"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=
gnu
++14"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-g -O0 --coverage"
)
find_package
(
Boost REQUIRED COMPONENTS system filesystem
)
...
...
src/Mesh/include/Mesh.hpp
View file @
1e23efd2
#ifndef OERSTED_MESH_HPP
#define OERSTED_MESH_HPP
#include
<boost/filesystem.hpp>
#include
"../src/Mesh.h"
#include
"../src/Edge.h"
#include
"../src/Point.h"
...
...
src/Sketch/CMakeLists.txt
View file @
1e23efd2
...
...
@@ -5,6 +5,10 @@ set(SOURCE_FILES
./src/Sketch.h ./src/Sketch.cpp
./src/Variable.h ./src/Variable.cpp
./src/SketchElement.h ./src/SketchElement.cpp
./src/Vertex.h ./src/Vertex.cpp
./src/Curve.h ./src/Curve.cpp
...
...
@@ -13,26 +17,26 @@ set(SOURCE_FILES
./src/Constraint.h ./src/Constraint.cpp
./src/Angle.h ./src/Angle.cpp
./src/Coincident.
cpp
./src/Coincident.
h
./src/Distance.
cpp
./src/Distance.
h
./src/Fixation.
cpp
./src/Fixation.
h
./src/Horizontal.
cpp
./src/Horizontal.
h
./src/Length.
cpp
./src/Length.
h
./src/Radius.
cpp
./src/Radius.
h
./src/Rotation.
cpp
./src/Rotation.
h
./src/Symmetry.
cpp
./src/Symmetry.
h
./src/Tangency.
cpp
./src/Tangency.
h
./src/Vertical.
cpp
./src/Vertical.
h
./src/Coincident.
h
./src/Coincident.
cpp
./src/Distance.
h
./src/Distance.
cpp
./src/Fixation.
h
./src/Fixation.
cpp
./src/Horizontal.
h
./src/Horizontal.
cpp
./src/Length.
h
./src/Length.
cpp
./src/Radius.
h
./src/Radius.
cpp
./src/Rotation.
h
./src/Rotation.
cpp
./src/Symmetry.
h
./src/Symmetry.
cpp
./src/Tangency.
h
./src/Tangency.
cpp
./src/Vertical.
h
./src/Vertical.
cpp
./src/Pattern.h ./src/Pattern.cpp
./src/MirrorCopy.
cpp
./src/MirrorCopy.
h
./src/RotateCopy.
cpp
./src/RotateCopy.
h
./src/MirrorCopy.
h
./src/MirrorCopy.
cpp
./src/RotateCopy.
h
./src/RotateCopy.
cpp
./src/Branch.h ./src/Branch.cpp
./src/Star.h ./src/Star.cpp
./src/Constellation.h ./src/Constellation.cpp
./src/Contour.h ./src/Contour.cpp
)
./src/Contour.h ./src/Contour.cpp
src/sPoint.cpp src/sPoint.h
)
add_library
(
sketch STATIC
${
SOURCE_FILES
}
)
...
...
src/Sketch/include/Sketch.hpp
View file @
1e23efd2
...
...
@@ -3,16 +3,38 @@
#include
"../src/Sketch.h"
#include
"../src/Variable.h"
#include
"../src/SketchElement.h"
#include
"../src/Vertex.h"
#include
"../src/Curve.h"
#include
"../src/LineSegment.h"
#include
"../src/CircularArc.h"
#include
"../src/Constraint.h"
#include
"../src/Angle.h"
#include
"../src/Coincident.h"
#include
"../src/Distance.h"
#include
"../src/Constraint.h"
#include
"../src/Fixation.h"
#include
"../src/Horizontal.h"
#include
"../src/Length.h"
#include
"../src/Radius.h"
#include
"../src/Rotation.h"
#include
"../src/Symmetry.h"
#include
"../src/Tangency.h"
#include
"../src/Vertical.h"
#include
"../src/Pattern.h"
#include
"../src/MirrorCopy.h"
#include
"../src/RotateCopy.h"
#include
"../src/Branch.h"
#include
"../src/Star.h"
#include
"../src/Constellation.h"
#include
"../src/Contour.h"
...
...
src/Sketch/src/Angle.cpp
View file @
1e23efd2
#include
"Sketch.hpp"
#include
"Angle.h"
#include
"LineSegment.h"
void
Angle
::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
{
/*
...
...
@@ -9,15 +10,15 @@ void Angle::update(Eigen::MatrixXd &J, Eigen::VectorXd &r) {
parameters is zero when the cosine (resp. sine) is equal to one.
*/
const
double
x00
=
Line0
->
S
tart
->
x
();
const
double
x01
=
Line0
->
E
nd
->
x
();
const
double
x10
=
Line1
->
S
tart
->
x
();
const
double
x11
=
Line1
->
E
nd
->
x
();
const
double
x00
=
Line0
->
s
tart
()
->
x
();
const
double
x01
=
Line0
->
e
nd
()
->
x
();
const
double
x10
=
Line1
->
s
tart
()
->
x
();
const
double
x11
=
Line1
->
e
nd
()
->
x
();
const
double
y00
=
Line0
->
S
tart
->
y
();
const
double
y01
=
Line0
->
E
nd
->
y
();
const
double
y10
=
Line1
->
S
tart
->
y
();
const
double
y11
=
Line1
->
E
nd
->
y
();
const
double
y00
=
Line0
->
s
tart
()
->
y
();
const
double
y01
=
Line0
->
e
nd
()
->
y
();
const
double
y10
=
Line1
->
s
tart
()
->
y
();
const
double
y11
=
Line1
->
e
nd
()
->
y
();
double
vx0
=
x01
-
x00
;
double
vy0
=
y01
-
y00
;
...
...
@@ -42,38 +43,38 @@ void Angle::update(Eigen::MatrixXd &J, Eigen::VectorXd &r) {
r
(
EquationIndex
)
=
scale
*
(
dot
-
cos
(
M_PI
*
Dim
/
180.0
));
f
=
scale
*
(
vx1
-
dot
*
vx0
)
/
d0
;
J
(
EquationIndex
,
Line0
->
S
tart
->
X
->
get
_index
())
-=
f
;
J
(
EquationIndex
,
Line0
->
E
nd
->
X
->
get
_index
())
+=
f
;
J
(
EquationIndex
,
Line0
->
s
tart
()
->
x
_index
())
-=
f
;
//TODO: Change get_index() and set_index() to size_t index() and size_t index(size_t) (overloaded)
J
(
EquationIndex
,
Line0
->
e
nd
()
->
x
_index
())
+=
f
;
f
=
scale
*
(
vx0
-
dot
*
vx1
)
/
d1
;
J
(
EquationIndex
,
Line1
->
S
tart
->
X
->
get
_index
())
-=
f
;
J
(
EquationIndex
,
Line1
->
E
nd
->
X
->
get
_index
())
+=
f
;
J
(
EquationIndex
,
Line1
->
s
tart
()
->
x
_index
())
-=
f
;
J
(
EquationIndex
,
Line1
->
e
nd
()
->
x
_index
())
+=
f
;
f
=
scale
*
(
vy1
-
dot
*
vy0
)
/
d0
;
J
(
EquationIndex
,
Line0
->
S
tart
->
Y
->
get
_index
())
-=
f
;
J
(
EquationIndex
,
Line0
->
E
nd
->
Y
->
get
_index
())
+=
f
;
J
(
EquationIndex
,
Line0
->
s
tart
()
->
y
_index
())
-=
f
;
J
(
EquationIndex
,
Line0
->
e
nd
()
->
y
_index
())
+=
f
;
f
=
scale
*
(
vy0
-
dot
*
vy1
)
/
d1
;
J
(
EquationIndex
,
Line1
->
S
tart
->
Y
->
get
_index
())
-=
f
;
J
(
EquationIndex
,
Line1
->
E
nd
->
Y
->
get
_index
())
+=
f
;
J
(
EquationIndex
,
Line1
->
s
tart
()
->
y
_index
())
-=
f
;
J
(
EquationIndex
,
Line1
->
e
nd
()
->
y
_index
())
+=
f
;
}
else
{
// Solve (cross product) = sin(Dim)
r
(
EquationIndex
)
=
scale
*
(
cross
-
sin
(
M_PI
*
Dim
/
180.0
));
f
=
scale
*
(
vy1
-
cross
*
vx0
)
/
d0
;
J
(
EquationIndex
,
Line0
->
S
tart
->
X
->
get
_index
())
-=
f
;
J
(
EquationIndex
,
Line0
->
E
nd
->
X
->
get
_index
())
+=
f
;
J
(
EquationIndex
,
Line0
->
s
tart
()
->
x
_index
())
-=
f
;
J
(
EquationIndex
,
Line0
->
e
nd
()
->
x
_index
())
+=
f
;
f
=
scale
*
(
vy0
+
cross
*
vx1
)
/
d1
;
J
(
EquationIndex
,
Line1
->
S
tart
->
X
->
get
_index
())
+=
f
;
J
(
EquationIndex
,
Line1
->
E
nd
->
X
->
get
_index
())
-=
f
;
J
(
EquationIndex
,
Line1
->
s
tart
()
->
x
_index
())
+=
f
;
J
(
EquationIndex
,
Line1
->
e
nd
()
->
x
_index
())
-=
f
;
f
=
scale
*
(
vx1
+
cross
*
vy0
)
/
d0
;
J
(
EquationIndex
,
Line0
->
S
tart
->
Y
->
get
_index
())
+=
f
;
J
(
EquationIndex
,
Line0
->
E
nd
->
Y
->
get
_index
())
-=
f
;
J
(
EquationIndex
,
Line0
->
s
tart
()
->
y
_index
())
+=
f
;
J
(
EquationIndex
,
Line0
->
e
nd
()
->
y
_index
())
-=
f
;
f
=
scale
*
(
vx0
-
cross
*
vy1
)
/
d1
;
J
(
EquationIndex
,
Line1
->
S
tart
->
Y
->
get
_index
())
-=
f
;
J
(
EquationIndex
,
Line1
->
E
nd
->
Y
->
get
_index
())
+=
f
;
J
(
EquationIndex
,
Line1
->
s
tart
()
->
y
_index
())
-=
f
;
J
(
EquationIndex
,
Line1
->
e
nd
()
->
y
_index
())
+=
f
;
}
}
\ No newline at end of file
src/Sketch/src/Angle.h
View file @
1e23efd2
#ifndef OERSTED_ANGLE_H
#define OERSTED_ANGLE_H
class
Angle
:
public
Constraint
{
public:
std
::
shared_ptr
<
LineSegment
>
Line0
;
std
::
shared_ptr
<
LineSegment
>
Line1
;
#include
"Constraint.h"
double
Dim
;
class
LineSegment
;
class
Angle
:
public
Constraint
{
public:
Angle
(
std
::
shared_ptr
<
LineSegment
>
l0
,
std
::
shared_ptr
<
LineSegment
>
l1
,
double
angle
)
:
Line0
(
l0
),
Line1
(
l1
),
Dim
(
angle
)
{};
size_t
set_equation_index
(
size_t
i
)
override
{
...
...
@@ -15,7 +14,17 @@ public:
return
1
;
};
double
dim
()
const
{
return
Dim
;
};
void
dim
(
double
d
)
{
Dim
=
d
;};
void
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
override
;
protected:
std
::
shared_ptr
<
LineSegment
>
Line0
;
std
::
shared_ptr
<
LineSegment
>
Line1
;
double
Dim
;
};
#endif //OERSTED_ANGLE_H
\ No newline at end of file
src/Sketch/src/Branch.cpp
View file @
1e23efd2
#include
"Sketch.hpp"
\ No newline at end of file
#include
"Branch.h"
#include
"LineSegment.h"
\ No newline at end of file
src/Sketch/src/Branch.h
View file @
1e23efd2
#ifndef OERSTED_BRANCH_H
#define OERSTED_BRANCH_H
#include
<memory>
class
Curve
;
struct
Branch
{
std
::
shared_ptr
<
Curve
>
Path
;
bool
Orientation
;
double
Angle
;
bool
Orientation
;
};
#endif //OERSTED_BRANCH_H
src/Sketch/src/CircularArc.cpp
View file @
1e23efd2
#include
"Sketch.hpp"
#include
"CircularArc.h"
#include
"sPoint.h"
void
CircularArc
::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
{
/*
...
...
@@ -16,13 +17,13 @@ void CircularArc::update(Eigen::MatrixXd &J, Eigen::VectorXd &r) {
r
(
EquationIndex
)
=
radius
()
-
rad
;
J
(
EquationIndex
,
R
adius
->
get
_index
())
+=
rad
/
radius
();
J
(
EquationIndex
,
r
adius_index
())
+=
rad
/
radius
();
J
(
EquationIndex
,
Start
->
X
->
get
_index
())
-=
dx
/
rad
;
J
(
EquationIndex
,
Start
->
Y
->
get
_index
())
-=
dy
/
rad
;
J
(
EquationIndex
,
Start
->
x
_index
())
-=
dx
/
rad
;
J
(
EquationIndex
,
Start
->
y
_index
())
-=
dy
/
rad
;
J
(
EquationIndex
,
Center
->
X
->
get
_index
())
+=
dx
/
rad
;
J
(
EquationIndex
,
Center
->
Y
->
get
_index
())
+=
dy
/
rad
;
J
(
EquationIndex
,
Center
->
x
_index
())
+=
dx
/
rad
;
J
(
EquationIndex
,
Center
->
y
_index
())
+=
dy
/
rad
;
dx
=
End
->
x
()
-
Center
->
x
();
dy
=
End
->
y
()
-
Center
->
y
();
...
...
@@ -30,13 +31,13 @@ void CircularArc::update(Eigen::MatrixXd &J, Eigen::VectorXd &r) {
r
(
EquationIndex
+
1
)
=
radius
()
-
rad
;
J
(
EquationIndex
+
1
,
R
adius
->
get
_index
())
+=
rad
/
radius
();
J
(
EquationIndex
+
1
,
r
adius_index
())
+=
rad
/
radius
();
J
(
EquationIndex
+
1
,
End
->
X
->
get
_index
())
-=
dx
/
rad
;
J
(
EquationIndex
+
1
,
End
->
Y
->
get
_index
())
-=
dy
/
rad
;
J
(
EquationIndex
+
1
,
End
->
x
_index
())
-=
dx
/
rad
;
J
(
EquationIndex
+
1
,
End
->
y
_index
())
-=
dy
/
rad
;
J
(
EquationIndex
+
1
,
Center
->
X
->
get
_index
())
+=
dx
/
rad
;
J
(
EquationIndex
+
1
,
Center
->
Y
->
get
_index
())
+=
dy
/
rad
;
J
(
EquationIndex
+
1
,
Center
->
x
_index
())
+=
dx
/
rad
;
J
(
EquationIndex
+
1
,
Center
->
y
_index
())
+=
dy
/
rad
;
}
double
CircularArc
::
s_to_a
(
double
s
)
const
{
...
...
@@ -205,8 +206,7 @@ Direction CircularArc::is_identical(std::shared_ptr<Curve> const &c) const {
if
(
cc
.
get
()
==
nullptr
)
{
return
Direction
::
None
;
}
else
{
return
is_identical
(
cc
->
radius
(),
cc
->
center
()
->
x
(),
cc
->
center
()
->
y
(),
cc
->
start
()
->
x
(),
cc
->
start
()
->
y
(),
cc
->
end
()
->
x
(),
cc
->
end
()
->
y
());
return
is_identical
(
cc
->
radius
(),
cc
->
center
()
->
x
(),
cc
->
center
()
->
y
(),
cc
->
start
()
->
x
(),
cc
->
start
()
->
y
(),
cc
->
end
()
->
x
(),
cc
->
end
()
->
y
());
}
}
...
...
@@ -226,8 +226,7 @@ Direction CircularArc::is_identical(std::shared_ptr<Curve> const &c, std::shared
}
}
Direction
CircularArc
::
is_identical
(
const
double
r
,
const
double
xc
,
const
double
yc
,
const
double
xs
,
const
double
ys
,
const
double
xe
,
const
double
ye
)
const
{
Direction
CircularArc
::
is_identical
(
const
double
r
,
const
double
xc
,
const
double
yc
,
const
double
xs
,
const
double
ys
,
const
double
xe
,
const
double
ye
)
const
{
double
tol
=
FLT_EPSILON
*
radius
();
if
(
abs
(
radius
()
-
r
)
<
tol
&&
abs
(
center
()
->
x
()
-
xc
)
<
tol
&&
abs
(
center
()
->
y
()
-
yc
)
<
tol
&&
...
...
src/Sketch/src/CircularArc.h
View file @
1e23efd2
...
...
@@ -2,17 +2,10 @@
#define OERSTED_CIRCULARARC_H
#include
"Curve.h"
#include
"Sketch.h"
class
CircularArc
final
:
public
Curve
{
public:
friend
class
Coincident
<
CircularArc
>
;
friend
class
Distance
<
CircularArc
>
;
friend
class
Radius
;
friend
class
Tangency
;
CircularArc
()
:
Curve
(),
Radius
(
std
::
make_shared
<
Variable
>
(
0.0
))
{};
CircularArc
(
CircularArc
const
*
c
)
:
Curve
(
c
->
Start
,
c
->
End
,
c
->
ForConstruction
),
Center
(
c
->
Center
),
Radius
(
c
->
Radius
)
{};
...
...
@@ -23,10 +16,29 @@ public:
CircularArc
(
std
::
shared_ptr
<
Vertex
>
v0
,
std
::
shared_ptr
<
Vertex
>
v1
,
std
::
shared_ptr
<
Vertex
>
c
,
std
::
shared_ptr
<
Variable
>
r
,
Sketch
&
s
,
bool
fc
=
false
)
:
Curve
(
v0
,
v1
,
fc
),
Center
(
c
),
Radius
(
r
)
{};
std
::
shared_ptr
<
Vertex
>
center
()
const
{
return
Center
;
};
size_t
set_equation_index
(
size_t
i
)
override
{
EquationIndex
=
i
;
return
2
;
};
size_t
radius_index
()
const
{
return
Radius
->
get_index
();
};
bool
is_coincident
(
std
::
shared_ptr
<
Curve
>
const
&
c
)
const
override
;
double
a
(
double
s
,
bool
orientation
)
const
override
;
double
area
()
const
override
;
double
da
(
double
s
,
bool
orientation
)
const
override
;
double
length
()
const
override
{
throw
;
};
double
radius
()
const
{
return
Radius
->
value
();
};
using
Curve
::
on_manifold
;
using
Curve
::
on_segment
;
void
get_verticies
(
std
::
list
<
std
::
shared_ptr
<
Vertex
>>
&
v
,
Direction
dir
=
Direction
::
Forward
)
const
override
{
if
(
dir
==
Direction
::
Forward
)
{
v
.
push_back
(
Start
);
...
...
@@ -39,42 +51,25 @@ public:
}
};
size_t
set_equation_index
(
size_t
i
)
override
{
EquationIndex
=
i
;
return
2
;
};
void
register_parameters
(
Sketch
*
s
)
override
{
s
->
add_parameter
(
Radius
);
};
void
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
override
;
sPoint
point
(
double
s
)
const
override
;
Vertex
tangent
(
double
s
,
bool
orientation
)
const
override
;
double
length
()
const
override
{
throw
;
};
double
area
()
const
override
;
double
a
(
double
s
,
bool
orientation
)
const
override
;
void
replace_verticies
(
std
::
vector
<
std
::
shared_ptr
<
Vertex
>>
oldv
,
std
::
vector
<
std
::
shared_ptr
<
Vertex
>>
newv
)
override
;
double
da
(
double
s
,
bool
orientation
)
const
override
;
void
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
override
;
std
::
pair
<
double
,
double
>
supremum
()
const
override
;
using
Curve
::
on_manifold
;
std
::
shared_ptr
<
Curve
>
clone
()
const
override
{
return
std
::
make_shared
<
CircularArc
>
(
this
);
}
;
using
Curve
::
on_segment
;
std
::
shared_ptr
<
Vertex
>
center
()
const
{
return
Center
;
}
;
Direction
is_identical
(
std
::
shared_ptr
<
Curve
>
const
&
c
)
const
override
;
Direction
is_identical
(
std
::
shared_ptr
<
Curve
>
const
&
c
,
std
::
shared_ptr
<
Vertex
>
const
&
origin
,
double
const
angle
)
const
override
;
bool
is_coincident
(
std
::
shared_ptr
<
Curve
>
const
&
c
)
const
override
;
std
::
shared_ptr
<
Curve
>
clone
()
const
override
{
return
std
::
make_shared
<
CircularArc
>
(
this
);
};
sPoint
point
(
double
s
)
const
override
;
void
replace_verticies
(
std
::
vector
<
std
::
shared_ptr
<
Vertex
>>
oldv
,
std
::
vector
<
std
::
shared_ptr
<
Vertex
>>
newv
)
override
;
Vertex
tangent
(
double
s
,
bool
orientation
)
const
override
;
protected:
std
::
shared_ptr
<
Vertex
>
Center
;
...
...
@@ -84,14 +79,13 @@ protected:
bool
on_segment
(
const
double
x
,
const
double
y
)
const
override
;
Direction
is_identical
(
const
double
r
,
const
double
xc
,
const
double
yc
,
const
double
xs
,
const
double
ys
,
const
double
xe
,
const
double
ye
)
const
;
private:
double
s_to_a
(
double
s
)
const
;
double
a_to_s
(
double
a
)
const
;
double
arc_angle
()
const
;
Direction
is_identical
(
const
double
r
,
const
double
xc
,
const
double
yc
,
const
double
xs
,
const
double
ys
,
const
double
xe
,
const
double
ye
)
const
;
};
#endif //OERSTED_CIRCULARARC_H
src/Sketch/src/Coincident.cpp
View file @
1e23efd2
#include
"Sketch.hpp"
#include
"Coincident.h"
#include
"CircularArc.h"
#include
"LineSegment.h"
template
<
>
void
Coincident
<
CircularArc
>::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
{
const
double
rc
=
Element
->
radius
();
const
double
xc
=
Element
->
C
enter
->
x
();
const
double
yc
=
Element
->
C
enter
->
y
();
const
double
xc
=
Element
->
c
enter
()
->
x
();
const
double
yc
=
Element
->
c
enter
()
->
y
();
const
double
xp
=
Point
->
x
();
const
double
yp
=
Point
->
y
();
...
...
@@ -17,13 +19,13 @@ void Coincident<CircularArc>::update(Eigen::MatrixXd &J, Eigen::VectorXd &r) {
r
(
EquationIndex
)
=
dr
-
rc
;
J
(
EquationIndex
,
Element
->
R
adius
->
get
_index
())
=
-
dr
/
rc
;
J
(
EquationIndex
,
Element
->
r
adius_index
())
=
-
dr
/
rc
;
J
(
EquationIndex
,
Element
->
C
enter
->
X
->
get
_index
())
-=
dx
;
J
(
EquationIndex
,
Element
->
C
enter
->
Y
->
get
_index
())
-=
dy
;
J
(
EquationIndex
,
Element
->
c
enter
()
->
x
_index
())
-=
dx
;
J
(
EquationIndex
,
Element
->
c
enter
()
->
y
_index
())
-=
dy
;
J
(
EquationIndex
,
Point
->
X
->
get
_index
())
+=
dx
;
J
(
EquationIndex
,
Point
->
Y
->
get
_index
())
+=
dy
;
J
(
EquationIndex
,
Point
->
x
_index
())
+=
dx
;
J
(
EquationIndex
,
Point
->
y
_index
())
+=
dy
;
}
template
...
...
@@ -34,10 +36,10 @@ void Coincident<LineSegment>::update(Eigen::MatrixXd &J, Eigen::VectorXd &r) {
const
double
xp
=
Point
->
x
();
const
double
yp
=
Point
->
y
();
const
double
x0
=
Element
->
S
tart
->
x
();
const
double
y0
=
Element
->
S
tart
->
y
();
const
double
x1
=
Element
->
E
nd
->
x
();
const
double
y1
=
Element
->
E
nd
->
y
();
const
double
x0
=
Element
->
s
tart
()
->
x
();
const
double
y0
=
Element
->
s
tart
()
->
y
();
const
double
x1
=
Element
->
e
nd
()
->
x
();
const
double
y1
=
Element
->
e
nd
()
->
y
();
double
dx0
=
x0
-
xp
;
double
dy0
=
y0
-
yp
;
...
...
@@ -62,16 +64,16 @@ void Coincident<LineSegment>::update(Eigen::MatrixXd &J, Eigen::VectorXd &r) {
f0
=
scale
*
(
dy1
-
cross
*
dx0
)
/
dr0
;
f1
=
scale
*
(
dy0
+
cross
*
dx1
)
/
dr1
;
J
(
EquationIndex
,
Point
->
X
->
get
_index
())
-=
f0
-
f1
;
J
(
EquationIndex
,
Element
->
S
tart
->
X
->
get
_index
())
+=
f0
;
J
(
EquationIndex
,
Element
->
E
nd
->
X
->
get
_index
())
-=
f1
;
J
(
EquationIndex
,
Point
->
x
_index
())
-=
f0
-
f1
;
J
(
EquationIndex
,
Element
->
s
tart
()
->
x
_index
())
+=
f0
;
J
(
EquationIndex
,
Element
->
e
nd
()
->
x
_index
())
-=
f1
;
f0
=
scale
*
(
dx1
+
cross
*
dy0
)
/
dr0
;
f1
=
scale
*
(
dx0
-
cross
*
dy1
)
/
dr1
;
J
(
EquationIndex
,
Point
->
Y
->
get
_index
())
+=
f0
-
f1
;
J
(
EquationIndex
,
Element
->
S
tart
->
Y
->
get
_index
())
-=
f0
;
J
(
EquationIndex
,
Element
->
E
nd
->
Y
->
get
_index
())
+=
f1
;
J
(
EquationIndex
,
Point
->
y
_index
())
+=
f0
-
f1
;
J
(
EquationIndex
,
Element
->
s
tart
()
->
y
_index
())
-=
f0
;
J
(
EquationIndex
,
Element
->
e
nd
()
->
y
_index
())
+=
f1
;
}
template
...
...
src/Sketch/src/Coincident.h
View file @
1e23efd2
#ifndef OERSTED_COINCIDENT_H
#define OERSTED_COINCIDENT_H
#include
"Constraint.h"
class
Vertex
;
template
<
class
T
>
class
Coincident
:
public
Constraint
{
public:
std
::
shared_ptr
<
Vertex
>
Point
;
std
::
shared_ptr
<
T
>
Element
;
// Constructors
Coincident
(
std
::
shared_ptr
<
Vertex
>
p
,
std
::
shared_ptr
<
T
>
e
)
:
Point
(
p
),
Element
(
e
)
{};
// Public Member Functions
size_t
set_equation_index
(
size_t
i
)
override
{
EquationIndex
=
i
;
return
1
;
};
void
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
override
;
protected:
std
::
shared_ptr
<
Vertex
>
Point
;
std
::
shared_ptr
<
T
>
Element
;
};
#endif //OERSTED_COINCIDENT_H
src/Sketch/src/Constellation.cpp
View file @
1e23efd2
#include
"Sketch.hpp"
#include
"Constellation.h"
#include
"Sketch.h"
#include
"Star.h"
#include
"Branch.h"
#include
"Curve.h"
#include
"Contour.h"
Constellation
::
Constellation
(
Sketch
const
*
s
)
{
for
(
size_t
i
=
0
;
i
!=
s
->
size_verticies
();
++
i
)
{
...
...
src/Sketch/src/Constellation.h
View file @
1e23efd2
#ifndef OERSTED_CONSTELLATION_H
#define OERSTED_CONSTELLATION_H
#include
"Sketch.h"
#include
<list>
#include
<vector>
#include
<memory>
class
Branch
;
class
Contour
;
class
Curve
;
class
Star
;
class
Sketch
;
class
Constellation
{
public:
// Constructors
Constellation
()
{};
Constellation
(
Sketch
const
*
s
);
...
...
@@ -19,13 +26,13 @@ public:
private:
std
::
list
<
Star
>
Stars
;
void
pop
(
std
::
shared_ptr
<
Curve
>
c
=
std
::
shared_ptr
<
Curve
>
()
);
bool
find_closed_contour
(
std
::
vector
<
std
::
shared_ptr
<
Curve
>>
&
curves
,
std
::
vector
<
bool
>
&
orientation
);
bool
twin
(
std
::
list
<
Star
>::
iterator
&
s_out
,
std
::
list
<
Branch
>::
iterator
&
b_out
);
void
supremum
(
std
::
list
<
Star
>::
iterator
&
s_out
,
std
::
list
<
Branch
>::
iterator
&
b_out
);
void
pop
(
std
::
shared_ptr
<
Curve
>
c
=
std
::
shared_ptr
<
Curve
>
()
);
bool
find_closed_contour
(
std
::
vector
<
std
::
shared_ptr
<
Curve
>>
&
curves
,
std
::
vector
<
bool
>
&
orientation
);
void
supremum
(
std
::
list
<
Star
>::
iterator
&
s_out
,
std
::
list
<
Branch
>::
iterator
&
b_out
);
};
#endif //OERSTED_CONSTELLATION_H
\ No newline at end of file
src/Sketch/src/Constraint.cpp
View file @
1e23efd2
#include
"Sketch.hpp"
\ No newline at end of file
#include
"Constraint.h"
\ No newline at end of file
src/Sketch/src/Constraint.h
View file @
1e23efd2
#ifndef OERSTED_CONSTRAINT_H