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
Thomas Pitiot
CGoGN
Commits
6d2bfd06
Commit
6d2bfd06
authored
Mar 29, 2012
by
Pierre Kraemer
Browse files
import MOKA file (3GMap)
parent
0ff930b2
Changes
6
Hide whitespace changes
Inline
Side-by-side
include/Algo/Import/import.h
View file @
6d2bfd06
...
...
@@ -43,38 +43,44 @@ namespace Import
/**
* import a mesh
* @param map the map in which the function imports the mesh
* @param filename
(*.{trian,trianbgz,off,obj,ply})
* @param filename
* @param attrNames attribute names
* @param kind what kind of mesh is the file (if none (-1) determined by filename extension) (cf enum in Mesh2Tables for other kind values)
* @param mergeColseVertces a boolean indicating if the imported mesh should be closed
* @param mergeCloseVertices a boolean indicating if close vertices should be merged during import
* @return a boolean indicating if import was successfull
*/
template
<
typename
PFP
>
bool
importMesh
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportSurfacique
::
ImportType
kind
=
ImportSurfacique
::
UNKNOWNSURFACE
,
bool
mergeCloseVertices
=
false
);
bool
importMesh
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
bool
mergeCloseVertices
=
false
);
/**
* import a volumetric mesh
* @param map the map in which the function imports the mesh
* @param filename
(*.{tet,off,ts})
* @param filename
* @param attrNames attribute names
* @param kind what kind of mesh is the file (if none (-1) determined by filename extension) (cf enum in Mesh2Tables for other kind values)
* @param mergeColseVertces a boolean indicating if the imported mesh should be closed
* @param mergeCloseVertices a boolean indicating if close vertices should be merged during import
* @return a boolean indicating if import was successfull
*/
template
<
typename
PFP
>
bool
importMeshV
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportVolumique
::
ImportType
kind
=
ImportVolumique
::
UNKNOWNVOLUME
,
bool
mergeCloseVertices
=
false
);
bool
importMeshV
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
bool
mergeCloseVertices
=
false
);
/**
* import a mesh and extrud it
* @param map the map in which the function imports the mesh
* @param filename
(*.{trian,trianbgz,off,obj,ply})
* @param filename
* @param attrNames attribute names
* @param kind what kind of mesh is the file (if none (-1) determined by filename extension) (cf enum in Mesh2Tables for other kind values)
* @param mergeColseVertces a boolean indicating if the imported mesh should be closed
* @param mergeCloseVertices a boolean indicating if close vertices should be merged during import
* @return a boolean indicating if import was successfull
*/
template
<
typename
PFP
>
bool
importMeshToExtrude
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportSurfacique
::
ImportType
kind
=
ImportSurfacique
::
UNKNOWNSURFACE
);
bool
importMeshToExtrude
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
);
/**
* import a MOKA file
* @param gmap the gmap in which the function imports the mesh
* @param filename
* @param attrNames attribute names
*/
template
<
typename
PFP
>
bool
importMoka
(
typename
PFP
::
MAP
&
gmap
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
);
/*
...
...
@@ -101,6 +107,7 @@ bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vect
}
// namespace CGoGN
#include
"Algo/Import/importMesh.hpp"
#include
"Algo/Import/importMoka.hpp"
//#include "Algo/Import/importObjTex.hpp"
#include
"Algo/Import/importObjEle.hpp"
#include
"Algo/Import/importTet.hpp"
...
...
include/Algo/Import/import2tables.h
View file @
6d2bfd06
...
...
@@ -101,7 +101,7 @@ public:
inline
unsigned
int
getEmbIdx
(
int
i
)
{
return
m_emb
[
i
];
}
bool
importMesh
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportSurfacique
::
ImportType
kind
);
bool
importMesh
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
);
bool
importTrian
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
);
...
...
@@ -184,7 +184,7 @@ public:
inline
unsigned
int
getEmbIdx
(
int
i
)
{
return
m_emb
[
i
];
}
bool
importMesh
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportVolumique
::
ImportType
kind
,
float
scaleFactor
);
bool
importMesh
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
float
scaleFactor
);
bool
importTet
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
float
scaleFactor
);
...
...
include/Algo/Import/import2tablesSurface.hpp
View file @
6d2bfd06
...
...
@@ -80,10 +80,9 @@ ImportSurfacique::ImportType MeshTablesSurface<PFP>::getFileType(const std::stri
}
template
<
typename
PFP
>
bool
MeshTablesSurface
<
PFP
>::
importMesh
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportSurfacique
::
ImportType
kind
)
bool
MeshTablesSurface
<
PFP
>::
importMesh
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
)
{
if
(
kind
==
ImportSurfacique
::
UNKNOWNSURFACE
)
kind
=
getFileType
(
filename
);
ImportSurfacique
::
ImportType
kind
=
getFileType
(
filename
);
attrNames
.
clear
()
;
...
...
include/Algo/Import/import2tablesVolume.hpp
View file @
6d2bfd06
...
...
@@ -47,10 +47,9 @@ ImportVolumique::ImportType MeshTablesVolume<PFP>::getFileType(const std::string
}
template
<
typename
PFP
>
bool
MeshTablesVolume
<
PFP
>::
importMesh
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportVolumique
::
ImportType
kind
,
float
scaleFactor
=
1.0
f
)
bool
MeshTablesVolume
<
PFP
>::
importMesh
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
float
scaleFactor
=
1.0
f
)
{
if
(
kind
==
ImportVolumique
::
UNKNOWNVOLUME
)
kind
=
getFileType
(
filename
);
ImportVolumique
::
ImportType
kind
=
getFileType
(
filename
);
switch
(
kind
)
{
...
...
include/Algo/Import/importMesh.hpp
View file @
6d2bfd06
...
...
@@ -241,18 +241,17 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
{
typedef
typename
PFP
::
VEC3
VEC3
;
AutoAttributeHandler
<
NoMathIONameAttribute
<
std
::
vector
<
Dart
>
>
>
vecDartsPerVertex
(
map
,
VERTEX
,
"incidents"
);
AutoAttributeHandler
<
NoMathIONameAttribute
<
std
::
vector
<
Dart
>
>
>
vecDartsPerVertex
(
map
,
VERTEX
,
"incidents"
);
return
false
;
}
template
<
typename
PFP
>
bool
importMesh
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportSurfacique
::
ImportType
kind
,
bool
mergeCloseVertices
)
bool
importMesh
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
bool
mergeCloseVertices
)
{
MeshTablesSurface
<
PFP
>
mts
(
map
);
if
(
!
mts
.
importMesh
(
filename
,
attrNames
,
kind
))
if
(
!
mts
.
importMesh
(
filename
,
attrNames
))
return
false
;
if
(
mergeCloseVertices
)
...
...
@@ -262,8 +261,19 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector
}
template
<
typename
PFP
>
bool
importMeshV
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportVolumique
::
ImportType
kind
,
bool
mergeCloseVertices
)
bool
importMeshV
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
bool
mergeCloseVertices
)
{
ImportVolumique
::
ImportType
kind
=
ImportVolumique
::
UNKNOWNVOLUME
;
if
((
filename
.
rfind
(
".tet"
)
!=
std
::
string
::
npos
)
||
(
filename
.
rfind
(
".TET"
)
!=
std
::
string
::
npos
))
kind
=
ImportVolumique
::
TET
;
if
((
filename
.
rfind
(
".ele"
)
!=
std
::
string
::
npos
)
||
(
filename
.
rfind
(
".ELE"
)
!=
std
::
string
::
npos
))
kind
=
ImportVolumique
::
ELE
;
if
((
filename
.
rfind
(
".ts"
)
!=
std
::
string
::
npos
)
||
(
filename
.
rfind
(
".TS"
)
!=
std
::
string
::
npos
))
kind
=
ImportVolumique
::
TS
;
switch
(
kind
)
{
case
ImportVolumique
::
TET
:
...
...
@@ -288,20 +298,18 @@ bool importMeshV(typename PFP::MAP& map, const std::string& filename, std::vecto
return
false
;
}
template
<
typename
PFP
>
bool
importMeshToExtrude
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportSurfacique
::
ImportType
kind
)
bool
importMeshToExtrude
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
)
{
float
dist
=
5.0
f
;
MeshTablesSurface
<
PFP
>
mts
(
map
);
if
(
!
mts
.
importMesh
(
filename
,
attrNames
,
kind
))
if
(
!
mts
.
importMesh
(
filename
,
attrNames
))
return
false
;
return
importMeshSToV
<
PFP
>
(
map
,
mts
,
dist
);
}
}
// namespace Import
}
// namespace Algo
...
...
include/Algo/Import/importMoka.hpp
0 → 100644
View file @
6d2bfd06
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
namespace
CGoGN
{
namespace
Algo
{
namespace
Import
{
template
<
typename
PFP
>
bool
importMoka
(
typename
PFP
::
MAP
&
gmap
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
)
{
if
(
gmap
.
mapTypeName
().
compare
(
"GMap3"
)
!=
0
)
{
CGoGNerr
<<
"Unable to load MOKA file "
<<
filename
<<
" : given map is not a 3-GMap"
<<
CGoGNendl
;
return
false
;
}
// open file
igzstream
fp
(
filename
.
c_str
(),
std
::
ios
::
in
|
std
::
ios
::
binary
);
if
(
!
fp
.
good
())
{
CGoGNerr
<<
"Unable to open file "
<<
filename
<<
CGoGNendl
;
return
false
;
}
AttributeHandler
<
typename
PFP
::
VEC3
>
position
=
gmap
.
template
getAttribute
<
typename
PFP
::
VEC3
>(
VERTEX
,
"position"
);
if
(
!
position
.
isValid
())
position
=
gmap
.
template
addAttribute
<
typename
PFP
::
VEC3
>(
VERTEX
,
"position"
);
attrNames
.
push_back
(
position
.
name
());
AttributeContainer
&
vertexContainer
=
gmap
.
getAttributeContainer
(
VERTEX
)
;
std
::
string
ligne
;
std
::
getline
(
fp
,
ligne
);
// check if the file format is in ascii
if
(
ligne
.
compare
(
"Moka file [ascii]"
)
!=
0
)
{
CGoGNerr
<<
"Unable to load this MOKA file "
<<
filename
<<
CGoGNendl
;
return
false
;
}
// ignore 2nd line
std
::
getline
(
fp
,
ligne
);
AttributeHandler
<
Dart
>
att_beta0
=
gmap
.
template
getAttribute
<
Dart
>(
DART
,
"beta0"
);
AttributeHandler
<
Dart
>
att_beta1
=
gmap
.
template
getAttribute
<
Dart
>(
DART
,
"beta1"
);
AttributeHandler
<
Dart
>
att_beta2
=
gmap
.
template
getAttribute
<
Dart
>(
DART
,
"beta2"
);
AttributeHandler
<
Dart
>
att_beta3
=
gmap
.
template
getAttribute
<
Dart
>(
DART
,
"beta3"
);
std
::
map
<
Dart
,
unsigned
int
>
map_dart_emb
;
while
(
!
std
::
getline
(
fp
,
ligne
).
eof
())
{
std
::
stringstream
oss
(
ligne
);
unsigned
int
beta0
,
beta1
,
beta2
,
beta3
;
Dart
d
=
gmap
.
newDart
();
// read involutions
oss
>>
beta0
;
oss
>>
beta1
;
oss
>>
beta2
;
oss
>>
beta3
;
att_beta0
[
d
]
=
beta0
;
att_beta1
[
d
]
=
beta1
;
att_beta2
[
d
]
=
beta2
;
att_beta3
[
d
]
=
beta3
;
// ignore markers
unsigned
int
tmp
;
for
(
unsigned
int
i
=
0
;
i
<
4
;
++
i
)
oss
>>
tmp
;
// check if contains embedding
unsigned
int
emb
;
oss
>>
emb
;
if
(
emb
==
1
)
{
typename
PFP
::
VEC3
pos
;
oss
>>
pos
[
0
];
oss
>>
pos
[
1
];
oss
>>
pos
[
2
];
unsigned
int
id
=
vertexContainer
.
insertLine
();
position
[
id
]
=
pos
;
map_dart_emb
.
insert
(
std
::
pair
<
Dart
,
unsigned
int
>
(
d
,
id
));
}
}
for
(
typename
std
::
map
<
Dart
,
unsigned
int
>::
iterator
it
=
map_dart_emb
.
begin
()
;
it
!=
map_dart_emb
.
end
()
;
++
it
)
gmap
.
embedOrbit
(
VERTEX
,
it
->
first
,
it
->
second
);
gmap
.
closeMap
();
fp
.
close
();
return
true
;
}
}
// namespace Import
}
// namespace Algo
}
// namespace CGoGN
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment