0027350: Support for Universal Windows Platform
authorski <ski@opencascade.com>
Fri, 12 Aug 2016 15:38:48 +0000 (18:38 +0300)
committerabv <abv@opencascade.com>
Fri, 26 Aug 2016 06:43:29 +0000 (09:43 +0300)
- Toolchain file to configure a Visual Studio generator for a Windows 10 Universal Application was added (CMake).
- There is no support for environment variables in UWP.
- SID is not supported (were excluded).
- Windows registry is not supported (were excluded).
- Mess with usage of Unicode/ANSI was corrected.
- Added sample to check UWP functionality.
- Excluded usage of methods with Unicode characters where it is possible.
- Minor corrections to allow building OCAF (except TKVCAF) and DE (except VRML and XDE)
- Building of unsupported modules for UWP platform is off by default .
- Checking of DataExchange functionality was added to XAML (UWP) sample.
- Added information about UWP to the documentation.
- Update of results of merge with issue 27801

69 files changed:
CMakeLists.txt
adm/cmake/vardescr.cmake
adm/templates/uwp.toolchain.config.cmake [new file with mode: 0644]
dox/dev_guides/building/cmake/cmake.md
dox/dev_guides/debug/debug.md
samples/xaml/App.xaml [new file with mode: 0644]
samples/xaml/App.xaml.cpp [new file with mode: 0644]
samples/xaml/App.xaml.h [new file with mode: 0644]
samples/xaml/Assets/LockScreenLogo.scale-200.png [new file with mode: 0644]
samples/xaml/Assets/SplashScreen.scale-200.png [new file with mode: 0644]
samples/xaml/Assets/Square150x150Logo.scale-200.png [new file with mode: 0644]
samples/xaml/Assets/Square44x44Logo.scale-200.png [new file with mode: 0644]
samples/xaml/Assets/Square44x44Logo.targetsize-24_altform-unplated.png [new file with mode: 0644]
samples/xaml/Assets/StoreLogo.png [new file with mode: 0644]
samples/xaml/Assets/Wide310x150Logo.scale-200.png [new file with mode: 0644]
samples/xaml/CMakeLists.txt [new file with mode: 0644]
samples/xaml/MainPage.xaml [new file with mode: 0644]
samples/xaml/MainPage.xaml.cpp [new file with mode: 0644]
samples/xaml/MainPage.xaml.h [new file with mode: 0644]
samples/xaml/Package.appxmanifest [new file with mode: 0644]
samples/xaml/ReadMe.md [new file with mode: 0644]
samples/xaml/pch.cpp [new file with mode: 0644]
samples/xaml/pch.h [new file with mode: 0644]
samples/xaml/uwp_TemporaryKey.pfx [new file with mode: 0644]
src/AppParCurves/AppParCurves_BSpGradient.gxx
src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx
src/BRepPrimAPI/BRepPrimAPI_MakeCone.cxx
src/BRepPrimAPI/BRepPrimAPI_MakeCylinder.cxx
src/BRepPrimAPI/BRepPrimAPI_MakeSphere.cxx
src/BRepTools/BRepTools_NurbsConvertModification.cxx
src/BiTgte/BiTgte_Blend.cxx
src/CDF/CDF.hxx
src/CDF/CDF_Application.cxx
src/CDF/CDF_StoreList.cxx
src/CDF/CDF_Timer.cxx [deleted file]
src/CDF/CDF_Timer.hxx [deleted file]
src/CDF/FILES
src/ChFi3d/ChFi3d_Builder_0.cxx
src/ChFi3d/ChFi3d_Builder_6.cxx
src/ChFi3d/ChFi3d_Debug.cxx
src/ChFi3d/ChFi3d_FilBuilder.cxx
src/IFSelect/IFSelect_SessionPilot.cxx
src/OSD/OSD.hxx
src/OSD/OSD_Chronometer.cxx
src/OSD/OSD_Directory.cxx
src/OSD/OSD_DirectoryIterator.cxx
src/OSD/OSD_Disk.cxx
src/OSD/OSD_Environment.cxx
src/OSD/OSD_Error.cxx
src/OSD/OSD_File.cxx
src/OSD/OSD_FileIterator.cxx
src/OSD/OSD_FileNode.cxx
src/OSD/OSD_FileNode.hxx
src/OSD/OSD_Host.cxx
src/OSD/OSD_MemInfo.cxx
src/OSD/OSD_Parallel.cxx
src/OSD/OSD_Process.cxx
src/OSD/OSD_SharedLibrary.cxx
src/OSD/OSD_Timer.cxx
src/OSD/OSD_WNT.cxx
src/OSD/OSD_signal.cxx
src/Resource/Resource_Manager.cxx
src/Standard/Standard.cxx
src/Standard/Standard_MMgrOpt.cxx
src/Standard/Standard_Macro.hxx
src/TKSTL/EXTERNLIB
src/TopOpeBRep/TopOpeBRep_EdgesIntersector.cxx
src/TopOpeBRepTool/TopOpeBRepTool_CurveTool.cxx
src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx

index de625e7..3567140 100644 (file)
@@ -65,7 +65,7 @@ if (DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE) # single-configuration ge
 endif()
 
 # enable extended messages of many OCCT algorithms
