summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CSXCAD/CMakeLists.txt13
-rw-r--r--CSXCAD/matlab/AddDump.m4
-rw-r--r--CSXCAD/matlab/AutoSmoothMeshLines.m6
-rw-r--r--CSXCAD/python/CSXCAD/CSPrimitives.pxd236
-rw-r--r--CSXCAD/python/CSXCAD/CSPrimitives.pyx1261
-rw-r--r--CSXCAD/python/CSXCAD/CSProperties.pxd218
-rw-r--r--CSXCAD/python/CSXCAD/CSProperties.pyx1163
-rw-r--r--CSXCAD/python/CSXCAD/CSRectGrid.pxd56
-rw-r--r--CSXCAD/python/CSXCAD/CSRectGrid.pyx222
-rw-r--r--CSXCAD/python/CSXCAD/CSTransform.pxd53
-rw-r--r--CSXCAD/python/CSXCAD/CSTransform.pyx225
-rw-r--r--CSXCAD/python/CSXCAD/CSXCAD.pxd65
-rw-r--r--CSXCAD/python/CSXCAD/CSXCAD.pyx385
-rw-r--r--CSXCAD/python/CSXCAD/ParameterObjects.pxd29
-rw-r--r--CSXCAD/python/CSXCAD/ParameterObjects.pyx34
-rw-r--r--CSXCAD/python/CSXCAD/SmoothMeshLines.py266
-rw-r--r--CSXCAD/python/CSXCAD/Utilities.pyx53
-rw-r--r--CSXCAD/python/CSXCAD/__init__.py7
-rw-r--r--CSXCAD/python/README.md14
-rw-r--r--CSXCAD/python/doc/CSPrimitives.rst26
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimBox.rst7
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimCurve.rst7
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimCylinder.rst7
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimCylindricalShell.rst7
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimLinPoly.rst8
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimPoint.rst7
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimPolygon.rst8
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimPolyhedron.rst8
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimPolyhedronReader.rst8
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimRotPoly.rst8
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimSphere.rst7
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimSphericalShell.rst7
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimWire.rst8
-rw-r--r--CSXCAD/python/doc/CSPrimitives/CSPrimitives.rst7
-rw-r--r--CSXCAD/python/doc/CSProperties.rst19
-rw-r--r--CSXCAD/python/doc/CSProperties/CSPropConductingSheet.rst7
-rw-r--r--CSXCAD/python/doc/CSProperties/CSPropDumpBox.rst7
-rw-r--r--CSXCAD/python/doc/CSProperties/CSPropExcitation.rst7
-rw-r--r--CSXCAD/python/doc/CSProperties/CSPropLumpedElement.rst7
-rw-r--r--CSXCAD/python/doc/CSProperties/CSPropMaterial.rst7
-rw-r--r--CSXCAD/python/doc/CSProperties/CSPropMetal.rst7
-rw-r--r--CSXCAD/python/doc/CSProperties/CSPropProbeBox.rst7
-rw-r--r--CSXCAD/python/doc/CSProperties/CSProperties.rst7
-rw-r--r--CSXCAD/python/doc/CSRectGrid.rst8
-rw-r--r--CSXCAD/python/doc/CSTransform.rst9
-rw-r--r--CSXCAD/python/doc/CSXCAD.rst8
-rw-r--r--CSXCAD/python/doc/CSXCAD_API.rst13
-rw-r--r--CSXCAD/python/doc/Makefile225
-rw-r--r--CSXCAD/python/doc/Mesh.rst12
-rw-r--r--CSXCAD/python/doc/Utilities.rst8
-rw-r--r--CSXCAD/python/doc/about.rst21
-rw-r--r--CSXCAD/python/doc/conf.py348
-rw-r--r--CSXCAD/python/doc/index.rst25
-rw-r--r--CSXCAD/python/doc/install.rst31
-rw-r--r--CSXCAD/python/setup.py37
-rw-r--r--CSXCAD/python/tests/sphere.plybin0 -> 2099 bytes
-rw-r--r--CSXCAD/python/tests/sphere.stlbin0 -> 4884 bytes
-rw-r--r--CSXCAD/python/tests/test_CSPrimitives.py302
-rw-r--r--CSXCAD/python/tests/test_CSProperties.py140
-rw-r--r--CSXCAD/python/tests/test_CSRectGrid.py73
-rw-r--r--CSXCAD/python/tests/test_CSTransform.py81
-rw-r--r--CSXCAD/python/tests/test_CSXCAD.py49
-rw-r--r--CSXCAD/src/CSPrimCylinder.cpp4
-rw-r--r--CSXCAD/src/CSPrimCylindricalShell.cpp4
-rw-r--r--CSXCAD/src/CSPrimLinPoly.cpp4
-rw-r--r--CSXCAD/src/CSPrimMultiBox.cpp2
-rw-r--r--CSXCAD/src/CSPrimPolygon.cpp8
-rw-r--r--CSXCAD/src/CSPrimPolyhedron.cpp1
-rw-r--r--CSXCAD/src/CSPrimRotPoly.cpp8
-rw-r--r--CSXCAD/src/CSPrimSphere.cpp4
-rw-r--r--CSXCAD/src/CSPrimSphericalShell.cpp4
-rw-r--r--CSXCAD/src/CSPrimUserDefined.cpp4
-rw-r--r--CSXCAD/src/CSPrimWire.cpp4
-rw-r--r--CSXCAD/src/CSPropConductingSheet.cpp8
-rw-r--r--CSXCAD/src/CSPropDebyeMaterial.cpp16
-rw-r--r--CSXCAD/src/CSPropDumpBox.cpp4
-rw-r--r--CSXCAD/src/CSPropExcitation.cpp16
-rw-r--r--CSXCAD/src/CSPropLorentzMaterial.cpp48
-rw-r--r--CSXCAD/src/CSPropLumpedElement.cpp12
-rw-r--r--CSXCAD/src/CSPropMaterial.cpp40
-rw-r--r--CSXCAD/src/CSPropProbeBox.cpp1
-rw-r--r--CSXCAD/src/CSProperties.cpp2
-rw-r--r--CSXCAD/src/CSProperties.h6
-rw-r--r--CSXCAD/src/CSRectGrid.cpp1
-rw-r--r--CSXCAD/src/CSXCAD_Global.h2
-rw-r--r--CSXCAD/src/ContinuousStructure.cpp9
-rw-r--r--CSXCAD/src/ContinuousStructure.h9
-rw-r--r--CSXCAD/src/ParameterCoord.cpp4
-rw-r--r--CSXCAD/src/ParameterObjects.h14
89 files changed, 6019 insertions, 125 deletions
diff --git a/CSXCAD/CMakeLists.txt b/CSXCAD/CMakeLists.txt
index 9d516d5..a2b0448 100644
--- a/CSXCAD/CMakeLists.txt
+++ b/CSXCAD/CMakeLists.txt
@@ -10,6 +10,8 @@ PROJECT(CSXCAD CXX C)
cmake_minimum_required(VERSION 2.8)
+set (CMAKE_CXX_FLAGS -fPIC )
+
# default
set(LIB_VERSION_MAJOR 0)
set(LIB_VERSION_MINOR 6)
@@ -114,18 +116,11 @@ find_package(Boost 1.46 COMPONENTS
date_time
serialization
chrono
+ REQUIRED
)
# vtk
-if (WIN32)
- find_package(VTK 6.1 REQUIRED)
-else()
- # prefer >=6.1, fallback to >=5.4
- find_package(VTK 6.1 COMPONENTS vtkIOGeometry vtkIOPLY NO_MODULE)
- IF (NOT ${VTK_FOUND})
- find_package(VTK REQUIRED)
- endif()
-endif()
+find_package(VTK REQUIRED COMPONENTS vtkIOGeometry vtkIOPLY NO_MODULE)
message(STATUS "Found package VTK. Using version " ${VTK_VERSION})
include(${VTK_USE_FILE})
diff --git a/CSXCAD/matlab/AddDump.m b/CSXCAD/matlab/AddDump.m
index f454992..a3adc59 100644
--- a/CSXCAD/matlab/AddDump.m
+++ b/CSXCAD/matlab/AddDump.m
@@ -8,11 +8,15 @@ function CSX = AddDump(CSX, name, varargin)
% 1 for H-field time-domain dump
% 2 for electric current time-domain dump
% 3 for total current density (rot(H)) time-domain dump
+% 4 for D-field (electric flux density) time-domain dump
+% 5 for B-field (magnetic flux density) time-domain dump
%
% 10 for E-field frequency-domain dump
% 11 for H-field frequency-domain dump
% 12 for electric current frequency-domain dump
% 13 for total current density (rot(H)) frequency-domain dump
+% 14 for D-field (electric flux density) frequency-domain dump
+% 15 for B-field (magnetic flux density) frequency-domain dump
%
% 20 local SAR frequency-domain dump
% 21 1g averaging SAR frequency-domain dump
diff --git a/CSXCAD/matlab/AutoSmoothMeshLines.m b/CSXCAD/matlab/AutoSmoothMeshLines.m
index e41e261..e520fe6 100644
--- a/CSXCAD/matlab/AutoSmoothMeshLines.m
+++ b/CSXCAD/matlab/AutoSmoothMeshLines.m
@@ -44,7 +44,7 @@ lines = sort(unique(lines));
range = lines(end)-lines(1);
if (~isempty(find(diff(lines)<range*1e-6)))
- warning('CSXCAD:AutoSmoothMeshLines','some lines found with very small distance which may cause smoothing failure!');
+ warning('CSXCAD:AutoSmoothMeshLines','some lines found with very small distance which may cause smoothing failure');
end
methods = {};
@@ -138,7 +138,7 @@ end
if ((allowed_min_res>0) && (results.min_res<allowed_min_res))
if (silent==0)
- warning('CSXCAD:AutoSmoothMeshLines','method failed to obey allowed min res!');
+ warning('CSXCAD:AutoSmoothMeshLines','method failed to obey allowed min res');
end
quality = -1;
return
@@ -152,7 +152,7 @@ if (results.max_res>max_res*1.01)
end
if (results.max_ratio>ratio*1.01)
if (silent==0)
- warning('CSXCAD:AutoSmoothMeshLines',['method failed to fulfill the max. ratio: ' num2str(results.max_ratio) ' > ' num2str(ratio)]');
+ warning('CSXCAD:AutoSmoothMeshLines',['method failed to fulfill the max. ratio: ' num2str(results.max_ratio) ' > ' num2str(ratio)]);
end
quality = quality*(ratio/results.max_ratio);
end
diff --git a/CSXCAD/python/CSXCAD/CSPrimitives.pxd b/CSXCAD/python/CSXCAD/CSPrimitives.pxd
new file mode 100644
index 0000000..8d9e1a1
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/CSPrimitives.pxd
@@ -0,0 +1,236 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from libcpp.string cimport string
+from libcpp cimport bool
+
+from ParameterObjects cimport _ParameterSet, ParameterSet
+from CSProperties cimport _CSProperties, CSProperties
+from CSTransform cimport _CSTransform, CSTransform
+from CSRectGrid cimport CoordinateSystem
+
+cdef extern from "CSXCAD/CSPrimitives.h":
+ cpdef enum PrimitiveType "CSPrimitives::PrimitiveType":
+ POINT "CSPrimitives::POINT"
+ BOX "CSPrimitives::BOX"
+ MULTIBOX "CSPrimitives::MULTIBOX"
+ SPHERE "CSPrimitives::SPHERE"
+ SPHERICALSHELL "CSPrimitives::SPHERICALSHELL"
+ CYLINDER "CSPrimitives::CYLINDER"
+ CYLINDRICALSHELL "CSPrimitives::CYLINDRICALSHELL"
+ POLYGON "CSPrimitives::POLYGON"
+ LINPOLY "CSPrimitives::LINPOLY"
+ ROTPOLY "CSPrimitives::ROTPOLY"
+ POLYHEDRON "CSPrimitives::POLYHEDRON"
+ CURVE "CSPrimitives::CURVE"
+ WIRE "CSPrimitives::WIRE"
+ USERDEFINED "CSPrimitives::USERDEFINED"
+ POLYHEDRONREADER "CSPrimitives::POLYHEDRONREADER"
+
+
+cdef extern from "CSXCAD/CSPrimitives.h":
+ cdef cppclass _CSPrimitives "CSPrimitives":
+ _CSPrimitives(_ParameterSet*, _CSProperties*) except +
+ unsigned int GetID()
+ int GetType()
+ string GetTypeName()
+
+ _CSProperties* GetProperty()
+
+ void SetPriority(int val)
+ int GetPriority()
+ bool Update(string *ErrStr)
+
+ bool GetBoundBox(double dBoundBox[6])
+
+ int GetDimension()
+
+ bool IsInside(double* Coord, double tol)
+
+ bool GetPrimitiveUsed()
+ void SetPrimitiveUsed(bool val)
+
+ void SetCoordinateSystem(CoordinateSystem cs_type)
+ CoordinateSystem GetCoordinateSystem()
+
+ _CSTransform* GetTransform()
+
+cdef class CSPrimitives:
+ cdef _CSPrimitives *thisptr
+ cdef readonly CSTransform __transform
+ cdef readonly CSProperties __prop
+ cdef __GetProperty(self)
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimPoint.h":
+ cdef cppclass _CSPrimPoint "CSPrimPoint" (_CSPrimitives):
+ _CSPrimPoint(_ParameterSet*, _CSProperties*) except +
+ void SetCoord(int idx, double val)
+ double GetCoord(int idx)
+
+cdef class CSPrimPoint(CSPrimitives):
+ pass
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimBox.h":
+ cdef cppclass _CSPrimBox "CSPrimBox" (_CSPrimitives):
+ _CSPrimBox(_ParameterSet*, _CSProperties*) except +
+ void SetCoord(int idx, double val)
+ double GetCoord(int idx)
+
+cdef class CSPrimBox(CSPrimitives):
+ pass
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimCylinder.h":
+ cdef cppclass _CSPrimCylinder "CSPrimCylinder" (_CSPrimitives):
+ _CSPrimCylinder(_ParameterSet*, _CSProperties*) except +
+ void SetCoord(int idx, double val)
+ double GetCoord(int idx)
+ void SetRadius(double val)
+ double GetRadius()
+
+cdef class CSPrimCylinder(CSPrimitives):
+ pass
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimCylindricalShell.h":
+ cdef cppclass _CSPrimCylindricalShell "CSPrimCylindricalShell" (_CSPrimCylinder):
+ _CSPrimCylindricalShell(_ParameterSet*, _CSProperties*) except +
+ void SetShellWidth(double val)
+ double GetShellWidth()
+
+cdef class CSPrimCylindricalShell(CSPrimCylinder):
+ pass
+
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimSphere.h":
+ cdef cppclass _CSPrimSphere "CSPrimSphere" (_CSPrimitives):
+ _CSPrimSphere(_ParameterSet*, _CSProperties*) except +
+ void SetCenter(double x1, double x2, double x3)
+ double GetCoord(int idx)
+ void SetRadius(double val)
+ double GetRadius()
+
+cdef class CSPrimSphere(CSPrimitives):
+ pass
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimSphericalShell.h":
+ cdef cppclass _CSPrimSphericalShell "CSPrimSphericalShell" (_CSPrimSphere):
+ _CSPrimSphericalShell(_ParameterSet*, _CSProperties*) except +
+ void SetShellWidth(double val)
+ double GetShellWidth()
+
+cdef class CSPrimSphericalShell(CSPrimSphere):
+ pass
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimPolygon.h":
+ cdef cppclass _CSPrimPolygon "CSPrimPolygon" (_CSPrimitives):
+ _CSPrimPolygon(_ParameterSet*, _CSProperties*) except +
+ void AddCoord(double val)
+ double GetCoord(int index)
+ void ClearCoords()
+ size_t GetQtyCoords()
+ void SetNormDir(int ny)
+ int GetNormDir()
+ void SetElevation(double val)
+ double GetElevation()
+
+cdef class CSPrimPolygon(CSPrimitives):
+ pass
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimLinPoly.h":
+ cdef cppclass _CSPrimLinPoly "CSPrimLinPoly" (_CSPrimPolygon):
+ _CSPrimLinPoly(_ParameterSet*, _CSProperties*) except +
+ void SetLength(double val)
+ double GetLength()
+
+cdef class CSPrimLinPoly(CSPrimPolygon):
+ pass
+
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimRotPoly.h":
+ cdef cppclass _CSPrimRotPoly "CSPrimRotPoly" (_CSPrimPolygon):
+ _CSPrimRotPoly(_ParameterSet*, _CSProperties*) except +
+ void SetRotAxisDir(int ny)
+ int GetRotAxisDir()
+ void SetAngle(int index, double val)
+ double GetAngle(int index)
+
+cdef class CSPrimRotPoly(CSPrimPolygon):
+ pass
+
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimCurve.h":
+ cdef cppclass _CSPrimCurve "CSPrimCurve" (_CSPrimitives):
+ _CSPrimCurve(_ParameterSet*, _CSProperties*) except +
+ size_t AddPoint(double *coords)
+ size_t GetNumberOfPoints()
+ bool GetPoint(size_t point_index, double point[3])
+ void ClearPoints()
+
+cdef class CSPrimCurve(CSPrimitives):
+ pass
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimWire.h":
+ cdef cppclass _CSPrimWire "CSPrimWire" (_CSPrimCurve):
+ _CSPrimWire(_ParameterSet*, _CSProperties*) except +
+ void SetWireRadius(double val)
+ double GetWireRadius()
+
+cdef class CSPrimWire(CSPrimCurve):
+ pass
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimPolyhedron.h":
+ cdef cppclass _CSPrimPolyhedron "CSPrimPolyhedron" (_CSPrimitives):
+ _CSPrimPolyhedron(_ParameterSet*, _CSProperties*) except +
+ void Reset()
+ void AddVertex(float px, float py, float pz)
+ float* GetVertex(unsigned int n)
+ unsigned int GetNumVertices()
+ void AddFace(int numVertex, int* vertices)
+ int* GetFace(unsigned int n, unsigned int &numVertices)
+ unsigned int GetNumFaces()
+
+cdef class CSPrimPolyhedron(CSPrimitives):
+ pass
+
+###############################################################################
+cdef extern from "CSXCAD/CSPrimPolyhedronReader.h":
+ ctypedef enum FileType "CSPrimPolyhedronReader::FileType":
+ UNKNOWN "CSPrimPolyhedronReader::UNKNOWN"
+ STL_FILE "CSPrimPolyhedronReader::STL_FILE"
+ PLY_FILE "CSPrimPolyhedronReader::PLY_FILE"
+ cdef cppclass _CSPrimPolyhedronReader "CSPrimPolyhedronReader" (_CSPrimPolyhedron):
+ _CSPrimPolyhedronReader(_ParameterSet*, _CSProperties*) except +
+ void SetFilename(string name)
+ string GetFilename()
+ void SetFileType(FileType ft)
+ FileType GetFileType()
+ bool ReadFile()
+
+cdef class CSPrimPolyhedronReader(CSPrimPolyhedron):
+ pass
diff --git a/CSXCAD/python/CSXCAD/CSPrimitives.pyx b/CSXCAD/python/CSXCAD/CSPrimitives.pyx
new file mode 100644
index 0000000..3a169eb
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/CSPrimitives.pyx
@@ -0,0 +1,1261 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,2016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""CSXCAD.CSPrimitives
+Module for all Primitives
+
+Notes
+-----
+Usually it is not meant to create primitives manually, but instead
+use the ContinuousStructure object to create primives using the
+e.g. AddBox or AddCylinder methods.
+
+Examples
+--------
+Create a metal box:
+
+>>> pset = ParameterObjects.ParameterSet()
+>>> metal = CSProperties.CSPropMetal(pset)
+>>> box = CSPrimitives.CSPrimBox(pset, metal)
+"""
+
+import numpy as np
+import sys
+from libcpp.string cimport string
+from libcpp cimport bool
+
+cimport CSPrimitives
+from Utilities import CheckNyDir, GetMultiDirs
+cimport CSRectGrid
+
+cdef class CSPrimitives:
+ """
+ Virtual base class for all primives, cannot be created!
+
+ """
+ @staticmethod
+ def fromType(prim_type, pset, prop, no_init=False, **kw):
+ """ fromType(prim_type, pset, prop, no_init=False, **kw)
+
+ Create a primtive specified by the `prim_type`
+
+ :param prim_type: Primitive type
+ :param pset: ParameterSet to assign to the new primitive
+ :param prop: CSProperty to assign to the new primitive
+ :param no_init: do not create an actual C++ instance
+ """
+ prim = None
+ if prim_type == POINT:
+ prim = CSPrimPoint(pset, prop, no_init=no_init, **kw)
+ elif prim_type == POINT:
+ prim = CSPrimPoint(pset, prop, no_init=no_init, **kw)
+ elif prim_type == BOX:
+ prim = CSPrimBox(pset, prop, no_init=no_init, **kw)
+ elif prim_type == MULTIBOX:
+ raise Exception('Primitive type "MULTIBOX" not yet implemented!')
+ elif prim_type == SPHERE:
+ prim = CSPrimSphere(pset, prop, no_init=no_init, **kw)
+ elif prim_type == SPHERICALSHELL:
+ prim = CSPrimSphericalShell(pset, prop, no_init=no_init, **kw)
+ elif prim_type == CYLINDER:
+ prim = CSPrimCylinder(pset, prop, no_init=no_init, **kw)
+ elif prim_type == CYLINDRICALSHELL:
+ prim = CSPrimCylindricalShell(pset, prop, no_init=no_init, **kw)
+ elif prim_type == POLYGON:
+ prim = CSPrimPolygon(pset, prop, no_init=no_init, **kw)
+ elif prim_type == LINPOLY:
+ prim = CSPrimLinPoly(pset, prop, no_init=no_init, **kw)
+ elif prim_type == ROTPOLY:
+ prim = CSPrimRotPoly(pset, prop, no_init=no_init, **kw)
+ elif prim_type == POLYHEDRON:
+ prim = CSPrimPolyhedron(pset, prop, no_init=no_init, **kw)
+ elif prim_type == CURVE:
+ prim = CSPrimCurve(pset, prop, no_init=no_init, **kw)
+ elif prim_type == WIRE:
+ prim = CSPrimWire(pset, prop, no_init=no_init, **kw)
+ elif prim_type == USERDEFINED:
+ raise Exception('Primitive type "USERDEFINED" not yet implemented!')
+ elif prim_type == POLYHEDRONREADER:
+ prim = CSPrimPolyhedronReader(pset, prop, no_init=no_init, **kw)
+ return prim
+
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ self.__transform = None
+ self.__prop = prop
+ if no_init:
+ self.thisptr = NULL
+ return
+
+ assert self.thisptr, 'Error, object cannot be created (protected)'
+ self.__prop = prop
+
+ if 'priority' in kw:
+ self.SetPriority(kw['priority'])
+ del kw['priority']
+ if 'no_init' in kw:
+ del kw['no_init']
+
+ assert len(kw)==0, 'Unknown keyword arguments: "{}"'.format(kw)
+
+ def GetID(self):
+ """
+ Get the ID for this primitive
+
+ :returns: int -- ID for this primitive
+ """
+ return self.thisptr.GetID()
+
+ def GetProperty(self):
+ """
+ Get the property for this primitive
+
+ :returns: CSProperties.CSProperties
+ """
+ return self.__GetProperty()
+
+ cdef __GetProperty(self):
+ cdef _CSProperties* _prop
+ cdef CSProperties prop
+ if self.__prop is None:
+ _prop = self.thisptr.GetProperty()
+ self.__prop = CSProperties.fromType(_prop.GetType(), pset=None, no_init=True)
+ self.__prop.thisptr = _prop
+
+ return self.__prop
+
+ def GetType(self):
+ """
+ Get the type as int for this primitive
+
+ :returns: int -- Type for this primitive (e.g. 0 --> Point, 1 --> Box, ...)
+ """
+ return self.thisptr.GetType()
+
+ def GetTypeName(self):
+ """
+ Get the type as string (UTF-8) for this primitive
+
+ :returns: str -- Type name for this primitive ("Point", "Box", ...)
+ """
+ return self.thisptr.GetTypeName().decode('UTF-8')
+
+ def SetPriority(self, val):
+ """ SetPriority(val)
+
+ Set the priority for this primitive
+
+ :param val: int -- Higher priority values will override primitives with a lower priority
+ """
+ self.thisptr.SetPriority(val)
+
+ def GetPriority(self):
+ """
+ Get the priority for this primitive
+
+ :returns: int -- Priority for this primitive
+ """
+ return self.thisptr.GetPriority()
+
+ def GetBoundBox(self):
+ """
+ Get the bounding box for this primitive
+
+ :returns: (2,3) ndarray -- bounding box for this primitive
+ """
+ bb = np.zeros([2,3])
+ cdef double _bb[6]
+ self.thisptr.GetBoundBox(_bb)
+ for n in range(3):
+ bb[0,n] = _bb[2*n]
+ bb[1,n] = _bb[2*n+1]
+ return bb
+
+ def GetDimension(self):
+ """
+ Get the dimension of this primitive
+
+ :returns: int -- dimension 0..3
+ """
+ return self.thisptr.GetDimension()
+
+ def IsInside(self, coord, tol=0):
+ """ IsInside(coord, tol=0)
+
+ Check if a given coordinate is inside this primitive.
+
+ :param coord: (3,) array -- coordinate
+ :returns: bool
+ """
+ cdef double c_coord[3]
+ for n in range(3):
+ c_coord[n] = coord[n]
+
+ return self.thisptr.IsInside(c_coord, tol)
+
+ def GetPrimitiveUsed(self):
+ """
+ Get if this primitive has been used (used flag set)
+ """
+ return self.thisptr.GetPrimitiveUsed()
+
+ def SetPrimitiveUsed(self, val):
+ """ SetPrimitiveUsed(val)
+
+ Set used flag.
+ """
+ self.thisptr.SetPrimitiveUsed(val)
+
+ def __GetCSX(self):
+ if self.__prop is None:
+ return None
+ return self.__prop.__CSX
+
+ def GetTransform(self):
+ """ GetTransform()
+
+ Get the transformation class assigned to this primitive.
+ If this primitve does not have any, it will be created.
+
+ :return: CSTransform class
+
+ See Also
+ --------
+ CSXCAD.CSTransform.CSTransform
+ """
+ if self.__transform is None:
+ self.__transform = CSTransform(no_init=True)
+ self.__transform.thisptr = self.thisptr.GetTransform()
+ return self.__transform
+
+ def AddTransform(self, transform, *args, no_init=False, **kw):
+ """ AddTransform(transform, *args, **kw)
+
+ Add a transformation to this primitive.
+
+ See Also
+ --------
+ CSXCAD.CSTransform.CSTransform.AddTransform
+ """
+ tr = self.GetTransform()
+ tr.AddTransform(transform, *args, **kw)
+
+ def HasTransform(self):
+ """
+ Check if this primitive has a transformation attached.
+ It will not create one if it does not.
+
+ :returns: bool
+ """
+ if self.__transform is None:
+ return False
+ return self.__transform.HasTransform()
+
+ def SetCoordinateSystem(self, cs_type):
+ """ SetCoordinateSystem(cs_type)
+
+ Set the coordinate system type (Cartesian or cylindrical) for this primitive.
+ If set to None, the mesh type of the assigned rect grid will be used.
+
+ :param cs_type: coordinate system (0 : Cartesian, 1 : Cylindrical) or None
+
+ See Also
+ --------
+ CSXCAD.CSRectGrid.CSRectGrid.SetMeshType
+
+ """
+ assert cs_type in [CSRectGrid.CARTESIAN, CSRectGrid.CYLINDRICAL, None], 'Unknown coordinate system: {}'.format(cs_type)
+ if cs_type is None:
+ cs_type = CSRectGrid.UNDEFINED_CS
+ self.thisptr.SetCoordinateSystem(cs_type)
+
+ def GetCoordinateSystem(self):
+ """ GetCoordinateSystem
+
+ :returns: coordinate system (0 : Cartesian, 1 : Cylindrical) or None
+ """
+ cs_type = self.thisptr.GetCoordinateSystem()
+ if cs_type == CSRectGrid.UNDEFINED_CS:
+ return None
+ return cs_type
+
+ def Update(self):
+ """ Trigger an internal update and report success and error message
+
+ :returns: bool, err_msg -- success and error message (empty on success)
+ """
+ cdef string s
+ succ = self.thisptr.Update(&s)
+ return succ, str(s)
+
+
+###############################################################################
+cdef class CSPrimPoint(CSPrimitives):
+ """ Point Primitive
+
+ A point is defined by a single 3D coordinate.
+
+ Parameters
+ ----------
+ coord : (vector)
+ Coordinate vector (3,) array
+
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimPoint(pset.thisptr, prop.thisptr)
+
+ if 'coord' in kw:
+ self.SetCoord(kw['coord'])
+ del kw['coord']
+ super(CSPrimPoint, self).__init__(pset, prop, *args, **kw)
+
+ def SetCoord(self, coord):
+ """ SetCoord(coord)
+
+ Set the coordinate for this point primitive
+
+ :param coord: list/array of float -- Set the point coordinate
+ """
+ ptr = <_CSPrimPoint*>self.thisptr
+ assert len(coord)==3, "CSPrimPoint:SetCoord: length of array needs to be 3"
+ for n in range(3):
+ ptr.SetCoord(n, coord[n])
+
+ def GetCoord(self):
+ """
+ Get the point coordinate for this primitive
+
+ :returns: (3,) ndarray -- point coordinate for this primitive
+ """
+ ptr = <_CSPrimPoint*>self.thisptr
+ coord = np.zeros(3)
+ for n in range(3):
+ coord[n] = ptr.GetCoord(n)
+ return coord
+
+###############################################################################
+cdef class CSPrimBox(CSPrimitives):
+ """ Box Primitive
+
+ A box is defined by two 3D coordinates. E.g. the lower-left (start)
+ and upper right (stop) point.
+ A box is a cube in Cartesian coordinates.
+ A box is a cylinder in cylindrical coordinates.
+
+ Parameters
+ ----------
+ start : (3,) array
+ Start point vector (3,) array
+ stop : (3,) array
+ Stop point vector (3,) array
+
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimBox(pset.thisptr, prop.thisptr)
+ if 'start' in kw:
+ self.SetStart(kw['start'])
+ del kw['start']
+ if 'stop' in kw:
+ self.SetStop(kw['stop'])
+ del kw['stop']
+ super(CSPrimBox, self).__init__(pset, prop, *args, **kw)
+
+ def SetStart(self, coord):
+ """ SetStart(coord)
+
+ Set the start coordinate for this box primitive.
+
+ :param coord: list/array of float -- Set the start point coordinate
+ """
+ ptr = <_CSPrimBox*>self.thisptr
+ assert len(coord)==3, "CSPrimBox:SetStart: length of array needs to be 3"
+ for n in range(3):
+ ptr.SetCoord(2*n, coord[n])
+
+ def SetStop(self, coord):
+ """ SetStop(coord)
+
+ Set the stop coordinate for this box primitive.
+
+ :param coord: list/array of float -- Set the stop point coordinate
+ """
+ ptr = <_CSPrimBox*>self.thisptr
+ assert len(coord)==3, "CSPrimBox:SetStop: length of array needs to be 3"
+ for n in range(3):
+ ptr.SetCoord(2*n+1, coord[n])
+
+ def GetStart(self):
+ """
+ Get the start coordinate for this primitive.
+
+ :returns: (3,) ndarray -- Start coordinate for this primitive
+ """
+ ptr = <_CSPrimBox*>self.thisptr
+ coord = np.zeros(3)
+ for n in range(3):
+ coord[n] = ptr.GetCoord(2*n)
+ return coord
+
+ def GetStop(self):
+ """
+ Get the stop coordinate for this primitive.
+
+ :returns: (3,) ndarray -- Stop coordinate for this primitive
+ """
+ ptr = <_CSPrimBox*>self.thisptr
+ coord = np.zeros(3)
+ for n in range(3):
+ coord[n] = ptr.GetCoord(2*n+1)
+ return coord
+
+###############################################################################
+cdef class CSPrimCylinder(CSPrimitives):
+ """ Cylinder Primitive
+
+ A cylinder is defined by its axis and a radius.
+ The axis is defined by two 3D coordinates (start/stop).
+
+ Parameters
+ ----------
+ start : (3,) array
+ Axis start point vector (3,) array
+ stop : (3,) array
+ Axis stop point vector (3,) array
+ radius : float
+ The cylinder radius
+
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimCylinder(pset.thisptr, prop.thisptr)
+ if 'start' in kw:
+ self.SetStart(kw['start'])
+ del kw['start']
+ if 'stop' in kw:
+ self.SetStop(kw['stop'])
+ del kw['stop']
+ if 'radius' in kw:
+ self.SetRadius(kw['radius'])
+ del kw['radius']
+ super(CSPrimCylinder, self).__init__(pset, prop, *args, **kw)
+
+ def SetStart(self, coord):
+ """ SetStart(coord)
+
+ Set the start coordinate for the cylinder axis.
+
+ :param coord: list/array of float -- Set the axis start point coordinate.
+ """
+ ptr = <_CSPrimCylinder*>self.thisptr
+ assert len(coord)==3, "CSPrimCylinder:SetStart: length of array needs to be 3"
+ for n in range(3):
+ ptr.SetCoord(2*n, coord[n])
+
+ def SetStop(self, coord):
+ """ SetStop(coord)
+
+ Set the stop coordinate for the cylinder axis.
+
+ :param coord: list/array of float -- Set the axis stop point coordinate.
+ """
+ ptr = <_CSPrimCylinder*>self.thisptr
+ assert len(coord)==3, "CSPrimCylinder:SetStop: length of array needs to be 3"
+ for n in range(3):
+ ptr.SetCoord(2*n+1, coord[n])
+
+ def GetStart(self):
+ """
+ Get the axis start coordinate.
+
+ :returns: (3,) ndarray -- Axis start coordinate.
+ """
+ ptr = <_CSPrimCylinder*>self.thisptr
+ coord = np.zeros(3)
+ for n in range(3):
+ coord[n] = ptr.GetCoord(2*n)
+ return coord
+
+ def GetStop(self):
+ """
+ Get the axis stop coordinate.
+
+ :returns: (3,) ndarray -- Axis stop coordinate.
+ """
+ ptr = <_CSPrimCylinder*>self.thisptr
+ coord = np.zeros(3)
+ for n in range(3):
+ coord[n] = ptr.GetCoord(2*n+1)
+ return coord
+
+ def SetRadius(self, val):
+ """ SetRadius(val)
+
+ Set the cylinder radius
+
+ :param val: float -- Set the cylinder radius
+ """
+ ptr = <_CSPrimCylinder*>self.thisptr
+ ptr.SetRadius(val)
+
+ def GetRadius(self):
+ """
+ Get the cylinder radius.
+
+ :returns: float -- Cylinder radius.
+ """
+ ptr = <_CSPrimCylinder*>self.thisptr
+ return ptr.GetRadius()
+
+###############################################################################
+cdef class CSPrimCylindricalShell(CSPrimCylinder):
+ """ Cylindrical Shell (hollow cylinder)
+
+ A cylindrical shell is defined like a cylinder with an additional shell width.
+
+ Parameters
+ ----------
+ shell_width : float
+ Width of the cylindrical shell
+
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimCylindricalShell(pset.thisptr, prop.thisptr)
+ if 'shell_width' in kw:
+ self.SetShellWidth(kw['shell_width'])
+ del kw['shell_width']
+ super(CSPrimCylindricalShell, self).__init__(pset, prop, *args, **kw)
+
+ def SetShellWidth(self, val):
+ """ SetShellWidth(val)
+
+ Set the cylinder shell width.
+
+ :param val: float -- Set the cylinder shell width
+ """
+ ptr = <_CSPrimCylindricalShell*>self.thisptr
+ ptr.SetShellWidth(val)
+
+ def GetShellWidth(self):
+ """
+ Get the cylinder shell width.
+
+ :returns: float -- Cylinder shell width.
+ """
+ ptr = <_CSPrimCylindricalShell*>self.thisptr
+ return ptr.GetShellWidth()
+
+###############################################################################
+cdef class CSPrimSphere(CSPrimitives):
+ """ Sphere Primitive
+
+ A sphere is defined by its center and radius.
+ The center is defined by a 3D coordinate.
+
+ Parameters
+ ----------
+ center : (3,) array
+ Center point vector (3,) array
+ radius : float
+ The sphere radius
+
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimSphere(pset.thisptr, prop.thisptr)
+ if 'center' in kw:
+ self.SetCenter(kw['center'])
+ del kw['center']
+ if 'radius' in kw:
+ self.SetRadius(kw['radius'])
+ del kw['radius']
+ super(CSPrimSphere, self).__init__(pset, prop, *args, **kw)
+
+ def SetCenter(self, coord):
+ """ SetRadius(val)
+
+ Set the sphere center point.
+
+ :param coord: (3,) array -- Set the sphere center point.
+ """
+ ptr = <_CSPrimSphere*>self.thisptr
+ assert len(coord)==3, "CSPrimSphere:SetCenter: length of array needs to be 3"
+ ptr.SetCenter(coord[0], coord[1], coord[2])
+
+ def GetCenter(self):
+ """
+ Get the sphere center point.
+
+ :returns: (3,) ndarray -- Center coordinate.
+ """
+ ptr = <_CSPrimSphere*>self.thisptr
+ coord = np.zeros(3)
+ for n in range(3):
+ coord[n] = ptr.GetCoord(n)
+ return coord
+
+ def SetRadius(self, val):
+ """ SetRadius(val)
+
+ Set the sphere radius
+
+ :param val: float -- Set the sphere radius
+ """
+ ptr = <_CSPrimSphere*>self.thisptr
+ ptr.SetRadius(val)
+
+ def GetRadius(self):
+ """
+ Get the sphere radius.
+
+ :returns: float -- Sphere radius.
+ """
+ ptr = <_CSPrimSphere*>self.thisptr
+ return ptr.GetRadius()
+
+###############################################################################
+cdef class CSPrimSphericalShell(CSPrimSphere):
+ """ Spherical Shell (hollow sphere) Primitive Class
+
+ A spherical shell is defined like a sphere with an additional shell width.
+
+ Parameters
+ ----------
+ shell_width : float
+ Width of the spherical shell
+
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimSphericalShell(pset.thisptr, prop.thisptr)
+ if 'shell_width' in kw:
+ self.SetShellWidth(kw['shell_width'])
+ del kw['shell_width']
+ super(CSPrimSphericalShell, self).__init__(pset, prop, *args, **kw)
+
+ def SetShellWidth(self, val):
+ """ SetShellWidth(val)
+
+ Set the sphere shell width.
+
+ :param val: float -- Set the sphere shell width
+ """
+ ptr = <_CSPrimSphericalShell*>self.thisptr
+ ptr.SetShellWidth(val)
+
+ def GetShellWidth(self):
+ """
+ Get the sphere shell width.
+
+ :returns: float -- sphere shell width.
+ """
+ ptr = <_CSPrimSphericalShell*>self.thisptr
+ return ptr.GetShellWidth()
+
+###############################################################################
+cdef class CSPrimPolygon(CSPrimitives):
+ """ Polygon Primitive
+
+ A polygon is a surface defined by a set of 2D points/coordinates.
+ To place the polygon in a 3D space, a normal direction (x/y/z) and an
+ elevation in this direction have to be specified.
+
+ Parameters
+ ----------
+ points : (N,2) array
+ Array of coordinates
+ norm_dir : float or str
+ Normal direction, either 0,1,2 or x/y/z respectively
+ elevation : float
+ Elevation in normal direciton
+
+ Examples
+ --------
+ Define a half circle as polygon
+
+ >>> polygon = CSPrimitives.CSPrimBox(pset, metal, norm_dir='z', elevation=1.0)
+ >>> ang = np.linspace(0, np.pi, 21)
+ >>> polygon.SetCoords(5*np.cos(ang), 5*np.sin(ang))
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimPolygon(pset.thisptr, prop.thisptr)
+ if 'points' in kw:
+ assert len(kw['points'])==2, 'points must be a list of length 2'
+ self.SetCoords(kw['points'][0], kw['points'][1])
+ del kw['points']
+ if 'norm_dir' in kw:
+ self.SetNormDir(kw['norm_dir'])
+ del kw['norm_dir']
+ if 'elevation' in kw:
+ self.SetElevation(kw['elevation'])
+ del kw['elevation']
+ super(CSPrimPolygon, self).__init__(pset, prop, *args, **kw)
+
+ def SetCoords(self, x0, x1):
+ """ SetCoords(x0, x1)
+
+ Set the coordinates for the polygon. This will clear all previous coordinates.
+
+ :param x0, x1: (N,), (N,) Two arrays for x0/x1 of the polygon coordinates.
+ """
+ assert len(x0)==len(x1), 'SetCoords: x0/x1 do not have the same length'
+ assert len(x0)>0, 'SetCoords: empty coordinates'
+
+ ptr = <_CSPrimPolygon*>self.thisptr
+ ptr.ClearCoords()
+ for n in range(len(x0)):
+ ptr.AddCoord(x0[n])
+ ptr.AddCoord(x1[n])
+
+ def GetCoords(self):
+ """
+ Get the coordinates for the polygon
+
+ :return x0, x1: (N,), (N,) Arrays for x0,x1 of the polygon coordinates
+ """
+ ptr = <_CSPrimPolygon*>self.thisptr
+ N = ptr.GetQtyCoords()
+ x0 = np.zeros(N)
+ x1 = np.zeros(N)
+ for n in range(N):
+ x0[n] = ptr.GetCoord(2*n)
+ x1[n] = ptr.GetCoord(2*n+1)
+ return x0, x1
+
+ def GetQtyCoords(self):
+ """
+ Get the number of coordinates for the polygon
+
+ :return val: int -- Number of polygon coordinates.
+ """
+ ptr = <_CSPrimPolygon*>self.thisptr
+ return ptr.GetQtyCoords()
+
+ def ClearCoords(self):
+ """
+ Remove all coordinates.
+ """
+ ptr = <_CSPrimPolygon*>self.thisptr
+ ptr.ClearCoords()
+
+ def SetNormDir(self, ny):
+ """ SetNormDir(ny)
+
+ Set the normal direction.
+
+ :param ny: int or string -- Normal direction, either 0/1/2 or 'x'/'y'/'z'
+ """
+ ptr = <_CSPrimPolygon*>self.thisptr
+ ptr.SetNormDir(CheckNyDir(ny))
+
+ def GetNormDir(self):
+ """
+ Get the normal direction.
+
+ :return ny: int -- Normal direction as 0, 1 or 2 meaning x,y or z
+ """
+ ptr = <_CSPrimPolygon*>self.thisptr
+ return ptr.GetNormDir()
+
+ def SetElevation(self, val):
+ """ SetElevation(val)
+
+ Set the elevation in normal direction.
+
+ :param val: float -- Elevation in normal direction.
+ """
+ ptr = <_CSPrimPolygon*>self.thisptr
+ ptr.SetElevation(val)
+
+ def GetElevation(self):
+ """
+ Get the elevation in normal direction.
+
+ :return val: float -- Get the elevation in normal direction.
+ """
+ ptr = <_CSPrimPolygon*>self.thisptr
+ return ptr.GetElevation()
+
+###############################################################################
+cdef class CSPrimLinPoly(CSPrimPolygon):
+ """ Linear Extruded Polygon
+
+ A linear extruded polygon is a polygon that is extruded in normal direction
+ for a certain length above the elevation.
+
+ Parameters
+ ----------
+ length : float
+ Extrusion length in normal direction
+
+ Examples
+ --------
+ Define a half circle with a height (in z direction) of 1
+
+ >>> linpoly = CSPrimitives.CSPrimLinPoly(pset, metal, norm_dir='z', elevation=0.5)
+ >>> ang = np.linspace(0, np.pi, 21)
+ >>> linpoly.SetCoords(5*np.cos(ang), 5*np.sin(ang))
+ >>> linpoly.SetLength(1.0)
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimLinPoly(pset.thisptr, prop.thisptr)
+ if 'length' in kw:
+ self.SetLength(kw['length'])
+ del kw['length']
+ super(CSPrimLinPoly, self).__init__(pset, prop, *args, **kw)
+
+ def SetLength(self, val):
+ """ SetLength(val)
+
+ Set the extrusion length in normal direction.
+
+ :param val: float -- Extrusion length in normal direction.
+ """
+ ptr = <_CSPrimLinPoly*>self.thisptr
+ ptr.SetLength(val)
+
+ def GetLength(self):
+ """
+ Get the extrusion length in normal direction.
+
+ :return val: float -- Get the extrusion length in normal direction.
+ """
+ ptr = <_CSPrimLinPoly*>self.thisptr
+ return ptr.GetLength()
+
+###############################################################################
+cdef class CSPrimRotPoly(CSPrimPolygon):
+ """ Rotation Extruded Polygon
+
+ A rotation extruded polygon is a polygon that is rotated around a Cartesian
+ axis with a given start and stop angle.
+
+ Parameters
+ ----------
+ rot_axis : float or str
+ Rotation axis direction, either 0,1,2 or x/y/z respectively.
+ angle : float, float
+ Start/Stop angle (rad) of rotation. Default is (0, 2*pi).
+
+ Examples
+ --------
+ Define a half circle on the xy-plane, rotated around the x axis
+
+ >>> rotpoly = CSPrimitives.CSPrimRotPoly(pset, metal, norm_dir='z')
+ >>> ang = np.linspace(0, np.pi, 21)
+ >>> rotpoly.SetCoords(5*np.cos(ang), 5*np.sin(ang))
+ >>> rotpoly.SetRotAxisDir('x')
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimRotPoly(pset.thisptr, prop.thisptr)
+ if 'rot_axis' in kw:
+ self.SetRotAxisDir(kw['rot_axis'])
+ del kw['rot_axis']
+ if 'angle' in kw:
+ assert len(kw['angle'])==2, 'angle must be a list/array of length 2'
+ self.SetRotAxisDir(kw['angle'][0],kw['angle'][1])
+ del kw['angle']
+ super(CSPrimRotPoly, self).__init__(pset, prop, *args, **kw)
+
+ def SetRotAxisDir(self, ny):
+ """ SetRotAxisDir(ny)
+
+ Set the rotation axis direction, either 0,1,2 or x/y/z respectively.
+
+ :param ny: int or str -- Rotation axis direction, either 0,1,2 or x/y/z respectively.
+ """
+ ptr = <_CSPrimRotPoly*>self.thisptr
+ ptr.SetRotAxisDir(CheckNyDir(ny))
+
+ def GetRotAxisDir(self):
+ """
+ Get the rotation axis direction
+
+ :returns ny: int -- Rotation axis direction as 0, 1 or 2 meaning x,y or z
+ """
+ ptr = <_CSPrimRotPoly*>self.thisptr
+ return ptr.GetRotAxisDir()
+
+ def SetAngle(self, a0, a1):
+ """ SetAngle(a0, a1)
+
+ Set the start/stop angle (rad) of rotation. Default is (0, 2*pi).
+
+ :param a0: float -- Start angle (rad) of rotation.
+ :param a1: float -- Stop angle (rad) of rotation.
+ """
+ ptr = <_CSPrimRotPoly*>self.thisptr
+ ptr.SetAngle(0, a0)
+ ptr.SetAngle(1, a1)
+
+ def GetAngle(self):
+ """
+ Get the start/stop angle (rad) of rotation.
+
+ :returns a0, a1: float, float -- Start/Stop angle (rad) of rotation.
+ """
+ ptr = <_CSPrimRotPoly*>self.thisptr
+ return ptr.GetAngle(0), ptr.GetAngle(1)
+
+###############################################################################
+cdef class CSPrimCurve(CSPrimitives):
+ """ Curve Primitive
+
+ A curve is a set of consequtive 3D coordinates.
+
+ Parameters
+ ----------
+ points : (3, N) array
+ Array of 3D coordinates.
+
+ Examples
+ --------
+
+ >>> x = np.array([0, 0, 1, 1]) + 1.5
+ >>> y = np.array([0, 1, 1, 0]) + 2.5
+ >>> z = np.array([0, 1, 3, 4])
+ >>> curve = CSPrimitives.CSPrimCurve(pset, metal, points=[x,y,z])
+ >>> curve.AddPoint([2, 0, 5])
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimCurve(pset.thisptr, prop.thisptr)
+ if 'points' in kw:
+ assert len(kw['points'])==3, 'points list not of length 3'
+ self.SetPoints(kw['points'][0], kw['points'][1], kw['points'][2])
+ del kw['points']
+ super(CSPrimCurve, self).__init__(pset, prop, *args, **kw)
+
+ def AddPoint(self, point):
+ """ AddPoint(point)
+
+ Add a single point to the list.
+
+ :param point: (3,) array -- Add a single 3D point
+ """
+ assert len(point)==3, "CSPrimSphere:SetCenter: length of array needs to be 3"
+ ptr = <_CSPrimCurve*>self.thisptr
+ cdef double dp[3]
+ for n in range(3):
+ dp[n] = point[n]
+ ptr.AddPoint(dp)
+
+ def SetPoints(self, x, y, z):
+ """ SetPoints(x, y, z)
+
+ Set an array of 3D coordinates
+
+ :param x,y,z: each (N,) array -- Array of 3D point components
+ """
+ assert len(x)==len(y)==len(z), 'SetPoints: each component must be of equal length'
+ assert len(x)>0, 'SetPoints: empty list!'
+ ptr = <_CSPrimCurve*>self.thisptr
+ ptr.ClearPoints()
+ cdef double dp[3]
+ for n in range(len(x)):
+ dp[0] = x[n]
+ dp[1] = y[n]
+ dp[2] = z[n]
+ ptr.AddPoint(dp)
+
+ def GetPoint(self, idx):
+ """ GetPoint(idx)
+
+ Get a point with a given index.
+
+ :param idx: int -- Index of point requested.
+ :return point: (3,) array -- Point coordinate at index `idx`
+ """
+ ptr = <_CSPrimCurve*>self.thisptr
+ cdef double dp[3]
+ assert ptr.GetPoint(idx, dp), 'GetPoint: invalid index'
+ point = np.zeros(3)
+ for n in range(3):
+ point[n] = dp[n]
+ return point
+
+ def ClearPoints(self):
+ """
+ Clear all points.
+ """
+ ptr = <_CSPrimCurve*>self.thisptr
+ ptr.ClearPoints()
+
+ def GetNumberOfPoints(self):
+ """
+ Get the number of points.
+
+ :return num: int -- Get the number of points.
+ """
+ ptr = <_CSPrimCurve*>self.thisptr
+ return ptr.GetNumberOfPoints()
+
+
+###############################################################################
+cdef class CSPrimWire(CSPrimCurve):
+ """ Wire Primitive
+
+ A wire is a curve with a given radius.
+
+ Parameters
+ ----------
+ radius : float
+ Wire radius
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimWire(pset.thisptr, prop.thisptr)
+ if 'radius' in kw:
+ self.SetWireRadius(kw['radius'])
+ del kw['radius']
+ super(CSPrimWire, self).__init__(pset, prop, *args, **kw)
+
+
+ def SetWireRadius(self, val):
+ """ SetWireRadius(val)
+
+ Set the wire radius
+
+ :param val: float -- Set the wire radius
+ """
+ ptr = <_CSPrimWire*>self.thisptr
+ ptr.SetWireRadius(val)
+
+ def GetWireRadius(self):
+ """
+ Get the wire radius.
+
+ :returns: float -- Wire radius.
+ """
+ ptr = <_CSPrimWire*>self.thisptr
+ return ptr.GetWireRadius()
+
+###############################################################################
+cdef class CSPrimPolyhedron(CSPrimitives):
+ """ Polyhedron Primitive
+
+ A polyhedron is a 3D solid with flat polygonal faces (currently only triangles).
+
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimPolyhedron(pset.thisptr, prop.thisptr)
+ super(CSPrimPolyhedron, self).__init__(pset, prop, *args, **kw)
+
+ def Reset(self):
+ """
+ Reset the polyhedron, that means removeing all faces.
+ """
+ ptr = <_CSPrimPolyhedron*>self.thisptr
+ ptr.Reset()
+
+ def AddVertex(self, x, y, z):
+ """ AddVertex(x, y, z)
+
+ Add a single 3D vertex.
+
+ :param x,y,z: float,float,float -- 3D vertex
+ """
+ ptr = <_CSPrimPolyhedron*>self.thisptr
+ ptr.AddVertex(x, y, z)
+
+ def GetVertex(self, idx):
+ """ GetVertex(idx)
+
+ Get the vertex with index `idx`.
+
+ :param idx: int -- Vertex index to return
+ :returns point: (3,) array -- Vertex coordinate at index `idx`
+ """
+ ptr = <_CSPrimPolyhedron*>self.thisptr
+ assert idx>=0 and idx<ptr.GetNumVertices(), "Error: invalid vertex index"
+ cdef float* p
+ p = ptr.GetVertex(idx)
+ assert p!=NULL
+ pyp = np.zeros(3)
+ for n in range(3):
+ pyp[n] = p[n]
+ return pyp
+
+ def GetNumVertices(self):
+ """
+ Get the number of vertices.
+
+ :returns num: int -- Number of vertices
+ """
+ ptr = <_CSPrimPolyhedron*>self.thisptr
+ return ptr.GetNumVertices()
+
+ def AddFace(self, verts):
+ """ AddFace(verts)
+
+ Add a face with a given list of vertices.
+ The vertices have to be added already.
+ Currently only triangle faces are possible.
+
+ :params verts: (N,) array -- Face with N vericies (currently N=3!)
+ """
+ assert len(verts)==3, 'AddFace: currently only triangles allowed as faces'
+ cdef int i_v[3]
+ for n in range(3):
+ i_v[n] = verts[n]
+ ptr = <_CSPrimPolyhedron*>self.thisptr
+ ptr.AddFace(len(verts), i_v)
+
+ def GetFace(self, idx):
+ """ GetFace(idx)
+
+ Get the face vertex indicies for the given face index `idx`
+
+ :param idx: int -- Face index to return
+ :returns: (N,) array -- Vertices array for face with index `idx`
+ """
+ ptr = <_CSPrimPolyhedron*>self.thisptr
+ assert idx>=0 and idx<ptr.GetNumFaces(), "Error: invalid face index"
+ cdef int *i_v
+ cdef unsigned int numVert=0
+ i_v = ptr.GetFace(idx, numVert)
+ assert i_v!=NULL
+ face = np.zeros(numVert, np.int)
+ for n in range(numVert):
+ face[n] = i_v[n]
+ return face
+
+ def GetNumFaces(self):
+ """
+ Get the number of faces.
+
+ :return num: int -- number of faces
+ """
+ ptr = <_CSPrimPolyhedron*>self.thisptr
+ return ptr.GetNumFaces()
+
+###############################################################################
+cdef class CSPrimPolyhedronReader(CSPrimPolyhedron):
+ """ Polyhedron Reader
+
+ This primives creates a polyhedron by reading a STL or PLY file.
+
+ Parameters
+ ----------
+ filename : str
+ File name to read
+ """
+ def __init__(self, ParameterSet pset, CSProperties prop, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = new _CSPrimPolyhedronReader(pset.thisptr, prop.thisptr)
+ if 'filename' in kw:
+ self.SetFilename(kw['filename'])
+ del kw['filename']
+ super(CSPrimPolyhedronReader, self).__init__(pset, prop, *args, **kw)
+
+ def SetFilename(self, fn):
+ """ SetFilename(fn)
+
+ Set the file name to read. This will try set the propper file type as well.
+
+ :param fn: str -- File name to read
+ """
+ ptr = <_CSPrimPolyhedronReader*>self.thisptr
+ if fn.endswith('.stl'):
+ self.SetFileType(1)
+ elif fn.endswith('.ply'):
+ self.SetFileType(2)
+ else:
+ self.SetFileType(0)
+ ptr.SetFilename(fn.encode('UTF-8'))
+
+ def GetFilename(self):
+ """
+ Get the file name.
+
+ :returns fn: str -- File name to read
+ """
+ ptr = <_CSPrimPolyhedronReader*>self.thisptr
+ return ptr.GetFilename()
+
+ def SetFileType(self, t):
+ """ SetFileType(t)
+
+ Set the file type. 1 --> STL-File, 2 --> PLY, 0 --> other/unknown
+
+ :param t: int -- File type (see above)
+ """
+ ptr = <_CSPrimPolyhedronReader*>self.thisptr
+ ptr.SetFileType(t)
+
+ def GetFileType(self):
+ """
+ Get the file type. 1 --> STL-File, 2 --> PLY, 0 --> other/unknown
+
+ :return t: int -- File type (see above)
+ """
+ ptr = <_CSPrimPolyhedronReader*>self.thisptr
+ return ptr.GetFileType()
+
+ def ReadFile(self):
+ """
+ Issue to read the file.
+
+ :return succ: bool -- True on successful read
+ """
+ ptr = <_CSPrimPolyhedronReader*>self.thisptr
+ return ptr.ReadFile()
diff --git a/CSXCAD/python/CSXCAD/CSProperties.pxd b/CSXCAD/python/CSXCAD/CSProperties.pxd
new file mode 100644
index 0000000..7b47e1a
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/CSProperties.pxd
@@ -0,0 +1,218 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from libcpp.string cimport string
+from libcpp.vector cimport vector
+from libcpp cimport bool
+
+from ParameterObjects cimport _ParameterSet, ParameterSet
+from CSPrimitives cimport _CSPrimitives, CSPrimitives
+from CSXCAD cimport ContinuousStructure
+
+cdef extern from "CSXCAD/CSProperties.h":
+ cpdef enum PropertyType "CSProperties::PropertyType":
+ ANY "CSProperties::ANY"
+ UNKNOWN "CSProperties::UNKNOWN"
+ MATERIAL "CSProperties::MATERIAL"
+ METAL "CSProperties::METAL"
+ EXCITATION "CSProperties::EXCITATION"
+ PROBEBOX "CSProperties::PROBEBOX"
+ RESBOX "CSProperties::RESBOX"
+ DUMPBOX "CSProperties::DUMPBOX"
+ DISPERSIVEMATERIAL "CSProperties::DISPERSIVEMATERIAL"
+ LORENTZMATERIAL "CSProperties::LORENTZMATERIAL"
+ DEBYEMATERIAL "CSProperties::DEBYEMATERIAL"
+ DISCRETE_MATERIAL "CSProperties::DISCRETE_MATERIAL"
+ LUMPED_ELEMENT "CSProperties::LUMPED_ELEMENT"
+ CONDUCTINGSHEET "CSProperties::CONDUCTINGSHEET"
+
+cdef extern from "CSXCAD/CSProperties.h":
+ cdef cppclass _CSProperties "CSProperties":
+ _CSProperties(_ParameterSet*) except +
+ int GetType()
+ string GetTypeString()
+
+ _ParameterSet* GetParameterSet()
+
+ void SetName(string name)
+ string GetName()
+
+ int GetQtyPrimitives()
+ _CSPrimitives* GetPrimitive(size_t index)
+
+ bool ExistAttribute(string name)
+ string GetAttributeValue(string name)
+ void AddAttribute(string name, string value)
+
+ void SetFillColor(unsigned char R, unsigned char G, unsigned char B, unsigned char a)
+ void SetEdgeColor(unsigned char R, unsigned char G, unsigned char B, unsigned char a)
+
+cdef class CSProperties:
+ cdef _CSProperties *thisptr
+ cdef __SetPtr(self, _CSProperties *ptr)
+ cdef __GetPrimitive(self, size_t index)
+ cdef readonly ContinuousStructure __CSX
+ cdef readonly ParameterSet __paraset
+ cdef readonly list __primitives
+
+##############################################################################
+cdef extern from "CSXCAD/CSPropMaterial.h":
+ cdef cppclass _CSPropMaterial "CSPropMaterial" (_CSProperties):
+ _CSPropMaterial(_ParameterSet*) except +
+ void SetEpsilon(double val, int ny)
+ double GetEpsilon(int ny)
+ int SetEpsilonWeightFunction(string fct, int ny)
+ string GetEpsilonWeightFunction(int ny)
+
+ void SetMue(double val, int ny)
+ double GetMue(int ny)
+ int SetMueWeightFunction(string fct, int ny)
+ string GetMueWeightFunction(int ny)
+
+ void SetKappa(double val, int ny)
+ double GetKappa(int ny)
+ int SetKappaWeightFunction(string fct, int ny)
+ string GetKappaWeightFunction(int ny)
+
+ void SetSigma(double val, int ny)
+ double GetSigma(int ny)
+ int SetSigmaWeightFunction(string fct, int ny)
+ string GetSigmaWeightFunction(int ny)
+
+ void SetDensity(double val)
+ double GetDensity()
+ int SetDensityWeightFunction(string fct)
+ string GetDensityWeightFunction()
+
+ void SetIsotropy(bool val)
+ bool GetIsotropy()
+
+cdef class CSPropMaterial(CSProperties):
+ pass
+
+##############################################################################
+cdef extern from "CSXCAD/CSPropLumpedElement.h":
+ cdef cppclass _CSPropLumpedElement "CSPropLumpedElement" (_CSProperties):
+ _CSPropLumpedElement(_ParameterSet*) except +
+ void SetResistance(double val)
+ double GetResistance()
+
+ void SetCapacity(double val)
+ double GetCapacity()
+
+ void SetInductance(double val)
+ double GetInductance()
+
+ void SetDirection(int ny)
+ int GetDirection()
+
+ void SetCaps(bool val)
+ int GetCaps()
+
+cdef class CSPropLumpedElement(CSProperties):
+ pass
+
+##############################################################################
+cdef extern from "CSXCAD/CSPropMetal.h":
+ cdef cppclass _CSPropMetal "CSPropMetal" (_CSProperties):
+ _CSPropMetal(_ParameterSet*) except +
+
+cdef class CSPropMetal(CSProperties):
+ pass
+
+##############################################################################
+cdef extern from "CSXCAD/CSPropConductingSheet.h":
+ cdef cppclass _CSPropConductingSheet "CSPropConductingSheet" (_CSPropMetal):
+ _CSPropConductingSheet(_ParameterSet*) except +
+ void SetConductivity(double val)
+ double GetConductivity()
+
+ void SetThickness(double val)
+ double GetThickness()
+
+cdef class CSPropConductingSheet(CSPropMetal):
+ pass
+
+##############################################################################
+cdef extern from "CSXCAD/CSPropExcitation.h":
+ cdef cppclass _CSPropExcitation "CSPropExcitation" (_CSProperties):
+ _CSPropExcitation(_ParameterSet*) except +
+ void SetExcitType(int val)
+ int GetExcitType()
+
+ void SetExcitation(double val, int Component)
+ double GetExcitation(int Component)
+
+ void SetPropagationDir(double val, int Component)
+ double GetPropagationDir(int Component)
+
+ int SetWeightFunction(string fct, int ny)
+ string GetWeightFunction(int ny)
+
+ void SetFrequency(double val)
+ double GetFrequency()
+
+ void SetDelay(double val)
+ double GetDelay()
+
+cdef class CSPropExcitation(CSProperties):
+ pass
+
+##############################################################################
+cdef extern from "CSXCAD/CSPropProbeBox.h":
+ cdef cppclass _CSPropProbeBox "CSPropProbeBox" (_CSProperties):
+ _CSPropProbeBox(_ParameterSet*) except +
+ void SetProbeType(int type)
+ int GetProbeType()
+
+ void SetWeighting(double weight)
+ double GetWeighting()
+
+ void SetNormalDir(unsigned int ndir)
+ int GetNormalDir()
+
+ size_t CountFDSamples()
+ vector[double]* GetFDSamples()
+ void ClearFDSamples()
+ void AddFDSample(double freq)
+
+cdef class CSPropProbeBox(CSProperties):
+ pass
+
+
+##############################################################################
+cdef extern from "CSXCAD/CSPropDumpBox.h":
+ cdef cppclass _CSPropDumpBox "CSPropDumpBox" (_CSPropProbeBox):
+ _CSPropDumpBox(_ParameterSet*) except +
+ void SetDumpType(int _type)
+ int GetDumpType()
+
+ void SetDumpMode(int mode)
+ int GetDumpMode()
+
+ void SetFileType(int ftype)
+ int GetFileType()
+
+ void SetOptResolution(int ny, double val)
+ double GetOptResolution(int ny)
+
+ void SetSubSampling(int ny, unsigned int val)
+ unsigned int GetSubSampling(int ny)
+
+cdef class CSPropDumpBox(CSPropProbeBox):
+ pass
diff --git a/CSXCAD/python/CSXCAD/CSProperties.pyx b/CSXCAD/python/CSXCAD/CSProperties.pyx
new file mode 100644
index 0000000..00b998c
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/CSProperties.pyx
@@ -0,0 +1,1163 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""
+Module for all Properties like metal, material, propes and dumps
+
+Notes
+-----
+Usually it is not meant to create properties manually, but instead
+use the ContinuousStructure object to create properties using the
+e.g. AddMaterial or AddMetal methods.
+
+
+Examples
+--------
+Create a metal property:
+
+>>> pset = ParameterObjects.ParameterSet()
+>>> metal = CSProperties.CSPropMetal(pset)
+"""
+
+import numpy as np
+from ParameterObjects cimport _ParameterSet, ParameterSet
+cimport CSProperties
+cimport CSPrimitives as c_CSPrimitives
+from CSPrimitives import CSPrimitives
+from Utilities import CheckNyDir
+
+def hex2color(color):
+ if color.startswith('#'):
+ color = color.lstrip('#')
+ rgb = tuple(int(color[i:i+2], 16) for i in (0, 2 ,4))
+ return rgb
+ else:
+ return None
+
+cdef class CSProperties:
+ """
+ Virtual base class for all properties, cannot be created!
+
+ """
+
+ @staticmethod
+ def fromType(p_type, pset, no_init=False, **kw):
+ """ fromType(p_type, pset, no_init=False, **kw)
+
+ Create a property specified by the `p_type`
+
+ :param p_type: Property type
+ :param pset: ParameterSet to assign to the new primitive
+ :param no_init: do not create an actual C++ instance
+ """
+ prop = None
+ if p_type == CONDUCTINGSHEET + METAL:
+ prop = CSPropConductingSheet(pset, no_init=no_init, **kw)
+ elif p_type == METAL:
+ prop = CSPropMetal(pset, no_init=no_init, **kw)
+ elif p_type == MATERIAL:
+ prop = CSPropMaterial(pset, no_init=no_init, **kw)
+ elif p_type == LUMPED_ELEMENT:
+ prop = CSPropLumpedElement(pset, no_init=no_init, **kw)
+ elif p_type == EXCITATION:
+ prop = CSPropExcitation(pset, no_init=no_init, **kw)
+ elif p_type == PROBEBOX:
+ prop = CSPropProbeBox(pset, no_init=no_init, **kw)
+ elif p_type == DUMPBOX:
+ prop = CSPropDumpBox(pset, no_init=no_init, **kw)
+
+ return prop
+
+ @staticmethod
+ def fromTypeName(type_str, pset, no_init=False, **kw):
+ """ fromTypeName(type_str, pset, no_init=False, **kw)
+
+ Create a property specified by the `type_str`
+
+ :param type_str: Property type name string
+ :param pset: ParameterSet to assign to the new primitive
+ :param no_init: do not create an actual C++ instance
+ """
+ prop = None
+ if type_str=='Material':
+ prop = CSPropMaterial(pset, no_init=no_init, **kw)
+ elif type_str=='LumpedElement':
+ prop = CSPropLumpedElement(pset, no_init=no_init, **kw)
+ elif type_str=='Metal':
+ prop = CSPropMetal(pset, no_init=no_init, **kw)
+ elif type_str=='ConductingSheet':
+ prop = CSPropConductingSheet(pset, no_init=no_init, **kw)
+ elif type_str=='Excitation':
+ prop = CSPropExcitation(pset, no_init=no_init, **kw)
+ elif type_str=='ProbeBox':
+ prop = CSPropProbeBox(pset, no_init=no_init, **kw)
+ elif type_str=='DumpBox':
+ prop = CSPropDumpBox(pset, no_init=no_init, **kw)
+ return prop
+
+ def __init__(self, ParameterSet pset, *args, no_init=False, **kw):
+ self.__CSX = None
+ # internal list of primitives
+ self.__primitives = []
+ if no_init:
+ self.thisptr = NULL
+ return
+ assert self.thisptr, "Error, cannot create CSProperties (protected)"
+
+ self.__paraset = ParameterSet(no_init=True)
+ self.__paraset.thisptr = self.thisptr.GetParameterSet()
+
+ assert len(kw)==0, 'Unknown keywords: {}'.format(kw)
+
+ cdef __SetPtr(self, _CSProperties *ptr):
+ self.thisptr = ptr
+
+ def GetQtyPrimitives(self):
+ """
+ Get the number of primitives assigned to this property
+
+ :returns: int -- Number of primitives
+ """
+ return self.thisptr.GetQtyPrimitives()
+
+ def GetPrimitive(self, index):
+ return self.__GetPrimitive(index)
+
+ def GetAllPrimitives(self):
+ return [self.GetPrimitive(n) for n in range(self.GetQtyPrimitives())]
+
+ cdef __GetPrimitive(self, size_t index):
+ cdef _CSPrimitives *_prim
+ cdef CSPrimitives prim
+ _prim = self.thisptr.GetPrimitive(index)
+ if self.__primitives is None:
+ self.__primitives = []
+ for p in self.__primitives:
+ prim = p
+ if prim.thisptr == _prim:
+ return p
+ prim = CSPrimitives.fromType(_prim.GetType(), pset=self.__paraset, prop=self, no_init=True)
+ prim.thisptr = _prim
+ self.__primitives.append(prim)
+ return prim
+
+ def GetType(self):
+ """ Get the type of the property
+
+ :returns: int -- Type ID of this property
+ """
+ return self.thisptr.GetType()
+
+ def GetTypeString(self):
+ """ Get the type of the property as a string
+
+ :returns: str -- Type name of this property type
+ """
+ return self.thisptr.GetTypeString().decode('UTF-8')
+
+ def GetParameterSet(self):
+ """
+ Get the parameter set assigned to this class
+ """
+ return self.__paraset
+
+ def SetName(self, name):
+ """ SetName(name)
+
+ Set the name of this property
+
+ :params name: str -- Name for this property
+ """
+ self.thisptr.SetName(name.encode('UTF-8'))
+
+ def GetName(self):
+ """
+ Get the name of this property
+
+ :returns: str -- Name for this property
+ """
+ return self.thisptr.GetName().decode('UTF-8')
+
+ def SetColor(self, color, alpha=255):
+ """ SetColor(color, alpha=255)
+
+ Set the fill and edge color for this property.
+
+ :param color: hex color value
+ :param alpha: transparency value
+ """
+ self.SetFillColor(color, alpha)
+ self.SetEdgeColor(color, alpha)
+
+ def SetFillColor(self, color, alpha=255):
+ """ SetFillColor(color, alpha=255)
+
+ Set the fill color for this property.
+
+ :param color: hex color value
+ :param alpha: transparency value
+ """
+ rgb = hex2color(color)
+ self.thisptr.SetFillColor(rgb[0], rgb[1], rgb[2], alpha)
+
+ def SetEdgeColor(self, color, alpha=255):
+ """ SetColor(color, alpha=255)
+
+ Set the edge color for this property.
+
+ :param color: hex color value
+ :param alpha: transparency value
+ """
+ rgb = hex2color(color)
+ self.thisptr.SetEdgeColor(rgb[0], rgb[1], rgb[2], alpha)
+
+ def ExistAttribute(self, name):
+ """ ExistAttribute(name)
+
+ Check if an attribute with the given `name` exists
+
+ :param name: str -- Attribute name
+ :returns: bool
+ """
+ return self.thisptr.ExistAttribute(name.encode('UTF-8'))
+
+ def GetAttributeValue(self, name):
+ """ GetAttributeValue(name)
+
+ Get the value of the attribute with the given `name`
+
+ :param name: str -- Attribute name
+ :returns: str -- Attribute value
+ """
+ return self.thisptr.GetAttributeValue(name.encode('UTF-8')).decode('UTF-8')
+
+ def AddAttribute(self, name, val):
+ """ AddAttribute(name, val)
+
+ Add an attribure and value
+
+ :param name: str -- Attribute name
+ :param val: str -- Attribute value
+ """
+ self.thisptr.AddAttribute(name.encode('UTF-8'), val.encode('UTF-8'))
+
+ def AddPoint(self, coord, **kw):
+ """ AddPoint(coord, **kw)
+
+ Add a point to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimPoint : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.POINT, coord=coord, **kw)
+
+ def AddBox(self, start, stop, **kw):
+ """ AddBox(start, stop, **kw)
+
+ Add a box to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimBox : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.BOX, start=start, stop=stop, **kw)
+
+ def AddCylinder(self, start, stop, radius, **kw):
+ """ AddCylinder(start, stop, radius, **kw)
+
+ Add a cylinder to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimCylinder : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.CYLINDER, start=start, stop=stop, radius=radius, **kw)
+
+ def AddCylindricalShell(self, start, stop, radius, shell_width, **kw):
+ """ AddCylindricalShell(start, stop, radius, shell_width, **kw)
+
+ Add a cylindrical shell to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimCylindricalShell : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.CYLINDRICALSHELL, start=start, stop=stop, radius=radius, shell_width=shell_width, **kw)
+
+ def AddSphere(self, center, radius, **kw):
+ """ AddSphere(center, radius, **kw)
+
+ Add a sphere to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimSphere : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.SPHERE, center=center, radius=radius, **kw)
+
+ def AddSphericalShell(self, center, radius, shell_width, **kw):
+ """ AddSphericalShell(center, radius, shell_width, **kw)
+
+ Add a spherical shell to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimSphericalShell : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.SPHERICALSHELL, center=center, radius=radius, shell_width=shell_width, **kw)
+
+ def AddPolygon(self, points, norm_dir, elevation, **kw):
+ """ AddPolygon(points, norm_dir, elevation, **kw)
+
+ Add a polygon to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimPolygon : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.POLYGON, points=points, norm_dir=norm_dir, elevation=elevation, **kw)
+
+ def AddLinPoly(self, points, norm_dir, elevation, length, **kw):
+ """ AddLinPoly(points, norm_dir, elevation, length, **kw)
+
+ Add a linear extruded polygon to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimLinPoly : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.LINPOLY, points=points, norm_dir=norm_dir, elevation=elevation, length=length, **kw)
+
+ def AddRotPoly(self, points, norm_dir, elevation, rot_axis, angle, **kw):
+ """ AddRotPoly(points, norm_dir, elevation, rot_axis, angle, **kw)
+
+ Add a rotated polygon to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimRotPoly : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.ROTPOLY, points=points, norm_dir=norm_dir, elevation=elevation, rot_axis=rot_axis, angle=angle, **kw)
+
+ def AddCurve(self, points, **kw):
+ """ AddCurve(points, **kw)
+
+ Add a curve to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimCurve : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.CURVE, points=points, **kw)
+
+ def AddWire(self, points, radius, **kw):
+ """ AddWire(points, radius, **kw)
+
+ Add a wire to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimWire : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.WIRE, points=points, radius=radius, **kw)
+
+ def AddPolyhedron(self, **kw):
+ """ AddPolyhedron(**kw)
+
+ Add a polyhedron to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimPolyhedron : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.POLYHEDRON, **kw)
+
+ def AddPolyhedronReader(self, filename, **kw):
+ """ AddPolyhedronReader(filename, **kw)
+
+ Add a polyhedron from file to this property.
+
+ See Also
+ --------
+ CSXCAD.CSPrimitives.CSPrimPolyhedronReader : See here for details on primitive arguments
+ """
+ return self.__CreatePrimitive(c_CSPrimitives.POLYHEDRONREADER, filename=filename, **kw)
+
+ def __CreatePrimitive(self, prim_type, **kw):
+ pset = self.GetParameterSet()
+ prim = CSPrimitives.fromType(prim_type, pset, self, **kw)
+ if prim is None:
+ raise Exception('CreatePrimitive: Unknown primitive type requested!')
+ self.__primitives.append(prim)
+ return prim
+
+###############################################################################
+cdef class CSPropMaterial(CSProperties):
+ """ General material property
+
+ This is a material with options to define relative electric permeability
+ (`eplsilon`), relative magnetic permittivity (`mue`), electric conductivity
+ (`kappa`), magnetic conductivity (`sigma`) and `density`.
+
+ :params epsilon: scalar or vector - relative electric permeability
+ :params mue: scalar or vector - relative magnetic permittivity
+ :params kappa: scalar or vector - relectric conductivity
+ :params sigma: scalar or vector - magnetic conductivity
+ :params density: float - Density
+ """
+ def __init__(self, ParameterSet pset, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = <_CSProperties*> new _CSPropMaterial(pset.thisptr)
+
+ self.SetMaterialProperty(**kw)
+ for k in list(kw.keys()):
+ if k in ['epsilon', 'mue', 'kappa', 'sigma', 'density']:
+ del kw[k]
+
+ super(CSPropMaterial, self).__init__(pset, *args, **kw)
+
+ def SetIsotropy(self, val):
+ """ SetIsotropy(val)
+
+ Set isotropy status for this material.
+
+ :param val: bool -- enable/disable isotropy
+ """
+ (<_CSPropMaterial*>self.thisptr).SetIsotropy(val)
+
+ def GetIsotropy(self):
+ """
+ Get isotropy status for this material.
+
+ :returns: bool -- isotropy status
+ """
+ return (<_CSPropMaterial*>self.thisptr).GetIsotropy()
+
+ def SetMaterialProperty(self, **kw):
+ """ SetMaterialProperty(**kw)
+ Set the material properties.
+
+ :params epsilon: scalar or vector - relative electric permeability
+ :params mue: scalar or vector - relative magnetic permittivity
+ :params kappa: scalar or vector - relectric conductivity
+ :params sigma: scalar or vector - magnetic conductivity
+ :params density: float - Density
+ """
+ for prop_name in kw:
+ val = kw[prop_name]
+ if prop_name == 'density':
+ (<_CSPropMaterial*>self.thisptr).SetDensity(val)
+ continue
+ if type(val)==float or type(val)==int:
+ self.__SetMaterialPropertyDir(prop_name, 0, val)
+ continue
+ assert len(val)==3, 'SetMaterialProperty: "{}" must be a list or array of length 3'.format(prop_name)
+ for n in range(3):
+ self.__SetMaterialPropertyDir(prop_name, n, val[n])
+
+ def __SetMaterialPropertyDir(self, prop_name, ny, val):
+ if prop_name=='epsilon':
+ return (<_CSPropMaterial*>self.thisptr).SetEpsilon(val, ny)
+ elif prop_name=='mue':
+ return (<_CSPropMaterial*>self.thisptr).SetMue(val, ny)
+ elif prop_name=='kappa':
+ return (<_CSPropMaterial*>self.thisptr).SetKappa(val, ny)
+ elif prop_name=='sigma':
+ return (<_CSPropMaterial*>self.thisptr).SetSigma(val, ny)
+ else:
+ raise Exception('SetMaterialPropertyDir: Error, unknown material property')
+
+ def SetMaterialWeight(self, **kw):
+ """ SetMaterialWeight(**kw)
+
+ Set the material weighting function(s)
+
+ The functions can use the variables:
+ `x`,`y`,`z`
+ `rho` for the distance to z-axis
+ `r` for the distance to origin
+ `a` for alpha or phi (as in cylindircal and spherical coord systems)
+ `t` for theta (as in the spherical coord system
+
+ all these variables are not weighted with the drawing unit defined by
+ the grid
+
+ :params epsilon: str or str-vector - relative electric permeability
+ :params mue: str or str-vector - relative magnetic permittivity
+ :params kappa: str or str-vector - relectric conductivity
+ :params sigma: str or str-vector - magnetic conductivity
+ :params density: str - Density
+ """
+ for prop_name in kw:
+ val = kw[prop_name]
+ if prop_name == 'density':
+ (<_CSPropMaterial*>self.thisptr).SetDensityWeightFunction(val.encode('UTF-8'))
+ continue
+ if type(val)==str:
+ self.__SetMaterialWeightDir(prop_name, 0, val)
+ continue
+ assert len(val)==3, 'SetMaterialWeight: "{}" must be a list or array of length 3'.format(prop_name)
+ for n in range(3):
+ self.__SetMaterialWeightDir(prop_name, n, val[n])
+
+ def __SetMaterialWeightDir(self, prop_name, ny, val):
+ val = val.encode('UTF-8')
+ if prop_name=='epsilon':
+ return (<_CSPropMaterial*>self.thisptr).SetEpsilonWeightFunction(val, ny)
+ elif prop_name=='mue':
+ return (<_CSPropMaterial*>self.thisptr).SetMueWeightFunction(val, ny)
+ elif prop_name=='kappa':
+ return (<_CSPropMaterial*>self.thisptr).SetKappaWeightFunction(val, ny)
+ elif prop_name=='sigma':
+ return (<_CSPropMaterial*>self.thisptr).SetSigmaWeightFunction(val, ny)
+ else:
+ raise Exception('SetMaterialWeightDir: Error, unknown material property')
+
+ def GetMaterialProperty(self, prop_name):
+ """ SetMaterialProperty(prop_name)
+ Get the material property with of type `prop_name`.
+
+ :params prop_name: str -- material property type
+ :returns: float for isotropic material and `density` or else (3,) array
+ """
+ if prop_name == 'density':
+ return (<_CSPropMaterial*>self.thisptr).GetDensity()
+ if (<_CSPropMaterial*>self.thisptr).GetIsotropy():
+ return self.__GetMaterialPropertyDir(prop_name, 0)
+ val = np.zeros(3)
+ for n in range(3):
+ val[n] = self.__GetMaterialPropertyDir(prop_name, n)
+ return val
+
+ def __GetMaterialPropertyDir(self, prop_name, ny):
+ if prop_name=='epsilon':
+ return (<_CSPropMaterial*>self.thisptr).GetEpsilon(ny)
+ elif prop_name=='mue':
+ return (<_CSPropMaterial*>self.thisptr).GetMue(ny)
+ elif prop_name=='kappa':
+ return (<_CSPropMaterial*>self.thisptr).GetKappa(ny)
+ elif prop_name=='sigma':
+ return (<_CSPropMaterial*>self.thisptr).GetSigma(ny)
+ else:
+ raise Exception('GetMaterialPropertyDir: Error, unknown material property')
+
+ def GetMaterialWeight(self, prop_name):
+ """ GetMaterialWeight(prop_name)
+ Get the material weighting function(s).
+
+ :params prop_name: str -- material property type
+ :returns: str for isotropic material and `density` or else str array
+ """
+ if prop_name == 'density':
+ return (<_CSPropMaterial*>self.thisptr).GetDensityWeightFunction().decode('UTF-8')
+ if (<_CSPropMaterial*>self.thisptr).GetIsotropy():
+ return self.__GetMaterialWeightDir(prop_name, 0).decode('UTF-8')
+ val = ['', '', '']
+ for n in range(3):
+ val[n] = self.__GetMaterialWeightDir(prop_name, n).decode('UTF-8')
+ return val
+
+ def __GetMaterialWeightDir(self, prop_name, ny):
+ if prop_name=='epsilon':
+ return (<_CSPropMaterial*>self.thisptr).GetEpsilonWeightFunction(ny)
+ elif prop_name=='mue':
+ return (<_CSPropMaterial*>self.thisptr).GetMueWeightFunction(ny)
+ elif prop_name=='kappa':
+ return (<_CSPropMaterial*>self.thisptr).GetKappaWeightFunction(ny)
+ elif prop_name=='sigma':
+ return (<_CSPropMaterial*>self.thisptr).GetSigmaWeightFunction(ny)
+ else:
+ raise Exception('GetMaterialWeightDir: Error, unknown material property')
+
+
+###############################################################################
+cdef class CSPropLumpedElement(CSProperties):
+ """
+ Lumped element property.
+
+ A lumped element can consist of a resitor `R`, capacitor `C` and inductance
+ `L` active in a given direction `ny`.
+ If Caps are enable, a small PEC plate is added to each
+ end of the lumped element to ensure contact to a connecting line
+
+ :param ny: int or str -- direction: 0,1,2 or 'x','y','z' for the orientation of the lumped element
+ :param caps: bool -- enable/disable caps
+ :param R: float -- lumped resitance value
+ :param C: float -- lumped capacitance value
+ :param L: float -- lumped inductance value
+ """
+ def __init__(self, ParameterSet pset, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = <_CSProperties*> new _CSPropLumpedElement(pset.thisptr)
+
+ for k in kw:
+ if k=='R':
+ self.SetResistance(kw[k])
+ elif k=='L':
+ self.SetInductance(kw[k])
+ elif k=='C':
+ self.SetCapacity(kw[k])
+ elif k=='ny':
+ self.SetDirection(kw[k])
+ elif k=='caps':
+ self.SetCaps(kw[k])
+ for k in ['R', 'L', 'C', 'ny', 'caps']:
+ if k in kw:
+ del kw[k]
+
+ super(CSPropLumpedElement, self).__init__(pset, *args, **kw)
+
+ def SetResistance(self, val):
+ """ SetResistance(val)
+ """
+ (<_CSPropLumpedElement*>self.thisptr).SetResistance(val)
+
+ def GetResistance(self):
+ """ GetResistance()
+ """
+ return (<_CSPropLumpedElement*>self.thisptr).GetResistance()
+
+ def SetCapacity(self, val):
+ """ SetCapacity(val)
+ """
+ (<_CSPropLumpedElement*>self.thisptr).SetCapacity(val)
+
+ def GetCapacity(self):
+ """ GetCapacity()
+ """
+ return (<_CSPropLumpedElement*>self.thisptr).GetCapacity()
+
+ def SetInductance(self, val):
+ """ SetInductance(val)
+ """
+ (<_CSPropLumpedElement*>self.thisptr).SetInductance(val)
+
+ def GetInductance(self):
+ """ GetInductance()
+ """
+ return (<_CSPropLumpedElement*>self.thisptr).GetInductance()
+
+ def SetDirection(self, ny):
+ """ SetDirection(ny)
+ """
+ (<_CSPropLumpedElement*>self.thisptr).SetDirection(CheckNyDir(ny))
+
+ def GetDirection(self):
+ """ GetDirection()
+ """
+ return (<_CSPropLumpedElement*>self.thisptr).GetDirection()
+
+ def SetCaps(self, val):
+ """ SetCaps(val)
+ """
+ (<_CSPropLumpedElement*>self.thisptr).SetCaps(val)
+
+ def GetCaps(self):
+ """ GetCaps()
+ """
+ return (<_CSPropLumpedElement*>self.thisptr).GetCaps()==1
+
+
+###############################################################################
+cdef class CSPropMetal(CSProperties):
+ """ Metal property
+
+ A metal property is usually modeled as a perfect electric conductor (PEC).
+ It does not have any further arguments.
+
+ See Also
+ --------
+ CSPropConductingSheet : For all lossy conductor model with a finite conductivity
+ """
+ def __init__(self, ParameterSet pset, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = <_CSProperties*> new _CSPropMetal(pset.thisptr)
+ super(CSPropMetal, self).__init__(pset, *args, **kw)
+
+###############################################################################
+cdef class CSPropConductingSheet(CSPropMetal):
+ """ Conducting sheet model property
+
+ A conducting sheet is a model for a thin conducting metal sheet.
+
+ Notes
+ -----
+ Only 2D primitives (sheets) should be added to this property
+
+ :param conductivity: float -- finite conductivity e.g. 56e6 (S/m)
+ :param thickness: float -- finite modeled thickness (e.g. 18e-6)
+ """
+ def __init__(self, ParameterSet pset, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = <_CSProperties*> new _CSPropConductingSheet(pset.thisptr)
+
+ if 'conductivity' in kw:
+ self.SetConductivity(kw['conductivity'])
+ del kw['conductivity']
+ if 'thickness' in kw:
+ self.SetThickness(kw['thickness'])
+ del kw['thickness']
+ super(CSPropConductingSheet, self).__init__(pset, *args, **kw)
+
+ def SetConductivity(self, val):
+ """ SetConductivity(val)
+ """
+ (<_CSPropConductingSheet*>self.thisptr).SetConductivity(val)
+
+ def GetConductivity(self):
+ """ GetConductivity()
+ """
+ return (<_CSPropConductingSheet*>self.thisptr).GetConductivity()
+
+ def SetThickness(self, val):
+ """ SetThickness(val)
+ """
+ (<_CSPropConductingSheet*>self.thisptr).SetThickness(val)
+
+ def GetThickness(self):
+ """ GetThickness()
+ """
+ return (<_CSPropConductingSheet*>self.thisptr).GetThickness()
+
+###############################################################################
+cdef class CSPropExcitation(CSProperties):
+ """ Excitation property
+
+ An excitation property is defined to define the (field) sources.
+
+ Depending on the EM modeling tool there exist different excitation types
+ with different meanings.
+
+ :param exc_type: int -- excitation type (see SetExcitation)
+ :param exc_val: (3,) array like -- set the excitation vector
+ :param delay: float -- excitation delay in seconds
+ """
+ def __init__(self, ParameterSet pset, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = <_CSProperties*> new _CSPropExcitation(pset.thisptr)
+
+ if 'exc_type' in kw:
+ self.SetExcitType(kw['exc_type'])
+ del kw['exc_type']
+ if 'exc_val' in kw:
+ self.SetExcitation(kw['exc_val'])
+ del kw['exc_val']
+ if 'delay' in kw:
+ self.SetDelay(kw['delay'])
+ del kw['delay']
+ super(CSPropExcitation, self).__init__(pset, *args, **kw)
+
+ def SetExcitType(self, val):
+ """ SetExcitType(val)
+
+ :param val: int -- excitation type (see above)
+ """
+ (<_CSPropExcitation*>self.thisptr).SetExcitType(val)
+
+ def GetExcitType(self):
+ """ GetExcitType()
+ Get the excitation type.
+
+ :return: int -- excitation type (see above)
+ """
+ return (<_CSPropExcitation*>self.thisptr).GetExcitType()
+
+ def SetExcitation(self, val):
+ """ SetExcitation(val)
+
+ openEMS excitation types:
+
+ * 0 : E-field soft excitation
+ * 1 : E-field hard excitation
+ * 2 : H-field soft excitation
+ * 3 : H-field hard excitation
+ * 10 : plane wave excitation
+
+ :param val: (3,) array -- excitation vector
+ """
+ assert len(val)==3, "Error, excitation vector must be of dimension 3"
+ for n in range(3):
+ (<_CSPropExcitation*>self.thisptr).SetExcitation(val[n], n)
+
+ def GetExcitation(self):
+ """ GetExcitation()
+
+ :returns: (3,) array -- excitation vector
+ """
+ val = np.zeros(3)
+ for n in range(3):
+ val[n] = (<_CSPropExcitation*>self.thisptr).GetExcitation(n)
+ return val
+
+ def SetPropagationDir(self, val):
+ """ SetPropagationDir(val)
+
+ Set the propagation direction, e.g. for a plane wave excitation
+
+ :param val: (3,) array -- propagation vector
+ """
+ assert len(val)==3, "Error, excitation vector must be of dimension 3"
+ for n in range(3):
+ (<_CSPropExcitation*>self.thisptr).SetPropagationDir(val[n], n)
+
+ def GetPropagationDir(self):
+ """ GetPropagationDir()
+
+ Get the propagation direction, e.g. of a plane wave excitation
+
+ :returns: (3,) array -- propagation vector
+ """
+ val = np.zeros(3)
+ for n in range(3):
+ val[n] = (<_CSPropExcitation*>self.thisptr).GetPropagationDir(n)
+ return val
+
+ def SetWeightFunction(self, func):
+ """SetWeightFunction(func)
+
+ Set the weigthing function for the excitation.
+
+ """
+
+ assert len(func)==3, 'Error, excitation weighting function must be an array of length 3'
+ for n in range(3):
+ assert type(func[n]) is str, 'Error, excitation weighting function must be a string'
+ (<_CSPropExcitation*>self.thisptr).SetWeightFunction(func[n].encode('UTF-8'), n)
+
+ def GetWeightFunction(self):
+ """GetWeightFunction()
+
+ Get the weigthing function for the excitation.
+
+ :returns: 3 element list of strings
+ """
+
+ func = [None]*3
+ for n in range(3):
+ func[n] = (<_CSPropExcitation*>self.thisptr).GetWeightFunction(n).decode('UTF-8')
+ return func
+
+ def SetFrequency(self, val):
+ """ SetFrequency(val)
+
+ Frequency for numerical phase velocity compensation (optional)
+
+ :param val: float -- Frequency
+ """
+ (<_CSPropExcitation*>self.thisptr).SetFrequency(val)
+
+ def GetFrequency(self):
+ """ GetFrequency()
+ """
+ return (<_CSPropExcitation*>self.thisptr).GetFrequency()
+
+ def SetDelay(self, val):
+ """ SetDelay(val)
+
+ Set signal delay for this property.
+
+ :param val: float -- Signal delay
+ """
+ (<_CSPropExcitation*>self.thisptr).SetDelay(val)
+
+ def GetDelay(self):
+ """ GetDelay()
+ """
+ return (<_CSPropExcitation*>self.thisptr).GetDelay()
+
+###############################################################################
+cdef class CSPropProbeBox(CSProperties):
+ """
+ Probe propery.
+
+ Depending on the EM modeling tool there exist different probe types
+ with different meanings.
+
+ openEMS probe types:
+
+ * 0 : for voltage probing
+ * 1 : for current probing
+ * 2 : for E-field probing
+ * 3 : for H-field probing
+ * 10 : for waveguide voltage mode matching
+ * 11 : for waveguide current mode matching
+
+ :param p_type: probe type (default is 0)
+ :param weight: weighting factor (default is 1)
+ :param frequency: dump in the frequency domain at the given samples (in Hz)
+ :param mode_function: A mode function (used only with type 3/4 in openEMS)
+ :param norm_dir: necessary for current probing box with dimension not 2
+ """
+ def __init__(self, ParameterSet pset, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = <_CSProperties*> new _CSPropProbeBox(pset.thisptr)
+
+ if 'p_type' in kw:
+ self.SetProbeType(kw['p_type'])
+ del kw['p_type']
+ if 'weight' in kw:
+ self.SetWeighting(kw['weight'])
+ del kw['weight']
+ if 'norm_dir' in kw:
+ self.SetNormalDir(kw['norm_dir'])
+ del kw['norm_dir']
+ if 'frequency' in kw:
+ self.SetFrequency(kw['frequency'])
+ del kw['frequency']
+ if 'mode_function' in kw:
+ self.SetModeFunction(kw['mode_function'])
+ del kw['mode_function']
+ super(CSPropProbeBox, self).__init__(pset, *args, **kw)
+
+ def SetProbeType(self, val):
+ """ SetProbeType(val)
+ """
+ (<_CSPropProbeBox*>self.thisptr).SetProbeType(val)
+
+ def GetProbeType(self):
+ """ GetProbeType()
+ """
+ return (<_CSPropProbeBox*>self.thisptr).GetProbeType()
+
+ def SetWeighting(self, val):
+ """ SetWeighting(val)
+ """
+ (<_CSPropProbeBox*>self.thisptr).SetWeighting(val)
+
+ def GetWeighting(self):
+ """ GetWeighting()
+ """
+ return (<_CSPropProbeBox*>self.thisptr).GetWeighting()
+
+ def SetNormalDir(self, val):
+ """ SetNormalDir(val)
+ """
+ (<_CSPropProbeBox*>self.thisptr).SetNormalDir(val)
+
+ def GetNormalDir(self):
+ """ GetNormalDir()
+ """
+ return (<_CSPropProbeBox*>self.thisptr).GetNormalDir()
+
+ def AddFrequency(self, freq):
+ """ AddFrequency(freq)
+ """
+ if np.isscalar(freq):
+ (<_CSPropProbeBox*>self.thisptr).AddFDSample(freq)
+ else:
+ for f in freq:
+ (<_CSPropProbeBox*>self.thisptr).AddFDSample(f)
+
+ def ClearFrequency(self):
+ """ ClearFrequency()
+ """
+ (<_CSPropProbeBox*>self.thisptr).ClearFDSamples()
+
+ def SetFrequency(self, freq):
+ """ SetFrequency(freq)
+ """
+ self.ClearFrequency()
+ self.AddFrequency(freq)
+
+ def GetFrequency(self):
+ """ GetFrequency
+ """
+ cdef vector[double]* _freq = (<_CSPropProbeBox*>self.thisptr).GetFDSamples()
+ Nf = _freq.size()
+ freq = np.zeros(Nf)
+ for n in range(Nf):
+ freq[n] = _freq.at(n)
+ return freq
+
+ def GetFrequencyCount(self):
+ """ GetFrequencyCount()
+ """
+ return (<_CSPropProbeBox*>self.thisptr).CountFDSamples()
+
+ def SetModeFunction(self, mode_fun):
+ """ SetModeFunction(mode_fun)
+ """
+ assert len(mode_fun)==3, 'SetModeFunction: mode_fun must be list of length 3'
+ self.AddAttribute('ModeFunctionX', str(mode_fun[0]))
+ self.AddAttribute('ModeFunctionY', str(mode_fun[1]))
+ self.AddAttribute('ModeFunctionZ', str(mode_fun[2]))
+
+###############################################################################
+cdef class CSPropDumpBox(CSPropProbeBox):
+ """
+ Dump property to create field dumps.
+
+ Depending on the EM modeling tool there exist different dump types, dump
+ modes and file types with different meanings.
+
+ openEMS dump types:
+
+ * 0 : for E-field time-domain dump (default)
+ * 1 : for H-field time-domain dump
+ * 2 : for electric current time-domain dump
+ * 3 : for total current density (rot(H)) time-domain dump
+
+ * 10 : for E-field frequency-domain dump
+ * 11 : for H-field frequency-domain dump
+ * 12 : for electric current frequency-domain dump
+ * 13 : for total current density (rot(H)) frequency-domain dump
+
+ * 20 : local SAR frequency-domain dump
+ * 21 : 1g averaging SAR frequency-domain dump
+ * 22 : 10g averaging SAR frequency-domain dump
+
+ * 29 : raw data needed for SAR calculations (electric field FD, cell volume, conductivity and density)
+
+ openEMS dump modes:
+
+ * 0 : no-interpolation
+ * 1 : node-interpolation (default, see warning below)
+ * 2 : cell-interpolation (see warning below)
+
+ openEMS file types:
+
+ * 0 : vtk-file (default)
+ * 1 : hdf5-file (easier to read by python, using h5py)
+
+ :param dump_type: dump type (see above)
+ :param dump_mode: dump mode (see above)
+ :param file_type: file type (see above)
+ :param frequency: specify a frequency vector (required for dump types >=10)
+ :param sub_sampling: field domain sub-sampling, e.g. '2,2,4'
+ :param opt_resolution: field domain dump resolution, e.g. '10' or '10,20,5'
+
+ Notes
+ -----
+ openEMS FDTD Interpolation abnormalities:
+
+ * no-interpolation:
+ fields are located in the mesh by the Yee-scheme, the mesh only
+ specifies E- or H-Yee-nodes --> use node- or cell-interpolation or
+ be aware of the offset
+ * E-field dump & node-interpolation:
+ normal electric fields on boundaries will have false amplitude due to
+ forward/backward interpolation in case of (strong) changes in material
+ permittivity or on metal surfaces
+ --> use no- or cell-interpolation
+ * H-field dump & cell-interpolation:
+ normal magnetic fields on boundaries will have false amplitude due to
+ forward/backward interpolation in case of (strong) changes in material
+ permeability --> use no- or node-interpolation
+ """
+ def __init__(self, ParameterSet pset, *args, no_init=False, **kw):
+ if no_init:
+ self.thisptr = NULL
+ return
+ if not self.thisptr:
+ self.thisptr = <_CSProperties*> new _CSPropDumpBox(pset.thisptr)
+
+ if 'dump_type' in kw:
+ self.SetDumpType(kw['dump_type'])
+ del kw['dump_type']
+ if 'dump_mode' in kw:
+ self.SetDumpMode(kw['dump_mode'])
+ del kw['dump_mode']
+ if 'file_type' in kw:
+ self.SetFileType(kw['file_type'])
+ del kw['file_type']
+ if 'opt_resolution' in kw:
+ self.SetOptResolution(kw['opt_resolution'])
+ del kw['opt_resolution']
+ if 'sub_sampling' in kw:
+ self.SetSubSampling(kw['sub_sampling'])
+ del kw['sub_sampling']
+ super(CSPropDumpBox, self).__init__(pset, *args, **kw)
+
+ def SetDumpType(self, val):
+ """ SetDumpType(val)
+ """
+ (<_CSPropDumpBox*>self.thisptr).SetDumpType(val)
+
+ def GetDumpType(self):
+ """ GetDumpType()
+ """
+ return (<_CSPropDumpBox*>self.thisptr).GetDumpType()
+
+ def SetDumpMode(self, val):
+ """ SetDumpMode(val)
+ """
+ (<_CSPropDumpBox*>self.thisptr).SetDumpMode(val)
+
+ def GetDumpMode(self):
+ """ GetDumpMode()
+ """
+ return (<_CSPropDumpBox*>self.thisptr).GetDumpMode()
+
+ def SetFileType(self, val):
+ """ SetFileType(val)
+ """
+ (<_CSPropDumpBox*>self.thisptr).SetFileType(val)
+
+ def GetFileType(self):
+ """ GetFileType()
+ """
+ return (<_CSPropDumpBox*>self.thisptr).GetFileType()
+
+ def SetOptResolution(self, val):
+ """ SetOptResolution(val)
+ """
+ assert len(val)==3, 'SetOptResolution: value must be list or array of length 3'
+ for n in range(3):
+ (<_CSPropDumpBox*>self.thisptr).SetOptResolution(n, val[n])
+
+ def GetOptResolution(self):
+ """ GetOptResolution()
+ """
+ val = np.zeros(3)
+ for n in range(3):
+ val[n] = (<_CSPropDumpBox*>self.thisptr).GetOptResolution(n)
+ return val
+
+ def SetSubSampling(self, val):
+ """ SetSubSampling(val)
+ """
+ assert len(val)==3, "SetSubSampling: 'val' must be a list or array of length 3"
+ for n in range(3):
+ (<_CSPropDumpBox*>self.thisptr).SetSubSampling(n, val[n])
+
+ def GetSubSampling(self):
+ """ GetSubSampling()
+ """
+ val = np.zeros(3)
+ for n in range(3):
+ val[n] = (<_CSPropDumpBox*>self.thisptr).GetSubSampling(n)
+ return val
diff --git a/CSXCAD/python/CSXCAD/CSRectGrid.pxd b/CSXCAD/python/CSXCAD/CSRectGrid.pxd
new file mode 100644
index 0000000..7ae344e
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/CSRectGrid.pxd
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from libcpp.string cimport string
+from libcpp cimport bool
+
+cdef extern from "CSXCAD/CSXCAD_Global.h":
+ cpdef enum CoordinateSystem "CoordinateSystem":
+ CARTESIAN "CARTESIAN"
+ CYLINDRICAL "CYLINDRICAL"
+ UNDEFINED_CS "UNDEFINED_CS"
+
+cdef extern from "CSXCAD/CSRectGrid.h":
+ cdef cppclass _CSRectGrid "CSRectGrid":
+ _CSRectGrid() except +
+ void AddDiscLine(int direct, double val)
+
+ void clear()
+ void ClearLines(int direct)
+
+ void SetDeltaUnit(double val)
+ double GetDeltaUnit()
+
+ void Sort(int direct)
+ double* GetLines(int direct, double *array, unsigned int &qty, bool sorted)
+ size_t GetQtyLines(int direct)
+ double GetLine(int direct, size_t Index)
+
+ unsigned int Snap2LineNumber(int ny, double value, bool &inside)
+
+ int GetDimension()
+ void SetMeshType(CoordinateSystem cs_type)
+ CoordinateSystem GetMeshType()
+
+ void IncreaseResolution(int nu, int factor)
+ double* GetSimArea()
+ bool isValid()
+
+cdef class CSRectGrid:
+ cdef _CSRectGrid *thisptr
+ cdef bool no_init
diff --git a/CSXCAD/python/CSXCAD/CSRectGrid.pyx b/CSXCAD/python/CSXCAD/CSRectGrid.pyx
new file mode 100644
index 0000000..d47467b
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/CSRectGrid.pyx
@@ -0,0 +1,222 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""
+Rectilinear Grid Class for CSXCAD
+"""
+
+import numpy as np
+cimport CSRectGrid
+from Utilities import CheckNyDir
+from SmoothMeshLines import SmoothMeshLines
+
+cdef class CSRectGrid:
+ """
+ Rectilinear Grid Class for CSXCAD. The grid can be defined e.g. as a Cartesian
+ or cylindrical mesh and can hold mesh lines in the 3 fundamental directions.
+ E.g. x,y and z for the Cartesian and rho, a and z for the cylindrical mesh.
+
+ :param CoordSystem: define the coordinate system (default 0 : Cartesian)
+ """
+ def __cinit__(self, *args, no_init=False, **kw):
+ self.no_init = no_init
+ if no_init==False:
+ self.thisptr = new _CSRectGrid()
+ if 'CoordSystem' in kw:
+ self.SetMeshType(kw['CoordSystem'])
+ del kw['CoordSystem']
+ elif 'cs_type' in kw:
+ self.SetMeshType(kw['cs_type'])
+ del kw['cs_type']
+ else:
+ self.thisptr = NULL
+
+ assert len(kw)==0, 'Unknown keyword arguments: "{}"'.format(kw)
+
+ def __dealloc__(self):
+ if not self.no_init:
+ del self.thisptr
+
+ def SetMeshType(self, cs_type):
+ """ SetMeshType(cs_type)
+
+ Set the coordinate system type (Cartesian or cylindrical) for this mesh.
+
+ :param cs_type: coordinate system (0 : Cartesian, 1 : Cylindrical)
+ """
+ assert cs_type in [CARTESIAN, CYLINDRICAL], 'Unknown coordinate system: {}'.format(cs_type)
+ self.thisptr.SetMeshType(cs_type)
+
+ def GetMeshType(self):
+ return self.thisptr.GetMeshType()
+
+ def SetLines(self, ny, lines):
+ """ SetLines(ny, lines)
+
+ Set an array of lines. This will clear all previous defined lines in
+ the given direction.
+
+ :param ny: int or str -- direction definition
+ :param lines: array -- list of lines to be set in the given direction
+ """
+ ny = CheckNyDir(ny)
+
+ assert len(lines)>0, 'SetLines: "lines" must be an array or list'
+ self.thisptr.ClearLines(ny)
+ for n in range(len(lines)):
+ self.thisptr.AddDiscLine(ny, lines[n])
+
+ def AddLine(self, ny, line):
+ """ AddLine(ny, lines)
+
+ Add an array of lines. This will *not* clear the previous defined lines in
+ the given direction.
+
+ :param ny: int or str -- direction definition
+ :param lines: array -- list of lines to be added in the given direction
+ """
+ ny = CheckNyDir(ny)
+ if np.isscalar(line):
+ self.thisptr.AddDiscLine(ny, line)
+ return
+ assert len(line)>0, 'AddLine: "lines" must be a float, array or list'
+ for n in range(len(line)):
+ self.thisptr.AddDiscLine(ny, line[n])
+
+ def GetQtyLines(self, ny):
+ """ GetQtyLines(ny)
+
+ :param ny: int or str -- direction definition
+ """
+ ny = CheckNyDir(ny)
+ return self.thisptr.GetQtyLines(ny)
+
+ def GetLine(self, ny, idx):
+ """ GetLine(ny, idx)
+
+ Get the line in a given direction `ny` and index
+
+ :param ny: int or str -- direction definition
+ :param idx: int -- line index
+ """
+ ny = CheckNyDir(ny)
+ return self.thisptr.GetLine(ny, idx)
+
+ def GetLines(self, ny, do_sort=False):
+ """ GetLines(ny, do_sort=False)
+
+ Get all lines in a given direction `ny`.
+
+ :param ny: int or str -- direction definition
+ :param do_sort: bool -- sort lines
+ """
+ ny = CheckNyDir(ny)
+ cdef unsigned int N = 0
+ cdef double* array = NULL
+ array = self.thisptr.GetLines(ny, array, N, do_sort)
+ lines = np.zeros(N)
+ for n in range(N):
+ lines[n] = array[n]
+ return lines
+
+ def ClearLines(self, ny):
+ """ ClearLines(ny)
+
+ Clear all lines in a given direction `ny`.
+
+ :param ny: int or str -- direction definition
+ """
+ ny = CheckNyDir(ny)
+ self.thisptr.ClearLines(ny)
+
+ def SmoothMeshLines(self, ny, max_res, ratio=1.5):
+ """ SmoothMeshLines(ny, max_res, ratio=1.5)
+
+ Smooth all mesh lines in the given direction with a max. allowed resolution.
+
+ :param ny: int or str -- direction definition or 'all' for all directions
+ :param max_res: float -- max. allowed resolution
+ :param ratio: float -- max. allowed ration of mesh smoothing de/increase
+ """
+ if ny=='all':
+ for n in range(3):
+ self.SmoothMeshLines(n, max_res, ratio)
+ else:
+ lines = self.GetLines(ny)
+ lines = SmoothMeshLines(lines, max_res, ratio)
+ self.SetLines(ny, lines)
+
+ def Clear(self):
+ """
+ Clear all lines and delta unit.
+ """
+ self.thisptr.clear()
+
+ def SetDeltaUnit(self, unit):
+ """ SetDeltaUnit(unit)
+
+ Set the drawing unit for all mesh lines. Default is 1 (m)
+ """
+ self.thisptr.SetDeltaUnit(unit)
+
+ def GetDeltaUnit(self):
+ """
+ Get the drawing unit for all mesh lines.
+ """
+ return self.thisptr.GetDeltaUnit()
+
+ def Sort(self, ny='all'):
+ """ Sort(ny='all')
+
+ Sort mesh lines in the given direction or all directions.
+ """
+ if ny=='all':
+ for n in range(3):
+ self.thisptr.Sort(n)
+ else:
+ ny = CheckNyDir(ny)
+ self.thisptr.Sort(ny)
+
+ def Snap2LineNumber(self, ny, value):
+ """ Snap2LineNumber(ny, value)
+
+ Find a fitting mesh line index for the given direction and value.
+ """
+ ny = CheckNyDir(ny)
+ cdef bool inside=False
+ pos = self.thisptr.Snap2LineNumber(ny, value, inside)
+ return pos, inside>0
+
+ def GetSimArea(self):
+ """
+ Get the simulation area as defined by the mesh.
+
+ :returns: (2,3) array -- Simulation domain box
+ """
+ bb = np.zeros([2,3])
+ cdef double *_bb = self.thisptr.GetSimArea()
+ for n in range(3):
+ bb[0,n] = _bb[2*n]
+ bb[1,n] = _bb[2*n+1]
+ return bb
+
+ def IsValid(self):
+ """
+ Check if the mesh is valid. That is at least 2 mesh lines in all directions.
+ """
+ return self.thisptr.isValid()
diff --git a/CSXCAD/python/CSXCAD/CSTransform.pxd b/CSXCAD/python/CSXCAD/CSTransform.pxd
new file mode 100644
index 0000000..05a43e2
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/CSTransform.pxd
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from libcpp.string cimport string
+from libcpp cimport bool
+from ParameterObjects cimport _ParameterSet
+
+cdef extern from "CSXCAD/CSTransform.h":
+ cdef cppclass _CSTransform "CSTransform":
+ _CSTransform() except +
+ _CSTransform(_ParameterSet*) except +
+
+ void Reset()
+
+ double* Transform(double *inCoord, double *outCoord)
+ double* InvertTransform(double *inCoord, double *outCoord)
+
+ double* GetMatrix()
+
+ bool HasTransform()
+
+ void Translate(double *translate, bool concatenate)
+
+ void SetMatrix(double *matrix, bool concatenate)
+
+ void RotateOrigin(double *vector, double angle, bool concatenate)
+ void RotateXYZ(int ny, double angle, bool concatenate)
+
+ void Scale(double scale, bool concatenate)
+ void Scale(double *scale, bool concatenate)
+
+ void SetPreMultiply()
+ void SetPostMultiply()
+
+ void SetAngleRadian()
+
+cdef class CSTransform:
+ cdef _CSTransform *thisptr \ No newline at end of file
diff --git a/CSXCAD/python/CSXCAD/CSTransform.pyx b/CSXCAD/python/CSXCAD/CSTransform.pyx
new file mode 100644
index 0000000..80b7b04
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/CSTransform.pyx
@@ -0,0 +1,225 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""
+Affine Transformations for primitives
+"""
+
+import numpy as np
+from ParameterObjects cimport _ParameterSet, ParameterSet
+cimport CSTransform
+from Utilities import CheckNyDir
+
+cdef class CSTransform:
+ """
+ This class can realize affine transformations for all CSPrimtivies.
+ Individual tranformations can be concatenated to the previous. As a result
+ the order of transformations is important.
+ """
+ def __cinit__(self, ParameterSet pset=None, no_init=False, **kw):
+ if no_init==False:
+ if pset is None:
+ self.thisptr = new _CSTransform()
+ else:
+ self.thisptr = new _CSTransform(pset.thisptr)
+ self.thisptr.SetAngleRadian()
+ else:
+ self.thisptr = NULL
+
+ def Reset(self):
+ """
+ Reset all transformations.
+ """
+ self.thisptr.Reset()
+
+ def HasTransform(self):
+ """
+ Check if any transformations are set.
+ """
+ return self.thisptr.HasTransform()
+
+ def Transform(self, coord, invers=False):
+ """ Transform(coord, invers)
+
+ Apply a transformation to the given coordinate.
+
+ :param coord: (3,) array -- coordinate to transform
+ :param invers: bool -- do an invers transformation
+ :returns: (3,) array -- transformed coordinates
+ """
+ cdef double[3] d_coord
+ cdef double[3] d_out
+ for n in range(3):
+ d_coord[n] = coord[n]
+
+ if not invers:
+ self.thisptr.Transform(d_coord, d_out)
+ else:
+ self.thisptr.InvertTransform(d_coord, d_out)
+ out = np.zeros((3,))
+ for n in range(3):
+ out[n] = d_out[n]
+ return out
+
+ def GetMatrix(self):
+ """
+ Get the full 4x4 transformation matrix used for transformation.
+
+ :returns: (4,4) array -- transformation matrix
+ """
+ cdef double *d_mat = NULL
+ d_mat = self.thisptr.GetMatrix()
+ mat = np.zeros([4,4])
+ for n in range(4):
+ for m in range(4):
+ mat[n][m] = d_mat[4*n + m]
+
+ return mat
+
+ def AddTransform(self, transform, *args, **kw):
+ """ AddTransform(transform, *args, **kw)
+
+ Add a transform by name and arguments.
+
+ Examples
+ --------
+ Add a translation and 30° rotation around the z-axis:
+
+ >>> tr = CSTransform()
+ >>> tr.AddTransform('Translate', [10, 4,6])
+ >>> tr.AddTransform('RotateAxis', 'z', 30)
+
+ Add a rotation around the axis=[1, 1, 0] by pi/3 (30°):
+
+ >>> tr = CSTransform()
+ >>> tr.AddTransform('RotateOrigin', [1, 1, 0], np.pi/3, deg=False)
+
+ Available Transformation keywords:
+
+ * RotateAxis : Rotate around x,y or z-axis
+ * RotateOrigin : Rotate around a given axis
+ * Translate : Translation vector
+ * Scale : Scale value or vector
+ * Matrix : A affine transformation matrix as (4,4) array
+
+ :param transform: str -- transformation name or keyword.
+ """
+ assert type(transform)==str, 'AddTransform, transform name must be a string'
+ if transform == 'RotateAxis':
+ self.RotateAxis(*args, **kw)
+ elif transform == 'RotateOrigin':
+ self.RotateOrigin(*args, **kw)
+ elif transform == 'Translate':
+ self.Translate(*args, **kw)
+ elif transform == 'Scale':
+ self.Scale(*args, **kw)
+ elif transform in ['Matrix', 'SetMatrix']:
+ self.SetMatrix(*args, **kw)
+ else:
+ raise Exception('AddTransform: Unkown transformation "{}"'.format(transform))
+
+ def Translate(self, vec, concatenate=True):
+ """ Translate(vec, concatenate=True)
+
+ Add a trsanslation transformation.
+
+ :param vec: (3,) array -- translation vector
+ """
+ assert len(vec)==3, 'Translate vector must be a list or array of length 3'
+ cdef double[3] d_vec;
+ for n in range(3):
+ d_vec[n] = vec[n]
+ self.thisptr.Translate(d_vec, concatenate)
+
+
+ def SetMatrix(self, mat, concatenate=True):
+ """ SetMatrix(mat, concatenate=True)
+
+ Add an arbitrary (invertable) trsanslation matrix.
+
+ :param mat: (3,) array -- translation vector
+ """
+ mat = np.array(mat)
+ assert mat.shape == (4,4), 'SetMatrix: matrix must be of shape (4,4)'
+ cdef double[16] d_mat;
+ for n in range(4):
+ for m in range(4):
+ d_mat[4*n + m] = mat[n][m]
+ self.thisptr.SetMatrix(d_mat, concatenate)
+
+ def RotateOrigin(self, vec, angle, deg=True, concatenate=True):
+ """ RotateOrigin(vec, angle, deg=True, concatenate=True)
+
+ Add a rotation transformation around an arbitrary axis.
+
+ :param vec: (3,) array -- translation axis vector.
+ :param angle: float -- rotation angle (default in degrees)
+ :param deg: bool -- set degree or radiant for angle (default True)
+ """
+ assert len(vec)==3, 'RotateOrigin: axis vector must be a list or array of length 3'
+ cdef double[3] d_vec;
+ for n in range(3):
+ d_vec[n] = vec[n]
+ if deg:
+ angle = np.deg2rad(angle)
+ self.thisptr.RotateOrigin(d_vec, angle, concatenate)
+
+ def RotateAxis(self, ny, angle, deg=True, concatenate=True):
+ """ RotateAxis(ny, angle, deg=True, concatenate=True)
+
+ Add a rotation transformation around a cartesian axis (x,y or z).
+
+ :param ny: int or str -- translation axis vector 0/1/2 or 'x'/'y'/'z.
+ :param angle: float -- rotation angle (default in degrees)
+ :param deg: bool -- set degree or radiant for angle (default True)
+ """
+ ny = CheckNyDir(ny)
+ if deg:
+ angle = np.deg2rad(angle)
+ self.thisptr.RotateXYZ(ny, angle, concatenate)
+
+ def Scale(self, scale, bool concatenate=True):
+ """ Scale(scale, concatenate=True)
+
+ Add a scaleing transformation.
+
+ :param scale: float or (3,) array -- Scaling factor
+ """
+ cdef double[3] d_scale;
+ if type(scale)==float or type(scale)==int:
+ d_scale[0] = scale
+ self.thisptr.Scale(d_scale[0], concatenate)
+ return
+
+ assert len(scale)==3, 'Scale: scale must be a float or array of length 3'
+ for n in range(3):
+ d_scale[n] = scale[n]
+ self.thisptr.Scale(d_scale, concatenate)
+
+ def SetPreMultiply(self):
+ """
+ Set all following transformations as pre multiply (default is post multiply)
+ """
+ self.thisptr.SetPreMultiply()
+
+ def SetPostMultiply(self):
+ """
+ Set all following transformations as post multiply (default)
+ """
+ self.thisptr.SetPostMultiply()
+
diff --git a/CSXCAD/python/CSXCAD/CSXCAD.pxd b/CSXCAD/python/CSXCAD/CSXCAD.pxd
new file mode 100644
index 0000000..b95b7c1
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/CSXCAD.pxd
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from libcpp.string cimport string
+from libcpp cimport bool
+from libcpp.vector cimport vector
+
+cimport CSPrimitives
+cimport CSProperties
+
+from CSPrimitives cimport _CSPrimitives, CSPrimitives, PrimitiveType
+from ParameterObjects cimport _ParameterSet, ParameterSet
+from CSProperties cimport _CSProperties, CSProperties, PropertyType
+from CSRectGrid cimport _CSRectGrid, CSRectGrid, CoordinateSystem
+
+cdef extern from "CSXCAD/ContinuousStructure.h":
+ cdef cppclass _ContinuousStructure "ContinuousStructure":
+ _ContinuousStructure() except +
+ bool Write2XML(string)
+ string ReadFromXML(string)
+ _ParameterSet* GetParameterSet()
+
+ _CSRectGrid* GetGrid()
+
+ void SetCoordInputType(CoordinateSystem cs_type)
+
+ void AddProperty(_CSProperties* prop)
+ _CSProperties* GetProperty(int index)
+ int GetQtyPrimitives(PropertyType prop_type)
+ int GetQtyProperties()
+
+ _CSProperties* GetPropertyByCoordPriority(const double* coord, PropertyType prop_type, bool markFoundAsUsed, _CSPrimitives** foundPrimitive)
+
+ vector[_CSPrimitives*] GetAllPrimitives(bool sort, PropertyType prop_type)
+
+ vector[_CSProperties*] GetPropertiesByName(string name)
+ vector[_CSProperties*] GetPropertyByType(PropertyType prop_type)
+
+ string Update()
+
+cdef class ContinuousStructure:
+ cdef _ContinuousStructure *thisptr # hold a C++ instance which we're wrapping
+ cdef readonly ParameterSet __paraset
+ cdef readonly CSRectGrid __grid
+ cdef _AddProperty(self, CSProperties prop)
+ cdef _GetProperty(self, int index)
+ cdef __GetPropertyByCoordPriority(self, double* coord, PropertyType prop_type, bool markFoundAsUsed)
+ cdef __GetAllPrimitives(self, bool sort, PropertyType prop_type)
+ cdef __GetPropertiesByName(self, string name)
+ cdef __GetPropertyByType(self, PropertyType prop_type) \ No newline at end of file
diff --git a/CSXCAD/python/CSXCAD/CSXCAD.pyx b/CSXCAD/python/CSXCAD/CSXCAD.pyx
new file mode 100644
index 0000000..a8d5fa7
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/CSXCAD.pyx
@@ -0,0 +1,385 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+
+"""
+This moduld contains the main class ContinuousStructure (CSX).
+
+
+Examples
+--------
+
+>>> CSX = CSXCAD.ContinuousStructure()
+>>> metal = CSX.AddMetal('metal') # create a metal property
+>>> box = CSX.AddBox(metal, [0,0,0, [10,10,10]) # assign a box to the metal property
+
+>>> mesh = CSX.GetGrid() # get a grid instance
+>>> mesh.AddLine('x', [-20, 0, 20]) # add some lines in x-direction
+>>> mesh.SmoothMeshLines('x', 2.5) # smooth the mesh
+"""
+
+cimport CSXCAD
+
+from CSProperties import CSPropMaterial, CSPropExcitation
+from CSProperties import CSPropMetal, CSPropConductingSheet
+from CSProperties import CSPropLumpedElement, CSPropProbeBox, CSPropDumpBox
+from CSPrimitives import CSPrimPoint, CSPrimBox, CSPrimCylinder, CSPrimCylindricalShell
+from CSPrimitives import CSPrimSphere, CSPrimSphericalShell
+from CSPrimitives import CSPrimPolygon, CSPrimLinPoly, CSPrimRotPoly
+from CSPrimitives import CSPrimCurve, CSPrimWire
+from CSPrimitives import CSPrimPolyhedron, CSPrimPolyhedronReader
+cimport CSProperties as c_CSProperties
+cimport CSRectGrid as c_CSRectGrid
+from CSProperties import CSProperties
+from ParameterObjects import ParameterSet
+
+from SmoothMeshLines import SmoothMeshLines
+
+cdef class ContinuousStructure:
+ """ ContinuousStructure
+
+ With this class different properties and primitives can be created and a
+ rectengular grid assigned.
+
+ See Also
+ --------
+ CSXCAD.CSProperties
+ CSXCAD.CSPrimitives
+ CSXCAD.CSRectGrid
+
+ Examples
+ --------
+ Create a metal box:
+
+ >>> CSX = CSXCAD.ContinuousStructure()
+ >>> metal = CSX.AddMetal('metal') # create a metal property with name "metal"
+ >>> start = [0,0,0]
+ >>> stop = [1,2,1]
+ >>> box = CSX.AddBox(metal, start, stop) # Assign a box to propety "metal"
+ """
+ def __cinit__(self, **kw):
+ self.thisptr = new _ContinuousStructure()
+ self.__paraset = ParameterSet(no_init=True)
+ self.__paraset.thisptr = self.thisptr.GetParameterSet()
+
+ self.__grid = CSRectGrid(no_init=True)
+ self.__grid.thisptr = self.thisptr.GetGrid()
+
+ if 'CoordSystem' in kw:
+ self.SetMeshType(kw['CoordSystem'])
+ del kw['CoordSystem']
+ elif 'cs_type' in kw:
+ self.SetMeshType(kw['cs_type'])
+ del kw['cs_type']
+
+ assert len(kw)==0, 'Unknown keyword arguments: "{}"'.format(kw)
+
+ def __dealloc__(self):
+ del self.thisptr
+
+ def Update(self):
+ return self.thisptr.Update().decode('UTF-8')
+
+ def Write2XML(self, fn):
+ """ Write2XML(fn)
+
+ Write geometry to an xml-file
+
+ :param fn: str -- file name
+ """
+ self.thisptr.Write2XML(fn.encode('UTF-8'))
+
+ def ReadFromXML(self, fn):
+ """ ReadFromXML(fn)
+
+ Read geometry from xml-file
+
+ :param fn: str -- file name
+ """
+ return self.thisptr.ReadFromXML(fn.encode('UTF-8')).decode('UTF-8')
+
+ def GetParameterSet(self):
+ """
+ Get the parameter set assigned to this class
+ """
+ return self.__paraset
+
+ def GetGrid(self):
+ """
+ Get the CSRectGrid assigned to this class.
+
+ See Also
+ --------
+ CSXCAD.CSRectGrid, DefineGrid
+ """
+ return self.__grid
+
+ def SetMeshType(self, cs_type):
+ self.__grid.SetMeshType(cs_type)
+ self.thisptr.SetCoordInputType(cs_type)
+
+ def DefineGrid(self, mesh, unit, smooth_mesh_res=None):
+ """ DefineGrid(mesh, unit, smooth_mesh_res=None)
+
+ Assign a mesh lines to the grid assigned to this property.
+
+ :param mesh: (3,) list of mesh lines
+ :param unit: float -- drawing unit
+ :param smooth_mesh_res: an optional mesh smoothing
+
+ See Also
+ --------
+ CSXCAD.CSRectGrid, GetGrid, CSXCAD.SmoothMeshLines.SmoothMeshLines
+
+ """
+ grid = self.GetGrid()
+ grid.Clear()
+ if smooth_mesh_res is not None:
+ for k in mesh:
+ mesh[k] = SmoothMeshLines(mesh[k], smooth_mesh_res)
+
+ for k in mesh:
+ grid.SetLines(k, mesh[k])
+
+ grid.SetDeltaUnit(unit)
+ return grid
+
+ def GetQtyProperties(self):
+ return self.thisptr.GetQtyProperties()
+
+ def GetQtyPrimitives(self, prop_type=c_CSProperties.ANY):
+ return self.thisptr.GetQtyPrimitives(prop_type)
+
+ def AddMaterial(self, name, **kw):
+ """ AddMaterial(name, **kw)
+
+ Add a material property with name `name`.
+
+ See Also
+ --------
+ CSXCAD.CSProperties.CSPropMaterial
+ """
+ return self.__CreateProperty('Material', name, **kw)
+
+ def AddLumpedElement(self, name, **kw):
+ """ AddLumpedElement(name, **kw)
+
+ Add a lumped element with name `name`.
+
+ See Also
+ --------
+ CSXCAD.CSProperties.CSPropLumpedElement
+ """
+ return self.__CreateProperty('LumpedElement', name, **kw)
+
+ def AddMetal(self, name):
+ """ AddMetal(name)
+
+ Add a metal property with name `name`.
+
+ See Also
+ --------
+ CSXCAD.CSProperties.CSPropMetal
+ """
+ return self.__CreateProperty('Metal', name)
+
+ def AddConductingSheet(self, name, **kw):
+ """ AddConductingSheet(name, **kw)
+
+ Add a conducting sheet with name `name`.
+
+ See Also
+ --------
+ CSXCAD.CSProperties.CSPropConductingSheet
+ """
+ return self.__CreateProperty('ConductingSheet', name, **kw)
+
+ def AddExcitation(self, name, exc_type, exc_val, **kw):
+ """ AddExcitation(name, exc_type, exc_val, **kw)
+
+ Add an excitation property with name `name`.
+
+ See Also
+ --------
+ CSXCAD.CSProperties.CSPropExcitation
+ """
+ return self.__CreateProperty('Excitation', name, exc_type=exc_type, exc_val=exc_val, **kw)
+
+ def AddProbe(self, name, p_type, **kw):
+ """ AddProbe(name, p_type, **kw)
+
+ Add a probe property with name `name`.
+
+ See Also
+ --------
+ CSXCAD.CSProperties.CSPropProbeBox
+ """
+ return self.__CreateProperty('ProbeBox', name, p_type=p_type, **kw)
+
+ def AddDump(self, name, **kw):
+ """ AddDump(name, **kw)
+
+ Add a dump property with name `name`.
+
+ See Also
+ --------
+ CSXCAD.CSProperties.CSPropDumpBox
+ """
+ return self.__CreateProperty('DumpBox', name, **kw)
+
+ def __CreateProperty(self, type_str, name, *args, **kw):
+ assert len(args)==0, 'CreateProperty does not support additional arguments'
+ prop = CSProperties.fromTypeName(type_str, self.__paraset, **kw)
+ if prop is None:
+ raise Exception('CreateProperty: Unknown property type requested: {}'.format(type_str))
+ prop.SetName(name)
+ self.AddProperty(prop)
+ return prop
+
+ def AddProperty(self, prop):
+ """ AddProperty(prop)
+
+ Add an already created property (`prop`) to this class.
+
+ Notes
+ -----
+ This class will take ownership of the property.
+ """
+ self._AddProperty(prop)
+
+ cdef _AddProperty(self, CSProperties prop):
+ prop.__CSX = self
+ self.thisptr.AddProperty(prop.thisptr)
+
+ def GetProperty(self, index):
+ """ GetProperty(index)
+
+ Get the property at the given index
+
+ See Also
+ --------
+ CSXCAD.GetQtyProperties
+ """
+ if index<0 or index >=self.GetQtyProperties():
+ raise IndexError('Index is out of range')
+ return self._GetProperty(index)
+
+ cdef _GetProperty(self, int index):
+ cdef _CSProperties* _prop
+ cdef CSProperties prop
+ _prop = self.thisptr.GetProperty(index)
+ prop = CSProperties.fromType(_prop.GetType(), pset=None, no_init=True)
+ prop.thisptr = _prop
+ return prop
+
+ def GetAllProperties(self):
+ """ GetAllProperties()
+
+ Get a list of all properties
+ """
+ props = []
+ for n in range(self.GetQtyProperties()):
+ props.append(self._GetProperty(n))
+ return props
+
+ def GetPropertiesByName(self, name):
+ """ GetPropertiesByName(name)
+
+ Get all the property specifed by their name
+ """
+ return self.__GetPropertiesByName(name.encode('UTF-8'))
+
+ cdef __GetPropertiesByName(self, string name):
+ cdef vector[_CSProperties*] vprop
+ vprop = self.thisptr.GetPropertiesByName(name)
+
+ cdef _CSProperties* _prop
+ cdef CSProperties prop
+ props = []
+ for n in range(vprop.size()):
+ _prop = vprop.at(n)
+ prop = CSProperties.fromType(_prop.GetType(), pset=None, no_init=True)
+ prop.thisptr = _prop
+ props.append(prop)
+
+ return props
+
+ def GetPropertyByType(self, prop_type):
+ """ GetPropertyByType(prop_type)
+
+ Get a list of properties specified by their type
+ """
+ return self.__GetPropertyByType(prop_type)
+
+ cdef __GetPropertyByType(self, PropertyType prop_type):
+ cdef vector[_CSProperties*] vprop
+ vprop = self.thisptr.GetPropertyByType(prop_type)
+
+ cdef _CSProperties* _prop
+ cdef CSProperties prop
+ props = []
+ for n in range(vprop.size()):
+ _prop = vprop.at(n)
+ prop = CSProperties.fromType(_prop.GetType(), pset=None, no_init=True)
+ prop.thisptr = _prop
+ props.append(prop)
+
+ return props
+
+ def GetPropertyByCoordPriority(self, coord, prop_type=c_CSProperties.ANY, markFoundAsUsed=False):
+ """ GetPropertyByCoordPriority(coord, prop_type=None, markFoundAsUsed=False)
+ """
+ cdef double _coord[3]
+ for n in range(3):
+ _coord[n] = coord[n]
+ return self.__GetPropertyByCoordPriority(_coord, prop_type, markFoundAsUsed)
+
+ cdef __GetPropertyByCoordPriority(self, double* coord, PropertyType prop_type, bool markFoundAsUsed):
+ cdef _CSPrimitives *prim
+ cdef _CSProperties *_prop = self.thisptr.GetPropertyByCoordPriority(coord, prop_type, markFoundAsUsed, &prim)
+
+ cdef CSProperties prop
+ if _prop==NULL:
+ return None
+ else:
+ prop = CSProperties.fromType(_prop.GetType(), pset=None, no_init=True)
+ prop.thisptr = _prop
+ return prop
+
+ def GetAllPrimitives(self, sort=False, prop_type=c_CSProperties.ANY):
+ """ GetAllPrimitives(sort, prop_type)
+
+ Get a list of all primitives.
+ """
+ return self.__GetAllPrimitives(sort, prop_type)
+
+ cdef __GetAllPrimitives(self, bool sort, PropertyType prop_type):
+ cdef vector[_CSPrimitives*] vprim
+ vprim = self.thisptr.GetAllPrimitives(sort, prop_type)
+
+ cdef _CSPrimitives* _prim
+ cdef CSPrimitives prim
+ prims = []
+ for n in range(vprim.size()):
+ _prim = vprim.at(n)
+ prim = CSPrimitives.fromType(_prim.GetType(), pset=None, prop=None, no_init=True)
+ prim.thisptr = _prim
+ prims.append(prim)
+
+ return prims
+
diff --git a/CSXCAD/python/CSXCAD/ParameterObjects.pxd b/CSXCAD/python/CSXCAD/ParameterObjects.pxd
new file mode 100644
index 0000000..e9baebb
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/ParameterObjects.pxd
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from libcpp cimport bool
+
+cdef extern from "CSXCAD/ParameterObjects.h":
+ cdef cppclass _ParameterSet "ParameterSet":
+ _ParameterSet() except +
+ void PrintSelf()
+ bool GetModified()
+
+cdef class ParameterSet:
+ cdef _ParameterSet *thisptr
+ cdef bool no_init
diff --git a/CSXCAD/python/CSXCAD/ParameterObjects.pyx b/CSXCAD/python/CSXCAD/ParameterObjects.pyx
new file mode 100644
index 0000000..3d02804
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/ParameterObjects.pyx
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from libcpp.string cimport string
+from libcpp cimport bool
+
+cimport ParameterObjects
+
+cdef class ParameterSet:
+ def __cinit__(self, no_init=False):
+ self.no_init = no_init
+ if no_init==True:
+ self.thisptr = NULL
+ else:
+ self.thisptr = new _ParameterSet()
+
+ def __dealloc__(self):
+ if not self.no_init:
+ del self.thisptr
diff --git a/CSXCAD/python/CSXCAD/SmoothMeshLines.py b/CSXCAD/python/CSXCAD/SmoothMeshLines.py
new file mode 100644
index 0000000..4da8d88
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/SmoothMeshLines.py
@@ -0,0 +1,266 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import numpy as np
+import pylab as plt
+
+def MeshLinesSymmetric(l, rel_tol=1e-6):
+ """
+ Internal function, do not use.
+ """
+ l = np.array(l)
+ N = len(l)
+ rng = l[-1]-l[0]
+ if N%2==0: # even
+ mid_val = 0.5*(l[0] + l[-1])
+ else: # off
+ mid_val = l[(N-1)/2]
+
+ for n in range(int(N/2)):
+ if np.abs(mid_val - np.sum((l[n], l[N-n-1])))>rng*rel_tol:
+ return False
+
+ return True
+
+def Unique(l, tol=1e-7):
+ """
+ Internal function, do not use.
+ """
+ l = np.unique(l)
+ dl = np.diff(l)
+ idx = np.where(dl<np.mean(dl)*tol)[0]
+ if len(idx)>0:
+ l = np.delete(l, idx)
+
+ return l
+
+def SmoothRange(start, stop, start_res, stop_res, max_res, ratio):
+ """
+ Internal function, do not use.
+ """
+ assert ratio>1
+ rng = (stop-start)
+
+ # very small range
+ if rng<max_res and rng<start_res*ratio and rng<stop_res*ratio:
+ return Unique([start, stop])
+
+ # very large range and easy start/stop res
+ if start_res>=(max_res/ratio) and stop_res>=(max_res/ratio):
+ N = np.ceil(rng/max_res)
+ return np.linspace(start, stop, N+1)
+
+ def one_side_taper(start_res, ratio, max_res):
+ res = start_res
+ pos = 0
+ N = 0
+ while res<max_res and pos<rng:
+ res *= ratio
+ pos += res
+ N += 1
+ if pos>rng:
+ l = np.zeros(N+1)
+ for n in range(N+1):
+ l[n] = np.sum(start_res * ratio ** np.arange(1,n+1))
+ return l * rng/pos
+
+ _ratio = np.e**((np.log(max_res) - np.log(start_res))/(N))
+
+ l = [0]
+ pos = 0
+ res = start_res
+ for n in range(N):
+ res *= _ratio
+ pos += res
+ l.append(pos)
+
+ while pos<rng:
+ pos += max_res
+ l.append(pos)
+
+ return np.array(l) * rng/l[-1]
+
+ # need to taper start
+ if start_res<(max_res/ratio) and stop_res>=(max_res/ratio):
+ return start + one_side_taper(start_res, ratio, max_res)
+
+ # need to taper stop
+ if start_res>=(max_res/ratio) and stop_res<(max_res/ratio):
+ return np.sort(stop - one_side_taper(stop_res, ratio, max_res))
+
+ # test if max taper on both sides is possible
+ pos1 = 0
+ N1 = 0
+ res = start_res
+ while res<max_res:
+ res *= ratio
+ pos1 += res
+ N1 += 1
+ ratio1 = np.e**((np.log(max_res) - np.log(start_res))/(N1))
+ pos1 = np.sum(start_res * ratio1 ** np.arange(1,N1+1))
+
+ pos2 = 0
+ N2 = 0
+ res = stop_res
+ while res<max_res:
+ res *= ratio
+ pos2 += res
+ N2 += 1
+ ratio2 = np.e**((np.log(max_res) - np.log(stop_res))/(N2))
+ pos2 = np.sum(stop_res * ratio2 ** np.arange(1,N2+1))
+
+ if (pos1+pos2)<rng:
+ l = [0]
+ for n in range(1,N1+1):
+ l.append(l[-1]+start_res*ratio1**n)
+ r = [0]
+ for n in range(1,N2+1):
+ r.append(r[-1]+stop_res*ratio2**n)
+
+ left = rng-pos1-pos2
+ N = int(np.ceil(left/max_res))
+
+ for n in range(N):
+ l.append(l[-1]+max_res)
+
+ length = l[-1]+r[-1]
+ c = Unique(np.r_[np.array(l), length-np.array(r)])
+ return start + c *rng/length
+
+ l = [0]
+ r = [0]
+ while l[-1]+r[-1]<rng:
+ if start_res==stop_res:
+ start_res *= ratio
+ l.append(l[-1]+start_res)
+ stop_res *= ratio
+ r.append(r[-1]+start_res)
+ elif start_res<stop_res:
+ start_res *= ratio
+ l.append(l[-1]+start_res)
+ else:
+ stop_res *= ratio
+ r.append(r[-1]+start_res)
+
+ length = l[-1]+r[-1]
+ c = Unique(np.r_[np.array(l), length-np.array(r)])
+ return start + c *rng/length
+
+def CheckSymmetry(lines):
+ tolerance = 1e-10
+ NP = len(lines)
+ if NP<=2:
+ return 0
+ line_range = lines[-1]-lines[0]
+ center = 0.5*(lines[-1]+lines[0])
+
+ # check all lines for symmetry
+ for n in range(int(NP/2)):
+ if (abs((center-lines[n])-(lines[-n-1]-center)) > line_range*tolerance):
+ return 0
+
+ # check central point to be symmetry-center
+ if NP%2==1:
+ if (abs(lines[int(NP/2)]-center) > line_range*tolerance):
+ return 0
+
+ # if all checks pass, return true
+ return 2 if NP%2==0 else 1
+
+def SmoothMeshLines(lines, max_res, ratio=1.5, **kw):
+ """This is the form of a docstring.
+
+ Parameters
+ ----------
+
+ lines : list
+ List of mesh lines to be smoothed
+ max_res : float
+ Maximum allowed resolution, resulting mesh will always stay below that value
+ ratio : float
+ Ratio of increase or decrease of neighboring mesh lines
+
+ """
+ out_l = Unique(lines)
+ sym = CheckSymmetry(out_l)
+ if sym==1:
+ center = 0.5*(out_l[-1]+out_l[0])
+ out_l = out_l[:int(len(out_l)/2)+1]
+ elif sym==2:
+ center = 0.5*(out_l[-1]+out_l[0])
+ out_l = out_l[:int(len(out_l)/2)]
+
+ dl = np.diff(out_l)
+
+ while len(np.where(dl>max_res)[0])>0:
+ N = len(out_l)
+ dl[dl<=max_res] = np.max(dl)*2
+ idx = np.argmin(dl)
+ dl = np.diff(out_l)
+ if idx>0:
+ start_res = dl[idx-1]
+ else:
+ start_res = max_res
+ if idx<len(dl)-1:
+ stop_res = dl[idx+1]
+ else:
+ stop_res = max_res
+ l = SmoothRange(out_l[idx], out_l[idx+1], start_res, stop_res, max_res, ratio)
+ out_l = Unique(np.r_[out_l, l])
+ dl = np.diff(out_l)
+
+ if len(out_l)==N:
+ break
+
+ if sym==1:
+ return Unique(np.r_[out_l, 2*center-out_l[:-1]])
+ elif sym==2:
+ l = SmoothRange(out_l[-1], 2*center-out_l[-1], dl[-1], dl[-1], max_res, ratio)
+ return Unique(np.r_[out_l, l, 2*center-out_l])
+ return Unique(out_l)
+
+
+if __name__ == "__main__":
+
+# print(SmoothRange(0., 1., 10., 50., 25., 1.5))
+# print(SmoothRange(0., 100., 1., 50., 25., 1.5))
+# print(SmoothRange(0., 100., 50., 1., 25., 1.5))
+# print(SmoothRange(0., 135., 5., 1.5, 25., 1.5))
+# print(SmoothRange(0., 10., 6., 6.5, 25., 1.5))
+
+# l = [-100, -50, 50, 100]
+# l = [ -50., 100., 0., 0.381, 0.762, 1.143, 1.524]
+#
+ l = [-100, -90, 0, 90, 100]
+
+ l = np.array([-6574.4, -6351.2, -4798.8, -4575.6, -1049.4, -826.198, 826.198, 1049.4, 4575.6, 4798.8, 6351.2, 6574.4])+6574.4
+ print (l)
+
+ print("sym: ", CheckSymmetry(l))
+# print(np.mean(l))
+#
+ plt.plot(l, l, 'k*')
+ ol = SmoothMeshLines(l, 892.809033532)
+ print(ol)
+ print("sym: ", CheckSymmetry(ol))
+# ol = SmoothMeshLines(l, 800)
+# print(np.mean(ol))
+# print(ol)
+
+ plt.plot(ol, ol, 'r*')
+ plt.show() \ No newline at end of file
diff --git a/CSXCAD/python/CSXCAD/Utilities.pyx b/CSXCAD/python/CSXCAD/Utilities.pyx
new file mode 100644
index 0000000..768da21
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/Utilities.pyx
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015,20016 Thorsten Liebig (Thorsten.Liebig@gmx.de)
+#
+# 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+def CheckNyDir(ny):
+ """ CheckNyDir(ny)
+
+ Translate directions like 'x'/'y' or 'z' into 0/1 or 2.
+ Raise an assertion error otherwise.
+
+ :param ny: int or str
+ :returns: int -- direction as 0/1/2
+ """
+ if ny in [0, 1, 2]:
+ return ny
+ elif ny in ['x','y','z']:
+ return ['x','y','z'].index(ny)
+ elif ny in ['r','a','z']:
+ return ['r','a','z'].index(ny)
+ else:
+ raise Exception('CheckNyDir: invalid direction: "{}"'.format(ny))
+
+def GetMultiDirs(dirs):
+ assert type(dirs)==str, 'GetMultiDirs: dirs must be of type str'
+ dirs = ''.join(sorted(dirs))
+ if dirs == 'all' or dirs == 'xyz' or dirs == 'raz':
+ return [0, 1, 2]
+ elif dirs == 'x' or dirs == 'r':
+ return [0,]
+ elif dirs == 'y' or dirs == 'a':
+ return [1,]
+ elif dirs == 'z':
+ return [2,]
+ elif dirs == 'xy' or dirs == 'ra':
+ return [0, 1]
+ elif dirs == 'yz' or dirs == 'az':
+ return [1, 2]
+ elif dirs == 'xz' or dirs == 'rz':
+ return [0, 2]
diff --git a/CSXCAD/python/CSXCAD/__init__.py b/CSXCAD/python/CSXCAD/__init__.py
new file mode 100644
index 0000000..d8ca9cc
--- /dev/null
+++ b/CSXCAD/python/CSXCAD/__init__.py
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+#
+# Shortcut CSXCAD import
+
+from __future__ import absolute_import
+
+from CSXCAD.CSXCAD import ContinuousStructure
diff --git a/CSXCAD/python/README.md b/CSXCAD/python/README.md
new file mode 100644
index 0000000..dfea3ba
--- /dev/null
+++ b/CSXCAD/python/README.md
@@ -0,0 +1,14 @@
+# CSXCAD python interface
+
+## Install
+* Simple version:
+```python
+python setup.py install
+```
+
+* Extended options, e.g. for custom install path at */opt/openEMS*:
+```python
+python setup.py build_ext -I/opt/openEMS/include -L/opt/openEMS/lib -R/opt/openEMS/lib"
+pyhton setup.py install
+```
+**Note:** The install command may require root on Linux, or add --user to install to ~/.local
diff --git a/CSXCAD/python/doc/CSPrimitives.rst b/CSXCAD/python/doc/CSPrimitives.rst
new file mode 100644
index 0000000..0417de0
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives.rst
@@ -0,0 +1,26 @@
+.. _csprimitives:
+
+CSPrimitives
+============
+
+.. automodule:: CSXCAD.CSPrimitives
+
+**List of Primitives:**
+
+.. toctree::
+
+ CSPrimitives/CSPrimitives
+ CSPrimitives/CSPrimPoint
+ CSPrimitives/CSPrimBox
+ CSPrimitives/CSPrimCylinder
+ CSPrimitives/CSPrimCylindricalShell
+ CSPrimitives/CSPrimSphere
+ CSPrimitives/CSPrimSphericalShell
+ CSPrimitives/CSPrimPolygon
+ CSPrimitives/CSPrimLinPoly
+ CSPrimitives/CSPrimRotPoly
+ CSPrimitives/CSPrimCurve
+ CSPrimitives/CSPrimWire
+ CSPrimitives/CSPrimPolyhedron
+ CSPrimitives/CSPrimPolyhedronReader
+
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimBox.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimBox.rst
new file mode 100644
index 0000000..7122770
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimBox.rst
@@ -0,0 +1,7 @@
+.. _csprimbox:
+
+CSPrimBox
+---------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimBox
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimCurve.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimCurve.rst
new file mode 100644
index 0000000..8125780
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimCurve.rst
@@ -0,0 +1,7 @@
+.. _csprimcurve:
+
+CSPrimCurve
+-----------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimCurve
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimCylinder.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimCylinder.rst
new file mode 100644
index 0000000..57c312d
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimCylinder.rst
@@ -0,0 +1,7 @@
+.. _csprimcylinder:
+
+CSPrimCylinder
+--------------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimCylinder
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimCylindricalShell.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimCylindricalShell.rst
new file mode 100644
index 0000000..31630c4
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimCylindricalShell.rst
@@ -0,0 +1,7 @@
+.. _csprimcylindricalshell:
+
+CSPrimCylindricalShell
+----------------------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimCylindricalShell
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimLinPoly.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimLinPoly.rst
new file mode 100644
index 0000000..236a9a0
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimLinPoly.rst
@@ -0,0 +1,8 @@
+.. _csprimlinpoly:
+
+CSPrimLinPoly
+-------------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimLinPoly
+ :members:
+ :show-inheritance:
+
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimPoint.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimPoint.rst
new file mode 100644
index 0000000..ca3cbdc
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimPoint.rst
@@ -0,0 +1,7 @@
+.. _csprimpoint:
+
+CSPrimPoint
+-----------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimPoint
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimPolygon.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimPolygon.rst
new file mode 100644
index 0000000..ffeaf22
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimPolygon.rst
@@ -0,0 +1,8 @@
+.. _csprimpolygon:
+
+CSPrimPolygon
+-------------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimPolygon
+ :members:
+ :show-inheritance:
+
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimPolyhedron.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimPolyhedron.rst
new file mode 100644
index 0000000..b7d01c9
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimPolyhedron.rst
@@ -0,0 +1,8 @@
+.. _csprimpolyhedron:
+
+CSPrimPolyhedron
+----------------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimPolyhedron
+ :members:
+ :show-inheritance:
+
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimPolyhedronReader.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimPolyhedronReader.rst
new file mode 100644
index 0000000..ed10b4a
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimPolyhedronReader.rst
@@ -0,0 +1,8 @@
+.. _csprimpolyhedronreader:
+
+CSPrimPolyhedronReader
+----------------------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimPolyhedronReader
+ :members:
+ :show-inheritance:
+
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimRotPoly.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimRotPoly.rst
new file mode 100644
index 0000000..cf1ca34
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimRotPoly.rst
@@ -0,0 +1,8 @@
+.. _csprimrotpoly:
+
+CSPrimRotPoly
+-------------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimRotPoly
+ :members:
+ :show-inheritance:
+
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimSphere.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimSphere.rst
new file mode 100644
index 0000000..245447e
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimSphere.rst
@@ -0,0 +1,7 @@
+.. _csprimsphere:
+
+CSPrimSphere
+------------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimSphere
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimSphericalShell.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimSphericalShell.rst
new file mode 100644
index 0000000..5c86259
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimSphericalShell.rst
@@ -0,0 +1,7 @@
+.. _csprimsphericalshell:
+
+CSPrimSphericalShell
+--------------------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimSphericalShell
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimWire.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimWire.rst
new file mode 100644
index 0000000..b0e2c56
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimWire.rst
@@ -0,0 +1,8 @@
+.. _csprimwire:
+
+CSPrimWire
+----------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimWire
+ :members:
+ :show-inheritance:
+
diff --git a/CSXCAD/python/doc/CSPrimitives/CSPrimitives.rst b/CSXCAD/python/doc/CSPrimitives/CSPrimitives.rst
new file mode 100644
index 0000000..b2406df
--- /dev/null
+++ b/CSXCAD/python/doc/CSPrimitives/CSPrimitives.rst
@@ -0,0 +1,7 @@
+.. _csprimitives_base:
+
+CSPrimitives (Base Class)
+-------------------------
+.. autoclass:: CSXCAD.CSPrimitives.CSPrimitives
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSProperties.rst b/CSXCAD/python/doc/CSProperties.rst
new file mode 100644
index 0000000..57705f7
--- /dev/null
+++ b/CSXCAD/python/doc/CSProperties.rst
@@ -0,0 +1,19 @@
+.. _csproperties:
+
+CSProperties
+============
+
+.. automodule:: CSXCAD.CSProperties
+
+**List of Properties:**
+
+.. toctree::
+
+ CSProperties/CSProperties
+ CSProperties/CSPropMaterial
+ CSProperties/CSPropLumpedElement
+ CSProperties/CSPropMetal
+ CSProperties/CSPropConductingSheet
+ CSProperties/CSPropExcitation
+ CSProperties/CSPropProbeBox
+ CSProperties/CSPropDumpBox
diff --git a/CSXCAD/python/doc/CSProperties/CSPropConductingSheet.rst b/CSXCAD/python/doc/CSProperties/CSPropConductingSheet.rst
new file mode 100644
index 0000000..2d0995a
--- /dev/null
+++ b/CSXCAD/python/doc/CSProperties/CSPropConductingSheet.rst
@@ -0,0 +1,7 @@
+.. _cspropconductingsheet:
+
+CSPropConductingSheet
+---------------------
+.. autoclass:: CSXCAD.CSProperties.CSPropConductingSheet
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSProperties/CSPropDumpBox.rst b/CSXCAD/python/doc/CSProperties/CSPropDumpBox.rst
new file mode 100644
index 0000000..228dc96
--- /dev/null
+++ b/CSXCAD/python/doc/CSProperties/CSPropDumpBox.rst
@@ -0,0 +1,7 @@
+.. _cspropdumpbox:
+
+CSPropDumpBox
+-------------
+.. autoclass:: CSXCAD.CSProperties.CSPropDumpBox
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSProperties/CSPropExcitation.rst b/CSXCAD/python/doc/CSProperties/CSPropExcitation.rst
new file mode 100644
index 0000000..6c34e39
--- /dev/null
+++ b/CSXCAD/python/doc/CSProperties/CSPropExcitation.rst
@@ -0,0 +1,7 @@
+.. _cspropexcitation:
+
+CSPropExcitation
+----------------
+.. autoclass:: CSXCAD.CSProperties.CSPropExcitation
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSProperties/CSPropLumpedElement.rst b/CSXCAD/python/doc/CSProperties/CSPropLumpedElement.rst
new file mode 100644
index 0000000..2b40907
--- /dev/null
+++ b/CSXCAD/python/doc/CSProperties/CSPropLumpedElement.rst
@@ -0,0 +1,7 @@
+.. _csproplumpedelement:
+
+CSPropLumpedElement
+-------------------
+.. autoclass:: CSXCAD.CSProperties.CSPropLumpedElement
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSProperties/CSPropMaterial.rst b/CSXCAD/python/doc/CSProperties/CSPropMaterial.rst
new file mode 100644
index 0000000..f176dae
--- /dev/null
+++ b/CSXCAD/python/doc/CSProperties/CSPropMaterial.rst
@@ -0,0 +1,7 @@
+.. _cspropmaterial:
+
+CSPropMaterial
+--------------
+.. autoclass:: CSXCAD.CSProperties.CSPropMaterial
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSProperties/CSPropMetal.rst b/CSXCAD/python/doc/CSProperties/CSPropMetal.rst
new file mode 100644
index 0000000..32e934f
--- /dev/null
+++ b/CSXCAD/python/doc/CSProperties/CSPropMetal.rst
@@ -0,0 +1,7 @@
+.. _cspropmetal:
+
+CSPropMetal
+-----------
+.. autoclass:: CSXCAD.CSProperties.CSPropMetal
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSProperties/CSPropProbeBox.rst b/CSXCAD/python/doc/CSProperties/CSPropProbeBox.rst
new file mode 100644
index 0000000..aca9bbe
--- /dev/null
+++ b/CSXCAD/python/doc/CSProperties/CSPropProbeBox.rst
@@ -0,0 +1,7 @@
+.. _cspropprobebox:
+
+CSPropProbeBox
+--------------
+.. autoclass:: CSXCAD.CSProperties.CSPropProbeBox
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSProperties/CSProperties.rst b/CSXCAD/python/doc/CSProperties/CSProperties.rst
new file mode 100644
index 0000000..76b19fd
--- /dev/null
+++ b/CSXCAD/python/doc/CSProperties/CSProperties.rst
@@ -0,0 +1,7 @@
+.. _cspropertiesbase:
+
+CSProperties (Base Class)
+-------------------------
+.. autoclass:: CSXCAD.CSProperties.CSProperties
+ :members:
+ :show-inheritance:
diff --git a/CSXCAD/python/doc/CSRectGrid.rst b/CSXCAD/python/doc/CSRectGrid.rst
new file mode 100644
index 0000000..e83cee0
--- /dev/null
+++ b/CSXCAD/python/doc/CSRectGrid.rst
@@ -0,0 +1,8 @@
+.. _csrectgrid:
+
+CSRectGrid
+----------
+
+.. automodule:: CSXCAD.CSRectGrid
+ :members:
+ :undoc-members:
diff --git a/CSXCAD/python/doc/CSTransform.rst b/CSXCAD/python/doc/CSTransform.rst
new file mode 100644
index 0000000..1879b8a
--- /dev/null
+++ b/CSXCAD/python/doc/CSTransform.rst
@@ -0,0 +1,9 @@
+.. _cstransform:
+
+CSTransform
+------------
+
+.. automodule:: CSXCAD.CSTransform
+ :members:
+ :undoc-members:
+
diff --git a/CSXCAD/python/doc/CSXCAD.rst b/CSXCAD/python/doc/CSXCAD.rst
new file mode 100644
index 0000000..0fedd2b
--- /dev/null
+++ b/CSXCAD/python/doc/CSXCAD.rst
@@ -0,0 +1,8 @@
+.. _csxcad:
+
+CSXCAD
+------
+
+.. automodule:: CSXCAD
+ :members: ContinuousStructure
+ :undoc-members:
diff --git a/CSXCAD/python/doc/CSXCAD_API.rst b/CSXCAD/python/doc/CSXCAD_API.rst
new file mode 100644
index 0000000..fea360b
--- /dev/null
+++ b/CSXCAD/python/doc/CSXCAD_API.rst
@@ -0,0 +1,13 @@
+CSXCAD Python Interface
+=======================
+
+.. toctree::
+ :maxdepth: 2
+
+ CSXCAD
+ CSProperties
+ CSPrimitives
+ CSTransform
+ CSRectGrid
+ Mesh
+ Utilities
diff --git a/CSXCAD/python/doc/Makefile b/CSXCAD/python/doc/Makefile
new file mode 100644
index 0000000..4dcdb4b
--- /dev/null
+++ b/CSXCAD/python/doc/Makefile
@@ -0,0 +1,225 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " applehelp to make an Apple Help Book"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " epub3 to make an epub3"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " xml to make Docutils-native XML files"
+ @echo " pseudoxml to make pseudoxml-XML files for display purposes"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+ @echo " coverage to run coverage check of the documentation (if enabled)"
+ @echo " dummy to check syntax errors of document sources"
+
+.PHONY: clean
+clean:
+ rm -rf $(BUILDDIR)/*
+
+.PHONY: html
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+.PHONY: dirhtml
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+.PHONY: singlehtml
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+.PHONY: pickle
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+.PHONY: json
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+.PHONY: htmlhelp
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+.PHONY: qthelp
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/CSXCAD.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/CSXCAD.qhc"
+
+.PHONY: applehelp
+applehelp:
+ $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
+ @echo
+ @echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
+ @echo "N.B. You won't be able to view it unless you put it in" \
+ "~/Library/Documentation/Help or install it in your application" \
+ "bundle."
+
+.PHONY: devhelp
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/CSXCAD"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/CSXCAD"
+ @echo "# devhelp"
+
+.PHONY: epub
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+.PHONY: epub3
+epub3:
+ $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
+ @echo
+ @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."
+
+.PHONY: latex
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+.PHONY: latexpdf
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+.PHONY: latexpdfja
+latexpdfja:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through platex and dvipdfmx..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+.PHONY: text
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+.PHONY: man
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+.PHONY: texinfo
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+.PHONY: info
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+.PHONY: gettext
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+.PHONY: changes
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+.PHONY: linkcheck
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+.PHONY: doctest
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
+
+.PHONY: coverage
+coverage:
+ $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
+ @echo "Testing of coverage in the sources finished, look at the " \
+ "results in $(BUILDDIR)/coverage/python.txt."
+
+.PHONY: xml
+xml:
+ $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+ @echo
+ @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+.PHONY: pseudoxml
+pseudoxml:
+ $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+ @echo
+ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
+
+.PHONY: dummy
+dummy:
+ $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
+ @echo
+ @echo "Build finished. Dummy builder generates no files."
diff --git a/CSXCAD/python/doc/Mesh.rst b/CSXCAD/python/doc/Mesh.rst
new file mode 100644
index 0000000..13a9978
--- /dev/null
+++ b/CSXCAD/python/doc/Mesh.rst
@@ -0,0 +1,12 @@
+.. _mesh:
+
+Mesh
+====
+
+SmoothMeshLines
+---------------
+
+.. automodule:: CSXCAD.SmoothMeshLines
+ :members:
+ :undoc-members:
+
diff --git a/CSXCAD/python/doc/Utilities.rst b/CSXCAD/python/doc/Utilities.rst
new file mode 100644
index 0000000..d192e0e
--- /dev/null
+++ b/CSXCAD/python/doc/Utilities.rst
@@ -0,0 +1,8 @@
+.. _utilities:
+
+Utilities
+---------
+
+.. automodule:: CSXCAD.Utilities
+ :members:
+ :undoc-members:
diff --git a/CSXCAD/python/doc/about.rst b/CSXCAD/python/doc/about.rst
new file mode 100644
index 0000000..9d14464
--- /dev/null
+++ b/CSXCAD/python/doc/about.rst
@@ -0,0 +1,21 @@
+.. _about:
+
+About
+=====
+
+CSXCAD (Continuous Structure XML) is a C++ library to describe geometrical objects and their physical or non-physical properties.
+
+It supports a Matlab/Octave and Python interface for high-level interaction.
+
+License
+-------
+
+CSXCAD is licensed under the terms of the LGPLv3.
+
+Further information
+-------------------
+
+:Website: http://openems.de/index.php/CSXCAD
+:Forum: http://openems.de/forum/
+:Tutorials: http://openems.de/index.php/Tutorials
+
diff --git a/CSXCAD/python/doc/conf.py b/CSXCAD/python/doc/conf.py
new file mode 100644
index 0000000..2d64e69
--- /dev/null
+++ b/CSXCAD/python/doc/conf.py
@@ -0,0 +1,348 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# CSXCAD documentation build configuration file, created by
+# sphinx-quickstart on Sun Aug 28 22:27:13 2016.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#
+import os
+import sys
+import sphinx_rtd_theme
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#
+# needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+ 'sphinx.ext.autodoc',
+ 'sphinx.ext.intersphinx',
+ 'sphinx.ext.todo',
+ 'sphinx.ext.mathjax',
+ 'numpydoc',
+ 'sphinx.ext.autosummary',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix(es) of source filenames.
+# You can specify multiple suffix as a list of string:
+#
+# source_suffix = ['.rst', '.md']
+source_suffix = '.rst'
+
+# The encoding of source files.
+#
+# source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = 'CSXCAD'
+copyright = '2016, Thorsten Liebig'
+author = 'Thorsten Liebig'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.6'
+# The full version, including alpha/beta/rc tags.
+release = '0.6.1'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#
+# This is also used if you do content translation via gettext catalogs.
+# Usually you set "language" from the command line for these cases.
+language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#
+# today = ''
+#
+# Else, today_fmt is used as the format for a strftime call.
+#
+# today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+# This patterns also effect to html_static_path and html_extra_path
+exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#
+# default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#
+# add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#
+# add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#
+# show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+# modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+# keep_warnings = False
+
+# If true, `todo` and `todoList` produce output, else they produce nothing.
+todo_include_todos = True
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+#
+html_theme = 'sphinx_rtd_theme'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#
+# html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+# html_theme_path = []
+
+# The name for this set of Sphinx documents.
+# "<project> v<release> documentation" by default.
+#
+# html_title = 'CSXCAD v0.6.1'
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#
+# html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#
+# html_logo = None
+
+# The name of an image file (relative to this directory) to use as a favicon of
+# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#
+# html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#
+# html_extra_path = []
+
+# If not None, a 'Last updated on:' timestamp is inserted at every page
+# bottom, using the given strftime format.
+# The empty string is equivalent to '%b %d, %Y'.
+#
+# html_last_updated_fmt = None
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#
+# html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#
+# html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#
+# html_additional_pages = {}
+
+# If false, no module index is generated.
+#
+# html_domain_indices = True
+
+# If false, no index is generated.
+#
+# html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#
+# html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#
+# html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#
+# html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#
+# html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#
+# html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+# html_file_suffix = None
+
+# Language to be used for generating the HTML full-text search index.
+# Sphinx supports the following languages:
+# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
+# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh'
+#
+# html_search_language = 'en'
+
+# A dictionary with options for the search language support, empty by default.
+# 'ja' uses this config value.
+# 'zh' user can custom change `jieba` dictionary path.
+#
+# html_search_options = {'type': 'default'}
+
+# The name of a javascript file (relative to the configuration directory) that
+# implements a search results scorer. If empty, the default will be used.
+#
+# html_search_scorer = 'scorer.js'
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'CSXCADdoc'
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+ # The paper size ('letterpaper' or 'a4paper').
+ #
+ # 'papersize': 'letterpaper',
+
+ # The font size ('10pt', '11pt' or '12pt').
+ #
+ # 'pointsize': '10pt',
+
+ # Additional stuff for the LaTeX preamble.
+ #
+ # 'preamble': '',
+
+ # Latex figure (float) alignment
+ #
+ # 'figure_align': 'htbp',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
+latex_documents = [
+ (master_doc, 'CSXCAD.tex', 'CSXCAD Documentation',
+ 'Thorsten Liebig', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#
+# latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#
+# latex_use_parts = False
+
+# If true, show page references after internal links.
+#
+# latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#
+# latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#
+# latex_appendices = []
+
+# It false, will not define \strong, \code, itleref, \crossref ... but only
+# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added
+# packages.
+#
+# latex_keep_old_macro_names = True
+
+# If false, no module index is generated.
+#
+# latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ (master_doc, 'csxcad', 'CSXCAD Documentation',
+ [author], 1)
+]
+
+# If true, show URL addresses after external links.
+#
+# man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ (master_doc, 'CSXCAD', 'CSXCAD Documentation',
+ author, 'CSXCAD', 'One line description of project.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#
+# texinfo_appendices = []
+
+# If false, no module index is generated.
+#
+# texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#
+# texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#
+# texinfo_no_detailmenu = False
+
+numpydoc_show_class_members = False
diff --git a/CSXCAD/python/doc/index.rst b/CSXCAD/python/doc/index.rst
new file mode 100644
index 0000000..2a76ecb
--- /dev/null
+++ b/CSXCAD/python/doc/index.rst
@@ -0,0 +1,25 @@
+.. CSXCAD documentation master file, created by
+ sphinx-quickstart on Sun Aug 28 22:27:13 2016.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to CSXCAD's documentation!
+==================================
+
+Contents:
+
+.. toctree::
+ :maxdepth: 2
+
+ about
+ install
+ CSXCAD_API
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/CSXCAD/python/doc/install.rst b/CSXCAD/python/doc/install.rst
new file mode 100644
index 0000000..f3b57ca
--- /dev/null
+++ b/CSXCAD/python/doc/install.rst
@@ -0,0 +1,31 @@
+.. _install:
+
+Install
+=======
+
+Instructions how to install the CSXCAD python interface.
+
+Linux
+-----
+
+* Make sure CSXCAD was build and installed correctly
+
+* Simple version:
+
+.. code-block:: console
+
+ python setup.py install
+
+* Extended options, e.g. for custom install path at */opt*:
+
+.. code-block:: console
+
+ python setup.py build_ext -I/opt/include -L/opt/lib -R/opt/lib"
+ pyhton setup.py install
+
+**Note:** The install command may require root on Linux, or add ``--user`` to install to *~/.local*
+
+Windows
+-------
+
+The python interface for CSXCAD currently does not support MS Windows.
diff --git a/CSXCAD/python/setup.py b/CSXCAD/python/setup.py
new file mode 100644
index 0000000..07c1608
--- /dev/null
+++ b/CSXCAD/python/setup.py
@@ -0,0 +1,37 @@
+from distutils.core import setup
+from distutils.extension import Extension
+from Cython.Build import cythonize
+
+import os
+
+extensions = [
+ Extension("*", [os.path.join(os.path.dirname(__file__), "CSXCAD","*.pyx")],
+ language="c++", # generate C++ code
+ libraries = ['CSXCAD',]),
+]
+
+setup(
+ name="CSXCAD",
+ version = '0.6.2',
+ description = "Python interface for the CSXCAD library",
+ classifiers = [
+ 'Development Status :: 3 - Alpha',
+ 'Intended Audience :: Developers',
+ 'Intended Audience :: Information Technology',
+ 'Intended Audience :: Science/Research',
+ 'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
+ 'Programming Language :: Python',
+ 'Topic :: Scientific/Engineering',
+ 'Topic :: Software Development :: Libraries :: Python Modules',
+ 'Operating System :: POSIX :: Linux',
+ 'Operating System :: Microsoft :: Windows',
+ ],
+ author = 'Thorsten Liebig',
+ author_email = 'Thorsten.Liebig@gmx.de',
+ maintainer = 'Thorsten Liebig',
+ maintainer_email = 'Thorsten.Liebig@gmx.de',
+ url = 'http://openEMS.de',
+ packages=["CSXCAD", ],
+ package_data={'CSXCAD': ['*.pxd']},
+ ext_modules = cythonize(extensions)
+ )
diff --git a/CSXCAD/python/tests/sphere.ply b/CSXCAD/python/tests/sphere.ply
new file mode 100644
index 0000000..1e03e01
--- /dev/null
+++ b/CSXCAD/python/tests/sphere.ply
Binary files differ
diff --git a/CSXCAD/python/tests/sphere.stl b/CSXCAD/python/tests/sphere.stl
new file mode 100644
index 0000000..2afa4fd
--- /dev/null
+++ b/CSXCAD/python/tests/sphere.stl
Binary files differ
diff --git a/CSXCAD/python/tests/test_CSPrimitives.py b/CSXCAD/python/tests/test_CSPrimitives.py
new file mode 100644
index 0000000..ed9fc85
--- /dev/null
+++ b/CSXCAD/python/tests/test_CSPrimitives.py
@@ -0,0 +1,302 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sun Dec 13 14:49:46 2015
+
+@author: thorsten
+"""
+
+import numpy as np
+
+from CSXCAD import ParameterObjects
+from CSXCAD import CSProperties
+from CSXCAD import CSPrimitives
+
+import unittest
+
+class Test_CSPrimMethods(unittest.TestCase):
+ def setUp(self):
+ self.pset = ParameterObjects.ParameterSet()
+ self.metal = CSProperties.CSPropMetal(self.pset)
+
+ def test_general(self):
+ box = CSPrimitives.CSPrimBox(self.pset, self.metal)
+
+ self.assertEqual(box.GetType(), 1)
+ self.assertEqual(box.GetTypeName(), 'Box')
+ self.assertEqual(box.GetPriority(), 0)
+
+ box.SetPriority(10)
+ self.assertEqual(box.GetPriority(), 10)
+
+ box.SetPriority(-10)
+ self.assertEqual(box.GetPriority(), -10)
+
+ box.SetStart([0,0,0])
+ box.SetStop([1,2,3])
+ self.assertTrue(box.Update())
+
+ self.assertTrue( (box.GetBoundBox() == np.array([[0,0,0],[1,2,3]])).all())
+ self.assertTrue( (box.GetStart() == np.array([0,0,0])).all())
+ self.assertTrue( (box.GetStop() == np.array([1,2,3])).all())
+
+ self.assertEqual(box.GetDimension(), 3)
+ self.assertTrue(box.IsInside([0,0,0]))
+ self.assertTrue(box.IsInside([0.5,0.5,0.5]))
+ self.assertFalse(box.IsInside([-0.5,0.5,0.5]))
+
+ tr = box.GetTransform()
+ self.assertFalse(tr.HasTransform())
+
+ box.AddTransform('Translate', [0, 1, 0])
+ self.assertTrue(tr.HasTransform())
+
+ self.assertEqual(box.GetCoordinateSystem(), None)
+
+ box.SetCoordinateSystem(0)
+ self.assertEqual(box.GetCoordinateSystem(), 0)
+
+ def test_point(self):
+ coord = [0,0.1,0.2]
+ point = CSPrimitives.CSPrimPoint(self.pset, self.metal, coord=coord)
+ self.assertTrue( (point.GetCoord() == coord).all())
+
+ coord = np.array(coord)*2
+ point.SetCoord(coord)
+ self.assertTrue( (point.GetCoord() == coord).all())
+
+ def test_box(self):
+ box = CSPrimitives.CSPrimBox(self.pset, self.metal)
+ tr = box.GetTransform()
+ self.assertFalse(tr.HasTransform())
+
+
+ def test_cylinder(self):
+ # TEST Cylinder
+ cyl = CSPrimitives.CSPrimCylinder(self.pset, self.metal)
+ start = [1,2,3]
+ cyl.SetStart(start)
+ self.assertTrue( (cyl.GetStart()==start).all() )
+
+ stop = np.array([5,6,7])
+ cyl.SetStop(stop)
+ self.assertTrue( (cyl.GetStop()==stop).all() )
+
+ self.assertTrue( cyl.GetType()==5 )
+ self.assertTrue( cyl.GetTypeName()=='Cylinder' )
+
+ self.assertTrue( cyl.GetPriority()==0 )
+
+ cyl.SetRadius(5)
+ self.assertTrue( cyl.GetRadius()==5.0 )
+
+ def test_cylinder_shell(self):
+ # TEST Cylinder-Shell
+ cyl_shell = CSPrimitives.CSPrimCylindricalShell(self.pset, self.metal)
+ start = [1,2,3]
+ cyl_shell.SetStart(start)
+ self.assertTrue( (cyl_shell.GetStart()==start).all() )
+
+ stop = np.array([5,6,7])
+ cyl_shell.SetStop(stop)
+ self.assertTrue( (cyl_shell.GetStop()==stop).all() )
+
+ self.assertTrue( cyl_shell.GetType()==6 )
+ self.assertTrue( cyl_shell.GetTypeName()=='CylindricalShell' )
+
+ self.assertTrue( cyl_shell.GetPriority()==0 )
+
+ cyl_shell.SetRadius(5)
+ self.assertTrue( cyl_shell.GetRadius()==5.0 )
+
+ cyl_shell.SetShellWidth(1.5)
+ self.assertTrue( cyl_shell.GetShellWidth()==1.5 )
+
+ def test_sphere(self):
+ # TEST Sphere
+ sphere = CSPrimitives.CSPrimSphere(self.pset, self.metal)
+ center = np.array([1.1,2.2,3.3])
+ sphere.SetCenter(center)
+ self.assertTrue( (sphere.GetCenter()==center).all() )
+
+ self.assertTrue( sphere.GetType()==3 )
+ self.assertTrue( sphere.GetTypeName()=='Sphere' )
+
+ self.assertTrue( sphere.GetPriority()==0 )
+
+ sphere.SetRadius(5)
+ self.assertTrue( sphere.GetRadius()==5.0 )
+
+ def test_sphere_shell(self):
+ # TEST Sphere-Shell
+ sphere_shell = CSPrimitives.CSPrimSphericalShell(self.pset, self.metal)
+ center = np.array([1.1,2.2,3.3])
+ sphere_shell.SetCenter(center)
+ self.assertTrue( (sphere_shell.GetCenter()==center).all() )
+
+ self.assertTrue( sphere_shell.GetType()==4 )
+ self.assertTrue( sphere_shell.GetTypeName()=='SphericalShell' )
+
+ self.assertTrue( sphere_shell.GetPriority()==0 )
+
+ sphere_shell.SetRadius(5)
+ self.assertTrue( sphere_shell.GetRadius()==5.0 )
+
+ sphere_shell.SetShellWidth(1.5)
+ self.assertTrue( sphere_shell.GetShellWidth()==1.5 )
+
+ def test_polygon(self):
+ # Test polygon
+ poly = CSPrimitives.CSPrimPolygon(self.pset, self.metal)
+ x0 = np.array([0, 0, 1, 1])
+ x1 = np.array([0, 1, 1, 0])
+ poly.SetCoords(x0, x1)
+ o0, o1 = poly.GetCoords()
+ self.assertTrue( (o0==x0).all() )
+ self.assertTrue( (o1==x1).all() )
+
+ self.assertTrue( poly.GetQtyCoords()==4 )
+ self.assertTrue( poly.GetNormDir()==0 )
+ poly.SetNormDir('y')
+ self.assertTrue( poly.GetNormDir()==1 )
+ poly.SetNormDir(2)
+ self.assertTrue( poly.GetNormDir()==2 )
+
+ poly.SetElevation(0.123)
+ self.assertTrue( poly.GetElevation()==0.123 )
+
+ def test_lin_poly(self):
+ # Test Lin-Polygon
+ linpoly = CSPrimitives.CSPrimLinPoly(self.pset, self.metal)
+ x0 = np.array([0, 0, 1, 1])
+ x1 = np.array([0, 1, 1, 0])
+ linpoly.SetCoords(x0, x1)
+ o0, o1 = linpoly.GetCoords()
+ self.assertTrue( (o0==x0).all() )
+ self.assertTrue( (o1==x1).all() )
+
+ self.assertTrue( linpoly.GetQtyCoords()==4 )
+ self.assertTrue( linpoly.GetNormDir()==0 )
+ linpoly.SetNormDir('y')
+ self.assertTrue( linpoly.GetNormDir()==1 )
+ linpoly.SetNormDir(2)
+ self.assertTrue( linpoly.GetNormDir()==2 )
+
+ linpoly.SetElevation(0.123)
+ self.assertTrue( linpoly.GetElevation()==0.123 )
+
+ linpoly.SetLength(11.23)
+ self.assertTrue( linpoly.GetLength()==11.23 )
+
+ def test_rot_poly(self):
+ # Test Rot-Polygon
+ rotpoly = CSPrimitives.CSPrimRotPoly(self.pset, self.metal)
+ x0 = np.array([0, 0, 1, 1]) + 1.5
+ x1 = np.array([0, 1, 1, 0]) + 2.5
+ rotpoly.SetCoords(x0, x1)
+ o0, o1 = rotpoly.GetCoords()
+ self.assertTrue( (o0==x0).all() )
+ self.assertTrue( (o1==x1).all() )
+
+ self.assertTrue( rotpoly.GetQtyCoords()==4 )
+ self.assertTrue( rotpoly.GetNormDir()==0 )
+ rotpoly.SetNormDir('y')
+ self.assertTrue( rotpoly.GetNormDir()==1 )
+ rotpoly.SetNormDir(0)
+ self.assertTrue( rotpoly.GetNormDir()==0 )
+
+ rotpoly.SetRotAxisDir('z')
+ self.assertTrue( rotpoly.GetRotAxisDir()==2 )
+
+ rotpoly.SetAngle(0, 2*np.pi)
+ self.assertTrue( (rotpoly.GetAngle() == np.array([0, 2*np.pi])).all() )
+
+ def test_curve(self):
+ # Test Curve
+ x = np.array([0, 0, 1, 1]) + 1.5
+ y = np.array([0, 1, 1, 0]) + 2.5
+ z = np.array([0, 1, 3, 4])
+ curve = CSPrimitives.CSPrimCurve(self.pset, self.metal)#, points=[x,y,z])
+ curve.SetPoints(x, y, z)
+
+ self.assertTrue( (curve.GetPoint(0)==np.array([1.5,2.5,0])).all() )
+ self.assertTrue( curve.GetNumberOfPoints()==4 )
+
+ curve.AddPoint([10, 10, 10.5])
+ self.assertTrue( curve.GetNumberOfPoints()==5 )
+
+ curve.ClearPoints()
+ self.assertTrue( curve.GetNumberOfPoints()==0 )
+
+ def test_wire(self):
+ # Test Wire
+ wire = CSPrimitives.CSPrimWire(self.pset, self.metal)
+ x = np.array([0, 0, 1, 1]) - 1.5
+ y = np.array([0, 1, 1, 0]) - 2.5
+ z = np.array([0, 1, 3, 4])
+ wire.SetPoints(x, y, z)
+
+ self.assertTrue( (wire.GetPoint(0)==np.array([-1.5,-2.5,0])).all() )
+ self.assertTrue( wire.GetNumberOfPoints()==4 )
+
+ wire.AddPoint([10, -10, 10.5])
+ self.assertTrue( wire.GetNumberOfPoints()==5 )
+
+ wire.SetWireRadius(1.5)
+ self.assertTrue( wire.GetWireRadius()==1.5 )
+
+ # Test CSPrimPolyhedron
+ ph = CSPrimitives.CSPrimPolyhedron(self.pset, self.metal)
+ self.assertTrue( ph.GetNumVertices()==0 )
+ self.assertTrue( ph.GetNumFaces()==0 )
+
+ ph.AddVertex(0,0,0)
+ ph.AddVertex(0,1,0)
+ ph.AddVertex(1,0,0)
+ self.assertTrue( ph.GetNumVertices()==3 )
+ self.assertTrue( (ph.GetVertex(0)==np.array([0,0,0])).all() )
+
+ ph.AddFace([0,1,2])
+ self.assertTrue( ph.GetNumFaces()==1 )
+ self.assertTrue( (ph.GetFace(0)==np.array([0,1,2])).all() )
+
+ def test_polyhedron(self):
+ ## Test CSPrimPolyhedron
+ ph = CSPrimitives.CSPrimPolyhedron(self.pset, self.metal)
+
+ # create pyramid
+ x0 = 0
+ y0 = 0
+ z0 = 0
+ width = 50
+ height = 150
+ ph.AddVertex(x0 , y0 , z0) #0
+ ph.AddVertex(x0+width , y0 , z0) #1
+ ph.AddVertex(x0+width , y0+width , z0) #2
+ ph.AddVertex(x0 , y0+width , z0) #3
+ ph.AddVertex(x0+width/2, y0+width/2, z0+height) #4 (tip)
+
+ ph.AddFace([0,1,2])
+ ph.AddFace([0,2,3])
+ ph.AddFace([1,0,4])
+ ph.AddFace([0,3,4])
+ ph.AddFace([3,2,4])
+ ph.AddFace([2,1,4])
+
+ self.assertTrue((ph.GetFace(1)==np.array([0,2,3])).all())
+ self.assertEqual(ph.GetNumVertices(), 5)
+ self.assertEqual(ph.GetNumFaces() , 6)
+
+ ph.Update()
+ self.assertTrue (ph.IsInside([x0+width/4, y0+width/4, z0+height/2]))
+ self.assertFalse(ph.IsInside([x0 , y0 , z0+height/2]))
+
+ def test_polyhedron_reader(self):
+ ## Test CSPrimPolyhedronReader
+ phr = CSPrimitives.CSPrimPolyhedronReader(self.pset, self.metal)
+ phr.SetFilename('sphere.stl')
+ self.assertTrue( phr.ReadFile() )
+ self.assertEqual(phr.GetNumVertices(), 50)
+ self.assertEqual(phr.GetNumFaces(), 96)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/CSXCAD/python/tests/test_CSProperties.py b/CSXCAD/python/tests/test_CSProperties.py
new file mode 100644
index 0000000..4703796
--- /dev/null
+++ b/CSXCAD/python/tests/test_CSProperties.py
@@ -0,0 +1,140 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Thu Dec 10 21:47:29 2015
+
+@author: thorsten
+"""
+
+import numpy as np
+
+from CSXCAD import ParameterObjects
+from CSXCAD import CSProperties, CSPrimitives
+
+import unittest
+
+class Test_CSPrimMethods(unittest.TestCase):
+ def setUp(self):
+ self.pset = ParameterObjects.ParameterSet()
+
+ def test_add_primitives(self):
+ prop = CSProperties.CSPropMetal(self.pset)
+ box = prop.AddBox(start= [0,0,0] , stop=[1,1,1])
+
+ self.assertEqual( prop.GetQtyPrimitives(), 1)
+ self.assertEqual( id(prop.GetPrimitive(0)), id(box))
+
+ self.assertEqual( prop.GetPrimitive(0).GetType(), CSPrimitives.BOX)
+ self.assertEqual( len(prop.GetAllPrimitives()), 1)
+ self.assertEqual( prop.GetAllPrimitives(), [box,])
+
+ prim = prop.AddCylinder(start= [0,0,0] , stop=[1,1,1], radius=0.5)
+ self.assertEqual( prop.GetQtyPrimitives(), 2)
+ self.assertEqual( prop.GetPrimitive(1).GetType(), CSPrimitives.CYLINDER)
+
+ prim = prop.AddCylindricalShell(start= [0,0,0] , stop=[1,1,1], radius=0.5, shell_width=0.1)
+ self.assertEqual( prop.GetQtyPrimitives(), 3)
+ self.assertEqual( prop.GetPrimitive(2).GetType(), CSPrimitives.CYLINDRICALSHELL)
+
+ prim = prop.AddSphere(center=[1,1,1], radius=0.5)
+ self.assertEqual( prop.GetQtyPrimitives(), 4)
+ self.assertEqual( prop.GetPrimitive(3).GetType(), CSPrimitives.SPHERE)
+
+ prim = prop.AddSphericalShell(center=[1,1,1], radius=0.5, shell_width=0.1)
+ self.assertEqual( prop.GetQtyPrimitives(), 5)
+ self.assertEqual( prop.GetPrimitive(4).GetType(), CSPrimitives.SPHERICALSHELL)
+
+ self.assertEqual( len(prop.GetAllPrimitives()), 5)
+
+ def test_metal(self):
+ prop = CSProperties.CSPropMetal(self.pset)
+
+ self.assertEqual( prop.GetType(), CSProperties.METAL)
+ self.assertEqual( prop.GetTypeString(), 'Metal')
+
+ def test_material(self):
+ prop = CSProperties.CSPropMaterial(self.pset, epsilon = 5.0)
+
+ self.assertEqual( prop.GetType(), CSProperties.MATERIAL)
+ self.assertEqual( prop.GetTypeString(), 'Material')
+
+ self.assertEqual( prop.GetMaterialProperty('epsilon'), 5.0)
+ self.assertEqual( prop.GetMaterialProperty('mue'), 1.0)
+
+# print(CSX.GetQtyProperties())
+
+ prop.SetMaterialProperty(epsilon=[1.0, 2.0, 3.0], mue=2.0)
+ self.assertEqual( prop.GetMaterialProperty('epsilon'), 1.0)
+ self.assertEqual( prop.GetMaterialProperty('mue'), 2.0)
+
+ prop.SetMaterialWeight(epsilon=['sin(x)', 'y', 'z'], mue='cos(y)', density='z*z')
+ self.assertEqual( prop.GetMaterialWeight('epsilon'), 'sin(x)')
+ self.assertEqual( prop.GetMaterialWeight('mue'), 'cos(y)')
+ self.assertEqual( prop.GetMaterialWeight('density'), 'z*z')
+
+ prop.SetIsotropy(False)
+ self.assertFalse( prop.GetIsotropy(),False)
+ self.assertTrue( (prop.GetMaterialProperty('epsilon')==[1.0, 2.0, 3.0]).all())
+
+ def test_lumped_elem(self):
+ prop = CSProperties.CSPropLumpedElement(self.pset, R = 50, C=1e-12, caps=True, ny='x')
+
+ self.assertEqual( prop.GetType(), CSProperties.LUMPED_ELEMENT)
+ self.assertEqual( prop.GetTypeString(), 'LumpedElement')
+
+ self.assertEqual( prop.GetResistance(), 50)
+ prop.SetResistance(55.0)
+ prop.SetDirection('x')
+ self.assertEqual( prop.GetResistance(), 55)
+ self.assertEqual( prop.GetCapacity(), 1e-12)
+ self.assertTrue( prop.GetCaps())
+ prop.SetCaps(False)
+ self.assertFalse( prop.GetCaps())
+ self.assertEqual( prop.GetDirection(), 0)
+
+ def test_cond_sheet(self):
+ prop = CSProperties.CSPropConductingSheet(self.pset, conductivity=56e6, thickness=35e-6)
+
+ self.assertEqual( prop.GetType(), CSProperties.CONDUCTINGSHEET + CSProperties.METAL)
+ self.assertEqual( prop.GetTypeString(), 'ConductingSheet')
+
+ self.assertEqual( prop.GetConductivity(), 56e6)
+ self.assertEqual( prop.GetThickness(), 35e-6)
+
+ def test_excitation(self):
+ prop = CSProperties.CSPropExcitation(self.pset, exc_type=1, exc_val=[-1.0, 0, 1.0], delay=1e-9)
+
+ self.assertEqual( prop.GetType(), CSProperties.EXCITATION)
+ self.assertEqual( prop.GetTypeString(), 'Excitation')
+
+ self.assertEqual( prop.GetExcitType(), 1)
+ self.assertTrue( (prop.GetExcitation()==[-1.0, 0, 1.0]).all() )
+ self.assertEqual( prop.GetDelay(),1e-9)
+
+ prop.SetWeightFunction(['y','x','z'])
+ self.assertEqual(prop.GetWeightFunction(), ['y','x','z'])
+
+ def test_probe(self):
+ prop = CSProperties.CSPropProbeBox(self.pset, frequency=[1e9, 2.4e9])
+
+ self.assertEqual( prop.GetType(), CSProperties.PROBEBOX)
+ self.assertEqual( prop.GetTypeString(), 'ProbeBox')
+
+ self.assertEqual(prop.GetFrequencyCount(), 2)
+ prop.AddFrequency(5e9)
+ self.assertEqual(prop.GetFrequencyCount(), 3)
+ self.assertTrue((prop.GetFrequency() == [1e9, 2.4e9, 5e9]).all())
+
+ prop.ClearFrequency()
+ self.assertEqual(prop.GetFrequencyCount(), 0)
+
+ prop.SetFrequency(np.linspace(1e9,2e9,11))
+ self.assertEqual(prop.GetFrequencyCount(), 11)
+
+ def test_dump(self):
+ prop = CSProperties.CSPropDumpBox(self.pset)
+
+ self.assertEqual( prop.GetType(), CSProperties.DUMPBOX)
+ self.assertEqual( prop.GetTypeString(), 'DumpBox')
+
+if __name__ == '__main__':
+ unittest.main() \ No newline at end of file
diff --git a/CSXCAD/python/tests/test_CSRectGrid.py b/CSXCAD/python/tests/test_CSRectGrid.py
new file mode 100644
index 0000000..ddefb9a
--- /dev/null
+++ b/CSXCAD/python/tests/test_CSRectGrid.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Dec 12 22:04:58 2015
+
+@author: thorsten
+"""
+
+import numpy as np
+
+from CSXCAD import CSRectGrid
+
+import unittest
+
+class Test_CSRectGrid(unittest.TestCase):
+ def test_rect_grid(self):
+
+ grid = CSRectGrid.CSRectGrid(CoordSystem=0)
+
+ self.assertEqual( grid.GetMeshType(), 0 )
+
+ grid.SetMeshType(1)
+ self.assertEqual( grid.GetMeshType(), 1 )
+
+ grid.SetLines('x', [0, 1, 2])
+ grid.SetLines('y', [-2,0, 1])
+ self.assertEqual( grid.GetQtyLines('y'), 3 )
+ grid.AddLine('y',4)
+ self.assertEqual( grid.GetQtyLines('y'), 4 )
+ grid.AddLine('y',[4, 2, 5])
+ self.assertEqual( grid.GetQtyLines('y'), 7 )
+ self.assertTrue( (grid.GetLines('y')==np.array([-2., 0., 1., 4., 4., 2., 5.])).all() ) # check unsorted lines
+ grid.Sort('y')
+ self.assertTrue( (grid.GetLines('y')==np.array([-2., 0., 1., 2., 4., 5.])).all() )
+ self.assertEqual( grid.GetQtyLines('y'), 6 )
+
+ grid.SetLines('z', [10, 11, 12])
+
+ self.assertEqual( grid.GetLine('y', 1), 0.0 )
+
+ self.assertEqual( grid.GetQtyLines('x'), 3 )
+
+ grid.SetDeltaUnit(1e-3)
+ self.assertEqual( grid.GetDeltaUnit(), 1e-3 )
+
+ self.assertTrue( grid.IsValid() )
+
+ # check grid snapping
+ self.assertEqual( grid.Snap2LineNumber('y', 1), (2,True) )
+ self.assertEqual( grid.Snap2LineNumber('y', 1.1), (2,True) )
+ self.assertEqual( grid.Snap2LineNumber('y', 1.5), (3,True) )
+ self.assertEqual( grid.Snap2LineNumber('y', 1.6), (3,True) )
+ self.assertEqual( grid.Snap2LineNumber('y', 5.0), (5,True) )
+ self.assertEqual( grid.Snap2LineNumber('y', 5.01), (5,False) )
+
+ self.assertEqual( grid.Snap2LineNumber('y', -2.0), (0,True) )
+ self.assertEqual( grid.Snap2LineNumber('y', -2.01), (0,False) )
+
+ self.assertTrue( (grid.GetSimArea() == np.array([[0, -2, 10],[2, 5, 12]])).all() )
+
+ grid.ClearLines('x')
+ self.assertEqual( grid.GetQtyLines('x'), 0 )
+ self.assertEqual( grid.GetQtyLines('y'), 6 )
+ self.assertEqual( grid.GetQtyLines('z'), 3 )
+
+ self.assertFalse( grid.IsValid() )
+
+ grid.Clear()
+ self.assertEqual( grid.GetQtyLines('y'), 0 )
+
+ self.assertFalse( grid.IsValid() )
+
+if __name__ == '__main__':
+ unittest.main() \ No newline at end of file
diff --git a/CSXCAD/python/tests/test_CSTransform.py b/CSXCAD/python/tests/test_CSTransform.py
new file mode 100644
index 0000000..d2a35dd
--- /dev/null
+++ b/CSXCAD/python/tests/test_CSTransform.py
@@ -0,0 +1,81 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Fri Sep 2 21:42:50 2016
+
+@author: thorsten
+"""
+
+from CSXCAD import CSTransform
+import numpy as np
+
+import unittest
+
+def compare_coords(c1, c2):
+ c1 = np.array(c1)
+ c2 = np.array(c2)
+ return np.sum(np.abs(c1-c2))<1e-6
+
+
+class Test_CSTransform(unittest.TestCase):
+ def setUp(self):
+ self.tr = CSTransform.CSTransform()
+
+ def test_basics(self):
+ identity = np.identity(4)
+
+ self.assertFalse( self.tr.HasTransform() )
+ self.assertTrue( (self.tr.GetMatrix()==identity).all() )
+
+ self.tr.Translate([1,2,1])
+ self.assertTrue( self.tr.HasTransform() )
+ self.assertFalse((self.tr.GetMatrix()==identity).all() )
+
+ self.tr.Reset()
+ self.assertFalse( self.tr.HasTransform() )
+ self.assertTrue( (self.tr.GetMatrix()==identity).all() )
+
+ def test_translate(self):
+ test_pnt = np.array([1,1,1])/np.sqrt(3)
+
+ self.tr.Translate([1,2,1])
+ translate = np.identity(4)
+ translate[:3,3] = [1,2,1]
+ self.assertTrue( (self.tr.GetMatrix()==translate).all() )
+
+ self.assertTrue( compare_coords(self.tr.Transform(test_pnt), [ 1.57735027, 2.57735027, 1.57735027]) )
+
+ def test_rotate(self):
+ self.tr.RotateAxis('x', 45)
+ self.assertTrue( compare_coords(self.tr.Transform([0,np.sqrt(2),0]), [0, 1, 1]) )
+
+ self.tr.Reset()
+ self.tr.RotateAxis('x', -45)
+ self.assertTrue( compare_coords(self.tr.Transform([0,np.sqrt(2),0]), [0, 1, -1]) )
+
+ self.tr.Reset()
+ self.tr.RotateAxis('z', -90)
+ self.assertTrue( compare_coords(self.tr.Transform([1,0,0]), [0, -1, 0]) )
+ self.tr.RotateOrigin([0,0,1], 90)
+ self.assertTrue( compare_coords(self.tr.Transform([1,0,0]), [1, 0, 0]) )
+
+ self.tr.Reset()
+ self.tr.RotateOrigin([0,1,1], 90)
+ self.assertTrue( compare_coords(self.tr.Transform([1,0,0]), [0, 1/np.sqrt(2), -1/np.sqrt(2)]) )
+
+ def test_scale(self):
+ self.tr.Scale(3)
+ self.assertTrue( compare_coords(self.tr.Transform([1,0,0]), [3, 0, 0]) )
+
+ self.tr.Reset()
+ self.tr.Scale([1,2,3])
+ self.assertTrue( compare_coords(self.tr.Transform([1,1,1]), [1, 2, 3]) )
+
+ def test_matrix(self):
+ self.tr.RotateOrigin([1,1,1], 90)
+ mat = self.tr.GetMatrix()
+ self.tr.Reset()
+ self.tr.SetMatrix(mat)
+ self.assertTrue( (self.tr.GetMatrix()==mat).all() )
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/CSXCAD/python/tests/test_CSXCAD.py b/CSXCAD/python/tests/test_CSXCAD.py
new file mode 100644
index 0000000..062eb6c
--- /dev/null
+++ b/CSXCAD/python/tests/test_CSXCAD.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Fri Dec 4 16:24:49 2015
+
+@author: thorsten
+"""
+
+import numpy as np
+
+from CSXCAD.CSXCAD import ContinuousStructure
+from CSXCAD import CSProperties
+
+from CSXCAD.CSProperties import CSPropMetal
+from CSXCAD import CSPrimitives
+csx = ContinuousStructure()
+pset = csx.GetParameterSet()
+grid = csx.GetGrid()
+
+##### Test Metal Prop
+metal = CSPropMetal(pset)
+assert metal.GetQtyPrimitives() == 0
+assert metal.GetTypeString()=='Metal'
+
+metal.SetName('metal')
+assert metal.GetName()=='metal'
+
+
+print(csx.GetQtyPrimitives(0))
+metal.AddBox([0,0,0], [1,1,1])
+
+ans = csx.AddProperty(metal)
+
+print(csx.GetQtyPrimitives(CSProperties.ANY))
+print(csx.GetQtyPrimitives(CSProperties.METAL))
+metal2 = csx.AddMetal('test')
+assert metal2.GetName()=='test'
+
+##### Test Excitation Prop
+exc_val = np.array([0,1,0])
+exc = csx.AddExcitation('excite', 0, exc_val)
+assert exc.GetName()=='excite'
+assert exc.GetExcitType() == 0
+assert (exc.GetExcitation()==exc_val).all()
+
+csx.Write2XML('test_CSXCAD.xml')
+
+del metal
+
+print("all ok") \ No newline at end of file
diff --git a/CSXCAD/src/CSPrimCylinder.cpp b/CSXCAD/src/CSPrimCylinder.cpp
index fb16262..453a851 100644
--- a/CSXCAD/src/CSPrimCylinder.cpp
+++ b/CSXCAD/src/CSPrimCylinder.cpp
@@ -153,8 +153,8 @@ bool CSPrimCylinder::Update(std::string *ErrStr)
EC=psRadius.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
bOK=false;
std::stringstream stream;
diff --git a/CSXCAD/src/CSPrimCylindricalShell.cpp b/CSXCAD/src/CSPrimCylindricalShell.cpp
index 0ca1701..481055d 100644
--- a/CSXCAD/src/CSPrimCylindricalShell.cpp
+++ b/CSXCAD/src/CSPrimCylindricalShell.cpp
@@ -136,8 +136,8 @@ bool CSPrimCylindricalShell::Update(std::string *ErrStr)
bool bOK=CSPrimCylinder::Update(ErrStr);
EC=psShellWidth.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
bOK=false;
std::stringstream stream;
diff --git a/CSXCAD/src/CSPrimLinPoly.cpp b/CSXCAD/src/CSPrimLinPoly.cpp
index 5ca3201..b03b9a9 100644
--- a/CSXCAD/src/CSPrimLinPoly.cpp
+++ b/CSXCAD/src/CSPrimLinPoly.cpp
@@ -95,8 +95,8 @@ bool CSPrimLinPoly::Update(std::string *ErrStr)
bool bOK = CSPrimPolygon::Update(ErrStr);
EC=extrudeLength.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
bOK=false;
std::stringstream stream;
diff --git a/CSXCAD/src/CSPrimMultiBox.cpp b/CSXCAD/src/CSPrimMultiBox.cpp
index e5547f0..51f1a5f 100644
--- a/CSXCAD/src/CSPrimMultiBox.cpp
+++ b/CSXCAD/src/CSPrimMultiBox.cpp
@@ -211,7 +211,7 @@ bool CSPrimMultiBox::Update(std::string *ErrStr)
for (size_t i=0;i<vCoords.size();++i)
{
EC=vCoords.at(i)->Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
if ((EC!=0) && (ErrStr!=NULL))
{
bOK=false;
diff --git a/CSXCAD/src/CSPrimPolygon.cpp b/CSXCAD/src/CSPrimPolygon.cpp
index 733fb0a..523857c 100644
--- a/CSXCAD/src/CSPrimPolygon.cpp
+++ b/CSXCAD/src/CSPrimPolygon.cpp
@@ -214,8 +214,8 @@ bool CSPrimPolygon::Update(std::string *ErrStr)
for (size_t i=1;i<vCoords.size();++i)
{
EC=vCoords[i].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
bOK=false;
std::stringstream stream;
@@ -226,8 +226,8 @@ bool CSPrimPolygon::Update(std::string *ErrStr)
}
EC=Elevation.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
bOK=false;
std::stringstream stream;
diff --git a/CSXCAD/src/CSPrimPolyhedron.cpp b/CSXCAD/src/CSPrimPolyhedron.cpp
index 7eac505..2454f28 100644
--- a/CSXCAD/src/CSPrimPolyhedron.cpp
+++ b/CSXCAD/src/CSPrimPolyhedron.cpp
@@ -268,6 +268,7 @@ bool CSPrimPolyhedron::IsInside(const double* Coord, double /*tol*/)
bool CSPrimPolyhedron::Update(std::string *ErrStr)
{
+ BuildTree();
//update local bounding box
m_BoundBoxValid = GetBoundBox(m_BoundBox);
return CSPrimitives::Update(ErrStr);
diff --git a/CSXCAD/src/CSPrimRotPoly.cpp b/CSXCAD/src/CSPrimRotPoly.cpp
index 705b08e..1411277 100644
--- a/CSXCAD/src/CSPrimRotPoly.cpp
+++ b/CSXCAD/src/CSPrimRotPoly.cpp
@@ -110,8 +110,8 @@ bool CSPrimRotPoly::Update(std::string *ErrStr)
bool bOK = CSPrimPolygon::Update(ErrStr);
EC=StartStopAngle[0].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
bOK=false;
std::stringstream stream;
@@ -121,8 +121,8 @@ bool CSPrimRotPoly::Update(std::string *ErrStr)
}
EC=StartStopAngle[1].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
bOK=false;
std::stringstream stream;
diff --git a/CSXCAD/src/CSPrimSphere.cpp b/CSXCAD/src/CSPrimSphere.cpp
index a372fe3..3d20308 100644
--- a/CSXCAD/src/CSPrimSphere.cpp
+++ b/CSXCAD/src/CSPrimSphere.cpp
@@ -126,8 +126,8 @@ bool CSPrimSphere::Update(std::string *ErrStr)
m_Center.SetCoordinateSystem(m_PrimCoordSystem, m_MeshType);
EC=psRadius.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
bOK=false;
std::stringstream stream;
diff --git a/CSXCAD/src/CSPrimSphericalShell.cpp b/CSXCAD/src/CSPrimSphericalShell.cpp
index 73f2d82..cb71cbd 100644
--- a/CSXCAD/src/CSPrimSphericalShell.cpp
+++ b/CSXCAD/src/CSPrimSphericalShell.cpp
@@ -92,8 +92,8 @@ bool CSPrimSphericalShell::Update(std::string *ErrStr)
bool bOK=CSPrimSphere::Update(ErrStr);
EC=psShellWidth.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
bOK=false;
std::stringstream stream;
diff --git a/CSXCAD/src/CSPrimUserDefined.cpp b/CSXCAD/src/CSPrimUserDefined.cpp
index 2cd5219..746e77e 100644
--- a/CSXCAD/src/CSPrimUserDefined.cpp
+++ b/CSXCAD/src/CSPrimUserDefined.cpp
@@ -190,8 +190,8 @@ bool CSPrimUserDefined::Update(std::string *ErrStr)
for (int i=0;i<3;++i)
{
EC=dPosShift[i].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
bOK=false;
std::ostringstream oss;
diff --git a/CSXCAD/src/CSPrimWire.cpp b/CSXCAD/src/CSPrimWire.cpp
index a182400..776e62d 100644
--- a/CSXCAD/src/CSPrimWire.cpp
+++ b/CSXCAD/src/CSPrimWire.cpp
@@ -116,8 +116,8 @@ bool CSPrimWire::Update(std::string *ErrStr)
CSPrimCurve::Update(ErrStr);
EC=wireRadius.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
bOK=false;
std::stringstream stream;
diff --git a/CSXCAD/src/CSPropConductingSheet.cpp b/CSXCAD/src/CSPropConductingSheet.cpp
index adce7fd..1fc5a53 100644
--- a/CSXCAD/src/CSPropConductingSheet.cpp
+++ b/CSXCAD/src/CSPropConductingSheet.cpp
@@ -39,8 +39,8 @@ bool CSPropConductingSheet::Update(std::string *ErrStr)
{
int EC=Conductivity.Evaluate();
bool bOK=true;
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in ConductingSheet-Property Conductivity-Value";
@@ -49,8 +49,8 @@ bool CSPropConductingSheet::Update(std::string *ErrStr)
}
EC=Thickness.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in ConductingSheet-Property Thickness-Value";
diff --git a/CSXCAD/src/CSPropDebyeMaterial.cpp b/CSXCAD/src/CSPropDebyeMaterial.cpp
index f12c261..b1809be 100644
--- a/CSXCAD/src/CSPropDebyeMaterial.cpp
+++ b/CSXCAD/src/CSPropDebyeMaterial.cpp
@@ -99,8 +99,8 @@ bool CSPropDebyeMaterial::Update(std::string *ErrStr)
for (int n=0;n<3;++n)
{
EC=EpsDelta[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Debye Material-Property epsilon Delta frequency value (ID: " << uiID << "): ";
@@ -109,8 +109,8 @@ bool CSPropDebyeMaterial::Update(std::string *ErrStr)
}
EC=WeightEpsDelta[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Debye Material-Property epsilon Delta frequency weighting function (ID: " << uiID << "): ";
@@ -119,8 +119,8 @@ bool CSPropDebyeMaterial::Update(std::string *ErrStr)
}
EC=EpsRelaxTime[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Debye Material-Property epsilon relaxation time value (ID: " << uiID << "): ";
@@ -129,8 +129,8 @@ bool CSPropDebyeMaterial::Update(std::string *ErrStr)
}
EC=WeightEpsRelaxTime[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Debye Material-Property epsilon relaxation time weighting function (ID: " << uiID << "): ";
diff --git a/CSXCAD/src/CSPropDumpBox.cpp b/CSXCAD/src/CSPropDumpBox.cpp
index 6cccce6..a16f92e 100644
--- a/CSXCAD/src/CSPropDumpBox.cpp
+++ b/CSXCAD/src/CSPropDumpBox.cpp
@@ -44,6 +44,7 @@ void CSPropDumpBox::SetSubSampling(int ny, unsigned int val)
{
if ((ny<0) || (ny>2)) return;
if (val<1) return;
+ m_SubSampling=true;
SubSampling[ny] = val;
}
@@ -56,7 +57,6 @@ void CSPropDumpBox::SetSubSampling(unsigned int val[])
void CSPropDumpBox::SetSubSampling(const char* vals)
{
if (vals==NULL) return;
- m_SubSampling=true;
std::vector<int> values = SplitString2Int(std::string(vals),',');
for (int ny=0;ny<3 && ny<(int)values.size();++ny)
SetSubSampling(ny,values.at(ny));
@@ -72,6 +72,7 @@ void CSPropDumpBox::SetOptResolution(int ny, double val)
{
if ((ny<0) || (ny>2)) return;
if (val<0) return;
+ m_OptResolution=true;
OptResolution[ny] = val;
}
@@ -84,7 +85,6 @@ void CSPropDumpBox::SetOptResolution(double val[])
void CSPropDumpBox::SetOptResolution(const char* vals)
{
if (vals==NULL) return;
- m_OptResolution=true;
std::vector<double> values = SplitString2Double(std::string(vals),',');
if (values.size()==1) //allow one resolution for all directions
{
diff --git a/CSXCAD/src/CSPropExcitation.cpp b/CSXCAD/src/CSPropExcitation.cpp
index 8d498ad..4089567 100644
--- a/CSXCAD/src/CSPropExcitation.cpp
+++ b/CSXCAD/src/CSPropExcitation.cpp
@@ -171,8 +171,8 @@ bool CSPropExcitation::Update(std::string *ErrStr)
for (unsigned int i=0;i<3;++i)
{
EC=Excitation[i].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Excitation-Property Excitaion-Value (ID: " << uiID << "): ";
@@ -180,8 +180,8 @@ bool CSPropExcitation::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=PropagationDir[i].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Excitation-Property PropagationDir-Value (ID: " << uiID << "): ";
@@ -190,8 +190,8 @@ bool CSPropExcitation::Update(std::string *ErrStr)
}
}
EC=m_Frequency.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Excitation-Property Frequency-Value";
@@ -199,8 +199,8 @@ bool CSPropExcitation::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=Delay.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Excitation-Property Delay-Value";
diff --git a/CSXCAD/src/CSPropLorentzMaterial.cpp b/CSXCAD/src/CSPropLorentzMaterial.cpp
index 73cda4a..763da66 100644
--- a/CSXCAD/src/CSPropLorentzMaterial.cpp
+++ b/CSXCAD/src/CSPropLorentzMaterial.cpp
@@ -163,8 +163,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
for (int n=0;n<3;++n)
{
EC=EpsPlasma[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property epsilon plasma frequency value (ID: " << uiID << "): ";
@@ -172,8 +172,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=MuePlasma[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property mue plasma frequency value (ID: " << uiID << "): ";
@@ -182,8 +182,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
}
EC=WeightEpsPlasma[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property epsilon plasma frequency weighting function (ID: " << uiID << "): ";
@@ -191,8 +191,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=WeightMuePlasma[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property mue plasma frequency value weighting function (ID: " << uiID << "): ";
@@ -201,8 +201,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
}
EC=EpsLorPole[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property epsilon lorentz pole frequency value (ID: " << uiID << "): ";
@@ -210,8 +210,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=MueLorPole[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property mue lorentz pole frequency value (ID: " << uiID << "): ";
@@ -220,8 +220,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
}
EC=WeightEpsLorPole[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property epsilon lorentz pole frequency weighting function (ID: " << uiID << "): ";
@@ -229,8 +229,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=WeightMueLorPole[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property mue lorentz pole frequency value weighting function (ID: " << uiID << "): ";
@@ -239,8 +239,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
}
EC=EpsRelaxTime[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property epsilon relaxation time value (ID: " << uiID << "): ";
@@ -248,8 +248,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=MueRelaxTime[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property mue relaxation time value (ID: " << uiID << "): ";
@@ -258,8 +258,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
}
EC=WeightEpsRelaxTime[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property epsilon relaxation time weighting function (ID: " << uiID << "): ";
@@ -267,8 +267,8 @@ bool CSPropLorentzMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=WeightMueRelaxTime[o][n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Lorentz Material-Property mue relaxation time value weighting function (ID: " << uiID << "): ";
diff --git a/CSXCAD/src/CSPropLumpedElement.cpp b/CSXCAD/src/CSPropLumpedElement.cpp
index f4dc602..f21f610 100644
--- a/CSXCAD/src/CSPropLumpedElement.cpp
+++ b/CSXCAD/src/CSPropLumpedElement.cpp
@@ -37,8 +37,8 @@ bool CSPropLumpedElement::Update(std::string *ErrStr)
{
int EC=m_R.Evaluate();
bool bOK=true;
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in LumpedElement-Property Resistance-Value";
@@ -48,8 +48,8 @@ bool CSPropLumpedElement::Update(std::string *ErrStr)
}
EC=m_C.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in LumpedElement-Property Capacitor-Value";
@@ -59,8 +59,8 @@ bool CSPropLumpedElement::Update(std::string *ErrStr)
}
EC=m_L.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in LumpedElement-Property Inductance-Value";
diff --git a/CSXCAD/src/CSPropMaterial.cpp b/CSXCAD/src/CSPropMaterial.cpp
index 7fd2415..21fc2dd 100644
--- a/CSXCAD/src/CSPropMaterial.cpp
+++ b/CSXCAD/src/CSPropMaterial.cpp
@@ -128,8 +128,8 @@ bool CSPropMaterial::Update(std::string *ErrStr)
for (int n=0;n<3;++n)
{
EC=Epsilon[n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Material-Property Epsilon-Value (ID: " << uiID << "): ";
@@ -137,8 +137,8 @@ bool CSPropMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=Mue[n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Material-Property Mue-Value (ID: " << uiID << "): ";
@@ -146,8 +146,8 @@ bool CSPropMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=Kappa[n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Material-Property Kappa-Value (ID: " << uiID << "): ";
@@ -155,8 +155,8 @@ bool CSPropMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=Sigma[n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Material-Property Sigma-Value (ID: " << uiID << "): ";
@@ -164,8 +164,8 @@ bool CSPropMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=WeightEpsilon[n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Material-Property Epsilon-Value weighting function (ID: " << uiID << "): ";
@@ -173,8 +173,8 @@ bool CSPropMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=WeightMue[n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Material-Property Mue-Value weighting function (ID: " << uiID << "): ";
@@ -182,8 +182,8 @@ bool CSPropMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=WeightKappa[n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Material-Property Kappa-Value weighting function (ID: " << uiID << "): ";
@@ -191,8 +191,8 @@ bool CSPropMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=WeightSigma[n].Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Material-Property Sigma-Value weighting function (ID: " << uiID << "): ";
@@ -202,8 +202,8 @@ bool CSPropMaterial::Update(std::string *ErrStr)
}
EC=Density.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Material-Property Density-Value (ID: " << uiID << "): ";
@@ -211,8 +211,8 @@ bool CSPropMaterial::Update(std::string *ErrStr)
PSErrorCode2Msg(EC,ErrStr);
}
EC=WeightDensity.Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Material-Property Density weighting function (ID: " << uiID << "): ";
diff --git a/CSXCAD/src/CSPropProbeBox.cpp b/CSXCAD/src/CSPropProbeBox.cpp
index b7c87da..c9234f1 100644
--- a/CSXCAD/src/CSPropProbeBox.cpp
+++ b/CSXCAD/src/CSPropProbeBox.cpp
@@ -50,6 +50,7 @@ bool CSPropProbeBox::Write2XML(TiXmlNode& root, bool parameterised, bool sparse)
prop->SetAttribute("NormDir",(int)uiNumber);
prop->SetAttribute("Type",ProbeType);
prop->SetAttribute("Weight",m_weight);
+ prop->SetAttribute("NormDir",m_NormDir);
prop->SetAttribute("StartTime",startTime);
prop->SetAttribute("StopTime" ,stopTime );
diff --git a/CSXCAD/src/CSProperties.cpp b/CSXCAD/src/CSProperties.cpp
index 605b0be..6da7bf2 100644
--- a/CSXCAD/src/CSProperties.cpp
+++ b/CSXCAD/src/CSProperties.cpp
@@ -164,10 +164,12 @@ void CSProperties::AddAttribute(std::string name, std::string value)
size_t CSProperties::GetQtyPrimitives() {return vPrimitives.size();}
CSPrimitives* CSProperties::GetPrimitive(size_t index) {if (index<vPrimitives.size()) return vPrimitives.at(index); else return NULL;}
void CSProperties::SetFillColor(RGBa color) {FillColor.R=color.R;FillColor.G=color.G;FillColor.B=color.B;FillColor.a=color.a;}
+void CSProperties::SetFillColor(unsigned char R, unsigned char G, unsigned char B, unsigned char a) {FillColor.R=R;FillColor.G=G;FillColor.B=B;FillColor.a=a;}
RGBa CSProperties::GetFillColor() {return FillColor;}
RGBa CSProperties::GetEdgeColor() {return EdgeColor;}
void CSProperties::SetEdgeColor(RGBa color) {EdgeColor.R=color.R;EdgeColor.G=color.G;EdgeColor.B=color.B;EdgeColor.a=color.a;}
+void CSProperties::SetEdgeColor(unsigned char R, unsigned char G, unsigned char B, unsigned char a) {EdgeColor.R=R;EdgeColor.G=G;EdgeColor.B=B;EdgeColor.a=a;}
bool CSProperties::GetVisibility() {return bVisisble;}
void CSProperties::SetVisibility(bool val) {bVisisble=val;}
diff --git a/CSXCAD/src/CSProperties.h b/CSXCAD/src/CSProperties.h
index d8757ee..58b0085 100644
--- a/CSXCAD/src/CSProperties.h
+++ b/CSXCAD/src/CSProperties.h
@@ -76,7 +76,7 @@ public:
//! Enumeration of all possible sub-types of this base-class
enum PropertyType
{
- ANY = 0xfff, UNKNOWN = 0x001, MATERIAL = 0x002, METAL = 0x004, EXCITATION = 0x008, PROBEBOX = 0x010, RESBOX = 0x020, DUMPBOX = 0x040, /* unused = 0x080, */
+ ANY = 0xffff, UNKNOWN = 0x001, MATERIAL = 0x002, METAL = 0x004, EXCITATION = 0x008, PROBEBOX = 0x010, RESBOX = 0x020, DUMPBOX = 0x040, /* unused = 0x080, */
DISPERSIVEMATERIAL = 0x100, LORENTZMATERIAL = 0x200, DEBYEMATERIAL = 0x400,
DISCRETE_MATERIAL = 0x1000, LUMPED_ELEMENT = 0x2000, CONDUCTINGSHEET = 0x4000
};
@@ -89,6 +89,8 @@ public:
//! Get Property Type as a string. (default is the xml element name)
virtual const std::string GetTypeString() const {return GetTypeXMLString();}
+ ParameterSet* GetParameterSet() {return clParaSet;}
+
//! Check if Property is a physical material. Current PropertyType: MATERIAL & METAL
bool GetMaterial() {return bMaterial;}
//!Get ID of this property. Used for primitive-->property mapping. \sa SetID
@@ -138,11 +140,13 @@ public:
//! Set a fill-color for this property. \sa GetFillColor
void SetFillColor(RGBa color);
+ void SetFillColor(unsigned char R, unsigned char G, unsigned char B, unsigned char a);
//! Get a fill-color for this property. \sa SetFillColor \return RGBa color object.
RGBa GetFillColor();
//! Set a edge-color for this property. \sa SetEdgeColor
void SetEdgeColor(RGBa color);
+ void SetEdgeColor(unsigned char R, unsigned char G, unsigned char B, unsigned char a);
//! Get a fill-color for this property. \sa GetEdgeColor \return RGBa color object.
RGBa GetEdgeColor();
diff --git a/CSXCAD/src/CSRectGrid.cpp b/CSXCAD/src/CSRectGrid.cpp
index 50f2947..4f90bfe 100644
--- a/CSXCAD/src/CSRectGrid.cpp
+++ b/CSXCAD/src/CSRectGrid.cpp
@@ -255,6 +255,7 @@ bool CSRectGrid::Write2XML(TiXmlNode &root, bool sorted)
TiXmlElement grid("RectilinearGrid");
grid.SetDoubleAttribute("DeltaUnit",dDeltaUnit);
+ grid.SetAttribute("CoordSystem",(int)this->GetMeshType());
TiXmlElement XLines("XLines");
XLines.SetAttribute("Qty",(int)Lines[0].size());
diff --git a/CSXCAD/src/CSXCAD_Global.h b/CSXCAD/src/CSXCAD_Global.h
index 15f1b32..6589ae9 100644
--- a/CSXCAD/src/CSXCAD_Global.h
+++ b/CSXCAD/src/CSXCAD_Global.h
@@ -20,7 +20,7 @@
#define _CSXCAD_LIB_NAME_ "CSXCAD-Lib: Continuous Structure XML - CAD"
#define _CSXCAD_LIB_NAME_SHORT_ "CSXCAD"
-#define _CSXCAD_AUTHOR_ "Thorsten Liebig (2008-2012)"
+#define _CSXCAD_AUTHOR_ "Thorsten Liebig (2008-2016)"
#define _CSXCAD_AUTHOR_MAIL_ "Thorsten.Liebig@gmx.de"
#define _CSXCAD_VERSION_ GIT_VERSION
#define _CSXCAD_LICENSE_ "LGPL v3"
diff --git a/CSXCAD/src/ContinuousStructure.cpp b/CSXCAD/src/ContinuousStructure.cpp
index a0c17a1..2882b04 100644
--- a/CSXCAD/src/ContinuousStructure.cpp
+++ b/CSXCAD/src/ContinuousStructure.cpp
@@ -373,11 +373,11 @@ bool ContinuousStructure::isGeometryValid()
return true;
}
-double* ContinuousStructure::GetObjectArea()
+double* ContinuousStructure::GetObjectArea(CSProperties::PropertyType type)
{
CSPrimitives* prim=NULL;
bool AccBound;
- std::vector<CSPrimitives*> vPrimitives=GetAllPrimitives();
+ std::vector<CSPrimitives*> vPrimitives=GetAllPrimitives(type);
for (size_t i=0;i<vPrimitives.size();++i)
{
prim=vPrimitives.at(i);
@@ -631,6 +631,11 @@ const char* ContinuousStructure::ReadFromXML(const char* file)
return ReadFromXML(&doc);
}
+std::string ContinuousStructure::ReadFromXML(std::string file)
+{
+ return ReadFromXML(file.c_str());
+}
+
void ContinuousStructure::UpdateIDs()
{
for (size_t i=0;i<vProperties.size();++i)
diff --git a/CSXCAD/src/ContinuousStructure.h b/CSXCAD/src/ContinuousStructure.h
index aa986c5..6d2b25b 100644
--- a/CSXCAD/src/ContinuousStructure.h
+++ b/CSXCAD/src/ContinuousStructure.h
@@ -78,7 +78,7 @@ public:
//! Get a primitive by its unique ID.
CSPrimitives* GetPrimitiveByID(unsigned int ID);
- //! Get all primitives with the given name
+ //! Get all properties with the given name
std::vector<CSProperties*> GetPropertiesByName(std::string name);
//! Get a property by its internal index number. \sa GetQtyProperties
@@ -135,7 +135,6 @@ public:
//! Get a primitives array of a certian type
std::vector<CSPrimitives*> GetPrimitivesByType(CSPrimitives::PrimitiveType type);
-
//! Get a primitives array inside a bounding box and with a certian property type (default is any)
std::vector<CSPrimitives*> GetPrimitivesByBoundBox(const double* boundbox, bool sorted=false, CSProperties::PropertyType type=CSProperties::ANY);
@@ -160,7 +159,7 @@ public:
std::string Update();
//! Get an array containing the absolute size of the current structure.
- double* GetObjectArea();
+ double* GetObjectArea(CSProperties::PropertyType type=CSProperties::ANY);
//! Delete and clear all objects includes. This will result in an empty structure.
void clear();
@@ -185,7 +184,9 @@ public:
\param file Filename to read this structure from.
*/
const char* ReadFromXML(const char* file);
- //! Read a structure from a given XML-node.
+ std::string ReadFromXML(std::string file);
+
+ //! Read a structure from a given XML-node.
/*!
\return Will return a string with possible error-messages!
\param rootNode XML-node to read this structure from.
diff --git a/CSXCAD/src/ParameterCoord.cpp b/CSXCAD/src/ParameterCoord.cpp
index 62da688..a79b1dc 100644
--- a/CSXCAD/src/ParameterCoord.cpp
+++ b/CSXCAD/src/ParameterCoord.cpp
@@ -210,8 +210,8 @@ bool ParameterCoord::Evaluate(std::string *ErrStr)
for (int i=0;i<3;++i)
{
EC=m_Coords[i]->Evaluate();
- if (EC!=ParameterScalar::NO_ERROR) bOK=false;
- if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
+ if (EC!=ParameterScalar::PS_NO_ERROR) bOK=false;
+ if ((EC!=ParameterScalar::PS_NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in ParameterCoord (component: " << i << "): ";
diff --git a/CSXCAD/src/ParameterObjects.h b/CSXCAD/src/ParameterObjects.h
index 9e9da49..383999f 100644
--- a/CSXCAD/src/ParameterObjects.h
+++ b/CSXCAD/src/ParameterObjects.h
@@ -15,8 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _PARAMETEROBJECTS_H_
-#define _PARAMETEROBJECTS_H_
+#pragma once
+
/*
* Author: Thorsten Liebig
* Date: 03-12-2008
@@ -210,10 +210,10 @@ std::string PSErrorCode2Msg(int code);
class CSXCAD_EXPORT ParameterScalar
{
public:
- enum EvaluateErrorType
- {
- NO_ERROR
- };
+ enum EvaluateErrorType
+ {
+ PS_NO_ERROR
+ };
ParameterScalar();
ParameterScalar(ParameterSet* ParaSet, double value);
ParameterScalar(ParameterSet* ParaSet, const std::string value);
@@ -247,5 +247,3 @@ protected:
std::string sValue;
double dValue;
};
-
-#endif