This program 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 3 of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
- Author
- Bertrand Kerautret (
kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr
) LORIA (CNRS, UMR 7503), University of Nancy, France
- Date
- 2012/07/02
Functions for testing class 3DMeshFromPoints.
This file is part of the DGtal library.
Definition in file testMesh.cpp.
Test the mesh object construction.
Definition at line 51 of file testMesh.cpp.
89 trace.
info() << p0f0 << p1f0 << p2f0<< endl;
92 trace.
info() << p0f1 << p1f1 << p2f1<< endl;
99 bool okMeshConstruct = (p0==p0f0) && (p1==p1f0) && (p2==p2f0) &&
100 (p3==p0f1) && (p4==p1f1) && (p5==p2f1) ;
103 bool okMeshIterators =
true;
112 okMeshIterators = okMeshIterators && (nb == aMesh.
nbVertex());
114 trace.
info() <<
"vertex iteration test ok"<<std::endl;
120 (*it)[0]+=10; (*it)[1]+=5;
129 okMeshIterators = okMeshIterators && (nb == aMesh.
nbFaces());
131 trace.
info() <<
"face iteration test ok"<<std::endl;
142 trace.
info() <<
"getVertex and getFaceCenter tests ok"<<std::endl;
154 bool boundingBoxOK = (bb.first ==
Point(20,10)) && (bb.second ==
Point(26,18));
155 trace.
info() <<
"bouding box=" << bb.first <<
" " << bb.second <<
"(should be (20,10) (26,18)" <<std::endl;
165 trace.
info() <<
"nb vertices before subdivision: " << aMeshR.
nbVertex() << std::endl;
166 trace.
info() <<
"nb faces before subdivision: " << aMeshR.
nbFaces() << std::endl;
168 trace.
info() <<
"nb vertices after subdivision: " << aMeshR.
nbVertex() <<
" (should be 4)"<<std::endl;
169 trace.
info() <<
"nb faces after subdivision: " << aMeshR.
nbFaces() <<
" (should be 3)" <<std::endl;
173 trace.
info() << (okSubDivide ?
"[subdivise OK]":
"[subdivise fail]" ) << std::endl;
187 trace.
info() <<
"nb faces after quad to triangle transform: " << aMeshQ.
nbFaces() ;
188 bool okQuadToTrans = aMeshQ.
nbFaces() == 2;
189 trace.
info() <<
"(should be 2) "<< (okQuadToTrans?
"[ok]":
"[error]") << std::endl;
197 aMesh.
nbFaces() == aMesh3.nbFaces() && aMesh.
nbVertex() == aMesh3.nbVertex() &&
199 trace.
info() << (okMeshCopy ?
"[copy ok]":
"[copy fail]" ) << std::endl;
207 trace.
info() << (okRemoveFace ?
"[face remove ok]":
"[face remove fail]" ) << std::endl;
209 ok = ok & okMeshConstruct && okMeshIterators && okMeshColor && okMeshCopy && boundingBoxOK &&
210 okSubDivide && okQuadToTrans && okRemoveFace;
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
const TPoint & getVertex(Index i) const
void addQuadFace(Index indexVertex1, Index indexVertex2, Index indexVertex3, Index indexVertex4, const DGtal::Color &aColor=DGtal::Color::White)
RealPoint getFaceBarycenter(Index i) const
unsigned int quadToTriangularFaces()
void changeScale(const typename TPoint::Component aScale)
std::pair< TPoint, TPoint > getBoundingBox() const
void setFaceColor(Index i, const DGtal::Color &aColor)
const Color & getFaceColor(Index i) const
const MeshFace & getFace(Index i) const
FaceStorage::const_iterator faceEnd() const
void invertVertexFaceOrder()
ConstIterator vertexEnd() const
std::vector< Index > MeshFace
void removeFaces(const std::vector< Index > &facesIndex)
double subDivideTriangularFaces(const double minArea)
void addTriangularFace(Index indexVertex1, Index indexVertex2, Index indexVertex3, const DGtal::Color &aColor=DGtal::Color::White)
FaceStorage::const_iterator faceBegin() const
ConstIterator vertexBegin() const
void addVertex(const TPoint &vertex)
PointVector< 3, double > RealPoint
References DGtal::Mesh< TPoint >::addQuadFace(), DGtal::Mesh< TPoint >::addTriangularFace(), DGtal::Mesh< TPoint >::addVertex(), DGtal::Trace::beginBlock(), DGtal::Mesh< TPoint >::changeScale(), DGtal::Trace::endBlock(), DGtal::Mesh< TPoint >::faceBegin(), DGtal::Mesh< TPoint >::faceEnd(), DGtal::Mesh< TPoint >::getBoundingBox(), DGtal::Mesh< TPoint >::getFace(), DGtal::Mesh< TPoint >::getFaceBarycenter(), DGtal::Mesh< TPoint >::getFaceColor(), DGtal::Mesh< TPoint >::getVertex(), DGtal::Trace::info(), DGtal::Mesh< TPoint >::invertVertexFaceOrder(), DGtal::Mesh< TPoint >::nbFaces(), DGtal::Mesh< TPoint >::nbVertex(), DGtal::Mesh< TPoint >::quadToTriangularFaces(), DGtal::Color::Red, DGtal::Mesh< TPoint >::removeFaces(), DGtal::Mesh< TPoint >::setFaceColor(), DGtal::Mesh< TPoint >::subDivideTriangularFaces(), DGtal::trace, DGtal::Mesh< TPoint >::vertexBegin(), DGtal::Mesh< TPoint >::vertexEnd(), and DGtal::Color::White.
Referenced by main().
bool testMeshGeneration |
( |
| ) |
|
Test mesh generation from static fonctions.
[testMeshCreateSkeleton]
[testMeshCreateSkeleton]
[testMeshCreateTubeMesh]
[testMeshCreateTubeMesh]
[testMeshCreateHeightSequence]
[testMeshCreateHeightSequence]
[testMeshCreateSequenceMesh]
[testMeshCreateSequenceMesh]
[testMeshExport]
[testMeshExport]
Definition at line 221 of file testMesh.cpp.
229 std::vector<Z3i::RealPoint> aSkeleton;
249 trace.
info() <<
"Nb faces: "<< aMesh.nbFaces() <<
" (sould be 320)" << std::endl;
250 trace.
info() <<
"Nb vertices: "<< aMesh.nbVertex() <<
" (sould be 352)" << std::endl;
251 bool okMeshTube1 = aMesh.nbFaces() == 320 && aMesh.nbVertex() == 352;
253 trace.
beginBlock (
"Testing Tube generation (bis with variable raidii ..." );
255 std::vector<double> vectRadii;
256 vectRadii.push_back(0.5);
257 vectRadii.push_back(1.5);
258 vectRadii.push_back(2.5);
262 trace.
info() <<
"Nb faces: "<< aMeshBis.nbFaces() <<
" (sould be 320)" << std::endl;
263 trace.
info() <<
"Nb vertices: "<< aMeshBis.nbVertex() <<
" (sould be 352)" << std::endl;
265 std::ofstream ofbis (
"tubeVariableRadiiGeneratedFromTestMesh.off");
268 bool okMeshTube1bis = aMeshBis.nbFaces() == 320 && aMeshBis.nbVertex() == 352;
273 std::vector<double> heightSequence;
274 heightSequence.push_back(0.1);
275 heightSequence.push_back(0.2);
276 heightSequence.push_back(0.15);
278 heightSequence.push_back(1.1);
279 heightSequence.push_back(2.2);
280 heightSequence.push_back(1.15);
282 heightSequence.push_back(0.1);
283 heightSequence.push_back(0.2);
284 heightSequence.push_back(0.15);
291 trace.
info() <<
"Nb faces: "<< aMesh.nbFaces() <<
" (sould be 324)" << std::endl;
292 trace.
info() <<
"Nb vertices: "<< aMesh.nbVertex() <<
" (sould be 361)" << std::endl;
293 bool okMeshTube1AndHF = aMesh.nbFaces() == 324 && aMesh.nbVertex() == 361;
296 std::ofstream of (
"tubeAndHeighFieldGeneratedFromTestMesh.off");
301 ok = ok & okMeshTube1 & okMeshTube1bis & okMeshTube1AndHF;
static const Color Yellow
static bool export2OFF(std::ostream &out, const Mesh< TPoint > &aMesh, bool exportColor=true)
References DGtal::Trace::beginBlock(), DGtal::Color::Blue, DGtal::Trace::endBlock(), DGtal::MeshWriter< TPoint >::export2OFF(), DGtal::Color::Green, DGtal::Trace::info(), DGtal::Mesh< TPoint >::nbFaces(), DGtal::Mesh< TPoint >::nbVertex(), DGtal::trace, and DGtal::Color::Yellow.
Referenced by main().
bool testVisualTubularMesh |
( |
| ) |
|
Test the mesh object construction.
Definition at line 311 of file testMesh.cpp.
313 unsigned int nbok = 0;
316 trace.
beginBlock(
"Testing visual tubular mesh generation (shell mesh):");
318 std::vector<Z3i::RealPoint> centerline;
319 unsigned int nbPoints = 0;
321 double radiusSpirale = 13.0;
322 double radiusTube = 15.0;
323 double alphaMax = 32.0;
325 for (
double alpha = 0; alpha< alphaMax; alpha += 0.1, z += 0.5-reduc)
327 centerline.push_back(
Z3i::RealPoint(radiusSpirale*cos(alpha), radiusSpirale*sin(alpha), z ));
329 radiusSpirale -=reduc;
330 radiusSpirale =
std::max(radiusSpirale, 0.0);
333 std::vector<double> vectRadius;
334 for(
unsigned int i=0; i<nbPoints; i++)
336 vectRadius.push_back(radiusTube);
338 radiusTube =
std::max(radiusTube, 0.0);
344 trace.
info() <<
"Mesh generated with " << theMeshShell.nbFaces()
345 <<
" faces (should be " << (centerline.size()-1)*63 <<
" )" << std::endl;
347 nbok += theMeshShell.nbFaces() == (centerline.size()-1)*63;
348 theMeshShell >>
"spiraleGeneratedFromTestMesh.off";
354 trace.
beginBlock(
"Testing visual tubular mesh generation (tube mesh):");
355 std::vector<Z3i::RealPoint> centerLine2;
389 trace.
info() <<
"Mesh generated with " << theMeshTube.nbFaces() <<
" faces (should be "
390 << (centerLine2.size()-1)*32 <<
" )" << std::endl;
392 nbok += theMeshTube.nbFaces() == (centerLine2.size()-1)*32;
394 theMeshTube >>
"tubeGeneratedFromTestMesh.off";
static void createTubularMesh(Mesh< TPoint > &aMesh, const std::vector< TPoint > &aSkeleton, const double aRadius, const double angleStep=0.2, const DGtal::Color &aMeshColor=DGtal::Color::White)
References DGtal::Trace::beginBlock(), DGtal::Color::Blue, DGtal::Mesh< TPoint >::createTubularMesh(), DGtal::Trace::endBlock(), DGtal::Trace::info(), max(), DGtal::Mesh< TPoint >::nbFaces(), and DGtal::trace.
Referenced by main().