Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tools
frackit
Commits
ecb65a0e
Commit
ecb65a0e
authored
Jan 13, 2020
by
Dennis Gläser
Browse files
[test][disknetwork][shape] test creation on layer brep file and use domain constraints
parent
1b796ea7
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/entitynetwork/CMakeLists.txt
View file @
ecb65a0e
...
@@ -21,7 +21,7 @@ frackit_add_test(NAME test_generate_disk_network_cylinder
...
@@ -21,7 +21,7 @@ frackit_add_test(NAME test_generate_disk_network_cylinder
frackit_add_test
(
NAME test_generate_disk_network_shape
frackit_add_test
(
NAME test_generate_disk_network_shape
SOURCES test_generate_disk_network_shape.cc
SOURCES test_generate_disk_network_shape.cc
LABELS entitynetwork sampling
LABELS entitynetwork sampling
COMPILE_DEFINITIONS BREPFILE=
"
${
CMAKE_SOURCE_DIR
}
/test/entitynetwork/
box
.brep"
COMPILE_DEFINITIONS BREPFILE=
"
${
CMAKE_SOURCE_DIR
}
/test/entitynetwork/
layer
.brep"
COMMAND ./test_generate_disk_network_shape
)
COMMAND ./test_generate_disk_network_shape
)
set
(
CMAKE_BUILD_TYPE Debug
)
set
(
CMAKE_BUILD_TYPE Debug
)
test/entitynetwork/test_generate_disk_network_shape.cc
View file @
ecb65a0e
...
@@ -44,8 +44,10 @@ int main(int argc, char** argv)
...
@@ -44,8 +44,10 @@ int main(int argc, char** argv)
assert
(
solids
.
size
()
==
1
);
assert
(
solids
.
size
()
==
1
);
const
auto
&
domain
=
solids
[
0
];
const
auto
&
domain
=
solids
[
0
];
const
auto
domainFaces
=
OCCUtilities
::
getFaces
(
domain
);
const
auto
domainVolume
=
computeMagnitude
(
domain
);
const
auto
domainVolume
=
computeMagnitude
(
domain
);
const
auto
domainShells
=
OCCUtilities
::
getShells
(
domain
);
assert
(
domainShells
.
size
()
==
1
);
const
auto
domainShellFaces
=
OCCUtilities
::
getFaces
(
domainShells
[
0
]);
// create the disk samplers
// create the disk samplers
using
ctype
=
double
;
using
ctype
=
double
;
...
@@ -57,18 +59,18 @@ int main(int argc, char** argv)
...
@@ -57,18 +59,18 @@ int main(int argc, char** argv)
PointSampler
pointSampler
(
OCCUtilities
::
getBoundingBox
(
domain
));
PointSampler
pointSampler
(
OCCUtilities
::
getBoundingBox
(
domain
));
// sampler for disks of orientation 1
// sampler for disks of orientation 1
DiskSampler
diskSampler_1
(
std
::
normal_distribution
<
ctype
>
(
0.
35
,
0.1
),
DiskSampler
diskSampler_1
(
std
::
normal_distribution
<
ctype
>
(
4
0.
0
,
6.5
),
std
::
normal_distribution
<
ctype
>
(
0.
225
,
0.0
5
),
std
::
normal_distribution
<
ctype
>
(
2
0.
0
,
4.
5
),
std
::
normal_distribution
<
ctype
>
(
toRadians
(
25
.0
),
toRadians
(
5.0
)),
std
::
normal_distribution
<
ctype
>
(
toRadians
(
0
.0
),
toRadians
(
5.0
)),
std
::
normal_distribution
<
ctype
>
(
toRadians
(
0.0
),
toRadians
(
5.0
)),
std
::
normal_distribution
<
ctype
>
(
toRadians
(
0.0
),
toRadians
(
5.0
)),
std
::
normal_distribution
<
ctype
>
(
toRadians
(
45
.0
),
toRadians
(
5.0
)));
std
::
normal_distribution
<
ctype
>
(
toRadians
(
0
.0
),
toRadians
(
5.0
)));
// sampler for disks of orientation 1
// sampler for disks of orientation 1
DiskSampler
diskSampler_2
(
std
::
normal_distribution
<
ctype
>
(
0.
35
,
0.1
),
DiskSampler
diskSampler_2
(
std
::
normal_distribution
<
ctype
>
(
4
0.
0
,
6.5
),
std
::
normal_distribution
<
ctype
>
(
0.
225
,
0.0
5
),
std
::
normal_distribution
<
ctype
>
(
2
0.
0
,
4.
5
),
std
::
normal_distribution
<
ctype
>
(
toRadians
(
-
3
5.0
),
toRadians
(
5.0
)),
std
::
normal_distribution
<
ctype
>
(
toRadians
(
4
5.0
),
toRadians
(
5.0
)),
std
::
normal_distribution
<
ctype
>
(
toRadians
(
0.0
),
toRadians
(
5.0
)),
std
::
normal_distribution
<
ctype
>
(
toRadians
(
0.0
),
toRadians
(
5.0
)),
std
::
normal_distribution
<
ctype
>
(
toRadians
(
-
45
.0
),
toRadians
(
5.0
)));
std
::
normal_distribution
<
ctype
>
(
toRadians
(
0
.0
),
toRadians
(
5.0
)));
//! containers to store created entities
//! containers to store created entities
std
::
vector
<
Disk
>
diskSet1
;
std
::
vector
<
Disk
>
diskSet1
;
...
@@ -80,22 +82,22 @@ int main(int argc, char** argv)
...
@@ -80,22 +82,22 @@ int main(int argc, char** argv)
Frackit
::
EntityNetworkConstraints
<
ctype
>
constraintsOnDomain
;
Frackit
::
EntityNetworkConstraints
<
ctype
>
constraintsOnDomain
;
// constraints among disks of the same set
// constraints among disks of the same set
constraintsOnSelf
.
setMinDistance
(
0.
1
);
constraintsOnSelf
.
setMinDistance
(
1
0.
0
);
constraintsOnSelf
.
setMinIntersectingAngle
(
toRadians
(
45.0
));
constraintsOnSelf
.
setMinIntersectingAngle
(
toRadians
(
45.0
));
constraintsOnSelf
.
setMinIntersectionMagnitude
(
0.01
);
constraintsOnSelf
.
setMinIntersectionMagnitude
(
2.5
);
constraintsOnSelf
.
setMinIntersectionDistance
(
0
.0
5
);
constraintsOnSelf
.
setMinIntersectionDistance
(
2
.0
);
// constraints with the other disk set
// constraints with the other disk set
constraintsOnOther
.
setMinDistance
(
0.01
);
constraintsOnOther
.
setMinDistance
(
2.5
);
constraintsOnOther
.
setMinIntersectingAngle
(
toRadians
(
1
5
.0
));
constraintsOnOther
.
setMinIntersectingAngle
(
toRadians
(
1
0
.0
));
constraintsOnOther
.
setMinIntersectionMagnitude
(
0.0
1
);
constraintsOnOther
.
setMinIntersectionMagnitude
(
1
0.0
);
constraintsOnOther
.
setMinIntersectionDistance
(
0
.0
5
);
constraintsOnOther
.
setMinIntersectionDistance
(
2
.0
);
// constraints with the
other disk set
// constraints with the
domain
constraintsOnDomain
.
setMinDistance
(
0.01
);
constraintsOnDomain
.
setMinDistance
(
2.5
);
constraintsOnDomain
.
setMinIntersectingAngle
(
toRadians
(
1
5.0
));
constraintsOnDomain
.
setMinIntersectingAngle
(
toRadians
(
5.0
));
constraintsOnDomain
.
setMinIntersectionMagnitude
(
0.0
1
);
constraintsOnDomain
.
setMinIntersectionMagnitude
(
2
0.0
);
constraintsOnDomain
.
setMinIntersectionDistance
(
0
.0
5
);
constraintsOnDomain
.
setMinIntersectionDistance
(
2
.0
);
//! create pseudo-random number generator to select set during creation
//! create pseudo-random number generator to select set during creation
std
::
default_random_engine
randomNumber
{
std
::
random_device
{}()};
std
::
default_random_engine
randomNumber
{
std
::
random_device
{}()};
...
@@ -113,8 +115,8 @@ int main(int argc, char** argv)
...
@@ -113,8 +115,8 @@ int main(int argc, char** argv)
ctype
currentDensity
=
0.0
;
ctype
currentDensity
=
0.0
;
ctype
currentDiskArea
=
0.0
;
ctype
currentDiskArea
=
0.0
;
const
std
::
size_t
numTargetEntities_1
=
5
;
const
std
::
size_t
numTargetEntities_1
=
6
;
const
std
::
size_t
numTargetEntities_2
=
5
;
const
std
::
size_t
numTargetEntities_2
=
6
;
while
(
accepted_1
!=
numTargetEntities_1
||
accepted_2
!=
numTargetEntities_2
)
while
(
accepted_1
!=
numTargetEntities_1
||
accepted_2
!=
numTargetEntities_2
)
{
{
bool
createSecondary
=
randomNumber
()
%
2
;
bool
createSecondary
=
randomNumber
()
%
2
;
...
@@ -138,17 +140,16 @@ int main(int argc, char** argv)
...
@@ -138,17 +140,16 @@ int main(int argc, char** argv)
// enforce constraints w.r.t. to the other disk set
// enforce constraints w.r.t. to the other disk set
if
(
!
constraintsOnOther
.
evaluate
(
diskSetOther
,
disk
))
continue
;
if
(
!
constraintsOnOther
.
evaluate
(
diskSetOther
,
disk
))
continue
;
// // enforce constraints w.r.t. the domain boundaries
// enforce constraints w.r.t. the domain boundaries
// TODO: INTERSECTION ALGOS WITH SHAPE CLASSES
bool
violates
=
false
;
// bool violates = false;
for
(
const
auto
&
face
:
domainShellFaces
)
// for (const auto& face : domainFaces)
if
(
!
constraintsOnDomain
.
evaluate
(
face
,
disk
))
// if (!constraintsOnDomain.evaluate(face, disk))
{
violates
=
true
;
break
;
}
// { violates = true; break; }
if
(
violates
)
continue
;
// if (violates) continue;
// reject if intersection with domain is too small (here: 0.2m²)
// reject if intersection with domain is too small (here: 0.2m²)
const
auto
containedArea
=
computeContainedMagnitude
(
disk
,
domain
);
const
auto
containedArea
=
computeContainedMagnitude
(
disk
,
domain
);
if
(
containedArea
<
0.
1
)
continue
;
if
(
containedArea
<
2
0.
0
*
10.0
*
M_PI
/
5.0
)
continue
;
// if we get here, the disk is admissible
// if we get here, the disk is admissible
diskSetSelf
.
push_back
(
std
::
move
(
disk
));
diskSetSelf
.
push_back
(
std
::
move
(
disk
));
...
...
Write
Preview
Supports
Markdown
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