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
a3be313e
Commit
a3be313e
authored
May 20, 2014
by
Pierre Kraemer
Browse files
Merge branch 'develop' of cgogn:~thery/CGoGNMR into develop
parents
8259ea87
b9dbea54
Changes
27
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/Modelling/basics.cpp
View file @
a3be313e
...
...
@@ -47,81 +47,6 @@ typedef PFP::MAP::IMPL MAP_IMPL ; // map implementation
typedef
PFP
::
VEC3
VEC3
;
// type of R³ vector
// example of cell marking with CellMarker for a simple traversal
template
<
unsigned
int
ORBIT
>
void
simpleTraversal
(
MAP
&
map
)
// NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
CellMarker
<
MAP
,
ORBIT
>
cm
(
map
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
cm
.
isMarked
(
d
))
// is the cell (of dart d) not marked ?
{
std
::
cout
<<
orbitName
(
ORBIT
)
<<
" of dart "
<<
d
<<
std
::
endl
;
cm
.
mark
(
d
);
// mark the cell
}
}
std
::
cout
<<
std
::
endl
;
// all cells are unmarked automatically during the destruction of the CellMarker
}
// example of cell marking with CellMarkerNoUnmark for a double traversal
template
<
unsigned
int
ORBIT
>
void
doubleTraversal
(
MAP
&
map
)
// NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
CellMarkerNoUnmark
<
MAP
,
ORBIT
>
cm
(
map
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
cm
.
isMarked
(
d
))
// is the cell (of dart d) not marked ?
{
std
::
cout
<<
"First Pass"
<<
orbitName
(
ORBIT
)
<<
" of dart "
<<
d
<<
std
::
endl
;
cm
.
mark
(
d
);
// mark the cell
}
}
std
::
cout
<<
std
::
endl
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
cm
.
isMarked
(
d
))
// is the cell (of dart d) marked ?
{
std
::
cout
<<
"second Pass"
<<
orbitName
(
ORBIT
)
<<
" of dart "
<<
d
<<
std
::
endl
;
cm
.
unmark
(
d
);
// unmark the cell
}
}
std
::
cout
<<
std
::
endl
;
// destructor does not clean the markers
// user MUST ensure that he has unmark all he has marked
}
// example of usage of CellMarkerStore
void
negativePositions
(
MAP
&
map
,
VertexAttribute
<
VEC3
,
MAP_IMPL
>&
position
)
// NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
// if user knows that small numbers of cell will be marked
// it is more efficient to store them instead of traverse
// all darts for cleanning. CellMarkerStore do it for you.
CellMarkerStore
<
MAP
,
VERTEX
>
cms
(
map
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
cms
.
isMarked
(
d
)
&&
(
position
[
d
][
0
]
<=
0.0
)
&&
(
position
[
d
][
1
]
<=
0.0
))
{
std
::
cout
<<
"position["
<<
d
<<
"] < (0,0)"
<<
std
::
endl
;
cms
.
mark
(
d
);
}
}
std
::
cout
<<
std
::
endl
;
}
int
main
()
{
// declare a map to handle the mesh
...
...
@@ -149,6 +74,5 @@ int main()
position
[
myMap
.
phi
<
11
>
(
f2
.
dart
)]
=
VEC3
(
0
,
-
2
,
0
);
position
[
myMap
.
phi_1
(
f2
.
dart
)]
=
VEC3
(
2
,
-
2
,
0
);
return
0
;
}
Apps/Tuto/tuto_subdivision.cpp
View file @
a3be313e
...
...
@@ -33,6 +33,7 @@
#include
"Algo/Export/export.h"
#include
"Algo/Modelisation/subdivision.h"
#include
"Algo/Geometry/normal.h"
using
namespace
CGoGN
;
...
...
@@ -50,19 +51,20 @@ typedef PFP::MAP MAP ;
typedef
PFP
::
MAP
::
IMPL
MAP_IMPL
;
typedef
PFP
::
VEC3
VEC3
;
void
pipo
(
PFP
::
MAP
&
m
)
{
std
::
cout
<<
m
.
getNbDarts
()
<<
std
::
endl
;
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
3
)
{
CGoGN
out
<<
"Usage : "
<<
argv
[
0
]
<<
" filename nbSteps"
<<
CGoGNendl
;
return
0
;
CGoGN
err
<<
"Usage : "
<<
argv
[
0
]
<<
" filename nbSteps"
<<
CGoGNendl
;
return
1
;
}
std
::
string
filename
(
argv
[
1
]);
unsigned
int
nbSteps
;
std
::
istringstream
iss
(
argv
[
2
]);
iss
>>
nbSteps
;
unsigned
int
nbSteps
=
atoi
(
argv
[
2
]);
// declaration of the map
MAP
myMap
;
...
...
@@ -70,13 +72,32 @@ int main(int argc, char **argv)
std
::
vector
<
std
::
string
>
attrNames
;
Algo
::
Surface
::
Import
::
importMesh
<
PFP
>
(
myMap
,
argv
[
1
],
attrNames
);
// get a handler to the 3D vector attribute created by the import
// get a handler to the 3D vector attribute created by the import
(position always the first)
VertexAttribute
<
VEC3
,
MAP_IMPL
>
position
=
myMap
.
getAttribute
<
VEC3
,
VERTEX
>
(
attrNames
[
0
]);
// a second map
MAP
myMap2
;
// for copying the initial mesh
myMap2
.
copyFrom
(
myMap
);
// AttributeHandler are linked to the map, need a new one
VertexAttribute
<
VEC3
,
MAP_IMPL
>
position2
=
myMap2
.
getAttribute
<
VEC3
,
VERTEX
>
(
attrNames
[
0
]);
// subdivide first map with Loop algo
for
(
unsigned
int
i
=
0
;
i
<
nbSteps
;
++
i
)
Algo
::
Surface
::
Modelisation
::
LoopSubdivision
<
PFP
>
(
myMap
,
position
);
Algo
::
Surface
::
Export
::
exportOFF
<
PFP
>
(
myMap
,
position
,
"result.off"
);
// and export to file
Algo
::
Surface
::
Export
::
exportOFF
<
PFP
>
(
myMap
,
position
,
"resultLoop.off"
);
// subdivide second map with CatmullClark (using map2/position2)
for
(
unsigned
int
i
=
0
;
i
<
nbSteps
;
++
i
)
Algo
::
Surface
::
Modelisation
::
CatmullClarkSubdivision
<
PFP
>
(
myMap2
,
position2
);
// and export to file (using map2/position2)
Algo
::
Surface
::
Export
::
exportOFF
<
PFP
>
(
myMap2
,
position2
,
"resultCC.off"
);
return
0
;
}
include/Container/attributeContainer.h
View file @
a3be313e
...
...
@@ -138,7 +138,8 @@ public:
~
AttributeContainer
();
unsigned
int
getOrbit
();
unsigned
int
getOrbit
()
const
;
void
setOrbit
(
unsigned
int
orbit
);
void
setRegistry
(
std
::
map
<
std
::
string
,
RegisteredBaseAttribute
*>*
re
);
...
...
@@ -273,7 +274,7 @@ public:
/**
* get the name of an attribute, given its index in the container
*/
const
std
::
string
&
getAttributeName
(
unsigned
int
attrIndex
);
const
std
::
string
&
getAttributeName
(
unsigned
int
attrIndex
)
const
;
/**
* fill a vector with pointers to the blocks of the given attribute
...
...
@@ -290,7 +291,7 @@ public:
* @param names vector of names
* @return number of attributes
*/
unsigned
int
getAttributesNames
(
std
::
vector
<
std
::
string
>&
names
);
unsigned
int
getAttributesNames
(
std
::
vector
<
std
::
string
>&
names
)
const
;
/**
* fill a vector with attribute type names
...
...
@@ -364,7 +365,7 @@ public:
* @param index index of the line
* @return number of refs of the line
*/
unsigned
int
getNbRefs
(
unsigned
int
index
);
unsigned
int
getNbRefs
(
unsigned
int
index
)
const
;
/**
* set the number of refs of the given line
...
...
@@ -473,6 +474,14 @@ public:
*/
void
copyFrom
(
const
AttributeContainer
&
cont
);
/**
* dump the container in CSV format (; separated columns)
*/
void
dumpCSV
()
const
;
void
dumpByLines
()
const
;
};
}
// namespace CGoGN
...
...
include/Container/attributeContainer.hpp
View file @
a3be313e
...
...
@@ -30,7 +30,7 @@
namespace
CGoGN
{
inline
unsigned
int
AttributeContainer
::
getOrbit
()
inline
unsigned
int
AttributeContainer
::
getOrbit
()
const
{
return
m_orbit
;
}
...
...
@@ -332,7 +332,7 @@ inline bool AttributeContainer::unrefLine(unsigned int index)
return
false
;
}
inline
unsigned
int
AttributeContainer
::
getNbRefs
(
unsigned
int
index
)
inline
unsigned
int
AttributeContainer
::
getNbRefs
(
unsigned
int
index
)
const
{
unsigned
int
bi
=
index
/
_BLOCKSIZE_
;
unsigned
int
j
=
index
%
_BLOCKSIZE_
;
...
...
include/Container/attributeMultiVector.h
View file @
a3be313e
...
...
@@ -176,6 +176,12 @@ public:
virtual
bool
loadBin
(
CGoGNistream
&
fs
)
=
0
;
static
bool
skipLoadBin
(
CGoGNistream
&
fs
);
/**
* lecture binaire
* @param fs filestream
*/
virtual
void
dump
(
unsigned
int
i
)
const
=
0
;
};
...
...
@@ -266,17 +272,17 @@ public:
* ARITHMETIC OPERATIONS *
**************************************/
void
affect
(
unsigned
int
i
,
unsigned
int
j
);
//
void affect(unsigned int i, unsigned int j);
void
add
(
unsigned
int
i
,
unsigned
int
j
);
//
void add(unsigned int i, unsigned int j);
void
sub
(
unsigned
int
i
,
unsigned
int
j
);
//
void sub(unsigned int i, unsigned int j);
void
mult
(
unsigned
int
i
,
double
alpha
);
//
void mult(unsigned int i, double alpha);
void
div
(
unsigned
int
i
,
double
alpha
);
//
void div(unsigned int i, double alpha);
void
lerp
(
unsigned
res
,
unsigned
int
i
,
unsigned
int
j
,
double
alpha
);
//
void lerp(unsigned res, unsigned int i, unsigned int j, double alpha);
/**************************************
* SAVE & LOAD *
...
...
@@ -294,6 +300,13 @@ public:
* @param fs filestream
*/
bool
loadBin
(
CGoGNistream
&
fs
);
/**
* lecture binaire
* @param fs filestream
*/
virtual
void
dump
(
unsigned
int
i
)
const
;
};
}
// namespace CGoGN
...
...
include/Container/attributeMultiVector.hpp
View file @
a3be313e
...
...
@@ -407,4 +407,11 @@ inline bool AttributeMultiVectorGen::skipLoadBin(CGoGNistream& fs)
return
true
;
}
template
<
typename
T
>
void
AttributeMultiVector
<
T
>::
dump
(
unsigned
int
i
)
const
{
CGoGNout
<<
this
->
operator
[](
i
);
}
}
// namespace CGoGN
include/Container/fakeAttribute.h
View file @
a3be313e
...
...
@@ -48,6 +48,13 @@ public:
static
std
::
string
CGoGNnameOfType
()
{
return
""
;
}
};
template
<
typename
T
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
NoTypeNameAttribute
<
T
>&
)
{
out
<<
"no_output"
;
return
out
;
}
}
// namespace CGoGN
#endif
/* FAKEATTRIBUTE_H_ */
include/Topology/generic/genericmap.h
View file @
a3be313e
...
...
@@ -87,6 +87,9 @@ class GenericMap
template
<
typename
MAP
,
unsigned
int
CELL
>
friend
class
CellMarkerBase
;
protected:
// protected copy constructor to prevent the copy of map
GenericMap
(
const
GenericMap
&
)
{}
/**
* Attributes Containers
*/
...
...
@@ -124,7 +127,7 @@ protected:
*/
Mark
m_boundaryMarkers
[
2
]
;
// 0 for dim 2 / 1 for dim 3
unsigned
int
m_nbThreads
;
unsigned
int
m_nbThread
Marker
s
;
/**
* Store links to created AttributeHandlers, DartMarkers and CellMarkers
...
...
@@ -358,7 +361,7 @@ public:
* return allowed threads
* @return the number of threads (including principal)
*/
unsigned
int
getNbThreadMarkers
()
;
unsigned
int
getNbThreadMarkers
()
const
;
/**
* Remove some added threads
...
...
@@ -411,6 +414,11 @@ public:
* compact the map
*/
void
compact
()
;
/**
* @brief dump all attributes of map in CSV format (; separated columns)
*/
void
dumpCSV
()
const
;
}
;
...
...
include/Topology/generic/genericmap.hpp
View file @
a3be313e
...
...
@@ -49,7 +49,7 @@ inline void GenericMap::deleteDartLine(unsigned int index)
{
m_attribs
[
DART
].
removeLine
(
index
)
;
// free the dart line
for
(
unsigned
int
t
=
0
;
t
<
m_nbThreads
;
++
t
)
// clear markers of
for
(
unsigned
int
t
=
0
;
t
<
m_nbThread
Marker
s
;
++
t
)
// clear markers of
(
*
m_markTables
[
DART
][
t
])[
index
].
clear
()
;
// the removed dart
for
(
unsigned
int
orbit
=
0
;
orbit
<
NB_ORBITS
;
++
orbit
)
...
...
@@ -61,7 +61,7 @@ inline void GenericMap::deleteDartLine(unsigned int index)
{
if
(
m_attribs
[
orbit
].
unrefLine
(
emb
))
// unref the pointed embedding line
{
for
(
unsigned
int
t
=
0
;
t
<
m_nbThreads
;
++
t
)
// and clear its markers if it was
for
(
unsigned
int
t
=
0
;
t
<
m_nbThread
Marker
s
;
++
t
)
// and clear its markers if it was
(
*
m_markTables
[
orbit
][
t
])[
emb
].
clear
()
;
// its last unref (and was thus freed)
}
}
...
...
include/Topology/generic/mapCommon.h
View file @
a3be313e
...
...
@@ -36,6 +36,12 @@ class MapCommon : public MAP_IMPL
{
typedef
MAP_IMPL
IMPL
;
protected:
// protected copy constructor to prevent the copy of map
MapCommon
(
const
MapCommon
<
MAP_IMPL
>&
m
)
:
MAP_IMPL
(
m
)
{}
public:
MapCommon
()
{}
/****************************************
* DARTS TRAVERSALS *
****************************************/
...
...
@@ -127,7 +133,10 @@ public:
/****************************************
* BOUNDARY MANAGEMENT *
****************************************/
protected:
/**
* mark a dart as belonging to boundary
*/
...
...
include/Topology/generic/mapCommon.hpp
View file @
a3be313e
...
...
@@ -85,7 +85,7 @@ void MapCommon<MAP_IMPL>::setDartEmbedding(Dart d, unsigned int emb)
{
if
(
this
->
m_attribs
[
ORBIT
].
unrefLine
(
old
))
// then unref the old emb
{
for
(
unsigned
int
t
=
0
;
t
<
this
->
m_nbThreads
;
++
t
)
// clear the markers if it was the
for
(
unsigned
int
t
=
0
;
t
<
this
->
m_nbThread
Marker
s
;
++
t
)
// clear the markers if it was the
(
*
this
->
m_markTables
[
ORBIT
][
t
])[
old
].
clear
();
// last unref of the line
}
}
...
...
include/Topology/generic/mapImpl/mapMono.h
View file @
a3be313e
...
...
@@ -42,6 +42,9 @@ public:
inline
virtual
void
clear
(
bool
removeAttrib
);
protected:
// protected copy constructor to prevent the copy of map
MapMono
(
const
MapMono
&
m
)
:
GenericMap
(
m
){}
std
::
vector
<
AttributeMultiVector
<
Dart
>*>
m_involution
;
std
::
vector
<
AttributeMultiVector
<
Dart
>*>
m_permutation
;
std
::
vector
<
AttributeMultiVector
<
Dart
>*>
m_permutation_inv
;
...
...
include/Topology/generic/mapImpl/mapMulti.h
View file @
a3be313e
...
...
@@ -44,6 +44,9 @@ public:
inline
virtual
void
clear
(
bool
removeAttrib
);
protected:
// protected copy constructor to prevent the copy of map
MapMulti
(
const
MapMulti
&
m
)
:
GenericMap
(
m
)
{}
std
::
vector
<
AttributeMultiVector
<
Dart
>*>
m_involution
;
std
::
vector
<
AttributeMultiVector
<
Dart
>*>
m_permutation
;
std
::
vector
<
AttributeMultiVector
<
Dart
>*>
m_permutation_inv
;
...
...
include/Topology/gmap/embeddedGMap2.h
View file @
a3be313e
...
...
@@ -37,12 +37,15 @@ namespace CGoGN
*/
class
EmbeddedGMap2
:
public
GMap2
<
MapMono
>
{
EmbeddedGMap2
(
const
EmbeddedGMap2
&
m
)
:
GMap2
<
MapMono
>
(
m
)
{}
public:
typedef
MapMono
IMPL
;
typedef
GMap2
<
MapMono
>
TOPO_MAP
;
static
const
unsigned
int
DIMENSION
=
TOPO_MAP
::
DIMENSION
;
EmbeddedGMap2
()
{}
/**
* create a new face with managed embeddings
*/
...
...
include/Topology/gmap/embeddedGMap3.h
View file @
a3be313e
...
...
@@ -37,12 +37,15 @@ namespace CGoGN
*/
class
EmbeddedGMap3
:
public
GMap3
<
MapMono
>
{
EmbeddedGMap3
(
const
EmbeddedGMap3
&
m
)
:
GMap3
<
MapMono
>
(
m
)
{}
public:
typedef
MapMono
IMPL
;
typedef
GMap3
<
MapMono
>
TOPO_MAP
;
static
const
unsigned
int
DIMENSION
=
TOPO_MAP
::
DIMENSION
;
EmbeddedGMap3
()
{}
/*!
*
*/
...
...
include/Topology/gmap/gmap0.h
View file @
a3be313e
...
...
@@ -40,6 +40,9 @@ template <typename MAP_IMPL>
class
GMap0
:
public
MapCommon
<
MAP_IMPL
>
{
protected:
// protected copy constructor to prevent the copy of map
GMap0
(
const
GMap0
<
MAP_IMPL
>&
m
)
:
MapCommon
<
MAP_IMPL
>
(
m
)
{}
void
init
()
;
public:
...
...
include/Topology/gmap/gmap1.h
View file @
a3be313e
...
...
@@ -37,6 +37,9 @@ template <typename MAP_IMPL>
class
GMap1
:
public
GMap0
<
MAP_IMPL
>
{
protected:
// protected copy constructor to prevent the copy of map
GMap1
(
const
GMap1
<
MAP_IMPL
>&
m
)
:
GMap0
<
MAP_IMPL
>
(
m
)
{}
void
init
()
;
public:
...
...
include/Topology/gmap/gmap2.h
View file @
a3be313e
...
...
@@ -37,6 +37,9 @@ template <typename MAP_IMPL>
class
GMap2
:
public
GMap1
<
MAP_IMPL
>
{
protected:
// protected copy constructor to prevent the copy of map
GMap2
(
const
GMap2
<
MAP_IMPL
>&
m
)
:
GMap1
<
MAP_IMPL
>
(
m
)
{}
void
init
()
;
public:
...
...
include/Topology/gmap/gmap3.h
View file @
a3be313e
...
...
@@ -37,6 +37,9 @@ template <typename MAP_IMPL>
class
GMap3
:
public
GMap2
<
MAP_IMPL
>
{
protected:
// protected copy constructor to prevent the copy of map
GMap3
(
const
GMap3
<
MAP_IMPL
>&
m
)
:
GMap2
<
MAP_IMPL
>
(
m
)
{}
void
init
()
;
public:
...
...
include/Topology/map/embeddedMap2.h
View file @
a3be313e
...
...
@@ -37,12 +37,16 @@ namespace CGoGN
*/
class
EmbeddedMap2
:
public
Map2
<
MapMono
>
{
EmbeddedMap2
(
const
EmbeddedMap2
&
m
)
:
Map2
<
MapMono
>
(
m
)
{}
public:
typedef
MapMono
IMPL
;
typedef
Map2
<
MapMono
>
TOPO_MAP
;
static
const
unsigned
int
DIMENSION
=
TOPO_MAP
::
DIMENSION
;
EmbeddedMap2
()
{}
/*
*/
Dart
newPolyLine
(
unsigned
int
nbEdges
)
;
...
...
Prev
1
2
Next
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