-if ((SINGLE_GENERATOR AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR NOT SINGLE_GENERATOR)
+if (((SINGLE_GENERATOR AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR NOT SINGLE_GENERATOR) AND (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore"))
   if (NOT BUILD_WITH_DEBUG)
     set (BUILD_WITH_DEBUG OFF CACHE BOOL "${BUILD_WITH_DEBUG_DESCR}")
   endif()
@@ -309,6 +309,15 @@ if (MSVC)
   set (BUILD_MODULE_MfcSamples OFF CACHE BOOL "${BUILD_MODULE_MfcSamples_DESCR}")
 endif()
 
+# uwp sample
+if (MSVC)
+  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
+    set (BUILD_MODULE_UwpSample OFF CACHE BOOL "${BUILD_MODULE_UwpSample_DESCR}")
+  else()
+    unset (BUILD_MODULE_UwpSample)
+  endif()
+endif()
+
 # whether use optional 3rdparty or not
 if (APPLE)
   set (USE_GLX OFF CACHE BOOL "${USE_GLX_DESCR}")
@@ -647,6 +656,10 @@ if (INSTALL_SAMPLES)
     OCCT_INSTALL_FILE_OR_DIR ("samples/CSharp" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}")
     OCCT_INSTALL_FILE_OR_DIR ("samples/mfc" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}")
 
+    if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
+      OCCT_INSTALL_FILE_OR_DIR ("samples/xaml" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}")
+    endif()
+
     install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}/CSharp" RENAME "env.${SCRIPT_EXT}")
     install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}/mfc/standard" RENAME "env.${SCRIPT_EXT}")
   endif()
@@ -795,6 +808,10 @@ if (BUILD_MODULE_MfcSamples)
   add_subdirectory(samples/mfc/standard/10_Convert)
 endif()
 
+if (BUILD_MODULE_UwpSample)
+  add_subdirectory(samples/xaml)
+endif()
+
 # Prepare variables for configuration of OpenCASCADE cmake config file
 set (OCCT_MODULES_ENABLED)
 set (OCCT_LIBRARIES)
index c406cd4..eb64e81 100644 (file)
@@ -108,6 +108,9 @@ set (BUILD_MODULE_MfcSamples_DESCR
 These samples show some possibilities of using OCCT and they can be executed
 with script samples.bat from the installation directory (INSTALL_DIR)")
 
+set (BUILD_MODULE_UwpSample_DESCR
+"Indicates whether OCCT UWP sample should be built together with OCCT.")
+
 set (BUILD_DOC_Overview_DESCR
 "Indicates whether OCCT overview documentation project (Markdown format) should be
 created together with OCCT. It is not built together with OCCT. Checking this options
@@ -144,5 +147,11 @@ set (USE_GLX_DESCR "Indicates whether X11 OpenGl on OSX is used or not")
 set (USE_D3D_DESCR "Indicates whether optional Direct3D wrapper in OCCT visualization module should be build or not")
 
 macro (BUILD_MODULE MODULE_NAME)
-  set (BUILD_MODULE_${MODULE_NAME} ON CACHE BOOL "${BUILD_MODULE_${MODULE_NAME}_DESCR}")
+  set (ENABLE_MODULE TRUE)
+  set (OCCT_MODULES_FOR_UWP FoundationClasses ModelingAlgorithms ModelingData)
+  list (FIND OCCT_MODULES_FOR_UWP ${OCCT_MODULE} CAN_BE_USED_IN_UWP)
+  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" AND CAN_BE_USED_IN_UWP EQUAL -1)
+    set (ENABLE_MODULE FALSE)
+  endif()
+  set (BUILD_MODULE_${MODULE_NAME} ${ENABLE_MODULE} CACHE BOOL "${BUILD_MODULE_${MODULE_NAME}_DESCR}")
 endmacro()
diff --git a/adm/templates/uwp.toolchain.config.cmake b/adm/templates/uwp.toolchain.config.cmake
new file mode 100644 (file)
index 0000000..4dbd2ae
--- /dev/null
@@ -0,0 +1,5 @@
+# A toolchain file to configure a Visual Studio generator for a Windows 10 Universal Application (UWP)
+# Specify the CMAKE_SYSTEM_VERSION variable to be 10.0 to build with the latest available Windows 10 SDK.
+
+set (CMAKE_SYSTEM_NAME WindowsStore)
+set (CMAKE_SYSTEM_VERSION 10.0)
index ab4314b..c089273 100644 (file)
@@ -60,6 +60,10 @@ Once the source and build directories are selected, "Configure" button should be
 
 @figure{/dev_guides/building/cmake/images/cmake_image002.png}
 
+To build OCCT with using Universal Windows Platform (UWP) specify path to toolchain file for cross-compiling <i>d:/occt/adm/templates/uwp.toolchain.config.cmake</i>.
+
+**Note**: Universal Windows Platform (UWP) is supported only on "Visual Studio 14 2015". File <i>d:/occt/samples/xaml/ReadMe.md</i> desribes building procedure of XAML (UWP) sample.
+
 Once "Finish" button is pressed, the first pass of the configuration process is executed. At the end of the process, CMake outputs the list of environment variables which have to be properly specified for successful configuration. 
 
 @figure{/dev_guides/building/cmake/images/cmake_image003.png}
index 963957c..d48434f 100644 (file)
@@ -35,6 +35,8 @@ This feature can be activated by defining environment variable *CSF_DEBUG_BOP*,
 
 The diagnostic code checks validity of the input arguments and the result of each Boolean operation. When an invalid situation is detected, the report consisting of argument shapes and a DRAW script to reproduce the problematic operation is saved to the directory pointed by *CSF_DEBUG_BOP*.
 
+Note that this feature does not applicable for UWP build.
+
 @section occt_debug_call Functions for calling from debugger
 
 Modern interactive debuggers provide the possibility to execute application code at a program break point. This feature can be used to analyse the temporary objects available only in the context of the debugged code. OCCT provides several global functions that can be used in this way.
diff --git a/samples/xaml/App.xaml b/samples/xaml/App.xaml
new file mode 100644 (file)
index 0000000..e922bc1
--- /dev/null
@@ -0,0 +1,7 @@
+<Application
+  x:Class="uwp.App"
+  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+  xmlns:local="using:uwp"
+  RequestedTheme="Light">
+</Application>
diff --git a/samples/xaml/App.xaml.cpp b/samples/xaml/App.xaml.cpp
new file mode 100644 (file)
index 0000000..a948197
--- /dev/null
@@ -0,0 +1,124 @@
+//
+// App.xaml.cpp
+// Implementation of the App class.
+//
+
+#include "pch.h"
+#include "MainPage.xaml.h"
+
+using namespace uwp;
+
+using namespace Platform;
+using namespace Windows::ApplicationModel;
+using namespace Windows::ApplicationModel::Activation;
+using namespace Windows::Foundation;
+using namespace Windows::Foundation::Collections;
+using namespace Windows::UI::Xaml;
+using namespace Windows::UI::Xaml::Controls;
+using namespace Windows::UI::Xaml::Controls::Primitives;
+using namespace Windows::UI::Xaml::Data;
+using namespace Windows::UI::Xaml::Input;
+using namespace Windows::UI::Xaml::Interop;
+using namespace Windows::UI::Xaml::Media;
+using namespace Windows::UI::Xaml::Navigation;
+
+/// <summary>
+/// Initializes the singleton application object.  This is the first line of authored code
+/// executed, and as such is the logical equivalent of main() or WinMain().
+/// </summary>
+App::App()
+{
+  InitializeComponent();
+  Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
+}
+
+/// <summary>
+/// Invoked when the application is launched normally by the end user.  Other entry points
+/// will be used such as when the application is launched to open a specific file.
+/// </summary>
+/// <param name="theEvent">Details about the launch request and process.</param>
+void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ theEvent)
+{
+#if _DEBUG
+  // Show graphics profiling information while debugging.
+  if (IsDebuggerPresent())
+  {
+    // Display the current frame rate counters
+    DebugSettings->EnableFrameRateCounter = true;
+  }
+#endif
+  auto rootFrame = dynamic_cast<Frame^>(Window::Current->Content);
+
+  // Do not repeat app initialization when the Window already has content,
+  // just ensure that the window is active
+  if (rootFrame == nullptr)
+  {
+    // Create a Frame to act as the navigation context and associate it with
+    // a SuspensionManager key
+    rootFrame = ref new Frame();
+
+    rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed);
+
+    if (theEvent->PreviousExecutionState == ApplicationExecutionState::Terminated)
+    {
+      // TODO: Restore the saved session state only when appropriate, scheduling the
+      // final launch steps after the restore is complete
+
+    }
+
+    if (theEvent->PrelaunchActivated == false)
+    {
+      if (rootFrame->Content == nullptr)
+      {
+        // When the navigation stack isn't restored navigate to the first page,
+        // configuring the new page by passing required information as a navigation
+        // parameter
+        rootFrame->Navigate(TypeName(MainPage::typeid), theEvent->Arguments);
+      }
+      // Place the frame in the current Window
+      Window::Current->Content = rootFrame;
+      // Ensure the current window is active
+      Window::Current->Activate();
+    }
+  }
+  else
+  {
+    if (theEvent->PrelaunchActivated == false)
+    {
+      if (rootFrame->Content == nullptr)
+      {
+        // When the navigation stack isn't restored navigate to the first page,
+        // configuring the new page by passing required information as a navigation
+        // parameter
+        rootFrame->Navigate(TypeName(MainPage::typeid), theEvent->Arguments);
+      }
+      // Ensure the current window is active
+      Window::Current->Activate();
+    }
+  }
+}
+
+/// <summary>
+/// Invoked when application execution is being suspended.  Application state is saved
+/// without knowing whether the application will be terminated or resumed with the contents
+/// of memory still intact.
+/// </summary>
+/// <param name="theSender">The source of the suspend request.</param>
+/// <param name="theEvent">Details about the suspend request.</param>
+void App::OnSuspending(Object^ theSender, SuspendingEventArgs^ theEvent)
+{
+  (void)theSender;  // Unused parameter
+  (void)theEvent;   // Unused parameter
+
+                    //TODO: Save application state and stop any background activity
+}
+
+/// <summary>
+/// Invoked when Navigation to a certain page fails
+/// </summary>
+/// <param name="theSender">The Frame which failed navigation</param>
+/// <param name="theEvent">Details about the navigation failure</param>
+void App::OnNavigationFailed(Platform::Object ^theSender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^theEvent)
+{
+  throw ref new FailureException("Failed to load Page " + theEvent->SourcePageType.Name);
+}
\ No newline at end of file
diff --git a/samples/xaml/App.xaml.h b/samples/xaml/App.xaml.h
new file mode 100644 (file)
index 0000000..20cba08
--- /dev/null
@@ -0,0 +1,27 @@
+//
+// App.xaml.h
+// Declaration of the App class.
+//
+
+#pragma once
+
+#include "App.g.h"
+
+namespace uwp
+{
+  /// <summary>
+  /// Provides application-specific behavior to supplement the default Application class.
+  /// </summary>
+  ref class App sealed
+  {
+  protected:
+    virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ theEvent) override;
+
+  internal:
+    App();
+
+  private:
+    void OnSuspending(Platform::Object^ theSender, Windows::ApplicationModel::SuspendingEventArgs^ theEvent);
+    void OnNavigationFailed(Platform::Object ^theSender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^theEvent);
+  };
+}
diff --git a/samples/xaml/Assets/LockScreenLogo.scale-200.png b/samples/xaml/Assets/LockScreenLogo.scale-200.png
new file mode 100644 (file)
index 0000000..735f57a
Binary files /dev/null and b/samples/xaml/Assets/LockScreenLogo.scale-200.png differ
diff --git a/samples/xaml/Assets/SplashScreen.scale-200.png b/samples/xaml/Assets/SplashScreen.scale-200.png
new file mode 100644 (file)
index 0000000..023e7f1
Binary files /dev/null and b/samples/xaml/Assets/SplashScreen.scale-200.png differ
diff --git a/samples/xaml/Assets/Square150x150Logo.scale-200.png b/samples/xaml/Assets/Square150x150Logo.scale-200.png
new file mode 100644 (file)
index 0000000..af49fec
Binary files /dev/null and b/samples/xaml/Assets/Square150x150Logo.scale-200.png differ
diff --git a/samples/xaml/Assets/Square44x44Logo.scale-200.png b/samples/xaml/Assets/Square44x44Logo.scale-200.png
new file mode 100644 (file)
index 0000000..ce342a2
Binary files /dev/null and b/samples/xaml/Assets/Square44x44Logo.scale-200.png differ
diff --git a/samples/xaml/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/samples/xaml/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
new file mode 100644 (file)
index 0000000..f6c02ce
Binary files /dev/null and b/samples/xaml/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ
diff --git a/samples/xaml/Assets/StoreLogo.png b/samples/xaml/Assets/StoreLogo.png
new file mode 100644 (file)
index 0000000..7385b56
Binary files /dev/null and b/samples/xaml/Assets/StoreLogo.png differ
diff --git a/samples/xaml/Assets/Wide310x150Logo.scale-200.png b/samples/xaml/Assets/Wide310x150Logo.scale-200.png
new file mode 100644 (file)
index 0000000..288995b
Binary files /dev/null and b/samples/xaml/Assets/Wide310x150Logo.scale-200.png differ
diff --git a/samples/xaml/CMakeLists.txt b/samples/xaml/CMakeLists.txt
new file mode 100644 (file)
index 0000000..26d988b
--- /dev/null
@@ -0,0 +1,99 @@
+cmake_minimum_required(VERSION 3.4.0)
+project(uwp)
+
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+
+set(SOURCE_FILES
+  App.xaml.cpp
+  MainPage.xaml.cpp
+  pch.cpp
+  )
+
+set(HEADER_FILES
+  App.xaml.h
+  MainPage.xaml.h
+  pch.h
+  )
+
+set(XAML_FILES
+  App.xaml
+  MainPage.xaml
+  )
+
+set(ASSET_FILES
+    Assets/LockScreenLogo.scale-200.png
+    Assets/SplashScreen.scale-200.png
+    Assets/Square150x150Logo.scale-200.png
+    Assets/Square44x44Logo.scale-200.png
+    Assets/Square44x44Logo.targetsize-24_altform-unplated.png
+    Assets/StoreLogo.png
+    Assets/Wide310x150Logo.scale-200.png
+    )
+
+set(CONTENT_FILES
+    Package.appxmanifest
+    )
+
+set(RESOURCE_FILES
+  ${CONTENT_FILES} ${ASSET_FILES}
+  uwp_TemporaryKey.pfx)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+set_property(SOURCE ${CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
+set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
+set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "Assets")
+
+set_property(SOURCE "App.xaml" PROPERTY VS_XAML_TYPE "ApplicationDefinition")
+
+source_group("Source Files" FILES ${SOURCE_FILES})
+source_group("Header Files" FILES ${HEADER_FILES})
+source_group("Resource Files" FILES ${RESOURCE_FILES})
+source_group("Xaml Files" FILES ${XAML_FILES})
+
+add_executable(uwp WIN32 ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES} ${XAML_FILES})
+
+set_property(TARGET uwp PROPERTY VS_WINRT_COMPONENT TRUE)
+
+set_property (TARGET uwp PROPERTY FOLDER Samples)
+
+if (SINGLE_GENERATOR)
+  install (TARGETS uwp DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_BIN}")
+else()
+  install (TARGETS uwp
+           CONFIGURATIONS Release RelWithDebInfo
+           DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_BIN}")
+  install (TARGETS uwp
+           CONFIGURATIONS Debug
+           DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_BIN}d")
+endif()
+
+#include_directories
+
+# OCCT libraries for using
+set (uwp_USED_LIBS        TKernel
+                          TKMath
+                          TKG2d
+                          TKG3d
+                          TKGeomBase
+                          TKBRep
+                          TKGeomAlgo
+                          TKTopAlgo
+                          TKPrim
+                          TKShHealing
+                          TKBO
+                          TKBool
+                          TKFillet
+                          TKMesh
+                          TKFeat
+                          TKHLR
+                          TKOffset
+                          TKXMesh
+                          TKIGES
+                          TKSTEP
+                          TKXSBase
+                          TKSTL
+#                         TKVRML
+                          )
+
+target_link_libraries (uwp ${uwp_USED_LIBS})
\ No newline at end of file
diff --git a/samples/xaml/MainPage.xaml b/samples/xaml/MainPage.xaml
new file mode 100644 (file)
index 0000000..58ca32c
--- /dev/null
@@ -0,0 +1,47 @@
+<Page
+  x:Class="uwp.MainPage"
+  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+  xmlns:local="using:uwp"
+  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+  mc:Ignorable="d">
+
+  <!-- Common grid-->
+  <Grid x:Name="contentPanel" HorizontalAlignment="Center" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" MinWidth="800" MinHeight="800">
+    <Grid.RowDefinitions>
+      <RowDefinition MinHeight="40" MaxHeight="40"/>
+      <RowDefinition MinHeight="30" MaxHeight="30"/>
+      <RowDefinition MinHeight="30"/>
+    </Grid.RowDefinitions>
+
+    <!-- Grid for buttons (locates at first row of Common grid)-->
+    <Grid x:Name="buttonPanel" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Grid.Row="0">
+      <Grid.RowDefinitions>
+        <RowDefinition MinHeight="40"/>
+      </Grid.RowDefinitions>
+      <Grid.ColumnDefinitions>
+        <ColumnDefinition MinWidth="190"/>
+        <ColumnDefinition MinWidth="190"/>
+        <ColumnDefinition MinWidth="190"/>
+        <ColumnDefinition MinWidth="190"/>
+        <ColumnDefinition MinWidth="190"/>
+      </Grid.ColumnDefinitions>
+      <Button x:Name="offset"  MaxHeight="30" MinHeight="30" MaxWidth="180" MinWidth="180" Content="Test offset"                 Grid.Row="0" Grid.Column="0" Click="OnClickOffset"/>
+      <Button x:Name="mesh"    MaxHeight="30" MinHeight="30" MaxWidth="180" MinWidth="180" Content="Test mesh"                   Grid.Row="0" Grid.Column="1" Click="OnClickMesh"/>
+      <Button x:Name="boolean" MaxHeight="30" MinHeight="30" MaxWidth="180" MinWidth="180" Content="Test boolean operation"      Grid.Row="0" Grid.Column="2" Click="OnClickBoolean"/>
+      <Button x:Name="tmpdir"  MaxHeight="30" MinHeight="30" MaxWidth="180" MinWidth="180" Content="Create temp file"            Grid.Row="0" Grid.Column="3" Click="OnClickBuildTemporary"/>
+      <Button x:Name="de"      MaxHeight="30" MinHeight="30" MaxWidth="180" MinWidth="180" Content="Test DataExchange"           Grid.Row="0" Grid.Column="4" Click="OnClickDataExchange"/>
+    </Grid>
+
+    <!-- TextBlock for label -->
+    <StackPanel Grid.Row="1"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
+      <TextBlock Text="Output:" HorizontalAlignment="Left" Grid.Row="1"/>
+    </StackPanel>
+
+    <!-- TextBlock for output information -->
+    <StackPanel Grid.Row="2"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
+      <TextBlock x:Name="Output_TextBlock" Text="" HorizontalAlignment="Left" Grid.Row="2"/>
+    </StackPanel>
+  </Grid>
+</Page>
diff --git a/samples/xaml/MainPage.xaml.cpp b/samples/xaml/MainPage.xaml.cpp
new file mode 100644 (file)
index 0000000..cee94f5
--- /dev/null
@@ -0,0 +1,457 @@
+//
+// MainPage.xaml.cpp
+// Implementation of the MainPage class.
+//
+
+#include "pch.h"
+#include "MainPage.xaml.h"
+
+using namespace uwp;
+
+using namespace Platform;
+using namespace Windows::Foundation;
+using namespace Windows::Foundation::Collections;
+using namespace Windows::UI::ViewManagement;
+using namespace Windows::UI::Xaml;
+using namespace Windows::UI::Xaml::Controls;
+using namespace Windows::UI::Xaml::Controls::Primitives;
+using namespace Windows::UI::Xaml::Data;
+using namespace Windows::UI::Xaml::Input;
+using namespace Windows::UI::Xaml::Media;
+using namespace Windows::UI::Xaml::Navigation;
+
+using namespace Windows::UI::Popups;
+
+#include <BRepAlgo.hxx>
+#include <BRepAlgoAPI_Fuse.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
+#include <BRepPrimAPI_MakeBox.hxx>
+#include <BRepPrimAPI_MakeSphere.hxx>
+#include <BRepTools.hxx>
+#include <Geom2dAPI_PointsToBSpline.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <Geom2d_OffsetCurve.hxx>
+#include <gp_Pnt.hxx>
+#include <IGESControl_Controller.hxx>
+#include <IGESControl_Reader.hxx>
+#include <IGESControl_Writer.hxx>
+#include <Interface_Static.hxx>
+#include <OSD_Directory.hxx>
+#include <OSD_File.hxx>
+#include <OSD_Path.hxx>
+#include <OSD_Protection.hxx>
+#include <STEPControl_Reader.hxx>
+#include <STEPControl_Writer.hxx>
+#include <StlAPI_Writer.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <VrmlAPI_Writer.hxx>
+
+#include <Strsafe.h>
+
+//=======================================================================
+//function : MainPage
+//purpose  :
+//=======================================================================
+MainPage::MainPage()
+{
+  InitializeComponent();
+  ApplicationView::PreferredLaunchViewSize = Size(1000, 500);
+  ApplicationView::PreferredLaunchWindowingMode = ApplicationViewWindowingMode::PreferredLaunchViewSize;
+}
+
+//=======================================================================
+//function : Throw
+//purpose  : Test offset functionality
+//=======================================================================
+void MainPage::OnClickOffset(Platform::Object^  theSender,
+  Windows::UI::Xaml::Input::PointerRoutedEventArgs^ theEvent)
+{
+  TColgp_Array1OfPnt2d array(1, 5); // sizing array
+  array.SetValue(1, gp_Pnt2d(-4, 0)); array.SetValue(2, gp_Pnt2d(-7, 2));
+  array.SetValue(3, gp_Pnt2d(-6, 3)); array.SetValue(4, gp_Pnt2d(-4, 3));
+  array.SetValue(5, gp_Pnt2d(-3, 5));
+  Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);
+
+  Standard_Real dist = 1;
+  Handle(Geom2d_OffsetCurve) OC =
+    new Geom2d_OffsetCurve(SPL1, dist);
+  Standard_Real dist2 = 1.5;
+  Handle(Geom2d_OffsetCurve) OC2 =
+    new Geom2d_OffsetCurve(SPL1, dist2);
+
+  Platform::String ^aMessage;
+
+  if (OC.IsNull()) {
+    aMessage = "Error: could not create offset curve with offset distance " + dist;
+  } else if (OC2.IsNull()) {
+    aMessage = "Error: could not create offset curve with offset distance 1.5" + dist2;
+  } else {
+    aMessage = "Result: Two offset curves OC and OC2 were successfully created from source curve SPL1. \n";
+  }
+  Output_TextBlock->Text = aMessage;
+}
+
+//=======================================================================
+//function : OnClickMesh
+//purpose  : Test mesh functionality
+//=======================================================================
+void MainPage::OnClickMesh(Platform::Object^  theSender,
+  Windows::UI::Xaml::Input::PointerRoutedEventArgs^ theEvent)
+{
+  TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200, 60, 60);
+  TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100, 20, 20), 80);
+  TopoDS_Shape ShapeFused = BRepAlgoAPI_Fuse(theSphere, theBox);
+  BRepMesh_IncrementalMesh(ShapeFused, 1);
+
+  Standard_Integer result(0);
+
+  for (TopExp_Explorer ex(ShapeFused, TopAbs_FACE); ex.More(); ex.Next()) {
+    TopoDS_Face F = TopoDS::Face(ex.Current());
+    TopLoc_Location L;
+    Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L);
+    result = result + facing->NbTriangles();
+  }
+
+  Platform::String ^aMessage;
+  if (ShapeFused.IsNull()) {
+    aMessage = "Error: could not fuse source shapes";
+  } else if (result == 0) {
+    aMessage = "Error: mesh could not be created";
+  } else {
+    aMessage = "Result: Mesh was created\
+--- Number of created triangles ---\n";
+
+    aMessage += result;
+    aMessage += ("\n\n");
+  }
+  Output_TextBlock->Text = aMessage;
+}
+
+//=======================================================================
+//function : OnClickBoolean
+//purpose  : Test boolean operations
+//=======================================================================
+void MainPage::OnClickBoolean(Platform::Object^  theSender,
+  Windows::UI::Xaml::Input::PointerRoutedEventArgs^ theEvent)
+{
+  TCollection_AsciiString asd;
+  gp_Pnt P(-5, 5, -5);
+  TopoDS_Shape theBox1 = BRepPrimAPI_MakeBox(60, 200, 70).Shape();
+
+  TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P, 20, 150, 110).Shape();
+
+  TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox1, theBox2);
+
+  Platform::String ^aMessage;
+
+  if (FusedShape.IsNull()) {
+    aMessage = "Error: could not fuse shapes theBox1 and theBox2";
+  } else {
+    aMessage = "Result: Shapes were successfully fused. \n";
+  }
+  Output_TextBlock->Text = aMessage;
+}
+
+//=======================================================================
+//function : OnClickBuildTemporary
+//purpose  : Test OSD_File::BuildTemporary() method
+//=======================================================================
+void MainPage::OnClickBuildTemporary(Platform::Object^  theSender,
+  Windows::UI::Xaml::Input::PointerRoutedEventArgs^ theEvent)
+{
+  OSD_File theTmpFile;
+  theTmpFile.BuildTemporary();
+  Standard_Boolean fKO = theTmpFile.Failed();
+  if (fKO)
+  {
+    Output_TextBlock->Text = "Error: cannot create temporary file";
+  } else {
+    OSD_Path theTmpFilepath;
+    theTmpFile.Path(theTmpFilepath);
+    TCollection_AsciiString theTmpFilepathTrek;
+    theTmpFilepath.SystemName(theTmpFilepathTrek);
+    wchar_t wchar_str[MAX_PATH];
+    StringCchCopy(wchar_str, _countof(wchar_str), L"Result: ");
+    TCollection_ExtendedString aWName(theTmpFilepathTrek);
+    StringCchCat(wchar_str, _countof(wchar_str), (const wchar_t*)aWName.ToExtString());
+    Platform::String^ p_string = ref new Platform::String(wchar_str);
+    Output_TextBlock->Text = p_string;
+  }
+}
+
+//=======================================================================
+//function : OnClickDataExchange
+//purpose  : Test data exchange functionality
+//=======================================================================
+void MainPage::OnClickDataExchange(Platform::Object^  theSender,
+    Windows::UI::Xaml::Input::PointerRoutedEventArgs^ theEvent)
+{
+  Output_TextBlock->Text = "";
+
+  // Create box for export
+  TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200, 60, 60);
+
+  // Create temporary directory
+  wchar_t tmpPath[MAX_PATH];
+  wchar_t filePath[MAX_PATH];
+  char tmpPathA[MAX_PATH];
+
+  if (!GetTempPathW(_countof(tmpPath), tmpPath)) {
+    StringCchCopyW(tmpPath, _countof(tmpPath), L"./");
+  }
+
+  WideCharToMultiByte(CP_UTF8, 0, tmpPath, -1, tmpPathA, sizeof(tmpPathA), NULL, NULL);
+  OSD_Path tmpDirPath(tmpPathA);
+  OSD_Directory tmpDir(tmpDirPath);
+
+  OSD_Protection srt;
+  tmpDir.Build(srt);
+
+  // Export box to .brep
+  StringCchCopyW(filePath, _countof(filePath), tmpPath);
+  StringCchCatW(filePath, _countof(filePath), L"/box.brep");
+  if (SaveBREP(filePath, theBox))
+    Output_TextBlock->Text += L"OK: export to .brep\n";
+  // Import from .brep
+  TopoDS_Shape theBoxFromBrep;
+  if (ReadBREP(filePath, theBoxFromBrep))
+    Output_TextBlock->Text += L"OK: import from .brep\n";
+  else
+    Output_TextBlock->Text += L"Error: import from .brep\n";
+
+  // Export box to .iges
+  StringCchCopyW(filePath, _countof(filePath), tmpPath);
+  StringCchCatW(filePath, _countof(filePath), L"/box.iges");
+  if (SaveIGES(filePath, theBox))
+    Output_TextBlock->Text += L"OK: export to .iges\n";
+  // Import from .iges
+  TopoDS_Shape theBoxFromIges;
+  if (ReadIGES(filePath, theBoxFromIges))
+    Output_TextBlock->Text += L"OK: import from .iges\n";
+  else
+    Output_TextBlock->Text += L"Error: import from .iges\n";
+
+  // Export box to .step
+  StringCchCopyW(filePath, _countof(filePath), tmpPath);
+  StringCchCatW(filePath, _countof(filePath), L"/box.step");
+
+  STEPControl_StepModelType aSelection = STEPControl_AsIs;
+  if (SaveSTEP(filePath, theBox, aSelection))
+    Output_TextBlock->Text += L"OK: export to .iges\n";
+  // Import from .iges
+  TopoDS_Shape theBoxFromStep;
+  if (ReadSTEP(filePath, theBoxFromStep))
+    Output_TextBlock->Text += L"OK: import from .step\n";
+  else
+    Output_TextBlock->Text += L"Error: import from .step\n";
+
+  // Export box to .stl
+  StringCchCopyW(filePath, _countof(filePath), tmpPath);
+  StringCchCatW(filePath, _countof(filePath), L"/box.stl");
+
+  if (SaveSTL(filePath, theBox))
+    Output_TextBlock->Text += L"OK: export to .stl\n";
+
+/*
+  // Export box to .vrml
+  StringCchCopyW(filePath, _countof(filePath), tmpPath);
+  StringCchCatW(filePath, _countof(filePath), L"/box.vrml");
+
+  if (SaveVRML(filePath, theBox))
+    Output_TextBlock->Text += L"OK: export to .vrml\n";
+*/
+}
+
+//=======================================================================
+//function : SaveBREP
+//purpose  : Export shape to .brep
+//=======================================================================
+Standard_Boolean MainPage::SaveBREP(const wchar_t* theFilePath, const TopoDS_Shape& theShape)
+{
+  std::filebuf aFileBuf;
+  std::ostream aStream(&aFileBuf);
+
+  if (!aFileBuf.open(theFilePath, ios::out)) {
+    Output_TextBlock->Text += L"Error: cannot open file for export (brep)\n";
+    return Standard_False;
+  }
+
+  BRepTools::Write(theShape, aStream);
+  return Standard_True;
+}
+
+//=======================================================================
+//function : SaveIGES
+//purpose  : Export shape to .iges
+//=======================================================================
+Standard_Boolean MainPage::SaveIGES(const wchar_t* theFilePath, const TopoDS_Shape& theShape)
+{
+  std::filebuf aFileBuf;
+  std::ostream aStream(&aFileBuf);
+
+  if (!aFileBuf.open(theFilePath, ios::out)) {
+    Output_TextBlock->Text += L"Error: cannot open file for export (iges)\n";
+    return Standard_False;
+  }
+
+  IGESControl_Controller::Init();
+  IGESControl_Writer ICW(Interface_Static::CVal("XSTEP.iges.unit"), Interface_Static::IVal("XSTEP.iges.writebrep.mode"));
+
+  ICW.AddShape(theShape);
+  ICW.ComputeModel();
+
+  if (!ICW.Write(aStream)) {
+    Output_TextBlock->Text += L"Error: cannot export box to .iges\n";
+    return Standard_False;
+  }
+
+  return Standard_True;
+}
+
+//=======================================================================
+//function : SaveSTEP
+//purpose  : Export shape to .step
+//=======================================================================
+Standard_Boolean MainPage::SaveSTEP(const wchar_t* theFilePath, const TopoDS_Shape& theShape, const STEPControl_StepModelType theValue)
+{
+  std::filebuf aFileBuf;
+  std::ostream aStream(&aFileBuf);
+
+  if (!aFileBuf.open(theFilePath, ios::out)) {
+    Output_TextBlock->Text += L"Error: cannot open file for export (step)\n";
+    return Standard_False;
+  }
+
+  STEPControl_Writer aWriter;
+
+  if (aWriter.Transfer(theShape, theValue) != IFSelect_RetDone) {
+    Output_TextBlock->Text += L"Error: cannot translate shape to STEP\n";
+    return Standard_False;
+  }
+
+  char theFilePathA[MAX_PATH];
+  WideCharToMultiByte(CP_UTF8, 0, theFilePath, -1, theFilePathA, sizeof(theFilePathA), NULL, NULL);
+
+  switch (aWriter.Write(theFilePathA))
+  {
+  case IFSelect_RetError:
+    Output_TextBlock->Text += L"Error: Incorrect Data\n";
+    break;
+  case IFSelect_RetFail:
+    Output_TextBlock->Text += L"Error: Writing has failed\n";
+    break;
+  case IFSelect_RetVoid:
+    Output_TextBlock->Text += L"Error: Nothing to transfer\n";
+    break;
+  default:
+    return Standard_True;
+  }
+  return Standard_False;
+}
+
+//=======================================================================
+//function : SaveSTL
+//purpose  : Export shape to .stl
+//=======================================================================
+Standard_Boolean MainPage::SaveSTL(const wchar_t* theFilePath, const TopoDS_Shape& theShape)
+{
+  StlAPI_Writer myStlWriter;
+
+  char theFilePathA[MAX_PATH];
+  WideCharToMultiByte(CP_UTF8, 0, theFilePath, -1, theFilePathA, sizeof(theFilePathA), NULL, NULL);
+
+  return myStlWriter.Write(theShape, theFilePathA) == StlAPI_StatusOK;
+}
+
+//=======================================================================
+//function : SaveVRML
+//purpose  : Export shape to .vrml
+//=======================================================================
+/*
+Standard_Boolean MainPage::SaveVRML(const wchar_t* theFilePath, const TopoDS_Shape& theShape)
+{
+  VrmlAPI_Writer aWriter;
+
+  char theFilePathA[MAX_PATH];
+  WideCharToMultiByte(CP_UTF8, 0, theFilePath, -1, theFilePathA, sizeof(theFilePathA), NULL, NULL);
+
+  aWriter.Write(theShape, theFilePathA);
+
+  return Standard_True;
+}
+*/
+
+//=======================================================================
+//function : ReadBREP
+//purpose  : Import shape from .brep
+//=======================================================================
+Standard_Boolean MainPage::ReadBREP(const wchar_t* theFilePath, TopoDS_Shape& theShape)
+{
+  theShape.Nullify();
+
+  BRep_Builder aBuilder;
+
+  char theFilePathA[MAX_PATH];
+  WideCharToMultiByte(CP_UTF8, 0, theFilePath, -1, theFilePathA, sizeof(theFilePathA), NULL, NULL);
+
+  if (!BRepTools::Read(theShape, theFilePathA, aBuilder))
+    return Standard_False;
+
+  return !theShape.IsNull() && BRepAlgo::IsValid(theShape);
+}
+
+//=======================================================================
+//function : ReadIGES
+//purpose  : Import shape from .iges
+//=======================================================================
+Standard_Boolean MainPage::ReadIGES(const wchar_t* theFilePath, TopoDS_Shape& theShape)
+{
+  theShape.Nullify();
+
+  IGESControl_Reader Reader;
+
+  char theFilePathA[MAX_PATH];
+  WideCharToMultiByte(CP_UTF8, 0, theFilePath, -1, theFilePathA, sizeof(theFilePathA), NULL, NULL);
+
+  if (Reader.ReadFile(theFilePathA) != IFSelect_RetDone)
+    return Standard_False;
+
+  Reader.TransferRoots();
+  theShape = Reader.OneShape();
+
+  return !theShape.IsNull();
+}
+
+//=======================================================================
+//function : ReadSTEP
+//purpose  : Import shape from .step
+//=======================================================================
+Standard_Boolean MainPage::ReadSTEP(const wchar_t* theFilePath, TopoDS_Shape& theShape)
+{
+  theShape.Nullify();
+
+  STEPControl_Reader aReader;
+
+  char theFilePathA[MAX_PATH];
+  WideCharToMultiByte(CP_UTF8, 0, theFilePath, -1, theFilePathA, sizeof(theFilePathA), NULL, NULL);
+
+  switch (aReader.ReadFile(theFilePathA))
+  {
+  case IFSelect_RetError:
+    Output_TextBlock->Text += L"Error: Not a valid Step file\n";
+    break;
+  case IFSelect_RetFail:
+    Output_TextBlock->Text += L"Error: Reading has failed\n";
+    break;
+  case IFSelect_RetVoid:
+    Output_TextBlock->Text += L"Error: Nothing to transfer\n";
+    break;
+  default:
+    return Standard_True;
+  }
+  return Standard_False;
+}
\ No newline at end of file
diff --git a/samples/xaml/MainPage.xaml.h b/samples/xaml/MainPage.xaml.h
new file mode 100644 (file)
index 0000000..d59c600
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// MainPage.xaml.h
+// Declaration of the MainPage class.
+//
+
+#pragma once
+
+#include <TopoDS_Shape.hxx>
+#include <STEPControl_StepModelType.hxx>
+
+#include "MainPage.g.h"
+
+namespace uwp
+{
+  /// <summary>
+  /// An empty page that can be used on its own or navigated to within a Frame.
+  /// </summary>
+  public ref class MainPage sealed
+  {
+  public:
+    MainPage();
+
+    void OnClickOffset(Platform::Object^  theSender,
+      Windows::UI::Xaml::Input::PointerRoutedEventArgs^ theEvent);
+
+    void OnClickMesh(Platform::Object^  theSender,
+      Windows::UI::Xaml::Input::PointerRoutedEventArgs^ theEvent);
+
+    void OnClickBoolean(Platform::Object^  theSender,
+      Windows::UI::Xaml::Input::PointerRoutedEventArgs^ theEvent);
+
+    void OnClickDataExchange(Platform::Object^  theSender,
+        Windows::UI::Xaml::Input::PointerRoutedEventArgs^ theEvent);
+
+    void OnClickBuildTemporary(Platform::Object^  theSender,
+      Windows::UI::Xaml::Input::PointerRoutedEventArgs^ theEvent);
+
+  private:
+    // test data exchange export functionality
+    Standard_Boolean SaveBREP(const wchar_t* theFilePath, const TopoDS_Shape& theShape);
+    Standard_Boolean SaveIGES(const wchar_t* theFilePath, const TopoDS_Shape& theShape);
+    Standard_Boolean SaveSTEP(const wchar_t* theFilePath, const TopoDS_Shape& theShape, const STEPControl_StepModelType theValue);
+    Standard_Boolean SaveSTL (const wchar_t* theFilePath, const TopoDS_Shape& theShape);
+    // Standard_Boolean SaveVRML(const wchar_t* theFilePath, const TopoDS_Shape& theShape);
+
+    // test data exchange import functionality
+    Standard_Boolean ReadBREP(const wchar_t* theFilePath, TopoDS_Shape& theShape);
+    Standard_Boolean ReadIGES(const wchar_t* theFilePath, TopoDS_Shape& theShape);
+    Standard_Boolean ReadSTEP(const wchar_t* theFilePath, TopoDS_Shape& theShape);
+  };
+}
diff --git a/samples/xaml/Package.appxmanifest b/samples/xaml/Package.appxmanifest
new file mode 100644 (file)
index 0000000..6322608
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<Package
+  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
+  xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
+  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
+  IgnorableNamespaces="uap mp">
+
+  <Identity
+    Name="d1574dea-d11e-4b37-a8f2-f1c2b1bad122"
+    Publisher="CN=OPEN CASCADE S.A.S."
+    Version="1.0.0.0" />
+
+  <mp:PhoneIdentity PhoneProductId="d1574dea-d11e-4b37-a8f2-f1c2b1bad122" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
+
+  <Properties>
+    <DisplayName>Open CASCADE Technology UWP Sample</DisplayName>
+    <PublisherDisplayName>OPEN CASCADE S.A.S.</PublisherDisplayName>
+    <Logo>Assets\StoreLogo.png</Logo>
+  </Properties>
+
+  <Dependencies>
+    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
+  </Dependencies>
+
+  <Resources>
+    <Resource Language="x-generate"/>
+  </Resources>
+
+  <Applications>
+    <Application Id="App"
+      Executable="$targetnametoken$.exe"
+      EntryPoint="uwp.App">
+      <uap:VisualElements
+        DisplayName="Open CASCADE Technology UWP Sample"
+        Square150x150Logo="Assets\Square150x150Logo.png"
+        Square44x44Logo="Assets\Square44x44Logo.png"
+        Description="Open CASCADE Technology UWP Sample"
+        BackgroundColor="transparent">
+        <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
+        <uap:SplashScreen Image="Assets\SplashScreen.png" />
+      </uap:VisualElements>
+    </Application>
+  </Applications>
+
+  <Capabilities>
+    <Capability Name="internetClient" />
+  </Capabilities>
+</Package>
\ No newline at end of file
diff --git a/samples/xaml/ReadMe.md b/samples/xaml/ReadMe.md
new file mode 100644 (file)
index 0000000..1a5bd41
--- /dev/null
@@ -0,0 +1,20 @@
+XAML (UWP) sample
+
+This sample was created to check possibility of OCCT compilation on Universal Windows Platform (UWP).
+Note that only FoundationClasses, ModelingAlgorithms and ModelingData modules can be built at the moment.
+
+Building OCCT and XAML (UWP) sample using CMake (since CMake version 3.4.0):
+  - Run CMake, select source and binary directories for OCCT
+  - Press "Configure" button
+  - Select generator for this project - "Visual Studio 14 2015"
+  - Select radio button "Specify toolchain file for cross-compiling" and press button "Next"
+  - Specify absolute path to the Toolchain file "OCCT/adm/templates/uwp.toolchain.config.cmake" and press button "Finish"
+  - After first configuration specify 3RDPARTY_DIR, INSTALL_DIR
+  - Turn ON BUILD_MODULE_Uwp checkbox.
+  - Press "Generate" button
+  - Build OCCT and XAML (UWP) sample from Visual Studio as usual.
+
+Troubleshooting:
+  If you have got an error like this (appears after running the sample from Visual Studio):
+    "Error : DEP3321 : To deploy this application, your deployment target should be running Windows Universal Runtime version 10.0.10240.0 or higher. You currently are running version 10.0.10166.0."
+  Go to the properties of uwp sample project and in tab "General", set minimum deployment target to the lowest one.
\ No newline at end of file
diff --git a/samples/xaml/pch.cpp b/samples/xaml/pch.cpp
new file mode 100644 (file)
index 0000000..97b544e
--- /dev/null
@@ -0,0 +1,6 @@
+//
+// pch.cpp
+// Include the standard header and generate the precompiled header.
+//
+
+#include "pch.h"
diff --git a/samples/xaml/pch.h b/samples/xaml/pch.h
new file mode 100644 (file)
index 0000000..b793236
--- /dev/null
@@ -0,0 +1,11 @@
+//
+// pch.h
+// Header for standard system include files.
+//
+
+#pragma once
+
+#include <collection.h>
+#include <ppltasks.h>
+
+#include "App.xaml.h"
diff --git a/samples/xaml/uwp_TemporaryKey.pfx b/samples/xaml/uwp_TemporaryKey.pfx
new file mode 100644 (file)
index 0000000..28ae51e
Binary files /dev/null and b/samples/xaml/uwp_TemporaryKey.pfx differ
index abed1d2..83953e2 100644 (file)
 #include <TColgp_Array1OfVec.hxx>
 #include <TColgp_Array1OfVec2d.hxx>
 
-#include <OSD_Chronometer.hxx>
-
-static OSD_Chronometer chr1;
-
-
-
 static AppParCurves_Constraint FirstConstraint
   (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
    const Standard_Integer FirstPoint)
index 225c41b..ce20031 100644 (file)
@@ -28,6 +28,7 @@
 #include <BRepAlgoAPI_Check.hxx>
 #include <BRepLib_FuseEdges.hxx>
 #include <BRepTools.hxx>
+#include <OSD_Environment.hxx>
 #include <OSD_File.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TopExp.hxx>
@@ -53,9 +54,10 @@ class BRepAlgoAPI_DumpOper {
     myIsDump(Standard_False),
     myIsDumpArgs(Standard_False),
     myIsDumpRes(Standard_False)  {
-      char *pathdump = getenv("CSF_DEBUG_BOP");
-      myIsDump=(pathdump!=NULL);
-      myPath=pathdump;
+      OSD_Environment env("CSF_DEBUG_BOP");
+      TCollection_AsciiString pathdump = env.Value();
+      myIsDump = (!pathdump.IsEmpty() ? Standard_True: Standard_False);
+      myPath=pathdump.ToCString();
   };
   //
   virtual ~BRepAlgoAPI_DumpOper() {
index 00f1b90..728bf46 100644 (file)
 #include <gp_Dir.hxx>
 #include <Standard_DomainError.hxx>
 
-static gp_Ax2 ConeComputeAxes() { 
-  static Standard_Integer firsttime=1;
-  static Standard_Integer modif=0;
-  static Standard_Real cosa=cos(0.122);
-  static Standard_Real sina=sin(0.122);
-  static Standard_Real ux=1.0;
-  static Standard_Real uy=0.0;
-  
-  if(firsttime) { 
-    modif = getenv("PRIM_CONE") != NULL;
-    firsttime = 0;
-  }
-  if(modif) { 
-    Standard_Real nux = cosa*ux+sina*uy;
-    Standard_Real nuy =-sina*ux+cosa*uy;
-    ux=nux; uy=nuy;
-    return(gp_Ax2(gp::Origin(),gp::DZ(),gp_Dir(ux,uy,0.0)));
-  }
-  else { 
-    return(gp::XOY());
-  }
-}
-
-
-
 //=======================================================================
 //function : BRepPrimAPI_MakeCone
 //purpose  : 
@@ -56,7 +31,7 @@ static gp_Ax2 ConeComputeAxes() {
 BRepPrimAPI_MakeCone::BRepPrimAPI_MakeCone(const Standard_Real R1,
                                   const Standard_Real R2, 
                                   const Standard_Real H) :
-       myCone(ConeComputeAxes(),R1, R2, H)
+       myCone(gp::XOY(),R1, R2, H)
 {
 }
 
index 2877c62..e68e23d 100644 (file)
 #include <gp_Dir.hxx>
 #include <Standard_DomainError.hxx>
 
-static gp_Ax2 CylinderComputeAxes() { 
-  static Standard_Integer firsttime=1;
-  static Standard_Integer modif=0;
-  static Standard_Real cosa=cos(0.1);
-  static Standard_Real sina=sin(0.1);
-  static Standard_Real ux=1.0;
-  static Standard_Real uy=0.0;
-  
-  if(firsttime) { 
-    modif = getenv("PRIM_CYLINDER") != NULL;
-    firsttime = 0;
-  }
-  if(modif) { 
-    Standard_Real nux = cosa*ux+sina*uy;
-    Standard_Real nuy =-sina*ux+cosa*uy;
-    ux=nux; uy=nuy;
-    return(gp_Ax2(gp::Origin(),gp::DZ(),gp_Dir(ux,uy,0.0)));
-  }
-  else { 
-    return(gp::XOY());
-  }
-
-}
-
-
-
 //=======================================================================
 //function : BRepPrimAPI_MakeCylinder
 //purpose  : 
@@ -56,7 +30,7 @@ static gp_Ax2 CylinderComputeAxes() {
 
 BRepPrimAPI_MakeCylinder::BRepPrimAPI_MakeCylinder(const Standard_Real R,
                                           const Standard_Real H) :
-       myCylinder(CylinderComputeAxes(), R , H)
+       myCylinder(gp::XOY(), R , H)
 {
 }
 
index f4330a6..d302518 100644 (file)
 #include <gp_Pnt.hxx>
 #include <Standard_DomainError.hxx>
 
-static gp_Ax2 SphereComputeAxes() { 
-  static Standard_Integer firsttime=1;
-  static Standard_Integer modif=0;
-  static Standard_Real cosa=cos(0.111);
-  static Standard_Real sina=sin(0.111);
-  static Standard_Real ux=1.0;
-  static Standard_Real uy=0.0;
-  
-  if(firsttime) { 
-    modif = getenv("PRIM_SPHERE") != NULL;
-    firsttime = 0;
-  }
-  if(modif) { 
-    Standard_Real nux = cosa*ux+sina*uy;
-    Standard_Real nuy =-sina*ux+cosa*uy;
-    ux=nux; uy=nuy;
-    return(gp_Ax2(gp::Origin(),gp::DZ(),gp_Dir(ux,uy,0.0)));
-  }
-  else { 
-    return(gp::XOY());
-  }
-}
-
-
 //=======================================================================
 //function : BRepPrimAPI_MakeSphere
 //purpose  : 
 //=======================================================================
 
 BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const Standard_Real R) :
-       mySphere(SphereComputeAxes(),R)
+       mySphere(gp::XOY(),R)
 {
 }
 
index 698ed41..1a8de56 100644 (file)
@@ -53,7 +53,6 @@
 #include <gp_GTrsf2d.hxx>
 #include <gp_Pnt.hxx>
 #include <gp_TrsfForm.hxx>
-#include <OSD_Chronometer.hxx>
 #include <ProjLib_ComputeApprox.hxx>
 #include <ProjLib_ComputeApproxOnPolarSurface.hxx>
 #include <Standard_NoSuchObject.hxx>
index 1b1cb70..8fb6506 100644 (file)
@@ -69,7 +69,6 @@
 #include <gp_Pnt.hxx>
 #include <gp_Pnt2d.hxx>
 #include <gp_Sphere.hxx>
-#include <OSD_Chronometer.hxx>
 #include <Precision.hxx>
 #include <Standard_NotImplemented.hxx>
 #include <Standard_OutOfRange.hxx>
 #include <TopTools_MapIteratorOfMapOfShape.hxx>
 #include <TopTools_SequenceOfShape.hxx>
 
+#ifdef OCCT_DEBUG
+#include <OSD_Chronometer.hxx>
+#endif
+
 #include <stdio.h>
 // include - all hxx,
 //         - all small static functions.
 //======================== START STATIC FUNCTIONS ============
 // variables for performance 
 Standard_Real t_mkcurve;
+#ifdef OCCT_DEBUG
 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
 extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real&    time);
+#endif
 #ifdef DRAW
 static Standard_Boolean Affich = Standard_False;
 static char name[100];
index 705ae28..b647551 100644 (file)
@@ -32,52 +32,14 @@ class CDF_Store;
 class CDF_MetaDataDriver;
 class CDF_FWOSDriver;
 class CDF_MetaDataDriverFactory;
-class CDF_Timer;
-
-
 
 class CDF 
 {
 public:
-
-  DEFINE_STANDARD_ALLOC
-
   
   Standard_EXPORT static void GetLicense (const Standard_Integer anApplicationIdentifier);
   
   Standard_EXPORT static Standard_Boolean IsAvailable (const Standard_Integer anApplicationIdentifier);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-friend class CDF_Directory;
-friend class CDF_DirectoryIterator;
-friend class CDF_Session;
-friend class CDF_Application;
-friend class CDF_StoreList;
-friend class CDF_Store;
-friend class CDF_MetaDataDriver;
-friend class CDF_FWOSDriver;
-friend class CDF_MetaDataDriverFactory;
-friend class CDF_Timer;
-
 };
 
-
-
-
-
-
-
 #endif // _CDF_HeaderFile
index 31ad366..3992409 100644 (file)
@@ -20,7 +20,6 @@
 #include <CDF_Directory.hxx>
 #include <CDF_MetaDataDriver.hxx>
 #include <CDF_Session.hxx>
-#include <CDF_Timer.hxx>
 #include <CDM_CanCloseStatus.hxx>
 #include <CDM_Document.hxx>
 #include <CDM_MetaData.hxx>
@@ -99,11 +98,8 @@ Handle(CDM_Document) CDF_Application::Retrieve(const TCollection_ExtendedString&
 Handle(CDM_Document)  CDF_Application::Retrieve(const TCollection_ExtendedString& aFolder, 
                                     const TCollection_ExtendedString& aName,
                                     const TCollection_ExtendedString& aVersion,
-                                    const Standard_Boolean UseStorageConfiguration) {
-#ifdef OCCT_DEBUG
-  CDF_Timer theTimer;
-#endif
-
+                                    const Standard_Boolean UseStorageConfiguration)
+{
   Handle(CDM_MetaData) theMetaData; 
   
   if(aVersion.Length() == 0) 
@@ -111,28 +107,14 @@ Handle(CDM_Document)  CDF_Application::Retrieve(const TCollection_ExtendedString
   else 
     theMetaData=theMetaDataDriver->MetaData(aFolder,aName,aVersion);
 
-#ifdef OCCT_DEBUG
-  theTimer.ShowAndRestart("Getting MetaData: ");
-#endif
-
   CDF_TypeOfActivation theTypeOfActivation=TypeOfActivation(theMetaData);
   Handle(CDM_Document) theDocument=Retrieve(theMetaData,UseStorageConfiguration,Standard_False);
 
-#ifdef OCCT_DEBUG
-  theTimer.ShowAndRestart("Creating Transient: ");
-#endif
-
   CDF_Session::CurrentSession()->Directory()->Add(theDocument);
   Activate(theDocument,theTypeOfActivation);
 
-#ifdef OCCT_DEBUG
-  theTimer.ShowAndStop("Activate: ");
-#endif
-
   theDocument->Open(this);
   return theDocument;
-
-
 }
 
 //=======================================================================
@@ -150,25 +132,13 @@ PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString&
 //=======================================================================
 PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString&  aFolder, const TCollection_ExtendedString&  aName, const TCollection_ExtendedString&  aVersion) {
   
-#ifdef OCCT_DEBUG
-  CDF_Timer theTimer;
-#endif
-
   if (!theMetaDataDriver->Find(aFolder,aName,aVersion))
     return PCDM_RS_UnknownDocument;
   else if (!theMetaDataDriver->HasReadPermission(aFolder,aName,aVersion))
     return PCDM_RS_PermissionDenied;
   else {
-#ifdef OCCT_DEBUG
-    theTimer.ShowAndRestart("theMetaDataDriver->Find: ");
-#endif
-
     Handle(CDM_MetaData) theMetaData = theMetaDataDriver->MetaData(aFolder,aName,aVersion);
 
-#ifdef OCCT_DEBUG
-    theTimer.ShowAndStop("Getting MetaData: ");
-#endif
-
     if(theMetaData->IsRetrieved()) {
       return theMetaData->Document()->IsModified()
        ? PCDM_RS_AlreadyRetrievedAndModified : PCDM_RS_AlreadyRetrieved;
@@ -199,11 +169,8 @@ PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString&
     }
   }
   return PCDM_RS_OK;
-  
 }
 
-
-
 //=======================================================================
 //function : Activate
 //purpose  : 
index 619af20..5fc200a 100644 (file)
@@ -20,7 +20,6 @@
 #include <CDF_MetaDataDriverError.hxx>
 #include <CDF_Session.hxx>
 #include <CDF_StoreList.hxx>
-#include <CDF_Timer.hxx>
 #include <CDM_Document.hxx>
 #include <CDM_MetaData.hxx>
 #include <CDM_ReferenceIterator.hxx>
@@ -28,9 +27,7 @@
 #include <PCDM_Document.hxx>
 #include <PCDM_StorageDriver.hxx>
 #include <Standard_ErrorHandler.hxx>
-#include <Standard_Macro.hxx>
 #include <Standard_NoSuchObject.hxx>
-#include <Standard_Type.hxx>
 #include <TCollection_ExtendedString.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(CDF_StoreList,Standard_Transient)
@@ -112,15 +109,9 @@ PCDM_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData, TCollect
           }
           TCollection_ExtendedString theName=theMetaDataDriver->BuildFileName(theDocument);
 
-          CDF_Timer theTimer;
           aDocumentStorageDriver->Write(theDocument,theName);
           status = aDocumentStorageDriver->GetStoreStatus();
-
-          theTimer.ShowAndRestart("Driver->Write: ");
-
           aMetaData = theMetaDataDriver->CreateMetaData(theDocument,theName);
-          theTimer.ShowAndStop("metadata creating: ");
-
           theDocument->SetMetaData(aMetaData);
 
           CDM_ReferenceIterator it(theDocument);
diff --git a/src/CDF/CDF_Timer.cxx b/src/CDF/CDF_Timer.cxx
deleted file mode 100644 (file)
index 3e229f0..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// Created on: 1998-07-17
-// Created by: Jean-Louis Frenkel
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <CDF_Timer.hxx>
-
-#include <stdlib.h>
-CDF_Timer::CDF_Timer() {
-  myTimer.Start();
-}
-
-
-void CDF_Timer::ShowAndRestart(const Standard_CString aMessage) {
-  if(MustShow()) {
-    Show(aMessage);
-    myTimer.Reset();
-    myTimer.Start();
-  }
-}
-  
-void CDF_Timer::ShowAndStop(const Standard_CString aMessage) {
-  if(MustShow()) {
-    Show(aMessage);
-    myTimer.Stop();
-  }
-}
-void CDF_Timer::Show(const Standard_CString aMessage) {
-  Standard_Integer minutes,hours; Standard_Real seconds,CPUtime;
-  myTimer.Show(seconds,minutes,hours,CPUtime);
-  cout << aMessage << hours << "h " << minutes << "' " << seconds << "'' (cpu: " << CPUtime << ")" << endl;
-}
-Standard_Boolean CDF_Timer::MustShow() {
-  static Standard_Boolean theMustShow=getenv("STORETIMER") != NULL;
-  return theMustShow;
-}
diff --git a/src/CDF/CDF_Timer.hxx b/src/CDF/CDF_Timer.hxx
deleted file mode 100644 (file)
index e979cb5..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-// Created on: 1998-07-17
-// Created by: Jean-Louis Frenkel
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _CDF_Timer_HeaderFile
-#define _CDF_Timer_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-#include <OSD_Timer.hxx>
-#include <Standard_CString.hxx>
-#include <Standard_Boolean.hxx>
-
-
-
-class CDF_Timer 
-{
-public:
-
-  DEFINE_STANDARD_ALLOC
-
-  
-  Standard_EXPORT CDF_Timer();
-  
-  Standard_EXPORT void ShowAndRestart (const Standard_CString aMessage);
-  
-  Standard_EXPORT void ShowAndStop (const Standard_CString aMessage);
-  
-  Standard_EXPORT Standard_Boolean MustShow();
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-  
-  Standard_EXPORT void Show (const Standard_CString aMessage);
-
-
-  OSD_Timer myTimer;
-
-
-};
-
-
-
-
-
-
-
-#endif // _CDF_Timer_HeaderFile
index 0c82247..d0aa8b6 100755 (executable)
@@ -21,7 +21,5 @@ CDF_StoreList.cxx
 CDF_StoreList.hxx
 CDF_StoreSetNameStatus.hxx
 CDF_SubComponentStatus.hxx
-CDF_Timer.cxx
-CDF_Timer.hxx
 CDF_TryStoreStatus.hxx
 CDF_TypeOfActivation.hxx
index 9ba0cf3..9af214b 100644 (file)
 #include <ChFi3d_Builder_0.hxx>
 
 #ifdef OCCT_DEBUG
-#include <OSD_Chronometer.hxx>
 extern Standard_Boolean ChFi3d_GetcontextFORCEBLEND(); 
 extern Standard_Boolean ChFi3d_GettraceDRAWINT();
 extern Standard_Boolean ChFi3d_GettraceDRAWENLARGE();
@@ -169,8 +168,6 @@ extern Standard_Boolean ChFi3d_GettraceDRAWSPINE();
 extern Standard_Real  t_sameparam, t_batten;
 extern void ChFi3d_SettraceDRAWINT(const Standard_Boolean b);
 extern void ChFi3d_SettraceDRAWSPINE(const Standard_Boolean b);
-extern void ChFi3d_InitChron(OSD_Chronometer& ch);
-extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
 #endif
 
 #include <stdio.h>
index 8728a19..c08336f 100644 (file)
 #include <TopTools_ListOfShape.hxx>
 
 #include <stdio.h>
-#ifdef OCCT_DEBUG
-// For measurements.
-#include <OSD_Chronometer.hxx>
-//static OSD_Chronometer appclock;
-#endif
 
 //#define DRAW 
 
index c7de810..d2e0c2a 100644 (file)
 #include <gp_Vec.hxx>
 #include <gp_Vec2d.hxx>
 #include <gp_Ax1.hxx>
-#include <OSD_Chronometer.hxx>
 
 #ifdef DRAW
 #include <DBRep.hxx>
 #endif
 
 #ifdef OCCT_DEBUG
+#include <OSD_Chronometer.hxx>
 OSD_Chronometer simul,elspine,chemine;
 #endif
 
@@ -169,6 +169,7 @@ void ChFi3d_SetcontextNOOPT(const Standard_Boolean b)
 Standard_Boolean ChFi3d_GetcontextNOOPT() 
 { return ChFi3d_contextNOOPT; }
 
+#ifdef OCCT_DEBUG
 // ***********************************************
 //    initialization and result of a chrono 
 //************************************************
@@ -186,7 +187,7 @@ Standard_EXPORT void ChFi3d_ResultChron( OSD_Chronometer & ch,
     ch.Show(tch);
     time=time +tch;
 }
-
+#endif
 
 //==============================================================
 // function : ChFi3d_CheckSurfData
index 1ac6beb..9539559 100644 (file)
@@ -71,6 +71,7 @@
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 
 #ifdef OCCT_DEBUG
+#include <OSD_Chronometer.hxx>
 extern Standard_Boolean ChFi3d_GettraceCHRON();
 extern Standard_Real  t_computedata ,t_completedata; 
                     
index f40e510..1ce7004 100644 (file)
@@ -37,10 +37,10 @@ IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SessionPilot,IFSelect_Activator)
 #define MAXCARS 1000
 
 static int initactor = 0;
-static char* trace;
-
 static TCollection_AsciiString nulword;
 
+//#define DEBUG_TRACE
+
 // Nb Maxi de words : cf thewords et method SetCommandLine
 
     IFSelect_SessionPilot::IFSelect_SessionPilot (const Standard_CString prompt)
@@ -57,7 +57,6 @@ static TCollection_AsciiString nulword;
   Add (4,"xsource");
   Add (5,"xstep");
   Add (6,"xnew");
-  trace = getenv("DEBUGMODE");
 }
 
 
