From: Anthony Geay Date: Wed, 9 Oct 2024 07:41:43 +0000 (+0200) Subject: [EDF30384] : Shape recognition pretty printer X-Git-Tag: V9_14_0a1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9907fed82fa558b40a3c7782d1a96bd8a816c76b;p=tools%2Fmedcoupling.git [EDF30384] : Shape recognition pretty printer --- diff --git a/src/ShapeRecogn/Swig/ShapeRecognCommon.i b/src/ShapeRecogn/Swig/ShapeRecognCommon.i index 66e959206..3bd80083e 100644 --- a/src/ShapeRecogn/Swig/ShapeRecognCommon.i +++ b/src/ShapeRecogn/Swig/ShapeRecognCommon.i @@ -53,6 +53,37 @@ using namespace INTERP_KERNEL; %include "ShapeRecognImpl.i" %pythoncode %{ +def AreasListOfPropertiesForPrimitive(cls, primitiveType): + # Cone + if primitiveType == 3: + return ["Radius","AxisPoint","Axis"] + # Plan + elif primitiveType == 0: + return ["Normal","AffinePoint"] + # Cylinder + elif primitiveType == 2: + return ["Radius","AxisPoint","Axis"] + # Tore + elif primitiveType == 4: + return ["Center","Radius","MinorRadius"] + # Sphere + elif primitiveType == 1: + return ["Center","Radius"] + raise RuntimeError(f"Unrecognized primitive {primitiveType}") + +def AreasReprOfArea(self, areaId ): + def evaluateProps(self, areaId, listOfProps ): + def evaluateProp(self, areaId, prop): + return eval(f"self.get{prop}({areaId})") + return [ f"{prop} = {evaluateProp(self,areaId,prop)}" for prop in listOfProps] + primitiveType = self.getPrimitiveType( areaId ) + ret = [ ConvertPrimitiveToString( primitiveType ) ] + ret += evaluateProps(self,areaId,Areas.ListOfPropertiesForPrimitive(primitiveType)) + return "\n".join( ret ) + +Areas.ListOfPropertiesForPrimitive = classmethod( AreasListOfPropertiesForPrimitive ) +Areas.reprOfArea = AreasReprOfArea + import os __filename=os.environ.get('PYTHONSTARTUP') if __filename and os.path.isfile(__filename): diff --git a/src/ShapeRecogn/Swig/ShapeRecognImpl.i b/src/ShapeRecogn/Swig/ShapeRecognImpl.i index 6d2b97f07..5c4c0fb86 100644 --- a/src/ShapeRecogn/Swig/ShapeRecognImpl.i +++ b/src/ShapeRecogn/Swig/ShapeRecognImpl.i @@ -77,6 +77,36 @@ public: std::copy(res.begin(),res.end(),ret->getPointer()); return ret.retn(); } + + std::vector getAxis(mcIdType areaId) const + { + std::array tmp(self->getAxis(areaId)); + return {tmp.cbegin(),tmp.cend()}; + } + + std::vector getAxisPoint(mcIdType areaId) const + { + std::array tmp(self->getAxisPoint(areaId)); + return {tmp.cbegin(),tmp.cend()}; + } + + std::vector getNormal(mcIdType areaId) const + { + std::array tmp(self->getNormal(areaId)); + return {tmp.cbegin(),tmp.cend()}; + } + + std::vector getAffinePoint(mcIdType areaId) const + { + std::array tmp(self->getAffinePoint(areaId)); + return {tmp.cbegin(),tmp.cend()}; + } + + std::vector getCenter(mcIdType areaId) const + { + std::array tmp(self->getCenter(areaId)); + return {tmp.cbegin(),tmp.cend()}; + } } private: Areas();