From: jfa Date: Fri, 6 Apr 2007 12:55:09 +0000 (+0000) Subject: NPAL15298: KindOfShape(). For all cases. X-Git-Tag: V3_2_6pre4~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=53a38614c4cb85eb65184c22d91a5080966994ff;p=modules%2Fgeom.git NPAL15298: KindOfShape(). For all cases. --- diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index f1bf6e58f..33d31bbca 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -2127,32 +2127,33 @@ module GEOM SHELL, WIRE, // SOLIDs - SPHERE, - CYLINDER, - BOX, - ROTATED_BOX, - TORUS, - CONE, - POLYHEDRON, - SOLID, + SPHERE, // full sphere + CYLINDER, // cylinder + BOX, // box with faces, parallel to global coordinate planes + ROTATED_BOX, // other box + TORUS, // full torus + CONE, // cone + POLYHEDRON, // solid, bounded by polygons + SOLID, // other solid // FACEs - SPHERE2D, - CYLINDER2D, - TORUS2D, - CONE2D, - DISK, - ELLIPSE2D, - POLYGON, - PLANAR, - FACE, + SPHERE2D, // spherical face (closed) + CYLINDER2D, // cylindrical face with defined height + TORUS2D, // toroidal face (closed) + CONE2D, // conical face with defined height + DISK_CIRCLE, // planar, bounded by circle + DISK_ELLIPSE, // planar, bounded by ellipse + POLYGON, // planar, bounded by segments + PLANE, // infinite planar + PLANAR, // other planar + FACE, // other face // EDGEs - CIRCLE, - ARC, - ELLIPSE, - ARC_ELLIPSE, - LINE, // infinite segment - SEGMENT, - EDGE, + CIRCLE, // full circle + ARC_CIRCLE, // arc of circle + ELLIPSE, // full ellipse + ARC_ELLIPSE, // arc of ellipse + LINE, // infinite segment + SEGMENT, // segment + EDGE, // other edge // VERTEX VERTEX }; diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index 1dc078d53..f04746716 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -25,10 +25,13 @@ #include #include +#include +#include + #include #include -#include "utilities.h" +#include #include #include @@ -132,318 +135,587 @@ GEOMImpl_IMeasureOperations::ShapeKind GEOMImpl_IMeasureOperations::KindOfShape TopoDS_Shape aShape = aRefShape->GetValue(); if (aShape.IsNull()) return aKind; - TopAbs_ShapeEnum aType = aShape.ShapeType(); + // Call algorithm + GEOMAlgo_ShapeInfoFiller aSF; + aSF.SetShape(aShape); + aSF.Perform(); + Standard_Integer iErr = aSF.ErrorStatus(); + if (iErr) { + SetErrorCode("Error in GEOMAlgo_ShapeInfoFiller"); + return SK_NO_SHAPE; + } + const GEOMAlgo_ShapeInfo& anInfo = aSF.Info(); + + // Interprete results + TopAbs_ShapeEnum aType = anInfo.Type(); switch (aType) { - //??? geompy.kind.compound nb_solids nb_faces nb_edges nb_vertices - //??? geompy.kind.compsolid nb_solids nb_faces nb_edges nb_vertices - //? "nb_faces" - all faces or only 'standalone' faces? - case TopAbs_COMPOUND: - aKind = SK_COMPOUND; - // - break; - case TopAbs_COMPSOLID: - aKind = SK_COMPSOLID; - // - break; - case TopAbs_SHELL: - //geompy.kind.shell geompy.info.closed nb_faces nb_edges nb_vertices - //geompy.kind.shell geompy.info.unclosed nb_faces nb_edges nb_vertices + case TopAbs_COMPOUND: + case TopAbs_COMPSOLID: + { + // (+) geompy.kind.COMPOUND nb_solids nb_faces nb_edges nb_vertices + // (+) geompy.kind.COMPSOLID nb_solids nb_faces nb_edges nb_vertices + // ??? "nb_faces" - all faces or only 'standalone' faces? + if (aType == TopAbs_COMPOUND) + aKind = SK_COMPOUND; + else + aKind = SK_COMPSOLID; + + //theIntegers->Append(anInfo.NbSubShapes(TopAbs_COMPOUND)); + //theIntegers->Append(anInfo.NbSubShapes(TopAbs_COMPSOLID)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_SOLID)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_FACE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_EDGE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_VERTEX)); + } + break; + + case TopAbs_SHELL: + { + // (+) geompy.kind.SHELL geompy.info.closed nb_faces nb_edges nb_vertices + // (+) geompy.kind.SHELL geompy.info.unclosed nb_faces nb_edges nb_vertices aKind = SK_SHELL; - // - break; - case TopAbs_WIRE: - //geompy.kind.wire geompy.info.closed nb_edges nb_vertices - //geompy.kind.wire geompy.info.unclosed nb_edges nb_vertices + + theIntegers->Append((int)anInfo.KindOfClosed()); + + theIntegers->Append(anInfo.NbSubShapes(TopAbs_FACE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_EDGE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_VERTEX)); + } + break; + + case TopAbs_WIRE: + { + // (+) geompy.kind.WIRE geompy.info.closed nb_edges nb_vertices + // (+) geompy.kind.WIRE geompy.info.unclosed nb_edges nb_vertices aKind = SK_WIRE; - // - break; - case TopAbs_SOLID: - //geompy.kind.sphere xc yc zc R - //geompy.kind.cylinder xb yb zb dx dy dz R H - //geompy.kind.box xc yc zc dx dy dz - //geompy.kind.rotated_box xo yo zo zx zy zz xx xy xz dx dy dz - //geompy.kind.torus xc yc zc dx dy dz R_1 R_2 - //geompy.kind.cone xb yb zb dx dy dz H R_1 R_2 - //geompy.kind.polyhedron nb_faces nb_edges nb_vertices - //geompy.kind.solid nb_faces nb_edges nb_vertices + + theIntegers->Append((int)anInfo.KindOfClosed()); + + theIntegers->Append(anInfo.NbSubShapes(TopAbs_EDGE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_VERTEX)); + } + break; + + case TopAbs_SOLID: + { aKind = SK_SOLID; - //if () { - // aKind = SK_SPHERE; - // aKind = SK_CYLINDER; - // aKind = SK_BOX; - // aKind = SK_ROTATED_BOX; - // aKind = SK_TORUS; - // aKind = SK_CONE; - // aKind = SK_POLYHEDRON; - //} - break; - case TopAbs_FACE: - // geompy.kind.sphere2d xc yc zc R - // + geompy.kind.cylinder2d xb yb zb dx dy dz R H - // geompy.kind.torus2d xc yc zc dx dy dz R_1 R_2 - // geompy.kind.cone2d xc yc zc dx dy dz R_1 R_2 - // geompy.kind.disk xc yc zc dx dy dz R - // geompy.kind.ellipse2d xc yc zc dx dy dz R_1 R_2 - // geompy.kind.polygon xo yo zo dx dy dz nb_edges nb_vertices - // + geompy.kind.planar xo yo zo dx dy dz nb_edges nb_vertices - // + geompy.kind.face nb_edges nb_vertices _surface_type_id_ - aKind = SK_FACE; - { - TopoDS_Face aF = TopoDS::Face(aShape); - int nbWires = 0, nbEdges = 0, nbVertices = 0; + GEOMAlgo_KindOfName aKN = anInfo.KindOfName(); + switch (aKN) + { + case GEOMAlgo_KN_SPHERE: + // (+) geompy.kind.SPHERE xc yc zc R + { + aKind = SK_SPHERE; - TopTools_MapOfShape mapShape; - TopExp_Explorer expw (aF, TopAbs_WIRE); - for (; expw.More(); expw.Next()) { - if (mapShape.Add(expw.Current())) { - //listShape.Append(expw.Current()); - nbWires++; - } - } + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); - mapShape.Clear(); - TopExp_Explorer expe (aF, TopAbs_EDGE); - for (; expe.More(); expe.Next()) { - if (mapShape.Add(expe.Current())) { - //listShape.Append(expe.Current()); - nbEdges++; - } + theDoubles->Append(anInfo.Radius1()); } - - mapShape.Clear(); - TopExp_Explorer expf (aF, TopAbs_VERTEX); - for (; expf.More(); expf.Next()) { - if (mapShape.Add(expf.Current())) { - //listShape.Append(expf.Current()); - nbVertices++; - } + break; + case GEOMAlgo_KN_CYLINDER: + // (+) geompy.kind.CYLINDER xb yb zb dx dy dz R H + { + aKind = SK_CYLINDER; + + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + theDoubles->Append(anInfo.Height()); } - - // Geometry - Handle(Geom_Surface) aGS = BRep_Tool::Surface(aF); - if (!aGS.IsNull()) { - BRepAdaptor_Surface aBAS (aF); - - if (aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { - // planar - aKind = SK_PLANAR; - - Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS); - gp_Pln aPln = aGPlane->Pln(); - gp_Ax3 aPos = aPln.Position(); - gp_Pnt anOri = aPos.Location(); - gp_Dir aDirZ = aPos.Direction(); - //gp_Dir aDirX = aPos.XDirection(); - - // xo yo zo - theDoubles->Append(anOri.X()); - theDoubles->Append(anOri.Y()); - theDoubles->Append(anOri.Z()); - - // dx dy dz - theDoubles->Append(aDirZ.X()); - theDoubles->Append(aDirZ.Y()); - theDoubles->Append(aDirZ.Z()); - - // nb_edges nb_vertices (for planar only) - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); - - //if () { - // aKind = SK_DISK; - // aKind = SK_ELLIPSE2D; - // aKind = SK_POLYGON; - //} + break; + case GEOMAlgo_KN_BOX: + // (+) geompy.kind.BOX xc yc zc ax ay az + { + aKind = SK_BOX; + + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + gp_Dir aX = anAx3.XDirection(); + + // ax ay az + if (aD.IsParallel(gp::DZ(), Precision::Angular()) && + aX.IsParallel(gp::DX(), Precision::Angular())) { + theDoubles->Append(anInfo.Length()); // ax' + theDoubles->Append(anInfo.Width()); // ay' + theDoubles->Append(anInfo.Height()); // az' } - else if (aGS->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { - //if (/*isSphere*/false) { - if (aBAS.IsUClosed() && aBAS.IsVClosed()) { // does not work - Handle(Geom_SphericalSurface) aGSph = Handle(Geom_SphericalSurface)::DownCast(aGS); - - // parameters - gp_Pnt aLoc = aGSph->Location(); - Standard_Real rr = aGSph->Radius(); - - // xc yc zc - theDoubles->Append(aLoc.X()); - theDoubles->Append(aLoc.Y()); - theDoubles->Append(aLoc.Z()); - - // R - theDoubles->Append(rr); - - aKind = SK_SPHERE2D; - } - else { - // nb_edges nb_vertices (for spherical only) - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); - - theIntegers->Append((Standard_Integer)GeomAbs_Sphere); - } + else if (aD.IsParallel(gp::DZ(), Precision::Angular()) && + aX.IsParallel(gp::DY(), Precision::Angular())) { + theDoubles->Append(anInfo.Width()); // ay' + theDoubles->Append(anInfo.Length()); // ax' + theDoubles->Append(anInfo.Height()); // az' } - else if (aGS->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { - // Pure cylinder or just a piece of cylindric surface - TopLoc_Location aL; - Handle(Geom_Surface) aGSLoc = BRep_Tool::Surface(aF, aL); - - //aF.Orientation(TopAbs_FORWARD); - TopExp_Explorer ex (aF, TopAbs_EDGE); - Standard_Real uMin, uMax, vMin, vMax; - bool isCylinder = true; - for (; ex.More(); ex.Next()) { - // check all edges: pure cylinder has only one seam edge - // and two edges with const v parameter - TopoDS_Edge E = TopoDS::Edge(ex.Current()); - - if (BRep_Tool::IsClosed(E, aGSLoc, aL)) { - // seam edge - //TopoDS_Edge ERevr = E; - //ERevr.Reverse(); - //Handle(Geom2d_Curve) pcRepl1 = BRep_Tool::CurveOnSurface(E , aF, f,l); - //Handle(Geom2d_Curve) pcRepl2 = BRep_Tool::CurveOnSurface(ERevr, aF, f,l); - } - else { - BRepTools::UVBounds(aF, E, uMin, uMax, vMin, vMax); - if (Abs(vMin - vMax) > Precision::Confusion()) - // neither seam, nor v-constant - isCylinder = false; - } - } - - if (isCylinder) { - aKind = SK_CYLINDER2D; - - Handle(Geom_CylindricalSurface) aGCyl = Handle(Geom_CylindricalSurface)::DownCast(aGS); - - // parameters - gp_Pnt aLoc = aGCyl->Location(); - gp_Ax1 anAx = aGCyl->Axis(); - gp_Dir aDir = anAx.Direction(); - Standard_Real rr = aGCyl->Radius(); - - // xb yb zb - theDoubles->Append(aLoc.X()); - theDoubles->Append(aLoc.Y()); - theDoubles->Append(aLoc.Z()); - - // dx dy dz - theDoubles->Append(aDir.X()); - theDoubles->Append(aDir.Y()); - theDoubles->Append(aDir.Z()); - - // R - theDoubles->Append(rr); - - // H - Standard_Real hh = Abs(aBAS.FirstVParameter() - aBAS.LastVParameter()); - theDoubles->Append(hh); - } - else { - // nb_edges nb_vertices (for cylinrical only) - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); - - theIntegers->Append((Standard_Integer)GeomAbs_Cylinder); - } + else if (aD.IsParallel(gp::DX(), Precision::Angular()) && + aX.IsParallel(gp::DZ(), Precision::Angular())) { + theDoubles->Append(anInfo.Height()); // az' + theDoubles->Append(anInfo.Width()); // ay' + theDoubles->Append(anInfo.Length()); // ax' } - else if (aGS->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) { - // aKind = SK_TORUS2D; - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); - - theIntegers->Append((Standard_Integer)GeomAbs_Torus); + else if (aD.IsParallel(gp::DX(), Precision::Angular()) && + aX.IsParallel(gp::DY(), Precision::Angular())) { + theDoubles->Append(anInfo.Height()); // az' + theDoubles->Append(anInfo.Length()); // ax' + theDoubles->Append(anInfo.Width()); // ay' } - else if (aGS->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) { - // aKind = SK_CONE2D; - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); - - theIntegers->Append((Standard_Integer)GeomAbs_Cone); + else if (aD.IsParallel(gp::DY(), Precision::Angular()) && + aX.IsParallel(gp::DZ(), Precision::Angular())) { + theDoubles->Append(anInfo.Width()); // ay' + theDoubles->Append(anInfo.Height()); // az' + theDoubles->Append(anInfo.Length()); // ax' } - else if (aGS->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) { - // - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); - - theIntegers->Append((Standard_Integer)GeomAbs_SurfaceOfExtrusion); + else if (aD.IsParallel(gp::DY(), Precision::Angular()) && + aX.IsParallel(gp::DX(), Precision::Angular())) { + theDoubles->Append(anInfo.Length()); // ax' + theDoubles->Append(anInfo.Height()); // az' + theDoubles->Append(anInfo.Width()); // ay' } - else if (aGS->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) { - // - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); - - theIntegers->Append((Standard_Integer)GeomAbs_SurfaceOfRevolution); + else { + // (+) geompy.kind.ROTATED_BOX xo yo zo zx zy zz xx xy xz ax ay az + aKind = SK_ROTATED_BOX; + + // Direction and XDirection + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(aX.X()); + theDoubles->Append(aX.Y()); + theDoubles->Append(aX.Z()); + + // ax ay az + theDoubles->Append(anInfo.Length()); + theDoubles->Append(anInfo.Width()); + theDoubles->Append(anInfo.Height()); } - else if (aGS->IsKind(STANDARD_TYPE(Geom_BezierSurface))) { - // - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); + } + break; + case GEOMAlgo_KN_TORUS: + // (+) geompy.kind.TORUS xc yc zc dx dy dz R_1 R_2 + { + aKind = SK_TORUS; + + gp_Pnt aO = anInfo.Location(); + theDoubles->Append(aO.X()); + theDoubles->Append(aO.Y()); + theDoubles->Append(aO.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + theDoubles->Append(anInfo.Radius2()); + } + break; + case GEOMAlgo_KN_CONE: + // (+) geompy.kind.CONE xb yb zb dx dy dz R_1 R_2 H + { + aKind = SK_CONE; + + gp_Pnt aO = anInfo.Location(); + theDoubles->Append(aO.X()); + theDoubles->Append(aO.Y()); + theDoubles->Append(aO.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + theDoubles->Append(anInfo.Radius2()); + theDoubles->Append(anInfo.Height()); + } + break; + case GEOMAlgo_KN_POLYHEDRON: + // (+) geompy.kind.POLYHEDRON nb_faces nb_edges nb_vertices + { + aKind = SK_POLYHEDRON; + + theIntegers->Append(anInfo.NbSubShapes(TopAbs_FACE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_EDGE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_VERTEX)); + } + break; + default: + // (+) geompy.kind.SOLID nb_faces nb_edges nb_vertices + { + theIntegers->Append(anInfo.NbSubShapes(TopAbs_FACE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_EDGE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_VERTEX)); + } + } + } + break; - theIntegers->Append((Standard_Integer)GeomAbs_BezierSurface); - } - else if (aGS->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) { - // - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); + case TopAbs_FACE: + { + aKind = SK_FACE; - theIntegers->Append((Standard_Integer)GeomAbs_BSplineSurface); - } - else if (aGS->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) { - // - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); + GEOMAlgo_KindOfName aKN = anInfo.KindOfName(); + switch (aKN) { + case GEOMAlgo_KN_SPHERE: + // (+) geompy.kind.SPHERE2D xc yc zc R + { + aKind = SK_SPHERE2D; - theIntegers->Append((Standard_Integer)GeomAbs_OffsetSurface); - } - else if (aGS->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { - // - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); - theIntegers->Append((Standard_Integer)GeomAbs_OtherSurface); - } - else { - // ??? - theIntegers->Append(nbEdges); - theIntegers->Append(nbVertices); + theDoubles->Append(anInfo.Radius1()); + } + break; + case GEOMAlgo_KN_CYLINDER: + // (+) geompy.kind.CYLINDER2D xb yb zb dx dy dz R H + { + aKind = SK_CYLINDER2D; + + gp_Pnt aO = anInfo.Location(); + theDoubles->Append(aO.X()); + theDoubles->Append(aO.Y()); + theDoubles->Append(aO.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + theDoubles->Append(anInfo.Height()); + } + break; + case GEOMAlgo_KN_TORUS: + // (+) geompy.kind.TORUS2D xc yc zc dx dy dz R_1 R_2 + { + aKind = SK_TORUS2D; + + gp_Pnt aO = anInfo.Location(); + theDoubles->Append(aO.X()); + theDoubles->Append(aO.Y()); + theDoubles->Append(aO.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + theDoubles->Append(anInfo.Radius2()); + } + break; + case GEOMAlgo_KN_CONE: + // (+) geompy.kind.CONE2D xc yc zc dx dy dz R_1 R_2 H + { + aKind = SK_CONE2D; + + gp_Pnt aO = anInfo.Location(); + theDoubles->Append(aO.X()); + theDoubles->Append(aO.Y()); + theDoubles->Append(aO.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + theDoubles->Append(anInfo.Radius2()); + theDoubles->Append(anInfo.Height()); + } + break; + case GEOMAlgo_KN_DISKCIRCLE: + // (+) geompy.kind.DISK_CIRCLE xc yc zc dx dy dz R + { + aKind = SK_DISK_CIRCLE; + + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + } + break; + case GEOMAlgo_KN_DISKELLIPSE: + // (+) geompy.kind.DISK_ELLIPSE xc yc zc dx dy dz R_1 R_2 + { + aKind = SK_DISK_ELLIPSE; + + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + theDoubles->Append(anInfo.Radius2()); + } + break; + case GEOMAlgo_KN_RECTANGLE: + case GEOMAlgo_KN_TRIANGLE: + case GEOMAlgo_KN_QUADRANGLE: + case GEOMAlgo_KN_POLYGON: + // (+) geompy.kind.POLYGON xo yo zo dx dy dz nb_edges nb_vertices + { + aKind = SK_POLYGON; + + gp_Pnt aO = anInfo.Location(); + theDoubles->Append(aO.X()); + theDoubles->Append(aO.Y()); + theDoubles->Append(aO.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theIntegers->Append(anInfo.NbSubShapes(TopAbs_EDGE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_VERTEX)); + } + break; + case GEOMAlgo_KN_PLANE: // infinite + // (+) geompy.kind.PLANE xo yo zo dx dy dz + { + aKind = SK_PLANE; + + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + } + break; + default: + if (anInfo.KindOfShape() == GEOMAlgo_KS_PLANE) { + // (+) geompy.kind.PLANAR xo yo zo dx dy dz nb_edges nb_vertices + + aKind = SK_PLANAR; + + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theIntegers->Append(anInfo.NbSubShapes(TopAbs_EDGE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_VERTEX)); + } + else { + // ??? geompy.kind.FACE nb_edges nb_vertices _surface_type_id_ + // (+) geompy.kind.FACE nb_edges nb_vertices - theIntegers->Append((Standard_Integer)GeomAbs_OtherSurface); - } + theIntegers->Append(anInfo.NbSubShapes(TopAbs_EDGE)); + theIntegers->Append(anInfo.NbSubShapes(TopAbs_VERTEX)); } } - break; - case TopAbs_EDGE: - //geompy.kind.circle xc yc zc dx dy dz R - //geompy.kind.arc xc yc zc dx dy dz R x1 y1 z1 x2 y2 z2 - //geompy.kind.ellipse xc yc zc dx dy dz R_1 R_2 - //geompy.kind.arcEllipse xc yc zc dx dy dz R_1 R_2 x1 y1 z1 x2 y2 z2 - //geompy.kind.line x1 y1 z1 x2 y2 z2 - //geompy.kind.segment x1 y1 z1 x2 y2 z2 - //geompy.kind.edge nb_vertices _curve_type_id_ + } + break; + + case TopAbs_EDGE: + { aKind = SK_EDGE; - //if () { - // aKind = SK_CIRCLE; - // aKind = SK_ARC; - // aKind = SK_ELLIPSE; - // aKind = SK_ARC_ELLIPSE; - // aKind = SK_LINE; - // aKind = SK_SEGMENT; - //} - break; - case TopAbs_VERTEX: - //geompy.kind.VERTEX x y z - aKind = SK_VERTEX; - { - TopoDS_Vertex aV = TopoDS::Vertex(aShape); - gp_Pnt aP = BRep_Tool::Pnt(aV); - theDoubles->Append(aP.X()); - theDoubles->Append(aP.Y()); - theDoubles->Append(aP.Z()); + + GEOMAlgo_KindOfName aKN = anInfo.KindOfName(); + switch (aKN) { + case GEOMAlgo_KN_CIRCLE: + { + // (+) geompy.kind.CIRCLE xc yc zc dx dy dz R + aKind = SK_CIRCLE; + + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + } + break; + case GEOMAlgo_KN_ARCCIRCLE: + { + // (+) geompy.kind.ARC_CIRCLE xc yc zc dx dy dz R x1 y1 z1 x2 y2 z2 + aKind = SK_ARC_CIRCLE; + + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + + gp_Pnt aP1 = anInfo.Pnt1(); + theDoubles->Append(aP1.X()); + theDoubles->Append(aP1.Y()); + theDoubles->Append(aP1.Z()); + + gp_Pnt aP2 = anInfo.Pnt2(); + theDoubles->Append(aP2.X()); + theDoubles->Append(aP2.Y()); + theDoubles->Append(aP2.Z()); + } + break; + case GEOMAlgo_KN_ELLIPSE: + { + // (+) geompy.kind.ELLIPSE xc yc zc dx dy dz R_1 R_2 + aKind = SK_ELLIPSE; + + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + theDoubles->Append(anInfo.Radius2()); + } + break; + case GEOMAlgo_KN_ARCELLIPSE: + { + // (+) geompy.kind.ARC_ELLIPSE xc yc zc dx dy dz R_1 R_2 x1 y1 z1 x2 y2 z2 + aKind = SK_ARC_ELLIPSE; + + gp_Pnt aC = anInfo.Location(); + theDoubles->Append(aC.X()); + theDoubles->Append(aC.Y()); + theDoubles->Append(aC.Z()); + + gp_Ax3 anAx3 = anInfo.Position(); + gp_Dir aD = anAx3.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + + theDoubles->Append(anInfo.Radius1()); + theDoubles->Append(anInfo.Radius2()); + + gp_Pnt aP1 = anInfo.Pnt1(); + theDoubles->Append(aP1.X()); + theDoubles->Append(aP1.Y()); + theDoubles->Append(aP1.Z()); + + gp_Pnt aP2 = anInfo.Pnt2(); + theDoubles->Append(aP2.X()); + theDoubles->Append(aP2.Y()); + theDoubles->Append(aP2.Z()); + } + break; + case GEOMAlgo_KN_LINE: + { + // ??? geompy.kind.LINE x1 y1 z1 x2 y2 z2 + // (+) geompy.kind.LINE x1 y1 z1 dx dy dz + aKind = SK_LINE; + + gp_Pnt aO = anInfo.Location(); + theDoubles->Append(aO.X()); + theDoubles->Append(aO.Y()); + theDoubles->Append(aO.Z()); + + gp_Dir aD = anInfo.Direction(); + theDoubles->Append(aD.X()); + theDoubles->Append(aD.Y()); + theDoubles->Append(aD.Z()); + } + break; + case GEOMAlgo_KN_SEGMENT: + { + // (+) geompy.kind.SEGMENT x1 y1 z1 x2 y2 z2 + aKind = SK_SEGMENT; + + gp_Pnt aP1 = anInfo.Pnt1(); + theDoubles->Append(aP1.X()); + theDoubles->Append(aP1.Y()); + theDoubles->Append(aP1.Z()); + + gp_Pnt aP2 = anInfo.Pnt2(); + theDoubles->Append(aP2.X()); + theDoubles->Append(aP2.Y()); + theDoubles->Append(aP2.Z()); + } + break; + default: + // ??? geompy.kind.EDGE nb_vertices _curve_type_id_ + // (+) geompy.kind.EDGE nb_vertices + theIntegers->Append(anInfo.NbSubShapes(TopAbs_VERTEX)); } - break; + } + break; + + case TopAbs_VERTEX: + { + // (+) geompy.kind.VERTEX x y z + aKind = SK_VERTEX; + + gp_Pnt aP = anInfo.Location(); + theDoubles->Append(aP.X()); + theDoubles->Append(aP.Y()); + theDoubles->Append(aP.Z()); + } + break; } SetErrorCode(OK); diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx index 12e82110c..b889d3872 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx @@ -48,32 +48,33 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations { SK_SHELL, SK_WIRE, // SOLIDs - SK_SPHERE, - SK_CYLINDER, - SK_BOX, - SK_ROTATED_BOX, - SK_TORUS, - SK_CONE, - SK_POLYHEDRON, - SK_SOLID, + SK_SPHERE, // full sphere + SK_CYLINDER, // cylinder + SK_BOX, // box with faces, parallel to global coordinate planes + SK_ROTATED_BOX, // other box + SK_TORUS, // full torus + SK_CONE, // cone + SK_POLYHEDRON, // solid, bounded by polygons + SK_SOLID, // other solid // FACEs - SK_SPHERE2D, - SK_CYLINDER2D, - SK_TORUS2D, - SK_CONE2D, - SK_DISK, - SK_ELLIPSE2D, - SK_POLYGON, - SK_PLANAR, - SK_FACE, + SK_SPHERE2D, // spherical face (closed) + SK_CYLINDER2D, // cylindrical face with defined height + SK_TORUS2D, // toroidal face (closed) + SK_CONE2D, // conical face with defined height + SK_DISK_CIRCLE, // planar, bounded by circle + SK_DISK_ELLIPSE, // planar, bounded by ellipse + SK_POLYGON, // planar, bounded by segments + SK_PLANE, // infinite planar + SK_PLANAR, // other planar + SK_FACE, // other face // EDGEs - SK_CIRCLE, - SK_ARC, - SK_ELLIPSE, - SK_ARC_ELLIPSE, - SK_LINE, // infinite segment - SK_SEGMENT, - SK_EDGE, + SK_CIRCLE, // full circle + SK_ARC_CIRCLE, // arc of circle + SK_ELLIPSE, // full ellipse + SK_ARC_ELLIPSE, // arc of ellipse + SK_LINE, // infinite segment + SK_SEGMENT, // segment + SK_EDGE, // other edge // VERTEX SK_VERTEX }; diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index 8f7b3116f..119e2d976 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -149,6 +149,11 @@ ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE" kind = GEOM.GEOM_IKindOfShape +class info: + UNKNOWN = 0 + CLOSED = 1 + UNCLOSED = 2 + # ----------------------------------------------------------------------------- # Basic primitives # ----------------------------------------------------------------------------- @@ -1978,45 +1983,45 @@ def GetPosition(theShape): # @note Concrete meaning of each value, returned via \a theIntegers # or \a theDoubles list depends on the kind of the shape. # The full list of possible outputs is: -# Currently implemented cases are marked with '+' sign: -# -# geompy.kind.COMPOUND nb_solids nb_faces nb_edges nb_vertices -# geompy.kind.COMPSOLID nb_solids nb_faces nb_edges nb_vertices -# -# geompy.kind.SHELL geompy.info.closed nb_faces nb_edges nb_vertices -# geompy.kind.SHELL geompy.info.unclosed nb_faces nb_edges nb_vertices -# -# geompy.kind.WIRE geompy.info.closed nb_edges nb_vertices -# geompy.kind.WIRE geompy.info.unclosed nb_edges nb_vertices -# -# geompy.kind.SPHERE xc yc zc R -# geompy.kind.CYLINDER xb yb zb dx dy dz R H -# geompy.kind.BOX xc yc zc dx dy dz -# geompy.kind.ROTATED_BOX xo yo zo zx zy zz xx xy xz dx dy dz -# geompy.kind.TORUS xc yc zc dx dy dz R_1 R_2 -# geompy.kind.CONE xb yb zb dx dy dz H R_1 R_2 -# geompy.kind.POLYHEDRON nb_faces nb_edges nb_vertices -# geompy.kind.SOLID nb_faces nb_edges nb_vertices -# -# geompy.kind.SPHERE2D xc yc zc R -# + geompy.kind.CYLINDER2D xb yb zb dx dy dz R H -# geompy.kind.TORUS2D xc yc zc dx dy dz R_1 R_2 -# geompy.kind.CONE2D xc yc zc dx dy dz R_1 R_2 -# geompy.kind.DISK xc yc zc dx dy dz R -# geompy.kind.ELLIPSE2D xc yc zc dx dy dz R_1 R_2 -# geompy.kind.POLYGON xo yo zo dx dy dz nb_edges nb_vertices -# + geompy.kind.PLANAR xo yo zo dx dy dz nb_edges nb_vertices -# + geompy.kind.FACE nb_edges nb_vertices _surface_type_id_ +# +# geompy.kind.COMPOUND nb_solids nb_faces nb_edges nb_vertices +# geompy.kind.COMPSOLID nb_solids nb_faces nb_edges nb_vertices +# +# geompy.kind.SHELL geompy.info.CLOSED nb_faces nb_edges nb_vertices +# geompy.kind.SHELL geompy.info.UNCLOSED nb_faces nb_edges nb_vertices +# +# geompy.kind.WIRE geompy.info.CLOSED nb_edges nb_vertices +# geompy.kind.WIRE geompy.info.UNCLOSED nb_edges nb_vertices +# +# geompy.kind.SPHERE xc yc zc R +# geompy.kind.CYLINDER xb yb zb dx dy dz R H +# geompy.kind.BOX xc yc zc ax ay az +# geompy.kind.ROTATED_BOX xc yc zc zx zy zz xx xy xz ax ay az +# geompy.kind.TORUS xc yc zc dx dy dz R_1 R_2 +# geompy.kind.CONE xb yb zb dx dy dz R_1 R_2 H +# geompy.kind.POLYHEDRON nb_faces nb_edges nb_vertices +# geompy.kind.SOLID nb_faces nb_edges nb_vertices +# +# geompy.kind.SPHERE2D xc yc zc R +# geompy.kind.CYLINDER2D xb yb zb dx dy dz R H +# geompy.kind.TORUS2D xc yc zc dx dy dz R_1 R_2 +# geompy.kind.CONE2D xc yc zc dx dy dz R_1 R_2 H +# geompy.kind.DISK_CIRCLE xc yc zc dx dy dz R +# geompy.kind.DISK_ELLIPSE xc yc zc dx dy dz R_1 R_2 +# geompy.kind.POLYGON xo yo zo dx dy dz nb_edges nb_vertices +# geompy.kind.PLANE xo yo zo dx dy dz +# geompy.kind.PLANAR xo yo zo dx dy dz nb_edges nb_vertices +# geompy.kind.FACE nb_edges nb_vertices # # geompy.kind.CIRCLE xc yc zc dx dy dz R -# geompy.kind.ARC xc yc zc dx dy dz R x1 y1 z1 x2 y2 z2 -# geompy.kind.ELLIPSE xc yc zc dx dy dz R_1 R_2 -# geompy.kind.ARC_ELLIPSE xc yc zc dx dy dz R_1 R_2 x1 y1 z1 x2 y2 z2 -# geompy.kind.LINE x1 y1 z1 x2 y2 z2 +# geompy.kind.ARC_CIRCLE xc yc zc dx dy dz R x1 y1 z1 x2 y2 z2 +# geompy.kind.ELLIPSE xc yc zc dx dy dz R_1 R_2 +# geompy.kind.ARC_ELLIPSE xc yc zc dx dy dz R_1 R_2 x1 y1 z1 x2 y2 z2 +# geompy.kind.LINE xo yo zo dx dy dz # geompy.kind.SEGMENT x1 y1 z1 x2 y2 z2 -# geompy.kind.EDGE nb_vertices _curve_ +# geompy.kind.EDGE nb_vertices # -# + geompy.kind.VERTEX x y z +# geompy.kind.VERTEX x y z # # Example: see GEOM_TestMeasures.py def KindOfShape(theShape):