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
44d05ecd
Commit
44d05ecd
authored
Nov 27, 2016
by
JasonPries
Browse files
Add shared_ptr const correctness to Sketch
parent
29e056a9
Changes
72
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
44d05ecd
...
...
@@ -4,6 +4,7 @@ project(Oersted)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=gnu++14"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-g -O0 --coverage"
)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
find_package
(
Boost REQUIRED COMPONENTS system filesystem
)
include_directories
(
${
Boost_INCLUDE_DIR
}
)
...
...
src/Mesh/src/Mesh.cpp
View file @
44d05ecd
...
...
@@ -5,7 +5,7 @@ Mesh::Mesh(Sketch &sketch) {
for
(
size_t
i
=
0
;
i
!=
sketch
.
size_curves
();
++
i
)
{
auto
c
=
sketch
.
curve
(
i
);
if
(
!
(
c
->
F
or
C
onstruction
))
{
if
(
!
(
c
->
f
or
_c
onstruction
()
))
{
Curves
.
push_back
(
c
);
}
}
...
...
@@ -542,7 +542,7 @@ void Mesh::create_boundary_polygon() {
Edges
.
reserve
(
Boundary
->
size
());
Points
.
reserve
(
Boundary
->
size
());
for
(
size_t
i
=
0
;
i
!=
Boundary
->
size
();
++
i
)
{
std
::
shared_ptr
<
Curve
>
cc
=
Boundary
->
curve
(
i
);
std
::
shared_ptr
<
Curve
const
>
cc
=
Boundary
->
curve
(
i
);
bool
dir
=
Boundary
->
orientation
(
i
);
Edge
&
e
=
new_edge
(
Points
.
size
(),
Constraints
.
size
(),
dir
);
// TODO: change to new_edge(Edge)
e
.
Twin
=
e
.
Self
;
...
...
@@ -629,7 +629,7 @@ void Mesh::insert_internal_boundaries() {
*/
// Find interior curves
std
::
vector
<
std
::
shared_ptr
<
Curve
>>
interior
;
std
::
vector
<
std
::
shared_ptr
<
Curve
const
>>
interior
;
for
(
auto
c
:
Curves
)
{
bool
on_exterior
=
false
;
for
(
size_t
i
=
0
;
i
!=
Boundary
->
size
();
++
i
)
{
...
...
@@ -691,7 +691,7 @@ void Mesh::insert_internal_boundaries() {
}
else
{
double
s0
=
dc
.
S0
;
double
s1
=
dc
.
S1
;
std
::
shared_ptr
<
Curve
>
cc
=
dc
.
ConstraintCurve
;
std
::
shared_ptr
<
Curve
const
>
cc
=
dc
.
ConstraintCurve
;
double
sn
=
(
s0
+
s1
)
/
2.0
;
Point
const
p
=
cc
->
point
(
sn
);
...
...
@@ -778,7 +778,7 @@ void Mesh::split_edge(size_t ei) {
DartConstraint
&
dc
=
Constraints
[
Edges
[
ei
].
Constraint
];
double
s0
=
dc
.
S0
;
double
s1
=
dc
.
S1
;
std
::
shared_ptr
<
Curve
>
cc
=
dc
.
ConstraintCurve
;
std
::
shared_ptr
<
Curve
const
>
cc
=
dc
.
ConstraintCurve
;
double
sn
=
(
s0
+
s1
)
/
2.0
;
dc
.
S1
=
sn
;
...
...
@@ -1069,7 +1069,7 @@ InsertPointResult Mesh::insert_midpoint(size_t ei) {
DartConstraint
&
dc
=
Constraints
[
Edges
[
ei
].
Constraint
];
double
s0
=
dc
.
S0
;
double
s1
=
dc
.
S1
;
std
::
shared_ptr
<
Curve
>
cc
=
dc
.
ConstraintCurve
;
std
::
shared_ptr
<
Curve
const
>
cc
=
dc
.
ConstraintCurve
;
double
sn
=
(
s0
+
s1
)
/
2.0
;
dc
.
S1
=
sn
;
...
...
src/Mesh/src/Mesh.h
View file @
44d05ecd
...
...
@@ -21,11 +21,11 @@ class DartConstraint {
public:
DartConstraint
()
:
S0
(
DBL_MAX
),
S1
(
DBL_MAX
),
ConstraintCurve
(
nullptr
)
{};
DartConstraint
(
double
s0
,
double
s1
,
std
::
shared_ptr
<
Curve
>
cc
)
:
S0
(
s0
),
S1
(
s1
),
ConstraintCurve
(
cc
)
{};
DartConstraint
(
double
s0
,
double
s1
,
std
::
shared_ptr
<
Curve
const
>
cc
)
:
S0
(
s0
),
S1
(
s1
),
ConstraintCurve
(
cc
)
{};
double
S0
;
double
S1
;
std
::
shared_ptr
<
Curve
>
ConstraintCurve
;
std
::
shared_ptr
<
Curve
const
>
ConstraintCurve
;
};
class
Mesh
{
...
...
@@ -92,7 +92,7 @@ public:
DartConstraint
const
constraint
(
size_t
ei
)
const
{
return
Constraints
[
Edges
[
ei
].
Constraint
];
};
std
::
shared_ptr
<
Curve
>
constraint_curve
(
size_t
ei
)
const
{
return
Constraints
[
Edges
[
ei
].
Constraint
].
ConstraintCurve
;
};
std
::
shared_ptr
<
Curve
const
>
constraint_curve
(
size_t
ei
)
const
{
return
Constraints
[
Edges
[
ei
].
Constraint
].
ConstraintCurve
;
};
Point
circumcenter
(
size_t
ei
)
const
;
...
...
@@ -134,9 +134,9 @@ public:
InsertPointResult
insert_point
(
Point
const
p
)
{
return
insert_point
(
p
,
Edges
.
size
()
-
1
);
};
protected:
std
::
shared_ptr
<
Contour
>
Boundary
;
std
::
vector
<
std
::
shared_ptr
<
Curve
>>
Curves
;
std
::
vector
<
std
::
shared_ptr
<
Contour
>>
Contours
;
std
::
shared_ptr
<
Contour
const
>
Boundary
;
std
::
vector
<
std
::
shared_ptr
<
Curve
const
>>
Curves
;
std
::
vector
<
std
::
shared_ptr
<
Contour
const
>>
Contours
;
std
::
vector
<
Point
>
Points
;
std
::
vector
<
Edge
>
Edges
;
...
...
src/Mesh/src/Point.h
View file @
44d05ecd
...
...
@@ -3,18 +3,15 @@
#include
"Mesh.h"
class
Point
{
// TODO, Replace Verticies member in Mesh with lighterweight Node class
class
Point
{
public:
Point
()
:
X
{
0.0
},
Y
{
0.0
}
{};
Point
(
double
x
,
double
y
)
:
X
{
x
},
Y
{
y
}
{};
//Point(Vertex const &v) : X{v.x()}, Y{v.y()} {};
Point
(
std
::
shared_ptr
<
Vertex
>
v
)
:
X
{
v
->
x
()},
Y
{
v
->
y
()}
{};
Point
(
std
::
shared_ptr
<
Vertex
const
>
const
&
v
)
:
X
{
v
->
x
()},
Y
{
v
->
y
()}
{};
Point
(
sPoint
const
p
p
)
:
X
{
p
p
.
x
()
},
Y
{
p
p
.
y
()
}
{};
Point
(
double2
const
p
)
:
X
{
p
.
X
},
Y
{
p
.
Y
}
{};
//double W; // Nurbs weight?
double
X
;
...
...
@@ -25,9 +22,13 @@ public:
bool
operator
==
(
Vertex
const
&
v
)
const
{
return
(
X
==
v
.
x
())
&&
(
Y
==
v
.
y
());
};
bool
operator
==
(
double2
const
&
p
)
const
{
return
(
X
==
p
.
X
)
&&
(
Y
==
p
.
Y
);
};
bool
operator
!=
(
Point
const
&
p
)
const
{
return
(
X
!=
p
.
X
)
||
(
Y
!=
p
.
Y
);
};
bool
operator
!=
(
Vertex
const
&
v
)
const
{
return
(
X
!=
v
.
x
())
&&
(
Y
!=
v
.
y
());
};
bool
operator
!=
(
Vertex
const
&
v
)
const
{
return
(
X
!=
v
.
x
())
||
(
Y
!=
v
.
y
());
};
bool
operator
!=
(
double2
const
&
p
)
const
{
return
(
X
!=
p
.
X
)
||
(
Y
!=
p
.
Y
);
};
};
double
dist
(
Point
const
&
p0
,
Point
const
&
p1
);
...
...
src/Sketch/CMakeLists.txt
View file @
44d05ecd
...
...
@@ -10,7 +10,7 @@ set(SOURCE_FILES
./src/SketchElement.h ./src/SketchElement.cpp
./src/Vertex.h ./src/Vertex.cpp
./
src/
sPoint
.h
./
src/
sPoint
.cpp
src/
doublen
.h src/
doublen
.cpp
./src/Curve.h ./src/Curve.cpp
./src/LineSegment.h ./src/LineSegment.cpp
...
...
src/Sketch/src/Angle.cpp
View file @
44d05ecd
#include
"Angle.h"
#include
"LineSegment.h"
void
Angle
::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
{
void
Angle
::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
const
{
/*
The dot product of two unit vectors equals the cosine of the angle between them.
The cross product of two unit vectros equals the sine of the angle between them.
...
...
@@ -10,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
->
start
()
->
x
();
const
double
x01
=
Line0
->
end
()
->
x
();
const
double
x10
=
Line1
->
start
()
->
x
();
const
double
x11
=
Line1
->
end
()
->
x
();
double
x00
=
Line0
->
start
()
->
x
();
double
x01
=
Line0
->
end
()
->
x
();
double
x10
=
Line1
->
start
()
->
x
();
double
x11
=
Line1
->
end
()
->
x
();
const
double
y00
=
Line0
->
start
()
->
y
();
const
double
y01
=
Line0
->
end
()
->
y
();
const
double
y10
=
Line1
->
start
()
->
y
();
const
double
y11
=
Line1
->
end
()
->
y
();
double
y00
=
Line0
->
start
()
->
y
();
double
y01
=
Line0
->
end
()
->
y
();
double
y10
=
Line1
->
start
()
->
y
();
double
y11
=
Line1
->
end
()
->
y
();
double
vx0
=
x01
-
x00
;
double
vy0
=
y01
-
y00
;
...
...
src/Sketch/src/Angle.h
View file @
44d05ecd
...
...
@@ -7,7 +7,7 @@ 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
)
{};
Angle
(
std
::
shared_ptr
<
LineSegment
const
>
l0
,
std
::
shared_ptr
<
LineSegment
const
>
l1
,
double
angle
)
:
Line0
(
l0
),
Line1
(
l1
),
Dim
(
angle
)
{};
size_t
set_equation_index
(
size_t
i
)
override
{
EquationIndex
=
i
;
...
...
@@ -18,11 +18,12 @@ public:
void
dim
(
double
d
)
{
Dim
=
d
;};
void
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
override
;
void
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
const
override
;
protected:
std
::
shared_ptr
<
LineSegment
>
Line0
;
std
::
shared_ptr
<
LineSegment
>
Line1
;
std
::
shared_ptr
<
LineSegment
const
>
Line0
;
std
::
shared_ptr
<
LineSegment
const
>
Line1
;
double
Dim
;
};
...
...
src/Sketch/src/Branch.h
View file @
44d05ecd
...
...
@@ -6,8 +6,10 @@
class
Curve
;
struct
Branch
{
std
::
shared_ptr
<
Curve
>
Path
;
std
::
shared_ptr
<
Curve
const
>
Path
;
double
Angle
;
bool
Orientation
;
};
...
...
src/Sketch/src/CircularArc.cpp
View file @
44d05ecd
#include
"CircularArc.h"
#include
"
sPoint
.h"
#include
"
doublen
.h"
void
CircularArc
::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
{
void
CircularArc
::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
const
{
/*
Calculate residual and jacobian from (1 - rad / radius())
Normalize linearized equations by multiplying through by radius()
...
...
@@ -41,12 +41,12 @@ void CircularArc::update(Eigen::MatrixXd &J, Eigen::VectorXd &r) {
}
double
CircularArc
::
s_to_a
(
double
s
)
const
{
const
double
xc
=
Center
->
x
();
const
double
yc
=
Center
->
y
();
const
double
x0
=
Start
->
x
();
const
double
y0
=
Start
->
y
();
const
double
x1
=
End
->
x
();
const
double
y1
=
End
->
y
();
double
xc
=
Center
->
x
();
double
yc
=
Center
->
y
();
double
x0
=
Start
->
x
();
double
y0
=
Start
->
y
();
double
x1
=
End
->
x
();
double
y1
=
End
->
y
();
double
a0
=
atan2
(
y0
-
yc
,
x0
-
xc
);
double
a1
=
atan2
(
y1
-
yc
,
x1
-
xc
);
...
...
@@ -58,12 +58,12 @@ double CircularArc::s_to_a(double s) const {
}
double
CircularArc
::
a_to_s
(
double
a
)
const
{
const
double
xc
=
Center
->
x
();
const
double
yc
=
Center
->
y
();
const
double
x0
=
Start
->
x
();
const
double
y0
=
Start
->
y
();
const
double
x1
=
End
->
x
();
const
double
y1
=
End
->
y
();
double
xc
=
Center
->
x
();
double
yc
=
Center
->
y
();
double
x0
=
Start
->
x
();
double
y0
=
Start
->
y
();
double
x1
=
End
->
x
();
double
y1
=
End
->
y
();
double
a0
=
atan2
(
y0
-
yc
,
x0
-
xc
);
double
a1
=
atan2
(
y1
-
yc
,
x1
-
xc
);
...
...
@@ -79,12 +79,12 @@ double CircularArc::a_to_s(double a) const {
}
double
CircularArc
::
arc_angle
()
const
{
const
double
xc
=
Center
->
x
();
const
double
yc
=
Center
->
y
();
const
double
x0
=
Start
->
x
();
const
double
y0
=
Start
->
y
();
const
double
x1
=
End
->
x
();
const
double
y1
=
End
->
y
();
double
xc
=
Center
->
x
();
double
yc
=
Center
->
y
();
double
x0
=
Start
->
x
();
double
y0
=
Start
->
y
();
double
x1
=
End
->
x
();
double
y1
=
End
->
y
();
double
a0
=
atan2
(
y0
-
yc
,
x0
-
xc
);
double
a1
=
atan2
(
y1
-
yc
,
x1
-
xc
);
...
...
@@ -95,19 +95,19 @@ double CircularArc::arc_angle() const {
return
(
a1
-
a0
);
}
sPoint
CircularArc
::
point
(
double
s
)
const
{
double2
CircularArc
::
point
(
double
s
)
const
{
double
a
=
s_to_a
(
s
);
return
sPoint
{
center
()
->
x
()
+
radius
()
*
cos
(
a
),
center
()
->
y
()
+
radius
()
*
sin
(
a
)};
return
double2
{
center
()
->
x
()
+
radius
()
*
cos
(
a
),
center
()
->
y
()
+
radius
()
*
sin
(
a
)};
}
Vertex
CircularArc
::
tangent
(
double
s
,
bool
orientation
)
const
{
double2
CircularArc
::
tangent
(
double
s
,
bool
orientation
)
const
{
double
a
=
s_to_a
(
s
);
if
(
orientation
)
{
return
Vertex
{
-
sin
(
a
),
cos
(
a
)};
return
double2
{
-
sin
(
a
),
cos
(
a
)};
}
else
{
return
Vertex
{
sin
(
a
),
-
cos
(
a
)};
return
double2
{
sin
(
a
),
-
cos
(
a
)};
}
}
...
...
@@ -150,7 +150,7 @@ double CircularArc::da(double s, bool orientation) const {
}
}
std
::
pair
<
double
,
double
>
CircularArc
::
supremum
()
const
{
double2
CircularArc
::
supremum
()
const
{
double
x
=
start
()
->
x
();
double
y
=
start
()
->
y
();
double
sup
=
sqrt
(
x
*
x
+
y
*
y
);
...
...
@@ -168,9 +168,9 @@ std::pair<double, double> CircularArc::supremum() const {
double
s
=
a_to_s
(
center
()
->
atan
());
if
(
s
>
0.0
&&
s
<
1.0
)
{
sPoint
v
=
point
(
s
);
xx
=
v
.
x
()
;
yy
=
v
.
y
()
;
double2
v
=
point
(
s
);
xx
=
v
.
X
;
yy
=
v
.
Y
;
val
=
sqrt
(
xx
*
xx
+
yy
*
yy
);
if
(
val
>
sup
)
{
...
...
@@ -184,10 +184,10 @@ std::pair<double, double> CircularArc::supremum() const {
double
ang
=
s_to_a
(
par
);
double
cross
=
abs
(
x
*
cos
(
ang
)
+
y
*
sin
(
ang
))
/
sup
;
// cross product of vector from origin to point and tangent vector
return
std
::
pair
<
double
,
double
>
(
sup
,
cross
)
;
return
double2
{
sup
,
cross
}
;
}
bool
CircularArc
::
on_manifold
(
const
double
x
,
const
double
y
)
const
{
bool
CircularArc
::
on_manifold
(
double
x
,
double
y
)
const
{
double
dx
=
Center
->
x
()
-
x
;
double
dy
=
Center
->
y
()
-
y
;
double
dr
=
sqrt
(
dx
*
dx
+
dy
*
dy
);
...
...
@@ -200,46 +200,44 @@ bool CircularArc::on_manifold(const double x, const double y) const {
}
}
Direc
tion
CircularArc
::
is_identical
(
std
::
shared_ptr
<
Curve
>
const
&
c
)
const
{
std
::
shared_ptr
<
CircularArc
>
cc
=
std
::
dynamic_pointer_cast
<
CircularArc
>
(
c
);
MatchOrienta
tion
CircularArc
::
is_identical
(
std
::
shared_ptr
<
Curve
const
>
const
&
c
)
const
{
std
::
shared_ptr
<
CircularArc
const
>
cc
=
std
::
dynamic_pointer_cast
<
CircularArc
const
>
(
c
);
if
(
cc
.
get
()
==
nullptr
)
{
return
Direc
tion
::
None
;
return
MatchOrienta
tion
::
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
());
}
}
Direc
tion
CircularArc
::
is_identical
(
std
::
shared_ptr
<
Curve
>
const
&
c
,
std
::
shared_ptr
<
Vertex
>
const
&
origin
,
double
const
angle
)
const
{
std
::
shared_ptr
<
CircularArc
>
cc
=
std
::
dynamic_pointer_cast
<
CircularArc
>
(
c
);
MatchOrienta
tion
CircularArc
::
is_identical
(
std
::
shared_ptr
<
Curve
const
>
const
&
c
,
std
::
shared_ptr
<
Vertex
const
>
const
&
origin
,
double
angle
)
const
{
std
::
shared_ptr
<
CircularArc
const
>
cc
=
std
::
dynamic_pointer_cast
<
CircularArc
const
>
(
c
);
if
(
cc
.
get
()
==
nullptr
)
{
return
Direc
tion
::
None
;
return
MatchOrienta
tion
::
None
;
}
else
{
double
xc
,
yc
,
xs
,
ys
,
xe
,
ye
;
double2
pc
=
cc
->
center
()
->
rotate
(
origin
,
angle
);
double2
ps
=
cc
->
start
()
->
rotate
(
origin
,
angle
);
double2
pe
=
cc
->
end
()
->
rotate
(
origin
,
angle
);
std
::
tie
(
xc
,
yc
)
=
cc
->
center
()
->
rotate
(
origin
,
angle
);
std
::
tie
(
xs
,
ys
)
=
cc
->
start
()
->
rotate
(
origin
,
angle
);
std
::
tie
(
xe
,
ye
)
=
cc
->
end
()
->
rotate
(
origin
,
angle
);
return
is_identical
(
cc
->
radius
(),
xc
,
yc
,
xs
,
ys
,
xe
,
ye
);
return
is_identical
(
cc
->
radius
(),
pc
.
X
,
pc
.
Y
,
ps
.
X
,
ps
.
Y
,
pe
.
X
,
pe
.
Y
);
}
}
Direc
tion
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
{
MatchOrienta
tion
CircularArc
::
is_identical
(
double
r
,
double
xc
,
double
yc
,
double
xs
,
double
ys
,
double
xe
,
double
ye
)
const
{
double
tol
=
FLT_EPSILON
*
radius
();
if
(
abs
(
radius
()
-
r
)
<
tol
&&
abs
(
center
()
->
x
()
-
xc
)
<
tol
&&
abs
(
center
()
->
y
()
-
yc
)
<
tol
&&
abs
(
start
()
->
x
()
-
xs
)
<
tol
&&
abs
(
start
()
->
y
()
-
ys
)
<
tol
&&
abs
(
end
()
->
x
()
-
xe
)
<
tol
&&
abs
(
end
()
->
y
()
-
ye
)
<
tol
)
{
return
Direc
tion
::
Forward
;
return
MatchOrienta
tion
::
Forward
;
}
else
{
return
Direc
tion
::
None
;
return
MatchOrienta
tion
::
None
;
}
}
bool
CircularArc
::
is_coincident
(
std
::
shared_ptr
<
Curve
>
const
&
c
)
const
{
std
::
shared_ptr
<
CircularArc
>
cc
=
std
::
dynamic_pointer_cast
<
CircularArc
>
(
c
);
bool
CircularArc
::
is_coincident
(
std
::
shared_ptr
<
Curve
const
>
const
&
c
)
const
{
std
::
shared_ptr
<
CircularArc
const
>
cc
=
std
::
dynamic_pointer_cast
<
CircularArc
const
>
(
c
);
if
(
cc
.
get
()
==
nullptr
)
{
return
false
;
...
...
@@ -259,7 +257,7 @@ bool CircularArc::is_coincident(std::shared_ptr<Curve> const &c) const {
}
}
bool
CircularArc
::
on_segment
(
const
double
x
,
const
double
y
)
const
{
bool
CircularArc
::
on_segment
(
double
x
,
double
y
)
const
{
double
dx
=
x
-
center
()
->
x
();
double
dy
=
y
-
center
()
->
y
();
double
dr
=
sqrt
(
dx
*
dx
+
dy
*
dy
);
...
...
@@ -295,7 +293,7 @@ bool CircularArc::on_segment(const double x, const double y) const {
}
}
void
CircularArc
::
replace_verticies
(
std
::
vector
<
std
::
shared_ptr
<
Vertex
>>
oldv
,
std
::
vector
<
std
::
shared_ptr
<
Vertex
>>
newv
)
{
void
CircularArc
::
replace_verticies
(
std
::
vector
<
std
::
shared_ptr
<
Vertex
const
>>
const
&
oldv
,
std
::
vector
<
std
::
shared_ptr
<
Vertex
const
>>
const
&
newv
)
{
auto
i
=
std
::
find
(
oldv
.
begin
(),
oldv
.
end
(),
Start
);
if
(
i
!=
oldv
.
end
())
{
size_t
j
=
i
-
oldv
.
begin
();
...
...
src/Sketch/src/CircularArc.h
View file @
44d05ecd
...
...
@@ -6,15 +6,18 @@
class
CircularArc
final
:
public
Curve
{
public:
CircularArc
()
:
Curve
(),
Radius
(
std
::
make_shared
<
Variable
>
(
0.0
))
{}
;
using
Curve
::
on_manifold
;
CircularArc
(
CircularArc
const
*
c
)
:
Curve
(
c
->
Start
,
c
->
End
,
c
->
ForConstruction
),
Center
(
c
->
Center
),
Radius
(
c
->
Radius
)
{}
;
using
Curve
::
on_segment
;
CircularArc
(
std
::
shared_ptr
<
Vertex
>
v0
,
std
::
shared_ptr
<
Vertex
>
v1
,
std
::
shared_ptr
<
Vertex
>
c
,
bool
fc
=
false
)
:
Curve
(
v0
,
v1
,
fc
),
Center
(
c
)
{};
public:
CircularArc
()
:
Curve
(),
Radius
(
std
::
make_shared
<
Variable
const
>
(
0.0
))
{};
CircularArc
(
CircularArc
const
*
c
)
:
Curve
(
c
->
Start
,
c
->
End
,
c
->
ForConstruction
),
Center
(
c
->
Center
),
Radius
(
c
->
Radius
)
{};
CircularArc
(
std
::
shared_ptr
<
Vertex
>
v0
,
std
::
shared_ptr
<
Vertex
>
v1
,
std
::
shared_ptr
<
Vertex
>
c
,
double
r
,
bool
fc
=
false
)
:
Curve
(
v0
,
v1
,
fc
),
Center
(
c
)
,
Radius
(
std
::
make_shared
<
Variable
>
(
r
))
{};
CircularArc
(
std
::
shared_ptr
<
Vertex
const
>
v0
,
std
::
shared_ptr
<
Vertex
const
>
v1
,
std
::
shared_ptr
<
Vertex
c
onst
>
c
,
bool
fc
=
false
)
:
Curve
(
v0
,
v1
,
fc
),
Center
(
c
)
{};
CircularArc
(
std
::
shared_ptr
<
Vertex
>
v0
,
std
::
shared_ptr
<
Vertex
>
v1
,
std
::
shared_ptr
<
Vertex
>
c
,
std
::
shared_ptr
<
Varia
ble
>
r
,
Sketch
&
s
,
bool
fc
=
false
)
:
Curve
(
v0
,
v1
,
fc
),
Center
(
c
),
Radius
(
r
)
{};
CircularArc
(
std
::
shared_ptr
<
Vertex
const
>
v0
,
std
::
shared_ptr
<
Vertex
const
>
v1
,
std
::
shared_ptr
<
Vertex
const
>
c
,
dou
ble
r
,
bool
fc
=
false
)
:
Curve
(
v0
,
v1
,
fc
),
Center
(
c
),
Radius
(
std
::
make_shared
<
Variable
const
>
(
r
)
)
{};
size_t
set_equation_index
(
size_t
i
)
override
{
EquationIndex
=
i
;
...
...
@@ -23,7 +26,7 @@ public:
size_t
radius_index
()
const
{
return
Radius
->
get_index
();
};
bool
is_coincident
(
std
::
shared_ptr
<
Curve
>
const
&
c
)
const
override
;
bool
is_coincident
(
std
::
shared_ptr
<
Curve
const
>
const
&
c
)
const
override
;
double
a
(
double
s
,
bool
orientation
)
const
override
;
...
...
@@ -35,49 +38,45 @@ public:
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
)
{
void
get_verticies
(
std
::
list
<
std
::
shared_ptr
<
Vertex
const
>>
&
v
,
MatchOrientation
dir
=
MatchOrientation
::
Forward
)
const
override
{
if
(
dir
==
MatchOrientation
::
Forward
)
{
v
.
push_back
(
Start
);
v
.
push_back
(
End
);
v
.
push_back
(
Center
);
}
else
if
(
dir
==
Direc
tion
::
Reverse
)
{
}
else
if
(
dir
==
MatchOrienta
tion
::
Reverse
)
{
v
.
push_back
(
End
);
v
.
push_back
(
Start
);
v
.
push_back
(
Center
);
}
};
void
register_parameters
(
Sketch
*
s
)
override
{
s
->
add_parameter
(
Radius
);
};
void
replace_verticies
(
std
::
vector
<
std
::
shared_ptr
<
Vertex
>>
oldv
,
std
::
vector
<
std
::
shared_ptr
<
Vertex
>>
newv
)
override
;
void
register_parameters
(
Sketch
*
s
)
const
override
{
s
->
add_parameter
(
std
::
const_pointer_cast
<
Variable
>
(
Radius
));
};
void
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
V
ector
Xd
&
r
)
override
;
void
replace_verticies
(
std
::
vector
<
std
::
shared_ptr
<
Vertex
const
>>
const
&
oldv
,
std
::
v
ector
<
std
::
shared_ptr
<
Vertex
const
>>
const
&
newv
)
override
;
std
::
pair
<
double
,
double
>
supremum
(
)
const
override
;
void
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
const
override
;
std
::
shared_ptr
<
Curve
>
clone
()
const
override
{
return
std
::
make_shared
<
CircularArc
>
(
this
);
};
std
::
shared_ptr
<
Vertex
>
center
()
const
{
return
Center
;
};
std
::
shared_ptr
<
Vertex
const
>
center
()
const
{
return
Center
;
};
MatchOrientation
is_identical
(
std
::
shared_ptr
<
Curve
const
>
const
&
c
)
const
override
;
Direc
tion
is_identical
(
std
::
shared_ptr
<
Curve
>
const
&
c
)
const
override
;
MatchOrienta
tion
is_identical
(
std
::
shared_ptr
<
Curve
const
>
const
&
c
,
std
::
shared_ptr
<
Vertex
const
>
const
&
origin
,
double
angle
)
const
override
;
Direction
is_identical
(
std
::
shared_ptr
<
Curve
>
const
&
c
,
std
::
shared_ptr
<
Vertex
>
const
&
origin
,
double
const
angle
)
const
override
;
double2
point
(
double
s
)
const
override
;
sPoint
point
(
double
s
)
const
override
;
double
2
s
upremum
(
)
const
override
;
Vertex
tangent
(
double
s
,
bool
orientation
)
const
override
;
double2
tangent
(
double
s
,
bool
orientation
)
const
override
;
protected:
std
::
shared_ptr
<
Vertex
>
Center
;
std
::
shared_ptr
<
Variable
>
Radius
;
std
::
shared_ptr
<
Vertex
const
>
Center
;
std
::
shared_ptr
<
Variable
const
>
Radius
;
bool
on_manifold
(
const
double
x
,
const
double
y
)
const
override
;
bool
on_manifold
(
double
x
,
double
y
)
const
override
;
bool
on_segment
(
const
double
x
,
const
double
y
)
const
override
;
bool
on_segment
(
double
x
,
double
y
)
const
override
;
double
s_to_a
(
double
s
)
const
;
...
...
@@ -85,7 +84,7 @@ protected:
double
arc_angle
()
const
;
Direc
tion
is_identical
(
const
double
r
,
const
double
xc
,
const
double
yc
,
const
double
xs
,
const
double
ys
,
const
double
xe
,
const
double
ye
)
const
;
MatchOrienta
tion
is_identical
(
double
r
,
double
xc
,
double
yc
,
double
xs
,
double
ys
,
double
xe
,
double
ye
)
const
;
};
#endif //OERSTED_CIRCULARARC_H
src/Sketch/src/Coincident.cpp
View file @
44d05ecd
...
...
@@ -3,12 +3,12 @@
#include
"LineSegment.h"
template
<
>
void
Coincident
<
CircularArc
>::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
{
const
double
rc
=
Element
->
radius
();
const
double
xc
=
Element
->
center
()
->
x
();
const
double
yc
=
Element
->
center
()
->
y
();
const
double
xp
=
Point
->
x
();
const
double
yp
=
Point
->
y
();
void
Coincident
<
CircularArc
>::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
const
{
double
rc
=
Element
->
radius
();
double
xc
=
Element
->
center
()
->
x
();
double
yc
=
Element
->
center
()
->
y
();
double
xp
=
Point
->
x
();
double
yp
=
Point
->
y
();
double
dx
=
xp
-
xc
;
double
dy
=
yp
-
yc
;
...
...
@@ -32,14 +32,14 @@ template
class
Coincident
<
CircularArc
>;
template
<
>
void
Coincident
<
LineSegment
>::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
{
const
double
xp
=
Point
->
x
();
const
double
yp
=
Point
->
y
();
const
double
x0
=
Element
->
start
()
->
x
();
const
double
y0
=
Element
->
start
()
->
y
();
const
double
x1
=
Element
->
end
()
->
x
();
const
double
y1
=
Element
->
end
()
->
y
();
void
Coincident
<
LineSegment
>::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
const
{
double
xp
=
Point
->
x
();
double
yp
=
Point
->
y
();
double
x0
=
Element
->
start
()
->
x
();
double
y0
=
Element
->
start
()
->
y
();
double
x1
=
Element
->
end
()
->
x
();
double
y1
=
Element
->
end
()
->
y
();
double
dx0
=
x0
-
xp
;
double
dy0
=
y0
-
yp
;
...
...
src/Sketch/src/Coincident.h
View file @
44d05ecd
...
...
@@ -8,18 +8,19 @@ class Vertex;
template
<
class
T
>
class
Coincident
:
public
Constraint
{
public:
Coincident
(
std
::
shared_ptr
<
Vertex
>
p
,
std
::
shared_ptr
<
T
>
e
)
:
Point
(
p
),
Element
(
e
)
{};
Coincident
(
std
::
shared_ptr
<
Vertex
const
>
p
,
std
::
shared_ptr
<
T
const
>
e
)
:
Point
(
p
),
Element
(
e
)
{};