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
fab91099
Commit
fab91099
authored
Nov 19, 2016
by
JasonPries
Browse files
Change Sketch Boundary and Contour vector from raw pointers to shared pointers
parent
000b41f0
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/Mesh/src/Mesh.h
View file @
fab91099
...
...
@@ -128,9 +128,9 @@ public:
InsertPointResult
insert_point
(
Point
const
p
)
{
return
insert_point
(
p
,
Edges
.
size
()
-
1
);
};
protected:
Contour
const
*
Boundary
;
std
::
shared_ptr
<
Contour
>
Boundary
;
std
::
vector
<
Curve
const
*>
Curves
;
std
::
vector
<
Contour
const
*
>
Contours
;
std
::
vector
<
std
::
shared_ptr
<
Contour
>
>
Contours
;
std
::
vector
<
Point
>
Points
;
std
::
vector
<
Edge
>
Edges
;
...
...
src/Sketch/src/Constellation.cpp
View file @
fab91099
...
...
@@ -75,7 +75,7 @@ void Constellation::pop(const Curve *c) {
}
}
bool
Constellation
::
boundary
(
Contour
*
c
)
{
bool
Constellation
::
boundary
(
std
::
shared_ptr
<
Contour
>
c
)
{
std
::
vector
<
const
Curve
*>
curves
;
std
::
vector
<
bool
>
orientation
;
...
...
@@ -121,14 +121,14 @@ bool Constellation::boundary(Contour *c) {
}
}
bool
Constellation
::
contours
(
std
::
vector
<
Contour
*
>
&
contours
)
{
bool
Constellation
::
contours
(
std
::
vector
<
std
::
shared_ptr
<
Contour
>
>
&
contours
)
{
std
::
vector
<
const
Curve
*>
contour_curves
;
std
::
vector
<
bool
>
orientation
;
while
(
size
()
>
0
)
{
bool
success
=
find_closed_contour
(
contour_curves
,
orientation
);
if
(
success
)
{
contours
.
push_back
(
new
Contour
(
contour_curves
,
orientation
));
contours
.
push_back
(
std
::
make_shared
<
Contour
>
(
contour_curves
,
orientation
));
}
else
{
return
false
;
}
...
...
src/Sketch/src/Constellation.h
View file @
fab91099
...
...
@@ -12,9 +12,9 @@ public:
size_t
size
()
{
return
Stars
.
size
();
};
bool
contours
(
std
::
vector
<
Contour
*
>
&
contours
);
bool
contours
(
std
::
vector
<
std
::
shared_ptr
<
Contour
>
>
&
contours
);
bool
boundary
(
Contour
*
c
);
bool
boundary
(
std
::
shared_ptr
<
Contour
>
);
private:
std
::
list
<
Star
>
Stars
;
...
...
src/Sketch/src/Sketch.cpp
View file @
fab91099
...
...
@@ -3,12 +3,10 @@
Sketch
::
Sketch
()
{
NumEquations
=
0
;
NumVariables
=
0
;
Boundary
=
new
Contour
();
Boundary
=
std
::
make_shared
<
Contour
>
();
}
void
Sketch
::
delete_me
()
{
delete
Boundary
;
Variables
.
clear
();
Verticies
.
clear
();
...
...
@@ -28,9 +26,6 @@ void Sketch::delete_me() {
}
Patterns
.
clear
();
for
(
auto
x
:
Contours
)
{
delete
x
;
}
Contours
.
clear
();
};
...
...
@@ -78,7 +73,6 @@ void Sketch::solve() {
bool
Sketch
::
build
()
{
Constellation
c
=
Constellation
(
this
);
bool
success
=
c
.
boundary
(
Boundary
);
Contours
.
resize
(
0
);
...
...
src/Sketch/src/Sketch.h
View file @
fab91099
...
...
@@ -155,9 +155,9 @@ public:
const
Constraint
*
constraint
(
size_t
i
)
const
{
return
Constraints
[
i
];
};
const
Contour
*
contour
(
size_t
i
)
const
{
return
Contours
[
i
];
};
std
::
shared_ptr
<
Contour
>
contour
(
size_t
i
)
const
{
return
Contours
[
i
];
};
const
Contour
*
boundary
()
const
{
return
Boundary
;
};
std
::
shared_ptr
<
Contour
>
boundary
()
const
{
return
Boundary
;
};
size_t
size
()
const
{
return
(
Verticies
.
size
()
+
Curves
.
size
()
+
Constraints
.
size
());
};
...
...
@@ -178,7 +178,6 @@ public:
template
<
class
T
,
class
...
ArgT
>
std
::
shared_ptr
<
T
>
new_element_SHARED_PTR
(
ArgT
&&
...
args
);
//#TODO: Add elements by pointer
void
add_element
(
std
::
shared_ptr
<
Vertex
>
v
);
void
add_element
(
Curve
&
c
);
...
...
@@ -217,9 +216,9 @@ private:
std
::
vector
<
Constraint
*>
Constraints
;
std
::
vector
<
Pattern
*>
Patterns
;
std
::
vector
<
Contour
*
>
Contours
;
std
::
vector
<
std
::
shared_ptr
<
Contour
>
>
Contours
;
Contour
*
Boundary
;
std
::
shared_ptr
<
Contour
>
Boundary
;
size_t
NumVariables
;
size_t
NumEquations
;
...
...
test/Sketch/test_RotateCopy.cpp
View file @
fab91099
...
...
@@ -131,7 +131,7 @@ TEST(RotateCopy, nonoverlapping) {
TEST
(
RotateCopy
,
overlapping
)
{
for
(
bool
remove_internal
:
{
true
,
false
})
{
Sketch
s
;
Sketch
s
=
Sketch
()
;
size_t
N
=
4
;
double
a_deg
=
360.0
/
N
;
...
...
test/Sketch/test_Star.cpp
View file @
fab91099
...
...
@@ -214,7 +214,7 @@ TEST(Star, find_closed_contour_0) {
EXPECT_EQ
(
sketch
.
size_contours
(),
1
);
EXPECT_TRUE
(
*
sketch
.
contour
(
0
)
==
*
sketch
.
boundary
());
const
Contour
*
contour
=
sketch
.
contour
(
0
);
auto
contour
=
sketch
.
contour
(
0
);
EXPECT_TRUE
(
contour
->
size
()
==
3
);
EXPECT_TRUE
(
&
l0
==
contour
->
curve
(
0
)
||
&
l0
==
contour
->
curve
(
1
)
||
&
l0
==
contour
->
curve
(
2
));
EXPECT_TRUE
(
&
l5
==
contour
->
curve
(
0
)
||
&
l5
==
contour
->
curve
(
1
)
||
&
l5
==
contour
->
curve
(
2
));
...
...
@@ -255,7 +255,7 @@ TEST(Star, find_closed_contour_1) {
EXPECT_TRUE
(
sketch
.
size_contours
()
==
1
);
EXPECT_TRUE
(
*
sketch
.
contour
(
0
)
==
*
sketch
.
boundary
());
const
Contour
*
contour
=
sketch
.
contour
(
0
);
auto
contour
=
sketch
.
contour
(
0
);
EXPECT_TRUE
(
contour
->
size
()
==
3
);
EXPECT_TRUE
(
&
l0
==
contour
->
curve
(
0
)
||
&
l0
==
contour
->
curve
(
1
)
||
&
l0
==
contour
->
curve
(
2
));
EXPECT_TRUE
(
&
l1
==
contour
->
curve
(
0
)
||
&
l1
==
contour
->
curve
(
1
)
||
&
l1
==
contour
->
curve
(
2
));
...
...
@@ -302,7 +302,7 @@ TEST(Star, find_closed_contour_2) {
EXPECT_FALSE
(
sketch
.
contour
(
0
)
==
sketch
.
boundary
());
EXPECT_FALSE
(
sketch
.
contour
(
1
)
==
sketch
.
boundary
());
const
Contour
*
contour
=
sketch
.
contour
(
1
);
auto
contour
=
sketch
.
contour
(
1
);
EXPECT_EQ
(
contour
->
size
(),
3
);
EXPECT_TRUE
(
&
l0
==
contour
->
curve
(
0
)
||
&
l0
==
contour
->
curve
(
1
)
||
&
l0
==
contour
->
curve
(
2
));
...
...
@@ -316,8 +316,8 @@ TEST(Star, find_closed_contour_2) {
EXPECT_TRUE
(
&
l4
==
contour
->
curve
(
0
)
||
&
l4
==
contour
->
curve
(
1
)
||
&
l4
==
contour
->
curve
(
2
));
EXPECT_TRUE
(
&
c0
==
contour
->
curve
(
0
)
||
&
c0
==
contour
->
curve
(
1
)
||
&
c0
==
contour
->
curve
(
2
));
const
Contour
*
c0
=
sketch
.
contour
(
0
);
const
Contour
*
c1
=
sketch
.
contour
(
1
);
auto
c0
=
sketch
.
contour
(
0
);
auto
c1
=
sketch
.
contour
(
1
);
for
(
size_t
i
=
0
;
i
<
3
;
++
i
)
{
for
(
size_t
j
=
0
;
j
<
3
;
++
j
)
{
if
(
c0
->
curve
(
i
)
==
c1
->
curve
(
j
))
{
...
...
@@ -329,7 +329,7 @@ TEST(Star, find_closed_contour_2) {
// Test Boundary
{
const
Contour
*
boundary
=
sketch
.
boundary
();
auto
boundary
=
sketch
.
boundary
();
EXPECT_EQ
(
boundary
->
size
(),
4
);
EXPECT_TRUE
(
&
l0
==
boundary
->
curve
(
0
)
||
&
l0
==
boundary
->
curve
(
1
)
||
&
l0
==
boundary
->
curve
(
2
)
||
&
l0
==
boundary
->
curve
(
3
));
...
...
@@ -369,7 +369,7 @@ TEST(Star, find_closed_contour_3) {
EXPECT_TRUE
(
sketch
.
size_contours
()
==
1
);
EXPECT_TRUE
(
*
sketch
.
contour
(
0
)
==
*
sketch
.
boundary
());
const
Contour
*
contour
=
sketch
.
contour
(
0
);
auto
contour
=
sketch
.
contour
(
0
);
EXPECT_TRUE
(
contour
->
size
()
==
2
);
EXPECT_TRUE
(
&
arc
==
contour
->
curve
(
0
)
||
&
arc
==
contour
->
curve
(
1
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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