Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
openCARP
meshalyzer
Commits
071a31a7
Commit
071a31a7
authored
Jun 10, 2016
by
Edward Vigmond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduced number of glBegin/glEnd calls when drawing surfaces
added flush for HDF5 text files
parent
3dc40157
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
145 additions
and
18 deletions
+145
-18
DrawingObjects.h
DrawingObjects.h
+12
-4
IGBheader.cc
IGBheader.cc
+1
-1
Makefile
Makefile
+4
-5
Quadrilateral.cc
Quadrilateral.cc
+47
-0
Surfaces.cc
Surfaces.cc
+12
-1
Triangle.cc
Triangle.cc
+31
-0
hdf5api/Makefile
hdf5api/Makefile
+2
-1
hdf5api/src/text.c
hdf5api/src/text.c
+25
-0
hdf5api/src/text.h
hdf5api/src/text.h
+2
-0
hdf5api/test/suite_utils.c
hdf5api/test/suite_utils.c
+4
-2
hdf5api/test/test_generics.c
hdf5api/test/test_generics.c
+2
-2
hdf5api/test/test_surfaces.c
hdf5api/test/test_surfaces.c
+1
-1
main.cc
main.cc
+2
-1
No files found.
DrawingObjects.h
View file @
071a31a7
...
...
@@ -22,7 +22,7 @@ gzFile openFile( const char*, const char* );
class
DrawingObj
{
public:
DrawingObj
()
:
_n
(
0
),
_size
(
1
),
_3D
(
false
)
{}
DrawingObj
()
{}
virtual
~
DrawingObj
()
{}
//! draw single objs
...
...
@@ -39,9 +39,9 @@ class DrawingObj
void
threeD
(
bool
b
){
_3D
=
b
;
}
bool
threeD
(
void
){
return
_3D
;
}
protected:
int
_n
;
//!< \# objects
float
_size
;
//!< size to draw objects
bool
_3D
;
int
_n
=
0
;
//!< \# objects
float
_size
=
1
;
//!< size to draw objects
bool
_3D
=
false
;
};
...
...
@@ -165,6 +165,8 @@ class SurfaceElement : public MultiPoint
virtual
void
draw
(
int
,
GLfloat
*
,
float
=
1
)
=
0
;
virtual
void
draw
(
int
,
int
,
GLfloat
*
,
Colourscale
*
,
DATA_TYPE
*
,
int
stride
,
dataOpac
*
dopac
,
const
GLfloat
*
)
=
0
;
virtual
void
draw
(
int
,
GLfloat
*
,
Colourscale
*
,
DATA_TYPE
*
,
dataOpac
*
dopa
,
const
GLfloat
*
,
bool
)
=
0
;
void
read_normals
(
int
,
int
,
const
char
*
);
void
vertnorm
(
GLfloat
*
a
){
_ptnrml
=
a
;
}
...
...
@@ -185,6 +187,8 @@ class PolyGon : public SurfaceElement
int
stride
,
dataOpac
*
dopac
,
const
GLfloat
*
);
virtual
void
draw
(
int
,
int
,
GLfloat
*
,
Colourscale
*
,
DATA_TYPE
*
,
int
stride
=
1
,
dataOpac
*
dopac
=
NULL
);
virtual
void
draw
(
int
,
GLfloat
*
,
Colourscale
*
,
DATA_TYPE
*
,
dataOpac
*
dopac
,
const
GLfloat
*
,
bool
lightson
){}
virtual
bool
read
(
const
char
*
){}
static
const
int
_zero
;
const
int
*
iso_polys
(
unsigned
int
index
){
return
&
_zero
;}
...
...
@@ -202,6 +206,8 @@ class Triangle : public SurfaceElement
int
stride
=
1
,
dataOpac
*
dopac
=
NULL
);
virtual
void
draw
(
int
,
int
,
GLfloat
*
,
Colourscale
*
,
DATA_TYPE
*
,
int
stride
,
dataOpac
*
dopac
,
const
GLfloat
*
);
virtual
void
draw
(
int
,
GLfloat
*
,
Colourscale
*
,
DATA_TYPE
*
,
dataOpac
*
dopac
,
const
GLfloat
*
,
bool
lightson
);
virtual
bool
read
(
const
char
*
);
virtual
void
compute_normals
(
int
,
int
);
virtual
DrawingObj
*
isosurf
(
DATA_TYPE
*
d
,
DATA_TYPE
val
){}
...
...
@@ -223,6 +229,8 @@ class Quadrilateral : public SurfaceElement
int
stride
=
1
,
dataOpac
*
dopac
=
NULL
);
virtual
void
draw
(
int
,
int
,
GLfloat
*
,
Colourscale
*
,
DATA_TYPE
*
,
int
stride
,
dataOpac
*
dopac
,
const
GLfloat
*
);
virtual
void
draw
(
int
,
GLfloat
*
,
Colourscale
*
,
DATA_TYPE
*
,
dataOpac
*
dopac
,
const
GLfloat
*
,
bool
lightson
);
virtual
bool
read
(
const
char
*
);
virtual
void
compute_normals
(
int
,
int
);
bool
add
(
const
char
*
);
...
...
IGBheader.cc
View file @
071a31a7
...
...
@@ -216,7 +216,7 @@ HEX2: 3 -o-o-o-o-o- -o---o---o---o---o---o
int
my_fputs
(
FILE
*
,
char
*
);
bool
Header_Quiet
=
0
;
bool
Header_Quiet
=
false
;
char
Header_Message
[
256
];
const
char
*
Header_Type
[]
=
...
...
Makefile
View file @
071a31a7
HOSTMACHINE
:=
$(
shell
uname
)
#
HDF5=1
HDF5
=
1
include
make.conf
CXX
:=
c++
-std
=
c++11
CXX
:=
c++
-std
=
c++11
-fopenmp
HDF5API_ROOT
:=
./hdf5api
...
...
@@ -32,8 +32,7 @@ else
endif
COMMON_LIBS
=
$(FLTK_LIBS)
-lpng
-lpthread
-lm
-lz
$(LIB_HDF5)
#LDFLAGS = -fopenmp
CXXFLAGS
=
-std
=
c++11
-I
$(HDF5_ROOT)
/include
-I
$(HDF5API_ROOT)
/include
$(FLTK_INC)
$(COMMON_INC)
CXXFLAGS
=
-std
=
c++11
$(OMP_FLAG)
-I
$(HDF5_ROOT)
/include
-I
$(HDF5API_ROOT)
/include
$(FLTK_INC)
$(COMMON_INC)
HDF5_CXXFLAGS
=
£
(
CXXFLAGS
)
LIBS
=
-L
$(HDF5API_ROOT)
/lib
$(FLTK_LD_FLAGS)
$(COMMON_LIBS)
...
...
@@ -58,7 +57,7 @@ mesalyzer: $(LIB_CH5) $(FLTK_SOURCES:.fl=.cc) $(OS_OBJS) $(LIB_CH5)
ifdef
HDF5
$(LIB_CH5)
:
cd
hdf5api
&&
make all
$(LIB_CH5)
$(FLTK_SOURCES:.fl=.cc)
$(OBJS)
$(LIB_CH5)
cd
hdf5api
&&
make all
endif
$(OS_files
:
.o=_os.o): %_os.o: %.cc
...
...
Quadrilateral.cc
View file @
071a31a7
...
...
@@ -91,6 +91,53 @@ void Quadrilateral::draw( int p0, int p1, GLfloat *colour, Colourscale* cs,
}
/** draw one Quadrilaterals and do not do glBegin/glEnd
*
* \param p0 index of first point to draw
* \param colour colour to use if no data
* \param cs colour scale
* \param data data associated with nodes (NULL for no data display)
* \param dataopac data opacity
* \param ptnrml vertex normals (NULL for none)
* \param lightson true if lights are on
*/
void
Quadrilateral
::
draw
(
int
p0
,
GLfloat
*
colour
,
Colourscale
*
cs
,
DATA_TYPE
*
data
,
dataOpac
*
dataopac
,
const
GLfloat
*
ptnrml
,
bool
lightson
)
{
if
(
p0
>=
_n
)
return
;
int
i
=
4
*
p0
;
if
(
!
_pt
->
vis
(
_node
[
i
])
||
!
_pt
->
vis
(
_node
[
i
+
1
])
||
!
_pt
->
vis
(
_node
[
i
+
2
])
||
!
_pt
->
vis
(
_node
[
i
+
3
])
)
return
;
if
(
lightson
&&
ptnrml
==
NULL
)
glNormal3fv
(
nrml
(
i
/
3
)
);
if
(
data
!=
NULL
)
{
if
(
dataopac
->
on
()
)
{
// data opacity
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
cs
->
colourize
(
data
[
_node
[
i
+
j
]],
dataopac
->
alpha
(
data
[
_node
[
i
+
j
]]));
if
(
lightson
&&
ptnrml
)
glNormal3fv
(
ptnrml
+
_node
[
i
+
j
]
*
3
);
glVertex3fv
(
_pt
->
pt
(
_node
[
i
+
j
])
);
}
}
else
{
// no data opacity
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
cs
->
colourize
(
data
[
_node
[
i
+
j
]],
colour
[
3
]
);
if
(
lightson
&&
ptnrml
)
glNormal3fv
(
ptnrml
+
_node
[
i
+
j
]
*
3
);
glVertex3fv
(
_pt
->
pt
(
_node
[
i
+
j
])
);
}
}
}
else
{
// no data
glColor4fv
(
colour
);
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
if
(
lightson
&&
ptnrml
)
glNormal3fv
(
ptnrml
+
_node
[
i
+
j
]
*
3
);
glVertex3fv
(
_pt
->
pt
(
_node
[
i
+
j
])
);
}
}
}
/** draw a quadrilateral
*
* \param e element to highlight
...
...
Surfaces.cc
View file @
071a31a7
...
...
@@ -102,8 +102,19 @@ void Surfaces::determine_vert_norms( PPoint& pt )
void
Surfaces
::
draw
(
GLfloat
*
fill
,
Colourscale
*
cs
,
DATA_TYPE
*
dat
,
int
stride
,
dataOpac
*
dataopac
,
const
GLfloat
*
ptnrml
)
{
GLboolean
lightson
;
glGetBooleanv
(
GL_LIGHTING
,
&
lightson
);
glBegin
(
GL_TRIANGLES
);
for
(
int
i
=
0
;
i
<
_ele
.
size
();
i
+=
stride
)
if
(
_ele
[
i
]
->
ptsPerObj
()
==
3
)
_ele
[
i
]
->
draw
(
0
,
fill
,
cs
,
dat
,
dataopac
,
ptnrml
,
lightson
);
glEnd
();
glBegin
(
GL_QUADS
);
for
(
int
i
=
0
;
i
<
_ele
.
size
();
i
+=
stride
)
_ele
[
i
]
->
draw
(
0
,
0
,
fill
,
cs
,
dat
,
stride
,
dataopac
,
ptnrml
);
if
(
_ele
[
i
]
->
ptsPerObj
()
==
4
)
_ele
[
i
]
->
draw
(
0
,
fill
,
cs
,
dat
,
dataopac
,
ptnrml
,
lightson
);
glEnd
();
}
/** redraw elements through which the branch cut passes with flat shading
...
...
Triangle.cc
View file @
071a31a7
...
...
@@ -21,6 +21,37 @@ void Triangle::draw( int p0, int p1, GLfloat *colour, Colourscale* cs,
draw
(
p0
,
p1
,
colour
,
cs
,
data
,
stride
,
dataopac
,
_ptnrml
);
}
/** draw one Triangle but do not call glBegin/glEnd
*
* \param p0 index of first point to draw
* \param colour colour to use if no data
* \param cs colour scale
* \param data data associated with nodes (NULL for no data display)
* \param dataopac data opacity
* \param ptnrml vertex normals (NULL for none)
*/
void
Triangle
::
draw
(
int
p0
,
GLfloat
*
colour
,
Colourscale
*
cs
,
DATA_TYPE
*
data
,
dataOpac
*
dataopac
,
const
GLfloat
*
ptnrml
,
bool
lightson
)
{
if
(
p0
>=
_n
)
return
;
int
i
=
3
*
p0
;
if
(
!
_pt
->
vis
(
_node
[
i
])
||
!
_pt
->
vis
(
_node
[
i
+
1
])
||
!
_pt
->
vis
(
_node
[
i
+
2
])
)
return
;
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
if
(
data
)
cs
->
colourize
(
data
[
_node
[
i
+
j
]],
dataopac
->
on
()
?
dataopac
->
alpha
(
data
[
_node
[
i
+
j
]])
:
colour
[
3
]
);
else
glColor4fv
(
colour
);
if
(
lightson
&&
ptnrml
)
glNormal3fv
(
ptnrml
+
_node
[
i
+
j
]
*
3
);
glVertex3fv
(
_pt
->
pt
(
_node
[
i
+
j
])
);
}
}
/** draw many Triangles
*
...
...
hdf5api/Makefile
View file @
071a31a7
...
...
@@ -11,6 +11,7 @@ LIBPATH := lib/$(LIBFILE)
CFLAGS
:=
-std
=
c99
-Wall
-Isrc
-g
-O0
AR
:=
ar
ARFLAGS
:=
-rcs
HDF5_LIBS
:=
$(LIBPATH)
-lhdf5_hl
-lhdf5
CFLAGS
+=
-I
$(HDF5_ROOT)
/include
-L
$(HDF5_ROOT)
/lib
OBJS
:=
$(
patsubst
%.c, %.o,
$(
wildcard
$(SRCDIR)
/
*
.c
))
...
...
@@ -45,7 +46,7 @@ $(TESTINVALID): $(GENBIN)
./
$(GENBIN)
./test/data/test_invalid.h5
$(TESTBIN)
:
$(LIBPATH) $(TESTOBJS) $(TESTINVALID)
$(CC)
$(CFLAGS)
$(
LIBPATH)
$(TESTOBJ
S)
-o
$(TESTBIN)
$(CC)
$(CFLAGS)
$(
TESTOBJS)
$(HDF5_LIB
S)
-o
$(TESTBIN)
$(GENBIN)
:
$(GENOBJS)
$(CC)
$(CFLAGS)
$(GENOBJS)
-o
$(GENBIN)
...
...
hdf5api/src/text.c
View file @
071a31a7
...
...
@@ -4,6 +4,31 @@
#include <stdlib.h>
#include <string.h>
/** \brief flush a text file or all text files
* \param[in] hdf_file The HDF file reference id
* \param[in] index text file index, -1=all
* \returns 0 if successful, -1 on error
*/
int
ch5_text_flush
(
hid_t
hdf_file
,
int
index
)
{
hid_t
container_id
=
ch5_nchild_create_or_open_container
(
hdf_file
,
CH5_TEXT_GROUP_NAME
);
if
(
container_id
<
0
)
return
-
1
;
if
(
index
==
-
1
)
H5Fflush
(
container_id
,
H5F_SCOPE_LOCAL
);
else
{
hid_t
text_id
;
int
status
=
ch5_nchild_open_child
(
container_id
,
index
,
&
text_id
,
NULL
);
if
(
status
!=
0
)
return
1
;
H5Fflush
(
text_id
,
H5F_SCOPE_LOCAL
);
H5Dclose
(
text_id
);
}
H5Gclose
(
container_id
);
}
/**
* \brief Creates a new text file
* \param[in] hdf_file The HDF file reference id
...
...
hdf5api/src/text.h
View file @
071a31a7
...
...
@@ -24,6 +24,8 @@ int ch5_text_info(hid_t hdf_file, unsigned int index, ch5_text_file *info);
int
ch5_text_free_info
(
ch5_text_file
*
info
);
int
ch5_text_flush
(
hid_t
hdf_file
,
int
index
);
int
ch5_text_append
(
hid_t
hdf_file
,
unsigned
int
file_index
,
...
...
hdf5api/test/suite_utils.c
View file @
071a31a7
...
...
@@ -42,7 +42,8 @@ void run_test(char const *name, int (*test_fn)(void)) {
void
print_test_result
(
char
const
*
name
,
int
result
)
{
struct
winsize
w
;
ioctl
(
STDOUT_FILENO
,
TIOCGWINSZ
,
&
w
);
int
e
=
ioctl
(
0
,
TIOCGWINSZ
,
&
w
);
if
(
!
w
.
ws_col
)
w
.
ws_col
=
80
;
int
name_width
=
w
.
ws_col
-
3
-
5
;
char
*
out_name
=
pad_str_right
(
name
,
name_width
,
'.'
);
...
...
@@ -71,13 +72,14 @@ void print_result_summary() {
void
print_title
(
char
const
*
text
)
{
struct
winsize
w
;
ioctl
(
STDOUT_FILENO
,
TIOCGWINSZ
,
&
w
);
int
e
=
ioctl
(
STDOUT_FILENO
,
TIOCGWINSZ
,
&
w
);
int
orig_len
=
strlen
(
text
);
char
*
padded
=
(
char
*
)
calloc
(
sizeof
(
char
),
orig_len
+
5
);
padded
[
0
]
=
padded
[
1
]
=
'='
;
padded
[
2
]
=
' '
;
strncpy
(
&
padded
[
3
],
text
,
orig_len
);
padded
[
orig_len
+
3
]
=
' '
;
if
(
!
w
.
ws_col
)
w
.
ws_col
=
80
;
char
*
full_text
=
pad_str_right
(
padded
,
w
.
ws_col
,
'='
);
printf
(
"
\n\x1B
[33m%s
\x1B
[0m
\n
"
,
full_text
);
free
(
padded
);
...
...
hdf5api/test/test_generics.c
View file @
071a31a7
...
...
@@ -154,7 +154,7 @@ int gets_type_insensitive_single_attribute() {
int
nchild_generates_names
()
{
const
char
*
expected
=
"Prefix000321"
;
char
*
name
=
ch5_nchild_gen_name
(
"Prefix"
,
321
);
char
*
name
=
ch5_nchild_gen_name
(
"Prefix"
,
321
,
NULL
);
int
result
=
1
;
if
(
name
==
NULL
)
{
fprintf
(
stderr
,
"Returned string was null.
\n
"
);
...
...
@@ -235,4 +235,4 @@ int nchild_counts_children() {
return
result
;
}
#endif
\ No newline at end of file
#endif
hdf5api/test/test_surfaces.c
View file @
071a31a7
...
...
@@ -9,7 +9,7 @@
int
surf_creates_named_surface
()
{
OPEN_WRITE_TEST_FILE
;
char
*
name
=
fixture_surface_name
(
0
);
char
*
dset_name
=
ch5_nchild_gen_name
(
CH5_SURF_CHILD_PREFIX
,
0
);
char
*
dset_name
=
ch5_nchild_gen_name
(
CH5_SURF_CHILD_PREFIX
,
0
,
NULL
);
int
surf0_idx
=
ch5m_surf_create
(
file
,
name
,
5
,
8
);
int
result
=
(
surf0_idx
!=
-
1
);
...
...
main.cc
View file @
071a31a7
...
...
@@ -364,7 +364,8 @@ void process_h5_format(char *fin, Meshwin *w, Controls *control, bool no_elems)
void
print_usage
(
void
)
{
cout
<<
"meshalyzer [options] model_base[.] [file.dat] [file.xfrm] [file.mshz] [file.vpts]"
<<
endl
;
cout
<<
"meshalyzer [options] model_base[.[pts]] [file.igb|file.dat|file.datH5:nodal/#] [file.xfrm] [file.mshz] "
"[file.vpts]"
<<
endl
;
cout
<<
"with options: "
<<
endl
;
cout
<<
"--iconifycontrols|-i iconify controls on startup"
<<
endl
;
cout
<<
"--no_elem|-n do not read element info"
<<
endl
;
...
...
Write
Preview
Markdown
is supported
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