Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CGoGN
CGoGN
Commits
cc9276e7
Commit
cc9276e7
authored
Jan 28, 2011
by
Pierre Kraemer
Browse files
decimationVolumique ok
parent
7e940260
Changes
11
Hide whitespace changes
Inline
Side-by-side
Apps/Examples/decimationVolumique.cpp
View file @
cc9276e7
...
...
@@ -348,12 +348,10 @@ void maillageTest()
int
main
(
int
argc
,
char
**
argv
)
{
//Initilisation du plongement geometrique
position
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"position"
);
/*
* Chargement de maillages
*/
std
::
vector
<
std
::
string
>
attrNames
;
if
(
argc
<
2
)
{
std
::
cerr
<<
"usage : "
<<
argv
[
0
]
<<
" -off"
<<
std
::
endl
;
...
...
@@ -371,7 +369,8 @@ int main(int argc, char **argv)
return
1
;
}
Algo
::
Import
::
importOFFWithELERegions
<
PFP
>
(
myMap
,
position
,
argv
[
2
],
argv
[
3
]);
Algo
::
Import
::
importOFFWithELERegions
<
PFP
>
(
myMap
,
argv
[
2
],
argv
[
3
],
attrNames
);
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
attrNames
[
0
])
;
}
else
if
(
std
::
string
(
argv
[
1
])
==
"-tet"
)
{
...
...
@@ -380,7 +379,8 @@ int main(int argc, char **argv)
return
1
;
}
Algo
::
Import
::
importTet
<
PFP
>
(
myMap
,
position
,
argv
[
2
]);
Algo
::
Import
::
importTet
<
PFP
>
(
myMap
,
argv
[
2
],
attrNames
);
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
attrNames
[
0
])
;
}
else
if
(
std
::
string
(
argv
[
1
])
==
"-ts"
)
{
...
...
@@ -389,7 +389,8 @@ int main(int argc, char **argv)
return
1
;
}
Algo
::
Import
::
importTs
<
PFP
>
(
myMap
,
position
,
argv
[
2
]);
Algo
::
Import
::
importTs
<
PFP
>
(
myMap
,
argv
[
2
],
attrNames
);
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
attrNames
[
0
])
;
//scalar = myMap.getAttribute<PFP::REAL>(VERTEX_ORBIT, "scalar");
}
...
...
Apps/Examples/decimationVolumique.h
View file @
cc9276e7
...
...
@@ -21,6 +21,7 @@
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __DECIMATIONVOLUMIQUE__
#define __DECIMATIONVOLUMIQUE__
...
...
@@ -45,30 +46,25 @@
using
namespace
CGoGN
;
struct
PFP
{
// definition de la carte
struct
PFP
{
// definition of the map
typedef
Map3
MAP
;
// definition
du
type
de
re
e
l
utilis
e
// definition
of the
type
of
re
a
l
valu
e
typedef
float
REAL
;
// definition du type de vecteur (point) utilise
// other types definitions
typedef
Geom
::
Vector
<
3
,
REAL
>
VEC3
;
// definition du
type
de
matrice 3x3 utilise
typede
f
Geom
::
Vector
<
6
,
REAL
>
VEC6
;
typedef
Geom
::
Matrix
<
3
,
3
,
REAL
>
MATRIX33
;
// definition du type de matrice 4x4 utilise
typedef
Geom
::
Matrix
<
4
,
4
,
REAL
>
MATRIX44
;
typedef
Geom
::
Matrix
<
3
,
6
,
REAL
>
MATRIX36
;
// definition du type du AttributeHandler de vecteur 3D
typedef
AttributeHandler
<
VEC3
>
TVEC3
;
// definition du type du AttributeHandler de reels
typedef
AttributeHandler
<
REAL
>
TREAL
;
};
// qq initialisation cachees (car penible syntaxiquement)
INIT_STATICS_MAP
();
PFP
::
MAP
myMap
;
SelectorTrue
allDarts
;
PFP
::
TVEC3
position
;
...
...
Apps/Examples/squelette3carte.h
View file @
cc9276e7
...
...
@@ -21,6 +21,7 @@
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __SQUELETTE3CARTE__
#define __SQUELETTE3CARTE__
...
...
@@ -45,29 +46,25 @@
using
namespace
CGoGN
;
struct
PFP
{
// definition de la carte
struct
PFP
{
// definition of the map
typedef
Map3
MAP
;
// definition
du
type
de
re
e
l
utilis
e
// definition
of the
type
of
re
a
l
valu
e
typedef
float
REAL
;
// definition du type de vecteur (point) utilise
// other types definitions
typedef
Geom
::
Vector
<
3
,
REAL
>
VEC3
;
// definition du
type
de
matrice 3x3 utilise
typede
f
Geom
::
Vector
<
6
,
REAL
>
VEC6
;
typedef
Geom
::
Matrix
<
3
,
3
,
REAL
>
MATRIX33
;
// definition du type de matrice 4x4 utilise
typedef
Geom
::
Matrix
<
4
,
4
,
REAL
>
MATRIX44
;
typedef
Geom
::
Matrix
<
3
,
6
,
REAL
>
MATRIX36
;
// definition du type du AttributeHandler de vecteur 3D
typedef
AttributeHandler
<
VEC3
>
TVEC3
;
// definition du type du AttributeHandler de reels
typedef
AttributeHandler
<
REAL
>
TREAL
;
};
// qq initialisation cachees (car penible syntaxiquement)
INIT_STATICS_MAP
();
PFP
::
MAP
myMap
;
SelectorTrue
allDarts
;
...
...
include/Algo/Import/import.h
View file @
cc9276e7
...
...
@@ -49,10 +49,6 @@ namespace Import
template
<
typename
PFP
>
bool
importMesh
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportSurfacique
::
ImportType
kind
=
ImportSurfacique
::
UNKNOWNSURFACE
);
template
<
typename
PFP
>
bool
importPLYPTM
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
typename
PFP
::
TVEC3
&
positions
,
ImportSurfacique
::
ImportType
kind
,
typename
PFP
::
TFRAME
&
frame
,
typename
PFP
::
TRGBFUNCTIONS
&
funcs
);
/**
* import a volumic mesh
*/
...
...
@@ -63,27 +59,26 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, typename PF
//bool importObjWithTex(typename PFP::MAP& map, const std::string& filename);
//
/*
* TODO a transformer en utilisant un MeshTableVolume.
*/
template
<
typename
PFP
>
bool
importOFFWithELERegions
(
typename
PFP
::
MAP
&
the_map
,
typename
PFP
::
TVEC3
&
m_position
,
char
*
filenameOFF
,
char
*
filenameELE
);
bool
importOFFWithELERegions
(
typename
PFP
::
MAP
&
the_map
,
char
*
filenameOFF
,
char
*
filenameELE
,
std
::
vector
<
std
::
string
>&
attrNames
);
template
<
typename
PFP
>
bool
importTet
(
typename
PFP
::
MAP
&
the_map
,
typename
PFP
::
TVEC3
&
m_position
,
char
*
filen
ame
,
float
scaleFactor
=
1.0
f
);
bool
importTet
(
typename
PFP
::
MAP
&
the_map
,
char
*
filename
,
std
::
vector
<
std
::
string
>&
attrN
ame
s
,
float
scaleFactor
=
1.0
f
);
template
<
typename
PFP
>
bool
importTs
(
typename
PFP
::
MAP
&
the_map
,
typename
PFP
::
TVEC3
&
m_position
,
char
*
filen
ame
,
float
scaleFactor
=
1.0
f
);
bool
importTs
(
typename
PFP
::
MAP
&
the_map
,
char
*
filename
,
std
::
vector
<
std
::
string
>&
attrN
ame
s
,
float
scaleFactor
=
1.0
f
);
template
<
typename
PFP
>
bool
importInESS
(
typename
PFP
::
MAP
&
the_map
,
typename
PFP
::
TVEC3
&
m_position
,
char
*
filen
ame
);
bool
importInESS
(
typename
PFP
::
MAP
&
the_map
,
char
*
filename
,
std
::
vector
<
std
::
string
>&
attrN
ame
s
);
}
}
// namespace Import
}
}
// namespace Algo
}
}
// namespace CGoGN
#include
"Algo/Import/importMesh.hpp"
//#include "Algo/Import/importObjTex.hpp"
...
...
include/Algo/Import/import2tables.h
View file @
cc9276e7
...
...
@@ -50,12 +50,12 @@ namespace Import
namespace
ImportSurfacique
{
enum
ImportType
{
UNKNOWNSURFACE
,
TRIAN
,
TRIANBGZ
,
PLY
,
PLYPTM
,
OFF
,
OBJ
,
CTM
,
VRML
};
enum
ImportType
{
UNKNOWNSURFACE
,
TRIAN
,
TRIANBGZ
,
PLY
,
PLYPTM
,
OFF
,
OBJ
,
CTM
,
VRML
};
}
namespace
ImportVolumique
{
enum
ImportType
{
UNKNOWNVOLUME
,
TET
,
TRIANBGZ
,
PLY
};
enum
ImportType
{
UNKNOWNVOLUME
,
TET
,
TRIANBGZ
,
PLY
};
}
...
...
include/Algo/Import/import2tablesSurface.hpp
View file @
cc9276e7
...
...
@@ -45,6 +45,7 @@ ImportSurfacique::ImportType MeshTablesSurface<PFP>::getFileType(const std::stri
{
if
((
filename
.
rfind
(
".trianbgz"
)
!=
std
::
string
::
npos
)
||
(
filename
.
rfind
(
".TRIANBGZ"
)
!=
std
::
string
::
npos
))
return
ImportSurfacique
::
TRIANBGZ
;
if
((
filename
.
rfind
(
".trian"
)
!=
std
::
string
::
npos
)
||
(
filename
.
rfind
(
".TRIAN"
)
!=
std
::
string
::
npos
))
return
ImportSurfacique
::
TRIAN
;
...
...
@@ -53,10 +54,13 @@ ImportSurfacique::ImportType MeshTablesSurface<PFP>::getFileType(const std::stri
if
((
filename
.
rfind
(
".ply"
)
!=
std
::
string
::
npos
)
||
(
filename
.
rfind
(
".PLY"
)
!=
std
::
string
::
npos
))
return
ImportSurfacique
::
PLY
;
if
((
filename
.
rfind
(
".off"
)
!=
std
::
string
::
npos
)
||
(
filename
.
rfind
(
".OFF"
)
!=
std
::
string
::
npos
))
return
ImportSurfacique
::
OFF
;
if
((
filename
.
rfind
(
".obj"
)
!=
std
::
string
::
npos
)
||
(
filename
.
rfind
(
".OBJ"
)
!=
std
::
string
::
npos
))
return
ImportSurfacique
::
OBJ
;
if
((
filename
.
rfind
(
".ctm"
)
!=
std
::
string
::
npos
)
||
(
filename
.
rfind
(
".OBJ"
)
!=
std
::
string
::
npos
))
return
ImportSurfacique
::
CTM
;
...
...
@@ -93,6 +97,10 @@ bool MeshTablesSurface<PFP>::importMesh(const std::string& filename, std::vector
std
::
cout
<<
"TYPE: PLY"
<<
std
::
endl
;
return
importPly
(
filename
,
attrNames
);
break
;
case
ImportSurfacique
::
PLYPTM
:
std
::
cout
<<
"TYPE: PLYPTM"
<<
std
::
endl
;
return
importPlyPTM
(
filename
,
attrNames
);
break
;
case
ImportSurfacique
::
OBJ
:
std
::
cout
<<
"TYPE: OBJ"
<<
std
::
endl
;
return
importObj
(
filename
,
attrNames
);
...
...
include/Algo/Import/importInESS.hpp
View file @
cc9276e7
...
...
@@ -33,7 +33,7 @@ namespace Import
{
template
<
typename
PFP
>
typename
PFP
::
VEC3
stringToEmb
(
std
::
string
s
)
typename
PFP
::
VEC3
stringToEmb
(
std
::
string
&
s
)
{
if
(
s
[
0
]
==
'('
)
s
.
erase
(
0
,
2
);
...
...
@@ -55,10 +55,13 @@ typename PFP::VEC3 stringToEmb(std::string s)
}
template
<
typename
PFP
>
bool
importInESS
(
typename
PFP
::
MAP
&
the_
map
,
typename
PFP
::
TVEC3
&
m_position
,
char
*
filen
ame
)
bool
importInESS
(
typename
PFP
::
MAP
&
map
,
char
*
filename
,
std
::
vector
<
std
::
string
>&
attrN
ame
s
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
AttribContainer
&
container
=
map
.
getAttributeContainer
(
VERTEX_CELL
)
;
AttributeHandler
<
VEC3
>
position
=
map
.
template
addAttribute
<
VEC3
>(
VERTEX_ORBIT
,
"position"
)
;
attrNames
.
push_back
(
position
.
name
())
;
// open file
std
::
ifstream
fp
(
filename
,
std
::
ios
::
in
);
...
...
@@ -85,10 +88,8 @@ bool importInESS(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, ch
stringToEmb
<
PFP
>
(
bg
.
substr
(
0
,
posCoord
));
stringToEmb
<
PFP
>
(
bg
.
substr
(
posCoord
+
3
));
while
(
std
::
getline
(
fp
,
line
)
)
{
posData
=
line
.
find
(
"
\t
"
);
// First column
...
...
@@ -107,14 +108,12 @@ bool importInESS(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, ch
++
count
;
}
fp
.
close
();
return
true
;
}
}
// namespace Import
}
// namespace Algo
}
}
// end namespaces
}
}
// namespace CGoGN
include/Algo/Import/importMesh.hpp
View file @
cc9276e7
...
...
@@ -430,8 +430,6 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
template
<
typename
PFP
>
bool
importMesh
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportSurfacique
::
ImportType
kind
)
{
// AttribContainer& vertexContainer = map.getAttributeContainer(VERTEX_ORBIT);
MeshTablesSurface
<
PFP
>
mts
(
map
);
if
(
!
mts
.
importMesh
(
filename
,
attrNames
,
kind
))
...
...
@@ -440,20 +438,6 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector
return
importMesh
<
PFP
>
(
map
,
mts
);
}
template
<
typename
PFP
>
bool
importPLYPTM
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
typename
PFP
::
TVEC3
&
positions
,
ImportSurfacique
::
ImportType
kind
,
typename
PFP
::
TFRAME
&
Frame
,
typename
PFP
::
TRGBFUNCS
&
RGBfunctions
)
{
AttribContainer
&
vertexContainer
=
map
.
getAttributeContainer
(
VERTEX_ORBIT
);
MeshTablesSurface
<
PFP
>
mts
(
vertexContainer
,
positions
);
if
(
!
mts
.
importPlyPTM
(
filename
,
Frame
,
RGBfunctions
))
return
false
;
return
importMesh
<
PFP
>
(
map
,
mts
);
}
template
<
typename
PFP
>
bool
importMesh
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
typename
PFP
::
TVEC3
&
positions
,
ImportVolumique
::
ImportType
kind
)
{
...
...
include/Algo/Import/importObjEle.hpp
View file @
cc9276e7
...
...
@@ -27,19 +27,25 @@
namespace
CGoGN
{
namespace
Algo
{
namespace
Import
namespace
Import
{
template
<
typename
PFP
>
bool
importOFFWithELERegions
(
typename
PFP
::
MAP
&
the_map
,
typename
PFP
::
TVEC3
&
m_position
,
char
*
filenameOFF
,
char
*
filenameELE
)
bool
importOFFWithELERegions
(
typename
PFP
::
MAP
&
map
,
char
*
filenameOFF
,
char
*
filenameELE
,
std
::
vector
<
std
::
string
>&
attrNames
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
AttribContainer
&
container
=
map
.
getAttributeContainer
(
VERTEX_CELL
)
;
AttributeHandler
<
VEC3
>
position
=
map
.
template
addAttribute
<
VEC3
>(
VERTEX_ORBIT
,
"position"
)
;
attrNames
.
push_back
(
position
.
name
())
;
unsigned
int
m_nbVertices
=
0
,
m_nbFaces
=
0
,
m_nbEdges
=
0
,
m_nbVolumes
=
0
;
AutoAttributeHandler
<
NoMathIONameAttribute
<
std
::
vector
<
Dart
>
>
>
vecDartsPerVertex
(
the_
map
,
VERTEX_ORBIT
,
"incidents"
);
AutoAttributeHandler
<
NoMathIONameAttribute
<
std
::
vector
<
Dart
>
>
>
vecDartsPerVertex
(
map
,
VERTEX_ORBIT
,
"incidents"
);
// open files
std
::
ifstream
foff
(
filenameOFF
,
std
::
ios
::
in
);
...
...
@@ -67,7 +73,6 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
return
false
;
}
//Reading number of vertex/faces/edges in OFF file
int
nbe
;
{
...
...
@@ -98,13 +103,11 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
std
::
cout
<<
"nb points = "
<<
m_nbVertices
<<
" / nb faces = "
<<
m_nbFaces
<<
" / nb edges = "
<<
m_nbEdges
<<
" / nb tet = "
<<
m_nbVolumes
<<
std
::
endl
;
AttribContainer
&
m_container
=
the_map
.
getAttributeContainer
(
VERTEX_ORBIT
);
//Reading vertices
std
::
vector
<
unsigned
int
>
verticesID
;
verticesID
.
reserve
(
m_nbVertices
);
for
(
unsigned
int
i
=
0
;
i
<
m_nbVertices
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
m_nbVertices
;
++
i
)
{
do
{
...
...
@@ -120,8 +123,8 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
//we can read colors informations if exists
VEC3
pos
(
x
,
y
,
z
);
unsigned
int
id
=
m_
container
.
insertLine
();
m_
position
[
id
]
=
pos
;
unsigned
int
id
=
container
.
insertLine
();
position
[
id
]
=
pos
;
// std::cout << "emb : " << pos << " / id = " << id << std::endl;
verticesID
.
push_back
(
id
);
...
...
@@ -142,8 +145,8 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
oss
>>
nbe
;
// std::cout << "tetra number : " << nbe << std::endl;
//Algo::Modelisation::Polyhedron<PFP>::createOrientedTetra(
the_
map);
Dart
d
=
Algo
::
Modelisation
::
Polyhedron
<
PFP
>::
createOrientedPolyhedron
(
the_
map
,
4
);
//Algo::Modelisation::Polyhedron<PFP>::createOrientedTetra(map);
Dart
d
=
Algo
::
Modelisation
::
Polyhedron
<
PFP
>::
createOrientedPolyhedron
(
map
,
4
);
Geom
::
Vec4ui
pt
;
oss
>>
pt
[
0
];
oss
>>
pt
[
1
];
...
...
@@ -160,33 +163,33 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
{
// std::cout << "\t embedding number : " << pt[j];
FunctorSetEmb
<
typename
PFP
::
MAP
>
femb
(
the_
map
,
VERTEX_ORBIT
,
verticesID
[
pt
[
j
]]);
FunctorSetEmb
<
typename
PFP
::
MAP
>
femb
(
map
,
VERTEX_ORBIT
,
verticesID
[
pt
[
j
]]);
Dart
dd
=
d
;
do
{
femb
(
dd
);
//vecDartPtrEmb[pt[j]].push_back(dd);
vecDartsPerVertex
[
pt
[
j
]].
push_back
(
dd
);
dd
=
the_
map
.
phi1
(
the_
map
.
phi2
(
dd
));
dd
=
map
.
phi1
(
map
.
phi2
(
dd
));
}
while
(
dd
!=
d
);
d
=
the_
map
.
phi1
(
d
);
d
=
map
.
phi1
(
d
);
// std::cout << " done" << std::endl;
}
//Embed the last vertex
// std::cout << "\t embedding number : " << pt[3] << std::endl;
d
=
the_
map
.
phi_1
(
the_
map
.
phi2
(
d
));
d
=
map
.
phi_1
(
map
.
phi2
(
d
));
FunctorSetEmb
<
typename
PFP
::
MAP
>
femb
(
the_
map
,
VERTEX_ORBIT
,
verticesID
[
pt
[
3
]]);
FunctorSetEmb
<
typename
PFP
::
MAP
>
femb
(
map
,
VERTEX_ORBIT
,
verticesID
[
pt
[
3
]]);
Dart
dd
=
d
;
do
{
femb
(
dd
);
// std::cout << "embed" << std::endl;
//vecDartPtrEmb[pt[3]].push_back(dd);
vecDartsPerVertex
[
pt
[
3
]].
push_back
(
dd
);
dd
=
the_
map
.
phi1
(
the_
map
.
phi2
(
dd
));
dd
=
map
.
phi1
(
map
.
phi2
(
dd
));
}
while
(
dd
!=
d
);
// std::cout << "end tetra" << std::endl;
...
...
@@ -198,21 +201,21 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
fele
.
close
();
//Association des phi3
for
(
Dart
d
=
the_
map
.
begin
();
d
!=
the_
map
.
end
();
the_
map
.
next
(
d
))
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
std
::
vector
<
Dart
>&
vec
=
vecDartsPerVertex
[
d
];
for
(
typename
std
::
vector
<
Dart
>::
iterator
it
=
vec
.
begin
();
it
!=
vec
.
end
();
++
it
)
{
if
(
the_
map
.
phi3
(
*
it
)
==*
it
)
if
(
map
.
phi3
(
*
it
)
==*
it
)
{
bool
sewn
=
false
;
for
(
typename
std
::
vector
<
Dart
>::
iterator
itnext
=
it
+
1
;
itnext
!=
vec
.
end
()
&&
!
sewn
;
++
itnext
)
{
if
(
the_
map
.
getDartEmbedding
(
VERTEX_ORBIT
,
the_
map
.
phi1
(
*
it
))
==
the_
map
.
getDartEmbedding
(
VERTEX_ORBIT
,
the_
map
.
phi_1
(
*
itnext
))
&&
the_
map
.
getDartEmbedding
(
VERTEX_ORBIT
,
the_
map
.
phi_1
(
*
it
))
==
the_
map
.
getDartEmbedding
(
VERTEX_ORBIT
,
the_
map
.
phi1
(
*
itnext
)))
if
(
map
.
getDartEmbedding
(
VERTEX_ORBIT
,
map
.
phi1
(
*
it
))
==
map
.
getDartEmbedding
(
VERTEX_ORBIT
,
map
.
phi_1
(
*
itnext
))
&&
map
.
getDartEmbedding
(
VERTEX_ORBIT
,
map
.
phi_1
(
*
it
))
==
map
.
getDartEmbedding
(
VERTEX_ORBIT
,
map
.
phi1
(
*
itnext
)))
{
the_
map
.
sewVolumes
(
*
it
,
the_
map
.
phi_1
(
*
itnext
));
map
.
sewVolumes
(
*
it
,
map
.
phi_1
(
*
itnext
));
sewn
=
true
;
}
}
...
...
@@ -225,7 +228,8 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
return
true
;
}
}
// namespace Import
}
}
// end namespaces
}
}
// namespace Algo
}
// namespace CGoGN
include/Algo/Import/importTet.hpp
View file @
cc9276e7
...
...
@@ -33,12 +33,16 @@ namespace Import
{
template
<
typename
PFP
>
bool
importTet
(
typename
PFP
::
MAP
&
the_
map
,
typename
PFP
::
TVEC3
&
m_position
,
char
*
filen
ame
,
float
scaleFactor
)
bool
importTet
(
typename
PFP
::
MAP
&
map
,
char
*
filename
,
std
::
vector
<
std
::
string
>&
attrN
ame
s
,
float
scaleFactor
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
AttribContainer
&
container
=
map
.
getAttributeContainer
(
VERTEX_CELL
)
;
AttributeHandler
<
VEC3
>
position
=
map
.
template
addAttribute
<
VEC3
>(
VERTEX_ORBIT
,
"position"
)
;
attrNames
.
push_back
(
position
.
name
())
;
unsigned
int
m_nbVertices
=
0
,
m_nbFaces
=
0
,
m_nbEdges
=
0
,
m_nbVolumes
=
0
;
AutoAttributeHandler
<
NoMathIONameAttribute
<
std
::
vector
<
Dart
>
>
>
vecDartsPerVertex
(
the_
map
,
VERTEX_ORBIT
,
"incidents"
);
AutoAttributeHandler
<
NoMathIONameAttribute
<
std
::
vector
<
Dart
>
>
>
vecDartsPerVertex
(
map
,
VERTEX_ORBIT
,
"incidents"
);
// open file
std
::
ifstream
fp
(
filename
,
std
::
ios
::
in
);
...
...
@@ -63,8 +67,6 @@ bool importTet(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, char
//std::cout << "nbT = " << nbt << std::endl;
AttribContainer
&
m_container
=
the_map
.
getAttributeContainer
(
VERTEX_ORBIT
);
//lecture sommets
std
::
vector
<
unsigned
int
>
verticesID
;
verticesID
.
reserve
(
nbv
);
...
...
@@ -86,8 +88,8 @@ bool importTet(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, char
//std::cout << "VEC3 = " << pos << std::endl;
unsigned
int
id
=
m_
container
.
insertLine
();
m_
position
[
id
]
=
pos
;
unsigned
int
id
=
container
.
insertLine
();
position
[
id
]
=
pos
;
verticesID
.
push_back
(
id
);
}
...
...
@@ -105,99 +107,99 @@ bool importTet(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, char
std
::
cout
<<
"nb points = "
<<
m_nbVertices
<<
" / nb faces = "
<<
m_nbFaces
<<
" / nb edges = "
<<
m_nbEdges
<<
" / nb tet = "
<<
m_nbVolumes
<<
std
::
endl
;
//Read and embed tetrahedra TODO
for
(
unsigned
i
=
0
;
i
<
m_nbVolumes
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
m_nbVolumes
;
++
i
)
{
int
nbe
;
do
{
int
nbe
;
do
{
std
::
getline
(
fp
,
ligne
);
}
while
(
ligne
.
size
()
==
0
);
std
::
stringstream
oss
(
ligne
);
oss
>>
nbe
;
// std::cout << "tetra number : " << nbe << std::endl;
//Algo::Modelisation::Polyhedron<PFP>::createOrientedTetra(the_map);
Dart
d
=
Algo
::
Modelisation
::
Polyhedron
<
PFP
>::
createOrientedPolyhedron
(
the_map
,
4
);
Geom
::
Vec4ui
pt
;
oss
>>
pt
[
0
];
oss
>>
pt
[
1
];
oss
>>
pt
[
2
];
oss
>>
pt
[
3
];
std
::
getline
(
fp
,
ligne
);
}
while
(
ligne
.
size
()
==
0
);
//regions ?
oss
>>
nbe
;
// std::cout << "\t embedding number : " << pt[0] << " " << pt[1] << " " << pt[2] << " " << pt[3] << std::endl;
// Embed three vertices
for
(
unsigned
int
j
=
0
;
j
<
3
;
++
j
)
{
// std::cout << "\t embedding number : " << pt[j];
std
::
stringstream
oss
(
ligne
);
oss
>>
nbe
;
// std::cout << "tetra number : " << nbe << std::endl;
FunctorSetEmb
<
typename
PFP
::
MAP
>
femb
(
the_map
,
VERTEX_ORBIT
,
verticesID
[
pt
[
j
]]);
//Algo::Modelisation::Polyhedron<PFP>::createOrientedTetra(map);
Dart
d
=
Algo
::
Modelisation
::
Polyhedron
<
PFP
>::
createOrientedPolyhedron
(
map
,
4
);
Geom
::
Vec4ui
pt
;
oss
>>
pt
[
0
];
oss
>>
pt
[
1
];
oss
>>
pt
[
2
];
oss
>>
pt
[
3
];
Dart
dd
=
d
;
do
{
femb
(
dd
);
//vecDartPtrEmb[pt[j]].push_back(dd);
vecDartsPerVertex
[
pt
[
j
]].
push_back
(
dd
);
dd
=
the_map
.
phi1
(
the_map
.
phi2
(
dd
));
}
while
(
dd
!=
d
);
//regions ?
oss
>>
nbe
;
d
=
the_map
.
phi1
(
d
)
;
// std::cout << "\t embedding number : " << pt[0] << " " << pt[1] << " " << pt[2] << " " << pt[3] << std::endl
;
// std::cout << " done" << std::endl;
}
// Embed three vertices
for
(
unsigned
int
j
=
0
;
j
<
3
;
++
j
)
{
// std::cout << "\t embedding number : " << pt[j];
//Embed the last vertex
// std::cout << "\t embedding number : " << pt[3] << std::endl;
d
=
the_map
.
phi_1
(
the_map
.
phi2
(
d
));
FunctorSetEmb
<
typename
PFP
::
MAP
>
femb
(
map
,
VERTEX_ORBIT
,
verticesID
[
pt
[
j
]]);
FunctorSetEmb
<
typename
PFP
::
MAP
>
femb
(
the_map
,
VERTEX_ORBIT
,
verticesID
[
pt
[
3
]]);
Dart
dd
=
d
;
do
{
femb
(
dd
);
// std::cout << "embed" << std::endl;
//vecDartPtrEmb[pt[3]].push_back(dd);
vecDartsPerVertex
[
pt
[
3
]].
push_back
(
dd
);
dd
=
the_map
.
phi1
(
the_map
.
phi2
(
dd
));
}
while
(
dd
!=
d
);
//vecDartPtrEmb[pt[j]].push_back(dd);
vecDartsPerVertex
[
pt
[
j
]].
push_back
(
dd
);
dd
=
map
.
phi1
(
map
.
phi2
(
dd
));
}
while
(
dd
!=
d
);
// std::cout << "end tetra" << std::endl;
d
=
map
.
phi1
(
d
);
// std::cout << " done" << std::endl;
}