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
SocialAgents3D
Commits
f3141075
Commit
f3141075
authored
Mar 06, 2015
by
pitiot
Browse files
ajout visu des surfaces mais bug
parent
7f72f657
Changes
5
Hide whitespace changes
Inline
Side-by-side
include/simulator.h
View file @
f3141075
...
...
@@ -19,12 +19,14 @@ public:
void
init
(
int
argc
,
char
**
argv
);
void
doStep
();
void
initMovingObject
();
void
initSurfaces
();
void
initFixedObjects
();
void
initEmptyMovingObject
();
EnvMap
envMap_
;
double
nbSteps_
;
MovingObject
*
aiguille
;
std
::
vector
<
ArticulatedObject
*
>
objects
;
std
::
vector
<
Surface
*
>
surfaces
;
bool
Needle_or_knife
;
};
...
...
src/simulator.cpp
View file @
f3141075
...
...
@@ -26,6 +26,7 @@ void Simulator::init(int argc, char **argv)
// Needle_or_knife=false;
// initFixedObjects();
initSurfaces
();
initMovingObject
();
// initEmptyMovingObject();
...
...
@@ -37,6 +38,14 @@ void Simulator::doStep()
++
nbSteps_
;
}
void
Simulator
::
initSurfaces
()
{
ArticulatedObject
*
obj
=
new
Surface
(
this
,
VEC3
(
0.2
f
,
0
,
0
));
CGoGNout
<<
"surface initialisée : "
<<
obj
->
index_articulated
<<
CGoGNendl
;
}
void
Simulator
::
initFixedObjects
()
{
std
::
vector
<
std
::
pair
<
VEC3
,
Dart
>>
startingPoints
;
...
...
@@ -88,7 +97,7 @@ void Simulator::initFixedObjects()
ArticulatedObject
*
obj
=
new
Tree
(
this
,
startingPoints
,
segmentParts
);
objects
.
push_back
(
obj
);
CGoGNout
<<
"Objet Fixe initialisé : "
<<
obj
->
index_articulated
<<
CGoGNendl
;
...
...
src/surface.cpp
View file @
f3141075
...
...
@@ -3,13 +3,6 @@
//initialisation Surface
Surface
::
Surface
(
Simulator
*
sim
,
VEC3
offset
)
{
surfaceMap
.
initImplicitProperties
();
positionSurface
=
surfaceMap
.
addAttribute
<
VEC3
,
VERTEX
,
SURFACE
>
(
"positionSurface"
);
indexParticule
=
surfaceMap
.
addAttribute
<
int
,
VERTEX
,
SURFACE
>
(
"indexParticule"
);
indexSegment
=
surfaceMap
.
addAttribute
<
int
,
EDGE
,
SURFACE
>
(
"indexSegment"
);
initPlane
();
index_articulated
=
sim
->
objects
.
size
();
r
=
0.1
f
;
g
=
0.4
f
;
b
=
0.5
f
;
...
...
@@ -18,10 +11,18 @@ Surface::Surface(Simulator* sim,VEC3 offset)
nbVertices
=
0
;
nbEdges
=
0
;
surfaceMap
.
initImplicitProperties
();
positionSurface
=
surfaceMap
.
addAttribute
<
VEC3
,
VERTEX
,
SURFACE
>
(
"positionSurface"
);
indexParticule
=
surfaceMap
.
addAttribute
<
int
,
VERTEX
,
SURFACE
>
(
"indexParticule"
);
indexSegment
=
surfaceMap
.
addAttribute
<
int
,
EDGE
,
SURFACE
>
(
"indexSegment"
);
initPlane
();
index_articulated
=
sim
->
surfaces
.
size
();
belonging_cells
=
new
std
::
vector
<
Dart
>
[
nbEdges
];
neighbor_cells
=
new
std
::
vector
<
Dart
>
[
nbEdges
];
// initialisation des particules et des attributs de sommet
TraversorV
<
SURFACE
>
tv
(
surfaceMap
);
for
(
Dart
d
=
tv
.
begin
()
;
d
!=
tv
.
end
()
;
d
=
tv
.
next
())
{
...
...
@@ -30,7 +31,18 @@ Surface::Surface(Simulator* sim,VEC3 offset)
parts_
.
push_back
(
new
CGoGN
::
Algo
::
Volume
::
MovingObjects
::
ParticleCell3D
<
PFP
>
(
sim_
->
envMap_
.
map
,
sim_
->
envMap_
.
getBelongingCell
(
positionSurface
[
d
]),
positionSurface
[
d
]
,
sim_
->
envMap_
.
position
));
nbVertices
++
;
}
// initialisation tableaux de vecteurs qui vont stocker les belonging cells
TraversorE
<
SURFACE
>
tE2
(
surfaceMap
);
for
(
Dart
d
=
tE2
.
begin
()
;
d
!=
tE2
.
end
()
;
d
=
tE2
.
next
())
{
nbEdges
++
;
}
belonging_cells
=
new
std
::
vector
<
Dart
>
[
nbEdges
];
neighbor_cells
=
new
std
::
vector
<
Dart
>
[
nbEdges
];
int
indexLocal
=
0
;
// initialisation des segments et des attributs d'edge
TraversorE
<
SURFACE
>
tE
(
surfaceMap
);
for
(
Dart
d
=
tE
.
begin
()
;
d
!=
tE
.
end
()
;
d
=
tE
.
next
())
{
...
...
@@ -39,18 +51,21 @@ Surface::Surface(Simulator* sim,VEC3 offset)
CGoGNout
<<
" init Segment :"
<<
nbEdges
;
CGoGNout
<<
" || nb_segments :"
<<
Segments_
.
size
()
<<
CGoGNendl
;
#endif
indexSegment
[
d
]
=
nbEdges
;
indexSegment
[
d
]
=
indexLocal
;
unsigned
int
ind1
=
indexParticule
[
d
];
unsigned
int
ind2
=
indexParticule
[
surfaceMap
.
phi1
(
d
)];
Segment
*
o
=
new
Segment
(
parts_
[
ind1
]
->
getPosition
(),
parts_
[
ind2
]
->
getPosition
(),
this
,
ind1
,
ind2
,
nbEdges
,
r
,
g
,
b
);
this
,
ind1
,
ind2
,
indexLocal
,
r
,
g
,
b
);
Segments_
.
push_back
(
o
);
sim_
->
envMap_
.
FirstRegistrationSegment
(
o
);
nbEdges
++
;
indexLocal
++
;
}
sim_
->
surfaces
.
push_back
(
this
);
}
void
Surface
::
initGL
()
...
...
@@ -73,8 +88,9 @@ void Surface::initGL()
void
Surface
::
draw
()
{
m_positionVBO
->
updateData
(
positionSurface
)
;
m_positionVBO
->
updateData
(
positionSurface
)
;
glLineWidth
(
1.0
f
);
m_simpleColorShader
->
setColor
(
Geom
::
Vec4f
(
1.0
,
0.627
,
0.0
,
0.
));
m_render
->
draw
(
m_simpleColorShader
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
m_simpleColorShader
->
setColor
(
Geom
::
Vec4f
(
0.0
,
0.0
,
0.0
,
0.
));
...
...
@@ -85,66 +101,9 @@ void Surface::draw()
void
Surface
::
initPlane
()
{
CGoGNout
<<
" initialisation d'un plan"
<<
CGoGNendl
;
Algo
::
Surface
::
Tilings
::
Triangular
::
Grid
<
PFPSurface
>
prim
(
surfaceMap
,
1
,
1
)
;
Algo
::
Surface
::
Tilings
::
Triangular
::
Grid
<
PFPSurface
>
prim
(
surfaceMap
,
2
,
2
)
;
prim
.
embedIntoGrid
(
positionSurface
,
1.0
f
,
1.0
f
,
0.0
f
)
;
Dart
dY
=
prim
.
getDart
()
;
//remind the first quad of the line
Dart
dX
=
prim
.
getDart
()
;
//goes through the line
bool
odd
=
true
;
//odd line or not
int
nx
=
1
,
ny
=
1
;
for
(
unsigned
int
i
=
0
;
i
<
nx
*
ny
;)
{
Dart
dNext
=
surfaceMap
.
phi1
(
surfaceMap
.
phi2
(
surfaceMap
.
phi1
(
dX
)))
;
Dart
toCut
=
dX
;
if
(
odd
)
{
toCut
=
surfaceMap
.
phi1
(
toCut
)
;
//change the side of the split face
positionSurface
[
toCut
][
0
]
-=
sim_
->
envMap_
.
maxCellSize
/
2.0
f
;
//move vertices for equilateral triangles
}
surfaceMap
.
splitFace
(
toCut
,
surfaceMap
.
phi1
(
surfaceMap
.
phi1
(
toCut
)))
;
++
i
;
if
(
i
%
nx
==
0
&&
i
>
0
)
//goes up and change side of split
{
Dart
endSquare
=
surfaceMap
.
newFace
(
3
)
;
//add triangle add end of lines to make a square
Dart
dN
;
if
(
odd
)
{
dN
=
surfaceMap
.
phi1
(
surfaceMap
.
phi2
(
surfaceMap
.
phi1
(
dX
)))
;
surfaceMap
.
sewFaces
(
dN
,
endSquare
)
;
positionSurface
[
surfaceMap
.
phi_1
(
endSquare
)]
=
positionSurface
[
surfaceMap
.
phi1
(
endSquare
)]
;
positionSurface
[
surfaceMap
.
phi_1
(
endSquare
)][
0
]
+=
sim_
->
envMap_
.
maxCellSize
/
2.0
f
;
}
else
{
dN
=
surfaceMap
.
phi1
(
dX
)
;
surfaceMap
.
sewFaces
(
dN
,
endSquare
)
;
positionSurface
[
surfaceMap
.
phi_1
(
endSquare
)]
=
positionSurface
[
endSquare
]
;
}
if
(
odd
)
dY
=
surfaceMap
.
phi2
(
surfaceMap
.
phi_1
(
surfaceMap
.
phi2
(
surfaceMap
.
phi1
(
dY
))))
;
else
dY
=
surfaceMap
.
phi2
(
surfaceMap
.
phi1
(
surfaceMap
.
phi2
(
surfaceMap
.
phi_1
(
dY
))))
;
dX
=
dY
;
odd
=
!
odd
;
}
else
dX
=
dNext
;
}
// //add hexagons
// for(Dart d = surfaceMap.begin(); d != surfaceMap.end(); surfaceMap.next(d))
// {
// if(surfaceMap.vertexDegree(d)==6)
// {
// surfaceMap.deleteVertex(d);
// }
// }
}
src/tree.cpp
View file @
f3141075
...
...
@@ -39,6 +39,6 @@ Tree::Tree(Simulator* sim, std::vector<std::pair<VEC3, Dart>> startingPoints, st
sim_
->
envMap_
.
FirstRegistrationSegment
(
o
);
}
sim_
->
objects
.
push_back
(
this
);
}
src/viewer.cpp
View file @
f3141075
...
...
@@ -235,6 +235,13 @@ void Volusion::cb_initGL()
m_sh2
->
setClipPlaneParamsAll
(
clip_id2
,
Geom
::
Vec3f
(
0
,
0
,
1
),
m_PosObj
);
m_explode_render
->
setClippingPlane
(
Geom
::
Vec4f
(
0
,
0
,
1
,
m_PosObj
*
Geom
::
Vec3f
(
0
,
0
,
-
1
)));
for
(
Surface
*
surf
:
simul
.
surfaces
)
{
surf
->
initGL
();
registerShader
(
surf
->
m_simpleColorShader
);
}
m_MovingObjectVBO
=
new
Utils
::
VBO
();
m_MovingObjectVBO
->
setDataSize
(
3
);
m_MovingObjectVBO
->
allocate
(
10000
);
...
...
@@ -332,6 +339,11 @@ void Volusion::cb_redraw()
}
if
(
true
)
// affichage objets fixes
{
for
(
Surface
*
surf
:
simul
.
surfaces
)
{
surf
->
draw
();
}
for
(
ArticulatedObject
*
art
:
simul
.
objects
)
{
...
...
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