@@ -100,7 +99,9 @@ static TCollection_AsciiString nulword;
       if (thenbwords >= MAXWORDS) {  unarg[nc] = val;  nc ++;  continue;  }
       unarg[nc] = '\0';
       thewords(thenbwords).Clear();  thewords(thenbwords).AssignCat(unarg);
-      if (trace) cout<<"thewords("<<thenbwords<<") ="<<unarg<<endl;
+#ifdef DEBUG_TRACE
+      cout<<"thewords("<<thenbwords<<") ="<<unarg<<endl;
+#endif
       thenbwords ++; nc = 0;
       continue;
     }
@@ -111,7 +112,9 @@ static TCollection_AsciiString nulword;
   if (nc > 0) {
     unarg[nc] = '\0'; thewords(thenbwords).Clear();
     thewords(thenbwords).AssignCat(unarg);
-    if (trace) cout<<"thewords("<<thenbwords<<")="<<unarg<<endl<<" .. Fin avec thenbwords="<<thenbwords+1<<endl;
+#ifdef DEBUG_TRACE
+    cout<<"thewords("<<thenbwords<<")="<<unarg<<endl<<" .. Fin avec thenbwords="<<thenbwords+1<<endl;
+#endif
     thenbwords ++;
   }
 /*
index f3a1cd2..2520b43 100644 (file)
@@ -33,7 +33,6 @@ class OSD_File;
 class OSD_FileIterator;
 class OSD_Directory;
 class OSD_DirectoryIterator;
-class OSD_Chronometer;
 class OSD_Timer;
 class OSD_Printer;
 class OSD_Host;
index 9c1d77d..6153aaf 100644 (file)
@@ -136,10 +136,15 @@ static inline __int64 EncodeFILETIME (PFILETIME pFt)
 //=======================================================================
 void OSD_Chronometer::GetProcessCPU (Standard_Real& UserSeconds, Standard_Real& SystemSeconds)
 {
+#ifndef OCCT_UWP
   FILETIME ftStart, ftExit, ftKernel, ftUser;
   ::GetProcessTimes (GetCurrentProcess(), &ftStart, &ftExit, &ftKernel, &ftUser);
   UserSeconds   = 0.0000001 * EncodeFILETIME (&ftUser);
   SystemSeconds = 0.0000001 * EncodeFILETIME (&ftKernel);
+#else
+  UserSeconds = 0.0;
+  SystemSeconds = 0.0;
+#endif
 }
 
 //=======================================================================
@@ -148,10 +153,15 @@ void OSD_Chronometer::GetProcessCPU (Standard_Real& UserSeconds, Standard_Real&
 //=======================================================================
 void OSD_Chronometer::GetThreadCPU (Standard_Real& UserSeconds, Standard_Real& SystemSeconds)
 {
+#ifndef OCCT_UWP
   FILETIME ftStart, ftExit, ftKernel, ftUser;
   ::GetThreadTimes (GetCurrentThread(), &ftStart, &ftExit, &ftKernel, &ftUser);
   UserSeconds   = 0.0000001 * EncodeFILETIME (&ftUser);
   SystemSeconds = 0.0000001 * EncodeFILETIME (&ftKernel);
+#else
+  UserSeconds = 0.0;
+  SystemSeconds = 0.0;
+#endif
 }
 
 #endif /* _WIN32 */
index 2415f4f..88e12b0 100644 (file)
@@ -84,6 +84,7 @@ char                    name[] = "/tmp/CSFXXXXXX";
 #include <OSD_Protection.hxx>
 #include <Standard_ProgramError.hxx>
 #include <TCollection_ExtendedString.hxx>
+#include <NCollection_String.hxx>
 
 #include <OSD_WNT_1.hxx>
 
@@ -110,7 +111,7 @@ OSD_Directory :: OSD_Directory ( const OSD_Path& Name ) :
 
 }  // end constructor ( 2 )
 
