]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
[EDF30384] : Shape recognition pretty printer
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 9 Oct 2024 07:41:43 +0000 (09:41 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 9 Oct 2024 07:41:43 +0000 (09:41 +0200)
src/ShapeRecogn/Swig/ShapeRecognCommon.i
src/ShapeRecogn/Swig/ShapeRecognImpl.i

index 66e959206a7ac8c09000992a8294a86024917631..3bd80083ed7dcb1096196b05221f946c00003292 100644 (file)
@@ -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):
index 6d2b97f075c2f4997c74e2a721d2eaa5fa114195..5c4c0fb867dce0347d4827410a0e35ee275a1c83 100644 (file)
@@ -77,6 +77,36 @@ public:
         std::copy(res.begin(),res.end(),ret->getPointer());
         return ret.retn();
       }
+      
+      std::vector<double> getAxis(mcIdType areaId) const
+      {
+        std::array<double, 3> tmp(self->getAxis(areaId));
+        return {tmp.cbegin(),tmp.cend()};
+      }
+
+      std::vector<double> getAxisPoint(mcIdType areaId) const
+      {
+        std::array<double, 3> tmp(self->getAxisPoint(areaId));
+        return {tmp.cbegin(),tmp.cend()};
+      }
+
+      std::vector<double> getNormal(mcIdType areaId) const
+      {
+        std::array<double, 3> tmp(self->getNormal(areaId));
+        return {tmp.cbegin(),tmp.cend()};
+      }
+      
+      std::vector<double> getAffinePoint(mcIdType areaId) const
+      {
+        std::array<double, 3> tmp(self->getAffinePoint(areaId));
+        return {tmp.cbegin(),tmp.cend()};
+      }
+      
+      std::vector<double> getCenter(mcIdType areaId) const
+      {
+        std::array<double, 3> tmp(self->getCenter(areaId));
+        return {tmp.cbegin(),tmp.cend()};
+      }
     }
 private:
     Areas();