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
000b41f0
Commit
000b41f0
authored
Nov 18, 2016
by
JasonPries
Browse files
Change Sketch Variable and Vertex vectors from raw pointers to shared pointers
parent
305f7d04
Changes
42
Hide whitespace changes
Inline
Side-by-side
.idea/Oersted.iml
View file @
000b41f0
...
...
@@ -70,14 +70,15 @@
<sourceFolder
url=
"file://$MODULE_DIR$/CMakeLists.txt"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_Curve.cpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_LineSegment.cpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_Pattern.cpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_Sketch.cpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_MirrorCopy.cpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_Contour.cpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_CircularArc.cpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_Vertex.cpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_Star.cpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_
Sketch.h
pp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_
RotateCopy.c
pp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_Constraint.cpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/Sketch/test_Sketch.hpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/main.cpp"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/CMakeLists.txt"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/test/UseCases/test_Rotor.cpp"
isTestSource=
"false"
/>
...
...
src/Mesh/src/Point.h
View file @
000b41f0
...
...
@@ -10,9 +10,11 @@ public:
Point
(
double
x
,
double
y
)
:
X
{
x
},
Y
{
y
}
{};
Point
(
Vertex
const
&
v
)
:
X
{
v
.
x
()},
Y
{
v
.
y
()}
{};
//
Point(Vertex const &v) : X{v.x()}, Y{v.y()} {};
Point
(
Vertex
const
*
v
)
:
X
{
v
->
x
()},
Y
{
v
->
y
()}
{};
Point
(
std
::
shared_ptr
<
Vertex
>
v
)
:
X
{
v
->
x
()},
Y
{
v
->
y
()}
{};
Point
(
sPoint
const
pp
)
:
X
{
pp
.
x
()},
Y
{
pp
.
y
()}
{};
//double W; // Nurbs weight?
double
X
;
...
...
src/Sketch/src/CircularArc.cpp
View file @
000b41f0
...
...
@@ -94,10 +94,10 @@ double CircularArc::arc_angle() const {
return
(
a1
-
a0
);
}
Vertex
CircularArc
::
point
(
double
s
)
const
{
sPoint
CircularArc
::
point
(
double
s
)
const
{
double
a
=
s_to_a
(
s
);
return
Vertex
{
center
()
->
x
()
+
radius
()
*
cos
(
a
),
center
()
->
y
()
+
radius
()
*
sin
(
a
)};
return
sPoint
{
center
()
->
x
()
+
radius
()
*
cos
(
a
),
center
()
->
y
()
+
radius
()
*
sin
(
a
)};
}
Vertex
CircularArc
::
tangent
(
double
s
,
bool
orientation
)
const
{
...
...
@@ -167,7 +167,7 @@ std::pair<double, double> CircularArc::supremum() const {
double
s
=
a_to_s
(
center
()
->
atan
());
if
(
s
>
0.0
&&
s
<
1.0
)
{
Vertex
v
=
point
(
s
);
sPoint
v
=
point
(
s
);
xx
=
v
.
x
();
yy
=
v
.
y
();
val
=
sqrt
(
xx
*
xx
+
yy
*
yy
);
...
...
@@ -216,7 +216,7 @@ bool CircularArc::is_identical(const Curve *c) const {
}
}
bool
CircularArc
::
is_identical
(
const
Curve
*
c
,
const
Vertex
*
origin
,
const
double
angle
)
const
{
bool
CircularArc
::
is_identical
(
const
Curve
*
c
,
std
::
shared_ptr
<
Vertex
>
origin
,
const
double
angle
)
const
{
const
CircularArc
*
cc
=
dynamic_cast
<
const
CircularArc
*>
(
c
);
if
(
cc
==
nullptr
)
{
...
...
@@ -302,7 +302,7 @@ bool CircularArc::on_segment(const double x, const double y) const {
}
}
void
CircularArc
::
replace_verticies
(
std
::
vector
<
Vertex
*
>
oldv
,
std
::
vector
<
Vertex
*
>
newv
)
{
void
CircularArc
::
replace_verticies
(
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
oldv
,
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
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 @
000b41f0
...
...
@@ -14,23 +14,23 @@ public:
friend
class
Tangency
;
// Constructors
CircularArc
()
:
Curve
(),
Radius
(
new
Variable
(
0.0
))
{};
CircularArc
()
:
Curve
(),
Radius
(
std
::
make_shared
<
Variable
>
(
0.0
))
{};
CircularArc
(
const
CircularArc
*
c
)
:
Curve
(
c
->
Start
,
c
->
End
,
c
->
ForConstruction
),
Center
(
c
->
Center
),
Radius
(
c
->
Radius
)
{};
CircularArc
(
Vertex
&
v0
,
Vertex
&
v1
,
Vertex
&
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
,
bool
fc
=
false
)
:
Curve
(
v0
,
v1
,
fc
),
Center
(
c
)
{};
CircularArc
(
Vertex
&
v0
,
Vertex
&
v1
,
Vertex
&
c
,
double
r
,
bool
fc
=
false
)
:
Curve
(
v0
,
v1
,
fc
),
Center
(
&
c
),
Radius
(
new
Variable
{
r
}
)
{};
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
(
Vertex
&
v0
,
Vertex
&
v1
,
Vertex
&
c
,
Variable
&
r
,
Sketch
&
s
,
bool
fc
=
false
)
:
Curve
(
v0
,
v1
,
fc
),
Center
(
&
c
),
Radius
(
&
r
)
{};
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
)
{};
// Accessors
const
Vertex
*
center
()
const
{
return
Center
;
};
std
::
shared_ptr
<
Vertex
>
center
()
const
{
return
Center
;
};
double
radius
()
const
{
return
Radius
->
value
();
};
// Virtual Function Implementation
void
get_verticies
(
std
::
list
<
Vertex
*
>
&
v
)
const
override
{
void
get_verticies
(
std
::
list
<
std
::
shared_ptr
<
Vertex
>
>
&
v
)
const
override
{
v
.
push_back
(
Start
);
v
.
push_back
(
End
);
v
.
push_back
(
Center
);
...
...
@@ -46,7 +46,7 @@ public:
void
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
override
;
// Calculation
Vertex
point
(
double
s
)
const
override
;
sPoint
point
(
double
s
)
const
override
;
Vertex
tangent
(
double
s
,
bool
orientation
)
const
override
;
...
...
@@ -68,18 +68,18 @@ public:
// Curve-Curve Comparison
bool
is_identical
(
const
Curve
*
c
)
const
override
;
bool
is_identical
(
const
Curve
*
c
,
const
Vertex
*
origin
,
const
double
angle
)
const
override
;
bool
is_identical
(
const
Curve
*
c
,
std
::
shared_ptr
<
Vertex
>
origin
,
const
double
angle
)
const
override
;
bool
is_coincident
(
const
Curve
*
c
)
const
override
;
// Modification
Curve
*
clone
()
const
override
{
return
new
CircularArc
(
this
);
};
void
replace_verticies
(
std
::
vector
<
Vertex
*
>
oldv
,
std
::
vector
<
Vertex
*
>
newv
)
override
;
void
replace_verticies
(
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
oldv
,
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
newv
)
override
;
protected:
Vertex
*
Center
;
Variable
*
Radius
;
std
::
shared_ptr
<
Vertex
>
Center
;
std
::
shared_ptr
<
Variable
>
Radius
;
bool
on_manifold
(
const
double
x
,
const
double
y
)
const
override
;
...
...
src/Sketch/src/Coincident.h
View file @
000b41f0
...
...
@@ -4,11 +4,11 @@
template
<
class
T
>
class
Coincident
:
public
Constraint
{
public:
Vertex
*
Point
;
std
::
shared_ptr
<
Vertex
>
Point
;
T
*
Element
;
// Constructors
Coincident
(
Vertex
&
p
,
T
&
e
)
:
Point
(
&
p
),
Element
(
&
e
)
{};
Coincident
(
std
::
shared_ptr
<
Vertex
>
p
,
T
&
e
)
:
Point
(
p
),
Element
(
&
e
)
{};
// Public Member Functions
size_t
set_equation_index
(
size_t
i
)
override
{
...
...
src/Sketch/src/Contour.cpp
View file @
000b41f0
...
...
@@ -7,10 +7,10 @@ Contour::Contour(const std::vector<const Curve *> &c) {
Curves
=
std
::
vector
<
const
Curve
*>
();
Curves
.
reserve
(
c
.
size
());
std
::
vector
<
const
Vertex
*
>
start
;
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
start
;
start
.
reserve
(
c
.
size
());
std
::
vector
<
const
Vertex
*
>
end
;
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
end
;
end
.
reserve
(
c
.
size
());
for
(
size_t
i
=
0
;
i
<
c
.
size
();
i
++
)
{
...
...
@@ -73,8 +73,8 @@ bool Contour::initialize(const std::vector<const Curve *> &c, const std::vector<
Orientation
.
push_back
(
dir
[
i
]);
size_t
j
=
(
i
+
1
)
%
c
.
size
();
const
Vertex
*
vi
=
(
dir
[
i
]
?
c
[
i
]
->
end
()
:
c
[
i
]
->
start
());
const
Vertex
*
vj
=
(
dir
[
j
]
?
c
[
j
]
->
start
()
:
c
[
j
]
->
end
());
std
::
shared_ptr
<
Vertex
>
vi
=
(
dir
[
i
]
?
c
[
i
]
->
end
()
:
c
[
i
]
->
start
());
std
::
shared_ptr
<
Vertex
>
vj
=
(
dir
[
j
]
?
c
[
j
]
->
start
()
:
c
[
j
]
->
end
());
if
(
vi
!=
vj
)
{
return
false
;
}
...
...
@@ -119,8 +119,8 @@ double Contour::area() const {
double
area
{
0.0
};
for
(
size_t
i
=
0
;
i
!=
Curves
.
size
();
++
i
)
{
const
Vertex
*
v0
=
Curves
[
i
]
->
start
();
const
Vertex
*
v1
=
Curves
[
i
]
->
end
();
std
::
shared_ptr
<
Vertex
>
v0
=
Curves
[
i
]
->
start
();
std
::
shared_ptr
<
Vertex
>
v1
=
Curves
[
i
]
->
end
();
const
double
da
=
Curves
[
i
]
->
area
()
+
v0
->
x
()
*
v1
->
y
()
-
v0
->
y
()
*
v1
->
x
();
if
(
Orientation
[
i
])
{
...
...
src/Sketch/src/Contour.h
View file @
000b41f0
...
...
@@ -13,7 +13,7 @@ public:
Contour
(
const
std
::
vector
<
const
Curve
*>
&
c
,
const
std
::
vector
<
bool
>
&
dir
);
//Public Member Functions
const
Vertex
*
vertex
(
size_t
i
)
const
{
return
(
Orientation
[
i
]
?
Curves
[
i
]
->
start
()
:
Curves
[
i
]
->
end
());
};
std
::
shared_ptr
<
Vertex
>
vertex
(
size_t
i
)
const
{
return
(
Orientation
[
i
]
?
Curves
[
i
]
->
start
()
:
Curves
[
i
]
->
end
());
};
const
Curve
*
curve
(
size_t
i
)
const
{
return
Curves
[
i
];
};
...
...
src/Sketch/src/Curve.cpp
View file @
000b41f0
#include
"Sketch.hpp"
Curve
*
Curve
::
split
(
Vertex
*
vnew
,
double
s
)
{
Curve
*
cnew
=
clone
();
*
(
vnew
)
=
point
(
s
);
End
=
vnew
;
cnew
->
Start
=
vnew
;
return
cnew
;
}
bool
Curve
::
on_segment
(
const
Vertex
*
v
)
const
{
bool
Curve
::
on_segment
(
std
::
shared_ptr
<
Vertex
>
v
)
const
{
return
on_segment
(
v
->
x
(),
v
->
y
());
}
bool
Curve
::
on_segment
(
const
Vertex
*
v
,
const
Vertex
*
origin
,
const
double
angle
)
const
{
bool
Curve
::
on_segment
(
std
::
shared_ptr
<
Vertex
>
v
,
std
::
shared_ptr
<
Vertex
>
origin
,
const
double
angle
)
const
{
double
x
,
y
;
std
::
tie
(
x
,
y
)
=
v
->
rotate
(
origin
,
angle
);
return
on_segment
(
x
,
y
);
}
bool
Curve
::
on_manifold
(
const
Vertex
*
v
)
const
{
bool
Curve
::
on_manifold
(
std
::
shared_ptr
<
Vertex
>
v
)
const
{
return
on_manifold
(
v
->
x
(),
v
->
y
());
}
bool
Curve
::
on_manifold
(
const
Vertex
*
v
,
const
Vertex
*
origin
,
const
double
angle
)
const
{
bool
Curve
::
on_manifold
(
std
::
shared_ptr
<
Vertex
>
v
,
std
::
shared_ptr
<
Vertex
>
origin
,
const
double
angle
)
const
{
double
x
,
y
;
std
::
tie
(
x
,
y
)
=
v
->
rotate
(
origin
,
angle
);
...
...
src/Sketch/src/Curve.h
View file @
000b41f0
...
...
@@ -10,23 +10,23 @@ public:
// Constructors
Curve
()
:
Start
(
nullptr
),
End
(
nullptr
)
{};
Curve
(
Vertex
&
v0
,
Vertex
&
v1
,
bool
fc
=
false
)
:
Start
(
&
v0
),
End
(
&
v1
),
ForConstruction
(
fc
)
{};
Curve
(
std
::
shared_ptr
<
Vertex
>
v0
,
std
::
shared_ptr
<
Vertex
>
v1
,
bool
fc
=
false
)
:
Start
(
v0
),
End
(
v1
),
ForConstruction
(
fc
)
{};
Curve
(
Vertex
*
v0
,
Vertex
*
v1
,
bool
fc
=
false
)
:
Start
(
v0
),
End
(
v1
),
ForConstruction
(
fc
)
{};
//
Curve(Vertex *v0, Vertex *v1, bool fc = false) : Start(v0), End(v1), ForConstruction(fc) {};
// Properties
bool
ForConstruction
=
false
;
// Accessors
const
Vertex
*
start
()
const
{
return
Start
;
};
std
::
shared_ptr
<
Vertex
>
start
()
const
{
return
Start
;
};
const
Vertex
*
end
()
const
{
return
End
;
};
std
::
shared_ptr
<
Vertex
>
end
()
const
{
return
End
;
};
virtual
void
get_verticies
(
std
::
list
<
Vertex
*
>
&
v
)
const
=
0
;
virtual
void
get_verticies
(
std
::
list
<
std
::
shared_ptr
<
Vertex
>
>
&
v
)
const
=
0
;
// Calculation
// #TODO: Add const to double_t and bool arguments where appropriate
virtual
Vertex
point
(
double
s
)
const
=
0
;
virtual
sPoint
point
(
double
s
)
const
=
0
;
virtual
Vertex
tangent
(
double
s
,
bool
orientation
)
const
=
0
;
...
...
@@ -39,15 +39,15 @@ public:
virtual
std
::
pair
<
double
,
double
>
supremum
()
const
=
0
;
// maximum length of vector between origin and point on curve
// Curve-Vertex Comparison
virtual
bool
on_manifold
(
const
Vertex
*
v
)
const
final
;
// true if vertex is on manifold defined by curve
virtual
bool
on_manifold
(
const
Vertex
*
v
,
const
Vertex
*
origin
,
const
double
angle
)
const
final
;
virtual
bool
on_manifold
(
std
::
shared_ptr
<
Vertex
>
v
)
const
final
;
// true if vertex is on manifold defined by curve
virtual
bool
on_manifold
(
std
::
shared_ptr
<
Vertex
>
v
,
std
::
shared_ptr
<
Vertex
>
origin
,
const
double
angle
)
const
final
;
virtual
bool
on_segment
(
const
Vertex
*
v
)
const
final
;
// true if vertex is on curve segment
virtual
bool
on_segment
(
const
Vertex
*
v
,
const
Vertex
*
origin
,
const
double
angle
)
const
final
;
virtual
bool
on_segment
(
std
::
shared_ptr
<
Vertex
>
v
)
const
final
;
// true if vertex is on curve segment
virtual
bool
on_segment
(
std
::
shared_ptr
<
Vertex
>
v
,
std
::
shared_ptr
<
Vertex
>
origin
,
const
double
angle
)
const
final
;
// Curve-Curve Comparison
virtual
bool
is_identical
(
const
Curve
*
c
)
const
=
0
;
// true if (input curve) XOR (object curve) is a set with measure < tol
virtual
bool
is_identical
(
const
Curve
*
c
,
const
Vertex
*
origin
,
const
double
angle
)
const
=
0
;
virtual
bool
is_identical
(
const
Curve
*
c
,
std
::
shared_ptr
<
Vertex
>
origin
,
const
double
angle
)
const
=
0
;
// #TODO: virtual bool is_overlapping(const Curve* c) const = 0; // true if (input curve) AND (object curve) is a set with measure > tol
// #TODO: virtual bool is_overlapping(const Curve* c, const Vertex* origin, const double_t angle) const = 0;
...
...
@@ -56,16 +56,15 @@ public:
// #TODO: virtual bool is_coincident(const Curve* c, const Vertex* origin, const double_t angle) const = 0;
// Modification
Curve
*
split
(
Vertex
*
v
,
double
s
);
void
reverse
()
{
std
::
swap
(
Start
,
End
);
};
virtual
Curve
*
clone
()
const
=
0
;
virtual
void
replace_verticies
(
std
::
vector
<
Vertex
*
>
oldv
,
std
::
vector
<
Vertex
*
>
newv
)
=
0
;
virtual
void
replace_verticies
(
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
oldv
,
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
newv
)
=
0
;
protected:
Vertex
*
Start
,
*
End
;
std
::
shared_ptr
<
Vertex
>
Start
;
std
::
shared_ptr
<
Vertex
>
End
;
virtual
bool
on_manifold
(
const
double
x
,
const
double
y
)
const
=
0
;
...
...
src/Sketch/src/Distance.cpp
View file @
000b41f0
...
...
@@ -204,17 +204,17 @@ template
class
Distance
<
LineSegment
>;
template
<
>
size_t
Distance
<
Vertex
>::
set_equation_index
(
size_t
i
)
{
size_t
Distance
<
std
::
shared_ptr
<
Vertex
>
>
::
set_equation_index
(
size_t
i
)
{
EquationIndex
=
i
;
return
1
;
}
template
<
>
void
Distance
<
Vertex
>::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
{
const
double
x0
=
Element0
->
x
();
const
double
y0
=
Element0
->
y
();
const
double
x1
=
Element1
->
x
();
const
double
y1
=
Element1
->
y
();
void
Distance
<
std
::
shared_ptr
<
Vertex
>
>
::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
{
const
double
x0
=
(
*
Element0
)
->
x
();
const
double
y0
=
(
*
Element0
)
->
y
();
const
double
x1
=
(
*
Element1
)
->
x
();
const
double
y1
=
(
*
Element1
)
->
y
();
double
dx
=
x1
-
x0
;
double
dy
=
y1
-
y0
;
...
...
@@ -224,11 +224,11 @@ void Distance<Vertex>::update(Eigen::MatrixXd &J, Eigen::VectorXd &r) {
r
(
EquationIndex
)
=
dr
-
Dim
;
J
(
EquationIndex
,
Element0
->
X
->
get_index
())
-=
dx
;
J
(
EquationIndex
,
Element0
->
Y
->
get_index
())
-=
dy
;
J
(
EquationIndex
,
Element1
->
X
->
get_index
())
+=
dx
;
J
(
EquationIndex
,
Element1
->
Y
->
get_index
())
+=
dy
;
J
(
EquationIndex
,
(
*
Element0
)
->
X
->
get_index
())
-=
dx
;
J
(
EquationIndex
,
(
*
Element0
)
->
Y
->
get_index
())
-=
dy
;
J
(
EquationIndex
,
(
*
Element1
)
->
X
->
get_index
())
+=
dx
;
J
(
EquationIndex
,
(
*
Element1
)
->
Y
->
get_index
())
+=
dy
;
}
template
class
Distance
<
Vertex
>;
\ No newline at end of file
class
Distance
<
std
::
shared_ptr
<
Vertex
>
>
;
\ No newline at end of file
src/Sketch/src/Fixation.cpp
View file @
000b41f0
#include
"Sketch.hpp"
Fixation
::
Fixation
(
Vertex
&
v
)
{
Point
=
&
v
;
Dim
=
new
Vertex
(
v
);
Fixation
::
Fixation
(
std
::
shared_ptr
<
Vertex
>
v
)
{
Point
=
v
;
Dim
=
sPoint
(
v
->
x
(),
v
->
y
()
);
}
void
Fixation
::
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
{
r
(
EquationIndex
)
=
Point
->
x
()
-
Dim
->
x
()
;
r
(
EquationIndex
)
=
Point
->
x
()
-
Dim
.
X
;
J
(
EquationIndex
,
Point
->
X
->
get_index
())
+=
1.0
;
r
(
EquationIndex
+
1
)
=
Point
->
y
()
-
Dim
->
y
()
;
r
(
EquationIndex
+
1
)
=
Point
->
y
()
-
Dim
.
Y
;
J
(
EquationIndex
+
1
,
Point
->
Y
->
get_index
())
+=
1.0
;
}
\ No newline at end of file
src/Sketch/src/Fixation.h
View file @
000b41f0
...
...
@@ -3,11 +3,11 @@
class
Fixation
:
public
Constraint
{
public:
Vertex
*
Point
;
Vertex
*
Dim
;
std
::
shared_ptr
<
Vertex
>
Point
;
sPoint
Dim
;
// Constructors
Fixation
(
Vertex
&
v
);
Fixation
(
std
::
shared_ptr
<
Vertex
>
v
);
// Public Member Functions
size_t
set_equation_index
(
size_t
i
)
override
{
...
...
src/Sketch/src/LineSegment.cpp
View file @
000b41f0
#include
"Sketch.hpp"
Vertex
LineSegment
::
point
(
double
s
)
const
{
sPoint
LineSegment
::
point
(
double
s
)
const
{
const
double
x0
=
start
()
->
x
();
const
double
y0
=
start
()
->
y
();
const
double
x1
=
end
()
->
x
();
const
double
y1
=
end
()
->
y
();
return
Vertex
{
x0
*
(
1.0
-
s
)
+
x1
*
s
,
y0
*
(
1.0
-
s
)
+
y1
*
s
};
return
sPoint
{
x0
*
(
1.0
-
s
)
+
x1
*
s
,
y0
*
(
1.0
-
s
)
+
y1
*
s
};
}
Vertex
LineSegment
::
tangent
(
double
s
,
bool
orientation
)
const
{
...
...
@@ -115,7 +115,7 @@ bool LineSegment::is_identical(const Curve *c) const {
}
}
bool
LineSegment
::
is_identical
(
const
Curve
*
c
,
const
Vertex
*
origin
,
const
double
angle
)
const
{
bool
LineSegment
::
is_identical
(
const
Curve
*
c
,
std
::
shared_ptr
<
Vertex
>
origin
,
const
double
angle
)
const
{
const
LineSegment
*
l
=
dynamic_cast
<
const
LineSegment
*>
(
c
);
if
(
l
==
nullptr
)
{
...
...
@@ -162,7 +162,7 @@ bool LineSegment::is_coincident(const Curve *c) const {
double
LineSegment
::
length
()
const
{
return
hypot
(
end
()
->
x
()
-
start
()
->
x
(),
end
()
->
y
()
-
start
()
->
y
());
};
void
LineSegment
::
replace_verticies
(
std
::
vector
<
Vertex
*
>
oldv
,
std
::
vector
<
Vertex
*
>
newv
)
{
void
LineSegment
::
replace_verticies
(
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
oldv
,
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
newv
)
{
auto
i
=
std
::
find
(
oldv
.
begin
(),
oldv
.
end
(),
Start
);
if
(
i
!=
oldv
.
end
())
{
size_t
j
=
i
-
oldv
.
begin
();
...
...
src/Sketch/src/LineSegment.h
View file @
000b41f0
...
...
@@ -24,10 +24,10 @@ public:
LineSegment
(
const
LineSegment
*
l
)
:
Curve
(
l
->
Start
,
l
->
End
,
l
->
ForConstruction
)
{};
LineSegment
(
Vertex
&
v0
,
Vertex
&
v1
,
bool
fc
=
false
)
:
Curve
(
v0
,
v1
,
fc
)
{};
LineSegment
(
std
::
shared_ptr
<
Vertex
>
v0
,
std
::
shared_ptr
<
Vertex
>
v1
,
bool
fc
=
false
)
:
Curve
(
v0
,
v1
,
fc
)
{};
// Virtual Function Implementation
void
get_verticies
(
std
::
list
<
Vertex
*
>
&
v
)
const
override
{
void
get_verticies
(
std
::
list
<
std
::
shared_ptr
<
Vertex
>
>
&
v
)
const
override
{
v
.
push_back
(
Start
);
v
.
push_back
(
End
);
};
...
...
@@ -42,7 +42,7 @@ public:
void
update
(
Eigen
::
MatrixXd
&
J
,
Eigen
::
VectorXd
&
r
)
override
{};
// Calculation
Vertex
point
(
double
s
)
const
override
;
sPoint
point
(
double
s
)
const
override
;
Vertex
tangent
(
double
s
,
bool
orientation
)
const
override
;
...
...
@@ -64,14 +64,14 @@ public:
// Curve-Curve Comparison
bool
is_identical
(
const
Curve
*
c
)
const
override
;
bool
is_identical
(
const
Curve
*
c
,
const
Vertex
*
origin
,
const
double
angle
)
const
override
;
bool
is_identical
(
const
Curve
*
c
,
std
::
shared_ptr
<
Vertex
>
origin
,
const
double
angle
)
const
override
;
bool
is_coincident
(
const
Curve
*
c
)
const
override
;
// Modification
Curve
*
clone
()
const
override
{
return
new
LineSegment
(
this
);
};
void
replace_verticies
(
std
::
vector
<
Vertex
*
>
oldv
,
std
::
vector
<
Vertex
*
>
newv
)
override
;
void
replace_verticies
(
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
oldv
,
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
newv
)
override
;
protected:
bool
on_manifold
(
const
double
x
,
const
double
y
)
const
override
;
...
...
src/Sketch/src/MirrorCopy.cpp
View file @
000b41f0
...
...
@@ -11,7 +11,7 @@ MirrorCopy::MirrorCopy(std::vector<const Curve *> &input, LineSegment *l, bool r
// Clone input curves and create a list of unique input verticies
Curves
.
reserve
(
Input
.
size
());
std
::
list
<
Vertex
*
>
input_vlist
;
std
::
list
<
std
::
shared_ptr
<
Vertex
>
>
input_vlist
;
for
(
auto
c
:
Input
)
{
if
(
l
->
is_coincident
(
c
))
{
const_cast
<
Curve
*>
(
c
)
->
ForConstruction
=
RemoveInternalBoundaries
;
// TODO: const_cast is ugly
...
...
@@ -48,7 +48,9 @@ MirrorCopy::MirrorCopy(std::vector<const Curve *> &input, LineSegment *l, bool r
px
=
x
-
2.0
*
px
;
py
=
y
-
2.0
*
py
;
Verticies
.
push_back
(
new
Vertex
(
px
,
py
));
//Verticies.push_back(new Vertex(px, py));
Verticies
.
push_back
(
std
::
make_shared
<
Vertex
>
(
px
,
py
));
++
v
;
}
else
{
...
...
@@ -57,7 +59,7 @@ MirrorCopy::MirrorCopy(std::vector<const Curve *> &input, LineSegment *l, bool r
}
// Replace verticies in mirror curves
std
::
vector
<
Vertex
*
>
input_vvector
{
input_vlist
.
begin
(),
input_vlist
.
end
()};
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
input_vvector
{
input_vlist
.
begin
(),
input_vlist
.
end
()};
for
(
auto
c
:
Curves
)
{
c
->
replace_verticies
(
input_vvector
,
Verticies
);
c
->
reverse
();
...
...
@@ -66,6 +68,6 @@ MirrorCopy::MirrorCopy(std::vector<const Curve *> &input, LineSegment *l, bool r
// Constrain mirrored verticies to be symmetric about the SymmetryLine
Constraints
.
reserve
(
Verticies
.
size
());
for
(
size_t
i
=
0
;
i
!=
Verticies
.
size
();
++
i
)
{
Constraints
.
push_back
(
new
Symmetry
(
*
input_vvector
[
i
],
*
Verticies
[
i
],
*
SymmetryLine
));
Constraints
.
push_back
(
new
Symmetry
(
input_vvector
[
i
],
Verticies
[
i
],
*
SymmetryLine
));
}
}
\ No newline at end of file
src/Sketch/src/Pattern.cpp
View file @
000b41f0
...
...
@@ -2,7 +2,7 @@
void
Pattern
::
register_elements
(
Sketch
*
s
)
{
for
(
auto
v
:
Verticies
)
{
s
->
add_element
(
*
v
);
s
->
add_element
(
v
);
}
for
(
auto
c
:
Curves
)
{
...
...
src/Sketch/src/Pattern.h
View file @
000b41f0
...
...
@@ -20,7 +20,7 @@ protected:
std
::
vector
<
const
Curve
*>
Input
;
bool
RemoveInternalBoundaries
;
std
::
vector
<
Vertex
*
>
Verticies
;
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
Verticies
;
std
::
vector
<
Curve
*>
Curves
;
std
::
vector
<
Constraint
*>
Constraints
;
};
...
...
src/Sketch/src/RotateCopy.cpp
View file @
000b41f0
#include
"Sketch.hpp"
RotateCopy
::
RotateCopy
(
std
::
vector
<
const
Curve
*>
&
input
,
Vertex
*
center
,
double
angle
,
size_t
copies
,
bool
remove_internal
)
{
RotateCopy
::
RotateCopy
(
std
::
vector
<
const
Curve
*>
&
input
,
std
::
shared_ptr
<
Vertex
>
center
,
double
angle
,
size_t
copies
,
bool
remove_internal
)
{
// Creates rotated copies of the input curves about an vertex
// #TODO: Need to rearrange code and reserve vector sizes in a way that makes more sense (much code copied from MirrorCopy constructor)
// #TODO: Restructure to obviate the need for local_curves and local_verticies
...
...
@@ -48,9 +48,9 @@ RotateCopy::RotateCopy(std::vector<const Curve *> &input, Vertex *center, double
// TODO: Check for complete elimination of leading/lagging curves
// Get leading/lagging verticies
std
::
vector
<
Vertex
*
>
leading_verticies
;
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
leading_verticies
;
{
std
::
list
<
Vertex
*
>
local_verts
;
std
::
list
<
std
::
shared_ptr
<
Vertex
>
>
local_verts
;
for
(
auto
i
:
leading_curves
)
{
i
->
get_verticies
(
local_verts
);
}
...
...
@@ -61,9 +61,9 @@ RotateCopy::RotateCopy(std::vector<const Curve *> &input, Vertex *center, double
leading_verticies
.
assign
(
local_verts
.
begin
(),
local_verts
.
end
());
// assign to vector
}
std
::
vector
<
Vertex
*
>
lagging_verticies
;
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
lagging_verticies
;
{
std
::
list
<
Vertex
*
>
local_verts
;
std
::
list
<
std
::
shared_ptr
<
Vertex
>
>
local_verts
;
for
(
auto
i
:
lagging_curves
)
{
i
->
get_verticies
(
local_verts
);
}
...
...
@@ -75,9 +75,9 @@ RotateCopy::RotateCopy(std::vector<const Curve *> &input, Vertex *center, double
}
// Get internal verticies
std
::
vector
<
Vertex
*
>
internal_verticies
;
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
internal_verticies
;
{
std
::
list
<
Vertex
*
>
local_verts
;
std
::
list
<
std
::
shared_ptr
<
Vertex
>
>
local_verts
;
for
(
auto
c
:
internal_curves
)
{
c
->
get_verticies
(
local_verts
);
}
...
...
@@ -100,7 +100,7 @@ RotateCopy::RotateCopy(std::vector<const Curve *> &input, Vertex *center, double
}
// Make rotated copies
std
::
vector
<
Vertex
*
>
rotated_lagging
(
leading_verticies
.
begin
(),
leading_verticies
.
end
());
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
rotated_lagging
(
leading_verticies
.
begin
(),
leading_verticies
.
end
());
for
(
size_t
i
=
0
;
i
!=
Copies
;
++
i
)
{
bool
last_iteration
=
(
i
==
Copies
-
1
);
// Create curve clones
...
...
@@ -130,7 +130,7 @@ RotateCopy::RotateCopy(std::vector<const Curve *> &input, Vertex *center, double
double
x0
=
Center
->
x
();
double
y0
=
Center
->
y
();
std
::
vector
<
Vertex
*
>
rotated_leading
;
std
::
vector
<
std
::
shared_ptr
<
Vertex
>
>
rotated_leading
;
for
(
auto
v
:
leading_verticies
)
{
double
dx
=
v
->
x
()
-
x0
;
double
dy
=
v
->
y
()
-
y0
;
...
...
@@ -138,14 +138,16 @@ RotateCopy::RotateCopy(std::vector<const Curve *> &input, Vertex *center, double
double
vx
=
cosa
*
dx
-
sina
*
dy
+
x0
;
double
vy
=
sina
*
dx
+
cosa
*
dy
+
y0
;
rotated_leading
.
push_back
(
new
Vertex
(
vx
,
vy
));
//rotated_leading.push_back(new Vertex(vx, vy));
rotated_leading
.
push_back
(
std
::
make_shared
<
Vertex
>
(
vx
,
vy
));