-void OSD_Directory :: Build (const OSD_Protection& Protect ) {
+void OSD_Directory :: Build (const OSD_Protection& Protect) {
 
  TCollection_AsciiString dirName;
 
@@ -118,15 +119,15 @@ void OSD_Directory :: Build (const OSD_Protection& Protect ) {
 
  if (  dirName.IsEmpty ()  )
 
-  Standard_ProgramError :: Raise (
-                            TEXT( "OSD_Directory :: Build (): incorrect call - no directory name" )
-                           );
+  Standard_ProgramError :: Raise ( "OSD_Directory :: Build (): incorrect call - no directory name");
  TCollection_ExtendedString dirNameW(dirName);
- if (  Exists () || CreateDirectoryW ( (const wchar_t*) dirNameW.ToExtString (), NULL )  )
-
-  SetProtection ( Protect );
-
- else
+ if (Exists() || CreateDirectoryW((const wchar_t*)dirNameW.ToExtString(), NULL)) {
+#ifndef OCCT_UWP
+   SetProtection(Protect);
+#else
+   (void)Protect;
+#endif
+ } else
 
   _osd_wnt_set_error ( myError, OSD_WDirectory );
 
@@ -136,7 +137,10 @@ OSD_Directory OSD_Directory :: BuildTemporary () {
 
  OSD_Directory           retVal;
  OSD_Protection          prt;
- OSD_Path                dirPath (  tctmpnam ( NULL )  );
+
+ wchar_t* aName = _wtmpnam(NULL);
+ NCollection_String aFolder(aName != NULL ? aName : L"");
+ OSD_Path dirPath(aFolder.ToCString());
 
  retVal.SetPath ( dirPath );
  retVal.Build ( prt );                            
index 1970977..2c89a95 100644 (file)
@@ -239,7 +239,7 @@ Standard_Boolean OSD_DirectoryIterator :: More () {
 
   // make wchar_t string from UTF-8
   TCollection_ExtendedString wcW(wc);
-  myHandle = FindFirstFileW ((const wchar_t*)wcW.ToExtString(), (PWIN32_FIND_DATAW)myData);
+  myHandle = FindFirstFileExW ((const wchar_t*)wcW.ToExtString(), FindExInfoStandard, (PWIN32_FIND_DATAW)myData, FindExSearchNameMatch, NULL, 0);
 
   if ( myHandle == INVALID_HANDLE_VALUE )
 
index 5823c1e..b84a566 100644 (file)
@@ -162,6 +162,8 @@ Standard_Integer OSD_Disk::Error()const{
 #include <OSD_OSDError.hxx>
 #include <OSD_Path.hxx>
 #include <Standard_ProgramError.hxx>
+#include <NCollection_String.hxx>
+#include <TCollection_ExtendedString.hxx>
 
 #include <windows.h>
 
@@ -170,14 +172,22 @@ void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
 static void __fastcall _osd_wnt_set_disk_name ( TCollection_AsciiString&, const OSD_Path& );
 
 OSD_Disk :: OSD_Disk () {
-
- TCHAR cwd[ MAX_PATH ];
-
- GetCurrentDirectory ( MAX_PATH, cwd );
-
- cwd[ 3 ] = TEXT( '\x00' );
- DiskName = cwd;
-
+ DWORD aBuffLen = GetCurrentDirectoryW(0, NULL);
+ wchar_t* aBuff = new wchar_t[size_t(aBuffLen) + 1];
+ GetCurrentDirectoryW(aBuffLen, aBuff);
+ aBuff[aBuffLen - 1] = (aBuff[aBuffLen - 2] == L'\\') ? L'\0' : L'\\';
+ aBuff[aBuffLen] = L'\0';
+ if (aBuffLen > 3 && aBuff[0] != L'\\')
+ {
+   aBuff[3] = L'\0';
+   NCollection_String aFolder(aBuff);
+   DiskName = aFolder.ToCString();
+   delete[] aBuff;
+ }
+ else
+ {
+   DiskName = "";
+ }
 }  // end constructor ( 1 )
 
 OSD_Disk :: OSD_Disk ( const OSD_Path& Name ) {
@@ -223,8 +233,8 @@ Standard_Integer OSD_Disk :: DiskSize () {
   ULARGE_INTEGER lpTotalNumberOfBytes;    // receives the number of bytes on disk
   ULARGE_INTEGER lpTotalNumberOfFreeBytes;// receives the free bytes on disk
 
-
-  if (!GetDiskFreeSpaceEx (DiskName.ToCString (),
+  TCollection_ExtendedString DiskNameW(DiskName);
+  if (!GetDiskFreeSpaceExW ((const wchar_t*)DiskNameW.ToExtString(),
                           &lpFreeBytesAvailableToCaller,
                           &lpTotalNumberOfBytes,
                           &lpTotalNumberOfFreeBytes))
@@ -261,8 +271,8 @@ Standard_Integer OSD_Disk :: DiskFree () {
   ULARGE_INTEGER lpTotalNumberOfFreeBytes;// receives the free bytes on disk
 
   // if (   !GetDiskFreeSpace (  DiskName.ToCString (), &dwSpC, &dwBpS, &dwFC, &dwC  )   )
-
-  if (!GetDiskFreeSpaceEx (DiskName.ToCString (),
+  TCollection_ExtendedString DiskNameW(DiskName);
+  if (!GetDiskFreeSpaceExW((const wchar_t*)DiskNameW.ToExtString(),
                           &lpFreeBytesAvailableToCaller,
                           &lpTotalNumberOfBytes,
                           &lpTotalNumberOfFreeBytes))
@@ -349,26 +359,26 @@ static void __fastcall _osd_wnt_set_disk_name ( TCollection_AsciiString& result,
   dir = path.Trek ();
   
   if (   (  j = dir.UsefullLength ()  ) > 2 &&
-         dir.Value ( 1 ) == TEXT( '|' )     &&
-         dir.Value ( 2 ) == TEXT( '|' )
+         dir.Value ( 1 ) == '|'     &&
+         dir.Value ( 2 ) == '|'
   ) {
   
-   dir.SetValue (  1, TEXT( '\\' )  );
-   dir.SetValue (  2, TEXT( '\\' )  );
+   dir.SetValue (  1, '\\');
+   dir.SetValue (  2, '\\');
    
    for ( i = 3, k = 0; i <= j; ++i )
 
-    if (  dir.Value ( i ) == TEXT( '|' )  ) {
+    if (  dir.Value ( i ) == '|') {
     
      if ( k == 0 ) {
 
-      dir.SetValue (  i, TEXT( "\\" )  );     
+      dir.SetValue (  i, '\\');
       ++k;
       continue; 
      
      }  // end if
 
-     dir.SetValue (  i, TEXT( "\\" )  );
+     dir.SetValue (  i, '\\');
      break;
      
     }  /* end if */
@@ -381,14 +391,14 @@ static void __fastcall _osd_wnt_set_disk_name ( TCollection_AsciiString& result,
 
      else {
 
-      dir += TEXT( "\\" );
+      dir += '\\';
       dir += path.Name ();
       dir += path.Extension ();
       
      }  // end else    
     }
 
-    if (   dir.Value (  dir.UsefullLength ()  ) != TEXT( '\\' )   ) dir += TEXT( "\\" );
+    if (   dir.Value (  dir.UsefullLength ()  ) != '\\') dir += '\\';
 
     result = dir;
   
@@ -398,7 +408,7 @@ badPath:
 
   }  // end else
  
- } else result += TEXT( "/" );
+ } else result += '/';
 
 }  // end _osd_set_disk_name
 
index c34a524..d3ed551 100644 (file)
@@ -246,7 +246,9 @@ Standard_Integer OSD_Environment::Error() const
   #pragma warning( disable : 4700 )
 #endif
 
+#ifndef OCCT_UWP
 static void __fastcall _set_error ( OSD_Error&, DWORD );
+#endif
 
 OSD_Environment :: OSD_Environment () {
 
@@ -276,6 +278,7 @@ void OSD_Environment :: SetValue ( const TCollection_AsciiString& Value ) {
 
 TCollection_AsciiString OSD_Environment::Value()
 {
+#ifndef OCCT_UWP
   myValue.Clear();
 
   SetLastError (ERROR_SUCCESS);
@@ -306,6 +309,10 @@ TCollection_AsciiString OSD_Environment::Value()
   }
   myValue = aValue.ToCString();
   return myValue;
+#else
+  myValue = "";
+  return myValue;
+#endif
 }
 
 void OSD_Environment :: SetName ( const TCollection_AsciiString& name ) {
@@ -322,14 +329,18 @@ TCollection_AsciiString OSD_Environment :: Name () const {
 
 void OSD_Environment::Build()
 {
+#ifndef OCCT_UWP
   NCollection_Utf8String aSetVariable = NCollection_Utf8String(myName.ToCString()) + "=" + myValue.ToCString();
   _wputenv (aSetVariable.ToUtfWide().ToCString());
+#endif
 }
 
 void OSD_Environment::Remove()
 {
+#ifndef OCCT_UWP
   NCollection_Utf8String aSetVariable = NCollection_Utf8String(myName.ToCString()) + "=";
   _wputenv (aSetVariable.ToUtfWide().ToCString());
+#endif
 }
 
 Standard_Boolean OSD_Environment :: Failed () const {
@@ -355,6 +366,7 @@ Standard_Integer OSD_Environment :: Error () const {
 
 }  // end OSD_Environment :: Error
 
+#ifndef OCCT_UWP
 static void __fastcall _set_error ( OSD_Error& err, DWORD code ) {
 
  DWORD              errCode;
@@ -377,5 +389,6 @@ static void __fastcall _set_error ( OSD_Error& err, DWORD code ) {
  err.SetValue ( errCode, OSD_WEnvironment, buffer );
 
 }  // end _set_error
+#endif
 
 #endif
index e2d0ab9..130fdf6 100755 (executable)
@@ -449,6 +449,7 @@ void OSD_Error::Perror() {
 #include <TCollection_ExtendedString.hxx>
 
 #include <windows.h>
+#include <Strsafe.h>
 
 typedef struct _error_table {
 
@@ -570,82 +571,60 @@ OSD_Error :: OSD_Error () :
 
 void OSD_Error :: Perror () {
 
- Standard_Character buff[ 32 ];
- Standard_CString   ptr;
+ wchar_t buff[32];
 
-  lstrcpy (  buff, "Error ( "  );
+  StringCchCopyW(buff, _countof(buff), L"Error ( ");
 
   switch ( myCode ) {
   
    case OSD_WDirectoryIterator:
-
-    ptr = "OSD_DirectoryIterator";
-
+     StringCchCatW(buff, _countof(buff), L"OSD_DirectoryIterator");
    break;
 
    case OSD_WDirectory:
-
-    ptr = "OSD_Directory";
-
+    StringCchCatW(buff, _countof(buff), L"OSD_Directory");
    break;
 
    case OSD_WFileIterator:
-
-    ptr = "OSD_FileIterator";
-
+    StringCchCatW(buff, _countof(buff), L"OSD_FileIterator");
    break;
 
    case OSD_WFile:
-  
-    ptr = "OSD_File";
-
+    StringCchCatW(buff, _countof(buff), L"OSD_File");
    break;
 
    case OSD_WFileNode:
-
-    ptr = "OSD_FileNode";
-
+    StringCchCatW(buff, _countof(buff), L"OSD_FileNode");
    break;
 
    case OSD_WHost:
-
-    ptr = "OSD_Host";
-
+    StringCchCatW(buff, _countof(buff), L"OSD_Host");
    break;
 
    case OSD_WProcess:
-
-    ptr = "OSD_Environment";
-
+    StringCchCatW(buff, _countof(buff), L"OSD_Environment");
    break;
 
    case OSD_WEnvironmentIterator:
-
-    ptr = "OSD_EnvironmentIterator";
-
+     StringCchCatW(buff, _countof(buff), L"OSD_EnvironmentIterator");
    break;
 
    case OSD_WEnvironment:
-
-    ptr = "OSD_Environment";
-
+     StringCchCatW(buff, _countof(buff), L"OSD_Environment");
    break;
 
    case OSD_WDisk:
-
-    ptr = "OSD_Disk";
-
+     StringCchCatW(buff, _countof(buff), L"OSD_Disk");
    break;
 
    default:
-
-    ptr = "Unknown";
+     StringCchCatW(buff, _countof(buff), L"Unknown");
 
   }  // end switch
 
-  lstrcat ( buff, ptr );
-  lstrcat (  buff, " )"  );
-  std::cerr << buff;
+  StringCchCatW(buff, _countof(buff), L" )");
+
+  std::wcerr << buff;
  
  std::cerr << myMessage.ToCString() << std::endl << std::flush;
 
index fb0c6f0..4977f34 100644 (file)
@@ -839,6 +839,8 @@ void OSD_File::Rewind() {
 # include <tchar.h>
 #endif  // _INC_TCHAR
 
+#include <Strsafe.h>
+
 #if defined(__CYGWIN32__) || defined(__MINGW32__)
 #define VAC
 #endif
@@ -858,15 +860,16 @@ void OSD_File::Rewind() {
 #define OPEN_APPEND 2
 
 void                            _osd_wnt_set_error        ( OSD_Error&, OSD_WhoAmI, ... );
+#ifndef OCCT_UWP
 PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd ( const OSD_Protection&, BOOL, wchar_t* = NULL );
 BOOL                 __fastcall _osd_wnt_sd_to_protection (
                                  PSECURITY_DESCRIPTOR, OSD_Protection&, BOOL
                                 );
 BOOL                 __fastcall _osd_print (const Standard_PCharacter, const wchar_t* );
-
+static int       __fastcall _get_buffer(HANDLE, Standard_PCharacter&, DWORD, BOOL, BOOL);
+#endif
 static void      __fastcall _test_raise ( HANDLE, Standard_CString );
 static Standard_Integer __fastcall _get_line (Standard_PCharacter& buffer, DWORD dwBuffSize, LONG& theSeekPos);
-static int       __fastcall _get_buffer ( HANDLE, Standard_PCharacter&, DWORD, BOOL, BOOL );
 static DWORD     __fastcall _get_access_mask ( OSD_SingleProtection );
 static DWORD     __fastcall _get_dir_access_mask ( OSD_SingleProtection prt );
 static HANDLE    __fastcall _open_file  ( Standard_CString, OSD_OpenMode, DWORD, LPBOOL = NULL );
@@ -942,7 +945,9 @@ int OSD_File::Capture(int theDescr) {
 }
 
 void OSD_File::Rewind() { 
-  SetFilePointer( myFileHandle, 0, NULL, FILE_BEGIN ); 
+  LARGE_INTEGER aDistanceToMove = { 0 };
+  aDistanceToMove.QuadPart = 0;
+  SetFilePointerEx(myFileHandle, aDistanceToMove, NULL, FILE_BEGIN);
 }
 
 // protect against occasional use of myFileHande in Windows code
@@ -952,9 +957,7 @@ void OSD_File::Rewind() {
 // Build a file if it doesn't exist or create again if it already exists
 // ---------------------------------------------------------------------
 
-void OSD_File :: Build (
-                  const OSD_OpenMode Mode, const OSD_Protection& Protect
-                 ) {
+void OSD_File :: Build ( const OSD_OpenMode Mode, const OSD_Protection& Protect) {
 
  TCollection_AsciiString fName;
 
@@ -980,8 +983,11 @@ void OSD_File :: Build (
   _osd_wnt_set_error ( myError, OSD_WFile );
 
  else {
-
+#ifndef OCCT_UWP
   SetProtection ( Protect );
+#else
+  (void)Protect;
+#endif
   myIO |= FLAG_FILE;
 
  }  // end else
@@ -1027,9 +1033,7 @@ void OSD_File :: Open (const OSD_OpenMode Mode, const OSD_Protection& /*Protect*
 // Append to an existing file
 // ---------------------------------------------------------------------
 
-void OSD_File :: Append (
-                  const OSD_OpenMode Mode, const OSD_Protection& Protect
-                 ) {
+void OSD_File :: Append ( const OSD_OpenMode Mode, const OSD_Protection& Protect) {
 
  BOOL                    fNew = FALSE;
  TCollection_AsciiString fName;
@@ -1059,8 +1063,11 @@ void OSD_File :: Append (
    Seek ( 0, OSD_FromEnd );
 
   } else {
-  
-   SetProtection ( Protect );
+#ifndef OCCT_UWP
+    SetProtection ( Protect );
+#else
+    (void)Protect;
+#endif
    myIO |= FLAG_FILE;
   
   }  // end else
@@ -1170,12 +1177,13 @@ void OSD_File :: ReadLine (
 
     } else if ( dwDummy != 0 ) {  // end-of-file reached ?
 
-     if ( peekChar != '\n' )  // if we did not get a <CR><LF> sequence
-    
-     // adjust file position
-
-      SetFilePointer (myFileHandle, -1, NULL, FILE_CURRENT);
-
+      if (peekChar != '\n')  // if we did not get a <CR><LF> sequence
+      {
+        // adjust file position
+        LARGE_INTEGER aDistanceToMove = { 0 };
+        aDistanceToMove.QuadPart = -1;
+        SetFilePointerEx(myFileHandle, aDistanceToMove, NULL, FILE_CURRENT);
+      }
     } else
      myIO |= FLAG_EOF;
 
@@ -1183,13 +1191,15 @@ void OSD_File :: ReadLine (
 
    } else if ( aSeekPos != 0 )
    {
-     SetFilePointer (myFileHandle, aSeekPos, NULL, FILE_CURRENT);
+     LARGE_INTEGER aDistanceToMove = { 0 };
+     aDistanceToMove.QuadPart = aSeekPos;
+     SetFilePointerEx(myFileHandle, aDistanceToMove, NULL, FILE_CURRENT);
    }
 
   }  // end else
    
  } else if ( myIO & FLAG_SOCKET || myIO & FLAG_PIPE || myIO & FLAG_NAMED_PIPE ) {
-
+#ifndef OCCT_UWP
   dwBytesRead = (DWORD)_get_buffer (myFileHandle, cBuffer, 
                                     (DWORD)NByte, TRUE, myIO & FLAG_SOCKET);
 
@@ -1241,7 +1251,7 @@ void OSD_File :: ReadLine (
    delete [] cDummyBuffer ;
 
   }  // end else
-   
+#endif
  } else
 
   RAISE(  "OSD_File :: ReadLine (): incorrect call - file is a directory"  );
@@ -1360,8 +1370,10 @@ void OSD_File :: Seek (
     RAISE(  "OSD_File :: Seek (): invalid parameter"  );
   
   }  // end switch
+  LARGE_INTEGER aDistanceToMove, aNewFilePointer = { 0 };
+  aDistanceToMove.QuadPart = Offset;
 
-  if (SetFilePointer (myFileHandle, (LONG)Offset, NULL, dwMoveMethod) == 0xFFFFFFFF)
+  if (!SetFilePointerEx(myFileHandle, aDistanceToMove, &aNewFilePointer, dwMoveMethod))
 
    _osd_wnt_set_error ( myError, OSD_WFile );
   
@@ -1464,9 +1476,13 @@ typedef struct _osd_wnt_key {
  void OSD_File::BuildTemporary () {
 
  OSD_Protection prt;
- HKEY           hKey;
- TCHAR          tmpPath[ MAX_PATH ];
+ wchar_t        tmpPath[ MAX_PATH ];
  BOOL           fOK = FALSE;
+
+// Windows Registry not supported by UWP
+#ifndef OCCT_UWP
+ HKEY           hKey;
+
  OSD_WNT_KEY    regKey[ 2 ] = {
  
                  { HKEY_LOCAL_MACHINE,
@@ -1488,25 +1504,25 @@ typedef struct _osd_wnt_key {
    DWORD dwType;
    DWORD dwSize = 0;
 
-   if (  RegQueryValueEx (
-          hKey, "TEMP", NULL, &dwType, NULL, &dwSize
+   if (  RegQueryValueExW (
+          hKey, L"TEMP", NULL, &dwType, NULL, &dwSize
          ) == ERROR_SUCCESS
    ) {
   
-    LPTSTR kVal = ( LPTSTR )HeapAlloc (
+     wchar_t* kVal = (wchar_t*)HeapAlloc (
                              GetProcessHeap (), HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS,
-                             dwSize + sizeof ( TCHAR )
+                             dwSize + sizeof (wchar_t)
                             );
 
-     RegQueryValueEx (  hKey, "TEMP", NULL, &dwType, ( LPBYTE )kVal, &dwSize  );
+     RegQueryValueExW (  hKey, L"TEMP", NULL, &dwType, ( LPBYTE )kVal, &dwSize  );
 
      if ( dwType == REG_EXPAND_SZ )
     
-      ExpandEnvironmentStrings ( kVal, tmpPath, MAX_PATH );
+      ExpandEnvironmentStringsW ( kVal, tmpPath, MAX_PATH );
 
      else
 
-      lstrcpy ( tmpPath, kVal );
+       StringCchCopyW (tmpPath, _countof(tmpPath), kVal);
 
     HeapFree (  GetProcessHeap (), 0, ( LPVOID )kVal  );
     fOK = TRUE;
@@ -1520,15 +1536,21 @@ typedef struct _osd_wnt_key {
   if ( fOK ) break;
 
  }  // end for
+#else
+ if (GetTempPathW(_countof(tmpPath), tmpPath))
+   fOK = TRUE;
+#endif
+ if ( !fOK )       StringCchCopyW(tmpPath, _countof(tmpPath), L"./");
 
- if ( !fOK ) lstrcpy (  tmpPath, "./"  );
- GetTempFileName ( tmpPath, "CSF", 0, tmpPath );
+ GetTempFileNameW ( tmpPath, L"CSF", 0, tmpPath );
 
  if ( IsOpen() )
   Close();
 
- SetPath (  OSD_Path ( tmpPath )  );
+ char tmpPathA[MAX_PATH];
+ WideCharToMultiByte(CP_UTF8, 0, tmpPath, -1, tmpPathA, sizeof(tmpPathA), NULL, NULL);
+ SetPath(OSD_Path(tmpPathA));
+
  Build   (  OSD_ReadWrite, prt    );
 }  // end OSD_File :: BuildTemporary
 
@@ -1598,8 +1620,12 @@ void OSD_File :: UnLock () {
  
   LARGE_INTEGER aSize;
   aSize.QuadPart = Size();
-  if (!UnlockFile (myFileHandle, 0, 0, aSize.LowPart, aSize.HighPart))
-   
+
+  OVERLAPPED anOverlappedArea;
+  anOverlappedArea.Offset = 0;
+  anOverlappedArea.OffsetHigh = 0;
+
+  if (!UnlockFileEx(myFileHandle, 0, aSize.LowPart, aSize.HighPart,&anOverlappedArea))
    _osd_wnt_set_error ( myError, OSD_WFile );
 
   ImperativeFlag = Standard_False;
@@ -1651,9 +1677,8 @@ Standard_Size OSD_File::Size()
 // -------------------------------------------------------------------------- 
 // Print contains of a file
 // -------------------------------------------------------------------------- 
-
-void OSD_File :: Print ( const OSD_Printer& WhichPrinter ) {
-
+void OSD_File :: Print ( const OSD_Printer& WhichPrinter) {
+#ifndef OCCT_UWP
  if (myFileHandle != INVALID_HANDLE_VALUE)
 
   RAISE(  "OSD_File :: Print (): incorrect call - file opened"  );
@@ -1668,9 +1693,10 @@ void OSD_File :: Print ( const OSD_Printer& WhichPrinter ) {
                       (const wchar_t*)fNameW.ToExtString ()  )   )
 
   _osd_wnt_set_error ( myError, OSD_WFile );
-
+#else
+  (void)WhichPrinter;
+#endif
 }  // end OSD_File :: Print
-
 // -------------------------------------------------------------------------- 
 // Test if a file is open
 // -------------------------------------------------------------------------- 
@@ -1687,6 +1713,7 @@ Standard_Boolean OSD_File :: IsOpen () const {
 #define __leave return retVal
 #endif
 
+#ifndef OCCT_UWP
 PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd (
                                  const OSD_Protection& prot, BOOL fDir, wchar_t* fName
                                 ) {
@@ -1945,6 +1972,7 @@ leave: ;     // added for VisualAge
  return retVal;
  
 }  // end _osd_wnt_protection_to_sd */
+#endif
 
 #if defined(__CYGWIN32__) || defined(__MINGW32__)
 #undef __try
@@ -1954,17 +1982,13 @@ leave: ;     // added for VisualAge
 
 static void __fastcall _test_raise ( HANDLE hFile, Standard_CString str ) {
 
- Standard_Character buff[ 64 ];
+  if (hFile == INVALID_HANDLE_VALUE) {
+    TCollection_AsciiString buff = "OSD_File :: ";
+    buff += str;
+    buff += " (): wrong access";
 
- if (hFile == INVALID_HANDLE_VALUE) {
-  strcpy (  buff, "OSD_File :: "  );
-  strcat (  buff, str );
-  strcat (  buff, " (): wrong access"  );
-
-  Standard_ProgramError :: Raise ( buff );
- }  // end if
+    Standard_ProgramError::Raise(buff.ToCString());
+  }  // end if
 
 }  // end _test_raise
 
@@ -2006,6 +2030,7 @@ static Standard_Integer __fastcall _get_line (Standard_PCharacter& buffer, DWORD
  return dwBuffSize;
 }  // end _get_line
 
+#ifndef OCCT_UWP
 static int __fastcall _get_buffer (
                         HANDLE hChannel,
                         Standard_PCharacter& buffer, 
@@ -2283,7 +2308,7 @@ static DWORD __fastcall _get_dir_access_mask ( OSD_SingleProtection prt ) {
  return retVal;
 
 }  // end _get_dir_access_mask
-
+#endif
 static HANDLE __fastcall _open_file (
                           Standard_CString fName,
                           OSD_OpenMode oMode,
@@ -2324,12 +2349,24 @@ static HANDLE __fastcall _open_file (
 
  // make wide character string from UTF-8
  TCollection_ExtendedString fNameW(fName, Standard_True);
+#ifndef OCCT_UWP
  retVal = CreateFileW (
            (const wchar_t*) fNameW.ToExtString(), dwDesiredAccess,
            FILE_SHARE_READ | FILE_SHARE_WRITE,
            NULL, dwCreationDistribution, FILE_ATTRIBUTE_NORMAL, NULL
           );
-
+#else
+ CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams = {};
+ pCreateExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ pCreateExParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
+ pCreateExParams.lpSecurityAttributes = NULL;
+ pCreateExParams.hTemplateFile = NULL;
+ retVal = CreateFile2 (
+           (const wchar_t*) fNameW.ToExtString(), dwDesiredAccess,
+           FILE_SHARE_READ | FILE_SHARE_WRITE,
+           dwCreationDistribution, &pCreateExParams
+          );
+#endif
  if ( retVal          == INVALID_HANDLE_VALUE &&
       dwOptions       == OPEN_APPEND          &&
       GetLastError () == ERROR_FILE_NOT_FOUND
@@ -2337,12 +2374,24 @@ static HANDLE __fastcall _open_file (
 
  
   dwCreationDistribution = CREATE_ALWAYS;
-  
+#ifndef OCCT_UWP
   retVal = CreateFileW (
             (const wchar_t*) fNameW.ToExtString(), dwDesiredAccess,
             FILE_SHARE_READ | FILE_SHARE_WRITE,
             NULL, dwCreationDistribution, FILE_ATTRIBUTE_NORMAL, NULL
            );
+#else
+  CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams2 = {};
+  pCreateExParams2.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+  pCreateExParams2.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
+  pCreateExParams2.lpSecurityAttributes = NULL;
+  pCreateExParams2.hTemplateFile = NULL;
+  retVal = CreateFile2(
+    (const wchar_t*)fNameW.ToExtString(), dwDesiredAccess,
+    FILE_SHARE_READ | FILE_SHARE_WRITE,
+    dwCreationDistribution, &pCreateExParams2
+  );
+#endif
 
   *fNew = TRUE;
 
@@ -2357,7 +2406,6 @@ Standard_Integer __fastcall _get_file_type (
                             ) {
 
  Standard_Integer retVal = 0;
- DWORD            dwType;
  int              fileType;
 
  fileType = (fileHandle == INVALID_HANDLE_VALUE ? 
@@ -2375,10 +2423,11 @@ Standard_Integer __fastcall _get_file_type (
   {
    // make wide character string from UTF-8
    TCollection_ExtendedString fNameW(fName, Standard_True);
-   dwType = GetFileAttributesW ( (const wchar_t*) fNameW.ToExtString() );
-   if (  dwType  != 0xFFFFFFFF  )
 
-    retVal =  dwType & FILE_ATTRIBUTE_DIRECTORY ? FLAG_DIRECTORY : FLAG_FILE;
+   WIN32_FILE_ATTRIBUTE_DATA aFileInfo;
+   if (GetFileAttributesExW((const wchar_t*)fNameW.ToExtString(), GetFileExInfoStandard, &aFileInfo))
+
+    retVal = aFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? FLAG_DIRECTORY : FLAG_FILE;
 
    else
 
@@ -2410,6 +2459,8 @@ Standard_Integer __fastcall _get_file_type (
 #define __leave return retVal
 #endif
 
+#ifndef OCCT_UWP
+// None of the existing security APIs are supported in a UWP applications
 BOOL __fastcall _osd_wnt_sd_to_protection (
                  PSECURITY_DESCRIPTOR pSD, OSD_Protection& prot, BOOL fDir
                 ) {
@@ -2495,13 +2546,14 @@ leave: ;      // added for VisualAge
  return retVal;
 
 }  // end _osd_wnt_sd_to_protection
+#endif
 
 #if defined(__CYGWIN32__) || defined(__MINGW32__)
 #undef __try
 #undef __finally
 #undef __leave
 #endif
-
+#ifndef OCCT_UWP
 static OSD_SingleProtection __fastcall _get_protection ( DWORD mask ) {
 
  OSD_SingleProtection retVal;
@@ -2717,6 +2769,7 @@ static OSD_SingleProtection __fastcall _get_protection_dir ( DWORD mask ) {
  return retVal;
 
 }  // end _get_protection_dir
+#endif
 
 #if defined(__CYGWIN32__) || defined(__MINGW32__)
 #define __try
@@ -2724,6 +2777,7 @@ static OSD_SingleProtection __fastcall _get_protection_dir ( DWORD mask ) {
 #define __leave return fOK
 #endif
 
+#ifndef OCCT_UWP
 BOOL __fastcall _osd_print (const Standard_PCharacter pName, const wchar_t* fName ) {
 
  BOOL   fOK, fJob;                
@@ -2802,6 +2856,7 @@ leave: ;       // added for VisualAge
  return fOK;
                 
 }  // end _osd_print
+#endif
 
 #if defined(__CYGWIN32__) || defined(__MINGW32__)
 #undef __try
index f8f78b2..399467c 100644 (file)
@@ -317,7 +317,7 @@ Standard_Boolean OSD_FileIterator :: More () {
 
   // make wchar_t string from UTF-8
   TCollection_ExtendedString wcW(wc);
-  myHandle = FindFirstFileW ((const wchar_t*)wcW.ToExtString(), (PWIN32_FIND_DATAW)myData);
+  myHandle = FindFirstFileExW((const wchar_t*)wcW.ToExtString(), FindExInfoStandard, (PWIN32_FIND_DATAW)myData, FindExSearchNameMatch, NULL, 0);
 
   if (  myHandle == INVALID_HANDLE_VALUE  )
   
index ebf9694..c70994e 100644 (file)
@@ -363,6 +363,11 @@ Standard_Integer OSD_FileNode::Error()const{
 //----------------------------------------------------------------------------
 
 #define STRICT
+#ifdef NONLS
+#undef NONLS
+#endif
+#include <windows.h>
+
 #include <OSD_FileNode.hxx>
 #include <OSD_Protection.hxx>
 #include <Quantity_Date.hxx>
@@ -375,13 +380,18 @@ Standard_Integer OSD_FileNode::Error()const{
 # include <tchar.h>
 #endif  // _INC_TCHAR
 
+#include <Strsafe.h>
+
 #define TEST_RAISE( arg ) _test_raise (  fName, ( arg )  )
 #define RAISE( arg ) Standard_ProgramError :: Raise (  ( arg )  )
 
+#ifndef OCCT_UWP
+// None of the existing security APIs are supported in a UWP applications
 PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd ( const OSD_Protection&, BOOL, wchar_t* = NULL );
 BOOL                 __fastcall _osd_wnt_sd_to_protection (
                                  PSECURITY_DESCRIPTOR pSD, OSD_Protection& prot, BOOL
                                 );
+#endif
 Standard_Integer     __fastcall _get_file_type ( Standard_CString, HANDLE );
 
 void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
@@ -447,12 +457,14 @@ Standard_Boolean OSD_FileNode::Exists () {
 
  // make wide character string from UTF-8
  TCollection_ExtendedString fNameW(fName);
- if (  GetFileAttributesW ( (const wchar_t*) fNameW.ToExtString ()  ) == 0xFFFFFFFF  ) {
+
+ WIN32_FILE_ATTRIBUTE_DATA aFileInfo;
+
+ if ( !GetFileAttributesExW((const wchar_t*)fNameW.ToExtString(), GetFileExInfoStandard, &aFileInfo)) {
+
   if (  GetLastError () != ERROR_FILE_NOT_FOUND  )
+    _osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
 
-   _osd_wnt_set_error (  myError, OSD_WFileNode, fName.ToCString ()  );
  } else
 
   retVal = Standard_True;
@@ -480,9 +492,7 @@ void OSD_FileNode::Remove () {
   case FLAG_FILE:
 
    if (   !DeleteFileW (  (const wchar_t*) fNameW.ToExtString ()  )   )
-
-    _osd_wnt_set_error (  myError, OSD_WFileNode,  fName.ToCString ()  );
-
+     _osd_wnt_set_error (  myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
   break;
 
   case FLAG_DIRECTORY:
@@ -492,16 +502,11 @@ void OSD_FileNode::Remove () {
 //      ne pas detruire un repertoire no vide.
 
    if (   !RemoveDirectoryW ( (const wchar_t*) fNameW.ToExtString ()  )   )
-
-    _osd_wnt_set_error (  myError, OSD_WFileNode, fName.ToCString ()  );
-
+     _osd_wnt_set_error (  myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
   break;
 
   default:
-
-   RAISE(  TEXT( "OSD_FileNode :: Remove ():"
-                 " invalid file type - neither file nor directory" )  );
-
+   RAISE("OSD_FileNode :: Remove (): invalid file type - neither file nor directory");
  }  // end switch
 
 }  // end OSD_FileNode :: Remove
@@ -533,9 +538,7 @@ void OSD_FileNode::Move ( const OSD_Path& NewPath ) {
                      MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED
                      )
        )
-     _osd_wnt_set_error ( myError, OSD_WFileNode,
-                          fName.ToCString (), fNameDst.ToCString ()  );
+     _osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
   break;
 
   case FLAG_DIRECTORY:
@@ -544,17 +547,11 @@ void OSD_FileNode::Move ( const OSD_Path& NewPath ) {
             (const wchar_t*) fNameW.ToExtString (), (const wchar_t*) fNameDstW.ToExtString ()
            )
    )
-    _osd_wnt_set_error ( myError, OSD_WFileNode,
-                         fName.ToCString (), fNameDst.ToCString ()  );
-
+   _osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
   break;
 
   default:
-
-   RAISE(  TEXT( "OSD_FileNode :: Move (): "
-                 "invalid file type - neither file nor directory" )  );
-
+   RAISE("OSD_FileNode :: Move (): invalid file type - neither file nor directory");
  }  // end switch
 
 }  // end OSD_FileNode :: Move
@@ -580,11 +577,14 @@ void OSD_FileNode::Copy ( const OSD_Path& ToPath ) {
  switch (_get_file_type (fName.ToCString(), INVALID_HANDLE_VALUE)) {
 
   case FLAG_FILE:
-
-   if (!CopyFileW ((const wchar_t*)fNameW.ToExtString (),
-                   (const wchar_t*)fNameDstW.ToExtString (), FALSE ))
-     _osd_wnt_set_error (myError, OSD_WFileNode,
-                         fName.ToCString (), fNameDst.ToCString ());
+#ifndef OCCT_UWP
+    if (!CopyFileW((const wchar_t*)fNameW.ToExtString(),
+      (const wchar_t*)fNameDstW.ToExtString(), FALSE))
+#else
+   if (CopyFile2((const wchar_t*)fNameW.ToExtString (),
+                 (const wchar_t*)fNameDstW.ToExtString (), FALSE ) != S_OK)
+#endif
+   _osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
   break;
 
   case FLAG_DIRECTORY:
@@ -593,22 +593,21 @@ void OSD_FileNode::Copy ( const OSD_Path& ToPath ) {
             (const wchar_t*)fNameW.ToExtString (), (const wchar_t*)fNameDstW.ToExtString ()
           )
    )
-    _osd_wnt_set_error (
-     myError, OSD_WFileNode, fName.ToCString (), fNameDst.ToCString ()
-    );
+
+   _osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
 
   break;
 
   default:
-
-   RAISE(  TEXT( "OSD_FileNode :: Copy ():"
-                 " invalid file type - neither file nor directory" )  );
+   RAISE("OSD_FileNode :: Copy (): invalid file type - neither file nor directory");
 
  }  // end switch
 
 }  // end OSD_FileNode :: Copy
 
+// None of the existing security APIs are supported in a UWP applications
+#ifndef OCCT_UWP
+
 //=======================================================================
 //function : Protection
 //purpose  : 
@@ -671,8 +670,7 @@ void OSD_FileNode::SetProtection ( const OSD_Protection& Prot ) {
                        (const wchar_t*) fNameW.ToExtString (), DACL_SECURITY_INFORMATION, pSD
                       )
  )
-  
-  _osd_wnt_set_error (  myError, OSD_WFileNode, fName.ToCString ()  );
+  _osd_wnt_set_error (  myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
 
  if ( pSD != NULL )
 
@@ -680,6 +678,46 @@ void OSD_FileNode::SetProtection ( const OSD_Protection& Prot ) {
 
 }  // end OSD_FileNode :: SetProtection
 
+#else /* UWP stub */
+
+#include <io.h>
+
+//=======================================================================
+//function : Protection
+//purpose  : 
+//=======================================================================
+
+OSD_Protection OSD_FileNode::Protection ()
+{
+ TCollection_AsciiString fName;
+
+ myPath.SystemName ( fName );
+ TCollection_ExtendedString fNameW(fName);
+
+ OSD_SingleProtection aProt = OSD_None;
+ if (_waccess_s ((const wchar_t*)fNameW.ToExtString(), 6))
+   aProt = OSD_RW;
+ else if (_waccess_s ((const wchar_t*)fNameW.ToExtString(), 2))
+   aProt = OSD_W;
+ else if (_waccess_s ((const wchar_t*)fNameW.ToExtString(), 4))
+   aProt = OSD_R;
+
+ // assume full access for system and none for everybody
+ OSD_Protection retVal (OSD_RWXD, aProt, aProt, OSD_None);
+ return retVal;
+}  // end OSD_FileNode :: Protection
+
+//=======================================================================
+//function : SetProtection
+//purpose  : 
+//=======================================================================
+
+void OSD_FileNode::SetProtection ( const OSD_Protection& /*Prot*/ )
+{
+}  // end OSD_FileNode :: SetProtection
+
+#endif
+
 //=======================================================================
 //function : AccessMoment
 //purpose  : 
@@ -714,8 +752,7 @@ Quantity_Date OSD_FileNode::AccessMoment () {
                     );
 }
  else
-
-  _osd_wnt_set_error (  myError, OSD_WFileNode, fName.ToCString ()  );
+  _osd_wnt_set_error (  myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
 
  return retVal;
 
@@ -755,8 +792,7 @@ Quantity_Date OSD_FileNode::CreationMoment () {
                     );
 }
  else
-
-  _osd_wnt_set_error (  myError, OSD_WFileNode, fName.ToCString ()  );
+  _osd_wnt_set_error (  myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
 
  return retVal;
 
@@ -809,26 +845,30 @@ Standard_Integer OSD_FileNode::Error () const {
 void _osd_wnt_set_error ( OSD_Error& err, OSD_WhoAmI who, ... ) {
 
  DWORD              errCode;
- Standard_Character buffer[ 2048 ];
+
+ wchar_t buffer[2048];
+
  va_list            arg_ptr;
 
  va_start ( arg_ptr, who);
 
  errCode = GetLastError ();
 
- if (  !FormatMessage (
-         FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
+ if (  !FormatMessageW (
+         FORMAT_MESSAGE_FROM_SYSTEM,
          0, errCode, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ),
          buffer, 2048, &arg_ptr
         )
  ) {
-  sprintf ( buffer, "error code %d", (Standard_Integer)errCode );
+  StringCchPrintfW(buffer, _countof(buffer), L"error code %d", (Standard_Integer)errCode);
+
   SetLastError ( errCode );
 
  }  // end if
 
- err.SetValue ( errCode, who, buffer );
+ char aBufferA[2048];
+ WideCharToMultiByte(CP_UTF8, 0, buffer, -1, aBufferA, sizeof(aBufferA), NULL, NULL);
+ err.SetValue(errCode, who, aBufferA);
 
  va_end ( arg_ptr );
 
@@ -851,11 +891,23 @@ static BOOL __fastcall _get_file_time (
  HANDLE     hFile = INVALID_HANDLE_VALUE;
 
  __try {
-
-  if (   (  hFile = CreateFileW ((const wchar_t*) fName, 0, 0,
-                                 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
-         ) == INVALID_HANDLE_VALUE
-  ) __leave;
+#ifndef OCCT_UWP
+   if ((hFile = CreateFileW((const wchar_t*)fName, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
+     ) == INVALID_HANDLE_VALUE
+     )
+#else
+   CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams = {};
+   pCreateExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+   pCreateExParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
+   pCreateExParams.lpSecurityAttributes = NULL;
+   pCreateExParams.hTemplateFile = NULL;
+   if ((hFile = CreateFile2(
+     (const wchar_t*)fName, NULL, NULL,
+     OPEN_EXISTING, &pCreateExParams)
+     ) == INVALID_HANDLE_VALUE
+     )
+#endif
+    __leave;
 
   if (  !GetFileTime ( hFile, &ftCreationTime, NULL, &ftLastWriteTime )  ) __leave;
 
@@ -890,17 +942,12 @@ leave: ;      // added for VisualAge
 #endif
 
 static void __fastcall _test_raise ( TCollection_AsciiString fName, Standard_CString str ) {
-
- Standard_Character buff[ 64 ];
-
  if (  fName.IsEmpty ()  ) {
-  strcpy (  buff, "OSD_FileNode :: "  );
-  strcat (  buff, str );
-  strcat (  buff, " (): wrong access"  );
+   TCollection_AsciiString buff = "OSD_FileNode :: ";
+   buff += str;
+   buff += " (): wrong access";
 
-  Standard_ProgramError :: Raise ( buff );
+   Standard_ProgramError::Raise(buff.ToCString());
  }  // end if
 
 }  // end _test_raise
index 99dcd78..f04055e 100644 (file)
@@ -57,13 +57,14 @@ public:
   
   //! Copies <me> to another FileNode
   Standard_EXPORT void Copy (const OSD_Path& ToPath);
-  
+
+  // None of the existing security APIs are supported in a UWP applications
   //! Returns access mode of <me>.
   Standard_EXPORT OSD_Protection Protection();
   
   //! Changes protection of the FileNode
   Standard_EXPORT void SetProtection (const OSD_Protection& Prot);
-  
+
   //! Returns last write access.
   //! On UNIX, AccessMoment and CreationMoment return the
   //! same value.
index 8bf2a08..4ab93a9 100644 (file)
@@ -200,7 +200,7 @@ static TCollection_AsciiString interAddr;
 static Standard_Integer        memSize;
 
 OSD_Host :: OSD_Host () {
-
+#ifndef OCCT_UWP
  DWORD              nSize;
  Standard_Character szHostName[ MAX_COMPUTERNAME_LENGTH + 1 ];
  char*              hostAddr = 0;
@@ -280,7 +280,7 @@ OSD_Host :: OSD_Host () {
  if ( fInit )
 
   myName = hostName;
-
+#endif
 }  // end constructor
 
 TCollection_AsciiString OSD_Host :: SystemVersion () {
index f96df93..2d578d8 100644 (file)
@@ -57,7 +57,7 @@ void OSD_MemInfo::Update()
   {
     myCounters[anIter] = Standard_Size(-1);
   }
-
+#ifndef OCCT_UWP
 #if defined(_WIN32)
 #if (_WIN32_WINNT >= 0x0500)
   MEMORYSTATUSEX aStatEx;
@@ -167,6 +167,7 @@ void OSD_MemInfo::Update()
     myCounters[MemHeapUsage] = aStats.size_in_use;
   }
 #endif
+#endif
 }
 
 // =======================================================================
index 8b80fba..28de4c6 100644 (file)
     #endif
 #endif
 
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(OCCT_UWP)
 namespace {
   // for a 64-bit app running under 64-bit Windows, this is FALSE
   static bool isWow64()
   {
     typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE , PBOOL);
     BOOL bIsWow64 = FALSE;
+
     HMODULE aKern32Module = GetModuleHandleW(L"kernel32");
     LPFN_ISWOW64PROCESS aFunIsWow64 = (aKern32Module == NULL) ? (LPFN_ISWOW64PROCESS )NULL
       : (LPFN_ISWOW64PROCESS)GetProcAddress(aKern32Module, "IsWow64Process");
@@ -62,11 +63,14 @@ Standard_Integer OSD_Parallel::NbLogicalProcessors()
 #ifdef _WIN32
   // GetSystemInfo() will return the number of processors in a data field in a SYSTEM_INFO structure.
   SYSTEM_INFO aSysInfo;
+#ifndef OCCT_UWP
   if ( isWow64() )
   {
     typedef BOOL (WINAPI *LPFN_GSI)(LPSYSTEM_INFO );
+
     HMODULE aKern32 = GetModuleHandleW(L"kernel32");
     LPFN_GSI aFuncSysInfo = (LPFN_GSI )GetProcAddress(aKern32, "GetNativeSystemInfo");
+
     // So, they suggest 32-bit apps should call this instead of the other in WOW64
     if ( aFuncSysInfo != NULL )
     {
@@ -81,6 +85,9 @@ Standard_Integer OSD_Parallel::NbLogicalProcessors()
   {
     GetSystemInfo(&aSysInfo);
   }
+#else
+  GetNativeSystemInfo(&aSysInfo);
+#endif
   aNumLogicalProcessors = aSysInfo.dwNumberOfProcessors;
 #else
   // These are the choices. We'll check number of processors online.
index b73c1e2..065ed73 100644 (file)
@@ -210,7 +210,7 @@ OSD_Process :: OSD_Process () {
 
 Standard_Integer OSD_Process::Spawn (const TCollection_AsciiString& cmd,
                            const Standard_Boolean ShowWindow /* = Standard_True */) {
-
+#ifndef OCCT_UWP
  STARTUPINFO         si;
  PROCESS_INFORMATION pi;
  DWORD aRes = 0;
@@ -248,6 +248,11 @@ Standard_Integer OSD_Process::Spawn (const TCollection_AsciiString& cmd,
  }  // end else
 
  return aRes;
+#else
+  (void)cmd;
+  (void)ShowWindow;
+  return 0;
+#endif
 }  // end OSD_Process :: Spawn
 
 void OSD_Process :: TerminalType ( TCollection_AsciiString& Name ) {
@@ -273,6 +278,7 @@ Quantity_Date OSD_Process :: SystemDate () {
 
 TCollection_AsciiString OSD_Process :: UserName () 
 {
+#ifndef OCCT_UWP
        Standard_PCharacter pBuff = new char[UNLEN + 1];
        DWORD                   dwSize = UNLEN + 1;
        TCollection_AsciiString retVal;
@@ -287,10 +293,13 @@ TCollection_AsciiString OSD_Process :: UserName ()
        }
        delete [] pBuff;
        return retVal;
+#else
+  return "";
+#endif
 }  // end OSD_Process :: UserName
 
 Standard_Boolean OSD_Process :: IsSuperUser () {
-
+#ifndef OCCT_UWP
  Standard_Boolean retVal = FALSE;
  PSID             pSIDadmin;
  HANDLE           hProcessToken = INVALID_HANDLE_VALUE;
@@ -327,7 +336,9 @@ Standard_Boolean OSD_Process :: IsSuperUser () {
  if ( pTKgroups     != NULL                 ) FreeTokenInformation ( pTKgroups );
 
  return retVal;
-
+#else
+ return FALSE;
+#endif
 }  // end OSD_Process :: IsSuperUser
 
 Standard_Integer OSD_Process :: ProcessId () {
@@ -337,9 +348,8 @@ Standard_Integer OSD_Process :: ProcessId () {
 }  // end OSD_Process :: ProcessId
 
 OSD_Path OSD_Process :: CurrentDirectory () {
-
   OSD_Path anCurrentDirectory;
-
+#ifndef OCCT_UWP
   DWORD dwSize = PATHLEN + 1;
   Standard_WideChar* pBuff = new wchar_t[dwSize];
 
@@ -353,6 +363,7 @@ OSD_Path OSD_Process :: CurrentDirectory () {
     _osd_wnt_set_error ( myError, OSD_WProcess );
  
   delete[] pBuff;
+#endif
   return anCurrentDirectory;
 }  // end OSD_Process :: CurrentDirectory
 
index 333bf91..c39ef0c 100644 (file)
@@ -184,13 +184,15 @@ void OSD_SharedLibrary::Destroy() {
 #endif
 #include <windows.h>
 
-
 #include <OSD_Path.hxx>
 #include <OSD_SharedLibrary.hxx>
 #include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
 
 static DWORD              lastDLLError;
-static Standard_Character errMsg[ 1024 ];
+
+static wchar_t errMsg[1024];
+static char errMsgA[1024];
 
 OSD_SharedLibrary :: OSD_SharedLibrary () {
 
@@ -224,7 +226,13 @@ void OSD_SharedLibrary :: SetName ( const Standard_CString aName ) {
  name = path.Name ();
  name.AssignCat (  path.Extension ()  );
 
- myHandle = GetModuleHandle (  name.ToCString ()  );
+#ifndef OCCT_UWP
+ myHandle = GetModuleHandle(name.ToCString());
+#else
+ TCollection_ExtendedString nameW(name);
+ myHandle = LoadPackagedLibrary ((const wchar_t*)nameW.ToExtString(), NULL  );
+ FreeLibrary ((HMODULE) myHandle);
+#endif
 
 }  // end OSD_SharedLibrary :: SetName
 
@@ -238,15 +246,17 @@ Standard_Boolean OSD_SharedLibrary :: DlOpen ( const OSD_LoadMode /*Mode*/ ) {
 
  Standard_Boolean retVal = Standard_True;
 
- if (  (  myHandle ) == NULL &&
-       (  myHandle = ( HINSTANCE )LoadLibraryEx (
-                                   myName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH
-                                  )  ) == NULL
- ) {
-  lastDLLError = GetLastError ();
-  retVal       = Standard_False;
+ if ( myHandle == NULL ) {
+#ifndef OCCT_UWP
+  myHandle = (HINSTANCE)LoadLibraryEx(myName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+#else
+  TCollection_ExtendedString myNameW(myName);
+  myHandle = (HINSTANCE)LoadPackagedLibrary((const wchar_t*)myNameW.ToExtString(), NULL);
+#endif
+  if ( myHandle == NULL ) {
+   lastDLLError = GetLastError ();
+   retVal       = Standard_False;
+  }
  }  // end if
 
  return retVal;
@@ -273,13 +283,14 @@ void OSD_SharedLibrary :: DlClose () const {
 
 Standard_CString OSD_SharedLibrary :: DlError () const {
 
- FormatMessage (
+ FormatMessageW (
   FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
-  0, lastDLLError, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ), errMsg, 1024, ( va_list* )&myName
+  0, lastDLLError, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ),
+   errMsg, 1024, ( va_list* )&myName
  );
 
return errMsg;
-
WideCharToMultiByte(CP_UTF8, 0, errMsg, -1, errMsgA, sizeof(errMsgA), NULL, NULL);
+ return errMsgA;
 }  // end OSD_SharedLibrary :: DlError
 
 void OSD_SharedLibrary :: Destroy () {
index b011a4f..93ca383 100644 (file)
@@ -42,7 +42,6 @@ static inline Standard_Real GetWallClockTime ()
 }
 
 #else
-
 //-------------------  Windows NT  ------------------
 
 #define STRICT
@@ -62,7 +61,11 @@ static inline Standard_Real GetWallClockTime ()
   LARGE_INTEGER time;
   return isOk && QueryPerformanceCounter (&time) ? 
          (Standard_Real)time.QuadPart / (Standard_Real)freq.QuadPart :
+#ifndef OCCT_UWP
          0.001 * GetTickCount();
+#else
+         0.001 * GetTickCount64();
+#endif
 }
 
 #endif /* _WIN32 */
index a77c0b8..13328f7 100644 (file)
 /***/
 #include <OSD_WNT_1.hxx>
 
+#include <Strsafe.h>
 #include <wchar.h>
 #include <stdlib.h>
+
+#include <Standard_Macro.hxx>
+
 /***/
+#ifndef OCCT_UWP
 static void Init ( void );
 /***/
 class Init_OSD_WNT {  // provides initialization
@@ -37,6 +42,7 @@ class Init_OSD_WNT {  // provides initialization
 }; // end Init_OSD_WNT
 
 static Init_OSD_WNT initOsdWnt;
+#endif
 /***/
 static BOOL   fInit = FALSE;
 static PSID*  predefinedSIDs;
@@ -59,6 +65,8 @@ static RESPONSE_DIR_PROC _response_dir_proc;
 #define SID_WORLD         7
 #define SID_NULL          8
 /***/
+#ifndef OCCT_UWP
+// None of the existing security APIs are supported in a UWP applications
 /******************************************************************************/
 /* Function : AllocSD                                                       */
 /* Purpose  : Allocates and initializes security identifier                 */
@@ -597,7 +605,7 @@ void FreeAce ( PVOID pACE ) {
  HeapFree ( hHeap, 0, pACE );
 
 }  /* end FreeAce */
-
+#endif
 #define WILD_CARD     L"/*.*"
 #define WILD_CARD_LEN (  sizeof ( WILD_CARD )  )
 
@@ -697,23 +705,24 @@ retry:
  retVal = CreateDirectoryW ( newDir, NULL );
 
  if (   retVal || (  !retVal && GetLastError () == ERROR_ALREADY_EXISTS  )   ) {
-
+  size_t anOldDirLength;
+  StringCchLengthW (oldDir, sizeof(oldDir) / sizeof(oldDir[0]), &anOldDirLength);
   if (   (  pFD = ( PWIN32_FIND_DATAW )HeapAlloc (
                                        hHeap, 0, sizeof ( WIN32_FIND_DATAW )
                                       )
          ) != NULL &&
-         (  pName = ( LPWSTR )HeapAlloc (
-                               hHeap, 0, lstrlenW ( oldDir ) + WILD_CARD_LEN +
-                               sizeof (  L'\x00'  )
-                              )
+         (
+           pName = (LPWSTR)HeapAlloc(
+             hHeap, 0, anOldDirLength + WILD_CARD_LEN +
+             sizeof(L'\x00')
+           )
          ) != NULL
   ) {
-
-   lstrcpyW ( pName, oldDir    );
-   lstrcatW ( pName, WILD_CARD );
+    StringCchCopyW (pName, sizeof(pName) / sizeof(pName[0]), oldDir);
+    StringCchCatW  (pName, sizeof(pName), WILD_CARD);
 
    retVal = TRUE;
-   fFind  = (  hFindFile = FindFirstFileW ( pName, pFD )  ) != INVALID_HANDLE_VALUE;
+   fFind  = (  hFindFile = FindFirstFileExW(pName, FindExInfoStandard, pFD, FindExSearchNameMatch, NULL, 0)  ) != INVALID_HANDLE_VALUE;
 
    while ( fFind ) {
   
@@ -721,28 +730,35 @@ retry:
           pFD -> cFileName[ 0 ] != L'.' &&
           pFD -> cFileName[ 1 ] != L'.'
     ) {
-  
-     if (   ( pFullNameSrc = ( LPWSTR )HeapAlloc (
-                                        hHeap, 0,
-                                        lstrlenW ( oldDir ) + lstrlenW ( pFD -> cFileName ) +
-                                        sizeof (  L'/'  ) + sizeof ( L'\x00'  )
-                                       )
-            ) == NULL ||
-            ( pFullNameDst = ( LPWSTR )HeapAlloc (
-                                        hHeap, 0,
-                                        lstrlenW ( newDir ) + lstrlenW ( pFD -> cFileName ) +
-                                        sizeof (  L'/'  ) + sizeof (  L'\x00'  )
-                                       )
-            ) == NULL
+     size_t anOldDirLength2;
+     size_t aNewDirLength;
+     size_t aFileNameLength;
+
+     StringCchLengthW (oldDir, sizeof(oldDir) / sizeof(oldDir[0]), &anOldDirLength2);
+     StringCchLengthW (newDir, sizeof(newDir) / sizeof(newDir[0]), &aNewDirLength);
+     StringCchLengthW (pFD->cFileName, sizeof(pFD->cFileName) / sizeof(pFD->cFileName[0]), &aFileNameLength);
+
+     if (    (pFullNameSrc = (LPWSTR)HeapAlloc(
+                                  hHeap, 0,
+                                  anOldDirLength2 + aFileNameLength +
+                                  sizeof(L'/') + sizeof(L'\x00')
+                                 )
+             ) == NULL ||
+             (pFullNameDst = (LPWSTR)HeapAlloc(
+                                      hHeap, 0,
+                                      aNewDirLength + aFileNameLength +
+                                      sizeof(L'/') + sizeof(L'\x00')
+                                 )
+             ) == NULL
      ) break;
-  
-     lstrcpyW ( pFullNameSrc, oldDir );
-     lstrcatW ( pFullNameSrc, L"/"  );
-     lstrcatW ( pFullNameSrc, pFD -> cFileName );
 
-     lstrcpyW ( pFullNameDst, newDir );
-     lstrcatW ( pFullNameDst, L"/"  );
-     lstrcatW ( pFullNameDst, pFD -> cFileName );
+     StringCchCopyW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), oldDir);
+     StringCchCatW  (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), L"/");
+     StringCchCatW  (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), pFD->cFileName);
+
+     StringCchCopyW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), newDir);
+     StringCchCatW  (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), L"/");
+     StringCchCatW  (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), pFD->cFileName);
 
      if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
 
@@ -862,22 +878,24 @@ BOOL CopyDirectory ( LPCWSTR dirSrc, LPCWSTR dirDst ) {
 
  if (   retVal || (  !retVal && GetLastError () == ERROR_ALREADY_EXISTS  )   ) {
 
+   size_t aDirSrcLength;
+   StringCchLengthW (dirSrc, sizeof(dirSrc) / sizeof(dirSrc[0]), &aDirSrcLength);
+
   if (   (  pFD = ( PWIN32_FIND_DATAW )HeapAlloc (
                                        hHeap, 0, sizeof ( WIN32_FIND_DATAW )
                                       )
          ) != NULL &&
          (  pName = ( LPWSTR )HeapAlloc (
-                               hHeap, 0, lstrlenW ( dirSrc ) + WILD_CARD_LEN +
+                               hHeap, 0, aDirSrcLength + WILD_CARD_LEN +
                                sizeof (  L'\x00'  )
                               )
          ) != NULL
   ) {
-
-   lstrcpyW ( pName, dirSrc    );
-   lstrcatW ( pName, WILD_CARD );
+   StringCchCopyW (pName, sizeof(pName) / sizeof(pName[0]), dirSrc);
+   StringCchCatW (pName, sizeof(pName) / sizeof(pName[0]), WILD_CARD);
 
    retVal = TRUE;
-   fFind  = (  hFindFile = FindFirstFileW ( pName, pFD )  ) != INVALID_HANDLE_VALUE;
+   fFind = (hFindFile = FindFirstFileExW(pName, FindExInfoStandard, pFD, FindExSearchNameMatch, NULL, 0)) != INVALID_HANDLE_VALUE;
 
    while ( fFind ) {
   
@@ -885,28 +903,36 @@ BOOL CopyDirectory ( LPCWSTR dirSrc, LPCWSTR dirDst ) {
           pFD -> cFileName[ 0 ] != L'.' &&
           pFD -> cFileName[ 1 ] != L'.'
     ) {
-  
+      size_t aDirSrcLength2;
+      size_t aDirDstLength;
+      size_t aFileNameLength;
+
+      StringCchLengthW (dirSrc, sizeof(dirSrc) / sizeof(dirSrc[0]), &aDirSrcLength2);
+      StringCchLengthW (dirDst, sizeof(dirDst) / sizeof(dirDst[0]), &aDirDstLength);
+      StringCchLengthW (pFD -> cFileName, sizeof(pFD -> cFileName) / sizeof(pFD -> cFileName[0]), &aFileNameLength);
+
      if (   ( pFullNameSrc = ( LPWSTR )HeapAlloc (
                                         hHeap, 0,
-                                        lstrlenW ( dirSrc ) + lstrlenW ( pFD -> cFileName ) +
+                                        aDirSrcLength2 + aFileNameLength +
                                         sizeof (  L'/'  ) + sizeof (  L'\x00'  )
                                        )
             ) == NULL ||
             ( pFullNameDst = ( LPWSTR )HeapAlloc (
                                         hHeap, 0,
-                                        lstrlenW ( dirDst ) + lstrlenW ( pFD -> cFileName ) +
+                                        aDirDstLength + aFileNameLength +
                                         sizeof (  L'/'  ) + sizeof (  L'\x00'  )
                                        )
             ) == NULL
      ) break;
   
-     lstrcpyW ( pFullNameSrc, dirSrc );
-     lstrcatW ( pFullNameSrc, L"/"  );
-     lstrcatW ( pFullNameSrc, pFD -> cFileName );
 
-     lstrcpyW ( pFullNameDst, dirDst );
-     lstrcatW ( pFullNameDst, L"/"  );
-     lstrcatW ( pFullNameDst, pFD -> cFileName );
+     StringCchCopyW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), dirSrc);
+     StringCchCatW  (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), L"/");
+     StringCchCatW  (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), pFD->cFileName);
+
+     StringCchCopyW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), dirDst);
+     StringCchCatW  (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), L"/");
+     StringCchCatW  (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), pFD->cFileName);
 
      if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
 
@@ -915,7 +941,11 @@ BOOL CopyDirectory ( LPCWSTR dirSrc, LPCWSTR dirDst ) {
    
      } else {
 retry:   
-      retVal = CopyFileW ( pFullNameSrc, pFullNameDst, FALSE );
+#ifndef OCCT_UWP
+      retVal = CopyFileW(pFullNameSrc, pFullNameDst, FALSE);
+#else
+      retVal = (CopyFile2(pFullNameSrc, pFullNameDst, FALSE) == S_OK) ? TRUE : FALSE;
+#endif
       if ( ! retVal ) {
       
        if ( _response_dir_proc != NULL ) {
index 3c57948..99968bf 100644 (file)
 #ifdef NOUSER
 #undef NOUSER
 #endif
+#ifdef NONLS
+#undef NONLS
+#endif
 #include <windows.h>
 
+#include <Strsafe.h>
+
 #ifndef STATUS_FLOAT_MULTIPLE_FAULTS
   // <ntstatus.h>
   #define STATUS_FLOAT_MULTIPLE_FAULTS     (0xC00002B4L)
@@ -72,7 +77,9 @@ static Standard_Mutex THE_SIGNAL_MUTEX;
 static LONG __fastcall _osd_raise ( DWORD, LPSTR );
 static BOOL WINAPI     _osd_ctrl_break_handler ( DWORD );
 
+#ifndef OCCT_UWP
 static LONG _osd_debug   ( void );
+#endif
 
 //# define _OSD_FPX ( _EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW | _EM_UNDERFLOW )
 # define _OSD_FPX ( _EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW )
@@ -86,7 +93,9 @@ static LONG CallHandler (DWORD dwExceptionCode,
                          ptrdiff_t ExceptionInformation0)
 {
   Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling
-  static char          buffer[ 2048 ];
+
+  static wchar_t         buffer[2048];
+
   int                  flterr = 0;
 
   buffer[0] = '\0' ;
@@ -95,47 +104,47 @@ static LONG CallHandler (DWORD dwExceptionCode,
   switch ( dwExceptionCode ) {
     case EXCEPTION_FLT_DENORMAL_OPERAND:
 //      cout << "CallHandler : EXCEPTION_FLT_DENORMAL_OPERAND:" << endl ;
-      lstrcpyA (  buffer, "FLT DENORMAL OPERAND"  );
+      StringCchCopyW (buffer, _countof(buffer), L"FLT DENORMAL OPERAND");
       flterr = 1 ;
       break ;
     case EXCEPTION_FLT_DIVIDE_BY_ZERO:
 //      cout << "CallHandler : EXCEPTION_FLT_DIVIDE_BY_ZERO:" << endl ;
-      lstrcpyA (  buffer, "FLT DIVIDE BY ZERO"  );
+      StringCchCopyW (buffer, _countof(buffer), L"FLT DIVIDE BY ZERO");
       flterr = 1 ;
       break ;
     case EXCEPTION_FLT_INEXACT_RESULT:
 //      cout << "CallHandler : EXCEPTION_FLT_INEXACT_RESULT:" << endl ;
-      lstrcpyA (  buffer, "FLT INEXACT RESULT"  );
+      StringCchCopyW (buffer, _countof(buffer), L"FLT INEXACT RESULT");
       flterr = 1 ;
       break ;
     case EXCEPTION_FLT_INVALID_OPERATION:
 //      cout << "CallHandler : EXCEPTION_FLT_INVALID_OPERATION:" << endl ;
-      lstrcpyA (  buffer, "FLT INVALID OPERATION"  );
+      StringCchCopyW (buffer, _countof(buffer), L"FLT INVALID OPERATION");
       flterr = 1 ;
       break ;
     case EXCEPTION_FLT_OVERFLOW:
 //      cout << "CallHandler : EXCEPTION_FLT_OVERFLOW:" << endl ;
-      lstrcpyA (  buffer, "FLT OVERFLOW"  );
+      StringCchCopyW (buffer, _countof(buffer), L"FLT OVERFLOW");
       flterr = 1 ;
       break ;
     case EXCEPTION_FLT_STACK_CHECK:
 //      cout << "CallHandler : EXCEPTION_FLT_STACK_CHECK:" << endl ;
-      lstrcpyA (  buffer, "FLT STACK CHECK"  );
+      StringCchCopyW (buffer, _countof(buffer), L"FLT STACK CHECK");
       flterr = 1 ;
       break ;
     case EXCEPTION_FLT_UNDERFLOW:
 //      cout << "CallHandler : EXCEPTION_FLT_UNDERFLOW:" << endl ;
-      lstrcpyA (  buffer, "FLT UNDERFLOW"  );
+      StringCchCopyW (buffer, _countof(buffer), L"FLT UNDERFLOW");
       flterr = 1 ;
       break ;
     case STATUS_FLOAT_MULTIPLE_TRAPS:
 //      cout << "CallHandler : EXCEPTION_FLT_UNDERFLOW:" << endl ;
-      lstrcpyA (  buffer, "FLT MULTIPLE TRAPS (possible overflow in conversion of double to integer)"  );
+      StringCchCopyW (buffer, _countof(buffer), L"FLT MULTIPLE TRAPS (possible overflow in conversion of double to integer)");
       flterr = 1 ;
       break ;
     case STATUS_FLOAT_MULTIPLE_FAULTS:
 //      cout << "CallHandler : EXCEPTION_FLT_UNDERFLOW:" << endl ;
-      lstrcpyA (  buffer, "FLT MULTIPLE FAULTS"  );
+      StringCchCopyW (buffer, _countof(buffer), L"FLT MULTIPLE FAULTS");
       flterr = 1 ;
       break ;
     case STATUS_NO_MEMORY:
@@ -144,89 +153,92 @@ static LONG CallHandler (DWORD dwExceptionCode,
       Raise (  "MEMORY ALLOCATION ERROR ( no room in the process heap )"  );
     case EXCEPTION_ACCESS_VIOLATION:
 //      cout << "CallHandler : EXCEPTION_ACCESS_VIOLATION:" << endl ;
-      wsprintf ( buffer, "%s%s%s0x%.8p%s%s%s", "ACCESS VIOLATION",
-                 fMsgBox ? "\n" : " ", "at address ",
+      StringCchPrintfW (buffer, _countof(buffer), L"%s%s%s0x%.8p%s%s%s", L"ACCESS VIOLATION",
+                 fMsgBox ? L"\n" : L" ", L"at address ",
                  ExceptionInformation1 ,
-                 " during '",
-                 ExceptionInformation0 ? "WRITE" : "READ",
-                 "' operation");
+                 L" during '",
+                 ExceptionInformation0 ? L"WRITE" : L"READ",
+                 L"' operation");
       break;
     case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
 //      cout << "CallHandler : EXCEPTION_ARRAY_BOUNDS_EXCEEDED:" << endl ;
-      lstrcpyA (  buffer, "ARRAY BOUNDS EXCEEDED"  );
+      StringCchCopyW (buffer, _countof(buffer), L"ARRAY BOUNDS EXCEEDED");
       break;
     case EXCEPTION_DATATYPE_MISALIGNMENT:
 //      cout << "CallHandler : EXCEPTION_DATATYPE_MISALIGNMENT:" << endl ;
-      lstrcpyA (  buffer, "DATATYPE MISALIGNMENT"  );
+      StringCchCopyW (buffer, _countof(buffer), L"DATATYPE MISALIGNMENT");
       break;
 
     case EXCEPTION_ILLEGAL_INSTRUCTION:
 //      cout << "CallHandler : EXCEPTION_ILLEGAL_INSTRUCTION:" << endl ;
-      lstrcpyA (  buffer, "ILLEGAL INSTRUCTION"  );
+      StringCchCopyW (buffer, _countof(buffer), L"ILLEGAL INSTRUCTION");
       break;
 
     case EXCEPTION_IN_PAGE_ERROR:
 //      cout << "CallHandler : EXCEPTION_IN_PAGE_ERROR:" << endl ;
-      lstrcpyA (  buffer, "IN_PAGE ERROR"  );
+      StringCchCopyW (buffer, _countof(buffer), L"IN_PAGE ERROR");
       break;
 
     case EXCEPTION_INT_DIVIDE_BY_ZERO:
 //      cout << "CallHandler : EXCEPTION_INT_DIVIDE_BY_ZERO:" << endl ;
-      lstrcpyA (  buffer, "INTEGER DIVISION BY ZERO"  );
+      StringCchCopyW (buffer, _countof(buffer), L"INTEGER DIVISION BY ZERO");
       break;
 
     case EXCEPTION_INT_OVERFLOW:
 //      cout << "CallHandler : EXCEPTION_INT_OVERFLOW:" << endl ;
-      lstrcpyA (  buffer, "INTEGER OVERFLOW"  );
+      StringCchCopyW (buffer, _countof(buffer), L"INTEGER OVERFLOW");
       break;
 
     case EXCEPTION_INVALID_DISPOSITION:
 //      cout << "CallHandler : EXCEPTION_INVALID_DISPOSITION:" << endl ;
-      lstrcpyA (  buffer, "INVALID DISPOSITION"  );
+      StringCchCopyW (buffer, _countof(buffer), L"INVALID DISPOSITION");
       break;
 
     case EXCEPTION_NONCONTINUABLE_EXCEPTION:
 //      cout << "CallHandler : EXCEPTION_NONCONTINUABLE_EXCEPTION:" << endl ;
-      lstrcpyA (  buffer, "NONCONTINUABLE EXCEPTION"  );
+      StringCchCopyW (buffer, _countof(buffer), L"NONCONTINUABLE EXCEPTION");
       break;
 
     case EXCEPTION_PRIV_INSTRUCTION:
 //      cout << "CallHandler : EXCEPTION_PRIV_INSTRUCTION:" << endl ;
-      lstrcpyA (  buffer, "PRIVELEGED INSTRUCTION ENCOUNTERED"  );
+      StringCchCopyW (buffer, _countof(buffer), L"PRIVELEGED INSTRUCTION ENCOUNTERED");
       break;
 
     case EXCEPTION_STACK_OVERFLOW:
 //      cout << "CallHandler : EXCEPTION_STACK_OVERFLOW:" << endl ;
-#if defined( _MSC_VER ) && ( _MSC_VER >= 1300 )
+#if defined( _MSC_VER ) && ( _MSC_VER >= 1300 ) && !defined(OCCT_UWP)
     // try recovering from stack overflow: available in MS VC++ 7.0
       if (!_resetstkoflw())
-        lstrcpyA (  buffer, "Unrecoverable STACK OVERFLOW"  );
+        StringCchCopyW (buffer, _countof(buffer), L"Unrecoverable STACK OVERFLOW");
       else
 #endif
-        lstrcpyA (  buffer, "STACK OVERFLOW"  );
+      StringCchCopyW (buffer, _countof(buffer), L"STACK OVERFLOW");
       break;
 
     default:
-      wsprintf( buffer, "unknown exception code 0x%x, params 0x%p 0x%p",
+      StringCchPrintfW (buffer, _countof(buffer), L"unknown exception code 0x%x, params 0x%p 0x%p",
                 dwExceptionCode, ExceptionInformation1, ExceptionInformation0 );
 
   }  // end switch
 
  // provide message to the user with possibility to stop
-  int idx = lstrlenA ( buffer );
+  size_t idx;
+  StringCchLengthW (buffer, _countof(buffer),&idx);
   if ( idx && fMsgBox && dwExceptionCode != EXCEPTION_NONCONTINUABLE_EXCEPTION ) {
      // reset FP operations before message box, otherwise it may fail to show up
     _fpreset();
     _clearfp();
 
+#ifndef OCCT_UWP
     MessageBeep ( MB_ICONHAND );
-    int aChoice = ::MessageBox (0, buffer, "OCCT Exception Handler", MB_ABORTRETRYIGNORE | MB_ICONSTOP);
+    int aChoice = ::MessageBoxW (0, buffer, L"OCCT Exception Handler", MB_ABORTRETRYIGNORE | MB_ICONSTOP);
     if (aChoice == IDRETRY)
     {
       _osd_debug();
       DebugBreak();
     } else if (aChoice == IDABORT)
       exit(0xFFFF);
+#endif
   }
 
   // reset FPE state
@@ -237,7 +249,10 @@ static LONG CallHandler (DWORD dwExceptionCode,
    _controlfp ( 0, _OSD_FPX ) ;          // JR add :
 //     cout << "OSD::WntHandler _controlfp( 0, _OSD_FPX ) " << hex << _controlfp(0,0) << dec << endl ;
   }
-  return _osd_raise ( dwExceptionCode, buffer );
+
+  char aBufferA[2048];
+  WideCharToMultiByte(CP_UTF8, 0, buffer, -1, aBufferA, sizeof(aBufferA), NULL, NULL);
+  return _osd_raise(dwExceptionCode, aBufferA);
 }
 
 //=======================================================================
@@ -292,7 +307,9 @@ static void SIGWntHandler (int signum, int sub_code)
       cout << "SIGWntHandler unexpected signal : " << signum << endl ;
       break ;
   }
+#ifndef OCCT_UWP
   DebugBreak ();
+#endif
 }
 #endif
 
@@ -348,7 +365,7 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
   Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling
   LPTOP_LEVEL_EXCEPTION_FILTER aPreviousFilter;
 
-  OSD_Environment env (TEXT("CSF_DEBUG_MODE"));
+  OSD_Environment env ("CSF_DEBUG_MODE");
   TCollection_AsciiString val = env.Value();
   if (!env.Failed())
   {
@@ -377,8 +394,9 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
 
   // Set Ctrl-C and Ctrl-Break handler
   fCtrlBrk = Standard_False;
+#ifndef OCCT_UWP
   SetConsoleCtrlHandler (&_osd_ctrl_break_handler, TRUE);
-
+#endif
 #ifdef _MSC_VER
 //  _se_translator_function pOldSeFunc =
   _set_se_translator (TranslateSE);
@@ -401,11 +419,11 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
 void OSD::ControlBreak () {
   if ( fCtrlBrk ) {
     fCtrlBrk = Standard_False;
-    OSD_Exception_CTRL_BREAK :: Raise (  TEXT( "*** INTERRUPT ***" )  );
+    OSD_Exception_CTRL_BREAK :: Raise ( "*** INTERRUPT ***" );
   }
 }  // end OSD :: ControlBreak
-
 #if !defined(__MINGW32__) && !defined(__CYGWIN32__)
+#ifndef OCCT_UWP
 //============================================================================
 //==== _osd_ctrl_break_handler
 //============================================================================
@@ -418,7 +436,7 @@ static BOOL WINAPI _osd_ctrl_break_handler ( DWORD dwCode ) {
 
   return TRUE;
 }  // end _osd_ctrl_break_handler
-
+#endif
 //============================================================================
 //==== _osd_raise
 //============================================================================
@@ -487,6 +505,7 @@ static LONG __fastcall _osd_raise ( DWORD dwCode, LPSTR msg )
 //============================================================================
 //==== _osd_debug
 //============================================================================
+#ifndef OCCT_UWP
 LONG _osd_debug ( void ) {
 
   LONG action ;
@@ -525,7 +544,7 @@ LONG _osd_debug ( void ) {
 
       if (   (  hEvent = CreateEvent ( &sa, TRUE, FALSE, NULL )  ) == NULL   ) __leave;
 
-      wsprintf (  cmdLine, keyValue, GetCurrentProcessId (), hEvent  );
+      StringCchPrintf(cmdLine, _countof(cmdLine), keyValue, GetCurrentProcessId(), hEvent);
 
       ZeroMemory (  &si, sizeof ( STARTUPINFO )  );
 
@@ -569,8 +588,9 @@ LONG _osd_debug ( void ) {
   return action ;
 
 }  // end _osd_debug
-#endif
 
+#endif
+#endif
 #else
 
 //---------- All Systems except Windows NT : ----------------------------------
index 73a5d58..f6752db 100644 (file)
@@ -14,6 +14,7 @@
 
 
 #include <OSD_Directory.hxx>
+#include <OSD_Environment.hxx>
 #include <OSD_File.hxx>
 #include <OSD_Path.hxx>
 #include <OSD_Protection.hxx>
@@ -86,11 +87,13 @@ Resource_Manager::Resource_Manager(const Standard_CString aName,
 Resource_Manager::Resource_Manager(const Standard_CString aName,
                                   const Standard_Boolean Verbose) : myName(aName), myVerbose(Verbose)
 {
-  Debug = (getenv("ResourceDebug") != NULL) ;
+  OSD_Environment envDebug("ResourceDebug");
+  Debug = (!envDebug.Value().IsEmpty()) ;
 
   TCollection_AsciiString Directory ;
 
-  if ( getenv ("CSF_ResourceVerbose") != NULL )
+  OSD_Environment envVerbose("CSF_ResourceVerbose");
+  if (!envVerbose.Value().IsEmpty())
     myVerbose = Standard_True;
 
   TCollection_AsciiString aPath,aUserPath;
@@ -231,8 +234,10 @@ Standard_Boolean Resource_Manager::Save() const
   anEnvVar += myName;
   anEnvVar += "UserDefaults";
 
-  Standard_CString dir;
-  if ((dir = getenv (anEnvVar.ToCString())) == NULL) {
+  TCollection_AsciiString dir;
+  OSD_Environment anEnv(anEnvVar);
+  dir = anEnv.Value();
+  if (dir.IsEmpty()) {
     if (myVerbose)
       cout << "Resource Manager Warning: environment variable \""
           << anEnvVar << "\" not set.  Cannot save resources." << endl ;
@@ -479,8 +484,10 @@ void Resource_Manager::GetResourcePath (TCollection_AsciiString& aPath, const St
   anEnvVar += aName;
   anEnvVar += isUserDefaults?"UserDefaults":"Defaults";
 
-  Standard_CString dir;
-  if ((dir = getenv (anEnvVar.ToCString())) == NULL)
+  TCollection_AsciiString dir;
+  OSD_Environment anEnv(anEnvVar);
+  dir = anEnv.Value();
+  if (dir.IsEmpty())
     return;
 
   TCollection_AsciiString aResPath(dir);
index cf2ee42..e151412 100644 (file)
   extern "C" int posix_memalign (void** thePtr, size_t theAlign, size_t theSize);
 #endif
 
+// There is no support for environment variables in UWP
+// OSD_Environment could not be used here because of cyclic dependency
+#ifdef OCCT_UWP
+#define getenv(x) NULL
+#endif
+
 #ifndef OCCT_MMGT_OPT_DEFAULT
 #define OCCT_MMGT_OPT_DEFAULT 0
 #endif
index 4d04709..f188393 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
 #include <Standard_MMgrOpt.hxx>
 #include <Standard_OutOfMemory.hxx>
 #include <Standard_Assert.hxx>
@@ -20,9 +24,7 @@
 #include <stdio.h>
 #include <errno.h>
 
-#ifdef _WIN32
-# include <windows.h>
-#else
+#ifndef _WIN32
 # include <sys/mman.h>    /* mmap() */
 #endif
 
@@ -32,6 +34,9 @@
 extern "C" int getpagesize() ;
 #endif
 
+#ifdef _WIN32
+#include <Strsafe.h>
+#endif
 //======================================================================
 // Assumptions
 //======================================================================
@@ -752,10 +757,16 @@ retry:
         goto retry;
       // if nothing helps, make error message and raise exception
       const int BUFSIZE=1024;
-      char message[BUFSIZE];
-      if ( FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), 0, message, BUFSIZE-1, 0) <=0 )
-        strcpy (message, "Standard_MMgrOpt::AllocMemory() failed to mmap");
-      Standard_OutOfMemory::Raise (message);
+
+      wchar_t message[BUFSIZE];
+
+      if ( FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), 0,
+        message, BUFSIZE-1, 0) <=0 )
+        StringCchCopyW(message, _countof(message), L"Standard_MMgrOpt::AllocMemory() failed to mmap");
+
+      char messageA[BUFSIZE];
+      WideCharToMultiByte(CP_UTF8, 0, message, -1, messageA, sizeof(messageA), NULL, NULL);
+      Standard_OutOfMemory::Raise(messageA);
     }
 
     // record map handle in the beginning
index 73747e6..c81ceec 100644 (file)
 #   endif  // __Standard_DLL
 # endif  // __Standard_API
 
-#endif  
+// Support of Universal Windows Platform
+#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_APP
+ #define OCCT_UWP
+#else
+ #ifdef OCCT_UWP
+   #undef OCCT_UWP
+ #endif
+#endif
+
+#endif
index 1efec1e..4f723a0 100755 (executable)
@@ -3,5 +3,4 @@ TKMath
 TKBRep
 TKG2d
 TKG3d
-TKMesh
 TKTopAlgo
index 6c9d1b6..26c9018 100644 (file)
@@ -35,7 +35,6 @@
 #include <gp_Pnt2d.hxx>
 #include <IntRes2d_IntersectionPoint.hxx>
 #include <IntRes2d_IntersectionSegment.hxx>
-#include <OSD_Chronometer.hxx>
 #include <Precision.hxx>
 #include <Standard_Failure.hxx>
 #include <TCollection_AsciiString.hxx>
index 2bdfe38..2fbe674 100644 (file)
@@ -47,7 +47,6 @@
 #include <gp_Pln.hxx>
 #include <gp_Pnt2d.hxx>
 #include <gp_Vec.hxx>
-#include <OSD_Chronometer.hxx>
 #include <Precision.hxx>
 #include <ProjLib_ProjectedCurve.hxx>
 #include <Standard_NotImplemented.hxx>
index 522fe57..9a87517 100644 (file)
@@ -200,11 +200,12 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument (const Ha
     "CSF_XmlOcafResource",
     "CASROOT"
   };
-  TCollection_AsciiString aResourceDir = "";
-  aResourceDir = getenv (aCSFVariable[0]);
+  OSD_Environment anEnv (aCSFVariable[0]);
+  TCollection_AsciiString aResourceDir = anEnv.Value();
   if (aResourceDir.IsEmpty()) {
     // now try by CASROOT
-    aResourceDir = getenv (aCSFVariable[1]);
+    OSD_Environment anEnv2(aCSFVariable[1]);
+    aResourceDir = anEnv2.Value();
     if ( !aResourceDir.IsEmpty() ) {
       aResourceDir += "/src/XmlOcafResource" ;
       aToSetCSFVariable = Standard_True; //CSF variable to be set later