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
David Cazier
CGoGN
Commits
2cb734d8
Commit
2cb734d8
authored
Jan 19, 2012
by
untereiner
Browse files
new Polyhedra creation functions (createPrism, createPyramid, createDiamond)
parent
26eef763
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Apps/Examples/simpleGMap2.cpp
View file @
2cb734d8
...
...
@@ -31,7 +31,7 @@ SimpleGMap2::SimpleGMap2()
{
position
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
"position"
);
Dart
d
=
Algo
::
Modelisation
::
Polyhedron
<
PFP
>::
createTetra
(
myMap
);
Dart
d
=
Algo
::
Modelisation
::
createTetra
hedron
<
PFP
>
(
myMap
);
position
[
d
]
=
VEC3
(
0
,
0
,
0
);
position
[
myMap
.
phi1
(
d
)]
=
VEC3
(
10
,
0
,
15
);
position
[
myMap
.
phi_1
(
d
)]
=
VEC3
(
10
,
20
,
15
);
...
...
Apps/Tuto/tuto3.cpp
View file @
2cb734d8
...
...
@@ -123,7 +123,7 @@ void MyQT::traverseMap()
void
MyQT
::
createMap
()
{
Dart
d1
=
Algo
::
Modelisation
::
Polyhedron
<
PFP
>::
createTetra
(
myMap
);
Dart
d1
=
Algo
::
Modelisation
::
createTetra
hedron
<
PFP
>
(
myMap
);
Dart
d2
=
d1
;
...
...
Apps/Tuto/tuto4.cpp
View file @
2cb734d8
...
...
@@ -126,7 +126,7 @@ void MyQT::traverseMap()
void
MyQT
::
createMap
()
{
Dart
d1
=
Algo
::
Modelisation
::
Poly
hedron
<
PFP
>
::
createHexa
(
myMap
);
Dart
d1
=
Algo
::
Modelisation
::
createHexa
hedron
<
PFP
>
(
myMap
);
Dart
d2
=
d1
;
...
...
include/Algo/ImplicitHierarchicalMesh/ihm3.h
View file @
2cb734d8
...
...
@@ -59,6 +59,8 @@ public:
~
ImplicitHierarchicalMap3
()
;
void
update_topo_shortcuts
();
//!
/*!
*
...
...
include/Algo/ImplicitHierarchicalMesh/ihm3.hpp
View file @
2cb734d8
...
...
@@ -63,6 +63,16 @@ AttributeHandler_IHM<T> ImplicitHierarchicalMap3::getAttribute(unsigned int orbi
return
AttributeHandler_IHM
<
T
>
(
this
,
h
.
getDataVector
())
;
}
inline
void
ImplicitHierarchicalMap3
::
update_topo_shortcuts
()
{
Map3
::
update_topo_shortcuts
();
m_dartLevel
=
Map3
::
getAttribute
<
unsigned
int
>
(
DART
,
"dartLevel"
)
;
m_faceId
=
Map3
::
getAttribute
<
unsigned
int
>
(
DART
,
"faceId"
)
;
m_edgeId
=
Map3
::
getAttribute
<
unsigned
int
>
(
DART
,
"edgeId"
)
;
}
/***************************************************
* MAP TRAVERSAL *
***************************************************/
...
...
include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp
View file @
2cb734d8
This diff is collapsed.
Click to expand it.
include/Algo/Import/import2tables.h
View file @
2cb734d8
...
...
@@ -57,7 +57,7 @@ namespace Import
namespace
ImportVolumique
{
enum
ImportType
{
UNKNOWNVOLUME
,
TET
,
TRIANBGZ
,
PLY
};
enum
ImportType
{
UNKNOWNVOLUME
,
TET
,
TRIANBGZ
,
PLY
,
OFF
,
OBJ
};
}
...
...
include/Algo/Import/importMesh.hpp
View file @
2cb734d8
...
...
@@ -25,6 +25,7 @@
#include
"Topology/generic/attributeHandler.h"
#include
"Topology/generic/autoAttributeHandler.h"
#include
"Container/fakeAttribute.h"
#include
"Algo/Modelisation/polyhedron.h"
namespace
CGoGN
{
...
...
@@ -128,6 +129,111 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
return
true
;
}
template
<
typename
PFP
>
bool
importMeshSToV
(
typename
PFP
::
MAP
&
map
,
MeshTablesSurface
<
PFP
>&
mts
,
float
dist
)
{
AutoAttributeHandler
<
NoMathIONameAttribute
<
std
::
vector
<
Dart
>
>
>
vecDartsPerVertex
(
map
,
VERTEX
,
"incidents"
);
unsigned
nbf
=
mts
.
getNbFaces
();
int
index
=
0
;
// buffer for tempo faces (used to remove degenerated edges)
std
::
vector
<
unsigned
int
>
edgesBuffer
;
edgesBuffer
.
reserve
(
16
);
DartMarkerNoUnmark
m
(
map
)
;
AttributeHandler
<
typename
PFP
::
VEC3
>
position
=
map
.
template
getAttribute
<
typename
PFP
::
VEC3
>(
VERTEX
,
"position"
);
std
::
vector
<
unsigned
int
>
backEdgesBuffer
(
mts
.
getNbVertices
(),
EMBNULL
);
// for each face of table -> create a prism
for
(
unsigned
int
i
=
0
;
i
<
nbf
;
++
i
)
{
// store face in buffer, removing degenerated edges
unsigned
int
nbe
=
mts
.
getNbEdgesFace
(
i
);
edgesBuffer
.
clear
();
unsigned
int
prec
=
EMBNULL
;
for
(
unsigned
int
j
=
0
;
j
<
nbe
;
++
j
)
{
unsigned
int
em
=
mts
.
getEmbIdx
(
index
++
);
if
(
em
!=
prec
)
{
prec
=
em
;
edgesBuffer
.
push_back
(
em
);
}
}
// check first/last vertices
if
(
edgesBuffer
.
front
()
==
edgesBuffer
.
back
())
edgesBuffer
.
pop_back
();
// create only non degenerated faces
nbe
=
edgesBuffer
.
size
();
if
(
nbe
>
2
)
{
Dart
d
=
Algo
::
Modelisation
::
createPrism
<
PFP
>
(
map
,
nbe
);
//Embed the base faces
for
(
unsigned
int
j
=
0
;
j
<
nbe
;
++
j
)
{
unsigned
int
em
=
edgesBuffer
[
j
];
// get embedding
if
(
backEdgesBuffer
[
em
]
==
EMBNULL
)
{
unsigned
int
emn
=
map
.
newCell
(
VERTEX
);
map
.
copyCell
(
VERTEX
,
emn
,
em
);
backEdgesBuffer
[
em
]
=
emn
;
position
[
emn
]
+=
typename
PFP
::
VEC3
(
0
,
0
,
dist
);
}
FunctorSetEmb
<
typename
PFP
::
MAP
>
fsetemb
(
map
,
VERTEX
,
em
);
foreach_dart_of_orbit_in_parent
<
typename
PFP
::
MAP
>
(
&
map
,
VERTEX
,
d
,
fsetemb
)
;
//Embed the other base face
Dart
d2
=
map
.
phi1
(
map
.
phi1
(
map
.
phi2
(
d
)));
unsigned
int
em2
=
backEdgesBuffer
[
em
];
FunctorSetEmb
<
typename
PFP
::
MAP
>
fsetemb2
(
map
,
VERTEX
,
em2
);
foreach_dart_of_orbit_in_parent
<
typename
PFP
::
MAP
>
(
&
map
,
VERTEX
,
d2
,
fsetemb2
)
;
m
.
mark
(
d
)
;
// mark on the fly to unmark on second loop
vecDartsPerVertex
[
em
].
push_back
(
d
);
// store incident darts for fast adjacency reconstruction
d
=
map
.
phi1
(
d
);
}
}
}
// reconstruct neighbourhood
unsigned
int
nbBoundaryEdges
=
0
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
m
.
isMarked
(
d
))
{
// darts incident to end vertex of edge
std
::
vector
<
Dart
>&
vec
=
vecDartsPerVertex
[
map
.
phi1
(
d
)];
unsigned
int
embd
=
map
.
getEmbedding
(
VERTEX
,
d
);
Dart
good_dart
=
NIL
;
for
(
typename
std
::
vector
<
Dart
>::
iterator
it
=
vec
.
begin
();
it
!=
vec
.
end
()
&&
good_dart
==
NIL
;
++
it
)
{
if
(
map
.
getEmbedding
(
VERTEX
,
map
.
phi1
(
*
it
))
==
embd
)
good_dart
=
*
it
;
}
if
(
good_dart
!=
NIL
)
{
map
.
sewVolumes
(
map
.
phi2
(
d
),
map
.
phi2
(
good_dart
),
false
);
m
.
unmarkOrbit
(
EDGE
,
d
);
}
else
{
m
.
unmark
(
d
);
++
nbBoundaryEdges
;
}
}
}
return
true
;
}
template
<
typename
PFP
>
bool
importMesh
(
typename
PFP
::
MAP
&
map
,
MeshTablesVolume
<
PFP
>&
mtv
)
{
...
...
@@ -441,179 +547,40 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector
return
importMesh
<
PFP
>
(
map
,
mts
);
}
/*
template
<
typename
PFP
>
bool
importMesh
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
,
ImportVolumique
::
ImportType
kind
)
{
MeshTablesVolume<PFP> mtv(map)
;
float
dist
=
5.0
f
;
if(!mtv.importMesh(filename, attrNames, kind))
return false;
if
(
kind
==
ImportVolumique
::
OBJ
)
{
MeshTablesSurface
<
PFP
>
mts
(
map
);
return importMesh<PFP>(map, mtv);
}
*/
//
//
//
// AutoAttributeHandler< NoMathIONameAttribute< std::vector<Dart> > > vecDartsPerVertex(map, VERTEX, "incidents");
//
//
// // Attributes container for vertex orbit
// AttributeContainer& vertexContainer = map.getAttributeContainer(VERTEX);
//
// AttributeHandler<VEC3> positions(idPositions,map);
//
// MeshTablesSurface<VEC3> mts(vertexContainer, positions);
//
// if (!mts.importMesh(filename,kind))
// return false;
//
// // marker for phi2 reconstruction
// m = map.getNewMarker();
//
// unsigned nbf = mts.getNbFaces();
// int index = 0;
// // buffer for tempo faces (used to remove degenerated edges)
// std::vector<unsigned int> edgesBuffer;
// edgesBuffer.reserve(8);
//
// // for each face of table
// for(unsigned int i = 0; i < nbf; ++i)
// {
// // store face in buffer, removing degenerated edges
// unsigned int nbe = mts.getNbEdgesFace(i);
// edgesBuffer.clear();
// unsigned int prec=EMBNULL;
// for (unsigned int j=0; j<nbe; ++j)
// {
// unsigned int em = mts.getEmbIdx(index++);
// if (em!=prec)
// {
// prec = em;
// edgesBuffer.push_back(em);
// }
// }
// // check first/last vertices
// if (edgesBuffer.front() == edgesBuffer.back())
// edgesBuffer.pop_back();
//
// // create only non degenerated faces
// nbe = edgesBuffer.size();
// if (nbe >2)
// {
// Dart d = map.newFace(nbe);
// for (unsigned int j=0; j<nbe; ++j)
// {
// unsigned int em = edgesBuffer[j]; // get embedding
// map.setDartEmbedding(VERTEX, d, em); // associate to dart
// vecDartsPerVertex[em].push_back(d); // store incident darts for fast phi2 reconstruction
// d = map.phi1(d);
// }
// map.markOrbit(FACE,d,m);// mark on the fly to unmark on second loop
// }
// }
//
// unsigned nbnm=0;
// // reconstruct neighbourhood
//
// for (Dart d = map.begin(); d != map.end(); map.next(d))
if
(
!
mts
.
importMesh
(
filename
,
attrNames
,
ImportSurfacique
::
OBJ
))
return
false
;
//if (mergeCloseVertices)
// mts.mergeCloseVertices();
return
importMeshSToV
<
PFP
>
(
map
,
mts
,
dist
);
}
else
return
false
;
// else
// {
// if (map.isMarkedDart(d, m))
// {
// // darts incident to end vertex of edge
// std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];
// MeshTablesVolume<PFP> mtv(map);
//
// unsigned int embd = map.getEmbedding(VERTEX, d);
// unsigned int nbf=0;
// Dart good_dart;
// for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end(); ++it)
// {
// if ( map.getEmbedding(VERTEX,map.phi1(*it))==embd)
// {
// good_dart = *it;
// nbf++;
// }
// }
//
// if (nbf==1)
// {
// if (good_dart == map.phi2(good_dart))
// {
// map.sewFaces(d, good_dart);
// map.unmarkOrbit(EDGE, d, m);
// }
// }
// else
// {
// ++nbnm;
// }
// }
// }
//
//
//// return true;
// if(!mtv.importMesh(filename, attrNames, kind))
// return false;
//
// if (nbnm > 0)
// {
// if (closeObject)
// {
// Marker mb = map.closeMap(true);
//// // for all vertices
//// for (unsigned int index = 0; index < vecDartsEmb.size(); ++index)
//// {
//// // if vertex is on boundary
//// if (vecEmbNbFp[index] > 0)
//// {
//// // find first dart that is sewed to boundary
//// std::vector<Dart>& vd = vecDartsEmb[index];
//// typename std::vector<Dart>::iterator jt = vd.begin();
//// while (!map.isMarkedDart(*jt, m))
//// jt++;
//// unsigned int P = map.getEmbedding(VERTEX, *jt);
//// // while vertex if a "non manifold point"
//// while (vecEmbNbFp[index] > 1)
//// {
//// Dart e = map.phi2(*jt);
//// // turn in boundary until we find same embedding
//// do
//// {
//// e = map.phi1(e);
//// // embedding of boundary darts on the fly
//// unsigned int emb = map.getEmbedding(VERTEX, map.phi1(map.phi2(e)));
//// map.setDartEmbedding(VERTEX, e, emb);
//// } while (map.getEmbedding(VERTEX, map.phi2(e)) != P);
//// // separate the face
//// map.phi1sew(map.phi2(*jt), e);
//// vecEmbNbFp[index]--;
//// }
//// // copy embedding of vertex of boundary of last face
//// Dart e = map.phi2(*jt);
//// Dart d = e;
//// if (map.getEmbedding(VERTEX, d) == EMBNULL)
//// {
//// do
//// {
//// unsigned int emb = map.getEmbedding(VERTEX, map.phi1(map.phi2(d)));
//// map.setDartEmbedding(VERTEX, d, emb);
//// d = map.phi1(d);
//// } while (d != e);
//// }
//// }
//// }
// map.unmarkAll(m);
// map.releaseMarker(m);
// m = mb;
// }
// else
// {
// CGoGNout << "Warning " << nbnm << " darts with phi2 fix points" << CGoGNendl;
// }
// return importMesh<PFP>(map, mtv);
// }
//
// return true;
//}
}
}
// namespace Import
...
...
include/Algo/Import/importTet.hpp
View file @
2cb734d8
...
...
@@ -114,7 +114,7 @@ bool importTet(typename PFP::MAP& map, const std::string& filename, std::vector<
oss
>>
nbe
;
//number of vertices = 4
assert
(
nbe
==
4
);
Dart
d
=
Algo
::
Modelisation
::
Polyhedron
<
PFP
>::
create
Poly
hedron
(
map
,
4
);
Dart
d
=
Algo
::
Modelisation
::
create
Tetra
hedron
<
PFP
>
(
map
);
Geom
::
Vec4ui
pt
;
oss
>>
pt
[
0
];
...
...
include/Algo/Import/importTs.hpp
View file @
2cb734d8
...
...
@@ -132,7 +132,7 @@ bool importTs(typename PFP::MAP& map, const std::string& filename, std::vector<s
// CGoGNout << "tetra number : " << nbe << CGoGNendl;
//Algo::Modelisation::Polyhedron<PFP>::createTetra(map);
Dart
d
=
Algo
::
Modelisation
::
Polyhedron
<
PFP
>::
create
Poly
hedron
(
map
,
4
);
Dart
d
=
Algo
::
Modelisation
::
create
Tetra
hedron
<
PFP
>
(
map
);
Geom
::
Vec4ui
pt
;
oss
>>
pt
[
0
];
oss
>>
pt
[
1
];
...
...
include/Algo/Modelisation/polyhedron.h
View file @
2cb734d8
...
...
@@ -42,7 +42,7 @@ namespace Algo
namespace
Modelisation
{
enum
{
NONE
,
GRID
,
CUBE
,
CYLINDER
,
CONE
,
SPHERE
,
TORE
,
COMPOSED
};
enum
{
NONE
,
GRID
,
CUBE
,
CYLINDER
,
CONE
,
SPHERE
,
TORE
,
COMPOSED
};
/**
* sudivide the all quads of primtive into 2 triangles
...
...
@@ -70,6 +70,64 @@ enum { NONE,GRID, CUBE, CYLINDER, CONE, SPHERE, TORE, COMPOSED };
template
<
typename
PFP
>
void
explodPolyhedron
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
typename
PFP
::
TVEC3
position
);
/**
* create a n-sided pyramid
*/
template
<
typename
PFP
>
Dart
createPyramid
(
typename
PFP
::
MAP
&
map
,
unsigned
int
nbSides
);
/**
* create a n-sided prism
*/
template
<
typename
PFP
>
Dart
createPrism
(
typename
PFP
::
MAP
&
map
,
unsigned
int
nbSides
);
/**
* create a n-sided diamond
*/
template
<
typename
PFP
>
Dart
createDiamond
(
typename
PFP
::
MAP
&
map
,
unsigned
int
nbSides
);
/**
* create a tetrahedron
*/
template
<
typename
PFP
>
Dart
createTetrahedron
(
typename
PFP
::
MAP
&
map
);
/**
* create a hexahedron
*/
template
<
typename
PFP
>
Dart
createHexahedron
(
typename
PFP
::
MAP
&
map
);
/**
* create a 3-sided prism
*/
template
<
typename
PFP
>
Dart
createTriangularPrism
(
typename
PFP
::
MAP
&
map
);
/**
* create a 3-sided pyramid
*/
template
<
typename
PFP
>
Dart
createQuadrangularPyramid
(
typename
PFP
::
MAP
&
map
);
/**
* create 4-sided diamond (i.e. an octahedron)
*/
template
<
typename
PFP
>
Dart
createOctahedron
(
typename
PFP
::
MAP
&
map
);
/**
* class of geometric Polyhedron
* It alloaw the creation of:
...
...
@@ -82,7 +140,6 @@ void explodPolyhedron(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 positi
*
* Topological creation methods are separated from embedding to
* easily allow specific embedding.
*/
template
<
typename
PFP
>
class
Polyhedron
...
...
@@ -167,30 +224,6 @@ public:
*/
Polyhedron
(
const
Polyhedron
<
PFP
>&
p1
,
const
Polyhedron
<
PFP
>&
p2
);
/**
* create simple simple polyhedron (not handled by Polyhedron object)
*/
static
Dart
createPolyhedron
(
typename
PFP
::
MAP
&
the_map
,
unsigned
int
nbFaces
);
/**
* create simple simple tetrahedron (not handled by Polyhedron object)
*/
static
Dart
createTetra
(
typename
PFP
::
MAP
&
the_map
);
/**
* create simple simple pyramid (not handled by Polyhedron object)
*/
static
Dart
createPyra
(
typename
PFP
::
MAP
&
the_map
);
/**
* create simple simple hexaedron (not handled by Polyhedron object)
*/
static
Dart
createHexa
(
typename
PFP
::
MAP
&
the_map
);
/**
* create simple simple prism (not handled by Polyhedron object)
*/
static
Dart
createPrism
(
typename
PFP
::
MAP
&
the_map
);
/*
* get the reference dart
...
...
include/Algo/Modelisation/polyhedron.hpp
View file @
2cb734d8
...
...
@@ -31,6 +31,170 @@ namespace Algo
namespace
Modelisation
{
/**
* create a n-sided pyramid
*/
template
<
typename
PFP
>
Dart
createPyramid
(
typename
PFP
::
MAP
&
map
,
unsigned
int
n
)
{
Dart
dres
=
Dart
::
nil
();
std
::
vector
<
Dart
>
m_tableVertDarts
;
m_tableVertDarts
.
reserve
(
n
);
// creation of triangles around circunference and storing vertices
for
(
unsigned
int
i
=
0
;
i
<
n
;
++
i
)
{
Dart
d
=
map
.
newFace
(
3
,
false
);
m_tableVertDarts
.
push_back
(
d
);
}
// sewing the triangles
for
(
unsigned
int
i
=
0
;
i
<
n
-
1
;
++
i
)
{
Dart
d
=
m_tableVertDarts
[
i
];
d
=
map
.
phi_1
(
d
);
Dart
e
=
m_tableVertDarts
[
i
+
1
];
e
=
map
.
phi1
(
e
);
map
.
sewFaces
(
d
,
e
,
false
);
}
//sewing the last with the first
map
.
sewFaces
(
map
.
phi1
(
m_tableVertDarts
[
0
]),
map
.
phi_1
(
m_tableVertDarts
[
n
-
1
]),
false
);
//sewing the bottom face
Dart
d1
=
map
.
newFace
(
n
,
false
);
dres
=
d1
;
for
(
unsigned
int
i
=
0
;
i
<
n
;
++
i
)
{
map
.
sewFaces
(
m_tableVertDarts
[
i
],
d1
,
false
);
d1
=
map
.
phi1
(
d1
);
}
//return a dart from the base
return
dres
;
}
/**
* create a n-sided prism
*/
template
<
typename
PFP
>
Dart
createPrism
(
typename
PFP
::
MAP
&
map
,
unsigned
int
n
)
{
Dart
dres
=
Dart
::
nil
();
unsigned
int
nb
=
n
*
2
;
std
::
vector
<
Dart
>
m_tableVertDarts
;
m_tableVertDarts
.
reserve
(
nb
);
// creation of quads around circunference and storing vertices
for
(
unsigned
int
i
=
0
;
i
<
n
;
++
i
)
{
Dart
d
=
map
.
newFace
(
4
,
false
);
m_tableVertDarts
.
push_back
(
d
);
}
// storing a dart from the vertex pointed by phi1(phi1(d))
for
(
unsigned
int
i
=
0
;
i
<
n
;
++
i
)
{
m_tableVertDarts
.
push_back
(
map
.
phi1
(
map
.
phi1
(
m_tableVertDarts
[
i
])));
}
// sewing the quads
for
(
unsigned
int
i
=
0
;
i
<
n
-
1
;
++
i
)
{
Dart
d
=
m_tableVertDarts
[
i
];
d
=
map
.
phi_1
(
d
);
Dart
e
=
m_tableVertDarts
[
i
+
1
];
e
=
map
.
phi1
(
e
);
map
.
sewFaces
(
d
,
e
,
false
);
}
//sewing the last with the first
map
.
sewFaces
(
map
.
phi1
(
m_tableVertDarts
[
0
]),
map
.
phi_1
(
m_tableVertDarts
[
n
-
1
]),
false
);
//sewing the top & bottom faces
Dart
d1
=
map
.
newFace
(
n
,
false
);
Dart
d2
=
map
.
newFace
(
n
,
false
);
dres
=
d1
;
for
(
unsigned
int
i
=
0
;
i
<
n
;
++
i
)
{
map
.
sewFaces
(
m_tableVertDarts
[
i
],
d1
,
false
);