From: fps Date: Thu, 26 Sep 2013 09:22:16 +0000 (+0000) Subject: add parse example X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FBR_V7_main_Field;p=modules%2Fgeom.git add parse example --- diff --git a/src/XAO/tests/BrepGeometryTest.cxx b/src/XAO/tests/BrepGeometryTest.cxx index 096676aad..069b64d31 100644 --- a/src/XAO/tests/BrepGeometryTest.cxx +++ b/src/XAO/tests/BrepGeometryTest.cxx @@ -251,3 +251,55 @@ void BrepGeometryTest::testGetSolidVolume() delete geom; } + +void BrepGeometryTest::testParse() +{ + BrepGeometry* geom = new BrepGeometry("box"); + readBrep(geom, "Box_2.brep"); + std::cout << std::endl; + + for (int solidIndex = 0; solidIndex < geom->countSolids(); ++solidIndex) + { + std::cout << "Solid #" << solidIndex << " : " << geom->getSolidReference(solidIndex) << std::endl; + int nbShells = geom->countSolidShells(solidIndex); + for (int shellIndex = 0; shellIndex < nbShells; ++shellIndex) + { + std::cout << " Shell #" << shellIndex << std::endl; + std::vector faces = geom->getSolidFaces(solidIndex, shellIndex); + for (int indf = 0; indf < faces.size(); ++indf) + { + int faceIndex = faces[indf]; + std::cout << " Face #" << geom->getFaceReference(faceIndex) << std::endl; + + int nbWires = geom->countFaceWires(faceIndex); + for (int wireIndex = 0; wireIndex < nbWires; ++wireIndex) + { + std::cout << " Wire #" << wireIndex << std::endl; + std::vector edges = geom->getFaceEdges(faceIndex, wireIndex); + for (int inde = 0; inde < edges.size(); ++inde) + { + int edgeIndex = edges[inde]; + std::cout << " Edge #" << geom->getEdgeReference(edgeIndex) << " : "; + + int va = 0, vb = 0; + geom->getEdgeVertices(edgeIndex, va, vb); + int vaRef = geom->getVertexID(va); + int vbRef = geom->getVertexID(vb); + double ax, ay, az, bx, by, bz; + geom->getVertexXYZ(va, ax, ay, az); + geom->getVertexXYZ(vb, bx, by, bz); + + std::cout << vaRef << " (" << ax << ", " << ay << ", " << az << ")"; + std::cout << " - "; + std::cout << vbRef << " (" << bx << ", " << by << ", " << bz << ")"; + std::cout << std::endl; + } + } + + + } + } + } + + delete geom; +} diff --git a/src/XAO/tests/BrepGeometryTest.hxx b/src/XAO/tests/BrepGeometryTest.hxx index d74b63ce0..427c7db8d 100644 --- a/src/XAO/tests/BrepGeometryTest.hxx +++ b/src/XAO/tests/BrepGeometryTest.hxx @@ -18,6 +18,7 @@ namespace XAO CPPUNIT_TEST(testGetEdgeLength); CPPUNIT_TEST(testGetFaceArea); CPPUNIT_TEST(testGetSolidVolume); + CPPUNIT_TEST(testParse); CPPUNIT_TEST_SUITE_END(); public: @@ -36,6 +37,8 @@ namespace XAO void testGetEdgeLength(); void testGetFaceArea(); void testGetSolidVolume(); + + void testParse(); }; }