Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thomas Pitiot
SocialAgents3D
Commits
ab0782c2
Commit
ab0782c2
authored
Mar 30, 2015
by
Thomas Pitiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajout chargement maillages + check
parent
1b4debb2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
68 deletions
+83
-68
include/env_map.h
include/env_map.h
+1
-0
src/env_map.cpp
src/env_map.cpp
+82
-68
No files found.
include/env_map.h
View file @
ab0782c2
...
...
@@ -54,6 +54,7 @@ public:
void
init
(
int
argc
,
char
**
argv
)
;
bool
checkPointInMap
(
VEC3
pos
,
Dart
neighborhood
);
bool
checkPointInCube
(
VEC3
pos
);
bool
checkFaces
();
// vérifie que tous les points des faces sont bien coplanaires si ce n'eest pas le cas renvoie true
bool
insideVolume
(
VEC3
pos
,
Dart
d
);
REAL
volumeMaxdistance
(
Vol
volume
);
VEC3
normaleFromVolume
(
Dart
volume
,
Dart
face
);
...
...
src/env_map.cpp
View file @
ab0782c2
...
...
@@ -32,66 +32,82 @@ void EnvMap::init(int argc, char **argv)
mapMaxZ
=
0
;
std
::
cout
<<
"Init EnvMap"
<<
std
::
endl
;
if
(
argc
>
2
)
#ifdef IHMap
map
.
initImplicitProperties
();
// Si map MR
#endif
if
(
argc
>
1
)
{
std
::
string
filename
(
argv
[
2
]);
std
::
string
filename
(
argv
[
1
]);
open_file
(
filename
);
TraversorV
<
MAP
>
tv
(
map
);
for
(
Dart
d
=
tv
.
begin
()
;
d
!=
tv
.
end
()
;
d
=
tv
.
next
())
{
position
[
d
]
/=
10
;
}
}
else
{
//Intialisation map
#ifdef IHMap
map
.
initImplicitProperties
();
// Si map MR
#endif
///// initialisation attributs
position
=
map
.
addAttribute
<
VEC3
,
VERTEX
,
MAP
>
(
"position"
);
facecenter
=
map
.
addAttribute
<
VEC3
,
FACE
,
MAP
>
(
"facecenter"
);
volumecenter
=
map
.
addAttribute
<
VEC3
,
VOLUME
,
MAP
>
(
"volumecenter"
);
color
=
map
.
addAttribute
<
VEC3
,
VOLUME
,
MAP
>
(
"color"
);
RegisteredEdges
=
map
.
addAttribute
<
ARETES
,
VOLUME
,
MAP
>
(
"RegisteredEdges"
);
RegisteredNeighborEdges
=
map
.
addAttribute
<
ARETES
,
VOLUME
,
MAP
>
(
"RegisteredNeighborEdges"
);
RegisteredTriangles
=
map
.
addAttribute
<
TRIANGLES
,
VOLUME
,
MAP
>
(
"RegisteredTriangles"
);
RegisteredNeighborTriangles
=
map
.
addAttribute
<
TRIANGLES
,
VOLUME
,
MAP
>
(
"RegisteredNeighborTriangles"
);
int
nb
=
1
;
Algo
::
Volume
::
Tilings
::
Cubic
::
Grid
<
PFP
>
cubic
(
map
,
nb
,
nb
,
nb
);
cubic
.
embedIntoGrid
(
position
,
1.0
f
,
1.0
f
,
1.0
f
);
// map.check();
TraversorV
<
MAP
>
tv
(
map
);
for
(
Dart
d
=
tv
.
begin
()
;
d
!=
tv
.
end
()
;
d
=
tv
.
next
())
{
position
[
d
]
*=
10
;
if
(
position
[
d
][
0
]
<
mapMinX
)
mapMinX
=
position
[
d
][
0
];
if
(
position
[
d
][
0
]
>
mapMaxX
)
mapMaxX
=
position
[
d
][
0
];
if
(
position
[
d
][
1
]
<
mapMinY
)
mapMinY
=
position
[
d
][
1
];
if
(
position
[
d
][
1
]
>
mapMaxY
)
mapMaxY
=
position
[
d
][
1
];
if
(
position
[
d
][
2
]
<
mapMinZ
)
mapMinZ
=
position
[
d
][
2
];
if
(
position
[
d
][
2
]
>
mapMaxZ
)
mapMaxZ
=
position
[
d
][
2
];
}
TraversorF
<
MAP
>
tf
(
map
);
for
(
Dart
d
=
tf
.
begin
()
;
d
!=
tf
.
end
()
;
d
=
tf
.
next
())
{
facecenter
[
d
]
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
,
VertexAttribute
<
VEC3
,
MAP
>>
(
map
,
d
,
position
);
// map.check();
}
if
(
checkFaces
())
exit
(
0
);
///// initialisation attributs
}
facecenter
=
map
.
addAttribute
<
VEC3
,
FACE
,
MAP
>
(
"facecenter"
);
volumecenter
=
map
.
addAttribute
<
VEC3
,
VOLUME
,
MAP
>
(
"volumecenter"
);
color
=
map
.
addAttribute
<
VEC3
,
VOLUME
,
MAP
>
(
"color"
);
RegisteredEdges
=
map
.
addAttribute
<
ARETES
,
VOLUME
,
MAP
>
(
"RegisteredEdges"
);
RegisteredNeighborEdges
=
map
.
addAttribute
<
ARETES
,
VOLUME
,
MAP
>
(
"RegisteredNeighborEdges"
);
RegisteredTriangles
=
map
.
addAttribute
<
TRIANGLES
,
VOLUME
,
MAP
>
(
"RegisteredTriangles"
);
RegisteredNeighborTriangles
=
map
.
addAttribute
<
TRIANGLES
,
VOLUME
,
MAP
>
(
"RegisteredNeighborTriangles"
);
TraversorW
<
MAP
>
tra
(
map
);
for
(
Dart
d
=
tra
.
begin
();
d
!=
tra
.
end
();
d
=
tra
.
next
())
{
color
[
d
]
=
position
[
d
]
/
10
+
VEC3
(
0.5
,
0.5
,
0.5
);
volumecenter
[
d
]
=
Algo
::
Surface
::
Geometry
::
volumeCentroid
<
PFP
,
VertexAttribute
<
VEC3
,
MAP
>>
(
map
,
d
,
position
);
}
TraversorV
<
MAP
>
tv
(
map
);
for
(
Dart
d
=
tv
.
begin
()
;
d
!=
tv
.
end
()
;
d
=
tv
.
next
())
{
if
(
position
[
d
][
0
]
<
mapMinX
)
mapMinX
=
position
[
d
][
0
];
if
(
position
[
d
][
0
]
>
mapMaxX
)
mapMaxX
=
position
[
d
][
0
];
if
(
position
[
d
][
1
]
<
mapMinY
)
mapMinY
=
position
[
d
][
1
];
if
(
position
[
d
][
1
]
>
mapMaxY
)
mapMaxY
=
position
[
d
][
1
];
if
(
position
[
d
][
2
]
<
mapMinZ
)
mapMinZ
=
position
[
d
][
2
];
if
(
position
[
d
][
2
]
>
mapMaxZ
)
mapMaxZ
=
position
[
d
][
2
];
}
TraversorF
<
MAP
>
tf
(
map
);
for
(
Dart
d
=
tf
.
begin
()
;
d
!=
tf
.
end
()
;
d
=
tf
.
next
())
{
facecenter
[
d
]
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
,
VertexAttribute
<
VEC3
,
MAP
>>
(
map
,
d
,
position
);
}
TraversorW
<
MAP
>
tra
(
map
);
for
(
Dart
d
=
tra
.
begin
();
d
!=
tra
.
end
();
d
=
tra
.
next
())
{
VEC3
pos
=
position
[
d
];
color
[
d
]
=
VEC3
((
pos
[
0
]
-
mapMinX
)
/
(
mapMaxX
-
mapMinX
),(
pos
[
1
]
-
mapMinY
)
/
(
mapMaxY
-
mapMinY
),(
pos
[
2
]
-
mapMinZ
)
/
(
mapMaxZ
-
mapMinZ
));
volumecenter
[
d
]
=
Algo
::
Surface
::
Geometry
::
volumeCentroid
<
PFP
,
VertexAttribute
<
VEC3
,
MAP
>>
(
map
,
d
,
position
);
}
map
.
check
();
}
REAL
EnvMap
::
volumeMaxdistance
(
Vol
volume
)
...
...
@@ -179,9 +195,6 @@ bool EnvMap::insideVolume(VEC3 pos, Dart volume) // définit si le point pos est
///// a coder
Dart
EnvMap
::
getBelongingCell
(
const
PFP
::
VEC3
&
pos
)
{
#ifdef IHMap
...
...
@@ -204,7 +217,30 @@ Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
}
bool
EnvMap
::
checkFaces
()
{
CGoGNout
<<
"check faces"
<<
CGoGNendl
;
TraversorF
<
MAP
>
tf
(
map
);
for
(
Dart
d
=
tf
.
begin
()
;
d
!=
tf
.
end
()
;
d
=
tf
.
next
())
{
Dart
d2
=
map
.
phi1
(
d
);
Dart
d3
=
map
.
phi1
(
d2
);
Geom
::
Plane3D
<
typename
PFP
::
REAL
>
plan
(
position
[
d
],
position
[
d2
],
position
[
d3
]);
do
{
d3
=
map
.
phi1
(
d3
);
if
(
plan
.
orient
(
position
[
d3
])
!=
Geom
::
ON
)
{
CGoGNout
<<
" face non coplanaire !"
<<
d3
<<
CGoGNendl
;
return
true
;
}
}
while
(
d3
!=
d
);
}
return
false
;
}
...
...
@@ -244,37 +280,15 @@ void EnvMap::open_file(std::string filename)
}
else
{
// if(!Algo::Volume::Import::importMesh<PFP>(map, filename, attrNames))
// {
// std::cerr << "could not import " << filename << std::endl ;
// return ;
// }
// else
// position = map.getAttribute<VEC3, VERTEX>(attrNames[0]) ;
}
color
=
map
.
addAttribute
<
VEC3
,
VOLUME
,
MAP
>
(
"colorVol"
);
TraversorCell
<
MAP
,
VOLUME
>
tra
(
map
);
float
maxV
=
0.0
f
;
for
(
Dart
d
=
tra
.
begin
();
d
!=
tra
.
end
();
d
=
tra
.
next
())
{
float
v
=
Algo
::
Geometry
::
tetrahedronVolume
<
PFP
>
(
map
,
d
,
position
);
color
[
d
]
=
VEC3
(
v
,
0
,
0
);
if
(
v
>
maxV
)
maxV
=
v
;
// if(envMap.map.isVolumeIncidentToBoundary(d))
// color[d] = VEC3(0,0,0);
// else
color
[
d
]
=
VEC3
(
v
,
0
,
0
);
if
(
!
Algo
::
Volume
::
Import
::
importMesh
<
PFP
>
(
map
,
filename
,
attrNames
))
{
std
::
cerr
<<
"could not import "
<<
filename
<<
std
::
endl
;
return
;
}
else
position
=
map
.
getAttribute
<
VEC3
,
VERTEX
,
MAP
>
(
attrNames
[
0
])
;
}
for
(
unsigned
int
i
=
color
.
begin
();
i
!=
color
.
end
();
color
.
next
(
i
))
{
color
[
i
][
0
]
/=
maxV
;
color
[
i
][
2
]
=
1.0
f
-
color
[
i
][
0
];
}
}
}
//////////////////////////////////enregistrement des segments
...
...
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