Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CGoGN
CGoGN
Commits
51620456
Commit
51620456
authored
Sep 09, 2011
by
untereiner
Browse files
Options
Browse Files
Download
Plain Diff
Merge cgogn:~cgogn/CGoGN
parents
22a1e9b7
c0fb7beb
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
907 additions
and
291 deletions
+907
-291
include/Algo/Geometry/area.h
include/Algo/Geometry/area.h
+14
-2
include/Algo/Geometry/area.hpp
include/Algo/Geometry/area.hpp
+55
-1
include/Algo/Geometry/laplacian.h
include/Algo/Geometry/laplacian.h
+34
-11
include/Algo/Geometry/laplacian.hpp
include/Algo/Geometry/laplacian.hpp
+92
-26
include/Algo/Geometry/normal.hpp
include/Algo/Geometry/normal.hpp
+5
-7
include/Algo/Import/import2tables.h
include/Algo/Import/import2tables.h
+5
-5
include/Algo/Import/import2tablesSurface.hpp
include/Algo/Import/import2tablesSurface.hpp
+1
-1
include/Algo/LinearSolving/basic.h
include/Algo/LinearSolving/basic.h
+155
-145
include/Algo/LinearSolving/matrixSetup.h
include/Algo/LinearSolving/matrixSetup.h
+308
-32
include/Algo/LinearSolving/variablesSetup.h
include/Algo/LinearSolving/variablesSetup.h
+152
-0
include/Topology/generic/attribmap.h
include/Topology/generic/attribmap.h
+0
-1
include/Topology/generic/attribmap.hpp
include/Topology/generic/attribmap.hpp
+1
-0
include/Topology/generic/attributeHandler.h
include/Topology/generic/attributeHandler.h
+18
-15
include/Topology/generic/attributeHandler.hpp
include/Topology/generic/attributeHandler.hpp
+61
-43
include/Topology/generic/autoAttributeHandler.h
include/Topology/generic/autoAttributeHandler.h
+3
-1
src/Topology/generic/genericmap.cpp
src/Topology/generic/genericmap.cpp
+1
-0
src/Utils/Shaders/shaderSimpleColor.cpp
src/Utils/Shaders/shaderSimpleColor.cpp
+2
-1
No files found.
include/Algo/Geometry/area.h
View file @
51620456
...
...
@@ -35,17 +35,29 @@ namespace Geometry
{
template
<
typename
PFP
>
typename
PFP
::
REAL
triangleArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
);
typename
PFP
::
REAL
triangleArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
;
template
<
typename
PFP
>
typename
PFP
::
REAL
convexFaceArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
);
typename
PFP
::
REAL
convexFaceArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
;
template
<
typename
PFP
>
typename
PFP
::
REAL
totalArea
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
select
=
SelectorTrue
(),
unsigned
int
th
=
0
)
;
template
<
typename
PFP
>
typename
PFP
::
REAL
vertexOneRingArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
;
template
<
typename
PFP
>
typename
PFP
::
REAL
vertexVoronoiArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
;
template
<
typename
PFP
>
void
computeAreaFaces
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TREAL
&
face_area
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
template
<
typename
PFP
>
void
computeOneRingAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TREAL
&
vertex_area
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
template
<
typename
PFP
>
void
computeVoronoiAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TREAL
&
vertex_area
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
}
// namespace Geometry
}
// namespace Algo
...
...
include/Algo/Geometry/area.hpp
View file @
51620456
...
...
@@ -70,7 +70,7 @@ typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const typename
template
<
typename
PFP
>
typename
PFP
::
REAL
totalArea
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
select
,
unsigned
int
th
)
{
float
area
=
0.0
f
;
typename
PFP
::
REAL
area
(
0
)
;
DartMarker
mark
(
map
,
th
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
...
...
@@ -83,6 +83,32 @@ typename PFP::REAL totalArea(typename PFP::MAP& map, const typename PFP::TVEC3&
return
area
;
}
template
<
typename
PFP
>
typename
PFP
::
REAL
vertexOneRingArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
{
typename
PFP
::
REAL
area
(
0
)
;
Dart
it
=
d
;
do
{
area
+=
convexFaceArea
<
PFP
>
(
map
,
it
,
position
)
;
it
=
map
.
alpha1
(
it
)
;
}
while
(
it
!=
d
)
;
return
area
;
}
template
<
typename
PFP
>
typename
PFP
::
REAL
vertexVoronoiArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
{
typename
PFP
::
REAL
area
(
0
)
;
Dart
it
=
d
;
do
{
area
+=
convexFaceArea
<
PFP
>
(
map
,
it
,
position
)
/
3
;
it
=
map
.
alpha1
(
it
)
;
}
while
(
it
!=
d
)
;
return
area
;
}
template
<
typename
PFP
>
void
computeAreaFaces
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TREAL
&
face_area
,
const
FunctorSelect
&
select
)
{
...
...
@@ -97,6 +123,34 @@ void computeAreaFaces(typename PFP::MAP& map, const typename PFP::TVEC3& positio
}
}
template
<
typename
PFP
>
void
computeOneRingAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TREAL
&
vertex_area
,
const
FunctorSelect
&
select
)
{
CellMarker
marker
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
marker
.
isMarked
(
d
))
{
marker
.
mark
(
d
);
vertex_area
[
d
]
=
vertexOneRingArea
<
PFP
>
(
map
,
d
,
position
)
;
}
}
}
template
<
typename
PFP
>
void
computeVoronoiAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TREAL
&
vertex_area
,
const
FunctorSelect
&
select
)
{
CellMarker
marker
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
marker
.
isMarked
(
d
))
{
marker
.
mark
(
d
);
vertex_area
[
d
]
=
vertexVoronoiArea
<
PFP
>
(
map
,
d
,
position
)
;
}
}
}
}
// namespace Geometry
}
// namespace Algo
...
...
include/Algo/Geometry/laplacian.h
View file @
51620456
...
...
@@ -40,25 +40,48 @@ namespace Algo
namespace
Geometry
{
enum
LaplacianType
{
TOPOLOGICAL
};
template
<
typename
PFP
,
typename
ATTR_TYPE
>
ATTR_TYPE
computeLaplacianTopoVertex
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
)
;
template
<
typename
PFP
>
void
computeLaplacianVertices
(
template
<
typename
PFP
,
typename
ATTR_TYPE
>
ATTR_TYPE
computeLaplacianCotanVertex
(
typename
PFP
::
MAP
&
map
,
LaplacianType
type
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
laplacian
,
Dart
d
,
const
typename
PFP
::
TREAL
&
edgeWeight
,
const
typename
PFP
::
TREAL
&
vertexArea
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
)
;
template
<
typename
PFP
,
typename
ATTR_TYPE
>
void
computeLaplacianTopoVertices
(
typename
PFP
::
MAP
&
map
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
AttributeHandler
<
ATTR_TYPE
>&
laplacian
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
template
<
typename
PFP
,
typename
ATTR_TYPE
>
void
computeLaplacianCotanVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TREAL
&
edgeWeight
,
const
typename
PFP
::
TREAL
&
vertexArea
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
AttributeHandler
<
ATTR_TYPE
>&
laplacian
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
template
<
typename
PFP
>
void
computeLaplacianVertex_Topo
(
typename
PFP
::
REAL
computeCotanWeightEdge
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
;
template
<
typename
PFP
>
void
computeCotanWeightEdges
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
laplacian
)
;
typename
PFP
::
TREAL
&
edgeWeight
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
}
// namespace Geoemtry
...
...
include/Algo/Geometry/laplacian.hpp
View file @
51620456
...
...
@@ -33,13 +33,55 @@ namespace Algo
namespace
Geometry
{
template
<
typename
PFP
>
void
computeLaplacianVertices
(
typename
PFP
::
MAP
&
map
,
LaplacianType
type
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
laplacian
,
const
FunctorSelect
&
select
)
template
<
typename
PFP
,
typename
ATTR_TYPE
>
ATTR_TYPE
computeLaplacianTopoVertex
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
)
{
ATTR_TYPE
l
(
0
)
;
unsigned
int
val
=
0
;
Dart
it
=
d
;
do
{
l
+=
attr
[
map
.
phi1
(
it
)]
-
attr
[
it
]
;
val
++
;
it
=
map
.
alpha1
(
it
)
;
}
while
(
it
!=
d
)
;
l
/=
val
;
return
l
;
}
template
<
typename
PFP
,
typename
ATTR_TYPE
>
ATTR_TYPE
computeLaplacianCotanVertex
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TREAL
&
edgeWeight
,
const
typename
PFP
::
TREAL
&
vertexArea
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
)
{
typedef
typename
PFP
::
REAL
REAL
;
ATTR_TYPE
l
(
0
)
;
Dart
it
=
d
;
REAL
vArea
=
vertexArea
[
d
]
;
REAL
val
=
0
;
do
{
REAL
w
=
edgeWeight
[
it
]
/
vArea
;
l
+=
(
attr
[
map
.
phi1
(
it
)]
-
attr
[
it
])
*
w
;
val
+=
w
;
it
=
map
.
alpha1
(
it
)
;
}
while
(
it
!=
d
)
;
l
/=
val
;
return
l
;
}
template
<
typename
PFP
,
typename
ATTR_TYPE
>
void
computeLaplacianTopoVertices
(
typename
PFP
::
MAP
&
map
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
AttributeHandler
<
ATTR_TYPE
>&
laplacian
,
const
FunctorSelect
&
select
)
{
CellMarker
marker
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
...
...
@@ -47,35 +89,59 @@ void computeLaplacianVertices(
if
(
select
(
d
)
&&
!
marker
.
isMarked
(
d
))
{
marker
.
mark
(
d
);
switch
(
type
)
{
case
TOPOLOGICAL
:
{
computeLaplacianVertex_Topo
<
PFP
>
(
map
,
d
,
position
,
laplacian
)
;
break
;
}
}
laplacian
[
d
]
=
computeLaplacianTopoVertex
<
PFP
,
ATTR_TYPE
>
(
map
,
d
,
attr
)
;
}
}
}
template
<
typename
PFP
,
typename
ATTR_TYPE
>
void
computeLaplacianCotanVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TREAL
&
edgeWeight
,
const
typename
PFP
::
TREAL
&
vertexArea
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
AttributeHandler
<
ATTR_TYPE
>&
laplacian
,
const
FunctorSelect
&
select
)
{
CellMarker
marker
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
marker
.
isMarked
(
d
))
{
marker
.
mark
(
d
);
laplacian
[
d
]
=
computeLaplacianCotanVertex
<
PFP
,
ATTR_TYPE
>
(
map
,
d
,
edgeWeight
,
vertexArea
,
attr
)
;
}
}
}
template
<
typename
PFP
>
void
computeLaplacianVertex_Topo
(
typename
PFP
::
REAL
computeCotanWeightEdge
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
{
typename
PFP
::
REAL
alpha
=
angle
<
PFP
>
(
map
,
map
.
phi_1
(
d
),
map
.
phi2
(
map
.
phi1
(
d
)),
position
)
;
Dart
dd
=
map
.
phi2
(
d
)
;
typename
PFP
::
REAL
beta
=
angle
<
PFP
>
(
map
,
map
.
phi_1
(
dd
),
map
.
phi2
(
map
.
phi1
(
dd
)),
position
)
;
return
0.5
*
(
1
/
tan
(
alpha
)
+
1
/
tan
(
beta
)
)
;
}
template
<
typename
PFP
>
void
computeCotanWeightEdges
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
laplacian
)
typename
PFP
::
TREAL
&
edgeWeight
,
const
FunctorSelect
&
select
=
SelectorTrue
())
{
typedef
typename
PFP
::
VEC3
VEC3
;
VEC3
l
(
0
)
;
unsigned
int
val
=
0
;
Dart
dd
=
d
;
do
CellMarker
marker
(
map
,
EDGE
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
l
+=
vectorOutOfDart
<
PFP
>
(
map
,
dd
,
position
)
;
val
++
;
dd
=
map
.
alpha1
(
dd
)
;
}
while
(
dd
!=
d
)
;
l
/=
val
;
laplacian
[
d
]
=
l
;
if
(
select
(
d
)
&&
!
marker
.
isMarked
(
d
))
{
marker
.
mark
(
d
)
;
edgeWeight
[
d
]
=
computeCotanWeightEdge
<
PFP
>
(
map
,
d
,
position
)
;
}
}
}
}
// namespace Geometry
...
...
include/Algo/Geometry/normal.hpp
View file @
51620456
...
...
@@ -50,24 +50,22 @@ typename PFP::VEC3 triangleNormal(typename PFP::MAP& map, Dart d, const typename
return
N
;
}
template
<
typename
PFP
>
typename
PFP
::
VEC3
newellNormal
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
{
Dart
e
=
d
;
Dart
e
=
d
;
typename
PFP
::
VEC3
normal
(
0
);
do
{
const
typename
PFP
::
VEC3
&
P
=
position
[
e
];
e
=
map
.
phi1
(
e
);
const
typename
PFP
::
VEC3
&
Q
=
position
[
e
];
normal
[
0
]
+=
(
P
[
1
]
-
Q
[
1
])
*
(
P
[
2
]
+
Q
[
2
]);
normal
[
1
]
+=
(
P
[
2
]
-
Q
[
2
])
*
(
P
[
0
]
+
Q
[
0
]);
normal
[
2
]
+=
(
P
[
0
]
-
Q
[
0
])
*
(
P
[
1
]
+
Q
[
1
]);
}
while
(
e
!=
d
);
normal
[
0
]
+=
(
P
[
1
]
-
Q
[
1
])
*
(
P
[
2
]
+
Q
[
2
]);
normal
[
1
]
+=
(
P
[
2
]
-
Q
[
2
])
*
(
P
[
0
]
+
Q
[
0
]);
normal
[
2
]
+=
(
P
[
0
]
-
Q
[
0
])
*
(
P
[
1
]
+
Q
[
1
]);
}
while
(
e
!=
d
);
normal
.
normalize
();
return
normal
;
}
...
...
include/Algo/Import/import2tables.h
View file @
51620456
...
...
@@ -65,9 +65,9 @@ class MeshTablesSurface
protected:
typename
PFP
::
MAP
&
m_map
;
unsigned
m_nbVertices
;
unsigned
int
m_nbVertices
;
unsigned
m_nbFaces
;
unsigned
int
m_nbFaces
;
unsigned
int
m_lab
;
...
...
@@ -138,11 +138,11 @@ class MeshTablesVolume
protected:
typename
PFP
::
MAP
&
m_map
;
unsigned
m_nbVertices
;
unsigned
int
m_nbVertices
;
unsigned
m_nbFaces
;
unsigned
int
m_nbFaces
;
unsigned
m_nbVolumes
;
unsigned
int
m_nbVolumes
;
/**
* number of edges per face
...
...
include/Algo/Import/import2tablesSurface.hpp
View file @
51620456
...
...
@@ -267,7 +267,7 @@ bool MeshTablesSurface<PFP>::importTrianBinGz(const std::string& filename, std::
template<typename PFP>
bool MeshTablesSurface<PFP>::importOff(const std::string& filename, std::vector<std::string>& attrNames)
{
AttributeHandler<typename PFP::VEC3> positions =
m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "position") ;
AttributeHandler<typename PFP::VEC3> positions = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "position") ;
if (!positions.isValid())
positions = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "position") ;
...
...
include/Algo/LinearSolving/basic.h
View file @
51620456
...
...
@@ -26,6 +26,7 @@
#define __LINEAR_SOLVING_BASIC__
#include "OpenNL/linear_solver.h"
#include "Algo/LinearSolving/variablesSetup.h"
#include "Algo/LinearSolving/matrixSetup.h"
namespace
CGoGN
...
...
@@ -34,112 +35,9 @@ namespace CGoGN
namespace
LinearSolving
{
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
class
FunctorMeshToSolver_Scalar
:
public
FunctorMap
<
typename
PFP
::
MAP
>
{
protected:
LinearSolver
<
SOLVER_TRAITS
>*
solver
;
CellMarker
&
lockingMarker
;
const
AttributeHandler
<
ATTR_TYPE
>&
attrTable
;
const
AttributeHandler
<
unsigned
int
>&
indexTable
;
bool
lockedVertices
;
public:
typedef
typename
PFP
::
MAP
MAP
;
FunctorMeshToSolver_Scalar
(
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
CellMarker
&
lm
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
const
AttributeHandler
<
unsigned
int
>
index
)
:
FunctorMap
<
MAP
>
(
m
),
solver
(
s
),
lockingMarker
(
lm
),
attrTable
(
attr
),
indexTable
(
index
),
lockedVertices
(
false
)
{}
bool
operator
()(
Dart
d
)
{
solver
->
variable
(
indexTable
[
d
]).
set_value
(
attrTable
[
d
])
;
if
(
lockingMarker
.
isMarked
(
d
))
{
solver
->
variable
(
indexTable
[
d
]).
lock
()
;
lockedVertices
=
true
;
}
return
false
;
}
bool
hasLockedVertices
()
{
return
lockedVertices
;
}
}
;
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
class
FunctorMeshToSolver_Vector
:
public
FunctorMap
<
typename
PFP
::
MAP
>
{
protected:
LinearSolver
<
SOLVER_TRAITS
>*
solver
;
CellMarker
&
lockingMarker
;
const
AttributeHandler
<
ATTR_TYPE
>&
attrTable
;
const
AttributeHandler
<
unsigned
int
>&
indexTable
;
unsigned
int
coord
;
bool
lockedVertices
;
public:
typedef
typename
PFP
::
MAP
MAP
;
FunctorMeshToSolver_Vector
(
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
CellMarker
&
lm
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
unsigned
int
c
,
const
AttributeHandler
<
unsigned
int
>
index
)
:
FunctorMap
<
MAP
>
(
m
),
solver
(
s
),
lockingMarker
(
lm
),
attrTable
(
attr
),
indexTable
(
index
),
coord
(
c
),
lockedVertices
(
false
)
{}
bool
operator
()(
Dart
d
)
{
solver
->
variable
(
indexTable
[
d
]).
set_value
((
attrTable
[
d
])[
coord
])
;
if
(
lockingMarker
.
isMarked
(
d
))
{
solver
->
variable
(
indexTable
[
d
]).
lock
()
;
lockedVertices
=
true
;
}
return
false
;
}
bool
hasLockedVertices
()
{
return
lockedVertices
;
}
}
;
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
class
FunctorSolverToMesh_Scalar
:
public
FunctorMap
<
typename
PFP
::
MAP
>
{
protected:
LinearSolver
<
SOLVER_TRAITS
>*
solver
;
AttributeHandler
<
ATTR_TYPE
>&
attrTable
;
const
AttributeHandler
<
unsigned
int
>&
indexTable
;
public:
typedef
typename
PFP
::
MAP
MAP
;
FunctorSolverToMesh_Scalar
(
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
AttributeHandler
<
ATTR_TYPE
>&
attr
,
const
AttributeHandler
<
unsigned
int
>
index
)
:
FunctorMap
<
MAP
>
(
m
),
solver
(
s
),
attrTable
(
attr
),
indexTable
(
index
)
{}
bool
operator
()(
Dart
d
)
{
attrTable
[
d
]
=
solver
->
variable
(
indexTable
[
d
]).
value
()
;
return
false
;
}
}
;
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
class
FunctorSolverToMesh_Vector
:
public
FunctorMap
<
typename
PFP
::
MAP
>
{
protected:
LinearSolver
<
SOLVER_TRAITS
>*
solver
;
AttributeHandler
<
ATTR_TYPE
>&
attrTable
;
const
AttributeHandler
<
unsigned
int
>&
indexTable
;
unsigned
int
coord
;
public:
typedef
typename
PFP
::
MAP
MAP
;
FunctorSolverToMesh_Vector
(
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
AttributeHandler
<
ATTR_TYPE
>&
attr
,
unsigned
int
c
,
const
AttributeHandler
<
unsigned
int
>
index
)
:
FunctorMap
<
MAP
>
(
m
),
solver
(
s
),
attrTable
(
attr
),
indexTable
(
index
),
coord
(
c
)
{}
bool
operator
()(
Dart
d
)
{
(
attrTable
[
d
])[
coord
]
=
solver
->
variable
(
indexTable
[
d
]).
value
()
;
return
false
;
}
}
;
/*******************************************************************************
* SOLVER INIT
*******************************************************************************/
template
<
class
SOLVER_TRAITS
>
void
initSolver
(
LinearSolver
<
SOLVER_TRAITS
>*
s
,
unsigned
int
nb_variables
,
bool
least_squares
,
bool
direct
)
...
...
@@ -159,96 +57,208 @@ void initSolver(LinearSolver<SOLVER_TRAITS>* s, unsigned int nb_variables, bool
s
->
set_direct
(
direct
)
;
}
/*******************************************************************************
* VARIABLES SETUP
*******************************************************************************/
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
void
setupVariables
(
typename
PFP
::
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
CellMarker
&
lm
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
const
AttributeHandler
<
unsigned
int
>
index
)
void
setupVariables
(
typename
PFP
::
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>
index
,
CellMarker
&
lm
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
)
{
FunctorMeshToSolver_Scalar
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
fmts
(
m
,
s
,
lm
,
attr
,
index
)
;
FunctorMeshToSolver_Scalar
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
fmts
(
s
,
index
,
lm
,
attr
)
;
m
.
foreach_orbit
(
VERTEX
,
fmts
)
;
}
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
void
setupVariables
(
typename
PFP
::
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
CellMarker
&
lm
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
unsigned
int
coord
,
const
AttributeHandler
<
unsigned
int
>
index
)
void
setupVariables
(
typename
PFP
::
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>
index
,
CellMarker
&
lm
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
unsigned
int
coord
)
{
FunctorMeshToSolver_Vector
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
fmts
(
m
,
s
,
lm
,
attr
,
coord
,
index
)
;
FunctorMeshToSolver_Vector
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
fmts
(
s
,
index
,
lm
,
attr
,
coord
)
;
m
.
foreach_orbit
(
VERTEX
,
fmts
)
;
}
/*******************************************************************************
* START MATRIX DEFINITION
*******************************************************************************/
template
<
class
SOLVER_TRAITS
>
void
startMatrix
(
LinearSolver
<
SOLVER_TRAITS
>*
s
)
{
s
->
begin_system
()
;
}
enum
ConstraintType
/*******************************************************************************
* MATRIX SETUP : EQUALITY
*******************************************************************************/
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
void
addRowsRHS_Equality
(
typename
PFP
::
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>
index
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
float
amount
)
{
FunctorEquality_Scalar
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
ec
(
s
,
index
,
attr
,
amount
)
;
m
.
foreach_orbit
(
VERTEX
,
ec
)
;
}
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
void
addRowsRHS_Equality
(
typename
PFP
::
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>
index
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
float
amount
,
unsigned
int
coord
)
{
FunctorEquality_Vector
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
ec
(
s
,
index
,
attr
,
amount
,
coord
)
;
m
.
foreach_orbit
(
VERTEX
,
ec
)
;
}
/*******************************************************************************
* MATRIX SETUP : LAPLACIAN TOPO
*******************************************************************************/
template
<
typename
PFP
,
class
SOLVER_TRAITS
>
void
addRows_Laplacian_Topo
(
typename
PFP
::
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>
index
)
{