ifrit-4.1.2/0000775060175406010010000000000012641012671011213 5ustar HomeNoneifrit-4.1.2/build/0000775060175406010010000000000012641012510012302 5ustar HomeNoneifrit-4.1.2/build/CMakeLists.txt0000775060175406010010000002545412641012510015057 0ustar HomeNone# # Copyright (c) 2002-2015 Nick Gnedin # All rights reserved. # # This file may be distributed and/or modified under the terms of the # GNU General Public License version 2 as published by the Free Software # Foundation and appearing in the file LICENSE.GPL included in the # packaging of this file. # CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) IF(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) ENDIF(COMMAND cmake_policy) SET(src ..) PROJECT(IFrIT) SET(Option:StereoSupport 1 CACHE BOOL "Enable OpenGL support for displaying stereo (disable this option if you see flicker)") # # Portability options # SET(Port:SearchOGL 0 CACHE BOOL "Search for OpenGL (normally should be found automatically)") SET(Port:SearchX11 0 CACHE BOOL "Search for X11 (normally should be found automatically)") SET(Port:NoLongLong 0 CACHE BOOL "Do not use long long type") SET(Port:Debian 0 CACHE BOOL "Do not use long long type") MARK_AS_ADVANCED(Port:SearchOGL Port:SearchX11 Port:NoLongLong) IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) ENDIF(NOT CMAKE_BUILD_TYPE) # # --------------------------------------------------------------------------- # # Configuration # # --------------------------------------------------------------------------- # # Shells # IF(WIN32) OPTION(Shell:CL "Include command-line shell" OFF) ELSE(WIN32) OPTION(Shell:CL "Include command-line shell" ON) ENDIF(WIN32) OPTION(Shell:QT "Include Qt-based GUI shell" ON) OPTION(Shell:OS "Include off-screen shell" ON) SET(tty_shells) SET(gui_shells) IF(Shell:CL) SET(tty_shells ${tty_shells} cl) ENDIF(Shell:CL) IF(Shell:OS) SET(tty_shells ${tty_shells} os) ENDIF(Shell:OS) IF(Shell:QT) SET(gui_shells ${gui_shells} qt) ENDIF(Shell:QT) IF(NOT tty_shells AND NOT gui_shells) MESSAGE(FATAL_ERROR "At least one shell must be selected.") ENDIF(NOT tty_shells AND NOT gui_shells) # # Scripts # OPTION(Script:PY "Use Python as scripting language" ON) SET(scripts) IF(Script:PY) SET(scripts ${scripts} python) ENDIF(Script:PY) IF(NOT scripts) MESSAGE("No scripting language is selected - IFrIT will not be able to use scripts.") ENDIF(NOT scripts) IF(Shell:OS AND NOT scripts) MESSAGE(FATAL_ERROR "The off-screen shell will not work without a script.") ENDIF(Shell:OS AND NOT scripts) # # Find max extension flag # SET(maxNum 1) FILE(READ ${src}/configure/iextensiondefines.h f) STRING(REGEX MATCHALL "#define IEXTENSION_[A-Z0-9_]*[ \t]*[0-9]*" m ${f}) IF(m) STRING(REGEX REPLACE "#define IEXTENSION_[A-Z0-9_]*[ \t]*([0-9]*)" "\\1;" num ${m}) SET(num ${num}0) FOREACH(n ${num}) IF(n GREATER ${maxNum}) SET(maxNum ${n}) ENDIF(n GREATER ${maxNum}) ENDFOREACH(n ${num}) ENDIF(m) # # Configure extensions # SET(extensions) FILE(GLOB dir ${src}/build/install.*.cpp) IF(dir) FOREACH(s ${dir}) STRING(REGEX REPLACE "^.*install\\.([A-Z0-9_]*)\\.cpp" "\\1" e ${s}) OPTION(Extension:${e} "Include ${e} extension" ON) IF(Extension:${e}) set(extensions ${extensions} ${e}) ENDIF(Extension:${e}) # # Check that the define for this extension has been set already. # STRING(REGEX MATCH "#define IEXTENSION_${e}[ \t]*[0-9]*" m ${f}) IF(NOT m) MESSAGE("Extension ${e} has not been defined in configure/iextensiondefines.h.\n I will define it for you.") SET(maxNum 2*${maxNum}) FILE(APPEND ${src}/configure/iextensiondefines.h "#define IEXTENSION_${e} ${maxNum}\n") ENDIF(NOT m) ENDFOREACH(s ${dir}) ENDIF(dir) # # --------------------------------------------------------------------------- # # Find dependencies # # --------------------------------------------------------------------------- # # Find VTK FIND_PACKAGE(VTK REQUIRED) IF(NOT VTK_FOUND) MESSAGE(FATAL_ERROR " VTK is not found. Please check that VTKDIR variables is set properly.") ENDIF(NOT VTK_FOUND) INCLUDE(${VTK_USE_FILE}) IF(VTK_USE_VOLUMEPRO AND VTK_HAVE_VP1000) OPTION(CustomVP1000 "Include custom support for VP1000" ON) ENDIF(VTK_USE_VOLUMEPRO AND VTK_HAVE_VP1000) # Find OpenGL IF(Port:SearchOGL) FIND_PACKAGE(OPENGL REQUIRED) IF(NOT OPENGL_FOUND) MESSAGE(FATAL_ERROR " OpenGL is not found. Please set advanced variables OPENGL_INCLUDE_DIR and OPENGL_LIBRARIES.") ENDIF(NOT OPENGL_FOUND) INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) ENDIF(Port:SearchOGL) # Find X11 IF(UNIX AND Port:SearchX11) FIND_PACKAGE(X11 REQUIRED) IF(NOT X11_FOUND) MESSAGE(FATAL_ERROR " X11 is not found. Please set advanced variables X11_X11_INCLUDE_PATH and X11_LIBRARIES.") ENDIF(NOT X11_FOUND) INCLUDE_DIRECTORIES(${X11_X11_INCLUDE_PATH}) ENDIF(UNIX AND Port:SearchX11) IF(Shell:QT) # Find Qt SET(QT_REQUIRED 1) INCLUDE(${CMAKE_ROOT}/Modules/FindQt.cmake) INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) IF(QT4_INSTALLED) INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}/QtCore) ENDIF(QT4_INSTALLED) ADD_DEFINITIONS(${QT_DEFINITIONS}) ENDIF(Shell:QT) IF(Script:PY) # Find Python SET(Python_ADDITIONAL_VERSIONS 3.4 3.3 3.2 3.1 3.0) INCLUDE(${CMAKE_ROOT}/Modules/FindPythonLibs.cmake) IF(PYTHONLIBS_FOUND) IF(PYTHONLIBS_VERSION_STRING STRLESS "2.7.0") MESSAGE(FATAL_ERROR " IFrIT needs Python 2.7 and higher. Please upgrade your Python installation.") ENDIF(PYTHONLIBS_VERSION_STRING STRLESS "2.7.0") INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS}) SET(BuildPythonModule 0 CACHE BOOL "Build and install a shared library for Python import. That requires that all VTK, Qt, and Python libraries are built as shared objects.") ELSE(PYTHONLIBS_FOUND) MESSAGE(FATAL_ERROR " Python is not found. Install Python on your system or uncheck Script:PY option") ENDIF(PYTHONLIBS_FOUND) ENDIF(Script:PY) # # --------------------------------------------------------------------------- # # Create the project # # --------------------------------------------------------------------------- # SET(my_shl 0) SET(my_scr 0) SET(my_ext 0) # # Core # FILE(GLOB sources ${src}/configure/*.cpp ${src}/core/*.cpp ${src}/help/*.cpp) INCLUDE_DIRECTORIES(${src}/configure ${src}/core ${src}/help ${src}/docs) # # Shells # IF(gui_shells) FILE(GLOB tmp ${src}/shells/configure/*.cpp ${src}/shells/generic/*.cpp ${src}/shells/base/*.cpp) IF(tmp) SET(sources ${sources} ${tmp}) INCLUDE_DIRECTORIES(${src}/shells/configure ${src}/shells/generic ${src}/shells/base) ENDIF(tmp) ENDIF(gui_shells) FOREACH(s ${tty_shells} ${gui_shells}) FILE(GLOB tmp ${src}/shells/${s}/*.cpp) IF(tmp) SET(sources ${sources} ${tmp}) INCLUDE_DIRECTORIES(${src}/shells/${s}) STRING(TOUPPER ${s} us) SET(my_shl ${my_shl}+ISHELL_${us}) ENDIF(tmp) ENDFOREACH(s) # # Scripts # IF(scripts) FILE(GLOB tmp ${src}/scripts/configure/*.cpp) IF(tmp) SET(sources ${sources} ${tmp}) INCLUDE_DIRECTORIES(${src}/scripts/configure) ENDIF(tmp) ENDIF(scripts) FOREACH(s ${scripts}) FILE(GLOB tmp ${src}/scripts/${s}/*.cpp) IF(tmp) SET(sources ${sources} ${tmp}) INCLUDE_DIRECTORIES(${src}/scripts/${s}) STRING(TOUPPER ${s} us) SET(my_scr ${my_scr}+ISCRIPT_${us}) ENDIF(tmp) ENDFOREACH(s) # # Extensions # FOREACH(e ${extensions}) SET(my_ext ${my_ext}+IEXTENSION_${e}) ENDFOREACH(e) FILE(GLOB tmp ${src}/core/imultiviewrendertool.cpp) IF(tmp) SET(my_ext ${my_ext}+IEXTENSION_MV) ENDIF(tmp) # # Special # IF(Shell:QT) SET(qtdir ${src}/shells/qt) SET(qthdr ${qtdir}/iqtwidgettexteditorsubject.h ${qtdir}/iqtwidgethelper.h ${qtdir}/iqtrenderwindowsubject.h ${qtdir}/iqtmenuwindowsubject.h ${qtdir}/iqtmainwindowsubject.h ${qtdir}/iqtframesubject.h) SET(tmp) QT_WRAP_CPP(dummy tmp ${qthdr}) SET(sources ${sources} ${tmp}) ENDIF(Shell:QT) IF(CustomVP1000) FILE(GLOB tmp ${src}/special/vp1000/*.cpp) IF(tmp) SET(sources ${sources} ${tmp}) INCLUDE_DIRECTORIES(${src}/special/vp1000) ADD_DEFINITIONS(-DI_CUSTOM_VP1000) ENDIF(tmp) ENDIF(CustomVP1000) IF(Extension:ART) FILE(GLOB tmp ${src}/special/artio/*.c) IF(tmp) SET(sources ${sources} ${tmp}) INCLUDE_DIRECTORIES(${src}/special/artio) ENDIF(tmp) ENDIF(Extension:ART) ADD_DEFINITIONS(-DI_EXTERNAL_CONFIGURATION) IF(CMAKE_BUILD_TYPE MATCHES "Debug") ADD_DEFINITIONS(-DI_DEBUG -DI_CHECK) ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug") # # Edition # FILE(GLOB tmp ${src}/configure/edition*.cpp) IF(tmp) ADD_DEFINITIONS(-DI_EDITION) ENDIF(tmp) FILE(GLOB tmp ${src}/configure/iconfiguresettings.ext) CONFIGURE_FILE(${tmp} ${tmp}.h @ONLY) IF(NOT Option:StereoSupport) ADD_DEFINITIONS(-DI_NO_STEREO) ENDIF(NOT Option:StereoSupport) # # Portability # IF(Port:NoLongLong) ADD_DEFINITIONS(-DI_NO_LONG_LONG) ENDIF(Port:NoLongLong) IF(Port:Debian) ADD_DEFINITIONS(-DI_PORT_DEBIAN) ENDIF(Port:Debian) # # Add libraries # FUNCTION(link target) TARGET_LINK_LIBRARIES(${target} ${VTK_LIBRARIES}) IF(Port:SearchOGL) TARGET_LINK_LIBRARIES(${target} ${OPENGL_LIBRARIES}) ENDIF(Port:SearchOGL) IF(UNIX AND Port:SearchX11) TARGET_LINK_LIBRARIES(${target} ${X11_LIBRARIES}) ENDIF(UNIX AND Port:SearchX11) IF(Shell:QT) IF(QT_LIBRARIES) TARGET_LINK_LIBRARIES(${target} ${QT_LIBRARIES}) ENDIF(QT_LIBRARIES) IF(QT4_INSTALLED) TARGET_LINK_LIBRARIES(${target} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QT3SUPPORT_LIBRARY} ${QT_QTOPENGL_LIBRARY}) IF (WIN32) FIND_LIBRARY(QT_QTMAIN_LIBRARY qtmain ${QT_LIBRARY_DIR} DOC "This Library is only needed by and included with Qt on MSWindows. It should be NOTFOUND, undefined or IGNORE otherwise.") IF(QT_QTMAIN_LIBRARY) TARGET_LINK_LIBRARIES(${target} ${QT_QTMAIN_LIBRARY}) ELSE(QT_QTMAIN_LIBRARY) MESSAGE(FATAL_ERROR " Qt Main library qtmain.lib is not found.") ENDIF(QT_QTMAIN_LIBRARY) ENDIF (WIN32) ENDIF(QT4_INSTALLED) ENDIF(Shell:QT) IF(Script:PY) TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIBRARIES}) IF(UNIX) TARGET_LINK_LIBRARIES(${target} util) ENDIF(UNIX) ENDIF(Script:PY) ENDFUNCTION(link) # # Create targets # FILE(GLOB dir install.*.cpp) ADD_LIBRARY(temp STATIC ${sources}) SET_TARGET_PROPERTIES(temp PROPERTIES POSITION_INDEPENDENT_CODE true) link(temp) IF(tty_shells) ADD_EXECUTABLE(ifrit ifrit.cpp ${dir}) ELSE(tty_shells) ADD_EXECUTABLE(ifrit WIN32 ifrit.cpp ${dir}) ENDIF(tty_shells) SET_TARGET_PROPERTIES(ifrit PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..) TARGET_LINK_LIBRARIES(ifrit temp) INSTALL(TARGETS ifrit RUNTIME DESTINATION bin) IF(BuildPythonModule AND PYTHON_INCLUDE_DIRS) ADD_LIBRARY(python SHARED python.cpp ${dir}) SET_TARGET_PROPERTIES(python PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(python PROPERTIES OUTPUT_NAME ifrit) SET_TARGET_PROPERTIES(python PROPERTIES LIBRARY_OUTPUT_DIRECTORY ..) TARGET_LINK_LIBRARIES(python temp) STRING(REGEX REPLACE "libpython([0-9]\\.[0-9])[m]*\\.[a-z]*" "python\\1/site-packages" dir ${PYTHON_LIBRARIES}) IF(EXISTS ${dir}) INSTALL(TARGETS python LIBRARY DESTINATION ${dir}) ELSE(EXISTS ${dir}) MESSAGE(ERROR " Unable to find the installation directory " ${dir} " for Python module. Python module will not be installed.") ENDIF(EXISTS ${dir}) ENDIF(BuildPythonModule AND PYTHON_INCLUDE_DIRS) ifrit-4.1.2/build/ifrit.cpp0000775060175406010010000001156512641012510014136 0ustar HomeNone//LICENSE A // // The IFrIT logo has been created using: // 1. Microsoft Agent software and Microsoft Agent character "Genie"; copyright (c) 1996-1998 Microsoft Corporation. All rights reserved. // 2. ACS Viewer 1.1, build 12; copyright (c) 2005 Grigory Filatov. // #include "irunner.h" #include #ifdef I_DEBUG #include #include "ihelpfactory.h" #endif namespace ifrit { void TestPerformance(); }; int main(int argc, const char **argv) { #ifdef I_DEBUG //iHelpFactory::CreateUserGuide(); //exit(0); #endif // // Skip program name // argc--; argv++; // // Check if a test call // if(argc==1 && (strcmp(argv[0],"test")==0 || strcmp(argv[0],"-test")==0 || strcmp(argv[0],"--test")==0)) { ifrit::TestPerformance(); return 0; } iRunner app; // that loads the factories app.Run(argc,argv); return 0; } #include "ivtk.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace ifrit { float TestRenderingPerformance(vtkRenderer *ren) { // // Set up the timer // ren->GetActiveCamera()->SetPosition(0.0,0.0,1.0); ren->ResetCamera(); ren->GetRenderWindow()->Render(); vtkTimerLog *timer = vtkTimerLog::New(); timer->StartTimer(); int i; float r = 0; do { for(i=0; i<35; i++) { ren->GetActiveCamera()->Azimuth(9); ren->GetRenderWindow()->Render(); } for(i=0; i<35; i++) { ren->GetActiveCamera()->Elevation(9); ren->GetActiveCamera()->OrthogonalizeViewUp(); ren->GetRenderWindow()->Render(); } for(i=0; i<40; i++) { ren->GetActiveCamera()->Roll(9); ren->GetRenderWindow()->Render(); } for(i=0; i<5; i++) { ren->GetActiveCamera()->Elevation(9); ren->GetActiveCamera()->OrthogonalizeViewUp(); ren->GetRenderWindow()->Render(); } for(i=0; i<5; i++) { ren->GetActiveCamera()->Azimuth(9); ren->GetRenderWindow()->Render(); } timer->StopTimer(); r += 1; } while(timer->GetElapsedTime() < 3.0); r /= timer->GetElapsedTime(); timer->Delete(); return r; } void TestPerformance() { int i; const float renRateScale[2] = { 7.5f, 7.5f }; vtkRenderer *ren = vtkRenderer::New(); vtkRenderWindow *win = vtkRenderWindow::New(); win->AddRenderer(ren); ren->Delete(); vtkImageData *data = vtkImageData::New(); data->SetDimensions(17,17,17); data->SetSpacing(0.125,0.125,0.125); data->SetOrigin(-1.0,-1.0,-1.0); #ifdef IVTK_5 data->SetScalarType(VTK_UNSIGNED_CHAR); data->SetNumberOfScalarComponents(1); data->AllocateScalars(); #else data->AllocateScalars(VTK_UNSIGNED_CHAR,1); #endif unsigned char *ptr = (unsigned char *)data->GetScalarPointer(); for(i=0; iGetNumberOfPoints(); i++) { ptr[i] = i % 256; } vtkCubeSource *cube = vtkCubeSource::New(); cube->Update(); vtkGlyph3D *glyph = vtkGlyph3D::New(); glyph->SetScaleModeToDataScalingOff(); glyph->SetColorModeToColorByScalar(); glyph->SetScaleFactor(0.08); glyph->SetSourceConnection(cube->GetOutputPort()); glyph->SetInputData(data); cube->Delete(); glyph->Update(); vtkPolyDataMapper *mapper = vtkPolyDataMapper::New(); vtkActor *actor = vtkActor::New(); mapper->ScalarVisibilityOn(); mapper->SetColorModeToMapScalars(); vtkLookupTable *lut = vtkLookupTable::New(); lut->SetRange(0.0,255.0); //lut->SetHueRange(0.0,255.0); mapper->SetLookupTable(lut); mapper->UseLookupTableScalarRangeOn(); lut->Delete(); actor->GetProperty()->SetColor(0.0,0.0,0.0); actor->SetMapper(mapper); mapper->Delete(); mapper->SetInputConnection(glyph->GetOutputPort()); glyph->Delete(); ren->AddActor(actor); actor->Delete(); // // set the scene // win->SetSize(512,512); ren->SetBackground(1.0,1.0,1.0); // // draw the resulting scene // win->SetWindowName("IFrIT - Performance Test"); win->Render(); win->SetWindowName("IFrIT - Performance Test"); actor->GetProperty()->SetOpacity(1.0); actor->GetProperty()->SetColor(0.0,0.0,1.0); float rr1 = TestRenderingPerformance(ren)*renRateScale[0]; actor->GetProperty()->SetOpacity(0.03); actor->GetProperty()->SetColor(1.0,0.0,0.0); float rr2 = TestRenderingPerformance(ren)*renRateScale[1]; char str[1000]; sprintf(str, "Rendering performance:\n\n" "Opaque:\t\t %.1f\n" "Transparent:\t %.1f\n\n" "Representative rangers for values:\n" "1-2\tLaptop with a chipset\n" "5-20\tDesktop with a low-end video card\n" "50-200\tWorkstation with a high-end video card\n\n" "VTK Version: %s\n",rr1,rr2,VTK_VERSION); vtkOutputWindow::GetInstance()->DisplayText(str); data->Delete(); win->RemoveRenderer(ren); win->Delete(); } }; ifrit-4.1.2/build/python.cpp0000674060175406010010000000204412641012510014330 0ustar HomeNone #include "iconfigure.h" #if ISCRIPT_INCLUDED(ISCRIPT_PYTHON) #include namespace ipyPrivate { PyObject* Start(PyObject *module, PyObject *args); void Free(void *ptr); }; PyMethodDef ModuleMethods[] = { {"start", ipyPrivate::Start, METH_VARARGS, "Start IFrIT."}, {NULL, NULL, 0, NULL} /* Sentinel */ }; #if (PY_MAJOR_VERSION > 2) PyModuleDef Module = { PyModuleDef_HEAD_INIT, "ifrit", "Module that provides access to IFrIT objects and their properties.", 0, ModuleMethods, NULL, NULL, NULL, NULL }; PyMODINIT_FUNC PyInit_ifrit(void) { // // Create the module // Module.m_free = &ipyPrivate::Free; PyObject* module = PyModule_Create(&Module); return module; } #else #if (PY_MINOR_VERSION < 7) #error IFrIT needs Python 2.7 or Python 3 #endif PyMODINIT_FUNC initifrit(void) { // // Create the module // PyObject *Module = Py_InitModule("ifrit",ModuleMethods); Py_InitModule4("ifrit",ModuleMethods,"Module that provides access to IFrIT objects and their properties.",Module,PYTHON_API_VERSION); } #endif #endif ifrit-4.1.2/configure/0000775060175406010010000000000012641012671013174 5ustar HomeNoneifrit-4.1.2/configure/iconfigure.h0000775060175406010010000000537012641012512015501 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Main configuration parameters and macros for working with them // #ifndef ICONFIGURE_H #define ICONFIGURE_H // // Supported extensions // #define IEXTENSION_NONE 0 #define IEXTENSION_MV 0x80000000 #include "iextensiondefines.h" // // Supported shells // #define ISHELL_OS 1 #define ISHELL_CL 2 #define ISHELL_GG 0xFFFFFFFC #define ISHELL_QT 4 // // Supported scripts // #define ISCRIPT_PYTHON 1 // // Multiple extensions can be included, they are not exclusive // #define IEXTENSION_INCLUDED(_Type_) ((IEXTENSION & _Type_) != 0) // // Multiple shells can be included, they are not exclusive // #define ISHELL_INCLUDED(_Type_) ((ISHELL & _Type_) != 0) // // Multiple scripts can be included, they are not exclusive // #define ISCRIPT_INCLUDED(_Type_) ((ISCRIPT & _Type_) != 0) // // ****************************************************************************** // // Set the parameters that define shell and extension. // #ifdef I_EXTERNAL_CONFIGURATION #include "iconfiguresettings.ext.h" #else #define IEXTENSION 0xFFFFFFFF #define ISHELL 0xFFFFFFFF #define ISCRIPT 1 #endif // // ****************************************************************************** // #if !defined(IEXTENSION) #error Misconfiguration: extension (IEXTENSION) is not set. !TERMINATE! #endif #if !defined(ISHELL) || (ISHELL == 0) #error Misconfiguration: shell (ISHELL) is not set. !TERMINATE! #endif #if !defined(ISCRIPT) #error Misconfiguration: script (ISCRIPT) is not set. !TERMINATE! #endif #endif // ICONFIGURE_H ifrit-4.1.2/configure/iconfiguresettings.ext0000775060175406010010000000250212641012513017626 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #define IEXTENSION @my_ext@ #define ISCRIPT @my_scr@ #define ISHELL @my_shl@ ifrit-4.1.2/configure/iedition.cpp0000775060175406010010000000301112641012512015474 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iconfigure.h" #include "iedition.h" #include "iobject.h" #include "istring.h" #ifndef I_EDITION void iEdition::ApplySettings(iObject *obj) { } const iString& iEdition::GetEditionName() { static const iString name("Standard Edition"); return name; } #endif ifrit-4.1.2/configure/iedition.h0000775060175406010010000000277712641012512015163 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // This class encapsulates edition-specific settings // #ifndef IEDITION_H #define IEDITION_H class iObject; class iString; class iEdition { public: static void ApplySettings(iObject *obj); static const iString& GetEditionName(); }; #endif // IEDITION_H ifrit-4.1.2/configure/iextensiondefines.h0000775060175406010010000000306112641012512017065 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Supported extensions // // DESCRIPTION: // Extensions in IFRIT must be associated with power-of-two ids, so that they can be ORed together. // #define IEXTENSION_ART 1 #define IEXTENSION_VTK 2 #define IEXTENSION_GADGET 4 // // Keep adding new defines here, but, please, do not change the existing ones. // ifrit-4.1.2/configure/irendertoolnew.cpp0000674060175406010010000000324512641012513016740 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iconfigure.h" #include "irendertool.h" #include "ierror.h" #if IEXTENSION_INCLUDED(IEXTENSION_MV) #include "imultiviewrendertool.h" #endif // // Factory method // iRenderTool* iRenderTool::New(iViewModule *vm) { IASSERT(vm); #if IEXTENSION_INCLUDED(IEXTENSION_MV) iRenderTool *tmp = new iMultiViewRenderTool(vm); #else iRenderTool *tmp = new iRenderTool(vm); #endif IERROR_CHECK_MEMORY(tmp); return tmp; } ifrit-4.1.2/configure/iscriptnew.cpp0000674060175406010010000000310512641012513016062 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iconfigure.h" #include "iscript.h" #include "ierror.h" // // Factory method (move somewhere else?) // #if ISCRIPT_INCLUDED(ISCRIPT_PYTHON) #include "../scripts/python/ipyscript.h" #endif iScript* iScript::New(iShell *s) { IASSERT(s); #if ISCRIPT_INCLUDED(ISCRIPT_PYTHON) return new ipyScript(s); #endif return 0; } ifrit-4.1.2/configure/ishellnew.cpp0000674060175406010010000000510512641012513015667 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iconfigure.h" #include "ishell.h" // // Factory method // #if ISHELL_INCLUDED(ISHELL_OS) #include "iosshell.h" #endif #if ISHELL_INCLUDED(ISHELL_CL) #include "iclshell.h" #endif #if ISHELL_INCLUDED(ISHELL_GG) #include "iggshell.h" #endif iShell* iShell::New(iRunner *runner, int argc, const char **argv) { // // Shell specifications // const char* list[] = { #if ISHELL_INCLUDED(ISHELL_QT) "qt", "qt/embed", "qt/exten", #endif #if ISHELL_INCLUDED(ISHELL_CL) "cl", #endif #if ISHELL_INCLUDED(ISHELL_OS) "os", #endif 0 }; iString type = list[0]; // // Also use options to specify shell - they overwrite the default choice // if(argc > 0) { iString s = iString(argv[0]); if(s[0] == '-') s = s.Part(1); int i = 0; while(list[i] != 0) { if(s == list[i]) { type = s; argc--; argv++; break; } i++; } } int mode = 0; if(type.EndsWith("/exten")) mode = 1; if(type.EndsWith("/embed")) mode = 2; #if ISHELL_INCLUDED(ISHELL_OS) if(type.BeginsWith("os")) { return new iosShell(runner,type.Part(0,2),argc,argv); } #endif #if ISHELL_INCLUDED(ISHELL_CL) if(type.BeginsWith("cl")) { return new iclShell(runner,true,type.Part(0,2),argc,argv); } #endif #if ISHELL_INCLUDED(ISHELL_GG) return new iggShell(runner,(mode==1),type.Part(0,2),argc,argv); #else return 0; #endif } ifrit-4.1.2/configure/iversion.cpp0000775060175406010010000002431012641012671015541 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iconfigure.h" #include "iversion.h" // // IFrIT version // #define IVERSION "4.1.2" #define IREVISION "581" // // History // // 060608 Base-3.0.0b1 ART-2.0.0b1 MV-1.0.0b1 -- First beta release // 060609 Base-3.0.0b2 ART-2.0.0b2 MV-1.0.0b2 -- Added special locations in CrossSectionViewSubject // 060622 Base-3.0.0b3 ART-2.0.0b3 MV-1.0.0b3 -- Added coordinate system switch for ART extension // 060701 Base-3.0.0b4 ART-2.0.0b4 MV-1.0.0b4 -- Added abstract/generic filters for porting, cleaned up class names // 060707 Base-3.0.0b5 ART-2.0.0b5 MV-1.0.0b5 -- Completed Script Debugger // 060721 Base-3.0.0b6 ART-2.0.0b6 MV-1.0.0b6 -- Completed port to Qt4 // 060728 Base-3.0.0b7 ART-2.0.0b7 MV-1.0.0b7 -- Internal changes, docking fixed (?) // 060815 Base-3.0.0b8 ART-2.0.0b8 MV-1.0.0b8 -- New icons, docking now really fixed, x-section in texture mode on multiple processors is fixed // Includes 3D texture model for volume rendering and direct MPEG/AVI movie creation // 060817 Base-3.0.0 ART-2.0.0 MV-1.0.0 -- First release: basic things seem to work now. // 060830 Base-3.0.1 ART-2.0.1 MV-1.0.0 -- Some bug fixes // 060926 Base-3.0.2 ART-2.0.2 MV-1.0.0 -- Refactored for simplified extensions (ViewSubjects etc) // 060930 Base-3.0.3 ART-2.0.3 MV-1.0.0 -- Need to re-release, created a branch in CVS too early by mistake // 061003 Base-3.0.4 ART-2.0.4 MV-1.0.0 -- Added special brightness palette, fixed iArray out-of-boundary bug, fixed DataExplorer bug // 061010 Base-3.0.5 ART-2.0.5 MV-1.0.0 -- fixed Interactor bug, ART isosurface bugs(?), more iArray out-of-boundary bugs // 061119 Base-3.0.6 ART-2.0.6 MV-1.0.0 -- fixed DataLimits+clones bug, RulerDialog bug, parallel stitch bug, added window list idalog, x-section placement enhancements // 061120 Base-3.0.7 ART-2.0.7 MV-1.0.0 -- work around vtkMarchingContourFilter multi-threaded bug. // 061221 Base-3.0.8 ART-2.0.8 MV-1.0.1 -- internal changes, pseudo-color composing in ImageComposer, minor GUI modifications, bug fixes. // 070203 Base-3.0.9 ART-2.0.9 MV-1.0.1 -- internal changes to particle masking, new masking modes, bug fixes // // 070325 Base-3.1.0 ART-2.1.0 MV-1.0.2 VTK-1.0.0b0 GADGET-1.0.0b0 // split DataSubject into DataSubject proper and DataFileLoader // added VTK & GADGET extensions // fixed MultiView full-screen mode bugs // // 070422 Base-3.1.1 ART-2.1.2 MV-1.0.2 VTK-1.0.0b0 GADGET-1.0.0b1 // fixed marker Create/Delete panel bug // other stylistic bug fixes // redone volume rendering interface // ART 2D & 3D texture volume rendering by uniform resampling // // 070502 Base-3.1.2 ART-2.1.3 MV-1.0.3 VTK-1.0.0b0 GADGET-1.0.0b2 // C-style casting replaced whereever possible // ViewModule::LabelOffset property added // Fixed bugs in iDataExplorer // Fixed bugs in recognizing animatable filename without a suffix // // 070508 Base-3.1.3 ART-2.1.3 MV-1.0.3 VTK-1.0.0b0 GADGET-1.0.0b2 // Fixed bugs with saving markers and animation not stopping on error // New markers are placed in the camera focal point // // 070527 Base-3.1.4 ART-2.1.4 MV-1.0.4 VTK-1.0.0b1 GADGET-1.0.0b2 // Added external image as a background // Fixed batch mode and channeling output // Fixed shifting // // 070618 Base-3.1.5 ART-2.1.5 MV-1.0.4 VTK-1.0.0b1 GADGET-1.0.0b2 // Added zooms in Composer // Fixed particle picking // Added particle auto-scaling // Fixed offscreen mode with Mesa libraries // // 070710 Base-3.1.6 ART-2.1.5 MV-1.0.4 VTK-1.0.0b1 GADGET-1.0.0b2 // Composer bug fixes // // 070826 Base-3.2.0 ART-2.1.5 MV-1.0.4 VTK-1.0.0b1 GADGET-1.0.0b2 // VTK-style iExpressionParser replaced with iCalculator // scripts are completely re-written and expanded // // 070916 Base-3.2.1 ART-2.1.5 MV-1.0.4 VTK-1.0.0b1 GADGET-1.0.0b2 // Bug fixes // // 071018 Base-3.2.2 ART-2.1.6 MV-1.0.4 VTK-1.0.0b1 GADGET-1.0.0b2 // Abundances/densities switch for species in ART extension // Bug fixes // // 080112 Base-3.2.3 ART-2.1.6 MV-1.0.4 VTK-1.0.0b1 GADGET-1.0.0b2 // Bug fixes in iOrthoSlicer and iBoundedPolyDataSource // // 080510 Base-3.2.4 ART-2.1.7 MV-1.0.4 VTK-1.0.0 GADGET-1.0.0 // Minor bug fixes // // 080510 Base-3.2.5 ART-2.1.8 MV-1.0.4 VTK-1.0.0 GADGET-1.0.0 // Color bar size, minor bug fixes, including finite cross-section bar in ART edition // // 080824 Base-3.2.6 ART-2.1.8 MV-1.0.4 VTK-1.0.0 GADGET-1.0.0 // Depth search option as a way to fix VTK artifacts, refresh button on FileSet dialog // // 081019 Base-3.2.7 ART-2.1.8 MV-1.1.0 VTK-1.0.0 GADGET-1.0.0 // MultiView extension redone, port to VTK 5.2, fixed overlays // // 090822 Base-3.2.8 ART-2.2.0 MV-1.1.0 VTK-1.0.0 GADGET-1.0.0 // Fixed isosurface making for left/right coordinate systems in ART extension // Renamed HART extension into ART extension and added support for CART // // 091210 Base-3.2.9 ART-2.2.1 MV-1.1.0 VTK-1.0.0 GADGET-1.0.0 // Added double precision particle positions reading for CART // Fixed a few minor bugs // // 100222 Base-3.3.0 ART-2.3.0 MV-1.2.0 VTK-1.1.0 GADGET-1.1.0 // Removed last vestiges of Qt3 when using Qt4 - Qt3Support is not needed any more // Ported to 64-bin windows // // 100315 Base-3.3.1 ART-2.3.0 MV-1.2.0 VTK-1.1.0 GADGET-1.1.0 // Emergency release: removed support for VTK 5.4 due to its performance bug // // 100503 Base-3.3.2 ART-2.3.1 MV-1.2.1 VTK-1.1.0 GADGET-1.1.0 // Fixed bug with ART streamlines, fixed anti-aliasiang bug in docking, blocked // all extraneous functions in iggRenderWindow, re-factored the stereo mode to // fix the flicker reported by Doug and stereo non-recongnition reported by Patrick. // // 100722 Base-3.3.3 ART-2.3.1 MV-1.2.1 VTK-1.1.0 GADGET-1.1.0 // Fixed a bug with Qt4 under Unix // // 100818 Base-3.3.4 ART-2.3.1 MV-1.2.1 VTK-1.1.0 GADGET-1.1.0 // Fixed a bug with crashes in cross section, reported by Robyn // Ported to VTK 5.6.1, added GPU Volume rendering support // Removed Event Recorder as it caused compilation errors on some compilers // // 120320 Base-3.3.5 ART-2.3.2 MV-1.2.1 VTK-1.1.0 GADGET-1.1.0 // A few bug fixes. // Ported to VTK 5.8.0, added GPU Volume rendering support // // 120809 Base-3.4.0 ART-2.4.0 MV-1.2.1 VTK-1.1.0 GADGET-1.1.0 // Mioved to Mercurial SC // ARTIO and CART io support // Some widget modification (FileName, Color) // Removed CameraPath Animator mode, fixed title page and logo // // 121219 Base-3.4.1 ART-2.4.0 MV-1.2.1 VTK-1.1.0 GADGET-1.1.0 // some bug fixes // // 130710 Base-3.4.2 ART-2.4.1 MV-1.2.1 VTK-1.1.0 GADGET-1.1.0 // some bug fixes // // 581*********************************************************************** // Drop sub-versioning for extensions // // 140309 4.0.0B1 // Full Python integration, initial release // // 141118 4.0.0B2 // Bug fixes, added two new palettes // // 141225 4.0.0B3 // Active instances/etc are controlled by the shell now, small changes in the GUI // // 141228 4.0.0 // Only tiny changes over B3, releasing as 4.0.0 // // 150212 4.0.1 // Two small bugs fixed // // 150216 4.1.0 // Port to VTK6, refactored eror reporting (use Monitor), progress observer, output, histogram making, some GUI changes. // // 150301 4.1.1 // Off-screen shell // // 15.... 4.1.2 // Bug fixes, Debian portability switch, fixed the bug with render observer not displaying, new ART mode // // // ToDo (major additions) // // 1. Point sprats for particles // 2. Multiple images in Composer (do we need this???) // #if ISHELL_INCLUDED(ISHELL_GG) #include "iggsubjectfactory.h" #endif const iString iVersion::GetVersion() { return iString(IVERSION); } const iString iVersion::GetRevisionId() { return iString(IREVISION); } const iString iVersion::GetIncludedExtensions() { iString tmp; #if IEXTENSION_INCLUDED(IEXTENSION_ART) tmp += "ART extension;"; #endif #if IEXTENSION_INCLUDED(IEXTENSION_MV) tmp += "MultiView extension;"; #endif #if IEXTENSION_INCLUDED(IEXTENSION_GADGET) tmp += "GADGET extension;"; #endif #if IEXTENSION_INCLUDED(IEXTENSION_VTK) tmp += "Native-VTK extension;"; #endif return tmp; } const iString iVersion::GetIncludedShells() { iString tmp; #if ISHELL_INCLUDED(ISHELL_OS) tmp += iString("Off-screen shell") + ";"; #endif #if ISHELL_INCLUDED(ISHELL_CL) tmp += iString("Command-line shell") + ";"; #endif #if ISHELL_INCLUDED(ISHELL_GG) tmp += iggSubjectFactory::GetIncludedShells(); #endif return tmp; } ifrit-4.1.2/configure/iversion.h0000775060175406010010000000305512641012512015203 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // IFrIT version and build // #ifndef IVERSION_H #define IVERSION_H #include "istring.h" class iVersion { public: static const iString GetVersion(); static const iString GetRevisionId(); static const iString GetIncludedShells(); static const iString GetIncludedExtensions(); }; #endif // IVERSION_H ifrit-4.1.2/configure/ivtk.h0000775060175406010010000000376712641012512014334 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // VTK version and build (porting helper) // #ifndef IVTK_H #define IVTK_H #include #include #if (VTK_MAJOR_VERSION < 5) || (VTK_MAJOR_VERSION==5 && VTK_MINOR_VERSION<6) #error "This version of VTK is too old and is no longer supported." #endif #if (VTK_MAJOR_VERSION==5 && VTK_MINOR_VERSION<10) #define IVTK_5_PRE10 #endif #if (VTK_MAJOR_VERSION==5 && VTK_MINOR_VERSION<8) #define IVTK_5_PRE8 #endif #if (VTK_MAJOR_VERSION == 5) #define IVTK_5 #define SetInputData SetInput #define AddInputData AddInput #define SetSourceData SetSource #endif #define IVTK_QUAD_ORDER 3 #ifdef VTK_USE_VIDEO_FOR_WINDOWS #define IVTK_SUPPORTS_AVI #endif #ifdef VTK_USE_MPEG2_ENCODER #define IVTK_SUPPORTS_MPEG #endif #endif // IVTK_H ifrit-4.1.2/core/0000775060175406010010000000000012641012573012144 5ustar HomeNoneifrit-4.1.2/core/iabstractextension.cpp0000674060175406010010000000775712641012544016600 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iabstractextension.h" #include "icrosssectionviewsubject.h" #include "ierror.h" #include "iobjectfactory.h" #include "iparticleviewsubject.h" #include "isurfaceviewsubject.h" #include "itensorfieldviewsubject.h" #include "ivectorfieldviewsubject.h" #include "ivolumeviewsubject.h" int iAbstractExtension::DefineToId(int n) { int id = -1; unsigned int k = (unsigned int)n; while(k != 0U) { id++; k = k >> 1; } return id; } iAbstractExtension::iAbstractExtension(int n, const iString& name) : mId(iAbstractExtension::DefineToId(n)), mName(name), mSubjectCounter(0) { // // Check that we configured correctly // if(n != (1<GetId(); } \ static int SubjectId(int n = -1){ return (1+Self()->GetId())*1000 + (n == -1 ? Self()->GetSubjectCounter() : n); } \ static const iString& Name(){ return Self()->GetName(); } \ private: \ _class_(); \ static const int mAutoInstall; \ static const iAbstractExtension* Self() #define iExtensionDefineMacro(_name_,_class_) \ const iAbstractExtension* _class_::Self() \ { \ static iAbstractExtension* self = new _class_; \ return self; \ } \ _class_::_class_() : iAbstractExtension(IEXTENSION_##_name_,#_name_){} #define iExtensionDeclareClassMacro(_prefix_) \ class _prefix_##Extension : public iAbstractExtension \ { \ iExtensionDeclareMacro(_prefix_##Extension); \ private: \ virtual iDataReaderExtension* CreateDataReaderExtension(iDataReader *reader) const; \ virtual iCrossSectionViewSubject* CreateCrossSectionSubject(iViewObject *obj, int index) const; \ virtual iParticleViewSubject* CreateParticleSubject(iViewObject *obj, int index) const; \ virtual iSurfaceViewSubject* CreateSurfaceSubject(iViewObject *obj, int index) const; \ virtual iTensorFieldViewSubject* CreateTensorFieldSubject(iViewObject *obj, int index) const; \ virtual iVectorFieldViewSubject* CreateVectorFieldSubject(iViewObject *obj, int index) const; \ virtual iVolumeViewSubject* CreateVolumeSubject(iViewObject *obj, int index) const; \ } #define iExtensionDefineClassMacro(_name_,_prefix_,_stype_,_vtype_,_ttype_,_ptype_) \ iExtensionDefineMacro(_name_,_prefix_##Extension); \ iCrossSectionViewSubject* _prefix_##Extension::CreateCrossSectionSubject(iViewObject *obj, int index) const \ { \ if(index == 0) return this->NewCrossSectionSubject(obj,_stype_::DataType()); else return 0; \ } \ iParticleViewSubject* _prefix_##Extension::CreateParticleSubject(iViewObject *obj, int index) const \ { \ if(index == 0) return this->NewParticleSubject(obj,_ptype_::DataType()); else return 0; \ } \ iSurfaceViewSubject* _prefix_##Extension::CreateSurfaceSubject(iViewObject *obj, int index) const \ { \ if(index == 0) return this->NewSurfaceSubject(obj,_stype_::DataType()); else return 0; \ } \ iTensorFieldViewSubject* _prefix_##Extension::CreateTensorFieldSubject(iViewObject *obj, int index) const \ { \ if(index == 0) return this->NewTensorFieldSubject(obj,_ttype_::DataType(),_stype_::DataType()); else return 0; \ } \ iVectorFieldViewSubject* _prefix_##Extension::CreateVectorFieldSubject(iViewObject *obj, int index) const \ { \ if(index == 0) return this->NewVectorFieldSubject(obj,_vtype_::DataType(),_stype_::DataType()); else return 0; \ } \ iVolumeViewSubject* _prefix_##Extension::CreateVolumeSubject(iViewObject *obj, int index) const \ { \ if(index == 0) return this->NewVolumeSubject(obj,_stype_::DataType()); else return 0; \ } \ iDataReaderExtension* _prefix_##Extension::CreateDataReaderExtension(iDataReader *reader) const \ { \ return new _prefix_##DataReaderExtension(reader); \ } #endif // IABSTRACTEXTENSION_H ifrit-4.1.2/core/iactor.cpp0000674060175406010010000002323512641012544014135 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iactor.h" #include "idatalimits.h" #include "ierror.h" #include "ilookuptable.h" #include "ipair.h" #include "ipalette.h" #include #include #include #include #include #include #include #include #include // // Templates // #include "iarray.tlh" #ifdef I_DEBUG #include bool iActor::mRandomColoring = false; #endif // // Actor class // iActor* iActor::New(vtkPlaneCollection *planes) { return new iActor(planes); } iActor::iActor(vtkPlaneCollection *planes) { mBasicScale = mAxisScale[0] = mAxisScale[1] = mAxisScale[2] = 1.0; mScaled = false; mCurrentSubject = 0; mDummySubject = new iActorSubject(this,0); IERROR_CHECK_MEMORY(mDummySubject); mDummySubjectPointer = mDummySubject; mDefaultMapper = vtkPolyDataMapper::New(); IERROR_CHECK_MEMORY(mDefaultMapper); if(planes != 0) mDefaultMapper->SetClippingPlanes(planes); this->SetMapper(mDefaultMapper); mDefaultMapper->Delete(); mLookupTable = iLookupTable::New(); IERROR_CHECK_MEMORY(mLookupTable); mDefaultMapper->SetLookupTable(mLookupTable); mDefaultMapper->UseLookupTableScalarRangeOn(); mDefaultLODMappers = 0; #ifdef I_DEBUG mRandomizer = vtkRandomAttributeGenerator::New(); IERROR_CHECK_MEMORY(mRandomizer); mRandomizer->SetDataTypeToUnsignedChar(); mRandomizer->SetNumberOfComponents(3); mRandomizer->GenerateCellScalarsOn(); mRandomizer->SetMinimumComponentValue(0.0); mRandomizer->SetMaximumComponentValue(255.0); mSavedInterpolationMode = -1; #endif } iActor::~iActor() { #ifdef I_DEBUG mRandomizer->Delete(); #endif while(mSubjects.Size() > 0) this->ReleaseGraphicsResources(mSubjects[mSubjects.MaxIndex()]->mWindow); delete mDummySubject; mLookupTable->Delete(); this->Mapper = mDefaultMapper; if(mDefaultLODMappers != 0) this->LODMappers = mDefaultLODMappers; } bool iActor::SetCurrentWindow(vtkWindow *win) { int i; IASSERT(win); if(mCurrentSubject!=0 && mCurrentSubject->mWindow==win) return true; // already current // // Find this window // mDummySubject->mWindow = win; i = mSubjects.Find(mDummySubjectPointer); if(i<0 || i>=mSubjects.Size()) return false; mCurrentSubject = mSubjects[i].Pointer(); this->Mapper = mCurrentSubject->mMapper; this->LODMappers = mCurrentSubject->mLODMappers; return true; } void iActor::ReleaseGraphicsResources(vtkWindow *win) { if(win==0 || !this->SetCurrentWindow(win)) return; // already released this->vtkLODActor::ReleaseGraphicsResources(win); if(mSubjects.Remove(mCurrentSubject)) delete mCurrentSubject; mCurrentSubject = 0; this->Mapper = mDefaultMapper; this->LODMappers = mDefaultLODMappers; } void iActor::Render(vtkRenderer *ren, vtkMapper *) { vtkWindow *win = ren->GetVTKWindow(); if(win == 0) return; // nothing to do if(mDefaultLODMappers == 0) { this->CreateOwnLODs(); mDefaultLODMappers = this->LODMappers; // saving for proper deletion vtkMapper *m; mDefaultLODMappers->InitTraversal(); while((m = mDefaultLODMappers->GetNextItem()) != 0) { m->SetLookupTable(mLookupTable); m->UseLookupTableScalarRangeOn(); m->SetClippingPlanes(mDefaultMapper->GetClippingPlanes()); } } if(!this->SetCurrentWindow(win)) { // // This window has not been attached yet // mCurrentSubject = new iActorSubject(this,win); IERROR_CHECK_MEMORY(mCurrentSubject); mSubjects.Add(mCurrentSubject); mCurrentSubject->mMapper->SetInputConnection(mDefaultMapper->GetInputConnection(0,0)); this->Mapper = mCurrentSubject->mMapper; this->LODMappers = mCurrentSubject->mLODMappers; } if(mScaled) { vtkCamera *cam = ren->GetActiveCamera(); double ps; if(cam->GetParallelProjection() == 0) { ps = cam->GetDistance()*tan(cam->GetViewAngle()/2.0*0.017453292)/1.6; } else { ps = cam->GetParallelScale()/1.6; } ps *= mBasicScale; this->SetScale(ps*mAxisScale[0],ps*mAxisScale[1],ps*mAxisScale[2]); } else { this->SetScale(mAxisScale[0],mAxisScale[1],mAxisScale[2]); } // // Fix VTK bug // if(this->GetProperty()->GetMTime() > this->Mapper->GetMTime()) { this->Mapper->Modified(); } #ifdef I_DEBUG if(mRandomColoring) { if(mSavedInterpolationMode == -1) { mSavedInterpolationMode = this->GetProperty()->GetInterpolation(); this->GetProperty()->SetInterpolationToFlat(); } mRandomizer->SetGenerateCellScalars(1); this->Mapper->SetColorModeToDefault(); this->Mapper->SetScalarModeToUseCellData(); } else { mRandomizer->SetGenerateCellScalars(0); this->Mapper->SetColorMode(mDefaultMapper->GetColorMode()); this->Mapper->SetScalarMode(mDefaultMapper->GetScalarMode()); if(mSavedInterpolationMode != -1) { this->GetProperty()->SetInterpolation(mSavedInterpolationMode); mSavedInterpolationMode = -1; } } #endif vtkLODActor::Render(ren,this->Mapper); } void iActor::SetScaled(bool s) { if(s != mScaled) { mScaled = s; this->Modified(); } } void iActor::SetBasicScale(double s) { if(s > 0.0) { mBasicScale = s; this->Modified(); } } void iActor::SetAxisScale(double sx, double sy, double sz) { if(sx>0.0 && sy>0.0 && sz>0.0) { mAxisScale[0] = sx; mAxisScale[1] = sy; mAxisScale[2] = sz; this->Modified(); } } // // Mapper functionality // void iActor::SetInputConnection(vtkAlgorithmOutput *port) { #ifdef I_DEBUG mRandomizer->SetInputConnection(port); port = mRandomizer->GetOutputPort(); #endif mDefaultMapper->SetInputConnection(port); vtkMapper *save = this->Mapper; this->Mapper = mDefaultMapper; this->UpdateOwnLODs(); this->Mapper = save; this->Mapper->SetInputConnection(port); } // // Mapper functionality // void iActor::SetInputData(vtkPolyData *data) { mDefaultMapper->SetInputData(data); vtkMapper *save = this->Mapper; this->Mapper = mDefaultMapper; this->UpdateOwnLODs(); this->Mapper = save; vtkPolyDataMapper::SafeDownCast(this->Mapper)->SetInputData(data); } void iActor::SetScalarVisibility(bool s) { int i; mDefaultMapper->SetScalarVisibility(s?1:0); for(i=0; imMapper->SetScalarVisibility(s?1:0); } void iActor::SetScalarRange(const iPair &p) { this->SetScalarRange(p.Min,p.Max); } void iActor::SetScalarRange(float min, float max) { int i; if(mDefaultMapper->GetUseLookupTableScalarRange() == 0) { mDefaultMapper->SetScalarRange(min,max); for(i=0; imMapper->SetScalarRange(min,max); } mLookupTable->SetTableRange(min,max); } void iActor::SyncWithLimits(iDataLimits *lims, int v) { if(lims!=0 && v>=0 && vGetNumVars()) { mLookupTable->SetStretchId(iStretch::Lin); this->SetScalarRange(lims->GetMin(v),lims->GetMax(v)); mLookupTable->SetStretchId(lims->GetStretchId(v)); } } void iActor::AddMapperObserver(unsigned long event, vtkCommand *obs) { int i; mDefaultMapper->AddObserver(event,obs); for(i=0; imMapper->AddObserver(event,obs); } void iActor::ColorByArrayComponent(int arrayNum, int component) { int i; mDefaultMapper->ColorByArrayComponent(arrayNum,component); for(i=0; imMapper->ColorByArrayComponent(arrayNum,component); } // // Helper classes // iActorSubject::iActorSubject(iActor *parent, vtkWindow *win) { IASSERT(parent); mWindow = win; if(win == 0) // dummy { mMapper = 0; mLODMappers = 0; } else { mMapper = vtkPolyDataMapper::New(); IERROR_CHECK_MEMORY(mMapper); mMapper->ShallowCopy(parent->GetMapper()); mLODMappers = vtkMapperCollection::New(); IERROR_CHECK_MEMORY(mLODMappers); vtkMapper *m1; vtkPolyDataMapper *m2; vtkMapperCollection *pm = parent->GetLODMappers(); pm->InitTraversal(); while((m1 = pm->GetNextItem()) != 0) { m2 = vtkPolyDataMapper::New(); IERROR_CHECK_MEMORY(m2); m2->ShallowCopy(m1); mLODMappers->AddItem(m2); m2->Delete(); } } } iActorSubject::~iActorSubject() { if(mMapper != 0) mMapper->Delete(); if(mLODMappers != 0) mLODMappers->Delete(); } iActorSubjectPointer::iActorSubjectPointer(iActorSubject *subject) { mPointer = subject; } void iActorSubjectPointer::operator=(iActorSubject *p) { mPointer = p; } void iActorSubjectPointer::operator=(const iActorSubjectPointer &p) { mPointer = p.mPointer; } bool iActorSubjectPointer::operator==(const iActorSubjectPointer &p) const { if(mPointer!=0 && p.mPointer!=0) { return (mPointer->mWindow == p.mPointer->mWindow); } else return (mPointer == p.mPointer); } ifrit-4.1.2/core/iactor.h0000674060175406010010000001016712641012513013576 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A combined class for ALL IFrIT actors & mappers - they must be the same so that renderers // can be copied. Thus, it is the most general scaled LOD actor. // This actor will render itself efficiently in multiple windows. // // #ifndef IACTOR_H #define IACTOR_H #include #include "iarray.h" #include "ivtk.h" class iActor; class iDataLimits; class iLookupTable; struct iPair; class iPalette; class vtkAlgorithmOutput; class vtkPlaneCollection; class vtkPolyData; class vtkPolyDataMapper; class vtkRandomAttributeGenerator; class iActorSubject { // // It is really just a struct... // friend class iActor; friend class iActorSubjectPointer; private: iActorSubject(iActor *parent, vtkWindow *win); virtual ~iActorSubject(); vtkWindow *mWindow; vtkPolyDataMapper *mMapper; vtkMapperCollection *mLODMappers; }; class iActorSubjectPointer { public: iActorSubjectPointer(iActorSubject *subject); iActorSubjectPointer(){ mPointer = 0; } inline iActorSubject* Pointer() const { return mPointer; } inline iActorSubject* operator->() const { return mPointer; } void operator=(iActorSubject *p); void operator=(const iActorSubjectPointer &p); bool operator==(const iActorSubjectPointer &p) const; private: iActorSubject *mPointer; }; class iActor: public vtkLODActor { public: vtkTypeMacro(iActor,vtkLODActor); static iActor* New(vtkPlaneCollection *planes = 0); virtual void ReleaseGraphicsResources(vtkWindow *win); virtual void Render(vtkRenderer *ren, vtkMapper *m); inline bool GetScaled(){ return mScaled; } void SetScaled(bool s); inline double GetBasicScale(){ return mBasicScale; } void SetBasicScale(double s); inline const double* GetAxisScale(){ return mAxisScale; } void SetAxisScale(double sx, double sy, double sz); // // Mapper functionality // void SetInputData(vtkPolyData *data); void SetInputConnection(vtkAlgorithmOutput *port); void SetScalarVisibility(bool s); void SetScalarRange(float min, float max); void SetScalarRange(const iPair &p); void SyncWithLimits(iDataLimits *l, int v); inline iLookupTable* GetLookupTable() const { return mLookupTable; } void AddMapperObserver(unsigned long event, vtkCommand *obs); void ColorByArrayComponent(int arrayNum, int component); #ifdef I_DEBUG static void SetRandomColoring(bool s){ mRandomColoring = s; } #endif protected: iActor(vtkPlaneCollection *planes = 0); virtual ~iActor(); private: bool SetCurrentWindow(vtkWindow *win); double mBasicScale, mAxisScale[3]; bool mScaled; iLookupArray mSubjects; iActorSubject *mDummySubject, *mCurrentSubject; iActorSubjectPointer mDummySubjectPointer; vtkPolyDataMapper *mDefaultMapper; vtkMapperCollection *mDefaultLODMappers; iLookupTable *mLookupTable; #ifdef I_DEBUG vtkRandomAttributeGenerator *mRandomizer; static bool mRandomColoring; int mSavedInterpolationMode; #endif }; #endif // IACTOR_H ifrit-4.1.2/core/iactorcollection.cpp0000674060175406010010000000363512641012544016213 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iactorcollection.h" #include "iactor.h" // // Templates // #include "iarray.tlh" iActorCollection* iActorCollection::New() { return new iActorCollection(); } iActorCollection::iActorCollection() { } iActorCollection::~iActorCollection() { int i; for(i=0; iUnRegister(this); } void iActorCollection::SetVisibility(int s) { int i; for(i=0; iSetVisibility(s); } void iActorCollection::AddActor(iActor *a) { if(a != 0) { mActors.AddUnique(a); a->Register(this); } } void iActorCollection::RemoveActor(iActor *a) { if(a != 0) { if(mActors.Remove(a)) a->UnRegister(this); } } ifrit-4.1.2/core/iactorcollection.h0000674060175406010010000000355512641012514015656 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A simple collection of iActors // #ifndef IACTORCOLLECTION_H #define IACTORCOLLECTION_H #include #include "iarray.h" class iActor; class iActorCollection : public vtkObject { public: vtkTypeMacro(iActorCollection,vtkObject); static iActorCollection* New(); void SetVisibility(int s); inline void VisibilityOn(){ this->SetVisibility(1); } inline void VisibilityOff(){ this->SetVisibility(0); } void AddActor(iActor *a); void RemoveActor(iActor *a); protected: virtual ~iActorCollection(); private: iActorCollection(); iLookupArray mActors; }; #endif // IACTORCOLLECTION_H ifrit-4.1.2/core/iactorviewsubject.cpp0000775060175406010010000001411312641012544016405 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iactorviewsubject.h" #include "iclipplane.h" #include "ierror.h" #include "ilookuptable.h" #include "imaterial.h" #include "ireplicatedactor.h" #include "iviewmodule.h" #include "iviewmoduleeventobservers.h" #include "iviewsubjectobserver.h" #include #include // // Templates // #include "iarray.tlh" #include "iproperty.tlh" using namespace iParameter; // // Single instance class // iActorViewInstance::iActorViewInstance(iActorViewSubject *owner, int num_actors, float max_opacity) : iViewInstance(owner), mMaxOpacity(max_opacity) { int i; iActor *a; if(num_actors < 1) { IBUG_FATAL("SolidViewSubject must have at least 1 Actor."); } mColor = owner->GetDefaultColor(); mOpacity = mMaxOpacity; for(i=0; iIsNonReplicating) { a = iActor::New(owner->GetViewModule()->GetClipPlane()->GetPlanes()); IERROR_CHECK_MEMORY(a); } else { a = iReplicatedActor::New(owner); IERROR_CHECK_MEMORY(a); } a->SetScalarVisibility(false); a->GetLookupTable()->SetColor(mColor); a->SetPosition(0.0,0.0,0.0); a->VisibilityOff(); a->DragableOff(); // use Dragable to mark Actors of ViewSubjects a->GetProperty()->SetOpacity(mOpacity); a->GetProperty()->SetInterpolationToGouraud(); a->GetProperty()->SetColor(owner->GetDefaultColor().ToVTK()); a->AddMapperObserver(vtkCommand::ProgressEvent,this->GetViewModule()->GetRenderEventObserver()); this->GetViewModule()->AddObject(a); this->Owner()->GetMaterial()->AddProperty(a->GetProperty()); mActors.Add(a); } // // Add observer to keep information about this object // mActors[0]->AddObserver(vtkCommand::UserEvent,owner->mObjectObserver); } iActorViewInstance::~iActorViewInstance() { int i; for(i=0; iiViewInstance::Owner()->GetMaterial()->RemoveProperty(mActors[i]->GetProperty()); this->GetViewModule()->RemoveObject(mActors[i]); mActors[i]->Delete(); } } iActorViewSubject* iActorViewInstance::Owner() const { return iRequiredCast(INFO,this->iViewInstance::Owner()); } void iActorViewInstance::ShowBody(bool s) { int i; for(i=0; iSetVisibility(s?1:0); } void iActorViewInstance::ResetBody() { int i; for(i=0; iVisibilityOff(); } bool iActorViewInstance::SetColor(const iColor& c) { if(!c.IsValid()) return false; mColor = c; int i, n = this->Owner()->IsSameColor ? mActors.Size() : 1; for(i=0; iGetProperty()->SetColor(c.ToVTK()); mActors[i]->GetLookupTable()->SetColor(c); } return true; } bool iActorViewInstance::SetOpacity(float o) { if(o<0 || o>1) return false; mOpacity = (o > mMaxOpacity) ? mMaxOpacity : o; int i, n = this->Owner()->IsSameOpacity ? mActors.Size() : 1; for(i=0; iGetProperty()->SetOpacity(mOpacity); } return true; } // // Main class // iActorViewSubject::iActorViewSubject(iObject *parent, const iString &fname, const iString &sname, iViewModule *vm, const iDataType &type, unsigned int flags, int minsize, int maxsize) : iViewSubject(parent,fname,sname,vm,type,flags,minsize,maxsize), HasNoColor((flags & ViewObject::Flag::HasNoColor) != 0U), HasNoOpacity((flags & ViewObject::Flag::HasNoOpacity) != 0U), IsSameColor((flags & ViewObject::Flag::IsSameColor) != 0U), IsSameOpacity((flags & ViewObject::Flag::IsSameOpacity) != 0U), iViewSubjectPropertyConstructMacroOP(!HasNoColor,Color,iActorViewInstance,Color,c), iViewSubjectPropertyConstructMacroOP(!HasNoOpacity,Float,iActorViewInstance,Opacity,o) { mDefaultColor = iColor::IFrIT(); } iActorViewSubject::~iActorViewSubject() { } // // Helper class // iPropPlacementHelper::iPropPlacementHelper(iViewModule *vm) : mPosition(vm), mSize(vm) { mDirection[0] = 0.0; mDirection[1] = 0.0; mDirection[2] = 1.0; } iPropPlacementHelper::~iPropPlacementHelper() { } bool iPropPlacementHelper::SetDirection(const iVector3D& n) { if(n[0]!=0.0 || n[1]!=0.0 || n[2]!=0.0) { mDirection = n; vtkMath::Normalize(mDirection); this->UpdateDirection(); return true; } else return false; } bool iPropPlacementHelper::SetBoxPosition(const iVector3D &v) { mPosition.SetBoxValue(v); this->SetPosition(mPosition); return true; } const iVector3D& iPropPlacementHelper::GetBoxPosition() const { return mPosition.BoxValue(); } void iPropPlacementHelper::SetPosition(const iPosition &p) { mPosition = p; this->UpdatePosition(); } bool iPropPlacementHelper::SetBoxSize(double p) { mSize.SetBoxValue(p); if(mSize > 0.0) { this->UpdateSize(); return true; } else return false; } double iPropPlacementHelper::GetBoxSize() const { return mSize.BoxValue(); } void iPropPlacementHelper::SetSize(const iDistance &s) { double v = s; this->SetSize(v); } void iPropPlacementHelper::SetSize(double s) { if(s < 1.1) { mSize = s; this->UpdateSize(); } } ifrit-4.1.2/core/iactorviewsubject.h0000674060175406010010000000720512641012514016051 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A ViewSubject that represents a fixed set of solid surfaces (iActor) // #ifndef IACTORVIEWSUBJECT_H #define IACTORVIEWSUBJECT_H #include "iviewsubject.h" #include "iposition.h" class iActor; class iActorViewSubject; namespace iParameter { namespace ViewObject { namespace Flag { const unsigned int HasNoColor = 2U; const unsigned int HasNoOpacity = 4U; const unsigned int IsSameColor = 8U; const unsigned int IsSameOpacity = 16U; }; }; }; class iActorViewInstance : public iViewInstance { friend class iActorViewSubject; public: iDataConsumerTypeMacroPass(iActorViewInstance,iViewInstance); iObjectSlotMacro1SR(Color,iColor); iObjectSlotMacro1SV(Opacity,float); protected: iActorViewInstance(iActorViewSubject *owner, int num_actors, float max_opacity); virtual ~iActorViewInstance(); iActorViewSubject* Owner() const; virtual void ShowBody(bool s); virtual void ResetBody(); const float mMaxOpacity; iArray mActors; }; class iActorViewSubject : public iViewSubject { friend class iActorViewInstance; friend class iObjectFactory; public: iDataConsumerTypeMacroPass(iActorViewSubject,iViewSubject); const bool HasNoColor, HasNoOpacity; const bool IsSameColor, IsSameOpacity; iType::vsp_color Color; iType::vsp_float Opacity; inline const iColor& GetDefaultColor() const { return mDefaultColor; } protected: iActorViewSubject(iObject *parent, const iString &fname, const iString &sname, iViewModule *vm, const iDataType &type, unsigned int flags, int minsize, int maxsize); virtual ~iActorViewSubject(); iColor mDefaultColor; }; class iPropPlacementHelper { public: virtual bool SetBoxSize(double p); double GetBoxSize() const; void SetSize(double p); void SetSize(const iDistance &p); inline double GetSize() const { return mSize; } virtual bool SetDirection(const iVector3D& pos); const iVector3D& GetDirection() const { return mDirection; } virtual bool SetBoxPosition(const iVector3D& pos); const iVector3D& GetBoxPosition() const; void SetPosition(const iPosition &pos); inline const iPosition& GetPosition() const { return mPosition; } protected: iPropPlacementHelper(iViewModule *vm); virtual ~iPropPlacementHelper(); virtual void UpdateDirection() = 0; virtual void UpdatePosition() = 0; virtual void UpdateSize() = 0; iVector3D mDirection; iPosition mPosition; iDistance mSize; }; #endif // IACTORVIEWSUBJECT_H ifrit-4.1.2/core/ianimator.cpp0000775060175406010010000004141112641012544014635 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Implementation of ianimator.h // #include "ianimator.h" #include "iboundingbox.h" #include "icolorbar.h" #include "icrosssectionviewsubject.h" #include "idatareader.h" #include "idirectory.h" #include "ierror.h" #include "ifile.h" #include "iimagecomposer.h" #include "ilabel.h" #include "imath.h" #include "imonitor.h" #include "ishell.h" #include "isystem.h" #include "iviewmodule.h" #include "iviewmoduleeventobservers.h" #include "iviewobject.h" #include #include #include #include #include #include #include using namespace iParameter; // // Templates // #include "iarray.tlh" #include "iproperty.tlh" #define DR this->GetViewModule()->GetReader() #define CAM this->GetViewModule()->GetRenderer()->GetActiveCamera() #define RAN_U (2.0*vtkMath::Random()-1.0) #define RAN_N (1.4142*tan(2.0*RAN_U/3.1415926)) #define LEN(x) (sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2])) // // iAnimator class // iAnimator* iAnimator::New(iViewModule *vm) { static iString LongName("Animator"); static iString ShortName("a"); IASSERT(vm); return new iAnimator(vm,LongName,ShortName); // non-inheritable, so no need to use Object Factory } iAnimator::iAnimator(iViewModule *vm, const iString &fname, const iString &sname) : iObject(vm,fname,sname), iViewModuleComponent(vm), iObjectConstructPropertyMacroS(Int,iAnimator,Style,s), iObjectConstructPropertyMacroS(Int,iAnimator,NumberOfFrames,nf), iObjectConstructPropertyMacroS(Int,iAnimator,NumberOfBlendedFrames,nb), iObjectConstructPropertyMacroS(Int,iAnimator,NumberOfTransitionFrames,nt), iObjectConstructPropertyMacroS(Float,iAnimator,Phi,dp), iObjectConstructPropertyMacroS(Float,iAnimator,Theta,dt), iObjectConstructPropertyMacroS(Float,iAnimator,Zoom,dz), iObjectConstructPropertyMacroS(Float,iAnimator,Roll,dr), iObjectConstructPropertyMacroS(String,iAnimator,TitlePageFile,tf), iObjectConstructPropertyMacroS(String,iAnimator,LogoFile,lf), iObjectConstructPropertyMacroS(Int,iAnimator,NumberOfTitlePageFrames,tnf), iObjectConstructPropertyMacroS(Int,iAnimator,NumberOfTitlePageBlendedFrames,tbf), iObjectConstructPropertyMacroS(Int,iAnimator,LogoLocation,ll), iObjectConstructPropertyMacroS(Float,iAnimator,LogoOpacity,lo), iObjectConstructPropertyMacroS(Int,iAnimator,Debug,d), iObjectConstructPropertyMacroA(iAnimator,Reset,r), iObjectConstructPropertyMacroA(iAnimator,Continue,c), iObjectConstructPropertyMacroQ(Int,iAnimator,CurrentFrame,cf), iObjectConstructPropertyMacroQ(Int,iAnimator,CurrentRecord,cr) { mRenderMode = RenderMode::Self; mStarted = mStartedRender = false; mDebug = 0; mNewRec = false; mCurRec = mPrevRec = -1; mCurFrame = mTotFrame = 0; mState.Style = 1; mState.NumberOfFrames = 1; mState.NumberOfBlendedFrames = 0; mState.NumberOfTransitionFrames = 0; mState.Phi = 1.0; mState.Theta = 0.0; mState.Zoom = 1.0; mState.Roll = 0.0; mNumberOfTitlePageFrames = 0; mNumberOfTitlePageBlendedFrames = 0; mLogoOpacity = 0.5; mLogoLocation = 0; mRandStep = 0.03; mSeed = 12345; mLeader = 0; } iAnimator::~iAnimator() { this->RemoveAllFollowers(); if(mLeader != 0) mLeader->RemoveFollower(this); while(mBlenderBase.Size() > 0) delete mBlenderBase.RemoveLast(); } // // This is the main driver // void iAnimator::Animate() { while(this->CallContinue()); } bool iAnimator::CallReset() { mState.Style = 0; mState.NumberOfFrames = 1; mState.Phi = 0.0; mState.Theta = 0.0; mState.Zoom = 1.0; mState.Roll = 0.0; mState.NumberOfBlendedFrames = 0; mState.NumberOfTransitionFrames = 0; return true; } // // Keep animating until stopped // bool iAnimator::CallContinue() { if(!mStarted) { this->Start(); } if(this->Frame(true)) { return true; } else { this->Stop(); return false; } } int iAnimator::GetCurrentFrame() const { return mCurFrame; } int iAnimator::GetCurrentRecord() const { return mCurRec; } // // Start the animator // void iAnimator::Start() { iMonitor h(this); if(mStarted) { h.PostError("Attempting to start an already started animation."); return; } // // Are we using a script? // this->SaveInternalState(); // // Disactivate Progress Dialog // iRenderEventObserver::BlockRenderEventObservers(true); this->GetViewModule()->StartAnimation(); mStarted = true; int i; for(i=0; iStart(); } // // Stop animation // void iAnimator::Stop() { iMonitor h(this); int i; for(i=0; iStop(); if(!mStarted) { h.PostError("Attempting to finish a never started animation."); return; } this->GetViewModule()->FinishAnimation(); // // Activate Progress Dialog // iRenderEventObserver::BlockRenderEventObservers(false); // // Reset to initial state // mStartedRender = false; this->GetViewModule()->GetLabel()->JustifyLeft(false); // // Restore the original state after execution of a script - must do it after reset() // so that projection is Set properly in case it was changed in a script before the // first render // this->RestoreState(true); mStarted = false; } void iAnimator::AddFollower(iAnimator *f) { if(f!=0 && f!=this) { mRenderMode = RenderMode::All; mFollowers.AddUnique(f); f->SetLeader(this); } } void iAnimator::RemoveFollower(iAnimator *f) { if(f != 0) { mFollowers.Remove(f); f->SetLeader(0); if(mFollowers.Size() == 0) mRenderMode = RenderMode::Self; } } void iAnimator::SetLeader(iAnimator *l) { if(l != this) { mLeader = l; } } void iAnimator::RemoveAllFollowers() { int i; for(i=0; iSetLeader(0); mFollowers.Clear(); mRenderMode = RenderMode::Self; } // // Internal functions // bool iAnimator::SetDebug(int s) { mDebug = s; this->GetViewModule()->SetDebugMode(s > 1); return true; } void iAnimator::ResetCurrentFile() { mNewRec = true; mPrevRec = mCurRec; mCurRec = DR->GetRecordNumber(); mCurFrame = mTotFrame = 0; } void iAnimator::SaveInternalState() { mState.isBoundingBox = this->GetViewModule()->GetBoundingBox()->IsVisible(); mState.isTimeLabel = this->GetViewModule()->GetLabel()->IsVisible(); mState.isColorBar = this->GetViewModule()->GetColorBar()->IsVisible(); if(DR != 0) mState.currec = this->GetViewModule()->GetReader()->GetRecordNumber(); mState.cameraProjection = CAM->GetParallelProjection(); CAM->GetPosition(mState.cameraPosition); CAM->GetFocalPoint(mState.cameraFocalPoint); CAM->GetViewUp(mState.cameraViewUp); mState.cameraParallelScale = CAM->GetParallelScale(); CAM->GetClippingRange(mState.cameraClippingRange); mState2 = mState; } void iAnimator::RestoreState(bool with_camera) { mState = mState2; if(DR!=0 && mDebug<2) { DR->LoadRecord(mState.currec,0,true); } this->GetViewModule()->GetBoundingBox()->Show(mState.isBoundingBox ); this->GetViewModule()->GetColorBar()->Show(mState.isColorBar); this->GetViewModule()->GetLabel()->Show(mState.isTimeLabel); if(with_camera) { CAM->SetParallelProjection(mState.cameraProjection); CAM->SetPosition(mState.cameraPosition); CAM->SetFocalPoint(mState.cameraFocalPoint); CAM->SetViewUp(mState.cameraViewUp); CAM->SetParallelScale(mState.cameraParallelScale); } } bool iAnimator::SetStyle(int ma) { if(ma>=0 && ma<3) { mState.Style = ma; return true; } else return false; } bool iAnimator::SetNumberOfFrames(int na) { if(na > 0) { mState.NumberOfFrames = na; return true; } else return false; } bool iAnimator::SetPhi(float va) { mState.Phi = va; return true; } bool iAnimator::SetTheta(float va) { mState.Theta = va; return true; } bool iAnimator::SetZoom(float va) { mState.Zoom = va; return true; } bool iAnimator::SetRoll(float va) { mState.Roll = va; return true; } bool iAnimator::SetNumberOfBlendedFrames(int na) { if(na >= 0) { mState.NumberOfBlendedFrames = na; return true; } else return false; } bool iAnimator::SetNumberOfTransitionFrames(int na) { if(na >= 0) { mState.NumberOfTransitionFrames = na; return true; } else return false; } bool iAnimator::SetNumberOfTitlePageFrames(int n) { if(n >= 0) { mNumberOfTitlePageFrames = n; return true; } else return false; } bool iAnimator::SetNumberOfTitlePageBlendedFrames(int n) { if(n >= 0) { mNumberOfTitlePageBlendedFrames = n; return true; } else return false; } bool iAnimator::SetLogoLocation(int n) { if(n>=0 && n<5) { mLogoLocation = n; return true; } else return false; } bool iAnimator::SetLogoOpacity(float v) { mLogoOpacity = v; return true; } bool iAnimator::SetLogoFile(const iString& s) { return true; bool ok = mLogoImage.LoadFromFile(s); if(ok) mLogoFile = s; else { mLogoFile.Clear(); mLogoImage.Clear(); } return ok; } bool iAnimator::SetTitlePageFile(const iString& s) { return true; bool ok = mTitlePageImage.LoadFromFile(s); if(ok) mTitlePageFile = s; else { mTitlePageFile.Clear(); mTitlePageImage.Clear(); } return ok; } bool iAnimator::Frame(bool dumpImage) { static float Pi = 3.1415927; int i; iMonitor h(this); mNewRec = false; if(!mStartedRender) { if(!DR->IsFileAnimatable()) { h.PostError("File is not animatable."); return false; } this->GetViewModule()->GetLabel()->JustifyLeft(true); vtkMath::RandomSeed(mSeed); if(mState.Style == 2) { wData.dphl0 = mState.Phi; wData.dthl0 = mState.Theta; wData.r = 0.0; wData.ramp = RAN_N; } if(mState.Style == 3) { for(i=0; i<3; i++) { wData.xc1[i] = 0.5*RAN_U; wData.xc2[i] = 0.5*RAN_U; } CAM->SetParallelProjection(0); CAM->GetPosition(wData.x); if(mState.cameraProjection == 1) { for(i=0; i<3; i++) wData.x[i] = 0.5*wData.x[i]; CAM->SetPosition(wData.x); } else { CAM->GetFocalPoint(wData.xc1); } CAM->SetFocalPoint(wData.xc1); float d = LEN(wData.x); wData.v[0] = d*0.5*RAN_U; wData.v[1] = d*0.5*RAN_U; wData.v[2] = 0.0; wData.t = 0.0; wData.dt0 = 0.1*Pi; wData.dt = wData.dt0; } mCurFrame = mTotFrame = 0; mPrevRec = -1; mCurRec = DR->GetRecordNumber(); mStartedRender = true; } if(mCurFrame == mState.NumberOfFrames) { bool ret = DR->LoadRecord(-1,1,mDebug>1); if(h.IsStopped() && !ret) { h.Reset(); return false; } this->GetViewModule()->UpdateLabel(); mNewRec = true; mPrevRec = mCurRec; mCurRec = DR->GetRecordNumber(); mCurFrame = 0; } if(h.IsStopped()) { return false; } mCurFrame++; mTotFrame++; // // Add transformations for rotate & tumble // if(mState.Style==1 || mState.Style==2) { CAM->Azimuth(-mState.Phi); CAM->Elevation(-mState.Theta); CAM->Zoom(mState.Zoom); CAM->Roll(mState.Roll); CAM->OrthogonalizeViewUp(); if(mState.Style == 2) { wData.r = wData.r + mRandStep; float cr = cos(wData.r*wData.ramp); float sr = sin(wData.r*wData.ramp); mState.Phi = wData.dphl0*cr + wData.dthl0*sr; mState.Theta = wData.dthl0*cr - wData.dphl0*sr; if(wData.r > 1.0) { wData.r = 0.0; wData.ramp = RAN_N; wData.dphl0 = mState.Phi; wData.dthl0 = mState.Theta; } } } // // Image data holder // iStereoImageArray images; // // Create the primary image set // this->GetViewModule()->CreateImages(images); if(h.IsStopped()) return false; // // Title page // if(mTotFrame==1 && dumpImage && !mTitlePageImage.IsEmpty() && mDebug==0) { iImage tmp = mTitlePageImage; // // We must update composer here because there is no automatic way to call // composer->Update() when vtkRenderWindow changes its size (it does not invoke an event). // this->GetViewModule()->GetShell()->GetImageComposer()->Update(); tmp.Scale(this->GetViewModule()->GetFullImageWidth(),this->GetViewModule()->GetFullImageHeight()); iStereoImageArray tmpset; tmpset.Copy(images); int n; for(n=0; nWriteImages(tmpset); if(h.IsStopped()) return false; } for(n=0; nWriteImages(tmpset); if(h.IsStopped()) return false; } } // // Transition effects // bool doTransitionFrames = dumpImage && mTotFrame>0 && mPrevRec>0 && mCurFrame<=mState.NumberOfTransitionFrames && mState.NumberOfTransitionFrames>0 && mDebug==0; if(doTransitionFrames) { iStereoImageArray tmpset; // // Objects for transition effects (blending with previous record) // DR->LoadRecord(mPrevRec,0,false); if(h.IsStopped()) return false; this->GetViewModule()->UpdateLabel(); this->GetViewModule()->CreateImages(tmpset); if(h.IsStopped()) return false; float ops = float(mCurFrame)/mState.NumberOfTransitionFrames; DR->LoadRecord(mCurRec,0,false); if(h.IsStopped()) return false; } // // Blending of images // bool doBlendedFrames = dumpImage && mTotFrame >0 && mState.NumberOfBlendedFrames>0 && mDebug==0; if(doBlendedFrames) { int k; // // Update the image list // while(mBlenderBase.Size() < mState.NumberOfBlendedFrames) { iStereoImageArray *ptmparr = new iStereoImageArray; IERROR_CHECK_MEMORY(ptmparr); ptmparr->Copy(images); mBlenderBase.Add(ptmparr); } while(mBlenderBase.Size() > mState.NumberOfBlendedFrames) { delete mBlenderBase.RemoveLast(); } delete mBlenderBase[0]; for(k=0; kCopy(*mBlenderBase[k+1]); mBlenderBase[mBlenderBase.MaxIndex()]->Copy(images); // // Make sure that all the arrays are of the same size // for(k=0; kSize() > images.Size()) mBlenderBase[k]->RemoveLast(); while(mBlenderBase[k]->Size() < images.Size()) mBlenderBase[k]->Add(images[mBlenderBase[k]->Size()]); } // // Blend the arrays // int n = 1; float ops; images.Copy(*mBlenderBase[0]); for(k=1; kFrame(false)) break; } if(mDebug==0 && dumpImage) { this->WriteImages(images); } return !h.IsStopped(); } // // Dump an image array, optionally adding a logo // void iAnimator::WriteImages(iStereoImageArray &images) { if(images.Size()>0 && mDebug==0 && !mLogoImage.IsEmpty()) { // // If the logo is more than 20% of the image, scale it down. // Use tmp as a temp storage // iImage tmp = mLogoImage; if(tmp.Width()>images[0].Width()/5 || tmp.Height()>images[0].Height()/5) { tmp.Scale(images[0].Width()/5,images[0].Height()/5); } if(tmp.Width()>=2 && tmp.Height()>=2) { // // tmp is now the proper logo image // int i, ioff, joff; // // Where do we place the logo? // ioff = tmp.Width()/5; joff = tmp.Height()/5; switch(mLogoLocation) { case 1: { // upper right corner ioff = images[0].Width() - tmp.Width() - ioff; joff = images[0].Height() - tmp.Height() - joff; break; } case 2: { // lower left right corner break; } case 3: { // lower right corner ioff = images[0].Width() - tmp.Width() - ioff; break; } default: { // upper left corner - the default choice joff = images[0].Height() - tmp.Height() - joff; break; } } for(i=0; iGetViewModule()->WriteImages(images,ImageType::MovieFrame); } ifrit-4.1.2/core/ianimator.h0000674060175406010010000001042712641012514014300 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IANIMATOR_H #define IANIMATOR_H #include "iobject.h" #include "iviewmodulecomponent.h" #include "iarray.h" #include "imath.h" #include "iimage.h" class iStereoImageArray; class vtkImageData; class vtkPolyData; #define iAnimatorPropertyMacro(_name_,_id_) \ iType::Traits::Type Get##_name_() const { return mState._name_; } \ bool Set##_name_(iType::Traits::Type s); \ iPropertyScalar _name_ class iAnimator : public iObject, public iViewModuleComponent { public: vtkTypeMacro(iAnimator,iObject); static iAnimator* New(iViewModule *vm = 0); iAnimatorPropertyMacro(Style,Int); iAnimatorPropertyMacro(NumberOfFrames,Int); iAnimatorPropertyMacro(NumberOfBlendedFrames,Int); iAnimatorPropertyMacro(NumberOfTransitionFrames,Int); iAnimatorPropertyMacro(Phi,Float); iAnimatorPropertyMacro(Theta,Float); iAnimatorPropertyMacro(Zoom,Float); iAnimatorPropertyMacro(Roll,Float); iObjectPropertyMacro1S(TitlePageFile,String); iObjectPropertyMacro1S(LogoFile,String); iObjectPropertyMacro1S(NumberOfTitlePageFrames,Int); iObjectPropertyMacro1S(NumberOfTitlePageBlendedFrames,Int); iObjectPropertyMacro1S(LogoLocation,Int); iObjectPropertyMacro1S(LogoOpacity,Float); iObjectPropertyMacro1S(Debug,Int); iObjectPropertyMacroA(Reset); iObjectPropertyMacroA(Continue); iObjectPropertyMacro2Q(CurrentFrame,Int); iObjectPropertyMacro2Q(CurrentRecord,Int); inline const iImage& GetTitlePageImage() const { return mTitlePageImage; } inline const iImage& GetLogoImage() const { return mLogoImage; } // // Animator controls // void Animate(); void AddFollower(iAnimator *f); void RemoveFollower(iAnimator *f); void RemoveAllFollowers(); inline void GetInfo(bool &nr, int &cr, int &cf) const { nr = mNewRec; cr = mCurRec; cf = mCurFrame; } protected: virtual ~iAnimator(); private: iAnimator(iViewModule *vm, const iString &fname, const iString &sname); void SetLeader(iAnimator *l); void Start(); void Stop(); bool Frame(bool dumpImage = true); void WriteImages(iStereoImageArray &images); void ResetCurrentFile(); void SaveInternalState(); void RestoreState(bool with_camera); bool mStarted, mStartedRender; unsigned long mSeed; struct State { int Style; int NumberOfFrames; int NumberOfBlendedFrames; int NumberOfTransitionFrames; float Phi; float Theta; float Zoom; float Roll; bool isBoundingBox; bool isTimeLabel; bool isColorBar; int currec; int cameraProjection; double cameraPosition[3]; double cameraFocalPoint[3]; double cameraViewUp[3]; double cameraParallelScale; double cameraClippingRange[2]; }; State mState, mState2; float mRandStep; bool mNewRec; int mPrevRec, mCurRec, mTotFrame, mCurFrame; iArray mBlenderBase; iImage mTitlePageImage, mLogoImage; iLookupArray mFollowers; iAnimator *mLeader; // // Internal (work) variables // struct AnimatorData { double pos[3]; float r, dphl0, dthl0, ramp; double xc1[3], xc2[3], x[3]; float v[3], t, dt0, dt; } wData; }; #endif // IANIMATOR_H ifrit-4.1.2/core/iappendimagedatafilter.cpp0000674060175406010010000000310712641012545017334 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iappendimagedatafilter.h" // // Templates // #include "igenericfilter.tlh" iAppendImageDataFilter::iAppendImageDataFilter(iDataConsumer *consumer) : iGenericImageDataFilter(consumer,0,true) // avoid setting the number of inputs { } void iAppendImageDataFilter::ProvideOutput() { this->ExecuteParent(); } ifrit-4.1.2/core/iappendimagedatafilter.h0000674060175406010010000000312712641012514016777 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IAPPENDIMAGEDATAFILTER_H #define IAPPENDIMAGEDATAFILTER_H #include "igenericfilter.h" #include class iAppendImageDataFilter : public iGenericImageDataFilter { iGenericFilterTypeMacro(iAppendImageDataFilter,vtkImageAppend); protected: virtual void ProvideOutput(); }; #endif // IAPPENDIMAGEDATAFILTER_H ifrit-4.1.2/core/iappendpolydatafilter.cpp0000674060175406010010000000310512641012545017233 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iappendpolydatafilter.h" // // Templates // #include "igenericfilter.tlh" iAppendPolyDataFilter::iAppendPolyDataFilter(iDataConsumer *consumer) : iGenericPolyDataFilter(consumer,1,true) // avoid setting the number of inputs { } void iAppendPolyDataFilter::ProvideOutput() { this->ExecuteParent(); } ifrit-4.1.2/core/iappendpolydatafilter.h0000674060175406010010000000313212641012514016674 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IAPPENDPOLYDATAFILTER_H #define IAPPENDPOLYDATAFILTER_H #include "igenericfilter.h" #include class iAppendPolyDataFilter : public iGenericPolyDataFilter { iGenericFilterTypeMacro(iAppendPolyDataFilter,vtkAppendPolyData); protected: virtual void ProvideOutput(); }; #endif // IAPPENDPOLYDATAFILTER_H ifrit-4.1.2/core/iarray.h0000674060175406010010000000676612641012514013617 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IARRAY_H #define IARRAY_H // // Automatically-resizable array of type T; the type must have operator =. // template class iArray { public: iArray(int inc = 10); virtual ~iArray(); T& operator[](int i); const T& operator[](int i) const; inline int Size() const { return this->mNum; } inline int MaxIndex() const { return this->mNum-1; } virtual void Add(const T &val); void Remove(int n); void Clear(); void Resize(int n); inline T& Last(){ return this->mArr[this->mNum-1]; } inline const T& Last() const { return this->mArr[this->mNum-1]; } void AddLast(); T RemoveLast(); // useful for deleteting all: while(arr.Size() > 0) delete arr.RemoveLast(); inline const T* Data() const { return this->mArr; } protected: void Extend(int len); T* mArr; int mNum, mLen; const int mInc; private: iArray(const iArray&); // not implemented void operator=(const iArray&); // not implemented }; // // iLookupArray class // Needs operator == for type T // template class iLookupArray : public iArray { public: iLookupArray(int inc = 10); virtual int Find(const T &val) const; bool AddUnique(const T &val); bool Remove(const T &val); private: }; // // iGenericOrderedArray class // Needs operator < for the key type K // template class iGenericOrderedArray : public iLookupArray { public: iGenericOrderedArray(const K& (*key)(const T &val), int inc = 10); // // In case of duplicate keys, add the new value last // virtual void Add(const T &val); virtual int Find(const T &val) const; // // In case of duplicate keys, return the first value // int FindByKey(const K &key) const; private: const K& (*Key)(const T &val); iGenericOrderedArray(const iGenericOrderedArray&); // not implemented void operator=(const iGenericOrderedArray&); // not implemented }; // // iOrderedArray class (order by its own value) // template class iOrderedArray : public iGenericOrderedArray { public: iOrderedArray(int inc = 10) : iGenericOrderedArray(Self,inc){} private: static const T& Self(const T &val){ return val; } iOrderedArray(const iOrderedArray&); // not implemented void operator=(const iOrderedArray&); // not implemented }; #endif // IARRAY_H ifrit-4.1.2/core/iarray.tlh0000674060175406010010000001053712641012510014142 0ustar HomeNone//LICENSE A #include "iarray.h" #include "ierror.h" // // iArray class // template iArray::iArray(int inc) : mInc((inc<1) ? 1 : inc) { this->mNum = 0; this->mLen = this->mInc; this->mArr = new T[this->mLen]; IERROR_CHECK_MEMORY(this->mArr); } template iArray::~iArray() { delete [] this->mArr; } template T& iArray::operator[](int i) { static T zero; if(i>=0 && imNum) return this->mArr[i]; else { IBUG_FATAL("Accessing iArray outside of boundaries."); return zero; } } template const T& iArray::operator[](int i) const { static T zero; if(i>=0 && imNum) return this->mArr[i]; else { IBUG_WARN("Accessing iArray outside of boundaries."); return zero; } } template void iArray::Extend(int len) { int i, n, inc = this->mLen/4; if(inc+this->mLen < len) inc = len - this->mLen; this->mLen += (incmInc) ? this->mInc : inc; T *tmp, *arr; tmp = new T[this->mLen]; IERROR_CHECK_MEMORY(tmp); n = this->mNum; arr = this->mArr; // dereference for speed for(i=0; imArr; this->mArr = tmp; } template void iArray::AddLast() { if(this->mNum == 0) this->Add(T(0)); else this->Add(this->mArr[this->mNum-1]); } template void iArray::Add(const T &val) { if(this->mNum == this->mLen) this->Extend(0); this->mArr[this->mNum++] = val; } template void iArray::Remove(int n) { if(n<0 || n>=this->mNum) { IBUG_FATAL("Accessing iArray outside of boundaries."); } int i, m = --this->mNum; T *arr = this->mArr; // dereference for speed for(i=n; i T iArray::RemoveLast() { if(this->mNum == 0) { IBUG_FATAL("Accessing iArray outside of boundaries."); return this->mArr[0]; } this->mNum--; return this->mArr[this->mNum]; } template void iArray::Clear() { this->mNum = 0; } template void iArray::Resize(int n) { if(n > this->mLen) this->Extend(n); if(n > this->mNum) this->mNum = n; if(n < this->mNum) { if(n < 0) this->mNum = 0; else this->mNum = n; } } // // iLookupArray class // template iLookupArray::iLookupArray(int inc) : iArray(inc) { } template int iLookupArray::Find(const T &val) const { int i, n = this->mNum; T *arr = this->mArr; // dereference for speed for(i=0; i bool iLookupArray::AddUnique(const T &val) { if(this->Find(val) == -1) { this->Add(val); return true; } else return false; } template bool iLookupArray::Remove(const T &val) { int i = this->Find(val); if(i > -1) { this->iArray::Remove(i); return true; } else return false; } // // iGenericOrderedArray class // template iGenericOrderedArray::iGenericOrderedArray(const K& (*key)(const T &val), int inc) : iLookupArray(inc) { this->Key = key; IASSERT(key); } template void iGenericOrderedArray::Add(const T &val) { int i, ia, ib; if(this->mNum == this->mLen) this->Extend(0); T *arr = this->mArr; // dereference for speed if(this->mNum==0 || this->Key(arr[this->mNum-1])Key(val)) { arr[this->mNum++] = val; return; } if(this->Key(val) < this->Key(arr[0])) { ib = 0; } else { ia = 0; ib = this->mNum; while(ib > ia+1) { i = (ia+ib)/2; if(this->Key(val) < this->Key(arr[i])) ib = i; else ia = i; } } for(i=this->mNum; i>ib; i--) arr[i] = arr[i-1]; arr[ib] = val; this->mNum++; } template int iGenericOrderedArray::Find(const T &val) const { int i = this->FindByKey(this->Key(val)); if(i > -1) { // // Check for duplicate keys // while(imNum && !(this->mArr[i]==val)) i++; if(i == this->mNum) i = -1; } return i; } template int iGenericOrderedArray::FindByKey(const K &key) const { if(this->mNum == 0) return -1; // empty array T *arr = this->mArr; // dereference for speed // // Binary search of the ordered array // int ia, ib, ic; ia = 0; ib = this->mNum - 1; while(ib > ia+1) { ic = (ia+ib)/2; if(this->Key(arr[ic]) < key) ia = ic; else ib = ic; } if(this->Key(arr[ia]) == key) return ia; else if(this->Key(arr[ib]) == key) return ib; else return -1; } ifrit-4.1.2/core/iaxis.cpp0000674060175406010010000001025512641012545013770 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iaxis.h" #include "ioverlayhelper.h" #include "irendertool.h" #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "igenericprop.tlh" iAxis* iAxis::New(iRenderTool *rt) { IASSERT(rt); return new iAxis(rt); } iAxis::iAxis(iRenderTool *rt) : iGenericProp(true), mOverlayHelper(rt) { mLineWidth = 2; mTickLength = TickLength; this->PickableOff(); } iAxis::~iAxis() { } void iAxis::UpdateGeometry(vtkViewport *vp) { int mag = mOverlayHelper->GetRenderingMagnification(); if(mag == 1) { this->AxisActor->GetProperty()->SetLineWidth(mLineWidth); this->SetTickLength(mTickLength); mPos1 = this->GetPosition(); mPos2 = this->GetPosition2(); this->GetProperty()->SetColor(this->GetOverlayHelper()->GetColor(vp).ToVTK()); this->GetOverlayHelper()->UpdateTextProperty(vp,this->LabelTextProperty); this->GetOverlayHelper()->UpdateTextProperty(vp,this->TitleTextProperty); } else { int winij[2]; mOverlayHelper->ComputePositionShiftsUnderMagnification(winij); int *sz = vp->GetSize(); if(this->GetPoint1Coordinate()->GetCoordinateSystem() == VTK_NORMALIZED_VIEWPORT) { this->SetPosition(mag*mPos1.X-winij[0],mag*mPos1.Y-winij[1]); } else { this->SetPosition(mag*mPos1.X-sz[0]*winij[0],mag*mPos1.Y-sz[1]*winij[1]); } if(this->GetPoint2Coordinate()->GetCoordinateSystem() == VTK_NORMALIZED_VIEWPORT) { this->SetPosition2(mag*mPos2.X-winij[0],mag*mPos2.Y-winij[1]); } else { this->SetPosition2(mag*mPos2.X-sz[0]*winij[0],mag*mPos2.Y-sz[1]*winij[1]); } this->AxisActor->GetProperty()->SetLineWidth(mLineWidth*mag); this->SetTickLength(mag*mTickLength); } } void iAxis::UpdateOverlay(vtkViewport *vp) { int i, mag = mOverlayHelper->GetRenderingMagnification(); // // This must be after RenderOpaqueGeometry // this->TitleTextProperty->SetFontSize(mOverlayHelper->GetFontSize(vp,mag)); this->TitleMapper->GetTextProperty()->ShallowCopy(this->TitleTextProperty); this->LabelTextProperty->SetFontSize(mOverlayHelper->GetFontSize(vp,mag)); for(i=0; iAdjustedNumberOfLabels; i++) { this->LabelMappers[i]->GetTextProperty()->ShallowCopy(this->LabelTextProperty); } int *s = vp->GetSize(); if(mag == 1) { mPosT = this->TitleActor->GetPosition(); mPosL.Resize(this->AdjustedNumberOfLabels); for(i=0; iAdjustedNumberOfLabels; i++) { mPosL[i] = this->LabelActors[i]->GetPosition(); } } else { int winij[2]; mOverlayHelper->ComputePositionShiftsUnderMagnification(winij); this->TitleActor->SetPosition(mag*mPosT.X-s[0]*winij[0],mag*mPosT.Y-s[1]*winij[1]); for(i=0; iAdjustedNumberOfLabels; i++) { this->LabelActors[i]->SetPosition(mag*mPosL[i].X-s[0]*winij[0],mag*mPosL[i].Y-s[1]*winij[1]); } } } iAxis::Pos& iAxis::Pos::operator=(const double *ptr) { this->X = ptr[0]; this->Y = ptr[1]; return *this; } ifrit-4.1.2/core/iaxis.h0000674060175406010010000000366712641012514013442 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IAXIS_H #define IAXIS_H #include "igenericprop.h" #include #include "ipointermacro.h" class iOverlayHelper; class iRenderTool; class iAxis: public iGenericProp { IPOINTER_AS_USER(OverlayHelper); public: vtkTypeMacro(iAxis,vtkAxisActor2D); static iAxis* New(iRenderTool *rt = 0); protected: iAxis(iRenderTool *rt); virtual ~iAxis(); virtual void UpdateGeometry(vtkViewport *vp); virtual void UpdateOverlay(vtkViewport *vp); private: struct Pos { float X; float Y; Pos& operator=(const double *ptr); // impl-shared copy }; float mLineWidth; int mTickLength; Pos mPos1, mPos2, mPosT; iArray mPosL; }; #endif // IAXIS_H ifrit-4.1.2/core/ibitmaptextsubject.cpp0000674060175406010010000000563412641012545016572 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ibitmaptextsubject.h" #include "ierror.h" #include "ioverlayhelper.h" #include "itextactor.h" #include #include #include #include // // Templates // #include "iarray.tlh" #include "igenericprop.tlh" iBitmapTextSubject* iBitmapTextSubject::New(iTextActor *parent, iRenderTool *rt) { IASSERT(rt); return new iBitmapTextSubject(parent,rt); } iBitmapTextSubject::iBitmapTextSubject(iTextActor *parent, iRenderTool *rt) : iTextSubject(parent,rt) { mMapper = vtkTextMapper::New(); IERROR_CHECK_MEMORY(mMapper); mActor = vtkActor2D::New(); IERROR_CHECK_MEMORY(mActor); this->AppendComponent(mActor); mActor->SetMapper(mMapper); mActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); mMapper->SetTextProperty(mParent->GetTextProperty()); } iBitmapTextSubject::~iBitmapTextSubject() { mMapper->Delete(); mActor->Delete(); } void iBitmapTextSubject::ComputeSize(vtkViewport *viewport, float s[2]) { mMapper->SetInput(mParent->GetText().ToCharPointer()); double w = mMapper->GetWidth(viewport); double h = mMapper->GetHeight(viewport); viewport->ViewportToNormalizedViewport (w,h); s[0] = w; s[1] = h; } void iBitmapTextSubject::UpdateGeometryBody(vtkViewport* viewport, int mag) { if(mag == 1) { //mMapper->GetTextProperty()->SetOrientation(mParent->GetAngle()); mActor->SetPosition(mPos[0],mPos[1]); mActor->SetPosition2(mSize[0],mSize[1]); } else { int winij[2]; this->GetOverlayHelper()->ComputePositionShiftsUnderMagnification(winij); mActor->SetPosition(mag*mPos[0]-winij[0],mag*mPos[1]-winij[1]); mActor->SetPosition2(mag*mSize[0],mag*mSize[1]); } } ifrit-4.1.2/core/ibitmaptextsubject.h0000674060175406010010000000353312641012515016230 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Class for displaying bitmap (2D) text in VTK // #ifndef IBITMAPSUBJECT_H #define IBITMAPSUBJECT_H #include "itextsubject.h" class vtkActor2D; class vtkTextMapper; class iBitmapTextSubject: public iTextSubject { public: static iBitmapTextSubject* New(iTextActor *parent, iRenderTool *rv); protected: virtual ~iBitmapTextSubject(); virtual void ComputeSize(vtkViewport *v, float s[2]); virtual void UpdateGeometryBody(vtkViewport *vp, int mag); private: iBitmapTextSubject(iTextActor *parent, iRenderTool *rv); vtkTextMapper *mMapper; vtkActor2D *mActor; }; #endif // IBITMAPSUBJECT_H ifrit-4.1.2/core/iboundeddisksource.cpp0000674060175406010010000000756412641012545016551 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iboundeddisksource.h" #include "ierror.h" #include #include #include #include #include #include #include // // Templates // #include "igenericfilter.tlh" // // iBoundedDiskSource class // iBoundedDiskSource* iBoundedDiskSource::New(iDataConsumer *consumer) { IASSERT(consumer); return new iBoundedDiskSource(consumer); } iBoundedDiskSource::iBoundedDiskSource(iDataConsumer *consumer) : iBoundedPolyDataSource(consumer,true,true) { mPointNormals = vtkPolyDataNormals::New(); IERROR_CHECK_MEMORY(mPointNormals); mSource = vtkDiskSource::New(); IERROR_CHECK_MEMORY(mSource); mPointNormals->SplittingOff(); mPointNormals->ConsistencyOff(); mPointNormals->ComputePointNormalsOn(); mPointNormals->ComputeCellNormalsOff(); mPointNormals->FlipNormalsOff(); mSource->SetInnerRadius(0.0); mSource->SetOuterRadius(1.0); mAppendPolyData = vtkAppendPolyData::New(); IERROR_CHECK_MEMORY(mAppendPolyData); mArrowSource = vtkArrowSource::New(); IERROR_CHECK_MEMORY(mArrowSource); mTransformPolyDataFilter = vtkTransformPolyDataFilter::New(); IERROR_CHECK_MEMORY(mTransformPolyDataFilter); vtkTransform *t = vtkTransform::New(); IERROR_CHECK_MEMORY(t); t->Identity(); t->RotateY(-90.0); mTransformPolyDataFilter->SetTransform(t); t->Delete(); mTransformPolyDataFilter->SetInputConnection(mArrowSource->GetOutputPort()); mAppendPolyData->AddInputConnection(mSource->GetOutputPort()); mAppendPolyData->AddInputConnection(mTransformPolyDataFilter->GetOutputPort()); mWithArrow = false; this->SetWithArrow(true); } iBoundedDiskSource::~iBoundedDiskSource() { mSource->Delete(); mPointNormals->Delete(); mAppendPolyData->Delete(); mArrowSource->Delete(); mTransformPolyDataFilter->Delete(); } void iBoundedDiskSource::SetWithArrow(bool s) { if(s == mWithArrow) return; mWithArrow = s; if(s) { mFilter->SetInputConnection(mAppendPolyData->GetOutputPort()); } else { mFilter->SetInputConnection(mSource->GetOutputPort()); } } void iBoundedDiskSource::AddObserverToSource(unsigned long e, vtkCommand *c, float p) { mSource->AddObserver(e,c,p); mPointNormals->AddObserver(e,c,p); } void iBoundedDiskSource::UpdateSourceResolution() { mSource->SetRadialResolution(1+mResolution/2); mSource->SetCircumferentialResolution(3*mResolution); } float iBoundedDiskSource::GetSourceMemorySize() const { float s = 0.0; s += mPointNormals->GetOutput()->GetActualMemorySize(); s += mSource->GetOutput()->GetActualMemorySize(); return s; } void iBoundedDiskSource::UpdateBoundaryConditions() { } ifrit-4.1.2/core/iboundeddisksource.h0000674060175406010010000000445212641012515016204 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IBOUNDEDDISKSOURCE_H #define IBOUNDEDDISKSOURCE_H #include "iboundedpolydatasource.h" class vtkAppendPolyData; class vtkArrowSource; class vtkDiskSource; class vtkPolyDataNormals; class vtkTransformPolyDataFilter; class iBoundedDiskSource : public iBoundedPolyDataSource { public: vtkTypeMacro(iBoundedDiskSource,iBoundedPolyDataSource); static iBoundedDiskSource* New(iDataConsumer *consumer = 0); void SetWithArrow(bool s); inline bool GetWithArrow() const { return mWithArrow; } protected: iBoundedDiskSource(iDataConsumer *consumer); virtual ~iBoundedDiskSource(); virtual void UpdateBoundaryConditions(); virtual void UpdateSourceResolution(); virtual void AddObserverToSource(unsigned long e, vtkCommand *c, float priority); virtual float GetSourceMemorySize() const; private: // // VTK stuff // vtkDiskSource *mSource; vtkPolyDataNormals *mPointNormals; vtkAppendPolyData *mAppendPolyData; vtkArrowSource *mArrowSource; vtkTransformPolyDataFilter *mTransformPolyDataFilter; bool mWithArrow; }; #endif // IBOUNDEDDISKSOURCE_H ifrit-4.1.2/core/iboundedplanesource.cpp0000674060175406010010000000464212641012545016710 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iboundedplanesource.h" #include "ierror.h" #include #include #include // // iBoundedPlaneSource class // iBoundedPlaneSource* iBoundedPlaneSource::New(iDataConsumer *consumer) { IASSERT(consumer); return new iBoundedPlaneSource(consumer); } iBoundedPlaneSource::iBoundedPlaneSource(iDataConsumer *consumer) : iBoundedPolyDataSource(consumer,true,false) { mSource = vtkPlaneSource::New(); IERROR_CHECK_MEMORY(mSource); mSource->SetOrigin(0.0,0.0,0.0); mSource->SetPoint1(7.0,0.0,0.0); mSource->SetPoint2(0.0,7.0,0.0); mSource->SetCenter(0.0,0.0,0.0); mFilter->SetInputConnection(mSource->GetOutputPort()); } iBoundedPlaneSource::~iBoundedPlaneSource() { mSource->Delete(); } void iBoundedPlaneSource::AddObserverToSource(unsigned long e, vtkCommand *c, float p) { mSource->AddObserver(e,c,p); } void iBoundedPlaneSource::UpdateSourceResolution() { mSource->SetResolution(mResolution,mResolution); } float iBoundedPlaneSource::GetSourceMemorySize() const { float s = 0.0; s += mSource->GetOutput()->GetActualMemorySize(); return s; } void iBoundedPlaneSource::UpdateBoundaryConditions() { } ifrit-4.1.2/core/iboundedplanesource.h0000674060175406010010000000370112641012515016345 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IBOUNDEDPLANESOURCE_H #define IBOUNDEDPLANESOURCE_H #include "iboundedpolydatasource.h" class vtkPlaneSource; class iBoundedPlaneSource : public iBoundedPolyDataSource { public: vtkTypeMacro(iBoundedPlaneSource,iBoundedPolyDataSource); static iBoundedPlaneSource* New(iDataConsumer *consumer = 0); protected: iBoundedPlaneSource(iDataConsumer *consumer); virtual ~iBoundedPlaneSource(); virtual void UpdateBoundaryConditions(); virtual void UpdateSourceResolution(); virtual void AddObserverToSource(unsigned long e, vtkCommand *c, float priority); virtual float GetSourceMemorySize() const; private: // // VTK stuff // vtkPlaneSource *mSource; }; #endif // IBOUNDEDPLANESOURCE_H ifrit-4.1.2/core/iboundedpolydatasource.cpp0000674060175406010010000001100112641012545017411 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iboundedpolydatasource.h" #include "idatalimits.h" #include "ierror.h" #include "itransform.h" #include "iviewmodule.h" #include #include #include #include #include #include // // Templates // #include "igenericfilter.tlh" // // iBoundedPolyDataSource class // iBoundedPolyDataSource::iBoundedPolyDataSource(iDataConsumer *consumer, bool normalCanChange, bool radiusCanChange) : iGenericPolyDataFilter(consumer,0,true), mNormalCanChange(normalCanChange), mRadiusCanChange(radiusCanChange) { mTransform = iTransform::New(); IERROR_CHECK_MEMORY(mTransform); mClipper = vtkClipPolyData::New(); IERROR_CHECK_MEMORY(mClipper); mClipPlanes = vtkPlanes::New(); IERROR_CHECK_MEMORY(mClipPlanes); mFilter = vtkTransformPolyDataFilter::New(); IERROR_CHECK_MEMORY(mFilter); mClipper->SetClipFunction(mClipPlanes); mClipper->InsideOutOn(); mFilter->SetTransform(mTransform); mTransform->PreMultiply(); mRadius = 1.0; mCenter[0] = mCenter[1] = mCenter[2] = 0.0; mNormal[0] = mNormal[1] = 0.0f; mNormal[2] = 1.0f; mResolution = 2; mBounds[0] = mBounds[2] = mBounds[4] = -1.0; mBounds[1] = mBounds[3] = mBounds[5] = 1.0; mClipPlanes->SetBounds(mBounds); mNormalChanged = true; mClipper->SetInputConnection(mFilter->GetOutputPort()); } iBoundedPolyDataSource::~iBoundedPolyDataSource() { mClipper->Delete(); mClipPlanes->Delete(); mTransform->Delete(); mFilter->Delete(); } unsigned long iBoundedPolyDataSource::AddObserver(unsigned long e, vtkCommand *c, float p) { this->AddObserverToSource(e,c,p); mFilter->AddObserver(e,c,p); return mClipper->AddObserver(e,c,p); } void iBoundedPolyDataSource::SetResolution(int r) { if(r > 0) { mResolution = r; this->UpdateSourceResolution(); this->Modified(); } } void iBoundedPolyDataSource::SetCenter(const double x[3]) { int i; for(i=0; i<3; i++) mCenter[i] = x[i]; this->Modified(); } void iBoundedPolyDataSource::SetNormal(const double n[3]) { int i; for(i=0; i<3; i++) mNormal[i] = n[i]; vtkMath::Normalize(mNormal); mNormalChanged = true; this->Modified(); } void iBoundedPolyDataSource::SetRadius(double r) { if(r > 0.0) { mRadius = r; this->Modified(); } } void iBoundedPolyDataSource::SetBounds(double b0, double b1, double b2, double b3, double b4, double b5) { mBounds[0] = b0; mBounds[1] = b1; mBounds[2] = b2; mBounds[3] = b3; mBounds[4] = b4; mBounds[5] = b5; mClipPlanes->SetBounds(mBounds); this->Modified(); } void iBoundedPolyDataSource::ProvideOutput() { mTransform->Identity(); if(vtkMath::Norm(mCenter) > 1.0e-30) { mTransform->Translate(mCenter); mFilter->Modified(); } if(mRadiusCanChange && fabs(mRadius-1.0)>1.0e-10) { mTransform->Scale(mRadius,mRadius,mRadius); mFilter->Modified(); } if(mNormalCanChange && mNormalChanged) { mTransform->SetDirection(mNormal[0],mNormal[1],mNormal[2]); } this->UpdateBoundaryConditions(); mClipper->Update(); this->OutputData()->ShallowCopy(mClipper->GetOutputDataObject(0)); } float iBoundedPolyDataSource::GetMemorySize() const { float s = 0.0; s += mClipper->GetOutput()->GetActualMemorySize(); s += mFilter->GetOutput()->GetActualMemorySize(); s += this->GetSourceMemorySize(); return s; } ifrit-4.1.2/core/iboundedpolydatasource.h0000674060175406010010000000574512641012515017075 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IBOUNDEDPOLYDATASOURCE_H #define IBOUNDEDPOLYDATASOURCE_H #include "igenericfilter.h" #include class iLimits; class iTransform; class vtkClipPolyData; class vtkCommand; class vtkPlanes; class vtkTransformPolyDataFilter; class iBoundedPolyDataSource : public iGenericPolyDataFilter { public: vtkTypeMacro(iBoundedPolyDataSource,vtkPolyDataAlgorithm); unsigned long AddObserver(unsigned long e, vtkCommand *c, float priority = 0.0); void SetCenter(const double x[3]); inline const double* GetCenter() const { return mCenter; } void SetResolution(int r); inline int GetResolution() const { return mResolution; } void SetBounds(double b0, double b1, double b2, double b3, double b4, double b5); inline const double* GetBounds() const { return mBounds; } void SetRadius(double r); inline double GetRadius() const { return mRadius; } void SetNormal(const double n[3]); inline const double* GetNormal() const { return mNormal; } float GetMemorySize() const; protected: iBoundedPolyDataSource(iDataConsumer *consumer, bool normalCanChange, bool radiusCanChange); virtual ~iBoundedPolyDataSource(); virtual void ProvideOutput(); virtual void UpdateBoundaryConditions() = 0; virtual void UpdateSourceResolution() = 0; virtual void AddObserverToSource(unsigned long e, vtkCommand *c, float priority) = 0; virtual float GetSourceMemorySize() const = 0; double mBounds[6]; double mCenter[3], mNormal[3], mRadius; int mResolution; bool mNormalChanged; const bool mNormalCanChange, mRadiusCanChange; // // VTK stuff // iTransform *mTransform; vtkPlanes *mClipPlanes; vtkClipPolyData *mClipper; vtkTransformPolyDataFilter *mFilter; }; #endif // IBOUNDEDPOLYDATASOURCE_H ifrit-4.1.2/core/iboundedspheresource.cpp0000674060175406010010000000760212641012546017077 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iboundedspheresource.h" #include "idataconsumer.h" #include "idatasubject.h" #include "ierror.h" #include "ispheresource.h" #include "iviewmodule.h" #include #include #include // // iBoundedSphereSource class // iBoundedSphereSource* iBoundedSphereSource::New(iDataConsumer *consumer) { IASSERT(consumer); return new iBoundedSphereSource(consumer); } iBoundedSphereSource::iBoundedSphereSource(iDataConsumer *consumer) : iBoundedPolyDataSource(consumer,false,true) { mAppend = vtkAppendPolyData::New(); IERROR_CHECK_MEMORY(mAppend); for(int i=0; i<8; i++) { mSource[i] = iSphereSource::New(); IERROR_CHECK_MEMORY(mSource[i]); } mAppend->UserManagedInputsOn(); mAppend->SetInputConnection(mSource[0]->GetOutputPort()); mSource[0]->SetResolution(1); mSource[0]->SetRadius(1.0); mFilter->SetInputConnection(mSource[0]->GetOutputPort()); } iBoundedSphereSource::~iBoundedSphereSource() { mAppend->Delete(); for(int i=0; i<8; i++) { mSource[i]->Delete(); } } void iBoundedSphereSource::AddObserverToSource(unsigned long e, vtkCommand *c, float p) { mAppend->AddObserver(e,c,p); for(int i=0; i<8; i++) { mSource[i]->AddObserver(e,c,p); } } void iBoundedSphereSource::UpdateSourceResolution() { mSource[0]->SetResolution(mResolution); } float iBoundedSphereSource::GetSourceMemorySize() const { float s = 0.0; for(int i=0; i<8; i++) { s += mSource[i]->GetOutput()->GetActualMemorySize(); } s += mAppend->GetOutput()->GetActualMemorySize(); return s; } void iBoundedSphereSource::UpdateBoundaryConditions() { int i, j, l, side[3]; double cen[3], xb; // // Test for out-of-bounds pieces // for(i=0; i<3; i++) { side[i] = 0; if(this->Consumer()->GetSubject()->IsDirectionPeriodic(i)) { xb = mCenter[i] - mRadius; if(xb < mBounds[2*i+0]) side[i] = -1; // we should only cross one boundary xb = mCenter[i] + mRadius; if(xb > mBounds[2*i+1]) side[i] = 1; } } if(side[0]==0 && side[1]==0 && side[2]==0) { // // Fully inside // mFilter->SetInputConnection(mSource[0]->GetOutputPort()); return; } mFilter->SetInputConnection(mAppend->GetOutputPort()); l = 1; for(i=0; i<3; i++) { if(side[i] != 0) { mAppend->SetNumberOfInputs(2*l); for(j=l; j<2*l; j++) { mSource[j]->SetRadius(1.0); mSource[j]->SetResolution(mResolution); mSource[j-l]->GetCenter(cen); cen[i] -= 2.0*side[i]/mRadius; mSource[j]->SetCenter(cen); #ifdef IVTK_5 mAppend->SetInputByNumber(j,mSource[j]->GetOutput()); #else mAppend->SetInputConnectionByNumber(j,mSource[j]->GetOutputPort()); #endif } l *= 2; } } } ifrit-4.1.2/core/iboundedspheresource.h0000674060175406010010000000403612641012515016536 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IBOUNDEDSPHERESOURCE_H #define IBOUNDEDSPHERESOURCE_H #include "iboundedpolydatasource.h" class iSphereSource; class vtkAppendPolyData; class iBoundedSphereSource : public iBoundedPolyDataSource { public: vtkTypeMacro(iBoundedSphereSource,iBoundedPolyDataSource); static iBoundedSphereSource* New(iDataConsumer *consumer = 0); protected: iBoundedSphereSource(iDataConsumer *consumer); virtual ~iBoundedSphereSource(); virtual void UpdateBoundaryConditions(); virtual void UpdateSourceResolution(); virtual void AddObserverToSource(unsigned long e, vtkCommand *c, float priority); virtual float GetSourceMemorySize() const; private: // // VTK stuff // vtkAppendPolyData *mAppend; iSphereSource *mSource[8]; // 8 of them for periodic BC }; #endif // IBOUNDEDSPHERESOURCE_H ifrit-4.1.2/core/iboundingbox.cpp0000674060175406010010000002664312641012546015353 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iboundingbox.h" #include "iactor.h" #include "iactorcollection.h" #include "icamera.h" #include "icubeaxesactor.h" #include "ierror.h" #include "irendertool.h" #include "iviewmodule.h" #include #include #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "iproperty.tlh" using namespace iParameter; namespace iBoundingBox_Private { // // Helper functions // iActor* CreateBoxA(iRenderTool *rt); iActorCollection* CreateBoxB(iRenderTool *rt); iActorCollection* CreateBoxC(iRenderTool *rt); }; using namespace iBoundingBox_Private; // // Main class // iBoundingBox* iBoundingBox::New(iViewModule *vm) { static iString LongName("BoundingBox"); static iString ShortName("bb"); IASSERT(vm); return new iBoundingBox(vm,LongName,ShortName); } iBoundingBox::iBoundingBox(iViewModule *vm, const iString &fname, const iString &sname) : iViewModuleTool(vm,fname,sname), iObjectConstructPropertyMacroS(Int,iBoundingBox,Type,t), iObjectConstructPropertyMacroV(Float,iBoundingBox,AxesRanges,r,6), iObjectConstructPropertyMacroV(String,iBoundingBox,AxesLabels,l,3) { // // Bounding boxes // mBox0Actor = CreateBoxA(this->GetViewModule()->GetRenderTool()); mBox1Actor = CreateBoxB(this->GetViewModule()->GetRenderTool()); mBox2Actor = CreateBoxA(this->GetViewModule()->GetRenderTool()); mBox3Actor = CreateBoxC(this->GetViewModule()->GetRenderTool()); mBox0Actor->GetMapper()->ScalarVisibilityOn(); mBox0Actor->GetProperty()->SetLineWidth(4.0); mBox2Actor->GetMapper()->ScalarVisibilityOff(); mBox2Actor->GetProperty()->SetLineWidth(1.0); mBox3AxesLabels = iCubeAxesActor::New(this->GetViewModule()->GetRenderTool()); IERROR_CHECK_MEMORY(mBox3AxesLabels); mBox3AxesLabels->PickableOff(); mBox3AxesLabels->VisibilityOff(); mBox3AxesLabels->SetCamera(this->GetViewModule()->GetRenderTool()->GetCamera()->GetDevice()); this->SetAxesLabels(0,"X"); this->SetAxesLabels(1,"Y"); this->SetAxesLabels(2,"Z"); this->SetAxesRanges(0,-1.0); this->SetAxesRanges(1,1.0); this->SetAxesRanges(2,-1.0); this->SetAxesRanges(3,1.0); this->SetAxesRanges(4,-1.0); this->SetAxesRanges(5,1.0); this->GetViewModule()->GetRenderTool()->AddObject(mBox3AxesLabels); // // Set bounding box // mType = -1; this->SetType(BoundingBoxType::Default); } iBoundingBox::~iBoundingBox() { this->GetViewModule()->GetRenderTool()->RemoveObject(mBox3AxesLabels); mBox3AxesLabels->Delete(); this->GetViewModule()->GetRenderTool()->RemoveObject(mBox0Actor); this->GetViewModule()->GetRenderTool()->RemoveObject(mBox2Actor); mBox0Actor->Delete(); mBox1Actor->Delete(); mBox2Actor->Delete(); mBox3Actor->Delete(); } void iBoundingBox::SetMagnification(int m) { if(m > 0) { mBox0Actor->GetProperty()->SetLineWidth(4.0*m); mBox2Actor->GetProperty()->SetLineWidth(1.0*m); } } void iBoundingBox::SetColor(const iColor &c) { mBox2Actor->GetProperty()->SetColor(c.ToVTK()); } bool iBoundingBox::SetAxesLabels(int i, const iString& label) { switch(i) { case 0: { mAxesLabels[0] = label; mBox3AxesLabels->SetXLabel(label.ToCharPointer()); return true; } case 1: { mAxesLabels[1] = label; mBox3AxesLabels->SetYLabel(label.ToCharPointer()); return true; } case 2: { mAxesLabels[2] = label; mBox3AxesLabels->SetZLabel(label.ToCharPointer()); return true; } default: { return false; } } } bool iBoundingBox::SetAxesRanges(int i, float v) { if(i>=0 && i<6) { double b[6]; mBox3AxesLabels->GetRanges(b); b[i] = v; mBox3AxesLabels->SetRanges(b); return true; } else return false; } float iBoundingBox::GetAxesRanges(int i) const { if(i>=0 && i<6) { return mBox3AxesLabels->GetRanges()[i]; } else return 0.0f; } bool iBoundingBox::ShowBody(bool s) { mBox0Actor->VisibilityOff(); mBox1Actor->VisibilityOff(); mBox2Actor->VisibilityOff(); mBox3Actor->VisibilityOff(); mBox3AxesLabels->VisibilityOff(); if(s) { switch(mType) { case BoundingBoxType::Default: { mBox0Actor->VisibilityOn(); break; } case BoundingBoxType::Classic: { mBox1Actor->VisibilityOn(); break; } case BoundingBoxType::HairThin: { mBox2Actor->VisibilityOn(); break; } case BoundingBoxType::Axes: { mBox3Actor->VisibilityOn(); mBox3AxesLabels->VisibilityOn(); break; } default: return false; } } return true; } bool iBoundingBox::SetType(int t) { if(BoundingBoxType::IsValid(t)) { mType = t; this->ShowBody(mIsVisible); return true; } else return false; } // // Helper functions in a private namespace // namespace iBoundingBox_Private { iActor* CreateBoxA(iRenderTool *rt) { // // Bounding box 1 // static float x[8][3]={{-1,-1,-1}, {1,-1,-1}, {1,1,-1}, {-1,1,-1}, {-1,-1,1}, {1,-1,1}, {1,1,1}, {-1,1,1}}; static vtkIdType lns[12][2]={{0,1}, {1,2}, {2,3}, {3,0}, {0,4}, {1,5}, {2,6}, {3,7}, {4,5}, {5,6}, {6,7}, {7,4}}; vtkPolyData *pd = vtkPolyData::New(); IERROR_CHECK_MEMORY(pd); vtkPoints *points = vtkPoints::New(VTK_FLOAT); IERROR_CHECK_MEMORY(points); vtkCellArray *polys = vtkCellArray::New(); IERROR_CHECK_MEMORY(polys); vtkFloatArray *scalars = vtkFloatArray::New(); IERROR_CHECK_MEMORY(scalars); // // Load the point, cell, and data attributes. // int i; for (i=0; i<8; i++) points->InsertPoint(i,x[i]); for (i=0; i<8; i++) scalars->InsertTuple1(i,(i<4)); for (i=0; i<12; i++) polys->InsertNextCell(2,lns[i]); // // We now assign the pieces to the vtkPolyData. // pd->SetLines(polys); polys->Delete(); pd->SetPoints(points); points->Delete(); pd->GetPointData()->SetScalars(scalars); scalars->Delete(); // // Configure the actor // iActor* box1Actor = iActor::New(); IERROR_CHECK_MEMORY(box1Actor); box1Actor->PickableOff(); box1Actor->VisibilityOff(); // mBox1Actor->SetScalarRange(0,1); box1Actor->GetProperty()->SetAmbient(1.0); box1Actor->GetProperty()->SetDiffuse(0.0); box1Actor->GetProperty()->SetSpecular(0.0); box1Actor->GetProperty()->SetLineWidth(4.0); box1Actor->GetProperty()->SetColor(0.0,0.0,0.0); box1Actor->SetInputData(pd); pd->Delete(); rt->AddObject(box1Actor); return box1Actor; } iActorCollection* CreateBoxB(iRenderTool *rt) { // // Bounding box 2 // float diam = 0.02; iActor *actor[12]; vtkCylinderSource *cs; int i; for(i=0; i<12; i++) { actor[i] = iActor::New(); IERROR_CHECK_MEMORY(actor[i]); actor[i]->PickableOff(); cs = vtkCylinderSource::New(); IERROR_CHECK_MEMORY(cs); cs->SetResolution(6); cs->SetHeight(2.0+2.0*diam); cs->SetRadius(diam); cs->Update(); actor[i]->SetInputConnection(cs->GetOutputPort()); cs->Delete(); } for(i=0; i<4; i++) { actor[i]->GetProperty()->SetColor(0.0,0.0,1.0); actor[i]->RotateX(90.0); } for(i=4; i<8; i++) actor[i]->GetProperty()->SetColor(0.0,1.0,0.0); for(i=8; i<12; i++) { actor[i]->GetProperty()->SetColor(1.0,0.0,0.0); actor[i]->RotateZ(90.0); } actor[ 0]->SetPosition(-1.0,-1.0,0.0); actor[ 1]->SetPosition(-1.0, 1.0,0.0); actor[ 2]->SetPosition( 1.0,-1.0,0.0); actor[ 3]->SetPosition( 1.0, 1.0,0.0); actor[ 4]->SetPosition(-1.0,0.0,-1.0); actor[ 5]->SetPosition(-1.0,0.0, 1.0); actor[ 6]->SetPosition( 1.0,0.0,-1.0); actor[ 7]->SetPosition( 1.0,0.0, 1.0); actor[ 8]->SetPosition(0.0,-1.0,-1.0); actor[ 9]->SetPosition(0.0,-1.0, 1.0); actor[10]->SetPosition(0.0, 1.0,-1.0); actor[11]->SetPosition(0.0, 1.0, 1.0); iActorCollection* box2Actor = iActorCollection::New(); IERROR_CHECK_MEMORY(box2Actor); for(i=0; i<12; i++) { actor[i]->GetProperty()->SetAmbient(0.2); actor[i]->GetProperty()->SetDiffuse(0.2); actor[i]->GetProperty()->SetSpecular(0.2); box2Actor->AddActor(actor[i]); rt->AddObject(actor[i]); actor[i]->Delete(); } box2Actor->SetVisibility(false); return box2Actor; } iActorCollection* CreateBoxC(iRenderTool *rt) { // // Bounding box 3 // float diam = 0.02; iActor *actor[12]; vtkArrowSource *as; vtkCylinderSource *cs; int i; for(i=0; i<3; i++) { actor[i] = iActor::New(); IERROR_CHECK_MEMORY(actor[i]); actor[i]->PickableOff(); as = vtkArrowSource::New(); IERROR_CHECK_MEMORY(as); as->SetShaftResolution(6); as->SetTipResolution(6); as->SetTipLength(0.15); as->SetShaftRadius(0.5*diam); as->SetTipRadius(1.5*diam); as->Update(); actor[i]->SetInputConnection(as->GetOutputPort()); as->Delete(); actor[i]->SetAxisScale(2.5,2.5,2.5); } diam *= 0.75; for(i=3; i<12; i++) { actor[i] = iActor::New(); IERROR_CHECK_MEMORY(actor[i]); actor[i]->PickableOff(); cs = vtkCylinderSource::New(); IERROR_CHECK_MEMORY(cs); cs->SetResolution(6); cs->SetHeight(2.0+2.0*diam); cs->SetRadius(diam); actor[i]->SetInputConnection(cs->GetOutputPort()); cs->Delete(); } actor[0]->GetProperty()->SetColor(0.0,0.0,1.0); actor[0]->RotateY(-90.0); actor[1]->GetProperty()->SetColor(0.0,1.0,0.0); actor[1]->RotateZ(90.0); actor[2]->GetProperty()->SetColor(1.0,0.0,0.0); for(i=3; i<6; i++) { actor[i]->GetProperty()->SetColor(0.0,0.0,1.0); actor[i]->RotateX(90.0); } for(i=6; i<9; i++) actor[i]->GetProperty()->SetColor(0.0,1.0,0.0); for(i=9; i<12; i++) { actor[i]->GetProperty()->SetColor(1.0,0.0,0.0); actor[i]->RotateZ(90.0); } actor[ 0]->SetPosition(-1.0,-1.0,-1.0); actor[ 1]->SetPosition(-1.0,-1.0,-1.0); actor[ 2]->SetPosition(-1.0,-1.0,-1.0); actor[ 3]->SetPosition(-1.0, 1.0,0.0); actor[ 4]->SetPosition( 1.0,-1.0,0.0); actor[ 5]->SetPosition( 1.0, 1.0,0.0); actor[ 6]->SetPosition(-1.0,0.0, 1.0); actor[ 7]->SetPosition( 1.0,0.0,-1.0); actor[ 8]->SetPosition( 1.0,0.0, 1.0); actor[ 9]->SetPosition(0.0, 1.0,-1.0); actor[10]->SetPosition(0.0,-1.0, 1.0); actor[11]->SetPosition(0.0, 1.0, 1.0); iActorCollection* box3Actor = iActorCollection::New(); IERROR_CHECK_MEMORY(box3Actor); for(i=0; i<12; i++) { actor[i]->GetProperty()->SetAmbient(0.2); actor[i]->GetProperty()->SetDiffuse(0.2); actor[i]->GetProperty()->SetSpecular(0.2); box3Actor->AddActor(actor[i]); rt->AddObject(actor[i]); actor[i]->Delete(); } box3Actor->SetVisibility(false); return box3Actor; } }; ifrit-4.1.2/core/iboundingbox.h0000674060175406010010000000444012641012515015003 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IBOUNDINGBOX_H #define IBOUNDINGBOX_H #include "iviewmoduletool.h" #include "istring.h" class iActor; class iActorCollection; class iCubeAxesActor; namespace iParameter { namespace BoundingBoxType { const int Default = 0; const int Classic = 1; const int HairThin = 2; const int Axes = 3; inline bool IsValid(int m){ return m>=0 && m<=3; } }; }; class iBoundingBox : public iViewModuleTool { public: vtkTypeMacro(iBoundingBox,iViewModuleTool); static iBoundingBox* New(iViewModule *vm = 0); iObjectPropertyMacro1S(Type,Int); iObjectPropertyMacro2V(AxesRanges,Float); iObjectPropertyMacro1V(AxesLabels,String,3); void SetMagnification(int m); void SetColor(const iColor &c); protected: virtual ~iBoundingBox(); private: iBoundingBox(iViewModule *vm, const iString &fname, const iString &sname); virtual bool ShowBody(bool s); // // Actors displayed by this class // iActor *mBox0Actor, *mBox2Actor; iActorCollection *mBox1Actor, *mBox3Actor; iCubeAxesActor *mBox3AxesLabels; }; #endif // IBOUNDINGBOX_H ifrit-4.1.2/core/ibuffer.h0000674060175406010010000000337012641012515013737 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IBUFFER_H #define IBUFFER_H // // Adjustable buffer (piece of memory) of type T. There is no out-of-boundary checking // like in iArray // template class iBuffer { public: iBuffer(); ~iBuffer(); void Reset(bool fill0); void Extend(int s); void Fill(const T* ptr, int size); // fast fill T& operator[](int i); inline const T& operator[](int i) const { return this->mArr[i]; } inline operator T*() const { return this->mArr; } private: T* mArr; int mLen; }; #endif // IBUFFER_H ifrit-4.1.2/core/ibuffer.tlh0000674060175406010010000000216112641012510014267 0ustar HomeNone//LICENSE A #include "ibuffer.h" #include "ierror.h" template iBuffer::iBuffer() { this->mLen = 100; this->mArr = new T[this->mLen]; IERROR_CHECK_MEMORY(this->mArr); } template iBuffer::~iBuffer() { delete [] this->mArr; } template void iBuffer::Reset(bool fill0) { delete [] this->mArr; this->mLen = 100; this->mArr = new T[this->mLen]; IERROR_CHECK_MEMORY(this->mArr); if(fill0) { int i; for(i=0; imLen; i++) this->mArr[i] = T(0); // we cannot use memcpy here because = is not necessarily a simple memory copy } } template T& iBuffer::operator[](int i) { if(i >= this->mLen) this->Extend(i+1); return this->mArr[(i<0)?0:i]; } template void iBuffer::Fill(const T* ptr, int size) { int i; if(size > this->mLen) this->Extend(size); for(i=0; imArr[i] = ptr[i]; // we cannot use memcpy here because = is not necessarily a simple memory copy } template void iBuffer::Extend(int s) { if(s > this->mLen) { delete [] this->mArr; this->mLen = s; mArr = new T[this->mLen]; IERROR_CHECK_MEMORY(mArr); } } ifrit-4.1.2/core/icamera.cpp0000674060175406010010000002024512641012546014255 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icamera.h" #include "ierror.h" #include "ieventobserver.h" #include "irendertool.h" #include "iviewmodule.h" #include #include #include // // Templates // #include "iarray.tlh" #include "iproperty.tlh" // // Main class // iCamera* iCamera::New(iRenderTool *rt) { static iString LongName("Camera"); static iString ShortName("c"); IASSERT(rt); return new iCamera(rt,LongName,ShortName); } iCamera::iCamera(iRenderTool *rt, const iString &fname, const iString &sname) : iObject(rt->GetViewModule(),fname,sname), iViewModuleComponent(rt->GetViewModule()), mPosition(rt->GetViewModule()), mFocalPoint(rt->GetViewModule()), Position(Self(),rt->GetViewModule(),static_cast(&iCamera::SetPosition),static_cast(&iCamera::GetPosition),"Position","x"), FocalPoint(Self(),rt->GetViewModule(),static_cast(&iCamera::SetFocalPoint),static_cast(&iCamera::GetFocalPoint),"FocalPoint","f"), iObjectConstructPropertyMacroS(Vector,iCamera,ViewUp,u), iObjectConstructPropertyMacroS(Pair,iCamera,ClippingRange,cr), iObjectConstructPropertyMacroS(Bool,iCamera,ParallelProjection,pp), iObjectConstructPropertyMacroS(Double,iCamera,ParallelScale,ps), iObjectConstructPropertyMacroS(Double,iCamera,ViewAngle,va), iObjectConstructPropertyMacroS(Bool,iCamera,ViewAngleVertical,vav), iObjectConstructPropertyMacroS(Double,iCamera,EyeAngle,ea), iObjectConstructPropertyMacroS(Bool,iCamera,ClippingRangeAuto,cra), // // actions // iObjectConstructPropertyMacroA1(Double,iCamera,Azimuth,a), iObjectConstructPropertyMacroA1(Double,iCamera,Elevation,e), iObjectConstructPropertyMacroA1(Double,iCamera,Yaw,y), iObjectConstructPropertyMacroA1(Double,iCamera,Pitch,p), iObjectConstructPropertyMacroA1(Double,iCamera,Roll,r), iObjectConstructPropertyMacroA1(Double,iCamera,Zoom,z), ResetCamera(Self(),static_cast(&iCamera::Reset),"Reset","rs"), OrthogonalizeCameraView(Self(),static_cast(&iCamera::OrthogonalizeView),"OrthogonalizeView","ov") { mRenderMode = iParameter::RenderMode::Self; mRenderTool = rt; mDevice = vtkCamera::New(); IERROR_CHECK_MEMORY(mDevice); mSyncProjections = false; mDevice->ParallelProjectionOn(); mDevice->Modified(); } iCamera::~iCamera() { mDevice->Delete(); } bool iCamera::Reset() { mRenderTool->ResetCamera(); return true; } bool iCamera::OrthogonalizeView() { static const double orts[6][3] = { { -1.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, -1.0 }, { 0.0, 0.0, 1.0 } }; // // Orthogonalize the camera position. // int i, j, imax; double d, *v, dmax, pos[3]; imax = 5; dmax = 0.0; v = mDevice->GetDirectionOfProjection(); for(i=0; i<6; i++) { d = vtkMath::Dot(orts[i],v); if(d > dmax) { dmax = d; imax = i; } } d = mDevice->GetDistance(); v = mDevice->GetFocalPoint(); for(j=0; j<3; j++) pos[j] = v[j] - d*orts[imax][j]; mDevice->SetPosition(pos); // // Orthogonalize the view up. // imax = 3; dmax = 0.0; v = mDevice->GetViewUp(); for(i=0; i<6; i++) { d = vtkMath::Dot(orts[i],v); if(d > dmax) { dmax = d; imax = i; } } mDevice->SetViewUp(orts[imax]); return true; } void iCamera::ShiftTo(const iPosition& pos) { int j; double cp[3], fp[3]; mDevice->GetPosition(cp); mDevice->GetFocalPoint(fp); for(j=0; j<3; j++) { cp[j] += (pos[j]-fp[j]); } mDevice->SetPosition(cp); mDevice->SetFocalPoint(pos); } bool iCamera::GetParallelProjection() const { return mDevice->GetParallelProjection() != 0; } double iCamera::GetParallelScale() const { return mDevice->GetParallelScale(); } double iCamera::GetViewAngle() const { return mDevice->GetViewAngle(); } bool iCamera::GetViewAngleVertical() const { return mDevice->GetUseHorizontalViewAngle() == 0; } double iCamera::GetEyeAngle() const { return mDevice->GetEyeAngle(); } bool iCamera::GetClippingRangeAuto() const { return mRenderTool->GetAdjustCameraClippingRangeAutomatically(); } bool iCamera::SetParallelProjection(bool b) { // // We shouldn't reset unless we actually change projections // if(b != this->GetParallelProjection()) { if(mSyncProjections) this->SyncProjections(); else mRenderTool->ResetCamera(); } mDevice->SetParallelProjection(b?1:0); return true; } bool iCamera::SetParallelScale(double f) { mDevice->SetParallelScale(f); return true; } bool iCamera::SetViewAngle(double f) { mDevice->SetViewAngle(f); return true; } bool iCamera::SetViewAngleVertical(bool b) { mDevice->SetUseHorizontalViewAngle(b?0:1); return true; } bool iCamera::SetEyeAngle(double f) { mDevice->SetEyeAngle(f); return true; } bool iCamera::SetClippingRangeAuto(bool b) { mRenderTool->SetAdjustCameraClippingRangeAutomatically(b); return true; } bool iCamera::CallAzimuth(double f) { mDevice->Azimuth(f); return true; } bool iCamera::CallElevation(double f) { mDevice->Elevation(f); return true; } bool iCamera::CallYaw(double f) { mDevice->Yaw(f); return true; } bool iCamera::CallPitch(double f) { mDevice->Pitch(f); return true; } bool iCamera::CallRoll(double f) { mDevice->Roll(f); return true; } bool iCamera::CallZoom(double f) { if(f > 1.0e-30) { if(mDevice->GetParallelProjection() != 0) { mDevice->SetParallelScale(mDevice->GetParallelScale()/f); } else { mDevice->Dolly(f); } return true; } else return false; } bool iCamera::SetPosition(const iPosition &p) { mDevice->SetPosition(p); return true; } const iPosition& iCamera::GetPosition() const { mPosition = mDevice->GetPosition(); return mPosition; } bool iCamera::SetFocalPoint(const iPosition &p) { mDevice->SetFocalPoint(p); return true; } const iPosition& iCamera::GetFocalPoint() const { mFocalPoint = mDevice->GetFocalPoint(); return mFocalPoint; } bool iCamera::SetViewUp(const iVector3D& v) { mDevice->SetViewUp(v); return true; } const iVector3D& iCamera::GetViewUp() const { mViewUp = mDevice->GetViewUp(); return mViewUp; } bool iCamera::SetClippingRange(const iPair& v) { double d, dv[2]; d = mDevice->GetDistance(); dv[0] = v.Min*d; dv[1] = v.Max*d; mRenderTool->SetCameraClippingRange(dv); return true; } const iPair& iCamera::GetClippingRange() const { double d, dv[2]; mDevice->GetClippingRange(dv); d = mDevice->GetDistance(); if(d > 0.0) { mClippingRange.Min = dv[0]/d; mClippingRange.Max = dv[1]/d; } return mClippingRange; } void iCamera::SyncProjections() { static const double minDistance = 0.0002; // idiotic VTK limit double r = 1.0e-35 + tan(0.5*iMath::Deg2Rad(mDevice->GetViewAngle())); if(mDevice->GetParallelProjection() != 0) { double d = mDevice->GetParallelScale()/r; if(d > minDistance) mDevice->Dolly(mDevice->GetDistance()/d); } else { mDevice->SetParallelScale(mDevice->GetDistance()*r); } mRenderTool->ResetCameraClippingRange(); } ifrit-4.1.2/core/icamera.h0000674060175406010010000000606012641012515013715 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // This class is a merger of iObject with vtkCamera class. But since we cannot inherit, we must decorate // #ifndef ICAMERA_H #define ICAMERA_H #include "iobject.h" #include "iviewmodulecomponent.h" #include "iposition.h" #include "ipropertyposition.h" class iEventObserver; class iRenderTool; class vtkCamera; class iCamera : public iObject, public iViewModuleComponent { friend class iExtensionFactory; public: vtkTypeMacro(iCamera,iObject); static iCamera* New(iRenderTool *rt = 0); iObjectSlotMacro2S(Position,const iPosition&); iObjectSlotMacro2S(FocalPoint,const iPosition&); iPropertyScalarPosition Position, FocalPoint; // // Camera orientation // iObjectPropertyMacro2S(ViewUp,Vector); iObjectPropertyMacro2S(ClippingRange,Pair); iObjectPropertyMacro2S(ParallelProjection,Bool); iObjectPropertyMacro2S(ParallelScale,Double); iObjectPropertyMacro2S(ViewAngle,Double); iObjectPropertyMacro2S(ViewAngleVertical,Bool); iObjectPropertyMacro2S(EyeAngle,Double); iObjectPropertyMacro2S(ClippingRangeAuto,Bool); // // actions // iObjectPropertyMacroA1(Azimuth,Double); iObjectPropertyMacroA1(Elevation,Double); iObjectPropertyMacroA1(Yaw,Double); iObjectPropertyMacroA1(Pitch,Double); iObjectPropertyMacroA1(Roll,Double); iObjectPropertyMacroA1(Zoom,Double); iObjectPropertyMacroA(ResetCamera); iObjectPropertyMacroA(OrthogonalizeCameraView); bool Reset(); bool OrthogonalizeView(); void ShiftTo(const iPosition& pos); vtkCamera* GetDevice() const { return mDevice; } protected: virtual ~iCamera(); private: iCamera(iRenderTool *rt, const iString &fname, const iString &sname); void SyncProjections(); bool mSyncProjections; vtkCamera *mDevice; iRenderTool *mRenderTool; mutable iVector3D mViewUp; mutable iPair mClippingRange; mutable iPosition mPosition, mFocalPoint; }; #endif ifrit-4.1.2/core/icameraorthoactor.cpp0000674060175406010010000001377112641012546016370 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icameraorthoactor.h" #include "ierror.h" #include "ioverlayhelper.h" #include "itextactor.h" #include #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "igenericprop.tlh" iCameraOrthoActor* iCameraOrthoActor::New(iRenderTool *rt) { IASSERT(rt); return new iCameraOrthoActor(rt); } iCameraOrthoActor::iCameraOrthoActor(iRenderTool *rt) : iGenericProp(false), mOverlayHelper(rt) { int i; for(i=0; i<2; i++) { mLabels[i] = iTextActor::New(rt); IERROR_CHECK_MEMORY(mLabels[i]); this->AppendComponent(mLabels[i]); mLabels[i]->SetBold(true); mActors[i] = vtkAxisActor2D::New(); IERROR_CHECK_MEMORY(mActors[i]); this->AppendComponent(mActors[i]); mActors[i]->GetPoint1Coordinate()->SetCoordinateSystemToNormalizedViewport(); mActors[i]->GetPoint2Coordinate()->SetCoordinateSystemToNormalizedViewport(); mActors[i]->SetPoint1(0.05,0.05); mActors[i]->TitleVisibilityOff(); mActors[i]->LabelVisibilityOff(); mActors[i]->TickVisibilityOff(); mActors[i]->GetProperty()->SetColor(0.0,0.0,0.0); mActors[i]->GetProperty()->SetLineWidth(2); } mActors[0]->SetPoint2(0.15,0.05); mActors[1]->SetPoint2(0.05,0.15); } iCameraOrthoActor::~iCameraOrthoActor() { int i; for(i=0; i<2; i++) { mActors[i]->Delete(); mLabels[i]->Delete(); } } void iCameraOrthoActor::UpdateGeometry(vtkViewport* vp) { static const double orts[6][3] = { { -1.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, -1.0 }, { 0.0, 0.0, 1.0 } }; vtkCamera *cam = mOverlayHelper->GetCamera(vp); if(cam == 0) { this->Disable(); return; } // // Check direction of projection // double d, vx[3], *vy, dmax; int i, imax = 5, jmax = 3; dmax = 0.0; vtkMath::Cross(cam->GetViewUp(),cam->GetViewPlaneNormal(),vx); for(i=0; i<6; i++) { d = vtkMath::Dot(orts[i],vx); if(d > dmax) { dmax = d; imax = i; } } if(dmax < 0.99999) { this->Disable(); return; } // // Check view up. // dmax = 0.0; vy = cam->GetViewUp(); for(i=0; i<6; i++) { d = vtkMath::Dot(orts[i],vy); if(d > dmax) { dmax = d; jmax = i; } } if(dmax < 0.99999) { this->Disable(); return; } // // We are orthogonal // double as[2]; vp->GetAspect(as); if(as[0] > 1.0) { as[1] /= as[0]; as[0] = 1.0; } static const double off1 = 0.02; static const double off2 = 0.12; double pos1[2], pos2[2]; for(i=0; i<2; i++) { pos1[i] = off1/as[i]; pos2[i] = off2/as[i]; } int mag = mOverlayHelper->GetRenderingMagnification(); if(mag > 1) { int winij[2]; mOverlayHelper->ComputePositionShiftsUnderMagnification(winij); for(i=0; i<2; i++) { pos1[i] = mag*pos1[i]-winij[i]; pos2[i] = mag*pos2[i]-winij[i]; } } if(jmax%2 == 0) // y-neg { if(imax%2 == 0) // x-neg { mActors[0]->SetPoint1(pos2[0],pos2[1]); mActors[0]->SetPoint2(pos1[0]+0.2*(pos2[0]-pos1[0]),pos2[1]); mActors[1]->SetPoint1(pos2[0],pos2[1]); mActors[1]->SetPoint2(pos2[0],pos1[1]+0.2*(pos2[1]-pos1[1])); mLabels[0]->SetPosition(pos1[0],pos2[1]); mLabels[1]->SetPosition(pos2[0],pos1[1]); } else // x-pos { mActors[0]->SetPoint1(pos1[0],pos2[1]); mActors[0]->SetPoint2(pos2[0]-0.2*(pos2[0]-pos1[0]),pos2[1]); mActors[1]->SetPoint1(pos1[0],pos2[1]); mActors[1]->SetPoint2(pos1[0],pos1[1]+0.2*(pos2[1]-pos1[1])); mLabels[0]->SetPosition(pos2[0],pos2[1]); mLabels[1]->SetPosition(pos1[0],pos1[1]); } } else // y-pos { if(imax%2 == 0) // x-neg { mActors[0]->SetPoint1(pos2[0],pos1[1]); mActors[0]->SetPoint2(pos1[0]+0.2*(pos2[0]-pos1[0]),pos1[1]); mActors[1]->SetPoint1(pos2[0],pos1[1]); mActors[1]->SetPoint2(pos2[0],pos2[1]-0.2*(pos2[1]-pos1[1])); mLabels[0]->SetPosition(pos1[0],pos1[1]); mLabels[1]->SetPosition(pos2[0],pos2[1]); } else // x-pos { mActors[0]->SetPoint1(pos1[0],pos1[1]); mActors[0]->SetPoint2(pos2[0]-0.2*(pos2[0]-pos1[0]),pos1[1]); mActors[1]->SetPoint1(pos1[0],pos1[1]); mActors[1]->SetPoint2(pos1[0],pos2[1]-0.2*(pos2[1]-pos1[1])); mLabels[0]->SetPosition(pos2[0],pos1[1]); mLabels[1]->SetPosition(pos1[0],pos2[1]); } } switch(imax/2) { case 0: { mLabels[0]->SetText("X"); break; } case 1: { mLabels[0]->SetText("Y"); break; } case 2: { mLabels[0]->SetText("Z"); break; } }; switch(jmax/2) { case 0: { mLabels[1]->SetText("X"); break; } case 1: { mLabels[1]->SetText("Y"); break; } case 2: { mLabels[1]->SetText("Z"); break; } }; for(i=0; i<2; i++) { mActors[i]->GetProperty()->SetColor(this->GetOverlayHelper()->GetColor(vp).ToVTK()); mActors[i]->GetProperty()->SetLineWidth(2*mag); } } ifrit-4.1.2/core/icameraorthoactor.h0000674060175406010010000000370712641012516016030 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A small actor that shows camera orientation when it is orthogonal // #ifndef ICAMERAORTHOACTOR_H #define ICAMERAORTHOACTOR_H #include "igenericprop.h" #include #include "ipointermacro.h" class iTextActor; class iOverlayHelper; class iRenderTool; class vtkAxisActor2D; class vtkCamera; class iCameraOrthoActor : public iGenericProp { IPOINTER_AS_USER(OverlayHelper); public: vtkTypeMacro(iCameraOrthoActor,vtkActor2D); static iCameraOrthoActor* New(iRenderTool *rt = 0); protected: virtual ~iCameraOrthoActor(); virtual void UpdateGeometry(vtkViewport *vp); private: iCameraOrthoActor(iRenderTool *rv); vtkAxisActor2D *mActors[2]; iTextActor *mLabels[2]; }; #endif ifrit-4.1.2/core/icaption.cpp0000674060175406010010000001256212641012546014465 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icaption.h" #include "iactor.h" #include "ierror.h" #include "ioverlayhelper.h" #include #include #include #include #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "igenericprop.tlh" bool iCaption::Transparent = true; iCaption* iCaption::New(iRenderTool *rt) { IASSERT(rt); return new iCaption(rt); } iCaption::iCaption(iRenderTool *rt) : iFramedTextActor(rt) { this->SetJustification(-1,-1); // // This is the leader (line) from the attachment point to the caption // mLeaderInput = vtkPolyData::New(); IERROR_CHECK_MEMORY(mLeaderInput); vtkPoints *pts = vtkPoints::New(VTK_DOUBLE); IERROR_CHECK_MEMORY(pts); pts->SetNumberOfPoints(2); mLeaderInput->SetPoints(pts); pts->Delete(); vtkCellArray *leader = vtkCellArray::New(); IERROR_CHECK_MEMORY(leader); leader->InsertNextCell(2); leader->InsertCellPoint(0); leader->InsertCellPoint(1); //at the attachment point mLeaderInput->SetLines(leader); leader->Delete(); mLeaderActor = iActor::New(); IERROR_CHECK_MEMORY(mLeaderActor); this->PrependComponent(mLeaderActor); mLeaderActor->SetInputData(mLeaderInput); mAttachmentPoint = vtkCoordinate::New(); IERROR_CHECK_MEMORY(mAttachmentPoint); mAttachmentPoint->SetCoordinateSystemToWorld(); mAttachmentPoint->SetValue(0.0,0.0,0.0); } iCaption::~iCaption() { mAttachmentPoint->Delete(); mLeaderInput->Delete(); mLeaderActor->Delete(); } void iCaption::SetAttachmentPoint(double x[3]) { mAttachmentPoint->SetValue(x); } const double* iCaption::GetAttachmentPoint() { return mAttachmentPoint->GetValue(); } void iCaption::UpdateGeometry(vtkViewport* vp) { static const int index[5][2] = { { 0, 2 }, { 1, 2 }, { 1, 3 }, { 0, 3 }, { 0, 2 } }; iFramedTextActor::UpdateGeometry(vp); if(!this->IsEnabled()) return; int mag = this->GetOverlayHelper()->GetRenderingMagnification(); if(mag == 1) { this->SetTransparent(Transparent); // // Compute the screen projection of the attachment point // int *vl = mAttachmentPoint->GetComputedViewportValue(vp); int *vs = vp->GetSize(); int j; float pa[3]; for(j=0; j<2; j++) pa[j] = float(vl[j])/vs[j]; // // Define the leader. Have to find the closest point from the // border to the attachment point. We look at the four vertices // and four edge centers. // float d2, d2min, pt[3], ptmin[2]; d2min = VTK_LARGE_FLOAT; pt[2] = pa[2] = 0.0; for(j=0; j<8; j++) { if(j%2 == 0) { pt[0] = wBounds[index[j/2][0]]; pt[1] = wBounds[index[j/2][1]]; } else { pt[0] = 0.5*(wBounds[index[j/2][0]]+wBounds[index[j/2+1][0]]); pt[1] = 0.5*(wBounds[index[j/2][1]]+wBounds[index[j/2+1][1]]); } d2 = vtkMath::Distance2BetweenPoints(pa,pt); if(d2 < d2min) { d2min = d2; ptmin[0] = pt[0]; ptmin[1] = pt[1]; } } // // Find the world coordinates of the nearest point. // vtkCamera *cam = this->GetOverlayHelper()->GetCamera(vp); double x[4], d[3]; double *clip = cam->GetClippingRange(); double *cpos = cam->GetPosition(); vp->SetDisplayPoint(ptmin[0]*vs[0],ptmin[1]*vs[1],0.0); vp->DisplayToWorld(); vp->GetWorldPoint(x); for(j=0; j<3; j++) d[j] = x[j] - cpos[j]; double cdop[3]; cam->GetDirectionOfProjection(cdop); vtkMath::Normalize(cdop); float s = clip[0]/vtkMath::Dot(d,cdop); for(j=0; j<3; j++) x[j] = cpos[j] + s*d[j]; #ifdef I_DEBUG iOutput::DisplayDebugMessage(iString("Caption: ")+iString::FromNumber(d2min)+" ("+iString::FromNumber(ptmin[0])+","+iString::FromNumber(ptmin[1])+")"); iOutput::DisplayDebugMessage(iString(" ")+iString::FromNumber(s)+" ("+iString::FromNumber(x[0])+","+iString::FromNumber(x[1])+","+iString::FromNumber(x[2])+","+iString::FromNumber(x[3])+")"); #endif vtkPoints *pts = mLeaderInput->GetPoints(); pts->SetPoint(0,mAttachmentPoint->GetValue()); pts->SetPoint(1,x); mLeaderInput->Modified(); mLeaderActor->GetProperty()->SetColor(this->GetOverlayHelper()->GetColor(vp).ToVTK()); } mLeaderActor->GetProperty()->SetLineWidth(2*mag); } ifrit-4.1.2/core/icaption.h0000674060175406010010000000362112641012516014123 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ICAPTION_H #define ICAPTION_H #include "iframedtextactor.h" class iActor; class vtkCoordinate; class vtkPolyData; class iCaption: public iFramedTextActor { public: vtkTypeMacro(iCaption,iFramedTextActor); static iCaption* New(iRenderTool *rt = 0); void SetAttachmentPoint(double x[3]); const double* GetAttachmentPoint(); static bool Transparent; protected: virtual ~iCaption(); virtual void UpdateGeometry(vtkViewport *vp); private: iCaption(iRenderTool *rv); vtkCoordinate *mAttachmentPoint; float mUnmagx1[2], mUnmagx2[2]; // // Leader // vtkPolyData *mLeaderInput; iActor *mLeaderActor; }; #endif // ICAPTION_H ifrit-4.1.2/core/icaptioninteractorstyle.cpp0000674060175406010010000001370212641012546017636 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icaptioninteractorstyle.h" #include "icaption.h" #include "imarker.h" #include "irendertool.h" #include "iviewmodule.h" #include "iviewobject.h" #include #include #include #include #include #include #include #include #include // // Templates (needed for some compilers) // #include "iarray.tlh" iCaptionInteractorStyle* iCaptionInteractorStyle::New(iViewModule *vm) { IASSERT(vm); return new iCaptionInteractorStyle(vm); } iCaptionInteractorStyle::iCaptionInteractorStyle(iViewModule *vm) : iViewModuleComponent(vm) { mInteractionMarker = 0; // // Experimental: gray screen for moving captions // vtkPolyData *data = vtkPolyData::New(); IERROR_CHECK_MEMORY(data); vtkPoints *pts = vtkPoints::New(VTK_FLOAT); IERROR_CHECK_MEMORY(pts); pts->SetNumberOfPoints(4); pts->SetPoint(0,0.0,0.0,0.0); pts->SetPoint(1,1.0,0.0,0.0); pts->SetPoint(2,1.0,1.0,0.0); pts->SetPoint(3,0.0,1.0,0.0); data->SetPoints(pts); pts->Delete(); vtkCellArray *cells = vtkCellArray::New(); IERROR_CHECK_MEMORY(cells); cells->InsertNextCell(4); cells->InsertCellPoint(0); cells->InsertCellPoint(1); cells->InsertCellPoint(2); cells->InsertCellPoint(3); data->SetPolys(cells); cells->Delete(); vtkPolyDataMapper2D *mapper = vtkPolyDataMapper2D::New(); IERROR_CHECK_MEMORY(mapper); mapper->SetInputData(data); data->Delete(); vtkCoordinate *c = vtkCoordinate::New(); IERROR_CHECK_MEMORY(c); c->SetCoordinateSystemToNormalizedViewport(); mapper->SetTransformCoordinate(c); c->Delete(); mScreen = vtkActor2D::New(); IERROR_CHECK_MEMORY(mScreen); mScreen->SetMapper(mapper); mapper->Delete(); mScreen->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); mScreen->SetPosition(0.0,0.0); mScreen->SetLayerNumber(10); mScreen->GetProperty()->SetOpacity(0.7); mScreen->GetProperty()->SetColor(0.5,0.5,0.5); this->GetViewModule()->GetRenderTool()->AddObject(mScreen); mScreen->SetVisibility(0); wNextStyle = 0; wTransparentCaptions = true; } iCaptionInteractorStyle::~iCaptionInteractorStyle() { this->GetViewModule()->GetRenderTool()->RemoveObject(mScreen); mScreen->Delete(); } void iCaptionInteractorStyle::Launch(vtkInteractorStyle *next) { mScreen->SetVisibility(1); wNextStyle = next; wTransparentCaptions = iCaption::Transparent; iCaption::Transparent = false; } void iCaptionInteractorStyle::FindPickedActor(int x, int y) { int i; if(this->CurrentRenderer == 0) return; for(i=0; iGetViewModule()->GetNumberOfMarkers(); i++) if(this->GetViewModule()->GetMarker(i)->GetMarkerCaption()->GetVisibility() == 1) { int *s = this->CurrentRenderer->GetSize(); float b[4]; this->GetViewModule()->GetMarker(i)->GetMarkerCaption()->GetBounds(this->CurrentRenderer,b); if(x>b[0]*s[0] && y>b[2]*s[1] && xGetViewModule()->GetMarker(i); return; } } mInteractionMarker = 0; } // // Rotating - a copy of vtkInteractorStyleTrackballActor::Rotate() with // no changes // void iCaptionInteractorStyle::Rotate() { if(CurrentRenderer==0 || mInteractionMarker==0) { return; } vtkRenderWindowInteractor *rwi = this->Interactor; int *size = CurrentRenderer->GetSize(); float dx = rwi->GetEventPosition()[0] - rwi->GetLastEventPosition()[0]; float dy = rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1]; const iPair &x(mInteractionMarker->GetCaptionPosition()); mInteractionMarker->SetCaptionPosition(iPair(x.X+dx/size[0],x.Y+dy/size[1])); rwi->Render(); } // // Need to overload this function too because it is not declared virtual in the parent class // void iCaptionInteractorStyle::OnLeftButtonDown() { int x = Interactor->GetEventPosition()[0]; int y = Interactor->GetEventPosition()[1]; this->FindPokedRenderer(x, y); this->FindPickedActor(x, y); if(CurrentRenderer!=0 && mInteractionMarker!=0) { this->StartRotate(); } else { this->Finish(); } } void iCaptionInteractorStyle::OnLeftButtonUp() { // // Quantize the position // if(mInteractionMarker != 0) { int *size = CurrentRenderer->GetSize(); const iPair &x0(mInteractionMarker->GetCaptionPosition()); iPair x; x.X = 10.0*floor(0.1*x0.X*size[0])/size[0]; x.Y = 10.0*floor(0.1*x0.Y*size[1])/size[1]; mInteractionMarker->SetCaptionPosition(x); Interactor->Render(); } mInteractionMarker = 0; } void iCaptionInteractorStyle::Finish() { if(mScreen->GetVisibility() != 0) { mScreen->SetVisibility(0); iCaption::Transparent = wTransparentCaptions; Interactor->Render(); if(wNextStyle != 0) { this->GetInteractor()->SetInteractorStyle(wNextStyle); } } } ifrit-4.1.2/core/icaptioninteractorstyle.h0000674060175406010010000000507012641012516017277 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ICAPTIONINTERACTORSTYLE_H #define ICAPTIONINTERACTORSTYLE_H #include #include "iviewmodulecomponent.h" class iMarkerInstance; class vtkActor2D; class iCaptionInteractorStyle: public vtkInteractorStyleTrackballActor, public iViewModuleComponent { public: vtkTypeMacro(iCaptionInteractorStyle,vtkInteractorStyleTrackballActor); static iCaptionInteractorStyle* New(iViewModule *vm = 0); void Launch(vtkInteractorStyle *next); void FindPickedActor(int x, int y); virtual void Rotate(); virtual void OnLeftButtonUp(); virtual void OnLeftButtonDown(); // // Disable all interactions except left mouse moving the caption around // virtual void Spin(){} virtual void Pan(){} virtual void Dolly(){} virtual void UniformScale(){} virtual void OnLeave(){ this->Finish(); } virtual void OnChar(){ this->Finish(); } virtual void OnMiddleButtonDown(){ this->Finish(); } virtual void OnMiddleButtonUp(){} virtual void OnRightButtonDown(){ this->Finish(); } virtual void OnRightButtonUp(){} protected: virtual ~iCaptionInteractorStyle(); private: iCaptionInteractorStyle(iViewModule *vm); void Finish(); iMarkerInstance *mInteractionMarker; vtkActor2D *mScreen; vtkInteractorStyle *wNextStyle; bool wTransparentCaptions; }; #endif // ICAPTIONINTERACTORSTYLE_H ifrit-4.1.2/core/iclipplane.cpp0000674060175406010010000001750512641012546015001 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iclipplane.h" #include "iactor.h" #include "ierror.h" #include "iposition.h" #include "itransform.h" #include "iviewmodule.h" #include #include #include #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "iproperty.tlh" using namespace iType; class iActor; class iClipPlanes; class iTransform; class iClipPlaneInstance : public vtkPlane, public iViewModuleComponent { friend class iClipPlane; public: vtkTypeMacro(iClipPlaneInstance,vtkPlane); void SetDirection(const iVector3D &dir); inline const iVector3D& GetDirection() const { return mDirection; } void SetPosition(const iPosition &pos); inline const iPosition& GetPosition() const { return mPosition; } void SetGlassPlaneVisible(bool s); bool GetGlassPlaneVisible() const; protected: virtual ~iClipPlaneInstance(); private: iClipPlaneInstance(iViewModule *vm); // // Actors displayed by this class // iActor *mActor; iTransform *mTransform; iVector3D mDirection; iPosition mPosition; }; // // Actor class // iClipPlaneInstance::iClipPlaneInstance(iViewModule *vm) : iViewModuleComponent(vm), mPosition(vm) { int i, j; // // Set plane parameters // vtkPolyData *pd = vtkPolyData::New(); IERROR_CHECK_MEMORY(pd); mActor = iActor::New(); IERROR_CHECK_MEMORY(mActor); static float x1[8][3] = { {1.0,0.0,0.0}, {0.7071,0.7071,0.0}, {0.0,1.0,0.0}, {-0.7071,0.7071,0.0}, {-1.0,0.0,0.0}, {-0.7071,-0.7071,0.0}, {0.0,-1.0,0.0}, {0.7071,-0.7071,0.0} }; static vtkIdType pts1[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; for(i=0; i<8; i++) for(j=0; j<3; j++) x1[i][j] *= 2.5; vtkPoints *points = vtkPoints::New(VTK_FLOAT); IERROR_CHECK_MEMORY(points); for(i=0; i<8; i++) points->InsertPoint(i,x1[i]); pd->SetPoints(points); points->Delete(); vtkCellArray *polys = vtkCellArray::New(); IERROR_CHECK_MEMORY(polys); polys->InsertNextCell(8,pts1); pd->SetPolys(polys); polys->Delete(); mActor->SetInputData(pd); pd->Delete(); mActor->VisibilityOff(); mActor->PickableOff(); mActor->GetProperty()->SetOpacity(0.5); mActor->GetProperty()->SetAmbient(1.0); mActor->GetProperty()->SetDiffuse(1.0); mActor->GetProperty()->SetSpecular(0.7); mActor->GetProperty()->SetSpecularPower(50.0); mActor->GetProperty()->SetColor(0.6,0.7,0.7); mTransform = iTransform::New(); IERROR_CHECK_MEMORY(mTransform); mActor->SetUserTransform(mTransform); this->GetViewModule()->AddObject(mActor); iPosition pos(this->GetViewModule()); this->SetPosition(pos); this->SetDirection(iVector3D(0.0,0.0,1.0)); } iClipPlaneInstance::~iClipPlaneInstance() { this->GetViewModule()->RemoveObject(mActor); mActor->Delete(); mTransform->Delete(); } void iClipPlaneInstance::SetGlassPlaneVisible(bool s) { mActor->SetVisibility(s?1:0); } bool iClipPlaneInstance::GetGlassPlaneVisible() const { return mActor->GetVisibility() != 0; } void iClipPlaneInstance::SetDirection(const iVector3D& dir) { mDirection = dir; vtkMath::Normalize(mDirection); int i; double n[3]; for(i=0; i<3; i++) n[i] = -mDirection[i]; this->SetNormal(n); // // Move the glass plane // mTransform->Identity(); mTransform->SetDirection(mDirection); mTransform->Translate(mPosition); } void iClipPlaneInstance::SetPosition(const iPosition &pos) { mPosition = pos; this->SetOrigin(mPosition); // // Move the glass plane // mTransform->Identity(); mTransform->SetDirection(mDirection); mTransform->Translate(mPosition); } // // Main class // iClipPlane* iClipPlane::New(iViewModule *vm) { static iString LongName("ClipPlane"); static iString ShortName("cp"); IASSERT(vm); return new iClipPlane(vm,LongName,ShortName); } iClipPlane::iClipPlane(iViewModule *vm, const iString &fname, const iString &sname) : iViewModuleTool(vm,fname,sname), Position(iObject::Self(),static_cast(&iClipPlane::SetPosition),static_cast(&iClipPlane::GetPosition),"Position","x",static_cast(&iClipPlane::GetNumber)), Direction(iObject::Self(),static_cast(&iClipPlane::SetDirection),static_cast(&iClipPlane::GetDirection),"Direction","d",static_cast(&iClipPlane::GetNumber)), Number(iObject::Self(),static_cast(&iClipPlane::SetNumber),static_cast(&iClipPlane::GetNumber),"Number","num",9), Remove(iObject::Self(),static_cast::CallerType>(&iClipPlane::CallRemove),"Delete","dlt"), Create(iObject::Self(),static_cast(&iClipPlane::CallCreate),"New","new") { Remove.AddFlag(iProperty::_FunctionsAsIndex); mPlanes = vtkPlaneCollection::New(); IERROR_CHECK_MEMORY(mPlanes); } iClipPlane::~iClipPlane() { mPlanes->RemoveAllItems(); mPlanes->Delete(); while(mInstances.Size() > 0) mInstances.RemoveLast()->Delete(); } int iClipPlane::GetNumber() const { return mInstances.Size(); } bool iClipPlane::SetNumber(int n) { if(n >= 0) { while(mInstances.Size() > n) { if(!this->CallRemove(mInstances.MaxIndex())) return false; } while(mInstances.Size() < n) { if(!this->CallCreate()) return false; } return true; } else return false; } bool iClipPlane::CallCreate() { if(mInstances.Size() >= 6) return false; iClipPlaneInstance *a = new iClipPlaneInstance(this->GetViewModule()); if(a != 0) { mInstances.Add(a); mPlanes->AddItem(a); return true; } else return false; } bool iClipPlane::CallRemove(int i) { if(i>=0 && iRemoveItem(mInstances[i]); mInstances[i]->Delete(); mInstances.Remove(i); return true; } else return false; } bool iClipPlane::ShowBody(bool s) { int i; for(i=0; iSetGlassPlaneVisible(s); } return true; } bool iClipPlane::SetPosition(int i, const iVector3D& p) { if(i>=0 && iGetViewModule()); pos.SetBoxValue(p); mInstances[i]->SetPosition(pos); return true; } else return false; } const iVector3D& iClipPlane::GetPosition(int i) const { static const iVector3D none; if(i>=0 && iGetPosition().BoxValue(); } else return none; } bool iClipPlane::SetDirection(int i, const iVector3D& d) { if(i>=0 && iSetDirection(d); return true; } else return false; } const iVector3D& iClipPlane::GetDirection(int i) const { static const iVector3D none; if(i>=0 && iGetDirection(); } else return none; } ifrit-4.1.2/core/iclipplane.h0000674060175406010010000000432212641012516014434 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A vtkPlaneCollection with a glass plane representation // #ifndef ICLIPPLANE_H #define ICLIPPLANE_H #include #include "iviewmoduletool.h" #include "iarray.h" class iClipPlaneInstance; class vtkPlaneCollection; class iClipPlane : public iViewModuleTool { public: vtkTypeMacro(iClipPlane,iViewModuleTool); static iClipPlane* New(iViewModule *vm = 0); iObjectPropertyMacro2V(Position,Vector); iObjectPropertyMacro2V(Direction,Vector); iObjectPropertyMacro2S(Number,Int); iPropertyAction1 Remove; iPropertyAction Create; inline vtkPlaneCollection* GetPlanes() const { return mPlanes; } protected: virtual ~iClipPlane(); private: iClipPlane(iViewModule *vm, const iString &fname, const iString &sname); bool CallCreate(); bool CallRemove(int i); virtual bool ShowBody(bool s); // // Actors displayed by this class // iArray mInstances; vtkPlaneCollection* mPlanes; }; #endif // ICLIPPLANE_H ifrit-4.1.2/core/icolor.cpp0000674060175406010010000000511212641012547014140 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icolor.h" iColor::iColor() { mAlpha = 1; mRed = mGreen = mBlue = 0; } iColor::iColor(const iColor &c) { mRed = c.mRed; mGreen = c.mGreen; mBlue = c.mBlue; mAlpha = c.mAlpha; } iColor::iColor(int r, int g, int b, int a) { mRed = r; mGreen = g; mBlue = b; mAlpha = a; } iColor::iColor(double c[3], double alpha) { if(c == 0) { mRed = mGreen = mBlue = 0; mAlpha = 255; } else { mRed = int(255*c[0]); mGreen = int(255*c[1]); mBlue = int(255*c[2]); mAlpha = int(255*alpha); } } double* iColor::ToVTK() const { mVTK[0] = mRed/255.0; mVTK[1] = mGreen/255.0; mVTK[2] = mBlue/255.0; mVTK[3] = mAlpha/255.0; return mVTK; } iColor iColor::Reverse() const { return iColor(255-mRed,255-mGreen,255-mBlue,mAlpha); } iColor iColor::Shadow() const { int c = (mRed+mGreen+mBlue)/3 > 127 ? 0 : 255; return iColor(c,c,c,mAlpha); } const iColor& iColor::IFrIT() { static const iColor tmp(120,180,240); return tmp; } const iColor& iColor::Black() { static const iColor tmp(0,0,0); return tmp; } const iColor& iColor::White() { static const iColor tmp(255,255,255); return tmp; } const iColor& iColor::Invalid() { static const iColor tmp(999,999,999,999); return tmp; } iColor& iColor::operator=(const iColor &c) { mRed = c.mRed; mGreen = c.mGreen; mBlue = c.mBlue; mAlpha = c.mAlpha; return *this; } ifrit-4.1.2/core/icolor.h0000674060175406010010000000641312641012516013606 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ICOLOR_H #define ICOLOR_H class iColor { public: iColor(); iColor(const iColor &c); iColor(int r, int g, int b, int a = 255); iColor(double c[3], double alpha = 1.0); inline int Red() const { return mRed; } inline int Green() const { return mGreen; } inline int Blue() const { return mBlue; } inline int Alpha() const { return mAlpha; } inline int Intensity() const { return (mRed+mGreen+mBlue)/3; } inline void GetRGB(char rgb[3]) const { rgb[0] = (char)mRed; rgb[1] = (char)mGreen; rgb[2] = (char)mBlue; } inline void GetRGB(unsigned char rgb[3]) const { rgb[0] = (unsigned char)mRed; rgb[1] = (unsigned char)mGreen; rgb[2] = (unsigned char)mBlue; } double* ToVTK() const; iColor Reverse() const; iColor Shadow() const; iColor& operator=(const iColor &c); // impl-shared copy friend bool operator==(const iColor &s1, const iColor &s2); friend bool operator!=(const iColor &s1, const iColor &s2); int operator[](int i) const; int& operator[](int i); bool IsValid() const; // // Some colors // static const iColor& IFrIT(); static const iColor& Black(); static const iColor& White(); static const iColor& Invalid(); private: int mRed, mGreen, mBlue, mAlpha; mutable double mVTK[4]; }; inline bool operator==(const iColor &s1, const iColor &s2) { return (s1.mRed==s2.mRed) && (s1.mGreen==s2.mGreen) && (s1.mBlue==s2.mBlue) && (s1.mAlpha==s2.mAlpha); } inline bool operator!=(const iColor &s1, const iColor &s2) { return (s1.mRed!=s2.mRed) || (s1.mGreen!=s2.mGreen) || (s1.mBlue!=s2.mBlue) || (s1.mAlpha!=s2.mAlpha); } inline bool iColor::IsValid() const { return (mRed>=0 && mRed<256 && mGreen>=0 && mGreen<256 && mBlue>=0 && mBlue<256 && mAlpha>=0 && mAlpha<256); } inline int iColor::operator[](int i) const { switch(i) { case 0: return mRed; case 1: return mGreen; case 2: return mBlue; default: return mAlpha; } } inline int& iColor::operator[](int i) { switch(i) { case 0: return mRed; case 1: return mGreen; case 2: return mBlue; default: return mAlpha; } } #endif // ICOLOR_H ifrit-4.1.2/core/icolorbar.cpp0000674060175406010010000004276712641012547014646 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icolorbar.h" #include "idata.h" #include "idatalimits.h" #include "idatareader.h" #include "ierror.h" #include "igenericprop.h" #include "imath.h" #include "ioverlayhelper.h" #include "ipalette.h" #include "ipalettecollection.h" #include "istretch.h" #include "irendertool.h" #include "itextactor.h" #include "iviewmodule.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace iParameter; // // Templates // #include "iarray.tlh" #include "igenericprop.tlh" #include "iproperty.tlh" // // helper classes // class iColorBarLabel { friend class iColorBarActor; private: iColorBarLabel(int id, iRenderTool *parent) { Base = iTextActor::New(parent); IERROR_CHECK_MEMORY(Base); Power = iTextActor::New(parent); IERROR_CHECK_MEMORY(Power); Base->SetJustification((id==1)?1:-1); Power->SetJustification(-1); } ~iColorBarLabel() { Base->Delete(); Power->Delete(); } iTextActor *Base, *Power; }; class iColorBarActor : public iGenericProp { IPOINTER_AS_USER(OverlayHelper); public: vtkTypeMacro(iColorBarActor,vtkActor2D); static iColorBarActor* New(bool left = false, iColorBar *parent = 0); void SetSideOffset(float v); inline float GetSideOffset() const { return mOffset; } void SetHeight(float v); inline float GetHeight() const { return mHeight*0.86; } // there is a 0.86 factor in vtkScalarBarActor static bool MethodToImage; protected: virtual ~iColorBarActor(); virtual void UpdateGeometry(vtkViewport *vp); private: iColorBarActor(const int id, iColorBar *parent); void UpdatePlacement(bool force); void UpdateMapper2Data(int mag); const int mId; bool mStarted; float mHeight, mOffset, mWidth4Height; float mXOff, mYOff; float mLabelOff, mTitleOff; int mJmax; iColorBar *mParent; vtkActor2D *mBarActor; vtkImageMapper *mBarMapper; vtkPolyDataMapper2D *mBarMapper2; vtkPolyData *mBarMapper2Data; iTextActor *mTitleActor; iArray mLabels; }; bool iColorBarActor::MethodToImage = false; iColorBarActor* iColorBarActor::New(bool left, iColorBar *parent) { IASSERT(parent); return new iColorBarActor(left,parent); } iColorBarActor::iColorBarActor(int id, iColorBar *parent) : iGenericProp(false), mOverlayHelper(parent->GetViewModule()->GetRenderTool()), mId(id) { int i; mParent = parent; mStarted = false; mJmax = 0; mWidth4Height = 0.03/0.7; mHeight = 0.7; mOffset = 0.08; mBarActor = vtkActor2D::New(); IERROR_CHECK_MEMORY(mBarActor); this->AppendComponent(mBarActor); mBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); mBarActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport(); mBarActor->SetWidth(mWidth4Height*mHeight*0.86); // there was a 0.86 factor in vtkScalarBarActor mBarActor->SetHeight(mHeight*0.86); // there was a 0.86 factor in vtkScalarBarActor mBarActor->PickableOff(); mBarActor->GetProperty()->SetDisplayLocationToForeground(); mBarActor->GetProperty()->SetColor(1,1,1); mBarMapper = vtkImageMapper::New(); IERROR_CHECK_MEMORY(mBarMapper); mBarMapper->RenderToRectangleOn(); mBarMapper->SetColorWindow(255.0); mBarMapper->SetColorLevel(127.5); mBarMapper->UseCustomExtentsOff(); mBarMapper2 = vtkPolyDataMapper2D::New(); IERROR_CHECK_MEMORY(mBarMapper2); vtkCoordinate *c = vtkCoordinate::New(); IERROR_CHECK_MEMORY(c); c->SetCoordinateSystemToNormalizedViewport(); mBarMapper2->SetTransformCoordinate(c); c->Delete(); mBarMapper2->SetScalarRange(0.0,1.0); mTitleActor = iTextActor::New(this->GetOverlayHelper()->GetRenderTool()); IERROR_CHECK_MEMORY(mTitleActor); this->AppendComponent(mTitleActor); mTitleActor->SetAngle(90.0); mTitleActor->SetJustification((mId==1)?-1:1,0); mTitleActor->SetBold(true); iColorBarLabel *l; for(i=0; i<10; i++) { l = new iColorBarLabel(mId,this->GetOverlayHelper()->GetRenderTool()); IERROR_CHECK_MEMORY(l); this->AppendComponent(l->Base); this->AppendComponent(l->Power); mLabels.Add(l); } // // Data for type 2 mapper // mBarMapper2Data = vtkPolyData::New(); IERROR_CHECK_MEMORY(mBarMapper2Data); vtkPoints *points = vtkPoints::New(VTK_FLOAT); IERROR_CHECK_MEMORY(points); vtkCellArray *cells = vtkCellArray::New(); IERROR_CHECK_MEMORY(cells); vtkFloatArray *scalars = vtkFloatArray::New(); IERROR_CHECK_MEMORY(scalars); scalars->SetNumberOfComponents(1); // // We now assign the pieces to the vtkPolyData. // mBarMapper2Data->SetPolys(cells); cells->Delete(); mBarMapper2Data->SetPoints(points); points->Delete(); mBarMapper2Data->GetCellData()->SetScalars(scalars); scalars->Delete(); mBarMapper2->SetInputData(mBarMapper2Data); // // Load the point, cell, and data attributes. // int n = 256; double x[3]; vtkIdType verts[4]; scalars->SetNumberOfTuples(n); float *arr = scalars->GetPointer(0); x[2] = 0.0; for(i=0; i<=n; i++) { x[1] = float(i)/n; x[0] = 0.0; points->InsertNextPoint(x); x[0] = 1.0; points->InsertNextPoint(x); if(i > 0) { verts[0] = 2*i - 2; verts[1] = 2*i - 1; verts[2] = 2*i + 1; verts[3] = 2*i + 0; cells->InsertNextCell(4,verts); arr[i-1] = float(i-1)/(n-1); } } this->UpdatePlacement(true); } iColorBarActor::~iColorBarActor() { int i; mBarMapper2Data->Delete(); mBarMapper2->Delete(); mBarMapper->Delete(); mBarActor->Delete(); mTitleActor->Delete(); for(i=0; iGetWidth()-w) > 1.0e-10 || fabs(mBarActor->GetHeight()-h) > 1.0e-10) { if(mId == 1) { mXOff = mOffset; mLabelOff = mXOff - 0.01; mTitleOff = mXOff + mWidth4Height*mHeight; } else { mXOff = 1.0 - mWidth4Height*mHeight - mOffset; mLabelOff = mXOff + mWidth4Height*mHeight; mTitleOff = mXOff - 0.3*mWidth4Height*mHeight; } mYOff = 0.01 + 0.5*(1-mHeight*0.86); // there was a 0.86 factor in vtkScalarBarActor this->UpdateMapper2Data(1); mBarActor->SetPosition(mXOff,mYOff); mBarActor->SetWidth(mWidth4Height*mHeight*0.86); // there was a 0.86 factor in vtkScalarBarActor mBarActor->SetHeight(mHeight*0.86); // there was a 0.86 factor in vtkScalarBarActor mTitleActor->SetPosition(mTitleOff,0.5); this->Modified(); } } void iColorBarActor::UpdateMapper2Data(int mag) { if(MethodToImage) return; double w = mWidth4Height*mHeight*0.86; double h = mHeight*0.86; vtkPoints *p = mBarMapper2Data->GetPoints(); int i, n = p->GetNumberOfPoints(); float x[3]; x[2] = 0; for(i=0; iSetPoint(i,x); x[0] = mag*w; p->SetPoint(i+1,x); } } void iColorBarActor::SetSideOffset(float v) { mOffset = v; this->UpdatePlacement(true); } void iColorBarActor::SetHeight(float v) { mHeight = v/0.86; // there is a 0.86 factor in vtkScalarBarActor this->UpdatePlacement(true); } void iColorBarActor::UpdateGeometry(vtkViewport* viewport) { const iColorBarItem *bar = mParent->GetBar(mId); if(bar==0 || bar->Palette==0) { this->Disable(); return; } iDataLimits *lim = mParent->GetViewModule()->GetReader()->GetLimits(bar->DataTypeId.Type()); if(lim==0 || bar->Var>=lim->GetNumVars()) { this->Disable(); return; } int j; float w1 = 0.0, h1 = 0.0, w2 = 0.0, h2 = 0.0; if(!mStarted) mStarted = true; int mag = this->GetOverlayHelper()->GetRenderingMagnification(); if(mag == 1) { int nstep, pow; float dv, voff, vstep, vbound, v; float s1[2], s2[2]; char s[100]; const char *fmt; float vl = lim->GetStretchedMin(bar->Var); float vu = lim->GetStretchedMax(bar->Var); switch(lim->GetStretchId(bar->Var)) { case iStretch::Log: { // // Log table // int ivl = 1 + (int)floor(vl-0.01); int ivu = 0 + (int)floor(vu+0.01); dv = vu - vl; if(dv<=0.0 || ivl>vu) { this->Disable(); return; } voff = ivl - vl; int ndex = ivu - ivl; if(ndex > 1) nstep = 1 + ndex/mLabels.Size(); else nstep = 1; mJmax = 1 + ndex/nstep; vstep = nstep; for(j=0; jBase->SetText(" 1"); mLabels[j]->Power->SetText(""); } else { mLabels[j]->Base->SetText("10"); mLabels[j]->Power->SetText(s); } mLabels[j]->Base->GetSize(viewport,s1); mLabels[j]->Power->GetSize(viewport,s2); if(w1 < s1[0]) w1 = s1[0]; if(h1 < s1[1]) h1 = s1[1]; if(w2 < s2[0]) w2 = s2[0]; if(h2 < s2[1]) h2 = s2[1]; } break; } default: { // // Lin table // mJmax = 5; voff = 0.0; if(fabs(vl) < 1.0e-3*fabs(vu)) vl = 0.0; if(fabs(vu) < 1.0e-3*fabs(vl)) vu = 0.0; dv = vu - vl; if(fabs(dv) < 1.0e-30*fabs(vu)) // dv is zero { if(vu > 0.0) { vu = vu*1.001; vl = vl*0.999; } else if(vu < 0.0) { vu = vu*0.999; vl = vl*1.001; } else { vu = 1.0; vl = -1.0; } dv = vu - vl; } vstep = dv/(mJmax-1); vbound = (fabs(vl) > fabs(vu)) ? fabs(vl) : fabs(vu); if(fabs(vstep) > 0.03*vbound) { fmt = "%.2g"; } else if(fabs(vstep) > 0.003*vbound) { fmt = "%.3g"; } else { fmt = "%g"; } for(j=0; jBase->SetText(s); mLabels[j]->Power->SetText(""); mLabels[j]->Base->GetSize(viewport,s1); mLabels[j]->Power->GetSize(viewport,s2); if(w1 < s1[0]) w1 = s1[0]; if(h1 < s1[1]) h1 = s1[1]; if(w2 < s2[0]) w2 = s2[0]; if(h2 < s2[1]) h2 = s2[1]; } } } w1 *= 0.8; w2 *= 0.8; h1 *= 0.8; float xpos, ypos; xpos = mLabelOff; for(j=0; j 0.0) { ypos = mYOff + 0.86*mHeight*(voff+vstep*j)/dv; } else { ypos = mYOff + 0.86*mHeight*0.5; } if(mId == 0) { mLabels[j]->Base->SetPosition(xpos,ypos-0.5*h1); mLabels[j]->Power->SetPosition(w1+xpos,ypos+0.5*h1); } else { mLabels[j]->Base->SetPosition(xpos-w2,ypos-0.5*h1); mLabels[j]->Power->SetPosition(xpos-w2,ypos+0.5*h1); } } for(j=mJmax; jBase->SetText(""); mLabels[j]->Power->SetText(""); } mTitleActor->SetText(lim->GetName(bar->Var).ToCharPointer()); if(MethodToImage) { mBarActor->SetMapper(mBarMapper); mBarMapper->SetInputData(iPaletteCollection::Global()->GetImageData(bar->Palette)); } else { mBarActor->SetMapper(mBarMapper2); mBarMapper2->SetLookupTable(iPaletteCollection::Global()->GetLookupTable(bar->Palette)); } this->UpdatePlacement(false); } else { mBarActor->SetWidth(mag*mWidth4Height*mHeight); mBarActor->SetHeight(mag*mHeight); // // Shift positions if under magnification - // int winij[2]; this->GetOverlayHelper()->ComputePositionShiftsUnderMagnification(winij); mBarActor->SetPosition(mag*mXOff-winij[0],mag*mYOff-winij[1]); if(winij[0]==0 && winij[1]==0) this->UpdateMapper2Data(mag); } } // // Main class // iColorBar* iColorBar::New(iViewModule *vm) { static iString LongName("ColorBar"); static iString ShortName("cb"); IASSERT(vm); return new iColorBar(vm,LongName,ShortName); } iColorBar::iColorBar(iViewModule *vm, const iString &fname, const iString &sname) : iViewModuleTool(vm,fname,sname), iObjectConstructPropertyMacroS(Bool,iColorBar,Automatic,a), iObjectConstructPropertyMacroS(Color,iColorBar,Color,c), iObjectConstructPropertyMacroS(Float,iColorBar,SideOffset,so), iObjectConstructPropertyMacroS(Float,iColorBar,Size,s), iObjectConstructPropertyMacroV(Int,iColorBar,Var,v,2), iObjectConstructPropertyMacroV(Int,iColorBar,Palette,p,2), iObjectConstructPropertyMacroV(DataType,iColorBar,DataType,dt,2) { Var.AddFlag(iProperty::_FunctionsAsIndex); mAutomatic = true; // // Create manual bars // mManualQueue[0].Bar.Palette = mManualQueue[1].Bar.Palette = 0; mManualQueue[0].Bar.DataTypeId = 1; mManualQueue[1].Bar.DataTypeId = 1; mManualQueue[0].Count = mManualQueue[1].Count = 1; mActors[0] = iColorBarActor::New(0,this); IERROR_CHECK_MEMORY(mActors[0]); mActors[1] = iColorBarActor::New(1,this); IERROR_CHECK_MEMORY(mActors[1]); this->GetViewModule()->GetRenderTool()->AddObject(mActors[0]); this->GetViewModule()->GetRenderTool()->AddObject(mActors[1]); mColor = iColor::Invalid(); } iColorBar::~iColorBar() { int i; for(i=0; i<2; i++) { this->GetViewModule()->GetRenderTool()->RemoveObject(mActors[i]); mActors[i]->Delete(); } } void iColorBar::SetMethodToImage(bool s) { iColorBarActor::MethodToImage = s; } bool iColorBar::SetMethodToImage() { return iColorBarActor::MethodToImage; } bool iColorBar::ShowBody(bool s) { int i; for(i=0; i<2; i++) mActors[i]->SetVisibility(s?1:0); return true; } bool iColorBar::Add(int priority, const iColorBarItem &bar) { if(bar.Var < 0) return false; iDataLimits *lim = this->GetViewModule()->GetReader()->GetLimits(bar.DataTypeId.Type()); if(lim==0 || bar.Var>=lim->GetNumVars()) return false; Item item; item.Bar = bar; item.Priority = priority; item.Count = 0; int idx = mAutomaticQueue.Find(item); if(idx >= 0) { mAutomaticQueue[idx].Count++; } else { // // Insert a new one keeping the list ordered by priority // item.Count = 1; mAutomaticQueue.Add(item); } int i; for(i=0; i<2; i++) mActors[i]->Modified(); return true; } void iColorBar::Remove(const iColorBarItem &bar) { Item item; item.Bar = bar; item.Priority = 0; item.Count = 0; int idx = mAutomaticQueue.Find(item); if(idx >= 0) { mAutomaticQueue[idx].Count--; if(mAutomaticQueue[idx].Count == 0) // delete the entry { mAutomaticQueue.iArray::Remove(idx); } int i; for(i=0; i<2; i++) mActors[i]->Modified(); } } // // Property slots // bool iColorBar::SetAutomatic(bool s) { mAutomatic = s; int i; for(i=0; i<2; i++) mActors[i]->Modified(); return true; } bool iColorBar::SetColor(const iColor& c) { int i; for(i=0; i<2; i++) { mActors[i]->GetOverlayHelper()->SetFixedColor(c); mActors[i]->GetOverlayHelper()->SetAutoColor(!c.IsValid()); } return true; } bool iColorBar::SetSideOffset(float v) { if(v>=0.01 && v<=0.3) { int i; for(i=0; i<2; i++) mActors[i]->SetSideOffset(v); return true; } else return false; } float iColorBar::GetSideOffset() const { return mActors[1]->GetSideOffset(); } bool iColorBar::SetSize(float v) { if(v>=0.1 && v<=1.0) { if(v > 0.95) v = 0.95; // make sure labels are visible; int i; for(i=0; i<2; i++) mActors[i]->SetHeight(v); return true; } else return false; } float iColorBar::GetSize() const { return mActors[1]->GetHeight(); } bool iColorBar::SetVar(int i, int v) { if(i>=0 && i<2) { mManualQueue[i].Bar.Var = v; return true; } else return false; } int iColorBar::GetVar(int i) const { if(i>=0 && i<2) { return mManualQueue[i].Bar.Var; } else return -1; } bool iColorBar::SetPalette(int i, int v) { if(i>=0 && i<2) { mManualQueue[i].Bar.Palette = v; return true; } else return false; } int iColorBar::GetPalette(int i) const { if(i>=0 && i<2) { return mManualQueue[i].Bar.Palette; } else return -1; } bool iColorBar::SetDataType(int i, const iDataType& v) { if(i>=0 && i<2) { mManualQueue[i].Bar.DataTypeId = v.GetId(); return true; } else return false; } const iDataType& iColorBar::GetDataType(int i) const { if(i>=0 && i<2) { return mManualQueue[i].Bar.DataTypeId.Type(); } else return iDataType::Null(); } const iColorBarItem* iColorBar::GetBar(int id) { if(mAutomatic) { if(mAutomaticQueue.Size() > id) return &(mAutomaticQueue[id].Bar); else return 0; } else { return &(mManualQueue[id].Bar); } } vtkActor2D* iColorBar::GetActor(int id) const { return mActors[id]; } bool iColorBar::Item::operator<(const iColorBar::Item &item) const { return Priority < item.Priority; } bool iColorBar::Item::operator==(const iColorBar::Item &item) const { return (Bar.Var==item.Bar.Var && Bar.DataTypeId==item.Bar.DataTypeId && Bar.Palette==item.Bar.Palette); } ifrit-4.1.2/core/icolorbar.h0000674060175406010010000000550012641012516014267 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ICOLORBAR_H #define ICOLORBAR_H #include "iviewmoduletool.h" #include "iarray.h" #include "icolorbaritem.h" #include "idataid.h" class iColorBarActor; class iColorBarLabel; class iDataType; class iPalette; class vtkActor2D; namespace iParameter { namespace ColorBarPriority { const int Surface = 0; const int Volume = 1; const int CrossSection = 2; const int Field = 3; const int Particles = 4; }; }; class iColorBar: public iViewModuleTool { public: vtkTypeMacro(iColorBar,iViewModuleTool); static iColorBar* New(iViewModule *vm = 0); iObjectPropertyMacro1S(Automatic,Bool); iObjectPropertyMacro1S(Color,Color); iObjectPropertyMacro2S(SideOffset,Float); iObjectPropertyMacro2S(Size,Float); iType::pv_int Var; iType::pv_int Palette; iPropertyVector DataType; iObjectSlotMacro2V(Var,int); iObjectSlotMacro2V(Palette,int); iObjectSlotMacro2V(DataType,const iDataType&); bool Add(int priority, const iColorBarItem &bar); void Remove(const iColorBarItem &bar); const iColorBarItem* GetBar(int id); vtkActor2D* GetActor(int id) const; static void SetMethodToImage(bool s); static bool SetMethodToImage(); protected: virtual ~iColorBar(); virtual bool ShowBody(bool s); private: iColorBar(iViewModule *vm, const iString &fname, const iString &sname); struct Item { iColorBarItem Bar; int Priority; int Count; bool operator<(const Item &item) const; bool operator==(const Item &item) const; }; iOrderedArray mAutomaticQueue; Item mManualQueue[2]; iColorBarActor *mActors[2]; }; #endif // ICOLORBAR_H ifrit-4.1.2/core/icolorbaritem.cpp0000674060175406010010000000251412641012547015507 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icolorbaritem.h" iColorBarItem::iColorBarItem() { Var = 0; Palette = 0; } ifrit-4.1.2/core/icolorbaritem.h0000674060175406010010000000266012641012516015152 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ICOLORBARITEM_H #define ICOLORBARITEM_H #include "idataid.h" struct iColorBarItem { int Var; int Palette; iDataId DataTypeId; iColorBarItem(); }; #endif // ICOLORBARITEM_H ifrit-4.1.2/core/icommondatadistributors.cpp0000674060175406010010000002507412641012547017633 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icommondatadistributors.h" #include "iappendimagedatafilter.h" #include "iappendpolydatafilter.h" #include "ierror.h" #include "iparallelmanager.h" #include "ireplicatedpolydata.h" #include "iviewsubject.h" #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "igenericfilter.tlh" // // Helper class // class iBasicDataDistributorHelper { public: template static bool CollectData(Collector *collector, iArray &localOutputs, vtkDataSet *globalOutput); static vtkDataArray* SplitArray(vtkDataArray *inArray, vtkIdType offset, vtkIdType size); }; template bool iBasicDataDistributorHelper::CollectData(Collector *collector, iArray &localOutputs, vtkDataSet *globalOutput) { IASSERT(collector); // // Append the local data // if(localOutputs.Size() == 1) { globalOutput->ShallowCopy(localOutputs[0]); } else { int i; Type *tmpOutput, *lo; collector->RemoveAllInputs(); for(i=0; iShallowCopy(lo); collector->AddInputData(tmpOutput); tmpOutput->Delete(); } collector->Update(); collector->RemoveAllInputs(); globalOutput->ShallowCopy(collector->OutputData()); } return true; } vtkDataArray* iBasicDataDistributorHelper::SplitArray(vtkDataArray *inArray, vtkIdType offset, vtkIdType size) { if(inArray != 0) { vtkDataArray *outArray = inArray->NewInstance(); IERROR_CHECK_MEMORY(outArray); int nc = inArray->GetNumberOfComponents(); outArray->SetNumberOfComponents(nc); outArray->SetVoidArray(inArray->GetVoidPointer(nc*offset),nc*size,1); return outArray; } else return 0; } // // Abstract field data distributor // iFieldDataDistributor::iFieldDataDistributor(iViewSubjectPipelineDataManager *manager, const iString &type) : iViewSubjectPipelineDataDistributor(manager,type) { mSplitDim = 2; } // // vtkImageData distributor // iImageDataDistributor::iImageDataDistributor(iViewSubjectPipelineDataManager *manager) : iFieldDataDistributor(manager,"vtkImageData") { } bool iImageDataDistributor::DistributeDataBody(vtkDataSet *globalInput, iArray &localInputs) { // // Default implementation: split the data in uniform chunks along the last non-trivial dimensions // vtkImageData *input = vtkImageData::SafeDownCast(globalInput); if(input == 0) return false; int nproc = localInputs.Size(); // // Read input structure and choose the split direction // int i, dims[3], dimsPiece[3]; double org[3], orgPiece[3], spa[3]; input->GetOrigin(org); input->GetSpacing(spa); input->GetDimensions(dims); int mSplitDim = 2; while(mSplitDim>=0 && dims[mSplitDim]<=1) mSplitDim--; if(mSplitDim < 0) { // // Nothing to split // for(i=1; iNewInstance(); IERROR_CHECK_MEMORY(localInputs[i]); } nproc = 1; mSplitDim = 2; } // // Adjust the number of processors // if(dims[mSplitDim]>0 && nproc>dims[mSplitDim]) { for(i=nproc; iNewInstance(); IERROR_CHECK_MEMORY(localInputs[i]); } nproc = dims[mSplitDim]; } if(nproc == 1) { // // Nothing to do for 1 proc // localInputs[0] = globalInput->NewInstance(); IERROR_CHECK_MEMORY(localInputs[0]); localInputs[0]->ShallowCopy(input); return true; } mEdges.Resize(nproc-1); // // Split the data between processors // int kstp, kbeg, kend; kstp = (dims[mSplitDim]+nproc-2)/nproc; // This is point data, hence -2 rather than -1 in kstp for(i=0; i<3; i++) { dimsPiece[i] = dims[i]; orgPiece[i] = org[i]; } vtkIdType dataOffset = 1, dataSize; for(i=0; iNewInstance()); IERROR_CHECK_MEMORY(li); localInputs[i] = li; li->CopyStructure(input); // a better way of setting all parameters li->SetDimensions(dimsPiece); li->SetOrigin(orgPiece); array = iBasicDataDistributorHelper::SplitArray(input->GetPointData()->GetScalars(),dataOffset*kbeg,dataSize); if(array != 0) { li->GetPointData()->SetScalars(array); array->Delete(); } array = iBasicDataDistributorHelper::SplitArray(input->GetPointData()->GetVectors(),dataOffset*kbeg,dataSize); if(array != 0) { li->GetPointData()->SetVectors(array); array->Delete(); } array = iBasicDataDistributorHelper::SplitArray(input->GetPointData()->GetTensors(),dataOffset*kbeg,dataSize); if(array != 0) { li->GetPointData()->SetTensors(array); array->Delete(); } } return true; } // // vtkImageData collector // iImageDataCollector::iImageDataCollector(iViewSubjectPipelineDataManager *manager) : iViewSubjectPipelineDataCollector(manager,"vtkImageData") { mCollector = iAppendImageDataFilter::New(); IERROR_CHECK_MEMORY(mCollector); } iImageDataCollector::~iImageDataCollector() { mCollector->Delete(); } bool iImageDataCollector::CollectDataBody(iArray &localOutputs, vtkDataSet *globalOutput) { mCollector->SetNumberOfThreads(localOutputs.Size()); return iBasicDataDistributorHelper::CollectData(mCollector,localOutputs,globalOutput); } // // vtkPolyData distributor // iPolyDataDistributor::iPolyDataDistributor(iViewSubjectPipelineDataManager *manager) : iViewSubjectPipelineDataDistributor(manager,"vtkPolyData") { } bool iPolyDataDistributor::DistributeDataBody(vtkDataSet *globalInput, iArray &localInputs) { int i; // // Default implementation: split the data in uniform chunks by the particle index. // Only split Vert data, assign Line, Poly, and Strip data to the master thread // vtkPolyData *input = vtkPolyData::SafeDownCast(globalInput); if(input == 0) return false; int nPieces = localInputs.Size(); vtkIdType nParticles = input->GetNumberOfPoints(); if(nPieces > nParticles) nPieces = nParticles; if(nPieces < 1) nPieces = 1; vtkIdType kbeg, kstp = (nParticles+nPieces-1)/nPieces; vtkIdType *inPtr = input->GetVerts()->GetData()->GetPointer(0); if(inPtr == 0) { // // We have no vertices - do not split. // for(i=0; iShallowCopy(input); return true; } vtkCellArray *tmpCells; vtkIdTypeArray *tmpData; vtkPolyData *li; for(i=0; iInitialize(); li->ShallowCopy(input); if(i > 0) { li->SetVerts(0); li->SetLines(0); li->SetPolys(0); li->SetStrips(0); } tmpCells = vtkCellArray::New(); if(tmpCells != 0) { tmpData = vtkIdTypeArray::New(); if(tmpData != 0) { tmpData->SetArray(inPtr+2*kbeg,2*kstp,1); tmpCells->SetCells(kstp,tmpData); li->SetVerts(tmpCells); tmpData->Delete(); } tmpCells->Delete(); } } for(i=nPieces; iOwner()); IERROR_CHECK_MEMORY(mCollector); } iPolyDataCollector::~iPolyDataCollector() { mCollector->Delete(); } bool iPolyDataCollector::CollectDataBody(iArray &localOutputs, vtkDataSet *globalOutput) { if(!iBasicDataDistributorHelper::CollectData(mCollector,localOutputs,globalOutput)) return false; if(mDistributor==0 || !mFixStiches) return true; #ifdef I_DEBUG if(iParallelManager::DebugSwitch == 4) return true; #endif // // Remove edges // int splitDim = mDistributor->GetSplitDimension(); const iArray &innerEdges(mDistributor->GetEdges()); int extDown = 0; int next = 1; if(mManager->Owner()->Owner()->GetDataReplicated() != 0) { int r[6]; mManager->Owner()->Owner()->GetDataReplicated()->GetReplicationFactors(r); extDown = r[2*splitDim]; next += r[2*splitDim+1] + extDown; } int i, j, numEdges = innerEdges.Size(); if(numEdges > 0) { int ntot = numEdges*next; double *allEdges = new double[ntot]; IERROR_CHECK_MEMORY(allEdges); for(j=0; j class iAppendImageDataFilter; class iAppendPolyDataFilter; class vtkImageData; class iFieldDataDistributor : public iViewSubjectPipelineDataDistributor { public: vtkTypeMacro(iFieldDataDistributor,iViewSubjectPipelineDataDistributor); iFieldDataDistributor(iViewSubjectPipelineDataManager *manager, const iString &type); inline int GetSplitDimension() const { return mSplitDim; } inline const iArray& GetEdges() const { return mEdges; } protected: int mSplitDim; iArray mEdges; }; class iImageDataDistributor : public iFieldDataDistributor { public: vtkTypeMacro(iImageDataDistributor,iFieldDataDistributor); iImageDataDistributor(iViewSubjectPipelineDataManager *manager); protected: virtual bool DistributeDataBody(vtkDataSet *globalInput, iArray &localInputs); }; class iImageDataCollector : public iViewSubjectPipelineDataCollector { public: vtkTypeMacro(iImageDataCollector,iViewSubjectPipelineDataCollector); iImageDataCollector(iViewSubjectPipelineDataManager *manager); protected: virtual ~iImageDataCollector(); virtual bool CollectDataBody(iArray &localOutputs, vtkDataSet *globalOutput); iAppendImageDataFilter *mCollector; }; class iPolyDataDistributor : public iViewSubjectPipelineDataDistributor { public: vtkTypeMacro(iPolyDataDistributor,iViewSubjectPipelineDataDistributor); iPolyDataDistributor(iViewSubjectPipelineDataManager *manager); protected: virtual bool DistributeDataBody(vtkDataSet *globalInput, iArray &localInputs); }; class iPolyDataCollector : public iViewSubjectPipelineDataCollector { public: vtkTypeMacro(iPolyDataCollector,iViewSubjectPipelineDataCollector); iPolyDataCollector(iViewSubjectPipelineDataManager *manager, iFieldDataDistributor *distributor = 0); void FixStiches(bool s){ mFixStiches = s; } protected: virtual ~iPolyDataCollector(); virtual bool CollectDataBody(iArray &localOutputs, vtkDataSet *globalOutput); bool mFixStiches; iFieldDataDistributor *mDistributor; iAppendPolyDataFilter *mCollector; }; #endif // ICOMMONDATADISTRIBUTORS_H ifrit-4.1.2/core/icontourfilter.cpp0000775060175406010010000001153112641012547015725 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icontourfilter.h" #include "idataconsumer.h" #include "iviewmodule.h" #include #include #include #include #include #include // // Templates // #include "igenericfilter.tlh" iContourFilter::iContourFilter(iDataConsumer *consumer) : iGenericFilter(consumer,1,true) { mMethod = 0; mCurVar = 0; vtkContourFilter *w0 = vtkContourFilter::New(); IERROR_CHECK_MEMORY(w0); w0->UseScalarTreeOn(); w0->ComputeNormalsOn(); w0->ComputeScalarsOff(); w0->ComputeGradientsOff(); w0->AddObserver(vtkCommand::ProgressEvent,consumer->GetViewModule()->GetRenderEventObserver()); vtkMarchingContourFilter *w1 = vtkMarchingContourFilter::New(); IERROR_CHECK_MEMORY(w1); w1->UseScalarTreeOn(); w1->ComputeNormalsOn(); w1->ComputeScalarsOff(); w1->ComputeGradientsOff(); w1->AddObserver(vtkCommand::ProgressEvent,consumer->GetViewModule()->GetRenderEventObserver()); mWorkers[0] = w0; mWorkers[1] = w1; } iContourFilter::~iContourFilter() { mWorkers[0]->Delete(); mWorkers[1]->Delete(); } void iContourFilter::SetMethod(int n) { if(n>=0 && n<2 && n!=mMethod) { mWorkers[mMethod]->GetOutput()->Initialize(); // erase old data mMethod = n; this->Modified(); } } void iContourFilter::SetCurrentVar(int n) { if(n>=0 && n!=mCurVar) { mCurVar = n; this->Modified(); } } float iContourFilter::GetLevel() const { return iRequiredCast(INFO,mWorkers[0])->GetValue(0); } void iContourFilter::SetLevel(float v) { iRequiredCast(INFO,mWorkers[0])->SetValue(0,v); iRequiredCast(INFO,mWorkers[1])->SetValue(0,v); this->Modified(); } void iContourFilter::ProvideOutput() { vtkImageData *input = this->InputData(); int numComp; if(this->InputData()->GetPointData()==0 || this->InputData()->GetPointData()->GetScalars()==0 || (numComp=this->InputData()->GetPointData()->GetScalars()->GetNumberOfComponents())<1 || mCurVar<0 || mCurVar>=numComp) { this->OutputData()->Initialize(); return; } // // VTK contouring filters always make the isosurface of the first component. We simple shift the data by mCurVar values // so that the current value is always the 0 component. // vtkImageData *shiftedInput = input->NewInstance(); IERROR_CHECK_MEMORY(shiftedInput); shiftedInput->ShallowCopy(input); vtkFloatArray *scalars = iRequiredCast(INFO,input->GetPointData()->GetScalars()); vtkFloatArray *shiftedScalars = vtkFloatArray::New(); IERROR_CHECK_MEMORY(shiftedScalars); shiftedScalars->SetNumberOfComponents(numComp); shiftedScalars->SetArray(scalars->GetPointer(mCurVar),scalars->GetSize(),1); shiftedInput->GetPointData()->SetScalars(shiftedScalars); shiftedScalars->Delete(); mWorkers[mMethod]->SetInputData(shiftedInput); mWorkers[mMethod]->Update(); shiftedInput->Delete(); // // Are there normals? Not all combinations of inputs/filters/VTK versions create those // if(mWorkers[mMethod]->GetOutput()->GetPointData()->GetNormals()==0 || mWorkers[mMethod]->GetOutput()->GetPointData()->GetNormals()->GetNumberOfTuples()==0) { vtkPolyDataNormals *nf = vtkPolyDataNormals::New(); IERROR_CHECK_MEMORY(nf); nf->ConsistencyOn(); nf->ComputePointNormalsOn(); nf->ComputeCellNormalsOff(); nf->SetInputConnection(mWorkers[mMethod]->GetOutputPort()); nf->Update(); mWorkers[mMethod]->GetOutput()->GetPointData()->SetNormals(nf->GetOutput()->GetPointData()->GetNormals()); nf->Delete(); } this->OutputData()->ShallowCopy(mWorkers[mMethod]->GetOutput()); } ifrit-4.1.2/core/icontourfilter.h0000674060175406010010000000365112641012517015371 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ICONTOURFILTER_H #define ICONTOURFILTER_H #include "igenericfilter.h" #include class vtkPolyDataAlgorithm; class iContourFilter : public iGenericFilter { iGenericFilterTypeMacro(iContourFilter,vtkDataSetAlgorithm); public: inline int GetMethod() const { return mCurVar; } void SetMethod(int n); inline int GetCurrentVar() const { return mCurVar; } void SetCurrentVar(int n); float GetLevel() const; void SetLevel(float); protected: virtual ~iContourFilter(); virtual void ProvideOutput(); private: int mCurVar, mMethod; vtkPolyDataAlgorithm *mWorkers[2]; }; #endif // ICONTOURFILTER_H ifrit-4.1.2/core/icoredatasubjects.cpp0000674060175406010010000001120412641012547016346 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icoredatasubjects.h" #include "icorefileloaders.h" #include "idata.h" #include "idatalimits.h" #include "idatareader.h" // // Templates (needed for some compilers) // #include "iarray.tlh" #include "iproperty.tlh" namespace iCoreData { class FieldLimits : public iDataLimits { public: vtkTypeMacro(FieldLimits,iDataLimits); static FieldLimits* New(const iDataSubject *subject = 0, unsigned rank = 0U) { IASSERT(subject); return new FieldLimits(subject,rank); } protected: FieldLimits(const iDataSubject *subject, unsigned rank) : iDataLimits(subject,true) { switch(rank) { case 1U: { this->DeclareVars(1); this->SetName(0,"Vector amplitude"); break; } case 2U: { this->DeclareVars(3); this->SetName(0,"Min eigenvalue"); this->SetName(1,"Med eigenvalue"); this->SetName(2,"Max eigenvalue"); break; } } } }; // // ******************************************************************** // // ScalarDataSubject class // // ******************************************************************** // iDataSubjectDefineTypeMacro(ScalarDataSubject,1,"Scalars","s",0,"core,field,scalars","IFRIT_SCALAR_FIELD_DATA_DIR"); ScalarDataSubject::ScalarDataSubject(ScalarFileLoader *fl) : iDataSubject(fl,ScalarDataSubject::DataType()), iObjectConstructPropertyMacroA2(Int,Float,ScalarDataSubject,Smooth,sm) { Smooth.AddFlag(iProperty::_FunctionsAsIndex); mConcreteLoader = fl; } bool ScalarDataSubject::CallSmooth(int v, float r) { return mConcreteLoader->Smooth(v,r); } const iString ScalarDataSubject::HelpTag() const { return "~_" + this->ShortName(); } // // ******************************************************************** // // VectorDataSubject class // // ******************************************************************** // iDataSubjectDefineTypeMacro(VectorDataSubject,2,"Vectors","v",1,"basic,field,vectors","IFRIT_VECTOR_FIELD_DATA_DIR"); VectorDataSubject::VectorDataSubject(iFileLoader *fl) : iDataSubject(fl,VectorDataSubject::DataType()) { } const iString VectorDataSubject::HelpTag() const { return "~_" + this->ShortName(); } iDataLimits* VectorDataSubject::CreateLimits() const { return FieldLimits::New(this,1U); } // // ******************************************************************** // // TensorDataSubject class // // ******************************************************************** // iDataSubjectDefineTypeMacro(TensorDataSubject,3,"Tensors","t",2,"basic,field,tensors","IFRIT_TENSOR_FIELD_DATA_DIR"); TensorDataSubject::TensorDataSubject(iFileLoader *fl) : iDataSubject(fl,TensorDataSubject::DataType()) { } const iString TensorDataSubject::HelpTag() const { return "~_" + this->ShortName(); } iDataLimits* TensorDataSubject::CreateLimits() const { return FieldLimits::New(this,2U); } // // ******************************************************************** // // ParticleDataSubject class // // ******************************************************************** // iDataSubjectDefineTypeMacro(ParticleDataSubject,4,"Particles","p",0,"core,particles","IFRIT_PARTICLE_SET_DATA_DIR"); ParticleDataSubject::ParticleDataSubject(iParticleFileLoader *fl) : iParticleDataSubject(fl,ParticleDataSubject::DataType()) { } const iString ParticleDataSubject::HelpTag() const { return "~_" + this->ShortName(); } }; ifrit-4.1.2/core/icoredatasubjects.h0000674060175406010010000000711712641012517016020 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // DataSubject(s) for core IFrIT DataType(s) // #ifndef ICOREDATASUBJECTS_H #define ICOREDATASUBJECTS_H #include "iparticledatasubject.h" class iDataReader; namespace iCoreData { class ScalarFileLoader; class ScalarDataSubject : public iDataSubject { friend class ::iDataReader; public: vtkTypeMacro(ScalarDataSubject,iDataSubject); iObjectPropertyMacroA2(Smooth,Int,Float); // // Inherited members // static const iDataType& DataType(); virtual const iDataType& GetDataType() const; // // Data subjects are treated by help differently from other objects // virtual const iString HelpTag() const; private: ScalarDataSubject(ScalarFileLoader *fl); // should not be created except by a Reader ScalarFileLoader *mConcreteLoader; }; class VectorDataSubject : public iDataSubject { friend class ::iDataReader; public: vtkTypeMacro(VectorDataSubject,iDataSubject); // // Inherited members // static const iDataType& DataType(); virtual const iDataType& GetDataType() const; // // Data subjects are treated by help differently from other objects // virtual const iString HelpTag() const; protected: virtual iDataLimits* CreateLimits() const; private: VectorDataSubject(iFileLoader *fl); // should not be created except by a Reader }; class TensorDataSubject : public iDataSubject { friend class ::iDataReader; public: vtkTypeMacro(TensorDataSubject,iDataSubject); // // Inherited members // static const iDataType& DataType(); virtual const iDataType& GetDataType() const; // // Data subjects are treated by help differently from other objects // virtual const iString HelpTag() const; protected: virtual iDataLimits* CreateLimits() const; private: TensorDataSubject(iFileLoader *fl); // should not be created except by a Reader }; class ParticleDataSubject : public iParticleDataSubject { friend class ::iDataReader; public: vtkTypeMacro(ParticleDataSubject,iParticleDataSubject); // // Inherited members // static const iDataType& DataType(); virtual const iDataType& GetDataType() const; // // Data subjects are treated by help differently from other objects // virtual const iString HelpTag() const; private: ParticleDataSubject(iParticleFileLoader *fl); // should not be created except by a Reader }; }; #endif ifrit-4.1.2/core/icorefileloaders.cpp0000674060175406010010000005021312641012550016160 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icorefileloaders.h" #include "iboundingbox.h" #include "idatasubject.h" #include "ifile.h" #include "imath.h" #include "imonitor.h" #include "iparallel.h" #include "iparallelfft.h" #include "iparallelmanager.h" #include "iparallelworker.h" #include "ishell.h" #include "ishelleventobservers.h" #include "iuniformgriddata.h" #include "iviewmodule.h" #include #include #include #include // // Templates (needed for some compilers) // #include "iarray.tlh" #include "ibuffer.tlh" using namespace iParameter; namespace iCoreData { // // Helper class for parallel executions // class ScalarHelper : protected iParallelWorker { public: ScalarHelper(ScalarFileLoader *loader); /*= void OperateOnData1(int nvar, int dims[3], const iString &calculatorExpression, bool doVector, float ps, float dp); =*/ bool OperateOnData2(int nvar, int dims[3], int ivar, float Rsmooth, float ps, float dp); protected: virtual int ExecuteStep(int step, iParallel::ProcessorInfo &p); /*= void ExecuteOperateOnData1(iParallel::ProcessorInfo &p); =*/ void ExecuteOperateOnData2(iParallel::ProcessorInfo &p); void ExecuteOperateOnData3(iParallel::ProcessorInfo &p); ScalarFileLoader *mLoader; iString mCalculatorExpression; int mNumVars, mNumProcs, *mDims, mVar; float *mDnyq, mRsmooth; float mProgStart, mProgStep; bool mDoVector, mOverflow; }; // // Main classes // // ******************************************************************** // // VectorFileLoader class // // ******************************************************************** // VectorFileLoader::VectorFileLoader(iDataReader *r) : iUniformGridFileLoader(r,100,false) { } void VectorFileLoader::AssignBinData(int ncoms, vtkIdType ntot, int com, float *d) { if(ncoms != 3) { IBUG_FATAL("Invalid number of components in VectorFileLoader"); } vtkIdType l; for(l=0; lSetNumberOfComponents(3); array->SetArray(mBuffer,size,1); array->SetName("Vectors"); data->GetPointData()->SetVectors(array); array->Delete(); } // // ******************************************************************** // // TensorFileLoader class // // ******************************************************************** // TensorFileLoader::TensorFileLoader(iDataReader *r) : iUniformGridFileLoader(r,200,false) { } void TensorFileLoader::AssignBinData(int ncoms, vtkIdType ntot, int com, float *d) { if(ncoms != 9) { IBUG_FATAL("Invalid number of components in TensorFileLoader"); } int noff1, noff2; vtkIdType l; switch(com) { case 0: { noff1 = 0; noff2 = -1; break; } case 1: { noff1 = 1; noff2 = 3; break; } case 2: { noff1 = 2; noff2 = 6; break; } case 3: { noff1 = 4; noff2 = -1; break; } case 4: { noff1 = 5; noff2 = 7; break; } case 5: { noff1 = 8; noff2 = -1; break; } default: { noff1 = 0; noff2 = -1; IBUG_WARN("Bug detected."); } } for(l=0; l 0) for(l=0; lSetNumberOfComponents(9); array->SetArray(mBuffer,size,1); array->SetName("Tensors"); data->GetPointData()->SetTensors(array); array->Delete(); } // // ******************************************************************** // // ScalarFileLoader class // // ******************************************************************** // ScalarFileLoader::ScalarFileLoader(iDataReader *r, VectorFileLoader *vs) : iUniformGridFileLoader(r,0,true) { mVectorFileLoader = vs; mCalculatorOutput = 0; // mCalculatorExpression = ""; mHelper2 = new ScalarHelper(this); IERROR_CHECK_MEMORY(mHelper2); } ScalarFileLoader::~ScalarFileLoader() { delete mHelper2; } void ScalarFileLoader::AssignBinData(int ncoms, vtkIdType ntot, int com, float *d) { vtkIdType l; for(l=0; lSetNumberOfComponents(mNumVars); array->SetArray(mBuffer,size,1); array->SetName("Scalars"); data->GetPointData()->SetScalars(array); array->Delete(); } int ScalarFileLoader::GetNumComponents(int nvars) const { return nvars; } void ScalarFileLoader::SetCalculatorOutput(int n) { if(n>=0 && nGetStream(0)->Subject->GetLimits()->GetNumVars()) { mCalculatorOutput = n; } } void ScalarFileLoader::SetCalculatorExpression(const iString &s) { mCalculatorExpression = s; } bool ScalarFileLoader::Smooth(int var, float r) { if(r>=0.0 && var>=0 && varGetStream(0)->Subject->GetLimits()->GetNumVars()) { iMonitor h(this,"Computing",1.0); return mHelper2->OperateOnData2(this->GetStream(0)->Subject->GetLimits()->GetNumVars(),mFileDims,var,r,0.0,1.0); } else return false; } // // ******************************************************************** // // ParticleFileLoader class // // ******************************************************************** // ParticleFileLoader::ParticleFileLoader(iDataReader *r) : iParticleFileLoader(r) { //mHelper2 = new ScalarHelper(this); IERROR_CHECK_MEMORY(mHelper2); } ParticleFileLoader::~ParticleFileLoader() { //delete mHelper2; } void ParticleFileLoader::LoadParticleFileBody(const iString &suffix, const iString &fname) { // // is the suffix valid? // iMonitor h(this); if(suffix.Lower()!="txt" && suffix.Lower()!="bin") { h.PostError("Incorrect file suffix."); return; } bool err, isBin = (suffix.Lower() == "bin"); // // Open the file // iFile F(fname); if(!F.Open(iFile::_Read,isBin?iFile::_Binary:iFile::_Text)) { h.PostError("File "+fname+" does not exist."); return; } // // Read the header // int i, nvar; bool paf; vtkIdType ntot0; float ll[3], ur[3]; iString buffer; if(isBin) { err = !this->ReadBinFileHeader(F,ntot0,ll,ur,paf,nvar); } else { err = !this->ReadTxtFileHeader(F,ntot0,ll,ur,paf,nvar,buffer); } if(ntot0 <= 0) err = true; if(err || h.IsStopped()) { F.Close(); h.PostError("Corrupted header."); return; } // // Compute scale and offset // float offsetF[3], scaleF[3]; double offsetD[3], scaleD[3]; if(paf) { for(i=0; i<3; i++) { offsetF[i] = ll[i]; scaleF[i] = 2.0/(ur[i]-ll[i]); } } else { for(i=0; i<3; i++) { offsetD[i] = ll[i]; scaleD[i] = 2.0/(ur[i]-ll[i]); } } // // Configure streams // this->ConfigureStreams(&ntot0,&nvar,paf); h.SetProgress(0.01); // // Read actual data // if(isBin) { err = !this->ReadBinFileContents(F,paf,scaleF,offsetF,scaleD,offsetD); } else { err = !this->ReadTxtFileContents(F,paf,scaleF,offsetF,scaleD,offsetD,buffer); } if(err || h.IsAborted()) { if(err) h.PostError("Corrupted data."); F.Close(); return; } h.SetProgress(1.0); F.Close(); } bool ParticleFileLoader::ReadBinFileHeader(iFile &F, vtkIdType &ntot0, float *ll, float *ur, bool &paf, int &nvar) { // // Read the header // iMonitor h(this); if(this->DetectFortranFileStructure(F,sizeof(int))) { int ntot1; if(!this->ReadFortranRecord(F,Buffer(ntot1))) return false; ntot0 = ntot1; } else if(this->DetectFortranFileStructure(F,sizeof(vtkIdType))) { vtkIdType ntot1; if(!this->ReadFortranRecord(F,Buffer(ntot1))) return false; ntot0 = ntot1; } else return false; float bounds[6]; if(!this->ReadFortranRecord(F,Buffer(bounds,6))) return false; int i; for(i=0; i<3; i++) { ll[i] = bounds[i]; ur[i] = bounds[3+i]; if(!(ll[i] < ur[i])) { h.PostError("Bounding box is corrupted."); return false; } } // // Auto-detect whether points are float or double // vtkIdType nrec = sizeof(float)*ntot0; int mar = F.SetMarker(); if(!this->SkipFortranRecord(F,nrec)) // X { // // not float - try double // paf = false; nrec = sizeof(double)*ntot0; F.ReturnToMarker(mar); if(!this->SkipFortranRecord(F,nrec)) return false; // X if(!this->SkipFortranRecord(F,nrec)) return false; // Y if(!this->SkipFortranRecord(F,nrec)) return false; // Z } else { if(!this->SkipFortranRecord(F,nrec)) return false; // Y if(!this->SkipFortranRecord(F,nrec)) return false; // Z paf = true; } // // Measure the file size to find out the number of variables // nrec = sizeof(float)*ntot0; for(i=0; i<999 && this->SkipFortranRecord(F,nrec); i++); F.ReturnToMarker(mar,true); nvar = i; return true; } bool ParticleFileLoader::ReadTxtFileHeader(iFile &F, vtkIdType &ntot0, float *ll, float *ur, bool &paf, int &nvar, iString &buffer) { iString s; // // TxT file coordinates are float - do we need to check whether they are long enough to be double? // paf = true; // // First line // if(!F.ReadLine(s)) return false; unsigned long ntotRead; int ret = sscanf(s.ToCharPointer(),"%ld",&ntotRead); if(ret != 1) return false; if(ntotRead <= 0) return false; ntot0 = ntotRead; // // Second line // if(!F.ReadLine(s)) return false; char *axisName[3]; int i; for(i=0; i<3; i++) { axisName[i] = 0; axisName[i] = new char[8192]; if(axisName[i] == 0) break; } if(i < 3 ) { for(i=0; i<3; i++) if(axisName[i] != 0) delete [] axisName[i]; return false; } ret = sscanf(s.ToCharPointer(),"%g %g %g %g %g %g %s %s %s",&ll[0],&ll[1],&ll[2],&ur[0],&ur[1],&ur[2],axisName[0],axisName[1],axisName[2]); if(ret == 9) { this->GetViewModule()->GetBoundingBox()->SetAxesLabels(0,axisName[0]); this->GetViewModule()->GetBoundingBox()->SetAxesLabels(1,axisName[1]); this->GetViewModule()->GetBoundingBox()->SetAxesLabels(2,axisName[2]); } for(i=0; i<3; i++) if(axisName[i] != 0) delete [] axisName[i]; if(ret!=6 && ret!=9) return false; // // Find out the number of variables // if(!F.ReadLine(s)) return false; double xyz[3]; float f[10]; ret = sscanf(s.ToCharPointer(),"%lg %lg %lg %g %g %g %g %g %g %g %g %g %g",&xyz[0],&xyz[1],&xyz[2],&f[0],&f[1],&f[2],&f[3],&f[4],&f[5],&f[6],&f[7],&f[8],&f[9]); if(ret<3 || ret>12) return false; nvar = ret - 3; buffer = s; return true; } bool ParticleFileLoader::ReadBinFileContents(iFile &F, bool paf, float *scaleF, float *offsetF, double *scaleD, double *offsetD) { ParticleStream *s = this->GetStream(0); // // parameters for the Progress Bar // iMonitor h(this); float updateStart, updateDuration = 0.99/(s->NumVariablesInFile+3); // // Read coordinates // int n; bool err = false; for(n=0; !err && n<3; n++) { updateStart = 0.01 + updateDuration*n; if(paf) { err = !this->ReadPositions(F,1,n,updateStart,updateDuration,scaleF+n,offsetF+n); } else { err = !this->ReadPositions(F,1,n,updateStart,updateDuration,scaleD+n,offsetD+n); } } if(err || h.IsAborted()) { if(err) h.PostError("Corrupted data."); return false; } // // Read variables // for(n=0; !err && nNumVariablesInFile; n++) { updateStart = 0.01 + updateDuration*(n+3); err = !this->ReadVariables(F,1,n,updateStart,updateDuration); } if(err || h.IsAborted()) { if(err) h.PostError("Corrupted data."); return false; } return true; } bool ParticleFileLoader::ReadTxtFileContents(iFile &F, bool paf, float *scaleF, float *offsetF, double *scaleD, double *offsetD, iString buffer) { ParticleStream *s = this->GetStream(0); // // Use the buffer // double xyz[3], xyzD[3]; float xyzF[3], f[10]; int i, ret; vtkIdType l; vtkPoints *pts = s->Points(); vtkFloatArray *vars = s->Scalars(); iMonitor h(this); mIterator.Start(); for(l=0; lNumTotal; l++) { if(l > 0) { if(!F.ReadLine(buffer)) { h.PostError("Truncated file."); return false; } } ret = sscanf(buffer.ToCharPointer(),"%lg %lg %lg %g %g %g %g %g %g %g %g %g %g",&xyz[0],&xyz[1],&xyz[2],&f[0],&f[1],&f[2],&f[3],&f[4],&f[5],&f[6],&f[7],&f[8],&f[9]); if(ret < s->NumVariablesInFile+3) { h.PostError("Corrupted data."); return false; } if((100*l)/s->NumTotal < (100*(l+1))/s->NumTotal) { h.SetProgress(0.01+0.99*double(l)/s->NumTotal); if(h.IsAborted()) { return false; } } if(mIterator.IsSelected()) { if(paf) { for(i=0; i<3; i++) xyzF[i] = -1.0 + scaleF[i]*(xyz[i]-offsetF[i]); pts->SetPoint(mIterator.GlobalIndex(),xyzF); } else { for(i=0; i<3; i++) xyzD[i] = -1.0 + scaleD[i]*(xyz[i]-offsetD[i]); pts->SetPoint(mIterator.GlobalIndex(),xyzD); } if(vars != 0) vars->SetTuple(mIterator.GlobalIndex(),f); } } mIterator.Stop(); return true; } // // Helper class // ScalarHelper::ScalarHelper(ScalarFileLoader *loader) : iParallelWorker(loader->GetViewModule()->GetParallelManager()) { mLoader = loader; IASSERT(loader); } /*= void ScalarHelper::OperateOnData1(int nvar, int dims[3], const iString &calculatorExpression, bool doVector, float ps, float dp) { mNumVars = nvar; mDims = dims; mCalculatorExpression = calculatorExpression; mDoVector = doVector; mProgStart = ps; mProgStep = dp; this->ParallelExecute(1); } =*/ bool ScalarHelper::OperateOnData2(int nvar, int dims[3], int var, float Rsmooth, float ps, float dp) { mNumVars = nvar; mDims = dims; mVar = var; mRsmooth = Rsmooth; mProgStart = ps + 0.4*dp; mProgStep = 0.2*dp; iMonitor h(mLoader); iParallelFFT *fft = iParallelFFT::New(this->GetManager()); mDnyq = new float[2*dims[1]*dims[2]]; if(fft!=0 && mDnyq!=0) { h.SetInterval("Computing",0.0,0.4); if(fft->Transform(true,var,nvar,dims[0],dims[1],dims[2],mLoader->GetDataPointer(),mDnyq) != 0) { delete [] mDnyq; h.PostError("Forward FFT failed for unknown reason."); return false; } h.SetInterval(0.4,0.2); this->ParallelExecute(2); h.SetInterval(0.6,0.4); if(fft->Transform(false,var,nvar,dims[0],dims[1],dims[2],mLoader->GetDataPointer(),mDnyq) != 0) { delete [] mDnyq; h.PostError("Inverse FFT failed for unknown reason."); return false; } mLoader->GetData(0)->Modified(); delete [] mDnyq; } else { h.PostError("Unable to allocate temporary work storage."); if(fft != 0) fft->Delete(); return false; } fft->Delete(); return true; } int ScalarHelper::ExecuteStep(int step, iParallel::ProcessorInfo &p) { switch(step) { case 1: { if(mNumProcs != p.NumProcs) return 3; /*= this->ExecuteOperateOnData1(p); =*/ return 0; } case 2: { if(mNumProcs != p.NumProcs) return 3; this->ExecuteOperateOnData2(p); return 0; } default: { #ifndef I_NO_CHECK IBUG_WARN("Internal check failed."); #endif return 2; } } } /*= // // Operate on mesh data // void ScalarHelper::ExecuteOperateOnData1(iParallel::ProcessorInfo &p) { float *arr1 = mFileLoader->GetDataPointer(); float *arr2 = mFileLoader->mVectorFileLoader->GetDataPointer(); if(arr1==0 || (mDoVector && arr2==0)) return; vtkIdType size = (vtkIdType)mDims[0]*mDims[1]*mDims[2]; int nout = mFileLoader->GetCalculatorOutput(); vtkIdType l, kbeg, kend, kstp; iParallel::SplitRange(p,size,kbeg,kend,kstp); float progScale = mProgStep/kstp; // // Create our calculator // iCalculator::Stack stack(0); iCalculator::calc_t calc; iCalculator::ExternalDataVariable var(arr1+kbeg*mNumVars,"Var",mNumVars); iCalculator::ExternalDataVariable vec(arr2==0?arr1:arr2+kbeg*3,"Vec",3); stack.Variables()->Add(&var); if(mDoVector) stack.Variables()->Add(&vec); const iCalculator::Executable *exe = calc.Compile(mCalculatorExpression,&stack); if(exe == 0) return; for(l=kbeg; lIsMaster(p)) this->Observer()->SetProgress(mProgStart+progScale*(l-kbeg)); if(this->Observer()->IsAborted()) return; } if(!calc.Execute(exe)) break; const iCalculator::DataVariable *res = dynamic_cast*>(exe->GetResult()); if(res==0 || res->Data()==0) break; arr1[nout+mNumVars*l] = res->Data()[0]; ++var; ++vec; } } =*/ void ScalarHelper::ExecuteOperateOnData2(iParallel::ProcessorInfo &p) { const float pi = 3.1415926535; vtkIdType size = mDims[2]; vtkIdType kbeg, kend, kstp; iParallel::SplitRange(p,size,kbeg,kend,kstp); // // Format everything // float *arr = mLoader->GetDataPointer(); if(arr == 0) return; arr += mVar; float progScale = mProgStep/kstp; int i, j, k; float wz, wy, wx, fac; vtkIdType l; for(k=kbeg; kGetShell()->GetExecutionEventObserver()->SetProgress(mProgStart+progScale*(k-kbeg)); if(mLoader->GetShell()->GetExecutionEventObserver()->IsAborted()) return; } wz = 2*pi/mDims[2]*k; if(wz > pi) wz -= 2*pi; for(j=0; j pi) wy -= 2*pi; l = mDims[0]*(j+mDims[1]*k); for(i=0; i class iDataReader; class vtkImageData; namespace iCoreData { class ScalarHelper; class VectorFileLoader : public iUniformGridFileLoader { friend class ::iDataReader; friend class ScalarHelper; public: vtkTypeMacro(VectorFileLoader,iUniformGridFileLoader); protected: VectorFileLoader(iDataReader *r); virtual int GetNumComponents(int nvars) const; virtual void AssignBinData(int ncoms, vtkIdType ntot, int com, float *d); virtual void AssignTxtData(int ncoms, vtkIdType ind, float *f); virtual void AttachBuffer(vtkImageData *data); }; class TensorFileLoader : public iUniformGridFileLoader { friend class ::iDataReader; public: vtkTypeMacro(TensorFileLoader,iUniformGridFileLoader); protected: TensorFileLoader(iDataReader *r); virtual int GetNumComponents(int nvars) const; virtual void AssignBinData(int ncoms, vtkIdType ntot, int com, float *d); virtual void AssignTxtData(int ncoms, vtkIdType ind, float *f); virtual void AttachBuffer(vtkImageData *data); }; class ScalarFileLoader : public iUniformGridFileLoader { friend class ::iDataReader; friend class ScalarHelper; public: vtkTypeMacro(ScalarFileLoader,iUniformGridFileLoader); void SetCalculatorExpression(const iString &s); inline const iString& GetCalculatorExpression() const { return mCalculatorExpression; } void SetCalculatorOutput(int n); inline int GetCalculatorOutput() const { return mCalculatorOutput; } bool Smooth(int var, float r); protected: ScalarFileLoader(iDataReader *r, VectorFileLoader *vs); virtual ~ScalarFileLoader(); virtual int GetNumComponents(int nvars) const; virtual void AssignBinData(int ncoms, vtkIdType ntot, int com, float *d); virtual void AssignTxtData(int ncoms, vtkIdType ind, float *f); virtual void AttachBuffer(vtkImageData *data); private: iString mCalculatorExpression; int mCalculatorOutput; VectorFileLoader *mVectorFileLoader; ScalarHelper *mHelper2; }; class ParticleFileLoader : public iParticleFileLoader { friend class ::iDataReader; public: vtkTypeMacro(ParticleFileLoader,iParticleFileLoader); protected: ParticleFileLoader(iDataReader *r); virtual ~ParticleFileLoader(); virtual void LoadParticleFileBody(const iString &suffix, const iString &fname); virtual bool ReadBinFileHeader(iFile &F, vtkIdType &ntot0, float *ll, float *ur, bool &paf, int &nvar); virtual bool ReadTxtFileHeader(iFile &F, vtkIdType &ntot0, float *ll, float *ur, bool &paf, int &nvar, iString &buffer); virtual bool ReadBinFileContents(iFile &F, bool paf, float *scaleF, float *offsetF, double *scaleD, double *offsetD); virtual bool ReadTxtFileContents(iFile &F, bool paf, float *scaleF, float *offsetF, double *scaleD, double *offsetD, iString buffer); private: ScalarHelper *mHelper2; }; }; #endif ifrit-4.1.2/core/icrosssectionpipeline.cpp0000674060175406010010000001301312641012550017257 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icrosssectionpipeline.h" #include "icrosssectionviewsubject.h" #include "ierror.h" #include "iorthopolygonplanefilter.h" #include "iorthoslicer.h" #include "iorthotextureplanefilter.h" #include // // Templates (needed for some compilers) // #include "iarray.tlh" #include "igenericfilter.tlh" #include "iviewsubjectpipeline.tlh" iPipelineKeyDefineMacro(iCrossSectionPipeline,Method); iPipelineKeyDefineMacro(iCrossSectionPipeline,Location); iPipelineKeyDefineMacro(iCrossSectionPipeline,Painting); iPipelineKeyDefineMacro(iCrossSectionPipeline,Direction); iPipelineKeyDefineMacro(iCrossSectionPipeline,SampleRate); iPipelineKeyDefineMacro(iCrossSectionPipeline,InterpolateData); // // Main class // iCrossSectionPipeline::iCrossSectionPipeline(iCrossSectionViewInstance *owner) : iViewSubjectPipeline(owner,1) { mOwner = owner; // // Do VTK stuff // mSlicer = this->CreateFilter(); mPolygonConverter = this->CreateFilter(); mTextureConverter = this->CreateFilter(); mSlicer->SetDir(mOwner->GetDirection()); mSlicer->SetCurrentVar(mOwner->GetPaintVar()); mPolygonConverter->SetInputConnection(mSlicer->GetOutputPort()); mTextureConverter->SetInputConnection(mSlicer->GetOutputPort()); this->UpdateContents(); } iCrossSectionPipeline::~iCrossSectionPipeline() { } void iCrossSectionPipeline::ProvideOutput() { vtkPolyData *output = this->OutputData(); vtkImageData *input = vtkImageData::SafeDownCast(this->InputData()); if(input == 0) { IBUG_ERROR("iCrossSectionPipeline is configured incorrectly."); return; } if(mSlicer->InputData() != input) { mSlicer->SetInputData(input); } switch(mOwner->GetActualMethod()) { case 0: { mPolygonConverter->Update(); output->ShallowCopy(mPolygonConverter->OutputData()); break; } case 1: { // // Need to assign texture offsets first // this->SetTextureOffset(input); mTextureConverter->Update(); output->ShallowCopy(mTextureConverter->OutputData()); break; } default: return; } } void iCrossSectionPipeline::SetTextureOffset(vtkImageData *input) { // // Assign texture offsets // if(mOwner->GetMethod() == 1) { double org[3], globalOrg[3], spa[3]; int dims[3], globalDims[3]; int Uidx, Vidx; int Axis = mOwner->GetDirection(); iOrthoSlicer::GetUV(Axis,Uidx,Vidx); input->GetOrigin(org); input->GetSpacing(spa); input->GetDimensions(dims); dims[Uidx] /= mOwner->GetSampleRate(); dims[Vidx] /= mOwner->GetSampleRate(); vtkImageData *globalInput = vtkImageData::SafeDownCast(mGlobalInput); if(globalInput == 0) { IBUG_WARN("Incompatible global input."); return; } globalInput->GetOrigin(globalOrg); globalInput->GetDimensions(globalDims); globalDims[Uidx] /= mOwner->GetSampleRate(); globalDims[Vidx] /= mOwner->GetSampleRate(); if(dims[Axis] != globalDims[Axis]) { // // Split along Axis // mTextureConverter->SetTexturePiece(mOwner->GetTextureData(),0,0,globalOrg,globalDims); } else { int offx = iMath::Round2Int((org[Uidx]-globalOrg[Uidx])/spa[Uidx]); int offy = iMath::Round2Int((org[Vidx]-globalOrg[Vidx])/spa[Vidx]); mTextureConverter->SetTexturePiece(mOwner->GetTextureData(),offx,offy,globalOrg,globalDims); } } } void iCrossSectionPipeline::UpdateMethod() { switch(mOwner->GetActualMethod()) { case 0: { mPolygonConverter->Modified(); break; } case 1: { mTextureConverter->Modified(); break; } default: return; } this->Modified(); } void iCrossSectionPipeline::UpdateDirection() { mSlicer->SetDir(mOwner->GetDirection()); mSlicer->SetPos(mOwner->GetLocation()); this->Modified(); } void iCrossSectionPipeline::UpdatePainting() { mSlicer->SetCurrentVar(mOwner->GetPaintVar()); this->Modified(); } void iCrossSectionPipeline::UpdateLocation() { mSlicer->SetPos(mOwner->GetLocation()); this->Modified(); } void iCrossSectionPipeline::UpdateInterpolateData() { mPolygonConverter->SetInterpolation(mOwner->GetInterpolateData()); mSlicer->SetInterpolation(mOwner->GetInterpolateData()); this->Modified(); } void iCrossSectionPipeline::UpdateSampleRate() { mSlicer->SetSampleRate(mOwner->GetSampleRate()); this->Modified(); } void iCrossSectionPipeline::UpdateReplicas() { // Not replicatable } ifrit-4.1.2/core/icrosssectionpipeline.h0000674060175406010010000000465612641012517016744 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ICROSSSECTIONPIPELINE_H #define ICROSSSECTIONPIPELINE_H #include "iviewsubjectpipeline.h" class iCrossSectionViewInstance; class iOrthoPolygonPlaneFilter; class iOrthoSlicer; class iOrthoTexturePlaneFilter; class vtkImageData; class iCrossSectionPipeline : public iViewSubjectPipeline { friend class iCrossSectionViewInstance; public: vtkTypeMacro(iCrossSectionPipeline,iViewSubjectPipeline); iPipelineKeyDeclareMacro(iCrossSectionPipeline,Method); iPipelineKeyDeclareMacro(iCrossSectionPipeline,Location); iPipelineKeyDeclareMacro(iCrossSectionPipeline,Painting); iPipelineKeyDeclareMacro(iCrossSectionPipeline,Direction); iPipelineKeyDeclareMacro(iCrossSectionPipeline,SampleRate); iPipelineKeyDeclareMacro(iCrossSectionPipeline,InterpolateData); protected: iCrossSectionPipeline(iCrossSectionViewInstance *owner); virtual ~iCrossSectionPipeline(); virtual void ProvideOutput(); virtual void UpdateReplicas(); void SetTextureOffset(vtkImageData *input); iCrossSectionViewInstance *mOwner; // // VTK stuff // iOrthoSlicer *mSlicer; iOrthoPolygonPlaneFilter *mPolygonConverter; iOrthoTexturePlaneFilter *mTextureConverter; }; #endif // ICROSSSECTIONPIPELINE_H ifrit-4.1.2/core/icrosssectionviewsubject.cpp0000674060175406010010000002546412641012550020021 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icrosssectionviewsubject.h" #include "iactor.h" #include "icamera.h" #include "icolorbar.h" #include "icommondatadistributors.h" #include "icoredatasubjects.h" #include "icrosssectionpipeline.h" #include "idatalimits.h" #include "ierror.h" #include "imaterial.h" #include "ihistogrammaker.h" #include "ilookuptable.h" #include "imarker.h" #include "iorthoslicer.h" #include "ipicker.h" #include "irendertool.h" #include "iuniformgriddata.h" #include "iviewmodule.h" #include "iviewobject.h" #include "iviewsubjectparallelpipeline.h" #include #include #include // // Templates // #include "iarray.tlh" #include "iproperty.tlh" using namespace iParameter; // // iCrossSectionViewSubject class // iCrossSectionViewInstance::iCrossSectionViewInstance(iCrossSectionViewSubject *owner) : iMultiViewInstance(owner,1,1,ColorBarPriority::CrossSection,true), mLocation(owner->GetViewModule()) { mMethod = 1; mDirection = 2; mSampleRate = 1; mInterpolateData = true; mLocation[0] = -1.0; mLocation[1] = -1.0; mLocation[2] = -1.0; mOverTheEdgeFlag = false; // // Do VTK stuff // mTexture = vtkTexture::New(); IERROR_CHECK_MEMORY(mTexture); mTextureData = vtkImageData::New(); IERROR_CHECK_MEMORY(mTextureData); mActors[0]->SetScalarVisibility(true); mActors[0]->ColorByArrayComponent(0,0); mActors[0]->GetProperty()->SetColor(1.0,1.0,1.0); mActors[0]->GetProperty()->SetOpacity(1.0); mTexture->SetLookupTable(mActors[0]->GetLookupTable()); mTexture->SetQualityTo32Bit(); //mTextureData->SetScalarTypeToFloat(); mTexture->SetInputData(mTextureData); } iCrossSectionViewInstance::~iCrossSectionViewInstance() { mTexture->Delete(); mTextureData->Delete(); } void iCrossSectionViewInstance::ConfigureBody() { // // Create pipeline (must be created after the object is fully created) // this->AddMainPipeline(1); mActors[0]->SetInputConnection(this->Pipeline()->GetOutputPort(0)); } void iCrossSectionViewInstance::FinishInitialization() { this->SetMethod(mMethod); this->SetInterpolateData(mInterpolateData); } bool iCrossSectionViewInstance::SetMethod(int m) { switch(m) { case 0: { mActors[0]->SetTexture(0); break; } case 1: { mActors[0]->SetTexture(mTexture); this->UpdateTextureSize(); break; } default: return false; } mMethod = m; this->Pipeline()->UpdateContents(iCrossSectionPipeline::KeyMethod); return true; } int iCrossSectionViewInstance::GetActualMethod() const { if(iRequiredCast(INFO,this->Owner())->mForcePolygonalMethod) return 0; else return mMethod; } bool iCrossSectionViewInstance::SetDirection(int d) { if(d>=0 && d<=2) { mDirection = d; this->Pipeline()->UpdateContents(iCrossSectionPipeline::KeyDirection); if(mMethod == 1) this->UpdateTextureSize(); this->Owner()->UpdateAutomaticShading(); return true; } else return false; } void iCrossSectionViewInstance::UpdatePainting() { this->iMultiViewInstance::UpdatePainting(); this->Pipeline()->UpdateContents(iCrossSectionPipeline::KeyPainting); } bool iCrossSectionViewInstance::SetBoxLocation(double p) { mLocation.SetBoxValue(mDirection,p); this->UpdateLocation(); return true; } double iCrossSectionViewInstance::GetBoxLocation() const { return mLocation.BoxValue(mDirection); } bool iCrossSectionViewInstance::SetInterpolateData(bool s) { mInterpolateData = s; if(mInterpolateData) { mTexture->InterpolateOn(); mActors[0]->GetProperty()->SetInterpolationToGouraud(); } else { mTexture->InterpolateOff(); mActors[0]->GetProperty()->SetInterpolationToFlat(); } this->Pipeline()->UpdateContents(iCrossSectionPipeline::KeyInterpolateData); return true; } bool iCrossSectionViewInstance::SetSampleRate(int p) { mSampleRate = p; this->Pipeline()->UpdateContents(iCrossSectionPipeline::KeySampleRate); return true; } void iCrossSectionViewInstance::SetLocation(const iCoordinate &p) { this->SetLocation(p.OpenGLValue()); } void iCrossSectionViewInstance::SetLocation(double p) { mLocation[mDirection] = p; this->UpdateLocation(); } void iCrossSectionViewInstance::UpdateLocation() { double minPos, maxPos; if(this->GetSubject()->GetData() != 0) { double bounds[6]; this->GetSubject()->GetData()->GetBounds(bounds); minPos = bounds[2*mDirection+0]; maxPos = bounds[2*mDirection+1]; } else { minPos = -1.0; maxPos = 1.0; } if(mLocation[mDirection] > maxPos) { mLocation[mDirection] = maxPos; mOverTheEdgeFlag = true; } else if(mLocation[mDirection] < minPos) { mLocation[mDirection] = minPos; mOverTheEdgeFlag = true; } else { mOverTheEdgeFlag = false; } this->Pipeline()->UpdateContents(iCrossSectionPipeline::KeyLocation); } void iCrossSectionViewInstance::ShowBody(bool show) { if(show) { this->UpdateTextureSize(); mActors[0]->VisibilityOn(); } else { mActors[0]->VisibilityOff(); } } bool iCrossSectionViewInstance::SetToSpecialLocation(int n) { switch(n) { case SpecialLocation::MaxData: case SpecialLocation::MinData: { if(this->IsThereData()) { if(n == SpecialLocation::MinData) { mLocation = this->GetSubject()->GetHistogramMaker()->GetMin(mPaintVar).Position; } else { mLocation = this->GetSubject()->GetHistogramMaker()->GetMax(mPaintVar).Position; } this->UpdateLocation(); this->GetViewModule()->GetRenderTool()->GetCamera()->ShiftTo(mLocation); } return true; } default: { mLocation.SetToSpecialLocation(n); this->UpdateLocation(); this->GetViewModule()->GetRenderTool()->GetCamera()->ShiftTo(mLocation); return true; } } } bool iCrossSectionViewInstance::SyncWithDataBody() { this->Pipeline()->SetInputData(this->GetSubject()->GetData()); if(mMethod == 1) this->UpdateTextureSize(); return true; } bool iCrossSectionViewInstance::CanBeShown() const { return this->IsPainted(); } void iCrossSectionViewInstance::UpdateTextureSize() { int dims[3], dimsOut[3], oldDimsOut[3]; int u, v; iUniformGridData *data = iUniformGridData::SafeDownCast(this->GetSubject()->GetData()); if(data == 0) return; data->GetNumCells(dims); iOrthoSlicer::GetUV(mDirection,u,v); dims[u] /= mSampleRate; dims[v] /= mSampleRate; // // Texture dimensions - make them a power of 2 for OpenGL // int xs = 1; int ys = 1; while(xs < dims[u]) xs = xs << 1; while(ys < dims[v]) ys = ys << 1; // // if the BC are not periodic, expand the texture to allow for padding // if(!this->GetSubject()->IsDirectionPeriodic(u) && xsGetSubject()->IsDirectionPeriodic(v) && ysGetDimensions(oldDimsOut); if(oldDimsOut[0]!=dimsOut[0] || oldDimsOut[1]!=dimsOut[1] || oldDimsOut[2]!=dimsOut[2]) { mTextureData->Initialize(); mTextureData->SetDimensions(dimsOut); #ifdef IVTK_5 mTextureData->SetScalarType(VTK_FLOAT); mTextureData->SetNumberOfScalarComponents(1); mTextureData->AllocateScalars(); #else mTextureData->AllocateScalars(VTK_FLOAT,1); #endif } } float iCrossSectionViewInstance::GetMemorySize() { return this->iDataConsumer::GetMemorySize() + mTextureData->GetActualMemorySize(); } void iCrossSectionViewInstance::RemoveInternalData() { this->iDataConsumer::RemoveInternalData(); mTextureData->Initialize(); } iViewSubjectPipeline* iCrossSectionViewInstance::CreatePipeline(int) { return new iCrossSectionPipeline(this); } void iCrossSectionViewInstance::ConfigureMainPipeline(iViewSubjectPipeline *p, int) { iViewSubjectParallelPipeline *pp = iRequiredCast(INFO,p); iImageDataDistributor *idd = new iImageDataDistributor(pp->GetDataManager()); pp->GetDataManager()->AddDistributor(idd); iPolyDataCollector *pdc = new iPolyDataCollector(pp->GetDataManager(),idd); pdc->FixStiches(false); // cannot fix stiches in flat mode pp->GetDataManager()->AddCollector(pdc); } // // Main class // bool iCrossSectionViewSubject::mForcePolygonalMethod = false; iCrossSectionViewSubject::iCrossSectionViewSubject(iViewObject *parent, const iDataType &type) : iMultiViewSubject(parent,parent->LongName(),parent->ShortName(),parent->GetViewModule(),type,ViewObject::Flag::HasNoColor|ViewObject::Flag::HasNoOpacity|ViewObject::Flag::IsNonReplicating,1), iViewSubjectPropertyConstructMacro(Int,iCrossSectionViewInstance,Method,m), iViewSubjectPropertyConstructMacro(Int,iCrossSectionViewInstance,Direction,d), iViewSubjectPropertyConstructMacro(Int,iCrossSectionViewInstance,SampleRate,sr), iViewSubjectPropertyConstructMacro(Bool,iCrossSectionViewInstance,InterpolateData,id), iViewSubjectPropertyConstructMacroGeneric(Double,iCrossSectionViewInstance,Location,l,SetBoxLocation,GetBoxLocation) { } iCrossSectionViewSubject::~iCrossSectionViewSubject() { } iCrossSectionViewInstance* iCrossSectionViewSubject::GetInstance(int i) const { if(i>=0 && i(INFO,mInstances[i]); } else return 0; } void iCrossSectionViewSubject::ForcePolygonalMethod(bool s) { mForcePolygonalMethod = s; } void iCrossSectionViewSubject::UpdateAutomaticShadingBody() { int i; for(i=0; i(INFO,mInstances[i]); int var = ins->GetPaintVar(); int dir = ins->GetDirection(); int j; for(j=i+1; j(INFO,mInstances[j]); if(ins->GetPaintVar()==var && ins->GetDirection()!=dir) { this->GetMaterial()->SetShading(true); return; } } } this->GetMaterial()->SetShading(false); } ifrit-4.1.2/core/icrosssectionviewsubject.h0000674060175406010010000000721512641012517017463 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Header file for iCrossSectionViewSubject class // #ifndef ICROSSSECTIONVIEWSUBJECT_H #define ICROSSSECTIONVIEWSUBJECT_H #include "imultiviewsubject.h" class iCrossSectionViewSubject; class iViewObject; class vtkImageData; class vtkTexture; namespace iParameter { namespace SpecialLocation { const int MaxData = -4; const int MinData = -3; }; }; class iCrossSectionViewInstance : public iMultiViewInstance { friend class iCrossSectionViewSubject; public: iDataConsumerTypeMacro(iCrossSectionViewInstance,iMultiViewInstance); iObjectSlotMacro1SV(Method,int); iObjectSlotMacro1SV(Direction,int); iObjectSlotMacro1SV(SampleRate,int); iObjectSlotMacro1SV(InterpolateData,bool); virtual bool SetBoxLocation(double p); double GetBoxLocation() const; void SetLocation(double p); void SetLocation(const iCoordinate &p); inline double GetLocation() const { return mLocation[mDirection]; } bool SetToSpecialLocation(int n); inline vtkImageData* GetTextureData() const { return mTextureData; } inline bool GetOverTheEdgeFlag() const { return mOverTheEdgeFlag; } int GetActualMethod() const; virtual float GetMemorySize(); virtual void RemoveInternalData(); protected: iCrossSectionViewInstance(iCrossSectionViewSubject *owner); virtual ~iCrossSectionViewInstance(); virtual void ConfigureBody(); virtual void FinishInitialization(); virtual void ConfigureMainPipeline(iViewSubjectPipeline *p, int id); virtual void ShowBody(bool s); virtual bool CanBeShown() const; virtual void UpdatePainting(); virtual iViewSubjectPipeline* CreatePipeline(int id); void UpdateLocation(); void UpdateTextureSize(); bool mOverTheEdgeFlag; iPosition mLocation; // // VTK stuff // vtkTexture *mTexture; vtkImageData *mTextureData; }; class iCrossSectionViewSubject : public iMultiViewSubject { friend class iCrossSectionViewInstance; public: iViewSubjectTypeMacro(iCrossSectionView,iMultiViewSubject); iType::vsp_int Method; iType::vsp_int Direction; iType::vsp_int SampleRate; iType::vsp_bool InterpolateData; iType::vsp_double Location; iCrossSectionViewInstance* GetInstance(int i = 0) const; static void ForcePolygonalMethod(bool s); protected: iCrossSectionViewSubject(iViewObject *parent, const iDataType &type); virtual ~iCrossSectionViewSubject(); virtual void UpdateAutomaticShadingBody(); static bool mForcePolygonalMethod; }; #endif // ICROSSSECTIONVIEWSUBJECT_H ifrit-4.1.2/core/icubeaxesactor.cpp0000674060175406010010000001033012641012550015642 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "icubeaxesactor.h" #include "iaxis.h" #include "ierror.h" #include "ioverlayhelper.h" #include "irendertool.h" #include "iviewmodule.h" #include #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "igenericprop.tlh" iCubeAxesActor* iCubeAxesActor::New(iRenderTool *rt) { IASSERT(rt); return new iCubeAxesActor(rt); } iCubeAxesActor::iCubeAxesActor(iRenderTool *rt) : iGenericProp(true), mOverlayHelper(rt) { // // Replace axes // this->XAxis->Delete(); this->YAxis->Delete(); this->ZAxis->Delete(); this->XAxis = iAxis::New(rt); this->XAxis->GetPositionCoordinate()->SetCoordinateSystemToDisplay(); this->XAxis->GetPosition2Coordinate()->SetCoordinateSystemToDisplay(); this->XAxis->AdjustLabelsOff(); this->YAxis = iAxis::New(rt); this->YAxis->GetPositionCoordinate()->SetCoordinateSystemToDisplay(); this->YAxis->GetPosition2Coordinate()->SetCoordinateSystemToDisplay(); this->YAxis->AdjustLabelsOff(); this->ZAxis = iAxis::New(rt); this->ZAxis->GetPositionCoordinate()->SetCoordinateSystemToDisplay(); this->ZAxis->GetPosition2Coordinate()->SetCoordinateSystemToDisplay(); this->ZAxis->AdjustLabelsOff(); this->XAxis->SetLabelTextProperty(this->AxisLabelTextProperty); this->YAxis->SetLabelTextProperty(this->AxisLabelTextProperty); this->ZAxis->SetLabelTextProperty(this->AxisLabelTextProperty); this->XAxis->SetTitleTextProperty(this->AxisTitleTextProperty); this->YAxis->SetTitleTextProperty(this->AxisTitleTextProperty); this->ZAxis->SetTitleTextProperty(this->AxisTitleTextProperty); this->SetFlyModeToOuterEdges(); this->SetLabelFormat("%6.2g"); this->ScalingOff(); float b = 1.0; this->SetBounds(-b,b,-b,b,-b,b); this->SetNumberOfLabels(5); this->UseRangesOn(); this->GetProperty()->SetColor(0.0,0.0,0.0); } iCubeAxesActor::~iCubeAxesActor() { } void iCubeAxesActor::UpdateGeometry(vtkViewport *) { // // Do nothing here, we work entirely by replacing axes // } int iCubeAxesActor::RenderOpaqueGeometry(vtkViewport *vp) { int mag = mOverlayHelper->GetRenderingMagnification(); if(strcmp(this->GetXLabel(),"X")==0 && strcmp(this->GetYLabel(),"Y")==0 && strcmp(this->GetZLabel(),"Z")==0) { if(mOverlayHelper->GetRenderTool()->GetViewModule()->InOpenGLCoordinates()) { this->SetRanges(-1.0,1.0,-1.0,1.0,-1.0,1.0); } else { float bs = mOverlayHelper->GetRenderTool()->GetViewModule()->GetBoxSize(); this->SetRanges(0.0,bs,0.0,bs,0.0,bs); } } if(mag == 1) { return this->vtkCubeAxesActor2D::RenderOpaqueGeometry(vp); } else { // // Block rebuilding when working under magnification // int ret = 0; if(this->XAxisVisibility != 0) ret += this->XAxis->RenderOpaqueGeometry(vp); if(this->YAxisVisibility != 0) ret += this->YAxis->RenderOpaqueGeometry(vp); if(this->ZAxisVisibility != 0) ret += this->ZAxis->RenderOpaqueGeometry(vp); return ret; } } ifrit-4.1.2/core/icubeaxesactor.h0000674060175406010010000000355112641012517015321 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ICUBEAXESACTOR_H #define ICUBEAXESACTOR_H #include "igenericprop.h" #include #include "ipointermacro.h" class iOverlayHelper; class iRenderTool; class vtkViewport; class iCubeAxesActor: public iGenericProp { IPOINTER_AS_USER(OverlayHelper); public: vtkTypeMacro(iCubeAxesActor,vtkCubeAxesActor2D); static iCubeAxesActor* New(iRenderTool *rt = 0); virtual int RenderOpaqueGeometry(vtkViewport *vp); protected: virtual ~iCubeAxesActor(); virtual void UpdateGeometry(vtkViewport *vp); private: iCubeAxesActor(iRenderTool *rv); }; #endif // ICUBEAXESACTOR_H ifrit-4.1.2/core/idata.cpp0000674060175406010010000001305312641012550013730 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "idata.h" #include "idirectory.h" #include "ishell.h" #include // // Templates // #include "iarray.tlh" using namespace iParameter; namespace iData_Private { iDataInfo& AllData() { static iDataInfo tmp; return tmp; } iLookupArray& Keywords() { static iLookupArray array; return array; } }; using namespace iData_Private; // // DataType class // iDataType::iDataType(int id, const iString& tname, const iString& sname, int rank, const iString &keywords, const iString &env) : mId(id), mTextName(tname), mRank(rank), mKeywords(keywords) { int i, n; mLongName = tname.Substitute(" ",""); mShortName = sname; for(i=0; iGetId()==AllData().Type(i).GetId() || mLongName==AllData().Type(i).LongName() || mShortName==AllData().Type(i).ShortName()) { IBUG_FATAL("Incorrectly configured DataType object."); } } // // Analyse keywords // if(!mKeywords.IsEmpty()) { n = mKeywords.Contains(","); for(i=0; i<=n; i++) { const iString &kw(mKeywords.Section(",",i,i)); if(Keywords().Find(kw) == -1) Keywords().Add(kw); } } AllData() += *this; if(!env.IsEmpty()) { char *e = getenv(env.ToCharPointer()); if(e!=0 && *e!=0) { mEnv = iString(e); if(!mEnv.EndsWith(iDirectory::Separator())) mEnv += iDirectory::Separator(); iDirectory::ExpandFileName(mEnv); } } } iDataType::~iDataType() { AllData() -= *this; } bool iDataType::MatchesKeyword(const iString &str) const { return (mKeywords.Find(str) != -1); } void iDataType::FindTypesByKeywords(iDataInfo &info, const iString &str) { int i, j, n = str.Contains(","); iString d; info.Clear(); for(i=0; i<=n; i++) { d = str.Section(",",i,i); #ifndef I_NO_CHECK if(Keywords().Find(d) == -1) { IBUG_WARN(d+" is not a valid keyword"); continue; } #endif for(j=0; jGetEnvironment(Environment::Data); } else { return mEnv + iDirectory::Separator(); } } else return null; } // // DataInfo class // iDataInfo::iDataInfo() { } iDataInfo::iDataInfo(const iDataInfo &set) { int i; for(i=0; i &arr(info.mArr); // cache for speed for(i=0; iIsNull()) mArr.AddUnique(arr[i]); return *this; } iDataInfo& iDataInfo::operator+=(const iDataType &type) { if(!type.IsNull()) mArr.AddUnique(&type); return *this; } iDataInfo& iDataInfo::operator-=(const iDataType &type) { if(!type.IsNull()) mArr.Remove(&type); return *this; } bool iDataInfo::Includes(const iDataType &type) const { return mArr.Find(&type) >= 0; } int iDataInfo::Index(const iDataType &type) const { int i; for(i=0; i=0 && i { public: iDataTypePointer(const iDataType *ptr = 0) : iPointer::Ordered(ptr){} }; class iDataInfo { public: static const iDataInfo& None(); static const iDataInfo& Any(); iDataInfo(); iDataInfo(const iDataInfo &info); iDataInfo(const iDataType &type); ~iDataInfo(); void Clear(); inline int Size() const { return mArr.Size(); } const iDataType& Type(int i) const; int Index(const iDataType &type) const; iDataInfo& operator=(const iDataInfo &info); iDataInfo& operator=(const iDataType &type); iDataInfo& operator+=(const iDataInfo &info); iDataInfo& operator+=(const iDataType &type); iDataInfo& operator-=(const iDataType &type); bool Includes(const iDataType &type) const; private: iOrderedArray mArr; }; inline bool iDataType::operator==(const iDataType &type) const { return mId == type.mId; } inline bool iDataType::operator!=(const iDataType &type) const { return mId != type.mId; } inline const iDataInfo operator+(const iDataInfo &info, const iDataType &type) { iDataInfo tmp(info); tmp += type; return tmp; } inline const iDataInfo operator+(const iDataInfo &info1, const iDataInfo &info2) { iDataInfo tmp(info1); tmp += info2; return tmp; } inline const iDataInfo operator-(const iDataInfo &info, const iDataType &type) { iDataInfo tmp(info); tmp -= type; return tmp; } #endif // IDATA_H ifrit-4.1.2/core/idataconsumer.cpp0000674060175406010010000001170112641012550015502 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "idataconsumer.h" #include "idata.h" #include "idatahandler.h" #include "idatalimits.h" #include "idatareader.h" #include "idatasubject.h" #include "ierror.h" #include "iviewmodule.h" // // Templates // #include "iarray.tlh" using namespace iParameter; int iDataConsumer::mModeGlobal = DataConsumerOptimizationMode::OptimizeForSpeed; // // Base class for all objects that use data // iDataConsumer::iDataConsumer(iViewModule *vm, const iDataType &type) : iViewModuleComponent(vm), mDataType(type), mPrimaryDataInfo(new iDataInfo(type)) { IASSERT(vm); IERROR_CHECK_MEMORY(mPrimaryDataInfo); mSecondaryDataInfo = new iDataInfo; IERROR_CHECK_MEMORY(mSecondaryDataInfo); mModeLocal = mModeGlobal; mOverrideGlobal = false; } iDataConsumer::~iDataConsumer() { delete mPrimaryDataInfo; delete mSecondaryDataInfo; // // Check that all DataHandlers have been deleted too. // Fails for VTK 5.0.0 - Garbage collection is more convoluted. // if(mDataHandlers.Size() > 0) { int i; for(i=0; imConsumer = 0; } } void iDataConsumer::AddSecondaryDataType(const iDataType &type) { *mSecondaryDataInfo += type; } float iDataConsumer::GetMemorySize() { int i; float s = 0.0; for(i=0; iGetMemorySize(); return s; } void iDataConsumer::RemoveInternalData() { int i; for(i=0; iRemoveInternalData(); } void iDataConsumer::SetGlobalOptimizationMode(int mode) { if(DataConsumerOptimizationMode::IsValid(mode)) { mModeGlobal = mode; } } void iDataConsumer::SetOptimizationMode(int mode) { // // Reset the global mode; // if(DataConsumerOptimizationMode::IsValid(mode)) { mModeLocal = mode; mOverrideGlobal = true; } else if(mode==DataConsumerOptimizationMode::ResetToGlobal) { mModeLocal = mModeGlobal; mOverrideGlobal = false; } } int iDataConsumer::GetOptimizationMode() const { if(mOverrideGlobal) return mModeLocal; else return mModeGlobal; } // // DataHandler registry functionality // void iDataConsumer::RegisterDataHandler(iDataHandler *c) { mDataHandlers.AddUnique(c); } void iDataConsumer::UnRegisterDataHandler(iDataHandler *c) { mDataHandlers.Remove(c); } bool iDataConsumer::IsUsingData(const iDataType &type, bool onlyprimary) const { if(mDataType == type) return true; return (!onlyprimary && mSecondaryDataInfo->Includes(type)); } iDataSubject* iDataConsumer::GetSubject() const { iDataSubject *subject = this->GetViewModule()->GetReader()->GetSubject(mDataType); IASSERT(subject); return subject; } iDataLimits* iDataConsumer::GetLimits() const { return this->GetSubject()->GetLimits(); } bool iDataConsumer::IsThereData() const { return this->GetSubject()->IsThereData(); } bool iDataConsumer::SyncWithLimits(int var, int mode) { int i; if(!this->SyncWithLimitsBody(var,mode)) return false; for(i=0; iSyncWithLimits(var,mode)) return false; } return true; } bool iDataConsumer::SyncWithLimitsBody(int var, int mode) { return true; } // // iSynchRequest class and its specializations // iSyncRequest::iSyncRequest(const iDataType& type) : mDataType(type) { } iSyncRequest::~iSyncRequest() { } iSyncWithDataRequest::iSyncWithDataRequest(const iDataType& type) : iSyncRequest(type) { } void iSyncWithDataRequest::Sync(iDataConsumer *consumer) const { IASSERT(consumer); consumer->SyncWithData(); } iSyncWithLimitsRequest::iSyncWithLimitsRequest(int var, int mode, const iDataType& type) : iSyncRequest(type), Var(var), Mode(mode) { } void iSyncWithLimitsRequest::Sync(iDataConsumer *consumer) const { IASSERT(consumer); consumer->SyncWithLimits(Var,Mode); } ifrit-4.1.2/core/idataconsumer.h0000674060175406010010000001214312641012520015145 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Single-type data consumer // #ifndef IDATACONSUMER_H #define IDATACONSUMER_H #include "iviewmodulecomponent.h" #include "iarray.h" #include "istring.h" class iDataConsumer; class iDataHandler; class iDataInfo; class iDataLimits; class iDataSubject; class iDataType; class iViewModule; class vtkDataSet; namespace iParameter { namespace DataConsumerOptimizationMode { // // DataConsumer parameters // const int ResetToGlobal = -1; const int OptimizeForSpeed = 0; const int OptimizeForMemory = 1; const int OptimizeForQuality = 2; inline bool IsValid(int m){ return m>=0 && m<=2; } }; }; // // Helper class for providing synchronization requests // class iSyncRequest { public: virtual ~iSyncRequest(); inline const iDataType& DataType() const { return mDataType; } virtual void Sync(iDataConsumer *consumer) const = 0; protected: iSyncRequest(const iDataType& type); private: const iDataType &mDataType; }; class iSyncWithDataRequest : public iSyncRequest { public: iSyncWithDataRequest(const iDataType& type); virtual void Sync(iDataConsumer *consumer) const; }; class iSyncWithLimitsRequest : public iSyncRequest { public: iSyncWithLimitsRequest(int var, int mode, const iDataType& type); virtual void Sync(iDataConsumer *consumer) const; private: const int Var, Mode; }; class iDataConsumer : public iViewModuleComponent { friend class iDataHandler; friend class iSyncWithDataRequest; friend class iSyncWithLimitsRequest; //friend class iViewModule; public: static void SetGlobalOptimizationMode(int mode); static int GetGlobalOptimizationMode(){ return mModeGlobal; } void SetOptimizationMode(int mode); int GetOptimizationMode() const; inline bool IsOptimizedForSpeed() const { return this->GetOptimizationMode() == iParameter::DataConsumerOptimizationMode::OptimizeForSpeed; } inline bool IsOptimizedForMemory() const { return this->GetOptimizationMode() == iParameter::DataConsumerOptimizationMode::OptimizeForMemory; } inline bool IsOptimizedForQuality() const { return this->GetOptimizationMode() == iParameter::DataConsumerOptimizationMode::OptimizeForQuality; } virtual float GetMemorySize(); virtual void RemoveInternalData(); inline const iDataType& GetDataType() const { return mDataType; } virtual bool IsThereData() const; void AddSecondaryDataType(const iDataType &type); inline const iDataInfo& GetPrimaryDataInfo() const { return *mPrimaryDataInfo; } inline const iDataInfo& GetSecondaryDataInfo() const { return *mSecondaryDataInfo; } iDataLimits* GetLimits() const; iDataSubject* GetSubject() const; virtual bool IsUsingData(const iDataType &type, bool onlyprimary) const; bool SyncWithLimits(int var, int mode); protected: iDataConsumer(iViewModule *vm, const iDataType &type); virtual ~iDataConsumer(); void RegisterDataHandler(iDataHandler *c); void UnRegisterDataHandler(iDataHandler *c); virtual bool SyncWithLimitsBody(int var, int mode); // by default do nothing virtual bool SyncWithData() = 0; private: static int mModeGlobal; int mModeLocal; bool mOverrideGlobal; iLookupArray mDataHandlers; const iDataType& mDataType; iDataInfo *mPrimaryDataInfo, *mSecondaryDataInfo; }; #define iDataConsumerTypeMacro(_type_,_parent_) \ protected: \ virtual bool SyncWithDataBody(); \ virtual bool SyncWithData() \ { \ if(!this->_type_::SyncWithDataBody()) return false; \ return this->_parent_::SyncWithData(); \ } \ vtkTypeMacro(_type_,_parent_) #define iDataConsumerTypeMacroPass(_type_,_parent_) \ protected: \ virtual bool SyncWithData() \ { \ return this->_parent_::SyncWithData(); \ } \ vtkTypeMacro(_type_,_parent_) #define iDataConsumerTypeMacroBase(_type_,_parent_) \ protected: \ virtual bool SyncWithDataBody(); \ virtual bool SyncWithData() \ { \ return this->_type_::SyncWithDataBody(); \ } \ vtkTypeMacro(_type_,_parent_) #endif // IDATACONSUMER_H ifrit-4.1.2/core/idataformatter.cpp0000674060175406010010000001431112641012550015652 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "idataformatter.h" #include "idatalimits.h" #include // // Templates // #include "iarray.tlh" iDataFormatter* iDataFormatter::New(iViewModule *vm) { IASSERT(vm); return new iDataFormatter(vm); } iDataFormatter::iDataFormatter(iViewModule *vm) : iViewModuleComponent(vm) { mFormatHelper = " "; } iDataFormatter::~iDataFormatter() { } void iDataFormatter::AddOneLine(const iString &name, const iString &data, const iString &unit) { mVarNameLines.Add(name); mVarDataLines.Add(data); mVarUnitLines.Add(unit); } void iDataFormatter::GetReport(int i, iString& varName, iString &varData, iString &varUnit) const { if(i>=0 && iGetRank(i)==0) { s2 = iString::FromNumber(v[i],"%.3e"); if(maxLen < s2.Length()) maxLen = s2.Length(); } while(mFormatHelper.Length() < maxLen) mFormatHelper += " "; for(i=0; iGetRank(i)==0) { vlog = float(iMath::Log10(1.0e-30+fabs(v[i]))); s2 = iString::FromNumber(v[i],"%.3e"); if(s2.Length() < maxLen) s2 += mFormatHelper.Part(0,maxLen-s2.Length()); s1 = s2 + " (" + iString::FromNumber(vlog,"% 5.2f") + " dex)"; this->AddOneLine(lim->GetName(i),s1,lim->GetUnit(i)); } } void iDataFormatter::FormatVectorData(iDataLimits *lim, int ivar, float *v, float *div, float *vort) { int i, maxLen; iString s1, s2, unit; if(lim==0 || v==0) return; if(ivar>=0 && ivarGetNumVars() && !lim->GetUnit(ivar).IsEmpty()) unit = lim->GetUnit(ivar); // // Divergence and vorticity // if(div != 0) { s1 = iString::FromNumber(div[0],"%.3e"); } if(vort != 0) { float vortVal = 0.0; for(i=0; i<3; i++) vortVal += vort[i]*vort[i]; vortVal = float(sqrt(vortVal)); s2 = iString::FromNumber(vortVal,"%.3e"); } maxLen = s1.Length(); if(s2.Length() > maxLen) maxLen = s2.Length(); while(mFormatHelper.Length() < maxLen) mFormatHelper += " "; if(!s1.IsEmpty()) this->AddOneLine("Divergence",s1+mFormatHelper.Part(0,maxLen-s1.Length()),unit); if(!s2.IsEmpty()) this->AddOneLine("Vorticity",s2+mFormatHelper.Part(0,maxLen-s2.Length()),unit); // // Vector components // s1 = "( "; for(i=0; i<3; i++) { s1 += iString::FromNumber(v[i],"%.3e"); if(i < 2) s1 += " , "; } s1 += " )"; this->AddOneLine((ivar<0 || ivar>=lim->GetNumVars())?"Vector components":lim->GetNameForClass(ivar),s1,unit); } void iDataFormatter::FormatTensorData(iDataLimits *lim, int ivar, float *v, bool compressed) { int i, j; iString s1, s2, unit; if(lim==0 || v==0) return; if(ivar>=0 && ivarGetNumVars() && !lim->GetUnit(ivar).IsEmpty()) unit = lim->GetUnit(ivar); // // Compute the eigenvalues // float *mat[3], eig[3], *eiv[3], tmp; float mat0[3], mat1[3], mat2[3]; float eiv0[3], eiv1[3], eiv2[3]; // // Set up working matrices // mat[0] = mat0; mat[1] = mat1; mat[2] = mat2; eiv[0] = eiv0; eiv[1] = eiv1; eiv[2] = eiv2; if(compressed) { mat[0][0] = *(v+0); mat[0][1] = *(v+1); mat[0][2] = *(v+2); mat[1][0] = *(v+1); mat[1][1] = *(v+3); mat[1][2] = *(v+4); mat[2][0] = *(v+2); mat[2][1] = *(v+4); mat[2][2] = *(v+5); } else { mat[0][0] = *(v+0); mat[0][1] = *(v+1); mat[0][2] = *(v+2); mat[1][0] = *(v+3); mat[1][1] = *(v+4); mat[1][2] = *(v+5); mat[2][0] = *(v+6); mat[2][1] = *(v+7); mat[2][2] = *(v+8); } vtkMath::Jacobi(mat,eig,eiv); // // Order eigenvalues // for(i=0; i<2; i++) { for(j=i+1; j<3; j++) { if(eig[i] > eig[j]) { tmp = eig[i]; eig[i] = eig[j]; eig[j] = tmp; } } } int maxLen = 0; for(i=0; i<3; i++) { s2 = iString::FromNumber(eig[i],"%.3e"); if(maxLen < s2.Length()) maxLen = s2.Length(); } while(mFormatHelper.Length() < maxLen) mFormatHelper += " "; for(i=0; i<3; i++) { s2 = iString::FromNumber(eig[i],"%.3e"); this->AddOneLine("Eigenvalue #"+iString::FromNumber(i),s2+mFormatHelper.Part(0,maxLen-s2.Length()),unit); } // // Tensor components // maxLen = 0; for(j=0; j<3; j++) { for(i=0; i<3; i++) { s2 = iString::FromNumber(mat[j][i],"%.3e"); if(maxLen < s2.Length()) maxLen = s2.Length(); } } while(mFormatHelper.Length() < maxLen) mFormatHelper += " "; for(j=0; j<3; j++) { s1 = " "; for(i=0; i<3; i++) { s2 = iString::FromNumber(mat[j][i],"%.3e"); if(s2.Length() < maxLen) s2 += mFormatHelper.Part(0,maxLen-s2.Length()); s1 += s2; s1 += " "; } if(j == 1) { this->AddOneLine((ivar<0 || ivar>=lim->GetNumVars())?"Tensor components":lim->GetName(ivar),s1,unit); } else { this->AddOneLine("",s1,unit); } } } ifrit-4.1.2/core/idataformatter.h0000674060175406010010000000440412641012520015316 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IDATAFORMATTER_H #define IDATAFORMATTER_H #include #include "iviewmodulecomponent.h" #include "iarray.h" #include "istring.h" class iDataLimits; class iDataFormatter : public vtkObjectBase, public iViewModuleComponent { public: static iDataFormatter* New(iViewModule *vm = 0); inline int GetNumReportLines() const { return mVarNameLines.Size(); } void GetReport(int i, iString& varName, iString &varData, iString &varUnit) const; void AddOneLine(const iString &name, const iString &data, const iString &unit); void ClearReport(); void FormatScalarData(iDataLimits *lim, int n, float *v, bool useRank = false); void FormatVectorData(iDataLimits *lim, int ivar, float *v, float *div = 0, float *vort = 0); void FormatTensorData(iDataLimits *lim, int ivar, float *v, bool compressed = false); protected: virtual ~iDataFormatter(); private: iDataFormatter(iViewModule *vm); iArray mVarNameLines, mVarDataLines, mVarUnitLines; iString mFormatHelper; }; #endif // IDATAFORMATTER_H ifrit-4.1.2/core/idatahandler.cpp0000775060175406010010000000467712641012550015304 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "idatahandler.h" #include "idataconsumer.h" #include "idatasubject.h" #include "ierror.h" #include "ishell.h" #include "iviewmodule.h" iDataHandler::iDataHandler(iDataConsumer *consumer) : iViewModuleComponent((consumer==0)?0:consumer->GetViewModule()) { IASSERT(consumer); mConsumer = consumer; mConsumer->RegisterDataHandler(this); this->GetViewModule()->GetShell()->OnInitAtom(); } iDataHandler::~iDataHandler() { // // On exit, garbare collector may delete consumer first; // then mConsumer would set to 0 by iDataConsumer destructor. // if(mConsumer != 0) mConsumer->UnRegisterDataHandler(this); } bool iDataHandler::IsOptimizedForSpeed() const { return mConsumer->IsOptimizedForSpeed(); } bool iDataHandler::IsOptimizedForMemory() const { return mConsumer->IsOptimizedForMemory(); } bool iDataHandler::IsOptimizedForQuality() const { return mConsumer->IsOptimizedForQuality(); } iDataLimits* iDataHandler::GetLimits() const { return mConsumer->GetLimits(); } void iDataHandler::GetPeriodicities(bool per[3]) const { int i; for(i=0; i<3; i++) per[i] = mConsumer->GetSubject()->IsDirectionPeriodic(i); } bool iDataHandler::SyncWithLimits(int var, int mode) { return true; } ifrit-4.1.2/core/idatahandler.h0000674060175406010010000000376012641012520014734 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IDATAHANDLER_H #define IDATAHANDLER_H #include "iviewmodulecomponent.h" class iDataConsumer; class iDataLimits; class iDataHandler : public iViewModuleComponent { friend class iDataConsumer; public: bool IsOptimizedForSpeed() const; bool IsOptimizedForMemory() const; bool IsOptimizedForQuality() const; iDataLimits* GetLimits() const; void GetPeriodicities(bool per[3]) const; // helper function virtual float GetMemorySize() = 0; virtual void RemoveInternalData() = 0; protected: iDataHandler(iDataConsumer *consumer); virtual ~iDataHandler(); iDataConsumer* Consumer() const { return mConsumer; } virtual bool SyncWithLimits(int var, int mode); private: iDataConsumer *mConsumer; }; #endif // IVISUALMODULEDATAHANDLER_H ifrit-4.1.2/core/idataid.cpp0000674060175406010010000000317012641012551014245 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "idataid.h" #include "idata.h" iDataId::iDataId(int id) : mTypeId(id) { } iDataId::iDataId(const iDataType& type) : mTypeId(type.mId) { } iDataId::iDataId(const iDataId& other) : mTypeId(other.mTypeId) { } void iDataId::operator=(const iDataId& other) { mTypeId = other.mTypeId; } const iDataType& iDataId::Type() const { return iDataType::FindTypeById(mTypeId); } ifrit-4.1.2/core/idataid.h0000674060175406010010000000347612641012520013717 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A simple wrapper over iDataType for scripts // #ifndef IDATAID_H #define IDATAID_H class iDataType; class iDataId { public: iDataId(int id = 0); iDataId(const iDataType& type); iDataId(const iDataId& other); void operator=(const iDataId& other); inline bool operator==(const iDataId& other) const { return mTypeId == other.mTypeId; } inline bool operator<(const iDataId& other) const { return mTypeId < other.mTypeId; } const iDataType& Type() const; operator const iDataType&() { return this->Type(); } private: int mTypeId; }; #endif // IDATAID_H ifrit-4.1.2/core/idatalimits.cpp0000674060175406010010000001576212641012551015164 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Class containing data limits for a single DataSubject // #include "idatalimits.h" #include "idatasubject.h" #include "ifileloader.h" #include "ihistogrammaker.h" #include "istretch.h" #include "iviewmodule.h" // // templates // #include "iarray.tlh" using namespace iParameter; iDataLimits* iDataLimits::New(const iDataSubject *subject) { IASSERT(subject); return new iDataLimits(subject,false); } iDataLimits::iDataLimits(const iDataSubject *subject, bool isfrozen) : mSubject(subject), mIsFrozen(isfrozen) { IASSERT(subject); mBlockNotifications = mIsActive = false; if(!mIsFrozen) { // // By default add just 1 var // this->DeclareVars(1); } } iDataLimits::~iDataLimits() { } const iDataType& iDataLimits::GetDataType() const { return mSubject->GetDataType(); } bool iDataLimits::Activate(int nvars) { mVars.Clear(); if(nvars >= 0) { mIsActive = true; return this->AddVars(nvars); } else { mIsActive = false; return true; } } bool iDataLimits::AddVars(int nvars) // add first nvars Vars { int var; for(var=0; varAddOneVar(); } return true; } void iDataLimits::AddOneVar(int ndecl) { if(ndecl<-1 || ndecl>=mDeclaredVars.Size()) { IBUG_ERROR("Invalid index for a declared variable."); return; } if(ndecl == -1) { // // Auto-expand the declared vars if needed // if(mVars.Size() == mDeclaredVars.Size()) { if(mIsFrozen) { IBUG_WARN("Unable to modify variables for frozen Limits."); return; } else { Var tmp(mDeclaredVars.Size()); mDeclaredVars.Add(tmp); } } ndecl = mVars.Size(); } mVars.AddUnique(&mDeclaredVars[ndecl]); } bool iDataLimits::Resize(int n) { if(mIsFrozen) return false; else { this->DeclareVars(n); return true; } } void iDataLimits::DeclareVars(int n) { if(n < 1) n = 1; while(mDeclaredVars.Size() > n) mDeclaredVars.RemoveLast(); while(mDeclaredVars.Size() < n) { Var tmp(mDeclaredVars.Size()); mDeclaredVars.Add(tmp); } } void iDataLimits::AddAllDeclared(bool s) { int i; mVars.Clear(); if(s) { mVarsBackup.Clear(); for(i=0; i=0 && n=0 && n=0 && n=0 && nCacheVar(n); if(v != 0) { v->Range = p; if(v->Range.Max < v->Range.Min) { float tmp = v->Range.Max; v->Range.Max = v->Range.Min; v->Range.Min = tmp; } else if(v->Range.Max == v->Range.Min) { float q = v->Range.Max; if(q > 0.0) { v->Range.Min = q*0.99; v->Range.Max = q*1.01; } else if(q < 0.0) { v->Range.Min = q*1.01; v->Range.Max = q*0.99; } else { v->Range.Min = -0.01; v->Range.Max = 0.01; } } if(!mBlockNotifications) { mSubject->SyncWithLimits(n,LimitsChangeMode::Range); } return true; } else return false; } bool iDataLimits::SetName(int n, const iString& name) { Var *v = this->CacheVar(n); if(v != 0) { if(mIsFrozen) return (v->Name == name); v->Name = name; if(!mBlockNotifications) { mSubject->SyncWithLimits(n,LimitsChangeMode::Name); } return true; } else return false; } bool iDataLimits::SetStretch(int n, const iString& str) { Var *v = this->CacheVar(n); if(v != 0) { if(!v->StretchFixed) { int id = iStretch::GetId(str); if(id != -1) { v->StretchId = id; if(!mBlockNotifications) { mSubject->SyncWithLimits(n,LimitsChangeMode::Stretch); } return true; } return false; } else return (iStretch::GetName(v->StretchId).Lower() == str.Lower()); } else return false; } const iString& iDataLimits::GetStretch(int n) const { static const iString null; const Var *v = this->CacheVar(n); if(v != 0) return iStretch::GetName(v->StretchId); else return null; } float iDataLimits::GetStretchedMax(int n) const { const Var *v = this->CacheVar(n); if(v != 0) return iStretch::Apply(v->Range.Max,v->StretchId,true); else return iMath::_LargeFloat; } float iDataLimits::GetStretchedMin(int n) const { const Var *v = this->CacheVar(n); if(v != 0) return iStretch::Apply(v->Range.Min,v->StretchId,false); else return -iMath::_LargeFloat; } const iPair iDataLimits::GetDataRange(int n) const { static const iPair none(-iMath::_LargeFloat,iMath::_LargeFloat); if(n>=0 && nIsThereData()) { return mSubject->GetHistogramMaker()->GetRange(n); } else return this->GetRange(n); } else return none; } float iDataLimits::GetDataMax(int n) const { if(n>=0 && nIsThereData()) { return mSubject->GetHistogramMaker()->GetMax(n).Value; } else return this->GetMax(n); } else return iMath::_LargeFloat; } float iDataLimits::GetDataMin(int n) const { if(n>=0 && nIsThereData()) { return mSubject->GetHistogramMaker()->GetMin(n).Value; } else return this->GetMin(n); } else return -iMath::_LargeFloat; } iDataLimits::Var::Var(int n) { Range = iPair(0.1,10); StretchId = iStretch::Lin; Rank = 0U; Included = true; StretchFixed = false; Name = "Variable"; if(n >= 0) Name += (" #"+iString::FromNumber(n+1)); } ifrit-4.1.2/core/idatalimits.h0000674060175406010010000001216312641012520014615 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IDATALIMITS_H #define IDATALIMITS_H #include #include "iarray.h" #include "imath.h" #include "ipair.h" #include "istretch.h" #include "istring.h" #include class iDataSubject; class iDataType; namespace iParameter { namespace LimitsChangeMode { const int Name = 0; const int Range = 1; const int Stretch = 2; }; }; class iDataLimits : public vtkObjectBase { friend class iDataSubject; friend class iEdition; friend class iFileLoader; public: vtkTypeMacro(iDataLimits,vtkObjectBase); static iDataLimits* New(const iDataSubject *subject = 0); int GetNumVars() const; const iPair& GetRange(int n) const; const iString& GetStretch(int n) const; int GetStretchId(int n) const; float GetMax(int n) const; float GetMin(int n) const; float GetStretchedMax(int n) const; float GetStretchedMin(int n) const; unsigned int GetRank(int n) const; const iString& GetName(int n) const; const iString& GetUnit(int n) const; bool GetStretchFixed(int n) const; const iString& GetNameForClass(int n) const; // GetClassName conflicts with something under VC++ bool SetRange(int n, const iPair& p); bool SetName(int n, const iString& v); bool SetStretch(int n, const iString& v); inline bool IsFrozen() const { return mIsFrozen; } const iDataType& GetDataType() const; //const iDataSubject* GetDataSubject() const { return mSubject; } const iPair GetDataRange(int n) const; float GetDataMax(int n) const; float GetDataMin(int n) const; void BlockNotifications(bool b); bool Resize(int n); // calls DeclareVars unless frozen protected: iDataLimits(const iDataSubject *subject, bool isfrozen); virtual ~iDataLimits(); bool Activate(int nvars); void DeclareVars(int n); // for child use void AddOneVar(int ndecl = -1); virtual bool AddVars(int nvars); struct Var { iPair Range; int StretchId; unsigned int Rank; bool Included, StretchFixed; iString Name, Unit, ClassName; Var(int n = -1); }; // // Protected for children to be able to fill in directly // iArray mDeclaredVars; private: Var* CacheVar(int n); const Var* CacheVar(int n) const; void AddAllDeclared(bool s); // helper for the Subject to save a state const iDataSubject *mSubject; const bool mIsFrozen; iLookupArray mVars, mVarsBackup; bool mBlockNotifications, mIsActive; }; inline const iPair& iDataLimits::GetRange(int n) const { static const iPair none(-iMath::_LargeFloat,iMath::_LargeFloat); const Var *v = this->CacheVar(n); if(v != 0) return v->Range; else return none; } inline float iDataLimits::GetMax(int n) const { const Var *v = this->CacheVar(n); if(v != 0) return v->Range.Max; else return iMath::_LargeFloat; } inline float iDataLimits::GetMin(int n) const { const Var *v = this->CacheVar(n); if(v != 0) return v->Range.Min; else return -iMath::_LargeFloat; } inline int iDataLimits::GetStretchId(int n) const { const Var *v = this->CacheVar(n); if(v != 0) return v->StretchId; else return -1; } inline const iString& iDataLimits::GetName(int n) const { static const iString null; const Var *v = this->CacheVar(n); if(v != 0) return v->Name; else return null; } inline const iString& iDataLimits::GetUnit(int n) const { static const iString null; const Var *v = this->CacheVar(n); if(v != 0) return v->Unit; else return null; } inline bool iDataLimits::GetStretchFixed(int n) const { const Var *v = this->CacheVar(n); if(v != 0) return v->StretchFixed; else return false; } inline unsigned int iDataLimits::GetRank(int n) const { const Var *v = this->CacheVar(n); if(v != 0) return v->Rank; else return (unsigned int)-1; } inline const iString& iDataLimits::GetNameForClass(int n) const { static const iString null; const Var *v = this->CacheVar(n); if(v != 0) return v->ClassName; else return null; } inline void iDataLimits::BlockNotifications(bool b) { mBlockNotifications = b; } #endif // IDATALIMITS_H ifrit-4.1.2/core/idataobject.cpp0000674060175406010010000000430012641012551015113 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "idataobject.h" #include "idatasubject.h" #include "ierror.h" #include "iviewmodule.h" // // templates // #include "iarray.tlh" // // Main class // iDataObject* iDataObject::New(iViewModule *parent) { static iString LongName = "Data"; static iString ShortName = "d"; return new iDataObject(parent,LongName,ShortName); } iDataObject::iDataObject(iViewModule *parent, const iString &fname, const iString &sname) : iObject(parent,fname,sname), iViewModuleComponent(parent) { mRenderMode = iParameter::RenderMode::NoRender; } iDataObject::~iDataObject() { } void iDataObject::WriteState(iString &s) const { int i; iString s1; s.Init(1000); this->WriteHead(s); s += "Known data types:\n"; for(i=0; i(INFO,mChildren[i]); s1 = " " + sub->LongName(); if(sub->IsThereData()) { while(s1.Length() < 20) s1 += " "; s1 += "loaded"; } s += s1 + "\n"; } } ifrit-4.1.2/core/idataobject.h0000674060175406010010000000363412641012520014565 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A container class that collects all DataSubjects (effectively a namespace, exist mere for convenience) // #ifndef IDATAOBJECT_H #define IDATAOBJECT_H #include "iobject.h" #include "iviewmodulecomponent.h" class iDataSubject; class iViewModule; // // Main class // class iDataObject : public iObject, public iViewModuleComponent { public: vtkTypeMacro(iDataObject,iObject); static iDataObject* New(iViewModule *parent); virtual void WriteState(iString &s) const; protected: virtual ~iDataObject(); private: iDataObject(iViewModule *parent, const iString &fname, const iString &sname); static iDataObject* New(){ return 0; } }; #endif // IDATAOBJECT_H ifrit-4.1.2/core/idatareader.cpp0000674060175406010010000004060212641012551015114 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "idatareader.h" #include "ibuffer.h" #include "icoredatasubjects.h" #include "icorefileloaders.h" #include "idata.h" #include "idatalimits.h" #include "idatareaderobserver.h" #include "idatasubject.h" #include "idirectory.h" #include "iedition.h" #include "ierror.h" #include "ifile.h" #include "imonitor.h" #include "iobjectfactory.h" #include "iparallelmanager.h" #include "iparallelworker.h" #include "ishell.h" #include "ishelleventobservers.h" #include "iuniformgriddata.h" #include "iuniformgridfileloader.h" #include "iviewmodule.h" #include // // Templates // #include "iarray.tlh" #include "iproperty.tlh" using namespace iParameter; // // Main class // iDataReader* iDataReader::New(iViewModule* vm) { static iString LongName("DataReader"); static iString ShortName("dr"); int i, j, k; IASSERT(vm); iDataReader *tmp = new iDataReader(vm,LongName,ShortName); IERROR_CHECK_MEMORY(tmp); iObjectFactory::InstallExtensions(tmp); iFileLoader *s; for(i=0; imExtensions.Size(); i++) { j = 0; while((s = iRequiredCast(INFO,tmp->mExtensions[i])->GetLoader(j++)) != 0) { for(k=0; kNumStreams(); k++) { iEdition::ApplySettings(s->GetStream(k)->Subject); } tmp->mLoaders.Add(s); } } iEdition::ApplySettings(tmp); return tmp; } iDataReader::iDataReader(iViewModule *vm, const iString &fname, const iString &sname) : iExtendableObject(vm,fname,sname), iViewModuleComponent(vm), iObjectConstructPropertyMacroS(Int,iDataReader,BoundaryConditions,bc), iObjectConstructPropertyMacroS(Int,iDataReader,ScaledDimension,sd), iObjectConstructPropertyMacroS(Int,iDataReader,VoxelLocation,vl), iObjectConstructPropertyMacroS(Int,iDataReader,MaxZDimension,mzd), iObjectConstructPropertyMacroV(Double,iDataReader,Shift,s,3), iObjectConstructPropertyMacroA2(DataType,String,iDataReader,Load,l), iObjectConstructPropertyMacroA1(DataType,iDataReader,Erase,e), iObjectConstructPropertyMacroA(iDataReader,Reload,r) { mRenderMode = RenderMode::Clones; mRecordLength = 4; mTwoCopies = mInExtensionUpdate = false; mCellToPointMode = 2; mVoxelLocation = VoxelLocation::Vertex; mBoundaryConditions = BoundaryConditions::None; //delete mPropertyStack; //mPropertyStack = new iDataReaderPropertyStack(this); IERROR_CHECK_MEMORY(mPropertyStack); mVectorLoader = new iCoreData::VectorFileLoader(this); IERROR_CHECK_MEMORY(mVectorLoader); mScalarLoader = new iCoreData::ScalarFileLoader(this,mVectorLoader); IERROR_CHECK_MEMORY(mScalarLoader); mTensorLoader = new iCoreData::TensorFileLoader(this); IERROR_CHECK_MEMORY(mTensorLoader); mParticleLoader = new iCoreData::ParticleFileLoader(this); IERROR_CHECK_MEMORY(mParticleLoader); iCoreData::ScalarDataSubject *us = new iCoreData::ScalarDataSubject(mScalarLoader); IERROR_CHECK_MEMORY(us); iCoreData::VectorDataSubject *uv = new iCoreData::VectorDataSubject(mVectorLoader); IERROR_CHECK_MEMORY(uv); iCoreData::TensorDataSubject *ut = new iCoreData::TensorDataSubject(mTensorLoader); IERROR_CHECK_MEMORY(ut); iCoreData::ParticleDataSubject *bp = new iCoreData::ParticleDataSubject(mParticleLoader); IERROR_CHECK_MEMORY(bp); iEdition::ApplySettings(us); iEdition::ApplySettings(uv); iEdition::ApplySettings(ut); iEdition::ApplySettings(bp); mLoaders.Add(mScalarLoader); mLoaders.Add(mVectorLoader); mLoaders.Add(mTensorLoader); mLoaders.Add(mParticleLoader); mCurrentRecord = -1; mPeriodicityLeader = 0; mShift[0] = mShift[1] = mShift[2] = 0.0f; mScaledDimension = -1; //max dim mMaxZDimension = 0; mDataReloadInfo = new iDataInfo; IERROR_CHECK_MEMORY(mDataReloadInfo); // mLastFileName = mLastAttemptedFileName = ""; mDirectory = new iDirectory; IERROR_CHECK_MEMORY(mDirectory); } iDataReader::~iDataReader() { int i; delete mDirectory; delete mDataReloadInfo; for(i=0; iDelete(); } void iDataReader::EraseData(const iDataType &type) { int i; for(i=0; iIsUsingData(type) && mLoaders[i]->IsThereData(type)) mLoaders[i]->EraseData(); } } void iDataReader::SetTwoCopies(bool s) { int i; if(mTwoCopies != s) { mTwoCopies = s; for(i=0; iSetTwoCopies(s); } } } void iDataReader::ReloadData(const iDataType &type) { int i; for(i=0; iIsUsingData(type) && mLoaders[i]->IsThereData(type)) { mLoaders[i]->LoadFile(mLoaders[i]->GetLastFileName(),mShift); } } } bool iDataReader::HasDataToReload() const { return (mDataReloadInfo->Size()>0 && this->IsThereData(*mDataReloadInfo)); } void iDataReader::RequestDataReload(const iDataInfo &info) { if(this->IsThereData(info)) { *mDataReloadInfo += info; if(this->GetShell()->GetDataReaderObserver()->AllowReload()) { this->CallReload(); } } } void iDataReader::ResetPipeline() { int i; for(i=0; iReset(); } } bool iDataReader::IsThereData(const iDataInfo &info) const { int i; for(i=0; iIsThereData(info.Type(i))) return true; } return false; } bool iDataReader::IsThereData(const iDataType &type) const { int i; for(i=0; iIsUsingData(type) && mLoaders[i]->IsThereData(type)) return true; } return false; } const iString& iDataReader::GetLastFileName(const iDataType &type) const { static const iString null; int i; for(i=0; iIsUsingData(type)) return mLoaders[i]->GetLastFileName(); } return null; } iDataLimits* iDataReader::GetLimits(const iDataType &type) const { int i; for(i=0; iIsUsingData(type)) return mLoaders[i]->GetSubject(type)->GetLimits(); } return 0; } iDataSubject* iDataReader::GetSubject(const iDataType &type) const { int i; for(i=0; iIsUsingData(type)) return mLoaders[i]->GetSubject(type); } return 0; } bool iDataReader::IsSetLeader(const iFileLoader *loader) const { return (mSetLoaders.Size()>0 && mSetLoaders[0]==loader); } void iDataReader::LoadFile(const iDataType &type, const iString &fname, bool savename) { int i; // // Find a loader that accepts this type. // for(i=0; iIsUsingData(type)) { this->LoadFile(mLoaders[i],fname,savename); return; } } // // We should not use a Monitor here, as it will wrap around DataReaderObserver->StartSet(). // this->OutputText(MessageType::Error,"There is no loader that supports the data type <"+type.LongName()+">."); } void iDataReader::LoadFile(iFileLoader *loader, const iString &name, bool savename) { if(loader == 0) { IBUG_WARN("Bug: trying to load file by a non-existent loader."); } int i; iString fname(name); iDirectory::ExpandFileName(fname); mLastAttemptedFileName = fname; this->GetViewModule()->GetParallelManager()->StartCounters(); this->GetShell()->GetDataReaderObserver()->StartSet(); // // Extension can bring us in again here, so make sure the Monitor goes out of scope before the call to extension // { iMonitor h(this); loader->LoadFile(fname,mShift); if(h.IsStopped()) { this->GetShell()->GetDataReaderObserver()->FinishSet(true); this->GetViewModule()->GetParallelManager()->StopCounters(); return; } } iString root, suffix; int newrec = loader->DissectFileName(fname,root,suffix); // // Update the set // if(newrec >= 0) { if(newrec == mCurrentRecord) { // // Adding to the existent set if the subject is not there yet // if(mSetLoaders.Find(loader) < 0) mSetLoaders.Add(loader); } else { if(savename) this->InsertIntoVisitedFilesList(loader,fname); // // Re-establish the set if we are not loading a new one // if(!this->IsSetLeader(loader)) { this->BreakSet(); mSetLoaders.Add(loader); } mCurrentRecord = newrec; } int m; iString s("File Set: "); for(m=0; m 0) s += " + "; s += mSetLoaders[m]->GetDataType(0).TextName(); } this->OutputText(MessageType::Information,s); } else { if(this->IsSetLeader(loader)) { this->BreakSet(); } if(savename) this->InsertIntoVisitedFilesList(loader,fname); } if(mPeriodicityLeader==0 || loader->GetPriority()GetPriority()) mPeriodicityLeader = loader; mLastFileName = fname; // // Do we have a set? If yes, load the rest of it too // if(this->IsSetLeader(loader)) { // //Is the filename consistent? // if(!mSetLoaders[0]->IsSeriesFileName(fname)) { this->BreakSet(); } else { // // Load the data // iMonitor h(this); for(i=1; !h.IsStopped() && iLoadFile(mSetLoaders[i]->GetFileName(newrec),mShift); } } } this->GetViewModule()->UpdateAfterFileLoad(); // // If this reader has an extension, ask it do to its share of work, but guard against loops if it calls this function // if(loader->GetReaderExtension() != 0) { if(mInExtensionUpdate) return; mInExtensionUpdate = true; loader->GetReaderExtension()->AfterLoadFile(loader,fname); mInExtensionUpdate = false; } this->GetShell()->GetDataReaderObserver()->FinishSet(false); this->GetViewModule()->GetParallelManager()->StopCounters(); } void iDataReader::BreakSet() { mCurrentRecord = -1; mSetLoaders.Clear(); mDirectory->Close(); } bool iDataReader::LoadRecord(int rec, int skip, bool savename) { iMonitor h(this); if(rec < 0) rec = mCurrentRecord; if(mSetLoaders.Size() == 0) { h.PostError("File set has not been established."); return true; } iString fname = mSetLoaders[0]->GetFileName(rec); if(!iFile::IsReadable(fname)) { h.PostError("File is not accessible."); return true; } if(skip != 0) { if(!mDirectory->IsOpened() && !mDirectory->Open(fname)) { h.PostError("Unable to read the directory."); return true; } while(skip>0 && !fname.IsEmpty()) { fname = mDirectory->GetFile(fname,1); if(this->IsAnotherSetLeader(fname)) skip--; } // // Is this filename from the same series? // if(!this->IsAnotherSetLeader(fname)) { h.PostError("File "+fname+" does not exist."); return false; } } if(!fname.IsEmpty()) { this->LoadFile(mSetLoaders[0],fname,savename); return true; } else { h.PostError("File "+fname+" does not exist."); return false; } } const iDataType& iDataReader::GetFileSetDataType(int member) const { if(member<0 || member>=mSetLoaders.Size()) { return iDataType::Null(); } else { return mSetLoaders[member]->GetDataType(0); } } const iString& iDataReader::GetLastFileSetName() const { static const iString none; if(mSetLoaders.Size() == 0) return none; else return mSetLoaders[0]->GetLastFileName(); } const iString iDataReader::GetFileSetName(int rec) const { static const iString none; if(mSetLoaders.Size()>0 && rec>=0) return mSetLoaders[0]->GetFileName(rec); else return none; } const iString iDataReader::GetFileSetRoot() const { static const iString none; if(mSetLoaders.Size() > 0) return mSetLoaders[0]->GetFileRoot(); else return none; } bool iDataReader::IsCurrentSetMember(const iString &fname) const { int i; for(i=0; iGetLastFileName() == fname) return true; } return false; } bool iDataReader::IsAnotherSetLeader(const iString &fname) const { if(mSetLoaders.Size() > 0) { return mSetLoaders[0]->IsSeriesFileName(fname); } else return false; } bool iDataReader::CallLoad(const iDataType& type, const iString& name) { iMonitor h(this); if(type.IsNull()) { h.PostError("Invalid data type."); return false; } else { iString fname(name); if(fname[0] == '+') { fname.Replace(0,1,this->GetViewModule()->GetShell()->GetEnvironment(Environment::Data)); } this->LoadFile(type,fname); return !h.IsStopped(); } } bool iDataReader::CallErase(const iDataType& type) { iMonitor h(this); if(type.IsNull()) { h.PostError("Invalid data type."); return false; } else { this->EraseData(type); return !h.IsStopped(); } } bool iDataReader::CallReload() { int i; if(this->HasDataToReload()) { iMonitor h(this); this->GetShell()->GetDataReaderObserver()->StartSet(); for(i=0; iSize(); i++) { this->ReloadData(mDataReloadInfo->Type(i)); } this->GetShell()->GetDataReaderObserver()->FinishSet(h.IsStopped()); mDataReloadInfo->Clear(); } return true; } bool iDataReader::SetShift(int d, double dx) { if(d>=0 && d<=2) { mShift[d] = dx; this->ShiftData(); return true; } else return false; } void iDataReader::ShiftData(const double *dr) { int i; if(dr == 0) dr = mShift; this->GetViewModule()->GetParallelManager()->StartCounters(); for(i=0; iIsThereData()) { mLoaders[i]->ShiftData(dr); } this->GetViewModule()->GetParallelManager()->StopCounters(); } float iDataReader::GetMemorySize() const { int i; float s = 0.0; for(i=0; iGetMemorySize(); } return s; } void iDataReader::InsertIntoVisitedFilesList(const iFileLoader *loader, const iString &name) { VisitedFile v; v.Name = name; v.Loader = loader; mVisitedFilesList.Add(v); } // // Outputs // vtkDataSet* iDataReader::GetData(const iDataType &type) const { int i; for(i=0; iIsUsingData(type)) { return mLoaders[i]->GetData(type); } } return 0; } // // Decorator functions // bool iDataReader::SetBoundaryConditions(int v) { int i; if(BoundaryConditions::IsValid(v)) { mBoundaryConditions = v; for(i=0; iRequestDataReload(mLoaders[i]->GetDataInfo()); } return true; } else return false; } // bool iDataReader::SetScaledDimension(int v) { int i; iUniformGridFileLoader *ds; for(i=0; iSetScaledDimension(v); mScaledDimension = ds->GetScaledDimension(); } } return true; } bool iDataReader::SetMaxZDimension(int v) { int i; iUniformGridFileLoader *ds; for(i=0; iSetMaxZDimension(v); mMaxZDimension = ds->GetMaxZDimension(); } } return true; } // bool iDataReader::SetVoxelLocation(int v) { int i; iUniformGridFileLoader *ds; for(i=0; iSetVoxelLocation(v); mVoxelLocation = ds->GetVoxelLocation(); } } return true; } // // Extension // iObjectExtensionAbstractConstructorBeginMacro(iDataReader) { } void iDataReaderExtension::AfterLoadFile(iFileLoader *loader, const iString &fname) { iMonitor h(loader); if(loader->GetReaderExtension() != this) { IBUG_ERROR("iDataReaderExtension is configured incorrectly."); h.PostError("Unable to read the data due to a bug."); return; } mLastFileName = fname; this->AfterLoadFileBody(loader,fname); } void iDataReaderExtension::AfterLoadFileBody(iFileLoader *, const iString &) { // // By default do nothing // } ifrit-4.1.2/core/idatareader.h0000674060175406010010000001330412641012520014554 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IDATAREADER_H #define IDATAREADER_H #include "iextendableobject.h" #include "iviewmodulecomponent.h" #include "iarray.h" class iDataInfo; class iDataLimits; class iDataReaderHelper; class iDataSubject; class iDataType; class iDirectory; class iFile; class iFileLoader; namespace iCoreData { class ScalarFileLoader; class VectorFileLoader; class TensorFileLoader; class ParticleFileLoader; }; class vtkDataSet; class vtkPolyData; class vtkImageData; class iDataReader : public iExtendableObject, public iViewModuleComponent { friend class iDataReaderHelper; public: struct VisitedFile { iString Name; const iFileLoader *Loader; }; vtkTypeMacro(iDataReader,iExtendableObject); static iDataReader* New(iViewModule *vm = 0); // // Non-static members // iObjectPropertyMacro1S(BoundaryConditions,Int); iObjectPropertyMacro1S(ScaledDimension,Int); iObjectPropertyMacro1S(VoxelLocation,Int); iObjectPropertyMacro1S(MaxZDimension,Int); iObjectPropertyMacro1V(Shift,Double,3); iObjectSlotMacroA2(Load,const iDataType&,const iString&); iPropertyAction2 Load; iObjectSlotMacroA1(Erase,const iDataType&); iPropertyAction1 Erase; iObjectPropertyMacroA(Reload); // reload requested data inline bool IsSet() const { return mSetLoaders.Size() > 0; } // // Loading of data // void LoadFile(const iDataType &type, const iString &fname, bool savename = true); bool LoadRecord(int rec, int skip = 0, bool savename = false); // return false if the record is missing, true otherwise (even in case of an error) // // Operation on data // bool IsThereData(const iDataType &type) const; bool IsThereData(const iDataInfo &info) const; void EraseData(const iDataType &type); void ReloadData(const iDataType &type); void RequestDataReload(const iDataInfo &info); bool HasDataToReload() const; void SetTwoCopies(bool s); void ResetPipeline(); iDataSubject* GetSubject(const iDataType &type) const; iDataLimits* GetLimits(const iDataType &type) const; // // Generic GetData // vtkDataSet* GetData(const iDataType &type) const; inline bool IsFileAnimatable() const { return (mCurrentRecord >= 0); } inline int GetRecordNumber() const { return mCurrentRecord; } virtual void ShiftData(const double *dx = 0); virtual float GetMemorySize() const; // // Functions for file manipulation // const iString& GetLastFileSetName() const; bool IsAnotherSetLeader(const iString &fname) const; bool IsCurrentSetMember(const iString &fname) const; const iString GetFileSetName(int rec) const; const iString GetFileSetRoot() const; const iDataType& GetFileSetDataType(int member = 0) const; const iString& GetLastFileName(const iDataType &type) const; inline const iString& GetLastFileName() const { return mLastFileName; } inline const iString& GetLastAttemptedFileName() const { return mLastAttemptedFileName; } inline const iArray& GetVisitedFilesList() const { return mVisitedFilesList; } inline int GetRecordLength() const { return mRecordLength; } protected: virtual ~iDataReader(); private: iDataReader(iViewModule *vm, const iString &fname, const iString &sname); void LoadFile(iFileLoader *loader, const iString &fname, bool savename); void InsertIntoVisitedFilesList(const iFileLoader *loader, const iString &name); void BreakSet(); bool IsSetLeader(const iFileLoader *loader) const; bool mTwoCopies, mInExtensionUpdate; int mCellToPointMode; iString mMode; iFileLoader *mPeriodicityLeader; iLookupArray mSetLoaders; iArray mLoaders; iCoreData::ScalarFileLoader *mScalarLoader; iCoreData::VectorFileLoader *mVectorLoader; iCoreData::TensorFileLoader *mTensorLoader; iCoreData::ParticleFileLoader *mParticleLoader; int mCurrentRecord, mRecordLength; iDataInfo *mDataReloadInfo; iString mLastFileName, mLastAttemptedFileName; iArray mVisitedFilesList; iDirectory *mDirectory; }; class iDataReaderExtension : public iObjectExtension { iObjectExtensionDeclareAbstractMacro(iDataReader); public: inline iDataReader* GetReader() const { return mRealOwner; } virtual iFileLoader* GetLoader(int n) const = 0; // // It is a good idea to keep track of the last file read. // inline const iString& GetLastFileName() const { return mLastFileName; } void AfterLoadFile(iFileLoader *loader, const iString &fname); protected: virtual void AfterLoadFileBody(iFileLoader *loader, const iString &fname); iString mLastFileName; }; #endif ifrit-4.1.2/core/idatareaderobserver.cpp0000674060175406010010000000517612641012551016673 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "idatareaderobserver.h" #include "idata.h" #include "ierror.h" #include "ioutput.h" #include "istring.h" using namespace iParameter; // // iDataReaderObserver class // iDataReaderObserver::iDataReaderObserver(iShell *s) : iShellComponent(s) { mStarted = false; } void iDataReaderObserver::StartSet() { if(mStarted) { IBUG_ERROR("iDataReaderObserver cannot be called recursively."); return; } mStarted = true; this->OnSetStart(); } void iDataReaderObserver::StartFile(const iString &fname, const iDataType &type) { this->OnFileStart(fname,type); } void iDataReaderObserver::FinishFile(const iString &fname, const iDataInfo &info) { this->OnFileFinish(fname,info); } void iDataReaderObserver::FinishSet(bool error) { this->OnSetFinish(error); mStarted = false; } bool iDataReaderObserver::AllowReload() { this->OutputText(MessageType::Warning,"This property only takes effect when the data set is reloaded. Use function call to reload the data as needed."); return false; } void iDataReaderObserver::OnSetStart() { } void iDataReaderObserver::OnFileFinish(const iString &fname, const iDataInfo &info) { } void iDataReaderObserver::OnSetFinish(bool error) { } void iDataReaderObserver::OnFileStart(const iString &fname, const iDataType &type) { this->OutputText(MessageType::Information,"Loading file: "+fname+" of data type "+type.LongName()); } ifrit-4.1.2/core/idatareaderobserver.h0000674060175406010010000000405112641012521016324 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // DataReader observer (this is not an EventObserver), just a callback class // #ifndef IDATAREADEROBSERVER_H #define IDATAREADEROBSERVER_H #include "ishellcomponent.h" class iDataInfo; class iDataType; class iString; class iDataReaderObserver : public iShellComponent { public: void StartSet(); void StartFile(const iString &fname, const iDataType &type); void FinishFile(const iString &fname, const iDataInfo &info); void FinishSet(bool error); virtual bool AllowReload(); protected: iDataReaderObserver(iShell *s); virtual void OnSetStart(); virtual void OnSetFinish(bool error); virtual void OnFileStart(const iString &fname, const iDataType &type) = 0; virtual void OnFileFinish(const iString &fname, const iDataInfo &info); private: bool mStarted; }; #endif // IDATAREADEROBSERVER_H ifrit-4.1.2/core/idatasubject.cpp0000674060175406010010000001247712641012551015322 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "idatasubject.h" #include "ibuffer.h" #include "idata.h" #include "idataconsumer.h" #include "idataobject.h" #include "idatareader.h" #include "ierror.h" #include "ifileloader.h" #include "ihistogrammaker.h" #include "iprobefilter.h" #include "ishell.h" #include "iviewmodule.h" // // Templates // #include "iarray.tlh" #include "ibuffer.tlh" #include "iproperty.tlh" using namespace iParameter; #define iDataSubjectPropertyConstructMacro(_fname_,_sname_) \ _fname_(iDataSubject::Self(),&iDataLimits::Set##_fname_,&iDataLimits::Get##_fname_,#_fname_,#_sname_) iDataSubject::iDataSubject(iFileLoader *fl, const iDataType& type) : iObject(fl->GetViewModule()->GetDataObject(),type.LongName(),type.ShortName()), iViewModuleComponent(fl->GetViewModule()), DataPresent(iObject::Self(),static_cast::GetterType>(&iDataSubject::IsThereData),"DataPresent","dp"), iObjectConstructPropertyMacroQ(String,iDataSubject,FileName,fn), iObjectConstructPropertyMacroS(Bool,iDataSubject,ResetOnLoad,rol), iDataSubjectPropertyConstructMacro(Range,r), iDataSubjectPropertyConstructMacro(Name,n), iDataSubjectPropertyConstructMacro(Stretch,s), iObjectConstructPropertyMacroA1(String,iDataSubject,Load,l), iObjectConstructPropertyMacroA(iDataSubject,Erase,e), mId(fl->NumStreams()) { mRenderMode = RenderMode::Clones; IASSERT(fl); mLoader = fl; // // Add self as a new stream // iFileLoader::Stream *s = fl->CreateNewStream(); IERROR_CHECK_MEMORY(s); s->Subject = this; fl->mStreams.Add(s); mLimits = 0; mHistogramMaker = 0; mResetOnLoad = true; } iDataSubject::~iDataSubject() { if(mHistogramMaker != 0) mHistogramMaker->Delete(); if(mLimits != 0) mLimits->Delete(); } bool iDataSubject::CallLoad(const iString& name) { return this->GetLoader()->GetReader()->CallLoad(iDataId(this->GetDataType()),name); } bool iDataSubject::CallErase() { return this->GetLoader()->GetReader()->CallErase(iDataId(this->GetDataType())); } iDataLimits* iDataSubject::CreateLimits() const { return iDataLimits::New(this); } iHistogramMaker* iDataSubject::CreateHistogramMaker() const { return iHistogramMaker::New(this); } bool iDataSubject::IsThereData() const { return mLoader->IsThereData(mId); } bool iDataSubject::IsThereScalarData() const { return mLoader->IsThereScalarData(mId); } bool iDataSubject::IsThereVectorData() const { return mLoader->IsThereVectorData(mId); } bool iDataSubject::IsThereTensorData() const { return mLoader->IsThereTensorData(mId); } bool iDataSubject::IsDirectionPeriodic(int d) const { if(d>=0 && d<3 && mLoader->IsThereData(mId)) { return (mLoader->GetBoundaryConditions()==BoundaryConditions::Periodic && mLoader->GetStream(mId)->Periodic[d]); } else return false; } const iString& iDataSubject::GetFileName() const { return mLoader->GetLastFileName(); } vtkDataSet* iDataSubject::GetData() const { return mLoader->GetData(mId); } iDataLimits* iDataSubject::GetLimits() const { if(mLimits == 0) { mLimits = this->CreateLimits(); IERROR_CHECK_MEMORY(mLimits); } return mLimits; } iHistogramMaker* iDataSubject::GetHistogramMaker() const { if(mHistogramMaker == 0) { mHistogramMaker = this->CreateHistogramMaker(); IERROR_CHECK_MEMORY(mHistogramMaker); } return mHistogramMaker; } bool iDataSubject::SetResetOnLoad(bool s) { mResetOnLoad = s; return true; } iProbeFilter* iDataSubject::CreateProbeFilter(iDataConsumer *consumer) const { return iProbeFilter::New(consumer); } void iDataSubject::SyncWithLimits(int var, int mode) const { iSyncWithLimitsRequest req(var,mode,this->GetDataType()); this->GetViewModule()->SyncWithData(req); } void iDataSubject::RequestDataReload() const { this->GetLoader()->GetReader()->RequestDataReload(this->GetDataType()); } const iString iDataSubject::HelpTag() const { return "~" + this->ShortName(); } void iDataSubject::SavePropertiesToString(iString &str) const { this->GetLimits()->AddAllDeclared(true); this->iObject::SavePropertiesToString(str); this->GetLimits()->AddAllDeclared(false); } unsigned int iDataSubject::GetDataRank() const { return this->GetDataType().GetRank(); } ifrit-4.1.2/core/idatasubject.h0000674060175406010010000001517412641012521014761 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A base class for all DataSubjects. One DataSubject provides data for a single unique DataType. // #ifndef IDATASUBJECT_H #define IDATASUBJECT_H #include "iobject.h" #include "iviewmodulecomponent.h" #include "idatalimits.h" class iDataConsumer; class iDataLimits; class iDataSubject; class iDataType; class iFileLoader; class iHistogramMaker; class iProbeFilter; class vtkDataSet; // // Property class that connect to iDataLimits // template class iDataSubjectProperty : public iPropertyDataVariable { public: typedef typename iType::Traits::Type ArgT; typedef bool (iDataLimits::*SetterType)(int i, ArgT val); typedef ArgT (iDataLimits::*GetterType)(int i) const; iDataSubjectProperty(iDataSubject *owner, SetterType setter, GetterType getter, const iString &fname, const iString &sname, int rank = 0) : iPropertyDataVariable(owner,fname,sname,rank) { this->mOwner = owner; this->mSetter = setter; this->mGetter = getter; } virtual int Size() const; virtual bool IsFixedSize() const { return false; } virtual bool Copy(const iPropertyVariable *p); virtual ArgT GetValue(int i) const; virtual bool SetValue(int i, ArgT v) const; protected: virtual bool Resize(int num, bool force = false); iDataSubject *mOwner; SetterType mSetter; GetterType mGetter; }; class iDataSubject : public iObject, public iViewModuleComponent { friend class iFileLoader; public: vtkTypeMacro(iDataSubject,iObject); iPropertyQuery DataPresent; iObjectPropertyMacro2Q(FileName,String); iObjectPropertyMacro1S(ResetOnLoad,Bool); iDataSubjectProperty Range; iDataSubjectProperty Name; iDataSubjectProperty Stretch; iObjectPropertyMacroA1(Load,String); iObjectPropertyMacroA(Erase); virtual bool IsThereData() const; void RequestDataReload() const; void SyncWithLimits(int var, int mode) const; // just pass a request to ViewModule // // Access to components // inline iFileLoader* GetLoader() const { return mLoader; } iHistogramMaker* GetHistogramMaker() const; iDataLimits* GetLimits() const; vtkDataSet* GetData() const; virtual const iDataType& GetDataType() const = 0; // // Boundary conditions // bool IsDirectionPeriodic(int d) const; // // We need to know what ProbeFilter would work with this Subject // virtual iProbeFilter* CreateProbeFilter(iDataConsumer *consumer) const; // // Provide some additional information about the data. // unsigned int GetDataRank() const; bool IsThereScalarData() const; bool IsThereVectorData() const; bool IsThereTensorData() const; // // Data subjects are treated by help differently from other objects // virtual const iString HelpTag() const; protected: iDataSubject(iFileLoader *fl, const iDataType& type); virtual ~iDataSubject(); iDataSubject* Self(){ return this; } // needed to avoid compiler warning inline int GetId() const { return mId; } virtual iHistogramMaker* CreateHistogramMaker() const; virtual iDataLimits* CreateLimits() const; virtual void SavePropertiesToString(iString &str) const; private: // // Components // const int mId; iFileLoader *mLoader; mutable iDataLimits *mLimits; // must be accessed via GetLimits() only mutable iHistogramMaker *mHistogramMaker; // must be accessed via GetHistogramMaker() only }; template int iDataSubjectProperty::Size() const { return this->mOwner->GetLimits()->GetNumVars(); } template typename iDataSubjectProperty::ArgT iDataSubjectProperty::GetValue(int i) const { return (this->mOwner->GetLimits()->*this->mGetter)(i); } template bool iDataSubjectProperty::SetValue(int i, ArgT v) const { return (this->mOwner->GetLimits()->*this->mSetter)(i,v); } template bool iDataSubjectProperty::Resize(int num, bool force) { return this->mOwner->GetLimits()->Resize(num); } template bool iDataSubjectProperty::Copy(const iPropertyVariable *p) { const iDataSubjectProperty *other = dynamic_cast*>(p); if(other != 0) { int i, n = this->Size(); if(other->Size() < n) n = other->Size(); for(i=0; iSetValue(i,other->GetValue(i))) return false; } return true; } else return false; } // // Useful macros to declare all members that have to be overwritten in children // #define iDataSubjectDefineTypeMacro(_object_,_id_,_fname_,_sname_,_rank_,_keywords_,_environment_) \ const iDataType& _object_::DataType() \ { \ static const iDataType tmp(_id_,_fname_,_sname_,_rank_,_keywords_,_environment_); \ return tmp; \ } \ const iDataType& _object_::GetDataType() const { return _object_::DataType(); } #define iDataSubjectDeclareClassMacro(_prefix_,_name_) \ class _prefix_##_name_##DataSubject : public iDataSubject \ { \ public: \ vtkTypeMacro(_prefix_##_name_##DataSubject,iDataSubject); \ static const iDataType& DataType(); \ const iDataType& GetDataType() const; \ _prefix_##_name_##DataSubject(iFileLoader *fl); \ } #define iDataSubjectDefineClassMacro(_prefix_,_name_,_fname_,_sname_,_rank_,_keywords_,_environment_) \ iDataSubjectDefineTypeMacro(_prefix_##_name_##DataSubject,_prefix_##Extension::SubjectId(),_fname_,_sname_,_rank_,_keywords_,_environment_); \ _prefix_##_name_##DataSubject::_prefix_##_name_##DataSubject(iFileLoader *fl) : iDataSubject(fl,_prefix_##_name_##DataSubject::DataType()){} #endif ifrit-4.1.2/core/idirectory.cpp0000674060175406010010000000652312641012551015030 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "idirectory.h" #include "ierror.h" #include // // templates // #include "iarray.tlh" iDirectory::iDirectory() { } bool iDirectory::Open(const iString &fname) { vtkDirectory *d = vtkDirectory::New(); IERROR_CHECK_MEMORY(d); if(d->Open(fname.ToCharPointer()) == 0) { // // Is the file name attached? // if(fname.Contains("/")==0 || d->Open(fname.Section("/",0,-2).ToCharPointer())==0) return false; else { mDirectory = fname.Section("/",0,-2) + "/"; } } else { mDirectory = fname; if(fname[-1] != '/') mDirectory += "/"; } mFiles.Clear(); int i, n = d->GetNumberOfFiles(); for(i=0; iGetFile(i)); // assume that all files are different, so AddUnique is not needed. } d->Delete(); return true; } void iDirectory::Close() { mDirectory.Clear(); mFiles.Clear(); } const iString iDirectory::GetFile(int i, bool prefixed) const { static const iString null = ""; if(i>=0 && i= 0) i += skip; return this->GetFile(i,prefixed); } bool iDirectory::Make(const iString &name) { return (vtkDirectory::MakeDirectory(name.ToCharPointer()) != 0); } const iString& iDirectory::Separator() { static const iString sep("/"); return sep; } const iString& iDirectory::Current() { static const iString cur("./"); return cur; } void iDirectory::ExpandFileName(iString& fname, const iString &path) { #ifdef _WIN32 // // Make sure we are Windows compatible // fname.Replace("\\",iDirectory::Separator()); #endif // // Apply standard expansion of the plus sign // if(!path.IsEmpty() && fname[0]=='+') fname.Replace(0,1,path); // // Is this an unprefixed file name? // if(fname.Contains(iDirectory::Separator()) == 0) fname = iDirectory::Current() + fname; } ifrit-4.1.2/core/idirectory.h0000674060175406010010000000430012641012521014461 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A class that accesses file names in a directory. It uses vtkDirectory // class internally, but changes interface to more convenient. // #ifndef IDIRECTORY_H #define IDIRECTORY_H #include "iarray.h" #include "istring.h" class iDirectory { public: iDirectory(); bool Open(const iString &name); void Close(); inline bool IsOpened() const { return !mDirectory.IsEmpty(); } inline const iString& GetDirectoryPrefix() const { return mDirectory; } inline int GetNumberOfFiles() const { return mFiles.Size(); } const iString GetFile(int i, bool prefixed = false) const; const iString GetFile(const iString & file, int skip) const; bool Make(const iString &name); // // Directory naming convention for portability // static const iString& Separator(); static const iString& Current(); static void ExpandFileName(iString& name, const iString &path = ""); private: iString mDirectory; iOrderedArray mFiles; }; #endif // IDIRECTORY_H ifrit-4.1.2/core/ierror.h0000674060175406010010000000512212641012521013611 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Some useful error reporting macros and function(s) // #ifndef IERROR_H #define IERROR_H #include "ioutput.h" #define IBUG_WARN(_m_) { iOutput::ReportBug(_m_,__FILE__,__LINE__,2); } #define IBUG_ERROR(_m_) { iOutput::ReportBug(_m_,__FILE__,__LINE__,1); } #define IBUG_FATAL(_m_) { iOutput::ReportBug(_m_,__FILE__,__LINE__,0); } #define IASSERT(_p_) { if((_p_) == 0) IBUG_FATAL("Invalid use of a null pointer."); } #define IERROR_CHECK_MEMORY(_p_) { if((_p_) == 0) iOutput::ReportBug("There is not enough memory to proceed.",__FILE__,__LINE__,-1); } // // error-reporting dynamic_cast - make it a global function to reduce de-referencing // (ideally we would avoid using it all - use iRequiredCast(INFO,vtkObject*) function whenever possible). // template inline O* iDynamicCast(int line, const char *file, I* p) { if(p == 0) return 0; O* tmp = dynamic_cast(p); if(tmp == 0) iOutput::ReportBug("Invalid cast.",file,line,0); return tmp; } // // RequiredCast for children of vtkObjectBase (which must be all cast-able objects) // class vtkObjectBase; template inline O* iRequiredCast(int line, const char *file, vtkObjectBase *p) { if(p == 0) return 0; O* tmp = O::SafeDownCast(p); if(tmp == 0) iOutput::ReportBug("Invalid cast.",file,line,0); return tmp; } #define INFO __LINE__,__FILE__ #endif // IERROR_H ifrit-4.1.2/core/ieventobserver.cpp0000674060175406010010000000343512641012552015715 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ieventobserver.h" #include "ierror.h" #include "ivtk.h" bool iEventObserver::mAllAreBlocked = false; // // Parent class for all event observers // iEventObserver::iEventObserver() { mIsBlocked = mLockedExecute = false; this->PassiveObserverOn(); // O-ho-ho, VTK guys - how I wish you messed less with the basic interface... } iEventObserver::~iEventObserver() { } void iEventObserver::Execute(vtkObject *caller, unsigned long event, void *data) { if(mAllAreBlocked || mIsBlocked) return; this->ExecuteBody(caller,event,data); } ifrit-4.1.2/core/ieventobserver.h0000674060175406010010000000371412641012521015356 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Base classes for event observers // #ifndef IEVENTOBSERVER_H #define IEVENTOBSERVER_H #include #include class iEventObserver : public vtkCommand { public: vtkTypeMacro(iEventObserver,vtkCommand); static void BlockAllEventObservers(bool s){ mAllAreBlocked = s; } void Block(bool s){ mIsBlocked = s; } virtual void Execute(vtkObject *caller, unsigned long event, void *data); protected: iEventObserver(); virtual ~iEventObserver(); void SetLockedExecute(bool s){ mLockedExecute = s; } virtual void ExecuteBody(vtkObject *caller, unsigned long event, void *data) = 0; private: static bool mAllAreBlocked; bool mIsBlocked, mLockedExecute; }; #endif // IEVENTOBSERVER_H ifrit-4.1.2/core/iexception.cpp0000674060175406010010000000253512641012552015022 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iexception.h" namespace iException { int Dummy = 0; // just a placeholder for the future }; ifrit-4.1.2/core/iexception.h0000674060175406010010000000271512641012521014463 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Exceptions used by IFRIT // #ifndef IEXCEPTION_H #define IEXCEPTION_H namespace iException { struct TotalDisaster { }; struct GlobalExit { }; struct UnableToOutput { }; }; #endif // IEXCEPTION_H ifrit-4.1.2/core/iextendableobject.cpp0000674060175406010010000000544412641012552016330 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iextendableobject.h" #include "idata.h" // // Templates // #include "iarray.tlh" #include "iproperty.tlh" // // Helper class // iObjectExtension::iObjectExtension(iExtendableObject *owner, const iString &fname, const iString &sname) : iObject(owner,fname,sname) { IASSERT(owner); mOwner = owner; mRenderMode = owner->GetRenderMode(); } iObjectExtension::~iObjectExtension() { } // // Main class // iExtendableObject::iExtendableObject(iObject *parent, const iString &fname, const iString &sname) : iObject(parent,fname,sname) { } iExtendableObject::~iExtendableObject() { while(mExtensions.Size() > 0) mExtensions.RemoveLast()->Delete(); } iObjectExtension* iExtendableObject::GetExtensionByName(const iString &name) const { int i; for(i=0; iLongName() == name) return mExtensions[i]; return 0; } iObjectExtension* iExtendableObject::GetExtensionByClassName(const iString &name) const { int i; for(i=0; iIsA(name.ToCharPointer())) return mExtensions[i]; return 0; } void iExtendableObject::InstallExtension(iObjectExtension *object) { IASSERT(object); mExtensions.AddUnique(object); // // We don't treat extensions as children // mChildren.Remove(object); // // Register extension properties // int j; for(j=0; jmVariableProperties.Size(); j++) { mVariableProperties.Add(object->mVariableProperties[j]); } for(j=0; jmFunctionProperties.Size(); j++) { mFunctionProperties.Add(object->mFunctionProperties[j]); } } ifrit-4.1.2/core/iextendableobject.h0000674060175406010010000001001312641012521015755 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // This a base class for objects that have other objects installed to them as extensions. // #ifndef IEXTENDABLEOBJECT_H #define IEXTENDABLEOBJECT_H #include "iobject.h" #include "iarray.h" class iDataInfo; class iExtendableObject; class iObjectExtension : public iObject { friend class iExtendableObject; public: vtkTypeMacro(iObjectExtension,iObject); protected: iObjectExtension(iExtendableObject *owner, const iString &fname, const iString &sname); virtual ~iObjectExtension(); iExtendableObject* Owner() const { return mOwner; } private: iExtendableObject* mOwner; }; class iExtendableObject : public iObject { friend class iObjectFactory; public: vtkTypeMacro(iExtendableObject,iObject); inline iObjectExtension* GetExtension(int n) const { return mExtensions[n]; } // will return 0 if out of bounds iObjectExtension* GetExtensionByName(const iString &name) const; // will return 0 if none has this name; if more than one has the same name, the first one will be returned iObjectExtension* GetExtensionByClassName(const iString &name) const; // will return 0 if none has this name; if more than one has the same name, the first one will be returned protected: iExtendableObject(iObject *parent, const iString &fname, const iString &sname); virtual ~iExtendableObject(); iLookupArray mExtensions; private: // // Constructor helpers accessible to iExtensionFactory only // void InstallExtension(iObjectExtension *object); }; // // Useful macros // #define iObjectExtensionDeclareCommonMacro(_owner_,_self_) \ public: \ static _self_* Self(_owner_ *owner) #define iObjectExtensionDeclareAbstractMacro(_owner_) \ iObjectExtensionDeclareCommonMacro(_owner_,_owner_##Extension); \ vtkTypeMacro(_owner_##Extension,iObjectExtension); \ protected: \ _owner_ *mRealOwner; \ _owner_##Extension(_owner_ *owner, const iString &fname, const iString &sname) #define iObjectExtensionDeclareSpecificMacro(_owner_,_self_) \ iObjectExtensionDeclareCommonMacro(_owner_,_self_); \ vtkTypeMacro(_self_,_owner_##Extension); \ protected: \ _self_(_owner_ *owner) #define iObjectExtensionDefineCommonMacro(_owner_,_self_) \ _self_* _self_::Self(_owner_ *owner) \ { \ return iRequiredCast<_self_>(INFO,owner->GetExtensionByClassName(#_self_)); \ } #define iObjectExtensionAbstractConstructorBeginMacro(_owner_) \ iObjectExtensionDefineCommonMacro(_owner_,_owner_##Extension) \ _owner_##Extension::_owner_##Extension(_owner_ *owner, const iString &fname, const iString &sname) : iObjectExtension(owner,fname,sname), mRealOwner(owner) #define iObjectExtensionSpecificConstructorBeginMacro(_owner_,_self_) \ iObjectExtensionDefineCommonMacro(_owner_,_self_) \ _self_::_self_(_owner_ *owner) : _owner_##Extension(owner,owner->LongName(),owner->ShortName()) #endif ifrit-4.1.2/core/ifieldglyphpipeline.cpp0000674060175406010010000000560612641012552016703 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ifieldglyphpipeline.h" #include "idatalimits.h" #include "ifieldviewsubject.h" #include "ireplicatedpolydata.h" #include "iresampleimagedatafilter.h" // // Templates (needed for some compilers) // #include "iarray.tlh" #include "igenericfilter.tlh" #include "iviewsubjectpipeline.tlh" iPipelineKeyDefineMacro(iFieldGlyphPipeline,GlyphSize); iPipelineKeyDefineMacro(iFieldGlyphPipeline,GlyphSampleRate); // // generic iFieldGlyphPipeline class // iFieldGlyphPipeline::iFieldGlyphPipeline(iFieldViewInstance *owner) : iReplicatedViewSubjectPipeline(owner,1) { mOwner = owner; // // Do VTK stuff // mResampleFilter = this->CreateFilter(); } iFieldGlyphPipeline::~iFieldGlyphPipeline() { } bool iFieldGlyphPipeline::PrepareInput() { vtkDataSet *input = this->InputData(); if(mResampleFilter!=0 && input->IsA("vtkImageData")) // this is so that child classes can circumvent the resample filter by deleting it. { vtkImageData *inp = vtkImageData::SafeDownCast(input); if(mResampleFilter->InputData() != inp) { mResampleFilter->SetInputData(inp); } } else { this->SetGlyphFilterInput(input); } // // Needed so that the glyph size is correct // this->UpdateGlyphSize(); return true; } void iFieldGlyphPipeline::UpdateGlyphSize() { // // Do not update unless necessary // if(mOwner->CanBeShown()) { double s = 10.0*mOwner->GetGlyphSize()*2.0/this->GetLimits()->GetMax(0); // 2.0 is the box size this->SetGlyphFilterScale(s); this->Modified(); } } void iFieldGlyphPipeline::UpdateGlyphSampleRate() { mResampleFilter->SetResampleRate(mOwner->GetGlyphSampleRate()); this->Modified(); } ifrit-4.1.2/core/ifieldglyphpipeline.h0000674060175406010010000000403312641012522016336 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IFIELDGLYPHPIPELINE_H #define IFIELDGLYPHPIPELINE_H #include "ireplicatedviewsubjectpipeline.h" class iFieldViewInstance; class iResampleImageDataFilter; class iFieldGlyphPipeline : public iReplicatedViewSubjectPipeline { public: vtkTypeMacro(iFieldGlyphPipeline,iReplicatedViewSubjectPipeline); iPipelineKeyDeclareMacro(iFieldGlyphPipeline,GlyphSize); iPipelineKeyDeclareMacro(iFieldGlyphPipeline,GlyphSampleRate); protected: iFieldGlyphPipeline(iFieldViewInstance *owner); virtual ~iFieldGlyphPipeline(); virtual bool PrepareInput(); virtual void SetGlyphFilterInput(vtkDataSet *input) = 0; virtual void SetGlyphFilterScale(double s) = 0; // // Our members // iFieldViewInstance *mOwner; iResampleImageDataFilter *mResampleFilter; }; #endif // IFIELDGLYPHPIPELINE_H ifrit-4.1.2/core/ifieldviewsubject.cpp0000674060175406010010000000753512641012552016367 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ifieldviewsubject.h" #include "iactor.h" #include "icolorbar.h" #include "idatareader.h" #include "idatasubject.h" #include "imergedatafilter.h" #include "iviewmodule.h" #include // // Templates (needed for some compilers) // #include "iarray.tlh" #include "igenericfilter.tlh" #include "iproperty.tlh" using namespace iParameter; // // Single instance class // iFieldViewInstance::iFieldViewInstance(iFieldViewSubject *owner, int numactors) : iPaintedViewInstance(owner,numactors,1.0,1,ColorBarPriority::Field,false) { mGlyphSize = 0.1; mGlyphSampleRate = 16; this->AddSecondaryDataType(owner->GetPaintingDataType()); // // Do VTK stuff // mMergeDataFilter = iMergeDataFilter::New(this); IERROR_CHECK_MEMORY(mMergeDataFilter); } iFieldViewInstance::~iFieldViewInstance() { mMergeDataFilter->Delete(); } iFieldViewSubject* iFieldViewInstance::Owner() const { return iRequiredCast(INFO,this->iPaintedViewInstance::Owner()); } bool iFieldViewInstance::SetGlyphSize(float v) { if(v < 10.0) { mGlyphSize = v; this->UpdateGlyphSize(); return true; } else return false; } bool iFieldViewInstance::SetGlyphSampleRate(int v) { if(v>0 && v<1000) { mGlyphSampleRate = v; this->UpdateGlyphSampleRate(); return true; } else return false; } bool iFieldViewInstance::IsConnectedToPaintingData() const { if(this->IsThereData()) { return mMergeDataFilter->HasData(0); } else return true; } bool iFieldViewInstance::SyncWithDataBody() { if(this->IsThereData()) { mMergeDataFilter->SetInputData(1,this->GetViewModule()->GetReader()->GetData(this->Owner()->GetPaintingDataType())); mMergeDataFilter->SetInputData(0,this->GetSubject()->GetData()); mMergeDataFilter->Update(); this->ResetPipelineInput(mMergeDataFilter->OutputData()); } return true; } iFieldViewSubject::iFieldViewSubject(iObject *parent, const iString &fname, const iString &sname, iViewModule *vm, const iDataType &type, const iDataType &sdt, unsigned int flags) : iPaintedViewSubject(parent,fname,sname,vm,type,sdt,flags,1,1), iViewSubjectPropertyConstructMacro(Float,iFieldViewInstance,GlyphSize,gs), iViewSubjectPropertyConstructMacro(Int,iFieldViewInstance,GlyphSampleRate,gr), iObjectConstructPropertyMacroQ(Bool,iFieldViewSubject,IsConnectedToScalars,cs) { this->AddSecondaryDataType(mPaintingDataType); } iFieldViewSubject::~iFieldViewSubject() { } bool iFieldViewSubject::GetIsConnectedToScalars() const { int i; for(i=0; i(INFO,mInstances[i])->IsConnectedToPaintingData()) return false; } return true; } ifrit-4.1.2/core/ifieldviewsubject.h0000674060175406010010000000477212641012522016031 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IFIELDVIEWSUBJECT_H #define IFIELDVIEWSUBJECT_H #include "ipaintedviewsubject.h" class iFieldViewSubject; class iMergeDataFilter; class iViewModule; class iFieldViewInstance : public iPaintedViewInstance { friend class iFieldViewSubject; public: iDataConsumerTypeMacro(iFieldViewInstance,iPaintedViewInstance); iObjectSlotMacro1SV(GlyphSize,float); iObjectSlotMacro1SV(GlyphSampleRate,int); protected: iFieldViewInstance(iFieldViewSubject *owner, int numactors); virtual ~iFieldViewInstance(); iFieldViewSubject* Owner() const; virtual bool IsConnectedToPaintingData() const; virtual void UpdateGlyphSize() = 0; virtual void UpdateGlyphSampleRate() = 0; virtual void ResetPipelineInput(vtkDataSet *input) = 0; iMergeDataFilter *mMergeDataFilter; }; class iFieldViewSubject : public iPaintedViewSubject { public: iDataConsumerTypeMacroPass(iFieldViewSubject,iPaintedViewSubject); iType::vsp_float GlyphSize; iType::vsp_int GlyphSampleRate; iObjectPropertyMacro2Q(IsConnectedToScalars,Bool); protected: iFieldViewSubject(iObject *parent, const iString &fname, const iString &sname, iViewModule *vm, const iDataType &type, const iDataType &sdt, unsigned int flags); virtual ~iFieldViewSubject(); }; #endif // IFIELDVIEWSUBJECT_H ifrit-4.1.2/core/ifile.cpp0000674060175406010010000001130212641012552013733 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ifile.h" #include "ierror.h" #include // // VTK guys do that - so, there must be a good reason // #ifdef read #undef read #endif #ifdef write #undef write #endif #ifdef close #undef close #endif struct iFilePosition { #ifndef VTK_USE_ANSI_STDLIB #ifdef _WIN32 streampos Value; #else istream::pos_type Value; #endif #else istream::pos_type Value; #endif }; iFile::iFile(const iString &n) { mName = n; mStream = new fstream(); IERROR_CHECK_MEMORY(mStream); mMaxMarker = 0; mNumMarker = 0; mMarker = 0; } iFile::~iFile() { delete mStream; if(mMarker != 0) delete mMarker; } void iFile::SetName(const iString &n) { this->Close(); mName = n; } bool iFile::Open(OpenMode mode, OpenType type) { int om = 0; if(mode & _Read) { om |= ios::in; #ifndef VTK_USE_ANSI_STDLIB om |= ios::nocreate; #endif } if(mode & _Write) { om |= ios::out; #ifndef VTK_USE_ANSI_STDLIB om |= !ios::nocreate; #endif } if(mode & _Append) { om = ios::out | ios::app; // append is exclusive #ifndef VTK_USE_ANSI_STDLIB om |= !ios::nocreate; #endif } if(type == _Binary) { om |= ios::binary; } mStream->clear(); mStream->open(mName.ToCharPointer(),ios::openmode(om)); return (mStream->fail()==0); } void iFile::Close() { mStream->clear(); mStream->close(); } bool iFile::ReadLine(iString &s, int max) { const int nbuf = 256; char buf[nbuf]; int n, r = 0; bool cont; mStream->clear(); s.Clear(); if(max < 1) return true; do { n = nbuf; if(n > max-r+1) n = max - r + 1; mStream->getline(buf,n); if(mStream->gcount() < n-1) { cont = false; } else { if(mStream->fail()!=0) { mStream->clear(); cont = true; } else { cont = false; } } if(mStream->fail()!=0 || mStream->eof()!=0) return false; s += buf; r += n-1; } while(cont && rclear(); mStream->read((char *)p,length); #ifdef I_DEBUG bool f = (mStream->fail() == 0); bool e = (mStream->eof() == 0); #endif return (mStream->fail()==0 && mStream->eof()==0); } bool iFile::SkipBlock(size_t length) { mStream->clear(); mStream->seekg(length,ios::cur); return (mStream->fail()==0 && mStream->eof()==0); } bool iFile::WriteLine(const iString &s) { mStream->clear(); *mStream << s.ToCharPointer() << endl; bool ret = (mStream->fail()==0 && mStream->eof()==0); mStream->flush(); return ret; } bool iFile::Rewind() { mStream->clear(); mStream->seekg(0); return (mStream->fail()==0 && mStream->eof()==0); } bool iFile::IsReadable(const iString &name) { iFile F(name); if(!F.Open(_Read,_Text)) return false; F.Close(); return true; } bool iFile::IsWritable(const iString &name) { iFile F(name); if(!F.Open(_ReadWrite,_Text)) return false; F.Close(); return true; } int iFile::SetMarker() { if(mNumMarker == mMaxMarker) { mMaxMarker += 100; iFilePosition *tmp = new iFilePosition[mMaxMarker]; IERROR_CHECK_MEMORY(tmp); if(mMarker != 0) { for(int i=0; itellg(); return mNumMarker++; } bool iFile::ReturnToMarker(int m, bool remove) { if(m<0 || m>=mNumMarker) return false; mStream->clear(); mStream->seekg(mMarker[m].Value); bool ret = (mStream->fail()==0 && mStream->eof()==0); if(remove) { for(int i=m; i struct iFilePosition; // this structure encapsulates file position type class iFile { public: enum OpenMode { _None = 0, _Read = 1, _Write = 2, _ReadWrite = 3, _Append = 4 }; enum OpenType { _Text = 0, _Binary = 1 }; iFile(const iString &name); ~iFile(); // // Open & close // void SetName(const iString &name); bool Open(OpenMode mode, OpenType type); void Close(); // // Reading // bool ReadLine(iString &s, int max = iString::MaxLength); bool ReadBlock(void *p, size_t length); // // Writing // bool WriteLine(const iString &s); // // Skipping // bool SkipBlock(size_t length); // // (Semi-)Random access // bool Rewind(); int SetMarker(); // marks the current location bool ReturnToMarker(int marker, bool remove = false); // returns to a given location int GetNumberOfMarkers() const { return mNumMarker; } // // Properties // static bool IsReadable(const iString &name); static bool IsWritable(const iString &name); inline const iString& GetName() const { return mName; } private: fstream *mStream; iString mName; iFilePosition *mMarker; int mNumMarker, mMaxMarker; }; #endif // IFILE_H ifrit-4.1.2/core/ifileloader.cpp0000674060175406010010000006575212641012552015144 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ifileloader.h" #include "idata.h" #include "idataconsumer.h" #include "idatalimits.h" #include "idatareader.h" #include "idatareaderobserver.h" #include "idatasubject.h" #include "ierror.h" #include "ifile.h" #include "ihistogrammaker.h" #include "imonitor.h" #include "iparallelmanager.h" #include "ishell.h" #include "ishelleventobservers.h" #include "isystem.h" #include "iviewmodule.h" #include "ivtktype.h" #include // // Templates // #include "iarray.tlh" #define IDATASUBJECT_DEFINE_SWAP_BYTES_FUNCTIONS(_type_) \ void iFileLoader::SwapBytes(_type_ &p) \ { \ iFileLoader_Private::SwapBytes(p); \ } \ void iFileLoader::SwapBytesRange(_type_ *p, vtkIdType count) \ { \ iFileLoader_Private::SwapBytesRange(p,count); \ } #define IDATASUBJECT_DEFINE_READ_BLOCK_FUNCTIONS(_type_) \ bool iFileLoader::ReadBlock(iFile& F, _type_ *p, vtkIdType len, double updateStart, double updateDuration) \ { \ return iFileLoader_Private::ReadBlockToArray(F,p,len,updateStart,updateDuration,mIsBigEndian!=iSystem::IsBigEndianMachine(),this->GetShell()->GetExecutionEventObserver()); \ } \ iFileLoader::ReadingBuffer iFileLoader::Buffer(_type_ &d) const \ { \ return ReadingBuffer(&d,1UL,iFileLoader_Private::TypeIndex(&d),sizeof(_type_)); \ } \ iFileLoader::ReadingBuffer iFileLoader::Buffer(_type_ *d, vtkIdType l) const \ { \ return ReadingBuffer(d,l,iFileLoader_Private::TypeIndex(d),sizeof(_type_)); \ } namespace iFileLoader_Private { // // Byte swap helpers // inline void Swap4Bytes(char* data) { char one_byte; one_byte = data[0]; data[0] = data[3]; data[3] = one_byte; one_byte = data[1]; data[1] = data[2]; data[2] = one_byte; } inline void Swap8Bytes(char* data) { char one_byte; one_byte = data[0]; data[0] = data[7]; data[7] = one_byte; one_byte = data[1]; data[1] = data[6]; data[6] = one_byte; one_byte = data[2]; data[2] = data[5]; data[5] = one_byte; one_byte = data[3]; data[3] = data[4]; data[4] = one_byte; } void Swap4BytesRange(char *data, vtkIdType count) { char *pos; vtkIdType i; pos = data; for(i = 0; i inline void SwapBytes(T &p) { switch(sizeof(T)) { case 4: { Swap4Bytes((char *)&p); break; } case 8: { Swap8Bytes((char *)&p); break; } default: { IBUG_FATAL("IFrIT was not ported to that platform."); } } } template inline void SwapBytesRange(T *p, vtkIdType count) { switch(sizeof(T)) { case 4: { Swap4BytesRange((char *)p,count); break; } case 8: { Swap8BytesRange((char *)p,count); break; } default: { IBUG_FATAL("IFrIT was not ported to that platform."); } } } // // Check validity of numbers // bool IsNumberValid(vtkTypeInt32 v){ return true; } bool IsNumberValid(vtkTypeInt64 v){ return true; } bool IsNumberValid(vtkTypeFloat32 v){ return (-iMath::_FloatMax<=v && v<=iMath::_FloatMax); } bool IsNumberValid(vtkTypeFloat64 v){ return (-iMath::_DoubleMax<=v && v<=iMath::_DoubleMax); } // // Type indices // const int _Int32 = 1; const int _Int64 = 2; const int _Float32 = 3; const int _Float64 = 4; int TypeIndex(vtkTypeInt32 *){ return _Int32; } int TypeIndex(vtkTypeInt64 *){ return _Int64; } int TypeIndex(vtkTypeFloat32 *){ return _Float32; } int TypeIndex(vtkTypeFloat64 *){ return _Float64; } // // Read blocks of data from a file // template bool ReadBlockToArray(iFile& F, T *p, vtkIdType len, double updateStart, double updateDuration, bool swapbytes, iExecutionEventObserver *observer) { const vtkIdType nline = 16384L; vtkIdType nread, l, nstep = (len+nline-1)/nline; double ustep = updateDuration/nstep; for(l=0; lIsAborted()) return true; if(l < nstep-1) nread = nline; else nread = len - nline*l; if(!F.ReadBlock(p+l*nline,nread*sizeof(T))) return false; if(ustep > 0.0) observer->SetProgress(updateStart+ustep*l); } if(swapbytes) { iFileLoader_Private::SwapBytesRange(p,len); } bool ok = true; for(l=0; ok && l bool AnalyzeFirstRecordForType(iFile &F, unsigned int len, bool &isBig) { T lrec1, lrec2; int m = F.SetMarker(); if(!F.ReadBlock(&lrec1,sizeof(T)) || !F.SkipBlock(len) || !F.ReadBlock(&lrec2,sizeof(T))) { F.ReturnToMarker(m,true); return false; // unable even to read } F.ReturnToMarker(m,true); // // Is the header/footer length ok? // if(lrec1 == lrec2) // succeeded { // // auto-detect data endiness // if(lrec1 != len) { SwapBytes(lrec1); if(lrec1 != len) return false; else isBig = !iSystem::IsBigEndianMachine(); } else isBig = iSystem::IsBigEndianMachine(); return true; } else return false; } }; using namespace iFileLoader_Private; using namespace iParameter; iFileLoader::iFileLoader(iDataReader *r, int priority) : iViewModuleComponent(r?r->GetViewModule():0), mReader(r), mReaderExtension(0), mPriority(priority) { this->Define(); } iFileLoader::iFileLoader(iDataReaderExtension *ext, int priority) : iViewModuleComponent(ext?ext->GetReader()->GetViewModule():0), mReader(ext->GetReader()), mReaderExtension(ext), mPriority(priority) { this->Define(); } void iFileLoader::Define() { IASSERT(mReader); mFortranHeaderFooterLength = -1; // mFileRoot = mFileSuffix = mLastFileName = ""; mIsBigEndian = true; mTwoCopies = false; mRecord = -1; mShift[0] = mShift[1] = mShift[2] = 0.0f; mPeriodic[0] = mPeriodic[1] = mPeriodic[2] = false; mInfo = new iDataInfo; IERROR_CHECK_MEMORY(mInfo); } iFileLoader::~iFileLoader() { delete mInfo; while(mStreams.Size() > 0) delete mStreams.RemoveLast(); } bool iFileLoader::IsUsingData(const iDataType &type) const { int i; for(i=0; iSubject->GetDataType() == type) return true; } return false; } const iDataInfo& iFileLoader::GetDataInfo() const { if(mInfo->Size() != mStreams.Size()) { mInfo->Clear(); int i; for(i=0; iSubject->GetDataType(); } return *mInfo; } const iDataType& iFileLoader::GetDataType(int n) const { if(n>=0 && nSubject->GetDataType(); else return iDataType::Null(); } vtkDataSet* iFileLoader::GetData(int n) const { if(n>=0 && nReleasedData; else return 0; } vtkDataSet* iFileLoader::GetData(const iDataType &type) const { int i; for(i=0; iSubject->GetDataType() == type) return this->GetData(i); } return 0; } iDataLimits* iFileLoader::GetLimits(int n) const { if(n>=0 && nSubject->GetLimits(); else return 0; } iDataSubject* iFileLoader::GetSubject(const iDataType &type) const { int i; for(i=0; iSubject->GetDataType() == type) return mStreams[i]->Subject; } return 0; } int iFileLoader::GetBoundaryConditions() const { return mReader->GetBoundaryConditions(); } bool iFileLoader::IsDirectionPeriodic(int d) const { if(d>=0 && d<3) { return (this->GetBoundaryConditions()==iParameter::BoundaryConditions::Periodic && mPeriodic[d]); } else return false; } void iFileLoader::SetDirectionPeriodic(int d, bool s) { if(d>=0 && d<3) { mPeriodic[d] = s; } } void iFileLoader::LoadFile(const iString &fname) { int i; double shift[3]; for(i=0; i<3; i++) shift[i] = mReader->GetShift(i); this->LoadFile(fname,shift); } void iFileLoader::LoadFile(const iString &fname, const double *shift) { int i; iMonitor h(this,"Loading file",0.8); mFortranHeaderFooterLength = -1; // must be set by a child class iString root, suffix; int record = this->DissectFileName(fname,root,suffix); this->GetShell()->GetDataReaderObserver()->StartFile(fname,this->GetDataType(0)); for(i=0; iSubject->GetLimits()->BlockNotifications(true); if(mStreams[i]->ReleasedData!=0 && !mTwoCopies) { // // The data can be referenced by other objects, so delete will not delete it. Thus, we first erase // the actual data by initializing the data object // mStreams[i]->ReleasedData->Initialize(); mStreams[i]->ReleasedData->Delete(); mStreams[i]->ReleasedData = 0; } } this->LoadFileBody(suffix,fname); for(i=0; iSubject->GetLimits()->BlockNotifications(false); } if(h.IsStopped()) { if(!mTwoCopies) this->EraseData(); return; } // // Check that we are properly configured // for(i=0; iReleasedData == 0) { IBUG_ERROR("Stream #"+iString::FromNumber(i)+" was not assigned data. This is a bug, the file has not been read properly."); if(!mTwoCopies) this->EraseData(); return; } } h.SetInterval("Shifting",0.8,0.1); mShift[0] = mShift[1] = mShift[2] = 0.0f; this->ShiftData(shift); if(h.IsStopped()) { if(!mTwoCopies) this->EraseData(); return; } mLastFileName = fname; mFileSuffix = suffix; mFileRoot = root; mRecord = record; h.SetProgress(1.0); h.SetInterval("Computing",0.9,0.1); // // Configure limits // bool overflow = false; iMonitor h1(this); for(i=0; iSubject->IsThereData()) { int var, nvars = mStreams[i]->Subject->GetHistogramMaker()->GetNumberOfComponents(); if(nvars < 0) { IBUG_ERROR("Stream #"+iString::FromNumber(i)+" has invalid data. This is a bug, the file has not been read properly."); if(!mTwoCopies) this->EraseData(); return; } mStreams[i]->Subject->GetLimits()->BlockNotifications(true); // // Try to set the requested number of variables. DataLimits will either expand to accommodate // all of them or limit the allowed number to the number of listed records. // if(!mStreams[i]->Subject->GetLimits()->Activate(nvars) || nvars!=mStreams[i]->Subject->GetLimits()->GetNumVars()) { IBUG_ERROR("Stream #"+iString::FromNumber(i)+" is unable to accommodate "+iString::FromNumber(nvars)+" fields - associated iDataLimits class has been configured incorrectly. This is a bug, the file has not been read properly."); if(!mTwoCopies) this->EraseData(); return; } iMonitor h2(this); for(var=0; varSubject->GetHistogramMaker()->GetRange(var,range); if(mStreams[i]->Subject->GetHistogramMaker()->HasOverflow(var)) overflow = true; } if(mStreams[i]->Subject->GetResetOnLoad()) { for(var=0; varSubject->GetLimits()->SetRange(var,mStreams[i]->Subject->GetHistogramMaker()->GetRange(var)); } } mStreams[i]->Subject->GetLimits()->BlockNotifications(false); iSyncWithDataRequest req(mStreams[i]->Subject->GetDataType()); this->GetViewModule()->SyncWithData(req); } h1.SetProgress(1.0); } if(overflow) { this->OutputText(MessageType::Warning,"The data are read correctly, but some values in the file were outside of range ("+iString::FromNumber(-iMath::_LargeFloat)+","+iString::FromNumber(iMath::_LargeFloat)+").\n These values were clamped to be within the required range."); } this->OutputDataDescription(); h.SetProgress(1.0); this->GetShell()->GetDataReaderObserver()->FinishFile(fname,this->GetDataInfo()); } void iFileLoader::AttachDataToStream(int i, vtkDataSet *ds) { if(i>=0 && iReleasedData != 0) { mStreams[i]->ReleasedData->Delete(); } mStreams[i]->ReleasedData = ds->NewInstance(); IERROR_CHECK_MEMORY(mStreams[i]->ReleasedData); if(mTwoCopies) { mStreams[i]->ReleasedData->DeepCopy(ds); } else { mStreams[i]->ReleasedData->ShallowCopy(ds); } this->Polish(mStreams[i]->ReleasedData); } } } bool iFileLoader::IsThereData(int n) const { if(n>=0 && nGetData(n)!=0 && this->GetData(n)->GetNumberOfPoints()>0); } else return false; } bool iFileLoader::IsThereScalarData(int n) const { if(n>=0 && nGetData(n)); } else return false; } bool iFileLoader::IsThereVectorData(int n) const { if(n>=0 && nGetData(n)); } else return false; } bool iFileLoader::IsThereTensorData(int n) const { if(n>=0 && nGetData(n)); } else return false; } bool iFileLoader::IsThereData() const { int i; for(i=0; iIsThereData(i)) return true; } return false; } bool iFileLoader::IsThereData(const iDataType &type) const { int i; for(i=0; iSubject->GetDataType() == type) return this->IsThereData(i); } return false; } void iFileLoader::EraseData() { int i; for(i=0; iReleasedData != 0) { mStreams[i]->ReleasedData->Initialize(); mStreams[i]->ReleasedData = 0; mStreams[i]->Subject->GetLimits()->Activate(-1); } // // EraseData can be called by a loader if a file load failed; in that case the data // may be in an invalid state, so send the request anyway, even if the data were not released // iSyncWithDataRequest req(mStreams[i]->Subject->GetDataType()); this->GetViewModule()->SyncWithData(req); } mRecord = -1; mShift[0] = mShift[1] = mShift[2] = 0.0f; } void iFileLoader::SetTwoCopies(bool s) { if(mTwoCopies != s) { mTwoCopies = s; } } void iFileLoader::Reset() { int i; for(i=0; iReleasedData != 0) { mStreams[i]->ReleasedData->Modified(); iSyncWithDataRequest req(mStreams[i]->Subject->GetDataType()); this->GetViewModule()->SyncWithData(req); } } void iFileLoader::ShiftData(const double *shift) { int i; double dx[3]; for(i=0; i<3; i++) dx[i] = shift[i] - mShift[i]; iMonitor h(this); for(i=0; iNumStreams(); i++) if(mStreams[i]->ReleasedData != 0) { h.SetInterval("Shifting",double(i)/this->NumStreams(),1.0/this->NumStreams()); this->ShiftDataBody(mStreams[i]->ReleasedData,dx); } for(i=0; i<3; i++) mShift[i] = shift[i]; } float iFileLoader::GetMemorySize() const { int i; float s = 0.0f; for(i=0; iReleasedData != 0) { s += mStreams[i]->ReleasedData->GetActualMemorySize(); } if(mTwoCopies) s *= 2; return s; } iFileLoader::Stream* iFileLoader::CreateNewStream() const { return new Stream(); } // // Data reading helpers // bool iFileLoader::SkipFortranRecord(iFile& F, vtkIdType len) { vtkIdType lrec1, lrec2; if(!this->ReadFortranHeaderFooter(F,lrec1)) return false; if(!F.SkipBlock(len)) return false; if(!this->ReadFortranHeaderFooter(F,lrec2)) return false; if(lrec1!=lrec2 || lrec1!=len) return false; return true; } bool iFileLoader::ReadFortranRecord(iFile& F, const ReadingBuffer &b, double updateStart, double updateDuration, bool autoswap, bool full) { vtkIdType lrec1, lrec2; if(!this->ReadFortranHeaderFooter(F,lrec1)) return false; if(full && lrec1!=b.Length*b.Size) return false; if(!ReadBlockToBuffer(F,b,updateStart,updateDuration,autoswap && mIsBigEndian!=iSystem::IsBigEndianMachine(),this->GetShell()->GetExecutionEventObserver())) return false; if(this->GetShell()->GetExecutionEventObserver()->IsAborted()) return true; if(!full && b.Length*b.SizeReadFortranHeaderFooter(F,lrec2)) return false; if(lrec1 != lrec2) return false; return true; } bool iFileLoader::ReadFortranRecord(iFile& F, const ReadingBuffer &b1, const ReadingBuffer &b2, double updateStart, double updateDuration, bool autoswap) { vtkIdType lrec1, lrec2; vtkIdType len = b1.Length*b1.Size + b2.Length*b2.Size; float f1 = float(b1.Length*b1.Size)/len; float f2 = float(b2.Length*b2.Size)/len; if(!this->ReadFortranHeaderFooter(F,lrec1)) return false; if(lrec1 != len) return false; if(!ReadBlockToBuffer(F,b1,updateStart,f1*updateDuration,autoswap && mIsBigEndian!=iSystem::IsBigEndianMachine(),this->GetShell()->GetExecutionEventObserver())) return false; if(this->GetShell()->GetExecutionEventObserver()->IsAborted()) return true; if(!ReadBlockToBuffer(F,b2,updateStart+f1*updateDuration,f2*updateDuration,autoswap && mIsBigEndian!=iSystem::IsBigEndianMachine(),this->GetShell()->GetExecutionEventObserver())) return false; if(this->GetShell()->GetExecutionEventObserver()->IsAborted()) return true; if(!this->ReadFortranHeaderFooter(F,lrec2)) return false; if(lrec1 != lrec2) return false; return true; } bool iFileLoader::ReadFortranRecord(iFile& F, const ReadingBuffer &b1, const ReadingBuffer &b2, const ReadingBuffer &b3, double updateStart, double updateDuration, bool autoswap) { vtkIdType lrec1, lrec2; vtkIdType len = b1.Length*b1.Size + b2.Length*b2.Size + b3.Length*b3.Size; float f1 = float(b1.Length*b1.Size)/len; float f2 = float(b2.Length*b2.Size)/len; float f3 = float(b3.Length*b3.Size)/len; if(!this->ReadFortranHeaderFooter(F,lrec1)) return false; if(lrec1 != len) return false; if(!ReadBlockToBuffer(F,b1,updateStart,f1*updateDuration,autoswap && mIsBigEndian!=iSystem::IsBigEndianMachine(),this->GetShell()->GetExecutionEventObserver())) return false; if(this->GetShell()->GetExecutionEventObserver()->IsAborted()) return true; if(!ReadBlockToBuffer(F,b2,updateStart+f1*updateDuration,f2*updateDuration,autoswap && mIsBigEndian!=iSystem::IsBigEndianMachine(),this->GetShell()->GetExecutionEventObserver())) return false; if(this->GetShell()->GetExecutionEventObserver()->IsAborted()) return true; if(!ReadBlockToBuffer(F,b3,updateStart+(f1+f2)*updateDuration,f3*updateDuration,autoswap && mIsBigEndian!=iSystem::IsBigEndianMachine(),this->GetShell()->GetExecutionEventObserver())) return false; if(this->GetShell()->GetExecutionEventObserver()->IsAborted()) return true; if(!this->ReadFortranHeaderFooter(F,lrec2)) return false; if(lrec1 != lrec2) return false; return true; } bool iFileLoader::ReadFortranRecord(iFile& F, int nbufs, const ReadingBuffer *b, double updateStart, double updateDuration, bool autoswap) // read any number of buffers { vtkIdType lrec1, lrec2; if(b==0 || nbufs<=0 || !this->ReadFortranHeaderFooter(F,lrec1)) return false; updateDuration /= nbufs; int i; vtkIdType len = 0L; for(i=0; iGetShell()->GetExecutionEventObserver())) return false; if(this->GetShell()->GetExecutionEventObserver()->IsAborted()) return true; } if(!this->ReadFortranHeaderFooter(F,lrec2)) return false; if(lrec1!=lrec2 || lrec1!=len) return false; return true; } bool iFileLoader::ReadFortranHeaderFooter(iFile& F, vtkIdType &lrec) { bool ret = false; if(mFortranHeaderFooterLength == 8) { vtkTypeInt64 ltmp; ret = F.ReadBlock(<mp,8); if(ret) { if(mIsBigEndian != iSystem::IsBigEndianMachine()) this->SwapBytes(ltmp); if(sizeof(vtkIdType) < 8) { IBUG_WARN("VTK is compiled with 32-bit Ids. The record length of this file is 64-bits, it cannot be read with this VTK installation. To be able to read this file you will have to recompile VTK with the advanced option VTK_USE_64BIT_IDS set to ON and then recompile IFrIT."); return false; } lrec = (vtkTypeUInt64)ltmp; } } else if(mFortranHeaderFooterLength == 4) { vtkTypeInt32 ltmp; ret = F.ReadBlock(<mp,4); if(ret) { if(mIsBigEndian != iSystem::IsBigEndianMachine()) this->SwapBytes(ltmp); lrec = (vtkTypeUInt32)ltmp; } } else { IBUG_WARN("Invalid Fortran header/footer length."); } return ret; } bool iFileLoader::DetectFortranFileStructure(iFile &F, vtkIdType len) { // // Try 4-byte records // if(AnalyzeFirstRecordForType(F,len,mIsBigEndian)) { mFortranHeaderFooterLength = sizeof(vtkTypeInt32); return true; } // // Try 8-byte records // if(AnalyzeFirstRecordForType(F,len,mIsBigEndian)) { mFortranHeaderFooterLength = sizeof(vtkTypeInt64); return true; } // // Failed to figure it out // return false; } iString iFileLoader::GetRecordAsString(int rec) const { const iString format = "%0" + iString::FromNumber(mReader->GetRecordLength()) + "d"; return iString::FromNumber(rec,format.ToCharPointer()); } int iFileLoader::DissectFileName(const iString &fname, iString &root, iString &suffix) const { bool ok; int rec; if(fname.Contains('.') > 0) { suffix = fname.Section(".",-1); root = fname.Part(0,fname.Length()-suffix.Length()-1); } else { suffix.Clear(); root = fname; } iString record = root.Part(-mReader->GetRecordLength()); rec = record.ToInt(ok); if(!ok || record!=this->GetRecordAsString(rec) || rec<0) { return -1; } else { root = root.Part(0,root.Length()-mReader->GetRecordLength()); return rec; } } const iString iFileLoader::GetFileName(int rec) const { if(mFileSuffix.IsEmpty()) { return mFileRoot + this->GetRecordAsString(rec); } else { return mFileRoot + this->GetRecordAsString(rec) + "." + mFileSuffix; } } bool iFileLoader::IsSeriesFileName(const iString &fname) const { iString root, suffix; int rec = this->DissectFileName(fname,root,suffix); return (rec>=0 && root==mFileRoot && suffix==mFileSuffix); } // // Optional final touch // void iFileLoader::Polish(vtkDataSet *data) { } // // Overloads // IDATASUBJECT_DEFINE_SWAP_BYTES_FUNCTIONS(vtkTypeInt32); IDATASUBJECT_DEFINE_SWAP_BYTES_FUNCTIONS(vtkTypeInt64); IDATASUBJECT_DEFINE_SWAP_BYTES_FUNCTIONS(vtkTypeFloat32); IDATASUBJECT_DEFINE_SWAP_BYTES_FUNCTIONS(vtkTypeFloat64); IDATASUBJECT_DEFINE_READ_BLOCK_FUNCTIONS(vtkTypeInt32); IDATASUBJECT_DEFINE_READ_BLOCK_FUNCTIONS(vtkTypeInt64); IDATASUBJECT_DEFINE_READ_BLOCK_FUNCTIONS(vtkTypeFloat32); IDATASUBJECT_DEFINE_READ_BLOCK_FUNCTIONS(vtkTypeFloat64); // // Helper class // iFileLoader::Stream::Stream() { Subject = 0; ReleasedData = 0; Periodic[0] = Periodic[1] = Periodic[2] = false; } iFileLoader::Stream::~Stream() { if(ReleasedData != 0) ReleasedData->Delete(); if(Subject != 0) Subject->Delete(); } #include #include #include #include void iFileLoader::OutputDataDescription() const { int j; this->OutputText(MessageType::Information,"File: "+mLastFileName); for(j=0; jNumStreams(); j++) { const iDataType &type(mStreams[j]->Subject->GetDataType()); vtkDataSet *data = mStreams[j]->ReleasedData; if(data == 0) continue; // // DataType and VTK class names // this->OutputText(MessageType::Information,"\tStream: "+type.TextName()+" ( VTK class name: "+data->GetClassName()+")"); if(mStreams[j]->Periodic[0] || mStreams[j]->Periodic[1] || mStreams[j]->Periodic[2]) { this->OutputText(MessageType::Information,iString("\t\tPeriodic directions: ")+(mStreams[j]->Periodic[0]?"X ":"")+(mStreams[j]->Periodic[0]?"Y ":"")+(mStreams[j]->Periodic[2]?"Z":"")); } // // Are we ImageData? // vtkImageData *im = vtkImageData::SafeDownCast(data); if(im != 0) { int dims[3]; im->GetDimensions(dims); this->OutputText(MessageType::Information,"\t\tDimensions = "+iString::FromNumber(dims[0])+" x "+iString::FromNumber(dims[1])+" x "+iString::FromNumber(dims[2])); } vtkPolyData *pl = vtkPolyData::SafeDownCast(data); if(pl != 0) { this->OutputText(MessageType::Information," Number of particles = "+iString::FromNumber(pl->GetNumberOfPoints())); } vtkPointData *pd = data->GetPointData(); if(pd!=0 && pd->GetScalars() != 0) { this->OutputText(MessageType::Information," Number of scalar components = "+iString::FromNumber(pd->GetScalars()->GetNumberOfComponents())); } if(pd!=0 && pd->GetVectors() != 0) { this->OutputText(MessageType::Information," Number of vector components = "+iString::FromNumber(pd->GetVectors()->GetNumberOfComponents())); } if(pd!=0 && pd->GetTensors() != 0) { this->OutputText(MessageType::Information," Number of tensor components = "+iString::FromNumber(pd->GetTensors()->GetNumberOfComponents())); } int i; for(i=0; iSubject->GetLimits()->GetNumVars(); i++) { float range[2]; mStreams[j]->Subject->GetHistogramMaker()->GetRange(i,range); this->OutputText(MessageType::Information," "+mStreams[j]->Subject->GetLimits()->GetName(i)+" from "+iString::FromNumber(range[0])+" ("+iString::FromNumber(iMath::Log10(1.0e-30+fabs(range[0])))+" dex) to "+iString::FromNumber(range[1])+" ("+iString::FromNumber(iMath::Log10(1.0e-30+fabs(range[1])))+" dex)"); } } } ifrit-4.1.2/core/ifileloader.h0000674060175406010010000001634012641012522014573 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A base class for all classes for reading data files. Each iFileLoader loads a single kind of data, // but may provide data for multiple data types. // #ifndef IFILELOADER_H #define IFILELOADER_H #include #include "iviewmodulecomponent.h" #include "iarray.h" #include "istring.h" #include class iDataLimits; class iDataReader; class iDataReaderExtension; class iDataSubject; class iDataInfo; class iDataType; class iFile; class vtkDataSet; namespace iParameter { // // Data parameters // namespace BoundaryConditions { const int None = 0; const int Periodic = 1; inline bool IsValid(int m){ return m>=0 && m<=1; } }; }; // // Helper macros // #define IDATAFILELOADER_DECLARE_SWAP_BYTES_FUNCTIONS(_type_) \ static void SwapBytes(_type_ &p); \ static void SwapBytesRange(_type_ *data, vtkIdType count) #define IDATAFILELOADER_DECLARE_READ_BLOCK_FUNCTIONS(_type_) \ bool ReadBlock(iFile& F, _type_ *p, vtkIdType len, double updateStart = 0.0, double updateDuration = 0.0); \ ReadingBuffer Buffer(_type_ &d) const; \ ReadingBuffer Buffer(_type_ *d, vtkIdType l) const class iFileLoader : public vtkObjectBase, public iViewModuleComponent { friend class iDataReader; friend class iDataSubject; public: vtkTypeMacro(iFileLoader,vtkObjectBase); IDATAFILELOADER_DECLARE_SWAP_BYTES_FUNCTIONS(vtkTypeInt32); IDATAFILELOADER_DECLARE_SWAP_BYTES_FUNCTIONS(vtkTypeInt64); IDATAFILELOADER_DECLARE_SWAP_BYTES_FUNCTIONS(vtkTypeFloat32); IDATAFILELOADER_DECLARE_SWAP_BYTES_FUNCTIONS(vtkTypeFloat64); // // Operation on data // void LoadFile(const iString &fname); void LoadFile(const iString &fname, const double *shift); void EraseData(); void Reset(); void ShiftData(const double *shift); inline bool IsTwoCopies() const { return mTwoCopies; } void SetTwoCopies(bool s); inline bool IsAnimatable() const { return (mRecord >= 0); } inline const iString& GetLastFileName() const { return mLastFileName; } inline const iString GetFileRoot() const { return mFileRoot; } virtual const iString GetFileName(int rec) const; iString GetRecordAsString(int rec) const; bool IsSeriesFileName(const iString &fname) const; virtual float GetMemorySize() const; // // Boundary conditions // int GetBoundaryConditions() const; bool IsDirectionPeriodic(int d) const; // // Access to components // inline iDataReader* GetReader() const { return mReader; } inline iDataReaderExtension* GetReaderExtension() const { return mReaderExtension; } bool IsThereData() const; virtual bool IsThereData(int n) const; virtual bool IsThereScalarData(int n) const; virtual bool IsThereVectorData(int n) const; virtual bool IsThereTensorData(int n) const; virtual vtkDataSet* GetData(int n) const; bool IsUsingData(const iDataType &type) const; const iDataType& GetDataType(int n) const; const iDataInfo& GetDataInfo() const; virtual int DissectFileName(const iString &fname, iString &root, iString &suffix) const; inline int NumStreams() const { return mStreams.Size(); } bool IsThereData(const iDataType &type) const; vtkDataSet* GetData(const iDataType &type) const; // // Some of children and collaborating loaders may need access to subject limits, // but they should not use subjects directly. // virtual iDataLimits* GetLimits(int n) const; inline int GetPriority() const { return mPriority; } // // Helper struct // struct ReadingBuffer { void *Data; vtkIdType Length; int Type, Size; ReadingBuffer(void *d, vtkIdType l, int t, int s) { Data = d; Length = l; Type = t; Size = s; } }; protected: iFileLoader(iDataReader *r, int priority); iFileLoader(iDataReaderExtension *ext, int priority); virtual ~iFileLoader(); virtual void LoadFileBody(const iString &suffix, const iString &fname) = 0; virtual void ShiftDataBody(vtkDataSet *data, const double *dx) = 0; virtual void Polish(vtkDataSet *data); // optional final touch // // Output information about the data. // virtual void OutputDataDescription() const; // // File reading helpers // IDATAFILELOADER_DECLARE_READ_BLOCK_FUNCTIONS(vtkTypeInt32); IDATAFILELOADER_DECLARE_READ_BLOCK_FUNCTIONS(vtkTypeInt64); IDATAFILELOADER_DECLARE_READ_BLOCK_FUNCTIONS(vtkTypeFloat32); IDATAFILELOADER_DECLARE_READ_BLOCK_FUNCTIONS(vtkTypeFloat64); bool DetectFortranFileStructure(iFile &F, vtkIdType len); bool ReadFortranHeaderFooter(iFile& F, vtkIdType &lrec); bool SkipFortranRecord(iFile& F, vtkIdType len); bool ReadFortranRecord(iFile& F, const ReadingBuffer &b, double updateStart = 0.0, double updateDuration = 0.0, bool autoswap = true, bool full = true); bool ReadFortranRecord(iFile& F, const ReadingBuffer &b1, const ReadingBuffer &b2, double updateStart = 0.0, double updateDuration = 0.0, bool autoswap = true); bool ReadFortranRecord(iFile& F, const ReadingBuffer &b1, const ReadingBuffer &b2, const ReadingBuffer &b3, double updateStart = 0.0, double updateDuration = 0.0, bool autoswap = true); bool ReadFortranRecord(iFile& F, int nbufs, const ReadingBuffer *b, double updateStart = 0.0, double updateDuration = 0.0, bool autoswap = true); // read any number of buffers void SetDirectionPeriodic(int d, bool s); // // Data management // struct Stream { iDataSubject *Subject; vtkDataSet *ReleasedData; bool Periodic[3]; Stream(); virtual ~Stream(); }; virtual Stream* CreateNewStream() const; inline Stream* GetStream(int i) const { return mStreams[i]; } // no bound checking for speed void AttachDataToStream(int i, vtkDataSet *ds); // // Components // bool mPeriodic[3]; bool mTwoCopies, mIsBigEndian; int mRecord, mFortranHeaderFooterLength; private: void Define(); double mShift[3]; const int mPriority; iString mFileRoot, mFileSuffix, mLastFileName; iDataReader *mReader; iDataReaderExtension *mReaderExtension; mutable iDataInfo *mInfo; iArray mStreams; // // Loaders should not be really accessing subjects, that may create cyclic dependency // iDataSubject* GetSubject(const iDataType &type) const; }; #endif // IFILELOADER_H ifrit-4.1.2/core/iflipnormalsfilter.cpp0000674060175406010010000000302112641012552016547 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iflipnormalsfilter.h" // // Templates // #include "igenericfilter.tlh" iFlipNormalsFilter::iFlipNormalsFilter(iDataConsumer *consumer) : iGenericPolyDataFilter(consumer,1,true) { } void iFlipNormalsFilter::ProvideOutput() { this->ExecuteParent(); } ifrit-4.1.2/core/iflipnormalsfilter.h0000674060175406010010000000310712641012522016216 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IFLIPNORMALSFILTER_H #define IFLIPNORMALSFILTER_H #include "igenericfilter.h" #include class iFlipNormalsFilter : public iGenericPolyDataFilter { iGenericFilterTypeMacro(iFlipNormalsFilter,vtkReverseSense); protected: virtual void ProvideOutput(); }; #endif // IFLIPNORMALSFILTER_H ifrit-4.1.2/core/iframedtextactor.cpp0000674060175406010010000001206212641012553016215 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iframedtextactor.h" #include "ierror.h" #include "ioverlayhelper.h" #include #include #include #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "igenericprop.tlh" iFramedTextActor* iFramedTextActor::New(iRenderTool *rt) { IASSERT(rt); return new iFramedTextActor(rt); } iFramedTextActor::iFramedTextActor(iRenderTool *rt) : iTextActor(rt) { this->SetPadding(0.02); vtkPolyData *data; vtkCellArray *cells; vtkPolyDataMapper2D *mapper; vtkCoordinate *coord; mBorderPoints = vtkPoints::New(VTK_FLOAT); IERROR_CHECK_MEMORY(mBorderPoints); mBorderPoints->SetNumberOfPoints(4); // // Border // data = vtkPolyData::New(); IERROR_CHECK_MEMORY(data); data->SetPoints(mBorderPoints); cells = vtkCellArray::New(); IERROR_CHECK_MEMORY(cells); cells->InsertNextCell(5); cells->InsertCellPoint(0); cells->InsertCellPoint(1); cells->InsertCellPoint(2); cells->InsertCellPoint(3); cells->InsertCellPoint(0); data->SetLines(cells); cells->Delete(); mapper = vtkPolyDataMapper2D::New(); IERROR_CHECK_MEMORY(mapper); mapper->SetInputData(data); data->Delete(); coord = vtkCoordinate::New(); IERROR_CHECK_MEMORY(coord); coord->SetCoordinateSystemToNormalizedViewport(); mapper->SetTransformCoordinate(coord); coord->Delete(); mBorderActor = vtkActor2D::New(); IERROR_CHECK_MEMORY(mBorderActor); this->PrependComponent(mBorderActor); mBorderActor->SetMapper(mapper); mapper->Delete(); // // Lining // data = vtkPolyData::New(); IERROR_CHECK_MEMORY(data); data->SetPoints(mBorderPoints); cells = vtkCellArray::New(); IERROR_CHECK_MEMORY(cells); cells->InsertNextCell(4); cells->InsertCellPoint(0); cells->InsertCellPoint(1); cells->InsertCellPoint(2); cells->InsertCellPoint(3); data->SetPolys(cells); cells->Delete(); mapper = vtkPolyDataMapper2D::New(); IERROR_CHECK_MEMORY(mapper); mapper->SetInputData(data); data->Delete(); coord = vtkCoordinate::New(); IERROR_CHECK_MEMORY(coord); coord->SetCoordinateSystemToNormalizedViewport(); mapper->SetTransformCoordinate(coord); coord->Delete(); mLiningActor = vtkActor2D::New(); IERROR_CHECK_MEMORY(mLiningActor); this->PrependComponent(mLiningActor); mLiningActor->SetMapper(mapper); mapper->Delete(); this->SetTransparent(true); } iFramedTextActor::~iFramedTextActor() { mBorderPoints->Delete(); mBorderActor->Delete(); mLiningActor->Delete(); } void iFramedTextActor::SetTransparent(bool s) { if(s != mTransparent) { mTransparent = s; mLiningActor->SetVisibility(mTransparent?0:1); this->Modified(); } } void iFramedTextActor::UpdateGeometry(vtkViewport* vp) { this->iTextActor::UpdateGeometry(vp); if(!this->IsEnabled()) return; int mag = this->GetOverlayHelper()->GetRenderingMagnification(); if(mag == 1) { // // Assign properties // mBorderActor->GetProperty()->SetColor(this->GetOverlayHelper()->GetColor(vp).ToVTK()); mLiningActor->GetProperty()->SetColor(vp->GetBackground()); } // // Scale lines // mBorderActor->GetProperty()->SetLineWidth(2*mag); // // Place border and lining // if(mag == 1) { this->GetBounds(vp,wBounds); int j; for(j=0; j<4; j++) wTrueBounds[j] = wBounds[j]; } else { int winij[2]; this->GetOverlayHelper()->ComputePositionShiftsUnderMagnification(winij); wBounds[0] = mag*wTrueBounds[0] - winij[0]; wBounds[1] = mag*wTrueBounds[1] - winij[0]; wBounds[2] = mag*wTrueBounds[2] - winij[1]; wBounds[3] = mag*wTrueBounds[3] - winij[1]; } // // Define the border // mBorderPoints->SetPoint(0,wBounds[0],wBounds[2],0.0); mBorderPoints->SetPoint(1,wBounds[1],wBounds[2],0.0); mBorderPoints->SetPoint(2,wBounds[1],wBounds[3],0.0); mBorderPoints->SetPoint(3,wBounds[0],wBounds[3],0.0); } ifrit-4.1.2/core/iframedtextactor.h0000674060175406010010000000367112641012522015664 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IFRAMEDTEXTACTOR_H #define IFRAMEDTEXTACTOR_H #include "itextactor.h" class vtkActor2D; class vtkPoints; class iFramedTextActor: public iTextActor { public: vtkTypeMacro(iFramedTextActor,iTextActor); static iFramedTextActor* New(iRenderTool *rt = 0); void SetTransparent(bool s); inline bool IsTransparent() const { return mTransparent; } protected: iFramedTextActor(iRenderTool *rv); virtual ~iFramedTextActor(); virtual void UpdateGeometry(vtkViewport *vp); float wBounds[4]; private: bool mTransparent; float wTrueBounds[4]; vtkPoints *mBorderPoints; vtkActor2D *mBorderActor; vtkActor2D *mLiningActor; }; #endif // IFRAMEDTEXTACTOR_H ifrit-4.1.2/core/igenericfilter.h0000775060175406010010000001322212641012522015305 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A front-end for portable inheritance // #ifndef IGENERICFILTER_H #define IGENERICFILTER_H #include "idatahandler.h" #include "ierror.h" #include "ivtk.h" #include class vtkAlgorithm; class vtkAlgorithmOutput; class vtkDataArray; class vtkDataObject; class vtkDataSet; class vtkFloatArray; class vtkImageData; class vtkInformation; class vtkInformationVector; class vtkPolyData; template class iGenericFilter : public Filter, public iDataHandler { public: virtual float GetMemorySize(); virtual void RemoveInternalData(); // // Expose a limited input/output API for better control // inline InputType* InputData(){ return this->InputData(0); } InputType* InputData(int n); inline OutputType* OutputData(){ return this->OutputData(0); } OutputType* OutputData(int n); protected: iGenericFilter(iDataConsumer *consumer, int numInputs, bool ownsOutput); virtual ~iGenericFilter(); virtual int FillInputPortInformation(int port, vtkInformation *info); virtual int FillOutputPortInformation(int port, vtkInformation *info); virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo); virtual int RequestUpdateExtent(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo); virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector); // // Helper function for children use // vtkDataObject* GetFilterOutputIfPresent(vtkAlgorithm *alg, int port); void Reset(); void ExecuteParent(); virtual void ProvideInfo(); // called by RequestInformation virtual void ProvideExtent(); // called by RequestUpdateExtent virtual void ProvideOutput() = 0; // called by RequestData virtual void VerifyOutput(); // called on every pipeline pass after Execute // // Cached information during the execution pass // struct Cache { vtkInformation *LastRequest; vtkInformationVector **InputVector; vtkInformationVector *OutputVector; void Reset(); }; Cache wCache; // // Helper members for transforming scalars // struct ArrayHelper { vtkFloatArray *ArrIn, *ArrOut; float *PtrIn, *PtrOut; int DimIn, DimOut; bool Init(vtkDataArray *arr, vtkIdType sizeOut = 0, int dimOut = 0); }; ArrayHelper wArray; private: #ifdef I_DEBUG long mThreadId; #endif private: const bool mOwnsOutput; #ifndef IVTK_5 /* blocked */ virtual void SetInputDataObject(int port, vtkDataObject *data){ this->Filter::SetInputDataObject(port,data); } /* blocked */ virtual void SetInputDataObject(vtkDataObject *data) { this->Filter::SetInputDataObject(data); } /* blocked */ virtual void AddInputDataObject(int port, vtkDataObject *data){ this->Filter::AddInputDataObject(port,data); } /* blocked */ virtual void AddInputDataObject(vtkDataObject *data) { this->Filter::AddInputDataObject(data); } #endif /* blocked */ vtkDataObject* GetInputDataObject(int port, int connection) { return this->Filter::GetInputDataObject(port,connection); } /* blocked */ vtkDataObject* GetOutputDataObject(int port) { return this->Filter::GetOutputDataObject(port); } /* blocked */ vtkDataObject* GetInput() { return this->Filter::GetInput(); } /* blocked */ vtkDataObject* GetInput(int port) { return this->Filter::GetInput(port); } /* blocked */ vtkDataObject* GetOutput() { return this->Filter::GetOutput(); } /* blocked */ vtkDataObject* GetOutput(int port) { return this->Filter::GetOutput(port); } }; template class iGenericPolyDataFilter : public iGenericFilter { protected: iGenericPolyDataFilter(iDataConsumer *consumer, int numInputs, bool ownsOutput); virtual void VerifyOutput(); }; template class iGenericImageDataFilter : public iGenericFilter { protected: iGenericImageDataFilter(iDataConsumer *consumer, int numInputs, bool ownsOutput); virtual void ProvideInfo(); }; // // Useful macro // #define iGenericFilterTypeMacro(_name_,_parent_) \ public: \ vtkTypeMacro(_name_,_parent_); \ static _name_* New(iDataConsumer *consumer = 0) { IASSERT(consumer); return new _name_(consumer); } \ protected: \ _name_(iDataConsumer *consumer) #endif // IGENERICFILTER_H ifrit-4.1.2/core/igenericfilter.tlh0000775060175406010010000003053212641012510015645 0ustar HomeNone//LICENSE A #include "igenericfilter.h" #include "ierror.h" #include "iviewmodule.h" #include "iviewmoduleeventobservers.h" #include "ivtk.h" #include "ivtktype.h" #include #include #include #include #include #include #include #include #ifdef I_DEBUG #include #endif template void iGenericFilter::Cache::Reset() { LastRequest = 0; InputVector = 0; OutputVector = 0; } // // Main template class // template iGenericFilter::iGenericFilter(iDataConsumer *consumer, int numInputs, bool ownsOutput) : iDataHandler(consumer), mOwnsOutput(ownsOutput) { // // Check our type // bool ids = (InputType::IsTypeOf("vtkDataSet") != 0); bool iid = (InputType::IsTypeOf("vtkImageData") != 0); bool ipd = (InputType::IsTypeOf("vtkPolyData") != 0); if(!ids && !iid && !ipd) { IBUG_FATAL("Incorrectly configured iGenericFilter<>"); } bool ods = (OutputType::IsTypeOf("vtkDataSet") != 0); bool oid = (OutputType::IsTypeOf("vtkImageData") != 0); bool opd = (OutputType::IsTypeOf("vtkPolyData") != 0); if(!ods && !oid && !opd) { IBUG_FATAL("Incorrectly configured iGenericFilter<>"); } if(Filter::IsTypeOf("vtkDataSetAlgorithm")!=0 && (!ids && !ods)) { IBUG_FATAL("Incorrectly configured iGenericFilter<>"); } if(Filter::IsTypeOf("vtkImageDataAlgorithm")!=0 && (!iid && !oid)) { IBUG_FATAL("Incorrectly configured iGenericFilter<>"); } if(Filter::IsTypeOf("vtkPolyDataAlgorithm")!=0 && (!ids && !ipd && !opd)) { IBUG_FATAL("Incorrectly configured iGenericFilter<>"); } this->AddObserver(vtkCommand::ProgressEvent,this->GetViewModule()->GetRenderEventObserver()); this->SetNumberOfInputPorts(numInputs); this->wCache.Reset(); #ifdef I_DEBUG this->mThreadId = vtkMultiThreader::GetCurrentThreadID(); #endif } template iGenericFilter::~iGenericFilter() { } template int iGenericFilter::FillInputPortInformation(int port, vtkInformation* info) { if(port == 0) { #ifndef I_NO_CHECK if(this->Filter::FillInputPortInformation(port,info) != 0) { if(InputType::IsTypeOf(info->Get(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE())) == 0) { IBUG_FATAL(iString("Invalid input type: ") + info->Get(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE())); } } #endif info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),ivtkType::Name()); return 1; } else return this->Filter::FillInputPortInformation(port,info); } template int iGenericFilter::FillOutputPortInformation(int port,vtkInformation* info) { #ifndef I_NO_CHECK if(this->Filter::FillOutputPortInformation(port,info) != 0) { if(OutputType::IsTypeOf(info->Get(vtkDataObject::DATA_TYPE_NAME())) == 0) { IBUG_FATAL(iString("Invalid output type: ") + info->Get(vtkDataObject::DATA_TYPE_NAME())); } } #endif info->Set(vtkDataObject::DATA_TYPE_NAME(),ivtkType::Name()); return 1; } template InputType* iGenericFilter::InputData(int n) { if(n>=0 && nGetNumberOfInputPorts()) { return iRequiredCast(INFO,this->Filter::GetInputDataObject(n,0)); } else return 0; } template OutputType* iGenericFilter::OutputData(int n) { if(n>=0 && nGetNumberOfOutputPorts()) { return iRequiredCast(INFO,this->Filter::GetOutputDataObject(n)); } else return 0; } template void iGenericFilter::Reset() { int i; for(i=0; iGetNumberOfOutputPorts(); i++) { this->OutputData(i)->Initialize(); } } template int iGenericFilter::RequestInformation(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo) { #ifndef I_NO_CHECK #ifndef IVTK_5 if(this->wCache.LastRequest != 0) { IBUG_ERROR("iGenericFilter: incorrect call sequence"); this->wCache.Reset(); return 0; } #endif if(this->OutputData() == 0) { IBUG_ERROR("iGenericFilter: incorrect type for output data."); this->wCache.Reset(); return 0; } #endif this->wCache.LastRequest = request; this->wCache.InputVector = inInfo; this->wCache.OutputVector = outInfo; #ifdef I_DEBUG if(vtkMultiThreader::ThreadsEqual(this->mThreadId,vtkMultiThreader::GetCurrentThreadID()) != 0) { iOutput::DisplayDebugMessage(iString("Providing info for filter ")+Filter::GetClassName()); } #endif this->ProvideInfo(); if(this->GetAbortExecute() != 0) { this->wCache.Reset(); this->Reset(); } return 1; } template int iGenericFilter::RequestUpdateExtent(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo) { if(this->wCache.LastRequest == 0) { this->wCache.LastRequest = request; this->wCache.InputVector = inInfo; this->wCache.OutputVector = outInfo; } #ifndef I_NO_CHECK if(inInfo!=this->wCache.InputVector || outInfo!=this->wCache.OutputVector) { IBUG_ERROR("iGenericFilter: incorrect request"); this->wCache.Reset(); return 0; } #endif this->wCache.LastRequest = request; // // By default update everything // int i; for(i=0; iGetNumberOfOutputPorts(); i++) { #ifdef IVTK_5 this->GetOutput(i)->SetUpdateExtentToWholeExtent(); #else this->SetUpdateExtentToWholeExtent(i); #endif } #ifdef I_DEBUG if(vtkMultiThreader::ThreadsEqual(this->mThreadId,vtkMultiThreader::GetCurrentThreadID()) != 0) { iOutput::DisplayDebugMessage(iString("Providing extent for filter ")+Filter::GetClassName()); } #endif this->ProvideExtent(); if(this->GetAbortExecute() != 0) { this->wCache.Reset(); this->Reset(); } return 1; } template int iGenericFilter::RequestData(vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo) { if(this->wCache.LastRequest == 0) { this->wCache.LastRequest = request; this->wCache.InputVector = inInfo; this->wCache.OutputVector = outInfo; } #ifndef I_NO_CHECK if(inInfo!=this->wCache.InputVector || outInfo!=this->wCache.OutputVector) { IBUG_ERROR("iGenericFilter: incorrect request"); this->wCache.Reset(); return 0; } #endif this->wCache.LastRequest = request; if(this->GetNumberOfInputPorts()>0 && this->InputData()==0) { this->wCache.Reset(); this->Reset(); return 1; } #ifdef I_DEBUG if(vtkMultiThreader::ThreadsEqual(this->mThreadId,vtkMultiThreader::GetCurrentThreadID()) != 0) { iOutput::DisplayDebugMessage(iString("Providing output for filter ")+Filter::GetClassName()); } #endif this->ProvideOutput(); this->wCache.Reset(); if(this->GetAbortExecute() != 0) { this->wCache.Reset(); this->Reset(); } else { if(this->IsOptimizedForMemory()) { int i; vtkDataSet *ds; for(i = 0; i < this->GetNumberOfOutputPorts(); i++) { ds = vtkDataSet::SafeDownCast(this->OutputData(i)); if(ds != 0) ds->Squeeze(); } } this->VerifyOutput(); } return 1; } template void iGenericFilter::ExecuteParent() { #ifndef I_NO_CHECK if(this->wCache.LastRequest==0 || this->wCache.InputVector==0 || this->wCache.OutputVector==0) { IBUG_ERROR("iGenericFilter: incorrect request"); return; } #endif if(this->Filter::RequestData(this->wCache.LastRequest,this->wCache.InputVector,this->wCache.OutputVector) == 0) { this->SetAbortExecute(1); } } template float iGenericFilter::GetMemorySize() { int i; float s = 0.0f; if(mOwnsOutput) { for(i=0; iGetNumberOfOutputPorts(); i++) { // // It is important to check that the output data actually exists, to avoid warnings // vtkDataObject *d = this->GetFilterOutputIfPresent(this,i); if(d != 0) s += d->GetActualMemorySize(); } } return s; } // // Helper function for child's use // template vtkDataObject* iGenericFilter::GetFilterOutputIfPresent(vtkAlgorithm *alg, int port) { if(alg==0 || port<0 || port>=alg->GetNumberOfOutputPorts()) return 0; // // It is important to check that the output data actually exists // vtkInformation* info = alg->GetExecutive()->GetOutputInformation(port); if(info!=0 && info->Has(vtkDataObject::DATA_OBJECT())) { return alg->GetOutputDataObject(port); } else return 0; } template void iGenericFilter::RemoveInternalData() { int i; if(mOwnsOutput) { for(i=0; iGetNumberOfOutputPorts(); i++) { this->OutputData(i)->Initialize(); } } } template void iGenericFilter::ProvideInfo() { // // Default implementation is to do nothing // } template void iGenericFilter::ProvideExtent() { // // Default implementation is to do nothing // } template void iGenericFilter::VerifyOutput() { // // Default implementation is to do nothing // } template bool iGenericFilter::ArrayHelper::Init(vtkDataArray *arr, vtkIdType sizeOut, int dimOut) { if(arr == 0) { ArrIn = ArrOut = 0; PtrIn = PtrOut = 0; DimIn = DimOut = 0; return false; } ArrIn = vtkFloatArray::SafeDownCast(arr); if(ArrIn == 0) { vtkGenericWarningMacro("Input array is not float."); return false; } DimIn = ArrIn->GetNumberOfComponents(); PtrIn = ArrIn->GetPointer(0); if(sizeOut < 1) sizeOut = ArrIn->GetNumberOfTuples(); if(dimOut < 1) dimOut = DimIn; ArrOut = vtkFloatArray::New(); if(ArrOut == 0) { vtkGenericWarningMacro("Not enough memory to create output scalars."); return false; } ArrOut->SetNumberOfComponents(dimOut); ArrOut->SetNumberOfTuples(sizeOut); DimOut = dimOut; PtrOut = ArrOut->GetPointer(0); if(PtrOut == 0) { vtkGenericWarningMacro("Not enough memory to create output scalars."); ArrOut->Delete(); return false; } return true; } // // PolyData filter // template iGenericPolyDataFilter::iGenericPolyDataFilter(iDataConsumer *consumer, int numInputs, bool ownsOutput) : iGenericFilter(consumer,numInputs,ownsOutput) { // // Check our type // if(Filter::IsTypeOf("vtkPolyDataAlgorithm") == 0) { IBUG_FATAL("Incorrectly configured iGenericPolyDataFilter<>"); } } template void iGenericPolyDataFilter::VerifyOutput() { vtkPolyData *input = this->InputData(); vtkPolyData *output = this->OutputData(); if(input!=0 && output!=0 && input->GetPoints()!=0 && output->GetPoints()!=0 && (input->GetPoints()->GetDataType()!=output->GetPoints()->GetDataType())) { #ifdef I_DEBUG int it = input->GetPoints()->GetDataType(); int ot = output->GetPoints()->GetDataType(); #endif vtkErrorMacro("Incompatible point types of input and output"); } } // // ImageData filter // template iGenericImageDataFilter::iGenericImageDataFilter(iDataConsumer *consumer, int numInputs, bool ownsOutput) : iGenericFilter(consumer,numInputs,ownsOutput) { // // Check our type // if(Filter::IsTypeOf("vtkImageAlgorithm") == 0) { IBUG_FATAL("Incorrectly configured iGenericImageDataFilter<>"); } } template void iGenericImageDataFilter::ProvideInfo() { vtkImageData *input = this->InputData(); if(input != 0) { vtkInformation* outInfo = this->wCache.OutputVector->GetInformationObject(0); outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),input->GetExtent(),6); } } ifrit-4.1.2/core/igenericprop.h0000674060175406010010000000511212641012522014775 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A front-end for portable props - in case VTK guys decide to change the vtkProp interface again... // #ifndef IGENERICPROP_H #define IGENERICPROP_H #include "iarray.h" #include "ivtk.h" #include class vtkProp; class vtkViewport; class vtkWindow; template class iGenericProp : public Prop { public: virtual int RenderOverlay(vtkViewport *vp); virtual int RenderOpaqueGeometry(vtkViewport *vp); virtual int HasTranslucentPolygonalGeometry(); virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vp); virtual int RenderVolumetricGeometry(vtkViewport *vp); virtual void ReleaseGraphicsResources(vtkWindow *win); protected: iGenericProp(bool self); virtual void UpdateGeometry(vtkViewport *vp) = 0; virtual void UpdateOverlay(vtkViewport *vp); virtual void Reset(); inline bool IsEnabled() const { return mEnabled; } void PrependComponent(vtkProp *p); void AppendComponent(vtkProp *p); void RemoveComponent(vtkProp *p); void RemoveAllComponents(); void ToggleComponent(vtkProp *p); void ShowComponents(int n, vtkProp **p); void Disable(); vtkTimeStamp GetLastRenderMTime() const { return mLastRenderMTime; } private: void MakeUpTodate(vtkViewport *vp); const bool mSelf; bool mDirty, mEnabled; iLookupArray mProps; vtkTimeStamp mLastRenderMTime; }; #endif // IGENERICPROP_H ifrit-4.1.2/core/igenericprop.tlh0000674060175406010010000000641312641012510015337 0ustar HomeNone//LICENSE A #include "igenericprop.h" #include #define IGENERICPROP_RENDER(_fun_) \ if(mEnabled) \ { \ ret = 0; \ for(j=0; jGetVisibility() != 0) \ { \ ret += mProps[j]->_fun_(vp); \ } \ if(mSelf) ret += this->Prop::_fun_(vp); \ } \ else ret = 0 template iGenericProp::iGenericProp(bool self) : mSelf(self) { mDirty = mEnabled = true; } template void iGenericProp::MakeUpTodate(vtkViewport *vp) { if(mDirty) { this->UpdateGeometry(vp); mDirty = false; } } template void iGenericProp::Reset() { } template void iGenericProp::UpdateOverlay(vtkViewport *) { } template int iGenericProp::RenderOverlay(vtkViewport *vp) { int j, ret; this->MakeUpTodate(vp); if(mEnabled) this->UpdateOverlay(vp); IGENERICPROP_RENDER(RenderOverlay); this->Reset(); mDirty = mEnabled = true; mLastRenderMTime.Modified(); return ret; } template int iGenericProp::RenderOpaqueGeometry(vtkViewport *vp) { int j, ret; this->MakeUpTodate(vp); IGENERICPROP_RENDER(RenderOpaqueGeometry); return ret; } template int iGenericProp::HasTranslucentPolygonalGeometry() { int j; if(mEnabled) { for(j=0; jGetVisibility() != 0) { if(mProps[j]->HasTranslucentPolygonalGeometry() != 0) return 1; } if(mSelf && this->Prop::HasTranslucentPolygonalGeometry()!=0) return 1; } return 0; } template int iGenericProp::RenderTranslucentPolygonalGeometry(vtkViewport *vp) { int j, ret; this->MakeUpTodate(vp); IGENERICPROP_RENDER(RenderTranslucentPolygonalGeometry); return ret; } template int iGenericProp::RenderVolumetricGeometry(vtkViewport *vp) { int j, ret; this->MakeUpTodate(vp); IGENERICPROP_RENDER(RenderVolumetricGeometry); return ret; } template void iGenericProp::ReleaseGraphicsResources(vtkWindow *win) { int j; for(j=0; jReleaseGraphicsResources(win); } if(mSelf) this->Prop::ReleaseGraphicsResources(win); } template void iGenericProp::PrependComponent(vtkProp *p) { if(p!=0 && p!=this) { p->SetVisibility(1); mProps.Add(p); // // Reorder // int i; for(i=mProps.MaxIndex(); i>0; i--) { mProps[i] = mProps[i-1]; } mProps[0] = p; } } template void iGenericProp::AppendComponent(vtkProp *p) { if(p!=0 && p!=this) { p->SetVisibility(1); mProps.Add(p); } } template void iGenericProp::RemoveComponent(vtkProp *p) { mProps.Remove(p); } template void iGenericProp::RemoveAllComponents() { mProps.Clear(); } template void iGenericProp::ToggleComponent(vtkProp *p) { int j; for(j=0; jSetVisibility(0); } j = mProps.Find(p); if(j > -1) p->SetVisibility(1); } template void iGenericProp::ShowComponents(int n, vtkProp **p) { int i, j; for(j=0; jSetVisibility(0); } for(i=0; i -1) p[i]->SetVisibility(1); } } template void iGenericProp::Disable() { mEnabled = false; } ifrit-4.1.2/core/ihistogram.cpp0000674060175406010010000000730512641012553015022 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ihistogram.h" #include "ierror.h" #include "imath.h" #include "istretch.h" #include // // Templates // #include "iarray.tlh" iHistogram::iHistogram() { this->Clear(); } iHistogram::~iHistogram() { } const iHistogram& iHistogram::Null() { static iHistogram null; return null; } void iHistogram::Clear() { mValues.Clear(); mBins.Clear(); mBins.Add(0); mStretchId = iStretch::Lin; mStretchedMin = 0; mStretchedMax = 0; mValueToBinScale = 0; } void iHistogram::Reset(int nbins, float min, float max, int sid) { int i; if(nbins<1 || min>=max || sid<0 || sid>=iStretch::Count) { this->Clear(); return; } mBins.Resize(nbins+1); mBins[0] = min; mBins[nbins] = max; mStretchId = sid; mStretchedMin = iStretch::Apply(min,sid,false); mStretchedMax = iStretch::Apply(max,sid,true); float s = (mStretchedMax-mStretchedMin)/nbins; for(i=1; iCheck(); #endif if(mValues.Size()==0 || vmBins[mValues.Size()]) return -1; return int(mValueToBinScale*(iStretch::Apply(v,mStretchId,false)-mStretchedMin)); } float iHistogram::GetMin() const { #ifdef I_CHECK this->Check(); #endif return mBins[0]; } float iHistogram::GetMax() const { #ifdef I_CHECK this->Check(); #endif return mBins[mValues.Size()]; } void iHistogram::GetRange(float range[2]) const { #ifdef I_CHECK this->Check(); #endif range[0] = mBins[0]; range[1] = mBins[mValues.Size()]; } float iHistogram::GetBinMin(int i) const { #ifdef I_CHECK this->Check(); #endif if(i>=0 && iCheck(); #endif if(i>=0 && iCheck(); #endif if(i>=0 && iCheck(); #endif if(i>=0 && i mValues; iArray mBins; }; #endif ifrit-4.1.2/core/ihistogrammaker.cpp0000674060175406010010000004002112641012553016032 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ihistogrammaker.h" #include "idatalimits.h" #include "idatasubject.h" #include "ierror.h" #include "ihistogram.h" #include "imath.h" #include "imonitor.h" #include "iparallel.h" #include "iparallelmanager.h" #include "ishell.h" #include "ishelleventobservers.h" #include "istretch.h" #include #include #include #include #include // // Templates // #include "iarray.tlh" // // Abstract iterator // iHistogramMaker::Iterator::Iterator(const iDataSubject *subject, int var, vtkIdType beg, vtkIdType end) { Subject = subject; IASSERT(Subject); Var = var; Idx = beg; End = end; DataPtr = 0; NumFields = 0; } bool iHistogramMaker::Iterator::Next(int step) { if(step == 1) { Idx++; } else { int i; for(i=0; i double iHistogramMaker::StdIterator::Weight() const { return 1.0; } template<> float iHistogramMaker::StdIterator<0U>::Value() const { #ifdef I_CHECK IASSERT(this->DataPtr); #endif return this->DataPtr[this->Var+this->Idx*this->NumFields]; } template<> float iHistogramMaker::StdIterator<1U>::Value() const { #ifdef I_CHECK IASSERT(this->DataPtr); #endif float *d = this->DataPtr + this->Idx*this->NumFields; return sqrt(d[0]*d[0]+d[1]*d[1]+d[2]*d[2]); } template<> float iHistogramMaker::StdIterator<2U>::Value() const { #ifdef I_CHECK IASSERT(this->DataPtr); #endif int i; float *m[3], e[3], *v[3], store[9]; float *d = this->DataPtr + this->Idx*this->NumFields; for(i=0; i<3; i++) { v[i] = store + 3*i; m[i] = d + 3*i; } vtkMath::Jacobi(m,e,v); return e[this->Var]; } // // VC++ syntax highlighter does not like something about these definitions, put it here not to confuse it in the rest of the file // template<> iHistogramMaker::StdIterator<0U>::StdIterator(const iDataSubject *subject, int var, vtkIdType beg, vtkIdType end) : Iterator(subject,var,beg,end) { vtkDataSet *data = Subject->GetData(); if(this->Idx<0 || this->Var<0 || data==0 || data->GetPointData()==0) return; if(data->GetPointData()->GetScalars() == 0) return; // // Access the data for both vtkPolyData and vtkImageData // vtkFloatArray *arr = vtkFloatArray::SafeDownCast(data->GetPointData()->GetScalars()); if(arr == 0) return; this->DataPtr = arr->GetPointer(0); if(this->DataPtr == 0) return; if(this->Var >= arr->GetNumberOfComponents()) return; this->NumFields = arr->GetNumberOfComponents(); } template<> iHistogramMaker::StdIterator<1U>::StdIterator(const iDataSubject *subject, int var, vtkIdType beg, vtkIdType end) : iHistogramMaker::Iterator(subject,var,beg,end) { vtkDataSet *data = Subject->GetData(); if(this->Idx<0 || this->Var<0 || data==0 || data->GetPointData()==0) return; if(data->GetPointData()->GetVectors() == 0) return; // // Access the data for both vtkPolyData and vtkImageData // vtkFloatArray *arr = vtkFloatArray::SafeDownCast(data->GetPointData()->GetVectors()); if(arr == 0) return; this->DataPtr = arr->GetPointer(0); if(this->DataPtr == 0) return; if(this->Var!=0 || arr->GetNumberOfComponents()!=3) return; this->NumFields = 3; } template<> iHistogramMaker::StdIterator<2U>::StdIterator(const iDataSubject *subject, int var, vtkIdType beg, vtkIdType end) : iHistogramMaker::Iterator(subject,var,beg,end) { vtkDataSet *data = Subject->GetData(); if(this->Idx<0 || this->Var<0 || data==0 || data->GetPointData()==0) return; if(data->GetPointData()->GetTensors() == 0) return; // // Access the data for both vtkPolyData and vtkImageData // vtkFloatArray *arr = vtkFloatArray::SafeDownCast(data->GetPointData()->GetTensors()); if(arr == 0) return; this->DataPtr = arr->GetPointer(0); if(this->DataPtr == 0) return; if(this->Var>2 || arr->GetNumberOfComponents()!=9) return; this->NumFields = 9; } // // Helper class // class iHistogramMakerWorker { public: struct ProcDataItem { float ValMax; float ValMin; vtkIdType CellMax; vtkIdType CellMin; double *Values; }; iHistogramMakerWorker() { NumBins = 0; } ~iHistogramMakerWorker() { while(ProcData.Size() > 0) delete ProcData.RemoveLast().Values; } void Update(int nprocs, int nbins) { while(ProcData.Size() > nprocs) delete ProcData.RemoveLast().Values; if(nbins>0 && nbins!=NumBins) { int i; NumBins = nbins; for(i=0; i ProcData; typedef iArray DataType; // // Work variables // int Var, StretchId; bool Overflow; }; //------------------------------------------------------------------------------ iHistogramMaker* iHistogramMaker::New(const iDataSubject *subject) { IASSERT(subject); return new iHistogramMaker(subject); } iHistogramMaker::iHistogramMaker(const iDataSubject *subject) : iParallelWorker(subject->GetShell()->GetParallelManager()), mNullPointInfo(subject->GetViewModule()) { mSubject = subject; mWorker = new iHistogramMakerWorker; IASSERT(mWorker); this->AddObserver(vtkCommand::StartEvent,subject->GetShell()->GetExecutionEventObserver()); this->AddObserver(vtkCommand::ProgressEvent,subject->GetShell()->GetExecutionEventObserver()); this->AddObserver(vtkCommand::EndEvent,subject->GetShell()->GetExecutionEventObserver()); } iHistogramMaker::~iHistogramMaker() { while(mItems.Size() > 0) delete mItems.RemoveLast(); delete mWorker; } bool iHistogramMaker::HasOverflow(int var) { if(this->ComputeRange(var)) { return mItems[var]->Overflow; } else return false; } const iPair iHistogramMaker::GetRange(int var) { iPair p; this->GetRange(var,p.Min,p.Max); return p; } void iHistogramMaker::GetRange(int var, float &min, float &max) { if(this->ComputeRange(var)) { min = mItems[var]->Min.Value; max = mItems[var]->Max.Value; } } void iHistogramMaker::GetRange(int var, float range[2]) { if(this->ComputeRange(var)) { range[0] = mItems[var]->Min.Value; range[1] = mItems[var]->Max.Value; } } const iHistogramMaker::PointInfo& iHistogramMaker::GetMin(int var) { if(this->ComputePoints(var)) { return mItems[var]->Min; } else return mNullPointInfo; } const iHistogramMaker::PointInfo& iHistogramMaker::GetMax(int var) { if(this->ComputePoints(var)) { return mItems[var]->Max; } else return mNullPointInfo; } const iHistogram& iHistogramMaker::GetHistogram(int var, int sid, bool full) { if(this->ComputeHistogram(var,sid,full?1.0:0.1,full?1:1000)) { return mItems[var]->Histogram[sid]; } else return iHistogram::Null(); } const iHistogram& iHistogramMaker::GetHistogram(int var, int sid, float fbins) { if(this->ComputeHistogram(var,sid,fbins,1)) { return mItems[var]->Histogram[sid]; } else return iHistogram::Null(); } bool iHistogramMaker::ComputeRange(int var) { if(!mSubject->IsThereData() || var<0 || var>=this->GetNumberOfComponents()) return false; // // Update Items array first // while(mItems.Size() > this->GetNumberOfComponents()) delete mItems.RemoveLast(); while(mItems.Size() < this->GetNumberOfComponents()) { VarItem *tmp = new VarItem(mSubject->GetViewModule()); IERROR_CHECK_MEMORY(tmp); mItems.Add(tmp); } VarItem &item(*(mItems[var])); // // Do we need to recompute? // if(item.RangeMTime < mSubject->GetData()->GetMTime()) { // // Recompute the limits // mWorker->Update(this->GetManager()->GetNumberOfProcessors(),0); mWorker->Overflow = false; mWorker->Var = var; iMonitor h(mSubject,"Computing",1.0); if(this->ParallelExecute(1) != 0) { return false; } int i; iHistogramMakerWorker::DataType &d(mWorker->ProcData); // cache for speed float vmin = d[0].ValMin; float vmax = d[0].ValMax; vtkIdType cmin = d[0].CellMin; vtkIdType cmax = d[0].CellMax; for(i=1; i d[i].ValMin) { vmin = d[i].ValMin; cmin = d[i].CellMin; } if(vmax < d[i].ValMax) { vmax = d[i].ValMax; cmax = d[i].CellMax; } } // // Spread values a little bit if needed // if(vmax-vmin < 0.01*(fabs(vmax)+fabs(vmin))) { if(vmin < 0) vmin *= 1.001; else vmin *= 0.999; if(vmax < 0) vmax *= 0.999; else vmax *= 1.001; } item.Max.Value = vmax; item.Min.Value = vmin; item.Max.Cell = cmax; item.Min.Cell = cmin; item.Overflow = mWorker->Overflow; // // Update the time // item.RangeMTime.Modified(); } return true; } bool iHistogramMaker::ComputePoints(int var) { if(this->ComputeRange(var)) { VarItem &item(*(mItems[var])); // // Do we need to recompute? // if(item.PointsMTime < mSubject->GetData()->GetMTime()) { this->FindPositionForCell(item.Min.Cell,item.Min.Position); this->FindPositionForCell(item.Max.Cell,item.Max.Position); } item.PointsMTime.Modified(); return true; } else return false; } bool iHistogramMaker::ComputeHistogram(int var, int sid, float fbins, int step) { if(sid<0 || sid>=iStretch::Count) return false; if(!this->ComputeRange(var)) return false; VarItem &item(*(mItems[var])); int nbins = iMath::Round2Int(fbins*(1+2*pow(this->GetNumberOfCells(),0.333))); if(nbins < 3) nbins = 3; if(item.HistogramMTime[sid]GetData()->GetMTime() || item.Histogram[sid].NumBins()!=nbins || item.DataStep[sid]!=step) { // // Check if we need to re-create the helper data // int nprocs = this->GetManager()->GetNumberOfProcessors(); mWorker->Update(nprocs,nbins); #ifndef I_NO_CHECK if(nbins != mWorker->NumBins) { IBUG_ERROR("iHistogramMaker:Helper is configured incorrectly."); return false; } #endif item.DataStep[sid] = step; mWorker->StretchId = sid; mWorker->Var = var; item.Histogram[sid].Reset(nbins,item.Min.Value,item.Max.Value,sid); // must be here for hist.Bin() to work iMonitor ph(mSubject,"Computing",1.0); if(this->ParallelExecute(2) != 0) { item.Histogram[sid].Clear(); return false; } int i, j; iHistogramMakerWorker::DataType &d(mWorker->ProcData); iHistogram &h(item.Histogram[sid]); for(i=0; iProcData.Size()) { IBUG_WARN("Error calling iHistogramMaker in parallel."); return -1; } vtkIdType ntup = this->GetNumberOfCells(); vtkIdType l, lbeg, lend, lstp; float v, vmin, vmax; int ret = 999; iHistogramMakerWorker::DataType &d(mWorker->ProcData); // // Distribute data // iParallel::SplitRange(p,ntup,lbeg,lend,lstp); Iterator *it = this->MakeIterator(mSubject->GetDataRank(),mWorker->Var,lbeg,lend); if(!it->IsReady()) { delete it; return -1; } // // Recompute the limits // if(step == 1) { vtkIdType lmin, lmax; vmin = vmax = it->Value(); lmin = lmax = it->Index(); while(it->Next()) { if((l = it->Index())%10000 == 0) { if(p.IsMaster()) mSubject->GetShell()->GetExecutionEventObserver()->SetProgress(double(l-lbeg)/(lend-lbeg)); if(mSubject->GetShell()->GetExecutionEventObserver()->IsAborted()) break; } v = it->Value(); if(v < -iMath::_LargeFloat) { mWorker->Overflow = true; v = -iMath::_LargeFloat; } if(v > iMath::_LargeFloat) { mWorker->Overflow = true; v = iMath::_LargeFloat; } if(v < vmin) { vmin = v; lmin = l; } if(v > vmax) { vmax = v; lmax = l; } } d[p.ThisProc].ValMin = vmin; d[p.ThisProc].ValMax = vmax; d[p.ThisProc].CellMin = lmin; d[p.ThisProc].CellMax = lmax; ret = 0; } // // Compute the histogram // if(step == 2) { int iv; int nbins = mWorker->NumBins; int step = mItems[mWorker->Var]->DataStep[mWorker->StretchId]; iHistogram &hist(mItems[mWorker->Var]->Histogram[mWorker->StretchId]); double *h = d[p.ThisProc].Values; memset(h,0,sizeof(double)*nbins); while(it->Next(step)) { if((l = it->Index())%10000 == 0) { if(step==1 && p.IsMaster()) mSubject->GetShell()->GetExecutionEventObserver()->SetProgress(double(l-lbeg)/(lend-lbeg)); if(mSubject->GetShell()->GetExecutionEventObserver()->IsAborted()) break; } iv = hist.Bin(it->Value()); if(iv>=0 && ivWeight(); } #ifdef I_CHECK else if(iv != -1) { IBUG_ERROR("Invalid index returned by iHistogram::Bin()"); iv = hist.Bin(it->Value()); } #endif } ret = 0; } delete it; return ret; } int iHistogramMaker::GetNumberOfComponents() { vtkDataSet *data = mSubject->GetData(); if(data==0 || data->GetPointData()==0) return 0; switch(mSubject->GetDataRank()) { case 0U: { if(data->GetPointData()->GetScalars() != 0) return data->GetPointData()->GetScalars()->GetNumberOfComponents(); else return 0; } case 1U: { if(data->GetPointData()->GetVectors() != 0) return 1; else return 0; } case 2U: { if(data->GetPointData()->GetTensors() != 0) return 3; else return 0; } } return 0; } vtkIdType iHistogramMaker::GetNumberOfCells() { vtkDataSet *data = mSubject->GetData(); if(data==0 || data->GetPointData()==0) return 0; switch(mSubject->GetDataRank()) { case 0U: { if(data->GetPointData()->GetScalars() != 0) return data->GetPointData()->GetScalars()->GetNumberOfTuples(); else return 0; } case 1U: { if(data->GetPointData()->GetVectors() != 0) return data->GetPointData()->GetVectors()->GetNumberOfTuples(); else return 0; } case 2U: { if(data->GetPointData()->GetTensors() != 0) return data->GetPointData()->GetTensors()->GetNumberOfTuples(); else return 0; } } return 0; } void iHistogramMaker::FindPositionForCell(vtkIdType cell, iPosition &pos) { int i; vtkImageData *id = vtkImageData::SafeDownCast(mSubject->GetData()); if(id != 0) { int dims[3],ijk[3]; double spa[3],org[3]; id->GetDimensions(dims); id->GetSpacing(spa); id->GetOrigin(org); ijk[2] = cell / (dims[0] * dims[1]); ijk[1] = (cell - dims[0] * dims[1] * ijk[2]) / dims[0]; ijk[0] = cell % dims[0]; for(i=0; i<3; i++) pos[i] = org[i] + spa[i] * ijk[i]; } else { for(i=0; i<3; i++) pos[i] = 0; } } iHistogramMaker::Iterator* iHistogramMaker::MakeIterator(unsigned int rank, int var, vtkIdType beg, vtkIdType end) const { switch(mSubject->GetDataRank()) { case 0U: return new StdIterator<0U>(mSubject,var,beg,end); case 1U: return new StdIterator<1U>(mSubject,var,beg,end); case 2U: return new StdIterator<2U>(mSubject,var,beg,end); default: return 0; } } iHistogramMaker::PointInfo::PointInfo(iViewModule *vm) : Position(vm) { } iHistogramMaker::VarItem::VarItem(iViewModule *vm) : Max(vm), Min(vm) { } ifrit-4.1.2/core/ihistogrammaker.h0000674060175406010010000001003712641012523015500 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Class that computes a histogram for DataSubject's data and also provides other general info about the DataSubject's data // #ifndef IHISTOGRAMMAKER_H #define IHISTOGRAMMAKER_H #include #include "iparallelworker.h" #include "iarray.h" #include "ihistogram.h" #include "iposition.h" #include "istretch.h" class iDataSubject; class iHistogram; class iHistogramMakerWorker; struct iPair; class iViewModule; class vtkDataSet; class iHistogramMaker : public vtkObject, protected iParallelWorker { public: struct PointInfo { float Value; vtkIdType Cell; iPosition Position; PointInfo(iViewModule *vm); }; vtkTypeMacro(iHistogramMaker,vtkObject); static iHistogramMaker* New(const iDataSubject *subject = 0); virtual int GetNumberOfComponents(); bool HasOverflow(int var); const iPair GetRange(int var); void GetRange(int var, float &min, float &max); void GetRange(int var, float range[2]); const PointInfo& GetMin(int var); const PointInfo& GetMax(int var); const iHistogram& GetHistogram(int var, int sid, bool full); protected: const iHistogram& GetHistogram(int var, int sid, float fbins); // scale number of bins by fbins factor iHistogramMaker(const iDataSubject *subject); virtual ~iHistogramMaker(); virtual int ExecuteStep(int step, iParallel::ProcessorInfo &p); // // Inherit these functions // virtual vtkIdType GetNumberOfCells(); virtual void FindPositionForCell(vtkIdType cell, iPosition &pos); private: bool ComputeRange(int var); bool ComputePoints(int var); bool ComputeHistogram(int var, int sid, float fbins, int step); struct VarItem { PointInfo Max; PointInfo Min; bool Overflow; int DataStep[iStretch::Count]; iHistogram Histogram[iStretch::Count]; vtkTimeStamp RangeMTime, PointsMTime, HistogramMTime[iStretch::Count]; VarItem(iViewModule *vm); }; iArray mItems; // have to use pointers due to a non-trivial constructor iHistogramMakerWorker *mWorker; const PointInfo mNullPointInfo; protected: const iDataSubject *mSubject; class Iterator { public: Iterator(const iDataSubject *subject, int var, vtkIdType beg, vtkIdType end); virtual bool Next(int step = 1); virtual float Value() const = 0; virtual double Weight() const = 0; inline vtkIdType Index() const { return Idx; } inline bool IsReady() const { return (this->NumFields != 0); } protected: vtkIdType Idx, End; const iDataSubject *Subject; float *DataPtr; int Var, NumFields; }; template class StdIterator : public Iterator { public: StdIterator(const iDataSubject *subject, int var, vtkIdType beg, vtkIdType end); virtual float Value() const; virtual double Weight() const; }; virtual Iterator* MakeIterator(unsigned int rank, int var, vtkIdType beg, vtkIdType end) const; }; #endif // IHISTOGRAMMAKER_H ifrit-4.1.2/core/iidentityfilter.cpp0000674060175406010010000000303012641012553016053 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iidentityfilter.h" // // Templates // #include "igenericfilter.tlh" iIdentityFilter::iIdentityFilter(iDataConsumer *consumer) : iGenericFilter(consumer,1,false) { } void iIdentityFilter::ProvideOutput() { this->ExecuteParent(); } ifrit-4.1.2/core/iidentityfilter.h0000674060175406010010000000325212641012523015523 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A filter that ShallowCopy-ies its input into its output // #ifndef IIDENTITYFILTER_H #define IIDENTITYFILTER_H #include "igenericfilter.h" #include class vtkDataSet; class iIdentityFilter : public iGenericFilter { iGenericFilterTypeMacro(iIdentityFilter,vtkPassThroughFilter); protected: virtual void ProvideOutput(); }; #endif // IIDENTITYFILTER_H ifrit-4.1.2/core/iimage.cpp0000674060175406010010000003713112641012553014107 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iimage.h" #include "icolor.h" #include "ierror.h" #include "imath.h" #include "ivtk.h" #include #include #include #include #include #include #include #include #include #include #include iImage::iImage(int depth) { if(depth<1 || depth>4) { IBUG_WARN("Incorrect number of image components"); depth = 3; } mData = 0; mDepth = depth; mWidth = mHeight = 0; } iImage::iImage(const iImage& img) { mData = img.mData; if(mData != 0) { mData->Register(0); mDepth = img.mDepth; mWidth = img.mWidth; mHeight = img.mHeight; } else { mDepth = 3; mWidth = mHeight = 0; } } iImage::~iImage() { if(mData != 0) mData->Delete(); } vtkImageData* iImage::CreateData(int w, int h, int d) { vtkImageData *tmp; tmp = vtkImageData::New(); IERROR_CHECK_MEMORY(tmp); tmp->SetOrigin(0.0,0.0,0.0); tmp->SetSpacing(1.0,1.0,1.0); tmp->SetDimensions(w,h,1); if(d != 0) { if(d < 1 || d>4) { IBUG_WARN("Incorrect number of image components"); d = 3; } #ifdef IVTK_5 tmp->SetScalarType(VTK_UNSIGNED_CHAR); tmp->SetNumberOfScalarComponents(d); tmp->AllocateScalars(); #else tmp->AllocateScalars(VTK_UNSIGNED_CHAR,d); #endif } return tmp; } unsigned char* iImage::DataPointer() const { if(mData != 0) return (unsigned char *)mData->GetScalarPointer(); else return 0; } void iImage::SetDataPointer(unsigned char* array, int w, int h, int d) { if(array!=0 && w>0 && h>0 && d>0 && d<5) { if(mData != 0) mData->Delete(); mData = CreateData(w,h,0); // do not allocate vtkUnsignedCharArray *a; if(mData->GetPointData()->GetScalars()==0 || (a = vtkUnsignedCharArray::SafeDownCast(mData->GetPointData()->GetScalars()))==0) { a = vtkUnsignedCharArray::New(); IERROR_CHECK_MEMORY(a); mData->GetPointData()->SetScalars(a); a->Delete(); } a->SetNumberOfComponents(d); a->SetArray(array,d*w*h,1); mDepth = d; mWidth = w; mHeight = h; } } void iImage::Clear() { mDepth = 3; mWidth = mHeight = 0; if(mData != 0) { mData->Delete(); mData = 0; } } bool iImage::LoadFromFile(const iString &filename) { return LoadFromFile(filename,*this); } bool iImage::LoadFromFile(const iString &filename, iImage &image) { iString suf = filename.Section(".",-1).Lower(); vtkImageReader2 *ir = 0; if(suf=="jpg" || suf=="jpeg") { ir = vtkJPEGReader::New(); IERROR_CHECK_MEMORY(ir); } if(suf == "pnm") { ir = vtkPNMReader::New(); IERROR_CHECK_MEMORY(ir); } if(suf == "bmp") { ir = vtkBMPReader::New(); IERROR_CHECK_MEMORY(ir); } if(suf=="tif" || suf=="tiff") { ir = vtkTIFFReader::New(); IERROR_CHECK_MEMORY(ir); } if(suf == "png") { ir = vtkPNGReader::New(); IERROR_CHECK_MEMORY(ir); } if(ir!=0 && ir->CanReadFile(filename.ToCharPointer())==3) { ir->SetFileName(filename.ToCharPointer()); ir->SetDataScalarTypeToUnsignedChar(); ir->Update(); if(image.mData != 0) image.mData->Delete(); image.mData = ir->GetOutput(); image.mData->Register(0); image.mDepth = image.mData->GetNumberOfScalarComponents(); int dims[3]; image.mData->GetDimensions(dims); image.mWidth = dims[0]; image.mHeight = dims[1]; ir->Delete(); return true; } else return false; } void iImage::Blend(const iImage& im, float op) { vtkImageBlend* iblend; if(mData==0 || im.mData==0) return; if(op < 0.0) op = 0.0; if(op > 1.0) op = 1.0; iblend = vtkImageBlend::New(); if(iblend == 0) return; iblend->SetInputData(0,im.mData); iblend->SetInputData(1,mData); iblend->SetOpacity(1,(double)op); iblend->Update(); mData->Delete(); mData = iblend->GetOutput(); mData->Register(0); iblend->Delete(); } void iImage::ReplaceData(vtkImageData *newdata) { if(newdata == 0) { this->Clear(); return; } int dims[3]; newdata->GetDimensions(dims); mDepth = newdata->GetNumberOfScalarComponents(); mWidth = dims[0]; mHeight = dims[1]; // // We need to actually copy the data, not just link it here, since if the data object // changes, we would have no way of knowing it. // if(mData == 0) mData = CreateData(mWidth,mHeight); mData->DeepCopy(newdata); } void iImage::Overlay(int x, int y, const iImage& ovr, float opacity, bool masking) { if(mData==0 || ovr.mData==0 || x<=-ovr.mWidth || x>=mWidth || y<=-ovr.mHeight || y>=mHeight || mDepth!=ovr.Depth()) return; if(opacity < 0.0) opacity = 0.0; if(opacity > 1.0) opacity = 1.0; if(mData->GetReferenceCount() > 1) { vtkImageData *tmp; tmp = vtkImageData::New(); if(tmp == 0) return; tmp->DeepCopy(mData); mData->Delete(); mData = tmp; } // // tmp is now the proper image // int k, j, i, joff, ioff; unsigned long lImage, lOvlay; unsigned char *iPtr = (unsigned char *)mData->GetScalarPointer(); unsigned char *oPtr = (unsigned char *)ovr.mData->GetScalarPointer(); // // totally transparent colors // unsigned char tc[4]; for(k=0; k=0 && joff0.9999) { k = ovr.mWidth; if(x+k > mWidth) k = mWidth - x; lImage = mDepth*(x+(unsigned long)mWidth*joff); lOvlay = mDepth*(0+(unsigned long)ovr.mWidth*j); memcpy(iPtr+lImage,oPtr+lOvlay,mDepth*(unsigned long)k); } else { for(i=0; i=0 && ioffDelete(); mData = img.mData; if(mData != 0) { mData->Register(0); mDepth = img.mDepth; mWidth = img.mWidth; mHeight = img.mHeight; } else { mDepth = 3; mWidth = mHeight = 0; } return *this; } bool operator==(const iImage &s1, const iImage &s2) { if(s1.mDepth != s2.mDepth) return false; if(s1.mWidth != s2.mWidth) return false; if(s1.mHeight != s2.mHeight) return false; if(s1.mData == s2.mData) return true; if(s1.mData==0 || s2.mData==0) return false; unsigned long i, n = s1.mDepth*s1.mWidth*s1.mHeight; unsigned char *p1 = (unsigned char *)s1.mData->GetScalarPointer(); unsigned char *p2 = (unsigned char *)s2.mData->GetScalarPointer(); if(p1 == p2) return true; if(p1==0 || p2==0) return false; for(i=0; iClear(); return; } if(this->IsEmpty()) { mWidth = w; mHeight = h; mData = CreateData(w,h,mDepth); memset(mData->GetScalarPointer(),0,mDepth*w*h); return; } switch(m) { case _Fit: { fx = float(w)/mWidth; fy = float(h)/mHeight; if(fx < fy) fy = fx; w = iMath::Round2Int(fy*mWidth); h = iMath::Round2Int(fy*mHeight); break; } case _Include: { fx = float(w)/mWidth; fy = float(h)/mHeight; if(fx < fy) fx = fy; w = iMath::Round2Int(fx*mWidth); h = iMath::Round2Int(fx*mHeight); break; } case _FitMin: { fx = float(w)/mWidth; fy = float(h)/mHeight; if(fx < fy) fy = fx; if(fy > 1.0) fy = 1.0; w = iMath::Round2Int(fy*mWidth); h = iMath::Round2Int(fy*mHeight); break; } case _Both: { break; } } // // w and h are now proper size. Scale linearly first. // vtkImageData *tmp = CreateData(w,h,mDepth); unsigned char *sPtr = (unsigned char *)mData->GetScalarPointer(); unsigned char *dPtr = (unsigned char *)tmp->GetScalarPointer(); fx = float(mWidth)/w; fy = float(mHeight)/h; int *i0l = new int[w]; IERROR_CHECK_MEMORY(i0l); int *i0s = new int[w]; IERROR_CHECK_MEMORY(i0s); float *x0l = new float[w]; IERROR_CHECK_MEMORY(x0l); float *x0s = new float[w]; IERROR_CHECK_MEMORY(x0s); int *j0l = new int[h]; IERROR_CHECK_MEMORY(j0l); int *j0s = new int[h]; IERROR_CHECK_MEMORY(j0s); float *y0l = new float[h]; IERROR_CHECK_MEMORY(y0l); float *y0s = new float[h]; IERROR_CHECK_MEMORY(y0s); int i, j, k; float v, x0, y0, x1, y1, dx, dy; for(j=0; j=mHeight) { IBUG_WARN("Corrupted image."); return; } dy = y0 - 0.5 - j0l[j]; if(dy > 0.0) { j0s[j] = j0l[j] + 1; if(j0s[j] >= mHeight) j0s[j] = j0l[j]; y0l[j] = 1.0 - dy; y0s[j] = dy; } else { j0s[j] = j0l[j] - 1; if(j0s[j] < 0) j0s[j] = j0l[j]; y0l[j] = 1.0 + dy; y0s[j] = -dy; } } for(i=0; i=mWidth) { IBUG_WARN("Corrupted image."); return; } dx = x0 - 0.5 - i0l[i]; if(dx > 0.0) { i0s[i] = i0l[i] + 1; if(i0s[i] >= mWidth) i0s[i] = i0l[i]; x0l[i] = 1.0 - dx; x0s[i] = dx; } else { i0s[i] = i0l[i] - 1; if(i0s[i] < 0) i0s[i] = i0l[i]; x0l[i] = 1.0 + dx; x0s[i] = -dx; } } for(j=0; j 255.0) v = 255.0; dPtr[k+mDepth*(i+w*j)] = (unsigned char)iMath::Round2Int(v); } } } delete [] i0l; delete [] i0s; delete [] x0l; delete [] x0s; delete [] j0l; delete [] j0s; delete [] y0l; delete [] y0s; mWidth = w; mHeight = h; mData->Delete(); mData = tmp; if(f == _None) return; this->Smooth(1.0,1.0); } void iImage::Smooth(float dx, float dy) { vtkImageGaussianSmooth *filter = vtkImageGaussianSmooth::New(); filter->SetDimensionality(3); filter->SetStandardDeviations(dx,dy,0.0); filter->SetRadiusFactors(1.0*dx,1.0*dy,1.0); // exp(-0.5*3.3^2) = 1/255 filter->SetInputData(mData); filter->Update(); if(mData != 0) mData->Delete(); mData = filter->GetOutput(); mData->Register(0); filter->Delete(); } bool iImage::CombineInPseudoColor(const iImage &imRed, const iImage &imGreen, const iImage &imBlue) { bool rIn(!imRed.IsEmpty()), gIn(!imGreen.IsEmpty()), bIn(!imBlue.IsEmpty()); int d = 0, w = 0, h = 0; if(rIn) { d = imRed.Depth(); w = imRed.Width(); h = imRed.Height(); } if(gIn) { if(d == 0) { d = imGreen.Depth(); w = imGreen.Width(); h = imGreen.Height(); } else { if(d != imGreen.Depth()) return false; if(w != imGreen.Width()) return false; if(h != imGreen.Height()) return false; } } if(bIn) { if(d == 0) { d = imBlue.Depth(); w = imBlue.Width(); h = imBlue.Height(); } else { if(d != imBlue.Depth()) return false; if(w != imBlue.Width()) return false; if(h != imBlue.Height()) return false; } } if((d!=3 && d!=4) || w==0 || h==0) return false; // no non-empty image is specified // // Reset the data // this->Clear(); mWidth = w; mHeight = h; mDepth = d; mData = CreateData(w,h,d); unsigned char *dPtr1, *dPtr2, *dPtr = this->DataPointer(); unsigned char *rPtr1, *rPtr2, *rPtr = imRed.DataPointer(); unsigned char *gPtr1, *gPtr2, *gPtr = imGreen.DataPointer(); unsigned char *bPtr1, *bPtr2, *bPtr = imBlue.DataPointer(); // // Fill in the data // int i, j, a[3], aMax; for(j=0; j 3) { a[0] = rIn ? rPtr2[3] : 0; a[1] = gIn ? gPtr2[3] : 0; a[2] = bIn ? bPtr2[3] : 0; aMax = (a[0] > a[1]) ? a[0] : a[1]; aMax = (a[2] > aMax) ? a[2] : aMax; } else { aMax = a[0] = a[1] = a[2] = 255; } // // Combine // dPtr2[0] = rIn ? (a[0]*(int(rPtr2[0])+int(rPtr2[1])+int(rPtr2[2])))/(3*aMax) : 0; dPtr2[1] = gIn ? (a[1]*(int(gPtr2[0])+int(gPtr2[1])+int(gPtr2[2])))/(3*aMax) : 0; dPtr2[2] = bIn ? (a[2]*(int(bPtr2[0])+int(bPtr2[1])+int(bPtr2[2])))/(3*aMax) : 0; if(d > 3) dPtr2[3] = aMax; } } return true; } void iImage::Crop(int x, int y, int w, int h) { if(x < 0) x = 0; if(y < 0) y = 0; if(x+w > mWidth) w = mWidth - x; if(y+h > mHeight) h = mHeight - y; // // Do nothing is we don't actually crop anything // if(x==0 && y==0 && w==mWidth && h==mHeight) return; vtkImageData *tmp = this->CreateData(w,h,mDepth); int j; vtkIdType line = mDepth*w; for(j=0; jGetScalarPointer(0,j,0),mData->GetScalarPointer(x,y+j,0),line); } mWidth = w; mHeight = h; mData->Delete(); mData = tmp; } void iImage::DrawFrame(int width, const iColor &color) { if(this->IsEmpty()) return; int i, j, k; unsigned char *ptr, *ptr0 = (unsigned char *)mData->GetScalarPointer(); unsigned char c[4]; if(width > (mWidth+1)/2) width = (mWidth+1)/2; if(width > (mHeight+1)/2) width = (mHeight+1)/2; c[0] = (unsigned char)color.Red(); c[1] = (unsigned char)color.Green(); c[2] = (unsigned char)color.Blue(); c[3] = (unsigned char)color.Alpha(); for(j=0; j(&iImageComposer::Set##_fname_),static_cast<_class_::GetterType>(&iImageComposer::Get##_fname_),#_fname_,#_sname_,static_cast<_class_::SizeType>(&iImageComposer::GetNumberOfBackgroundWindows)) #define iImageComposerConstructMacroF(_class_,_fname_,_sname_) \ _fname_(Self(),static_cast<_class_::SetterType>(&iImageComposer::Set##_fname_),static_cast<_class_::GetterType>(&iImageComposer::Get##_fname_),#_fname_,#_sname_,static_cast<_class_::SizeType>(&iImageComposer::GetNumberOfForegroundWindows)) iImageComposer::iImageComposer(iShell *s, const iString &fname, const iString &sname) : iObject(s,fname,sname), iShellComponent(s), iObjectConstructPropertyMacroV(Int,iImageComposer,NumTiles,nt,2), iObjectConstructPropertyMacroS(Int,iImageComposer,NumForegroundWindows,nfg), iObjectConstructPropertyMacroS(Bool,iImageComposer,ScaleBackground,sb), iObjectConstructPropertyMacroS(Bool,iImageComposer,InnerBorder,ib), iObjectConstructPropertyMacroS(Color,iImageComposer,BorderColor,bc), iObjectConstructPropertyMacroS(Int,iImageComposer,BorderWidth,bw), iImageComposerConstructMacroB(pv_int,BackgroundWindowIndex,bgi), iImageComposerConstructMacroB(pv_int,BackgroundWindowIndex2,bgi2), iImageComposerConstructMacroB(pv_int,BackgroundWindowIndex3,bgi3), iImageComposerConstructMacroB(pv_string,BackgroundWindowWallpaperFile,bgw), iImageComposerConstructMacroF(pv_color,ForegroundWindowBorderColor,fgc), iImageComposerConstructMacroF(pv_float,ForegroundWindowScale,fgs), iImageComposerConstructMacroF(pv_int,ForegroundWindowIndex,fgi), iImageComposerConstructMacroF(pv_int,ForegroundWindowIndex2,fgi2), iImageComposerConstructMacroF(pv_int,ForegroundWindowIndex3,fgi3), iImageComposerConstructMacroF(pv_int,ForegroundWindowBorderWidth,fgw), iImageComposerConstructMacroF(pv_int,ForegroundWindowPositionX,fgx), iImageComposerConstructMacroF(pv_int,ForegroundWindowPositionY,fgy), iImageComposerConstructMacroF(pv_int,ForegroundWindowZoomSource,fgz), iImageComposerConstructMacroF(pv_bool,ForegroundWindowZoom4Line,fgz4), iImageComposerConstructMacroF(pv_float,ForegroundWindowZoomFactor,fgzf), iImageComposerConstructMacroF(pv_float,ForegroundWindowZoomX,fgzx), iImageComposerConstructMacroF(pv_float,ForegroundWindowZoomY,fgzy), iObjectConstructPropertyMacroQ(Int,iImageComposer,ImageWidth,w), iObjectConstructPropertyMacroQ(Int,iImageComposer,ImageHeight,h) { mRenderMode = RenderMode::NoRender; BackgroundWindowIndex.AddFlag(iProperty::_FunctionsAsIndex); BackgroundWindowIndex2.AddFlag(iProperty::_FunctionsAsIndex); BackgroundWindowIndex3.AddFlag(iProperty::_FunctionsAsIndex); ForegroundWindowIndex.AddFlag(iProperty::_FunctionsAsIndex); ForegroundWindowIndex2.AddFlag(iProperty::_FunctionsAsIndex); ForegroundWindowIndex3.AddFlag(iProperty::_FunctionsAsIndex); mBlockUpdate = mInComposing = false; mNumTiles[0] = mNumTiles[1] = 1; mBorderWidth = 0; mBorderColor = iColor(0,0,0); mInnerBorder = false; mFullWidth = mTileWidth = 640; mFullHeight = mTileHeight = 480; mBackgroundWindows.Add(iImageComposerBackgroundWindow::New(0,0,this)); } iImageComposer::~iImageComposer() { int i; for(i=0; i1 || n<1) return false; if(n == mNumTiles[k]) return true; int i, j; // // CreateBackgroundImage checks for out-of-boundary requests, so we need to have // mNumTiles[X,Y] Set before creating new windows // int oldNumTiles[2]; oldNumTiles[0] = mNumTiles[0]; oldNumTiles[1] = mNumTiles[1]; mNumTiles[k] = n; iArray tmp; for(j=0; jUpdateSize(); return true; } void iImageComposer::AddForegroundWindow(iViewModule *v) { if(v == 0) return; mForegroundWindows.Add(iImageComposerForegroundWindow::New(v,this)); } void iImageComposer::RemoveForegroundWindow(int n) { if(n<0 || n>=mForegroundWindows.Size()) return; delete mForegroundWindows[n]; mForegroundWindows.Remove(n); } bool iImageComposer::SetScaleBackground(bool s) { if(s != mScaleBackground) { mScaleBackground = s; this->UpdateSize(); } return true; } bool iImageComposer::SetInnerBorder(bool s) { if(s != mInnerBorder) { mInnerBorder = s; this->UpdateSize(); } return true; } bool iImageComposer::SetBorderWidth(int s) { if(s >= 0) { mBorderWidth = s; this->UpdateSize(); } return true; } bool iImageComposer::SetBorderColor(const iColor& c) { if(c != mBorderColor) { mBorderColor = c; } return true; } void iImageComposer::Update() { this->UpdateWindowList(); this->UpdateSize(); } void iImageComposer::UpdateSize() { if(mBlockUpdate) return; int i; // // Compute real size // mTileWidth = mTileHeight = 0; for(i=0; iGetWindowWidth()) mTileWidth = mBackgroundWindows[i]->GetWindowWidth(); if(mTileHeight < mBackgroundWindows[i]->GetWindowHeight()) mTileHeight = mBackgroundWindows[i]->GetWindowHeight(); } if(mTileWidth==0 || mTileHeight==0) { for(i=0; iGetShell()->GetNumberOfViewModules(); i++) { if(mTileWidth < this->GetShell()->GetViewModule(i)->GetThisImageWidth()) mTileWidth = this->GetShell()->GetViewModule(i)->GetThisImageWidth(); if(mTileHeight < this->GetShell()->GetViewModule(i)->GetThisImageHeight()) mTileHeight = this->GetShell()->GetViewModule(i)->GetThisImageHeight(); } } mFullWidth = mNumTiles[0]*mTileWidth + 2*mBorderWidth; mFullHeight = mNumTiles[1]*mTileHeight + 2*mBorderWidth; if(mInnerBorder) { mFullWidth += (mNumTiles[0]-1)*mBorderWidth; mFullHeight += (mNumTiles[1]-1)*mBorderWidth; } // // Make sure no foreground window moves out of image area // for(i=0; iCorrectPosition(); } } int iImageComposer::GetImageWidth() const { return mFullWidth; } int iImageComposer::GetImageHeight() const { return mFullHeight; } void iImageComposer::UpdateWindowList() { int i; for(i=0; iUpdateWindow(); for(i=0; iUpdateWindow(); if(mForegroundWindows[i]->GetViewModule() == 0) this->RemoveForegroundWindow(i); } } iImageComposerBackgroundWindow* iImageComposer::GetBackgroundWindow(int i) const { if(i>=0 && i=0 && iIsEmpty()) return true; } // // Is there an active foreground window? // if(mForegroundWindows.Size() > 0) return true; // // At the very least, is there a border? // return mBorderWidth > 0; } bool iImageComposer::Compose(iViewModule *vm, iStereoImageArray &images) { if(vm == 0) { IBUG_ERROR("No ViewModule is specified"); return false; } iMonitor h(this); mInComposing = true; // // We received a request to compose the images and put the data into images. // First, make sure that Composer is up to date // this->UpdateWindowList(); iStereoImage outIm; char rgb[3]; int i, j, k, xoff; unsigned char *dPtr, *dPtr1; outIm.Scale(mFullWidth,mFullHeight); dPtr = outIm.LeftEye().DataPointer(); int d = outIm.Depth(); bool work = false; if(mBorderWidth > 0) { work = true; // // Create the border // mBorderColor.GetRGB(rgb); // // Vertical lines // for(j=0; jIsEmpty()) { work = true; mBackgroundWindows[i]->Draw(outIm); } } if(h.IsStopped()) return false; // // Foreground windows are rendered in the inverse order // for(i=0; iIsEmpty()) { work = true; mForegroundWindows[i]->Draw(outIm); } } if(h.IsStopped()) return false; if(work) { images.Clear(); images.Add(outIm); } else { vm->RenderImages(images); } mInComposing = false; return !h.IsStopped(); } // // Getters // int iImageComposer::GetNumForegroundWindows() const { return mForegroundWindows.Size(); } int iImageComposer::GetBackgroundWindowIndex(int i) const { return mBackgroundWindows[i]->GetWindowNumber(0); } int iImageComposer::GetBackgroundWindowIndex2(int i) const { return mBackgroundWindows[i]->GetWindowNumber(1); } int iImageComposer::GetBackgroundWindowIndex3(int i) const { return mBackgroundWindows[i]->GetWindowNumber(2); } const iString& iImageComposer::GetBackgroundWindowWallpaperFile(int i) const { return mBackgroundWindows[i]->GetWallpaperFile(); } int iImageComposer::GetForegroundWindowIndex(int i) const { return mForegroundWindows[i]->GetWindowNumber(0); } int iImageComposer::GetForegroundWindowIndex2(int i) const { return mForegroundWindows[i]->GetWindowNumber(1); } int iImageComposer::GetForegroundWindowIndex3(int i) const { return mForegroundWindows[i]->GetWindowNumber(2); } int iImageComposer::GetForegroundWindowPositionX(int i) const { return mForegroundWindows[i]->GetPositionX(); } int iImageComposer::GetForegroundWindowPositionY(int i) const { return mForegroundWindows[i]->GetPositionY(); } int iImageComposer::GetForegroundWindowBorderWidth(int i) const { return mForegroundWindows[i]->GetBorderWidth(); } const iColor& iImageComposer::GetForegroundWindowBorderColor(int i) const { return mForegroundWindows[i]->GetBorderColor(); } float iImageComposer::GetForegroundWindowScale(int i) const { return mForegroundWindows[i]->GetScale(); } int iImageComposer::GetForegroundWindowZoomSource(int i) const { if(mForegroundWindows[i]->GetZoomSource() == 0) { return 0; } else { return mForegroundWindows[i]->GetZoomSource()->GetId(); } } bool iImageComposer::GetForegroundWindowZoom4Line(int i) const { return (mForegroundWindows[i]->GetZoomFlag() == iImageComposerForegroundWindow::_4Lines); } float iImageComposer::GetForegroundWindowZoomX(int i) const { return mForegroundWindows[i]->GetZoomX(); } float iImageComposer::GetForegroundWindowZoomY(int i) const { return mForegroundWindows[i]->GetZoomY(); } float iImageComposer::GetForegroundWindowZoomFactor(int i) const { return mForegroundWindows[i]->GetZoomFactor(); } // // Setters // bool iImageComposer::SetNumForegroundWindows(int n) { while(n < mForegroundWindows.Size()) this->RemoveForegroundWindow(n); while(n > mForegroundWindows.Size()) this->AddForegroundWindow(this->GetShell()->GetViewModule(0)); this->UpdateWindowList(); return true; } bool iImageComposer::SetBackgroundWindowIndex(int i, int k) { mBackgroundWindows[i]->SetViewModule((k>=0)?this->GetShell()->GetViewModule(k):0,0); this->Update(); return true; } bool iImageComposer::SetBackgroundWindowIndex2(int i, int k) { mBackgroundWindows[i]->SetViewModule((k>=0)?this->GetShell()->GetViewModule(k):0,1); this->Update(); return true; } bool iImageComposer::SetBackgroundWindowIndex3(int i, int k) { mBackgroundWindows[i]->SetViewModule((k>=0)?this->GetShell()->GetViewModule(k):0,2); this->Update(); return true; } bool iImageComposer::SetBackgroundWindowWallpaperFile(int i, const iString& s) { if(mBackgroundWindows[i]->LoadWallpaperImage(s)) { this->Update(); return true; } else return false; } bool iImageComposer::SetForegroundWindowIndex(int i, int k) { mForegroundWindows[i]->SetViewModule(this->GetShell()->GetViewModule(k),0); return true; } bool iImageComposer::SetForegroundWindowIndex2(int i, int k) { mForegroundWindows[i]->SetViewModule(this->GetShell()->GetViewModule(k),1); return true; } bool iImageComposer::SetForegroundWindowIndex3(int i, int k) { mForegroundWindows[i]->SetViewModule(this->GetShell()->GetViewModule(k),2); return true; } bool iImageComposer::SetForegroundWindowBorderWidth(int i, int w) { mForegroundWindows[i]->SetBorderWidth(w); return true; } bool iImageComposer::SetForegroundWindowBorderColor(int i, const iColor& c) { mForegroundWindows[i]->SetBorderColor(c); return true; } bool iImageComposer::SetForegroundWindowScale(int i, float v) { mForegroundWindows[i]->SetScale(v); return true; } bool iImageComposer::SetForegroundWindowPositionX(int i, int v) { mForegroundWindows[i]->SetPositionX(v); return true; } bool iImageComposer::SetForegroundWindowPositionY(int i, int v) { mForegroundWindows[i]->SetPositionY(v); return true; } bool iImageComposer::SetForegroundWindowZoom4Line(int i, bool b) { mForegroundWindows[i]->SetZoomFlag(b?iImageComposerForegroundWindow::_4Lines:1); return true; } bool iImageComposer::SetForegroundWindowZoomX(int i, float v) { mForegroundWindows[i]->SetZoomPosition(v,mForegroundWindows[i]->GetZoomY()); return true; } bool iImageComposer::SetForegroundWindowZoomY(int i, float v) { mForegroundWindows[i]->SetZoomPosition(mForegroundWindows[i]->GetZoomX(),v); return true; } bool iImageComposer::SetForegroundWindowZoomSource(int i, int k) { if(k < 0) { mForegroundWindows[i]->SetZoomSource(this->GetBackgroundWindow(-k-1)); } else if(k > 0) { mForegroundWindows[i]->SetZoomSource(this->GetForegroundWindow(k-1)); } else { mForegroundWindows[i]->SetZoomSource(0); } return true; } bool iImageComposer::SetForegroundWindowZoomFactor(int i, float v) { mForegroundWindows[i]->SetZoomFactor(v); return true; } ifrit-4.1.2/core/iimagecomposer.h0000674060175406010010000001073512641012523015322 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IIMAGECOMPOSER_H #define IIMAGECOMPOSER_H #include "iobject.h" #include "ishellcomponent.h" #include "iarray.h" class iImageComposerWindow; class iImageComposerBackgroundWindow; class iImageComposerForegroundWindow; class iStereoImageArray; class iViewModule; #define iImageComposerPropertyMacro(_name_,_id_) \ iObjectSlotMacro2V(_name_,iType::Traits::Type); \ iPropertyVector _name_ class iImageComposer : public iObject, public iShellComponent { public: vtkTypeMacro(iImageComposer,iObject); static iImageComposer* New(iShell *s = 0); iObjectPropertyMacro1V(NumTiles,Int,2); iObjectPropertyMacro2S(NumForegroundWindows,Int); iObjectPropertyMacro1S(ScaleBackground,Bool); iObjectPropertyMacro1S(InnerBorder,Bool); iObjectPropertyMacro1S(BorderColor,Color); iObjectPropertyMacro1S(BorderWidth,Int); iImageComposerPropertyMacro(BackgroundWindowIndex,Int); iImageComposerPropertyMacro(BackgroundWindowIndex2,Int); iImageComposerPropertyMacro(BackgroundWindowIndex3,Int); iImageComposerPropertyMacro(BackgroundWindowWallpaperFile,String); iImageComposerPropertyMacro(ForegroundWindowIndex,Int); iImageComposerPropertyMacro(ForegroundWindowIndex2,Int); iImageComposerPropertyMacro(ForegroundWindowIndex3,Int); iImageComposerPropertyMacro(ForegroundWindowBorderColor,Color); iImageComposerPropertyMacro(ForegroundWindowScale,Float); iImageComposerPropertyMacro(ForegroundWindowBorderWidth,Int); iImageComposerPropertyMacro(ForegroundWindowPositionX,Int); iImageComposerPropertyMacro(ForegroundWindowPositionY,Int); iImageComposerPropertyMacro(ForegroundWindowZoomSource,Int); iImageComposerPropertyMacro(ForegroundWindowZoom4Line,Bool); iImageComposerPropertyMacro(ForegroundWindowZoomFactor,Float); iImageComposerPropertyMacro(ForegroundWindowZoomX,Float); iImageComposerPropertyMacro(ForegroundWindowZoomY,Float); iObjectPropertyMacro2Q(ImageWidth,Int); iObjectPropertyMacro2Q(ImageHeight,Int); int GetTileWidth() const { return mTileWidth; } int GetTileHeight() const { return mTileHeight; } int GetNumTilesX() const { return mNumTiles[0]; } int GetNumTilesY() const { return mNumTiles[1]; } int GetNumberOfBackgroundWindows() const { return mBackgroundWindows.Size(); } int GetNumberOfForegroundWindows() const { return mForegroundWindows.Size(); } inline iImageComposerBackgroundWindow* GetBackgroundWindow(int i, int j) const { return this->GetBackgroundWindow(i+mNumTiles[0]*j); } iImageComposerBackgroundWindow* GetBackgroundWindow(int i) const; iImageComposerForegroundWindow* GetForegroundWindow(int i) const; void AddForegroundWindow(iViewModule *v); void RemoveForegroundWindow(int n); // // Other functions // inline bool InComposing() const { return mInComposing; } bool Compose(iViewModule *vm, iStereoImageArray &images); bool IsActive(); void Update(); // update all void UpdateWindowList(); void UpdateSize(); protected: virtual ~iImageComposer(); private: iImageComposer(iShell *s, const iString &fname, const iString &sname); bool mBlockUpdate, mInComposing; int mFullWidth, mFullHeight; int mTileWidth, mTileHeight; iArray mBackgroundWindows; iArray mForegroundWindows; }; #endif // IIMAGECOMPOSER_H ifrit-4.1.2/core/iimagecomposerwindows.cpp0000674060175406010010000006555412641012553017304 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iimagecomposerwindows.h" #include "ierror.h" #include "iimagecomposer.h" #include "imath.h" #include "imonitor.h" #include "ishell.h" #include "istereoimagearray.h" #include "iviewmodule.h" #include #include // // Templates // #include "iarray.tlh" iColor iImageComposerBackgroundWindow::mEmptyBackground = iColor::White(); int iImageComposerForegroundWindow::mPosQuantum = 10; namespace iImageComposerWindow_Private { void DrawPixel(int x, int y, float f, const iStereoImage &image, const iColor &color, bool swap = false) { if(x<0 || y<0) return; if(swap) { int tmp = x; x = y; y = tmp; } if(x>=image.Width() || y>=image.Height()) return; unsigned char rgb[4], *ptr; color.GetRGB(rgb); rgb[3] = 255; int eye, numEyes = 1; if(image.IsStereo()) numEyes = 2; int k, d = image.Depth(), w = image.Width(); for(eye=0; eye abs(x2-x1)); if(swap) { tmp = x1; x1 = y1; y1 = tmp; tmp = x2; x2 = y2; y2 = tmp; } if(x2 < x1) { tmp = x1; x1 = x2; x2 = tmp; tmp = y1; y1 = y2; y2 = tmp; } float dx = x2 - x1; float dy = y2 - y1; float gradient = dy/dx; // dx cannot be zero // // main loop // int x; float f, y = y1 + 1.0e-3; // first y-intersection for the main loop for(x=x1; x<=x2; x++) { f = fpart(y); DrawPixel(x,int(y),f0*(1.0f-f),image,color,swap); DrawPixel(x,int(y)+1,f0*f,image,color,swap); y += gradient; } } void DrawWideLine(int x1, int y1, int x2, int y2, int w, const iStereoImage &image, const iColor &color, int corner = -1) { int i, j; if(w < 1) { return; } if(x1==x2 && y1==y2) { for(j=0; j abs(x2-x1)); if(swap) { tmp = x1; x1 = y1; y1 = tmp; tmp = x2; x2 = y2; y2 = tmp; if(corner != -1) corner = 2*(corner & 1) + (corner & 2)/2; } if(x2 < x1) { tmp = x1; x1 = x2; x2 = tmp; tmp = y1; y1 = y2; y2 = tmp; if(corner != -1) corner = (corner & 2) + 1 - (corner & 1); } float dx = x2 - x1; float dy = y2 - y1; float gradient = dy/dx; // dx cannot be zero float normal[2]; normal[1] = 1.0/sqrt(1.0+gradient*gradient); normal[0] = -gradient*normal[1]; int ymin, ymax; if(y1 < y2) { ymin = y1; ymax = y2 + w - 1; } else if(y1 > y2) { ymin = y2; ymax = y1 + w - 1; } else { ymin = y1; ymax = y1 + w - 1; } // // main loop // const int subsample = 4; const float scale = 1.0f/subsample, offset = 0.5f*(subsample-1), w2 = 0.5*w; float r1, r2; switch(w) { case 1: { r1 = r2 = w2; break; } case 2: { r1 = w2 - 0.75; r2 = w2 + 0.75; break; } default: { r1 = w2 - 0.75; r2 = w2 + 0.75; break; } } int x0, y0, k, kmax = w + 2; float p[2], f, r; float x = x1 + 0.5*(w-1), y = y1 + 0.5*(w-1), xmax = x2 + 0.5*(w-1) + 1.0e-2; while(x < xmax) { x0 = iMath::Round2Int(x); y0 = iMath::Round2Int(y); for(k=-kmax; k<=kmax; k++) { f = 0.0f; for(j=0; j0.0 && y0+k>=ymin && y0+k<=ymax) { DrawPixel(x0,y0+k,f,image,color,swap); } } x += 1.0f; y += gradient; } } }; using namespace iImageComposerWindow_Private; // // Helper classes // iImageComposerWindow::iImageComposerWindow(iViewModule *vm, iImageComposer *ic) { mType = UNDEFINED; mComposer = ic; mViewModules[0] = vm; mViewModules[1] = mViewModules[2] = 0; } iImageComposerWindow::~iImageComposerWindow() { while(mZoomTargets.Size() > 0) { mZoomTargets[mZoomTargets.MaxIndex()]->SetZoomSource(0); } } void iImageComposerWindow::SetViewModule(iViewModule *vm, int win) { if(win>0 && win<3) { mViewModules[win] = vm; } else { mViewModules[0] = vm; if(vm == 0) mViewModules[1] = mViewModules[2] = 0; } } void iImageComposerWindow::UpdateWindow() { int j, k; bool present; iShell *s = this->GetImageComposer()->GetShell(); for(j=0; j<3; j++) if(mViewModules[j] != 0) { present = false; for(k=0; !present && kGetNumberOfViewModules(); k++) { if(mViewModules[j] == s->GetViewModule(k)) present = true; } if(!present) this->SetViewModule(0,j); } } int iImageComposerWindow::GetWindowNumber(int win) const { if(win<0 && win>2) win = 2; if(mViewModules[win] == 0) return -1; else return mViewModules[win]->GetWindowNumber(); } bool iImageComposerWindow::RenderStereoImage(iStereoImage &im) const { iMonitor h(this->GetImageComposer()); if(mViewModules[0] == 0) { h.PostError("Unable to render image: ViewModule is not set."); return false; } if(mViewModules[1]!=0 || mViewModules[2]!=0) { iStereoImage imRed, imGreen, imBlue; mViewModules[0]->RenderStereoImage(imRed); if(h.IsStopped()) return false; im.SetStereo(imRed.IsStereo()); if(mViewModules[1] != 0) { mViewModules[1]->RenderStereoImage(imGreen); if(h.IsStopped()) return false; if(imRed.Width()!=imGreen.Width() || imRed.Height()!=imGreen.Height()) { imGreen.SetStereo(imRed.IsStereo()); imGreen.Scale(imRed.Width(),imRed.Height()); } } if(mViewModules[2] != 0) { mViewModules[2]->RenderStereoImage(imBlue); if(h.IsStopped()) return false; if(imRed.Width()!=imBlue.Width() || imRed.Height()!=imBlue.Height()) { imBlue.SetStereo(imRed.IsStereo()); imBlue.Scale(imRed.Width(),imRed.Height()); } } if(!im.CombineInPseudoColor(imRed,imGreen,imBlue)) { h.PostError("Unable to render image: error in pseudo-color composting."); return false; } else return true; } else { mViewModules[0]->RenderStereoImage(im); return !h.IsStopped(); } } void iImageComposerWindow::OverlayImage(iStereoImage &outIm, const iStereoImage &inIm, const iColor &bg) const { // // Check that dimensions are ok. // iStereoImage winIm(inIm); winIm.Scale(this->GetContentsWidth(),this->GetContentsHeight()); unsigned char *outPtr[2], *outPtr1, *winPtr, *winPtr1; // // Prepare the left eye // outPtr[0] = outIm.LeftEye().DataPointer(); // // Begin creating a non-stereo image // int eye, numEyes = 1; outPtr[1] = 0; // for debugging - will crash if tries to write into the right eye image // // Check whether we need to switch to a stereo mode // if(winIm.IsStereo()) { numEyes = 2; if(!outIm.IsStereo()) { // // Prepare the right eye // outIm.CopyLeftEyeToRightEye(); outPtr[1] = outIm.RightEye().DataPointer(); } } int outWidth = outIm.Width(); int outHeight = outIm.Height(); int winWidth = winIm.Width(); int winHeight = winIm.Height(); int winDepth = winIm.Depth(); int outDepth = outIm.Depth(); int d = (winDepth < outDepth) ? winDepth : outDepth; // // Fill in the background color; this may be needed since winIm may have smaller size/depth // int i, j, k, xoff, yoff, w1, h1; char rgb[4]; bg.GetRGB(rgb); rgb[3] = 255; if(inIm.IsEmpty() || this->GetContentsWidth()GetImageWidth() || this->GetContentsHeight()GetImageHeight() || winDepthGetImageX(); yoff = this->GetImageY(); w1 = this->GetImageWidth(); h1 = this->GetImageHeight(); for(eye=0; eyeGetContentsX(); yoff = this->GetContentsY(); w1 = winWidth; h1 = winHeight; if(xoff+w1 > outWidth) w1 = outWidth - xoff; if(yoff+h1 > outHeight) h1 = outHeight - yoff; for(eye=0; eyeGetBackgroundWindow(j))!=0 && w!=this) j++; if(w == this) { return -(1+j); } else { IBUG_WARN("Invalid id for a background window."); return 0; } } int iImageComposerBackgroundWindow::GetImageX() const { int x = mComposer->GetBorderWidth() + mTileX*mComposer->GetTileWidth(); if(mComposer->GetInnerBorder()) x += mTileX*mComposer->GetBorderWidth(); return x; } int iImageComposerBackgroundWindow::GetImageY() const { int y = mComposer->GetBorderWidth() + mTileY*mComposer->GetTileHeight(); if(mComposer->GetInnerBorder()) y += mTileY*mComposer->GetBorderWidth(); return y; } int iImageComposerBackgroundWindow::GetImageWidth() const { return mComposer->GetTileWidth(); } int iImageComposerBackgroundWindow::GetImageHeight() const { return mComposer->GetTileHeight(); } int iImageComposerBackgroundWindow::GetContentsX() const { int x = this->GetImageX(); if(!mComposer->GetScaleBackground()) x += (mComposer->GetTileWidth()-this->GetWindowWidth())/2; return x; } int iImageComposerBackgroundWindow::GetContentsY() const { int y = this->GetImageY(); if(!mComposer->GetScaleBackground()) y += (mComposer->GetTileHeight()-this->GetWindowHeight())/2; return y; } int iImageComposerBackgroundWindow::GetContentsWidth() const { if(mComposer->GetScaleBackground()) return mComposer->GetTileWidth(); else return this->GetWindowWidth(); } int iImageComposerBackgroundWindow::GetContentsHeight() const { if(mComposer->GetScaleBackground()) return mComposer->GetTileHeight(); else return this->GetWindowHeight(); } int iImageComposerBackgroundWindow::GetWindowWidth() const { if(this->GetViewModule() != 0) return this->GetViewModule()->GetThisImageWidth(); else return mWallpaperImage.Width(); } int iImageComposerBackgroundWindow::GetWindowHeight() const { if(this->GetViewModule() != 0) return this->GetViewModule()->GetThisImageHeight(); else return mWallpaperImage.Height(); } bool iImageComposerBackgroundWindow::IsEmpty() const { return (this->GetViewModule()==0 && mWallpaperImage.IsEmpty()); } void iImageComposerBackgroundWindow::Draw(iStereoImage &outIm) const { iStereoImage winIm; if(this->GetViewModule() != 0) { // // Render the image // if(this->RenderStereoImage(winIm)) this->OverlayImage(outIm,winIm,mEmptyBackground); } else { winIm = mWallpaperImage; this->OverlayImage(outIm,winIm,mEmptyBackground); } } bool iImageComposerBackgroundWindow::LoadWallpaperImage(const iString &s) { if(s != mWallpaperFile) { if(s.IsEmpty()) { mWallpaperImage.Clear(); mWallpaperFile.Clear(); mComposer->UpdateSize(); return true; } else { bool ret = mWallpaperImage.LoadFromFile(s); if(ret) { mWallpaperFile = s; mComposer->UpdateSize(); } return ret; } } else return true; } // // Foreground windows // iImageComposerForegroundWindow* iImageComposerForegroundWindow::New(iViewModule *vm, iImageComposer *ic) { return new iImageComposerForegroundWindow(vm,ic); } iImageComposerForegroundWindow::iImageComposerForegroundWindow(iViewModule *vm, iImageComposer *ic) : iImageComposerWindow(vm,ic) { mType = FOREGROUND; mBorderWidth = 1; mScale = 0.5; mPosX = mPosY = 0; mZoomX = mZoomY = 0.5f; mZoomFactor = 0.2f; mZoomSource = 0; mZoomFlag = _4Lines; mZoomAuto = false; } iImageComposerForegroundWindow::~iImageComposerForegroundWindow() { if(mZoomSource != 0) mZoomSource->UnRegisterZoomTarget(this); } int iImageComposerForegroundWindow::GetId() const { iImageComposerForegroundWindow *w; int j = 0; while((w = mComposer->GetForegroundWindow(j))!=0 && w!=this) j++; if(w == this) { return (1+j); } else { IBUG_WARN("Invalid id for a foreground window."); return 0; } } int iImageComposerForegroundWindow::GetImageX() const { return mPosX; } int iImageComposerForegroundWindow::GetImageY() const { return mPosY; } int iImageComposerForegroundWindow::GetImageWidth() const { return 2*mBorderWidth + this->GetContentsWidth(); } int iImageComposerForegroundWindow::GetImageHeight() const { return 2*mBorderWidth + this->GetContentsHeight(); } int iImageComposerForegroundWindow::GetContentsX() const { return mPosX + mBorderWidth; } int iImageComposerForegroundWindow::GetContentsY() const { return mPosY + mBorderWidth; } int iImageComposerForegroundWindow::GetContentsWidth() const { return iMath::Round2Int(mScale*this->GetWindowWidth()); } int iImageComposerForegroundWindow::GetContentsHeight() const { return iMath::Round2Int(mScale*this->GetWindowHeight()); } int iImageComposerForegroundWindow::GetWindowWidth() const { if(this->GetViewModule() != 0) return this->GetViewModule()->GetThisImageWidth(); else return 0; } int iImageComposerForegroundWindow::GetWindowHeight() const { if(this->GetViewModule() != 0) return this->GetViewModule()->GetThisImageHeight(); else return 0; } void iImageComposerForegroundWindow::UpdateWindow() { this->iImageComposerWindow::UpdateWindow(); mZoomAuto = this->SyncZoom(); } bool iImageComposerForegroundWindow::IsEmpty() const { return (this->GetViewModule() == 0); } void iImageComposerForegroundWindow::Draw(iStereoImage &outIm) const { if(this->GetViewModule() != 0) { iMonitor h(this->GetImageComposer()); iStereoImage winIm; this->RenderStereoImage(winIm); if(h.IsStopped()) return; // // Draw zoom first // if(mZoomSource != 0) { int bw = this->GetBorderWidth(); iColor bc(this->GetBorderColor()); int zx1 = iMath::Round2Int(mZoomSource->GetContentsX()+(mZoomX*mZoomSource->GetContentsWidth()-0.5*this->GetZoomWidth())); int zy1 = iMath::Round2Int(mZoomSource->GetContentsY()+(mZoomY*mZoomSource->GetContentsHeight()-0.5*this->GetZoomHeight())); int zx2 = iMath::Round2Int(mZoomSource->GetContentsX()+(mZoomX*mZoomSource->GetContentsWidth()+0.5*this->GetZoomWidth())); int zy2 = iMath::Round2Int(mZoomSource->GetContentsY()+(mZoomY*mZoomSource->GetContentsHeight()+0.5*this->GetZoomHeight())); int i; for(i=0; iGetCoordinatesForZoomLine(0,x,y,mPosX,mPosY,this->GetImageWidth()-bw+1,this->GetImageHeight()-bw+1)) DrawWideLine(zx1,zy1,x,y,bw,outIm,bc,0); if(this->GetCoordinatesForZoomLine(1,x,y,mPosX,mPosY,this->GetImageWidth()-bw+1,this->GetImageHeight()-bw+1)) DrawWideLine(zx2,zy1,x,y,bw,outIm,bc,1); if(this->GetCoordinatesForZoomLine(2,x,y,mPosX,mPosY,this->GetImageWidth()-bw+1,this->GetImageHeight()-bw+1)) DrawWideLine(zx1,zy2,x,y,bw,outIm,bc,2); if(this->GetCoordinatesForZoomLine(3,x,y,mPosX,mPosY,this->GetImageWidth()-bw+1,this->GetImageHeight()-bw+1)) DrawWideLine(zx2,zy2,x,y,bw,outIm,bc,3); } // // Draw the window // this->OverlayImage(outIm,winIm,mBorderColor); } } void iImageComposerForegroundWindow::SetScale(float s) { if(s>0.0 && s<=1.0 && fabs(s-mScale)>1.0e-5) { mScale = s; this->CorrectPosition(); } } void iImageComposerForegroundWindow::SetPosition(int x, int y) { if(x!=mPosX || y!=mPosY) { // // Quantize the position but not if we are against the outer wall // if(x+this->GetImageWidth() < mComposer->GetImageWidth()) mPosX = mPosQuantum*(x/mPosQuantum); else mPosX = x; if(y+this->GetImageHeight() < mComposer->GetImageHeight()) mPosY = mPosQuantum*(y/mPosQuantum); else mPosY = y; this->CorrectPosition(); } } void iImageComposerForegroundWindow::SetBorderWidth(int w) { if(w>=0 && w!=mBorderWidth) { mBorderWidth = w; this->CorrectPosition(); } } void iImageComposerForegroundWindow::SetBorderColor(const iColor& c) { if(c != mBorderColor) { mBorderColor = c; } } void iImageComposerForegroundWindow::CorrectPosition() { if(mPosX < 0) mPosX = 0; if(mPosY < 0) mPosY = 0; if(mBorderWidth > this->GetWindowWidth()/4) mBorderWidth = this->GetWindowWidth()/4; if(mBorderWidth > this->GetWindowHeight()/4) mBorderWidth = this->GetWindowHeight()/4; // // Is scale small enough? // if(this->GetImageWidth() > mComposer->GetImageWidth()) { mPosX = 0; mScale = float(mComposer->GetImageWidth()-2*mBorderWidth)/this->GetWindowWidth(); } if(this->GetImageHeight() > mComposer->GetImageHeight()) { mPosY = 0; mScale = float(mComposer->GetImageHeight()-2*mBorderWidth)/this->GetWindowHeight(); } // // Now we are guaranteed to fit into the image. But are we fully inside? // if(mPosX+this->GetImageWidth() > mComposer->GetImageWidth()) mPosX = mComposer->GetImageWidth() - this->GetImageWidth(); if(mPosY+this->GetImageHeight() > mComposer->GetImageHeight()) mPosY = mComposer->GetImageHeight() - this->GetImageHeight(); this->UpdateZoomFlag(); } void iImageComposerForegroundWindow::SetZoomSource(iImageComposerWindow *source) { if(source != this) { if(mZoomSource != 0) mZoomSource->UnRegisterZoomTarget(this); mZoomSource = source; if(source != 0) source->RegisterZoomTarget(this); this->UpdateZoomPosition(); this->UpdateZoomFlag(); } } void iImageComposerForegroundWindow::SetZoomPosition(float x, float y) { if(x>0.0f && x<1.0f && y>0.0f && y<1.0f && (fabs(x-mZoomX)>1.0e-5 || fabs(y-mZoomY)>1.0e-5)) { mZoomX = x; mZoomY = y; if(mZoomSource != 0) this->UpdateZoomPosition(); } } void iImageComposerForegroundWindow::SetZoomFactor(float factor) { if(factor>0.0f && factor<1.0f && fabs(factor-mZoomFactor)>1.0e-5) { mZoomFactor = factor; if(mZoomSource != 0) this->UpdateZoomPosition(); } } void iImageComposerForegroundWindow::SetZoomFlag(int f) { if(f > 0) { mZoomFlag = f; this->UpdateZoomFlag(); } } bool iImageComposerForegroundWindow::GetCoordinatesForZoomLine(int n, int &x, int &y, int wx, int wy, int ww, int wh) const { if(n<0 || n>3 || (mZoomFlag & (1<GetContentsX()+(mZoomX*mZoomSource->GetContentsWidth()-0.5*this->GetZoomWidth())); pz[1][0] = pz[3][0] = iMath::Round2Int(mZoomSource->GetContentsX()+(mZoomX*mZoomSource->GetContentsWidth()+0.5*this->GetZoomWidth())); pz[0][1] = pz[1][1] = iMath::Round2Int(mZoomSource->GetContentsY()+(mZoomY*mZoomSource->GetContentsHeight()-0.5*this->GetZoomHeight())); pz[2][1] = pz[3][1] = iMath::Round2Int(mZoomSource->GetContentsY()+(mZoomY*mZoomSource->GetContentsHeight()+0.5*this->GetZoomHeight())); pw[0][0] = pw[2][0] = mPosX; pw[1][0] = pw[3][0] = mPosX + this->GetImageWidth() - 1; pw[0][1] = pw[1][1] = mPosY; pw[2][1] = pw[3][1] = mPosY + this->GetImageHeight() - 1; for(j=0; j<4; j++) { n[0] = pw[j][1] - pz[j][1]; n[1] = pz[j][0] - pw[j][0]; ok = true; s = 0; for(i=0; ok && i<4; i++) if(i != j) { d = n[0]*(pz[i][0]-pz[j][0]) + n[1]*(pz[i][1]-pz[j][1]); if(s==0 && d!=0) { s = d/abs(d); } if(d*s < 0) ok = false; } for(i=0; ok && i<4; i++) if(i != j) { d = n[0]*(pw[i][0]-pz[j][0]) + n[1]*(pw[i][1]-pz[j][1]); if(d*s < 0) ok = false; } if(ok) { mZoomFlag = mZoomFlag | (1 << j); } } // // Activate a switch if needed // if(mZoomFlag == (_Line11 | _Line12)) { mZoomFlag = _Line21 | _Line22 | _ShiftX; } if(mZoomFlag == (_Line21 | _Line22)) { mZoomFlag = _Line11 | _Line12 | _ShiftX; } if(mZoomFlag == (_Line11 | _Line21)) { mZoomFlag = _Line12 | _Line22 | _ShiftY; } if(mZoomFlag == (_Line12 | _Line22)) { mZoomFlag = _Line11 | _Line21 | _ShiftY; } } void iImageComposerForegroundWindow::UpdateZoomPosition() { if(mZoomSource==0 || this->GetViewModule()==0 || (mZoomAuto=this->SyncZoom())) return; if(this->GetWindowWidth()*mZoomFactor > mZoomSource->GetContentsWidth()) { mZoomFactor = float(mZoomSource->GetContentsWidth())/this->GetWindowWidth(); } if(this->GetWindowHeight()*mZoomFactor > mZoomSource->GetContentsHeight()) { mZoomFactor = float(mZoomSource->GetContentsHeight())/this->GetWindowHeight(); } float w = 0.5*this->GetWindowWidth()*mZoomFactor/mZoomSource->GetContentsWidth(); float h = 0.5*this->GetWindowHeight()*mZoomFactor/mZoomSource->GetContentsHeight(); if(mZoomX < w) mZoomX = w; if(mZoomY < h) mZoomY = h; if(mZoomX > 1.0f-w) mZoomX = 1.0f - w; if(mZoomY > 1.0f-h) mZoomY = 1.0f - h; this->UpdateZoomFlag(); } bool iImageComposerForegroundWindow::SyncZoom() { if(mZoomSource==0 || mZoomSource->GetViewModule()==0 || this->GetViewModule()==0) return false; iViewModule *source = mZoomSource->GetViewModule(); iViewModule *target = this->GetViewModule(); // // Do we have the same projections? // if(source->GetRenderer()->GetActiveCamera()->GetParallelProjection() != target->GetRenderer()->GetActiveCamera()->GetParallelProjection()) return false; // // ViewUp vectors must coincide // int i; double sPos[3], tPos[3]; source->GetRenderer()->GetActiveCamera()->GetViewUp(sPos); target->GetRenderer()->GetActiveCamera()->GetViewUp(tPos); for(i=0; i<3; i++) if(fabs(sPos[i]-tPos[i]) > iMath::_DoubleTolerance) { return false; } // // In perspective projection camera focal points, view angles, and directions must coincide // if(source->GetRenderer()->GetActiveCamera()->GetParallelProjection() == 0) { source->GetRenderer()->GetActiveCamera()->GetFocalPoint(sPos); target->GetRenderer()->GetActiveCamera()->GetFocalPoint(tPos); for(i=0; i<3; i++) if(fabs(sPos[i]-tPos[i]) > iMath::_DoubleTolerance) { return false; } source->GetRenderer()->GetActiveCamera()->GetDirectionOfProjection(sPos); target->GetRenderer()->GetActiveCamera()->GetDirectionOfProjection(tPos); for(i=0; i<3; i++) if(fabs(sPos[i]-tPos[i]) > iMath::_DoubleTolerance) { return false; } if(fabs(source->GetRenderer()->GetActiveCamera()->GetViewAngle()-target->GetRenderer()->GetActiveCamera()->GetViewAngle()) > iMath::_DoubleTolerance) { return false; } } // // Get target frustrum planes // double aspect[2], planes[24]; target->GetRenderer()->GetAspect(aspect); target->GetRenderer()->GetActiveCamera()->GetFrustumPlanes(aspect[0]/aspect[1],planes); // // Find the source focal plane // double fp[3], fplane[4]; source->GetRenderer()->GetActiveCamera()->GetFocalPoint(fp); source->GetRenderer()->GetActiveCamera()->GetViewPlaneNormal(fplane); fplane[3] = -(fplane[0]*fp[0]+fplane[1]*fp[1]+fplane[2]*fp[2]); // // Find the rectangle that we see at the camera focal point in the target window // double r[4][3]; if(!iMath::Intersect3Planes(fplane,planes+4*0,planes+4*2,r[0])) return false; // -X & -Y planes if(!iMath::Intersect3Planes(fplane,planes+4*1,planes+4*2,r[1])) return false; // +X & -Y planes if(!iMath::Intersect3Planes(fplane,planes+4*0,planes+4*3,r[2])) return false; // -X & +Y planes if(!iMath::Intersect3Planes(fplane,planes+4*1,planes+4*3,r[3])) return false; // +X & +Y planes // // Find the projections of this rectangle onto the source view plane // for(i=0; i<4; i++) { source->GetRenderer()->WorldToView(r[i][0],r[i][1],r[i][2]); source->GetRenderer()->ViewToNormalizedViewport(r[i][0],r[i][1],r[i][2]); } // // Is it a rectangle? // if(fabs(r[0][0]-r[2][0])>iMath::_DoubleTolerance || fabs(r[1][0]-r[3][0])>iMath::_DoubleTolerance || fabs(r[0][1]-r[1][1])>iMath::_DoubleTolerance || fabs(r[2][1]-r[3][1])>iMath::_DoubleTolerance) return false; // // Does it fits? // if(r[0][0]<0.0 || r[0][0]>1.0 || r[0][1]<0.0 || r[0][1]>1.0 || r[3][0]<0.0 || r[3][0]>1.0 || r[3][1]<0.0 || r[3][1]>1.0) return false; mZoomFactor = (r[3][1]-r[0][1])*mZoomSource->GetContentsHeight()/this->GetWindowHeight(); mZoomX = 0.5*(r[0][0]+r[3][0]); mZoomY = 0.5*(r[0][1]+r[3][1]); this->UpdateZoomFlag(); return true; } ifrit-4.1.2/core/iimagecomposerwindows.h0000674060175406010010000001536412641012523016740 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IIMAGECOMPOSERWINDOWS_H #define IIMAGECOMPOSERWINDOWS_H #include "iarray.h" #include "icolor.h" #include "iimage.h" #include "istring.h" class iImageComposer; class iImageComposerForegroundWindow; class iStereoImage; class iViewModule; class iImageComposerWindow { public: enum iImageComposerWindowType { UNDEFINED = 0, BACKGROUND = 1, FOREGROUND = 2 }; virtual ~iImageComposerWindow(); inline iViewModule* GetViewModule(int win = 0) const { return mViewModules[(win>0 && win<3)?win:0]; } void SetViewModule(iViewModule *vm, int win = 0); inline iImageComposerWindowType GetType() const { return mType; } inline const iImageComposer* GetImageComposer() const { return mComposer; } int GetWindowNumber(int win = 0) const; virtual void UpdateWindow(); virtual int GetId() const = 0; virtual int GetImageX() const = 0; virtual int GetImageY() const = 0; virtual int GetImageWidth() const = 0; virtual int GetImageHeight() const = 0; virtual int GetContentsX() const = 0; virtual int GetContentsY() const = 0; virtual int GetContentsWidth() const = 0; virtual int GetContentsHeight() const = 0; virtual int GetWindowWidth() const = 0; virtual int GetWindowHeight() const = 0; virtual bool IsEmpty() const = 0; virtual void Draw(iStereoImage &outIm) const = 0; void RegisterZoomTarget(iImageComposerForegroundWindow *win); void UnRegisterZoomTarget(iImageComposerForegroundWindow *win); protected: iImageComposerWindow(iViewModule *vm, iImageComposer *ic); // // Helper functions // bool RenderStereoImage(iStereoImage &winIm) const; void OverlayImage(iStereoImage &outIm, const iStereoImage &winIm, const iColor &bg) const; iViewModule *mViewModules[3]; iImageComposer *mComposer; iImageComposerWindowType mType; iLookupArray mZoomTargets; }; class iImageComposerBackgroundWindow : public iImageComposerWindow { public: static iImageComposerBackgroundWindow* New(int tx, int ty, iImageComposer *ic); virtual int GetId() const; virtual int GetImageX() const; virtual int GetImageY() const; virtual int GetImageWidth() const; virtual int GetImageHeight() const; virtual int GetContentsX() const; virtual int GetContentsY() const; virtual int GetContentsWidth() const; virtual int GetContentsHeight() const; virtual int GetWindowWidth() const; virtual int GetWindowHeight() const; virtual bool IsEmpty() const; virtual void Draw(iStereoImage &outIm) const; int GetTileX() const { return mTileX; } int GetTileY() const { return mTileY; } const iString& GetWallpaperFile() const { return mWallpaperFile; } const iImage& GetWallpaperImage() const { return mWallpaperImage; } bool LoadWallpaperImage(const iString &s); protected: iImageComposerBackgroundWindow(int tx, int ty, iImageComposer *ic); private: int mTileX, mTileY; iImage mWallpaperImage; iString mWallpaperFile; static iColor mEmptyBackground; }; class iImageComposerForegroundWindow : public iImageComposerWindow { public: enum Flags { _Line11 = 1, _Line21 = 2, _Line12 = 4, _Line22 = 8, _4Lines = 15, _ShiftX = 16, _ShiftY = 32 }; static iImageComposerForegroundWindow* New(iViewModule *vm, iImageComposer *ic); virtual ~iImageComposerForegroundWindow(); virtual int GetId() const; virtual int GetImageX() const; virtual int GetImageY() const; virtual int GetImageWidth() const; virtual int GetImageHeight() const; virtual int GetContentsX() const; virtual int GetContentsY() const; virtual int GetContentsWidth() const; virtual int GetContentsHeight() const; virtual int GetWindowWidth() const; virtual int GetWindowHeight() const; virtual void UpdateWindow(); virtual bool IsEmpty() const; virtual void Draw(iStereoImage &outIm) const; inline float GetScale() const { return mScale; } inline int GetPositionX() const { return mPosX; } inline int GetPositionY() const { return mPosY; } inline int GetBorderWidth() const { return mBorderWidth; } inline const iColor& GetBorderColor() const { return mBorderColor; } void SetScale(float s); void SetPosition(int x, int y); void SetPositionX(int x); void SetPositionY(int y); void SetBorderWidth(int w); void SetBorderColor(const iColor& c); void CorrectPosition(); inline float GetZoomX() const { return mZoomX; } inline float GetZoomY() const { return mZoomY; } inline float GetZoomFactor() const { return mZoomFactor; } inline iImageComposerWindow* GetZoomSource() const { return mZoomSource; } inline int GetZoomFlag() const { return mZoomFlag; } void SetZoomSource(iImageComposerWindow *source); void SetZoomPosition(float x, float y); void SetZoomFactor(float factor); void SetZoomFlag(int f); inline bool IsAutoZoom() const { return mZoomAuto; } bool GetCoordinatesForZoomLine(int n, int &x, int &y, int wx, int wy, int ww, int wh) const; inline float GetZoomWidth() const { return mZoomFactor*this->GetWindowWidth(); } inline float GetZoomHeight() const { return mZoomFactor*this->GetWindowHeight(); } protected: iImageComposerForegroundWindow(iViewModule *vm, iImageComposer *ic); void UpdateZoomPosition(); void UpdateZoomFlag(); bool SyncZoom(); private: float mScale; iColor mBorderColor; int mBorderWidth, mPosX, mPosY; int mZoomFlag; bool mZoomAuto; float mZoomX, mZoomY, mZoomFactor; iImageComposerWindow *mZoomSource; static int mPosQuantum; }; inline void iImageComposerForegroundWindow::SetPositionX(int x) { this->SetPosition(x,mPosY); } inline void iImageComposerForegroundWindow::SetPositionY(int y) { this->SetPosition(mPosX,y); } #endif // IIMAGECOMPOSERWINDOWS_H ifrit-4.1.2/core/ikeyboardinteractorstyle.cpp0000674060175406010010000000572112641012554020002 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ikeyboardinteractorstyle.h" #include iKeyboardInteractorStyle* iKeyboardInteractorStyle::New() { return new iKeyboardInteractorStyle; } iKeyboardInteractorStyle::iKeyboardInteractorStyle() { } iKeyboardInteractorStyle::~iKeyboardInteractorStyle() { } void iKeyboardInteractorStyle::OnChar() { // // Are these universal??? // const char _Left = 18; const char _Down = 21; const char _Up = 19; const char _Right = 20; // catch keycodes switch (Interactor->GetKeyCode()) { case 'a': case 'A': { MotionFactor *= 0.5; break; } case 'z': case 'Z': { MotionFactor *= 2.0; break; } case '+': { this->DoZoom(0,1); break; } case '-': { this->DoZoom(0,-1); break; } case 'h': case 'H': case _Left: { this->DoMove(-1,0); break; } case 'j': case 'J': case _Down: { this->DoMove(0,-1); break; } case 'k': case 'K': case _Up: { this->DoMove(0,1); break; } case 'l': case 'L': case _Right: { this->DoMove(1,0); break; } default: { vtkInteractorStyleTrackballCamera::OnChar(); } } Interactor->Render(); } void iKeyboardInteractorStyle::FakeEvent(int dx, int dy) { int x, y; Interactor->GetMousePosition(&x,&y); Interactor->SetEventPosition(x-dx,y-dy); Interactor->SetEventPosition(x,y); this->FindPokedRenderer(x,y); } void iKeyboardInteractorStyle::DoZoom(int dx, int dy) { this->FakeEvent(dx,dy); this->Dolly(); } void iKeyboardInteractorStyle::DoMove(int dx, int dy) { this->FakeEvent(dx,dy); if(Interactor->GetShiftKey()) { this->Pan(); } else if(Interactor->GetControlKey()) { this->Spin(); } else { this->Rotate(); } } ifrit-4.1.2/core/ikeyboardinteractorstyle.h0000674060175406010010000000411312641012523017435 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IKEYBOARDINTERACTORSTYLE_H #define IKEYBOARDINTERACTORSTYLE_H #include class iKeyboardInteractorStyle: public vtkInteractorStyleTrackballCamera { public: vtkTypeMacro(iKeyboardInteractorStyle,vtkInteractorStyleTrackballCamera); static iKeyboardInteractorStyle* New(); // // Disable mouse interaction // virtual void OnMouseMove(){} virtual void OnLeftButtonDown(){} virtual void OnLeftButtonUp(){} virtual void OnMiddleButtonDown(){} virtual void OnMiddleButtonUp(){} virtual void OnRightButtonDown(){} virtual void OnRightButtonUp(){} virtual void OnChar(); protected: virtual ~iKeyboardInteractorStyle(); private: iKeyboardInteractorStyle(); void FakeEvent(int dx, int dy); void DoZoom(int dx, int dy); void DoMove(int dx, int dy); }; #endif // IKEYBOARDINTERACTORSTYLE_H ifrit-4.1.2/core/ilabel.cpp0000674060175406010010000001247712641012554014113 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ilabel.h" #include "idatareader.h" #include "iedition.h" #include "ierror.h" #include "irendertool.h" #include "itextactor.h" #include "iviewmodule.h" // // Templates // #include "iarray.tlh" #include "iproperty.tlh" // // Main class // iLabel* iLabel::New(iViewModule *vm) { static iString LongName("Label"); static iString ShortName("lb"); IASSERT(vm); return new iLabel(vm,LongName,ShortName); } iLabel::iLabel(iViewModule *vm, const iString &fname, const iString &sname) : iViewModuleTool(vm,fname,sname), iObjectConstructPropertyMacroS(String,iLabel,Name,n), iObjectConstructPropertyMacroS(String,iLabel,Unit,u), iObjectConstructPropertyMacroS(Float,iLabel,Offset,o), iObjectConstructPropertyMacroS(Float,iLabel,Scale,s), iObjectConstructPropertyMacroS(Int,iLabel,NumDigits,d) { mName = "Record"; mUnit = ""; mScale = 1.0; mOffset = 0.0; mNumDigits = 2; mLeftJustification = false; // // Text label actors // mActor = iTextActor::New(this->GetViewModule()->GetRenderTool()); IERROR_CHECK_MEMORY(mActor); mActor->SetText(""); mActor->SetJustification(1,1); mActor->SetPosition(0.95,0.9); mActor->VisibilityOff(); mActor->PickableOff(); this->GetViewModule()->GetRenderTool()->AddObject(mActor); iEdition::ApplySettings(this); } iLabel::~iLabel() { this->GetViewModule()->GetRenderTool()->RemoveObject(mActor); mActor->Delete(); } void iLabel::Update() { if(this->GetViewModule()->GetReader()->IsFileAnimatable()) { iString s; int r = this->GetViewModule()->GetReader()->GetRecordNumber(); float v = 0.0; iString unit(mUnit); if(fabs(mScale) > 0.0) v = mScale*(r-mOffset); else { unit.Clear(); if(this->GetViewModule()->GetReader()->GetFileSetRoot().EndsWith("1.")) r += 10000; v = 1.0e4/((r>0)?r:1)-1.0; } // // Auto unit expansion // if(!unit.IsEmpty() && unit[0]=='.') { // // Use SI prefixes (from wikipedia.org) // if(v > 1.0e24) { v *= 1.0e-24; unit.Replace(0,1,"Y"); } else if(v > 1.0e21) { v *= 1.0e-21; unit.Replace(0,1,"Z"); } else if(v > 1.0e18) { v *= 1.0e-18; unit.Replace(0,1,"E"); } else if(v > 1.0e15) { v *= 1.0e-15; unit.Replace(0,1,"P"); } else if(v > 1.0e12) { v *= 1.0e-12; unit.Replace(0,1,"T"); } else if(v > 1.0e9) { v *= 1.0e-9; unit.Replace(0,1,"G"); } else if(v > 1.0e6) { v *= 1.0e-6; unit.Replace(0,1,"M"); } else if(v > 1.0e3) { v *= 1.0e-3; unit.Replace(0,1,"k"); } else if(v>0.0 && v<1.0e-23) { v *= 1.0e24; unit.Replace(0,1,"y"); } else if(v>0.0 && v<1.0e-20) { v *= 1.0e21; unit.Replace(0,1,"z"); } else if(v>0.0 && v<1.0e-17) { v *= 1.0e18; unit.Replace(0,1,"a"); } else if(v>0.0 && v<1.0e-14) { v *= 1.0e15; unit.Replace(0,1,"f"); } else if(v>0.0 && v<1.0e-11) { v *= 1.0e12; unit.Replace(0,1,"p"); } else if(v>0.0 && v<1.0e-8) { v *= 1.0e9; unit.Replace(0,1,"n"); } else if(v>0.0 && v<1.0e-5) { v *= 1.0e6; unit.Replace(0,1,"u"); } else if(v>0.0 && v<1.0e-2) { v *= 1.0e3; unit.Replace(0,1,"m"); } else unit = unit.Part(1); } iString format = "%-." + iString::FromNumber(mNumDigits) + "f"; iString num = iString::FromNumber(v,format.ToCharPointer()); // // Beatify // int i = num.Find('.'); if(i == -1) i = num.Length(); while(i > 3) { i -= 3; num = num.Part(0,i) + "," + num.Part(i); } // // Form label // s = mName + "=" + num + unit; mActor->SetText(s); } else { mActor->SetText(""); } } void iLabel::JustifyLeft(bool s) { if(s != mLeftJustification) { mLeftJustification = s; mActor->MoveJustification(s?-1:1); } } bool iLabel::SetName(const iString& s) { mName = s; this->Update(); return true; } bool iLabel::SetUnit(const iString& s) { mUnit = s; this->Update(); return true; } bool iLabel::SetScale(float v) { mScale = v; this->Update(); return true; } bool iLabel::SetOffset(float v) { mOffset = v; this->Update(); return true; } bool iLabel::SetNumDigits(int v) { if(v>=0 && v<=7) { mNumDigits = v; this->Update(); return true; } else return false; } bool iLabel::ShowBody(bool s) { mActor->SetVisibility(s?1:0); this->Update(); return true; } ifrit-4.1.2/core/ilabel.h0000674060175406010010000000363012641012524013544 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ILABEL_H #define ILABEL_H #include "iviewmoduletool.h" class iTextActor; class iLabel : public iViewModuleTool { public: vtkTypeMacro(iLabel,iViewModuleTool); static iLabel* New(iViewModule *vm = 0); iObjectPropertyMacro1S(Name,String); iObjectPropertyMacro1S(Unit,String); iObjectPropertyMacro1S(Offset,Float); iObjectPropertyMacro1S(Scale,Float); iObjectPropertyMacro1S(NumDigits,Int); void JustifyLeft(bool s); void Update(); protected: virtual ~iLabel(); private: iLabel(iViewModule *vm, const iString &fname, const iString &sname); virtual bool ShowBody(bool s); bool mLeftJustification; iTextActor *mActor; }; #endif // ILABEL_H ifrit-4.1.2/core/ilegend.cpp0000674060175406010010000001023412641012554014257 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ilegend.h" #include "ierror.h" #include "ioverlayhelper.h" #include #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "igenericprop.tlh" iLegend* iLegend::New(iRenderTool *rv) { IASSERT(rv); return new iLegend(rv); } iLegend::iLegend(iRenderTool *rv) : iGenericProp(true), mOverlayHelper(rv) { this->BorderOn(); this->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); this->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport(); this->GetPosition2Coordinate()->SetReferenceCoordinate(this->GetPositionCoordinate()); this->SetPosition2(0.25,0.08); this->BorderOn(); this->LockBorderOn(); this->GetProperty()->SetColor(0.0,0.0,0.0); this->GetProperty()->SetLineWidth(2.0); this->GetEntryTextProperty()->SetJustificationToLeft(); this->GetEntryTextProperty()->SetVerticalJustificationToCentered(); this->GetEntryTextProperty()->SetBold(1); this->PickableOff(); } iLegend::~iLegend() { } void iLegend::UpdateGeometry(vtkViewport *viewport) { // // Maintain the font size // int mag = mOverlayHelper->GetRenderingMagnification(); if(mag == 1) { double *x1 = this->GetPosition(); double *x2 = this->GetPosition2(); int *size = viewport->GetSize(); float s = (mOverlayHelper->GetFontSize(viewport)*NumberOfEntries+(NumberOfEntries+1)*Padding)/fabs(size[1]*x2[1]); mOverlayHelper->UpdateTextProperty(viewport,this->EntryTextProperty); this->EntryTextProperty->Modified(); mUnmagx1[0] = x1[0]; mUnmagx1[1] = x1[1]; mUnmagx2[0] = s*x2[0]; mUnmagx2[1] = s*x2[1]; // // Corrections // if(mUnmagx2[0] > 0.25) mUnmagx2[0] = 0.25; if(mUnmagx2[1] > 0.16) mUnmagx2[1] = 0.16; if(mUnmagx1[0] > 0.5) { mUnmagx1[0] = 0.98 - mUnmagx2[0]; this->SetPosition(mUnmagx1[0],mUnmagx1[1]); } } else { int winij[2]; mOverlayHelper->ComputePositionShiftsUnderMagnification(winij); this->SetPosition(mag*mUnmagx1[0]-winij[0],mag*mUnmagx1[1]-winij[1]); this->Padding *= mag; } this->SetPosition2(mUnmagx2[0]*mag,mUnmagx2[1]*mag); // // Scale lines // this->GetProperty()->SetLineWidth(2*mag); this->GetProperty()->SetColor(this->GetOverlayHelper()->GetColor(viewport).ToVTK()); } void iLegend::UpdateOverlay(vtkViewport *viewport) { int i; // // Redo text colors and rerender them // for(i=0; iNumberOfEntries; i++) { //this->TextMapper[i]->GetTextProperty()->ShallowCopy(this->GetEntryTextProperty()); this->TextMapper[i]->GetTextProperty()->SetColor(this->GetOverlayHelper()->GetColor(viewport).ToVTK()); } } void iLegend::Reset() { int mag = mOverlayHelper->GetRenderingMagnification(); // // Reset to the unmagnified state // if(mag > 1) { this->SetPosition(mUnmagx1[0],mUnmagx1[1]); this->SetPosition2(mUnmagx2[0],mUnmagx2[1]); this->Padding /= mag; } } ifrit-4.1.2/core/ilegend.h0000674060175406010010000000352012641012524013721 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ILEGEND_H #define ILEGEND_H #include "igenericprop.h" #include #include "ipointermacro.h" class iOverlayHelper; class iRenderTool; class iLegend: public iGenericProp { IPOINTER_AS_USER(OverlayHelper); public: vtkTypeMacro(iLegend,vtkLegendBoxActor); static iLegend* New(iRenderTool *rv = 0); protected: virtual ~iLegend(); virtual void UpdateGeometry(vtkViewport *vp); virtual void UpdateOverlay(vtkViewport *vp); virtual void Reset(); private: iLegend(iRenderTool *rv); float mUnmagx1[2], mUnmagx2[2]; }; #endif // ILEGEND_H ifrit-4.1.2/core/ilights.cpp0000674060175406010010000001420512641012554014315 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ilights.h" #include "ierror.h" #include "irendertool.h" #include "iviewmodule.h" #include "ivtk.h" #include #include #include // // Templates // #include "iarray.tlh" #include "iproperty.tlh" namespace iLightKit_Private { void UpdateLight(vtkLight *l, double elevation, double azimuth, double ex[3], double ey[3], double ez[3]) { int i; double org[3], pos[3]; elevation = vtkMath::RadiansFromDegrees(elevation); azimuth = vtkMath::RadiansFromDegrees(azimuth); org[0] = cos(elevation)*sin(azimuth); org[1] = sin(elevation); org[2] = cos(elevation)*cos(azimuth); for(i=0; i<3; i++) { pos[i] = org[0]*ex[i] + org[1]*ey[i] + org[2]*ez[i]; } l->SetPosition(pos); } }; using namespace iLightKit_Private; // // Main class // iLightKit::iLightKit(vtkRenderer *renderer) { this->vtkLightKit::SetKeyLightAngle(45.0,0.0); this->vtkLightKit::SetFillLightAngle(-75.0,0.0); this->vtkLightKit::SetBackLightAngle(0.0,110.0); this->vtkLightKit::SetKeyLightIntensity(1.0); this->vtkLightKit::SetKeyToFillRatio(3.0); this->vtkLightKit::SetKeyToHeadRatio(6.0); this->vtkLightKit::SetKeyToBackRatio(3.0); mAngles[0] = mAngles[1] = 0.0; // // Initiate lights // if(renderer != 0) { // // This is to fix a bug with off-screen rednering: the key light must be first. // renderer->AddLight(this->KeyLight); renderer->AddLight(this->FillLight); renderer->AddLight(this->HeadLight); renderer->AddLight(this->BackLight0); renderer->AddLight(this->BackLight1); } this->UpdateAngles(); } iLightKit::~iLightKit() { } void iLightKit::SetAngles(double a[2]) { if(fabs(a[0]-mAngles[0])>1.0e-5 || fabs(a[1]-mAngles[1])>1.0e-5) { mAngles[0] = a[0]; mAngles[1] = a[1]; this->UpdateAngles(); } } void iLightKit::SetIntensities(float i[3]) { if(i[0] > 1.0e-10) { this->SetKeyLightIntensity(i[0]); if(i[1] > 1.0e-10) this->SetKeyToFillRatio(i[0]/i[1]); if(i[2] > 1.0e-10) this->SetKeyToHeadRatio(i[0]/i[2]); } } void iLightKit::GetIntensities(float i[3]) const { i[0] = this->KeyLightIntensity; i[1] = this->KeyLightIntensity/this->KeyToFillRatio; i[2] = this->KeyLightIntensity/this->KeyToHeadRatio; } void iLightKit::UpdateAngles() { double ex[3], ey[3], ez[3]; double ce = cos(vtkMath::RadiansFromDegrees(mAngles[0])); double se = sin(vtkMath::RadiansFromDegrees(mAngles[0])); double ca = cos(vtkMath::RadiansFromDegrees(mAngles[1])); double sa = sin(vtkMath::RadiansFromDegrees(mAngles[1])); ex[0] = ce*ca; ex[1] = 0.0; ex[2] = -ce*sa; ey[0] = -se*sa; ey[1] = ce; ey[2] = -se*ca; ez[0] = ce*sa; ez[1] = se; ez[2] = ce*ca; UpdateLight(this->KeyLight,this->KeyLightAngle[0],this->KeyLightAngle[1],ex,ey,ez); UpdateLight(this->FillLight,this->FillLightAngle[0],this->FillLightAngle[1],ex,ey,ez); // UpdateLight(this->Headlight,0.0,0.0,ex,ey,ez); UpdateLight(this->BackLight0,this->BackLightAngle[0],this->BackLightAngle[1],ex,ey,ez); UpdateLight(this->BackLight1,this->BackLightAngle[0],this->BackLightAngle[1],ex,ey,ez); } // // Main class // iLights* iLights::New(iViewModule *vm) { static iString LongName("Lights"); static iString ShortName("ls"); IASSERT(vm); return new iLights(vm,LongName,ShortName); } iLights::iLights(iViewModule *vm, const iString &fname, const iString &sname) : iObject(vm,fname,sname), iViewModuleComponent(vm), iObjectConstructPropertyMacroS(Vector,iLights,Direction,d), iObjectConstructPropertyMacroV(Float,iLights,Intensities,i,3), iObjectConstructPropertyMacroS(Bool,iLights,TwoSided,ts) { mRenderMode = iParameter::RenderMode::Self; mLightKit = new iLightKit(this->GetViewModule()->GetRenderTool()->GetRenderer()); IERROR_CHECK_MEMORY(mLightKit); double angles[2]; mLightKit->GetAngles(angles); // // Use vtkLight angle convention // angles[0] = vtkMath::RadiansFromDegrees(angles[0]); angles[1] = vtkMath::RadiansFromDegrees(angles[1]); mDirection[0] = cos(angles[0])*sin(angles[1]); mDirection[1] = sin(angles[0]); mDirection[2] = cos(angles[0])*cos(angles[1]); } iLights::~iLights() { mLightKit->Delete(); } bool iLights::SetDirection(const iVector3D& dir) { double ang[2]; ang[0] = vtkMath::DegreesFromRadians(atan2(dir[1],sqrt(dir[0]*dir[0]+dir[2]*dir[2]))); ang[1] = vtkMath::DegreesFromRadians(atan2(dir[0],dir[2])); mLightKit->SetAngles(ang); mDirection = dir; return true; } bool iLights::SetIntensities(int i, float v) { if(i>=0 && i<3) { float val[3]; mLightKit->GetIntensities(val); val[i] = v; mLightKit->SetIntensities(val); return true; } else return false; } float iLights::GetIntensities(int i) const { if(i>=0 && i<3) { float val[3]; mLightKit->GetIntensities(val); return val[i]; } else return 0.0; } bool iLights::SetTwoSided(bool v) { this->GetViewModule()->GetRenderer()->SetTwoSidedLighting(v?1:0); return true; } bool iLights::GetTwoSided() const { return (this->GetViewModule()->GetRenderer()->GetTwoSidedLighting() != 0); } ifrit-4.1.2/core/ilights.h0000674060175406010010000000555212641012524013764 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ILIGHTS_H #define ILIGHTS_H #include #include "iobject.h" #include "iviewmodulecomponent.h" class iLights; class vtkRenderer; class iLightKit : public vtkLightKit { friend class iLights; public: void SetAngles(double a[2]); inline void GetAngles(double a[2]) const { a[0] = mAngles[0]; a[1] = mAngles[1]; } void SetIntensities(float i[3]); void GetIntensities(float i[3]) const; protected: virtual ~iLightKit(); private: iLightKit(vtkRenderer *renderer); void UpdateAngles(); // // Hide setting directions for individual lights // void SetKeyLightAngle(double elevation, double azimuth){} void SetKeyLightAngle(double angle[2]){} void SetKeyLightElevation(double x){} void SetKeyLightAzimuth(double x){} void SetFillLightAngle(double elevation, double azimuth){} void SetFillLightAngle(double angle[2]){} void SetFillLightElevation(double x){} void SetFillLightAzimuth(double x){} void SetBackLightAngle(double elevation, double azimuth){} void SetBackLightAngle(double angle[2]){} void SetBackLightElevation(double x){} void SetBackLightAzimuth(double x){} double mAngles[2]; }; class iLights : public iObject, public iViewModuleComponent { public: vtkTypeMacro(iLights,iObject); static iLights* New(iViewModule *vm = 0); iObjectPropertyMacro1S(Direction,Vector); iObjectPropertyMacro2V(Intensities,Float); iObjectPropertyMacro2S(TwoSided,Bool); inline iLightKit* GetLightKit() const { return mLightKit; } protected: virtual ~iLights(); private: iLights(iViewModule *vm, const iString &fname, const iString &sname); iLightKit *mLightKit; }; #endif // ILIGHTS_H ifrit-4.1.2/core/ilinetobandfilter.cpp0000674060175406010010000000302312641012554016344 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ilinetobandfilter.h" // // Templates // #include "igenericfilter.tlh" iLineToBandFilter::iLineToBandFilter(iDataConsumer *consumer) : iGenericPolyDataFilter(consumer,1,true) { } void iLineToBandFilter::ProvideOutput() { this->ExecuteParent(); } ifrit-4.1.2/core/ilinetobandfilter.h0000674060175406010010000000312412641012524016010 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ILINETOBANDFILTER_H #define ILINETOBANDFILTER_H #include "igenericfilter.h" #include class iLineToBandFilter : public iGenericPolyDataFilter { iGenericFilterTypeMacro(iLineToBandFilter,vtkRuledSurfaceFilter); protected: virtual void ProvideOutput(); }; #endif // ILINETOBANDFILTER_H ifrit-4.1.2/core/ilinetotubefilter.cpp0000674060175406010010000002033012641012554016377 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ilinetotubefilter.h" #include #include #include #include #include #include // // Templates // #include "igenericfilter.tlh" iLineToTubeFilter::iLineToTubeFilter(iDataConsumer *consumer) : iGenericPolyDataFilter(consumer,1,true) { } void iLineToTubeFilter::ProvideOutput() { vtkPolyData *input = this->InputData(); vtkPolyData *output = this->OutputData(); // // The code between === lines is copied from vtkTubeFilter.cxx file with minor modifications, as marked behind /// comments // Below is the original copyright notice. // // Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // All rights reserved. // See Copyright.txt or http://www.kitware.com/Copyright.htm for details. // // ========================================================================= // vtkPointData *pd=input->GetPointData(); vtkPointData *outPD=output->GetPointData(); vtkCellData *cd=input->GetCellData(); vtkCellData *outCD=output->GetCellData(); vtkCellArray *inLines = NULL; vtkDataArray *inNormals; vtkDataArray *inScalars=pd->GetScalars(); vtkDataArray *inVectors=pd->GetVectors(); vtkPoints *inPts; vtkIdType numPts = 0; vtkIdType numLines; vtkIdType numNewPts, numNewCells; vtkPoints *newPts; int deleteNormals=0; vtkFloatArray *newNormals; vtkIdType i; double range[2], maxSpeed=0; vtkCellArray *newStrips; vtkIdType npts=0, *pts=NULL; vtkIdType offset=0; vtkFloatArray *newTCoords=NULL; int abort=0; vtkIdType inCellId; double oldRadius=1.0; // Check input and initialize // vtkDebugMacro(<<"Creating tube"); if ( !(inPts=input->GetPoints()) || (numPts = inPts->GetNumberOfPoints()) < 1 || !(inLines = input->GetLines()) || (numLines = inLines->GetNumberOfCells()) < 1 ) { return; } // Create the geometry and topology numNewPts = numPts * this->NumberOfSides; /// ------ Removed ------------------------------------------ /// newPts = vtkPoints::New(); /// --------------------------------------------------------- /// ++++++ Added ++++++++++++++++++++++++++++++++++++++++++++ newPts = vtkPoints::New(inPts->GetDataType()); /// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ newPts->Allocate(numNewPts); newNormals = vtkFloatArray::New(); newNormals->SetName("TubeNormals"); newNormals->SetNumberOfComponents(3); newNormals->Allocate(3*numNewPts); newStrips = vtkCellArray::New(); newStrips->Allocate(newStrips->EstimateSize(1,numNewPts)); vtkCellArray *singlePolyline = vtkCellArray::New(); // Point data: copy scalars, vectors, tcoords. Normals may be computed here. outPD->CopyNormalsOff(); if ( (this->GenerateTCoords == VTK_TCOORDS_FROM_SCALARS && inScalars) || this->GenerateTCoords == VTK_TCOORDS_FROM_LENGTH || this->GenerateTCoords == VTK_TCOORDS_FROM_NORMALIZED_LENGTH ) { newTCoords = vtkFloatArray::New(); newTCoords->SetNumberOfComponents(2); newTCoords->Allocate(numNewPts); outPD->CopyTCoordsOff(); } outPD->CopyAllocate(pd,numNewPts); int generateNormals = 0; if ( !(inNormals=pd->GetNormals()) || this->UseDefaultNormal ) { deleteNormals = 1; inNormals = vtkFloatArray::New(); inNormals->SetNumberOfComponents(3); inNormals->SetNumberOfTuples(numPts); if ( this->UseDefaultNormal ) { for ( i=0; i < numPts; i++) { inNormals->SetTuple(i,this->DefaultNormal); } } else { // Normal generation has been moved to lower in the function. // This allows each different polylines to share vertices, but have // their normals (and hence their tubes) calculated independently generateNormals = 1; } } // If varying width, get appropriate info. // if ( inScalars ) { inScalars->GetRange(range,0); if ((range[1] - range[0]) == 0.0) { if (this->VaryRadius == VTK_VARY_RADIUS_BY_SCALAR ) { vtkWarningMacro(<< "Scalar range is zero!"); } range[1] = range[0] + 1.0; } if (this->VaryRadius == VTK_VARY_RADIUS_BY_ABSOLUTE_SCALAR) { // temporarily set the radius to 1.0 so that radius*scalar = scalar oldRadius = this->Radius; this->Radius = 1.0; if (range[0] < 0.0) { vtkWarningMacro(<< "Scalar values fall below zero when using absolute radius values!"); } } } if ( inVectors ) { maxSpeed = inVectors->GetMaxNorm(); } // Copy selected parts of cell data; certainly don't want normals // numNewCells = inLines->GetNumberOfCells() * this->NumberOfSides + 2; outCD->CopyNormalsOff(); outPD->CopyAllocate(pd,numNewCells); // Create points along each polyline that are connected into NumberOfSides // triangle strips. Texture coordinates are optionally generated. // this->Theta = 2.0*vtkMath::Pi() / this->NumberOfSides; vtkPolyLine *lineNormalGenerator = vtkPolyLine::New(); for (inCellId=0, inLines->InitTraversal(); inLines->GetNextCell(npts,pts) && !abort; inCellId++) { this->UpdateProgress((double)inCellId/numLines); abort = this->GetAbortExecute(); if (npts < 2) { /// ------ Removed ------------------------------------------ /// vtkWarningMacro(<< "Less than two points in line!"); /// --------------------------------------------------------- continue; //skip tubing this polyline } // If necessary calculate normals, each polyline calculates its // normals independently, avoiding conflicts at shared vertices. if (generateNormals) { singlePolyline->Reset(); //avoid instantiation singlePolyline->InsertNextCell(npts,pts); if ( !lineNormalGenerator->GenerateSlidingNormals(inPts,singlePolyline, inNormals) ) { vtkWarningMacro(<< "No normals for line!"); continue; //skip tubing this polyline } } // Generate the points around the polyline. The tube is not stripped // if the polyline is bad. // if ( !this->GeneratePoints(offset,npts,pts,inPts,newPts,pd,outPD, newNormals,inScalars,range,inVectors, maxSpeed,inNormals) ) { vtkWarningMacro(<< "Could not generate points!"); continue; //skip tubing this polyline } // Generate the strips for this polyline (including caps) // this->GenerateStrips(offset,npts,pts,inCellId,cd,outCD,newStrips); // Generate the texture coordinates for this polyline // if ( newTCoords ) { this->GenerateTextureCoords(offset,npts,pts,inPts,inScalars,newTCoords); } // Compute the new offset for the next polyline offset = this->ComputeOffset(offset,npts); }//for all polylines singlePolyline->Delete(); // reset the radius to ite orginal value if necessary if (this->VaryRadius == VTK_VARY_RADIUS_BY_ABSOLUTE_SCALAR) { this->Radius = oldRadius; } // Update ourselves // if ( deleteNormals ) { inNormals->Delete(); } if ( newTCoords ) { outPD->SetTCoords(newTCoords); newTCoords->Delete(); } output->SetPoints(newPts); newPts->Delete(); output->SetStrips(newStrips); newStrips->Delete(); outPD->SetNormals(newNormals); newNormals->Delete(); lineNormalGenerator->Delete(); output->Squeeze(); // // ========================================================================= // } ifrit-4.1.2/core/ilinetotubefilter.h0000674060175406010010000000307412641012524016047 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ILINETOTUBEFILTER_H #define ILINETOTUBEFILTER_H #include "igenericfilter.h" #include class iLineToTubeFilter : public iGenericPolyDataFilter { iGenericFilterTypeMacro(iLineToTubeFilter,vtkTubeFilter); protected: virtual void ProvideOutput(); }; #endif // ILINETOTUBEFILTER_H ifrit-4.1.2/core/ilookuptable.cpp0000674060175406010010000000753712641012554015356 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ilookuptable.h" #include "ierror.h" #include "imath.h" #include "ipalette.h" #include "ipalettecollection.h" #include "istretch.h" #include // // Optimized vtkLookupTable // iLookupTable* iLookupTable::New() { return new iLookupTable; } iLookupTable::iLookupTable() { mPaletteId = 0; } iLookupTable::~iLookupTable() { } void iLookupTable::SetPaletteId(int n) { if(n != mPaletteId) { mPaletteId = n; this->Modified(); this->Build(); } } void iLookupTable::SetReversed(bool s) { if(s && mPaletteId>0) { mPaletteId = -mPaletteId; this->Modified(); this->Build(); } if(!s && mPaletteId<0) { mPaletteId = -mPaletteId; this->Modified(); this->Build(); } } void iLookupTable::SetColor(const iColor &c) { double *rgb = c.ToVTK(); double hsv[3]; vtkMath::RGBToHSV(rgb,hsv); this->SetHueRange(hsv[0],hsv[0]); this->SetSaturationRange(hsv[1],hsv[1]); this->SetValueRange(0.0,1.0); this->Modified(); this->Build(); } void iLookupTable::SetStretchId(int s) { switch(s) { case iStretch::Log: { if(this->TableRange[0] < 1*iMath::_DoubleRes) this->TableRange[0] = 1*iMath::_DoubleRes; if(this->TableRange[1] < 2*iMath::_DoubleRes) this->TableRange[1] = 2*iMath::_DoubleRes; this->SetScaleToLog10(); break; } default: { this->SetScaleToLinear(); } } this->Modified(); } void iLookupTable::ForceBuild() { vtkLookupTable *lut = iPaletteCollection::Global()->GetLookupTable(mPaletteId); if(lut != 0) { this->Table->Initialize(); this->Table->SetArray(lut->GetPointer(0),4*lut->GetNumberOfTableValues(),1); this->BuildTime.Modified(); } else { this->Table->Initialize(); vtkLookupTable::ForceBuild(); } } unsigned long iLookupTable::GetMTime() { vtkLookupTable *lut = iPaletteCollection::Global()->GetLookupTable(mPaletteId); if(lut != 0) { if(lut->GetMTime() > this->vtkObject::GetMTime()) this->Modified(); } return this->vtkObject::GetMTime(); } void iLookupTable::MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat) { // // This is how this function is used. // //this->MapScalarsThroughTable2(scalars->GetVoidPointer(comp), // newColors->GetPointer(0), // scalars->GetDataType(), // scalars->GetNumberOfTuples(), // scalars->GetNumberOfComponents(), // VTK_RGBA); this->vtkLookupTable::MapScalarsThroughTable2(input,output,inputDataType,numberOfValues,inputIncrement,outputFormat); } ifrit-4.1.2/core/ilookuptable.h0000674060175406010010000000354412641012524015012 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ILOOKUPTABLE_H #define ILOOKUPTABLE_H #include class iColor; class iLookupTable : public vtkLookupTable { public: static iLookupTable* New(); void SetStretchId(int s); void SetPaletteId(int n); void SetReversed(bool s); void SetColor(const iColor &c); virtual void ForceBuild(); virtual unsigned long GetMTime(); virtual void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat); protected: virtual ~iLookupTable(); private: iLookupTable(); int mPaletteId; }; #endif // ILOOKUPTABLE_H ifrit-4.1.2/core/imagnifier.cpp0000674060175406010010000002025012641012555014762 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "imagnifier.h" #include "ierror.h" #include "itransform.h" #include "ivtk.h" #include #include #include #include #include #include #include iMagnifier* iMagnifier::New() { return new iMagnifier; } iMagnifier::iMagnifier() { this->Magnification = 1; mTileX = mTileY = 0; } iMagnifier::~iMagnifier() { } int iMagnifier::ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) { // generate the data if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) { this->RequestData(request, inputVector, outputVector); return 1; } // execute information if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) { this->RequestInformation(request, inputVector, outputVector); return 1; } return this->Superclass::ProcessRequest(request, inputVector, outputVector); } void iMagnifier::RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector* outputVector) { vtkInformation *outInfo = outputVector->GetInformationObject(0); vtkImageData *data = vtkImageData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); data->SetExtent(outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT())); #ifdef IVTK_5 data->AllocateScalars(); #else data->AllocateScalars(outInfo); #endif this->Render(data); } void iMagnifier::Render(vtkImageData *data) { // // The code between === lines is copied from vtkRenderLargeImage.cxx file with minor modifications, as marked behind /// comments // Below is the original copyright notice. // // Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // All rights reserved. // See Copyright.txt or http://www.kitware.com/Copyright.htm for details. // // ========================================================================= // int inExtent[6]; /// ++++++ Added ++++++++++++++++++++++++++++++++++++++++++++ vtkIdType inIncr[3]; /// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ int *size; int inWindowExtent[4]; /// ------ Removed ------------------------------------------ /// double viewAngle, parallelScale; /// --------------------------------------------------------- double windowCenter[2]; vtkCamera *cam; unsigned char *pixels, *outPtr; int x, y, row; int rowSize, rowStart, rowEnd, colStart, colEnd; int doublebuffer; int swapbuffers = 0; if (this->GetOutput()->GetScalarType() != VTK_UNSIGNED_CHAR) { vtkErrorMacro("mismatch in scalar types!"); return; } // Get the requested extents. this->GetOutput()->GetExtent(inExtent); // get and transform the increments data->GetIncrements(inIncr); // get the size of the render window size = this->Input->GetRenderWindow()->GetSize(); // convert the request into windows inWindowExtent[0] = inExtent[0]/size[0]; inWindowExtent[1] = inExtent[1]/size[0]; inWindowExtent[2] = inExtent[2]/size[1]; inWindowExtent[3] = inExtent[3]/size[1]; // store the old view angle & set the new cam = this->Input->GetActiveCamera(); cam->GetWindowCenter(windowCenter); /// ------ Removed ------------------------------------------ /// viewAngle = cam->GetViewAngle(); /// parallelScale = cam->GetParallelScale(); /// cam->SetViewAngle(asin(sin(viewAngle*3.1415926/360.0)/this->Magnification) /// * 360.0 / 3.1415926); /// cam->SetParallelScale(parallelScale/this->Magnification); /// --------------------------------------------------------- /// ++++++ Added ++++++++++++++++++++++++++++++++++++++++++++ // // A better way to magnify is to use the camera's UserTransform // vtkHomogeneousTransform *ct = cam->GetUserTransform(); if(ct != 0) ct->Register(this); iTransform *ut = iTransform::New(); cam->SetUserTransform(ut); ut->Delete(); /// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // are we double buffering? If so, read from back buffer .... doublebuffer = this->Input->GetRenderWindow()->GetDoubleBuffer(); if (doublebuffer) { // save swap buffer state to restore later swapbuffers = this->Input->GetRenderWindow()->GetSwapBuffers(); this->Input->GetRenderWindow()->SetSwapBuffers(0); } // render each of the tiles required to fill this request for (y = inWindowExtent[2]; y <= inWindowExtent[3]; y++) { for (x = inWindowExtent[0]; x <= inWindowExtent[1]; x++) { /// ------ Removed ------------------------------------------ /// cam->SetWindowCenter(x*2 - this->Magnification*(1-windowCenter[0]) + 1, /// y*2 - this->Magnification*(1-windowCenter[1]) + 1); /// --------------------------------------------------------- /// ++++++ Added ++++++++++++++++++++++++++++++++++++++++++++ // // This is where the bug is - in perspective projection the view is skewed, so // a better way to magnify is to use the camera's UserTransform. // mTileX = x; mTileY = y; ut->Identity(); ut->Scale(this->Magnification,this->Magnification,1); ut->Translate(-double(2*x+1-this->Magnification)/this->Magnification,-double(2*y+1-this->Magnification)/this->Magnification,0.0); /// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ this->Input->GetRenderWindow()->Render(); pixels = this->Input->GetRenderWindow()->GetPixelData(0,0,size[0] - 1, size[1] - 1, !doublebuffer); // now stuff the pixels into the data row by row colStart = inExtent[0] - x*size[0]; if (colStart < 0) { colStart = 0; } colEnd = size[0] - 1; if (colEnd > (inExtent[1] - x*size[0])) { colEnd = inExtent[1] - x*size[0]; } rowSize = colEnd - colStart + 1; // get the output pointer and do arith on it if necc outPtr = (unsigned char *)data->GetScalarPointer(inExtent[0],inExtent[2],0); outPtr = outPtr + (x*size[0] - inExtent[0])*inIncr[0] + (y*size[1] - inExtent[2])*inIncr[1]; rowStart = inExtent[2] - y*size[1]; if (rowStart < 0) { rowStart = 0; } rowEnd = size[1] - 1; if (rowEnd > (inExtent[3] - y*size[1])) { rowEnd = (inExtent[3] - y*size[1]); } for (row = rowStart; row <= rowEnd; row++) { memcpy(outPtr + row*inIncr[1] + colStart*inIncr[0], pixels + row*size[0]*3 + colStart*3, rowSize*3); } // free the memory delete [] pixels; } } // restore the state of the SwapBuffers bit before we mucked with it. if (doublebuffer && swapbuffers) { this->Input->GetRenderWindow()->SetSwapBuffers(swapbuffers); } /// ------ Removed ------------------------------------------ /// cam->SetViewAngle(viewAngle); /// cam->SetParallelScale(parallelScale); /// --------------------------------------------------------- /// ++++++ Added ++++++++++++++++++++++++++++++++++++++++++++ cam->SetUserTransform(ct); if(ct != 0) ct->Delete(); /// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ cam->SetWindowCenter(windowCenter[0],windowCenter[1]); // // ========================================================================= // } ifrit-4.1.2/core/imagnifier.h0000674060175406010010000000357312641012524014434 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // vtkRenderLargeImage with a bug fix // #ifndef IMAGNIFIER_H #define IMAGNIFIER_H #include class iMagnifier : public vtkRenderLargeImage { public: static iMagnifier* New(); inline void GetTile(int &x, int &y){ x = mTileX; y = mTileY; } virtual int ProcessRequest(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo); protected: void RequestData(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo); virtual ~iMagnifier(); private: iMagnifier(); void Render(vtkImageData *data); int mTileX, mTileY; }; #endif // IMAGNIFIER_H ifrit-4.1.2/core/imarker.cpp0000674060175406010010000002417412641012555014313 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "imarker.h" #include "iactor.h" #include "icamera.h" #include "icaption.h" #include "iclipplane.h" #include "ierror.h" #include "ilegend.h" #include "imaterial.h" #include "ipointglyph.h" #include "irendertool.h" #include "iviewmodule.h" #include "iviewsubject.h" #include #include #include // // Templates // #include "iarray.tlh" #include "iproperty.tlh" using namespace iParameter; iMarkerInstance::iMarkerInstance(iMarkerObject *owner) : iViewModuleComponent(owner->GetViewModule()), mPosition(owner->GetViewModule()) { mOwner = owner; mSize = 0.08; mScaled = true; mType = PointGlyphType::Sphere; mColor = iColor(255,0,0); mOpacity = 1.0; // // Do VTK stuff // mProp = iPointGlyph::New(); IERROR_CHECK_MEMORY(mProp); mProp->SetType(PointGlyphType::Sphere); mActor = iActor::New(this->GetViewModule()->GetClipPlane()->GetPlanes()); IERROR_CHECK_MEMORY(mActor); mActor->SetScalarVisibility(false); mActor->SetPosition(0.0,0.0,0.0); mActor->VisibilityOn(); mActor->DragableOff(); // use Dragable to mark Actors of ViewSubjects mActor->GetProperty()->SetOpacity(mOpacity); mActor->GetProperty()->SetInterpolationToGouraud(); mActor->GetProperty()->SetColor(mColor.ToVTK()); mActor->SetScaled(true); mActor->SetInputConnection(mProp->GetOutputPort()); this->GetViewModule()->AddObject(mActor); mOwner->GetMaterial()->AddProperty(mActor->GetProperty()); this->SetSize(mSize); mCaption = iCaption::New(this->GetViewModule()->GetRenderTool()); IERROR_CHECK_MEMORY(mCaption); this->GetViewModule()->AddObject(mCaption); mCaption->VisibilityOff(); mOwner->Modified(); } iMarkerInstance::~iMarkerInstance() { this->GetViewModule()->RemoveObject(mCaption); mCaption->Delete(); mOwner->GetMaterial()->RemoveProperty(mActor->GetProperty()); this->GetViewModule()->RemoveObject(mActor); mActor->Delete(); mProp->Delete(); mOwner->Modified(); } bool iMarkerInstance::SetType(int m) { if(m>=0 && mSetType(m); mType = m; return true; } else return false; } bool iMarkerInstance::SetSize(double s) { if(s>0.0 && s<=10.0) { mSize = s; mActor->SetBasicScale(mSize); float ps = 10.0*pow(s,0.3); if(ps < 1.0) ps = 1.0; if(ps > 10.0) ps = 10.0; mActor->GetProperty()->SetPointSize(ps); return true; } else return false; } bool iMarkerInstance::SetColor(const iColor& c) { if(!c.IsValid()) return false; mColor = c; mActor->GetProperty()->SetColor(c.ToVTK()); return true; } bool iMarkerInstance::SetOpacity(float op) { if(op>=0.0 && op<=1.0) { mOpacity = op; mActor->GetProperty()->SetOpacity(op); return true; } else return false; } bool iMarkerInstance::SetScaled(bool s) { mActor->SetScaled(s); mScaled = s; return true; } bool iMarkerInstance::SetBoxPosition(const iVector3D& v) { mPosition.SetBoxValue(v); this->SetPosition(mPosition); return true; } const iVector3D& iMarkerInstance::GetBoxPosition() const { return mPosition.BoxValue(); } bool iMarkerInstance::SetCaptionText(const iString& s) { mCaptionText = s; mCaption->SetText(s); if(s.IsEmpty()) mCaption->VisibilityOff(); else mCaption->VisibilityOn(); return true; } bool iMarkerInstance::SetCaptionPosition(const iPair& p) { mCaptionPosition = p; mCaption->SetPosition(p.X,p.Y); return true; } const iString iMarkerInstance::GetTypeAsString() const { return mProp->GetName(); } void iMarkerInstance::SetPosition(const iPosition &p) { mPosition = p; mActor->SetPosition(mPosition); mCaption->SetAttachmentPoint(mPosition); mOwner->Modified(); } // // Main class // iMarkerObject* iMarkerObject::New(iViewModule *parent) { static iString LongName("Marker"); static iString ShortName("m"); iMarkerObject *ret = new iMarkerObject(parent,LongName,ShortName); IERROR_CHECK_MEMORY(ret); return ret; } #define iMarkerObjectPropertyConstructMacroGeneric(_id_,_fname_,_sname_,_setter_,_getter_) \ _fname_(Self(),static_cast::SetterType>(&iMarkerInstance::_setter_),static_cast::GetterType>(&iMarkerInstance::_getter_),#_fname_,#_sname_) #define iMarkerObjectPropertyConstructMacro(_id_,_fname_,_sname_) iMarkerObjectPropertyConstructMacroGeneric(_id_,_fname_,_sname_,Set##_fname_,Get##_fname_) iMarkerObject::iMarkerObject(iViewModule *parent, const iString &fname, const iString &sname) : iMaterialObject(parent,fname,sname,1), iViewModuleComponent(parent), Number(iObject::Self(),static_cast(&iMarkerObject::SetNumber),static_cast(&iMarkerObject::GetNumber),"Number","num",9), Create(iObject::Self(),static_cast(&iMarkerObject::CreateInstance),"New","new"), Remove(iObject::Self(),static_cast::CallerType>(&iMarkerObject::RemoveInstance),"Delete","dlt"), iMarkerObjectPropertyConstructMacro(Int,Type,t), iMarkerObjectPropertyConstructMacro(Double,Size,s), iMarkerObjectPropertyConstructMacro(Bool,Scaled,sc), iMarkerObjectPropertyConstructMacro(Color,Color,c), iMarkerObjectPropertyConstructMacro(Float,Opacity,o), iMarkerObjectPropertyConstructMacroGeneric(Vector,Position,x,SetBoxPosition,GetBoxPosition), iMarkerObjectPropertyConstructMacro(String,CaptionText,ct), iMarkerObjectPropertyConstructMacro(Pair,CaptionPosition,cx), iObjectConstructPropertyMacroGenericS(Bool,iMarkerObject,Legend,l,ShowLegend,IsLegendVisible), iObjectConstructPropertyMacroS(Int,iMarkerObject,LegendPosition,lp), iObjectConstructPropertyMacroS(Bool,iMarkerObject,TransparentCaptions,tc), iObjectConstructPropertyMacroA(iMarkerObject,MoveCaptions,mc) { mLegendPosition = 0; mLegend = iLegend::New(this->GetViewModule()->GetRenderTool()); IERROR_CHECK_MEMORY(mLegend); this->SetLegendPosition(mLegendPosition); mLegend->VisibilityOff(); this->GetViewModule()->GetRenderTool()->AddObject(mLegend); } iMarkerObject::~iMarkerObject() { // // Legend needs to be deleted before markers - otherwise, markers get stuck somewhere and GarbareCollector crashes. // this->GetViewModule()->GetRenderTool()->RemoveObject(mLegend); mLegend->Delete(); } iMarkerInstance* iMarkerObject::GetMarker(int i) const { if(i>=0 && iSetPosition(this->GetViewModule()->GetRenderTool()->GetCamera()->GetFocalPoint()); mInstances.Add(m); this->BuildLegend(); return true; } bool iMarkerObject::RemoveInstance(int n) { if(n>=0 && nDelete(); mInstances.Remove(n); this->BuildLegend(); return true; } else return false; } bool iMarkerObject::ShowLegend(bool s) { if(s) { this->BuildLegend(); mLegend->VisibilityOn(); } else mLegend->VisibilityOff(); return true; } bool iMarkerObject::IsLegendVisible() const { return (mLegend->GetVisibility() != 0); } void iMarkerObject::UpdateLegend() { this->BuildLegend(-1); } void iMarkerObject::BuildLegend(int n) { int i; if(n<0 || n>mInstances.MaxIndex()) { mLegend->SetNumberOfEntries(mInstances.Size()); for(i=0; iUpdateEntry(i); } } else this->UpdateEntry(n); } void iMarkerObject::UpdateEntry(int n) { // // Fix a bug in vtkLegendBoxActor // iMarkerInstance *m = this->GetMarker(n); if(m!=0 && m->GetCaptionText().Length()>0) { mLegend->SetEntry(n,m->GetMarkerProp()->GetData(),m->GetCaptionText().ToCharPointer(),m->GetColor().ToVTK()); } else { mLegend->SetEntry(n,m->GetMarkerProp()->GetData()," ",m->GetColor().ToVTK()); } } bool iMarkerObject::SetLegendPosition(int p) { switch(p) { case 0: { mLegendPosition = 0; mLegend->SetPosition(0.73,0.02); return true; } case 1: { mLegendPosition = 1; mLegend->SetPosition(0.02,0.02); return true; } default: { return false; } } } bool iMarkerObject::GetTransparentCaptions() const { return iCaption::Transparent; } bool iMarkerObject::SetTransparentCaptions(bool s) { iCaption::Transparent = s; return true; } bool iMarkerObject::CallMoveCaptions() { this->GetViewModule()->LaunchInteractorStyleCaption(); return true; } void iMarkerObject::AddUser(iViewSubject *subject) { mUsers.AddUnique(subject); } void iMarkerObject::RemoveUser(iViewSubject *subject) { mUsers.Remove(subject); } void iMarkerObject::Modified() { int i; for(i=0; iUpdateOnMarkerChange(); } } int iMarkerObject::GetNumber() const { return mInstances.Size(); } bool iMarkerObject::SetNumber(int n) { if(n >= 0) { while(mInstances.Size() > n) { if(!this->RemoveInstance(mInstances.MaxIndex())) return false; } while(mInstances.Size() < n) { if(!this->CreateInstance()) return false; } return true; } else return false; } ifrit-4.1.2/core/imarker.h0000674060175406010010000001037312641012525013751 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IMARKER_H #define IMARKER_H #include "imaterialobject.h" #include "iviewmodulecomponent.h" #include "iposition.h" #include "ipropertymultiobject.h" class iActor; class iCaption; class iLegend; class iMarkerObject; class iPointGlyph; class iViewSubject; class iMarkerInstance : public vtkObjectBase, public iViewModuleComponent { friend class iMarkerObject; public: vtkTypeMacro(iMarkerInstance,vtkObjectBase); iObjectSlotMacro1SV(Type,int); iObjectSlotMacro1SV(Size,double); iObjectSlotMacro1SV(Scaled,bool); iObjectSlotMacro1SR(Color,iColor); iObjectSlotMacro1SV(Opacity,float); iObjectSlotMacro2S(BoxPosition,const iVector3D&); iObjectSlotMacro1SR(CaptionText,iString); iObjectSlotMacro1SR(CaptionPosition,iPair); const iString GetTypeAsString() const; void SetPosition(const iPosition &v); const iPosition& GetPosition() const { return mPosition; } inline iPointGlyph* GetMarkerProp() const { return mProp; } inline iCaption* GetMarkerCaption() const { return mCaption; } protected: virtual ~iMarkerInstance(); private: iMarkerInstance(iMarkerObject *owner); iPosition mPosition; // // VTK stuff // iActor *mActor; iPointGlyph *mProp; iCaption *mCaption; iMarkerObject *mOwner; }; class iMarkerObject : public iMaterialObject, public iViewModuleComponent { friend class iMarkerInstance; template friend class iPropertyMultiObject; public: vtkTypeMacro(iMarkerObject,iMaterialObject); static iMarkerObject* New(iViewModule *parent = 0); iObjectPropertyMacro2S(Number,Int); iPropertyAction Create; iPropertyAction1 Remove; iPropertyMultiObject Type; iPropertyMultiObject Size; iPropertyMultiObject Scaled; iPropertyMultiObject Color; iPropertyMultiObject Opacity; iPropertyMultiObject Position; iPropertyMultiObject CaptionText; iPropertyMultiObject CaptionPosition; bool ShowLegend(bool s); bool IsLegendVisible() const; void UpdateLegend(); iType::ps_bool Legend; iObjectPropertyMacro1S(LegendPosition,Int); iObjectPropertyMacro2S(TransparentCaptions,Bool); iObjectPropertyMacroA(MoveCaptions); iMarkerInstance* GetMarker(int i = -1) const; void AddUser(iViewSubject *); void RemoveUser(iViewSubject *); protected: virtual ~iMarkerObject(); bool CreateInstance(); bool RemoveInstance(int n); iArray mInstances; private: iMarkerObject(iViewModule *parent, const iString &fname, const iString &sname); void BuildLegend(int i = -2); void UpdateEntry(int i); void Modified(); iMarkerObject* Self(){ return this; } // needed to avoid compiler warning iLegend *mLegend; iLookupArray mUsers; }; #endif // IMARKER_H ifrit-4.1.2/core/imaterial.cpp0000674060175406010010000001117312641012555014623 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "imaterial.h" #include "ierror.h" #include "imaterialobject.h" #include #include // // Templates (needed for some compilers) // #include "iarray.tlh" #include "iproperty.tlh" using namespace iParameter; iMaterial* iMaterial::New(iMaterialObject *parent) { static iString LongName("Material"); static iString ShortName("_mat"); IASSERT(parent); return new iMaterial(parent,LongName,ShortName); } iMaterial::iMaterial(iMaterialObject *parent, const iString &fname, const iString &sname) : iObject(parent,fname,sname), iObjectConstructPropertyMacroS(Int,iMaterial,ShadingMode,sm), iObjectConstructPropertyMacroS(Float,iMaterial,Ambient,a), iObjectConstructPropertyMacroS(Float,iMaterial,Diffuse,d), iObjectConstructPropertyMacroS(Float,iMaterial,Specular,s), iObjectConstructPropertyMacroS(Float,iMaterial,SpecularPower,p) { mRenderMode = RenderMode::Self; mRealParent = parent; mShadingMode = 0; mAmbient = 0.3; mDiffuse = 0.4; mSpecular = 0.2; mSpecularPower = 0.5; this->SetShading(true); this->UpdateProperties(); } iMaterial::~iMaterial() { while(mActorProperties.Size() > 0) mActorProperties.RemoveLast()->UnRegister(this); while(mVolumeProperties.Size() > 0) mVolumeProperties.RemoveLast()->UnRegister(this); } void iMaterial::AddProperty(vtkProperty *prop) { IASSERT(prop); prop->Register(this); mActorProperties.AddUnique(prop); this->UpdateProperties(); } void iMaterial::AddProperty(vtkVolumeProperty *prop) { IASSERT(prop); prop->Register(this); mVolumeProperties.AddUnique(prop); this->UpdateProperties(); } void iMaterial::RemoveProperty(vtkProperty *prop) { IASSERT(prop); mActorProperties.Remove(prop); prop->UnRegister(this); } void iMaterial::RemoveProperty(vtkVolumeProperty *prop) { IASSERT(prop); mVolumeProperties.Remove(prop); prop->UnRegister(this); } void iMaterial::SetShading(bool s) { int i; if(mShadingMode != 0) return; for(i=0; iSetLighting(s); } for(i=0; iSetShade(s?1:0); } } void iMaterial::UpdateProperties() { int i; if(mShadingMode > 0) { mShadingMode = 0; this->SetShading(true); mShadingMode = 1; } else if(mShadingMode < 0) { mShadingMode = 0; this->SetShading(false); mShadingMode = -1; } for(i=0; iSetAmbient(mAmbient); mActorProperties[i]->SetDiffuse(mDiffuse); mActorProperties[i]->SetSpecular(mSpecular); mActorProperties[i]->SetSpecularPower(128*mSpecularPower); } for(i=0; iSetAmbient(mAmbient); mVolumeProperties[i]->SetDiffuse(mDiffuse); mVolumeProperties[i]->SetSpecular(mSpecular); mVolumeProperties[i]->SetSpecularPower(128*mSpecularPower); } } bool iMaterial::SetShadingMode(int mode) { mShadingMode = mode; this->UpdateProperties(); if(mode == 0) { mRealParent->UpdateAutomaticShading(); } return true; } bool iMaterial::SetAmbient(float v) { mAmbient = v; this->UpdateProperties(); return true; } bool iMaterial::SetDiffuse(float v) { mDiffuse = v; this->UpdateProperties(); return true; } bool iMaterial::SetSpecular(float v) { mSpecular = v; this->UpdateProperties(); return true; } bool iMaterial::SetSpecularPower(float v) { mSpecularPower = v; this->UpdateProperties(); return true; } ifrit-4.1.2/core/imaterial.h0000674060175406010010000000454412641012525014271 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // An object that controls materil for props // #ifndef IMATERIAL_H #define IMATERIAL_H #include "iobject.h" #include "iarray.h" class iMaterialObject; class vtkProperty; class vtkVolumeProperty; class iMaterial : public iObject { public: vtkTypeMacro(iMaterial,iObject); static iMaterial* New(iMaterialObject *parent = 0); iObjectPropertyMacro1S(ShadingMode,Int); iObjectPropertyMacro1S(Ambient,Float); iObjectPropertyMacro1S(Diffuse,Float); iObjectPropertyMacro1S(Specular,Float); iObjectPropertyMacro1S(SpecularPower,Float); void SetShading(bool s); void AddProperty(vtkProperty *prop); void AddProperty(vtkVolumeProperty *prop); void RemoveProperty(vtkProperty *prop); void RemoveProperty(vtkVolumeProperty *prop); protected: virtual ~iMaterial(); iMaterial* Self(){ return this; } // needed to avoid compiler warning private: iMaterial(iMaterialObject *parent, const iString &fname, const iString &sname); void UpdateProperties(); iLookupArray mActorProperties; iLookupArray mVolumeProperties; iMaterialObject *mRealParent; }; #endif // IMATERIAL_H ifrit-4.1.2/core/imaterialobject.cpp0000674060175406010010000000372612641012555016017 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "imaterialobject.h" #include "ierror.h" #include "ilegend.h" #include "imaterial.h" #include #include using namespace iParameter; // // Main class // iMaterialObject::iMaterialObject(iObject *parent, const iString &fname, const iString &sname, int level) : iObject(parent,fname,sname,level) { mMaterial = iMaterial::New(this); IERROR_CHECK_MEMORY(mMaterial); } iMaterialObject::~iMaterialObject() { mMaterial->Delete(); } void iMaterialObject::UpdateAutomaticShading() { if(mMaterial->GetShadingMode() == 0) { this->UpdateAutomaticShadingBody(); } } void iMaterialObject::UpdateAutomaticShadingBody() { // // By default set shading // mMaterial->SetShading(true); } ifrit-4.1.2/core/imaterialobject.h0000674060175406010010000000374112641012525015456 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Object that has material properties. This is a separate class as it serves as a parent to Material object. // It also isolated material interface so that it can be modified in the future. // #ifndef IMATERIALOBJECT_H #define IMATERIALOBJECT_H #include "iobject.h" class iMaterial; class iMaterialObject : public iObject { friend class iMaterial; public: vtkTypeMacro(iMaterialObject,iObject); iMaterial* GetMaterial() const { return mMaterial; } void UpdateAutomaticShading(); protected: iMaterialObject(iObject *parent, const iString &fname, const iString &sname, int level = 0); virtual ~iMaterialObject(); virtual void UpdateAutomaticShadingBody(); private: iMaterial *mMaterial; }; #endif // IMATERIALOBJECT_H ifrit-4.1.2/core/imath.cpp0000674060175406010010000000400512641012555013752 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "imath.h" #include "ierror.h" #include #include namespace iMath { bool Intersect3Planes(double *p1, double *p2, double *p3, double *x) { int i; double atmp[9], *a[3]; a[0] = atmp + 0; a[1] = atmp + 3; a[2] = atmp + 6; for(i=0; i<3; i++) { a[0][i] = p1[i]; a[1][i] = p2[i]; a[2][i] = p3[i]; } x[0] = -p1[3]; x[1] = -p2[3]; x[2] = -p3[3]; return (vtkMath::SolveLinearSystem(a,x,3) != 0); } Random::Random(int seed) { mGenerator = vtkMinimalStandardRandomSequence::New(); IERROR_CHECK_MEMORY(mGenerator); mGenerator->SetSeed(seed); } Random::~Random() { mGenerator->Delete(); } double Random::NextValue() { mGenerator->Next(); return mGenerator->GetValue(); } }; ifrit-4.1.2/core/imath.h0000674060175406010010000000706412641012525013424 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A few functions and macros for easier math and template creation. // #ifndef IMATH_H #define IMATH_H #include #include #include class vtkMinimalStandardRandomSequence; namespace iMath { #ifdef INT_MAX const int _IntMax = INT_MAX; #else const int _IntMax = 2147483647; #endif #ifdef INT_MIN const int _IntMin = INT_MIN; #else const int _IntMin = -2147483648; #endif #ifdef UINT_MAX const unsigned int _UnsignedIntMax = UINT_MAX; #else const unsigned int _UnsignedIntMax = 4294967295U; #endif #ifdef FLT_MAX const float _FloatMax = FLT_MAX; #else const float _FloatMax = 3.402823466e+38F; #endif #ifdef FLT_MIN const float _FloatMin = FLT_MIN; #else const float _FloatMin = 1.175494351e-38F; #endif #ifdef FLT_EPSILON const float _FloatRes = FLT_EPSILON; #else const float _FloatRes = 1.192092896e-07F; #endif #ifdef DBL_MAX const double _DoubleMax = DBL_MAX; #else const double _DoubleMax = 1.7976931348623158e+308; #endif #ifdef DBL_MIN const double _DoubleMin = DBL_MIN; #else const double _DoubleMin = 2.2250738585072014e-308; #endif #ifdef DBL_EPSILON const double _DoubleRes = DBL_EPSILON; #else const double _DoubleRes = 2.2204460492503131e-016; #endif const float _LargeFloat = 1.0e36f; const int _LargeInt = _IntMax - 777; const float _FloatTolerance = 10.0f*_FloatRes; const double _DoubleTolerance = 30.0*_DoubleRes; inline float Deg2Rad(float x) { return 3.1415927f/180.0f*x; } inline double Deg2Rad(double x) { return 3.1415926535897932384626433832795/180.0*x; } inline int Round2Int(float x) { return (int)floorf(0.5f+x); } inline int Round2Int(double x) { return (int)floor(0.5+x); } inline double Pow10(double x) { return pow(10.0,x); } inline float Pow10(float x) { return powf(10.0f,x); } inline double Log10(double x) { return log10(x); } inline float Log10(float x) { return log10f(x); } inline double PowN(double x, int n) { return pow(x,double(n)); } inline float PowN(float x, int n) { return powf(x,float(n)); } inline int Abs(int v) { return (v < 0) ? -v : v; } bool Intersect3Planes(double *p1, double *p2, double *p3, double *x); class Random { public: Random(int seed); ~Random(); double NextValue(); private: vtkMinimalStandardRandomSequence *mGenerator; }; } #endif ifrit-4.1.2/core/imeasuringbox.cpp0000674060175406010010000001535612641012555015537 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "imeasuringbox.h" #include "iactor.h" #include "ierror.h" #include "irendertool.h" #include "itextactor.h" #include "iviewmodule.h" #include #include #include #include #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "igenericprop.tlh" #include "iproperty.tlh" using namespace iParameter; namespace iMeasuringBoxActor_Private { class KeyboardObserver : public vtkCommand { public: vtkTypeMacro(KeyboardObserver,vtkCommand); static KeyboardObserver* New(iMeasuringBoxActor *parent = 0) { IASSERT(parent); return new KeyboardObserver(parent); } virtual void Execute(vtkObject *caller, unsigned long eventId, void *callData) { vtkInteractorStyle *s = vtkInteractorStyle::SafeDownCast(caller); if(eventId==vtkCommand::CharEvent && mParent->GetVisibility()!=0 && mParent->GetViewModule()->GetRenderWindowInteractor()!=0) { // catch keycodes switch(mParent->GetViewModule()->GetRenderWindowInteractor()->GetKeyCode()) { case '-': case 'a': case 'A': { mParent->SetSize(mParent->GetSize()*0.95); break; } case '+': case 'z': case 'Z': { mParent->SetSize(mParent->GetSize()/0.95); break; } case '<': case 's': case 'S': { mParent->SetOpacity(mParent->GetOpacity()*0.8); break; } case '>': case 'x': case 'X': { mParent->SetOpacity(mParent->GetOpacity()/0.8); break; } } mParent->GetViewModule()->GetRenderWindowInteractor()->Render(); } if(s != 0) s->OnChar(); } private: KeyboardObserver(iMeasuringBoxActor *parent) : mParent(parent) { } iMeasuringBoxActor *mParent; }; }; using namespace iMeasuringBoxActor_Private; iMeasuringBoxActor::iMeasuringBoxActor(iViewModule *vm) : iGenericProp(true), iViewModuleComponent(vm) { mStarted = false; mSize = 0.25; mBaseScale = 1.0; mFactor1r = 0.78; mFactor1g = 0.89; mFactor1b = 0.82; mFactor2 = 0.0; vtkCubeSource *cube = vtkCubeSource::New(); IERROR_CHECK_MEMORY(cube); cube->SetCenter(0.0,0.0,0.0); cube->SetXLength(2.0); cube->SetYLength(2.0); cube->SetZLength(2.0); mWorkerActor = iActor::New(); IERROR_CHECK_MEMORY(mWorkerActor); this->AppendComponent(mWorkerActor); mBoxActor = mWorkerActor; mFrameActor = this; mFrameActor->SetInputConnection(cube->GetOutputPort()); mFrameActor->GetProperty()->SetRepresentationToWireframe(); mFrameActor->GetProperty()->SetLineWidth(2); mBoxActor->SetInputConnection(cube->GetOutputPort()); mBoxActor->GetProperty()->SetOpacity(0.5); mBoxActor->GetProperty()->SetAmbient(0.5); mBoxActor->GetProperty()->SetDiffuse(0.5); mBoxActor->GetProperty()->SetSpecular(0.7); mBoxActor->GetProperty()->SetSpecularPower(50); cube->Delete(); mText = iTextActor::New(this->GetViewModule()->GetRenderTool()); IERROR_CHECK_MEMORY(mText); this->AppendComponent(mText); mText->SetBold(true); mText->SetPosition(0.5,0.03); mText->SetJustification(0); iColor black; this->SetColor(black); mObserver = KeyboardObserver::New(this); } iMeasuringBoxActor::~iMeasuringBoxActor() { mObserver->Delete(); mWorkerActor->Delete(); mText->Delete(); } void iMeasuringBoxActor::AttachToInteractorStyle(vtkInteractorStyle *s) { if(s != 0) s->AddObserver(vtkCommand::CharEvent,mObserver); } void iMeasuringBoxActor::SetSize(float s) { if(s > 0.0) { mSize = s; this->Modified(); } } void iMeasuringBoxActor::SetColor(iColor &c) { mBoxActor->GetProperty()->SetColor(mFactor1r+mFactor2*c.ToVTK()[0],mFactor1g+mFactor2*c.ToVTK()[1],mFactor1b+mFactor2*c.ToVTK()[2]); mFrameActor->GetProperty()->SetColor(c.ToVTK()); this->Modified(); } void iMeasuringBoxActor::SetOpacity(float o) { if(o > 0.0) { if(o > 1.0) o = 1.0; mBoxActor->GetProperty()->SetOpacity(o); this->Modified(); } } void iMeasuringBoxActor::UpdateGeometry(vtkViewport* viewport) { vtkRenderer *ren = vtkRenderer::SafeDownCast(viewport); if(ren == 0) { this->Disable(); return; } vtkCamera *cam = ren->GetActiveCamera(); if(cam == 0) { this->Disable(); return; } if(!mStarted) { mStarted = true; mBaseScale = cam->GetParallelScale(); } if(this->GetViewModule()->GetRenderTool()->GetRenderingMagnification() == 1) { float s = mSize*cam->GetParallelScale()/mBaseScale; char t[256]; sprintf(t,"Box size: %6.2g",s); mText->SetText(t); this->SetScale(s); mBoxActor->SetAxisScale(s,s,s); mBoxActor->SetPosition(cam->GetFocalPoint()); mFrameActor->SetAxisScale(s,s,s); mFrameActor->SetPosition(cam->GetFocalPoint()); } } void iMeasuringBoxActor::SetBaseScale(float s) { mStarted = true; mBaseScale = s; } // // Main class // iMeasuringBox* iMeasuringBox::New(iViewModule *vm) { static iString LongName("MeasuringBox"); static iString ShortName("mb"); IASSERT(vm); return new iMeasuringBox(vm,LongName,ShortName); } iMeasuringBox::iMeasuringBox(iViewModule *vm, const iString &fname, const iString &sname) : iViewModuleTool(vm,fname,sname) { mActor = new iMeasuringBoxActor(vm); IERROR_CHECK_MEMORY(mActor); mActor->VisibilityOff(); mActor->PickableOff(); this->GetViewModule()->GetRenderTool()->AddObject(mActor); } iMeasuringBox::~iMeasuringBox() { this->GetViewModule()->GetRenderTool()->RemoveObject(mActor); mActor->Delete(); } bool iMeasuringBox::ShowBody(bool s) { mActor->SetVisibility(s?1:0); return true; } ifrit-4.1.2/core/imeasuringbox.h0000674060175406010010000000557412641012525015202 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IMEASURINGBOX_H #define IMEASURINGBOX_H #include "igenericprop.h" #include "iactor.h" #include "iviewmoduletool.h" #include class iColor; class iMeasuringBox; class iTextActor; class vtkCommand; class vtkCubeSource; class vtkInteractorStyle; class vtkPolyDataMapper; class iMeasuringBoxActor : public iGenericProp, public iViewModuleComponent { friend class iMeasuringBox; public: vtkTypeMacro(iMeasuringBoxActor,iActor); void AttachToInteractorStyle(vtkInteractorStyle *s); void SetSize(float s); void SetOpacity(float s); void SetColor(iColor &c); void SetBaseScale(float s); inline float GetOpacity(){ return mBoxActor->GetProperty()->GetOpacity(); } inline float GetSize(){ return mSize; } virtual double *GetBounds(){ return 0; } // Set to zero so that the text is always displayed protected: virtual ~iMeasuringBoxActor(); virtual void UpdateGeometry(vtkViewport *vp); private: iMeasuringBoxActor(iViewModule *vm); iTextActor *mText; iActor *mFrameActor, *mBoxActor, *mWorkerActor; vtkCommand *mObserver; bool mStarted; float mSize, mBaseScale; float mFactor1r, mFactor1g, mFactor1b, mFactor2; }; class iMeasuringBox : public iViewModuleTool { public: vtkTypeMacro(iMeasuringBox,iViewModuleTool); static iMeasuringBox* New(iViewModule *vm = 0); inline iMeasuringBoxActor* GetActor() const { return mActor; } protected: virtual ~iMeasuringBox(); private: iMeasuringBox(iViewModule *vm, const iString &fname, const iString &sname); virtual bool ShowBody(bool s); // // Actors displayed by this class // iMeasuringBoxActor *mActor; }; #endif // IMEASURINGBOX_H ifrit-4.1.2/core/imergedatafilter.cpp0000674060175406010010000001254012641012555016163 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "imergedatafilter.h" #include "idata.h" #include "idatalimits.h" #include "idatareader.h" #include "ierror.h" #include "imath.h" #include "iviewmodule.h" #include #include #include // // Templates // #include "igenericfilter.tlh" iMergeDataFilter::iMergeDataFilter(iDataConsumer *consumer) : iGenericFilter(consumer,2,false) { mRank = 0; } int iMergeDataFilter::FillInputPortInformation(int port, vtkInformation* info) { if(port == 1) { info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),"vtkDataSet"); info->Set(vtkAlgorithm::INPUT_IS_OPTIONAL(),1); return 1; } else return this->iGenericFilter::FillInputPortInformation(port,info); } void iMergeDataFilter::SetRank(int rank) { if(rank>=0 && rank<3) { mRank = rank; } } bool iMergeDataFilter::HasData(int rank) { if(rank>=0 && rank<3) { this->Update(); IASSERT(this->OutputData()); vtkPointData *pd = this->OutputData()->GetPointData(); if(pd == 0) return false; switch(rank) { case 0: return (pd->GetScalars()!=0 && pd->GetScalars()->GetNumberOfTuples()>0); case 1: return (pd->GetVectors()!=0 && pd->GetVectors()->GetNumberOfTuples()>0); case 2: return (pd->GetTensors()!=0 && pd->GetTensors()->GetNumberOfTuples()>0); } } return false; } void iMergeDataFilter::ProvideInfo() { vtkInformation* inInfo = wCache.InputVector[0]->GetInformationObject(0); vtkInformation* outInfo = wCache.OutputVector->GetInformationObject(0); outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()),6); //outInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(),inInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT()),6); inInfo = wCache.InputVector[1]->GetInformationObject(0); if(inInfo != 0) { //inInfo->Set(vtkStreamingDemandDrivenPipeline::EXACT_EXTENT(),1); } } void iMergeDataFilter::ProvideOutput() { vtkDataSet *input = this->InputData(); vtkDataSet *output = this->OutputData(); vtkPointData *pd = input->GetPointData(); if(pd == 0) { output->Initialize(); return; } output->ShallowCopy(input); switch(mRank) { case 0: { if(this->AreDataSetsCompatible(input,this->InputData(1)) && this->InputData(1)->GetPointData()->GetScalars()!=0) { output->GetPointData()->SetScalars(this->InputData(1)->GetPointData()->GetScalars()); } break; } case 1: { if(this->AreDataSetsCompatible(input,this->InputData(1)) && this->InputData(1)->GetPointData()->GetVectors()!=0) { output->GetPointData()->SetVectors(this->InputData(1)->GetPointData()->GetVectors()); } break; } case 2: { if(this->AreDataSetsCompatible(input,this->InputData(1)) && this->InputData(1)->GetPointData()->GetTensors()!=0) { output->GetPointData()->SetTensors(this->InputData(1)->GetPointData()->GetTensors()); } break; } } } bool iMergeDataFilter::AreDataSetsCompatible(vtkDataSet *ds1, vtkDataSet *ds2) const { int i, numArrays; if(ds1==0 || ds2==0) return false; if(ds1->GetNumberOfPoints() != ds2->GetNumberOfPoints()) return false; vtkIdType numTuples, numPts = ds1->GetNumberOfPoints(); numArrays = ds1->GetPointData()->GetNumberOfArrays(); for(i=0; iGetPointData()->GetArray(i)->GetNumberOfTuples(); if(numTuples>0 && numTuples!=numPts) return false; } numArrays = ds2->GetPointData()->GetNumberOfArrays(); for(i=0; iGetPointData()->GetArray(i)->GetNumberOfTuples(); if(numTuples>0 && numTuples!=numPts) return false; } // // If ImageData, check that the dimensions are identical // vtkImageData *id1 = vtkImageData::SafeDownCast(ds1); vtkImageData *id2 = vtkImageData::SafeDownCast(ds2); if((id1==0 && id2!=0) || (id1!=0 && id2==0)) return false; if(id1!=0 && id2!=0) { int dim1[3], dim2[3]; id1->GetDimensions(dim1); id2->GetDimensions(dim2); return (dim1[0]==dim2[0] && dim1[1]==dim2[1] && dim1[2]==dim2[2]); } // // Other data types can be added here // return true; } ifrit-4.1.2/core/imergedatafilter.h0000674060175406010010000000357212641012525015632 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IMERGEDATAFILTER_H #define IMERGEDATAFILTER_H #include "igenericfilter.h" #include class vtkDataSet; class iMergeDataFilter : public iGenericFilter { iGenericFilterTypeMacro(iMergeDataFilter,vtkDataSetAlgorithm); public: inline int GetRank() const { return mRank; } void SetRank(int rank); bool HasData(int rank); protected: int FillInputPortInformation(int port, vtkInformation* info); virtual void ProvideInfo(); virtual void ProvideOutput(); private: bool AreDataSetsCompatible(vtkDataSet *ds1, vtkDataSet *ds2) const; int mRank; }; #endif ifrit-4.1.2/core/imonitor.cpp0000674060175406010010000000545112641012556014517 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "imonitor.h" #include "ierror.h" #include "iobject.h" #include "ishell.h" #include "ishelleventobservers.h" // // Convenience class // iMonitor::iMonitor(const iShellComponent *user) { IASSERT(user); mObserver = user->GetShell()->GetExecutionEventObserver(); IASSERT(mObserver); mObserver->Start(); mObserver->SetInterval(0.0,1.0); } iMonitor::iMonitor(const iShellComponent *user, const iString& label, double length) { IASSERT(user); mObserver = user->GetShell()->GetExecutionEventObserver(); IASSERT(mObserver); mObserver->Start(); mObserver->SetLabel(label); mObserver->SetInterval(0.0,length); } iMonitor::~iMonitor() { IASSERT(mObserver); mObserver->Finish(); } void iMonitor::SetInterval(double start, double length) { IASSERT(mObserver); mObserver->SetInterval(start,length); } void iMonitor::SetInterval(const iString& label, double start, double length) { IASSERT(mObserver); mObserver->SetLabel(label); mObserver->SetInterval(start,length); } void iMonitor::SetProgress(double prog) { IASSERT(mObserver); mObserver->SetProgress(prog); } bool iMonitor::IsStopped() const { IASSERT(mObserver); return (mObserver->IsAborted() || mObserver->IsInError()); } bool iMonitor::IsAborted() const { IASSERT(mObserver); return mObserver->IsAborted(); } void iMonitor::PostError(const iString &text) { IASSERT(mObserver); mObserver->PostError(text); } void iMonitor::Reset() { IASSERT(mObserver); mObserver->Reset(); } const iString& iMonitor::LastErrorMessage() const { IASSERT(mObserver); return mObserver->LastErrorMessage(); } ifrit-4.1.2/core/imonitor.h0000674060175406010010000000427612641012525014164 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A helper class that monitors execution of many IFrIT components // (starts and finishes execution observer automatically, reports // error and abort statuses, etc). It is created by value as a // local variable, with most of th work done by constructor and // destructor as the monitor goes in and out of scope. // #ifndef IMONITOR_H #define IMONITOR_H class iExecutionEventObserver; class iShellComponent; class iString; class iMonitor { public: iMonitor(const iShellComponent *user); iMonitor(const iShellComponent *user, const iString& label, double length); ~iMonitor(); void SetInterval(const iString& label, double start, double length); void SetInterval(double start, double length); void SetProgress(double prog); void PostError(const iString &text); void Reset(); const iString& LastErrorMessage() const; bool IsStopped() const; bool IsAborted() const; private: iExecutionEventObserver* mObserver; }; #endif // IMONITOR_H ifrit-4.1.2/core/imultiviewsubject.cpp0000674060175406010010000000513012641012556016427 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "imultiviewsubject.h" #include "imath.h" #include "iviewmodule.h" // // Templates // #include "iarray.tlh" #include "iproperty.tlh" using namespace iParameter; // // Single instance class // iMultiViewInstance::iMultiViewInstance(iMultiViewSubject *owner, int numactors, int numpaintedactors, int priority, bool alwayspainted) : iPaintedViewInstance(owner,numactors,1.0,numpaintedactors,priority,alwayspainted) { } iMultiViewInstance::~iMultiViewInstance() { } bool iMultiViewInstance::IsConnectedToPaintingData() const { return this->IsThereData(); } // // Main class // iMultiViewSubject::iMultiViewSubject(iObject *parent, const iString &fname, const iString &sname, iViewModule *vm, const iDataType &type, unsigned int flags, int minsize) : iPaintedViewSubject(parent,fname,sname,vm,type,type,flags,minsize,iMath::_IntMax), Number(iObject::Self(),static_cast(&iViewSubject::SetNumberOfInstances),static_cast(&iViewSubject::GetNumberOfInstances),"Number","num",9), Create(iObject::Self(),static_cast(&iViewSubject::CreateInstance),"New","new"), Remove(iObject::Self(),static_cast::CallerType>(&iViewSubject::RemoveInstance),"Delete","dlt") { Remove.AddFlag(iProperty::_FunctionsAsIndex); } iMultiViewSubject::~iMultiViewSubject() { } ifrit-4.1.2/core/imultiviewsubject.h0000674060175406010010000000440212641012525016071 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A ViewSubject that uses scalar data and has several instances // #ifndef IMULTIVIEWSUBJECT_H #define IMULTIVIEWSUBJECT_H #include "ipaintedviewsubject.h" class iMultiViewSubject; class iMultiViewInstance : public iPaintedViewInstance { friend class iMultiViewSubject; public: iDataConsumerTypeMacroPass(iMultiViewInstance,iPaintedViewInstance); protected: iMultiViewInstance(iMultiViewSubject *owner, int numactors, int numpaintedactors, int priority, bool alwayspainted); virtual ~iMultiViewInstance(); virtual bool IsConnectedToPaintingData() const; }; class iMultiViewSubject : public iPaintedViewSubject { public: iDataConsumerTypeMacroPass(iMultiViewSubject,iPaintedViewSubject); iType::ps_int Number; iPropertyAction Create; iPropertyAction1 Remove; protected: iMultiViewSubject(iObject *parent, const iString &fname, const iString &sname, iViewModule *vm, const iDataType &type, unsigned int flags, int minsize); virtual ~iMultiViewSubject(); }; #endif // IMULTIVIEWSUBJECT_H ifrit-4.1.2/core/iobject.cpp0000674060175406010010000002602112641012556014272 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iobject.h" #include "ierror.h" #include "ihelpfactory.h" #include "iproperty.h" // // Templates // #include "iarray.tlh" #include "iproperty.tlh" using namespace iParameter; // // ***************************************************************** // // iObject implementation // // ***************************************************************** // const iString& iObject::ChildLookup(iObject* const &ptr) { return ptr->Tag(); } const iString& iObject::VariableLookup(iPropertyVariable* const &ptr) { return ptr->Tag(); } const iString& iObject::FunctionLookup(iPropertyFunction* const &ptr) { return ptr->Tag(); } iObject::iObject(iObject *parent, const iString &fname, const iString &sname, int level) : mChildren(iObject::ChildLookup), mVariableProperties(iObject::VariableLookup), mFunctionProperties(iObject::FunctionLookup), mParent(parent), mLongName(fname), mShortName(sname), mTag(iString::FromNumber(level,"%1d")+sname) { if(mParent != 0) { mParent->mChildren.Add(this); } mRenderMode = -1; // unset } iObject::~iObject() { if(mParent != 0) mParent->mChildren.Remove(this); // // Delete children in reverse order in case they create static instances of reference-counted variables // while(mChildren.Size() > 0) mChildren.RemoveLast()->Delete(); } const iString iObject::HelpTag() const { return this->ShortName(); } int iObject::ParentIndex() const { if(mParent==0 || mParent->ShortName()!=this->ShortName()) { return -1; } else { // // Parent is our collection // iObject *obj = const_cast(this); IASSERT(obj); return mParent->mChildren.Find(obj); } } void iObject::RequestRender() { switch(mRenderMode) { case -1: { IBUG_FATAL("RenderMode for object "+this->LongName()+" was not set."); break; } case RenderMode::NoRender: { break; } default: { this->PassRenderRequest(mRenderMode); } } } bool iObject::IsImmediatePost() const { if(mParent != 0) { return mParent->IsImmediatePost(); } else return true; } void iObject::PassRenderRequest(int mode) { if(mParent != 0) { if(mode < mRenderMode) mode = mRenderMode; mParent->PassRenderRequest(mode); } } bool iObject::CopyState(const iObject *p) { if(this == p) return true; #ifdef I_DEBUG iOutput::DisplayDebugMessage("Copying object: "+this->LongName()); #endif if(this->LongName() != p->LongName()) { return false; } if(mVariableProperties.Size() != p->mVariableProperties.Size()) { return false; } int i; for(i=0; iTestFlag(iPropertyVariable::_DoNotIncludeInCopy)) { if(!mVariableProperties[i]->Copy(p->mVariableProperties[i])) { #ifdef I_DEBUG mVariableProperties[i]->Copy(p->mVariableProperties[i]); #endif return false; } } for(i=0; iCopyState(p->mChildren[i])) { return false; } } return true; } const iObject* iObject::FindByName(const iString &name) const { if(name==mShortName || name==mLongName) return this; iString cname(name); if(name.BeginsWith(mShortName+".") || name.BeginsWith(mLongName+".")) { cname = name.Section(".",1); // one of our children } int i; const iObject *obj; for(i=0; iFindByName(cname); if(obj != 0) { return obj; } } return 0; } const iProperty* iObject::FindPropertyByName(const iString &name) const { int idx = name.FindLast('.'); if(idx == -1) return 0; // not a property name const iObject *obj = this->FindByName(name.Part(0,idx)); if(obj == 0) return 0; return obj->GetLocalProperty(name.Part(idx+1)); } const iProperty* iObject::GetLocalProperty(const iString &name) const { #ifndef I_NO_CHECK if(name.Contains(".") > 0) { IBUG_ERROR("Incorrect call to iObject::GetLocalProperty."); return 0; } #endif // // Could be our local property or not a property name at all // int i; for(i=0; iShortName()==name || mVariableProperties[i]->LongName()==name) { return mVariableProperties[i]; } } for(i=0; iShortName()==name || mFunctionProperties[i]->LongName()==name) { return mFunctionProperties[i]; } } return 0; } void iObject::WriteHead(iString &s) const { s = "Object: " + this->LongName() + "/" + this->ShortName() + "\n"; } void iObject::WriteState(iString &s) const { int i, j; iString s1; s.Init(1000); this->WriteHead(s); // // Write alphabetically // if(mVariableProperties.Size() > 0) { s += "Variables:\n"; for(i=0; iGetTypeName(); if(!mVariableProperties[i]->IsFixedSize()) s1 += "[*]"; else if(mVariableProperties[i]->Size() > 1) s1 += "[" + iString::FromNumber(mVariableProperties[i]->Size()) + "]"; while(s1.Length() < 12) s1 += " "; s1 += mVariableProperties[i]->LongName() + "/" + mVariableProperties[i]->ShortName(); while(s1.Length() < 32) s1 += " "; s1 += "\t = "; iString s2; mVariableProperties[i]->SaveStateToString(s2,false); s2 = s2.Section(" = ",1); if(mVariableProperties[i]->Size() > 1) s2 = "(" + s2 + ")"; s1 += s2 + "\n"; s += " " + s1; } } if(mFunctionProperties.Size() > 0) { s += "Functions:\n"; for(i=0; iGetReturnTypeName(); while(s1.Length() < 12) s1 += " "; s1 += mFunctionProperties[i]->LongName() + "/" + mFunctionProperties[i]->ShortName() + "("; for(j=0; jNumArguments(); j++) { s1 += " " + mFunctionProperties[i]->GetArgumentTypeName(j); if(j < mFunctionProperties[i]->NumArguments()-1) s1 += " ,"; } s1 += " )\n"; s += " " + s1; } } } bool iObject::IsHidden() const { return (mShortName[0] == '@'); } void iObject::RegisterWithHelpFactory() const { if(this->IsHidden()) return; iString s = this->HelpTag() + "+" + this->LongName() + "/" + this->ShortName() + "+"; if(mParent != 0) { s += mParent->HelpTag(); } s += "+"; int i; for(i=0; i 0) s += ","; s += mChildren[i]->HelpTag(); } iHelpFactory::RegisterObject(s); this->RegisterPropertiesWithHelpFactory(); for(i=0; iRegisterWithHelpFactory(); } } void iObject::RegisterPropertiesWithHelpFactory() const { int i, j; iString s; for(i=0; iShortName().IsEmpty()) { s = mVariableProperties[i]->HelpTag() + "+" + mVariableProperties[i]->LongName() + "/" + mVariableProperties[i]->ShortName() + "+"; s += mVariableProperties[i]->GetTypeName() + "+"; if(!mVariableProperties[i]->IsFixedSize()) s += "[*]"; else if(mVariableProperties[i]->Size() > 1) s += "[" + iString::FromNumber(mVariableProperties[i]->Size()) + "]"; iHelpFactory::RegisterObjectProperty(s); } for(i=0; iShortName().IsEmpty()) { s = mFunctionProperties[i]->HelpTag() + "+" + mFunctionProperties[i]->LongName() + "/" + mFunctionProperties[i]->ShortName() + "+"; s += mFunctionProperties[i]->GetReturnTypeName() + "+("; for(j=0; jNumArguments(); j++) { s += " " + mFunctionProperties[i]->GetArgumentTypeName(j); if(j < mFunctionProperties[i]->NumArguments()-1) s += " ,"; } s += " )"; iHelpFactory::RegisterObjectProperty(s); } } void iObject::SaveStateToString(iString &s) const { s.Init(1000); s = this->GetFullName() + "#+++\n"; int i; iString s1; this->SavePropertiesToString(s1); s += s1 + this->GetFullName() + "#***\n"; for(i=0; iSaveStateToString(s1); s += s1; } s += this->GetFullName() + "#---\n"; } void iObject::SavePropertiesToString(iString &s) const { int i; iString s1; s.Clear(); for(i=0; iTestFlag(iPropertyVariable::_DoNotSaveInState)) { mVariableProperties[i]->SaveStateToString(s1,true); s += s1 + "\n"; } } bool iObject::LoadStateFromString(const iString &str) { iString head = this->GetFullName() + "#+++\n"; iString s = str; int ib = str.Find(head); int ie = str.Find(this->GetFullName()+"#***\n"); if(ib>-1 && ie>-1) { ib += head.Length(); s = str.Part(ib,ie-ib); ib = ie + head.Length(); } int i; bool ok = true; for(i=0; iTestFlag(iPropertyVariable::_DoNotSaveInState)) { if(!mVariableProperties[i]->LoadStateFromString(s) && !mVariableProperties[i]->TestFlag(iProperty::_OptionalInState)) { ok = false; #ifdef I_DEBUG mVariableProperties[i]->LoadStateFromString(s); #endif } this->OnLoadStateAtom(); } ie = str.Find(this->GetFullName()+"#---\n"); if(ib>-1 && ie>-1) { s = str.Part(ib,ie-ib); } for(i=0; iLoadStateFromString(s)) { ok = false; #ifdef I_DEBUG mChildren[i]->LoadStateFromString(s); #endif } } return ok; } const iString iObject::GetFullName() const { iString str; if(mParent != 0) { str += mParent->GetFullName(); if(mParent->LongName() != this->LongName()) str += "." + this->LongName(); } else { str += this->LongName(); } if(this->ParentIndex() >= 0) { str += "[" + iString::FromNumber(this->ParentIndex()) + "]"; } return str; } void iObject::OnLoadStateAtom() { if(mParent != 0) mParent->OnLoadStateAtom(); } // // This is a part of message subsystem for thread-safe execution. // Functions begining with underscore can be called from the driver thread. // Functions ending with underscore should be called from the slave thread. // bool iObject::_RequestPush(iProperty::Key key) { IASSERT(mParent); // root object overwrites this return mParent->_RequestPush(key); } ifrit-4.1.2/core/iobject.h0000674060175406010010000002505412641012526013741 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A small set of common functionality for all IFrIT viewization objects // #ifndef IOBJECT_H #define IOBJECT_H #include #include "iarray.h" #include "iproperty.h" #include "istring.h" #include class iProperty; class iPropertyFunction; class iPropertyVariable; namespace iParameter { namespace RenderMode { const int NoRender = 0; const int Self = 1; const int Clones = 2; const int All = 3; } }; class iObject : public vtkObjectBase { friend class iPropertyVariable; friend class iPropertyFunction; public: vtkTypeMacro(iObject,vtkObjectBase); inline const iString& LongName() const { return mLongName; } inline const iString& ShortName() const { return mShortName; } inline const iString& Tag() const { return mTag; } // for ordering const iString GetFullName() const; virtual const iString HelpTag() const; int ParentIndex() const; inline int GetRenderMode() const { return mRenderMode; } virtual void RequestRender(); virtual bool IsImmediatePost() const; virtual bool CopyState(const iObject *p); virtual void WriteState(iString &s) const; virtual void RegisterWithHelpFactory() const; bool IsHidden() const; virtual const iObject* FindByName(const iString &name) const; virtual const iProperty* FindPropertyByName(const iString &name) const; virtual const iProperty* GetLocalProperty(const iString &name) const; virtual void SaveStateToString(iString &str) const; virtual bool LoadStateFromString(const iString &str); // // Must be public for shell access // inline const iArray& Variables() const { return mVariableProperties; } inline const iArray& Functions() const { return mFunctionProperties; } inline const iArray& Children() const { return mChildren; } protected: iObject(iObject *parent, const iString &fname, const iString &sname, int level = 0); virtual ~iObject(); iObject* Self(){ return this; } // needed to avoid compiler warning iObject* Parent() const { return mParent; } virtual void PassRenderRequest(int mode); virtual void WriteHead(iString &s) const; virtual void SavePropertiesToString(iString &str) const; virtual void OnLoadStateAtom(); void RegisterPropertiesWithHelpFactory() const; // // Child-parent hierarchy (inherited classes need to change this, hence it is protected) // iGenericOrderedArray mChildren; static const iString& ChildLookup(iObject* const &ptr); int mRenderMode; // // Object properties // iGenericOrderedArray mVariableProperties; iGenericOrderedArray mFunctionProperties; static const iString& VariableLookup(iPropertyVariable* const &ptr); static const iString& FunctionLookup(iPropertyFunction* const &ptr); private: iObject *mParent; const iString& mLongName; const iString& mShortName; const iString mTag; // // This is a part of message subsystem for thread-safe execution. // Functions begining with underscore can be called from the driver thread. // public: virtual bool _RequestPush(iProperty::Key key); }; // // Helper macros // #define iObjectSlotMacro1S(_name_,_type_,_argt_) \ protected: _type_ m##_name_; \ public: _argt_ Get##_name_() const { return m##_name_; } \ bool Set##_name_(_argt_ s) #define iObjectSlotMacro1SV(_name_,_type_) \ iObjectSlotMacro1S(_name_,_type_,_type_) #define iObjectSlotMacro1SR(_name_,_type_) \ iObjectSlotMacro1S(_name_,_type_,const _type_&) #define iObjectSlotMacro2S(_name_,_argt_) \ _argt_ Get##_name_() const; \ bool Set##_name_(_argt_ s) #define iObjectSlotMacro1V(_name_,_type_,_argt_,_dim_) \ protected: _type_ m##_name_[_dim_]; \ public: _argt_ Get##_name_(int i) const { return m##_name_[i]; } \ bool Set##_name_(int i, _argt_ s) #define iObjectSlotMacro2V(_name_,_argt_) \ _argt_ Get##_name_(int i) const; \ bool Set##_name_(int i, _argt_ s) #define iObjectSlotMacro3V(_name_,_argt_) \ int Size##_name_() const; \ bool Resize##_name_(int n); \ _argt_ Get##_name_(int i) const; \ bool Set##_name_(int i, _argt_ s) #define iObjectSlotMacro1Q(_name_,_type_,_rett_) \ protected: _type_ m##_name_; \ public: _rett_ Get##_name_() const { return m##_name_; } #define iObjectSlotMacro2Q(_name_,_rett_) \ public: _rett_ Get##_name_() const #define iObjectSlotMacroA(_name_) \ bool Call##_name_() #define iObjectSlotMacroA1(_name_,_argt_) \ bool Call##_name_(_argt_ v) #define iObjectSlotMacroA2(_name_,_argt1_,_argt2_) \ bool Call##_name_(_argt1_ v1, _argt2_ v2) // // #define iObjectPropertyMacro1S(_name_,_id_) \ iObjectSlotMacro1S(_name_,iType::Traits::ContainerType,iType::Traits::Type); \ iPropertyScalar _name_ #define iObjectPropertyMacro2S(_name_,_id_) \ iObjectSlotMacro2S(_name_,iType::Traits::Type); \ iPropertyScalar _name_ #define iObjectPropertyMacro1V(_name_,_id_,_dim_) \ iObjectSlotMacro1V(_name_,iType::Traits::ContainerType,iType::Traits::Type,_dim_); \ iPropertyVector _name_ #define iObjectPropertyMacro2V(_name_,_id_) \ iObjectSlotMacro2V(_name_,iType::Traits::Type); \ iPropertyVector _name_ #define iObjectPropertyMacro3V(_name_,_id_) \ iObjectSlotMacro3V(_name_,iType::Traits::Type); \ iPropertyVector _name_ #define iObjectPropertyMacro1Q(_name_,_id_) \ iObjectSlotMacro1Q(_name_,iType::Traits::ContainerType,iType::Traits::Type); \ iPropertyQuery _name_ #define iObjectPropertyMacro2Q(_name_,_id_) \ iObjectSlotMacro2Q(_name_,iType::Traits::Type); \ iPropertyQuery _name_ #define iObjectPropertyMacroA(_name_) \ iObjectSlotMacroA(_name_); \ iPropertyAction _name_ #define iObjectPropertyMacroA1(_name_,_id_) \ iObjectSlotMacroA1(_name_,iType::Traits::Type); \ iPropertyAction1 _name_ #define iObjectPropertyMacroA2(_name_,_id1_,_id2_) \ iObjectSlotMacroA2(_name_,iType::Traits::Type,iType::Traits::Type); \ iPropertyAction2 _name_ // // #define iObjectConstructPropertyMacroGenericS(_id_,_subject_,_fname_,_sname_,_setter_,_getter_) \ _fname_(iObject::Self(),static_cast::SetterType>(&_subject_::_setter_),static_cast::GetterType>(&_subject_::_getter_),#_fname_,#_sname_) #define iObjectConstructPropertyMacroGenericSOP(YES,_id_,_subject_,_fname_,_sname_,_setter_,_getter_) \ _fname_(iObject::Self(),static_cast::SetterType>(&_subject_::_setter_),static_cast::GetterType>(&_subject_::_getter_),(YES)?#_fname_:"",(YES)?#_sname_:"") #define iObjectConstructPropertyMacroS(_id_,_subject_,_fname_,_sname_) iObjectConstructPropertyMacroGenericS(_id_,_subject_,_fname_,_sname_,Set##_fname_,Get##_fname_) #define iObjectConstructPropertyMacroSOP(YES,_id_,_subject_,_fname_,_sname_) iObjectConstructPropertyMacroGenericSOP(YES,_id_,_subject_,_fname_,_sname_,Set##_fname_,Get##_fname_) // // #define iObjectConstructPropertyMacroGenericV(_id_,_subject_,_fname_,_sname_,_dim_,_setter_,_getter_) \ _fname_(iObject::Self(),static_cast::SetterType>(&_subject_::_setter_),static_cast::GetterType>(&_subject_::_getter_),#_fname_,#_sname_,_dim_) #define iObjectConstructPropertyMacroGenericVOP(YES,_id_,_subject_,_fname_,_sname_,_dim_,_setter_,_getter_) \ _fname_(iObject::Self(),static_cast::SetterType>(&_subject_::_setter_),static_cast::GetterType>(&_subject_::_getter_),(YES)?#_fname_:"",(YES)?#_sname_:"",_dim_) #define iObjectConstructPropertyMacroV(_id_,_subject_,_fname_,_sname_,_dim_) iObjectConstructPropertyMacroGenericV(_id_,_subject_,_fname_,_sname_,_dim_,Set##_fname_,Get##_fname_) // // #define iObjectConstructPropertyMacroGenericQ(_id_,_subject_,_fname_,_sname_,_getter_) \ _fname_(iObject::Self(),static_cast::GetterType>(&_subject_::_getter_),#_fname_,#_sname_) #define iObjectConstructPropertyMacroQ(_id_,_subject_,_fname_,_sname_) iObjectConstructPropertyMacroGenericQ(_id_,_subject_,_fname_,_sname_,Get##_fname_) // // #define iObjectConstructPropertyMacroGenericA(_subject_,_fname_,_sname_,_caller_) \ _fname_(iObject::Self(),static_cast(&_subject_::_caller_),#_fname_,#_sname_) #define iObjectConstructPropertyMacroA(_subject_,_fname_,_sname_) iObjectConstructPropertyMacroGenericA(_subject_,_fname_,_sname_,Call##_fname_) // // #define iObjectConstructPropertyMacroGenericA1(_id_,_subject_,_fname_,_sname_,_caller_) \ _fname_(iObject::Self(),static_cast::CallerType>(&_subject_::_caller_),#_fname_,#_sname_) #define iObjectConstructPropertyMacroA1(_id_,_subject_,_fname_,_sname_) iObjectConstructPropertyMacroGenericA1(_id_,_subject_,_fname_,_sname_,Call##_fname_) // // #define iObjectConstructPropertyMacroGenericA2(_id1_,_id2_,_subject_,_fname_,_sname_,_caller_) \ _fname_(iObject::Self(),static_cast::CallerType>(&_subject_::_caller_),#_fname_,#_sname_) #define iObjectConstructPropertyMacroA2(_id1_,_id2_,_subject_,_fname_,_sname_) iObjectConstructPropertyMacroGenericA2(_id1_,_id2_,_subject_,_fname_,_sname_,Call##_fname_) #endif // IOBJECT_H ifrit-4.1.2/core/iobjectcollection.cpp0000674060175406010010000000533312641012556016351 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iobjectcollection.h" #include "ierror.h" #include "ihelpfactory.h" #include "istring.h" // // Templates // #include "iarray.tlh" #include "iproperty.tlh" // // Main class // iObjectCollection::iObjectCollection(iObject *parent, const iString &fname, const iString &sname) : iObject(parent,fname,sname) { } iObject* iObjectCollection::GetMember(int i) const { if(i>=0 && iShortName() || name==this->LongName()) return this; // // Require an index for a member. // bool ok; iString prefix = name.Section(".", 0, 0); if (prefix.BeginsWith(this->ShortName() + "[") || prefix.BeginsWith(this->LongName() + "[")) { if (!prefix.EndsWith("]")) return 0; // incorrect index int i = prefix.Find('['); iString sidx = prefix.Part(i, prefix.Length() - 1 - i); int idx = sidx.ToInt(ok); if (ok && idx >= 0 && idx < this->Size()) { // // There is an index specifier // const iObject *obj = this->GetMember(idx); IASSERT(obj); if (name.Contains(".") > 0) obj = obj->FindByName(name.Section(".", 1)); return obj; } else return 0; // incorrect index } else return 0; } void iObjectCollection::RegisterWithHelpFactory() const { this->RegisterPropertiesWithHelpFactory(); int i; for(i=0; iRegisterWithHelpFactory(); } } ifrit-4.1.2/core/iobjectcollection.h0000674060175406010010000000542312641012526016013 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IOBJECTCOLLECTION_H #define IOBJECTCOLLECTION_H #include "iobject.h" class iObjectCollection : public iObject { friend class iShell; public: vtkTypeMacro(iObjectCollection,iObject); inline int Size() const { return mChildren.Size(); } virtual iObject* GetMember(int i) const; virtual void RegisterWithHelpFactory() const; virtual const iObject* FindByName(const iString &name) const; protected: virtual bool CreateMember() = 0; virtual bool RemoveMember(int i) = 0; iObjectCollection(iObject *parent, const iString &fname, const iString &sname); static bool AutoCreate; }; // // A simple collection of the fixed number of iObjects // template class iObjectCollectionFixed : public iObjectCollection { public: iObjectPropertyMacro1S(Number,Int); vtkTypeMacro(iObjectCollectionFixed,iObjectCollection); protected: iObjectCollectionFixed(iObject *parent, const iString &fname, const iString &sname, int minsize); virtual ~iObjectCollectionFixed(); virtual bool CreateMember(); virtual bool RemoveMember(int i); virtual Object* NewObject() = 0; const int MinSize; }; // // Resizable collection // template class iObjectCollectionResizable : public iObjectCollectionFixed { public: vtkTypeMacro(iObjectCollectionResizable,iObjectCollectionFixed); iPropertyAction1 Remove; protected: iObjectCollectionResizable(iObject *parent, const iString &fname, const iString &sname, int minsize); virtual bool RemoveMember(int i); }; #endif // IOBJECTCOLLECTION_H ifrit-4.1.2/core/iobjectcollection.tlh0000674060175406010010000000415112641012510016341 0ustar HomeNone//LICENSE A #include "iobjectcollection.h" #include "imath.h" // // A simple collection of iObjects // template iObjectCollectionFixed::iObjectCollectionFixed(iObject *parent, const iString &fname, const iString &sname, int minsize) : iObjectCollection(parent,fname,sname), Number(iObject::Self(),static_cast(&iObjectCollectionFixed::SetNumber),static_cast(&iObjectCollectionFixed::GetNumber),"Number","num",9), MinSize(minsize) { } template iObjectCollectionFixed::~iObjectCollectionFixed() { } template bool iObjectCollectionFixed::CreateMember() { Object* tmp = this->NewObject(); if(tmp == 0) return false; this->mNumber = this->Size(); #ifndef I_NO_CHECK if(mChildren.Find(tmp) != this->mNumber-1) { IBUG_ERROR("Incorrect ordering of collection members."); } #endif return true; } template bool iObjectCollectionFixed::RemoveMember(int i) { if(i>=0 && iSize() && this->Size()>this->MinSize) { this->mChildren[i]->Delete(); this->mNumber = this->Size(); return true; } else return false; } template bool iObjectCollectionFixed::SetNumber(int n) { if(iObjectCollection::AutoCreate && n>=this->MinSize) { while(this->Size() > n) { if(!this->RemoveMember(mChildren.MaxIndex())) return false; } while(this->Size() < n) { if(!this->CreateMember()) return false; } return true; } else return false; } // // Resizable collection // template iObjectCollectionResizable::iObjectCollectionResizable(iObject *parent, const iString &fname, const iString &sname, int minsize) : iObjectCollectionFixed(parent,fname,sname,minsize), Remove(iObject::Self(),static_cast::CallerType>(&iObjectCollectionResizable::RemoveMember),"Delete","dlt") { Remove.AddFlag(iProperty::_FunctionsAsIndex); } template bool iObjectCollectionResizable::RemoveMember(int i) { return this->iObjectCollectionFixed::RemoveMember(i); } ifrit-4.1.2/core/iobjectfactory.cpp0000674060175406010010000001517112641012556015666 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iobjectfactory.h" // // This file is documented only partially. // #include "iabstractextension.h" #include "icoredatasubjects.h" #include "icrosssectionviewsubject.h" #include "idatareader.h" #include "idatalimits.h" #include "iedition.h" #include "iparticleviewsubject.h" #include "ipicker.h" #include "ipointer.h" #include "isurfaceviewsubject.h" #include "itensorfieldviewsubject.h" #include "ivectorfieldviewsubject.h" #include "iviewmodule.h" #include "iviewobject.h" #include "ivolumeviewsubject.h" // // Templates // #include "iarray.tlh" using namespace iParameter; // // Helper class // class iAbstractExtensionPointer : public iPointer::Ordered { public: iAbstractExtensionPointer(iAbstractExtension *ptr = 0) : iPointer::Ordered(ptr){} }; // // Main class // iArray& iObjectFactory::Extensions() { static iOrderedArray ext; return ext; } void iObjectFactory::AttachExtension(iAbstractExtension *ext) { if(ext != 0) Extensions().Add(ext); } // // ************************************************************************** // // IMPORTANT: Factory methods do not need to be checked for null pointers // since they are only called from within New() functions // // ************************************************************************** // iViewObject* iObjectFactory::CreateViewObject(iViewModule *parent, const iString& name) { IASSERT(parent); int i, j; iViewObject *obj = 0; iViewSubject *sub; iArray &ext(Extensions()); // // View objects // if(obj == 0) { static iString LongName = "CrossSection"; static iString ShortName = "x"; if(name==ShortName || name==LongName) { obj = iViewObject::New(parent,LongName,ShortName); IERROR_CHECK_MEMORY(obj); obj->AddSubject(iCrossSectionViewSubject::New(obj,iCoreData::ScalarDataSubject::DataType())); for(i=0; iCreateCrossSectionSubject(obj,j++)) != 0) obj->AddSubject(sub); } } } if(obj == 0) { static iString LongName = "Particles"; static iString ShortName = "p"; if(name==ShortName || name==LongName) { obj = iViewObject::New(parent,LongName,ShortName); if(obj == 0) return 0; obj->AddSubject(iParticleViewSubject::New(obj,iCoreData::ParticleDataSubject::DataType())); for(i=0; iCreateParticleSubject(obj,j++)) != 0) obj->AddSubject(sub); } } } if(obj == 0) { static iString LongName = "Surface"; static iString ShortName = "s"; if(name==ShortName || name==LongName) { obj = iViewObject::New(parent,LongName,ShortName); if(obj == 0) return 0; obj->AddSubject(iSurfaceViewSubject::New(obj,iCoreData::ScalarDataSubject::DataType())); for(i=0; iCreateSurfaceSubject(obj,j++)) != 0) obj->AddSubject(sub); } } } if(obj == 0) { static iString LongName = "TensorField"; static iString ShortName = "t"; if(name==ShortName || name==LongName) { obj = iViewObject::New(parent,LongName,ShortName); if(obj == 0) return 0; obj->AddSubject(iTensorFieldViewSubject::New(obj,iCoreData::TensorDataSubject::DataType(),iCoreData::ScalarDataSubject::DataType())); for(i=0; iCreateTensorFieldSubject(obj,j++)) != 0) obj->AddSubject(sub); } } } if(obj == 0) { static iString LongName = "VectorField"; static iString ShortName = "u"; if(name==ShortName || name==LongName) { obj = iViewObject::New(parent,LongName,ShortName); if(obj == 0) return 0; obj->AddSubject(iVectorFieldViewSubject::New(obj,iCoreData::VectorDataSubject::DataType(),iCoreData::ScalarDataSubject::DataType())); for(i=0; iCreateVectorFieldSubject(obj,j++)) != 0) obj->AddSubject(sub); } } } if(obj == 0) { static iString LongName = "Volume"; static iString ShortName = "v"; if(name==ShortName || name==LongName) { obj = iViewObject::New(parent,LongName,ShortName); if(obj == 0) return 0; obj->AddSubject(iVolumeViewSubject::New(obj,iCoreData::ScalarDataSubject::DataType())); for(i=0; iCreateVolumeSubject(obj,j++)) != 0) obj->AddSubject(sub); } } } for(i=0; obj==0 && iCreateSpecialObject(parent,name); } iEdition::ApplySettings(obj); return obj; } // // These functions install extensions on various extendable classes. // void iObjectFactory::InstallExtensions(iDataReader *reader) { int i; iArray &ext(Extensions()); iDataReaderExtension *s; for(i=0; iCreateDataReaderExtension(reader); if(s != 0) reader->InstallExtension(s); } } void iObjectFactory::InstallExtensions(iPicker *picker) { int i; iArray &ext(Extensions()); iPickerExtension *s; for(i=0; iCreatePickerExtension(picker); if(s != 0) picker->InstallExtension(s); } } void iObjectFactory::InstallExtensions(iViewModule *vm) { int i; iArray &ext(Extensions()); iViewModuleExtension *s; for(i=0; iCreateViewModuleExtension(vm); if(s != 0) vm->InstallExtension(s); } } ifrit-4.1.2/core/iobjectfactory.h0000674060175406010010000000375712641012526015337 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IOBJECTFACTORY_H #define IOBJECTFACTORY_H class iAbstractExtension; class iAbstractExtensionPointer; class iDataReader; template class iArray; class iPicker; class iString; class iViewModule; class iViewObject; class iViewObjectParent; class iObjectFactory { friend class iAbstractExtension; public: static iViewObject* CreateViewObject(iViewModule *parent, const iString& name); // // Extensions for extendable objects // static void InstallExtensions(iDataReader *reader); static void InstallExtensions(iPicker *picker); static void InstallExtensions(iViewModule *vm); private: static void AttachExtension(iAbstractExtension *ext); static iArray& Extensions(); }; #endif // IOBJECTFACTORY_H ifrit-4.1.2/core/ioptimizepolydatafilter.cpp0000674060175406010010000000332012641012556017625 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ioptimizepolydatafilter.h" // // Templates // #include "igenericfilter.tlh" iOptimizePolyDataFilter::iOptimizePolyDataFilter(iDataConsumer *consumer) : iGenericPolyDataFilter(consumer,1,true) { mEnabled = true; } void iOptimizePolyDataFilter::SetEnabled(bool s) { mEnabled = s; } void iOptimizePolyDataFilter::ProvideOutput() { if(mEnabled) { this->ExecuteParent(); } else { this->OutputData()->ShallowCopy(this->InputData()); } } ifrit-4.1.2/core/ioptimizepolydatafilter.h0000674060175406010010000000327712641012526017302 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IOPTIMIZEPOLYDATAFILTER_H #define IOPTIMIZEPOLYDATAFILTER_H #include "igenericfilter.h" #include class iOptimizePolyDataFilter : public iGenericPolyDataFilter { iGenericFilterTypeMacro(iOptimizePolyDataFilter,vtkStripper); public: void SetEnabled(bool s); inline bool GetEnabled() const { return mEnabled; } protected: virtual void ProvideOutput(); bool mEnabled; }; #endif // IOPTIMIZEPOLYDATAFILTER_H ifrit-4.1.2/core/iorthopolygonplanefilter.cpp0000674060175406010010000001450412641012556020020 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iorthopolygonplanefilter.h" #include "ierror.h" #include "iorthoslicer.h" #include "ivtk.h" #include #include #include #include #include #include // // Templates // #include "igenericfilter.tlh" #ifndef IVTK_QUAD_ORDER #error Misconfiguration: missing IVTK_QUAD_ORDER define. !TERMINATE! #endif iOrthoPolygonPlaneFilter::iOrthoPolygonPlaneFilter(iDataConsumer *consumer) : iGenericFilter(consumer,1,true) { mInterpolate = true; mOldDimU = mOldDimV = 0; // // Keep our quds so that we do not have to re-create them unless something changes // mNewQuads = vtkCellArray::New(); IERROR_CHECK_MEMORY(mNewQuads); } iOrthoPolygonPlaneFilter::~iOrthoPolygonPlaneFilter() { mNewQuads->Delete(); } void iOrthoPolygonPlaneFilter::SetInterpolation(bool s) { mInterpolate = s; this->Modified(); } void iOrthoPolygonPlaneFilter::ProvideOutput() { int dims[3]; double org[3], spa[3]; vtkImageData *input = this->InputData(); vtkPolyData *output = this->OutputData(); output->Initialize(); // // Do we have cell or point data? // bool isPointData; if(input->GetPointData()->GetScalars() != 0) { isPointData = true; } else if(input->GetCellData()->GetScalars() != 0) { isPointData = false; } else { // // Must be quiet here for parallel execution // return; } input->GetOrigin(org); input->GetSpacing(spa); input->GetDimensions(dims); int i, j, k, Axis = -1; for(i=0; i<3; i++) { if(dims[i] == 1) Axis = i; } if(Axis == -1) { vtkErrorMacro("iOrthoPolygonPlaneFilter: input data are not a plane."); return; } int u, v, dimU, dimV; iOrthoSlicer::GetUV(Axis,u,v); if(isPointData) { dimU = dims[u]; dimV = dims[v]; } else { dimU = dims[u] + 1; dimV = dims[v] + 1; } if(dimU<1 || dimV<1) { return; } vtkIdType numPts = (vtkIdType)dimU*dimV; vtkPoints *newPts = vtkPoints::New(VTK_FLOAT); IERROR_CHECK_MEMORY(newPts); newPts->SetNumberOfPoints(numPts); float xyz[3]; xyz[Axis] = org[Axis]; float *p = (float *)newPts->GetVoidPointer(0); for(j=0; jUpdateProgress(float(j)/dimV); if(this->GetAbortExecute()) break; xyz[v] = org[v] + spa[v]*j; for(i=0; iDelete(); mNewQuads = vtkCellArray::New(); IERROR_CHECK_MEMORY(mNewQuads); mNewQuads->Allocate(mNewQuads->EstimateSize((dimV-1)*(dimU-1),4)); vtkIdType l[4]; for(j=0; jUpdateProgress(float(j)/(dimV-1)); if(this->GetAbortExecute()) break; for(i=0; iInsertNextCell(4,l); } } mOldDimU = dimU; mOldDimV = dimV; } output->SetPolys(mNewQuads); output->SetPoints(newPts); newPts->Delete(); // // Assign scalars // if(isPointData) { if(!mInterpolate) { // // Correct for flat shading // if(!wArray.Init(input->GetPointData()->GetScalars())) { this->SetAbortExecute(1); return; } float *pl, *ql; for(j=0; jGetPointData()->SetScalars(wArray.ArrOut); wArray.ArrOut->Delete(); } else { output->GetPointData()->SetScalars(input->GetPointData()->GetScalars()); } } else { if(!wArray.Init(input->GetCellData()->GetScalars(),numPts)) { this->SetAbortExecute(1); return; } int du = dimU - 1; if(mInterpolate) { float *ql; int i1, j1, i2, j2; for(j=0; jGetPointData()->SetScalars(wArray.ArrOut); wArray.ArrOut->Delete(); } } ifrit-4.1.2/core/iorthopolygonplanefilter.h0000674060175406010010000000347512641012526017467 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IORTHOPOLYGONPLANEFILTER_H #define IORTHOPOLYGONPLANEFILTER_H #include "igenericfilter.h" #include class vtkCellArray; class iOrthoPolygonPlaneFilter : public iGenericFilter { iGenericFilterTypeMacro(iOrthoPolygonPlaneFilter,vtkDataSetAlgorithm); public: void SetInterpolation(bool s); protected: virtual ~iOrthoPolygonPlaneFilter(); virtual void ProvideOutput(); private: bool mInterpolate; int mOldDimU, mOldDimV; vtkCellArray *mNewQuads; }; #endif // IORTHOPOLYGONPLANEFILTER_H ifrit-4.1.2/core/iorthoslicer.cpp0000674060175406010010000001542612641012556015370 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iorthoslicer.h" #include "idata.h" #include "ierror.h" #include "iuniformgriddata.h" #include "iviewmodule.h" #include #include #include using namespace iParameter; // // Templates // #include "igenericfilter.tlh" iOrthoSlicer::iOrthoSlicer(iDataConsumer *consumer) : iGenericImageDataFilter(consumer,1,true) { mCurVar = 0; mPos[0] = mPos[1] = mPos[2] = 0; mDir = 2; mSampleRate = 1; mInterpolate = true; } iOrthoSlicer::~iOrthoSlicer() { } void iOrthoSlicer::SetCurrentVar(int n) { if(n>=0 && n!=mCurVar) { mCurVar = n; this->Modified(); } } void iOrthoSlicer::SetInterpolation(bool s) { if(s != mInterpolate) { mInterpolate = s; this->Modified(); } } void iOrthoSlicer::SetPos(double p) { mPos[mDir] = p; this->Modified(); } void iOrthoSlicer::SetDir(int d) { if(d>=0 && d<3 && d!=mDir) { mDir = d; this->Modified(); } } void iOrthoSlicer::ProvideOutput() { int numCellsIn[3], dimsIn[3], dimsOut[3]; double orgIn[3], spaIn[3]; double orgOut[3], spaOut[3]; int u, v; iOrthoSlicer::GetUV(mDir,u,v); iUniformGridData *input = iUniformGridData::SafeDownCast(this->InputData()); vtkImageData *output = this->OutputData(); output->Initialize(); if(input == 0) return; input->GetNumCells(numCellsIn); if(numCellsIn[u]<1 || numCellsIn[v]<1) return; // // Get info about out configuration // input->GetSpacing(spaIn); input->GetGlobalOrigin(orgIn); input->GetDimensions(dimsIn); // // Compute the sub-sampling factor // int step = mSampleRate; step = (numCellsIn[u]/8 > step) ? step : numCellsIn[u]/8; step = (numCellsIn[v]/8 > step) ? step : numCellsIn[v]/8; if(step < 1) step = 1; // // Decide what we do: cell vs point data, how many points, etc. // if(input->GetVoxelLocation() == VoxelLocation::Vertex) { // // Place points as we get them // dimsOut[u] = numCellsIn[u]/step + 1; dimsOut[v] = numCellsIn[v]/step + 1; if(dimsOut[u]<2 || dimsOut[v]<2) return; spaOut[u] = (spaIn[u]*numCellsIn[u])/(dimsOut[u]-1); spaOut[v] = (spaIn[v]*numCellsIn[v])/(dimsOut[v]-1); } else { // // Create points around cells, but throw away periodic offsets // dimsOut[u] = numCellsIn[u]/step; dimsOut[v] = numCellsIn[v]/step; if(dimsOut[u]<1 || dimsOut[v]<1) return; spaOut[u] = (spaIn[u]*numCellsIn[u])/dimsOut[u]; spaOut[v] = (spaIn[v]*numCellsIn[v])/dimsOut[v]; } dimsOut[mDir] = 1; spaOut[mDir] = 1.0; orgOut[u] = orgIn[u]; orgOut[v] = orgIn[v]; orgOut[mDir] = mPos[mDir]; // // Find the intersection // int ijk[3], ijk1[3], ijk2[3]; float ht = (mPos[mDir]-orgIn[mDir])/spaIn[mDir]; //Normalized height // // Must do that for parallel work // if(ht<-0.01 || ht>numCellsIn[mDir]+0.01) { return; } if(input->GetVoxelLocation() == VoxelLocation::Center) ht -= 0.5; // // Add a little bit of a cushion // if(ht < 0.01) ht = 0.01; if(ht > numCellsIn[mDir]-0.01) ht = numCellsIn[mDir] - 0.01; ijk1[mDir] = ijk2[mDir] = int(ht); //Grid Point below if(ijk2[mDir] < dimsIn[mDir]-1) ijk2[mDir]++; #ifndef I_NO_CHECK if(ijk1[mDir]<0 || ijk2[mDir]>=dimsIn[mDir]) { IBUG_WARN("Internal check failed."); } #endif float ss2 = ht - ijk1[mDir]; float ss1 = 1.0 - ss2; output->SetDimensions(dimsOut); output->SetOrigin(orgOut); output->SetSpacing(spaOut); // // Prepare output scalars // vtkIdType numPts = dimsOut[u]*dimsOut[v]; if(!wArray.Init(input->GetPointData()->GetScalars(),numPts,1)) { this->SetAbortExecute(1); return; } wArray.PtrIn += mCurVar; vtkIdType loffOut, loffIn1, loffIn2; for(ijk[v]=0; ijk[v]UpdateProgress(double(ijk[v])/dimsOut[v]); if(this->GetAbortExecute()) break; for(ijk[u]=0; ijk[u]GetVoxelLocation() == VoxelLocation::Vertex) { output->GetPointData()->SetScalars(wArray.ArrOut); wArray.ArrOut->Delete(); } else { output->GetCellData()->SetScalars(wArray.ArrOut); wArray.ArrOut->Delete(); } } void iOrthoSlicer::GetUV(int Axis, int &u, int &v) { switch(Axis) { case 0: { u = 1; v = 2; return; } case 1: { u = 0; v = 2; return; } case 2: { u = 0; v = 1; return; } } } ifrit-4.1.2/core/iorthoslicer.h0000674060175406010010000000424412641012526015026 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IORTHOSLICER_H #define IORTHOSLICER_H #include "igenericfilter.h" #include class iOrthoSlicer : public iGenericImageDataFilter { iGenericFilterTypeMacro(iOrthoSlicer,vtkImageAlgorithm); public: void SetCurrentVar(int n); inline int GetCurrentVar() const { return mCurVar; } void SetDir(int d); inline int GetDir() const { return mDir; } void SetPos(double p); inline double GetPos() const { return mPos[mDir]; } void SetInterpolation(bool s); inline bool GetInterpolation() const { return mInterpolate; } void SetSampleRate(int r){ mSampleRate = r; Modified(); } inline int GetSampleRate() const { return mSampleRate; } static void GetUV(int Axis, int &Uidx, int &Vidx); protected: virtual ~iOrthoSlicer(); virtual void ProvideOutput(); private: int mCurVar; double mPos[3]; int mDir, mSampleRate; bool mInterpolate; }; #endif // IORTHOSLICER_H ifrit-4.1.2/core/iorthotextureplanefilter.cpp0000674060175406010010000001655412641012557020041 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iorthotextureplanefilter.h" #include "idatalimits.h" #include "ierror.h" #include "iorthoslicer.h" #include "imath.h" #include #include #include #include // // Templates // #include "igenericfilter.tlh" iOrthoTexturePlaneFilter::iOrthoTexturePlaneFilter(iDataConsumer *consumer) : iGenericFilter(consumer,1,true) { mTexture = 0; mOffX = mOffY = 0; } void iOrthoTexturePlaneFilter::SetTexturePiece(vtkImageData *texture, int offx, int offy, double globalOrg[3], int globalDims[3]) { int i; mTexture = texture; mOffX = offx; mOffY = offy; for(i=0; i<3; i++) { mGlobalOrg[i] = globalOrg[i]; mGlobalDims[i] = globalDims[i]; } this->Modified(); } void iOrthoTexturePlaneFilter::ProvideOutput() { vtkImageData *input = this->InputData(); vtkPolyData *output = this->OutputData(); int dims[3], dimsTexture[3]; double org[3], spa[3]; output->Initialize(); if(mTexture == 0) return; // // Do we have cell or point data? // vtkFloatArray *scalars; bool isPointData; if(input->GetPointData()->GetScalars() != 0) { isPointData = true; scalars = vtkFloatArray::SafeDownCast(input->GetPointData()->GetScalars()); } else if(input->GetCellData()->GetScalars() != 0) { isPointData = false; scalars = vtkFloatArray::SafeDownCast(input->GetCellData()->GetScalars()); } else { // // Must be quiet here for parallel execution // return; } if(scalars == 0) return; // // Prepare texture support // input->GetOrigin(org); input->GetSpacing(spa); input->GetDimensions(dims); int i, Axis = -1; for(i=0; i<3; i++) { if(dims[i] == 1) Axis = i; } if(Axis == -1) return; int u, v, dimU, dimV; iOrthoSlicer::GetUV(Axis,u,v); if(isPointData) { dimU = dims[u] - 1; dimV = dims[v] - 1; } else { dimU = dims[u]; dimV = dims[v]; } if(dimU<1 || dimV<1) { return; } mTexture->GetDimensions(dimsTexture); // // AppendPolyDataFilter does not merge texture coordinates into one, so we need to create the correct texture support here. // We create it for zero offset instance, and skip it altogether for other instances. // if(mOffX==0 && mOffY==0) { float tc[2], pad; static vtkIdType pts[4]={0,1,2,3}; int dimU, dimV; if(isPointData) { dimU = mGlobalDims[u] - 1; dimV = mGlobalDims[v] - 1; pad = 0.0; } else { dimU = mGlobalDims[u] - 1; dimV = mGlobalDims[v] - 1; pad = 0.5; } // // We'll create the building blocks of polydata including data attributes. // vtkPoints *points = vtkPoints::New(VTK_FLOAT); IERROR_CHECK_MEMORY(points); points->SetNumberOfPoints(4); vtkCellArray *polys = vtkCellArray::New(); IERROR_CHECK_MEMORY(polys); vtkFloatArray *tcoords = vtkFloatArray::New(); IERROR_CHECK_MEMORY(tcoords); tcoords->SetNumberOfComponents(2); tcoords->SetNumberOfTuples(4); vtkFloatArray *normals = vtkFloatArray::New(); IERROR_CHECK_MEMORY(normals); normals->SetNumberOfComponents(3); normals->SetNumberOfTuples(4); // // Load the cell, and data attributes. // polys->InsertNextCell(4,pts); // // Place the support plane // double x1[3]; x1[Axis] = org[Axis]; // // LL point // x1[u] = mGlobalOrg[u] - pad*spa[u]; x1[v] = mGlobalOrg[v] - pad*spa[v]; points->SetPoint(0,x1); tc[0] = 0.0; tc[1] = 0.0; tcoords->SetTuple(0,tc); // // LR point // x1[u] = mGlobalOrg[u] - pad*spa[u] + spa[u]*dimU; x1[v] = mGlobalOrg[v] - pad*spa[v]; points->SetPoint(1,x1); tc[0] = float(dimU)/dimsTexture[0]; tc[1] = 0.0; tcoords->SetTuple(1,tc); // // UR point // x1[u] = mGlobalOrg[u] - pad*spa[u] + spa[u]*dimU; x1[v] = mGlobalOrg[v] - pad*spa[v] + spa[v]*dimV; points->SetPoint(2,x1); tc[0] = float(dimU)/dimsTexture[0]; tc[1] = float(dimV)/dimsTexture[1]; tcoords->SetTuple(2,tc); // // UL point // x1[u] = mGlobalOrg[u] - pad*spa[u]; x1[v] = mGlobalOrg[v] - pad*spa[v] + spa[v]*dimV; points->SetPoint(3,x1); tc[0] = 0.0; tc[1] = float(dimV)/dimsTexture[1]; tcoords->SetTuple(3,tc); x1[u] = x1[v] = 0.0; x1[Axis] = 1.0; normals->SetTuple(0,x1); normals->SetTuple(1,x1); normals->SetTuple(2,x1); normals->SetTuple(3,x1); // // We now assign the pieces to the vtkPolyData. // output->SetPolys(polys); output->SetPoints(points); output->GetPointData()->SetTCoords(tcoords); output->GetPointData()->SetNormals(normals); polys->Delete(); points->Delete(); tcoords->Delete(); normals->Delete(); } // // Fill in our portion of the texture // int ncomIn = scalars->GetNumberOfComponents(); float *ptrIn = scalars->GetPointer(0); float *ptrOut = (float *)mTexture->GetScalarPointer(); if(ptrOut == 0) { vtkErrorMacro("Texture data has not been allocated properly."); return; } int ijk[3], ijkmin[3], ijknum[3]; ijk[Axis] = 0; ijkmin[u] = 0; ijkmin[v] = 0; ijknum[u] = dimU; ijknum[v] = dimV; if(mOffX < 0) ijkmin[u] -= mOffX; if(mOffY < 0) ijkmin[v] -= mOffY; if(mOffX+ijknum[u] > dimsTexture[0]) ijknum[u] = dimsTexture[0] - mOffX; if(mOffY+ijknum[v] > dimsTexture[1]) ijknum[v] = dimsTexture[1] - mOffY; vtkIdType off1 = 0, off2 = 0, off3; switch(Axis) { case 0: { // // u = 1, v = 2; // off1 = dims[0]; off2 = dims[0]*dims[1]; break; } case 1: { // // u = 0, v = 1; // off1 = 1; off2 = dims[0]*dims[1]; break; } case 2: { // // u = 0, v = 1; // off1 = 1; off2 = dims[0]; break; } } off1 *= ncomIn; off2 *= ncomIn; off3 = off1 + off2; vtkIdType lIn, lOut; for(ijk[v]=ijkmin[v]; ijk[v]UpdateProgress(double(ijk[v]-ijkmin[v])/(ijknum[v]-ijkmin[v])); if(this->GetAbortExecute()) break; for(ijk[u]=ijkmin[u]; ijk[u]Modified(); } ifrit-4.1.2/core/iorthotextureplanefilter.h0000674060175406010010000000360512641012526017473 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IORTHOTEXTUREPLANEFILTER_H #define IORTHOTEXTUREPLANEFILTER_H #include "igenericfilter.h" #include class iOrthoTexturePlaneFilter : public iGenericFilter { iGenericFilterTypeMacro(iOrthoTexturePlaneFilter,vtkDataSetAlgorithm); public: // // Offsets needed for parallel work // void SetTexturePiece(vtkImageData *texture, int offX, int offY, double globalOrg[3], int globalDims[3]); protected: virtual void ProvideOutput(); private: vtkImageData *mTexture; int mOffX, mOffY; double mGlobalOrg[3]; int mGlobalDims[3]; }; #endif // IORTHOTEXTUREPLANEFILTER_H ifrit-4.1.2/core/ioutput.cpp0000775060175406010010000001474412641012557014400 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ioutput.h" #include "iarray.h" #include "ierror.h" #include "iexception.h" #include "ifile.h" #include "imath.h" #include "ioutputchannel.h" #include "ishell.h" #include "istring.h" #include // // Templates // #include "iarray.tlh" using namespace iParameter; namespace iOutput_Private { // // Take over VTK display function to prevent it from displaying extra windows // class OutputWindow : public vtkOutputWindow { public: vtkTypeMacro(OutputWindow,vtkOutputWindow); static OutputWindow* New() { return new OutputWindow(); } // // Don't overwrite those, they ARE thread-safe // virtual void DisplayText(const char* message) { iOutput::Display(MessageType::Information,message); } virtual void DisplayErrorText(const char* message) { const char* fm = this->FormattedErrorMessage(message); if(fm != 0) { iOutput::Display(MessageType::Warning,fm); // display VTK messages as warning to avoid interrupting the rendering stream } } virtual void DisplayWarningText(const char* message) { const char* fm = this->FormattedErrorMessage(message); if(fm != 0) { iOutput::Display(MessageType::Warning,message); } } virtual void DisplayGenericWarningText(const char* message) { const char* fm = this->FormattedErrorMessage(message); if(fm != 0) { this->DisplayWarningText(fm); } } virtual void DisplayDebugText(const char* message) { #ifdef I_DEBUG this->DisplayText(message); #endif } private: OutputWindow() { this->PromptUserOff(); } const char* FormattedErrorMessage(const char* message) const { // // Block some of the VTK error messages - not all are useful // static const char *classBlockError[] = { "vtkDecimate", "vtkPolyDataNormals", "vtkWindowedSincPolyDataFilter", "vtkStreamingDemandDrivenPipeline", "vtkDataSetToDataSetFilter", "vtkOpenGLExtensionManager", "vtkStreamingDemandDrivenPipeline" }; static const char *messgBlockError[] = { "No data to decimate!", "No data to generate normals for!", "No data to smooth!", "The update extent specified in the information for output port", "Changing input type. Deleting output", "Extension GL_VERSION_1_2 could not be loaded.", "returned failure for request: vtkInformation" }; static const int nBlockError = sizeof(classBlockError)/sizeof(char*); int i; for(i=0; i Stack; // // Error log // iArray ErrorLog; }; using namespace iOutput_Private; void iOutput::Display(int type, const iString &text) { try { if(Stack.Size() > 0) { Stack.Last()->Display(type,text); } else { // // Send everything to the standard vtkOutputWindow // iString s = text + "\n"; if(type == MessageType::Error) vtkOutputWindow::GetInstance()->PromptUserOff(); vtkOutputWindow::GetInstance()->DisplayText(s.ToCharPointer()); vtkOutputWindow::GetInstance()->PromptUserOff(); } } catch(iException::GlobalExit) { cerr << "Unable to display output - something is awfully wrong." << endl; throw iException::UnableToOutput(); // this exception is not supposed to be caught exit(-1); } } void iOutput::ReportBug(const char* text, const char* file, int line, int severity) { ReportBug(iString(text),file,line,severity); } void iOutput::ReportBug(const iString& text, const char* file, int line, int severity) { iString s; if(severity >= 0) s += "BUG: "; s += text + "\n FILE: " + file + "\n LINE: " + iString::FromNumber(line); switch(severity) { case 0: { s += "\n This problem is fatal. IFrIT will now exit."; break; } case 1: { s += "\n Current operation is aborted."; break; } case 2: { int o = 0; // just a placeholder for a breakpoint break; } } Display(MessageType::Error,s); if(severity <= 0) { throw iException::GlobalExit(); } } void iOutput::AddChannel(iOutputChannel *channel) { IASSERT(channel); Stack.Add(channel); channel->Register(0); // // Take over the VTK output window // OutputWindow *ow = OutputWindow::New(); if(ow == 0) { vtkOutputWindow::GetInstance()->DisplayErrorText("FATAL ERROR: unable to initialize output channel."); exit(-1); } vtkOutputWindow::SetInstance(ow); ow->Delete(); } void iOutput::RemoveChannel(iOutputChannel *channel) { if(Stack.Remove(channel)) { channel->UnRegister(0); } if(Stack.Size() == 0) { // // Restore the VTK output window // vtkOutputWindow::SetInstance(0); } } void iOutput::LogError(const iString &text) { ErrorLog.Add(text); } #ifdef I_DEBUG void iOutput::DisplayDebugMessage(const iString& text) { static int count = 0; iString s = iString::FromNumber(++count,"...%6d ") + text; Display(MessageType::DebugMessage,s); } #endif ifrit-4.1.2/core/ioutput.h0000674060175406010010000000433012641012527014026 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Class for outputing textual information. It is static, so it is available globally. // It uses a stack of iOutputChannel(s) to handle the output. Shells can add or remove // channels to redirect output where they like. // #ifndef IOUTPUT_H #define IOUTPUT_H class iOutputChannel; class iString; namespace iParameter { namespace MessageType { const int Error = 0; const int Warning = 1; const int Information = 2; #ifdef I_DEBUG const int DebugMessage = 3; #endif }; }; class iOutput { public: static void Display(int type, const iString &text); static void ReportBug(const char* text, const char* file, int line, int severity); static void ReportBug(const iString& text, const char* file, int line, int severity); static void LogError(const iString &text); static void AddChannel(iOutputChannel *channel); static void RemoveChannel(iOutputChannel *channel); #ifdef I_DEBUG static void DisplayDebugMessage(const iString& text); #endif }; #endif // IOUTPUT_H ifrit-4.1.2/core/ioutputchannel.cpp0000674060175406010010000000414112641012557015715 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ioutputchannel.h" #include "ierror.h" #include "ishell.h" #include using namespace iParameter; iOutputChannel::iOutputChannel(iShell *s) : iShellComponent(s) { mInDisplay = false; mMutex = vtkCriticalSection::New(); IASSERT(mMutex); } iOutputChannel::~iOutputChannel() { mMutex->Delete(); } void iOutputChannel::Display(int type, const iString &text) { if(mInDisplay) return; mMutex->Lock(); mInDisplay = true; this->DisplayBody(type,text); if(type == MessageType::Error) { iOutput::LogError(text); } mMutex->Unlock(); mInDisplay = false; } void iOutputChannel::DisplayBody(int type, const iString &text) { iString s = text + "\n"; switch(type) { case MessageType::Error: { cerr << s.ToCharPointer(); cerr.flush(); break; } default: { cout << s.ToCharPointer(); cout.flush(); } } } ifrit-4.1.2/core/ioutputchannel.h0000674060175406010010000000367712641012527015374 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Method for outputing messages // #ifndef IOUTPUTCHANNEL_H #define IOUTPUTCHANNEL_H #include #include "ishellcomponent.h" #include class iShell; class iString; class vtkCriticalSection; class iOutputChannel : public vtkObjectBase, public iShellComponent { friend class iShell; public: vtkTypeMacro(iOutputChannel,vtkObjectBase); // // Use this function to report errors and display text // void Display(int type, const iString &text); protected: iOutputChannel(iShell *s); virtual ~iOutputChannel(); virtual void DisplayBody(int type, const iString &text) = 0; private: bool mInDisplay; vtkCriticalSection *mMutex; }; #endif // IOUTPUTCHANNEL_H ifrit-4.1.2/core/ioverlayhelper.cpp0000674060175406010010000000733512641012557015715 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ioverlayhelper.h" #include "ierror.h" #include "imagnifier.h" #include "imath.h" #include "irendertool.h" #include #include #include #include using namespace iParameter; iOverlayHelper* iOverlayHelper::New(iRenderTool *rt) { IASSERT(rt); return new iOverlayHelper(rt); } iOverlayHelper::iOverlayHelper(iRenderTool *rt) : mRenderTool(rt) { mIsAutoColor = true; mFontFactor = 1.0f; } iOverlayHelper::~iOverlayHelper() { } const iColor& iOverlayHelper::GetColor(vtkViewport* viewport) { if(mIsAutoColor && viewport!=0) { int i; double bg[3]; viewport->GetBackground(bg); for(i=0; i<3; i++) bg[i] = 1.0 - bg[i]; wColor = iColor(bg); } else { wColor = mFixedColor; } return wColor; } int iOverlayHelper::GetRenderingMagnification() const { return mRenderTool->GetRenderingMagnification(); } void iOverlayHelper::ComputePositionShiftsUnderMagnification(int winij[2]) { int mag = mRenderTool->GetRenderingMagnification(); // // Compute position shifts if under magnification // if(mag > 1) { mRenderTool->GetMagnifier()->GetTile(winij[0],winij[1]); } else winij[0] = winij[1] = 0; } vtkCamera* iOverlayHelper::GetCamera(vtkViewport *vp) const { vtkRenderer *ren = vtkRenderer::SafeDownCast(vp); if(ren == 0) return 0; else return ren->GetActiveCamera(); } int iOverlayHelper::GetFontSize(vtkViewport *vp, float factor) const { float v = factor*16*mFontFactor*exp(0.3*mRenderTool->GetFontScale())/480; vtkRenderer *ren = vtkRenderer::SafeDownCast(vp); if(ren != 0) { if(ren->GetActiveCamera()->GetUseHorizontalViewAngle() != 0) { return iMath::Round2Int(v*vp->GetSize()[0]); } else { return iMath::Round2Int(v*vp->GetSize()[1]); } } else return iMath::Round2Int(v*480); } void iOverlayHelper::UpdateTextProperty(vtkViewport *vp, vtkTextProperty *prop) { #ifndef I_NO_CHECK int mag = mRenderTool->GetRenderingMagnification(); if(mag > 1) { IBUG_WARN("Extra call to iOverlayHelper::UpdateTextProperty"); } #endif if(prop != 0) { switch(mRenderTool->GetFontType()) { case TextType::Arial: { prop->SetFontFamilyToArial(); mFontFactor = 1.0; break; } case TextType::Courier: { prop->SetFontFamilyToCourier(); mFontFactor = 1.2; break; } case TextType::Times: { prop->SetFontFamilyToTimes(); mFontFactor = 1.0; break; } } prop->ItalicOff(); prop->ShadowOn(); prop->SetColor(this->GetColor(vp).ToVTK()); } } ifrit-4.1.2/core/ioverlayhelper.h0000674060175406010010000000505612641012527015355 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A helper class for all 2D objects; includes basic functionality for working under // magnification. // #ifndef IOVERLAYHELPER_H #define IOVERLAYHELPER_H #include #include "icolor.h" #include "ipointermacro.h" #include class iRenderTool; class vtkCamera; class vtkProperty2D; class vtkTextProperty; class vtkViewport; class iOverlayHelper : public vtkObjectBase { IPOINTER_AS_PART(RenderTool); public: vtkTypeMacro(iOverlayHelper,vtkObjectBase); static iOverlayHelper* New(iRenderTool *rv = 0); int GetFontSize(vtkViewport *vp, float factor = 1.0f) const; void UpdateTextProperty(vtkViewport *vp, vtkTextProperty *prop); vtkCamera* GetCamera(vtkViewport *viewport) const; int GetRenderingMagnification() const; void ComputePositionShiftsUnderMagnification(int winij[2]); void SetFixedColor(const iColor &c){ mFixedColor = c; } inline const iColor& GetFixedColor() const { return mFixedColor; } const iColor& GetColor(vtkViewport* viewport); void SetAutoColor(bool s){ mIsAutoColor = s; } inline bool IsAutoColor() const { return mIsAutoColor; } protected: virtual ~iOverlayHelper(); private: iOverlayHelper(iRenderTool *rv); iColor mFixedColor; bool mIsAutoColor; float mFontFactor; // // Work variable // iColor wColor; }; #endif // IOVERLAYHELPER_H ifrit-4.1.2/core/ipaintedviewsubject.cpp0000674060175406010010000001171112641012557016724 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ipaintedviewsubject.h" #include "iactor.h" #include "icolorbar.h" #include "idatalimits.h" #include "idatareader.h" #include "ierror.h" #include "ilookuptable.h" #include "ipalette.h" #include "ipalettecollection.h" #include "iviewmodule.h" // // Templates (needed for some compilers) // #include "iarray.tlh" #include "iproperty.tlh" using namespace iParameter; // // Single instance class // iPaintedViewInstance::iPaintedViewInstance(iPaintedViewSubject *owner, int numactors, float maxopacity, int numpaintedactors, int priority, bool alwayspainted) : iActorViewInstance(owner,numactors,maxopacity), mNumPaintedActors((numactorsSetScalarVisibility(alwayspainted); mActors[i]->GetLookupTable()->SetPaletteId(mPalette); mActors[i]->ColorByArrayComponent(0,0); } } iPaintedViewInstance::~iPaintedViewInstance() { } iPaintedViewSubject* iPaintedViewInstance::Owner() const { return iRequiredCast(INFO,this->iActorViewInstance::Owner()); } void iPaintedViewInstance::UpdateColorBars() { if(mColorBars.Size()==0 && this->IsPainted()) { this->AddColorBar(mColorBarPriority,mPaintVar,mPalette,this->GetPaintingLimits()->GetDataType()); } } bool iPaintedViewInstance::SetPaintVar(int v) { if(v<-1 || v>=this->GetPaintingLimits()->GetNumVars()) return false; if(v != mPaintVar) { this->RemoveColorBars(); mPaintVar = v; this->UpdateColorBars(); this->UpdatePainting(); this->Owner()->UpdateAutomaticShading(); if(mAlwaysPainted && v==-1) { this->Show(false); } } return true; } bool iPaintedViewInstance::SetPalette(int pid) { if(abs(pid) > iPaletteCollection::Global()->Size()) return false; this->RemoveColorBars(); mPalette = pid; this->UpdateColorBars(); int i; for(i=0; iGetLookupTable()->SetPaletteId(pid); } return true; } void iPaintedViewInstance::UpdatePainting() { int i; if(this->IsPainted()) { for(i=0; iSyncWithLimits(this->GetPaintingLimits(),mPaintVar); mActors[i]->ColorByArrayComponent(0,mPaintVar+mPaintOffset); mActors[i]->SetScalarVisibility(true); } } else { for(i=0; iSetScalarVisibility(false); } if(mAlwaysPainted) this->Show(false); } } bool iPaintedViewInstance::IsPainted() const { return (this->IsConnectedToPaintingData() && mPaintVar>=0 && mPaintVarGetPaintingLimits()->GetNumVars()); } bool iPaintedViewInstance::SyncWithDataBody() { if(mPaintVar >= this->GetPaintingLimits()->GetNumVars()) { this->SetPaintVar(-1); } this->UpdatePainting(); return true; } bool iPaintedViewInstance::SyncWithLimitsBody(int var, int mode) { if(var == mPaintVar) { this->UpdatePainting(); } return true; } iDataLimits* iPaintedViewInstance::GetPaintingLimits() const { iDataLimits *lim = this->GetViewModule()->GetReader()->GetLimits(this->Owner()->GetPaintingDataType()); IASSERT(lim); return lim; } iPaintedViewSubject::iPaintedViewSubject(iObject *parent, const iString &fname, const iString &sname, iViewModule *vm, const iDataType &type, const iDataType &pdt, unsigned int flags, int minsize, int maxsize) : iActorViewSubject(parent,fname,sname,vm,type,flags,minsize,maxsize), mPaintingDataType(pdt), iViewSubjectPropertyConstructMacro(Int,iPaintedViewInstance,Palette,p), iViewSubjectPropertyConstructMacro(Int,iPaintedViewInstance,PaintVar,pv) { PaintVar.AddFlag(iProperty::_FunctionsAsIndex); } iPaintedViewSubject::~iPaintedViewSubject() { } ifrit-4.1.2/core/ipaintedviewsubject.h0000674060175406010010000000541312641012527016370 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPAINTEDVIEWSUBJECT_H #define IPAINTEDVIEWSUBJECT_H #include "iactorviewsubject.h" class iDataLimits; class iPaintedViewSubject; class iPaintedViewInstance : public iActorViewInstance { friend class iPaintedViewSubject; public: iDataConsumerTypeMacro(iPaintedViewInstance,iActorViewInstance); iObjectSlotMacro1SV(Palette,int); iObjectSlotMacro1SV(PaintVar,int); protected: iPaintedViewInstance(iPaintedViewSubject *owner, int numactors, float maxopacity, int numpaintedactors, int priority, bool alwayspainted); virtual ~iPaintedViewInstance(); iPaintedViewSubject* Owner() const; virtual void UpdatePainting(); virtual void UpdateColorBars(); virtual bool IsPainted() const; virtual iDataLimits* GetPaintingLimits() const; virtual bool SyncWithLimitsBody(int var, int mode); virtual bool IsConnectedToPaintingData() const = 0; int mPaintOffset; private: const int mNumPaintedActors, mColorBarPriority; const bool mAlwaysPainted; }; class iPaintedViewSubject : public iActorViewSubject { public: iDataConsumerTypeMacroPass(iPaintedViewSubject,iActorViewSubject); iType::vsp_int Palette; iType::vsp_int PaintVar; const iDataType& GetPaintingDataType() const { return mPaintingDataType; } protected: iPaintedViewSubject(iObject *parent, const iString &fname, const iString &sname, iViewModule *vm, const iDataType &type, const iDataType &pdt, unsigned int flags, int minsize, int maxsize); virtual ~iPaintedViewSubject(); const iDataType &mPaintingDataType; }; #endif // IPAINTEDVIEWSUBJECT_H ifrit-4.1.2/core/ipair.h0000674060175406010010000000401512641012527013421 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPAIR_H #define IPAIR_H // // A first-value-ordered pair of values for various uses // struct iPair { union { float X; float Min; }; union { float Y; float Max; }; iPair(float x = 0.0, float y = 0.0) { X = x; Y = y; } iPair(const iPair &p) { X = p.X; Y = p.Y; } void operator=(const iPair &p) { X = p.X; Y = p.Y; } bool operator==(const iPair &p) const { return (X == p.X); } inline float operator[](int i) const { return (i==0) ? X : Y; } inline float& operator[](int i) { return (i==0) ? X : Y; } }; struct iOrderedPair : public iPair { iOrderedPair(float x = 0.0, float y = 0.0) : iPair(x,y){} iOrderedPair(const iPair &p) : iPair(p){} bool operator<(const iOrderedPair &p) const { return (X < p.X); } }; #endif // IPAIR_H ifrit-4.1.2/core/ipalette.cpp0000674060175406010010000001462012641012557014465 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ipalette.h" #include "ierror.h" #include "iimage.h" #include "imath.h" //#include "ipalettecollection.h" #include "ipiecewisefunction.h" #include #include // // Templates // #include "iarray.tlh" #include "iproperty.tlh" // // Implementation of iPalette class // iPalette::iPalette(iObject *parent, const iString &fname, const iString &sname) : iObject(parent,fname,sname), Name(iObject::Self(),static_cast(&iPalette::SetName),static_cast(&iPalette::GetName),"Name","n",4), Red(iObject::Self(),"Red","r",3), Green(iObject::Self(),"Green","g",2), Blue(iObject::Self(),"Blue","b",1) { mRenderMode = iParameter::RenderMode::All; mName = "unnamed"; mRed = iPiecewiseFunction::New(); IERROR_CHECK_MEMORY(mRed); mGreen = iPiecewiseFunction::New(); IERROR_CHECK_MEMORY(mGreen); mBlue = iPiecewiseFunction::New(); IERROR_CHECK_MEMORY(mBlue); Red.AttachFunction(mRed); Green.AttachFunction(mGreen); Blue.AttachFunction(mBlue); mCTF[0] = vtkColorTransferFunction::New(); IERROR_CHECK_MEMORY(mCTF[0]); mCTF[1] = vtkColorTransferFunction::New(); IERROR_CHECK_MEMORY(mCTF[1]); mLT[0] = vtkLookupTable::New(); IERROR_CHECK_MEMORY(mLT[0]); mLT[1] = vtkLookupTable::New(); IERROR_CHECK_MEMORY(mLT[1]); mCTF[0]->SetColorSpaceToRGB(); mCTF[1]->SetColorSpaceToRGB(); mLT[0]->SetNumberOfTableValues(256); mLT[1]->SetNumberOfTableValues(256); // // Image representation // mImage[0] = new iImage(3); IERROR_CHECK_MEMORY(mImage[0]); mImage[1] = new iImage(3); IERROR_CHECK_MEMORY(mImage[1]); mImage[2] = new iImage(3); IERROR_CHECK_MEMORY(mImage[2]); mImageNeedsUpdate = true; mImageWidth = 256; mImageHeight = 32; } iPalette::~iPalette() { delete mImage[2]; delete mImage[1]; delete mImage[0]; mCTF[0]->Delete(); mCTF[1]->Delete(); mLT[0]->Delete(); mLT[1]->Delete(); mRed->Delete(); mGreen->Delete(); mBlue->Delete(); } bool iPalette::SetName(const iString& s) { mName = s; return true; } void iPalette::SetComponents(const iPiecewiseFunction *r, const iPiecewiseFunction *g, const iPiecewiseFunction *b) { if(r != 0) mRed->Copy(r); if(g != 0) mGreen->Copy(g); if(b != 0) mBlue->Copy(b); this->Update(); } iPiecewiseFunction* iPalette::GetComponent(int n) const { switch(n) { case 0: return mRed; case 1: return mGreen; case 2: return mBlue; default: return 0; } } iColor iPalette::GetColor(int n) const { n = ( n < 0 ) ? 0 : n; n = ( n > 255 ) ? 255 : n; float x = float(n)/255.0; float r = mRed->GetValue(x); float g = mGreen->GetValue(x); float b = mBlue->GetValue(x); return iColor(iMath::Round2Int(255.0*r),iMath::Round2Int(255.0*g),iMath::Round2Int(255.0*b)); } void iPalette::Update() { int i, ir, ig, ib; float x; // // Update vtkColorTransferFunction // mCTF[0]->RemoveAllPoints(); mCTF[1]->RemoveAllPoints(); ir = ig = ib = 0; while(irN() && igN() && ibN()) { x = mRed->X(ir); if(x > mGreen->X(ig)) x = mGreen->X(ig); if(x > mBlue->X(ib)) x = mBlue->X(ib); mCTF[0]->AddRGBPoint(255.0*x,mRed->GetValue(x),mGreen->GetValue(x),mBlue->GetValue(x)); mCTF[1]->AddRGBPoint(255.0*(1.0-x),mRed->GetValue(x),mGreen->GetValue(x),mBlue->GetValue(x)); if(fabs(x-mRed->X(ir)) < 1.0e-4) ir++; if(fabs(x-mGreen->X(ig)) < 1.0e-4) ig++; if(fabs(x-mBlue->X(ib)) < 1.0e-4) ib++; } // // Update vtkLookupTable // for(i=0; i<256; i++) { x = float(i)/255.0; mLT[0]->SetTableValue(i,mRed->GetValue(x),mGreen->GetValue(x),mBlue->GetValue(x)); mLT[1]->SetTableValue(255-i,mRed->GetValue(x),mGreen->GetValue(x),mBlue->GetValue(x)); } mImageNeedsUpdate = true; } bool iPalette::CopyState(const iObject *other) { const iPalette *p = dynamic_cast(other); if(p == 0) return false; mRed->Copy(p->mRed); mGreen->Copy(p->mGreen); mBlue->Copy(p->mBlue); this->SetName(p->GetName()); this->Update(); return true; } const iImage* iPalette::GetImage(int shape) { if(shape<0 || shape>2) return 0; if(mImageNeedsUpdate) { mImageNeedsUpdate = false; // // Update the image // mImage[0]->Scale(mImageWidth,mImageHeight); mImage[1]->Scale(mImageHeight,mImageWidth); mImage[2]->Scale(mImageHeight,mImageWidth); unsigned char *dPtr0 = mImage[0]->DataPointer(); unsigned char *dPtr1 = mImage[1]->DataPointer(); unsigned char *dPtr2 = mImage[2]->DataPointer(); int i, j, ir; float x; unsigned char r, g, b; for(i=0; iGetValue(x))); g = char(iMath::Round2Int(255.0*mGreen->GetValue(x))); b = char(iMath::Round2Int(255.0*mBlue->GetValue(x))); dPtr0[0+3*i] = r; dPtr0[1+3*i] = g; dPtr0[2+3*i] = b; for(j=0; j #include // // templates // #include "iarray.tlh" #include "iobjectcollection.tlh" #include "iproperty.tlh" iPaletteCollection* iPaletteCollection::mGlobal = 0; // // Helper functions hidden in a private namespace // namespace iPaletteCollection_Private { int Decode(int id, bool &r) { if(id < 0) { r = true; return -id - 1; } else { r = false; return id - 1; } } }; using namespace iPaletteCollection_Private; // // Main class // iPaletteCollection* iPaletteCollection::New(iShell *s) { static iString LongName("Palette"); static iString ShortName("pal"); IASSERT(s); iPaletteCollection *tmp = new iPaletteCollection(s,LongName,ShortName); tmp->CreateDefaultPalettes(); if(mGlobal == 0) mGlobal = tmp; return tmp; } iPaletteCollection::iPaletteCollection(iShell *s, const iString &fname, const iString &sname) : iObjectCollectionFixed(s,fname,sname,0), iShellComponent(s), Create(iObject::Self(),static_cast(&iPaletteCollection::CreateMember),"New","new") { mRenderMode = iParameter::RenderMode::NoRender; } iPaletteCollection::~iPaletteCollection() { mGlobal = 0; } iPalette* iPaletteCollection::NewObject() { return new iPalette(this,this->LongName(),this->ShortName()); } iPalette* iPaletteCollection::GetPalette(int n) const { return iRequiredCast(INFO,this->GetMember(n)); } vtkImageData* iPaletteCollection::GetImageData(int id) const { bool r; int n = Decode(id,r); if(n>=0 && nSize()) { const iImage *im = this->GetPalette(n)->GetImage(r?2:1); if(im == 0) return 0; return im->DataObject(); } else return 0; } vtkLookupTable* iPaletteCollection::GetLookupTable(int id) const { bool r; int n = Decode(id,r); if(n>=0 && nSize()) return this->GetPalette(n)->GetLookupTable(r); else return 0; } vtkColorTransferFunction* iPaletteCollection::GetColorTransferFunction(int id) const { bool r; int n = Decode(id,r); if(n>=0 && nSize()) return this->GetPalette(n)->GetColorTransferFunction(r); else return 0; } void iPaletteCollection::WritePaletteImages(iShell *s, const iString& dirname) { int i; iString fname; vtkPNGWriter *w = vtkPNGWriter::New(); IERROR_CHECK_MEMORY(w); iPaletteCollection *c = iPaletteCollection::New(s); IERROR_CHECK_MEMORY(c); for(i=0; iSize(); i++) { vtkImageData *im = vtkImageData::SafeDownCast(c->GetPalette(i)->GetImage()->DataObject()); IERROR_CHECK_MEMORY(im); fname = dirname + "/pal_" + c->GetPalette(i)->GetName() + ".png"; fname.Replace(" ",""); fname.Replace("-",""); w->SetFileName(fname.ToCharPointer()); w->SetInputData(im); w->Write(); } c->Delete(); w->Delete(); } void iPaletteCollection::CreateDefaultPalettes() { iPalette* tmp; iPiecewiseFunction *r, *g, *b; if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Rainbow"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,0.0); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.1); r->MovePoint(1,1.0,1.0); g->MovePoint(1,1.0,0.9); b->MovePoint(1,1.0,0.9); r->AddPoint(1.0/6.0,0.0); g->AddPoint(1.0/6.0,0.0); b->AddPoint(1.0/6.0,1.0); r->AddPoint(2.0/6.0,0.0); g->AddPoint(2.0/6.0,1.0); b->AddPoint(2.0/6.0,1.0); r->AddPoint(3.0/6.0,0.0); g->AddPoint(3.0/6.0,1.0); b->AddPoint(3.0/6.0,0.0); r->AddPoint(4.0/6.0,1.0); g->AddPoint(4.0/6.0,1.0); b->AddPoint(4.0/6.0,0.0); r->AddPoint(5.0/6.0,1.0); g->AddPoint(5.0/6.0,0.0); b->AddPoint(5.0/6.0,0.0); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Isolum"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,90.0/255); g->MovePoint(0,0.0,190.0/255); b->MovePoint(0,0.0,245.0/255); r->MovePoint(1,1.0,180.0/255); g->MovePoint(1,1.0,180.0/255); b->MovePoint(1,1.0,0); r->AddPoint(0.25,157.0/255); g->AddPoint(0.25,157.0/255); b->AddPoint(0.25,200.0/255); r->AddPoint(0.50,220.0/255); g->AddPoint(0.50,150.0/255); b->AddPoint(0.50,130.0/255); r->AddPoint(0.67,245.0/255); g->AddPoint(0.67,120.0/255); b->AddPoint(0.67, 80.0/255); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Ametrine"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,30.0/255); g->MovePoint(0,0.0,60.0/255); b->MovePoint(0,0.0,150.0/255); r->MovePoint(1,1.0,220.0/255); g->MovePoint(1,1.0,220.0/255); b->MovePoint(1,1.0,0); r->AddPoint(0.27,180.0/255); g->AddPoint(0.27,90.0/255); b->AddPoint(0.27,155.0/255); r->AddPoint(0.50,230.0/255); g->AddPoint(0.50,85.0/255); b->AddPoint(0.50,65.0/255); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Temperature"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,0.3); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.0); r->MovePoint(1,1.0,1.0); g->MovePoint(1,1.0,0.8); b->MovePoint(1,1.0,0.8); r->AddPoint(0.7,1.0); g->AddPoint(0.6,0.0); b->AddPoint(0.8,0.0); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Greyscale"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,0.0); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.0); r->MovePoint(1,1.0,1.0); g->MovePoint(1,1.0,1.0); b->MovePoint(1,1.0,1.0); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Blue-white"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,0.0); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.1); r->MovePoint(1,1.0,0.9); g->MovePoint(1,1.0,0.9); b->MovePoint(1,1.0,1.0); r->AddPoint(0.75,0.0); g->AddPoint(0.38,0.0); b->AddPoint(0.78,1.0); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Prizm"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,0.0); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.0); r->MovePoint(1,1.0,0.0); g->MovePoint(1,1.0,0.0); b->MovePoint(1,1.0,0.0); r->AddPoint(0.25,1.0); g->AddPoint(0.25,0.0); b->AddPoint(0.25,0.0); r->AddPoint(0.50,0.0); g->AddPoint(0.50,1.0); b->AddPoint(0.50,0.0); r->AddPoint(0.75,0.0); g->AddPoint(0.75,0.0); b->AddPoint(0.75,1.0); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Green-white"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,0.0); g->MovePoint(0,0.0,0.1); b->MovePoint(0,0.0,0.0); r->MovePoint(1,1.0,1.0); g->MovePoint(1,1.0,1.0); b->MovePoint(1,1.0,1.0); r->AddPoint(0.375,0.0); b->AddPoint(0.750,0.0); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Blue-red"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,0.0); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.0); r->MovePoint(1,1.0,1.0); g->MovePoint(1,1.0,0.0); b->MovePoint(1,1.0,0.0); r->AddPoint(0.25,0.0); g->AddPoint(0.25,1.0); b->AddPoint(0.25,1.0); r->AddPoint(0.5,0.0); g->AddPoint(0.5,0.0); b->AddPoint(0.5,1.0); r->AddPoint(0.75,1.0); g->AddPoint(0.75,0.0); b->AddPoint(0.75,1.0); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Stern"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,0.0); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.0); r->MovePoint(1,1.0,1.0); g->MovePoint(1,1.0,1.0); b->MovePoint(1,1.0,1.0); r->AddPoint(0.05,1.0); r->AddPoint(0.25,0.0); b->AddPoint(0.50,1.0); b->AddPoint(0.75,0.0); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Haze"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,1.0); g->MovePoint(0,0.0,0.8); b->MovePoint(0,0.0,1.0); r->MovePoint(1,1.0,1.0); g->MovePoint(1,1.0,0.8); b->MovePoint(1,1.0,0.0); r->AddPoint(0.5,0.0); g->AddPoint(0.5,0.1); b->AddPoint(0.5,0.5); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("Starlight"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,0.5); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.0); r->MovePoint(1,1.0,1.0); g->MovePoint(1,1.0,1.0); b->MovePoint(1,1.0,0.7); r->AddPoint(0.5,0.9); g->AddPoint(0.5,0.7); b->AddPoint(0.5,0.2); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("2 color"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,1.0); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.0); r->MovePoint(1,1.0,0.0); g->MovePoint(1,1.0,0.0); b->MovePoint(1,1.0,1.0); r->AddPoint(0.4999,1.0); g->AddPoint(0.4999,0.0); b->AddPoint(0.4999,0.0); r->AddPoint(0.5001,0.0); g->AddPoint(0.5001,0.0); b->AddPoint(0.5001,1.0); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("3 color"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,1.0); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.0); r->MovePoint(1,1.0,0.0); g->MovePoint(1,1.0,0.0); b->MovePoint(1,1.0,1.0); r->AddPoint(0.3332,1.0); g->AddPoint(0.3332,0.0); b->AddPoint(0.3332,0.0); r->AddPoint(0.3334,0.0); g->AddPoint(0.3334,1.0); b->AddPoint(0.3334,0.0); r->AddPoint(0.6665,0.0); g->AddPoint(0.6665,1.0); b->AddPoint(0.6665,0.0); r->AddPoint(0.6667,0.0); g->AddPoint(0.6667,0.0); b->AddPoint(0.6667,1.0); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("4 color"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,1.0); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.0); r->MovePoint(1,1.0,0.0); g->MovePoint(1,1.0,0.0); b->MovePoint(1,1.0,1.0); r->AddPoint(0.2499,1.0); g->AddPoint(0.2499,0.0); b->AddPoint(0.2499,0.0); r->AddPoint(0.2501,1.0); g->AddPoint(0.2501,1.0); b->AddPoint(0.2501,0.0); r->AddPoint(0.4999,1.0); g->AddPoint(0.4999,1.0); b->AddPoint(0.4999,0.0); r->AddPoint(0.5001,0.0); g->AddPoint(0.5001,1.0); b->AddPoint(0.5001,0.0); r->AddPoint(0.7499,0.0); g->AddPoint(0.7499,1.0); b->AddPoint(0.7499,0.0); r->AddPoint(0.7501,0.0); g->AddPoint(0.7501,0.0); b->AddPoint(0.7501,1.0); tmp->Update(); } if(this->CreateMember()) { tmp = this->GetPalette(mChildren.MaxIndex()); tmp->SetName("8 color"); r = tmp->mRed; g = tmp->mGreen; b = tmp->mBlue; r->MovePoint(0,0.0,1.0); g->MovePoint(0,0.0,0.0); b->MovePoint(0,0.0,0.0); r->MovePoint(1,1.0,1.0); g->MovePoint(1,1.0,0.0); b->MovePoint(1,1.0,1.0); r->AddPoint(0.1249,1.0); g->AddPoint(0.1249,0.0); b->AddPoint(0.1249,0.0); r->AddPoint(0.1251,1.0); g->AddPoint(0.1251,0.5); b->AddPoint(0.1251,0.0); r->AddPoint(0.2499,1.0); g->AddPoint(0.2499,0.5); b->AddPoint(0.2499,0.0); r->AddPoint(0.2501,1.0); g->AddPoint(0.2501,1.0); b->AddPoint(0.2501,0.0); r->AddPoint(0.3749,1.0); g->AddPoint(0.3749,1.0); b->AddPoint(0.3749,0.0); r->AddPoint(0.3751,0.0); g->AddPoint(0.3751,1.0); b->AddPoint(0.3751,0.0); r->AddPoint(0.4999,0.0); g->AddPoint(0.4999,1.0); b->AddPoint(0.4999,0.0); r->AddPoint(0.5001,0.0); g->AddPoint(0.5001,1.0); b->AddPoint(0.5001,1.0); r->AddPoint(0.6249,0.0); g->AddPoint(0.6249,1.0); b->AddPoint(0.6249,1.0); r->AddPoint(0.6251,0.0); g->AddPoint(0.6251,0.5); b->AddPoint(0.6251,1.0); r->AddPoint(0.7499,0.0); g->AddPoint(0.7499,0.5); b->AddPoint(0.7499,1.0); r->AddPoint(0.7501,0.0); g->AddPoint(0.7501,0.0); b->AddPoint(0.7501,1.0); r->AddPoint(0.8749,0.0); g->AddPoint(0.8749,0.0); b->AddPoint(0.8749,1.0); r->AddPoint(0.8751,1.0); g->AddPoint(0.8751,0.0); b->AddPoint(0.8751,1.0); tmp->Update(); } } ifrit-4.1.2/core/ipalettecollection.h0000775060175406010010000000463612641012527016213 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPALETTECOLLECTION_H #define IPALETTECOLLECTION_H #include "iobjectcollection.h" #include "ipalette.h" #include "ishellcomponent.h" class vtkColorTransferFunction; class vtkImageData; class vtkLookupTable; // // We inherit from iObject to get access to state saving // class iPaletteCollection : public iObjectCollectionFixed, public iShellComponent { friend class iShell; public: vtkTypeMacro(iPaletteCollection,iObjectCollectionFixed); static iPaletteCollection* New(iShell *s = 0); iPropertyAction Create; // // Global set, available everywhere // static const iPaletteCollection* Global(){ return mGlobal; } iPalette* GetPalette(int n) const; vtkImageData* GetImageData(int id) const; vtkLookupTable* GetLookupTable(int id) const; vtkColorTransferFunction* GetColorTransferFunction(int id) const; protected: virtual ~iPaletteCollection(); virtual iPalette* NewObject(); private: iPaletteCollection(iShell *s, const iString &fname, const iString &sname); void CreateDefaultPalettes(); static void WritePaletteImages(iShell *s, const iString& dirname); static iPaletteCollection* mGlobal; }; #endif // IPALETTECOLLECTION_H ifrit-4.1.2/core/iparallel.cpp0000674060175406010010000000247112641012557014624 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparallel.h" // // A placeholder for future additions // ifrit-4.1.2/core/iparallel.h0000674060175406010010000000360512641012530014260 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPARALLEL_H #define IPARALLEL_H // // Misc parallelization tools // namespace iParallel { const unsigned long InformationEvent = 1001; struct ProcessorInfo { int NumProcs; int ThisProc; ProcessorInfo(){ ThisProc = 0; NumProcs = 1; } // Must initialize to serial state!!! inline bool IsMaster() const { return (ThisProc == 0); } }; // // Helpers // template inline void SplitRange(ProcessorInfo &p, T n, T &lbeg, T &lend, T &lstp) { lstp = (n+p.NumProcs-1)/p.NumProcs; lbeg = lstp*p.ThisProc; lend = lbeg + lstp; if(p.ThisProc+1 == p.NumProcs) { lend = n; lstp = lend - lbeg; } } }; #endif // IPARALLEL_H ifrit-4.1.2/core/iparallelfft.cpp0000674060175406010010000063210312641012560015317 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparallelfft.h" #include "ierror.h" #include "imath.h" #include "iparallel.h" #include "iparallelmanager.h" #include "ishell.h" #include "ishelleventobservers.h" namespace iParallelFFT_Private { int rffti1_(int *n, float *wa, int *ifac); int rfftf1_(int *n, float *c, float *ch, float *wa, int *ifac); int rfftb1_(int *n, float *c, float *ch, float *wa, int *ifac); int cffti1_(int *n, float *wa, int *ifac); int cfftf1_(int *n, float *c, float *ch, float *wa, int *ifac); int cfftb1_(int *n, float *c, float *ch, float *wa, int *ifac); }; using namespace iParallelFFT_Private; iParallelFFT* iParallelFFT::New(iParallelManager *pp) { return new iParallelFFT(pp); } iParallelFFT::iParallelFFT(iParallelManager *pp) : iParallelWorker(pp) { mProg = mProgStart = mProgScale = 0.0; mWork1 = mWork2 = mWork3 = mW1 = mZ1 = 0; mNumProcs = mN12 = mN1 = mN2 = mN3 = 0; } iParallelFFT::~iParallelFFT() { if(mWork1 != 0) delete [] mWork1; if(mWork2 != 0) delete [] mWork2; if(mWork3 != 0) delete [] mWork3; if(mW1 != 0) delete [] mW1; if(mZ1 != 0) delete [] mZ1; } int iParallelFFT::Transform(bool forward, int comp, int ncomp, int nn1, int nn2, int nn3, float *data1, float *dnyq1) { if(ncomp<1 || comp<0 || comp>=ncomp || nn1<2 || nn2<1 || nn3<1 || data1==0 || dnyq1==0) return -1; // // Create/update temp. storage // int nProcs1 = this->GetManager()->GetNumberOfProcessors(); if(mWork1==0 || nn1>mN1 || nn2>mN2 || nn3>mN3 || nProcs1>mNumProcs) { if(mWork1 != 0) delete [] mWork1; if(mWork2 != 0) delete [] mWork2; if(mWork3 != 0) delete [] mWork3; if(mW1 != 0) delete [] mW1; if(mZ1 != 0) delete [] mZ1; int nmax = nn1; if(nmax < nn2) nmax = nn2; if(nmax < nn3) nmax = nn3; mWork1 = new float[1*nn1+15]; IERROR_CHECK_MEMORY(mWork1); mWork2 = new float[2*nn2+15]; IERROR_CHECK_MEMORY(mWork2); mWork3 = new float[2*nn3+15]; IERROR_CHECK_MEMORY(mWork3); mZ1 = new float[nmax*nProcs1*2]; IERROR_CHECK_MEMORY(mZ1); mW1 = new float[nmax*nProcs1*2]; IERROR_CHECK_MEMORY(mW1); // workspace for parallelization } if(mN1 != nn1) rffti1_(&nn1,mWork1,(int *)(mWork1+1*nn1)); if(mN2!=nn2 && nn2>1) cffti1_(&nn2,mWork2,(int *)(mWork2+2*nn2)); if(mN3!=nn3 && nn3>1) cffti1_(&nn3,mWork3,(int *)(mWork3+2*nn3)); mNC = ncomp; mN1 = nn1; mN2 = nn2; mN3 = nn3; mNumProcs = nProcs1; mData = data1 + comp; mDnyq = dnyq1; if(mN1%2 == 0) mN12 = mN1/2; else mN12 = (mN1-1)/2; int kstp = (mN3+mNumProcs-1)/mNumProcs; int jstp = (mN2+mNumProcs-1)/mNumProcs; mProg = 0.0; mProgStart = 0.0; mProgScale = 1.0/(2*kstp+jstp); int ret; if(forward) { ret = this->ParallelExecute(1); if(ret==0 && mN2>1) ret = this->ParallelExecute(2); if(ret==0 && mN3>1) ret = this->ParallelExecute(3); } else { ret = 0; if(ret==0 && mN3>1) ret = this->ParallelExecute(-3); if(ret==0 && mN2>1) ret = this->ParallelExecute(-2); ret = this->ParallelExecute(-1); } return ret; } int iParallelFFT::ExecuteStep(int step, iParallel::ProcessorInfo &p) { if(mNumProcs != p.NumProcs) return 3; switch(step) { case 1: { this->ExecuteForwardTransform1(p); return 0; } case 2: { this->ExecuteForwardTransform2(p); return 0; } case 3: { this->ExecuteForwardTransform3(p); return 0; } case -3: { this->ExecuteInverseTransform3(p); return 0; } case -2: { this->ExecuteInverseTransform2(p); return 0; } case -1: { this->ExecuteInverseTransform1(p); return 0; } default: { return 2; } } } void iParallelFFT::ExecuteForwardTransform1(iParallel::ProcessorInfo &p) { int i, j, k; long lc, lf; float *w, *z; // // X - direction // int kbeg, kend, kstp; iParallel::SplitRange(p,mN3,kbeg,kend,kstp); w = mW1 + mN1*p.ThisProc; z = mZ1 + mN1*p.ThisProc; for(k=kbeg; kGetManager()->GetShell()->GetExecutionEventObserver()->SetProgress(mProgStart+mProgScale*mProg); } if(this->GetManager()->GetShell()->GetExecutionEventObserver()->IsAborted()) return; for(j=0; jGetManager()->GetShell()->GetExecutionEventObserver()->SetProgress(mProgStart+mProgScale*mProg); } if(this->GetManager()->GetShell()->GetExecutionEventObserver()->IsAborted()) return; for(i=0; iGetManager()->GetShell()->GetExecutionEventObserver()->SetProgress(mProgStart+mProgScale*mProg); } if(this->GetManager()->GetShell()->GetExecutionEventObserver()->IsAborted()) return; for(i=0; iGetManager()->GetShell()->GetExecutionEventObserver()->SetProgress(mProgStart+mProgScale*mProg); } if(this->GetManager()->GetShell()->GetExecutionEventObserver()->IsAborted()) return; for(i=0; iGetManager()->GetShell()->GetExecutionEventObserver()->SetProgress(mProgStart+mProgScale*mProg); } if(this->GetManager()->GetShell()->GetExecutionEventObserver()->IsAborted()) return; for(i=0; iGetManager()->GetShell()->GetExecutionEventObserver()->SetProgress(mProgStart+mProgScale*mProg); } if(this->GetManager()->GetShell()->GetExecutionEventObserver()->IsAborted()) return; for(j=0; j= 0 ? (x) : -(x)) #define dabs(x) (doublereal)abs(x) #ifndef min #define min(a,b) ((a) <= (b) ? (a) : (b)) #endif #ifndef max #define max(a,b) ((a) >= (b) ? (a) : (b)) #endif #define dmin(a,b) (doublereal)min(a,b) #define dmax(a,b) (doublereal)max(a,b) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_Set(a,b) ((a) | ((uinteger)1 << (b))) /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef int /* Unknown procedure type */ (*U_fp)(...); typedef shortint (*J_fp)(...); typedef integer (*I_fp)(...); typedef real (*R_fp)(...); typedef doublereal (*D_fp)(...), (*E_fp)(...); typedef /* Complex */ VOID (*C_fp)(...); typedef /* Double Complex */ VOID (*Z_fp)(...); typedef logical (*L_fp)(...); typedef shortlogical (*K_fp)(...); typedef /* Character */ VOID (*H_fp)(...); typedef /* Subroutine */ int (*S_fp)(...); #else typedef int /* Unknown procedure type */ (*U_fp)(); typedef shortint (*J_fp)(); typedef integer (*I_fp)(); typedef real (*R_fp)(); typedef doublereal (*D_fp)(), (*E_fp)(); typedef /* Complex */ VOID (*C_fp)(); typedef /* Double Complex */ VOID (*Z_fp)(); typedef logical (*L_fp)(); typedef shortlogical (*K_fp)(); typedef /* Character */ VOID (*H_fp)(); typedef /* Subroutine */ int (*S_fp)(); #endif /* E_fp is for real functions when -R is not specified */ typedef VOID C_f; /* complex function */ typedef VOID H_f; /* character function */ typedef VOID Z_f; /* double complex function */ typedef doublereal E_f; /* real function with -R not specified */ /* undef any lower-case symbols that your C compiler predefines, e.g.: */ #ifndef Skip_f2c_Undefs #undef cray #undef gcos #undef mc68010 #undef mc68020 #undef mips #undef pdp11 #undef sgi #undef sparc #undef sun #undef sun2 #undef sun3 #undef sun4 #undef u370 #undef u3b #undef u3b2 #undef u3b5 #undef unix #undef vax #endif #endif /* Subroutine */ int cfftb1_(int *n, float *c__, float *ch, float *wa, int *ifac) { /* System generated locals */ integer i__1; /* Local variables */ integer i__, k1, l1, l2, n2, na, nf, ip, iw, ix2, ix3, ix4, nac, ido, idl1, idot; extern /* Subroutine */ int passb_(integer *, integer *, integer *, integer *, integer *, real *, real *, real *, real *, real *, real *), passb2_(integer *, integer *, real *, real *, real *), passb3_(integer *, integer *, real *, real *, real *, real *), passb4_(integer *, integer *, real *, real *, real *, real *, real *), passb5_(integer *, integer *, real *, real *, real *, real *, real *, real *); /* Parameter adjustments */ --ifac; --wa; --ch; --c__; /* Function Body */ nf = ifac[2]; na = 0; l1 = 1; iw = 1; i__1 = nf; for (k1 = 1; k1 <= i__1; ++k1) { ip = ifac[k1 + 2]; l2 = ip * l1; ido = *n / l2; idot = ido + ido; idl1 = idot * l1; if (ip != 4) { goto L103; } ix2 = iw + idot; ix3 = ix2 + idot; if (na != 0) { goto L101; } passb4_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3]); goto L102; L101: passb4_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3]); L102: na = 1 - na; goto L115; L103: if (ip != 2) { goto L106; } if (na != 0) { goto L104; } passb2_(&idot, &l1, &c__[1], &ch[1], &wa[iw]); goto L105; L104: passb2_(&idot, &l1, &ch[1], &c__[1], &wa[iw]); L105: na = 1 - na; goto L115; L106: if (ip != 3) { goto L109; } ix2 = iw + idot; if (na != 0) { goto L107; } passb3_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2]); goto L108; L107: passb3_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2]); L108: na = 1 - na; goto L115; L109: if (ip != 5) { goto L112; } ix2 = iw + idot; ix3 = ix2 + idot; ix4 = ix3 + idot; if (na != 0) { goto L110; } passb5_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); goto L111; L110: passb5_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); L111: na = 1 - na; goto L115; L112: if (na != 0) { goto L113; } passb_(&nac, &idot, &ip, &l1, &idl1, &c__[1], &c__[1], &c__[1], &ch[1] , &ch[1], &wa[iw]); goto L114; L113: passb_(&nac, &idot, &ip, &l1, &idl1, &ch[1], &ch[1], &ch[1], &c__[1], &c__[1], &wa[iw]); L114: if (nac != 0) { na = 1 - na; } L115: l1 = l2; iw += (ip - 1) * idot; /* L116: */ } if (na == 0) { return 0; } n2 = *n + *n; i__1 = n2; for (i__ = 1; i__ <= i__1; ++i__) { c__[i__] = ch[i__]; /* L117: */ } return 0; } /* cfftb1_ */ /* Subroutine */ int passb_(integer *nac, integer *ido, integer *ip, integer * l1, integer *idl1, real *cc, real *c1, real *c2, real *ch, real *ch2, real *wa) { /* System generated locals */ integer ch_dim1, ch_dim2, ch_offSet, cc_dim1, cc_dim2, cc_offSet, c1_dim1, c1_dim2, c1_offSet, c2_dim1, c2_offSet, ch2_dim1, ch2_offSet, i__1, i__2, i__3; /* Local variables */ integer i__, j, k, l, jc, lc, ik, nt, idj, idl, inc, idp; real wai, war; integer ipp2, idij, idlj, idot, ipph; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; c1_dim1 = *ido; c1_dim2 = *l1; c1_offSet = 1 + c1_dim1 * (1 + c1_dim2); c1 -= c1_offSet; cc_dim1 = *ido; cc_dim2 = *ip; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; ch2_dim1 = *idl1; ch2_offSet = 1 + ch2_dim1; ch2 -= ch2_offSet; c2_dim1 = *idl1; c2_offSet = 1 + c2_dim1; c2 -= c2_offSet; --wa; /* Function Body */ idot = *ido / 2; nt = *ip * *idl1; ipp2 = *ip + 2; ipph = (*ip + 1) / 2; idp = *ip * *ido; if (*ido < *l1) { goto L106; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 1; i__ <= i__3; ++i__) { ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] + cc[i__ + (jc + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] - cc[i__ + (jc + k * cc_dim2) * cc_dim1]; /* L101: */ } /* L102: */ } /* L103: */ } i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L104: */ } /* L105: */ } goto L112; L106: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { i__3 = *l1; for (k = 1; k <= i__3; ++k) { ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] + cc[i__ + (jc + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] - cc[i__ + (jc + k * cc_dim2) * cc_dim1]; /* L107: */ } /* L108: */ } /* L109: */ } i__1 = *ido; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L110: */ } /* L111: */ } L112: idl = 2 - *ido; inc = 0; i__1 = ipph; for (l = 2; l <= i__1; ++l) { lc = ipp2 - l; idl += *ido; i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { c2[ik + l * c2_dim1] = ch2[ik + ch2_dim1] + wa[idl - 1] * ch2[ik + (ch2_dim1 << 1)]; c2[ik + lc * c2_dim1] = wa[idl] * ch2[ik + *ip * ch2_dim1]; /* L113: */ } idlj = idl; inc += *ido; i__2 = ipph; for (j = 3; j <= i__2; ++j) { jc = ipp2 - j; idlj += inc; if (idlj > idp) { idlj -= idp; } war = wa[idlj - 1]; wai = wa[idlj]; i__3 = *idl1; for (ik = 1; ik <= i__3; ++ik) { c2[ik + l * c2_dim1] += war * ch2[ik + j * ch2_dim1]; c2[ik + lc * c2_dim1] += wai * ch2[ik + jc * ch2_dim1]; /* L114: */ } /* L115: */ } /* L116: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { ch2[ik + ch2_dim1] += ch2[ik + j * ch2_dim1]; /* L117: */ } /* L118: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *idl1; for (ik = 2; ik <= i__2; ik += 2) { ch2[ik - 1 + j * ch2_dim1] = c2[ik - 1 + j * c2_dim1] - c2[ik + jc * c2_dim1]; ch2[ik - 1 + jc * ch2_dim1] = c2[ik - 1 + j * c2_dim1] + c2[ik + jc * c2_dim1]; ch2[ik + j * ch2_dim1] = c2[ik + j * c2_dim1] + c2[ik - 1 + jc * c2_dim1]; ch2[ik + jc * ch2_dim1] = c2[ik + j * c2_dim1] - c2[ik - 1 + jc * c2_dim1]; /* L119: */ } /* L120: */ } *nac = 1; if (*ido == 2) { return 0; } *nac = 0; i__1 = *idl1; for (ik = 1; ik <= i__1; ++ik) { c2[ik + c2_dim1] = ch2[ik + ch2_dim1]; /* L121: */ } i__1 = *ip; for (j = 2; j <= i__1; ++j) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { c1[(k + j * c1_dim2) * c1_dim1 + 1] = ch[(k + j * ch_dim2) * ch_dim1 + 1]; c1[(k + j * c1_dim2) * c1_dim1 + 2] = ch[(k + j * ch_dim2) * ch_dim1 + 2]; /* L122: */ } /* L123: */ } if (idot > *l1) { goto L127; } idij = 0; i__1 = *ip; for (j = 2; j <= i__1; ++j) { idij += 2; i__2 = *ido; for (i__ = 4; i__ <= i__2; i__ += 2) { idij += 2; i__3 = *l1; for (k = 1; k <= i__3; ++k) { c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L124: */ } /* L125: */ } /* L126: */ } return 0; L127: idj = 2 - *ido; i__1 = *ip; for (j = 2; j <= i__1; ++j) { idj += *ido; i__2 = *l1; for (k = 1; k <= i__2; ++k) { idij = idj; i__3 = *ido; for (i__ = 4; i__ <= i__3; i__ += 2) { idij += 2; c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L128: */ } /* L129: */ } /* L130: */ } return 0; } /* passb_ */ /* Subroutine */ int passb2_(integer *ido, integer *l1, real *cc, real *ch, real *wa1) { /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; real ti2, tr2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 3; cc -= cc_offSet; --wa1; /* Function Body */ if (*ido > 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[(k + ch_dim2) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] + cc[((k << 1) + 2) * cc_dim1 + 1]; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] - cc[((k << 1) + 2) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[((k << 1) + 1) * cc_dim1 + 2] + cc[((k << 1) + 2) * cc_dim1 + 2]; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = cc[((k << 1) + 1) * cc_dim1 + 2] - cc[((k << 1) + 2) * cc_dim1 + 2]; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] + cc[i__ - 1 + ((k << 1) + 2) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] - cc[i__ - 1 + ((k << 1) + 2) * cc_dim1]; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + ((k << 1) + 1) * cc_dim1] + cc[i__ + ((k << 1) + 2) * cc_dim1]; ti2 = cc[i__ + ((k << 1) + 1) * cc_dim1] - cc[i__ + ((k << 1) + 2) * cc_dim1]; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * ti2 + wa1[i__] * tr2; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * tr2 - wa1[i__] * ti2; /* L103: */ } /* L104: */ } return 0; } /* passb2_ */ /* Subroutine */ int passb3_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2) { /* Initialized data */ static real taur = -.5f; static real taui = .866025403784439f; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; real ci2, ci3, di2, di3, cr2, cr3, dr2, dr3, ti2, tr2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + (cc_dim1 << 2); cc -= cc_offSet; --wa1; --wa2; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { tr2 = cc[(k * 3 + 2) * cc_dim1 + 1] + cc[(k * 3 + 3) * cc_dim1 + 1]; cr2 = cc[(k * 3 + 1) * cc_dim1 + 1] + taur * tr2; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 3 + 1) * cc_dim1 + 1] + tr2; ti2 = cc[(k * 3 + 2) * cc_dim1 + 2] + cc[(k * 3 + 3) * cc_dim1 + 2]; ci2 = cc[(k * 3 + 1) * cc_dim1 + 2] + taur * ti2; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[(k * 3 + 1) * cc_dim1 + 2] + ti2; cr3 = taui * (cc[(k * 3 + 2) * cc_dim1 + 1] - cc[(k * 3 + 3) * cc_dim1 + 1]); ci3 = taui * (cc[(k * 3 + 2) * cc_dim1 + 2] - cc[(k * 3 + 3) * cc_dim1 + 2]); ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci3; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr2 + ci3; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ci2 + cr3; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ci2 - cr3; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { tr2 = cc[i__ - 1 + (k * 3 + 2) * cc_dim1] + cc[i__ - 1 + (k * 3 + 3) * cc_dim1]; cr2 = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + taur * tr2; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + tr2; ti2 = cc[i__ + (k * 3 + 2) * cc_dim1] + cc[i__ + (k * 3 + 3) * cc_dim1]; ci2 = cc[i__ + (k * 3 + 1) * cc_dim1] + taur * ti2; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 3 + 1) * cc_dim1] + ti2; cr3 = taui * (cc[i__ - 1 + (k * 3 + 2) * cc_dim1] - cc[i__ - 1 + ( k * 3 + 3) * cc_dim1]); ci3 = taui * (cc[i__ + (k * 3 + 2) * cc_dim1] - cc[i__ + (k * 3 + 3) * cc_dim1]); dr2 = cr2 - ci3; dr3 = cr2 + ci3; di2 = ci2 + cr3; di3 = ci2 - cr3; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * di2 + wa1[i__] * dr2; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * dr2 - wa1[i__] * di2; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * di3 + wa2[ i__] * dr3; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * dr3 - wa2[i__] * di3; /* L103: */ } /* L104: */ } return 0; } /* passb3_ */ /* Subroutine */ int passb4_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2, real *wa3) { /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; real ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 5; cc -= cc_offSet; --wa1; --wa2; --wa3; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti1 = cc[((k << 2) + 1) * cc_dim1 + 2] - cc[((k << 2) + 3) * cc_dim1 + 2]; ti2 = cc[((k << 2) + 1) * cc_dim1 + 2] + cc[((k << 2) + 3) * cc_dim1 + 2]; tr4 = cc[((k << 2) + 4) * cc_dim1 + 2] - cc[((k << 2) + 2) * cc_dim1 + 2]; ti3 = cc[((k << 2) + 2) * cc_dim1 + 2] + cc[((k << 2) + 4) * cc_dim1 + 2]; tr1 = cc[((k << 2) + 1) * cc_dim1 + 1] - cc[((k << 2) + 3) * cc_dim1 + 1]; tr2 = cc[((k << 2) + 1) * cc_dim1 + 1] + cc[((k << 2) + 3) * cc_dim1 + 1]; ti4 = cc[((k << 2) + 2) * cc_dim1 + 1] - cc[((k << 2) + 4) * cc_dim1 + 1]; tr3 = cc[((k << 2) + 2) * cc_dim1 + 1] + cc[((k << 2) + 4) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 1] = tr2 + tr3; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = tr2 - tr3; ch[(k + ch_dim2) * ch_dim1 + 2] = ti2 + ti3; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ti2 - ti3; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = tr1 + tr4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = tr1 - tr4; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ti1 + ti4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 2] = ti1 - ti4; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ti1 = cc[i__ + ((k << 2) + 1) * cc_dim1] - cc[i__ + ((k << 2) + 3) * cc_dim1]; ti2 = cc[i__ + ((k << 2) + 1) * cc_dim1] + cc[i__ + ((k << 2) + 3) * cc_dim1]; ti3 = cc[i__ + ((k << 2) + 2) * cc_dim1] + cc[i__ + ((k << 2) + 4) * cc_dim1]; tr4 = cc[i__ + ((k << 2) + 4) * cc_dim1] - cc[i__ + ((k << 2) + 2) * cc_dim1]; tr1 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] - cc[i__ - 1 + ((k << 2) + 3) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] + cc[i__ - 1 + ((k << 2) + 3) * cc_dim1]; ti4 = cc[i__ - 1 + ((k << 2) + 2) * cc_dim1] - cc[i__ - 1 + ((k << 2) + 4) * cc_dim1]; tr3 = cc[i__ - 1 + ((k << 2) + 2) * cc_dim1] + cc[i__ - 1 + ((k << 2) + 4) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = tr2 + tr3; cr3 = tr2 - tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = ti2 + ti3; ci3 = ti2 - ti3; cr2 = tr1 + tr4; cr4 = tr1 - tr4; ci2 = ti1 + ti4; ci4 = ti1 - ti4; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * cr2 - wa1[i__] * ci2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * ci2 + wa1[i__] * cr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * cr3 - wa2[i__] * ci3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * ci3 + wa2[ i__] * cr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * cr4 - wa3[i__] * ci4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * ci4 + wa3[i__] * cr4; /* L103: */ } /* L104: */ } return 0; } /* passb4_ */ /* Subroutine */ int passb5_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2, real *wa3, real *wa4) { /* Initialized data */ static real tr11 = .309016994374947f; static real ti11 = .951056516295154f; static real tr12 = -.809016994374947f; static real ti12 = .587785252292473f; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; real ci2, ci3, ci4, ci5, di3, di4, di5, di2, cr2, cr3, cr5, cr4, ti2, ti3, ti4, ti5, dr3, dr4, dr5, dr2, tr2, tr3, tr4, tr5; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 6; cc -= cc_offSet; --wa1; --wa2; --wa3; --wa4; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti5 = cc[(k * 5 + 2) * cc_dim1 + 2] - cc[(k * 5 + 5) * cc_dim1 + 2]; ti2 = cc[(k * 5 + 2) * cc_dim1 + 2] + cc[(k * 5 + 5) * cc_dim1 + 2]; ti4 = cc[(k * 5 + 3) * cc_dim1 + 2] - cc[(k * 5 + 4) * cc_dim1 + 2]; ti3 = cc[(k * 5 + 3) * cc_dim1 + 2] + cc[(k * 5 + 4) * cc_dim1 + 2]; tr5 = cc[(k * 5 + 2) * cc_dim1 + 1] - cc[(k * 5 + 5) * cc_dim1 + 1]; tr2 = cc[(k * 5 + 2) * cc_dim1 + 1] + cc[(k * 5 + 5) * cc_dim1 + 1]; tr4 = cc[(k * 5 + 3) * cc_dim1 + 1] - cc[(k * 5 + 4) * cc_dim1 + 1]; tr3 = cc[(k * 5 + 3) * cc_dim1 + 1] + cc[(k * 5 + 4) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 5 + 1) * cc_dim1 + 1] + tr2 + tr3; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[(k * 5 + 1) * cc_dim1 + 2] + ti2 + ti3; cr2 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr11 * tr2 + tr12 * tr3; ci2 = cc[(k * 5 + 1) * cc_dim1 + 2] + tr11 * ti2 + tr12 * ti3; cr3 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr12 * tr2 + tr11 * tr3; ci3 = cc[(k * 5 + 1) * cc_dim1 + 2] + tr12 * ti2 + tr11 * ti3; cr5 = ti11 * tr5 + ti12 * tr4; ci5 = ti11 * ti5 + ti12 * ti4; cr4 = ti12 * tr5 - ti11 * tr4; ci4 = ti12 * ti5 - ti11 * ti4; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci5; ch[(k + ch_dim2 * 5) * ch_dim1 + 1] = cr2 + ci5; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ci2 + cr5; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ci3 + cr4; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr3 - ci4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = cr3 + ci4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 2] = ci3 - cr4; ch[(k + ch_dim2 * 5) * ch_dim1 + 2] = ci2 - cr5; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ti5 = cc[i__ + (k * 5 + 2) * cc_dim1] - cc[i__ + (k * 5 + 5) * cc_dim1]; ti2 = cc[i__ + (k * 5 + 2) * cc_dim1] + cc[i__ + (k * 5 + 5) * cc_dim1]; ti4 = cc[i__ + (k * 5 + 3) * cc_dim1] - cc[i__ + (k * 5 + 4) * cc_dim1]; ti3 = cc[i__ + (k * 5 + 3) * cc_dim1] + cc[i__ + (k * 5 + 4) * cc_dim1]; tr5 = cc[i__ - 1 + (k * 5 + 2) * cc_dim1] - cc[i__ - 1 + (k * 5 + 5) * cc_dim1]; tr2 = cc[i__ - 1 + (k * 5 + 2) * cc_dim1] + cc[i__ - 1 + (k * 5 + 5) * cc_dim1]; tr4 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] - cc[i__ - 1 + (k * 5 + 4) * cc_dim1]; tr3 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] + cc[i__ - 1 + (k * 5 + 4) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr2 + tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 5 + 1) * cc_dim1] + ti2 + ti3; cr2 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr11 * tr2 + tr12 * tr3; ci2 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr11 * ti2 + tr12 * ti3; cr3 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr12 * tr2 + tr11 * tr3; ci3 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr12 * ti2 + tr11 * ti3; cr5 = ti11 * tr5 + ti12 * tr4; ci5 = ti11 * ti5 + ti12 * ti4; cr4 = ti12 * tr5 - ti11 * tr4; ci4 = ti12 * ti5 - ti11 * ti4; dr3 = cr3 - ci4; dr4 = cr3 + ci4; di3 = ci3 + cr4; di4 = ci3 - cr4; dr5 = cr2 + ci5; dr2 = cr2 - ci5; di5 = ci2 - cr5; di2 = ci2 + cr5; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * dr2 - wa1[i__] * di2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * di2 + wa1[i__] * dr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * dr3 - wa2[i__] * di3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * di3 + wa2[ i__] * dr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * dr4 - wa3[i__] * di4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * di4 + wa3[i__] * dr4; ch[i__ - 1 + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 1] * dr5 - wa4[i__] * di5; ch[i__ + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 1] * di5 + wa4[ i__] * dr5; /* L103: */ } /* L104: */ } return 0; } /* passb5_ */ /* Subroutine */ int cfftf1_(int *n, float *c__, float *ch, float *wa, int *ifac) { /* System generated locals */ integer i__1; /* Local variables */ integer i__, k1, l1, l2, n2, na, nf, ip, iw, ix2, ix3, ix4, nac, ido, idl1, idot; extern /* Subroutine */ int passf_(integer *, integer *, integer *, integer *, integer *, real *, real *, real *, real *, real *, real *), passf2_(integer *, integer *, real *, real *, real *), passf3_(integer *, integer *, real *, real *, real *, real *), passf4_(integer *, integer *, real *, real *, real *, real *, real *), passf5_(integer *, integer *, real *, real *, real *, real *, real *, real *); /* Parameter adjustments */ --ifac; --wa; --ch; --c__; /* Function Body */ nf = ifac[2]; na = 0; l1 = 1; iw = 1; i__1 = nf; for (k1 = 1; k1 <= i__1; ++k1) { ip = ifac[k1 + 2]; l2 = ip * l1; ido = *n / l2; idot = ido + ido; idl1 = idot * l1; if (ip != 4) { goto L103; } ix2 = iw + idot; ix3 = ix2 + idot; if (na != 0) { goto L101; } passf4_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3]); goto L102; L101: passf4_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3]); L102: na = 1 - na; goto L115; L103: if (ip != 2) { goto L106; } if (na != 0) { goto L104; } passf2_(&idot, &l1, &c__[1], &ch[1], &wa[iw]); goto L105; L104: passf2_(&idot, &l1, &ch[1], &c__[1], &wa[iw]); L105: na = 1 - na; goto L115; L106: if (ip != 3) { goto L109; } ix2 = iw + idot; if (na != 0) { goto L107; } passf3_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2]); goto L108; L107: passf3_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2]); L108: na = 1 - na; goto L115; L109: if (ip != 5) { goto L112; } ix2 = iw + idot; ix3 = ix2 + idot; ix4 = ix3 + idot; if (na != 0) { goto L110; } passf5_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); goto L111; L110: passf5_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); L111: na = 1 - na; goto L115; L112: if (na != 0) { goto L113; } passf_(&nac, &idot, &ip, &l1, &idl1, &c__[1], &c__[1], &c__[1], &ch[1] , &ch[1], &wa[iw]); goto L114; L113: passf_(&nac, &idot, &ip, &l1, &idl1, &ch[1], &ch[1], &ch[1], &c__[1], &c__[1], &wa[iw]); L114: if (nac != 0) { na = 1 - na; } L115: l1 = l2; iw += (ip - 1) * idot; /* L116: */ } if (na == 0) { return 0; } n2 = *n + *n; i__1 = n2; for (i__ = 1; i__ <= i__1; ++i__) { c__[i__] = ch[i__]; /* L117: */ } return 0; } /* cfftf1_ */ /* Subroutine */ int passf_(integer *nac, integer *ido, integer *ip, integer * l1, integer *idl1, real *cc, real *c1, real *c2, real *ch, real *ch2, real *wa) { /* System generated locals */ integer ch_dim1, ch_dim2, ch_offSet, cc_dim1, cc_dim2, cc_offSet, c1_dim1, c1_dim2, c1_offSet, c2_dim1, c2_offSet, ch2_dim1, ch2_offSet, i__1, i__2, i__3; /* Local variables */ integer i__, j, k, l, jc, lc, ik, nt, idj, idl, inc, idp; real wai, war; integer ipp2, idij, idlj, idot, ipph; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; c1_dim1 = *ido; c1_dim2 = *l1; c1_offSet = 1 + c1_dim1 * (1 + c1_dim2); c1 -= c1_offSet; cc_dim1 = *ido; cc_dim2 = *ip; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; ch2_dim1 = *idl1; ch2_offSet = 1 + ch2_dim1; ch2 -= ch2_offSet; c2_dim1 = *idl1; c2_offSet = 1 + c2_dim1; c2 -= c2_offSet; --wa; /* Function Body */ idot = *ido / 2; nt = *ip * *idl1; ipp2 = *ip + 2; ipph = (*ip + 1) / 2; idp = *ip * *ido; if (*ido < *l1) { goto L106; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 1; i__ <= i__3; ++i__) { ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] + cc[i__ + (jc + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] - cc[i__ + (jc + k * cc_dim2) * cc_dim1]; /* L101: */ } /* L102: */ } /* L103: */ } i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L104: */ } /* L105: */ } goto L112; L106: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { i__3 = *l1; for (k = 1; k <= i__3; ++k) { ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] + cc[i__ + (jc + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] - cc[i__ + (jc + k * cc_dim2) * cc_dim1]; /* L107: */ } /* L108: */ } /* L109: */ } i__1 = *ido; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L110: */ } /* L111: */ } L112: idl = 2 - *ido; inc = 0; i__1 = ipph; for (l = 2; l <= i__1; ++l) { lc = ipp2 - l; idl += *ido; i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { c2[ik + l * c2_dim1] = ch2[ik + ch2_dim1] + wa[idl - 1] * ch2[ik + (ch2_dim1 << 1)]; c2[ik + lc * c2_dim1] = -wa[idl] * ch2[ik + *ip * ch2_dim1]; /* L113: */ } idlj = idl; inc += *ido; i__2 = ipph; for (j = 3; j <= i__2; ++j) { jc = ipp2 - j; idlj += inc; if (idlj > idp) { idlj -= idp; } war = wa[idlj - 1]; wai = wa[idlj]; i__3 = *idl1; for (ik = 1; ik <= i__3; ++ik) { c2[ik + l * c2_dim1] += war * ch2[ik + j * ch2_dim1]; c2[ik + lc * c2_dim1] -= wai * ch2[ik + jc * ch2_dim1]; /* L114: */ } /* L115: */ } /* L116: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { ch2[ik + ch2_dim1] += ch2[ik + j * ch2_dim1]; /* L117: */ } /* L118: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *idl1; for (ik = 2; ik <= i__2; ik += 2) { ch2[ik - 1 + j * ch2_dim1] = c2[ik - 1 + j * c2_dim1] - c2[ik + jc * c2_dim1]; ch2[ik - 1 + jc * ch2_dim1] = c2[ik - 1 + j * c2_dim1] + c2[ik + jc * c2_dim1]; ch2[ik + j * ch2_dim1] = c2[ik + j * c2_dim1] + c2[ik - 1 + jc * c2_dim1]; ch2[ik + jc * ch2_dim1] = c2[ik + j * c2_dim1] - c2[ik - 1 + jc * c2_dim1]; /* L119: */ } /* L120: */ } *nac = 1; if (*ido == 2) { return 0; } *nac = 0; i__1 = *idl1; for (ik = 1; ik <= i__1; ++ik) { c2[ik + c2_dim1] = ch2[ik + ch2_dim1]; /* L121: */ } i__1 = *ip; for (j = 2; j <= i__1; ++j) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { c1[(k + j * c1_dim2) * c1_dim1 + 1] = ch[(k + j * ch_dim2) * ch_dim1 + 1]; c1[(k + j * c1_dim2) * c1_dim1 + 2] = ch[(k + j * ch_dim2) * ch_dim1 + 2]; /* L122: */ } /* L123: */ } if (idot > *l1) { goto L127; } idij = 0; i__1 = *ip; for (j = 2; j <= i__1; ++j) { idij += 2; i__2 = *ido; for (i__ = 4; i__ <= i__2; i__ += 2) { idij += 2; i__3 = *l1; for (k = 1; k <= i__3; ++k) { c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L124: */ } /* L125: */ } /* L126: */ } return 0; L127: idj = 2 - *ido; i__1 = *ip; for (j = 2; j <= i__1; ++j) { idj += *ido; i__2 = *l1; for (k = 1; k <= i__2; ++k) { idij = idj; i__3 = *ido; for (i__ = 4; i__ <= i__3; i__ += 2) { idij += 2; c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L128: */ } /* L129: */ } /* L130: */ } return 0; } /* passf_ */ /* Subroutine */ int passf2_(integer *ido, integer *l1, real *cc, real *ch, real *wa1) { /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; real ti2, tr2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 3; cc -= cc_offSet; --wa1; /* Function Body */ if (*ido > 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[(k + ch_dim2) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] + cc[((k << 1) + 2) * cc_dim1 + 1]; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] - cc[((k << 1) + 2) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[((k << 1) + 1) * cc_dim1 + 2] + cc[((k << 1) + 2) * cc_dim1 + 2]; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = cc[((k << 1) + 1) * cc_dim1 + 2] - cc[((k << 1) + 2) * cc_dim1 + 2]; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] + cc[i__ - 1 + ((k << 1) + 2) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] - cc[i__ - 1 + ((k << 1) + 2) * cc_dim1]; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + ((k << 1) + 1) * cc_dim1] + cc[i__ + ((k << 1) + 2) * cc_dim1]; ti2 = cc[i__ + ((k << 1) + 1) * cc_dim1] - cc[i__ + ((k << 1) + 2) * cc_dim1]; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * ti2 - wa1[i__] * tr2; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * tr2 + wa1[i__] * ti2; /* L103: */ } /* L104: */ } return 0; } /* passf2_ */ /* Subroutine */ int passf3_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2) { /* Initialized data */ static real taur = -.5f; static real taui = -.866025403784439f; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; real ci2, ci3, di2, di3, cr2, cr3, dr2, dr3, ti2, tr2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + (cc_dim1 << 2); cc -= cc_offSet; --wa1; --wa2; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { tr2 = cc[(k * 3 + 2) * cc_dim1 + 1] + cc[(k * 3 + 3) * cc_dim1 + 1]; cr2 = cc[(k * 3 + 1) * cc_dim1 + 1] + taur * tr2; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 3 + 1) * cc_dim1 + 1] + tr2; ti2 = cc[(k * 3 + 2) * cc_dim1 + 2] + cc[(k * 3 + 3) * cc_dim1 + 2]; ci2 = cc[(k * 3 + 1) * cc_dim1 + 2] + taur * ti2; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[(k * 3 + 1) * cc_dim1 + 2] + ti2; cr3 = taui * (cc[(k * 3 + 2) * cc_dim1 + 1] - cc[(k * 3 + 3) * cc_dim1 + 1]); ci3 = taui * (cc[(k * 3 + 2) * cc_dim1 + 2] - cc[(k * 3 + 3) * cc_dim1 + 2]); ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci3; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr2 + ci3; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ci2 + cr3; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ci2 - cr3; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { tr2 = cc[i__ - 1 + (k * 3 + 2) * cc_dim1] + cc[i__ - 1 + (k * 3 + 3) * cc_dim1]; cr2 = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + taur * tr2; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + tr2; ti2 = cc[i__ + (k * 3 + 2) * cc_dim1] + cc[i__ + (k * 3 + 3) * cc_dim1]; ci2 = cc[i__ + (k * 3 + 1) * cc_dim1] + taur * ti2; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 3 + 1) * cc_dim1] + ti2; cr3 = taui * (cc[i__ - 1 + (k * 3 + 2) * cc_dim1] - cc[i__ - 1 + ( k * 3 + 3) * cc_dim1]); ci3 = taui * (cc[i__ + (k * 3 + 2) * cc_dim1] - cc[i__ + (k * 3 + 3) * cc_dim1]); dr2 = cr2 - ci3; dr3 = cr2 + ci3; di2 = ci2 + cr3; di3 = ci2 - cr3; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * di2 - wa1[i__] * dr2; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * dr2 + wa1[i__] * di2; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * di3 - wa2[ i__] * dr3; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * dr3 + wa2[i__] * di3; /* L103: */ } /* L104: */ } return 0; } /* passf3_ */ /* Subroutine */ int passf4_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2, real *wa3) { /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; real ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 5; cc -= cc_offSet; --wa1; --wa2; --wa3; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti1 = cc[((k << 2) + 1) * cc_dim1 + 2] - cc[((k << 2) + 3) * cc_dim1 + 2]; ti2 = cc[((k << 2) + 1) * cc_dim1 + 2] + cc[((k << 2) + 3) * cc_dim1 + 2]; tr4 = cc[((k << 2) + 2) * cc_dim1 + 2] - cc[((k << 2) + 4) * cc_dim1 + 2]; ti3 = cc[((k << 2) + 2) * cc_dim1 + 2] + cc[((k << 2) + 4) * cc_dim1 + 2]; tr1 = cc[((k << 2) + 1) * cc_dim1 + 1] - cc[((k << 2) + 3) * cc_dim1 + 1]; tr2 = cc[((k << 2) + 1) * cc_dim1 + 1] + cc[((k << 2) + 3) * cc_dim1 + 1]; ti4 = cc[((k << 2) + 4) * cc_dim1 + 1] - cc[((k << 2) + 2) * cc_dim1 + 1]; tr3 = cc[((k << 2) + 2) * cc_dim1 + 1] + cc[((k << 2) + 4) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 1] = tr2 + tr3; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = tr2 - tr3; ch[(k + ch_dim2) * ch_dim1 + 2] = ti2 + ti3; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ti2 - ti3; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = tr1 + tr4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = tr1 - tr4; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ti1 + ti4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 2] = ti1 - ti4; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ti1 = cc[i__ + ((k << 2) + 1) * cc_dim1] - cc[i__ + ((k << 2) + 3) * cc_dim1]; ti2 = cc[i__ + ((k << 2) + 1) * cc_dim1] + cc[i__ + ((k << 2) + 3) * cc_dim1]; ti3 = cc[i__ + ((k << 2) + 2) * cc_dim1] + cc[i__ + ((k << 2) + 4) * cc_dim1]; tr4 = cc[i__ + ((k << 2) + 2) * cc_dim1] - cc[i__ + ((k << 2) + 4) * cc_dim1]; tr1 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] - cc[i__ - 1 + ((k << 2) + 3) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] + cc[i__ - 1 + ((k << 2) + 3) * cc_dim1]; ti4 = cc[i__ - 1 + ((k << 2) + 4) * cc_dim1] - cc[i__ - 1 + ((k << 2) + 2) * cc_dim1]; tr3 = cc[i__ - 1 + ((k << 2) + 2) * cc_dim1] + cc[i__ - 1 + ((k << 2) + 4) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = tr2 + tr3; cr3 = tr2 - tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = ti2 + ti3; ci3 = ti2 - ti3; cr2 = tr1 + tr4; cr4 = tr1 - tr4; ci2 = ti1 + ti4; ci4 = ti1 - ti4; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * cr2 + wa1[i__] * ci2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * ci2 - wa1[i__] * cr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * cr3 + wa2[i__] * ci3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * ci3 - wa2[ i__] * cr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * cr4 + wa3[i__] * ci4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * ci4 - wa3[i__] * cr4; /* L103: */ } /* L104: */ } return 0; } /* passf4_ */ /* Subroutine */ int passf5_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2, real *wa3, real *wa4) { /* Initialized data */ static real tr11 = .309016994374947f; static real ti11 = -.951056516295154f; static real tr12 = -.809016994374947f; static real ti12 = -.587785252292473f; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; real ci2, ci3, ci4, ci5, di3, di4, di5, di2, cr2, cr3, cr5, cr4, ti2, ti3, ti4, ti5, dr3, dr4, dr5, dr2, tr2, tr3, tr4, tr5; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 6; cc -= cc_offSet; --wa1; --wa2; --wa3; --wa4; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti5 = cc[(k * 5 + 2) * cc_dim1 + 2] - cc[(k * 5 + 5) * cc_dim1 + 2]; ti2 = cc[(k * 5 + 2) * cc_dim1 + 2] + cc[(k * 5 + 5) * cc_dim1 + 2]; ti4 = cc[(k * 5 + 3) * cc_dim1 + 2] - cc[(k * 5 + 4) * cc_dim1 + 2]; ti3 = cc[(k * 5 + 3) * cc_dim1 + 2] + cc[(k * 5 + 4) * cc_dim1 + 2]; tr5 = cc[(k * 5 + 2) * cc_dim1 + 1] - cc[(k * 5 + 5) * cc_dim1 + 1]; tr2 = cc[(k * 5 + 2) * cc_dim1 + 1] + cc[(k * 5 + 5) * cc_dim1 + 1]; tr4 = cc[(k * 5 + 3) * cc_dim1 + 1] - cc[(k * 5 + 4) * cc_dim1 + 1]; tr3 = cc[(k * 5 + 3) * cc_dim1 + 1] + cc[(k * 5 + 4) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 5 + 1) * cc_dim1 + 1] + tr2 + tr3; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[(k * 5 + 1) * cc_dim1 + 2] + ti2 + ti3; cr2 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr11 * tr2 + tr12 * tr3; ci2 = cc[(k * 5 + 1) * cc_dim1 + 2] + tr11 * ti2 + tr12 * ti3; cr3 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr12 * tr2 + tr11 * tr3; ci3 = cc[(k * 5 + 1) * cc_dim1 + 2] + tr12 * ti2 + tr11 * ti3; cr5 = ti11 * tr5 + ti12 * tr4; ci5 = ti11 * ti5 + ti12 * ti4; cr4 = ti12 * tr5 - ti11 * tr4; ci4 = ti12 * ti5 - ti11 * ti4; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci5; ch[(k + ch_dim2 * 5) * ch_dim1 + 1] = cr2 + ci5; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ci2 + cr5; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ci3 + cr4; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr3 - ci4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = cr3 + ci4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 2] = ci3 - cr4; ch[(k + ch_dim2 * 5) * ch_dim1 + 2] = ci2 - cr5; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ti5 = cc[i__ + (k * 5 + 2) * cc_dim1] - cc[i__ + (k * 5 + 5) * cc_dim1]; ti2 = cc[i__ + (k * 5 + 2) * cc_dim1] + cc[i__ + (k * 5 + 5) * cc_dim1]; ti4 = cc[i__ + (k * 5 + 3) * cc_dim1] - cc[i__ + (k * 5 + 4) * cc_dim1]; ti3 = cc[i__ + (k * 5 + 3) * cc_dim1] + cc[i__ + (k * 5 + 4) * cc_dim1]; tr5 = cc[i__ - 1 + (k * 5 + 2) * cc_dim1] - cc[i__ - 1 + (k * 5 + 5) * cc_dim1]; tr2 = cc[i__ - 1 + (k * 5 + 2) * cc_dim1] + cc[i__ - 1 + (k * 5 + 5) * cc_dim1]; tr4 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] - cc[i__ - 1 + (k * 5 + 4) * cc_dim1]; tr3 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] + cc[i__ - 1 + (k * 5 + 4) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr2 + tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 5 + 1) * cc_dim1] + ti2 + ti3; cr2 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr11 * tr2 + tr12 * tr3; ci2 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr11 * ti2 + tr12 * ti3; cr3 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr12 * tr2 + tr11 * tr3; ci3 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr12 * ti2 + tr11 * ti3; cr5 = ti11 * tr5 + ti12 * tr4; ci5 = ti11 * ti5 + ti12 * ti4; cr4 = ti12 * tr5 - ti11 * tr4; ci4 = ti12 * ti5 - ti11 * ti4; dr3 = cr3 - ci4; dr4 = cr3 + ci4; di3 = ci3 + cr4; di4 = ci3 - cr4; dr5 = cr2 + ci5; dr2 = cr2 - ci5; di5 = ci2 - cr5; di2 = ci2 + cr5; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * dr2 + wa1[i__] * di2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * di2 - wa1[i__] * dr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * dr3 + wa2[i__] * di3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * di3 - wa2[ i__] * dr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * dr4 + wa3[i__] * di4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * di4 - wa3[i__] * dr4; ch[i__ - 1 + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 1] * dr5 + wa4[i__] * di5; ch[i__ + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 1] * di5 - wa4[ i__] * dr5; /* L103: */ } /* L104: */ } return 0; } /* passf5_ */ /* Subroutine */ int radb2_(integer *ido, integer *l1, real *cc, real *ch, real *wa1) { /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; real ti2, tr2; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 3; cc -= cc_offSet; --wa1; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[(k + ch_dim2) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] + cc[*ido + ((k << 1) + 2) * cc_dim1]; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] - cc[*ido + ((k << 1) + 2) * cc_dim1]; /* L101: */ } if ((i__1 = *ido - 2) < 0) { goto L107; } else if (i__1 == 0) { goto L105; } else { goto L102; } L102: idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] + cc[ic - 1 + ((k << 1) + 2) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] - cc[ic - 1 + ((k << 1) + 2) * cc_dim1]; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + ((k << 1) + 1) * cc_dim1] - cc[ic + ((k << 1) + 2) * cc_dim1]; ti2 = cc[i__ + ((k << 1) + 1) * cc_dim1] + cc[ic + ((k << 1) + 2) * cc_dim1]; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * tr2 - wa1[i__ - 1] * ti2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * ti2 + wa1[i__ - 1] * tr2; /* L103: */ } /* L104: */ } if (*ido % 2 == 1) { return 0; } L105: i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[*ido + (k + ch_dim2) * ch_dim1] = cc[*ido + ((k << 1) + 1) * cc_dim1] + cc[*ido + ((k << 1) + 1) * cc_dim1]; ch[*ido + (k + (ch_dim2 << 1)) * ch_dim1] = -(cc[((k << 1) + 2) * cc_dim1 + 1] + cc[((k << 1) + 2) * cc_dim1 + 1]); /* L106: */ } L107: return 0; } /* radb2_ */ /* Subroutine */ int radb3_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2) { /* Initialized data */ static real taur = -.5f; static real taui = .866025403784439f; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; real ci2, ci3, di2, di3, cr2, cr3, dr2, dr3, ti2, tr2; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + (cc_dim1 << 2); cc -= cc_offSet; --wa1; --wa2; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { tr2 = cc[*ido + (k * 3 + 2) * cc_dim1] + cc[*ido + (k * 3 + 2) * cc_dim1]; cr2 = cc[(k * 3 + 1) * cc_dim1 + 1] + taur * tr2; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 3 + 1) * cc_dim1 + 1] + tr2; ci3 = taui * (cc[(k * 3 + 3) * cc_dim1 + 1] + cc[(k * 3 + 3) * cc_dim1 + 1]); ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci3; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr2 + ci3; /* L101: */ } if (*ido == 1) { return 0; } idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; tr2 = cc[i__ - 1 + (k * 3 + 3) * cc_dim1] + cc[ic - 1 + (k * 3 + 2) * cc_dim1]; cr2 = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + taur * tr2; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + tr2; ti2 = cc[i__ + (k * 3 + 3) * cc_dim1] - cc[ic + (k * 3 + 2) * cc_dim1]; ci2 = cc[i__ + (k * 3 + 1) * cc_dim1] + taur * ti2; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 3 + 1) * cc_dim1] + ti2; cr3 = taui * (cc[i__ - 1 + (k * 3 + 3) * cc_dim1] - cc[ic - 1 + ( k * 3 + 2) * cc_dim1]); ci3 = taui * (cc[i__ + (k * 3 + 3) * cc_dim1] + cc[ic + (k * 3 + 2) * cc_dim1]); dr2 = cr2 - ci3; dr3 = cr2 + ci3; di2 = ci2 + cr3; di3 = ci2 - cr3; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * dr2 - wa1[i__ - 1] * di2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * di2 + wa1[i__ - 1] * dr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * dr3 - wa2[i__ - 1] * di3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * di3 + wa2[ i__ - 1] * dr3; /* L102: */ } /* L103: */ } return 0; } /* radb3_ */ /* Subroutine */ int radb4_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2, real *wa3) { /* Initialized data */ static real sqrt2 = 1.414213562373095f; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; real ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 5; cc -= cc_offSet; --wa1; --wa2; --wa3; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { tr1 = cc[((k << 2) + 1) * cc_dim1 + 1] - cc[*ido + ((k << 2) + 4) * cc_dim1]; tr2 = cc[((k << 2) + 1) * cc_dim1 + 1] + cc[*ido + ((k << 2) + 4) * cc_dim1]; tr3 = cc[*ido + ((k << 2) + 2) * cc_dim1] + cc[*ido + ((k << 2) + 2) * cc_dim1]; tr4 = cc[((k << 2) + 3) * cc_dim1 + 1] + cc[((k << 2) + 3) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 1] = tr2 + tr3; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = tr1 - tr4; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = tr2 - tr3; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = tr1 + tr4; /* L101: */ } if ((i__1 = *ido - 2) < 0) { goto L107; } else if (i__1 == 0) { goto L105; } else { goto L102; } L102: idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; ti1 = cc[i__ + ((k << 2) + 1) * cc_dim1] + cc[ic + ((k << 2) + 4) * cc_dim1]; ti2 = cc[i__ + ((k << 2) + 1) * cc_dim1] - cc[ic + ((k << 2) + 4) * cc_dim1]; ti3 = cc[i__ + ((k << 2) + 3) * cc_dim1] - cc[ic + ((k << 2) + 2) * cc_dim1]; tr4 = cc[i__ + ((k << 2) + 3) * cc_dim1] + cc[ic + ((k << 2) + 2) * cc_dim1]; tr1 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] - cc[ic - 1 + ((k << 2) + 4) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] + cc[ic - 1 + ((k << 2) + 4) * cc_dim1]; ti4 = cc[i__ - 1 + ((k << 2) + 3) * cc_dim1] - cc[ic - 1 + ((k << 2) + 2) * cc_dim1]; tr3 = cc[i__ - 1 + ((k << 2) + 3) * cc_dim1] + cc[ic - 1 + ((k << 2) + 2) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = tr2 + tr3; cr3 = tr2 - tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = ti2 + ti3; ci3 = ti2 - ti3; cr2 = tr1 - tr4; cr4 = tr1 + tr4; ci2 = ti1 + ti4; ci4 = ti1 - ti4; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * cr2 - wa1[i__ - 1] * ci2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * ci2 + wa1[i__ - 1] * cr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * cr3 - wa2[i__ - 1] * ci3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * ci3 + wa2[ i__ - 1] * cr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 2] * cr4 - wa3[i__ - 1] * ci4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 2] * ci4 + wa3[i__ - 1] * cr4; /* L103: */ } /* L104: */ } if (*ido % 2 == 1) { return 0; } L105: i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti1 = cc[((k << 2) + 2) * cc_dim1 + 1] + cc[((k << 2) + 4) * cc_dim1 + 1]; ti2 = cc[((k << 2) + 4) * cc_dim1 + 1] - cc[((k << 2) + 2) * cc_dim1 + 1]; tr1 = cc[*ido + ((k << 2) + 1) * cc_dim1] - cc[*ido + ((k << 2) + 3) * cc_dim1]; tr2 = cc[*ido + ((k << 2) + 1) * cc_dim1] + cc[*ido + ((k << 2) + 3) * cc_dim1]; ch[*ido + (k + ch_dim2) * ch_dim1] = tr2 + tr2; ch[*ido + (k + (ch_dim2 << 1)) * ch_dim1] = sqrt2 * (tr1 - ti1); ch[*ido + (k + ch_dim2 * 3) * ch_dim1] = ti2 + ti2; ch[*ido + (k + (ch_dim2 << 2)) * ch_dim1] = -sqrt2 * (tr1 + ti1); /* L106: */ } L107: return 0; } /* radb4_ */ /* Subroutine */ int radb5_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2, real *wa3, real *wa4) { /* Initialized data */ static real tr11 = .309016994374947f; static real ti11 = .951056516295154f; static real tr12 = -.809016994374947f; static real ti12 = .587785252292473f; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; real ci2, ci3, ci4, ci5, di3, di4, di5, di2, cr2, cr3, cr5, cr4, ti2, ti3, ti4, ti5, dr3, dr4, dr5, dr2, tr2, tr3, tr4, tr5; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 6; cc -= cc_offSet; --wa1; --wa2; --wa3; --wa4; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti5 = cc[(k * 5 + 3) * cc_dim1 + 1] + cc[(k * 5 + 3) * cc_dim1 + 1]; ti4 = cc[(k * 5 + 5) * cc_dim1 + 1] + cc[(k * 5 + 5) * cc_dim1 + 1]; tr2 = cc[*ido + (k * 5 + 2) * cc_dim1] + cc[*ido + (k * 5 + 2) * cc_dim1]; tr3 = cc[*ido + (k * 5 + 4) * cc_dim1] + cc[*ido + (k * 5 + 4) * cc_dim1]; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 5 + 1) * cc_dim1 + 1] + tr2 + tr3; cr2 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr11 * tr2 + tr12 * tr3; cr3 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr12 * tr2 + tr11 * tr3; ci5 = ti11 * ti5 + ti12 * ti4; ci4 = ti12 * ti5 - ti11 * ti4; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci5; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr3 - ci4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = cr3 + ci4; ch[(k + ch_dim2 * 5) * ch_dim1 + 1] = cr2 + ci5; /* L101: */ } if (*ido == 1) { return 0; } idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; ti5 = cc[i__ + (k * 5 + 3) * cc_dim1] + cc[ic + (k * 5 + 2) * cc_dim1]; ti2 = cc[i__ + (k * 5 + 3) * cc_dim1] - cc[ic + (k * 5 + 2) * cc_dim1]; ti4 = cc[i__ + (k * 5 + 5) * cc_dim1] + cc[ic + (k * 5 + 4) * cc_dim1]; ti3 = cc[i__ + (k * 5 + 5) * cc_dim1] - cc[ic + (k * 5 + 4) * cc_dim1]; tr5 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] - cc[ic - 1 + (k * 5 + 2) * cc_dim1]; tr2 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] + cc[ic - 1 + (k * 5 + 2) * cc_dim1]; tr4 = cc[i__ - 1 + (k * 5 + 5) * cc_dim1] - cc[ic - 1 + (k * 5 + 4) * cc_dim1]; tr3 = cc[i__ - 1 + (k * 5 + 5) * cc_dim1] + cc[ic - 1 + (k * 5 + 4) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr2 + tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 5 + 1) * cc_dim1] + ti2 + ti3; cr2 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr11 * tr2 + tr12 * tr3; ci2 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr11 * ti2 + tr12 * ti3; cr3 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr12 * tr2 + tr11 * tr3; ci3 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr12 * ti2 + tr11 * ti3; cr5 = ti11 * tr5 + ti12 * tr4; ci5 = ti11 * ti5 + ti12 * ti4; cr4 = ti12 * tr5 - ti11 * tr4; ci4 = ti12 * ti5 - ti11 * ti4; dr3 = cr3 - ci4; dr4 = cr3 + ci4; di3 = ci3 + cr4; di4 = ci3 - cr4; dr5 = cr2 + ci5; dr2 = cr2 - ci5; di5 = ci2 - cr5; di2 = ci2 + cr5; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * dr2 - wa1[i__ - 1] * di2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * di2 + wa1[i__ - 1] * dr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * dr3 - wa2[i__ - 1] * di3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * di3 + wa2[ i__ - 1] * dr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 2] * dr4 - wa3[i__ - 1] * di4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 2] * di4 + wa3[i__ - 1] * dr4; ch[i__ - 1 + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 2] * dr5 - wa4[i__ - 1] * di5; ch[i__ + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 2] * di5 + wa4[ i__ - 1] * dr5; /* L102: */ } /* L103: */ } return 0; } /* radb5_ */ /* Subroutine */ int radbg_(integer *ido, integer *ip, integer *l1, integer * idl1, real *cc, real *c1, real *c2, real *ch, real *ch2, real *wa) { /* Initialized data */ static real tpi = 6.28318530717959f; /* System generated locals */ integer ch_dim1, ch_dim2, ch_offSet, cc_dim1, cc_dim2, cc_offSet, c1_dim1, c1_dim2, c1_offSet, c2_dim1, c2_offSet, ch2_dim1, ch2_offSet, i__1, i__2, i__3; /* Builtin functions */ /* Local variables */ integer i__, j, k, l, j2, ic, jc, lc, ik, is; real dc2, ai1, ai2, ar1, ar2, ds2; integer nbd; real dcp, arg, dsp, ar1h, ar2h; integer idp2, ipp2, idij, ipph; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; c1_dim1 = *ido; c1_dim2 = *l1; c1_offSet = 1 + c1_dim1 * (1 + c1_dim2); c1 -= c1_offSet; cc_dim1 = *ido; cc_dim2 = *ip; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; ch2_dim1 = *idl1; ch2_offSet = 1 + ch2_dim1; ch2 -= ch2_offSet; c2_dim1 = *idl1; c2_offSet = 1 + c2_dim1; c2 -= c2_offSet; --wa; /* Function Body */ arg = tpi / (real) (*ip); dcp = cos(arg); dsp = sin(arg); idp2 = *ido + 2; nbd = (*ido - 1) / 2; ipp2 = *ip + 2; ipph = (*ip + 1) / 2; if (*ido < *l1) { goto L103; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L101: */ } /* L102: */ } goto L106; L103: i__1 = *ido; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L104: */ } /* L105: */ } L106: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; j2 = j + j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[(k + j * ch_dim2) * ch_dim1 + 1] = cc[*ido + (j2 - 2 + k * cc_dim2) * cc_dim1] + cc[*ido + (j2 - 2 + k * cc_dim2) * cc_dim1]; ch[(k + jc * ch_dim2) * ch_dim1 + 1] = cc[(j2 - 1 + k * cc_dim2) * cc_dim1 + 1] + cc[(j2 - 1 + k * cc_dim2) * cc_dim1 + 1]; /* L107: */ } /* L108: */ } if (*ido == 1) { goto L116; } if (nbd < *l1) { goto L112; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { ic = idp2 - i__; ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = cc[i__ - 1 + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] + cc[ic - 1 + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] = cc[i__ - 1 + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] - cc[ic - 1 + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] - cc[ic + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] + cc[ic + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; /* L109: */ } /* L110: */ } /* L111: */ } goto L116; L112: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; i__3 = *l1; for (k = 1; k <= i__3; ++k) { ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = cc[i__ - 1 + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] + cc[ic - 1 + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] = cc[i__ - 1 + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] - cc[ic - 1 + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] - cc[ic + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] + cc[ic + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; /* L113: */ } /* L114: */ } /* L115: */ } L116: ar1 = 1.f; ai1 = 0.f; i__1 = ipph; for (l = 2; l <= i__1; ++l) { lc = ipp2 - l; ar1h = dcp * ar1 - dsp * ai1; ai1 = dcp * ai1 + dsp * ar1; ar1 = ar1h; i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { c2[ik + l * c2_dim1] = ch2[ik + ch2_dim1] + ar1 * ch2[ik + ( ch2_dim1 << 1)]; c2[ik + lc * c2_dim1] = ai1 * ch2[ik + *ip * ch2_dim1]; /* L117: */ } dc2 = ar1; ds2 = ai1; ar2 = ar1; ai2 = ai1; i__2 = ipph; for (j = 3; j <= i__2; ++j) { jc = ipp2 - j; ar2h = dc2 * ar2 - ds2 * ai2; ai2 = dc2 * ai2 + ds2 * ar2; ar2 = ar2h; i__3 = *idl1; for (ik = 1; ik <= i__3; ++ik) { c2[ik + l * c2_dim1] += ar2 * ch2[ik + j * ch2_dim1]; c2[ik + lc * c2_dim1] += ai2 * ch2[ik + jc * ch2_dim1]; /* L118: */ } /* L119: */ } /* L120: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { ch2[ik + ch2_dim1] += ch2[ik + j * ch2_dim1]; /* L121: */ } /* L122: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[(k + j * ch_dim2) * ch_dim1 + 1] = c1[(k + j * c1_dim2) * c1_dim1 + 1] - c1[(k + jc * c1_dim2) * c1_dim1 + 1]; ch[(k + jc * ch_dim2) * ch_dim1 + 1] = c1[(k + j * c1_dim2) * c1_dim1 + 1] + c1[(k + jc * c1_dim2) * c1_dim1 + 1]; /* L123: */ } /* L124: */ } if (*ido == 1) { goto L132; } if (nbd < *l1) { goto L128; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] - c1[i__ + (k + jc * c1_dim2) * c1_dim1]; ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] = c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] + c1[i__ + (k + jc * c1_dim2) * c1_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = c1[i__ + (k + j * c1_dim2) * c1_dim1] + c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = c1[i__ + (k + j * c1_dim2) * c1_dim1] - c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1]; /* L125: */ } /* L126: */ } /* L127: */ } goto L132; L128: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { i__3 = *l1; for (k = 1; k <= i__3; ++k) { ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] - c1[i__ + (k + jc * c1_dim2) * c1_dim1]; ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] = c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] + c1[i__ + (k + jc * c1_dim2) * c1_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = c1[i__ + (k + j * c1_dim2) * c1_dim1] + c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = c1[i__ + (k + j * c1_dim2) * c1_dim1] - c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1]; /* L129: */ } /* L130: */ } /* L131: */ } L132: if (*ido == 1) { return 0; } i__1 = *idl1; for (ik = 1; ik <= i__1; ++ik) { c2[ik + c2_dim1] = ch2[ik + ch2_dim1]; /* L133: */ } i__1 = *ip; for (j = 2; j <= i__1; ++j) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { c1[(k + j * c1_dim2) * c1_dim1 + 1] = ch[(k + j * ch_dim2) * ch_dim1 + 1]; /* L134: */ } /* L135: */ } if (nbd > *l1) { goto L139; } is = -(*ido); i__1 = *ip; for (j = 2; j <= i__1; ++j) { is += *ido; idij = is; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { idij += 2; i__3 = *l1; for (k = 1; k <= i__3; ++k) { c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L136: */ } /* L137: */ } /* L138: */ } goto L143; L139: is = -(*ido); i__1 = *ip; for (j = 2; j <= i__1; ++j) { is += *ido; i__2 = *l1; for (k = 1; k <= i__2; ++k) { idij = is; i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { idij += 2; c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L140: */ } /* L141: */ } /* L142: */ } L143: return 0; } /* radbg_ */ /* Subroutine */ int rfftb1_(int *n, float *c__, float *ch, float *wa, int *ifac) { /* System generated locals */ integer i__1; /* Local variables */ integer i__, k1, l1, l2, na, nf, ip, iw, ix2, ix3, ix4, ido, idl1; extern /* Subroutine */ int radb2_(integer *, integer *, real *, real *, real *), radb3_(integer *, integer *, real *, real *, real *, real *), radb4_(integer *, integer *, real *, real *, real *, real *, real *), radb5_(integer *, integer *, real *, real *, real *, real *, real *, real *), radbg_(integer *, integer *, integer *, integer *, real *, real *, real *, real *, real *, real *); /* Parameter adjustments */ --ifac; --wa; --ch; --c__; /* Function Body */ nf = ifac[2]; na = 0; l1 = 1; iw = 1; i__1 = nf; for (k1 = 1; k1 <= i__1; ++k1) { ip = ifac[k1 + 2]; l2 = ip * l1; ido = *n / l2; idl1 = ido * l1; if (ip != 4) { goto L103; } ix2 = iw + ido; ix3 = ix2 + ido; if (na != 0) { goto L101; } radb4_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3]); goto L102; L101: radb4_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3]); L102: na = 1 - na; goto L115; L103: if (ip != 2) { goto L106; } if (na != 0) { goto L104; } radb2_(&ido, &l1, &c__[1], &ch[1], &wa[iw]); goto L105; L104: radb2_(&ido, &l1, &ch[1], &c__[1], &wa[iw]); L105: na = 1 - na; goto L115; L106: if (ip != 3) { goto L109; } ix2 = iw + ido; if (na != 0) { goto L107; } radb3_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2]); goto L108; L107: radb3_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2]); L108: na = 1 - na; goto L115; L109: if (ip != 5) { goto L112; } ix2 = iw + ido; ix3 = ix2 + ido; ix4 = ix3 + ido; if (na != 0) { goto L110; } radb5_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); goto L111; L110: radb5_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); L111: na = 1 - na; goto L115; L112: if (na != 0) { goto L113; } radbg_(&ido, &ip, &l1, &idl1, &c__[1], &c__[1], &c__[1], &ch[1], &ch[ 1], &wa[iw]); goto L114; L113: radbg_(&ido, &ip, &l1, &idl1, &ch[1], &ch[1], &ch[1], &c__[1], &c__[1] , &wa[iw]); L114: if (ido == 1) { na = 1 - na; } L115: l1 = l2; iw += (ip - 1) * ido; /* L116: */ } if (na == 0) { return 0; } i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { c__[i__] = ch[i__]; /* L117: */ } return 0; } /* rfftb1_ */ /* Subroutine */ int radf2_(integer *ido, integer *l1, real *cc, real *ch, real *wa1) { /* System generated locals */ integer ch_dim1, ch_offSet, cc_dim1, cc_dim2, cc_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; real ti2, tr2; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_offSet = 1 + ch_dim1 * 3; ch -= ch_offSet; cc_dim1 = *ido; cc_dim2 = *l1; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; --wa1; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[((k << 1) + 1) * ch_dim1 + 1] = cc[(k + cc_dim2) * cc_dim1 + 1] + cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]; ch[*ido + ((k << 1) + 2) * ch_dim1] = cc[(k + cc_dim2) * cc_dim1 + 1] - cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]; /* L101: */ } if ((i__1 = *ido - 2) < 0) { goto L107; } else if (i__1 == 0) { goto L105; } else { goto L102; } L102: idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; tr2 = wa1[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1] + wa1[i__ - 1] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1]; ti2 = wa1[i__ - 2] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1] - wa1[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1]; ch[i__ + ((k << 1) + 1) * ch_dim1] = cc[i__ + (k + cc_dim2) * cc_dim1] + ti2; ch[ic + ((k << 1) + 2) * ch_dim1] = ti2 - cc[i__ + (k + cc_dim2) * cc_dim1]; ch[i__ - 1 + ((k << 1) + 1) * ch_dim1] = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + tr2; ch[ic - 1 + ((k << 1) + 2) * ch_dim1] = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] - tr2; /* L103: */ } /* L104: */ } if (*ido % 2 == 1) { return 0; } L105: i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[((k << 1) + 2) * ch_dim1 + 1] = -cc[*ido + (k + (cc_dim2 << 1)) * cc_dim1]; ch[*ido + ((k << 1) + 1) * ch_dim1] = cc[*ido + (k + cc_dim2) * cc_dim1]; /* L106: */ } L107: return 0; } /* radf2_ */ /* Subroutine */ int radf3_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2) { /* Initialized data */ static real taur = -.5f; static real taui = .866025403784439f; /* System generated locals */ integer ch_dim1, ch_offSet, cc_dim1, cc_dim2, cc_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; real ci2, di2, di3, cr2, dr2, dr3, ti2, ti3, tr2, tr3; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_offSet = 1 + (ch_dim1 << 2); ch -= ch_offSet; cc_dim1 = *ido; cc_dim2 = *l1; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; --wa1; --wa2; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { cr2 = cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1] + cc[(k + cc_dim2 * 3) * cc_dim1 + 1]; ch[(k * 3 + 1) * ch_dim1 + 1] = cc[(k + cc_dim2) * cc_dim1 + 1] + cr2; ch[(k * 3 + 3) * ch_dim1 + 1] = taui * (cc[(k + cc_dim2 * 3) * cc_dim1 + 1] - cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]); ch[*ido + (k * 3 + 2) * ch_dim1] = cc[(k + cc_dim2) * cc_dim1 + 1] + taur * cr2; /* L101: */ } if (*ido == 1) { return 0; } idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; dr2 = wa1[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1] + wa1[i__ - 1] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1]; di2 = wa1[i__ - 2] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1] - wa1[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1]; dr3 = wa2[i__ - 2] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1] + wa2[i__ - 1] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1]; di3 = wa2[i__ - 2] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1] - wa2[ i__ - 1] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1]; cr2 = dr2 + dr3; ci2 = di2 + di3; ch[i__ - 1 + (k * 3 + 1) * ch_dim1] = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + cr2; ch[i__ + (k * 3 + 1) * ch_dim1] = cc[i__ + (k + cc_dim2) * cc_dim1] + ci2; tr2 = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + taur * cr2; ti2 = cc[i__ + (k + cc_dim2) * cc_dim1] + taur * ci2; tr3 = taui * (di2 - di3); ti3 = taui * (dr3 - dr2); ch[i__ - 1 + (k * 3 + 3) * ch_dim1] = tr2 + tr3; ch[ic - 1 + (k * 3 + 2) * ch_dim1] = tr2 - tr3; ch[i__ + (k * 3 + 3) * ch_dim1] = ti2 + ti3; ch[ic + (k * 3 + 2) * ch_dim1] = ti3 - ti2; /* L102: */ } /* L103: */ } return 0; } /* radf3_ */ /* Subroutine */ int radf4_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2, real *wa3) { /* Initialized data */ static real hsqt2 = .7071067811865475f; /* System generated locals */ integer cc_dim1, cc_dim2, cc_offSet, ch_dim1, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; real ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_offSet = 1 + ch_dim1 * 5; ch -= ch_offSet; cc_dim1 = *ido; cc_dim2 = *l1; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; --wa1; --wa2; --wa3; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { tr1 = cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1] + cc[(k + (cc_dim2 << 2)) * cc_dim1 + 1]; tr2 = cc[(k + cc_dim2) * cc_dim1 + 1] + cc[(k + cc_dim2 * 3) * cc_dim1 + 1]; ch[((k << 2) + 1) * ch_dim1 + 1] = tr1 + tr2; ch[*ido + ((k << 2) + 4) * ch_dim1] = tr2 - tr1; ch[*ido + ((k << 2) + 2) * ch_dim1] = cc[(k + cc_dim2) * cc_dim1 + 1] - cc[(k + cc_dim2 * 3) * cc_dim1 + 1]; ch[((k << 2) + 3) * ch_dim1 + 1] = cc[(k + (cc_dim2 << 2)) * cc_dim1 + 1] - cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]; /* L101: */ } if ((i__1 = *ido - 2) < 0) { goto L107; } else if (i__1 == 0) { goto L105; } else { goto L102; } L102: idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; cr2 = wa1[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1] + wa1[i__ - 1] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1]; ci2 = wa1[i__ - 2] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1] - wa1[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1]; cr3 = wa2[i__ - 2] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1] + wa2[i__ - 1] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1]; ci3 = wa2[i__ - 2] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1] - wa2[ i__ - 1] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1]; cr4 = wa3[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 2)) * cc_dim1] + wa3[i__ - 1] * cc[i__ + (k + (cc_dim2 << 2)) * cc_dim1]; ci4 = wa3[i__ - 2] * cc[i__ + (k + (cc_dim2 << 2)) * cc_dim1] - wa3[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 2)) * cc_dim1]; tr1 = cr2 + cr4; tr4 = cr4 - cr2; ti1 = ci2 + ci4; ti4 = ci2 - ci4; ti2 = cc[i__ + (k + cc_dim2) * cc_dim1] + ci3; ti3 = cc[i__ + (k + cc_dim2) * cc_dim1] - ci3; tr2 = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + cr3; tr3 = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] - cr3; ch[i__ - 1 + ((k << 2) + 1) * ch_dim1] = tr1 + tr2; ch[ic - 1 + ((k << 2) + 4) * ch_dim1] = tr2 - tr1; ch[i__ + ((k << 2) + 1) * ch_dim1] = ti1 + ti2; ch[ic + ((k << 2) + 4) * ch_dim1] = ti1 - ti2; ch[i__ - 1 + ((k << 2) + 3) * ch_dim1] = ti4 + tr3; ch[ic - 1 + ((k << 2) + 2) * ch_dim1] = tr3 - ti4; ch[i__ + ((k << 2) + 3) * ch_dim1] = tr4 + ti3; ch[ic + ((k << 2) + 2) * ch_dim1] = tr4 - ti3; /* L103: */ } /* L104: */ } if (*ido % 2 == 1) { return 0; } L105: i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti1 = -hsqt2 * (cc[*ido + (k + (cc_dim2 << 1)) * cc_dim1] + cc[*ido + (k + (cc_dim2 << 2)) * cc_dim1]); tr1 = hsqt2 * (cc[*ido + (k + (cc_dim2 << 1)) * cc_dim1] - cc[*ido + ( k + (cc_dim2 << 2)) * cc_dim1]); ch[*ido + ((k << 2) + 1) * ch_dim1] = tr1 + cc[*ido + (k + cc_dim2) * cc_dim1]; ch[*ido + ((k << 2) + 3) * ch_dim1] = cc[*ido + (k + cc_dim2) * cc_dim1] - tr1; ch[((k << 2) + 2) * ch_dim1 + 1] = ti1 - cc[*ido + (k + cc_dim2 * 3) * cc_dim1]; ch[((k << 2) + 4) * ch_dim1 + 1] = ti1 + cc[*ido + (k + cc_dim2 * 3) * cc_dim1]; /* L106: */ } L107: return 0; } /* radf4_ */ /* Subroutine */ int radf5_(integer *ido, integer *l1, real *cc, real *ch, real *wa1, real *wa2, real *wa3, real *wa4) { /* Initialized data */ static real tr11 = .309016994374947f; static real ti11 = .951056516295154f; static real tr12 = -.809016994374947f; static real ti12 = .587785252292473f; /* System generated locals */ integer cc_dim1, cc_dim2, cc_offSet, ch_dim1, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; real ci2, di2, ci4, ci5, di3, di4, di5, ci3, cr2, cr3, dr2, dr3, dr4, dr5, cr5, cr4, ti2, ti3, ti5, ti4, tr2, tr3, tr4, tr5; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_offSet = 1 + ch_dim1 * 6; ch -= ch_offSet; cc_dim1 = *ido; cc_dim2 = *l1; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; --wa1; --wa2; --wa3; --wa4; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { cr2 = cc[(k + cc_dim2 * 5) * cc_dim1 + 1] + cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]; ci5 = cc[(k + cc_dim2 * 5) * cc_dim1 + 1] - cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]; cr3 = cc[(k + (cc_dim2 << 2)) * cc_dim1 + 1] + cc[(k + cc_dim2 * 3) * cc_dim1 + 1]; ci4 = cc[(k + (cc_dim2 << 2)) * cc_dim1 + 1] - cc[(k + cc_dim2 * 3) * cc_dim1 + 1]; ch[(k * 5 + 1) * ch_dim1 + 1] = cc[(k + cc_dim2) * cc_dim1 + 1] + cr2 + cr3; ch[*ido + (k * 5 + 2) * ch_dim1] = cc[(k + cc_dim2) * cc_dim1 + 1] + tr11 * cr2 + tr12 * cr3; ch[(k * 5 + 3) * ch_dim1 + 1] = ti11 * ci5 + ti12 * ci4; ch[*ido + (k * 5 + 4) * ch_dim1] = cc[(k + cc_dim2) * cc_dim1 + 1] + tr12 * cr2 + tr11 * cr3; ch[(k * 5 + 5) * ch_dim1 + 1] = ti12 * ci5 - ti11 * ci4; /* L101: */ } if (*ido == 1) { return 0; } idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; dr2 = wa1[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1] + wa1[i__ - 1] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1]; di2 = wa1[i__ - 2] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1] - wa1[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1]; dr3 = wa2[i__ - 2] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1] + wa2[i__ - 1] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1]; di3 = wa2[i__ - 2] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1] - wa2[ i__ - 1] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1]; dr4 = wa3[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 2)) * cc_dim1] + wa3[i__ - 1] * cc[i__ + (k + (cc_dim2 << 2)) * cc_dim1]; di4 = wa3[i__ - 2] * cc[i__ + (k + (cc_dim2 << 2)) * cc_dim1] - wa3[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 2)) * cc_dim1]; dr5 = wa4[i__ - 2] * cc[i__ - 1 + (k + cc_dim2 * 5) * cc_dim1] + wa4[i__ - 1] * cc[i__ + (k + cc_dim2 * 5) * cc_dim1]; di5 = wa4[i__ - 2] * cc[i__ + (k + cc_dim2 * 5) * cc_dim1] - wa4[ i__ - 1] * cc[i__ - 1 + (k + cc_dim2 * 5) * cc_dim1]; cr2 = dr2 + dr5; ci5 = dr5 - dr2; cr5 = di2 - di5; ci2 = di2 + di5; cr3 = dr3 + dr4; ci4 = dr4 - dr3; cr4 = di3 - di4; ci3 = di3 + di4; ch[i__ - 1 + (k * 5 + 1) * ch_dim1] = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + cr2 + cr3; ch[i__ + (k * 5 + 1) * ch_dim1] = cc[i__ + (k + cc_dim2) * cc_dim1] + ci2 + ci3; tr2 = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + tr11 * cr2 + tr12 * cr3; ti2 = cc[i__ + (k + cc_dim2) * cc_dim1] + tr11 * ci2 + tr12 * ci3; tr3 = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + tr12 * cr2 + tr11 * cr3; ti3 = cc[i__ + (k + cc_dim2) * cc_dim1] + tr12 * ci2 + tr11 * ci3; tr5 = ti11 * cr5 + ti12 * cr4; ti5 = ti11 * ci5 + ti12 * ci4; tr4 = ti12 * cr5 - ti11 * cr4; ti4 = ti12 * ci5 - ti11 * ci4; ch[i__ - 1 + (k * 5 + 3) * ch_dim1] = tr2 + tr5; ch[ic - 1 + (k * 5 + 2) * ch_dim1] = tr2 - tr5; ch[i__ + (k * 5 + 3) * ch_dim1] = ti2 + ti5; ch[ic + (k * 5 + 2) * ch_dim1] = ti5 - ti2; ch[i__ - 1 + (k * 5 + 5) * ch_dim1] = tr3 + tr4; ch[ic - 1 + (k * 5 + 4) * ch_dim1] = tr3 - tr4; ch[i__ + (k * 5 + 5) * ch_dim1] = ti3 + ti4; ch[ic + (k * 5 + 4) * ch_dim1] = ti4 - ti3; /* L102: */ } /* L103: */ } return 0; } /* radf5_ */ /* Subroutine */ int radfg_(integer *ido, integer *ip, integer *l1, integer * idl1, real *cc, real *c1, real *c2, real *ch, real *ch2, real *wa) { /* Initialized data */ static real tpi = 6.28318530717959f; /* System generated locals */ integer ch_dim1, ch_dim2, ch_offSet, cc_dim1, cc_dim2, cc_offSet, c1_dim1, c1_dim2, c1_offSet, c2_dim1, c2_offSet, ch2_dim1, ch2_offSet, i__1, i__2, i__3; /* Builtin functions */ /* Local variables */ integer i__, j, k, l, j2, ic, jc, lc, ik, is; real dc2, ai1, ai2, ar1, ar2, ds2; integer nbd; real dcp, arg, dsp, ar1h, ar2h; integer idp2, ipp2, idij, ipph; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; c1_dim1 = *ido; c1_dim2 = *l1; c1_offSet = 1 + c1_dim1 * (1 + c1_dim2); c1 -= c1_offSet; cc_dim1 = *ido; cc_dim2 = *ip; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; ch2_dim1 = *idl1; ch2_offSet = 1 + ch2_dim1; ch2 -= ch2_offSet; c2_dim1 = *idl1; c2_offSet = 1 + c2_dim1; c2 -= c2_offSet; --wa; /* Function Body */ arg = tpi / (real) (*ip); dcp = cos(arg); dsp = sin(arg); ipph = (*ip + 1) / 2; ipp2 = *ip + 2; idp2 = *ido + 2; nbd = (*ido - 1) / 2; if (*ido == 1) { goto L119; } i__1 = *idl1; for (ik = 1; ik <= i__1; ++ik) { ch2[ik + ch2_dim1] = c2[ik + c2_dim1]; /* L101: */ } i__1 = *ip; for (j = 2; j <= i__1; ++j) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[(k + j * ch_dim2) * ch_dim1 + 1] = c1[(k + j * c1_dim2) * c1_dim1 + 1]; /* L102: */ } /* L103: */ } if (nbd > *l1) { goto L107; } is = -(*ido); i__1 = *ip; for (j = 2; j <= i__1; ++j) { is += *ido; idij = is; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { idij += 2; i__3 = *l1; for (k = 1; k <= i__3; ++k) { ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = wa[idij - 1] * c1[ i__ - 1 + (k + j * c1_dim2) * c1_dim1] + wa[idij] * c1[i__ + (k + j * c1_dim2) * c1_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = wa[idij - 1] * c1[i__ + (k + j * c1_dim2) * c1_dim1] - wa[idij] * c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1]; /* L104: */ } /* L105: */ } /* L106: */ } goto L111; L107: is = -(*ido); i__1 = *ip; for (j = 2; j <= i__1; ++j) { is += *ido; i__2 = *l1; for (k = 1; k <= i__2; ++k) { idij = is; i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { idij += 2; ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = wa[idij - 1] * c1[ i__ - 1 + (k + j * c1_dim2) * c1_dim1] + wa[idij] * c1[i__ + (k + j * c1_dim2) * c1_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = wa[idij - 1] * c1[i__ + (k + j * c1_dim2) * c1_dim1] - wa[idij] * c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1]; /* L108: */ } /* L109: */ } /* L110: */ } L111: if (nbd < *l1) { goto L115; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] + ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] - ch[i__ + (k + jc * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] + ch[i__ + (k + jc * ch_dim2) * ch_dim1]; c1[i__ + (k + jc * c1_dim2) * c1_dim1] = ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] - ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L112: */ } /* L113: */ } /* L114: */ } goto L121; L115: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { i__3 = *l1; for (k = 1; k <= i__3; ++k) { c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] + ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] - ch[i__ + (k + jc * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] + ch[i__ + (k + jc * ch_dim2) * ch_dim1]; c1[i__ + (k + jc * c1_dim2) * c1_dim1] = ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] - ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L116: */ } /* L117: */ } /* L118: */ } goto L121; L119: i__1 = *idl1; for (ik = 1; ik <= i__1; ++ik) { c2[ik + c2_dim1] = ch2[ik + ch2_dim1]; /* L120: */ } L121: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { c1[(k + j * c1_dim2) * c1_dim1 + 1] = ch[(k + j * ch_dim2) * ch_dim1 + 1] + ch[(k + jc * ch_dim2) * ch_dim1 + 1]; c1[(k + jc * c1_dim2) * c1_dim1 + 1] = ch[(k + jc * ch_dim2) * ch_dim1 + 1] - ch[(k + j * ch_dim2) * ch_dim1 + 1]; /* L122: */ } /* L123: */ } ar1 = 1.f; ai1 = 0.f; i__1 = ipph; for (l = 2; l <= i__1; ++l) { lc = ipp2 - l; ar1h = dcp * ar1 - dsp * ai1; ai1 = dcp * ai1 + dsp * ar1; ar1 = ar1h; i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { ch2[ik + l * ch2_dim1] = c2[ik + c2_dim1] + ar1 * c2[ik + ( c2_dim1 << 1)]; ch2[ik + lc * ch2_dim1] = ai1 * c2[ik + *ip * c2_dim1]; /* L124: */ } dc2 = ar1; ds2 = ai1; ar2 = ar1; ai2 = ai1; i__2 = ipph; for (j = 3; j <= i__2; ++j) { jc = ipp2 - j; ar2h = dc2 * ar2 - ds2 * ai2; ai2 = dc2 * ai2 + ds2 * ar2; ar2 = ar2h; i__3 = *idl1; for (ik = 1; ik <= i__3; ++ik) { ch2[ik + l * ch2_dim1] += ar2 * c2[ik + j * c2_dim1]; ch2[ik + lc * ch2_dim1] += ai2 * c2[ik + jc * c2_dim1]; /* L125: */ } /* L126: */ } /* L127: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { ch2[ik + ch2_dim1] += c2[ik + j * c2_dim1]; /* L128: */ } /* L129: */ } if (*ido < *l1) { goto L132; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { cc[i__ + (k * cc_dim2 + 1) * cc_dim1] = ch[i__ + (k + ch_dim2) * ch_dim1]; /* L130: */ } /* L131: */ } goto L135; L132: i__1 = *ido; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { cc[i__ + (k * cc_dim2 + 1) * cc_dim1] = ch[i__ + (k + ch_dim2) * ch_dim1]; /* L133: */ } /* L134: */ } L135: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; j2 = j + j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { cc[*ido + (j2 - 2 + k * cc_dim2) * cc_dim1] = ch[(k + j * ch_dim2) * ch_dim1 + 1]; cc[(j2 - 1 + k * cc_dim2) * cc_dim1 + 1] = ch[(k + jc * ch_dim2) * ch_dim1 + 1]; /* L136: */ } /* L137: */ } if (*ido == 1) { return 0; } if (nbd < *l1) { goto L141; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; j2 = j + j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { ic = idp2 - i__; cc[i__ - 1 + (j2 - 1 + k * cc_dim2) * cc_dim1] = ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] + ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; cc[ic - 1 + (j2 - 2 + k * cc_dim2) * cc_dim1] = ch[i__ - 1 + ( k + j * ch_dim2) * ch_dim1] - ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; cc[i__ + (j2 - 1 + k * cc_dim2) * cc_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] + ch[i__ + (k + jc * ch_dim2) * ch_dim1]; cc[ic + (j2 - 2 + k * cc_dim2) * cc_dim1] = ch[i__ + (k + jc * ch_dim2) * ch_dim1] - ch[i__ + (k + j * ch_dim2) * ch_dim1]; /* L138: */ } /* L139: */ } /* L140: */ } return 0; L141: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; j2 = j + j; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; i__3 = *l1; for (k = 1; k <= i__3; ++k) { cc[i__ - 1 + (j2 - 1 + k * cc_dim2) * cc_dim1] = ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] + ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; cc[ic - 1 + (j2 - 2 + k * cc_dim2) * cc_dim1] = ch[i__ - 1 + ( k + j * ch_dim2) * ch_dim1] - ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; cc[i__ + (j2 - 1 + k * cc_dim2) * cc_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] + ch[i__ + (k + jc * ch_dim2) * ch_dim1]; cc[ic + (j2 - 2 + k * cc_dim2) * cc_dim1] = ch[i__ + (k + jc * ch_dim2) * ch_dim1] - ch[i__ + (k + j * ch_dim2) * ch_dim1]; /* L142: */ } /* L143: */ } /* L144: */ } return 0; } /* radfg_ */ /* Subroutine */ int rfftf1_(int *n, float *c__, float *ch, float *wa, int *ifac) { /* System generated locals */ integer i__1; /* Local variables */ integer i__, k1, l1, l2, na, kh, nf, ip, iw, ix2, ix3, ix4, ido, idl1; extern /* Subroutine */ int radf2_(integer *, integer *, real *, real *, real *), radf3_(integer *, integer *, real *, real *, real *, real *), radf4_(integer *, integer *, real *, real *, real *, real *, real *), radf5_(integer *, integer *, real *, real *, real *, real *, real *, real *), radfg_(integer *, integer *, integer *, integer *, real *, real *, real *, real *, real *, real *); /* Parameter adjustments */ --ifac; --wa; --ch; --c__; /* Function Body */ nf = ifac[2]; na = 1; l2 = *n; iw = *n; i__1 = nf; for (k1 = 1; k1 <= i__1; ++k1) { kh = nf - k1; ip = ifac[kh + 3]; l1 = l2 / ip; ido = *n / l2; idl1 = ido * l1; iw -= (ip - 1) * ido; na = 1 - na; if (ip != 4) { goto L102; } ix2 = iw + ido; ix3 = ix2 + ido; if (na != 0) { goto L101; } radf4_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3]); goto L110; L101: radf4_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3]); goto L110; L102: if (ip != 2) { goto L104; } if (na != 0) { goto L103; } radf2_(&ido, &l1, &c__[1], &ch[1], &wa[iw]); goto L110; L103: radf2_(&ido, &l1, &ch[1], &c__[1], &wa[iw]); goto L110; L104: if (ip != 3) { goto L106; } ix2 = iw + ido; if (na != 0) { goto L105; } radf3_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2]); goto L110; L105: radf3_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2]); goto L110; L106: if (ip != 5) { goto L108; } ix2 = iw + ido; ix3 = ix2 + ido; ix4 = ix3 + ido; if (na != 0) { goto L107; } radf5_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); goto L110; L107: radf5_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); goto L110; L108: if (ido == 1) { na = 1 - na; } if (na != 0) { goto L109; } radfg_(&ido, &ip, &l1, &idl1, &c__[1], &c__[1], &c__[1], &ch[1], &ch[ 1], &wa[iw]); na = 1; goto L110; L109: radfg_(&ido, &ip, &l1, &idl1, &ch[1], &ch[1], &ch[1], &c__[1], &c__[1] , &wa[iw]); na = 0; L110: l2 = l1; /* L111: */ } if (na == 1) { return 0; } i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { c__[i__] = ch[i__]; /* L112: */ } return 0; } /* rfftf1_ */ /* Subroutine */ int rffti1_(int *n, float *wa, int *ifac) { /* Initialized data */ static integer ntryh[4] = { 4,2,3,5 }; /* System generated locals */ integer i__1, i__2, i__3; /* Builtin functions */ /* Local variables */ integer i__, j, k1, l1, l2, ib; real fi; integer ld, ii, nf, ip, nl, is, nq, nr; real arg; integer ido, ipm; real tpi; integer nfm1; real argh; integer ntry = 0; real argld; /* Parameter adjustments */ --ifac; --wa; /* Function Body */ nl = *n; nf = 0; j = 0; L101: ++j; if (j - 4 <= 0) { goto L102; } else { goto L103; } L102: ntry = ntryh[j - 1]; goto L104; L103: ntry += 2; L104: nq = nl / ntry; nr = nl - ntry * nq; if (nr != 0) { goto L101; } else { goto L105; } L105: ++nf; ifac[nf + 2] = ntry; nl = nq; if (ntry != 2) { goto L107; } if (nf == 1) { goto L107; } i__1 = nf; for (i__ = 2; i__ <= i__1; ++i__) { ib = nf - i__ + 2; ifac[ib + 2] = ifac[ib + 1]; /* L106: */ } ifac[3] = 2; L107: if (nl != 1) { goto L104; } ifac[1] = *n; ifac[2] = nf; tpi = 6.28318530717959f; argh = tpi / (real) (*n); is = 0; nfm1 = nf - 1; l1 = 1; if (nfm1 == 0) { return 0; } i__1 = nfm1; for (k1 = 1; k1 <= i__1; ++k1) { ip = ifac[k1 + 2]; ld = 0; l2 = l1 * ip; ido = *n / l2; ipm = ip - 1; i__2 = ipm; for (j = 1; j <= i__2; ++j) { ld += l1; i__ = is; argld = (real) ld * argh; fi = 0.f; i__3 = ido; for (ii = 3; ii <= i__3; ii += 2) { i__ += 2; fi += 1.f; arg = fi * argld; wa[i__ - 1] = cos(arg); wa[i__] = sin(arg); /* L108: */ } is += ido; /* L109: */ } l1 = l2; /* L110: */ } return 0; } /* rffti1_ */ /* Subroutine */ int cffti1_(int *n, float *wa, int *ifac) { /* Initialized data */ static integer ntryh[4] = { 3,4,2,5 }; /* System generated locals */ integer i__1, i__2, i__3; /* Builtin functions */ /* Local variables */ integer i__, j, i1, k1, l1, l2, ib; real fi; integer ld, ii, nf, ip, nl, nq, nr; real arg; integer ido, ipm; real tpi, argh; integer idot, ntry = 0; real argld; /* Parameter adjustments */ --ifac; --wa; /* Function Body */ nl = *n; nf = 0; j = 0; L101: ++j; if (j - 4 <= 0) { goto L102; } else { goto L103; } L102: ntry = ntryh[j - 1]; goto L104; L103: ntry += 2; L104: nq = nl / ntry; nr = nl - ntry * nq; if (nr != 0) { goto L101; } else { goto L105; } L105: ++nf; ifac[nf + 2] = ntry; nl = nq; if (ntry != 2) { goto L107; } if (nf == 1) { goto L107; } i__1 = nf; for (i__ = 2; i__ <= i__1; ++i__) { ib = nf - i__ + 2; ifac[ib + 2] = ifac[ib + 1]; /* L106: */ } ifac[3] = 2; L107: if (nl != 1) { goto L104; } ifac[1] = *n; ifac[2] = nf; tpi = 6.28318530717959f; argh = tpi / (real) (*n); i__ = 2; l1 = 1; i__1 = nf; for (k1 = 1; k1 <= i__1; ++k1) { ip = ifac[k1 + 2]; ld = 0; l2 = l1 * ip; ido = *n / l2; idot = ido + ido + 2; ipm = ip - 1; i__2 = ipm; for (j = 1; j <= i__2; ++j) { i1 = i__; wa[i__ - 1] = 1.f; wa[i__] = 0.f; ld += l1; fi = 0.f; argld = (real) ld * argh; i__3 = idot; for (ii = 4; ii <= i__3; ii += 2) { i__ += 2; fi += 1.f; arg = fi * argld; wa[i__ - 1] = cos(arg); wa[i__] = sin(arg); /* L108: */ } if (ip <= 5) { goto L109; } wa[i1 - 1] = wa[i__ - 1]; wa[i1] = wa[i__]; L109: ; } l1 = l2; /* L110: */ } return 0; } /* cffti1_ */ /* Subroutine */ int zfftb1_(integer *n, doublereal *c__, doublereal *ch, doublereal *wa, integer *ifac) { /* System generated locals */ integer i__1; /* Local variables */ integer i__, k1, l1, l2, n2, na, nf, ip, iw, ix2, ix3, ix4, nac, ido, idl1, idot; extern /* Subroutine */ int padsb_(integer *, integer *, integer *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *), padsb2_(integer *, integer *, doublereal *, doublereal *, doublereal *), padsb3_( integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *), padsb4_(integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *), padsb5_( integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *); /* Parameter adjustments */ --ifac; --wa; --ch; --c__; /* Function Body */ nf = ifac[2]; na = 0; l1 = 1; iw = 1; i__1 = nf; for (k1 = 1; k1 <= i__1; ++k1) { ip = ifac[k1 + 2]; l2 = ip * l1; ido = *n / l2; idot = ido + ido; idl1 = idot * l1; if (ip != 4) { goto L103; } ix2 = iw + idot; ix3 = ix2 + idot; if (na != 0) { goto L101; } padsb4_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3]); goto L102; L101: padsb4_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3]); L102: na = 1 - na; goto L115; L103: if (ip != 2) { goto L106; } if (na != 0) { goto L104; } padsb2_(&idot, &l1, &c__[1], &ch[1], &wa[iw]); goto L105; L104: padsb2_(&idot, &l1, &ch[1], &c__[1], &wa[iw]); L105: na = 1 - na; goto L115; L106: if (ip != 3) { goto L109; } ix2 = iw + idot; if (na != 0) { goto L107; } padsb3_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2]); goto L108; L107: padsb3_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2]); L108: na = 1 - na; goto L115; L109: if (ip != 5) { goto L112; } ix2 = iw + idot; ix3 = ix2 + idot; ix4 = ix3 + idot; if (na != 0) { goto L110; } padsb5_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); goto L111; L110: padsb5_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); L111: na = 1 - na; goto L115; L112: if (na != 0) { goto L113; } padsb_(&nac, &idot, &ip, &l1, &idl1, &c__[1], &c__[1], &c__[1], &ch[1] , &ch[1], &wa[iw]); goto L114; L113: padsb_(&nac, &idot, &ip, &l1, &idl1, &ch[1], &ch[1], &ch[1], &c__[1], &c__[1], &wa[iw]); L114: if (nac != 0) { na = 1 - na; } L115: l1 = l2; iw += (ip - 1) * idot; /* L116: */ } if (na == 0) { return 0; } n2 = *n + *n; i__1 = n2; for (i__ = 1; i__ <= i__1; ++i__) { c__[i__] = ch[i__]; /* L117: */ } return 0; } /* zfftb1_ */ /* Subroutine */ int padsb_(integer *nac, integer *ido, integer *ip, integer * l1, integer *idl1, doublereal *cc, doublereal *c1, doublereal *c2, doublereal *ch, doublereal *ch2, doublereal *wa) { /* System generated locals */ integer ch_dim1, ch_dim2, ch_offSet, cc_dim1, cc_dim2, cc_offSet, c1_dim1, c1_dim2, c1_offSet, c2_dim1, c2_offSet, ch2_dim1, ch2_offSet, i__1, i__2, i__3; /* Local variables */ integer i__, j, k, l, jc, lc, ik, nt, idj, idl, inc, idp; doublereal wai, war; integer ipp2, idij, idlj, idot, ipph; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; c1_dim1 = *ido; c1_dim2 = *l1; c1_offSet = 1 + c1_dim1 * (1 + c1_dim2); c1 -= c1_offSet; cc_dim1 = *ido; cc_dim2 = *ip; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; ch2_dim1 = *idl1; ch2_offSet = 1 + ch2_dim1; ch2 -= ch2_offSet; c2_dim1 = *idl1; c2_offSet = 1 + c2_dim1; c2 -= c2_offSet; --wa; /* Function Body */ idot = *ido / 2; nt = *ip * *idl1; ipp2 = *ip + 2; ipph = (*ip + 1) / 2; idp = *ip * *ido; if (*ido < *l1) { goto L106; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 1; i__ <= i__3; ++i__) { ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] + cc[i__ + (jc + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] - cc[i__ + (jc + k * cc_dim2) * cc_dim1]; /* L101: */ } /* L102: */ } /* L103: */ } i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L104: */ } /* L105: */ } goto L112; L106: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { i__3 = *l1; for (k = 1; k <= i__3; ++k) { ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] + cc[i__ + (jc + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] - cc[i__ + (jc + k * cc_dim2) * cc_dim1]; /* L107: */ } /* L108: */ } /* L109: */ } i__1 = *ido; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L110: */ } /* L111: */ } L112: idl = 2 - *ido; inc = 0; i__1 = ipph; for (l = 2; l <= i__1; ++l) { lc = ipp2 - l; idl += *ido; i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { c2[ik + l * c2_dim1] = ch2[ik + ch2_dim1] + wa[idl - 1] * ch2[ik + (ch2_dim1 << 1)]; c2[ik + lc * c2_dim1] = wa[idl] * ch2[ik + *ip * ch2_dim1]; /* L113: */ } idlj = idl; inc += *ido; i__2 = ipph; for (j = 3; j <= i__2; ++j) { jc = ipp2 - j; idlj += inc; if (idlj > idp) { idlj -= idp; } war = wa[idlj - 1]; wai = wa[idlj]; i__3 = *idl1; for (ik = 1; ik <= i__3; ++ik) { c2[ik + l * c2_dim1] += war * ch2[ik + j * ch2_dim1]; c2[ik + lc * c2_dim1] += wai * ch2[ik + jc * ch2_dim1]; /* L114: */ } /* L115: */ } /* L116: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { ch2[ik + ch2_dim1] += ch2[ik + j * ch2_dim1]; /* L117: */ } /* L118: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *idl1; for (ik = 2; ik <= i__2; ik += 2) { ch2[ik - 1 + j * ch2_dim1] = c2[ik - 1 + j * c2_dim1] - c2[ik + jc * c2_dim1]; ch2[ik - 1 + jc * ch2_dim1] = c2[ik - 1 + j * c2_dim1] + c2[ik + jc * c2_dim1]; ch2[ik + j * ch2_dim1] = c2[ik + j * c2_dim1] + c2[ik - 1 + jc * c2_dim1]; ch2[ik + jc * ch2_dim1] = c2[ik + j * c2_dim1] - c2[ik - 1 + jc * c2_dim1]; /* L119: */ } /* L120: */ } *nac = 1; if (*ido == 2) { return 0; } *nac = 0; i__1 = *idl1; for (ik = 1; ik <= i__1; ++ik) { c2[ik + c2_dim1] = ch2[ik + ch2_dim1]; /* L121: */ } i__1 = *ip; for (j = 2; j <= i__1; ++j) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { c1[(k + j * c1_dim2) * c1_dim1 + 1] = ch[(k + j * ch_dim2) * ch_dim1 + 1]; c1[(k + j * c1_dim2) * c1_dim1 + 2] = ch[(k + j * ch_dim2) * ch_dim1 + 2]; /* L122: */ } /* L123: */ } if (idot > *l1) { goto L127; } idij = 0; i__1 = *ip; for (j = 2; j <= i__1; ++j) { idij += 2; i__2 = *ido; for (i__ = 4; i__ <= i__2; i__ += 2) { idij += 2; i__3 = *l1; for (k = 1; k <= i__3; ++k) { c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L124: */ } /* L125: */ } /* L126: */ } return 0; L127: idj = 2 - *ido; i__1 = *ip; for (j = 2; j <= i__1; ++j) { idj += *ido; i__2 = *l1; for (k = 1; k <= i__2; ++k) { idij = idj; i__3 = *ido; for (i__ = 4; i__ <= i__3; i__ += 2) { idij += 2; c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L128: */ } /* L129: */ } /* L130: */ } return 0; } /* padsb_ */ /* Subroutine */ int padsb2_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1) { /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; doublereal ti2, tr2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 3; cc -= cc_offSet; --wa1; /* Function Body */ if (*ido > 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[(k + ch_dim2) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] + cc[((k << 1) + 2) * cc_dim1 + 1]; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] - cc[((k << 1) + 2) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[((k << 1) + 1) * cc_dim1 + 2] + cc[((k << 1) + 2) * cc_dim1 + 2]; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = cc[((k << 1) + 1) * cc_dim1 + 2] - cc[((k << 1) + 2) * cc_dim1 + 2]; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] + cc[i__ - 1 + ((k << 1) + 2) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] - cc[i__ - 1 + ((k << 1) + 2) * cc_dim1]; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + ((k << 1) + 1) * cc_dim1] + cc[i__ + ((k << 1) + 2) * cc_dim1]; ti2 = cc[i__ + ((k << 1) + 1) * cc_dim1] - cc[i__ + ((k << 1) + 2) * cc_dim1]; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * ti2 + wa1[i__] * tr2; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * tr2 - wa1[i__] * ti2; /* L103: */ } /* L104: */ } return 0; } /* padsb2_ */ /* Subroutine */ int padsb3_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2) { /* Initialized data */ static doublereal taur = -.5; static doublereal taui = .86602540378443864676; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; doublereal ci2, ci3, di2, di3, cr2, cr3, dr2, dr3, ti2, tr2; /* *** TAUI IS SQRT(3)/2 *** */ /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + (cc_dim1 << 2); cc -= cc_offSet; --wa1; --wa2; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { tr2 = cc[(k * 3 + 2) * cc_dim1 + 1] + cc[(k * 3 + 3) * cc_dim1 + 1]; cr2 = cc[(k * 3 + 1) * cc_dim1 + 1] + taur * tr2; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 3 + 1) * cc_dim1 + 1] + tr2; ti2 = cc[(k * 3 + 2) * cc_dim1 + 2] + cc[(k * 3 + 3) * cc_dim1 + 2]; ci2 = cc[(k * 3 + 1) * cc_dim1 + 2] + taur * ti2; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[(k * 3 + 1) * cc_dim1 + 2] + ti2; cr3 = taui * (cc[(k * 3 + 2) * cc_dim1 + 1] - cc[(k * 3 + 3) * cc_dim1 + 1]); ci3 = taui * (cc[(k * 3 + 2) * cc_dim1 + 2] - cc[(k * 3 + 3) * cc_dim1 + 2]); ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci3; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr2 + ci3; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ci2 + cr3; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ci2 - cr3; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { tr2 = cc[i__ - 1 + (k * 3 + 2) * cc_dim1] + cc[i__ - 1 + (k * 3 + 3) * cc_dim1]; cr2 = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + taur * tr2; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + tr2; ti2 = cc[i__ + (k * 3 + 2) * cc_dim1] + cc[i__ + (k * 3 + 3) * cc_dim1]; ci2 = cc[i__ + (k * 3 + 1) * cc_dim1] + taur * ti2; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 3 + 1) * cc_dim1] + ti2; cr3 = taui * (cc[i__ - 1 + (k * 3 + 2) * cc_dim1] - cc[i__ - 1 + ( k * 3 + 3) * cc_dim1]); ci3 = taui * (cc[i__ + (k * 3 + 2) * cc_dim1] - cc[i__ + (k * 3 + 3) * cc_dim1]); dr2 = cr2 - ci3; dr3 = cr2 + ci3; di2 = ci2 + cr3; di3 = ci2 - cr3; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * di2 + wa1[i__] * dr2; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * dr2 - wa1[i__] * di2; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * di3 + wa2[ i__] * dr3; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * dr3 - wa2[i__] * di3; /* L103: */ } /* L104: */ } return 0; } /* padsb3_ */ /* Subroutine */ int padsb4_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2, doublereal *wa3) { /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; doublereal ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 5; cc -= cc_offSet; --wa1; --wa2; --wa3; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti1 = cc[((k << 2) + 1) * cc_dim1 + 2] - cc[((k << 2) + 3) * cc_dim1 + 2]; ti2 = cc[((k << 2) + 1) * cc_dim1 + 2] + cc[((k << 2) + 3) * cc_dim1 + 2]; tr4 = cc[((k << 2) + 4) * cc_dim1 + 2] - cc[((k << 2) + 2) * cc_dim1 + 2]; ti3 = cc[((k << 2) + 2) * cc_dim1 + 2] + cc[((k << 2) + 4) * cc_dim1 + 2]; tr1 = cc[((k << 2) + 1) * cc_dim1 + 1] - cc[((k << 2) + 3) * cc_dim1 + 1]; tr2 = cc[((k << 2) + 1) * cc_dim1 + 1] + cc[((k << 2) + 3) * cc_dim1 + 1]; ti4 = cc[((k << 2) + 2) * cc_dim1 + 1] - cc[((k << 2) + 4) * cc_dim1 + 1]; tr3 = cc[((k << 2) + 2) * cc_dim1 + 1] + cc[((k << 2) + 4) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 1] = tr2 + tr3; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = tr2 - tr3; ch[(k + ch_dim2) * ch_dim1 + 2] = ti2 + ti3; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ti2 - ti3; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = tr1 + tr4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = tr1 - tr4; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ti1 + ti4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 2] = ti1 - ti4; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ti1 = cc[i__ + ((k << 2) + 1) * cc_dim1] - cc[i__ + ((k << 2) + 3) * cc_dim1]; ti2 = cc[i__ + ((k << 2) + 1) * cc_dim1] + cc[i__ + ((k << 2) + 3) * cc_dim1]; ti3 = cc[i__ + ((k << 2) + 2) * cc_dim1] + cc[i__ + ((k << 2) + 4) * cc_dim1]; tr4 = cc[i__ + ((k << 2) + 4) * cc_dim1] - cc[i__ + ((k << 2) + 2) * cc_dim1]; tr1 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] - cc[i__ - 1 + ((k << 2) + 3) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] + cc[i__ - 1 + ((k << 2) + 3) * cc_dim1]; ti4 = cc[i__ - 1 + ((k << 2) + 2) * cc_dim1] - cc[i__ - 1 + ((k << 2) + 4) * cc_dim1]; tr3 = cc[i__ - 1 + ((k << 2) + 2) * cc_dim1] + cc[i__ - 1 + ((k << 2) + 4) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = tr2 + tr3; cr3 = tr2 - tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = ti2 + ti3; ci3 = ti2 - ti3; cr2 = tr1 + tr4; cr4 = tr1 - tr4; ci2 = ti1 + ti4; ci4 = ti1 - ti4; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * cr2 - wa1[i__] * ci2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * ci2 + wa1[i__] * cr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * cr3 - wa2[i__] * ci3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * ci3 + wa2[ i__] * cr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * cr4 - wa3[i__] * ci4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * ci4 + wa3[i__] * cr4; /* L103: */ } /* L104: */ } return 0; } /* padsb4_ */ /* Subroutine */ int padsb5_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2, doublereal *wa3, doublereal *wa4) { /* Initialized data */ static doublereal tr11 = .3090169943749474241; static doublereal ti11 = .95105651629515357212; static doublereal tr12 = -.8090169943749474241; static doublereal ti12 = .58778525229247312917; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; doublereal ci2, ci3, ci4, ci5, di3, di4, di5, di2, cr2, cr3, cr5, cr4, ti2, ti3, ti4, ti5, dr3, dr4, dr5, dr2, tr2, tr3, tr4, tr5; /* *** TR11=COS(2*PI/5), TI11=SIN(2*PI/5) */ /* *** TR12=COS(4*PI/5), TI12=SIN(4*PI/5) */ /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 6; cc -= cc_offSet; --wa1; --wa2; --wa3; --wa4; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti5 = cc[(k * 5 + 2) * cc_dim1 + 2] - cc[(k * 5 + 5) * cc_dim1 + 2]; ti2 = cc[(k * 5 + 2) * cc_dim1 + 2] + cc[(k * 5 + 5) * cc_dim1 + 2]; ti4 = cc[(k * 5 + 3) * cc_dim1 + 2] - cc[(k * 5 + 4) * cc_dim1 + 2]; ti3 = cc[(k * 5 + 3) * cc_dim1 + 2] + cc[(k * 5 + 4) * cc_dim1 + 2]; tr5 = cc[(k * 5 + 2) * cc_dim1 + 1] - cc[(k * 5 + 5) * cc_dim1 + 1]; tr2 = cc[(k * 5 + 2) * cc_dim1 + 1] + cc[(k * 5 + 5) * cc_dim1 + 1]; tr4 = cc[(k * 5 + 3) * cc_dim1 + 1] - cc[(k * 5 + 4) * cc_dim1 + 1]; tr3 = cc[(k * 5 + 3) * cc_dim1 + 1] + cc[(k * 5 + 4) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 5 + 1) * cc_dim1 + 1] + tr2 + tr3; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[(k * 5 + 1) * cc_dim1 + 2] + ti2 + ti3; cr2 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr11 * tr2 + tr12 * tr3; ci2 = cc[(k * 5 + 1) * cc_dim1 + 2] + tr11 * ti2 + tr12 * ti3; cr3 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr12 * tr2 + tr11 * tr3; ci3 = cc[(k * 5 + 1) * cc_dim1 + 2] + tr12 * ti2 + tr11 * ti3; cr5 = ti11 * tr5 + ti12 * tr4; ci5 = ti11 * ti5 + ti12 * ti4; cr4 = ti12 * tr5 - ti11 * tr4; ci4 = ti12 * ti5 - ti11 * ti4; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci5; ch[(k + ch_dim2 * 5) * ch_dim1 + 1] = cr2 + ci5; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ci2 + cr5; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ci3 + cr4; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr3 - ci4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = cr3 + ci4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 2] = ci3 - cr4; ch[(k + ch_dim2 * 5) * ch_dim1 + 2] = ci2 - cr5; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ti5 = cc[i__ + (k * 5 + 2) * cc_dim1] - cc[i__ + (k * 5 + 5) * cc_dim1]; ti2 = cc[i__ + (k * 5 + 2) * cc_dim1] + cc[i__ + (k * 5 + 5) * cc_dim1]; ti4 = cc[i__ + (k * 5 + 3) * cc_dim1] - cc[i__ + (k * 5 + 4) * cc_dim1]; ti3 = cc[i__ + (k * 5 + 3) * cc_dim1] + cc[i__ + (k * 5 + 4) * cc_dim1]; tr5 = cc[i__ - 1 + (k * 5 + 2) * cc_dim1] - cc[i__ - 1 + (k * 5 + 5) * cc_dim1]; tr2 = cc[i__ - 1 + (k * 5 + 2) * cc_dim1] + cc[i__ - 1 + (k * 5 + 5) * cc_dim1]; tr4 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] - cc[i__ - 1 + (k * 5 + 4) * cc_dim1]; tr3 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] + cc[i__ - 1 + (k * 5 + 4) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr2 + tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 5 + 1) * cc_dim1] + ti2 + ti3; cr2 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr11 * tr2 + tr12 * tr3; ci2 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr11 * ti2 + tr12 * ti3; cr3 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr12 * tr2 + tr11 * tr3; ci3 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr12 * ti2 + tr11 * ti3; cr5 = ti11 * tr5 + ti12 * tr4; ci5 = ti11 * ti5 + ti12 * ti4; cr4 = ti12 * tr5 - ti11 * tr4; ci4 = ti12 * ti5 - ti11 * ti4; dr3 = cr3 - ci4; dr4 = cr3 + ci4; di3 = ci3 + cr4; di4 = ci3 - cr4; dr5 = cr2 + ci5; dr2 = cr2 - ci5; di5 = ci2 - cr5; di2 = ci2 + cr5; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * dr2 - wa1[i__] * di2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * di2 + wa1[i__] * dr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * dr3 - wa2[i__] * di3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * di3 + wa2[ i__] * dr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * dr4 - wa3[i__] * di4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * di4 + wa3[i__] * dr4; ch[i__ - 1 + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 1] * dr5 - wa4[i__] * di5; ch[i__ + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 1] * di5 + wa4[ i__] * dr5; /* L103: */ } /* L104: */ } return 0; } /* padsb5_ */ /* Subroutine */ int zfftf1_(integer *n, doublereal *c__, doublereal *ch, doublereal *wa, integer *ifac) { /* System generated locals */ integer i__1; /* Local variables */ integer i__, k1, l1, l2, n2, na, nf, ip, iw, ix2, ix3, ix4, nac, ido, idl1, idot; extern /* Subroutine */ int padsf_(integer *, integer *, integer *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *), padsf2_(integer *, integer *, doublereal *, doublereal *, doublereal *), padsf3_( integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *), padsf4_(integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *), padsf5_( integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *); /* Parameter adjustments */ --ifac; --wa; --ch; --c__; /* Function Body */ nf = ifac[2]; na = 0; l1 = 1; iw = 1; i__1 = nf; for (k1 = 1; k1 <= i__1; ++k1) { ip = ifac[k1 + 2]; l2 = ip * l1; ido = *n / l2; idot = ido + ido; idl1 = idot * l1; if (ip != 4) { goto L103; } ix2 = iw + idot; ix3 = ix2 + idot; if (na != 0) { goto L101; } padsf4_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3]); goto L102; L101: padsf4_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3]); L102: na = 1 - na; goto L115; L103: if (ip != 2) { goto L106; } if (na != 0) { goto L104; } padsf2_(&idot, &l1, &c__[1], &ch[1], &wa[iw]); goto L105; L104: padsf2_(&idot, &l1, &ch[1], &c__[1], &wa[iw]); L105: na = 1 - na; goto L115; L106: if (ip != 3) { goto L109; } ix2 = iw + idot; if (na != 0) { goto L107; } padsf3_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2]); goto L108; L107: padsf3_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2]); L108: na = 1 - na; goto L115; L109: if (ip != 5) { goto L112; } ix2 = iw + idot; ix3 = ix2 + idot; ix4 = ix3 + idot; if (na != 0) { goto L110; } padsf5_(&idot, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); goto L111; L110: padsf5_(&idot, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); L111: na = 1 - na; goto L115; L112: if (na != 0) { goto L113; } padsf_(&nac, &idot, &ip, &l1, &idl1, &c__[1], &c__[1], &c__[1], &ch[1] , &ch[1], &wa[iw]); goto L114; L113: padsf_(&nac, &idot, &ip, &l1, &idl1, &ch[1], &ch[1], &ch[1], &c__[1], &c__[1], &wa[iw]); L114: if (nac != 0) { na = 1 - na; } L115: l1 = l2; iw += (ip - 1) * idot; /* L116: */ } if (na == 0) { return 0; } n2 = *n + *n; i__1 = n2; for (i__ = 1; i__ <= i__1; ++i__) { c__[i__] = ch[i__]; /* L117: */ } return 0; } /* zfftf1_ */ /* Subroutine */ int padsf_(integer *nac, integer *ido, integer *ip, integer * l1, integer *idl1, doublereal *cc, doublereal *c1, doublereal *c2, doublereal *ch, doublereal *ch2, doublereal *wa) { /* System generated locals */ integer ch_dim1, ch_dim2, ch_offSet, cc_dim1, cc_dim2, cc_offSet, c1_dim1, c1_dim2, c1_offSet, c2_dim1, c2_offSet, ch2_dim1, ch2_offSet, i__1, i__2, i__3; /* Local variables */ integer i__, j, k, l, jc, lc, ik, nt, idj, idl, inc, idp; doublereal wai, war; integer ipp2, idij, idlj, idot, ipph; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; c1_dim1 = *ido; c1_dim2 = *l1; c1_offSet = 1 + c1_dim1 * (1 + c1_dim2); c1 -= c1_offSet; cc_dim1 = *ido; cc_dim2 = *ip; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; ch2_dim1 = *idl1; ch2_offSet = 1 + ch2_dim1; ch2 -= ch2_offSet; c2_dim1 = *idl1; c2_offSet = 1 + c2_dim1; c2 -= c2_offSet; --wa; /* Function Body */ idot = *ido / 2; nt = *ip * *idl1; ipp2 = *ip + 2; ipph = (*ip + 1) / 2; idp = *ip * *ido; if (*ido < *l1) { goto L106; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 1; i__ <= i__3; ++i__) { ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] + cc[i__ + (jc + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] - cc[i__ + (jc + k * cc_dim2) * cc_dim1]; /* L101: */ } /* L102: */ } /* L103: */ } i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L104: */ } /* L105: */ } goto L112; L106: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { i__3 = *l1; for (k = 1; k <= i__3; ++k) { ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] + cc[i__ + (jc + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + (j + k * cc_dim2) * cc_dim1] - cc[i__ + (jc + k * cc_dim2) * cc_dim1]; /* L107: */ } /* L108: */ } /* L109: */ } i__1 = *ido; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L110: */ } /* L111: */ } L112: idl = 2 - *ido; inc = 0; i__1 = ipph; for (l = 2; l <= i__1; ++l) { lc = ipp2 - l; idl += *ido; i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { c2[ik + l * c2_dim1] = ch2[ik + ch2_dim1] + wa[idl - 1] * ch2[ik + (ch2_dim1 << 1)]; c2[ik + lc * c2_dim1] = -wa[idl] * ch2[ik + *ip * ch2_dim1]; /* L113: */ } idlj = idl; inc += *ido; i__2 = ipph; for (j = 3; j <= i__2; ++j) { jc = ipp2 - j; idlj += inc; if (idlj > idp) { idlj -= idp; } war = wa[idlj - 1]; wai = wa[idlj]; i__3 = *idl1; for (ik = 1; ik <= i__3; ++ik) { c2[ik + l * c2_dim1] += war * ch2[ik + j * ch2_dim1]; c2[ik + lc * c2_dim1] -= wai * ch2[ik + jc * ch2_dim1]; /* L114: */ } /* L115: */ } /* L116: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { ch2[ik + ch2_dim1] += ch2[ik + j * ch2_dim1]; /* L117: */ } /* L118: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *idl1; for (ik = 2; ik <= i__2; ik += 2) { ch2[ik - 1 + j * ch2_dim1] = c2[ik - 1 + j * c2_dim1] - c2[ik + jc * c2_dim1]; ch2[ik - 1 + jc * ch2_dim1] = c2[ik - 1 + j * c2_dim1] + c2[ik + jc * c2_dim1]; ch2[ik + j * ch2_dim1] = c2[ik + j * c2_dim1] + c2[ik - 1 + jc * c2_dim1]; ch2[ik + jc * ch2_dim1] = c2[ik + j * c2_dim1] - c2[ik - 1 + jc * c2_dim1]; /* L119: */ } /* L120: */ } *nac = 1; if (*ido == 2) { return 0; } *nac = 0; i__1 = *idl1; for (ik = 1; ik <= i__1; ++ik) { c2[ik + c2_dim1] = ch2[ik + ch2_dim1]; /* L121: */ } i__1 = *ip; for (j = 2; j <= i__1; ++j) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { c1[(k + j * c1_dim2) * c1_dim1 + 1] = ch[(k + j * ch_dim2) * ch_dim1 + 1]; c1[(k + j * c1_dim2) * c1_dim1 + 2] = ch[(k + j * ch_dim2) * ch_dim1 + 2]; /* L122: */ } /* L123: */ } if (idot > *l1) { goto L127; } idij = 0; i__1 = *ip; for (j = 2; j <= i__1; ++j) { idij += 2; i__2 = *ido; for (i__ = 4; i__ <= i__2; i__ += 2) { idij += 2; i__3 = *l1; for (k = 1; k <= i__3; ++k) { c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L124: */ } /* L125: */ } /* L126: */ } return 0; L127: idj = 2 - *ido; i__1 = *ip; for (j = 2; j <= i__1; ++j) { idj += *ido; i__2 = *l1; for (k = 1; k <= i__2; ++k) { idij = idj; i__3 = *ido; for (i__ = 4; i__ <= i__3; i__ += 2) { idij += 2; c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L128: */ } /* L129: */ } /* L130: */ } return 0; } /* padsf_ */ /* Subroutine */ int padsf2_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1) { /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; doublereal ti2, tr2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 3; cc -= cc_offSet; --wa1; /* Function Body */ if (*ido > 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[(k + ch_dim2) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] + cc[((k << 1) + 2) * cc_dim1 + 1]; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] - cc[((k << 1) + 2) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[((k << 1) + 1) * cc_dim1 + 2] + cc[((k << 1) + 2) * cc_dim1 + 2]; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = cc[((k << 1) + 1) * cc_dim1 + 2] - cc[((k << 1) + 2) * cc_dim1 + 2]; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] + cc[i__ - 1 + ((k << 1) + 2) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] - cc[i__ - 1 + ((k << 1) + 2) * cc_dim1]; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + ((k << 1) + 1) * cc_dim1] + cc[i__ + ((k << 1) + 2) * cc_dim1]; ti2 = cc[i__ + ((k << 1) + 1) * cc_dim1] - cc[i__ + ((k << 1) + 2) * cc_dim1]; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * ti2 - wa1[i__] * tr2; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * tr2 + wa1[i__] * ti2; /* L103: */ } /* L104: */ } return 0; } /* padsf2_ */ /* Subroutine */ int padsf3_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2) { /* Initialized data */ static doublereal taur = -.5; static doublereal taui = -.86602540378443864676; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; doublereal ci2, ci3, di2, di3, cr2, cr3, dr2, dr3, ti2, tr2; /* *** TAUI IS -SQRT(3)/2 *** */ /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + (cc_dim1 << 2); cc -= cc_offSet; --wa1; --wa2; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { tr2 = cc[(k * 3 + 2) * cc_dim1 + 1] + cc[(k * 3 + 3) * cc_dim1 + 1]; cr2 = cc[(k * 3 + 1) * cc_dim1 + 1] + taur * tr2; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 3 + 1) * cc_dim1 + 1] + tr2; ti2 = cc[(k * 3 + 2) * cc_dim1 + 2] + cc[(k * 3 + 3) * cc_dim1 + 2]; ci2 = cc[(k * 3 + 1) * cc_dim1 + 2] + taur * ti2; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[(k * 3 + 1) * cc_dim1 + 2] + ti2; cr3 = taui * (cc[(k * 3 + 2) * cc_dim1 + 1] - cc[(k * 3 + 3) * cc_dim1 + 1]); ci3 = taui * (cc[(k * 3 + 2) * cc_dim1 + 2] - cc[(k * 3 + 3) * cc_dim1 + 2]); ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci3; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr2 + ci3; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ci2 + cr3; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ci2 - cr3; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { tr2 = cc[i__ - 1 + (k * 3 + 2) * cc_dim1] + cc[i__ - 1 + (k * 3 + 3) * cc_dim1]; cr2 = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + taur * tr2; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + tr2; ti2 = cc[i__ + (k * 3 + 2) * cc_dim1] + cc[i__ + (k * 3 + 3) * cc_dim1]; ci2 = cc[i__ + (k * 3 + 1) * cc_dim1] + taur * ti2; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 3 + 1) * cc_dim1] + ti2; cr3 = taui * (cc[i__ - 1 + (k * 3 + 2) * cc_dim1] - cc[i__ - 1 + ( k * 3 + 3) * cc_dim1]); ci3 = taui * (cc[i__ + (k * 3 + 2) * cc_dim1] - cc[i__ + (k * 3 + 3) * cc_dim1]); dr2 = cr2 - ci3; dr3 = cr2 + ci3; di2 = ci2 + cr3; di3 = ci2 - cr3; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * di2 - wa1[i__] * dr2; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * dr2 + wa1[i__] * di2; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * di3 - wa2[ i__] * dr3; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * dr3 + wa2[i__] * di3; /* L103: */ } /* L104: */ } return 0; } /* padsf3_ */ /* Subroutine */ int padsf4_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2, doublereal *wa3) { /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; doublereal ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 5; cc -= cc_offSet; --wa1; --wa2; --wa3; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti1 = cc[((k << 2) + 1) * cc_dim1 + 2] - cc[((k << 2) + 3) * cc_dim1 + 2]; ti2 = cc[((k << 2) + 1) * cc_dim1 + 2] + cc[((k << 2) + 3) * cc_dim1 + 2]; tr4 = cc[((k << 2) + 2) * cc_dim1 + 2] - cc[((k << 2) + 4) * cc_dim1 + 2]; ti3 = cc[((k << 2) + 2) * cc_dim1 + 2] + cc[((k << 2) + 4) * cc_dim1 + 2]; tr1 = cc[((k << 2) + 1) * cc_dim1 + 1] - cc[((k << 2) + 3) * cc_dim1 + 1]; tr2 = cc[((k << 2) + 1) * cc_dim1 + 1] + cc[((k << 2) + 3) * cc_dim1 + 1]; ti4 = cc[((k << 2) + 4) * cc_dim1 + 1] - cc[((k << 2) + 2) * cc_dim1 + 1]; tr3 = cc[((k << 2) + 2) * cc_dim1 + 1] + cc[((k << 2) + 4) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 1] = tr2 + tr3; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = tr2 - tr3; ch[(k + ch_dim2) * ch_dim1 + 2] = ti2 + ti3; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ti2 - ti3; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = tr1 + tr4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = tr1 - tr4; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ti1 + ti4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 2] = ti1 - ti4; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ti1 = cc[i__ + ((k << 2) + 1) * cc_dim1] - cc[i__ + ((k << 2) + 3) * cc_dim1]; ti2 = cc[i__ + ((k << 2) + 1) * cc_dim1] + cc[i__ + ((k << 2) + 3) * cc_dim1]; ti3 = cc[i__ + ((k << 2) + 2) * cc_dim1] + cc[i__ + ((k << 2) + 4) * cc_dim1]; tr4 = cc[i__ + ((k << 2) + 2) * cc_dim1] - cc[i__ + ((k << 2) + 4) * cc_dim1]; tr1 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] - cc[i__ - 1 + ((k << 2) + 3) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] + cc[i__ - 1 + ((k << 2) + 3) * cc_dim1]; ti4 = cc[i__ - 1 + ((k << 2) + 4) * cc_dim1] - cc[i__ - 1 + ((k << 2) + 2) * cc_dim1]; tr3 = cc[i__ - 1 + ((k << 2) + 2) * cc_dim1] + cc[i__ - 1 + ((k << 2) + 4) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = tr2 + tr3; cr3 = tr2 - tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = ti2 + ti3; ci3 = ti2 - ti3; cr2 = tr1 + tr4; cr4 = tr1 - tr4; ci2 = ti1 + ti4; ci4 = ti1 - ti4; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * cr2 + wa1[i__] * ci2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * ci2 - wa1[i__] * cr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * cr3 + wa2[i__] * ci3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * ci3 - wa2[ i__] * cr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * cr4 + wa3[i__] * ci4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * ci4 - wa3[i__] * cr4; /* L103: */ } /* L104: */ } return 0; } /* padsf4_ */ /* Subroutine */ int padsf5_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2, doublereal *wa3, doublereal *wa4) { /* Initialized data */ static doublereal tr11 = .3090169943749474241; static doublereal ti11 = -.95105651629515357212; static doublereal tr12 = -.8090169943749474241; static doublereal ti12 = -.58778525229247312917; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k; doublereal ci2, ci3, ci4, ci5, di3, di4, di5, di2, cr2, cr3, cr5, cr4, ti2, ti3, ti4, ti5, dr3, dr4, dr5, dr2, tr2, tr3, tr4, tr5; /* *** TR11=COS(2*PI/5), TI11=-SIN(2*PI/5) */ /* *** TR12=-COS(4*PI/5), TI12=-SIN(4*PI/5) */ /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 6; cc -= cc_offSet; --wa1; --wa2; --wa3; --wa4; /* Function Body */ if (*ido != 2) { goto L102; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti5 = cc[(k * 5 + 2) * cc_dim1 + 2] - cc[(k * 5 + 5) * cc_dim1 + 2]; ti2 = cc[(k * 5 + 2) * cc_dim1 + 2] + cc[(k * 5 + 5) * cc_dim1 + 2]; ti4 = cc[(k * 5 + 3) * cc_dim1 + 2] - cc[(k * 5 + 4) * cc_dim1 + 2]; ti3 = cc[(k * 5 + 3) * cc_dim1 + 2] + cc[(k * 5 + 4) * cc_dim1 + 2]; tr5 = cc[(k * 5 + 2) * cc_dim1 + 1] - cc[(k * 5 + 5) * cc_dim1 + 1]; tr2 = cc[(k * 5 + 2) * cc_dim1 + 1] + cc[(k * 5 + 5) * cc_dim1 + 1]; tr4 = cc[(k * 5 + 3) * cc_dim1 + 1] - cc[(k * 5 + 4) * cc_dim1 + 1]; tr3 = cc[(k * 5 + 3) * cc_dim1 + 1] + cc[(k * 5 + 4) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 5 + 1) * cc_dim1 + 1] + tr2 + tr3; ch[(k + ch_dim2) * ch_dim1 + 2] = cc[(k * 5 + 1) * cc_dim1 + 2] + ti2 + ti3; cr2 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr11 * tr2 + tr12 * tr3; ci2 = cc[(k * 5 + 1) * cc_dim1 + 2] + tr11 * ti2 + tr12 * ti3; cr3 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr12 * tr2 + tr11 * tr3; ci3 = cc[(k * 5 + 1) * cc_dim1 + 2] + tr12 * ti2 + tr11 * ti3; cr5 = ti11 * tr5 + ti12 * tr4; ci5 = ti11 * ti5 + ti12 * ti4; cr4 = ti12 * tr5 - ti11 * tr4; ci4 = ti12 * ti5 - ti11 * ti4; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci5; ch[(k + ch_dim2 * 5) * ch_dim1 + 1] = cr2 + ci5; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 2] = ci2 + cr5; ch[(k + ch_dim2 * 3) * ch_dim1 + 2] = ci3 + cr4; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr3 - ci4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = cr3 + ci4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 2] = ci3 - cr4; ch[(k + ch_dim2 * 5) * ch_dim1 + 2] = ci2 - cr5; /* L101: */ } return 0; L102: i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 2; i__ <= i__2; i__ += 2) { ti5 = cc[i__ + (k * 5 + 2) * cc_dim1] - cc[i__ + (k * 5 + 5) * cc_dim1]; ti2 = cc[i__ + (k * 5 + 2) * cc_dim1] + cc[i__ + (k * 5 + 5) * cc_dim1]; ti4 = cc[i__ + (k * 5 + 3) * cc_dim1] - cc[i__ + (k * 5 + 4) * cc_dim1]; ti3 = cc[i__ + (k * 5 + 3) * cc_dim1] + cc[i__ + (k * 5 + 4) * cc_dim1]; tr5 = cc[i__ - 1 + (k * 5 + 2) * cc_dim1] - cc[i__ - 1 + (k * 5 + 5) * cc_dim1]; tr2 = cc[i__ - 1 + (k * 5 + 2) * cc_dim1] + cc[i__ - 1 + (k * 5 + 5) * cc_dim1]; tr4 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] - cc[i__ - 1 + (k * 5 + 4) * cc_dim1]; tr3 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] + cc[i__ - 1 + (k * 5 + 4) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr2 + tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 5 + 1) * cc_dim1] + ti2 + ti3; cr2 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr11 * tr2 + tr12 * tr3; ci2 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr11 * ti2 + tr12 * ti3; cr3 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr12 * tr2 + tr11 * tr3; ci3 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr12 * ti2 + tr11 * ti3; cr5 = ti11 * tr5 + ti12 * tr4; ci5 = ti11 * ti5 + ti12 * ti4; cr4 = ti12 * tr5 - ti11 * tr4; ci4 = ti12 * ti5 - ti11 * ti4; dr3 = cr3 - ci4; dr4 = cr3 + ci4; di3 = ci3 + cr4; di4 = ci3 - cr4; dr5 = cr2 + ci5; dr2 = cr2 - ci5; di5 = ci2 - cr5; di2 = ci2 + cr5; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * dr2 + wa1[i__] * di2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 1] * di2 - wa1[i__] * dr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * dr3 + wa2[i__] * di3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 1] * di3 - wa2[ i__] * dr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * dr4 + wa3[i__] * di4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 1] * di4 - wa3[i__] * dr4; ch[i__ - 1 + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 1] * dr5 + wa4[i__] * di5; ch[i__ + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 1] * di5 - wa4[ i__] * dr5; /* L103: */ } /* L104: */ } return 0; } /* padsf5_ */ /* Subroutine */ int razb2_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1) { /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; doublereal ti2, tr2; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 3; cc -= cc_offSet; --wa1; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[(k + ch_dim2) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] + cc[*ido + ((k << 1) + 2) * cc_dim1]; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cc[((k << 1) + 1) * cc_dim1 + 1] - cc[*ido + ((k << 1) + 2) * cc_dim1]; /* L101: */ } if ((i__1 = *ido - 2) < 0) { goto L107; } else if (i__1 == 0) { goto L105; } else { goto L102; } L102: idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] + cc[ic - 1 + ((k << 1) + 2) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 1) + 1) * cc_dim1] - cc[ic - 1 + ((k << 1) + 2) * cc_dim1]; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + ((k << 1) + 1) * cc_dim1] - cc[ic + ((k << 1) + 2) * cc_dim1]; ti2 = cc[i__ + ((k << 1) + 1) * cc_dim1] + cc[ic + ((k << 1) + 2) * cc_dim1]; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * tr2 - wa1[i__ - 1] * ti2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * ti2 + wa1[i__ - 1] * tr2; /* L103: */ } /* L104: */ } if (*ido % 2 == 1) { return 0; } L105: i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[*ido + (k + ch_dim2) * ch_dim1] = cc[*ido + ((k << 1) + 1) * cc_dim1] + cc[*ido + ((k << 1) + 1) * cc_dim1]; ch[*ido + (k + (ch_dim2 << 1)) * ch_dim1] = -(cc[((k << 1) + 2) * cc_dim1 + 1] + cc[((k << 1) + 2) * cc_dim1 + 1]); /* L106: */ } L107: return 0; } /* razb2_ */ /* Subroutine */ int razb3_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2) { /* Initialized data */ static doublereal taur = -.5; static doublereal taui = .86602540378443864676; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; doublereal ci2, ci3, di2, di3, cr2, cr3, dr2, dr3, ti2, tr2; integer idp2; /* *** TAUI IS SQRT(3)/2 *** */ /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + (cc_dim1 << 2); cc -= cc_offSet; --wa1; --wa2; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { tr2 = cc[*ido + (k * 3 + 2) * cc_dim1] + cc[*ido + (k * 3 + 2) * cc_dim1]; cr2 = cc[(k * 3 + 1) * cc_dim1 + 1] + taur * tr2; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 3 + 1) * cc_dim1 + 1] + tr2; ci3 = taui * (cc[(k * 3 + 3) * cc_dim1 + 1] + cc[(k * 3 + 3) * cc_dim1 + 1]); ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci3; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr2 + ci3; /* L101: */ } if (*ido == 1) { return 0; } idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; tr2 = cc[i__ - 1 + (k * 3 + 3) * cc_dim1] + cc[ic - 1 + (k * 3 + 2) * cc_dim1]; cr2 = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + taur * tr2; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 3 + 1) * cc_dim1] + tr2; ti2 = cc[i__ + (k * 3 + 3) * cc_dim1] - cc[ic + (k * 3 + 2) * cc_dim1]; ci2 = cc[i__ + (k * 3 + 1) * cc_dim1] + taur * ti2; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 3 + 1) * cc_dim1] + ti2; cr3 = taui * (cc[i__ - 1 + (k * 3 + 3) * cc_dim1] - cc[ic - 1 + ( k * 3 + 2) * cc_dim1]); ci3 = taui * (cc[i__ + (k * 3 + 3) * cc_dim1] + cc[ic + (k * 3 + 2) * cc_dim1]); dr2 = cr2 - ci3; dr3 = cr2 + ci3; di2 = ci2 + cr3; di3 = ci2 - cr3; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * dr2 - wa1[i__ - 1] * di2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * di2 + wa1[i__ - 1] * dr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * dr3 - wa2[i__ - 1] * di3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * di3 + wa2[ i__ - 1] * dr3; /* L102: */ } /* L103: */ } return 0; } /* razb3_ */ /* Subroutine */ int razb4_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2, doublereal *wa3) { /* Initialized data */ static doublereal sqrt2 = 1.4142135623730950488; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; doublereal ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 5; cc -= cc_offSet; --wa1; --wa2; --wa3; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { tr1 = cc[((k << 2) + 1) * cc_dim1 + 1] - cc[*ido + ((k << 2) + 4) * cc_dim1]; tr2 = cc[((k << 2) + 1) * cc_dim1 + 1] + cc[*ido + ((k << 2) + 4) * cc_dim1]; tr3 = cc[*ido + ((k << 2) + 2) * cc_dim1] + cc[*ido + ((k << 2) + 2) * cc_dim1]; tr4 = cc[((k << 2) + 3) * cc_dim1 + 1] + cc[((k << 2) + 3) * cc_dim1 + 1]; ch[(k + ch_dim2) * ch_dim1 + 1] = tr2 + tr3; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = tr1 - tr4; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = tr2 - tr3; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = tr1 + tr4; /* L101: */ } if ((i__1 = *ido - 2) < 0) { goto L107; } else if (i__1 == 0) { goto L105; } else { goto L102; } L102: idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; ti1 = cc[i__ + ((k << 2) + 1) * cc_dim1] + cc[ic + ((k << 2) + 4) * cc_dim1]; ti2 = cc[i__ + ((k << 2) + 1) * cc_dim1] - cc[ic + ((k << 2) + 4) * cc_dim1]; ti3 = cc[i__ + ((k << 2) + 3) * cc_dim1] - cc[ic + ((k << 2) + 2) * cc_dim1]; tr4 = cc[i__ + ((k << 2) + 3) * cc_dim1] + cc[ic + ((k << 2) + 2) * cc_dim1]; tr1 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] - cc[ic - 1 + ((k << 2) + 4) * cc_dim1]; tr2 = cc[i__ - 1 + ((k << 2) + 1) * cc_dim1] + cc[ic - 1 + ((k << 2) + 4) * cc_dim1]; ti4 = cc[i__ - 1 + ((k << 2) + 3) * cc_dim1] - cc[ic - 1 + ((k << 2) + 2) * cc_dim1]; tr3 = cc[i__ - 1 + ((k << 2) + 3) * cc_dim1] + cc[ic - 1 + ((k << 2) + 2) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = tr2 + tr3; cr3 = tr2 - tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = ti2 + ti3; ci3 = ti2 - ti3; cr2 = tr1 - tr4; cr4 = tr1 + tr4; ci2 = ti1 + ti4; ci4 = ti1 - ti4; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * cr2 - wa1[i__ - 1] * ci2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * ci2 + wa1[i__ - 1] * cr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * cr3 - wa2[i__ - 1] * ci3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * ci3 + wa2[ i__ - 1] * cr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 2] * cr4 - wa3[i__ - 1] * ci4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 2] * ci4 + wa3[i__ - 1] * cr4; /* L103: */ } /* L104: */ } if (*ido % 2 == 1) { return 0; } L105: i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti1 = cc[((k << 2) + 2) * cc_dim1 + 1] + cc[((k << 2) + 4) * cc_dim1 + 1]; ti2 = cc[((k << 2) + 4) * cc_dim1 + 1] - cc[((k << 2) + 2) * cc_dim1 + 1]; tr1 = cc[*ido + ((k << 2) + 1) * cc_dim1] - cc[*ido + ((k << 2) + 3) * cc_dim1]; tr2 = cc[*ido + ((k << 2) + 1) * cc_dim1] + cc[*ido + ((k << 2) + 3) * cc_dim1]; ch[*ido + (k + ch_dim2) * ch_dim1] = tr2 + tr2; ch[*ido + (k + (ch_dim2 << 1)) * ch_dim1] = sqrt2 * (tr1 - ti1); ch[*ido + (k + ch_dim2 * 3) * ch_dim1] = ti2 + ti2; ch[*ido + (k + (ch_dim2 << 2)) * ch_dim1] = -sqrt2 * (tr1 + ti1); /* L106: */ } L107: return 0; } /* razb4_ */ /* Subroutine */ int razb5_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2, doublereal *wa3, doublereal *wa4) { /* Initialized data */ static doublereal tr11 = .3090169943749474241; static doublereal ti11 = .95105651629515357212; static doublereal tr12 = -.8090169943749474241; static doublereal ti12 = .58778525229247312917; /* System generated locals */ integer cc_dim1, cc_offSet, ch_dim1, ch_dim2, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; doublereal ci2, ci3, ci4, ci5, di3, di4, di5, di2, cr2, cr3, cr5, cr4, ti2, ti3, ti4, ti5, dr3, dr4, dr5, dr2, tr2, tr3, tr4, tr5; integer idp2; /* *** TR11=COS(2*PI/5), TI11=SIN(2*PI/5) */ /* *** TR12=COS(4*PI/5), TI12=SIN(4*PI/5) */ /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; cc_dim1 = *ido; cc_offSet = 1 + cc_dim1 * 6; cc -= cc_offSet; --wa1; --wa2; --wa3; --wa4; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti5 = cc[(k * 5 + 3) * cc_dim1 + 1] + cc[(k * 5 + 3) * cc_dim1 + 1]; ti4 = cc[(k * 5 + 5) * cc_dim1 + 1] + cc[(k * 5 + 5) * cc_dim1 + 1]; tr2 = cc[*ido + (k * 5 + 2) * cc_dim1] + cc[*ido + (k * 5 + 2) * cc_dim1]; tr3 = cc[*ido + (k * 5 + 4) * cc_dim1] + cc[*ido + (k * 5 + 4) * cc_dim1]; ch[(k + ch_dim2) * ch_dim1 + 1] = cc[(k * 5 + 1) * cc_dim1 + 1] + tr2 + tr3; cr2 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr11 * tr2 + tr12 * tr3; cr3 = cc[(k * 5 + 1) * cc_dim1 + 1] + tr12 * tr2 + tr11 * tr3; ci5 = ti11 * ti5 + ti12 * ti4; ci4 = ti12 * ti5 - ti11 * ti4; ch[(k + (ch_dim2 << 1)) * ch_dim1 + 1] = cr2 - ci5; ch[(k + ch_dim2 * 3) * ch_dim1 + 1] = cr3 - ci4; ch[(k + (ch_dim2 << 2)) * ch_dim1 + 1] = cr3 + ci4; ch[(k + ch_dim2 * 5) * ch_dim1 + 1] = cr2 + ci5; /* L101: */ } if (*ido == 1) { return 0; } idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; ti5 = cc[i__ + (k * 5 + 3) * cc_dim1] + cc[ic + (k * 5 + 2) * cc_dim1]; ti2 = cc[i__ + (k * 5 + 3) * cc_dim1] - cc[ic + (k * 5 + 2) * cc_dim1]; ti4 = cc[i__ + (k * 5 + 5) * cc_dim1] + cc[ic + (k * 5 + 4) * cc_dim1]; ti3 = cc[i__ + (k * 5 + 5) * cc_dim1] - cc[ic + (k * 5 + 4) * cc_dim1]; tr5 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] - cc[ic - 1 + (k * 5 + 2) * cc_dim1]; tr2 = cc[i__ - 1 + (k * 5 + 3) * cc_dim1] + cc[ic - 1 + (k * 5 + 2) * cc_dim1]; tr4 = cc[i__ - 1 + (k * 5 + 5) * cc_dim1] - cc[ic - 1 + (k * 5 + 4) * cc_dim1]; tr3 = cc[i__ - 1 + (k * 5 + 5) * cc_dim1] + cc[ic - 1 + (k * 5 + 4) * cc_dim1]; ch[i__ - 1 + (k + ch_dim2) * ch_dim1] = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr2 + tr3; ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * 5 + 1) * cc_dim1] + ti2 + ti3; cr2 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr11 * tr2 + tr12 * tr3; ci2 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr11 * ti2 + tr12 * ti3; cr3 = cc[i__ - 1 + (k * 5 + 1) * cc_dim1] + tr12 * tr2 + tr11 * tr3; ci3 = cc[i__ + (k * 5 + 1) * cc_dim1] + tr12 * ti2 + tr11 * ti3; cr5 = ti11 * tr5 + ti12 * tr4; ci5 = ti11 * ti5 + ti12 * ti4; cr4 = ti12 * tr5 - ti11 * tr4; ci4 = ti12 * ti5 - ti11 * ti4; dr3 = cr3 - ci4; dr4 = cr3 + ci4; di3 = ci3 + cr4; di4 = ci3 - cr4; dr5 = cr2 + ci5; dr2 = cr2 - ci5; di5 = ci2 - cr5; di2 = ci2 + cr5; ch[i__ - 1 + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * dr2 - wa1[i__ - 1] * di2; ch[i__ + (k + (ch_dim2 << 1)) * ch_dim1] = wa1[i__ - 2] * di2 + wa1[i__ - 1] * dr2; ch[i__ - 1 + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * dr3 - wa2[i__ - 1] * di3; ch[i__ + (k + ch_dim2 * 3) * ch_dim1] = wa2[i__ - 2] * di3 + wa2[ i__ - 1] * dr3; ch[i__ - 1 + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 2] * dr4 - wa3[i__ - 1] * di4; ch[i__ + (k + (ch_dim2 << 2)) * ch_dim1] = wa3[i__ - 2] * di4 + wa3[i__ - 1] * dr4; ch[i__ - 1 + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 2] * dr5 - wa4[i__ - 1] * di5; ch[i__ + (k + ch_dim2 * 5) * ch_dim1] = wa4[i__ - 2] * di5 + wa4[ i__ - 1] * dr5; /* L102: */ } /* L103: */ } return 0; } /* razb5_ */ /* Subroutine */ int razbg_(integer *ido, integer *ip, integer *l1, integer * idl1, doublereal *cc, doublereal *c1, doublereal *c2, doublereal *ch, doublereal *ch2, doublereal *wa) { /* Initialized data */ static doublereal tpi = 6.28318530717958647692; /* System generated locals */ integer ch_dim1, ch_dim2, ch_offSet, cc_dim1, cc_dim2, cc_offSet, c1_dim1, c1_dim2, c1_offSet, c2_dim1, c2_offSet, ch2_dim1, ch2_offSet, i__1, i__2, i__3; /* Builtin functions */ /* Local variables */ integer i__, j, k, l, j2, ic, jc, lc, ik, is; doublereal dc2, ai1, ai2, ar1, ar2, ds2; integer nbd; doublereal dcp, arg, dsp, ar1h, ar2h; integer idp2, ipp2, idij, ipph; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; c1_dim1 = *ido; c1_dim2 = *l1; c1_offSet = 1 + c1_dim1 * (1 + c1_dim2); c1 -= c1_offSet; cc_dim1 = *ido; cc_dim2 = *ip; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; ch2_dim1 = *idl1; ch2_offSet = 1 + ch2_dim1; ch2 -= ch2_offSet; c2_dim1 = *idl1; c2_offSet = 1 + c2_dim1; c2 -= c2_offSet; --wa; /* Function Body */ arg = tpi / (real) (*ip); dcp = cos(arg); dsp = sin(arg); idp2 = *ido + 2; nbd = (*ido - 1) / 2; ipp2 = *ip + 2; ipph = (*ip + 1) / 2; if (*ido < *l1) { goto L103; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L101: */ } /* L102: */ } goto L106; L103: i__1 = *ido; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[i__ + (k + ch_dim2) * ch_dim1] = cc[i__ + (k * cc_dim2 + 1) * cc_dim1]; /* L104: */ } /* L105: */ } L106: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; j2 = j + j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[(k + j * ch_dim2) * ch_dim1 + 1] = cc[*ido + (j2 - 2 + k * cc_dim2) * cc_dim1] + cc[*ido + (j2 - 2 + k * cc_dim2) * cc_dim1]; ch[(k + jc * ch_dim2) * ch_dim1 + 1] = cc[(j2 - 1 + k * cc_dim2) * cc_dim1 + 1] + cc[(j2 - 1 + k * cc_dim2) * cc_dim1 + 1]; /* L107: */ } /* L108: */ } if (*ido == 1) { goto L116; } if (nbd < *l1) { goto L112; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { ic = idp2 - i__; ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = cc[i__ - 1 + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] + cc[ic - 1 + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] = cc[i__ - 1 + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] - cc[ic - 1 + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] - cc[ic + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] + cc[ic + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; /* L109: */ } /* L110: */ } /* L111: */ } goto L116; L112: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; i__3 = *l1; for (k = 1; k <= i__3; ++k) { ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = cc[i__ - 1 + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] + cc[ic - 1 + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] = cc[i__ - 1 + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] - cc[ic - 1 + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = cc[i__ + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] - cc[ic + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = cc[i__ + ((j << 1) - 1 + k * cc_dim2) * cc_dim1] + cc[ic + ((j << 1) - 2 + k * cc_dim2) * cc_dim1]; /* L113: */ } /* L114: */ } /* L115: */ } L116: ar1 = 1.; ai1 = 0.; i__1 = ipph; for (l = 2; l <= i__1; ++l) { lc = ipp2 - l; ar1h = dcp * ar1 - dsp * ai1; ai1 = dcp * ai1 + dsp * ar1; ar1 = ar1h; i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { c2[ik + l * c2_dim1] = ch2[ik + ch2_dim1] + ar1 * ch2[ik + ( ch2_dim1 << 1)]; c2[ik + lc * c2_dim1] = ai1 * ch2[ik + *ip * ch2_dim1]; /* L117: */ } dc2 = ar1; ds2 = ai1; ar2 = ar1; ai2 = ai1; i__2 = ipph; for (j = 3; j <= i__2; ++j) { jc = ipp2 - j; ar2h = dc2 * ar2 - ds2 * ai2; ai2 = dc2 * ai2 + ds2 * ar2; ar2 = ar2h; i__3 = *idl1; for (ik = 1; ik <= i__3; ++ik) { c2[ik + l * c2_dim1] += ar2 * ch2[ik + j * ch2_dim1]; c2[ik + lc * c2_dim1] += ai2 * ch2[ik + jc * ch2_dim1]; /* L118: */ } /* L119: */ } /* L120: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { ch2[ik + ch2_dim1] += ch2[ik + j * ch2_dim1]; /* L121: */ } /* L122: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[(k + j * ch_dim2) * ch_dim1 + 1] = c1[(k + j * c1_dim2) * c1_dim1 + 1] - c1[(k + jc * c1_dim2) * c1_dim1 + 1]; ch[(k + jc * ch_dim2) * ch_dim1 + 1] = c1[(k + j * c1_dim2) * c1_dim1 + 1] + c1[(k + jc * c1_dim2) * c1_dim1 + 1]; /* L123: */ } /* L124: */ } if (*ido == 1) { goto L132; } if (nbd < *l1) { goto L128; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] - c1[i__ + (k + jc * c1_dim2) * c1_dim1]; ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] = c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] + c1[i__ + (k + jc * c1_dim2) * c1_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = c1[i__ + (k + j * c1_dim2) * c1_dim1] + c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = c1[i__ + (k + j * c1_dim2) * c1_dim1] - c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1]; /* L125: */ } /* L126: */ } /* L127: */ } goto L132; L128: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { i__3 = *l1; for (k = 1; k <= i__3; ++k) { ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] - c1[i__ + (k + jc * c1_dim2) * c1_dim1]; ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] = c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] + c1[i__ + (k + jc * c1_dim2) * c1_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = c1[i__ + (k + j * c1_dim2) * c1_dim1] + c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1]; ch[i__ + (k + jc * ch_dim2) * ch_dim1] = c1[i__ + (k + j * c1_dim2) * c1_dim1] - c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1]; /* L129: */ } /* L130: */ } /* L131: */ } L132: if (*ido == 1) { return 0; } i__1 = *idl1; for (ik = 1; ik <= i__1; ++ik) { c2[ik + c2_dim1] = ch2[ik + ch2_dim1]; /* L133: */ } i__1 = *ip; for (j = 2; j <= i__1; ++j) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { c1[(k + j * c1_dim2) * c1_dim1 + 1] = ch[(k + j * ch_dim2) * ch_dim1 + 1]; /* L134: */ } /* L135: */ } if (nbd > *l1) { goto L139; } is = -(*ido); i__1 = *ip; for (j = 2; j <= i__1; ++j) { is += *ido; idij = is; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { idij += 2; i__3 = *l1; for (k = 1; k <= i__3; ++k) { c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L136: */ } /* L137: */ } /* L138: */ } goto L143; L139: is = -(*ido); i__1 = *ip; for (j = 2; j <= i__1; ++j) { is += *ido; i__2 = *l1; for (k = 1; k <= i__2; ++k) { idij = is; i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { idij += 2; c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[ i__ - 1 + (k + j * ch_dim2) * ch_dim1] - wa[idij] * ch[i__ + (k + j * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = wa[idij - 1] * ch[i__ + (k + j * ch_dim2) * ch_dim1] + wa[idij] * ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L140: */ } /* L141: */ } /* L142: */ } L143: return 0; } /* razbg_ */ /* Subroutine */ int dfftb1_(integer *n, doublereal *c__, doublereal *ch, doublereal *wa, integer *ifac) { /* System generated locals */ integer i__1; /* Local variables */ integer i__, k1, l1, l2, na, nf, ip, iw, ix2, ix3, ix4, ido, idl1; extern /* Subroutine */ int razb2_(integer *, integer *, doublereal *, doublereal *, doublereal *), razb3_(integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *), razb4_( integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *), razb5_(integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *), razbg_(integer *, integer *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *); /* Parameter adjustments */ --ifac; --wa; --ch; --c__; /* Function Body */ nf = ifac[2]; na = 0; l1 = 1; iw = 1; i__1 = nf; for (k1 = 1; k1 <= i__1; ++k1) { ip = ifac[k1 + 2]; l2 = ip * l1; ido = *n / l2; idl1 = ido * l1; if (ip != 4) { goto L103; } ix2 = iw + ido; ix3 = ix2 + ido; if (na != 0) { goto L101; } razb4_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3]); goto L102; L101: razb4_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3]); L102: na = 1 - na; goto L115; L103: if (ip != 2) { goto L106; } if (na != 0) { goto L104; } razb2_(&ido, &l1, &c__[1], &ch[1], &wa[iw]); goto L105; L104: razb2_(&ido, &l1, &ch[1], &c__[1], &wa[iw]); L105: na = 1 - na; goto L115; L106: if (ip != 3) { goto L109; } ix2 = iw + ido; if (na != 0) { goto L107; } razb3_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2]); goto L108; L107: razb3_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2]); L108: na = 1 - na; goto L115; L109: if (ip != 5) { goto L112; } ix2 = iw + ido; ix3 = ix2 + ido; ix4 = ix3 + ido; if (na != 0) { goto L110; } razb5_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); goto L111; L110: razb5_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); L111: na = 1 - na; goto L115; L112: if (na != 0) { goto L113; } razbg_(&ido, &ip, &l1, &idl1, &c__[1], &c__[1], &c__[1], &ch[1], &ch[ 1], &wa[iw]); goto L114; L113: razbg_(&ido, &ip, &l1, &idl1, &ch[1], &ch[1], &ch[1], &c__[1], &c__[1] , &wa[iw]); L114: if (ido == 1) { na = 1 - na; } L115: l1 = l2; iw += (ip - 1) * ido; /* L116: */ } if (na == 0) { return 0; } i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { c__[i__] = ch[i__]; /* L117: */ } return 0; } /* dfftb1_ */ /* Subroutine */ int razf2_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1) { /* System generated locals */ integer ch_dim1, ch_offSet, cc_dim1, cc_dim2, cc_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; doublereal ti2, tr2; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_offSet = 1 + ch_dim1 * 3; ch -= ch_offSet; cc_dim1 = *ido; cc_dim2 = *l1; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; --wa1; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[((k << 1) + 1) * ch_dim1 + 1] = cc[(k + cc_dim2) * cc_dim1 + 1] + cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]; ch[*ido + ((k << 1) + 2) * ch_dim1] = cc[(k + cc_dim2) * cc_dim1 + 1] - cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]; /* L101: */ } if ((i__1 = *ido - 2) < 0) { goto L107; } else if (i__1 == 0) { goto L105; } else { goto L102; } L102: idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; tr2 = wa1[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1] + wa1[i__ - 1] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1]; ti2 = wa1[i__ - 2] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1] - wa1[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1]; ch[i__ + ((k << 1) + 1) * ch_dim1] = cc[i__ + (k + cc_dim2) * cc_dim1] + ti2; ch[ic + ((k << 1) + 2) * ch_dim1] = ti2 - cc[i__ + (k + cc_dim2) * cc_dim1]; ch[i__ - 1 + ((k << 1) + 1) * ch_dim1] = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + tr2; ch[ic - 1 + ((k << 1) + 2) * ch_dim1] = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] - tr2; /* L103: */ } /* L104: */ } if (*ido % 2 == 1) { return 0; } L105: i__1 = *l1; for (k = 1; k <= i__1; ++k) { ch[((k << 1) + 2) * ch_dim1 + 1] = -cc[*ido + (k + (cc_dim2 << 1)) * cc_dim1]; ch[*ido + ((k << 1) + 1) * ch_dim1] = cc[*ido + (k + cc_dim2) * cc_dim1]; /* L106: */ } L107: return 0; } /* razf2_ */ /* Subroutine */ int razf3_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2) { /* Initialized data */ static doublereal taur = -.5; static doublereal taui = .86602540378443864676; /* System generated locals */ integer ch_dim1, ch_offSet, cc_dim1, cc_dim2, cc_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; doublereal ci2, di2, di3, cr2, dr2, dr3, ti2, ti3, tr2, tr3; integer idp2; /* *** TAUI IS -SQRT(3)/2 *** */ /* Parameter adjustments */ ch_dim1 = *ido; ch_offSet = 1 + (ch_dim1 << 2); ch -= ch_offSet; cc_dim1 = *ido; cc_dim2 = *l1; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; --wa1; --wa2; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { cr2 = cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1] + cc[(k + cc_dim2 * 3) * cc_dim1 + 1]; ch[(k * 3 + 1) * ch_dim1 + 1] = cc[(k + cc_dim2) * cc_dim1 + 1] + cr2; ch[(k * 3 + 3) * ch_dim1 + 1] = taui * (cc[(k + cc_dim2 * 3) * cc_dim1 + 1] - cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]); ch[*ido + (k * 3 + 2) * ch_dim1] = cc[(k + cc_dim2) * cc_dim1 + 1] + taur * cr2; /* L101: */ } if (*ido == 1) { return 0; } idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; dr2 = wa1[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1] + wa1[i__ - 1] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1]; di2 = wa1[i__ - 2] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1] - wa1[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1]; dr3 = wa2[i__ - 2] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1] + wa2[i__ - 1] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1]; di3 = wa2[i__ - 2] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1] - wa2[ i__ - 1] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1]; cr2 = dr2 + dr3; ci2 = di2 + di3; ch[i__ - 1 + (k * 3 + 1) * ch_dim1] = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + cr2; ch[i__ + (k * 3 + 1) * ch_dim1] = cc[i__ + (k + cc_dim2) * cc_dim1] + ci2; tr2 = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + taur * cr2; ti2 = cc[i__ + (k + cc_dim2) * cc_dim1] + taur * ci2; tr3 = taui * (di2 - di3); ti3 = taui * (dr3 - dr2); ch[i__ - 1 + (k * 3 + 3) * ch_dim1] = tr2 + tr3; ch[ic - 1 + (k * 3 + 2) * ch_dim1] = tr2 - tr3; ch[i__ + (k * 3 + 3) * ch_dim1] = ti2 + ti3; ch[ic + (k * 3 + 2) * ch_dim1] = ti3 - ti2; /* L102: */ } /* L103: */ } return 0; } /* razf3_ */ /* Subroutine */ int razf4_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2, doublereal *wa3) { /* Initialized data */ static doublereal hsqt2 = .7071067811865475244; /* System generated locals */ integer cc_dim1, cc_dim2, cc_offSet, ch_dim1, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; doublereal ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_offSet = 1 + ch_dim1 * 5; ch -= ch_offSet; cc_dim1 = *ido; cc_dim2 = *l1; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; --wa1; --wa2; --wa3; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { tr1 = cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1] + cc[(k + (cc_dim2 << 2)) * cc_dim1 + 1]; tr2 = cc[(k + cc_dim2) * cc_dim1 + 1] + cc[(k + cc_dim2 * 3) * cc_dim1 + 1]; ch[((k << 2) + 1) * ch_dim1 + 1] = tr1 + tr2; ch[*ido + ((k << 2) + 4) * ch_dim1] = tr2 - tr1; ch[*ido + ((k << 2) + 2) * ch_dim1] = cc[(k + cc_dim2) * cc_dim1 + 1] - cc[(k + cc_dim2 * 3) * cc_dim1 + 1]; ch[((k << 2) + 3) * ch_dim1 + 1] = cc[(k + (cc_dim2 << 2)) * cc_dim1 + 1] - cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]; /* L101: */ } if ((i__1 = *ido - 2) < 0) { goto L107; } else if (i__1 == 0) { goto L105; } else { goto L102; } L102: idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; cr2 = wa1[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1] + wa1[i__ - 1] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1]; ci2 = wa1[i__ - 2] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1] - wa1[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1]; cr3 = wa2[i__ - 2] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1] + wa2[i__ - 1] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1]; ci3 = wa2[i__ - 2] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1] - wa2[ i__ - 1] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1]; cr4 = wa3[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 2)) * cc_dim1] + wa3[i__ - 1] * cc[i__ + (k + (cc_dim2 << 2)) * cc_dim1]; ci4 = wa3[i__ - 2] * cc[i__ + (k + (cc_dim2 << 2)) * cc_dim1] - wa3[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 2)) * cc_dim1]; tr1 = cr2 + cr4; tr4 = cr4 - cr2; ti1 = ci2 + ci4; ti4 = ci2 - ci4; ti2 = cc[i__ + (k + cc_dim2) * cc_dim1] + ci3; ti3 = cc[i__ + (k + cc_dim2) * cc_dim1] - ci3; tr2 = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + cr3; tr3 = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] - cr3; ch[i__ - 1 + ((k << 2) + 1) * ch_dim1] = tr1 + tr2; ch[ic - 1 + ((k << 2) + 4) * ch_dim1] = tr2 - tr1; ch[i__ + ((k << 2) + 1) * ch_dim1] = ti1 + ti2; ch[ic + ((k << 2) + 4) * ch_dim1] = ti1 - ti2; ch[i__ - 1 + ((k << 2) + 3) * ch_dim1] = ti4 + tr3; ch[ic - 1 + ((k << 2) + 2) * ch_dim1] = tr3 - ti4; ch[i__ + ((k << 2) + 3) * ch_dim1] = tr4 + ti3; ch[ic + ((k << 2) + 2) * ch_dim1] = tr4 - ti3; /* L103: */ } /* L104: */ } if (*ido % 2 == 1) { return 0; } L105: i__1 = *l1; for (k = 1; k <= i__1; ++k) { ti1 = -hsqt2 * (cc[*ido + (k + (cc_dim2 << 1)) * cc_dim1] + cc[*ido + (k + (cc_dim2 << 2)) * cc_dim1]); tr1 = hsqt2 * (cc[*ido + (k + (cc_dim2 << 1)) * cc_dim1] - cc[*ido + ( k + (cc_dim2 << 2)) * cc_dim1]); ch[*ido + ((k << 2) + 1) * ch_dim1] = tr1 + cc[*ido + (k + cc_dim2) * cc_dim1]; ch[*ido + ((k << 2) + 3) * ch_dim1] = cc[*ido + (k + cc_dim2) * cc_dim1] - tr1; ch[((k << 2) + 2) * ch_dim1 + 1] = ti1 - cc[*ido + (k + cc_dim2 * 3) * cc_dim1]; ch[((k << 2) + 4) * ch_dim1 + 1] = ti1 + cc[*ido + (k + cc_dim2 * 3) * cc_dim1]; /* L106: */ } L107: return 0; } /* razf4_ */ /* Subroutine */ int razf5_(integer *ido, integer *l1, doublereal *cc, doublereal *ch, doublereal *wa1, doublereal *wa2, doublereal *wa3, doublereal *wa4) { /* Initialized data */ static doublereal tr11 = .3090169943749474241; static doublereal ti11 = .95105651629515357212; static doublereal tr12 = -.8090169943749474241; static doublereal ti12 = .58778525229247312917; /* System generated locals */ integer cc_dim1, cc_dim2, cc_offSet, ch_dim1, ch_offSet, i__1, i__2; /* Local variables */ integer i__, k, ic; doublereal ci2, di2, ci4, ci5, di3, di4, di5, ci3, cr2, cr3, dr2, dr3, dr4, dr5, cr5, cr4, ti2, ti3, ti5, ti4, tr2, tr3, tr4, tr5; integer idp2; /* Parameter adjustments */ ch_dim1 = *ido; ch_offSet = 1 + ch_dim1 * 6; ch -= ch_offSet; cc_dim1 = *ido; cc_dim2 = *l1; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; --wa1; --wa2; --wa3; --wa4; /* Function Body */ i__1 = *l1; for (k = 1; k <= i__1; ++k) { cr2 = cc[(k + cc_dim2 * 5) * cc_dim1 + 1] + cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]; ci5 = cc[(k + cc_dim2 * 5) * cc_dim1 + 1] - cc[(k + (cc_dim2 << 1)) * cc_dim1 + 1]; cr3 = cc[(k + (cc_dim2 << 2)) * cc_dim1 + 1] + cc[(k + cc_dim2 * 3) * cc_dim1 + 1]; ci4 = cc[(k + (cc_dim2 << 2)) * cc_dim1 + 1] - cc[(k + cc_dim2 * 3) * cc_dim1 + 1]; ch[(k * 5 + 1) * ch_dim1 + 1] = cc[(k + cc_dim2) * cc_dim1 + 1] + cr2 + cr3; ch[*ido + (k * 5 + 2) * ch_dim1] = cc[(k + cc_dim2) * cc_dim1 + 1] + tr11 * cr2 + tr12 * cr3; ch[(k * 5 + 3) * ch_dim1 + 1] = ti11 * ci5 + ti12 * ci4; ch[*ido + (k * 5 + 4) * ch_dim1] = cc[(k + cc_dim2) * cc_dim1 + 1] + tr12 * cr2 + tr11 * cr3; ch[(k * 5 + 5) * ch_dim1 + 1] = ti12 * ci5 - ti11 * ci4; /* L101: */ } if (*ido == 1) { return 0; } idp2 = *ido + 2; i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; dr2 = wa1[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1] + wa1[i__ - 1] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1]; di2 = wa1[i__ - 2] * cc[i__ + (k + (cc_dim2 << 1)) * cc_dim1] - wa1[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 1)) * cc_dim1]; dr3 = wa2[i__ - 2] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1] + wa2[i__ - 1] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1]; di3 = wa2[i__ - 2] * cc[i__ + (k + cc_dim2 * 3) * cc_dim1] - wa2[ i__ - 1] * cc[i__ - 1 + (k + cc_dim2 * 3) * cc_dim1]; dr4 = wa3[i__ - 2] * cc[i__ - 1 + (k + (cc_dim2 << 2)) * cc_dim1] + wa3[i__ - 1] * cc[i__ + (k + (cc_dim2 << 2)) * cc_dim1]; di4 = wa3[i__ - 2] * cc[i__ + (k + (cc_dim2 << 2)) * cc_dim1] - wa3[i__ - 1] * cc[i__ - 1 + (k + (cc_dim2 << 2)) * cc_dim1]; dr5 = wa4[i__ - 2] * cc[i__ - 1 + (k + cc_dim2 * 5) * cc_dim1] + wa4[i__ - 1] * cc[i__ + (k + cc_dim2 * 5) * cc_dim1]; di5 = wa4[i__ - 2] * cc[i__ + (k + cc_dim2 * 5) * cc_dim1] - wa4[ i__ - 1] * cc[i__ - 1 + (k + cc_dim2 * 5) * cc_dim1]; cr2 = dr2 + dr5; ci5 = dr5 - dr2; cr5 = di2 - di5; ci2 = di2 + di5; cr3 = dr3 + dr4; ci4 = dr4 - dr3; cr4 = di3 - di4; ci3 = di3 + di4; ch[i__ - 1 + (k * 5 + 1) * ch_dim1] = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + cr2 + cr3; ch[i__ + (k * 5 + 1) * ch_dim1] = cc[i__ + (k + cc_dim2) * cc_dim1] + ci2 + ci3; tr2 = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + tr11 * cr2 + tr12 * cr3; ti2 = cc[i__ + (k + cc_dim2) * cc_dim1] + tr11 * ci2 + tr12 * ci3; tr3 = cc[i__ - 1 + (k + cc_dim2) * cc_dim1] + tr12 * cr2 + tr11 * cr3; ti3 = cc[i__ + (k + cc_dim2) * cc_dim1] + tr12 * ci2 + tr11 * ci3; tr5 = ti11 * cr5 + ti12 * cr4; ti5 = ti11 * ci5 + ti12 * ci4; tr4 = ti12 * cr5 - ti11 * cr4; ti4 = ti12 * ci5 - ti11 * ci4; ch[i__ - 1 + (k * 5 + 3) * ch_dim1] = tr2 + tr5; ch[ic - 1 + (k * 5 + 2) * ch_dim1] = tr2 - tr5; ch[i__ + (k * 5 + 3) * ch_dim1] = ti2 + ti5; ch[ic + (k * 5 + 2) * ch_dim1] = ti5 - ti2; ch[i__ - 1 + (k * 5 + 5) * ch_dim1] = tr3 + tr4; ch[ic - 1 + (k * 5 + 4) * ch_dim1] = tr3 - tr4; ch[i__ + (k * 5 + 5) * ch_dim1] = ti3 + ti4; ch[ic + (k * 5 + 4) * ch_dim1] = ti4 - ti3; /* L102: */ } /* L103: */ } return 0; } /* razf5_ */ /* Subroutine */ int razfg_(integer *ido, integer *ip, integer *l1, integer * idl1, doublereal *cc, doublereal *c1, doublereal *c2, doublereal *ch, doublereal *ch2, doublereal *wa) { /* Initialized data */ static doublereal tpi = 6.28318530717958647692; /* System generated locals */ integer ch_dim1, ch_dim2, ch_offSet, cc_dim1, cc_dim2, cc_offSet, c1_dim1, c1_dim2, c1_offSet, c2_dim1, c2_offSet, ch2_dim1, ch2_offSet, i__1, i__2, i__3; /* Builtin functions */ /* Local variables */ integer i__, j, k, l, j2, ic, jc, lc, ik, is; doublereal dc2, ai1, ai2, ar1, ar2, ds2; integer nbd; doublereal dcp, arg, dsp, ar1h, ar2h; integer idp2, ipp2, idij, ipph; /* Parameter adjustments */ ch_dim1 = *ido; ch_dim2 = *l1; ch_offSet = 1 + ch_dim1 * (1 + ch_dim2); ch -= ch_offSet; c1_dim1 = *ido; c1_dim2 = *l1; c1_offSet = 1 + c1_dim1 * (1 + c1_dim2); c1 -= c1_offSet; cc_dim1 = *ido; cc_dim2 = *ip; cc_offSet = 1 + cc_dim1 * (1 + cc_dim2); cc -= cc_offSet; ch2_dim1 = *idl1; ch2_offSet = 1 + ch2_dim1; ch2 -= ch2_offSet; c2_dim1 = *idl1; c2_offSet = 1 + c2_dim1; c2 -= c2_offSet; --wa; /* Function Body */ arg = tpi / (real) (*ip); dcp = cos(arg); dsp = sin(arg); ipph = (*ip + 1) / 2; ipp2 = *ip + 2; idp2 = *ido + 2; nbd = (*ido - 1) / 2; if (*ido == 1) { goto L119; } i__1 = *idl1; for (ik = 1; ik <= i__1; ++ik) { ch2[ik + ch2_dim1] = c2[ik + c2_dim1]; /* L101: */ } i__1 = *ip; for (j = 2; j <= i__1; ++j) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { ch[(k + j * ch_dim2) * ch_dim1 + 1] = c1[(k + j * c1_dim2) * c1_dim1 + 1]; /* L102: */ } /* L103: */ } if (nbd > *l1) { goto L107; } is = -(*ido); i__1 = *ip; for (j = 2; j <= i__1; ++j) { is += *ido; idij = is; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { idij += 2; i__3 = *l1; for (k = 1; k <= i__3; ++k) { ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = wa[idij - 1] * c1[ i__ - 1 + (k + j * c1_dim2) * c1_dim1] + wa[idij] * c1[i__ + (k + j * c1_dim2) * c1_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = wa[idij - 1] * c1[i__ + (k + j * c1_dim2) * c1_dim1] - wa[idij] * c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1]; /* L104: */ } /* L105: */ } /* L106: */ } goto L111; L107: is = -(*ido); i__1 = *ip; for (j = 2; j <= i__1; ++j) { is += *ido; i__2 = *l1; for (k = 1; k <= i__2; ++k) { idij = is; i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { idij += 2; ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] = wa[idij - 1] * c1[ i__ - 1 + (k + j * c1_dim2) * c1_dim1] + wa[idij] * c1[i__ + (k + j * c1_dim2) * c1_dim1]; ch[i__ + (k + j * ch_dim2) * ch_dim1] = wa[idij - 1] * c1[i__ + (k + j * c1_dim2) * c1_dim1] - wa[idij] * c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1]; /* L108: */ } /* L109: */ } /* L110: */ } L111: if (nbd < *l1) { goto L115; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] + ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] - ch[i__ + (k + jc * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] + ch[i__ + (k + jc * ch_dim2) * ch_dim1]; c1[i__ + (k + jc * c1_dim2) * c1_dim1] = ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] - ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L112: */ } /* L113: */ } /* L114: */ } goto L121; L115: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { i__3 = *l1; for (k = 1; k <= i__3; ++k) { c1[i__ - 1 + (k + j * c1_dim2) * c1_dim1] = ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] + ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; c1[i__ - 1 + (k + jc * c1_dim2) * c1_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] - ch[i__ + (k + jc * ch_dim2) * ch_dim1]; c1[i__ + (k + j * c1_dim2) * c1_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] + ch[i__ + (k + jc * ch_dim2) * ch_dim1]; c1[i__ + (k + jc * c1_dim2) * c1_dim1] = ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1] - ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1]; /* L116: */ } /* L117: */ } /* L118: */ } goto L121; L119: i__1 = *idl1; for (ik = 1; ik <= i__1; ++ik) { c2[ik + c2_dim1] = ch2[ik + ch2_dim1]; /* L120: */ } L121: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { c1[(k + j * c1_dim2) * c1_dim1 + 1] = ch[(k + j * ch_dim2) * ch_dim1 + 1] + ch[(k + jc * ch_dim2) * ch_dim1 + 1]; c1[(k + jc * c1_dim2) * c1_dim1 + 1] = ch[(k + jc * ch_dim2) * ch_dim1 + 1] - ch[(k + j * ch_dim2) * ch_dim1 + 1]; /* L122: */ } /* L123: */ } ar1 = 1.; ai1 = 0.; i__1 = ipph; for (l = 2; l <= i__1; ++l) { lc = ipp2 - l; ar1h = dcp * ar1 - dsp * ai1; ai1 = dcp * ai1 + dsp * ar1; ar1 = ar1h; i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { ch2[ik + l * ch2_dim1] = c2[ik + c2_dim1] + ar1 * c2[ik + ( c2_dim1 << 1)]; ch2[ik + lc * ch2_dim1] = ai1 * c2[ik + *ip * c2_dim1]; /* L124: */ } dc2 = ar1; ds2 = ai1; ar2 = ar1; ai2 = ai1; i__2 = ipph; for (j = 3; j <= i__2; ++j) { jc = ipp2 - j; ar2h = dc2 * ar2 - ds2 * ai2; ai2 = dc2 * ai2 + ds2 * ar2; ar2 = ar2h; i__3 = *idl1; for (ik = 1; ik <= i__3; ++ik) { ch2[ik + l * ch2_dim1] += ar2 * c2[ik + j * c2_dim1]; ch2[ik + lc * ch2_dim1] += ai2 * c2[ik + jc * c2_dim1]; /* L125: */ } /* L126: */ } /* L127: */ } i__1 = ipph; for (j = 2; j <= i__1; ++j) { i__2 = *idl1; for (ik = 1; ik <= i__2; ++ik) { ch2[ik + ch2_dim1] += c2[ik + j * c2_dim1]; /* L128: */ } /* L129: */ } if (*ido < *l1) { goto L132; } i__1 = *l1; for (k = 1; k <= i__1; ++k) { i__2 = *ido; for (i__ = 1; i__ <= i__2; ++i__) { cc[i__ + (k * cc_dim2 + 1) * cc_dim1] = ch[i__ + (k + ch_dim2) * ch_dim1]; /* L130: */ } /* L131: */ } goto L135; L132: i__1 = *ido; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *l1; for (k = 1; k <= i__2; ++k) { cc[i__ + (k * cc_dim2 + 1) * cc_dim1] = ch[i__ + (k + ch_dim2) * ch_dim1]; /* L133: */ } /* L134: */ } L135: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; j2 = j + j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { cc[*ido + (j2 - 2 + k * cc_dim2) * cc_dim1] = ch[(k + j * ch_dim2) * ch_dim1 + 1]; cc[(j2 - 1 + k * cc_dim2) * cc_dim1 + 1] = ch[(k + jc * ch_dim2) * ch_dim1 + 1]; /* L136: */ } /* L137: */ } if (*ido == 1) { return 0; } if (nbd < *l1) { goto L141; } i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; j2 = j + j; i__2 = *l1; for (k = 1; k <= i__2; ++k) { i__3 = *ido; for (i__ = 3; i__ <= i__3; i__ += 2) { ic = idp2 - i__; cc[i__ - 1 + (j2 - 1 + k * cc_dim2) * cc_dim1] = ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] + ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; cc[ic - 1 + (j2 - 2 + k * cc_dim2) * cc_dim1] = ch[i__ - 1 + ( k + j * ch_dim2) * ch_dim1] - ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; cc[i__ + (j2 - 1 + k * cc_dim2) * cc_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] + ch[i__ + (k + jc * ch_dim2) * ch_dim1]; cc[ic + (j2 - 2 + k * cc_dim2) * cc_dim1] = ch[i__ + (k + jc * ch_dim2) * ch_dim1] - ch[i__ + (k + j * ch_dim2) * ch_dim1]; /* L138: */ } /* L139: */ } /* L140: */ } return 0; L141: i__1 = ipph; for (j = 2; j <= i__1; ++j) { jc = ipp2 - j; j2 = j + j; i__2 = *ido; for (i__ = 3; i__ <= i__2; i__ += 2) { ic = idp2 - i__; i__3 = *l1; for (k = 1; k <= i__3; ++k) { cc[i__ - 1 + (j2 - 1 + k * cc_dim2) * cc_dim1] = ch[i__ - 1 + (k + j * ch_dim2) * ch_dim1] + ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; cc[ic - 1 + (j2 - 2 + k * cc_dim2) * cc_dim1] = ch[i__ - 1 + ( k + j * ch_dim2) * ch_dim1] - ch[i__ - 1 + (k + jc * ch_dim2) * ch_dim1]; cc[i__ + (j2 - 1 + k * cc_dim2) * cc_dim1] = ch[i__ + (k + j * ch_dim2) * ch_dim1] + ch[i__ + (k + jc * ch_dim2) * ch_dim1]; cc[ic + (j2 - 2 + k * cc_dim2) * cc_dim1] = ch[i__ + (k + jc * ch_dim2) * ch_dim1] - ch[i__ + (k + j * ch_dim2) * ch_dim1]; /* L142: */ } /* L143: */ } /* L144: */ } return 0; } /* razfg_ */ /* Subroutine */ int dfftf1_(integer *n, doublereal *c__, doublereal *ch, doublereal *wa, integer *ifac) { /* System generated locals */ integer i__1; /* Local variables */ integer i__, k1, l1, l2, na, kh, nf, ip, iw, ix2, ix3, ix4, ido, idl1; extern /* Subroutine */ int razf2_(integer *, integer *, doublereal *, doublereal *, doublereal *), razf3_(integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *), razf4_( integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *), razf5_(integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *), razfg_(integer *, integer *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *); /* Parameter adjustments */ --ifac; --wa; --ch; --c__; /* Function Body */ nf = ifac[2]; na = 1; l2 = *n; iw = *n; i__1 = nf; for (k1 = 1; k1 <= i__1; ++k1) { kh = nf - k1; ip = ifac[kh + 3]; l1 = l2 / ip; ido = *n / l2; idl1 = ido * l1; iw -= (ip - 1) * ido; na = 1 - na; if (ip != 4) { goto L102; } ix2 = iw + ido; ix3 = ix2 + ido; if (na != 0) { goto L101; } razf4_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3]); goto L110; L101: razf4_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3]); goto L110; L102: if (ip != 2) { goto L104; } if (na != 0) { goto L103; } razf2_(&ido, &l1, &c__[1], &ch[1], &wa[iw]); goto L110; L103: razf2_(&ido, &l1, &ch[1], &c__[1], &wa[iw]); goto L110; L104: if (ip != 3) { goto L106; } ix2 = iw + ido; if (na != 0) { goto L105; } razf3_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2]); goto L110; L105: razf3_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2]); goto L110; L106: if (ip != 5) { goto L108; } ix2 = iw + ido; ix3 = ix2 + ido; ix4 = ix3 + ido; if (na != 0) { goto L107; } razf5_(&ido, &l1, &c__[1], &ch[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); goto L110; L107: razf5_(&ido, &l1, &ch[1], &c__[1], &wa[iw], &wa[ix2], &wa[ix3], &wa[ ix4]); goto L110; L108: if (ido == 1) { na = 1 - na; } if (na != 0) { goto L109; } razfg_(&ido, &ip, &l1, &idl1, &c__[1], &c__[1], &c__[1], &ch[1], &ch[ 1], &wa[iw]); na = 1; goto L110; L109: razfg_(&ido, &ip, &l1, &idl1, &ch[1], &ch[1], &ch[1], &c__[1], &c__[1] , &wa[iw]); na = 0; L110: l2 = l1; /* L111: */ } if (na == 1) { return 0; } i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { c__[i__] = ch[i__]; /* L112: */ } return 0; } /* dfftf1_ */ /* Subroutine */ int dffti1_(integer *n, doublereal *wa, integer *ifac) { /* Initialized data */ static integer ntryh[4] = { 4,2,3,5 }; /* System generated locals */ integer i__1, i__2, i__3; /* Builtin functions */ /* Local variables */ integer i__, j, k1, l1, l2, ib; doublereal fi; integer ld, ii, nf, ip, nl, is, nq, nr; doublereal arg; integer ido, ipm; doublereal tpi; integer nfm1; doublereal argh; integer ntry = 0; doublereal argld; /* Parameter adjustments */ --ifac; --wa; /* Function Body */ nl = *n; nf = 0; j = 0; L101: ++j; if (j - 4 <= 0) { goto L102; } else { goto L103; } L102: ntry = ntryh[j - 1]; goto L104; L103: ntry += 2; L104: nq = nl / ntry; nr = nl - ntry * nq; if (nr != 0) { goto L101; } else { goto L105; } L105: ++nf; ifac[nf + 2] = ntry; nl = nq; if (ntry != 2) { goto L107; } if (nf == 1) { goto L107; } i__1 = nf; for (i__ = 2; i__ <= i__1; ++i__) { ib = nf - i__ + 2; ifac[ib + 2] = ifac[ib + 1]; /* L106: */ } ifac[3] = 2; L107: if (nl != 1) { goto L104; } ifac[1] = *n; ifac[2] = nf; tpi = 6.28318530717958647692; argh = tpi / (real) (*n); is = 0; nfm1 = nf - 1; l1 = 1; if (nfm1 == 0) { return 0; } i__1 = nfm1; for (k1 = 1; k1 <= i__1; ++k1) { ip = ifac[k1 + 2]; ld = 0; l2 = l1 * ip; ido = *n / l2; ipm = ip - 1; i__2 = ipm; for (j = 1; j <= i__2; ++j) { ld += l1; i__ = is; argld = (real) ld * argh; fi = 0.; i__3 = ido; for (ii = 3; ii <= i__3; ii += 2) { i__ += 2; fi += 1.; arg = fi * argld; wa[i__ - 1] = cos(arg); wa[i__] = sin(arg); /* L108: */ } is += ido; /* L109: */ } l1 = l2; /* L110: */ } return 0; } /* dffti1_ */ /* Subroutine */ int zffti1_(integer *n, doublereal *wa, integer *ifac) { /* Initialized data */ static integer ntryh[4] = { 3,4,2,5 }; /* System generated locals */ integer i__1, i__2, i__3; /* Builtin functions */ /* Local variables */ integer i__, j, i1, k1, l1, l2, ib; doublereal fi; integer ld, ii, nf, ip, nl, nq, nr; doublereal arg; integer ido, ipm; doublereal tpi, argh; integer idot, ntry = 0; doublereal argld; /* Parameter adjustments */ --ifac; --wa; /* Function Body */ nl = *n; nf = 0; j = 0; L101: ++j; if (j - 4 <= 0) { goto L102; } else { goto L103; } L102: ntry = ntryh[j - 1]; goto L104; L103: ntry += 2; L104: nq = nl / ntry; nr = nl - ntry * nq; if (nr != 0) { goto L101; } else { goto L105; } L105: ++nf; ifac[nf + 2] = ntry; nl = nq; if (ntry != 2) { goto L107; } if (nf == 1) { goto L107; } i__1 = nf; for (i__ = 2; i__ <= i__1; ++i__) { ib = nf - i__ + 2; ifac[ib + 2] = ifac[ib + 1]; /* L106: */ } ifac[3] = 2; L107: if (nl != 1) { goto L104; } ifac[1] = *n; ifac[2] = nf; tpi = 6.28318530717958647692; argh = tpi / (real) (*n); i__ = 2; l1 = 1; i__1 = nf; for (k1 = 1; k1 <= i__1; ++k1) { ip = ifac[k1 + 2]; ld = 0; l2 = l1 * ip; ido = *n / l2; idot = ido + ido + 2; ipm = ip - 1; i__2 = ipm; for (j = 1; j <= i__2; ++j) { i1 = i__; wa[i__ - 1] = 1.; wa[i__] = 0.; ld += l1; fi = 0.; argld = (real) ld * argh; i__3 = idot; for (ii = 4; ii <= i__3; ii += 2) { i__ += 2; fi += 1.; arg = fi * argld; wa[i__ - 1] = cos(arg); wa[i__] = sin(arg); /* L108: */ } if (ip <= 5) { goto L109; } wa[i1 - 1] = wa[i__ - 1]; wa[i1] = wa[i__]; L109: ; } l1 = l2; /* L110: */ } return 0; } /* zffti1_ */ }; ifrit-4.1.2/core/iparallelfft.h0000674060175406010010000000472212641012530014761 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPARALLELFFT_H #define IPARALLELFFT_H #include "iparallelworker.h" class iParallelFFT : protected iParallelWorker { public: static iParallelFFT* New(iParallelManager *pp); virtual void Delete(){ delete this; } // // data must be a float arrays with dimensions n1*n2*n3 // FFT component #icomp with ncomp altogether // dnyq (Nyquist frequency) must be a float arrays with dimensions 2*n2*n3 // Memory allocation is not checked. // int Transform(bool forward, int comp, int ncomp, int n1, int n2, int n3, float *data, float *dnyq); protected: virtual ~iParallelFFT(); private: iParallelFFT(iParallelManager *pp); virtual int ExecuteStep(int step, iParallel::ProcessorInfo &p); void ExecuteForwardTransform1(iParallel::ProcessorInfo &p); void ExecuteForwardTransform2(iParallel::ProcessorInfo &p); void ExecuteForwardTransform3(iParallel::ProcessorInfo &p); void ExecuteInverseTransform3(iParallel::ProcessorInfo &p); void ExecuteInverseTransform2(iParallel::ProcessorInfo &p); void ExecuteInverseTransform1(iParallel::ProcessorInfo &p); float *mWork1, *mWork2, *mWork3, *mW1, *mZ1, *mData, *mDnyq; int mNC, mN1, mN2, mN3, mN12, mNumProcs; float mProg, mProgStart, mProgScale; }; #endif // IPARALLELFFT_H ifrit-4.1.2/core/iparallelmanager.cpp0000674060175406010010000001725012641012560016152 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparallelmanager.h" #include "iarray.h" #include "ierror.h" #include "ieventobserver.h" #include "iparallel.h" #include "iparallelworker.h" #include "iviewmodule.h" #include #include #if defined(I_DEBUG) #include "ishell.h" #endif // // Templates // #include "iarray.tlh" using namespace iParallel; using namespace iParameter; #ifdef I_DEBUG int iParallelManager::DebugSwitch = 0; #endif // // Helper classes // class iParallelTimer { public: iParallelTimer() { mClock = vtkTimerLog::New(); IERROR_CHECK_MEMORY(mClock); mValue = 0.0; } ~iParallelTimer() { mClock->Delete(); } void Reset() { mValue = 0.0; } void Start() { mClock->StartTimer(); } void Stop() { mClock->StopTimer(); mValue += mClock->GetElapsedTime(); } double GetValue() const { return mValue; } private: vtkTimerLog *mClock; double mValue; }; class iParallelHelper { public: iParallelHelper() { mWallTimer = 0; } virtual ~iParallelHelper() { int i; if(mWallTimer != 0) delete mWallTimer; for(i=0; iGetMinMax(minnp,maxnp); mWallTimer = new iParallelTimer; IERROR_CHECK_MEMORY(mWallTimer); iParallelTimer *tmp; while(mProcTimers.Size() < maxnp) { tmp = new iParallelTimer; IERROR_CHECK_MEMORY(tmp); mProcTimers.Add(tmp); } } void ResetMaxNumProcs(int &n) { this->SetNumProcs(n); iParallelTimer *tmp; while(mProcTimers.Size() < n) { tmp = new iParallelTimer; IERROR_CHECK_MEMORY(tmp); mProcTimers.Add(tmp); } while(mProcTimers.Size() > n) delete mProcTimers.RemoveLast(); } void StartTimers() { int i; for(i=0; iReset(); if(mWallTimer != 0) { mWallTimer->Reset(); mWallTimer->Start(); } } bool StopTimers() { if(mWallTimer != 0) mWallTimer->Stop(); if(mProcTimers[0] != 0) return (mProcTimers[0]->GetValue() > 0.01); else return false; } double GetProcessorExecutionTime(int n) const { if(n>=0 && nGetValue(); else return 0.0; } double GetWallClockExecutionTime() const { if(mWallTimer != 0) return mWallTimer->GetValue(); else return 0.0; } int ExecuteWorkerInParallel(iParallelWorker *worker, ProcessorInfo &p) { if(worker!=0 && p.NumProcs<=mProcTimers.Size() && p.ThisProc>=0 && p.ThisProcStart(); int ret = worker->ExecuteInternal(p); mProcTimers[p.ThisProc]->Stop(); return ret; } else return 1; } virtual void GetMinMax(int &minnp, int &maxnp) = 0; virtual void SetNumProcs(int &np) = 0; virtual int ExecuteWorker(iParallelWorker *worker) = 0; protected: iArray mProcTimers; iParallelTimer *mWallTimer; }; // // Private namespace with actual helpers // namespace iParallelManager_Private { class SharedMemoryHelper : public iParallelHelper { public: SharedMemoryHelper() { mExec = vtkMultiThreader::New(); IERROR_CHECK_MEMORY(mExec); } virtual ~SharedMemoryHelper() { mExec->Delete(); } virtual void GetMinMax(int &minnp, int &maxnp) { minnp = 1; maxnp = mExec->GetGlobalDefaultNumberOfThreads(); } virtual void SetNumProcs(int &np) { mExec->SetNumberOfThreads(np); np = mExec->GetNumberOfThreads(); } virtual int ExecuteWorker(iParallelWorker *worker) { Data d; d.Self = this; d.Worker = worker; d.Value = 0; if(worker != 0) { mExec->SetSingleMethod(MySingleMethod,&d); mExec->SingleMethodExecute(); } return d.Value; } static VTK_THREAD_RETURN_TYPE MySingleMethod(void *input) { if(input != 0) { vtkMultiThreader::ThreadInfo *ti = (vtkMultiThreader::ThreadInfo * )input; Data *d = (Data * )ti->UserData; if(d != 0) { ProcessorInfo p; p.NumProcs = ti->NumberOfThreads; p.ThisProc = ti->ThreadID; d->Value = d->Self->ExecuteWorkerInParallel(d->Worker,p); } } return VTK_THREAD_RETURN_VALUE; } protected: struct Data { SharedMemoryHelper *Self; iParallelWorker *Worker; int Value; }; vtkMultiThreader *mExec; }; class SharedMemoryManager : public iParallelManager { public: SharedMemoryManager(iShell *s) : iParallelManager(s) { } protected: virtual iParallelHelper* CreateHelper() const { return new SharedMemoryHelper; } }; }; using namespace iParallelManager_Private; iParallelManager* iParallelManager::New(iShell *s) { iParallelManager *ret = new SharedMemoryManager(s); ret->Define(); return ret; } iParallelManager::iParallelManager(iShell *s) : iShellComponent(s) { } void iParallelManager::Define() { mHelper = this->CreateHelper(); if(mHelper != 0) { mHelper->Initialize(mMinNumProcs,mMaxNumProcs); this->SetNumberOfProcessors(1); #ifdef I_DEBUG iOutput::DisplayDebugMessage("Max # of procs: "+iString::FromNumber(mMaxNumProcs)+", using "+iString::FromNumber(this->GetNumberOfProcessors())); #endif mCount = 0; } else { mCount = -1; mNumProcs = mMinNumProcs = mMaxNumProcs = 1; } } iParallelManager::~iParallelManager() { if(mHelper != 0) delete mHelper; } int iParallelManager::ExecuteWorker(iParallelWorker *worker) { int ret; bool single = (mCount == 0); if(single) this->StartCounters(); if(mHelper!=0 && mNumProcs>1) { ret = mHelper->ExecuteWorker(worker); } else { ProcessorInfo p; if(worker != 0) ret = worker->ExecuteInternal(p); else ret = 1; } if(single) this->StopCounters(); return ret; } void iParallelManager::SetNumberOfProcessors(int n) { if(mHelper != 0) { if(n == 0) n = mMaxNumProcs; // auto-set to max available number if(n>0 && n<=mMaxNumProcs) { mNumProcs = n; mHelper->SetNumProcs(mNumProcs); } } } double iParallelManager::GetProcessorExecutionTime(int n) const { if(mHelper != 0) { return mHelper->GetProcessorExecutionTime(n); } else return 0.0; } double iParallelManager::GetWallClockExecutionTime() const { if(mHelper != 0) { return mHelper->GetWallClockExecutionTime(); } else return 0.0; } void iParallelManager::StartCounters() { if(mHelper != 0) { if(mCount == 0) { mHelper->StartTimers(); } mCount++; } } void iParallelManager::StopCounters() { if(mHelper != 0) { mCount--; if(mCount == 0) { if(mHelper->StopTimers()) this->InvokeEvent(InformationEvent,0); } #ifndef I_NO_CHECK if(mCount < 0) IBUG_WARN("Imbalanced start/stop counters."); #endif } } ifrit-4.1.2/core/iparallelmanager.h0000674060175406010010000000443212641012530015612 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPARALLELMANAGER_H #define IPARALLELMANAGER_H #include #include "ishellcomponent.h" class iParallelHelper; class iParallelUpdateEventObserver; class iParallelWorker; class iParallelManager : public vtkObject, public iShellComponent { public: static iParallelManager* New(iShell *s); int ExecuteWorker(iParallelWorker *worker); inline int GetMinNumberOfProcessors() const { return mMinNumProcs; } inline int GetMaxNumberOfProcessors() const { return mMaxNumProcs; } inline int GetNumberOfProcessors() const { return mNumProcs; } void SetNumberOfProcessors(int n); void StartCounters(); void StopCounters(); double GetProcessorExecutionTime(int n) const; double GetWallClockExecutionTime() const; #ifdef I_DEBUG static int DebugSwitch; #endif protected: iParallelManager(iShell *s); virtual ~iParallelManager(); virtual iParallelHelper* CreateHelper() const = 0; private: void Define(); int mNumProcs, mMinNumProcs, mMaxNumProcs; int mCount; iParallelHelper *mHelper; }; #endif // IPARALLELMANAGER_H ifrit-4.1.2/core/iparallelworker.cpp0000674060175406010010000000432412641012560016047 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparallelworker.h" #include "ierror.h" #include "iparallel.h" #include "iparallelmanager.h" #include "ishell.h" #include "ishelleventobservers.h" #include "iviewmodulecomponent.h" #include using namespace iParallel; iParallelWorker::iParallelWorker(iParallelManager *pm) { mManager = pm; IASSERT(mManager); mSerial = false; } iParallelWorker::~iParallelWorker() { } iParallelManager* iParallelWorker::GetManager() const { return mManager; } int iParallelWorker::ParallelExecute(int step) { int ret = 0; if(mSerial || mManager==0) { ProcessorInfo p; ret = this->ExecuteStep(step,p); } else { wStep = step; ret = mManager->ExecuteWorker(this); } if(ret != 0) IBUG_WARN("Failure in iParallelWorker::ParallelExecute."); return ret; } int iParallelWorker::ExecuteInternal(ProcessorInfo &p) { // // p is guaranteed to have the correct value for ThisProc and NumProcs (0<=ThisProcExecuteStep(wStep,p); } ifrit-4.1.2/core/iparallelworker.h0000674060175406010010000000374112641012530015513 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPARALLELWORKER_H #define IPARALLELWORKER_H namespace iParallel { struct ProcessorInfo; }; class iParallelManager; class iString; class iParallelWorker { friend class iParallelHelper; friend class iParallelManager; public: iParallelManager* GetManager() const; void SetExecuteSerially(bool s){ mSerial = s; } inline bool GetExecuteSerially(){ return mSerial; } virtual int ParallelExecute(int step); protected: iParallelWorker(iParallelManager *pp); virtual ~iParallelWorker(); virtual int ExecuteStep(int step, iParallel::ProcessorInfo &p) = 0; private: bool mSerial; iParallelManager *mManager; int wStep; // work variable int ExecuteInternal(iParallel::ProcessorInfo &p); }; #endif // IPARALLELWORKER_H ifrit-4.1.2/core/iparticleconnector.cpp0000674060175406010010000001635712641012560016550 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparticleconnector.h" #include "ierror.h" #include "imath.h" #include #include #include #include #include // // Templates // #include "igenericfilter.tlh" #define EQTOL 1.001 namespace iParticleConnector_Private { // // Do our own quick sort for efficiency reason (based on a Java code by Denis Ahrens) // #define SAVE(CELL,i1) { itmp = indx[i1]; } #define MOVE(i1,i2) { indx[i1] = indx[i2]; } #define RESTORE(i2,CELL) { indx[i2] = itmp; } #define SWAP(i1,i2) { SAVE(1,i1); MOVE(i1,i2); RESTORE(i2,1); } #define GREATER1(ind1,ind2) (data[mConnectVariable+nc*ind1]>data[mConnectVariable+nc*ind2]) #define GREATER2(ind1,ind2) ((data[mConnectionBreakVariable+nc*ind1]>EQTOL*data[mConnectionBreakVariable+nc*ind2])||((EQTOL*data[mConnectionBreakVariable+nc*ind1]>data[mConnectionBreakVariable+nc*ind2])&&(data[mConnectVariable+nc*ind1]>data[mConnectVariable+nc*ind2]))) // // Recursive worker // void SortWorker1(iParticleConnector *me, vtkIdType l, vtkIdType r, int nc, int mConnectVariable, float *data, vtkIdType *indx) { const int M = 8; vtkIdType i, j; vtkIdType v, itmp; if(me->GetAbortExecute()) return; if((r-l) > M) { // // Use quicksort // i = (r+l)/2; if(GREATER1(indx[l],indx[i])) // Tri-Median Method! { SWAP(l,i); } if(GREATER1(indx[l],indx[r])) { SWAP(l,r); } if(GREATER1(indx[i],indx[r])) { SWAP(i,r); } j = r-1; SWAP(i,j); i = l; v = indx[j]; for(;;) { do i++; while(GREATER1(v,indx[i])); // no ++i/--j in macro expansion! do j--; while(GREATER1(indx[j],v)); if(j < i) break; SWAP(i,j); } SWAP(i,r-1); SortWorker1(me,l,j,nc,mConnectVariable,data,indx); SortWorker1(me,i+1,r,nc,mConnectVariable,data,indx); } else { // // Array is small, use insertion sort. // for(i=l+1; i<=r; i++) { SAVE(1,i); v = indx[i]; j = i; while(j>l && GREATER1(indx[j-1],v)) { MOVE(j,j-1); j--; } RESTORE(j,1); } } } // // Interface // void Index1(iParticleConnector *me, vtkIdType n, int nc, int mConnectVariable, float *data, vtkIdType *indx) { vtkIdType j; for(j=0; jGetAbortExecute()) return; if((r-l) > M) { // // Use quicksort // i = (r+l)/2; if(GREATER2(indx[l],indx[i])) // Tri-Median Method! { SWAP(l,i); } if(GREATER2(indx[l],indx[r])) { SWAP(l,r); } if(GREATER2(indx[i],indx[r])) { SWAP(i,r); } j = r-1; SWAP(i,j); i = l; v = indx[j]; for(;;) { do i++; while(GREATER2(v,indx[i])); // no ++i/--j in macro expansion! do j--; while(GREATER2(indx[j],v)); if(j < i) break; SWAP(i,j); } SWAP(i,r-1); SortWorker2(me,l,j,nc,mConnectionBreakVariable,mConnectVariable,data,indx); SortWorker2(me,i+1,r,nc,mConnectionBreakVariable,mConnectVariable,data,indx); } else { // // Array is small, use insertion sort. // for(i=l+1; i<=r; i++) { SAVE(1,i); v = indx[i]; j = i; while(j>l && GREATER2(indx[j-1],v)) { MOVE(j,j-1); j--; } RESTORE(j,1); } } } // // Interface // void Index2(iParticleConnector *me, vtkIdType n, int nc, int mConnectionBreakVariable, int mConnectVariable, float *data, vtkIdType *indx) { vtkIdType j; for(j=0; j(consumer,1,true) { mConnectVariable = mConnectionBreakVariable = -1; } void iParticleConnector::SetConnectVariable(int a) { if(a>=-1 && a!=mConnectVariable) { mConnectVariable = a; this->Modified(); } } void iParticleConnector::SetConnectionBreakVariable(int a) { if(a>=-1 && a!=mConnectionBreakVariable) { mConnectionBreakVariable = a; this->Modified(); } } void iParticleConnector::ProvideOutput() { vtkPolyData *input = this->InputData(); vtkPolyData *output = this->OutputData(); output->ShallowCopy(input); if(mConnectVariable==-1 || input->GetPointData()->GetScalars()==0 || mConnectionBreakVariable==mConnectVariable) return; vtkFloatArray *inVars = iRequiredCast(INFO,input->GetPointData()->GetScalars()); vtkIdType np = input->GetNumberOfPoints(); vtkIdType nc = inVars->GetNumberOfComponents(); if(mConnectVariable<0 || mConnectVariable>=nc || mConnectionBreakVariable<-1 || mConnectionBreakVariable>=nc) return; vtkCellArray *olin; olin = vtkCellArray::New(); IERROR_CHECK_MEMORY(olin); vtkIdType id[2]; vtkIdType l; vtkIdType *ind; ind = new vtkIdType[np]; IERROR_CHECK_MEMORY(ind); float *data = inVars->GetPointer(0); if(mConnectionBreakVariable == -1) // no separation { Index1(this,np,nc,mConnectVariable,data,ind); #ifdef I_CHECK for(l=0; lUpdateProgress(double(l)/np); if(this->GetAbortExecute()) break; } id[0] = ind[l]; id[1] = ind[l+1]; olin->InsertNextCell(2,id); } } else { Index2(this,np,nc,mConnectionBreakVariable,mConnectVariable,data,ind); #ifdef I_CHECK for(l=0; lUpdateProgress(double(l)/np); if(this->GetAbortExecute()) break; } if(data[mConnectionBreakVariable+nc*ind[l]]*EQTOL > data[mConnectionBreakVariable+nc*ind[l+1]]) { id[0] = ind[l]; id[1] = ind[l+1]; olin->InsertNextCell(2,id); } } } delete [] ind; output->SetLines(olin); olin->Delete(); } ifrit-4.1.2/core/iparticleconnector.h0000674060175406010010000000353312641012530016202 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPARTICLECONNECTOR_H #define IPARTICLECONNECTOR_H #include "igenericfilter.h" #include class iParticleConnector : public iGenericPolyDataFilter { iGenericFilterTypeMacro(iParticleConnector,vtkPolyDataAlgorithm); public: inline int GetConnectVariable(){ return mConnectVariable; } void SetConnectVariable(int v); inline int GetConnectionBreakVariable(){ return mConnectionBreakVariable; } void SetConnectionBreakVariable(int v); protected: virtual void ProvideOutput(); private: int mConnectVariable, mConnectionBreakVariable; }; #endif ifrit-4.1.2/core/iparticledataconverter.cpp0000674060175406010010000002676212641012560017420 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparticledataconverter.h" //#include "idatalimits.h" #include "ierror.h" #include "imath.h" #include "iparticleviewsubject.h" #include "ipiecewisefunction.h" #include "ipointglyph.h" #include "istretch.h" #include "iviewmodule.h" #include #include #include #include #include #include #include #include // // Templates (needed for some compilers) // #include "iarray.tlh" #include "igenericfilter.tlh" using namespace iParameter; iParticleDataConverter* iParticleDataConverter::New(iViewInstance *owner) { IASSERT(owner); return new iParticleDataConverter(owner); } iParticleDataConverter::iParticleDataConverter(iViewInstance *owner) : iGenericPolyDataFilter(owner,1,true) { mOwner = iRequiredCast(INFO,owner); mSize = 0.005; mPoint = iPointGlyph::New(); IERROR_CHECK_MEMORY(mPoint); this->SetType(PointGlyphType::Point); } iParticleDataConverter::~iParticleDataConverter() { mPoint->Delete(); } int iParticleDataConverter::GetType() const { return mPoint->GetType(); } void iParticleDataConverter::SetType(int t) { mPoint->SetType(t); this->Modified(); } void iParticleDataConverter::SetSize(float s) { if(s>0.0 && s<1000.1) { mSize = 0.005*s; this->Modified(); } } void iParticleDataConverter::ProvideOutput() { int i, j; vtkIdType lp, lv; vtkIdType nCell1, *pCell1, pCell2[999]; double x0[3], x1[3], x2[3]; vtkPolyData *input = this->InputData(); vtkPolyData *output = this->OutputData(); output->ShallowCopy(input); if(mPoint->GetType() == PointGlyphType::Point) return; vtkPoints *inpPnts = input->GetPoints(); if(inpPnts == 0) return; vtkCellArray *inpVrts = input->GetVerts(); if(inpVrts == 0) return; // // Direct access to the input data // vtkIdType nInpVrts = inpVrts->GetNumberOfCells(); vtkIdType nInpPnts = inpPnts->GetNumberOfPoints(); if(nInpVrts<=0 || nInpPnts<=0) return; int sop; switch(inpPnts->GetDataType()) { case VTK_FLOAT: { sop = sizeof(float); break; } case VTK_DOUBLE: { sop = sizeof(double); break; } default: return; } // // Direct access to the glyph data // mPoint->Update(); vtkPoints *srcPnts = mPoint->GetData()->GetPoints(); if(srcPnts->GetDataType() != VTK_FLOAT) { vtkErrorMacro("Source points are not floats."); return; } float *srcPntsArr = (float *)srcPnts->GetVoidPointer(0); bool srcCellPoly = true; vtkCellArray *srcClls = mPoint->GetData()->GetPolys(); if(srcClls==0 || srcClls->GetNumberOfCells()==0) { srcClls = mPoint->GetData()->GetVerts(); srcCellPoly = false; } if(srcClls==0 || srcClls->GetNumberOfCells()==0) { vtkErrorMacro("Incorrect input to iParticleDataConverter"); return; } int sSrcNmls = 0; vtkFloatArray *srcNmls = 0; if(mPoint->GetData()->GetPointData()->GetNormals() != 0) { srcNmls = iRequiredCast(INFO,mPoint->GetData()->GetPointData()->GetNormals()); sSrcNmls = 1; } else if(mPoint->GetData()->GetCellData()->GetNormals() != 0) { srcNmls = iRequiredCast(INFO,mPoint->GetData()->GetCellData()->GetNormals()); sSrcNmls = -1; } float *srcNmlsArr = 0; if(srcNmls != 0) srcNmlsArr = (float *)srcNmls->GetVoidPointer(0); vtkIdType nSrcPnts = srcPnts->GetNumberOfPoints(); vtkIdType nSrcClls = srcClls->GetNumberOfCells(); vtkIdType nSrcCellMax = srcClls->GetMaxCellSize(); bool rotate = mPoint->GetOriented(); bool orient = false; // // Check if lines specified too // vtkIdType nOutPntsOff = 0; vtkCellArray *inpLins = 0; float *inpPntsDir = 0; if(input->GetLines()!=0 && input->GetLines()->GetNumberOfCells()>0) { inpLins = input->GetLines(); nOutPntsOff = nInpPnts; // // If lines are present, arrows and cones are oriented along the lines // if(mPoint->GetType()==PointGlyphType::Cone || mPoint->GetType()==PointGlyphType::Arrow) { orient = true; inpPntsDir = new float[3*nInpPnts]; if(inpPntsDir == 0) { vtkErrorMacro("There is not enough memory to convert the particle set data"); this->SetAbortExecute(1); return; } memset(inpPntsDir,0,3*nInpPnts*sizeof(float)); inpLins->InitTraversal(); while(inpLins->GetNextCell(nCell1,pCell1) != 0) { #ifndef I_NO_CHECK if(nCell1 != 2) { IBUG_WARN("Line contains more than 2 points!"); break; } #endif inpPnts->GetPoint(pCell1[0],x1); inpPnts->GetPoint(pCell1[1],x2); for(j=0; j<3; j++) { x0[j] = x2[j] - x1[j]; } vtkMath::Normalize(x0); for(j=0; j<3; j++) { inpPntsDir[3*pCell1[0]+j] += x0[j]; inpPntsDir[3*pCell1[1]+j] += x0[j]; } } for(lp=0; lpGetDataType()); IERROR_CHECK_MEMORY(outPnts); vtkCellArray *outClls = vtkCellArray::New(); IERROR_CHECK_MEMORY(outClls); // // Allocates and Sets MaxId // outPnts->SetNumberOfPoints(nOutPnts); // // If not enough memory - revert to points // if(outPnts->GetVoidPointer(0)==0 || outClls->Allocate(outClls->EstimateSize(nOutClls,nSrcCellMax))==0) { if(inpPntsDir != 0) delete [] inpPntsDir; outPnts->Delete(); outClls->Delete(); vtkErrorMacro("There is not enough memory to convert the particle set data"); this->SetAbortExecute(1); return; } // // Output normals // vtkFloatArray *outNmls = vtkFloatArray::New(); IERROR_CHECK_MEMORY(outNmls); outNmls->SetNumberOfComponents(3); float *outNmlsArr = 0; if(sSrcNmls > 0) { // Allocates and Sets MaxId outNmls->SetNumberOfTuples(nOutPnts); outNmlsArr = (float *)outNmls->GetVoidPointer(0); } else if(sSrcNmls < 0) { // Allocates and Sets MaxId outNmls->SetNumberOfTuples(nOutClls); outNmlsArr = (float *)outNmls->GetVoidPointer(0); } if(sSrcNmls!=0 && outNmlsArr==0) { if(inpPntsDir != 0) delete [] inpPntsDir; outPnts->Delete(); outClls->Delete(); outNmls->Delete(); vtkErrorMacro("There is not enough memory to convert the particle set data"); this->SetAbortExecute(1); return; } bool hasScalars = (input->GetPointData()->GetScalars() != 0); if(hasScalars && !wArray.Init(input->GetPointData()->GetScalars(),nOutPnts)) { outPnts->Delete(); outClls->Delete(); outNmls->Delete(); this->SetAbortExecute(1); return; } // // Variable for scaling // int cvar = mOwner->GetScaleVar(); // // Set fixed seed to make sure particles do not jump in an animation // vtkMath::RandomSeed(123456789); // // If lines specified, add original points first // if(nOutPntsOff > 0) { memcpy(outPnts->GetVoidPointer(0),inpPnts->GetVoidPointer(0),nInpPnts*3*sop); if(hasScalars) memcpy(wArray.PtrOut,wArray.PtrIn,nInpPnts*wArray.DimIn*sizeof(float)); if(sSrcNmls != 0) { memset(outNmlsArr,0,nInpPnts*3*sizeof(float)); // for(lp=0; lpGetScaleFactor(); // // Main loop // double mat[3][3]; double en, e[4]; // Euler quaternion float *s0 = 0; double s, ct, st, cp, sp; vtkIdType llPnts = nOutPntsOff, llClls = 0; outClls->InitTraversal(); inpVrts->InitTraversal(); for(lv=0; lvUpdateProgress(double(lv)/nInpVrts); if(this->GetAbortExecute()) break; } inpVrts->GetNextCell(nCell1,pCell1); #ifndef I_NO_CHECK if(nCell1 != 1) { IBUG_WARN("Vert contains more than 1 point!"); break; } #endif lp = pCell1[0]; inpPnts->GetPoint(lp,x0); s = mSize; if(hasScalars) { s0 = wArray.PtrIn + wArray.DimIn*lp; if(cvar >= 0) { s = scale*s0[cvar]; } } if(rotate) { if(orient) { ct = inpPntsDir[3*lp+2]; cp = inpPntsDir[3*lp+0]; st = sqrt(1.0-ct*ct); sp = sqrt(1.0-cp*cp); if(inpPntsDir[3*lp+1] < 0.0) sp = -sp; mat[0][0] = ct*cp; mat[1][0] = ct*sp; mat[2][0] = -st; mat[0][1] = -sp; mat[1][1] = cp; mat[2][1] = 0.0; mat[0][2] = st*cp; mat[1][2] = st*sp; mat[2][2] = ct; } else { en = 0.0; for(j=0; j<4; j++) { e[j] = vtkMath::Random(); en += e[j]*e[j]; } en = 1.0/sqrt(en); for(j=0; j<4; j++) e[j] *= en; // // There is a bug in VTK: the quaternion must be normalized, despite the claim to the opposite in the help // vtkMath::QuaternionToMatrix3x3(e,mat); } } srcClls->InitTraversal(); for(i=0; iGetNextCell(nCell1,pCell1); for(j=0; jInsertNextCell(nCell1,pCell2); if(sSrcNmls < 0) // cell normals { for(j=0; j<3; j++) outNmlsArr[3*llClls+j] = srcNmlsArr[3*i+j]; } llClls++; } for(i=0; iSetPoint(llPnts,x1); if(hasScalars) { for(j=0; j 0) // point normals { for(j=0; j<3; j++) outNmlsArr[3*llPnts+j] = srcNmlsArr[3*i+j]; } llPnts++; } } if(inpPntsDir != 0) delete [] inpPntsDir; output->SetPoints(outPnts); outPnts->Delete(); // // remove verts // output->SetVerts(0); if(srcCellPoly) { output->SetPolys(outClls); } else { output->SetVerts(outClls); } outClls->Delete(); if(hasScalars) { output->GetPointData()->SetScalars(wArray.ArrOut); wArray.ArrOut->Delete(); } if(sSrcNmls > 0) { output->GetPointData()->SetNormals(outNmls); } else if(sSrcNmls < 0) { output->GetCellData()->SetNormals(outNmls); } else { output->GetPointData()->SetNormals(0); output->GetCellData()->SetNormals(0); } outNmls->Delete(); } float iParticleDataConverter::GetMemorySize() { if(this->GetType() == PointGlyphType::Point) return 0.0; else return this->iGenericPolyDataFilter::GetMemorySize(); } ifrit-4.1.2/core/iparticledataconverter.h0000674060175406010010000000425312641012530017051 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Ifrit data filter: takes PolyData data with only vertices specified and // changes the point symbol. // #ifndef IPARTICLEDATACONVERTER_H #define IPARTICLEDATACONVERTER_H #include "igenericfilter.h" #include class iParticleViewInstance; class iPointGlyph; class iViewInstance; class iParticleDataConverter: public iGenericPolyDataFilter { vtkTypeMacro(iParticleDataConverter,vtkPolyDataAlgorithm); public: static iParticleDataConverter* New(iViewInstance *owner = 0); int GetType() const; inline float GetSize() const { return mSize; } virtual void SetType(int t); virtual void SetSize(float s); virtual float GetMemorySize(); protected: iParticleDataConverter(iViewInstance *owner); virtual ~iParticleDataConverter(); virtual void ProvideOutput(); private: float mSize; iPointGlyph *mPoint; iParticleViewInstance *mOwner; }; #endif // IPARTICLEDATACONVERTER_H ifrit-4.1.2/core/iparticledatasubject.cpp0000674060175406010010000000717212641012560017042 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparticledatasubject.h" #include "idata.h" #include "idatalimits.h" #include "ierror.h" #include "iparticlefileloader.h" #include "iparticleprobefilter.h" // // Templates // #include "iarray.tlh" #include "iproperty.tlh" iParticleDataSubject::iParticleDataSubject(iParticleFileLoader *fl, const iDataType& type) : iDataSubject(fl,type), iObjectConstructPropertyMacroQ(Bool,iParticleDataSubject,UseExtras,ue), iObjectConstructPropertyMacroS(Bool,iParticleDataSubject,TypeIncluded,ti), iObjectConstructPropertyMacroS(Int,iParticleDataSubject,DownsampleMode,dm), iObjectConstructPropertyMacroS(Int,iParticleDataSubject,DownsampleFactor,df), iObjectConstructPropertyMacroS(Bool,iParticleDataSubject,AddOrderAsVar,ov), iObjectConstructPropertyMacroS(Int,iParticleDataSubject,DensityVar,dv) { DensityVar.AddFlag(iProperty::_FunctionsAsIndex); mParticleLoader = fl; IASSERT(mParticleLoader); } iDataLimits* iParticleDataSubject::CreateLimits() const { return iDataLimits::New(this); } bool iParticleDataSubject::GetTypeIncluded() const { return mParticleLoader->GetTypeIncluded(this->GetId()); } int iParticleDataSubject::GetDownsampleMode() const { return mParticleLoader->GetDownsampleMode(); } int iParticleDataSubject::GetDownsampleFactor() const { return mParticleLoader->GetDownsampleFactor(this->GetId()); } bool iParticleDataSubject::GetAddOrderAsVar() const { return mParticleLoader->GetAddOrderAsVariable(this->GetId()); } int iParticleDataSubject::GetDensityVar() const { return mParticleLoader->GetDensityVariable(this->GetId()); } bool iParticleDataSubject::GetUseExtras() const { return mParticleLoader->IsUsingExtras(); } bool iParticleDataSubject::SetTypeIncluded(bool b) { mParticleLoader->SetTypeIncluded(this->GetId(),b); return true;; } bool iParticleDataSubject::SetDownsampleMode(int i) { mParticleLoader->SetDownsampleMode(i); return true;; } bool iParticleDataSubject::SetDownsampleFactor(int i) { mParticleLoader->SetDownsampleFactor(this->GetId(),i); return true;; } bool iParticleDataSubject::SetAddOrderAsVar(bool b) { mParticleLoader->SetAddOrderAsVariable(this->GetId(),b); return true;; } bool iParticleDataSubject::SetDensityVar(int i) { mParticleLoader->SetDensityVariable(this->GetId(),i); return true;; } iProbeFilter* iParticleDataSubject::CreateProbeFilter(iDataConsumer *consumer) const { return iParticleProbeFilter::New(consumer); } ifrit-4.1.2/core/iparticledatasubject.h0000674060175406010010000000563612641012530016507 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A base class for all DataSubjects of particle types. // #ifndef IPARTICLEDATASUBJECT_H #define IPARTICLEDATASUBJECT_H #include "idatasubject.h" class iParticleFileLoader; class iParticleDataSubject : public iDataSubject { friend class iParticleFileLoader; public: vtkTypeMacro(iParticleDataSubject,iDataSubject); iObjectPropertyMacro2Q(UseExtras,Bool); iObjectPropertyMacro2S(TypeIncluded,Bool); iObjectPropertyMacro2S(DownsampleMode,Int); iObjectPropertyMacro2S(DownsampleFactor,Int); iObjectPropertyMacro2S(AddOrderAsVar,Bool); iObjectPropertyMacro2S(DensityVar,Int); virtual iProbeFilter* CreateProbeFilter(iDataConsumer *consumer) const; protected: iParticleDataSubject(iParticleFileLoader *fl, const iDataType& type); virtual iDataLimits* CreateLimits() const; private: iParticleFileLoader *mParticleLoader; }; // // Useful macros to declare all members that have to be overwritten in children // #define iParticleDataSubjectDeclareClassMacro(_prefix_,_name_) \ class _prefix_##_name_##DataSubject : public iParticleDataSubject \ { \ public: \ vtkTypeMacro(_prefix_##_name_##DataSubject,iParticleDataSubject); \ static const iDataType& DataType(); \ const iDataType& GetDataType() const; \ _prefix_##_name_##DataSubject(iParticleFileLoader *fl); \ } #define iParticleDataSubjectDefineClassMacro(_prefix_,_name_,_fname_,_sname_,_keywords_,_environment_) \ iDataSubjectDefineTypeMacro(_prefix_##_name_##DataSubject,_prefix_##Extension::SubjectId(),_fname_,_sname_,0,_keywords_,_environment_); \ _prefix_##_name_##DataSubject::_prefix_##_name_##DataSubject(iParticleFileLoader *fl) : iParticleDataSubject(fl,_prefix_##_name_##DataSubject::DataType()){} #endif ifrit-4.1.2/core/iparticledensityestimator.cpp0000674060175406010010000001040212641012561020147 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparticledensityestimator.h" #include "ierror.h" #include "iparallel.h" #include "iparticlefileloader.h" #include "iviewmodule.h" #include #include #include #include #include #include #include iParticleDensityEstimator* iParticleDensityEstimator::New(iParticleFileLoader *loader) { IASSERT(loader); return new iParticleDensityEstimator(loader); } iParticleDensityEstimator::iParticleDensityEstimator(iParticleFileLoader *loader) : iParallelWorker(loader->GetViewModule()->GetParallelManager()) { mNumNeighbors = 16; mLocator = vtkPointLocator::New(); IERROR_CHECK_MEMORY(mLocator); mData = vtkPolyData::New(); IERROR_CHECK_MEMORY(mData); mLocator->SetDataSet(mData); } iParticleDensityEstimator::~iParticleDensityEstimator() { mLocator->Delete(); mData->Delete(); } void iParticleDensityEstimator::SetNumNeighbors(int num) { if(num > 1) { mNumNeighbors = num; } } void iParticleDensityEstimator::ComputeDensity(vtkPoints *points, vtkFloatArray *scalars, int varIn, int varOut) { if(points==0 || scalars==0 || scalars->GetDataType()!=VTK_FLOAT || varIn<-1 || varIn>=scalars->GetNumberOfComponents() || varOut<0 || varOut>=scalars->GetNumberOfComponents()) return; wVarIn = varIn; wVarOut = varOut; mData->SetPoints(points); mData->GetPointData()->SetScalars(scalars); this->InvokeEvent(vtkCommand::StartEvent); this->PrepareForStep(); this->ParallelExecute(1); this->InvokeEvent(vtkCommand::EndEvent); mData->SetPoints(0); mData->GetPointData()->SetScalars(0); } void iParticleDensityEstimator::PrepareForStep() { mLocator->BuildLocator(); } int iParticleDensityEstimator::ExecuteStep(int step, iParallel::ProcessorInfo &p) { vtkIdType l, kstp, kbeg, kend; vtkIdType id; int i, n; iParallel::SplitRange(p,mData->GetNumberOfPoints(),kbeg,kend,kstp); double r2, sr0, sr2, r2max, x[3], x1[3]; vtkPoints *points = mData->GetPoints(); int nc = mData->GetPointData()->GetScalars()->GetNumberOfComponents(); vtkIdList *result = vtkIdList::New(); if(result == 0) return 1; float v; float *ptrIn = (float *)mData->GetPointData()->GetScalars()->GetVoidPointer(0) + wVarIn; float *ptrOut = (float *)mData->GetPointData()->GetScalars()->GetVoidPointer(0) + wVarOut; for(l=kbeg; lUpdateProgress(double(l-kbeg)/(kend-kbeg)); if(this->GetAbortExecute()) break; } points->GetPoint(l,x); mLocator->FindClosestNPoints(mNumNeighbors,x,result); n = result->GetNumberOfIds(); sr0 = sr2 = r2max = 0.0; for(i=0; iGetId(i); points->GetPoint(id,x1); r2 = vtkMath::Distance2BetweenPoints(x,x1); v = (wVarIn == -1) ? 1.0 : ptrIn[nc*id]; sr0 += v; sr2 += v*r2; if(r2 > r2max) r2max = r2; } if(n>0 && r2max>0.0) { ptrOut[nc*l] = 2.5*(sr0-sr2/r2max)/(12.566*n*r2max*sqrt(r2max)); } else { ptrOut[nc*l] = (wVarIn == -1) ? 1.0 : ptrIn[nc*l]; } } result->Delete(); return 0; } ifrit-4.1.2/core/iparticledensityestimator.h0000674060175406010010000000474212641012531017623 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Helper class for computing particle density in place (NOT a filter!!!) - there is no elegant way to add // a variable without replicating the data in the memory. // It can be inherited to implement a faster density assignment scheme. // #ifndef IPARTICLEDENSITYESTIMATOR_H #define IPARTICLEDENSITYESTIMATOR_H #include #include "iparallelworker.h" class iParticleFileLoader; class vtkFloatArray; class vtkPointLocator; class vtkPoints; class vtkPolyData; class iParticleDensityEstimator : public vtkAlgorithm, protected iParallelWorker { public: vtkTypeMacro(iParticleDensityEstimator,vtkAlgorithm); static iParticleDensityEstimator* New(iParticleFileLoader *loader = 0); void SetNumNeighbors(int num); inline int GetNumNeighbors() const { return mNumNeighbors; } void ComputeDensity(vtkPoints *points, vtkFloatArray *scalars, int varIn, int varOut); protected: iParticleDensityEstimator(iParticleFileLoader *loader); virtual ~iParticleDensityEstimator(); virtual int ExecuteStep(int step, iParallel::ProcessorInfo &p); virtual void PrepareForStep(); int mNumNeighbors; vtkPolyData *mData; vtkPointLocator *mLocator; // // Work variables // int wVarIn, wVarOut; }; #endif // IPARTICLEDENSITYESTIMATOR_H ifrit-4.1.2/core/iparticledownsampleiterator.cpp0000674060175406010010000001347012641012561020473 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparticledownsampleiterator.h" #include "imath.h" #include // // Templates // #include "iarray.tlh" // // Main class // iParticleDownsampleIterator::iParticleDownsampleIterator() { mMaskId = -1; mDownsampleMode = 0; wIdTot = -1L; wIdLoc = wIdGlob = -1; wMask = 0; } iParticleDownsampleIterator::~iParticleDownsampleIterator() { } void iParticleDownsampleIterator::SetDownsampleMode(int v) { if(v>=0 && v<=5 && v!=mDownsampleMode) { mDownsampleMode = v; } } vtkIdType iParticleDownsampleIterator::GetNumGlobalTotal() const { int i; vtkIdType n = 0L; for(i=0; iCreateOneMask(i,ntot[i],df[i]); } vtkIdType iParticleDownsampleIterator::CreateOneMask(int i, vtkIdType ntot, int df) { if(i < 0) { IBUG_ERROR("Mask id should be non-negative.") return 0; } if(i == 0) { mMaskId = 0; while(mMasks.Size() > 0) mMasks.RemoveLast(); } else { if(i != mMaskId+1) { IBUG_ERROR("iParticleDownsampleIterator::PrepareMask should be called sequentially."); return 0; } mMaskId++; } while(i > mMasks.MaxIndex()) mMasks.Add(Mask()); mMasks[i].DownsampleFactor = df; if(df < 2) { mMasks[i].Dim1D = 1; mMasks[i].Dim2D = 1; mMasks[i].NumSelected = (df == 1) ? ntot : 0; mMasks[i].RandomThreshold = (df == 1) ? 0.0 : 1.0; } else { switch(mDownsampleMode) { case 1: { vtkIdType n1 = (vtkIdType)(0.5+sqrt(double(ntot))); if(n1>1 && n1*n1>ntot) n1--; mMasks[i].Dim1D = n1; mMasks[i].Dim2D = 1; vtkIdType ns = (mMasks[i].Dim1D+df-1)/df; mMasks[i].NumSelected = ns*ns; mMasks[i].RandomThreshold = 1.0; break; } case 2: { vtkIdType n1 = (vtkIdType)(0.5+pow(double(ntot),1.0/3.0)); if(n1>1 && n1*n1*n1>ntot) n1--; mMasks[i].Dim1D = n1; mMasks[i].Dim2D = n1*n1; vtkIdType ns = (mMasks[i].Dim1D+df-1)/df; mMasks[i].NumSelected = ns*ns*ns; mMasks[i].RandomThreshold = 1.0; break; } default: { mMasks[i].Dim1D = 1; mMasks[i].Dim2D = 1; mMasks[i].NumSelected = (ntot+df-1)/df; mMasks[i].RandomThreshold = 1.0/df; } } } mMasks[i].NumTotal = ntot; mMasks[i].NumSkipped = mMasks[i].NumTotal - mMasks[i].NumSelected; if(i == 0) { mMasks[i].OffsetTotal = 0; mMasks[i].OffsetSelected = 0; } else { mMasks[i].OffsetTotal = mMasks[i-1].OffsetTotal + mMasks[i-1].NumTotal; mMasks[i].OffsetSelected = mMasks[i-1].OffsetSelected + mMasks[i-1].NumSelected; } mMasks[i].Skip = false; mMasks[i].Buffer = 0; mMasks[i].BufferWidth = mMasks[i].BufferIncrement = 0; return mMasks[i].NumSelected; } bool iParticleDownsampleIterator::AttachBuffer(int i, vtkDataArray *array, int offset) { if(i>=0 && i=0 && offsetGetNumberOfComponents()) { mMasks[i].Buffer = (char *)array->GetVoidPointer(offset); mMasks[i].BufferWidth = array->GetNumberOfComponents(); mMasks[i].BufferIncrement = mMasks[i].BufferWidth*array->GetDataTypeSize(); return true; } else return false; } void iParticleDownsampleIterator::SkipMask(int n, bool s) { if(n>=0 && nmMasks.MaxIndex()) m = 0; wMask = mMasks.Data() + m; wIdTot = wMask->OffsetTotal - 1; wIdLoc = -1; wIdGlob = wMask->OffsetSelected - 1; } void iParticleDownsampleIterator::Stop(int m) { #ifndef I_NO_CHECK wIdTot++; wIdGlob++; if(m==-1 && wIdTot==wMask->OffsetTotal+wMask->NumTotal) { this->AdvanceCurrentMask(); } if(m<0 || m>mMasks.MaxIndex()) m = mMasks.MaxIndex(); if(wMask!=&mMasks[m] || wIdGlob!=wMask->NumSelected+wMask->OffsetSelected || wIdTot!=wMask->NumTotal+wMask->OffsetTotal) { IBUG_WARN("Internal check failed."); } #endif wIdTot = -1L; wIdLoc = wIdGlob = -1; wMask = 0; } void iParticleDownsampleIterator::AdvanceCurrentMask() { // // Do nothing if requested to advance the last mask // if(wMask == &mMasks[mMasks.MaxIndex()]) return; wMask++; while(wMask->Skip || wMask->NumTotal==0) { wIdTot += wMask->NumTotal; wIdGlob += wMask->NumSelected; wIdLoc = 0; if(wMask != &mMasks[mMasks.MaxIndex()]) wMask++; else break; } } #ifdef I_CHECK void iParticleDownsampleIterator::ReportBug() { IBUG_WARN("Internal check failed."); } #endif ifrit-4.1.2/core/iparticledownsampleiterator.h0000674060175406010010000001270412641012531020134 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Helper class for reading a subset of particles // #ifndef IPARTICLEDOWNSAMPLEITERATOR_H #define IPARTICLEDOWNSAMPLEITERATOR_H #include "iarray.h" #include class vtkDataArray; class iParticleDownsampleIterator { public: iParticleDownsampleIterator(); virtual ~iParticleDownsampleIterator(); void SetDownsampleMode(int v); inline int GetDownsampleMode() const { return mDownsampleMode; } inline vtkIdType GetNumTotal(int i) const { if(i>=0 && i=0 && i=0 && i=0 && i=0 && iBuffer + wMask->BufferIncrement*wIdLoc; } protected: // // Helper types // struct Mask { bool Skip; vtkIdType NumTotal; vtkIdType NumSkipped; vtkIdType OffsetTotal; vtkIdType NumSelected; vtkIdType OffsetSelected; int DownsampleFactor; vtkIdType Dim1D, Dim2D; float RandomThreshold; char *Buffer; int BufferWidth, BufferIncrement; Mask(){ NumTotal = NumSkipped = OffsetTotal = 0; NumSelected = OffsetSelected = 0; DownsampleFactor = 1; Dim1D = Dim2D = 1; RandomThreshold = 0.0f; Buffer = 0; BufferWidth = BufferIncrement = 0; } }; private: void AdvanceCurrentMask(); #ifdef I_CHECK void ReportBug(); #endif // // Members // int mMaskId, mDownsampleMode; iArray mMasks; // // Work variables // vtkIdType wIdTot; vtkIdType wIdGlob, wIdLoc; const Mask *wMask; }; // // Inlined for efficiency // inline bool iParticleDownsampleIterator::IsSelected() { wIdTot++; if(wIdTot == wMask->OffsetTotal+wMask->NumTotal) { this->AdvanceCurrentMask(); // advance the current mask; skip skipped and empty masks too } vtkIdType idt = wIdTot - wMask->OffsetTotal; bool ret = false; if(wMask->DownsampleFactor < 2) { ret = (wMask->DownsampleFactor == 1); } else { switch(mDownsampleMode) { case 0: { if(idt%wMask->DownsampleFactor == 0) ret = true; break; } case 1: { vtkIdType i2 = idt/wMask->Dim1D; vtkIdType i1 = idt - wMask->Dim1D*i2; if(i1%wMask->DownsampleFactor==0 && i2%wMask->DownsampleFactor==0 && i1Dim1D && i2Dim1D) ret = true; break; } case 2: { vtkIdType i3 = idt/wMask->Dim2D; vtkIdType i2 = idt/wMask->Dim1D - wMask->Dim1D*i3; vtkIdType i1 = idt - wMask->Dim1D*(i2+wMask->Dim1D*i3); if(i1%wMask->DownsampleFactor==0 && i2%wMask->DownsampleFactor==0 && i3%wMask->DownsampleFactor==0 && i1Dim1D && i2Dim1D && i3Dim1D) ret = true; break; } case 3: { if((wIdLoc+1NumSelected) && (wIdLoc+wMask->NumSkipped<=idt || vtkMath::Random()RandomThreshold)) ret = true; break; } case 4: { if(idt < wMask->NumSelected) ret = true; break; } case 5: { if(idt >= wMask->NumSkipped) ret = true; break; } } } if(ret) { wIdGlob++; wIdLoc = wIdGlob - wMask->OffsetSelected; #ifdef I_CHECK if(wIdLoc >= wMask->NumSelected) this->ReportBug(); #endif } return ret; } #endif // IPARTICLEDOWNSAMPLEITERATOR_H ifrit-4.1.2/core/iparticlefileloader.cpp0000674060175406010010000005251712641012561016663 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparticlefileloader.h" #include "ibuffer.h" #include "idata.h" #include "idatalimits.h" #include "idatareader.h" #include "idatasubject.h" #include "ierror.h" #include "imonitor.h" #include "iparallel.h" #include "iparallelmanager.h" #include "iparallelworker.h" #include "iparticledensityestimator.h" #include "ishell.h" #include "ishelleventobservers.h" #include "iviewmodule.h" #include #include #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "ibuffer.tlh" // // Helper classes for parallel execution & templates // class iParticleHelper : protected iParallelWorker { public: iParticleHelper(iParticleFileLoader *loader); void ShiftData(bool paf, int dim, vtkIdType n, bool per[3], double dr, float *pf, double *pd); void AddOrderAsVar(int var, int nc, vtkIdType n, float *pf); template bool ReadFortranRecordWithMaskTemplate(iFile &F, int dest, int inNum, int outOffset, double updateStart, double updateDuration, T *scale, T *offset); template void AutoScalePositions(); protected: virtual int ExecuteStep(int step, iParallel::ProcessorInfo &p); iParticleFileLoader *mLoader; bool *mPeriodic; float *mFarr; double *mDarr; int mDim, mCom, mNumProcs; bool mPaf; vtkIdType mTot; double mDr; }; // // Main class // iParticleFileLoader::iParticleFileLoader(iDataReader *r, int priority, bool useExtras) : iFileLoader(r,priority), mUseExtras(useExtras) { this->Define(); } iParticleFileLoader::iParticleFileLoader(iDataReaderExtension *ext, int priority, bool useExtras) : iFileLoader(ext,priority), mUseExtras(useExtras) { this->Define(); } void iParticleFileLoader::Define() { mHaveNormals = false; mHelper = new iParticleHelper(this); IERROR_CHECK_MEMORY(mHelper); mDensityEstimator = iParticleDensityEstimator::New(this); IERROR_CHECK_MEMORY(mDensityEstimator); mDensityEstimator->AddObserver(vtkCommand::StartEvent,this->GetShell()->GetExecutionEventObserver()); mDensityEstimator->AddObserver(vtkCommand::ProgressEvent,this->GetShell()->GetExecutionEventObserver()); mDensityEstimator->AddObserver(vtkCommand::EndEvent,this->GetShell()->GetExecutionEventObserver()); } iParticleFileLoader::~iParticleFileLoader() { delete mHelper; mDensityEstimator->Delete(); } void iParticleFileLoader::SetDownsampleMode(int v) { mIterator.SetDownsampleMode(v); this->GetReader()->RequestDataReload(this->GetDataInfo()); } int iParticleFileLoader::GetDownsampleMode() const { return mIterator.GetDownsampleMode(); } void iParticleFileLoader::SetNumNeighbors(int num) { mDensityEstimator->SetNumNeighbors(num); this->GetReader()->RequestDataReload(this->GetDataInfo()); } int iParticleFileLoader::GetNumNeighbors() const { return mDensityEstimator->GetNumNeighbors(); } void iParticleFileLoader::SetTypeIncluded(int type, bool s) { if(type>=0 && typeNumStreams()) { this->GetStream(type)->Included = s; this->GetReader()->RequestDataReload(this->GetDataType(type)); } } void iParticleFileLoader::SetDownsampleFactor(int type, int value) { if(value > 0) { if(type>=0 && typeNumStreams()) { this->GetStream(type)->DownsampleFactor = value; } else if(type == -1) { int i; for(i=0; iNumStreams(); i++) this->GetStream(i)->DownsampleFactor = value; } this->GetReader()->RequestDataReload(this->GetDataInfo()); } } void iParticleFileLoader::SetDensityVariable(int type, int var) { if(mUseExtras && type>=0 && typeNumStreams()) { this->GetStream(type)->Extras.DensityVariable = (var > -2) ? var : -2; this->GetReader()->RequestDataReload(this->GetDataInfo()); } } void iParticleFileLoader::SetAddOrderAsVariable(int type, bool s) { if(mUseExtras && type>=0 && typeNumStreams()) { this->GetStream(type)->Extras.AddOrderAsVariable = s; this->GetReader()->RequestDataReload(this->GetDataInfo()); } } void iParticleFileLoader::AddExtras(ParticleStream *stream) { int nvar = stream->NumVariablesInFile; // // If we save the order in file as a variable, fill it in. // if(stream->Extras.AddOrderAsVariable && nvarNumVariablesInData) { mHelper->AddOrderAsVar(nvar,stream->Scalars()->GetNumberOfComponents(),stream->Scalars()->GetNumberOfTuples(),stream->Scalars()->GetPointer(0)); nvar++; } // // Check if we need to add density // iMonitor h(this,"Operating",1.0); if(stream->Extras.DensityVariable>-2 && nvarNumVariablesInData && stream->Extras.DensityVariableComputeDensity(stream->Points(),stream->Scalars(),stream->Extras.DensityVariable,nvar); nvar++; } // // Final check // if(nvar != stream->NumVariablesInData) { IBUG_ERROR("iParticleFileLoader is configured icorrectly: unfilled variables remained."); h.PostError("Unable to read the data due to a bug."); } } void iParticleFileLoader::WrapPositions(vtkPoints *points) { int i; vtkIdType l, loff, ntot = points->GetNumberOfPoints(); // // Boundary condition // for(i=0; i<3; i++) this->SetDirectionPeriodic(i,true); if(this->GetBoundaryConditions() == iParameter::BoundaryConditions::Periodic) { if(points->GetDataType() == VTK_FLOAT) { float *xptrF = (float *)points->GetVoidPointer(0); for(i=0; i<3; i++) if(this->IsDirectionPeriodic(i)) { for(l=0; lGetDataType() == VTK_DOUBLE) { double *xptrD = (double *)points->GetVoidPointer(0); for(i=0; i<3; i++) if(this->IsDirectionPeriodic(i)) { for(l=0; lLoadParticleFileBody(suffix,fname); if(h.IsStopped()) return; h.SetInterval(0.8,0.2); // // Apply extras // for(i=0; iNumStreams(); i++) { this->WrapPositions(this->GetStream(i)->Points()); this->AddExtras(this->GetStream(i)); } for(i=0; iNumStreams(); i++) { this->AttachDataToStream(i,this->GetStream(i)->Data); } for(i=0; iNumStreams(); i++) { this->FinalizePolyData(this->GetStream(i)->Data); } } void iParticleFileLoader::ShiftDataBody(vtkDataSet *data, const double *dx) { int i; iMonitor h(this,"Shifting",1.0); for(i=0; i<3; i++) { h.SetInterval(i/3.0,1.0/3.0); if(fabs(dx[i]) > 1.0e-100) { this->ShiftPolyData(iRequiredCast(INFO,data),i,dx[i]); } } } void iParticleFileLoader::FinalizePolyData(vtkPolyData *data) { if(data==0 || data->GetPoints()==0) return; vtkIdType l, ntot = data->GetNumberOfPoints(); if(mHaveNormals) { vtkFloatArray *newNormals; newNormals = vtkFloatArray::New(); IERROR_CHECK_MEMORY(newNormals); newNormals->SetNumberOfComponents(3); // Allocates and Sets MaxId newNormals->SetNumberOfTuples(ntot); float *p = (float *)newNormals->GetVoidPointer(0); if(p != 0) { for(l=0; lGetPointData()->SetNormals(newNormals); } newNormals->Delete(); } } void iParticleFileLoader::ShiftPolyData(vtkPolyData *data, int d, double dx) { if(data==0 || data->GetPoints()==0 || d<0 || d>2) return; vtkIdType n = data->GetPoints()->GetNumberOfPoints(); float *pf = (float *)data->GetPoints()->GetVoidPointer(0); double *pd = (double *)data->GetPoints()->GetVoidPointer(0); if(pf!=0 && pd!=0) { mHelper->ShiftData(data->GetPoints()->GetDataType()==VTK_FLOAT,d,n,mPeriodic,dx,pf,pd); data->Modified(); } } bool iParticleFileLoader::ReadPositions(iFile &F, int inNum, int outOffset, double updateStart, double updateDuration, float *scale, float *offset) { return mHelper->ReadFortranRecordWithMaskTemplate(F,0,inNum,outOffset,updateStart,updateDuration,scale,offset); } bool iParticleFileLoader::ReadPositions(iFile &F, int inNum, int outOffset, double updateStart, double updateDuration, double *scale, double *offset) { return mHelper->ReadFortranRecordWithMaskTemplate(F,0,inNum,outOffset,updateStart,updateDuration,scale,offset); } bool iParticleFileLoader::ReadVariables(iFile &F, int inNum, int outOffset, double updateStart, double updateDuration, float *scale) { return mHelper->ReadFortranRecordWithMaskTemplate(F,1,inNum,outOffset,updateStart,updateDuration,scale,(float *)0); } bool iParticleFileLoader::ReadIntVariables(iFile &F, int inNum, int outOffset, double updateStart, double updateDuration) { return mHelper->ReadFortranRecordWithMaskTemplate(F,1,inNum,outOffset,updateStart,updateDuration,(float *)0,(float *)0); } void iParticleFileLoader::ConfigureStreams(vtkIdType *ntot, int *nvar, bool paf) { int n; ParticleStream *stream; for(n=0; nNumStreams(); n++) { stream = this->GetStream(n); if(stream->Data == 0) { stream->Data = vtkPolyData::New(); IERROR_CHECK_MEMORY(stream->Data); } vtkIdType nsel = mIterator.CreateOneMask(n,ntot[n],stream->Included?stream->DownsampleFactor:0); // // Determine how many extra (derived) variables we need. // int nvarIn = nvar[n]; if(stream->Extras.DensityVariable>-2 && stream->Extras.DensityVariableExtras.AddOrderAsVariable) nvar[n]++; // // Fill in stream info // stream->NumTotal = ntot[n]; stream->NumSelected = nsel; stream->NumVariablesInFile = nvarIn; stream->NumVariablesInData = nvar[n]; stream->InFile = true; // // Create data arrays // vtkPoints *oldPoints = stream->Data->GetPoints(); vtkCellArray *oldVerts = stream->Data->GetVerts(); vtkFloatArray *oldScalars = iRequiredCast(INFO,stream->Data->GetPointData()->GetScalars()); int type = paf ? VTK_FLOAT : VTK_DOUBLE; if(oldPoints==0 || oldPoints->GetNumberOfPoints()!=nsel || oldPoints->GetDataType()!=type) { stream->Data->SetPoints(0); // delete the old data first vtkPoints *points = vtkPoints::New(type); IERROR_CHECK_MEMORY(points); // Allocates and Sets MaxId points->SetNumberOfPoints(nsel); stream->Data->SetPoints(points); points->Delete(); } if(oldVerts==0 || oldVerts->GetNumberOfCells()!=nsel) { stream->Data->SetVerts(0); // delete the old data first vtkCellArray *verts = vtkCellArray::New(); IERROR_CHECK_MEMORY(verts); // This allocates but does not Set Max Id verts->Allocate(verts->EstimateSize(nsel,1)); vtkIdType l; for(l=0; lInsertNextCell(1); verts->InsertCellPoint(l); } stream->Data->SetVerts(verts); verts->Delete(); } if(oldScalars==0 || oldScalars->GetNumberOfTuples()!=nsel || oldScalars->GetNumberOfComponents()!=nvar[n]) { stream->Data->GetPointData()->SetScalars(0); // delete the old data first if(nvar[n] > 0) { vtkFloatArray *scalars = vtkFloatArray::New(); IERROR_CHECK_MEMORY(scalars); scalars->SetNumberOfComponents(nvar[n]); scalars->SetNumberOfTuples(nsel); stream->Data->GetPointData()->SetScalars(scalars); scalars->Delete(); } } } } void iParticleFileLoader::AutoScalePositions() { // // Scale positions automatically // vtkPoints *p = 0; int i; for(i=0; p==0 && iNumStreams(); i++) { if(this->GetStream(i)->Data->GetNumberOfPoints() > 0) { p = this->GetStream(i)->Points(); } } if(p == 0) return; switch(p->GetDataType()) { case VTK_FLOAT: { mHelper->AutoScalePositions(); break; } case VTK_DOUBLE: { mHelper->AutoScalePositions(); break; } } } // // Helper class // iParticleHelper::iParticleHelper(iParticleFileLoader *loader) : iParallelWorker(loader->GetViewModule()->GetParallelManager()) { mLoader = loader; IASSERT(loader); } void iParticleHelper::ShiftData(bool paf, int dim, vtkIdType n, bool per[3], double dr, float *pf, double *pd) { mPaf = paf; mDim = dim; mTot = n; mDr = dr; mFarr = pf; mDarr = pd; mPeriodic = per; iMonitor h(mLoader,"Shifting",1.0); this->ParallelExecute(1); } void iParticleHelper::AddOrderAsVar(int dim, int com, vtkIdType tot, float *pf) { mDim = dim; mCom = com; mTot = tot; mFarr = pf; iMonitor h(mLoader,"Formatting",1.0); this->ParallelExecute(2); } int iParticleHelper::ExecuteStep(int step, iParallel::ProcessorInfo &p) { vtkIdType l, kstp, kbeg, kend; int d = mDim; int nc = mCom; iParallel::SplitRange(p,mTot,kbeg,kend,kstp); switch(step) { case 1: { float dr = mDr; if(mPaf) { float *x = mFarr + 3*kbeg; for(l=kbeg; lGetShell()->GetExecutionEventObserver()->SetProgress(double(l-kbeg)/(kend-kbeg)); if(mLoader->GetShell()->GetExecutionEventObserver()->IsAborted()) return 2; } x[d] += 2.0*dr; if(mPeriodic[d]) { if(x[d] > 1.0) x[d] -= 2.0; if(x[d] < -1.0) x[d] += 2.0; } x += 3; } } else { double *x = mDarr + 3*kbeg; for(l=kbeg; lGetShell()->GetExecutionEventObserver()->SetProgress(double(l-kbeg)/(kend-kbeg)); if(mLoader->GetShell()->GetExecutionEventObserver()->IsAborted()) return 2; } x[d] += 2.0*dr; if(mPeriodic[d]) { if(x[d] > 1.0) x[d] -= 2.0; if(x[d] < -1.0) x[d] += 2.0; } x += 3; } } return 0; } case 2: { float *f = mFarr + mDim; for(l=kbeg; lGetShell()->GetExecutionEventObserver()->SetProgress(double(l-kbeg)/(kend-kbeg)); if(mLoader->GetShell()->GetExecutionEventObserver()->IsAborted()) return 2; } f[nc*l] = l; } return 0; } default: { return 1; } } } template bool iParticleHelper::ReadFortranRecordWithMaskTemplate(iFile &F, int dest, int inNum, int outOffset, double updateStart, double updateDuration, T *scale, T *offset) { iParticleDownsampleIterator &it(this->mLoader->mIterator); iMonitor h(this->mLoader); if(this->mLoader->NumStreams() == 0) { IBUG_ERROR("Streams must be configured prior to a call to iParticleFileLoader::ReadFortranRecordWithMask."); h.PostError("Unable to read the data due to a bug."); return false; } if(this->mLoader->NumStreams() != it.GetNumMasks()) { IBUG_ERROR("Masks must be created prior to a call to iParticleFileLoader::ReadFortranRecordWithMask."); h.PostError("Unable to read the data due to a bug."); return false; } // // Is component valid? // if(inNum<1 || outOffset<0) { IBUG_ERROR("Invalid call to iParticleFileLoader::ReadFortranRecordWithMask."); h.PostError("Unable to read the data due to a bug."); return false; } int j; vtkDataArray *arr; for(j=0; jmLoader->NumStreams(); j++) { if(this->mLoader->GetStream(j)->InFile) { switch(dest) { case 0: { arr = this->mLoader->GetStream(j)->Points()->GetData(); break; } case 1: { arr = this->mLoader->GetStream(j)->Scalars(); break; } default: { arr = 0; } } if((arr==0 && it.GetNumSelected(j)>0) || !it.AttachBuffer(j,arr,outOffset)) { IBUG_ERROR("Invalid call to iParticleFileLoader::ReadFortranRecordWithMask."); return false; } it.SkipMask(j,false); } else it.SkipMask(j,true); } // // Read the header // vtkIdType lrec1, lrec2; if(!this->mLoader->ReadFortranHeaderFooter(F,lrec1)) { h.PostError("Corrupted data."); return false; } // // Find # of components in the record // int nCompRec = lrec1/((vtkIdType)sizeof(T)*it.GetNumGlobalTotal()); if(lrec1 != nCompRec*sizeof(T)*it.GetNumGlobalTotal()) { h.PostError("Corrupted data."); return false; } // // Decide how to read // vtkIdType l, lpiece1, lpiece = it.GetNumGlobalTotal()/1000; if(lpiece < 1000) lpiece = 1000; int npieces = (it.GetNumGlobalTotal()+lpiece-1)/lpiece; // // Create tmp array // T *ptr, *ptmp; D *d = new D[lpiece*nCompRec]; if(d == 0) { h.PostError("Not enough memory to create the data."); return false; } // // parameters for the Progress Bar // updateDuration /= npieces; // // Read piece by piece // int i; it.Start(); for(j=0; jmLoader->ReadBlock(F,d,inNum*lpiece1,updateStart+j*updateDuration,updateDuration)) { h.PostError("Corrupted data."); delete [] d; return false; } if(h.IsAborted()) { delete [] d; return false; } for(l=0; lmLoader->ReadFortranHeaderFooter(F,lrec2) || lrec1!=lrec2) { h.PostError("Corrupted data."); return false; } // // Do we need to scale? // int nCompArr; vtkIdType nSizeArr; if(scale != 0) { if(offset != 0) { // // Scale as positions // for(j=0; j void iParticleHelper::AutoScalePositions() { // // Scale positions automatically // int i, j; vtkIdType l, np; T min[3], max[3], r = 0.0, *ptr; bool start = true; // // Find min/max // for(j=0; jmLoader->NumStreams(); j++) if(this->mLoader->GetStream(j)->Data->GetNumberOfPoints() > 0) { ptr = (T *)this->mLoader->GetStream(j)->Points()->GetVoidPointer(0); if(ptr == 0) continue; if(start) { start = false; for(i=0; i<3; i++) { min[i] = ptr[i]; max[i] = ptr[i]; } } np = this->mLoader->GetStream(j)->Points()->GetNumberOfPoints(); for(l=0; l max[i]) max[i] = ptr[3*l+i]; } } for(i=0; i<3; i++) { if(r < (max[i]-min[i])) r = max[i] - min[i]; } } if(!(r > 0.0)) return; r = 2.0/r; for(j=0; jmLoader->NumStreams(); j++) if(this->mLoader->GetStream(j)->Data->GetNumberOfPoints() > 0) { ptr = (T *)this->mLoader->GetStream(j)->Points()->GetVoidPointer(0); if(ptr == 0) continue; np = this->mLoader->GetStream(j)->Points()->GetNumberOfPoints(); for(l=0; lDelete(); } vtkPoints* iParticleFileLoader::ParticleStream::Points() const { IASSERT(Data); vtkPoints *p = Data->GetPoints(); IASSERT(p); return p; } vtkCellArray* iParticleFileLoader::ParticleStream::Verts() const { IASSERT(Data); vtkCellArray *c = Data->GetVerts(); IASSERT(c); return c; } vtkFloatArray* iParticleFileLoader::ParticleStream::Scalars() const { IASSERT(Data); IASSERT(Data->GetPointData()); return vtkFloatArray::SafeDownCast(Data->GetPointData()->GetScalars()); } iParticleFileLoader::Stream* iParticleFileLoader::CreateNewStream() const { return new ParticleStream; } iParticleFileLoader::ParticleStreamExtras::ParticleStreamExtras() { DensityVariable = -2; AddOrderAsVariable = false; } ifrit-4.1.2/core/iparticlefileloader.h0000674060175406010010000001230612641012531016315 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Abstract DataLoader for reading various particle files // #ifndef IPARTICLEFILELOADER_H #define IPARTICLEFILELOADER_H #include "ifileloader.h" #include "iparticledownsampleiterator.h" class iParticleDensityEstimator; class iParticleHelper; class vtkCellArray; class vtkDataArray; class vtkDoubleArray; class vtkFloatArray; class vtkPoints; class vtkPolyData; class iParticleFileLoader : public iFileLoader { friend class iParticleHelper; public: vtkTypeMacro(iParticleFileLoader,iFileLoader); void SetDownsampleMode(int v); int GetDownsampleMode() const; void SetTypeIncluded(int type, bool s); bool GetTypeIncluded(int type) const; void SetDownsampleFactor(int type, int value); int GetDownsampleFactor(int type) const; void SetDensityVariable(int type, int var); int GetDensityVariable(int type) const; void SetAddOrderAsVariable(int type, bool s); bool GetAddOrderAsVariable(int type) const; void SetNumNeighbors(int num); int GetNumNeighbors() const; inline bool IsUsingExtras() const { return mUseExtras; } protected: iParticleFileLoader(iDataReader *r, int priority = 300, bool useExtras = true); iParticleFileLoader(iDataReaderExtension *ext, int priority = 300, bool useExtras = true); virtual ~iParticleFileLoader(); struct ParticleStreamExtras { int DensityVariable; bool AddOrderAsVariable; ParticleStreamExtras(); }; struct ParticleStream : public Stream { bool Included, InFile; int DownsampleFactor; int NumVariablesInFile, NumVariablesInData; vtkIdType NumTotal; vtkIdType NumSelected; ParticleStreamExtras Extras; vtkPolyData *Data; ParticleStream(); virtual ~ParticleStream(); vtkPoints* Points() const; vtkCellArray* Verts() const; vtkFloatArray* Scalars() const; }; virtual Stream* CreateNewStream() const; inline ParticleStream* GetStream(int i) const { return static_cast(iFileLoader::GetStream(i)); } // no bound checking for speed virtual void LoadFileBody(const iString &suffix, const iString &fname); virtual void ShiftDataBody(vtkDataSet *data, const double *dx); virtual void LoadParticleFileBody(const iString &suffix, const iString &fname) = 0; virtual void AddExtras(ParticleStream *stream); // // helper functions // void WrapPositions(vtkPoints *points); void FinalizePolyData(vtkPolyData *data); void ShiftPolyData(vtkPolyData *data, int d, double dx); bool ReadPositions(iFile &F, int inNum, int outOffset, double updateStart, double updateDuration, float *scale, float *offset); bool ReadPositions(iFile &F, int inNum, int outOffset, double updateStart, double updateDuration, double *scale, double *offset); bool ReadVariables(iFile &F, int inNum, int outOffset, double updateStart, double updateDuration, float *scale = 0); bool ReadIntVariables(iFile &F, int inNum, int outOffset, double updateStart, double updateDuration); void AutoScalePositions(); void ConfigureStreams(vtkIdType *ntot, int *nvar, bool paf = true); iParticleDownsampleIterator mIterator; // value, not the pointer, for efficiency (to remove one level of indirection in loops) iParticleDensityEstimator *mDensityEstimator; private: void Define(); // // Members // const bool mUseExtras; bool mHaveNormals; iParticleHelper *mHelper; }; inline bool iParticleFileLoader::GetTypeIncluded(int type) const { if(type>=0 && typeNumStreams()) { return this->GetStream(type)->Included; } else return false; } inline int iParticleFileLoader::GetDownsampleFactor(int type) const { if(type>=0 && typeNumStreams()) { return this->GetStream(type)->DownsampleFactor; } else return 1; } inline int iParticleFileLoader::GetDensityVariable(int type) const { if(type>=0 && typeNumStreams()) { return this->GetStream(type)->Extras.DensityVariable; } else return 1; } inline bool iParticleFileLoader::GetAddOrderAsVariable(int type) const { if(type>=0 && typeNumStreams()) { return this->GetStream(type)->Extras.AddOrderAsVariable; } else return false; } #endif ifrit-4.1.2/core/iparticlepipeline.cpp0000674060175406010010000000523412641012561016354 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparticlepipeline.h" #include "ierror.h" #include "iparticledataconverter.h" #include "iparticleviewsubject.h" #include "ireplicatedpolydata.h" // // Templates // #include "iarray.tlh" #include "igenericfilter.tlh" #include "iviewsubjectpipeline.tlh" iPipelineKeyDefineMacro(iParticlePipeline,Type); iPipelineKeyDefineMacro(iParticlePipeline,Scaling); iPipelineKeyDefineMacro(iParticlePipeline,FixedSize); // // iParticlePipeline class // iParticlePipeline::iParticlePipeline(iParticleViewInstance *owner) : iReplicatedViewSubjectPipeline(owner,1) { mOwner = owner; // // Do VTK stuff // mDataConverter = this->CreateFilter(); this->CompletePipeline(mDataConverter->GetOutputPort()); this->UpdateContents(); } iParticlePipeline::~iParticlePipeline() { } bool iParticlePipeline::PrepareInput() { vtkPolyData *input = vtkPolyData::SafeDownCast(this->InputData()); if(input == 0) { IBUG_ERROR("iParticlePipeline is configured incorrectly."); return false; } if(mDataConverter->InputData() != input) { mDataConverter->SetInputData(input); } return true; } void iParticlePipeline::UpdateScaling() { mDataConverter->Modified(); this->Modified(); } void iParticlePipeline::UpdateType() { mDataConverter->SetType(mOwner->GetType()); this->Modified(); } void iParticlePipeline::UpdateFixedSize() { mDataConverter->SetSize(mOwner->GetFixedSize()); this->Modified(); } ifrit-4.1.2/core/iparticlepipeline.h0000674060175406010010000000375512641012531016024 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPARTICLEPIPELINE_H #define IPARTICLEPIPELINE_H #include "ireplicatedviewsubjectpipeline.h" class iParticleDataConverter; class iParticleViewInstance; class vtkPolyData; class iParticlePipeline : public iReplicatedViewSubjectPipeline { friend class iParticleViewInstance; public: vtkTypeMacro(iParticlePipeline,iReplicatedViewSubjectPipeline); iPipelineKeyDeclareMacro(iParticlePipeline,Type); iPipelineKeyDeclareMacro(iParticlePipeline,Scaling); iPipelineKeyDeclareMacro(iParticlePipeline,FixedSize); protected: iParticlePipeline(iParticleViewInstance *owner); virtual ~iParticlePipeline(); virtual bool PrepareInput(); iParticleViewInstance *mOwner; iParticleDataConverter *mDataConverter; }; #endif // IPARTICLEPIPELINE_H ifrit-4.1.2/core/iparticleprobefilter.cpp0000674060175406010010000000522212641012561017061 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparticleprobefilter.h" #include "ierror.h" #include "iviewsubject.h" #include #include // // Templates // #include "igenericfilter.tlh" iParticleProbeFilter::iParticleProbeFilter(iDataConsumer *consumer) : iProbeFilter(consumer) { } void iParticleProbeFilter::ProvideOutput() { vtkDataSet *input = this->InputData(); vtkDataSet *output = this->OutputData(); vtkDataSet *source = this->SourceData(); output->ShallowCopy(input); if(input->IsA("vtkPointSet") && output->IsA("vtkPointSet")) { vtkDataArray *atts = vtkDataSet::SafeDownCast(source)->GetPointData()->GetScalars(); if(atts!=0 && atts->GetSize()>0) { vtkFloatArray *outScalars = vtkFloatArray::New(); IERROR_CHECK_MEMORY(outScalars); outScalars->SetNumberOfComponents(atts->GetNumberOfComponents()); vtkPointLocator *locator = vtkPointLocator::New(); IERROR_CHECK_MEMORY(locator); locator->SetDataSet(vtkDataSet::SafeDownCast(source)); locator->BuildLocator(); vtkPoints *pts = vtkPointSet::SafeDownCast(input)->GetPoints(); vtkIdType i, l, n = pts->GetNumberOfPoints(); for(i=0; iFindClosestPoint(pts->GetPoint(i)); if(l != -1) outScalars->InsertNextTuple(atts->GetTuple(l)); else outScalars->InsertNextTuple(atts->GetTuple(0)); } output->GetPointData()->SetScalars(outScalars); outScalars->Delete(); locator->Delete(); } } } ifrit-4.1.2/core/iparticleprobefilter.h0000674060175406010010000000302112641012531016516 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPARTICLEPROBEFILTER_H #define IPARTICLEPROBEFILTER_H #include "iprobefilter.h" class iParticleProbeFilter : public iProbeFilter { iGenericFilterTypeMacro(iParticleProbeFilter,iProbeFilter); protected: virtual void ProvideOutput(); }; #endif // IPARTICLEPROBEFILTER_H ifrit-4.1.2/core/iparticlesplitter.cpp0000674060175406010010000003054612641012561016421 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparticlesplitter.h" #include "idataconsumer.h" #include "idatasubject.h" #include "ihistogrammaker.h" #include "ierror.h" #include #include #include #include #include #include #include // // Templates (needed for some compilers) // #include "iarray.tlh" #include "igenericfilter.tlh" namespace iParticleSplitter_Private { // // QuickFind // #define ARR(i) Vars[ncom*(i)+varSort] bool Find(vtkIdType n, int ncom, int varSort, float *Vars, vtkIdType iStart, float aval, vtkIdType &iLo, vtkIdType &iHi) { vtkIdType i1 = iStart; vtkIdType i2 = n - 1; vtkIdType ic; if(aval <= ARR(i1)) { iLo = i1; iHi = i1; return true; } if(aval >= ARR(i2)) { iLo = i2; iHi = i2; return true; } while(i2-i1 > 1) { ic = (i1+i2)/2; if(aval >= ARR(ic)) i1 = ic; if(aval <= ARR(ic)) i2 = ic; } iLo = i1; iHi = i2; return true; } // // QuickSort // #define SAVE(CELL,i1) { for(ii=0; ii<3; ii++) poi##CELL[ii] = Points[3*(i1)+ii]; for(ii=0; ii void SortWorker(vtkAlgorithm *filter, vtkIdType l, vtkIdType r, int ncom, int varSort, T *Points, float *Vars, float *Nrms, T *poi1, float *var1, float *nrm1) { const int M = 8; vtkIdType i, j; float v; int ii; if(filter!=0 && filter->GetAbortExecute()) return; if ((r-l)>M) { // // Use quicksort // i = (r+l)/2; if (ARR(l)>ARR(i)) SWAP(l,i); // Tri-Median Method! if (ARR(l)>ARR(r)) SWAP(l,r); if (ARR(i)>ARR(r)) SWAP(i,r); j = r-1; SWAP(i,j); i = l; v = ARR(j); for(;;) { do i++; while(ARR(i) < v); // no ++i/--j in macro expansion! do j--; while(ARR(j) > v); if (jl && ARR(j-1)>v) { MOVE(j,j-1); j--; } RESTORE(j,1); } } } // // Do our own quick sort for efficiency reason (based on a Java code by Denis Ahrens) // template void Sort(vtkAlgorithm *filter, vtkIdType n, int ncom, int varSort, T *Points, float *Vars, float* Nrms) { T poi1[3]; float nrm1[3]; float *var1; var1 = new float[ncom]; IERROR_CHECK_MEMORY(var1); SortWorker(filter,0,n-1,ncom,varSort,Points,Vars,Nrms,poi1,var1,nrm1); delete [] var1; } }; using namespace iParticleSplitter_Private; iParticleSplitter::iParticleSplitter(iDataConsumer *consumer) : iGenericPolyDataFilter(consumer,1,true) { mOwnsData = false; mSavedPoints = 0; mSavedVerts = 0; mSavedNorms = 0; mSavedVars = 0; vtkPolyData *i = InputData(); vtkPolyData *o = OutputData(); // // Splitter functionality // mSplitVariable = -1; mRanges.Add(iPair(-iMath::_LargeFloat,iMath::_LargeFloat)); mSorted = mSorterMode = false; mSortingMTime = 0; } iParticleSplitter::~iParticleSplitter() { if(mOwnsData) { mSavedPoints->Delete(); mSavedVerts->Delete(); mSavedNorms->Delete(); mSavedVars->Delete(); } } float iParticleSplitter::GetMemorySize() const { float s = 0.0; if(mOwnsData) { s += mSavedPoints->GetActualMemorySize(); s += mSavedVerts->GetActualMemorySize(); s += mSavedNorms->GetActualMemorySize(); s += mSavedVars->GetActualMemorySize(); } return s; } bool iParticleSplitter::CreatePiece(const iPair &p) { if(mSorterMode || mSplitVariable==-1) return false; // // Create a new piece (somehow it is not automatically generated - must be a VTK bug) // int n = this->GetNumberOfOutputPorts(); this->SetNumberOfOutputPorts(n+1); vtkPolyData *d = vtkPolyData::New(); IERROR_CHECK_MEMORY(d); this->GetExecutive()->SetOutputData(n,d); #ifndef I_NO_CHECK IASSERT(this->OutputData(n)); #endif mRanges.Add(p); this->Modified(); return true; } bool iParticleSplitter::DeletePiece(int n) { if(n>=0 && n1) { mRanges.Remove(n); int i; for(i=n; iGetExecutive()->SetOutputData(i,this->GetExecutive()->GetOutputData(i+1),this->GetExecutive()->GetOutputInformation(i+1)); } this->SetNumberOfOutputPorts(mRanges.Size()); return true; } else return false; } void iParticleSplitter::SetPieceRange(int n, const iPair &p) { if(n>=0 && nModified(); } } void iParticleSplitter::TakeOverData(bool s) { if(mOwnsData == s) return; mOwnsData = s; if(mOwnsData) { mSavedPoints = vtkPoints::New(); IERROR_CHECK_MEMORY(mSavedPoints); mSavedVerts = vtkCellArray::New(); IERROR_CHECK_MEMORY(mSavedVerts); mSavedNorms = vtkFloatArray::New(); IERROR_CHECK_MEMORY(mSavedNorms); mSavedVars = vtkFloatArray::New(); IERROR_CHECK_MEMORY(mSavedVars); } else { mSavedPoints->Delete(); mSavedPoints = 0; mSavedVerts->Delete(); mSavedVerts = 0; mSavedNorms->Delete(); mSavedNorms = 0; mSavedVars->Delete(); mSavedVars = 0; } this->Modified(); } void iParticleSplitter::SetSplitVariable(int v) { // // Reset to a single piece if the Variable changes // if(v!=mSplitVariable && v>=-1 && vGetLimits()->GetNumVars()) { mRanges.Clear(); this->SetNumberOfOutputPorts(1); mSplitVariable = v; mSorted = false; if(v == -1) { mRanges.Add(iPair(-iMath::_LargeFloat,iMath::_LargeFloat)); } else { mRanges.Add(this->GetLimits()->GetDataRange(mSplitVariable)); } this->Modified(); } } void iParticleSplitter::SetSorterMode(bool s) { if(s == mSorterMode) return; mSorterMode = s; // // Reset to a single piece if the Variable changes // if(s) { mRanges.Clear(); this->SetNumberOfOutputPorts(1); mSorted = false; mRanges.Add(iPair(-iMath::_LargeFloat,iMath::_LargeFloat)); this->Modified(); } } void iParticleSplitter::ProvideOutput() { vtkPolyData *input = this->InputData(); vtkPolyData *output = this->OutputData(); output->Initialize(); vtkPoints *newPoints, *oldPoints; vtkCellArray *newVerts, *oldVerts; vtkFloatArray *newNorms, *oldNorms; vtkFloatArray *newVars, *oldVars; if(mSorterMode || mSplitVariable==-1 || mSplitVariable>=this->GetLimits()->GetNumVars()) { output->ShallowCopy(input); if(!mSorterMode) return; } if(mOwnsData) { oldPoints = mSavedPoints; oldVerts = mSavedVerts; oldVars = mSavedVars; oldPoints->SetDataType(input->GetPoints()->GetDataType()); oldPoints->DeepCopy(input->GetPoints()); oldVerts->DeepCopy(input->GetVerts()); if(input->GetPointData()->GetNormals() != 0) { oldNorms = mSavedNorms; oldNorms->DeepCopy(input->GetPointData()->GetNormals()); } else { oldNorms = 0; } oldVars->DeepCopy(input->GetPointData()->GetScalars()); } else { oldPoints = input->GetPoints(); oldVerts = input->GetVerts(); if(input->GetPointData()->GetNormals() != 0) { oldNorms = vtkFloatArray::SafeDownCast(input->GetPointData()->GetNormals()); } else { oldNorms = 0; } oldVars = vtkFloatArray::SafeDownCast(input->GetPointData()->GetScalars()); } float *pPointsF = 0; double *pPointsD = 0; bool pointsAreFloat; switch(oldPoints->GetDataType()) { case VTK_FLOAT: { pointsAreFloat = true; pPointsF = (float *)oldPoints->GetVoidPointer(0); break; } case VTK_DOUBLE: { pointsAreFloat = false; pPointsD = (double *)oldPoints->GetVoidPointer(0); break; } default: { output->ShallowCopy(input); vtkErrorMacro("Incorrect Points type"); return; } } vtkIdType *pVerts = (vtkIdType *)oldVerts->GetPointer(); float *pNorms = 0; if(oldNorms != 0) pNorms = (float *)oldNorms->GetPointer(0); float *pVars = (float *)oldVars->GetPointer(0); int ncom = oldVars->GetNumberOfComponents(); vtkIdType ntup = oldVars->GetNumberOfTuples(); if(!mSorted || mSortingMTimeGetMTime()) { mSorted = true; mSortingMTime = input->GetMTime(); if(pointsAreFloat) { iParticleSplitter_Private::Sort(this,ntup,ncom,mSplitVariable,pPointsF,pVars,pNorms); } else { iParticleSplitter_Private::Sort(this,ntup,ncom,mSplitVariable,pPointsD,pVars,pNorms); } #ifdef I_CHECK for(vtkIdType l=0; l pVars[mSplitVariable+ncom*(l+1)]) { IBUG_WARN("Sorted incorrectly."); break; } #endif } if(mSorterMode) return; int n, nmax = mRanges.Size(); vtkIdType iLo, iHi; vtkIdType iStart, iTotal; vtkFloatArray *fArray; vtkDoubleArray *dArray; vtkIdTypeArray *jArray; for(n=0; n=ntup) { vtkErrorMacro("Error #3 in iGroupSplitter"); } else { output = this->OutputData(n); output->Initialize(); if(iTotal > 0) { newPoints = vtkPoints::New(oldPoints->GetDataType()); IERROR_CHECK_MEMORY(newPoints); if(pointsAreFloat) { fArray = vtkFloatArray::New(); IERROR_CHECK_MEMORY(fArray); fArray->SetNumberOfComponents(3); fArray->SetArray(pPointsF+3*iStart,3*iTotal,1); newPoints->SetData(fArray); fArray->Delete(); } else { dArray = vtkDoubleArray::New(); IERROR_CHECK_MEMORY(dArray); dArray->SetNumberOfComponents(3); dArray->SetArray(pPointsD+3*iStart,3*iTotal,1); newPoints->SetData(dArray); dArray->Delete(); } output->SetPoints(newPoints); newPoints->Delete(); newVars = vtkFloatArray::New(); IERROR_CHECK_MEMORY(newVars); newVars->SetNumberOfComponents(ncom); newVars->SetArray(pVars+ncom*iStart,ncom*iTotal,1); output->GetPointData()->SetScalars(newVars); newVars->Delete(); if(oldNorms != 0) { newNorms = vtkFloatArray::New(); IERROR_CHECK_MEMORY(newNorms); newNorms->SetNumberOfComponents(3); newNorms->SetArray(pNorms+3*iStart,3*iTotal,1); output->GetPointData()->SetNormals(newNorms); newNorms->Delete(); } newVerts = vtkCellArray::New(); IERROR_CHECK_MEMORY(newVerts); jArray = vtkIdTypeArray::New(); IERROR_CHECK_MEMORY(jArray); jArray->SetNumberOfComponents(1); jArray->SetArray(pVerts,2*iTotal,1); newVerts->SetCells(iTotal,jArray); jArray->Delete(); output->SetVerts(newVerts); newVerts->Delete(); } } } } ifrit-4.1.2/core/iparticlesplitter.h0000674060175406010010000000500612641012531016054 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPARTICLESPLITTER_H #define IPARTICLESPLITTER_H #include "igenericfilter.h" #include #include "iarray.h" #include "ipair.h" class iParticleViewSubject; class vtkPoints; class vtkCellArray; class vtkFloatArray; class vtkFloatArray; class iParticleSplitter : public iGenericPolyDataFilter { friend class iParticleViewSubject; iGenericFilterTypeMacro(iParticleSplitter,vtkPolyDataAlgorithm); public: inline int GetNumberOfPieces() const { return mRanges.Size(); } void SetSplitVariable(int v); inline int GetSplitVariable() const { return mSplitVariable; } void SetSorterMode(bool s); inline bool GetSorterMode() const { return mSorterMode; } const iPair& GetPieceRange(int n) const { return mRanges[n]; } void SetPieceRange(int n, const iPair &p); bool CreatePiece(const iPair &p); bool DeletePiece(int n); void TakeOverData(bool); float GetMemorySize() const; protected: virtual ~iParticleSplitter(); virtual void ProvideOutput(); private: int mSplitVariable; bool mOwnsData, mSorted, mSorterMode; iArray mRanges; vtkPoints *mSavedPoints; vtkCellArray *mSavedVerts; vtkFloatArray *mSavedNorms; vtkFloatArray *mSavedVars; unsigned long mSortingMTime; }; #endif // IPARTICLESPLITTER_H ifrit-4.1.2/core/iparticleviewsubject.cpp0000775060175406010010000003603512641012561017106 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iparticleviewsubject.h" #include "iactor.h" #include "icolorbar.h" #include "icommondatadistributors.h" #include "icoredatasubjects.h" #include "idatalimits.h" #include "idatareader.h" #include "idatasubject.h" #include "ierror.h" #include "ilookuptable.h" #include "imath.h" #include "iparticleconnector.h" #include "iparticlepipeline.h" #include "iparticlesplitter.h" #include "ipointglyph.h" #include "irendertool.h" #include "istretch.h" #include "iviewmodule.h" #include "iviewmoduleeventobservers.h" #include "iviewobject.h" #include "iviewsubjectparallelpipeline.h" #include #include #include #include #include // // Templates (needed for some compilers) // #include "iarray.tlh" #include "igenericfilter.tlh" #include "iproperty.tlh" using namespace iParameter; namespace iParticleViewSubject_Private { class CameraEventObserver : public iEventObserver { public: vtkTypeMacro(CameraEventObserver,iEventObserver); static CameraEventObserver* New(iParticleViewInstance *owner = 0) { IASSERT(owner); return new CameraEventObserver(owner); } void Activate(bool s) { if(s) { mReferenceSize = mOwner->GetFixedSize(); mParallelScale = mCamera->GetParallelScale(); mDistance = mCamera->GetDistance(); } else { mReferenceSize = -1.0; } } protected: CameraEventObserver(iParticleViewInstance *owner) : iEventObserver() { mOwner = owner; mReferenceSize = -1.0; mParallelScale = mDistance = 0.0; mCamera = mOwner->GetViewModule()->GetRenderer()->GetActiveCamera(); mCamera->AddObserver(vtkCommand::ModifiedEvent,this); mCamera->Register(this); } ~CameraEventObserver() { mCamera->RemoveObserver(this); mCamera->UnRegister(this); } virtual void ExecuteBody(vtkObject *caller, unsigned long event, void *) { if(caller==mCamera && event==vtkCommand::ModifiedEvent) { if(mReferenceSize > 0.0) { if(mCamera->GetParallelProjection() != 0) { mOwner->SetFixedSize(mReferenceSize*mCamera->GetParallelScale()/mParallelScale); } else { mOwner->SetFixedSize(mReferenceSize*mCamera->GetDistance()/mDistance); } } } } private: vtkCamera *mCamera; iParticleViewInstance *mOwner; double mReferenceSize, mParallelScale, mDistance; }; }; using namespace iParticleViewSubject_Private; // // Single instance class // iParticleViewInstance::iParticleViewInstance(iParticleViewSubject *owner) : iPaintedViewInstance(owner,2,0.99,2,ColorBarPriority::Particles,false) { mRealOwner = owner; mType = PointGlyphType::Point; mScaleVar = -1; mFixedSize = 1.0; mScaleFactor = 1.0; mLineWidth = 1; mAutoScaled = false; mConnector = iParticleConnector::New(this); IERROR_CHECK_MEMORY(mConnector); mCameraEventObserver = CameraEventObserver::New(this); IERROR_CHECK_MEMORY(mCameraEventObserver); mConnector->AddObserver(vtkCommand::ProgressEvent,this->GetViewModule()->GetRenderEventObserver()); mActors[0]->GetProperty()->SetPointSize(mFixedSize); mActors[0]->GetProperty()->SetLineWidth(mLineWidth); mActors[1]->GetProperty()->SetPointSize(1); mActors[1]->GetProperty()->SetLineWidth(1); mActors[1]->VisibilityOff(); mActors[1]->PickableOff(); this->SetColor(owner->GetDefaultColor()); } iParticleViewInstance::~iParticleViewInstance() { mCameraEventObserver->Delete(); mConnector->Delete(); } void iParticleViewInstance::ConfigureBody() { // // Create pipeline (must be created after the object is fully created) // this->AddMainPipeline(1); mActors[0]->SetInputConnection(mConnector->GetOutputPort()); mActors[1]->SetInputConnection(this->Pipeline()->GetOutputPort()); this->Pipeline()->SetInputConnection(mConnector->GetOutputPort()); } void iParticleViewInstance::SetInputConnection(vtkAlgorithmOutput *port) { mConnector->SetInputConnection(port); } iViewSubjectPipeline* iParticleViewInstance::CreatePipeline(int) { return new iParticlePipeline(this); } void iParticleViewInstance::ConfigureMainPipeline(iViewSubjectPipeline *p, int) { iViewSubjectParallelPipeline *pp = iRequiredCast(INFO,p); pp->GetDataManager()->AddDistributor(new iPolyDataDistributor(pp->GetDataManager())); pp->GetDataManager()->AddCollector(new iPolyDataCollector(pp->GetDataManager(),0)); } void iParticleViewInstance::ShowBody(bool show) { if(show) { mActors[0]->VisibilityOn(); if(mType != PointGlyphType::Point) mActors[1]->VisibilityOn(); } else { mActors[0]->VisibilityOff(); mActors[1]->VisibilityOff(); } } bool iParticleViewInstance::SetType(int t) { if(t<0 || t>=PointGlyphType::SIZE) return false; mType = t; this->Pipeline()->UpdateContents(iParticlePipeline::KeyType); if(mType == PointGlyphType::Point) { mActors[0]->GetProperty()->SetPointSize(mFixedSize); mActors[1]->VisibilityOff(); } else { mActors[0]->GetProperty()->SetPointSize(1.0); mActors[1]->SetVisibility(mActors[0]->GetVisibility()); } return true; } bool iParticleViewInstance::SetScaleVar(int v) { if(v<-1 || (this->IsThereData() && v>=this->GetLimits()->GetNumVars())) return false; if(mScaleVar != v) { mScaleVar = v; this->Pipeline()->UpdateContents(iParticlePipeline::KeyScaling); } return true; } bool iParticleViewInstance::SetFixedSize(float s) { if(s>0.0 && s<1000.1) { mFixedSize = s; if(mType == PointGlyphType::Point) mActors[0]->GetProperty()->SetPointSize(mFixedSize); this->Pipeline()->UpdateContents(iParticlePipeline::KeyFixedSize); return true; } else return false; } bool iParticleViewInstance::SetScaleFactor(float f) { if(f > 0.0) { mScaleFactor = f; this->Pipeline()->UpdateContents(iParticlePipeline::KeyScaling); return true; } else return false; } bool iParticleViewInstance::SetLineWidth(int w) { if(w>=1 && w<=100) { mLineWidth = w; mActors[0]->GetProperty()->SetLineWidth(mLineWidth); return true; } else return false; } bool iParticleViewInstance::SetAutoScaled(bool s) { if(s != mAutoScaled) { mAutoScaled = s; iRequiredCast(INFO,mCameraEventObserver)->Activate(s); } return true; } bool iParticleViewInstance::SetConnectVar(int a) { mConnector->SetConnectVariable(a); return true; } bool iParticleViewInstance::SetConnectionBreakVar(int a) { mConnector->SetConnectionBreakVariable(a); return true; } int iParticleViewInstance::GetConnectVar() const { return mConnector->GetConnectVariable(); } int iParticleViewInstance::GetConnectionBreakVar() const { return mConnector->GetConnectionBreakVariable(); } bool iParticleViewInstance::SyncWithDataBody() { if(mScaleVar >= this->GetLimits()->GetNumVars()) this->SetScaleVar(-1); if(this->GetConnectVar() >= this->GetLimits()->GetNumVars()) this->SetConnectVar(-1); if(this->GetConnectionBreakVar() >= this->GetLimits()->GetNumVars()) this->SetConnectionBreakVar(-1); return true; } bool iParticleViewInstance::CanBeShown() const { return this->IsThereData(); } bool iParticleViewInstance::IsConnectedToPaintingData() const { return this->IsThereData(); } // // Main class // iParticleViewSubject* iParticleViewSubject::New(iViewObject *parent,const iDataType &type,const iColor &color) { iParticleViewSubject *obj = new iParticleViewSubject(parent,type,color); IERROR_CHECK_MEMORY(obj); obj->InitInstances(); return obj; } iParticleViewSubject::iParticleViewSubject(iViewObject *parent, const iDataType &type, const iColor &color) : iPaintedViewSubject(parent,parent->LongName(),parent->ShortName(),parent->GetViewModule(),type,type,ViewObject::Flag::IsSameColor|ViewObject::Flag::IsSameOpacity,1,iMath::_IntMax), SplitVar(iObject::Self(),static_cast(&iParticleViewSubject::SetSplitVar),static_cast(&iParticleViewSubject::GetSplitVar),"SplitVar","v",9), SplitRanges(iObject::Self(),static_cast(&iParticleViewSubject::SetSplitRanges),static_cast(&iParticleViewSubject::GetSplitRanges),"SplitRanges","r",static_cast(&iParticleViewSubject::SizeSplitRanges),static_cast(&iParticleViewSubject::ResizeSplitRanges),8), SplitRangesTiled(iObject::Self(),static_cast(&iParticleViewSubject::SetSplitRangesTiled),static_cast(&iParticleViewSubject::GetSplitRangesTiled),"SplitRangesTiled","rt",7), iViewSubjectPropertyConstructMacro(Int,iParticleViewInstance,Type,t), iViewSubjectPropertyConstructMacro(Int,iParticleViewInstance,ScaleVar,sv), iViewSubjectPropertyConstructMacro(Float,iParticleViewInstance,ScaleFactor,sf), iViewSubjectPropertyConstructMacro(Float,iParticleViewInstance,FixedSize,s), iViewSubjectPropertyConstructMacro(Int,iParticleViewInstance,LineWidth,lw), iViewSubjectPropertyConstructMacro(Bool,iParticleViewInstance,AutoScaled,au), iViewSubjectPropertyConstructMacro(Int,iParticleViewInstance,ConnectVar,cv), iViewSubjectPropertyConstructMacro(Int,iParticleViewInstance,ConnectionBreakVar,cbv), iObjectConstructPropertyMacroS(Int,iParticleViewSubject,RenderSortVar,rsv) { SplitVar.AddFlag(iProperty::_FunctionsAsIndex); ScaleVar.AddFlag(iProperty::_FunctionsAsIndex); ConnectVar.AddFlag(iProperty::_FunctionsAsIndex); ConnectionBreakVar.AddFlag(iProperty::_FunctionsAsIndex); mSplitter = iParticleSplitter::New(this); IERROR_CHECK_MEMORY(mSplitter); mSplitVar = mRenderSortVar = -1; mSplitRangesTiled = false; if(color.IsValid()) mDefaultColor = color; } iParticleViewSubject::~iParticleViewSubject() { mSplitter->Delete(); } void iParticleViewSubject::InitInstances() { this->iViewSubject::InitInstances(); iRequiredCast(INFO,mInstances[0])->SetInputConnection(mSplitter->GetOutputPort()); } bool iParticleViewSubject::CreateInstance() { int oldLast = mSplitter->GetNumberOfPieces() - 1; iPair pold(mSplitter->GetPieceRange(oldLast)); iPair pnew(0.5*(pold.Min+pold.Max),pold.Max); pold.Max = pnew.Min; if(!mSplitter->CreatePiece(pold)) return false; // // Create a new piece // iParticleViewInstance *ins = new iParticleViewInstance(this); if(ins == 0) { mSplitter->DeletePiece(mSplitter->GetNumberOfPieces()-1); return false; } ins->Configure(); int newLast = mInstances.Size(); mInstances.Add(ins); // // Set the correct piece number // this->CopyInstances(newLast,oldLast); ins->SetInputConnection(mSplitter->GetOutputPort(mSplitter->GetNumberOfPieces()-1)); this->SetSplitRanges(oldLast,pold); this->SetSplitRanges(newLast,pnew); ins->Show(this->IsVisible()); return true; } bool iParticleViewSubject::RemoveInstance(int n) { if(mSplitter->DeletePiece(n)) { mInstances[n]->Delete(); mInstances.Remove(n); return true; } else return false; } void iParticleViewSubject::BecomeClone(iViewSubject *v) { mSplitter->TakeOverData(v != 0); } bool iParticleViewSubject::SyncWithDataBody() { mSplitter->SetInputData(vtkPolyData::SafeDownCast(this->GetSubject()->GetData())); this->SetSplitRangesTiled(mSplitRangesTiled); return true; } bool iParticleViewSubject::SetSplitVar(int v) { if(v!=-1 && mSplitter->GetSorterMode()) return false; if(v == mSplitVar) return true; mSplitter->SetSplitVariable(v); if(mSplitVar != mSplitter->GetSplitVariable()) { mSplitVar = mSplitter->GetSplitVariable(); while(mInstances.MaxIndex() > 0) { mInstances[mInstances.MaxIndex()]->Delete(); mInstances.Remove(mInstances.MaxIndex()); } mSplitRangesTiled = false; return true; } else return false; } bool iParticleViewSubject::SetRenderSortVar(int v) { if(v<-1 || (this->IsThereData() && v>=this->GetLimits()->GetNumVars())) return false; if(mRenderSortVar != v) { mRenderSortVar = v; if(v > -1) { this->SetSplitVar(-1); mSplitter->SetSplitVariable(mRenderSortVar); mSplitter->SetSorterMode(true); } else { mSplitter->SetSorterMode(false); } } return true; } bool iParticleViewSubject::SetSplitRangesTiled(bool s) { mSplitRangesTiled = s; if(mSplitVar==-1 || !s) return true; float min = iStretch::Apply(this->GetLimits()->GetMin(mSplitVar),this->GetLimits()->GetStretchId(mSplitVar),false); float max = iStretch::Apply(this->GetLimits()->GetMax(mSplitVar),this->GetLimits()->GetStretchId(mSplitVar),true); iArray &arr(mSplitter->mRanges); // cache for speed // // arange all ranges in a tiled sequence // int i; float d = (max-min)/arr.Size(); for(i=0; iGetLimits()->GetStretchId(mSplitVar)); arr[i].Max = iStretch::Reset(min+d*(i+1),this->GetLimits()->GetStretchId(mSplitVar)); } mSplitter->Modified(); return true; } int iParticleViewSubject::SizeSplitRanges() const { return mInstances.Size(); } bool iParticleViewSubject::ResizeSplitRanges(int n) { if(n < 1) return false; while(n < mInstances.Size()) { if(!this->RemoveInstance(mInstances.MaxIndex())) { mSplitRangesTiled = false; return false; } } while(n > mInstances.Size()) { if(!this->CreateInstance()) { mSplitRangesTiled = false; return false; } } this->SetSplitRangesTiled(mSplitRangesTiled); return true; } bool iParticleViewSubject::SetSplitRanges(int i, const iPair& p) { // // Special case - one range changed in a tiled mode // iPair p1(p); if(mSplitRangesTiled) { iArray &arr(mSplitter->mRanges); // cache for speed if(i == 0) { p1.Min = arr[0].Min; } else { arr[i-1].Max = p1.Min; } if(i == arr.MaxIndex()) { p1.Max = arr[arr.MaxIndex()].Max; } else { arr[i+1].Min = p1.Max; } } mSplitter->SetPieceRange(i,p1); return true; } const iPair& iParticleViewSubject::GetSplitRanges(int i) const { return mSplitter->GetPieceRange(i); } int iParticleViewSubject::DepthPeelingRequestBody() const { if(mRenderSortVar > -1) return -1; int i; for(i=0; i -1) return 1; } return 0; } ifrit-4.1.2/core/iparticleviewsubject.h0000674060175406010010000000750112641012531016542 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPARTICLEVIEWSUBJECT_H #define IPARTICLEVIEWSUBJECT_H #include "ipaintedviewsubject.h" #include "ipair.h" class iEventObserver; class iParticleConnector; class iParticleViewSubject; class iParticleSplitter; class iViewObject; class vtkAlgorithmOutput; class vtkPolyData; class iParticleViewInstance : public iPaintedViewInstance { friend class iParticleViewSubject; public: iDataConsumerTypeMacro(iParticleViewInstance,iPaintedViewInstance); iObjectSlotMacro1SV(Type,int); iObjectSlotMacro1SV(ScaleVar,int); iObjectSlotMacro1SV(ScaleFactor,float); iObjectSlotMacro1SV(FixedSize,float); iObjectSlotMacro1SV(LineWidth,int); iObjectSlotMacro1SV(AutoScaled,bool); iObjectSlotMacro2S(ConnectVar,int); iObjectSlotMacro2S(ConnectionBreakVar,int); protected: void SetInputConnection(vtkAlgorithmOutput *port); // // Inherited members // protected: iParticleViewInstance(iParticleViewSubject *owner); virtual ~iParticleViewInstance(); virtual void ConfigureBody(); virtual void ConfigureMainPipeline(iViewSubjectPipeline *p, int id); virtual iViewSubjectPipeline* CreatePipeline(int id); virtual void ShowBody(bool s); virtual bool CanBeShown() const; virtual void UpdateColorBars(){} virtual bool IsConnectedToPaintingData() const; private: // // VTK members // iParticleConnector *mConnector; iEventObserver *mCameraEventObserver; iParticleViewSubject *mRealOwner; }; class iParticleViewSubject : public iPaintedViewSubject { public: iViewSubjectTypeMacro1(iParticleView,iPaintedViewSubject); static iParticleViewSubject* New(iViewObject *parent, const iDataType &type, const iColor &color); // // Splitter functionality (must be first on the list) // iType::ps_int SplitVar; iObjectSlotMacro1SV(SplitVar,int); iObjectPropertyMacro3V(SplitRanges,Pair); iObjectPropertyMacro1S(SplitRangesTiled,Bool); // // Group properties // iType::vsp_int Type; iType::vsp_int ScaleVar; iType::vsp_float ScaleFactor; iType::vsp_float FixedSize; iType::vsp_int LineWidth; iType::vsp_bool AutoScaled; iType::vsp_int ConnectVar; iType::vsp_int ConnectionBreakVar; iType::ps_int RenderSortVar; iObjectSlotMacro1SV(RenderSortVar,int); virtual void BecomeClone(iViewSubject *other); protected: iParticleViewSubject(iViewObject *parent, const iDataType &type, const iColor &color = iColor::Black()); virtual ~iParticleViewSubject(); virtual void InitInstances(); virtual bool CreateInstance(); virtual bool RemoveInstance(int n); virtual int DepthPeelingRequestBody() const; iParticleSplitter *mSplitter; }; #endif // IPARTICLEVIEWOBJECT_H ifrit-4.1.2/core/ipicker.cpp0000775060175406010010000002560512641012562014307 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ipicker.h" #include "iactor.h" #include "idata.h" #include "idataformatter.h" #include "idatalimits.h" #include "idatareader.h" #include "idatasubject.h" #include "ierror.h" #include "iobjectfactory.h" #include "iprobefilter.h" #include "iviewmodule.h" #include "iviewmoduleeventobservers.h" #include "iviewsubject.h" #include "iviewsubjectobserver.h" #include #include #include #include #include #include #include #include #include #include #include #include #include // // templates // #include "iarray.tlh" #include "iproperty.tlh" // // Picker must be an object so that it can be created by the ObjectFactory // namespace iPicker_Private { const int NumPickMethods = 3; class CellPicker : public vtkCellPicker { public: static CellPicker* New() { return new CellPicker; } virtual vtkAssemblyPath* GetPath() { return 0; // we do not highlight the picked prop } }; class PointPicker : public vtkPointPicker { public: static PointPicker* New() { return new PointPicker; } virtual vtkAssemblyPath* GetPath() { return 0; // we do not highlight the picked prop } }; class ObjectPicker : public vtkPropPicker { public: static ObjectPicker* New() { return new ObjectPicker; } virtual vtkAssemblyPath* GetPath() { return 0; // we do not highlight the picked prop } }; class PickHandler : public vtkPicker { public: static PickHandler* New(iPicker *parent) { return new PickHandler(parent); } virtual vtkAssemblyPath* GetPath() { return 0; // we do not highlight the picked prop } virtual int Pick(double x, double y, double z, vtkRenderer *ren) { int pm = mParent->GetPickMethod(); if(pm>=0 && pmSetTolerance(this->GetTolerance()); this->InvokeEvent(vtkCommand::StartPickEvent,0); int ret = mDevices[pm]->Pick(x,y,z,ren); mDevices[pm]->GetPickPosition(this->PickPosition); this->SetPath(mDevices[pm]->vtkAbstractPropPicker::GetPath()); mParent->UpdateReport(); this->InvokeEvent(vtkCommand::EndPickEvent,0); return ret; } else { vtkErrorMacro("Invalid pick method."); return 0; } } virtual void Modified() { int i; for(i=0; iModified(); this->vtkAbstractPropPicker::Modified(); } private: PickHandler(iPicker *parent) { IASSERT(parent); mParent = parent; // // Pickers // mDevices[0] = CellPicker::New(); IERROR_CHECK_MEMORY(mDevices[0]); mDevices[1] = PointPicker::New(); IERROR_CHECK_MEMORY(mDevices[1]); mDevices[2] = ObjectPicker::New(); IERROR_CHECK_MEMORY(mDevices[2]); // // Observer // mObserver = iPickEventObserver::New(mParent->GetViewModule()); IERROR_CHECK_MEMORY(mObserver); this->AddObserver(vtkCommand::StartPickEvent,mObserver); this->AddObserver(vtkCommand::EndPickEvent,mObserver); int i; for(i=0; iAddObserver(vtkCommand::AbortCheckEvent,mParent->GetViewModule()->GetRenderEventObserver()); } } ~PickHandler() { int i; for(i=0; iDelete(); mObserver->Delete(); } iPicker *mParent; iPickEventObserver *mObserver; vtkAbstractPropPicker *mDevices[NumPickMethods]; }; }; using namespace iParameter; using namespace iPicker_Private; iPicker* iPicker::New(iViewModule *vm) { static iString LongName("Picker"); static iString ShortName("pi"); IASSERT(vm); iPicker *tmp = new iPicker(vm,LongName,ShortName); IERROR_CHECK_MEMORY(tmp); iObjectFactory::InstallExtensions(tmp); return tmp; } iPicker::iPicker(iViewModule *vm, const iString &fname, const iString &sname) : iExtendableObject(vm,fname,sname), iViewModuleComponent(vm), mDataFormatter(vm), mPosition(vm), Position(iObject::Self(),static_cast::GetterType>(&iPicker::GetBoxPosition),"Position","x"), iObjectConstructPropertyMacroS(Float,iPicker,Accuracy,a), iObjectConstructPropertyMacroS(Int,iPicker,PickMethod,m), iObjectConstructPropertyMacroS(Float,iPicker,PointSize,ps) { mRenderMode = RenderMode::Self; mSubjectName = ""; mDataTypePointer = 0; mPickMethod = PickMethod::Point; // // Handler // mHandler = PickHandler::New(this); IERROR_CHECK_MEMORY(mHandler); mAccuracy = 0.02; this->SetAccuracy(mAccuracy); // // Graphical representation // mPointActor = iActor::New(); IERROR_CHECK_MEMORY(mPointActor); mPointSource = vtkSphereSource::New(); IERROR_CHECK_MEMORY(mPointSource); mPointSize = 0.1; this->SetPointSize(mPointSize); mPointSource->SetRadius(0.5); mPointActor->GetProperty()->SetColor(0.9,0.9,0.9); mPointActor->VisibilityOff(); mPointActor->PickableOff(); this->GetViewModule()->AddObject(mPointActor); // // PolyData inout for a probe filter // mProbeInput = vtkPolyData::New(); IERROR_CHECK_MEMORY(mProbeInput); vtkCellArray *v = vtkCellArray::New(); IERROR_CHECK_MEMORY(v); v->InsertNextCell(1); v->InsertCellPoint(0); mProbeInput->SetVerts(v); v->Delete(); vtkPoints *p = vtkPoints::New(VTK_DOUBLE); IERROR_CHECK_MEMORY(p); p->SetNumberOfPoints(1); p->SetPoint(0,0.0,0.0,0.0); mProbeInput->SetPoints(p); p->Delete(); } iPicker::~iPicker() { mHandler->Delete(); this->GetViewModule()->RemoveObject(mPointActor); mPointActor->Delete(); mPointSource->Delete(); mProbeInput->Delete(); } void iPicker::Modified() { mHandler->Modified(); } void iPicker::UpdateReport() { mSubjectName = "Unknown"; mPosition = mHandler->GetPickPosition(); this->SetPointSize(mPointSize); mPointActor->SetPosition(mPosition); mDataFormatter->ClearReport(); this->UpdateReportBody(); // this can replace mPointObject via its extensions mPointActor->SetInputConnection(mPointSource->GetOutputPort()); mPointActor->SetScaled(true); mPointActor->SetPosition(mPosition); // // Check if extensions want to modify the point actor // if(mDataTypePointer != 0) { int i; for(i=0; i(INFO,mExtensions[i])->IsUsingData(*mDataTypePointer)) { iRequiredCast(INFO,mExtensions[i])->ModifyActor(*mDataTypePointer,mPointActor); // the last installed extension prevails } } this->ShowPickedPoint(mDataTypePointer != 0); } void iPicker::UpdateReportBody() { iString s1, s2; // // Get the object info // vtkProp *obj = mHandler->GetViewProp(); if(obj == 0) { mSubjectName = ""; mPointActor->VisibilityOff(); return; } iViewSubjectObserver *obs = iRequiredCast(INFO,obj->GetCommand(1)); if(obs != 0) { mSubjectName = obs->GetSubjectName(); mDataTypePointer = &obs->GetSubjectDataType(); } else { mSubjectName = "Unknown"; mDataTypePointer = 0; } // // Get the data info // if(mDataTypePointer == 0) return; iDataSubject *subject = this->GetViewModule()->GetReader()->GetSubject(*mDataTypePointer); iDataLimits *lim = subject->GetLimits(); // // Use the ProbeFilter to find attribute values // mProbeInput->GetPoints()->SetPoint(0,mPosition); iProbeFilter *probe = subject->CreateProbeFilter(obs->GetSubject()); probe->SetInputData(mProbeInput); probe->SetSourceData(subject->GetData()); probe->Update(); vtkPolyData *out = probe->GetPolyDataOutput(); if(out==0 || out->GetPointData()==0) { IBUG_WARN("Unable to probe data for the picked object"); return; } // // Ask extensions to provide extra information // int i; for(i=0; i(INFO,mExtensions[i])->IsUsingData(*mDataTypePointer)) { iRequiredCast(INFO,mExtensions[i])->AddInfo(*mDataTypePointer); } vtkDataArray *d = 0; int nvar = 0; if(subject->IsThereScalarData()) { d = out->GetPointData()->GetScalars(); nvar = lim->GetNumVars(); if(d==0 || nvar<1 || d->GetNumberOfComponents()!=nvar || !d->IsA("vtkFloatArray")) { IBUG_WARN("Unable to probe data for the picked object"); return; } float *v = (float *)d->GetVoidPointer(0); mDataFormatter->FormatScalarData(lim,nvar,v); } if(subject->IsThereVectorData()) { d = out->GetPointData()->GetVectors(); nvar = 3; if(d==0 || nvar<1 || d->GetNumberOfComponents()!=nvar || !d->IsA("vtkFloatArray")) { IBUG_WARN("Unable to probe data for the picked object"); return; } float *v = (float *)d->GetVoidPointer(0); mDataFormatter->FormatVectorData(lim,-1,v); } if(subject->IsThereTensorData()) { d = out->GetPointData()->GetTensors(); nvar = 9; if(d==0 || nvar<1 || d->GetNumberOfComponents()!=nvar || !d->IsA("vtkFloatArray")) { IBUG_WARN("Unable to probe data for the picked object"); return; } float *v = (float *)d->GetVoidPointer(0); mDataFormatter->FormatTensorData(lim,-1,v); } probe->Delete(); } bool iPicker::SetPointSize(float s) { if(s > 0.0) { mPointSize = s; mPointActor->SetScaled(true); mPointActor->SetBasicScale(mPointSize); this->Modified(); return true; } else return false; } void iPicker::ShowPickedPoint(bool s) { if(!mSubjectName.IsEmpty() && s) { mPointActor->VisibilityOn(); } if(!s) { mPointActor->VisibilityOff(); } this->RequestRender(); } bool iPicker::SetPickMethod(int s) { if(s>=0 && s 0.0f) { mHandler->SetTolerance(s); return true; } else return false; } // // Extension class // iObjectExtensionAbstractConstructorBeginMacro(iPicker) { } ifrit-4.1.2/core/ipicker.h0000674060175406010010000000606312641012532013744 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPICKER_H #define IPICKER_H #include "iextendableobject.h" #include "iviewmodulecomponent.h" #include "iposition.h" class iActor; class iDataFormatter; class iDataType; class vtkPicker; class vtkPolyData; class vtkSphereSource; namespace iParameter { namespace PickMethod { // // Picker parameters // const int Cell = 0; const int Point = 1; const int Object = 2; }; }; class iPicker : public iExtendableObject, public iViewModuleComponent { IPOINTER_AS_USER(DataFormatter); public: vtkTypeMacro(iPicker,iExtendableObject); static iPicker* New(iViewModule *vm = 0); iObjectPropertyMacro1S(Accuracy,Float); iObjectPropertyMacro1S(PickMethod,Int); iObjectPropertyMacro1S(PointSize,Float); iPropertyQuery Position; inline const iPosition& GetPosition() const { return mPosition; } inline const iVector3D& GetBoxPosition() const { return mPosition.BoxValue(); } inline const iString& GetObjectName() const { return mSubjectName; } void ShowPickedPoint(bool s); inline vtkPicker* GetHandler() const { return mHandler; } void UpdateReport(); virtual void Modified(); protected: iPicker(iViewModule *vm, const iString &fname, const iString &sname); virtual ~iPicker(); virtual void UpdateReportBody(); private: iPosition mPosition; iString mSubjectName; const iDataType *mDataTypePointer; vtkPolyData *mProbeInput; // // Actual workers // vtkPicker *mHandler; // // Graphical representation // iActor *mPointActor; vtkSphereSource *mPointSource; }; class iPickerExtension : public iObjectExtension { iObjectExtensionDeclareAbstractMacro(iPicker); public: virtual bool IsUsingData(const iDataType &type) const = 0; virtual void ModifyActor(const iDataType &type, iActor *actor) = 0; virtual void AddInfo(const iDataType &type) = 0; }; #endif // IPICKER_H ifrit-4.1.2/core/ipiecewisefunction.cpp0000674060175406010010000001157512641012562016554 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ipiecewisefunction.h" #include "ierror.h" #include "imath.h" #include // // Templates // #include "iarray.tlh" class iPiecewiseFunctionHelper : public vtkPiecewiseFunction { public: iPiecewiseFunctionHelper(iPiecewiseFunction *p) { mParent = p; } virtual void Update() { int i; this->RemoveAllPoints(); for(i=0; imArray.Size(); i++) this->AddPoint(255*mParent->mArray[i].X,mParent->mArray[i].Y); } void ParentChanged() { this->Update(); mParent->Modified(); } private: iPiecewiseFunction *mParent; }; // // iPiecewiseFunction class // iPiecewiseFunction* iPiecewiseFunction::New(float ymin, float ymax) { iPiecewiseFunction *tmp = new iPiecewiseFunction(ymin,ymax,10); IERROR_CHECK_MEMORY(tmp); return tmp; } iPiecewiseFunction::iPiecewiseFunction(float ymin, float ymax, int inc) : mArray(inc) { mYmin = ymin; mYmax = ymax; mArray.Add(iPair(0.0,ymin)); mArray.Add(iPair(1.0,ymax)); mHelper = new iPiecewiseFunctionHelper(this); IERROR_CHECK_MEMORY(mHelper); mHelper->ParentChanged(); } iPiecewiseFunction::~iPiecewiseFunction() { mHelper->Delete(); } vtkPiecewiseFunction* iPiecewiseFunction::GetVTKFunction() const { return mHelper; } void iPiecewiseFunction::Copy(const iPiecewiseFunction *f) { if(this==f || f==0) return; mArray.Clear(); int i; for(i=0; iN(); i++) { mArray.Add(f->mArray[i]); } mYmin = f->mYmin; mYmax = f->mYmax; mHelper->ParentChanged(); } void iPiecewiseFunction::SetMinMax(float ymin, float ymax) { mYmin = ymin; mYmax = ymax; for(int i=0; i mYmax) ? mYmax : mArray[i].Y; mArray[i].Y = (mArray[i].Y < mYmin) ? mYmin : mArray[i].Y; } mHelper->ParentChanged(); } void iPiecewiseFunction::AddPoint(int n) { n++; if(n < 1) n = 1; if(n > mArray.MaxIndex()) n = mArray.MaxIndex(); mArray.Add(iPair(0.5*(mArray[n-1].X+mArray[n].X),0.5*(mArray[n-1].Y+mArray[n].Y))); mHelper->ParentChanged(); } void iPiecewiseFunction::AddPoint(const iPair &p) { float x = p.X; if(x < 0.0) x = 0.0; if(x > 1.0) x = 1.0; float y = p.Y; if(y < mYmin) y = mYmin; if(y > mYmax) y = mYmax; mArray.Add(iPair(x,y)); mHelper->ParentChanged(); } void iPiecewiseFunction::RemovePoint(int n) { if(n>0 && n2) { mArray.iArray::Remove(n); mHelper->ParentChanged(); } } void iPiecewiseFunction::MovePoint(int n, const iPair &p) { if(n>0 && n mArray[n+1].X) x = mArray[n+1].X; float y = p.Y; if(y < mYmin) y = mYmin; if(y > mYmax) y = mYmax; mArray[n] = iPair(x,y); } else if(n==0 || n==mArray.MaxIndex()) { float y = p.Y; if(y < mYmin) y = mYmin; if(y > mYmax) y = mYmax; mArray[n].Y = y; } mHelper->ParentChanged(); } int iPiecewiseFunction::FindPoint(const iPair &p, float &dmin) const { int i, imin; float d, dx, dy; dmin = iMath::_LargeFloat; imin = -1; for(i=0; i mArray[mArray.MaxIndex()].X) return mArray[mArray.MaxIndex()].Y; for(i=1; iParentChanged(); } ifrit-4.1.2/core/ipiecewisefunction.h0000674060175406010010000000535312641012532016213 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPIECEWISEFUNCTION_H #define IPIECEWISEFUNCTION_H #include "vtkObject.h" #include "iarray.h" #include "ipair.h" class iPiecewiseFunctionHelper; class iPiecewiseFunctionUser; class vtkObject; class vtkPiecewiseFunction; class iPiecewiseFunction : public vtkObject { friend class iPropertyPiecewiseFunction; friend class iPiecewiseFunctionHelper; public: vtkTypeMacro(iPiecewiseFunction,vtkObject); static iPiecewiseFunction* New(float ymin = 0.0f, float ymax = 1.0f); inline int N() const { return mArray.Size(); } inline const iPair& P(int i) const { return mArray[i]; } inline float X(int i) const { return mArray[i].X; } inline float Y(int i) const { return mArray[i].Y; } inline float Min() const { return mYmin; } inline float Max() const { return mYmax; } void SetMinMax(float ymin, float ymax); void AddPoint(int n); void AddPoint(const iPair &p); void RemovePoint(int n); void MovePoint(int n, const iPair &p); int FindPoint(const iPair &p, float &d) const; float GetValue(float x) const; inline void AddPoint(float x, float y){ this->AddPoint(iPair(x,y)); } inline void MovePoint(int n, float x, float y){ this->MovePoint(n,iPair(x,y)); } void Copy(const iPiecewiseFunction *f); void Reset(); vtkPiecewiseFunction* GetVTKFunction() const; protected: iPiecewiseFunction(float ymin, float ymax, int inc); virtual ~iPiecewiseFunction(); iOrderedArray mArray; float mYmin, mYmax; iPiecewiseFunctionHelper *mHelper; }; #endif // IPIECEWISEFUNCTION_H ifrit-4.1.2/core/ipointer.cpp0000674060175406010010000000260712641012562014505 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ipointer.h" #include "ierror.h" namespace iPointer { // // helper function // void Validate(void *ptr) { IASSERT(ptr); } }; ifrit-4.1.2/core/ipointer.h0000674060175406010010000000735512641012532014154 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPOINTER_H #define IPOINTER_H // // various simple but useful pointer types // namespace iPointer { // // helper function // void Validate(void *ptr); // // Small common functionality // template class TrivialBase { public: // // Cast to the holder's type // inline operator T*() const { return this->mPtr; } // // Dereference the pointer and return a reference to the contained object. // inline T& operator*() const { return *this->mPtr; } // // Provides normal pointer target member access using operator ->. // inline T* operator->() const { return this->mPtr; } protected: TrivialBase(T* ptr) { this->mPtr = ptr; } T* mPtr; private: // // Not implemented // TrivialBase(); // cannot have an automatic default constructor - otherwise the compiler will not require explicit instantination TrivialBase& operator=(TrivialBase&); }; // // Simple non-assignable, non-transferable auto-ptr // template class AutoDeleted : public TrivialBase { public: template AutoDeleted(P parent) : TrivialBase(T::New(parent)) { Validate(this->mPtr); } AutoDeleted() : TrivialBase(T::New()) { Validate(this->mPtr); } ~AutoDeleted() { this->mPtr->Delete(); } private: // // Not implemented // //AutoDeleted(); // cannot have an automatic default constructor - otherwise the compiler will not require explicit instantination AutoDeleted& operator=(AutoDeleted&); }; // // A pointer that cannot have a NULL value // template class AlwaysValid : public TrivialBase { public: AlwaysValid(T *ptr) : TrivialBase(ptr) { Validate(this->mPtr); } private: // // Not implemented // AlwaysValid(); AlwaysValid& operator=(AlwaysValid&); }; // // A pointer ordered by GetId() call of the argument class // template class Ordered : public TrivialBase { public: Ordered(T *ptr) : TrivialBase(ptr) { } // // Allow assignment operator // void operator=(const Ordered &p) { this->mPtr = p.mPtr; } bool operator==(const Ordered &other) const { return (this->mPtr==0 ? other.mPtr==0 : (other.mPtr!=0 && this->mPtr->GetId()==other.mPtr->GetId())); } bool operator<(const Ordered &other) const { return (this->mPtr==0 ? other.mPtr!=0 : (other.mPtr!=0 && this->mPtr->GetId()GetId())); } private: // // Not implemented // Ordered(); }; }; #endif // IPOINTER_H ifrit-4.1.2/core/ipointermacro.h0000674060175406010010000000326412641012532015171 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IPOINTERMACRO_H #define IPOINTERMACRO_H #include "ipointer.h" #define IPOINTER_AS_PART(_name_) \ public: \ inline i##_name_* Get##_name_() const { return m##_name_; } \ private: \ iPointer::AlwaysValid const m##_name_ #define IPOINTER_AS_USER(_name_) \ public: \ inline i##_name_* Get##_name_() const { return m##_name_; } \ private: \ iPointer::AutoDeleted const m##_name_ #endif // IPOINTERMACRO_H ifrit-4.1.2/core/ipointglyph.cpp0000674060175406010010000003107412641012562015222 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ipointglyph.h" #include "ierror.h" #include "ispheresource.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace iPointGlyph_Private { struct PointType { int Type; // for consistency checking bool IsOriented; const char *Name; }; const PointType type[] = { { 0, false, "Point" }, { 1, false, "Sphere" }, { 2, true, "Tetrahydron" }, { 3, false, "Cube" }, { 4, false, "Octahedron" }, { 5, false, "Icosahedron" }, { 6, false, "Dodecahedron" }, { 7, true, "Cone" }, { 8, true, "Cylinder" }, { 9, true, "Arrow" }, { 10, false, "Cluster" }, { 11, true, "Galaxy" } }; }; using namespace iParameter; using namespace iPointGlyph_Private; iPointGlyph* iPointGlyph::New() { return new iPointGlyph(); } iPointGlyph::iPointGlyph() { int i; mType = PointGlyphType::Point; for(i=0; iSetNumberOfInputPorts(0); this->CreateData(3); } iPointGlyph::~iPointGlyph() { int i; for(i=0; iDelete(); } } void iPointGlyph::CreateData(int res) { int i; vtkIdType l, n; double x[3], r; vtkPoints *p, *op; vtkFloatArray *fa; vtkDataArray *da; bool done[PointGlyphType::SIZE]; for(i=0; i 100) res = 100; vtkPolyDataNormals *pn = vtkPolyDataNormals::New(); IERROR_CHECK_MEMORY(pn); pn->AutoOrientNormalsOn(); pn->ConsistencyOn(); // // Sphere // /* vtkSphereSource *ss = vtkSphereSource::New(); IERROR_CHECK_MEMORY(ss); vtkDecimatePro *sf = vtkDecimatePro::New(); IERROR_CHECK_MEMORY(sf); ss->SetThetaResolution(12*res); ss->SetPhiResolution(6*res); ss->SetRadius(0.5); ss->LatLongTessellationOff(); ss->Update(); ss->GetOutput()->GetPointData()->SetNormals(0); sf->SetTargetReduction(0.5); sf->PreserveTopologyOn(); sf->SetInputConnection(ss->GetOutputPort()); pn->ComputePointNormalsOn(); pn->SetInputConnection(sf->GetOutputPort()); pn->SetOutput(mData[PointGlyphType::Sphere]); pn->Update(); sf->Delete(); ss->Delete(); done[PointGlyphType::Sphere] = true; */ iSphereSource *ss = iSphereSource::New(); IERROR_CHECK_MEMORY(ss); ss->SetResolution(3*res); ss->SetRadius(0.5); ss->SetOutput(mData[PointGlyphType::Sphere]); ss->Update(); ss->Delete(); done[PointGlyphType::Sphere] = true; // // Platonic solids // vtkPlatonicSolidSource *ps = vtkPlatonicSolidSource::New(); IERROR_CHECK_MEMORY(ps); pn->ComputePointNormalsOff(); pn->SetInputConnection(ps->GetOutputPort()); pn->SetOutput(mData[PointGlyphType::Tetrahydron]); pn->ComputeCellNormalsOn(); pn->FlipNormalsOn(); ps->SetSolidTypeToTetrahedron(); pn->Update(); mData[PointGlyphType::Tetrahydron]->GetCellData()->Initialize(); // clears the cell colors that are set by vtkPlatonicSolidSource this->ScaleData(mData[PointGlyphType::Tetrahydron],0.5); done[PointGlyphType::Tetrahydron] = true; pn->SetOutput(mData[PointGlyphType::Cube]); pn->ComputeCellNormalsOff(); pn->FlipNormalsOff(); ps->SetSolidTypeToCube(); pn->Update(); mData[PointGlyphType::Cube]->GetCellData()->Initialize(); // clears the cell colors that are set by vtkPlatonicSolidSource this->ScaleData(mData[PointGlyphType::Cube],0.5); done[PointGlyphType::Cube] = true; pn->SetOutput(mData[PointGlyphType::Octahedron]); pn->ComputeCellNormalsOn(); pn->FlipNormalsOff(); ps->SetSolidTypeToOctahedron(); pn->Update(); mData[PointGlyphType::Octahedron]->GetCellData()->Initialize(); // clears the cell colors that are set by vtkPlatonicSolidSource this->ScaleData(mData[PointGlyphType::Octahedron],0.5); done[PointGlyphType::Octahedron] = true; pn->SetOutput(mData[PointGlyphType::Icosahedron]); pn->ComputeCellNormalsOn(); pn->FlipNormalsOff(); ps->SetSolidTypeToIcosahedron(); pn->Update(); mData[PointGlyphType::Icosahedron]->GetCellData()->Initialize(); // clears the cell colors that are set by vtkPlatonicSolidSource this->ScaleData(mData[PointGlyphType::Icosahedron],0.5); done[PointGlyphType::Icosahedron] = true; pn->SetOutput(mData[PointGlyphType::Dodecahedron]); pn->ComputeCellNormalsOn(); pn->FlipNormalsOff(); ps->SetSolidTypeToDodecahedron(); pn->Update(); mData[PointGlyphType::Dodecahedron]->GetCellData()->Initialize(); // clears the cell colors that are set by vtkPlatonicSolidSource this->ScaleData(mData[PointGlyphType::Dodecahedron],0.5); done[PointGlyphType::Dodecahedron] = true; pn->Delete(); ps->Delete(); // // Cone // vtkConeSource *cs = vtkConeSource::New(); IERROR_CHECK_MEMORY(cs); cs->SetResolution(6*res); cs->SetOutput(mData[PointGlyphType::Cone]); cs->Update(); cs->Delete(); this->ScaleData(mData[PointGlyphType::Cone],0.8); this->SwapAxes(mData[PointGlyphType::Cone],0,2); this->ShiftData(mData[PointGlyphType::Cone],2,0.1); done[PointGlyphType::Cone] = true; // // Cylinder // vtkCylinderSource *ts = vtkCylinderSource::New(); IERROR_CHECK_MEMORY(ts); ts->SetResolution(6*res); ts->SetOutput(mData[PointGlyphType::Cylinder]); ts->Update(); ts->Delete(); this->ScaleData(mData[PointGlyphType::Cylinder],0.7); this->SwapAxes(mData[PointGlyphType::Cylinder],1,2); done[PointGlyphType::Cylinder] = true; // // Arrow // vtkArrowSource *as = vtkArrowSource::New(); IERROR_CHECK_MEMORY(as); as->SetTipResolution(6*res); as->SetShaftResolution(6*res); as->SetTipRadius(0.5); as->SetShaftRadius(0.2); as->SetOutput(mData[PointGlyphType::Arrow]); as->Update(); as->Delete(); this->ScaleData(mData[PointGlyphType::Arrow],0.93); this->SwapAxes(mData[PointGlyphType::Arrow],0,2); this->ShiftData(mData[PointGlyphType::Arrow],2,-0.45); done[PointGlyphType::Arrow] = true; // // Point // vtkPointSource *cc; cc = vtkPointSource::New(); IERROR_CHECK_MEMORY(cc); cc->SetNumberOfPoints(1); cc->SetCenter(0.0,0.0,0.0); cc->SetRadius(1.0); cc->SetOutput(mData[PointGlyphType::Point]); cc->Update(); cc->Delete(); p = mData[PointGlyphType::Point]->GetPoints(); p->SetPoint(0,0.0,0.0,0.0); done[PointGlyphType::Point] = true; // // Cluster // cc = vtkPointSource::New(); IERROR_CHECK_MEMORY(cc); cc->SetNumberOfPoints(30*res); cc->SetCenter(0.0,0.0,0.0); cc->SetRadius(1.0); cc->SetOutput(mData[PointGlyphType::Cluster]); cc->Update(); cc->Delete(); // // Rearrange points radially to have a centrally concentrated cluster // p = mData[PointGlyphType::Cluster]->GetPoints(); n = p->GetNumberOfPoints(); for(l=0; lGetPoint(l,x); r = x[0]*x[0] + x[1]*x[1] + x[2]*x[2]; r = 0.5*pow(2*r/(1.0+r),2.0); x[0] *= r; x[1] *= r; x[2] *= r; p->SetPoint(l,x); } done[PointGlyphType::Cluster] = true; // // Galaxy // cc = vtkPointSource::New(); IERROR_CHECK_MEMORY(cc); cc->SetNumberOfPoints(30*res); cc->SetCenter(0.0,0.0,0.0); cc->SetRadius(1.0); cc->SetOutput(mData[PointGlyphType::Galaxy]); cc->Update(); cc->Delete(); // // Rearrange points to have a spiral galaxy in z=0 plane. // double r1, phi; p = mData[PointGlyphType::Galaxy]->GetPoints(); n = p->GetNumberOfPoints(); for(l=0; lGetPoint(l,x); r = x[0]*x[0] + x[1]*x[1] + x[2]*x[2]; r = 0.5*(0.2*(1-r)+2*r)/(1.0+r); x[0] *= r; x[1] *= r; x[2] /= (5.0+20.0*r); if(l > 0.7*n) { r1 = sqrt(x[0]*x[0]+x[1]*x[1]); phi = atan2(x[1],x[0]); if(phi > vtkMath::Pi()) phi -= 2*vtkMath::Pi(); if(phi > 0.0) phi = 0.5*vtkMath::Pi(); else phi = -0.5*vtkMath::Pi(); x[0] = r1*cos(phi-5.0*r1); x[1] = r1*sin(phi-5.0*r1); } p->SetPoint(l,x); } done[PointGlyphType::Galaxy] = true; // // Test that all are done // for(i=0; iGetPoints(); if(op->GetDataType() != VTK_FLOAT) { n = op->GetNumberOfPoints(); p = vtkPoints::New(VTK_FLOAT); if(p == 0) break; p->SetNumberOfPoints(n); for(l=0; lSetPoint(l,op->GetPoint(l)); } mData[i]->SetPoints(p); p->Delete(); } } // // Make all normals float // for(i=0; iGetPointData()->GetNormals(); if(da!=0 && da->GetDataType()!=VTK_FLOAT) { n = da->GetNumberOfTuples(); fa = vtkFloatArray::New(); if(fa == 0) break; fa->SetNumberOfComponents(3); fa->SetNumberOfTuples(n); for(l=0; lSetTuple(l,da->GetTuple(l)); } mData[i]->GetPointData()->SetNormals(fa); fa->Delete(); } da = mData[i]->GetCellData()->GetNormals(); if(da!=0 && da->GetDataType()!=VTK_FLOAT) { n = da->GetNumberOfTuples(); fa = vtkFloatArray::New(); if(fa == 0) break; fa->SetNumberOfComponents(3); fa->SetNumberOfTuples(n); for(l=0; lSetTuple(l,da->GetTuple(l)); } mData[i]->GetCellData()->SetNormals(fa); fa->Delete(); } } } void iPointGlyph::ScaleData(vtkPolyData *d, double fac) { double x[3]; vtkPoints *p = d->GetPoints(); vtkIdType l, n = p->GetNumberOfPoints(); // // Scale data // for(l=0; lGetPoint(l,x); x[0] *= fac; x[1] *= fac; x[2] *= fac; p->SetPoint(l,x); } } void iPointGlyph::SwapAxes(vtkPolyData *d, int a1, int a2) { double r, x[3]; vtkPoints *p = d->GetPoints(); vtkIdType l, n = p->GetNumberOfPoints(); // // Swap points // for(l=0; lGetPoint(l,x); r = x[a1]; x[a1] = -x[a2]; x[a2] = r; p->SetPoint(l,x); } // // Don't forget to rotate normals too (if they exist) // vtkDataArray *da = d->GetPointData()->GetNormals(); if(da != 0) { n = da->GetNumberOfTuples(); for(l=0; lGetTuple(l,x); r = x[0]; x[0] = -x[2]; x[2] = r; da->SetTuple(l,x); } } da = d->GetCellData()->GetNormals(); if(da != 0) { n = da->GetNumberOfTuples(); for(l=0; lGetTuple(l,x); r = x[0]; x[0] = -x[2]; x[2] = r; da->SetTuple(l,x); } } } void iPointGlyph::ShiftData(vtkPolyData *d, int a, double dx) { double x[3]; vtkPoints *p = d->GetPoints(); vtkIdType l, n = p->GetNumberOfPoints(); // // Shift the data // for(l=0; lGetPoint(l,x); x[a] += dx; p->SetPoint(l,x); } } bool iPointGlyph::GetOriented() const { return iPointGlyph::GetOriented(mType); } const char* iPointGlyph::GetName() const { return iPointGlyph::GetName(mType); } bool iPointGlyph::GetOriented(int t) { if(t>=0 && t=0 && t=0 && tModified(); } } vtkPolyData* iPointGlyph::GetData() { return this->vtkPolyDataAlgorithm::GetOutput(); } int iPointGlyph::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) { this->GetData()->ShallowCopy(mData[mType]); return 1; } ifrit-4.1.2/core/ipointglyph.h0000674060175406010010000000526012641012532014662 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A representation for a single particle // #ifndef IPOINTGLYPH_H #define IPOINTGLYPH_H #include class iDataConsumer; namespace iParameter { namespace PointGlyphType { const int Point = 0; const int Sphere = 1; const int Tetrahydron = 2; const int Cube = 3; const int Octahedron = 4; const int Icosahedron = 5; const int Dodecahedron = 6; const int Cone = 7; const int Cylinder = 8; const int Arrow = 9; const int Cluster = 10; const int Galaxy = 11; const int SIZE = 12; }; }; class iPointGlyph: public vtkPolyDataAlgorithm { public: vtkTypeMacro(iPointGlyph,vtkPolyDataAlgorithm); static iPointGlyph* New(); inline int GetType() const { return mType; } void SetType(int m); bool GetOriented() const; const char* GetName() const; static bool GetOriented(int t); static const char* GetName(int t); vtkPolyData* GetData(); protected: iPointGlyph(); virtual ~iPointGlyph(); virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector); private: void CreateData(int res); void ScaleData(vtkPolyData *d, double fac); void SwapAxes(vtkPolyData *d, int a1, int a2); void ShiftData(vtkPolyData *d, int a, double dx); int mType; vtkPolyData *mData[iParameter::PointGlyphType::SIZE]; // // Block for better control // void GetOutput(); void OutputData(); }; #endif // IPOINTGLYPH_H ifrit-4.1.2/core/iposition.cpp0000674060175406010010000001026612641012562014671 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iposition.h" #include "icamera.h" #include "ierror.h" #include "imarker.h" #include "ipicker.h" #include "irendertool.h" #include "iviewmodule.h" using namespace iParameter; // // iCoordinate functions // iCoordinate::iCoordinate(iViewModule *vm) : iViewModuleComponent(vm), mOffset(1) { IASSERT(vm); mOGLValue = 0.0; } iCoordinate::iCoordinate(iViewModule *vm, int offset) : iViewModuleComponent(vm), mOffset(offset) { IASSERT(vm); mOGLValue = 0.0; } void iCoordinate::UpdateBoxValue() const { if(this->GetViewModule()->InOpenGLCoordinates()) { mBoxValue = mOGLValue; } else { mBoxValue = 0.5*(mOffset+mOGLValue)*this->GetViewModule()->GetBoxSize(); } } void iCoordinate::UpdateOGLValue() { if(this->GetViewModule()->InOpenGLCoordinates()) { mOGLValue = mBoxValue; } else { mOGLValue = -mOffset + 2.0*mBoxValue/this->GetViewModule()->GetBoxSize(); } } void iCoordinate::PeriodicWrap() { mOGLValue -= 2.0*floor(0.5*(1.0+mOGLValue)); } void iCoordinate::CutToBounds() { if(mOGLValue < -1.0) mOGLValue = -1.0; if(mOGLValue > 1.0) mOGLValue = 1.0; } // // iDistance functions // iDistance::iDistance(iViewModule *vm) : iCoordinate(vm,0) { mOGLValue = 1.0; } void iDistance::PeriodicWrap() { } // // iPosition functions // iPosition::iPosition(iViewModule *vm) : iViewModuleComponent(vm) { IASSERT(vm); } bool iPosition::SetToSpecialLocation(int v) { switch(v) { case SpecialLocation::PickedPoint: { if(!this->GetViewModule()->GetPicker()->GetObjectName().IsEmpty()) { *this = this->GetViewModule()->GetPicker()->GetPosition(); return true; } break; } case SpecialLocation::FocalPoint: { *this = this->GetViewModule()->GetRenderTool()->GetCamera()->GetFocalPoint(); return true; } case SpecialLocation::BoxCenter: { *this = 0; return true; } default: { if(v>0 && v<=this->GetViewModule()->GetNumberOfMarkers()) { *this = this->GetViewModule()->GetMarker(v-1)->GetPosition(); return true; } } } return false; } void iPosition::UpdateBoxValue() const { if(this->GetViewModule()->InOpenGLCoordinates()) { mBoxValue = mOGLValue; } else { int i; float boxSize = this->GetViewModule()->GetBoxSize(); for(i=0; i<3; i++) mBoxValue[i] = 0.5*(1.0+mOGLValue[i])*boxSize; } } void iPosition::UpdateOGLValue() { if(this->GetViewModule()->InOpenGLCoordinates()) { mOGLValue = mBoxValue; } else { int i; float boxSize = this->GetViewModule()->GetBoxSize(); for(i=0; i<3; i++) mOGLValue[i] = -1.0 + 2.0*mBoxValue[i]/boxSize; } } void iPosition::PeriodicWrap() { int i; // // If x is in between -1 and 1, do nothing - this way x=1 remains 1, and not wrapped into x=-1 // for(i=0; i<3; i++) if(mOGLValue[i]<-1.0 || mOGLValue[i]>1.0) mOGLValue[i] -= 2.0*floor(0.5*(1.0+mOGLValue[i])); } void iPosition::CutToBounds() { int i; for(i=0; i<3; i++) { if(mOGLValue[i] < -1.0) mOGLValue[i] = -1.0; if(mOGLValue[i] > 1.0) mOGLValue[i] = 1.0; } } ifrit-4.1.2/core/iposition.h0000674060175406010010000001162312641012532014331 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A double-valued position // #ifndef IPOSITION_H #define IPOSITION_H #include "iviewmodulecomponent.h" #include "ivector3D.h" namespace iParameter { namespace SpecialLocation { const int FIRST__ = -2; const int PickedPoint = -2; const int FocalPoint = -1; const int BoxCenter = 0; }; }; class iCoordinate : public iViewModuleComponent { public: iCoordinate(iViewModule *vm); inline double BoxValue() const { this->UpdateBoxValue(); return mBoxValue; } inline operator double() const { return mOGLValue; } inline double OpenGLValue() const { return mOGLValue; } void SetBoxValue(double x); void operator=(const iCoordinate&); void operator=(double); inline bool operator<(const iCoordinate &p) const { return mOGLValue < p.mOGLValue; } inline bool operator>(const iCoordinate &p) const { return mOGLValue > p.mOGLValue; } inline bool operator<(double x) const { return mOGLValue < x; } inline bool operator>(double x) const { return mOGLValue > x; } void PeriodicWrap(); void CutToBounds(); protected: iCoordinate(iViewModule *vm, int offset); void UpdateOGLValue(); void UpdateBoxValue() const; mutable double mBoxValue; double mOGLValue; const int mOffset; private: iCoordinate(const iCoordinate&); // not implemented }; class iDistance : public iCoordinate { public: iDistance(iViewModule *vm); void SetBoxValue(double x); void operator=(const iDistance&); void operator=(double); private: void PeriodicWrap(); iDistance(const iDistance&); // not implemented }; class iPosition : public iViewModuleComponent { public: iPosition(iViewModule *vm); inline const iVector3D& BoxValue() const { this->UpdateBoxValue(); return mBoxValue; } inline double BoxValue(int i) const { this->UpdateBoxValue(); return mBoxValue[i]; } inline operator double*(){ return mOGLValue; } inline operator const double*() const { return mOGLValue; } inline double operator[](int i) const { return mOGLValue[i]; } inline double& operator[](int i){ return mOGLValue[i]; } inline const iVector3D& OpenGLValue() const { return mOGLValue; } inline double OpenGLValue(int i) const { return mOGLValue[i]; } bool SetToSpecialLocation(int v); void SetBoxValue(const iVector3D &v); void SetBoxValue(int i, double x); void operator=(const iPosition&); void operator=(const double *); void PeriodicWrap(); void CutToBounds(); private: void UpdateOGLValue(); void UpdateBoxValue() const; mutable iVector3D mBoxValue; iVector3D mOGLValue; iPosition(const iPosition&); // not implemented }; // // iCoordinate functions // inline void iCoordinate::SetBoxValue(double x) { mBoxValue = x; this->UpdateOGLValue(); } inline void iCoordinate::operator=(const iCoordinate &p) { mOGLValue = p.mOGLValue; } inline void iCoordinate::operator=(double s) { mOGLValue = s; } // // iDistance functions // inline void iDistance::SetBoxValue(double x) { if(x > 0.0) { mBoxValue = x; this->UpdateOGLValue(); } } inline void iDistance::operator=(const iDistance &p) { if(p.mOGLValue > 0.0) mOGLValue = p.mOGLValue; } inline void iDistance::operator=(double s) { if(s > 0.0) mOGLValue = s; } // // iPosition functions // inline void iPosition::SetBoxValue(const iVector3D &v) { mBoxValue = v; this->UpdateOGLValue(); } inline void iPosition::SetBoxValue(int i, double x) { if(i>=0 && i<3) { this->UpdateBoxValue(); // needed for out-of-date box values at other indicies not to propagate into OGL values mBoxValue[i] = x; this->UpdateOGLValue(); } } inline void iPosition::operator=(const iPosition &p) { mOGLValue = p.mOGLValue; } inline void iPosition::operator=(const double *p) { mOGLValue = p; } #endif // IPOSITION_H ifrit-4.1.2/core/ipostscriptwriter.cpp0000674060175406010010000001747212641012562016502 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ipostscriptwriter.h" #include #include #define VTK_MARGIN 0.95 iPostScriptWriter::Paper iPostScriptWriter::mPaper[NFORMATS]; iPostScriptWriter::iPostScriptWriter() { int i = 0; if(i < NFORMATS) { mPaper[i].Width = 33.0556; mPaper[i].Height = 46.7778; mPaper[i].Name = "A0"; i++; } if(i < NFORMATS) { mPaper[i].Width = 23.3889; mPaper[i].Height = 33.0556; mPaper[i].Name = "A1"; i++; } if(i < NFORMATS) { mPaper[i].Width = 16.5278; mPaper[i].Height = 23.3889; mPaper[i].Name = "A2"; i++; } if(i < NFORMATS) { mPaper[i].Width = 11.6944; mPaper[i].Height = 16.5278; mPaper[i].Name = "A3"; i++; } if(i < NFORMATS) { mPaper[i].Width = 8.26389; mPaper[i].Height = 11.6944; mPaper[i].Name = "A4"; i++; } if(i < NFORMATS) { mPaper[i].Width = 5.84772; mPaper[i].Height = 8.26389; mPaper[i].Name = "A5"; i++; } if(i < NFORMATS) { mPaper[i].Width = 4.12500; mPaper[i].Height = 5.84772; mPaper[i].Name = "A6"; i++; } if(i < NFORMATS) { mPaper[i].Width = 2.91667; mPaper[i].Height = 4.12500; mPaper[i].Name = "A7"; i++; } if(i < NFORMATS) { mPaper[i].Width = 2.05556; mPaper[i].Height = 2.91667; mPaper[i].Name = "A8"; i++; } if(i < NFORMATS) { mPaper[i].Width = 8.5 ; mPaper[i].Height = 11.0 ; mPaper[i].Name = "Letter"; i++; } if(i < NFORMATS) { mPaper[i].Width = 11.0 ; mPaper[i].Height = 17.0 ; mPaper[i].Name = "11x17"; i++; } mFormat = 9; mOrient = 0; } iPostScriptWriter::~iPostScriptWriter() { } void iPostScriptWriter::SetPaperFormat(int f) { if(f>=0 && f=0 && o<=1) mOrient = o; } void iPostScriptWriter::WriteFileHeader(ofstream *file, vtkImageData *cache) { // // Copied from vtkPostScriptWriter.cxx with addition of options to specify paper size and orientation. // int min1, max1, min2, max2, min3, max3; int bpp; int cols, rows, scols, srows; float scale = 1; int pagewid = (int)(mPaper[mFormat].Width*72); int pagehgt = (int)(mPaper[mFormat].Height*72); // Find the length of the rows to write. cache->GetExtent(min1, max1, min2, max2, min3, max3); bpp = cache->GetNumberOfScalarComponents(); cols = max1 - min1 + 1; rows = max2 - min2 + 1; if(mOrient == 1) { // // Landscape orientation // int q = cols; cols = rows; rows = q; } // // Fit to width // scale = float(pagewid)/cols; scols = int(scale*cols*VTK_MARGIN); srows = int(scale*rows*VTK_MARGIN); // // If too high, fit to height // if(srows > pagehgt*VTK_MARGIN) { scale = scale*(pagehgt*VTK_MARGIN/srows); scols = (int)(scale*cols*VTK_MARGIN); srows = (int)(scale*rows*VTK_MARGIN); } float llx = (pagewid-scols) / 2; float lly = (pagehgt-srows) / 2; // spit out the PostScript header *file << "%!PS-Adobe-2.0 EPSF-2.0\n"; *file << "%%Creator: IFrIT\n"; *file << "%%Title: " << this->InternalFileName << endl; *file << "%%Pages: 1\n"; *file << "%%BoundingBox: " << (int) llx << " " << (int) lly << " " << (int) ( llx + scols + 0.5 ) << " " << (int) ( lly + srows + 0.5 ) << endl; *file << "%%EndComments\n"; *file << "/readstring {\n"; *file << " currentfile exch readhexstring pop\n"; *file << "} bind def\n"; if ( bpp == 3) { *file << "/rpicstr " << cols << " string def\n"; *file << "/gpicstr " << cols << " string def\n"; *file << "/bpicstr " << cols << " string def\n"; } else if (bpp == 1) { *file << "/picstr " << cols << " string def\n"; } else { vtkWarningMacro( " vtkPostScriptWriter only supports 1 and 3 component images"); } *file << "%%EndProlog\n"; *file << "%%Page: 1 1\n"; *file << "gsave\n"; *file << llx << " " << lly << " translate\n"; *file << scols << " " << srows << " scale\n"; *file << cols << " " << rows << " 8\n"; *file << "[ " << cols << " 0 0 " << -rows << " 0 " << rows << " ]\n"; if (bpp == 3) { *file << "{ rpicstr readstring }\n"; *file << "{ gpicstr readstring }\n"; *file << "{ bpicstr readstring }\n"; *file << "true 3\n"; *file << "colorimage\n"; } else { *file << "{ picstr readstring }\n"; *file << "image\n"; } } void iPostScriptWriter::WriteFile(ofstream *file, vtkImageData *data, int extent[6]) { // // Copied from vtkPostScriptWriter.cxx with addition of options to specify paper size and orientation. // int idxC, idx0, idx1, idx2; unsigned char *ptr; unsigned long count = 0; unsigned long tarGet; float progress = this->Progress; float area; int *wExtent; static int itemsperline = 0; char* hexits = (char *) "0123456789abcdef"; // Make sure we actually have data. if ( !data->GetPointData()->GetScalars()) { vtkErrorMacro(<< "Could not Get data from input."); return; } // take into consideration the scalar type switch (data->GetScalarType()) { case VTK_UNSIGNED_CHAR: break; default: vtkErrorMacro("PostScriptWriter only accepts unsigned char scalars!"); return; } int i0 = 0, i1 = 1, i2 = 2, i3 = 3; if(mOrient == 1) { i0 = 2; i1 = 3; i2 = 0; i3 = 1; } wExtent = this->GetInput()->GetExtent(); area = ((extent[5] - extent[4] + 1)*(extent[3] - extent[2] + 1)* (extent[1] - extent[0] + 1)) / ((wExtent[5] -wExtent[4] + 1)*(wExtent[3] -wExtent[2] + 1)* (wExtent[1] -wExtent[0] + 1)); int numComponents = data->GetNumberOfScalarComponents(); // ignore alpha int maxComponent = numComponents; if (numComponents == 2) { maxComponent = 1; } if (numComponents == 4) { maxComponent = 3; } tarGet = (unsigned long)((extent[5]-extent[4]+1)* (extent[i3]-extent[i2]+1)/(50.0*area)); tarGet++; int ptrOffset = numComponents; int idx1run; if(mOrient == 1) { ptrOffset = numComponents*(extent[1]-extent[0]+1); } for (idx2 = extent[4]; idx2 <= extent[5]; ++idx2) { for (idx1run = extent[i3]; idx1run >= extent[i2]; idx1run--) { // // Orientation // idx1 = idx1run; if(mOrient == 1) { idx1 = extent[i3] + extent[i2] - idx1run; } if (!(count%tarGet)) { this->UpdateProgress(progress + count/(50.0*tarGet)); } count++; // write out components one at a time because for (idxC = 0; idxC < maxComponent; idxC++) { // // Orientation // if(mOrient == 1) { ptr = (unsigned char *)data->GetScalarPointer(idx1,extent[2],idx2); } else { ptr = (unsigned char *)data->GetScalarPointer(extent[0],idx1,idx2); } ptr += idxC; for ( idx0 = extent[i0]; idx0 <= extent[i1]; idx0++ ) { if ( itemsperline == 30 ) { *file << endl; itemsperline = 0; } *file << hexits[*ptr >> 4] << hexits[*ptr & 15]; ptr += ptrOffset; } } } } } ifrit-4.1.2/core/ipostscriptwriter.h0000674060175406010010000000436312641012532016137 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // vtkPostScriptWriter with different paper formats // #ifndef IPOSTSCRIPTWRITER_H #define IPOSTSCRIPTWRITER_H #define NFORMATS 11 #include class iPostScriptWriter : public vtkPostScriptWriter { public: vtkTypeMacro(iPostScriptWriter,vtkPostScriptWriter); static iPostScriptWriter* New(){ return new iPostScriptWriter; } virtual void SetPaperFormat(int f); inline int GetPaperFormat(){ return mFormat; } virtual void SetOrientation(int o); inline int GetOrientation(){ return mOrient; } static const char* GetPaperFormatName(int n){ if(n>=0 && n #include #include #include #include #include // // Templates (needed for some compilers) // #include "igenericfilter.tlh" iProbeFilter::iProbeFilter(iDataConsumer *consumer) : iGenericFilter(consumer,2,true) { mRestrictedType = 0; } void iProbeFilter::RestrictToType(const char *name) { if(vtkDataObjectTypes::GetTypeIdFromClassName(name) != -1) { mRestrictedType = name; } } // // This filter is too generic, we need to specialize the output depending on the input // int iProbeFilter::FillInputPortInformation(int port, vtkInformation *info) { if(mRestrictedType == 0) { return this->vtkProbeFilter::FillInputPortInformation(port,info); } else { info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),mRestrictedType); return 1; } } int iProbeFilter::FillOutputPortInformation(int port, vtkInformation *info) { if(mRestrictedType == 0) { return this->vtkProbeFilter::FillOutputPortInformation(port,info); } else { info->Set(vtkDataObject::DATA_TYPE_NAME(),mRestrictedType); return 1; } } void iProbeFilter::ProvideOutput() { vtkDataSet *input = this->InputData(); vtkDataSet *output = this->OutputData(); vtkDataSet *source = this->SourceData(); if(source->IsA("vtkImageData") && input->IsA("vtkPointSet") && output->IsA("vtkPointSet")) { this->ProduceOutputForImageData(vtkPointSet::SafeDownCast(input),vtkPointSet::SafeDownCast(output),vtkImageData::SafeDownCast(source)); } else { output->ShallowCopy(input); // Probe does not copy normals... this->vtkProbeFilter::Probe(input,source,output); } } vtkDataSet* iProbeFilter::SourceData() { return iRequiredCast(INFO,this->GetSource()); } void iProbeFilter::ProduceOutputForImageData(vtkPointSet *input, vtkPointSet *output, vtkImageData *source) { output->ShallowCopy(input); vtkPoints *inpts = input->GetPoints(); if(inpts == 0) return; vtkIdType numPts = inpts->GetNumberOfPoints(); if(!wArray.Init(source->GetPointData()->GetScalars(),numPts)) { this->SetAbortExecute(1); return; } int j, dims[3], ijk1[3], ijk2[3]; double org[3], spa[3]; source->GetDimensions(dims); source->GetSpacing(spa); source->GetOrigin(org); vtkIdType l, loff, loff111, loff112, loff121, loff122, loff211, loff212, loff221, loff222; double x[3]; double d1[3], d2[3]; bool per[3]; this->GetPeriodicities(per); // // Loop over all input points, interpolating source data // for(l=0; lUpdateProgress(double(l)/numPts); if(this->GetAbortExecute()) break; } // Get the xyz coordinate of the point in the input dataset inpts->GetPoint(l,x); // Find the cell that contains xyz and get it iUniformGridData::CIC(per,dims,org,spa,x,ijk1,ijk2,d1,d2); loff111 = wArray.DimIn*(ijk1[0]+dims[0]*(ijk1[1]+(vtkIdType)dims[1]*ijk1[2])); loff112 = wArray.DimIn*(ijk1[0]+dims[0]*(ijk1[1]+(vtkIdType)dims[1]*ijk2[2])); loff121 = wArray.DimIn*(ijk1[0]+dims[0]*(ijk2[1]+(vtkIdType)dims[1]*ijk1[2])); loff122 = wArray.DimIn*(ijk1[0]+dims[0]*(ijk2[1]+(vtkIdType)dims[1]*ijk2[2])); loff211 = wArray.DimIn*(ijk2[0]+dims[0]*(ijk1[1]+(vtkIdType)dims[1]*ijk1[2])); loff212 = wArray.DimIn*(ijk2[0]+dims[0]*(ijk1[1]+(vtkIdType)dims[1]*ijk2[2])); loff221 = wArray.DimIn*(ijk2[0]+dims[0]*(ijk2[1]+(vtkIdType)dims[1]*ijk1[2])); loff222 = wArray.DimIn*(ijk2[0]+dims[0]*(ijk2[1]+(vtkIdType)dims[1]*ijk2[2])); loff = l*wArray.DimOut; for(j=0; jGetPointData()->SetScalars(wArray.ArrOut); wArray.ArrOut->Delete(); } ifrit-4.1.2/core/iprobefilter.h0000674060175406010010000000440512641012533015003 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Optimized version of vtkProbeFilter for vtkPolyData input and vtkImageData source; // Also, vtkProbeFilter does not pass through normals of the input (for a good reason!). // This filter adds passing normals. // #ifndef IPROBEFILTER_H #define IPROBEFILTER_H #include "igenericfilter.h" #include class vtkImageData; class vtkPointSet; class iProbeFilter : public iGenericFilter { iGenericFilterTypeMacro(iProbeFilter,vtkProbeFilter); public: void RestrictToType(const char *name); vtkDataSet* SourceData(); protected: virtual int FillInputPortInformation(int port, vtkInformation *info); virtual int FillOutputPortInformation(int port, vtkInformation *info); virtual void ProvideOutput(); private: void ProduceOutputForImageData(vtkPointSet *input, vtkPointSet *output, vtkImageData *source); const char *mRestrictedType; private: /* blocked */ vtkDataObject *GetSource(){ return this->vtkProbeFilter::GetSource(); } }; #endif // IPROBEFILTER_H ifrit-4.1.2/core/iproperty.cpp0000674060175406010010000001333112641012563014706 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iproperty.h" #include "ierror.h" #include "ipiecewisefunction.h" // // Templates // #include "iarray.tlh" #include "iproperty.tlh" iProperty::Key iProperty::KeyCounter = 1; iGenericOrderedArray iProperty::mRegistry(iProperty::EntryLookup); iProperty::iProperty(iObject *owner, const iString &fname, const iString &sname, int rank) : mRank(rank), mLongName(fname), mShortName(sname), mTag(iString::FromNumber(9-rank,"%1d")+sname) ,mKey(KeyCounter++) { IASSERT(owner); mOwner = owner; if(mRank<0 || mRank>9) { IBUG_FATAL("Property rank must be between 0 and 9"); } mFlags = 0; mRegistry.Add(this); } iProperty::~iProperty() { mRegistry.Remove(this); } bool iProperty::IsImmediatePost() const { return mOwner->IsImmediatePost(); } void iProperty::RequestRender() const { if(!this->TestFlag(_DoNotRequestRender)) { mOwner->RequestRender(); } } bool iProperty::_RequestPush() const { return mOwner->_RequestPush(mKey); } const iString iProperty::HelpTag() const { return this->Owner()->HelpTag() + "." + this->ShortName(); } void iProperty::AddFlag(Flag f) { mFlags |= f; } bool iProperty::TestFlag(Flag f) const { return (mFlags & f) != 0; } const iProperty* iProperty::FindPropertyByKey(const Key& key) { int i = mRegistry.FindByKey(key); if(i > -1) return mRegistry[i]; else return 0; } const iProperty::Key& iProperty::EntryLookup(const iProperty* const &ptr) { return ptr->GetKey(); } // // Abstract variable property // iPropertyVariable::iPropertyVariable(iObject *owner, const iString &fname, const iString &sname, int rank) : iProperty(owner,fname,sname,rank) { if(!this->ShortName().IsEmpty()) this->Owner()->mVariableProperties.Add(this); } iPropertyVariable::~iPropertyVariable() { if(!this->ShortName().IsEmpty()) this->Owner()->mVariableProperties.Remove(this); } // // Abstract function property (not a variable) // iPropertyFunction::iPropertyFunction(iObject *owner, const iString &fname, const iString &sname, int rank) : iProperty(owner,fname,sname,rank) { this->Owner()->mFunctionProperties.Add(this); } iPropertyFunction::~iPropertyFunction() { this->Owner()->mFunctionProperties.Remove(this); } // // Special property that correctly updates the piecewise function // iPropertyPiecewiseFunction::iPropertyPiecewiseFunction(iObject *owner, const iString &fname, const iString &sname, int rank) : iPropertyDataVariable(owner,fname,sname,rank) { mFunction = 0; } iPropertyPiecewiseFunction::~iPropertyPiecewiseFunction() { } void iPropertyPiecewiseFunction::AttachFunction(iPiecewiseFunction *f) { mFunction = f; } int iPropertyPiecewiseFunction::Size() const { if(mFunction != 0) return mFunction->N(); else return 0; } bool iPropertyPiecewiseFunction::Resize(int dim, bool force) { if(dim>1 && mFunction!=0) { int i, olddim = mFunction->N(); for(i=olddim; iAddPoint(mFunction->N()-2); for(i=dim; iRemovePoint(mFunction->N()-2); return true; } else return false; } const iPair& iPropertyPiecewiseFunction::GetValue(int i) const { static const iPair null(0,0); if(mFunction != 0) return mFunction->P(i); else return null; } bool iPropertyPiecewiseFunction::SetValue(int i, const iPair& p) const { if(mFunction != 0) { mFunction->MovePoint(i,p); return true; } else return false; } bool iPropertyPiecewiseFunction::Copy(const iPropertyVariable *p) { const iPropertyPiecewiseFunction *other = dynamic_cast(p); if(other != 0) { this->Resize(other->Size(),true); return iPropertyDataVariable::Copy(p); } else return false; } // // Simple command with no arguments // iPropertyAction::iPropertyAction(iObject *owner, CallerType caller, const iString &fname, const iString &sname, int rank) : iPropertyTypeFunction(owner,fname,sname,rank) { mCaller = caller; IASSERT(caller); mQueue = 0; } bool iPropertyAction::CallAction() const { return (this->Owner()->*mCaller)(); } bool iPropertyAction::_PostCall() const { if(this->IsImmediatePost()) { if(this->CallAction()) { this->RequestRender(); return true; } else return false; } else { // // Message queue // mQueue++; return this->_RequestPush(); } } bool iPropertyAction::PushPostedValue_() const { bool ret = this->CallAction(); mQueue--; if(ret) { this->RequestRender(); return true; } else return false; } bool iPropertyAction::HasPostedRequests() const { return (mQueue > 0); } ifrit-4.1.2/core/iproperty.h0000674060175406010010000003311612641012533014353 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A self-saveable/loadable property for iObject class // #ifndef IPROPERTY_H #define IPROPERTY_H #include "iarray.h" #include "itype.h" class iObject; class iPiecewiseFunction; //class iShell; // // Base class for all object properties (now sure we need it - keep for now) // class iProperty { friend class iObject; public: typedef size_t Key; enum Flag { _OptionalInState = 0x0001, _FunctionsAsIndex = 0x0002, _DoNotSaveInState = 0x0004, _DoNotIncludeInCopy = 0x0008, _DoNotRequestRender = 0x0010 }; virtual ~iProperty(); inline const iString& LongName() const { return mLongName; } inline const iString& ShortName() const { return mShortName; } inline const iString& Tag() const { return mTag; } // for ordering iObject* Owner() const { return mOwner; } const iString HelpTag() const; void AddFlag(Flag f); bool TestFlag(Flag f) const; static const iProperty* FindPropertyByKey(const Key& key); const Key& GetKey() const { return mKey; } protected: iProperty(iObject *owner, const iString &fname, const iString &sname, int rank); void RequestRender() const; bool IsImmediatePost() const; private: iObject *mOwner; const int mRank; const iString mLongName, mShortName, mTag; int mFlags; // // Registry functionality // const Key mKey; static Key KeyCounter; static iGenericOrderedArray mRegistry; static const Key& EntryLookup(const iProperty* const &ptr); iProperty(const iProperty&); // Not implemented. void operator=(const iProperty&); // Not implemented. // // This is a part of message subsystem for thread-safe execution. // Functions begining with underscore can be called from the driver thread. // Functions ending with underscore should be called from the slave thread only. // public: virtual bool PushPostedValue_() const = 0; virtual bool HasPostedRequests() const = 0; protected: bool _RequestPush() const; }; // // Abstract variable property // class iPropertyVariable : public iProperty { public: virtual ~iPropertyVariable(); virtual iType::TypeId GetType() const = 0; virtual const iString& GetTypeName() const = 0; virtual iString ConvertToString(bool exact) const = 0; virtual void SaveStateToString(iString &str, bool exact) const = 0; virtual bool LoadStateFromString(const iString &str) = 0; virtual int Size() const = 0; virtual bool IsFixedSize() const = 0; virtual bool Copy(const iPropertyVariable *p) = 0; virtual bool CopyElement(int iy, int ix) = 0; protected: iPropertyVariable(iObject *owner, const iString &fname, const iString &sname, int rank); virtual bool Resize(int num, bool force = false) = 0; }; // // Abstract function property (not a variable) // class iPropertyFunction : public iProperty { public: virtual ~iPropertyFunction(); virtual iType::TypeId GetReturnType() const = 0; virtual const iString& GetReturnTypeName() const = 0; virtual int NumArguments() const = 0; virtual iType::TypeId GetArgumentType(int i) const = 0; virtual const iString& GetArgumentTypeName(int i) const = 0; protected: iPropertyFunction(iObject *owner, const iString &fname, const iString &sname, int rank); }; // // Abstract variable property of a given type // template class iPropertyDataVariable : public iPropertyVariable { public: typedef typename iType::Traits::Type ArgT; virtual ~iPropertyDataVariable(); virtual iType::TypeId GetType() const; virtual const iString& GetTypeName() const; virtual iString ConvertToString(bool exact) const; virtual void SaveStateToString(iString &str, bool exact) const; virtual bool LoadStateFromString(const iString &str); virtual bool Copy(const iPropertyVariable *p); virtual bool CopyElement(int iy, int ix); // // SetValue does not cause a render, PostValue does // virtual ArgT GetValue(int i) const = 0; virtual bool SetValue(int i, ArgT v) const = 0; protected: iPropertyDataVariable(iObject *owner, const iString &fname, const iString &sname, int rank); // // This is a part of message subsystem for thread-safe execution. // Functions begining with underscore can be called from the driver thread. // Functions ending with underscore should be called from the slave thread only. // public: bool _PostValue(int i, ArgT v) const; virtual bool PushPostedValue_() const; virtual bool HasPostedRequests() const; struct QueueItem { int Index; typename iType::Traits::ContainerType Value; }; mutable iArray mQueue; }; // // Scalar (1D) variable // template class iPropertyScalar : public iPropertyDataVariable { public: typedef typename iType::Traits::Type ArgT; typedef bool (iObject::*SetterType)(ArgT val); typedef ArgT (iObject::*GetterType)() const; iPropertyScalar(iObject *owner, SetterType setter, GetterType getter, const iString &fname, const iString &sname, int rank = 0); virtual int Size() const { return 1; } virtual bool IsFixedSize() const { return true; } virtual ArgT GetValue(int i) const; virtual bool SetValue(int i, ArgT v) const; protected: virtual bool Resize(int, bool force = false){ return false; } private: SetterType mSetter; GetterType mGetter; }; // // Fixed-size vector variable // template class iPropertyVector : public iPropertyDataVariable { public: typedef typename iType::Traits::Type ArgT; typedef int (iObject::*SizeType)() const; typedef bool (iObject::*ResizeType)(int n); typedef bool (iObject::*SetterType)(int i, ArgT val); typedef ArgT (iObject::*GetterType)(int i) const; iPropertyVector(iObject *owner, SetterType setter, GetterType getter, const iString &fname, const iString &sname, int dim, int rank = 0); iPropertyVector(iObject *owner, SetterType setter, GetterType getter, const iString &fname, const iString &sname, SizeType size, ResizeType resize = 0, int rank = 0); virtual int Size() const { return (this->mSize == 0) ? this->mDim : (this->Owner()->*mSize)(); } virtual bool IsFixedSize() const { return (this->mResize == 0); } virtual ArgT GetValue(int i) const; virtual bool SetValue(int i, ArgT v) const; protected: virtual bool Resize(int num, bool force = false); private: int mDim; SizeType mSize; ResizeType mResize; SetterType mSetter; GetterType mGetter; }; // // Special property that correctly updates the piecewise function. // class iPropertyPiecewiseFunction : public iPropertyDataVariable { public: iPropertyPiecewiseFunction(iObject *owner, const iString &fname, const iString &sname, int rank = 0); virtual ~iPropertyPiecewiseFunction(); void AttachFunction(iPiecewiseFunction *f); inline iPiecewiseFunction* Function() const { return mFunction; } virtual int Size() const; virtual bool IsFixedSize() const { return false; } virtual bool Copy(const iPropertyVariable *p); virtual iType::Traits::Type GetValue(int i) const; virtual bool SetValue(int i, iType::Traits::Type p) const; protected: virtual bool Resize(int dim, bool force = false); private: iPiecewiseFunction *mFunction; }; // // Function with a given return type // template class iPropertyTypeFunction : public iPropertyFunction { public: iPropertyTypeFunction(iObject *owner, const iString &fname, const iString &sname, int rank); virtual ~iPropertyTypeFunction(); virtual iType::TypeId GetReturnType() const; virtual const iString& GetReturnTypeName() const; }; // // Simple action with no arguments // class iPropertyAction : public iPropertyTypeFunction { public: typedef bool (iObject::*CallerType)(); iPropertyAction(iObject *owner, CallerType caller, const iString &fname, const iString &sname, int rank = 0); virtual int NumArguments() const { return 0; } virtual iType::TypeId GetArgumentType(int) const { return iType::None; } virtual const iString& GetArgumentTypeName(int) const { static iString none; return none; } virtual bool CallAction() const; private: CallerType mCaller; // // This is a part of message subsystem for thread-safe execution. // Functions begining with underscore can be called from the driver thread. // Functions ending with underscore should be called from the slave thread only. // public: bool _PostCall() const; virtual bool PushPostedValue_() const; virtual bool HasPostedRequests() const; mutable int mQueue; }; // // An action with 1 argument // template class iPropertyAction1 : public iPropertyTypeFunction { public: typedef typename iType::Traits::Type ArgT; typedef bool (iObject::*CallerType)(ArgT v); iPropertyAction1(iObject *owner, CallerType caller, const iString &fname, const iString &sname, int rank = 0); virtual int NumArguments() const { return 1; } virtual iType::TypeId GetArgumentType(int i) const; virtual const iString& GetArgumentTypeName(int i) const; virtual bool CallAction(ArgT v) const; private: CallerType mCaller; // // This is a part of message subsystem for thread-safe execution. // Functions begining with underscore can be called from the driver thread. // Functions ending with underscore should be called from the slave thread only. // public: bool _PostCall(ArgT v) const; virtual bool PushPostedValue_() const; virtual bool HasPostedRequests() const; struct QueueItem { typename iType::Traits::ContainerType Value; }; mutable iArray mQueue; }; // // An action with 2 arguments // template class iPropertyAction2 : public iPropertyTypeFunction { public: typedef typename iType::Traits::Type ArgT1; typedef typename iType::Traits::Type ArgT2; typedef bool (iObject::*CallerType)(ArgT1 v1, ArgT2 v2); iPropertyAction2(iObject *owner, CallerType caller, const iString &fname, const iString &sname, int rank = 0); virtual int NumArguments() const { return 2; } virtual iType::TypeId GetArgumentType(int i) const; virtual const iString& GetArgumentTypeName(int i) const; virtual bool CallAction(ArgT1 v1, ArgT2 v2) const; private: CallerType mCaller; // // This is a part of message subsystem for thread-safe execution. // Functions begining with underscore can be called from the driver thread. // Functions ending with underscore should be called from the slave thread only. // public: bool _PostCall(ArgT1 v1, ArgT2 v2) const; virtual bool PushPostedValue_() const; virtual bool HasPostedRequests() const; struct QueueItem { typename iType::Traits::ContainerType Value1; typename iType::Traits::ContainerType Value2; }; mutable iArray mQueue; }; // // A simple query with no arguments // template class iPropertyQuery : public iPropertyTypeFunction { public: typedef typename iType::Traits::Type RetT; typedef RetT (iObject::*GetterType)() const; iPropertyQuery(iObject *owner, GetterType getter, const iString &fname, const iString &sname, int rank = 0); virtual int NumArguments() const { return 0; } virtual iType::TypeId GetArgumentType(int) const { return iType::None; } virtual const iString& GetArgumentTypeName(int) const { static iString none; return none; } virtual RetT GetQuery() const; private: GetterType mGetter; // // This is a part of message subsystem for thread-safe execution. // Functions begining with underscore can be called from the driver thread. // Functions ending with underscore should be called from the slave thread only. // public: // // Query should never modify the core, hence assume it is thread safe // virtual bool PushPostedValue_() const { return true; } virtual bool HasPostedRequests() const { return false; } }; namespace iType { typedef iPropertyScalar ps_int; typedef iPropertyScalar ps_bool; typedef iPropertyScalar ps_float; typedef iPropertyScalar s_double; typedef iPropertyScalar ps_string; typedef iPropertyScalar ps_pair; typedef iPropertyScalar ps_color; typedef iPropertyScalar ps_vector; typedef iPropertyVector pv_int; typedef iPropertyVector pv_bool; typedef iPropertyVector pv_float; typedef iPropertyVector pv_double; typedef iPropertyVector pv_string; typedef iPropertyVector pv_pair; typedef iPropertyVector pv_color; typedef iPropertyVector pv_vector; }; #endif // IPROPERTY_H ifrit-4.1.2/core/iproperty.tlh0000674060175406010010000002267012641012510014711 0ustar HomeNone//LICENSE A #include "iproperty.h" #include "iarray.h" #include "ierror.h" #include "iobject.h" // // Variable property that caches its data // template iPropertyDataVariable::iPropertyDataVariable(iObject *owner, const iString &fname, const iString &sname, int rank) : iPropertyVariable(owner,fname,sname,rank) { } template iPropertyDataVariable::~iPropertyDataVariable() { } template iType::TypeId iPropertyDataVariable::GetType() const { return id; } template const iString& iPropertyDataVariable::GetTypeName() const { return iType::Traits::TypeName(); } template iString iPropertyDataVariable::ConvertToString(bool exact) const { int i; iString str; for(i=0; iSize(); i++) { if(i > 0) str += ","; str += iType::Traits::ValueToString(this->GetValue(i),exact); } return str; } template void iPropertyDataVariable::SaveStateToString(iString &str, bool exact) const { str = this->Owner()->GetFullName() + "." + this->LongName() + " = " + this->ConvertToString(exact); } template bool iPropertyDataVariable::LoadStateFromString(const iString &str) { iString head = this->Owner()->GetFullName() + "." + this->LongName() + " = "; int i = str.Find(head); if(i == -1) return false; iString s = str.Part(i+head.Length()).Section("\n",0,0); int n = s.IsEmpty() ? 0 : (s.Contains(',')+1); if(n != this->Size()) { if(!this->Resize(n,true)) return false; } typename iType::Traits::ContainerType val; for(i=0; iSize(); i++) { if(!iType::Traits::StringToValue(s.Section(",",i,i),val)) return false; if(!this->SetValue(i,val)) return false; } return true; } template bool iPropertyDataVariable::Copy(const iPropertyVariable *p) { const iPropertyDataVariable *other = dynamic_cast*>(p); if(other != 0) { if(this->Size() != other->Size()) return false; int i, n = this->Size(); for(i=0; iSetValue(i,other->GetValue(i))) return false; } return true; } else return false; } template bool iPropertyDataVariable::CopyElement(int iy, int ix) { if(ix == iy) return true; if(iy>=0 && iySize() && ix>=0 && ixSize()) { return this->SetValue(iy,this->GetValue(ix)); } else return false; } template bool iPropertyDataVariable::_PostValue(int i, ArgT v) const { if(this->IsImmediatePost()) { if(this->SetValue(i,v)) { this->RequestRender(); return true; } else return false; } else { // // Message queue // QueueItem qi; qi.Index = i; qi.Value = v; this->mQueue.Add(qi); return this->_RequestPush(); } } template bool iPropertyDataVariable::PushPostedValue_() const { bool ret = this->SetValue(this->mQueue[0].Index,this->mQueue[0].Value); this->mQueue.Remove(0); if(ret) { this->RequestRender(); return true; } else return false; } template bool iPropertyDataVariable::HasPostedRequests() const { return (this->mQueue.Size() > 0); } // // Scalar (1D) variable // template iPropertyScalar::iPropertyScalar(iObject *owner, SetterType setter, GetterType getter, const iString &fname, const iString &sname, int rank) : iPropertyDataVariable(owner,fname,sname,rank) { this->mSetter = setter; IASSERT(setter); this->mGetter = getter; IASSERT(getter); } template typename iPropertyScalar::ArgT iPropertyScalar::GetValue(int) const { return (this->Owner()->*this->mGetter)(); } template bool iPropertyScalar::SetValue(int, ArgT v) const { return (this->Owner()->*this->mSetter)(v); } // // Fixed-size vector variable // template iPropertyVector::iPropertyVector(iObject *owner, SetterType setter, GetterType getter, const iString &fname, const iString &sname, int dim, int rank) : iPropertyDataVariable(owner,fname,sname,rank) { if(dim < 1) dim = 1; this->mDim = dim; this->mSize = 0; this->mResize = 0; this->mSetter = setter; IASSERT(setter); this->mGetter = getter; IASSERT(getter); } template iPropertyVector::iPropertyVector(iObject *owner, SetterType setter, GetterType getter, const iString &fname, const iString &sname, SizeType size, ResizeType resize, int rank) : iPropertyDataVariable(owner,fname,sname,rank) { this->mDim = 0; this->mSize = size; this->mResize = resize; this->mSetter = setter; IASSERT(setter); this->mGetter = getter; IASSERT(getter); } template typename iPropertyVector::ArgT iPropertyVector::GetValue(int i) const { return (this->Owner()->*mGetter)(i); } template bool iPropertyVector::SetValue(int i, ArgT v) const { if(i>=this->Size() && (this->mResize==0 || !(this->Owner()->*mResize)(i+1))) return false; return (this->Owner()->*mSetter)(i,v); } template bool iPropertyVector::Resize(int num, bool force) { if(num>=0 && this->mResize!=0 && (this->Owner()->*mResize)(num)) { return true; } else return false; } // // Function property (not a variable) // template iPropertyTypeFunction::iPropertyTypeFunction(iObject *owner, const iString &fname, const iString &sname, int rank) : iPropertyFunction(owner,fname,sname,rank) { } template iPropertyTypeFunction::~iPropertyTypeFunction() { } template iType::TypeId iPropertyTypeFunction::GetReturnType() const { return id; } template const iString& iPropertyTypeFunction::GetReturnTypeName() const { return iType::Traits::TypeName(); } // // An action with 1 argument // template iPropertyAction1::iPropertyAction1(iObject *owner, CallerType caller, const iString &fname, const iString &sname, int rank) : iPropertyTypeFunction(owner,fname,sname,rank) { this->mCaller = caller; IASSERT(caller); } template iType::TypeId iPropertyAction1::GetArgumentType(int i) const { if(i == 0) { return id; } else return iType::None; } template const iString& iPropertyAction1::GetArgumentTypeName(int i) const { static iString none; if(i == 0) { return iType::Traits::TypeName(); } else return none; } template bool iPropertyAction1::CallAction(ArgT v) const { return (this->Owner()->*mCaller)(v); } template bool iPropertyAction1::_PostCall(ArgT v) const { if(this->IsImmediatePost()) { if(this->CallAction(v)) { this->RequestRender(); return true; } else return false; } else { // // Message queue // QueueItem qi; qi.Value = v; this->mQueue.Add(qi); return this->_RequestPush(); } } template bool iPropertyAction1::PushPostedValue_() const { bool ret = this->CallAction(this->mQueue[0].Value); this->mQueue.Remove(0); if(ret) { this->RequestRender(); return true; } else return false; } template bool iPropertyAction1::HasPostedRequests() const { return (this->mQueue.Size() > 0); } // // An action with 2 arguments // template iPropertyAction2::iPropertyAction2(iObject *owner, CallerType caller, const iString &fname, const iString &sname, int rank) : iPropertyTypeFunction(owner,fname,sname,rank) { this->mCaller = caller; IASSERT(caller); } template iType::TypeId iPropertyAction2::GetArgumentType(int i) const { switch(i) { case 0: { return id1; } case 1: { return id2; } default: { return iType::None; } } } template const iString& iPropertyAction2::GetArgumentTypeName(int i) const { static iString none; switch(i) { case 0: { return iType::Traits::TypeName(); } case 1: { return iType::Traits::TypeName(); } default: { return none; } } } template bool iPropertyAction2::CallAction(ArgT1 v1, ArgT2 v2) const { return (this->Owner()->*mCaller)(v1,v2); } template bool iPropertyAction2::_PostCall(ArgT1 v1, ArgT2 v2) const { if(this->IsImmediatePost()) { if(this->CallAction(v1,v2)) { this->RequestRender(); return true; } else return false; } else { // // Message queue // QueueItem qi; qi.Value1 = v1; qi.Value2 = v2; this->mQueue.Add(qi); return this->_RequestPush(); } } template bool iPropertyAction2::PushPostedValue_() const { bool ret = this->CallAction(this->mQueue[0].Value1,this->mQueue[0].Value2); this->mQueue.Remove(0); if(ret) { this->RequestRender(); return true; } else return false; } template bool iPropertyAction2::HasPostedRequests() const { return (this->mQueue.Size() > 0); } // // A simple query with no arguments // template iPropertyQuery::iPropertyQuery(iObject *owner, GetterType getter, const iString &fname, const iString &sname, int rank) : iPropertyTypeFunction(owner,fname,sname,rank) { this->mGetter = getter; IASSERT(getter); } template typename iPropertyQuery::RetT iPropertyQuery::GetQuery() const { return (this->Owner()->*this->mGetter)(); } ifrit-4.1.2/core/ipropertymultiobject.h0000674060175406010010000000615312641012533016616 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A property for an Object with multiple Instances (MarkerObject, ViewSubject) // #ifndef IPROPERTYMULTIOBJECT_H #define IPROPERTYMULTIOBJECT_H #include "iproperty.h" template class iPropertyMultiObject : public iPropertyDataVariable { public: typedef typename iType::Traits::Type ArgT; typedef bool (Instance::*SetterType)(ArgT val); typedef ArgT (Instance::*GetterType)() const; iPropertyMultiObject(Object *owner, SetterType setter, GetterType getter, const iString &fname, const iString &sname, int rank = 0); virtual int Size() const; virtual bool IsFixedSize() const { return false; } virtual ArgT GetValue(int i) const; virtual bool SetValue(int i, ArgT v) const; protected: virtual bool Resize(int, bool force = false){ return false; } private: Object *mRealOwner; SetterType mSetter; GetterType mGetter; }; template iPropertyMultiObject::iPropertyMultiObject(Object *owner, SetterType setter, GetterType getter, const iString &fname, const iString &sname, int rank) : iPropertyDataVariable(owner,fname,sname,rank) { this->mRealOwner = owner; this->mSetter = setter; this->mGetter = getter; } template int iPropertyMultiObject::Size() const { return this->mRealOwner->mInstances.Size(); } template typename iPropertyMultiObject::ArgT iPropertyMultiObject::GetValue(int i) const { return (this->mRealOwner->mInstances[i]->*this->mGetter)(); } template bool iPropertyMultiObject::SetValue(int i, ArgT v) const { return (this->mRealOwner->mInstances[i]->*this->mSetter)(v); } #endif // IPROPERTYMULTIOBJECT_H ifrit-4.1.2/core/ipropertymultiobject.tlh0000674060175406010010000002564612641012510017161 0ustar HomeNone//LICENSE A #include "iviewsubject.h" #include "icolorbar.h" #include "idata.h" #include "idatalimits.h" #include "idatareader.h" #include "idatasubject.h" #include "ierror.h" #include "iviewmodule.h" #include "iviewobject.h" #include "iviewsubjectobserver.h" #include "iviewsubjectparallelpipeline.h" #include "iarray.tlh" #include "iproperty.tlh" using namespace iParameter; // // Single instance class // iViewInstance::iViewInstance(iViewSubject *owner) : iDataConsumer(owner->GetViewModule(),owner->GetDataType()), iReplicatedElement(false), mOwner(owner), mIndex(owner->mInstances.Size()) { mIsInitialized = mIsConfigured = mCreatingMainPipeline = false; mShading = owner->IsAlwaysShaded; mAmbient = 0.3; mDiffuse = 0.4; mSpecular = 0.2; mSpecularPower = 0.5; } iViewInstance::~iViewInstance() { this->RemoveColorBars(); while(mPipelines.Size() > 0) mPipelines.RemoveLast()->Delete(); // // Make sure it does not matter in which order we are deleted and removed from the object list of instances // int i, idx; for(i=idx=0; imInstances.Size(); i++) if(mOwner->mInstances[i] != this) { mOwner->mInstances[i]->mIndex = idx++; } } void iViewInstance::Configure() { if(!mIsConfigured) { this->ConfigureBody(); mIsConfigured = true; } else { IBUG_FATAL("ViewInstance has been already configured."); } } iViewSubjectPipeline* iViewInstance::CreateMainPipeline(int numInputs, int id) { iViewSubjectPipeline *p = iViewSubjectParallelPipeline::New(this,numInputs,id); this->ConfigureMainPipeline(p,id); return p; } void iViewInstance::AddMainPipeline(int numInputs) { if(numInputs > 0) { mCreatingMainPipeline = true; iViewSubjectPipeline *p = this->CreateMainPipeline(numInputs,mPipelines.Size()); IERROR_CHECK_MEMORY(p); mCreatingMainPipeline = false; mPipelines.Add(p); } } void iViewInstance::ConfigureMainPipeline(iViewSubjectPipeline *, int) { } void iViewInstance::Reset() { // // Un-initialize, if needed // if(mIsInitialized) { this->RemoveColorBars(); this->ResetBody(); mIsInitialized = false; } } void iViewInstance::Show(bool s) { if(!mIsConfigured) { IBUG_FATAL("ViewInstance has not been configured."); return; } if(s && !mIsInitialized) { this->FinishInitialization(); mIsInitialized = true; } if(mIsInitialized) { this->ShowBody(s && this->CanBeShown()); if(s) { this->UpdateColorBars(); } else { this->RemoveColorBars(); } } } void iViewInstance::AddColorBar(int priority, int var, int palette, const iDataType &type) { if(this->Owner()->IsVisible()) { iColorBarItem bar; bar.Var = var; bar.Palette = palette; bar.DataTypeId = type.GetId(); if(this->GetViewModule()->GetColorBar()->Add(priority,bar)) mColorBars.Add(bar); } } void iViewInstance::RemoveColorBars() { int i; for(i=0; iGetViewModule()->GetColorBar()->Remove(mColorBars[i]); mColorBars.Clear(); } iViewSubjectPipeline* iViewInstance::CreatePipeline(int) { return 0; } void iViewInstance::UpdateReplicasBody() { int i; // // We modify objects inside pipelines, but pipelines themselves would not execute if they remain unmodified. // for(i=0; iUpdateReplicas(); } bool iViewInstance::SetShading(bool s) { if(!mOwner->IsAlwaysShaded) { mShading = s; this->UpdateMaterialProperties(); return true; } else return false; } bool iViewInstance::SetAmbient(float v) { mAmbient = v; this->UpdateMaterialProperties(); return true; } bool iViewInstance::SetDiffuse(float v) { mDiffuse = v; this->UpdateMaterialProperties(); return true; } bool iViewInstance::SetSpecular(float v) { mSpecular = v; this->UpdateMaterialProperties(); return true; } bool iViewInstance::SetSpecularPower(float v) { mSpecularPower = v; this->UpdateMaterialProperties(); return true; } void iViewInstance::UpdateOnMarkerChange() { } // // Main class // iViewSubject::iViewSubject(iObject *parent, const iString &fname, const iString &sname, iViewModule *vm, const iDataType &type, unsigned int flags, int minsize, int maxsize) : iObject(parent,fname,sname,1), iDataConsumer(vm,type), iReplicatedElement(false), IsNonReplicating((flags & ViewObject::Flag::IsNonReplicating) != 0), IsAlwaysVisible((flags & ViewObject::Flag::IsAlwaysVisible) != 0), IsAlwaysShaded((flags & ViewObject::Flag::IsAlwaysShaded) != 0U), HasNoPalette((flags & ViewObject::Flag::HasNoPalette) != 0U), iObjectConstructPropertyMacroGenericVOP(!IsNonReplicating,Int,iViewSubject,ReplicationFactors,rf,6,SetReplicationFactors,GetReplicationFactors), iObjectConstructPropertyMacroGenericSOP(!IsAlwaysVisible,Bool,iViewSubject,Visible,vis,Show,IsVisible), iViewSubjectPropertyConstructMacroOP(!IsAlwaysShaded,Bool,iViewInstance,Shading,mw), iViewSubjectPropertyConstructMacro(Float,iViewInstance,Ambient,ma), iViewSubjectPropertyConstructMacro(Float,iViewInstance,Diffuse,md), iViewSubjectPropertyConstructMacro(Float,iViewInstance,Specular,ms), iViewSubjectPropertyConstructMacro(Float,iViewInstance,SpecularPower,mp), mMinSize(minsize), mMaxSize(maxsize) { mRenderMode = RenderMode::Self; mObjectObserver = iViewSubjectObserver::New(this); IERROR_CHECK_MEMORY(mObjectObserver); Visible.AddFlag(iProperty::_DoNotSaveInState); Visible.AddFlag(iProperty::_DoNotIncludeInCopy); mIsVisible = false; } iViewSubject::~iViewSubject() { mObjectObserver->Delete(); while(mInstances.Size() > 0) { mInstances.RemoveLast()->Delete(); } } void iViewSubject::InitInstances() { iViewInstance *inst = this->MakeInstance(); IERROR_CHECK_MEMORY(inst); inst->Configure(); mInstances.Add(inst); } void iViewSubject::Delete() { while(mDataReplicated.Size() > 0) mDataReplicated[mDataReplicated.MaxIndex()]->ReplicateAs(0); while(mPropReplicated.Size() > 0) mPropReplicated[mPropReplicated.MaxIndex()]->ReplicateAs(0); this->iObject::Delete(); } void iViewSubject::Reset() { this->SyncWithData(this->RequestAll()); int i; for(i=0; iReset(); } bool iViewSubject::Show(bool s) { int i; if(s) { if(!this->IsThereData()) return false; this->SyncWithData(this->RequestAll()); mIsVisible = true; for(i=0; iShow(true); } } else { for(i=0; iShow(false); } mIsVisible = false; } return true; } void iViewSubject::SyncWithDataBody(const iDataSyncRequest &r) { if(this->IsUsingData(r.Data(),true)) { // // If we are visible, but data disappeared, hide us. // if(this->IsVisible()) { if(!this->IsThereData()) this->Show(false); } // // If data is non-periodic, remove replicas (done inside UpdateReplicas()) // if(this->IsReplicated()) { this->UpdateReplicas(true); } } if(this->IsUsingData(r.Data(),false)) { int i; for(i=0; iSyncWithData(r); } } float iViewSubject::GetMemorySize() { int i; float s = this->iDataConsumer::GetMemorySize(); for(i=0; iGetMemorySize(); return s; } void iViewSubject::RemoveInternalData() { int i; // // remove everything, including the pipeline outputs // for(i=0; iRemoveInternalData(); } this->iDataConsumer::RemoveInternalData(); } void iViewSubject::UpdateMaterialProperties() { int i; for(i=0; iUpdateMaterialProperties(); } void iViewSubject::UpdateOnMarkerChange() { int i; for(i=0; iUpdateOnMarkerChange(); } bool iViewSubject::CopyInstances(int iy, int ix) { if(ix>=0 && ix=0 && iyVariables().Size(); i++) { if(this->Variables()[i]->Size() == mInstances.Size()) // only ViewSubject properties { if(!this->Variables()[i]->CopyElement(iy,ix)) { return false; } } } return true; } else return false; } bool iViewSubject::SetReplicationFactors(int d, int n) { if(n>=0 && d>=0 && d<6) { if(n != mReplicationFactors[d]) { mReplicationFactors[d] = n; this->UpdateReplicas(); } return true; } else return false; } void iViewSubject::RegisterReplicatedElement(iReplicatedElement *r, bool isData) { if(r != 0) { if(isData) mDataReplicated.AddUnique(r); else mPropReplicated.AddUnique(r); this->UpdateReplicas(); } } void iViewSubject::UnRegisterReplicatedElement(iReplicatedElement *r) { if(r != 0) { mDataReplicated.Remove(r); mPropReplicated.Remove(r); this->UpdateReplicas(); } } void iViewSubject::UpdateReplicasHead() { int i; if(IsNonReplicating) { for(i=0; i<6; i++) mReplicationFactors[i] = 0; } else { // // If data is non-periodic, remove replicas // for(i=0; i<3; i++) if(!this->GetSubject()->IsDirectionPeriodic(i)) { mReplicationFactors[2*i] = mReplicationFactors[2*i+1] = 0; } } } void iViewSubject::UpdateReplicasBody() { int i; for(i=0; iUpdateReplicas(); for(i=0; iUpdateReplicas(); // // We modify objects inside pipelines, but pipelines themselves would not execute if they remain unmodified. // for(i=0; iUpdateReplicas(false); } void iViewSubject::WriteHead(iString &s) const { s = "Data Type: " + this->GetDataType().LongName() + "/" + this->GetDataType().ShortName() + "\n"; } void iViewSubject::BecomeClone(iViewSubject *) { } int iViewSubject::DepthPeelingRequest() const { if(this->IsVisible()) return this->DepthPeelingRequestBody(); else return 0; } int iViewSubject::DepthPeelingRequestBody() const { return 0; } const iString iViewSubject::GetQualifiedName() const { iViewObject *parent = dynamic_cast(this->Parent()); if(parent == 0) { return this->iObject::GetFullName(); } else { return parent->GetFullName() + "[" + this->GetDataType().LongName() + "]"; } } bool iViewSubject::CreateInstance() { if(mInstances.Size() < mMaxSize) { // // Create a new piece // iViewInstance *ins = this->MakeInstance(); if(ins == 0) { return false; } ins->Configure(); int oldLast = mInstances.MaxIndex(); mInstances.Add(ins); // // Set the correct piece number // this->CopyInstances(mInstances.MaxIndex(),oldLast); ins->SyncWithData(this->RequestAll()); ins->Show(this->IsVisible()); return true; } else return false; } bool iViewSubject::RemoveInstance(int n) { if(mMinSize=0 && nDelete(); mInstances.Remove(n); return true; } else return false; } bool iViewSubject::SetNumberOfInstances(int n) { if(mMinSize<=n && n<=mMaxSize) { while(mInstances.Size() > n) { if(!this->RemoveInstance(mInstances.MaxIndex())) return false; } while(mInstances.Size() < n) { if(!this->CreateInstance()) return false; } return true; } else return false; } ifrit-4.1.2/core/ipropertyposition.cpp0000674060175406010010000000562512641012563016502 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ipropertyposition.h" #include "ierror.h" #include "iobject.h" #include "iposition.h" // // Templates // #include "iarray.tlh" #include "iproperty.tlh" iPropertyScalarPosition::iPropertyScalarPosition(iObject *owner, iViewModule *vm, SetterType setter, GetterType getter, const iString &name, const iString &sname) : iPropertyScalar(owner,(iPropertyScalar::SetterType)setter,(iPropertyScalar::GetterType)getter,name,sname), iViewModuleComponent(vm) { mSetter = setter; IASSERT(setter); mGetter = getter; IASSERT(getter); } const iVector3D& iPropertyScalarPosition::GetValue(int i) const { return (this->Owner()->*mGetter)().BoxValue(); } bool iPropertyScalarPosition::SetValue(int i, const iVector3D& v) const { iPosition pos(this->GetViewModule()); pos.SetBoxValue(v); if((this->Owner()->*mSetter)(pos)) { this->RequestRender(); return true; } else return false; } iPropertyScalarDistance::iPropertyScalarDistance(iObject *owner, iViewModule *vm, SetterType setter, GetterType getter, const iString &name, const iString &sname) : iPropertyScalar(owner,(iPropertyScalar::SetterType)setter,(iPropertyScalar::GetterType)getter,name,sname), iViewModuleComponent(vm) { mSetter = setter; IASSERT(setter); mGetter = getter; IASSERT(getter); } double iPropertyScalarDistance::GetValue(int i) const { return (this->Owner()->*mGetter)().BoxValue(); } bool iPropertyScalarDistance::SetValue(int i, double v) const { iDistance d(this->GetViewModule()); d.SetBoxValue(v); if((this->Owner()->*mSetter)(d)) { this->RequestRender(); return true; } else return false; } ifrit-4.1.2/core/ipropertyposition.h0000674060175406010010000000510312641012533016133 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Position-values property // #ifndef IPROPERTYPOSITION_H #define IPROPERTYPOSITION_H #include "iproperty.h" #include "iviewmodulecomponent.h" class iDistance; class iPosition; // // Index that automatically shifts by 1 for script indexing // class iPropertyScalarPosition : public iPropertyScalar, public iViewModuleComponent { public: typedef bool (iObject::*SetterType)(const iPosition& val); typedef const iPosition& (iObject::*GetterType)() const; iPropertyScalarPosition(iObject *owner, iViewModule *vm, SetterType setter, GetterType getter, const iString &name, const iString &sname); protected: virtual const iVector3D& GetValue(int i) const; virtual bool SetValue(int i, const iVector3D& v) const; private: SetterType mSetter; GetterType mGetter; }; class iPropertyScalarDistance : public iPropertyScalar, public iViewModuleComponent { public: typedef bool (iObject::*SetterType)(const iDistance& val); typedef const iDistance& (iObject::*GetterType)() const; iPropertyScalarDistance(iObject *owner, iViewModule *vm, SetterType setter, GetterType getter, const iString &name, const iString &sname); protected: virtual double GetValue(int i) const; virtual bool SetValue(int i, double v) const; private: SetterType mSetter; GetterType mGetter; }; #endif // IPROPERTYPOSITION_H ifrit-4.1.2/core/ireducepolydatafilter.cpp0000674060175406010010000000450112641012563017234 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ireducepolydatafilter.h" #include "ierror.h" #include #include // // Templates // #include "igenericfilter.tlh" iReducePolyDataFilter::iReducePolyDataFilter(iDataConsumer *consumer) : iGenericPolyDataFilter(consumer,1,true) { mTriangulator = vtkTriangleFilter::New(); IERROR_CHECK_MEMORY(mTriangulator); mDecimator = vtkDecimatePro::New(); IERROR_CHECK_MEMORY(mDecimator); mDecimator->PreserveTopologyOn(); mDecimator->BoundaryVertexDeletionOff(); mDecimator->SetInputConnection(mTriangulator->GetOutputPort()); } void iReducePolyDataFilter::SetTargetReduction(double v) { mDecimator->SetTargetReduction(v); this->Modified(); } double iReducePolyDataFilter::GetTargetReduction() { return mDecimator->GetTargetReduction(); } iReducePolyDataFilter::~iReducePolyDataFilter() { mDecimator->Delete(); mTriangulator->Delete(); } void iReducePolyDataFilter::ProvideOutput() { mTriangulator->SetInputData(this->InputData()); mDecimator->Update(); this->OutputData()->ShallowCopy(mDecimator->GetOutput()); } ifrit-4.1.2/core/ireducepolydatafilter.h0000674060175406010010000000350712641012533016703 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IREDUCEPOLYDATAFILTER_H #define IREDUCEPOLYDATAFILTER_H #include "igenericfilter.h" #include class vtkDecimatePro; class vtkTriangleFilter; class iReducePolyDataFilter : public iGenericPolyDataFilter { iGenericFilterTypeMacro(iReducePolyDataFilter,vtkPolyDataAlgorithm); public: virtual ~iReducePolyDataFilter(); void SetTargetReduction(double v); double GetTargetReduction(); protected: virtual void ProvideOutput(); vtkDecimatePro *mDecimator; vtkTriangleFilter *mTriangulator; }; #endif // IREDUCEPOLYDATAFILTER_H ifrit-4.1.2/core/ireducepolydatafilter2.cpp0000674060175406010010000000333212641012563017317 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ireducepolydatafilter2.h" #include "vtkCellArray.h" #include "vtkEdgeTable.h" #include "vtkDoubleArray.h" #include "vtkIdList.h" #include "vtkMath.h" #include "vtkPointData.h" #include "vtkPriorityQueue.h" // // Templates // #include "igenericfilter.tlh" iReducePolyDataFilter2::iReducePolyDataFilter2(iDataConsumer *consumer) : iGenericPolyDataFilter(consumer,1,true) { } void iReducePolyDataFilter2::ProvideOutput() { this->ExecuteParent(); } ifrit-4.1.2/core/ireducepolydatafilter2.h0000674060175406010010000000315312641012533016762 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IREDUCEPOLYDATAFILTER2_H #define IREDUCEPOLYDATAFILTER2_H #include "igenericfilter.h" #include class iReducePolyDataFilter2 : public iGenericPolyDataFilter { iGenericFilterTypeMacro(iReducePolyDataFilter2,vtkQuadricDecimation); protected: virtual void ProvideOutput(); }; #endif // IREDUCEPOLYDATAFILTER2_H ifrit-4.1.2/core/irendertool.cpp0000674060175406010010000006237312641012563015211 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "irendertool.h" #include "iactor.h" #include "icamera.h" #include "ierror.h" #include "ieventobserver.h" #include "imagnifier.h" #include "irendertoolbackground.h" #include "ishell.h" #include "istereoimage.h" #include "istereoimagearray.h" #include "iviewmodule.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // // Templates // #include "iarray.tlh" using namespace iParameter; // // Helper classes // class iMainWindowObserver : public iEventObserver { public: vtkTypeMacro(iMainWindowObserver,iEventObserver); static iMainWindowObserver* New(iRenderTool *rt = 0) { IASSERT(rt); return new iMainWindowObserver(rt); } protected: iMainWindowObserver(iRenderTool *rt) : iEventObserver() { mRenderTool = rt; } virtual void ExecuteBody(vtkObject *, unsigned long event, void *) { switch(event) { case ModifiedEvent: { mRenderTool->mRenderWindowSize = mRenderTool->mMainWin->GetSize(); mRenderTool->mRenderWindowPosition = mRenderTool->mMainWin->GetPosition(); break; } } } private: iRenderTool *mRenderTool; }; class iDualWindowObserver : public iEventObserver { public: vtkTypeMacro(iDualWindowObserver,iEventObserver); static iDualWindowObserver* New(iRenderTool *rt = 0) { IASSERT(rt); return new iDualWindowObserver(rt); } protected: iDualWindowObserver(iRenderTool *rt) : iEventObserver() { mRenderTool = rt; } virtual void ExecuteBody(vtkObject *, unsigned long event, void *) { switch(event) { case EndEvent: { if(mRenderTool->mDualWin != 0) mRenderTool->mDualWin->Render(); break; } case ModifiedEvent: { if(mRenderTool->mDualWin != 0) mRenderTool->mDualWin->SetSize(mRenderTool->mMainWin->GetSize()); break; } } } private: iRenderTool *mRenderTool; }; class iRendererObserver : public iEventObserver { public: vtkTypeMacro(iRendererObserver,iEventObserver); static iRendererObserver* New(iRenderTool *rt = 0) { IASSERT(rt); return new iRendererObserver(rt); } protected: iRendererObserver(iRenderTool *rt) : iEventObserver() { mRenderTool = rt; } virtual void ExecuteBody(vtkObject *, unsigned long event, void *) { switch(event) { case ModifiedEvent: { break; } case ResetCameraClippingRangeEvent: { double *cr = mRenderTool->mMainRen->GetActiveCamera()->GetClippingRange(); if(mRenderTool->mAutoClippingRange) { mRenderTool->mClippingRange[0] = cr[0]; mRenderTool->mClippingRange[1] = cr[1]; } else { cr[0] = mRenderTool->mClippingRange[0]; cr[1] = mRenderTool->mClippingRange[1]; } break; } } } private: iRenderTool *mRenderTool; }; class iStereoRenderObserver : public iEventObserver { public: vtkTypeMacro(iStereoRenderObserver,iEventObserver); static iStereoRenderObserver* New(iRenderTool *rt = 0) { IASSERT(rt); return new iStereoRenderObserver(rt); } protected: iStereoRenderObserver(iRenderTool *rt) : iEventObserver() { mRenderTool = rt; } virtual void ExecuteBody(vtkObject *, unsigned long event, void *) { switch(event) { case ModifiedEvent: { if(mRenderTool->mMainWinStereoRender != (mRenderTool->mMainWin->GetStereoRender()!=0)) { mRenderTool->mMainWin->SetStereoRender(mRenderTool->mMainWinStereoRender?1:0); } break; } } } private: iRenderTool *mRenderTool; }; // // Main class // iRenderTool::iRenderTool(iViewModule *vm, vtkRenderer *ren, iMagnifier *mag) : iViewModuleComponent(vm), mStereoModeOffset(2-VTK_STEREO_CRYSTAL_EYES) { // // Keeping the rendering order (a workaround for a VTK bug) // mActorObjects = vtkPropCollection::New(); IERROR_CHECK_MEMORY(mActorObjects); mVolumeObjects = vtkPropCollection::New(); IERROR_CHECK_MEMORY(mVolumeObjects); // // Main Window stuff // mDualWin = 0; #ifdef I_NO_STEREO bool stereo = false; #else bool stereo = true; #endif mMainWin = this->GetViewModule()->GetShell()->CreateRenderWindow(this->GetViewModule(),stereo); IERROR_CHECK_MEMORY(mMainWin); mMainWin->SetAlphaBitPlanes(1); mMainWin->SetMultiSamples(0); mDepthPeelingStyle = DepthPeeling::Low; if(ren == 0) { mMainRen = vtkRenderer::New(); IERROR_CHECK_MEMORY(mMainRen); mMainCam = iCamera::New(this); IERROR_CHECK_MEMORY(mMainCam); mMainRen->SetActiveCamera(mMainCam->GetDevice()); // // Configure Renderer. It is important to switch the backing store off for the // stereo mode to work properly. // mMainRen->SetLayer(IRENDERTOOLBACKGROUND_FRONT_LAYER); mMainRen->BackingStoreOff(); mMainRen->TwoSidedLightingOff(); mMainRen->LightFollowCameraOn(); mMainRen->GetActiveCamera()->SetEyeAngle(2.0); this->ConfigureDepthPeeling(mMainRen); // // Configure Interactor (can be null) // mMainInt = this->GetViewModule()->GetShell()->CreateRenderWindowInteractor(this->GetViewModule()); if(mMainInt != 0) { mMainInt->SetRenderWindow(mMainWin); mMainInt->LightFollowCameraOff(); } // // Image magnifier // mMagnifier = iMagnifier::New(); IERROR_CHECK_MEMORY(mMagnifier); } else { mMainRen = ren; mMainInt = 0; mMainCam = 0; mMagnifier = mag; IASSERT(mag); mMagnifier->Register(ren); } // // Create backgrounds // mMainBkg = iRenderToolBackground::New(); IERROR_CHECK_MEMORY(mMainBkg); mDualBkg = iRenderToolBackground::New(); IERROR_CHECK_MEMORY(mDualBkg); // // Configure Window // mMainWin->SetSize(640,480); mMainWin->SetNumberOfLayers(2); mMainWin->AddRenderer(mMainRen); mMainWin->AddRenderer(mMainBkg->GetRenderer()); mMainWin->SetWindowName("IFrIT - Visualization Window"); // // Dual window renderer and observer // mDualRen = this->CreateRenderer(); mDualRen->SetActiveCamera(mMainRen->GetActiveCamera()); mDualRen->LightFollowCameraOff(); // // Window observers // mMainWindowObserver = iMainWindowObserver::New(this); IERROR_CHECK_MEMORY(mMainWindowObserver); mDualWindowObserver = iDualWindowObserver::New(this); IERROR_CHECK_MEMORY(mDualWindowObserver); mMainWin->AddObserver(vtkCommand::ModifiedEvent,mMainWindowObserver); // // Dual window alignment markers (only needed for the primary window) // if(ren == 0) { mStereoAlignmentMarksActor = vtkPropAssembly::New(); IERROR_CHECK_MEMORY(mStereoAlignmentMarksActor); mStereoAlignmentMarksActor->VisibilityOff(); mStereoAlignmentMarksActor->PickableOff(); vtkPolyDataMapper2D *mapper2D = vtkPolyDataMapper2D::New(); IERROR_CHECK_MEMORY(mapper2D); vtkLineSource *ls; vtkActor2D *actor2D[8]; float aml = 0.15; float amo = 0.1; int i; for(i=0; i<8; i++) { actor2D[i] = vtkActor2D::New(); IERROR_CHECK_MEMORY(actor2D[i]); mapper2D = vtkPolyDataMapper2D::New(); IERROR_CHECK_MEMORY(mapper2D); ls = vtkLineSource::New(); IERROR_CHECK_MEMORY(ls); ls->SetResolution(1); if(i%2 == 0) { ls->SetPoint1(-aml,0.0,0.0); ls->SetPoint2(aml,0.0,0.0); } else { ls->SetPoint1(0.0,-aml,0.0); ls->SetPoint2(0.0,aml,0.0); } ls->Update(); mapper2D->SetInputConnection(ls->GetOutputPort()); ls->Delete(); vtkCoordinate *c = vtkCoordinate::New(); IERROR_CHECK_MEMORY(c); c->SetCoordinateSystemToView(); mapper2D->SetTransformCoordinate(c); c->Delete(); actor2D[i]->SetMapper(mapper2D); mapper2D->Delete(); actor2D[i]->GetProperty()->SetColor(0.0,0.0,0.0); actor2D[i]->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); actor2D[i]->PickableOff(); actor2D[i]->SetPosition((0.5-amo)*(2*((i/2)%2)-1),(0.5-amo)*(2*((i/4)%2)-1)); actor2D[i]->SetLayerNumber(1); mStereoAlignmentMarksActor->AddPart(actor2D[i]); actor2D[i]->Delete(); } this->AddObject(mStereoAlignmentMarksActor); mStereoAlignmentMarksActor->Delete(); } else { mStereoAlignmentMarksActor = 0; } // // Clipping range controls // mRendererObserver = iRendererObserver::New(this); IERROR_CHECK_MEMORY(mRendererObserver); mAutoClippingRange = true; mMainRen->AddObserver(vtkCommand::ResetCameraClippingRangeEvent,mRendererObserver); mMainRen->AddObserver(vtkCommand::ModifiedEvent,mRendererObserver); // // Disable pressing 3 in the render window // mStereoRenderObserver = iStereoRenderObserver::New(this); IERROR_CHECK_MEMORY(mStereoRenderObserver); mMainWin->AddObserver(vtkCommand::ModifiedEvent,mStereoRenderObserver); // // RenderWindow collection // mWindowCollection = vtkRenderWindowCollection::New(); IERROR_CHECK_MEMORY(mWindowCollection); mWindowCollectionUpToDate = false; // // Properties // mStereoMode = 0; this->SetMainWinStereoRender(false); mMainWin->SetStereoType(0); // for pressing 3 in the render window this->SetAntialiasingMode(0*Antialiasing::Points+1*Antialiasing::Lines+1*Antialiasing::Polys); this->SetDepthPeelingStyle(DepthPeeling::Low); mStereoAlignmentMarksOn = true; // // Set the properties // mFontScale = 0; mFontType = TextType::Arial; } iRenderTool::~iRenderTool() { this->ShowDualWindow(false); mActorObjects->Delete(); mVolumeObjects->Delete(); mWindowCollection->RemoveAllItems(); mWindowCollection->Delete(); mDualWindowObserver->Delete(); mMainWindowObserver->Delete(); mMagnifier->Delete(); mMainRen->RemoveObserver(mStereoRenderObserver); mStereoRenderObserver->Delete(); mMainRen->RemoveObserver(mRendererObserver); mRendererObserver->Delete(); if(mMainInt != 0) mMainInt->Delete(); if(mMainCam != 0) mMainCam->Delete(); mMainRen->SetRenderWindow(0); mMainWin->RemoveRenderer(mMainBkg->GetRenderer()); mMainWin->RemoveRenderer(mMainRen); mMainBkg->Delete(); mDualBkg->Delete(); mMainWin->RemoveAllObservers(); mDualRen->Delete(); mMainRen->Delete(); mMainWin->Finalize(); mMainWin->Delete(); } int iRenderTool::GetRenderingMagnification() const { return mMagnifier->GetMagnification(); } int iRenderTool::GetNumberOfActiveViews() const { return (mDualWin == 0) ? 1 : 2; } void iRenderTool::Render() { mMainWin->InvokeEvent(vtkCommand::StartEvent,NULL); this->ResetCameraClippingRange(); mMainWin->Render(); mMainWin->InvokeEvent(vtkCommand::EndEvent,NULL); } void iRenderTool::ResetCamera() { const double scale = 1.6/sqrt(3.0); int i; double bounds[6], fp[3]; mMainRen->ComputeVisiblePropBounds(bounds); mMainRen->GetActiveCamera()->GetFocalPoint(fp); for(i=0; i<3; i++) { if(fabs(bounds[2*i+0]-fp[i]) > fabs(bounds[2*i+1]-fp[i])) { bounds[2*i+1] = 2*fp[i] - bounds[2*i+0]; } else { bounds[2*i+0] = 2*fp[i] - bounds[2*i+1]; } } mMainRen->ResetCamera(bounds); // // IFrIT-style reset // mMainCam->GetDevice()->SetParallelScale(scale*mMainCam->GetDevice()->GetParallelScale()); mMainCam->GetDevice()->Dolly(1.0/scale); mMainRen->ResetCameraClippingRange(); } void iRenderTool::AddObserver(unsigned long event, iEventObserver *command) { Observer tmp; tmp.Event = event; tmp.Command = command; mObservers.Add(tmp); mMainWin->AddObserver(event,command); if(mDualWin != 0) mDualWin->AddObserver(event,command); } void iRenderTool::UpdateWindowName() { static const iString null; this->UpdateWindowName(null); } void iRenderTool::UpdateWindowName(const iString& suffix) { static iString WindowName("IFrIT - Visualization Window"); iString base(WindowName); if(this->GetShell()->GetNumberOfViewModules() > 1) base += " #" + iString::FromNumber(this->GetViewModule()->GetWindowNumber()+1); if(!suffix.IsEmpty()) base += ": " + suffix; if(mDualWin == 0) { mMainWin->SetWindowName(base.ToCharPointer()); } else { mMainWin->SetWindowName((base+": Left Eye").ToCharPointer()); mDualWin->SetWindowName((base+": Right Eye").ToCharPointer()); } } vtkRenderWindowCollection* iRenderTool::GetRenderWindowCollection() { if(!mWindowCollectionUpToDate) { this->UpdateWindowCollection(); mWindowCollectionUpToDate = true; } return mWindowCollection; } void iRenderTool::UpdateWindowCollection() { mWindowCollection->RemoveAllItems(); mWindowCollection->AddItem(mMainWin); if(mDualWin != 0) mWindowCollection->AddItem(mDualWin); } void iRenderTool::WindowsModified() { mWindowCollectionUpToDate = false; } void iRenderTool::ResetCameraClippingRange() { if(mAutoClippingRange) mMainRen->ResetCameraClippingRange(); } void iRenderTool::SetBackground(const iColor &color) { mMainRen->SetBackground(color.ToVTK()); mDualRen->SetBackground(color.ToVTK()); mMainBkg->SetColor(color); mDualBkg->SetColor(color); } void iRenderTool::SetBackground(const iImage &image) { mMainBkg->SetImage(image); mDualBkg->SetImage(image); } void iRenderTool::AddObject(vtkProp* p) { if(p == 0) return; if(p->IsA("vtkVolume") != 0) { mVolumeObjects->AddItem(p); mMainRen->AddViewProp(p); mDualRen->AddViewProp(p); } else { // // Make sure all actors are ahead of volumes (is it a VTK bug?) // if(mActorObjects->GetNumberOfItems() == 0) { mMainRen->AddViewProp(p); mDualRen->AddViewProp(p); } else { mMainRen->GetViewProps()->InsertItem(mActorObjects->GetNumberOfItems()-1,p); mDualRen->GetViewProps()->InsertItem(mActorObjects->GetNumberOfItems()-1,p); } mActorObjects->AddItem(p); } } void iRenderTool::RemoveObject(vtkProp* p) { if(p == 0) return; if(p->IsA("vtkVolume") != 0) { mVolumeObjects->RemoveItem(p); } else { mActorObjects->RemoveItem(p); } mMainRen->RemoveViewProp(p); mDualRen->RemoveViewProp(p); } void iRenderTool::SetRenderWindowSize(int w, int h) { if(w>0 && h>0) { mMainWin->SetSize(w,h); if(mDualWin != 0) mDualWin->SetSize(w,h); mRenderWindowSize = mMainWin->GetSize(); } } void iRenderTool::SetRenderWindowPosition(int x, int y) { mMainWin->SetPosition(x,y); mRenderWindowPosition = mMainWin->GetPosition(); } void iRenderTool::Reset() { #ifndef I_OFFSCREEN vtkOpenGLRenderWindow *w = vtkOpenGLRenderWindow::SafeDownCast(mMainWin); if(w!=0 && w->GetNeverRendered()==0) { w->MakeCurrent(); w->OpenGLInit(); } if(mDualWin != 0) { w = vtkOpenGLRenderWindow::SafeDownCast(mDualWin); if(w!=0 && w->GetNeverRendered()==0) { w->MakeCurrent(); w->OpenGLInit(); } } #endif } void iRenderTool::SetAntialiasingMode(int m) { bool s; mAntialiasingMode = m; s = (m & Antialiasing::Points) > 0; mMainWin->SetPointSmoothing(s?1:0); if(mDualWin != 0) { mDualWin->SetPointSmoothing(s?1:0); } s = (m & Antialiasing::Lines) > 0; mMainWin->SetLineSmoothing(s?1:0); if(mDualWin != 0) { mDualWin->SetLineSmoothing(s?1:0); } s = (m & Antialiasing::Polys) > 0; mMainWin->SetPolygonSmoothing(s?1:0); if(mDualWin != 0) { mDualWin->SetPolygonSmoothing(s?1:0); } this->Reset(); } void iRenderTool::SetDepthPeelingStyle(int s) { mDepthPeelingStyle = s; this->ConfigureDepthPeeling(mMainRen); this->ConfigureDepthPeeling(mDualRen); this->Reset(); } void iRenderTool::ConfigureDepthPeeling(vtkRenderer *ren) const { if(ren == 0) return; ren->SetUseDepthPeeling((mDepthPeelingStyle != DepthPeeling::Off)?1:0); switch(mDepthPeelingStyle) { case DepthPeeling::Off: { // // Already set // break; } case DepthPeeling::Low: { ren->SetOcclusionRatio(0.1); ren->SetMaximumNumberOfPeels(3); break; } case DepthPeeling::High: { ren->SetOcclusionRatio(0.03); ren->SetMaximumNumberOfPeels(10); break; } case DepthPeeling::Exact: { ren->SetOcclusionRatio(0.0); ren->SetMaximumNumberOfPeels(0); break; } default: { IBUG_ERROR("Invalid DepthPeelingStyle."); } } } void iRenderTool::SetAdjustCameraClippingRangeAutomatically(bool s) { mAutoClippingRange = s; } void iRenderTool::SetBackgroundImageFixedAspect(bool s) { if(mBackgroundImageFixedAspect != s) { mBackgroundImageFixedAspect = s; mMainBkg->SetImageFixedAspect(s); mDualBkg->SetImageFixedAspect(s); } } void iRenderTool::SetBackgroundImageTile(float tx, float ty, float tw, float th) { float tile[4]; tile[0] = tx; tile[1] = ty; tile[2] = tw; tile[3] = th; this->SetBackgroundImageTile(tile); } void iRenderTool::SetBackgroundImageTile(const float tile[4]) { mMainBkg->SetImageTile(tile); mDualBkg->SetImageTile(tile); } void iRenderTool::SetCameraClippingRange(double cr[2]) { // // This is a dirty trick to avoid the minimum bound on the nearest clipping range of 0.0001 // if(!mAutoClippingRange) { double *d = mMainRen->GetActiveCamera()->GetClippingRange(); mClippingRange[0] = d[0] = cr[0]; mClippingRange[1] = d[1] = cr[1]; } } void iRenderTool::RenderImages(int mag, iStereoImageArray &images) { iStereoImage tmp; images.Clear(); this->RenderStereoImage(mag,tmp); images.Add(tmp); } void iRenderTool::RenderStereoImage(int mag, iStereoImage &image) { int v = 0; mDualWindowObserver->Block(true); if(mStereoAlignmentMarksActor != 0) { v = mStereoAlignmentMarksActor->GetVisibility(); mStereoAlignmentMarksActor->VisibilityOff(); } mMagnifier->SetMagnification(mag); // // Render main window // int lfc = mMainRen->GetLightFollowCamera(); mMainRen->SetLightFollowCamera(0); // Maintain correct lighting under magnification mMagnifier->SetInput(mMainRen); mMagnifier->Modified(); mMagnifier->UpdateWholeExtent(); image.ReplaceData(0,mMagnifier->GetOutput()); mMainRen->SetLightFollowCamera(lfc); // // Render dual window // if(mDualWin != 0) { mMagnifier->SetInput(mDualRen); mMagnifier->Modified(); mMagnifier->UpdateWholeExtent(); mMagnifier->Update(); image.ReplaceData(1,mMagnifier->GetOutput()); } mMagnifier->SetMagnification(1); if(mStereoAlignmentMarksActor != 0) { mStereoAlignmentMarksActor->SetVisibility(v); } mDualWindowObserver->Block(false); } float iRenderTool::GetLastRenderTimeInSeconds() const { float s = mMainRen->GetLastRenderTimeInSeconds(); if(mDualWin != 0) s += mDualRen->GetLastRenderTimeInSeconds(); return s; } void iRenderTool::GetAspectRatio(double ar[2]) const { mMainRen->GetAspect(ar); } // // Stereo operations // void iRenderTool::ShowStereoAlignmentMarks(bool s) { mStereoAlignmentMarksOn = s; mStereoAlignmentMarksActor->SetVisibility((s && mDualWin!=0)?1:0); } void iRenderTool::SetStereoMode(int m) { if(m==mStereoMode || m<0) return; if(mStereoMode == 1) this->ShowDualWindow(false); if(mStereoMode == 2) { // // This seems extraneous, but that trick was needed to avoid flicker // that Doug was complaining about. It was debugged on Robert's laptop. // this->SetMainWinStereoRender(false); mMainWin->Render(); } mStereoMode = m; // // Don't get stuck in a right-eye-only mode, it is not renderable in the non-stereo mode // mMainWin->SetStereoType(0); switch(mStereoMode) { case 0: { this->SetMainWinStereoRender(false); break; } case 1: { this->ShowDualWindow(true); break; } case 2: { if(mMainWin->GetStereoCapableWindow() == 0) { this->SetStereoMode(0); this->OutputText(MessageType::Error,"Crystal Eyes mode is not supported on this machine."); } else { mMainWin->SetStereoType(VTK_STEREO_CRYSTAL_EYES); this->SetMainWinStereoRender(true); } break; } default: { mMainWin->SetStereoType(mStereoMode-mStereoModeOffset); mStereoMode = mMainWin->GetStereoType() + mStereoModeOffset; this->SetMainWinStereoRender(true); break; } } } void iRenderTool::ShowDualWindow(bool s) { if(s) { if(mDualWin == 0) // DualWindow is not shown yet { mDualWin = this->GetViewModule()->GetShell()->CreateRenderWindow(this->GetViewModule(),false); IERROR_CHECK_MEMORY(mDualWin); mDualWin->SetAlphaBitPlanes(1); mDualWin->SetMultiSamples(0); mDualWin->SetStereoTypeToRight(); mDualWin->StereoRenderOn(); int *s = mMainWin->GetSize(); mDualWin->SetSize(s[0],s[1]); this->WindowsModified(); int i; for(i=0; iAddObserver(mObservers[i].Event,mObservers[i].Command); } // // Copy RenderWindows // mDualWin->SetLineSmoothing(mMainWin->GetLineSmoothing()); mDualWin->SetPointSmoothing(mMainWin->GetPointSmoothing()); mDualWin->SetPolygonSmoothing(mMainWin->GetPolygonSmoothing()); mDualWin->SetNumberOfLayers(2); mDualWin->AddRenderer(mDualRen); mDualWin->AddRenderer(mDualBkg->GetRenderer()); mMainWin->SetStereoTypeToLeft(); this->SetMainWinStereoRender(true); mMainWin->AddObserver(vtkCommand::StartEvent,mDualWindowObserver); mMainWin->AddObserver(vtkCommand::EndEvent,mDualWindowObserver); mMainWin->AddObserver(vtkCommand::ModifiedEvent,mDualWindowObserver); if(mStereoAlignmentMarksActor!=0 && mStereoAlignmentMarksOn) mStereoAlignmentMarksActor->VisibilityOn(); this->UpdateWindowName(); } } else { if(mDualWin != 0) { this->WindowsModified(); mDualRen->SetRenderWindow(0); mDualBkg->GetRenderer()->SetRenderWindow(0); mDualWin->RemoveRenderer(mDualRen); mDualWin->RemoveRenderer(mDualBkg->GetRenderer()); mDualWin->Finalize(); mDualWin->Delete(); mDualWin = 0; this->SetMainWinStereoRender(false); mMainWin->RemoveObserver(mDualWindowObserver); if(mStereoAlignmentMarksActor != 0) mStereoAlignmentMarksActor->VisibilityOff(); this->UpdateWindowName(); } } } iRenderTool* iRenderTool::CreateInstance(vtkRenderer *ren) const { return new iRenderTool(this->GetViewModule(),ren,mMagnifier); } vtkRenderer* iRenderTool::CreateRenderer() const { vtkRenderer *ren = vtkRenderer::New(); if(ren == 0) return 0; ren->SetLayer(IRENDERTOOLBACKGROUND_FRONT_LAYER); // // Copy the state of the primary renderer // ren->SetBackingStore(mMainRen->GetBackingStore()); ren->SetTwoSidedLighting(mMainRen->GetTwoSidedLighting()); ren->SetBackground(mMainRen->GetBackground()); ren->LightFollowCameraOff(); // only the primary renderer can control lights this->ConfigureDepthPeeling(ren); // // Copy props. The trick is that we need to register the new renderer with every iActor // so that iActors can create special mappers for this renderer. Otherwise, vtkPolyDataMappers // remember the last window they rendered into, and will reset at switching to a different window. // vtkPropCollection *pc = mMainRen->GetViewProps(); vtkProp *p; pc->InitTraversal(); while((p = pc->GetNextProp()) != 0) { ren->AddViewProp(p); } // // Copy lights // vtkLight *l; vtkLightCollection *lc = mMainRen->GetLights(); lc->InitTraversal(); while((l = lc->GetNextItem()) != 0) ren->AddLight(l); // // Copy cullers // vtkCuller *c; vtkCullerCollection *cc = mMainRen->GetCullers(); cc->InitTraversal(); ren->GetCullers()->RemoveAllItems(); while((c = cc->GetNextItem()) != 0) ren->AddCuller(c); return ren; } int iRenderTool::GetFullScreenMode() const { return 1; } void iRenderTool::CopyBackground(const iRenderTool *source) { if(source != 0) { mMainBkg->Copy(source->mMainBkg); mDualBkg->Copy(source->mDualBkg); } } void iRenderTool::SetFontScale(int s) { if(s>-10 && s<10) { mFontScale = s; } } void iRenderTool::SetFontType(int s) { if(TextType::IsValid(s)) { mFontType = s; } } void iRenderTool::SetMainWinStereoRender(bool s) { mMainWinStereoRender = s; mMainWin->SetStereoRender(s?1:0); } #include #include #include void iRenderTool::ExportScene(const iString &fname) { vtkExporter *ex = 0; iString type = fname.Section(".",-1); if(type == "obj") { vtkOBJExporter *w = vtkOBJExporter::New(); IERROR_CHECK_MEMORY(w); w->SetFilePrefix(fname.Section(".",0,-2).ToCharPointer()); ex = w; } else if(type == "x3d") { vtkX3DExporter *w = vtkX3DExporter ::New(); IERROR_CHECK_MEMORY(w); w->SetBinary(0); w->SetFileName(fname.ToCharPointer()); ex = w; } else if(type == "vrml") { vtkVRMLExporter *w = vtkVRMLExporter ::New(); IERROR_CHECK_MEMORY(w); w->SetFileName(fname.ToCharPointer()); ex = w; } if(ex != 0) { ex->SetRenderWindow(mMainWin); mMainWin->RemoveRenderer(mMainBkg->GetRenderer()); ex->Write(); mMainWin->AddRenderer(mMainBkg->GetRenderer()); } } ifrit-4.1.2/core/irendertool.h0000674060175406010010000001565312641012533014652 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // iRenderTool is a combination of a RenderWindow and a Renderer. // In dual-window stereo mode it pops up a separate view for the right eye. // #ifndef IRENDERTOOL_H #define IRENDERTOOL_H #include #include "iviewmodulecomponent.h" #include "iarray.h" #include class iActor; class iCamera; class iColor; class iEventObserver; class iImage; class iMagnifier; class iRenderToolBackground; class iString; class iStereoImage; class iStereoImageArray; class vtkProp; class vtkPropAssembly; class vtkPropCollection; class vtkRenderer; class vtkRenderWindow; class vtkRenderWindowCollection; class vtkRenderWindowInteractor; namespace iParameter { namespace TextType { const int Arial = 0; const int Courier = 1; const int Times = 2; inline bool IsValid(int m){ return m>=0 && m<=2; } }; namespace Antialiasing { const int Points = 1; const int Lines = 2; const int Polys = 4; }; namespace DepthPeeling { const int Off = 0; const int Low = 1; const int High = 2; const int Exact = 3; }; }; class iRenderTool : public vtkObjectBase, public iViewModuleComponent { friend class iCamera; friend class iDualWindowObserver; friend class iExtensionFactory; friend class iMainWindowObserver; friend class iRendererObserver; friend class iStereoRenderObserver; public: vtkTypeMacro(iRenderTool,vtkObjectBase); static iRenderTool* New(iViewModule *vm = 0); virtual int GetNumberOfActiveViews() const; void SetRenderWindowPosition(int x, int y); void SetRenderWindowPosition(const int *p){ this->SetRenderWindowPosition(p[0],p[1]); } inline const int* GetRenderWindowPosition() const { return mRenderWindowPosition; } virtual void SetRenderWindowSize(int w, int h); void SetRenderWindowSize(const int *s){ this->SetRenderWindowSize(s[0],s[1]); } inline const int* GetRenderWindowSize() const { return mRenderWindowSize; } inline iMagnifier* GetMagnifier() const { return mMagnifier; } inline vtkRenderer* GetRenderer() const { return mMainRen; } inline vtkRenderWindow* GetRenderWindow() const { return mMainWin; } inline vtkRenderWindowInteractor* GetRenderWindowInteractor() const { return mMainInt; } vtkRenderWindowCollection* GetRenderWindowCollection(); inline iCamera* GetCamera() const { return mMainCam; } int GetRenderingMagnification() const; void Render(); virtual void AddObserver(unsigned long event, iEventObserver *observer); virtual void UpdateWindowName(); virtual void UpdateWindowName(const iString& suffix); virtual void SetBackground(const iColor &color); virtual void SetBackground(const iImage &image); virtual float GetLastRenderTimeInSeconds() const; void GetAspectRatio(double ar[2]) const; virtual void AddObject(vtkProp* p); virtual void RemoveObject(vtkProp* p); virtual void SetAntialiasingMode(int m); inline int GetAntialiasingMode() const { return mAntialiasingMode; } virtual void SetDepthPeelingStyle(int s); inline int GetDepthPeelingStyle() const { return mDepthPeelingStyle; } virtual void SetStereoMode(int m); inline int GetStereoMode() const { return mStereoMode; } void SetBackgroundImageTile(float tx, float ty, float tw, float th); void SetBackgroundImageTile(const float tile[4]); virtual void SetBackgroundImageFixedAspect(bool s); inline bool GetBackgroundImageFixedAspect() const { return mBackgroundImageFixedAspect; } virtual int GetFullScreenMode() const; virtual void CopyBackground(const iRenderTool *source); virtual void ShowStereoAlignmentMarks(bool s); virtual void RenderImages(int mag, iStereoImageArray &images); void RenderStereoImage(int mag, iStereoImage &image); void ExportScene(const iString &fname); virtual void SetFontType(int t); inline int GetFontType() const { return mFontType; } virtual void SetFontScale(int t); inline int GetFontScale() const { return mFontScale; } protected: iRenderTool(iViewModule *vm, vtkRenderer *ren = 0, iMagnifier *mag = 0); virtual ~iRenderTool(); virtual iRenderTool* CreateInstance(vtkRenderer *ren) const; vtkRenderer* CreateRenderer() const; void ShowDualWindow(bool s); // // Functions used by iCamera class // virtual void ResetCamera(); void ResetCameraClippingRange(); void SetAdjustCameraClippingRangeAutomatically(bool s); inline bool GetAdjustCameraClippingRangeAutomatically() const { return mAutoClippingRange; } void SetCameraClippingRange(double cr[2]); inline void GetCameraClippingRange(double cr[2]) const { cr[0] = mClippingRange[0]; cr[1] = mClippingRange[1]; } virtual void UpdateWindowCollection(); void WindowsModified(); // // Rendering pipeline // vtkRenderWindow *mMainWin, *mDualWin; vtkRenderer *mMainRen, *mDualRen; iRenderToolBackground *mMainBkg, *mDualBkg; vtkRenderWindowInteractor *mMainInt; vtkRenderWindowCollection *mWindowCollection; iCamera *mMainCam; vtkPropAssembly *mStereoAlignmentMarksActor; iEventObserver *mMainWindowObserver, *mDualWindowObserver, *mRendererObserver, *mStereoRenderObserver; // // Observers registry // struct Observer { unsigned long Event; iEventObserver *Command; Observer(){ Event = 0L; Command = 0; } }; iArray mObservers; private: void Reset(); void ConfigureDepthPeeling(vtkRenderer *ren) const; // // Other members // iMagnifier *mMagnifier; int mStereoMode, mFontScale, mFontType, mDepthPeelingStyle, mAntialiasingMode; double mClippingRange[2]; bool mStereoAlignmentMarksOn, mAutoClippingRange, mWindowCollectionUpToDate, mBackgroundImageFixedAspect; const int mStereoModeOffset; int *mRenderWindowPosition, *mRenderWindowSize; bool mMainWinStereoRender; void SetMainWinStereoRender(bool s); // // For ordered rendering // vtkPropCollection *mActorObjects, *mVolumeObjects; }; #endif // IRENDERVIEW_H ifrit-4.1.2/core/irendertoolbackground.cpp0000674060175406010010000001314712641012563017244 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "irendertoolbackground.h" #include "ierror.h" #include "iimage.h" #include "imath.h" #include "ivtk.h" #include #include #include #include class iRenderToolBackgroundImageMapper : public vtkImageMapper { public: static iRenderToolBackgroundImageMapper* New() { return new iRenderToolBackgroundImageMapper; } virtual void RenderData(vtkViewport *, vtkImageData *, vtkActor2D *) { } virtual void RenderOverlay(vtkViewport *viewport, vtkActor2D *actor) { int *size = viewport->GetSize(); if(this->GetMTime()>mBuildTime || size[0]!=mOldSize[0] || size[1]!=mOldSize[1]) { mOldSize[0] = size[0]; mOldSize[1] = size[1]; mImageTile = mImageFull;; if(mTile[0]>0.0 || mTile[2]<1.0 || mTile[1]>0.0 || mTile[3]<1.0) { int fw = mImageFull.Width(); int fh = mImageFull.Height(); if(mFixedAspect) { float sx = float(fw)/size[0]; float sy = float(fh)/size[1]; if(sx > sy) { fw = iMath::Round2Int(sy*size[0]); } else { fh = iMath::Round2Int(sx*size[1]); } } int x = iMath::Round2Int(mTile[0]*fw); int w = iMath::Round2Int(mTile[2]*fw) - x; int y = iMath::Round2Int(mTile[1]*fh); int h = iMath::Round2Int(mTile[3]*fh) - y; mImageTile.Crop(x,y,w,h); } mImageTile.Scale(size[0],size[1]); mWorker->SetInputData(mImageTile.DataObject()); mBuildTime.Modified(); } mWorker->RenderOverlay(viewport,actor); } void SetImageFixedAspect(bool s) { if(mFixedAspect != s) { mFixedAspect = s; this->Modified(); } } bool GetImageFixedAspect() { return mFixedAspect; } void SetImageTile(const float tile[4]) { if(tile[0]!=mTile[0] || tile[1]!=mTile[1] || tile[2]!=mTile[2] || tile[3]!=mTile[3]) { int j; for(j=0; j<4; j++) { mTile[j] = tile[j]; } this->Modified(); } } void SetImage(const iImage &im) { mImageFull = im; this->Modified(); } protected: iRenderToolBackgroundImageMapper() { mFixedAspect = false; mTile[0] = mTile[1] = 0.0; mTile[2] = mTile[3] = 1.0; mOldSize[0] = mOldSize[1] = 0; mWorker = vtkImageMapper::New(); IERROR_CHECK_MEMORY(mWorker); mWorker->SetColorWindow(255.0); mWorker->SetColorLevel(127.5); mWorker->RenderToRectangleOff(); mWorker->UseCustomExtentsOff(); } ~iRenderToolBackgroundImageMapper() { mWorker->Delete(); } bool mFixedAspect; float mTile[2], mMinExtent[2], mMaxExtent[2]; int mOldSize[2]; iImage mImageFull, mImageTile; vtkImageMapper *mWorker; vtkTimeStamp mBuildTime; }; // // Main class // iRenderToolBackground* iRenderToolBackground::New() { return new iRenderToolBackground; } iRenderToolBackground::iRenderToolBackground() { mRenderer = vtkRenderer::New(); IERROR_CHECK_MEMORY(mRenderer); mActor = vtkActor2D::New(); IERROR_CHECK_MEMORY(mActor); mMapper = iRenderToolBackgroundImageMapper::New(); IERROR_CHECK_MEMORY(mMapper); mActor->SetMapper(mMapper); mMapper->Delete(); mActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); mActor->SetPosition(0.0,0.0); mActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport(); mActor->SetPosition2(1.0,1.0); mActor->VisibilityOff(); mActor->PickableOff(); mActor->GetProperty()->SetDisplayLocationToBackground(); mRenderer->AddActor2D(mActor); mRenderer->SetLayer(IRENDERTOOLBACKGROUND_BACK_LAYER); mRenderer->SetInteractive(0); } iRenderToolBackground::~iRenderToolBackground() { mRenderer->RemoveActor2D(mActor); mRenderer->Delete(); mActor->Delete(); } void iRenderToolBackground::SetColor(const iColor &color) { if(color != mColor) { mColor = color; mRenderer->SetBackground(color.ToVTK()); } } void iRenderToolBackground::SetImage(const iImage &image) { if(image != mImage) { if(image.IsEmpty()) { mImage.Clear(); mActor->VisibilityOff(); } else { mImage = image; mMapper->SetImage(mImage); mActor->VisibilityOn(); } } } void iRenderToolBackground::SetImageFixedAspect(bool s) { mMapper->SetImageFixedAspect(s); } void iRenderToolBackground::SetImageTile(const float tile[4]) { mMapper->SetImageTile(tile); } void iRenderToolBackground::Copy(const iRenderToolBackground *source) { if(source != 0) { this->SetColor(source->mColor); this->SetImage(source->mImage); mMapper->SetImageFixedAspect(source->mMapper->GetImageFixedAspect()); } } ifrit-4.1.2/core/irendertoolbackground.h0000674060175406010010000000457612641012533016714 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A background renderer for iRenderTool // #ifndef IRENDERTOOLBACKGROUND_H #define IRENDERTOOLBACKGROUND_H #include #include "icolor.h" #include "iimage.h" #include class iRenderToolBackgroundImageMapper; class vtkActor2D; class vtkRenderer; #define IRENDERTOOLBACKGROUND_BACK_LAYER 0 #define IRENDERTOOLBACKGROUND_FRONT_LAYER 1 class iRenderToolBackground : public vtkObjectBase { public: vtkTypeMacro(iRenderToolBackground,vtkObjectBase); static iRenderToolBackground* New(); inline vtkRenderer* GetRenderer() const { return mRenderer; } void SetColor(const iColor &color); inline const iColor& GetColor() const { return mColor; } void SetImage(const iImage &image); inline const iImage& GetImage() const { return mImage; } void SetImageFixedAspect(bool s); void SetImageTile(const float tile[4]); void Copy(const iRenderToolBackground *source); protected: virtual ~iRenderToolBackground(); private: iRenderToolBackground(); iColor mColor; iImage mImage; vtkActor2D *mActor; iRenderToolBackgroundImageMapper *mMapper; vtkRenderer *mRenderer; }; #endif // IRENDERTOOLBACKGROUND_H ifrit-4.1.2/core/ireplicatedactor.cpp0000674060175406010010000001304112641012563016165 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ireplicatedactor.h" #include "iarray.h" #include "iclipplane.h" #include "ierror.h" #include "iviewmodule.h" #include "iviewsubject.h" #include #include #include // // Templates // #include "iarray.tlh" // // We need to take over Device to know which mapper to use on all replicas // class iReplicatedActorDevice: public vtkActor { friend class iReplicatedActor; private: struct Replica { vtkActor *Actor; int Pos[3]; Replica(){ Actor = 0; Pos[0] = Pos[1] = Pos[2] = 0; } }; static iReplicatedActorDevice* New(iReplicatedActor *parent) { return new iReplicatedActorDevice(parent); } virtual void Render(vtkRenderer *ren, vtkMapper *mapper) { int i; for(i=0; iGetMTime() < mParent->GetMTime()) { mReplicas[i].Actor->ShallowCopy(mParent); mReplicas[i].Actor->SetPosition(2.0*mReplicas[i].Pos[0],2.0*mReplicas[i].Pos[1],2.0*mReplicas[i].Pos[2]); mReplicas[i].Actor->Modified(); // Actor is not modifed on ShallowCopy } mReplicas[i].Actor->Render(ren,mapper); } } void CreateReplica(int i, int j, int k) { mReplicas.Add(Replica()); Replica &tmp = mReplicas[mReplicas.MaxIndex()]; tmp.Pos[0] = i; tmp.Pos[1] = j; tmp.Pos[2] = k; tmp.Actor = vtkActor::New(); IERROR_CHECK_MEMORY(tmp.Actor); tmp.Actor->SetPosition(2.0*tmp.Pos[0],2.0*tmp.Pos[1],2.0*tmp.Pos[2]); tmp.Actor->SetProperty(this->GetProperty()); } // // Delete unneeded actors // void DeleteReplicas(int numReplicas[6]) { int k; for(k=0; knumReplicas[1] || mReplicas[k].Pos[1]<-numReplicas[2] || mReplicas[k].Pos[1]>numReplicas[3] || mReplicas[k].Pos[2]<-numReplicas[4] || mReplicas[k].Pos[2]>numReplicas[5]) { mReplicas[k].Actor->Delete(); mReplicas.Remove(k); k--; } } } iReplicatedActorDevice(iReplicatedActor *parent) { mParent = parent; IASSERT(parent); vtkMatrix4x4 *m = vtkMatrix4x4::New(); IERROR_CHECK_MEMORY(m); this->SetUserMatrix(m); m->Delete(); this->CreateReplica(0,0,0); } virtual ~iReplicatedActorDevice() { while(mReplicas.Size() > 0) mReplicas.RemoveLast().Actor->Delete(); } iArray mReplicas; iReplicatedActor *mParent; }; // // Main class // iReplicatedActor* iReplicatedActor::New(iViewSubject *owner) { IASSERT(owner); return new iReplicatedActor(owner); } iReplicatedActor::iReplicatedActor(iViewSubject *owner) : iActor(owner->GetViewModule()->GetClipPlane()->GetPlanes()), iReplicatedElement(false) { // // Must create property first - it is not created by default // IASSERT(this->GetProperty()); // // Substitute the device // this->Device->Delete(); this->Device = mRealDevice = iReplicatedActorDevice::New(this); IERROR_CHECK_MEMORY(mRealDevice); this->ReplicateAs(owner); } iReplicatedActor::~iReplicatedActor() { } double* iReplicatedActor::GetBounds() { int i; iActor::GetBounds(); if(this->Bounds!=0 && mReplicatedBoundsMTimeBoundsMTime) { mReplicatedBoundsMTime.Modified(); for(i=0; i<3; i++) { this->Bounds[2*i+0] -= 2.0*mReplicationFactors[2*i+0]; this->Bounds[2*i+1] += 2.0*mReplicationFactors[2*i+1]; } } return this->Bounds; } void iReplicatedActor::Render(vtkRenderer *ren, vtkMapper *m) { iActor::Render(ren,m); // // Update time // this->EstimatedRenderTime *= (mReplicationFactors[0]+mReplicationFactors[1])*(mReplicationFactors[2]+mReplicationFactors[3])*(mReplicationFactors[4]+mReplicationFactors[5]); } void iReplicatedActor::UpdateReplicasBody() { int i, j, k; // // Add needed actors // for(k=-mReplicationFactors[4]; k<=mReplicationFactors[5]; k++) { for(j=-mReplicationFactors[2]; j<=mReplicationFactors[3]; j++) { for(i=-mReplicationFactors[0]; i<=mReplicationFactors[1]; i++) { if(i<-mOldReplicationFactors[0] || i>mOldReplicationFactors[1] || j<-mOldReplicationFactors[2] || j>mOldReplicationFactors[3] || k<-mOldReplicationFactors[4] || k>mOldReplicationFactors[5]) { mRealDevice->CreateReplica(i,j,k); } } } } // // Delete unneeded actors // mRealDevice->DeleteReplicas(mReplicationFactors); // // Need to redo bounds // this->BoundsMTime.Modified(); } ifrit-4.1.2/core/ireplicatedactor.h0000674060175406010010000000401212641012534015626 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // An actor that can be replicated periodically. This is a preferred way to replicate, since // we create no new data and re-use mappers. // #ifndef IREPLICATEDACTOR_H #define IREPLICATEDACTOR_H #include "iactor.h" #include "ireplicatedelement.h" class iReplicatedActorDevice; class iReplicatedActor : public iActor, public iReplicatedElement { public: vtkTypeMacro(iReplicatedActor,iActor); static iReplicatedActor* New(iViewSubject *owner = 0); virtual double* GetBounds(); virtual void Render(vtkRenderer *ren, vtkMapper *m); protected: iReplicatedActor(iViewSubject *owner); virtual ~iReplicatedActor(); virtual void UpdateReplicasBody(); private: iReplicatedActorDevice *mRealDevice; vtkTimeStamp mReplicatedBoundsMTime; }; #endif // IREPLICATEDACTOR_H ifrit-4.1.2/core/ireplicatedelement.cpp0000674060175406010010000000530012641012563016505 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ireplicatedelement.h" #include "ierror.h" #include "iviewsubject.h" iReplicatedElement::iReplicatedElement(bool isData) : mIsData(isData) { int i; for(i=0; i<6; i++) mReplicationFactors[i] = mOldReplicationFactors[i] = 0; mParent = 0; } iReplicatedElement::~iReplicatedElement() { if(mParent != 0) { mParent->UnRegisterReplicatedElement(this); } } void iReplicatedElement::ReplicateAs(iViewSubject *parent) { if(mParent != 0) { mParent->UnRegisterReplicatedElement(this); } mParent = parent; if(mParent != 0) { mParent->RegisterReplicatedElement(this,mIsData); } this->UpdateReplicas(); } void iReplicatedElement::UpdateReplicas(bool force) { int i; bool work = force; this->UpdateReplicasHead(); if(mParent != 0) { if(mIsData == mParent->IsOptimizedForQuality()) { for(i=0; i<6; i++) mReplicationFactors[i] = mParent->mReplicationFactors[i]; } else { for(i=0; i<6; i++) mReplicationFactors[i] = 0; } } for(i=0; !work && i<6; i++) { if(mOldReplicationFactors[i] != mReplicationFactors[i]) work = true; } if(work) { this->UpdateReplicasBody(); for(i=0; i<6; i++) mOldReplicationFactors[i] = mReplicationFactors[i]; } } void iReplicatedElement::SetReplicationFactors(const int n[6]) { int i; for(i=0; i<6; i++) mReplicationFactors[i] = n[i]; this->UpdateReplicas(); } void iReplicatedElement::GetReplicationFactors(int n[6]) const { int i; for(i=0; i<6; i++) n[i] = mReplicationFactors[i]; } ifrit-4.1.2/core/ireplicatedelement.h0000674060175406010010000000417512641012534016161 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A class that can be replicated periodically in all 3 directions. // #ifndef IREPLICATEDELEMENT_H #define IREPLICATEDELEMENT_H class iViewSubject; class iReplicatedElement { friend class iViewSubject; public: void SetReplicationFactors(const int n[6]); void GetReplicationFactors(int n[6]) const; inline bool IsReplicated() const { return mReplicationFactors[0]>0 || mReplicationFactors[1]>0 || mReplicationFactors[2]>0 || mReplicationFactors[3]>0 || mReplicationFactors[4]>0 || mReplicationFactors[5]>0; } void ReplicateAs(iViewSubject *parent); protected: iReplicatedElement(bool isData); virtual ~iReplicatedElement(); void UpdateReplicas(bool force = false); virtual void UpdateReplicasHead(){} virtual void UpdateReplicasBody() = 0; const bool mIsData; int mReplicationFactors[6], mOldReplicationFactors[6]; iViewSubject *mParent; }; #endif // IREPLICATEDELEMENT_H ifrit-4.1.2/core/ireplicatedgriddata.cpp0000674060175406010010000001150612641012564016641 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ireplicatedgriddata.h" #include "idata.h" #include "ierror.h" #include "iparallel.h" #include "iviewmodule.h" #include "iviewsubject.h" #include #include #include // // Templates // #include "igenericfilter.tlh" iReplicatedGridData* iReplicatedGridData::New(iViewInstance *owner) { IASSERT(owner); return new iReplicatedGridData(owner); } iReplicatedGridData::iReplicatedGridData(iViewInstance *owner) : iGenericImageDataFilter(owner,1,true), iParallelWorker(owner->GetViewModule()->GetParallelManager()), iReplicatedElement(true) { this->ReplicateAs(owner->Owner()); } void iReplicatedGridData::UpdateReplicasBody() { this->Modified(); } void iReplicatedGridData::ProvideInfo() { vtkImageData *input = this->InputData(); vtkImageData *output = this->OutputData(); int i, ext[6]; double org[3]; input->GetExtent(ext); input->GetOrigin(org); for(i=0; i<3; i++) { ext[2*i+1] = 1 + (ext[2*i+1]-1)*(mReplicationFactors[2*i+1]+mReplicationFactors[2*i]+1); org[i] -= 2.0*mReplicationFactors[2*i]; } output->SetExtent(ext); output->SetSpacing(input->GetSpacing()); output->SetOrigin(org); vtkInformation* outInfo = wCache.OutputVector->GetInformationObject(0); outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),ext,6); } void iReplicatedGridData::ProvideOutput() { vtkImageData *input = this->InputData(); vtkImageData *output = this->OutputData(); int i, extDown[3], extUp[3]; double pos[3]; output->Initialize(); int n = input->GetNumberOfScalarComponents(); if(n == 0) return; bool work = false; for(i=0; i<3; i++) { extDown[i] = -mReplicationFactors[2*i]; extUp[i] = mReplicationFactors[2*i+1]; if(extDown[i] != 0) work = true; if(extUp[i] != 0) work = true; } if(!work) { output->ShallowCopy(input); return; } input->GetSpacing(pos); output->SetSpacing(pos); input->GetDimensions(wDimsIn); input->GetOrigin(pos); int next = 1; for(i=0; i<3; i++) { wExt[i] = extUp[i] - extDown[i] + 1; wDimsOut[i] = 1 + (wDimsIn[i]-1)*wExt[i]; next *= wExt[i]; } wSize = input->GetScalarSize()*input->GetNumberOfScalarComponents(); wSize0 = (wDimsIn[0]-1)*wSize; wSize1 = wSize0 + wSize; for(i=0; i<3; i++) pos[i] += 2.0*extDown[i]; output->SetOrigin(pos); output->SetDimensions(wDimsOut); #ifdef IVTK_5 output->SetScalarType(input->GetScalarType()); output->SetNumberOfScalarComponents(input->GetNumberOfScalarComponents()); output->AllocateScalars(); #else output->AllocateScalars(input->GetScalarType(),input->GetNumberOfScalarComponents()); #endif wPtrIn = (char *)input->GetScalarPointer(); wPtrOut = (char *)output->GetScalarPointer(); this->ParallelExecute(0); } int iReplicatedGridData::ExecuteStep(int, iParallel::ProcessorInfo &p) { int j, k, i1, j1, k1; int kBeg, kEnd, kStp; vtkIdType loff, loff1, loff2; iParallel::SplitRange(p,wDimsIn[2],kBeg,kEnd,kStp); for(k1=0; k1UpdateProgress(double(k-kBeg+wDimsIn[2]*k1)/((kEnd-kBeg)*wExt[2])); if(this->GetAbortExecute()) break; for(j1=0; j1IsReplicated()) { return this->iGenericImageDataFilter::GetMemorySize(); } else return 0.0; } ifrit-4.1.2/core/ireplicatedgriddata.h0000674060175406010010000000430612641012534016303 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Takes StructuredPoints data of any type and replicates them periodically. // #ifndef IREPLICATEDGRIDDATA_H #define IREPLICATEDGRIDDATA_H #include "igenericfilter.h" #include #include "iparallelworker.h" #include "ireplicatedelement.h" class iViewInstance; class iReplicatedGridData : public iGenericImageDataFilter, protected iParallelWorker, public iReplicatedElement { public: vtkTypeMacro(iReplicatedGridData,vtkImageAlgorithm); static iReplicatedGridData* New(iViewInstance *owner = 0); virtual float GetMemorySize(); protected: iReplicatedGridData(iViewInstance *owner); virtual void ProvideInfo(); virtual void ProvideOutput(); virtual void UpdateReplicasBody(); virtual int ExecuteStep(int step, iParallel::ProcessorInfo &p); private: // // Work variables // int wDimsIn[3], wDimsOut[3], wExt[3]; vtkIdType wSize, wSize0, wSize1; char *wPtrIn, *wPtrOut; }; #endif // IREPLICATEDGRIDDATA_H ifrit-4.1.2/core/ireplicatedpolydata.cpp0000674060175406010010000003350312641012564016700 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ireplicatedpolydata.h" #include "ierror.h" #include "imath.h" #include "iviewmodule.h" #include "iviewsubject.h" #include #include #include #include #include #include // // Templates // #include "igenericfilter.tlh" namespace iReplicatedPolyData_Private { // // QuickFind // #define ARR(i) lptr1[i] bool Find(vtkIdType n, vtkIdType *lptr1, vtkIdType l, vtkIdType &ind) { vtkIdType i1 = 0; vtkIdType i2 = n - 1; vtkIdType ic; if(l < ARR(i1)) { ind = -1; return false; } if(l > ARR(i2)) { ind = -1; return false; } while(i2-i1 > 1) { ic = (i1+i2)/2; if(l >= ARR(ic)) i1 = ic; if(l <= ARR(ic)) i2 = ic; } if(l == ARR(i1)) { ind = i1; return true; } else if(l == ARR(i2)) { ind = i2; return true; } else { ind = -1; return false; } } // // QuickSort // #define SAVE(CELL,i1) { ltmp1 = lptr1[i1]; ltmp2 = lptr2[i1]; } #define MOVE(i1,i2) { lptr1[i1] = lptr1[i2]; lptr2[i1] = lptr2[i2]; } #define RESTORE(i2,CELL) { lptr1[i2] = ltmp1; lptr2[i2] = ltmp2; } #define SWAP(i1,i2) { SAVE(1,i1); MOVE(i1,i2); RESTORE(i2,1); } // // Recursive worker // void SortWorker(vtkIdType l, vtkIdType r, vtkIdType *lptr1, vtkIdType *lptr2) { const int M = 8; vtkIdType i, j, v, ltmp1, ltmp2; if ((r-l)>M) { // // Use quicksort // i = (r+l)/2; if (ARR(l)>ARR(i)) SWAP(l,i); // Tri-Median Method! if (ARR(l)>ARR(r)) SWAP(l,r); if (ARR(i)>ARR(r)) SWAP(i,r); j = r-1; SWAP(i,j); i = l; v = ARR(j); for(;;) { do i++; while(ARR(i) < v); // no ++i/--j in macro expansion! do j--; while(ARR(j) > v); if (jl && ARR(j-1)>v) { MOVE(j,j-1); j--; } RESTORE(j,1); } } } // // Do our own quick sort for efficiency reason (based on a Java code by Denis Ahrens) // void Sort(vtkIdType n, vtkIdType *lptr1, vtkIdType *lptr2) { SortWorker(0,n-1,lptr1,lptr2); } }; using namespace iReplicatedPolyData_Private; iReplicatedPolyData::iReplicatedPolyData(iViewInstance *owner) : iGenericPolyDataFilter(owner,1,true), iReplicatedElement(true) { this->ReplicateAs(owner->Owner()); } void iReplicatedPolyData::UpdateReplicasBody() { this->Modified(); } void iReplicatedPolyData::ProvideOutput() { vtkPolyData *input = this->InputData(); vtkPolyData *output = this->OutputData(); int extDown[3], extUp[3]; int i; output->ShallowCopy(input); bool work = false; for(i=0; i<3; i++) { extDown[i] = -mReplicationFactors[2*i]; extUp[i] = mReplicationFactors[2*i+1]; if(extDown[i] != 0) work = true; if(extUp[i] != 0) work = true; } if(!work) return; vtkPolyData *tmp = vtkPolyData::New(); if(tmp == 0) return; for(i=0; i<3; i++) if(extUp[i]>0 || extDown[i]<0) { tmp->ShallowCopy(output); this->ExtendDirection(tmp,output,i,extDown[i],extUp[i]); } tmp->Delete(); } void iReplicatedPolyData::ExtendDirection(vtkPolyData *input, vtkPolyData *output, int dim, int extDown, int extUp) { int i, j; if(input==0 || output==0 || dim<0 || dim>2 || extDown>0 || extUp<0) return; output->ShallowCopy(input); int next = extUp - extDown + 1; if(next < 2) return; vtkPoints *ipoi = input->GetPoints(); if(ipoi == 0) return; vtkCellArray *iver = input->GetVerts(); vtkCellArray *ilin = input->GetLines(); vtkCellArray *ipol = input->GetPolys(); vtkCellArray *isrp = input->GetStrips(); vtkDataArray *isca = input->GetPointData()->GetScalars(); vtkDataArray *inor = input->GetPointData()->GetNormals(); float *iptrpoiF = 0; double *iptrpoiD = 0; float *iptrsca = (isca == 0) ? 0 : (float *)isca->GetVoidPointer(0); float *iptrnor = (inor == 0) ? 0 : (float *)inor->GetVoidPointer(0); vtkIdType npoi = ipoi->GetNumberOfPoints(); if(npoi == 0) return; vtkIdType nver = (iver == 0) ? 0 : iver->GetNumberOfCells(); vtkIdType nlin = (ilin == 0) ? 0 : ilin->GetNumberOfCells(); vtkIdType npol = (ipol == 0) ? 0 : ipol->GetNumberOfCells(); vtkIdType nsrp = (isrp == 0) ? 0 : isrp->GetNumberOfCells(); vtkIdType nsca = (isca == 0) ? 0 : isca->GetNumberOfComponents()*isca->GetNumberOfTuples(); vtkIdType nnor = (inor == 0) ? 0 : inor->GetNumberOfComponents()*inor->GetNumberOfTuples(); vtkPoints *opoi; opoi = vtkPoints::New(ipoi->GetDataType()); IERROR_CHECK_MEMORY(opoi); opoi->SetNumberOfPoints(next*npoi); float *optrpoiF = 0; double *optrpoiD = 0; float *optrsca = 0, *optrnor = 0; vtkCellArray *over = 0, *olin = 0, *opol = 0, *osrp = 0; vtkFloatArray *osca = 0, *onor = 0; bool pointsAreFloat; switch(ipoi->GetDataType()) { case VTK_FLOAT: { pointsAreFloat = true; iptrpoiF = (float *)ipoi->GetVoidPointer(0); optrpoiF = (float *)opoi->GetVoidPointer(0); break; } case VTK_DOUBLE: { pointsAreFloat = false; iptrpoiD = (double *)ipoi->GetVoidPointer(0); optrpoiD = (double *)opoi->GetVoidPointer(0); break; } default: { vtkErrorMacro("Incorrect Points type"); return; } } if(nver > 0) { over = vtkCellArray::New(); IERROR_CHECK_MEMORY(over); } if(nlin > 0) { olin = vtkCellArray::New(); IERROR_CHECK_MEMORY(olin); } if(npol > 0) { opol = vtkCellArray::New(); IERROR_CHECK_MEMORY(opol); } if(nsrp > 0) { osrp = vtkCellArray::New(); IERROR_CHECK_MEMORY(osrp); } if(nsca > 0) { osca = vtkFloatArray::New(); IERROR_CHECK_MEMORY(osca); osca->SetNumberOfComponents(isca->GetNumberOfComponents()); osca->SetNumberOfTuples(next*isca->GetNumberOfTuples()); optrsca = (float *)osca->GetVoidPointer(0); } if(nnor > 0) { onor = vtkFloatArray::New(); IERROR_CHECK_MEMORY(onor); onor->SetNumberOfComponents(3); onor->SetNumberOfTuples(next*inor->GetNumberOfTuples()); optrnor = (float *)onor->GetVoidPointer(0); } vtkIdType npts, *pts, *pts1; int maxCellSize = 0, curmax; if(nver > 0) { curmax = iver->GetMaxCellSize(); if(curmax > maxCellSize) maxCellSize = curmax; } if(nlin > 0) { curmax = ilin->GetMaxCellSize(); if(curmax > maxCellSize) maxCellSize = curmax; } if(npol > 0) { curmax = ipol->GetMaxCellSize(); if(curmax > maxCellSize) maxCellSize = curmax; } if(nsrp > 0) { curmax = isrp->GetMaxCellSize(); if(curmax > maxCellSize) maxCellSize = curmax; } pts = new vtkIdType[maxCellSize]; IERROR_CHECK_MEMORY(pts); double s[3]; s[0] = s[1] = s[2] = 0.0; s[dim] = 2.0; int off = 0; vtkIdType l, loff1, loff2, noff; for(j=extDown; j<=extUp; j++) { this->UpdateProgress(double(j-extDown)/next); if(this->GetAbortExecute()) break; noff = off*npoi; if(pointsAreFloat) { for(l=0; l 0) for(iver->InitTraversal(); iver->GetNextCell(npts,pts1)!=0; ) { pts[0] = pts1[0] + noff; over->InsertNextCell(1,pts); } if(nlin > 0) for(ilin->InitTraversal(); ilin->GetNextCell(npts,pts1)!=0; ) { for(i=0; iInsertNextCell(npts,pts); } if(npol > 0) for(ipol->InitTraversal(); ipol->GetNextCell(npts,pts1)!=0; ) { for(i=0; iInsertNextCell(npts,pts); } if(nsrp > 0) for(isrp->InitTraversal(); isrp->GetNextCell(npts,pts1)!=0; ) { for(i=0; iInsertNextCell(npts,pts); } if(nsca > 0) memcpy(optrsca+off*nsca,iptrsca,nsca*sizeof(float)); if(nnor > 0) memcpy(optrnor+off*nnor,iptrnor,nnor*sizeof(float)); off++; } delete [] pts; output->SetPoints(opoi); opoi->Delete(); if(nver > 0) { output->SetVerts(over); over->Delete(); } if(nlin > 0) { output->SetLines(olin); olin->Delete(); } if(npol > 0) { output->SetPolys(opol); opol->Delete(); } if(nsrp > 0) { output->SetStrips(osrp); osrp->Delete(); } if(nsca > 0) { output->GetPointData()->SetScalars(osca); osca->Delete(); } if(nnor > 0) { output->GetPointData()->SetNormals(onor); onor->Delete(); } // // Patch stitches // double *edges = new double[next-1]; if(edges == 0) return; for(j=0; jIsReplicated()) return this->iGenericPolyDataFilter::GetMemorySize(); else return 0.0; } void iReplicatedPolyData::PatchStitches(vtkPolyData *input, int ndim, double *edges, vtkIdType nEdges) { int i, j, k; if(input==0 || nEdges<=0 || ndim<0 || ndim>2) { return; } vtkCellArray *cell[4]; cell[0] = input->GetVerts(); cell[1] = input->GetLines(); cell[2] = input->GetPolys(); cell[3] = input->GetStrips(); vtkPoints *points = input->GetPoints(); if(points == 0) return; float *ptrF = 0; double *ptrD = 0; bool pointsAreFloat = false; double tolerance; switch (points->GetDataType()) { case VTK_FLOAT: { pointsAreFloat = true; ptrF = (float *)points->GetVoidPointer(0); tolerance = iMath::_FloatTolerance; break; } case VTK_DOUBLE: { pointsAreFloat = false; ptrD = (double *)points->GetVoidPointer(0); tolerance = iMath::_DoubleTolerance; break; } default: tolerance = 0.0; } vtkIdList *edgeIds = vtkIdList::New(); IERROR_CHECK_MEMORY(edgeIds); vtkIdList *outIds = vtkIdList::New(); IERROR_CHECK_MEMORY(outIds); vtkIdList *repIds = vtkIdList::New(); IERROR_CHECK_MEMORY(repIds); vtkIdList *indIds = vtkIdList::New(); IERROR_CHECK_MEMORY(indIds); vtkPointLocator *loc = vtkPointLocator::New(); IERROR_CHECK_MEMORY(loc); vtkPoints *tmpPoints = vtkPoints::New(points->GetDataType()); IERROR_CHECK_MEMORY(tmpPoints); int div[3]; for(i=0; i<3; i++) { div[i] = 100; } div[ndim] = 1; loc->SetTolerance(tolerance); vtkIdType np = points->GetNumberOfPoints(); vtkIdType l, lid, ncell, *pcell; double xe, x[3], bounds[6]; vtkIdType *outptr, *repptr, nout; float *nor, *norptr = 0; if(input->GetPointData()->GetNormals() != 0) norptr = (float *)input->GetPointData()->GetNormals()->GetVoidPointer(0); points->GetBounds(bounds); for(k=0; kInitialize(); xe = edges[k]; if(pointsAreFloat) { for(l=0; lInsertNextId(l); } } } else { for(l=0; lInsertNextId(l); } } } loc->Initialize(); outIds->Initialize(); repIds->Initialize(); indIds->Initialize(); tmpPoints->Initialize(); loc->SetDivisions(div); bounds[2*ndim] = xe - 2*tolerance; bounds[2*ndim+1] = xe + 2*tolerance; loc->InitPointInsertion(tmpPoints,bounds); for(l=0; lGetNumberOfIds(); l++) { points->GetPoint(edgeIds->GetId(l),x); if(loc->InsertUniquePoint(x,lid) == 0) { outIds->InsertNextId(edgeIds->GetId(l)); repIds->InsertNextId(edgeIds->GetId(indIds->GetId(lid))); } else indIds->InsertNextId(l); } // // We need to sort outIds and repIds arrays to make searching efficient // nout = outIds->GetNumberOfIds(); bool *norFixed = new bool[nout]; if(norFixed!=0 && nout>0) { outptr = outIds->GetPointer(0); repptr = repIds->GetPointer(0); Sort(nout,outptr,repptr); memset(norFixed,0,nout); // // Replace outIds with repIds and fix normals on the way. make sure not to // do it more than once. // for(i=0; i<4; i++) if(cell[i] != 0) { cell[i]->InitTraversal(); while(cell[i]->GetNextCell(ncell,pcell) > 0) { for(l=0; lDelete(); edgeIds->Delete(); tmpPoints->Delete(); outIds->Delete(); repIds->Delete(); indIds->Delete(); } ifrit-4.1.2/core/ireplicatedpolydata.h0000674060175406010010000000440512641012534016341 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // Takes PolyData data of any type and replicates them periodically. // #ifndef IREPLICATEDPOLYDATA_H #define IREPLICATEDPOLYDATA_H #include "igenericfilter.h" #include #include "ireplicatedelement.h" class iViewInstance; class iReplicatedPolyData : public iGenericPolyDataFilter, public iReplicatedElement { public: vtkTypeMacro(iReplicatedPolyData,iGenericPolyDataFilter); static iReplicatedPolyData* New(iViewInstance *owner = 0) { IERROR_CHECK_MEMORY(owner); return new iReplicatedPolyData(owner); } virtual float GetMemorySize(); // // Removes stitches between extensions in place // static void PatchStitches(vtkPolyData *input, int ndim, double *edges, vtkIdType nEdges); protected: iReplicatedPolyData(iViewInstance *owner); virtual void ProvideOutput(); virtual void UpdateReplicasBody(); private: void ExtendDirection(vtkPolyData *input, vtkPolyData *output, int dim, int extDown, int extUp); }; #endif // IREPLICATEDPOLYDATA_H ifrit-4.1.2/core/ireplicatedviewsubjectpipeline.cpp0000674060175406010010000000441212641012564021140 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ireplicatedviewsubjectpipeline.h" #include "ireplicatedpolydata.h" // // Templates (needed for some compilers) // #include "iarray.tlh" #include "igenericfilter.tlh" #include "iviewsubjectpipeline.tlh" // // generic iFieldGlyphPipeline class // iReplicatedViewSubjectPipeline::iReplicatedViewSubjectPipeline(iViewInstance *owner, int numInputs) : iViewSubjectPipeline(owner,numInputs) { mOwner = owner; // // Do VTK stuff // mDataReplicated = this->CreateFilter(); } iReplicatedViewSubjectPipeline::~iReplicatedViewSubjectPipeline() { } void iReplicatedViewSubjectPipeline::CompletePipeline(vtkAlgorithmOutput *port) { mDataReplicated->SetInputConnection(port); } void iReplicatedViewSubjectPipeline::ProvideOutput() { if(this->PrepareInput()) { // // Update the pipeline // mDataReplicated->Update(); this->OutputData()->ShallowCopy(mDataReplicated->OutputData()); } } void iReplicatedViewSubjectPipeline::UpdateReplicas() { mDataReplicated->Modified(); this->Modified(); } ifrit-4.1.2/core/ireplicatedviewsubjectpipeline.h0000674060175406010010000000371412641012534020606 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IREPLICATEDVIEWSUBJECTPIPELINE_H #define IREPLICATEDVIEWSUBJECTPIPELINE_H #include "iviewsubjectpipeline.h" class iReplicatedPolyData; class iReplicatedViewSubjectPipeline : public iViewSubjectPipeline { public: vtkTypeMacro(iReplicatedViewSubjectPipeline,iViewSubjectPipeline); protected: iReplicatedViewSubjectPipeline(iViewInstance *owner, int numInputs); virtual ~iReplicatedViewSubjectPipeline(); virtual void ProvideOutput(); virtual void UpdateReplicas(); virtual bool PrepareInput() = 0; void CompletePipeline(vtkAlgorithmOutput *port); private: // // Our members (make private for refactoring) // iReplicatedPolyData *mDataReplicated; }; #endif // IREPLICATEDVIEWSUBJECTPIPELINE_H ifrit-4.1.2/core/ireplicatedvolume.cpp0000674060175406010010000001110212641012564016361 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ireplicatedvolume.h" #include "ibuffer.h" #include "ierror.h" #include "iviewsubject.h" #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "ibuffer.tlh" #include "igenericprop.tlh" // // Main class // iReplicatedVolume* iReplicatedVolume::New(iViewSubject *owner) { IASSERT(owner); return new iReplicatedVolume(owner); } iReplicatedVolume::iReplicatedVolume(iViewSubject *owner) : iGenericProp(false), iReplicatedElement(false), iViewModuleComponent(owner->GetViewModule()) { // // Must create property first - it is not created by default // IASSERT(this->GetProperty()); // // Create main replica // this->CreateReplica(0,0,0); this->ReplicateAs(owner); mCuller = vtkFrustumCoverageCuller::New(); IERROR_CHECK_MEMORY(mCuller); mCuller->SetSortingStyleToBackToFront(); } iReplicatedVolume::~iReplicatedVolume() { mCuller->Delete(); while(mReplicas.Size() > 0) mReplicas.RemoveLast().Volume->Delete(); } void iReplicatedVolume::CreateReplica(int i, int j, int k) { mReplicas.Add(Replica()); Replica &tmp = mReplicas[mReplicas.MaxIndex()]; tmp.Pos[0] = i; tmp.Pos[1] = j; tmp.Pos[2] = k; tmp.Volume = vtkVolume::New(); tmp.Volume->ShallowCopy(this); tmp.Volume->SetPosition(2.0*tmp.Pos[0],2.0*tmp.Pos[1],2.0*tmp.Pos[2]); } double* iReplicatedVolume::GetBounds() { int i; vtkVolume::GetBounds(); if(this->Bounds != 0) { for(i=0; i<3; i++) { this->Bounds[2*i+0] -= 2.0*mReplicationFactors[2*i+0]; this->Bounds[2*i+1] += 2.0*mReplicationFactors[2*i+1]; } } return this->Bounds; } void iReplicatedVolume::UpdateGeometry(vtkViewport *vp) { int initialized = 0; int i, n = mReplicas.Size(); vtkProp** buf = new vtkProp*[n]; IERROR_CHECK_MEMORY(buf); for(i=0; iGetMTime() < this->GetMTime()) { mReplicas[i].Volume->ShallowCopy(this); mReplicas[i].Volume->SetPosition(2.0*mReplicas[i].Pos[0],2.0*mReplicas[i].Pos[1],2.0*mReplicas[i].Pos[2]); } buf[i] = mReplicas[i].Volume; } // // Reorder volumes // mCuller->Cull(iRequiredCast(INFO,vp),buf,n,initialized); // // n can change inside Cull() // this->RemoveAllComponents(); for(i=0; iAppendComponent(buf[i]); delete [] buf; } void iReplicatedVolume::UpdateReplicasBody() { int i, j, k; Replica tmp; // // Add needed actors // for(k=-mReplicationFactors[4]; k<=mReplicationFactors[5]; k++) { for(j=-mReplicationFactors[2]; j<=mReplicationFactors[3]; j++) { for(i=-mReplicationFactors[0]; i<=mReplicationFactors[1]; i++) { if(i<-mOldReplicationFactors[0] || i>mOldReplicationFactors[1] || j<-mOldReplicationFactors[2] || j>mOldReplicationFactors[3] || k<-mOldReplicationFactors[4] || k>mOldReplicationFactors[5]) { this->CreateReplica(i,j,k); } } } } // // Delete unneeded actors // for(k=0; kmReplicationFactors[1] || mReplicas[k].Pos[1]<-mReplicationFactors[2] || mReplicas[k].Pos[1]>mReplicationFactors[3] || mReplicas[k].Pos[2]<-mReplicationFactors[4] || mReplicas[k].Pos[2]>mReplicationFactors[5]) { mReplicas[k].Volume->Delete(); mReplicas.Remove(k); } } } ifrit-4.1.2/core/ireplicatedvolume.h0000674060175406010010000000455612641012534016042 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A volume that can be replicated periodically. This is a preferred way to replicate, since // we create no new data and re-use mappers. // #ifndef IREPLICATEDVOLUME_H #define IREPLICATEDVOLUME_H #include "igenericprop.h" #include #include "ireplicatedelement.h" #include "iviewmodulecomponent.h" #include "iarray.h" class vtkFrustumCoverageCuller; class iReplicatedVolume : public iGenericProp, public iReplicatedElement, public iViewModuleComponent { public: vtkTypeMacro(iReplicatedVolume,vtkVolume); static iReplicatedVolume* New(iViewSubject *owner = 0); virtual double* GetBounds(); inline vtkTransform* GetTransform() const { return this->Transform; } protected: iReplicatedVolume(iViewSubject *owner); virtual ~iReplicatedVolume(); virtual void UpdateGeometry(vtkViewport *vp); virtual void UpdateReplicasBody(); private: void CreateReplica(int i, int j, int k); struct Replica { vtkVolume *Volume; int Pos[3]; Replica(){ Volume = 0; Pos[0] = Pos[1] = Pos[2] = 0; } }; iArray mReplicas; vtkFrustumCoverageCuller *mCuller; }; #endif // IREPLICATEDVOLUME_H ifrit-4.1.2/core/iresampleimagedatafilter.cpp0000674060175406010010000001477112641012564017707 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iresampleimagedatafilter.h" #include "idataconsumer.h" #include "imath.h" #include "iviewmodule.h" #include #include // // Templates // #include "igenericfilter.tlh" iResampleImageDataFilter::iResampleImageDataFilter(iDataConsumer *consumer) : iGenericImageDataFilter(consumer,1,true) { mResampleRate = 1; } void iResampleImageDataFilter::SetResampleRate(int v) { if(v>0 && v!=mResampleRate) { mResampleRate = v; this->Modified(); } } void iResampleImageDataFilter::ComputeOutputShape(int dims[3], double spac[3], int outDims[3], double outSpac[3]) { int i; if(mResampleRate == 1) { for(i=0; i<3; i++) { outDims[i] = dims[i]; outSpac[i] = spac[i]; } } int imax = -1, maxdim = 0; for(i=0; i<3; i++) { if(maxdim < dims[i]) { imax = i; maxdim = dims[i]; } outDims[i] = (dims[i]+mResampleRate-1)/mResampleRate; // this should never overshoot #ifndef I_NO_CHECK if((outDims[i]-1)*mResampleRate > dims[i]-1) { IBUG_FATAL("Dimension overshoot bug."); } #endif } if(fabs(maxdim*spac[imax]-2.0) < 0.001*spac[imax]) { // // Fitted to the wholebox // outSpac[imax] = 2.0/outDims[imax]; } else { outSpac[imax] = spac[imax]*dims[imax]/outDims[imax]; } for(i=0; i<3; i++) if(i != imax) { if(fabs(spac[i]-spac[imax]) < 0.001*spac[imax]) { outSpac[i] = outSpac[imax]; // keep uniformity if present } else { outSpac[i] = spac[i]*dims[i]/outDims[i]; } } } void iResampleImageDataFilter::ProvideInfo() { vtkInformation *inInfo = wCache.InputVector[0]->GetInformationObject(0); vtkInformation *outInfo = wCache.OutputVector->GetInformationObject(0); int i, dims[3], outDims[3], ext[6]; double spac[3], outSpac[3]; inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),ext); inInfo->Get(vtkDataObject::SPACING(),spac); for(i=0; i<3; i++) { dims[i] = ext[2*i+1] - ext[2*i] + 1; } this->ComputeOutputShape(dims,spac,outDims,outSpac); for(i=0; i<3; i++) { ext[2*i] = 0; ext[2*i+1] = outDims[i] - 1; } outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),ext,6); outInfo->Set(vtkDataObject::SPACING(),outSpac,3); } void iResampleImageDataFilter::ProvideOutput() { vtkImageData *input = this->InputData(); vtkImageData *output = this->OutputData(); output->Initialize(); if(input->GetPointData()->GetScalars()==0 && input->GetPointData()->GetVectors()==0 && input->GetPointData()->GetTensors()==0) return; if(mResampleRate == 1) { output->ShallowCopy(input); return; } int i, dims[3], outDims[3]; double spac[3], outSpac[3]; double orig[3]; input->GetDimensions(dims); input->GetSpacing(spac); input->GetOrigin(orig); this->ComputeOutputShape(dims,spac,outDims,outSpac); output->SetDimensions(outDims); output->SetSpacing(outSpac); output->SetOrigin(orig); // cannot change origin, or the scalars and vectors/tensors will be mismatched vtkIdType sizeOut = (vtkIdType)outDims[0]*outDims[1]*outDims[2]; for(i=0; i<3; i++) { wInDims[i] = dims[i]; wOutDims[i] = outDims[i]; #ifndef I_NO_CHECK if(wOutDims[i] == 0) { IBUG_FATAL("Zero dimension bug."); } #endif } if(input->GetPointData()->GetScalars() != 0) { if(!wArray.Init(input->GetPointData()->GetScalars(),sizeOut)) { this->SetAbortExecute(1); return; } this->ResampleArray(); output->GetPointData()->SetScalars(wArray.ArrOut); wArray.ArrOut->Delete(); } if(input->GetPointData()->GetVectors() != 0) { if(!wArray.Init(input->GetPointData()->GetVectors(),sizeOut)) { this->SetAbortExecute(1); return; } this->ResampleArray(); output->GetPointData()->SetVectors(wArray.ArrOut); wArray.ArrOut->Delete(); } if(input->GetPointData()->GetTensors() != 0) { if(!wArray.Init(input->GetPointData()->GetTensors(),sizeOut)) { this->SetAbortExecute(1); return; } this->ResampleArray(); output->GetPointData()->SetTensors(wArray.ArrOut); wArray.ArrOut->Delete(); } } void iResampleImageDataFilter::ResampleArray() { int i, j, k, m; float *ptrIn, *ptrOut; int ncomp = wArray.DimIn; vtkIdType loffIn, loffOut; #ifdef I_CHECK vtkIdType l = 0; #endif #ifndef I_NO_CHECK vtkIdType sizeIn = wArray.ArrIn->GetNumberOfTuples(); vtkIdType sizeOut = wArray.ArrOut->GetNumberOfTuples(); if(wArray.DimIn != wArray.DimOut) { IBUG_FATAL("Incompatible arrays."); } #endif for(k=0; kUpdateProgress(double(k)/wOutDims[2]); if(this->GetAbortExecute()) break; for(j=0; j= sizeIn) { IBUG_FATAL("Out-of-bounds bug."); } if(loffOut+(wOutDims[0]-1) >= sizeOut) { IBUG_FATAL("Out-of-bounds bug."); } #endif for(i=0; iGetNumberOfTuples()) { IBUG_FATAL("Out-of-bounds bug."); } #endif } ifrit-4.1.2/core/iresampleimagedatafilter.h0000674060175406010010000000364012641012534017342 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IRESAMPLEIMAGEDATAFILTER_H #define IRESAMPLEIMAGEDATAFILTER_H #include "igenericfilter.h" #include class iResampleImageDataFilter : public iGenericImageDataFilter { iGenericFilterTypeMacro(iResampleImageDataFilter,vtkImageAlgorithm); public: void SetResampleRate(int v); inline int GetResampleRate() const { return mResampleRate; } protected: virtual void ProvideInfo(); virtual void ProvideOutput(); void ResampleArray(); private: void ComputeOutputShape(int dims[3], double spac[3], int outDims[3], double outSpac[3]); int mResampleRate; int wInDims[3], wOutDims[3]; }; #endif // IRESAMPLEIMAGEDATAFILTER_H ifrit-4.1.2/core/iruler.cpp0000674060175406010010000001172512641012564014161 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iruler.h" #include "icamera.h" #include "ierror.h" #include "ioverlayhelper.h" #include "irendertool.h" #include "iviewmodule.h" #include #include #include // // Templates // #include "iarray.tlh" #include "igenericprop.tlh" #include "iproperty.tlh" iRulerActor::iRulerActor(iRuler *owner) : iAxis(owner->GetViewModule()->GetRenderTool()), iViewModuleComponent(owner->GetViewModule()) { mOwner = owner; IASSERT(owner); mStarted = false; mBaseScale = 1.0; this->LabelTextProperty->SetVerticalJustificationToTop(); this->TitleTextProperty->SetJustificationToCentered(); this->TitleTextProperty->SetVerticalJustificationToBottom(); this->SetPoint1(0.25,0.9); this->SetPoint2(0.75,0.9); this->SetRange(0.0,1.0); this->AdjustLabelsOff(); this->SetNumberOfLabels(3); } void iRulerActor::UpdateGeometry(vtkViewport *vp) { vtkCamera *cam = this->GetOverlayHelper()->GetCamera(vp); if(cam==0 || cam->GetParallelProjection()==0) { this->Disable(); return; } int mag = this->GetOverlayHelper()->GetRenderingMagnification(); if(mag == 1) { if(!mStarted) { mStarted = true; mBaseScale = cam->GetParallelScale(); } float s; if(cam->GetParallelProjection() != 0) { s = cam->GetParallelScale()/mBaseScale; } else { s = cam->GetDistance()*(1.0e-35+tan(0.5*iMath::Deg2Rad(cam->GetViewAngle())))/mBaseScale; } double as[2]; vp->GetAspect(as); float dx = 0.5/mBaseScale*as[1]/as[0]; if(!this->GetViewModule()->InOpenGLCoordinates()) s *= this->GetViewModule()->GetBoxSize(); this->SetRange(0.0,s); mOwner->SetScale(s); this->SetPoint1(0.5-dx,0.9); this->SetPoint2(0.5+dx,0.9); } this->iAxis::UpdateGeometry(vp); } void iRulerActor::UpdateOverlay(vtkViewport *vp) { int mag = this->GetOverlayHelper()->GetRenderingMagnification(); if(mag == 1) { int *sz = vp->GetSize(); this->TitleActor->SetPosition(0.5*sz[0],0.91*sz[1]); } this->iAxis::UpdateOverlay(vp); } void iRulerActor::SetBaseScale(float s) { if(s > 0.0) { mStarted = true; mBaseScale = s; this->Modified(); } } void iRulerActor::SetScale(float s) { if(!mStarted) { mStarted = true; mBaseScale = this->GetOverlayHelper()->GetRenderTool()->GetCamera()->GetDevice()->GetParallelScale(); } if(s>0.0 && this->GetVisibility()!=0) { if(!this->GetViewModule()->InOpenGLCoordinates()) s /= this->GetViewModule()->GetBoxSize(); this->GetOverlayHelper()->GetRenderTool()->GetCamera()->GetDevice()->SetParallelScale(s*mBaseScale); this->Modified(); } } void iRulerActor::SetTitle(const iString &title) { this->vtkAxisActor2D::SetTitle(title.ToCharPointer()); if(title.IsEmpty()) this->TitleVisibilityOff(); else this->TitleVisibilityOn(); this->Modified(); } // // Main class // iRuler* iRuler::New(iViewModule *vm) { static iString LongName("Ruler"); static iString ShortName("rl"); IASSERT(vm); return new iRuler(vm,LongName,ShortName); } iRuler::iRuler(iViewModule *vm, const iString &fname, const iString &sname) : iViewModuleTool(vm,fname,sname), iObjectConstructPropertyMacroS(Float,iRuler,Scale,s), iObjectConstructPropertyMacroS(String,iRuler,Title,t) { mScale = 1.0; mActor = new iRulerActor(this); IERROR_CHECK_MEMORY(mActor); mActor->VisibilityOff(); mActor->PickableOff(); this->GetViewModule()->GetRenderTool()->AddObject(mActor); } iRuler::~iRuler() { this->GetViewModule()->GetRenderTool()->RemoveObject(mActor); mActor->Delete(); } bool iRuler::ShowBody(bool s) { mActor->SetVisibility(s?1:0); return true; } bool iRuler::SetScale(float s) { if(s > 0.0) { mScale = s; mActor->SetScale(s); return true; } else return false; } bool iRuler::SetTitle(const iString& s) { mTitle = s; mActor->SetTitle(s); return true; } ifrit-4.1.2/core/iruler.h0000674060175406010010000000443412641012535013623 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IRULER_H #define IRULER_H #include "iaxis.h" #include "iviewmoduletool.h" #include "istring.h" class iRuler; class iRulerActor: public iAxis, public iViewModuleComponent { friend class iRuler; public: vtkTypeMacro(iRulerActor,iAxis); void SetBaseScale(float s); void SetScale(float s); void SetTitle(const iString &title); protected: virtual void UpdateGeometry(vtkViewport *vp); virtual void UpdateOverlay(vtkViewport *vp); private: iRulerActor(iRuler *owner); iRuler *mOwner; bool mStarted; float mBaseScale; }; class iRuler : public iViewModuleTool { public: vtkTypeMacro(iRuler,iViewModuleTool); static iRuler* New(iViewModule *vm = 0); iObjectPropertyMacro1S(Scale,Float); iObjectPropertyMacro1S(Title,String); inline iRulerActor* GetActor() const { return mActor; } protected: virtual ~iRuler(); private: iRuler(iViewModule *vm, const iString &fname, const iString &sname); virtual bool ShowBody(bool s); // // Actors displayed by this class // iRulerActor *mActor; }; #endif // IRULER_H ifrit-4.1.2/core/irunner.cpp0000674060175406010010000001463012641012564014337 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ivtk.h" #ifndef IVTK_5 #include VTK_MODULE_INIT(vtkInteractionStyle); VTK_MODULE_INIT(vtkRenderingOpenGL); VTK_MODULE_INIT(vtkRenderingVolumeOpenGL); VTK_MODULE_INIT(vtkRenderingFreeType); VTK_MODULE_INIT(vtkRenderingFreeTypeOpenGL); #endif #include "irunner.h" #include "ierror.h" #include "iexception.h" #include "iscript.h" #include "ishell.h" #include "isystem.h" #include "iversion.h" #include // // Generic implementation of the runner // namespace iRunner_Private { bool RunShell(iShell *shell) { bool ret = false; try { // // Run application // if(shell->Initialize()) { shell->Start(); ret = !shell->IsFailed(); } else { //this->Display(MessageType::Error,"Shell <"+shell->Type()+"> failed to initialize."); } } catch(iException::TotalDisaster) { cerr << "IFrIT experienced a \"Total Disaster\" failure." << endl; } return ret; } VTK_THREAD_RETURN_TYPE ThreadRunner(void *data) { vtkMultiThreader::ThreadInfo *ti = static_cast(data); IASSERT(ti); iShell *shell = static_cast(ti->UserData); IASSERT(shell); RunShell(shell); *(ti->ActiveFlag) = 0; return VTK_THREAD_RETURN_VALUE; } }; using namespace iRunner_Private; using namespace iParameter; // // Main class // iRunner::iRunner() { // // Constructor is trivial // mShell = 0; mThreader = vtkMultiThreader::New(); mThreadId = -1; // // Check that sizes of basic types are correct // if(sizeof(int)!=4 || sizeof(float)!=4 || sizeof(double)!=8) { int sint = sizeof(int); int sflt = sizeof(float); int sdbl = sizeof(double); int sptr = sizeof(void*); int slng = sizeof(long); int svtk = sizeof(vtkIdType); int ssiz = sizeof(size_t); iOutput::Display(MessageType::Error,"IFrIT has not been ported to this machine."); exit(0); } // // Check that vtkIdType can address a full pointer // if(sizeof(vtkIdType) < sizeof(void*)) { iOutput::Display(MessageType::Error,"This machine is "+iString::FromNumber(8*int(sizeof(void*)))+"-bit, but VTK has been compiled with "+iString::FromNumber(8*int(sizeof(vtkIdType)))+"-bit ids.\n" "IFrIT will not be able to use more than 2GB of memory per single array.\n" "Just letting you know.\n"); } if(sizeof(vtkIdType) > sizeof(void*)) { iOutput::Display(MessageType::Error,"This machine is "+iString::FromNumber(8*int(sizeof(void*)))+"-bit, but VTK has been compiled with "+iString::FromNumber(8*int(sizeof(vtkIdType)))+"-bit ids.\n" "This configuration is inconsistent and is prone to crashes.\n" "Please recompile VTK with the advanced option VTK_USE_64BIT_IDS set to OFF.\n"); exit(0); } } iRunner::~iRunner() { if(mShell != 0) { iOutput::Display(MessageType::Error,"Invalid use of iRunner: class deleted before the launched shell is stopped; that causes a memory leak."); } if(mThreader != 0) mThreader->Delete(); } bool iRunner::Launch(int argc, const char **argv) { if(mShell != 0) { iOutput::Display(MessageType::Error,"Runner can run only one shell at a time."); return false; } // // Create the shell object // mShell = iShell::New(this,argc,argv); if(mShell == 0) { iOutput::Display(MessageType::Error,"Invalid shell specification."); return false; } if(mShell->IsFailed()) { iOutput::Display(MessageType::Error,"Shell failed to initialize."); return false; } if(mShell->PrintHelp()) { mShell->Delete(); mShell = 0; return false; } if(mShell->IsThreaded()) { if(mThreader == 0) { iOutput::Display(MessageType::Error,"Threader failed to initialize."); return false; } mThreadId = mThreader->SpawnThread(ThreadRunner,mShell); if(mThreadId < 0) { iOutput::Display(MessageType::Error,"Unable to start a new thread. Without threads IFrIT cannot be run in the external mode."); mShell->Delete(); mShell = 0; return false; } while(!mShell->IsRunning() && mThreader->IsThreadActive(mThreadId)!=0) { iSystem::Sleep(100); } if(mThreader->IsThreadActive(mThreadId) == 0) { mShell->Delete(); mShell = 0; return false; } } else { if(!RunShell(mShell)) { mShell = 0; return false; } } return true; } void iRunner::Stop() { if(mShell == 0 ) { iOutput::Display(MessageType::Error,"Cannot stop a shell that hasn't been launched."); return; } if(mShell->IsThreaded()) { if(!mShell->IsStopped()) // in case the interpreter was terminated before the shell was killed { mShell->Stop(); mThreader->TerminateThread(mThreadId); } } mShell->Delete(); mShell = 0; } void iRunner::Run(int argc, const char **argv) { if(this->Launch(argc,argv)) { if(mShell->IsThreaded()) { // // For now do this... // iScript *script = iScript::New(mShell); if(script == 0) { this->Stop(); iOutput::Display(MessageType::Error,"No script is available. Shell needs a script to run in the extending mode."); return; } cout << "Using scripting language: " << script->Name().ToCharPointer() << endl; if(!script->RunInterpreter()) { iOutput::Display(MessageType::Error,"This script does not have a full command interpreter."); } script->Delete(); } this->Stop(); } } ifrit-4.1.2/core/irunner.h0000674060175406010010000000400612641012535013776 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef IRUNNER_H #define IRUNNER_H class iShell; class iString; class vtkMultiThreader; // // Interface for starting the code in various ways // class iRunner { friend class iShell; public: iRunner(); virtual ~iRunner(); inline iShell* GetShell() const { return mShell; } // // The main driver that creates, runs, and deletes a shell in one call // Event loop is implemented via iScript interface // void Run(int argc, const char **argv); // // For external driving (launches but does not run an event loop in the extended mode). // Launched shell needs to be stopped explicitly for thread safety. // bool Launch(int argc, const char **argv); void Stop(); private: iShell *mShell; vtkMultiThreader *mThreader; int mThreadId; }; #endif // IRUNNER_H ifrit-4.1.2/core/iscript.cpp0000674060175406010010000000613712641012565014336 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "iscript.h" // // Actual base class // iScript::iScript(const iString& name, iShell *s) : iShellComponent(s), mName(name) { mIOHelper = 0; mObserver = 0; } iScript::~iScript() { } void iScript::Delete() { this->InstallIOHelper(0); this->InstallObserver(0); delete this; } void iScript::InstallObserver(iScriptObserver *obs) { if(mObserver != obs) { if(mObserver != 0) delete mObserver; mObserver = obs; if(mObserver != 0) mObserver->mScript = this; this->OnInstallObserver(); } } void iScript::InstallIOHelper(iScriptIOHelper *ioh) { if(mIOHelper != ioh) { if(mIOHelper != 0) delete mIOHelper; mIOHelper = ioh; this->OnInstallIOHelper(); } } void iScript::OnInstallObserver() { } void iScript::OnInstallIOHelper() { } // // Observer class // iScriptObserver::iScriptObserver() { mScript = 0; mIsEnabled = true; } iScriptObserver::~iScriptObserver() { } void iScriptObserver::Enable(bool s) { mIsEnabled = s; } bool iScriptObserver::IsTerminated() { if(mIsEnabled && mScript!=0) return this->IsTerminatedBody(); else return false; } void iScriptObserver::OnStart() { if(mIsEnabled && mScript!=0) this->OnStartBody(); } void iScriptObserver::OnStop(bool aborted) { if(mIsEnabled && mScript!=0) this->OnStopBody(aborted); } void iScriptObserver::OnBeginLine(int line, const iString &file) { if(mIsEnabled && mScript!=0) this->OnBeginLineBody(line,file); } void iScriptObserver::OnEndLine(int line, const iString &file) { if(mIsEnabled && mScript!=0) this->OnEndLineBody(line,file); } /* void iScriptObserver::OnFunctionCall(int line, const iString &file, const iString &fun) { if(mIsEnabled && mScript!=0) this->OnFunctionCallBody(line,file,fun); } void iScriptObserver::OnVariableChange(int line, const iString &file, const iString &var) { if(mIsEnabled && mScript!=0) this->OnVariableChangeBody(line,file,var); } */ ifrit-4.1.2/core/iscript.h0000674060175406010010000000700612641012535013774 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef ISCRIPT_H #define ISCRIPT_H #include "ishellcomponent.h" #include "istring.h" class iScriptIOHelper; class iScriptObserver; class iScript : public iShellComponent { public: static iScript* New(iShell *s); // factory method void Delete(); inline const iString& Name() const { return mName; } virtual iString GetPrompt1() const = 0; virtual iString GetPrompt2() const = 0; virtual const iString& CreateTemplate() const = 0; virtual const iString& GetScriptFileSuffix() const = 0; virtual bool IsTraceable() const = 0; virtual bool RunInterpreter() = 0; // return false if this script cannot run an interpreter virtual bool ExecuteSegment(const iString &text) = 0; // return false on error void InstallObserver(iScriptObserver *obs); void InstallIOHelper(iScriptIOHelper *ioh); protected: iScript(const iString& name, iShell *s); virtual ~iScript(); virtual void OnInstallObserver(); virtual void OnInstallIOHelper(); iString mName; iScriptObserver *mObserver; iScriptIOHelper *mIOHelper; private: iScript(const iScript&); // not implemented void operator=(const iScript&); }; class iScriptIOHelper { public: virtual iString Read() = 0; virtual int Write(const iString &str, bool err = false) = 0; }; class iScriptObserver { friend class iScript; public: virtual ~iScriptObserver(); void Enable(bool s); inline bool IsEnabled() const { return mIsEnabled; } void OnStart(); void OnStop(bool aborted); void OnBeginLine(int line, const iString &file); void OnEndLine(int line, const iString &file); bool IsTerminated(); //void OnFunctionCall(int line, const iString &file, const iString &fun); //void OnVariableChange(int line, const iString &file, const iString &var); protected: iScriptObserver(); iScript* Script() const { return mScript; } virtual void OnStartBody() = 0; virtual void OnStopBody(bool aborted) = 0; virtual void OnBeginLineBody(int line, const iString &file) = 0; virtual void OnEndLineBody(int line, const iString &file) = 0; virtual bool IsTerminatedBody() = 0; //virtual void OnFunctionCallBody(int line, const iString &file, const iString &fun) = 0; //virtual void OnVariableChangeBody(int line, const iString &file, const iString &var) = 0; private: iScript *mScript; bool mIsEnabled; }; #endif // ISCRIPT_H ifrit-4.1.2/core/iserialpipeline.h0000674060175406010010000000520412641012535015473 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // This is base class for all parallellizable pipelines // #ifndef ISERIALPIPELINE_H #define ISERIALPIPELINE_H #include "igenericfilter.h" template class iSerialPipeline : public Filter { public: virtual iSerialPipeline* Copy() const = 0; virtual float GetMemorySize() { return this->Filter::GetMemorySize() + this->GetContentsMemorySize(); } virtual void UpdateContents(int n, int info = 0) = 0; void SetGlobalInput(InputType *i) { this->mGlobalInput = i; } InputType* GetGlobalInput() const { return this->mGlobalInput; } virtual void SetNthInput(int num, vtkDataObject *input){ Filter::SetNthInput(num,input); } // vtkProcessObject::SetNthInput(num,input) is protected protected: iSerialPipeline(iViewSubject *vo, int numInputs) : Filter(vo,numInputs,true,true) { this->mGlobalInput = 0; } virtual float GetContentsMemorySize() const = 0; InputType *mGlobalInput; }; // // Create specific filters // typedef iSerialPipeline iPolyDataToPolyDataPipeline; typedef iSerialPipeline iGridDataToPolyDataPipeline; typedef iSerialPipeline iGridDataToGridDataPipeline; typedef iSerialPipeline iAnyDataToPolyDataPipeline; #endif // ISERIALPIPELINE_H ifrit-4.1.2/core/ishell.cpp0000674060175406010010000006035712641012565014145 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "ishell.h" #include "idatareader.h" #include "idatareaderobserver.h" #include "idirectory.h" #include "ierror.h" #include "iexception.h" #include "ifile.h" #include "iimagecomposer.h" #include "ioutputchannel.h" #include "ipalettecollection.h" #include "iparallel.h" #include "iparallelmanager.h" #include "irunner.h" #include "ishelleventobservers.h" #include "isystem.h" #include "iviewmodule.h" #include "iviewmodulecollection.h" #include "ivolumeviewsubject.h" #include #include #include #include #include #include #include #include #include // // Templates // #include "iarray.tlh" #include "iproperty.tlh" using namespace iParameter; const iString iShell::mShortOptionPrefix = "-"; const iString iShell::mLongOptionPrefix = "--"; class iInteractorEventObserver : public iEventObserver, public iShellComponent { public: vtkTypeMacro(iInteractorEventObserver,iEventObserver); static iInteractorEventObserver* New(iShell *s = 0) { IASSERT(s); return new iInteractorEventObserver(s); } void Activate(bool s) { mActive = s; } protected: iInteractorEventObserver(iShell *s) : iEventObserver(), iShellComponent(s) { mInUpdate = mActive = false; } virtual void ExecuteBody(vtkObject *caller, unsigned long event1, void *callData) { if(!mActive || mInUpdate) return; vtkRenderWindowInteractor *iren, *driver = vtkRenderWindowInteractor::SafeDownCast(caller); if(this->GetShell()!=0 && driver!=0) { int i; mInUpdate = true; for(i=0; iGetShell()->GetNumberOfViewModules(); i++) if((iren=this->GetShell()->GetViewModule(i)->GetRenderWindowInteractor())!=driver && iren!=0) { iren->SetControlKey(driver->GetControlKey()); iren->SetShiftKey(driver->GetShiftKey()); iren->SetEventPosition(driver->GetEventPosition()); iren->SetKeySym(driver->GetKeySym()); iren->InvokeEvent(event1,callData); } mInUpdate = false; } } bool mInUpdate, mActive; }; namespace iShell_Private { iString LongName("ifrit"); iString ShortName("i"); }; // // Main class // iShell::iShell(iRunner *runner, bool threaded, const iString &type, int argc, const char **argv) : iObject(0,iShell_Private::LongName,iShell_Private::ShortName), mType(type), iObjectConstructPropertyMacroS(Bool,iShell,AutoRender,ar), iObjectConstructPropertyMacroS(Int,iShell,OptimizationMode,om), iObjectConstructPropertyMacroS(Int,iShell,NumberOfProcessors,np), iObjectConstructPropertyMacroS(Bool,iShell,SynchronizeInteractors,si), iObjectConstructPropertyMacroSOP(threaded,Bool,iShell,Modal,m), iObjectConstructPropertyMacroGenericA1(String,iShell,RestoreState,restore,RestoreStateFromFile), iObjectConstructPropertyMacroGenericA1(String,iShell,SaveState,save,SaveStateToFile), iObjectConstructPropertyMacroA1(Int,iShell,SynchronizeCameras,sc) { mRenderMode = RenderMode::NoRender; mCanBeDeleted = true; Modal.AddFlag(iProperty::_OptionalInState); try { mRunner = runner; IASSERT(mRunner); mExitObserver = 0; mOutputChannel = 0; // // Members for threaded running // mIsThreaded = threaded; mMutex = vtkCriticalSection::New(); IERROR_CHECK_MEMORY(mMutex); mModal = mLastPushResult = true; mIsRunning = mIsStopped = mBlockAutoRender = mInPush = mIsFailed = false; mInitSteps = -1; mNumProcs = 0; mProgCur = -1; mProgMax = 1; // // Set environment variables // Is the base-dir environment variable set? // char *e = getenv("IFRIT_DIR"); if(e != 0) { mEnvironment[Environment::Base] = iString(e); if(mEnvironment[Environment::Base].IsEmpty()) mEnvironment[Environment::Base] = iDirectory::Current(); if(!mEnvironment[Environment::Base].EndsWith(iDirectory::Separator())) mEnvironment[Environment::Base] += iDirectory::Separator(); } else { // // Get the home directory, if it exists // e = getenv("APPDATA"); // windows? if(e != 0) { mEnvironment[Environment::Base] = iString(e) + iDirectory::Separator() + "IfrIT" + iDirectory::Separator(); } else // unix? { e = getenv("HOME"); mEnvironment[Environment::Base] = iString(e) + iDirectory::Separator() + ".ifrit" + iDirectory::Separator(); } // // Is it readable? // iDirectory dir; if(!dir.Open(mEnvironment[Environment::Base])) { // // try to create // if(!dir.Make(mEnvironment[Environment::Base])) { mEnvironment[Environment::Base] = iDirectory::Current(); } } } // // Read other environment here // e = getenv("IFRIT_DATA_DIR"); if(e != 0) mEnvironment[Environment::Data] = iString(e) + iDirectory::Separator(); else mEnvironment[Environment::Data] = iDirectory::Current(); e = getenv("IFRIT_IMAGE_DIR"); if(e != 0) mEnvironment[Environment::Image] = iString(e) + iDirectory::Separator(); else mEnvironment[Environment::Image] = iDirectory::Current(); e = getenv("IFRIT_SCRIPT_DIR"); if(e != 0) mEnvironment[Environment::Script] = iString(e) + iDirectory::Separator(); else mEnvironment[Environment::Script] = mEnvironment[Environment::Base]; e = getenv("IFRIT_PALETTE_DIR"); if(e != 0) mEnvironment[Environment::Palette] = iString(e) + iDirectory::Separator(); else mEnvironment[Environment::Palette] = mEnvironment[Environment::Base]; iDirectory::ExpandFileName(mEnvironment[Environment::Base]); iDirectory::ExpandFileName(mEnvironment[Environment::Data]); iDirectory::ExpandFileName(mEnvironment[Environment::Image]); iDirectory::ExpandFileName(mEnvironment[Environment::Script]); iDirectory::ExpandFileName(mEnvironment[Environment::Palette]); // // Define some basic command-line options // this->AddCommandLineOption("i","init-file","load the state from a file with name ",true); this->AddCommandLineOption("np","num-procs","set the number of processors to use to ",true); this->AddCommandLineOption("GPU","force-GPU","try to use GPU even if VTK does not find it",false); this->AddCommandLineOption("no-GPU","force-no-GPU","do not use GPU even if it is present on the system (useful for running IFrIT remotely)",false); mAutoRender = true; mBlockAutoRender = true; // block render requests while objects are being created mSynchronizeInteractors = false; // // Start with all members NULL // mParallelManager = 0; mParallelObserver = 0; mPalettes = 0; mViewModules = 0; int i; for(i=0; iDelete(); } bool iShell::PrintHelp() { // // On --help option print help and return before we created anything // if(mArgV.Size()>0 && (mArgV[0]=="-h" || mArgV[0]=="-help" || mArgV[0]=="--help")) { int j; iString sl, sh, s = "Format: ifrit [shell] [option] ... [data_dir_name]\n"; s += "Options:\n"; for(j=0; jOutputText(MessageType::Information,s); return true; } else return false; } bool iShell::Initialize() { try { if(!this->StartConstructor()) return false; mOutputChannel = this->CreateOutputChannel(); IASSERT(mOutputChannel); iOutput::AddChannel(mOutputChannel); mWorkTimer = vtkTimerLog::New(); IERROR_CHECK_MEMORY(mWorkTimer); mWorkTimer->StartTimer(); mInitSteps = 0; if(!this->ParseCommandLine()) return false; this->OnInitStart(); // // Parallel performance - this must be first, since many components are parallel workers as well // mParallelManager = iParallelManager::New(this); IERROR_CHECK_MEMORY(mParallelManager); if(mNumProcs > 0) mParallelManager->SetNumberOfProcessors(mNumProcs); mParallelObserver = iRequiredCast(INFO,this->CreateShellEventObserver(ShellObserver::ParallelUpdate)); IERROR_CHECK_MEMORY(mParallelObserver); mParallelManager->AddObserver(iParallel::InformationEvent,mParallelObserver); mPalettes = iPaletteCollection::New(this); IERROR_CHECK_MEMORY(mPalettes); // // Create observer for synchronizing interactors // mInteractorObserver = iInteractorEventObserver::New(this); IERROR_CHECK_MEMORY(mInteractorObserver); // // Execution observer for monitoring executon and diplaying work progress. // mExecutionObserver = iRequiredCast(INFO,this->CreateShellEventObserver(ShellObserver::Execution)); IERROR_CHECK_MEMORY(mExecutionObserver); // // DataReader observer for displying progress while loading data // mDataReaderObserver = this->CreateDataReaderObserver(); IERROR_CHECK_MEMORY(mDataReaderObserver); // // Composer must be created before view modules // mComposer = iImageComposer::New(this); IERROR_CHECK_MEMORY(mComposer); // // ViewModule family must be created after ControlModule is fully created // mViewModules = iViewModuleCollection::New(this); IERROR_CHECK_MEMORY(mViewModules); // // Finish construction of a child shell // if(!this->ConstructorBody()) return false; // // Set the init file name // if(mStateFileName.IsEmpty()) { iString fname = this->GetEnvironment(Environment::Base) + "ifrit.ini"; if(iFile::IsReadable(fname)) mStateFileName = fname; } // // Register all objects and their properties with the help factory // this->RegisterWithHelpFactory(); #ifdef I_DEBUG //iPaletteCollection::WritePaletteImages(this,"Work/docs/images"); //iHelpFactory::CreateUserGuide(); //exit(0); #endif // // Load the state file if needed // if(!mStateFileName.IsEmpty()) { this->OnInitState(); mLoadedState = this->RestoreStateFromFile(mStateFileName); } else mLoadedState = false; this->OnInitFinish(); mBlockAutoRender = false; mCanBeDeleted = false; return true; } catch(iException::GlobalExit) { mIsFailed = true; if(mExitObserver != 0) mExitObserver->OnExit(this); return false; } } void iShell::Delete() { // // Don't delete yet, wait for Finalize to complete - who knows where it is wandering... // int n = 0; while(!mCanBeDeleted && n<100) { iSystem::Sleep(100); n++; } if(n == 100) { IBUG_FATAL("Shell is unable to finish."); } else { // // Remove the output channel - after the next call it may be invalid // if(mOutputChannel != 0) { iOutput::RemoveChannel(mOutputChannel); mOutputChannel->Delete(); mOutputChannel = 0; } this->iObject::Delete(); } } bool iShell::StartConstructor() { return true; } void iShell::FinishDestructor() { } void iShell::Start() { try { mIsRunning = true; mIsStopped = false; this->StartBody(); } catch(iException::GlobalExit) { mIsFailed = true; mIsStopped = true; mInPush = false; mPushRequestQueue.Clear(); } // // Clean up, we are done // try { mIsRunning = false; mBlockAutoRender = true; // // Delete the shell components // this->DestructorBody(); // // We are just about to start deleting objects. First thing we do is to block all // observers since we do not know at each moment in the deleting process which objects // are still present and which have been already deleted. // iEventObserver::BlockAllEventObservers(true); // // Delete components // mViewModules->Delete(); mComposer->Delete(); delete mDataReaderObserver; mExecutionObserver->Delete(); mInteractorObserver->Delete(); mPalettes->Delete(); mParallelObserver->Delete(); mParallelManager->Delete(); mWorkTimer->Delete(); this->FinishDestructor(); mCanBeDeleted = true; } catch(iException::GlobalExit) { mIsFailed = true; mIsRunning = false; mBlockAutoRender = true; mCanBeDeleted = true; } if(mExitObserver != 0) mExitObserver->OnExit(this); } void iShell::Stop() { try { this->StopBody(); } catch(iException::GlobalExit) { mIsFailed = true; mInPush = false; mPushRequestQueue.Clear(); } mIsStopped = true; } void iShell::OutputText(int type, const iString &text) const { if(mOutputChannel != 0) { mOutputChannel->Display(type,text); } else { iOutput::Display(type,text); } } void iShell::PassRenderRequest(int mode) { switch(mode) { case RenderMode::NoRender: { break; } case RenderMode::All: { // // Render all // int j; for(j=0; jSize(); j++) this->RequestRender(mViewModules->GetViewModule(j)); break; } default: { IBUG_FATAL("Invalid RenderMode"); break; } } } bool iShell::IsImmediatePost() const { return !this->IsThreaded(); } void iShell::RequestRender(iViewModule* vm, bool force) { IASSERT(vm); if(force || this->IsAutoRendering()) { vm->ActualRender(); } } float iShell::GetMemorySize(int mod) const { float s = 0.0; if(mod < 0) { int i; for(i=0; iSize(); i++) s += mViewModules->GetViewModule(i)->GetMemorySize(); } else if(mod>=0 && modSize()) { mViewModules->GetViewModule(mod)->GetMemorySize(); } return s; } void iShell::SetExitObserver(iShellExitObserver *obs) { if(mExitObserver != 0) delete mExitObserver; mExitObserver = obs; } // // Saving and restoring the state // bool iShell::SaveStateToFile(const iString& str) { iString fname(str); if(fname.IsEmpty()) { fname = this->GetEnvironment(Environment::Base) + "ifrit.ini"; } if(fname[0] == '+') { fname.Replace(0,1,this->GetEnvironment(Environment::Base)); } iFile F(fname); if(!F.Open(iFile::_Write,iFile::_Text)) { this->OutputText(MessageType::Error,"Unable to open text file "+fname+" for writing."); return false; } // // Save the state of this shell and all its children // iString s; this->SaveStateToString(s); if(!F.WriteLine(s)) { F.Close(); return false; } F.Close(); return true; } bool iShell::RestoreStateFromFile(const iString& str) { iString fname(str); if(fname.IsEmpty()) { fname = this->GetEnvironment(Environment::Base) + "ifrit.ini"; } if(fname[0] == '+') { fname.Replace(0,1,this->GetEnvironment(Environment::Base)); } iFile F(fname); if(!F.Open(iFile::_Read,iFile::_Text)) { this->OutputText(MessageType::Error,"Unable to open text file "+fname+" for reading."); return false; } iObjectCollection::AutoCreate = true; mBlockAutoRender = true; iString line, s; mProgMax = 1; while(F.ReadLine(line)) { if(line.Contains(" = ") > 0) mProgMax++; s += line + "\n"; } F.Close(); mProgCur = 0; bool ret = this->LoadStateFromString(s); this->OnLoadStateAtomBody(-1); mProgCur = -1; mBlockAutoRender = false; iObjectCollection::AutoCreate = false; if(ret) { int i; for(i=0; iSize(); i++) mViewModules->GetViewModule(i)->RequestRender(); } else { this->OutputText(MessageType::Error,"The state file <"+fname+"> is corrupted or incomplete.\nSome properties may not have been set."); } return ret; } void iShell::OnLoadStateAtom() { if(mProgCur >= 0) { this->OnLoadStateAtomBody((100*mProgCur++)/mProgMax); } } iEventObserver* iShell::GetInteractorObserver() const { return mInteractorObserver; } int iShell::GetNumberOfViewModules() const { return mViewModules->Size(); } iViewModule* iShell::GetViewModule(int mod) const { if(mod>=0 && modSize()) { return mViewModules->GetViewModule(mod); } else { IBUG_FATAL("Invalid VM index"); return 0; } } // // We add/remove observers so that in the non-sync mode no extra callbacks take place. // bool iShell::SetAutoRender(bool s) { mAutoRender = s; return true; } bool iShell::SetSynchronizeInteractors(bool s) { mSynchronizeInteractors = s; mInteractorObserver->Activate(s); return true; } bool iShell::SetOptimizationMode(int m) { iDataConsumer::SetGlobalOptimizationMode(m); vtkMapper::SetGlobalImmediateModeRendering((m==DataConsumerOptimizationMode::OptimizeForMemory)?1:0); vtkDataObject::SetGlobalReleaseDataFlag((m==DataConsumerOptimizationMode::OptimizeForMemory)?1:0); // // We need to reset everything // int j; for(j=0; jSize(); j++) mViewModules->GetViewModule(j)->GetReader()->ResetPipeline(); return true; } int iShell::GetOptimizationMode() const { return iDataConsumer::GetGlobalOptimizationMode(); } bool iShell::SetNumberOfProcessors(int n) { if(n > mParallelManager->GetMaxNumberOfProcessors()) n = mParallelManager->GetMaxNumberOfProcessors(); if(n>=mParallelManager->GetMinNumberOfProcessors() && n<=mParallelManager->GetMaxNumberOfProcessors()) { mParallelManager->SetNumberOfProcessors(n); } else this->OutputText(MessageType::Warning,"Unable to set the number of processors."); // // We need always to return true, for the state files to work on any machine // return true; } int iShell::GetNumberOfProcessors() const { return mParallelManager->GetNumberOfProcessors(); } bool iShell::CallSynchronizeCameras(int v) { if (v >= 0 && v < mViewModules->Size()) { iViewModule *module = mViewModules->GetViewModule(v); IERROR_CHECK_MEMORY(module); int i; vtkCamera *c = module->GetRenderer()->GetActiveCamera(); double *fp = c->GetFocalPoint(); double *cp = c->GetPosition(); double *vu = c->GetViewUp(); double ps = c->GetParallelScale(); for (i = 0; i < mViewModules->Size(); i++) { c = mViewModules->GetViewModule(i)->GetRenderer()->GetActiveCamera(); c->SetFocalPoint(fp); c->SetPosition(cp); c->SetViewUp(vu); c->SetParallelScale(ps); mViewModules->GetViewModule(i)->RequestRender(); } return true; } else return false; } // // Environment querying // const iString& iShell::GetEnvironment(Environment::Type type) const { static const iString none; if(type>=0 && typeStopTimer(); if(mWorkTimer->GetElapsedTime() > 0.1) { mWorkTimer->StartTimer(); this->OnInitAtomBody(true); } else { this->OnInitAtomBody(false); } } void iShell::OnInitAtomBody(bool) { } void iShell::OnLoadStateAtomBody(int prog) { } void iShell::AddCommandLineOption(const iString &sname, const iString& lname, const iString &help, bool value) { Option tmp; tmp.ShortName = mShortOptionPrefix + sname; tmp.LongName = mLongOptionPrefix + lname; tmp.Help = help; tmp.NeedsValue = value; mOptions.Add(tmp); } bool iShell::ParseCommandLine() { // // Parse command-line options // int i = 0; while(i < mArgV.Size()) { int j; for(j=0; jOnCommandLineOption(mOptions[j].ShortName.Part(mShortOptionPrefix.Length()),mArgV[i])) return false; } else { this->OutputText(MessageType::Error,"Option "+mOptions[j].ShortName+" / "+mOptions[j].LongName+" requires an argument."); return false; } } else { if(!this->OnCommandLineOption(mOptions[j].ShortName.Part(mShortOptionPrefix.Length()),"")) return false; } break; } if(mArgV[i].BeginsWith(mOptions[j].ShortName+"=") || mArgV[i].BeginsWith(mOptions[j].LongName+"=")) { if(mOptions[j].NeedsValue) { int k = mArgV[i].Find('='); if(k > -1) { if(!this->OnCommandLineOption(mOptions[j].ShortName.Part(mShortOptionPrefix.Length()),mArgV[i].Part(k+1))) return false; break; } } this->OutputText(MessageType::Error,"Option "+mOptions[j].ShortName+" / "+mOptions[j].LongName+" requires an argument."); return false; } } if(j < mOptions.Size()) { mArgV.Remove(i); } else { if(i < mArgV.Size()) i++; } } // // Non-option arguments // if(!this->OnCommandLineArguments(mArgV)) return false; // // Not an option or known argument // if(mArgV.Size() == 1) { // // This must be the name of the default data directory // iDirectory d; if(d.Open(mArgV[0])) { d.Close(); mEnvironment[Environment::Data] = mArgV[0]; } else { this->OutputText(MessageType::Error,"Unable to open directory "+iString(mArgV[0])+"."); return false; } mArgV.Remove(0); } // // Unrecognized arguments // if(mArgV.Size() > 0) { this->OutputText(MessageType::Error,"Command-line argument "+iString(mArgV[0])+" is not supported."); return false; } return true; } bool iShell::OnCommandLineOption(const iString &sname, const iString& str) { if(sname == "np") { bool ok; int n = str.ToInt(ok); if(ok && n>0 && n<16385) mNumProcs = n; return true; } if(sname == "i") { iString fn(str); iDirectory::ExpandFileName(fn,this->GetEnvironment(Environment::Base)); if(iFile::IsReadable(fn)) { mStateFileName = fn; return true; } else { this->OutputText(MessageType::Error,"File "+fn+" is not accessible.\nIFrIT will now exit."); return false; } } if(sname == "GPU") { iVolumeViewSubject::SetGPUMode(1); return true; } if(sname == "no-GPU") { iVolumeViewSubject::SetGPUMode(-1); return true; } IBUG_ERROR("Comman-line option "+sname+" has been declared but not implemeneted."); return false; } bool iShell::OnCommandLineArguments(iArray &argv) { return true; } // // This is a part of message subsystem for thread-safe execution. // Functions begining with underscore can be called from the driver thread. // Functions ending with underscore should be called from the slave thread. // bool iShell::_RequestPush(iProperty::Key key) { // // Wait until the previous push is completed // while(mInPush) { iSystem::Sleep(1); } mMutex->Lock(); mPushRequestQueue.Add(key); mMutex->Unlock(); // // If post is modal, we wait for an asnwer // if(mModal) { while(this->HasPostedRequests()) // on failure mModal is set to false { iSystem::Sleep(1); } return mLastPushResult; } else return true; } void iShell::PushAllRequests_() { if(mInPush) return; mInPush = true; mMutex->Lock(); int i; const iProperty *prop; for(i=0; iPushPostedValue_(); if(!mLastPushResult && !mModal) { // // Set some kind of error, since none has been returned with the non-modal post // this->OutputText(MessageType::Error,"Calling object property <"+prop->Owner()->GetFullName()+"."+prop->LongName()+"> did not success."); } } } mPushRequestQueue.Clear(); mMutex->Unlock(); mInPush = false; } bool iShell::HasPostedRequests() const { return (mPushRequestQueue.Size() > 0); } bool iShell::SetModal(bool s) { mModal = s; return true; } void iShell::OnInitStart() { this->OutputText(MessageType::Information,"Initializing..."); } void iShell::OnInitState() { this->OutputText(MessageType::Information,"Loading the state file..."); } void iShell::OnInitFinish() { this->OutputText(MessageType::Information,"Initialization complete."); } ifrit-4.1.2/core/ishell.h0000775060175406010010000002145012641012535013600 0ustar HomeNone/*========================================================================= Program: Ionization FRont Interactive Tool (IFRIT) Language: C++ Copyright (c) 2002-2012 Nick Gnedin All rights reserved. This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation and appearing in the file LICENSE.GPL included in the packaging of this file. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ // // A base class for all GUI shells around the VTK-based core // #ifndef ISHELL_H #define ISHELL_H #include "iobject.h" #include "iarray.h" #include "istring.h" class iDataReaderObserver; class iEventObserver; class iFile; class iImageComposer; class iInteractorEventObserver; class iOutputChannel; class iPaletteCollection; class iParallelManager; class iParallelUpdateEventObserver; class iExecutionEventObserver; class iRunner; class iShellExitObserver; class iViewModule; class iViewModuleCollection; class vtkCriticalSection; class vtkMultiThreader; class vtkRenderWindow; class vtkRenderWindowInteractor; class vtkTimerLog; namespace iParameter { namespace Environment { enum Type { Base, Data, Image, Script, Palette, ScalarsData, VectorsData, TensorsData, ParticlesData, SIZE }; }; namespace ShellObserver { enum Type { Execution, ParallelUpdate }; }; namespace ViewModuleObserver { enum Type { Render, Pick }; }; }; class iShell : public iObject { friend class iRunner; public: vtkTypeMacro(iShell,iObject); virtual void Delete(); iObjectPropertyMacro1S(AutoRender,Bool); iObjectPropertyMacro2S(OptimizationMode,Int); iObjectPropertyMacro2S(NumberOfProcessors,Int); iObjectPropertyMacro1S(SynchronizeInteractors,Bool); iObjectPropertyMacro1S(Modal,Bool); iObjectPropertyMacroA1(SaveState,String); iObjectPropertyMacroA1(RestoreState,String); iObjectPropertyMacroA1(SynchronizeCameras,Int); // // Access to components // inline const iString& Type() const { return mType; } inline bool IsRunning() const { return mIsRunning; } inline bool IsStopped() const { return mIsStopped; } inline bool IsThreaded() const { return mIsThreaded; } inline bool IsFailed() const { return mIsFailed; } inline bool IsAutoRendering() const { return !mBlockAutoRender && mAutoRender; } const iString& GetEnvironment(iParameter::Environment::Type type) const; virtual bool SaveStateToFile(const iString& filename); virtual bool RestoreStateFromFile(const iString& filename); // // mod = -1: sum up all view modules // float GetMemorySize(int mod = -1) const; // // Interface for step-by-step execution // bool PrintHelp(); bool Initialize(); void Start(); void Stop(); // // Access to components // int GetNumberOfViewModules() const; iViewModule* GetViewModule(int mod) const; void RequestRender(iViewModule *vm, bool force = false); inline iImageComposer* GetImageComposer() const { return mComposer; } inline iParallelManager* GetParallelManager() const { return mParallelManager; } inline iPaletteCollection* GetPalettes() const { return mPalettes; } inline iDataReaderObserver* GetDataReaderObserver() const { return mDataReaderObserver; } inline iExecutionEventObserver* GetExecutionEventObserver() const { return mExecutionObserver; } iEventObserver* GetInteractorObserver() const; void OnInitAtom(); void SetExitObserver(iShellExitObserver *obs); // // I still haven't decided what the proper way to output text is - either // through the "cloud" iOutput or via shells own OutputChannel. To avoid // invasive changes in the future, this choice is made in this function, and // all ShellComponents should use it to display output. // void OutputText(int type, const iString &text) const; // // Factory methods for ViewModule // virtual vtkRenderWindow* CreateRenderWindow(iViewModule *vm, bool stereo) const = 0; virtual vtkRenderWindowInteractor* CreateRenderWindowInteractor(iViewModule *vm) const = 0; virtual iEventObserver* CreateViewModuleEventObserver(iParameter::ViewModuleObserver::Type type, iViewModule *vm) const = 0; protected: iShell(iRunner *runner, bool threaded, const iString &type, int argc, const char **argv); virtual ~iShell(); // // For thread safety, the constructor of a child shell should be trivial // (only set command-line options and initialize simple members), and all // constructor/destructor work must be done in the following functions: // virtual bool StartConstructor(); // ran before visual modules are created virtual bool ConstructorBody() = 0; virtual void DestructorBody() = 0; virtual void FinishDestructor(); // ran after visual modules are deleted virtual void StartBody() = 0; virtual void StopBody() = 0; // // These functions can be overwritten in a child class to provide more information about the initialization process // virtual void OnInitStart(); virtual void OnInitState(); virtual void OnInitFinish(); // // These functions can be used to animate the initialization/load state file progress. // Do nothing by default. // virtual void OnInitAtomBody(bool timed); virtual void OnLoadStateAtomBody(int prog); // // This functions parse command-line options and other argumenst // virtual bool OnCommandLineOption(const iString &sname, const iString& value); virtual bool OnCommandLineArguments(iArray &argv); // // Factory methods for itself // virtual iDataReaderObserver* CreateDataReaderObserver() = 0; virtual iEventObserver* CreateShellEventObserver(iParameter::ShellObserver::Type type) = 0; virtual iOutputChannel* CreateOutputChannel() = 0; // // *** no inheritable functions below this point *** // virtual void PassRenderRequest(int mode); virtual bool IsImmediatePost() const; // // This functions ads command-line options. // void AddCommandLineOption(const iString &sname, const iString& lname, const iString &help, bool value); void OnLoadStateAtom(); // // Slots // void SetStateFile(const iString &name); void SetNumProcs(const iString &str); void ForceGPU(); void ForceNoGPU(); // // A timer for diverse use // vtkTimerLog *mWorkTimer; bool mBlockAutoRender, mLoadedState, mIsFailed; // // View Modules // iViewModuleCollection *mViewModules; static iShell* New(){ return 0; } private: // // Factory method // static iShell* New(iRunner *runner, int argc, const char **argv); struct Option { iString ShortName, LongName; iString Help; bool NeedsValue; Option() { NeedsValue = false; } }; bool ParseCommandLine(); static const iString mShortOptionPrefix, mLongOptionPrefix; iArray