- 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
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()
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}")
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()
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)
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
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()
--- /dev/null
+# 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)
@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}
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.
--- /dev/null
+<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>
--- /dev/null
+//
+// 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
--- /dev/null
+//
+// 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);
+ };
+}
--- /dev/null
+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
--- /dev/null
+<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>
--- /dev/null
+//
+// 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
--- /dev/null
+//
+// 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);
+ };
+}
--- /dev/null
+<?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
--- /dev/null
+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
--- /dev/null
+//
+// pch.cpp
+// Include the standard header and generate the precompiled header.
+//
+
+#include "pch.h"
--- /dev/null
+//
+// pch.h
+// Header for standard system include files.
+//
+
+#pragma once
+
+#include <collection.h>
+#include <ppltasks.h>
+
+#include "App.xaml.h"
#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)
#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>
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() {
#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 :
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)
{
}
#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 :
BRepPrimAPI_MakeCylinder::BRepPrimAPI_MakeCylinder(const Standard_Real R,
const Standard_Real H) :
- myCylinder(CylinderComputeAxes(), R , H)
+ myCylinder(gp::XOY(), R , H)
{
}
#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)
{
}
#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>
#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];
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
#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>
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)
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;
-
-
}
//=======================================================================
//=======================================================================
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;
}
}
return PCDM_RS_OK;
-
}
-
-
//=======================================================================
//function : Activate
//purpose :
#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>
#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)
}
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);
+++ /dev/null
-// 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;
-}
+++ /dev/null
-// 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
CDF_StoreList.hxx
CDF_StoreSetNameStatus.hxx
CDF_SubComponentStatus.hxx
-CDF_Timer.cxx
-CDF_Timer.hxx
CDF_TryStoreStatus.hxx
CDF_TypeOfActivation.hxx
#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();
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>
#include <TopTools_ListOfShape.hxx>
#include <stdio.h>
-#ifdef OCCT_DEBUG
-// For measurements.
-#include <OSD_Chronometer.hxx>
-//static OSD_Chronometer appclock;
-#endif
//#define DRAW
#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
Standard_Boolean ChFi3d_GetcontextNOOPT()
{ return ChFi3d_contextNOOPT; }
+#ifdef OCCT_DEBUG
// ***********************************************
// initialization and result of a chrono
//************************************************
ch.Show(tch);
time=time +tch;
}
-
+#endif
//==============================================================
// function : ChFi3d_CheckSurfData
#include <TopTools_ListIteratorOfListOfShape.hxx>
#ifdef OCCT_DEBUG
+#include <OSD_Chronometer.hxx>
extern Standard_Boolean ChFi3d_GettraceCHRON();
extern Standard_Real t_computedata ,t_completedata;
#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)
Add (4,"xsource");
Add (5,"xstep");
Add (6,"xnew");
- trace = getenv("DEBUGMODE");
}
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;
}
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 ++;
}
/*
class OSD_FileIterator;
class OSD_Directory;
class OSD_DirectoryIterator;
-class OSD_Chronometer;
class OSD_Timer;
class OSD_Printer;
class OSD_Host;
//=======================================================================
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
}
//=======================================================================
//=======================================================================
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 */
#include <OSD_Protection.hxx>
#include <Standard_ProgramError.hxx>
#include <TCollection_ExtendedString.hxx>
+#include <NCollection_String.hxx>
#include <OSD_WNT_1.hxx>
} // end constructor ( 2 )
-void OSD_Directory :: Build (const OSD_Protection& Protect ) {
+void OSD_Directory :: Build (const OSD_Protection& Protect) {
TCollection_AsciiString dirName;
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 );
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 );
// 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 )
#include <OSD_OSDError.hxx>
#include <OSD_Path.hxx>
#include <Standard_ProgramError.hxx>
+#include <NCollection_String.hxx>
+#include <TCollection_ExtendedString.hxx>
#include <windows.h>
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 ) {
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))
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))
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 */
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;
} // end else
- } else result += TEXT( "/" );
+ } else result += '/';
} // end _osd_set_disk_name
#pragma warning( disable : 4700 )
#endif
+#ifndef OCCT_UWP
static void __fastcall _set_error ( OSD_Error&, DWORD );
+#endif
OSD_Environment :: OSD_Environment () {
TCollection_AsciiString OSD_Environment::Value()
{
+#ifndef OCCT_UWP
myValue.Clear();
SetLastError (ERROR_SUCCESS);
}
myValue = aValue.ToCString();
return myValue;
+#else
+ myValue = "";
+ return myValue;
+#endif
}
void OSD_Environment :: SetName ( const TCollection_AsciiString& name ) {
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 {
} // end OSD_Environment :: Error
+#ifndef OCCT_UWP
static void __fastcall _set_error ( OSD_Error& err, DWORD code ) {
DWORD errCode;
err.SetValue ( errCode, OSD_WEnvironment, buffer );
} // end _set_error
+#endif
#endif
#include <TCollection_ExtendedString.hxx>
#include <windows.h>
+#include <Strsafe.h>
typedef struct _error_table {
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;
# include <tchar.h>
#endif // _INC_TCHAR
+#include <Strsafe.h>
+
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#define VAC
#endif
#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 );
}
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
// 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;
_osd_wnt_set_error ( myError, OSD_WFile );
else {
-
+#ifndef OCCT_UWP
SetProtection ( Protect );
+#else
+ (void)Protect;
+#endif
myIO |= FLAG_FILE;
} // end else
// 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;
Seek ( 0, OSD_FromEnd );
} else {
-
- SetProtection ( Protect );
+#ifndef OCCT_UWP
+ SetProtection ( Protect );
+#else
+ (void)Protect;
+#endif
myIO |= FLAG_FILE;
} // end else
} 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;
} 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);
delete [] cDummyBuffer ;
} // end else
-
+#endif
} else
RAISE( "OSD_File :: ReadLine (): incorrect call - file is a directory" );
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 );
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,
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;
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
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;
// --------------------------------------------------------------------------
// 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" );
(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
// --------------------------------------------------------------------------
#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
) {
return retVal;
} // end _osd_wnt_protection_to_sd */
+#endif
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#undef __try
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
return dwBuffSize;
} // end _get_line
+#ifndef OCCT_UWP
static int __fastcall _get_buffer (
HANDLE hChannel,
Standard_PCharacter& buffer,
return retVal;
} // end _get_dir_access_mask
-
+#endif
static HANDLE __fastcall _open_file (
Standard_CString fName,
OSD_OpenMode oMode,
// 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
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;
) {
Standard_Integer retVal = 0;
- DWORD dwType;
int fileType;
fileType = (fileHandle == INVALID_HANDLE_VALUE ?
{
// 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
#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
) {
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;
return retVal;
} // end _get_protection_dir
+#endif
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#define __try
#define __leave return fOK
#endif
+#ifndef OCCT_UWP
BOOL __fastcall _osd_print (const Standard_PCharacter pName, const wchar_t* fName ) {
BOOL fOK, fJob;
return fOK;
} // end _osd_print
+#endif
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#undef __try
// 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 )
//----------------------------------------------------------------------------
#define STRICT
+#ifdef NONLS
+#undef NONLS
+#endif
+#include <windows.h>
+
#include <OSD_FileNode.hxx>
#include <OSD_Protection.hxx>
#include <Quantity_Date.hxx>
# 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, ... );
// 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;
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:
// 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
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:
(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
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:
(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 :
(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 )
} // 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 :
);
}
else
-
- _osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
+ _osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
return retVal;
);
}
else
-
- _osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
+ _osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
return retVal;
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 );
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;
#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
//! 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.
static Standard_Integer memSize;
OSD_Host :: OSD_Host () {
-
+#ifndef OCCT_UWP
DWORD nSize;
Standard_Character szHostName[ MAX_COMPUTERNAME_LENGTH + 1 ];
char* hostAddr = 0;
if ( fInit )
myName = hostName;
-
+#endif
} // end constructor
TCollection_AsciiString OSD_Host :: SystemVersion () {
{
myCounters[anIter] = Standard_Size(-1);
}
-
+#ifndef OCCT_UWP
#if defined(_WIN32)
#if (_WIN32_WINNT >= 0x0500)
MEMORYSTATUSEX aStatEx;
myCounters[MemHeapUsage] = aStats.size_in_use;
}
#endif
+#endif
}
// =======================================================================
#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");
#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 )
{
{
GetSystemInfo(&aSysInfo);
}
+#else
+ GetNativeSystemInfo(&aSysInfo);
+#endif
aNumLogicalProcessors = aSysInfo.dwNumberOfProcessors;
#else
// These are the choices. We'll check number of processors online.
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;
} // end else
return aRes;
+#else
+ (void)cmd;
+ (void)ShowWindow;
+ return 0;
+#endif
} // end OSD_Process :: Spawn
void OSD_Process :: TerminalType ( TCollection_AsciiString& Name ) {
TCollection_AsciiString OSD_Process :: UserName ()
{
+#ifndef OCCT_UWP
Standard_PCharacter pBuff = new char[UNLEN + 1];
DWORD dwSize = UNLEN + 1;
TCollection_AsciiString retVal;
}
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;
if ( pTKgroups != NULL ) FreeTokenInformation ( pTKgroups );
return retVal;
-
+#else
+ return FALSE;
+#endif
} // end OSD_Process :: IsSuperUser
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];
_osd_wnt_set_error ( myError, OSD_WProcess );
delete[] pBuff;
+#endif
return anCurrentDirectory;
} // end OSD_Process :: CurrentDirectory
#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 () {
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
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;
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 () {
}
#else
-
//------------------- Windows NT ------------------
#define STRICT
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 */
/***/
#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
}; // end Init_OSD_WNT
static Init_OSD_WNT initOsdWnt;
+#endif
/***/
static BOOL fInit = FALSE;
static PSID* predefinedSIDs;
#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 */
HeapFree ( hHeap, 0, pACE );
} /* end FreeAce */
-
+#endif
#define WILD_CARD L"/*.*"
#define WILD_CARD_LEN ( sizeof ( WILD_CARD ) )
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 ) {
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 ) {
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 ) {
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 ) {
} 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 ) {
#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)
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 )
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' ;
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:
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
_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);
}
//=======================================================================
cout << "SIGWntHandler unexpected signal : " << signum << endl ;
break ;
}
+#ifndef OCCT_UWP
DebugBreak ();
+#endif
}
#endif
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())
{
// 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);
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
//============================================================================
return TRUE;
} // end _osd_ctrl_break_handler
-
+#endif
//============================================================================
//==== _osd_raise
//============================================================================
//============================================================================
//==== _osd_debug
//============================================================================
+#ifndef OCCT_UWP
LONG _osd_debug ( void ) {
LONG action ;
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 ) );
return action ;
} // end _osd_debug
-#endif
+#endif
+#endif
#else
//---------- All Systems except Windows NT : ----------------------------------
#include <OSD_Directory.hxx>
+#include <OSD_Environment.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
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;
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 ;
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);
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
// 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>
#include <stdio.h>
#include <errno.h>
-#ifdef _WIN32
-# include <windows.h>
-#else
+#ifndef _WIN32
# include <sys/mman.h> /* mmap() */
#endif
extern "C" int getpagesize() ;
#endif
+#ifdef _WIN32
+#include <Strsafe.h>
+#endif
//======================================================================
// Assumptions
//======================================================================
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
# 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
TKBRep
TKG2d
TKG3d
-TKMesh
TKTopAlgo
#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>
#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>
"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