Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
8f00809a
Commit
8f00809a
authored
Mar 30, 2017
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
GUI for boolean operations :-)
parent
a437511f
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Fltk/contextWindow.cpp
+7
-2
7 additions, 2 deletions
Fltk/contextWindow.cpp
Fltk/graphicWindow.cpp
+115
-1
115 additions, 1 deletion
Fltk/graphicWindow.cpp
Geo/GeoStringInterface.cpp
+25
-0
25 additions, 0 deletions
Geo/GeoStringInterface.cpp
Geo/GeoStringInterface.h
+5
-0
5 additions, 0 deletions
Geo/GeoStringInterface.h
with
152 additions
and
3 deletions
Fltk/contextWindow.cpp
+
7
−
2
View file @
8f00809a
...
...
@@ -419,6 +419,8 @@ elementaryContextWindow::elementaryContextWindow(int deltaFontSize)
}
group
[
8
]
->
end
();
}
/* FIXME: TODO
// 9: Torus
{
group[9] = new Fl_Group
...
...
@@ -437,6 +439,7 @@ elementaryContextWindow::elementaryContextWindow(int deltaFontSize)
(WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Wedge");
group[11]->end();
}
*/
tab2
->
end
();
}
...
...
@@ -482,9 +485,11 @@ void elementaryContextWindow::updatePoint(double pt[3], int which)
void
elementaryContextWindow
::
show
(
int
pane
)
{
if
(
pane
<
0
||
pane
>
10
)
return
;
// FIXME: TODO
if
(
pane
<
0
||
pane
>
8
)
return
;
for
(
int
i
=
0
;
i
<
11
;
i
++
)
for
(
int
i
=
0
;
i
<
9
;
i
++
)
group
[
i
]
->
hide
();
if
(
pane
<
6
){
...
...
This diff is collapsed.
Click to expand it.
Fltk/graphicWindow.cpp
+
115
−
1
View file @
8f00809a
...
...
@@ -1580,6 +1580,110 @@ static void geometry_elementary_delete_cb(Fl_Widget *w, void *data)
action_point_line_surface_volume
(
6
,
0
,
(
const
char
*
)
data
);
}
static
void
geometry_elementary_boolean_cb
(
Fl_Widget
*
w
,
void
*
data
)
{
if
(
!
data
)
return
;
std
::
string
mode
((
const
char
*
)
data
);
bool
selectObject
=
true
;
std
::
vector
<
GEntity
*>
object
,
tool
;
if
(
GModel
::
current
()
->
getDim
()
==
3
)
opt_geometry_volumes
(
0
,
GMSH_SET
|
GMSH_GUI
,
1
);
else
if
(
GModel
::
current
()
->
getDim
()
==
2
)
opt_geometry_surfaces
(
0
,
GMSH_SET
|
GMSH_GUI
,
1
);
while
(
1
)
{
if
(
object
.
empty
())
Msg
::
StatusGl
(
"Select object
\n
"
"[Press 'e' to end selection or 'q' to abort]"
);
else
if
(
selectObject
)
Msg
::
StatusGl
(
"Select object
\n
"
"[Press 'e' to end selection, 'u' to undo last selection or "
"'q' to abort]"
);
else
if
(
tool
.
empty
())
Msg
::
StatusGl
(
"Select tool
\n
"
"[Press 'e' to end selection or 'q' to abort]"
);
else
Msg
::
StatusGl
(
"Select tool
\n
"
"[Press 'e' to end selection, 'u' to undo last selection or "
"'q' to abort]"
);
char
ib
=
FlGui
::
instance
()
->
selectEntity
(
ENT_ALL
);
if
(
ib
==
'l'
)
{
for
(
unsigned
int
i
=
0
;
i
<
FlGui
::
instance
()
->
selectedEdges
.
size
();
i
++
){
if
(
FlGui
::
instance
()
->
selectedEdges
[
i
]
->
getSelection
()
!=
1
){
FlGui
::
instance
()
->
selectedEdges
[
i
]
->
setSelection
(
1
);
if
(
selectObject
)
object
.
push_back
(
FlGui
::
instance
()
->
selectedEdges
[
i
]);
else
tool
.
push_back
(
FlGui
::
instance
()
->
selectedEdges
[
i
]);
}
}
for
(
unsigned
int
i
=
0
;
i
<
FlGui
::
instance
()
->
selectedFaces
.
size
();
i
++
){
if
(
FlGui
::
instance
()
->
selectedFaces
[
i
]
->
getSelection
()
!=
1
){
FlGui
::
instance
()
->
selectedFaces
[
i
]
->
setSelection
(
1
);
if
(
selectObject
)
object
.
push_back
(
FlGui
::
instance
()
->
selectedFaces
[
i
]);
else
tool
.
push_back
(
FlGui
::
instance
()
->
selectedFaces
[
i
]);
}
}
for
(
unsigned
int
i
=
0
;
i
<
FlGui
::
instance
()
->
selectedRegions
.
size
();
i
++
){
if
(
FlGui
::
instance
()
->
selectedRegions
[
i
]
->
getSelection
()
!=
1
){
FlGui
::
instance
()
->
selectedRegions
[
i
]
->
setSelection
(
1
);
if
(
selectObject
)
object
.
push_back
(
FlGui
::
instance
()
->
selectedRegions
[
i
]);
else
tool
.
push_back
(
FlGui
::
instance
()
->
selectedRegions
[
i
]);
}
}
}
if
(
ib
==
'r'
)
{
for
(
unsigned
int
i
=
0
;
i
<
FlGui
::
instance
()
->
selectedEdges
.
size
();
i
++
)
FlGui
::
instance
()
->
selectedEdges
[
i
]
->
setSelection
(
0
);
for
(
unsigned
int
i
=
0
;
i
<
FlGui
::
instance
()
->
selectedFaces
.
size
();
i
++
)
FlGui
::
instance
()
->
selectedFaces
[
i
]
->
setSelection
(
0
);
for
(
unsigned
int
i
=
0
;
i
<
FlGui
::
instance
()
->
selectedRegions
.
size
();
i
++
)
FlGui
::
instance
()
->
selectedRegions
[
i
]
->
setSelection
(
0
);
}
if
(
ib
==
'u'
)
{
if
(
selectObject
&&
object
.
size
()){
object
[
object
.
size
()
-
1
]
->
setSelection
(
0
);
object
.
pop_back
();
}
else
if
(
tool
.
size
()){
tool
[
tool
.
size
()
-
1
]
->
setSelection
(
0
);
tool
.
pop_back
();
}
}
if
(
ib
==
'e'
)
{
if
(
selectObject
){
if
(
object
.
empty
())
Msg
::
Error
(
"At least one object must be selected"
);
else
selectObject
=
false
;
}
else
if
(
tool
.
empty
()){
Msg
::
Error
(
"At least one tool must be selected"
);
}
else
{
apply_boolean
(
GModel
::
current
()
->
getFileName
(),
mode
,
object
,
tool
);
GModel
::
current
()
->
setSelection
(
0
);
selectObject
=
true
;
object
.
clear
();
tool
.
clear
();
}
}
if
(
ib
==
'q'
)
{
GModel
::
current
()
->
setSelection
(
0
);
break
;
}
}
drawContext
::
global
()
->
draw
();
Msg
::
StatusGl
(
""
);
}
static
void
geometry_elementary_split_cb
(
Fl_Widget
*
w
,
void
*
data
)
{
if
(
!
data
)
return
;
...
...
@@ -3792,12 +3896,14 @@ static menuItem static_modules[] = {
(
Fl_Callback
*
)
geometry_elementary_add_new_cb
,
(
void
*
)
"Cylinder"
}
,
{
"0Modules/Geometry/Elementary entities/Add/Block"
,
(
Fl_Callback
*
)
geometry_elementary_add_new_cb
,
(
void
*
)
"Block"
}
,
/* FIXME: TODO
{"0Modules/Geometry/Elementary entities/Add/Torus",
(Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Torus"} ,
{"0Modules/Geometry/Elementary entities/Add/Cone",
(Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Cone"} ,
{"0Modules/Geometry/Elementary entities/Add/Wedge",
(Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Wedge"} ,
*/
{
"0Modules/Geometry/Elementary entities/Add/Volume"
,
(
Fl_Callback
*
)
geometry_elementary_add_new_cb
,
(
void
*
)
"Volume"
}
,
{
"0Modules/Geometry/Elementary entities/Translate/Point"
,
...
...
@@ -3876,6 +3982,14 @@ static menuItem static_modules[] = {
(
Fl_Callback
*
)
geometry_elementary_add_symmetry_cb
,
(
void
*
)
"Surface"
}
,
{
"0Modules/Geometry/Elementary entities/Symmetry/Duplicate volume"
,
(
Fl_Callback
*
)
geometry_elementary_add_symmetry_cb
,
(
void
*
)
"Volume"
}
,
{
"0Modules/Geometry/Elementary entities/Boolean/Intersection"
,
(
Fl_Callback
*
)
geometry_elementary_boolean_cb
,
(
void
*
)
"BooleanIntersection"
}
,
{
"0Modules/Geometry/Elementary entities/Boolean/Union"
,
(
Fl_Callback
*
)
geometry_elementary_boolean_cb
,
(
void
*
)
"BooleanUnion"
}
,
{
"0Modules/Geometry/Elementary entities/Boolean/Difference"
,
(
Fl_Callback
*
)
geometry_elementary_boolean_cb
,
(
void
*
)
"BooleanDifference"
}
,
{
"0Modules/Geometry/Elementary entities/Boolean/Fragments"
,
(
Fl_Callback
*
)
geometry_elementary_boolean_cb
,
(
void
*
)
"BooleanFragments"
}
,
{
"0Modules/Geometry/Elementary entities/Delete/Point"
,
(
Fl_Callback
*
)
geometry_elementary_delete_cb
,
(
void
*
)
"Point"
}
,
{
"0Modules/Geometry/Elementary entities/Delete/Line"
,
...
...
This diff is collapsed.
Click to expand it.
Geo/GeoStringInterface.cpp
+
25
−
0
View file @
8f00809a
...
...
@@ -591,3 +591,28 @@ void split_edge(int edge_id, List_T *vertices, const std::string &fileName)
sstream
<<
"Split Line("
<<
edge_id
<<
") {"
<<
list2string
(
vertices
)
<<
"};"
;
add_infile
(
sstream
.
str
(),
fileName
,
true
);
}
void
apply_boolean
(
const
std
::
string
&
fileName
,
const
std
::
string
&
op
,
const
std
::
vector
<
GEntity
*>
&
object
,
const
std
::
vector
<
GEntity
*>
&
tool
)
{
std
::
ostringstream
sstream
;
sstream
<<
op
<<
"{ "
;
for
(
unsigned
int
i
=
0
;
i
<
object
.
size
();
i
++
){
switch
(
object
[
i
]
->
dim
()){
case
3
:
sstream
<<
"Volume{"
<<
object
[
i
]
->
tag
()
<<
"}; "
;
break
;
case
2
:
sstream
<<
"Surface{"
<<
object
[
i
]
->
tag
()
<<
"}; "
;
break
;
case
1
:
sstream
<<
"Line{"
<<
object
[
i
]
->
tag
()
<<
"}; "
;
break
;
}
}
sstream
<<
"Delete; }{ "
;
for
(
unsigned
int
i
=
0
;
i
<
tool
.
size
();
i
++
){
switch
(
tool
[
i
]
->
dim
()){
case
3
:
sstream
<<
"Volume{"
<<
tool
[
i
]
->
tag
()
<<
"}; "
;
break
;
case
2
:
sstream
<<
"Surface{"
<<
tool
[
i
]
->
tag
()
<<
"}; "
;
break
;
case
1
:
sstream
<<
"Line{"
<<
tool
[
i
]
->
tag
()
<<
"}; "
;
break
;
}
}
sstream
<<
"Delete; }"
;
add_infile
(
sstream
.
str
(),
fileName
);
}
This diff is collapsed.
Click to expand it.
Geo/GeoStringInterface.h
+
5
−
0
View file @
8f00809a
...
...
@@ -10,6 +10,8 @@
#include
<vector>
#include
"ListUtils.h"
class
GEntity
;
void
coherence
(
const
std
::
string
&
fileName
);
void
delet
(
List_T
*
list
,
const
std
::
string
&
fileName
,
const
std
::
string
&
what
);
void
add_infile
(
const
std
::
string
&
text
,
const
std
::
string
&
fileName
,
...
...
@@ -90,5 +92,8 @@ void protude(List_T *list, const std::string &fileName, const std::string &what,
const
std
::
string
&
px
,
const
std
::
string
&
py
,
const
std
::
string
&
pz
,
const
std
::
string
&
angle
);
void
split_edge
(
int
edge_id
,
List_T
*
vertices
,
const
std
::
string
&
fileName
);
void
apply_boolean
(
const
std
::
string
&
fileName
,
const
std
::
string
&
op
,
const
std
::
vector
<
GEntity
*>
&
object
,
const
std
::
vector
<
GEntity
*>
&
tool
);
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment