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
76c14b67
Commit
76c14b67
authored
9 years ago
by
Gilles Marckmann
Browse files
Options
Downloads
Patches
Plain Diff
small improvements
parent
99d8f375
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Post/PViewX3D.cpp
+164
-164
164 additions, 164 deletions
Post/PViewX3D.cpp
with
164 additions
and
164 deletions
Post/PViewX3D.cpp
+
164
−
164
View file @
76c14b67
...
...
@@ -48,7 +48,7 @@ bool PView::writeX3D(const std::string &fileName )
}
}
int
_count
=
0
;
std
::
vector
<
bool
>
visible
(
_size
,
false
)
;
bool
visible
[
_size
]
;
if
(
PView
::
getInnerBorder
()
)
{
// evaluate bbox of each triangle
std
::
list
<
TriangleToSort
*
>
tlist
;
...
...
@@ -101,32 +101,7 @@ bool PView::writeX3D(const std::string &fileName )
float
*
n0
=
van
->
getVertexArray
(
3
*
in
);
float
*
n1
=
van
->
getVertexArray
(
3
*
(
in
+
1
)
);
float
*
n2
=
van
->
getVertexArray
(
3
*
(
in
+
2
)
);
// bool cas00 = (p0[0]==n0[0] && p0[1]==n0[1] && p0[2]==n0[2]);
// bool cas01 = (p0[0]==n1[0] && p0[1]==n1[1] && p0[2]==n1[2]);
// bool cas02 = (p0[0]==n2[0] && p0[1]==n2[1] && p0[2]==n2[2]);
// bool cas10 = (p1[0]==n0[0] && p1[1]==n0[1] && p1[2]==n0[2]);
// bool cas11 = (p1[0]==n1[0] && p1[1]==n1[1] && p1[2]==n1[2]);
// bool cas12 = (p1[0]==n2[0] && p1[1]==n2[1] && p1[2]==n2[2]);
// bool cas20 = (p2[0]==n0[0] && p2[1]==n0[1] && p2[2]==n0[2]);
// bool cas21 = (p2[0]==n1[0] && p2[1]==n1[1] && p2[2]==n1[2]);
// bool cas22 = (p2[0]==n2[0] && p2[1]==n2[1] && p2[2]==n2[2]);
/*
if ( p0[0]==n0[0] && p0[1]==n0[1] && p0[2]==n0[2] ){
if ( p1[0]==n1[0] && p1[1]==n1[1] && p1[2]==n1[2] ){
if ( p2[0]==n2[0] && p2[1]==n2[1] && p2[2]==n2[2] ) { found=true; } }
else if ( p1[0]==n2[0] && p1[1]==n2[1] && p1[2]==n2[2] ) {
if ( p2[0]==n1[0] && p2[1]==n1[1] && p2[2]==n1[2] ) { found=true; } } }
else if ( p0[0]==n1[0] && p0[1]==n1[1] && p0[2]==n1[2] ) {
if ( p1[0]==n0[0] && p1[1]==n0[1] && p1[2]==n0[2] ){
if ( p2[0]==n2[0] && p2[1]==n2[1] && p2[2]==n2[2] ) { found=true; } }
else if ( p1[0]==n2[0] && p1[1]==n2[1] && p1[2]==n2[2] ) {
if ( p2[0]==n0[0] && p2[1]==n0[1] && p2[2]==n0[2] ) { found=true; } } }
else if ( p0[0]==n2[0] && p0[1]==n2[1] && p0[2]==n2[2] ) {
if ( p1[0]==n0[0] && p1[1]==n0[1] && p1[2]==n0[2] ){
if ( p2[0]==n1[0] && p2[1]==n1[1] && p2[2]==n1[2] ) { found=true; } }
else if ( p1[0]==n1[0] && p1[1]==n1[1] && p1[2]==n1[2] ) {
if ( p2[0]==n0[0] && p2[1]==n0[1] && p2[2]==n0[2] ) { found=true; } } }
*/
if
(
almostEqual
(
p0
[
0
],
n0
[
0
])
&&
almostEqual
(
p0
[
1
],
n0
[
1
])
&&
almostEqual
(
p0
[
2
],
n0
[
2
])
){
if
(
almostEqual
(
p1
[
0
],
n1
[
0
])
&&
almostEqual
(
p1
[
1
],
n1
[
1
])
&&
almostEqual
(
p1
[
2
],
n1
[
2
])
){
if
(
almostEqual
(
p2
[
0
],
n2
[
0
])
&&
almostEqual
(
p2
[
1
],
n2
[
1
])
&&
almostEqual
(
p2
[
2
],
n2
[
2
])
)
{
found
=
true
;
}
}
...
...
@@ -143,7 +118,6 @@ bool PView::writeX3D(const std::string &fileName )
else
if
(
almostEqual
(
p1
[
0
],
n1
[
0
])
&&
almostEqual
(
p1
[
1
],
n1
[
1
])
&&
almostEqual
(
p1
[
2
],
n1
[
2
])
)
{
if
(
almostEqual
(
p2
[
0
],
n0
[
0
])
&&
almostEqual
(
p2
[
1
],
n0
[
1
])
&&
almostEqual
(
p2
[
2
],
n0
[
2
])
)
{
found
=
true
;
}
}
}
if
(
found
){
visible
[
gip
]
=
false
;
visible
[
gin
]
=
false
;
...
...
@@ -242,16 +216,7 @@ bool PView::writeX3D(const std::string &fileName )
fprintf
(
fp
,
" <!-- example: upper left-hand corner of screen (x=-2, y=1) and set back z=-5 from user view -->
\n
"
);
fprintf
(
fp
,
" <fieldValue name='screenOffset' value='%g %g %g'/>
\n
"
,
_center
.
x
(),
_center
.
y
()
,
_center
.
z
()
-
.2
*
_diagonal
);
fprintf
(
fp
,
" <fieldValue name='children'>
\n
"
);
/*---------------------------------------------------------
fprintf(fp," <Shape> \n");
fprintf(fp," <Text string='\"HUD : place for legend\" \"stay fixed while user navigates\"'> \n");
fprintf(fp," <FontStyle justify='\"MIDDLE\" \"MIDDLE\"' size='0.02'/> \n");
fprintf(fp," </Text> \n");
fprintf(fp," <Appearance> \n");
fprintf(fp," <Material diffuseColor='0. 0. 0.'/> \n");
fprintf(fp," </Appearance> \n");
fprintf(fp," </Shape> \n");
------------------------------------------------------------*/
// here contour/scalebar legends in frame (-.45,-.28, 0.) and (.45, .28,0.) : viewport .9 x .56
double
viewportWidth
=
.9
;
...
...
@@ -339,32 +304,20 @@ bool PView::writeX3D(const std::string &fileName )
}
}
// end of contour legend
// frame to visualize HUD if necessary----------------------------------------
/*
fprintf(fp," <Shape>\n");
fprintf(fp," <IndexedFaceSet solid=\"false\" colorPerVertex=\"true\" coordIndex=\"0 1 2 3 -1\">\n");
fprintf(fp," <Coordinate point= \" -.45 -.28 0. .45 -.28 0. .45 .28 0. -.45 .28 0. \" />\n");
fprintf(fp," <Color color= \"0 0 0, 0 0 0, 1 1 1, 1 1 1\" /> \n");
fprintf(fp," </IndexedFaceSet>\n");
fprintf(fp," <Appearance> \n");
fprintf(fp," <Material transparency='0.75' /> \n");
fprintf(fp," </Appearance> \n");
fprintf(fp," </Shape>");
*/
//-----------------------------------------------------------------------------
fprintf
(
fp
,
" </fieldValue>
\n
"
);
fprintf
(
fp
,
" </ProtoInstance>
\n
"
);
//count all visible triangles of previous visited PView
_count
=
0
;
// geometrical objects
for
(
unsigned
int
ipv
=
0
;
ipv
<
PView
::
list
.
size
();
ipv
++
){
PViewData
*
data
=
PView
::
list
[
ipv
]
->
getData
(
true
);
PViewOptions
*
opt
=
PView
::
list
[
ipv
]
->
getOptions
();
if
(
!
data
->
getDirty
()
&&
opt
->
visible
)
{
VertexArray
*
va
;
PViewData
*
data
;
PViewOptions
*
opt
;
// points ------------------------NOT TREATED YET-------------------------------
/*
for(unsigned int ipv = 0; ipv < PView::list.size(); ipv++){
data = PView::list[ipv]->getData(true);
opt = PView::list[ipv]->getOptions();
if( !data->getDirty() && opt->visible ) {
va=PView::list[ipv]->va_points;
for(int ipt = 0; ipt < va->getNumVertices(); ipt++){
float *p = va->getVertexArray(3 * ipt);
...
...
@@ -382,26 +335,46 @@ bool PView::writeX3D(const std::string &fileName )
else
fprintf(fp,"sphere : %g %g %g \n", p[0], p[1], p[2] );
}
} // enf if dirty
}// end loop on PView::list
*/
// lines -----------------------------------------------------------------------
va
=
PView
::
list
[
ipv
]
->
va_lines
;
int
_ind
=
0
;
fprintf
(
fp
,
"<Shape>
\n
"
);
fprintf
(
fp
,
" <IndexedLineSet coordIndex=' "
);
for
(
unsigned
int
ipv
=
0
;
ipv
<
PView
::
list
.
size
();
ipv
++
){
PViewData
*
data
=
PView
::
list
[
ipv
]
->
getData
(
true
);
PViewOptions
*
opt
=
PView
::
list
[
ipv
]
->
getOptions
();
if
(
!
data
->
getDirty
()
&&
opt
->
visible
)
{
va
=
PView
::
list
[
ipv
]
->
va_lines
;
for
(
int
ipt
=
0
;
ipt
<
va
->
getNumVertices
();
ipt
+=
2
){
if
(
opt
->
lineType
!=
2
&&
opt
->
lineType
!=
1
)
{
fprintf
(
fp
,
"%i %i %i "
,
ipt
,
ipt
+
1
,
-
1
);
fprintf
(
fp
,
"%i %i %i "
,
_ind
,
_ind
+
1
,
-
1
);
}
_ind
+=
2
;
}
}
// end if dirty
}
// end for loop on PView::list
fprintf
(
fp
,
"'>
\n
"
);
fprintf
(
fp
,
" <Coordinate DEF='TurnPoints' point=' "
);
for
(
unsigned
int
ipv
=
0
;
ipv
<
PView
::
list
.
size
();
ipv
++
){
PViewData
*
data
=
PView
::
list
[
ipv
]
->
getData
(
true
);
PViewOptions
*
opt
=
PView
::
list
[
ipv
]
->
getOptions
();
if
(
!
data
->
getDirty
()
&&
opt
->
visible
)
{
va
=
PView
::
list
[
ipv
]
->
va_lines
;
for
(
int
ipt
=
0
;
ipt
<
va
->
getNumVertices
();
ipt
+=
2
){
if
(
opt
->
lineType
!=
2
&&
opt
->
lineType
!=
1
)
{
float
*
p0
=
va
->
getVertexArray
(
3
*
ipt
);
float
*
p1
=
va
->
getVertexArray
(
3
*
(
ipt
+
1
));
fprintf
(
fp
,
"%g %g %g %g %g %g "
,
p0
[
0
],
p0
[
1
],
p0
[
2
],
p1
[
0
],
p1
[
1
],
p1
[
2
]);
}
}
}
// end for
}
// end if dirty
}
// end for loop on PView::list
fprintf
(
fp
,
"'/>
\n
"
);
fprintf
(
fp
,
" </IndexedLineSet>
\n
"
);
fprintf
(
fp
,
" <Appearance>
\n
"
);
...
...
@@ -412,9 +385,13 @@ bool PView::writeX3D(const std::string &fileName )
fprintf
(
fp
,
"</Shape>
\n
"
);
//vectors --------------------colored arrow replaced by colored cones-------------------
for
(
unsigned
int
ipv
=
0
;
ipv
<
PView
::
list
.
size
();
ipv
++
){
data
=
PView
::
list
[
ipv
]
->
getData
(
true
);
opt
=
PView
::
list
[
ipv
]
->
getOptions
();
if
(
!
data
->
getDirty
()
&&
opt
->
visible
)
{
va
=
PView
::
list
[
ipv
]
->
va_vectors
;
for
(
int
iv
=
0
;
iv
<
va
->
getNumVertices
();
iv
+=
2
){
float
*
s
=
va
->
getVertexArray
(
3
*
iv
);
float
*
v
=
va
->
getVertexArray
(
3
*
(
iv
+
1
));
...
...
@@ -438,47 +415,74 @@ bool PView::writeX3D(const std::string &fileName )
fprintf
(
fp
,
" </Appearance>
\n
"
);
fprintf
(
fp
,
"</Shape>
\n
"
);
fprintf
(
fp
,
"</Transform>
\n
"
);
}
}
}
// end if l
}
// end for iv
}
// end if dirty
}
// end for loop on PView::list
//triangles --------------------------colored triangles -------------------------------
va
=
PView
::
list
[
ipv
]
->
va_triangles
;
//triangles --------------------------colored triangles -------------------------------
//count all visible triangles of previous visited PView
_count
=
0
;
_ind
=
0.
;
fprintf
(
fp
,
"<Transform>
\n
"
);
fprintf
(
fp
,
"<Shape>
\n
"
);
fprintf
(
fp
,
" <IndexedTriangleSet index=' "
);
// index of point of the visible tirangle
int
ind
=
0
;
fprintf
(
fp
,
" <Appearance>
\n
"
);
fprintf
(
fp
,
" <Material transparency='%g' "
,
PView
::
getTransparencyValue
()
);
fprintf
(
fp
,
" ambientIntensity='0.15' diffuseColor='.5 .5 .5' emissiveColor='0 0 0' "
);
fprintf
(
fp
,
" shininess='0.1' specularColor='.1 .1 .1' />
\n
"
);
fprintf
(
fp
,
" </Appearance>
\n
"
);
fprintf
(
fp
,
" <IndexedTriangleSet solid='true' ccw='true' colorPerVertex='true'
\n
"
);
fprintf
(
fp
,
" normalPerVertex='true' containerField='geometry' index=' "
);
for
(
unsigned
int
ipv
=
0
;
ipv
<
PView
::
list
.
size
();
ipv
++
){
data
=
PView
::
list
[
ipv
]
->
getData
(
true
);
opt
=
PView
::
list
[
ipv
]
->
getOptions
();
if
(
!
data
->
getDirty
()
&&
opt
->
visible
)
{
va
=
PView
::
list
[
ipv
]
->
va_triangles
;
for
(
int
ipt
=
0
;
ipt
<
va
->
getNumVertices
();
ipt
+=
3
){
if
(
(
PView
::
getInnerBorder
()
&&
visible
[
_count
+
ipt
/
3
]
)
||
!
PView
::
getInnerBorder
()
)
{
fprintf
(
fp
,
"%i %i %i "
,
ind
,
ind
+
1
,
ind
+
2
);
ind
+=
3
;
if
(
(
PView
::
getInnerBorder
()
&&
visible
[
_count
]
)
||
!
PView
::
getInnerBorder
()
)
{
fprintf
(
fp
,
"%i %i %i "
,
_
ind
,
_
ind
+
1
,
_
ind
+
2
);
_
ind
+=
3
;
}
_count
++
;
}
fprintf
(
fp
,
" ' solid='false' ccw='true' colorPerVertex='true' normalPerVertex='true' containerField='geometry'>
\n
"
);
fprintf
(
fp
,
" <Coordinate point='"
);
}
// enf if dirty
}
// end loop on PView::list
fprintf
(
fp
,
" ' >
\n
"
);
fprintf
(
fp
,
" <Coordinate point='"
);
_count
=
0
;
for
(
unsigned
int
ipv
=
0
;
ipv
<
PView
::
list
.
size
();
ipv
++
){
data
=
PView
::
list
[
ipv
]
->
getData
(
true
);
opt
=
PView
::
list
[
ipv
]
->
getOptions
();
if
(
!
data
->
getDirty
()
&&
opt
->
visible
)
{
va
=
PView
::
list
[
ipv
]
->
va_triangles
;
for
(
int
ipt
=
0
;
ipt
<
va
->
getNumVertices
();
ipt
+=
3
){
if
(
(
PView
::
getInnerBorder
()
&&
visible
[
_count
+
ipt
/
3
]
)
||
!
PView
::
getInnerBorder
())
{
if
(
(
PView
::
getInnerBorder
()
&&
visible
[
_count
]
)
||
!
PView
::
getInnerBorder
())
{
float
*
p0
=
va
->
getVertexArray
(
3
*
ipt
);
float
*
p1
=
va
->
getVertexArray
(
3
*
(
ipt
+
1
));
float
*
p2
=
va
->
getVertexArray
(
3
*
(
ipt
+
2
));
/*
std::cout<<" PV" << ipv<<" ipt "<<ipt<<" coord "<<p0[0]<<","
<<p0[1]<<","<<p0[2]<<"|"<<p1[0]<<","<<p1[1]<<","<<p1[2]
<<"|"<<p2[0]<<","<<p2[1]<<","<<p2[2]<<std::endl;
*/
fprintf
(
fp
,
"%e %e %e %e %e %e %e %e %e "
,
p0
[
0
],
p0
[
1
],
p0
[
2
]
,
p1
[
0
],
p1
[
1
],
p1
[
2
]
,
p2
[
0
],
p2
[
1
],
p2
[
2
]);
}
_count
++
;
}
}
// enf if dirty
}
// end loop on PView::list
fprintf
(
fp
,
" '/>
\n
"
);
fprintf
(
fp
,
" <Color color='"
);
_count
=
0
;
for
(
unsigned
int
ipv
=
0
;
ipv
<
PView
::
list
.
size
();
ipv
++
){
data
=
PView
::
list
[
ipv
]
->
getData
(
true
);
opt
=
PView
::
list
[
ipv
]
->
getOptions
();
if
(
!
data
->
getDirty
()
&&
opt
->
visible
)
{
va
=
PView
::
list
[
ipv
]
->
va_triangles
;
for
(
int
ipt
=
0
;
ipt
<
va
->
getNumVertices
();
ipt
+=
3
){
if
(
(
PView
::
getInnerBorder
()
&&
visible
[
_count
+
ipt
/
3
]
)
||
!
PView
::
getInnerBorder
()
)
{
if
(
(
PView
::
getInnerBorder
()
&&
visible
[
_count
]
)
||
!
PView
::
getInnerBorder
()
)
{
unsigned
char
*
c0
=
va
->
getColorArray
(
4
*
ipt
);
unsigned
char
*
c1
=
va
->
getColorArray
(
4
*
(
ipt
+
1
));
unsigned
char
*
c2
=
va
->
getColorArray
(
4
*
(
ipt
+
2
));
...
...
@@ -486,29 +490,24 @@ bool PView::writeX3D(const std::string &fileName )
UnsignedChar2rgba
(
c0
,
rgba0
)
;
UnsignedChar2rgba
(
c1
,
rgba1
)
;
UnsignedChar2rgba
(
c2
,
rgba2
)
;
/*
fprintf(fp,"%g %g %g %g %g %g %g %g %g "
, rgba0[0],rgba0[1],rgba0[2]
, rgba1[0],rgba1[1],rgba1[2]
, rgba2[0],rgba2[1],rgba2[2]);
*/
fprintf
(
fp
,
"%g %g %g %g %g %g %g %g %g "
,
.5
,
.5
,
.5
,
.5
,
.5
,
.5
,
.5
,
.5
,
.5
);
}
_count
++
;
}
}
// enf if dirty
}
// end loop on PView::list
fprintf
(
fp
,
" '/>
\n
"
);
fprintf
(
fp
,
" </IndexedTriangleSet>
\n
"
);
fprintf
(
fp
,
" <Appearance>
\n
"
);
fprintf
(
fp
,
" <Material transparency='%g'
\n
"
,
PView
::
getTransparencyValue
()
);
fprintf
(
fp
,
" ambientIntensity=
\"
0.5
\"
"
);
fprintf
(
fp
,
" diffuseColor=
\"
.5 .5 .5
\"
"
);
fprintf
(
fp
,
" emissiveColor=
\"
0.0 0.0 0.0
\"
"
);
fprintf
(
fp
,
" shininess=
\"
0.25
\"
"
);
fprintf
(
fp
,
" specularColor=
\"
.1 .1 .1
\"
/> "
);
fprintf
(
fp
,
" </Appearance>
\n
"
);
fprintf
(
fp
,
"</Shape>
\n
"
);
fprintf
(
fp
,
"</Transform>
\n
"
);
_count
+=
va
->
getNumVertices
()
/
3
;
}
// enf if dirty
}
// end loop on PView::list
fprintf
(
fp
,
"</Scene>
\n
"
);
fprintf
(
fp
,
"</X3D>
\n
"
);
fclose
(
fp
);
...
...
@@ -737,3 +736,4 @@ static void writeX3DStringCenter( FILE *fp,char *label,double x, double y, doubl
fprintf
(
fp
,
" </Transform>
\n
"
);
}
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