[SCM] OCE packaging branch, upstream, updated. OCE-0.6.0-230-g17bea23

Denis Barbier bouzim at gmail.com
Fri Feb 24 18:50:09 UTC 2012


The following commit has been merged in the upstream branch:
commit 6bcb16819a012983b2a7b520bef7192f498ff146
Author: Denis Barbier <bouzim at gmail.com>
Date:   Tue Dec 13 01:28:42 2011 +0100

    Upgrade to OCCT 6.5.2
    
    Apply patches from 03dc44b on official/6.5.2.

diff --git a/CMakeLists.txt b/CMakeLists.txt
old mode 100755
new mode 100644
index b8db043..186591f
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,8 +27,8 @@ SET(OCE_VERSION_DEVEL -dev)
 
 SET(OCE_VERSION ${OCE_VERSION_MAJOR}.${OCE_VERSION_MINOR}.${OCE_VERSION_PATCH}${OCE_VERSION_DEVEL})
 
-SET(OCE_ABI_SOVERSION 1)
-SET(OCE_ABI_VERSION ${OCE_ABI_SOVERSION}.1.0)
+SET(OCE_ABI_SOVERSION 2)
+SET(OCE_ABI_VERSION ${OCE_ABI_SOVERSION}.0.0)
 
 # Set the minimum version of cmake required to 2.6
 CMAKE_MINIMUM_REQUIRED( VERSION 2.6 )
@@ -803,25 +803,15 @@ ENDFOREACH(RESOURCE_FILE ${INSTALL_RESOURCE_FILES})
 INSTALL(FILES ${INSTALL_STDRESOURCE_FILES}
 	DESTINATION ${${PROJECT_NAME}_INSTALL_DATA_DIR}/src/StdResource)
 
-CONFIGURE_FILE( ${${PROJECT_NAME}_SOURCE_DIR}/env.sh.cmake
-	${${PROJECT_NAME}_BINARY_DIR}/env.sh @ONLY )
-CONFIGURE_FILE( ${${PROJECT_NAME}_SOURCE_DIR}/env.csh.cmake
-	${${PROJECT_NAME}_BINARY_DIR}/env.csh @ONLY )
-
 IF(WIN32)
 	SET(ENV_SCRIPTS
 		${${PROJECT_NAME}_SOURCE_DIR}/env.bat
 		${${PROJECT_NAME}_SOURCE_DIR}/env_build.bat
 		${${PROJECT_NAME}_SOURCE_DIR}/msvc.bat
 	)
-ELSE(WIN32)
-	SET(ENV_SCRIPTS
-		${${PROJECT_NAME}_BINARY_DIR}/env.csh
-		${${PROJECT_NAME}_BINARY_DIR}/env.sh
-	)
+	INSTALL(FILES ${ENV_SCRIPTS}
+		DESTINATION ${${PROJECT_NAME}_INSTALL_SCRIPT_DIR})
 ENDIF(WIN32)
-INSTALL(FILES ${ENV_SCRIPTS}
-	DESTINATION ${${PROJECT_NAME}_INSTALL_SCRIPT_DIR})
 
 FILE(GLOB header_files ${${PROJECT_NAME}_SOURCE_DIR}/inc/*.*)
 INSTALL(FILES ${header_files}
diff --git a/README.txt b/README.txt
index 0e42800..0d75369 100644
--- a/README.txt
+++ b/README.txt
@@ -1,7 +1,7 @@
 oce stands for *o*pencascade *c*ommunity *e*dition.
 
 This project aims at gathering patches/changes/improvements from the OCC community over the latest release
-(currently OCCT 6.5.1).
+(currently OCCT 6.5.2).
 
 We use the following online resources:
   * Sources
diff --git a/drv/BRepMesh/BRepMesh_Classifier.jxx b/drv/BRepMesh/BRepMesh_Classifier.jxx
index 02f5abe..d9199f6 100644
--- a/drv/BRepMesh/BRepMesh_Classifier.jxx
+++ b/drv/BRepMesh/BRepMesh_Classifier.jxx
@@ -7,9 +7,6 @@
 #ifndef _TColStd_IndexedMapOfInteger_HeaderFile
 #include <TColStd_IndexedMapOfInteger.hxx>
 #endif
-#ifndef _BRepMesh_IndexedMapOfVertex_HeaderFile
-#include <BRepMesh_IndexedMapOfVertex.hxx>
-#endif
 #ifndef _BRepMesh_DataStructureOfDelaun_HeaderFile
 #include <BRepMesh_DataStructureOfDelaun.hxx>
 #endif
diff --git a/drv/BRepMesh/BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger_0.cxx b/drv/BRepMesh/BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger_0.cxx
new file mode 100644
index 0000000..3bcf7f1
--- /dev/null
+++ b/drv/BRepMesh/BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger_0.cxx
@@ -0,0 +1,37 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#include <BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
+
+#ifndef _Standard_NoSuchObject_HeaderFile
+#include <Standard_NoSuchObject.hxx>
+#endif
+#ifndef _TColStd_MapIntegerHasher_HeaderFile
+#include <TColStd_MapIntegerHasher.hxx>
+#endif
+#ifndef _BRepMesh_DataMapOfIntegerListOfInteger_HeaderFile
+#include <BRepMesh_DataMapOfIntegerListOfInteger.hxx>
+#endif
+#ifndef _BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_HeaderFile
+#include <BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx>
+#endif
+ 
+
+#define TheKey Standard_Integer
+#define TheKey_hxx <Standard_Integer.hxx>
+#define TheItem BRepMesh_ListOfInteger
+#define TheItem_hxx <BRepMesh_ListOfInteger.hxx>
+#define Hasher TColStd_MapIntegerHasher
+#define Hasher_hxx <TColStd_MapIntegerHasher.hxx>
+#define TCollection_DataMapNode BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapNode_hxx <BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx>
+#define TCollection_DataMapIterator BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapIterator_hxx <BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
+#define Handle_TCollection_DataMapNode Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapNode_Type_() BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_Type_()
+#define TCollection_DataMap BRepMesh_DataMapOfIntegerListOfInteger
+#define TCollection_DataMap_hxx <BRepMesh_DataMapOfIntegerListOfInteger.hxx>
+#include <TCollection_DataMapIterator.gxx>
+
diff --git a/drv/BRepMesh/BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_0.cxx b/drv/BRepMesh/BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_0.cxx
new file mode 100644
index 0000000..57bfeb8
--- /dev/null
+++ b/drv/BRepMesh/BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_0.cxx
@@ -0,0 +1,54 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#include <BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx>
+
+#ifndef _Standard_Type_HeaderFile
+#include <Standard_Type.hxx>
+#endif
+
+#ifndef _TColStd_MapIntegerHasher_HeaderFile
+#include <TColStd_MapIntegerHasher.hxx>
+#endif
+#ifndef _BRepMesh_DataMapOfIntegerListOfInteger_HeaderFile
+#include <BRepMesh_DataMapOfIntegerListOfInteger.hxx>
+#endif
+#ifndef _BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger_HeaderFile
+#include <BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
+#endif
+
+ 
+
+
+IMPLEMENT_STANDARD_TYPE(BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger)
+IMPLEMENT_STANDARD_SUPERTYPE_ARRAY()
+  STANDARD_TYPE(TCollection_MapNode),
+  STANDARD_TYPE(MMgt_TShared),
+  STANDARD_TYPE(Standard_Transient),
+
+IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END()
+IMPLEMENT_STANDARD_TYPE_END(BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger)
+
+
+IMPLEMENT_DOWNCAST(BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger,Standard_Transient)
+IMPLEMENT_STANDARD_RTTI(BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger)
+
+
+#define TheKey Standard_Integer
+#define TheKey_hxx <Standard_Integer.hxx>
+#define TheItem BRepMesh_ListOfInteger
+#define TheItem_hxx <BRepMesh_ListOfInteger.hxx>
+#define Hasher TColStd_MapIntegerHasher
+#define Hasher_hxx <TColStd_MapIntegerHasher.hxx>
+#define TCollection_DataMapNode BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapNode_hxx <BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx>
+#define TCollection_DataMapIterator BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapIterator_hxx <BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
+#define Handle_TCollection_DataMapNode Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapNode_Type_() BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_Type_()
+#define TCollection_DataMap BRepMesh_DataMapOfIntegerListOfInteger
+#define TCollection_DataMap_hxx <BRepMesh_DataMapOfIntegerListOfInteger.hxx>
+#include <TCollection_DataMapNode.gxx>
+
diff --git a/drv/BRepMesh/BRepMesh_DataMapOfIntegerListOfInteger_0.cxx b/drv/BRepMesh/BRepMesh_DataMapOfIntegerListOfInteger_0.cxx
new file mode 100644
index 0000000..c252889
--- /dev/null
+++ b/drv/BRepMesh/BRepMesh_DataMapOfIntegerListOfInteger_0.cxx
@@ -0,0 +1,40 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#include <BRepMesh_DataMapOfIntegerListOfInteger.hxx>
+
+#ifndef _Standard_DomainError_HeaderFile
+#include <Standard_DomainError.hxx>
+#endif
+#ifndef _Standard_NoSuchObject_HeaderFile
+#include <Standard_NoSuchObject.hxx>
+#endif
+#ifndef _TColStd_MapIntegerHasher_HeaderFile
+#include <TColStd_MapIntegerHasher.hxx>
+#endif
+#ifndef _BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_HeaderFile
+#include <BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx>
+#endif
+#ifndef _BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger_HeaderFile
+#include <BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
+#endif
+ 
+
+#define TheKey Standard_Integer
+#define TheKey_hxx <Standard_Integer.hxx>
+#define TheItem BRepMesh_ListOfInteger
+#define TheItem_hxx <BRepMesh_ListOfInteger.hxx>
+#define Hasher TColStd_MapIntegerHasher
+#define Hasher_hxx <TColStd_MapIntegerHasher.hxx>
+#define TCollection_DataMapNode BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapNode_hxx <BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx>
+#define TCollection_DataMapIterator BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapIterator_hxx <BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
+#define Handle_TCollection_DataMapNode Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapNode_Type_() BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_Type_()
+#define TCollection_DataMap BRepMesh_DataMapOfIntegerListOfInteger
+#define TCollection_DataMap_hxx <BRepMesh_DataMapOfIntegerListOfInteger.hxx>
+#include <TCollection_DataMap.gxx>
+
diff --git a/drv/BRepMesh/BRepMesh_DataStructureOfDelaun.jxx b/drv/BRepMesh/BRepMesh_DataStructureOfDelaun.jxx
index 5e41f00..d571ea9 100644
--- a/drv/BRepMesh/BRepMesh_DataStructureOfDelaun.jxx
+++ b/drv/BRepMesh/BRepMesh_DataStructureOfDelaun.jxx
@@ -1,8 +1,8 @@
 #ifndef _BRepMesh_Vertex_HeaderFile
 #include <BRepMesh_Vertex.hxx>
 #endif
-#ifndef _BRepMesh_IDMapOfNodeOfDataStructureOfDelaun_HeaderFile
-#include <BRepMesh_IDMapOfNodeOfDataStructureOfDelaun.hxx>
+#ifndef _BRepMesh_VertexTool_HeaderFile
+#include <BRepMesh_VertexTool.hxx>
 #endif
 #ifndef _BRepMesh_Edge_HeaderFile
 #include <BRepMesh_Edge.hxx>
diff --git a/drv/BRepMesh/BRepMesh_DiscretFactory.jxx b/drv/BRepMesh/BRepMesh_DiscretFactory.jxx
index 02edc7a..5cacc5e 100644
--- a/drv/BRepMesh/BRepMesh_DiscretFactory.jxx
+++ b/drv/BRepMesh/BRepMesh_DiscretFactory.jxx
@@ -4,6 +4,9 @@
 #ifndef _TCollection_AsciiString_HeaderFile
 #include <TCollection_AsciiString.hxx>
 #endif
+#ifndef _BRepMesh_DiscretRoot_HeaderFile
+#include <BRepMesh_DiscretRoot.hxx>
+#endif
 #ifndef _TopoDS_Shape_HeaderFile
 #include <TopoDS_Shape.hxx>
 #endif
diff --git a/drv/BRepMesh/BRepMesh_DiscretRoot.ixx b/drv/BRepMesh/BRepMesh_DiscretRoot.ixx
index 59fa3d4..594099e 100644
--- a/drv/BRepMesh/BRepMesh_DiscretRoot.ixx
+++ b/drv/BRepMesh/BRepMesh_DiscretRoot.ixx
@@ -5,6 +5,24 @@
 
 #include <BRepMesh_DiscretRoot.jxx>
 
+#ifndef _Standard_Type_HeaderFile
+#include <Standard_Type.hxx>
+#endif
+
+
  
 
 
+IMPLEMENT_STANDARD_TYPE(BRepMesh_DiscretRoot)
+IMPLEMENT_STANDARD_SUPERTYPE_ARRAY()
+  STANDARD_TYPE(Standard_Transient),
+
+IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END()
+IMPLEMENT_STANDARD_TYPE_END(BRepMesh_DiscretRoot)
+
+
+IMPLEMENT_DOWNCAST(BRepMesh_DiscretRoot,Standard_Transient)
+IMPLEMENT_STANDARD_RTTI(BRepMesh_DiscretRoot)
+
+
+
diff --git a/drv/BRepMesh/BRepMesh_FastDiscret.jxx b/drv/BRepMesh/BRepMesh_FastDiscret.jxx
index 3874f10..c6e4bc9 100644
--- a/drv/BRepMesh/BRepMesh_FastDiscret.jxx
+++ b/drv/BRepMesh/BRepMesh_FastDiscret.jxx
@@ -10,6 +10,9 @@
 #ifndef _TopoDS_Face_HeaderFile
 #include <TopoDS_Face.hxx>
 #endif
+#ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#endif
 #ifndef _TopoDS_Edge_HeaderFile
 #include <TopoDS_Edge.hxx>
 #endif
diff --git a/drv/BRepMesh/BRepMesh_IncrementalMesh.ixx b/drv/BRepMesh/BRepMesh_IncrementalMesh.ixx
index 648bed9..8ebcb6b 100644
--- a/drv/BRepMesh/BRepMesh_IncrementalMesh.ixx
+++ b/drv/BRepMesh/BRepMesh_IncrementalMesh.ixx
@@ -5,6 +5,25 @@
 
 #include <BRepMesh_IncrementalMesh.jxx>
 
+#ifndef _Standard_Type_HeaderFile
+#include <Standard_Type.hxx>
+#endif
+
+
  
 
 
+IMPLEMENT_STANDARD_TYPE(BRepMesh_IncrementalMesh)
+IMPLEMENT_STANDARD_SUPERTYPE_ARRAY()
+  STANDARD_TYPE(BRepMesh_DiscretRoot),
+  STANDARD_TYPE(Standard_Transient),
+
+IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END()
+IMPLEMENT_STANDARD_TYPE_END(BRepMesh_IncrementalMesh)
+
+
+IMPLEMENT_DOWNCAST(BRepMesh_IncrementalMesh,Standard_Transient)
+IMPLEMENT_STANDARD_RTTI(BRepMesh_IncrementalMesh)
+
+
+
diff --git a/drv/BRepMesh/BRepMesh_VertexTool.ixx b/drv/BRepMesh/BRepMesh_VertexTool.ixx
new file mode 100644
index 0000000..86c5b0f
--- /dev/null
+++ b/drv/BRepMesh/BRepMesh_VertexTool.ixx
@@ -0,0 +1,10 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#include <BRepMesh_VertexTool.jxx>
+
+ 
+
+
diff --git a/drv/BRepMesh/BRepMesh_VertexTool.jxx b/drv/BRepMesh/BRepMesh_VertexTool.jxx
new file mode 100644
index 0000000..67abab8
--- /dev/null
+++ b/drv/BRepMesh/BRepMesh_VertexTool.jxx
@@ -0,0 +1,9 @@
+#ifndef _BRepMesh_Vertex_HeaderFile
+#include <BRepMesh_Vertex.hxx>
+#endif
+#ifndef _gp_XY_HeaderFile
+#include <gp_XY.hxx>
+#endif
+#ifndef _BRepMesh_VertexTool_HeaderFile
+#include <BRepMesh_VertexTool.hxx>
+#endif
diff --git a/drv/RWStl/RWStl.jxx b/drv/RWStl/RWStl.jxx
index 9147c37..94364a9 100644
--- a/drv/RWStl/RWStl.jxx
+++ b/drv/RWStl/RWStl.jxx
@@ -4,6 +4,9 @@
 #ifndef _OSD_Path_HeaderFile
 #include <OSD_Path.hxx>
 #endif
+#ifndef _Message_ProgressIndicator_HeaderFile
+#include <Message_ProgressIndicator.hxx>
+#endif
 #ifndef _RWStl_HeaderFile
 #include <RWStl.hxx>
 #endif
diff --git a/drv/StepFile/step.tab.c b/drv/StepFile/step.tab.c
index 48acd53..5df8526 100644
--- a/drv/StepFile/step.tab.c
+++ b/drv/StepFile/step.tab.c
@@ -1,5 +1,5 @@
 
-/*  A Bison parser, made from /dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc
+/*  A Bison parser, made from /dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc
  by  GNU Bison version 1.25
   */
 
@@ -30,7 +30,7 @@
 #define	HEXA	273
 #define	QUID	274
 
-#line 3 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 3 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 
 #include "recfile.ph"		/* definitions des types d'arguments */
 #include "recfile.pc"		/* la-dedans, tout y est */
@@ -746,75 +746,75 @@ yyreduce:
   switch (yyn) {
 
 case 10:
-#line 49 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 49 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_finfile();  return(0);  /*  fini pour celui-la  */  ;
     break;}
 case 15:
-#line 58 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 58 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_finhead();  ;
     break;}
 case 16:
-#line 60 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 60 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_typarg(rec_argIdent);     rec_newarg();  ;
     break;}
 case 17:
-#line 61 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 61 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  /* deja fait par lex*/ 	 rec_newarg();  ;
     break;}
 case 18:
-#line 62 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 62 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_newarg();  ;
     break;}
 case 19:
-#line 63 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 63 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_newarg();  ;
     break;}
 case 20:
-#line 64 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 64 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_typarg(rec_argMisc);      rec_newarg();
 			   yyerrstatus = 1; yyclearin;  ;
     break;}
 case 21:
-#line 69 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 69 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_listype();  ;
     break;}
 case 22:
-#line 72 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 72 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_deblist();  ;
     break;}
 case 23:
-#line 75 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 75 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  if (modeprint > 0)
 		{  printf("Record no : %d -- ",nbrec+1);  rec_print(currec);  }
 	   rec_newent ();  yyerrstatus = 0; ;
     break;}
 case 40:
-#line 102 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 102 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  scope_debut();  ;
     break;}
 case 41:
-#line 105 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 105 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_typarg(rec_argIdent);    rec_newarg();  ;
     break;}
 case 44:
-#line 111 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 111 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_deblist();  ;
     break;}
 case 45:
-#line 114 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 114 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  scope_fin();  ;
     break;}
 case 46:
-#line 116 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 116 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  printf("***  Warning : Export List not yet processed\n");
 	   rec_newent();  scope_fin() ; ;
     break;}
 case 47:
-#line 121 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 121 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_ident();  ;
     break;}
 case 48:
-#line 124 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 124 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
 {  rec_type ();  ;
     break;}
 }
@@ -1015,4 +1015,4 @@ yyerrhandle:
   yystate = yyn;
   goto yynewstate;
 }
-#line 126 "/dn43/OCCT/tmp/results_31.05.2011/occt/release-sources-20110531/src/StepFile/step.yacc"
+#line 126 "/dn43/OCCT/tmp/results_30.09.2011/occt/release-sources-20110930/src/StepFile/step.yacc"
diff --git a/drv/V3d/V3d_View.jxx b/drv/V3d/V3d_View.jxx
index a9b48ec..8700b4d 100644
--- a/drv/V3d/V3d_View.jxx
+++ b/drv/V3d/V3d_View.jxx
@@ -49,6 +49,12 @@
 #ifndef _V3d_Plane_HeaderFile
 #include <V3d_Plane.hxx>
 #endif
+#ifndef _TCollection_ExtendedString_HeaderFile
+#include <TCollection_ExtendedString.hxx>
+#endif
+#ifndef _TCollection_AsciiString_HeaderFile
+#include <TCollection_AsciiString.hxx>
+#endif
 #ifndef _Aspect_ColorScale_HeaderFile
 #include <Aspect_ColorScale.hxx>
 #endif
diff --git a/drv/Visual3d/Visual3d_View.jxx b/drv/Visual3d/Visual3d_View.jxx
index 8e7275f..1e15dd2 100644
--- a/drv/Visual3d/Visual3d_View.jxx
+++ b/drv/Visual3d/Visual3d_View.jxx
@@ -34,9 +34,15 @@
 #ifndef _TColStd_Array2OfReal_HeaderFile
 #include <TColStd_Array2OfReal.hxx>
 #endif
+#ifndef _TCollection_ExtendedString_HeaderFile
+#include <TCollection_ExtendedString.hxx>
+#endif
 #ifndef _Quantity_Color_HeaderFile
 #include <Quantity_Color.hxx>
 #endif
+#ifndef _TCollection_AsciiString_HeaderFile
+#include <TCollection_AsciiString.hxx>
+#endif
 #ifndef _Graphic3d_MapOfStructure_HeaderFile
 #include <Graphic3d_MapOfStructure.hxx>
 #endif
diff --git a/env.csh.cmake b/env.csh.cmake
deleted file mode 100644
index 927c56e..0000000
--- a/env.csh.cmake
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/csh
-
-setenv CASROOT @OCE_ABSPATH_DATA_DIR@
-
-setenv CSF_MDTVFontDirectory $CASROOT/src/FontMFT
-setenv CSF_LANGUAGE us
-setenv MMGT_CLEAR 1
-setenv CSF_EXCEPTION_PROMPT 1
-setenv CSF_SHMessage $CASROOT/src/SHMessage
-setenv CSF_MDTVTexturesDirectory $CASROOT/src/Textures
-setenv CSF_XSMessage $CASROOT/src/XSMessage
-setenv CSF_StandardDefaults $CASROOT/src/StdResource
-setenv CSF_PluginDefaults $CASROOT/src/StdResource
-setenv CSF_XCAFDefaults $CASROOT/src/StdResource
-setenv CSF_StandardLiteDefaults $CASROOT/src/StdResource
-setenv CSF_GraphicShr @OCE_DEFAULT_CSF_GraphicShr@
-setenv CSF_UnitsLexicon $CASROOT/src/UnitsAPI/Lexi_Expr.dat
-setenv CSF_UnitsDefinition $CASROOT/src/UnitsAPI/Units.dat
-setenv CSF_IGESDefaults $CASROOT/src/XSTEPResource
-setenv CSF_STEPDefaults $CASROOT/src/XSTEPResource
-setenv CSF_XmlOcafResource $CASROOT/src/XmlOcafResource
-setenv CSF_MIGRATION_TYPES $CASROOT/src/StdResource/MigrationSheet.txt
-
diff --git a/env.sh.cmake b/env.sh.cmake
deleted file mode 100644
index 0d3358b..0000000
--- a/env.sh.cmake
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-export CASROOT=@OCE_ABSPATH_DATA_DIR@
-
-export CSF_MDTVFontDirectory=$CASROOT/src/FontMFT
-export CSF_LANGUAGE=us
-export MMGT_CLEAR=1
-export CSF_EXCEPTION_PROMPT=1
-export CSF_SHMessage=$CASROOT/src/SHMessage
-export CSF_MDTVTexturesDirectory=$CASROOT/src/Textures
-export CSF_XSMessage=$CASROOT/src/XSMessage
-export CSF_StandardDefaults=$CASROOT/src/StdResource
-export CSF_PluginDefaults=$CASROOT/src/StdResource
-export CSF_XCAFDefaults=$CASROOT/src/StdResource
-export CSF_StandardLiteDefaults=$CASROOT/src/StdResource
-export CSF_GraphicShr=@OCE_DEFAULT_CSF_GraphicShr@
-export CSF_UnitsLexicon=$CASROOT/src/UnitsAPI/Lexi_Expr.dat
-export CSF_UnitsDefinition=$CASROOT/src/UnitsAPI/Units.dat
-export CSF_IGESDefaults=$CASROOT/src/XSTEPResource
-export CSF_STEPDefaults=$CASROOT/src/XSTEPResource
-export CSF_XmlOcafResource=$CASROOT/src/XmlOcafResource
-export CSF_MIGRATION_TYPES=$CASROOT/src/StdResource/MigrationSheet.txt
-
diff --git a/env_DRAW.sh b/env_DRAW.sh
index 3752a7e..c56e537 100755
--- a/env_DRAW.sh
+++ b/env_DRAW.sh
@@ -1,26 +1,15 @@
 #!/bin/sh -f
 
-OS_NAME=`uname`
+export CASROOT="LOCATION OF OCCT"
+export OCCT3RDPARTY="LOCATION OF OCCT3RDPARTY"
 
-export OCCT3RDPARTY=$CASROOT/../3rdparty/$OS_NAME
+export TCLHOME=$OCCT3RDPARTY/tcltk
+export FTGLDIR=$OCCT3RDPARTY/ftgl
+export GL2PSDIR=$OCCT3RDPARTY/gl2ps
+export FREEIMAGEDIR=$OCCT3RDPARTY/freeimage
+export TBBBIN=$OCCT3RDPARTY/tbb/bin
+export TBBLIB=$OCCT3RDPARTY/tbb/lib
 
-if [ ! -n $TCLHOME ]; then export TCLHOME=$OCCT3RDPARTY/tcltk ; fi
-if [ ! -n $FTGLDIR ]; then export FTGLDIR=$OCCT3RDPARTY/ftgl ; fi
-if [ ! -n $GL2PSDIR ]; then export GL2PSDIR=$OCCT3RDPARTY/gl2ps ; fi
-if [ ! -n $FREEIMAGEDIR ]; then export FREEIMAGEDIR=$OCCT3RDPARTY/freeimage ; fi
-if [ ! -n $TBBBIN ]; then export TBBBIN=$OCCT3RDPARTY/tbb/bin ; fi
-if [ ! -n $TBBLIB ]; then export TBBBIN=$OCCT3RDPARTY/tbb/lib ; fi
-
-if [ -z "PATH" ];
-then PATH=$TCLHOME/bin:$FTGLDIR/bin:$GL2PSDIR/bin:$FREEIMAGEDIR/bin:$TBBBIN:$CASROOT/$OS_NAME/bin;
-else PATH=$TCLHOME/bin:$FTGLDIR/bin:$GL2PSDIR/bin:$FREEIMAGEDIR/bin:$TBBBIN:$CASROOT/$OS_NAME/bin:$PATH;
-fi
-export PATH
-if [ -z "LD_LIBRARY_PATH" ];
-then LD_LIBRARY_PATH=$TCLHOME/lib:$FTGLDIR/lib:$GL2PSDIR/lib:$FREEIMAGEDIR/lib:$TBBBIN:$CASROOT/$OS_NAME/lib;
-else LD_LIBRARY_PATH=$TCLHOME/lib:$FTGLDIR/lib:$GL2PSDIR/lib:$FREEIMAGEDIR/lib:$TBBBIN:$CASROOT/$OS_NAME/lib:$LD_LIBRARY_PATH;
-fi
-export LD_LIBRARY_PATH
 export CSF_MDTVFontDirectory=$CASROOT/src/FontMFT
 export CSF_LANGUAGE=us
 export MMGT_CLEAR=1
@@ -32,7 +21,7 @@ export CSF_StandardDefaults=$CASROOT/src/StdResource
 export CSF_PluginDefaults=$CASROOT/src/StdResource
 export CSF_XCAFDefaults=$CASROOT/src/StdResource
 export CSF_StandardLiteDefaults=$CASROOT/src/StdResource
-export CSF_GraphicShr=$CASROOT/$OS_NAME/lib/libTKOpenGl.so
+export CSF_GraphicShr=$CASROOT/lin/lib/libTKOpenGl.so
 export CSF_UnitsLexicon=$CASROOT/src/UnitsAPI/Lexi_Expr.dat
 export CSF_UnitsDefinition=$CASROOT/src/UnitsAPI/Units.dat
 export CSF_IGESDefaults=$CASROOT/src/XSTEPResource
@@ -40,10 +29,10 @@ export CSF_STEPDefaults=$CASROOT/src/XSTEPResource
 export CSF_XmlOcafResource=$CASROOT/src/XmlOcafResource
 export CSF_MIGRATION_TYPES=$CASROOT/src/StdResource/MigrationSheet.txt
 
-export TCLLIBPATH=$TCLHOME/lib
-
-export TCLLIBPATH=$TCLHOME/lib
-export TCL_LIBRARY=$TCLLIBPATH/tcl8.5
-export TK_LIBRARY=$TCLLIBPATH/tk8.5
-export TCLX_LIBRARY=$TCLLIBPATH/tclx8.4
+export TCL_LIBRARY=$TCLHOME/tcl8.5
+export TK_LIBRARY=$TCLHOME/tk8.5
+export TCLX_LIBRARY=$TCLHOME/tclx8.4
 export TCLLIBPATH="$TCLHOME/bin $TCLHOME/lib $TCL_LIBRARY $TK_LIBRARY $TCLX_LIBRARY"
+
+export PATH=$TCLHOME/bin:$FTGLDIR/bin:$GL2PSDIR/bin:$FREEIMAGEDIR/bin:$TBBBIN:$CASROOT/lin/bin:$PATH
+export LD_LIBRARY_PATH=$TCLHOME/lib:$FTGLDIR/lib:$GL2PSDIR/lib:$FREEIMAGEDIR/lib:$TBBLIB:$CASROOT/lin/lib:$LD_LIBRARY_PATH
diff --git a/env_build.bat b/env_build.bat
index ee9cbdc..333ada9 100755
--- a/env_build.bat
+++ b/env_build.bat
@@ -8,6 +8,7 @@ rem Default is vc8 win32
 
 set VCVER=vc8
 set "VCVARS=%VS80COMNTOOLS%..\..\VC\vcvarsall.bat"
+set "DevEnvDir=%VS80COMNTOOLS%..\IDE"
 if not "%1" == "" (
     if /I "%1" == "vc8" (
         set VCVER=vc8
@@ -93,5 +94,5 @@ if /I "%VCVER%" == "vc10" (
         set "PATH=%VS100COMNTOOLS%..\..\VC\bin\x86_amd64;%PATH%"
     )
     echo Attention: If you get problem during compilation with embedding manifests 
-    echo            ^(mt.exe^), try buildng ^(not rebuilding^) for the second time 
+    echo            ^(mt.exe^), try building ^(not rebuilding^) for the second time 
 )
diff --git a/inc/AIS2D_DataMapOfIOStatus.hxx b/inc/AIS2D_DataMapOfIOStatus.hxx
index 71e6a09..923d1d5 100644
--- a/inc/AIS2D_DataMapOfIOStatus.hxx
+++ b/inc/AIS2D_DataMapOfIOStatus.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class AIS2D_InteractiveObject;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(AIS2D_InteractiveObject)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(AIS2D_InteractiveObject)& K) ;
 
 
 
diff --git a/inc/AIS2D_DataMapOfLC.hxx b/inc/AIS2D_DataMapOfLC.hxx
index 28124e9..ecddfbd 100644
--- a/inc/AIS2D_DataMapOfLC.hxx
+++ b/inc/AIS2D_DataMapOfLC.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class AIS2D_LocalContext;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/AIS2D_DataMapOfLocStat.hxx b/inc/AIS2D_DataMapOfLocStat.hxx
index f0476e0..8a64f2e 100644
--- a/inc/AIS2D_DataMapOfLocStat.hxx
+++ b/inc/AIS2D_DataMapOfLocStat.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class AIS2D_InteractiveObject;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(AIS2D_InteractiveObject)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(AIS2D_InteractiveObject)& K) ;
 
 
 
diff --git a/inc/AIS2D_DataMapOfPrimAspects.hxx b/inc/AIS2D_DataMapOfPrimAspects.hxx
index 7df6724..7a45802 100644
--- a/inc/AIS2D_DataMapOfPrimAspects.hxx
+++ b/inc/AIS2D_DataMapOfPrimAspects.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Graphic2d_Primitive;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Graphic2d_Primitive)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Graphic2d_Primitive)& K) ;
 
 
 
diff --git a/inc/AIS_DataMapOfILC.hxx b/inc/AIS_DataMapOfILC.hxx
index d584835..d83bdbe 100644
--- a/inc/AIS_DataMapOfILC.hxx
+++ b/inc/AIS_DataMapOfILC.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class AIS_LocalContext;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/AIS_DataMapOfIOStatus.hxx b/inc/AIS_DataMapOfIOStatus.hxx
index 35500e6..6919e6e 100644
--- a/inc/AIS_DataMapOfIOStatus.hxx
+++ b/inc/AIS_DataMapOfIOStatus.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class AIS_InteractiveObject;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(AIS_InteractiveObject)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(AIS_InteractiveObject)& K) ;
 
 
 
diff --git a/inc/AIS_DataMapOfSelStat.hxx b/inc/AIS_DataMapOfSelStat.hxx
index 30c815f..af86bd9 100644
--- a/inc/AIS_DataMapOfSelStat.hxx
+++ b/inc/AIS_DataMapOfSelStat.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class SelectMgr_SelectableObject;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(SelectMgr_SelectableObject)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(SelectMgr_SelectableObject)& K) ;
 
 
 
diff --git a/inc/AIS_DataMapofIntegerListOfinteractive.hxx b/inc/AIS_DataMapofIntegerListOfinteractive.hxx
index 44338e1..cca621b 100644
--- a/inc/AIS_DataMapofIntegerListOfinteractive.hxx
+++ b/inc/AIS_DataMapofIntegerListOfinteractive.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class AIS_ListOfInteractive;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/AIS_IndexedDataMapOfOwnerPrs.hxx b/inc/AIS_IndexedDataMapOfOwnerPrs.hxx
index f97af7a..b459c7c 100644
--- a/inc/AIS_IndexedDataMapOfOwnerPrs.hxx
+++ b/inc/AIS_IndexedDataMapOfOwnerPrs.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -101,6 +104,10 @@ public:
   Standard_EXPORT    const Handle_Prs3d_Presentation& FindFromKey(const Handle(SelectMgr_EntityOwner)& K) const;
   
   Standard_EXPORT     Handle_Prs3d_Presentation& ChangeFromKey(const Handle(SelectMgr_EntityOwner)& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Handle(SelectMgr_EntityOwner)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Handle(SelectMgr_EntityOwner)& K) ;
 
 
 
diff --git a/inc/Aspect_GradientBackground.hxx b/inc/Aspect_GradientBackground.hxx
index 1ddc991..30eb2a9 100644
--- a/inc/Aspect_GradientBackground.hxx
+++ b/inc/Aspect_GradientBackground.hxx
@@ -51,8 +51,6 @@ public:
   Standard_EXPORT   Aspect_GradientBackground(const Quantity_Color& AColor1,const Quantity_Color& AColor2,const Aspect_GradientFillMethod AMethod = Aspect_GFM_HOR);
   //! Modifies the colours of the window gradient background <me>. <br>
   Standard_EXPORT     void SetColors(const Quantity_Color& AColor1,const Quantity_Color& AColor2,const Aspect_GradientFillMethod AMethod = Aspect_GFM_HOR) ;
-  
-  Standard_EXPORT     void SetBgGradientFillMethod(const Aspect_GradientFillMethod AMethod = Aspect_GFM_NONE) const;
   //! Returns colours of the window gradient background <me>. <br>
   Standard_EXPORT     void Colors(Quantity_Color& AColor1,Quantity_Color& AColor2) const;
   //! Returns the current gradient background fill mode. <br>
diff --git a/inc/Aspect_GraphicCallbackProc.hxx b/inc/Aspect_GraphicCallbackProc.hxx
index 3a6e79e..0b2fd79 100644
--- a/inc/Aspect_GraphicCallbackProc.hxx
+++ b/inc/Aspect_GraphicCallbackProc.hxx
@@ -15,13 +15,20 @@
 #define OCC_REDRAW_WINDOWAREA 2
 #define OCC_REDRAW_BITMAP 3
 
-/* 
-   This flag, when bitwise OR`ed with the "reason" value, 
-   informs the callback that it is called before redrawing the overlayer .
-   Otherwise, the callback is invoked after the overlayer is redrawn.        
-*/
+// The flags below provide additional information to define the moment when
+// callback was invoked in redraw procedure. These flags are bitwise OR'ed
+// with the "reason" value of callback:
+// 1) OCC_PRE_REDRAW  - callback was invoked before redrawing underlayer
+//                      ( at the beginning of redraw procedure );
+// 2) OCC_PRE_OVERLAY - callback was invoked before redrawing overlayer;
+// Otherwise, if no flags added to the "reason" value, the callback was
+// invoked at the end of redraw ( after the overlayer is redrawn )
+#define OCC_PRE_REDRAW  0x4000
 #define OCC_PRE_OVERLAY 0x8000
 
+// mask for all additional callbacks that invoked in process of redrawing
+#define OCC_REDRAW_ADDITIONAL_CALLBACKS ( OCC_PRE_REDRAW | OCC_PRE_OVERLAY )
+
  typedef struct {
    int reason;
    int wsID;
diff --git a/inc/Aspect_PrintAlgo.hxx b/inc/Aspect_PrintAlgo.hxx
new file mode 100644
index 0000000..afbe11a
--- /dev/null
+++ b/inc/Aspect_PrintAlgo.hxx
@@ -0,0 +1,19 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#ifndef _Aspect_PrintAlgo_HeaderFile
+#define _Aspect_PrintAlgo_HeaderFile
+
+//! Defines the type of color scale orientation <br>
+enum Aspect_PrintAlgo {
+Aspect_PA_STRETCH,
+Aspect_PA_TILE
+};
+
+#ifndef _Standard_PrimitiveTypes_HeaderFile
+#include <Standard_PrimitiveTypes.hxx>
+#endif
+
+#endif
diff --git a/inc/BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx b/inc/BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx
index 46901a4..ae2110e 100644
--- a/inc/BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx
+++ b/inc/BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -94,6 +97,10 @@ public:
   Standard_EXPORT    const TColStd_IndexedMapOfInteger& FindFromKey(const Standard_Integer& K) const;
   
   Standard_EXPORT     TColStd_IndexedMapOfInteger& ChangeFromKey(const Standard_Integer& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/BOPTColStd_IndexedDataMapOfIntegerInteger.hxx b/inc/BOPTColStd_IndexedDataMapOfIntegerInteger.hxx
index 62f0e2c..0385a46 100644
--- a/inc/BOPTColStd_IndexedDataMapOfIntegerInteger.hxx
+++ b/inc/BOPTColStd_IndexedDataMapOfIntegerInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -93,6 +96,10 @@ public:
   Standard_EXPORT    const Standard_Integer& FindFromKey(const Standard_Integer& K) const;
   
   Standard_EXPORT     Standard_Integer& ChangeFromKey(const Standard_Integer& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/BOPTColStd_IndexedDataMapOfSWRInteger.hxx b/inc/BOPTColStd_IndexedDataMapOfSWRInteger.hxx
index f0a72bf..2d0dc4b 100644
--- a/inc/BOPTColStd_IndexedDataMapOfSWRInteger.hxx
+++ b/inc/BOPTColStd_IndexedDataMapOfSWRInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -94,6 +97,10 @@ public:
   Standard_EXPORT    const Standard_Integer& FindFromKey(const BOPTColStd_ShapeWithRank& K) const;
   
   Standard_EXPORT     Standard_Integer& ChangeFromKey(const BOPTColStd_ShapeWithRank& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const BOPTColStd_ShapeWithRank& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const BOPTColStd_ShapeWithRank& K) ;
 
 
 
diff --git a/inc/BOPTools_IDMapOfPaveBlockIMapOfInteger.hxx b/inc/BOPTools_IDMapOfPaveBlockIMapOfInteger.hxx
index 99c7ece..a5c1347 100644
--- a/inc/BOPTools_IDMapOfPaveBlockIMapOfInteger.hxx
+++ b/inc/BOPTools_IDMapOfPaveBlockIMapOfInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const TColStd_IndexedMapOfInteger& FindFromKey(const BOPTools_PaveBlock& K) const;
   
   Standard_EXPORT     TColStd_IndexedMapOfInteger& ChangeFromKey(const BOPTools_PaveBlock& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const BOPTools_PaveBlock& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const BOPTools_PaveBlock& K) ;
 
 
 
diff --git a/inc/BOPTools_IDMapOfPaveBlockIMapOfPaveBlock.hxx b/inc/BOPTools_IDMapOfPaveBlockIMapOfPaveBlock.hxx
index 5eed101..eeaaaa0 100644
--- a/inc/BOPTools_IDMapOfPaveBlockIMapOfPaveBlock.hxx
+++ b/inc/BOPTools_IDMapOfPaveBlockIMapOfPaveBlock.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const BOPTools_IMapOfPaveBlock& FindFromKey(const BOPTools_PaveBlock& K) const;
   
   Standard_EXPORT     BOPTools_IMapOfPaveBlock& ChangeFromKey(const BOPTools_PaveBlock& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const BOPTools_PaveBlock& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const BOPTools_PaveBlock& K) ;
 
 
 
diff --git a/inc/BOPTools_IndexedDataMapOfIntegerDEInfo.hxx b/inc/BOPTools_IndexedDataMapOfIntegerDEInfo.hxx
index 17a923e..d78c498 100644
--- a/inc/BOPTools_IndexedDataMapOfIntegerDEInfo.hxx
+++ b/inc/BOPTools_IndexedDataMapOfIntegerDEInfo.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -94,6 +97,10 @@ public:
   Standard_EXPORT    const BOPTools_DEInfo& FindFromKey(const Standard_Integer& K) const;
   
   Standard_EXPORT     BOPTools_DEInfo& ChangeFromKey(const Standard_Integer& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/BOPTools_IndexedDataMapOfIntegerPaveSet.hxx b/inc/BOPTools_IndexedDataMapOfIntegerPaveSet.hxx
index 7f90eb7..ac59cf4 100644
--- a/inc/BOPTools_IndexedDataMapOfIntegerPaveSet.hxx
+++ b/inc/BOPTools_IndexedDataMapOfIntegerPaveSet.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -94,6 +97,10 @@ public:
   Standard_EXPORT    const BOPTools_PaveSet& FindFromKey(const Standard_Integer& K) const;
   
   Standard_EXPORT     BOPTools_PaveSet& ChangeFromKey(const Standard_Integer& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/BOPTools_IndexedDataMapOfIntegerState.hxx b/inc/BOPTools_IndexedDataMapOfIntegerState.hxx
index d6b3a48..f24767e 100644
--- a/inc/BOPTools_IndexedDataMapOfIntegerState.hxx
+++ b/inc/BOPTools_IndexedDataMapOfIntegerState.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -96,6 +99,10 @@ public:
   Standard_EXPORT    const BooleanOperations_StateOfShape& FindFromKey(const Standard_Integer& K) const;
   
   Standard_EXPORT     BooleanOperations_StateOfShape& ChangeFromKey(const Standard_Integer& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/BOPTools_IndexedDataMapOfShapeWithState.hxx b/inc/BOPTools_IndexedDataMapOfShapeWithState.hxx
index 96efeba..623b947 100644
--- a/inc/BOPTools_IndexedDataMapOfShapeWithState.hxx
+++ b/inc/BOPTools_IndexedDataMapOfShapeWithState.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -97,6 +100,10 @@ public:
   Standard_EXPORT    const BooleanOperations_StateOfShape& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     BooleanOperations_StateOfShape& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BOP_IndexedDataMapOfEdgeListFaceInfo.hxx b/inc/BOP_IndexedDataMapOfEdgeListFaceInfo.hxx
index 2d0d25c..2ebee5d 100644
--- a/inc/BOP_IndexedDataMapOfEdgeListFaceInfo.hxx
+++ b/inc/BOP_IndexedDataMapOfEdgeListFaceInfo.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const BOP_ListOfFaceInfo& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     BOP_ListOfFaceInfo& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BOP_IndexedDataMapOfSolidClassifier.hxx b/inc/BOP_IndexedDataMapOfSolidClassifier.hxx
index c9b46ed..45380b0 100644
--- a/inc/BOP_IndexedDataMapOfSolidClassifier.hxx
+++ b/inc/BOP_IndexedDataMapOfSolidClassifier.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -97,6 +100,10 @@ public:
   Standard_EXPORT    const BOP_PSoClassif& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     BOP_PSoClassif& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BOP_IndexedDataMapOfVertexListEdgeInfo.hxx b/inc/BOP_IndexedDataMapOfVertexListEdgeInfo.hxx
index af29ab2..f3eb109 100644
--- a/inc/BOP_IndexedDataMapOfVertexListEdgeInfo.hxx
+++ b/inc/BOP_IndexedDataMapOfVertexListEdgeInfo.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const BOP_ListOfEdgeInfo& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     BOP_ListOfEdgeInfo& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepAlgo_DataMapOfShapeBoolean.hxx b/inc/BRepAlgo_DataMapOfShapeBoolean.hxx
index ec6f64d..efeb2fd 100644
--- a/inc/BRepAlgo_DataMapOfShapeBoolean.hxx
+++ b/inc/BRepAlgo_DataMapOfShapeBoolean.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Integer_HeaderFile
 #include <Standard_Integer.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepAlgo_DataMapOfShapeInterference.hxx b/inc/BRepAlgo_DataMapOfShapeInterference.hxx
index 8e2db15..bbdcdfa 100644
--- a/inc/BRepAlgo_DataMapOfShapeInterference.hxx
+++ b/inc/BRepAlgo_DataMapOfShapeInterference.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepBndLib.hxx b/inc/BRepBndLib.hxx
index a2680c8..8f897a1 100644
--- a/inc/BRepBndLib.hxx
+++ b/inc/BRepBndLib.hxx
@@ -13,6 +13,9 @@
 #include <Standard_Macro.hxx>
 #endif
 
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
 class TopoDS_Shape;
 class Bnd_Box;
 
@@ -53,7 +56,7 @@ public:
 //! -   This algorithm is time consuming if triangulation has not <br>
 //!   been inserted inside the data structure of the shape S. <br>
 //! -   The resulting bounding box may be somewhat larger than the object. <br>
-  Standard_EXPORT   static  void Add(const TopoDS_Shape& S,Bnd_Box& B) ;
+  Standard_EXPORT   static  void Add(const TopoDS_Shape& S,Bnd_Box& B,const Standard_Boolean useTriangulation = Standard_True) ;
   //! Adds the shape S to the bounding box B. <br>
 //! This is a quick algorithm but only works if the shape S is <br>
 //! composed of polygonal planar faces, as is the case if S is <br>
diff --git a/inc/BRepBuilderAPI_MakeFace.hxx b/inc/BRepBuilderAPI_MakeFace.hxx
index 8081f6a..f2e0819 100644
--- a/inc/BRepBuilderAPI_MakeFace.hxx
+++ b/inc/BRepBuilderAPI_MakeFace.hxx
@@ -97,8 +97,9 @@ public:
   Standard_EXPORT   BRepBuilderAPI_MakeFace(const gp_Sphere& S);
   //! Make a face from a torus. <br>
   Standard_EXPORT   BRepBuilderAPI_MakeFace(const gp_Torus& C);
-  //! Make a face from a Surface. <br>
-  Standard_EXPORT   BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S);
+  //! Make a face from a Surface. Accepts tolerance value (TolDegen) <br>
+//! for resolution of degenerated edges. <br>
+  Standard_EXPORT   BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S,const Standard_Real TolDegen);
   //! Make a face from a plane. <br>
   Standard_EXPORT   BRepBuilderAPI_MakeFace(const gp_Pln& P,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax);
   //! Make a face from a cylinder. <br>
@@ -109,8 +110,9 @@ public:
   Standard_EXPORT   BRepBuilderAPI_MakeFace(const gp_Sphere& S,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax);
   //! Make a face from a torus. <br>
   Standard_EXPORT   BRepBuilderAPI_MakeFace(const gp_Torus& C,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax);
-  //! Make a face from a Surface. <br>
-  Standard_EXPORT   BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax);
+  //! Make a face from a Surface. Accepts tolerance value (TolDegen) <br>
+//!          for resolution of degenerated edges. <br>
+  Standard_EXPORT   BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax,const Standard_Real TolDegen);
   //! Find a surface from the wire and make a face. <br>
 //!          if <OnlyPlane> is true, the computed surface will be <br>
 //!          a plane. If it is not possible to find a plane, the <br>
@@ -178,13 +180,15 @@ public:
 //! want to work on the geometries of the two faces independently. <br>
   Standard_EXPORT     void Init(const TopoDS_Face& F) ;
   //! Initializes (or reinitializes) the construction of a face on <br>
-//! the surface S. If Bound is true (the default value), a wire is <br>
+//! the surface S. If Bound is true, a wire is <br>
 //! automatically created from the natural bounds of the <br>
 //! surface S and added to the face in order to bound it. If <br>
 //! Bound is false, no wire is added. This option is used <br>
 //! when real bounds are known. These will be added to <br>
 //! the face after this initialization, using the function Add. <br>
-  Standard_EXPORT     void Init(const Handle(Geom_Surface)& S,const Standard_Boolean Bound = Standard_True) ;
+//! TolDegen parameter is used for resolution of degenerated edges <br>
+//! if calculation of natural bounds is turned on. <br>
+  Standard_EXPORT     void Init(const Handle(Geom_Surface)& S,const Standard_Boolean Bound,const Standard_Real TolDegen) ;
   //!  Initializes (or reinitializes) the construction of a face on <br>
 //! the surface S, limited in the u parametric direction by <br>
 //! the two parameter values UMin and UMax and in the <br>
@@ -194,7 +198,8 @@ public:
 //! -      BRepBuilderAPI_ParametersOutOfRange <br>
 //!    when the parameters given are outside the bounds of the <br>
 //!    surface or the basis surface of a trimmed surface. <br>
-  Standard_EXPORT     void Init(const Handle(Geom_Surface)& S,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax) ;
+//! TolDegen parameter is used for resolution of degenerated edges. <br>
+  Standard_EXPORT     void Init(const Handle(Geom_Surface)& S,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax,const Standard_Real TolDegen) ;
   //! Adds the wire W to the constructed face as a hole. <br>
 //! Warning <br>
 //! W must not cross the other bounds of the face, and all <br>
diff --git a/inc/BRepCheck_DataMapOfShapeListOfStatus.hxx b/inc/BRepCheck_DataMapOfShapeListOfStatus.hxx
index 4d8f9d2..4a7658e 100644
--- a/inc/BRepCheck_DataMapOfShapeListOfStatus.hxx
+++ b/inc/BRepCheck_DataMapOfShapeListOfStatus.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepCheck_DataMapOfShapeResult.hxx b/inc/BRepCheck_DataMapOfShapeResult.hxx
index 124531d..71810d7 100644
--- a/inc/BRepCheck_DataMapOfShapeResult.hxx
+++ b/inc/BRepCheck_DataMapOfShapeResult.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepClass3d_MapOfInter.hxx b/inc/BRepClass3d_MapOfInter.hxx
index bad2053..9a7ebf5 100644
--- a/inc/BRepClass3d_MapOfInter.hxx
+++ b/inc/BRepClass3d_MapOfInter.hxx
@@ -87,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepExtrema_DistanceSS.hxx b/inc/BRepExtrema_DistanceSS.hxx
index 363725d..522133b 100644
--- a/inc/BRepExtrema_DistanceSS.hxx
+++ b/inc/BRepExtrema_DistanceSS.hxx
@@ -130,7 +130,7 @@ class BRepExtrema_DistanceSS
  private:
 
   //! computes the distance between two Shapes ( face edge vertex) <br>
-  void Perform(const TopoDS_Shape& S1,const TopoDS_Shape& S2,const Bnd_Box& B1,const Bnd_Box& B2);
+  Standard_EXPORT void Perform(const TopoDS_Shape& S1,const TopoDS_Shape& S2,const Bnd_Box& B1,const Bnd_Box& B2);
 
   //! computes the distance between two vertices <br>
   void Perform(const TopoDS_Vertex& S1,const TopoDS_Vertex& S2);
diff --git a/inc/BRepFill_DataMapOfNodeDataMapOfShapeShape.hxx b/inc/BRepFill_DataMapOfNodeDataMapOfShapeShape.hxx
index d5f9748..89b64f5 100644
--- a/inc/BRepFill_DataMapOfNodeDataMapOfShapeShape.hxx
+++ b/inc/BRepFill_DataMapOfNodeDataMapOfShapeShape.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MAT_Node;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(MAT_Node)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(MAT_Node)& K) ;
 
 
 
diff --git a/inc/BRepFill_DataMapOfNodeShape.hxx b/inc/BRepFill_DataMapOfNodeShape.hxx
index 0f8dd5a..870e52c 100644
--- a/inc/BRepFill_DataMapOfNodeShape.hxx
+++ b/inc/BRepFill_DataMapOfNodeShape.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MAT_Node;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(MAT_Node)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(MAT_Node)& K) ;
 
 
 
diff --git a/inc/BRepFill_DataMapOfOrientedShapeListOfShape.hxx b/inc/BRepFill_DataMapOfOrientedShapeListOfShape.hxx
index d75d102..861b2ad 100644
--- a/inc/BRepFill_DataMapOfOrientedShapeListOfShape.hxx
+++ b/inc/BRepFill_DataMapOfOrientedShapeListOfShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepFill_DataMapOfShapeDataMapOfShapeListOfShape.hxx b/inc/BRepFill_DataMapOfShapeDataMapOfShapeListOfShape.hxx
index f03452f..91079a4 100644
--- a/inc/BRepFill_DataMapOfShapeDataMapOfShapeListOfShape.hxx
+++ b/inc/BRepFill_DataMapOfShapeDataMapOfShapeListOfShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepFill_DataMapOfShapeSequenceOfPnt.hxx b/inc/BRepFill_DataMapOfShapeSequenceOfPnt.hxx
index d7ea15b..930d4ee 100644
--- a/inc/BRepFill_DataMapOfShapeSequenceOfPnt.hxx
+++ b/inc/BRepFill_DataMapOfShapeSequenceOfPnt.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepFill_DataMapOfShapeSequenceOfReal.hxx b/inc/BRepFill_DataMapOfShapeSequenceOfReal.hxx
index adeff83..d4ceadb 100644
--- a/inc/BRepFill_DataMapOfShapeSequenceOfReal.hxx
+++ b/inc/BRepFill_DataMapOfShapeSequenceOfReal.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepFill_IndexedDataMapOfOrientedShapeListOfShape.hxx b/inc/BRepFill_IndexedDataMapOfOrientedShapeListOfShape.hxx
index fb8cbdf..705f7d7 100644
--- a/inc/BRepFill_IndexedDataMapOfOrientedShapeListOfShape.hxx
+++ b/inc/BRepFill_IndexedDataMapOfOrientedShapeListOfShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const TopTools_ListOfShape& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     TopTools_ListOfShape& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepLib_MakeFace.hxx b/inc/BRepLib_MakeFace.hxx
index 8fe0ef6..028a371 100644
--- a/inc/BRepLib_MakeFace.hxx
+++ b/inc/BRepLib_MakeFace.hxx
@@ -94,8 +94,9 @@ public:
   Standard_EXPORT   BRepLib_MakeFace(const gp_Sphere& S);
   //! Make a face from a torus. <br>
   Standard_EXPORT   BRepLib_MakeFace(const gp_Torus& C);
-  //! Make a face from a Surface. <br>
-  Standard_EXPORT   BRepLib_MakeFace(const Handle(Geom_Surface)& S);
+  //! Make a face from a Surface. Accepts tolerance value (TolDegen) <br>
+//!          for resolution of degenerated edges. <br>
+  Standard_EXPORT   BRepLib_MakeFace(const Handle(Geom_Surface)& S,const Standard_Real TolDegen);
   //! Make a face from a plane. <br>
   Standard_EXPORT   BRepLib_MakeFace(const gp_Pln& P,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax);
   //! Make a face from a cylinder. <br>
@@ -106,8 +107,10 @@ public:
   Standard_EXPORT   BRepLib_MakeFace(const gp_Sphere& S,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax);
   //! Make a face from a torus. <br>
   Standard_EXPORT   BRepLib_MakeFace(const gp_Torus& C,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax);
-  //! Make a face from a Surface. <br>
-  Standard_EXPORT   BRepLib_MakeFace(const Handle(Geom_Surface)& S,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax);
+  //! Make a face from a Surface. Accepts min & max parameters <br>
+//!          to construct the face's bounds. Also accepts tolerance value (TolDegen) <br>
+//!          for resolution of degenerated edges. <br>
+  Standard_EXPORT   BRepLib_MakeFace(const Handle(Geom_Surface)& S,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax,const Standard_Real TolDegen);
   //! Find a surface from the wire and make a face. <br>
 //!          if <OnlyPlane> is true, the computed surface will be <br>
 //!          a plane. If it is not possible to find a plane, the <br>
@@ -129,12 +132,15 @@ public:
   Standard_EXPORT   BRepLib_MakeFace(const TopoDS_Face& F,const TopoDS_Wire& W);
   //! Load the face. <br>
   Standard_EXPORT     void Init(const TopoDS_Face& F) ;
-  //! Creates the face  from the  surface.  If Bound  is <br>
+  //! Creates the face  from the  surface. If Bound is <br>
 //!          True a wire is made from the natural bounds. <br>
-  Standard_EXPORT     void Init(const Handle(Geom_Surface)& S,const Standard_Boolean Bound = Standard_True) ;
-  //! Creates the face from the surface  and the min-max <br>
-//!          values. <br>
-  Standard_EXPORT     void Init(const Handle(Geom_Surface)& S,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax) ;
+//!          Accepts tolerance value (TolDegen) for resolution <br>
+//!          of degenerated edges. <br>
+  Standard_EXPORT     void Init(const Handle(Geom_Surface)& S,const Standard_Boolean Bound,const Standard_Real TolDegen) ;
+  //! Creates the face from the surface and the min-max <br>
+//!          values. Accepts tolerance value (TolDegen) for resolution <br>
+//!          of degenerated edges. <br>
+  Standard_EXPORT     void Init(const Handle(Geom_Surface)& S,const Standard_Real UMin,const Standard_Real UMax,const Standard_Real VMin,const Standard_Real VMax,const Standard_Real TolDegen) ;
   //! Adds the wire <W> in the current face. <br>
   Standard_EXPORT     void Add(const TopoDS_Wire& W) ;
   
diff --git a/inc/BRepMAT2d_DataMapOfBasicEltShape.hxx b/inc/BRepMAT2d_DataMapOfBasicEltShape.hxx
index 6887902..1515f96 100644
--- a/inc/BRepMAT2d_DataMapOfBasicEltShape.hxx
+++ b/inc/BRepMAT2d_DataMapOfBasicEltShape.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MAT_BasicElt;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(MAT_BasicElt)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(MAT_BasicElt)& K) ;
 
 
 
diff --git a/inc/BRepMAT2d_DataMapOfShapeSequenceOfBasicElt.hxx b/inc/BRepMAT2d_DataMapOfShapeSequenceOfBasicElt.hxx
index 1c341f3..ac82f1d 100644
--- a/inc/BRepMAT2d_DataMapOfShapeSequenceOfBasicElt.hxx
+++ b/inc/BRepMAT2d_DataMapOfShapeSequenceOfBasicElt.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepMesh.hxx b/inc/BRepMesh.hxx
index b58d09a..ad49bf6 100644
--- a/inc/BRepMesh.hxx
+++ b/inc/BRepMesh.hxx
@@ -30,6 +30,7 @@ class BRepMesh_SelectorOfDataStructureOfDelaun;
 class BRepMesh_Delaun;
 class BRepMesh_DataStructureOfDelaun;
 class BRepMesh_CircleTool;
+class BRepMesh_VertexTool;
 class BRepMesh_Array1OfVertexOfDelaun;
 class BRepMesh_HArray1OfVertexOfDelaun;
 class BRepMesh_HeapSortVertexOfDelaun;
@@ -37,6 +38,7 @@ class BRepMesh_HeapSortIndexedVertexOfDelaun;
 class BRepMesh_NodeHasherOfDataStructureOfDelaun;
 class BRepMesh_LinkHasherOfDataStructureOfDelaun;
 class BRepMesh_ElemHasherOfDataStructureOfDelaun;
+class BRepMesh_DataMapOfIntegerListOfInteger;
 class BRepMesh_IDMapOfNodeOfDataStructureOfDelaun;
 class BRepMesh_IDMapOfLinkOfDataStructureOfDelaun;
 class BRepMesh_IMapOfElementOfDataStructureOfDelaun;
@@ -59,6 +61,8 @@ class BRepMesh_GeomTool;
 class BRepMesh_DataMapOfIntegerPnt;
 class BRepMesh_PairOfPolygon;
 class BRepMesh_DataMapOfShapePairOfPolygon;
+class BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger;
+class BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger;
 class BRepMesh_IndexedDataMapNodeOfIDMapOfNodeOfDataStructureOfDelaun;
 class BRepMesh_IndexedDataMapNodeOfIDMapOfLinkOfDataStructureOfDelaun;
 class BRepMesh_IndexedMapNodeOfIMapOfElementOfDataStructureOfDelaun;
@@ -129,6 +133,7 @@ friend class BRepMesh_SelectorOfDataStructureOfDelaun;
 friend class BRepMesh_Delaun;
 friend class BRepMesh_DataStructureOfDelaun;
 friend class BRepMesh_CircleTool;
+friend class BRepMesh_VertexTool;
 friend class BRepMesh_Array1OfVertexOfDelaun;
 friend class BRepMesh_HArray1OfVertexOfDelaun;
 friend class BRepMesh_HeapSortVertexOfDelaun;
@@ -136,6 +141,7 @@ friend class BRepMesh_HeapSortIndexedVertexOfDelaun;
 friend class BRepMesh_NodeHasherOfDataStructureOfDelaun;
 friend class BRepMesh_LinkHasherOfDataStructureOfDelaun;
 friend class BRepMesh_ElemHasherOfDataStructureOfDelaun;
+friend class BRepMesh_DataMapOfIntegerListOfInteger;
 friend class BRepMesh_IDMapOfNodeOfDataStructureOfDelaun;
 friend class BRepMesh_IDMapOfLinkOfDataStructureOfDelaun;
 friend class BRepMesh_IMapOfElementOfDataStructureOfDelaun;
@@ -158,6 +164,8 @@ friend class BRepMesh_GeomTool;
 friend class BRepMesh_DataMapOfIntegerPnt;
 friend class BRepMesh_PairOfPolygon;
 friend class BRepMesh_DataMapOfShapePairOfPolygon;
+friend class BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger;
+friend class BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger;
 friend class BRepMesh_IndexedDataMapNodeOfIDMapOfNodeOfDataStructureOfDelaun;
 friend class BRepMesh_IndexedDataMapNodeOfIDMapOfLinkOfDataStructureOfDelaun;
 friend class BRepMesh_IndexedMapNodeOfIMapOfElementOfDataStructureOfDelaun;
diff --git a/inc/BRepMesh_Classifier.hxx b/inc/BRepMesh_Classifier.hxx
index 22578db..c4c278d 100644
--- a/inc/BRepMesh_Classifier.hxx
+++ b/inc/BRepMesh_Classifier.hxx
@@ -28,9 +28,6 @@
 #ifndef _BRepMesh_Status_HeaderFile
 #include <BRepMesh_Status.hxx>
 #endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
 #ifndef _Handle_BRepMesh_DataStructureOfDelaun_HeaderFile
 #include <Handle_BRepMesh_DataStructureOfDelaun.hxx>
 #endif
@@ -40,7 +37,6 @@
 class TopoDS_Face;
 class BRepMesh_DataMapOfShapePairOfPolygon;
 class TColStd_IndexedMapOfInteger;
-class BRepMesh_IndexedMapOfVertex;
 class BRepMesh_DataStructureOfDelaun;
 class gp_Pnt2d;
 class TColgp_SequenceOfPnt2d;
@@ -64,16 +60,12 @@ public:
   }
 
   
-  Standard_EXPORT   BRepMesh_Classifier(const TopoDS_Face& F,const Standard_Real Tol,const BRepMesh_DataMapOfShapePairOfPolygon& edges,const TColStd_IndexedMapOfInteger& themap,const BRepMesh_IndexedMapOfVertex& Str,const Standard_Real Umin,const Standard_Real Umax,const Standard_Real Vmin,const Standard_Real Vmax);
-  
   Standard_EXPORT   BRepMesh_Classifier(const TopoDS_Face& F,const Standard_Real Tol,const BRepMesh_DataMapOfShapePairOfPolygon& edges,const TColStd_IndexedMapOfInteger& themap,const Handle(BRepMesh_DataStructureOfDelaun)& Str,const Standard_Real Umin,const Standard_Real Umax,const Standard_Real Vmin,const Standard_Real Vmax);
   
   Standard_EXPORT     TopAbs_State Perform(const gp_Pnt2d& Puv) const;
   
         BRepMesh_Status State() const;
   
-        Standard_Boolean NaturalRestriction() const;
-  
   Standard_EXPORT     void Destroy() ;
 ~BRepMesh_Classifier()
 {
@@ -105,7 +97,6 @@ Standard_Real V1;
 Standard_Real U2;
 Standard_Real V2;
 BRepMesh_Status myState;
-Standard_Boolean isnatural;
 
 
 };
diff --git a/inc/BRepMesh_Classifier.lxx b/inc/BRepMesh_Classifier.lxx
index b687b17..816ccdd 100644
--- a/inc/BRepMesh_Classifier.lxx
+++ b/inc/BRepMesh_Classifier.lxx
@@ -15,13 +15,3 @@ inline BRepMesh_Status BRepMesh_Classifier::State() const
 {
   return myState;
 }
-
-//=======================================================================
-//function : NaturalRestriction
-//purpose  : 
-//=======================================================================
-
-inline Standard_Boolean BRepMesh_Classifier::NaturalRestriction() const
-{
-  return isnatural;
-}
diff --git a/inc/BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx b/inc/BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx
new file mode 100644
index 0000000..dd533fa
--- /dev/null
+++ b/inc/BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx
@@ -0,0 +1,87 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#ifndef _BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger_HeaderFile
+#define _BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger_HeaderFile
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+
+#ifndef _TCollection_BasicMapIterator_HeaderFile
+#include <TCollection_BasicMapIterator.hxx>
+#endif
+#ifndef _Standard_Integer_HeaderFile
+#include <Standard_Integer.hxx>
+#endif
+#ifndef _BRepMesh_ListOfInteger_HeaderFile
+#include <BRepMesh_ListOfInteger.hxx>
+#endif
+#ifndef _Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_HeaderFile
+#include <Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx>
+#endif
+class Standard_NoSuchObject;
+class TColStd_MapIntegerHasher;
+class BRepMesh_DataMapOfIntegerListOfInteger;
+class BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger;
+
+
+
+class BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger  : public TCollection_BasicMapIterator {
+public:
+
+  void* operator new(size_t,void* anAddress) 
+  {
+    return anAddress;
+  }
+  void* operator new(size_t size) 
+  {
+    return Standard::Allocate(size); 
+  }
+  void  operator delete(void *anAddress) 
+  {
+    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
+  }
+
+  
+  Standard_EXPORT   BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger();
+  
+  Standard_EXPORT   BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger(const BRepMesh_DataMapOfIntegerListOfInteger& aMap);
+  
+  Standard_EXPORT     void Initialize(const BRepMesh_DataMapOfIntegerListOfInteger& aMap) ;
+  
+  Standard_EXPORT    const Standard_Integer& Key() const;
+  
+  Standard_EXPORT    const BRepMesh_ListOfInteger& Value() const;
+
+
+
+
+
+protected:
+
+
+
+
+
+private:
+
+
+
+
+
+};
+
+
+
+
+
+// other Inline functions and methods (like "C++: function call" methods)
+
+
+#endif
diff --git a/inc/BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx b/inc/BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx
new file mode 100644
index 0000000..be033dd
--- /dev/null
+++ b/inc/BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx
@@ -0,0 +1,103 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#ifndef _BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_HeaderFile
+#define _BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_HeaderFile
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_DefineHandle_HeaderFile
+#include <Standard_DefineHandle.hxx>
+#endif
+#ifndef _Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_HeaderFile
+#include <Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx>
+#endif
+
+#ifndef _Standard_Integer_HeaderFile
+#include <Standard_Integer.hxx>
+#endif
+#ifndef _BRepMesh_ListOfInteger_HeaderFile
+#include <BRepMesh_ListOfInteger.hxx>
+#endif
+#ifndef _TCollection_MapNode_HeaderFile
+#include <TCollection_MapNode.hxx>
+#endif
+#ifndef _TCollection_MapNodePtr_HeaderFile
+#include <TCollection_MapNodePtr.hxx>
+#endif
+class TColStd_MapIntegerHasher;
+class BRepMesh_DataMapOfIntegerListOfInteger;
+class BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger;
+
+
+
+class BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger : public TCollection_MapNode {
+
+public:
+
+  
+      BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger(const Standard_Integer& K,const BRepMesh_ListOfInteger& I,const TCollection_MapNodePtr& n);
+  
+        Standard_Integer& Key() const;
+  
+        BRepMesh_ListOfInteger& Value() const;
+
+
+
+
+  DEFINE_STANDARD_RTTI(BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger)
+
+protected:
+
+
+
+
+private: 
+
+
+Standard_Integer myKey;
+BRepMesh_ListOfInteger myValue;
+
+
+};
+
+#define TheKey Standard_Integer
+#define TheKey_hxx <Standard_Integer.hxx>
+#define TheItem BRepMesh_ListOfInteger
+#define TheItem_hxx <BRepMesh_ListOfInteger.hxx>
+#define Hasher TColStd_MapIntegerHasher
+#define Hasher_hxx <TColStd_MapIntegerHasher.hxx>
+#define TCollection_DataMapNode BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapNode_hxx <BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx>
+#define TCollection_DataMapIterator BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapIterator_hxx <BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
+#define Handle_TCollection_DataMapNode Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger
+#define TCollection_DataMapNode_Type_() BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_Type_()
+#define TCollection_DataMap BRepMesh_DataMapOfIntegerListOfInteger
+#define TCollection_DataMap_hxx <BRepMesh_DataMapOfIntegerListOfInteger.hxx>
+
+#include <TCollection_DataMapNode.lxx>
+
+#undef TheKey
+#undef TheKey_hxx
+#undef TheItem
+#undef TheItem_hxx
+#undef Hasher
+#undef Hasher_hxx
+#undef TCollection_DataMapNode
+#undef TCollection_DataMapNode_hxx
+#undef TCollection_DataMapIterator
+#undef TCollection_DataMapIterator_hxx
+#undef Handle_TCollection_DataMapNode
+#undef TCollection_DataMapNode_Type_
+#undef TCollection_DataMap
+#undef TCollection_DataMap_hxx
+
+
+// other Inline functions and methods (like "C++: function call" methods)
+
+
+#endif
diff --git a/inc/BRepMesh_DataMapOfFaceAttribute.hxx b/inc/BRepMesh_DataMapOfFaceAttribute.hxx
index 4c98410..f63dfaa 100644
--- a/inc/BRepMesh_DataMapOfFaceAttribute.hxx
+++ b/inc/BRepMesh_DataMapOfFaceAttribute.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Face;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Face& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Face& K) ;
 
 
 
diff --git a/inc/BRepMesh_DataMapOfIntegerListOfInteger.hxx b/inc/BRepMesh_DataMapOfIntegerListOfInteger.hxx
new file mode 100644
index 0000000..3f0a813
--- /dev/null
+++ b/inc/BRepMesh_DataMapOfIntegerListOfInteger.hxx
@@ -0,0 +1,124 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#ifndef _BRepMesh_DataMapOfIntegerListOfInteger_HeaderFile
+#define _BRepMesh_DataMapOfIntegerListOfInteger_HeaderFile
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+
+#ifndef _TCollection_BasicMap_HeaderFile
+#include <TCollection_BasicMap.hxx>
+#endif
+#ifndef _Standard_Integer_HeaderFile
+#include <Standard_Integer.hxx>
+#endif
+#ifndef _BRepMesh_ListOfInteger_HeaderFile
+#include <BRepMesh_ListOfInteger.hxx>
+#endif
+#ifndef _Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_HeaderFile
+#include <Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
+class Standard_DomainError;
+class Standard_NoSuchObject;
+class TColStd_MapIntegerHasher;
+class BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger;
+class BRepMesh_DataMapIteratorOfDataMapOfIntegerListOfInteger;
+
+
+
+class BRepMesh_DataMapOfIntegerListOfInteger  : public TCollection_BasicMap {
+public:
+
+  void* operator new(size_t,void* anAddress) 
+  {
+    return anAddress;
+  }
+  void* operator new(size_t size) 
+  {
+    return Standard::Allocate(size); 
+  }
+  void  operator delete(void *anAddress) 
+  {
+    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
+  }
+
+  
+  Standard_EXPORT   BRepMesh_DataMapOfIntegerListOfInteger(const Standard_Integer NbBuckets = 1);
+  
+  Standard_EXPORT     BRepMesh_DataMapOfIntegerListOfInteger& Assign(const BRepMesh_DataMapOfIntegerListOfInteger& Other) ;
+    BRepMesh_DataMapOfIntegerListOfInteger& operator =(const BRepMesh_DataMapOfIntegerListOfInteger& Other) 
+{
+  return Assign(Other);
+}
+  
+  Standard_EXPORT     void ReSize(const Standard_Integer NbBuckets) ;
+  
+  Standard_EXPORT     void Clear() ;
+~BRepMesh_DataMapOfIntegerListOfInteger()
+{
+  Clear();
+}
+  
+  Standard_EXPORT     Standard_Boolean Bind(const Standard_Integer& K,const BRepMesh_ListOfInteger& I) ;
+  
+  Standard_EXPORT     Standard_Boolean IsBound(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Boolean UnBind(const Standard_Integer& K) ;
+  
+  Standard_EXPORT    const BRepMesh_ListOfInteger& Find(const Standard_Integer& K) const;
+   const BRepMesh_ListOfInteger& operator()(const Standard_Integer& K) const
+{
+  return Find(K);
+}
+  
+  Standard_EXPORT     BRepMesh_ListOfInteger& ChangeFind(const Standard_Integer& K) ;
+    BRepMesh_ListOfInteger& operator()(const Standard_Integer& K) 
+{
+  return ChangeFind(K);
+}
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
+
+
+
+
+
+protected:
+
+
+
+
+
+private:
+
+  
+  Standard_EXPORT   BRepMesh_DataMapOfIntegerListOfInteger(const BRepMesh_DataMapOfIntegerListOfInteger& Other);
+
+
+
+
+};
+
+
+
+
+
+// other Inline functions and methods (like "C++: function call" methods)
+
+
+#endif
diff --git a/inc/BRepMesh_DataMapOfIntegerListOfXY.hxx b/inc/BRepMesh_DataMapOfIntegerListOfXY.hxx
index c3d2382..df04dad 100644
--- a/inc/BRepMesh_DataMapOfIntegerListOfXY.hxx
+++ b/inc/BRepMesh_DataMapOfIntegerListOfXY.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class BRepMesh_ListOfXY;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/BRepMesh_DataMapOfIntegerPnt.hxx b/inc/BRepMesh_DataMapOfIntegerPnt.hxx
index beac166..445b971 100644
--- a/inc/BRepMesh_DataMapOfIntegerPnt.hxx
+++ b/inc/BRepMesh_DataMapOfIntegerPnt.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class gp_Pnt;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/BRepMesh_DataMapOfShapePairOfPolygon.hxx b/inc/BRepMesh_DataMapOfShapePairOfPolygon.hxx
index f79fc8e..9f303e1 100644
--- a/inc/BRepMesh_DataMapOfShapePairOfPolygon.hxx
+++ b/inc/BRepMesh_DataMapOfShapePairOfPolygon.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepMesh_DataMapOfShapeReal.hxx b/inc/BRepMesh_DataMapOfShapeReal.hxx
index 70bcce0..e6f48e3 100644
--- a/inc/BRepMesh_DataMapOfShapeReal.hxx
+++ b/inc/BRepMesh_DataMapOfShapeReal.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepMesh_DataMapOfVertexInteger.hxx b/inc/BRepMesh_DataMapOfVertexInteger.hxx
index 8b83223..4d748c2 100644
--- a/inc/BRepMesh_DataMapOfVertexInteger.hxx
+++ b/inc/BRepMesh_DataMapOfVertexInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Vertex;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Vertex& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Vertex& K) ;
 
 
 
diff --git a/inc/BRepMesh_DataStructureOfDelaun.hxx b/inc/BRepMesh_DataStructureOfDelaun.hxx
index e859744..b9c1800 100644
--- a/inc/BRepMesh_DataStructureOfDelaun.hxx
+++ b/inc/BRepMesh_DataStructureOfDelaun.hxx
@@ -16,15 +16,15 @@
 #include <Handle_BRepMesh_DataStructureOfDelaun.hxx>
 #endif
 
-#ifndef _BRepMesh_IDMapOfNodeOfDataStructureOfDelaun_HeaderFile
-#include <BRepMesh_IDMapOfNodeOfDataStructureOfDelaun.hxx>
-#endif
-#ifndef _BRepMesh_ListOfInteger_HeaderFile
-#include <BRepMesh_ListOfInteger.hxx>
+#ifndef _BRepMesh_VertexTool_HeaderFile
+#include <BRepMesh_VertexTool.hxx>
 #endif
 #ifndef _BRepMesh_IDMapOfLinkOfDataStructureOfDelaun_HeaderFile
 #include <BRepMesh_IDMapOfLinkOfDataStructureOfDelaun.hxx>
 #endif
+#ifndef _BRepMesh_ListOfInteger_HeaderFile
+#include <BRepMesh_ListOfInteger.hxx>
+#endif
 #ifndef _BRepMesh_IMapOfElementOfDataStructureOfDelaun_HeaderFile
 #include <BRepMesh_IMapOfElementOfDataStructureOfDelaun.hxx>
 #endif
@@ -50,7 +50,7 @@
 #include <Standard_OStream.hxx>
 #endif
 class BRepMesh_Vertex;
-class BRepMesh_IDMapOfNodeOfDataStructureOfDelaun;
+class BRepMesh_VertexTool;
 class BRepMesh_Edge;
 class BRepMesh_Triangle;
 
@@ -86,7 +86,7 @@ public:
   //! Removes the all nodes and sets new map of <br>
 //! nodes from the mesh. <br>
 //! For internal use only. <br>
-  Standard_EXPORT     void ReplaceNodes(const BRepMesh_IDMapOfNodeOfDataStructureOfDelaun& NewNodes) ;
+  Standard_EXPORT     void ReplaceNodes(const BRepMesh_VertexTool& NewNodes) ;
   //! Removes the node of index <index> from the mesh. <br>
   Standard_EXPORT     void RemoveNode(const Standard_Integer Index) ;
   //! Changes the UV  value of node of index <Index>  by <br>
@@ -126,7 +126,7 @@ public:
   Standard_EXPORT     void ClearDomain() ;
   //! Finds the index of the node.  Returns 0 if the <br>
 //!          node is not in the mesh. <br>
-  Standard_EXPORT     Standard_Integer IndexOf(const BRepMesh_Vertex& aNode) const;
+  Standard_EXPORT     Standard_Integer IndexOf(const BRepMesh_Vertex& aNode) ;
   //! Finds the index of the Link.  Returns 0 if the <br>
 //!          Link is not in the mesh. <br>
   Standard_EXPORT     Standard_Integer IndexOf(const BRepMesh_Edge& aLink) const;
@@ -152,6 +152,9 @@ public:
   Standard_EXPORT     void Statistics(Standard_OStream& flot) const;
   
   Standard_EXPORT    const BRepMesh_BaseAllocator& Allocator() const;
+  //! Give the data structure for cell size and <br>
+//!          tolerance initialization. <br>
+  Standard_EXPORT     BRepMesh_VertexTool& Data() ;
 
 
 
@@ -169,8 +172,7 @@ private:
 //!          the mesh. Used by RemoveElement. <br>
   Standard_EXPORT     void ClearElement(const Standard_Integer Index,const BRepMesh_Triangle& theElem) ;
 
-BRepMesh_IDMapOfNodeOfDataStructureOfDelaun myNodes;
-BRepMesh_ListOfInteger myDelNodes;
+BRepMesh_VertexTool myNodes;
 BRepMesh_IDMapOfLinkOfDataStructureOfDelaun myLinks;
 BRepMesh_ListOfInteger myDelLinks;
 BRepMesh_IMapOfElementOfDataStructureOfDelaun myElements;
diff --git a/inc/BRepMesh_Delaun.hxx b/inc/BRepMesh_Delaun.hxx
index d8beae6..3c175e7 100644
--- a/inc/BRepMesh_Delaun.hxx
+++ b/inc/BRepMesh_Delaun.hxx
@@ -31,9 +31,6 @@
 #ifndef _BRepMesh_MapOfInteger_HeaderFile
 #include <BRepMesh_MapOfInteger.hxx>
 #endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
 #ifndef _BRepMesh_MapOfIntegerInteger_HeaderFile
 #include <BRepMesh_MapOfIntegerInteger.hxx>
 #endif
@@ -74,22 +71,12 @@ public:
   //! Creates  the triangulation with   and existant <br>
 //!          Mesh data structure. <br>
   Standard_EXPORT   BRepMesh_Delaun(const Handle(BRepMesh_DataStructureOfDelaun)& OldMesh,TColStd_Array1OfInteger& VertexIndices,const Standard_Boolean ZPositive = Standard_True);
-  //! Adds a new vertex in the triangulation. <br>
-  Standard_EXPORT     void AddVertex(const BRepMesh_Vertex& theVertex) ;
   //! Removes a vertex in the triangulation. <br>
   Standard_EXPORT     void RemoveVertex(const BRepMesh_Vertex& theVertex) ;
   //! Adds some vertices in the triangulation. <br>
   Standard_EXPORT     void AddVertices(BRepMesh_Array1OfVertexOfDelaun& Vertices) ;
-  //! Substitutes the Edge beetween to  triangles by the <br>
-//!          other  diagonal  of  the  quadrilatere  if  it  is <br>
-//!          possible (convex polygon). Return True if done. <br>
-  Standard_EXPORT     Standard_Boolean RevertDiagonal(const Standard_Integer theEdge) ;
   //! Modify mesh to use the edge. Return True if done. <br>
   Standard_EXPORT     Standard_Boolean UseEdge(const Standard_Integer theEdge) ;
-  //! Smooths the  mesh  in 2d space. The  method  is to <br>
-//!          move  the  free  and  OnSurface  vertices  at  the <br>
-//!          barycentre of their polygon. <br>
-  Standard_EXPORT     void SmoothMesh(const Standard_Real Epsilon) ;
   //! Gives the Mesh data structure. <br>
   Standard_EXPORT    const Handle_BRepMesh_DataStructureOfDelaun& Result() const;
   //! Gives the list of frontier edges <br>
@@ -110,9 +97,6 @@ public:
   //! Computes the triangulation and add the vertices <br>
 //!          edges and triangles to the Mesh data structure. <br>
   Standard_EXPORT     void Compute(TColStd_Array1OfInteger& VertexIndices) ;
-  //! Clear the  existing  triangles  and recomputes <br>
-//!          the triangulation . <br>
-  Standard_EXPORT     void ReCompute(TColStd_Array1OfInteger& VertexIndices) ;
   //! Build the super mesh . <br>
   Standard_EXPORT     void SuperMesh(const Bnd_Box2d& theBox) ;
   //! Test  if   triangle   of  index   <TrianIndex> <br>
@@ -120,9 +104,6 @@ public:
 //!          is != 0  then theVertex is  on Edge  of  index <br>
 //!          <edgeOn>. <br>
   Standard_EXPORT     Standard_Boolean Contains(const Standard_Integer TrianIndex,const BRepMesh_Vertex& theVertex,Standard_Integer& edgeOn) const;
-  //! Gives  the   index   of  triangle   containing <br>
-//!          geometricaly <theVertex>. <br>
-  Standard_EXPORT     Standard_Integer TriangleContaining(const BRepMesh_Vertex& theVertex) ;
 
 
 
@@ -150,6 +131,10 @@ private:
 //!          When an edge is suppressed more than one time <br>
 //!          it is destroyed. <br>
   Standard_EXPORT     void DeleteTriangle(const Standard_Integer TrianIndex,BRepMesh_MapOfIntegerInteger& freeEdges) ;
+  
+  Standard_EXPORT     void Perform(Bnd_Box2d& theBndBox,TColStd_Array1OfInteger& theVertexIndices) ;
+  //! Creates the triangles on new nodes <br>
+  Standard_EXPORT     void CreateTrianglesOnNewVertices(TColStd_Array1OfInteger& theVertexIndices) ;
 
 
 Handle_BRepMesh_DataStructureOfDelaun MeshData;
diff --git a/inc/BRepMesh_DiscretFactory.hxx b/inc/BRepMesh_DiscretFactory.hxx
index 390e15d..9a5cdc3 100644
--- a/inc/BRepMesh_DiscretFactory.hxx
+++ b/inc/BRepMesh_DiscretFactory.hxx
@@ -13,8 +13,8 @@
 #include <Standard_Macro.hxx>
 #endif
 
-#ifndef _BRepMesh_PDiscretRoot_HeaderFile
-#include <BRepMesh_PDiscretRoot.hxx>
+#ifndef _BRepMesh_PluginEntryType_HeaderFile
+#include <BRepMesh_PluginEntryType.hxx>
 #endif
 #ifndef _BRepMesh_FactoryError_HeaderFile
 #include <BRepMesh_FactoryError.hxx>
@@ -25,15 +25,28 @@
 #ifndef _TCollection_AsciiString_HeaderFile
 #include <TCollection_AsciiString.hxx>
 #endif
+#ifndef _Plugin_MapOfFunctions_HeaderFile
+#include <Plugin_MapOfFunctions.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _Handle_BRepMesh_DiscretRoot_HeaderFile
+#include <Handle_BRepMesh_DiscretRoot.hxx>
+#endif
 #ifndef _Standard_Real_HeaderFile
 #include <Standard_Real.hxx>
 #endif
 class TColStd_MapOfAsciiString;
 class TCollection_AsciiString;
+class BRepMesh_DiscretRoot;
 class TopoDS_Shape;
 
 
 
+//! This class intended to setup / retrieve default triangulation algorithm. <br>
+//! Use BRepMesh_DiscretFactory::Get() static method to retrieve global Factory instance. <br>
+//! Use BRepMesh_DiscretFactory::Discret() method to retrieve meshing tool. <br>
 class BRepMesh_DiscretFactory  {
 public:
 
@@ -51,20 +64,38 @@ public:
   }
 
   
+//! Returns the global factory instance. <br>
   Standard_EXPORT   static  BRepMesh_DiscretFactory& Get() ;
   
+//! Returns the list of registered meshing algorithms. <br>
   Standard_EXPORT    const TColStd_MapOfAsciiString& Names() const;
   
-  Standard_EXPORT     void SetDefaultName(const TCollection_AsciiString& theName) ;
+//! Setup meshing algorithm by name. <br>
+//! Returns true if requested tool is available. <br>
+//! On fail Factory will continue to use previous algo. <br>
+  Standard_EXPORT     Standard_Boolean SetDefaultName(const TCollection_AsciiString& theName) ;
   
+//! Returns name for current meshing algorithm. <br>
   Standard_EXPORT    const TCollection_AsciiString& DefaultName() const;
   
-  Standard_EXPORT     void SetFunctionName(const TCollection_AsciiString& theName) ;
+//! Advanced function. Changes function name to retrieve from plugin. <br>
+//! Returns true if requested tool is available. <br>
+//! On fail Factory will continue to use previous algo. <br>
+  Standard_EXPORT     Standard_Boolean SetFunctionName(const TCollection_AsciiString& theFuncName) ;
+  
+//! Setup meshing algorithm that should be created by this Factory. <br>
+//! Returns true if requested tool is available. <br>
+//! On fail Factory will continue to use previous algo. <br>
+//! Call ::ErrorStatus() method to retrieve fault reason. <br>
+  Standard_EXPORT     Standard_Boolean SetDefault(const TCollection_AsciiString& theName,const TCollection_AsciiString& theFuncName = "DISCRETALGO") ;
   
+//! Returns function name that should be exported by plugin. <br>
   Standard_EXPORT    const TCollection_AsciiString& FunctionName() const;
   
-  Standard_EXPORT     BRepMesh_PDiscretRoot& Discret(const TopoDS_Shape& theShape,const Standard_Real theDeflection,const Standard_Real theAngle) ;
+//! Returns triangulation algorithm instance. <br>
+  Standard_EXPORT     Handle_BRepMesh_DiscretRoot Discret(const TopoDS_Shape& theShape,const Standard_Real theDeflection,const Standard_Real theAngle) ;
   
+//! Returns error status for last meshing algorithm switch. <br>
   Standard_EXPORT     BRepMesh_FactoryError ErrorStatus() const;
 
 
@@ -80,12 +111,12 @@ Standard_EXPORT virtual ~BRepMesh_DiscretFactory();
   Standard_EXPORT     void Clear() ;
 
 
-BRepMesh_PDiscretRoot myPDiscret;
+BRepMesh_PluginEntryType myPluginEntry;
 BRepMesh_FactoryError myErrorStatus;
 TColStd_MapOfAsciiString myNames;
-TCollection_AsciiString myFixedNames[1];
 TCollection_AsciiString myDefaultName;
 TCollection_AsciiString myFunctionName;
+Plugin_MapOfFunctions myFactoryMethods;
 
 
 private:
diff --git a/inc/BRepMesh_DiscretRoot.hxx b/inc/BRepMesh_DiscretRoot.hxx
index 0dd8234..ba4edee 100644
--- a/inc/BRepMesh_DiscretRoot.hxx
+++ b/inc/BRepMesh_DiscretRoot.hxx
@@ -9,8 +9,11 @@
 #ifndef _Standard_HeaderFile
 #include <Standard.hxx>
 #endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
+#ifndef _Standard_DefineHandle_HeaderFile
+#include <Standard_DefineHandle.hxx>
+#endif
+#ifndef _Handle_BRepMesh_DiscretRoot_HeaderFile
+#include <Handle_BRepMesh_DiscretRoot.hxx>
 #endif
 
 #ifndef _Standard_Real_HeaderFile
@@ -22,47 +25,48 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Transient_HeaderFile
+#include <Standard_Transient.hxx>
+#endif
 class TopoDS_Shape;
 
 
 
-class BRepMesh_DiscretRoot  {
-public:
+//! This is a common interface for meshing algorithms <br>
+//! instantiated by Mesh Factory and implemented by plugins. <br>
+class BRepMesh_DiscretRoot : public Standard_Transient {
 
-  void* operator new(size_t,void* anAddress) 
-  {
-    return anAddress;
-  }
-  void* operator new(size_t size) 
-  {
-    return Standard::Allocate(size); 
-  }
-  void  operator delete(void *anAddress) 
-  {
-    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-  }
+public:
 
   
+//! Setup linear deflection. <br>
   Standard_EXPORT     void SetDeflection(const Standard_Real theDeflection) ;
 Standard_EXPORT virtual ~BRepMesh_DiscretRoot();
   
+//! Returns linear deflection. <br>
   Standard_EXPORT     Standard_Real Deflection() const;
   
+//! Setup angular deflection. <br>
   Standard_EXPORT     void SetAngle(const Standard_Real theAngle) ;
   
+//! Returns angular deflection. <br>
   Standard_EXPORT     Standard_Real Angle() const;
   
+//! Set the shape to triangulate. <br>
   Standard_EXPORT     void SetShape(const TopoDS_Shape& theShape) ;
   
   Standard_EXPORT    const TopoDS_Shape& Shape() const;
   
+//! Compute triangulation for set shape. <br>
   Standard_EXPORT   virtual  void Perform()  = 0;
   
+//! Returns true if triangualtion was performed and has success. <br>
   Standard_EXPORT     Standard_Boolean IsDone() const;
 
 
 
 
+  DEFINE_STANDARD_RTTI(BRepMesh_DiscretRoot)
 
 protected:
 
@@ -75,15 +79,13 @@ protected:
   
   Standard_EXPORT   virtual  void Init() ;
 
-
 Standard_Real myDeflection;
 Standard_Real myAngle;
 TopoDS_Shape myShape;
 Standard_Boolean myIsDone;
 
 
-private:
-
+private: 
 
 
 
diff --git a/inc/BRepMesh_FastDiscret.hxx b/inc/BRepMesh_FastDiscret.hxx
index bcbf4fc..c24f982 100644
--- a/inc/BRepMesh_FastDiscret.hxx
+++ b/inc/BRepMesh_FastDiscret.hxx
@@ -80,6 +80,7 @@ class BRepMesh_DataStructureOfDelaun;
 class Bnd_Box;
 class TopoDS_Shape;
 class TopoDS_Face;
+class TopTools_IndexedDataMapOfShapeListOfShape;
 class TopoDS_Edge;
 class BRepAdaptor_HSurface;
 class Geom2d_Curve;
@@ -120,7 +121,7 @@ public:
   //! Build triangulation on the whole shape <br>
   Standard_EXPORT     void Perform(const TopoDS_Shape& shape) ;
   //! Record a face for further processing. <br>
-  Standard_EXPORT     void Add(const TopoDS_Face& face) ;
+  Standard_EXPORT     void Add(const TopoDS_Face& face,const TopTools_IndexedDataMapOfShapeListOfShape& ancestor) ;
   //! Triangulate a face previously recorded for <br>
 //!          processing by call to Add(). Can be executed in <br>
 //!          parallel threads. <br>
@@ -131,6 +132,17 @@ public:
 }
   
   Standard_EXPORT     BRepMesh_Status CurrentFaceStatus() const;
+  //! Returns computed relative deflection for edge <br>
+  Standard_EXPORT   static  Standard_Real RelativeEdgeDeflection(const TopoDS_Edge& edge,const Standard_Real defle,const Standard_Real dtotale,Standard_Real& cdef) ;
+  //! Returns the maximal dimension of Bnd_Box <br>
+  Standard_EXPORT   static  void BoxMaxDimension(const Bnd_Box& box,Standard_Real& maxdim) ;
+  
+//! Request algorithm to launch in multiple threads <br>
+//! to improve performance (should be supported by plugin). <br>
+  Standard_EXPORT     void SetParallel(const Standard_Boolean theInParallel) ;
+  
+//! Returns the multi-threading usage flag. <br>
+  Standard_EXPORT     Standard_Boolean IsParallel() const;
   //! Gives the number of built triangles. <br>
   Standard_EXPORT     Standard_Integer NbTriangles() const;
   //! Gives the triangle of <Index>. <br>
@@ -189,7 +201,7 @@ protected:
 private: 
 
   
-  Standard_EXPORT     void Add(const TopoDS_Edge& edge,const TopoDS_Face& face,const Handle(BRepAdaptor_HSurface)& S,const Handle(Geom2d_Curve)& C,const Standard_Real defedge,const Standard_Real first,const Standard_Real last) ;
+  Standard_EXPORT     void Add(const TopoDS_Edge& edge,const TopoDS_Face& face,const Handle(BRepAdaptor_HSurface)& S,const Handle(Geom2d_Curve)& C,const TopTools_IndexedDataMapOfShapeListOfShape& ancestor,const Standard_Real defedge,const Standard_Real first,const Standard_Real last) ;
   
   Standard_EXPORT     void Add(const TopoDS_Vertex& theVert,const TopoDS_Face& face,const Handle(BRepAdaptor_HSurface)& S) ;
   
@@ -205,6 +217,7 @@ Standard_Real myAngle;
 Standard_Real myDeflection;
 Standard_Real myDtotale;
 Standard_Boolean myWithShare;
+Standard_Boolean myInParallel;
 BRepMesh_DataMapOfVertexInteger myVertices;
 BRepMesh_DataMapOfShapePairOfPolygon myEdges;
 BRepMesh_DataMapOfShapePairOfPolygon myInternaledges;
diff --git a/inc/BRepMesh_IDMapOfLinkOfDataStructureOfDelaun.hxx b/inc/BRepMesh_IDMapOfLinkOfDataStructureOfDelaun.hxx
index c18082b..21e0205 100644
--- a/inc/BRepMesh_IDMapOfLinkOfDataStructureOfDelaun.hxx
+++ b/inc/BRepMesh_IDMapOfLinkOfDataStructureOfDelaun.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -97,6 +100,10 @@ public:
   Standard_EXPORT    const BRepMesh_PairOfIndex& FindFromKey(const BRepMesh_Edge& K) const;
   
   Standard_EXPORT     BRepMesh_PairOfIndex& ChangeFromKey(const BRepMesh_Edge& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const BRepMesh_Edge& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const BRepMesh_Edge& K) ;
 
 
 
diff --git a/inc/BRepMesh_IDMapOfNodeOfDataStructureOfDelaun.hxx b/inc/BRepMesh_IDMapOfNodeOfDataStructureOfDelaun.hxx
index ce08f6e..4ec41c1 100644
--- a/inc/BRepMesh_IDMapOfNodeOfDataStructureOfDelaun.hxx
+++ b/inc/BRepMesh_IDMapOfNodeOfDataStructureOfDelaun.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -97,6 +100,10 @@ public:
   Standard_EXPORT    const BRepMesh_ListOfInteger& FindFromKey(const BRepMesh_Vertex& K) const;
   
   Standard_EXPORT     BRepMesh_ListOfInteger& ChangeFromKey(const BRepMesh_Vertex& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const BRepMesh_Vertex& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const BRepMesh_Vertex& K) ;
 
 
 
diff --git a/inc/BRepMesh_IncrementalMesh.hxx b/inc/BRepMesh_IncrementalMesh.hxx
index dd7f17e..00c804c 100644
--- a/inc/BRepMesh_IncrementalMesh.hxx
+++ b/inc/BRepMesh_IncrementalMesh.hxx
@@ -9,8 +9,11 @@
 #ifndef _Standard_HeaderFile
 #include <Standard.hxx>
 #endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
+#ifndef _Standard_DefineHandle_HeaderFile
+#include <Standard_DefineHandle.hxx>
+#endif
+#ifndef _Handle_BRepMesh_IncrementalMesh_HeaderFile
+#include <Handle_BRepMesh_IncrementalMesh.hxx>
 #endif
 
 #ifndef _Standard_Boolean_HeaderFile
@@ -40,6 +43,9 @@
 #ifndef _BRepMesh_DiscretRoot_HeaderFile
 #include <BRepMesh_DiscretRoot.hxx>
 #endif
+#ifndef _BRepMesh_PDiscretRoot_HeaderFile
+#include <BRepMesh_PDiscretRoot.hxx>
+#endif
 class BRepMesh_FastDiscret;
 class TopoDS_Shape;
 class TopoDS_Edge;
@@ -48,27 +54,14 @@ class TopoDS_Face;
 
 //! Builds the mesh of a shape with respect of their <br>
 //!          correctly triangulated parts <br>
-//! <br>
-class BRepMesh_IncrementalMesh  : public BRepMesh_DiscretRoot {
-public:
+class BRepMesh_IncrementalMesh : public BRepMesh_DiscretRoot {
 
-  void* operator new(size_t,void* anAddress) 
-  {
-    return anAddress;
-  }
-  void* operator new(size_t size) 
-  {
-    return Standard::Allocate(size); 
-  }
-  void  operator delete(void *anAddress) 
-  {
-    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-  }
+public:
 
   
   Standard_EXPORT   BRepMesh_IncrementalMesh();
 Standard_EXPORT virtual ~BRepMesh_IncrementalMesh();
-  //! if the  boolean    <Relatif>   is  True,    the <br>
+  //! If the  boolean    <Relatif>   is  True,    the <br>
 //!          deflection used   for the polygonalisation   of <br>
 //!          each edge will be <D> * Size of Edge. <br>
 //!          the deflection used for the faces will be the maximum <br>
@@ -86,18 +79,36 @@ Standard_EXPORT virtual ~BRepMesh_IncrementalMesh();
   Standard_EXPORT     Standard_Boolean IsModified() const;
   
   Standard_EXPORT     Standard_Integer GetStatusFlags() const;
+  
+//! Request algorithm to launch in multiple threads to improve performance. <br>
+  Standard_EXPORT     void SetParallel(const Standard_Boolean theInParallel) ;
+  
+//! Returns the multi-threading usage flag. <br>
+  Standard_EXPORT     Standard_Boolean IsParallel() const;
+  
+//! Plugin interface for the Mesh Factories. <br>
+  Standard_EXPORT   static  Standard_Integer Discret(const TopoDS_Shape& theShape,const Standard_Real theDeflection,const Standard_Real theAngle,BRepMesh_PDiscretRoot& theAlgo) ;
+  
+//! Returns multi-threading usage flag set by default in <br>
+//! Discret() static method (thus applied only to Mesh Factories). <br>
+  Standard_EXPORT   static  Standard_Boolean IsParallelDefault() ;
+  
+//! Setup multi-threading usage flag set by default in <br>
+//! Discret() static method (thus applied only to Mesh Factories). <br>
+  Standard_EXPORT   static  void SetParallelDefault(const Standard_Boolean theInParallel) ;
 
 
 
 
+  DEFINE_STANDARD_RTTI(BRepMesh_IncrementalMesh)
 
 protected:
 
   
   Standard_EXPORT   virtual  void Init() ;
 
-
 Standard_Boolean myRelative;
+Standard_Boolean myInParallel;
 TopTools_MapOfShape myMap;
 Handle_BRepMesh_FastDiscret myMesh;
 Standard_Boolean myModified;
@@ -108,12 +119,12 @@ Bnd_Box myBox;
 Standard_Integer myStatus;
 
 
-private:
+private: 
 
   //! Locate a correct discretisation if it exists <br>
 //!          Set no one otherwise <br>
   Standard_EXPORT     void Update(const TopoDS_Edge& E) ;
-  //! if the face is  not correctly triangulated, or <br>
+  //! If the face is  not correctly triangulated, or <br>
 //!          if  one  of its edges  is  to be discretisated <br>
 //!          correctly, the triangulation  of this face  is <br>
 //!          built. <br>
@@ -121,7 +132,6 @@ private:
 
 
 
-
 };
 
 
diff --git a/inc/BRepMesh_PluginEntryType.hxx b/inc/BRepMesh_PluginEntryType.hxx
new file mode 100644
index 0000000..d657557
--- /dev/null
+++ b/inc/BRepMesh_PluginEntryType.hxx
@@ -0,0 +1,17 @@
+#ifndef _BRepMesh_PluginEntryType_HeaderFile
+#define _BRepMesh_PluginEntryType_HeaderFile
+
+#ifndef _Standard_Real_HeaderFile
+  #include <Standard_Real.hxx>
+#endif
+
+class TopoDS_Shape;
+class BRepMesh_DiscretRoot;
+
+//! Type definition for plugin exported function
+typedef Standard_Integer (*BRepMesh_PluginEntryType) (const TopoDS_Shape&    theShape,
+                                                      const Standard_Real    theDeflection,
+                                                      const Standard_Real    theAngle,
+                                                      BRepMesh_DiscretRoot*& theMeshAlgoInstance);
+
+#endif //_BRepMesh_PluginEntryType_HeaderFile
diff --git a/inc/BRepMesh_VectorOfVertex.hxx b/inc/BRepMesh_VectorOfVertex.hxx
new file mode 100644
index 0000000..f2e6592
--- /dev/null
+++ b/inc/BRepMesh_VectorOfVertex.hxx
@@ -0,0 +1,19 @@
+// File:        BRepMesh_VectorOfVertex.hxx
+// Created:     Jun 1 18:11:53 2011
+// Author:      Oleg AGASHIN
+// Copyright:   Open CASCADE SAS 2011
+
+
+#ifndef _BRepMesh_VectorOfVertex_HeaderFile
+#define _BRepMesh_VectorOfVertex_HeaderFile
+
+#ifndef _BRepMesh_Vertex_HeaderFile
+#include <BRepMesh_Vertex.hxx>
+#endif
+#ifndef NCollection_Vector_HeaderFile
+#include <NCollection_Vector.hxx>
+#endif
+
+typedef NCollection_Vector<BRepMesh_Vertex> BRepMesh_VectorOfVertex;
+
+#endif
diff --git a/inc/BRepMesh_VertexCellFilter.hxx b/inc/BRepMesh_VertexCellFilter.hxx
new file mode 100644
index 0000000..1df57bc
--- /dev/null
+++ b/inc/BRepMesh_VertexCellFilter.hxx
@@ -0,0 +1,24 @@
+// File:        BRepMesh_VertexCellFilter.hxx
+// Created:     Jun 2 10:17:51 2011
+// Author:      Oleg AGASHIN
+// Copyright:   Open CASCADE SAS 2011
+
+#ifndef _BRepMesh_VertexCellFilter_HeaderFile
+#define _BRepMesh_VertexCellFilter_HeaderFile
+
+#ifndef _gp_XYZ_HeaderFile
+#include <gp_XYZ.hxx>
+#endif
+#ifndef _gp_XY_HeaderFile
+#include <gp_XY.hxx>
+#endif
+#ifndef NCollection_CellFilter_HeaderFile
+#include <NCollection_CellFilter.hxx>
+#endif
+#ifndef _BRepMesh_VertexInspector_HeaderFile
+#include <BRepMesh_VertexInspector.hxx>
+#endif
+
+typedef NCollection_CellFilter<BRepMesh_VertexInspector> BRepMesh_VertexCellFilter;
+
+#endif
diff --git a/inc/BRepMesh_VertexInspector.hxx b/inc/BRepMesh_VertexInspector.hxx
new file mode 100644
index 0000000..fd04588
--- /dev/null
+++ b/inc/BRepMesh_VertexInspector.hxx
@@ -0,0 +1,132 @@
+// File:        BRepMesh_VertexInspector.hxx
+// Created:     Jun 1 18:13:23 2011
+// Author:      Oleg AGASHIN
+// Copyright:   Open CASCADE SAS 2011
+
+
+#ifndef _BRepMesh_VertexInspector_HeaderFile
+#define _BRepMesh_VertexInspector_HeaderFile
+
+#include <BRepMesh_ListOfInteger.hxx> 
+#ifndef _Precision_HeaderFile
+#include <Precision.hxx>
+#endif
+#ifndef _gp_XY_HeaderFile
+#include <gp_XY.hxx>
+#endif
+#ifndef _gp_XYZ_HeaderFile
+#include <gp_XYZ.hxx>
+#endif
+
+#ifndef NCollection_CellFilter_HeaderFile
+#include <NCollection_CellFilter.hxx>
+#endif
+#ifndef _BRepMesh_Vertex_HeaderFile
+#include <BRepMesh_Vertex.hxx>
+#endif
+#ifndef _BRepMesh_VectorOfVertex_HeaderFile
+#include <BRepMesh_VectorOfVertex.hxx>
+#endif
+#ifndef _TColStd_Array1OfReal_HeaderFile
+#include <TColStd_Array1OfReal.hxx>
+#endif
+#include <BRepMesh_BaseAllocator.hxx>
+
+//=======================================================================
+//! The class to find in the coincidence points 
+//=======================================================================
+
+class BRepMesh_VertexInspector : public NCollection_CellFilter_InspectorXY
+{
+public:
+  typedef Standard_Integer Target;
+  //! Constructor; remembers tolerance and collector data structure.
+  //! theTol can be Real or Array1OfReal with two elements which describe
+  //! tolerance for each dimension.
+  BRepMesh_VertexInspector (const Standard_Integer nbComp,
+                            const BRepMesh_BaseAllocator& theAlloc);
+                            
+  BRepMesh_VertexInspector (const Standard_Integer nbComp,
+                            const Standard_Real    theTol,
+                            const BRepMesh_BaseAllocator& theAlloc);
+                            
+  BRepMesh_VertexInspector (const Standard_Integer nbComp,
+                            const Standard_Real    aTolX,
+                            const Standard_Real    aTolY,
+                            const BRepMesh_BaseAllocator& theAlloc);
+
+  Standard_Integer Add(const BRepMesh_Vertex& theVertex);
+  
+  void SetTolerance(const Standard_Real theTol)
+  {
+    myTol(0) = theTol*theTol;
+    myTol(1) = 0.;
+  }
+  
+  void SetTolerance(const Standard_Real theTolX, const Standard_Real theTolY)
+  {
+    myTol(0) = theTolX*theTolX;
+    myTol(1) = theTolY*theTolY;
+  }
+  
+  void Clear()
+  {
+    myVertices.Clear();
+    myDelNodes.Clear();
+  }
+
+  void Delete(const Standard_Integer theIndex)
+  {
+    myVertices(theIndex-1).SetMovability(BRepMesh_Deleted);
+    myDelNodes.Append(theIndex);
+  }
+  
+  Standard_Integer GetNbVertices() const
+  {
+    return myVertices.Length(); 
+  }
+
+  BRepMesh_Vertex& GetVertex(Standard_Integer theInd)
+  {
+    return myVertices(theInd-1);
+  }
+  
+  //! Set current node to be checked
+  void SetCurrent (const gp_XY& theCurVertex, const Standard_Boolean theExactVal = Standard_False) 
+  { 
+    myResInd.Clear();
+    myCurrent = theCurVertex;
+  }
+
+  //!Get result index of node
+  const Standard_Integer GetCoincidentInd() const
+  {
+    if ( myResInd.Size() > 0 )
+    {
+      return myResInd.First();
+    }
+    return 0;
+  }
+  
+  const BRepMesh_ListOfInteger& GetListOfDelNodes() const
+  {
+    return myDelNodes;
+  }
+
+  //! Implementation of inspection method
+  NCollection_CellFilter_Action Inspect (const Standard_Integer theTarget); 
+
+  static Standard_Boolean IsEqual (Standard_Integer theIdx, const Standard_Integer theTarget)
+  {
+    return (theIdx == theTarget);
+  }
+
+private:
+  TColStd_Array1OfReal                 myTol;
+  BRepMesh_ListOfInteger               myResInd;
+  BRepMesh_VectorOfVertex              myVertices;
+  BRepMesh_ListOfInteger               myDelNodes;
+  gp_XY                                myCurrent;
+};
+
+#endif
diff --git a/inc/BRepMesh_VertexTool.hxx b/inc/BRepMesh_VertexTool.hxx
new file mode 100644
index 0000000..85f6e4a
--- /dev/null
+++ b/inc/BRepMesh_VertexTool.hxx
@@ -0,0 +1,146 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#ifndef _BRepMesh_VertexTool_HeaderFile
+#define _BRepMesh_VertexTool_HeaderFile
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+
+#ifndef _BRepMesh_BaseAllocator_HeaderFile
+#include <BRepMesh_BaseAllocator.hxx>
+#endif
+#ifndef _BRepMesh_VertexCellFilter_HeaderFile
+#include <BRepMesh_VertexCellFilter.hxx>
+#endif
+#ifndef _BRepMesh_VertexInspector_HeaderFile
+#include <BRepMesh_VertexInspector.hxx>
+#endif
+#ifndef _BRepMesh_DataMapOfIntegerListOfInteger_HeaderFile
+#include <BRepMesh_DataMapOfIntegerListOfInteger.hxx>
+#endif
+#ifndef _TColStd_Array1OfReal_HeaderFile
+#include <TColStd_Array1OfReal.hxx>
+#endif
+#ifndef _Standard_Integer_HeaderFile
+#include <Standard_Integer.hxx>
+#endif
+#ifndef _Standard_Real_HeaderFile
+#include <Standard_Real.hxx>
+#endif
+#ifndef _BRepMesh_ListOfInteger_HeaderFile
+#include <BRepMesh_ListOfInteger.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _Standard_OStream_HeaderFile
+#include <Standard_OStream.hxx>
+#endif
+class BRepMesh_Vertex;
+class gp_XY;
+
+
+//! Describes the data structure necessary for the <br>
+//!          mesh algorithm and contains the vertices in UV space. <br>
+class BRepMesh_VertexTool  {
+public:
+
+  void* operator new(size_t,void* anAddress) 
+  {
+    return anAddress;
+  }
+  void* operator new(size_t size) 
+  {
+    return Standard::Allocate(size); 
+  }
+  void  operator delete(void *anAddress) 
+  {
+    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
+  }
+
+  
+  Standard_EXPORT   BRepMesh_VertexTool(const BRepMesh_BaseAllocator& theAlloc);
+  //! Constructs a VertexTool with an  evaluation of the <br>
+//!          number of vertices. <br>
+  Standard_EXPORT   BRepMesh_VertexTool(const Standard_Integer nbComp,const BRepMesh_BaseAllocator& theAlloc);
+  //! Sets new size for cellfilter. <br>
+  Standard_EXPORT     void SetCellSize(const Standard_Real theSize) ;
+  //! Sets new size for cellfilter. <br>
+  Standard_EXPORT     void SetCellSize(const Standard_Real theXSize,const Standard_Real theYSize) ;
+  //! Sets new size for cellfilter. <br>
+  Standard_EXPORT     void SetTolerance(const Standard_Real theTol) ;
+  //! Sets new size for cellfilter. <br>
+  Standard_EXPORT     void SetTolerance(const Standard_Real theTolX,const Standard_Real theTolY) ;
+  //! Adds a vertex to the tool. <br>
+  Standard_EXPORT     Standard_Integer Add(const BRepMesh_Vertex& theVertex,const BRepMesh_ListOfInteger& theParams) ;
+  //! Adds a vertex to the tool. <br>
+  Standard_EXPORT     Standard_Integer Add(const BRepMesh_Vertex& theVertex) ;
+  //! Deletes a vertex from the tool. <br>
+  Standard_EXPORT     void Delete(const Standard_Integer theIndex) ;
+  //! Returns data assigned to theIndex. <br>
+  Standard_EXPORT     BRepMesh_ListOfInteger& FindFromIndex(const Standard_Integer theIndex) const;
+    BRepMesh_ListOfInteger& operator()(const Standard_Integer theIndex) const
+{
+  return FindFromIndex(theIndex);
+}
+  //! Selects the vertex by theIndex. <br>
+  Standard_EXPORT    const BRepMesh_Vertex& FindKey(const Standard_Integer theIndex) ;
+  //! Returns an index of theVertex. <br>
+  Standard_EXPORT     Standard_Integer FindIndex(const BRepMesh_Vertex& theVertex) ;
+  //! Returns a number of vertices. <br>
+  Standard_EXPORT     Standard_Integer Extent() const;
+  //! Returns True when the map contains no keys. <br>
+  Standard_EXPORT     Standard_Boolean IsEmpty() const;
+  //! Substitutes vertex with Index on <br>
+//!          theVertex with attributes theData. <br>
+  Standard_EXPORT     void Substitute(const Standard_Integer Index,const BRepMesh_Vertex& theVertex,const BRepMesh_ListOfInteger& theData) ;
+  //! Remove last node from the structure. <br>
+  Standard_EXPORT     void RemoveLast() ;
+  //! Returns the list with indexes of <br>
+//!          vertices that have Movability attribute <br>
+//!          equal to BRepMesh_Deleted and can be <br>
+//!          replaced with another node. <br>
+  Standard_EXPORT    const BRepMesh_ListOfInteger& GetListOfDelNodes() const;
+  //! Prints statistics. <br>
+  Standard_EXPORT     void Statistics(Standard_OStream& S) const;
+
+
+
+
+
+protected:
+
+
+
+
+
+private:
+
+  
+  Standard_EXPORT     void ExpandPoint(const gp_XY& thePnt,gp_XY& theMinPnt,gp_XY& theMaxPnt) ;
+
+
+BRepMesh_BaseAllocator myAllocator;
+BRepMesh_VertexCellFilter myCellFilter;
+BRepMesh_VertexInspector mySelector;
+BRepMesh_DataMapOfIntegerListOfInteger myLinksMap;
+TColStd_Array1OfReal myTol;
+
+
+};
+
+
+
+
+
+// other Inline functions and methods (like "C++: function call" methods)
+
+
+#endif
diff --git a/inc/BRepOffset_DataMapOfShapeListOfInterval.hxx b/inc/BRepOffset_DataMapOfShapeListOfInterval.hxx
index 8556724..a4f101b 100644
--- a/inc/BRepOffset_DataMapOfShapeListOfInterval.hxx
+++ b/inc/BRepOffset_DataMapOfShapeListOfInterval.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepOffset_DataMapOfShapeMapOfShape.hxx b/inc/BRepOffset_DataMapOfShapeMapOfShape.hxx
index 556ed25..6b92ff5 100644
--- a/inc/BRepOffset_DataMapOfShapeMapOfShape.hxx
+++ b/inc/BRepOffset_DataMapOfShapeMapOfShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepOffset_DataMapOfShapeOffset.hxx b/inc/BRepOffset_DataMapOfShapeOffset.hxx
index a44d8e4..102c9d9 100644
--- a/inc/BRepOffset_DataMapOfShapeOffset.hxx
+++ b/inc/BRepOffset_DataMapOfShapeOffset.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepTools_MapOfVertexPnt2d.hxx b/inc/BRepTools_MapOfVertexPnt2d.hxx
index 85e1290..fbcb7cf 100644
--- a/inc/BRepTools_MapOfVertexPnt2d.hxx
+++ b/inc/BRepTools_MapOfVertexPnt2d.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BRepTopAdaptor_MapOfShapeTool.hxx b/inc/BRepTopAdaptor_MapOfShapeTool.hxx
index 554d09d..f7faeac 100644
--- a/inc/BRepTopAdaptor_MapOfShapeTool.hxx
+++ b/inc/BRepTopAdaptor_MapOfShapeTool.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BiTgte_DataMapOfShapeBox.hxx b/inc/BiTgte_DataMapOfShapeBox.hxx
index 6cd2956..e9e372c 100644
--- a/inc/BiTgte_DataMapOfShapeBox.hxx
+++ b/inc/BiTgte_DataMapOfShapeBox.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BinLDrivers_DocumentStorageDriver.hxx b/inc/BinLDrivers_DocumentStorageDriver.hxx
index 4ea6f2c..d03ef7b 100644
--- a/inc/BinLDrivers_DocumentStorageDriver.hxx
+++ b/inc/BinLDrivers_DocumentStorageDriver.hxx
@@ -25,9 +25,6 @@
 #ifndef _BinObjMgt_SRelocationTable_HeaderFile
 #include <BinObjMgt_SRelocationTable.hxx>
 #endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
 #ifndef _Handle_CDM_MessageDriver_HeaderFile
 #include <Handle_CDM_MessageDriver.hxx>
 #endif
@@ -52,6 +49,9 @@
 #ifndef _Standard_OStream_HeaderFile
 #include <Standard_OStream.hxx>
 #endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
 #ifndef _Handle_Standard_Type_HeaderFile
 #include <Handle_Standard_Type.hxx>
 #endif
@@ -78,8 +78,6 @@ public:
   //! Write <theDocument> to the binary file <theFileName> <br>
   Standard_EXPORT   virtual  void Write(const Handle(CDM_Document)& theDocument,const TCollection_ExtendedString& theFileName) ;
   
-  Standard_EXPORT     Standard_Boolean IsError() const;
-  
   Standard_EXPORT   virtual  Handle_BinMDF_ADriverTable AttributeDrivers(const Handle(CDM_MessageDriver)& theMsgDriver) ;
   //! Create a section that should be written after the OCAF data <br>
   Standard_EXPORT     void AddSection(const TCollection_AsciiString& theName,const Standard_Boolean isPostRead = Standard_True) ;
@@ -103,7 +101,6 @@ protected:
 
 Handle_BinMDF_ADriverTable myDrivers;
 BinObjMgt_SRelocationTable myRelocTable;
-Standard_Boolean myIsError;
 
 
 private: 
diff --git a/inc/BinMDF_TypeADriverMap.hxx b/inc/BinMDF_TypeADriverMap.hxx
index 9cd0206..7cb20b6 100644
--- a/inc/BinMDF_TypeADriverMap.hxx
+++ b/inc/BinMDF_TypeADriverMap.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Type;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Type)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Type)& K) ;
 
 
 
diff --git a/inc/BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors.hxx b/inc/BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors.hxx
index d913d88..9f76e22 100644
--- a/inc/BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors.hxx
+++ b/inc/BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const BooleanOperations_AncestorsSeqAndSuccessorsSeq& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     BooleanOperations_AncestorsSeqAndSuccessorsSeq& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/BooleanOperations_IndexedDataMapOfShapeInteger.hxx b/inc/BooleanOperations_IndexedDataMapOfShapeInteger.hxx
index ff7e5a1..b03de9c 100644
--- a/inc/BooleanOperations_IndexedDataMapOfShapeInteger.hxx
+++ b/inc/BooleanOperations_IndexedDataMapOfShapeInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -94,6 +97,10 @@ public:
   Standard_EXPORT    const Standard_Integer& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     Standard_Integer& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/CDF_Application.hxx b/inc/CDF_Application.hxx
index de87eff..77863eb 100644
--- a/inc/CDF_Application.hxx
+++ b/inc/CDF_Application.hxx
@@ -19,8 +19,8 @@
 #ifndef _TCollection_ExtendedString_HeaderFile
 #include <TCollection_ExtendedString.hxx>
 #endif
-#ifndef _CDF_RetrievableStatus_HeaderFile
-#include <CDF_RetrievableStatus.hxx>
+#ifndef _PCDM_ReaderStatus_HeaderFile
+#include <PCDM_ReaderStatus.hxx>
 #endif
 #ifndef _CDM_Application_HeaderFile
 #include <CDM_Application.hxx>
@@ -113,13 +113,13 @@ public:
 //!             of CDM_MetaData <br>
   Standard_EXPORT     Handle_CDM_Document Retrieve(const TCollection_ExtendedString& aFolder,const TCollection_ExtendedString& aName,const TCollection_ExtendedString& aVersion,const Standard_Boolean UseStorageConfiguration = Standard_True) ;
   
-  Standard_EXPORT     CDF_RetrievableStatus CanRetrieve(const TCollection_ExtendedString& aFolder,const TCollection_ExtendedString& aName) ;
+  Standard_EXPORT     PCDM_ReaderStatus CanRetrieve(const TCollection_ExtendedString& aFolder,const TCollection_ExtendedString& aName) ;
   
-  Standard_EXPORT     CDF_RetrievableStatus CanRetrieve(const TCollection_ExtendedString& aFolder,const TCollection_ExtendedString& aName,const TCollection_ExtendedString& aVersion) ;
+  Standard_EXPORT     PCDM_ReaderStatus CanRetrieve(const TCollection_ExtendedString& aFolder,const TCollection_ExtendedString& aName,const TCollection_ExtendedString& aVersion) ;
   
   Standard_EXPORT   virtual  void Formats(TColStd_SequenceOfExtendedString& Formats)  = 0;
   //! Checks  status  after  Retrieve <br>
-        CDF_RetrievableStatus GetRetrieveStatus() const;
+        PCDM_ReaderStatus GetRetrieveStatus() const;
   
   Standard_EXPORT     Standard_Boolean FindReader(const TCollection_ExtendedString& aFileName) ;
   
@@ -150,7 +150,7 @@ protected:
   
   Standard_EXPORT   CDF_Application();
 
-CDF_RetrievableStatus myRetrievableStatus;
+PCDM_ReaderStatus myRetrievableStatus;
 
 
 private: 
@@ -182,7 +182,7 @@ private:
   
   Standard_EXPORT     CDF_TypeOfActivation TypeOfActivation(const Handle(CDM_MetaData)& aMetaData) ;
   
-  Standard_EXPORT     CDF_RetrievableStatus CanRetrieve(const Handle(CDM_MetaData)& aMetaData) ;
+  Standard_EXPORT     PCDM_ReaderStatus CanRetrieve(const Handle(CDM_MetaData)& aMetaData) ;
 
 TCollection_ExtendedString myDefaultFolder;
 
diff --git a/inc/CDF_Application.lxx b/inc/CDF_Application.lxx
index 88df837..11d8c58 100644
--- a/inc/CDF_Application.lxx
+++ b/inc/CDF_Application.lxx
@@ -10,7 +10,7 @@
 // !       szy ! Creation                                !26-06-2003! 5.0-20-%L%!
 // +---------------------------------------------------------------------------+
 
-inline CDF_RetrievableStatus CDF_Application::GetRetrieveStatus() const {
+inline PCDM_ReaderStatus CDF_Application::GetRetrieveStatus() const {
   return myRetrievableStatus;
 }
 // @@SDM: begin
diff --git a/inc/CDF_RetrievableStatus.hxx b/inc/CDF_RetrievableStatus.hxx
deleted file mode 100644
index 2d3c0df..0000000
--- a/inc/CDF_RetrievableStatus.hxx
+++ /dev/null
@@ -1,38 +0,0 @@
-// This file is generated by WOK (CPPExt).
-// Please do not edit this file; modify original file instead.
-// The copyright and license terms as defined for the original file apply to 
-// this header file considered to be the "object code" form of the original source.
-
-#ifndef _CDF_RetrievableStatus_HeaderFile
-#define _CDF_RetrievableStatus_HeaderFile
-
-
-enum CDF_RetrievableStatus {
-CDF_RS_OK,
-CDF_RS_AlreadyRetrievedAndModified,
-CDF_RS_AlreadyRetrieved,
-CDF_RS_UnknownDocument,
-CDF_RS_NoDriver,
-CDF_RS_UnknownFileDriver,
-CDF_RS_WrongResource,
-CDF_RS_OpenError,
-CDF_RS_NoVersion,
-CDF_RS_NoModel,
-CDF_RS_NoSchema,
-CDF_RS_NoDocument,
-CDF_RS_ExtensionFailure,
-CDF_RS_WrongStreamMode,
-CDF_RS_FormatFailure,
-CDF_RS_TypeFailure,
-CDF_RS_TypeNotFoundInSchema,
-CDF_RS_UnrecognizedFileFormat,
-CDF_RS_MakeFailure,
-CDF_RS_PermissionDenied,
-CDF_RS_DriverFailure
-};
-
-#ifndef _Standard_PrimitiveTypes_HeaderFile
-#include <Standard_PrimitiveTypes.hxx>
-#endif
-
-#endif
diff --git a/inc/CDF_Store.hxx b/inc/CDF_Store.hxx
index 92b6b58..7206333 100644
--- a/inc/CDF_Store.hxx
+++ b/inc/CDF_Store.hxx
@@ -25,8 +25,8 @@
 #ifndef _TCollection_ExtendedString_HeaderFile
 #include <TCollection_ExtendedString.hxx>
 #endif
-#ifndef _CDF_StoreStatus_HeaderFile
-#include <CDF_StoreStatus.hxx>
+#ifndef _PCDM_StoreStatus_HeaderFile
+#include <PCDM_StoreStatus.hxx>
 #endif
 #ifndef _CDF_TryStoreStatus_HeaderFile
 #include <CDF_TryStoreStatus.hxx>
@@ -151,7 +151,7 @@ public:
 //!           thes methods worked correctly, and if not why. <br>
   Standard_EXPORT     void SetMain() ;
   
-  Standard_EXPORT     CDF_StoreStatus StoreStatus() const;
+  Standard_EXPORT     PCDM_StoreStatus StoreStatus() const;
   
   Standard_EXPORT     Standard_ExtString AssociatedStatusText() const;
   //! defines the name under which the document should be stored. <br>
@@ -189,7 +189,7 @@ Standard_Boolean myIsMainDocument;
 TCollection_ExtendedString myLastName;
 TCollection_ExtendedString myPath;
 TCollection_ExtendedString myText;
-CDF_StoreStatus myStatus;
+PCDM_StoreStatus myStatus;
 
 
 };
diff --git a/inc/CDF_StoreList.hxx b/inc/CDF_StoreList.hxx
index b07b61d..eb8e98c 100644
--- a/inc/CDF_StoreList.hxx
+++ b/inc/CDF_StoreList.hxx
@@ -34,8 +34,8 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
-#ifndef _CDF_StoreStatus_HeaderFile
-#include <CDF_StoreStatus.hxx>
+#ifndef _PCDM_StoreStatus_HeaderFile
+#include <PCDM_StoreStatus.hxx>
 #endif
 #ifndef _Handle_CDM_MetaData_HeaderFile
 #include <Handle_CDM_MetaData.hxx>
@@ -57,7 +57,7 @@ public:
   Standard_EXPORT     Standard_Boolean IsConsistent() const;
   //! stores each object of the storelist in the reverse <br>
 //!          order of which they had been added. <br>
-  Standard_EXPORT     CDF_StoreStatus Store(Handle(CDM_MetaData)& aMetaData,TCollection_ExtendedString& aStatusAssociatedText) ;
+  Standard_EXPORT     PCDM_StoreStatus Store(Handle(CDM_MetaData)& aMetaData,TCollection_ExtendedString& aStatusAssociatedText) ;
   
   Standard_EXPORT     void Init() ;
   
diff --git a/inc/CDF_StoreStatus.hxx b/inc/CDF_StoreStatus.hxx
deleted file mode 100644
index 6173124..0000000
--- a/inc/CDF_StoreStatus.hxx
+++ /dev/null
@@ -1,21 +0,0 @@
-// This file is generated by WOK (CPPExt).
-// Please do not edit this file; modify original file instead.
-// The copyright and license terms as defined for the original file apply to 
-// this header file considered to be the "object code" form of the original source.
-
-#ifndef _CDF_StoreStatus_HeaderFile
-#define _CDF_StoreStatus_HeaderFile
-
-
-enum CDF_StoreStatus {
-CDF_SS_OK,
-CDF_SS_DriverFailure,
-CDF_SS_WriteFailure,
-CDF_SS_Failure
-};
-
-#ifndef _Standard_PrimitiveTypes_HeaderFile
-#include <Standard_PrimitiveTypes.hxx>
-#endif
-
-#endif
diff --git a/inc/CDM_MetaDataLookUpTable.hxx b/inc/CDM_MetaDataLookUpTable.hxx
index edad27b..be81e8e 100644
--- a/inc/CDM_MetaDataLookUpTable.hxx
+++ b/inc/CDM_MetaDataLookUpTable.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_ExtendedString;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_ExtendedString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_ExtendedString& K) ;
 
 
 
diff --git a/inc/CDM_PresentationDirectory.hxx b/inc/CDM_PresentationDirectory.hxx
index e986912..d440e02 100644
--- a/inc/CDM_PresentationDirectory.hxx
+++ b/inc/CDM_PresentationDirectory.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_ExtendedString;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_ExtendedString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_ExtendedString& K) ;
 
 
 
diff --git a/inc/ChFiDS_IndexedDataMapOfVertexListOfStripe.hxx b/inc/ChFiDS_IndexedDataMapOfVertexListOfStripe.hxx
index 203e8c9..62b0850 100644
--- a/inc/ChFiDS_IndexedDataMapOfVertexListOfStripe.hxx
+++ b/inc/ChFiDS_IndexedDataMapOfVertexListOfStripe.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const ChFiDS_ListOfStripe& FindFromKey(const TopoDS_Vertex& K) const;
   
   Standard_EXPORT     ChFiDS_ListOfStripe& ChangeFromKey(const TopoDS_Vertex& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Vertex& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Vertex& K) ;
 
 
 
diff --git a/inc/ChFiKPart_RstMap.hxx b/inc/ChFiKPart_RstMap.hxx
index ba5b706..7b94953 100644
--- a/inc/ChFiKPart_RstMap.hxx
+++ b/inc/ChFiKPart_RstMap.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Adaptor2d_HCurve2d;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/DNaming_DataMapOfShapeOfName.hxx b/inc/DNaming_DataMapOfShapeOfName.hxx
index 687cda1..c7722f4 100644
--- a/inc/DNaming_DataMapOfShapeOfName.hxx
+++ b/inc/DNaming_DataMapOfShapeOfName.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/Draft_DataMapOfEdgeEdgeInfo.hxx b/inc/Draft_DataMapOfEdgeEdgeInfo.hxx
index 5656b73..d16a6bb 100644
--- a/inc/Draft_DataMapOfEdgeEdgeInfo.hxx
+++ b/inc/Draft_DataMapOfEdgeEdgeInfo.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Edge;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Edge& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Edge& K) ;
 
 
 
diff --git a/inc/Draft_DataMapOfFaceFaceInfo.hxx b/inc/Draft_DataMapOfFaceFaceInfo.hxx
index 88f5823..d0cc3fe 100644
--- a/inc/Draft_DataMapOfFaceFaceInfo.hxx
+++ b/inc/Draft_DataMapOfFaceFaceInfo.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Face;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Face& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Face& K) ;
 
 
 
diff --git a/inc/Draft_DataMapOfVertexVertexInfo.hxx b/inc/Draft_DataMapOfVertexVertexInfo.hxx
index f9132ba..2f6b22e 100644
--- a/inc/Draft_DataMapOfVertexVertexInfo.hxx
+++ b/inc/Draft_DataMapOfVertexVertexInfo.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Vertex;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Vertex& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Vertex& K) ;
 
 
 
diff --git a/inc/Draw_MapOfFunctions.hxx b/inc/Draw_MapOfFunctions.hxx
index faf87bb..d07cc6c 100644
--- a/inc/Draw_MapOfFunctions.hxx
+++ b/inc/Draw_MapOfFunctions.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -86,6 +89,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/Draw_VMap.hxx b/inc/Draw_VMap.hxx
index df3571e..7b0126f 100644
--- a/inc/Draw_VMap.hxx
+++ b/inc/Draw_VMap.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Draw_Drawable3D;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/GCPnts_TangentialDeflection.gxx b/inc/GCPnts_TangentialDeflection.gxx
index d519140..ebfb5e2 100644
--- a/inc/GCPnts_TangentialDeflection.gxx
+++ b/inc/GCPnts_TangentialDeflection.gxx
@@ -1,7 +1,7 @@
-// File:	GCPnts_TangentialDeflection.gxx
-// Created:	Fri Nov  8 11:26:11 1996
-// Author:	Jean Claude VAUTHIER
-//		<jcv at brunox.paris1.matra-dtv.fr>
+// File:    GCPnts_TangentialDeflection.gxx
+// Created: Fri Nov  8 11:26:11 1996
+// Author:  Jean Claude VAUTHIER
+//    <jcv at brunox.paris1.matra-dtv.fr>
 
 #include <GCPnts_DeflectionType.hxx>
 #include <Standard_ConstructionError.hxx>
@@ -16,9 +16,9 @@
 void GCPnts_TangentialDeflection::EvaluateDu (
   const TheCurve& C,
   const Standard_Real      U,
-	gp_Pnt&   P,
-	Standard_Real&     Du,
-	Standard_Boolean&  NotDone) const {
+  gp_Pnt&   P,
+  Standard_Real&     Du,
+  Standard_Boolean&  NotDone) const {
 
   gp_Vec T, N;
   D2 (C, U, P, T, N);
@@ -26,8 +26,9 @@ void GCPnts_TangentialDeflection::EvaluateDu (
   Standard_Real LTol = Precision::Confusion ();
   if (Lt > LTol && N.Magnitude () > LTol) {
     Standard_Real Lc = N.CrossMagnitude (T);
-    if (Lc/Lt > LTol) {
-      Du = sqrt (8.0 * curvatureDeflection * Lt / Lc);
+    Standard_Real Ln = Lc/Lt;
+    if (Ln > LTol) {
+      Du = sqrt (8.0 * curvatureDeflection / Ln);
       NotDone = Standard_False;
     }
   }
@@ -67,12 +68,12 @@ GCPnts_TangentialDeflection::GCPnts_TangentialDeflection (
 
 { 
   Initialize (C, 
-	      FirstParameter, 
-	      LastParameter,
-	      AngularDeflection, 
-	      CurvatureDeflection, 
-	      MinimumOfPoints,
-	      UTol);
+        FirstParameter, 
+        LastParameter,
+        AngularDeflection, 
+        CurvatureDeflection, 
+        MinimumOfPoints,
+        UTol);
 }
 
 
@@ -95,8 +96,8 @@ void GCPnts_TangentialDeflection::Initialize (
               C.LastParameter (),
               AngularDeflection, 
               CurvatureDeflection,
-	      MinimumOfPoints,
-	      UTol);
+              MinimumOfPoints,
+              UTol);
 }
 
 
@@ -147,14 +148,14 @@ void GCPnts_TangentialDeflection::Initialize (
    {
      Handle_TheBSplineCurve BS = C.BSpline() ;
      if (BS->NbPoles() == 2 ) PerformLinear (C);
-     else     	              PerformCurve  (C);
+     else                     PerformCurve  (C);
      break;
    }
  case GeomAbs_BezierCurve:
    {
      Handle_TheBezierCurve  BZ = C.Bezier(); 
      if (BZ->NbPoles() == 2) PerformLinear (C);
-     else        	     PerformCurve  (C);
+     else                    PerformCurve  (C);
      break;
    }
  default: PerformCurve (C);
@@ -233,22 +234,17 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
 
 {
   Standard_Integer i;       
-  Standard_Boolean Correction, TooLarge, TooSmall, MorePoints;
   gp_XYZ V1, V2;
-//  gp_Pnt MiddlePoint, CurrentPoint, LastPoint, PreviousPoint;   
   gp_Pnt MiddlePoint, CurrentPoint, LastPoint;   
-  Standard_Real Coef = 0.0, ACoef = 0.0, FCoef = 0.0, Du = 0.0, Dusave = 0.0, MiddleU = 0.0, L1 = 0.0, L2 = 0.0;
+  Standard_Real Du, Dusave, MiddleU = 0.0, L1 = 0.0, L2 = 0.0;
 
   Standard_Real U1       = firstu;   
-  Standard_Real U2       = firstu;   
-  Standard_Real AngleMax = angularDeflection * 0.5;  //car on prend le point milieu
   Standard_Real LTol     = Precision::Confusion ();  //protection longueur nulle
   Standard_Real ATol     = Precision::Angular ();    //protection angle nul
 
   D0 (C, lastu, LastPoint);
 
   //Initialization du calcul
-  //---------------------------------------------------------------------
 
   Standard_Boolean NotDone = Standard_True;
   Dusave = (lastu - firstu)*Us3;
@@ -270,38 +266,38 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
       Du = (lastu-firstu)/NbPoints;
       MiddleU = firstu + Du;
       for (i = 2; i < NbPoints; i++) {
-	D0 (C, MiddleU, MiddlePoint);
-	V2 = MiddlePoint.XYZ();
-	V2.Subtract (CurrentPoint.XYZ());
-	L2 = V2.Modulus ();
-	if (L2 > LTol) {
-	  if (((V2.CrossMagnitude (V1))/(L1*L2)) >= ATol) {
-	    //C'etait une singularite
-	    IsLine = Standard_False;
-	    break;
-	  }
-	  if (minNbPnts > 2) {
-	    parameters.Append (MiddleU);
-	    points    .Append (MiddlePoint);
-	  }
-	}
-	MiddleU += Du;
+        D0 (C, MiddleU, MiddlePoint);
+        V2 = MiddlePoint.XYZ();
+        V2.Subtract (CurrentPoint.XYZ());
+        L2 = V2.Modulus ();
+        if (L2 > LTol) {
+          if (((V2.CrossMagnitude (V1))/(L1*L2)) >= ATol) {
+            //C'etait une singularite
+            IsLine = Standard_False;
+            break;
+          }
+          if (minNbPnts > 2) {
+            parameters.Append (MiddleU);
+            points    .Append (MiddlePoint);
+          }
+        }
+        MiddleU += Du;
       }
       if (IsLine) {
-	//C'etait une droite (plusieurs poles alignes), Calcul termine :
-	parameters.Append (lastu);
-	points    .Append (LastPoint);
-	return;
+        //C'etait une droite (plusieurs poles alignes), Calcul termine :
+        parameters.Append (lastu);
+        points    .Append (LastPoint);
+        return;
       }
       else {
-	//c'etait une singularite on continue :
-	Standard_Integer pointsLength=points.Length ();
-	for (i = 2; i <= pointsLength; i++) {
-	  points    .Remove (i);
-	  parameters.Remove (i);
-	  pointsLength--;
-	}
-	Du = (lastu-firstu)*Us3;
+        //c'etait une singularite on continue :
+        Standard_Integer pointsLength=points.Length ();
+        for (i = 2; i <= pointsLength; i++) {
+          points    .Remove (i);
+          parameters.Remove (i);
+          pointsLength--;
+        }
+        Du = Dusave;
       }
     }
     else  {
@@ -313,11 +309,11 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
       V1.Subtract (CurrentPoint.XYZ());
       L1 = V1.Modulus ();
       if (L1 < LTol) {
-	// L1 < LTol C'est une courbe de longueur nulle, calcul termine :
-	// on renvoi un segment de 2 points   (protection)
-	parameters.Append (lastu);
-	points    .Append (LastPoint);
-	return;
+        // L1 < LTol C'est une courbe de longueur nulle, calcul termine :
+        // on renvoi un segment de 2 points   (protection)
+        parameters.Append (lastu);
+        points    .Append (LastPoint);
+        return;
       }
     }
   }
@@ -335,8 +331,11 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
   }
 
   //Traitement normal pour une courbe
-  //-------------------------------------------------------------------
-  MorePoints = Standard_True;
+  Standard_Boolean MorePoints = Standard_True;
+  Standard_Real U2            = firstu;   
+  Standard_Real AngleMax      = angularDeflection * 0.5;  //car on prend le point milieu
+
+  gp_Pnt aPrevPoint = points.Last();
 
   while (MorePoints) {
 
@@ -350,18 +349,22 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
     }
     else D0 (C, U2, CurrentPoint);           //Point suivant
 
+    Standard_Real Coef, ACoef, FCoef;
+    Standard_Boolean Correction, TooLarge, TooSmall;
     TooLarge   = Standard_False;
     TooSmall   = Standard_False;
     Correction = Standard_True;
+
+    Standard_Real lastCoef = 0;
      
     while (Correction) {                     //Ajustement Du
       MiddleU = (U1+U2)*0.5;                 //Verif / au point milieu
       D0 (C, MiddleU, MiddlePoint);
 
       V1 = CurrentPoint.XYZ ();              //Critere de fleche
-      V1.Subtract (points.Last().XYZ());
+      V1.Subtract (aPrevPoint.XYZ());
       V2 = MiddlePoint.XYZ ();
-      V2.Subtract (points.Last().XYZ());
+      V2.Subtract (aPrevPoint.XYZ());
       L1 = V1.Modulus ();
       if (L1 > LTol) FCoef = V1.CrossMagnitude(V2)/(L1*curvatureDeflection);
       else           FCoef = 0.0;
@@ -378,48 +381,54 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
       else                Coef = FCoef;
 
 
-      if (Coef <= 1.0) {                     
-	if (Abs (lastu-U2) < uTol) {
+      if (Coef <= 1.0) {
+        if (Abs (lastu-U2) < uTol) {
           parameters.Append (lastu);
-	  points    .Append (LastPoint);
-	  MorePoints = Standard_False;
-	  Correction = Standard_False;
-	}
-	else {
-	  if (Coef >= 0.75 || TooLarge || TooSmall) { 
-	    parameters.Append (U2);
-	    points    .Append (CurrentPoint);
-	    Correction = Standard_False;
-	  }
-	  else {
-	    TooSmall = Standard_True;
-	    Standard_Real UUU2 = U2;
-	    Du += Min((U2-U1)*(1.-Coef), Du*Us3);
-
-	    U2 = U1 + Du;
-	    if (U2 >= lastu) U2 = UUU2;
-	    if (U2 >= lastu) {
-	      parameters.Append (lastu);
-	      points    .Append (LastPoint);
-	      MorePoints = Standard_False;
-	      Correction = Standard_False;
-	    }
-	    else D0 (C, U2, CurrentPoint);
-	  }
-	}
+          points    .Append (LastPoint);
+          MorePoints = Standard_False;
+          Correction = Standard_False;
+        }
+        else {
+          if (Coef >= 0.55 || TooLarge) { 
+            parameters.Append (U2);
+            points    .Append (CurrentPoint);
+            aPrevPoint = CurrentPoint;
+            Correction = Standard_False;
+          }
+          else if (TooSmall) {
+            Correction = Standard_False;
+            aPrevPoint = CurrentPoint;
+          }
+          else {
+            TooSmall = Standard_True;
+            lastCoef = Coef;
+            //Standard_Real UUU2 = U2;
+            Du += Min((U2-U1)*(1.-Coef), Du*Us3);
+
+            U2 = U1 + Du;
+            //if (U2 >= lastu) U2 = UUU2;
+            if (U2 >= lastu) {
+              parameters.Append (lastu);
+              points    .Append (LastPoint);
+              MorePoints = Standard_False;
+              Correction = Standard_False;
+            }
+            else D0 (C, U2, CurrentPoint);
+          }
+        }
       }
       else {
 
-	if (Coef >= 1.5) {
-	  U2 = MiddleU;
-	  CurrentPoint = MiddlePoint;
-	}
-	else {
-	  Du*=0.9;
-	  U2 = U1 + Du;
-	  D0 (C, U2, CurrentPoint);
-	  TooLarge = Standard_True;
-	}
+        if (Coef >= 1.5) {
+          U2 = MiddleU;
+          CurrentPoint = MiddlePoint;
+        }
+        else {
+          Du*=0.9;
+          U2 = U1 + Du;
+          D0 (C, U2, CurrentPoint);
+          TooLarge = Standard_True;
+        }
 
       }
     }
@@ -428,37 +437,37 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
 
     if (MorePoints) {
       if (U1 > firstu) {
-	if (FCoef > ACoef) {
-	  //La fleche est critere de decoupage
-	  EvaluateDu (C, U2, CurrentPoint, Du, NotDone);
-	  if (NotDone) {
-	    Du += (Du-Dusave)*(Du/Dusave);
-	    if (Du > 1.5 * Dusave) Du = 1.5  * Dusave;
-	    if (Du < 0.75* Dusave) Du = 0.75 * Dusave;
-	  }
-	}
-	else {
-	  //L'angle est le critere de decoupage
-	  Du += (Du-Dusave)*(Du/Dusave);
-	  if (Du > 1.5 * Dusave) Du = 1.5  * Dusave;
-	  if (Du < 0.75* Dusave) Du = 0.75 * Dusave;
-	}
+        if (FCoef > ACoef) {
+          //La fleche est critere de decoupage
+          EvaluateDu (C, U2, CurrentPoint, Du, NotDone);
+          if (NotDone) {
+            Du += (Du-Dusave)*(Du/Dusave);
+            if (Du > 1.5 * Dusave) Du = 1.5  * Dusave;
+            if (Du < 0.75* Dusave) Du = 0.75 * Dusave;
+          }
+        }
+        else {
+          //L'angle est le critere de decoupage
+          Du += (Du-Dusave)*(Du/Dusave);
+          if (Du > 1.5 * Dusave) Du = 1.5  * Dusave;
+          if (Du < 0.75* Dusave) Du = 0.75 * Dusave;
+        }
       }
       
       if (Du < uTol) {
-	Du = lastu - U2;
-	if (Du < uTol) {
-	  parameters.Append (lastu);
-	  points    .Append (LastPoint);
-	  MorePoints = Standard_False;
-	}
-	else if (Du*Us3 > uTol) Du*=Us3;
+        Du = lastu - U2;
+        if (Du < uTol) {
+          parameters.Append (lastu);
+          points    .Append (LastPoint);
+          MorePoints = Standard_False;
+        }
+        else if (Du*Us3 > uTol) Du*=Us3;
       }
       U1 = U2;
       Dusave = Du;
     }
   }
-                              //Recalage avant dernier point :
+  //Recalage avant dernier point :
   i = points.Length()-1;
 //  Real d = points (i).Distance (points (i+1));
 // if (Abs(parameters (i) - parameters (i+1))<= 0.000001 || d < Precision::Confusion()) {
@@ -476,13 +485,12 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
     points    .SetValue (i, MiddlePoint);
   }
 
-  //-- ------------------------------------------------------------
   //-- On rajoute des points aux milieux des segments si le nombre
   //-- mini de points n'est pas atteint
   //--
   Standard_Integer Nbp =  points.Length();
   Standard_Integer MinNb= (9*minNbPnts)/10;
-  if(MinNb<3) MinNb=3;
+  //if(MinNb<4) MinNb=4;
 
   //-- if(Nbp <  MinNb) { cout<<"\n*"; } else {  cout<<"\n."; } 
   while(Nbp < MinNb) { 
@@ -497,8 +505,3 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
     }
   }
 }
-
-
-
-
-
diff --git a/inc/Geom2dHatch_HatchingsOfHatcher.hxx b/inc/Geom2dHatch_HatchingsOfHatcher.hxx
index 707ca36..2199aab 100644
--- a/inc/Geom2dHatch_HatchingsOfHatcher.hxx
+++ b/inc/Geom2dHatch_HatchingsOfHatcher.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Geom2dHatch_HatchingOfHatcher;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/Geom2dHatch_MapOfElementsOfElementsOfHatcher.hxx b/inc/Geom2dHatch_MapOfElementsOfElementsOfHatcher.hxx
index 7138665..04e6449 100644
--- a/inc/Geom2dHatch_MapOfElementsOfElementsOfHatcher.hxx
+++ b/inc/Geom2dHatch_MapOfElementsOfElementsOfHatcher.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Geom2dHatch_ElementOfHatcher;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/GeometryTest.hxx b/inc/GeometryTest.hxx
index 78909a6..ed5f7b3 100644
--- a/inc/GeometryTest.hxx
+++ b/inc/GeometryTest.hxx
@@ -62,6 +62,8 @@ public:
   //! defines     command  to    test  the    polyhedral <br>
 //!          triangulations and the polygons from the Poly package. <br>
   Standard_EXPORT   static  void PolyCommands(Draw_Interpretor& I) ;
+  //! defines commands to test projection of geometric objects <br>
+  Standard_EXPORT   static  void TestProjCommands(Draw_Interpretor& I) ;
 
 
 
diff --git a/inc/GraphDS_EntityRoleMap.hxx b/inc/GraphDS_EntityRoleMap.hxx
index 63015bc..1c92ad1 100644
--- a/inc/GraphDS_EntityRoleMap.hxx
+++ b/inc/GraphDS_EntityRoleMap.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Transient;
@@ -90,6 +93,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Transient)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Transient)& K) ;
 
 
 
diff --git a/inc/Graphic3d_CGraduatedTrihedron.hxx b/inc/Graphic3d_CGraduatedTrihedron.hxx
index 5332137..489feb2 100644
--- a/inc/Graphic3d_CGraduatedTrihedron.hxx
+++ b/inc/Graphic3d_CGraduatedTrihedron.hxx
@@ -1,22 +1,70 @@
-/*============================================================================*/
-/*==== Titre: Graphic3d_CGraduatedTrihedron.hxx			              */
-/*==== Role : The header file of primitive type "CGraduatedTrihedron" from Graphic3d */
-/*====									      */
-/*==== Implementation:  This is a primitive type implemented with typedef     */
-/*============================================================================*/
+// File:      Graphic3d_CGraduatedTrihedron.hxx
+// Created:   6 March 2011
+// Author:    Sergey ZERCHANINOV
+// Copyright: OPEN CASCADE SA 2011
 
 #ifndef _Graphic3d_CGraduatedTrihedron_HeaderFile
 #define _Graphic3d_CGraduatedTrihedron_HeaderFile
 
-#include <InterfaceGraphic_Graphic3d.hxx>
-#include <InterfaceGraphic_Visual3d.hxx>
-typedef CALL_DEF_GRADUATEDTRIHEDRON Graphic3d_CGraduatedTrihedron;
-
-#if defined(__cplusplus) || defined(c_plusplus)
-/*==== Definition de Type ====================================================*/
+#include <Standard_Boolean.hxx>
+#include <Standard_Integer.hxx>
 #include <Standard_Type.hxx>
+#include <Quantity_Color.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <OSD_FontAspect.hxx>
+
+typedef void (*minMaxValuesCallback)(void*);
+class Graphic3d_CGraduatedTrihedron
+{
+  public:
+    /* Default constructor. Nullifies the view pointer */
+    Graphic3d_CGraduatedTrihedron () : ptrVisual3dView(NULL) {}
+
+    /* Names of axes */
+    TCollection_ExtendedString xname, yname, zname;
+    /* Draw names */
+    Standard_Boolean xdrawname, ydrawname, zdrawname;
+    /* Draw values */
+    Standard_Boolean xdrawvalues, ydrawvalues, zdrawvalues;
+    /* Draw grid */
+    Standard_Boolean drawgrid;
+    /* Draw axes */
+    Standard_Boolean drawaxes;
+    /* Number of splits along axes */
+    Standard_Integer nbx, nby, nbz;
+    /* Offset for drawing values */
+    Standard_Integer xoffset, yoffset, zoffset;
+    /* Offset for drawing names of axes */
+    Standard_Integer xaxisoffset, yaxisoffset, zaxisoffset;
+    /* Draw tickmarks */
+    Standard_Boolean xdrawtickmarks, ydrawtickmarks, zdrawtickmarks;
+    /* Length of tickmarks */
+    Standard_Integer xtickmarklength, ytickmarklength, ztickmarklength;
+    /* Grid color */
+    Quantity_Color gridcolor;
+    /* Colors of axis names */
+    Quantity_Color xnamecolor, ynamecolor, znamecolor;
+    /* Colors of axis and values */
+    Quantity_Color xcolor, ycolor, zcolor;
+    /* Font name of names of axes: Courier, Arial, ... */
+    TCollection_AsciiString fontOfNames;
+    /* Style of names of axes: OSD_FA_Regular, OSD_FA_Bold, ... */
+    OSD_FontAspect styleOfNames;
+    /* Size of names of axes: 8, 10, 12, 14, ... */
+    Standard_Integer sizeOfNames;
+    /* Font name of values: Courier, Arial, ... */
+    TCollection_AsciiString fontOfValues;
+    /* Style of values: OSD_FA_Regular, OSD_FA_Bold, ... */
+    OSD_FontAspect styleOfValues;
+    /* Size of values: 8, 10, 12, 14, ... */
+    Standard_Integer sizeOfValues;
+
+    /* Callback function to define boundary box of displayed objects */
+    minMaxValuesCallback cbCubicAxes;
+    void* ptrVisual3dView;
+};
+
 const Handle(Standard_Type)& TYPE(Graphic3d_CGraduatedTrihedron);
-/*============================================================================*/
 
-#endif
 #endif /*Graphic3d_CGraduatedTrihedron_HeaderFile*/
diff --git a/inc/Graphic3d_GraphicDriver.hxx b/inc/Graphic3d_GraphicDriver.hxx
index e283fcc..b6ccf32 100644
--- a/inc/Graphic3d_GraphicDriver.hxx
+++ b/inc/Graphic3d_GraphicDriver.hxx
@@ -97,9 +97,6 @@
 #ifndef _Aspect_TypeOfTriedronEcho_HeaderFile
 #include <Aspect_TypeOfTriedronEcho.hxx>
 #endif
-#ifndef _OSD_FontAspect_HeaderFile
-#include <OSD_FontAspect.hxx>
-#endif
 #ifndef _Graphic3d_CGraduatedTrihedron_HeaderFile
 #include <Graphic3d_CGraduatedTrihedron.hxx>
 #endif
@@ -130,6 +127,9 @@
 #ifndef _Aspect_Handle_HeaderFile
 #include <Aspect_Handle.hxx>
 #endif
+#ifndef _Aspect_PrintAlgo_HeaderFile
+#include <Aspect_PrintAlgo.hxx>
+#endif
 #ifndef _Graphic3d_ExportFormat_HeaderFile
 #include <Graphic3d_ExportFormat.hxx>
 #endif
@@ -386,10 +386,8 @@ public:
   Standard_EXPORT   virtual  void TriedronErase(const Graphic3d_CView& ACView)  = 0;
   //! call_togl_triedron_echo <br>
   Standard_EXPORT   virtual  void TriedronEcho(const Graphic3d_CView& ACView,const Aspect_TypeOfTriedronEcho AType = Aspect_TOTE_NONE)  = 0;
-  //! call_togl_graduatedtrihedron_get <br>
-  Standard_EXPORT   virtual  void GetGraduatedTrihedron(const Graphic3d_CView& view,Standard_CString& xname,Standard_CString& yname,Standard_CString& zname,Standard_Boolean& xdrawname,Standard_Boolean& ydrawname,Standard_Boolean& zdrawname,Standard_Boolean& xdrawvalues,Standard_Boolean& ydrawvalues,Standard_Boolean& zdrawvalues,Standard_Boolean& drawgrid,Standard_Boolean& drawaxes,Standard_Integer& nbx,Standard_Integer& nby,Standard_Integer& nbz,Standard_Integer& xoffset,Standard_Integer& yoffset,Standard_Integer& zoffset,Standard_Integer& xaxisoffset,Standard_Integer& yaxisoffset,Standard_Integer& zaxisoffset,Standard_Boolean& xdrawtickmarks,Standard_Boolean& ydrawtickmarks,Standard_Boolean& zdrawtickmarks,Standard_Integer& xtickmarklength,Standard_Integer& ytickmarklength,Standard_Integer& ztickmarklength,Quantity_Color& gridcolor,Quantity_Color& xnamecolor,Quantity_Color& ynamecolor,Quantity_Color& znamecolor,Quantity_Color& xcolor,Quantity_Color& ycolor,Quantity_Color& zcolor,Standard_CString& fontOfNames,OSD_FontAspect& styleOfNames,Standard_Integer& sizeOfNames,Standard_CString& fontOfValues,OSD_FontAspect& styleOfValues,Standard_Integer& sizeOfValues) const;
   //! call_togl_graduatedtrihedron_display <br>
-  Standard_EXPORT   virtual  void GraduatedTrihedronDisplay(const Graphic3d_CView& view,Graphic3d_CGraduatedTrihedron& cubic,const Standard_CString xname,const Standard_CString yname,const Standard_CString zname,const Standard_Boolean xdrawname,const Standard_Boolean ydrawname,const Standard_Boolean zdrawname,const Standard_Boolean xdrawvalues,const Standard_Boolean ydrawvalues,const Standard_Boolean zdrawvalues,const Standard_Boolean drawgrid,const Standard_Boolean drawaxes,const Standard_Integer nbx,const Standard_Integer nby,const Standard_Integer nbz,const Standard_Integer xoffset,const Standard_Integer yoffset,const Standard_Integer zoffset,const Standard_Integer xaxisoffset,const Standard_Integer yaxisoffset,const Standard_Integer zaxisoffset,const Standard_Boolean xdrawtickmarks,const Standard_Boolean ydrawtickmarks,const Standard_Boolean zdrawtickmarks,const Standard_Integer xtickmarklength,const Standard_Integer ytickmarklength,const Standard_Integer ztickmarklength,const Quantity_Color& gridcolor,const Quantity_Color& xnamecolor,const Quantity_Color& ynamecolor,const Quantity_Color& znamecolor,const Quantity_Color& xcolor,const Quantity_Color& ycolor,const Quantity_Color& zcolor,const Standard_CString fontOfNames,const OSD_FontAspect styleOfNames,const Standard_Integer sizeOfNames,const Standard_CString fontOfValues,const OSD_FontAspect styleOfValues,const Standard_Integer sizeOfValues)  = 0;
+  Standard_EXPORT   virtual  void GraduatedTrihedronDisplay(const Graphic3d_CView& view,const Graphic3d_CGraduatedTrihedron& cubic)  = 0;
   //! call_togl_graduatedtrihedron_erase <br>
   Standard_EXPORT   virtual  void GraduatedTrihedronErase(const Graphic3d_CView& view)  = 0;
   //! call_togl_graduatedtrihedron_minmaxvalues <br>
@@ -511,9 +509,21 @@ public:
 //! (background is white) <br>
 //! else set to TRUE for printing with current background color. <br>
 //! <filename>: If != NULL, then the view will be printed to a file. <br>
-  Standard_EXPORT   virtual  void Print(const Graphic3d_CView& ACView,const Aspect_CLayer2d& ACUnderLayer,const Aspect_CLayer2d& ACOverLayer,const Aspect_Handle hPrnDC,const Standard_Boolean showBackground,const Standard_CString filename) const = 0;
+//! <printAlgorithm>: Select print algorithm: stretch, tile. <br>
+//! <theScaleFactor>: Scaling coefficient, used internally to scale the <br>
+//! printings accordingly to the scale factor selected in the printer <br>
+//! properties dialog. <br>
+//! Returns Standard_True if the data is passed to the printer, otherwise <br>
+//! Standard_False if the print operation failed due to the printer errors, <br>
+//! or insufficient system memory available. <br>
+  Standard_EXPORT   virtual  Standard_Boolean Print(const Graphic3d_CView& ACView,const Aspect_CLayer2d& ACUnderLayer,const Aspect_CLayer2d& ACOverLayer,const Aspect_Handle hPrnDC,const Standard_Boolean showBackground,const Standard_CString filename,const Aspect_PrintAlgo printAlgorithm = Aspect_PA_STRETCH,const Standard_Real theScaleFactor = 1.0) const = 0;
   
   Standard_EXPORT   virtual  void Export(const Standard_CString FileName,const Graphic3d_ExportFormat Format,const Graphic3d_SortType SortType,const Standard_Integer W,const Standard_Integer H,const Graphic3d_CView& View,const Aspect_CLayer2d& Under,const Aspect_CLayer2d& Over,const Standard_Real Precision = 0.005,const Standard_Address ProgressBarFunc = NULL,const Standard_Address ProgressObject = NULL)  = 0;
+  //! Clear visualization data in graphical driver and <br>
+//! stop displaying the primitives array of the graphical group <br>
+//! <theCGroup>. This method is internal and should be used <br>
+//! by Graphic3d_Group only. <br>
+  Standard_EXPORT   virtual  void RemovePrimitiveArray(const Graphic3d_CGroup& theCGroup,const Graphic3d_PrimitiveArray& thePArray)  = 0;
   //! call_togl_light <br>
   Standard_EXPORT   static  Standard_Integer Light(const Graphic3d_CLight& ACLight,const Standard_Boolean Update) ;
   //! call_togl_plane <br>
diff --git a/inc/Graphic3d_Group.hxx b/inc/Graphic3d_Group.hxx
index 4750793..5e656f5 100644
--- a/inc/Graphic3d_Group.hxx
+++ b/inc/Graphic3d_Group.hxx
@@ -55,6 +55,9 @@
 #ifndef _Handle_Graphic3d_Structure_HeaderFile
 #include <Handle_Graphic3d_Structure.hxx>
 #endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
 #ifndef _Handle_Graphic3d_AspectLine3d_HeaderFile
 #include <Handle_Graphic3d_AspectLine3d.hxx>
 #endif
@@ -70,9 +73,6 @@
 #ifndef _Standard_Real_HeaderFile
 #include <Standard_Real.hxx>
 #endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
 #ifndef _Graphic3d_TypeOfPolygon_HeaderFile
 #include <Graphic3d_TypeOfPolygon.hxx>
 #endif
@@ -136,7 +136,13 @@ public:
   //! Creates a group in the structure <AStructure>. <br>
   Standard_EXPORT   Graphic3d_Group(const Handle(Graphic3d_Structure)& AStructure);
   //! Supress all primitives and attributes of <me>. <br>
-  Standard_EXPORT     void Clear() ;
+//!          To clear group without update in Graphic3d_StructureManager <br>
+//!          pass Standard_False as <theUpdateStructureMgr>. This <br>
+//!          used on context and viewer destruction, when the pointer <br>
+//!          to structure manager in Graphic3d_Structure could be <br>
+//!          already released (pointers are used here to avoid handle <br>
+//!          cross-reference); <br>
+  Standard_EXPORT     void Clear(const Standard_Boolean theUpdateStructureMgr = Standard_True) ;
   //! Supress the group <me> in the structure. <br>
   Standard_EXPORT     void Destroy() ;
 ~Graphic3d_Group()
diff --git a/inc/HLRTopoBRep_DataMapOfShapeFaceData.hxx b/inc/HLRTopoBRep_DataMapOfShapeFaceData.hxx
index ad20013..5b05405 100644
--- a/inc/HLRTopoBRep_DataMapOfShapeFaceData.hxx
+++ b/inc/HLRTopoBRep_DataMapOfShapeFaceData.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/HLRTopoBRep_MapOfShapeListOfVData.hxx b/inc/HLRTopoBRep_MapOfShapeListOfVData.hxx
index 5fbafb8..38d3e38 100644
--- a/inc/HLRTopoBRep_MapOfShapeListOfVData.hxx
+++ b/inc/HLRTopoBRep_MapOfShapeListOfVData.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx b/inc/Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx
new file mode 100644
index 0000000..04d6c22
--- /dev/null
+++ b/inc/Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger.hxx
@@ -0,0 +1,27 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#ifndef _Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_HeaderFile
+#define _Handle_BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger_HeaderFile
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_DefineHandle_HeaderFile
+#include <Standard_DefineHandle.hxx>
+#endif
+
+#ifndef _Handle_TCollection_MapNode_HeaderFile
+#include <Handle_TCollection_MapNode.hxx>
+#endif
+
+class Standard_Transient;
+class Handle(Standard_Type);
+class Handle(TCollection_MapNode);
+class BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger;
+
+DEFINE_STANDARD_HANDLE(BRepMesh_DataMapNodeOfDataMapOfIntegerListOfInteger,TCollection_MapNode)
+
+#endif
diff --git a/inc/Handle_BRepMesh_DiscretRoot.hxx b/inc/Handle_BRepMesh_DiscretRoot.hxx
new file mode 100644
index 0000000..723dba8
--- /dev/null
+++ b/inc/Handle_BRepMesh_DiscretRoot.hxx
@@ -0,0 +1,27 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#ifndef _Handle_BRepMesh_DiscretRoot_HeaderFile
+#define _Handle_BRepMesh_DiscretRoot_HeaderFile
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_DefineHandle_HeaderFile
+#include <Standard_DefineHandle.hxx>
+#endif
+
+#ifndef _Handle_Standard_Transient_HeaderFile
+#include <Handle_Standard_Transient.hxx>
+#endif
+
+class Standard_Transient;
+class Handle(Standard_Type);
+class Handle(Standard_Transient);
+class BRepMesh_DiscretRoot;
+
+DEFINE_STANDARD_HANDLE(BRepMesh_DiscretRoot,Standard_Transient)
+
+#endif
diff --git a/inc/Handle_BRepMesh_IncrementalMesh.hxx b/inc/Handle_BRepMesh_IncrementalMesh.hxx
new file mode 100644
index 0000000..c233b7e
--- /dev/null
+++ b/inc/Handle_BRepMesh_IncrementalMesh.hxx
@@ -0,0 +1,27 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#ifndef _Handle_BRepMesh_IncrementalMesh_HeaderFile
+#define _Handle_BRepMesh_IncrementalMesh_HeaderFile
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_DefineHandle_HeaderFile
+#include <Standard_DefineHandle.hxx>
+#endif
+
+#ifndef _Handle_BRepMesh_DiscretRoot_HeaderFile
+#include <Handle_BRepMesh_DiscretRoot.hxx>
+#endif
+
+class Standard_Transient;
+class Handle(Standard_Type);
+class Handle(BRepMesh_DiscretRoot);
+class BRepMesh_IncrementalMesh;
+
+DEFINE_STANDARD_HANDLE(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot)
+
+#endif
diff --git a/inc/Image_ColorPixelDataMap.hxx b/inc/Image_ColorPixelDataMap.hxx
index dd15c1d..10b151d 100644
--- a/inc/Image_ColorPixelDataMap.hxx
+++ b/inc/Image_ColorPixelDataMap.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Aspect_ColorPixel;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Aspect_ColorPixel& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Aspect_ColorPixel& K) ;
 
 
 
diff --git a/inc/Image_LookupTable.hxx b/inc/Image_LookupTable.hxx
index fcc7544..d4c92e2 100644
--- a/inc/Image_LookupTable.hxx
+++ b/inc/Image_LookupTable.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Aspect_IndexPixel;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Aspect_IndexPixel& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Aspect_IndexPixel& K) ;
 
 
 
diff --git a/inc/IntPatch_ImpImpIntersection_1.gxx b/inc/IntPatch_ImpImpIntersection_1.gxx
index bcf3d2c..ae67ca8 100644
--- a/inc/IntPatch_ImpImpIntersection_1.gxx
+++ b/inc/IntPatch_ImpImpIntersection_1.gxx
@@ -21,6 +21,9 @@ static Standard_Boolean IntPCy (const IntSurf_Quadric&,
 
 static Standard_Boolean IntPSp (const IntSurf_Quadric&,
 				const IntSurf_Quadric&,
+				//modified by NIZNHY-PKV Tue Sep 20 08:59:56 2011t
+				const Standard_Real,
+				//modified by NIZNHY-PKV Tue Sep 20 08:59:52 2011t
 				const Standard_Real,
 				const Standard_Boolean,
 				Standard_Boolean&,
diff --git a/inc/IntPatch_ImpImpIntersection_2.gxx b/inc/IntPatch_ImpImpIntersection_2.gxx
index ce97f70..e414882 100644
--- a/inc/IntPatch_ImpImpIntersection_2.gxx
+++ b/inc/IntPatch_ImpImpIntersection_2.gxx
@@ -3,11 +3,18 @@
 // Author:    Jacques GOUSSARD
 // Copyright: OPEN CASCADE 1992
 
+//=======================================================================
+//function : IntPatch_ImpImpIntersection
+//purpose  : 
+//=======================================================================
 IntPatch_ImpImpIntersection::IntPatch_ImpImpIntersection ():
        done(Standard_False)
 {
 }
-//--------------------------------------------------------------
+//=======================================================================
+//function : IntPatch_ImpImpIntersection
+//purpose  : 
+//=======================================================================
 IntPatch_ImpImpIntersection::IntPatch_ImpImpIntersection
        (const Handle(Adaptor3d_HSurface)&  S1,
 	const Handle(Adaptor3d_TopolTool)& D1,
@@ -18,7 +25,10 @@ IntPatch_ImpImpIntersection::IntPatch_ImpImpIntersection
 {
   Perform(S1,D1,S2,D2,TolArc,TolTang);
 }
-//--------------------------------------------------------------
+//=======================================================================
+//function : Perform
+//purpose  : 
+//=======================================================================
 void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
 					  const Handle(Adaptor3d_TopolTool)& D1,
 					  const Handle(Adaptor3d_HSurface)&  S2,
@@ -39,25 +49,21 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
   Standard_Boolean multpoint = Standard_False;
 
   Standard_Boolean nosolonS1 = Standard_False;
-              // indique s il y a des points sur restriction du carreau 1
+  // indique s il y a des points sur restriction du carreau 1
   Standard_Boolean nosolonS2 = Standard_False;
-              // indique s il y a des points sur restriction du carreau 2
-
+  // indique s il y a des points sur restriction du carreau 2
   Standard_Integer i, nbpt, nbseg;
-
   IntPatch_SequenceOfSegmentOfTheSOnBounds edg1,edg2;
   IntPatch_SequenceOfPathPointOfTheSOnBounds pnt1,pnt2;
-
+  //
   // On commence par intersecter les supports des surfaces
-
   IntSurf_Quadric quad1;
   IntSurf_Quadric quad2;
   IntPatch_ArcFunction AFunc;
   Standard_Real Tolang = 1.e-8;
   GeomAbs_SurfaceType typs1 = S1->GetType();
   GeomAbs_SurfaceType typs2 = S2->GetType();
-
-
+  //
   switch (typs1) {
 
   case GeomAbs_Plane :
@@ -92,7 +98,10 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
       case GeomAbs_Sphere:
 	{
 	  quad2.SetValue(S2->Sphere());
-	  if (!IntPSp(quad1,quad2,TolTang,Standard_False,empt,slin,spnt)) {
+	  //modified by NIZNHY-PKV Tue Sep 20 09:03:06 2011f
+	  if (!IntPSp(quad1,quad2,Tolang,TolTang,Standard_False,empt,slin,spnt)) {
+	  //if (!IntPSp(quad1,quad2,TolTang,Standard_False,empt,slin,spnt)) {
+	    //modified by NIZNHY-PKV Tue Sep 20 09:03:10 2011t
 	    return;
 	  }
 	  if (empt) {
@@ -202,7 +211,10 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
       case GeomAbs_Plane:
 	{
 	  quad2.SetValue(S2->Plane());
-	  if (!IntPSp(quad1,quad2,TolTang,Standard_True,empt,slin,spnt)) {
+	  //modified by NIZNHY-PKV Tue Sep 20 09:03:35 2011f
+	  if (!IntPSp(quad1,quad2,Tolang,TolTang,Standard_True,empt,slin,spnt)) {
+	  //if (!IntPSp(quad1,quad2,TolTang,Standard_True,empt,slin,spnt)) {
+	    //modified by NIZNHY-PKV Tue Sep 20 09:03:38 2011t
 	    return;
 	  }
 	  if (empt) {
@@ -338,22 +350,17 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
       Standard_ConstructionError::Raise();
       break;
     }
-  }
-
-
+  } //switch (typs1) {
+  //
   if (!SameSurf) {
-
     AFunc.SetQuadric(quad2);
     AFunc.Set(S1);
     
     solrst.Perform(AFunc, D1, TolArc, TolTang);
-
-
     if (!solrst.IsDone()) {
       return;
     }
 
-
     if (solrst.AllArcSolution() && typs1 == typs2) {
       all1 = Standard_True;
     }
@@ -370,19 +377,16 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
     if (nosolonS1 && all1) {  // cas de face sans restrictions
       all1 = Standard_False;
     }
-
-  }
+  }//if (!SameSurf) {
   else {
     nosolonS1 = Standard_True;
   }
 
   if (!SameSurf) {
-
     AFunc.SetQuadric(quad1);
     AFunc.Set(S2);
 
     solrst.Perform(AFunc, D2, TolArc, TolTang);
-
     if (!solrst.IsDone()) {
       return;
     }
@@ -404,16 +408,13 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
     if (nosolonS2 && all2) {  // cas de face sans restrictions
       all2 = Standard_False;
     }
-
-  }
+  }// if (!SameSurf) {
   else {
     nosolonS2 = Standard_True;
   }
-
+  //
   if (SameSurf || (all1 && all2)) {
-
     // faces "paralleles" parfaites
-
     empt = Standard_False;
     tgte = Standard_True;
     slin.Clear();
@@ -422,46 +423,34 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
     gp_Pnt Ptreference;
 
     switch (typs1) {
-    case GeomAbs_Plane:
-      {
-	Ptreference = (S1->Plane()).Location();
-      }
+    case GeomAbs_Plane:      {
+      Ptreference = (S1->Plane()).Location();
+    }
       break;
-    case GeomAbs_Cylinder:
-      {
-	Ptreference = ElSLib::Value(0.,0.,S1->Cylinder());
-      }
+    case GeomAbs_Cylinder: {
+      Ptreference = ElSLib::Value(0.,0.,S1->Cylinder());
+    }
       break;
-    case GeomAbs_Sphere:
-      {
-	Ptreference = ElSLib::Value(PI/4.,PI/4.,S1->Sphere());
-      }
+    case GeomAbs_Sphere:      {
+      Ptreference = ElSLib::Value(PI/4.,PI/4.,S1->Sphere());
+    }
       break;
-    case GeomAbs_Cone:
-      {
-	Ptreference = ElSLib::Value(0.,10.,S1->Cone());
-      }
+    case GeomAbs_Cone:      {
+      Ptreference = ElSLib::Value(0.,10.,S1->Cone());
+    }
       break;
-    
-#ifndef DEB
     default: 
       break;
-#endif
     }
+    //
     oppo = quad1.Normale(Ptreference).Dot(quad2.Normale(Ptreference)) < 0.0;
-
     done = Standard_True;
     return;
-  }
+  }// if (SameSurf || (all1 && all2)) {
 
   if (!nosolonS1 || !nosolonS2) {
-
-
     empt = Standard_False;
-
     // C est la qu il faut commencer a bosser...
-
-
     PutPointsOnLine(S1,S2,pnt1, slin, Standard_True, D1, quad1,quad2,
 		    multpoint,TolArc);
     
@@ -477,19 +466,52 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
     }
 
     if (edg1.Length() !=0 || edg2.Length() !=0) {
-//      ProcessRLine(slin,S1,S2,TolArc);
+      //      ProcessRLine(slin,S1,S2,TolArc);
       ProcessRLine(slin,quad1,quad2,TolArc);
     }
-
-  }
+  }//if (!nosolonS1 || !nosolonS2) {
   else {
     empt = ((slin.Length()==0) && (spnt.Length()==0));
   }
-
-  Standard_Integer nblin = slin.Length();
-
-
-
+  //
+  Standard_Integer nblin, aNbPnt;
+  //
+  //modified by NIZNHY-PKV Tue Sep 06 10:03:35 2011f
+  aNbPnt=spnt.Length();
+  if (aNbPnt) {
+    IntPatch_SequenceOfPoint aSIP;
+    //
+    for(i=1; i<=aNbPnt; ++i) {
+      Standard_Real aU1, aV1, aU2, aV2;
+      gp_Pnt2d aP2D;
+      TopAbs_State aState1, aState2;
+      //
+      const IntPatch_Point& aIP=spnt(i);
+      aIP.Parameters(aU1, aV1, aU2, aV2);
+      //
+      aP2D.SetCoord(aU1, aV1);
+      aState1=D1->Classify(aP2D, TolArc);
+      //
+      aP2D.SetCoord(aU2, aV2);
+      aState2=D2->Classify(aP2D, TolArc);
+      //
+      if(aState1!=TopAbs_OUT && aState2!=TopAbs_OUT) {
+	aSIP.Append(aIP);
+      }
+    }
+    //
+    spnt.Clear();
+    //
+    aNbPnt=aSIP.Length();
+    for(i=1; i<=aNbPnt; ++i) {
+      const IntPatch_Point& aIP=aSIP(i);
+      spnt.Append(aIP);
+    }
+    //
+  }//  if (aNbPnt) {
+  //modified by NIZNHY-PKV Tue Sep 06 10:18:20 2011t
+  //
+  nblin = slin.Length();
   for(i=1; i<=nblin; i++) {
     IntPatch_IType thetype = slin.Value(i)->ArcType();
     if(  (thetype ==  IntPatch_Ellipse)
@@ -498,70 +520,6 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
        ||(thetype ==  IntPatch_Parabola)
        ||(thetype ==  IntPatch_Hyperbola)) { 
       Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine)*)&slin.Value(i));
-      
-/*      if(thetype  == IntPatch_Circle) { 
-	gp_Pnt P;
-	IntPatch_Point point;
-	Standard_Real u1,v1,u2,v2; 
-	Standard_Boolean Addf = Standard_False;
-	Standard_Boolean Addl = Standard_False;
-	Standard_Integer v=0;
-	Standard_Integer nbv;
-	gp_Circ Circ = glin->Circle();
-	nbv = glin->NbVertex();
-	if(glin->HasFirstPoint() == Standard_False) { 
-	  P=ElCLib::Value(0.0,Circ);
-	  quad1.Parameters(P,u1,v1); quad2.Parameters(P,u2,v2);
-	  point.SetValue(P,TolArc,Standard_False);
-	  point.SetParameters(u1,v1,u2,v2); 
-	  point.SetParameter(0.0);
-	  glin->AddVertex(point);
-	  nbv++;
-	  glin->SetFirstPoint(nbv);
-	}
-	if(glin->HasLastPoint() == Standard_False) { 
-	  P=ElCLib::Value(0.0,Circ);
-	  quad1.Parameters(P,u1,v1); quad2.Parameters(P,u2,v2);
-	  point.SetValue(P,TolArc,Standard_False);
-	  point.SetParameters(u1,v1,u2,v2);
-	  point.SetParameter(PI+PI);
-	  glin->AddVertex(point);
-	  nbv++;
-	  glin->SetLastPoint(nbv);
-	}
-      }
-      else if(thetype == IntPatch_Ellipse) { 
-	gp_Pnt P;
-	IntPatch_Point point;
-	Standard_Real u1,v1,u2,v2; 
-	Standard_Boolean Addf = Standard_False;
-	Standard_Boolean Addl = Standard_False;
-	Standard_Integer v=0;
-	Standard_Integer nbv;
-	gp_Elips Elips = glin->Ellipse();
-	nbv = glin->NbVertex();
-	if(glin->HasFirstPoint() == Standard_False) { 
-	  P=ElCLib::Value(0.0,Elips);
-	  quad1.Parameters(P,u1,v1);  quad2.Parameters(P,u2,v2);
-	  point.SetValue(P,TolArc,Standard_False);
-	  point.SetParameters(u1,v1,u2,v2);
-	  point.SetParameter(0.0);
-	  glin->AddVertex(point);
-	  nbv++;
-	  glin->SetFirstPoint(nbv);
-	}
-	if(glin->HasLastPoint() == Standard_False) {
-	  P=ElCLib::Value(0.0,Elips);
-	  quad1.Parameters(P,u1,v1);  quad2.Parameters(P,u2,v2);
-	  point.SetValue(P,TolArc,Standard_False);
-	  point.SetParameters(u1,v1,u2,v2);
-	  point.SetParameter(PI+PI);
-	  glin->AddVertex(point);
-	  nbv++;
-	  glin->SetLastPoint(nbv);
-	}
-	} 
-*/
     glin->ComputeVertexParameters(TolArc); 
     }
     else if(thetype == IntPatch_Analytic) { 
@@ -573,20 +531,14 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
       rlig->ComputeVertexParameters(TolArc); 
     }
   }
-#if 1 
+  //
   //----------------------------------------------------------------
   //-- On place 2 vertex sur les courbes de GLine qui n en 
   //-- contiennent pas. 
-  
   for(i=1; i<=nblin; i++) {
     gp_Pnt P;
     IntPatch_Point point;
     Standard_Real u1,v1,u2,v2; 
-#ifdef DEB
-    Standard_Boolean Addf = Standard_False;
-    Standard_Boolean Addl = Standard_False;
-    Standard_Integer v=0;
-#endif
     if(slin.Value(i)->ArcType() == IntPatch_Circle) { 
       const Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine)*)&slin.Value(i));
       if(glin->NbVertex() == 0) { 
@@ -631,115 +583,6 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
       }
     }
   }
-#endif
-
   done = Standard_True;
 }
-//--------------------------------------------------------------
-
 
-#if 0
-//-- Ancien bout de code 
-  //----------------------------------------------------------------
-  //-- On place 2 vertex sur les courbes de GLine qui n en 
-  //-- contiennent pas. 
-  
-  for(i=1; i<=nblin; i++) {
-    gp_Pnt P;
-    IntPatch_Point point;
-    Standard_Real u1,v1,u2,v2; 
-    Standard_Boolean Addf = Standard_False;
-    Standard_Boolean Addl = Standard_False;
-    Standard_Integer v=0;
-    Standard_Integer nbv;
-    if(slin.Value(i)->ArcType() == IntPatch_Circle) { 
-      const Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine)*)&slin.Value(i));
-      nbv = glin->NbVertex();
-      if(glin->NbVertex() == 0) { Addf=Addl=Standard_True; } 
-      else { 
-	if(glin->HasFirstPoint() == Standard_False) { 
-	  Addf = Standard_True;
-	  for(v=1;v<=nbv;v++) { 
-	    Standard_Real gv = glin->Vertex(v).ParameterOnLine();
-	    if(gv<Precision::PConfusion()) 
-	      Addf = Standard_False;
-	  }
-	}
-	if(glin->HasLastPoint() == Standard_False) { 
-	  Addl = Standard_True;
-	  for(v=1;v<=nbv;v++) { 
-	    Standard_Real gv = glin->Vertex(v).ParameterOnLine();
-	    if((PI+PI-gv)<Precision::PConfusion()) 
-	      Addl = Standard_False;
-	  }
-	}
-      }
-      if(Addl || Addf) { 
-	gp_Circ Circ = glin->Circle();
-	if(Addf) { 
-	  P=ElCLib::Value(0.0,Circ);
-	  quad1.Parameters(P,u1,v1);
-	  quad2.Parameters(P,u2,v2);
-	  point.SetValue(P,TolArc,Standard_False);
-	  point.SetParameters(u1,v1,u2,v2);
-	  point.SetParameter(0.0);
-	  glin->AddVertex(point);
-	}
-	if(Addl) { 
-	  P=ElCLib::Value(0.0,Circ);
-	  quad1.Parameters(P,u1,v1);
-	  quad2.Parameters(P,u2,v2);
-	  point.SetValue(P,TolArc,Standard_False);
-	  point.SetParameters(u1,v1,u2,v2);
-	  point.SetParameter(PI+PI);
-	  glin->AddVertex(point);
-	}
-      }
-    }
-    
-    else if(slin.Value(i)->ArcType() == IntPatch_Ellipse) { 
-      const Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine)*)&slin.Value(i));
-      nbv = glin->NbVertex();
-      if(glin->NbVertex() == 0) { Addf=Addl=Standard_True; } 
-      else { 
-	if(glin->HasFirstPoint() == Standard_False) { 
-	  Addf = Standard_True;
-	  for(v=1;v<=nbv;v++) { 
-	    Standard_Real gv = glin->Vertex(v).ParameterOnLine();
-	    if(gv<Precision::PConfusion()) 
-	      Addf = Standard_False;
-	  }
-	}
-	if(glin->HasLastPoint() == Standard_False) { 
-	  Addl = Standard_True;
-	  for(v=1;v<=nbv;v++) { 
-	    Standard_Real gv = glin->Vertex(v).ParameterOnLine();
-	    if((PI+PI-gv)<Precision::PConfusion()) 
-	      Addl = Standard_False;
-	  }
-	}
-      }
-      if(Addl || Addf) { 
-	gp_Elips Elips = glin->Ellipse();
-	if(Addf) { 
-	  P=ElCLib::Value(0.0,Elips);
-	  quad1.Parameters(P,u1,v1);
-	  quad2.Parameters(P,u2,v2);
-	  point.SetValue(P,TolArc,Standard_False);
-	  point.SetParameters(u1,v1,u2,v2);
-	  point.SetParameter(0.0);
-	  glin->AddVertex(point);
-	}
-	if(Addl) { 
-	  P=ElCLib::Value(0.0,Elips);
-	  quad1.Parameters(P,u1,v1);
-	  quad2.Parameters(P,u2,v2);
-	  point.SetValue(P,TolArc,Standard_False);
-	  point.SetParameters(u1,v1,u2,v2);
-	  point.SetParameter(PI+PI);
-	  glin->AddVertex(point);
-	}
-      }
-    }
-  }
-#endif
diff --git a/inc/IntPatch_ImpImpIntersection_3.gxx b/inc/IntPatch_ImpImpIntersection_3.gxx
index 5302cb5..c9e9eb7 100644
--- a/inc/IntPatch_ImpImpIntersection_3.gxx
+++ b/inc/IntPatch_ImpImpIntersection_3.gxx
@@ -3,13 +3,35 @@
 // Author:    Jacques GOUSSARD
 // Copyright: OPEN CASCADE 1992
 
+//modified by NIZNHY-PKV Thu Sep 15 11:09:12 2011
+static 
+  void SeamPosition(const gp_Pnt& aPLoc, 
+		    const gp_Ax3& aPos,
+		    gp_Ax2& aSeamPos);
+static
+  void AdjustToSeam (const gp_Cylinder& aQuad,
+		     gp_Circ& aCirc);
+static
+  void AdjustToSeam (const gp_Sphere& aQuad,
+		     gp_Circ& aCirc,
+		     const Standard_Real aTolAng);
+static
+  void AdjustToSeam (const gp_Cone& aQuad,
+		     gp_Circ& aCirc);
+//modified by NIZNHY-PKV Thu Sep 15 11:09:13 2011
+
+//=======================================================================
+//function : IntPP
+//purpose  : 
+// Traitement du cas Plan/Plan
+//=======================================================================
 Standard_Boolean IntPP (const IntSurf_Quadric& Quad1,
 			const IntSurf_Quadric& Quad2,
 			const Standard_Real Tolang,
 			const Standard_Real TolTang,
 			Standard_Boolean& Same,
 			IntPatch_SequenceOfLine& slin)
-// Traitement du cas Plan/Plan
+
 {
   IntSurf_TypeTrans trans1,trans2;
   IntAna_ResultType typint;
@@ -37,12 +59,17 @@ Standard_Boolean IntPP (const IntSurf_Quadric& Quad1,
       trans1 = IntSurf_In;
       trans2 = IntSurf_Out;
     }
-    Handle(IntPatch_GLine) glig = new IntPatch_GLine (linsol,Standard_False,trans1,trans2);
+    Handle(IntPatch_GLine) glig = 
+      new IntPatch_GLine (linsol,Standard_False,trans1,trans2);
     slin.Append(glig);
   }
   return Standard_True;
 }
-//====================================================================================
+//=======================================================================
+//function : IntPCy
+//purpose  : 
+// Traitement du cas Plan/Cylindre et reciproquement
+//=======================================================================
 Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
 			 const IntSurf_Quadric& Quad2,
 			 const Standard_Real Tolang,
@@ -51,7 +78,6 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
 			 Standard_Boolean& Empty,
 			 IntPatch_SequenceOfLine& slin)
 
-// Traitement du cas Plan/Cylindre et reciproquement
 {
   gp_Pln Pl;
   gp_Cylinder Cy;
@@ -76,14 +102,12 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
 
   switch (typint) {
 	    
-  case IntAna_Empty :
-    {
+    case IntAna_Empty :    {
       Empty = Standard_True;
     }
-    break;
+      break;
 
-  case IntAna_Line:
-    {
+    case IntAna_Line:    {
       gp_Lin linsol = inter.Line(1);
       gp_Pnt orig(linsol.Location());
       if (NbSol == 1) {                 // ligne de tangence
@@ -128,7 +152,8 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
 	}
 	slin.Append(glig);
       }
-      else {      // on a 2 droites. Il faut determiner les transitions
+      else {      
+	// on a 2 droites. Il faut determiner les transitions
 	// de chacune.
 	
 	if (linsol.Direction().DotCross(Quad2.Normale(orig),
@@ -140,7 +165,8 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
 	  trans1 = IntSurf_In;
 	  trans2 = IntSurf_Out;
 	}
-	Handle(IntPatch_GLine) glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
+	Handle(IntPatch_GLine) glig = 
+	  new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
 	slin.Append(glig);
 	
 	linsol = inter.Line(2);
@@ -159,15 +185,19 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
 	slin.Append(glig);
       }
     }
-    break;
-    
-  case IntAna_Circle:
-    {
-      gp_Circ cirsol = inter.Circle(1);
+      break;
+      //
+    case IntAna_Circle:    {
+      gp_Circ cirsol;
       gp_Pnt ptref;
       gp_Vec Tgt;
+      //
+      cirsol = inter.Circle(1);
+      //modified by NIZNHY-PKV Thu Sep 15 11:30:03 2011f
+      AdjustToSeam(Cy, cirsol);
+      //modified by NIZNHY-PKV Thu Sep 15 11:30:15 2011t
       ElCLib::D1(0.,cirsol,ptref,Tgt);
-
+      
       if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) > 0.0) {
 	trans1 = IntSurf_Out;
 	trans2 = IntSurf_In;
@@ -179,15 +209,14 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
       Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
       slin.Append(glig);
     }
-    break;
-    
-  case IntAna_Ellipse:
-    {
+      break;
+      // 
+    case IntAna_Ellipse:    {
       gp_Elips elipsol = inter.Ellipse(1);
       gp_Pnt ptref;
       gp_Vec Tgt;
       ElCLib::D1(0.,elipsol,ptref,Tgt);
-
+      
       if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) > 0.0) {
 	trans1 = IntSurf_Out;
 	trans2 = IntSurf_In;
@@ -199,25 +228,31 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
       Handle(IntPatch_GLine) glig = new IntPatch_GLine(elipsol,Standard_False,trans1,trans2);
       slin.Append(glig);
     }
-    break;
-    
-  default:
-    {
+      break;
+      //
+    default:    {
       return Standard_False; // on ne doit pas passer ici
     }
   }
   return Standard_True;
 }
-//====================================================================================
+//=======================================================================
+//function : IntPSp
+//purpose  : 
+// Traitement du cas Plan/Sphere et reciproquement
+//=======================================================================
 Standard_Boolean IntPSp (const IntSurf_Quadric& Quad1,
 			 const IntSurf_Quadric& Quad2,
+			 //modified by NIZNHY-PKV Tue Sep 20 08:59:36 2011f
+			 const Standard_Real Tolang,
+			 //modified by NIZNHY-PKV Tue Sep 20 08:59:39 2011t
 			 const Standard_Real TolTang,
 			 const Standard_Boolean Reversed,
 			 Standard_Boolean& Empty,
 			 IntPatch_SequenceOfLine& slin,
 			 IntPatch_SequenceOfPoint& spnt)
 
-// Traitement du cas Plan/Sphere et reciproquement
+
 {
   gp_Circ cirsol;
   gp_Pln Pl;
@@ -242,15 +277,12 @@ Standard_Boolean IntPSp (const IntSurf_Quadric& Quad1,
   Empty = Standard_False;
 
   switch (typint) {
-
-  case IntAna_Empty :
-    {
+    case IntAna_Empty :    {
       Empty = Standard_True;
     }
-    break;
-    
-  case IntAna_Point:
-    {
+      break;
+      //
+    case IntAna_Point:    {
       gp_Pnt psol = inter.Point(1);
       Standard_Real U1,V1,U2,V2;
       Quad1.Parameters(psol,U1,V1);
@@ -260,11 +292,13 @@ Standard_Boolean IntPSp (const IntSurf_Quadric& Quad1,
       ptsol.SetParameters(U1,V1,U2,V2);
       spnt.Append(ptsol);
     }
-    break;
-    
-  case IntAna_Circle:
-    {
+      break;
+      //
+    case IntAna_Circle:    {
       cirsol = inter.Circle(1);
+      //modified by NIZNHY-PKV Thu Sep 15 11:30:03 2011f
+      AdjustToSeam(Sp, cirsol, Tolang);
+      //modified by NIZNHY-PKV Thu Sep 15 11:30:15 2011t
       gp_Pnt ptref;
       gp_Vec Tgt;
       ElCLib::D1(0.,cirsol,ptref,Tgt);
@@ -280,16 +314,19 @@ Standard_Boolean IntPSp (const IntSurf_Quadric& Quad1,
       Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
       slin.Append(glig);
     }
-    break;
-    
-  default:
-    {
+      break;
+      
+    default:    {
       return Standard_False;  // on ne doit pas passer ici
     }
   }
   return Standard_True;
 }
-//====================================================================================
+//=======================================================================
+//function : IntPCo
+//purpose  : 
+// Traitement du cas Plan/Cone et reciproquement
+//=======================================================================
 Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
 			 const IntSurf_Quadric& Quad2,
 			 const Standard_Real Tolang,
@@ -300,7 +337,7 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
 			 IntPatch_SequenceOfLine& slin,
 			 IntPatch_SequenceOfPoint& spnt)
 
-// Traitement du cas Plan/Cone et reciproquement
+
 {
   gp_Pnt apex;
 
@@ -323,16 +360,16 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
   }
 
   inter.Perform(Pl,Co,Tolang,TolTang);
-  if (!inter.IsDone()) {return Standard_False;}
-
+  if (!inter.IsDone()) {
+    return Standard_False;
+  }
+  //
   typint = inter.TypeInter();
   Standard_Integer NbSol = inter.NbSolutions();
   Empty = Standard_False;
 
   switch (typint) {
-	    
-  case IntAna_Point:
-    {
+    case IntAna_Point:    {
       gp_Pnt psol = inter.Point(1);
       Standard_Real U1,V1,U2,V2;
       Quad1.Parameters(psol,U1,V1);
@@ -342,10 +379,9 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
       ptsol.SetParameters(U1,V1,U2,V2);
       spnt.Append(ptsol);
     }
-    break;
-    
-  case IntAna_Line:
-    {
+      break;
+      
+    case IntAna_Line:    {
       gp_Lin linsol = inter.Line(1);
       if (linsol.Direction().Dot(Co.Axis().Direction()) <0.) {
 	linsol.SetDirection(linsol.Direction().Reversed());
@@ -355,7 +391,7 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
       Standard_Real U1,V1,U2,V2;
       Quad1.Parameters(apex,U1,V1);
       Quad2.Parameters(apex,U2,V2);
-
+      
       if (NbSol == 1) {                 // ligne de tangence
 	IntPatch_Point ptsol;
 	ptsol.SetValue(apex,TolTang,Standard_False);
@@ -372,10 +408,9 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
 	  Normp = Quad2.Normale(ptbid);
 	  Normco = Quad1.Normale(ptbid);
 	}
-
 	IntSurf_Situation situco,situco_otherside;
 	IntSurf_Situation situp,situp_otherside;
-
+	
 	if (Normp.Dot(TestCurvature) > 0.) {
 	  situco           = IntSurf_Outside;
 	  situco_otherside = IntSurf_Inside;
@@ -504,100 +539,71 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
       }
     }
     break;
-    
-  case IntAna_Circle:
-    {
+      
+    case IntAna_Circle:    {
       gp_Circ cirsol = inter.Circle(1);
-#if 0 
-      if (ElCLib::LineParameter(Co.Axis(),cirsol.Location()) < 
-	  ElCLib::LineParameter(Co.Axis(),apex) ) {
-	Empty = Standard_True;
+      //modified by NIZNHY-PKV Thu Sep 15 11:34:04 2011f
+      AdjustToSeam(Co, cirsol);
+      //modified by NIZNHY-PKV Thu Sep 15 11:36:08 2011t
+      gp_Pnt ptref;
+      gp_Vec Tgt;
+      ElCLib::D1(0.,cirsol,ptref,Tgt);
+      
+      if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
+	trans1 = IntSurf_Out;
+	trans2 = IntSurf_In;
       }
-#endif
-      if(0) { } 
       else {
-
-	gp_Pnt ptref;
-	gp_Vec Tgt;
-	ElCLib::D1(0.,cirsol,ptref,Tgt);
-	
-	if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
-	  trans1 = IntSurf_Out;
-	  trans2 = IntSurf_In;
-	}
-	else {
-	  trans1 = IntSurf_In;
-	  trans2 = IntSurf_Out;
-	}
-	Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
-	slin.Append(glig);
+	trans1 = IntSurf_In;
+	trans2 = IntSurf_Out;
       }
+      Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
+      slin.Append(glig);
     }
-    break;
-    
-  case IntAna_Ellipse:
-    {
+      break;
+      
+    case IntAna_Ellipse:    {
       gp_Elips  elipsol = inter.Ellipse(1);
-#if 0 
-      if (ElCLib::LineParameter(Co.Axis(),elipsol.Location()) < 
-	  ElCLib::LineParameter(Co.Axis(),apex) ) {
-	Empty = Standard_True;
+      gp_Pnt ptref;
+      gp_Vec Tgt;
+      ElCLib::D1(0.,elipsol,ptref,Tgt);
+      
+      if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
+	trans1 = IntSurf_Out;
+	trans2 = IntSurf_In;
       }
-#endif
-      if(0) { } 
       else {
-	gp_Pnt ptref;
-	gp_Vec Tgt;
-	ElCLib::D1(0.,elipsol,ptref,Tgt);
-	
-	if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
-	  trans1 = IntSurf_Out;
-	  trans2 = IntSurf_In;
-	}
-	else {
-	  trans1 = IntSurf_In;
-	  trans2 = IntSurf_Out;
-	}
-	Handle(IntPatch_GLine) glig = new IntPatch_GLine(elipsol,Standard_False,trans1,trans2);
-	slin.Append(glig);
+	trans1 = IntSurf_In;
+	trans2 = IntSurf_Out;
       }
+      Handle(IntPatch_GLine) glig = new IntPatch_GLine(elipsol,Standard_False,trans1,trans2);
+      slin.Append(glig);
     }
-    break;
-    
-  case IntAna_Parabola:
-    {
+      break;
+      
+    case IntAna_Parabola:    {
       gp_Parab parabsol = inter.Parabola(1);
-#if 0 
-      if (ElCLib::LineParameter(Co.Axis(),parabsol.Focus()) < 
-	  ElCLib::LineParameter(Co.Axis(),apex) ) {
-	Empty = Standard_True;
+      
+      gp_Vec Tgtorig(parabsol.YAxis().Direction());
+      Standard_Real ptran = Tgtorig.DotCross(Quad2.Normale(parabsol.Location()),
+					     Quad1.Normale(parabsol.Location()));
+      if (ptran >0.00000001) {
+	trans1 = IntSurf_Out;
+	trans2 = IntSurf_In;
       }
-#endif
-      if(0) { } 
-      else {
-	
-	gp_Vec Tgtorig(parabsol.YAxis().Direction());
-	Standard_Real ptran = Tgtorig.DotCross(Quad2.Normale(parabsol.Location()),
-					       Quad1.Normale(parabsol.Location()));
-	if (ptran >0.00000001) {
-	  trans1 = IntSurf_Out;
-	  trans2 = IntSurf_In;
-	}
-	else if (ptran <-0.00000001) {
-	  trans1 = IntSurf_In;
-	  trans2 = IntSurf_Out;
-	}
-	else { 
-	  trans1=trans2=IntSurf_Undecided; 
-	}
-	Handle(IntPatch_GLine) glig = new IntPatch_GLine(parabsol,Standard_False,trans1,trans2);
-	slin.Append(glig);
+      else if (ptran <-0.00000001) {
+	trans1 = IntSurf_In;
+	trans2 = IntSurf_Out;
       }
+      else { 
+	trans1=trans2=IntSurf_Undecided; 
+      }
+      Handle(IntPatch_GLine) glig = new IntPatch_GLine(parabsol,Standard_False,trans1,trans2);
+      slin.Append(glig);
     }
-    break;
-    
-  case IntAna_Hyperbola:
-    {
+      break;
+      
+    case IntAna_Hyperbola:    {
       gp_Pnt tophypr;
       gp_Vec Tgttop;
       
@@ -624,13 +630,78 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
 	slin.Append(glig);
       }
     }
-    break;
-    
-  default:
-    {
+      break;
+      
+    default:    {
       return Standard_False;
     }
   }
   return Standard_True;
 }
-//====================================================================================
+//
+//modified by NIZNHY-PKV Thu Sep 15 10:53:39 2011f
+//=======================================================================
+//function : AdjustToSeam
+//purpose  : 
+//=======================================================================
+void AdjustToSeam (const gp_Cone& aQuad,
+		   gp_Circ& aCirc)
+{
+   gp_Ax2 aAx2;
+   //
+   const gp_Pnt& aPLoc=aCirc.Location();
+   const gp_Ax3& aAx3=aQuad.Position();
+   SeamPosition(aPLoc, aAx3, aAx2);
+   aCirc.SetPosition(aAx2);
+} 
+//=======================================================================
+//function : AdjustToSeam
+//purpose  : 
+//=======================================================================
+void AdjustToSeam (const gp_Sphere& aQuad,
+		   gp_Circ& aCirc,
+		   const Standard_Real aTolAng)
+{
+   gp_Ax2 aAx2;
+   //
+   const gp_Ax1& aAx1C=aCirc.Axis();
+   const gp_Ax3& aAx3=aQuad.Position();
+   const gp_Ax1& aAx1Q=aAx3.Axis();
+   //
+   const gp_Dir& aDirC=aAx1C.Direction();
+   const gp_Dir& aDirQ=aAx1Q.Direction();
+   if (aDirC.IsParallel(aDirQ, aTolAng)) {
+     const gp_Pnt& aPLoc=aCirc.Location();
+     SeamPosition(aPLoc, aAx3, aAx2);
+     aCirc.SetPosition(aAx2);
+   }
+} 
+//=======================================================================
+//function : AdjustToSeam
+//purpose  : 
+//=======================================================================
+void AdjustToSeam (const gp_Cylinder& aQuad,
+		   gp_Circ& aCirc)
+{
+   gp_Ax2 aAx2;
+   //
+   const gp_Pnt& aPLoc=aCirc.Location();
+   const gp_Ax3& aAx3=aQuad.Position();
+   SeamPosition(aPLoc, aAx3, aAx2);
+   aCirc.SetPosition(aAx2);
+} 
+//=======================================================================
+//function : SeamPosition
+//purpose  : 
+//=======================================================================
+void SeamPosition(const gp_Pnt& aPLoc, 
+		  const gp_Ax3& aPos, 
+		  gp_Ax2& aSeamPos)
+{
+  const gp_Dir& aDZ=aPos.Direction();
+  const gp_Dir& aDX=aPos.XDirection();
+  gp_Ax2 aAx2(aPLoc, aDZ, aDX);
+  aSeamPos=aAx2;
+}
+			    
+//modified by NIZNHY-PKV Thu Sep 15 10:53:41 2011t
diff --git a/inc/IntTools_DataMapOfCurveSampleBox.hxx b/inc/IntTools_DataMapOfCurveSampleBox.hxx
index b12a958..f33ebbb 100644
--- a/inc/IntTools_DataMapOfCurveSampleBox.hxx
+++ b/inc/IntTools_DataMapOfCurveSampleBox.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class IntTools_CurveRangeSample;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const IntTools_CurveRangeSample& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const IntTools_CurveRangeSample& K) ;
 
 
 
diff --git a/inc/IntTools_DataMapOfSurfaceSampleBox.hxx b/inc/IntTools_DataMapOfSurfaceSampleBox.hxx
index f013a8a..768f2a7 100644
--- a/inc/IntTools_DataMapOfSurfaceSampleBox.hxx
+++ b/inc/IntTools_DataMapOfSurfaceSampleBox.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class IntTools_SurfaceRangeSample;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const IntTools_SurfaceRangeSample& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const IntTools_SurfaceRangeSample& K) ;
 
 
 
diff --git a/inc/IntTools_FaceFace.hxx b/inc/IntTools_FaceFace.hxx
index 8eed8dc..12ced59 100644
--- a/inc/IntTools_FaceFace.hxx
+++ b/inc/IntTools_FaceFace.hxx
@@ -109,11 +109,15 @@ public:
   Standard_EXPORT    const TopoDS_Face& Face2() const;
   
 //! Returns True if faces are tangent <br>
+//! <br>
   Standard_EXPORT     Standard_Boolean TangentFaces() const;
   
-//! Provides post-processing the result lines, <br>
-//! which includes spliting closed curves. <br>
-  Standard_EXPORT     void PrepareLines3D() ;
+//! Provides post-processing the result lines. <br>
+//! <bToSplit> - the flag. <br>
+//!  In case of <bToSplit> is true the closed 3D-curves will be splitted <br>
+//!  on parts. <br>
+//!  In case of <bToSplit> is false the closed 3D-curves remain untouched. <br>
+  Standard_EXPORT     void PrepareLines3D(const Standard_Boolean bToSplit = Standard_True) ;
   
   Standard_EXPORT     void SetList(IntSurf_ListOfPntOn2S& ListOfPnts) ;
 
diff --git a/inc/IntTools_IndexedDataMapOfTransientAddress.hxx b/inc/IntTools_IndexedDataMapOfTransientAddress.hxx
index a570b0a..33c2f7d 100644
--- a/inc/IntTools_IndexedDataMapOfTransientAddress.hxx
+++ b/inc/IntTools_IndexedDataMapOfTransientAddress.hxx
@@ -100,6 +100,10 @@ public:
   Standard_EXPORT    const Standard_Address& FindFromKey(const Handle(Standard_Transient)& K) const;
   
   Standard_EXPORT     Standard_Address& ChangeFromKey(const Handle(Standard_Transient)& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Handle(Standard_Transient)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Handle(Standard_Transient)& K) ;
 
 
 
diff --git a/inc/InterfaceGraphic_Cextern.hxx b/inc/InterfaceGraphic_Cextern.hxx
index f4708d7..fe52fa4 100644
--- a/inc/InterfaceGraphic_Cextern.hxx
+++ b/inc/InterfaceGraphic_Cextern.hxx
@@ -63,6 +63,7 @@
 #include <InterfaceGraphic_Graphic3d.hxx>
 #include <InterfaceGraphic_Visual3d.hxx>
 
+#include <Graphic3d_CGraduatedTrihedron.hxx>
 
 #define  BUC61044    /* 25/10/01 SAV ; added functionality to control gl depth testing
       from higher API */
@@ -1091,21 +1092,13 @@ int EXPORT call_togl_isgllight (
   CALL_DEF_VIEW *aview
 #endif
 );
-void EXPORT call_togl_graduatedtrihedron_get (
-#ifdef INTERFACEGRAPHIC_PROTOTYPE
-    /* View id */
-	CALL_DEF_VIEW* aview, 
-    /* Graduated trihedron data */
-    CALL_DEF_GRADUATEDTRIHEDRON* cubic
-#endif
-);
 
 void EXPORT call_togl_graduatedtrihedron_display (
 #ifdef INTERFACEGRAPHIC_PROTOTYPE
     /* View id */
 	CALL_DEF_VIEW* aview, 
     /* Graduated trihedron data */
-    CALL_DEF_GRADUATEDTRIHEDRON* cubic
+    const Graphic3d_CGraduatedTrihedron &cubic
 #endif
 );
 
diff --git a/inc/InterfaceGraphic_Graphic3d.hxx b/inc/InterfaceGraphic_Graphic3d.hxx
index 8bf7416..1fe3f75 100644
--- a/inc/InterfaceGraphic_Graphic3d.hxx
+++ b/inc/InterfaceGraphic_Graphic3d.hxx
@@ -246,7 +246,7 @@ typedef struct {
 
 typedef struct {
 
-        char *string;
+        unsigned short *string;
 
         CALL_DEF_POINT Position;
 
@@ -260,7 +260,7 @@ typedef struct {
 
         int VAlign;
 	
-	bool Zoomable;
+        bool Zoomable;
 
 } CALL_DEF_TEXT;
 
diff --git a/inc/InterfaceGraphic_Visual3d.hxx b/inc/InterfaceGraphic_Visual3d.hxx
index 79e1404..bff76a3 100644
--- a/inc/InterfaceGraphic_Visual3d.hxx
+++ b/inc/InterfaceGraphic_Visual3d.hxx
@@ -52,8 +52,6 @@ Facility : CAS-CADE V1
 #include <Aspect_GraphicCallbackProc.hxx>
 #endif
 
-#include <OSD_FontAspect.hxx>
-
 typedef float CALL_DEF_MATRIX4X4[4][4];
 
 /* SOMMET */
@@ -256,61 +254,4 @@ typedef struct {
 
 } CALL_DEF_PICK;
 
-/* Graduated trihedron */
-typedef void (*minMaxValuesCallback)(void*);
-typedef struct
-{
-    /* Names of axes */
-    char *xname, *yname, *zname;
-    /* Draw names */
-    Standard_Boolean xdrawname, ydrawname, zdrawname;
-    /* Draw values */
-    Standard_Boolean xdrawvalues, ydrawvalues, zdrawvalues;
-    /* Draw grid */
-    Standard_Boolean drawgrid;
-    /* Draw axes */
-    Standard_Boolean drawaxes;
-    /* Number of splits along axes */
-    unsigned int nbx, nby, nbz;
-    /* Offset for drawing values */
-    int xoffset, yoffset, zoffset;
-    /* Offset for drawing names of axes */
-    int xaxisoffset, yaxisoffset, zaxisoffset;
-    /* Draw tickmarks */
-    Standard_Boolean xdrawtickmarks, ydrawtickmarks, zdrawtickmarks;
-    /* Length of tickmarks */
-    unsigned int xtickmarklength, ytickmarklength, ztickmarklength;
-    /* Grid color */
-    float gridcolor[3];
-    /* X name color */
-    float xnamecolor[3];
-    /* Y name color */
-    float ynamecolor[3];
-    /* Z name color */
-    float znamecolor[3];
-    /* X color of axis and values */
-    float xcolor[3];
-    /* Y color of axis and values */
-    float ycolor[3];
-    /* Z color of axis and values */
-    float zcolor[3];
-    /* Font name of names of axes: Courier, Arial, ... */
-    char* fontOfNames;
-    /* Style of names of axes: OSD_FA_Regular, OSD_FA_Bold, ... */
-    OSD_FontAspect styleOfNames;
-    /* Size of names of axes: 8, 10, 12, 14, ... */
-    int sizeOfNames;
-    /* Font name of values: Courier, Arial, ... */
-    char* fontOfValues;
-    /* Style of values: OSD_FA_Regular, OSD_FA_Bold, ... */
-    OSD_FontAspect styleOfValues;
-    /* Size of values: 8, 10, 12, 14, ... */
-    int sizeOfValues;
-
-    /* Callback function to define boundary box of displayed objects */
-    minMaxValuesCallback cbCubicAxes;
-    void* ptrVisual3dView;
-
-} CALL_DEF_GRADUATEDTRIHEDRON;
-
 #endif /* InterfaceGraphic_Visual3dHeader */
diff --git a/inc/InterfaceGraphic_telem.hxx b/inc/InterfaceGraphic_telem.hxx
index f630a58..8084b3c 100644
--- a/inc/InterfaceGraphic_telem.hxx
+++ b/inc/InterfaceGraphic_telem.hxx
@@ -116,15 +116,6 @@ struct TEL_MATRIX3_DATA
 };
 typedef TEL_MATRIX3_DATA* tel_matrix3_data;
 
-struct TEL_TEXT_DATA
-{
-  TEL_POINT  attach_pt;
-  Tint       length;
-  Tchar*     data;
-  IMPLEMENT_MEMORY_OPERATORS
-};
-typedef TEL_TEXT_DATA* tel_text_data;
-
 struct TEL_ALIGN_DATA
 {
   Tint Hmode;
diff --git a/inc/InterfaceGraphic_tgl_all.hxx b/inc/InterfaceGraphic_tgl_all.hxx
index aee37aa..1f1aae7 100644
--- a/inc/InterfaceGraphic_tgl_all.hxx
+++ b/inc/InterfaceGraphic_tgl_all.hxx
@@ -19,6 +19,8 @@ therefore it should be made signed explicitly, as on Linux
 typedef  signed char  Tchar;
 typedef  char         Tbool;
 typedef  unsigned int Tuint;
+/* szv: Techar is an Extended character */
+typedef  unsigned short Techar;
 
 #define  TGL_SP   1
 #define  TGL_DP   0
diff --git a/inc/Interface_DataMapOfTransientInteger.hxx b/inc/Interface_DataMapOfTransientInteger.hxx
index e84add4..b592c03 100644
--- a/inc/Interface_DataMapOfTransientInteger.hxx
+++ b/inc/Interface_DataMapOfTransientInteger.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Transient;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Transient)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Transient)& K) ;
 
 
 
diff --git a/inc/LocOpe_DataMapOfShapePnt.hxx b/inc/LocOpe_DataMapOfShapePnt.hxx
index cdf30e1..c7be395 100644
--- a/inc/LocOpe_DataMapOfShapePnt.hxx
+++ b/inc/LocOpe_DataMapOfShapePnt.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/MAT2d_DataMapOfBiIntInteger.hxx b/inc/MAT2d_DataMapOfBiIntInteger.hxx
index 023b6c5..2fde1e9 100644
--- a/inc/MAT2d_DataMapOfBiIntInteger.hxx
+++ b/inc/MAT2d_DataMapOfBiIntInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MAT2d_BiInt;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const MAT2d_BiInt& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const MAT2d_BiInt& K) ;
 
 
 
diff --git a/inc/MAT2d_DataMapOfBiIntSequenceOfInteger.hxx b/inc/MAT2d_DataMapOfBiIntSequenceOfInteger.hxx
index a0dd86b..159d478 100644
--- a/inc/MAT2d_DataMapOfBiIntSequenceOfInteger.hxx
+++ b/inc/MAT2d_DataMapOfBiIntSequenceOfInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MAT2d_BiInt;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const MAT2d_BiInt& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const MAT2d_BiInt& K) ;
 
 
 
diff --git a/inc/MAT2d_DataMapOfIntegerBisec.hxx b/inc/MAT2d_DataMapOfIntegerBisec.hxx
index 35c610d..9ecc806 100644
--- a/inc/MAT2d_DataMapOfIntegerBisec.hxx
+++ b/inc/MAT2d_DataMapOfIntegerBisec.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Bisector_Bisec;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MAT2d_DataMapOfIntegerConnexion.hxx b/inc/MAT2d_DataMapOfIntegerConnexion.hxx
index 4084ef7..f95fdf8 100644
--- a/inc/MAT2d_DataMapOfIntegerConnexion.hxx
+++ b/inc/MAT2d_DataMapOfIntegerConnexion.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MAT2d_Connexion;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MAT2d_DataMapOfIntegerPnt2d.hxx b/inc/MAT2d_DataMapOfIntegerPnt2d.hxx
index 7304e17..71dc952 100644
--- a/inc/MAT2d_DataMapOfIntegerPnt2d.hxx
+++ b/inc/MAT2d_DataMapOfIntegerPnt2d.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class gp_Pnt2d;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MAT2d_DataMapOfIntegerSequenceOfConnexion.hxx b/inc/MAT2d_DataMapOfIntegerSequenceOfConnexion.hxx
index 8975715..1079ccb 100644
--- a/inc/MAT2d_DataMapOfIntegerSequenceOfConnexion.hxx
+++ b/inc/MAT2d_DataMapOfIntegerSequenceOfConnexion.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MAT2d_SequenceOfConnexion;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MAT2d_DataMapOfIntegerVec2d.hxx b/inc/MAT2d_DataMapOfIntegerVec2d.hxx
index 0940ec9..99aa8b1 100644
--- a/inc/MAT2d_DataMapOfIntegerVec2d.hxx
+++ b/inc/MAT2d_DataMapOfIntegerVec2d.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class gp_Vec2d;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MAT_DataMapOfIntegerArc.hxx b/inc/MAT_DataMapOfIntegerArc.hxx
index a67242b..2eb6fe2 100644
--- a/inc/MAT_DataMapOfIntegerArc.hxx
+++ b/inc/MAT_DataMapOfIntegerArc.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MAT_Arc;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MAT_DataMapOfIntegerBasicElt.hxx b/inc/MAT_DataMapOfIntegerBasicElt.hxx
index b6497ad..f87d8f8 100644
--- a/inc/MAT_DataMapOfIntegerBasicElt.hxx
+++ b/inc/MAT_DataMapOfIntegerBasicElt.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MAT_BasicElt;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MAT_DataMapOfIntegerBisector.hxx b/inc/MAT_DataMapOfIntegerBisector.hxx
index 5dbf1cf..df8eb6f 100644
--- a/inc/MAT_DataMapOfIntegerBisector.hxx
+++ b/inc/MAT_DataMapOfIntegerBisector.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MAT_Bisector;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MAT_DataMapOfIntegerNode.hxx b/inc/MAT_DataMapOfIntegerNode.hxx
index 968e35c..2e091a3 100644
--- a/inc/MAT_DataMapOfIntegerNode.hxx
+++ b/inc/MAT_DataMapOfIntegerNode.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MAT_Node;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MDF_TypeARDriverMap.hxx b/inc/MDF_TypeARDriverMap.hxx
index 9e69767..cdb2efd 100644
--- a/inc/MDF_TypeARDriverMap.hxx
+++ b/inc/MDF_TypeARDriverMap.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Type;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Type)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Type)& K) ;
 
 
 
diff --git a/inc/MDF_TypeASDriverMap.hxx b/inc/MDF_TypeASDriverMap.hxx
index 135d6c2..ee1d763 100644
--- a/inc/MDF_TypeASDriverMap.hxx
+++ b/inc/MDF_TypeASDriverMap.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Type;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Type)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Type)& K) ;
 
 
 
diff --git a/inc/MDF_TypeDriverListMapOfARDriverTable.hxx b/inc/MDF_TypeDriverListMapOfARDriverTable.hxx
index e755a39..7efdb74 100644
--- a/inc/MDF_TypeDriverListMapOfARDriverTable.hxx
+++ b/inc/MDF_TypeDriverListMapOfARDriverTable.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Type;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Type)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Type)& K) ;
 
 
 
diff --git a/inc/MDF_TypeDriverListMapOfASDriverTable.hxx b/inc/MDF_TypeDriverListMapOfASDriverTable.hxx
index ca4b0c6..9048a48 100644
--- a/inc/MDF_TypeDriverListMapOfASDriverTable.hxx
+++ b/inc/MDF_TypeDriverListMapOfASDriverTable.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Type;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Type)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Type)& K) ;
 
 
 
diff --git a/inc/MeshTest_CheckTopology.hxx b/inc/MeshTest_CheckTopology.hxx
index 8631634..7e473db 100644
--- a/inc/MeshTest_CheckTopology.hxx
+++ b/inc/MeshTest_CheckTopology.hxx
@@ -10,6 +10,7 @@
 #include <NCollection_IndexedDataMap.hxx>
 #include <TColStd_SequenceOfInteger.hxx>
 #include <TColStd_SequenceOfReal.hxx>
+#include <Draw_Interpretor.hxx>
 
 //! This class checks topology of the mesh presented by
 //! triangulations of faces.
@@ -34,7 +35,7 @@ public:
     : myShape(theShape) {}
 
   //! performs checking
-  Standard_EXPORT void Perform();
+  Standard_EXPORT void Perform(Draw_Interpretor& di);
 
   //! returns the number of faces with free links
   Standard_Integer NbFacesWithFL() const
diff --git a/inc/MeshVS_DataMapOfColorMapOfInteger.hxx b/inc/MeshVS_DataMapOfColorMapOfInteger.hxx
index d55b86f..c2db9f8 100644
--- a/inc/MeshVS_DataMapOfColorMapOfInteger.hxx
+++ b/inc/MeshVS_DataMapOfColorMapOfInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Quantity_Color;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Quantity_Color& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Quantity_Color& K) ;
 
 
 
diff --git a/inc/MeshVS_DataMapOfHArray1OfSequenceOfInteger.hxx b/inc/MeshVS_DataMapOfHArray1OfSequenceOfInteger.hxx
index b673eaf..f9ac857 100644
--- a/inc/MeshVS_DataMapOfHArray1OfSequenceOfInteger.hxx
+++ b/inc/MeshVS_DataMapOfHArray1OfSequenceOfInteger.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MeshVS_HArray1OfSequenceOfInteger;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MeshVS_DataMapOfIntegerAsciiString.hxx b/inc/MeshVS_DataMapOfIntegerAsciiString.hxx
index 835d2ee..eeeeac1 100644
--- a/inc/MeshVS_DataMapOfIntegerAsciiString.hxx
+++ b/inc/MeshVS_DataMapOfIntegerAsciiString.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MeshVS_DataMapOfIntegerBoolean.hxx b/inc/MeshVS_DataMapOfIntegerBoolean.hxx
index e817015..ea81e2c 100644
--- a/inc/MeshVS_DataMapOfIntegerBoolean.hxx
+++ b/inc/MeshVS_DataMapOfIntegerBoolean.hxx
@@ -25,6 +25,9 @@
 #ifndef _Handle_MeshVS_DataMapNodeOfDataMapOfIntegerBoolean_HeaderFile
 #include <Handle_MeshVS_DataMapNodeOfDataMapOfIntegerBoolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TColStd_MapIntegerHasher;
@@ -83,6 +86,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MeshVS_DataMapOfIntegerColor.hxx b/inc/MeshVS_DataMapOfIntegerColor.hxx
index 388eb08..3a10dfa 100644
--- a/inc/MeshVS_DataMapOfIntegerColor.hxx
+++ b/inc/MeshVS_DataMapOfIntegerColor.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Quantity_Color;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MeshVS_DataMapOfIntegerMaterial.hxx b/inc/MeshVS_DataMapOfIntegerMaterial.hxx
index d42feaa..181fab6 100644
--- a/inc/MeshVS_DataMapOfIntegerMaterial.hxx
+++ b/inc/MeshVS_DataMapOfIntegerMaterial.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Graphic3d_MaterialAspect;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MeshVS_DataMapOfIntegerMeshEntityOwner.hxx b/inc/MeshVS_DataMapOfIntegerMeshEntityOwner.hxx
index eed54ac..ee181c5 100644
--- a/inc/MeshVS_DataMapOfIntegerMeshEntityOwner.hxx
+++ b/inc/MeshVS_DataMapOfIntegerMeshEntityOwner.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MeshVS_MeshEntityOwner;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MeshVS_DataMapOfIntegerOwner.hxx b/inc/MeshVS_DataMapOfIntegerOwner.hxx
index 75a182c..8fe8e00 100644
--- a/inc/MeshVS_DataMapOfIntegerOwner.hxx
+++ b/inc/MeshVS_DataMapOfIntegerOwner.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class SelectMgr_EntityOwner;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MeshVS_DataMapOfIntegerTwoColors.hxx b/inc/MeshVS_DataMapOfIntegerTwoColors.hxx
index a4f78a6..343f127 100644
--- a/inc/MeshVS_DataMapOfIntegerTwoColors.hxx
+++ b/inc/MeshVS_DataMapOfIntegerTwoColors.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TColStd_MapIntegerHasher;
@@ -86,6 +89,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MeshVS_DataMapOfIntegerVector.hxx b/inc/MeshVS_DataMapOfIntegerVector.hxx
index ebd4792..4065dc2 100644
--- a/inc/MeshVS_DataMapOfIntegerVector.hxx
+++ b/inc/MeshVS_DataMapOfIntegerVector.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class gp_Vec;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/MeshVS_DataMapOfTwoColorsMapOfInteger.hxx b/inc/MeshVS_DataMapOfTwoColorsMapOfInteger.hxx
index 5a3081b..5c74568 100644
--- a/inc/MeshVS_DataMapOfTwoColorsMapOfInteger.hxx
+++ b/inc/MeshVS_DataMapOfTwoColorsMapOfInteger.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TColStd_MapOfInteger;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const MeshVS_TwoColors& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const MeshVS_TwoColors& K) ;
 
 
 
diff --git a/inc/MoniTool_DataMapOfShapeTransient.hxx b/inc/MoniTool_DataMapOfShapeTransient.hxx
index 710099a..0a3cb7f 100644
--- a/inc/MoniTool_DataMapOfShapeTransient.hxx
+++ b/inc/MoniTool_DataMapOfShapeTransient.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/MoniTool_DataMapOfTimer.hxx b/inc/MoniTool_DataMapOfTimer.hxx
index 8e884b3..78af780 100644
--- a/inc/MoniTool_DataMapOfTimer.hxx
+++ b/inc/MoniTool_DataMapOfTimer.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class MoniTool_Timer;
@@ -90,6 +93,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_CString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_CString& K) ;
 
 
 
diff --git a/inc/MoniTool_IndexedDataMapOfShapeTransient.hxx b/inc/MoniTool_IndexedDataMapOfShapeTransient.hxx
index d4376ab..4505708 100644
--- a/inc/MoniTool_IndexedDataMapOfShapeTransient.hxx
+++ b/inc/MoniTool_IndexedDataMapOfShapeTransient.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -98,6 +101,10 @@ public:
   Standard_EXPORT    const Handle_Standard_Transient& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     Handle_Standard_Transient& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/NCollection_Haft.h b/inc/NCollection_Haft.h
new file mode 100644
index 0000000..d44c134
--- /dev/null
+++ b/inc/NCollection_Haft.h
@@ -0,0 +1,77 @@
+// File:      NCollection_Haft.h
+// Created:   02.06.11 08:12:42
+// Author:    Andrey BETENEV
+// Copyright: OPEN CASCADE SAS 2011
+
+#if ! defined(_MSC_VER) || ! defined(_MANAGED)
+#error This file is usable only in C++/CLI (.NET) programs
+#endif
+
+#pragma once
+
+using namespace System;
+using namespace System::Collections::Generic;
+
+//! Template CLI class providing the way to encapsulate instance of C++ 
+//! class as a field in the C++/CLI (ref) class. 
+//!
+//! It can be helpful to encapsulate OCCT Handles, maps, arrays, etc.
+//!
+//! Use of variable of the Haft type is very similar to that of encapsulated 
+//! class:
+//! - Default constructor creates default-constructed C++ instance
+//! - Non-default construction is possible by copy or by initialization from
+//!   compatible pointer (e.g. Haft for Handle can be initialized by pointer 
+//!   returned by operator new for a handled class)
+//! - Underlying C++ instance is accessed by operator ()
+
+template <class CPPClass> 
+public ref class NCollection_Haft 
+{
+public:
+  //! Initialize CLI Haft object by default-constructed C++ object
+  NCollection_Haft ()
+  {
+    myPtr = new CPPClass;
+  }
+
+  //! Initialize CLI Haft object by compatible C++ pointer
+  template <class T>
+  NCollection_Haft (const T* aPtr)
+  {
+    myPtr = new CPPClass (aPtr);
+  }
+
+  //! Initialize CLI Haft object by C++ class object
+  NCollection_Haft (const CPPClass& aPtr)
+  {
+    myPtr = new CPPClass (aPtr);
+  }
+
+  //! Destructor - invoked explicitly by delete, or automatically 
+  //! when local variable is scoped out
+  ~NCollection_Haft ()
+  {
+    this->Nullify();
+  }
+
+  //! Finalizer - called undeterministically by garbage collector
+  !NCollection_Haft ()
+  {
+    this->Nullify();
+  }
+
+  //! Function call operator is provided to access underlying C++ object
+  CPPClass& operator () () { return *myPtr; }
+
+protected:
+  //! Invalidate the haft
+  void Nullify ()
+  {
+    delete myPtr;
+    myPtr = 0;
+  }
+
+protected:
+  CPPClass* myPtr;
+};
diff --git a/inc/OpenGl_FontMgr.hxx b/inc/OpenGl_FontMgr.hxx
index a2d7c22..e551c72 100644
--- a/inc/OpenGl_FontMgr.hxx
+++ b/inc/OpenGl_FontMgr.hxx
@@ -1,7 +1,6 @@
 #ifndef OPENGL_FONT_MGR_H
 #define OPENGL_FONT_MGR_H
 
-
 #ifdef WNT
 # include <windows.h>
 # include <stdlib.h>
@@ -26,26 +25,27 @@ void dump_texture();
 
 class OpenGl_FontMgr
 {
-public:
+ public:
   static OpenGl_FontMgr*  instance();
 
   int request_font( const Handle(TCollection_HAsciiString)& fontName,
-    const OSD_FontAspect                   fontAspect,
-    const Standard_Integer                 fontHeight );
+                    const OSD_FontAspect                    fontAspect,
+                    const Standard_Integer                  fontHeight );
 
   void render_text( const Standard_Integer id,
-    const char* text,
-    const Standard_Boolean is2d = 0 );
+    const wchar_t* text,
+    const Standard_Boolean is2d = Standard_False );
 
   //render text by last requested font
-  void render_text( const char* text, const Standard_Boolean is2d = 0 );
+  void render_text( const wchar_t* text,
+    const Standard_Boolean is2d = Standard_False );
 
   //returns direct access to FTGL font
   //Warning: don't change font pointer.
   const FTFont*   fontById( const Standard_Integer id );
 
   //returns width of string
-  Standard_ShortReal computeWidth( const Standard_Integer id, const char* str );
+  Standard_ShortReal computeWidth( const Standard_Integer id, const wchar_t *str );
 
   bool requestFontList( Graphic3d_NListOfHAsciiString& );
 
diff --git a/inc/OpenGl_GraphicDriver.hxx b/inc/OpenGl_GraphicDriver.hxx
index 23d516d..ddb15df 100644
--- a/inc/OpenGl_GraphicDriver.hxx
+++ b/inc/OpenGl_GraphicDriver.hxx
@@ -94,9 +94,6 @@
 #ifndef _Aspect_TypeOfTriedronEcho_HeaderFile
 #include <Aspect_TypeOfTriedronEcho.hxx>
 #endif
-#ifndef _OSD_FontAspect_HeaderFile
-#include <OSD_FontAspect.hxx>
-#endif
 #ifndef _Graphic3d_CGraduatedTrihedron_HeaderFile
 #include <Graphic3d_CGraduatedTrihedron.hxx>
 #endif
@@ -118,6 +115,9 @@
 #ifndef _Aspect_Handle_HeaderFile
 #include <Aspect_Handle.hxx>
 #endif
+#ifndef _Aspect_PrintAlgo_HeaderFile
+#include <Aspect_PrintAlgo.hxx>
+#endif
 #ifndef _Graphic3d_ExportFormat_HeaderFile
 #include <Graphic3d_ExportFormat.hxx>
 #endif
@@ -378,10 +378,8 @@ public:
   Standard_EXPORT     void TriedronErase(const Graphic3d_CView& ACView) ;
   //! call_togl_triedron_echo <br>
   Standard_EXPORT     void TriedronEcho(const Graphic3d_CView& ACView,const Aspect_TypeOfTriedronEcho AType = Aspect_TOTE_NONE) ;
-  //! call_togl_graduatedtrihedron_get <br>
-  Standard_EXPORT     void GetGraduatedTrihedron(const Graphic3d_CView& view,Standard_CString& xname,Standard_CString& yname,Standard_CString& zname,Standard_Boolean& xdrawname,Standard_Boolean& ydrawname,Standard_Boolean& zdrawname,Standard_Boolean& xdrawvalues,Standard_Boolean& ydrawvalues,Standard_Boolean& zdrawvalues,Standard_Boolean& drawgrid,Standard_Boolean& drawaxes,Standard_Integer& nbx,Standard_Integer& nby,Standard_Integer& nbz,Standard_Integer& xoffset,Standard_Integer& yoffset,Standard_Integer& zoffset,Standard_Integer& xaxisoffset,Standard_Integer& yaxisoffset,Standard_Integer& zaxisoffset,Standard_Boolean& xdrawtickmarks,Standard_Boolean& ydrawtickmarks,Standard_Boolean& zdrawtickmarks,Standard_Integer& xtickmarklength,Standard_Integer& ytickmarklength,Standard_Integer& ztickmarklength,Quantity_Color& gridcolor,Quantity_Color& xnamecolor,Quantity_Color& ynamecolor,Quantity_Color& znamecolor,Quantity_Color& xcolor,Quantity_Color& ycolor,Quantity_Color& zcolor,Standard_CString& fontOfNames,OSD_FontAspect& styleOfNames,Standard_Integer& sizeOfNames,Standard_CString& fontOfValues,OSD_FontAspect& styleOfValues,Standard_Integer& sizeOfValues) const;
   //! call_togl_graduatedtrihedron_display <br>
-  Standard_EXPORT     void GraduatedTrihedronDisplay(const Graphic3d_CView& view,Graphic3d_CGraduatedTrihedron& cubic,const Standard_CString xname,const Standard_CString yname,const Standard_CString zname,const Standard_Boolean xdrawname,const Standard_Boolean ydrawname,const Standard_Boolean zdrawname,const Standard_Boolean xdrawvalues,const Standard_Boolean ydrawvalues,const Standard_Boolean zdrawvalues,const Standard_Boolean drawgrid,const Standard_Boolean drawaxes,const Standard_Integer nbx,const Standard_Integer nby,const Standard_Integer nbz,const Standard_Integer xoffset,const Standard_Integer yoffset,const Standard_Integer zoffset,const Standard_Integer xaxisoffset,const Standard_Integer yaxisoffset,const Standard_Integer zaxisoffset,const Standard_Boolean xdrawtickmarks,const Standard_Boolean ydrawtickmarks,const Standard_Boolean zdrawtickmarks,const Standard_Integer xtickmarklength,const Standard_Integer ytickmarklength,const Standard_Integer ztickmarklength,const Quantity_Color& gridcolor,const Quantity_Color& xnamecolor,const Quantity_Color& ynamecolor,const Quantity_Color& znamecolor,const Quantity_Color& xcolor,const Quantity_Color& ycolor,const Quantity_Color& zcolor,const Standard_CString fontOfNames,const OSD_FontAspect styleOfNames,const Standard_Integer sizeOfNames,const Standard_CString fontOfValues,const OSD_FontAspect styleOfValues,const Standard_Integer sizeOfValues) ;
+  Standard_EXPORT     void GraduatedTrihedronDisplay(const Graphic3d_CView& view,const Graphic3d_CGraduatedTrihedron& cubic) ;
   //! call_togl_graduatedtrihedron_erase <br>
   Standard_EXPORT     void GraduatedTrihedronErase(const Graphic3d_CView& view) ;
   //! call_togl_graduatedtrihedron_minmaxvalues <br>
@@ -478,7 +476,18 @@ public:
 //! (background is white) <br>
 //! else set to TRUE for printing with current background color. <br>
 //! <filename>: If != NULL, then the view will be printed to a file. <br>
-  Standard_EXPORT     void Print(const Graphic3d_CView& ACView,const Aspect_CLayer2d& ACUnderLayer,const Aspect_CLayer2d& ACOverLayer,const Aspect_Handle hPrnDC,const Standard_Boolean showBackground,const Standard_CString filename) const;
+//! <printAlgorithm>: Select print algorithm: stretch, tile. <br>
+//! <theScaleFactor>: Scaling coefficient, used internally to scale the <br>
+//! printings accordingly to the scale factor selected in the printer <br>
+//! properties dialog. <br>
+//! Returns Standard_True if the data is passed to the printer, otherwise <br>
+//! Standard_False if the print operation failed due to the printer errors, <br>
+//! or lack of system memory. This might be related to insufficient memory <br>
+//! or some internal errors. All this errors are indicated by the message <br>
+//! boxes (on level of OpenGl_GraphicDriver). <br>
+//! Warning: This function can reuse FBO assigned to the view <br>
+//! Please take it into account if you use it for your purposes; <br>
+  Standard_EXPORT     Standard_Boolean Print(const Graphic3d_CView& ACView,const Aspect_CLayer2d& ACUnderLayer,const Aspect_CLayer2d& ACOverLayer,const Aspect_Handle hPrnDC,const Standard_Boolean showBackground,const Standard_CString filename,const Aspect_PrintAlgo printAlgorithm = Aspect_PA_STRETCH,const Standard_Real theScaleFactor = 1.0) const;
   
   Standard_EXPORT   virtual  void Export(const Standard_CString FileName,const Graphic3d_ExportFormat Format,const Graphic3d_SortType SortType,const Standard_Integer W,const Standard_Integer H,const Graphic3d_CView& View,const Aspect_CLayer2d& Under,const Aspect_CLayer2d& Over,const Standard_Real Precision = 0.005,const Standard_Address ProgressBarFunc = NULL,const Standard_Address ProgressObject = NULL) ;
   //! call_togl_depthtest() <br>
@@ -503,6 +512,11 @@ public:
   Standard_EXPORT     void SetGLLightEnabled(const Graphic3d_CView& view,const Standard_Boolean isEnabled) const;
   //! call_togl_isgllight() <br>
   Standard_EXPORT     Standard_Boolean IsGLLightEnabled(const Graphic3d_CView& view) const;
+  //! Clear visualization data in graphical driver and <br>
+//! stop displaying the primitives array of the graphical group <br>
+//! <theCGroup>. This method is internal and should be used <br>
+//! by Graphic3d_Group only. <br>
+  Standard_EXPORT     void RemovePrimitiveArray(const Graphic3d_CGroup& theCGroup,const Graphic3d_PrimitiveArray& thePArray) ;
 
 
 
diff --git a/inc/OpenGl_PrinterContext.hxx b/inc/OpenGl_PrinterContext.hxx
new file mode 100644
index 0000000..2f117fd
--- /dev/null
+++ b/inc/OpenGl_PrinterContext.hxx
@@ -0,0 +1,116 @@
+// File:      OpenGl_PrinterContext.hxx
+// Created:   20.05.11 10:00:00
+// Author:    Anton POLETAEV
+
+#ifndef _OPENGL_PRINTERCONTEXT_H
+#define _OPENGL_PRINTERCONTEXT_H
+
+#include <MMgt_TShared.hxx>
+#include <Standard.hxx>
+#include <Standard_DefineHandle.hxx>
+#include <Handle_MMgt_TShared.hxx>
+#include <OpenGl_tgl_all.hxx>
+#include <NCollection_DataMap.hxx>
+#include <InterfaceGraphic_Graphic3d.hxx>
+#include <InterfaceGraphic_Visual3d.hxx>
+#include <TColStd_Array2OfReal.hxx>
+
+class Standard_Transient;
+class Handle(Standard_Type);
+class Handle(MMgt_TShared);
+class OpenGl_PrinterContext;
+
+DEFINE_STANDARD_HANDLE(OpenGl_PrinterContext,MMgt_TShared)
+
+//! Class provides specific information for redrawing view to offscreen buffer
+//! on printing. The information is: projection matrixes for tiling,
+//! scaling factors for text/markers and layer viewport dimensions.
+//! The OpenGl_PrinterContext class allows to have only one global instance
+//! that can be accessed by GetPrinterContext() during printing operation. 
+//! The class instance can be created only by call_togl_print().
+class OpenGl_PrinterContext : public MMgt_TShared
+{
+
+public:
+
+  //! Get the PrinterContext instance assigned for OpenGl context.
+  //! Return NULL, if there is no current printing operation and
+  //! there is no assigned instance for "theCtx" OpenGl context.
+  static OpenGl_PrinterContext* GetPrinterContext(GLCONTEXT theCtx);
+
+  //! Get view projection transformation matrix.
+  const TColStd_Array2OfReal& GetProjTransformation () 
+  {
+    return myProjTransform; 
+  }
+
+  //! Get view projection transformation matrix.
+  void GetProjTransformation (GLfloat theMatrix[16]); 
+
+  //! Get text/markers scale factor
+  void GetScale (GLfloat& theScaleX, GLfloat& theScaleY)
+  {
+    theScaleX = myScaleX;
+    theScaleY = myScaleY;
+  }
+
+  //! Get layer viewport dimensions
+  void GetLayerViewport (GLsizei& theViewportX,
+                         GLsizei& theViewportY)
+  {
+    theViewportX = myLayerViewportX;
+    theViewportY = myLayerViewportY;
+  }
+
+private:
+
+  //! Constructor
+  OpenGl_PrinterContext (GLCONTEXT theCtx);
+
+  //! Destructor
+  virtual ~OpenGl_PrinterContext ();
+
+  //! Deactivate current printing context.
+  //! Useful when you need to redraw in usual mode the same OpenGl context
+  //! that you used for printing right after printing, before the 
+  //! OpenGl_PrinterContext instance destroyed.
+  void Deactivate ();
+
+  //! Set view projection transformation matrix for printing/tiling purposes
+  //! theProjTransform parameter should be an 4x4 array.
+  bool SetProjTransformation (TColStd_Array2OfReal& theProjTransform);
+
+  //! Set text scale factor
+  void SetScale (GLfloat theScaleX, GLfloat theScaleY)
+  {
+    myScaleX = theScaleX;
+    myScaleY = theScaleY;
+  }
+
+  //! Set layer viewport dimensions
+  void SetLayerViewport (GLsizei theViewportX,
+                         GLsizei theViewportY) 
+  {
+    myLayerViewportX = theViewportX; 
+    myLayerViewportY = theViewportY;
+  }
+
+private:
+
+  static OpenGl_PrinterContext* g_PrinterContext;
+  static GLCONTEXT g_ContextId;
+  TColStd_Array2OfReal myProjTransform;
+  GLfloat              myScaleX;
+  GLfloat              myScaleY;
+  GLsizei              myLayerViewportX;
+  GLsizei              myLayerViewportY;
+  GLCONTEXT            myCtx;
+
+  // the printer context could be created only in method call_togl_print
+  friend Standard_Boolean call_togl_print (CALL_DEF_VIEW *, CALL_DEF_LAYER *,
+                                           CALL_DEF_LAYER *, 
+                                           const Aspect_Drawable, const int,
+                                           const char*, const int, const float);
+};
+
+#endif
diff --git a/inc/OpenGl_TextRender.hxx b/inc/OpenGl_TextRender.hxx
index 71e7c14..574417e 100644
--- a/inc/OpenGl_TextRender.hxx
+++ b/inc/OpenGl_TextRender.hxx
@@ -11,22 +11,21 @@
 #define NUM_CHAR_FONT 1024
 #define CACHE_SIZE 30
 
-class OpenGl_TextRender{
-
-public:
+class OpenGl_TextRender
+{
+ public:
 
   static OpenGl_TextRender* instance();
   Tint FindFont ( Tchar*, OSD_FontAspect, Tfloat, Tfloat = 1. , Tfloat = 1.);
 
-  void   StringSize( char *text, GLint *width, GLint *ascent, GLint *descent);
-  void   RenderText( const Standard_Integer id, const char* text);
-  void   RenderText( char*, GLuint, int, GLfloat, GLfloat, GLfloat );
-  void   ExportText( char* str, char* fontname, GLfloat height, GLfloat angle, GLint alingment, GLfloat x, GLfloat y, GLfloat z, GLboolean is2d );
+  void StringSize( const wchar_t *text, GLint *width, GLint *ascent, GLint *descent);
+  void RenderText( const wchar_t*, GLuint, int, GLfloat, GLfloat, GLfloat );
+  void ExportText( const wchar_t* text, char* fontname, GLfloat height, GLfloat angle, GLint alingment, GLfloat x, GLfloat y, GLfloat z, GLboolean is2d );
 #ifdef HAVE_GL2PS
   static void getGL2PSFontName(char *src_font, char *ps_font);
 #endif
-  
-private:
+
+ private:
 
   static int curFont  ;
   static int curSize  ;
diff --git a/inc/OpenGl_graduatedtrihedron.hxx b/inc/OpenGl_graduatedtrihedron.hxx
index f8af880..dda77d2 100644
--- a/inc/OpenGl_graduatedtrihedron.hxx
+++ b/inc/OpenGl_graduatedtrihedron.hxx
@@ -1,3 +1,8 @@
+// File:      OpenGl_graduatedtrihedron.hxx
+// Created:   6 March 2011
+// Author:    Sergey ZERCHANINOV
+// Copyright: OPEN CASCADE SA 2011
+
 #ifndef __OPENGL_GRADUATEDTRIHEDRON_H_
 #define __OPENGL_GRADUATEDTRIHEDRON_H_
 
@@ -9,8 +14,9 @@
 #include <InterfaceGraphic_Aspect.hxx>
 #include <InterfaceGraphic_Visual3d.hxx>
 
-extern TStatus call_graduatedtrihedron_get(int WsId, CALL_DEF_GRADUATEDTRIHEDRON* data);
-extern TStatus call_graduatedtrihedron_display(int WsId, CALL_DEF_GRADUATEDTRIHEDRON* data);
+#include <Graphic3d_CGraduatedTrihedron.hxx>
+
+extern TStatus call_graduatedtrihedron_display(int WsId, const Graphic3d_CGraduatedTrihedron &data);
 extern TStatus call_graduatedtrihedron_redraw(int WsId);
 extern TStatus call_graduatedtrihedron_erase(int WsId);
 extern TStatus call_graduatedtrihedron_minmaxvalues(const float xMin,
diff --git a/inc/OpenGl_telem_inquire.hxx b/inc/OpenGl_telem_inquire.hxx
index 523d15a..5f40c63 100644
--- a/inc/OpenGl_telem_inquire.hxx
+++ b/inc/OpenGl_telem_inquire.hxx
@@ -22,7 +22,7 @@ typedef union
   {
     TEL_POINT   ref_pt;  /* reference text point */
     TEL_POINT   anno;    /* annotation pt/offset */
-    Tchar       *string; /* text string */
+    Techar      *string; /* text string */
   } atext3;
 
   Tint            size;
diff --git a/inc/OpenGl_tgl_funcs.hxx b/inc/OpenGl_tgl_funcs.hxx
index ae56562..5b4fad7 100644
--- a/inc/OpenGl_tgl_funcs.hxx
+++ b/inc/OpenGl_tgl_funcs.hxx
@@ -58,6 +58,7 @@ from higher API */
 #include <InterfaceGraphic_Visual3d.hxx>
 
 #include <OSD_FontAspect.hxx>
+#include <Graphic3d_CGraduatedTrihedron.hxx>
 
 /*----------------------------------------------------------------------*/
 /*
@@ -152,7 +153,7 @@ extern  void  call_func_set_anno_char_ht(Tfloat); /* height */
 extern  void  call_func_set_anno_char_up_vec(Tfloat[2]); /* up_vector */
 extern  void  call_func_set_anno_path(Tint); /* path */
 extern  void  call_func_set_anno_align(Tint, Tint); /* hor, ver */
-extern  void  call_func_anno_text_rel3( tel_point, Tchar* );
+extern  void  call_func_anno_text_rel3( tel_point, Techar* );
 extern  void  call_func_dcue_ind(Tint); /* dcid */
 extern  void  call_func_set_do_texturemap(Tint); /* bool */
 extern  void  call_func_set_texture_id(Tint); /* TextureID */
@@ -350,6 +351,7 @@ extern void call_func_eval_map_matrix3( view_map3 *Map, int *err_ind,
 #define  call_func_del_struct          TsmDeleteStructure 
 
 #define call_func_inq_elem_ptr             TsmGetCurElemPtr
+#define call_func_inq_elem                 TsmGetCurElem
 
 /* Declarations  des subroutines  triedron */
 
@@ -383,11 +385,8 @@ void EXPORT call_togl_triedron_echo (
 
 /* Graduated trihedron */
 
-void EXPORT call_togl_graduatedtrihedron_get(CALL_DEF_VIEW* view, 
-                                             CALL_DEF_GRADUATEDTRIHEDRON* cubic);
-
-void EXPORT call_togl_graduatedtrihedron_display(CALL_DEF_VIEW* view, 
-                                                 CALL_DEF_GRADUATEDTRIHEDRON* cubic);
+void EXPORT call_togl_graduatedtrihedron_display(CALL_DEF_VIEW* view,
+                                                 const Graphic3d_CGraduatedTrihedron &cubic);
 
 void EXPORT call_togl_graduatedtrihedron_erase(CALL_DEF_VIEW* view);
 
@@ -1288,7 +1287,7 @@ void EXPORT call_togl_set_text_scale_factors (
 
 void EXPORT call_togl_text2d (
 
-                              char *s,
+                              Techar *s,
                               float x,
                               float y,
                               float height
@@ -1297,7 +1296,7 @@ void EXPORT call_togl_text2d (
 
 void EXPORT call_togl_textsize2d (
 
-                                  char *s,
+                                  Techar *s,
                                   float height,
                                   float *width,
                                   float *ascent,
@@ -1320,6 +1319,13 @@ void EXPORT call_togl_parray (
 
                               );
 
+void EXPORT call_togl_parray_remove (
+
+                                    CALL_DEF_GROUP *agroup,
+                                    CALL_DEF_PARRAY* parray
+
+                                    );
+
 void EXPORT call_togl_userdraw (
 
                                 CALL_DEF_GROUP    *agroup,
@@ -1328,16 +1334,18 @@ void EXPORT call_togl_userdraw (
                                 );
 
 /* ------------------------- */
-void EXPORT call_togl_print (
-
-                             CALL_DEF_VIEW *aview,
-                             CALL_DEF_LAYER *anunderlayer,
-                             CALL_DEF_LAYER *anoverlayer,
-                             const Aspect_Drawable hPrintDC,
-                             const int background,
-                             const char* filename
-
-                             );
+Standard_Boolean EXPORT call_togl_print (
+
+                                         CALL_DEF_VIEW *aview,
+                                         CALL_DEF_LAYER *anunderlayer,
+                                         CALL_DEF_LAYER *anoverlayer,
+                                         const Aspect_Drawable hPrintDC,
+                                         const int background,
+                                         const char* filename,
+                                         const int printalgo = 0,
+                                         const float theScaleFactor = 1.0
+
+                                         );
 
 
 #ifdef BUC61044
diff --git a/inc/PCDM_ReaderStatus.hxx b/inc/PCDM_ReaderStatus.hxx
index a8461a5..e83c4f4 100644
--- a/inc/PCDM_ReaderStatus.hxx
+++ b/inc/PCDM_ReaderStatus.hxx
@@ -23,7 +23,12 @@ PCDM_RS_TypeNotFoundInSchema,
 PCDM_RS_UnrecognizedFileFormat,
 PCDM_RS_MakeFailure,
 PCDM_RS_PermissionDenied,
-PCDM_RS_DriverFailure
+PCDM_RS_DriverFailure,
+PCDM_RS_AlreadyRetrievedAndModified,
+PCDM_RS_AlreadyRetrieved,
+PCDM_RS_UnknownDocument,
+PCDM_RS_WrongResource,
+PCDM_RS_NoModel
 };
 
 #ifndef _Standard_PrimitiveTypes_HeaderFile
diff --git a/inc/PCDM_StorageDriver.hxx b/inc/PCDM_StorageDriver.hxx
index c103b24..b364d06 100644
--- a/inc/PCDM_StorageDriver.hxx
+++ b/inc/PCDM_StorageDriver.hxx
@@ -19,6 +19,12 @@
 #ifndef _TCollection_ExtendedString_HeaderFile
 #include <TCollection_ExtendedString.hxx>
 #endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _PCDM_StoreStatus_HeaderFile
+#include <PCDM_StoreStatus.hxx>
+#endif
 #ifndef _PCDM_Writer_HeaderFile
 #include <PCDM_Writer.hxx>
 #endif
@@ -67,6 +73,14 @@ public:
   Standard_EXPORT     void SetFormat(const TCollection_ExtendedString& aformat) ;
   
   Standard_EXPORT     TCollection_ExtendedString GetFormat() const;
+  
+  Standard_EXPORT     Standard_Boolean IsError() const;
+  
+  Standard_EXPORT     void SetIsError(const Standard_Boolean theIsError) ;
+  
+  Standard_EXPORT     PCDM_StoreStatus GetStoreStatus() const;
+  
+  Standard_EXPORT     void SetStoreStatus(const PCDM_StoreStatus theStoreStatus) ;
 
 
 
@@ -82,6 +96,8 @@ private:
 
 
 TCollection_ExtendedString myFormat;
+Standard_Boolean myIsError;
+PCDM_StoreStatus myStoreStatus;
 
 
 };
diff --git a/inc/PCDM_StoreStatus.hxx b/inc/PCDM_StoreStatus.hxx
new file mode 100644
index 0000000..12ef592
--- /dev/null
+++ b/inc/PCDM_StoreStatus.hxx
@@ -0,0 +1,26 @@
+// This file is generated by WOK (CPPExt).
+// Please do not edit this file; modify original file instead.
+// The copyright and license terms as defined for the original file apply to 
+// this header file considered to be the "object code" form of the original source.
+
+#ifndef _PCDM_StoreStatus_HeaderFile
+#define _PCDM_StoreStatus_HeaderFile
+
+
+enum PCDM_StoreStatus {
+PCDM_SS_OK,
+PCDM_SS_DriverFailure,
+PCDM_SS_WriteFailure,
+PCDM_SS_Failure,
+PCDM_SS_DiskWritingFailure,
+PCDM_SS_UserRightsFailure,
+PCDM_SS_Doc_IsNull,
+PCDM_SS_No_Obj,
+PCDM_SS_Info_Section_Error
+};
+
+#ifndef _Standard_PrimitiveTypes_HeaderFile
+#include <Standard_PrimitiveTypes.hxx>
+#endif
+
+#endif
diff --git a/inc/PTColStd_PersistentTransientMap.hxx b/inc/PTColStd_PersistentTransientMap.hxx
index ef6af72..da0fe92 100644
--- a/inc/PTColStd_PersistentTransientMap.hxx
+++ b/inc/PTColStd_PersistentTransientMap.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Persistent;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Persistent)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Persistent)& K) ;
 
 
 
diff --git a/inc/PTColStd_TransientPersistentMap.hxx b/inc/PTColStd_TransientPersistentMap.hxx
index ea37878..3b6eb37 100644
--- a/inc/PTColStd_TransientPersistentMap.hxx
+++ b/inc/PTColStd_TransientPersistentMap.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Transient;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Transient)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Transient)& K) ;
 
 
 
diff --git a/inc/Plugin_MapOfFunctions.hxx b/inc/Plugin_MapOfFunctions.hxx
index 0469a08..c4ca71b 100644
--- a/inc/Plugin_MapOfFunctions.hxx
+++ b/inc/Plugin_MapOfFunctions.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -86,6 +89,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/Prs2d_DataMapOfAspectRoot.hxx b/inc/Prs2d_DataMapOfAspectRoot.hxx
index fd41139..7198e41 100644
--- a/inc/Prs2d_DataMapOfAspectRoot.hxx
+++ b/inc/Prs2d_DataMapOfAspectRoot.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Prs2d_AspectRoot;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/Prs3d_ShadedShape.gxx b/inc/Prs3d_ShadedShape.gxx
index a2edd47..52e9391 100644
--- a/inc/Prs3d_ShadedShape.gxx
+++ b/inc/Prs3d_ShadedShape.gxx
@@ -52,245 +52,238 @@
 
 
 static Standard_Real GetDeflection(const anyShape&             aShape,
-				   const Handle(Prs3d_Drawer)& aDrawer)
+                                   const Handle(Prs3d_Drawer)& aDrawer)
 {
-  Standard_Real aDeflection;
+  Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
   if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
     Bnd_Box B;
-    BRepBndLib::Add(aShape, B);
+    BRepBndLib::Add(aShape, B, Standard_False);
     if ( ! B.IsVoid() )
     {
       Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
       B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
       aDeflection = MAX3( aXmax-aXmin , aYmax-aYmin , aZmax-aZmin) 
-	* aDrawer->DeviationCoefficient()*4;    
+        * aDrawer->DeviationCoefficient()*4;    
     }
-    else
-      aDeflection = aDrawer->MaximalChordialDeviation();
   }
-  else
-    aDeflection = aDrawer->MaximalChordialDeviation();
-
   return aDeflection;
 }
 
 
 static Standard_Boolean ShadeFromShape(const anyShape&                    aShape,
-				       const Standard_Real                /*defle*/,
-				       const Standard_Boolean             /*share*/,
-				       const Handle (Prs3d_Presentation)& aPresentation,
-				       const Handle (Prs3d_Drawer)&       aDrawer) 
+                                       const Standard_Real                /*defle*/,
+                                       const Standard_Boolean             /*share*/,
+                                       const Handle (Prs3d_Presentation)& aPresentation,
+                                       const Handle (Prs3d_Drawer)&       aDrawer) 
 {
+  anyShadedShapeTool SST;
+  Handle(Poly_Triangulation) T;
+  TopLoc_Location loc;
+  gp_Pnt p;
+  Standard_Integer i,j,k,decal ;
+  Standard_Integer t[3], n[3];
+  Standard_Integer nbTriangles = 0, nbVertices = 0;
 
-    anyShadedShapeTool SST;
-    Handle(Poly_Triangulation) T;
-    TopLoc_Location loc;
-    gp_Pnt p;
-    Standard_Integer i,j,k,decal ;
-    Standard_Integer t[3], n[3];
-    Standard_Integer nbTriangles = 0, nbVertices = 0;
-
-    // precision for compare square distances
-    double dPreci = Precision::Confusion()*Precision::Confusion();
+  // precision for compare square distances
+  double dPreci = Precision::Confusion()*Precision::Confusion();
 
-    if ( !aDrawer->ShadingAspectGlobal() ) {
+  if ( !aDrawer->ShadingAspectGlobal() ) {
 
-      Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
-      if(anyShadedShapeTool::IsClosed(aShape)) {
-        Asp->SuppressBackFace();
-      } else {
-        Asp->AllowBackFace();
-      }
-      Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
+    Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
+    if(anyShadedShapeTool::IsClosed(aShape)) {
+      Asp->SuppressBackFace();
+    } else {
+      Asp->AllowBackFace();
     }
+    Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
+  }
 
 #ifdef G005
-    if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
+  if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
 
+    for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
+      const anyTopFace& F = SST.CurrentFace();
+      T = SST.Triangulation(F, loc);
+      if (!T.IsNull()) {
+        nbTriangles += T->NbTriangles();
+        nbVertices += T->NbNodes();
+      }
+    } 
+
+    if (nbVertices > 2 && nbTriangles > 0) {
+      Handle(Graphic3d_ArrayOfTriangles) parray =
+        new Graphic3d_ArrayOfTriangles(nbVertices,3*nbTriangles,
+          Standard_True,Standard_False,Standard_False,Standard_True);
       for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
         const anyTopFace& F = SST.CurrentFace();
         T = SST.Triangulation(F, loc);
         if (!T.IsNull()) {
-	  nbTriangles += T->NbTriangles();
-	  nbVertices += T->NbNodes();
-	}
-      } 
+          const gp_Trsf& trsf = loc.Transformation();
+          Poly_Connect pc(T);
+          // Extracts vertices & normals from nodes 
+          const TColgp_Array1OfPnt& Nodes = T->Nodes();
+          TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
+          SST.Normal(F, pc, NORMAL);
 
-      if (nbVertices > 2 && nbTriangles > 0) {
-        Handle(Graphic3d_ArrayOfTriangles) parray =
-		new Graphic3d_ArrayOfTriangles(nbVertices,3*nbTriangles,
-		Standard_True,Standard_False,Standard_False,Standard_True);
-        for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
-	  const anyTopFace& F = SST.CurrentFace();
-	  T = SST.Triangulation(F, loc);
-	  if (!T.IsNull()) {
-	    const gp_Trsf& trsf = loc.Transformation();
-	    Poly_Connect pc(T);
-	    // Extracts vertices & normals from nodes 
-	    const TColgp_Array1OfPnt& Nodes = T->Nodes();
-	    TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
-	    SST.Normal(F, pc, NORMAL);
+          decal = parray->VertexNumber();
+          for (i= Nodes.Lower(); i<= Nodes.Upper(); i++) {
+            p = Nodes(i);
+            if( !loc.IsIdentity() ) {
+              p.Transform(trsf);
+              NORMAL(i).Transform(trsf);
+            }
+            parray->AddVertex(p,NORMAL(i));
+          }
+  
+          // Fill parray with vertex and edge visibillity info
+          const Poly_Array1OfTriangle& triangles = T->Triangles();
+          for (i = 1; i <= T->NbTriangles(); i++) {
+            pc.Triangles(i,t[0],t[1],t[2]);
+            if (SST.Orientation(F) == TopAbs_REVERSED) 
+              triangles(i).Get(n[0],n[2],n[1]);
+            else 
+              triangles(i).Get(n[0],n[1],n[2]);
+            gp_Pnt P1 = Nodes(n[0]);
+            gp_Pnt P2 = Nodes(n[1]);
+            gp_Pnt P3 = Nodes(n[2]);
+            gp_Vec V1(P1,P2);
+            if ( V1.SquareMagnitude() > dPreci ) {
+              gp_Vec V2(P2,P3);
+              if ( V2.SquareMagnitude() > dPreci ) {
+                gp_Vec V3(P3,P1);
+                if ( V3.SquareMagnitude() > dPreci ) {
+                  V1.Normalize();
+                  V2.Normalize();
+                  V1.Cross(V2);
+                  if ( V1.SquareMagnitude() > dPreci ) {
+                    parray->AddEdge(n[0]+decal,t[0] == 0);
+                    parray->AddEdge(n[1]+decal,t[1] == 0);
+                    parray->AddEdge(n[2]+decal,t[2] == 0);
+                  }
+                }
+              }
+            }
+          }
+        }
+      }    
+      Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
+      Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
+      Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
+    }
+    return Standard_True;
+  }
+#endif
 
-            decal = parray->VertexNumber();
-	    for (i= Nodes.Lower(); i<= Nodes.Upper(); i++) {
-	      p = Nodes(i);
-	      if( !loc.IsIdentity() ) {
-		p.Transform(trsf);
-		NORMAL(i).Transform(trsf);
-	      }
-	      parray->AddVertex(p,NORMAL(i));
-	    }
-	  
-	    // Fill parray with vertex and edge visibillity info
-	    const Poly_Array1OfTriangle& triangles = T->Triangles();
-	    for (i = 1; i <= T->NbTriangles(); i++) {
-	      pc.Triangles(i,t[0],t[1],t[2]);
-	      if (SST.Orientation(F) == TopAbs_REVERSED) 
-	        triangles(i).Get(n[0],n[2],n[1]);
-	      else 
-	        triangles(i).Get(n[0],n[1],n[2]);
-	      gp_Pnt P1 = Nodes(n[0]);
-	      gp_Pnt P2 = Nodes(n[1]);
-	      gp_Pnt P3 = Nodes(n[2]);
-	      gp_Vec V1(P1,P2);
-	      if ( V1.SquareMagnitude() > dPreci ) {
-	        gp_Vec V2(P2,P3);
-	        if ( V2.SquareMagnitude() > dPreci ) {
-		  gp_Vec V3(P3,P1);
-		  if ( V3.SquareMagnitude() > dPreci ) {
-		    V1.Normalize();
-		    V2.Normalize();
-		    V1.Cross(V2);
-		    if ( V1.SquareMagnitude() > dPreci ) {
-		      parray->AddEdge(n[0]+decal,t[0] == 0);
-		      parray->AddEdge(n[1]+decal,t[1] == 0);
-		      parray->AddEdge(n[2]+decal,t[2] == 0);
-		    }
-		  }
-	        }
-	      }
-	    }
+  // phase de comptage:
+  Standard_Integer nt, nnn, n1, n2, n3, nnv, EI;
+  static Standard_Integer plus1mod3[3] = {1, 2, 0};
+  for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
+    const anyTopFace& F = SST.CurrentFace();
+    T = SST.Triangulation(F, loc);
+    if (!T.IsNull()) {
+      nnn = T->NbTriangles();
+      const TColgp_Array1OfPnt& Nodes = T->Nodes();
+      const Poly_Array1OfTriangle& triangles = T->Triangles();
+      for (nt = 1; nt <= nnn; nt++) {
+        if (SST.Orientation(F) == TopAbs_REVERSED) 
+          triangles(nt).Get(n1,n3,n2);
+        else 
+          triangles(nt).Get(n1,n2,n3);
+        const gp_Pnt& P1 = Nodes(n1);
+        const gp_Pnt& P2 = Nodes(n2);
+        const gp_Pnt& P3 = Nodes(n3);
+        gp_Vec V1(P1,P2);
+        if ( V1.SquareMagnitude() > dPreci ) {
+          gp_Vec V2(P2,P3);
+          if (V2.SquareMagnitude() > dPreci ) {
+            gp_Vec V3(P3,P1);
+            if (V3.SquareMagnitude() > dPreci ) {
+              V1.Normalize();
+              V2.Normalize();
+              V1.Cross(V2);
+              if (V1.SquareMagnitude() > dPreci ) {
+                nbTriangles++;
+              }
+            }
           }
-	}    
-        Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
-        Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
-        Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
+        }
       }
-      return Standard_True;
+      nbVertices += T->NbNodes();
     }
-#endif
+  }      
 
-    // phase de comptage:
-    Standard_Integer nt, nnn, n1, n2, n3, nnv, EI;
-    static Standard_Integer plus1mod3[3] = {1, 2, 0};
+  if (nbVertices > 2 && nbTriangles > 0) {
+    Graphic3d_Array1OfVertexN AVN(1, nbVertices);
+    Aspect_Array1OfEdge AE(1, 3*nbTriangles);
+    
+    EI = 1;
+    nnv = 1;
+    
     for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
       const anyTopFace& F = SST.CurrentFace();
       T = SST.Triangulation(F, loc);
       if (!T.IsNull()) {
-
-	nnn = T->NbTriangles();
-	const TColgp_Array1OfPnt& Nodes = T->Nodes();
-	const Poly_Array1OfTriangle& triangles = T->Triangles();
-	for (nt = 1; nt <= nnn; nt++) {
-	  if (SST.Orientation(F) == TopAbs_REVERSED) 
-	    triangles(nt).Get(n1,n3,n2);
-	  else 
-	    triangles(nt).Get(n1,n2,n3);
-	  const gp_Pnt& P1 = Nodes(n1);
-	  const gp_Pnt& P2 = Nodes(n2);
-	  const gp_Pnt& P3 = Nodes(n3);
-	  gp_Vec V1(P1,P2);
-	  if ( V1.SquareMagnitude() > dPreci ) {
-	    gp_Vec V2(P2,P3);
-	    if (V2.SquareMagnitude() > dPreci ) {
-	      gp_Vec V3(P3,P1);
-	      if (V3.SquareMagnitude() > dPreci ) {
-		V1.Normalize();
-		V2.Normalize();
-		V1.Cross(V2);
-		if (V1.SquareMagnitude() > dPreci ) {
-		  nbTriangles++;
-		}
-	      }
-	    }
-	  }
-	}
-	nbVertices += T->NbNodes();
-      }
-    }      
-
-    if (nbVertices > 2 && nbTriangles > 0) {
-      Graphic3d_Array1OfVertexN AVN(1, nbVertices);
-      Aspect_Array1OfEdge AE(1, 3*nbTriangles);
-      
-      EI = 1;
-      nnv = 1;
-      
-      for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
- 	const anyTopFace& F = SST.CurrentFace();
-	T = SST.Triangulation(F, loc);
-	if (!T.IsNull()) {
-	  Poly_Connect pc(T);
-	  // 1- les noeuds.
-	  const TColgp_Array1OfPnt& Nodes = T->Nodes();
-	  TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
-	  SST.Normal(F, pc, NORMAL);
-	  decal = nnv-1;
-	 
-	  for (j= Nodes.Lower(); j<= Nodes.Upper(); j++) {
-	    p = Nodes(j).Transformed(loc.Transformation());
-	    AVN(nnv).SetCoord(p.X(), p.Y(), p.Z());
-	    AVN(nnv).SetNormal(NORMAL(j).X(), NORMAL(j).Y(), NORMAL(j).Z());
-	    nnv++;
-	  }
-	  // 2- les edges.
-	  nbTriangles = T->NbTriangles();
-	  const Poly_Array1OfTriangle& triangles = T->Triangles();
-	  
-	  for (i = 1; i <= nbTriangles; i++) {
-	    pc.Triangles(i,t[0],t[1],t[2]);
-	    if (SST.Orientation(F) == TopAbs_REVERSED) 
-	      triangles(i).Get(n[0],n[2],n[1]);
-	    else 
-	      triangles(i).Get(n[0],n[1],n[2]);
-	    const gp_Pnt& P1 = Nodes(n[0]);
-	    const gp_Pnt& P2 = Nodes(n[1]);
-	    const gp_Pnt& P3 = Nodes(n[2]);
-	    gp_Vec V1(P1,P2);
-	    if (V1.SquareMagnitude() > 1.e-10) {
-	      gp_Vec V2(P2,P3);
-	      if (V2.SquareMagnitude() > 1.e-10) {
-		gp_Vec V3(P3,P1);
-		if (V3.SquareMagnitude() > 1.e-10) {
-		  V1.Normalize();
-		  V2.Normalize();
-		  V1.Cross(V2);
-		  if (V1.SquareMagnitude() > 1.e-10) {
-		    for (j = 0; j < 3; j++) {
-		      k = plus1mod3[j];
-		      if (t[j] == 0)
-		  	AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_VISIBLE);
-		      else
-			AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_INVISIBLE);
-		      EI++;
-		    }
-		  }
-		}
-	      }
-	    }
-	  }    
+        Poly_Connect pc(T);
+        // 1- les noeuds.
+        const TColgp_Array1OfPnt& Nodes = T->Nodes();
+        TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
+        SST.Normal(F, pc, NORMAL);
+        decal = nnv-1;
+       
+        for (j= Nodes.Lower(); j<= Nodes.Upper(); j++) {
+          p = Nodes(j).Transformed(loc.Transformation());
+          AVN(nnv).SetCoord(p.X(), p.Y(), p.Z());
+          AVN(nnv).SetNormal(NORMAL(j).X(), NORMAL(j).Y(), NORMAL(j).Z());
+          nnv++;
         }
+        // 2- les edges.
+        nbTriangles = T->NbTriangles();
+        const Poly_Array1OfTriangle& triangles = T->Triangles();
+        
+        for (i = 1; i <= nbTriangles; i++) {
+          pc.Triangles(i,t[0],t[1],t[2]);
+          if (SST.Orientation(F) == TopAbs_REVERSED) 
+            triangles(i).Get(n[0],n[2],n[1]);
+          else 
+            triangles(i).Get(n[0],n[1],n[2]);
+          const gp_Pnt& P1 = Nodes(n[0]);
+          const gp_Pnt& P2 = Nodes(n[1]);
+          const gp_Pnt& P3 = Nodes(n[2]);
+          gp_Vec V1(P1,P2);
+          if (V1.SquareMagnitude() > 1.e-10) {
+            gp_Vec V2(P2,P3);
+            if (V2.SquareMagnitude() > 1.e-10) {
+              gp_Vec V3(P3,P1);
+              if (V3.SquareMagnitude() > 1.e-10) {
+                V1.Normalize();
+                V2.Normalize();
+                V1.Cross(V2);
+                if (V1.SquareMagnitude() > 1.e-10) {
+                  for (j = 0; j < 3; j++) {
+                    k = plus1mod3[j];
+                    if (t[j] == 0)
+                      AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_VISIBLE);
+                    else
+                      AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_INVISIBLE);
+                    EI++;
+                  }
+                }
+              }
+            }
+          }
+        }    
       }
-      Prs3d_Root::CurrentGroup(aPresentation)->TriangleSet(AVN, AE);
     }
-    return Standard_True;
+    Prs3d_Root::CurrentGroup(aPresentation)->TriangleSet(AVN, AE);
+  }
+  return Standard_True;
 }
 
 
 
 void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
-			    const anyShape&                    aShape,
-			    const Handle (Prs3d_Drawer)&       aDrawer)
+                            const anyShape&                    aShape,
+                            const Handle (Prs3d_Drawer)&       aDrawer)
 {
 
   if (aShape.IsNull()) return;
@@ -308,13 +301,13 @@ void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
 
       // il faut presenter les edges  isoles.
       for (ex.Init(aShape, TopAbs_EDGE, TopAbs_FACE); ex.More(); ex.Next()) {
-	haselement = Standard_True;
-	B.Add(CO, ex.Current());
+        haselement = Standard_True;
+        B.Add(CO, ex.Current());
       }
       // il faut presenter les vertex isoles.
       for (ex.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next()) {
-	haselement = Standard_True;
-	B.Add(CO, ex.Current());
+        haselement = Standard_True;
+        B.Add(CO, ex.Current());
       }
       if (haselement) StdPrs_WFShape::Add(aPresentation, CO, aDrawer);
     }
@@ -323,15 +316,20 @@ void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
     }
   }
   Standard_Real aDeflection = GetDeflection(aShape, aDrawer);
-  //using of plugin
-  BRepMesh_PDiscretRoot pAlgo;
-  pAlgo=BRepMesh_DiscretFactory::Get().Discret(aShape,
-					       aDeflection,
-					       aDrawer->HLRAngle());
-  if (pAlgo)
-    pAlgo->Perform();
 
-  ShadeFromShape(aShape, aDeflection, Standard_True, aPresentation, aDrawer);
-}
+  // Check if it is possible to avoid unnecessary recomputation 
+  // of shape triangulation
+  if (!BRepTools::Triangulation (aShape, aDeflection))
+  {
+    BRepTools::Clean (aShape);
 
+    // retrieve meshing tool from Factory
+    Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (aShape,
+                                                                                     aDeflection,
+                                                                                     aDrawer->HLRAngle());
+    if (!aMeshAlgo.IsNull())
+      aMeshAlgo->Perform();
+  }
 
+  ShadeFromShape(aShape, aDeflection, Standard_True, aPresentation, aDrawer);
+}
diff --git a/inc/RWStl.hxx b/inc/RWStl.hxx
index 4f25dc9..15cdfa6 100644
--- a/inc/RWStl.hxx
+++ b/inc/RWStl.hxx
@@ -19,8 +19,12 @@
 #ifndef _Handle_StlMesh_Mesh_HeaderFile
 #include <Handle_StlMesh_Mesh.hxx>
 #endif
+#ifndef _Handle_Message_ProgressIndicator_HeaderFile
+#include <Handle_Message_ProgressIndicator.hxx>
+#endif
 class StlMesh_Mesh;
 class OSD_Path;
+class Message_ProgressIndicator;
 
 
 //! This package contains the methods to be used in <br>
@@ -52,23 +56,23 @@ public:
   //! write the meshing in a file following the <br>
 //!         binary format of an STL file. <br>
 //!         Returns false if the cannot be opened; <br>
-  Standard_EXPORT   static  Standard_Boolean WriteBinary(const Handle(StlMesh_Mesh)& aMesh,const OSD_Path& aPath) ;
+  Standard_EXPORT   static  Standard_Boolean WriteBinary(const Handle(StlMesh_Mesh)& aMesh,const OSD_Path& aPath,const Handle(Message_ProgressIndicator)& aProgInd = NULL) ;
   //! write the meshing in a file following the <br>
 //!         Ascii  format of an STL file. <br>
 //!         Returns false if the cannot be opened; <br>
-  Standard_EXPORT   static  Standard_Boolean WriteAscii(const Handle(StlMesh_Mesh)& aMesh,const OSD_Path& aPath) ;
+  Standard_EXPORT   static  Standard_Boolean WriteAscii(const Handle(StlMesh_Mesh)& aMesh,const OSD_Path& aPath,const Handle(Message_ProgressIndicator)& aProgInd = NULL) ;
   //! This method will chwck if the file is a binary <br>
 //!         file or an AsciiFile testing  the 5 first <br>
 //!         characters of the file wich are :"solid" in an <br>
 //!         ascii file. If we do not find that word we assume <br>
 //!         that it is a binary file. <br>
-  Standard_EXPORT   static  Handle_StlMesh_Mesh ReadFile(const OSD_Path& aPath) ;
+  Standard_EXPORT   static  Handle_StlMesh_Mesh ReadFile(const OSD_Path& aPath,const Handle(Message_ProgressIndicator)& aProgInd = NULL) ;
   //! Read a meshing from a binary file <br>
 //!        Raises NoMoreObject from Standard if a statement <br>
 //!        does not contain the right number of tokens <br>
 //!        Raises TypeMisMatch if a token has not the good <br>
 //!        type (often real) <br>
-  Standard_EXPORT   static  Handle_StlMesh_Mesh ReadBinary(const OSD_Path& aPath) ;
+  Standard_EXPORT   static  Handle_StlMesh_Mesh ReadBinary(const OSD_Path& aPath,const Handle(Message_ProgressIndicator)& aProgInd = NULL) ;
   //! Read a meshing from a binary file <br>
 //!        Raises NoMoreObject from Standard if a statement <br>
 //!        does not contain the right number of tokens <br>
@@ -76,7 +80,7 @@ public:
 //!        type (often real) <br>
 //!        Raises MoMoreObject if a file is finished before <br>
 //!        having found the word endsolid; <br>
-  Standard_EXPORT   static  Handle_StlMesh_Mesh ReadAscii(const OSD_Path& aPath) ;
+  Standard_EXPORT   static  Handle_StlMesh_Mesh ReadAscii(const OSD_Path& aPath,const Handle(Message_ProgressIndicator)& aProgInd = NULL) ;
 
 
 
diff --git a/inc/Resource_DataMapOfAsciiStringAsciiString.hxx b/inc/Resource_DataMapOfAsciiStringAsciiString.hxx
index 822c81f..db6d77d 100644
--- a/inc/Resource_DataMapOfAsciiStringAsciiString.hxx
+++ b/inc/Resource_DataMapOfAsciiStringAsciiString.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -83,6 +86,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/Resource_DataMapOfAsciiStringExtendedString.hxx b/inc/Resource_DataMapOfAsciiStringExtendedString.hxx
index c528c01..27cba49 100644
--- a/inc/Resource_DataMapOfAsciiStringExtendedString.hxx
+++ b/inc/Resource_DataMapOfAsciiStringExtendedString.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/STEPCAFControl_DataMapOfLabelExternFile.hxx b/inc/STEPCAFControl_DataMapOfLabelExternFile.hxx
index 5e1aaf1..7683f47 100644
--- a/inc/STEPCAFControl_DataMapOfLabelExternFile.hxx
+++ b/inc/STEPCAFControl_DataMapOfLabelExternFile.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TDF_Label;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TDF_Label& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TDF_Label& K) ;
 
 
 
diff --git a/inc/STEPCAFControl_DataMapOfLabelShape.hxx b/inc/STEPCAFControl_DataMapOfLabelShape.hxx
index 1884ebd..8c1b6bb 100644
--- a/inc/STEPCAFControl_DataMapOfLabelShape.hxx
+++ b/inc/STEPCAFControl_DataMapOfLabelShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TDF_Label;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TDF_Label& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TDF_Label& K) ;
 
 
 
diff --git a/inc/STEPCAFControl_DataMapOfPDExternFile.hxx b/inc/STEPCAFControl_DataMapOfPDExternFile.hxx
index d75f128..4648ead 100644
--- a/inc/STEPCAFControl_DataMapOfPDExternFile.hxx
+++ b/inc/STEPCAFControl_DataMapOfPDExternFile.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class StepBasic_ProductDefinition;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(StepBasic_ProductDefinition)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(StepBasic_ProductDefinition)& K) ;
 
 
 
diff --git a/inc/STEPCAFControl_DataMapOfSDRExternFile.hxx b/inc/STEPCAFControl_DataMapOfSDRExternFile.hxx
index a7cc416..0b2a818 100644
--- a/inc/STEPCAFControl_DataMapOfSDRExternFile.hxx
+++ b/inc/STEPCAFControl_DataMapOfSDRExternFile.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class StepShape_ShapeDefinitionRepresentation;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(StepShape_ShapeDefinitionRepresentation)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(StepShape_ShapeDefinitionRepresentation)& K) ;
 
 
 
diff --git a/inc/STEPCAFControl_DataMapOfShapePD.hxx b/inc/STEPCAFControl_DataMapOfShapePD.hxx
index ddaecfa..88b480b 100644
--- a/inc/STEPCAFControl_DataMapOfShapePD.hxx
+++ b/inc/STEPCAFControl_DataMapOfShapePD.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/STEPCAFControl_DataMapOfShapeSDR.hxx b/inc/STEPCAFControl_DataMapOfShapeSDR.hxx
index 069b2a9..0218e0b 100644
--- a/inc/STEPCAFControl_DataMapOfShapeSDR.hxx
+++ b/inc/STEPCAFControl_DataMapOfShapeSDR.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/STEPConstruct_DataMapOfAsciiStringTransient.hxx b/inc/STEPConstruct_DataMapOfAsciiStringTransient.hxx
index be87565..cd84396 100644
--- a/inc/STEPConstruct_DataMapOfAsciiStringTransient.hxx
+++ b/inc/STEPConstruct_DataMapOfAsciiStringTransient.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/STEPConstruct_DataMapOfPointTransient.hxx b/inc/STEPConstruct_DataMapOfPointTransient.hxx
index 6464eb2..80fad63 100644
--- a/inc/STEPConstruct_DataMapOfPointTransient.hxx
+++ b/inc/STEPConstruct_DataMapOfPointTransient.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class gp_Pnt;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const gp_Pnt& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const gp_Pnt& K) ;
 
 
 
diff --git a/inc/SelectMgr_DataMapOfIntegerSensitive.hxx b/inc/SelectMgr_DataMapOfIntegerSensitive.hxx
index 605a59b..b80ea49 100644
--- a/inc/SelectMgr_DataMapOfIntegerSensitive.hxx
+++ b/inc/SelectMgr_DataMapOfIntegerSensitive.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class SelectBasics_SensitiveEntity;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/SelectMgr_DataMapOfObjectSelectors.hxx b/inc/SelectMgr_DataMapOfObjectSelectors.hxx
index 1952119..fc2a7fc 100644
--- a/inc/SelectMgr_DataMapOfObjectSelectors.hxx
+++ b/inc/SelectMgr_DataMapOfObjectSelectors.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class SelectMgr_SelectableObject;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(SelectMgr_SelectableObject)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(SelectMgr_SelectableObject)& K) ;
 
 
 
diff --git a/inc/SelectMgr_DataMapOfSelectionActivation.hxx b/inc/SelectMgr_DataMapOfSelectionActivation.hxx
index dc6ea1e..fdbb0b5 100644
--- a/inc/SelectMgr_DataMapOfSelectionActivation.hxx
+++ b/inc/SelectMgr_DataMapOfSelectionActivation.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class SelectMgr_Selection;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(SelectMgr_Selection)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(SelectMgr_Selection)& K) ;
 
 
 
diff --git a/inc/SelectMgr_IndexedDataMapOfOwnerCriterion.hxx b/inc/SelectMgr_IndexedDataMapOfOwnerCriterion.hxx
index 91623df..f6703de 100644
--- a/inc/SelectMgr_IndexedDataMapOfOwnerCriterion.hxx
+++ b/inc/SelectMgr_IndexedDataMapOfOwnerCriterion.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -98,6 +101,10 @@ public:
   Standard_EXPORT    const SelectMgr_SortCriterion& FindFromKey(const Handle(SelectBasics_EntityOwner)& K) const;
   
   Standard_EXPORT     SelectMgr_SortCriterion& ChangeFromKey(const Handle(SelectBasics_EntityOwner)& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Handle(SelectBasics_EntityOwner)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Handle(SelectBasics_EntityOwner)& K) ;
 
 
 
diff --git a/inc/ShapeAnalysis_DataMapOfShapeListOfReal.hxx b/inc/ShapeAnalysis_DataMapOfShapeListOfReal.hxx
index 02c8da0..94f46a7 100644
--- a/inc/ShapeAnalysis_DataMapOfShapeListOfReal.hxx
+++ b/inc/ShapeAnalysis_DataMapOfShapeListOfReal.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/ShapeExtend_DataMapOfShapeListOfMsg.hxx b/inc/ShapeExtend_DataMapOfShapeListOfMsg.hxx
index 5784e02..a908784 100644
--- a/inc/ShapeExtend_DataMapOfShapeListOfMsg.hxx
+++ b/inc/ShapeExtend_DataMapOfShapeListOfMsg.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/ShapeExtend_DataMapOfTransientListOfMsg.hxx b/inc/ShapeExtend_DataMapOfTransientListOfMsg.hxx
index cc498da..28a437b 100644
--- a/inc/ShapeExtend_DataMapOfTransientListOfMsg.hxx
+++ b/inc/ShapeExtend_DataMapOfTransientListOfMsg.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Transient;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Transient)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Transient)& K) ;
 
 
 
diff --git a/inc/ShapeFix_DataMapOfShapeBox2d.hxx b/inc/ShapeFix_DataMapOfShapeBox2d.hxx
index 1d3a31f..0e2c5b5 100644
--- a/inc/ShapeFix_DataMapOfShapeBox2d.hxx
+++ b/inc/ShapeFix_DataMapOfShapeBox2d.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/Standard_Atomic.hxx b/inc/Standard_Atomic.hxx
index a57d08f..432e624 100644
--- a/inc/Standard_Atomic.hxx
+++ b/inc/Standard_Atomic.hxx
@@ -10,20 +10,13 @@
 //! By the moment, only operations necessary for reference counter 
 //! in Standard_Transient objects are implemented.
 //! 
-//! Currently only two x86-based configurations (Windows NT with 
-//! MS VC++ compiler and Linix with GCC) are really supported.
-//! Other configurations use non-atomic C equivalent.
+//! This is preffered to use fixed size types "int32_t" / "int64_t" for
+//! correct function declarations however we leave "int" assuming it is 32bits for now.
 
-//! @fn     void Standard_Atomic_Increment (int volatile* var)
-//! @brief  Increments atomically integer variable pointed by var
+#ifndef _Standard_Atomic_HeaderFile
+#define _Standard_Atomic_HeaderFile
 
-//! @fn     int Standard_Atomic_DecrementTest (int volatile* var)
-//! @brief  Decrements atomically integer variable pointed by var;
-//!         returns 1 if result is zero, 0 otherwise
-
-//===================================================
-// Windows NT, MSVC++ compiler
-//===================================================
+#include <Standard_Macro.hxx>
 
 #if defined(_MSC_VER) || defined(__BORLANDC__)
 #ifdef __BORLANDC__
@@ -38,95 +31,83 @@ extern "C" {
   long _InterlockedIncrement(long volatile* lpAddend);
   long _InterlockedDecrement(long volatile* lpAddend);
  }
-# pragma intrinsic (_InterlockedIncrement)
-# pragma intrinsic (_InterlockedDecrement)
+#endif
 #endif
 
-inline void Standard_Atomic_Increment (int volatile* var)
-{
-  _InterlockedIncrement (reinterpret_cast<long volatile*>(var));
-}
-
-inline int Standard_Atomic_DecrementTest (int volatile* var)
-{
-  return _InterlockedDecrement (reinterpret_cast<long volatile*>(var)) == 0;
-}
-
-//===================================================
-// GCC compiler on x86 or x86_64
-// Note: Linux kernel 2.6x provides definitions for atomic operators
-//       in the header file /usr/include/asm/atomic.h,
-//       however these definitions involve specific type atomic_t
-// Note: The same code probably would work for Intel compiler
-//===================================================
-#elif defined(__GNUG__) && (defined(__i386) || defined(__x86_64))
-
-inline void Standard_Atomic_Increment (int volatile* var)
-{
-  // C equivalent:
-  // ++(*var);
-
-  __asm__ __volatile__
-  (
-    "lock incl %0"
-  : "=m"(*var) // out
-  : "m" (*var) // in 
-  );
-}
-
-inline int Standard_Atomic_DecrementTest (int volatile* var)
-{
-  // C equivalent:
-  // return --(*var) == 0;
-
-  unsigned char c;
-  __asm__ __volatile__
-  (
-    "lock decl %0; sete %1"
-  : "=m"(*var), "=qm"(c) // out
-  : "m" (*var)           // in
-  : "memory"
-  );
-  return c != 0;
-}
-
-//===================================================
-// GCC extension for atomic operations
-// http://gcc.gnu.org/wiki/Atomic
-//===================================================
-#elif defined(__GNUG__) && !defined(__sparc_v9) && !defined(__sparc_v9__) // _Atomic_word is not an int on SPARC V9
-
-#include <ext/atomicity.h>
-
-inline void Standard_Atomic_Increment (int* var)
-{
-  // C equivalent:
-  // ++(*var);
-
-  __gnu_cxx::__atomic_add_dispatch(static_cast<_Atomic_word*>(var), 1);
-}
+#if defined(_MSC_VER)
+  // force intrinsic instead of WinAPI calls
+  #pragma intrinsic (_InterlockedIncrement)
+  #pragma intrinsic (_InterlockedDecrement)
+#endif
 
-inline int Standard_Atomic_DecrementTest (int* var)
+//! Increments atomically integer variable pointed by theValue
+//! and returns resulting incremented value.
+static int Standard_Atomic_Increment (volatile int* theValue)
 {
-  // C equivalent:
-  // return --(*var) == 0;
-
-  return __gnu_cxx::__exchange_and_add_dispatch(static_cast<_Atomic_word*>(var),-1) == 1;
-}
-
-//===================================================
-// Default stub implementation, not atomic actually
-//===================================================
+#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+  // mordern g++ compiler (gcc4.4+)
+  // built-in functions available for appropriate CPUs (at least -march=i486 should be specified on x86 platform)
+  return __sync_add_and_fetch (theValue, 1);
+#elif (defined(_WIN32) || defined(__WIN32__))
+  // WinAPI function or MSVC intrinsic
+  return _InterlockedIncrement(reinterpret_cast<long volatile*>(theValue));
+#elif defined(LIN)
+  // use x86 / x86_64 inline assembly (compatibility with alien compilers / old GCC)
+  int anIncResult;
+  __asm__ __volatile__ (
+  #if defined(_OCC64)
+    "lock xaddl %%ebx, (%%rax) \n\t"
+    "incl %%ebx                \n\t"
+    : "=b" (anIncResult)
+    : "a" (theValue), "b" (1)
+    : "cc", "memory");
+  #else
+    "lock xaddl %%eax, (%%ecx) \n\t"
+    "incl %%eax                \n\t"
+    : "=a" (anIncResult)
+    : "c" (theValue), "a" (1)
+    : "memory");
+  #endif
+  return anIncResult;
 #else
-
-inline void Standard_Atomic_Increment (int volatile* var)
-{
-  ++(*var);
+  //#error "Atomic operation doesn't implemented for current platform!"
+  return ++(*theValue);
+#endif
 }
 
-inline int Standard_Atomic_DecrementTest (int volatile* var)
+//! Decrements atomically integer variable pointed by theValue
+//! and returns resulting decremented value.
+static int Standard_Atomic_Decrement (volatile int* theValue)
 {
-  return --(*var) == 0;
+#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+  // mordern g++ compiler (gcc4.4+)
+  // built-in functions available for appropriate CPUs (at least -march=i486 should be specified on x86 platform)
+  return __sync_sub_and_fetch (theValue, 1);
+#elif (defined(_WIN32) || defined(__WIN32__))
+  // WinAPI function or MSVC intrinsic
+  return _InterlockedDecrement(reinterpret_cast<long volatile*>(theValue));
+#elif defined(LIN)
+  // use x86 / x86_64 inline assembly (compatibility with alien compilers / old GCC)
+  int aDecResult;
+  __asm__ __volatile__ (
+  #if defined(_OCC64)
+    "lock xaddl %%ebx, (%%rax) \n\t"
+    "decl %%ebx                \n\t"
+    : "=b" (aDecResult)
+    : "a" (theValue), "b" (-1)
+    : "cc", "memory");
+  #else
+    "lock xaddl %%eax, (%%ecx) \n\t"
+    "decl %%eax                \n\t"
+    : "=a" (aDecResult)
+    : "c" (theValue), "a" (-1)
+    : "memory");
+  #endif
+  return aDecResult;
+#else
+  //#error "Atomic operation doesn't implemented for current platform!"
+  return --(*theValue);
+#endif
 }
 
-#endif
+#endif //_Standard_Atomic_HeaderFile
diff --git a/inc/Standard_CString.hxx b/inc/Standard_CString.hxx
index 2db47a7..aa247f8 100644
--- a/inc/Standard_CString.hxx
+++ b/inc/Standard_CString.hxx
@@ -37,8 +37,6 @@ inline  Standard_Integer Abs (const Standard_Integer);
 inline Standard_CString ShallowCopy (const Standard_CString Value);
 inline Standard_Boolean IsSimilar(const Standard_CString One
 				 ,const Standard_CString Two);
-inline Standard_Boolean IsEqual(const Standard_CString One
-			       ,const Standard_CString Two);
 __Standard_API Standard_Integer HashCode (const Standard_CString,
                            const Standard_Integer);
 inline Standard_Integer HashCode (const Standard_CString,
@@ -85,15 +83,6 @@ inline Standard_Boolean IsSimilar(const Standard_CString One
 }
 
 //============================================================================
-// IsEqual : Returns Standard_True if two CString have the same value
-//============================================================================
-inline Standard_Boolean IsEqual(const Standard_CString One
-			       ,const Standard_CString Two)
-{ 
-  return (One == Two);
-}
-
-//============================================================================
 //==== HashCode of CString. Returns the HashCode itself and
 //====                              the HashCode % Upper
 //============================================================================
diff --git a/inc/Standard_ExtString.hxx b/inc/Standard_ExtString.hxx
index cc0a15a..f3c1a0f 100644
--- a/inc/Standard_ExtString.hxx
+++ b/inc/Standard_ExtString.hxx
@@ -31,25 +31,4 @@ inline Standard_ExtString ShallowCopy (const Standard_ExtString Value)
 //============================================================================
 __Standard_API Standard_Integer HashCode (const Standard_ExtString, const Standard_Integer);
 
-//============================================================================
-//==== IsSimilar : Returns Standard_True if two booleans have the same value
-//============================================================================
-inline Standard_Boolean IsSimilar(const Standard_ExtString One
-				 ,const Standard_ExtString Two)
-{ return One == Two; }
-
-//============================================================================
-// IsEqual : Returns Standard_True if two ExtString have the same value
-//============================================================================
-inline Standard_Boolean IsEqual(const Standard_ExtString One
-			       ,const Standard_ExtString Two)
-{ return One == Two; }
-
-
 #endif
-
-
-
-
-
-
diff --git a/inc/Standard_Static.hxx b/inc/Standard_Static.hxx
deleted file mode 100644
index 6c74692..0000000
--- a/inc/Standard_Static.hxx
+++ /dev/null
@@ -1,14 +0,0 @@
-#define Standard_STATIC(type,name) type& name() \
-                                   { \
-                                     static type _##name; \
-                                     return _##name; \
-                                   }
-
-#define Standard_STATIC_INIT(type,name,initfunc) type& name() \
-                                                 { \
-                                                   static type _##name = initfunc; \
-                                                   return _##name; \
-                                                 }
-
-
-
diff --git a/inc/Standard_StdAllocator.hxx b/inc/Standard_StdAllocator.hxx
old mode 100755
new mode 100644
diff --git a/inc/Standard_Transient_proto.hxx b/inc/Standard_Transient_proto.hxx
index f771a6e..aedc3d0 100644
--- a/inc/Standard_Transient_proto.hxx
+++ b/inc/Standard_Transient_proto.hxx
@@ -86,7 +86,7 @@ class Standard_Transient
 
  private:
 
-   Standard_Integer count;
+   volatile Standard_Integer count;
 };
 
 Standard_EXPORT const Handle(Standard_Type)& STANDARD_TYPE(Standard_Transient);
diff --git a/inc/Standard_Version.hxx b/inc/Standard_Version.hxx
index 3e34ae8..2debc92 100644
--- a/inc/Standard_Version.hxx
+++ b/inc/Standard_Version.hxx
@@ -10,6 +10,7 @@
 //            OCC_VERSION_MAJOR       : (integer) number identifying major version 
 //            OCC_VERSION_MINOR       : (integer) number identifying minor version 
 //            OCC_VERSION_MAINTENANCE : (integer) number identifying maintenance version 
+//            OCC_VERSION_DEVELOPMENT : (no value) if defined, identify development version.
 //            OCC_VERSION             : (real)    complete number (major.minor)
 //            OCC_VERSION_STRING      : (string)  complete number ("major.minor")
 //            OCC_VERSION_HEX         : (hex)     complete number as hex, two positions per each of major, minor, and patch number 
@@ -22,7 +23,8 @@
 // Primary definitions
 #define OCC_VERSION_MAJOR         6
 #define OCC_VERSION_MINOR         5
-#define OCC_VERSION_MAINTENANCE   1
+#define OCC_VERSION_MAINTENANCE   2
+//#define OCC_VERSION_DEVELOPMENT // This line must be commented in any final version (release)
 
 // Derived: version as real and string (major.minor)
 #define OCC_VERSION         6.5
diff --git a/inc/StdSelect_IndexedDataMapOfOwnerPrs.hxx b/inc/StdSelect_IndexedDataMapOfOwnerPrs.hxx
index a7515c5..d6aef8a 100644
--- a/inc/StdSelect_IndexedDataMapOfOwnerPrs.hxx
+++ b/inc/StdSelect_IndexedDataMapOfOwnerPrs.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -101,6 +104,10 @@ public:
   Standard_EXPORT    const Handle_StdSelect_Prs& FindFromKey(const Handle(SelectBasics_EntityOwner)& K) const;
   
   Standard_EXPORT     Handle_StdSelect_Prs& ChangeFromKey(const Handle(SelectBasics_EntityOwner)& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Handle(SelectBasics_EntityOwner)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Handle(SelectBasics_EntityOwner)& K) ;
 
 
 
diff --git a/inc/StepToTopoDS_DataMapOfRI.hxx b/inc/StepToTopoDS_DataMapOfRI.hxx
index 264d66d..2d8a63a 100644
--- a/inc/StepToTopoDS_DataMapOfRI.hxx
+++ b/inc/StepToTopoDS_DataMapOfRI.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class StepRepr_RepresentationItem;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(StepRepr_RepresentationItem)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(StepRepr_RepresentationItem)& K) ;
 
 
 
diff --git a/inc/StepToTopoDS_DataMapOfRINames.hxx b/inc/StepToTopoDS_DataMapOfRINames.hxx
index 892b4f2..3bc2f39 100644
--- a/inc/StepToTopoDS_DataMapOfRINames.hxx
+++ b/inc/StepToTopoDS_DataMapOfRINames.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/StepToTopoDS_DataMapOfTRI.hxx b/inc/StepToTopoDS_DataMapOfTRI.hxx
index 975e9c4..3125156 100644
--- a/inc/StepToTopoDS_DataMapOfTRI.hxx
+++ b/inc/StepToTopoDS_DataMapOfTRI.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class StepShape_TopologicalRepresentationItem;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(StepShape_TopologicalRepresentationItem)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(StepShape_TopologicalRepresentationItem)& K) ;
 
 
 
diff --git a/inc/StepToTopoDS_PointEdgeMap.hxx b/inc/StepToTopoDS_PointEdgeMap.hxx
index 07b0f70..861d9e2 100644
--- a/inc/StepToTopoDS_PointEdgeMap.hxx
+++ b/inc/StepToTopoDS_PointEdgeMap.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class StepToTopoDS_PointPair;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const StepToTopoDS_PointPair& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const StepToTopoDS_PointPair& K) ;
 
 
 
diff --git a/inc/StepToTopoDS_PointVertexMap.hxx b/inc/StepToTopoDS_PointVertexMap.hxx
index ba19b0b..b466c3b 100644
--- a/inc/StepToTopoDS_PointVertexMap.hxx
+++ b/inc/StepToTopoDS_PointVertexMap.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class StepGeom_CartesianPoint;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(StepGeom_CartesianPoint)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(StepGeom_CartesianPoint)& K) ;
 
 
 
diff --git a/inc/StlMesh_Mesh.hxx b/inc/StlMesh_Mesh.hxx
index 0357111..f22a4f6 100644
--- a/inc/StlMesh_Mesh.hxx
+++ b/inc/StlMesh_Mesh.hxx
@@ -119,11 +119,6 @@ public:
 protected:
 
 
-
-
-private: 
-
-
 Standard_Integer nbTriangles;
 Standard_Integer nbVertices;
 StlMesh_SequenceOfMeshDomain domains;
@@ -131,6 +126,11 @@ gp_XYZ xyzmax;
 gp_XYZ xyzmin;
 
 
+private: 
+
+
+
+
 };
 
 
diff --git a/inc/Storage_MapOfCallBack.hxx b/inc/Storage_MapOfCallBack.hxx
index 602a074..4a113e2 100644
--- a/inc/Storage_MapOfCallBack.hxx
+++ b/inc/Storage_MapOfCallBack.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/Storage_MapOfPers.hxx b/inc/Storage_MapOfPers.hxx
index 6be531c..818dcaa 100644
--- a/inc/Storage_MapOfPers.hxx
+++ b/inc/Storage_MapOfPers.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/Storage_PType.hxx b/inc/Storage_PType.hxx
index bd76660..e3851d2 100644
--- a/inc/Storage_PType.hxx
+++ b/inc/Storage_PType.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -93,6 +96,10 @@ public:
   Standard_EXPORT    const Standard_Integer& FindFromKey(const TCollection_AsciiString& K) const;
   
   Standard_EXPORT     Standard_Integer& ChangeFromKey(const TCollection_AsciiString& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/TColStd_DataMapOfAsciiStringInteger.hxx b/inc/TColStd_DataMapOfAsciiStringInteger.hxx
index 6933147..8d31081 100644
--- a/inc/TColStd_DataMapOfAsciiStringInteger.hxx
+++ b/inc/TColStd_DataMapOfAsciiStringInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -83,6 +86,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/TColStd_DataMapOfIntegerInteger.hxx b/inc/TColStd_DataMapOfIntegerInteger.hxx
index 53f1b08..d0ef1ea 100644
--- a/inc/TColStd_DataMapOfIntegerInteger.hxx
+++ b/inc/TColStd_DataMapOfIntegerInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TColStd_MapIntegerHasher;
@@ -83,6 +86,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TColStd_DataMapOfIntegerListOfInteger.hxx b/inc/TColStd_DataMapOfIntegerListOfInteger.hxx
index af7ecec..a3ec85f 100644
--- a/inc/TColStd_DataMapOfIntegerListOfInteger.hxx
+++ b/inc/TColStd_DataMapOfIntegerListOfInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TColStd_ListOfInteger;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TColStd_DataMapOfIntegerReal.hxx b/inc/TColStd_DataMapOfIntegerReal.hxx
index 9a4aeda..5f778a1 100644
--- a/inc/TColStd_DataMapOfIntegerReal.hxx
+++ b/inc/TColStd_DataMapOfIntegerReal.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TColStd_MapIntegerHasher;
@@ -86,6 +89,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TColStd_DataMapOfIntegerTransient.hxx b/inc/TColStd_DataMapOfIntegerTransient.hxx
index d030179..3b73ec4 100644
--- a/inc/TColStd_DataMapOfIntegerTransient.hxx
+++ b/inc/TColStd_DataMapOfIntegerTransient.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Transient;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TColStd_DataMapOfStringInteger.hxx b/inc/TColStd_DataMapOfStringInteger.hxx
index 2c5096a..181f227 100644
--- a/inc/TColStd_DataMapOfStringInteger.hxx
+++ b/inc/TColStd_DataMapOfStringInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_ExtendedString;
@@ -83,6 +86,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_ExtendedString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_ExtendedString& K) ;
 
 
 
diff --git a/inc/TColStd_DataMapOfTransientTransient.hxx b/inc/TColStd_DataMapOfTransientTransient.hxx
index d69980d..fcdf1f1 100644
--- a/inc/TColStd_DataMapOfTransientTransient.hxx
+++ b/inc/TColStd_DataMapOfTransientTransient.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Transient;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Transient)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Transient)& K) ;
 
 
 
diff --git a/inc/TColStd_IndexedDataMapOfTransientTransient.hxx b/inc/TColStd_IndexedDataMapOfTransientTransient.hxx
index af2b76a..e7e6666 100644
--- a/inc/TColStd_IndexedDataMapOfTransientTransient.hxx
+++ b/inc/TColStd_IndexedDataMapOfTransientTransient.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -97,6 +100,10 @@ public:
   Standard_EXPORT    const Handle_Standard_Transient& FindFromKey(const Handle(Standard_Transient)& K) const;
   
   Standard_EXPORT     Handle_Standard_Transient& ChangeFromKey(const Handle(Standard_Transient)& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Handle(Standard_Transient)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Handle(Standard_Transient)& K) ;
 
 
 
diff --git a/inc/TColgp_DataMapOfIntegerCirc2d.hxx b/inc/TColgp_DataMapOfIntegerCirc2d.hxx
index 736eff2..604a231 100644
--- a/inc/TColgp_DataMapOfIntegerCirc2d.hxx
+++ b/inc/TColgp_DataMapOfIntegerCirc2d.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class gp_Circ2d;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TCollection_DataMap.gxx b/inc/TCollection_DataMap.gxx
index 52ed51e..a8adf9b 100644
--- a/inc/TCollection_DataMap.gxx
+++ b/inc/TCollection_DataMap.gxx
@@ -137,56 +137,53 @@ Standard_Boolean TCollection_DataMap::Bind(const TheKey& K, const TheItem& I)
   return Standard_True;
 }
 
+
 //=======================================================================
-//function : Contains
+//function : Remove
 //purpose  : 
 //=======================================================================
 
-Standard_Boolean TCollection_DataMap::IsBound(const TheKey& K) const
+Standard_Boolean TCollection_DataMap::UnBind(const TheKey& K)
 {
   if (IsEmpty()) return Standard_False;
   TCollection_DataMapNode** data = (TCollection_DataMapNode**) myData1;
-  TCollection_DataMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
+  Standard_Integer k = Hasher::HashCode(K,NbBuckets());
+  TCollection_DataMapNode* p = data[k];
+  TCollection_DataMapNode* q = NULL;
   while (p) {
     if (Hasher::IsEqual(p->Key(),K)) {
+      Decrement();
+      if (q) q->Next() = p->Next();
+      else   data[k] = (TCollection_DataMapNode*) p->Next();
+      delete p;
       return Standard_True;
-      }
+    }
+    q = p;
     p = (TCollection_DataMapNode*) p->Next();
   }
   return Standard_False;
 }
-
 //=======================================================================
-//function : Remove
+//function : IsBound
 //purpose  : 
 //=======================================================================
-
-Standard_Boolean TCollection_DataMap::UnBind(const TheKey& K)
+Standard_Boolean TCollection_DataMap::IsBound(const TheKey& K) const
 {
   if (IsEmpty()) return Standard_False;
   TCollection_DataMapNode** data = (TCollection_DataMapNode**) myData1;
-  Standard_Integer k = Hasher::HashCode(K,NbBuckets());
-  TCollection_DataMapNode* p = data[k];
-  TCollection_DataMapNode* q = NULL;
+  TCollection_DataMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
   while (p) {
     if (Hasher::IsEqual(p->Key(),K)) {
-      Decrement();
-      if (q) q->Next() = p->Next();
-      else   data[k] = (TCollection_DataMapNode*) p->Next();
-      delete p;
       return Standard_True;
-    }
-    q = p;
+      }
     p = (TCollection_DataMapNode*) p->Next();
   }
   return Standard_False;
 }
-
 //=======================================================================
 //function : Find
 //purpose  : 
 //=======================================================================
-
 const TheItem& TCollection_DataMap::Find(const TheKey& K) const
 {
   Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_DataMap::Find");
@@ -201,12 +198,10 @@ const TheItem& TCollection_DataMap::Find(const TheKey& K) const
   Standard_NoSuchObject::Raise("TCollection_DataMap::Find");
   return p->Value();
 }
-
 //=======================================================================
 //function : ChangeFind
 //purpose  : 
 //=======================================================================
-
 TheItem& TCollection_DataMap::ChangeFind(const TheKey& K)
 {
   Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_DataMap::ChangeFind");
@@ -221,7 +216,36 @@ TheItem& TCollection_DataMap::ChangeFind(const TheKey& K)
   Standard_NoSuchObject::Raise("TCollection_DataMap::ChangeFind");
   return p->Value();
 }
-
+//modified by NIZNHY-PKV Tue Jul 05 09:54:14 2011f
+//=======================================================================
+//function : Find1
+//purpose  : 
+//=======================================================================
+Standard_Address TCollection_DataMap::Find1(const TheKey& K) const
+{
+  TCollection_DataMap *pMap=(TCollection_DataMap *)this;
+  return pMap->ChangeFind1(K);
+}
+//=======================================================================
+//function : ChangeFind1
+//purpose  : 
+//=======================================================================
+Standard_Address TCollection_DataMap::ChangeFind1(const TheKey& K)
+{
+  if (IsEmpty()) {
+    return NULL;
+  }
+  TCollection_DataMapNode** data = (TCollection_DataMapNode**) myData1;
+  TCollection_DataMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
+  while (p) {
+    if (Hasher::IsEqual(p->Key(),K)) {
+      return (Standard_Address)&p->Value();
+      }
+    p = (TCollection_DataMapNode*)  p->Next();
+  }
+  return NULL;
+}
+//modified by NIZNHY-PKV Tue Jul 05 09:54:18 2011t
 
 
 
diff --git a/inc/TCollection_IndexedDataMap.gxx b/inc/TCollection_IndexedDataMap.gxx
index fe0242a..ebcb7b5 100644
--- a/inc/TCollection_IndexedDataMap.gxx
+++ b/inc/TCollection_IndexedDataMap.gxx
@@ -242,24 +242,6 @@ void TCollection_IndexedDataMap::RemoveLast()
   delete p;
 }
 
-//=======================================================================
-//function : Contains
-//purpose  : 
-//=======================================================================
-
-Standard_Boolean TCollection_IndexedDataMap::Contains(const TheKey& K1) const
-{
-  if (IsEmpty()) return Standard_False;
-  TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
-  Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
-  TCollection_IndexedDataMapNode *p1;
-  p1 = data1[k1];
-  while (p1) {
-    if (Hasher::IsEqual(p1->Key1(),K1)) return Standard_True;
-    p1 = (TCollection_IndexedDataMapNode*) p1->Next();
-  }
-  return Standard_False;
-}
 
 //=======================================================================
 //function : FindKey
@@ -340,12 +322,27 @@ Standard_Integer TCollection_IndexedDataMap::FindIndex(const TheKey& K1) const
   }
   return 0;
 }
-
+//=======================================================================
+//function : Contains
+//purpose  : 
+//=======================================================================
+Standard_Boolean TCollection_IndexedDataMap::Contains(const TheKey& K1) const
+{
+  if (IsEmpty()) return Standard_False;
+  TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
+  Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
+  TCollection_IndexedDataMapNode *p1;
+  p1 = data1[k1];
+  while (p1) {
+    if (Hasher::IsEqual(p1->Key1(),K1)) return Standard_True;
+    p1 = (TCollection_IndexedDataMapNode*) p1->Next();
+  }
+  return Standard_False;
+}
 //=======================================================================
 //function : FindFromKey
 //purpose  : 
 //=======================================================================
-
 const TheItem& TCollection_IndexedDataMap::FindFromKey(const TheKey& K1) const
 {
   Standard_OutOfRange_Raise_if(IsEmpty(),"TCollection_IndexedDataMap::FindFromKey");  
@@ -360,12 +357,10 @@ const TheItem& TCollection_IndexedDataMap::FindFromKey(const TheKey& K1) const
   Standard_OutOfRange::Raise("TCollection_IndexedDataMap::FindFromKey");
   return p1->Value();
 }
-
 //=======================================================================
 //function : ChangeFromKey
 //purpose  : 
 //=======================================================================
-
 TheItem& TCollection_IndexedDataMap::ChangeFromKey(const TheKey& K1)
 {
   Standard_OutOfRange_Raise_if(IsEmpty(),"TCollection_IndexedDataMap::ChangeFromKey");  
@@ -380,8 +375,37 @@ TheItem& TCollection_IndexedDataMap::ChangeFromKey(const TheKey& K1)
   Standard_OutOfRange::Raise("TCollection_IndexedDataMap::ChangeFromKey");
   return p1->Value();
 }
-
-
+//modified by NIZNHY-PKV Tue Jul 05 08:37:03 2011f
+//=======================================================================
+//function : FindFromKey1
+//purpose  : 
+//=======================================================================
+Standard_Address TCollection_IndexedDataMap::FindFromKey1(const TheKey& K1) const
+{
+  TCollection_IndexedDataMap *pMap=(TCollection_IndexedDataMap *)this;
+  return pMap->ChangeFromKey1(K1);
+}
+//=======================================================================
+//function : ChangeFromKey1
+//purpose  : 
+//=======================================================================
+Standard_Address TCollection_IndexedDataMap::ChangeFromKey1(const TheKey& K1)
+{
+  if (IsEmpty()) {
+    return NULL;
+  }
+  TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
+  Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
+  TCollection_IndexedDataMapNode *p1;
+  p1 = data1[k1];
+  while (p1) {
+    if (Hasher::IsEqual(p1->Key1(),K1)) {
+      return (Standard_Address)&p1->Value();
+    }
+    p1 = (TCollection_IndexedDataMapNode*) p1->Next();
+  }
+  return NULL;
+}
 
 // @@SDM: begin
 
diff --git a/inc/TDF_AttributeDataMap.hxx b/inc/TDF_AttributeDataMap.hxx
index f0a74a3..3ef99af 100644
--- a/inc/TDF_AttributeDataMap.hxx
+++ b/inc/TDF_AttributeDataMap.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TDF_Attribute;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(TDF_Attribute)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(TDF_Attribute)& K) ;
 
 
 
diff --git a/inc/TDF_LabelDataMap.hxx b/inc/TDF_LabelDataMap.hxx
index 0861b7b..efc421c 100644
--- a/inc/TDF_LabelDataMap.hxx
+++ b/inc/TDF_LabelDataMap.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TDF_Label;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TDF_Label& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TDF_Label& K) ;
 
 
 
diff --git a/inc/TDF_LabelIntegerMap.hxx b/inc/TDF_LabelIntegerMap.hxx
index 987a1e2..dee3876 100644
--- a/inc/TDF_LabelIntegerMap.hxx
+++ b/inc/TDF_LabelIntegerMap.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TDF_Label;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TDF_Label& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TDF_Label& K) ;
 
 
 
diff --git a/inc/TDF_LabelLabelMap.hxx b/inc/TDF_LabelLabelMap.hxx
index c78b532..3f22d20 100644
--- a/inc/TDF_LabelLabelMap.hxx
+++ b/inc/TDF_LabelLabelMap.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TDF_Label;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TDF_Label& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TDF_Label& K) ;
 
 
 
diff --git a/inc/TDataStd_DataMapOfStringByte.hxx b/inc/TDataStd_DataMapOfStringByte.hxx
index 19cd423..b82283f 100644
--- a/inc/TDataStd_DataMapOfStringByte.hxx
+++ b/inc/TDataStd_DataMapOfStringByte.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_ExtendedString;
@@ -86,6 +89,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_ExtendedString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_ExtendedString& K) ;
 
 
 
diff --git a/inc/TDataStd_DataMapOfStringHArray1OfInteger.hxx b/inc/TDataStd_DataMapOfStringHArray1OfInteger.hxx
index 92d544e..4d47b28 100644
--- a/inc/TDataStd_DataMapOfStringHArray1OfInteger.hxx
+++ b/inc/TDataStd_DataMapOfStringHArray1OfInteger.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_ExtendedString;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_ExtendedString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_ExtendedString& K) ;
 
 
 
diff --git a/inc/TDataStd_DataMapOfStringHArray1OfReal.hxx b/inc/TDataStd_DataMapOfStringHArray1OfReal.hxx
index 5a6fead..dd595c2 100644
--- a/inc/TDataStd_DataMapOfStringHArray1OfReal.hxx
+++ b/inc/TDataStd_DataMapOfStringHArray1OfReal.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_ExtendedString;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_ExtendedString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_ExtendedString& K) ;
 
 
 
diff --git a/inc/TDataStd_DataMapOfStringReal.hxx b/inc/TDataStd_DataMapOfStringReal.hxx
index 9d8e47e..a0c5166 100644
--- a/inc/TDataStd_DataMapOfStringReal.hxx
+++ b/inc/TDataStd_DataMapOfStringReal.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_ExtendedString;
@@ -86,6 +89,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_ExtendedString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_ExtendedString& K) ;
 
 
 
diff --git a/inc/TDataStd_DataMapOfStringString.hxx b/inc/TDataStd_DataMapOfStringString.hxx
index 4b6d212..20e1f2e 100644
--- a/inc/TDataStd_DataMapOfStringString.hxx
+++ b/inc/TDataStd_DataMapOfStringString.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_ExtendedString;
@@ -83,6 +86,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_ExtendedString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_ExtendedString& K) ;
 
 
 
diff --git a/inc/TDocStd_Application.hxx b/inc/TDocStd_Application.hxx
index 08e9919..b5f4857 100644
--- a/inc/TDocStd_Application.hxx
+++ b/inc/TDocStd_Application.hxx
@@ -34,11 +34,11 @@
 #ifndef _Handle_TDocStd_Document_HeaderFile
 #include <Handle_TDocStd_Document.hxx>
 #endif
-#ifndef _CDF_RetrievableStatus_HeaderFile
-#include <CDF_RetrievableStatus.hxx>
+#ifndef _PCDM_ReaderStatus_HeaderFile
+#include <PCDM_ReaderStatus.hxx>
 #endif
-#ifndef _CDF_StoreStatus_HeaderFile
-#include <CDF_StoreStatus.hxx>
+#ifndef _PCDM_StoreStatus_HeaderFile
+#include <PCDM_StoreStatus.hxx>
 #endif
 class Resource_Manager;
 class Standard_NoSuchObject;
@@ -172,21 +172,21 @@ public:
 //! In order not to override a version of aDoc which <br>
 //! is already in memory, this method can be made <br>
 //! to depend on the value returned by IsInSession. <br>
-  Standard_EXPORT     CDF_RetrievableStatus Open(const TCollection_ExtendedString& path,Handle(TDocStd_Document)& aDoc) ;
+  Standard_EXPORT     PCDM_ReaderStatus Open(const TCollection_ExtendedString& path,Handle(TDocStd_Document)& aDoc) ;
   //!  Save the  active document  in the file  <name> in the <br>
 //!           path <path> ; o verwrites  the file  if  it already exists. <br>
-  Standard_EXPORT     CDF_StoreStatus SaveAs(const Handle(TDocStd_Document)& aDoc,const TCollection_ExtendedString& path) ;
+  Standard_EXPORT     PCDM_StoreStatus SaveAs(const Handle(TDocStd_Document)& aDoc,const TCollection_ExtendedString& path) ;
   //! Save aDoc active document. <br>
 //! Exceptions: <br>
 //!  Standard_NotImplemented if the document <br>
 //! was not retrieved in the applicative session by using Open. <br>
-  Standard_EXPORT     CDF_StoreStatus Save(const Handle(TDocStd_Document)& aDoc) ;
+  Standard_EXPORT     PCDM_StoreStatus Save(const Handle(TDocStd_Document)& aDoc) ;
   //!  Save the  active document  in the file  <name> in the <br>
 //!           path <path>  .  overwrite  the file  if  it <br>
 //!          already exist. <br>
-  Standard_EXPORT     CDF_StoreStatus SaveAs(const Handle(TDocStd_Document)& aDoc,const TCollection_ExtendedString& path,TCollection_ExtendedString& theStatusMessage) ;
+  Standard_EXPORT     PCDM_StoreStatus SaveAs(const Handle(TDocStd_Document)& aDoc,const TCollection_ExtendedString& path,TCollection_ExtendedString& theStatusMessage) ;
   //! Save the document overwriting the previous file <br>
-  Standard_EXPORT     CDF_StoreStatus Save(const Handle(TDocStd_Document)& aDoc,TCollection_ExtendedString& theStatusMessage) ;
+  Standard_EXPORT     PCDM_StoreStatus Save(const Handle(TDocStd_Document)& aDoc,TCollection_ExtendedString& theStatusMessage) ;
 
 
 friend class TDocStd_Document;
diff --git a/inc/TDocStd_LabelIDMapDataMap.hxx b/inc/TDocStd_LabelIDMapDataMap.hxx
index e4277ec..20eca6b 100644
--- a/inc/TDocStd_LabelIDMapDataMap.hxx
+++ b/inc/TDocStd_LabelIDMapDataMap.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TDF_Label;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TDF_Label& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TDF_Label& K) ;
 
 
 
diff --git a/inc/TFunction_DataMapOfGUIDDriver.hxx b/inc/TFunction_DataMapOfGUIDDriver.hxx
index aef4d14..5cc603b 100644
--- a/inc/TFunction_DataMapOfGUIDDriver.hxx
+++ b/inc/TFunction_DataMapOfGUIDDriver.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_GUID;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_GUID& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_GUID& K) ;
 
 
 
diff --git a/inc/TFunction_DataMapOfLabelListOfLabel.hxx b/inc/TFunction_DataMapOfLabelListOfLabel.hxx
index 2bed923..b9b1eb4 100644
--- a/inc/TFunction_DataMapOfLabelListOfLabel.hxx
+++ b/inc/TFunction_DataMapOfLabelListOfLabel.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TDF_Label;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TDF_Label& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TDF_Label& K) ;
 
 
 
diff --git a/inc/TNaming_DataMapOfShapePtrRefShape.hxx b/inc/TNaming_DataMapOfShapePtrRefShape.hxx
index d0734cf..66caaf3 100644
--- a/inc/TNaming_DataMapOfShapePtrRefShape.hxx
+++ b/inc/TNaming_DataMapOfShapePtrRefShape.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TNaming_DataMapOfShapeShapesSet.hxx b/inc/TNaming_DataMapOfShapeShapesSet.hxx
index 8c06318..7cea005 100644
--- a/inc/TNaming_DataMapOfShapeShapesSet.hxx
+++ b/inc/TNaming_DataMapOfShapeShapesSet.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TPrsStd_DataMapOfGUIDDriver.hxx b/inc/TPrsStd_DataMapOfGUIDDriver.hxx
index 49fdb61..23a1a1a 100644
--- a/inc/TPrsStd_DataMapOfGUIDDriver.hxx
+++ b/inc/TPrsStd_DataMapOfGUIDDriver.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_GUID;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_GUID& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_GUID& K) ;
 
 
 
diff --git a/inc/TopOpeBRepBuild_DataMapOfShapeListOfShapeListOfShape.hxx b/inc/TopOpeBRepBuild_DataMapOfShapeListOfShapeListOfShape.hxx
index 4804366..1d714c6 100644
--- a/inc/TopOpeBRepBuild_DataMapOfShapeListOfShapeListOfShape.hxx
+++ b/inc/TopOpeBRepBuild_DataMapOfShapeListOfShapeListOfShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepBuild_IndexedDataMapOfShapeVertexInfo.hxx b/inc/TopOpeBRepBuild_IndexedDataMapOfShapeVertexInfo.hxx
index 59ec887..a4b308c 100644
--- a/inc/TopOpeBRepBuild_IndexedDataMapOfShapeVertexInfo.hxx
+++ b/inc/TopOpeBRepBuild_IndexedDataMapOfShapeVertexInfo.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const TopOpeBRepBuild_VertexInfo& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     TopOpeBRepBuild_VertexInfo& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_DataMapOfCheckStatus.hxx b/inc/TopOpeBRepDS_DataMapOfCheckStatus.hxx
index eb7337f..9d889e9 100644
--- a/inc/TopOpeBRepDS_DataMapOfCheckStatus.hxx
+++ b/inc/TopOpeBRepDS_DataMapOfCheckStatus.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TColStd_MapIntegerHasher;
@@ -86,6 +89,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_DataMapOfIntegerListOfInterference.hxx b/inc/TopOpeBRepDS_DataMapOfIntegerListOfInterference.hxx
index 58e5a44..8ef58de 100644
--- a/inc/TopOpeBRepDS_DataMapOfIntegerListOfInterference.hxx
+++ b/inc/TopOpeBRepDS_DataMapOfIntegerListOfInterference.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopOpeBRepDS_ListOfInterference;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_DataMapOfInterferenceListOfInterference.hxx b/inc/TopOpeBRepDS_DataMapOfInterferenceListOfInterference.hxx
index d442ffd..f1f40e0 100644
--- a/inc/TopOpeBRepDS_DataMapOfInterferenceListOfInterference.hxx
+++ b/inc/TopOpeBRepDS_DataMapOfInterferenceListOfInterference.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopOpeBRepDS_Interference;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(TopOpeBRepDS_Interference)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(TopOpeBRepDS_Interference)& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_DataMapOfInterferenceShape.hxx b/inc/TopOpeBRepDS_DataMapOfInterferenceShape.hxx
index f28f384..298a8d8 100644
--- a/inc/TopOpeBRepDS_DataMapOfInterferenceShape.hxx
+++ b/inc/TopOpeBRepDS_DataMapOfInterferenceShape.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopOpeBRepDS_Interference;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(TopOpeBRepDS_Interference)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(TopOpeBRepDS_Interference)& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State.hxx b/inc/TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State.hxx
index 153aec2..a0de82e 100644
--- a/inc/TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State.hxx
+++ b/inc/TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_DataMapOfShapeState.hxx b/inc/TopOpeBRepDS_DataMapOfShapeState.hxx
index 25689ca..92bd79d 100644
--- a/inc/TopOpeBRepDS_DataMapOfShapeState.hxx
+++ b/inc/TopOpeBRepDS_DataMapOfShapeState.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_IndexedDataMapOfShapeWithState.hxx b/inc/TopOpeBRepDS_IndexedDataMapOfShapeWithState.hxx
index baf7fd9..0a691b1 100644
--- a/inc/TopOpeBRepDS_IndexedDataMapOfShapeWithState.hxx
+++ b/inc/TopOpeBRepDS_IndexedDataMapOfShapeWithState.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const TopOpeBRepDS_ShapeWithState& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     TopOpeBRepDS_ShapeWithState& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_IndexedDataMapOfVertexPoint.hxx b/inc/TopOpeBRepDS_IndexedDataMapOfVertexPoint.hxx
index b4fbfe2..b6971f2 100644
--- a/inc/TopOpeBRepDS_IndexedDataMapOfVertexPoint.hxx
+++ b/inc/TopOpeBRepDS_IndexedDataMapOfVertexPoint.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const TopOpeBRepDS_Point& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     TopOpeBRepDS_Point& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_MapOfCurve.hxx b/inc/TopOpeBRepDS_MapOfCurve.hxx
index 3984608..2685158 100644
--- a/inc/TopOpeBRepDS_MapOfCurve.hxx
+++ b/inc/TopOpeBRepDS_MapOfCurve.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopOpeBRepDS_CurveData;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_MapOfIntegerShapeData.hxx b/inc/TopOpeBRepDS_MapOfIntegerShapeData.hxx
index f900e0e..5fb7a72 100644
--- a/inc/TopOpeBRepDS_MapOfIntegerShapeData.hxx
+++ b/inc/TopOpeBRepDS_MapOfIntegerShapeData.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopOpeBRepDS_ShapeData;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_MapOfPoint.hxx b/inc/TopOpeBRepDS_MapOfPoint.hxx
index 1b0e8a3..f39de5d 100644
--- a/inc/TopOpeBRepDS_MapOfPoint.hxx
+++ b/inc/TopOpeBRepDS_MapOfPoint.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopOpeBRepDS_PointData;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_MapOfShapeData.hxx b/inc/TopOpeBRepDS_MapOfShapeData.hxx
index 778174f..e27aa25 100644
--- a/inc/TopOpeBRepDS_MapOfShapeData.hxx
+++ b/inc/TopOpeBRepDS_MapOfShapeData.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const TopOpeBRepDS_ShapeData& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     TopOpeBRepDS_ShapeData& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_MapOfSurface.hxx b/inc/TopOpeBRepDS_MapOfSurface.hxx
index d5637bc..02df138 100644
--- a/inc/TopOpeBRepDS_MapOfSurface.hxx
+++ b/inc/TopOpeBRepDS_MapOfSurface.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopOpeBRepDS_SurfaceData;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TopOpeBRepDS_ShapeSurface.hxx b/inc/TopOpeBRepDS_ShapeSurface.hxx
index bd4a7f9..cdb1036 100644
--- a/inc/TopOpeBRepDS_ShapeSurface.hxx
+++ b/inc/TopOpeBRepDS_ShapeSurface.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepTool_DataMapOfOrientedShapeC2DF.hxx b/inc/TopOpeBRepTool_DataMapOfOrientedShapeC2DF.hxx
index 3cb18e3..b146b23 100644
--- a/inc/TopOpeBRepTool_DataMapOfOrientedShapeC2DF.hxx
+++ b/inc/TopOpeBRepTool_DataMapOfOrientedShapeC2DF.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepTool_DataMapOfShapeListOfC2DF.hxx b/inc/TopOpeBRepTool_DataMapOfShapeListOfC2DF.hxx
index 2fb796a..13eaa23 100644
--- a/inc/TopOpeBRepTool_DataMapOfShapeListOfC2DF.hxx
+++ b/inc/TopOpeBRepTool_DataMapOfShapeListOfC2DF.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepTool_DataMapOfShapeface.hxx b/inc/TopOpeBRepTool_DataMapOfShapeface.hxx
index bbef12b..37ea54b 100644
--- a/inc/TopOpeBRepTool_DataMapOfShapeface.hxx
+++ b/inc/TopOpeBRepTool_DataMapOfShapeface.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepTool_IndexedDataMapOfShapeBox.hxx b/inc/TopOpeBRepTool_IndexedDataMapOfShapeBox.hxx
index 99d19b1..58c9a51 100644
--- a/inc/TopOpeBRepTool_IndexedDataMapOfShapeBox.hxx
+++ b/inc/TopOpeBRepTool_IndexedDataMapOfShapeBox.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const Bnd_Box& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     Bnd_Box& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepTool_IndexedDataMapOfShapeBox2d.hxx b/inc/TopOpeBRepTool_IndexedDataMapOfShapeBox2d.hxx
index 9dcd134..c5ce5a3 100644
--- a/inc/TopOpeBRepTool_IndexedDataMapOfShapeBox2d.hxx
+++ b/inc/TopOpeBRepTool_IndexedDataMapOfShapeBox2d.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const Bnd_Box2d& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     Bnd_Box2d& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepTool_IndexedDataMapOfShapeconnexity.hxx b/inc/TopOpeBRepTool_IndexedDataMapOfShapeconnexity.hxx
index 3cd9cfa..6525536 100644
--- a/inc/TopOpeBRepTool_IndexedDataMapOfShapeconnexity.hxx
+++ b/inc/TopOpeBRepTool_IndexedDataMapOfShapeconnexity.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const TopOpeBRepTool_connexity& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     TopOpeBRepTool_connexity& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRepTool_IndexedDataMapOfSolidClassifier.hxx b/inc/TopOpeBRepTool_IndexedDataMapOfSolidClassifier.hxx
index 2da9d7d..cc405d5 100644
--- a/inc/TopOpeBRepTool_IndexedDataMapOfSolidClassifier.hxx
+++ b/inc/TopOpeBRepTool_IndexedDataMapOfSolidClassifier.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const BRepClass3d_SolidClassifier& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     BRepClass3d_SolidClassifier& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopOpeBRep_DataMapOfTopolTool.hxx b/inc/TopOpeBRep_DataMapOfTopolTool.hxx
index 2872e6b..9d10272 100644
--- a/inc/TopOpeBRep_DataMapOfTopolTool.hxx
+++ b/inc/TopOpeBRep_DataMapOfTopolTool.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -88,6 +91,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopTools_DataMapOfIntegerListOfShape.hxx b/inc/TopTools_DataMapOfIntegerListOfShape.hxx
index 2338274..7f653d8 100644
--- a/inc/TopTools_DataMapOfIntegerListOfShape.hxx
+++ b/inc/TopTools_DataMapOfIntegerListOfShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopTools_ListOfShape;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TopTools_DataMapOfIntegerShape.hxx b/inc/TopTools_DataMapOfIntegerShape.hxx
index b1448fe..95ef0d4 100644
--- a/inc/TopTools_DataMapOfIntegerShape.hxx
+++ b/inc/TopTools_DataMapOfIntegerShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/TopTools_DataMapOfOrientedShapeInteger.hxx b/inc/TopTools_DataMapOfOrientedShapeInteger.hxx
index 830fa3a..51bcc8c 100644
--- a/inc/TopTools_DataMapOfOrientedShapeInteger.hxx
+++ b/inc/TopTools_DataMapOfOrientedShapeInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopTools_DataMapOfOrientedShapeShape.hxx b/inc/TopTools_DataMapOfOrientedShapeShape.hxx
index 6c45ec2..b84629a 100644
--- a/inc/TopTools_DataMapOfOrientedShapeShape.hxx
+++ b/inc/TopTools_DataMapOfOrientedShapeShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopTools_DataMapOfShapeInteger.hxx b/inc/TopTools_DataMapOfShapeInteger.hxx
index ffa11ea..c8092bb 100644
--- a/inc/TopTools_DataMapOfShapeInteger.hxx
+++ b/inc/TopTools_DataMapOfShapeInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopTools_DataMapOfShapeListOfInteger.hxx b/inc/TopTools_DataMapOfShapeListOfInteger.hxx
index 94dd0ee..84c5c5b 100644
--- a/inc/TopTools_DataMapOfShapeListOfInteger.hxx
+++ b/inc/TopTools_DataMapOfShapeListOfInteger.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopTools_DataMapOfShapeListOfShape.hxx b/inc/TopTools_DataMapOfShapeListOfShape.hxx
index e99652b..2957dc8 100644
--- a/inc/TopTools_DataMapOfShapeListOfShape.hxx
+++ b/inc/TopTools_DataMapOfShapeListOfShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopTools_DataMapOfShapeReal.hxx b/inc/TopTools_DataMapOfShapeReal.hxx
index 2cf6e4c..7fc2222 100644
--- a/inc/TopTools_DataMapOfShapeReal.hxx
+++ b/inc/TopTools_DataMapOfShapeReal.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopTools_DataMapOfShapeSequenceOfShape.hxx b/inc/TopTools_DataMapOfShapeSequenceOfShape.hxx
index 6d5369a..bb09c3b 100644
--- a/inc/TopTools_DataMapOfShapeSequenceOfShape.hxx
+++ b/inc/TopTools_DataMapOfShapeSequenceOfShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopTools_DataMapOfShapeShape.hxx b/inc/TopTools_DataMapOfShapeShape.hxx
index 180904d..d8ee32e 100644
--- a/inc/TopTools_DataMapOfShapeShape.hxx
+++ b/inc/TopTools_DataMapOfShapeShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopTools_IndexedDataMapOfShapeAddress.hxx b/inc/TopTools_IndexedDataMapOfShapeAddress.hxx
index 4dde3cf..0aeb4cc 100644
--- a/inc/TopTools_IndexedDataMapOfShapeAddress.hxx
+++ b/inc/TopTools_IndexedDataMapOfShapeAddress.hxx
@@ -97,6 +97,10 @@ public:
   Standard_EXPORT    const Standard_Address& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     Standard_Address& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopTools_IndexedDataMapOfShapeListOfShape.hxx b/inc/TopTools_IndexedDataMapOfShapeListOfShape.hxx
index 3a4f2c1..180f34e 100644
--- a/inc/TopTools_IndexedDataMapOfShapeListOfShape.hxx
+++ b/inc/TopTools_IndexedDataMapOfShapeListOfShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -95,6 +98,10 @@ public:
   Standard_EXPORT    const TopTools_ListOfShape& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     TopTools_ListOfShape& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/TopTools_IndexedDataMapOfShapeShape.hxx b/inc/TopTools_IndexedDataMapOfShapeShape.hxx
index 40babe9..7504647 100644
--- a/inc/TopTools_IndexedDataMapOfShapeShape.hxx
+++ b/inc/TopTools_IndexedDataMapOfShapeShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -94,6 +97,10 @@ public:
   Standard_EXPORT    const TopoDS_Shape& FindFromKey(const TopoDS_Shape& K) const;
   
   Standard_EXPORT     TopoDS_Shape& ChangeFromKey(const TopoDS_Shape& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/Transfer_TransferMapOfProcessForFinder.hxx b/inc/Transfer_TransferMapOfProcessForFinder.hxx
index a247f66..b56d648 100644
--- a/inc/Transfer_TransferMapOfProcessForFinder.hxx
+++ b/inc/Transfer_TransferMapOfProcessForFinder.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -101,6 +104,10 @@ public:
   Standard_EXPORT    const Handle_Transfer_Binder& FindFromKey(const Handle(Transfer_Finder)& K) const;
   
   Standard_EXPORT     Handle_Transfer_Binder& ChangeFromKey(const Handle(Transfer_Finder)& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Handle(Transfer_Finder)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Handle(Transfer_Finder)& K) ;
 
 
 
diff --git a/inc/Transfer_TransferMapOfProcessForTransient.hxx b/inc/Transfer_TransferMapOfProcessForTransient.hxx
index 3a350e2..3275c72 100644
--- a/inc/Transfer_TransferMapOfProcessForTransient.hxx
+++ b/inc/Transfer_TransferMapOfProcessForTransient.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_OutOfRange;
 class Standard_NoSuchObject;
@@ -101,6 +104,10 @@ public:
   Standard_EXPORT    const Handle_Transfer_Binder& FindFromKey(const Handle(Standard_Transient)& K) const;
   
   Standard_EXPORT     Handle_Transfer_Binder& ChangeFromKey(const Handle(Standard_Transient)& K) ;
+  
+  Standard_EXPORT     Standard_Address FindFromKey1(const Handle(Standard_Transient)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFromKey1(const Handle(Standard_Transient)& K) ;
 
 
 
diff --git a/inc/V3d_View.hxx b/inc/V3d_View.hxx
index fb2e325..0ed3dcd 100644
--- a/inc/V3d_View.hxx
+++ b/inc/V3d_View.hxx
@@ -163,9 +163,15 @@
 #ifndef _OSD_FontAspect_HeaderFile
 #include <OSD_FontAspect.hxx>
 #endif
+#ifndef _TCollection_ExtendedString_HeaderFile
+#include <TCollection_ExtendedString.hxx>
+#endif
 #ifndef _Quantity_Color_HeaderFile
 #include <Quantity_Color.hxx>
 #endif
+#ifndef _TCollection_AsciiString_HeaderFile
+#include <TCollection_AsciiString.hxx>
+#endif
 #ifndef _Handle_Aspect_ColorScale_HeaderFile
 #include <Handle_Aspect_ColorScale.hxx>
 #endif
@@ -199,6 +205,9 @@
 #ifndef _Aspect_Handle_HeaderFile
 #include <Aspect_Handle.hxx>
 #endif
+#ifndef _Aspect_PrintAlgo_HeaderFile
+#include <Aspect_PrintAlgo.hxx>
+#endif
 #ifndef _Handle_Image_PixMap_HeaderFile
 #include <Handle_Image_PixMap.hxx>
 #endif
@@ -221,6 +230,8 @@ class Quantity_Color;
 class Graphic3d_TextureEnv;
 class V3d_Light;
 class V3d_Plane;
+class TCollection_ExtendedString;
+class TCollection_AsciiString;
 class Aspect_ColorScale;
 class Visual3d_ViewOrientation;
 class Visual3d_ViewMapping;
@@ -401,9 +412,9 @@ public:
   //! Highlights the echo zone of the Triedron. <br>
   Standard_EXPORT     void TriedronEcho(const Aspect_TypeOfTriedronEcho AType = Aspect_TOTE_NONE) ;
   //! Returns data of a graduated trihedron. <br>
-  Standard_EXPORT     void GetGraduatedTrihedron(Standard_CString& xname,Standard_CString& yname,Standard_CString& zname,Standard_Boolean& xdrawname,Standard_Boolean& ydrawname,Standard_Boolean& zdrawname,Standard_Boolean& xdrawvalues,Standard_Boolean& ydrawvalues,Standard_Boolean& zdrawvalues,Standard_Boolean& drawgrid,Standard_Boolean& drawaxes,Standard_Integer& nbx,Standard_Integer& nby,Standard_Integer& nbz,Standard_Integer& xoffset,Standard_Integer& yoffset,Standard_Integer& zoffset,Standard_Integer& xaxisoffset,Standard_Integer& yaxisoffset,Standard_Integer& zaxisoffset,Standard_Boolean& xdrawtickmarks,Standard_Boolean& ydrawtickmarks,Standard_Boolean& zdrawtickmarks,Standard_Integer& xtickmarklength,Standard_Integer& ytickmarklength,Standard_Integer& ztickmarklength,Quantity_Color& gridcolor,Quantity_Color& xnamecolor,Quantity_Color& ynamecolor,Quantity_Color& znamecolor,Quantity_Color& xcolor,Quantity_Color& ycolor,Quantity_Color& zcolor,Standard_CString& fontOfNames,OSD_FontAspect& styleOfNames,Standard_Integer& sizeOfNames,Standard_CString& fontOfValues,OSD_FontAspect& styleOfValues,Standard_Integer& sizeOfValues) const;
+  Standard_EXPORT     void GetGraduatedTrihedron(TCollection_ExtendedString& xname,TCollection_ExtendedString& yname,TCollection_ExtendedString& zname,Standard_Boolean& xdrawname,Standard_Boolean& ydrawname,Standard_Boolean& zdrawname,Standard_Boolean& xdrawvalues,Standard_Boolean& ydrawvalues,Standard_Boolean& zdrawvalues,Standard_Boolean& drawgrid,Standard_Boolean& drawaxes,Standard_Integer& nbx,Standard_Integer& nby,Standard_Integer& nbz,Standard_Integer& xoffset,Standard_Integer& yoffset,Standard_Integer& zoffset,Standard_Integer& xaxisoffset,Standard_Integer& yaxisoffset,Standard_Integer& zaxisoffset,Standard_Boolean& xdrawtickmarks,Standard_Boolean& ydrawtickmarks,Standard_Boolean& zdrawtickmarks,Standard_Integer& xtickmarklength,Standard_Integer& ytickmarklength,Standard_Integer& ztickmarklength,Quantity_Color& gridcolor,Quantity_Color& xnamecolor,Quantity_Color& ynamecolor,Quantity_Color& znamecolor,Quantity_Color& xcolor,Quantity_Color& ycolor,Quantity_Color& zcolor,TCollection_AsciiString& fontOfNames,OSD_FontAspect& styleOfNames,Standard_Integer& sizeOfNames,TCollection_AsciiString& fontOfValues,OSD_FontAspect& styleOfValues,Standard_Integer& sizeOfValues) const;
   //! Displays a graduated trihedron. <br>
-  Standard_EXPORT     void GraduatedTrihedronDisplay(const Standard_CString xname = "X\0",const Standard_CString yname = "Y\0",const Standard_CString zname = "Z\0",const Standard_Boolean xdrawname = Standard_True,const Standard_Boolean ydrawname = Standard_True,const Standard_Boolean zdrawname = Standard_True,const Standard_Boolean xdrawvalues = Standard_True,const Standard_Boolean ydrawvalues = Standard_True,const Standard_Boolean zdrawvalues = Standard_True,const Standard_Boolean drawgrid = Standard_True,const Standard_Boolean drawaxes = Standard_True,const Standard_Integer nbx = 3,const Standard_Integer nby = 3,const Standard_Integer nbz = 3,const Standard_Integer xoffset = 10,const Standard_Integer yoffset = 10,const Standard_Integer zoffset = 10,const Standard_Integer xaxisoffset = 30,const Standard_Integer yaxisoffset = 30,const Standard_Integer zaxisoffset = 30,const Standard_Boolean xdrawtickmarks = Standard_True,const Standard_Boolean ydrawtickmarks = Standard_True,const Standard_Boolean zdrawtickmarks = Standard_True,const Standard_Integer xtickmarklength = 10,const Standard_Integer ytickmarklength = 10,const Standard_Integer ztickmarklength = 10,const Quantity_Color& gridcolor = Quantity_NOC_WHITE,const Quantity_Color& xnamecolor = Quantity_NOC_RED,const Quantity_Color& ynamecolor = Quantity_NOC_GREEN,const Quantity_Color& znamecolor = Quantity_NOC_BLUE1,const Quantity_Color& xcolor = Quantity_NOC_RED,const Quantity_Color& ycolor = Quantity_NOC_GREEN,const Quantity_Color& zcolor = Quantity_NOC_BLUE1,const Standard_CString fontOfNames = "Arial",const OSD_FontAspect styleOfNames = OSD_FA_Bold,const Standard_Integer sizeOfNames = 12,const Standard_CString fontOfValues = "Arial",const OSD_FontAspect styleOfValues = OSD_FA_Regular,const Standard_Integer sizeOfValues = 12) ;
+  Standard_EXPORT     void GraduatedTrihedronDisplay(const TCollection_ExtendedString& xname = "X",const TCollection_ExtendedString& yname = "Y",const TCollection_ExtendedString& zname = "Z",const Standard_Boolean xdrawname = Standard_True,const Standard_Boolean ydrawname = Standard_True,const Standard_Boolean zdrawname = Standard_True,const Standard_Boolean xdrawvalues = Standard_True,const Standard_Boolean ydrawvalues = Standard_True,const Standard_Boolean zdrawvalues = Standard_True,const Standard_Boolean drawgrid = Standard_True,const Standard_Boolean drawaxes = Standard_True,const Standard_Integer nbx = 3,const Standard_Integer nby = 3,const Standard_Integer nbz = 3,const Standard_Integer xoffset = 10,const Standard_Integer yoffset = 10,const Standard_Integer zoffset = 10,const Standard_Integer xaxisoffset = 30,const Standard_Integer yaxisoffset = 30,const Standard_Integer zaxisoffset = 30,const Standard_Boolean xdrawtickmarks = Standard_True,const Standard_Boolean ydrawtickmarks = Standard_True,const Standard_Boolean zdrawtickmarks = Standard_True,const Standard_Integer xtickmarklength = 10,const Standard_Integer ytickmarklength = 10,const Standard_Integer ztickmarklength = 10,const Quantity_Color& gridcolor = Quantity_NOC_WHITE,const Quantity_Color& xnamecolor = Quantity_NOC_RED,const Quantity_Color& ynamecolor = Quantity_NOC_GREEN,const Quantity_Color& znamecolor = Quantity_NOC_BLUE1,const Quantity_Color& xcolor = Quantity_NOC_RED,const Quantity_Color& ycolor = Quantity_NOC_GREEN,const Quantity_Color& zcolor = Quantity_NOC_BLUE1,const TCollection_AsciiString& fontOfNames = "Arial",const OSD_FontAspect styleOfNames = OSD_FA_Bold,const Standard_Integer sizeOfNames = 12,const TCollection_AsciiString& fontOfValues = "Arial",const OSD_FontAspect styleOfValues = OSD_FA_Regular,const Standard_Integer sizeOfValues = 12) ;
   //! Erases a graduated trihedron from the view. <br>
   Standard_EXPORT     void GraduatedTrihedronErase() ;
   
@@ -897,8 +908,17 @@ public:
 //! (background is white) <br>
 //! else set to TRUE for printing with current background color. <br>
 //! <filename>: If != NULL, then the view will be printed to a file. <br>
+//! <printAlgorithm>: If you want to select the print algorithm, then you can <br>
+//! specify one of existing algorithms: Aspect_PA_STRETCH, Aspect_PA_TILE. <br>
+//! Returns Standard_True if the data is passed to the printer, otherwise <br>
+//! Standard_False if the print operation failed. This might be related to <br>
+//! insufficient memory or some internal errors. All this errors are <br>
+//! indicated by the message boxes (on level of OpenGl_GraphicDriver). <br>
+//!  Warning: This function can reuse FBO assigned to the <br>
+//!  view on level of OpenGl_GraphicDriver; Please take it into account if <br>
+//!  you use it for your purposes; <br>
 //!  Warning: Works only under Windows. <br>
-  Standard_EXPORT     void Print(const Aspect_Handle hPrnDC = NULL,const Standard_Boolean showDialog = Standard_True,const Standard_Boolean showBackground = Standard_True,const Standard_CString filename = NULL) const;
+  Standard_EXPORT     Standard_Boolean Print(const Aspect_Handle hPrnDC = NULL,const Standard_Boolean showDialog = Standard_True,const Standard_Boolean showBackground = Standard_True,const Standard_CString filename = NULL,const Aspect_PrintAlgo printAlgorithm = Aspect_PA_STRETCH) const;
   //! dump the full contents of the view <br>
 //!        to a pixmap of pixel size <theWidth>*<theHeight> and <br>
 //!        buffer type <theBufferType>. If <theForceCentered> is true <br>
diff --git a/inc/Viewer2dTest_DataMapOfText.hxx b/inc/Viewer2dTest_DataMapOfText.hxx
index 0b389f5..ea3ea6c 100644
--- a/inc/Viewer2dTest_DataMapOfText.hxx
+++ b/inc/Viewer2dTest_DataMapOfText.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/Visual3d_View.hxx b/inc/Visual3d_View.hxx
index d862a46..9352a9a 100644
--- a/inc/Visual3d_View.hxx
+++ b/inc/Visual3d_View.hxx
@@ -55,6 +55,9 @@
 #ifndef _Graphic3d_CBitFields8_HeaderFile
 #include <Graphic3d_CBitFields8.hxx>
 #endif
+#ifndef _Graphic3d_CGraduatedTrihedron_HeaderFile
+#include <Graphic3d_CGraduatedTrihedron.hxx>
+#endif
 #ifndef _Graphic3d_DataStructureManager_HeaderFile
 #include <Graphic3d_DataStructureManager.hxx>
 #endif
@@ -127,6 +130,9 @@
 #ifndef _Aspect_Handle_HeaderFile
 #include <Aspect_Handle.hxx>
 #endif
+#ifndef _Aspect_PrintAlgo_HeaderFile
+#include <Aspect_PrintAlgo.hxx>
+#endif
 #ifndef _Graphic3d_PtrFrameBuffer_HeaderFile
 #include <Graphic3d_PtrFrameBuffer.hxx>
 #endif
@@ -151,7 +157,9 @@ class Visual3d_Layer;
 class Aspect_Background;
 class Aspect_GradientBackground;
 class TColStd_Array2OfReal;
+class TCollection_ExtendedString;
 class Quantity_Color;
+class TCollection_AsciiString;
 class Graphic3d_MapOfStructure;
 class Graphic3d_Structure;
 class Aspect_GraphicDriver;
@@ -339,10 +347,10 @@ public:
   Standard_EXPORT     void TriedronErase() ;
   //! Highlights the echo zone of the Triedron. <br>
   Standard_EXPORT     void TriedronEcho(const Aspect_TypeOfTriedronEcho AType = Aspect_TOTE_NONE) ;
-  //! Returns data of a graduated trihedron. <br>
-  Standard_EXPORT     void GetGraduatedTrihedron(Standard_CString& xname,Standard_CString& yname,Standard_CString& zname,Standard_Boolean& xdrawname,Standard_Boolean& ydrawname,Standard_Boolean& zdrawname,Standard_Boolean& xdrawvalues,Standard_Boolean& ydrawvalues,Standard_Boolean& zdrawvalues,Standard_Boolean& drawgrid,Standard_Boolean& drawaxes,Standard_Integer& nbx,Standard_Integer& nby,Standard_Integer& nbz,Standard_Integer& xoffset,Standard_Integer& yoffset,Standard_Integer& zoffset,Standard_Integer& xaxisoffset,Standard_Integer& yaxisoffset,Standard_Integer& zaxisoffset,Standard_Boolean& xdrawtickmarks,Standard_Boolean& ydrawtickmarks,Standard_Boolean& zdrawtickmarks,Standard_Integer& xtickmarklength,Standard_Integer& ytickmarklength,Standard_Integer& ztickmarklength,Quantity_Color& gridcolor,Quantity_Color& xnamecolor,Quantity_Color& ynamecolor,Quantity_Color& znamecolor,Quantity_Color& xcolor,Quantity_Color& ycolor,Quantity_Color& zcolor,Standard_CString& fontOfNames,OSD_FontAspect& styleOfNames,Standard_Integer& sizeOfNames,Standard_CString& fontOfValues,OSD_FontAspect& styleOfValues,Standard_Integer& sizeOfValues) const;
+  //! Returns data of a graduated trihedron if displayed (return value is True) <br>
+  Standard_EXPORT     Standard_Boolean GetGraduatedTrihedron(TCollection_ExtendedString& xname,TCollection_ExtendedString& yname,TCollection_ExtendedString& zname,Standard_Boolean& xdrawname,Standard_Boolean& ydrawname,Standard_Boolean& zdrawname,Standard_Boolean& xdrawvalues,Standard_Boolean& ydrawvalues,Standard_Boolean& zdrawvalues,Standard_Boolean& drawgrid,Standard_Boolean& drawaxes,Standard_Integer& nbx,Standard_Integer& nby,Standard_Integer& nbz,Standard_Integer& xoffset,Standard_Integer& yoffset,Standard_Integer& zoffset,Standard_Integer& xaxisoffset,Standard_Integer& yaxisoffset,Standard_Integer& zaxisoffset,Standard_Boolean& xdrawtickmarks,Standard_Boolean& ydrawtickmarks,Standard_Boolean& zdrawtickmarks,Standard_Integer& xtickmarklength,Standard_Integer& ytickmarklength,Standard_Integer& ztickmarklength,Quantity_Color& gridcolor,Quantity_Color& xnamecolor,Quantity_Color& ynamecolor,Quantity_Color& znamecolor,Quantity_Color& xcolor,Quantity_Color& ycolor,Quantity_Color& zcolor,TCollection_AsciiString& fontOfNames,OSD_FontAspect& styleOfNames,Standard_Integer& sizeOfNames,TCollection_AsciiString& fontOfValues,OSD_FontAspect& styleOfValues,Standard_Integer& sizeOfValues) const;
   //! Displays a graduated trihedron. <br>
-  Standard_EXPORT     void GraduatedTrihedronDisplay(const Standard_CString xname,const Standard_CString yname,const Standard_CString zname,const Standard_Boolean xdrawname,const Standard_Boolean ydrawname,const Standard_Boolean zdrawname,const Standard_Boolean xdrawvalues,const Standard_Boolean ydrawvalues,const Standard_Boolean zdrawvalues,const Standard_Boolean drawgrid,const Standard_Boolean drawaxes,const Standard_Integer nbx,const Standard_Integer nby,const Standard_Integer nbz,const Standard_Integer xoffset,const Standard_Integer yoffset,const Standard_Integer zoffset,const Standard_Integer xaxisoffset,const Standard_Integer yaxisoffset,const Standard_Integer zaxisoffset,const Standard_Boolean xdrawtickmarks,const Standard_Boolean ydrawtickmarks,const Standard_Boolean zdrawtickmarks,const Standard_Integer xtickmarklength,const Standard_Integer ytickmarklength,const Standard_Integer ztickmarklength,const Quantity_Color& gridcolor,const Quantity_Color& xnamecolor,const Quantity_Color& ynamecolor,const Quantity_Color& znamecolor,const Quantity_Color& xcolor,const Quantity_Color& ycolor,const Quantity_Color& zcolor,const Standard_CString fontOfNames,const OSD_FontAspect styleOfNames,const Standard_Integer sizeOfNames,const Standard_CString fontOfValues,const OSD_FontAspect styleOfValues,const Standard_Integer sizeOfValues) ;
+  Standard_EXPORT     void GraduatedTrihedronDisplay(const TCollection_ExtendedString& xname,const TCollection_ExtendedString& yname,const TCollection_ExtendedString& zname,const Standard_Boolean xdrawname,const Standard_Boolean ydrawname,const Standard_Boolean zdrawname,const Standard_Boolean xdrawvalues,const Standard_Boolean ydrawvalues,const Standard_Boolean zdrawvalues,const Standard_Boolean drawgrid,const Standard_Boolean drawaxes,const Standard_Integer nbx,const Standard_Integer nby,const Standard_Integer nbz,const Standard_Integer xoffset,const Standard_Integer yoffset,const Standard_Integer zoffset,const Standard_Integer xaxisoffset,const Standard_Integer yaxisoffset,const Standard_Integer zaxisoffset,const Standard_Boolean xdrawtickmarks,const Standard_Boolean ydrawtickmarks,const Standard_Boolean zdrawtickmarks,const Standard_Integer xtickmarklength,const Standard_Integer ytickmarklength,const Standard_Integer ztickmarklength,const Quantity_Color& gridcolor,const Quantity_Color& xnamecolor,const Quantity_Color& ynamecolor,const Quantity_Color& znamecolor,const Quantity_Color& xcolor,const Quantity_Color& ycolor,const Quantity_Color& zcolor,const TCollection_AsciiString& fontOfNames,const OSD_FontAspect styleOfNames,const Standard_Integer sizeOfNames,const TCollection_AsciiString& fontOfValues,const OSD_FontAspect styleOfValues,const Standard_Integer sizeOfValues) ;
   //! Erases a graduated trihedron from the view. <br>
   Standard_EXPORT     void GraduatedTrihedronErase() ;
   //! Returns the value of the default window background. <br>
@@ -436,16 +444,30 @@ public:
 //! (background is white) <br>
 //! else set to TRUE for printing with current background color. <br>
 //! <filename>: If != NULL, then the view will be printed to a file. <br>
+//! <printAlgo>: Select print algorithm: stretch, tile. <br>
+//! <theScaleFactor>: Scaling coefficient, used internally to scale the <br>
+//! printings accordingly to the scale factor selected in the printer <br>
+//! properties dialog. <br>
+//! Returns Standard_True if the data is passed to the printer, otherwise <br>
+//! Standard_False if the print operation failed due to printer error <br>
+//! or insufficient memory. <br>
 //!  Warning: Works only under Windows. <br>
-  Standard_EXPORT     void Print(const Handle(Visual3d_Layer)& AnUnderLayer,const Handle(Visual3d_Layer)& AnOverLayer,const Aspect_Handle hPrnDC,const Standard_Boolean showBackground,const Standard_CString filename) const;
+  Standard_EXPORT     Standard_Boolean Print(const Handle(Visual3d_Layer)& AnUnderLayer,const Handle(Visual3d_Layer)& AnOverLayer,const Aspect_Handle hPrnDC,const Standard_Boolean showBackground,const Standard_CString filename,const Aspect_PrintAlgo printAlgorithm = Aspect_PA_STRETCH,const Standard_Real theScaleFactor = 1.0) const;
   //! print the contents of the view to printer. <br>
 //! <hPrnDC> : Pass the PrinterDeviceContext (HDC), <br>
 //! <showBackground> : When set to FALSE then print the view without background color <br>
 //! (background is white) <br>
 //! else set to TRUE for printing with current background color. <br>
 //! <filename>: If != NULL, then the view will be printed to a file. <br>
+//! <printAlgo>: Select print algorithm: stretch, tile. <br>
+//! <theScaleFactor>: Scaling coefficient, used internally to scale the <br>
+//! printings accordingly to the scale factor selected in the printer <br>
+//! properties dialog. <br>
+//! Returns Standard_True if the data is passed to the printer, otherwise <br>
+//! Standard_False if the print operation failed due to printer error <br>
+//! or insufficient memory. <br>
 //!  Warning: Works only under Windows. <br>
-  Standard_EXPORT     void Print(const Aspect_Handle hPrnDC,const Standard_Boolean showBackground,const Standard_CString filename) const;
+  Standard_EXPORT     Standard_Boolean Print(const Aspect_Handle hPrnDC,const Standard_Boolean showBackground,const Standard_CString filename,const Aspect_PrintAlgo printAlgorithm = Aspect_PA_STRETCH,const Standard_Real theScaleFactor = 1.0) const;
   //! if <AFlag> is Standard_True then the transparency <br>
 //!	    is managed in the view <me>. <br>
 //!	    Default Standard_False <br>
@@ -581,6 +603,7 @@ Aspect_GradientBackground MyGradientBackground;
 Graphic3d_MapOfStructure MyDisplayedStructure;
 Visual3d_ViewManagerPtr MyPtrViewManager;
 Graphic3d_CBitFields8 MyCBitFields;
+Graphic3d_CGraduatedTrihedron MyGTrihedron;
 
 
 };
diff --git a/inc/XCAFApp_Application.hxx b/inc/XCAFApp_Application.hxx
index 3c57532..a1b97c1 100644
--- a/inc/XCAFApp_Application.hxx
+++ b/inc/XCAFApp_Application.hxx
@@ -55,14 +55,14 @@ public:
 
 protected:
 
+  //! methods from CDF_Application <br>
+//!          ============================ <br>
+  Standard_EXPORT   XCAFApp_Application();
 
 
 
 private: 
 
-  //! methods from CDF_Application <br>
-//!          ============================ <br>
-  Standard_EXPORT   XCAFApp_Application();
 
 
 
diff --git a/inc/XCAFDoc_DataMapOfShapeLabel.hxx b/inc/XCAFDoc_DataMapOfShapeLabel.hxx
index 5c1721b..039a67a 100644
--- a/inc/XCAFDoc_DataMapOfShapeLabel.hxx
+++ b/inc/XCAFDoc_DataMapOfShapeLabel.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/XCAFPrs_DataMapOfShapeStyle.hxx b/inc/XCAFPrs_DataMapOfShapeStyle.hxx
index 63be44c..fc6c177 100644
--- a/inc/XCAFPrs_DataMapOfShapeStyle.hxx
+++ b/inc/XCAFPrs_DataMapOfShapeStyle.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TopoDS_Shape;
@@ -85,6 +88,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TopoDS_Shape& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TopoDS_Shape& K) ;
 
 
 
diff --git a/inc/XCAFPrs_DataMapOfStyleShape.hxx b/inc/XCAFPrs_DataMapOfStyleShape.hxx
index 5908616..483b202 100644
--- a/inc/XCAFPrs_DataMapOfStyleShape.hxx
+++ b/inc/XCAFPrs_DataMapOfStyleShape.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class XCAFPrs_Style;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const XCAFPrs_Style& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const XCAFPrs_Style& K) ;
 
 
 
diff --git a/inc/XCAFPrs_DataMapOfStyleTransient.hxx b/inc/XCAFPrs_DataMapOfStyleTransient.hxx
index c11cba0..42fd4fc 100644
--- a/inc/XCAFPrs_DataMapOfStyleTransient.hxx
+++ b/inc/XCAFPrs_DataMapOfStyleTransient.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class XCAFPrs_Style;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const XCAFPrs_Style& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const XCAFPrs_Style& K) ;
 
 
 
diff --git a/inc/XSDRAWSTLVRML_CoordsMap.hxx b/inc/XSDRAWSTLVRML_CoordsMap.hxx
index 4dbe291..00ab663 100644
--- a/inc/XSDRAWSTLVRML_CoordsMap.hxx
+++ b/inc/XSDRAWSTLVRML_CoordsMap.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TColStd_DataMapOfIntegerReal;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/XSDRAWSTLVRML_ElemNodesMap.hxx b/inc/XSDRAWSTLVRML_ElemNodesMap.hxx
index c033469..6ff2045 100644
--- a/inc/XSDRAWSTLVRML_ElemNodesMap.hxx
+++ b/inc/XSDRAWSTLVRML_ElemNodesMap.hxx
@@ -25,6 +25,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TColStd_DataMapOfIntegerInteger;
@@ -84,6 +87,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Standard_Integer& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Standard_Integer& K) ;
 
 
 
diff --git a/inc/XmlLDrivers_DocumentStorageDriver.hxx b/inc/XmlLDrivers_DocumentStorageDriver.hxx
index 8492e39..58e2b69 100644
--- a/inc/XmlLDrivers_DocumentStorageDriver.hxx
+++ b/inc/XmlLDrivers_DocumentStorageDriver.hxx
@@ -28,15 +28,15 @@
 #ifndef _XmlObjMgt_SRelocationTable_HeaderFile
 #include <XmlObjMgt_SRelocationTable.hxx>
 #endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
 #ifndef _PCDM_StorageDriver_HeaderFile
 #include <PCDM_StorageDriver.hxx>
 #endif
 #ifndef _Handle_CDM_Document_HeaderFile
 #include <Handle_CDM_Document.hxx>
 #endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
 #ifndef _XmlObjMgt_Element_HeaderFile
 #include <XmlObjMgt_Element.hxx>
 #endif
@@ -65,8 +65,6 @@ public:
   
   Standard_EXPORT   virtual  void Write(const Handle(CDM_Document)& theDocument,const TCollection_ExtendedString& theFileName) ;
   
-  Standard_EXPORT     Standard_Boolean IsError() const;
-  
   Standard_EXPORT   virtual  Handle_XmlMDF_ADriverTable AttributeDrivers(const Handle(CDM_MessageDriver)& theMsgDriver) ;
 
 
@@ -87,7 +85,6 @@ protected:
 
 Handle_XmlMDF_ADriverTable myDrivers;
 XmlObjMgt_SRelocationTable myRelocTable;
-Standard_Boolean myIsError;
 
 
 private: 
diff --git a/inc/XmlMDF_MapOfDriver.hxx b/inc/XmlMDF_MapOfDriver.hxx
index b3ae1f6..fe071a5 100644
--- a/inc/XmlMDF_MapOfDriver.hxx
+++ b/inc/XmlMDF_MapOfDriver.hxx
@@ -28,6 +28,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class TCollection_AsciiString;
@@ -87,6 +90,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const TCollection_AsciiString& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const TCollection_AsciiString& K) ;
 
 
 
diff --git a/inc/XmlMDF_TypeADriverMap.hxx b/inc/XmlMDF_TypeADriverMap.hxx
index 2ab7fbd..4b6cf8c 100644
--- a/inc/XmlMDF_TypeADriverMap.hxx
+++ b/inc/XmlMDF_TypeADriverMap.hxx
@@ -31,6 +31,9 @@
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
+#ifndef _Standard_Address_HeaderFile
+#include <Standard_Address.hxx>
+#endif
 class Standard_DomainError;
 class Standard_NoSuchObject;
 class Standard_Type;
@@ -91,6 +94,10 @@ public:
 {
   return ChangeFind(K);
 }
+  
+  Standard_EXPORT     Standard_Address Find1(const Handle(Standard_Type)& K) const;
+  
+  Standard_EXPORT     Standard_Address ChangeFind1(const Handle(Standard_Type)& K) ;
 
 
 
diff --git a/msvc.bat b/msvc.bat
index 7504ace..1811f36 100755
--- a/msvc.bat
+++ b/msvc.bat
@@ -4,7 +4,7 @@ rem Launch MS VC with environment prepared for building OCCT
 rem Use:
 rem - first argument specifies version of Visual Studio (vc8, vc9, or vc10),
 rem - second argument specifies mode (win32 or win64),
-rem - third argument specifies path to solution to be loaded
+rem - third argument specifies building mode (Release or Debug)
 rem - fourth argument is path to MS project solution
 rem Default options are:
 rem   vc8 win32 Debug adm\win32\vc8\OCCT.sln
diff --git a/src/AIS/AIS_AngleDimension.cxx b/src/AIS/AIS_AngleDimension.cxx
index 3379452..d1bbd95 100644
--- a/src/AIS/AIS_AngleDimension.cxx
+++ b/src/AIS/AIS_AngleDimension.cxx
@@ -574,7 +574,7 @@ void AIS_AngleDimension::ComputeConeAngle(const Handle(Prs3d_Presentation)& aPre
    if ( aType == STANDARD_TYPE(Geom_OffsetSurface) || Offset > 0.01 ) {            //offset surface
      aOffsetSurf = new Geom_OffsetSurface (aSurf, Offset);
      aSurf = aOffsetSurf->Surface();
-     BRepBuilderAPI_MakeFace mkFace(aSurf);
+     BRepBuilderAPI_MakeFace mkFace(aSurf, Precision::Confusion());
      mkFace.Build();
      if( !mkFace.IsDone() ) return;
      tmpSurf.Initialize( mkFace.Face() );
@@ -1910,7 +1910,7 @@ void AIS_AngleDimension::ComputeConeAngleSelection(const Handle(SelectMgr_Select
     if ( aType == STANDARD_TYPE(Geom_OffsetSurface) || Offset > 0.01 ) {            //offset surface
       aOffsetSurf = new Geom_OffsetSurface (aSurf, Offset);
       aSurf = aOffsetSurf->Surface();
-      BRepBuilderAPI_MakeFace mkFace(aSurf);
+      BRepBuilderAPI_MakeFace mkFace(aSurf, Precision::Confusion());
       mkFace.Build();
       if( !mkFace.IsDone() ) return;
       tmpSurf.Initialize( mkFace.Face() );
diff --git a/src/AIS/AIS_GlobalStatus.cxx b/src/AIS/AIS_GlobalStatus.cxx
index 22e8297..bcf2c6a 100644
--- a/src/AIS/AIS_GlobalStatus.cxx
+++ b/src/AIS/AIS_GlobalStatus.cxx
@@ -3,15 +3,9 @@
 // Author:	Robert COUBLANC
 //		<rob at robox.paris1.matra-dtv.fr>
 
-
 #include <AIS_GlobalStatus.ixx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
 
-
-
-static TColStd_ListIteratorOfListOfInteger It;
-
-
 AIS_GlobalStatus::AIS_GlobalStatus():
 myStatus(AIS_DS_None),
 myLayerIndex(0),
@@ -37,22 +31,32 @@ mySubInt(Standard_False)
   mySelModes.Append(SMode);
 }
 
-
 void AIS_GlobalStatus::RemoveDisplayMode(const Standard_Integer aMode)
 {
-  for(It.Initialize(myDispModes);It.More();It.Next()){
-    if(It.Value()==aMode){ myDispModes.Remove(It);
-			   return;}
+  TColStd_ListIteratorOfListOfInteger anIt (myDispModes);
+  for (; anIt.More(); anIt.Next())
+  {
+    if (anIt.Value() == aMode)
+    {
+      myDispModes.Remove (anIt);
+      return;
+    }
   }
 }
 
 void AIS_GlobalStatus::RemoveSelectionMode(const Standard_Integer aMode)
 {
-  for(It.Initialize(mySelModes);It.More();It.Next()){
-    if(It.Value()==aMode){ mySelModes.Remove(It);
-			   return;}
+  TColStd_ListIteratorOfListOfInteger anIt (mySelModes);
+  for (; anIt.More(); anIt.Next())
+  {
+    if (anIt.Value() == aMode)
+    {
+      mySelModes.Remove (anIt);
+      return;
+    }
   }
 }
+
 void AIS_GlobalStatus::ClearSelectionModes()
 {
   mySelModes.Clear();
@@ -60,16 +64,26 @@ void AIS_GlobalStatus::ClearSelectionModes()
 
 Standard_Boolean AIS_GlobalStatus::IsDModeIn(const Standard_Integer aMode) const 
 {
-  for(It.Initialize(myDispModes);It.More();It.Next())
-    if(It.Value()==aMode) return Standard_True;
+  TColStd_ListIteratorOfListOfInteger anIt (myDispModes);
+  for (; anIt.More(); anIt.Next())
+  {
+    if (anIt.Value() == aMode)
+    {
+      return Standard_True;
+    }
+  }
   return Standard_False;
-  
 }
 
 Standard_Boolean AIS_GlobalStatus::IsSModeIn(const Standard_Integer aMode) const 
 {
-  for(It.Initialize(mySelModes);It.More();It.Next())
-    if(It.Value()==aMode) return Standard_True;
+  TColStd_ListIteratorOfListOfInteger anIt (mySelModes);
+  for (; anIt.More(); anIt.Next())
+  {
+    if (anIt.Value() == aMode)
+    {
+      return Standard_True;
+    }
+  }
   return Standard_False;
 }
-
diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx
index 46302c3..fb94705 100644
--- a/src/AIS/AIS_InteractiveContext.cxx
+++ b/src/AIS/AIS_InteractiveContext.cxx
@@ -57,6 +57,7 @@
 #include <Prs3d_DatumAspect.hxx>
 #include <Prs3d_PlaneAspect.hxx>
 #include <PrsMgr_PresentableObject.hxx>
+#include <Standard_Atomic.hxx>
 #include <UnitsAPI.hxx>
 
 #include <AIS_Trihedron.hxx>
@@ -91,28 +92,23 @@ static Standard_Boolean AISDebugModeOn()
   return (isDebugMode != 0);
 }
 
-static TCollection_AsciiString AIS_Context_NewSelName()
+namespace
 {
-  static Standard_Integer index_sel = 1;
-  TCollection_AsciiString name("AIS_SelContext_");
-  TCollection_AsciiString theind(index_sel);
-  name += theind;
-  index_sel++;
-  return name;
-}
-
-static TCollection_AsciiString AIS_Context_NewCurName()
-{
-  static Standard_Integer index_cur = 1;
-  TCollection_AsciiString name("AIS_CurContext_");
-  TCollection_AsciiString theind(index_cur);
-  name += theind;
-  index_cur++;
-  return name;
-}
+  static volatile Standard_Integer THE_AIS_INDEX_SEL = 0;
+  static volatile Standard_Integer THE_AIS_INDEX_CUR = 0;
 
-static TColStd_ListIteratorOfListOfInteger ItL;
+  static TCollection_AsciiString AIS_Context_NewSelName()
+  {
+    return TCollection_AsciiString ("AIS_SelContext_")
+         + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_SEL));
+  }
 
+  static TCollection_AsciiString AIS_Context_NewCurName()
+  {
+    return TCollection_AsciiString ("AIS_CurContext_")
+         + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR));
+  }
+};
 
 //=======================================================================
 //function : AIS_InteractiveContext
@@ -504,7 +500,8 @@ void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj
         updcol = updateviewer;
                          }// attention on fait expres de ne pas mettre de break..
       case AIS_DS_FullErased:{
-        for (ItL.Initialize(STATUS->DisplayedModes());ItL.More();ItL.Next()){
+        TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
+        for (;ItL.More();ItL.Next()){
           myMainPM->Display(anIObj,ItL.Value());
           if(STATUS->IsSubIntensityOn())
             myMainPM->Color(anIObj,mySubIntensity,ItL.Value());
@@ -523,7 +520,8 @@ void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj
       //       Finally, activate selection mode <SelMode> if not yet activated.
       case AIS_DS_Displayed:{
         TColStd_ListOfInteger aModesToRemove;
-        for(ItL.Initialize(STATUS->DisplayedModes());ItL.More();ItL.Next()){
+        TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
+        for(;ItL.More();ItL.Next()){
 
           Standard_Integer OldMode = ItL.Value();
 
@@ -1817,7 +1815,8 @@ void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)&
       // SAN : erase presentations for all display modes different from <aMode>
       if(STATUS->GraphicStatus()==AIS_DS_Displayed){
         TColStd_ListOfInteger aModesToRemove;
-        for(ItL.Initialize(STATUS->DisplayedModes());ItL.More();ItL.Next()){
+        TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
+        for(;ItL.More();ItL.Next()){
 
           Standard_Integer OldMode = ItL.Value();
 
@@ -2092,7 +2091,7 @@ void AIS_InteractiveContext::SetDeviationAngle(
  
   if(!anIObj->HasInteractiveContext())
     anIObj->SetContext(this);
-// To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+  // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
   if(anIObj->Type()!=AIS_KOI_Shape) return;
   if(anIObj->Signature()!=0) return;
   (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationAngle(anAngle);
@@ -2134,7 +2133,7 @@ void AIS_InteractiveContext::SetAngleAndDeviation(
   if(!anIObj->HasInteractiveContext())
     anIObj->SetContext(this);
 
-// To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+  // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
   if(anIObj->Type()!=AIS_KOI_Shape) return;
   if(anIObj->Signature()!=0) return;
   (*((Handle(AIS_Shape)*)&anIObj))->SetAngleAndDeviation(anAngle);
@@ -2162,7 +2161,7 @@ void AIS_InteractiveContext::SetHLRAngleAndDeviation(
    if(!anIObj->HasInteractiveContext())
     anIObj->SetContext(this);
 
-// To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+  // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
   if(anIObj->Type()!=AIS_KOI_Shape) return;
   if(anIObj->Signature()!=0) return;
   (*((Handle(AIS_Shape)*)&anIObj))->SetHLRAngleAndDeviation(anAngle);
@@ -2205,7 +2204,7 @@ void AIS_InteractiveContext::SetHLRDeviationAngle(
  
   if(!anIObj->HasInteractiveContext())
     anIObj->SetContext(this);
-// To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+  // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
   if( anIObj->Type()!=AIS_KOI_Shape) return;
   if(anIObj->Signature()!=0) return;
   (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationAngle(anAngle);
@@ -2626,7 +2625,8 @@ void AIS_InteractiveContext::Status(const Handle(AIS_InteractiveObject)& anIObj,
       break;
     }
     astatus += "\t| Active Display Modes in the MainViewer :\n";
-    for(ItL.Initialize(ST->DisplayedModes());ItL.More();ItL.Next()){
+    TColStd_ListIteratorOfListOfInteger ItL (ST->DisplayedModes());
+    for(;ItL.More();ItL.Next()){
       astatus += "\t|\t Mode ";
       astatus += TCollection_AsciiString(ItL.Value());
       astatus+="\n";
@@ -2688,7 +2688,8 @@ void AIS_InteractiveContext::EraseGlobal(const Handle(AIS_InteractiveObject)& an
   Standard_Integer Dmode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
   if(STATUS->GraphicStatus()==AIS_DS_Displayed){
     
-    for(ItL.Initialize(STATUS->DisplayedModes());ItL.More();ItL.Next()){
+    TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
+    for(;ItL.More();ItL.Next()){
       if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
         myMainPM->Unhighlight(anIObj,ItL.Value());
       myMainPM->Erase(anIObj,ItL.Value());
@@ -2732,7 +2733,8 @@ void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& an
   // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
   Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
   // ENDCLE
-   for(ItL.Initialize(STATUS->DisplayedModes());ItL.More();ItL.Next()){
+   TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
+   for(;ItL.More();ItL.Next()){
      if(STATUS->IsHilighted()){
        if(IsCurrent(anIObj))
 #ifdef OCC204
diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx
index bee0e9f..1a0b684 100644
--- a/src/AIS/AIS_Shape.cxx
+++ b/src/AIS/AIS_Shape.cxx
@@ -84,13 +84,13 @@
 static Standard_Boolean myFirstCompute;
 
 Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
-				   const Handle(Prs3d_Drawer)& aDrawer)
+                                       const Handle(Prs3d_Drawer)& aDrawer)
 {
   // WARNING: this same piece of code appears several times in Prs3d classes
-  Standard_Real aDeflection;
+  Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
   if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
     Bnd_Box B;
-    BRepBndLib::Add(aShape, B);
+    BRepBndLib::Add(aShape, B, Standard_False);
     if ( ! B.IsVoid() )
     {
       Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
@@ -98,17 +98,13 @@ Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
       aDeflection = Max( aXmax-aXmin, Max(aYmax-aYmin, aZmax-aZmin)) *
                     aDrawer->DeviationCoefficient() * 4;
     }
-    else
-      aDeflection = aDrawer->MaximalChordialDeviation();
   }
-  else
-    aDeflection = aDrawer->MaximalChordialDeviation();
   return aDeflection;
 }
 
 void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
-		       const Bnd_Box& B,
-		       const Handle(Prs3d_Drawer)& aDrawer)
+                           const Bnd_Box& B,
+                           const Handle(Prs3d_Drawer)& aDrawer)
 {
   Standard_Real X[2],Y[2],Z[2];
   Standard_Integer Indx [16] ;
@@ -133,7 +129,7 @@ void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
   for(Standard_Integer k=0;k<=1;k++)
     for(Standard_Integer j=0;j<=1;j++)
       for(Standard_Integer i=0;i<=1;i++)
-	V(++Rank) = Graphic3d_Vertex(X[i],Y[j],Z[k]);
+        V(++Rank) = Graphic3d_Vertex(X[i],Y[j],Z[k]);
   
   
   Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPrs);
@@ -156,7 +152,7 @@ void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
   }
   G->EndPrimitives();
 }
-		     
+
 static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode)
 {
   TColStd_ListIteratorOfListOfInteger It(LL);
@@ -210,8 +206,8 @@ Standard_Boolean AIS_Shape::AcceptShapeDecomposition() const
 //purpose  : 
 //=======================================================================
 void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
-			const Handle(Prs3d_Presentation)& aPrs,
-			const Standard_Integer aMode)
+                        const Handle(Prs3d_Presentation)& aPrs,
+                        const Standard_Integer aMode)
 {  
   aPrs->Clear();
   if(myshape.IsNull()) return;
@@ -258,42 +254,42 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
       
       
       if (OwnDeviationAngle(newangle,prevangle) ||
-	  OwnDeviationCoefficient(newcoeff,prevcoeff))
-	if (Abs (newangle - prevangle) > Precision::Angular() ||
-	    Abs (newcoeff - prevcoeff) > Precision::Confusion()  ) { 
+          OwnDeviationCoefficient(newcoeff,prevcoeff))
+        if (Abs (newangle - prevangle) > Precision::Angular() ||
+            Abs (newcoeff - prevcoeff) > Precision::Confusion()  ) { 
 #ifdef DEB
-	  cout << "AIS_Shape : compute"<<endl;
-	  cout << "newangl   : " << newangle << " # de " << "prevangl  : " << prevangle << " OU "<<endl;
-	  cout << "newcoeff  : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
+          cout << "AIS_Shape : compute"<<endl;
+          cout << "newangl   : " << newangle << " # de " << "prevangl  : " << prevangle << " OU "<<endl;
+          cout << "newcoeff  : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
 #endif
-	  BRepTools::Clean(myshape);
-	}
+          BRepTools::Clean(myshape);
+        }
       
       //shading only on face...
       if ((Standard_Integer) myshape.ShapeType()>4)
-	StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
+        StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
       else {
-	myDrawer->SetShadingAspectGlobal(Standard_False);
-	if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
-	else 	{
-	  {
-	    try {
-	      OCC_CATCH_SIGNALS
-	      StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
-	    }
-	    catch (Standard_Failure) {
+        myDrawer->SetShadingAspectGlobal(Standard_False);
+        if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
+        else {
+          {
+            try {
+              OCC_CATCH_SIGNALS
+              StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
+            }
+            catch (Standard_Failure) {
 #ifdef DEB
-	      cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
+              cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
 #endif
-	      StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
-	    }
-	  }
-	}
+              StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
+            }
+          }
+        }
       }
 #ifdef BUC60918
       Standard_Real value = Transparency() ;
       if( value > 0. ) {
-	SetTransparency( value );
+        SetTransparency( value );
       }
 #endif
       break;
@@ -317,8 +313,8 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
 //=======================================================================
 
 void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager*/,
-			const Handle(Graphic2d_GraphicObject)& /*aGRO*/,
-			const Standard_Integer /*aMode*/)
+                        const Handle(Graphic2d_GraphicObject)& /*aGRO*/,
+                        const Standard_Integer /*aMode*/)
 {
 }
 
@@ -327,7 +323,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentat
 //purpose  : Hidden Line Removal
 //=======================================================================
 void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
-			const Handle(Prs3d_Presentation)& aPresentation)
+                        const Handle(Prs3d_Presentation)& aPresentation)
 {
   Compute(aProjector,aPresentation,myshape);
 }
@@ -338,8 +334,8 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
 //=======================================================================
 
 void AIS_Shape::Compute(const Handle(Prs3d_Projector)&     aProjector,
-			const Handle(Geom_Transformation)& TheTrsf,
-			const Handle(Prs3d_Presentation)&  aPresentation)
+                        const Handle(Geom_Transformation)& TheTrsf,
+                        const Handle(Prs3d_Presentation)&  aPresentation)
 {
   const TopLoc_Location& loc = myshape.Location();
   TopoDS_Shape shbis = myshape.Located(TopLoc_Location(TheTrsf->Trsf())*loc);
@@ -352,8 +348,8 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)&     aProjector,
 //=======================================================================
 
 void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
-			const Handle(Prs3d_Presentation)& aPresentation,
-			const TopoDS_Shape& SH)
+                        const Handle(Prs3d_Presentation)& aPresentation,
+                        const TopoDS_Shape& SH)
 {
   if (SH.ShapeType() == TopAbs_COMPOUND) {
 #ifdef BUC60547
@@ -379,7 +375,7 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
   if (OwnHLRDeviationAngle(newangle,prevangle) || OwnHLRDeviationCoefficient(newcoeff, prevcoeff))
       
     if (Abs (newangle - prevangle) > Precision::Angular() ||
-	Abs (newcoeff - prevcoeff) > Precision::Confusion()  ) { 
+        Abs (newcoeff - prevcoeff) > Precision::Confusion()  ) { 
 #ifdef DEB
       cout << "AIS_Shape : compute"<<endl;
       cout << "newangle  : " << newangle << " # de " << "prevangl  : " << prevangle << " OU "<<endl;
@@ -471,7 +467,7 @@ Standard_Integer AIS_Shape::SelectionMode(const TopAbs_ShapeEnum aType)
 //=======================================================================
 
 void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-		 const Standard_Integer aMode)
+                                              const Standard_Integer aMode)
 {
   if(myshape.IsNull()) return;
   if (myshape.ShapeType() == TopAbs_COMPOUND) {
@@ -496,20 +492,7 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
 
 // POP protection against crash in low layers
 
-  Standard_Real aDeflection = myDrawer->MaximalChordialDeviation();
-  if (myDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
-  {
-    // Vector is calculated depending on global min max of the part:
-    Bnd_Box aBndBox; //= BoundingBox(); ?
-    BRepBndLib::Add (shape, aBndBox);
-    if (!aBndBox.IsVoid())
-    {
-      Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
-      aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
-      aDeflection = Max (aXmax - aXmin, Max (aYmax - aYmin, aZmax - aZmin)) * myDrawer->DeviationCoefficient();
-    }
-  }
-
+  Standard_Real aDeflection = GetDeflection(shape, myDrawer);
   Standard_Boolean autoTriangulation = Standard_True;
   try {  
     OCC_CATCH_SIGNALS
@@ -518,7 +501,7 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                       shape,
                                       TypOfSel,
                                       aDeflection,
-                                      myDrawer->DeviationAngle(),
+                                      myDrawer->HLRAngle(),
                                       autoTriangulation); 
   } catch ( Standard_Failure ) {
 //    cout << "a Shape should be incorrect : A Selection on the Bnd  is activated   "<<endl;
@@ -571,7 +554,7 @@ void AIS_Shape::SetColor(const Quantity_Color &aCol)
   hasOwnColor = Standard_True;
 #ifdef GER61351
   if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
-	myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
+    myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
   }
 #else
   myOwnColor  = aCol; 
@@ -786,7 +769,7 @@ void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
 {
 #ifdef GER61351
   if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
-	myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
+    myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
   }
   myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
   hasOwnMaterial = Standard_True;
@@ -814,7 +797,7 @@ void AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat)
 {
 #ifdef GER61351
   if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
-	myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
+    myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
   }
   myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
   hasOwnMaterial = Standard_True;
@@ -846,11 +829,11 @@ void AIS_Shape::UnsetMaterial()
   if( HasColor() || IsTransparent()) {
     Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(myDrawer->Link()); 
     if( HasColor() ) {
-	Quantity_Color color = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
+      Quantity_Color color = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
       mat.SetColor(color);
     }
     if( IsTransparent() ) {
-	Standard_Real trans = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
+      Standard_Real trans = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
       mat.SetTransparency(trans);
     }
     myDrawer->ShadingAspect()->SetMaterial(mat,myCurrentFacingModel);
@@ -900,8 +883,8 @@ void AIS_Shape::SetTransparency(const Standard_Real AValue)
       
       Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
       P->SetPrimitivesAspect(a4bis);
-#ifdef BUC60918 	//force highest priority for transparent objects
-      P->SetDisplayPriority(10);	
+#ifdef BUC60918   //force highest priority for transparent objects
+      P->SetDisplayPriority(10);
 #endif
       G->SetGroupPrimitivesAspect(a4bis);
     }
@@ -937,7 +920,7 @@ void AIS_Shape::UnsetTransparency()
       Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
       P->SetPrimitivesAspect(a4bis);
       G->SetGroupPrimitivesAspect(a4bis);
-#ifdef BUC60918	
+#ifdef BUC60918
       P->ResetDisplayPriority();
 #endif
     }
@@ -1133,7 +1116,7 @@ void AIS_Shape::SetOwnHLRDeviationAngle ( const Standard_Real  anAngle )
 //=======================================================================
 
 Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real &  aCoefficient,
-						      Standard_Real & aPreviousCoefficient ) const
+                                                      Standard_Real & aPreviousCoefficient ) const
 {
   aCoefficient = myDrawer->DeviationCoefficient();
   aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
@@ -1146,7 +1129,7 @@ Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real &  aCoeffici
 //=======================================================================
 
 Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoefficient,
-							 Standard_Real & aPreviousCoefficient ) const
+                                                         Standard_Real & aPreviousCoefficient ) const
 {
   aCoefficient = myDrawer->HLRDeviationCoefficient();
   aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient ();
@@ -1160,7 +1143,7 @@ Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoeffi
 //=======================================================================
 
 Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real &  anAngle,
-						Standard_Real & aPreviousAngle ) const
+                                                Standard_Real & aPreviousAngle ) const
 {
   anAngle = myDrawer->DeviationAngle();
   aPreviousAngle = myDrawer->PreviousDeviationAngle (); 
@@ -1173,10 +1156,9 @@ Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real &  anAngle,
 //=======================================================================
 
 Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real &  anAngle,
-						   Standard_Real & aPreviousAngle ) const
+                                                   Standard_Real & aPreviousAngle ) const
 {
   anAngle = myDrawer->HLRAngle();
   aPreviousAngle = myDrawer->PreviousHLRDeviationAngle (); 
   return myDrawer->IsOwnHLRDeviationAngle();
-
 }
diff --git a/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.cxx b/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.cxx
index aeced51..1d2b2a5 100644
--- a/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.cxx
+++ b/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.cxx
@@ -530,78 +530,110 @@ Standard_Real Adaptor3d_SurfaceOfRevolution::VResolution
 
 GeomAbs_SurfaceType Adaptor3d_SurfaceOfRevolution::GetType() const 
 {
-
-  Standard_Real TolConf = Precision::Confusion();
-  Standard_Real TolAng  = Precision::Angular();
+  Standard_Real TolConf, TolAng;
+  GeomAbs_SurfaceType bRet;
+  //
+  bRet=GeomAbs_SurfaceOfRevolution;
+  TolConf = Precision::Confusion();
+  TolAng  = Precision::Angular();
+  //
   switch ( myBasisCurve->GetType()) {
+  case GeomAbs_Line:    {
+    const gp_Ax1& Axe = (myBasisCurve->Line()).Position();
     
-  case GeomAbs_Line:
-    {
-      const gp_Ax1& Axe = (myBasisCurve->Line()).Position();
-      
-      if (myAxis.IsParallel(Axe, TolAng)) {
-	return GeomAbs_Cylinder;
-      }
-      else if (myAxis.IsNormal( Axe, TolAng)) {
-	return GeomAbs_Plane;
-      }
-      else {
-	Standard_Real uf = myBasisCurve->FirstParameter();
-	Standard_Real ul = myBasisCurve->LastParameter();
-	Standard_Boolean istrim = (!Precision::IsInfinite(uf) && 
-				   !Precision::IsInfinite(ul));
-	if(istrim){
-	  gp_Pnt pf = myBasisCurve->Value(uf);
-	  gp_Pnt pl = myBasisCurve->Value(ul);
-	  Standard_Real len = pf.Distance(pl);
-	  //on calcule la distance projetee sur l axe.
-	  gp_Vec vlin(pf,pl);
-	  gp_Vec vaxe(myAxis.Direction());
-	  Standard_Real projlen = Abs(vaxe.Dot(vlin));
-	  Standard_Real aTolConf = len*TolAng;
-	  if ((len - projlen) <= aTolConf) {
-	    return GeomAbs_Cylinder;
-	  }
-	  else if (projlen <= aTolConf) {
-	    return GeomAbs_Plane;
-	  }
-	}
-	gp_Vec V(myAxis.Location(),
-		 myBasisCurve->Line().Location());
-	gp_Vec W(Axe.Direction());
-	if (Abs(V.DotCross(myAxis.Direction(),W)) <= TolConf){
-	  return GeomAbs_Cone;
+    if (myAxis.IsParallel(Axe, TolAng)) {
+      bRet=GeomAbs_Cylinder;
+      return bRet;
+    }
+    else if (myAxis.IsNormal( Axe, TolAng)) {
+      bRet=GeomAbs_Plane;
+      return bRet;
+    }
+    else {
+      Standard_Real uf = myBasisCurve->FirstParameter();
+      Standard_Real ul = myBasisCurve->LastParameter();
+      Standard_Boolean istrim = (!Precision::IsInfinite(uf) && 
+				 !Precision::IsInfinite(ul));
+      if(istrim){
+	gp_Pnt pf = myBasisCurve->Value(uf);
+	gp_Pnt pl = myBasisCurve->Value(ul);
+	Standard_Real len = pf.Distance(pl);
+	//on calcule la distance projetee sur l axe.
+	gp_Vec vlin(pf,pl);
+	gp_Vec vaxe(myAxis.Direction());
+	Standard_Real projlen = Abs(vaxe.Dot(vlin));
+	Standard_Real aTolConf = len*TolAng;
+	if ((len - projlen) <= aTolConf) {
+	  bRet=GeomAbs_Cylinder;
+	  return bRet;
 	}
-	else {
-	  return GeomAbs_SurfaceOfRevolution;
+	else if (projlen <= aTolConf) {
+	  bRet=GeomAbs_Plane;
+	  return bRet;
 	}
       }
-      break;
-    }
-    
-  case GeomAbs_Circle: 
-    {
-      const gp_Circ& C = myBasisCurve->Circle();
-      if (!C.Position().IsCoplanar(myAxis,TolConf,TolAng)) {
-	return GeomAbs_SurfaceOfRevolution;
-      }
-      else if( gp_Lin(myAxis).Distance(C.Location()) <= TolConf) {
-	return GeomAbs_Sphere;
+      gp_Vec V(myAxis.Location(),
+	       myBasisCurve->Line().Location());
+      gp_Vec W(Axe.Direction());
+      if (Abs(V.DotCross(myAxis.Direction(),W)) <= TolConf){
+	bRet=GeomAbs_Cone;
+	return bRet;
       }
       else {
-	Standard_Real MajorRadius = gp_Lin(myAxis).Distance(C.Location());
-	if(MajorRadius > C.Radius()) return GeomAbs_Torus;
-	return GeomAbs_SurfaceOfRevolution;
+	return bRet;
       }
-      break;
     }
+    break;
+  }//case GeomAbs_Line: 
+  //  
+  case GeomAbs_Circle:   {
     
+    Standard_Real MajorRadius, aR;
+    gp_Lin aLin(myAxis);
+    //
+    const gp_Circ& C=myBasisCurve->Circle();
+    const gp_Pnt& aLC=C.Location();
+    aR=C.Radius();
+    //
+   
+    if (!C.Position().IsCoplanar(myAxis, TolConf, TolAng)) {
+      return bRet;
+    }
+    else if(aLin.Distance(aLC) <= TolConf) {
+      bRet=GeomAbs_Sphere;
+      return bRet;
+    }
+    else {
+      MajorRadius = aLin.Distance(aLC);
+      if(MajorRadius>aR) {
+	//modified by NIZNHY-PKV Thu Feb 24 09:46:29 2011f
+	Standard_Real aT, aDx, dX;
+	gp_Pnt aPx;
+	//
+	aT=0.;
+	aPx=ElCLib::Value(aT, C);
+	aDx=aLin.Distance(aPx);
+	dX=aDx-MajorRadius-aR;
+	if (dX<0.) {
+	  dX=-dX;
+	}
+	if (dX<TolConf) {
+	  bRet=GeomAbs_Torus;
+	}
+	//bRet=GeomAbs_Torus;
+	//return bRet;
+	//modified by NIZNHY-PKV Thu Feb 24 09:52:29 2011t
+      }
+      return bRet;
+    }
+    break;
+  }
+  //  
   default:
     break;
   }
   
-  // portage WNT
-  return GeomAbs_SurfaceOfRevolution;
+  return bRet;
 }
 
 //=======================================================================
diff --git a/src/AdvApp2Var/AdvApp2Var_Patch.cxx b/src/AdvApp2Var/AdvApp2Var_Patch.cxx
index 2aa7274..3b178a3 100644
--- a/src/AdvApp2Var/AdvApp2Var_Patch.cxx
+++ b/src/AdvApp2Var/AdvApp2Var_Patch.cxx
@@ -39,6 +39,8 @@ myV0(0.),
 myV1(1.),
 myOrdInU(0),
 myOrdInV(0),
+myNbCoeffInU(0),
+myNbCoeffInV(0),
 myApprIsDone(Standard_False),
 myHasResult(Standard_False),
 myCutSense(0),
@@ -64,6 +66,8 @@ myV0(V0),
 myV1(V1),
 myOrdInU(iu),
 myOrdInV(iv),
+myNbCoeffInU(0),
+myNbCoeffInV(0),
 myApprIsDone(Standard_False),
 myHasResult(Standard_False),
 myCutSense(0),
diff --git a/src/Aspect/Aspect.cdl b/src/Aspect/Aspect.cdl
index 10a489f..3b5bc46 100644
--- a/src/Aspect/Aspect.cdl
+++ b/src/Aspect/Aspect.cdl
@@ -844,6 +844,29 @@ is
         end TypeOfColorScaleOrientation;
         ---Purpose: Defines the type of color scale orientation
 
+        enumeration PrintAlgo is
+          PA_STRETCH,
+          PA_TILE
+        end PrintAlgo;
+        ---Purpose: Defines print algorithm
+        --          Aspect_PrintAlgo:
+        --          1) PA_STRETCH - Stretch offscreen printing frame
+        --                          if its dimensions are smaller than
+        --                          the printer's printing area dimensions;
+        --                          This algorithm is more reliable as it
+        --                          works on any hardware and is recommended
+        --                          to be used with average printing resolutions,
+        --                          as it more RAM memory dependent than PA_TILE;
+        --                          Stretching is performend using bicubic interpolation
+        --                          algorithm from FreeImage library if OCCT is built
+        --                          with FreeImage support, otherwise Windows API 
+        --                          StretchBlt() function in STRETCH_HALFTONE mode
+        --                          is used;
+        --          2) PA_TILE    - If the offscreen printing frame dimensions
+        --                          are smaller than the printer's printing
+        --                          area dimensions - use multiple printing
+        --                          frames to cover the whole printing area
+
         ---------------------------------
         -- Category: Instantiated classes
         ---------------------------------
diff --git a/src/Aspect/Aspect_GradientBackground.cdl b/src/Aspect/Aspect_GradientBackground.cdl
index bfbaa0f..efbea01 100644
--- a/src/Aspect/Aspect_GradientBackground.cdl
+++ b/src/Aspect/Aspect_GradientBackground.cdl
@@ -47,9 +47,6 @@ is
     ---Purpose: Modifies the colours of the window gradient background <me>.
     ---Category: Methods to modify the class definition
 
-    SetBgGradientFillMethod( me      ;
-                             AMethod : GradientFillMethod from Aspect = Aspect_GFM_NONE);
-
     ----------------------------
     -- Category: Inquire methods
     ----------------------------
diff --git a/src/Aspect/Aspect_GradientBackground.cxx b/src/Aspect/Aspect_GradientBackground.cxx
index d6d79ab..0a469fd 100644
--- a/src/Aspect/Aspect_GradientBackground.cxx
+++ b/src/Aspect/Aspect_GradientBackground.cxx
@@ -48,4 +48,3 @@ Aspect_GradientFillMethod Aspect_GradientBackground::BgGradientFillMethod( ) con
 {
   return MyGradientMethod;
 }
-
diff --git a/src/BOP/BOP_Refiner.cxx b/src/BOP/BOP_Refiner.cxx
index 58acedf..b443807 100644
--- a/src/BOP/BOP_Refiner.cxx
+++ b/src/BOP/BOP_Refiner.cxx
@@ -218,10 +218,23 @@
       }
     }//  if (aNbF==1)
   }// for (i=1; i<=aNb; ++i)
-  
+  //
+  //modified by NIZNHY-PKV Wed Nov 03 14:27:22 2010f
+  Standard_Boolean bFound;
+  TopoDS_Iterator aItS;
+  TopAbs_Orientation aOr;
+  //modified by NIZNHY-PKV Wed Nov 03 14:27:24 2010t
+  //
   aNbF=aMFE.Extent();
   for (i=1; i<=aNbF; ++i) {
-    const TopoDS_Face& aF=TopoDS::Face(aMFE.FindKey(i));
+    //modified by NIZNHY-PKV Wed Nov 03 14:29:03 2010f
+    TopoDS_Face aF=TopoDS::Face(aMFE.FindKey(i));
+    aOr=aF.Orientation();
+    if (aOr==TopAbs_INTERNAL) {
+      aF.Orientation(TopAbs_FORWARD);
+    }
+    //const TopoDS_Face& aF=TopoDS::Face(aMFE.FindKey(i));
+    //modified by NIZNHY-PKV Wed Nov 03 14:29:06 2010t
     TopoDS_Face* pF=(TopoDS_Face*)&aF;
     
     const TopTools_ListOfShape& aLE=aMFE(i);
@@ -241,6 +254,23 @@
 	TopTools_ListIteratorOfListOfShape aWIt(aLW);
 	for (; aWIt.More(); aWIt.Next()) {
 	  const TopoDS_Wire& aW=TopoDS::Wire(aWIt.Value());
+	  //
+	  //modified by NIZNHY-PKV Wed Nov 03 14:12:48 2010f
+	  bFound=Standard_False;
+	  aItS.Initialize(aW);
+	  for(; aItS.More(); aItS.Next()) {
+	    const TopoDS_Shape& aEW=aItS.Value();
+	    if (aEW==aE) {
+	      bFound=Standard_True;
+	      break;
+	    }
+	  }
+	  //
+	  if (!bFound) {
+	    continue;
+	  }
+	  //modified by NIZNHY-PKV Wed Nov 03 14:14:22 2010t
+	  //
 	  TopoDS_Wire* pW=(TopoDS_Wire*)&aW;
 	  pW->Free(Standard_True);
 	  //
@@ -253,6 +283,9 @@
 	  //
 	  pF->Free(Standard_True);
 	  aBB.Remove(*pF, aW);
+	  //modified by NIZNHY-PKV Wed Nov 03 14:29:56 2010f
+	  pF->Orientation(aOr);
+	  //modified by NIZNHY-PKV Wed Nov 03 14:29:59 2010t
 	  myNbRemovedEdges++;
 	}
       }
diff --git a/src/BOP/BOP_ShellSolid.cxx b/src/BOP/BOP_ShellSolid.cxx
index 9808113..9a678bf 100644
--- a/src/BOP/BOP_ShellSolid.cxx
+++ b/src/BOP/BOP_ShellSolid.cxx
@@ -547,7 +547,8 @@ static Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1,
   BooleanOperations_StateOfShape aState, aStateCmp;
   TopAbs_Orientation anOr;
   TopExp_Explorer anExp;
-  
+  TopoDS_Edge aSS;
+  //
   iRankF1=aDS.Rank(nF1);
   aStateCmp=BOP_BuilderTools::StateToCompare(iRankF1, myOperation);
   
@@ -564,10 +565,21 @@ static Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1,
     if (!aNbPB) {
       aState=aDS.GetState(nE);
       if (aState==aStateCmp) {
-	TopoDS_Edge aSS=TopoDS::Edge(anE);
-	aSS.Orientation(anOr);
-	//
-	aWES.AddStartElement (aSS);
+	aSS=TopoDS::Edge(anE);
+	//modified by NIZNHY-PKV Mon Sep 19 09:13:59 2011f
+	if (anOr==TopAbs_INTERNAL) {
+	  aSS.Orientation(TopAbs_FORWARD);
+	  aWES.AddStartElement (aSS);
+	  aSS.Orientation(TopAbs_REVERSED);
+	  aWES.AddStartElement (aSS);
+	}
+	else{
+	  aSS.Orientation(anOr);
+	  aWES.AddStartElement (aSS);
+	}
+	//aSS.Orientation(anOr);
+	//aWES.AddStartElement (aSS);
+	//modified by NIZNHY-PKV Mon Sep 19 09:14:02 2011t
       }
       continue;
     }
@@ -580,10 +592,21 @@ static Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1,
       aState=aDS.GetState(nSp);
       if (aState==aStateCmp) {
 	const TopoDS_Shape& aSplit=aDS.Shape(nSp);
-	TopoDS_Edge aSS=TopoDS::Edge(aSplit);
-	aSS.Orientation(anOr);
-	//
-	aWES.AddStartElement (aSS);
+	aSS=TopoDS::Edge(aSplit);
+	//modified by NIZNHY-PKV Mon Sep 19 08:58:23 2011f
+	if (anOr==TopAbs_INTERNAL) {
+	  aSS.Orientation(TopAbs_FORWARD);
+	  aWES.AddStartElement (aSS);
+	  aSS.Orientation(TopAbs_REVERSED);
+	  aWES.AddStartElement (aSS);
+	}
+	else{
+	  aSS.Orientation(anOr);
+	  aWES.AddStartElement (aSS);
+	}
+	//aSS.Orientation(anOr);
+	//aWES.AddStartElement (aSS);
+	//modified by NIZNHY-PKV Mon Sep 19 08:58:33 2011t
       }
     }
   }
diff --git a/src/BOPTest/BOPTest_BOPCommands.cxx b/src/BOPTest/BOPTest_BOPCommands.cxx
index 4a8049d..3ffa9f5 100644
--- a/src/BOPTest/BOPTest_BOPCommands.cxx
+++ b/src/BOPTest/BOPTest_BOPCommands.cxx
@@ -58,18 +58,10 @@
 #include <BRepAlgoAPI_Fuse.hxx>
 #include <BRepAlgoAPI_Cut.hxx>
 
-#include <TColStd_IndexedMapOfInteger.hxx>
-
-
-
-//XX
-// CHRONOMETER
-//
-#include <Standard_Static.hxx>
 #include <OSD_Chronometer.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
 
-
-Standard_STATIC(OSD_Chronometer, S_Chrono);
+static OSD_Chronometer DRAW_BOP_CHRONO;
 static void StartChrono();
 static void StopChrono(Draw_Interpretor&); 
 Standard_Integer btimesum (Draw_Interpretor& , Standard_Integer n, const char** a);
@@ -752,8 +744,8 @@ void StartChrono()
   char *xr=getenv ("BOPCHRONO");
   if (xr!=NULL){
     if (!strcmp (xr, "yes")){
-      S_Chrono().Reset();
-      S_Chrono().Start();
+      DRAW_BOP_CHRONO.Reset();
+      DRAW_BOP_CHRONO.Start();
     }
   }
 }
@@ -768,8 +760,8 @@ void StopChrono(Draw_Interpretor& di)
   if (xr!=NULL){
     if (!strcmp (xr, "yes")) {
       Standard_Real Chrono;
-      S_Chrono().Stop();
-      S_Chrono().Show(Chrono);
+      DRAW_BOP_CHRONO.Stop();
+      DRAW_BOP_CHRONO.Show(Chrono);
       //
       char *aFileName=getenv("BOPCHRONOFILE");
       if (aFileName!=NULL){
diff --git a/src/BOPTest/BOPTest_LowCommands.cxx b/src/BOPTest/BOPTest_LowCommands.cxx
index 748c304..2af5281 100644
--- a/src/BOPTest/BOPTest_LowCommands.cxx
+++ b/src/BOPTest/BOPTest_LowCommands.cxx
@@ -55,7 +55,6 @@
 #include <IntTools_Context.hxx>
 #include <IntTools_FClass2d.hxx>
 #include <gp_Pnt2d.hxx>
-#include <Standard_Static.hxx>
 #include <OSD_Chronometer.hxx>
 
 #include <BRepTools.hxx>
diff --git a/src/BOPTools/BOPTools_PCurveMaker.cxx b/src/BOPTools/BOPTools_PCurveMaker.cxx
index 00a3337..a46cce3 100644
--- a/src/BOPTools/BOPTools_PCurveMaker.cxx
+++ b/src/BOPTools/BOPTools_PCurveMaker.cxx
@@ -6,10 +6,12 @@
 
 #include <BOPTools_PCurveMaker.ixx>
 
+#include <gp_Pnt.hxx>
 #include <gp_Pnt2d.hxx>
 
 #include <Precision.hxx>
 
+#include <Geom_Surface.hxx>
 #include <Geom_Curve.hxx>
 #include <Geom_TrimmedCurve.hxx>
 #include <Geom2d_Curve.hxx>
@@ -45,6 +47,10 @@
 #include <BOPTools_PaveBlock.hxx>
 #include <BOPTools_Tools2D.hxx>
 
+//modified by NIZNHY-PKV Tue Jun 28 13:24:42 2011f
+static 
+  void UpdateVertices(const TopoDS_Edge& aE, const TopoDS_Face& aF);
+//modified by NIZNHY-PKV Tue Jun 28 13:24:46 2011t
 
 //=======================================================================
 // function: BOPTools_PCurveMaker
@@ -71,7 +77,6 @@
 //=======================================================================
   void BOPTools_PCurveMaker::Do()
 {
-  
   BOPTools_CArray1OfSSInterference& aFFs=(myFiller->InterfPool())->SSInterferences();
   
   Standard_Integer i, aNb,  nF1, nF2, nE;
@@ -152,7 +157,6 @@
 	const Handle(Geom_Curve)& aC3DE=BRep_Tool::Curve(aE, aTFirst, aTLast);
 	Handle(Geom_TrimmedCurve)aC3DETrim=new Geom_TrimmedCurve(aC3DE, aTFirst, aTLast);
 	//
-	//modified by NIZNHY-PKV Wed Sep  3 11:13:41 2003 f 
 	Handle(Geom2d_Curve) aC2D1, aC2D1A, aC2D2, aC2D2A;
 	//
 	aC2D1=aIC.FirstCurve2d();
@@ -160,9 +164,6 @@
 	  BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
 	  BOPTools_Tools2D::CurveOnSurface(aE, aF1FWD, aC2D1, aOutFirst, aOutLast, aOutTol, Standard_True);
 	}
-	//const Handle(Geom2d_Curve)& aC2D1=aIC.FirstCurve2d();
-	//Handle(Geom2d_Curve) aC2D1A;
-	//modified by NIZNHY-PKV Wed Sep  3 11:13:48 2003 t
 	//
 	if (aC3DE->IsPeriodic()) {
 	  BOPTools_Tools2D::AdjustPCurveOnFace(aF1FWD, aTFirst, aTLast,  aC2D1, aC2D1A); 
@@ -172,16 +173,15 @@
 	}
 	//
 	aBB.UpdateEdge(aE, aC2D1A, aF1FWD, aTolFact);
+	//modified by NIZNHY-PKV Tue Jun 28 07:52:55 2011f
+	UpdateVertices(aE, aF1FWD);
+	//modified by NIZNHY-PKV Tue Jun 28 07:52:57 2011t
 
-	//modified by NIZNHY-PKV Wed Sep  3 11:23:00 2003 f
 	aC2D2=aIC.SecondCurve2d();
 	if (aC2D2.IsNull()) {
 	  BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
 	  BOPTools_Tools2D::CurveOnSurface(aE, aF2FWD, aC2D2, aOutFirst, aOutLast, aOutTol, Standard_True);
 	}
-	//const Handle(Geom2d_Curve)& aC2D2=aIC.SecondCurve2d();
-	//Handle(Geom2d_Curve) aC2D2A;
-	//modified by NIZNHY-PKV Wed Sep  3 11:23:12 2003 t
 	//
 	if (aC3DE->IsPeriodic()) {
 	  BOPTools_Tools2D::AdjustPCurveOnFace(aF2FWD, aTFirst, aTLast, aC2D2, aC2D2A); 
@@ -191,6 +191,9 @@
 	}
 	//
 	aBB.UpdateEdge(aE, aC2D2A, aF2FWD, aTolFact);
+	//modified by NIZNHY-PKV Tue Jun 28 07:52:55 2011f
+	UpdateVertices(aE, aF2FWD);
+	//modified by NIZNHY-PKV Tue Jun 28 07:52:57 2011t
       } 
     }// for (j=1; j<=aNbCurves; j++)
     
@@ -198,3 +201,47 @@
   myIsDone=Standard_True;
 }
 
+//modified by NIZNHY-PKV Tue Jun 28 07:37:47 2011f
+//=======================================================================
+//function : UpdateVertices
+//purpose  : update tolerances of vertices comparing extremities of
+//           3d and 2d curves
+//=======================================================================
+void UpdateVertices(const TopoDS_Edge& aE, const TopoDS_Face& aF)
+{
+  Standard_Integer j;
+  Standard_Real aT[2], aUx, aVx, aTolV2, aD2, aD;
+  gp_Pnt aP3D, aP3Dx;
+  gp_Pnt2d aP2Dx;
+  Handle(Geom_Surface) aS;
+  Handle(Geom_Curve) aC3D;
+  Handle(Geom2d_Curve) aC2D;
+  TopoDS_Edge aEf;
+  TopoDS_Vertex aV[2];
+  BRep_Builder aBB;
+  //
+  aEf=aE;
+  aEf.Orientation(TopAbs_FORWARD);
+  //
+  TopExp::Vertices(aEf, aV[0], aV[1]);
+  //
+  aS=BRep_Tool::Surface(aF);
+  aC3D=BRep_Tool::Curve(aEf, aT[0], aT[1]);
+  aC2D=BRep_Tool::CurveOnSurface(aEf, aF, aT[0], aT[1]);
+  //
+  for (j=0; j<2; ++j) {
+    aTolV2=BRep_Tool::Tolerance(aV[j]);
+    aTolV2=aTolV2*aTolV2;
+    //
+    aC3D->D0(aT[j], aP3D);
+    aC2D->D0(aT[j], aP2Dx);
+    aP2Dx.Coord(aUx, aVx);
+    aS->D0(aUx, aVx, aP3Dx);
+    aD2=aP3D.SquareDistance(aP3Dx);
+    if (aD2>aTolV2) {
+      aD=sqrt(aD2);
+      aBB.UpdateVertex(aV[j], aD);
+    }
+  }
+}
+//modified by NIZNHY-PKV Tue Jun 28 07:37:50 2011t
diff --git a/src/BOPTools/BOPTools_PaveFiller_3.cxx b/src/BOPTools/BOPTools_PaveFiller_3.cxx
index 52cfdb3..3739680 100644
--- a/src/BOPTools/BOPTools_PaveFiller_3.cxx
+++ b/src/BOPTools/BOPTools_PaveFiller_3.cxx
@@ -130,7 +130,16 @@ static
 				 BOPTools_PaveFiller& aPF,
 				 TColStd_SequenceOfInteger& aSeqVx,
 				 TColStd_SequenceOfReal& aSeqTolVx);
- 
+//modified by NIZNHY-PKV Wed Aug 31 10:32:52 2011f 
+static
+  void ProcessAloneStickVertices(const Standard_Integer nF1,
+				 const Standard_Integer nF2,
+				 const BOPTools_PaveSet& aPSF,
+				 BOPTools_SequenceOfCurves& aSCvs,
+				 BOPTools_PaveFiller& aPF,
+				 TColStd_SequenceOfInteger& aSeqVx,
+				 TColStd_SequenceOfReal& aSeqTolVx);
+//modified by NIZNHY-PKV Wed Aug 31 10:32:59 2011t 
 //wkar OCC334 t
 
 static
@@ -182,6 +191,14 @@ static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC,
                                            const TopTools_ListOfShape& theL,
                                            Standard_Real&        theTF);
 
+//modified by NIZNHY-PKV Sat Mar 05 12:23:05 2011f
+static
+  void CorrectTolR3D(BOPTools_PaveFiller& aPF,
+		     const BOPTools_SSInterference& aFF,
+		     const TColStd_MapOfInteger& aMVStick,
+		     Standard_Real& aTolR3D);
+//modified by NIZNHY-PKV Sat Mar 05 12:23:07 2011t
+
 //=======================================================================
 // function: PerformFF
 // purpose: 
@@ -448,13 +465,14 @@ static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC,
 
   for (i=1; i<=aNbFFs; i++) {
     BOPTools_SSInterference& aFFi=aFFs(i);
-    // 
+    //  
+    nF1=aFFi.Index1();
+    nF2=aFFi.Index2();
+    //
     // Curves' tolerance
     aTolR3D=aFFi.TolR3D();
     //
     // Faces
-    nF1=aFFi.Index1();
-    nF2=aFFi.Index2();
     const TopoDS_Face& aF1=TopoDS::Face(myDS->GetShape(nF1));
     const TopoDS_Face& aF2=TopoDS::Face(myDS->GetShape(nF2));
 
@@ -570,7 +588,6 @@ static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC,
             continue;
           }
         }
-        // -&&
         //
 	aBC.AppendNewBlock(aPBNew);
       }
@@ -1324,9 +1341,10 @@ static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC,
 {
   Standard_Integer nV;
   Standard_Boolean bIsVertexOnLine;
-  Standard_Real aT, aTolVExt;
-  
-
+  Standard_Real aT, aTolVExt, aTolTresh;
+  BRep_Builder aBB;
+  //
+  aTolTresh=0.01;
   nV=aPave.Index();
   const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
   const IntTools_Curve& aC=aBC.Curve();
@@ -1342,6 +1360,11 @@ static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC,
     aPaveSet.Append(aPaveNew);
     //<-B
     BOPTools_Tools::UpdateVertex (aC, aT, aV);
+    //modified by NIZNHY-PKV Sat Mar 05 13:43:27 2011f
+    if(aTolR3D<aTolTresh) {
+    aBB.UpdateVertex(aV, aTolR3D);
+    }
+    //modified by NIZNHY-PKV Sat Mar 05 13:43:29 2011t
   }
 }
 //
@@ -1431,7 +1454,25 @@ static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC,
     // Put existing paves on curves
     BOPTools_PaveSet aPSF;
     PrepareSetForFace (nF1, nF2, aPSF);
-
+    //
+    //modified by NIZNHY-PKV Sat Mar 05 12:12:05 2011f
+    {
+      Standard_Integer nVX;
+      BOPTools_ListIteratorOfListOfPave aItLP;
+      TColStd_MapOfInteger aMVStick;
+      //
+      const BOPTools_ListOfPave& aLPX=aPSF.Set();
+      aItLP.Initialize(aLPX);
+      for (; aItLP.More(); aItLP.Next()) {
+	const BOPTools_Pave& aPX=aItLP.Value();
+	nVX=aPX.Index();
+	aMVStick.Add(nVX);
+      }
+      //
+      CorrectTolR3D(*this, aFFi, aMVStick, aTolR3D);
+    }
+    //modified by NIZNHY-PKV Sat Mar 05 12:12:07 2011t
+    //
     BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
     aNbCurves=aSCvs.Length();
     for (j=1; j<=aNbCurves; j++) {
@@ -1442,7 +1483,43 @@ static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC,
       //
       PutPaveOnCurve (aPSF, aTolR3D, aBC);
     }
+    //modified by NIZNHY-PKV Tue Aug 30 14:54:50 2011f
+    {
+      Standard_Integer aNbVtx, jx;
+      Standard_Real aTolVRange;
+      TColStd_SequenceOfInteger aSeqVx;
+      TColStd_SequenceOfReal    aSeqTolVx;
+      //
+      ProcessAloneStickVertices(nF1, 
+				nF2, 
+				aPSF, 
+				aSCvs, 
+				*this,
+				aSeqVx, 
+				aSeqTolVx);
+      // 
+      aNbVtx=aSeqVx.Length();
+      for (jx=1; jx<=aNbVtx; ++jx) {
+	BOPTools_PaveSet aPSFx;
+	BOPTools_Pave aPVx;
 
+	nV=aSeqVx(jx);
+	aTolVRange=aSeqTolVx(jx);
+	
+	aPVx.SetIndex(nV);
+	aPSFx.Append(aPVx);
+
+	for (j=1; j<=aNbCurves; j++) {
+	  BOPTools_Curve& aBC=aSCvs(j);
+	  // DEBUG
+	  const IntTools_Curve& aC=aBC.Curve();
+	  Handle (Geom_Curve) aC3D= aC.Curve();
+	  //
+	  PutPaveOnCurve (aPSFx, aTolVRange, aBC);
+	}
+      }
+    }
+    //modified by NIZNHY-PKV Tue Aug 30 14:54:56 2011t
     //
     // Put bounding paves on curves
     //Check very specific case of cone-cone intersection (OCC13211)
@@ -1793,6 +1870,7 @@ Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
 #include <Geom_Surface.hxx>
 #include <GeomAdaptor_Surface.hxx>
 #include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <BOPTools_Tools3D.hxx>
 
 //=======================================================================
 // function: ProcessAloneStickVertices
@@ -1884,6 +1962,106 @@ void ProcessAloneStickVertices(const Standard_Integer nF1,
     }
   }
 }
+//modified by NIZNHY-PKV Wed Aug 31 10:29:29 2011f
+//=======================================================================
+// function: ProcessAloneStickVertices
+// purpose: 
+//=======================================================================
+void ProcessAloneStickVertices(const Standard_Integer nF1,
+			       const Standard_Integer nF2,
+			       const BOPTools_PaveSet& aPSF,
+			       BOPTools_SequenceOfCurves& aSCvs,
+			       BOPTools_PaveFiller& aPF,
+			       TColStd_SequenceOfInteger& aSeqVx,
+			       TColStd_SequenceOfReal& aSeqTolVx)
+{
+  GeomAbs_SurfaceType aType1, aType2;
+  //
+  BooleanOperations_PShapesDataStructure pDS=aPF.DS();
+  //
+  const TopoDS_Face& aF1= TopoDS::Face(pDS->Shape(nF1));
+  const TopoDS_Face& aF2= TopoDS::Face(pDS->Shape(nF2));
+  Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1);
+  Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2);
+  GeomAdaptor_Surface aGAS1(aS1);
+  GeomAdaptor_Surface aGAS2(aS2);
+  //
+  aType1=aGAS1.GetType();
+  aType2=aGAS2.GetType();
+  //
+  if(aType1==GeomAbs_Torus  || aType2==GeomAbs_Torus) {
+    Standard_Integer aNbSCvs, jVU, aNbVU, nVU, k, m, n;
+    Standard_Real aTC[2], aD, aD2, aDT2, aU, aV, aScPr, aDScPr;
+    TColStd_IndexedMapOfInteger aMVU;
+    GeomAbs_CurveType aTypeC;
+    gp_Pnt aPC[2], aPVU;
+    gp_Dir aDN[2];
+    gp_Pnt2d aP2D;
+    
+    Handle(Geom2d_Curve) aC2D[2];
+    //
+    aDT2=2e-7;     // the rich criteria
+    aDScPr=5.e-9;  // the creasing criteria
+    //
+    UnUsedMap(aSCvs, aPSF, aMVU);
+    //
+    aNbVU=aMVU.Extent();
+    for (jVU=1; jVU<=aNbVU; ++jVU) {
+      nVU=aMVU(jVU);
+      const TopoDS_Vertex& aVU=*((TopoDS_Vertex*)&pDS->Shape(nVU));
+      aPVU=BRep_Tool::Pnt(aVU);
+      //
+      aNbSCvs=aSCvs.Length();
+      for (k=1; k<=aNbSCvs; ++k) {
+	BOPTools_Curve& aBC=aSCvs(k);
+	const IntTools_Curve& aIC=aBC.Curve();
+	//Handle(Geom_Curve) aC3D=aIC.Curve(); //DEB
+	aTypeC=aIC.Type();
+	if (!(aTypeC==GeomAbs_BezierCurve || GeomAbs_BSplineCurve)) {
+	  continue;
+	}
+	//
+	aIC.Bounds(aTC[0], aTC[1], aPC[0], aPC[1]);
+	aC2D[0]=aIC.FirstCurve2d();
+	aC2D[1]=aIC.SecondCurve2d();
+	if (aC2D[0].IsNull() || aC2D[1].IsNull()) {
+	   continue;
+	}
+	//
+	for (m=0; m<2; ++m) {
+	  aD2=aPC[m].SquareDistance(aPVU);
+	  if (aD2>aDT2) {// no rich
+	    continue; 
+	  }
+	  //
+	  for (n=0; n<2; ++n) {
+	    Handle(Geom_Surface)& aS=(!n)? aS1 : aS2;
+	    aC2D[n]->D0(aTC[m], aP2D);
+	    aP2D.Coord(aU, aV);
+	    BOPTools_Tools3D::GetNormalToSurface(aS, aU, aV, aDN[n]);
+	  }
+	  // 
+	  aScPr=aDN[0]*aDN[1];
+	  if (aScPr<0.) {
+	    aScPr=-aScPr;
+	  }
+	  aScPr=1.-aScPr;
+	  //
+	  if (aScPr>aDScPr) {
+	    continue;
+	  }
+	  //
+	  // The intersection curve aIC is vanishing curve (the crease)
+	  aD=sqrt(aD2);
+	  //
+	  aSeqVx.Append(nVU);
+	  aSeqTolVx.Append(aD);
+	}
+      }//for (k=1; k<=aNbSCvs; ++k) {
+    }//for (jVU=1; jVU=aNbVU; ++jVU) {
+  }//if(aType1==GeomAbs_Torus  || aType2==GeomAbs_Torus) {
+}
+//modified by NIZNHY-PKV Wed Aug 31 10:29:37 2011t
 //=======================================================================
 // function: UnUsedMap
 // purpose: 
@@ -3053,3 +3231,100 @@ Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC,
   theTF = maxD;
   return eIndex;
 }
+//=======================================================================
+//function : CorrectTolR3D
+//purpose  : 
+//=======================================================================
+void CorrectTolR3D(BOPTools_PaveFiller& aPF,
+		   const BOPTools_SSInterference& aFF,
+		   const TColStd_MapOfInteger& aMVStick,
+		   Standard_Real& aTolR3D)
+{
+  Standard_Boolean bHasBounds;
+  Standard_Integer i, nF[2], nV, aNbCurves;
+  Standard_Real aT1, aT2, aU, aV, aT, aA, aTolV, aTolVmax;
+  Standard_Real aTolR, aTolTresh, aAmin, aAmax;
+  TColStd_MapIteratorOfMapOfInteger aIt;
+  gp_Pnt aP, aP1, aP2;
+  gp_Dir aDN[2];
+  gp_Vec aVT;
+  Handle(Geom_Surface) aS[2];
+  Handle(Geom_Curve) aC3D;
+  GeomAdaptor_Surface aGAS;
+  GeomAbs_SurfaceType aType;
+  TopoDS_Face aF[2];
+  //
+  BooleanOperations_PShapesDataStructure myDS=aPF.DS();
+  IntTools_Context& myContext=aPF.ChangeContext();
+  //
+  aTolTresh=0.0005;
+  aAmin=0.012;// 0.7-7 deg
+  aAmax=0.12;
+  //
+  if (!aMVStick.Extent()) {
+    return;
+  }
+  //
+  BOPTools_SSInterference& aFFi=*((BOPTools_SSInterference*)&aFF);
+  BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
+  aNbCurves=aSCvs.Length();
+  if (aNbCurves!=1){
+    return;
+  }
+  //
+  aFFi.Indices(nF[0], nF[1]);
+  for (i=0; i<2; ++i) {
+    aF[i]=*((TopoDS_Face*)(&myDS->Shape(nF[i])));
+    aS[i]=BRep_Tool::Surface(aF[i]);
+    aGAS.Load(aS[i]);
+    aType=aGAS.GetType();
+    if (aType!=GeomAbs_BSplineSurface) {
+      return;
+    }
+  }
+  //
+  BOPTools_Curve& aBC=aSCvs(1);
+  const IntTools_Curve& aIC=aBC.Curve();
+  bHasBounds=aIC.HasBounds();
+  if (!bHasBounds){
+    return;
+  }
+  //
+  aIC.Bounds (aT1, aT2, aP1, aP2);
+  aT=IntTools_Tools::IntermediatePoint(aT1, aT2);
+  aC3D=aIC.Curve();
+  aC3D->D0(aT, aP);
+  //
+  for (i=0; i<2; ++i) {
+    GeomAPI_ProjectPointOnSurf& aPPS=myContext.ProjPS(aF[i]);
+    aPPS.Perform(aP);
+    aPPS.LowerDistanceParameters(aU, aV);
+    BOPTools_Tools3D::GetNormalToSurface(aS[i], aU, aV, aDN[i]);
+  }
+  //
+  aA=aDN[0].Angle(aDN[1]);
+  aA=fabs(aA);
+  if (aA>0.5*PI) {
+    aA=PI-aA;
+  }
+  //
+  if (aA<aAmin || aA>aAmax) {
+    return;
+  }
+  //
+  aTolVmax=-1.;
+  aIt.Initialize(aMVStick);
+  for (; aIt.More(); aIt.Next()) {
+    nV=aIt.Key();
+    const TopoDS_Vertex& aV=*((TopoDS_Vertex*)(&myDS->Shape(nV)));
+    aTolV=BRep_Tool::Tolerance(aV);
+    if (aTolV>aTolVmax) {
+      aTolVmax=aTolV;
+    }
+  }
+  //
+  aTolR=aTolVmax/aA;
+  if (aTolR<aTolTresh) {
+    aTolR3D=aTolR;
+  }
+}
diff --git a/src/BOPTools/BOPTools_Tools3D_1.cxx b/src/BOPTools/BOPTools_Tools3D_1.cxx
index a602bd8..72f0fcb 100644
--- a/src/BOPTools/BOPTools_Tools3D_1.cxx
+++ b/src/BOPTools/BOPTools_Tools3D_1.cxx
@@ -830,58 +830,6 @@ void Add(const TopoDS_Shape& aS,
   }
   return aStPF;
 }
-
-// ===========================================================================================
-// function: CheckSameDomainFaceInside
-// purpose: Check if distance between several points of theFace1 and
-//          theFace2 
-// ===========================================================================================
-Standard_Boolean BOPTools_Tools3D::CheckSameDomainFaceInside(const TopoDS_Face& theFace1,
-							     const TopoDS_Face& theFace2,
-							     IntTools_Context&  theContext) 
-{
-  Standard_Real umin = 0., umax = 0., vmin = 0., vmax = 0.;
-  BRepTools::UVBounds(theFace1, umin, umax, vmin, vmax);
-  Handle(Geom_Surface) aSurface = BRep_Tool::Surface(theFace1);
-
-  Standard_Real aTolerance = BRep_Tool::Tolerance(theFace1);
-  aTolerance += BRep_Tool::Tolerance(theFace2);
-
-  Standard_Integer nbpoints = 5;
-  Standard_Real adeltau = (umax - umin) / (nbpoints + 1);
-  Standard_Real adeltav = (vmax - vmin) / (nbpoints + 1);
-  Standard_Real U = umin + adeltau;
-  Standard_Boolean bFoundON = Standard_False;
-  GeomAPI_ProjectPointOnSurf& aProjector = theContext.ProjPS(theFace2);
-
-  for(Standard_Integer i = 1; i <= nbpoints; i++, U+=adeltau) {
-    Standard_Real V = vmin + adeltav;
-
-    for(Standard_Integer j = 1; j <= nbpoints; j++, V+=adeltav) {
-      gp_Pnt2d aPoint(U,V);
-
-      if(theContext.IsPointInFace(theFace1, aPoint)) {
-	gp_Pnt aP3d = aSurface->Value(U, V);
-	aProjector.Perform(aP3d);
-
-	if(aProjector.IsDone()) {
-	  Standard_Real U2 = 0., V2 = 0.;
-	  aProjector.LowerDistanceParameters(U2, V2);
-
-	  aPoint = gp_Pnt2d(U2, V2);
-
-	  if(aProjector.LowerDistance() > aTolerance)
-	     return Standard_False;
-	  else if(theContext.IsPointInFace(theFace2, aPoint))
-	    bFoundON = Standard_True;
-	}
-      }
-    }
-  }
-
-  return bFoundON;
-}
-
 // ===========================================================================================
 // function: ComputeFaceState
 // purpose: 
@@ -994,3 +942,68 @@ Standard_Boolean BOPTools_Tools3D::ComputeFaceState(const TopoDS_Face&  theFace,
 
   return Standard_True;
 }
+//modified by NIZNHY-PKV Thu Sep 22 10:55:14 2011f
+// ===========================================================================================
+// function: CheckSameDomainFaceInside
+// purpose: Check if distance between several points of theFace1 and
+//          theFace2 
+// ===========================================================================================
+Standard_Boolean BOPTools_Tools3D::CheckSameDomainFaceInside(const TopoDS_Face& theFace1,
+							     const TopoDS_Face& theFace2,
+							     IntTools_Context&  theContext) 
+{
+  Standard_Boolean bFoundON, bPointInFace; 
+  Standard_Integer nbpoints, i, j;
+  Standard_Real umin, umax, vmin, vmax, aTol, adeltau, adeltav, U, V, U2, V2, aD, aTolE;
+  gp_Pnt2d aP2D;
+  gp_Pnt aP3D; 
+  TopExp_Explorer aExp;
+  //
+  BRepTools::UVBounds(theFace1, umin, umax, vmin, vmax);
+  Handle(Geom_Surface) aS1=BRep_Tool::Surface(theFace1);
+  //
+  aTol=BRep_Tool::Tolerance(theFace1);
+  aExp.Init(theFace1, TopAbs_EDGE);
+  for(; aExp.More(); aExp.Next()) {
+    const TopoDS_Edge& aE = TopoDS::Edge(aExp.Current());
+    aTolE = BRep_Tool::Tolerance(aE);
+    aTol=(aTol < aTolE) ? aTolE : aTol;
+  }
+  aTol=aTol+BRep_Tool::Tolerance(theFace2);
+  //
+  nbpoints=5;
+  adeltau=(umax - umin) / (nbpoints + 1);
+  adeltav=(vmax - vmin) / (nbpoints + 1);
+  bFoundON = Standard_False;
+  //
+  GeomAPI_ProjectPointOnSurf& aProjector = theContext.ProjPS(theFace2);
+  //
+  for(i=1; i<=nbpoints; ++i){
+    U=umin+i*adeltau;
+    for(j=1; j<=nbpoints; ++j) {
+      V=vmin+j*adeltav;
+      aP2D.SetCoord(U,V);
+      bPointInFace=theContext.IsPointInFace(theFace1, aP2D);
+      if(bPointInFace) {
+	aP3D=aS1->Value(U, V);
+	aProjector.Perform(aP3D);
+	if(aProjector.IsDone()) {
+	  aProjector.LowerDistanceParameters(U2, V2);
+	  aP2D.SetCoord(U2, V2);
+	  //
+	  aD=aProjector.LowerDistance();
+	  if(aD > aTol) {
+	    return Standard_False;
+	  }
+	  //
+	  bPointInFace=theContext.IsPointInFace(theFace2, aP2D);
+	  if (bPointInFace) {
+	    bFoundON = Standard_True;
+	  }
+	}
+      }
+    }
+  }
+  return bFoundON;
+}
+//modified by NIZNHY-PKV Thu Sep 22 10:55:19 2011t
diff --git a/src/BRepAlgo/BRepAlgo_Section.cxx b/src/BRepAlgo/BRepAlgo_Section.cxx
index 14e1d1f..7df7c14 100644
--- a/src/BRepAlgo/BRepAlgo_Section.cxx
+++ b/src/BRepAlgo/BRepAlgo_Section.cxx
@@ -380,6 +380,6 @@ static TopoDS_Shape MakeShape(const Handle(Geom_Surface)& );
 TopoDS_Shape MakeShape(const Handle(Geom_Surface)& S)
 {
   GeomAbs_Shape c = S->Continuity();
-  if (c >= GeomAbs_C2) return BRepBuilderAPI_MakeFace(S);
+  if (c >= GeomAbs_C2) return BRepBuilderAPI_MakeFace(S, Precision::Confusion());
   else return BRepBuilderAPI_MakeShell(S);
 }
diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_Section.cxx b/src/BRepAlgoAPI/BRepAlgoAPI_Section.cxx
index a415c83..7fffe90 100644
--- a/src/BRepAlgoAPI/BRepAlgoAPI_Section.cxx
+++ b/src/BRepAlgoAPI/BRepAlgoAPI_Section.cxx
@@ -36,7 +36,7 @@
 static TopoDS_Shape MakeShape(const Handle(Geom_Surface)& S)
 {
   GeomAbs_Shape c = S->Continuity();
-  if (c >= GeomAbs_C2) return BRepBuilderAPI_MakeFace(S);
+  if (c >= GeomAbs_C2) return BRepBuilderAPI_MakeFace(S, Precision::Confusion());
   else return BRepBuilderAPI_MakeShell(S);
 }
 
diff --git a/src/BRepBndLib/BRepBndLib.cdl b/src/BRepBndLib/BRepBndLib.cdl
index 02472e5..13bbe1f 100644
--- a/src/BRepBndLib/BRepBndLib.cdl
+++ b/src/BRepBndLib/BRepBndLib.cdl
@@ -24,7 +24,9 @@ is
     -- 	 Package methods for shapes
     -- 	 
 
-    Add(S : Shape from TopoDS; B : in out Box from Bnd);
+    Add(S               : Shape from TopoDS; 
+        B               : in out Box from Bnd;
+        useTriangulation: Boolean from Standard = Standard_True);
     	---Purpose:Adds the shape S to the bounding box B.
 -- More precisely are successively added to B:
 -- -   each face of S; the triangulation of the face is used if it exists,
diff --git a/src/BRepBndLib/BRepBndLib.cxx b/src/BRepBndLib/BRepBndLib.cxx
index 28bc3b5..cbc4e4e 100644
--- a/src/BRepBndLib/BRepBndLib.cxx
+++ b/src/BRepBndLib/BRepBndLib.cxx
@@ -26,12 +26,11 @@
 //purpose  : Add a shape bounding to a box
 //=======================================================================
 
-void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B)
+void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTriangulation)
 {
   TopExp_Explorer ex;
 
   // Add the faces
-
   BRepAdaptor_Surface BS;
   Handle(Geom_Surface) GS;
   Handle(Poly_Triangulation) T;
@@ -42,80 +41,86 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B)
   for (ex.Init(S,TopAbs_FACE); ex.More(); ex.Next()) {
     const TopoDS_Face& F = TopoDS::Face(ex.Current());
     T = BRep_Tool::Triangulation(F, l);
-    if (!T.IsNull()) {
+    if (useTriangulation && !T.IsNull())
+    {
       nbNodes = T->NbNodes();
       const TColgp_Array1OfPnt& Nodes = T->Nodes();
       for (i = 1; i <= nbNodes; i++) {
-	if (l.IsIdentity()) B.Add(Nodes(i));
-	else B.Add(Nodes(i).Transformed(l));
+        if (l.IsIdentity()) B.Add(Nodes(i));
+        else B.Add(Nodes(i).Transformed(l));
       }
       //       B.Enlarge(T->Deflection());
       B.Enlarge(T->Deflection() + BRep_Tool::Tolerance(F));
-    }
-    else {
+    } else
+    {
       GS = BRep_Tool::Surface(F, l);
       if (!GS.IsNull()) {
-	BS.Initialize(F, Standard_False);
-	if (BS.GetType() != GeomAbs_Plane) {
-	  BS.Initialize(F);
-	  BndLib_AddSurface::Add(BS, BRep_Tool::Tolerance(F), B);
-	}
-	else {
-	  // on travaille directement sur les courbes 3d.
-	  TopExp_Explorer ex2(F, TopAbs_EDGE);
-	  if (!ex2.More()) {
-	    BS.Initialize(F);
-	    BndLib_AddSurface::Add(BS, BRep_Tool::Tolerance(F), B);
-	  }
-	  else {
-	    for (;ex2.More();ex2.Next()) {
-	      BC.Initialize(TopoDS::Edge(ex2.Current()));
-	      BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(F), B);
-	    }
-	    B.Enlarge(BRep_Tool::Tolerance(F));
-	  }
-	}
+        BS.Initialize(F, Standard_False);
+        if (BS.GetType() != GeomAbs_Plane) {
+          BS.Initialize(F);
+          BndLib_AddSurface::Add(BS, BRep_Tool::Tolerance(F), B);
+        }
+        else {
+          // on travaille directement sur les courbes 3d.
+          TopExp_Explorer ex2(F, TopAbs_EDGE);
+          if (!ex2.More()) {
+            BS.Initialize(F);
+            BndLib_AddSurface::Add(BS, BRep_Tool::Tolerance(F), B);
+          }
+          else {
+            for (;ex2.More();ex2.Next()) {
+              BC.Initialize(TopoDS::Edge(ex2.Current()));
+              BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(F), B);
+            }
+            B.Enlarge(BRep_Tool::Tolerance(F));
+          }
+        }
       }
     }
   }
 
   // Add the edges not in faces
-
-
   Handle(TColStd_HArray1OfInteger) HIndices;
   Handle(Poly_PolygonOnTriangulation) Poly;
 
-  for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE); ex.More(); ex.Next()) {
+  for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE); ex.More(); ex.Next())
+  {
     const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
     Handle(Poly_Polygon3D) P3d = BRep_Tool::Polygon3D(E, l);
-    if (!P3d.IsNull()) {
+    if (!P3d.IsNull())
+    {
       const TColgp_Array1OfPnt& Nodes = P3d->Nodes();
       nbNodes = P3d->NbNodes();
-      for (i = 1; i <= nbNodes; i++) {
-	if (l.IsIdentity()) B.Add(Nodes(i));
-	else B.Add(Nodes(i).Transformed(l));
+      for (i = 1; i <= nbNodes; i++)
+      {
+        if (l.IsIdentity()) B.Add(Nodes(i));
+        else B.Add(Nodes(i).Transformed(l));
       }
       //       B.Enlarge(P3d->Deflection());
       B.Enlarge(P3d->Deflection() + BRep_Tool::Tolerance(E));
     }
-    else {
+    else
+    {
       BRep_Tool::PolygonOnTriangulation(E, Poly, T, l);
-      if (!Poly.IsNull()) {
-	const TColStd_Array1OfInteger& Indices = Poly->Nodes();
-	const TColgp_Array1OfPnt& Nodes = T->Nodes();
-	nbNodes = Indices.Length();
-	for (i = 1; i <= nbNodes; i++) {
-	  if (l.IsIdentity()) B.Add(Nodes(Indices(i)));
-	  else B.Add(Nodes(Indices(i)).Transformed(l));
-	}
-	// 	B.Enlarge(T->Deflection());
-	B.Enlarge(Poly->Deflection() + BRep_Tool::Tolerance(E));
+      if (useTriangulation && !Poly.IsNull())
+      {
+        const TColStd_Array1OfInteger& Indices = Poly->Nodes();
+        const TColgp_Array1OfPnt& Nodes = T->Nodes();
+        nbNodes = Indices.Length();
+        for (i = 1; i <= nbNodes; i++)
+        {
+          if (l.IsIdentity()) B.Add(Nodes(Indices(i)));
+          else B.Add(Nodes(Indices(i)).Transformed(l));
+        }
+        // 	B.Enlarge(T->Deflection());
+        B.Enlarge(Poly->Deflection() + BRep_Tool::Tolerance(E));
       }
       else {
-	if (BRep_Tool::IsGeometric(E)) {
-	  BC.Initialize(E);
-	  BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(E), B);
-	}
+        if (BRep_Tool::IsGeometric(E))
+        {
+          BC.Initialize(E);
+          BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(E), B);
+        }
       }
     }
   }
diff --git a/src/BRepBuilderAPI/BRepBuilderAPI_MakeFace.cdl b/src/BRepBuilderAPI/BRepBuilderAPI_MakeFace.cdl
index 5e54e04..4fe6aa0 100644
--- a/src/BRepBuilderAPI/BRepBuilderAPI_MakeFace.cdl
+++ b/src/BRepBuilderAPI/BRepBuilderAPI_MakeFace.cdl
@@ -90,9 +90,10 @@ is
 	---Level: Public
     returns MakeFace from BRepBuilderAPI;
 
-    Create(S : Surface from Geom)
-	---Purpose: Make a face from a Surface.
-	---Level: Public
+    Create(S : Surface from Geom; TolDegen : Real)
+    ---Purpose: Make a face from a Surface. Accepts tolerance value (TolDegen)
+    -- for resolution of degenerated edges.
+    ---Level: Public
     returns MakeFace from BRepBuilderAPI;
 
     ----------------------------------------------
@@ -124,9 +125,10 @@ is
 	---Level: Public
     returns MakeFace from BRepBuilderAPI;
 
-    Create(S : Surface from Geom; UMin, UMax, VMin, VMax : Real)
-	---Purpose: Make a face from a Surface.
-	---Level: Public
+    Create(S : Surface from Geom; UMin, UMax, VMin, VMax, TolDegen : Real)
+    ---Purpose: Make a face from a Surface. Accepts tolerance value (TolDegen)
+    --          for resolution of degenerated edges.
+    ---Level: Public
     returns MakeFace from BRepBuilderAPI;
 
     ----------------------------------------------
@@ -243,26 +245,29 @@ is
     	-- want to work on the geometries of the two faces independently.
     is static;
 
-    Init(me : in out; S : Surface from Geom; Bound : Boolean = Standard_True)
-	---Purpose: Initializes (or reinitializes) the construction of a face on
-    	-- the surface S. If Bound is true (the default value), a wire is
-    	-- automatically created from the natural bounds of the
-    	-- surface S and added to the face in order to bound it. If
-    	-- Bound is false, no wire is added. This option is used
-    	-- when real bounds are known. These will be added to
-    	-- the face after this initialization, using the function Add.
-      is static;
-
-    Init(me : in out; S : Surface from Geom; UMin, UMax, VMin, VMax : Real) 
-	---Purpose:  Initializes (or reinitializes) the construction of a face on
-    	-- the surface S, limited in the u parametric direction by
-    	-- the two parameter values UMin and UMax and in the
-    	-- v parametric direction by the two parameter values VMin and VMax.
-    	-- Warning
-    	--  Error returns:
-    	-- -      BRepBuilderAPI_ParametersOutOfRange
-    	--    when the parameters given are outside the bounds of the
-    	--    surface or the basis surface of a trimmed surface.
+    Init(me : in out; S : Surface from Geom; Bound : Boolean; TolDegen : Real)
+    ---Purpose: Initializes (or reinitializes) the construction of a face on
+    -- the surface S. If Bound is true, a wire is
+    -- automatically created from the natural bounds of the
+    -- surface S and added to the face in order to bound it. If
+    -- Bound is false, no wire is added. This option is used
+    -- when real bounds are known. These will be added to
+    -- the face after this initialization, using the function Add.
+    -- TolDegen parameter is used for resolution of degenerated edges
+    -- if calculation of natural bounds is turned on.
+    is static;
+
+    Init(me : in out; S : Surface from Geom; UMin, UMax, VMin, VMax, TolDegen : Real) 
+    ---Purpose:  Initializes (or reinitializes) the construction of a face on
+    -- the surface S, limited in the u parametric direction by
+    -- the two parameter values UMin and UMax and in the
+    -- v parametric direction by the two parameter values VMin and VMax.
+    -- Warning
+    --  Error returns:
+    -- -      BRepBuilderAPI_ParametersOutOfRange
+    --    when the parameters given are outside the bounds of the
+    --    surface or the basis surface of a trimmed surface.
+    -- TolDegen parameter is used for resolution of degenerated edges.
     is static;
 
     Add(me : in out; W : Wire from TopoDS)
diff --git a/src/BRepBuilderAPI/BRepBuilderAPI_MakeFace.cxx b/src/BRepBuilderAPI/BRepBuilderAPI_MakeFace.cxx
index 17357c6..e59aeab 100644
--- a/src/BRepBuilderAPI/BRepBuilderAPI_MakeFace.cxx
+++ b/src/BRepBuilderAPI/BRepBuilderAPI_MakeFace.cxx
@@ -112,8 +112,9 @@ BRepBuilderAPI_MakeFace::BRepBuilderAPI_MakeFace(const gp_Torus& T)
 //purpose  : 
 //=======================================================================
 
-BRepBuilderAPI_MakeFace::BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S)
-: myMakeFace(S)
+BRepBuilderAPI_MakeFace::BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S,
+                                                 const Standard_Real TolDegen)
+: myMakeFace(S, TolDegen)
 {
   if ( myMakeFace.IsDone()) {
     Done();
@@ -222,12 +223,13 @@ BRepBuilderAPI_MakeFace::BRepBuilderAPI_MakeFace(const gp_Torus& T,
 //purpose  : 
 //=======================================================================
 
-BRepBuilderAPI_MakeFace::BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S,
-				   const Standard_Real UMin,
-				   const Standard_Real UMax,
-				   const Standard_Real VMin,
-				   const Standard_Real VMax)
-: myMakeFace(S,UMin,UMax,VMin,VMax)
+BRepBuilderAPI_MakeFace::BRepBuilderAPI_MakeFace (const Handle(Geom_Surface)& S,
+                                                  const Standard_Real UMin,
+                                                  const Standard_Real UMax,
+                                                  const Standard_Real VMin,
+                                                  const Standard_Real VMax,
+                                                  const Standard_Real TolDegen)
+: myMakeFace (S, UMin, UMax, VMin, VMax, TolDegen)
 {
   if ( myMakeFace.IsDone()) {
     Done();
@@ -389,9 +391,10 @@ void BRepBuilderAPI_MakeFace::Init(const TopoDS_Face& F)
 //=======================================================================
 
 void  BRepBuilderAPI_MakeFace::Init(const Handle(Geom_Surface)& S,
-			     const Standard_Boolean Bound)
+                                    const Standard_Boolean Bound,
+                                    const Standard_Real TolDegen)
 {
-  myMakeFace.Init(S,Bound);
+  myMakeFace.Init(S, Bound, TolDegen);
   if ( myMakeFace.IsDone()) {
     Done();
     myShape = myMakeFace.Shape();
@@ -404,13 +407,14 @@ void  BRepBuilderAPI_MakeFace::Init(const Handle(Geom_Surface)& S,
 //purpose  : 
 //=======================================================================
 
-void  BRepBuilderAPI_MakeFace::Init(const Handle(Geom_Surface)& SS,
-			     const Standard_Real Um,
-			     const Standard_Real UM,
-			     const Standard_Real Vm,
-			     const Standard_Real VM)
+void  BRepBuilderAPI_MakeFace::Init (const Handle(Geom_Surface)& SS,
+                                     const Standard_Real Um,
+                                     const Standard_Real UM,
+                                     const Standard_Real Vm,
+                                     const Standard_Real VM,
+                                     const Standard_Real TolDegen)
 {
-  myMakeFace.Init(SS,Um,UM,Vm,VM);
+  myMakeFace.Init (SS, Um, UM, Vm, VM, TolDegen);
   if ( myMakeFace.IsDone()) {
     Done();
     myShape = myMakeFace.Shape();
diff --git a/src/BRepClass3d/BRepClass3d_SClassifier.cxx b/src/BRepClass3d/BRepClass3d_SClassifier.cxx
index 452e52a..675bf81 100644
--- a/src/BRepClass3d/BRepClass3d_SClassifier.cxx
+++ b/src/BRepClass3d/BRepClass3d_SClassifier.cxx
@@ -18,18 +18,33 @@
 // modified by NIZHNY-MKK  Mon Jun 21 15:13:40 2004
 #include <Precision.hxx>
 #include <ElCLib.hxx>
+#include <Geom_Surface.hxx>
+#include <BRep_Tool.hxx>
 
-static Standard_Real GetAddToParam(const gp_Lin& L,const Standard_Real P,const Bnd_Box& B);
+static
+  void FaceNormal (const TopoDS_Face& aF,
+		   const Standard_Real U,
+		   const Standard_Real V,
+		   gp_Dir& aDN);
 
-//extern void DrawSegment(const gp_Pnt& P1,const gp_Lin& L,const Standard_Real par);
-//extern Standard_Boolean DebugDrawSegment;
+static 
+  Standard_Real GetAddToParam(const gp_Lin& L,const Standard_Real P,const Bnd_Box& B);
 
 
+
+//=======================================================================
+//function : BRepClass3d_SClassifier
+//purpose  : 
+//=======================================================================
 BRepClass3d_SClassifier::BRepClass3d_SClassifier() 
 { 
 }
 
 
+//=======================================================================
+//function : BRepClass3d_SClassifier
+//purpose  : 
+//=======================================================================
 BRepClass3d_SClassifier::BRepClass3d_SClassifier(BRepClass3d_SolidExplorer& S,
 						 const gp_Pnt&  P,
 						 const Standard_Real Tol) { 
@@ -42,7 +57,11 @@ BRepClass3d_SClassifier::BRepClass3d_SClassifier(BRepClass3d_SolidExplorer& S,
 }
 
 
-void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& SolidExplorer,
+//=======================================================================
+//function : PerformInfinitePoint
+//purpose  : 
+//=======================================================================
+void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& aSE,
 						   const Standard_Real /*Tol*/) {
   //-- Idee : On prend un point A dans la face1 et un point B dans la face B 
   //-- ( si on a une seule face , on prend 2 points dans la meme face.)
@@ -51,62 +70,83 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& So
   //-- premier point. Si le solide a une seule face et que la droite AB ne le coupe pas 
   //-- on ne peut pas decider.
 
-  if(SolidExplorer.Reject(gp_Pnt(0,0,0))) { 
+  if(aSE.Reject(gp_Pnt(0,0,0))) { 
     myState=3; //-- in ds le cas solide sans face 
     return;
   }
-
-
-  Standard_Integer nump = 0;
+  //
+  //------------------------------------------------------------
+  // 1
+  Standard_Boolean bFound, bFlag;
+  Standard_Integer nump;
+  Standard_Real aParam, aU1, aV1, aU2, aV2;
   gp_Pnt A,B;
-
-  Standard_Real aParam = 0.5;
+  gp_Dir aDN1, aDN2;
+  TopoDS_Face aF, aF1, aF2;
+  //
+  nump = 0;
+  aParam = 0.5;
   myFace.Nullify();
   myState=2; 
-  for(SolidExplorer.InitShell();
-      SolidExplorer.MoreShell() && nump<2;
-      SolidExplorer.NextShell()) { 
-    
-    for(SolidExplorer.InitFace(); 
-	SolidExplorer.MoreFace()  && nump<2;
-	 ) {
-      
-      TopoDS_Shape aLocalShape = SolidExplorer.CurrentFace();
-      TopoDS_Face f = TopoDS::Face(aLocalShape);
-//      TopoDS_Face f = TopoDS::Face(SolidExplorer.CurrentFace());
-      SolidExplorer.NextFace();
-      if(nump==0) { 
+  for(aSE.InitShell(); aSE.MoreShell() && nump<2;  aSE.NextShell()) { 
+    for(aSE.InitFace();	aSE.MoreFace()  && nump<2; ) {
+      TopoDS_Shape aLocalShape = aSE.CurrentFace();
+      aF = TopoDS::Face(aLocalShape);
+      aSE.NextFace();
+      if(!nump) { 
 	nump++;
-	if(SolidExplorer.FindAPointInTheFace(f,A,aParam)) { 
-	  if(SolidExplorer.MoreFace() == Standard_False) { 
-	    nump++;
-	    SolidExplorer.FindAPointInTheFace(f,B,aParam);
-	  }
-	}
-	else { 
+	bFound=aSE.FindAPointInTheFace(aF, A, aU1, aV1, aParam);
+	if (!bFound) {
 	  return;
 	}
-      }      
-      else if(nump==1) { 
-	if(SolidExplorer.FindAPointInTheFace(f,B,aParam)) { 
+	aF1=aF;
+	if(!aSE.MoreFace()) { 
 	  nump++;
+	  bFound=aSE.FindAPointInTheFace(aF, B, aU2, aV2, aParam);
+	  if (!bFound) {
+	    return;
+	  }
+	  aF2=aF;
 	}
-	else { 
+      }// if(nump==0) {    
+      else if(nump==1) { 
+	bFound=aSE.FindAPointInTheFace(aF, B, aU2, aV2, aParam);
+	if(!bFound) { 
 	  return;
-	}
+	} 
+	aF2=aF;
+	nump++;
       }
+    }// for(aSE.InitFace();	aSE.MoreFace()  && nump<2; ) {
+  }// for(aSE.InitShell(); aSE.MoreShell() && nump<2;  aSE.NextShell()) { 
+  //
+  //------------------------------------------------------------
+  // 2
+  Standard_Integer cpasbon;
+  Standard_Real parmin, aD2, aSP;
+  IntCurveSurface_TransitionOnCurve aTC;    
+  TopAbs_State aState;
+  //
+  parmin = RealLast();
+  //
+  bFlag=Standard_False;
+  if (aF1!=aF2) {
+    FaceNormal(aF1, aU1, aV1, aDN1);
+    FaceNormal(aF2, aU2, aV2, aDN2);
+    aSP=1.-aDN1*aDN2;
+    if (aSP < 1.e-5) {
+      bFlag=!bFlag;
     }
   }
-  //------------------------------------------------------------
-  
-  Standard_Real parmin = RealLast();
-  
-  if(A.SquareDistance(B)<0.000001) { 
+  //
+  aD2=A.SquareDistance(B);
+  if(aD2<0.000001 || bFlag) { 
     B.SetCoord(A.X()+1,A.Y()+1,A.Z()+1);
   }
-  Standard_Integer cpasbon = 0;
+  //
+  cpasbon = 0;
   gp_Vec AB(A,B);
-
+  //
   do { 
     switch (cpasbon) 
       {
@@ -119,45 +159,35 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& So
     gp_Lin L(A,gp_Dir(AB));    
     //-- cout<<"\npoint A "<<A.X()<<" "<<A.Y()<<" "<<A.Z()<<endl;
     //-- cout<<"\npoint B "<<B.X()<<" "<<B.Y()<<" "<<B.Z()<<endl;
-      
-
-    for(SolidExplorer.InitShell();
-	SolidExplorer.MoreShell();
-	SolidExplorer.NextShell()) { 
-      
-      if(SolidExplorer.RejectShell(L) == Standard_False) { 
-	
-	for(SolidExplorer.InitFace(); 
-	    SolidExplorer.MoreFace(); 
-	    SolidExplorer.NextFace()) {
-	  
-	  if(SolidExplorer.RejectFace(L) == Standard_False) { 
-	    
-	    TopoDS_Shape aLocalShape = SolidExplorer.CurrentFace();
+    for(aSE.InitShell();aSE.MoreShell();aSE.NextShell()) { 
+      if(aSE.RejectShell(L) == Standard_False) { 
+	for(aSE.InitFace();aSE.MoreFace(); aSE.NextFace()) {
+	  if(aSE.RejectFace(L) == Standard_False) { 
+	    TopoDS_Shape aLocalShape = aSE.CurrentFace();
 	    TopoDS_Face f = TopoDS::Face(aLocalShape);
-//	    TopoDS_Face f = TopoDS::Face(SolidExplorer.CurrentFace());
-	    IntCurvesFace_Intersector& Intersector3d = SolidExplorer.Intersector(f);
-	    Intersector3d.Perform(L,-RealLast(),parmin); //-- Avant (14 oct 98 il y avait -RealLast RealLast)
+	    IntCurvesFace_Intersector& Intersector3d = aSE.Intersector(f);
+	    Intersector3d.Perform(L,-RealLast(),parmin); 
 
 	    if(Intersector3d.IsDone()) { 
 	      if(Intersector3d.NbPnt()) { 
 		if(Intersector3d.WParameter(1) < parmin) {
+		  aState=Intersector3d.State(1);
 		  parmin = Intersector3d.WParameter(1);
-		  if(Intersector3d.State(1)==TopAbs_IN) { 
-		    
+		  if(aState==TopAbs_IN || aState==TopAbs_ON) { 
+		    aTC=Intersector3d.Transition(1);
 		    //-- The intersection point between the line and a face F 
 		    // -- of the solid is in the face F 
-		    
-		    if(Intersector3d.Transition(1) == IntCurveSurface_Out) { 
+		    if(aTC == IntCurveSurface_Out) { 
 		      //-- The line is going from inside the solid to outside 
 		      //-- the solid.
 		      myState = 3; //-- IN --
 		    }
-		    else if(Intersector3d.Transition(1) == IntCurveSurface_In) { 
+		    else if(aTC == IntCurveSurface_In) { 
 		      myState = 4; //-- OUT --
 		    }
 		    myFace  = f;
 		  }
+		  /*
 		  else if(Intersector3d.State(1)==TopAbs_ON)  {
 		    //-- The intersection point between the line and a face F 
 		    //-- of the solid is in the face F 
@@ -172,7 +202,9 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& So
 		    //-- myState = 2;
 		    myFace  = f;
 		  }
+		  */
 		}
+		
 		else { 
 		  //-- No point has been found by the Intersector3d.
 		  //-- Or a Point has been found with a greater parameter.
@@ -194,9 +226,9 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& So
 //function : Perform
 //purpose  : 
 //=======================================================================
-  void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer,
-					const gp_Pnt&  P,
-					const Standard_Real Tol) 
+void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer,
+				      const gp_Pnt&  P,
+				      const Standard_Real Tol) 
 { 
 
 
@@ -219,7 +251,6 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& So
     //-- englobantes en priorite de facon a avoir un parmin le plus faible possible. 
     //-- optimisation pour assurer le plus de rejections possibles avec les autres 
     //-- faces. 
-    //modified by NIZNHY-PKV Thu Nov 14 12:33:53 2002 f
     Standard_Integer iFlag;
     //
 
@@ -257,14 +288,11 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& So
 	return;
       }
       //SolidExplorer.Segment(P,L,Par);
-      //modified by NIZNHY-PKV Thu Nov 14 12:33:58 2002 t
       //
       //process results from uncorrected shells
       //
-      //modified by NIZNHY-PKV Thu Nov 14 15:05:43 2002 f
       //if(Par > 1.e+100 && L.Direction().IsParallel(gp_Dir(0.,0.,1.),1.e-8)) {
       if (iFlag==2) {
-	//modified by NIZNHY-PKV Thu Nov 14 15:06:16 2002 t
 	myState = 4;
 	return;
       }
@@ -476,4 +504,26 @@ Standard_Real GetAddToParam(const gp_Lin&       L,
   }
   return Par - P;
 }
-
+//=======================================================================
+//function : FaceNormal
+//purpose  : 
+//=======================================================================
+void FaceNormal (const TopoDS_Face& aF,
+		 const Standard_Real U,
+		 const Standard_Real V,
+		 gp_Dir& aDN)
+{
+  gp_Pnt aPnt ;
+  gp_Vec aD1U, aD1V, aN;
+  Handle(Geom_Surface) aS;
+
+  aS=BRep_Tool::Surface(aF);
+  aS->D1 (U, V, aPnt, aD1U, aD1V);
+  aN=aD1U.Crossed(aD1V);
+  aN.Normalize();  
+  aDN.SetXYZ(aN.XYZ());
+  if (aF.Orientation() == TopAbs_REVERSED){
+    aDN.Reverse();
+  }
+  return;
+}
diff --git a/src/BRepExtrema/BRepExtrema_DistShapeShape.hxx b/src/BRepExtrema/BRepExtrema_DistShapeShape.hxx
deleted file mode 100644
index 119f81a..0000000
--- a/src/BRepExtrema/BRepExtrema_DistShapeShape.hxx
+++ /dev/null
@@ -1,215 +0,0 @@
-// File generated by CPPExt (Value)
-//
-//                     Copyright (C) 1991 - 2000 by  
-//                      Matra Datavision SA.  All rights reserved.
-//  
-//                     Copyright (C) 2001 - 2004 by
-//                     Open CASCADE SA.  All rights reserved.
-// 
-// This file is part of the Open CASCADE Technology software.
-//
-// This software may be distributed and/or modified under the terms and
-// conditions of the Open CASCADE Public License as defined by Open CASCADE SA
-// and appearing in the file LICENSE included in the packaging of this file.
-//  
-// This software is distributed on an "AS IS" basis, without warranty of any
-// kind, and Open CASCADE SA hereby disclaims all such warranties,
-// including without limitation, any warranties of merchantability, fitness
-// for a particular purpose or non-infringement. Please see the License for
-// the specific terms and conditions governing rights and limitations under the
-// License.
-
-#ifndef _BRepExtrema_DistShapeShape_HeaderFile
-#define _BRepExtrema_DistShapeShape_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _BRepExtrema_SeqOfSolution_HeaderFile
-#include <BRepExtrema_SeqOfSolution.hxx>
-#endif
-#ifndef _BRepExtrema_SolutionElem_HeaderFile
-#include <BRepExtrema_SolutionElem.hxx>
-#endif
-#ifndef _TopoDS_Shape_HeaderFile
-#include <TopoDS_Shape.hxx>
-#endif
-#ifndef _TopTools_IndexedMapOfShape_HeaderFile
-#include <TopTools_IndexedMapOfShape.hxx>
-#endif
-#ifndef _Extrema_ExtFlag_HeaderFile
-#include <Extrema_ExtFlag.hxx>
-#endif
-#ifndef _Extrema_ExtAlgo_HeaderFile
-#include <Extrema_ExtAlgo.hxx>
-#endif
-#ifndef _BRepExtrema_SupportType_HeaderFile
-#include <BRepExtrema_SupportType.hxx>
-#endif
-#ifndef _Standard_OStream_HeaderFile
-#include <Standard_OStream.hxx>
-#endif
-#ifndef _gp_Pnt_HeaderFile
-#include <gp_Pnt.hxx>
-#endif
-class TopoDS_Shape;
-class TopTools_IndexedMapOfShape;
-class Bnd_SeqOfBox;
-
-
-//! This class  provides tools to compute minimum distance <br>
-//! between two Shapes (Compound,CompSolid, Solid, Shell, Face, Wire, Edge, Vertex). <br>
-class BRepExtrema_DistShapeShape
-{
- public:
-
-  void* operator new(size_t,void* anAddress) 
-  {
-    return anAddress;
-  }
-  void* operator new(size_t size) 
-  {
-    return Standard::Allocate(size); 
-  }
-  void  operator delete(void *anAddress) 
-  {
-    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-  }
-
-  //! create empty tool <br>
-  Standard_EXPORT BRepExtrema_DistShapeShape();
-  //! computation of the minimum distance (value and pair of points) using default deflection <br>
-  //! Default value is Precision::Confusion(). <br>
-  Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,const TopoDS_Shape& Shape2,const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
-  //! create tool and load both shapes into it <br>
-  Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,const TopoDS_Shape& Shape2,const Standard_Real theDeflection,const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
-  
-  Standard_EXPORT void SetDeflection(const Standard_Real theDeflection)
-  {
-    myEps = theDeflection;
-  }
-  //! load first shape into extrema <br>
-  Standard_EXPORT void LoadS1(const TopoDS_Shape& Shape1);
-  //! load second shape into extrema <br>
-  Standard_EXPORT void LoadS2(const TopoDS_Shape& Shape1);
-  //! computation of  the minimum  distance  (value  and <br>
-  //!          couple  of points). Parameter theDeflection is used <br>
-  //!          to specify a maximum deviation of extreme distances <br>
-  //!          from the minimum one. <br>
-  //!          Returns IsDone status. <br>
-  Standard_EXPORT Standard_Boolean Perform();
-  //! True if the minimum distance is found. <br>
-  Standard_EXPORT Standard_Boolean IsDone() const
-  { 
-    return myIsDone;
-  }
-  //! Returns the number of solutions satisfying the minimum distance. <br>
-  Standard_EXPORT Standard_Integer NbSolution() const
-  { 
-    return mySolutionsShape1.Length();
-  }
-  //! Returns the value of the minimum distance. <br>
-  Standard_EXPORT Standard_Real Value() const;
-  //! True if one of the shapes is a solid and the other shape <br>
-  //! is completely or partially inside the solid. <br>
-  Standard_EXPORT Standard_Boolean InnerSolution() const
-  { 
-    return myInnerSol;
-  }
-  //! Returns the Point corresponding to the <N>th solution on the first Shape <br>
-  Standard_EXPORT const gp_Pnt & PointOnShape1(const Standard_Integer N) const
-  { 
-    return mySolutionsShape1.Value(N).Point();
-  }
-  //! Returns the Point corresponding to the <N>th solution on the second Shape <br>
-  Standard_EXPORT const gp_Pnt & PointOnShape2(const Standard_Integer N) const
-  { 
-    return mySolutionsShape2.Value(N).Point();
-  }
-  //! gives the type of the support where the Nth solution on the first shape is situated: <br>
-  //!   IsVertex => the Nth solution on the first shape is a Vertex <br>
-  //!   IsOnEdge => the Nth soluion on the first shape is on a Edge <br>
-  //!   IsInFace => the Nth solution on the first shape is inside a face <br>
-  //! the corresponding support is obtained by the method SupportOnShape1 <br>
-  Standard_EXPORT BRepExtrema_SupportType SupportTypeShape1(const Standard_Integer N) const
-  { 
-    return mySolutionsShape1.Value(N).SupportKind();
-  }
-  //! gives the type of the support where the Nth solution on the second shape is situated: <br>
-  //!   IsVertex => the Nth solution on the second shape is a Vertex <br>
-  //!   IsOnEdge => the Nth soluion on the secondt shape is on a Edge <br>
-  //!   IsInFace => the Nth solution on the second shape is inside a face <br>
-  //! the corresponding support is obtained by the method SupportOnShape2 <br>
-  Standard_EXPORT BRepExtrema_SupportType SupportTypeShape2(const Standard_Integer N) const
-  { 
-    return mySolutionsShape2.Value(N).SupportKind();
-  }
-  //! gives the support where the Nth solution on the first shape is situated. <br>
-  //! This support can be a Vertex, an Edge or a Face. <br>
-  Standard_EXPORT TopoDS_Shape SupportOnShape1(const Standard_Integer N) const;
-  //! gives the support where the Nth solution on the second shape is situated. <br>
-  //! This support can be a Vertex, an Edge or a Face. <br>
-  Standard_EXPORT TopoDS_Shape SupportOnShape2(const Standard_Integer N) const;
-  //! gives the corresponding parameter t if the Nth solution <br>
-  //! is situated on an Egde of the first shape <br>
-  Standard_EXPORT void ParOnEdgeS1(const Standard_Integer N,Standard_Real& t) const;
-  //! gives the corresponding parameter t if the Nth solution <br>
-  //! is situated on an Egde of the first shape <br>
-  Standard_EXPORT void ParOnEdgeS2(const Standard_Integer N,Standard_Real& t) const;
-  //! gives the corresponding parameters (U,V) if the Nth solution <br>
-  //! is situated on an face of the first shape <br>
-  Standard_EXPORT void ParOnFaceS1(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
-  //! gives the corresponding parameters (U,V) if the Nth solution <br>
-  //! is situated on an Face of the second shape <br>
-  Standard_EXPORT void ParOnFaceS2(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
-  //! Prints on the stream o information on the current state of the object. <br>
-  Standard_EXPORT void Dump(Standard_OStream& o) const;
-
-  Standard_EXPORT void SetFlag(const Extrema_ExtFlag F)
-  {
-    myFlag = F;
-  }
-
-  Standard_EXPORT void SetAlgo(const Extrema_ExtAlgo A)
-  {
-    myAlgo = A;
-  }
-
-private:
-
-  //! computes the minimum distance between two maps of shapes (Face,Edge,Vertex) <br>
-  Standard_EXPORT void DistanceMapMap(const TopTools_IndexedMapOfShape& Map1,const TopTools_IndexedMapOfShape& Map2,const Bnd_SeqOfBox& LBox1,const Bnd_SeqOfBox& LBox2);
-
-  Standard_Real myDistRef;
-  Standard_Real myDistValue;
-  Standard_Boolean myIsDone;
-  BRepExtrema_SeqOfSolution mySolutionsShape1;
-  BRepExtrema_SeqOfSolution mySolutionsShape2;
-  Standard_Boolean myInnerSol;
-  Standard_Real myEps;
-  TopoDS_Shape myShape1;
-  TopoDS_Shape myShape2;
-  TopTools_IndexedMapOfShape myMapV1;
-  TopTools_IndexedMapOfShape myMapV2;
-  TopTools_IndexedMapOfShape myMapE1;
-  TopTools_IndexedMapOfShape myMapE2;
-  TopTools_IndexedMapOfShape myMapF1;
-  TopTools_IndexedMapOfShape myMapF2;
-  Extrema_ExtFlag myFlag;
-  Extrema_ExtAlgo myAlgo;
-};
-
-#endif
diff --git a/src/BRepExtrema/BRepExtrema_DistanceSS.cxx b/src/BRepExtrema/BRepExtrema_DistanceSS.cxx
index 8e23252..e8a66c7 100644
--- a/src/BRepExtrema/BRepExtrema_DistanceSS.cxx
+++ b/src/BRepExtrema/BRepExtrema_DistanceSS.cxx
@@ -348,7 +348,7 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
 	  else if (aV > Vmax)
 	    Vmax = aV;
 
-	  i++;
+      i++;
 	}
       
     GeomAdaptor_Surface aGAS(pSurf);
@@ -369,7 +369,7 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
     }
 
     Handle(Geom_Surface) result = new Geom_RectangularTrimmedSurface(pSurf, Umin, Umax, Vmin, Vmax);
-    aResFace = BRepBuilderAPI_MakeFace(result);
+    aResFace = BRepBuilderAPI_MakeFace(result, Precision::Confusion());
 
     bIsInfinit = Standard_True;
   }
diff --git a/src/BRepExtrema/BRepExtrema_DistanceSS.hxx b/src/BRepExtrema/BRepExtrema_DistanceSS.hxx
deleted file mode 100644
index 363725d..0000000
--- a/src/BRepExtrema/BRepExtrema_DistanceSS.hxx
+++ /dev/null
@@ -1,174 +0,0 @@
-// File generated by CPPExt (Value)
-//
-//                     Copyright (C) 1991 - 2000 by  
-//                      Matra Datavision SA.  All rights reserved.
-//  
-//                     Copyright (C) 2001 - 2004 by
-//                     Open CASCADE SA.  All rights reserved.
-// 
-// This file is part of the Open CASCADE Technology software.
-//
-// This software may be distributed and/or modified under the terms and
-// conditions of the Open CASCADE Public License as defined by Open CASCADE SA
-// and appearing in the file LICENSE included in the packaging of this file.
-//  
-// This software is distributed on an "AS IS" basis, without warranty of any
-// kind, and Open CASCADE SA hereby disclaims all such warranties,
-// including without limitation, any warranties of merchantability, fitness
-// for a particular purpose or non-infringement. Please see the License for
-// the specific terms and conditions governing rights and limitations under the
-// License.
-
-#ifndef _BRepExtrema_DistanceSS_HeaderFile
-#define _BRepExtrema_DistanceSS_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _BRepExtrema_SeqOfSolution_HeaderFile
-#include <BRepExtrema_SeqOfSolution.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Extrema_ExtFlag_HeaderFile
-#include <Extrema_ExtFlag.hxx>
-#endif
-#ifndef _Extrema_ExtAlgo_HeaderFile
-#include <Extrema_ExtAlgo.hxx>
-#endif
-#ifndef _Precision_HeaderFile
-#include <Precision.hxx>
-#endif
-class TopoDS_Shape;
-class Bnd_Box;
-class TopoDS_Vertex;
-class TopoDS_Edge;
-class TopoDS_Face;
-
-
-//!  This class allows to compute minimum distance between two shapes <br>
-//! (face edge vertex) and is used in DistShapeShape class. <br>
-class BRepExtrema_DistanceSS
-{
- public:
-
-  void* operator new(size_t,void* anAddress) 
-  {
-    return anAddress;
-  }
-  void* operator new(size_t size) 
-  {
-    return Standard::Allocate(size); 
-  }
-  void  operator delete(void *anAddress) 
-  {
-    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-  }
-
-  //! computes the distance between two Shapes ( face edge vertex). <br>
-  Standard_EXPORT BRepExtrema_DistanceSS(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
-                                         const Bnd_Box& B1, const Bnd_Box& B2,
-                                         const Standard_Real DstRef,
-                                         const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,
-                                         const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad)
-  : myDstRef(DstRef), myModif(Standard_False), myEps(Precision::Confusion()), myFlag(F), myAlgo(A)
-  {
-    Perform(S1, S2, B1, B2);
-  }
-  //! computes the distance between two Shapes ( face edge vertex). <br>
-  //! Parameter theDeflection is used to specify a maximum deviation <br>
-  //! of extreme distances from the minimum one. <br>
-  //! Default value is Precision::Confusion(). <br>
-  Standard_EXPORT BRepExtrema_DistanceSS(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
-                                         const Bnd_Box& B1, const Bnd_Box& B2,
-                                         const Standard_Real DstRef, const Standard_Real aDeflection,
-                                         const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,
-                                         const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad)
-  : myDstRef(DstRef), myModif(Standard_False), myEps(aDeflection), myFlag(F), myAlgo(A)
-  {
-    Perform(S1, S2, B1, B2);
-  }
-  //! True if the distance has been computed <br>
-  Standard_EXPORT Standard_Boolean IsDone() const
-  {
-    return myModif;
-  }
-  //! returns the distance value <br>
-  Standard_EXPORT Standard_Real DistValue() const
-  {
-    return myDstRef;
-  }
-  //! returns the list of solutions on the first shape <br>
-  Standard_EXPORT const BRepExtrema_SeqOfSolution& Seq1Value() const
-  {
-    return SeqSolShape1;
-  }
-  //! returns the list of solutions on the second shape <br>
-  Standard_EXPORT const BRepExtrema_SeqOfSolution& Seq2Value() const
-  {
-    return SeqSolShape2;
-  }
-  //! sets the flag controlling minimum and maximum search
-  Standard_EXPORT void SetFlag(const Extrema_ExtFlag F)
-  {
-    myFlag = F;
-  }
-  //! sets the flag controlling ...
-  Standard_EXPORT void SetAlgo(const Extrema_ExtAlgo A)
-  {
-    myAlgo = A;
-  }
-
- private:
-
-  //! computes the distance between two Shapes ( face edge vertex) <br>
-  void Perform(const TopoDS_Shape& S1,const TopoDS_Shape& S2,const Bnd_Box& B1,const Bnd_Box& B2);
-
-  //! computes the distance between two vertices <br>
-  void Perform(const TopoDS_Vertex& S1,const TopoDS_Vertex& S2);
-  //! computes the minimum distance between a vertex and an edge <br>
-  void Perform(const TopoDS_Vertex& S1,const TopoDS_Edge& S2,const Bnd_Box& B1,const Bnd_Box& B2);
-  //! computes the minimum distance between a vertex and a face <br>
-  void Perform(const TopoDS_Vertex& S1,const TopoDS_Face& S2,const Bnd_Box& B1,const Bnd_Box& B2);
-
-  //! computes the minimum distance between an edge and a vertex <br>
-  void Perform(const TopoDS_Edge& S1,const TopoDS_Vertex& S2,const Bnd_Box& B1,const Bnd_Box& B2);
-  /*{
-    Perform(S2, S1, B2, B1);
-  }*/
-  //! computes the minimum distance between two edges <br>
-  void Perform(const TopoDS_Edge& S1,const TopoDS_Edge& S2,const Bnd_Box& B1,const Bnd_Box& B2);
-  //! computes the minimum distance an edge and a face <br>
-  void Perform(const TopoDS_Edge& S1,const TopoDS_Face& S2,const Bnd_Box& B1,const Bnd_Box& B2);
-
-  //! computes the minimum distance betwwen a face and a vertex <br>
-  void Perform(const TopoDS_Face& S1,const TopoDS_Vertex& S2,const Bnd_Box& B1,const Bnd_Box& B2);
-  /*{
-    Perform(S2, S1, B2, B1);
-  }*/
-  //! computes the minimum distance between a face and an edge <br>
-  void Perform(const TopoDS_Face& S1,const TopoDS_Edge& S2,const Bnd_Box& B1,const Bnd_Box& B2);
-  /*{
-    Perform(S2, S1, B2, B1);
-  }*/
-  //! computes the minimum distance between two faces <br>
-  void Perform(const TopoDS_Face& S1,const TopoDS_Face& S2,const Bnd_Box& B1,const Bnd_Box& B2);
-
-  BRepExtrema_SeqOfSolution SeqSolShape1;
-  BRepExtrema_SeqOfSolution SeqSolShape2;
-  Standard_Real myDstRef;
-  Standard_Boolean myModif;
-  Standard_Real myEps;
-  Extrema_ExtFlag myFlag;
-  Extrema_ExtAlgo myAlgo;
-};
-
-#endif
diff --git a/src/BRepExtrema/BRepExtrema_ExtCC.hxx b/src/BRepExtrema/BRepExtrema_ExtCC.hxx
deleted file mode 100644
index a6e2fcd..0000000
--- a/src/BRepExtrema/BRepExtrema_ExtCC.hxx
+++ /dev/null
@@ -1,102 +0,0 @@
-// This file is generated by WOK (CPPExt).
-// Please do not edit this file; modify original file instead.
-// The copyright and license terms as defined for the original file apply to 
-// this header file considered to be the "object code" form of the original source.
-
-#ifndef _BRepExtrema_ExtCC_HeaderFile
-#define _BRepExtrema_ExtCC_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Extrema_ExtCC_HeaderFile
-#include <Extrema_ExtCC.hxx>
-#endif
-#ifndef _Handle_BRepAdaptor_HCurve_HeaderFile
-#include <Handle_BRepAdaptor_HCurve.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-class BRepAdaptor_HCurve;
-class TopoDS_Edge;
-class gp_Pnt;
-
-
-class BRepExtrema_ExtCC
-{
- public:
-
-  void* operator new(size_t,void* anAddress) 
-  {
-    return anAddress;
-  }
-  void* operator new(size_t size) 
-  {
-    return Standard::Allocate(size); 
-  }
-  void  operator delete(void *anAddress) 
-  {
-    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-  }
-  
-  Standard_EXPORT BRepExtrema_ExtCC()
-  {
-  }
-  //! It calculates all the distances. <br>
-  Standard_EXPORT BRepExtrema_ExtCC(const TopoDS_Edge& E1,const TopoDS_Edge& E2);
-
-  Standard_EXPORT void Initialize(const TopoDS_Edge& E2);
-  //! An exception is raised if the fields have not been initialized. <br>
-  Standard_EXPORT void Perform(const TopoDS_Edge& E1);
-  //! True if the distances are found. <br>
-  Standard_EXPORT Standard_Boolean IsDone() const
-  {
-    return myExtCC.IsDone();
-  }
-  //! Returns the number of extremum distances. <br>
-  Standard_EXPORT Standard_Integer NbExt() const
-  {
-    return myExtCC.NbExt();
-  }
-  //! Returns True if E1 and E2 are parallel. <br>
-  Standard_EXPORT Standard_Boolean IsParallel() const
-  {
-    return myExtCC.IsParallel();
-  }
-  //! Returns the value of the <N>th extremum square distance. <br>
-  Standard_EXPORT Standard_Real SquareDistance(const Standard_Integer N) const
-  {
-    return myExtCC.SquareDistance(N);
-  }
-  //! Returns the parameter on the first edge of the <N>th extremum distance. <br>
-  Standard_EXPORT Standard_Real ParameterOnE1(const Standard_Integer N) const;
-  //! Returns the Point of the <N>th extremum distance on the edge E1. <br>
-  Standard_EXPORT gp_Pnt PointOnE1(const Standard_Integer N) const;
-  //! Returns the parameter on the second edge of the <N>th extremum distance. <br>
-  Standard_EXPORT Standard_Real ParameterOnE2(const Standard_Integer N) const;
-  //! Returns the Point of the <N>th extremum distance on the edge E2. <br>
-  Standard_EXPORT gp_Pnt PointOnE2(const Standard_Integer N) const;
-  //! if the edges is a trimmed curve, <br>
-  //! dist11 is a square distance between the point on E1 <br>
-  //! of parameter FirstParameter and the point of <br>
-  //! parameter FirstParameter on E2. <br>
-  Standard_EXPORT void TrimmedSquareDistances(Standard_Real& dist11,Standard_Real& distP12,Standard_Real& distP21,Standard_Real& distP22,gp_Pnt& P11,gp_Pnt& P12,gp_Pnt& P21,gp_Pnt& P22) const;
-
- private:
-
-  Extrema_ExtCC myExtCC;
-  Handle_BRepAdaptor_HCurve myHC;
-};
-
-#endif
diff --git a/src/BRepExtrema/BRepExtrema_ExtCF.hxx b/src/BRepExtrema/BRepExtrema_ExtCF.hxx
deleted file mode 100644
index 1fb6d62..0000000
--- a/src/BRepExtrema/BRepExtrema_ExtCF.hxx
+++ /dev/null
@@ -1,129 +0,0 @@
-// This file is generated by WOK (CPPExt).
-// Please do not edit this file; modify original file instead.
-// The copyright and license terms as defined for the original file apply to 
-// this header file considered to be the "object code" form of the original source.
-
-#ifndef _BRepExtrema_ExtCF_HeaderFile
-#define _BRepExtrema_ExtCF_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Extrema_ExtCS_HeaderFile
-#include <Extrema_ExtCS.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _TColStd_SequenceOfReal_HeaderFile
-#include <TColStd_SequenceOfReal.hxx>
-#endif
-#ifndef _Extrema_SequenceOfPOnSurf_HeaderFile
-#include <Extrema_SequenceOfPOnSurf.hxx>
-#endif
-#ifndef _Extrema_SequenceOfPOnCurv_HeaderFile
-#include <Extrema_SequenceOfPOnCurv.hxx>
-#endif
-#ifndef _Handle_BRepAdaptor_HSurface_HeaderFile
-#include <Handle_BRepAdaptor_HSurface.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _Extrema_POnCurv_HeaderFile
-#include <Extrema_POnCurv.hxx>
-#endif
-#ifndef _Extrema_POnSurf_HeaderFile
-#include <Extrema_POnSurf.hxx>
-#endif
-class BRepAdaptor_HSurface;
-class TopoDS_Edge;
-class TopoDS_Face;
-class gp_Pnt;
-
-
-class BRepExtrema_ExtCF
-{
- public:
-
-  void* operator new(size_t,void* anAddress) 
-  {
-    return anAddress;
-  }
-  void* operator new(size_t size) 
-  {
-    return Standard::Allocate(size); 
-  }
-  void  operator delete(void *anAddress) 
-  {
-    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-  }
-
-  Standard_EXPORT BRepExtrema_ExtCF()
-  {
-  }
-  //! It calculates all the distances. <br>
-  Standard_EXPORT BRepExtrema_ExtCF(const TopoDS_Edge& V,const TopoDS_Face& E);
-
-  Standard_EXPORT void Initialize(const TopoDS_Face& E);
-  //! An exception is raised if the fields have not been initialized. <br>
-  //! Be careful: this method uses the Face only for classify not for the fields. <br>
-  Standard_EXPORT void Perform(const TopoDS_Edge& V,const TopoDS_Face& F);
-  //! True if the distances are found. <br>
-  Standard_EXPORT Standard_Boolean IsDone() const
-  {
-    return myExtCS.IsDone();
-  }
-  //! Returns the number of extremum distances. <br>
-  Standard_EXPORT Standard_Integer NbExt() const
-  {
-    return mySqDist.Length();
-  }
-  //! Returns the value of the <N>th extremum square distance. <br>
-  Standard_EXPORT Standard_Real SquareDistance(const Standard_Integer N) const
-  {
-    return mySqDist.Value(N);
-  }
-  //! Returns True if the curve is on a parallel surface. <br>
-  Standard_EXPORT Standard_Boolean IsParallel() const
-  {
-    return myExtCS.IsParallel();
-  }
-  //! Returns the parameters on the Edge of the <N>th extremum distance. <br>
-  Standard_EXPORT Standard_Real ParameterOnEdge(const Standard_Integer N) const
-  {
-    return myPointsOnC.Value(N).Parameter();
-  }
-  //! Returns the parameters on the Face of the <N>th extremum distance. <br>
-  Standard_EXPORT void ParameterOnFace(const Standard_Integer N,Standard_Real& U,Standard_Real& V) const
-  {
-    myPointsOnS.Value(N).Parameter(U, V);
-  }
-  //! Returns the Point of the <N>th extremum distance. <br>
-  Standard_EXPORT gp_Pnt PointOnEdge(const Standard_Integer N) const
-  {
-    return myPointsOnC.Value(N).Value();
-  }
-  //! Returns the Point of the <N>th extremum distance. <br>
-  Standard_EXPORT gp_Pnt PointOnFace(const Standard_Integer N) const
-  {
-    return myPointsOnS.Value(N).Value();
-  }
-
- private:
-
-  Extrema_ExtCS myExtCS;
-  TColStd_SequenceOfReal mySqDist;
-  Extrema_SequenceOfPOnSurf myPointsOnS;
-  Extrema_SequenceOfPOnCurv myPointsOnC;
-  Handle_BRepAdaptor_HSurface myHS;
-};
-
-#endif
diff --git a/src/BRepExtrema/BRepExtrema_ExtFF.hxx b/src/BRepExtrema/BRepExtrema_ExtFF.hxx
deleted file mode 100644
index 9e2035e..0000000
--- a/src/BRepExtrema/BRepExtrema_ExtFF.hxx
+++ /dev/null
@@ -1,124 +0,0 @@
-// This file is generated by WOK (CPPExt).
-// Please do not edit this file; modify original file instead.
-// The copyright and license terms as defined for the original file apply to 
-// this header file considered to be the "object code" form of the original source.
-
-#ifndef _BRepExtrema_ExtFF_HeaderFile
-#define _BRepExtrema_ExtFF_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Extrema_ExtSS_HeaderFile
-#include <Extrema_ExtSS.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _TColStd_SequenceOfReal_HeaderFile
-#include <TColStd_SequenceOfReal.hxx>
-#endif
-#ifndef _Extrema_SequenceOfPOnSurf_HeaderFile
-#include <Extrema_SequenceOfPOnSurf.hxx>
-#endif
-#ifndef _Handle_BRepAdaptor_HSurface_HeaderFile
-#include <Handle_BRepAdaptor_HSurface.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _Extrema_POnSurf_HeaderFile
-#include <Extrema_POnSurf.hxx>
-#endif
-class BRepAdaptor_HSurface;
-class TopoDS_Face;
-class gp_Pnt;
-
-
-
-class BRepExtrema_ExtFF
-{
- public:
-
-  void* operator new(size_t,void* anAddress) 
-  {
-    return anAddress;
-  }
-  void* operator new(size_t size) 
-  {
-    return Standard::Allocate(size); 
-  }
-  void  operator delete(void *anAddress) 
-  {
-    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-  }
-
-  
-  Standard_EXPORT BRepExtrema_ExtFF()
-  {
-  }
-  //! It calculates all the distances. <br>
-  Standard_EXPORT BRepExtrema_ExtFF(const TopoDS_Face& F1,const TopoDS_Face& F2);
-  
-  Standard_EXPORT void Initialize(const TopoDS_Face& F2) ;
-  //! An exception is raised if the fields have not been initialized. <br>
-  //! Be careful: this method uses the Face F2 only for classify, not for the fields. <br>
-  Standard_EXPORT void Perform(const TopoDS_Face& F1,const TopoDS_Face& F2);
-  //! True if the distances are found. <br>
-  Standard_EXPORT Standard_Boolean IsDone() const
-  {
-    return myExtSS.IsDone();
-  }
-  //! Returns True if the surfaces are parallel. <br>
-  Standard_EXPORT Standard_Boolean IsParallel() const
-  {
-    return myExtSS.IsParallel();
-  }
-  //! Returns the number of extremum distances. <br>
-  Standard_EXPORT Standard_Integer NbExt() const
-  {
-    return mySqDist.Length();
-  }
-  //! Returns the value of the <N>th extremum square distance. <br>
-  Standard_EXPORT Standard_Real SquareDistance(const Standard_Integer N) const
-  {
-    return mySqDist.Value(N);
-  }
-  //! Returns the parameters on the Face F1 of the <N>th extremum distance. <br>
-  Standard_EXPORT void ParameterOnFace1(const Standard_Integer N,Standard_Real& U,Standard_Real& V) const
-  {
-    myPointsOnS1.Value(N).Parameter(U, V);
-  }
-  //! Returns the parameters on the Face F2 of the <N>th extremum distance. <br>
-  Standard_EXPORT void ParameterOnFace2(const Standard_Integer N,Standard_Real& U,Standard_Real& V) const
-  {
-    myPointsOnS2.Value(N).Parameter(U, V);
-  }
-  //! Returns the Point of the <N>th extremum distance. <br>
-  Standard_EXPORT gp_Pnt PointOnFace1(const Standard_Integer N) const
-  {
-    return myPointsOnS1.Value(N).Value(); 
-  }
-  //! Returns the Point of the <N>th extremum distance. <br>
-  Standard_EXPORT gp_Pnt PointOnFace2(const Standard_Integer N) const
-  {
-    return myPointsOnS2.Value(N).Value();
-  }
-
- private:
-
-  Extrema_ExtSS myExtSS;
-  TColStd_SequenceOfReal mySqDist;
-  Extrema_SequenceOfPOnSurf myPointsOnS1;
-  Extrema_SequenceOfPOnSurf myPointsOnS2;
-  Handle_BRepAdaptor_HSurface myHS;
-};
-
-#endif
diff --git a/src/BRepExtrema/BRepExtrema_ExtPC.hxx b/src/BRepExtrema/BRepExtrema_ExtPC.hxx
deleted file mode 100644
index 631d1ac..0000000
--- a/src/BRepExtrema/BRepExtrema_ExtPC.hxx
+++ /dev/null
@@ -1,110 +0,0 @@
-// This file is generated by WOK (CPPExt).
-// Please do not edit this file; modify original file instead.
-// The copyright and license terms as defined for the original file apply to 
-// this header file considered to be the "object code" form of the original source.
-
-#ifndef _BRepExtrema_ExtPC_HeaderFile
-#define _BRepExtrema_ExtPC_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Extrema_ExtPC_HeaderFile
-#include <Extrema_ExtPC.hxx>
-#endif
-#ifndef _Handle_BRepAdaptor_HCurve_HeaderFile
-#include <Handle_BRepAdaptor_HCurve.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-class BRepAdaptor_HCurve;
-class TopoDS_Vertex;
-class TopoDS_Edge;
-class gp_Pnt;
-
-
-class BRepExtrema_ExtPC
-{
- public:
-
-  void* operator new(size_t,void* anAddress) 
-  {
-    return anAddress;
-  }
-  void* operator new(size_t size) 
-  {
-    return Standard::Allocate(size); 
-  }
-  void  operator delete(void *anAddress) 
-  {
-    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-  }
-
-  
-  Standard_EXPORT BRepExtrema_ExtPC()
-  {
-  }
-  //! It calculates all the distances. <br>
-  Standard_EXPORT BRepExtrema_ExtPC(const TopoDS_Vertex& V,const TopoDS_Edge& E);
-  
-  Standard_EXPORT void Initialize(const TopoDS_Edge& E);
-  //! An exception is raised if the fields have not been initialized. <br>
-  Standard_EXPORT void Perform(const TopoDS_Vertex& V);
-  //! True if the distances are found. <br>
-  Standard_EXPORT Standard_Boolean IsDone() const
-  {
-    return myExtPC.IsDone();
-  }
-  //! Returns the number of extremum distances. <br>
-  Standard_EXPORT Standard_Integer NbExt() const
-  {
-    return myExtPC.NbExt();
-  }
-  //! Returns True if the <N>th extremum distance is a minimum. <br>
-  Standard_EXPORT Standard_Boolean IsMin(const Standard_Integer N) const
-  {
-    return myExtPC.IsMin(N);
-  }
-  //! Returns the value of the <N>th extremum square distance. <br>
-  Standard_EXPORT Standard_Real SquareDistance(const Standard_Integer N) const
-  {
-    return myExtPC.SquareDistance(N);
-  }
-  //! Returns the parameter on the edge of the <N>th extremum distance. <br>
-  Standard_EXPORT Standard_Real Parameter(const Standard_Integer N) const
-  {
-    return myExtPC.Point(N).Parameter();
-  }
-  //! Returns the Point of the <N>th extremum distance. <br>
-  Standard_EXPORT gp_Pnt Point(const Standard_Integer N) const
-  {
-    return myExtPC.Point(N).Value();
-  }
-  //! if the curve is a trimmed curve, <br>
-  //! dist1 is a square distance between <P> and the point <br>
-  //! of parameter FirstParameter <pnt1> and <br>
-  //! dist2 is a square distance between <P> and the point <br>
-  //! of parameter LastParameter <pnt2>. <br>
-  Standard_EXPORT void TrimmedSquareDistances(Standard_Real& dist1,Standard_Real& dist2,gp_Pnt& pnt1,gp_Pnt& pnt2) const
-  {
-    myExtPC.TrimmedSquareDistances(dist1,dist2,pnt1,pnt2);
-  }
-
- private:
-
-  Extrema_ExtPC myExtPC;
-  Handle_BRepAdaptor_HCurve myHC;
-};
-
-#endif
diff --git a/src/BRepExtrema/BRepExtrema_ExtPF.hxx b/src/BRepExtrema/BRepExtrema_ExtPF.hxx
deleted file mode 100644
index 6e8ac30..0000000
--- a/src/BRepExtrema/BRepExtrema_ExtPF.hxx
+++ /dev/null
@@ -1,139 +0,0 @@
-// File generated by CPPExt (Value)
-//
-//                     Copyright (C) 1991 - 2000 by  
-//                      Matra Datavision SA.  All rights reserved.
-//  
-//                     Copyright (C) 2001 - 2004 by
-//                     Open CASCADE SA.  All rights reserved.
-// 
-// This file is part of the Open CASCADE Technology software.
-//
-// This software may be distributed and/or modified under the terms and
-// conditions of the Open CASCADE Public License as defined by Open CASCADE SA
-// and appearing in the file LICENSE included in the packaging of this file.
-//  
-// This software is distributed on an "AS IS" basis, without warranty of any
-// kind, and Open CASCADE SA hereby disclaims all such warranties,
-// including without limitation, any warranties of merchantability, fitness
-// for a particular purpose or non-infringement. Please see the License for
-// the specific terms and conditions governing rights and limitations under the
-// License.
-
-#ifndef _BRepExtrema_ExtPF_HeaderFile
-#define _BRepExtrema_ExtPF_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Extrema_ExtPS_HeaderFile
-#include <Extrema_ExtPS.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _TColStd_SequenceOfReal_HeaderFile
-#include <TColStd_SequenceOfReal.hxx>
-#endif
-#ifndef _Extrema_SequenceOfPOnSurf_HeaderFile
-#include <Extrema_SequenceOfPOnSurf.hxx>
-#endif
-#ifndef _BRepAdaptor_Surface_HeaderFile
-#include <BRepAdaptor_Surface.hxx>
-#endif
-#ifndef _Extrema_ExtFlag_HeaderFile
-#include <Extrema_ExtFlag.hxx>
-#endif
-#ifndef _Extrema_ExtAlgo_HeaderFile
-#include <Extrema_ExtAlgo.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-class TopoDS_Vertex;
-class TopoDS_Face;
-class gp_Pnt;
-
-
-class BRepExtrema_ExtPF
-{
- public:
-
-  void* operator new(size_t,void* anAddress) 
-  {
-    return anAddress;
-  }
-  void* operator new(size_t size) 
-  {
-    return Standard::Allocate(size); 
-  }
-  void  operator delete(void *anAddress) 
-  {
-    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-  }
-
-  Standard_EXPORT BRepExtrema_ExtPF()
-  {}
-  //! It calculates all the distances. <br>
-  Standard_EXPORT BRepExtrema_ExtPF(const TopoDS_Vertex& TheVertex,const TopoDS_Face& TheFace,
-                                    const Extrema_ExtFlag TheFlag = Extrema_ExtFlag_MINMAX,
-                                    const Extrema_ExtAlgo TheAlgo = Extrema_ExtAlgo_Grad);
-  
-  Standard_EXPORT void Initialize(const TopoDS_Face& TheFace,
-                                  const Extrema_ExtFlag TheFlag = Extrema_ExtFlag_MINMAX,
-                                  const Extrema_ExtAlgo TheAlgo = Extrema_ExtAlgo_Grad);
-
-  //! An exception is raised if the fields have not been initialized. <br>
-  //! Be careful: this method uses the Face only for classify not for the fields. <br>
-  Standard_EXPORT void Perform(const TopoDS_Vertex& TheVertex,const TopoDS_Face& TheFace);
-  //! True if the distances are found. <br>
-  Standard_EXPORT Standard_Boolean IsDone() const
-  {
-    return myExtPS.IsDone();
-  }
-  //! Returns the number of extremum distances. <br>
-  Standard_EXPORT Standard_Integer NbExt() const
-  {
-    return myPoints.Length();
-  }
-  //! Returns the value of the <N>th extremum square distance. <br>
-  Standard_EXPORT Standard_Real SquareDistance(const Standard_Integer N) const
-  {
-    return mySqDist.Value(N);
-  }
-  //! Returns the parameters on the Face of the <N>th extremum distance. <br>
-  Standard_EXPORT void Parameter(const Standard_Integer N,Standard_Real& U,Standard_Real& V) const
-  {
-    myPoints.Value(N).Parameter(U, V);
-  }
-  //! Returns the Point of the <N>th extremum distance. <br>
-  Standard_EXPORT gp_Pnt Point(const Standard_Integer N) const
-  {
-    return myPoints.Value(N).Value();
-  }
-
-  Standard_EXPORT void SetFlag(const Extrema_ExtFlag F)
-  {
-    myExtPS.SetFlag(F);
-  }
-
-  Standard_EXPORT void SetAlgo(const Extrema_ExtAlgo A)
-  {
-    myExtPS.SetAlgo(A);
-  }
-
- private:
-
-  Extrema_ExtPS myExtPS;
-  TColStd_SequenceOfReal mySqDist;
-  Extrema_SequenceOfPOnSurf myPoints;
-  BRepAdaptor_Surface mySurf;
-};
-
-#endif
diff --git a/src/BRepExtrema/BRepExtrema_Poly.hxx b/src/BRepExtrema/BRepExtrema_Poly.hxx
deleted file mode 100644
index 41095ab..0000000
--- a/src/BRepExtrema/BRepExtrema_Poly.hxx
+++ /dev/null
@@ -1,34 +0,0 @@
-// This file is generated by WOK (CPPExt).
-// Please do not edit this file; modify original file instead.
-// The copyright and license terms as defined for the original file apply to 
-// this header file considered to be the "object code" form of the original source.
-
-#ifndef _BRepExtrema_Poly_HeaderFile
-#define _BRepExtrema_Poly_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-class TopoDS_Shape;
-class gp_Pnt;
-
-
-class BRepExtrema_Poly
-{
- public:
-
-  //! returns Standard_True if OK. <br>
-  Standard_EXPORT static Standard_Boolean Distance(const TopoDS_Shape& S1,const TopoDS_Shape& S2,gp_Pnt& P1,gp_Pnt& P2,Standard_Real& dist);
-};
-
-#endif
diff --git a/src/BRepExtrema/BRepExtrema_SeqOfSolution.hxx b/src/BRepExtrema/BRepExtrema_SeqOfSolution.hxx
deleted file mode 100644
index 3c07a20..0000000
--- a/src/BRepExtrema/BRepExtrema_SeqOfSolution.hxx
+++ /dev/null
@@ -1,18 +0,0 @@
-// This file is generated by WOK (CPPExt).
-// Please do not edit this file; modify original file instead.
-// The copyright and license terms as defined for the original file apply to 
-// this header file considered to be the "object code" form of the original source.
-
-#ifndef _BRepExtrema_SeqOfSolution_HeaderFile
-#define _BRepExtrema_SeqOfSolution_HeaderFile
-
-#ifndef _NCollection_Sequence_HeaderFile
-#include <NCollection_Sequence.hxx>
-#endif
-#ifndef _BRepExtrema_SolutionElem_HeaderFile
-#include <BRepExtrema_SolutionElem.hxx>
-#endif
-
-typedef NCollection_Sequence<BRepExtrema_SolutionElem> BRepExtrema_SeqOfSolution;
-
-#endif
diff --git a/src/BRepExtrema/BRepExtrema_SolutionElem.hxx b/src/BRepExtrema/BRepExtrema_SolutionElem.hxx
deleted file mode 100644
index 1bf1a19..0000000
--- a/src/BRepExtrema/BRepExtrema_SolutionElem.hxx
+++ /dev/null
@@ -1,156 +0,0 @@
-// This file is generated by WOK (CPPExt).
-// Please do not edit this file; modify original file instead.
-// The copyright and license terms as defined for the original file apply to 
-// this header file considered to be the "object code" form of the original source.
-
-#ifndef _BRepExtrema_SolutionElem_HeaderFile
-#define _BRepExtrema_SolutionElem_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _gp_Pnt_HeaderFile
-#include <gp_Pnt.hxx>
-#endif
-#ifndef _BRepExtrema_SupportType_HeaderFile
-#include <BRepExtrema_SupportType.hxx>
-#endif
-#ifndef _TopoDS_Vertex_HeaderFile
-#include <TopoDS_Vertex.hxx>
-#endif
-#ifndef _TopoDS_Edge_HeaderFile
-#include <TopoDS_Edge.hxx>
-#endif
-#ifndef _TopoDS_Face_HeaderFile
-#include <TopoDS_Face.hxx>
-#endif
-class gp_Pnt;
-class TopoDS_Vertex;
-class TopoDS_Edge;
-class TopoDS_Face;
-
-
-//! This class is used to store information relative to the <br>
-//! minimum distance between two shapes. <br>
-class BRepExtrema_SolutionElem
-{
- public:
-
-  void* operator new(size_t,void* anAddress) 
-  {
-    return anAddress;
-  }
-  void* operator new(size_t size) 
-  {
-    return Standard::Allocate(size); 
-  }
-  void  operator delete(void *anAddress) 
-  {
-    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-  }
-
-  
-  Standard_EXPORT BRepExtrema_SolutionElem()
-  : myDist(0.), myPoint(0.,0.,0.), mySupType(BRepExtrema_IsVertex), myPar1(0.), myPar2(0.)
-  {
-  }
-  //! initialisation of the fields <br>
-  //! This constructor is used when the solution of a distance is a Vertex. <br>
-  //! The different initialized fields are: <br>
-  //!            _ the distance d <br>
-  //!            _ the solution point <br>
-  //!            _ the type of solution <br>
-  //!            _ and the Vertex. <br>
-  Standard_EXPORT BRepExtrema_SolutionElem(const Standard_Real d,const gp_Pnt& Pt,const BRepExtrema_SupportType SolType,const TopoDS_Vertex& vertex)
-  : myDist(d), myPoint(Pt), mySupType(SolType), myVertex(vertex), myPar1(0.), myPar2(0.)
-  {
-  }
-  //! initialisation of  the fiels. <br>
-  //! This constructor is used when the  solution of distance is on an Edge. <br>
-  //! The different initialized fields are: <br>
-  //!            _ the distance d, <br>
-  //!            _ the solution point, <br>
-  //!            _ the type of solution, <br>
-  //!            _ the Edge, <br>
-  //!            _ and the parameter t to locate the solution. <br>
-  Standard_EXPORT BRepExtrema_SolutionElem(const Standard_Real d,const gp_Pnt& Pt,const BRepExtrema_SupportType SolType,const TopoDS_Edge& edge,const Standard_Real t)
-  : myDist(d), myPoint(Pt), mySupType(SolType), myEdge(edge), myPar1(t), myPar2(0.)
-  {
-  }
-  //! initialisation of the fields <br>
-  //! This constructor is used when the  solution of distance is in <br>
-  //! a Face. The different initialized fields are: <br>
-  //!            _ the distance d, <br>
-  //!            _ the solution point, <br>
-  //!            _ the type of solution, <br>
-  //!            _ the Face, <br>
-  //!            _ and the parameter u et v to locate the solution. <br>
-  Standard_EXPORT BRepExtrema_SolutionElem(const Standard_Real d,const gp_Pnt& Pt,const BRepExtrema_SupportType SolType,const TopoDS_Face& face,const Standard_Real u,const Standard_Real v)
-  : myDist(d), myPoint(Pt), mySupType(SolType), myFace(face), myPar1(u), myPar2(v)
-  {
-  }
-  //! returns the value of the minimum distance. <br>
-  Standard_EXPORT Standard_Real Dist() const
-  {
-    return myDist;
-  }
-  //! returns the solution point. <br>
-  Standard_EXPORT const gp_Pnt & Point() const
-  {
-    return myPoint;
-  }
-  //! returns the Support type : <br>
-  //!	    IsVertex => The solution is a vertex. <br>
-  //! 	    IsOnEdge => The solution belongs to an Edge. <br>
-  //! 	    IsInFace => The solution is inside a Face. <br>
-  Standard_EXPORT BRepExtrema_SupportType SupportKind() const
-  {
-    return mySupType;
-  }
-  //! returns the vertex if the solution is a Vertex. <br>
-  Standard_EXPORT const TopoDS_Vertex & Vertex() const
-  {
-    return myVertex;
-  }
-  //! returns the vertex if the solution is an Edge. <br>
-  Standard_EXPORT const TopoDS_Edge & Edge() const
-  {
-    return myEdge;
-  }
-  //! returns the vertex if the solution is an Face. <br>
-  Standard_EXPORT const TopoDS_Face & Face() const
-  {
-    return myFace;
-  }
-  //! returns the parameter t if the solution is on Edge. <br>
-  Standard_EXPORT void EdgeParameter(Standard_Real& par1) const
-  {
-    par1 = myPar1;
-  }
-  //! returns the parameters u et v if the solution is in a Face. <br>
-  Standard_EXPORT void FaceParameter(Standard_Real& par1,Standard_Real& par2) const
-  {
-    par1 = myPar1;
-    par2 = myPar2;
-  }
-
- private:
-
-  Standard_Real myDist;
-  gp_Pnt myPoint;
-  BRepExtrema_SupportType mySupType;
-  TopoDS_Vertex myVertex;
-  TopoDS_Edge myEdge;
-  TopoDS_Face myFace;
-  Standard_Real myPar1;
-  Standard_Real myPar2;
-};
-
-#endif
diff --git a/src/BRepExtrema/BRepExtrema_SupportType.hxx b/src/BRepExtrema/BRepExtrema_SupportType.hxx
deleted file mode 100644
index a3d03e6..0000000
--- a/src/BRepExtrema/BRepExtrema_SupportType.hxx
+++ /dev/null
@@ -1,20 +0,0 @@
-// This file is generated by WOK (CPPExt).
-// Please do not edit this file; modify original file instead.
-// The copyright and license terms as defined for the original file apply to 
-// this header file considered to be the "object code" form of the original source.
-
-#ifndef _BRepExtrema_SupportType_HeaderFile
-#define _BRepExtrema_SupportType_HeaderFile
-
-enum BRepExtrema_SupportType
-{
-  BRepExtrema_IsVertex,
-  BRepExtrema_IsOnEdge,
-  BRepExtrema_IsInFace
-};
-
-#ifndef _Standard_PrimitiveTypes_HeaderFile
-#include <Standard_PrimitiveTypes.hxx>
-#endif
-
-#endif
diff --git a/src/BRepFeat/BRepFeat.cxx b/src/BRepFeat/BRepFeat.cxx
index 7a3c474..fbb9c68 100644
--- a/src/BRepFeat/BRepFeat.cxx
+++ b/src/BRepFeat/BRepFeat.cxx
@@ -522,7 +522,7 @@ void BRepFeat::FaceUntil(const TopoDS_Shape& Sbase,
     return;
   }
 
-  FUntil = BRepLib_MakeFace(str);
+  FUntil = BRepLib_MakeFace(str, Precision::Confusion());
 }
 
 
diff --git a/src/BRepFeat/BRepFeat_MakeDPrism.cxx b/src/BRepFeat/BRepFeat_MakeDPrism.cxx
index 54e505f..a45b7c9 100644
--- a/src/BRepFeat/BRepFeat_MakeDPrism.cxx
+++ b/src/BRepFeat/BRepFeat_MakeDPrism.cxx
@@ -796,7 +796,7 @@ void BRepFeat_MakeDPrism::PerformFromEnd(const TopoDS_Shape& Until)
 	S = Handle(Geom_RectangularTrimmedSurface)::
 	  DownCast(S)->BasisSurface();
       }
-      BRepLib_MakeFace fac(S);
+      BRepLib_MakeFace fac(S, Precision::Confusion());
       mySFrom = fac.Face();  
       Trf = TransformShapeFU(0);
 //      FFrom = TopoDS::Face(mySFrom);      
diff --git a/src/BRepFeat/BRepFeat_MakePrism.cxx b/src/BRepFeat/BRepFeat_MakePrism.cxx
index 734872d..5c7cbc5 100644
--- a/src/BRepFeat/BRepFeat_MakePrism.cxx
+++ b/src/BRepFeat/BRepFeat_MakePrism.cxx
@@ -833,7 +833,7 @@ void BRepFeat_MakePrism::PerformFromEnd(const TopoDS_Shape& Until)
 	S = Handle(Geom_RectangularTrimmedSurface)::
 	  DownCast(S)->BasisSurface();
       }
-      BRepLib_MakeFace fac(S);
+      BRepLib_MakeFace fac(S, Precision::Confusion());
       mySFrom = fac.Face();  
       Trf = TransformShapeFU(0);
       FFrom = TopoDS::Face(mySFrom);
diff --git a/src/BRepFill/BRepFill_CompatibleWires.cxx b/src/BRepFill/BRepFill_CompatibleWires.cxx
index 0db9132..7dbb931 100644
--- a/src/BRepFill/BRepFill_CompatibleWires.cxx
+++ b/src/BRepFill/BRepFill_CompatibleWires.cxx
@@ -786,6 +786,41 @@ void BRepFill_CompatibleWires::
   if (!allClosed)
     Standard_NoSuchObject::Raise("BRepFill_CompatibleWires::SameNumberByPolarMethod : the wires must be closed");
   
+  // sections ponctuelles, sections bouclantes ?
+  if (myDegen1) ideb++;
+  if (myDegen2) ifin--;
+  Standard_Boolean vClosed = (!myDegen1) && (!myDegen2)
+                                && (myWork(ideb).IsSame(myWork(ifin)));
+
+  //Removing degenerated edges
+  for (i = ideb; i <= ifin; i++)
+  {
+    Standard_Boolean hasDegEdge = Standard_False;
+    TopoDS_Iterator anItw(myWork(i));
+    for (; anItw.More(); anItw.Next())
+    {
+      const TopoDS_Edge& anEdge = TopoDS::Edge(anItw.Value());
+      if (BRep_Tool::Degenerated(anEdge))
+      {
+        hasDegEdge = Standard_True;
+        break;
+      }
+    }
+    if (hasDegEdge)
+    {
+      TopoDS_Wire aNewWire;
+      BRep_Builder aBBuilder;
+      aBBuilder.MakeWire(aNewWire);
+      for (anItw.Initialize(myWork(i)); anItw.More(); anItw.Next())
+      {
+        const TopoDS_Edge& anEdge = TopoDS::Edge(anItw.Value());
+        if (!BRep_Tool::Degenerated(anEdge))
+          aBBuilder.Add(aNewWire, anEdge);
+      }
+      myWork(i) = aNewWire;
+    }
+  }
+  
   // Nombre max de decoupes possibles
   Standard_Integer NbMaxV = 0;
   for (i=1; i<=NbSects; i++) {
@@ -794,12 +829,6 @@ void BRepFill_CompatibleWires::
     }
   }
   
-  // sections ponctuelles, sections bouclantes ?
-  if (myDegen1) ideb++;
-  if (myDegen2) ifin--;
-  Standard_Boolean vClosed = (!myDegen1) && (!myDegen2)
-                                && (myWork(ideb).IsSame(myWork(ifin)));
-  
   // construction des tableaux de plans des wires 
   gp_Pln P;
   Handle(TColgp_HArray1OfPnt) Pos
@@ -1364,14 +1393,19 @@ void BRepFill_CompatibleWires::ComputeOrigin(const  Standard_Boolean polar )
 
   //Consider that all wires have same number of edges (polar==Standard_False)
   TopTools_SequenceOfShape PrevSeq;
+  TopTools_SequenceOfShape PrevEseq;
   Standard_Integer theLength = 0;
   const TopoDS_Wire& wire = TopoDS::Wire( myWork(ideb) );
   for (anExp.Init(wire); anExp.More(); anExp.Next())
     {
       PrevSeq.Append(anExp.CurrentVertex());
+      PrevEseq.Append(anExp.Current());
       theLength++;
     }
 
+  Standard_Integer nbs, NbSamples = 0;
+  if (theLength <= 2)
+    NbSamples = 4;
   for (i = ideb+1; i <= ifin; i++)
     {
       const TopoDS_Wire& wire = TopoDS::Wire(myWork(i));
@@ -1407,6 +1441,27 @@ void BRepFill_CompatibleWires::ComputeOrigin(const  Standard_Boolean polar )
 		const TopoDS_Vertex& V = TopoDS::Vertex( SeqVertices(k) );
 		gp_Pnt P = BRep_Tool::Pnt(V);
 		SumDist += Pprev.Distance(P);
+                if (NbSamples > 0)
+                {
+                  const TopoDS_Edge& PrevEdge = TopoDS::Edge(PrevEseq(n));
+                  const TopoDS_Edge& CurEdge = TopoDS::Edge(SeqEdges(k));
+                  BRepAdaptor_Curve PrevEcurve(PrevEdge);
+                  BRepAdaptor_Curve Ecurve(CurEdge);
+                  Standard_Real SampleOnPrev = (PrevEcurve.LastParameter()-PrevEcurve.FirstParameter())/NbSamples;
+                  Standard_Real SampleOnCur = (Ecurve.LastParameter()-Ecurve.FirstParameter())/NbSamples;
+                  for (nbs = 1; nbs <= NbSamples-1; nbs++)
+                  {
+                    Standard_Real ParOnPrev = (PrevEdge.Orientation() == TopAbs_FORWARD)?
+                      (PrevEcurve.FirstParameter() + nbs*SampleOnPrev) :
+                      (PrevEcurve.FirstParameter() + (NbSamples-nbs)*SampleOnPrev);
+                    Standard_Real ParOnCur = (CurEdge.Orientation() == TopAbs_FORWARD)?
+                      (Ecurve.FirstParameter() + nbs*SampleOnCur) :
+                      (Ecurve.FirstParameter() + (NbSamples-nbs)*SampleOnCur);
+                    gp_Pnt PonPrev = PrevEcurve.Value(ParOnPrev);
+                    gp_Pnt PonCur = Ecurve.Value(ParOnCur);
+                    SumDist += PonPrev.Distance(PonCur);
+                  }
+                }
 	      }
 	    for (k = 1; k < j; k++, n++)
 	      {
@@ -1415,6 +1470,27 @@ void BRepFill_CompatibleWires::ComputeOrigin(const  Standard_Boolean polar )
 		const TopoDS_Vertex& V = TopoDS::Vertex( SeqVertices(k) );
 		gp_Pnt P = BRep_Tool::Pnt(V);
 		SumDist += Pprev.Distance(P);
+                if (NbSamples > 0)
+                {
+                  const TopoDS_Edge& PrevEdge = TopoDS::Edge(PrevEseq(n));
+                  const TopoDS_Edge& CurEdge = TopoDS::Edge(SeqEdges(k));
+                  BRepAdaptor_Curve PrevEcurve(PrevEdge);
+                  BRepAdaptor_Curve Ecurve(CurEdge);
+                  Standard_Real SampleOnPrev = (PrevEcurve.LastParameter()-PrevEcurve.FirstParameter())/NbSamples;
+                  Standard_Real SampleOnCur = (Ecurve.LastParameter()-Ecurve.FirstParameter())/NbSamples;
+                  for (nbs = 1; nbs <= NbSamples-1; nbs++)
+                  {
+                    Standard_Real ParOnPrev = (PrevEdge.Orientation() == TopAbs_FORWARD)?
+                      (PrevEcurve.FirstParameter() + nbs*SampleOnPrev) :
+                      (PrevEcurve.FirstParameter() + (NbSamples-nbs)*SampleOnPrev);
+                    Standard_Real ParOnCur = (CurEdge.Orientation() == TopAbs_FORWARD)?
+                      (Ecurve.FirstParameter() + nbs*SampleOnCur) :
+                      (Ecurve.FirstParameter() + (NbSamples-nbs)*SampleOnCur);
+                    gp_Pnt PonPrev = PrevEcurve.Value(ParOnPrev);
+                    gp_Pnt PonCur = Ecurve.Value(ParOnCur);
+                    SumDist += PonPrev.Distance(PonCur);
+                  }
+                }
 	      }
 	    if (SumDist < MinSumDist)
 	      {
@@ -1432,6 +1508,30 @@ void BRepFill_CompatibleWires::ComputeOrigin(const  Standard_Boolean polar )
 		const TopoDS_Vertex& V = TopoDS::Vertex( SeqVertices(k) );
 		gp_Pnt P = BRep_Tool::Pnt(V);
 		SumDist += Pprev.Distance(P);
+                if (NbSamples > 0)
+                {
+                  Standard_Integer k_cur = k-1;
+                  if (k_cur == 0)
+                    k_cur = theLength;
+                  const TopoDS_Edge& PrevEdge = TopoDS::Edge(PrevEseq(n));
+                  const TopoDS_Edge& CurEdge = TopoDS::Edge(SeqEdges(k_cur));
+                  BRepAdaptor_Curve PrevEcurve(PrevEdge);
+                  BRepAdaptor_Curve Ecurve(CurEdge);
+                  Standard_Real SampleOnPrev = (PrevEcurve.LastParameter()-PrevEcurve.FirstParameter())/NbSamples;
+                  Standard_Real SampleOnCur = (Ecurve.LastParameter()-Ecurve.FirstParameter())/NbSamples;
+                  for (nbs = 1; nbs <= NbSamples-1; nbs++)
+                  {
+                    Standard_Real ParOnPrev = (PrevEdge.Orientation() == TopAbs_FORWARD)?
+                      (PrevEcurve.FirstParameter() + nbs*SampleOnPrev) :
+                      (PrevEcurve.FirstParameter() + (NbSamples-nbs)*SampleOnPrev);
+                    Standard_Real ParOnCur = (CurEdge.Orientation() == TopAbs_FORWARD)?
+                      (Ecurve.FirstParameter() + (NbSamples-nbs)*SampleOnCur) :
+                      (Ecurve.FirstParameter() + nbs*SampleOnCur);
+                    gp_Pnt PonPrev = PrevEcurve.Value(ParOnPrev);
+                    gp_Pnt PonCur = Ecurve.Value(ParOnCur);
+                    SumDist += PonPrev.Distance(PonCur);
+                  }
+                }
 	      }
 	    for (k = theLength; k > j; k--, n++)
 	      {
@@ -1440,6 +1540,27 @@ void BRepFill_CompatibleWires::ComputeOrigin(const  Standard_Boolean polar )
 		const TopoDS_Vertex& V = TopoDS::Vertex( SeqVertices(k) );
 		gp_Pnt P = BRep_Tool::Pnt(V);
 		SumDist += Pprev.Distance(P);
+                if (NbSamples > 0)
+                {
+                  const TopoDS_Edge& PrevEdge = TopoDS::Edge(PrevEseq(n));
+                  const TopoDS_Edge& CurEdge = TopoDS::Edge(SeqEdges(k-1));
+                  BRepAdaptor_Curve PrevEcurve(PrevEdge);
+                  BRepAdaptor_Curve Ecurve(CurEdge);
+                  Standard_Real SampleOnPrev = (PrevEcurve.LastParameter()-PrevEcurve.FirstParameter())/NbSamples;
+                  Standard_Real SampleOnCur = (Ecurve.LastParameter()-Ecurve.FirstParameter())/NbSamples;
+                  for (nbs = 1; nbs <= NbSamples-1; nbs++)
+                  {
+                    Standard_Real ParOnPrev = (PrevEdge.Orientation() == TopAbs_FORWARD)?
+                      (PrevEcurve.FirstParameter() + nbs*SampleOnPrev) :
+                      (PrevEcurve.FirstParameter() + (NbSamples-nbs)*SampleOnPrev);
+                    Standard_Real ParOnCur = (CurEdge.Orientation() == TopAbs_FORWARD)?
+                      (Ecurve.FirstParameter() + (NbSamples-nbs)*SampleOnCur) :
+                      (Ecurve.FirstParameter() + nbs*SampleOnCur);
+                    gp_Pnt PonPrev = PrevEcurve.Value(ParOnPrev);
+                    gp_Pnt PonCur = Ecurve.Value(ParOnCur);
+                    SumDist += PonPrev.Distance(PonCur);
+                  }
+                }
 	      }
 	    if (SumDist < MinSumDist)
 	      {
@@ -1450,17 +1571,20 @@ void BRepFill_CompatibleWires::ComputeOrigin(const  Standard_Boolean polar )
 	  }
       
       PrevSeq.Clear();
+      PrevEseq.Clear();
       if (forward)
 	{
 	  for (j = jmin; j <= theLength; j++)
 	    {
 	      BB.Add( newwire, TopoDS::Edge(SeqEdges(j)) );
 	      PrevSeq.Append( SeqVertices(j) );
+              PrevEseq.Append( SeqEdges(j) );
 	    }
 	  for (j = 1; j < jmin; j++)
 	    {
 	      BB.Add( newwire, TopoDS::Edge(SeqEdges(j)) );
 	      PrevSeq.Append( SeqVertices(j) );
+              PrevEseq.Append( SeqEdges(j) );
 	    }
 	}
       else
@@ -1470,12 +1594,14 @@ void BRepFill_CompatibleWires::ComputeOrigin(const  Standard_Boolean polar )
 	      TopoDS_Shape aLocalShape = SeqEdges(j).Reversed();
 	      BB.Add( newwire, TopoDS::Edge(aLocalShape) );
 	      //PrevSeq.Append( SeqVertices(j) );
+              PrevEseq.Append( SeqEdges(j).Reversed() );
 	    }
 	  for (j = theLength; j >= jmin; j--)
 	    {
 	      TopoDS_Shape aLocalShape = SeqEdges(j).Reversed();
 	      BB.Add( newwire, TopoDS::Edge(aLocalShape) );
 	      //PrevSeq.Append( SeqVertices(j) );
+              PrevEseq.Append( SeqEdges(j).Reversed() );
 	    }
 	  for (j = jmin; j >= 1; j--)
 	    PrevSeq.Append( SeqVertices(j) );
@@ -1905,11 +2031,3 @@ void BRepFill_CompatibleWires::SearchOrigin()
   // sections bouclantes ?
   if (vClosed) myWork(myWork.Length()) = myWork(1);
 }
-
-
-
-
-
-
-
-
diff --git a/src/BRepFill/BRepFill_Draft.cxx b/src/BRepFill/BRepFill_Draft.cxx
index c837c82..eeb4740 100644
--- a/src/BRepFill/BRepFill_Draft.cxx
+++ b/src/BRepFill/BRepFill_Draft.cxx
@@ -552,7 +552,7 @@ static Standard_Boolean GoodOrientation(const Bnd_Box& B,
   // En attendant une utilisation des traces & retriction dans BRepFill_Sweep
   // On fait un Fuse.
     BRepLib_MakeFace MkF;
-    MkF.Init(Surf);
+    MkF.Init(Surf, Standard_True, Precision::Confusion());
     Fuse(MkF.Face(), KeepOutSide);
   }
 }
diff --git a/src/BRepLib/BRepLib_MakeFace.cdl b/src/BRepLib/BRepLib_MakeFace.cdl
index c335e64..1b6c8d4 100644
--- a/src/BRepLib/BRepLib_MakeFace.cdl
+++ b/src/BRepLib/BRepLib_MakeFace.cdl
@@ -88,9 +88,10 @@ is
 	---Level: Public
     returns MakeFace from BRepLib;
 
-    Create(S : Surface from Geom)
-	---Purpose: Make a face from a Surface.
-	---Level: Public
+    Create(S : Surface from Geom; TolDegen : Real)
+    ---Purpose: Make a face from a Surface. Accepts tolerance value (TolDegen)
+    --          for resolution of degenerated edges.
+    ---Level: Public
     returns MakeFace from BRepLib;
 
     ----------------------------------------------
@@ -122,9 +123,11 @@ is
 	---Level: Public
     returns MakeFace from BRepLib;
 
-    Create(S : Surface from Geom; UMin, UMax, VMin, VMax : Real)
-	---Purpose: Make a face from a Surface.
-	---Level: Public
+    Create(S : Surface from Geom; UMin, UMax, VMin, VMax, TolDegen : Real)
+    ---Purpose: Make a face from a Surface. Accepts min & max parameters
+    --          to construct the face's bounds. Also accepts tolerance value (TolDegen)
+    --          for resolution of degenerated edges.
+    ---Level: Public
     returns MakeFace from BRepLib;
 
     ----------------------------------------------
@@ -198,16 +201,19 @@ is
 	---Level: Public
     is static;
 
-    Init(me : in out; S : Surface from Geom; Bound : Boolean = Standard_True)
-	---Purpose: Creates the face  from the  surface.  If Bound  is
-	--          True a wire is made from the natural bounds.
-	---Level: Public
+    Init(me : in out; S : Surface from Geom; Bound : Boolean; TolDegen : Real)
+    ---Purpose: Creates the face  from the  surface. If Bound is
+    --          True a wire is made from the natural bounds.
+    --          Accepts tolerance value (TolDegen) for resolution
+    --          of degenerated edges.
+    ---Level: Public
     is static;
 
-    Init(me : in out; S : Surface from Geom; UMin, UMax, VMin, VMax : Real) 
-	---Purpose: Creates the face from the surface  and the min-max
-	--          values.
-	---Level: Public
+    Init(me : in out; S : Surface from Geom; UMin, UMax, VMin, VMax, TolDegen : Real) 
+    ---Purpose: Creates the face from the surface and the min-max
+    --          values. Accepts tolerance value (TolDegen) for resolution
+    --          of degenerated edges.
+    ---Level: Public
     is static;
 
     Add(me : in out; W : Wire from TopoDS)
@@ -244,6 +250,5 @@ is
     is static;
     
 fields
-    myError : FaceError from BRepLib;
-
+    myError    : FaceError from BRepLib;
 end MakeFace;
diff --git a/src/BRepLib/BRepLib_MakeFace.cxx b/src/BRepLib/BRepLib_MakeFace.cxx
index 5299b44..c454681 100644
--- a/src/BRepLib/BRepLib_MakeFace.cxx
+++ b/src/BRepLib/BRepLib_MakeFace.cxx
@@ -68,7 +68,7 @@ BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Face& F)
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Pln& P)
 {
   Handle(Geom_Plane) GP = new Geom_Plane(P);
-  Init(GP);
+  Init(GP, Standard_True, Precision::Confusion());
 }
 
 
@@ -80,7 +80,7 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Pln& P)
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cylinder& C)
 {
   Handle(Geom_CylindricalSurface) GC = new Geom_CylindricalSurface(C);
-  Init(GC);
+  Init(GC, Standard_True, Precision::Confusion());
 }
 
 
@@ -92,7 +92,7 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cylinder& C)
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cone& C)
 {
   Handle(Geom_ConicalSurface) GC = new Geom_ConicalSurface(C);
-  Init(GC);
+  Init(GC, Standard_True, Precision::Confusion());
 }
 
 
@@ -104,7 +104,7 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cone& C)
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Sphere& S)
 {
   Handle(Geom_SphericalSurface) GS = new Geom_SphericalSurface(S);
-  Init(GS);
+  Init(GS, Standard_True, Precision::Confusion());
 }
 
 
@@ -116,7 +116,7 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Sphere& S)
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Torus& T)
 {
   Handle(Geom_ToroidalSurface) GT = new Geom_ToroidalSurface(T);
-  Init(GT);
+  Init(GT, Standard_True, Precision::Confusion());
 }
 
 
@@ -125,9 +125,10 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Torus& T)
 //purpose  : 
 //=======================================================================
 
-BRepLib_MakeFace::BRepLib_MakeFace(const Handle(Geom_Surface)& S)
+BRepLib_MakeFace::BRepLib_MakeFace(const Handle(Geom_Surface)& S,
+                                   const Standard_Real TolDegen)
 {
-  Init(S);
+  Init(S, Standard_True, TolDegen);
 }
 
 
@@ -137,13 +138,13 @@ BRepLib_MakeFace::BRepLib_MakeFace(const Handle(Geom_Surface)& S)
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Pln& P,
-				   const Standard_Real UMin,
-				   const Standard_Real UMax,
-				   const Standard_Real VMin,
-				   const Standard_Real VMax)
+                                   const Standard_Real UMin,
+                                   const Standard_Real UMax,
+                                   const Standard_Real VMin,
+                                   const Standard_Real VMax)
 {
   Handle(Geom_Plane) GP = new Geom_Plane(P);
-  Init(GP,UMin,UMax,VMin,VMax);
+  Init(GP, UMin, UMax, VMin, VMax, Precision::Confusion());
 }
 
 
@@ -153,13 +154,13 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Pln& P,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cylinder& C,
-				   const Standard_Real UMin,
-				   const Standard_Real UMax,
-				   const Standard_Real VMin,
-				   const Standard_Real VMax)
+                                   const Standard_Real UMin,
+                                   const Standard_Real UMax,
+                                   const Standard_Real VMin,
+                                   const Standard_Real VMax)
 {
   Handle(Geom_CylindricalSurface) GC = new Geom_CylindricalSurface(C);
-  Init(GC,UMin,UMax,VMin,VMax);
+  Init(GC, UMin, UMax, VMin, VMax, Precision::Confusion());
 }
 
 
@@ -169,13 +170,13 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cylinder& C,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cone& C,
-				   const Standard_Real UMin,
-				   const Standard_Real UMax,
-				   const Standard_Real VMin,
-				   const Standard_Real VMax)
+                                   const Standard_Real UMin,
+                                   const Standard_Real UMax,
+                                   const Standard_Real VMin,
+                                   const Standard_Real VMax)
 {
   Handle(Geom_ConicalSurface) GC = new Geom_ConicalSurface(C);
-  Init(GC,UMin,UMax,VMin,VMax);
+  Init(GC, UMin, UMax, VMin, VMax, Precision::Confusion());
 }
 
 
@@ -185,13 +186,13 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cone& C,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Sphere& S,
-				   const Standard_Real UMin,
-				   const Standard_Real UMax,
-				   const Standard_Real VMin,
-				   const Standard_Real VMax)
+                                   const Standard_Real UMin,
+                                   const Standard_Real UMax,
+                                   const Standard_Real VMin,
+                                   const Standard_Real VMax)
 {
   Handle(Geom_SphericalSurface) GS = new Geom_SphericalSurface(S);
-  Init(GS,UMin,UMax,VMin,VMax);
+  Init(GS, UMin, UMax, VMin, VMax, Precision::Confusion());
 }
 
 
@@ -201,13 +202,13 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Sphere& S,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Torus& T,
-				   const Standard_Real UMin,
-				   const Standard_Real UMax,
-				   const Standard_Real VMin,
-				   const Standard_Real VMax)
+                                   const Standard_Real UMin,
+                                   const Standard_Real UMax,
+                                   const Standard_Real VMin,
+                                   const Standard_Real VMax)
 {
   Handle(Geom_ToroidalSurface) GT = new Geom_ToroidalSurface(T);
-  Init(GT,UMin,UMax,VMin,VMax);
+  Init(GT, UMin, UMax, VMin, VMax, Precision::Confusion());
 }
 
 
@@ -217,12 +218,13 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Torus& T,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const Handle(Geom_Surface)& S,
-				   const Standard_Real UMin,
-				   const Standard_Real UMax,
-				   const Standard_Real VMin,
-				   const Standard_Real VMax)
+                                   const Standard_Real UMin,
+                                   const Standard_Real UMax,
+                                   const Standard_Real VMin,
+                                   const Standard_Real VMax,
+                                   const Standard_Real TolDegen)
 {
-  Init(S,UMin,UMax,VMin,VMax);
+  Init(S, UMin, UMax, VMin, VMax, TolDegen);
 }
 
 
@@ -232,7 +234,7 @@ BRepLib_MakeFace::BRepLib_MakeFace(const Handle(Geom_Surface)& S,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W,
-				   const Standard_Boolean OnlyPlane)
+                                   const Standard_Boolean OnlyPlane)
 
 {
   // Find a surface through the wire
@@ -263,11 +265,11 @@ BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Pln& P,
-				   const TopoDS_Wire& W,
-				   const Standard_Boolean Inside)
+                                   const TopoDS_Wire& W,
+                                   const Standard_Boolean Inside)
 {
   Handle(Geom_Plane) Pl = new Geom_Plane(P);
-  Init(Pl,Standard_False);
+  Init(Pl, Standard_False, Precision::Confusion());
   Add(W);
   if (Inside) CheckInside();
 }
@@ -279,11 +281,11 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Pln& P,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cylinder& C,
-				   const TopoDS_Wire& W,
-				   const Standard_Boolean Inside)
+                                   const TopoDS_Wire& W,
+                                   const Standard_Boolean Inside)
 {
   Handle(Geom_CylindricalSurface) GC = new Geom_CylindricalSurface(C);
-  Init(GC,Standard_False);
+  Init(GC, Standard_False, Precision::Confusion());
   Add(W);
   if (Inside) CheckInside();
 }
@@ -295,11 +297,11 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cylinder& C,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cone& C,
-				   const TopoDS_Wire& W,
-				   const Standard_Boolean Inside)
+                                   const TopoDS_Wire& W,
+                                   const Standard_Boolean Inside)
 {
   Handle(Geom_ConicalSurface) GC = new Geom_ConicalSurface(C);
-  Init(GC,Standard_False);
+  Init(GC, Standard_False, Precision::Confusion());
   Add(W);
   if (Inside) CheckInside();
 }
@@ -311,11 +313,11 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cone& C,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Sphere& S,
-				   const TopoDS_Wire& W,
-				   const Standard_Boolean Inside)
+                                   const TopoDS_Wire& W,
+                                   const Standard_Boolean Inside)
 {
   Handle(Geom_SphericalSurface) GS = new Geom_SphericalSurface(S);
-  Init(GS,Standard_False);
+  Init(GS, Standard_False, Precision::Confusion());
   Add(W);
   if (Inside) CheckInside();
 }
@@ -327,11 +329,11 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Sphere& S,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const gp_Torus& T,
-				   const TopoDS_Wire& W,
-				   const Standard_Boolean Inside)
+                                   const TopoDS_Wire& W,
+                                   const Standard_Boolean Inside)
 {
   Handle(Geom_ToroidalSurface) GT = new Geom_ToroidalSurface(T);
-  Init(GT,Standard_False);
+  Init(GT, Standard_False, Precision::Confusion());
   Add(W);
   if (Inside) CheckInside();
 }
@@ -343,10 +345,10 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Torus& T,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const Handle(Geom_Surface)& S,
-				   const TopoDS_Wire& W,
-				   const Standard_Boolean Inside)
+                                   const TopoDS_Wire& W,
+                                   const Standard_Boolean Inside)
 {
-  Init(S,Standard_False);
+  Init(S, Standard_False, Precision::Confusion());
   Add(W);
   if (Inside) CheckInside();
 }
@@ -358,7 +360,7 @@ BRepLib_MakeFace::BRepLib_MakeFace(const Handle(Geom_Surface)& S,
 //=======================================================================
 
 BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Face& F,
-				   const TopoDS_Wire& W)
+                                   const TopoDS_Wire& W)
 {
   Init(F);
   Add(W);
@@ -389,13 +391,14 @@ void BRepLib_MakeFace::Init(const TopoDS_Face& F)
 //=======================================================================
 
 void  BRepLib_MakeFace::Init(const Handle(Geom_Surface)& S,
-			     const Standard_Boolean Bound)
+                             const Standard_Boolean Bound,
+                             const Standard_Real TolDegen)
 {
   myError = BRepLib_FaceDone;
   if (Bound) {
     Standard_Real UMin,UMax,VMin,VMax;
     S->Bounds(UMin,UMax,VMin,VMax);
-    Init(S,UMin,UMax,VMin,VMax);
+    Init(S,UMin,UMax,VMin,VMax,TolDegen);
   }
   else {
     BRep_Builder B;
@@ -408,44 +411,58 @@ void  BRepLib_MakeFace::Init(const Handle(Geom_Surface)& S,
 
 //=======================================================================
 //function : IsDegenerated
-//purpose  : fonction statique qui verifie qu'une courbe n'est pas reduite 
-//           a un point, pour ainsi coder l'edge Degenere.
+//purpose  : Checks whether the passed curve is degenerated with the
+//           passed tolerance value
 //=======================================================================
 
-static Standard_Boolean IsDegenerated(const Handle(Geom_Curve)& C,
-				      const Standard_Real       tol)
+static Standard_Boolean IsDegenerated(const Handle(Geom_Curve)& theCurve,
+                                      const Standard_Real theMaxTol,
+                                      Standard_Real& theActTol)
 {
-  GeomAdaptor_Curve AC(C);
-  
+  GeomAdaptor_Curve AC(theCurve);
+  Standard_Real aConfusion = Precision::Confusion();
+  theActTol = aConfusion;
   GeomAbs_CurveType Type = AC.GetType();
+
   if (Type == GeomAbs_Circle) {
     gp_Circ Circ = AC.Circle();
-    return (Circ.Radius() < tol);
+    if ( Circ.Radius() > theMaxTol )
+      return Standard_False;
+    theActTol = Max(Circ.Radius(), aConfusion);
+    return Standard_True;
   }
   else if (Type == GeomAbs_BSplineCurve) {
     Handle(Geom_BSplineCurve) BS = AC.BSpline();
     Standard_Integer NbPoles = BS->NbPoles();
-    Standard_Real tol2 = tol*tol;
+    Standard_Real aMaxPoleDist2 = 0.0, aMaxTol2 = theMaxTol*theMaxTol;
     gp_Pnt P1,P2;
     P1 = BS->Pole(1);
     for (Standard_Integer i = 2; i <= NbPoles; i++) {
       P2 = BS->Pole(i);
-      if (P1.SquareDistance(P2) > tol2) return Standard_False;
-//      P1 = P2;
+      Standard_Real aPoleDist2 = P1.SquareDistance(P2);
+      if (aPoleDist2 > aMaxTol2)
+        return Standard_False;
+      if (aPoleDist2 > aMaxPoleDist2)
+        aMaxPoleDist2 = aPoleDist2;
     }
+    theActTol = Max(1.000001*Sqrt(aMaxPoleDist2), aConfusion);
     return Standard_True;
   }
   else if (Type == GeomAbs_BezierCurve) {
     Handle(Geom_BezierCurve) BZ = AC.Bezier();
     Standard_Integer NbPoles = BZ->NbPoles();
-    Standard_Real tol2 = tol*tol;
+    Standard_Real aMaxPoleDist2 = 0.0, aMaxTol2 = theMaxTol*theMaxTol;;
     gp_Pnt P1,P2;
     P1 = BZ->Pole(1);
     for (Standard_Integer i = 2; i <= NbPoles; i++) {
       P2 = BZ->Pole(i);
-      if (P1.SquareDistance(P2) > tol2) return Standard_False;
-//      P1 = P2;
+      Standard_Real aPoleDist2 = P1.SquareDistance(P2);
+      if (aPoleDist2 > aMaxTol2)
+        return Standard_False;
+      if (aPoleDist2 > aMaxPoleDist2)
+        aMaxPoleDist2 = aPoleDist2;
     }
+    theActTol = Max(1.000001*Sqrt(aMaxPoleDist2), aConfusion);
     return Standard_True;
   }
   
@@ -458,10 +475,11 @@ static Standard_Boolean IsDegenerated(const Handle(Geom_Curve)& C,
 //=======================================================================
 
 void  BRepLib_MakeFace::Init(const Handle(Geom_Surface)& SS,
-			     const Standard_Real Um,
-			     const Standard_Real UM,
-			     const Standard_Real Vm,
-			     const Standard_Real VM)
+                             const Standard_Real Um,
+                             const Standard_Real UM,
+                             const Standard_Real Vm,
+                             const Standard_Real VM,
+                             const Standard_Real TolDegen)
 {
   myError = BRepLib_FaceDone;
 
@@ -549,26 +567,27 @@ void  BRepLib_MakeFace::Init(const Handle(Geom_Surface)& SS,
   
   
   // compute 3d curves and degenerate flag
-  Standard_Real tol = Precision::Confusion();
+  Standard_Real maxTol = TolDegen;
   Handle(Geom_Curve) Cumin,Cumax,Cvmin,Cvmax;
   Standard_Boolean Dumin,Dumax,Dvmin,Dvmax;
   Dumin = Dumax = Dvmin = Dvmax = Standard_False;
+  Standard_Real uminTol, umaxTol, vminTol, vmaxTol;
 
   if (!umininf) {
     Cumin = S->UIso(UMin);
-    Dumin = IsDegenerated(Cumin,tol);
+    Dumin = IsDegenerated(Cumin, maxTol, uminTol);
   }
   if (!umaxinf) {
     Cumax = S->UIso(UMax);
-    Dumax = IsDegenerated(Cumax,tol);
+    Dumax = IsDegenerated(Cumax, maxTol, umaxTol);
   }
   if (!vmininf) {
     Cvmin = S->VIso(VMin);
-    Dvmin = IsDegenerated(Cvmin,tol);
+    Dvmin = IsDegenerated(Cvmin, maxTol, vminTol);
   }
   if (!vmaxinf) {
     Cvmax = S->VIso(VMax);
-    Dvmax = IsDegenerated(Cvmax,tol);
+    Dvmax = IsDegenerated(Cvmax, maxTol, vmaxTol);
   }
 
   // compute vertices
@@ -577,12 +596,12 @@ void  BRepLib_MakeFace::Init(const Handle(Geom_Surface)& SS,
   TopoDS_Vertex V00,V10,V11,V01;
   
   if (!umininf) {
-    if (!vmininf) B.MakeVertex(V00,S->Value(UMin,VMin),tol);
-    if (!vmaxinf) B.MakeVertex(V01,S->Value(UMin,VMax),tol);
+    if (!vmininf) B.MakeVertex(V00,S->Value(UMin,VMin), Max(uminTol, vminTol));
+    if (!vmaxinf) B.MakeVertex(V01,S->Value(UMin,VMax), Max(uminTol, vmaxTol));
   }
   if (!umaxinf) {
-    if (!vmininf) B.MakeVertex(V10,S->Value(UMax,VMin),tol);
-    if (!vmaxinf) B.MakeVertex(V11,S->Value(UMax,VMax),tol);
+    if (!vmininf) B.MakeVertex(V10,S->Value(UMax,VMin), Max(umaxTol, vminTol));
+    if (!vmaxinf) B.MakeVertex(V11,S->Value(UMax,VMax), Max(umaxTol, vmaxTol));
   }
 
   if (uclosed) {
@@ -613,20 +632,20 @@ void  BRepLib_MakeFace::Init(const Handle(Geom_Surface)& SS,
   
   // make the face
   TopoDS_Face& F = TopoDS::Face(myShape);
-  B.MakeFace(F,S,tol);
+  B.MakeFace(F,S,Precision::Confusion());
 
   // make the edges
   TopoDS_Edge eumin,eumax,evmin,evmax;
 
   if (!umininf) {
     if (!Dumin)
-      B.MakeEdge(eumin,Cumin,tol);
+      B.MakeEdge(eumin,Cumin,uminTol);
     else
       B.MakeEdge(eumin);
     if (uclosed) 
-      B.UpdateEdge(eumin,Lumax,Lumin,F,tol);
+      B.UpdateEdge(eumin,Lumax,Lumin,F,Max(uminTol, umaxTol));
     else
-      B.UpdateEdge(eumin,Lumin,F,tol);
+      B.UpdateEdge(eumin,Lumin,F,uminTol);
     B.Degenerated(eumin,Dumin);
     if (!vmininf) {
       V00.Orientation(TopAbs_FORWARD);
@@ -644,10 +663,10 @@ void  BRepLib_MakeFace::Init(const Handle(Geom_Surface)& SS,
       eumax = eumin;
     else {
       if (!Dumax)
-	B.MakeEdge(eumax,Cumax,tol);
+	B.MakeEdge(eumax,Cumax,umaxTol);
       else
 	B.MakeEdge(eumax);
-      B.UpdateEdge(eumax,Lumax,F,tol);
+      B.UpdateEdge(eumax,Lumax,F,umaxTol);
       B.Degenerated(eumax,Dumax);
       if (!vmininf) {
 	V10.Orientation(TopAbs_FORWARD);
@@ -663,13 +682,13 @@ void  BRepLib_MakeFace::Init(const Handle(Geom_Surface)& SS,
 
   if (!vmininf) {
     if (!Dvmin)
-      B.MakeEdge(evmin,Cvmin,tol);
+      B.MakeEdge(evmin,Cvmin,vminTol);
     else
       B.MakeEdge(evmin);
     if (vclosed)
-      B.UpdateEdge(evmin,Lvmin,Lvmax,F,tol);
+      B.UpdateEdge(evmin,Lvmin,Lvmax,F,Max(vminTol, vmaxTol));
     else
-      B.UpdateEdge(evmin,Lvmin,F,tol);
+      B.UpdateEdge(evmin,Lvmin,F,vminTol);
     B.Degenerated(evmin,Dvmin);
     if (!umininf) {
       V00.Orientation(TopAbs_FORWARD);
@@ -687,10 +706,10 @@ void  BRepLib_MakeFace::Init(const Handle(Geom_Surface)& SS,
       evmax = evmin;
     else {
       if (!Dvmax)
-	B.MakeEdge(evmax,Cvmax,tol);
+	B.MakeEdge(evmax,Cvmax,vmaxTol);
       else
 	B.MakeEdge(evmax);
-      B.UpdateEdge(evmax,Lvmax,F,tol);
+      B.UpdateEdge(evmax,Lvmax,F,vmaxTol);
       B.Degenerated(evmax,Dvmax);
       if (!umininf) {
 	V01.Orientation(TopAbs_FORWARD);
@@ -748,7 +767,7 @@ void  BRepLib_MakeFace::Init(const Handle(Geom_Surface)& SS,
     // Les Isos sont Approximees a Precision::Approximation()
     // et on code Precision::Confusion() dans l'arete.
     // ==> Un petit passage dans SamePrameter pour regler les tolerances.
-    BRepLib::SameParameter( F, tol, Standard_True);
+    BRepLib::SameParameter(F, Precision::Confusion(), Standard_True);
   }
 
   Done();
diff --git a/src/BRepMAT2d/BRepMAT2d_Explorer.cxx b/src/BRepMAT2d/BRepMAT2d_Explorer.cxx
index ba6ed59..6cefcd4 100644
--- a/src/BRepMAT2d/BRepMAT2d_Explorer.cxx
+++ b/src/BRepMAT2d/BRepMAT2d_Explorer.cxx
@@ -71,7 +71,7 @@ void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
   TopExp_Explorer Exp (F,TopAbs_WIRE);
 //  Modified by Sergey KHROMOV - Tue Nov 26 16:10:37 2002 Begin
   Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F);
-  TopoDS_Face          aNewF = BRepBuilderAPI_MakeFace(aSurf);
+  TopoDS_Face          aNewF = BRepBuilderAPI_MakeFace(aSurf, Precision::Confusion());
 
   while (Exp.More()) {
     Add (TopoDS::Wire (Exp.Current()),F, aNewF);
diff --git a/src/BRepMesh/BRepMesh.cdl b/src/BRepMesh/BRepMesh.cdl
index c9313d3..aac323b 100644
--- a/src/BRepMesh/BRepMesh.cdl
+++ b/src/BRepMesh/BRepMesh.cdl
@@ -32,7 +32,8 @@ uses    Standard,
         GeomAbs,
         GeomAdaptor,
         TopLoc,
-        SortTools
+        SortTools,
+        Plugin
 
 
 is    enumeration DegreeOfFreedom is 
@@ -75,6 +76,11 @@ is    enumeration DegreeOfFreedom is
       imported PairOfIndex from BRepMesh;
       imported CircleInspector from BRepMesh;
       imported CellFilter from BRepMesh;
+      imported VertexInspector from BRepMesh;
+      imported VertexCellFilter from BRepMesh;
+      imported VectorOfVertex from BRepMesh;
+
+      primitive PluginEntryType;
 
       class ComparatorOfVertexOfDelaun;
       class ComparatorOfIndexedVertexOfDelaun;
@@ -82,7 +88,8 @@ is    enumeration DegreeOfFreedom is
       class Delaun;
       class DataStructureOfDelaun;
       class CircleTool;
-
+      class VertexTool;
+    
       class Array1OfVertexOfDelaun instantiates Array1 from TCollection
         (Vertex from BRepMesh);
 
@@ -104,6 +111,9 @@ is    enumeration DegreeOfFreedom is
       class ElemHasherOfDataStructureOfDelaun instantiates MapHasher from TCollection
         (Triangle from BRepMesh);
 
+      class DataMapOfIntegerListOfInteger     instantiates DataMap from TCollection
+        (Integer from Standard, ListOfInteger from BRepMesh, MapIntegerHasher from TColStd);
+
       class IDMapOfNodeOfDataStructureOfDelaun  instantiates IndexedDataMap from TCollection
         (Vertex from BRepMesh,
         ListOfInteger from BRepMesh,
diff --git a/src/BRepMesh/BRepMesh_BaseAllocator.hxx b/src/BRepMesh/BRepMesh_BaseAllocator.hxx
deleted file mode 100644
index ad57a04..0000000
--- a/src/BRepMesh/BRepMesh_BaseAllocator.hxx
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <NCollection_IncAllocator.hxx>
-
-typedef Handle_NCollection_IncAllocator BRepMesh_BaseAllocator;
diff --git a/src/BRepMesh/BRepMesh_CMPLRS.edl b/src/BRepMesh/BRepMesh_CMPLRS.edl
new file mode 100644
index 0000000..f153f24
--- /dev/null
+++ b/src/BRepMesh/BRepMesh_CMPLRS.edl
@@ -0,0 +1,9 @@
+ at ifnotdefined (%BRepMesh_CMPLRS_EDL) then
+
+ at set %BRepMesh_CMPLRS_EDL="";
+
+ at if ( %Station != "sun" ) then
+  @string %CMPLRS_CXX_INCLUDE = %CMPLRS_CXX_INCLUDE %CSF_TBB_INCLUDES;
+ at endif;
+
+ at endif;
diff --git a/src/BRepMesh/BRepMesh_CellFilter.hxx b/src/BRepMesh/BRepMesh_CellFilter.hxx
deleted file mode 100644
index 1edc138..0000000
--- a/src/BRepMesh/BRepMesh_CellFilter.hxx
+++ /dev/null
@@ -1,20 +0,0 @@
-// File:        BRepMesh_CellFilter.hxx
-// Created:     May 26 16:40:53 2008
-// Author:      Ekaterina SMIRNOVA
-// Copyright:   Open CASCADE SAS 2008
-
-
-#include <gp_XYZ.hxx>
-#include <gp_XY.hxx>
-#include <NCollection_CellFilter.hxx>
-#include <BRepMesh_CircleInspector.hxx>
-
-typedef NCollection_CellFilter<BRepMesh_CircleInspector> BRepMesh_CellFilter;
-
-#ifdef __BORLANDC__
-  // definition of global functions is needed for map
-  Standard_Integer HashCode (const NCollection_CellFilter<BRepMesh_CircleInspector>::Cell &aCell, const Standard_Integer theUpper)
-  { return aCell.HashCode(theUpper); }
-  Standard_Boolean IsEqual (const NCollection_CellFilter<BRepMesh_CircleInspector>::Cell &aCell1, const NCollection_CellFilter<BRepMesh_CircleInspector>::Cell &aCell2)
-  { return aCell1.IsEqual(aCell2); }
-#endif
diff --git a/src/BRepMesh/BRepMesh_Circ.lxx b/src/BRepMesh/BRepMesh_Circ.lxx
deleted file mode 100644
index c80633f..0000000
--- a/src/BRepMesh/BRepMesh_Circ.lxx
+++ /dev/null
@@ -1,10 +0,0 @@
-// File:        BRepMesh_Circ.lxx
-// Created:     Mon Aug  9 17:46:36 1993
-// Author:      Didier PIFFAULT
-//              <dpf at zerox>
-
-inline const gp_XY& BRepMesh_Circ::Location() const
-{ return location;}
-
-inline const Standard_Real& BRepMesh_Circ::Radius() const
-{ return radius;}
diff --git a/src/BRepMesh/BRepMesh_CircleInspector.hxx b/src/BRepMesh/BRepMesh_CircleInspector.hxx
deleted file mode 100644
index d20f1fc..0000000
--- a/src/BRepMesh/BRepMesh_CircleInspector.hxx
+++ /dev/null
@@ -1,84 +0,0 @@
-// File:        BRepMesh_CircleInspector.hxx
-// Created:     May 26 16:40:53 2008
-// Author:      Ekaterina SMIRNOVA
-// Copyright:   Open CASCADE SAS 2008
-
-
-#ifndef BRepMesh_CircleInspector_Header
-#define BRepMesh_CircleInspector_Header
-
-#include <BRepMesh_Circ.hxx>
-
-#include <BRepMesh_ListOfInteger.hxx>
-#include <Precision.hxx>
-#include <gp_XY.hxx>
-#include <gp_XYZ.hxx>
-
-#include <NCollection_CellFilter.hxx>
-#include <NCollection_Vector.hxx>
-
-typedef NCollection_Vector<BRepMesh_Circ> CircVector;
-
-//=======================================================================
-//! The class to find in the coincidence points 
-//=======================================================================
-
-class BRepMesh_CircleInspector : public NCollection_CellFilter_InspectorXY
-{
-public:
-  typedef Standard_Integer Target;
-  //! Constructor; remembers tolerance and collector data structure.
-  //! All the found points are put in the map and excluded from further
-  //! consideration.
-  BRepMesh_CircleInspector (Standard_Real theTol,
-    Standard_Integer nbComp,
-    const BRepMesh_BaseAllocator& theAlloc);
-
-  void Add(Standard_Integer theInd,const BRepMesh_Circ& theCircle)
-  {
-    myInitCircle.SetValue(theInd, theCircle);
-  }
-
-  void ClerResList()
-  {
-    myResInd.Clear();
-  }
-
-  CircVector& MapOfCirc()
-  {
-    return myInitCircle; 
-  }
-
-  BRepMesh_Circ& GetCirc(Standard_Integer theInd)
-  {
-    return myInitCircle(theInd);
-  }
-
-  //! Set current node to be checked
-  void SetCurrent (const gp_XY& theCurCircle) 
-  { 
-    myCurrent = theCurCircle;
-  }
-
-  //!Get result index of node
-  BRepMesh_ListOfInteger& GetCoincidentInd()
-  {
-    return myResInd;
-  }
-
-  //! Implementation of inspection method
-  NCollection_CellFilter_Action Inspect (const Standard_Integer theTarget); 
-
-  static Standard_Boolean IsEqual (Standard_Integer theIdx, const Standard_Integer theTarget)
-  {
-    return (theIdx == theTarget);
-  }
-
-private:
-  Standard_Real                        myTol;
-  BRepMesh_ListOfInteger               myResInd;
-  CircVector                           myInitCircle;
-  gp_XY                                myCurrent;
-};
-
-#endif
diff --git a/src/BRepMesh/BRepMesh_Classifier.cdl b/src/BRepMesh/BRepMesh_Classifier.cdl
index 886c2e0..e5b71ad 100644
--- a/src/BRepMesh/BRepMesh_Classifier.cdl
+++ b/src/BRepMesh/BRepMesh_Classifier.cdl
@@ -27,15 +27,6 @@ is
     	      Tol    : Real                          from Standard;
     	      edges  : DataMapOfShapePairOfPolygon   from BRepMesh;
        	      themap : IndexedMapOfInteger           from TColStd;
-    	      Str    : IndexedMapOfVertex            from BRepMesh;
-    	      Umin, Umax, Vmin, Vmax: Real           from Standard)
-    returns Classifier from BRepMesh;
-    
-    
-    Create   (F      : Face                          from TopoDS; 
-    	      Tol    : Real                          from Standard;
-    	      edges  : DataMapOfShapePairOfPolygon   from BRepMesh;
-       	      themap : IndexedMapOfInteger           from TColStd;
     	      Str    : DataStructureOfDelaun         from BRepMesh;
     	      Umin, Umax, Vmin, Vmax: Real           from Standard)
     returns Classifier from BRepMesh;
@@ -49,10 +40,6 @@ is
     returns Status from BRepMesh;
         ---C++: inline
 
-    NaturalRestriction(me)
-    returns Boolean from Standard;
-        ---C++: inline
-
 
     Destroy(me: in out);
     	---C++: alias ~
@@ -76,6 +63,5 @@ fields
     U2          : Real              from Standard;
     V2          : Real              from Standard;
     myState     : Status            from BRepMesh;
-    isnatural   : Boolean           from Standard;
 
 end Classifier from BRepMesh;
diff --git a/src/BRepMesh/BRepMesh_Classifier.cxx b/src/BRepMesh/BRepMesh_Classifier.cxx
index f20a01b..c010807 100644
--- a/src/BRepMesh/BRepMesh_Classifier.cxx
+++ b/src/BRepMesh/BRepMesh_Classifier.cxx
@@ -88,8 +88,8 @@ static Standard_Boolean IsLine(const Handle(Geom2d_Curve)& C2d)
 //=======================================================================
 
 void BRepMesh_Classifier::AnalizeWire (const TColgp_SequenceOfPnt2d&  theSeqPnt2d,
-				       const Standard_Real Umin,  const Standard_Real Umax,
-				       const Standard_Real Vmin,  const Standard_Real Vmax)
+                                       const Standard_Real Umin,  const Standard_Real Umax,
+                                       const Standard_Real Vmin,  const Standard_Real Vmax)
 {
   const Standard_Integer nbpnts = theSeqPnt2d.Length();
   if (nbpnts < 2) return;
@@ -135,355 +135,273 @@ void BRepMesh_Classifier::AnalizeWire (const TColgp_SequenceOfPnt2d&  theSeqPnt2
 }
 
 //=======================================================================
-//function : BRepMesh_Classifier
-//purpose  : 
+//function : triangle2Area
+//purpose  : calculating area under triangle
 //=======================================================================
 
-BRepMesh_Classifier::BRepMesh_Classifier(const TopoDS_Face& aFace,
-					 const Standard_Real TolUV,
-					 const BRepMesh_DataMapOfShapePairOfPolygon& edges,
-					 const TColStd_IndexedMapOfInteger& themap,
-					 const BRepMesh_IndexedMapOfVertex& Str,
-					 const Standard_Real Umin,
-					 const Standard_Real Umax,
-					 const Standard_Real Vmin,
-					 const Standard_Real Vmax):
-					 Toluv(TolUV), Face(aFace),  
-					 myState(BRepMesh_NoError),
-					 isnatural(Standard_False)
-{ 
-  //-- impasse sur les surfs definies sur plus d une periode
+inline static Standard_Real triangle2Area(const gp_XY& p1, const gp_XY& p2)
+{
+  return p1.Crossed(p2);
+}
 
-  //-- once definition
-  Face.Orientation(TopAbs_FORWARD);
-  
-  TopoDS_Edge  edge;
-  BRepTools_WireExplorer WireExplorer;
-  //TopExp_Explorer FaceExplorer;
-  TopoDS_Iterator FaceExplorer;
+//=======================================================================
+//function : getSegmentParams
+//purpose  : extracting segment attributes 
+//=======================================================================
 
-  TColgp_SequenceOfPnt2d aWirePoints, aWire; 
-  TColStd_SequenceOfInteger aWireLength;
+static Standard_Real getSegmentParams(const BRepMesh_Array1OfBiPoint& theBiPoints,
+                                      const Standard_Integer Index,
+                                      Standard_Real& x11,
+                                      Standard_Real& y11,
+                                      Standard_Real& x12,
+                                      Standard_Real& y12,
+                                      Standard_Real& A,
+                                      Standard_Real& B,
+                                      Standard_Real& C)
+{
+  Standard_Real *aCoordinates;
+  aCoordinates = ((Standard_Real*)(theBiPoints(Index).Coordinates()));
+  x11 =  aCoordinates[0];
+  y11 =  aCoordinates[1];
+  x12 =  aCoordinates[2];
+  y12 =  aCoordinates[3];
+  A   =  aCoordinates[5];
+  B   = -aCoordinates[4];
+  C   = - x11*A - y11*B;
+  return A*A+B*B;
+}
 
+//=======================================================================
+//function : checkWiresIntersection
+//purpose  : finding intersection.
+//           If the intersection is found return Standard_True
+//=======================================================================
 
-  //-- twice definitions
-  TopAbs_Orientation anOr = TopAbs_FORWARD;
-  Standard_Boolean falsewire = Standard_False;
-  Standard_Integer i, index, firstindex = 0, lastindex = 0, nbedges = 0;
-#ifdef DEB_MESH
-  debwire = 0;
-#endif
+static Standard_Boolean checkWiresIntersection(const Standard_Integer            theFirstWireId,
+                                              const Standard_Integer            theSecondWireId,
+                                              Standard_Integer* const           theFirstOuterSegmentId,
+                                              Standard_Integer                  theLastOuterSegmentId,
+                                              const TColStd_SequenceOfInteger&  theWireLength,
+                                              const BRepMesh_Array1OfBiPoint&   theBiPoints,
+                                              const Standard_Boolean            findNextIntersection   = Standard_False,
+                                              const Standard_Boolean            isFirstSegment         = Standard_False,
+                                              Standard_Integer* const           theFirstInnerSegmentId = 0)
+{
+  Standard_Real A1, B1, C1, A2, B2, C2, AB, BC, CA, xc, yc;
+  Standard_Real  mu1, d, mu2;
+  Standard_Integer ik = *theFirstOuterSegmentId, jk;
+  Standard_Real x11, x12, y11, y12, x21, x22, y21, y22;
 
-  for(FaceExplorer.Initialize(Face); FaceExplorer.More(); FaceExplorer.Next())
+  // Calculate bounds for first wire
+  Standard_Integer ikEnd = theLastOuterSegmentId;
+  Standard_Boolean isFirst = Standard_True;
+  if ( findNextIntersection )
   {
-#ifdef DEB_MESH
-    if (debclass) { debwire++;  cout <<endl;  cout << "#wire no "<<debwire; debedge = 0;}
-#endif
-    if(FaceExplorer.Value().ShapeType() != TopAbs_WIRE)
-      continue;
-    // For each wire we create a data map, linking vertices (only
-    // the ends of edges) with their positions in the sequence of
-    // all 2d points from this wire.
-    // When we meet some vertex for the second time - the piece
-    // of sequence is treated for a HOLE and quits the sequence.
-    // Actually, we must unbind the vertices belonging to the
-    // loop from the map, but since they can't appear twice on the
-    // valid wire, leave them for a little speed up.
-    nbedges = 0;
-    TColgp_SequenceOfPnt2d SeqPnt2d;
-    TColStd_DataMapOfIntegerInteger NodeInSeq;
-    // Start traversing the wire
-    for (WireExplorer.Init(TopoDS::Wire(FaceExplorer.Value()),Face); WireExplorer.More(); WireExplorer.Next())
-    {
-      edge = WireExplorer.Current();
-#ifdef DEB_MESH
-      if (debclass) { debedge++; cout << endl; cout << "#edge no "<<debedge <<endl;}
-#endif
-      anOr = edge.Orientation();
-      if (anOr != TopAbs_FORWARD && anOr != TopAbs_REVERSED) continue;
-      if (edges.IsBound(edge))
-      {
-        // Retrieve polygon
-	// Define the direction for adding points to SeqPnt2d
-	Standard_Integer iFirst,iLast,iIncr;
-	const BRepMesh_PairOfPolygon& pair = edges.Find(edge);
-	Handle(Poly_PolygonOnTriangulation) NOD;
-        if (anOr == TopAbs_FORWARD)
-        {
-	  NOD = pair.First();
-	  iFirst = 1;
-          iLast  = NOD->NbNodes();
-          iIncr  = 1;
-        }
-        else
-        {
-	  NOD = pair.Last();
-	  iFirst = NOD->NbNodes();
-          iLast  = 1;
-          iIncr  = -1;
-        }
-	const TColStd_Array1OfInteger& indices = NOD->Nodes();
-
-	// indexFirst and nodeLast are the indices of first and last
-	// vertices of the edge in IndexedMap <Str>
-	const Standard_Integer indexFirst = themap.FindKey(indices(iFirst));
-	const Standard_Integer indexLast = themap.FindKey(indices(iLast));
-
-	// Skip degenerated edge : OCC481(apo)
-	if (indexLast == indexFirst && (iLast-iFirst) == iIncr) continue;
-
-	// If there's a gap between edges -> raise <falsewire> flag
-	if (nbedges)
-        {
-          if (indexFirst != lastindex)
-          {
-            falsewire = Standard_True; 
-            break;
-          }
-	}
-	else firstindex = indexFirst;
-        lastindex = indexLast;
+    isFirst = isFirstSegment;
+  }
 
-	// Record first vertex (to detect loops)
-	NodeInSeq.Bind(indexFirst,SeqPnt2d.Length()+1);
+  // Calculate bounds for second wire
+  Standard_Integer jkStart = 0, jkEnd = 0;
+  for (jk = 1; jk <= theSecondWireId; jk++)
+  {
+    jkStart = jkEnd + 1;
+    jkEnd  += theWireLength(jk);
+  }
 
-	// Add vertices in sequence
-        for (i = iFirst; i != iLast; i += iIncr)
-        {
-          index = (i == iFirst)? indexFirst : themap.FindKey(indices(i));
+  // total area under polygon (area of loop)
+  Standard_Real aLoopArea          = 0.0;
+  // area under first triangles of polygon
+  Standard_Real aFirstTriangleArea = 0.0;
+  // contains coordinates of the end point of segment if first intersection point is finding
+  // or coordinates of the intersecting point if second intersection point is finding
+  gp_XY aStartPoint;
 
-          gp_Pnt2d vp(Str(index).Coord());
-          SeqPnt2d.Append(vp);
-#ifdef DEB_MESH
-          if (debclass) cout<<"point p"<<index<<" "<<vp.X()<<" "<< vp.Y()<<endl;
-#endif
-        }
-
-	// Now, is there a loop?
-	if (NodeInSeq.IsBound(indexLast))
-        {
-	  // Yes, treat it separately as a hole
-	  // 1. Divide points into main wire and a loop
-	  const Standard_Integer iWireStart = NodeInSeq(indexLast);
-	  if(iWireStart < SeqPnt2d.Length()) {
-	    SeqPnt2d.Split(iWireStart, aWire);
-	    //OCC319->  the operation will be done later
-	    // 2. Proceed the loop
-	    //AnalizeWire(aLoop, Umin, Umax, Vmin, Vmax, aWirePoints, aWireLength, NbBiPoint);
-	    aWireLength.Append(aWire.Length());
-	    aWirePoints.Append(aWire);
-	    //<-OCC319
-	  }
-	}
-
-	nbedges++;
-      }
+  for (; ik <= ikEnd; ik++)
+  {
+    mu1 = getSegmentParams(theBiPoints, ik, x11, y11, x12, y12, A1, B1, C1);
+    // for second intersection point we must count the area from first intersection point 
+    if ( !findNextIntersection )
+    {
+      aLoopArea = 0.0;
+      aStartPoint.SetCoord(x12, y12);
     }
 
-    if (nbedges)
+    //for theFirstWireId == theSecondWireId the algorithm check current wire on selfintersection
+    if ( findNextIntersection && theFirstInnerSegmentId && isFirst)
     {
-      // Isn't it open?
-      if (falsewire || (firstindex != lastindex) || SeqPnt2d.Length() > 1)
-      { 
-	myState = BRepMesh_OpenWire; 
-	return;
-      }
+      jk = *theFirstInnerSegmentId;
     }
-    else
+    else if (theSecondWireId == theFirstWireId)
     {
-#ifdef DEB_MESH
-      cout <<"Warning : empty wire" <<endl;
-#endif      
+      jk = ik + 2;
     }
-  }
-
-  // Check natural restriction
-  const Standard_Integer nbwires = aWireLength.Length();
-  if (nbwires == 1 && nbedges == 4)
-  {
-    Handle(Geom2d_Curve) C2d;
-    Standard_Real pfbid, plbid;
-    isnatural = Standard_True;
-    for(FaceExplorer.Initialize(Face); FaceExplorer.More(); FaceExplorer.Next())
+    else
     {
-      if(FaceExplorer.Value().ShapeType() != TopAbs_WIRE)
-        continue;
-      TopoDS_Iterator aEdgeIt(FaceExplorer.Value());
-      for( ; aEdgeIt.More(); aEdgeIt.Next())
-      {
-        edge = TopoDS::Edge(aEdgeIt.Value());
-        if(anOr == TopAbs_FORWARD || anOr == TopAbs_REVERSED)
-        {
-          C2d = BRep_Tool::CurveOnSurface(edge,Face,pfbid,plbid);
-          //OCC316(APO): if(!IsLine(C2d)) { isnatural = Standard_False; break; }
-          if(!C2d.IsNull() && !IsLine(C2d)) { isnatural = Standard_False; break; }
-          else
-          { // sont-ce des isos:
-            gp_Pnt2d P1, P2;
-            C2d->D0(pfbid, P1);
-            C2d->D0(plbid, P2);
-            if ((Abs(P1.X()-P2.X()) > 1.e-04) && (Abs(P1.Y()-P2.Y()) > 1.e-04)) { isnatural = Standard_False; break; }
-          }
-        }
-      }
+      jk = jkStart;
     }
-  }
 
-  Standard_Integer NbBiPoint = aWirePoints.Length();
-  BRepMesh_Array1OfBiPoint BiPoints(0,NbBiPoint);
-
-  BRepMesh_BiPoint *BP;
-  Standard_Real *Coordinates1;
-  Standard_Real x1 = 0, y1 = 0, x2, y2, xstart = 0, ystart = 0;
-  Standard_Integer j, l = 1;
-  BP = &(BiPoints.ChangeValue(1));
-
-  // Fill array of segments (bi-points)
-  for (i = 1; i <= nbwires; i++)
-  {
-    const Standard_Integer len = aWireLength(i) + 1;
-    for (j = 1; j <= len; j++)
+    // Explore second wire
+    Standard_Boolean aFirstPass = Standard_True;
+    for (; jk <= jkEnd; jk++)
     {
-      // Obtain last point of the segment
-      if (j == len)
+      // don't check end's segment of the wire on selfrestriction
+      if ( theSecondWireId == theFirstWireId && isFirst && jk == ikEnd ) continue;
+
+      mu2 = getSegmentParams(theBiPoints, jk, x21, y21, x22, y22, A2, B2, C2);
+      gp_XY p2(x21, y21), p3(x22, y22);
+
+      //different segments may have common vertex (see OCC287 bug for example)
+      AB = A1*B2 - A2*B1;
+      //check on minimal of distance between current segment and points of another linear segments - OCC319
+      d = A1*x22 + B1*y22 + C1;
+      Standard_Real dTol = MIN_DIST*MIN_DIST;
+      if(theFirstWireId != theSecondWireId       && // if compared wires are different &&
+         AB*AB > PARALL_COND*PARALL_COND*mu1*mu2 && // angle between two segments greater then PARALL_COND &&
+         d*d   < dTol*mu1 &&             // distance between vertex of the segment and other one's less then MIN_DIST
+         (x22-x11)*(x22-x12) < 0.0 && (y22-y11)*(y22-y12) < 0.0)
       {
-        x2 = xstart;
-        y2 = ystart;
+        // if we finding the second intersection we must return Standard_False for setting
+        // self-intersection result flag
+        if ( findNextIntersection )
+          return Standard_False;
+
+        // we can step here when finding first intersection, return self-intersection flag
+        return Standard_True;
       }
-      else
+
+      if( aFirstPass )
       {
-        const gp_Pnt2d& PT = aWirePoints(l); l++;
-        x2 = PT.X();
-        y2 = PT.Y();
+        aFirstTriangleArea = triangle2Area(aStartPoint, p2);
       }
-      // Build segment (bi-point)
-      if (j == 1)
+      Standard_Real aTmpArea = triangle2Area(p2, p3);
+
+      //look for intersection of two linear segments
+      if(Abs(AB) <= RESOLUTION)
       {
-        xstart = x2;
-        ystart = y2;
+        aLoopArea += aTmpArea;
+        continue;  //current segments seem parallel - no intersection
       }
-      else
+      
+      //calculate coordinates of point of the intersection
+      BC = B1*C2 - B2*C1;  xc = BC/AB;
+      CA = C1*A2 - C2*A1;  yc = CA/AB;
+
+      // remember current intersection point and area of first triangle
+      if( findNextIntersection && ik == *theFirstOuterSegmentId && jk == *theFirstInnerSegmentId )
       {
-        Coordinates1 = ((Standard_Real*)(BP->Coordinates())); BP++;
-        Coordinates1[0] = x1;
-        Coordinates1[1] = y1;
-        Coordinates1[2] = x2;
-        Coordinates1[3] = y2;
-        Coordinates1[4] = x2 - x1;
-        Coordinates1[5] = y2 - y1;
+        aStartPoint.SetCoord(xc, yc);
+        continue;
       }
-      x1 = x2;
-      y1 = y2;
-    }
-  }
 
-  Standard_Real *Coordinates2;
-  Standard_Real A1, B1, C1, A2, B2, C2, AB, BC, CA, xc, yc;
-  Standard_Real  mu1, d, mu2;
-  Standard_Integer ik, ikEnd = 0, jk, jkEnd = 0;
-  Standard_Real x11, x12, y11, y12, x21, x22, y21, y22;
-  for(i = 1; i <= nbwires; i++)
-  {
-    ik = ikEnd + 1;  ikEnd += aWireLength(i);
-    // Explore first wire
-    for (; ik <= ikEnd; ik++)
-    {
-      Coordinates1 = ((Standard_Real*)(BiPoints.ChangeValue(ik).Coordinates()));
-      x11 = Coordinates1[0];
-      y11 = Coordinates1[1];
-      x12 = Coordinates1[2];
-      y12 = Coordinates1[3];
-      A1 =  Coordinates1[5];
-      B1 = -Coordinates1[4];
-      C1 = - x11*A1 - y11*B1;
-      //mu1 = Sqrt(A1*A1+B1*B1);
-      mu1 = A1*A1+B1*B1;
-      for (j = i; j <= nbwires; j++)
+      //check on belonging of intersection point to the both of segments
+      Standard_Boolean isOnLines = Standard_True;
+
+      Standard_Real dd[2][4] = { {(xc-x11), (xc-x12), (xc-x21), (xc-x22)},   //dX
+                                 {(yc-y11), (yc-y12), (yc-y21), (yc-y22)} }; //dY
+
+      Standard_Integer i = 0;
+      for(; i < 2; i++ )
       {
-        //for i==j the algorithm check current wire on selfintersection
-	if (j == i)
+        if ( dd[i][0]*dd[i][1] > dTol || dd[i][2]*dd[i][3] > dTol)
         {
-          jk = ik + 2;  jkEnd = ikEnd;
+          isOnLines = Standard_False;
+          break;
         }
-        else
+      }
+
+      // check the intersection point is on the ends of segments
+      if ( isOnLines )
+      {
+        for( i = 0; i < 2; i++ )
         {
-          jk = jkEnd + 1;  jkEnd = jk + aWireLength(j) - 1;
+          //     if it's the last segment and intersection point lies at the end
+          if ( ( jk == jkEnd                                              ||
+          //     dX                        && dY
+          //     or when the start or the end point of the first segment
+                (Abs(dd[0][0])  < MIN_DIST && Abs(dd[1][0])   < MIN_DIST) ||
+                (Abs(dd[0][1])  < MIN_DIST && Abs(dd[1][1])   < MIN_DIST)) &&
+          //     is equal to one of the end points of the second
+               (Abs(dd[0][i+2]) < MIN_DIST && Abs(dd[1][i+2]) < MIN_DIST))
+          {
+            // no intersection
+            isOnLines = Standard_False;
+            aLoopArea = aTmpArea = 0.0;
+            aFirstPass = Standard_True;
+            break;
+          }
         }
-        // Explore second wire
-	for (; jk <= jkEnd; jk++)
+      }
+
+
+      if( isOnLines )
+      {
+        p3.SetX(xc); p3.SetY(yc); 
+        aLoopArea += aFirstTriangleArea;             // First triangle area
+        aLoopArea += triangle2Area(p2, p3); 
+        aLoopArea += triangle2Area(p3, aStartPoint); // Last triangle area
+
+        if( Abs(aLoopArea)/2 > PI*MIN_DIST )
         {
-          // don't check end's segment of the wire on selfrestriction
-	  if (jk == ikEnd) continue;
-	  Coordinates2 = ((Standard_Real*)(BiPoints.ChangeValue(jk).Coordinates()));
-	  x21 = Coordinates2[0];
-          y21 = Coordinates2[1];
-          x22 = Coordinates2[2];
-          y22 = Coordinates2[3];
-	  A2 =  Coordinates2[5];
-          B2 = -Coordinates2[4];
-          C2 = - x21*A2 - y21*B2;
-	  //mu2 = Sqrt(A2*A2+B2*B2);
-          mu2 = A2*A2+B2*B2;
-	  //different segments may have common vertex (see OCC287 bug for example)
-	  //if(x22 == x11 && y22 == y11){ myState = BRepMesh_OpenWire;  return;}
-	  AB = A1*B2 - A2*B1;
-	  //check on minimal of distance between current segment and points of another linear segments - OCC319
-	  //d = Abs(A1*x22 + B1*y22 + C1);
-          d = A1*x22 + B1*y22 + C1;
-	  if(i != j &&                        // if compared wires are different &&
-	     AB*AB > PARALL_COND*PARALL_COND*mu1*mu2 && // angle between two segments greater then PARALL_COND &&
-	     d*d < MIN_DIST*MIN_DIST*mu1 &&              // distance between vertex of the segment and other one's less then MIN_DIST
-	     (x22-x11)*(x22-x12) < 0.0 && (y22-y11)*(y22-y12) < 0.0)
+          if ( findNextIntersection )
           {
-	    myState = BRepMesh_SelfIntersectingWire;  return;
-	  }
-	  //look for intersection of two linear segments
-	  if(Abs(AB) <= RESOLUTION) continue;  //current segments seem parallel - no intersection
-	  //calculate coordinates of point of the intersection
-	  BC = B1*C2 - B2*C1;  xc = BC/AB;
-	  CA = C1*A2 - C2*A1;  yc = CA/AB;
-          if( Abs(xc-x11) > RESOLUTION && Abs(xc-x12) > RESOLUTION &&
-              Abs(yc-y11) > RESOLUTION && Abs(yc-y12) > RESOLUTION &&
-              Abs(xc-x21) > RESOLUTION && Abs(xc-x22) > RESOLUTION &&
-              Abs(yc-y21) > RESOLUTION && Abs(yc-y22) > RESOLUTION )
+            // intersection is found, but Standard_False returns, because area is too much
+            return Standard_False;
+          }
+
+          if ( checkWiresIntersection(theFirstWireId, theSecondWireId, &ik, ikEnd, theWireLength,
+                           theBiPoints, Standard_True, isFirst, &jk) )
           {
-	    //check on belonging of intersection point to the both of segments
-	    if((xc-x11)*(xc-x12) < 0.0 && (yc-y11)*(yc-y12) < 0.0 &&
-	       (xc-x21)*(xc-x22) < 0.0 && (yc-y21)*(yc-y22) < 0.0)
-            {
-	      //different segments may have common vertex (why "<" but "<=")
-	      myState = BRepMesh_SelfIntersectingWire;  return;
-            }
-	  }
+            // small crossing is not intersection, continue cheching
+            aLoopArea = aTmpArea = 0.0;
+            aFirstPass = Standard_True;
+          }
+          else
+          {
+            // if we found only one intersection
+            return Standard_True;
+          }
+        }
+        else if ( findNextIntersection )
+        {
+          // small intersection, skip double checking
+          *theFirstOuterSegmentId = ik;
+          *theFirstInnerSegmentId = jk + 1;
+          return Standard_True;
         }
       }
-    }
-  }
+      if ( aFirstPass )
+      {
+        aFirstPass = Standard_False;
+      }
 
-  // Find holes
-  for (i = nbwires; i >= 1; i--)
-  {
-    NbBiPoint = aWirePoints.Length() - aWireLength(i) + 1;
-    aWirePoints.Split(NbBiPoint, aWire);
-    AnalizeWire(aWire, Umin, Umax, Vmin, Vmax);
+      aLoopArea += aTmpArea;
+    }
+    
+    if ( isFirst )
+    {
+      isFirst = Standard_False;
+    }
   }
+  return Standard_False;
 }
 
 
-//Wind code duplication
+//=======================================================================
+//function : BRepMesh_Classifier
+//purpose  : 
+//=======================================================================
 
 BRepMesh_Classifier::BRepMesh_Classifier(const TopoDS_Face& aFace,
-					 const Standard_Real TolUV,
-					 const BRepMesh_DataMapOfShapePairOfPolygon& edges,
-					 const TColStd_IndexedMapOfInteger& themap,
-					 const Handle(BRepMesh_DataStructureOfDelaun)& Str,
-					 const Standard_Real Umin,
-					 const Standard_Real Umax,
-					 const Standard_Real Vmin,
-					 const Standard_Real Vmax):
-					 Toluv(TolUV), Face(aFace),
-					 myState(BRepMesh_NoError),
-					 isnatural(Standard_False)
+                                         const Standard_Real TolUV,
+                                         const BRepMesh_DataMapOfShapePairOfPolygon& edges,
+                                         const TColStd_IndexedMapOfInteger& themap,
+                                         const Handle(BRepMesh_DataStructureOfDelaun)& Str,
+                                         const Standard_Real Umin,
+                                         const Standard_Real Umax,
+                                         const Standard_Real Vmin,
+                                         const Standard_Real Vmax):
+                                         Toluv(TolUV), Face(aFace),
+                                         myState(BRepMesh_NoError)
 {
   //-- impasse sur les surfs definies sur plus d une periode
 
@@ -537,50 +455,50 @@ BRepMesh_Classifier::BRepMesh_Classifier(const TopoDS_Face& aFace,
       if (edges.IsBound(edge))
       {
         // Retrieve polygon
-	// Define the direction for adding points to SeqPnt2d
-	Standard_Integer iFirst,iLast,iIncr;
-	const BRepMesh_PairOfPolygon& pair = edges.Find(edge);
-	Handle(Poly_PolygonOnTriangulation) NOD;
+        // Define the direction for adding points to SeqPnt2d
+        Standard_Integer iFirst,iLast,iIncr;
+        const BRepMesh_PairOfPolygon& pair = edges.Find(edge);
+        Handle(Poly_PolygonOnTriangulation) NOD;
         if (anOr == TopAbs_FORWARD)
         {
-	  NOD = pair.First();
-	  iFirst = 1;
+          NOD = pair.First();
+          iFirst = 1;
           iLast  = NOD->NbNodes();
           iIncr  = 1;
         }
         else
         {
-	  NOD = pair.Last();
-	  iFirst = NOD->NbNodes();
+          NOD = pair.Last();
+          iFirst = NOD->NbNodes();
           iLast  = 1;
           iIncr  = -1;
         }
-	const TColStd_Array1OfInteger& indices = NOD->Nodes();
+        const TColStd_Array1OfInteger& indices = NOD->Nodes();
 
-	// indexFirst and nodeLast are the indices of first and last
-	// vertices of the edge in IndexedMap <Str>
-	const Standard_Integer indexFirst = themap.FindKey(indices(iFirst));
-	const Standard_Integer indexLast = themap.FindKey(indices(iLast));
+        // indexFirst and indexLast are the indices of first and last
+        // vertices of the edge in IndexedMap <Str>
+        const Standard_Integer indexFirst = themap.FindKey(indices(iFirst));
+        const Standard_Integer indexLast = themap.FindKey(indices(iLast));
 
-	// Skip degenerated edge : OCC481(apo)
-	if (indexLast == indexFirst && (iLast-iFirst) == iIncr) continue;
+        // Skip degenerated edge : OCC481(apo)
+        if (indexLast == indexFirst && (iLast-iFirst) == iIncr) continue;
 
-	// If there's a gap between edges -> raise <falsewire> flag
-	if (nbedges)
+        // If there's a gap between edges -> raise <falsewire> flag
+        if (nbedges)
         {
           if (indexFirst != lastindex)
           {
             falsewire = Standard_True;
             break;
           }
-	}
-	else firstindex = indexFirst;
-        lastindex = indexLast;
+        }
+        else firstindex = indexFirst;
+              lastindex = indexLast;
 
-	// Record first vertex (to detect loops)
-	NodeInSeq.Bind(indexFirst,SeqPnt2d.Length()+1);
+        // Record first vertex (to detect loops)
+        NodeInSeq.Bind(indexFirst,SeqPnt2d.Length()+1);
 
-	// Add vertices in sequence
+        // Add vertices in sequence
         for (i = iFirst; i != iLast; i += iIncr)
         {
           index = (i == iFirst)? indexFirst : themap.FindKey(indices(i));
@@ -592,24 +510,23 @@ BRepMesh_Classifier::BRepMesh_Classifier(const TopoDS_Face& aFace,
 #endif
         }
 
-	// Now, is there a loop?
-	if (NodeInSeq.IsBound(indexLast))
+        // Now, is there a loop?
+        if (NodeInSeq.IsBound(indexLast))
         {
-	  // Yes, treat it separately as a hole
-	  // 1. Divide points into main wire and a loop
-	  const Standard_Integer iWireStart = NodeInSeq(indexLast);
-	  if(iWireStart < SeqPnt2d.Length()) {
-	    SeqPnt2d.Split(iWireStart, aWire);
-	    //OCC319->  the operation will be done later
-	    // 2. Proceed the loop
-	    //AnalizeWire(aLoop, Umin, Umax, Vmin, Vmax, aWirePoints, aWireLength, NbBiPoint);
-	    aWireLength.Append(aWire.Length());
-	    aWirePoints.Append(aWire);
-	    //<-OCC319
-	  }
-	}
-
-	nbedges++;
+          // Yes, treat it separately as a hole
+          // 1. Divide points into main wire and a loop
+          const Standard_Integer iWireStart = NodeInSeq(indexLast);
+          if(iWireStart < SeqPnt2d.Length()) {
+            SeqPnt2d.Split(iWireStart, aWire);
+            //OCC319->  the operation will be done later
+            // 2. Proceed the loop
+            //AnalizeWire(aLoop, Umin, Umax, Vmin, Vmax, aWirePoints, aWireLength, NbBiPoint);
+            aWireLength.Append(aWire.Length());
+            aWirePoints.Append(aWire);
+            //<-OCC319
+          }
+        }
+        nbedges++;
       }
     }
 
@@ -618,8 +535,8 @@ BRepMesh_Classifier::BRepMesh_Classifier(const TopoDS_Face& aFace,
       // Isn't it open?
       if (falsewire || (firstindex != lastindex) || SeqPnt2d.Length() > 1)
       {
-	myState = BRepMesh_OpenWire;
-	return;
+        myState = BRepMesh_OpenWire;
+        return;
       }
     }
     else
@@ -630,38 +547,7 @@ BRepMesh_Classifier::BRepMesh_Classifier(const TopoDS_Face& aFace,
     }
   }
 
-  // Check natural restriction
   const Standard_Integer nbwires = aWireLength.Length();
-  if (nbwires == 1 && nbedges == 4)
-  {
-    Handle(Geom2d_Curve) C2d;
-    Standard_Real pfbid, plbid;
-    isnatural = Standard_True;
-    for(FaceExplorer.Initialize(Face); FaceExplorer.More(); FaceExplorer.Next())
-    {
-      if(FaceExplorer.Value().ShapeType() != TopAbs_WIRE)
-        continue;
-      TopoDS_Iterator aEdgeIt(FaceExplorer.Value());
-      for( ; aEdgeIt.More(); aEdgeIt.Next())
-      {
-        edge = TopoDS::Edge(aEdgeIt.Value());
-        if(anOr == TopAbs_FORWARD || anOr == TopAbs_REVERSED)
-        {
-          C2d = BRep_Tool::CurveOnSurface(edge,Face,pfbid,plbid);
-          //OCC316(APO): if(!IsLine(C2d)) { isnatural = Standard_False; break; }
-          if(!C2d.IsNull() && !IsLine(C2d)) { isnatural = Standard_False; break; }
-          else
-          { // sont-ce des isos:
-            gp_Pnt2d P1, P2;
-            C2d->D0(pfbid, P1);
-            C2d->D0(plbid, P2);
-            if ((Abs(P1.X()-P2.X()) > 1.e-04) && (Abs(P1.Y()-P2.Y()) > 1.e-04)) { isnatural = Standard_False; break; }
-          }
-        }
-      }
-    }
-  }
-
   Standard_Integer NbBiPoint = aWirePoints.Length();
   BRepMesh_Array1OfBiPoint BiPoints(0,NbBiPoint);
 
@@ -710,85 +596,18 @@ BRepMesh_Classifier::BRepMesh_Classifier(const TopoDS_Face& aFace,
     }
   }
 
-  Standard_Real *Coordinates2;
-  Standard_Real A1, B1, C1, A2, B2, C2, AB, BC, CA, xc, yc;
-  Standard_Real  mu1, d, mu2;
-  Standard_Integer ik, ikEnd = 0, jk, jkEnd = 0;
-  Standard_Real x11, x12, y11, y12, x21, x22, y21, y22;
+  // Search the intersection
+  // Explore first wire
+  Standard_Integer ik, ikEnd = 0;
   for(i = 1; i <= nbwires; i++)
   {
     ik = ikEnd + 1;  ikEnd += aWireLength(i);
-    // Explore first wire
-    for (; ik <= ikEnd; ik++)
+    // Explore second wire
+    for (j = i; j <= nbwires; j++)
     {
-      Coordinates1 = ((Standard_Real*)(BiPoints.ChangeValue(ik).Coordinates()));
-      x11 = Coordinates1[0];
-      y11 = Coordinates1[1];
-      x12 = Coordinates1[2];
-      y12 = Coordinates1[3];
-      A1 =  Coordinates1[5];
-      B1 = -Coordinates1[4];
-      C1 = - x11*A1 - y11*B1;
-      //mu1 = Sqrt(A1*A1+B1*B1);
-      mu1 = A1*A1+B1*B1;
-      for (j = i; j <= nbwires; j++)
+      if ( checkWiresIntersection(i, j, &ik, ikEnd, aWireLength, BiPoints) )
       {
-        //for i==j the algorithm check current wire on selfintersection
-	if (j == i)
-        {
-          jk = ik + 2;  jkEnd = ikEnd;
-        }
-        else
-        {
-          jk = jkEnd + 1;  jkEnd = jk + aWireLength(j) - 1;
-        }
-        // Explore second wire
-	for (; jk <= jkEnd; jk++)
-        {
-          // don't check end's segment of the wire on selfrestriction
-	  if (jk == ikEnd) continue;
-	  Coordinates2 = ((Standard_Real*)(BiPoints.ChangeValue(jk).Coordinates()));
-	  x21 = Coordinates2[0];
-          y21 = Coordinates2[1];
-          x22 = Coordinates2[2];
-          y22 = Coordinates2[3];
-	  A2 =  Coordinates2[5];
-          B2 = -Coordinates2[4];
-          C2 = - x21*A2 - y21*B2;
-	  //mu2 = Sqrt(A2*A2+B2*B2);
-          mu2 = A2*A2+B2*B2;
-	  //different segments may have common vertex (see OCC287 bug for example)
-	  //if(x22 == x11 && y22 == y11){ myState = BRepMesh_OpenWire;  return;}
-	  AB = A1*B2 - A2*B1;
-	  //check on minimal of distance between current segment and points of another linear segments - OCC319
-	  //d = Abs(A1*x22 + B1*y22 + C1);
-          d = A1*x22 + B1*y22 + C1;
-	  if(i != j &&                        // if compared wires are different &&
-	     AB*AB > PARALL_COND*PARALL_COND*mu1*mu2 && // angle between two segments greater then PARALL_COND &&
-	     d*d < MIN_DIST*MIN_DIST*mu1 &&              // distance between vertex of the segment and other one's less then MIN_DIST
-	     (x22-x11)*(x22-x12) < 0.0 && (y22-y11)*(y22-y12) < 0.0)
-          {
-	    myState = BRepMesh_SelfIntersectingWire;  return;
-	  }
-	  //look for intersection of two linear segments
-	  if(Abs(AB) <= RESOLUTION) continue;  //current segments seem parallel - no intersection
-	  //calculate coordinates of point of the intersection
-	  BC = B1*C2 - B2*C1;  xc = BC/AB;
-	  CA = C1*A2 - C2*A1;  yc = CA/AB;
-	  //check on belonging of intersection point to the both of segments
-          if( Abs(xc-x11) > RESOLUTION && Abs(xc-x12) > RESOLUTION &&
-              Abs(yc-y11) > RESOLUTION && Abs(yc-y12) > RESOLUTION &&
-              Abs(xc-x21) > RESOLUTION && Abs(xc-x22) > RESOLUTION &&
-              Abs(yc-y21) > RESOLUTION && Abs(yc-y22) > RESOLUTION )
-          {
-            if((xc-x11)*(xc-x12) < 0.0 && (yc-y11)*(yc-y12) < 0.0 &&
-	      (xc-x21)*(xc-x22) < 0.0 && (yc-y21)*(yc-y22) < 0.0)
-            {
-	      //different segments may have common vertex (why "<" but "<=")
-	      myState = BRepMesh_SelfIntersectingWire;  return;
-	    }
-          }
-	}
+        myState = BRepMesh_SelfIntersectingWire; return;
       }
     }
   }
diff --git a/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cdl b/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cdl
index fe5c24d..65157e8 100644
--- a/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cdl
+++ b/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cdl
@@ -22,7 +22,7 @@ class DataStructureOfDelaun from BRepMesh inherits TShared from MMgt
               NodeHasherOfDataStructureOfDelaun from BRepMesh,
               LinkHasherOfDataStructureOfDelaun from BRepMesh,
               ElemHasherOfDataStructureOfDelaun from BRepMesh,
-              IDMapOfNodeOfDataStructureOfDelaun from BRepMesh,
+              VertexTool from BRepMesh,
               IDMapOfLinkOfDataStructureOfDelaun from BRepMesh,
               IMapOfElementOfDataStructureOfDelaun from BRepMesh,
               SelectorOfDataStructureOfDelaun from BRepMesh,
@@ -32,173 +32,171 @@ class DataStructureOfDelaun from BRepMesh inherits TShared from MMgt
 
   is          Create     (theAllocator: BaseAllocator from BRepMesh;
                           NodeNumber : Integer from Standard = 100)
-               ---Purpose: <NodeNumber>   is just  an   evaluation of the
-               --          presumed  number of nodes  in this mesh.   The
-               --          Mesh   data  structure will   be automatically
-               --          redimensioned if necessary.
-               returns mutable DataStructureOfDelaun from BRepMesh ;
+                ---Purpose: <NodeNumber>   is just  an   evaluation of the
+                --          presumed  number of nodes  in this mesh.   The
+                --          Mesh   data  structure will   be automatically
+                --          redimensioned if necessary.
+                returns mutable DataStructureOfDelaun from BRepMesh ;
 
-             AddNode    (me      : mutable ;
+              AddNode    (me      : mutable ;
                           theNode : Vertex from BRepMesh) 
-            returns Integer from Standard
-            ---Purpose: Adds a node to the  mesh  if  the node is  not
-            --          already in the Mesh.  Returns the index of the
-            --          node in the structure.
-            is static;
-
-          GetNode    (me      : mutable; 
-                      Index   : Integer from Standard)
-            returns Vertex from BRepMesh 
-            ---Purpose: Get the value of node <Index>.
-            ---C++:  return const &
-            ---C++:  alias operator ()
-            is static;
-
-          GetNodeList    (me      : mutable; 
+                returns Integer from Standard
+                ---Purpose: Adds a node to the  mesh  if  the node is  not
+                --          already in the Mesh.  Returns the index of the
+                --          node in the structure.
+                is static;
+
+              GetNode    (me      : mutable; 
                           Index   : Integer from Standard)
-            returns ListOfInteger from BRepMesh
-            ---Purpose: Get the list of node <Index>.
-            ---C++:  return const &
-            is static;
-
-          ForceRemoveNode (me    : mutable;
-                            Index : Integer from Standard) 
-          ---Purpose: Removes the node of index <index> from the mesh.
-          is static;
-
-        ForceRemoveLink (me    : mutable;
-                          Index : Integer from Standard) 
-          ---Purpose: Removes the link of index <index> from the mesh.
-          is static;
-
-        ReplaceNodes (me       : mutable;
-                      NewNodes : IDMapOfNodeOfDataStructureOfDelaun from BRepMesh) 
-             ---Purpose: Removes the all nodes and sets new map of 
-             -- nodes from the mesh.
-             -- For internal use only.
-             is static;
-
-           RemoveNode (me      : mutable;
-                        Index   : Integer from Standard) 
-            ---Purpose: Removes the node of index <index> from the mesh.
-            is static;
-
-          MoveNode   (me      : mutable ;
-                      Index   : Integer from Standard;
-                      newNode : Vertex from BRepMesh) 
-            ---Purpose: Changes the UV  value of node of index <Index>  by
-            --          <newNode>. Returns false if <newnode> is already in
-            --          the structure.
-            returns Boolean from Standard is static;
-
-          NbNodes        (me)
-            returns Integer from Standard
-            ---Purpose: Gives the number of nodes in this mesh.
-            is static;
-
-
-          AddLink    (me      : mutable;
-                      theLink : Edge from BRepMesh) 
-            returns Integer from Standard
-            ---Purpose: Adds a Link  to the  mesh if  the Link is  not
-            --          already in the structure. Returns the index of
-            --          the link in the structure.
-            is static;
-
-          GetLink    (me    : mutable; 
-                      Index : Integer from Standard)
-          returns Edge from BRepMesh 
-          ---Purpose: Get the value of Link <Index>.
-          ---C++: return const &
-          is static;
-
-        RemoveLink (me      : mutable;
-                    Index   : Integer from Standard) 
-            ---Purpose: Removes the Link of  index  <Index> from the
-            --          mesh.
-            is static;
-
-          SubstituteLink (me      : mutable ;
+                returns Vertex from BRepMesh 
+                ---Purpose: Get the value of node <Index>.
+                ---C++:  return const &
+                ---C++:  alias operator ()
+                is static;
+
+              GetNodeList    (me      : mutable; 
+                              Index   : Integer from Standard)
+                returns ListOfInteger from BRepMesh
+                ---Purpose: Get the list of node <Index>.
+                ---C++:  return const &
+                is static;
+
+              ForceRemoveNode (me    : mutable;
+                                Index : Integer from Standard) 
+              ---Purpose: Removes the node of index <index> from the mesh.
+              is static;
+
+              ForceRemoveLink (me    : mutable;
+                                Index : Integer from Standard) 
+                ---Purpose: Removes the link of index <index> from the mesh.
+                is static;
+
+              ReplaceNodes (me       : mutable;
+                            NewNodes : VertexTool from BRepMesh) 
+                ---Purpose: Removes the all nodes and sets new map of 
+                -- nodes from the mesh.
+                -- For internal use only.
+                is static;
+
+              RemoveNode (me      : mutable;
+                          Index   : Integer from Standard) 
+                ---Purpose: Removes the node of index <index> from the mesh.
+                is static;
+
+              MoveNode   (me      : mutable ;
                           Index   : Integer from Standard;
-                          newLink : Edge from BRepMesh) 
-            ---Purpose: Substitutes  the  Link  of  index  <Index>  by
-            --          <newLink> clear the connectivity.
-            returns Boolean from Standard is static;
-
-          NbLinks        (me)
-            returns Integer from Standard
-            ---Purpose: Gives the number of elements in this mesh.
-            is static;
-
-
-          AddElement     (me         : mutable;
-                          theElement : Triangle from BRepMesh) 
-               returns Integer from Standard
-               ---Purpose: Adds an element  to  the mesh  if it    is not
-               --          already in the  Mesh. Returns the index of the
-               --          element in the structure.
-               is static;
-
-             GetElement     (me    : mutable; 
-                              Index : Integer from Standard)
-          returns Triangle from BRepMesh
-          ---Purpose: Get the value of Element <Index>.
-          ---C++: return const &
-          is static;
+                          newNode : Vertex from BRepMesh) 
+                ---Purpose: Changes the UV  value of node of index <Index>  by
+                --          <newNode>. Returns false if <newnode> is already in
+                --          the structure.
+                returns Boolean from Standard is static;
+
+              NbNodes        (me)
+                returns Integer from Standard
+                ---Purpose: Gives the number of nodes in this mesh.
+                is static;
+
+
+              AddLink    (me      : mutable;
+                          theLink : Edge from BRepMesh) 
+                returns Integer from Standard
+                ---Purpose: Adds a Link  to the  mesh if  the Link is  not
+                --          already in the structure. Returns the index of
+                --          the link in the structure.
+                is static;
+
+              GetLink    (me    : mutable; 
+                          Index : Integer from Standard)
+              returns Edge from BRepMesh 
+                ---Purpose: Get the value of Link <Index>.
+                ---C++: return const &
+              is static;
 
-        RemoveElement  (me      : mutable;
-                        Index   : Integer from Standard) 
-            ---Purpose: Removes the element of index <Index> in the mesh.
-            is static;
+              RemoveLink (me      : mutable;
+                          Index   : Integer from Standard) 
+                ---Purpose: Removes the Link of  index  <Index> from the
+                --          mesh.
+                is static;
+
+              SubstituteLink (me      : mutable ;
+                              Index   : Integer from Standard;
+                              newLink : Edge from BRepMesh) 
+                ---Purpose: Substitutes  the  Link  of  index  <Index>  by
+                --          <newLink> clear the connectivity.
+                returns Boolean from Standard is static;
+
+              NbLinks        (me)
+                returns Integer from Standard
+                ---Purpose: Gives the number of elements in this mesh.
+                is static;
+
+
+              AddElement     (me         : mutable;
+                              theElement : Triangle from BRepMesh) 
+                returns Integer from Standard
+                ---Purpose: Adds an element  to  the mesh  if it    is not
+                --          already in the  Mesh. Returns the index of the
+                --          element in the structure.
+                is static;
+
+               GetElement     (me    : mutable; 
+                              Index : Integer from Standard)
+                returns Triangle from BRepMesh
+                ---Purpose: Get the value of Element <Index>.
+                ---C++: return const &
+                is static;
 
-          SubstituteElement  (me         : mutable ;
-                              Index      : Integer from Standard;
-                              newElement : Triangle from BRepMesh) 
-               ---Purpose: Substitutes  the  element   of  index  <Index>  by
-               --          <newElement>. The links connectivity is updated.
-               returns Boolean from Standard is static;
+              RemoveElement  (me      : mutable;
+                              Index   : Integer from Standard) 
+                ---Purpose: Removes the element of index <Index> in the mesh.
+                is static;
 
-             NbElements     (me)
-               returns Integer from Standard
-               ---Purpose: Gives the number of elements in this mesh.
-               is static;
+              SubstituteElement  (me         : mutable ;
+                                  Index      : Integer from Standard;
+                                  newElement : Triangle from BRepMesh) 
+                ---Purpose: Substitutes  the  element   of  index  <Index>  by
+                --          <newElement>. The links connectivity is updated.
+                returns Boolean from Standard is static;
 
+              NbElements     (me)
+                returns Integer from Standard
+                ---Purpose: Gives the number of elements in this mesh.
+                is static;
 
-             ClearDomain        (me         : mutable) 
-               ---Purpose:  Removes all elements
-               is static;
+              ClearDomain    (me         : mutable) 
+                ---Purpose:  Removes all elements
+                is static;
 
 
-             IndexOf        (me;
+              IndexOf        (me: mutable;
                               aNode : Vertex from BRepMesh)
-          ---Purpose: Finds the index of the node.  Returns 0 if the
-          --          node is not in the mesh.
-               returns Integer from Standard;
+                ---Purpose: Finds the index of the node.  Returns 0 if the
+                --          node is not in the mesh.
+                     returns Integer from Standard;
 
               IndexOf        (me;
                               aLink : Edge from BRepMesh)
-          ---Purpose: Finds the index of the Link.  Returns 0 if the
-          --          Link is not in the mesh.
+                ---Purpose: Finds the index of the Link.  Returns 0 if the
+                --          Link is not in the mesh.
                 returns Integer from Standard;
 
               IndexOf        (me;
                               anElement : Triangle from BRepMesh)
-              ---Purpose: Finds the index  of the Element.  Returns 0 if
-              --          the Element is not in the mesh.
+                ---Purpose: Finds the index  of the Element.  Returns 0 if
+                --          the Element is not in the mesh.
                 returns Integer from Standard;
 
-
-            LinkNeighboursOf (me;
-                              theNode         : in Integer from Standard)
-                    returns ListOfInteger from BRepMesh
-                    ---C++: return const &
-                    ---Purpose: Gives the list of  Link's indices handling the
-                    --          node <theNode>.
-                    is static;
+              LinkNeighboursOf (me;
+                                theNode         : in Integer from Standard)
+                returns ListOfInteger from BRepMesh
+                ---C++: return const &
+                ---Purpose: Gives the list of  Link's indices handling the
+                --          node <theNode>.
+                is static;
 
 
-                  ElemConnectedTo (me;
-                                   theLink     : in Integer from Standard)
+              ElemConnectedTo (me;
+                               theLink     : in Integer from Standard)
                 returns PairOfIndex from BRepMesh
                 ---C++: return const &
                 ---Purpose: Gives the element's indices conected
@@ -232,26 +230,30 @@ class DataStructureOfDelaun from BRepMesh inherits TShared from MMgt
               ClearElement   (me      : mutable;
                               Index   : Integer from Standard;
                               theElem : Triangle from BRepMesh) 
-            ---Purpose: Deletes  the element of  index <Index> in
-            --          the mesh. Used by RemoveElement.
+                ---Purpose: Deletes  the element of  index <Index> in
+                --          the mesh. Used by RemoveElement.
                 is static private;
 
-          Statistics     (me;
-                          flot  : in out OStream from Standard) 
-          ---Purpose: Give informations on map.
-          is static;
-
-        Allocator (me) returns BaseAllocator from BRepMesh;
-        ---C++: return const&
-
+              Statistics     (me;
+                              flot  : in out OStream from Standard) 
+                ---Purpose: Give informations on map.
+                is static;
 
-          fields      myNodes        : IDMapOfNodeOfDataStructureOfDelaun from BRepMesh;
-                      myDelNodes     : ListOfInteger from BRepMesh;
-                      myLinks        : IDMapOfLinkOfDataStructureOfDelaun from BRepMesh;
-                      myDelLinks     : ListOfInteger from BRepMesh;
-                      myElements     : IMapOfElementOfDataStructureOfDelaun from BRepMesh;
-                              --myDelElements  : ListOfInteger from BRepMesh;
-                      myElemOfDomain : MapOfInteger  from BRepMesh;
-                      myLinkOfDomain : MapOfInteger  from BRepMesh;
-                      myAllocator    : BaseAllocator from BRepMesh;
+              Allocator (me) returns BaseAllocator from BRepMesh;
+                ---C++: return const&
+              
+              Data (me: mutable) returns VertexTool from BRepMesh;
+                ---Purpose: Give the data structure for cell size and
+                --          tolerance initialization.
+                ---C++: return &
+
+
+  fields      myNodes        : VertexTool from BRepMesh;
+              myLinks        : IDMapOfLinkOfDataStructureOfDelaun from BRepMesh;
+              myDelLinks     : ListOfInteger from BRepMesh;
+              myElements     : IMapOfElementOfDataStructureOfDelaun from BRepMesh;
+                      --myDelElements  : ListOfInteger from BRepMesh;
+              myElemOfDomain : MapOfInteger  from BRepMesh;
+              myLinkOfDomain : MapOfInteger  from BRepMesh;
+              myAllocator    : BaseAllocator from BRepMesh;
 end DataStructureOfDelaun;
diff --git a/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx b/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx
index 1b454c3..6146b59 100644
--- a/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx
+++ b/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx
@@ -11,8 +11,7 @@
 //=======================================================================
 BRepMesh_DataStructureOfDelaun::BRepMesh_DataStructureOfDelaun(const BRepMesh_BaseAllocator& theAlloc,
                                                                const Standard_Integer NodeNumber)
-                                                               : myNodes(NodeNumber+3),
-                                                               myDelNodes(theAlloc),
+                                                               : myNodes(NodeNumber, theAlloc),
                                                                myLinks(NodeNumber*3),
                                                                myDelLinks(theAlloc),
                                                                myElements(NodeNumber*2),
@@ -29,23 +28,7 @@ BRepMesh_DataStructureOfDelaun::BRepMesh_DataStructureOfDelaun(const BRepMesh_Ba
 //=======================================================================
 Standard_Integer  BRepMesh_DataStructureOfDelaun::AddNode(const BRepMesh_Vertex& theNode)
 {
-  Standard_Integer NodeIndex=myNodes.FindIndex(theNode);
-  if (NodeIndex>0 && !myDelNodes.IsEmpty()) {
-    if (myNodes.FindKey(NodeIndex).Movability()==BRepMesh_Deleted)
-      NodeIndex=0;
-  }
-  if (NodeIndex<=0) {
-    BRepMesh_ListOfInteger thelist(myAllocator);
-    if (!myDelNodes.IsEmpty()) {
-      NodeIndex=myDelNodes.First();
-      myNodes.Substitute(NodeIndex, theNode, thelist);
-      myDelNodes.RemoveFirst();
-    }
-    else {
-      NodeIndex=myNodes.Add(theNode, thelist);
-    }
-  }
-  return NodeIndex;
+  return myNodes.Add(theNode);
 }
 
 //=======================================================================
@@ -72,14 +55,8 @@ const BRepMesh_ListOfInteger& BRepMesh_DataStructureOfDelaun::GetNodeList(const
 //=======================================================================
 void  BRepMesh_DataStructureOfDelaun::ForceRemoveNode(const Standard_Integer Index)
 {
-  //Warning, the static cast from const& to & is called for
-  //performance reasons. This is applicable only in case if later
-  //modification of element (field movability) does not influent on
-  //has calculation.
-  BRepMesh_Vertex& vref=(BRepMesh_Vertex&)myNodes.FindKey(Index);
   if ( myNodes.FindFromIndex(Index).Extent()==0) {
-    vref.SetMovability(BRepMesh_Deleted);
-    myDelNodes.Append(Index);
+    myNodes.Delete(Index);
   }
 }
 
@@ -87,14 +64,12 @@ void  BRepMesh_DataStructureOfDelaun::ForceRemoveNode(const Standard_Integer Ind
 //function : ReplaceNodes
 //purpose  : 
 //=======================================================================
-void  BRepMesh_DataStructureOfDelaun::ReplaceNodes(const BRepMesh_IDMapOfNodeOfDataStructureOfDelaun& NewNodes)
+void  BRepMesh_DataStructureOfDelaun::ReplaceNodes(const BRepMesh_VertexTool& NewNodes)
 {
-  if (NewNodes.IsEmpty() || NewNodes.Extent() != myNodes.Extent())
+  if ( NewNodes.IsEmpty() )
     return;
-  /*for (Standard_Integer i = 1; i <= myNodes.Extent(); i++)
-  ForceRemoveNode(i);*/
 
-  myNodes.Assign(NewNodes);
+  myNodes = NewNodes;
 }
 
 //=======================================================================
@@ -139,15 +114,9 @@ void  BRepMesh_DataStructureOfDelaun::ForceRemoveLink(const Standard_Integer Ind
 //=======================================================================
 void  BRepMesh_DataStructureOfDelaun::RemoveNode(const Standard_Integer Index)
 {
-  //Warning, the static cast from const& to & is called for
-  //performance reasons. This is applicable only in case if later
-  //modification of element (field movability) does not influent on
-  //has calculation.
-  BRepMesh_Vertex& vref=(BRepMesh_Vertex&)myNodes.FindKey(Index);
-  if (vref.Movability()==BRepMesh_Free &&
-    myNodes.FindFromIndex(Index).Extent()==0) {
-      vref.SetMovability(BRepMesh_Deleted);
-      myDelNodes.Append(Index);
+  if (myNodes.FindKey(Index).Movability() == BRepMesh_Free &&
+      myNodes.FindFromIndex(Index).Extent() == 0) {
+      myNodes.Delete(Index);
   }
 }
 
@@ -158,11 +127,8 @@ void  BRepMesh_DataStructureOfDelaun::RemoveNode(const Standard_Integer Index)
 Standard_Boolean BRepMesh_DataStructureOfDelaun::MoveNode(const Standard_Integer Index, 
                                                           const BRepMesh_Vertex& newNode)
 {
-  if (myNodes.FindIndex(newNode)==0) {
-    BRepMesh_Vertex vref(myNodes.FindKey(Index));
-    const BRepMesh_ListOfInteger& refLink=myNodes(Index);
-    vref.SetMovability(BRepMesh_Deleted);
-    myNodes.Substitute(Index, vref, refLink);
+  if (myNodes.FindIndex(newNode) == 0) {
+    const BRepMesh_ListOfInteger& refLink = myNodes(Index);
     myNodes.Substitute(Index, newNode, refLink);
     return Standard_True;
   }
@@ -452,7 +418,7 @@ Standard_Integer  BRepMesh_DataStructureOfDelaun::NbElements()const
 //function : IndexOf
 //purpose  : 
 //=======================================================================
-Standard_Integer BRepMesh_DataStructureOfDelaun::IndexOf(const BRepMesh_Vertex& aNode)const
+Standard_Integer BRepMesh_DataStructureOfDelaun::IndexOf(const BRepMesh_Vertex& aNode)
 {
   return myNodes.FindIndex(aNode);
 }
@@ -561,8 +527,7 @@ void BRepMesh_DataStructureOfDelaun::ClearDeleted()
   }
   */
 
-  // Traitement des Links 
-
+  // Process Links:
   lastNonDelItem=myLinks.Extent();
 
   while (!myDelLinks.IsEmpty()) {
@@ -573,10 +538,10 @@ void BRepMesh_DataStructureOfDelaun::ClearDeleted()
       lastNonDelItem--;
     }
 
-    IndexDelItem=myDelLinks.First();
+    IndexDelItem = myDelLinks.First();
     myDelLinks.RemoveFirst();
 
-    if (IndexDelItem<lastNonDelItem) {
+    if (IndexDelItem < lastNonDelItem) {
       BRepMesh_Edge lItem=myLinks.FindKey(lastNonDelItem);
       BRepMesh_PairOfIndex Data(myLinks(lastNonDelItem));
       myLinks.RemoveLast();
@@ -620,22 +585,22 @@ void BRepMesh_DataStructureOfDelaun::ClearDeleted()
   }
 
 
-  // Traitement des Nodes :
+  // Process Nodes:
+  lastNonDelItem = myNodes.Extent();
+  BRepMesh_ListOfInteger &aDelNodes = (BRepMesh_ListOfInteger &)myNodes.GetListOfDelNodes();
 
-  lastNonDelItem=myNodes.Extent();
-
-  while (!myDelNodes.IsEmpty()) {
-    while (lastNonDelItem>0) {
+  while (!aDelNodes.IsEmpty()) {
+    while (lastNonDelItem > 0) {
       if (myNodes.FindKey(lastNonDelItem).Movability()!=BRepMesh_Deleted)
         break;
       myNodes.RemoveLast();
       lastNonDelItem--;
     }
-    IndexDelItem=myDelNodes.First();
-    myDelNodes.RemoveFirst();
+    IndexDelItem = aDelNodes.First();
+    aDelNodes.RemoveFirst();
 
     if (IndexDelItem<lastNonDelItem) {
-      BRepMesh_Vertex nItem=myNodes.FindKey(lastNonDelItem);
+      BRepMesh_Vertex nItem = myNodes.FindKey(lastNonDelItem);
       BRepMesh_ListOfInteger Data;
       Data.Append(myNodes(lastNonDelItem));
       myNodes.RemoveLast();
@@ -666,7 +631,7 @@ void BRepMesh_DataStructureOfDelaun::Statistics(Standard_OStream& S) const
 {
   S << " Map de nodes : \n";
   myNodes.Statistics(S);
-  S << "\n Deleted nodes : " << myDelNodes.Extent() << endl;
+  S << "\n Deleted nodes : " << myNodes.GetListOfDelNodes().Extent() << endl;
 
   S << "\n\n Map de Links : \n";
   myLinks.Statistics(S);
@@ -685,3 +650,12 @@ const BRepMesh_BaseAllocator& BRepMesh_DataStructureOfDelaun::Allocator() const
 {
   return myAllocator;
 }
+
+//=======================================================================
+//function : Data
+//purpose  : 
+//=======================================================================
+BRepMesh_VertexTool& BRepMesh_DataStructureOfDelaun::Data()
+{
+  return myNodes;
+}
diff --git a/src/BRepMesh/BRepMesh_Delaun.cdl b/src/BRepMesh/BRepMesh_Delaun.cdl
index 70c20fd..e22c547 100644
--- a/src/BRepMesh/BRepMesh_Delaun.cdl
+++ b/src/BRepMesh/BRepMesh_Delaun.cdl
@@ -3,7 +3,7 @@
 -- Author:      Didier PIFFAULT
 --              <dpf at nonox>
 ---Copyright:	 Matra Datavision 1993, 1994 
-
+ 
 
 class Delaun from BRepMesh
 
@@ -33,115 +33,95 @@ class Delaun from BRepMesh
   is
   -- Interface :
 
-            Create         (Vertices  : in out Array1OfVertexOfDelaun from BRepMesh;
-                            ZPositive : in Boolean from Standard=Standard_True)
+          Create         (Vertices  : in out Array1OfVertexOfDelaun from BRepMesh;
+                          ZPositive : in Boolean from Standard=Standard_True)
               ---Purpose: Creates the  triangulation with an  empty Mesh
               --          data structure.
               returns Delaun from BRepMesh;
 
 
-            Create         (OldMesh   : mutable DataStructureOfDelaun from BRepMesh;
-                            Vertices  : in out Array1OfVertexOfDelaun from BRepMesh;
-                            ZPositive : in Boolean from Standard=Standard_True)
+          Create         (OldMesh   : mutable DataStructureOfDelaun from BRepMesh;
+                          Vertices  : in out Array1OfVertexOfDelaun from BRepMesh;
+                          ZPositive : in Boolean from Standard=Standard_True)
               ---Purpose: Creates  the triangulation with   and existant
               --          Mesh data structure.
               returns Delaun from BRepMesh;
 
 
-            Create         (OldMesh       : mutable DataStructureOfDelaun from BRepMesh;
-                            VertexIndices : in out Array1OfInteger from TColStd;
-                            ZPositive     : in Boolean from Standard=Standard_True)
+          Create         (OldMesh       : mutable DataStructureOfDelaun from BRepMesh;
+                          VertexIndices : in out Array1OfInteger from TColStd;
+                          ZPositive     : in Boolean from Standard=Standard_True)
                   ---Purpose: Creates  the triangulation with   and existant
                   --          Mesh data structure.
                   returns Delaun from BRepMesh;
 
 
-                AddVertex      (me            : in out;
-                                theVertex     : in Vertex from BRepMesh);
-                ---Purpose: Adds a new vertex in the triangulation.
-
-
-                  RemoveVertex   (me            : in out;
-                                  theVertex     : in Vertex from BRepMesh);
+          RemoveVertex   (me            : in out;
+                          theVertex     : in Vertex from BRepMesh);
                 ---Purpose: Removes a vertex in the triangulation.
 
 
-                  AddVertices    (me            : in out;
-                                  Vertices      : in out Array1OfVertexOfDelaun from BRepMesh);
+           AddVertices    (me            : in out;
+                           Vertices      : in out Array1OfVertexOfDelaun from BRepMesh);
                 ---Purpose: Adds some vertices in the triangulation.
 
 
-                  RevertDiagonal (me            : in out;
-                                  theEdge       : in Integer from Standard)
-                  ---Purpose: Substitutes the Edge beetween to  triangles by the
-                  --          other  diagonal  of  the  quadrilatere  if  it  is
-                  --          possible (convex polygon). Return True if done.
-                  returns Boolean from Standard;
-
-
-                UseEdge        (me            : in out;
-                                theEdge       : in Integer from Standard)
+           UseEdge        (me            : in out;
+                           theEdge       : in Integer from Standard)
                   ---Purpose: Modify mesh to use the edge. Return True if done.
                   returns Boolean from Standard;
 
 
-                SmoothMesh     (me            : in out;
-                                Epsilon       : in Real from Standard);
-                ---Purpose: Smooths the  mesh  in 2d space. The  method  is to
-                  --          move  the  free  and  OnSurface  vertices  at  the
-                  --          barycentre of their polygon.
-
-
-                  Result         (me)
+           Result         (me)
                   ---C++: return const &
                   ---Purpose: Gives the Mesh data structure.
                   returns DataStructureOfDelaun from BRepMesh;
 
 
-                Frontier       (me     : in out)
+           Frontier       (me     : in out)
                   ---Purpose: Gives the list of frontier edges
                   ---C++: return const &
                   returns MapOfInteger from BRepMesh;
 
 
-                InternalEdges  (me     : in out)
+           InternalEdges  (me     : in out)
                   ---Purpose: Gives the list of internal edges
                   ---C++: return const &
                   returns MapOfInteger from BRepMesh;
 
 
-                FreeEdges      (me     : in out)
+           FreeEdges      (me     : in out)
                   ---Purpose: Gives the list of free edges used only one time
                   ---C++: return const &
                   returns MapOfInteger from BRepMesh;
 
 
-                GetVertex      (me;
-                                vIndex : in Integer from Standard)
+           GetVertex      (me;
+                           vIndex : in Integer from Standard)
                  ---C++: return const &
                  ---C++: inline
                  returns Vertex from BRepMesh;
 
 
-         GetEdge        (me;
-                          eIndex : in Integer from Standard)
+           GetEdge        (me;
+                           eIndex : in Integer from Standard)
            ---C++: return const &
            ---C++: inline
            returns Edge from BRepMesh;
 
 
-         GetTriangle    (me;
-                          tIndex : in Integer from Standard)
+           GetTriangle    (me;
+                           tIndex : in Integer from Standard)
            ---C++: return const &
            ---C++: inline
            returns Triangle from BRepMesh;
 
 
-         -- Implementation :
+           -- Implementation :
 
-         Init           (me            : in out;
-                          Vertices      : in out Array1OfVertexOfDelaun from BRepMesh);
-         ---Purpose: Initializes the triangulation with an Array of
+           Init           (me            : in out;
+                           Vertices      : in out Array1OfVertexOfDelaun from BRepMesh);
+           ---Purpose: Initializes the triangulation with an Array of
            --          Vertex.
 
            Compute        (me            : in out;
@@ -149,14 +129,10 @@ class Delaun from BRepMesh
            ---Purpose: Computes the triangulation and add the vertices
            --          edges and triangles to the Mesh data structure.
 
-           ReCompute      (me            : in out;
-                            VertexIndices : in out Array1OfInteger from TColStd);
-            ---Purpose: Clear the  existing  triangles  and recomputes
-            --          the triangulation .
 
            SuperMesh      (me            : in out;
-                            theBox        : Box2d from Bnd);
-         ---Purpose: Build the super mesh .
+                           theBox        : Box2d from Bnd);
+           ---Purpose: Build the super mesh .
 
 
            FrontierAdjust (me            : in out)
@@ -164,9 +140,9 @@ class Delaun from BRepMesh
            is private;
 
 
-         MeshLeftPolygonOf  (me        : in out;
-                              EdgeIndex : Integer from Standard;
-                              EdgeSens  : Boolean from Standard)
+           MeshLeftPolygonOf  (me        : in out;
+                               EdgeIndex : Integer from Standard;
+                               EdgeSens  : Boolean from Standard)
               ---Purpose: Find left polygon of the edge and call MeshPolygon.
               is private;
 
@@ -178,7 +154,7 @@ class Delaun from BRepMesh
 
 
             CreateTriangles(me            : in out; 
-                                vertexIndex   : Integer from Standard; 
+                            vertexIndex   : Integer from Standard; 
                 --vertex        : in Vertex from BRepMesh; 
                                 freeEdges: out MapOfIntegerInteger from BRepMesh)
                 ---Purpose: Creates the triangles beetween the node 
@@ -194,34 +170,40 @@ class Delaun from BRepMesh
                --          When an edge is suppressed more than one time 
                --          it is destroyed.
                is private;
+               
+               
+           Perform (me: in out;
+                    theBndBox       : out Box2d from Bnd;
+                    theVertexIndices: out Array1OfInteger from TColStd)
+              is private;
 
 
-             Contains       (me;
-                              TrianIndex    : Integer from Standard;
-                              theVertex     : in Vertex from BRepMesh;
-                              edgeOn        : out Integer from Standard)
-                  ---Purpose: Test  if   triangle   of  index   <TrianIndex>
-                  --          contains geometricaly <theVertex>. If <EdgeOn>
-                  --          is != 0  then theVertex is  on Edge  of  index
-                  --          <edgeOn>.
-                  returns Boolean from Standard;
+           Contains       (me;
+                           TrianIndex    : Integer from Standard;
+                           theVertex     : in Vertex from BRepMesh;
+                           edgeOn        : out Integer from Standard)
+            ---Purpose: Test  if   triangle   of  index   <TrianIndex>
+            --          contains geometricaly <theVertex>. If <EdgeOn>
+            --          is != 0  then theVertex is  on Edge  of  index
+            --          <edgeOn>.
+            returns Boolean from Standard;
+
+
+            CreateTrianglesOnNewVertices(me            : in out;
+                                       theVertexIndices: out Array1OfInteger from TColStd)
+                --vertex        : in Vertex from BRepMesh; 
+                ---Purpose: Creates the triangles on new nodes
+              is private;
+
 
-                TriangleContaining
-                  (me            : in out;
-                    theVertex     : in Vertex from BRepMesh)
-                  ---Purpose: Gives  the   index   of  triangle   containing
-                  --          geometricaly <theVertex>. 
-                  returns Integer from Standard;
-
-
-                fields  MeshData               : DataStructureOfDelaun from BRepMesh;
-                        PositiveOrientation    : Boolean from Standard;
-                        tCircles               : CircleTool from BRepMesh;
-                        supVert1               : Integer from Standard;
-                        supVert2               : Integer from Standard;
-                        supVert3               : Integer from Standard;
-                        supTrian               : Triangle from BRepMesh;
-                        mapEdges               : MapOfInteger from BRepMesh;
+            fields  MeshData               : DataStructureOfDelaun from BRepMesh;
+                    PositiveOrientation    : Boolean from Standard;
+                    tCircles               : CircleTool from BRepMesh;
+                    supVert1               : Integer from Standard;
+                    supVert2               : Integer from Standard;
+                    supVert3               : Integer from Standard;
+                    supTrian               : Triangle from BRepMesh;
+                    mapEdges               : MapOfInteger from BRepMesh;
 
 
 end Delaun;
diff --git a/src/BRepMesh/BRepMesh_Delaun.cxx b/src/BRepMesh/BRepMesh_Delaun.cxx
index 74f72a5..b58e49f 100644
--- a/src/BRepMesh/BRepMesh_Delaun.cxx
+++ b/src/BRepMesh/BRepMesh_Delaun.cxx
@@ -13,6 +13,7 @@
 #include <Bnd_Box2d.hxx>
 #include <gp.hxx>
 #include <TColStd_MapOfInteger.hxx>
+#include <TColStd_Array1OfBoolean.hxx>
 #include <BRepMesh_MapOfIntegerInteger.hxx>
 #include <BRepMesh_HeapSortIndexedVertexOfDelaun.hxx>
 #include <BRepMesh_ComparatorOfIndexedVertexOfDelaun.hxx>
@@ -20,6 +21,8 @@
 #include <BRepMesh_SelectorOfDataStructureOfDelaun.hxx>
 #include <BRepMesh_HeapSortVertexOfDelaun.hxx>
 #include <BRepMesh_ComparatorOfVertexOfDelaun.hxx>
+#include <TColgp_Array1OfXY.hxx>
+#include <TColStd_Array1OfReal.hxx>
 
 typedef TColStd_ListIteratorOfListOfInteger  IteratorOnListOfInteger;
 typedef TColStd_ListOfInteger                ListOfInteger;
@@ -95,16 +98,7 @@ void BRepMesh_Delaun::Init(BRepMesh_Array1OfVertexOfDelaun& Vertices)
     vertexIndices(niver)=MeshData->AddNode(Vertices(niver));
   }
 
-  theBox.Enlarge(Precision::PConfusion());
-  SuperMesh(theBox);
-
-  BRepMesh_HeapSortIndexedVertexOfDelaun::Sort
-    (vertexIndices, 
-    BRepMesh_ComparatorOfIndexedVertexOfDelaun(SortingDirection,
-    Precision::PConfusion(),
-    MeshData));
-
-  Compute(vertexIndices);
+  Perform(theBox, vertexIndices);
 }
 
 
@@ -126,17 +120,26 @@ BRepMesh_Delaun::BRepMesh_Delaun
       theBox.Add(gp_Pnt2d(GetVertex(VertexIndices(niver)).Coord()));
     }
 
-    theBox.Enlarge(Precision::PConfusion());
-    SuperMesh(theBox);
+    Perform(theBox, VertexIndices);
+  }
+}
+
+//=======================================================================
+//function : Perform
+//purpose  : 
+//=======================================================================
+void BRepMesh_Delaun::Perform (Bnd_Box2d& theBndBox, TColStd_Array1OfInteger& theVertexIndices)
+{
+  theBndBox.Enlarge(Precision::PConfusion());
+  SuperMesh(theBndBox);
 
-    BRepMesh_HeapSortIndexedVertexOfDelaun::Sort
-      (VertexIndices, 
-      BRepMesh_ComparatorOfIndexedVertexOfDelaun(SortingDirection,
-      Precision::PConfusion(),
-      MeshData));
+  BRepMesh_HeapSortIndexedVertexOfDelaun::Sort
+    (theVertexIndices, 
+    BRepMesh_ComparatorOfIndexedVertexOfDelaun(SortingDirection,
+    Precision::PConfusion(),
+    MeshData));
 
-    Compute(VertexIndices);
-  }
+  Compute(theVertexIndices);
 }
 
 //=======================================================================
@@ -160,87 +163,17 @@ void BRepMesh_Delaun::Compute (TColStd_Array1OfInteger& VertexIndices)
     Standard_Integer iVert=VertexIndices.Lower();
     CreateTriangles(VertexIndices(iVert), loopEdges);
 
-    // Insertion of nodes :
-    Standard_Boolean modif=Standard_True;
-    Standard_Integer edgeOn, triPerce;
-
-    Standard_Integer aVertIdx;
-    for (iVert++; iVert<=VertexIndices.Upper(); iVert++) {
-      aVertIdx = VertexIndices(iVert);
-      const BRepMesh_Vertex& refToVert=GetVertex(aVertIdx);
-      loopEdges.Clear();
-
-      // List of indices of circles containing the node :
-      BRepMesh_ListOfInteger& cirL=tCircles.Select(refToVert.Coord());
-      BRepMesh_ListOfInteger::Iterator itT(cirL);
-
-      edgeOn=0;
-      triPerce=0;
-
-      for (; itT.More(); itT.Next()) {
+    CreateTrianglesOnNewVertices(VertexIndices);
 
         // To add a node in the mesh it is necessary to check to conditions
         // - the node should be located on the border of the mesh and in an existing triangle
         // - all adjacent triangles should belong to a component connected with this triangle 
-        if (Contains(itT.Value(), refToVert, edgeOn)) {
+      /*  if (Contains(itT.Value(), refToVert, edgeOn)) {
           triPerce=itT.Value();
           cirL.Remove(itT);
           break;
-        }
-      }
-
-      if (triPerce>0) {
-        DeleteTriangle(triPerce, loopEdges);
-
-        modif=Standard_True;
-        while (modif && !cirL.IsEmpty()) {
-          modif=Standard_False;
-          BRepMesh_ListOfInteger::Iterator itT1(cirL);
-          for (; itT1.More(); itT1.Next()) {
-            GetTriangle(itT1.Value()).Edges(e1,e2,e3,o1,o2,o3);
-            if (loopEdges.IsBound(e1) || 
-              loopEdges.IsBound(e2) || 
-              loopEdges.IsBound(e3)) {
-                modif=Standard_True;
-                DeleteTriangle(itT1.Value(), loopEdges);
-                cirL.Remove(itT1);
-                break;
-            }
-          }
-        }
-
-#ifdef TRIANGULATION_DEBUG
-        if (Triangulation_Trace>0) {
-          cout << " creation triangle avec le vertex: ";
-          cout << refToVert.Coord().X() << "  " << refToVert.Coord().Y() << endl;
-        }
-#endif
-        // Creation of triangles with the current node 
-        // and free edges and removal of these edges from the list of free edges 
-        CreateTriangles(aVertIdx, loopEdges);
-
-      }
-    }
-
-    // check that internal edges are not crossed by triangles
-    BRepMesh_MapOfInteger::Iterator itFr(InternalEdges());
-
-    // destruction of triancles intersecting internal edges 
-    // and their replacement by makeshift triangles
-    Standard_Integer nbc;
-
-    itFr.Reset();
-    for (; itFr.More(); itFr.Next()) {
-      nbc = MeshData->ElemConnectedTo(itFr.Key()).Extent();
-      if (nbc == 0) {
-        MeshLeftPolygonOf(itFr.Key(), Standard_True); 
-        MeshLeftPolygonOf(itFr.Key(), Standard_False); 
-      }
-    }
-
-    // adjustment of meshes to boundary edges
-    FrontierAdjust();
-
+        }*/
+        // Insertion of nodes :
   }
 
   // destruction of triangles containing a top of the super triangle
@@ -270,22 +203,6 @@ void BRepMesh_Delaun::Compute (TColStd_Array1OfInteger& VertexIndices)
 }
 
 //=======================================================================
-//function : ReCompute
-//purpose  : 
-//=======================================================================
-void BRepMesh_Delaun::ReCompute (TColStd_Array1OfInteger& VertexIndices)
-{
-  MeshData->ClearDomain();
-
-  // Initialisation du CircleTool :
-  tCircles.Initialize(VertexIndices.Length());
-
-  if (VertexIndices.Length()>2)
-    Compute(VertexIndices);
-}
-
-
-//=======================================================================
 //function : FrontierAdjust
 //purpose  : 
 //=======================================================================
@@ -297,113 +214,131 @@ void BRepMesh_Delaun::FrontierAdjust()
   BRepMesh_ListOfInteger::Iterator itconx;
   ListOfInteger tril;
 
-  // find external triangles on boundary edges
-  BRepMesh_MapOfInteger::Iterator itFr(Frontier());
-  for (; itFr.More(); itFr.Next()) {
-    const BRepMesh_PairOfIndex& aPair = MeshData->ElemConnectedTo(itFr.Key());
-    for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) {
-      const BRepMesh_Triangle& trc=GetTriangle(aPair.Index(j));
-      trc.Edges(e1,e2,e3,o1,o2,o3);
-      if      ((itFr.Key()==e1 && !o1) || 
-        (itFr.Key()==e2 && !o2) ||
-        (itFr.Key()==e3 && !o3))   {
+  Standard_Integer pass = 1;
+  for (; pass <= 2; pass++ )
+  {
+    // 1 pass): find external triangles on boundary edges
+    // 2 pass): find external triangles on boundary edges
+    // because in comlex curved boundaries external triangles can appear  
+    // after "mesh left polygon"
+    BRepMesh_MapOfInteger::Iterator itFr(Frontier());
+    for (; itFr.More(); itFr.Next()) {
+      const BRepMesh_PairOfIndex& aPair = MeshData->ElemConnectedTo(itFr.Key());
+      for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) {
+        const BRepMesh_Triangle& trc=GetTriangle(aPair.Index(j));
+        trc.Edges(e1,e2,e3,o1,o2,o3);
+        if      ((itFr.Key()==e1 && !o1) || 
+          (itFr.Key()==e2 && !o2) ||
+          (itFr.Key()==e3 && !o3))   {
 #ifdef TRIANGULATION_DEBUG
-          if (Triangulation_Trace>0) {
-            cout << "---> destruction du triangle " << aPair.Index(j) << endl;
-          }
+            if (Triangulation_Trace>0) {
+              cout << "---> destruction du triangle " << aPair.Index(j) << endl;
+            }
 #endif
-          tril.Append(aPair.Index(j));
+            tril.Append(aPair.Index(j));
+        }
       }
     }
-  }
 
-  // destruction  of external triangles on boundary edges
-  for (; !tril.IsEmpty(); tril.RemoveFirst()) {
-    DeleteTriangle(tril.First(), loopEdges);
-  }
+    // destruction  of external triangles on boundary edges
+    for (; !tril.IsEmpty(); tril.RemoveFirst()) {
+      DeleteTriangle(tril.First(), loopEdges);
+    }
 
-  // destrucrion of remaining hanging edges :
-  BRepMesh_MapOfIntegerInteger::Iterator itFE(loopEdges);
+    // destrucrion of remaining hanging edges :
+    BRepMesh_MapOfIntegerInteger::Iterator itFE(loopEdges);
 
-  for (; itFE.More(); itFE.Next()) {
-    if (MeshData->ElemConnectedTo(itFE.Key()).IsEmpty())
-      MeshData->RemoveLink(itFE.Key());
-  }
+    for (; itFE.More(); itFE.Next()) {
+      if (MeshData->ElemConnectedTo(itFE.Key()).IsEmpty())
+        MeshData->RemoveLink(itFE.Key());
+    }
 
-  // destruction of triangles crossing the boundary edges and 
-  // their replacement by makeshift triangles
-  itFr.Reset();
-  for (; itFr.More(); itFr.Next()) {
-    if (MeshData->ElemConnectedTo(itFr.Key()).IsEmpty()) { 
-      MeshLeftPolygonOf(itFr.Key(), Standard_True); 
+    // destruction of triangles crossing the boundary edges and 
+    // their replacement by makeshift triangles
+    if ( pass == 1 )
+    {
+      itFr.Reset();
+    }
+    else
+    {
+      // in some cases there remain unused boundaries check
+      itFr.Initialize(Frontier());
+    }
+    
+    for (; itFr.More(); itFr.Next()) {
+      if (MeshData->ElemConnectedTo(itFr.Key()).IsEmpty()) { 
+        MeshLeftPolygonOf(itFr.Key(), Standard_True); 
+      }
     }
-  } 
 
-  // After this processing there sometimes remain triangles outside boundaries.
-  // Destruction of these triangles : 
-  Standard_Integer nbFront;
+    if ( pass == 2 ) break;
 
-  // For each edge with only one connection
-  // If one of its tops already passes two boundary edges, 
-  // the connected triangle is outside of the contour 
-  Standard_Boolean again = Standard_True;
+    // After this processing there sometimes remain triangles outside boundaries.
+    // Destruction of these triangles : 
+    Standard_Integer nbFront;
 
-  while (again) {
-    tril.Clear();
-    loopEdges.Clear();
+    // For each edge with only one connection
+    // If one of its tops already passes two boundary edges, 
+    // the connected triangle is outside of the contour 
+    Standard_Boolean again = Standard_True;
 
-    for (itFr.Initialize(FreeEdges()); itFr.More(); itFr.Next()) {
-      const BRepMesh_Edge& edg=GetEdge(itFr.Key());
-      if (edg.Movability()!=BRepMesh_Frontier) {
-        nbFront=0;
-        if (MeshData->ElemConnectedTo(itFr.Key()).IsEmpty()) 
-          loopEdges.Bind(itFr.Key(), Standard_True);
-        else {
-          for (itconx.Init(MeshData->LinkNeighboursOf(edg.FirstNode()));
-            itconx.More(); itconx.Next()) {
-              if (GetEdge(itconx.Value()).Movability()==BRepMesh_Frontier) {
-                nbFront++;
-                if (nbFront>1) break;
-              }
-          }
-          if (nbFront==2) {
-            const BRepMesh_PairOfIndex& aPair = MeshData->ElemConnectedTo(itFr.Key());
-            for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) {
-              const Standard_Integer elemId = aPair.Index(j);
-              GetTriangle(elemId).Edges(e1, e2, e3, o1, o2, o3);
-              if (GetEdge(e1).Movability()==BRepMesh_Free &&
-                GetEdge(e2).Movability()==BRepMesh_Free &&
-                GetEdge(e3).Movability()==BRepMesh_Free) {
-#ifdef TRIANGULATION_DEBUG
-                  if (Triangulation_Trace>0) {
-                    cout << " ----> destruction du triangle" << elemId <<endl;
-                  }
-#endif
-                  tril.Append(elemId);
+    while (again) {
+      tril.Clear();
+      loopEdges.Clear();
+
+      for (itFr.Initialize(FreeEdges()); itFr.More(); itFr.Next()) {
+        const BRepMesh_Edge& edg=GetEdge(itFr.Key());
+        if (edg.Movability()!=BRepMesh_Frontier) {
+          nbFront=0;
+          if (MeshData->ElemConnectedTo(itFr.Key()).IsEmpty()) 
+            loopEdges.Bind(itFr.Key(), Standard_True);
+          else {
+            for (itconx.Init(MeshData->LinkNeighboursOf(edg.FirstNode()));
+              itconx.More(); itconx.Next()) {
+                if (GetEdge(itconx.Value()).Movability()==BRepMesh_Frontier) {
+                  nbFront++;
+                  if (nbFront>1) break;
+                }
+            }
+            if (nbFront==2) {
+              const BRepMesh_PairOfIndex& aPair = MeshData->ElemConnectedTo(itFr.Key());
+              for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) {
+                const Standard_Integer elemId = aPair.Index(j);
+                GetTriangle(elemId).Edges(e1, e2, e3, o1, o2, o3);
+                if (GetEdge(e1).Movability()==BRepMesh_Free &&
+                  GetEdge(e2).Movability()==BRepMesh_Free &&
+                  GetEdge(e3).Movability()==BRepMesh_Free) {
+  #ifdef TRIANGULATION_DEBUG
+                    if (Triangulation_Trace>0) {
+                      cout << " ----> destruction du triangle" << elemId <<endl;
+                    }
+  #endif
+                    tril.Append(elemId);
+                }
               }
             }
           }
         }
       }
-    }
 
-    // Destruction des triangles :
-    Standard_Integer kk = 0;
-    for (; !tril.IsEmpty(); tril.RemoveFirst()) {
-      DeleteTriangle(tril.First(), loopEdges);
-      kk++;
-    }
+      // Destruction des triangles :
+      Standard_Integer kk = 0;
+      for (; !tril.IsEmpty(); tril.RemoveFirst()) {
+        DeleteTriangle(tril.First(), loopEdges);
+        kk++;
+      }
 
-    // destruction of remaining hanging edges
-    for (itFE.Initialize(loopEdges); itFE.More(); itFE.Next()) {
-      if (MeshData->ElemConnectedTo(itFE.Key()).IsEmpty())
-        MeshData->RemoveLink(itFE.Key());
-    }
+      // destruction of remaining hanging edges
+      for (itFE.Initialize(loopEdges); itFE.More(); itFE.Next()) {
+        if (MeshData->ElemConnectedTo(itFE.Key()).IsEmpty())
+          MeshData->RemoveLink(itFE.Key());
+      }
 
-    if (kk == 0) break;
+      if (kk == 0) break;
+    }
   }
 
-  // find external triangles on boundary edges
+/*   // find external triangles on boundary edges
   // because in comlex curved boundaries external triangles can appear
   // after "mesh left polygon"
   for (itFr.Initialize(Frontier()); itFr.More(); itFr.Next()) {
@@ -440,7 +375,7 @@ void BRepMesh_Delaun::FrontierAdjust()
     if (MeshData->ElemConnectedTo(itFr.Key()).IsEmpty()) { 
       MeshLeftPolygonOf(itFr.Key(), Standard_True); 
     }
-  }
+  } */
 }
 
 
@@ -913,120 +848,123 @@ void BRepMesh_Delaun::CreateTriangles (const Standard_Integer theVertexIndex,
 }
 
 //=======================================================================
-//function : DeleteTriangle
-//purpose : The concerned triangles are deleted and the freed edges are added in 
-//           <loopEdges>.  If an edge is added twice, it does not exist and
-//          it is necessary to destroy it.  This corresponds to the destruction of two
-//          connected triangles.
+//function : CreateTrianglesOnNewVertices
+//purpose  : Creation of triangles from the new nodes
 //=======================================================================
-
-void  BRepMesh_Delaun::DeleteTriangle (const Standard_Integer tIndex, 
-                                       BRepMesh_MapOfIntegerInteger& fEdges)
+void BRepMesh_Delaun::CreateTrianglesOnNewVertices (TColStd_Array1OfInteger& theVertexIndices)
 {
-  tCircles.Delete(tIndex);
-
-  Standard_Integer fe1, fe2, fe3;
-  Standard_Boolean or1, or2, or3;
-  GetTriangle(tIndex).Edges(fe1, fe2, fe3, or1, or2, or3);
-  MeshData->RemoveElement(tIndex);
-
-  if (!fEdges.Bind(fe1, or1)) {
-    fEdges.UnBind(fe1);
-    MeshData->RemoveLink(fe1);
-  }
-  if (!fEdges.Bind(fe2, or2))  {
-    fEdges.UnBind(fe2);
-    MeshData->RemoveLink(fe2);
-  }
-  if (!fEdges.Bind(fe3, or3))  {
-    fEdges.UnBind(fe3);
-    MeshData->RemoveLink(fe3);
-  }
+  BRepMesh_MapOfIntegerInteger loopEdges(10,MeshData->Allocator());
 
-}
+  Standard_Integer iVert;
+  // Insertion of nodes :
+  Standard_Boolean modif=Standard_True;
+  Standard_Integer edgon, triPer;
+  Standard_Integer e1, e2, e3;
+  Standard_Boolean o1, o2, o3;
+  Standard_Integer aVertIdx;
 
+  for( iVert = theVertexIndices.Lower(); iVert<=theVertexIndices.Upper(); iVert++ ) 
+  {
+    loopEdges.Clear();
+    edgon = 0, triPer = 0;
+    aVertIdx = theVertexIndices(iVert);    
+    const BRepMesh_Vertex& aVert = GetVertex(aVertIdx);  
 
-//=======================================================================
-//function : AddVertex
-//purpose  : 
-//=======================================================================
-void  BRepMesh_Delaun::AddVertex(const BRepMesh_Vertex& theVert)
-{
-  Standard_Integer nv = MeshData->AddNode(theVert);
+    // Iterator in the list of indexes of circles containing the node
+    BRepMesh_ListOfInteger& cirL=tCircles.Select(aVert.Coord());
+    
+    BRepMesh_ListOfInteger::Iterator itT(cirL);
+    for (; itT.More(); itT.Next()) {
 
-  // Iterator in the list of indexes of circles containing the node :
-  BRepMesh_ListOfInteger& cirL=tCircles.Select(theVert.Coord());
+      // To add a node in the mesh it is necessary to check conditions: 
+      // - the node should be within the boundaries of the mesh and so in an existing triangle
+      // - all adjacent triangles should belong to a component connected with this triangle
+      if (Contains(itT.Value(), aVert, edgon)) {
+        if (edgon==0) {
+          triPer=itT.Value();
+          cirL.Remove(itT);
+          break;
+        }
+        else if (GetEdge(edgon).Movability()==BRepMesh_Free) {
+          triPer=itT.Value();
+          cirL.Remove(itT);
+          break;
+        }
+      }
+    }
 
-  Standard_Integer edgon=0;
-  Standard_Integer triPer=0;
-  Standard_Integer e1, e2, e3;
-  Standard_Boolean o1, o2, o3;
+    if (triPer>0) {
+      DeleteTriangle(triPer, loopEdges);
 
-  BRepMesh_ListOfInteger::Iterator itT(cirL);
-  for (; itT.More(); itT.Next()) {
-
-    // To add a node in the mesh it is necessary to check conditions: 
-    // - the node should be within the boundaries of the mesh and so in an existing triangle
-    // - all adjacent triangles should belong to a component connected with this triangle
-    if (Contains(itT.Value(), theVert, edgon)) {
-      if (edgon==0) {
-        triPer=itT.Value();
-        cirL.Remove(itT);
-        break;
-      }
-      else if (GetEdge(edgon).Movability()==BRepMesh_Free) {
-        triPer=itT.Value();
-        cirL.Remove(itT);
-        break;
+      modif=Standard_True;    
+      while (modif && !cirL.IsEmpty()) {
+        modif=Standard_False;
+        BRepMesh_ListOfInteger::Iterator itT1(cirL);
+        for (; itT1.More(); itT1.Next()) {
+          GetTriangle(itT1.Value()).Edges(e1,e2,e3,o1,o2,o3);
+          if (loopEdges.IsBound(e1) || 
+            loopEdges.IsBound(e2) || 
+            loopEdges.IsBound(e3)) {
+              modif=Standard_True;
+              DeleteTriangle(itT1.Value(), loopEdges);
+              cirL.Remove(itT1);
+              break;
+          }
+        }
       }
+
+      // Creation of triangles with the current node and free edges
+      // and removal of these edges from the list of free edges
+      CreateTriangles(aVertIdx, loopEdges);
     }
   }
+  // check that internal edges are not crossed by triangles
+  BRepMesh_MapOfInteger::Iterator itFr(InternalEdges());
 
-  if (triPer>0) {
-
-    BRepMesh_MapOfIntegerInteger loopEdges(10,MeshData->Allocator());
-    DeleteTriangle(triPer, loopEdges);
-
-    Standard_Boolean modif=Standard_True;
-    while (modif && !cirL.IsEmpty()) {
-      modif=Standard_False;
-      BRepMesh_ListOfInteger::Iterator itT1(cirL);
-      for (; itT1.More(); itT1.Next()) {
-        GetTriangle(itT.Value()).Edges(e1,e2,e3,o1,o2,o3);
-        if (loopEdges.IsBound(e1) || 
-          loopEdges.IsBound(e2) || 
-          loopEdges.IsBound(e3)) {
-            modif=Standard_True;
-            DeleteTriangle(itT1.Value(), loopEdges);
-            cirL.Remove(itT1);
-            break;
-        }
-      }
+  // destruction of triancles intersecting internal edges 
+  // and their replacement by makeshift triangles
+  Standard_Integer nbc;
+
+  itFr.Reset();
+  for (; itFr.More(); itFr.Next()) {
+    nbc = MeshData->ElemConnectedTo(itFr.Key()).Extent();
+    if (nbc == 0) {
+      MeshLeftPolygonOf(itFr.Key(), Standard_True); 
+      MeshLeftPolygonOf(itFr.Key(), Standard_False); 
     }
+  }
 
-    // Creation of triangles with the current node and free edges
-    // and removal of these edges from the list of free edges
-    CreateTriangles(nv, loopEdges);
+  // adjustment of meshes to boundary edges
+  FrontierAdjust();
+}
 
-    // Check that internal edges are not crossed by the triangles
-    BRepMesh_MapOfInteger::Iterator itFr(InternalEdges());
+//=======================================================================
+//function : DeleteTriangle
+//purpose : The concerned triangles are deleted and the freed edges are added in 
+//           <loopEdges>.  If an edge is added twice, it does not exist and
+//          it is necessary to destroy it.  This corresponds to the destruction of two
+//          connected triangles.
+//=======================================================================
 
-    // Destruction of triangles crossing internal edges and 
-    // their replacement by makeshift triangles
-    Standard_Integer nbc;
-    itFr.Reset();
-    for (; itFr.More(); itFr.Next()) {
-      nbc = MeshData->ElemConnectedTo(itFr.Key()).Extent();
-      if (nbc == 0) {
-        MeshLeftPolygonOf(itFr.Key(), Standard_True); 
-        MeshLeftPolygonOf(itFr.Key(), Standard_False); 
-      }
-    }
+void  BRepMesh_Delaun::DeleteTriangle (const Standard_Integer tIndex, 
+                                       BRepMesh_MapOfIntegerInteger& fEdges)
+{
+  tCircles.Delete(tIndex);
 
-    FrontierAdjust();
+  TColStd_Array1OfInteger fe(1,3);
+  TColStd_Array1OfBoolean ornt(1,3);
+  GetTriangle(tIndex).Edges(fe(1), fe(2), fe(3), ornt(1), ornt(2), ornt(3));
+  MeshData->RemoveElement(tIndex);
 
+  Standard_Integer i = 1;
+  for(; i <= 3; i++ )
+  {
+    if (!fEdges.Bind(fe(i), ornt(i))) 
+    {
+      fEdges.UnBind(fe(i));
+      MeshData->RemoveLink(fe(i));
+    }
   }
-
 }
 
 //=======================================================================
@@ -1107,218 +1045,14 @@ void  BRepMesh_Delaun::AddVertices(BRepMesh_Array1OfVertexOfDelaun& vertices)
     (vertices, 
     BRepMesh_ComparatorOfVertexOfDelaun(SortingDirection, Precision::PConfusion()));
 
-  BRepMesh_MapOfIntegerInteger loopEdges(10,MeshData->Allocator());
-  Standard_Boolean modif=Standard_True;
-  Standard_Integer edgon, triPer;
-  Standard_Integer e1, e2, e3;
-  Standard_Boolean o1, o2, o3;
-
   Standard_Integer niver;
-  Standard_Integer aIdxVert;
-  for (niver=vertices.Lower(); niver<=vertices.Upper(); niver++) {
-    aIdxVert = MeshData->AddNode(vertices(niver));
-
-    // Iterator in the list of indexes of circles containing the node
-    BRepMesh_ListOfInteger& cirL=tCircles.Select(vertices(niver).Coord());
-
-    edgon=0;
-    triPer=0;
-
-    BRepMesh_ListOfInteger::Iterator itT(cirL);
-    for (; itT.More(); itT.Next()) {
-
-      // To add a node in the mesh it is necessary to check conditions: 
-      // - the node should be within the boundaries of the mesh and so in an existing triangle
-      // - all adjacent triangles should belong to a component connected with this triangle
-      if (Contains(itT.Value(), vertices(niver), edgon)) {
-        if (edgon==0) {
-          triPer=itT.Value();
-          cirL.Remove(itT);
-          break;
-        }
-        else if (GetEdge(edgon).Movability()==BRepMesh_Free) {
-          triPer=itT.Value();
-          cirL.Remove(itT);
-          break;
-        }
-      }
-    }
-
-    if (triPer>0) {
-      DeleteTriangle(triPer, loopEdges);
-
-      modif=Standard_True;
-      while (modif && !cirL.IsEmpty()) {
-        modif=Standard_False;
-        BRepMesh_ListOfInteger::Iterator itT1(cirL);
-        for (; itT1.More(); itT1.Next()) {
-          GetTriangle(itT1.Value()).Edges(e1,e2,e3,o1,o2,o3);
-          if (loopEdges.IsBound(e1) || 
-            loopEdges.IsBound(e2) || 
-            loopEdges.IsBound(e3)) {
-              modif=Standard_True;
-              DeleteTriangle(itT1.Value(), loopEdges);
-              cirL.Remove(itT1);
-              break;
-          }
-        }
-      }
-
-      // Creation of triangles with the current node and free edges
-      // and removal of these edges from the list of free edges
-      CreateTriangles(aIdxVert, loopEdges);
-    }
-  }
-
-  // Check that internal edges are not crossed by triangles
-  BRepMesh_MapOfInteger::Iterator itFr(InternalEdges());
-
-  // Destruction of triangles crossing internal edges 
-  //and their replacement by makeshift triangles
-  Standard_Integer nbc;
-  itFr.Reset();
-  for (; itFr.More(); itFr.Next()) {
-    nbc = MeshData->ElemConnectedTo(itFr.Key()).Extent();
-    if (nbc == 0) {
-      MeshLeftPolygonOf(itFr.Key(), Standard_True); 
-      MeshLeftPolygonOf(itFr.Key(), Standard_False); 
-    }
-  }
-
-  // Adjustment of meshes to boundary edges
-  FrontierAdjust();
-}
-
+    
+  TColStd_Array1OfInteger vertexIndices(vertices.Lower(), vertices.Upper());
 
-//=======================================================================
-//function : RevertDiagonal
-//purpose  : 
-//=======================================================================
-Standard_Boolean BRepMesh_Delaun::RevertDiagonal(const Standard_Integer ind)
-{
-  const BRepMesh_PairOfIndex& elConx = MeshData->ElemConnectedTo(ind);
-  const BRepMesh_Edge& lEdge = GetEdge(ind);
-  if (elConx.Extent()==2 && lEdge.Movability()==BRepMesh_Free) {
-    Standard_Integer t1(elConx.FirstIndex());
-    Standard_Integer t2(elConx.LastIndex());
-
-    Standard_Integer e1t1, e2t1, e3t1, e1t2, e2t2, e3t2 ;
-    Standard_Boolean o1t1, o2t1, o3t1, o1t2, o2t2, o3t2;
-#ifndef DEB
-    Standard_Integer ed13=0, ed23=0, ed14=0, ed24=0, v1, v2, v3=0, v4=0, vc1;
-    Standard_Boolean oindt1=Standard_False, or13=Standard_False, 
-      or23=Standard_False, or14=Standard_False, or24=Standard_False, orien;
-#else
-    Standard_Integer ed13, ed23, ed14, ed24, v1, v2, v3, v4, vc1;
-    Standard_Boolean oindt1, or13, or23, or14, or24, orien;
-#endif
-    GetTriangle(t1).Edges(e1t1, e2t1, e3t1, o1t1, o2t1, o3t1);
-    GetTriangle(t2).Edges(e1t2, e2t2, e3t2, o1t2, o2t2, o3t2);
-
-    v1=lEdge.FirstNode(); v2=lEdge.LastNode();
-    if      (e1t1==ind) {
-      if (o2t1) v3 =GetEdge(e2t1).LastNode();
-      else      v3 =GetEdge(e2t1).FirstNode();
-      ed13=e3t1; ed23=e2t1;
-      or13=o3t1; or23=o2t1;
-      oindt1=o1t1;
-    }
-    else if (e2t1==ind) {
-      if (o3t1) v3 =GetEdge(e3t1).LastNode();
-      else      v3 =GetEdge(e3t1).FirstNode();
-      ed13=e1t1; ed23=e3t1;
-      or13=o1t1; or23=o3t1;
-      oindt1=o2t1;
-    }
-    else if (e3t1==ind) {
-      if (o1t1) v3 =GetEdge(e1t1).LastNode();
-      else      v3 =GetEdge(e1t1).FirstNode();
-      ed13=e2t1; ed23=e1t1;
-      or13=o2t1; or23=o1t1;
-      oindt1=o3t1;
-    }
-    if      (e1t2==ind) {
-      if (o2t2) v4 =GetEdge(e2t2).LastNode();
-      else      v4 =GetEdge(e2t2).FirstNode();
-      ed14=e2t2; ed24=e3t2;
-      or14=o2t2; or24=o3t2;
-    }
-    else if (e2t2==ind) {
-      if (o3t2) v4 =GetEdge(e3t2).LastNode();
-      else      v4 =GetEdge(e3t2).FirstNode();
-      ed14=e3t2; ed24=e1t2;
-      or14=o3t2; or24=o1t2;
-    }
-    else if (e3t2==ind) {
-      if (o1t2) v4 =GetEdge(e1t2).LastNode();
-      else      v4 =GetEdge(e1t2).FirstNode();
-      ed14=e1t2; ed24=e2t2;
-      or14=o1t2; or24=o2t2;
-    }
-    if (!oindt1) {
-      vc1=v3; v3=v4; v4=vc1;
-      vc1=ed13; ed13=ed24; ed24=vc1;
-      orien =or13; or13=or24; or24=orien ;
-      vc1=ed14; ed14=ed23; ed23=vc1;
-      orien =or14; or14=or23; or23=orien ;
-    }
-    const BRepMesh_Vertex& vert1 = GetVertex(v1);
-    const BRepMesh_Vertex& vert2 = GetVertex(v2);
-    const BRepMesh_Vertex& vert3 = GetVertex(v3);
-    const BRepMesh_Vertex& vert4 = GetVertex(v4);
-
-    gp_XY ved13(vert1.Coord()); ved13.Subtract(vert3.Coord());
-    gp_XY ved14(vert4.Coord()); ved14.Subtract(vert1.Coord());
-    gp_XY ved23(vert3.Coord()); ved23.Subtract(vert2.Coord());
-    gp_XY ved24(vert2.Coord()); ved24.Subtract(vert4.Coord());
-
-    Standard_Real z13, z24, modul;
-    z13=z24=0.;
-    modul=ved13.Modulus();
-    if (modul>Precision::PConfusion()) {
-      ved13.SetCoord(ved13.X()/modul, ved13.Y()/modul);
-      z13=ved13^ved14;
-    }
-    modul=ved24.Modulus();
-    if (modul>Precision::PConfusion()) {
-      ved24.SetCoord(ved24.X()/modul, ved24.Y()/modul);
-      z24=ved24^ved23;
-    }
+  for (niver=vertices.Lower(); niver<=vertices.Upper(); niver++)     
+    vertexIndices(niver)=MeshData->AddNode(vertices(niver));
 
-    if (Abs(z13)>=Precision::PConfusion()&&Abs(z24)>=Precision::PConfusion()) {
-      if ((z13>0. && z24>0.) || (z13<0. && z24<0.)) {
-        tCircles.Delete(t1);
-        tCircles.Delete(t2);
-        if (!tCircles.Add(vert4.Coord(), vert2.Coord(), vert3.Coord(), t1) &&
-          !tCircles.Add(vert3.Coord(), vert1.Coord(), vert4.Coord(), t2)) {
-            Standard_Integer newd=ind;
-            BRepMesh_Edge newEdg=BRepMesh_Edge(v3, v4, BRepMesh_Free);
-            if (!MeshData->SubstituteLink(newd, newEdg)) {
-              newd=MeshData->IndexOf(newEdg);
-              MeshData->RemoveLink(ind);
-            }
-            MeshData->SubstituteElement(t1, BRepMesh_Triangle(ed24, ed23, newd,
-              or24, or23, Standard_True,
-              BRepMesh_Free));
-            MeshData->SubstituteElement(t2, BRepMesh_Triangle(ed13, ed14, newd,
-              or13, or14, Standard_False,
-              BRepMesh_Free));
-            return Standard_True;
-        }
-        else {
-          if (oindt1) {
-            tCircles.Add(vert1.Coord(), vert2.Coord(), vert3.Coord(), t1);
-            tCircles.Add(vert2.Coord(), vert1.Coord(), vert4.Coord(), t2);
-          }
-          else {
-            tCircles.Add(vert1.Coord(), vert2.Coord(), vert3.Coord(), t2);
-            tCircles.Add(vert2.Coord(), vert1.Coord(), vert4.Coord(), t1);
-          }
-        }
-      }
-    }
-  }
-  return Standard_False;
+  CreateTrianglesOnNewVertices(vertexIndices);
 }
 
 //=======================================================================
@@ -1395,46 +1129,6 @@ Standard_Boolean BRepMesh_Delaun::UseEdge(const Standard_Integer ind)
 }
 
 //=======================================================================
-//function : SmoothMesh
-//purpose  : 
-//=======================================================================
-void BRepMesh_Delaun::SmoothMesh(const Standard_Real Epsilon)
-{
-  Standard_Integer baryVert, polyVert, nbPolyVert;
-  Standard_Real uSom, vSom, newU, newV;
-  Standard_Integer nbVert=MeshData->NbNodes();
-  BRepMesh_ListOfInteger::Iterator itNeig;
-
-  uSom=vSom=0;
-  for (baryVert=1; baryVert<=nbVert; baryVert++) {
-    const BRepMesh_Vertex& curVert=GetVertex(baryVert);
-    if (curVert.Movability()==BRepMesh_Free) {
-      const BRepMesh_ListOfInteger& neighEdg=MeshData->LinkNeighboursOf(baryVert);
-      if (neighEdg.Extent()>2) {
-        nbPolyVert=0;
-        for (itNeig.Init(neighEdg); itNeig.More(); itNeig.Next()) {
-          const BRepMesh_Edge& nedg=GetEdge(itNeig.Value());
-          polyVert=nedg.FirstNode();
-          if (polyVert==baryVert) polyVert=nedg.LastNode();
-          nbPolyVert++;
-          const gp_XY& pVal = GetVertex(polyVert).Coord();
-          uSom+=pVal.X();
-          vSom+=pVal.Y();
-        }
-        if (nbPolyVert>2) {
-          newU=uSom/(Standard_Real)nbPolyVert;
-          newV=vSom/(Standard_Real)nbPolyVert;
-          if (!curVert.Coord().IsEqual(gp_XY(newU, newV), Epsilon)) {
-            BRepMesh_Vertex newVert(newU, newV, curVert.Movability());
-            MeshData->MoveNode(baryVert, newVert);
-          }
-        }
-      }
-    }
-  }
-}
-
-//=======================================================================
 //function : Result
 //purpose  : 
 //=======================================================================
@@ -1499,103 +1193,92 @@ const BRepMesh_MapOfInteger& BRepMesh_Delaun::FreeEdges ()
 //function : Contains
 //purpose  : 
 //=======================================================================
+
+static Standard_Real calculateDist(const TColgp_Array1OfXY& E,
+                                   const TColgp_Array1OfXY& P,
+                                   const TColStd_Array1OfInteger& e,
+                                   const BRepMesh_Vertex& vert,
+                                   TColStd_Array1OfReal& v,
+                                   TColStd_Array1OfReal& mode,
+                                   Standard_Integer& edgOn)
+{
+  Standard_Real distMin = -1;
+  Standard_Integer i = 1;
+  for(; i <= 3; i++ )
+  {
+    mode(i) = E(i).SquareModulus();
+    if (mode(i) <= EPSEPS) return -1;
+    v(i) = E(i)^(vert.Coord()-P(i));
+    Standard_Real dist = (v(i)*v(i))/mode(i);
+    
+    if ( distMin < 0 || dist < distMin )
+    {
+      edgOn   = e(i);
+      distMin = dist;
+    }
+  }
+  return distMin;
+}
+
 Standard_Boolean BRepMesh_Delaun::Contains(const Standard_Integer tri,
                                            const BRepMesh_Vertex& vert,
                                            Standard_Integer& edgOn)const
 {
-  edgOn=0;
-  Standard_Integer e1, e2, e3, p1, p2, p3;
-  Standard_Boolean o1, o2, o3;
-  GetTriangle(tri).Edges(e1, e2, e3, o1, o2, o3);
-  const BRepMesh_Edge& edg1=GetEdge(e1);
-  const BRepMesh_Edge& edg2=GetEdge(e2);
-  const BRepMesh_Edge& edg3=GetEdge(e3);
-  if (o1) {
-    p1=edg1.FirstNode();
-    p2=edg1.LastNode();
+  edgOn = 0;
+  TColStd_Array1OfInteger e(1,3);
+  TColStd_Array1OfInteger p(1,3);
+  TColStd_Array1OfBoolean o(1,3);
+  GetTriangle(tri).Edges(e(1), e(2), e(3), o(1), o(2), o(3));
+  const BRepMesh_Edge* edg[3] = { &GetEdge(e(1)),
+                                  &GetEdge(e(2)),
+                                  &GetEdge(e(3)) };
+  if (o(1)) {
+    p(1) = edg[0]->FirstNode();
+    p(2) = edg[0]->LastNode();
   }
   else {
-    p2=edg1.FirstNode();
-    p1=edg1.LastNode();
-  }
-  if (o3) p3=edg3.FirstNode();
-  else    p3=edg3.LastNode();
-
-  const gp_XY& P1=GetVertex(p1).Coord();
-  const gp_XY& P2=GetVertex(p2).Coord();
-  const gp_XY& P3=GetVertex(p3).Coord();
-  gp_XY E1(P2); E1.Subtract(P1);
-  gp_XY E2(P3); E2.Subtract(P2);
-  gp_XY E3(P1); E3.Subtract(P3);
-
-  Standard_Real mode1=E1.SquareModulus();
-  //Standard_Real dist=Sqrt(mode1);
-  if (mode1<=EPSEPS) return Standard_False;
-  Standard_Real v1=E1^(vert.Coord()-P1);
-  Standard_Real distMin=(v1*v1)/mode1;
-  edgOn=e1;
-
-  Standard_Real mode2=E2.SquareModulus();
-  Standard_Real dist;
-  //dist=Sqrt(mode2);
-  if (mode2<=EPSEPS) return Standard_False;
-  Standard_Real v2=E2^(vert.Coord()-P2);
-  dist=(v2*v2)/mode2;
-  if (dist<distMin) {
-    edgOn=e2;
-    distMin=dist;
+    p(2) = edg[0]->FirstNode();
+    p(1) = edg[0]->LastNode();
   }
-
-  Standard_Real mode3=E3.SquareModulus();
-  //dist=Sqrt(mode3);
-  if (mode3<=EPSEPS) return Standard_False;
-  Standard_Real v3=E3^(vert.Coord()-P3);
-  dist=(v3*v3)/mode3;
-  if (dist<distMin) {
-    edgOn=e3;
-    distMin=dist;
-  }
-
-  if (distMin>EPSEPS) {
-    Standard_Integer edf=edgOn;
-    edgOn=0;
-    if      (edf==e1 && edg1.Movability()!=BRepMesh_Free) {
-      if (v1<(mode1/5.)) edgOn=e1;
-    }
-    else if (edf==e2 && edg2.Movability()!=BRepMesh_Free) {
-      if (v2<(mode2/5.)) edgOn=e2;
-    }
-    else if (edf==e3 && edg3.Movability()!=BRepMesh_Free) {
-      if (v3<(mode3/5.)) edgOn=e3;
+  if (o(3)) p(3) = edg[2]->FirstNode();
+  else      p(3) = edg[2]->LastNode();
+
+  TColgp_Array1OfXY P(1,3);
+  P(1) = GetVertex(p(1)).Coord();
+  P(2) = GetVertex(p(2)).Coord();
+  P(3) = GetVertex(p(3)).Coord();
+  
+  TColgp_Array1OfXY E(1,3);
+  E(1) = P(2); E(1).Subtract(P(1));
+  E(2) = P(3); E(2).Subtract(P(2));
+  E(3) = P(1); E(3).Subtract(P(3));
+
+  Standard_Real distMin;
+  TColStd_Array1OfReal v   (1,3);
+  TColStd_Array1OfReal mode(1,3);
+  
+  distMin = calculateDist(E, P, e, vert, v, mode, edgOn);
+  if ( distMin < 0 )
+    return Standard_False;
+      
+  if ( distMin > EPSEPS ) {
+    Standard_Integer edf = edgOn;
+    edgOn = 0;
+    if ( edf != 0 ) 
+    {
+      Standard_Integer i = 1;
+      for(; i <= 3; i++ )
+      {
+        if( edf == e(i) )
+          break;
+      }
+      
+      if( edg[i-1]->Movability() != BRepMesh_Free )
+        if ( v(i) < (mode(i)/5.) ) edgOn = e(i);
     }
   }
 
-  return (v1+v2+v3!=0. &&((v1>=0. && v2>=0. && v3>=0.) ||
-    (v1<=0. && v2<=0. && v3<=0.)));
+  return (v(1)+v(2)+v(3) != 0. && ((v(1) >= 0. && v(2) >= 0. && v(3) >= 0.) ||
+                                   (v(1) <= 0. && v(2) <= 0. && v(3) <= 0.)));
 }
 
-//=======================================================================
-//function : TriangleContaining
-//purpose  : 
-//=======================================================================
-Standard_Integer BRepMesh_Delaun::TriangleContaining(const BRepMesh_Vertex& vert)
-{
-  const BRepMesh_ListOfInteger& cirL=tCircles.Select(vert.Coord());
-
-  BRepMesh_ListOfInteger::Iterator itT(cirL);
-  Standard_Integer triPer=0;
-  Standard_Integer edgon=0;
-  for (; itT.More(); itT.Next()) {
-    if (Contains(itT.Value(), vert, edgon)) {
-      if (edgon==0) {
-        triPer=itT.Value();
-        break;
-      }
-      else if (GetEdge(edgon).Movability()==BRepMesh_Free) {
-        triPer=itT.Value();
-        break;
-      }
-    }
-  }
-  return triPer;
-}
diff --git a/src/BRepMesh/BRepMesh_Delaun.lxx b/src/BRepMesh/BRepMesh_Delaun.lxx
deleted file mode 100644
index 5927103..0000000
--- a/src/BRepMesh/BRepMesh_Delaun.lxx
+++ /dev/null
@@ -1,27 +0,0 @@
-// File:        BRepMesh_Delaun.lxx
-// Created:     Thu Aug 19 10:52:01 1993
-// Author:      Didier PIFFAULT
-//              <dpf at zerox>
-
-
-#include <BRepMesh_DataStructureOfDelaun.hxx>
-
-inline const BRepMesh_Vertex& BRepMesh_Delaun::GetVertex
-(const Standard_Integer vIndex) const
-{
-  return MeshData->GetNode(vIndex);
-}
-
-
-inline const BRepMesh_Edge& BRepMesh_Delaun::GetEdge
-(const Standard_Integer eIndex) const
-{
-  return MeshData->GetLink(eIndex);
-}
-
-
-inline const BRepMesh_Triangle& BRepMesh_Delaun::GetTriangle
-(const Standard_Integer tIndex) const
-{
-  return MeshData->GetElement(tIndex);
-}
diff --git a/src/BRepMesh/BRepMesh_DiscretFactory.cdl b/src/BRepMesh/BRepMesh_DiscretFactory.cdl
index c29284a..e1e1d60 100644
--- a/src/BRepMesh/BRepMesh_DiscretFactory.cdl
+++ b/src/BRepMesh/BRepMesh_DiscretFactory.cdl
@@ -1,71 +1,105 @@
--- File:	BRepMesh_DiscretFactory.cdl
--- Created:	Thu Apr 10 12:34:15 2008
--- Author:	Peter KURNEV
---		<pkv at irinox>
----Copyright:	 Matra Datavision 2008
+-- File:      BRepMesh_DiscretFactory.cdl
+-- Created:   Thu Apr 10 12:34:15 2008
+-- Author:    Peter KURNEV <pkv at irinox>
+--
+---Copyright: Matra Datavision 2008
 
+class DiscretFactory from BRepMesh
 
-class DiscretFactory from BRepMesh 
-
-	---Purpose: 
+    ---Purpose:
+    -- This class intended to setup / retrieve default triangulation algorithm.
+    -- Use BRepMesh_DiscretFactory::Get() static method to retrieve global Factory instance.
+    -- Use BRepMesh_DiscretFactory::Discret() method to retrieve meshing tool.
 
 uses
-    AsciiString from TCollection, 
-    PDiscretRoot from BRepMesh, 
-    MapOfAsciiString from TColStd, 
-    FactoryError from BRepMesh,
-    Shape from TopoDS  
---raises
+    DiscretRoot      from BRepMesh,
+    FactoryError     from BRepMesh,
+    PluginEntryType  from BRepMesh,
+    AsciiString      from TCollection,
+    MapOfAsciiString from TColStd,
+    Shape            from TopoDS,
+    MapOfFunctions   from Plugin
 
+--raises
 
-is     
+is
     Create
-    	returns DiscretFactory from BRepMesh 
-    	is protected;  
-    ---C++: alias "Standard_EXPORT virtual ~BRepMesh_DiscretFactory();" 
-
-    Get(myclass) 
-    	returns DiscretFactory from BRepMesh; 
-    ---C++: return &  
-     
-    Names(me) 
-    	returns MapOfAsciiString from TColStd;  
-    ---C++: return const & 	 
-
-    SetDefaultName(me:out; 
-    	    theName:AsciiString from TCollection); 
-	 
-    DefaultName(me) 
-    	returns  AsciiString from TCollection; 
-    ---C++: return const &  
-     	 
-    SetFunctionName(me:out; 
-    	    theName:AsciiString from TCollection); 
-	 
-    FunctionName(me) 
-    	returns  AsciiString from TCollection;  
-    ---C++: return const &  
-
-    Discret(me:out; 
-	    theShape:Shape from TopoDS; 
-    	    theDeflection : Real    from Standard; 
-    	    theAngle      : Real    from Standard)
-    	returns PDiscretRoot from BRepMesh; 
-    ---C++: return &  
-     
-    ErrorStatus(me) 
-    	returns FactoryError from BRepMesh; 
-
-    Clear(me:out) 
-    	is protected; 
-	 
-fields 
-    myPDiscret    : PDiscretRoot from BRepMesh is protected; 
-    myErrorStatus : FactoryError from BRepMesh is protected;
-    myNames       : MapOfAsciiString from TColStd is protected; 
-    myFixedNames  : AsciiString from TCollection[1] is protected; 
-    myDefaultName : AsciiString from TCollection is protected; 
-    myFunctionName: AsciiString from TCollection is protected; 
-     
-end DiscretFactory;
+        returns DiscretFactory from BRepMesh
+        is protected;
+    ---C++: alias "Standard_EXPORT virtual ~BRepMesh_DiscretFactory();"
+
+    Get (myclass)
+        returns DiscretFactory from BRepMesh;
+    ---C++: return &
+    ---Purpose:
+    -- Returns the global factory instance.
+
+    Names (me)
+        returns MapOfAsciiString from TColStd;
+    ---C++: return const &
+    ---Purpose:
+    -- Returns the list of registered meshing algorithms.
+
+    SetDefaultName (     me : out;
+                    theName : AsciiString from TCollection)
+        returns Boolean from Standard;
+    ---Purpose:
+    -- Setup meshing algorithm by name.
+    -- Returns true if requested tool is available.
+    -- On fail Factory will continue to use previous algo.
+
+    DefaultName (me)
+        returns AsciiString from TCollection;
+    ---C++: return const &
+    ---Purpose:
+    -- Returns name for current meshing algorithm.
 
+    SetFunctionName (         me : out;
+                     theFuncName : AsciiString from TCollection)
+        returns Boolean from Standard;
+    ---Purpose:
+    -- Advanced function. Changes function name to retrieve from plugin.
+    -- Returns true if requested tool is available.
+    -- On fail Factory will continue to use previous algo.
+
+    SetDefault (         me : out;
+                    theName : AsciiString from TCollection;
+                theFuncName : AsciiString from TCollection = "DISCRETALGO")
+        returns Boolean from Standard;
+    ---Purpose:
+    -- Setup meshing algorithm that should be created by this Factory.
+    -- Returns true if requested tool is available.
+    -- On fail Factory will continue to use previous algo.
+    -- Call ::ErrorStatus() method to retrieve fault reason.
+
+    FunctionName (me)
+        returns AsciiString from TCollection;
+    ---C++: return const &
+    ---Purpose:
+    -- Returns function name that should be exported by plugin.
+
+    Discret (me            : out;
+             theShape      : Shape from TopoDS;
+             theDeflection : Real  from Standard;
+             theAngle      : Real  from Standard)
+        returns DiscretRoot from BRepMesh;
+    ---Purpose:
+    -- Returns triangulation algorithm instance.
+
+    ErrorStatus (me)
+        returns FactoryError from BRepMesh;
+    ---Purpose:
+    -- Returns error status for last meshing algorithm switch.
+
+    Clear (me : out)
+        is protected;
+
+fields
+    myPluginEntry    : PluginEntryType from BRepMesh is protected;
+    myErrorStatus    : FactoryError from BRepMesh is protected;
+    myNames          : MapOfAsciiString from TColStd is protected;
+    myDefaultName    : AsciiString from TCollection is protected;
+    myFunctionName   : AsciiString from TCollection is protected;
+    myFactoryMethods : MapOfFunctions from Plugin is protected;
+
+end DiscretFactory;
diff --git a/src/BRepMesh/BRepMesh_DiscretFactory.cxx b/src/BRepMesh/BRepMesh_DiscretFactory.cxx
index 9260b33..69f3402 100644
--- a/src/BRepMesh/BRepMesh_DiscretFactory.cxx
+++ b/src/BRepMesh/BRepMesh_DiscretFactory.cxx
@@ -1,223 +1,242 @@
-// File:	BRepMesh_DiscretFactory.cxx
-// Created:	Thu Apr 10 13:32:00 2008
-// Author:	Peter KURNEV
-//		<pkv at irinox>
-
+// File:    BRepMesh_DiscretFactory.cxx
+// Created: Thu Apr 10 13:32:00 2008
+// Author:  Peter KURNEV <pkv at irinox>
 
 #include <BRepMesh_DiscretFactory.ixx>
 
 #include <OSD_SharedLibrary.hxx>
 #include <OSD_Function.hxx>
 #include <BRepMesh_IncrementalMesh.hxx>
+#include <BRepMesh_PDiscretRoot.hxx>
 
-static 
-  void MakeLibName(const TCollection_AsciiString& , 
-		   TCollection_AsciiString& );
-static
-  Standard_Integer CreateDiscret(const TopoDS_Shape& theShape,
-				 const Standard_Real    ,
-				 const Standard_Real    ,
-				 OSD_Function& ,
-				 BRepMesh_PDiscretRoot& );
+namespace
+{
+  //! Embedded triangulation tool(s)
+  static TCollection_AsciiString THE_FAST_DISCRET_MESH ("FastDiscret");
+
+  //! Generate system-dependent name for dynamic library
+  //! (add standard prefixes and postfixes)
+  static void MakeLibName (const TCollection_AsciiString& theDefaultName,
+                                 TCollection_AsciiString& theLibName)
+  {
+    theLibName = "";
+  #ifndef WNT
+    theLibName += "lib";
+  #endif
+    theLibName += theDefaultName;
+  #ifdef WNT
+    theLibName += ".dll";
+  #elif __APPLE__
+    theLibName += ".dylib";
+  #elif defined (HPUX) || defined(_hpux)
+    theLibName += ".sl";
+  #else
+    theLibName += ".so";
+  #endif
+  }
+};
 
 //=======================================================================
 //function : BRepMesh_DiscretFactory
-//purpose  : 
+//purpose  :
 //=======================================================================
 BRepMesh_DiscretFactory::BRepMesh_DiscretFactory()
+: myPluginEntry (NULL),
+  myErrorStatus (BRepMesh_FE_NOERROR),
+  myDefaultName (THE_FAST_DISCRET_MESH),
+  myFunctionName ("DISCRETALGO")
 {
-  myFixedNames[0]="FastDiscret";
-
-  //
-  myNames.Add(myFixedNames[0]);
-  myDefaultName=myFixedNames[0];
-  myFunctionName="DISCRETALGO";
-  myPDiscret=NULL;
+  // register built-in meshing algorithms
+  myNames.Add (THE_FAST_DISCRET_MESH);
 }
+
 //=======================================================================
 //function : ~
-//purpose  : 
+//purpose  :
 //=======================================================================
 BRepMesh_DiscretFactory::~BRepMesh_DiscretFactory()
 {
   Clear();
 }
+
 //=======================================================================
 //function : ~
-//purpose  : 
+//purpose  :
 //=======================================================================
 void BRepMesh_DiscretFactory::Clear()
 {
-  if (myPDiscret) {
-    delete myPDiscret;
-    myPDiscret=NULL;
-  }
+  // what should we do here? Unload dynamic libraries and reset plugins list?
 }
+
 //=======================================================================
 //function : Get
-//purpose  : 
+//purpose  :
 //=======================================================================
-BRepMesh_DiscretFactory& BRepMesh_DiscretFactory::Get() 
+BRepMesh_DiscretFactory& BRepMesh_DiscretFactory::Get()
 {
-  static BRepMesh_DiscretFactory* sFactory;
-  static Standard_Boolean isInit=Standard_False;
-  if(!isInit) {
-    isInit = Standard_True;
-    sFactory = new BRepMesh_DiscretFactory;
-  }
-  return *sFactory;
+  //! global factory instance
+  static BRepMesh_DiscretFactory THE_GLOBAL_FACTORY;
+  return THE_GLOBAL_FACTORY;
 }
+
 //=======================================================================
 //function : ErrorStatus
-//purpose  : 
+//purpose  :
 //=======================================================================
-BRepMesh_FactoryError BRepMesh_DiscretFactory::ErrorStatus()const
+BRepMesh_FactoryError BRepMesh_DiscretFactory::ErrorStatus() const
 {
   return myErrorStatus;
 }
+
 //=======================================================================
 //function : Names
-//purpose  : 
+//purpose  :
 //=======================================================================
-const TColStd_MapOfAsciiString& BRepMesh_DiscretFactory::Names()const
+const TColStd_MapOfAsciiString& BRepMesh_DiscretFactory::Names() const
 {
   return myNames;
 }
+
 //=======================================================================
 //function : SetDefaultName
-//purpose  : 
+//purpose  :
 //=======================================================================
-void BRepMesh_DiscretFactory::SetDefaultName(const TCollection_AsciiString& theName)
+Standard_Boolean BRepMesh_DiscretFactory::SetDefaultName (const TCollection_AsciiString& theName)
 {
-  myDefaultName=theName;
+  return SetDefault (theName, myFunctionName);
 }
+
 //=======================================================================
 //function : DefaultName
-//purpose  : 
+//purpose  :
 //=======================================================================
-const TCollection_AsciiString& BRepMesh_DiscretFactory::DefaultName()const
+const TCollection_AsciiString& BRepMesh_DiscretFactory::DefaultName() const
 {
   return myDefaultName;
 }
+
 //=======================================================================
 //function : SetFunctionName
-//purpose  : 
+//purpose  :
 //=======================================================================
-void BRepMesh_DiscretFactory::SetFunctionName(const TCollection_AsciiString& theName)
+Standard_Boolean BRepMesh_DiscretFactory::SetFunctionName (const TCollection_AsciiString& theFuncName)
 {
-  myFunctionName=theName;
+  return SetDefault (myDefaultName, theFuncName);
 }
+
 //=======================================================================
 //function : FunctionName
-//purpose  : 
+//purpose  :
 //=======================================================================
-const TCollection_AsciiString& BRepMesh_DiscretFactory::FunctionName()const
+const TCollection_AsciiString& BRepMesh_DiscretFactory::FunctionName() const
 {
   return myFunctionName;
 }
+
 //=======================================================================
-//function : Discret
-//purpose  : 
+//function : SetDefault
+//purpose  :
 //=======================================================================
-BRepMesh_PDiscretRoot& 
-  BRepMesh_DiscretFactory::Discret(const TopoDS_Shape& theShape,
-				   const Standard_Real theDeflection,
-				   const Standard_Real theAngle)
+Standard_Boolean BRepMesh_DiscretFactory::SetDefault (const TCollection_AsciiString& theName,
+                                                      const TCollection_AsciiString& theFuncName)
 {
-  myErrorStatus=BRepMesh_FE_NOERROR;
-  Clear();
-  // DEB f
-  //myDefaultName="TKXMesh";
-  // DEB t
-  if(myDefaultName==myFixedNames[0]) {
-    myPDiscret=new BRepMesh_IncrementalMesh;
-    myPDiscret->SetDeflection(theDeflection);
-    myPDiscret->SetAngle(theAngle);
-    myPDiscret->SetShape(theShape);
+  myErrorStatus = BRepMesh_FE_NOERROR;
+  if (theName == THE_FAST_DISCRET_MESH)
+  {
+    // built-in, nothing to do
+    myPluginEntry  = NULL;
+    myDefaultName  = theName;
+    myFunctionName = theFuncName;
+    return Standard_True;
+  }
+  else if (theName == myDefaultName && theFuncName == myFunctionName)
+  {
+    // already active
+    return myPluginEntry != NULL;
   }
-  else {
-    Standard_Integer iErr;
+
+  TCollection_AsciiString aMeshAlgoId = theName + "_" + theFuncName;
+  BRepMesh_PluginEntryType aFunc = NULL;
+  if (myFactoryMethods.IsBound (aMeshAlgoId))
+  {
+    // retrieve from cache
+    aFunc = (BRepMesh_PluginEntryType )myFactoryMethods (aMeshAlgoId);
+  }
+  else
+  {
     TCollection_AsciiString aLibName;
-    OSD_Function aF;
-    //
-    myPDiscret=NULL;
-    //
-    MakeLibName(myDefaultName, aLibName);
-    //
-    OSD_SharedLibrary aSL(aLibName.ToCString());
-    if (!aSL.DlOpen(OSD_RTLD_LAZY)) {
-      myErrorStatus=BRepMesh_FE_LIBRARYNOTFOUND; // library is not found  
-      return myPDiscret;
-    }
-    //
-    aF = aSL.DlSymb(myFunctionName.ToCString());
-    if(aF==NULL ) {
-      myErrorStatus=BRepMesh_FE_FUNCTIONNOTFOUND; // function is not found  
-      return myPDiscret;
-    }
-    //
-    iErr=CreateDiscret(theShape,
-		       theDeflection,
-		       theAngle,
-		       aF,
-		       myPDiscret);
-    if (iErr) {
-      myErrorStatus=BRepMesh_FE_CANNOTCREATEALGO; // can not create the algo specified  
-    }
-    else {
-      myNames.Add(myDefaultName);
+    MakeLibName (theName, aLibName);
+    OSD_SharedLibrary aSL (aLibName.ToCString());
+    if (!aSL.DlOpen (OSD_RTLD_LAZY))
+    {
+      // library is not found
+      myErrorStatus = BRepMesh_FE_LIBRARYNOTFOUND;
+      return Standard_False;
     }
+
+    // retrieve the function from plugin
+    aFunc = (BRepMesh_PluginEntryType )aSL.DlSymb (theFuncName.ToCString());
+    myFactoryMethods.Bind (aMeshAlgoId, (OSD_Function )aFunc);
+  }
+
+  if (aFunc == NULL)
+  {
+    // function is not found - invalid plugin?
+    myErrorStatus = BRepMesh_FE_FUNCTIONNOTFOUND;
+    return Standard_False;
+  }
+
+  // try to create dummy tool
+  BRepMesh_PDiscretRoot anInstancePtr = NULL;
+  Standard_Integer anErr = aFunc (TopoDS_Shape(), 0.001, 0.1, anInstancePtr);
+  if (anErr != 0 || anInstancePtr == NULL)
+  {
+    // can not create the algo specified  
+    myErrorStatus = BRepMesh_FE_CANNOTCREATEALGO;
+    delete anInstancePtr;
+    return Standard_False;
   }
-  //
-  return myPDiscret;
+  delete anInstancePtr;
+
+  // if all checks done - switch to this tool
+  myPluginEntry  = aFunc;
+  myDefaultName  = theName;
+  myFunctionName = theFuncName;
+  myNames.Add (theName);
+  return Standard_True;
 }
+
 //=======================================================================
-//function : CreateDiscret
-//purpose  : 
+//function : Discret
+//purpose  :
 //=======================================================================
-Standard_Integer CreateDiscret(const TopoDS_Shape& theShape,
-			       const Standard_Real theDeflection,
-			       const Standard_Real theAngle,
-			       OSD_Function& theF,
-			       BRepMesh_PDiscretRoot& theAlgo)
+Handle(BRepMesh_DiscretRoot) BRepMesh_DiscretFactory
+  ::Discret (const TopoDS_Shape& theShape,
+             const Standard_Real theDeflection,
+             const Standard_Real theAngle)
 {
-  Standard_Integer iErr;
-  Standard_Integer (*fp) (const TopoDS_Shape& ,
-			  const Standard_Real ,
-			  const Standard_Real ,
-			  BRepMesh_PDiscretRoot& );
-  //
-  fp=(Standard_Integer (*)(const TopoDS_Shape& ,
-			   const Standard_Real ,
-			   const Standard_Real ,
-			   BRepMesh_PDiscretRoot&)) theF;
-  //
-  iErr=(*fp)(theShape,
-	     theDeflection,
-	     theAngle,
-	     theAlgo);
-  //
-  return iErr;
-}     
-//=======================================================================
-//function : MakeLibName
-//purpose  : 
-//=======================================================================
-void MakeLibName(const TCollection_AsciiString& theDefaultName, 
-		 TCollection_AsciiString& theLibName)
-{
-  theLibName="";
-#ifndef WNT
-  theLibName+="lib";
-#endif
-  theLibName+=theDefaultName;
-#ifdef WNT
-  theLibName+=".dll";
-#elif __APPLE__
-  theLibName+=".dylib";
-#elif defined (HPUX) || defined(_hpux)
-  theLibName+=".sl";
-#else
-  theLibName+=".so";
-#endif  
+  Handle(BRepMesh_DiscretRoot) aDiscretRoot;
+  BRepMesh_PDiscretRoot anInstancePtr = NULL;
+  if (myPluginEntry != NULL)
+  {
+    // use plugin
+    Standard_Integer anErr = myPluginEntry (theShape, theDeflection, theAngle, anInstancePtr);
+    if (anErr != 0 || anInstancePtr == NULL)
+    {
+      // can not create the algo specified - should never happens here
+      myErrorStatus = BRepMesh_FE_CANNOTCREATEALGO;
+      return aDiscretRoot;
+    }
+  }
+  else //if (myDefaultName == THE_FAST_DISCRET_MESH)
+  {
+    // use built-in
+    BRepMesh_IncrementalMesh::Discret (theShape, theDeflection, theAngle, anInstancePtr);
+  }
+
+  // cover with handle
+  aDiscretRoot = anInstancePtr;
+
+  // return the handle
+  return aDiscretRoot;
 }
diff --git a/src/BRepMesh/BRepMesh_DiscretRoot.cdl b/src/BRepMesh/BRepMesh_DiscretRoot.cdl
index bf7fdc0..5539634 100644
--- a/src/BRepMesh/BRepMesh_DiscretRoot.cdl
+++ b/src/BRepMesh/BRepMesh_DiscretRoot.cdl
@@ -1,65 +1,83 @@
--- File:	BRepMesh_DiscretRoot.cdl
--- Created:	Thu Apr 10 09:57:55 2008
--- Author:	Peter KURNEV
---		<pkv at irinox>
----Copyright:	 Matra Datavision 2008
+-- File:      BRepMesh_DiscretRoot.cdl
+-- Created:   Thu Apr 10 09:57:55 2008
+-- Author:    Peter KURNEV <pkv at irinox>
+--
+---Copyright: Matra Datavision 2008
 
+deferred class DiscretRoot from BRepMesh
 
-deferred class DiscretRoot from BRepMesh  
-	 
-    ---Purpose: 
+inherits Transient from Standard
+
+    ---Purpose:
+    -- This is a common interface for meshing algorithms
+    -- instantiated by Mesh Factory and implemented by plugins.
 
 uses
-    Shape from TopoDS 
-    
+    Shape from TopoDS
+
 --raises
 
-is 
-    
-    Initialize 
-    	returns DiscretRoot from BRepMesh;  
-	      
-    SetDeflection(me: out; 
-    	    theDeflection : Real from Standard); 
-    ---C++: alias "Standard_EXPORT virtual ~BRepMesh_DiscretRoot();" 
-    
-    Deflection(me) 
-    	returns Real from Standard; 
-
-    SetAngle(me: out; 
-    	    theAngle: Real from Standard); 
-	     
-    Angle(me) 
-    	returns Real from Standard;     
-     
-    SetShape(me: out; 
-    	    theShape: Shape from TopoDS); 
-
-    Shape(me) 
-    	returns Shape from TopoDS; 
-    ---C++: return const &    	     
-
-    Perform(me: out) 
-    	is deferred; 
-
-    IsDone(me) 
-    	returns Boolean from Standard;   
-
-    -- 
-    --  Protected methods 
-    --     
-    SetDone(me:out) 
-    	is protected;  
-	
-    SetNotDone(me:out) 
-    	is protected; 
-     
-    Init(me:out) 
-    	is virtual protected;  
-fields 
-    myDeflection : Real from Standard is protected; 
+is
+    Initialize
+        returns DiscretRoot from BRepMesh;
+
+    SetDeflection (           me : mutable;
+                   theDeflection : Real from Standard);
+    ---Purpose:
+    -- Setup linear deflection.
+
+    ---C++: alias "Standard_EXPORT virtual ~BRepMesh_DiscretRoot();"
+
+    Deflection (me)
+        returns Real from Standard;
+    ---Purpose:
+    -- Returns linear deflection.
+
+    SetAngle (      me : mutable;
+              theAngle : Real from Standard);
+    ---Purpose:
+    -- Setup angular deflection.
+
+    Angle (me)
+        returns Real from Standard;
+    ---Purpose:
+    -- Returns angular deflection.
+
+    SetShape (      me : mutable;
+              theShape : Shape from TopoDS);
+    ---Purpose:
+    -- Set the shape to triangulate.
+
+    Shape (me)
+        returns Shape from TopoDS;
+    ---C++: return const &
+
+    Perform (me : mutable)
+        is deferred;
+    ---Purpose:
+    -- Compute triangulation for set shape.
+
+    IsDone (me)
+        returns Boolean from Standard;
+    ---Purpose:
+    -- Returns true if triangualtion was performed and has success.
+
+    --
+    --  Protected methods
+    --
+    SetDone (me : mutable)
+        is protected;
+
+    SetNotDone (me : mutable)
+        is protected;
+
+    Init (me : mutable)
+        is virtual protected;
+
+fields
+    myDeflection : Real from Standard is protected;
     myAngle      : Real from Standard is protected;
-    myShape      : Shape from TopoDS  is protected; 
-    myIsDone     : Boolean from Standard is protected;  
-    
+    myShape      : Shape from TopoDS  is protected;
+    myIsDone     : Boolean from Standard is protected;
+
 end DiscretRoot;
diff --git a/src/BRepMesh/BRepMesh_DiscretRoot.cxx b/src/BRepMesh/BRepMesh_DiscretRoot.cxx
index d76aff0..dc56e9e 100644
--- a/src/BRepMesh/BRepMesh_DiscretRoot.cxx
+++ b/src/BRepMesh/BRepMesh_DiscretRoot.cxx
@@ -1,105 +1,115 @@
-// File:	BRepMesh_DiscretRoot.cxx
-// Created:	Thu Apr 10 10:08:44 2008
-// Author:	Peter KURNEV
-//		<pkv at irinox>
-
+// File:    BRepMesh_DiscretRoot.cxx
+// Created: Thu Apr 10 10:08:44 2008
+// Author:  Peter KURNEV <pkv at irinox>
 
 #include <BRepMesh_DiscretRoot.ixx>
- 
+
 //=======================================================================
 //function : BRepMesh_DiscretRoot
-//purpose  : 
+//purpose  :
 //=======================================================================
 BRepMesh_DiscretRoot::BRepMesh_DiscretRoot()
+: myDeflection (0.001),
+  myAngle (0.1),
+  myIsDone (Standard_False)
 {
-  myIsDone=Standard_False;
-  myDeflection=0.001;
-  myAngle=0.1;
+  //
 }
+
 //=======================================================================
 //function : ~
-//purpose  : 
+//purpose  :
 //=======================================================================
 BRepMesh_DiscretRoot::~BRepMesh_DiscretRoot()
 {
 }
+
 //=======================================================================
 //function : SetDeflection
-//purpose  : 
+//purpose  :
 //=======================================================================
-void BRepMesh_DiscretRoot::SetDeflection(const Standard_Real theDeflection)
+void BRepMesh_DiscretRoot::SetDeflection (const Standard_Real theDeflection)
 {
-  myDeflection=theDeflection;
+  myDeflection = theDeflection;
 }
+
 //=======================================================================
 //function : Deflection
 //purpose  : 
 //=======================================================================
-Standard_Real BRepMesh_DiscretRoot::Deflection()const 
+Standard_Real BRepMesh_DiscretRoot::Deflection() const
 {
   return myDeflection;
 }
+
 //=======================================================================
 //function : SetAngle
-//purpose  : 
+//purpose  :
 //=======================================================================
-void BRepMesh_DiscretRoot::SetAngle(const Standard_Real theAngle)
+void BRepMesh_DiscretRoot::SetAngle (const Standard_Real theAngle)
 {
-  myAngle=theAngle;
+  myAngle = theAngle;
 }
+
 //=======================================================================
 //function : Angle
-//purpose  : 
+//purpose  :
 //=======================================================================
-Standard_Real BRepMesh_DiscretRoot::Angle()const 
+Standard_Real BRepMesh_DiscretRoot::Angle() const
 {
   return myAngle;
 }
+
 //=======================================================================
 //function : SetShape
-//purpose  : 
+//purpose  :
 //=======================================================================
-void BRepMesh_DiscretRoot::SetShape(const TopoDS_Shape& theShape)
+void BRepMesh_DiscretRoot::SetShape (const TopoDS_Shape& theShape)
 {
-  myShape=theShape;
+  myShape = theShape;
 }
+
 //=======================================================================
 //function : Shape
-//purpose  : 
+//purpose  :
 //=======================================================================
-const TopoDS_Shape& BRepMesh_DiscretRoot::Shape()const
+const TopoDS_Shape& BRepMesh_DiscretRoot::Shape() const
 {
   return myShape;
 }
+
 //=======================================================================
 //function : IsDone
-//purpose  : 
+//purpose  :
 //=======================================================================
-Standard_Boolean BRepMesh_DiscretRoot::IsDone()const 
+Standard_Boolean BRepMesh_DiscretRoot::IsDone() const
 {
   return myIsDone;
 }
+
 //=======================================================================
 //function : SetDone
-//purpose  : 
+//purpose  :
 //=======================================================================
-void BRepMesh_DiscretRoot::SetDone() 
+void BRepMesh_DiscretRoot::SetDone()
 {
-  myIsDone=Standard_True;
+  myIsDone = Standard_True;
 }
+
 //=======================================================================
 //function : SetNotDone
-//purpose  : 
+//purpose  :
 //=======================================================================
-void BRepMesh_DiscretRoot::SetNotDone() 
+void BRepMesh_DiscretRoot::SetNotDone()
 {
-  myIsDone=Standard_False;
+  myIsDone = Standard_False;
 }
+
 //=======================================================================
 //function : Init
-//purpose  : 
+//purpose  :
 //=======================================================================
-void BRepMesh_DiscretRoot::Init() 
+void BRepMesh_DiscretRoot::Init()
 {
-  
+  //
 }
diff --git a/src/BRepMesh/BRepMesh_FastDiscret.cdl b/src/BRepMesh/BRepMesh_FastDiscret.cdl
index 65b0059..60ba361 100644
--- a/src/BRepMesh/BRepMesh_FastDiscret.cdl
+++ b/src/BRepMesh/BRepMesh_FastDiscret.cdl
@@ -51,7 +51,8 @@ uses    Boolean                   from Standard,
         Curve                     from Geom2d,
         MapOfInteger              from BRepMesh,
         BaseAllocator             from BRepMesh,
-        DataMapOfFaceAttribute    from BRepMesh
+        DataMapOfFaceAttribute    from BRepMesh,
+        IndexedDataMapOfShapeListOfShape from TopTools
 
 
 is
@@ -92,7 +93,8 @@ is
         Perform (me: mutable; shape: Shape from TopoDS) is static;
         ---Purpose: Build triangulation on the whole shape
 
-        Add (me: mutable; face: Face from TopoDS) is static;
+        Add (me: mutable; face: Face from TopoDS;
+                          ancestor : IndexedDataMapOfShapeListOfShape from TopTools) is static;
         ---Purpose: Record a face for further processing.
 
         Process (me; face: Face from TopoDS) is static;
@@ -109,6 +111,7 @@ is
              face   : Face     from TopoDS;
              S      : HSurface from BRepAdaptor;
              C      : Curve    from Geom2d;
+             ancestor : IndexedDataMapOfShapeListOfShape from TopTools;
              defedge: Real     from Standard;
              first  : Real     from Standard;
              last   : Real     from Standard)
@@ -128,6 +131,18 @@ is
                 last   : Real     from Standard)     
         returns Boolean is private;
 
+        RelativeEdgeDeflection(myclass;
+                               edge    : Edge    from TopoDS;
+                               defle   : Real    from Standard;
+                               dtotale : Real    from Standard;
+                               cdef    : out Real    from Standard)
+        ---Purpose: Returns computed relative deflection for edge
+          returns Real from Standard;
+
+        BoxMaxDimension(myclass;
+                        box    : in Box from Bnd;
+                        maxdim : out Real from Standard);
+        ---Purpose: Returns the maximal dimension of Bnd_Box
 
         InternalVertices
                (me         : mutable;
@@ -153,6 +168,16 @@ is
                    defedge: Real from Standard)
         is static private;
 
+        SetParallel (           me : mutable;
+                     theInParallel : Boolean from Standard);
+        ---Purpose:
+        -- Request algorithm to launch in multiple threads
+        -- to improve performance (should be supported by plugin).
+
+        IsParallel (me)
+            returns Boolean from Standard;
+        ---Purpose:
+        -- Returns the multi-threading usage flag.
 
 -- Output :
 
@@ -281,6 +306,7 @@ fields
       myDeflection   : Real                          from Standard;
       myDtotale      : Real                          from Standard;
       myWithShare    : Boolean                       from Standard;
+      myInParallel   : Boolean                       from Standard;
       myVertices     : DataMapOfVertexInteger        from BRepMesh;
       myEdges        : DataMapOfShapePairOfPolygon   from BRepMesh;
       myInternaledges: DataMapOfShapePairOfPolygon   from BRepMesh;
diff --git a/src/BRepMesh/BRepMesh_FastDiscret.cxx b/src/BRepMesh/BRepMesh_FastDiscret.cxx
index 1ff089f..93fdcec 100644
--- a/src/BRepMesh/BRepMesh_FastDiscret.cxx
+++ b/src/BRepMesh/BRepMesh_FastDiscret.cxx
@@ -13,6 +13,7 @@
 #include <BRepMesh_PairOfPolygon.hxx>
 #include <BRepMesh_DataMapOfShapePairOfPolygon.hxx>
 #include <BRepMesh_DataMapIteratorOfDataMapOfShapePairOfPolygon.hxx>
+#include <Geom_Plane.hxx>
 #include <GeomAbs_IsoType.hxx>
 #include <GeomAbs_SurfaceType.hxx>
 #include <TopAbs.hxx>
@@ -77,16 +78,13 @@
 
 #include <vector>
 
-// NOTE: replaced by more correct check
-// #if defined(WNT) || defined(LIN)
-// #define HAVE_TBB 1
-// #endif
-
-// paralleling with Intel TBB
 #ifdef HAVE_TBB
-#include <tbb/parallel_for_each.h>
+  // paralleling using Intel TBB
+  #include <tbb/parallel_for_each.h>
 #endif
 
+#define UVDEFLECTION 1.e-05
+
 inline Standard_Real MaxFaceTol (const TopoDS_Face& theFace)
 {
   Standard_Real T, TMax = BRep_Tool::Tolerance(theFace);
@@ -119,21 +117,18 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real    theDefle,
                                            const Standard_Boolean theInshape,
                                            const Standard_Boolean theRelative,
                                            const Standard_Boolean theShapetrigu) :
-  myAngle(theAngl), myDeflection(theDefle),myWithShare(theWithShare),
-  myNbLocat(0), myRelative(theRelative), myShapetrigu(theShapetrigu), 
-  myInshape(theInshape)
+  myAngle (theAngl),
+  myDeflection (theDefle),
+  myWithShare (theWithShare),
+  myInParallel (Standard_False),
+  myNbLocat (0),
+  myRelative (theRelative),
+  myShapetrigu (theShapetrigu), 
+  myInshape (theInshape)
 {
   myAllocator = new NCollection_IncAllocator(64000);
-  if (theRelative)
-  {
-    Standard_Real TXmin, TYmin, TZmin, TXmax, TYmax, TZmax;
-    theBox.Get(TXmin, TYmin, TZmin, TXmax, TYmax, TZmax);
-    myDtotale = TXmax-TXmin;
-    const Standard_Real dy = TYmax-TYmin;
-    const Standard_Real dz = TZmax-TZmin;
-    if (dy > myDtotale) myDtotale = dy;
-    if (dz > myDtotale) myDtotale = dz;
-  }
+  if(myRelative)
+    BoxMaxDimension(theBox, myDtotale);
 }
 
 //=======================================================================
@@ -149,53 +144,119 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real    theDefle,
                                            const Standard_Boolean theInshape,
                                            const Standard_Boolean theRelative,
                                            const Standard_Boolean theShapetrigu): 
-  myAngle(theAngl), myDeflection(theDefle),myWithShare(theWithShare),
-  myNbLocat(0), myRelative(theRelative), myShapetrigu(theShapetrigu),
-  myInshape(theInshape)
+  myAngle (theAngl),
+  myDeflection (theDefle),
+  myWithShare (theWithShare),
+  myInParallel (Standard_False),
+  myNbLocat (0),
+  myRelative (theRelative),
+  myShapetrigu (theShapetrigu),
+  myInshape (theInshape)
 {
   myAllocator = new NCollection_IncAllocator(64000);
-  if (theRelative)
-  {
-    Standard_Real TXmin, TYmin, TZmin, TXmax, TYmax, TZmax;
-    theBox.Get(TXmin, TYmin, TZmin, TXmax, TYmax, TZmax);
-    myDtotale = TXmax-TXmin;
-    const Standard_Real dy = TYmax-TYmin;
-    const Standard_Real dz = TZmax-TZmin;
-    if (dy > myDtotale) myDtotale = dy;
-    if (dz > myDtotale) myDtotale = dz;
-  }
+  if(myRelative)
+    BoxMaxDimension(theBox, myDtotale);
   Perform(theShape);
 }
 
 //=======================================================================
+//function : SetParallel
+//purpose  :
+//=======================================================================
+void BRepMesh_FastDiscret::SetParallel (const Standard_Boolean theInParallel)
+{
+  myInParallel = theInParallel;
+}
+
+//=======================================================================
+//function : IsParallel
+//purpose  :
+//=======================================================================
+Standard_Boolean BRepMesh_FastDiscret::IsParallel() const
+{
+  return myInParallel;
+}
+
+//=======================================================================
+//function : BoxMaxDimension
+//purpose  : 
+//=======================================================================
+
+void BRepMesh_FastDiscret::BoxMaxDimension(const Bnd_Box& theBox, Standard_Real& theMaxDim)
+{
+  if(theBox.IsVoid())
+    return;
+  Standard_Real TXmin, TYmin, TZmin, TXmax, TYmax, TZmax;
+  theBox.Get(TXmin, TYmin, TZmin, TXmax, TYmax, TZmax);
+  theMaxDim = TXmax-TXmin;
+  const Standard_Real dy = TYmax-TYmin;
+  const Standard_Real dz = TZmax-TZmin;
+  if (dy > theMaxDim) theMaxDim = dy;
+  if (dz > theMaxDim) theMaxDim = dz;
+}
+
+//=======================================================================
+//function : RelativeEdgeDeflection
+//purpose  : 
+//=======================================================================
+
+Standard_Real BRepMesh_FastDiscret::RelativeEdgeDeflection(const TopoDS_Edge& theEdge,
+	                                          						   const Standard_Real theDefle,
+							                                             const Standard_Real theDTotale,
+                                                           Standard_Real& theDefCoef)
+{
+  theDefCoef = 1.;
+  Standard_Real defedge = theDefle;
+  if(theEdge.IsNull())
+    return defedge;
+
+  Bnd_Box B;
+  BRepBndLib::Add(theEdge, B);
+  BoxMaxDimension(B, defedge);
+            
+  // adjusted in relation to the total size:
+  theDefCoef = theDTotale/(2*defedge);
+  if (theDefCoef < 0.5) theDefCoef = 0.5;
+  if (theDefCoef > 2.) theDefCoef = 2.;
+  defedge = theDefCoef * defedge * theDefle;
+
+  return defedge;
+}
+
+//=======================================================================
 //function : Perform(shape)
 //purpose  : 
 //=======================================================================
 
 void BRepMesh_FastDiscret::Perform(const TopoDS_Shape& theShape)
 {
+  TopTools_IndexedDataMapOfShapeListOfShape anAncestors;
+  TopExp::MapShapesAndAncestors(theShape, TopAbs_EDGE, TopAbs_FACE, anAncestors);
   std::vector<TopoDS_Face> aFaces;
   for (TopExp_Explorer ex(theShape, TopAbs_FACE); ex.More(); ex.Next()) {
     TopoDS_Face aF = TopoDS::Face(ex.Current());
-    Add(aF);
+    Add(aF, anAncestors);
     aFaces.push_back(aF);
   }
-  
-  // mesh faces in parallel threads using TBB
-  if (Standard::IsReentrant())
+
+  if (myInParallel)
   {
-#ifdef HAVE_TBB
+  #ifdef HAVE_TBB
+    // mesh faces in parallel threads using TBB
     tbb::parallel_for_each (aFaces.begin(), aFaces.end(), *this);
-#else
+  #else
+    // alternative parallelization not yet available
     int i, n = aFaces.size();
 #pragma omp parallel for private(i)
     for (i = 0; i < n; ++i)
       Process (aFaces[i]);
-#endif
+  #endif
   }
   else
+  {
     for (std::vector<TopoDS_Face>::iterator it(aFaces.begin()); it != aFaces.end(); it++)
       Process (*it);
+  }
 }
 
 
@@ -228,7 +289,8 @@ void BRepMesh_FastDiscret::Process(const TopoDS_Face& theFace) const
   return;                            \
 }
 
-void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface)
+void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface,
+                               const TopTools_IndexedDataMapOfShapeListOfShape& theAncestors)
 {
 #ifndef DEB_MESH
   try
@@ -242,6 +304,14 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface)
   Handle(NCollection_IncAllocator) anAlloc = Handle(NCollection_IncAllocator)::DownCast(myAllocator);
   anAlloc->Reset(Standard_False);  
   myStructure=new BRepMesh_DataStructureOfDelaun(anAlloc);
+
+  Standard_Real aUmin, aVmin, aUmax, aVmax;
+  BRepTools::UVBounds (theface, aUmin, aUmax, aVmin, aVmax);
+  Standard_Real aTolU = (aUmax - aUmin) * UVDEFLECTION;
+  Standard_Real aTolV = (aVmax - aVmin) * UVDEFLECTION;
+  myStructure->Data().SetCellSize ( 14 * aTolU, 14 * aTolV );
+  myStructure->Data().SetTolerance( aTolU, aTolV );
+
   BRepAdaptor_Surface  BS(face, Standard_False);
   Handle(BRepAdaptor_HSurface) gFace = new BRepAdaptor_HSurface(BS);
   
@@ -266,7 +336,6 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface)
   i = 1;
 
   Standard_Real defedge, defface;
-  Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, dx, dy, dz;
   Standard_Integer nbEdge = 0;
   Standard_Real savangle = myAngle;
   Standard_Real cdef;
@@ -297,20 +366,7 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface)
             defedge = P->Deflection();
           }
           else {
-            Bnd_Box B;
-            BRepBndLib::Add(edge, B);
-            B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
-            dx = aXmax-aXmin;
-            dy = aYmax-aYmin;
-            dz = aZmax-aZmin;
-            defedge = dx;
-            if (defedge < dy) defedge = dy;
-            if (defedge < dz) defedge = dz;
-            // adjusted in relation to the total size:
-            cdef = myDtotale/(2*defedge);
-            if (cdef < 0.5) cdef = 0.5;
-            if (cdef > 2.) cdef = 2.;
-            defedge = cdef * defedge * myDeflection;
+            defedge = RelativeEdgeDeflection(edge, myDeflection, myDtotale, cdef);
             myAngle = savangle * cdef;
           }
           defface = defface + defedge;
@@ -319,7 +375,7 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface)
         else defedge = myDeflection;
     
         defedge = Max(maxdef, defedge);
-        defedge = Max(1.e-05 , defedge);
+        defedge = Max(UVDEFLECTION , defedge);
         myMapdefle.Bind(edge, defedge);
       }
       else{
@@ -334,7 +390,7 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface)
       aLSeq.Append(l1);
       aCSeq.Append(C);
       aShSeq.Append(edge);
-      Add(edge, face, gFace, C, defedge, f1, l1);
+      Add(edge, face, gFace, C, theAncestors, defedge, f1, l1);
       myAngle = savangle;
     }
   }
@@ -467,7 +523,7 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface)
           defedge = Max(defedge, eps);
           myMapdefle.Bind(edge, defedge);
           const Handle(Geom2d_Curve)& C = aCSeq.Value(j1);
-          Add(edge, face, gFace, C, defedge, aFSeq.Value(j1), aLSeq.Value(j1));
+          Add(edge, face, gFace, C, theAncestors, defedge, aFSeq.Value(j1), aLSeq.Value(j1));
         }
 
         classifier.Nullify();
@@ -506,7 +562,7 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface)
     BS.D0 (myumin, myvmin, P11);
     BS.D0 (myumin, dfvave, P21);
     BS.D0 (myumin, myvmax, P31);
-    for (i1=0, dfucur=myumin; i1 <= 20; i1++, dfucur+=du)  {
+    for (i1=1, dfucur=myumin+du; i1 <= 20; i1++, dfucur+=du)  {
       BS.D0 (dfucur, myvmin, P12);
       BS.D0 (dfucur, dfvave, P22);
       BS.D0 (dfucur, myvmax, P32);
@@ -519,7 +575,7 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface)
     BS.D0(myumin, myvmin, P11);
     BS.D0(dfuave, myvmin, P21);
     BS.D0(myumax, myvmin, P31);
-    for (i1=0, dfvcur=myvmin; i1 <= 20; i1++, dfvcur+=dv) {
+    for (i1=1, dfvcur=myvmin+dv; i1 <= 20; i1++, dfvcur+=dv) {    
       BS.D0 (myumin, dfvcur, P12);
       BS.D0 (dfuave, dfvcur, P22);
       BS.D0 (myumax, dfvcur, P32);
@@ -659,6 +715,59 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface)
   myStructure.Nullify();
 }
 
+//=======================================================================
+//function : splitSegment
+//purpose  :
+//=======================================================================
+static void splitSegment( BRepMesh_GeomTool&    theGT, 
+                          const Handle(Geom_Surface)& theSurf, 
+                          const Handle(Geom2d_Curve)& theCurve2d,
+                          const BRepAdaptor_Curve&    theBAC,
+                          const Standard_Real         theSquareEDef,
+                          const Standard_Real         theFirst,
+                          const Standard_Real         theLast,
+                          const Standard_Integer      theNbIter)
+{
+  //limit ineration depth
+  if(theNbIter > 10)
+    return;
+  gp_Pnt2d uvf, uvl, uvm;
+  gp_Pnt   P3dF, P3dL, midP3d, midP3dFromSurf;
+  Standard_Real midpar;
+  
+  if(Abs(theLast - theFirst) < 2*Precision::PConfusion())
+    return;
+
+  theCurve2d->D0(theFirst, uvf);
+  theCurve2d->D0(theLast, uvl);
+
+  P3dF = theSurf->Value(uvf.X(), uvf.Y());
+  P3dL = theSurf->Value(uvl.X(), uvl.Y());
+  
+  if(P3dF.SquareDistance(P3dL) < theSquareEDef)
+    return;
+
+  uvm = gp_Pnt2d((uvf.XY() + uvl.XY())*0.5);
+  midP3dFromSurf = theSurf->Value(uvm.X(), uvm.Y());
+
+  gp_XYZ aVec = P3dL.XYZ()-P3dF.XYZ();
+  aVec.Normalize();
+
+  gp_XYZ Vec1 = midP3dFromSurf.XYZ() - P3dF.XYZ();
+  Standard_Real aModulus = Vec1.Dot(aVec);
+  gp_XYZ aProj = aVec*aModulus;
+  gp_XYZ aDist = Vec1 - aProj;
+    
+  if(aDist.SquareModulus() < theSquareEDef)
+    return;
+
+  midpar = (theFirst + theLast) * 0.5;
+  theBAC.D0(midpar, midP3d);
+  theGT.AddPoint(midP3d, midpar, Standard_False);
+
+  splitSegment(theGT, theSurf, theCurve2d, theBAC, theSquareEDef, theFirst, midpar, theNbIter+1);
+  splitSegment(theGT, theSurf, theCurve2d, theBAC, theSquareEDef, midpar, theLast,  theNbIter+1); 
+}
 
 //=======================================================================
 //function : Add
@@ -668,6 +777,7 @@ void BRepMesh_FastDiscret::Add( const TopoDS_Edge&                  theEdge,
                                 const TopoDS_Face&                  theFace, 
                                 const Handle(BRepAdaptor_HSurface)& theGFace,
                                 const Handle(Geom2d_Curve)&         theC2d,
+                                const TopTools_IndexedDataMapOfShapeListOfShape& theAncestors,
                                 const Standard_Real                 theDefEdge,
                                 const Standard_Real                 theFirst,
                                 const Standard_Real                 theLast)
@@ -852,7 +962,8 @@ void BRepMesh_FastDiscret::Add( const TopoDS_Edge&                  theEdge,
       if (orEdge == TopAbs_INTERNAL) otherdefedge *= 0.5;
       
       BRepAdaptor_Curve cons;
-      if (BRep_Tool::SameParameter(theEdge))
+      Standard_Boolean isSameParam = BRep_Tool::SameParameter(theEdge);
+      if (isSameParam)
       {
         cons.Initialize(theEdge);
       }
@@ -878,10 +989,46 @@ void BRepMesh_FastDiscret::Add( const TopoDS_Edge&                  theEdge,
                      Standard_True);
       }
 
+      Standard_Integer i; 
+      Standard_Integer nbnodes = GT.NbPoints();
+      //Check deflection in 2d space for improvement of edge tesselation.
+      if( isSameParam && nbnodes > 1)
+      {
+        Standard_Real aSquareEdgeDef = otherdefedge * otherdefedge;
+        const TopTools_ListOfShape& lf = theAncestors.FindFromKey(theEdge);
+        TopTools_ListIteratorOfListOfShape itl(lf);
+        for (; itl.More(); itl.Next()) {
+          const TopoDS_Face& aFace = TopoDS::Face (itl.Value());          
+
+          TopLoc_Location aLoc;
+          Standard_Real aF, aL;
+          Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace, aLoc);
+          const Handle(Standard_Type)& aType = aSurf->DynamicType();
+          if(aType == STANDARD_TYPE(Geom_Plane))
+            continue;
+          Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(theEdge, aFace, aF, aL);
+          if(Abs(aF-wFirst)>Precision::PConfusion()||Abs(aL-wLast)>Precision::PConfusion())
+            continue;
+          
+          gp_Pnt2d uvf;
+          Standard_Real parf;
+          nbnodes = GT.NbPoints();
+          TColStd_Array1OfReal aParamArray(1, nbnodes);
+          for (i = 1; i <= nbnodes; i++)
+          {          
+            GT.Value(cons, theGFace, i, parf, P3d, uvf);            
+            aParamArray.SetValue(i, parf);
+          }
+          for (i = 1; i < nbnodes; i++)
+          {
+            splitSegment(GT, aSurf, aCurve2d, cons, aSquareEdgeDef, aParamArray(i), aParamArray(i+1), 1);
+          }
+        }
+      }
+
       // Creation of polygons on triangulation:
       Standard_Real puv;
-      Standard_Integer i;      
-      Standard_Integer nbnodes = GT.NbPoints();
+      nbnodes = GT.NbPoints();
 
       TColStd_Array1OfInteger Nodes(1, nbnodes);
       TColStd_Array1OfInteger NodInStruct(1, nbnodes);
diff --git a/src/BRepMesh/BRepMesh_FastDiscretFace.cxx b/src/BRepMesh/BRepMesh_FastDiscretFace.cxx
index 02068b5..2ae760a 100644
--- a/src/BRepMesh/BRepMesh_FastDiscretFace.cxx
+++ b/src/BRepMesh/BRepMesh_FastDiscretFace.cxx
@@ -41,6 +41,8 @@
 #include <GeomLib.hxx>
 #include <Bnd_Box2d.hxx>
 
+#define UVDEFLECTION 1.e-05
+
 static Standard_Real FUN_CalcAverageDUV(TColStd_Array1OfReal& P, const Standard_Integer PLen)
 {
   Standard_Integer i, j, n = 0;
@@ -112,6 +114,21 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face&                    theFace
     Handle(NCollection_IncAllocator) anAlloc = Handle(NCollection_IncAllocator)::DownCast(myAllocator);
     anAlloc->Reset(Standard_False);  
     myStructure=new BRepMesh_DataStructureOfDelaun(anAlloc);
+    
+    Standard_Real umax   = myAttrib->GetUMax();
+    Standard_Real umin   = myAttrib->GetUMin();
+    Standard_Real vmax   = myAttrib->GetVMax();
+    Standard_Real vmin   = myAttrib->GetVMin();
+
+    Standard_Real aTolU = (umax - umin) * UVDEFLECTION;
+    Standard_Real aTolV = (vmax - vmin) * UVDEFLECTION;
+    Standard_Real uCellSize = 14 * aTolU;
+    Standard_Real vCellSize = 14 * aTolV;
+
+    myStructure->Data().SetCellSize ( uCellSize, vCellSize );
+    myStructure->Data().SetTolerance( aTolU, aTolV );
+
+
     BRepAdaptor_Surface  BS(face, Standard_False);
     Handle(BRepAdaptor_HSurface) gFace = new BRepAdaptor_HSurface(BS);
     
@@ -165,10 +182,8 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face&                    theFace
     //Standard_Real longu = 0.0, longv = 0.0; //, last , first;
     //gp_Pnt P11, P12, P21, P22, P31, P32;
 
-    Standard_Real umax = myAttrib->GetUMax();
-    Standard_Real umin = myAttrib->GetUMin();
-    Standard_Real vmax = myAttrib->GetVMax();
-    Standard_Real vmin = myAttrib->GetVMin();
+    Standard_Real deltaX = myAttrib->GetDeltaX();
+    Standard_Real deltaY = myAttrib->GetDeltaY();
     
     TColStd_Array1OfInteger tabvert_corr(1, nbVertices);
     gp_Pnt2d p2d;
@@ -180,8 +195,11 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face&                    theFace
     myUParam.Clear(); 
     myVParam.Clear();
   
-    BRepMesh_IDMapOfNodeOfDataStructureOfDelaun aMoveNodes(myVemap.Extent());
+    BRepMesh_VertexTool aMoveNodes(myVemap.Extent(), myAllocator);
     
+    aMoveNodes.SetCellSize ( uCellSize / deltaX, vCellSize / deltaY);
+    aMoveNodes.SetTolerance( aTolU     / deltaX, aTolV     / deltaY);
+
     for (i = 1; i <= myStructure->NbNodes(); i++)
     {
       const BRepMesh_Vertex& v = myStructure->GetNode(i);
@@ -191,11 +209,11 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face&                    theFace
         myVParam.Add(p2d.Y());
       }
       gp_XY res;
-      res.SetCoord((p2d.X()-(myAttrib->GetMinX()))/(myAttrib->GetDeltaX()),
-                   (p2d.Y()-(myAttrib->GetMinY()))/(myAttrib->GetDeltaY()));
+      res.SetCoord((p2d.X() - umin ) / deltaX,
+                   (p2d.Y() - vmin ) / deltaY);
       BRepMesh_Vertex v_new(res,v.Location3d(),v.Movability());
       const BRepMesh_ListOfInteger& alist = myStructure->GetNodeList(i);
-      aMoveNodes.Add(v_new,alist);
+      aMoveNodes.Add(v_new, alist);
       tabvert_corr(i) = i;
     }
     myStructure->ReplaceNodes(aMoveNodes);
@@ -206,9 +224,6 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face&                    theFace
 
     switch (thetype)
     {
-    case GeomAbs_Plane:
-      rajout = !classifier->NaturalRestriction();
-      break;
     case GeomAbs_Sphere:
     case GeomAbs_Torus:
       rajout = Standard_True;
@@ -234,7 +249,7 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face&                    theFace
     }
 
     Standard_Boolean isaline;
-    isaline = ((umax-umin)<1.e-05) || ((vmax-vmin)<1.e-05);
+    isaline = ((umax-umin) < UVDEFLECTION) || ((vmax-vmin) < UVDEFLECTION);
     
     Standard_Real aDef = -1;
     if (!isaline && myStructure->ElemOfDomain().Extent() > 0) {
@@ -281,18 +296,17 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face&                    theFace
     }
 
     //modify myStructure back
-    aMoveNodes.Clear();
-    Standard_Real deltaX = myAttrib->GetDeltaX();
-    Standard_Real deltaY = myAttrib->GetDeltaY();
+    aMoveNodes.SetCellSize ( uCellSize, vCellSize );
+    aMoveNodes.SetTolerance( aTolU    , aTolV     );
     for (i = 1; i <= myStructure->NbNodes(); i++)
     {
       const BRepMesh_Vertex& v = myStructure->GetNode(i);
       p2d = v.Coord();
       gp_XY res;
-      res.SetCoord(p2d.X()*deltaX+umin,p2d.Y()*deltaY+vmin);
+      res.SetCoord(p2d.X() * deltaX + umin, p2d.Y() * deltaY + vmin);
       BRepMesh_Vertex v_new(res,v.Location3d(),v.Movability());
       const BRepMesh_ListOfInteger& alist = myStructure->GetNodeList(i);
-      aMoveNodes.Add(v_new,alist);
+      aMoveNodes.Add(v_new, alist);
     }
     myStructure->ReplaceNodes(aMoveNodes);
   
@@ -578,6 +592,28 @@ static void filterParameters(const TColStd_IndexedMapOfReal& theParams,
     isCandidateDefined = Standard_True;
   }
   theResult.Append(aParamTmp.Last());
+  
+  if( theResult.Length() == 2 )
+  {
+    Standard_Real    dist  = theResult.Last() - theResult.First();
+    Standard_Integer nbint = (Standard_Integer)((dist / theFilterDist) + 0.5);
+
+    if( nbint > 1 )
+    {
+      //Five points more is maximum
+      if( nbint > 5 )
+      {
+        nbint = 5;
+      }
+
+      Standard_Integer i;
+      Standard_Real dU = dist / nbint;
+      for( i = 1; i < nbint; i++ )
+      {
+        theResult.InsertAfter(i, theResult.First()+i*dU);
+      }
+    }
+  }
 }
 
 void BRepMesh_FastDiscretFace::InternalVertices(const Handle(BRepAdaptor_HSurface)& theCaro,
@@ -600,26 +636,9 @@ void BRepMesh_FastDiscretFace::InternalVertices(const Handle(BRepAdaptor_HSurfac
   Standard_Real deltaX = myAttrib->GetDeltaX();
   Standard_Real deltaY = myAttrib->GetDeltaY();
 
-  if (thetype == GeomAbs_Plane && !theClassifier->NaturalRestriction())
-  {
-    // rajout d`un seul point au milieu.
-    const Standard_Real U = 0.5*(umin+umax);
-    const Standard_Real V = 0.5*(vmin+vmax);
-    if (theClassifier->Perform(gp_Pnt2d(U, V)) == TopAbs_IN)
-    {
-      // Record 3d point
-      BRepMesh_GeomTool::D0(theCaro, U, V, p3d);
-      myNbLocat++;
-      myLocation3d.Bind(myNbLocat, p3d);
-      // Record 2d point
-      p2d.SetCoord((U-umin)/deltaX, (V-vmin)/deltaY);
-      newV.Initialize(p2d.XY(), myNbLocat, BRepMesh_Free);
-      theInternalV.Append(newV);
-    }
-  }
-  else if (thetype == GeomAbs_Sphere)
-  {
-    gp_Sphere S = BS.Sphere();
+  if (thetype == GeomAbs_Sphere)
+  { 
+    gp_Sphere S = BS.Sphere(); 
     const Standard_Real R = S.Radius();
 
     // Calculate parameters for iteration in V direction
diff --git a/src/BRepMesh/BRepMesh_IncrementalMesh.cdl b/src/BRepMesh/BRepMesh_IncrementalMesh.cdl
index 141413f..6d3016f 100644
--- a/src/BRepMesh/BRepMesh_IncrementalMesh.cdl
+++ b/src/BRepMesh/BRepMesh_IncrementalMesh.cdl
@@ -1,19 +1,18 @@
--- File:	BRepMesh_IncrementalMesh.cdl
--- Created:	Tue Jun 20 10:19:28 1995
--- Author:	Stagiaire Alain JOURDAIN
---		<ajo at phobox>
----Copyright:	 Matra Datavision 1995
-
+-- File:       BRepMesh_IncrementalMesh.cdl
+-- Created:    Tue Jun 20 10:19:28 1995
+-- Author:     Stagiaire Alain JOURDAIN <ajo at phobox>
+--
+---Copyright:  Matra Datavision 1995
 
 class IncrementalMesh from BRepMesh
-    	inherits DiscretRoot from BRepMesh 
-	
-       ---Purpose: Builds the mesh of a shape with respect of their
-       --          correctly triangulated parts
-       --  
 
+inherits DiscretRoot from BRepMesh
+
+    ---Purpose: Builds the mesh of a shape with respect of their
+    --          correctly triangulated parts
+    --
 
-uses   
+uses
     Box from Bnd,
     Shape from TopoDS,
     Face  from TopoDS,
@@ -21,77 +20,109 @@ uses
     MapOfShape  from TopTools,
     IndexedDataMapOfShapeListOfShape from TopTools,
     DataMapOfShapeReal from TopTools,
-    FastDiscret from BRepMesh,
-    Status      from BRepMesh
+    FastDiscret  from BRepMesh,
+    Status       from BRepMesh,
+    PDiscretRoot from BRepMesh
 
-is      
+is
     Create
-    	returns IncrementalMesh from BRepMesh;
+        returns IncrementalMesh from BRepMesh;
     ---C++: alias "Standard_EXPORT virtual ~BRepMesh_IncrementalMesh();"
-        
-    Create(S      : Shape   from TopoDS;
-    	   D      : Real    from Standard;
-    	   Relatif: Boolean from Standard = Standard_False;
-           Ang    : Real    from Standard = 0.5)
-	   ---Purpose: if the  boolean    <Relatif>   is  True,    the
-	   --          deflection used   for the polygonalisation   of
-	   --          each edge will be <D> * Size of Edge.
-	   --          the deflection used for the faces will be the maximum
-	   --          deflection of their edges.
-       returns IncrementalMesh from BRepMesh;
-
-    SetRelative(me:out;  
-    	    theFlag : Boolean from Standard); 
-      
-    Relative(me)  
-    	returns Boolean from Standard; 
-      
-    Init(me:out) 
-    	is redefined protected;  
-     
-    Perform(me:out) 
-    	is redefined; 
-     
-    Update(me:out;  
-    	    S : Shape from TopoDS)
-	    ---Purpose: Builds the incremental mesh of the shape
-       is static; 
-       
-    IsModified(me) returns Boolean from Standard
-       is static; 
-     
-    Update(me : in out;
-    	      E  : Edge from TopoDS)
-	    ---Purpose: Locate a correct discretisation if it exists
-	    --          Set no one otherwise
-       is static private;
-     
-    Update(me : in out;
-    	      F  : Face from TopoDS) 
-            ---Purpose: if the face is  not correctly triangulated, or
-            --          if  one  of its edges  is  to be discretisated
-            --          correctly, the triangulation  of this face  is
-            --          built.
-    	is static private;
-      
-    GetStatusFlags(me)
-      returns Integer from Standard
-      is static;
-	
-      
+
+    Create (S       : Shape   from TopoDS;
+            D       : Real    from Standard;
+            Relatif : Boolean from Standard = Standard_False;
+            Ang     : Real    from Standard = 0.5)
+        returns IncrementalMesh from BRepMesh;
+    ---Purpose: If the  boolean    <Relatif>   is  True,    the
+    --          deflection used   for the polygonalisation   of
+    --          each edge will be <D> * Size of Edge.
+    --          the deflection used for the faces will be the maximum
+    --          deflection of their edges.
+
+    SetRelative (     me : mutable;
+                 theFlag : Boolean from Standard);
+
+    Relative (me)
+        returns Boolean from Standard;
+
+    Init (me : mutable)
+        is redefined protected;
+
+    Perform (me : mutable)
+        is redefined;
+
+    Update (me : mutable;
+             S : Shape from TopoDS)
+        is static;
+    ---Purpose: Builds the incremental mesh of the shape
+
+    IsModified (me)
+        returns Boolean from Standard
+        is static;
+
+    Update (me : mutable;
+            E  : Edge from TopoDS)
+        is static private;
+    ---Purpose: Locate a correct discretisation if it exists
+    --          Set no one otherwise
+
+    Update (me : mutable;
+            F  : Face from TopoDS)
+        is static private;
+    ---Purpose: If the face is  not correctly triangulated, or
+    --          if  one  of its edges  is  to be discretisated
+    --          correctly, the triangulation  of this face  is
+    --          built.
+
+    GetStatusFlags (me)
+        returns Integer from Standard
+        is static;
+
+    SetParallel (           me : mutable;
+                 theInParallel : Boolean from Standard);
+    ---Purpose:
+    -- Request algorithm to launch in multiple threads to improve performance.
+
+    IsParallel (me)
+        returns Boolean from Standard;
+    ---Purpose:
+    -- Returns the multi-threading usage flag.
+
+    --
+    --  Plugin interface
+    --
+    Discret (myclass;
+             theShape      : Shape from TopoDS;
+             theDeflection : Real from Standard;
+             theAngle      : Real from Standard;
+             theAlgo       : out PDiscretRoot from BRepMesh)
+        returns Integer from Standard;
+    ---Purpose:
+    -- Plugin interface for the Mesh Factories.
+
+    IsParallelDefault (myclass)
+        returns Boolean from Standard;
+    ---Purpose:
+    -- Returns multi-threading usage flag set by default in
+    -- Discret() static method (thus applied only to Mesh Factories).
+
+    SetParallelDefault (myclass;
+                        theInParallel : Boolean from Standard);
+    ---Purpose:
+    -- Setup multi-threading usage flag set by default in
+    -- Discret() static method (thus applied only to Mesh Factories).
+
 fields
     myRelative   : Boolean     from Standard is protected;
+    myInParallel : Boolean     from Standard is protected;
     myMap        : MapOfShape  from TopTools is protected;
     myMesh       : FastDiscret from BRepMesh is protected;
     myModified   : Boolean     from Standard is protected;
-    mymapedge    : DataMapOfShapeReal from TopTools is protected; 
+    mymapedge    : DataMapOfShapeReal from TopTools is protected;
     myancestors  : IndexedDataMapOfShapeListOfShape from TopTools is protected;
     mydtotale    : Real from Standard is protected;
     myBox        : Box  from Bnd is protected;
     myStatus     : Integer from Standard is protected;
 
 end IncrementalMesh;
-
-
-
-
diff --git a/src/BRepMesh/BRepMesh_IncrementalMesh.cxx b/src/BRepMesh/BRepMesh_IncrementalMesh.cxx
index ee8a9c2..b74b052 100644
--- a/src/BRepMesh/BRepMesh_IncrementalMesh.cxx
+++ b/src/BRepMesh/BRepMesh_IncrementalMesh.cxx
@@ -10,6 +10,7 @@
 #include <BRepMesh_Edge.hxx>
 #include <BRepMesh_Triangle.hxx>
 #include <BRepMesh_FastDiscretFace.hxx>
+#include <BRepMesh_PluginMacro.hxx>
 
 #include <Bnd_Box.hxx>
 #include <BRep_Builder.hxx>
@@ -36,24 +37,27 @@
 
 #include <vector>
 
-// NOTE: to be replaced by more correct check
-// #if defined(WNT) || defined(LIN)
-// #define HAVE_TBB 1
-// #endif
-
-// paralleling with Intel TBB
 #ifdef HAVE_TBB
-#include <tbb/parallel_for_each.h>
+  // paralleling using Intel TBB
+  #include <tbb/parallel_for_each.h>
 #endif
 
+namespace
+{
+  //! Default flag to control parallelization for BRepMesh_IncrementalMesh
+  //! tool returned for Mesh Factory
+  static Standard_Boolean IS_IN_PARALLEL = Standard_False;
+};
+
 //=======================================================================
 //function : BRepMesh_IncrementalMesh
 //purpose  : 
 //=======================================================================
 BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh() 
-: myRelative(Standard_False),
-  myModified(Standard_False),
-  myStatus(0)
+: myRelative (Standard_False),
+  myInParallel (Standard_False),
+  myModified (Standard_False),
+  myStatus (0)
 {
   mymapedge.Clear();
   myancestors.Clear();
@@ -63,24 +67,23 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
 //function : BRepMesh_IncrementalMesh
 //purpose  : 
 //=======================================================================
-
-BRepMesh_IncrementalMesh::
-BRepMesh_IncrementalMesh(const TopoDS_Shape& S,
-			 const Standard_Real D,
-			 const Standard_Boolean Rel,
-			 const Standard_Real Ang) :
-			 myRelative(Rel),
-			 myModified(Standard_False),
-                         myStatus(0)
+BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape,
+                                                    const Standard_Real theDeflection,
+                                                    const Standard_Boolean theRelative,
+                                                    const Standard_Real theAngle)
+: myRelative (theRelative),
+  myInParallel (Standard_False),
+  myModified (Standard_False),
+  myStatus (0)
 {
   mymapedge.Clear();
   myancestors.Clear();
-  myDeflection = D;
-  myAngle = Ang;
-  myShape = S;
-  
+  myDeflection = theDeflection;
+  myAngle = theAngle;
+  myShape = theShape;
+
   //
-  Perform(); 
+  Perform();
 }
 
 //=======================================================================
@@ -92,6 +95,24 @@ BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
 }
 
 //=======================================================================
+//function : SetParallel
+//purpose  :
+//=======================================================================
+void BRepMesh_IncrementalMesh::SetParallel (const Standard_Boolean theInParallel)
+{
+  myInParallel = theInParallel;
+}
+
+//=======================================================================
+//function : IsParallel
+//purpose  :
+//=======================================================================
+Standard_Boolean BRepMesh_IncrementalMesh::IsParallel() const
+{
+  return myInParallel;
+}
+
+//=======================================================================
 //function : Init
 //purpose  : 
 //=======================================================================
@@ -173,25 +194,17 @@ Standard_Integer BRepMesh_IncrementalMesh::GetStatusFlags() const
 //purpose  : Builds the incremental mesh of the shape
 //=======================================================================
 void BRepMesh_IncrementalMesh::Update(const TopoDS_Shape& S)
-				  
 {
   myModified = Standard_False;
   TopExp_Explorer ex;
 
-  Standard_Real TXmin, TYmin, TZmin, TXmax, TYmax, TZmax;
-  Standard_Real dx, dy, dz;
-
   //AGV 080407: Since version 6.2.0 there would be exception without this check
   if (myBox.IsVoid())
     return;
+
+  TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, myancestors);
   
-  myBox.Get(TXmin, TYmin, TZmin, TXmax, TYmax, TZmax);
-  dx = TXmax-TXmin;
-  dy = TYmax-TYmin;
-  dz = TZmax-TZmin;
-  mydtotale = dx;
-  if (dy > mydtotale) mydtotale = dy;
-  if (dz > mydtotale) mydtotale = dz;
+  BRepMesh_FastDiscret::BoxMaxDimension(myBox, mydtotale);
   
   for (ex.Init(S, TopAbs_EDGE); ex.More(); ex.Next()) {
     if(BRep_Tool::IsGeometric(TopoDS::Edge(ex.Current()))) {
@@ -218,27 +231,29 @@ void BRepMesh_IncrementalMesh::Update(const TopoDS_Shape& S)
     aFaces.push_back (F);
   }
 
-  // mesh faces in parallel threads using TBB
-  if (Standard::IsReentrant())
+  if (myInParallel)
   {
-#ifdef HAVE_TBB
+  #ifdef HAVE_TBB
+    // mesh faces in parallel threads using TBB
     tbb::parallel_for_each (aFaces.begin(), aFaces.end(), *myMesh.operator->());
-#else
+  #else
     int i, n = aFaces.size();
 #pragma omp parallel for private(i)
     for (i = 0; i < n; ++i)
       myMesh->Process (aFaces[i]);
-#endif
+  #endif
   }
   else
+  {
     for (std::vector<TopoDS_Face>::iterator it(aFaces.begin()); it != aFaces.end(); it++)
       myMesh->Process (*it);
+  }
 
   // maillage des edges non contenues dans les faces :
   Standard_Real f, l, defedge;
   Standard_Integer i, nbNodes;
   TopLoc_Location L;
-  Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+  Standard_Real cdef = 1.;
   ex.Init(S ,TopAbs_EDGE, TopAbs_FACE);
 
   while (ex.More()) {
@@ -249,23 +264,11 @@ void BRepMesh_IncrementalMesh::Update(const TopoDS_Shape& S)
       continue;
     }
 
-    if (myRelative) {
-      Bnd_Box B;
-      BRepBndLib::Add(E, B);
-      B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
-      dx = aXmax-aXmin;
-      dy = aYmax-aYmin;
-      dz = aZmax-aZmin;
-      defedge = dx;
-      if (defedge < dy) defedge = dy;
-      if (defedge < dz) defedge = dz;
-      // ajustement par rapport a la taille totale:
-      Standard_Real cdef = mydtotale/(2*defedge);
-      if (cdef < 0.5) cdef = 0.5;
-      if (cdef > 2.) cdef = 2.;
-      defedge = cdef * defedge * myDeflection;
-    }
-    else defedge = myDeflection;
+    if (myRelative) 
+      defedge = BRepMesh_FastDiscret::RelativeEdgeDeflection(E, myDeflection, 
+                                                             mydtotale, cdef);
+    else 
+      defedge = myDeflection;
     
     Handle(Poly_Polygon3D) P3D = BRep_Tool::Polygon3D(E, L);
     Standard_Boolean maill = Standard_False;
@@ -286,8 +289,8 @@ void BRepMesh_IncrementalMesh::Update(const TopoDS_Shape& S)
       TColgp_Array1OfPnt Nodes(1, nbNodes);
       TColStd_Array1OfReal UVNodes(1, nbNodes);
       for ( i = 1; i <= nbNodes; i++) {
-	Nodes(i) = TD.Value(i);
-	UVNodes(i) = TD.Parameter(i);
+        Nodes(i) = TD.Value(i);
+        UVNodes(i) = TD.Parameter(i);
       }
       
       BRep_Builder B;
@@ -298,7 +301,8 @@ void BRepMesh_IncrementalMesh::Update(const TopoDS_Shape& S)
 
     ex.Next();
   }
-}    
+}
+
 //=======================================================================
 //function : Update(edge)
 //purpose  : Locate a correct discretisation if it exists
@@ -312,6 +316,7 @@ void BRepMesh_IncrementalMesh::Update(const TopoDS_Edge& E)
   Handle(Poly_PolygonOnTriangulation) Poly, NullPoly;
   Standard_Boolean found = Standard_False;
   Standard_Real defedge = Precision::Confusion();
+  Standard_Real cdef = 1.;
   BRep_Builder B;
   Standard_Boolean defined = Standard_False;
   
@@ -320,33 +325,20 @@ void BRepMesh_IncrementalMesh::Update(const TopoDS_Edge& E)
     i++;
     if (!T.IsNull() && !Poly.IsNull()) {
       if (!defined) {
-	if (myRelative) {
-	  Bnd_Box aBox;
-	  BRepBndLib::Add(E, aBox);
-	  Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, dx, dy, dz;
-	  aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
-	  dx = aXmax-aXmin;
-	  dy = aYmax-aYmin;
-	  dz = aZmax-aZmin;
-	  defedge = dx;
-	  if (defedge < dy) defedge = dy;
-	  if (defedge < dz) defedge = dz;
-	  // ajustement par rapport a la taille totale:
-	  Standard_Real cdef = mydtotale/(2*defedge);
-	  if (cdef < 0.5) cdef = 0.5;
-	  if (cdef > 2.) cdef = 2.;
-	  defedge = cdef * defedge * myDeflection;
-	}
-	else defedge = myDeflection;
-	mymapedge.Bind(E, defedge);
-	defined = Standard_True;
+        if (myRelative) 
+          defedge = BRepMesh_FastDiscret::RelativeEdgeDeflection(E, myDeflection, 
+                                                                 mydtotale, cdef);
+        else 
+          defedge = myDeflection;
+        mymapedge.Bind(E, defedge);
+        defined = Standard_True;
       }
       if ((!myRelative && Poly->Deflection() <= 1.1*defedge) ||
-	  (myRelative && Poly->Deflection() <= 1.1*defedge)) 
-	found = Standard_True;
+          (myRelative && Poly->Deflection() <= 1.1*defedge)) 
+        found = Standard_True;
       else {
-	myModified = Standard_True;
-	B.UpdateEdge(E, NullPoly, T, l);
+        myModified = Standard_True;
+        B.UpdateEdge(E, NullPoly, T, l);
       }
     }
   } while (!Poly.IsNull());
@@ -376,7 +368,7 @@ void  BRepMesh_IncrementalMesh::Update(const TopoDS_Face& F)
   BRep_Builder B;
   TopExp_Explorer ex;
   
-  Standard_Real defedge, defface;
+  Standard_Real defedge, defface, cdef = 1.;
   Standard_Integer nbEdge = 0;
   if (myRelative) {
     defface = 0.;
@@ -385,25 +377,10 @@ void  BRepMesh_IncrementalMesh::Update(const TopoDS_Face& F)
       const TopoDS_Edge& edge = TopoDS::Edge(ex.Current());
       nbEdge++;
       if (mymapedge.IsBound(edge)) {
-	defedge = mymapedge(edge);
-      }
-      else {
-	Bnd_Box aBox;
-	BRepBndLib::Add(edge, aBox);
-	Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, dx, dy, dz;
-	aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
-	dx = aXmax-aXmin;
-	dy = aYmax-aYmin;
-	dz = aZmax-aZmin;
-	defedge = dx;
-	if (defedge < dy) defedge = dy;
-	if (defedge < dz) defedge = dz;
-	// ajustement par rapport a la taille totale:
-	Standard_Real cdef = mydtotale/(2*defedge);
-	if (cdef < 0.5) cdef = 0.5;
-	if (cdef > 2.) cdef = 2.;
-	defedge = cdef * defedge * myDeflection;
+        defedge = mymapedge(edge);
       }
+      else 
+        defedge = BRepMesh_FastDiscret::RelativeEdgeDeflection(edge, myDeflection, mydtotale, cdef);
       defface = defface + defedge;
     }
     if (nbEdge != 0) defface = defface / nbEdge;
@@ -414,18 +391,16 @@ void  BRepMesh_IncrementalMesh::Update(const TopoDS_Face& F)
 
   if (!T.IsNull()) {
     if ((!myRelative && T->Deflection() <= 1.1*defface) ||
-	(myRelative && T->Deflection() <= 1.1*defface)) {
-      for (ex.Init(F, TopAbs_EDGE);
-	   ex.More();
-	   ex.Next()) {
-	const TopoDS_Shape& E = ex.Current();
-	Poly = BRep_Tool::PolygonOnTriangulation(TopoDS::Edge(E), T, l);
-	if (Poly.IsNull() || myMap.Contains(E)) {
-	  WillBeTriangulated = Standard_True;
-	  // cas un peu special. la triangulation est bonne, mais
-	  // l'edge n'a pas de representation polygonalisee sur celle-ci.
-	  break;
-	}
+        (myRelative && T->Deflection() <= 1.1*defface)) {
+      for (ex.Init(F, TopAbs_EDGE); ex.More(); ex.Next()) {
+        const TopoDS_Shape& E = ex.Current();
+        Poly = BRep_Tool::PolygonOnTriangulation(TopoDS::Edge(E), T, l);
+        if (Poly.IsNull() || myMap.Contains(E)) {
+          WillBeTriangulated = Standard_True;
+          // cas un peu special. la triangulation est bonne, mais
+          // l'edge n'a pas de representation polygonalisee sur celle-ci.
+          break;
+        }
       }
     } 
     else WillBeTriangulated = Standard_True;
@@ -435,12 +410,12 @@ void  BRepMesh_IncrementalMesh::Update(const TopoDS_Face& F)
     myModified = Standard_True;
     if (!T.IsNull()) {
       for (ex.Init(F, TopAbs_EDGE); ex.More(); ex.Next()) {
-	B.UpdateEdge(TopoDS::Edge(ex.Current()), NullPoly, T, l);
-	myMap.Remove(ex.Current());
+        B.UpdateEdge(TopoDS::Edge(ex.Current()), NullPoly, T, l);
+        myMap.Remove(ex.Current());
       }
       B.UpdateFace(F, TNull);
     }
-    myMesh->Add(F);
+    myMesh->Add(F, myancestors);
     myStatus |= (Standard_Integer)(myMesh->CurrentFaceStatus());
     if (myMesh->CurrentFaceStatus() == BRepMesh_ReMesh) {
 #ifdef DEB_MESH
@@ -448,9 +423,7 @@ void  BRepMesh_IncrementalMesh::Update(const TopoDS_Face& F)
 #endif
 
       Standard_Integer index;
-      if( myancestors.Extent() < 1 )
-        TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,myancestors);
-
+      
       TopTools_MapOfShape MShape;
       MShape.Add(F);
 
@@ -488,7 +461,7 @@ void  BRepMesh_IncrementalMesh::Update(const TopoDS_Face& F)
                     }
                   }
                   B.UpdateFace(F2, TNull);
-                  myMesh->Add(F2);
+                  myMesh->Add(F2, myancestors);
                 }
               }
             }
@@ -498,3 +471,42 @@ void  BRepMesh_IncrementalMesh::Update(const TopoDS_Face& F)
     }
   }
 }
+
+//=======================================================================
+//function : Discret
+//purpose  :
+//=======================================================================
+Standard_Integer BRepMesh_IncrementalMesh::Discret (const TopoDS_Shape&    theShape,
+                                                    const Standard_Real    theDeflection,
+                                                    const Standard_Real    theAngle,
+                                                    BRepMesh_PDiscretRoot& theAlgo)
+{
+  BRepMesh_IncrementalMesh* anAlgo = new BRepMesh_IncrementalMesh();
+  anAlgo->SetDeflection (theDeflection);
+  anAlgo->SetAngle (theAngle);
+  anAlgo->SetShape (theShape);
+  anAlgo->SetParallel (IS_IN_PARALLEL);
+  theAlgo = anAlgo;
+  return 0; // no error
+}
+
+//=======================================================================
+//function : IsParallelDefault
+//purpose  :
+//=======================================================================
+Standard_Boolean BRepMesh_IncrementalMesh::IsParallelDefault()
+{
+  return IS_IN_PARALLEL;
+}
+
+//=======================================================================
+//function : Discret
+//purpose  :
+//=======================================================================
+void BRepMesh_IncrementalMesh::SetParallelDefault (const Standard_Boolean theInParallel)
+{
+  IS_IN_PARALLEL = theInParallel;
+}
+
+//! Export Mesh Plugin entry function
+DISCRETPLUGIN(BRepMesh_IncrementalMesh)
diff --git a/src/BRepMesh/BRepMesh_ListOfInteger.hxx b/src/BRepMesh/BRepMesh_ListOfInteger.hxx
deleted file mode 100644
index da0621d..0000000
--- a/src/BRepMesh/BRepMesh_ListOfInteger.hxx
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <NCollection_List.hxx>
-
-typedef NCollection_List<Standard_Integer> BRepMesh_ListOfInteger;
diff --git a/src/BRepMesh/BRepMesh_MapOfInteger.hxx b/src/BRepMesh/BRepMesh_MapOfInteger.hxx
deleted file mode 100644
index 3a0da42..0000000
--- a/src/BRepMesh/BRepMesh_MapOfInteger.hxx
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <NCollection_Map.hxx>
-
-typedef NCollection_Map<Standard_Integer> BRepMesh_MapOfInteger;
diff --git a/src/BRepMesh/BRepMesh_MapOfIntegerInteger.hxx b/src/BRepMesh/BRepMesh_MapOfIntegerInteger.hxx
deleted file mode 100644
index 8a0c51f..0000000
--- a/src/BRepMesh/BRepMesh_MapOfIntegerInteger.hxx
+++ /dev/null
@@ -1,12 +0,0 @@
-// File:        BRepMesh_MapOfIntegerInteger.hxx
-// Created:     Fri Jan 30 15:15:17 2009
-// Author:      Pavel DURANDIN (pdn)
-// Copyright:   Open CASCADE 2009
-
-#ifndef BRepMesh_MapOfIntegerInteger_HeaderFile
-#define BRepMesh_MapOfIntegerInteger_HeaderFile
-
-#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer, Standard_Integer> BRepMesh_MapOfIntegerInteger;
-
-#endif
diff --git a/src/BRepMesh/BRepMesh_PairOfIndex.hxx b/src/BRepMesh/BRepMesh_PairOfIndex.hxx
deleted file mode 100644
index e4646b9..0000000
--- a/src/BRepMesh/BRepMesh_PairOfIndex.hxx
+++ /dev/null
@@ -1,105 +0,0 @@
-// File:      BRepMesh_PairOfIndex.hxx
-// Created:   29.01.09 15:55:25
-// Author:    Pavel TELKOV
-// Copyright: Open CASCADE 2009
-
-/*
-* Purpose: This class represent pair of integer indices
-*          It is restricted to store more than two indices in it       
-*          This pair uses to store element indices connected to link
-*/ 
-
-#ifndef BRepMesh_PairOfIndex_HeaderFile
-#define BRepMesh_PairOfIndex_HeaderFile
-
-#include <Standard_OutOfRange.hxx>
-
-class BRepMesh_PairOfIndex
-{
-public:
-  BRepMesh_PairOfIndex()
-  { myIndx1 = myIndx2 = -1; }
-
-  BRepMesh_PairOfIndex(const BRepMesh_PairOfIndex& theOther)
-  {
-    myIndx1 = theOther.myIndx1;
-    myIndx1 = theOther.myIndx2;
-  }
-
-  //! Clear indices
-  void Clear()
-  {
-    myIndx1 = myIndx2 = -1;
-  }
-
-  //! append index (store first of last index of pair)
-  void Append(const Standard_Integer theIndx)
-  {
-    if ( myIndx1 < 0 )
-      myIndx1 = theIndx;
-    else
-    {
-      if ( myIndx2 >= 0 )
-        Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::Append, more than two index to store");
-      myIndx2 = theIndx;
-    }
-  }
-
-  //! prepend index (store first index)
-  void Prepend(const Standard_Integer theIndx)
-  {
-    if ( myIndx2 >= 0 )
-      Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::Append, more than two index to store");
-    myIndx2 = myIndx1;
-    myIndx1 = theIndx;
-  }
-
-  //! returns is pair not initialized by index
-  Standard_Boolean IsEmpty() const
-  {
-    return (myIndx1 < 0 /*optimisation && myIndx2 < 0*/);
-  }
-
-  //! returns numner of initialized indeces
-  Standard_Integer Extent() const
-  {
-    return (myIndx1 < 0 ? 0 : (myIndx2 < 0 ? 1 : 2));
-  }
-
-  //! returns first index from pair
-  Standard_Integer FirstIndex() const
-  {
-    return myIndx1;
-  }
-
-  //! returns last index
-  Standard_Integer LastIndex() const
-  {
-    return (myIndx2 < 0 ? myIndx1 : myIndx2);
-  }
-
-  Standard_Integer Index(const Standard_Integer theNum) const
-  {
-    return (theNum == 1 ? myIndx1 : myIndx2 /*(theNum == 2 ? myIndx2 : -1 )*/);
-  }
-
-  void SetIndex(const Standard_Integer theNum,
-    const Standard_Integer theIndex)
-  {
-    theNum == 1 ? myIndx1 = theIndex : myIndx2 = theIndex;
-  }
-
-  //! remove indicated
-  void RemoveIndex (const Standard_Integer theNum)
-  {
-    if ( theNum == 1 )
-      myIndx1 = myIndx2;
-    myIndx2 = -1;
-  }
-  //! fields
-private:
-  Standard_Integer myIndx1;
-  Standard_Integer myIndx2;
-};
-
-#endif
diff --git a/src/BRepMesh/BRepMesh_Status.hxx b/src/BRepMesh/BRepMesh_Status.hxx
deleted file mode 100644
index 338ec7d..0000000
--- a/src/BRepMesh/BRepMesh_Status.hxx
+++ /dev/null
@@ -1,18 +0,0 @@
-// File:        BRepMesh_Status.hxx
-// Created:     May 17 11:59:53 2011
-// Author:      Oleg AGASHIN
-// Copyright:   Open CASCADE SAS 2011
-
-#ifndef _BRepMesh_Status_HeaderFile
-#define _BRepMesh_Status_HeaderFile
-
-//! Discribes the wires discretisation. <br>
-enum BRepMesh_Status {
-BRepMesh_NoError              = 0x0,
-BRepMesh_OpenWire             = 0x1,
-BRepMesh_SelfIntersectingWire = 0x2,
-BRepMesh_Failure              = 0x4,
-BRepMesh_ReMesh               = 0x8
-};
-
-#endif
diff --git a/src/BRepMesh/BRepMesh_VertexInspector.cxx b/src/BRepMesh/BRepMesh_VertexInspector.cxx
new file mode 100644
index 0000000..70807bd
--- /dev/null
+++ b/src/BRepMesh/BRepMesh_VertexInspector.cxx
@@ -0,0 +1,102 @@
+// File:        BRepMesh_VertexInspector.cxx
+// Created:     Jun 1 18:32:12 2011
+// Author:      Oleg AGASHIN
+// Copyright:   Open CASCADE SAS 2011
+
+#include <gp_XY.hxx>
+#include <Precision.hxx>
+#include <BRepMesh_VertexInspector.hxx>
+#include <BRepMesh_Vertex.hxx>
+
+
+//=======================================================================
+//function : BRepMesh_VertexInspector
+//purpose  : Constructor
+//
+//=======================================================================
+
+BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp,
+                                                    const BRepMesh_BaseAllocator& theAlloc)
+                                                    : myTol(0,1),
+                                                    myResInd(theAlloc),
+                                                    myVertices(nbComp),
+                                                    myDelNodes(theAlloc)
+{
+  SetTolerance( Precision::Confusion() );
+}
+
+BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp,
+                                                    const Standard_Real    aTol,
+                                                    const BRepMesh_BaseAllocator& theAlloc)
+                                                    : myTol(0,1),
+                                                    myResInd(theAlloc),
+                                                    myVertices(nbComp),
+                                                    myDelNodes(theAlloc)
+{
+  SetTolerance( aTol );
+}
+
+BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp,
+                                                    const Standard_Real    aTolX,
+                                                    const Standard_Real    aTolY,
+                                                    const BRepMesh_BaseAllocator& theAlloc)
+                                                    : myTol(0,1),
+                                                    myResInd(theAlloc),
+                                                    myVertices(nbComp),
+                                                    myDelNodes(theAlloc)
+{
+  SetTolerance( aTolX, aTolY );
+}
+
+//=======================================================================
+//function : Inspect
+//purpose  : 
+//
+//=======================================================================
+NCollection_CellFilter_Action BRepMesh_VertexInspector::Inspect (const Standard_Integer theTarget)
+{
+  const BRepMesh_Vertex& aVertex = myVertices(theTarget-1);
+  if( aVertex.Movability() == BRepMesh_Deleted )
+  {
+    myDelNodes.Append(theTarget);
+    return CellFilter_Purge;
+  }
+  
+  const gp_XY& aPos = aVertex.Coord();
+  Standard_Real dx,dy;
+  dx = myCurrent.X() - aPos.X();
+  dy = myCurrent.Y() - aPos.Y();
+  
+  Standard_Boolean inTol;
+  if ( myTol(1) == 0. )
+  {
+    inTol = (dx*dx + dy*dy) <= myTol(0);
+  }
+  else
+  {
+    inTol = ( (dx*dx) <= myTol(0) ) && 
+            ( (dy*dy) <= myTol(1) );
+  }
+  if ( inTol )
+    myResInd.Append(theTarget);
+  return CellFilter_Keep;
+}
+
+//=======================================================================
+//function : Add
+//purpose  : 
+//
+//=======================================================================
+Standard_Integer BRepMesh_VertexInspector::Add(const BRepMesh_Vertex& theVertex)
+{
+  if( myDelNodes.IsEmpty() )
+  {
+    myVertices.Append(theVertex);
+    return myVertices.Length();
+  }
+  
+  Standard_Integer aNodeIndex = myDelNodes.First();
+  myVertices(aNodeIndex-1) = theVertex;
+  myDelNodes.RemoveFirst();
+  return aNodeIndex;
+}
diff --git a/src/BRepMesh/BRepMesh_VertexTool.cdl b/src/BRepMesh/BRepMesh_VertexTool.cdl
new file mode 100644
index 0000000..e041935
--- /dev/null
+++ b/src/BRepMesh/BRepMesh_VertexTool.cdl
@@ -0,0 +1,131 @@
+-- File:        BRepMesh_VertexTool.cdl
+-- Created:     Jun 2 11:35:21 2011
+-- Author:      Oleg AGASHIN
+---Copyright:   Open CASCADE SAS 2011
+
+
+class VertexTool from BRepMesh 
+
+  ---Purpose: Describes the data structure necessary for the
+  --          mesh algorithm and contains the vertices in UV space.
+
+  uses    Boolean from Standard,
+          Integer from Standard,
+          Real from Standard,
+          XY from gp,
+          ListOfInteger from BRepMesh,
+          VertexCellFilter from BRepMesh,
+          VertexInspector from BRepMesh,
+          BaseAllocator from BRepMesh,
+          Vertex from BRepMesh,
+          DataMapOfIntegerListOfInteger from BRepMesh,
+          Array1OfReal from TColStd
+
+  is      Create (theAlloc : in BaseAllocator from BRepMesh)
+          returns VertexTool from BRepMesh;
+
+
+          Create     (nbComp   : in Integer from Standard;
+                      theAlloc : in BaseAllocator from BRepMesh)
+             ---Purpose: Constructs a VertexTool with an  evaluation of the
+             --          number of vertices.
+             returns VertexTool from BRepMesh;
+
+          SetCellSize(me                 : in out;
+                      theSize            : in Real from Standard)
+            ---Purpose: Sets new size for cellfilter.
+            is static;
+            
+          SetCellSize(me                 : in out;
+                       theXSize            : in Real from Standard;
+                       theYSize            : in Real from Standard)
+             ---Purpose: Sets new size for cellfilter.
+             is static;
+
+          SetTolerance(me                 : in out;
+                      theTol            : in Real from Standard)
+            ---Purpose: Sets new size for cellfilter.
+            is static;
+            
+          SetTolerance(me                 : in out;
+                       theTolX            : in Real from Standard;
+                       theTolY            : in Real from Standard)
+             ---Purpose: Sets new size for cellfilter.
+             is static;
+
+          Add       (me       : in out;
+                     theVertex: in Vertex from BRepMesh;
+                     theParams: in ListOfInteger from BRepMesh)
+            ---Purpose: Adds a vertex to the tool.
+            returns Integer from Standard is static;
+
+          Add       (me       : in out;
+                     theVertex: in Vertex from BRepMesh)
+            ---Purpose: Adds a vertex to the tool.
+            returns Integer from Standard is static;
+
+          Delete   (me : in out; theIndex : Integer from Standard) 
+            ---Purpose: Deletes a vertex from the tool.
+            is static;
+
+          FindFromIndex   (me; theIndex : Integer from Standard)
+            ---Purpose: Returns data assigned to theIndex.
+            ---C++: alias operator() 
+            ---C++: return &
+            returns ListOfInteger from BRepMesh is static;
+          
+          FindKey   (me: out; theIndex: Integer from Standard)
+            ---Purpose: Selects the vertex by theIndex.
+            ---C++: return const &
+            returns Vertex from BRepMesh is static;
+            
+          FindIndex (me: out;
+	  	     theVertex: Vertex from BRepMesh)
+            ---Purpose: Returns an index of theVertex.
+            returns Integer from Standard is static;
+            
+          Extent    (me)
+            ---Purpose: Returns a number of vertices.
+            returns Integer from Standard is static;
+            
+          IsEmpty   (me)
+            ---Purpose: Returns True when the map contains no keys.
+            returns Boolean from Standard is static;
+          
+          Substitute(me: in out; Index: Integer from Standard;
+                     theVertex: Vertex from BRepMesh;
+                     theData  : ListOfInteger from BRepMesh)
+            ---Purpose: Substitutes vertex with Index on
+            --          theVertex with attributes theData.
+            is static;
+            
+          RemoveLast(me: out)
+            ---Purpose: Remove last node from the structure.
+            is static;
+            
+          GetListOfDelNodes(me)
+            ---Purpose: Returns the list with indexes of
+            --          vertices that have Movability attribute
+            --          equal to BRepMesh_Deleted and can be 
+            --          replaced with another node.
+            ---C++: return const &
+            returns ListOfInteger from BRepMesh
+            is static;
+            
+          ExpandPoint(me: in out;
+                      thePnt: in XY from gp;
+                      theMinPnt: out XY from gp;
+                      theMaxPnt: out XY from gp)
+            is static private;
+            
+          Statistics(me; S: in out OStream from Standard)
+            ---Purpose: Prints statistics.
+            is static;
+            
+  fields  myAllocator    : BaseAllocator from BRepMesh;
+          myCellFilter   : VertexCellFilter from BRepMesh;
+          mySelector     : VertexInspector from BRepMesh;
+          myLinksMap     : DataMapOfIntegerListOfInteger from BRepMesh;
+          myTol          : Array1OfReal from TColStd;
+
+end CircleTool;
diff --git a/src/BRepMesh/BRepMesh_VertexTool.cxx b/src/BRepMesh/BRepMesh_VertexTool.cxx
new file mode 100644
index 0000000..b0346c8
--- /dev/null
+++ b/src/BRepMesh/BRepMesh_VertexTool.cxx
@@ -0,0 +1,236 @@
+// File:        BRepMesh_VertexTool.cxx
+// Created:     Jun 2 10:19:12 2011
+// Author:      Oleg AGASHIN
+// Copyright:   Open CASCADE SAS 2011
+
+#include <BRepMesh_VertexTool.ixx>
+#include <gp_XY.hxx>
+#include <Precision.hxx>
+#include <BRepMesh_Vertex.hxx>
+#include <BRepMesh_VertexInspector.hxx>
+#include <BRepMesh_BaseAllocator.hxx>
+
+//=======================================================================
+//function : BRepMesh_VertexTool
+//purpose  : 
+//=======================================================================
+BRepMesh_VertexTool::BRepMesh_VertexTool(const BRepMesh_BaseAllocator& theAlloc)
+: myAllocator(theAlloc),
+  myCellFilter(0., myAllocator),
+  mySelector(64,myAllocator),
+  myTol(0,1)
+{
+  SetCellSize ( Precision::Confusion()+0.05*Precision::Confusion() );
+  SetTolerance( Precision::Confusion(), Precision::Confusion() );
+}
+
+//=======================================================================
+//function : BRepMesh_VertexTool
+//purpose  : 
+//=======================================================================
+BRepMesh_VertexTool::BRepMesh_VertexTool(const Standard_Integer        nbComp,
+                                         const BRepMesh_BaseAllocator& theAlloc)
+                                         : myAllocator(theAlloc),
+                                           myCellFilter(0., myAllocator),
+                                           mySelector(Max(nbComp,64),myAllocator),
+                                           myTol(0,1)
+{
+  SetCellSize ( Precision::Confusion()+0.05*Precision::Confusion() );
+  SetTolerance( Precision::Confusion(), Precision::Confusion() );
+}
+
+//=======================================================================
+//function : SetCellSize
+//purpose  : 
+//=======================================================================
+void BRepMesh_VertexTool::SetCellSize(const Standard_Real theSize)
+{
+  myCellFilter.Reset(theSize, myAllocator);
+  mySelector.Clear();
+}
+
+//=======================================================================
+//function : SetCellSize
+//purpose  : 
+//=======================================================================
+void BRepMesh_VertexTool::SetCellSize(const Standard_Real theXSize, 
+                                      const Standard_Real theYSize)
+{
+  Standard_Real aCellSize[2];
+  aCellSize[0] = theXSize;
+  aCellSize[1] = theYSize;
+  
+  myCellFilter.Reset(aCellSize, myAllocator);
+  mySelector.Clear();
+}
+
+//=======================================================================
+//function : SetTolerance
+//purpose  : 
+//=======================================================================
+void BRepMesh_VertexTool::SetTolerance(const Standard_Real theTol)
+{
+  mySelector.SetTolerance( theTol );
+  myTol(0) = theTol;
+  myTol(1) = theTol;
+}
+
+//=======================================================================
+//function : SetTolerance
+//purpose  : 
+//=======================================================================
+void BRepMesh_VertexTool::SetTolerance(const Standard_Real theTolX, const Standard_Real theTolY)
+{
+  mySelector.SetTolerance( theTolX, theTolY );
+  myTol(0) = theTolX;
+  myTol(1) = theTolY;
+}
+
+//=======================================================================
+//function : Add
+//purpose  : 
+//=======================================================================
+Standard_Integer BRepMesh_VertexTool::Add(const BRepMesh_Vertex& theVertex)
+{
+  Standard_Integer anIndex = FindIndex(theVertex);
+  if ( anIndex == 0 )
+  {
+    BRepMesh_ListOfInteger thelist(myAllocator);
+    anIndex = Add(theVertex, thelist);
+  }
+  return anIndex;
+}
+
+//=======================================================================
+//function : Add
+//purpose  : 
+//=======================================================================
+Standard_Integer BRepMesh_VertexTool::Add(const BRepMesh_Vertex& theVertex,
+                                          const BRepMesh_ListOfInteger& theParams)
+{
+  Standard_Integer anIndex = mySelector.Add(theVertex);
+  myLinksMap.Bind(anIndex, theParams);
+  gp_XY aMinPnt, aMaxPnt;
+  ExpandPoint(theVertex.Coord(), aMinPnt, aMaxPnt);
+  myCellFilter.Add(anIndex, aMinPnt, aMaxPnt);
+  return anIndex;
+}
+
+//=======================================================================
+//function : Delete
+//purpose  : 
+//=======================================================================
+void  BRepMesh_VertexTool::Delete(const Standard_Integer theIndex)
+{
+  BRepMesh_Vertex& aV = mySelector.GetVertex(theIndex);
+  gp_XY aMinPnt, aMaxPnt;
+  ExpandPoint(aV.Coord(), aMinPnt, aMaxPnt);
+  myCellFilter.Remove (theIndex, aMinPnt, aMaxPnt);
+  mySelector.Delete(theIndex);
+}
+
+//=======================================================================
+//function : RemoveLast
+//purpose  : 
+//=======================================================================
+void  BRepMesh_VertexTool::RemoveLast()
+{
+  Standard_Integer aIndex = mySelector.GetNbVertices();
+  Delete( aIndex );
+}
+
+//=======================================================================
+//function : GetListOfDelNodes
+//purpose  : 
+//=======================================================================
+const BRepMesh_ListOfInteger& BRepMesh_VertexTool::GetListOfDelNodes() const
+{
+  return mySelector.GetListOfDelNodes();
+}
+
+//=======================================================================
+//function : FindIndex
+//purpose  : 
+//=======================================================================
+Standard_Integer BRepMesh_VertexTool::FindIndex(const BRepMesh_Vertex& theVertex)
+{
+  mySelector.SetCurrent(theVertex.Coord());
+  myCellFilter.Inspect (theVertex.Coord(), mySelector);
+  return mySelector.GetCoincidentInd();
+}
+
+//=======================================================================
+//function : FindKey
+//purpose  : 
+//=======================================================================
+const BRepMesh_Vertex& BRepMesh_VertexTool::FindKey(const Standard_Integer theIndex)
+{
+  return mySelector.GetVertex(theIndex);
+}
+
+//=======================================================================
+//function : Substitute
+//purpose  : 
+//=======================================================================
+void BRepMesh_VertexTool::Substitute(const Standard_Integer Index,
+                                     const BRepMesh_Vertex& theVertex,
+                                     const BRepMesh_ListOfInteger& theData)
+{
+  BRepMesh_Vertex& aV = mySelector.GetVertex(Index);
+  gp_XY aMinPnt, aMaxPnt;
+  ExpandPoint(aV.Coord(), aMinPnt, aMaxPnt);
+  myCellFilter.Remove (Index, aMinPnt, aMaxPnt);
+  aV = theVertex;
+  ExpandPoint(aV.Coord(), aMinPnt, aMaxPnt);
+  myCellFilter.Add(Index, aMinPnt, aMaxPnt);
+  FindFromIndex(Index) = theData;
+}
+
+//=======================================================================
+//function : Extent
+//purpose  : 
+//=======================================================================
+Standard_Integer BRepMesh_VertexTool::Extent() const
+{
+  return mySelector.GetNbVertices();
+}
+
+//=======================================================================
+//function : IsEmpty
+//purpose  : 
+//=======================================================================
+Standard_Boolean BRepMesh_VertexTool::IsEmpty() const
+{
+  return mySelector.GetNbVertices() == 0;
+}
+
+//=======================================================================
+//function : FindFromIndex
+//purpose  : 
+//=======================================================================
+BRepMesh_ListOfInteger& BRepMesh_VertexTool::FindFromIndex(const Standard_Integer theIndex) const
+{
+  return (BRepMesh_ListOfInteger&) myLinksMap.Find(theIndex);
+}
+
+//=======================================================================
+//function : 
+//purpose  : 
+//=======================================================================
+void BRepMesh_VertexTool::ExpandPoint(const gp_XY& thePnt, gp_XY& theMinPnt, gp_XY& theMaxPnt)
+{
+  theMinPnt.SetX(thePnt.X() - myTol(0));
+  theMinPnt.SetY(thePnt.Y() - myTol(1));
+  theMaxPnt.SetX(thePnt.X() + myTol(0));
+  theMaxPnt.SetY(thePnt.Y() + myTol(1));
+}
+
+//=======================================================================
+//function : Statistics
+//purpose  : 
+//=======================================================================
+void BRepMesh_VertexTool::Statistics(Standard_OStream& S) const
+{
+  S <<"\nStructure Statistics\n---------------\n\n";
+  S <<"This structure has "<<mySelector.GetNbVertices()<<" Nodes\n\n";
+}
diff --git a/src/BRepMesh/FILES b/src/BRepMesh/FILES
index 8da01f5..6f7b781 100644
--- a/src/BRepMesh/FILES
+++ b/src/BRepMesh/FILES
@@ -1,3 +1,4 @@
+BRepMesh_PluginEntryType.hxx
 BRepMesh_PluginMacro.hxx
 BRepMesh_ClassifierPtr.hxx
 BRepMesh_CellFilter.hxx
@@ -8,4 +9,9 @@ BRepMesh_ListOfInteger.hxx
 BRepMesh_BaseAllocator.hxx
 BRepMesh_PairOfIndex.hxx
 BRepMesh_Status.hxx
+BRepMesh_CMPLRS.edl
+BRepMesh_VertexCellFilter.hxx
+BRepMesh_VertexInspector.hxx
+BRepMesh_VertexInspector.cxx
+BRepMesh_VectorOfVertex.hxx
 EXTERNLIB
diff --git a/src/BRepOffset/BRepOffset_Inter2d.cxx b/src/BRepOffset/BRepOffset_Inter2d.cxx
index de52542..376e601 100644
--- a/src/BRepOffset/BRepOffset_Inter2d.cxx
+++ b/src/BRepOffset/BRepOffset_Inter2d.cxx
@@ -1284,7 +1284,7 @@ static void ExtentEdge(const TopoDS_Edge& E,TopoDS_Edge& NE, const Standard_Real
       Standard_Real LastPar  = C3d->LastParameter();
       
       if (C3d->IsKind(STANDARD_TYPE(Geom_BoundedCurve)) &&
-	  FirstPar > anEf - a2Offset || LastPar < anEl + a2Offset)
+	  (FirstPar > anEf - a2Offset || LastPar < anEl + a2Offset))
 	{
 	  Handle(Geom_TrimmedCurve) aTrCurve = 
 	    new Geom_TrimmedCurve(C3d, FirstPar, LastPar);
diff --git a/src/BRepOffset/BRepOffset_MakeOffset.cxx b/src/BRepOffset/BRepOffset_MakeOffset.cxx
index 883bc13..437ad0a 100644
--- a/src/BRepOffset/BRepOffset_MakeOffset.cxx
+++ b/src/BRepOffset/BRepOffset_MakeOffset.cxx
@@ -2085,7 +2085,7 @@ void BRepOffset_MakeOffset::CorrectConicalFaces()
       {
 	Vfirst = -PI/2.; Vlast = p2d1.Y();
       }
-    TopoDS_Face NewSphericalFace = BRepLib_MakeFace(aSphSurf, Ufirst, Ulast, Vfirst, Vlast);
+    TopoDS_Face NewSphericalFace = BRepLib_MakeFace(aSphSurf, Ufirst, Ulast, Vfirst, Vlast, Precision::Confusion());
     TopoDS_Edge OldEdge;
     for (Explo.Init(NewSphericalFace, TopAbs_EDGE); Explo.More(); Explo.Next())
       {
diff --git a/src/BRepOffset/BRepOffset_Offset.cxx b/src/BRepOffset/BRepOffset_Offset.cxx
index b144937..9152386 100644
--- a/src/BRepOffset/BRepOffset_Offset.cxx
+++ b/src/BRepOffset/BRepOffset_Offset.cxx
@@ -1446,7 +1446,7 @@ void BRepOffset_Offset::Init(const TopoDS_Edge&  Edge,
   GeomFill_Pipe Pipe(CP,myOffset);
   Pipe.Perform();
 
-  BRepLib_MakeFace MF(Pipe.Surface());
+  BRepLib_MakeFace MF(Pipe.Surface(), Precision::Confusion());
   myFace = MF.Face();
 
   if ( Offset < 0.) myFace.Reverse();
diff --git a/src/BRepOffset/BRepOffset_Tool.cxx b/src/BRepOffset/BRepOffset_Tool.cxx
index 2c38930..c50db9b 100644
--- a/src/BRepOffset/BRepOffset_Tool.cxx
+++ b/src/BRepOffset/BRepOffset_Tool.cxx
@@ -377,7 +377,7 @@ static void BuildPCurves (const TopoDS_Edge&  E,
     {
       gp_Pnt fpoint = AC.Value( AC.FirstParameter() );
       gp_Pnt lpoint = AC.Value( AC.LastParameter() );
-      TopoDS_Face theFace = BRepLib_MakeFace( theSurf );
+      TopoDS_Face theFace = BRepLib_MakeFace( theSurf, Precision::Confusion() );
       Standard_Real U1 = 0., U2 = 0., TolProj = 1.e-4; //1.e-5;
       TopoDS_Edge theEdge;
       TopExp_Explorer Explo;
diff --git a/src/BRepSweep/BRepSweep_Rotation.cxx b/src/BRepSweep/BRepSweep_Rotation.cxx
index 75845ef..8389d3c 100644
--- a/src/BRepSweep/BRepSweep_Rotation.cxx
+++ b/src/BRepSweep/BRepSweep_Rotation.cxx
@@ -627,15 +627,61 @@ void  BRepSweep_Rotation::SetDirectingPCurve
 	       thePCurve);
 }
 
-
+//modified by NIZNHY-PKV Tue Jun 14 08:33:55 2011f
 //=======================================================================
 //function : DirectSolid
 //purpose  : 
 //=======================================================================
-
-TopAbs_Orientation BRepSweep_Rotation::DirectSolid
-  (const TopoDS_Shape& aGenS,
-   const Sweep_NumShape&)
+TopAbs_Orientation 
+  BRepSweep_Rotation::DirectSolid (const TopoDS_Shape& aGenS,
+				   const Sweep_NumShape&)
+{  // compare the face normal and the direction
+  Standard_Real aU1, aU2, aV1, aV2, aUx, aVx, aX, aMV2, aTol2, aTx;
+  TopAbs_Orientation aOr;
+  gp_Pnt aP;
+  gp_Vec du,dv;
+  BRepAdaptor_Surface surf(TopoDS::Face(aGenS));
+  //
+  aTol2=Precision::Confusion();
+  aTol2=aTol2*aTol2;
+  //
+  const gp_Pnt& aPAxeLoc=myAxe.Location();
+  const gp_Dir& aPAxeDir=myAxe.Direction();
+  //
+  aU1=surf.FirstUParameter();
+  aU2=surf.LastUParameter();
+  aV1=surf.FirstVParameter();
+  aV2=surf.LastVParameter();
+  //
+  aTx=0.5;
+  aUx=aTx*(aU1+aU2);
+  aVx=aTx*(aV1+aV2);
+  surf.D1(aUx, aVx, aP, du, dv);
+  //
+  gp_Vec aV(aPAxeLoc, aP);
+  aV.Cross(aPAxeDir);
+  aMV2=aV.SquareMagnitude();
+  if (aMV2<aTol2) {
+    aTx=0.43213918;
+    aUx=aU1*(1.-aTx)+aU2*aTx;
+    aVx=aV1*(1.-aTx)+aV2*aTx;
+    surf.D1(aUx, aVx, aP, du, dv);
+    aV.SetXYZ(aP.XYZ()-aPAxeLoc.XYZ());
+    aV.Cross(aPAxeDir);
+  }
+  //
+  aX = aV.DotCross(du, dv);
+  aOr = (aX > 0.) ? TopAbs_FORWARD : TopAbs_REVERSED;
+  return aOr;
+}
+/*
+//=======================================================================
+//function : DirectSolid
+//purpose  : 
+//=======================================================================
+TopAbs_Orientation 
+  BRepSweep_Rotation::DirectSolid (const TopoDS_Shape& aGenS,
+				   const Sweep_NumShape&)
 {
   // compare the face normal and the direction
   BRepAdaptor_Surface surf(TopoDS::Face(aGenS));
@@ -651,7 +697,8 @@ TopAbs_Orientation BRepSweep_Rotation::DirectSolid
   TopAbs_Orientation orient = (x > 0) ? TopAbs_FORWARD : TopAbs_REVERSED;
   return orient;
 }
-
+*/
+//modified by NIZNHY-PKV Tue Jun 14 08:33:59 2011t
 
 //=======================================================================
 //function : GGDShapeIsToAdd
diff --git a/src/BRepTest/BRepTest_CurveCommands.cxx b/src/BRepTest/BRepTest_CurveCommands.cxx
index bd65edd..45fc1e7 100644
--- a/src/BRepTest/BRepTest_CurveCommands.cxx
+++ b/src/BRepTest/BRepTest_CurveCommands.cxx
@@ -862,7 +862,7 @@ static Standard_Integer profile(Draw_Interpretor& di,
       S = BRepBuilderAPI_MakeFace(P,MW.Wire());
     else {
       BRepBuilderAPI_MakeFace MFace;
-      MFace.Init(Surface,Standard_False);
+      MFace.Init(Surface,Standard_False,Precision::Confusion());
       MFace.Add(MW.Wire());
       S = MFace.Face();
     }
@@ -1106,7 +1106,7 @@ static Standard_Integer bsplineprof(Draw_Interpretor& di,
       S = BRepBuilderAPI_MakeFace(P,MW.Wire());
     else {
       BRepBuilderAPI_MakeFace MFace;
-      MFace.Init(Surface,Standard_False);
+      MFace.Init(Surface,Standard_False,Precision::Confusion());
       MFace.Add(MW.Wire());
       S = MFace.Face();
     }
diff --git a/src/BRepTest/BRepTest_FillingCommands.cxx b/src/BRepTest/BRepTest_FillingCommands.cxx
index d12878f..081a082 100644
--- a/src/BRepTest/BRepTest_FillingCommands.cxx
+++ b/src/BRepTest/BRepTest_FillingCommands.cxx
@@ -314,7 +314,7 @@ static Standard_Integer gplate (Draw_Interpretor & ,Standard_Integer n,const cha
   
   Henri.Surface()->Bounds( Umin, Umax, Vmin, Vmax);
   
-  BRepBuilderAPI_MakeFace MF(Surf,Umin, Umax, Vmin, Vmax);
+  BRepBuilderAPI_MakeFace MF(Surf, Umin, Umax, Vmin, Vmax, Precision::Confusion());
   
   DBRep::Set(a[1],MF.Face());
   return 0;
diff --git a/src/BRepTest/BRepTest_OtherCommands.cxx b/src/BRepTest/BRepTest_OtherCommands.cxx
index a632c06..b6cccba 100644
--- a/src/BRepTest/BRepTest_OtherCommands.cxx
+++ b/src/BRepTest/BRepTest_OtherCommands.cxx
@@ -327,6 +327,50 @@ static Standard_Integer MakeShell(Draw_Interpretor& , Standard_Integer , const c
   return 0;
 }
 
+//=======================================================================
+//function : xbounds
+//purpose  : 
+//=======================================================================
+Standard_Integer xbounds(Draw_Interpretor& di, Standard_Integer n, const char** a)
+{
+  if (n<2) {
+    di << "Usage : " << a[0] << " face" << "\n";
+    return 0;
+  }
+  //
+ 
+  Standard_Real aUMin, aUMax, aVMin, aVMax;
+  TopoDS_Shape aS;
+  TopoDS_Face aF;
+  //
+  aS=DBRep::Get(a[1]);
+  if (aS.IsNull()) {
+    di << " null shapes is not allowed here\n";
+    return 0;
+  }
+  if (aS.ShapeType()!=TopAbs_FACE) {
+    di << " shape" << a[1] <<" must be a face\n";
+    return 0;
+  }
+  //
+  aF=*((TopoDS_Face*)&aS);
+  //
+  BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
+  //
+  TCollection_AsciiString aStr;
+  TCollection_AsciiString sUMin(aUMin);
+  TCollection_AsciiString sUMax(aUMax);
+  TCollection_AsciiString sVMin(aVMin);
+  TCollection_AsciiString sVMax(aVMax);
+  //
+  aStr=aStr+sUMin + "\n";
+  aStr=aStr+sUMax + "\n";
+  aStr=aStr+sVMin + "\n";
+  aStr=aStr+sVMax + "\n";
+  di <<aStr.ToCString();
+  //
+  return 0;
+}
 
 //=======================================================================
 //function : OtherCommands
@@ -358,6 +402,10 @@ void  BRepTest::OtherCommands(Draw_Interpretor& theCommands)
   theCommands.Add("mksh",
 		  "create a shell on Shape", __FILE__, MakeShell, g);
 
+
+  theCommands.Add("xbounds",
+		  "xbounds face", __FILE__, xbounds, g);
+
 }
 
 
diff --git a/src/BRepTest/BRepTest_SurfaceCommands.cxx b/src/BRepTest/BRepTest_SurfaceCommands.cxx
index 2dd9411..88b7f8b 100644
--- a/src/BRepTest/BRepTest_SurfaceCommands.cxx
+++ b/src/BRepTest/BRepTest_SurfaceCommands.cxx
@@ -31,6 +31,7 @@
 #include <Geom_Surface.hxx>
 #include <Geom2d_TrimmedCurve.hxx>
 #include <TopTools_ListOfShape.hxx>
+#include <Precision.hxx>
 
 #ifdef WNT
 //#define strcasecmp strcmp Already defined
@@ -78,7 +79,7 @@ static Standard_Integer mkface(Draw_Interpretor& , Standard_Integer n, const cha
 
   if (n == 3) {
     if (mkface)
-      res = BRepBuilderAPI_MakeFace(S);
+      res = BRepBuilderAPI_MakeFace(S, Precision::Confusion());
     else
       res = BRepBuilderAPI_MakeShell(S,Segment);
   }
@@ -91,7 +92,7 @@ static Standard_Integer mkface(Draw_Interpretor& , Standard_Integer n, const cha
   }
   else {
     if (mkface)
-      res = BRepBuilderAPI_MakeFace(S,atof(a[3]),atof(a[4]),atof(a[5]),atof(a[6]));
+      res = BRepBuilderAPI_MakeFace(S,atof(a[3]),atof(a[4]),atof(a[5]),atof(a[6]),Precision::Confusion());
     else
       res = BRepBuilderAPI_MakeShell(S,atof(a[3]),atof(a[4]),atof(a[5]),atof(a[6]),
 			      Segment);
diff --git a/src/BRepTest/BRepTest_SweepCommands.cxx b/src/BRepTest/BRepTest_SweepCommands.cxx
index d07a40c..9b657e4 100644
--- a/src/BRepTest/BRepTest_SweepCommands.cxx
+++ b/src/BRepTest/BRepTest_SweepCommands.cxx
@@ -166,7 +166,7 @@ static Standard_Integer geompipe(Draw_Interpretor& ,
   Handle(Geom_Surface) Sur=aPipe.Surface();
   TopoDS_Face F;
   if(!Sur.IsNull())
-    F =BRepBuilderAPI_MakeFace(Sur);
+    F = BRepBuilderAPI_MakeFace(Sur, Precision::Confusion());
   DBRep::Set(a[1],F);
   return 0;
 }
diff --git a/src/BRepTools/BRepTools.cxx b/src/BRepTools/BRepTools.cxx
index 2a35177..f77dea8 100644
--- a/src/BRepTools/BRepTools.cxx
+++ b/src/BRepTools/BRepTools.cxx
@@ -674,9 +674,6 @@ Standard_Boolean  BRepTools::Write(const TopoDS_Shape& Sh,
 
   errno = 0;
   os.close();
-#ifdef DEB
-//  cout<<"!!!"<<strerror(errno)<<endl;
-#endif
   isGood = os.good() && isGood && !errno;
 
   return isGood;
diff --git a/src/BinLDrivers/BinLDrivers_DocumentStorageDriver.cdl b/src/BinLDrivers/BinLDrivers_DocumentStorageDriver.cdl
index 0d67539..dce6566 100644
--- a/src/BinLDrivers/BinLDrivers_DocumentStorageDriver.cdl
+++ b/src/BinLDrivers/BinLDrivers_DocumentStorageDriver.cdl
@@ -39,8 +39,6 @@ is
         is redefined virtual;
         ---Purpose: Write <theDocument> to the binary file <theFileName>
 
-    IsError           (me) returns Boolean from Standard;
-
     AttributeDrivers  (me : mutable; theMsgDriver: MessageDriver from CDM)
         returns ADriverTable from BinMDF
         is virtual;
@@ -93,7 +91,6 @@ fields
     myPAtt      :       Persistent              from BinObjMgt;
     myDrivers   :       ADriverTable            from BinMDF    is protected;
     myRelocTable:       SRelocationTable        from BinObjMgt is protected;
-    myIsError   :       Boolean                 from Standard  is protected;
     myMsgDriver :       MessageDriver           from CDM;
 
     -- labels not having writable attributes on it-self and on children
diff --git a/src/BinLDrivers/BinLDrivers_DocumentStorageDriver.cxx b/src/BinLDrivers/BinLDrivers_DocumentStorageDriver.cxx
index 01c9698..a5328d1 100644
--- a/src/BinLDrivers/BinLDrivers_DocumentStorageDriver.cxx
+++ b/src/BinLDrivers/BinLDrivers_DocumentStorageDriver.cxx
@@ -55,7 +55,9 @@ void BinLDrivers_DocumentStorageDriver::Write
                           (const Handle(CDM_Document)&       theDocument,
                            const TCollection_ExtendedString& theFileName)
 {
-  myIsError   = Standard_False;
+  SetIsError(Standard_False);
+  SetStoreStatus(PCDM_SS_OK);
+
   myMsgDriver = theDocument -> Application() -> MessageDriver();
   myMapUnsupported.Clear();
 
@@ -69,7 +71,8 @@ void BinLDrivers_DocumentStorageDriver::Write
   Handle(TDocStd_Document) aDoc =
     Handle(TDocStd_Document)::DownCast(theDocument);
   if (aDoc.IsNull()) {
-    myIsError = Standard_True;
+    SetIsError(Standard_True);
+    SetStoreStatus(PCDM_SS_Doc_IsNull);
   }
   else {
     // Open the file
@@ -84,8 +87,11 @@ void BinLDrivers_DocumentStorageDriver::Write
 //  1. Write info section (including types table)
     WriteInfoSection(theDocument, aFileName);
     myTypesMap.Clear();
-    if (myIsError)
-      return;
+    if (IsError())
+    {
+        SetStoreStatus(PCDM_SS_Info_Section_Error);
+        return;
+    }
 
 #if !defined(IRIX) // 10.10.2005
     ofstream anOS (aFileName.ToCString(), ios::in | ios::binary | ios::ate);
@@ -140,7 +146,9 @@ void BinLDrivers_DocumentStorageDriver::Write
 #ifdef DEB
         WriteMessage (aMethStr + "no objects written");
 #endif
-        myIsError = Standard_True;
+       SetIsError(Standard_True);
+       SetStoreStatus(PCDM_SS_No_Obj);
+
       }
       myRelocTable.Clear();
     }
@@ -156,7 +164,8 @@ void BinLDrivers_DocumentStorageDriver::Write
         anErrorStr + aMethStr + "Problem writing the file ";
       WriteMessage (aStr + theFileName);
 #endif
-      myIsError = Standard_True;
+      SetIsError(Standard_True);
+      SetStoreStatus(PCDM_SS_DiskWritingFailure);
     }
 
   }
@@ -259,16 +268,6 @@ void BinLDrivers_DocumentStorageDriver::WriteSubTree
 }
 
 //=======================================================================
-//function : IsError
-//purpose  :
-//=======================================================================
-
-Standard_Boolean BinLDrivers_DocumentStorageDriver::IsError () const
-{
-  return myIsError;
-}
-
-//=======================================================================
 //function : AttributeDrivers
 //purpose  :
 //=======================================================================
@@ -364,7 +363,7 @@ void BinLDrivers_DocumentStorageDriver::WriteInfoSection
     WriteMessage (TCollection_ExtendedString("Error: Cannot open file ") +
                   theFileName);
 #endif
-    myIsError = Standard_True;
+    SetIsError(Standard_True);
     return;
   }
 
@@ -424,7 +423,7 @@ void BinLDrivers_DocumentStorageDriver::WriteInfoSection
     WriteMessage(TCollection_ExtendedString("Error: Problem writing header "
                                             "into file ") + theFileName);
 #endif
-    myIsError = Standard_True;
+    SetIsError(Standard_True);
   }
 #ifdef DEB
     const Standard_Integer aP = (Standard_Integer) aFileDriver.Tell(); 
diff --git a/src/Bnd/Bnd_Box.cxx b/src/Bnd/Bnd_Box.cxx
index b69679c..705546a 100644
--- a/src/Bnd/Bnd_Box.cxx
+++ b/src/Bnd/Bnd_Box.cxx
@@ -2,7 +2,7 @@
 // Created:	Fri Mar  8 11:07:06 1991
 // Author:	Christophe MARION
 //		<cma at topsn3>
-
+//
 #include <Bnd_Box.ixx>
 
 #define VoidMask  0x01
@@ -748,7 +748,22 @@ Standard_Boolean Bnd_Box::IsOut (const gp_Lin& L) const
 //=======================================================================
 
 Standard_Boolean Bnd_Box::IsOut (const Bnd_Box& Other) const
-{
+{ 
+  //modified by NIZNHY-PKV Fri Jul 08 11:03:43 2011f
+  if (!Flags && !Other.Flags) {
+    Standard_Boolean bRet;
+    Standard_Real delta;
+    //
+    delta = Other.Gap + Gap;
+    bRet=((Xmin - Other.Xmax > delta) ||
+	  (Other.Xmin - Xmax > delta) ||
+	  (Ymin - Other.Ymax > delta) ||
+	  (Other.Ymin - Ymax > delta) ||
+	  (Zmin - Other.Zmax > delta) ||
+	  (Other.Zmin - Zmax > delta));
+    return bRet;
+  }
+  //modified by NIZNHY-PKV Fri Jul 08 11:03:46 2011t
   if   (IsVoid())         return Standard_True;
   if   (Other.IsVoid())   return Standard_True;
   if   (IsWhole())        return Standard_False;
diff --git a/src/Bnd/Bnd_Sphere.lxx b/src/Bnd/Bnd_Sphere.lxx
deleted file mode 100644
index 5e48d30..0000000
--- a/src/Bnd/Bnd_Sphere.lxx
+++ /dev/null
@@ -1,30 +0,0 @@
-
-inline Standard_Integer Bnd_Sphere::U() const
-{
-  return myU;
-}
-
-inline Standard_Integer Bnd_Sphere::V() const
-{
-  return myV;
-}
-
-inline Standard_Boolean Bnd_Sphere::IsValid() const
-{
-  return myIsValid;
-}
-
-inline void Bnd_Sphere::SetValid(const Standard_Boolean isValid)
-{
-  myIsValid = isValid;
-}
-
-inline const gp_XYZ& Bnd_Sphere::Center() const
-{ 
-  return myCenter; 
-}
-
-inline Standard_Real Bnd_Sphere::Radius() const
-{ 
-  return myRadius; 
-}
diff --git a/src/CDF/CDF.cdl b/src/CDF/CDF.cdl
index fe7ad66..4f90af0 100644
--- a/src/CDF/CDF.cdl
+++ b/src/CDF/CDF.cdl
@@ -22,22 +22,8 @@ is
     
     deferred class Application;
 
-
----Category: Store in Database related classes.
---           
     private class StoreList;
 
-    enumeration StoreStatus is  
-    SS_OK,  
-    SS_DriverFailure,  
-    SS_WriteFailure,  
-    SS_Failure
-    end StoreStatus from CDF;
-
-
----Category: Retrieve from Database related classes.
---           
-
 ---Category: API for Store and retrieve
 --           
     
@@ -46,30 +32,6 @@ is
     
     enumeration TryStoreStatus is TS_OK,TS_NoCurrentDocument,TS_NoDriver,TS_NoSubComponentDriver
     end TryStoreStatus;
-    
-    enumeration RetrievableStatus is  
-    RS_OK, 
-    RS_AlreadyRetrievedAndModified, 
-    RS_AlreadyRetrieved, 
-    RS_UnknownDocument, 
-    RS_NoDriver, 
-    RS_UnknownFileDriver, 
-    RS_WrongResource,
-    RS_OpenError,  
-    RS_NoVersion, 
-    RS_NoModel, 
-    RS_NoSchema, 
-    RS_NoDocument, 
-    RS_ExtensionFailure,
-    RS_WrongStreamMode, 
-    RS_FormatFailure, 
-    RS_TypeFailure,
-    RS_TypeNotFoundInSchema, 
-    RS_UnrecognizedFileFormat, 
-    RS_MakeFailure,	
-    RS_PermissionDenied, 
-    RS_DriverFailure
-    end RetrievableStatus;
 
     enumeration SubComponentStatus is SCS_Consistent, SCS_Unconsistent,SCS_Stored,SCS_Modified
     end SubComponentStatus;
@@ -105,4 +67,3 @@ is
     returns Boolean from Standard;
 
 end CDF;
-
diff --git a/src/CDF/CDF_Application.cdl b/src/CDF/CDF_Application.cdl
index 98a6b31..df3042c 100644
--- a/src/CDF/CDF_Application.cdl
+++ b/src/CDF/CDF_Application.cdl
@@ -12,7 +12,7 @@ uses
     Document from CDM,  
     Manager from Resource, 
     MetaData from CDM,  
-    RetrievableStatus  from CDF,  
+    ReaderStatus  from PCDM,  
     GUID from Standard, 
     Reader from PCDM,  
     Writer from PCDM, 
@@ -101,18 +101,18 @@ is
 
     CanRetrieve(me: mutable; aFolder, aName: ExtendedString from TCollection)
     ---Purpose:
-    returns RetrievableStatus from CDF;
+    returns ReaderStatus from PCDM;
     
     CanRetrieve(me: mutable; aFolder, aName, aVersion: ExtendedString from TCollection)
     ---Purpose:
-    returns RetrievableStatus from CDF;
+    returns ReaderStatus from PCDM;
        
     Formats(me: mutable; Formats: out SequenceOfExtendedString from TColStd) 
     is deferred;
 ---Category: CurrentDocument methods.
 --           
 
-    GetRetrieveStatus(me) returns RetrievableStatus from CDF; 
+    GetRetrieveStatus(me) returns ReaderStatus from PCDM; 
     ---C++: inline     
     ---Purpose: Checks  status  after  Retrieve 
      
@@ -200,12 +200,12 @@ is
     is private;
 
     CanRetrieve(me: mutable; aMetaData: MetaData from CDM)
-    returns RetrievableStatus from CDF
+    returns ReaderStatus from PCDM
     is private;
 fields
 
     myDefaultFolder: ExtendedString from TCollection; 
-    myRetrievableStatus :  RetrievableStatus from CDF  is protected; 
+    myRetrievableStatus :  ReaderStatus from PCDM  is protected; 
     
 friends 
     class Session from CDF--,
diff --git a/src/CDF/CDF_Application.cxx b/src/CDF/CDF_Application.cxx
index 9554798..0b71da2 100644
--- a/src/CDF/CDF_Application.cxx
+++ b/src/CDF/CDF_Application.cxx
@@ -15,11 +15,11 @@
 #include <CDF_Session.hxx>
 #include <CDF_Directory.hxx>
 #include <CDF_MetaDataDriver.hxx>
-#include <CDF_RetrievableStatus.hxx>
+#include <PCDM_ReaderStatus.hxx>
 #include <PCDM_ReadWriter.hxx>
 #include <PCDM_RetrievalDriver.hxx>
 #include <PCDM_StorageDriver.hxx>
-#include <PCDM_ReaderStatus.hxx>
+
 
 #include <Plugin.hxx>
 #include <UTL.hxx>
@@ -33,7 +33,7 @@
 //function : 
 //purpose  : 
 //=======================================================================
-CDF_Application::CDF_Application():myRetrievableStatus(CDF_RS_OK) {}
+CDF_Application::CDF_Application():myRetrievableStatus(PCDM_RS_OK) {}
 
 //=======================================================================
 //function : Load
@@ -128,7 +128,7 @@ Handle(CDM_Document)  CDF_Application::Retrieve(const TCollection_ExtendedString
 //function : CanRetrieve
 //purpose  : 
 //=======================================================================
-CDF_RetrievableStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString&  aName) {
+PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString&  aName) {
  TCollection_ExtendedString aVersion;
  return CanRetrieve(aFolder,aName,aVersion);
 }
@@ -137,16 +137,16 @@ CDF_RetrievableStatus CDF_Application::CanRetrieve(const TCollection_ExtendedStr
 //function : CanRetrieve
 //purpose  : 
 //=======================================================================
-CDF_RetrievableStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString&  aFolder, const TCollection_ExtendedString&  aName, const TCollection_ExtendedString&  aVersion) {
+PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString&  aFolder, const TCollection_ExtendedString&  aName, const TCollection_ExtendedString&  aVersion) {
   
 #ifdef DEB
   CDF_Timer theTimer;
 #endif
 
   if (!theMetaDataDriver->Find(aFolder,aName,aVersion))
-    return CDF_RS_UnknownDocument;
+    return PCDM_RS_UnknownDocument;
   else if (!theMetaDataDriver->HasReadPermission(aFolder,aName,aVersion))
-    return CDF_RS_PermissionDenied;
+    return PCDM_RS_PermissionDenied;
   else {
 #ifdef DEB
     theTimer.ShowAndRestart("theMetaDataDriver->Find: ");
@@ -160,7 +160,7 @@ CDF_RetrievableStatus CDF_Application::CanRetrieve(const TCollection_ExtendedStr
 
     if(theMetaData->IsRetrieved()) {
       return theMetaData->Document()->IsModified()
-	? CDF_RS_AlreadyRetrievedAndModified : CDF_RS_AlreadyRetrieved;
+	? PCDM_RS_AlreadyRetrievedAndModified : PCDM_RS_AlreadyRetrieved;
     }
     else {
       TCollection_ExtendedString theFileName=theMetaData->FileName();
@@ -172,12 +172,12 @@ CDF_RetrievableStatus CDF_Application::CanRetrieve(const TCollection_ExtendedStr
 	  theFormat=UTL::Value(Resources(),ResourceName);
 	}
 	else
-	  return CDF_RS_UnrecognizedFileFormat;
+	  return PCDM_RS_UnrecognizedFileFormat;
       }
-      if(!FindReaderFromFormat(theFormat)) return CDF_RS_NoDriver;
+      if(!FindReaderFromFormat(theFormat)) return PCDM_RS_NoDriver;
     }
   }
-  return CDF_RS_OK;
+  return PCDM_RS_OK;
   
 }
 
@@ -242,82 +242,24 @@ Handle(CDM_Document) CDF_Application::Retrieve(const Handle(CDM_MetaData)& aMeta
 } 
 
 //=======================================================================
-//function : ConvertStatus
-//purpose  : 
-//=======================================================================
-static CDF_RetrievableStatus ConvertStatus(const PCDM_ReaderStatus theStatus) {
-  CDF_RetrievableStatus aStatus;
-  switch(theStatus) {
-  case PCDM_RS_OK:
-    aStatus=CDF_RS_OK;
-    break;
-  case PCDM_RS_NoDriver:
-    aStatus=CDF_RS_NoDriver;
-    break;
-  case PCDM_RS_UnknownFileDriver:
-    aStatus=CDF_RS_UnknownFileDriver;
-    break;
-  case PCDM_RS_OpenError:
-    aStatus=CDF_RS_OpenError;
-    break;
-  case PCDM_RS_NoVersion:
-    aStatus=CDF_RS_NoVersion;
-    break;
-  case PCDM_RS_NoSchema:
-    aStatus=CDF_RS_NoSchema;
-    break;
-  case PCDM_RS_NoDocument:
-    aStatus=CDF_RS_NoDocument;
-    break;
-  case PCDM_RS_ExtensionFailure:
-    aStatus=CDF_RS_ExtensionFailure;
-    break;
-  case PCDM_RS_WrongStreamMode:
-    aStatus=CDF_RS_WrongStreamMode;
-    break;
-  case PCDM_RS_FormatFailure:
-    aStatus=CDF_RS_FormatFailure;
-    break;
-  case PCDM_RS_TypeFailure:
-    aStatus=CDF_RS_TypeFailure;
-    break;
-  case PCDM_RS_TypeNotFoundInSchema:
-    aStatus=CDF_RS_TypeNotFoundInSchema;
-    break;
-  case PCDM_RS_UnrecognizedFileFormat:
-    aStatus=CDF_RS_UnrecognizedFileFormat;
-    break;
-  case PCDM_RS_MakeFailure:
-    aStatus=CDF_RS_MakeFailure;
-    break;
-  case PCDM_RS_PermissionDenied:
-    aStatus=CDF_RS_PermissionDenied;
-    break;
-  default:
-    aStatus=CDF_RS_DriverFailure;    
-  }
-  return aStatus;
-}
-
-//=======================================================================
 //function : Retrieve
 //purpose  : 
 //=======================================================================
 Handle(CDM_Document) CDF_Application::Retrieve(const Handle(CDM_MetaData)& aMetaData,const Standard_Boolean UseStorageConfiguration, const Standard_Boolean IsComponent) {
   
   Handle(CDM_Document) theDocumentToReturn;
-  myRetrievableStatus = CDF_RS_DriverFailure;
+  myRetrievableStatus = PCDM_RS_DriverFailure;
   if(IsComponent) {
     Standard_SStream aMsg;
     switch (CanRetrieve(aMetaData)) {
-    case CDF_RS_UnknownDocument: 
+    case PCDM_RS_UnknownDocument: 
       aMsg << "could not find the referenced document: " << aMetaData->Path() << "; not found."  <<(char)0 << endl;
-      myRetrievableStatus = CDF_RS_UnknownDocument;
+      myRetrievableStatus = PCDM_RS_UnknownDocument;
       Standard_Failure::Raise(aMsg);
       break;
-    case CDF_RS_PermissionDenied:      
+    case PCDM_RS_PermissionDenied:      
       aMsg << "Could not find the referenced document: " << aMetaData->Path() << "; permission denied. " <<(char)0 << endl;
-      myRetrievableStatus = CDF_RS_PermissionDenied;
+      myRetrievableStatus = PCDM_RS_PermissionDenied;
       Standard_Failure::Raise(aMsg);
       break;
     default:
@@ -326,9 +268,9 @@ Handle(CDM_Document) CDF_Application::Retrieve(const Handle(CDM_MetaData)& aMeta
     
   }
   Standard_Boolean AlreadyRetrieved=aMetaData->IsRetrieved();
-  if(AlreadyRetrieved) myRetrievableStatus = CDF_RS_AlreadyRetrieved;
+  if(AlreadyRetrieved) myRetrievableStatus = PCDM_RS_AlreadyRetrieved;
   Standard_Boolean Modified=AlreadyRetrieved && aMetaData->Document()->IsModified();
-  if(Modified) myRetrievableStatus = CDF_RS_AlreadyRetrievedAndModified;
+  if(Modified) myRetrievableStatus = PCDM_RS_AlreadyRetrievedAndModified;
   if(!AlreadyRetrieved || Modified) {
 
     Handle(PCDM_Reader) theReader=Reader(aMetaData->FileName());
@@ -353,17 +295,14 @@ Handle(CDM_Document) CDF_Application::Retrieve(const Handle(CDM_MetaData)& aMeta
       theReader->Read(aMetaData->FileName(),theDocument,this);
     } 
     catch (Standard_Failure) {
-      PCDM_ReaderStatus aStatus = theReader->GetStatus();
-      myRetrievableStatus = ConvertStatus(aStatus);
-      if(myRetrievableStatus  > CDF_RS_AlreadyRetrieved){
+      myRetrievableStatus = theReader->GetStatus();
+      if(myRetrievableStatus  > PCDM_RS_AlreadyRetrieved){
 	Standard_SStream aMsg;
 	aMsg << Standard_Failure::Caught() << endl;
 	Standard_Failure::Raise(aMsg);
       }	
     }
-    PCDM_ReaderStatus aStatus = theReader->GetStatus();
-    myRetrievableStatus = ConvertStatus(aStatus);
-    
+    myRetrievableStatus = theReader->GetStatus();    
     theDocument->SetMetaData(aMetaData);
 
     theDocumentToReturn=theDocument;
@@ -451,7 +390,7 @@ Handle(PCDM_Reader) CDF_Application::ReaderFromFormat(const TCollection_Extended
   if(!FindReaderFromFormat(aFormat,thePluginId,UnfoundResourceName)) {
     Standard_SStream aMsg; 
     aMsg << "Could not found the item:" << UnfoundResourceName <<(char)0;
-    myRetrievableStatus = CDF_RS_WrongResource;
+    myRetrievableStatus = PCDM_RS_WrongResource;
     Standard_NoSuchObject::Raise(aMsg);
   } 
   Handle(PCDM_Reader) R;
@@ -460,7 +399,7 @@ Handle(PCDM_Reader) CDF_Application::ReaderFromFormat(const TCollection_Extended
     R = Handle(PCDM_Reader)::DownCast(Plugin::Load(thePluginId));  
   } 
   catch (Standard_Failure) {
-    myRetrievableStatus = CDF_RS_WrongResource;
+    myRetrievableStatus = PCDM_RS_WrongResource;
     Standard_SStream aMsg;
     aMsg << Standard_Failure::Caught() << endl;
     Standard_Failure::Raise(aMsg);
@@ -470,7 +409,7 @@ Handle(PCDM_Reader) CDF_Application::ReaderFromFormat(const TCollection_Extended
     RD->SetFormat(aFormat);
     return RD;
   } else 
-    myRetrievableStatus = CDF_RS_WrongResource;
+    myRetrievableStatus = PCDM_RS_WrongResource;
   return R;
 }
 
@@ -540,7 +479,7 @@ Standard_Boolean CDF_Application::FindReaderFromFormat(const TCollection_Extende
 //function : CanRetrieve
 //purpose  : 
 //=======================================================================
-CDF_RetrievableStatus CDF_Application::CanRetrieve(const Handle(CDM_MetaData)& aMetaData) {
+PCDM_ReaderStatus CDF_Application::CanRetrieve(const Handle(CDM_MetaData)& aMetaData) {
   if(aMetaData->HasVersion())
     return CanRetrieve(aMetaData->Folder(),aMetaData->Name(),aMetaData->Version());
   else
diff --git a/src/CDF/CDF_Store.cdl b/src/CDF/CDF_Store.cdl
index a811ef0..ef9a05c 100644
--- a/src/CDF/CDF_Store.cdl
+++ b/src/CDF/CDF_Store.cdl
@@ -12,7 +12,7 @@ uses Document from CDM,
      SubComponentStatus from CDF,
      ExtendedString from TCollection,
      StoreList from CDF,
-     StoreStatus from CDF,
+     StoreStatus from PCDM,
      ExtendedString from TCollection
     
 is
@@ -148,7 +148,7 @@ is
 --           be used just after Realize  or Import --  method to know if
 --           thes methods worked correctly, and if not why.
 
-    StoreStatus(me) returns StoreStatus from CDF;
+    StoreStatus(me) returns StoreStatus from PCDM;
     AssociatedStatusText(me) returns ExtString from Standard;
 
     ---Category: Private methods
@@ -181,7 +181,7 @@ fields
 
     myPath: ExtendedString from TCollection;
     myText: ExtendedString from TCollection;
-    myStatus: StoreStatus from CDF;
+    myStatus: StoreStatus from PCDM;
     
 
 end Store from CDF;
diff --git a/src/CDF/CDF_Store.cxx b/src/CDF/CDF_Store.cxx
index 9921023..42f4983 100644
--- a/src/CDF/CDF_Store.cxx
+++ b/src/CDF/CDF_Store.cxx
@@ -2,7 +2,7 @@
 #include <CDF_Store.ixx>
 #include <CDF_Session.hxx>
 #include <CDF_Application.hxx>
-#include <CDF_StoreStatus.hxx>
+#include <PCDM_StoreStatus.hxx>
 #include <CDF_StoreSetNameStatus.hxx>
 #include <Standard_ProgramError.hxx>
 #include <CDF_MetaDataDriver.hxx>
@@ -160,7 +160,7 @@ void CDF_Store::Realize() {
   Handle(CDM_MetaData) m;
   myText = "";
   myStatus = myList->Store(m,myText);
-  if(myStatus==CDF_SS_OK) myPath = m->Path();
+  if(myStatus==PCDM_SS_OK) myPath = m->Path();
 }
 Standard_ExtString CDF_Store::Path() const {
   return myPath.ToExtString();
@@ -280,7 +280,7 @@ CDF_SubComponentStatus CDF_Store::SubComponentStatus(const Standard_ExtString aP
 
 
 
-CDF_StoreStatus CDF_Store::StoreStatus() const {
+PCDM_StoreStatus CDF_Store::StoreStatus() const {
   return myStatus;
 }
 Standard_ExtString CDF_Store::AssociatedStatusText() const {
diff --git a/src/CDF/CDF_StoreList.cdl b/src/CDF/CDF_StoreList.cdl
index 428062e..8c92ad2 100644
--- a/src/CDF/CDF_StoreList.cdl
+++ b/src/CDF/CDF_StoreList.cdl
@@ -6,7 +6,15 @@
 
 private class StoreList from CDF inherits Transient from Standard
 
-uses  Document from CDM, StackOfDocument from CDM, MapOfDocument from CDM, MapIteratorOfMapOfDocument from CDM, StackIteratorOfStackOfDocument from CDM,MetaData from CDM, ExtendedString from TCollection, StoreStatus from CDF
+uses
+    Document from CDM,
+    StackOfDocument from CDM,
+    MapOfDocument from CDM,
+    MapIteratorOfMapOfDocument from CDM,
+    StackIteratorOfStackOfDocument from CDM,
+    MetaData from CDM,
+    ExtendedString from TCollection,
+    StoreStatus from PCDM
 
 raises NoSuchObject from Standard
 is
@@ -19,7 +27,7 @@ is
     
     Store(me: mutable; aMetaData: out MetaData from CDM;
 		       aStatusAssociatedText: out ExtendedString from TCollection)
-    returns StoreStatus from CDF
+    returns StoreStatus from PCDM
     ---Purpose: stores each object of the storelist in the reverse
     --          order of which they had been added.
     raises NoSuchObject from Standard;
diff --git a/src/CDF/CDF_StoreList.cxx b/src/CDF/CDF_StoreList.cxx
index abe1e9c..f5af63e 100644
--- a/src/CDF/CDF_StoreList.cxx
+++ b/src/CDF/CDF_StoreList.cxx
@@ -65,61 +65,60 @@ void CDF_StoreList::Next() {
 Handle(CDM_Document) CDF_StoreList::Value() const {
   return myIterator.Key();
 }
-CDF_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData, TCollection_ExtendedString& aStatusAssociatedText) {
+PCDM_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData, TCollection_ExtendedString& aStatusAssociatedText) {
 
   Handle(CDF_MetaDataDriver) theMetaDataDriver = CDF_Session::CurrentSession()->MetaDataDriver();
 
-  static CDF_StoreStatus status ;
-  status = CDF_SS_OK;
+  PCDM_StoreStatus status = PCDM_SS_OK;
   {
     try {
       OCC_CATCH_SIGNALS
       for (; !myStack.IsEmpty(); myStack.Pop()) {
-	
-	Handle(CDM_Document) theDocument = myStack.Top();
-	if( theDocument == myMainDocument || theDocument->IsModified()) {
-
-	  if(!PCDM::FindStorageDriver(theDocument)){
-	    Standard_SStream aMsg;
-	    aMsg <<"No storage driver does exist for this format: " << theDocument->StorageFormat() << (char)0;
-	    Standard_Failure::Raise(aMsg);
-	  }
-	  
-	  
-	  if(!theMetaDataDriver->FindFolder(theDocument->RequestedFolder())) {
-	    Standard_SStream aMsg; aMsg << "could not find the active dbunit";
-	    aMsg << TCollection_ExtendedString(theDocument->RequestedFolder())<< (char)0;
-	    Standard_NoSuchObject::Raise(aMsg);
-	  }
-	  TCollection_ExtendedString theName=theMetaDataDriver->BuildFileName(theDocument);
-
-	  CDF_Timer theTimer;
-	  
-	  PCDM::StorageDriver(theDocument)->Write(theDocument,theName);
-	  theTimer.ShowAndRestart("Driver->Write: ");
-
-	  aMetaData = theMetaDataDriver->CreateMetaData(theDocument,theName);
-	  theTimer.ShowAndStop("metadata creating: ");
-	    
-	  theDocument->SetMetaData(aMetaData);
-	  
-
-	  CDM_ReferenceIterator it(theDocument);
-	  for(; it.More();it.Next()) {
-	    theMetaDataDriver->CreateReference(aMetaData,it.Document()->MetaData(),it.ReferenceIdentifier(),it.DocumentVersion());
-	  }
-	  
-	}
+
+        Handle(CDM_Document) theDocument = myStack.Top();
+        if( theDocument == myMainDocument || theDocument->IsModified()) {
+
+          if(!PCDM::FindStorageDriver(theDocument)){
+            Standard_SStream aMsg;
+            aMsg <<"No storage driver does exist for this format: " << theDocument->StorageFormat() << (char)0;
+            Standard_Failure::Raise(aMsg);
+          }
+
+          if(!theMetaDataDriver->FindFolder(theDocument->RequestedFolder())) {
+            Standard_SStream aMsg; aMsg << "could not find the active dbunit";
+            aMsg << TCollection_ExtendedString(theDocument->RequestedFolder())<< (char)0;
+            Standard_NoSuchObject::Raise(aMsg);
+          }
+          TCollection_ExtendedString theName=theMetaDataDriver->BuildFileName(theDocument);
+
+          CDF_Timer theTimer;
+          Handle(PCDM_StorageDriver) aDocumentStorageDriver = PCDM::StorageDriver(theDocument);
+
+          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);
+          for(; it.More();it.Next()) {
+            theMetaDataDriver->CreateReference(aMetaData,it.Document()->MetaData(),it.ReferenceIdentifier(),it.DocumentVersion());
+          }
+        }
       }
     }
 
     catch (CDF_MetaDataDriverError) {
       CAUGHT(aStatusAssociatedText,TCollection_ExtendedString("metadatadriver failed; reason:"));
-      status = CDF_SS_DriverFailure;
+      status = PCDM_SS_DriverFailure;
     }
     catch (Standard_Failure) {
       CAUGHT(aStatusAssociatedText,TCollection_ExtendedString("driver failed; reason:"));
-      status = CDF_SS_Failure; 
+      status = PCDM_SS_Failure; 
     }
   }
 
diff --git a/src/ChFi2d/ChFi2d_Builder.cxx b/src/ChFi2d/ChFi2d_Builder.cxx
index 61bd19c..2c18d36 100644
--- a/src/ChFi2d/ChFi2d_Builder.cxx
+++ b/src/ChFi2d/ChFi2d_Builder.cxx
@@ -1000,7 +1000,10 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V,
     Fillet.Tangency2(numsol,Vv1,Vv2,Ptg2);
 
     // check the validity of parameters
-    inside = (U2<param1 && U2>param2) || (U2<param2 && U2>param1);
+    //// modified by jgv, 08.08.2011 for bug 0022695 ////
+    //inside = (U2<param1 && U2>param2) || (U2<param2 && U2>param1);
+    inside = (U2 < param1 && U2 >= param2) || (U2 <= param2 && U2 > param1);
+    /////////////////////////////////////////////////////
     if ( (basisC1->DynamicType() == STANDARD_TYPE(Geom2d_Circle))
       &&  ( (2*PI<param1 && 2*PI>param2) || (2*PI<param2 && 2*PI>param1) ) ) {
       // arc of circle containing the circle origin
@@ -1014,7 +1017,10 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V,
       return filletEdge;
     }
 
-    inside = (Vv2<param3 && Vv2>param4) || (Vv2<param4 && Vv2>param3);
+    //// modified by jgv, 08.08.2011 for bug 0022695 ////
+    //inside = (Vv2<param3 && Vv2>param4) || (Vv2<param4 && Vv2>param3);
+    inside = (Vv2 < param3 && Vv2 >= param4) || (Vv2 <= param4 && Vv2 > param3);
+    /////////////////////////////////////////////////////
     if ( (basisC2->DynamicType() == STANDARD_TYPE(Geom2d_Circle))
       &&  ( (2*PI<param3 && 2*PI>param4) || (2*PI<param4 && 2*PI>param3) ) ) {
     // arc of circle containing the circle origin
diff --git a/src/ChFi3d/ChFi3d_Builder_2.cxx b/src/ChFi3d/ChFi3d_Builder_2.cxx
index e273d1c..a530252 100644
--- a/src/ChFi3d/ChFi3d_Builder_2.cxx
+++ b/src/ChFi3d/ChFi3d_Builder_2.cxx
@@ -997,7 +997,7 @@ static void  ChFi3d_BuildPlane (TopOpeBRepDS_DataStructure&    DStr,
     if  (theProp.IsNormalDefined()) {
       P =  theProp.Value();
       Handle(Geom_Plane) Pln  = new Geom_Plane(P, theProp.Normal());
-      TopoDS_Face        NewF = BRepLib_MakeFace(Pln);
+      TopoDS_Face        NewF = BRepLib_MakeFace(Pln, Precision::Confusion());
       NewF.Orientation(F.Orientation());
       pons.SetCoord(0.,0.);
       HS->ChangeSurface().Initialize(NewF);
diff --git a/src/ChFi3d/ChFi3d_Builder_CnCrn.cxx b/src/ChFi3d/ChFi3d_Builder_CnCrn.cxx
index 419eac0..9ce6703 100644
--- a/src/ChFi3d/ChFi3d_Builder_CnCrn.cxx
+++ b/src/ChFi3d/ChFi3d_Builder_CnCrn.cxx
@@ -367,7 +367,7 @@ static void CurveHermite (const TopOpeBRepDS_DataStructure& DStr,
       TopExp::MapShapes(OrtProj.Projection() , TopAbs_EDGE, MapE1);
         if (MapE1.Extent()!=0){
           if (MapE1.Extent()!=1) {
-            BRepLib_MakeFace Bface (BRep_Tool::Surface(F));
+            BRepLib_MakeFace Bface (BRep_Tool::Surface(F), Precision::Confusion());
             F=Bface.Face();
             OrtProj.Init(F);
             OrtProj.Build();
diff --git a/src/DDocStd/DDocStd_ApplicationCommands.cxx b/src/DDocStd/DDocStd_ApplicationCommands.cxx
index a258ad6..f4f4bdc 100644
--- a/src/DDocStd/DDocStd_ApplicationCommands.cxx
+++ b/src/DDocStd/DDocStd_ApplicationCommands.cxx
@@ -162,38 +162,40 @@ static Standard_Integer DDocStd_Open (Draw_Interpretor& di,
       di <<"document " << insession << "  is already in session" << "\n";
       return 0;
     }
-    CDF_RetrievableStatus theStatus = A->Open(path,D);
-    if (theStatus == CDF_RS_OK && !D.IsNull()) {
+    PCDM_ReaderStatus theStatus = A->Open(path,D);
+    if (theStatus == PCDM_RS_OK && !D.IsNull()) {
       Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(D);
       TDataStd_Name::Set(D->GetData()->Root(),a[2]);
       Draw::Set(a[2],DD);
       return 0; 
     } else {
       switch ( theStatus ) {
-      case CDF_RS_AlreadyRetrieved: 
-      case CDF_RS_AlreadyRetrievedAndModified: {
+      case PCDM_RS_AlreadyRetrieved: 
+      case PCDM_RS_AlreadyRetrievedAndModified: {
 	di << " already retrieved " << "\n" ;  
 	break;
       }
-      case CDF_RS_NoDriver: {
+      case PCDM_RS_NoDriver: {
 	di << " could not retrieve , no Driver to make it " <<"\n" ;
 	break ;
       }
-      case CDF_RS_UnknownDocument:
-      case CDF_RS_NoModel: {
+      case PCDM_RS_UnknownDocument:
+      case PCDM_RS_NoModel: {
 	di << " could not retrieve , Unknown Document or No Model " <<"\n";
 	break ; 
       }
-      case CDF_RS_TypeNotFoundInSchema:
-      case CDF_RS_UnrecognizedFileFormat: {
+      case PCDM_RS_TypeNotFoundInSchema:
+      case PCDM_RS_UnrecognizedFileFormat: {
 	di << " could not retrieve , Type not found or Unrecognized File Format" <<"\n";
 	break ;
       }
-      case CDF_RS_PermissionDenied: {
+      case PCDM_RS_PermissionDenied: {
 	di << " could not retrieve , permission denied " << "\n" ;  
 	break;
       }
-      default: /* Do nothing */ break;
+      default:
+	di << " could not retrieve " << "\n" ;  
+	break;
       }
       di << "DDocStd_Open : Error" << "\n";
     }	
@@ -241,18 +243,18 @@ static Standard_Integer DDocStd_SaveAs (Draw_Interpretor& di,
     TCollection_ExtendedString path (a[2]); 
     Handle(TDocStd_Application) A;
     if (!DDocStd::Find(A)) return 1;
-    CDF_StoreStatus theStatus = A->SaveAs(D,path);
-    if (theStatus != CDF_SS_OK ) {
+    PCDM_StoreStatus theStatus = A->SaveAs(D,path);
+    if (theStatus != PCDM_SS_OK ) {
       switch ( theStatus ) {
-      case CDF_SS_DriverFailure: {
+      case PCDM_SS_DriverFailure: {
 	di << " could not store , no driver found to make it " <<"\n" ;
 	break ;
       }
-      case CDF_SS_WriteFailure: {
+      case PCDM_SS_WriteFailure: {
 	di << " Write access failure " << "\n" ;  
 	break;
       }
-      case CDF_SS_Failure: {
+      case PCDM_SS_Failure: {
 	di << " Write failure " << "\n" ;  
       }
       default: /* Do nothing */ break;
diff --git a/src/DRAWEXE/EXTERNLIB b/src/DRAWEXE/EXTERNLIB
new file mode 100644
index 0000000..92f3046
--- /dev/null
+++ b/src/DRAWEXE/EXTERNLIB
@@ -0,0 +1,12 @@
+TKDraw
+TKMesh
+TKTopAlgo
+TKHLR
+TKGeomAlgo
+TKGeomBase
+TKG2d
+TKBRep
+TKMath
+TKG3d
+TKernel
+TKService
diff --git a/src/DRAWEXE/FILES b/src/DRAWEXE/FILES
index 14bfdad..9d9e5ff 100644
--- a/src/DRAWEXE/FILES
+++ b/src/DRAWEXE/FILES
@@ -1 +1,2 @@
 DRAWEXE_LINK.edl
+EXTERNLIB
diff --git a/src/DrawResources/demo.bat b/src/DrawResources/demo.bat
index 9e14029..50749b6 100755
--- a/src/DrawResources/demo.bat
+++ b/src/DrawResources/demo.bat
@@ -1,40 +1,40 @@
-echo ON
-
-echo " Open CASCADE "
-
-if not DEFINED CASROOT     echo CASROOT is mandatory
-
-if %PROCESSOR_ARCHITECTURE% EQU x86 Set STATION=Windows_NT
-
-
-
-rem =========================================
-rem
-rem    LD_LIBRARY_PATH definition 
-rem
-rem =========================================
-
-if NOT DEFINED OLDPATH set OLDPATH=%PATH%
-
-
-
-set PATH=%PATH%;%CASROOT%\%STATION%\dll;
-
-rem the Path where Tcl is installed
-
-set PATH=D:/DevTools/Tcltk/bin/;%PATH%;
-
-rem ======================================
-
-
-Set DrawExe=%CASROOT%\%STATION%\bin\TTOPOLOGY.exe
-
-# POP : Since C31 Version ; this Varaible are not Mandatory
-rem if not DEFINED DRAWHOME    Set DRAWHOME=%CASROOT%/src/DrawResources
-rem if not DEFINED DRAWDEFAULT set DRAWDEFAULT=%DRAWHOME%\\DrawDefault
-
-Set MMGT_CLEAR=1
-%DRAWEXE% 
-
-
-
+echo ON
+
+echo " Open CASCADE "
+
+if not DEFINED CASROOT     echo CASROOT is mandatory
+
+if %PROCESSOR_ARCHITECTURE% EQU x86 Set STATION=Windows_NT
+
+
+
+rem =========================================
+rem
+rem    LD_LIBRARY_PATH definition 
+rem
+rem =========================================
+
+if NOT DEFINED OLDPATH set OLDPATH=%PATH%
+
+
+
+set PATH=%PATH%;%CASROOT%\%STATION%\dll;
+
+rem the Path where Tcl is installed
+
+set PATH=D:/DevTools/Tcltk/bin/;%PATH%;
+
+rem ======================================
+
+
+Set DrawExe=%CASROOT%\%STATION%\bin\TTOPOLOGY.exe
+
+# POP : Since C31 Version ; this Varaible are not Mandatory
+rem if not DEFINED DRAWHOME    Set DRAWHOME=%CASROOT%/src/DrawResources
+rem if not DEFINED DRAWDEFAULT set DRAWDEFAULT=%DRAWHOME%\\DrawDefault
+
+Set MMGT_CLEAR=1
+%DRAWEXE% 
+
+
+
diff --git a/src/Extrema/Extrema_ExtElC.cxx b/src/Extrema/Extrema_ExtElC.cxx
index 2fcbc1e..65d44c8 100644
--- a/src/Extrema/Extrema_ExtElC.cxx
+++ b/src/Extrema/Extrema_ExtElC.cxx
@@ -21,16 +21,18 @@
 #include <gp_Dir.hxx>
 #include <gp_Ax1.hxx>
 
-
-
-//======================================================================
+//modified by NIZNHY-PKV Wed Sep 21 08:02:16 2011f
+static
+  void RefineDir(gp_Dir& aDir);
+//modified by NIZNHY-PKV Wed Sep 21 08:02:20 2011t
+//=======================================================================
+//class    : ExtremaExtElC_TrigonometricRoots
+//purpose  : 
 //==  Classe Interne (Donne des racines classees d un polynome trigo)
 //==  Code duplique avec IntAna_IntQuadQuad.cxx (lbr le 26 mars 98)
 //==  Solution fiable aux problemes de coefficients proches de 0 
 //==  avec essai de rattrapage si coeff<1.e-10 (jct le 27 avril 98) 
-//======================================================================
-static const Standard_Real PIpPI=Standard_PI+Standard_PI;
-
+//=======================================================================
 class ExtremaExtElC_TrigonometricRoots {
  private:
   Standard_Real Roots[4];
@@ -38,132 +40,188 @@ class ExtremaExtElC_TrigonometricRoots {
   Standard_Integer NbRoots;
   Standard_Boolean infinite_roots;
  public:
-  ExtremaExtElC_TrigonometricRoots(const Standard_Real CC
-		     ,const Standard_Real SC
-		     ,const Standard_Real C
-		     ,const Standard_Real S
-		     ,const Standard_Real Cte
-		     ,const Standard_Real Binf
-		     ,const Standard_Real Bsup);
-
-  Standard_Boolean IsDone() { return(done); }
-
+  ExtremaExtElC_TrigonometricRoots(const Standard_Real CC,
+				   const Standard_Real SC,
+				   const Standard_Real C,
+				   const Standard_Real S,
+				   const Standard_Real Cte,
+				   const Standard_Real Binf,
+				   const Standard_Real Bsup);
+  //
+  Standard_Boolean IsDone() {
+    return done; 
+  }
+  //
   Standard_Boolean IsARoot(Standard_Real u) {
+    Standard_Integer i;
+    Standard_Real PIpPI, aEps;
+    //
+    aEps=RealEpsilon();
+    PIpPI=Standard_PI+Standard_PI;
     for(Standard_Integer i=0 ; i<NbRoots; i++) {
-      if(Abs(u - Roots[i])<=RealEpsilon()) return(Standard_True);
-      if(Abs(u - Roots[i]-PIpPI)<=RealEpsilon()) return(Standard_True);
+      if(Abs(u - Roots[i])<=aEps) {
+	return Standard_True ;
+      }
+      if(Abs(u - Roots[i]-PIpPI)<=aEps) {
+	return Standard_True;
+      }
     }
-    return(Standard_False);
+    return Standard_False;
   }
-
+  //
   Standard_Integer NbSolutions() { 
-    if(!done) StdFail_NotDone::Raise();
-    return(NbRoots); 
+    if(!done) {
+      StdFail_NotDone::Raise();
+    }
+    return NbRoots; 
   }
+  //
   Standard_Boolean InfiniteRoots() { 
-    if(!done) StdFail_NotDone::Raise();
-    return(infinite_roots); 
+    if(!done) {
+      StdFail_NotDone::Raise();
+    }
+    return infinite_roots; 
   }
-  Standard_Real    Value(const Standard_Integer& n) {
-    if((!done)||(n>NbRoots)) StdFail_NotDone::Raise();
-    return(Roots[n-1]);
+  //
+  Standard_Real Value(const Standard_Integer& n) {
+    if((!done)||(n>NbRoots)) {
+      StdFail_NotDone::Raise();
+    }
+    return Roots[n-1];
   }
 }; 
-//----------------------------------------------------------------------
-ExtremaExtElC_TrigonometricRoots::ExtremaExtElC_TrigonometricRoots(const Standard_Real CC
-				       ,const Standard_Real SC
-				       ,const Standard_Real C
-				       ,const Standard_Real S
-				       ,const Standard_Real Cte
-				       ,const Standard_Real Binf
-				       ,const Standard_Real Bsup) {
-
-  Standard_Integer i ;
-  Standard_Integer nbessai = 1;
-  Standard_Real cc = CC, sc = SC, c = C, s = S, cte = Cte;
+//=======================================================================
+//function : ExtremaExtElC_TrigonometricRoots
+//purpose  : 
+//=======================================================================
+ExtremaExtElC_TrigonometricRoots::
+  ExtremaExtElC_TrigonometricRoots(const Standard_Real CC,
+				   const Standard_Real SC,
+				   const Standard_Real C,
+				   const Standard_Real S,
+				   const Standard_Real Cte,
+				   const Standard_Real Binf,
+				   const Standard_Real Bsup) 
+{
+  Standard_Integer i, nbessai;
+  Standard_Real cc ,sc, c, s, cte;
+  //
+  nbessai = 1;
+  cc = CC;
+  sc = SC;
+  c = C;
+  s = S;
+  cte = Cte;
   done=Standard_False;
   while (nbessai<=2 && !done) {
     //-- F= AA*CN*CN+2*BB*CN*SN+CC*CN+DD*SN+EE;
     math_TrigonometricFunctionRoots MTFR(cc,sc,c,s,cte,Binf,Bsup); 
+    //
     if(MTFR.IsDone()) {
       done=Standard_True;
       if(MTFR.InfiniteRoots()) {
 	infinite_roots=Standard_True;
       }
-      else {
+      else { //else #1
+	Standard_Boolean Triee;
+	Standard_Integer j, SvNbRoots;
+	Standard_Real aTwoPI, aMaxCoef, aPrecision;
+	//
+	aTwoPI=PI+PI;
 	NbRoots=MTFR.NbSolutions();
-	for( i=0;i<NbRoots;i++) {
+	for(i=0;i<NbRoots;++i) {
 	  Roots[i]=MTFR.Value(i+1);
-	  if(Roots[i]<0.0) Roots[i]+=PI+PI;
-	  if(Roots[i]>(PI+PI)) Roots[i]-=PI+PI;
+	  if(Roots[i]<0.) {
+	    Roots[i]=Roots[i]+aTwoPI;
+	  }
+	  if(Roots[i]>aTwoPI) {
+	    Roots[i]=Roots[i]-aTwoPI;
+	  }
 	}
-	Standard_Boolean Triee;
-      Standard_Integer j;
-	
 	//-- La recherche directe donne n importe quoi. 
 	// modified by OCC  Tue Oct  3 18:41:27 2006.BEGIN
-	Standard_Real aMaxCoef = Max(CC,SC);
+	aMaxCoef = Max(CC,SC);
 	aMaxCoef = Max(aMaxCoef,C);
 	aMaxCoef = Max(aMaxCoef,S);
 	aMaxCoef = Max(aMaxCoef,Cte);
-	const Standard_Real aPrecision = Max(1.e-8,1.e-12*aMaxCoef);
+	aPrecision = Max(1.e-8, 1.e-12*aMaxCoef);
 	// modified by OCC  Tue Oct  3 18:41:33 2006.END
 
-	Standard_Integer SvNbRoots=NbRoots;
-	for(i=0;i<SvNbRoots;i++) {
+	SvNbRoots=NbRoots;
+	for(i=0; i<SvNbRoots; ++i) {
 	  Standard_Real y;
-	Standard_Real co=cos(Roots[i]);
+	  Standard_Real co=cos(Roots[i]);
 	  Standard_Real si=sin(Roots[i]);
 	  y=co*(CC*co + (SC+SC)*si + C) + S*si + Cte;
 	  // modified by OCC  Tue Oct  3 18:43:00 2006
 	  if(Abs(y)>aPrecision) {
-#ifdef DEB
-	    printf("\n**IntAna_IntQuadQuad** Solution : %g ( %g cos2 + 2  %g cos sin + %g cos + %g sin  + %g) = %g\n",
-		   Roots[i],CC,SC,C,S,Cte,y);
-#endif
 	    NbRoots--;
 	    Roots[i]=1000.0;
 	  }
 	}
-	
+	//
 	do {
+	  Standard_Real t;
+	  //
 	  Triee=Standard_True;
-	  for(i=1,j=0;i<SvNbRoots;i++,j++) {
+	  for(i=1, j=0; i<SvNbRoots; ++i, ++j) {
 	    if(Roots[i]<Roots[j]) {
 	      Triee=Standard_False;
-	      Standard_Real t=Roots[i]; Roots[i]=Roots[j]; Roots[j]=t;
+	      t=Roots[i]; 
+	      Roots[i]=Roots[j]; 
+	      Roots[j]=t;
 	    }
 	  }
 	}
 	while(!Triee);
+	//
 	infinite_roots=Standard_False;
-	if(NbRoots==0) { //--!!!!! Detection du cas Pol = Cte ( 1e-50 ) !!!!
+	if(NbRoots==0) { 
+	  //--!!!!! Detection du cas Pol = Cte ( 1e-50 ) !!!!
 	  if((Abs(CC) + Abs(SC) + Abs(C) + Abs(S)) < 1e-10) {
 	    if(Abs(Cte) < 1e-10)  {
 	      infinite_roots=Standard_True;
 	    }
 	  }
 	}
-      }
-    }
+      } // else #1
+    } // if(MTFR.IsDone()) {
     else {
 	// on essaie en mettant les tres petits coeff. a ZERO
-      if (Abs(CC)<1e-10) cc = 0.0;
-      if (Abs(SC)<1e-10) sc = 0.0;
-      if (Abs(C)<1e-10) c = 0.0;
-      if (Abs(S)<1e-10) s = 0.0;
-      if (Abs(Cte)<1e-10) cte = 0.0;
+      if (Abs(CC)<1e-10) {
+	cc = 0.0;
+      }
+      if (Abs(SC)<1e-10) {
+	sc = 0.0;
+      }
+      if (Abs(C)<1e-10) {
+	c = 0.0;
+      }
+      if (Abs(S)<1e-10){
+	s = 0.0;
+      }
+      if (Abs(Cte)<1e-10){
+	cte = 0.0;
+      }
       nbessai++;
     }
-  }
+  } // while (nbessai<=2 && !done) {
 }
 
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC () { myDone = Standard_False; }
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Lin& C1, const gp_Lin& C2,
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC () 
+{
+  myDone = Standard_False; 
+}
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Lin& C1, 
+				const gp_Lin& C2,
 				const Standard_Real)
 // Fonction:
 //    Recherche de la distance minimale entre 2 droites.
@@ -242,9 +300,12 @@ Extrema_ExtElC::Extrema_ExtElC (const gp_Lin& C1, const gp_Lin& C2,
   }
   myDone = Standard_True;
 }
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Lin& C1, const gp_Circ& C2,
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Lin& C1, 
+				const gp_Circ& C2,
 				const Standard_Real)
 /*-----------------------------------------------------------------------------
 Fonction:
@@ -279,59 +340,97 @@ Methode:
     cette equation.
 -----------------------------------------------------------------------------*/
 {
+  Standard_Real Dx,Dy,Dz,aRO2O1, aTolRO2O1;
+  Standard_Real R, A1, A2, A3, A4, A5, aTol;
+  gp_Dir x2, y2, z2, D, D1;
+  //
   myIsPar = Standard_False;
   myDone = Standard_False;
   myNbExt = 0;
-
-// Calcul de T1 dans le repere du cercle ...
-  gp_Dir D = C1.Direction();
-  gp_Dir D1 = D;
-  gp_Dir x2, y2, z2;
+  //
+  // Calcul de T1 dans le repere du cercle ...
+  D = C1.Direction();
+  D1 = D;
   x2 = C2.XAxis().Direction();
   y2 = C2.YAxis().Direction();
   z2 = C2.Axis().Direction();
-  Standard_Real Dx = D.Dot(x2);
-  Standard_Real Dy = D.Dot(y2);
-  Standard_Real Dz = D.Dot(z2);
-  D.SetCoord(Dx,Dy,Dz);
-
-// Calcul de V dans le repere du cercle:
+  Dx = D.Dot(x2);
+  Dy = D.Dot(y2);
+  Dz = D.Dot(z2);
+  //
+  D.SetCoord(Dx, Dy, Dz);
+  //modified by NIZNHY-PKV Wed Sep 21 08:02:46 2011f
+  RefineDir(D);
+  D.Coord(Dx, Dy, Dz);
+  //modified by NIZNHY-PKV Wed Sep 21 08:02:48 2011t
+  //
+  // Calcul de V dans le repere du cercle:
   gp_Pnt O1 = C1.Location();
   gp_Pnt O2 = C2.Location();
   gp_Vec O2O1 (O2,O1);
-  O2O1.SetCoord(O2O1.Dot(x2), O2O1.Dot(y2), O2O1.Dot(z2));
+  //
+  //modified by NIZNHY-PKV Wed Sep 21 07:45:39 2011f
+  aTolRO2O1=gp::Resolution();
+  aRO2O1=O2O1.Magnitude();
+  if (aRO2O1 > aTolRO2O1) {
+    gp_Dir aDO2O1;
+    //
+    O2O1.Multiply(1./aRO2O1);
+    aDO2O1.SetCoord(O2O1.Dot(x2), O2O1.Dot(y2), O2O1.Dot(z2));
+    RefineDir(aDO2O1);
+    O2O1.SetXYZ(aRO2O1*aDO2O1.XYZ());
+  }
+  else {
+    O2O1.SetCoord(O2O1.Dot(x2), O2O1.Dot(y2), O2O1.Dot(z2));
+  }
+  //O2O1.SetCoord(O2O1.Dot(x2), O2O1.Dot(y2), O2O1.Dot(z2));
+  //modified by NIZNHY-PKV Wed Sep 21 07:45:42 2011t
+  //
   gp_XYZ Vxyz = (D.XYZ()*(O2O1.Dot(D)))-O2O1.XYZ();
-
-// Calcul des coefficients de l equation en Cos et Sin ...
-  Standard_Real R = C2.Radius();
-  Standard_Real A5 = R*R*Dx*Dy;
-  Standard_Real A1 = -2.*A5;
-  Standard_Real A2 = R*R*(Dx*Dx-Dy*Dy)/2.0;
-  Standard_Real A3 = R*Vxyz.Y();
-  Standard_Real A4 = -R*Vxyz.X();
- // Standard_Real TolU = Tol * R;
-
-  
-  if(fabs(A5) <= 1.e-12) A5 = 0.;
-  if(fabs(A1) <= 1.e-12) A1 = 0.;
-  if(fabs(A2) <= 1.e-12) A2 = 0.;
-  if(fabs(A3) <= 1.e-12) A3 = 0.;
-  if(fabs(A4) <= 1.e-12) A4 = 0.;
-  
-
+  //
+  // Calcul des coefficients de l equation en Cos et Sin ... 
+  aTol=1.e-12;
+  R = C2.Radius();
+  A5 = R*R*Dx*Dy;
+  A1 = -2.*A5;
+  A2 = R*R*(Dx*Dx-Dy*Dy)/2.;
+  A3 = R*Vxyz.Y();
+  A4 = -R*Vxyz.X();
+  //
+  if(fabs(A5) <= aTol) {
+    A5 = 0.;
+  }
+  if(fabs(A1) <= aTol) {
+    A1 = 0.;
+  }
+  if(fabs(A2) <= aTol) {
+    A2 = 0.;
+  }
+  if(fabs(A3) <= aTol) {
+    A3 = 0.;
+  }
+  if(fabs(A4) <= aTol) {
+    A4 = 0.;
+  }
+  //
   ExtremaExtElC_TrigonometricRoots Sol(A1,A2,A3,A4,A5,0.,PI+PI);
-  if (!Sol.IsDone()) { return; }
+  if (!Sol.IsDone()) { 
+    return; 
+  }
   if (Sol.InfiniteRoots()) { 
     myIsPar = Standard_True;
     mySqDist[0] = R*R;
     myDone = Standard_True;
     return; 
   }
-// Stockage des solutions ...
-  gp_Pnt P1,P2;
+  //
+  // Stockage des solutions ...
+  Standard_Integer NoSol, NbSol;
   Standard_Real U1,U2;
-  Standard_Integer NbSol = Sol.NbSolutions();
-  for (Standard_Integer NoSol = 1; NoSol <= NbSol; NoSol++) {
+  gp_Pnt P1,P2;
+  //
+  NbSol = Sol.NbSolutions();
+  for (NoSol=1; NoSol<=NbSol; ++NoSol) {
     U2 = Sol.Value(NoSol);
     P2 = ElCLib::Value(U2,C2);
     U1 = (gp_Vec(O1,P2)).Dot(D1);
@@ -343,10 +442,12 @@ Methode:
   }
   myDone = Standard_True;
 }
-
-
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Lin& C1, const gp_Elips& C2)
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Lin& C1,
+				const gp_Elips& C2)
 {
 /*-----------------------------------------------------------------------------
 Fonction:
@@ -413,7 +514,17 @@ Methode:
   Standard_Real A2 =(R2*Dx*Dx -r2*Dy*Dy -R2 +r2)/2.0;
   Standard_Real A3 = MinR*Vxyz.Y();
   Standard_Real A4 = -MajR*Vxyz.X();
-
+  //
+  //modified by NIZNHY-PKV Thu Feb 03 14:51:04 2011f
+  Standard_Real aEps=1.e-12;
+  //
+  if(fabs(A5) <= aEps) A5 = 0.;
+  if(fabs(A1) <= aEps) A1 = 0.;
+  if(fabs(A2) <= aEps) A2 = 0.;
+  if(fabs(A3) <= aEps) A3 = 0.;
+  if(fabs(A4) <= aEps) A4 = 0.;
+  //modified by NIZNHY-PKV Thu Feb 03 14:51:08 2011t
+  //
   ExtremaExtElC_TrigonometricRoots Sol(A1,A2,A3,A4,A5,0.,PI+PI);
   if (!Sol.IsDone()) { return; }
 
@@ -433,9 +544,13 @@ Methode:
   }
   myDone = Standard_True;
 }
-//=============================================================================
 
-Extrema_ExtElC::Extrema_ExtElC (const gp_Lin& C1, const gp_Hypr& C2)
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Lin& C1, 
+				const gp_Hypr& C2)
 {
 /*-----------------------------------------------------------------------------
 Fonction:
@@ -530,9 +645,12 @@ Methode:
   }
   myDone = Standard_True;
 }
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Lin& C1, const gp_Parab& C2)
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Lin& C1, 
+				const gp_Parab& C2)
 {
 /*-----------------------------------------------------------------------------
 Fonction:
@@ -615,107 +733,12 @@ Methode:
   }
   myDone = Standard_True;
 }
-//=============================================================================
-Extrema_ExtElC::Extrema_ExtElC (const gp_Circ&, const gp_Elips&)
-{
-  Standard_NotImplemented::Raise();
-}
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Circ&, const gp_Hypr&)
-{
-  Standard_NotImplemented::Raise();
-}
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Circ&, const gp_Parab&)
-{
-  Standard_NotImplemented::Raise();
-}
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Elips&, const gp_Elips&)
-{
-  Standard_NotImplemented::Raise();
-}
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Elips&, const gp_Hypr&)
-{
-  Standard_NotImplemented::Raise();
-}
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Elips&, const gp_Parab&)
-{
-  Standard_NotImplemented::Raise();
-}
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Hypr&, const gp_Hypr&)
-{
-  Standard_NotImplemented::Raise();
-}
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Hypr&, const gp_Parab&)
-{
-  Standard_NotImplemented::Raise();
-}
-//=============================================================================
-
-Extrema_ExtElC::Extrema_ExtElC (const gp_Parab&, const gp_Parab&)
-{
-  Standard_NotImplemented::Raise();
-}
-//=============================================================================
-
-Standard_Boolean Extrema_ExtElC::IsDone () const { return myDone; }
-//=============================================================================
-
-Standard_Boolean Extrema_ExtElC::IsParallel () const
-{
-  if (!IsDone()) { StdFail_NotDone::Raise(); }
-  return myIsPar;
-}
-//=============================================================================
-
-Standard_Integer Extrema_ExtElC::NbExt () const
-{
-  if (IsParallel()) { StdFail_InfiniteSolutions::Raise(); }
-  return myNbExt;
-}
-//=============================================================================
-
-Standard_Real Extrema_ExtElC::SquareDistance (const Standard_Integer N) const
-{
-  if (!myDone) { StdFail_NotDone::Raise(); }
-  if (myIsPar) {
-    if (N < 1 || N > 2) { Standard_OutOfRange::Raise(); }
-  }
-  else {  
-    if (N < 1 || N > NbExt()) { Standard_OutOfRange::Raise(); }
-  }
-  return mySqDist[N-1];
-}
-//=============================================================================
-
-void Extrema_ExtElC::Points (const Standard_Integer N,
-			     Extrema_POnCurv& P1, Extrema_POnCurv& P2) const
-{
-  if (N < 1 || N > NbExt()) { Standard_OutOfRange::Raise(); }
-  P1 = myPoint[N-1][0];
-  P2 = myPoint[N-1][1];
-}
-//=============================================================================
-//=============================================================================
-//
-//modified by NIZNHY-PKV Fri Nov 21 10:48:46 2008f
 //=======================================================================
 //function : Extrema_ExtElC
 //purpose  : 
 //=======================================================================
-Extrema_ExtElC::Extrema_ExtElC (const gp_Circ& C1, const gp_Circ& C2)
+Extrema_ExtElC::Extrema_ExtElC (const gp_Circ& C1, 
+				const gp_Circ& C2)
 {
   Standard_Boolean bIsSamePlane, bIsSameAxe;
   Standard_Real aTolD, aTolD2, aTolA, aD2, aDC2;
@@ -865,4 +888,170 @@ Extrema_ExtElC::Extrema_ExtElC (const gp_Circ& C1, const gp_Circ& C2)
     }// if (!bOut || !bIn) {
   }// else
 }
-//modified by NIZNHY-PKV Fri Nov 21 10:48:56 2008t
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Circ&, const gp_Elips&)
+{
+  Standard_NotImplemented::Raise();
+}
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Circ&, const gp_Hypr&)
+{
+  Standard_NotImplemented::Raise();
+}
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Circ&, const gp_Parab&)
+{
+  Standard_NotImplemented::Raise();
+}
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Elips&, const gp_Elips&)
+{
+  Standard_NotImplemented::Raise();
+}
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Elips&, const gp_Hypr&)
+{
+  Standard_NotImplemented::Raise();
+}
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Elips&, const gp_Parab&)
+{
+  Standard_NotImplemented::Raise();
+}
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Hypr&, const gp_Hypr&)
+{
+  Standard_NotImplemented::Raise();
+}
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Hypr&, const gp_Parab&)
+{
+  Standard_NotImplemented::Raise();
+}
+//=======================================================================
+//function : Extrema_ExtElC
+//purpose  : 
+//=======================================================================
+Extrema_ExtElC::Extrema_ExtElC (const gp_Parab&, const gp_Parab&)
+{
+  Standard_NotImplemented::Raise();
+}
+//=======================================================================
+//function : IsDone
+//purpose  : 
+//=======================================================================
+Standard_Boolean Extrema_ExtElC::IsDone () const {
+  return myDone; 
+}
+//=======================================================================
+//function : IsParallel
+//purpose  : 
+//=======================================================================
+Standard_Boolean Extrema_ExtElC::IsParallel () const
+{
+  if (!IsDone()) { 
+    StdFail_NotDone::Raise(); 
+  }
+  return myIsPar;
+}
+//=======================================================================
+//function : NbExt
+//purpose  : 
+//=======================================================================
+Standard_Integer Extrema_ExtElC::NbExt () const
+{
+  if (IsParallel()) {
+    StdFail_InfiniteSolutions::Raise(); 
+  }
+  return myNbExt;
+}
+//=======================================================================
+//function : SquareDistance
+//purpose  : 
+//=======================================================================
+Standard_Real Extrema_ExtElC::SquareDistance (const Standard_Integer N) const
+{
+  if (!myDone) { 
+    StdFail_NotDone::Raise(); 
+  }
+  if (myIsPar) {
+    if (N < 1 || N > 2) { 
+      Standard_OutOfRange::Raise(); 
+    }
+  }
+  else {  
+    if (N < 1 || N > NbExt()) { 
+      Standard_OutOfRange::Raise(); 
+    }
+  }
+  return mySqDist[N-1];
+}
+//=======================================================================
+//function : Points
+//purpose  : 
+//=======================================================================
+void Extrema_ExtElC::Points (const Standard_Integer N,
+			     Extrema_POnCurv& P1, 
+			     Extrema_POnCurv& P2) const
+{
+  if (N < 1 || N > NbExt()) { 
+    Standard_OutOfRange::Raise(); 
+  }
+  P1 = myPoint[N-1][0];
+  P2 = myPoint[N-1][1];
+}
+//modified by NIZNHY-PKV Wed Sep 21 07:59:19 2011f
+//=======================================================================
+//function : RefineDir
+//purpose  : 
+//=======================================================================
+void RefineDir(gp_Dir& aDir)
+{
+  Standard_Integer i, j, k, iK;
+  Standard_Real aCx[3], aEps, aX1, aX2, aOne;
+  //
+  iK=3;
+  aEps=RealEpsilon();
+  aDir.Coord(aCx[0], aCx[1], aCx[2]);
+  //
+  for (i=0; i<iK; ++i) {
+    aOne=(aCx[i]>0.) ? 1. : -1.;
+    aX1=aOne-aEps;
+    aX2=aOne+aEps;
+    //
+    if (aCx[i]>aX1 && aCx[i]<aX2) {
+      j=(i+1)%iK;
+      k=(i+2)%iK;
+      aCx[i]=aOne;
+      aCx[j]=0.;
+      aCx[k]=0.;
+      aDir.SetCoord(aCx[0], aCx[1], aCx[2]);
+      return;
+    }
+  }
+}
+//modified by NIZNHY-PKV Wed Sep 21 07:59:26 2011t
diff --git a/src/Extrema/Extrema_GenExtPS.cxx b/src/Extrema/Extrema_GenExtPS.cxx
index dd74b3c..acd38ca 100644
--- a/src/Extrema/Extrema_GenExtPS.cxx
+++ b/src/Extrema/Extrema_GenExtPS.cxx
@@ -376,71 +376,82 @@ void Extrema_GenExtPS::FindSolution(const gp_Pnt& P, const math_Vector& UV, cons
   if (myF.HasDegIso())
     aNbMaxIter = 150;
 
+  gp_Pnt PStart = myS->Value(UV(1), UV(2));
+  Standard_Real DistStart = P.SquareDistance(PStart);
+  Standard_Real DistSol = DistStart;
+  
   math_FunctionSetRoot S (myF,UV,Tol,UVinf,UVsup, aNbMaxIter);
-  if(S.IsDone()) {
-    root = S.Root();
-    myF.Value(root, errors);
-    if(f == Extrema_ExtFlag_MIN) 
+  Standard_Boolean ToResolveOnSubgrid = Standard_False;
+  if (f == Extrema_ExtFlag_MIN)
+  {
+    if(S.IsDone())
     {
-      if(Abs(errors(1)) > eps || Abs(errors(2)) > eps) {
+      root = S.Root();
+      myF.Value(root, errors);
+      gp_Pnt PSol = myS->Value(root(1), root(2));
+      DistSol = P.SquareDistance(PSol);
+      if(Abs(errors(1)) > eps || Abs(errors(2)) > eps || DistStart < DistSol)
         //try to improve solution on subgrid of sample points
-        gp_Pnt PSol = myS->Value(root(1), root(2));
-        Standard_Real DistSol = P.SquareDistance(PSol);
-
-        Standard_Real u1 = Max(UV(1) - PasU, myumin), u2 = Min(UV(1) + PasU, myusup);
-        Standard_Real v1 = Max(UV(2) - PasV, myvmin), v2 = Min(UV(2) + PasV, myvsup);
-
-        if(u2 - u1 < 2.*PasU) {
-          if(Abs(u1 - myumin) < 1.e-9) {
-            u2 = u1 + 2.*PasU;
-            u2 = Min(u2, myusup);
-          }
-          if(Abs(u2 - myusup) < 1.e-9) {
-            u1 = u2 - 2.*PasU;
-            u1 = Max(u1, myumin);
-          }
+        ToResolveOnSubgrid = Standard_True;
+    }
+    else
+      ToResolveOnSubgrid = Standard_True;
+    
+    if (ToResolveOnSubgrid)
+    {
+      Standard_Real u1 = Max(UV(1) - PasU, myumin), u2 = Min(UV(1) + PasU, myusup);
+      Standard_Real v1 = Max(UV(2) - PasV, myvmin), v2 = Min(UV(2) + PasV, myvsup);
+      
+      if(u2 - u1 < 2.*PasU) {
+        if(Abs(u1 - myumin) < 1.e-9) {
+          u2 = u1 + 2.*PasU;
+          u2 = Min(u2, myusup);
         }
-
-        if(v2 - v1 < 2.*PasV) {
-          if(Abs(v1 - myvmin) < 1.e-9) {
-            v2 = v1 + 2.*PasV;
-            v2 = Min(v2, myvsup);
-          }
-          if(Abs(v2 - myvsup) < 1.e-9) {
-            v1 = v2 - 2.*PasV;
-            v1 = Max(v1, myvmin);
-          }
+        if(Abs(u2 - myusup) < 1.e-9) {
+          u1 = u2 - 2.*PasU;
+          u1 = Max(u1, myumin);
         }
-
-        Standard_Real du = (u2 - u1)/(nbsubsample-1);
-        Standard_Real dv = (v2 - v1)/(nbsubsample-1);
-        Standard_Real u, v;
-        Standard_Real dist;
-
-        Standard_Boolean NewSolution = Standard_False;
-        Standard_Integer Nu, Nv;
-        for (Nu = 1, u = u1; Nu < nbsubsample; Nu++, u += du) {
-          for (Nv = 1, v = v1; Nv < nbsubsample; Nv++, v += dv) {
-            gp_Pnt Puv = myS->Value(u, v);
-            dist = P.SquareDistance(Puv);
-
-            if(dist < DistSol) {
-              UV(1) = u;
-              UV(2) = v;
-              NewSolution = Standard_True;
-              DistSol = dist;
-            }
-          }
+      }
+      
+      if(v2 - v1 < 2.*PasV) {
+        if(Abs(v1 - myvmin) < 1.e-9) {
+          v2 = v1 + 2.*PasV;
+          v2 = Min(v2, myvsup);
         }
-
-        if(NewSolution) {
-          //try to precise
-          math_FunctionSetRoot S (myF,UV,Tol,UVinf,UVsup, aNbMaxIter);
+        if(Abs(v2 - myvsup) < 1.e-9) {
+          v1 = v2 - 2.*PasV;
+          v1 = Max(v1, myvmin);
         }
-
       }
-    }
-  }
+      
+      Standard_Real du = (u2 - u1)/(nbsubsample-1);
+      Standard_Real dv = (v2 - v1)/(nbsubsample-1);
+      Standard_Real u, v;
+      Standard_Real dist;
+      
+      Standard_Boolean NewSolution = Standard_False;
+      Standard_Integer Nu, Nv;
+      for (Nu = 1, u = u1; Nu < nbsubsample; Nu++, u += du) {
+        for (Nv = 1, v = v1; Nv < nbsubsample; Nv++, v += dv) {
+          gp_Pnt Puv = myS->Value(u, v);
+          dist = P.SquareDistance(Puv);
+          
+          if(dist < DistSol) {
+            UV(1) = u;
+            UV(2) = v;
+            NewSolution = Standard_True;
+            DistSol = dist;
+          }
+        }
+      }
+      
+      if(NewSolution) {
+        //try to precise
+        math_FunctionSetRoot S (myF,UV,Tol,UVinf,UVsup, aNbMaxIter);
+      }
+    } //end of if (ToResolveOnSubgrid)
+  } //end of if (f == Extrema_ExtFlag_MIN)
+  
   myDone = Standard_True;
 }
 
diff --git a/src/Extrema/Extrema_HUBTreeOfSphere.hxx b/src/Extrema/Extrema_HUBTreeOfSphere.hxx
deleted file mode 100644
index babe938..0000000
--- a/src/Extrema/Extrema_HUBTreeOfSphere.hxx
+++ /dev/null
@@ -1,18 +0,0 @@
-// File:      BestFitBnd_HUBTreeOfSphere.hxx
-// Created:   Thu Mar 17 14:30:42 2005
-// Author:    OPEN CASCADE Support
-// Copyright: OPEN CASCADE SA 2005
-
-#ifndef _Extrema_HUBTreeOfSphere_HeaderFile
-#define _Extrema_HUBTreeOfSphere_HeaderFile
-
-#include <NCollection_UBTree.hxx>
-#include <NCollection_UBTreeFiller.hxx>
-#include <NCollection_Handle.hxx>
-#include <Bnd_Sphere.hxx>
-
-typedef NCollection_UBTree<Standard_Integer,Bnd_Sphere> Extrema_UBTreeOfSphere;
-typedef NCollection_UBTreeFiller<Standard_Integer,Bnd_Sphere> Extrema_UBTreeFillerOfSphere;
-typedef NCollection_Handle<Extrema_UBTreeOfSphere> Extrema_HUBTreeOfSphere;
-
-#endif //_Extrema_HUBTreeOfSphere_HeaderFile
diff --git a/src/FWOSPlugin/EXTERNLIB b/src/FWOSPlugin/EXTERNLIB
index 0348bd9..4bd793d 100644
--- a/src/FWOSPlugin/EXTERNLIB
+++ b/src/FWOSPlugin/EXTERNLIB
@@ -1 +1,2 @@
+TKernel
 TKCDF
diff --git a/src/GeomFill/GeomFill.cxx b/src/GeomFill/GeomFill.cxx
index 889ae36..9c9a7ba 100644
--- a/src/GeomFill/GeomFill.cxx
+++ b/src/GeomFill/GeomFill.cxx
@@ -26,12 +26,7 @@
 #include <GeomFill_PolynomialConvertor.hxx>
 #include <GeomFill_QuasiAngularConvertor.hxx>
 #include <Precision.hxx>
-#include <Standard_Static.hxx>
 
-// La classe de convertion
-Standard_STATIC (GeomFill_PolynomialConvertor, PConvertor);
-Standard_STATIC (GeomFill_QuasiAngularConvertor, QConvertor);
- 
 
 //=======================================================================
 //function : Surface
@@ -390,15 +385,17 @@ void GeomFill::GetCircle( const Convert_ParameterisationType  TConv,
 
   switch (TConv) {
   case Convert_QuasiAngular:
-    {   // On utilise le bon  "Convertor" 
-      if (!QConvertor().Initialized()) QConvertor().Init();
-      QConvertor().Section(pts1, Center, nplan, Angle, Poles, Weights);
+    {
+      GeomFill_QuasiAngularConvertor QConvertor;
+      QConvertor.Init();
+      QConvertor.Section(pts1, Center, nplan, Angle, Poles, Weights);
       break;
     }
   case Convert_Polynomial:
-    { // On utilise le bon  "Convertor" 
-      if (!PConvertor().Initialized()) PConvertor().Init();
-      PConvertor().Section(pts1, Center, nplan, Angle, Poles);
+    { 
+      GeomFill_PolynomialConvertor PConvertor;
+      PConvertor.Init();
+      PConvertor.Section(pts1, Center, nplan, Angle, Poles);
       Weights.Init(1);
       break;
     }
@@ -495,8 +492,9 @@ Standard_Boolean GeomFill::GetCircle(const Convert_ParameterisationType  TConv,
   switch (TConv) {
   case Convert_QuasiAngular:
     {
-      if (!QConvertor().Initialized()) QConvertor().Init();
-      QConvertor().Section(pts1, tang1, 
+      GeomFill_QuasiAngularConvertor QConvertor;
+      QConvertor.Init();
+      QConvertor.Section(pts1, tang1, 
 			Center, DCenter, 
 			nplan, dnplan,
 			Angle, DAngle,
@@ -506,8 +504,9 @@ Standard_Boolean GeomFill::GetCircle(const Convert_ParameterisationType  TConv,
   }
   case Convert_Polynomial:
     {
-      if (!PConvertor().Initialized()) PConvertor().Init();
-      PConvertor().Section(pts1, tang1, 
+      GeomFill_PolynomialConvertor PConvertor;
+      PConvertor.Init();
+      PConvertor.Section(pts1, tang1, 
 			Center, DCenter, 
 			nplan, dnplan,
 			Angle, DAngle,
@@ -649,8 +648,9 @@ Standard_Boolean GeomFill::GetCircle(const Convert_ParameterisationType  TConv,
   switch (TConv) {
   case Convert_QuasiAngular:
     {
-      if (!QConvertor().Initialized()) QConvertor().Init();
-      QConvertor().Section(pts1, tang1, Dtang1,
+      GeomFill_QuasiAngularConvertor QConvertor;
+      QConvertor.Init();
+      QConvertor.Section(pts1, tang1, Dtang1,
 			   Center, DCenter, D2Center,
 			   nplan, dnplan, d2nplan,
 			   Angle, DAngle, D2Angle,
@@ -660,8 +660,9 @@ Standard_Boolean GeomFill::GetCircle(const Convert_ParameterisationType  TConv,
   }
   case Convert_Polynomial:
     {
-      if (!PConvertor().Initialized()) PConvertor().Init();
-      PConvertor().Section(pts1, tang1, Dtang1,
+      GeomFill_PolynomialConvertor PConvertor;
+      PConvertor.Init();
+      PConvertor.Section(pts1, tang1, Dtang1,
 			   Center, DCenter, D2Center,
 			   nplan, dnplan,  d2nplan,
 			   Angle, DAngle, D2Angle,
diff --git a/src/GeometryTest/FILES b/src/GeometryTest/FILES
index 9b93feb..d79bef4 100644
--- a/src/GeometryTest/FILES
+++ b/src/GeometryTest/FILES
@@ -6,5 +6,4 @@ GeometryTest_API2dCommands.cxx
 GeometryTest_APICommands.cxx
 GeometryTest_ContinuityCommands.cxx
 GeometryTest_PolyCommands.cxx
-
-
+GeometryTest_TestProjCommands.cxx
diff --git a/src/GeometryTest/GeometryTest.cdl b/src/GeometryTest/GeometryTest.cdl
index 41990bd..baadcce 100644
--- a/src/GeometryTest/GeometryTest.cdl
+++ b/src/GeometryTest/GeometryTest.cdl
@@ -55,4 +55,7 @@ is
 	---Purpose: defines     command  to    test  the    polyhedral
 	--          triangulations and the polygons from the Poly package.
     
+    TestProjCommands(I : in out Interpretor from Draw);
+	---Purpose: defines commands to test projection of geometric objects
+    
 end GeometryTest;
diff --git a/src/GeometryTest/GeometryTest.cxx b/src/GeometryTest/GeometryTest.cxx
index 314069a..448803a 100644
--- a/src/GeometryTest/GeometryTest.cxx
+++ b/src/GeometryTest/GeometryTest.cxx
@@ -24,6 +24,7 @@ void GeometryTest::AllCommands(Draw_Interpretor& theCommands)
 //  GeometryTest::API2dCommands(theCommands);
   GeometryTest::APICommands(theCommands);
   GeometryTest::ContinuityCommands(theCommands);
+  GeometryTest::TestProjCommands(theCommands);
   // define the TCL variable Draw_GEOMETRY
   //char* com = "set Draw_GEOMETRY 1";
   //theCommands.Eval(com);
diff --git a/src/GeometryTest/GeometryTest_CurveCommands.cxx b/src/GeometryTest/GeometryTest_CurveCommands.cxx
index 907cb3a..e400f75 100644
--- a/src/GeometryTest/GeometryTest_CurveCommands.cxx
+++ b/src/GeometryTest/GeometryTest_CurveCommands.cxx
@@ -1261,12 +1261,12 @@ static Standard_Integer surfpoints (Draw_Interpretor& /*di*/, Standard_Integer /
 //function : intersect
 //purpose  : 
 //=======================================================================
-
 static Standard_Integer intersection (Draw_Interpretor& di, Standard_Integer n, const char** a)
 {
-  
-  if (n < 4) return 1;
-
+  if (n < 4) {
+    return 1;
+  }
+  //
   Handle(Geom_Curve) GC1;
   Handle(Geom_Surface) GS1 = DrawTrSurf::GetSurface(a[2]);
   if (GS1.IsNull()) {
@@ -1274,61 +1274,41 @@ static Standard_Integer intersection (Draw_Interpretor& di, Standard_Integer n,
     if (GC1.IsNull())
       return 1;
   }
-  
+  //
   Handle(Geom_Surface) GS2 = DrawTrSurf::GetSurface(a[3]);
-  if (GS2.IsNull()) return 1;
-
+  if (GS2.IsNull()) {
+    return 1;
+  }
+  //
   Standard_Real tol = Precision::Confusion();
   if (n == 5 || n == 9 || n == 13 || n == 17) tol = atof(a[n-1]);
-
+  //
   Handle(Geom_Curve) Result;
   gp_Pnt             Point;
-
+  //
   if (GC1.IsNull()) {
-
+    GeomInt_IntSS Inters;
+    //
     // Surface Surface
-
     if (n <= 5) {
       // General case
-      GeomAPI_IntSS Inters(GS1,GS2,tol);
-  
-      if (!Inters.IsDone()) return 1;
-    
-      Standard_Integer nblines = Inters.NbLines();
-      if (nblines >= 2) {
-        char newname[1024];
-        for (Standard_Integer i=1; i<=nblines; i++) {
-          sprintf(newname,"%s_%d",a[1],i);
-          Result = Inters.Line(i);
-          const char* temp = newname; // pour portage WNT
-          DrawTrSurf::Set(temp,Result);
-        }
-      }
-      else if (nblines == 1) {
-        Result = Inters.Line(1);
-        DrawTrSurf::Set(a[1],Result);
-      }
+      Inters.Perform(GS1,GS2,tol,Standard_True);
     }
-
     else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17) {
-      GeomInt_IntSS Inters;
       Standard_Boolean useStart = Standard_True, useBnd = Standard_True;
       Standard_Integer ista1=0,ista2=0,ibnd1=0,ibnd2=0;
       Standard_Real UVsta[4];
       Handle(GeomAdaptor_HSurface) AS1,AS2;
-
-      if (n <= 9) {
-        // user starting point
+      //
+      if (n <= 9) {        // user starting point
         useBnd = Standard_False;
         ista1 = 4; ista2 = 7;
       }
-      else if (n <= 13) {
-        // user bounding
+      else if (n <= 13) {        // user bounding
         useStart = Standard_False;
         ibnd1 = 4; ibnd2 = 11;
       }
-      else {
-        // both user starting point and bounding
+      else {        // both user starting point and bounding
         ista1 = 4; ista2 = 7;
         ibnd1 = 8; ibnd2 = 15;
       }
@@ -1342,56 +1322,56 @@ static Standard_Integer intersection (Draw_Interpretor& di, Standard_Integer n,
         AS1 = new GeomAdaptor_HSurface(GS1,UVbnd[0],UVbnd[1],UVbnd[2],UVbnd[3]);
         AS2 = new GeomAdaptor_HSurface(GS2,UVbnd[4],UVbnd[5],UVbnd[6],UVbnd[7]);
       }
-
-      if      (useStart && !useBnd)
+      //
+      if (useStart && !useBnd) {
         Inters.Perform(GS1,GS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
-      else if (!useStart && useBnd)
-        Inters.Perform(AS1,AS2,tol);
-      else
-        Inters.Perform(AS1,AS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
-
-      if (!Inters.IsDone()) return 1;
-
-      Standard_Integer nblines = Inters.NbLines();
-      if (nblines >= 2) {
-        char newname[1024];
-        for (Standard_Integer i=1; i<=nblines; i++) {
-          sprintf(newname,"%s_%d",a[1],i);
-          Result = Inters.Line(i);
-          const char* temp = newname;
-          DrawTrSurf::Set(temp,Result);
-        }
       }
-      else if (nblines == 1) {
-        Result = Inters.Line(1);
-        DrawTrSurf::Set(a[1],Result);
+      else if (!useStart && useBnd) {
+        Inters.Perform(AS1,AS2,tol);
       }
-
-      nblines = Inters.NbBoundaries();
-      if (nblines > 0) {
-        di<<"there are "<<nblines<<" boundary solutions"<<"\n";
-        char newname[1024];
-        for (Standard_Integer i=1; i<=nblines; i++) {
-          if (nblines > 1) sprintf(newname,"%s_b_%d",a[1],i);
-          else             sprintf(newname,"%s_b",a[1]);
-          Result = Inters.Boundary(i);
-          const char* temp = newname;
-          DrawTrSurf::Set(temp,Result);
-        }
+      else {
+        Inters.Perform(AS1,AS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
       }
-    }
-
+    }//else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17) {
     else {
       di<<"incorrect number of arguments"<<"\n";
       return 1;
     }
-  }
-
+    //
+    if (!Inters.IsDone()) {
+      return 1;
+    }
+    //
+    char buf[1024];
+    Standard_Integer i, aNbLines, aNbPoints; 
+      //
+    aNbLines = Inters.NbLines();
+    if (aNbLines >= 2) {
+      for (i=1; i<=aNbLines; ++i) {
+	sprintf(buf, "%s_%d",a[1],i);
+	Result = Inters.Line(i);
+	const char* temp = buf; 
+	DrawTrSurf::Set(temp,Result);
+      }
+    }
+    else if (aNbLines == 1) {
+      Result = Inters.Line(1);
+      DrawTrSurf::Set(a[1],Result);
+    }
+    //
+    aNbPoints=Inters.NbPoints();
+    for (i=1; i<=aNbPoints; ++i) {
+      Point=Inters.Point(i);
+      sprintf(buf,"%s_p_%d",a[1],i);
+      const char* temp =buf;
+      DrawTrSurf::Set(temp, Point);
+    }
+  }// if (GC1.IsNull()) {
+  //
   else {
-    
     // Curve Surface
     GeomAPI_IntCS Inters(GC1,GS2);
-  
+    //
     if (!Inters.IsDone()) return 1;
     
     Standard_Integer nblines = Inters.NbSegments();
@@ -1431,8 +1411,6 @@ static Standard_Integer intersection (Draw_Interpretor& di, Standard_Integer n,
 //function : CurveCommands
 //purpose  : 
 //=======================================================================
-
-
 void  GeometryTest::CurveCommands(Draw_Interpretor& theCommands)
 {
   
diff --git a/src/GeometryTest/GeometryTest_TestProjCommands.cxx b/src/GeometryTest/GeometryTest_TestProjCommands.cxx
new file mode 100644
index 0000000..fc3466a
--- /dev/null
+++ b/src/GeometryTest/GeometryTest_TestProjCommands.cxx
@@ -0,0 +1,112 @@
+// File:      GeometryTest_TestProjCommands.cxx
+// Created:   30.06.11 17:21:02
+// Author:    jgv at ROLEX
+// Copyright: Open CASCADE 2011
+
+#include <GeometryTest.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+
+#include <DBRep.hxx>
+#include <DBRep_DrawableShape.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Draw_Appli.hxx>
+#include <DrawTrSurf.hxx>
+#include <Draw_Marker3D.hxx>
+
+#include <stdio.h>
+#ifdef WNT
+Standard_IMPORT Draw_Viewer dout;
+#endif
+
+//=======================================================================
+//function : xdistcs
+//purpose  : 
+//=======================================================================
+static Standard_Integer xdistcs(Draw_Interpretor& , Standard_Integer n, const char** a)
+{
+  if (n<5) {
+    cout<<" Use xdistcs c s t1 t2 nbp"<<endl;
+    return 0;
+  }
+  //
+  Standard_Boolean bRet;
+  Standard_Integer i, aNbP, iSize;
+  Standard_Real aTol, aD, aT, aT1, aT2, dT;
+  gp_Pnt aP;
+  Handle(Geom_Curve) aC;
+  Handle(Geom_Surface) aS;
+  GeomAPI_ProjectPointOnSurf aPPS;
+  Handle(Draw_Marker3D) aMr;
+  Draw_Color aColor(Draw_rouge);
+  //
+  aTol=1.e-7;
+  //
+  aC=DrawTrSurf::GetCurve(a[1]);
+  if (aC.IsNull()) {
+    cout<<a[1]<<" is null curve"<<endl;
+    return 0;
+  }
+  //
+  aS=DrawTrSurf::GetSurface(a[2]);
+  if (aS.IsNull()) {
+    cout<<a[2]<<" is null"<<endl;
+    return 0;
+  }
+  //
+  aT1=atof(a[3]);
+  aT2=atof(a[4]);
+  //
+  aNbP=10;
+  if (n>5) {
+    aNbP=atoi(a[5]);
+  }
+  //
+  iSize=3;
+  //
+  dT=(aT2-aT1)/(aNbP-1);
+  for (i=0; i<aNbP; ++i) {
+    aT=aT1+i*dT;
+    if (i==aNbP-1) {
+      aT=aT2;
+    }
+    //
+    aC->D0(aT, aP);
+    aPPS.Init(aP, aS, aTol);
+    bRet=aPPS.IsDone();
+    if (!bRet) {
+      cout<<" GeomAPI_ProjectPointOnSurf failed"<<endl;
+      return 0;
+    }
+    //
+    aD=aPPS.LowerDistance();
+    printf(" T=%lg\tD=%lg\n", aT, aD);
+    //
+    aMr=new Draw_Marker3D(aP, Draw_Plus, aColor, iSize);
+    dout << aMr;
+  }
+  //
+  return 0;
+}
+
+//=======================================================================
+//function : TestProjCommands
+//purpose  : 
+//=======================================================================
+
+void  GeometryTest::TestProjCommands(Draw_Interpretor& theCommands)
+{
+  
+  static Standard_Boolean loaded = Standard_False;
+  if (loaded) return;
+  loaded = Standard_True;
+  
+  DrawTrSurf::BasicCommands(theCommands);
+  
+  const char* g;
+  
+  g = "Testing of projection (geometric objects)";
+  
+  theCommands.Add("xdistcs", "xdistcs c s t1 t2 nbp", __FILE__, xdistcs, g);
+}
diff --git a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx
index ea7d6a6..351f62f 100644
--- a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx
+++ b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx
@@ -906,6 +906,9 @@ Standard_Boolean Graphic3d_ArrayOfPrimitives::IsValid() {
       return Standard_False;
   }
 
+  // total number of edges(verticies) in bounds should be the same as variable
+  // of total number of defined edges(verticies); if no edges - only verticies 
+  // could be in bounds.
   if( nbounds > 0 ) {
     for( i=n=0 ; i<nbounds ; i++ ) {
       n += myPrimitiveArray->bounds[i];
@@ -916,7 +919,7 @@ Standard_Boolean Graphic3d_ArrayOfPrimitives::IsValid() {
 #endif
       if( nedges > n ) myPrimitiveArray->num_edges = n;
       else return Standard_False;
-    } else if( n != nvertexs ) {
+    } else if ( nedges == 0 && n != nvertexs ) {
 #if TRACE > 0
       cout << " *** An " << name << " has an incoherent number of vertexs " << nvertexs << endl;
 #endif
@@ -925,6 +928,7 @@ Standard_Boolean Graphic3d_ArrayOfPrimitives::IsValid() {
     }
   }
 
+  // check that edges (indexes to an array of verticies) are in range.
   if( nedges > 0 ) {
     for( i=0 ; i<nedges ; i++ ) {
       if( myPrimitiveArray->edges[i] >= myPrimitiveArray->num_vertexs ) {
@@ -936,116 +940,5 @@ Standard_Boolean Graphic3d_ArrayOfPrimitives::IsValid() {
     }
   }
 
-  Standard_Integer format;
-  Standard_Boolean valid = Standard_True;
-  for( i=0 ; i<nvertexs ; i++ ) {
-    format = myPrimitiveArray->format;
-    if( format != myPrimitiveArray->format ) {
-      valid = Standard_False;
-#if TRACE > 0
-      cout << " *** An " << name << " has an incoherent kind of vertexs " 
-        << i+1 << " of type " << myPrimitiveArray->format << "/" << format << endl;
-#endif
-      break;
-    }
-  }
-
-  if( valid ) return Standard_True;
-
-  if( nbounds > 0 ) 
-  {
-    for( j=n=0 ; j<nbounds ; j++ ) 
-    {
-      k = myPrimitiveArray->bounds[j];
-      for( i=0 ; i<k ; i++ ) 
-      {
-         format = myPrimitiveArray->format;
-        if( format != myPrimitiveArray->format ) 
-        {
-          if( myPrimitiveArray->format & MVNORMAL ) switch( myPrimitiveArray->type ) 
-          {
-      case TelPolygonsArrayType:
-        if( i == 0 ) ComputeVNormals(n+i,n+k-1);
-        break;
-      case TelTrianglesArrayType:
-        if( !(i % 3) ) ComputeVNormals(n+i,n+i+2);
-        break;
-      case TelQuadranglesArrayType:
-        if( !(i % 4) ) ComputeVNormals(n+i,n+i+3);
-        break;
-      case TelTriangleFansArrayType:
-      case TelTriangleStripsArrayType:
-        if( i < k-2 ) ComputeVNormals(n+i,n+i+2);
-        else
-          break;
-      case TelQuadrangleStripsArrayType:
-        if( !(i %2) && (i < k-3) ) ComputeVNormals(n+i,n+i+3);
-        break;
-      default:
-        break;
-          }
-        }
-      }
-      n += myPrimitiveArray->bounds[j];
-    }
-  } else if( nedges > 0 ) {
-    for( i=0 ; i<nedges ; i++ ) {
-      k = myPrimitiveArray->edges[i];
-      format = myPrimitiveArray->format;
-      if( format != myPrimitiveArray->format ) {
-        if( myPrimitiveArray->format & MVNORMAL ) switch( myPrimitiveArray->type ) {
-          case TelPolygonsArrayType:
-            if( i == 0 ) ComputeVNormals(i,nedges-1);
-            break;
-          case TelTrianglesArrayType:
-            k = i/3*3;
-            ComputeVNormals(k,k+2);
-            break;
-          case TelQuadranglesArrayType:
-            k = i/4*4;
-            ComputeVNormals(k,k+3);
-            break;
-          case TelTriangleFansArrayType:
-          case TelTriangleStripsArrayType:
-            if( i < nedges-2 ) ComputeVNormals(i,i+2);
-            else
-            break;
-          case TelQuadrangleStripsArrayType:
-            if( !(i %2) && (i < nedges-3) ) ComputeVNormals(i,i+3);
-            break;
-          default:
-            break;
-        }
-      }
-    }
-  } else if( nvertexs > 0 ) {
-    for( i=0 ; i<nvertexs ; i++ ) {
-      format = myPrimitiveArray->format;
-      if( format != myPrimitiveArray->format ) {
-        if( myPrimitiveArray->format & MVNORMAL ) switch( myPrimitiveArray->type ) {
-          case TelPolygonsArrayType:
-            if( i == 0 ) ComputeVNormals(i,nvertexs-1);
-            break;
-          case TelTrianglesArrayType:
-            if( !(i % 3) ) ComputeVNormals(i,i+2);
-            break;
-          case TelQuadranglesArrayType:
-            if( !(i % 4) ) ComputeVNormals(i,i+3);
-            break;
-          case TelTriangleFansArrayType:
-          case TelTriangleStripsArrayType:
-            if( i < nvertexs-2 ) ComputeVNormals(i,i+2);
-            else
-            break;
-          case TelQuadrangleStripsArrayType:
-            if( !(i %2) && (i < nvertexs-3) ) ComputeVNormals(i,i+3);
-            break;
-          default:
-            break;
-        }
-      }
-    }
-  }
-
   return Standard_True;
 }
diff --git a/src/Graphic3d/Graphic3d_CGraduatedTrihedron.cxx b/src/Graphic3d/Graphic3d_CGraduatedTrihedron.cxx
index b6649de..4e3bdf6 100644
--- a/src/Graphic3d/Graphic3d_CGraduatedTrihedron.cxx
+++ b/src/Graphic3d/Graphic3d_CGraduatedTrihedron.cxx
@@ -1,3 +1,7 @@
+// File:      Graphic3d_CGraduatedTrihedron.cxx
+// Created:   6 March 2011
+// Author:    Sergey ZERCHANINOV
+// Copyright: OPEN CASCADE SA 2011
 
 #include <Graphic3d_CGraduatedTrihedron.hxx>
 
diff --git a/src/Graphic3d/Graphic3d_GraphicDriver.cdl b/src/Graphic3d/Graphic3d_GraphicDriver.cdl
index bacce22..6bc9d05 100644
--- a/src/Graphic3d/Graphic3d_GraphicDriver.cdl
+++ b/src/Graphic3d/Graphic3d_GraphicDriver.cdl
@@ -66,6 +66,7 @@ uses
     TypeOfTriedronPosition  from Aspect,
     Handle              from Aspect,
     Display             from Aspect,
+    PrintAlgo           from Aspect,
 
     AspectLine3d        from Graphic3d,
     AspectMarker3d      from Graphic3d,
@@ -927,138 +928,9 @@ is
     ---Category: Graduated  trihedron
     ---------------------------------
 
-    GetGraduatedTrihedron(me;
-                          view : CView from Graphic3d;
-                          -- Names of axes --
-                          xname : out CString from Standard;
-                          yname : out CString from Standard;
-                          zname : out CString from Standard;
-                          -- Draw names --
-                          xdrawname : out Boolean from Standard;
-                          ydrawname : out Boolean from Standard;
-                          zdrawname : out Boolean from Standard;
-                          -- Draw values --
-                          xdrawvalues : out Boolean from Standard;
-                          ydrawvalues : out Boolean from Standard;
-                          zdrawvalues : out Boolean from Standard;
-                          -- Draw grid --
-                          drawgrid : out Boolean from Standard;
-                          -- Draw axes --
-                          drawaxes : out Boolean from Standard;
-                          -- Number of splits along axes --
-                          nbx : out Integer from Standard;
-                          nby : out Integer from Standard;
-                          nbz : out Integer from Standard;
-                          -- Offset for drawing values --
-                          xoffset : out Integer from Standard;
-                          yoffset : out Integer from Standard;
-                          zoffset : out Integer from Standard;
-                          -- Offset for drawing names of axes --
-                          xaxisoffset : out Integer from Standard;
-                          yaxisoffset : out Integer from Standard;
-                          zaxisoffset : out Integer from Standard;
-                          -- Draw tickmarks --
-                          xdrawtickmarks : out Boolean from Standard;
-                          ydrawtickmarks : out Boolean from Standard;
-                          zdrawtickmarks : out Boolean from Standard;
-                          -- Length of tickmarks --
-                          xtickmarklength : out Integer from Standard;
-                          ytickmarklength : out Integer from Standard;
-                          ztickmarklength : out Integer from Standard;
-                          -- Grid color --
-                          gridcolor : out Color from Quantity;
-                          -- X name color --
-                          xnamecolor : out Color from Quantity;
-                          -- Y name color --
-                          ynamecolor : out Color from Quantity;
-                          -- Z name color --
-                          znamecolor : out Color from Quantity;
-                          -- X color of axis and values --
-                          xcolor : out Color from Quantity;
-                          -- Y color of axis and values --
-                          ycolor : out Color from Quantity;
-                          -- Z color of axis and values --
-                          zcolor : out Color from Quantity;
-                          -- Name of font for names of axes --
-                          fontOfNames : out CString from Standard;
-                          -- Style of names of axes --
-                          styleOfNames : out FontAspect from OSD;
-                          -- Size of names of axes --
-                          sizeOfNames : out Integer from Standard;
-                          -- Name of font for values --
-                          fontOfValues : out CString from Standard;
-                          -- Style of values --
-                          styleOfValues : out FontAspect from OSD;
-                          -- Size of values --
-                          sizeOfValues : out Integer from Standard)
-    ---Purpose: call_togl_graduatedtrihedron_get
-    is virtual;
-
     GraduatedTrihedronDisplay(me : mutable;
                               view : CView from Graphic3d;
-                              cubic : in out CGraduatedTrihedron from Graphic3d;
-                              -- Names of axes --
-                              xname : CString from Standard;
-                              yname : CString from Standard;
-                              zname : CString from Standard;
-                              -- Draw names --
-                              xdrawname : Boolean from Standard;
-                              ydrawname : Boolean from Standard;
-                              zdrawname : Boolean from Standard;
-                              -- Draw values --
-                              xdrawvalues : Boolean from Standard;
-                              ydrawvalues : Boolean from Standard;
-                              zdrawvalues : Boolean from Standard;
-                              -- Draw grid --
-                              drawgrid : Boolean from Standard;
-                              -- Draw axes --
-                              drawaxes : Boolean from Standard;
-                              -- Number of splits along axes --
-                              nbx : Integer from Standard;
-                              nby : Integer from Standard;
-                              nbz : Integer from Standard;
-                              -- Offset for drawing values --
-                              xoffset : Integer from Standard;
-                              yoffset : Integer from Standard;
-                              zoffset : Integer from Standard;
-                              -- Offset for drawing names of axes --
-                              xaxisoffset : Integer from Standard;
-                              yaxisoffset : Integer from Standard;
-                              zaxisoffset : Integer from Standard;
-                              -- Draw tickmarks --
-                              xdrawtickmarks : Boolean from Standard;
-                              ydrawtickmarks : Boolean from Standard;
-                              zdrawtickmarks : Boolean from Standard;
-                              -- Length of tickmarks --
-                              xtickmarklength : Integer from Standard;
-                              ytickmarklength : Integer from Standard;
-                              ztickmarklength : Integer from Standard;
-                              -- Grid color --
-                              gridcolor : Color from Quantity;
-                              -- X name color --
-                              xnamecolor : Color from Quantity;
-                              -- Y name color --
-                              ynamecolor : Color from Quantity;
-                              -- Z name color --
-                              znamecolor : Color from Quantity;
-                              -- X color of axis and values --
-                              xcolor : Color from Quantity;
-                              -- Y color of axis and values --
-                              ycolor : Color from Quantity;
-                              -- Z color of axis and values --
-                              zcolor : Color from Quantity;
-                              -- Name of font for names of axes --
-                              fontOfNames : CString from Standard;
-                              -- Style of names of axes --
-                              styleOfNames : FontAspect from OSD;
-                              -- Size of names of axes --
-                              sizeOfNames : Integer from Standard;
-                              -- Name of font for values --
-                              fontOfValues : CString from Standard;
-                              -- Style of values --
-                              styleOfValues : FontAspect from OSD;
-                              -- Size of values --
-                              sizeOfValues : Integer from Standard)
+                              cubic : CGraduatedTrihedron from Graphic3d)
     ---Purpose: call_togl_graduatedtrihedron_display
     is deferred;
 
@@ -1429,8 +1301,10 @@ is
            ACOverLayer     : CLayer2d from Aspect;
            hPrnDC          : Handle from Aspect;
            showBackground  : Boolean;
-           filename        : CString)
-        is deferred;
+           filename        : CString;
+           printAlgorithm  : PrintAlgo from Aspect = Aspect_PA_STRETCH;
+           theScaleFactor  : Real from Standard = 1.0 )
+        returns Boolean from Standard is deferred;
       ---Level: Internal
       ---Purpose: print the contents of all layers of the view to the printer.
     -- <hPrnDC> : Pass the PrinterDeviceContext (HDC),
@@ -1438,6 +1312,13 @@ is
     -- (background is white)
       -- else set to TRUE for printing with current background color.
     -- <filename>: If != NULL, then the view will be printed to a file.
+    -- <printAlgorithm>: Select print algorithm: stretch, tile.   
+    -- <theScaleFactor>: Scaling coefficient, used internally to scale the
+    -- printings accordingly to the scale factor selected in the printer 
+    -- properties dialog.
+    -- Returns Standard_True if the data is passed to the printer, otherwise
+    -- Standard_False if the print operation failed due to the printer errors, 
+    -- or insufficient system memory available.
     ---Warning: Works only under Windows.
 
 
@@ -1452,6 +1333,15 @@ is
                 ProgressBarFunc  : Address from Standard = NULL;
                 ProgressObject   : Address from Standard = NULL ) is deferred;
 
+    RemovePrimitiveArray( me        : mutable;
+                          theCGroup : CGroup from Graphic3d;
+                          thePArray : PrimitiveArray from Graphic3d )
+        is deferred;
+        ---Purpose: Clear visualization data in graphical driver and
+        -- stop displaying the primitives array of the graphical group
+        -- <theCGroup>. This method is internal and should be used
+        -- by Graphic3d_Group only.
+
     --------------------------
     -- Category: Class methods
     --------------------------
diff --git a/src/Graphic3d/Graphic3d_GraphicDriver_9.cxx b/src/Graphic3d/Graphic3d_GraphicDriver_9.cxx
index 8c19d2b..8d3ab63 100644
--- a/src/Graphic3d/Graphic3d_GraphicDriver_9.cxx
+++ b/src/Graphic3d/Graphic3d_GraphicDriver_9.cxx
@@ -107,136 +107,8 @@ void Graphic3d_GraphicDriver::SetBgGradientStyle( const Graphic3d_CView& /*ACVie
 {
 }
 
-void Graphic3d_GraphicDriver::GetGraduatedTrihedron(const Graphic3d_CView&,
-                                                    /* Names of axes */
-                                                    Standard_CString&, 
-                                                    Standard_CString&, 
-                                                    Standard_CString&,
-                                                    /* Draw names */
-                                                    Standard_Boolean&, 
-                                                    Standard_Boolean&, 
-                                                    Standard_Boolean&,
-                                                    /* Draw values */
-                                                    Standard_Boolean&, 
-                                                    Standard_Boolean&, 
-                                                    Standard_Boolean&,
-                                                    /* Draw grid */
-                                                    Standard_Boolean&,
-                                                    /* Draw axes */
-                                                    Standard_Boolean&,
-                                                    /* Number of splits along axes */
-                                                    Standard_Integer&, 
-                                                    Standard_Integer&, 
-                                                    Standard_Integer&,
-                                                    /* Offset for drawing values */
-                                                    Standard_Integer&, 
-                                                    Standard_Integer&, 
-                                                    Standard_Integer&,
-                                                    /* Offset for drawing names of axes */
-                                                    Standard_Integer&, 
-                                                    Standard_Integer&, 
-                                                    Standard_Integer&,
-                                                    /* Draw tickmarks */
-                                                    Standard_Boolean&, 
-                                                    Standard_Boolean&, 
-                                                    Standard_Boolean&,
-                                                    /* Length of tickmarks */
-                                                    Standard_Integer&, 
-                                                    Standard_Integer&, 
-                                                    Standard_Integer&,
-                                                    /* Grid color */
-                                                    Quantity_Color&,
-                                                    /* X name color */
-                                                    Quantity_Color&,
-                                                    /* Y name color */
-                                                    Quantity_Color&,
-                                                    /* Z name color */
-                                                    Quantity_Color&,
-                                                    /* X color of axis and values */
-                                                    Quantity_Color&,
-                                                    /* Y color of axis and values */
-                                                    Quantity_Color&,
-                                                    /* Z color of axis and values */
-                                                    Quantity_Color&,
-                                                    /* Name of font for names of axes */
-                                                    Standard_CString&,
-                                                    /* Style of names of axes */
-                                                    OSD_FontAspect&,
-                                                    /* Size of names of axes */
-                                                    Standard_Integer&,
-                                                    /* Name of font for values */
-                                                    Standard_CString&,
-                                                    /* Style of values */
-                                                    OSD_FontAspect&,
-                                                    /* Size of values */
-                                                    Standard_Integer&) const
-{
-}
-
 void Graphic3d_GraphicDriver::GraduatedTrihedronDisplay(const Graphic3d_CView&,
-                                                        Graphic3d_CGraduatedTrihedron&,
-                                                        /* Names of axes */
-                                                        const Standard_CString, 
-                                                        const Standard_CString, 
-                                                        const Standard_CString,
-                                                        /* Draw names */
-                                                        const Standard_Boolean, 
-                                                        const Standard_Boolean, 
-                                                        const Standard_Boolean,
-                                                        /* Draw values */
-                                                        const Standard_Boolean, 
-                                                        const Standard_Boolean, 
-                                                        const Standard_Boolean,
-                                                        /* Draw grid */
-                                                        const Standard_Boolean,
-                                                        /* Draw axes */
-                                                        const Standard_Boolean,
-                                                        /* Number of splits along axes */
-                                                        const Standard_Integer, 
-                                                        const Standard_Integer, 
-                                                        const Standard_Integer,
-                                                        /* Offset for drawing values */
-                                                        const Standard_Integer, 
-                                                        const Standard_Integer, 
-                                                        const Standard_Integer,
-                                                        /* Offset for drawing names of axes */
-                                                        const Standard_Integer, 
-                                                        const Standard_Integer, 
-                                                        const Standard_Integer,
-                                                        /* Draw tickmarks */
-                                                        const Standard_Boolean, 
-                                                        const Standard_Boolean, 
-                                                        const Standard_Boolean,
-                                                        /* Length of tickmarks */
-                                                        const Standard_Integer, 
-                                                        const Standard_Integer, 
-                                                        const Standard_Integer,
-                                                        /* Grid color */
-                                                        const Quantity_Color&,
-                                                        /* X name color */
-                                                        const Quantity_Color&,
-                                                        /* Y name color */
-                                                        const Quantity_Color&,
-                                                        /* Z name color */
-                                                        const Quantity_Color&,
-                                                        /* X color of axis and values */
-                                                        const Quantity_Color&,
-                                                        /* Y color of axis and values */
-                                                        const Quantity_Color&,
-                                                        /* Z color of axis and values */
-                                                        const Quantity_Color&,
-                                                        /* Name of font for names of axes */
-                                                        const Standard_CString,
-                                                        /* Style of names of axes */
-                                                        const OSD_FontAspect,
-                                                        /* Size of names of axes */
-                                                        const Standard_Integer,
-                                                        /* Name of font for values */
-                                                        const Standard_CString,
-                                                        /* Style of values */
-                                                        const OSD_FontAspect,
-                                                        /* Size of values */
-                                                        const Standard_Integer)
+                                                        const Graphic3d_CGraduatedTrihedron&)
 {
 }
 
diff --git a/src/Graphic3d/Graphic3d_GraphicDriver_Print.cxx b/src/Graphic3d/Graphic3d_GraphicDriver_Print.cxx
index 0ee4d5d..ddc2075 100644
--- a/src/Graphic3d/Graphic3d_GraphicDriver_Print.cxx
+++ b/src/Graphic3d/Graphic3d_GraphicDriver_Print.cxx
@@ -14,10 +14,14 @@
 /* Print Methods                                                        */
 /************************************************************************/
 
-void Graphic3d_GraphicDriver::Print (const Graphic3d_CView& , 
-                                     const Aspect_CLayer2d& , 
-                                     const Aspect_CLayer2d& , 
-                                     const Aspect_Handle ,
-                                     const Standard_Boolean ,
-                                     const Standard_CString ) const {
-                                     }
+Standard_Boolean Graphic3d_GraphicDriver::Print (const Graphic3d_CView& , 
+                                                 const Aspect_CLayer2d& , 
+                                                 const Aspect_CLayer2d& , 
+                                                 const Aspect_Handle ,
+                                                 const Standard_Boolean ,
+                                                 const Standard_CString ,
+                                                 const Aspect_PrintAlgo ,
+	                                         const Standard_Real ) const
+{
+  return Standard_False;
+}
diff --git a/src/Graphic3d/Graphic3d_Group.cdl b/src/Graphic3d/Graphic3d_Group.cdl
index 5f7f17c..60dbafa 100644
--- a/src/Graphic3d/Graphic3d_Group.cdl
+++ b/src/Graphic3d/Graphic3d_Group.cdl
@@ -110,10 +110,17 @@
         -- Category: Methods to modify the class definition
         ---------------------------------------------------
     
-        Clear ( me  : mutable )
+        Clear ( me  : mutable;
+                theUpdateStructureMgr : Boolean from Standard = Standard_True )
             is static;
         ---Level: Public
         ---Purpose: Supress all primitives and attributes of <me>.
+        --          To clear group without update in Graphic3d_StructureManager
+        --          pass Standard_False as <theUpdateStructureMgr>. This
+        --          used on context and viewer destruction, when the pointer
+        --          to structure manager in Graphic3d_Structure could be 
+        --          already released (pointers are used here to avoid handle 
+        --          cross-reference);
         ---Category: Methods to modify the class definition
     
         Destroy ( me    : mutable )
diff --git a/src/Graphic3d/Graphic3d_Group_1.cxx b/src/Graphic3d/Graphic3d_Group_1.cxx
index 4d7fb59..43a255e 100644
--- a/src/Graphic3d/Graphic3d_Group_1.cxx
+++ b/src/Graphic3d/Graphic3d_Group_1.cxx
@@ -27,40 +27,43 @@
 
 //-Methods, in order
 
-void Graphic3d_Group::Clear () {
+void Graphic3d_Group::Clear (Standard_Boolean theUpdateStructureMgr)
+{
+  if (IsDeleted ()) return;
 
-	if (IsDeleted ()) return;
+  MyCGroup.ContextLine.IsSet     = 0,
+  MyCGroup.ContextText.IsSet     = 0,
+  MyCGroup.ContextMarker.IsSet   = 0,
+  MyCGroup.ContextFillArea.IsSet = 0;
 
-	MyCGroup.ContextLine.IsSet	= 0,
-	MyCGroup.ContextText.IsSet	= 0,
-	MyCGroup.ContextMarker.IsSet    = 0,
-	MyCGroup.ContextFillArea.IsSet	= 0;
+  MyCGroup.ContextLine.IsDef     = 0,
+  MyCGroup.ContextText.IsDef     = 0,
+  MyCGroup.ContextMarker.IsDef   = 0,
+  MyCGroup.ContextFillArea.IsDef = 0;
 
-	MyCGroup.ContextLine.IsDef	= 0,
-	MyCGroup.ContextText.IsDef	= 0,
-	MyCGroup.ContextMarker.IsDef    = 0,
-	MyCGroup.ContextFillArea.IsDef	= 0;
+  MyCGroup.PickId.IsDef = 0,
+  MyCGroup.PickId.IsSet = 0,
+  MyCGroup.PickId.Value = 0;
 
-	MyCGroup.PickId.IsDef		= 0,
-	MyCGroup.PickId.IsSet		= 0,
-	MyCGroup.PickId.Value		= 0;
+  MyBounds.XMin	= ShortRealLast (),
+  MyBounds.YMin	= ShortRealLast (),
+  MyBounds.ZMin	= ShortRealLast ();
 
-	MyBounds.XMin	= ShortRealLast (),
-	MyBounds.YMin	= ShortRealLast (),
-	MyBounds.ZMin	= ShortRealLast ();
+  MyBounds.XMax	= ShortRealFirst (),
+  MyBounds.YMax	= ShortRealFirst (),
+  MyBounds.ZMax	= ShortRealFirst ();
 
-	MyBounds.XMax	= ShortRealFirst (),
-	MyBounds.YMax	= ShortRealFirst (),
-	MyBounds.ZMax	= ShortRealFirst ();
+  if (MyContainsFacet) MyStructure->GroupsWithFacet (-1);
+  MyContainsFacet = Standard_False,
+  MyIsEmpty       = Standard_True;
 
-	if (MyContainsFacet) MyStructure->GroupsWithFacet (-1);
-	MyContainsFacet	= Standard_False,
-	MyIsEmpty	= Standard_True;
-
-	MyGraphicDriver->ClearGroup (MyCGroup);
-
-	Update ();
+  MyGraphicDriver->ClearGroup (MyCGroup);
 
+  // clear method could be used on Graphic3d_Structure destruction,
+  // and its structure manager could be already destroyed, in that
+  // case we don't need to update it;
+  if (theUpdateStructureMgr)
+    Update ();
 }
 
 void Graphic3d_Group::Destroy () {
@@ -69,6 +72,10 @@ void Graphic3d_Group::Destroy () {
 	cout << "Graphic3d_Group::Destroy ()\n";
 #endif
 
+  // tell graphics driver to clear internal resources of the group
+  if (!IsEmpty () && !MyGraphicDriver.IsNull ())
+    MyGraphicDriver->ClearGroup (MyCGroup);
+
 }
 
 void Graphic3d_Group::Remove () {
diff --git a/src/Graphic3d/Graphic3d_Group_10.cxx b/src/Graphic3d/Graphic3d_Group_10.cxx
index 3812c97..345b9db 100644
--- a/src/Graphic3d/Graphic3d_Group_10.cxx
+++ b/src/Graphic3d/Graphic3d_Group_10.cxx
@@ -1,9 +1,7 @@
-
-// File		Graphic3d_Group_10.cxx (Text)
-// Created	Fevrier 1992
-// Author	NW,JPB,CAL
-
-//-Copyright	MatraDatavision 1991,1992
+// File:      Graphic3d_Group_10.cxx (Text)
+// Created:   Fevrier 1992
+// Author:    NW,JPB,CAL
+// Copyright: OPEN CASCADE 1992
 
 //-Version	
 
@@ -36,29 +34,27 @@ void Graphic3d_Group::Text (
                        const Graphic3d_HorizontalTextAlignment AHta,
                        const Graphic3d_VerticalTextAlignment AVta,
                        const Standard_Boolean EvalMinMax
-                      ) {
-
-	if (IsDeleted ()) return;
-
-	MyIsEmpty	= Standard_False;
-
-	// Min-Max Update
-	if (EvalMinMax) {
-Standard_Real X, Y, Z;
-		APoint.Coord (X, Y, Z);
-		if (X < MyBounds.XMin) MyBounds.XMin	= Standard_ShortReal (X);
-		if (Y < MyBounds.YMin) MyBounds.YMin	= Standard_ShortReal (Y);
-		if (Z < MyBounds.ZMin) MyBounds.ZMin	= Standard_ShortReal (Z);
-		if (X > MyBounds.XMax) MyBounds.XMax	= Standard_ShortReal (X);
-		if (Y > MyBounds.YMax) MyBounds.YMax	= Standard_ShortReal (Y);
-		if (Z > MyBounds.ZMax) MyBounds.ZMax	= Standard_ShortReal (Z);
-	}
-
-	MyGraphicDriver->Text
-(MyCGroup, AText, APoint, AHeight, AAngle, ATp, AHta, AVta, EvalMinMax);
-
-	Update ();
-
+                      )
+{
+  if (IsDeleted ()) return;
+
+  MyIsEmpty = Standard_False;
+
+  // Min-Max Update
+  if (EvalMinMax) {
+    Standard_Real X, Y, Z;
+    APoint.Coord (X, Y, Z);
+    if (X < MyBounds.XMin) MyBounds.XMin	= Standard_ShortReal (X);
+    if (Y < MyBounds.YMin) MyBounds.YMin	= Standard_ShortReal (Y);
+    if (Z < MyBounds.ZMin) MyBounds.ZMin	= Standard_ShortReal (Z);
+    if (X > MyBounds.XMax) MyBounds.XMax	= Standard_ShortReal (X);
+    if (Y > MyBounds.YMax) MyBounds.YMax	= Standard_ShortReal (Y);
+    if (Z > MyBounds.ZMax) MyBounds.ZMax	= Standard_ShortReal (Z);
+  }
+
+  MyGraphicDriver->Text(MyCGroup, AText, APoint, AHeight, AAngle, ATp, AHta, AVta, EvalMinMax);
+
+  Update ();
 }
 
 void Graphic3d_Group::Text (
@@ -66,28 +62,27 @@ void Graphic3d_Group::Text (
                        const Graphic3d_Vertex& APoint, 
                        const Standard_Real AHeight, 
                        const Standard_Boolean EvalMinMax
-                      ) {
-
-	if (IsDeleted ()) return;
-
-	MyIsEmpty	= Standard_False;
-
-	// Min-Max Update
-	if (EvalMinMax) {
-Standard_Real X, Y, Z;
-		APoint.Coord (X, Y, Z);
-		if (X < MyBounds.XMin) MyBounds.XMin	= Standard_ShortReal (X);
-		if (Y < MyBounds.YMin) MyBounds.YMin	= Standard_ShortReal (Y);
-		if (Z < MyBounds.ZMin) MyBounds.ZMin	= Standard_ShortReal (Z);
-		if (X > MyBounds.XMax) MyBounds.XMax	= Standard_ShortReal (X);
-		if (Y > MyBounds.YMax) MyBounds.YMax	= Standard_ShortReal (Y);
-		if (Z > MyBounds.ZMax) MyBounds.ZMax	= Standard_ShortReal (Z);
-	}
-
-	MyGraphicDriver->Text (MyCGroup, AText, APoint, AHeight, EvalMinMax);
-
-	Update ();
-
+                      )
+{
+  if (IsDeleted ()) return;
+
+  MyIsEmpty = Standard_False;
+
+  // Min-Max Update
+  if (EvalMinMax) {
+    Standard_Real X, Y, Z;
+    APoint.Coord (X, Y, Z);
+    if (X < MyBounds.XMin) MyBounds.XMin	= Standard_ShortReal (X);
+    if (Y < MyBounds.YMin) MyBounds.YMin	= Standard_ShortReal (Y);
+    if (Z < MyBounds.ZMin) MyBounds.ZMin	= Standard_ShortReal (Z);
+    if (X > MyBounds.XMax) MyBounds.XMax	= Standard_ShortReal (X);
+    if (Y > MyBounds.YMax) MyBounds.YMax	= Standard_ShortReal (Y);
+    if (Z > MyBounds.ZMax) MyBounds.ZMax	= Standard_ShortReal (Z);
+  }
+
+  MyGraphicDriver->Text (MyCGroup, AText, APoint, AHeight, EvalMinMax);
+
+  Update ();
 }
 
 void Graphic3d_Group::Text (
@@ -99,31 +94,27 @@ void Graphic3d_Group::Text (
                        const Graphic3d_HorizontalTextAlignment AHta, 
                        const Graphic3d_VerticalTextAlignment AVta, 
                        const Standard_Boolean EvalMinMax
-                      ) {
-
-	if (IsDeleted ()) return;
-
-	if (! AText.IsAscii ()) return;
-
-	MyIsEmpty	= Standard_False;
-
-	// Min-Max Update
-	if (EvalMinMax) {
-Standard_Real X, Y, Z;
-		APoint.Coord (X, Y, Z);
-		if (X < MyBounds.XMin) MyBounds.XMin	= Standard_ShortReal (X);
-		if (Y < MyBounds.YMin) MyBounds.YMin	= Standard_ShortReal (Y);
-		if (Z < MyBounds.ZMin) MyBounds.ZMin	= Standard_ShortReal (Z);
-		if (X > MyBounds.XMax) MyBounds.XMax	= Standard_ShortReal (X);
-		if (Y > MyBounds.YMax) MyBounds.YMax	= Standard_ShortReal (Y);
-		if (Z > MyBounds.ZMax) MyBounds.ZMax	= Standard_ShortReal (Z);
-	}
-
-	MyGraphicDriver->Text
-(MyCGroup, AText, APoint, AHeight, AAngle, ATp, AHta, AVta, EvalMinMax);
-
-	Update ();
-
+                      )
+{
+  if (IsDeleted ()) return;
+
+  MyIsEmpty	= Standard_False;
+
+  // Min-Max Update
+  if (EvalMinMax) {
+    Standard_Real X, Y, Z;
+    APoint.Coord (X, Y, Z);
+    if (X < MyBounds.XMin) MyBounds.XMin	= Standard_ShortReal (X);
+    if (Y < MyBounds.YMin) MyBounds.YMin	= Standard_ShortReal (Y);
+    if (Z < MyBounds.ZMin) MyBounds.ZMin	= Standard_ShortReal (Z);
+    if (X > MyBounds.XMax) MyBounds.XMax	= Standard_ShortReal (X);
+    if (Y > MyBounds.YMax) MyBounds.YMax	= Standard_ShortReal (Y);
+    if (Z > MyBounds.ZMax) MyBounds.ZMax	= Standard_ShortReal (Z);
+  }
+
+  MyGraphicDriver->Text(MyCGroup, AText, APoint, AHeight, AAngle, ATp, AHta, AVta, EvalMinMax);
+
+  Update ();
 }
 
 void Graphic3d_Group::Text (
@@ -131,28 +122,25 @@ void Graphic3d_Group::Text (
                        const Graphic3d_Vertex& APoint, 
                        const Standard_Real AHeight, 
                        const Standard_Boolean EvalMinMax
-                      ) {
-
-	if (IsDeleted ()) return;
-
-	if (! AText.IsAscii ()) return;
-
-	MyIsEmpty	= Standard_False;
-
-	// Min-Max Update
-	if (EvalMinMax) {
-Standard_Real X, Y, Z;
-		APoint.Coord (X, Y, Z);
-		if (X < MyBounds.XMin) MyBounds.XMin	= Standard_ShortReal (X);
-		if (Y < MyBounds.YMin) MyBounds.YMin	= Standard_ShortReal (Y);
-		if (Z < MyBounds.ZMin) MyBounds.ZMin	= Standard_ShortReal (Z);
-		if (X > MyBounds.XMax) MyBounds.XMax	= Standard_ShortReal (X);
-		if (Y > MyBounds.YMax) MyBounds.YMax	= Standard_ShortReal (Y);
-		if (Z > MyBounds.ZMax) MyBounds.ZMax	= Standard_ShortReal (Z);
-	}
-
-	MyGraphicDriver->Text (MyCGroup, AText, APoint, AHeight, EvalMinMax);
-
-	Update ();
-
+                      )
+{
+  if (IsDeleted ()) return;
+
+  MyIsEmpty = Standard_False;
+
+  // Min-Max Update
+  if (EvalMinMax) {
+    Standard_Real X, Y, Z;
+    APoint.Coord (X, Y, Z);
+    if (X < MyBounds.XMin) MyBounds.XMin	= Standard_ShortReal (X);
+    if (Y < MyBounds.YMin) MyBounds.YMin	= Standard_ShortReal (Y);
+    if (Z < MyBounds.ZMin) MyBounds.ZMin	= Standard_ShortReal (Z);
+    if (X > MyBounds.XMax) MyBounds.XMax	= Standard_ShortReal (X);
+    if (Y > MyBounds.YMax) MyBounds.YMax	= Standard_ShortReal (Y);
+    if (Z > MyBounds.ZMax) MyBounds.ZMax	= Standard_ShortReal (Z);
+  }
+
+  MyGraphicDriver->Text (MyCGroup, AText, APoint, AHeight, EvalMinMax);
+
+  Update ();
 }
diff --git a/src/Graphic3d/Graphic3d_Group_13.cxx b/src/Graphic3d/Graphic3d_Group_13.cxx
index 9f0f8c5..f607fff 100644
--- a/src/Graphic3d/Graphic3d_Group_13.cxx
+++ b/src/Graphic3d/Graphic3d_Group_13.cxx
@@ -45,8 +45,17 @@ void Graphic3d_Group :: AddPrimitiveArray ( const Handle(Graphic3d_ArrayOfPrimit
 }
 
 void Graphic3d_Group :: RemovePrimitiveArrays () {
-
-	MyListOfPArray.Clear();
+  // clear primitives array's visualization data in graphics driver and remove
+  // references to it in driver
+  if (!IsEmpty() && !MyGraphicDriver.IsNull())
+  {
+    for (Graphic3d_ListIteratorOfListOfPArray it (MyListOfPArray);
+         it.More(); it.Next())
+      MyGraphicDriver->RemovePrimitiveArray (MyCGroup, it.Value()->Array());
+  }
+
+  // remove references to primitives arrays
+  MyListOfPArray.Clear();
 }
 
 Standard_Integer Graphic3d_Group :: ArrayNumber () const {
@@ -80,7 +89,14 @@ void Graphic3d_Group :: RemovePrimitiveArray ( const Standard_Integer aRank ) {
 	for( Standard_Integer i=1 ; it.More() ; it.Next(),i++ ) {
 	  if( aRank == i ) break;
 	}
-	MyListOfPArray.Remove(it);
+
+  // clear primitives array's visualization data in graphics driver and remove
+  // references to it in driver
+  if (!IsEmpty() && !MyGraphicDriver.IsNull())
+    MyGraphicDriver->RemovePrimitiveArray (MyCGroup, it.Value()->Array());
+
+  // remove references to primitives array
+  MyListOfPArray.Remove (it);
 }
 
 void Graphic3d_Group :: UserDraw ( const Standard_Address AnObject,				   
diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx
index 6c163f4..e61871c 100644
--- a/src/Graphic3d/Graphic3d_Structure.cxx
+++ b/src/Graphic3d/Graphic3d_Structure.cxx
@@ -216,22 +216,32 @@ void Graphic3d_Structure::Destroy () {
 
 //-Methods, in order
 
-void Graphic3d_Structure::Clear (const Standard_Boolean WithDestruction) {
+void Graphic3d_Structure::Clear (const Standard_Boolean WithDestruction)
+{
+  if (IsDeleted()) return;
 
-  if (IsDeleted ()) return;
+  MyCStructure.ContainsFacet = 0;
 
-  if (WithDestruction) {
-    MyGroupGenId.Free ();
-    MyGroups.Clear ();
+  // clean groups in graphics driver at first
+  if (WithDestruction)
+  {
+    // clean and empty each group
+    Standard_Integer Length = MyGroups.Length();
+    for (Standard_Integer aGrId = 1; aGrId <= Length; ++aGrId)
+      MyGroups.ChangeValue (aGrId)->Clear();
   }
+  GraphicClear (WithDestruction);
 
-  MyCStructure.ContainsFacet      = 0;
+  // only then remove group references
+  if (WithDestruction)
+  {
+    MyGroupGenId.Free();
+    MyGroups.Clear();
+  }
 
-  GraphicClear (WithDestruction);
   MyStructureManager->Clear (this, WithDestruction);
 
-  Update ();
-
+  Update();
 }
 
 void Graphic3d_Structure::Remove () {
@@ -250,6 +260,16 @@ void Graphic3d_Structure::Remove () {
 #endif
 
   Standard_Integer i, Length;
+
+  // clean groups in graphics driver at first; this is also should be done
+  // to avoid unwanted group cleaning in group's destructor
+  // Pass Standard_False to Clear(..) method to avoid updating in
+  // structure manager, it isn't necessary, besides of it structure manager
+  // could be already destroyed and invalid pointers used in structure;
+  Length = MyGroups.Length();
+  for (Standard_Integer aGrId = 1; aGrId <= Length; ++aGrId)
+    MyGroups.ChangeValue (aGrId)->Clear (Standard_False);
+
   //        Standard_Address APtr = (void *) This ().operator->();
   Standard_Address APtr = (void *) this;
   // It is necessary to remove the eventual pointer on the structure
diff --git a/src/HLRBRep/HLRBRep_PolyAlgo.cxx b/src/HLRBRep/HLRBRep_PolyAlgo.cxx
index 6230cf2..58f22e0 100644
--- a/src/HLRBRep/HLRBRep_PolyAlgo.cxx
+++ b/src/HLRBRep/HLRBRep_PolyAlgo.cxx
@@ -3651,8 +3651,8 @@ HLRBRep_PolyAlgo::UpdatePolyData (TColStd_Array1OfTransient& PD,
 	    Tri1Flags |=  FMskBack;
 	  }
 	  else
-//	    Tri1Flags &= ~FMskBack;
-	    Tri1Flags |= FMskBack;//OCC349
+	    Tri1Flags &= ~FMskBack;
+	    //Tri1Flags |= FMskBack;//OCC349
 	}
 	Tri2Node1 = Tri1Node1;
 	Tri2Node2 = Tri1Node2;
diff --git a/src/IGESToBRep/IGESToBRep_TopoSurface.cxx b/src/IGESToBRep/IGESToBRep_TopoSurface.cxx
index 21f703d..c0a6378 100644
--- a/src/IGESToBRep/IGESToBRep_TopoSurface.cxx
+++ b/src/IGESToBRep/IGESToBRep_TopoSurface.cxx
@@ -316,7 +316,7 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferTopoBasicSurface
     res = plane; 
   }
   else {
-    BRepLib_MakeFace makeFace(surf);
+    BRepLib_MakeFace makeFace(surf, Precision::Confusion());
     res = makeFace.Face();
   }
 
@@ -765,7 +765,7 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferSurfaceOfRevolution
         // PTV 29.08.2002  end of OCC663
       }
       if (!aResultSurf.IsNull()) {
-        BRepBuilderAPI_MakeFace aMakeF(aResultSurf);
+        BRepBuilderAPI_MakeFace aMakeF(aResultSurf, Precision::Confusion());
         if (aMakeF.IsDone()) res = aMakeF.Face();
       }
     }
@@ -902,7 +902,7 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferTabulatedCylinder
                                              aBasisCurve->FirstParameter(),
                                              aBasisCurve->LastParameter(),
                                              0., dir.Magnitude() );
-        BRepBuilderAPI_MakeFace aMakeF(aResultSurf);
+        BRepBuilderAPI_MakeFace aMakeF(aResultSurf, Precision::Confusion());
         if (aMakeF.IsDone()) res = aMakeF.Face();
       }
     }
@@ -1089,7 +1089,7 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferOffsetSurface
     basisSrf = new Geom_OffsetSurface(geomSupport, st->Distance()*GetUnitFactor());
   }
   
-  BRepLib_MakeFace MF(basisSrf);
+  BRepLib_MakeFace MF(basisSrf, Precision::Confusion());
   if(!MF.IsDone()) {
     Message_Msg msg1265("IGES_1265");
     SendFail(st, msg1265); // OffsetSurface Construction Error.
diff --git a/src/IntCurve/IntCurve_IntConicConic_1.cxx b/src/IntCurve/IntCurve_IntConicConic_1.cxx
index 1a040f9..275e849 100644
--- a/src/IntCurve/IntCurve_IntConicConic_1.cxx
+++ b/src/IntCurve/IntCurve_IntConicConic_1.cxx
@@ -378,23 +378,26 @@ void ProjectOnLAndIntersectWithLDomain(const gp_Circ2d& Circle
     NbSolTotal++;
   }
 }
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+//=======================================================================
+//function : LineCircleGeometricIntersection
+//purpose  : 
 //~~ On cherche des segments d intersection dans le `tuyau` 
 //~~   R+Tol   R-Tol  ( Tol est TolConf : Tolerance de confusion d arc)
 //~~ On Cherche un point d intersection a une distance TolTang du cercle.   
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-void LineCircleGeometricIntersection(const gp_Lin2d& Line
-				     ,const gp_Circ2d& Circle
-				     ,const Standard_Real Tol
-				     ,const Standard_Real TolTang
-				     ,PeriodicInterval& CInt1
-				     ,PeriodicInterval& CInt2
-				     ,Standard_Integer& nbsol) {
+//=======================================================================
+void LineCircleGeometricIntersection(const gp_Lin2d& Line,
+				     const gp_Circ2d& Circle,
+				     const Standard_Real Tol,
+				     const Standard_Real TolTang,
+				     PeriodicInterval& CInt1,
+				     PeriodicInterval& CInt2,
+				     Standard_Integer& nbsol) 
+{
   
 
   Standard_Real dO1O2=Line.Distance(Circle.Location());
   Standard_Real R=Circle.Radius();
-  //  Standard_Real RpTol=R+Tol; 
   Standard_Real RmTol=R-Tol;
   Standard_Real binf1,binf2=0,bsup1,bsup2=0;
     
@@ -412,12 +415,24 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line
   }
   else { 
     //---------------------------------------------------------------- 
-//    Standard_Real dO1O2dO1O2=dO1O2*dO1O2;
+    Standard_Boolean b2Sol;
     Standard_Real dAlpha1;
     //---------------------------------------------------------------
     //-- Line coupe le cercle Circle+ (=C(x1,y1,R1+Tol))
-    
-    if(dO1O2 > RmTol) { 
+    //modified by NIZNHY-PKV Thu May 12 12:25:17 2011f
+    b2Sol=Standard_False;
+    if (R>dO1O2+TolTang) {
+      Standard_Real aX2, aTol2;
+      //
+      aTol2=Tol*Tol;
+      aX2=4.*(R*R-dO1O2*dO1O2);
+      if (aX2>aTol2) {
+	b2Sol=!b2Sol;
+      }
+    }
+    if(dO1O2 > RmTol && !b2Sol) { 
+    //if(dO1O2 > RmTol) { 
+    //modified by NIZNHY-PKV Thu May 12 12:25:20 2011t
       Standard_Real dx=dO1O2;
       Standard_Real dy=0.0;     //(RpTol*RpTol-dx*dx); //Patch !!!
       dy=(dy>=0.0)? Sqrt(dy) : 0.0;
diff --git a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx
index 373ef7d..d93eedf 100644
--- a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx
+++ b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx
@@ -1220,25 +1220,6 @@ void SectionPointToParameters(const Intf_SectionPoint& Sp,
   }
 } 
 
-#define NBI 200
-
-static gp_Pnt P1[NBI][NBI];
-static gp_Pnt P2[NBI][NBI];
-static Standard_Integer IP1[NBI][NBI];
-static Standard_Integer IP2[NBI][NBI];
-
-static char             P1DS2[NBI][NBI];
-static char             P2DS1[NBI][NBI];
-
-#define _DECAL    7
-#define _DECAL2   14
-#define _BASE     128
-#define _BASEM1   127
-
-long unsigned nbappelstri=0;
-long unsigned nbappelslin=0;
-
-
 //==================================================================================
 // function : RemplitLin
 // purpose  : 
@@ -1340,541 +1321,748 @@ void IntPatch_PrmPrmIntersection::Remplit(const Standard_Integer a,
   }
 }
 
-//==================================================================================
-// function : PointDepart
-// purpose  : 
-//==================================================================================
-void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S,
-					      const Handle(Adaptor3d_HSurface)& S1,
-					      const Standard_Integer SU_1,
-					      const Standard_Integer SV_1,
-					      const Handle(Adaptor3d_HSurface)& S2,
-					      const Standard_Integer SU_2,
-					      const Standard_Integer SV_2) const 
-{ 
-  
-  Standard_Integer SU1 =SU_1 ;
-  Standard_Integer SV1 =SV_1 ;
-  Standard_Integer SU2 =SU_2 ;
-  Standard_Integer SV2 =SV_2 ;
-
-  SU1*=15;
-  SU2*=15;
-  SV1*=15;
-  SV2*=15;
-
-  if(NBI<SU1) SU1 = NBI;
-  if(NBI<SV1) SV1 = NBI;
-  if(NBI<SU2) SU2 = NBI;
-  if(NBI<SV2) SV2 = NBI;
-
-  //-- cout<<"\n SU1 "<<SU1<<" SV1 "<<SV1<<"  SU2 "<<SU2<<" SV2 "<<SV2<<endl;
-  Bnd_Box Box1;
-  Bnd_Box Box2;
-
-  Standard_Real U0 = S1->FirstUParameter();
-  Standard_Real U1 = S1->LastUParameter();
-  Standard_Real V0 = S1->FirstVParameter();
-  Standard_Real V1 = S1->LastVParameter();
-
-  Standard_Real resu0,resv0;
-  resu0=U0;resv0=V0;
-
-  Standard_Real  du1,du2,dv1,dv2;
-  du1 = (U1-U0)/(SU1-1);
-  dv1 = (V1-V0)/(SV1-1);
-  Standard_Real U,V;
-
-  Standard_Integer i,j;
-
-  Standard_Real dmaxOn1 = 0.0;
-  Standard_Real dmaxOn2 = 0.0;
-
-
-  for(U=U0,i=0; i<SU1; i++,U+=du1) { 
-    for(V=V0,j=0; j<SV1; V+=dv1,j++) { 
-      P1[i][j] = S1->Value(U,V);
-      Box1.Add(P1[i][j]);
-      if(i>0 && j>0) { 
-	Standard_Real x0,y0,z0;
-	Standard_Real x1,y1,z1;
-	P1[i][j].Coord(x0,y0,z0);
-	P1[i-1][j-1].Coord(x1,y1,z1);
-       
-	Standard_Real d =  Abs(x1-x0)+Abs(y1-y0)+Abs(z1-z0);
-	if(d>dmaxOn1) dmaxOn1 = d;
-      }
-    }
-  }
-  //-- cout<<" P(.,.)  du 1 fini "<<endl;
-  U0 = S2->FirstUParameter();
-  U1 = S2->LastUParameter();
-  V0 = S2->FirstVParameter();
-  V1 = S2->LastVParameter();
-  
-  du2 = (U1-U0)/(SU2-1);   dv2 = (V1-V0)/(SV2-1);
 
-  for(U=U0,i=0; i<SU2; i++,U+=du2) { 
-    for(V=V0,j=0; j<SV2; V+=dv2,j++) { 
-      P2[i][j] = S2->Value(U,V);
-      Box2.Add(P2[i][j]);
-      if(i>0 && j>0) { 
-	Standard_Real x0,y0,z0;
-	Standard_Real x1,y1,z1;
-	P2[i][j].Coord(x0,y0,z0);
-	P2[i-1][j-1].Coord(x1,y1,z1);
-	
-	Standard_Real d =  Abs(x1-x0)+Abs(y1-y0)+Abs(z1-z0);
-	if(d>dmaxOn2) dmaxOn2 = d;
-      }
-    }
-  }
-  //-- cout<<" P(.,.)  du 1 fini "<<endl;
-  Box1.Enlarge(1e-8);
-  Box2.Enlarge(1e-8);
 
-  if(Box1.IsOut(Box2)) { 
-    //-- cout<<" Rejection entre boites "<<endl;
+//=======================================================================
+//function : Perform
+//purpose  : 
+//=======================================================================
+void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&    Surf1,
+					   const Handle(Adaptor3d_TopolTool)& D1,
+					   const Handle(Adaptor3d_HSurface)&    Surf2,
+					   const Handle(Adaptor3d_TopolTool)& D2,
+					   const Standard_Real   TolTangency,
+					   const Standard_Real   Epsilon,
+					   const Standard_Real   Deflection,
+					   const Standard_Real   Increment,
+                                           IntSurf_ListOfPntOn2S& LOfPnts,
+                                           const Standard_Boolean RestrictLine)
+{
+  if (LOfPnts.IsEmpty()){
+    done = Standard_True;
     return;
   }
-  Standard_Real x10,y10,z10,x11,y11,z11;
-  Standard_Real x20,y20,z20,x21,y21,z21;
-  Standard_Real x0,y0,z0,x1,y1,z1;
-
-  Box1.Get(x10,y10,z10,x11,y11,z11);
-  Box2.Get(x20,y20,z20,x21,y21,z21);
-  x0 = (x10>x20)? x10 : x20;
-  y0 = (y10>y20)? y10 : y20;
-  z0 = (z10>z20)? z10 : z20;
-  
-  x1 = (x11<x21)? x11 : x21;
-  y1 = (y11<y21)? y11 : y21;
-  z1 = (z11<z21)? z11 : z21;
-  if(dmaxOn2 > dmaxOn1) dmaxOn1 = dmaxOn2;
-  dmaxOn1+=dmaxOn1;
-  x0-=dmaxOn1;
-  y0-=dmaxOn1;
-  z0-=dmaxOn1;
-  x1+=dmaxOn1;
-  y1+=dmaxOn1;
-  z1+=dmaxOn1;
-  
-
-  x10-=dmaxOn1;   y10-=dmaxOn1;   z10-=dmaxOn1; 
-  x11+=dmaxOn1;   y11+=dmaxOn1;   z11+=dmaxOn1; 
-
-  x20-=dmaxOn1;   y20-=dmaxOn1;   z20-=dmaxOn1; 
-  x21+=dmaxOn1;   y21+=dmaxOn1;   z21+=dmaxOn1; 
-
-
-  Standard_Real dx = (x1-x0)/NbPointsGrille();
-  Standard_Real dy = (y1-y0)/NbPointsGrille();
-  Standard_Real dz = (z1-z0)/NbPointsGrille();
-
-  //Standard_Integer INCRX,INCRY,INCRZ;
-  
-  Standard_Real dmax = dx;
-  if(dy>dmax) dmax = dy;
-  if(dz>dmax) dmax = dz;
+    
+  empt = Standard_True;
+  SLin.Clear();  
   
+  Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1;
+  Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2;
+  Standard_Real U1,U2,V1,V2;
   
-  if(dx<dmax*0.01) dx = dmax*0.01;
-  if(dy<dmax*0.01) dy = dmax*0.01;
-  if(dz<dmax*0.01) dz = dmax*0.01;
-  Standard_Real dx2 = dx*0.5;
-  Standard_Real dy2 = dy*0.5;
-  Standard_Real dz2 = dz*0.5 ;
+  UminLig1 = Surf1->FirstUParameter();
+  VminLig1 = Surf1->FirstVParameter();
+  UmaxLig1 = Surf1->LastUParameter();
+  VmaxLig1 = Surf1->LastVParameter();
+  UminLig2 = Surf2->FirstUParameter();
+  VminLig2 = Surf2->FirstVParameter();
+  UmaxLig2 = Surf2->LastUParameter();
+  VmaxLig2 = Surf2->LastVParameter();
   
+  IntSurf_ListIteratorOfListOfPntOn2S IterLOP1(LOfPnts);
 
-
-  IntPatch_PrmPrmIntersection_T3Bits M1(_BASE);
-  IntPatch_PrmPrmIntersection_T3Bits M2(_BASE);
-
-  for(i=0;i<SU1;i++) { 
-    for(j=0;j<SV1;j++) { 
-      IP1[i][j]=-1;
-      const gp_Pnt& P=P1[i][j];
-      P1DS2[i][j] = (char) CodeReject(x20,y20,z20,x21,y21,z21,P.X(),P.Y(),P.Z());
-      int ix = (int)((P.X()-x0  + dx2 )/dx);
-      if(DansGrille(ix)) { 
-	int iy = (int)((P.Y()-y0 + dy2)/dy);
-	if(DansGrille(iy)) {
-	  int iz = (int)((P.Z()-z0 + dz2)/dz);
-	  if(DansGrille(iz)) {
-	    IP1[i][j] = GrilleInteger(ix,iy,iz);
-	  }
-	}
-      }
-    }
-  }
-  //-- cout<<" Grille  du 1 fini "<<endl;
-  for(i=0;i<SU2;i++) { 
-    for(j=0;j<SV2;j++) { 
-      IP2[i][j]=-1;
-      const gp_Pnt& P=P2[i][j];
-      P2DS1[i][j] = (char) CodeReject(x10,y10,z10,x11,y11,z11,P.X(),P.Y(),P.Z());
-      int ix = (int)((P.X()-x0 + dx2)/dx);
-      if(DansGrille(ix)) { 
-	int iy = (int)((P.Y()-y0 + dy2)/dy);
-	if(DansGrille(iy)) {
-	  int iz = (int)((P.Z()-z0 + dz2)/dz);
-	  if(DansGrille(iz)) {
-	    IP2[i][j] =  GrilleInteger(ix,iy,iz);
-	  }
-	}
-      }
-    }
+  for(; IterLOP1.More(); IterLOP1.Next()){
+    IntSurf_PntOn2S Pnt = IterLOP1.Value();
+    Pnt.Parameters(U1, V1, U2, V2);
+    if(U1>UmaxLig1) UmaxLig1=U1;
+    if(V1>VmaxLig1) VmaxLig1=V1;
+    if(U2>UmaxLig2) UmaxLig2=U2;
+    if(V2>VmaxLig2) VmaxLig2=V2;
+    
+    if(U1<UminLig1) UminLig1=U1;
+    if(V1<VminLig1) VminLig1=V1;
+    if(U2<UminLig2) UminLig2=U2;
+    if(V2<VminLig2) VminLig2=V2; 
   }
-  //-- cout<<" Grille  du 2 fini "<<endl;
-  for(i=0;i<SU1-1;i+=1) {
-    for(j=0;j<SV1-1;j+=1) { 
-      if(!((P1DS2[i][j] & P1DS2[i+1][j]) || (P1DS2[i][j] & P1DS2[i+1][j+1])) )
-	Remplit(IP1[i][j],IP1[i+1][j],IP1[i+1][j+1],M1);
-      if(!((P1DS2[i][j] & P1DS2[i][j+1]) || (P1DS2[i][j] & P1DS2[i+1][j+1])))
-	Remplit(IP1[i][j],IP1[i][j+1],IP1[i+1][j+1],M1);	
-    }
-  }	
-  //-- cout<<" Remplissage du 1 fini "<<endl;
-  for(i=0;i<SU2-1;i+=1) {
-    for(j=0;j<SV2-1;j+=1) { 
-      if(!((P2DS1[i][j] & P2DS1[i+1][j]) || (P2DS1[i][j] & P2DS1[i+1][j+1])))
-	Remplit(IP2[i][j],IP2[i+1][j],IP2[i+1][j+1],M2);
-      if(!((P2DS1[i][j] & P2DS1[i][j+1]) || (P2DS1[i][j] & P2DS1[i+1][j+1])))
-	Remplit(IP2[i][j],IP2[i][j+1],IP2[i+1][j+1],M2);	
-    }
-  }	
-
-  //-- cout<<" Remplissage du 2 fini "<<endl;
-
-
-  M1.ResetAnd();
-  M2.ResetAnd();
-#ifdef DEB
-  long unsigned ind=0;
-#endif
-//POP
-  int newind=0;
-//  long unsigned newind=0;
-  long unsigned Compt=0;
-  //long unsigned ComptTrouve=0;
-  int ok=0;
-  int indicepointtraite = 0;
 
-  Standard_Integer k;
-  Standard_Integer nu,nv;
+  Standard_Real Deflection2 = Deflection*Deflection;
   
-  do { 
-    indicepointtraite--;
-    ok = M1.And(M2,newind);
-    if(ok) { 
-      IntegerGrille(newind,i,j,k);
-
-
-      int nb=0;
-      int LIM=3;
-      if(   DansGrille(i-1) && DansGrille(j-1) && DansGrille(k-1) 
-	 && DansGrille(i+1) && DansGrille(j+1) && DansGrille(k+1)) { 
-	int si,sj,sk;
-	for(si=-1; si<= 1 && nb<LIM; si++) { 
-	  for(sj=-1; sj<= 1 && nb<LIM; sj++) { 
-	    for(sk=-1; sk<= 1 && nb<LIM; sk++) { 
-	      long unsigned lu=GrilleInteger(i+si,j+sj,k+sk);
-	      if(M1.Val(lu) && M2.Val(lu)) { 
-		nb++;
-	      }
-	    }
-	  }
-	}
-	if(nb>=LIM) { 
-	  for(si=-1; si<= 1; si++) { 
-	    for(sj=-1; sj<= 1; sj++) { 
-	      for(sk=-1; sk<= 1; sk++) { 
-		if(si || sj || sk) { 
-		  long unsigned lu=GrilleInteger(i+si,j+sj,k+sk);
-		  M1.Raz(lu);
-		}
-	      }
-	    }
-	  }
-	}
-      }
-
+  Standard_Real SeuildPointLigne = 15.0 * Increment * Increment;
+  
+  Standard_Integer NbPntOn2SOnLine = 0, NbLigCalculee = 0, ver;
+  Standard_Real pu1,pu2,pv1,pv2, dminiPointLigne;
+  Standard_Boolean HasStartPoint,RejetLigne;
+  IntSurf_PntOn2S StartPOn2S;
+  gp_Pnt Point3dDebut,Point3dFin;
 
-      gp_Pnt P(dx*i + x0, dy*j + y0, dz*k+z0);
-      
-      //Standard_Integer ok12 = 1;
-      Standard_Integer nu1=-1,nu2=-1;
-#ifndef DEB
-      Standard_Integer nv1=0, nv2=0;
-#else
-      Standard_Integer nv1, nv2;
-#endif
-      int nbsur1 = 0;
-      for(nu=0;nu1<0 && nu<SU1;nu++) { 
-	for(nv=0;nu1<0 && nv<SV1;nv++) { 
-#ifndef DEB
-	  if( IP1[nu][nv]==(Standard_Integer) newind )  { 
-#else
-	  if( IP1[nu][nv]==newind )  { 
-#endif
-	    nbsur1++;
-	    IP1[nu][nv]=indicepointtraite;
-	    nu1=nu; nv1=nv;
-	  }
-	}
-      }
-      if(nu1>=0) { 
-	int nbsur2 = 0;
-	for(nu=0;nu2<0 && nu<SU2;nu++) { 
-	  for(nv=0;nu2<0 && nv<SV2;nv++) { 
-#ifndef DEB
-	    if( IP2[nu][nv]==(Standard_Integer) newind )  { 
-#else
-	    if( IP2[nu][nv]==newind )  {     
-#endif
-	      nbsur2++;
-	      IP2[nu][nv]=indicepointtraite;
-	      nu2=nu; nv2=nv;
-	    }
-	  }
-	}
-      }
-      if(nu1>=0 && nu2>=0) { 
-	IntSurf_PntOn2S POn2S;
-	POn2S.SetValue(P, 
-		       S1->FirstUParameter()+nu1*du1,
-		       S1->FirstVParameter()+nv1*dv1,
-		       S2->FirstUParameter()+nu2*du2,
-		       S2->FirstVParameter()+nv2*dv2);
-	LineOn2S->Add(POn2S);
-	Compt++;
-      }
-      else { 
-	//-- aucun point du triangle n a ete trouve assez proche
-	//-- on recherche les 3 points les plus proches de P 
-	//-- dans chacun des tableaux 
-	Standard_Real Dist3[3],u3[3],v3[3];
-	Dist3[0]=Dist3[1]=Dist3[2]=RealLast();
-	u3[0]=u3[1]=u3[2]=0;
-	v3[0]=v3[1]=v3[2]=0;
-	for(U=resu0,i=0; i<SU1; i++,U+=du1) { 
-	  for(V=resv0,j=0; j<SV1; V+=dv1,j++) {       
-	    //-- On place les 3 meilleures valeurs dans Dist1,Dist2,Dist3
-	    Standard_Real t = P1[i][j].SquareDistance(P);
-	    //-- On remplace la plus grande valeur ds Dist[.] par la val courante
-	    if(Dist3[0]<Dist3[1]) { 
-	      Standard_Real z;
-	      z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
-	      z=u3[0]; u3[0]=u3[1]; u3[1]=z;
-	      z=v3[0]; v3[0]=v3[1]; v3[1]=z;
-	    }
-	    if(Dist3[1]<Dist3[2]) { 
-	      Standard_Real z;
-	      z=Dist3[1]; Dist3[1]=Dist3[2]; Dist3[2]=z;
-	      z=u3[1]; u3[1]=u3[2]; u3[2]=z;
-	      z=v3[1]; v3[1]=v3[2]; v3[2]=z;
-	    }
-	    if(Dist3[0]<Dist3[1]) { 
-	      Standard_Real z;
-	      z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
-	      z=u3[0]; u3[0]=u3[1]; u3[1]=z;
-	      z=v3[0]; v3[0]=v3[1]; v3[1]=z;
-	    }
-	    //-- la plus grande valeur est dans Dist3[0]
-	    if(t<Dist3[0]) { 
-	      Dist3[0]=t; u3[0]=U; v3[0]=V;
-	    }
-	  }
-	}
-	//
-	Standard_Real U1_3 = (u3[0]+u3[1]+u3[2])/3.0;
-	Standard_Real V1_3 = (v3[0]+v3[1]+v3[2])/3.0;
-	
-	Dist3[0]=Dist3[1]=Dist3[2]=RealLast();
-	for(U=U0,i=0; i<SU2; i++,U+=du2) { 
-	  for(V=V0,j=0; j<SV2; V+=dv2,j++) {       
-	    //-- On place les 3 meilleures valeurs dans Dist1,Dist2,Dist3
-	    Standard_Real t = P2[i][j].SquareDistance(P);
-	    //-- On remplace la plus grande valeur ds Dist3[.] par la val courante
-	    if(Dist3[0]<Dist3[1]) { 
-	      Standard_Real z;
-	      z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
-	      z=u3[0]; u3[0]=u3[1]; u3[1]=z;
-	      z=v3[0]; v3[0]=v3[1]; v3[1]=z;
-	    }
-	    if(Dist3[1]<Dist3[2]) { 
-	      Standard_Real z;
-	      z=Dist3[1]; Dist3[1]=Dist3[2]; Dist3[2]=z;
-	      z=u3[1]; u3[1]=u3[2]; u3[2]=z;
-	      z=v3[1]; v3[1]=v3[2]; v3[2]=z;
-	    }
-	    if(Dist3[0]<Dist3[1]) { 
-	      Standard_Real z;
-	      z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
-	      z=u3[0]; u3[0]=u3[1]; u3[1]=z;
-	      z=v3[0]; v3[0]=v3[1]; v3[1]=z;
-	    }
-	    //-- la plus grande valeur est dans Dist3[0]
-	    if(t<Dist3[0]) { 
-	      Dist3[0]=t; u3[0]=U; v3[0]=V;
-	    }
-	  }
-	}
-	//
-	Standard_Real U2_3 = (u3[0]+u3[1]+u3[2])/3.0;
-	Standard_Real V2_3 = (v3[0]+v3[1]+v3[2])/3.0;
-	
-	IntSurf_PntOn2S POn2S;
-	POn2S.SetValue(P,U1_3,V1_3,U2_3,V2_3);
-	LineOn2S->Add(POn2S);
-	Compt++;	
-      }
-    }
-  }
-  while(ok);
-}
-
-//==================================================================================
-// function : Perform
-// purpose  : base SS Int. function
-//==================================================================================
-void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&    Surf1,
-					   const Handle(Adaptor3d_TopolTool)& D1,
-					   const Handle(Adaptor3d_HSurface)&    Surf2,
-					   const Handle(Adaptor3d_TopolTool)& D2,
-					   const Standard_Real   TolTangency,
-					   const Standard_Real   Epsilon,
-					   const Standard_Real   Deflection,
-					   const Standard_Real   Increment,
-                                           const Standard_Boolean ClearFlag) 
-{
-
-  D1->SamplePnts(Deflection, 10, 10);
-  D2->SamplePnts(Deflection, 10, 10);
-
-//=================================================================================
-  Standard_Integer NbU1 = D1->NbSamplesU();
-  Standard_Integer NbV1 = D1->NbSamplesV();
-  Standard_Integer NbU2 = D2->NbSamplesU();
-  Standard_Integer NbV2 = D2->NbSamplesV();
-  TColStd_Array1OfReal anUpars1(1, NbU1), aVpars1(1, NbV1);
-  TColStd_Array1OfReal anUpars2(1, NbU2), aVpars2(1, NbV2);
-  D1->UParameters(anUpars1); D1->VParameters(aVpars1);
-  D2->UParameters(anUpars2); D2->VParameters(aVpars2);
-//=======================================================================
-  Standard_Integer Limit = 2500;
-
-  if((NbU1*NbV1<=Limit && NbV2*NbU2<=Limit)) {  
-    empt = Standard_True;
-    // modified by NIZHNY-AMV  Tue Oct 18 12:37:02 2005.BEGIN
-    if (ClearFlag)
-      SLin.Clear();
-    // modified by NIZHNY-AMV  Tue Oct 18 12:37:02 2005.END
-    //
-    //IntPolyh_Intersection Interference(Surf1,NbU1,NbV1,Surf2,NbU2,NbV2);
-    //     IntPolyh_Intersection Interference(Surf1, anUpars1, aVpars1, 
-    // 				       Surf2, anUpars2, aVpars2);
-
-    IntPolyh_Intersection* pInterference = NULL;
-
-    if ( D1->IsUniformSampling() || D2->IsUniformSampling() ) {
-      pInterference = new IntPolyh_Intersection(Surf1,NbU1,NbV1,Surf2,NbU2,NbV2);
-    }
-    else {
-      pInterference = new IntPolyh_Intersection(Surf1, anUpars1, aVpars1, 
-						Surf2, anUpars2, aVpars2 );
-    }
-    if ( !pInterference ) {
-      done = Standard_False;
-      return;
-    }
-    //
-    IntPolyh_Intersection& Interference = *pInterference;
-    //
-    done = Interference.IsDone();
-    if( !done ) {
-      if ( pInterference ) {
-	delete pInterference;
-	pInterference = NULL;
-      }
-      return;
-    }
+  TColStd_Array1OfReal StartParams(1,4);
+  IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);  
     
-    Standard_Real Deflection2 = Deflection*Deflection;
-    Standard_Integer nbLigSec = Interference.NbSectionLines();
-    Standard_Integer nbTanZon = Interference.NbTangentZones();
-    Standard_Real SeuildPointLigne = 15.0 * Increment * Increment;
+  IntSurf_ListIteratorOfListOfPntOn2S IterLOP2(LOfPnts);
+  for(; IterLOP2.More(); IterLOP2.Next() ){
+    
+    IntSurf_PntOn2S cPnt = IterLOP2.Value();
+    cPnt.Parameters(U1, V1, U2, V2);
+    
+    StartParams(1) = U1;
+    StartParams(2) = V1;
+    StartParams(3) = U2;
+    StartParams(4) = V2;
+    
+    HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
+    dminiPointLigne = SeuildPointLigne + SeuildPointLigne;
+    if(HasStartPoint) {
+      StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
+      NbLigCalculee = SLin.Length();
+      Standard_Integer l;
+      for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { 
+        Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.ChangeValue(l));
+        if( (testwline->IsOutSurf1Box(gp_Pnt2d(pu1,pv1))==Standard_False) &&
+           (testwline->IsOutSurf2Box(gp_Pnt2d(pu2,pv2))==Standard_False) &&
+           (testwline->IsOutBox(StartPOn2S.Value())==Standard_False) )	{
+          NbPntOn2SOnLine = testwline->NbPnts();
+          Standard_Integer ll;
+          for( ll = 1; (ll < NbPntOn2SOnLine) && (dminiPointLigne >= SeuildPointLigne); ll++) { 
+            const gp_Pnt &Pa = testwline->Point(ll).Value();
+            const gp_Pnt &Pb = testwline->Point(ll+1).Value();
+            const gp_Pnt &PStart = StartPOn2S.Value();
+            gp_Vec AM(Pa,PStart);
+            gp_Vec MB(PStart,Pb);
+            Standard_Real AMMB = AM.Dot(MB);		    
+            if(AMMB > 0.0) {
+              gp_Dir ABN(Pb.X()-Pa.X(),Pb.Y()-Pa.Y(),Pb.Z()-Pa.Z());
+              Standard_Real lan =  ABN.X()*AM.X()+ABN.Y()*AM.Y()+ABN.Z()*AM.Z();
+              gp_Vec AH(lan*ABN.X(),lan*ABN.Y(),lan*ABN.Z());
+              gp_Vec HM(AM.X()-AH.X(),AM.Y()-AH.Y(),AM.Z()-AH.Z());
+              Standard_Real d = 0.0;
+              if(HM.X() < Deflection) { 
+                d+=HM.X()*HM.X();
+                if(HM.Y() < Deflection) { 
+                  d+=HM.Y()*HM.Y(); 
+                  if(HM.Z() < Deflection)
+                    d+=HM.Z()*HM.Z(); 
+                  else
+                    d=Deflection2;
+                }
+                else
+                  d=Deflection2;
+              } 
+              else
+                d=Deflection2; 
+              
+              if(d<Deflection2)
+                dminiPointLigne = 0.0;
+            }
+            else {
+              Standard_Real dab = Pa.SquareDistance(Pb);
+              Standard_Real dap = Pa.SquareDistance(PStart);
+              if(dap < dab)
+                dminiPointLigne=0;
+              else { 
+                Standard_Real dbp = Pb.SquareDistance(PStart);
+                if(dbp < dab)
+                  dminiPointLigne=0;
+              }
+            }
+          }// for( ll ...
+        }// if ...
+      }// for( l ...
+      
+      if(dminiPointLigne > SeuildPointLigne) {
+        PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
+        if(PW.IsDone())	{
+          if(PW.NbPoints()>2) {
+            RejetLigne = Standard_False;
+            Point3dDebut = PW.Value(1).Value();
+            Point3dFin   = PW.Value(PW.NbPoints()).Value();
+            for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
+              const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
+              const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
+              const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts());
+              if(Point3dDebut.Distance(verPointDebut.Value()) <= TolTangency) { 
+                if(Point3dFin.Distance(verPointFin.Value()) <= TolTangency)
+                  RejetLigne = Standard_True; 
+              }
+            }
+            
+            if(!RejetLigne) {
+              IntSurf_TypeTrans trans1,trans2;
+              Standard_Real locu,locv;
+              gp_Vec norm1,norm2,d1u,d1v;
+              gp_Pnt ptbid;
+              Standard_Integer indextg;
+              gp_Vec tgline(PW.TangentAtLine(indextg));
+              PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
+              Surf1->D1(locu,locv,ptbid,d1u,d1v);
+              norm1 = d1u.Crossed(d1v);
+              PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
+              Surf2->D1(locu,locv,ptbid,d1u,d1v);
+              norm2 = d1u.Crossed(d1v);
+              if( tgline.DotCross(norm2,norm1) >= 0. ) {
+                trans1 = IntSurf_Out;
+                trans2 = IntSurf_In;
+              }
+              else {
+                trans1 = IntSurf_In;
+                trans2 = IntSurf_Out;
+              }
+              
+              Standard_Real TolTang = TolTangency;
+              Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+              if (RestrictLine){
+                IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+                IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+              }
+              
+              if(wline->NbVertex() == 0) {
+                IntPatch_Point vtx;
+                IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
+                POn2S.Parameters(pu1,pv1,pu2,pv2);
+                vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+                vtx.SetParameters(pu1,pv1,pu2,pv2);
+                vtx.SetParameter(1);
+                wline->AddVertex(vtx);
+                
+                POn2S = PW.Line()->Value(wline->NbPnts());
+                POn2S.Parameters(pu1,pv1,pu2,pv2);
+                vtx.SetValue(Point3dFin,TolTang,Standard_False);
+                vtx.SetParameters(pu1,pv1,pu2,pv2);
+                vtx.SetParameter(wline->NbPnts());
+                wline->AddVertex(vtx);
+              }              
 
-    Standard_Integer NbPntOn2SOnLine = 0, NbLigCalculee = 0, ver;
-    Standard_Real U1,U2,V1,V2, pu1,pu2,pv1,pv2, incidence, dminiPointLigne;
-    Standard_Boolean HasStartPoint,RejetLigne;
-    IntSurf_PntOn2S StartPOn2S;
-    gp_Pnt Point3dDebut,Point3dFin;
+              Standard_Integer slinlen = SLin.Length();
+              if( slinlen > 0 ) {
+                Standard_Integer cnbV = wline->NbVertex();
+                Standard_Integer ciV;
+                for( ciV = 1; ciV <= cnbV; ciV++ ) {
+                  Standard_Real pntDMin = 1.e+100;
+                  Standard_Integer VDMin = 0;
+                  Standard_Integer WLDMin = 0;
+                  gp_Pnt cPV = wline->Vertex(ciV).Value();
+                  Standard_Integer iL;
+                  for( iL = 1; iL <= slinlen; iL++) {
+                    const Handle(IntPatch_Line)& aSLine = SLin.Value(iL);
+                    IntPatch_IType aType = aSLine->ArcType();
+                    if( aType != IntPatch_Walking)
+                      continue;
+                    const Handle(IntPatch_WLine)&  aWLine = (*((Handle(IntPatch_WLine)*)&aSLine));
+                    Standard_Integer tnbV = aWLine->NbVertex();
+                    Standard_Integer tiV;
+                    for( tiV = 1; tiV <= tnbV; tiV++ ) {
+                      gp_Pnt tPV = aWLine->Vertex(tiV).Value();
+                      Standard_Real tDistance = cPV.Distance(tPV);
+                      Standard_Real uRs1 = Surf1->Surface().UResolution(tDistance);
+                      Standard_Real vRs1 = Surf1->Surface().VResolution(tDistance);
+                      Standard_Real uRs2 = Surf2->Surface().UResolution(tDistance);
+                      Standard_Real vRs2 = Surf2->Surface().VResolution(tDistance);
+                      Standard_Real RmaxS1 = Max(uRs1,vRs1);
+                      Standard_Real RmaxS2 = Max(uRs2,vRs2);
+                      if(RmaxS1 < 1.e-4 && RmaxS2 < 1.e-4) {
+                        if( pntDMin > tDistance && tDistance > 1.e-9) {
+                          pntDMin = tDistance;
+                          VDMin = tiV;
+                          WLDMin = iL;
+                        }
+                      }
+                    }
+                  }
+                  
+                  if( VDMin != 0 ) {
+                    const Handle(IntPatch_Line)& aSLine = SLin.Value(WLDMin);
+                    const Handle(IntPatch_WLine)&  aWLine = (*((Handle(IntPatch_WLine)*)&aSLine));
+                    Standard_Integer tiVpar = (Standard_Integer)aWLine->Vertex(VDMin).ParameterOnLine();
+                    Standard_Integer ciVpar = (Standard_Integer)wline->Vertex(ciV).ParameterOnLine();
+                    Standard_Real u11 = 0., u12 = 0., v11 = 0., v12 = 0.;
+                    Standard_Real u21 = 0., u22 = 0., v21 = 0., v22 = 0.;
+                    wline->Point(ciVpar).Parameters(u11,v11,u12,v12);
+                    aWLine->Point(tiVpar).Parameters(u21,v21,u22,v22);
+                    
+                    Handle(IntSurf_LineOn2S) newL2s = new IntSurf_LineOn2S();
+                    IntSurf_PntOn2S replacePnt = aWLine->Point(tiVpar);
+                    Standard_Integer cNbP = wline->NbPnts();
+                    
+                    TColStd_SequenceOfInteger VPold;
+                    Standard_Integer iPo;
+                    for( iPo = 1; iPo <= cnbV; iPo++ ) {
+                      Standard_Real Po = wline->Vertex(iPo).ParameterOnLine();
+                      Standard_Integer IPo = (Standard_Integer) Po;
+                      VPold.Append(IPo);
+                    }
+                    
+                    Standard_Boolean removeNext = Standard_False;
+                    Standard_Boolean removePrev = Standard_False;
+                    if( ciV == 1) {
+                      Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV+1));
+                      if(dPar > 10) {
+				removeNext = Standard_True;
+				for( iPo = (ciV+1); iPo <= cnbV; iPo++ )
+				  VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
+			      }
+                    }
+                    else if( ciV == cnbV) {
+                      Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV-1));
+                      if(dPar > 10) {
+                        removePrev = Standard_True;
+                        VPold.SetValue(ciV, VPold.Value(ciV) - 1 );
+                      }
+                    }
+                    else {
+                      Standard_Integer dParMi = Abs( VPold.Value(ciV) - VPold.Value(ciV-1));
+                      Standard_Integer dParMa = Abs( VPold.Value(ciV) - VPold.Value(ciV+1));
+                      if(dParMi > 10) {
+                        removePrev = Standard_True;
+                        VPold.SetValue(ciV, VPold.Value(ciV) - 1 );
+                      }
+                      if(dParMa > 10) {
+                        removeNext = Standard_True;
+                        for( iPo = (ciV+1); iPo <= cnbV; iPo++ ) {
+                          if(dParMi > 10)
+                            VPold.SetValue(iPo, VPold.Value(iPo) - 2 );
+                          else
+                            VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
+                        }
+                      }
+                      else {
+                        if(dParMi > 10)
+                          for( iPo = (ciV+1); iPo <= cnbV; iPo++ )
+                            VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
+                      } 
+                    }
+                    Standard_Integer pI = (Standard_Integer) ciVpar;
+                    
+                    Standard_Integer iP;
+                    for( iP = 1; iP <= cNbP; iP++) {
+                      if( pI == iP )
+                        newL2s->Add(replacePnt);
+                      else if(removeNext && iP == (pI + 1))
+                        continue;
+                      else if(removePrev && iP == (pI - 1))
+                        continue;
+                      else
+                        newL2s->Add(wline->Point(iP));
+                    }
+                    
+                    IntPatch_Point newVtx;
+                    gp_Pnt Pnt3dV = aWLine->Vertex(VDMin).Value();
+                    newVtx.SetValue(Pnt3dV,TolTang,Standard_False);
+                    newVtx.SetParameters(u21,v21,u22,v22);
+                    newVtx.SetParameter(VPold.Value(ciV));
+                    
+                    Handle(IntPatch_WLine) NWLine = new IntPatch_WLine(newL2s,Standard_False,trans1,trans2);
+                    
+                    Standard_Integer iV;
+                    for( iV = 1; iV <= cnbV; iV++ ) {
+                      if( iV == ciV )
+                        NWLine->AddVertex(newVtx);
+                      else {
+                        IntPatch_Point theVtx = wline->Vertex(iV);
+                        theVtx.SetParameter(VPold.Value(iV));
+                        NWLine->AddVertex(theVtx);
+                      }
+                    }
+                    
+                    wline = NWLine;
+                  }
+                }
+              }// SLin.Length > 0
+              
+              SLin.Append(wline);
+              empt = Standard_False;
+            }// !RejetLigne
+          }// PW points > 2
+        }// done is True
+      }// dminiPointLigne > SeuildPointLigne
+    }// HasStartPoint  
+  }// for( IterLOP ...
+  done = Standard_True;
+  return;      
+}
+//=======================================================================
+//function : Perform
+//purpose  : 
+//=======================================================================
+void IntPatch_PrmPrmIntersection::Perform(const Handle(Adaptor3d_HSurface)&    Surf1,
+					  const Handle(Adaptor3d_TopolTool)& D1,
+					  const Handle(Adaptor3d_HSurface)&    Surf2,
+					  const Handle(Adaptor3d_TopolTool)& D2,
+					  const Standard_Real   U1Depart,
+					  const Standard_Real   V1Depart,
+					  const Standard_Real   U2Depart,
+					  const Standard_Real   V2Depart,
+					  const Standard_Real   TolTangency,
+					  const Standard_Real   Epsilon,
+					  const Standard_Real   Deflection,
+					  const Standard_Real   Increment) { 
+  
+  
+  
+//    Standard_Integer NbU1 = D1->NbSamplesU();
+//    Standard_Integer NbV1 = D1->NbSamplesV();
+//    Standard_Integer NbU2 = D2->NbSamplesU();
+//    Standard_Integer NbV2 = D2->NbSamplesV();
 
-    TColStd_Array1OfReal StartParams(1,4);
-    IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);
+  //-- Traitement des Lignes de sections
+  empt = Standard_True;
+  done = Standard_True;
+  SLin.Clear();  
+  
+  //------------------------------------------------------------
 
-    if(nbLigSec>=1) {  
-      Standard_Integer *TabL = new Standard_Integer [nbLigSec+1];
-      Standard_Integer ls;
-      for(ls=1;ls<=nbLigSec;ls++)
-	TabL[ls]=ls;
+  Standard_Real pu1,pu2,pv1,pv2;
+  
+  TColStd_Array1OfReal StartParams(1,4);
+  
+//    Standard_Integer MaxOscill = NbU1;
+//    if(MaxOscill < NbU2) MaxOscill=NbU2;
+//    if(MaxOscill < NbV1) MaxOscill=NbV1;
+//    if(MaxOscill < NbV2) MaxOscill=NbV2;
+  
+//    Standard_Real nIncrement=Increment;
+//    if(MaxOscill>10) { 
+//  #ifdef DEB 
+//      cout<<"\n IntPatch_PrmPrmIntersection.gxx : Increment:"<<Increment<<" -> "<<Increment/(0.5*MaxOscill)<<endl;
+//  #endif
+//      nIncrement/=0.5*MaxOscill;
+//    }
+  
+  IntPatch_ThePWalkingInter PW(Surf1,Surf2,
+			       TolTangency,
+			       Epsilon,
+			       Deflection,
+			       Increment); //nIncrement);
+  
+  
+  //Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
+  //Standard_Real    incidence;
+  //Standard_Real    dminiPointLigne;
+  
+  Standard_Boolean HasStartPoint;//,RejetLigne;
+  
+  IntSurf_PntOn2S StartPOn2S;
+  
+  //Standard_Integer ver;
+  
+  gp_Pnt Point3dDebut,Point3dFin;
+  
+  //------------------------------------------------------------
+  
+  StartParams(1) = U1Depart;
+  StartParams(2) = V1Depart;
+  StartParams(3) = U2Depart;
+  StartParams(4) = V2Depart;
+  
+  //-----------------------------------------------------------------------
+  //-- Calcul du premier point de cheminement a partir du point approche --
+  //-----------------------------------------------------------------------
+  HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);	
+  if(HasStartPoint) { 
+    //-------------------------------------------------
+    //-- Un point a ete trouve                       --
+    //-- On verifie qu il n appartient pas           --
+    //--  a une ligne de cheminement deja calculee.  --
+    //-------------------------------------------------
+    
+    PW.Perform(StartParams);
+    if(PW.IsDone()) {
+      
+      Point3dDebut = PW.Value(1).Value();
+      Point3dFin   = PW.Value(PW.NbPoints()).Value();
 
-      Standard_Boolean triok;
-      do { 
-	triok=Standard_True;
-	Standard_Integer b;
-	for( b = 2; b <= nbLigSec; b++ ) { 
-	  Standard_Integer nb_B = Interference.NbPointsInLine(TabL[b]);
-	  Standard_Integer nb_A = Interference.NbPointsInLine(TabL[b-1]);
-	  if( nb_B > nb_A ) { 
-	    Standard_Integer tyu=TabL[b]; 
-	    TabL[b]=TabL[b-1];
-	    TabL[b-1]=tyu;
-	    triok=Standard_False;
-	  }
-	}
-      } while(triok==Standard_False);
-      //
-      for( ls = 1; ls <= nbLigSec; ls++) {
-	Standard_Integer nbp, ilig, *TabPtDep;
+      IntSurf_TypeTrans trans1,trans2;
+      Standard_Real locu,locv;
+      gp_Vec norm1,norm2,d1u,d1v;
+      gp_Pnt ptbid;
+      Standard_Integer indextg;
+      gp_Vec tgline(PW.TangentAtLine(indextg));
+      PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
+      Surf1->D1(locu,locv,ptbid,d1u,d1v);
+      norm1 = d1u.Crossed(d1v);
+      PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
+      Surf2->D1(locu,locv,ptbid,d1u,d1v);
+      norm2 = d1u.Crossed(d1v);
+      if (tgline.DotCross(norm2,norm1)>0.) {
+	trans1 = IntSurf_Out;
+	trans2 = IntSurf_In;
+      }
+      else {
+	trans1 = IntSurf_In;
+	trans2 = IntSurf_Out;
+      }
+      
+      
+      
+      Standard_Real TolTang = TolTangency;
+      Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+      IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+      IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+      
+      //---------------
+      if(wline->NbVertex() == 0) {
+	IntPatch_Point vtx;
+	IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
+	POn2S.Parameters(pu1,pv1,pu2,pv2);
+	vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+	vtx.SetParameters(pu1,pv1,pu2,pv2);
+	vtx.SetParameter(1);
+	wline->AddVertex(vtx);
+	
+	POn2S = PW.Line()->Value(wline->NbPnts());
+	POn2S.Parameters(pu1,pv1,pu2,pv2);
+	vtx.SetValue(Point3dFin,TolTang,Standard_False);
+	vtx.SetParameters(pu1,pv1,pu2,pv2);
+	vtx.SetParameter(wline->NbPnts());
+	wline->AddVertex(vtx);
+      }
+      
+      //---------------
+      SLin.Append(wline);
+      empt = Standard_False;
+      
+    }
+  }
+}
+//==================================================================================
+// function : AdjustOnPeriodic
+// purpose  : 
+//==================================================================================
+void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1,
+		      const Handle(Adaptor3d_HSurface)& Surf2,
+		      IntPatch_SequenceOfLine& aSLin)
+{
+  Standard_Boolean bIsPeriodic[4], bModified, bIsNull, bIsPeriod;
+  Standard_Integer i, j, k, aNbLines, aNbPx, aIndx, aIndq;
+  Standard_Real aPeriod[4], dPeriod[4], ux[4], uq[4], aEps, du;
+  //
+  aEps=Precision::Confusion();
+  //
+  for (k=0; k<4; ++k) {
+    aPeriod[k]=0.;
+  }
+  //
+  bIsPeriodic[0]=Surf1->IsUPeriodic();
+  bIsPeriodic[1]=Surf1->IsVPeriodic();
+  bIsPeriodic[2]=Surf2->IsUPeriodic();
+  bIsPeriodic[3]=Surf2->IsVPeriodic();
+  //
+  if (bIsPeriodic[0]){
+    aPeriod[0]=Surf1->UPeriod();
+  }
+  if (bIsPeriodic[1]){
+    aPeriod[1]=Surf1->VPeriod();
+  }
+  if (bIsPeriodic[2]){
+    aPeriod[2]=Surf2->UPeriod();
+  }
+  if (bIsPeriodic[3]){
+    aPeriod[3]=Surf2->VPeriod();
+  }
+  //
+  for (k=0; k<4; ++k) {
+    dPeriod[k]=0.25*aPeriod[k];
+  }
+  //
+  aNbLines=aSLin.Length();
+  for (i=1; i<=aNbLines; ++i) {
+    Handle(IntPatch_WLine) aIL=Handle(IntPatch_WLine)::DownCast(aSLin.Value(i));
+    Handle(IntSurf_LineOn2S) aL=aIL->Curve();
+
+    aNbPx=aL->NbPoints();
+    if (aNbPx<10) {
+      continue;
+    }
+    //
+    for (j=0; j<2; ++j) {
+      bModified=Standard_False;
+      aIndx=1;
+      aIndq=2;
+      if (j) {
+	aIndx=aNbPx;
+	aIndq=aNbPx-1;
+      }
+      //
+      const IntSurf_PntOn2S& aPSx=aL->Value(aIndx);
+      const IntSurf_PntOn2S& aPSq=aL->Value(aIndq);
+      //
+      aPSx.Parameters(ux[0], ux[1], ux[2], ux[3]);
+      aPSq.Parameters(uq[0], uq[1], uq[2], uq[3]);
+      //
+      for (k=0; k<4; ++k) {
+	bIsNull=Standard_False;
+	bIsPeriod=Standard_False;
+	//
+	if (!bIsPeriodic[k]) {
+	  continue;
+	}
+	//
+	if (fabs(ux[k])<aEps) {
+	  bModified=Standard_True;
+	  bIsNull=Standard_True;
+	}
+	//
+	else if (fabs(ux[k]-aPeriod[k])<aEps) {
+	  bModified=Standard_True;
+	  bIsPeriod=Standard_True;
+	}
+	//
+	if (bModified) {
+	  du=fabs(ux[k]-uq[k]);
+	  if (du > dPeriod[k]) {
+	    if(bIsNull){
+	      ux[k]=aPeriod[k];
+	    }
+	    if(bIsPeriod) {
+	      ux[k]=0.;
+	    }
+	  }
+	}
+      }//for (k=0; k<4; ++k) 
+      if (bModified) {
+	IntSurf_PntOn2S aPntOn2S;
+	//
+	aPntOn2S=aPSx;  
+	aPntOn2S.SetValue(ux[0], ux[1], ux[2], ux[3]);
+	aL->Value(aIndx, aPntOn2S);
+      }
+    }//for (j=0; j<1; ++j) {
+  }//for (i=1; i<=aNbLines; ++i)
+}
+//==================================================================================
+// function : Perform
+// purpose  : base SS Int. function
+//==================================================================================
+void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Surf1,
+					   const Handle(Adaptor3d_TopolTool)& D1,
+					   const Handle(Adaptor3d_HSurface)& Surf2,
+					   const Handle(Adaptor3d_TopolTool)& D2,
+					   const Standard_Real   TolTangency,
+					   const Standard_Real   Epsilon,
+					   const Standard_Real   Deflection,
+					   const Standard_Real   Increment,
+                                           const Standard_Boolean ClearFlag) 
+{
+  Standard_Integer NbU1, NbV1, NbU2, NbV2, Limit; 
+  //
+  D1->SamplePnts(Deflection, 10, 10);
+  D2->SamplePnts(Deflection, 10, 10);
+  //
+  NbU1 = D1->NbSamplesU();
+  NbV1 = D1->NbSamplesV();
+  NbU2 = D2->NbSamplesU();
+  NbV2 = D2->NbSamplesV();
+  TColStd_Array1OfReal anUpars1(1, NbU1), aVpars1(1, NbV1);
+  TColStd_Array1OfReal anUpars2(1, NbU2), aVpars2(1, NbV2);
+  //
+  D1->UParameters(anUpars1); 
+  D1->VParameters(aVpars1);
+  D2->UParameters(anUpars2); 
+  D2->VParameters(aVpars2);
+  //---------------------------------------------
+  Limit = 2500;
+  if((NbU1*NbV1<=Limit && NbV2*NbU2<=Limit)) {  
+    empt = Standard_True;
+    if (ClearFlag){
+      SLin.Clear();
+    }
+    //
+    IntPolyh_Intersection* pInterference = NULL;
+
+    if ( D1->IsUniformSampling() || D2->IsUniformSampling() ) {
+      pInterference = new IntPolyh_Intersection(Surf1,NbU1,NbV1,Surf2,NbU2,NbV2);
+    }
+    else {
+      pInterference = new IntPolyh_Intersection(Surf1, anUpars1, aVpars1, 
+						Surf2, anUpars2, aVpars2 );
+    }
+    if ( !pInterference ) {
+      done = Standard_False;
+      return;
+    }
+    //
+    IntPolyh_Intersection& Interference = *pInterference;
+    //
+    done = Interference.IsDone();
+    if( !done ) {
+      if (pInterference) {
+	delete pInterference;
+	pInterference = NULL;
+      }
+      return;
+    }
+    
+    Standard_Real Deflection2 = Deflection*Deflection;
+    Standard_Integer nbLigSec = Interference.NbSectionLines();
+    Standard_Integer nbTanZon = Interference.NbTangentZones();
+    Standard_Real SeuildPointLigne = 15.0 * Increment * Increment;
+
+    Standard_Integer NbPntOn2SOnLine = 0, NbLigCalculee = 0, ver;
+    Standard_Real U1,U2,V1,V2, pu1,pu2,pv1,pv2, incidence, dminiPointLigne;
+    Standard_Boolean HasStartPoint,RejetLigne;
+    IntSurf_PntOn2S StartPOn2S;
+    gp_Pnt Point3dDebut,Point3dFin;
+
+    TColStd_Array1OfReal StartParams(1,4);
+    IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);
+
+    if(nbLigSec>=1) {  
+      Standard_Integer *TabL = new Standard_Integer [nbLigSec+1];
+      Standard_Integer ls;
+      for(ls=1; ls<=nbLigSec; ++ls){
+	TabL[ls]=ls;
+      }
+      //----------------------------------------1.1
+      Standard_Boolean triok;
+      do { 
+	Standard_Integer b, nb_B, nb_A, tyu;
+	//
+	triok=Standard_True;
+	for( b = 2; b <= nbLigSec; ++b ) { 
+	  nb_B = Interference.NbPointsInLine(TabL[b]);
+	  nb_A = Interference.NbPointsInLine(TabL[b-1]);
+	  if( nb_B > nb_A ) { 
+	    tyu=TabL[b]; 
+	    TabL[b]=TabL[b-1];
+	    TabL[b-1]=tyu;
+	    triok=Standard_False;
+	  }
+	}
+      } while(triok==Standard_False);
+      //----------------------------------------
+      // 1.2 For the line "ls" get 2D-bounds U,V for surfaces 1,2
+      //
+      for( ls = 1; ls <= nbLigSec; ++ls) {
+	Standard_Integer nbp, ilig, *TabPtDep;
 	//
 	nbp = Interference.NbPointsInLine(TabL[ls]);
-	//modified by NIZNHY-PKV Fri Sep  5 15:19:28 2008f
 	if (!nbp) {
 	  continue;
 	}
-	//modified by NIZNHY-PKV Fri Sep  5 15:19:31 2008t
-	TabPtDep = new Standard_Integer [nbp+1];
 	//
-	for( ilig = 1; ilig <= nbp; ilig++ )
+	TabPtDep = new Standard_Integer [nbp+1];
+	for( ilig = 1; ilig <= nbp; ++ilig ) {
 	  TabPtDep[ilig]=0;
-
+	}
+	//
 	Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1;
 	Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2;
 	Standard_Real _x,_y,_z;
-
-	Interference.GetLinePoint(TabL[ls],1,_x,_y,_z,UminLig1,VminLig1,UminLig2,VminLig2,incidence);
+	//
+	Interference.GetLinePoint(TabL[ls], 1, 
+				  _x,_y,_z, 
+				  UminLig1, VminLig1, UminLig2, VminLig2, 
+				  incidence);
 	
 	UmaxLig1=UminLig1;
 	VmaxLig1=VminLig1;
 	UmaxLig2=UminLig2;
 	VmaxLig2=VminLig2;
-
+	//
 	for( ilig = 2; ilig <= nbp; ilig++ ) { 
 	  Interference.GetLinePoint(TabL[ls],ilig,_x,_y,_z,U1,V1,U2,V2,incidence);
-	  
+	  //
 	  if(U1>UmaxLig1) UmaxLig1=U1;
 	  if(V1>VmaxLig1) VmaxLig1=V1;
 	  if(U2>UmaxLig2) UmaxLig2=U2;
 	  if(V2>VmaxLig2) VmaxLig2=V2;
-	  
+	  //
 	  if(U1<UminLig1) UminLig1=U1;
 	  if(V1<VminLig1) VminLig1=V1;
 	  if(U2<UminLig2) UminLig2=U2;
 	  if(V2<VminLig2) VminLig2=V2;
-	}
-	
+	}//for( ilig = 2; ilig <= nbp; ilig++ ) { 
+	//
+	//----------------------------------------
+	// 1.3
 	Standard_Integer nbps2 = (nbp>3)? (nbp/2) :  1;
 	Standard_Integer NombreDePointsDeDepartDuCheminement = 0;
 	Standard_Boolean lignetrouvee=Standard_False;
@@ -1975,21 +2163,20 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 
 	      if(dminiPointLigne > SeuildPointLigne) {
 		PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
-		//xf
+		//
 		Standard_Boolean bPWIsDone;
 		Standard_Integer iPWNbPoints, aNbPointsVer;
 		Standard_Real aD11, aD12, aD21, aD22, aDx;
 		//
 		bPWIsDone=PW.IsDone();
-		//xt
 		if(bPWIsDone) {
 		  iPWNbPoints=PW.NbPoints();
 		  //
 		  if( iPWNbPoints > 2 ) {
 		    RejetLigne = Standard_False;
 		    Point3dDebut = PW.Value(1).Value();
-		    Point3dFin   = PW.Value(PW.NbPoints()).Value();
-		    for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
+		    Point3dFin   = PW.Value(iPWNbPoints).Value();
+		    for( ver = 1; (!RejetLigne) && (ver<= NbLigCalculee); ++ver) { 
 		      const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
 		      //
 		      aNbPointsVer=verwline->NbPnts();
@@ -2029,13 +2216,16 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 			  gp_Dir aDir12(aVec12);
 			  gp_Lin aLin12(aP1, aDir12);
 			  aDx=aLin12.Distance(aPx);
-			  if (aDx<=TolTangency) {
+			  //modified by NIZNHY-PKV Tue May 10 11:08:07 2011f
+			  if (aDx<=2.*Epsilon) {
+			  //if (aDx<=TolTangency) {
+			  //modified by NIZNHY-PKV Tue May 10 11:08:13 2011t  
 			    RejetLigne = Standard_True;
 			    break;
 			  }
-			}
-		      }
-		    }
+			}//for(m=1; m<iPWNbPoints; ++m){
+		      }//if((aD11<=TolTangency && aD22<=TolTangency) ||...
+		    }// for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
 		    //
 		    if(!RejetLigne) {
 		      IntSurf_TypeTrans trans1,trans2;
@@ -2374,919 +2564,819 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 	    PW.Perform(StartParams,
 			 UminLig1,VminLig1,UminLig2,VminLig2,
 			 UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
-	    if(PW.IsDone()) {
-	      if(PW.NbPoints()>2) { 
-		//-----------------------------------------------
-		//-- Verification a posteriori : 
-		//-- On teste si le point de depart et de fin de 
-		//-- la ligne de cheminement est present dans une 
-		//-- autre ligne . 
-		//-----------------------------------------------
-		RejetLigne = Standard_False;
-		Point3dDebut = PW.Value(1).Value();
-		Point3dFin   = PW.Value(PW.NbPoints()).Value();
-		
-		for(ver=1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
-		  const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
-		  //-- Handle(IntPatch_WLine) verwline=Handle(IntPatch_WLine)::DownCast(SLin.Value(ver));
-		  const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
-		  const IntSurf_PntOn2S& verPointFin   = verwline->Point(verwline->NbPnts());
-		  if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency) { 
-		    RejetLigne = Standard_True; 
-		  }
-		  else { 
-		    if(Point3dFin.Distance(verPointFin.Value()) < TolTangency) { 
-		      RejetLigne = Standard_True; 
-		    }
-		  }
-		}
-		
-		if(!RejetLigne) { 
-
-		  IntSurf_TypeTrans trans1,trans2;
-		  Standard_Real locu,locv;
-		  gp_Vec norm1,norm2,d1u,d1v;
-		  gp_Pnt ptbid;
-		  Standard_Integer indextg;
-		  gp_Vec tgline(PW.TangentAtLine(indextg));
-		  PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
-		  Surf1->D1(locu,locv,ptbid,d1u,d1v);
-		  norm1 = d1u.Crossed(d1v);
-		  PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
-		  Surf2->D1(locu,locv,ptbid,d1u,d1v);
-		  norm2 = d1u.Crossed(d1v);
-		  if (tgline.DotCross(norm2,norm1)>0.) {
-		    trans1 = IntSurf_Out;
-		    trans2 = IntSurf_In;
-		  }
-		  else {
-		    trans1 = IntSurf_In;
-		    trans2 = IntSurf_Out;
-		  }
-		  
-		  
-		  
-		  Standard_Real TolTang = TolTangency;
-		  Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
-		  IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
-		  IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
-		  
-//---------------
-                    if(wline->NbVertex() == 0) {
-		      IntPatch_Point vtx;
-		      IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
-		      POn2S.Parameters(pu1,pv1,pu2,pv2);
-		      vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-		      vtx.SetParameters(pu1,pv1,pu2,pv2);
-		      vtx.SetParameter(1);
-		      wline->AddVertex(vtx);
-		      
-		      POn2S = PW.Line()->Value(wline->NbPnts());
-		      POn2S.Parameters(pu1,pv1,pu2,pv2);
-		      vtx.SetValue(Point3dFin,TolTang,Standard_False);
-		      vtx.SetParameters(pu1,pv1,pu2,pv2);
-		      vtx.SetParameter(wline->NbPnts());
-		      wline->AddVertex(vtx);
-		    }
-		    
-//---------------
-		  SLin.Append(wline);
-		  empt = Standard_False;
-		  
-		}
-		else { 
-		  //-- cout<<" ----- REJET DE LIGNE (POINT DE DEPART) ----- "<<endl;
-		}
-		//------------------------------------------------------------		
-	      }
-	    }  //--  le cheminement a reussi (done a True)
-	  }  //--  le point approche ne renvoie pas sur une ligne existante
-	} //-- Si HasStartPoint
-      //} //-- Boucle Sur les Points de la Tangent Zone
-    } //-- Boucle sur Les Tangent Zones
-
-    if ( pInterference ) {
-      delete pInterference;
-      pInterference = NULL;
-    }
-    return;
-  }
-
-  Handle(IntSurf_LineOn2S) LOn2S = new IntSurf_LineOn2S();
-  PointDepart( LOn2S, Surf1, NbU1, NbV1, Surf2, NbU2, NbV2 );
-  empt = Standard_True;
-  done = Standard_True;
-  SLin.Clear();  
-  Standard_Real Deflection2 = Deflection*Deflection;
-  
-  Standard_Integer NbPntOn2SOnLine;
-  Standard_Integer NbLigCalculee = 0;
-  Standard_Real U1,U2,V1,V2;
-  Standard_Real pu1,pu2,pv1,pv2;
-  
-  TColStd_Array1OfReal StartParams(1,4);
-  Standard_Integer MaxOscill = NbU1;
-  if(MaxOscill < NbU2) MaxOscill=NbU2;
-  if(MaxOscill < NbV1) MaxOscill=NbV1;
-  if(MaxOscill < NbV2) MaxOscill=NbV2;
-  
-  Standard_Real nIncrement=Increment;
-  //if(MaxOscill>10)
-    //nIncrement/=0.5*MaxOscill;
-
-  IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,nIncrement);
-  Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
-  Standard_Real    dminiPointLigne;
-  Standard_Boolean HasStartPoint,RejetLigne;
-  IntSurf_PntOn2S StartPOn2S;
-  Standard_Integer ver;
-  gp_Pnt Point3dDebut,Point3dFin;
-
-  //------------------------------------------------------------
-  //-- Calcul des parametres approches a partir des Zones De Tangence --
-  //--------------------------------------------------------------------
-  Standard_Integer nbTanZon = LOn2S->NbPoints();
-  for(Standard_Integer z=1; z <= nbTanZon; z++) { 
-    const IntSurf_PntOn2S& POn2S = LOn2S->Value(z);
-    POn2S.Parameters(U1,V1,U2,V2);
-    StartParams(1) = U1;
-    StartParams(2) = V1;
-    StartParams(3) = U2;
-    StartParams(4) = V2;
-    
-    //-----------------------------------------------------------------------
-    //-- Calcul du premier point de cheminement a partir du point approche --
-    //-----------------------------------------------------------------------
-    HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);	
-    if(HasStartPoint) { 
-      //-------------------------------------------------
-      //-- Un point a ete trouve                       --
-      //-- On verifie qu il n appartient pas           --
-      //--  a une ligne de cheminement deja calculee.  --
-      //-------------------------------------------------
-      StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
-      
-      NbLigCalculee = SLin.Length();
-      dminiPointLigne = SeuildPointLigne + SeuildPointLigne; 
-      
-      for(Standard_Integer l=1; 
-	  (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); 
-	  l++) { 
-	const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
-	
-	if(  (testwline->IsOutSurf1Box(gp_Pnt2d(pu1,pv1))==Standard_False)
-	   &&(testwline->IsOutSurf2Box(gp_Pnt2d(pu2,pv2))==Standard_False)
-	   &&(testwline->IsOutBox(StartPOn2S.Value())==Standard_False)) { 
-	  
-	  NbPntOn2SOnLine = testwline->NbPnts();
-	  for(Standard_Integer ll=1; 
-	      (ll < NbPntOn2SOnLine) && (dminiPointLigne >= SeuildPointLigne); 
-	      ll++) { 
-	    
-	    const gp_Pnt& Pa = testwline->Point(ll).Value();
-	    const gp_Pnt& Pb = testwline->Point(ll+1).Value();
-	    const gp_Pnt& PStart=StartPOn2S.Value();
-	    gp_Vec AM(Pa,PStart);
-	    gp_Vec MB(PStart,Pb);
-	    Standard_Real AMMB = AM.Dot(MB);
-	    if(AMMB > 0.0) {
-	      gp_Dir ABN(Pb.X()-Pa.X(),Pb.Y()-Pa.Y(),Pb.Z()-Pa.Z());
-	      Standard_Real lan =  ABN.X()*AM.X()+ABN.Y()*AM.Y()+ABN.Z()*AM.Z();
-	      gp_Vec AH(lan*ABN.X(),lan*ABN.Y(),lan*ABN.Z());
-	      gp_Vec HM(AM.X()-AH.X(),AM.Y()-AH.Y(),AM.Z()-AH.Z()); 
-	      
-	      Standard_Real d = 0.0;
-	      if(HM.X() < Deflection) { 
-		d+=HM.X()*HM.X();
-		if(HM.Y() < Deflection) { 
-		  d+=HM.Y()*HM.Y(); 
-		  if(HM.Z() < Deflection) { 
-		    d+=HM.Z()*HM.Z(); 
-		  }
-		  else { 
-		    d=Deflection2;
-		  }
-		}
-		else { 
-		  d=Deflection2;
-		}
-	      } 
-	      else { 
-		d=Deflection2; 
-	      }
-	      if(d<Deflection2) { 
-		dminiPointLigne = 0.0;
-	      }
-	    }
-	    else { 
-	      Standard_Real dab = Pa.Distance(Pb);
-	      Standard_Real dap = Pa.Distance(PStart);
-	      if(dap < dab) { 
-		dminiPointLigne=0;
-	      }
-	      else { 
-		Standard_Real dbp = Pb.Distance(PStart);
-		if(dbp < dab) { 
-		  dminiPointLigne=0;
-		}
-	      }
-	    }
-	  }
-	} //-- Rejections Boites 
-	//--	  else { 
-	//--	    cout<<" Rejet Boites "<<endl;
-	//--	  }
-      }
-      
-      
-      //-- Fin d exploration des lignes
-      if(dminiPointLigne > SeuildPointLigne) { 
-	//---------------------------------------------------
-	//-- Le point de depart du nouveau cheminement     --
-	//-- n est present dans aucune ligne deja calculee.--
-	//---------------------------------------------------
-	PW.Perform(StartParams);
-	if(PW.IsDone()) {
-	  if(PW.NbPoints()>2) { 
-	    //-----------------------------------------------
-	    //-- Verification a posteriori : 
-	    //-- On teste si le point de depart et de fin de 
-	    //-- la ligne de cheminement est present dans une 
-	    //-- autre ligne . 
-	    //-----------------------------------------------
-	    RejetLigne = Standard_False;
-	    Point3dDebut = PW.Value(1).Value();
-	    Point3dFin   = PW.Value(PW.NbPoints()).Value();
-	    
-	    for(ver=1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
-	      const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
-	      //-- Handle(IntPatch_WLine) verwline=Handle(IntPatch_WLine)::DownCast(SLin.Value(ver));
-	      const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
-	      const IntSurf_PntOn2S& verPointFin   = verwline->Point(verwline->NbPnts());
-	      if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency) { 
-		RejetLigne = Standard_True; 
-	      }
-	      else { 
-		if(Point3dFin.Distance(verPointFin.Value()) < TolTangency) { 
-		  RejetLigne = Standard_True; 
-		}
-	      }
-	    }
-	    
-	    if(!RejetLigne) { 
-	      
-	      IntSurf_TypeTrans trans1,trans2;
-	      Standard_Real locu,locv;
-	      gp_Vec norm1,norm2,d1u,d1v;
-	      gp_Pnt ptbid;
-	      Standard_Integer indextg;
-	      gp_Vec tgline(PW.TangentAtLine(indextg));
-	      PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
-	      Surf1->D1(locu,locv,ptbid,d1u,d1v);
-	      norm1 = d1u.Crossed(d1v);
-	      PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
-	      Surf2->D1(locu,locv,ptbid,d1u,d1v);
-	      norm2 = d1u.Crossed(d1v);
-	      if (tgline.DotCross(norm2,norm1)>0.) {
-		trans1 = IntSurf_Out;
-		trans2 = IntSurf_In;
-	      }
-	      else {
-		trans1 = IntSurf_In;
-		trans2 = IntSurf_Out;
-	      }
-	      
-	      
-	      
-	      Standard_Real TolTang = TolTangency;
-	      Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
-	      IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
-	      IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
-	      
-	      //---------------
-	      if(wline->NbVertex() == 0) {
-		IntPatch_Point vtx;
-		const IntSurf_PntOn2S& POn2Sf = PW.Line()->Value(1);
-		POn2Sf.Parameters(pu1,pv1,pu2,pv2);
-		vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-		vtx.SetParameters(pu1,pv1,pu2,pv2);
-		vtx.SetParameter(1);
-		wline->AddVertex(vtx);
-		
-		const IntSurf_PntOn2S& POn2Sl = PW.Line()->Value(wline->NbPnts());
-		POn2Sl.Parameters(pu1,pv1,pu2,pv2);
-		vtx.SetValue(Point3dFin,TolTang,Standard_False);
-		vtx.SetParameters(pu1,pv1,pu2,pv2);
-		vtx.SetParameter(wline->NbPnts());
-		wline->AddVertex(vtx);
-	      }
-	      
-	      //---------------
-	      SLin.Append(wline);
-	      empt = Standard_False;
-	      
-	    }
-	    else { 
-	      //-- cout<<" ----- REJET DE LIGNE (POINT DE DEPART) ----- "<<endl;
-	    }
-	    //------------------------------------------------------------		
-	  }
-	}  //--  le cheminement a reussi (done a True)
-      }  //--  le point approche ne renvoie pas sur une ligne existante
-    } //-- Si HasStartPoint
-  } //-- Boucle sur Les Tangent Zones
-    
-}
-// modified by NIZHNY-AMV  Tue Oct 18 12:37:02 2005
-void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&    Surf1,
-					   const Handle(Adaptor3d_TopolTool)& D1,
-					   const Handle(Adaptor3d_HSurface)&    Surf2,
-					   const Handle(Adaptor3d_TopolTool)& D2,
-					   const Standard_Real   TolTangency,
-					   const Standard_Real   Epsilon,
-					   const Standard_Real   Deflection,
-					   const Standard_Real   Increment,
-                                           IntSurf_ListOfPntOn2S& LOfPnts,
-                                           const Standard_Boolean RestrictLine)
-{
-  if (LOfPnts.IsEmpty()){
-    done = Standard_True;
-    return;
-  }
-    
-  empt = Standard_True;
-  SLin.Clear();  
-  
-  Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1;
-  Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2;
-  Standard_Real U1,U2,V1,V2;
-  
-  UminLig1 = Surf1->FirstUParameter();
-  VminLig1 = Surf1->FirstVParameter();
-  UmaxLig1 = Surf1->LastUParameter();
-  VmaxLig1 = Surf1->LastVParameter();
-  UminLig2 = Surf2->FirstUParameter();
-  VminLig2 = Surf2->FirstVParameter();
-  UmaxLig2 = Surf2->LastUParameter();
-  VmaxLig2 = Surf2->LastVParameter();
-  
-  IntSurf_ListIteratorOfListOfPntOn2S IterLOP1(LOfPnts);
-
-  for(; IterLOP1.More(); IterLOP1.Next()){
-    IntSurf_PntOn2S Pnt = IterLOP1.Value();
-    Pnt.Parameters(U1, V1, U2, V2);
-    if(U1>UmaxLig1) UmaxLig1=U1;
-    if(V1>VmaxLig1) VmaxLig1=V1;
-    if(U2>UmaxLig2) UmaxLig2=U2;
-    if(V2>VmaxLig2) VmaxLig2=V2;
-    
-    if(U1<UminLig1) UminLig1=U1;
-    if(V1<VminLig1) VminLig1=V1;
-    if(U2<UminLig2) UminLig2=U2;
-    if(V2<VminLig2) VminLig2=V2; 
-  }
-
-  Standard_Real Deflection2 = Deflection*Deflection;
-  
-  Standard_Real SeuildPointLigne = 15.0 * Increment * Increment;
-  
-  Standard_Integer NbPntOn2SOnLine = 0, NbLigCalculee = 0, ver;
-  Standard_Real pu1,pu2,pv1,pv2, dminiPointLigne;
-  Standard_Boolean HasStartPoint,RejetLigne;
-  IntSurf_PntOn2S StartPOn2S;
-  gp_Pnt Point3dDebut,Point3dFin;
-
-  TColStd_Array1OfReal StartParams(1,4);
-  IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);  
-    
-  IntSurf_ListIteratorOfListOfPntOn2S IterLOP2(LOfPnts);
-  for(; IterLOP2.More(); IterLOP2.Next() ){
-    
-    IntSurf_PntOn2S cPnt = IterLOP2.Value();
-    cPnt.Parameters(U1, V1, U2, V2);
-    
-    StartParams(1) = U1;
-    StartParams(2) = V1;
-    StartParams(3) = U2;
-    StartParams(4) = V2;
-    
-    HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
-    dminiPointLigne = SeuildPointLigne + SeuildPointLigne;
-    if(HasStartPoint) {
-      StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
-      NbLigCalculee = SLin.Length();
-      Standard_Integer l;
-      for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { 
-        Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.ChangeValue(l));
-        if( (testwline->IsOutSurf1Box(gp_Pnt2d(pu1,pv1))==Standard_False) &&
-           (testwline->IsOutSurf2Box(gp_Pnt2d(pu2,pv2))==Standard_False) &&
-           (testwline->IsOutBox(StartPOn2S.Value())==Standard_False) )	{
-          NbPntOn2SOnLine = testwline->NbPnts();
-          Standard_Integer ll;
-          for( ll = 1; (ll < NbPntOn2SOnLine) && (dminiPointLigne >= SeuildPointLigne); ll++) { 
-            const gp_Pnt &Pa = testwline->Point(ll).Value();
-            const gp_Pnt &Pb = testwline->Point(ll+1).Value();
-            const gp_Pnt &PStart = StartPOn2S.Value();
-            gp_Vec AM(Pa,PStart);
-            gp_Vec MB(PStart,Pb);
-            Standard_Real AMMB = AM.Dot(MB);		    
-            if(AMMB > 0.0) {
-              gp_Dir ABN(Pb.X()-Pa.X(),Pb.Y()-Pa.Y(),Pb.Z()-Pa.Z());
-              Standard_Real lan =  ABN.X()*AM.X()+ABN.Y()*AM.Y()+ABN.Z()*AM.Z();
-              gp_Vec AH(lan*ABN.X(),lan*ABN.Y(),lan*ABN.Z());
-              gp_Vec HM(AM.X()-AH.X(),AM.Y()-AH.Y(),AM.Z()-AH.Z());
-              Standard_Real d = 0.0;
-              if(HM.X() < Deflection) { 
-                d+=HM.X()*HM.X();
-                if(HM.Y() < Deflection) { 
-                  d+=HM.Y()*HM.Y(); 
-                  if(HM.Z() < Deflection)
-                    d+=HM.Z()*HM.Z(); 
-                  else
-                    d=Deflection2;
-                }
-                else
-                  d=Deflection2;
-              } 
-              else
-                d=Deflection2; 
-              
-              if(d<Deflection2)
-                dminiPointLigne = 0.0;
-            }
-            else {
-              Standard_Real dab = Pa.SquareDistance(Pb);
-              Standard_Real dap = Pa.SquareDistance(PStart);
-              if(dap < dab)
-                dminiPointLigne=0;
-              else { 
-                Standard_Real dbp = Pb.SquareDistance(PStart);
-                if(dbp < dab)
-                  dminiPointLigne=0;
-              }
-            }
-          }// for( ll ...
-        }// if ...
-      }// for( l ...
-      
-      if(dminiPointLigne > SeuildPointLigne) {
-        PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
-        if(PW.IsDone())	{
-          if(PW.NbPoints()>2) {
-            RejetLigne = Standard_False;
-            Point3dDebut = PW.Value(1).Value();
-            Point3dFin   = PW.Value(PW.NbPoints()).Value();
-            for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
-              const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
-              const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
-              const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts());
-              if(Point3dDebut.Distance(verPointDebut.Value()) <= TolTangency) { 
-                if(Point3dFin.Distance(verPointFin.Value()) <= TolTangency)
-                  RejetLigne = Standard_True; 
-              }
-            }
-            
-            if(!RejetLigne) {
-              IntSurf_TypeTrans trans1,trans2;
-              Standard_Real locu,locv;
-              gp_Vec norm1,norm2,d1u,d1v;
-              gp_Pnt ptbid;
-              Standard_Integer indextg;
-              gp_Vec tgline(PW.TangentAtLine(indextg));
-              PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
-              Surf1->D1(locu,locv,ptbid,d1u,d1v);
-              norm1 = d1u.Crossed(d1v);
-              PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
-              Surf2->D1(locu,locv,ptbid,d1u,d1v);
-              norm2 = d1u.Crossed(d1v);
-              if( tgline.DotCross(norm2,norm1) >= 0. ) {
-                trans1 = IntSurf_Out;
-                trans2 = IntSurf_In;
-              }
-              else {
-                trans1 = IntSurf_In;
-                trans2 = IntSurf_Out;
-              }
-              
-              Standard_Real TolTang = TolTangency;
-              Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
-              if (RestrictLine){
-                IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
-                IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
-              }
-              
-              if(wline->NbVertex() == 0) {
-                IntPatch_Point vtx;
-                IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
-                POn2S.Parameters(pu1,pv1,pu2,pv2);
-                vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-                vtx.SetParameters(pu1,pv1,pu2,pv2);
-                vtx.SetParameter(1);
-                wline->AddVertex(vtx);
-                
-                POn2S = PW.Line()->Value(wline->NbPnts());
-                POn2S.Parameters(pu1,pv1,pu2,pv2);
-                vtx.SetValue(Point3dFin,TolTang,Standard_False);
-                vtx.SetParameters(pu1,pv1,pu2,pv2);
-                vtx.SetParameter(wline->NbPnts());
-                wline->AddVertex(vtx);
-              }              
-
-              Standard_Integer slinlen = SLin.Length();
-              if( slinlen > 0 ) {
-                Standard_Integer cnbV = wline->NbVertex();
-                Standard_Integer ciV;
-                for( ciV = 1; ciV <= cnbV; ciV++ ) {
-                  Standard_Real pntDMin = 1.e+100;
-                  Standard_Integer VDMin = 0;
-                  Standard_Integer WLDMin = 0;
-                  gp_Pnt cPV = wline->Vertex(ciV).Value();
-                  Standard_Integer iL;
-                  for( iL = 1; iL <= slinlen; iL++) {
-                    const Handle(IntPatch_Line)& aSLine = SLin.Value(iL);
-                    IntPatch_IType aType = aSLine->ArcType();
-                    if( aType != IntPatch_Walking)
-                      continue;
-                    const Handle(IntPatch_WLine)&  aWLine = (*((Handle(IntPatch_WLine)*)&aSLine));
-                    Standard_Integer tnbV = aWLine->NbVertex();
-                    Standard_Integer tiV;
-                    for( tiV = 1; tiV <= tnbV; tiV++ ) {
-                      gp_Pnt tPV = aWLine->Vertex(tiV).Value();
-                      Standard_Real tDistance = cPV.Distance(tPV);
-                      Standard_Real uRs1 = Surf1->Surface().UResolution(tDistance);
-                      Standard_Real vRs1 = Surf1->Surface().VResolution(tDistance);
-                      Standard_Real uRs2 = Surf2->Surface().UResolution(tDistance);
-                      Standard_Real vRs2 = Surf2->Surface().VResolution(tDistance);
-                      Standard_Real RmaxS1 = Max(uRs1,vRs1);
-                      Standard_Real RmaxS2 = Max(uRs2,vRs2);
-                      if(RmaxS1 < 1.e-4 && RmaxS2 < 1.e-4) {
-                        if( pntDMin > tDistance && tDistance > 1.e-9) {
-                          pntDMin = tDistance;
-                          VDMin = tiV;
-                          WLDMin = iL;
-                        }
-                      }
-                    }
-                  }
-                  
-                  if( VDMin != 0 ) {
-                    const Handle(IntPatch_Line)& aSLine = SLin.Value(WLDMin);
-                    const Handle(IntPatch_WLine)&  aWLine = (*((Handle(IntPatch_WLine)*)&aSLine));
-                    Standard_Integer tiVpar = (Standard_Integer)aWLine->Vertex(VDMin).ParameterOnLine();
-                    Standard_Integer ciVpar = (Standard_Integer)wline->Vertex(ciV).ParameterOnLine();
-                    Standard_Real u11 = 0., u12 = 0., v11 = 0., v12 = 0.;
-                    Standard_Real u21 = 0., u22 = 0., v21 = 0., v22 = 0.;
-                    wline->Point(ciVpar).Parameters(u11,v11,u12,v12);
-                    aWLine->Point(tiVpar).Parameters(u21,v21,u22,v22);
-                    
-                    Handle(IntSurf_LineOn2S) newL2s = new IntSurf_LineOn2S();
-                    IntSurf_PntOn2S replacePnt = aWLine->Point(tiVpar);
-                    Standard_Integer cNbP = wline->NbPnts();
-                    
-                    TColStd_SequenceOfInteger VPold;
-                    Standard_Integer iPo;
-                    for( iPo = 1; iPo <= cnbV; iPo++ ) {
-                      Standard_Real Po = wline->Vertex(iPo).ParameterOnLine();
-                      Standard_Integer IPo = (Standard_Integer) Po;
-                      VPold.Append(IPo);
-                    }
-                    
-                    Standard_Boolean removeNext = Standard_False;
-                    Standard_Boolean removePrev = Standard_False;
-                    if( ciV == 1) {
-                      Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV+1));
-                      if(dPar > 10) {
-				removeNext = Standard_True;
-				for( iPo = (ciV+1); iPo <= cnbV; iPo++ )
-				  VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
-			      }
-                    }
-                    else if( ciV == cnbV) {
-                      Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV-1));
-                      if(dPar > 10) {
-                        removePrev = Standard_True;
-                        VPold.SetValue(ciV, VPold.Value(ciV) - 1 );
-                      }
-                    }
-                    else {
-                      Standard_Integer dParMi = Abs( VPold.Value(ciV) - VPold.Value(ciV-1));
-                      Standard_Integer dParMa = Abs( VPold.Value(ciV) - VPold.Value(ciV+1));
-                      if(dParMi > 10) {
-                        removePrev = Standard_True;
-                        VPold.SetValue(ciV, VPold.Value(ciV) - 1 );
-                      }
-                      if(dParMa > 10) {
-                        removeNext = Standard_True;
-                        for( iPo = (ciV+1); iPo <= cnbV; iPo++ ) {
-                          if(dParMi > 10)
-                            VPold.SetValue(iPo, VPold.Value(iPo) - 2 );
-                          else
-                            VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
-                        }
-                      }
-                      else {
-                        if(dParMi > 10)
-                          for( iPo = (ciV+1); iPo <= cnbV; iPo++ )
-                            VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
-                      } 
-                    }
-                    Standard_Integer pI = (Standard_Integer) ciVpar;
-                    
-                    Standard_Integer iP;
-                    for( iP = 1; iP <= cNbP; iP++) {
-                      if( pI == iP )
-                        newL2s->Add(replacePnt);
-                      else if(removeNext && iP == (pI + 1))
-                        continue;
-                      else if(removePrev && iP == (pI - 1))
-                        continue;
-                      else
-                        newL2s->Add(wline->Point(iP));
-                    }
-                    
-                    IntPatch_Point newVtx;
-                    gp_Pnt Pnt3dV = aWLine->Vertex(VDMin).Value();
-                    newVtx.SetValue(Pnt3dV,TolTang,Standard_False);
-                    newVtx.SetParameters(u21,v21,u22,v22);
-                    newVtx.SetParameter(VPold.Value(ciV));
-                    
-                    Handle(IntPatch_WLine) NWLine = new IntPatch_WLine(newL2s,Standard_False,trans1,trans2);
-                    
-                    Standard_Integer iV;
-                    for( iV = 1; iV <= cnbV; iV++ ) {
-                      if( iV == ciV )
-                        NWLine->AddVertex(newVtx);
-                      else {
-                        IntPatch_Point theVtx = wline->Vertex(iV);
-                        theVtx.SetParameter(VPold.Value(iV));
-                        NWLine->AddVertex(theVtx);
-                      }
-                    }
-                    
-                    wline = NWLine;
-                  }
-                }
-              }// SLin.Length > 0
-              
-              SLin.Append(wline);
-              empt = Standard_False;
-            }// !RejetLigne
-          }// PW points > 2
-        }// done is True
-      }// dminiPointLigne > SeuildPointLigne
-    }// HasStartPoint  
-  }// for( IterLOP ...
-  done = Standard_True;
-  return;      
-}
+	    if(PW.IsDone()) {
+	      if(PW.NbPoints()>2) { 
+		//-----------------------------------------------
+		//-- Verification a posteriori : 
+		//-- On teste si le point de depart et de fin de 
+		//-- la ligne de cheminement est present dans une 
+		//-- autre ligne . 
+		//-----------------------------------------------
+		RejetLigne = Standard_False;
+		Point3dDebut = PW.Value(1).Value();
+		Point3dFin   = PW.Value(PW.NbPoints()).Value();
+		
+		for(ver=1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
+		  const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
+		  //-- Handle(IntPatch_WLine) verwline=Handle(IntPatch_WLine)::DownCast(SLin.Value(ver));
+		  const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
+		  const IntSurf_PntOn2S& verPointFin   = verwline->Point(verwline->NbPnts());
+		  if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency) { 
+		    RejetLigne = Standard_True; 
+		  }
+		  else { 
+		    if(Point3dFin.Distance(verPointFin.Value()) < TolTangency) { 
+		      RejetLigne = Standard_True; 
+		    }
+		  }
+		}
+		
+		if(!RejetLigne) { 
 
-//======================================================================     
-void IntPatch_PrmPrmIntersection::Perform(const Handle(Adaptor3d_HSurface)&    Surf1,
-					  const Handle(Adaptor3d_TopolTool)& D1,
-					  const Handle(Adaptor3d_HSurface)&    Surf2,
-					  const Handle(Adaptor3d_TopolTool)& D2,
-					  const Standard_Real   U1Depart,
-					  const Standard_Real   V1Depart,
-					  const Standard_Real   U2Depart,
-					  const Standard_Real   V2Depart,
-					  const Standard_Real   TolTangency,
-					  const Standard_Real   Epsilon,
-					  const Standard_Real   Deflection,
-					  const Standard_Real   Increment) { 
-  
-  
-  
-//    Standard_Integer NbU1 = D1->NbSamplesU();
-//    Standard_Integer NbV1 = D1->NbSamplesV();
-//    Standard_Integer NbU2 = D2->NbSamplesU();
-//    Standard_Integer NbV2 = D2->NbSamplesV();
+		  IntSurf_TypeTrans trans1,trans2;
+		  Standard_Real locu,locv;
+		  gp_Vec norm1,norm2,d1u,d1v;
+		  gp_Pnt ptbid;
+		  Standard_Integer indextg;
+		  gp_Vec tgline(PW.TangentAtLine(indextg));
+		  PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
+		  Surf1->D1(locu,locv,ptbid,d1u,d1v);
+		  norm1 = d1u.Crossed(d1v);
+		  PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
+		  Surf2->D1(locu,locv,ptbid,d1u,d1v);
+		  norm2 = d1u.Crossed(d1v);
+		  if (tgline.DotCross(norm2,norm1)>0.) {
+		    trans1 = IntSurf_Out;
+		    trans2 = IntSurf_In;
+		  }
+		  else {
+		    trans1 = IntSurf_In;
+		    trans2 = IntSurf_Out;
+		  }
+		  
+		  
+		  
+		  Standard_Real TolTang = TolTangency;
+		  Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+		  IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+		  IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+		  
+		  //---------------
+                    if(wline->NbVertex() == 0) {
+		      IntPatch_Point vtx;
+		      IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
+		      POn2S.Parameters(pu1,pv1,pu2,pv2);
+		      vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+		      vtx.SetParameters(pu1,pv1,pu2,pv2);
+		      vtx.SetParameter(1);
+		      wline->AddVertex(vtx);
+		      
+		      POn2S = PW.Line()->Value(wline->NbPnts());
+		      POn2S.Parameters(pu1,pv1,pu2,pv2);
+		      vtx.SetValue(Point3dFin,TolTang,Standard_False);
+		      vtx.SetParameters(pu1,pv1,pu2,pv2);
+		      vtx.SetParameter(wline->NbPnts());
+		      wline->AddVertex(vtx);
+		    }
+		    
+		  //---------------
+		  SLin.Append(wline);
+		  empt = Standard_False;
+		  
+		}
+		else { 
+		  //-- cout<<" ----- REJET DE LIGNE (POINT DE DEPART) ----- "<<endl;
+		}
+		//------------------------------------------------------------		
+	      }
+	    }  //--  le cheminement a reussi (done a True)
+	  }  //--  le point approche ne renvoie pas sur une ligne existante
+	} //-- Si HasStartPoint
+      //} //-- Boucle Sur les Points de la Tangent Zone
+    } //-- Boucle sur Les Tangent Zones
 
-  //-- Traitement des Lignes de sections
+    if ( pInterference ) {
+      delete pInterference;
+      pInterference = NULL;
+    }
+    return;
+  }// if((NbU1*NbV1<=Limit && NbV2*NbU2<=Limit)) {  
+
+  Handle(IntSurf_LineOn2S) LOn2S = new IntSurf_LineOn2S();
+  PointDepart( LOn2S, Surf1, NbU1, NbV1, Surf2, NbU2, NbV2 );
   empt = Standard_True;
   done = Standard_True;
   SLin.Clear();  
+  Standard_Real Deflection2 = Deflection*Deflection;
   
-  //------------------------------------------------------------
-
+  Standard_Integer NbPntOn2SOnLine;
+  Standard_Integer NbLigCalculee = 0;
+  Standard_Real U1,U2,V1,V2;
   Standard_Real pu1,pu2,pv1,pv2;
   
   TColStd_Array1OfReal StartParams(1,4);
+  Standard_Integer MaxOscill = NbU1;
+  if(MaxOscill < NbU2) MaxOscill=NbU2;
+  if(MaxOscill < NbV1) MaxOscill=NbV1;
+  if(MaxOscill < NbV2) MaxOscill=NbV2;
   
-//    Standard_Integer MaxOscill = NbU1;
-//    if(MaxOscill < NbU2) MaxOscill=NbU2;
-//    if(MaxOscill < NbV1) MaxOscill=NbV1;
-//    if(MaxOscill < NbV2) MaxOscill=NbV2;
-  
-//    Standard_Real nIncrement=Increment;
-//    if(MaxOscill>10) { 
-//  #ifdef DEB 
-//      cout<<"\n IntPatch_PrmPrmIntersection.gxx : Increment:"<<Increment<<" -> "<<Increment/(0.5*MaxOscill)<<endl;
-//  #endif
-//      nIncrement/=0.5*MaxOscill;
-//    }
-  
-  IntPatch_ThePWalkingInter PW(Surf1,Surf2,
-			       TolTangency,
-			       Epsilon,
-			       Deflection,
-			       Increment); //nIncrement);
-  
-  
-  //Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
-  //Standard_Real    incidence;
-  //Standard_Real    dminiPointLigne;
-  
-  Standard_Boolean HasStartPoint;//,RejetLigne;
-  
+  Standard_Real nIncrement=Increment;
+  //if(MaxOscill>10)
+    //nIncrement/=0.5*MaxOscill;
+
+  IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,nIncrement);
+  Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
+  Standard_Real    dminiPointLigne;
+  Standard_Boolean HasStartPoint,RejetLigne;
   IntSurf_PntOn2S StartPOn2S;
-  
-  //Standard_Integer ver;
-  
+  Standard_Integer ver;
   gp_Pnt Point3dDebut,Point3dFin;
-  
+
   //------------------------------------------------------------
-  
-  StartParams(1) = U1Depart;
-  StartParams(2) = V1Depart;
-  StartParams(3) = U2Depart;
-  StartParams(4) = V2Depart;
-  
-  //-----------------------------------------------------------------------
-  //-- Calcul du premier point de cheminement a partir du point approche --
-  //-----------------------------------------------------------------------
-  HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);	
-  if(HasStartPoint) { 
-    //-------------------------------------------------
-    //-- Un point a ete trouve                       --
-    //-- On verifie qu il n appartient pas           --
-    //--  a une ligne de cheminement deja calculee.  --
-    //-------------------------------------------------
+  //-- Calcul des parametres approches a partir des Zones De Tangence --
+  //--------------------------------------------------------------------
+  Standard_Integer nbTanZon = LOn2S->NbPoints();
+  for(Standard_Integer z=1; z <= nbTanZon; z++) { 
+    const IntSurf_PntOn2S& POn2S = LOn2S->Value(z);
+    POn2S.Parameters(U1,V1,U2,V2);
+    StartParams(1) = U1;
+    StartParams(2) = V1;
+    StartParams(3) = U2;
+    StartParams(4) = V2;
     
-    PW.Perform(StartParams);
-    if(PW.IsDone()) {
+    //-----------------------------------------------------------------------
+    //-- Calcul du premier point de cheminement a partir du point approche --
+    //-----------------------------------------------------------------------
+    HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);	
+    if(HasStartPoint) { 
+      //-------------------------------------------------
+      //-- Un point a ete trouve                       --
+      //-- On verifie qu il n appartient pas           --
+      //--  a une ligne de cheminement deja calculee.  --
+      //-------------------------------------------------
+      StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
       
-      Point3dDebut = PW.Value(1).Value();
-      Point3dFin   = PW.Value(PW.NbPoints()).Value();
-
-      IntSurf_TypeTrans trans1,trans2;
-      Standard_Real locu,locv;
-      gp_Vec norm1,norm2,d1u,d1v;
-      gp_Pnt ptbid;
-      Standard_Integer indextg;
-      gp_Vec tgline(PW.TangentAtLine(indextg));
-      PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
-      Surf1->D1(locu,locv,ptbid,d1u,d1v);
-      norm1 = d1u.Crossed(d1v);
-      PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
-      Surf2->D1(locu,locv,ptbid,d1u,d1v);
-      norm2 = d1u.Crossed(d1v);
-      if (tgline.DotCross(norm2,norm1)>0.) {
-	trans1 = IntSurf_Out;
-	trans2 = IntSurf_In;
-      }
-      else {
-	trans1 = IntSurf_In;
-	trans2 = IntSurf_Out;
+      NbLigCalculee = SLin.Length();
+      dminiPointLigne = SeuildPointLigne + SeuildPointLigne; 
+      
+      for(Standard_Integer l=1; 
+	  (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); 
+	  l++) { 
+	const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
+	
+	if(  (testwline->IsOutSurf1Box(gp_Pnt2d(pu1,pv1))==Standard_False)
+	   &&(testwline->IsOutSurf2Box(gp_Pnt2d(pu2,pv2))==Standard_False)
+	   &&(testwline->IsOutBox(StartPOn2S.Value())==Standard_False)) { 
+	  
+	  NbPntOn2SOnLine = testwline->NbPnts();
+	  for(Standard_Integer ll=1; 
+	      (ll < NbPntOn2SOnLine) && (dminiPointLigne >= SeuildPointLigne); 
+	      ll++) { 
+	    
+	    const gp_Pnt& Pa = testwline->Point(ll).Value();
+	    const gp_Pnt& Pb = testwline->Point(ll+1).Value();
+	    const gp_Pnt& PStart=StartPOn2S.Value();
+	    gp_Vec AM(Pa,PStart);
+	    gp_Vec MB(PStart,Pb);
+	    Standard_Real AMMB = AM.Dot(MB);
+	    if(AMMB > 0.0) {
+	      gp_Dir ABN(Pb.X()-Pa.X(),Pb.Y()-Pa.Y(),Pb.Z()-Pa.Z());
+	      Standard_Real lan =  ABN.X()*AM.X()+ABN.Y()*AM.Y()+ABN.Z()*AM.Z();
+	      gp_Vec AH(lan*ABN.X(),lan*ABN.Y(),lan*ABN.Z());
+	      gp_Vec HM(AM.X()-AH.X(),AM.Y()-AH.Y(),AM.Z()-AH.Z()); 
+	      
+	      Standard_Real d = 0.0;
+	      if(HM.X() < Deflection) { 
+		d+=HM.X()*HM.X();
+		if(HM.Y() < Deflection) { 
+		  d+=HM.Y()*HM.Y(); 
+		  if(HM.Z() < Deflection) { 
+		    d+=HM.Z()*HM.Z(); 
+		  }
+		  else { 
+		    d=Deflection2;
+		  }
+		}
+		else { 
+		  d=Deflection2;
+		}
+	      } 
+	      else { 
+		d=Deflection2; 
+	      }
+	      if(d<Deflection2) { 
+		dminiPointLigne = 0.0;
+	      }
+	    }
+	    else { 
+	      Standard_Real dab = Pa.Distance(Pb);
+	      Standard_Real dap = Pa.Distance(PStart);
+	      if(dap < dab) { 
+		dminiPointLigne=0;
+	      }
+	      else { 
+		Standard_Real dbp = Pb.Distance(PStart);
+		if(dbp < dab) { 
+		  dminiPointLigne=0;
+		}
+	      }
+	    }
+	  }
+	} //-- Rejections Boites 
+	//--	  else { 
+	//--	    cout<<" Rejet Boites "<<endl;
+	//--	  }
       }
       
       
-      
-      Standard_Real TolTang = TolTangency;
-      Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
-      IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
-      IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
-      
-      //---------------
-      if(wline->NbVertex() == 0) {
-	IntPatch_Point vtx;
-	IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
-	POn2S.Parameters(pu1,pv1,pu2,pv2);
-	vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-	vtx.SetParameters(pu1,pv1,pu2,pv2);
-	vtx.SetParameter(1);
-	wline->AddVertex(vtx);
-	
-	POn2S = PW.Line()->Value(wline->NbPnts());
-	POn2S.Parameters(pu1,pv1,pu2,pv2);
-	vtx.SetValue(Point3dFin,TolTang,Standard_False);
-	vtx.SetParameters(pu1,pv1,pu2,pv2);
-	vtx.SetParameter(wline->NbPnts());
-	wline->AddVertex(vtx);
+      //-- Fin d exploration des lignes
+      if(dminiPointLigne > SeuildPointLigne) { 
+	//---------------------------------------------------
+	//-- Le point de depart du nouveau cheminement     --
+	//-- n est present dans aucune ligne deja calculee.--
+	//---------------------------------------------------
+	PW.Perform(StartParams);
+	if(PW.IsDone()) {
+	  if(PW.NbPoints()>2) { 
+	    //-----------------------------------------------
+	    //-- Verification a posteriori : 
+	    //-- On teste si le point de depart et de fin de 
+	    //-- la ligne de cheminement est present dans une 
+	    //-- autre ligne . 
+	    //-----------------------------------------------
+	    RejetLigne = Standard_False;
+	    Point3dDebut = PW.Value(1).Value();
+	    Point3dFin   = PW.Value(PW.NbPoints()).Value();
+	    
+	    for(ver=1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
+	      const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
+	      //-- Handle(IntPatch_WLine) verwline=Handle(IntPatch_WLine)::DownCast(SLin.Value(ver));
+	      const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
+	      const IntSurf_PntOn2S& verPointFin   = verwline->Point(verwline->NbPnts());
+	      if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency) { 
+		RejetLigne = Standard_True; 
+	      }
+	      else { 
+		if(Point3dFin.Distance(verPointFin.Value()) < TolTangency) { 
+		  RejetLigne = Standard_True; 
+		}
+	      }
+	    }
+	    
+	    if(!RejetLigne) { 
+	      
+	      IntSurf_TypeTrans trans1,trans2;
+	      Standard_Real locu,locv;
+	      gp_Vec norm1,norm2,d1u,d1v;
+	      gp_Pnt ptbid;
+	      Standard_Integer indextg;
+	      gp_Vec tgline(PW.TangentAtLine(indextg));
+	      PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
+	      Surf1->D1(locu,locv,ptbid,d1u,d1v);
+	      norm1 = d1u.Crossed(d1v);
+	      PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
+	      Surf2->D1(locu,locv,ptbid,d1u,d1v);
+	      norm2 = d1u.Crossed(d1v);
+	      if (tgline.DotCross(norm2,norm1)>0.) {
+		trans1 = IntSurf_Out;
+		trans2 = IntSurf_In;
+	      }
+	      else {
+		trans1 = IntSurf_In;
+		trans2 = IntSurf_Out;
+	      }
+	      
+	      
+	      
+	      Standard_Real TolTang = TolTangency;
+	      Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+	      IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+	      IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+	      
+	      //---------------
+	      if(wline->NbVertex() == 0) {
+		IntPatch_Point vtx;
+		const IntSurf_PntOn2S& POn2Sf = PW.Line()->Value(1);
+		POn2Sf.Parameters(pu1,pv1,pu2,pv2);
+		vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+		vtx.SetParameters(pu1,pv1,pu2,pv2);
+		vtx.SetParameter(1);
+		wline->AddVertex(vtx);
+		
+		const IntSurf_PntOn2S& POn2Sl = PW.Line()->Value(wline->NbPnts());
+		POn2Sl.Parameters(pu1,pv1,pu2,pv2);
+		vtx.SetValue(Point3dFin,TolTang,Standard_False);
+		vtx.SetParameters(pu1,pv1,pu2,pv2);
+		vtx.SetParameter(wline->NbPnts());
+		wline->AddVertex(vtx);
+	      }
+	      
+	      //---------------
+	      SLin.Append(wline);
+	      empt = Standard_False;
+	      
+	    }
+	    else { 
+	      //-- cout<<" ----- REJET DE LIGNE (POINT DE DEPART) ----- "<<endl;
+	    }
+	    //------------------------------------------------------------		
+	  }
+	}  //--  le cheminement a reussi (done a True)
+      }  //--  le point approche ne renvoie pas sur une ligne existante
+    } //-- Si HasStartPoint
+  } //-- Boucle sur Les Tangent Zones
+    
+}
+//modified by NIZNHY-PKV Wed May 25 09:39:07 2011f
+//=======================================================================
+//class : IntPatch_InfoPD
+//purpose  : 
+//=======================================================================
+class IntPatch_InfoPD {
+ public:
+  //----------------------------------------C-tor
+  IntPatch_InfoPD(const Standard_Integer aNBI) {
+    Standard_Integer aNBI2, i, j;
+    myNBI=aNBI;
+    //
+    aNBI2=aNBI*aNBI;
+    myP1DS2=new char[aNBI2];
+    myP2DS1=new char[aNBI2];
+    myIP1=new Standard_Integer[aNBI2]; 
+    myIP2=new Standard_Integer[aNBI2];
+    myP1=new gp_Pnt[aNBI2];
+    myP2=new gp_Pnt[aNBI2];
+    //
+    for (i=0; i<myNBI; ++i) {
+      for (j=0; j<myNBI; ++j) {
+	xP1DS2(i, j)=0;
+	xP2DS1(i, j)=0;
+	xIP1(i, j)=0;
+	xIP2(i, j)=0;
+	xP1(i, j).SetCoord(0., 0., 0.);
+	xP2(i, j).SetCoord(0., 0., 0.);
       }
-      
-      //---------------
-      SLin.Append(wline);
-      empt = Standard_False;
-      
     }
-  }
-}
-
-
-//xf
+  };
+  //---------------------------------------- D-tor
+  ~IntPatch_InfoPD() {
+    delete [] (char*) myP1DS2;
+    delete [] (char*) myP2DS1;
+    delete [] (Standard_Integer*) myIP1;
+    delete [] (Standard_Integer*) myIP2; 
+    delete [] (gp_Pnt*)myP1;
+    delete [] (gp_Pnt*)myP2;
+  };
+  //---------------------------------------- Index
+  Standard_Integer Index(const Standard_Integer i,
+			 const Standard_Integer j) const { 
+    return i*myNBI+j;
+  };
+  //---------------------------------------- NBI
+  Standard_Integer NBI() const { 
+    return myNBI;
+  };
+  //----------------------------------------xP1DS2
+  char& xP1DS2(const Standard_Integer i,
+	       const Standard_Integer j) { 
+    return myP1DS2[Index(i,j)];
+  };
+  //----------------------------------------xP2DS1
+  char& xP2DS1(const Standard_Integer i,
+	       const Standard_Integer j) { 
+    return myP2DS1[Index(i,j)];
+  };
+  //----------------------------------------xIP1
+  Standard_Integer& xIP1(const Standard_Integer i,
+			 const Standard_Integer j) { 
+    return myIP1[Index(i,j)];
+  };
+  //----------------------------------------xIP2
+  Standard_Integer& xIP2(const Standard_Integer i,
+			 const Standard_Integer j) { 
+    return myIP2[Index(i,j)];
+  };
+  //----------------------------------------xP1
+  gp_Pnt& xP1(const Standard_Integer i,
+	      const Standard_Integer j) { 
+    return myP1[Index(i,j)];
+  };
+  //----------------------------------------xP1
+  gp_Pnt& xP2(const Standard_Integer i,
+	      const Standard_Integer j) { 
+    return myP2[Index(i,j)];
+  };
+ protected:
+  Standard_Integer myNBI;
+  char *myP1DS2;
+  char *myP2DS1;
+  Standard_Integer *myIP1;
+  Standard_Integer *myIP2;
+  gp_Pnt *myP1;
+  gp_Pnt *myP2;
+}; 
+//modified by NIZNHY-PKV Tue May 24 11:38:55 2011t
 //==================================================================================
-// function : AdjustOnPeriodic
+// function : PointDepart
 // purpose  : 
 //==================================================================================
-void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1,
-		      const Handle(Adaptor3d_HSurface)& Surf2,
-		      IntPatch_SequenceOfLine& aSLin)
-{
-  Standard_Boolean bIsPeriodic[4], bModified, bIsNull, bIsPeriod;
-  Standard_Integer i, j, k, aNbLines, aNbPx, aIndx, aIndq;
-  Standard_Real aPeriod[4], dPeriod[4], ux[4], uq[4], aEps, du;
+void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S,
+					      const Handle(Adaptor3d_HSurface)& S1,
+					      const Standard_Integer SU_1,
+					      const Standard_Integer SV_1,
+					      const Handle(Adaptor3d_HSurface)& S2,
+					      const Standard_Integer SU_2,
+					      const Standard_Integer SV_2) const 
+{ 
+  Standard_Integer i, j, xNBI;
+  //modified by NIZNHY-PKV Tue May 24 11:37:38 2011f
+  xNBI=200;
+  IntPatch_InfoPD aIPD(xNBI);
+  //modified by NIZNHY-PKV Wed May 25 06:47:12 2011t
+  Standard_Integer iC15, SU1, SV1, SU2, SV2;
+  Standard_Real U0, U1, V0, V1, U, V;
+  Standard_Real resu0,resv0;
+  Standard_Real  du1,du2,dv1,dv2, dmaxOn1, dmaxOn2;
+  Standard_Real x0,y0,z0, x1,y1,z1,d;
+  Bnd_Box Box1, Box2;
   //
-  aEps=Precision::Confusion();
+  iC15=15;
+  SU1 =iC15*SU_1 ;
+  SV1 =iC15*SV_1 ;
+  SU2 =iC15*SU_2 ;
+  SV2 =iC15*SV_2 ;
+  //
+  if(xNBI<SU1) {
+    SU1 = xNBI;
+  }
+  if(xNBI<SV1){
+    SV1 = xNBI;
+  }
+  if(xNBI<SU2){
+    SU2 = xNBI;
+  }
+  if(xNBI<SV2){
+    SV2 = xNBI;
+  }
+  //
+  U0 = S1->FirstUParameter();
+  U1 = S1->LastUParameter();
+  V0 = S1->FirstVParameter();
+  V1 = S1->LastVParameter();
+  //
+  resu0=U0;
+  resv0=V0;
+  //
+  dmaxOn1 = 0.0;
+  dmaxOn2 = 0.0;
+  //-----
+  du1 = (U1-U0)/(SU1-1);
+  dv1 = (V1-V0)/(SV1-1);
+  for(U=U0,i=0; i<SU1; i++,U+=du1) { 
+    for(V=V0,j=0; j<SV1; V+=dv1,j++) { 
+      aIPD.xP1(i, j)= S1->Value(U,V);
+      Box1.Add(aIPD.xP1(i, j));
+      if(i>0 && j>0) { 
+	aIPD.xP1(i, j)    .Coord(x0,y0,z0);
+	aIPD.xP1(i-1, j-1).Coord(x1,y1,z1);
+	//
+	d=Abs(x1-x0)+Abs(y1-y0)+Abs(z1-z0);
+	if(d>dmaxOn1) {
+	  dmaxOn1 = d;
+	}
+      }
+    }
+  }
+  Box1.Enlarge(1.e-8);
+  //
+  U0 = S2->FirstUParameter();
+  U1 = S2->LastUParameter();
+  V0 = S2->FirstVParameter();
+  V1 = S2->LastVParameter();
+  //
+  du2 = (U1-U0)/(SU2-1);  
+  dv2 = (V1-V0)/(SV2-1);
+  for(U=U0,i=0; i<SU2; i++,U+=du2) { 
+    for(V=V0,j=0; j<SV2; V+=dv2,j++) { 
+      aIPD.xP2(i, j) = S2->Value(U,V);
+      Box2.Add(aIPD.xP2(i, j));
+      if(i>0 && j>0) { 
+	aIPD.xP2(i, j)    .Coord(x0,y0,z0);
+	aIPD.xP2(i-1, j-1).Coord(x1,y1,z1);
+	d =  Abs(x1-x0)+Abs(y1-y0)+Abs(z1-z0);
+	if(d>dmaxOn2) {
+	  dmaxOn2 = d;
+	}
+      }
+    }
+  }
+  Box2.Enlarge(1.e-8);
+  //--------
+  //
+  if(Box1.IsOut(Box2)) {
+    
+    return;
+  }
+  //
+  Standard_Integer aNbPG;
+  Standard_Real x10,y10,z10,x11,y11,z11;
+  Standard_Real x20,y20,z20,x21,y21,z21;
+  Standard_Real dx, dy, dz, dmax;
+  Standard_Real dx2, dy2, dz2;
+  //
+  Box1.Get(x10,y10,z10,x11,y11,z11);
+  Box2.Get(x20,y20,z20,x21,y21,z21);
+  //
+  x0 = (x10>x20)? x10 : x20;
+  y0 = (y10>y20)? y10 : y20;
+  z0 = (z10>z20)? z10 : z20;
+  //
+  x1 = (x11<x21)? x11 : x21;
+  y1 = (y11<y21)? y11 : y21;
+  z1 = (z11<z21)? z11 : z21;
+  //
+  if(dmaxOn2 > dmaxOn1) {
+    dmaxOn1 = dmaxOn2;
+  }
+  //
+  dmaxOn1+=dmaxOn1;
+  x0-=dmaxOn1;
+  y0-=dmaxOn1;
+  z0-=dmaxOn1;
+  x1+=dmaxOn1;
+  y1+=dmaxOn1;
+  z1+=dmaxOn1;
+  //
+  x10-=dmaxOn1;   y10-=dmaxOn1;   z10-=dmaxOn1; 
+  x11+=dmaxOn1;   y11+=dmaxOn1;   z11+=dmaxOn1; 
+
+  x20-=dmaxOn1;   y20-=dmaxOn1;   z20-=dmaxOn1; 
+  x21+=dmaxOn1;   y21+=dmaxOn1;   z21+=dmaxOn1; 
+
+  aNbPG=NbPointsGrille();
+  dx = (x1-x0)/aNbPG;
+  dy = (y1-y0)/aNbPG;
+  dz = (z1-z0)/aNbPG;
   //
-  for (k=0; k<4; ++k) {
-    aPeriod[k]=0.;
+  dmax = dx;
+  if(dy>dmax) {
+    dmax = dy;
   }
-  //
-  bIsPeriodic[0]=Surf1->IsUPeriodic();
-  bIsPeriodic[1]=Surf1->IsVPeriodic();
-  bIsPeriodic[2]=Surf2->IsUPeriodic();
-  bIsPeriodic[3]=Surf2->IsVPeriodic();
-  //
-  if (bIsPeriodic[0]){
-    aPeriod[0]=Surf1->UPeriod();
+  if(dz>dmax){
+    dmax = dz;
   }
-  if (bIsPeriodic[1]){
-    aPeriod[1]=Surf1->VPeriod();
+  //
+  if(dx<dmax*0.01) {
+    dx = dmax*0.01;
   }
-  if (bIsPeriodic[2]){
-    aPeriod[2]=Surf2->UPeriod();
+  if(dy<dmax*0.01) {
+    dy = dmax*0.01;
   }
-  if (bIsPeriodic[3]){
-    aPeriod[3]=Surf2->VPeriod();
+  if(dz<dmax*0.01) {
+    dz = dmax*0.01;
   }
   //
-  for (k=0; k<4; ++k) {
-    dPeriod[k]=0.25*aPeriod[k];
+  dx2 = dx*0.5;
+  dy2 = dy*0.5;
+  dz2 = dz*0.5 ;
+  //
+  IntPatch_PrmPrmIntersection_T3Bits M1(_BASE);
+  IntPatch_PrmPrmIntersection_T3Bits M2(_BASE);
+  //
+  for(i=0;i<SU1;i++) { 
+    for(j=0;j<SV1;j++) { 
+      aIPD.xIP1(i, j)=-1;
+      const gp_Pnt& P=aIPD.xP1(i, j);
+      aIPD.xP1DS2(i, j) = (char) CodeReject(x20,y20,z20,x21,y21,z21,P.X(),P.Y(),P.Z());
+      int ix = (int)((P.X()-x0  + dx2 )/dx);
+      if(DansGrille(ix)) { 
+	int iy = (int)((P.Y()-y0 + dy2)/dy);
+	if(DansGrille(iy)) {
+	  int iz = (int)((P.Z()-z0 + dz2)/dz);
+	  if(DansGrille(iz)) {
+	    aIPD.xIP1(i, j) = GrilleInteger(ix,iy,iz);
+	  }
+	}
+      }
+    }
+  }
+  //-- cout<<" Grille  du 1 fini "<<endl;
+  for(i=0;i<SU2;i++) { 
+    for(j=0;j<SV2;j++) { 
+      aIPD.xIP2(i, j)=-1;
+      const gp_Pnt& P=aIPD.xP2(i, j);
+      aIPD.xP2DS1(i, j) = (char) CodeReject(x10,y10,z10,x11,y11,z11,P.X(),P.Y(),P.Z());
+      int ix = (int)((P.X()-x0 + dx2)/dx);
+      if(DansGrille(ix)) { 
+	int iy = (int)((P.Y()-y0 + dy2)/dy);
+	if(DansGrille(iy)) {
+	  int iz = (int)((P.Z()-z0 + dz2)/dz);
+	  if(DansGrille(iz)) {
+	    aIPD.xIP2(i, j) =  GrilleInteger(ix,iy,iz);
+	  }
+	}
+      }
+    }
   }
   //
-  aNbLines=aSLin.Length();
-  for (i=1; i<=aNbLines; ++i) {
-    Handle(IntPatch_WLine) aIL=Handle(IntPatch_WLine)::DownCast(aSLin.Value(i));
-    Handle(IntSurf_LineOn2S) aL=aIL->Curve();
-
-    aNbPx=aL->NbPoints();
-    if (aNbPx<10) {
-      continue;
+  for(i=0;i<SU1-1;i+=1) {
+    for(j=0;j<SV1-1;j+=1) { 
+      if(!((aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i+1, j)) || 
+	   (aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i+1, j+1)))){
+	Remplit(aIPD.xIP1(i, j),
+		aIPD.xIP1(i+1, j),
+		aIPD.xIP1(i+1, j+1),
+		M1);
+      }
+      if(!((aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i, j+1)) || 
+	   (aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i+1, j+1)))) {
+	Remplit(aIPD.xIP1(i, j),
+		aIPD.xIP1(i, j+1),
+		aIPD.xIP1(i+1, j+1),
+		M1);	
+      }
     }
-    //
-    for (j=0; j<2; ++j) {
-      bModified=Standard_False;
-      aIndx=1;
-      aIndq=2;
-      if (j) {
-	aIndx=aNbPx;
-	aIndq=aNbPx-1;
+  }	
+  //
+  for(i=0;i<SU2-1;i+=1) {
+    for(j=0;j<SV2-1;j+=1) { 
+      if(!((aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i+1, j)) ||
+	   (aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i+1, j+1)))){
+	Remplit(aIPD.xIP2(i, j),
+		aIPD.xIP2(i+1, j),
+		aIPD.xIP2(i+1, j+1),
+		M2);
+      }
+      if(!((aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i, j+1)) || 
+	   (aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i+1, j+1)))){
+	Remplit(aIPD.xIP2(i, j),
+		aIPD.xIP2(i, j+1),
+		aIPD.xIP2(i+1, j+1),
+		M2);	
+      }
+    }
+  }	
+  //
+  M1.ResetAnd();
+  M2.ResetAnd();
+  //
+  int newind=0;
+  long unsigned Compt=0;
+  int ok=0;
+  int indicepointtraite = 0;
+  Standard_Integer k,nu,nv;
+  //
+  do { 
+    indicepointtraite--;
+    ok = M1.And(M2,newind);
+    if(ok) { 
+      IntegerGrille(newind,i,j,k);
+      int nb=0;
+      int LIM=3;
+      if(   DansGrille(i-1) && DansGrille(j-1) && DansGrille(k-1) 
+	 && DansGrille(i+1) && DansGrille(j+1) && DansGrille(k+1)) { 
+	int si,sj,sk;
+	for(si=-1; si<= 1 && nb<LIM; si++) { 
+	  for(sj=-1; sj<= 1 && nb<LIM; sj++) { 
+	    for(sk=-1; sk<= 1 && nb<LIM; sk++) { 
+	      long unsigned lu=GrilleInteger(i+si,j+sj,k+sk);
+	      if(M1.Val(lu) && M2.Val(lu)) { 
+		nb++;
+	      }
+	    }
+	  }
+	}
+	if(nb>=LIM) { 
+	  for(si=-1; si<= 1; si++) { 
+	    for(sj=-1; sj<= 1; sj++) { 
+	      for(sk=-1; sk<= 1; sk++) { 
+		if(si || sj || sk) { 
+		  long unsigned lu=GrilleInteger(i+si,j+sj,k+sk);
+		  M1.Raz(lu);
+		}
+	      }
+	    }
+	  }
+	}
       }
       //
-      const IntSurf_PntOn2S& aPSx=aL->Value(aIndx);
-      const IntSurf_PntOn2S& aPSq=aL->Value(aIndq);
-      //
-      aPSx.Parameters(ux[0], ux[1], ux[2], ux[3]);
-      aPSq.Parameters(uq[0], uq[1], uq[2], uq[3]);
+      gp_Pnt P(dx*i + x0, dy*j + y0, dz*k+z0);
       //
-      for (k=0; k<4; ++k) {
-	bIsNull=Standard_False;
-	bIsPeriod=Standard_False;
-	//
-	if (!bIsPeriodic[k]) {
-	  continue;
+      Standard_Integer nu1=-1,nu2=-1;
+      Standard_Integer nv1=0, nv2=0;
+      int nbsur1 = 0;
+      for(nu=0;nu1<0 && nu<SU1;nu++) { 
+	for(nv=0;nu1<0 && nv<SV1;nv++) { 
+	  if( aIPD.xIP1(nu, nv) ==(Standard_Integer) newind )  { 
+	    nbsur1++;
+	    aIPD.xIP1(nu, nv)=indicepointtraite;
+	    nu1=nu; nv1=nv;
+	  }
 	}
-	//
-	if (fabs(ux[k])<aEps) {
-	  bModified=Standard_True;
-	  bIsNull=Standard_True;
+      }
+      if(nu1>=0) { 
+	int nbsur2 = 0;
+	for(nu=0;nu2<0 && nu<SU2;nu++) { 
+	  for(nv=0;nu2<0 && nv<SV2;nv++) { 
+	    if( aIPD.xIP2(nu, nv)==(Standard_Integer) newind )  { 
+	      nbsur2++;
+	      aIPD.xIP2(nu, nv)=indicepointtraite;
+	      nu2=nu; nv2=nv;
+	    }
+	  }
 	}
-	//
-	else if (fabs(ux[k]-aPeriod[k])<aEps) {
-	  bModified=Standard_True;
-	  bIsPeriod=Standard_True;
+      }
+      if(nu1>=0 && nu2>=0) { 
+	IntSurf_PntOn2S POn2S;
+	POn2S.SetValue(P, 
+		       S1->FirstUParameter()+nu1*du1,
+		       S1->FirstVParameter()+nv1*dv1,
+		       S2->FirstUParameter()+nu2*du2,
+		       S2->FirstVParameter()+nv2*dv2);
+	LineOn2S->Add(POn2S);
+	Compt++;
+      }
+      else { 
+	//-- aucun point du triangle n a ete trouve assez proche
+	//-- on recherche les 3 points les plus proches de P 
+	//-- dans chacun des tableaux 
+	Standard_Real Dist3[3],u3[3],v3[3];
+	Dist3[0]=Dist3[1]=Dist3[2]=RealLast();
+	u3[0]=u3[1]=u3[2]=0;
+	v3[0]=v3[1]=v3[2]=0;
+	for(U=resu0,i=0; i<SU1; i++,U+=du1) { 
+	  for(V=resv0,j=0; j<SV1; V+=dv1,j++) {       
+	    //-- On place les 3 meilleures valeurs dans Dist1,Dist2,Dist3
+	    Standard_Real t = aIPD.xP1(i, j).SquareDistance(P);
+	    //-- On remplace la plus grande valeur ds Dist[.] par la val courante
+	    if(Dist3[0]<Dist3[1]) { 
+	      Standard_Real z;
+	      z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
+	      z=u3[0]; u3[0]=u3[1]; u3[1]=z;
+	      z=v3[0]; v3[0]=v3[1]; v3[1]=z;
+	    }
+	    if(Dist3[1]<Dist3[2]) { 
+	      Standard_Real z;
+	      z=Dist3[1]; Dist3[1]=Dist3[2]; Dist3[2]=z;
+	      z=u3[1]; u3[1]=u3[2]; u3[2]=z;
+	      z=v3[1]; v3[1]=v3[2]; v3[2]=z;
+	    }
+	    if(Dist3[0]<Dist3[1]) { 
+	      Standard_Real z;
+	      z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
+	      z=u3[0]; u3[0]=u3[1]; u3[1]=z;
+	      z=v3[0]; v3[0]=v3[1]; v3[1]=z;
+	    }
+	    //-- la plus grande valeur est dans Dist3[0]
+	    if(t<Dist3[0]) { 
+	      Dist3[0]=t; u3[0]=U; v3[0]=V;
+	    }
+	  }
 	}
 	//
-	if (bModified) {
-	  du=fabs(ux[k]-uq[k]);
-	  if (du > dPeriod[k]) {
-	    if(bIsNull){
-	      ux[k]=aPeriod[k];
+	Standard_Real U1_3 = (u3[0]+u3[1]+u3[2])/3.0;
+	Standard_Real V1_3 = (v3[0]+v3[1]+v3[2])/3.0;
+	
+	Dist3[0]=Dist3[1]=Dist3[2]=RealLast();
+	for(U=U0,i=0; i<SU2; i++,U+=du2) { 
+	  for(V=V0,j=0; j<SV2; V+=dv2,j++) {       
+	    //-- On place les 3 meilleures valeurs dans Dist1,Dist2,Dist3
+	    Standard_Real t = aIPD.xP2(i, j).SquareDistance(P);
+	    //-- On remplace la plus grande valeur ds Dist3[.] par la val courante
+	    if(Dist3[0]<Dist3[1]) { 
+	      Standard_Real z;
+	      z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
+	      z=u3[0]; u3[0]=u3[1]; u3[1]=z;
+	      z=v3[0]; v3[0]=v3[1]; v3[1]=z;
 	    }
-	    if(bIsPeriod) {
-	      ux[k]=0.;
+	    if(Dist3[1]<Dist3[2]) { 
+	      Standard_Real z;
+	      z=Dist3[1]; Dist3[1]=Dist3[2]; Dist3[2]=z;
+	      z=u3[1]; u3[1]=u3[2]; u3[2]=z;
+	      z=v3[1]; v3[1]=v3[2]; v3[2]=z;
+	    }
+	    if(Dist3[0]<Dist3[1]) { 
+	      Standard_Real z;
+	      z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
+	      z=u3[0]; u3[0]=u3[1]; u3[1]=z;
+	      z=v3[0]; v3[0]=v3[1]; v3[1]=z;
+	    }
+	    //-- la plus grande valeur est dans Dist3[0]
+	    if(t<Dist3[0]) { 
+	      Dist3[0]=t; u3[0]=U; v3[0]=V;
 	    }
 	  }
 	}
-      }//for (k=0; k<4; ++k) 
-      if (bModified) {
-	IntSurf_PntOn2S aPntOn2S;
 	//
-	aPntOn2S=aPSx;  
-	aPntOn2S.SetValue(ux[0], ux[1], ux[2], ux[3]);
-	aL->Value(aIndx, aPntOn2S);
+	Standard_Real U2_3 = (u3[0]+u3[1]+u3[2])/3.0;
+	Standard_Real V2_3 = (v3[0]+v3[1]+v3[2])/3.0;
+	//
+	IntSurf_PntOn2S POn2S;
+	POn2S.SetValue(P,U1_3,V1_3,U2_3,V2_3);
+	LineOn2S->Add(POn2S);
+	Compt++;	
       }
-    }//for (j=0; j<1; ++j) {
-  }//for (i=1; i<=aNbLines; ++i)
+    }
+  }
+  while(ok);
 }
-//xt
diff --git a/src/IntTools/IntTools_Context.cxx b/src/IntTools/IntTools_Context.cxx
index 75c0fa6..710c60a 100644
--- a/src/IntTools/IntTools_Context.cxx
+++ b/src/IntTools/IntTools_Context.cxx
@@ -108,8 +108,9 @@
 {
   Standard_Address anAdr;
   IntTools_FClass2d* pFClass2d;
- 
-  if (!myFClass2dMap.Contains(aF)) {
+  //
+  anAdr=myFClass2dMap.FindFromKey1(aF);
+  if (!anAdr) {
     Standard_Real aTolF;
     TopoDS_Face aFF=aF;
     aFF.Orientation(TopAbs_FORWARD);
@@ -122,8 +123,8 @@
   }
 
   else {
-    anAdr=myFClass2dMap.FindFromKey(aF);
-    pFClass2d=(IntTools_FClass2d*)anAdr;
+    Standard_Address *pAdr=(Standard_Address *)anAdr;
+    pFClass2d=(IntTools_FClass2d*)*pAdr;
   }
 
   return *pFClass2d;
@@ -136,8 +137,9 @@
 {
   Standard_Address anAdr;
   GeomAPI_ProjectPointOnSurf* pProjPS;
- 
-  if (!myProjPSMap.Contains(aF)) {
+  //
+  anAdr=myProjPSMap.FindFromKey1(aF);
+  if (!anAdr) {
     Standard_Real Umin, Usup, Vmin, Vsup, anEpsT=1.e-12 ;
     BRepAdaptor_Surface aBAS;
     //
@@ -157,8 +159,8 @@
   }
   
   else {
-    anAdr=myProjPSMap.FindFromKey(aF);
-    pProjPS=(GeomAPI_ProjectPointOnSurf*)anAdr;
+    Standard_Address *pAdr=(Standard_Address *)anAdr;
+    pProjPS=(GeomAPI_ProjectPointOnSurf*)*pAdr;
   }
   return *pProjPS;
 }
@@ -170,8 +172,9 @@
 {
   Standard_Address anAdr;
   GeomAPI_ProjectPointOnCurve* pProjPC;
- 
-  if (!myProjPCMap.Contains(aE)) {
+  //
+  anAdr=myProjPCMap.FindFromKey1(aE);
+  if (!anAdr) {
     Standard_Real f, l;
     //
     Handle(Geom_Curve)aC3D=BRep_Tool::Curve (aE, f, l);
@@ -182,10 +185,9 @@
     anAdr=(Standard_Address)pProjPC;
     myProjPCMap.Add(aE, anAdr);
   }
-  
   else {
-    anAdr=myProjPCMap.FindFromKey(aE);
-    pProjPC=(GeomAPI_ProjectPointOnCurve*)anAdr;
+    Standard_Address *pAdr=(Standard_Address *)anAdr;
+    pProjPC=(GeomAPI_ProjectPointOnCurve*)*pAdr;
   }
   return *pProjPC;
 }
@@ -198,8 +200,9 @@
 {
   Standard_Address anAdr;
   GeomAPI_ProjectPointOnCurve* pProjPT;
- 
-  if (!myProjPTMap.Contains(aC3D)) {
+  //
+  anAdr=myProjPTMap.FindFromKey1(aC3D);
+  if (!anAdr) {
     Standard_Real f, l;
     f=aC3D->FirstParameter();
     l=aC3D->LastParameter();
@@ -212,8 +215,8 @@
   }
   
   else {
-    anAdr=myProjPTMap.FindFromKey(aC3D);
-    pProjPT=(GeomAPI_ProjectPointOnCurve*)anAdr;
+    Standard_Address *pAdr=(Standard_Address *)anAdr;
+    pProjPT=(GeomAPI_ProjectPointOnCurve*)*pAdr;
   }
   return *pProjPT;
 }
@@ -225,8 +228,9 @@
 {
   Standard_Address anAdr;
   IntTools_SurfaceRangeLocalizeData* pSData;
- 
-  if (!myProjSDataMap.Contains(aF)) {
+  //
+  anAdr=myProjSDataMap.FindFromKey1(aF);
+  if (!anAdr) {
     //
     pSData=new IntTools_SurfaceRangeLocalizeData(3, 
 						 3, 
@@ -238,8 +242,8 @@
   }
   
   else {
-    anAdr=myProjSDataMap.FindFromKey(aF);
-    pSData=(IntTools_SurfaceRangeLocalizeData*)anAdr;
+    Standard_Address *pAdr=(Standard_Address *)anAdr;
+    pSData=(IntTools_SurfaceRangeLocalizeData*)*pAdr;
   }
   return *pSData;
 
@@ -252,24 +256,21 @@
 {
   Standard_Address anAdr;
   BRepClass3d_SolidClassifier* pSC;
- 
-  if (!mySClassMap.Contains(aSolid)) {
+  //
+  anAdr=mySClassMap.FindFromKey1(aSolid);
+  if (!anAdr) {
     //
     pSC=new BRepClass3d_SolidClassifier(aSolid);
     //
     anAdr=(Standard_Address)pSC;
     mySClassMap.Add(aSolid, anAdr);
   }
-  
   else {
-    anAdr=mySClassMap.FindFromKey(aSolid);
-    pSC =(BRepClass3d_SolidClassifier*)anAdr;
+    Standard_Address *pAdr=(Standard_Address *)anAdr;
+    pSC =(BRepClass3d_SolidClassifier*)*pAdr;
   }
   return *pSC;
 }
-
-
-//modified by NIZNHY-PKV Tue Feb  2 08:33:16 2010f
 //=======================================================================
 //function : ComputeVE
 //purpose  : 
@@ -302,9 +303,12 @@
   if (BRep_Tool::Degenerated(aE2)) {
     return -1;
   }
-  if (!BRep_Tool::IsGeometric(aE2)) { 
-    return -2;
-  }
+  //
+  //modified by NIZNHY-PKV Wed Jul 13 08:30:08 2011f
+  //if (!BRep_Tool::IsGeometric(aE2)) { 
+  //  return -2;
+  //}
+  //modified by NIZNHY-PKV Wed Jul 13 08:30:13 2011t
   //
   Standard_Real aTolV1, aTolE2, aTolSum, aTolVx;
   Standard_Integer aNbProj;
@@ -337,7 +341,6 @@
   //
   return 0;
 }
-//modified by NIZNHY-PKV Tue Feb  2 08:33:21 2010t
 //=======================================================================
 //function : ComputeVS
 //purpose  : 
diff --git a/src/IntTools/IntTools_EdgeEdge.cxx b/src/IntTools/IntTools_EdgeEdge.cxx
index 5d257e5..f86dafb 100644
--- a/src/IntTools/IntTools_EdgeEdge.cxx
+++ b/src/IntTools/IntTools_EdgeEdge.cxx
@@ -55,6 +55,7 @@
 #include <gp_Circ.hxx>
 #include <Extrema_ExtElC.hxx>
 #include <Extrema_POnCurv.hxx>
+#include <TopoDS_Iterator.hxx>
 
 //=======================================================================
 //function : IntTools_EdgeEdge::IntTools_EdgeEdge
@@ -516,11 +517,8 @@
   aCurveFrom->D0(t, aPFrom);
   
   Handle(Geom_Curve)aCurveTo=BRep_Tool::Curve (myCTo.Edge(), f, l);
-  //modified by NIZNHY-PKV Mon Jun  8 09:52:09 2009f
-  //aProjector.Init(aPFrom, aCurveTo, myTminTo, myTmaxTo);
   aProjector.Init(aCurveTo, myTminTo, myTmaxTo);
   aProjector.Perform(aPFrom);
-  //modified by NIZNHY-PKV Mon Jun  8 09:53:00 2009t
   aNbProj=aProjector.NbPoints();
   //
   if (myCTo.GetType()==GeomAbs_Circle) {
@@ -567,11 +565,8 @@
     }
   }
   
-  //modified by NIZNHY-PKV Mon Jun  8 09:54:19 2009f
-  //aProjector.Init(aPFrom, aCurveTo, myTminTo, myTmaxTo);
   aProjector.Init(aCurveTo, myTminTo, myTmaxTo);
   aProjector.Perform(aPFrom);
-  //modified by NIZNHY-PKV Mon Jun  8 09:55:11 2009t
   //
   Standard_Integer j, aNbPoints;
   //
@@ -585,11 +580,8 @@
       }
 	
       aCurveFrom->D0 (tt, aPFrom);
-      //modified by NIZNHY-PKV Mon Jun  8 09:54:52 2009f
-      //aProjector.Init(aPFrom, aCurveTo, myTminTo, myTmaxTo);
       aProjector.Init(aCurveTo, myTminTo, myTmaxTo);
       aProjector.Perform(aPFrom);
-      //modified by NIZNHY-PKV Mon Jun  8 09:55:07 2009t
       aNbPoints=aProjector.NbPoints();
       if (aNbPoints) {
 	break;
@@ -863,11 +855,8 @@
     }
   }
   //
-  //modified by NIZNHY-PKV Mon Jun  8 09:55:42 2009f
-  //aProjector.Init(aPm2, aCurveFrom, myTminFrom, myTmaxFrom);
   aProjector.Init(aCurveFrom, myTminFrom, myTmaxFrom);
   aProjector.Perform(aPm2);
-  //modified by NIZNHY-PKV Mon Jun  8 09:56:12 2009t
   Standard_Integer aNbPoints=aProjector.NbPoints();
   if (aNbPoints) { 
     Standard_Real aDD=aProjector.LowerDistance();
@@ -982,7 +971,6 @@
     }
   }
   //
-  //modified by NIZNHY-PKV Wed May 13 11:08:46 2009f
   if (aCT1==GeomAbs_Circle && aCT2==GeomAbs_Circle) {
     Standard_Boolean bIsDone, bIsParallel;
     Standard_Integer aNbExt;
@@ -1016,7 +1004,6 @@
       }
     }
   }
-  //modified by NIZNHY-PKV Wed May 13 11:08:51 2009t
   //
   // Prepare values of arguments for the interval [ta, tb]
   pri=IntTools::PrepareArgs (myCFrom, tb, ta, myDiscret, myDeflection, anArgs);
@@ -1133,11 +1120,8 @@
   gp_Pnt aP1;
   aCurveFrom->D0 (aT1, aP1);
   GeomAPI_ProjectPointOnCurve aProjector;
-  //modified by NIZNHY-PKV Mon Jun  8 09:56:53 2009f
-  //aProjector.Init(aP1, aCurveTo, myTminTo, myTmaxTo);
   aProjector.Init(aCurveTo, myTminTo, myTmaxTo);
   aProjector.Perform(aP1);
-  //modified by NIZNHY-PKV Mon Jun  8 09:57:12 2009t
   aNbPoints=aProjector.NbPoints();
   found=1;
   if (!aNbPoints) {
@@ -1149,11 +1133,8 @@
 	tt=aT1-myEpsT;
       }
       aCurveFrom->D0 (tt, aP1);
-      //modified by NIZNHY-PKV Mon Jun  8 09:57:34 2009f
-      //aProjector.Init(aP1, aCurveTo, myTminTo, myTmaxTo);
       aProjector.Init(aCurveTo, myTminTo, myTmaxTo);
       aProjector.Perform(aP1);
-      //modified by NIZNHY-PKV Mon Jun  8 09:57:51 2009t
       aNbPoints=aProjector.NbPoints();
       if (aNbPoints) {
 	found=1;
@@ -1456,12 +1437,9 @@
     if(!isfirst || !islast) {
       if(isfirst) {
 	aTx1 = aTF1;
-	//modified by NIZNHY-PKV Mon Jun  8 09:59:27 2009f
-	//GeomAPI_ProjectPointOnCurve aProjector(Curve1->Value(aTx1), Curve2, aTF2, aTL2);	
 	GeomAPI_ProjectPointOnCurve aProjector;
 	aProjector.Init(Curve2, aTF2, aTL2);
 	aProjector.Perform(Curve1->Value(aTx1));
-	//modified by NIZNHY-PKV Mon Jun  8 10:00:12 2009t
 	//
 	if(aProjector.NbPoints() > 0)
 	  aTx2 = aProjector.LowerDistanceParameter();
@@ -1476,12 +1454,9 @@
       
       if(islast) {
 	aTx1 = aTL1;
-	//modified by NIZNHY-PKV Mon Jun  8 10:00:24 2009f
-	//GeomAPI_ProjectPointOnCurve aProjector(Curve1->Value(aTx1), Curve2, aTF2, aTL2);
 	GeomAPI_ProjectPointOnCurve aProjector;
 	aProjector.Init(Curve2, aTF2, aTL2);
 	aProjector.Perform(Curve1->Value(aTx1));
-	//modified by NIZNHY-PKV Mon Jun  8 10:00:26 2009t
 	if(aProjector.NbPoints() > 0)
 	  aTx2 = aProjector.LowerDistanceParameter();
 	else {
@@ -1587,11 +1562,8 @@
   GeomAPI_ProjectPointOnCurve aProjector;
   Standard_Real aMidPar, aMidDist;   
   aMidPar = (aTF1 + aTL1) * 0.5;  
-  //modified by NIZNHY-PKV Mon Jun  8 10:01:32 2009f
-  //aProjector.Init(Curve1->Value(aMidPar), Curve2, aTF2, aTL2);
   aProjector.Init(Curve2, aTF2, aTL2);
   aProjector.Perform(Curve1->Value(aMidPar));
-  //modified by NIZNHY-PKV Mon Jun  8 10:02:09 2009t
   if(aProjector.NbPoints() > 0) {
     aMidDist=aProjector.LowerDistance();
     if(aMidDist * aMidDist < aDist2 || !istouch) {
@@ -1675,13 +1647,17 @@
 //=======================================================================
   void IntTools_EdgeEdge::ComputeLineLine()
 {
-  Standard_Real Tolang2 = 1.e-16; 
-  Standard_Real Tol2 = myCriteria*myCriteria; 
-  Standard_Boolean IsParallel = Standard_False, IsCoincide = Standard_False;
-  myIsDone = Standard_True;
-
+  Standard_Boolean IsParallel, IsCoincide;
+  Standard_Real Tolang2, Tol2;
   gp_Pnt P11, P12, P21, P22;
-
+  //
+  myIsDone = Standard_True;
+  //
+  IsParallel = Standard_False;
+  IsCoincide = Standard_False;
+  Tolang2 = 1.e-16;
+  Tol2 = myCriteria*myCriteria; 
+  //
   gp_Lin C1 = myCFrom.Line();
   gp_Lin C2 = myCTo.Line();
   const gp_Dir& D1 = C1.Position().Direction();
@@ -1756,7 +1732,26 @@
   if(IsParallel) {
     return;
   }
-
+  //
+  //modified by NIZNHY-PKV Tue Mar 29 08:29:14 2011f
+  {
+    TopoDS_Iterator aIt1, aIt2;
+    //
+    aIt1.Initialize(myEdge1);
+    for (; aIt1.More(); aIt1.Next()) {
+      const TopoDS_Shape& aV1=aIt1.Value();
+      aIt2.Initialize(myEdge2);
+      for (; aIt2.More(); aIt2.Next()) {
+	const TopoDS_Shape& aV2=aIt2.Value();
+	if (aV2.IsSame(aV1)) {
+	  // the two straight lines have commpn vertex
+	  return;
+	}
+      }
+    }
+  }
+  //modified by NIZNHY-PKV Tue Mar 29 08:29:16 2011t
+  //
   Standard_Real aSin2 = 1. - aCos*aCos;
   gp_Pnt O1 = C1.Location();
   gp_Pnt O2 = C2.Location();
@@ -1779,7 +1774,7 @@
   if(d2 > Tol2) {
     return;
   }
-
+  //
   IntTools_CommonPrt aCommonPrt;
   aCommonPrt.SetEdge1(myCFrom.Edge());
   aCommonPrt.SetEdge2(myCTo.Edge());
diff --git a/src/IntTools/IntTools_FaceFace.cdl b/src/IntTools/IntTools_FaceFace.cdl
index 5129d8c..59b4fd4 100644
--- a/src/IntTools/IntTools_FaceFace.cdl
+++ b/src/IntTools/IntTools_FaceFace.cdl
@@ -101,14 +101,18 @@ is
     	returns Boolean from Standard; 
 	---Purpose:
 	--- Returns True if faces are tangent
-	---
-
-    PrepareLines3D (me:out);
+	--- 
+    --modified by NIZNHY-PKV Fri Sep 16 07:44:22 2011	
+    PrepareLines3D (me:out; 
+    	    bToSplit: Boolean from Standard=Standard_True);
+    --PrepareLines3D (me:out);
     	---Purpose: 
-    	--- Provides post-processing the result lines,
-	--- which includes spliting closed curves.
-	---
-    --amv
+    	--- Provides post-processing the result lines. 
+        --- <bToSplit> - the flag.    		     
+    	--  In case of <bToSplit> is true the closed 3D-curves will be splitted  
+        --  on parts. 
+        --  In case of <bToSplit> is false the closed 3D-curves remain untouched.  
+    
     SetList (me: in out; ListOfPnts: in out ListOfPntOn2S from IntSurf);
     
     ----------------------------------------------------------
@@ -119,10 +123,8 @@ is
     	                  D2      : TopolTool from Adaptor3d)
 	is protected; 
 	
-    --modified by NIZNHY-PKV Tue Jul 10 10:01:27 2007f
     ComputeTolReached3d(me:out) 
     	is  protected; 
-    --modified by NIZNHY-PKV Tue Jul 10 10:01:30 2007t	
 
 fields 
  
diff --git a/src/IntTools/IntTools_FaceFace.cxx b/src/IntTools/IntTools_FaceFace.cxx
index 5ee3e8d..a53d105 100644
--- a/src/IntTools/IntTools_FaceFace.cxx
+++ b/src/IntTools/IntTools_FaceFace.cxx
@@ -267,13 +267,12 @@ static
 		  Standard_Real& aUVMaxStep,
 		  Standard_Real& aDeflection);
 
-//modified by NIZNHY-PKV Tue Feb 15 10:16:05 2011f
 static
   Standard_Boolean SortTypes(const GeomAbs_SurfaceType aType1,
 			     const GeomAbs_SurfaceType aType2);
 static
   Standard_Integer IndexType(const GeomAbs_SurfaceType aType);
-//modified by NIZNHY-PKV Tue Feb 15 10:16:09 2011t
+
 //
 //=======================================================================
 //function : 
@@ -415,7 +414,6 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
   aType1=aBAS1.GetType();
   aType2=aBAS2.GetType();
   //
-  //modified by NIZNHY-PKV Tue Feb 15 10:34:39 2011f
   bReverse=SortTypes(aType1, aType2);
   if (bReverse) {
     myFace1=aF2;
@@ -435,7 +433,6 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
       }
     }
   }
-  //modified by NIZNHY-PKV Tue Feb 15 10:34:45 2011t
   //
   S1=BRep_Tool::Surface(myFace1);
   S2=BRep_Tool::Surface(myFace2);
@@ -480,7 +477,7 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
       myTolReached3d=aTolFMax;
     }
     myTolReached2d = myTolReached3d;
-    //modified by NIZNHY-PKV Tue Feb 15 10:33:42 2011f
+    //
     if (bReverse) {
       Handle(Geom2d_Curve) aC2D1, aC2D2;
       //
@@ -494,7 +491,6 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
 	aIC.SetSecondCurve2d(aC2D1);
       }
     }
-    //modified by NIZNHY-PKV Tue Feb 15 10:33:46 2011t
     return;
   }//if(aType1==GeomAbs_Plane && aType2==GeomAbs_Plane){
   //
@@ -637,7 +633,6 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
     //
     ComputeTolReached3d();
     //
-    //modified by NIZNHY-PKV Tue Feb 15 14:13:25 2011f
     if (bReverse) {
       Handle(Geom2d_Curve) aC2D1, aC2D2;
       //
@@ -651,7 +646,6 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
 	aIC.SetSecondCurve2d(aC2D1);
       }
     }
-    //modified by NIZNHY-PKV Tue Feb 15 14:13:29 2011t
     //
     // Points
     Standard_Real U1,V1,U2,V2;
@@ -665,7 +659,7 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
       aISPnt.Parameters(U1,V1,U2,V2);
       aPntOnF1.Init(myFace1, aPnt, U1, V1);
       aPntOnF2.Init(myFace2, aPnt, U2, V2);
-      //modified by NIZNHY-PKV Tue Feb 15 10:34:10 2011f
+      //
       if (!bReverse) {
 	aPntOn2Faces.SetP1(aPntOnF1);
 	aPntOn2Faces.SetP2(aPntOnF2);
@@ -674,9 +668,6 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
 	aPntOn2Faces.SetP2(aPntOnF1);
 	aPntOn2Faces.SetP1(aPntOnF2);
       }
-      //aPntOn2Faces.SetP1(aPntOnF1);
-      //aPntOn2Faces.SetP2(aPntOnF2);
-      //modified by NIZNHY-PKV Tue Feb 15 10:34:14 2011t
       myPnts.Append(aPntOn2Faces);
     }
     //
@@ -738,7 +729,6 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
     }
   }
   //t
-
   //IFV Bug OCC20297 
   if((aType1 == GeomAbs_Cylinder && aType2 == GeomAbs_Plane) ||
      (aType2 == GeomAbs_Cylinder && aType1 == GeomAbs_Plane)) {
@@ -773,7 +763,6 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
   } // aType1 == GeomAbs_Cylinder && aType2 == GeomAbs_Plane) ...
   //End IFV Bug OCC20297
   //
-  //modified by NIZNHY-PKV Mon Feb 14 12:02:46 2011f
   if ((aType1==GeomAbs_Plane && aType2==GeomAbs_Torus) ||
       (aType2==GeomAbs_Plane && aType1==GeomAbs_Torus)) {
     aNbLin=mySeqOfCurve.Length();
@@ -832,7 +821,98 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
       myTolReached3d=1.1*myTolReached3d;
     }
   }// if ((aType1==GeomAbs_Plane && aType2==GeomAbs_Torus) ||
-  //modified by NIZNHY-PKV Mon Feb 14 12:02:49 2011t
+  //
+  if ((aType1==GeomAbs_SurfaceOfRevolution && aType2==GeomAbs_Cylinder) ||
+      (aType2==GeomAbs_SurfaceOfRevolution && aType1==GeomAbs_Cylinder)) {
+    Standard_Boolean bIsDone;
+    Standard_Integer i, j, aNbP;
+    Standard_Real aT, aT1, aT2, dT, aU1, aV1, aU2, aV2;
+    Standard_Real aDSmax, aDS1, aDS2, aDS;
+    gp_Pnt2d aP2D1, aP2D2;
+    gp_Pnt aP3D, aP3D1, aP3D2;
+    IntTools_Context aCtx;
+    //
+    aNbLin=mySeqOfCurve.Length();
+    aDSmax=-1.;
+    aNbP=11;
+    //
+    for (i=1; i<=aNbLin; ++i) {
+      const IntTools_Curve& aIC=mySeqOfCurve(i);
+      const Handle(Geom_Curve)& aC3D=aIC.Curve();
+      const Handle(Geom2d_Curve)& aC2D1=aIC.FirstCurve2d();
+      const Handle(Geom2d_Curve)& aC2D2=aIC.SecondCurve2d();
+      //
+      if (aC3D.IsNull()) {
+	continue;
+      }
+      const Handle(Geom_BSplineCurve)& aBC=Handle(Geom_BSplineCurve)::DownCast(aC3D);
+      if (aBC.IsNull()) {
+	return;
+      }
+      //
+      aT1=aBC->FirstParameter();
+      aT2=aBC->LastParameter();
+      //
+      dT=(aT2-aT1)/(aNbP-1);
+      for (j=0; j<aNbP; ++j) {
+	aT=aT1+j*dT;
+	if (j==aNbP-1) {
+	  aT=aT2;
+	}
+	//
+	aC3D->D0(aT, aP3D);
+	// 1
+	if (!aC2D1.IsNull()) {
+	  aC2D1->D0(aT, aP2D1);
+	  aP2D1.Coord(aU1, aV1);
+	  myHS1->D0(aU1, aV1, aP3D1);
+	  aDS1=aP3D.SquareDistance(aP3D1);
+	  if (aDS1>aDSmax) {
+	    aDSmax=aDS1;
+	  }
+	}
+	// 2
+	if (!aC2D2.IsNull()) {
+	  aC2D2->D0(aT, aP2D2);
+	  aP2D2.Coord(aU2, aV2);
+	  myHS2->D0(aU2, aV2, aP3D2);
+	  aDS2=aP3D.SquareDistance(aP3D2);
+	  if (aDS2>aDSmax) {
+	    aDSmax=aDS2;
+	  }
+	}
+	// 3
+	GeomAPI_ProjectPointOnSurf& aPPS1=aCtx.ProjPS(myFace1);
+	aPPS1.Perform(aP3D);
+	bIsDone=aPPS1.IsDone();
+	if (bIsDone) {
+	  aPPS1.LowerDistanceParameters(aU1, aV1);
+	  myHS1->D0(aU1, aV1, aP3D1);
+	  aDS1=aP3D.SquareDistance(aP3D1);
+	  if (aDS1>aDSmax) {
+	    aDSmax=aDS1;
+	  }
+	}
+	// 4
+	GeomAPI_ProjectPointOnSurf& aPPS2=aCtx.ProjPS(myFace2);
+	aPPS2.Perform(aP3D);
+	bIsDone=aPPS2.IsDone();
+	if (bIsDone) {
+	  aPPS2.LowerDistanceParameters(aU2, aV2);
+	  myHS2->D0(aU2, aV2, aP3D2);
+	  aDS2=aP3D.SquareDistance(aP3D2);
+	  if (aDS2>aDSmax) {
+	    aDSmax=aDS2;
+	  }
+	}
+      }//for (j=0; j<aNbP; ++j) {
+    }//for (i=1; i<=aNbLin; ++i) {
+    //
+    aDS=myTolReached3d*myTolReached3d;
+    if (aDSmax > aDS) {
+      myTolReached3d=sqrt(aDSmax);
+    }
+  }//if((aType1==GeomAbs_SurfaceOfRevolution ...
 }
 //=======================================================================
 //function : MakeCurve
@@ -2135,59 +2215,57 @@ Handle(Geom2d_BSplineCurve) MakeBSpline2d(const Handle(IntPatch_WLine)& theWLine
 
   return new Geom2d_BSplineCurve(poles,knots,mults,1);
 }
+//modified by NIZNHY-PKV Fri Sep 16 07:57:30 2011f
 //=======================================================================
 //function : PrepareLines3D
 //purpose  : 
 //=======================================================================
-  void IntTools_FaceFace::PrepareLines3D()
+  void IntTools_FaceFace::PrepareLines3D(const Standard_Boolean bToSplit)
 {
-  Standard_Integer i, aNbCurves, j, aNbNewCurves;
+  Standard_Integer i, aNbCurves;
+  GeomAbs_SurfaceType aType1, aType2;
   IntTools_SequenceOfCurves aNewCvs;
-
   //
-  // 1. Treatment of periodic and closed  curves
+  // 1. Treatment closed  curves
   aNbCurves=mySeqOfCurve.Length();
-  for (i=1; i<=aNbCurves; i++) {
+  for (i=1; i<=aNbCurves; ++i) {
     const IntTools_Curve& aIC=mySeqOfCurve(i);
-    // DEBUG
-    // const Handle(Geom_Curve)&   aC3D =aIC.Curve();
-    // const Handle(Geom2d_Curve)& aC2D1=aIC.FirstCurve2d();
-    // const Handle(Geom2d_Curve)& aC2D2=aIC.SecondCurve2d();
     //
-    IntTools_SequenceOfCurves aSeqCvs;
-    aNbNewCurves=IntTools_Tools::SplitCurve(aIC, aSeqCvs);
-    
-    if (aNbNewCurves) {
-      for (j=1; j<=aNbNewCurves; j++) {
-	const IntTools_Curve& aICNew=aSeqCvs(j);
-	aNewCvs.Append(aICNew);
+    if (bToSplit) {
+      Standard_Integer j, aNbC;
+      IntTools_SequenceOfCurves aSeqCvs;
+      //
+      aNbC=IntTools_Tools::SplitCurve(aIC, aSeqCvs);
+      if (aNbC) {
+	for (j=1; j<=aNbC; ++j) {
+	  const IntTools_Curve& aICNew=aSeqCvs(j);
+	  aNewCvs.Append(aICNew);
+	}
+      }
+      else {
+	aNewCvs.Append(aIC);
       }
     }
-    //
     else {
       aNewCvs.Append(aIC);
     }
   }
   //
   // 2. Plane\Cone intersection when we had 4 curves
-  GeomAbs_SurfaceType aType1, aType2;
-  BRepAdaptor_Surface aBS1, aBS2;
-  
-  aBS1.Initialize(myFace1);
-  aType1=aBS1.GetType();
-  
-  aBS2.Initialize(myFace2);
-  aType2=aBS2.GetType();
-  
+  aType1=myHS1->GetType();
+  aType2=myHS2->GetType();
+  aNbCurves=aNewCvs.Length();
+  //
   if ((aType1==GeomAbs_Plane && aType2==GeomAbs_Cone) ||
       (aType2==GeomAbs_Plane && aType1==GeomAbs_Cone)) {
-    aNbCurves=aNewCvs.Length();
     if (aNbCurves==4) {
-      GeomAbs_CurveType aCType1=aNewCvs(1).Type();
+      GeomAbs_CurveType aCType1;
+      //
+      aCType1=aNewCvs(1).Type();
       if (aCType1==GeomAbs_Line) {
 	IntTools_SequenceOfCurves aSeqIn, aSeqOut;
 	//
-	for (i=1; i<=aNbCurves; i++) {
+	for (i=1; i<=aNbCurves; ++i) {
 	  const IntTools_Curve& aIC=aNewCvs(i);
 	  aSeqIn.Append(aIC);
 	}
@@ -2196,26 +2274,23 @@ Handle(Geom2d_BSplineCurve) MakeBSpline2d(const Handle(IntPatch_WLine)& theWLine
 	//
 	aNewCvs.Clear();
 	aNbCurves=aSeqOut.Length(); 
-	for (i=1; i<=aNbCurves; i++) {
+	for (i=1; i<=aNbCurves; ++i) {
 	  const IntTools_Curve& aIC=aSeqOut(i);
 	  aNewCvs.Append(aIC);
 	}
-	//
       }
     }
-  }// end of if ((aType1==GeomAbs_Plane && ...
+  }// if ((aType1==GeomAbs_Plane && aType2==GeomAbs_Cone)...
   //
   // 3. Fill  mySeqOfCurve
   mySeqOfCurve.Clear();
   aNbCurves=aNewCvs.Length();
-  for (i=1; i<=aNbCurves; i++) {
+  for (i=1; i<=aNbCurves; ++i) {
     const IntTools_Curve& aIC=aNewCvs(i);
     mySeqOfCurve.Append(aIC);
   }
-
 }
-
-
+//modified by NIZNHY-PKV Fri Sep 16 07:57:32 2011t
 //=======================================================================
 //function : CorrectSurfaceBoundaries
 //purpose  : 
@@ -2835,8 +2910,12 @@ Standard_Boolean FindPoint(const gp_Pnt2d&     theFirstPoint,
       if ( bIsOut )
 	acurvec.Reverse();
 
-      if((aVec.Dot(acurvec) > 0.) &&
-	 (aVec.Angle(acurvec) < Precision::PConfusion())) {
+      Standard_Real aDotX, anAngleX;
+      //
+      aDotX = aVec.Dot(acurvec);
+      anAngleX = aVec.Angle(acurvec);
+      //
+      if(aDotX > 0. && fabs(anAngleX) < Precision::PConfusion()) {
 	if((i % 2) == 0) {
 	  if((acurpoint.Y() >= theVmin) &&
 	     (acurpoint.Y() <= theVmax)) {
@@ -3462,7 +3541,7 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine,
 
 	if(nbboundaries == 2) {
 	  //xf
-	  //bComputeLineEnd = Standard_True;
+	  bComputeLineEnd = Standard_True;
 	  //xt
 	}
 	else if(nbboundaries == 1) {
@@ -4378,7 +4457,6 @@ void Tolerances(const Handle(GeomAdaptor_HSurface)& aHS1,
     }
   }
 }
-//modified by NIZNHY-PKV Tue Feb 15 10:15:31 2011f
 //=======================================================================
 //function : SortTypes
 //purpose  : 
@@ -4443,4 +4521,3 @@ Standard_Integer IndexType(const GeomAbs_SurfaceType aType)
   } 
   return aIndex;
 }
-//modified by NIZNHY-PKV Tue Feb 15 10:15:39 2011t
diff --git a/src/IntTools/IntTools_Tools.cxx b/src/IntTools/IntTools_Tools.cxx
index ea9bec1..d416fc9 100644
--- a/src/IntTools/IntTools_Tools.cxx
+++ b/src/IntTools/IntTools_Tools.cxx
@@ -83,25 +83,34 @@ static
 //=======================================================================
   Standard_Boolean IntTools_Tools::IsClosed (const Handle(Geom_Curve)& aC3D)
 {
-  
-  Standard_Real aF, aL, aDist;
+  Standard_Boolean bRet;
+  Standard_Real aF, aL, aDist, aPC;
   gp_Pnt aP1, aP2;
-   
+  
   Handle (Geom_BoundedCurve) aGBC=
       Handle (Geom_BoundedCurve)::DownCast(aC3D);
   if (aGBC.IsNull()) {
     return Standard_False;
   }
-
+  
   aF=aC3D->FirstParameter();
   aL=aC3D-> LastParameter();
   
   aC3D->D0(aF, aP1);
   aC3D->D0(aL, aP2);
 
-  aDist=aP1.Distance(aP2);
-  //return (aDist < 1.e-12); 
-  return (aDist < Precision::Confusion()); 
+  
+  //
+  //modified by NIZNHY-PKV Mon Jul 04 11:58:23 2011f
+  aPC=Precision::Confusion();
+  aPC=aPC*aPC;
+  aDist=aP1.SquareDistance(aP2);
+  bRet=aDist<aPC;
+  return bRet;
+  //
+  //aDist=aP1.Distance(aP2);
+  //return (aDist < Precision::Confusion()); 
+  //modified by NIZNHY-PKV Mon Jul 04 11:59:50 2011t
 }
 
 //=======================================================================
@@ -218,7 +227,6 @@ static
   aF=aC3D->FirstParameter();
   aL=aC3D->LastParameter();
   aMid=0.5*(aF+aL);
-  //modified by NIZNHY-PKV Thu Feb  5 08:26:58 2009 f
   GeomAdaptor_Curve aGAC(aC3D);
   GeomAbs_CurveType aCT=aGAC.GetType();
   if (aCT==GeomAbs_BSplineCurve ||
@@ -226,7 +234,6 @@ static
     //aMid=0.5*aMid;
     aMid=IntTools_Tools::IntermediatePoint(aF, aL);
   }
-  //modified by NIZNHY-PKV Thu Feb  5 08:27:00 2009 t
   //
   Handle(Geom_Curve) aC3DNewF, aC3DNewL;
   aC3DNewF =new Geom_TrimmedCurve  (aC3D, aF, aMid);
@@ -278,20 +285,26 @@ static
 					     const Standard_Real aTolPV,
 					     const TopoDS_Vertex& aV)
 {
+  Standard_Boolean bRet;
   Standard_Real aTolV, aD, dTol;
   gp_Pnt aPv; 
   
   aTolV=BRep_Tool::Tolerance(aV);
   //
-  //modified by NIZNHY-PKV Thu Jan 18 17:44:46 2007f
-  //aTolV=aTolV+aTolPV;
   dTol=Precision::Confusion();
   aTolV=aTolV+aTolPV+dTol;
-  //modified by NIZNHY-PKV Thu Jan 18 17:44:49 2007t
   //
   aPv=BRep_Tool::Pnt(aV);
-  aD=aPv.Distance(aP);
-  return (aD<=aTolV);
+  //
+  //modified by NIZNHY-PKV Mon Jul 04 12:00:37 2011f
+  aD=aPv.SquareDistance(aP);
+  aTolV=aTolV*aTolV;
+  bRet=(aD<=aTolV);
+  return bRet;
+  //
+  //aD=aPv.Distance(aP);
+  //return (aD<=aTolV);
+  //modified by NIZNHY-PKV Mon Jul 04 12:00:40 2011t
 }
 
 
@@ -390,11 +403,14 @@ static
   aTolV1=BRep_Tool::Tolerance(aV1);
   aTolV2=BRep_Tool::Tolerance(aV2);
   aTolSum=aTolV1+aTolV2;
-
+  
   aP1=BRep_Tool::Pnt(aV1);
   aP2=BRep_Tool::Pnt(aV2);
-  
-  d=aP1.Distance(aP2);
+  //modified by NIZNHY-PKV Mon Jul 04 11:55:52 2011f
+  aTolSum=aTolSum*aTolSum;
+  d=aP1.SquareDistance(aP2);
+  //d=aP1.Distance(aP2);
+  //modified by NIZNHY-PKV Mon Jul 04 11:55:53 2011t
   if (d<aTolSum) {
     return 0;
   }
@@ -442,7 +458,8 @@ static
 						       const TopoDS_Edge& aE2)
 						       
 {
-  Standard_Real f1, l1, m1, f2, l2, m2, aTol1, aTol2, aSumTol;
+  Standard_Boolean bRet;
+  Standard_Real f1, l1, m1, f2, l2, m2, aTol1, aTol2, aSumTol, aD2;
   gp_Pnt aP1, aP2;
 
   aTol1=BRep_Tool::Tolerance(aE1);
@@ -456,11 +473,17 @@ static
   C2->D0(m2, aP2);
 
   aSumTol=aTol1+aTol2;
-  
-  if (aP1.Distance(aP2) < aSumTol) {
-    return Standard_True;
-  }
-  return Standard_False;
+  //modified by NIZNHY-PKV Mon Jul 04 12:02:20 2011f
+  aSumTol=aSumTol*aSumTol;
+  aD2=aP1.SquareDistance(aP2);
+  bRet=aD2<aSumTol;
+  return bRet;
+  //
+  //if (aP1.Distance(aP2) < aSumTol) {
+  //  return Standard_True;
+  //}
+  //return Standard_False;
+  //modified by NIZNHY-PKV Mon Jul 04 12:02:24 2011t
 }
 
 //=======================================================================
diff --git a/src/MeshTest/MeshTest_CheckTopology.cxx b/src/MeshTest/MeshTest_CheckTopology.cxx
index 7627fce..e26d381 100644
--- a/src/MeshTest/MeshTest_CheckTopology.cxx
+++ b/src/MeshTest/MeshTest_CheckTopology.cxx
@@ -24,7 +24,7 @@
 //purpose  : Performs checking
 //=======================================================================
 
-void MeshTest_CheckTopology::Perform ()
+void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
 {
   TopTools_IndexedMapOfShape aMapF;
   TopTools_IndexedDataMapOfShapeListOfShape aMapEF;
@@ -107,7 +107,7 @@ void MeshTest_CheckTopology::Perform ()
     TopLoc_Location aLoc;
     Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
     if (aT.IsNull()) {
-      cout<< "face "<<iF<<" has no triangulation"<<endl;
+      di << "face " <<iF <<" has no triangulation" << "\n";
       continue;
     }
 
diff --git a/src/MeshTest/MeshTest_PluginCommands.cxx b/src/MeshTest/MeshTest_PluginCommands.cxx
index 3c67d00..6d5d20b 100644
--- a/src/MeshTest/MeshTest_PluginCommands.cxx
+++ b/src/MeshTest/MeshTest_PluginCommands.cxx
@@ -11,6 +11,7 @@
 #include <TColStd_MapIteratorOfMapOfAsciiString.hxx>
 #include <BRepMesh_FactoryError.hxx>
 #include <BRepMesh_DiscretRoot.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
 #include <Bnd_Box.hxx>
 #include <BRepMesh_PDiscretRoot.hxx>
 #include <DBRep.hxx>
@@ -37,6 +38,7 @@ static Standard_Integer mpsetfunctionname (Draw_Interpretor& , Standard_Integer
 static Standard_Integer mpgetfunctionname (Draw_Interpretor& , Standard_Integer , const char** );
 static Standard_Integer mperror           (Draw_Interpretor& , Standard_Integer , const char** );
 static Standard_Integer mpincmesh         (Draw_Interpretor& , Standard_Integer , const char** );
+static Standard_Integer mpparallel        (Draw_Interpretor& , Standard_Integer , const char** );
 static Standard_Integer triarea           (Draw_Interpretor& , Standard_Integer , const char** );
 static Standard_Integer tricheck          (Draw_Interpretor& , Standard_Integer , const char** );
 
@@ -61,6 +63,8 @@ void MeshTest::PluginCommands(Draw_Interpretor& theCommands)
   theCommands.Add("mpgetfunctionname", "use mpgetfunctionname", __FILE__, mpgetfunctionname     , g);
   theCommands.Add("mperror"          , "use mperror"          , __FILE__, mperror     , g);
   theCommands.Add("mpincmesh"        , "use mpincmesh"        , __FILE__, mpincmesh      , g);
+  theCommands.Add("mpparallel"       , "mpparallel [toTurnOn] : show / set multi-threading flag for incremental mesh",
+    __FILE__, mpparallel, g);
   theCommands.Add("triarea","shape [eps]  (computes triangles and surface area)",__FILE__, triarea, g);
   theCommands.Add("tricheck", "shape   (checks triangulation of shape)", __FILE__, tricheck, g);
   
@@ -111,8 +115,10 @@ static Standard_Integer mpsetdefaultname (Draw_Interpretor& , Standard_Integer n
   //
   aName=a[1];
   //
-  BRepMesh_DiscretFactory::Get().SetDefaultName(aName);
-  printf(" *ready\n");
+  if (BRepMesh_DiscretFactory::Get().SetDefaultName (aName))
+    printf(" *ready\n");
+  else
+    printf(" *fault\n");
   //
   return 0;
 }
@@ -147,8 +153,10 @@ static Standard_Integer mpsetfunctionname (Draw_Interpretor& , Standard_Integer
   //
   aName=a[1];
   //
-  BRepMesh_DiscretFactory::Get().SetFunctionName(aName);
-  printf(" *ready\n");
+  if (BRepMesh_DiscretFactory::Get().SetFunctionName (aName))
+    printf(" *ready\n");
+  else
+    printf(" *fault\n");
   //
   return 0;
 }
@@ -193,11 +201,8 @@ static Standard_Integer mperror (Draw_Interpretor& , Standard_Integer n, const c
 //=======================================================================
 static Standard_Integer mpincmesh (Draw_Interpretor& , Standard_Integer n, const char** a)
 {
-  Standard_Boolean bIsDone;
   Standard_Real aDeflection, aAngle;
   TopoDS_Shape aS;
-  BRepMesh_FactoryError aErr;
-  BRepMesh_PDiscretRoot pAlgo;
   //
   if (n<3) {
     printf(" use mpincmesh s deflection [angle]\n");
@@ -216,23 +221,25 @@ static Standard_Integer mpincmesh (Draw_Interpretor& , Standard_Integer n, const
     aAngle=atof(a[3]);
   }
   //
-  pAlgo=BRepMesh_DiscretFactory::Get().Discret(aS,
-					       aDeflection,
-					       aAngle); 
+  Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (aS,
+                                                                                   aDeflection,
+                                                                                   aAngle);
   //
-  aErr=BRepMesh_DiscretFactory::Get().ErrorStatus();
-  if (aErr!=BRepMesh_FE_NOERROR) {
+  BRepMesh_FactoryError aErr = BRepMesh_DiscretFactory::Get().ErrorStatus();
+  if (aErr != BRepMesh_FE_NOERROR)
+  {
     printf(" *Factory::Get().ErrorStatus()=%d\n", (int)aErr);
   }
   //
-  if (!pAlgo) {
+  if (aMeshAlgo.IsNull())
+  {
     printf(" *Can not create the algo\n");
     return 0;
   }
   //
-  pAlgo->Perform();
-  bIsDone=pAlgo->IsDone();
-  if (!bIsDone) {
+  aMeshAlgo->Perform();
+  if (!aMeshAlgo->IsDone())
+  {
     printf(" *Not done\n");
   }
   //
@@ -304,7 +311,7 @@ static Standard_Integer triarea (Draw_Interpretor& di, int n, const char ** a)
     BRepGProp::SurfaceProperties(shape, props, anEps);
   double aGeomArea = props.Mass();
 
-  di << aTriArea << " " << aGeomArea << " ";
+  di << aTriArea << " " << aGeomArea << "\n";
   return 0;
 }
 
@@ -322,7 +329,7 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
 
   // execute check
   MeshTest_CheckTopology aCheck(shape);
-  aCheck.Perform();
+  aCheck.Perform(di);
 
   // dump info on free links inside the triangulation
   Standard_Integer nbFree = 0;
@@ -332,7 +339,7 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
       Standard_Integer nbEdge = aCheck.NbFreeLinks(k);
       Standard_Integer iF = aCheck.GetFaceNumWithFL(k);
       nbFree += nbEdge;
-      cout<<"free links of face "<<iF<<endl;
+      di << "free links of face " << iF << "\n";
       const TopoDS_Face& aFace = TopoDS::Face(aMapF.FindKey(iF));
       TopLoc_Location aLoc;
       Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
@@ -344,7 +351,7 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
       for (i=1; i <= nbEdge; i++) {
         Standard_Integer n1, n2;
         aCheck.GetFreeLink(k, i, n1, n2);
-        cout<<"{"<<n1<<" "<<n2<<"} ";
+        di << "{" << n1 << " " << n2 << "} ";
         pnts(1) = aPoints(n1).Transformed(trsf);
         pnts(2) = aPoints(n2).Transformed(trsf);
         Handle(Poly_Polygon3D) poly = new Poly_Polygon3D (pnts);
@@ -358,44 +365,44 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
         DrawTrSurf::Set (name, pnts2d(1));
         DrawTrSurf::Set (name, pnts2d(2));
       }
-      cout<<endl;
+      di << "\n";
     }
   }
 
   // dump info on cross face errors
   Standard_Integer nbErr = aCheck.NbCrossFaceErrors();
   if (nbErr > 0) {
-    cout<<"cross face errors: {face1, node1, face2, node2, distance}"<<endl;
+    di << "cross face errors: {face1, node1, face2, node2, distance}" << "\n";
     for (i=1; i <= nbErr; i++) {
       Standard_Integer iF1, n1, iF2, n2;
       Standard_Real aVal;
       aCheck.GetCrossFaceError(i, iF1, n1, iF2, n2, aVal);
-      cout<<"{"<<iF1<<" "<<n1<<" "<<iF2<<" "<<n2<<" "<<aVal<<"} ";
+      di << "{" << iF1 << " " << n1 << " " << iF2 << " " << n2 << " " << aVal << "} ";
     }
-    cout<<endl;
+    di << "\n";
   }
 
   // dump info on edges
   Standard_Integer nbAsync = aCheck.NbAsyncEdges();
   if (nbAsync > 0) {
-    cout<<"async edges:"<<endl;
+    di << "async edges:" << "\n";
     for (i=1; i <= nbAsync; i++) {
       Standard_Integer ie = aCheck.GetAsyncEdgeNum(i);
-      cout<<ie<<" ";
+      di << ie << " ";
     }
-    cout<<endl;
+    di << "\n";
   }
 
   // dump info on free nodes
   Standard_Integer nbFreeNodes = aCheck.NbFreeNodes();
   if (nbFreeNodes > 0) {
-    cout << "free nodes (in pairs: face / node): " << endl;
+    di << "free nodes (in pairs: face / node): " << "\n";
     for (i=1; i <= nbFreeNodes; i++) {
       Standard_Integer iface, inode;
       aCheck.GetFreeNodeNum(i, iface, inode);
-      cout << "{" << iface << " " << inode << "} ";
+      di << "{" << iface << " " << inode << "} ";
     }
-    cout << endl;
+    di << "\n";
   }
 
   // output errors summary to DRAW
@@ -403,6 +410,22 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
     di << "Free_links " << nbFree
        << " Cross_face_errors " << nbErr
        << " Async_edges " << nbAsync 
-       << " Free_nodes " << nbFreeNodes << " ";
+       << " Free_nodes " << nbFreeNodes << "\n";
+  return 0;
+}
+
+//=======================================================================
+//function : mpparallel
+//purpose  :
+//=======================================================================
+static int mpparallel (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+  if (argc == 2)
+  {
+    Standard_Boolean isParallelOn = atoi (argv[1]) == 1;
+    BRepMesh_IncrementalMesh::SetParallelDefault (isParallelOn);
+  }
+  std::cout << "Incremental Mesh, multi-threading "
+            << (BRepMesh_IncrementalMesh::IsParallelDefault() ? "ON\n" : "OFF\n");
   return 0;
 }
diff --git a/src/NCollection/FILES b/src/NCollection/FILES
index 799d7ec..71f73fe 100644
--- a/src/NCollection/FILES
+++ b/src/NCollection/FILES
@@ -77,3 +77,5 @@ NCollection_Handle.cxx
 
 NCollection_Comparator.hxx
 NCollection_QuickSort.hxx
+
+NCollection_Haft.h
diff --git a/src/NCollection/NCollection_Comparator.hxx b/src/NCollection/NCollection_Comparator.hxx
deleted file mode 100644
index 17040f7..0000000
--- a/src/NCollection/NCollection_Comparator.hxx
+++ /dev/null
@@ -1,69 +0,0 @@
-// File       NCollection_Comparator.hxx
-// Created    27 January 2011
-// Author     KGV
-// Copyright  OpenCASCADE 2011
-
-#ifndef _NCollection_Comparator_HeaderFile
-#define _NCollection_Comparator_HeaderFile
-
-#include <Precision.hxx>
-
-/**
- * Class to define basic compare operations.
- * Basic implementation use redirection to standard C++ operators.
- * You can use standard C++ templates mechanisms to redefine these methods
- * or to inherit basic implementation to create multiple comparators
- * for same type with different rules.
- */
-template<class TheItemType>
-class NCollection_Comparator
-{
-public:
-
-  NCollection_Comparator (const Standard_Real theTolerance = Precision::Confusion())
-  : myTolerance (theTolerance) {}
-
-  virtual ~NCollection_Comparator() {}
-
-public:
-  //! Comparison functions which should be overridden
-  //! if standard operators are not defined for user type.
-
-  //! Should return true if Left value is greater than Right
-  virtual Standard_Boolean IsGreater (const TheItemType& theLeft, const TheItemType& theRight) const
-  {
-    return theLeft > theRight;
-  }
-
-  //! Should return true if values are equal
-  virtual Standard_Boolean IsEqual (const TheItemType& theLeft, const TheItemType& theRight) const
-  {
-    return theLeft == theRight;
-  }
-
-public:
-  //! Comparison functions which may be overridden for performance reasons
-
-  //! Should return true if Left value is lower than Right
-  virtual Standard_Boolean IsLower (const TheItemType& theLeft, const TheItemType& theRight) const
-  {
-    return !IsGreater (theLeft, theRight) && !IsEqual (theLeft, theRight);
-  }
-
-  virtual Standard_Boolean IsLowerEqual (const TheItemType& theLeft, const TheItemType& theRight) const
-  {
-    return !IsGreater (theLeft, theRight);
-  }
-
-  virtual Standard_Boolean IsGreaterEqual (const TheItemType& theLeft, const TheItemType& theRight) const
-  {
-    return IsGreater (theLeft, theRight) || IsEqual (theLeft, theRight);
-  }
-
-protected:
-
-  Standard_Real myTolerance;
-
-};
-
-#endif /*_NCollection_Comparator_HeaderFile*/
diff --git a/src/NCollection/NCollection_IncAllocator.cxx b/src/NCollection/NCollection_IncAllocator.cxx
index 3283b72..425414a 100644
--- a/src/NCollection/NCollection_IncAllocator.cxx
+++ b/src/NCollection/NCollection_IncAllocator.cxx
@@ -23,9 +23,22 @@
 IMPLEMENT_STANDARD_HANDLE  (NCollection_IncAllocator,NCollection_BaseAllocator)
 IMPLEMENT_STANDARD_RTTIEXT (NCollection_IncAllocator,NCollection_BaseAllocator)
 
-#define IMEM_SIZE(_size) ((((_size) - 1)/sizeof(aligned_t)) + 1)
-#define IMEM_FREE(p_bl) ((unsigned int)(p_bl->p_end_block - p_bl->p_free_space))
-#define IMEM_ALIGN(_addr) (sizeof(aligned_t)* IMEM_SIZE((unsigned long)(_addr)))
+namespace
+{
+
+  inline size_t IMEM_SIZE (const size_t theSize)
+  {
+    return (theSize - 1) / sizeof(NCollection_IncAllocator::aligned_t) + 1;
+  }
+
+  inline size_t IMEM_ALIGN (const void* theAddress)
+  {
+    return sizeof(NCollection_IncAllocator::aligned_t) * IMEM_SIZE (size_t(theAddress));
+  }
+
+  #define IMEM_FREE(p_bl) (size_t(p_bl->p_end_block - p_bl->p_free_space))
+
+};
 
 #define MaxLookup 16
 
diff --git a/src/NCollection/NCollection_QuickSort.hxx b/src/NCollection/NCollection_QuickSort.hxx
deleted file mode 100644
index c6b5f6d..0000000
--- a/src/NCollection/NCollection_QuickSort.hxx
+++ /dev/null
@@ -1,97 +0,0 @@
-// File       NCollection_QuickSort.hxx
-// Created    27 January 2011
-// Author     KGV
-// Copyright  OpenCASCADE 2011
-
-#ifndef _NCollection_QuickSort_HeaderFile
-#define _NCollection_QuickSort_HeaderFile
-
-#include <NCollection_Comparator.hxx>
-#include <Standard_Integer.hxx>
-
-/**
- * Perform sorting of enumerable collection with QuickSort algorithm.
- * Enumerable collection should provide the random access to its values
- * by index number with methods Value(theId) and ChangeValue(theId).
- * Currently it supposed to be used with NCollection_Sequence and NCollection_Vector.
- *
- * Usage sample:
- *   // input sequence
- *   NCollection_Sequence<Standard_Real> aSequence;
- *   // perform sorting for the whole sequence.
- *   NCollection_QuickSort<NCollection_Sequence<Standard_Real>, Standard_Real>
- *     ::Perform (aSequence, NCollection_Comparator<Standard_Real>(),
- *                1, aSequence.Size());
- */
-template<class TheCollType, class TheItemType>
-class NCollection_QuickSort
-{
-public:
-
-  //! Main entry call to perform sorting
-  static void Perform (TheCollType& theEnumColl,
-                       const NCollection_Comparator<TheItemType>& theComparator,
-                       const Standard_Integer theLower,
-                       const Standard_Integer theUpper)
-  {
-    if (theLower < theUpper)
-    {
-      Standard_Integer aPivotPosition = Partition (theEnumColl, theComparator,
-                                                   theLower, theUpper);
-      if (theLower < aPivotPosition)
-      {
-        // recursive call
-        Perform (theEnumColl, theComparator,
-                 theLower, aPivotPosition - 1);
-      }
-      // recursive call
-      Perform (theEnumColl, theComparator,
-               aPivotPosition + 1, theUpper);
-    }
-  }
-
-private:
-
-  //! Auxiliary function
-  static void SwapValues (TheItemType& x, TheItemType& y)
-  {
-    TheItemType aCopy = x;
-    x = y;
-    y = aCopy;
-  }
-
-  static Standard_Integer Partition (TheCollType& theEnumColl,
-                                     const NCollection_Comparator<TheItemType>& theComparator,
-                                     const Standard_Integer theLower,
-                                     const Standard_Integer theUpper)
-  {
-    Standard_Integer anIdLeft (theLower), anIdRight (theUpper);
-    const TheItemType aPivot = theEnumColl.Value (theLower);
-
-    while (anIdLeft < anIdRight)
-    {
-      while (theComparator.IsGreater (theEnumColl.Value (anIdRight), aPivot))
-      {
-        --anIdRight;
-      }
-      while ((anIdLeft < anIdRight) &&
-             theComparator.IsLowerEqual (theEnumColl.Value (anIdLeft), aPivot))
-      {
-        ++anIdLeft;
-      }
-
-      if (anIdLeft < anIdRight)
-      {
-        SwapValues (theEnumColl.ChangeValue (anIdLeft),
-                    theEnumColl.ChangeValue (anIdRight));
-      }
-    }
-
-    theEnumColl.ChangeValue (theLower) = theEnumColl.Value (anIdRight);
-    theEnumColl.ChangeValue (anIdRight) = aPivot;
-    return anIdRight;
-  }
-
-};
-
-#endif /*_NCollection_QuickSort_HeaderFile*/
diff --git a/src/NIS/NIS_Allocator.hxx b/src/NIS/NIS_Allocator.hxx
deleted file mode 100644
index 927be4b..0000000
--- a/src/NIS/NIS_Allocator.hxx
+++ /dev/null
@@ -1,76 +0,0 @@
-// File:      NIS_Allocator.h
-// Created:   22.10.10 17:22
-// Author:    Alexander GRIGORIEV
-// Copyright: Open Cascade 2010
-
-
-#ifndef NIS_Allocator_HeaderFile
-#define NIS_Allocator_HeaderFile
-
-#include <NCollection_IncAllocator.hxx>
-
-/**
- * Subclass of Incremental Allocator. It is aware of the total
- * allocated and released memory. Used in NIS_Interactive context as
- * private allocator that manages all memory used by interactive objects.
- */
-
-class NIS_Allocator : public NCollection_IncAllocator
-{
- public:
-  // ---------- PUBLIC METHODS ----------
-
-
-  /**
-   * Constructor.
-   */
-  Standard_EXPORT NIS_Allocator (const size_t theBlockSize = 24600);
-
-  /**
-   * Query the total number of allocated bytes
-   */
-  inline Standard_Size  NAllocated      () const
-  {
-    return myNAllocated;
-  }
-
-  /**
-   * Query the total number of released bytes
-   */
-  inline Standard_Size  NFreed          () const
-  {
-    return myNFreed;
-  }
-
-  /**
-   * Set both counters to zero. Should be called with method Reset of the base
-   * class NCollection_IncAlocator.
-   */
-  Standard_EXPORT void ResetCounters   ();
-
-  /**
-   * Allocate memory with given size. Returns NULL on failure
-   */
-  Standard_EXPORT virtual void* Allocate        (const size_t size);
-
-  /*
-   * Free a previously allocated memory. Does nothing but count released bytes.
-   */
-  Standard_EXPORT virtual void  Free            (void *anAddress);
-
- private:
-  // ---------- PRIVATE FIELDS ----------
-
-  Standard_Size         myNAllocated;
-  Standard_Size         myNFreed;
-
- public:
-// Declaration of CASCADE RTTI
-DEFINE_STANDARD_RTTI (NIS_Allocator)
-};
-
-// Definition of HANDLE object using Standard_DefineHandle.hxx
-DEFINE_STANDARD_HANDLE (NIS_Allocator, NCollection_IncAllocator)
-
-
-#endif
diff --git a/src/NIS/NIS_View.cxx b/src/NIS/NIS_View.cxx
index 02c0943..874de84 100644
--- a/src/NIS/NIS_View.cxx
+++ b/src/NIS/NIS_View.cxx
@@ -262,8 +262,16 @@ void NIS_View::GetBndBox( Standard_Integer& theXMin, Standard_Integer& theXMax,
 
 int NIS_View::MyCallback (Aspect_Drawable                /* Window ID */,
                           void*                          ptrData, 
-                          Aspect_GraphicCallbackStruct*  /* call data */)
+                          Aspect_GraphicCallbackStruct*  callData /* call data */)
 {
+  // Avoid multiple rendering of the scene ( accordingly with update of
+  // callback mechanism, that invokes additional callbacks before
+  // underlay and overlay redrawing with OCC_PRE_REDRAW and OCC_PRE_OVERLAY
+  // bits added to the "reason" value of the callback data structure;
+  // see comments to OCC_REDRAW_ADDITIONAL_CALLBACKS definition )
+  if (callData->reason & OCC_REDRAW_ADDITIONAL_CALLBACKS)
+    return 0;
+  
   const Handle(NIS_View) thisView (static_cast<NIS_View *> (ptrData));
   NCollection_List<NIS_InteractiveContext *>::Iterator anIter;
 #ifdef CLIP
diff --git a/src/OSD/OSD_MAllocHook.cxx b/src/OSD/OSD_MAllocHook.cxx
index 96a32cc..ef41e0d 100644
--- a/src/OSD/OSD_MAllocHook.cxx
+++ b/src/OSD/OSD_MAllocHook.cxx
@@ -10,11 +10,11 @@
 #define __STDC_LIMIT_MACROS
 #endif
 #include <stdint.h>
-#include <stdlib.h>
 #endif
 
 #include <set>
 #include <map>
+#include <cstdlib>
 
 #ifndef SIZE_MAX
 #define SIZE_MAX UINT_MAX
diff --git a/src/OSD/OSD_MAllocHook.hxx b/src/OSD/OSD_MAllocHook.hxx
deleted file mode 100644
index 4edd59b..0000000
--- a/src/OSD/OSD_MAllocHook.hxx
+++ /dev/null
@@ -1,156 +0,0 @@
-// File:	OSD_MAllocHook.hxx
-// Created:	03.02.2011
-// Author:	Mikhail SAZONOV
-// Copyright:	Open CASCADE S.A.S. 2011
-
-#ifndef _OSD_MAllocHook_HeaderFile
-#define _OSD_MAllocHook_HeaderFile
-
-#include <Standard_TypeDef.hxx>
-#include <Standard_Mutex.hxx>
-#include <stdio.h>
-
-/**
- * This class provides the possibility to set callback for memory
- * allocation/deallocation.
- * On MS Windows, it works only in Debug builds. It relies on the
- * debug CRT function _CrtSetAllocHook (see MSDN for help).
- */
-class OSD_MAllocHook
-{
-public:
-  /**
-   * Interface of a class that should handle allocation/deallocation events
-   */
-  class Callback
-  {
-  public:
-    //! Allocation event handler
-    /**
-     * It is called when allocation is done
-     * @param theSize
-     *   the size of the memory block in bytes
-     * @param theRequestNum
-     *   the allocation order number of the memory block
-     */
-    virtual void AllocEvent
-                   (size_t      theSize,
-                    long        theRequestNum) = 0;
-
-    //! Freeing event handler
-    /**
-     * It is called when the block is freed
-     * @param theData
-     *   the pointer to the user data section of the memory block
-     * @param theSize
-     *   the size of the memory block in bytes
-     * @param theRequestNum
-     *   the allocation order number of the memory block
-     */
-    virtual void FreeEvent
-                   (void*       theData,
-                    size_t      theSize,
-                    long        theRequestNum) = 0;
-  };
-
-  /**
-   * Implementation of the handler that collects all events
-   * to the log file. It contains the method to generate the report
-   * from the log file.
-   */
-  class LogFileHandler: public Callback
-  {
-  public:
-    //! Constructor
-    Standard_EXPORT LogFileHandler();
-
-    //! Destructor
-    Standard_EXPORT ~LogFileHandler();
-
-    //! Create the file and start collecting events.
-    //! Return false if the file with the given name cannot be created.
-    Standard_EXPORT Standard_Boolean Open(const char* theFileName);
-
-    //! Close the file and stop collecting events
-    Standard_EXPORT void Close();
-
-    //! Make synthesized report on the given log file.
-    /**
-     * Generate an easy to use report in the
-     * new file with the given name, taking the given log file as input.
-     * If theIncludeAlive is true then
-     * include into the report the alive allocation numbers.
-     */
-    Standard_EXPORT static Standard_Boolean MakeReport
-                   (const char* theLogFile,
-                    const char* theOutFile,
-                    const Standard_Boolean theIncludeAlive = Standard_False);
-
-    Standard_EXPORT virtual void AllocEvent(size_t, long);
-    Standard_EXPORT virtual void FreeEvent(void*, size_t, long);
-
-  private:
-    FILE*          myLogFile;
-    Standard_Mutex myMutex;
-    size_t         myBreakSize;
-  };
-
-  /**
-   * Implementation of the handler that collects numbers of
-   * allocations/deallocations for each block size directly in the memory.
-   */
-  class CollectBySize: public Callback
-  {
-  public:
-    //! Constructor
-    Standard_EXPORT CollectBySize();
-
-    //! Destructor
-    Standard_EXPORT ~CollectBySize();
-
-    //! Reset the buffer and start collecting events.
-    Standard_EXPORT void Reset();
-
-    //! Write report in the given file.
-    Standard_EXPORT Standard_Boolean MakeReport(const char* theOutFile);
-
-    Standard_EXPORT virtual void AllocEvent(size_t, long);
-    Standard_EXPORT virtual void FreeEvent(void*, size_t, long);
-
-  private:
-    struct Numbers
-    {
-      int nbAlloc;
-      int nbFree;
-      int nbLeftPeak;
-      Numbers() : nbAlloc(0), nbFree(0), nbLeftPeak(0) {}
-    };
-
-    Standard_Mutex myMutex;
-    Numbers*       myArray;
-    size_t         myTotalLeftSize;
-    size_t         myTotalPeakSize;
-    size_t         myBreakSize;
-  };
-
-  //! Set handler of allocation/deallocation events
-  /**
-   * You can pass here any implementation. For easy start, you can try
-   * with the predefined handler LogFileHandler, which static instance 
-   * is returned by GetLogFileHandler().
-   * To clear the handler, pass NULL here.
-   */
-  Standard_EXPORT static void SetCallback
-                   (Callback* theCB);
-
-  //! Get current handler of allocation/deallocation events
-  Standard_EXPORT static Callback* GetCallback();
-
-  //! Get static instance of LogFileHandler handler
-  Standard_EXPORT static LogFileHandler* GetLogFileHandler();
-
-  //! Get static instance of CollectBySize handler
-  Standard_EXPORT static CollectBySize* GetCollectBySize();
-};
-
-#endif /* _OSD_MAllocHook_HeaderFile */
diff --git a/src/OpenGl/FILES b/src/OpenGl/FILES
index 8dcd730..fbbb96b 100644
--- a/src/OpenGl/FILES
+++ b/src/OpenGl/FILES
@@ -247,3 +247,5 @@ OpenGl_ResourceVBO.cxx
 OpenGl_ResourceVBO.hxx
 OpenGl_ResourceTexture.cxx
 OpenGl_ResourceTexture.hxx
+OpenGl_PrinterContext.cxx
+OpenGl_PrinterContext.hxx
diff --git a/src/OpenGl/OpenGl_FontMgr.cxx b/src/OpenGl/OpenGl_FontMgr.cxx
index 9842cac..c030c43 100644
--- a/src/OpenGl/OpenGl_FontMgr.cxx
+++ b/src/OpenGl/OpenGl_FontMgr.cxx
@@ -316,8 +316,8 @@ int OpenGl_FontMgr::request_font( const Handle(TCollection_HAsciiString)& fontNa
   return -1;
 }
 
-void OpenGl_FontMgr::render_text( const Standard_Integer id, const char* text,
-				  const Standard_Boolean is2d )
+void OpenGl_FontMgr::render_text( const Standard_Integer id, const wchar_t* text,
+                                  const Standard_Boolean is2d )
 {
 #ifdef TRACE
   cout << "TKOpenGl::render_text\n"
@@ -355,28 +355,30 @@ void OpenGl_FontMgr::render_text( const Standard_Integer id, const char* text,
 
 }
 
-void OpenGl_FontMgr::render_text( const char* text, const Standard_Boolean is2d ){
+void OpenGl_FontMgr::render_text ( const wchar_t* text, const Standard_Boolean is2d )
+{
   render_text( _CurrentFontId, text, is2d );
 }
 
-
-const FTFont* OpenGl_FontMgr::fontById( const Standard_Integer id ){
+const FTFont* OpenGl_FontMgr::fontById (const Standard_Integer id)
+{
   return _FontCache.IsBound( id ) ? _FontCache.Find( id ).Font: NULL;
 }
 
-Standard_ShortReal OpenGl_FontMgr::computeWidth( const Standard_Integer id, const char* str ){
+Standard_ShortReal OpenGl_FontMgr::computeWidth( const Standard_Integer id, const wchar_t* text )
+{
   if( !_FontCache.IsBound( id ) )
     return 0.f;
 
   OGLFont_Cache cache = _FontCache.Find( id );
 
-  Standard_ShortReal w = cache.Font->Advance( str );
+  Standard_ShortReal w = cache.Font->Advance( text );
 
   return w;
 }
 
-void OpenGl_FontMgr::setCurrentScale( const Standard_ShortReal xScale,
-                                     const Standard_ShortReal yScale)
+void OpenGl_FontMgr::setCurrentScale (const Standard_ShortReal xScale,
+                                      const Standard_ShortReal yScale)
 {
   _XCurrentScale = xScale;
   _YCurrentScale = yScale;
@@ -389,7 +391,8 @@ void OpenGl_FontMgr::setCurrentScale( const Standard_ShortReal xScale,
 #include <Image_ColorImage.hxx>
 #include <Quantity_Color.hxx>
 
-void dump_texture( int id) {
+void dump_texture( int id)
+{
   Handle(AlienImage_BMPAlienData) image = new AlienImage_BMPAlienData();
 
   if (!glIsTexture(id))
diff --git a/src/OpenGl/OpenGl_GraphicDriver.cdl b/src/OpenGl/OpenGl_GraphicDriver.cdl
index 4d76a7c..9f59be9 100644
--- a/src/OpenGl/OpenGl_GraphicDriver.cdl
+++ b/src/OpenGl/OpenGl_GraphicDriver.cdl
@@ -49,6 +49,7 @@ uses
     TypeOfTriedronPosition  from Aspect,
     Handle              from Aspect,
     Display             from Aspect,
+    PrintAlgo           from Aspect,
 
     AspectLine3d        from Graphic3d,
     AspectMarker3d      from Graphic3d,
@@ -904,138 +905,9 @@ is
     ---Category: Graduated trihedron
     --------------------------------
 
-    GetGraduatedTrihedron(me;
-                          view : CView from Graphic3d;
-                          -- Names of axes --
-                          xname : out CString from Standard;
-                          yname : out CString from Standard;
-                          zname : out CString from Standard;
-                          -- Draw names --
-                          xdrawname : out Boolean from Standard;
-                          ydrawname : out Boolean from Standard;
-                          zdrawname : out Boolean from Standard;
-                          -- Draw values --
-                          xdrawvalues : out Boolean from Standard;
-                          ydrawvalues : out Boolean from Standard;
-                          zdrawvalues : out Boolean from Standard;
-                          -- Draw grid --
-                          drawgrid : out Boolean from Standard;
-                          -- Draw axes --
-                          drawaxes : out Boolean from Standard;
-                          -- Number of splits along axes --
-                          nbx : out Integer from Standard;
-                          nby : out Integer from Standard;
-                          nbz : out Integer from Standard;
-                          -- Offset for drawing values --
-                          xoffset : out Integer from Standard;
-                          yoffset : out Integer from Standard;
-                          zoffset : out Integer from Standard;
-                          -- Offset for drawing names of axes --
-                          xaxisoffset : out Integer from Standard;
-                          yaxisoffset : out Integer from Standard;
-                          zaxisoffset : out Integer from Standard;
-                          -- Draw tickmarks --
-                          xdrawtickmarks : out Boolean from Standard;
-                          ydrawtickmarks : out Boolean from Standard;
-                          zdrawtickmarks : out Boolean from Standard;
-                          -- Length of tickmarks --
-                          xtickmarklength : out Integer from Standard;
-                          ytickmarklength : out Integer from Standard;
-                          ztickmarklength : out Integer from Standard;
-                          -- Grid color --
-                          gridcolor : out Color from Quantity;
-                          -- X name color --
-                          xnamecolor : out Color from Quantity;
-                          -- Y name color --
-                          ynamecolor : out Color from Quantity;
-                          -- Z name color --
-                          znamecolor : out Color from Quantity;
-                          -- X color of axis and values --
-                          xcolor : out Color from Quantity;
-                          -- Y color of axis and values --
-                          ycolor : out Color from Quantity;
-                          -- Z color of axis and values --
-                          zcolor : out Color from Quantity;
-                          -- Name of font for names of axes --
-                          fontOfNames : out CString from Standard;
-                          -- Style of names of axes --
-                          styleOfNames : out FontAspect from OSD;
-                          -- Size of names of axes --
-                          sizeOfNames : out Integer from Standard;
-                          -- Name of font for values --
-                          fontOfValues : out CString from Standard;
-                          -- Style of values --
-                          styleOfValues : out FontAspect from OSD;
-                          -- Size of values --
-                          sizeOfValues : out Integer from Standard)
-    ---Purpose: call_togl_graduatedtrihedron_get
-    is redefined static;
-
     GraduatedTrihedronDisplay(me : mutable;
                               view : CView from Graphic3d;
-                              cubic : in out CGraduatedTrihedron from Graphic3d;
-                              -- Names of axes --
-                              xname : CString from Standard;
-                              yname : CString from Standard;
-                              zname : CString from Standard;
-                              -- Draw names --
-                              xdrawname : Boolean from Standard;
-                              ydrawname : Boolean from Standard;
-                              zdrawname : Boolean from Standard;
-                              -- Draw values --
-                              xdrawvalues : Boolean from Standard;
-                              ydrawvalues : Boolean from Standard;
-                              zdrawvalues : Boolean from Standard;
-                              -- Draw grid --
-                              drawgrid : Boolean from Standard;
-                              -- Draw axes --
-                              drawaxes : Boolean from Standard;
-                              -- Number of splits along axes --
-                              nbx : Integer from Standard;
-                              nby : Integer from Standard;
-                              nbz : Integer from Standard;
-                              -- Offset for drawing values --
-                              xoffset : Integer from Standard;
-                              yoffset : Integer from Standard;
-                              zoffset : Integer from Standard;
-                              -- Offset for drawing names of axes --
-                              xaxisoffset : Integer from Standard;
-                              yaxisoffset : Integer from Standard;
-                              zaxisoffset : Integer from Standard;
-                              -- Draw tickmarks --
-                              xdrawtickmarks : Boolean from Standard;
-                              ydrawtickmarks : Boolean from Standard;
-                              zdrawtickmarks : Boolean from Standard;
-                              -- Length of tickmarks --
-                              xtickmarklength : Integer from Standard;
-                              ytickmarklength : Integer from Standard;
-                              ztickmarklength : Integer from Standard;
-                              -- Grid color --
-                              gridcolor : Color from Quantity;
-                              -- X name color --
-                              xnamecolor : Color from Quantity;
-                              -- Y name color --
-                              ynamecolor : Color from Quantity;
-                              -- Z name color --
-                              znamecolor : Color from Quantity;
-                              -- X color of axis and values --
-                              xcolor : Color from Quantity;
-                              -- Y color of axis and values --
-                              ycolor : Color from Quantity;
-                              -- Z color of axis and values --
-                              zcolor : Color from Quantity;
-                              -- Name of font for names of axes --
-                              fontOfNames : CString from Standard;
-                              -- Style of names of axes --
-                              styleOfNames : FontAspect from OSD;
-                              -- Size of names of axes --
-                              sizeOfNames : Integer from Standard;
-                              -- Name of font for values --
-                              fontOfValues : CString from Standard;
-                              -- Style of values --
-                              styleOfValues : FontAspect from OSD;
-                              -- Size of values --
-                              sizeOfValues : Integer from Standard)
+                              cubic : CGraduatedTrihedron from Graphic3d)
     ---Purpose: call_togl_graduatedtrihedron_display
     is redefined static;
 
@@ -1337,8 +1209,10 @@ is
              ACOverLayer     : CLayer2d from Aspect;
              hPrnDC          : Handle from Aspect;
              showBackground  : Boolean;
-             filename        : CString)
-        is redefined static;
+             filename        : CString;
+             printAlgorithm  : PrintAlgo from Aspect = Aspect_PA_STRETCH;
+             theScaleFactor  : Real from Standard = 1.0 ) 
+        returns Boolean from Standard is redefined static;
       ---Level: Internal
       ---Purpose: print the contents of all layers of the view to the printer.
     -- <hPrnDC> : Pass the PrinterDeviceContext (HDC),
@@ -1346,6 +1220,17 @@ is
     -- (background is white)
       -- else set to TRUE for printing with current background color.
     -- <filename>: If != NULL, then the view will be printed to a file.
+    -- <printAlgorithm>: Select print algorithm: stretch, tile.
+    -- <theScaleFactor>: Scaling coefficient, used internally to scale the
+    -- printings accordingly to the scale factor selected in the printer 
+    -- properties dialog.
+    -- Returns Standard_True if the data is passed to the printer, otherwise
+    -- Standard_False if the print operation failed due to the printer errors, 
+    -- or lack of system memory. This might be related to insufficient memory
+    -- or some internal errors. All this errors are indicated by the message 
+    -- boxes (on level of OpenGl_GraphicDriver).
+    -- Warning: This function can reuse FBO assigned to the view
+    -- Please take it into account if you use it for your purposes;
     ---Warning: Works only under Windows.
 
 
@@ -1431,4 +1316,13 @@ is
     --            returns Standard_False if fails
     --  ABD Integration support of system fonts (using FTGL and FreeType)
 
+        RemovePrimitiveArray( me        : mutable;
+                              theCGroup : CGroup from Graphic3d;
+                              thePArray : PrimitiveArray from Graphic3d )
+        is redefined static;
+        ---Purpose: Clear visualization data in graphical driver and
+        -- stop displaying the primitives array of the graphical group
+        -- <theCGroup>. This method is internal and should be used
+        -- by Graphic3d_Group only.
+
 end GraphicDriver from OpenGl;
diff --git a/src/OpenGl/OpenGl_GraphicDriver_710.cxx b/src/OpenGl/OpenGl_GraphicDriver_710.cxx
index 6ca8647..e7dcf09 100644
--- a/src/OpenGl/OpenGl_GraphicDriver_710.cxx
+++ b/src/OpenGl/OpenGl_GraphicDriver_710.cxx
@@ -43,35 +43,11 @@ void OpenGl_GraphicDriver::Text
  const Graphic3d_TextPath ATp,
  const Graphic3d_HorizontalTextAlignment AHta,
  const Graphic3d_VerticalTextAlignment AVta,
- const Standard_Boolean 
+ const Standard_Boolean EvalMinMax
  ) 
 {
-
-
-  Graphic3d_CGroup MyCGroup = ACGroup;
-
-  Standard_Real X, Y, Z;
-
-  CALL_DEF_TEXT atext;
-  APoint.Coord (X, Y, Z);
-  atext.Position.x  = float (X);
-  atext.Position.y  = float (Y);
-  atext.Position.z  = float (Z);
-  atext.Height      = float (AHeight);
-  if (atext.Height < 0)
-    atext.Height = DefaultTextHeight();
-  atext.Angle       = float (AAngle);
-  atext.Path        = int (ATp);
-  atext.HAlign      = int (AHta);
-  atext.VAlign      = int (AVta);
-  atext.string      = (char *) AText;
-
-  if (MyTraceLevel) {
-    PrintFunction ("call_togl_text");
-    PrintCGroup (MyCGroup, 1);
-  }
-  call_togl_text (&MyCGroup, &atext);
-
+  TCollection_ExtendedString TheText(AText);
+  OpenGl_GraphicDriver::Text(ACGroup,TheText,APoint,AHeight,AAngle,ATp,AHta,AVta,EvalMinMax);
 }
 
 void OpenGl_GraphicDriver::Text 
@@ -80,35 +56,11 @@ void OpenGl_GraphicDriver::Text
  const Standard_CString AText, 
  const Graphic3d_Vertex& APoint, 
  const Standard_Real AHeight, 
- const Standard_Boolean 
+ const Standard_Boolean EvalMinMax
  ) 
 {
-
-
-  Graphic3d_CGroup MyCGroup = ACGroup;
-
-  Standard_Real X, Y, Z;
-
-  CALL_DEF_TEXT atext;
-  APoint.Coord (X, Y, Z);
-  atext.Position.x  = float (X);
-  atext.Position.y  = float (Y);
-  atext.Position.z  = float (Z);
-  atext.Height    = float (AHeight);
-  if (atext.Height < 0)
-    atext.Height = DefaultTextHeight();
-  atext.Angle   = float (Standard_PI / 2.);
-  atext.Path    = int (Graphic3d_TP_RIGHT);
-  atext.HAlign    = int (Graphic3d_HTA_LEFT);
-  atext.VAlign    = int (Graphic3d_VTA_BOTTOM);
-  atext.string    = (char *) AText;
-
-  if (MyTraceLevel) {
-    PrintFunction ("call_togl_text");
-    PrintCGroup (MyCGroup, 1);
-  }
-  call_togl_text (&MyCGroup, &atext);
-
+  TCollection_ExtendedString TheText(AText);
+  OpenGl_GraphicDriver::Text(ACGroup,TheText,APoint,AHeight,EvalMinMax);
 }
 
 void OpenGl_GraphicDriver::Text 
@@ -124,14 +76,11 @@ void OpenGl_GraphicDriver::Text
  const Standard_Boolean 
  ) 
 {
-
-
   Graphic3d_CGroup MyCGroup = ACGroup;
 
-  Standard_Real X, Y, Z;
   CALL_DEF_TEXT atext;
-  TCollection_AsciiString ascii (AText,'?');
 
+  Standard_Real X, Y, Z;
   APoint.Coord (X, Y, Z);
   atext.Position.x  = float (X);
   atext.Position.y  = float (Y);
@@ -143,15 +92,13 @@ void OpenGl_GraphicDriver::Text
   atext.Path    = int (ATp);
   atext.HAlign    = int (AHta);
   atext.VAlign    = int (AVta);
-  atext.string    = (Standard_PCharacter)ascii.ToCString ();
+  atext.string    = (unsigned short *)AText.ToExtString ();
 
   if (MyTraceLevel) {
     PrintFunction ("call_togl_text");
     PrintCGroup (MyCGroup, 1);
   }
   call_togl_text (&MyCGroup, &atext);
-  ascii.Clear ();
-
 }
 
 void OpenGl_GraphicDriver::Text 
@@ -161,33 +108,29 @@ void OpenGl_GraphicDriver::Text
  const Graphic3d_Vertex& APoint, 
  const Standard_Real AHeight, 
  const Standard_Boolean 
- ) {
-
-
-   Graphic3d_CGroup MyCGroup = ACGroup;
-
-   Standard_Real X, Y, Z;
-   CALL_DEF_TEXT atext;
-   TCollection_AsciiString ascii (AText, '?');
-
-   APoint.Coord (X, Y, Z);
-   atext.Position.x  = float (X);
-   atext.Position.y  = float (Y);
-   atext.Position.z  = float (Z);
-   atext.Height    = float (AHeight);
-   if (atext.Height < 0)
-     atext.Height = DefaultTextHeight();
-   atext.Angle   = float (Standard_PI / 2.);
-   atext.Path    = int (Graphic3d_TP_RIGHT);
-   atext.HAlign    = int (Graphic3d_HTA_LEFT);
-   atext.VAlign    = int (Graphic3d_VTA_BOTTOM);
-   atext.string    = (Standard_PCharacter)ascii.ToCString ();
-
-   if (MyTraceLevel) {
-     PrintFunction ("call_togl_text");
-     PrintCGroup (MyCGroup, 1);
-   }
-   call_togl_text (&MyCGroup, &atext);
-   ascii.Clear ();
-
- }
+ )
+{
+  Graphic3d_CGroup MyCGroup = ACGroup;
+
+  CALL_DEF_TEXT atext;
+
+  Standard_Real X, Y, Z;
+  APoint.Coord (X, Y, Z);
+  atext.Position.x  = float (X);
+  atext.Position.y  = float (Y);
+  atext.Position.z  = float (Z);
+  atext.Height    = float (AHeight);
+  if (atext.Height < 0)
+    atext.Height = DefaultTextHeight();
+  atext.Angle   = float (Standard_PI / 2.);
+  atext.Path    = int (Graphic3d_TP_RIGHT);
+  atext.HAlign    = int (Graphic3d_HTA_LEFT);
+  atext.VAlign    = int (Graphic3d_VTA_BOTTOM);
+  atext.string    = (unsigned short *)AText.ToExtString ();
+
+  if (MyTraceLevel) {
+    PrintFunction ("call_togl_text");
+    PrintCGroup (MyCGroup, 1);
+  }
+  call_togl_text (&MyCGroup, &atext);
+}
diff --git a/src/OpenGl/OpenGl_GraphicDriver_713.cxx b/src/OpenGl/OpenGl_GraphicDriver_713.cxx
index a32f6cf..a61d155 100644
--- a/src/OpenGl/OpenGl_GraphicDriver_713.cxx
+++ b/src/OpenGl/OpenGl_GraphicDriver_713.cxx
@@ -36,8 +36,7 @@ Standard_Boolean OpenGl_GraphicDriver
 {
 #ifdef BUC61044
   Graphic3d_CView MyCView = view;
-  if ( call_togl_isdepthtest( &MyCView ) )
-    return Standard_True;
+  return call_togl_isdepthtest (&MyCView) != 0;
 #endif
   return Standard_True;
 }
@@ -66,8 +65,7 @@ Standard_Boolean OpenGl_GraphicDriver
 {
 #ifdef BUC61045
   Graphic3d_CView MyCView = view;
-  if ( call_togl_isgllight( &MyCView ) )
-    return Standard_True;
+  return call_togl_isgllight (&MyCView) != 0;
 #endif
   return Standard_True;
 }
@@ -81,6 +79,20 @@ void OpenGl_GraphicDriver :: PrimitiveArray( const Graphic3d_CGroup& ACGroup,
   if( parray ) call_togl_parray (&MyCGroup,parray);
 }
 
+//=======================================================================
+//function : RemovePrimitiveArray
+//purpose  : Purpose: Clear visualization data in graphical driver and
+//           stop displaying the primitives array of the graphical group
+//           <theCGroup>. This method is internal and should be used by
+//           Graphic3d_Group only.
+//=======================================================================
+
+void OpenGl_GraphicDriver::RemovePrimitiveArray (const Graphic3d_CGroup&         theCGroup,
+                                                 const Graphic3d_PrimitiveArray& thePArray)
+{
+  Graphic3d_CGroup MyCGroup = theCGroup;
+  if (thePArray != NULL) call_togl_parray_remove (&MyCGroup, thePArray);
+}
 
 void OpenGl_GraphicDriver :: UserDraw ( const Graphic3d_CGroup& ACGroup,
                                         const Graphic3d_CUserDraw& AUserDraw )
diff --git a/src/OpenGl/OpenGl_GraphicDriver_9.cxx b/src/OpenGl/OpenGl_GraphicDriver_9.cxx
index 60b0693..9318938 100644
--- a/src/OpenGl/OpenGl_GraphicDriver_9.cxx
+++ b/src/OpenGl/OpenGl_GraphicDriver_9.cxx
@@ -1,4 +1,3 @@
-
 // File   OpenGl_GraphicDriver_9.cxx
 // Created  1/08/97
 // Author       PCT
@@ -269,304 +268,10 @@ void OpenGl_GraphicDriver::SetBgGradientStyle(const Graphic3d_CView& ACView,cons
   call_togl_set_gradient_type( ACView.WsId, FillType);
 }
 
-void OpenGl_GraphicDriver::GetGraduatedTrihedron(const Graphic3d_CView& view,
-                                                 /* Names of axes */
-                                                 Standard_CString& xname, 
-                                                 Standard_CString& yname, 
-                                                 Standard_CString& zname,
-                                                 /* Draw names */
-                                                 Standard_Boolean& xdrawname, 
-                                                 Standard_Boolean& ydrawname, 
-                                                 Standard_Boolean& zdrawname,
-                                                 /* Draw values */
-                                                 Standard_Boolean& xdrawvalues, 
-                                                 Standard_Boolean& ydrawvalues, 
-                                                 Standard_Boolean& zdrawvalues,
-                                                 /* Draw grid */
-                                                 Standard_Boolean& drawgrid,
-                                                 /* Draw axes */
-                                                 Standard_Boolean& drawaxes,
-                                                 /* Number of splits along axes */
-                                                 Standard_Integer& nbx, 
-                                                 Standard_Integer& nby, 
-                                                 Standard_Integer& nbz,
-                                                 /* Offset for drawing values */
-                                                 Standard_Integer& xoffset, 
-                                                 Standard_Integer& yoffset, 
-                                                 Standard_Integer& zoffset,
-                                                 /* Offset for drawing names of axes */
-                                                 Standard_Integer& xaxisoffset, 
-                                                 Standard_Integer& yaxisoffset, 
-                                                 Standard_Integer& zaxisoffset,
-                                                 /* Draw tickmarks */
-                                                 Standard_Boolean& xdrawtickmarks, 
-                                                 Standard_Boolean& ydrawtickmarks, 
-                                                 Standard_Boolean& zdrawtickmarks,
-                                                 /* Length of tickmarks */
-                                                 Standard_Integer& xtickmarklength, 
-                                                 Standard_Integer& ytickmarklength, 
-                                                 Standard_Integer& ztickmarklength,
-                                                 /* Grid color */
-                                                 Quantity_Color& gridcolor,
-                                                 /* X name color */
-                                                 Quantity_Color& xnamecolor,
-                                                 /* Y name color */
-                                                 Quantity_Color& ynamecolor,
-                                                 /* Z name color */
-                                                 Quantity_Color& znamecolor,
-                                                 /* X color of axis and values */
-                                                 Quantity_Color& xcolor,
-                                                 /* Y color of axis and values */
-                                                 Quantity_Color& ycolor,
-                                                 /* Z color of axis and values */
-                                                 Quantity_Color& zcolor,
-                                                 /* Name of font for names of axes */
-                                                 Standard_CString& fontOfNames,
-                                                 /* Style of names of axes */
-                                                 OSD_FontAspect& styleOfNames,
-                                                 /* Size of names of axes */
-                                                 Standard_Integer& sizeOfNames,
-                                                 /* Name of font for values */
-                                                 Standard_CString& fontOfValues,
-                                                 /* Style of values */
-                                                 OSD_FontAspect& styleOfValues,
-                                                 /* Size of values */
-                                                 Standard_Integer& sizeOfValues) const
-{
-    Graphic3d_CGraduatedTrihedron cubic;
-    call_togl_graduatedtrihedron_get((CALL_DEF_VIEW*)&view, &cubic);
-
-    /* Names of axes */
-    xname = cubic.xname;
-    yname = cubic.yname; 
-    zname = cubic.zname;
-    /* Draw names */
-    xdrawname = cubic.xdrawname; 
-    ydrawname = cubic.ydrawname; 
-    zdrawname = cubic.zdrawname;
-    /* Draw values */
-    xdrawvalues = cubic.xdrawvalues; 
-    ydrawvalues = cubic.ydrawvalues; 
-    zdrawvalues = cubic.zdrawvalues;
-    /* Draw grid */
-    drawgrid = cubic.drawgrid;
-    /* Draw axes */
-    drawaxes = cubic.drawaxes;
-    /* Number of splits along axes */
-    nbx = cubic.nbx; 
-    nby = cubic.nby; 
-    nbz = cubic.nbz;
-    /* Offset for drawing values */
-    xoffset = cubic.xoffset; 
-    yoffset = cubic.yoffset; 
-    zoffset = cubic.zoffset;
-    /* Offset for drawing names of axes */
-    xaxisoffset = cubic.xaxisoffset; 
-    yaxisoffset = cubic.yaxisoffset; 
-    zaxisoffset = cubic.zaxisoffset;
-    /* Draw tickmarks */
-    xdrawtickmarks = cubic.xdrawtickmarks; 
-    ydrawtickmarks = cubic.ydrawtickmarks; 
-    zdrawtickmarks = cubic.zdrawtickmarks;
-    /* Length of tickmarks */
-    xtickmarklength = cubic.xtickmarklength; 
-    ytickmarklength = cubic.ytickmarklength; 
-    ztickmarklength = cubic.ztickmarklength;
-    /* Grid color */
-    gridcolor.SetValues(cubic.gridcolor[0], cubic.gridcolor[1], cubic.gridcolor[2], Quantity_TOC_RGB);
-    /* X name color */
-    xnamecolor.SetValues(cubic.xnamecolor[0], cubic.xnamecolor[1], cubic.xnamecolor[2], Quantity_TOC_RGB);
-    /* Y name color */
-    ynamecolor.SetValues(cubic.ynamecolor[0], cubic.ynamecolor[1], cubic.ynamecolor[2], Quantity_TOC_RGB);
-    /* Z name color */
-    znamecolor.SetValues(cubic.znamecolor[0], cubic.znamecolor[1], cubic.znamecolor[2], Quantity_TOC_RGB);
-    /* X color of axis and values */
-    xcolor.SetValues(cubic.xcolor[0], cubic.xcolor[1], cubic.xcolor[2], Quantity_TOC_RGB);
-    /* Y color of axis and values */
-    ycolor.SetValues(cubic.ycolor[0], cubic.ycolor[1], cubic.ycolor[2], Quantity_TOC_RGB);
-    /* Z color of axis and values */
-    zcolor.SetValues(cubic.zcolor[0], cubic.zcolor[1], cubic.zcolor[2], Quantity_TOC_RGB);
-    /* Name of font for names of axes */
-    fontOfNames = cubic.fontOfNames;
-    /* Style of names of axes */
-    styleOfNames = cubic.styleOfNames;
-    /* Size of names of axes */
-    sizeOfNames = cubic.sizeOfNames;
-    /* Name of font for values */
-    fontOfValues = cubic.fontOfValues;
-    /* Style of values */
-    styleOfValues = cubic.styleOfValues;
-    /* Size of values */
-    sizeOfValues = cubic.sizeOfValues;
-    /* Name of font for names of axes */
-    fontOfNames = cubic.fontOfNames;
-    /* Style of names of axes */
-    styleOfNames = cubic.styleOfNames;
-    /* Size of names of axes */
-    sizeOfNames = cubic.sizeOfNames;
-    /* Name of font for values */
-    fontOfValues = cubic.fontOfValues;
-    /* Style of values */
-    styleOfValues = cubic.styleOfValues;
-    /* Size of values */
-    sizeOfValues = cubic.sizeOfValues;
-}
-
 void OpenGl_GraphicDriver::GraduatedTrihedronDisplay(const Graphic3d_CView& view,
-                                                     Graphic3d_CGraduatedTrihedron& cubic,
-                                                     /* Names of axes */
-                                                     const Standard_CString xname, 
-                                                     const Standard_CString yname, 
-                                                     const Standard_CString zname,
-                                                     /* Draw names */
-                                                     const Standard_Boolean xdrawname, 
-                                                     const Standard_Boolean ydrawname, 
-                                                     const Standard_Boolean zdrawname,
-                                                     /* Draw values */
-                                                     const Standard_Boolean xdrawvalues, 
-                                                     const Standard_Boolean ydrawvalues, 
-                                                     const Standard_Boolean zdrawvalues,
-                                                     /* Draw grid */
-                                                     const Standard_Boolean drawgrid,
-                                                     /* Draw axes */
-                                                     const Standard_Boolean drawaxes,
-                                                     /* Number of splits along axes */
-                                                     const Standard_Integer nbx, 
-                                                     const Standard_Integer nby, 
-                                                     const Standard_Integer nbz,
-                                                     /* Offset for drawing values */
-                                                     const Standard_Integer xoffset, 
-                                                     const Standard_Integer yoffset, 
-                                                     const Standard_Integer zoffset,
-                                                     /* Offset for drawing names of axes */
-                                                     const Standard_Integer xaxisoffset, 
-                                                     const Standard_Integer yaxisoffset, 
-                                                     const Standard_Integer zaxisoffset,
-                                                     /* Draw tickmarks */
-                                                     const Standard_Boolean xdrawtickmarks, 
-                                                     const Standard_Boolean ydrawtickmarks, 
-                                                     const Standard_Boolean zdrawtickmarks,
-                                                     /* Length of tickmarks */
-                                                     const Standard_Integer xtickmarklength, 
-                                                     const Standard_Integer ytickmarklength, 
-                                                     const Standard_Integer ztickmarklength,
-                                                     /* Grid color */
-                                                     const Quantity_Color& gridcolor,
-                                                     /* X name color */
-                                                     const Quantity_Color& xnamecolor,
-                                                     /* Y name color */
-                                                     const Quantity_Color& ynamecolor,
-                                                     /* Z name color */
-                                                     const Quantity_Color& znamecolor,
-                                                     /* X color of axis and values */
-                                                     const Quantity_Color& xcolor,
-                                                     /* Y color of axis and values */
-                                                     const Quantity_Color& ycolor,
-                                                     /* Z color of axis and values */
-                                                     const Quantity_Color& zcolor,
-                                                     /* Name of font for names of axes */
-                                                     const Standard_CString fontOfNames,
-                                                     /* Style of names of axes */
-                                                     const OSD_FontAspect styleOfNames,
-                                                     /* Size of names of axes */
-                                                     const Standard_Integer sizeOfNames,
-                                                     /* Name of font for values */
-                                                     const Standard_CString fontOfValues,
-                                                     /* Style of values */
-                                                     const OSD_FontAspect styleOfValues,
-                                                     /* Size of values */
-                                                     const Standard_Integer sizeOfValues)
+                                                     const Graphic3d_CGraduatedTrihedron& cubic)
 {
-    /* Names of axes */
-    cubic.xname = (char*) xname;
-    cubic.yname = (char*) yname; 
-    cubic.zname = (char*) zname;
-    /* Draw names */
-    cubic.xdrawname = xdrawname; 
-    cubic.ydrawname = ydrawname; 
-    cubic.zdrawname = zdrawname;
-    /* Draw values */
-    cubic.xdrawvalues = xdrawvalues; 
-    cubic.ydrawvalues = ydrawvalues; 
-    cubic.zdrawvalues = zdrawvalues;
-    /* Draw grid */
-    cubic.drawgrid = drawgrid;
-    /* Draw axes */
-    cubic.drawaxes = drawaxes;
-    /* Number of splits along axes */
-    cubic.nbx = nbx; 
-    cubic.nby = nby; 
-    cubic.nbz = nbz;
-    /* Offset for drawing values */
-    cubic.xoffset = xoffset; 
-    cubic.yoffset = yoffset; 
-    cubic.zoffset = zoffset;
-    /* Offset for drawing names of axes */
-    cubic.xaxisoffset = xaxisoffset; 
-    cubic.yaxisoffset = yaxisoffset; 
-    cubic.zaxisoffset = zaxisoffset;
-    /* Draw tickmarks */
-    cubic.xdrawtickmarks = xdrawtickmarks; 
-    cubic.ydrawtickmarks = ydrawtickmarks; 
-    cubic.zdrawtickmarks = zdrawtickmarks;
-    /* Length of tickmarks */
-    cubic.xtickmarklength = xtickmarklength; 
-    cubic.ytickmarklength = ytickmarklength; 
-    cubic.ztickmarklength = ztickmarklength;
-    /* Grid color */
-    cubic.gridcolor[0] = (Standard_ShortReal) gridcolor.Red();
-    cubic.gridcolor[1] = (Standard_ShortReal) gridcolor.Green();
-    cubic.gridcolor[2] = (Standard_ShortReal) gridcolor.Blue();
-    /* X name color */
-    cubic.xnamecolor[0] = (Standard_ShortReal) xnamecolor.Red();
-    cubic.xnamecolor[1] = (Standard_ShortReal) xnamecolor.Green();
-    cubic.xnamecolor[2] = (Standard_ShortReal) xnamecolor.Blue();
-    /* Y name color */
-    cubic.ynamecolor[0] = (Standard_ShortReal) ynamecolor.Red();
-    cubic.ynamecolor[1] = (Standard_ShortReal) ynamecolor.Green();
-    cubic.ynamecolor[2] = (Standard_ShortReal) ynamecolor.Blue();
-    /* Z name color */
-    cubic.znamecolor[0] = (Standard_ShortReal) znamecolor.Red();
-    cubic.znamecolor[1] = (Standard_ShortReal) znamecolor.Green();
-    cubic.znamecolor[2] = (Standard_ShortReal) znamecolor.Blue();
-    /* X color of axis and values */
-    cubic.xcolor[0] = (Standard_ShortReal) xcolor.Red();
-    cubic.xcolor[1] = (Standard_ShortReal) xcolor.Green();
-    cubic.xcolor[2] = (Standard_ShortReal) xcolor.Blue();
-    /* Y color of axis and values */
-    cubic.ycolor[0] = (Standard_ShortReal) ycolor.Red();
-    cubic.ycolor[1] = (Standard_ShortReal) ycolor.Green();
-    cubic.ycolor[2] = (Standard_ShortReal) ycolor.Blue();
-    /* Z color of axis and values */
-    cubic.zcolor[0] = (Standard_ShortReal) zcolor.Red();
-    cubic.zcolor[1] = (Standard_ShortReal) zcolor.Green();
-    cubic.zcolor[2] = (Standard_ShortReal) zcolor.Blue();
-    /* Name of font for names of axes */
-    cubic.fontOfNames = (char*) fontOfNames;
-    /* Style of names of axes */
-    cubic.styleOfNames = styleOfNames;
-    /* Size of names of axes */
-    cubic.sizeOfNames = sizeOfNames;
-    /* Name of font for values */
-    cubic.fontOfValues = (char*) fontOfValues;
-    /* Style of values */
-    cubic.styleOfValues = styleOfValues;
-    /* Size of values */
-    cubic.sizeOfValues = sizeOfValues;
-    /* Name of font for names of axes */
-    cubic.fontOfNames = (char*) fontOfNames;
-    /* Style of names of axes */
-    cubic.styleOfNames = styleOfNames;
-    /* Size of names of axes */
-    cubic.sizeOfNames = sizeOfNames;
-    /* Name of font for values */
-    cubic.fontOfValues = (char*) fontOfValues;
-    /* Style of values */
-    cubic.styleOfValues = styleOfValues;
-    /* Size of values */
-    cubic.sizeOfValues = sizeOfValues;
-
-    call_togl_graduatedtrihedron_display((CALL_DEF_VIEW*)&view, &cubic);
+    call_togl_graduatedtrihedron_display((CALL_DEF_VIEW*)&view, cubic);
 }
 
 void OpenGl_GraphicDriver::GraduatedTrihedronErase(const Graphic3d_CView& view)
diff --git a/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx b/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx
index 066fa59..b00046b 100644
--- a/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx
+++ b/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx
@@ -200,7 +200,8 @@ void OpenGl_GraphicDriver::SetTextAttributes (const Standard_CString Font, const
   call_togl_set_text_attributes ((Tchar*)Font, AType, R, G, B);
 }   
 
-void OpenGl_GraphicDriver::Text (const Standard_CString AText, const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Height) {
+void OpenGl_GraphicDriver::Text (const Standard_CString AText, const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Height)
+{
   if (MyTraceLevel) {
     PrintFunction ("call_togl_text2d");
     PrintString ("Text", AText);
@@ -208,14 +209,15 @@ void OpenGl_GraphicDriver::Text (const Standard_CString AText, const Standard_Sh
     PrintShortReal ("Y", Y);
     PrintShortReal ("Height", Height);
   }
-  Standard_ShortReal h = Height;
-  if ( h < 0 )
-    h = DefaultTextHeight();
-  call_togl_text2d ((char *)AText, X, Y, h);
+  const Standard_ShortReal h = (Height < 0)? DefaultTextHeight() : Height;
+  TCollection_ExtendedString estr(AText);
+  call_togl_text2d ((Techar *)estr.ToExtString(), X, Y, h);
 }
 
-void OpenGl_GraphicDriver::TextSize (const Standard_CString AText, const Standard_ShortReal AHeight, Standard_ShortReal& AWidth, Standard_ShortReal& AnAscent, Standard_ShortReal& ADescent) const {
-  call_togl_textsize2d ((char *) AText, AHeight, &AWidth, &AnAscent, &ADescent);
+void OpenGl_GraphicDriver::TextSize (const Standard_CString AText, const Standard_ShortReal AHeight, Standard_ShortReal& AWidth, Standard_ShortReal& AnAscent, Standard_ShortReal& ADescent) const
+{
+  TCollection_ExtendedString estr(AText);
+  call_togl_textsize2d ((Techar *)estr.ToExtString(), AHeight, &AWidth, &AnAscent, &ADescent);
   if (MyTraceLevel) {
     PrintFunction ("call_togl_textsize2d");
     PrintString ("Text", AText);
diff --git a/src/OpenGl/OpenGl_GraphicDriver_print.cxx b/src/OpenGl/OpenGl_GraphicDriver_print.cxx
index ed25d2b..ef1646a 100644
--- a/src/OpenGl/OpenGl_GraphicDriver_print.cxx
+++ b/src/OpenGl/OpenGl_GraphicDriver_print.cxx
@@ -11,19 +11,22 @@
 #include <Aspect_DriverDefinitionError.hxx>
 #include <Standard_NotImplemented.hxx>
 
-#include "OpenGl_tgl_funcs.hxx"
+#include <OpenGl_tgl_funcs.hxx>
 
 
 /************************************************************************/
 /* Print Methods                                                        */
 /************************************************************************/
 
-void OpenGl_GraphicDriver::Print (const Graphic3d_CView& ACView, 
-                                  const Aspect_CLayer2d& ACUnderLayer, 
-                                  const Aspect_CLayer2d& ACOverLayer,
-                                  const Aspect_Handle    hPrintDC,
-                                  const Standard_Boolean showBackground,
-                                  const Standard_CString filename ) const
+Standard_Boolean OpenGl_GraphicDriver::Print
+  (const Graphic3d_CView& ACView, 
+   const Aspect_CLayer2d& ACUnderLayer, 
+   const Aspect_CLayer2d& ACOverLayer,
+   const Aspect_Handle    hPrintDC,
+   const Standard_Boolean showBackground,
+   const Standard_CString filename,
+   const Aspect_PrintAlgo printAlgorithm,
+   const Standard_Real theScaleFactor) const
 {
 
 #ifdef WNT
@@ -35,11 +38,12 @@ void OpenGl_GraphicDriver::Print (const Graphic3d_CView& ACView,
     PrintFunction ("call_togl_print");
     PrintCView (MyCView, 1);
   }
-  call_togl_print (&MyCView, &MyCUnderLayer, &MyCOverLayer,
-    hPrintDC, (int)showBackground, filename);
+  return call_togl_print (&MyCView, &MyCUnderLayer, &MyCOverLayer,
+                          hPrintDC, (int)showBackground, filename,
+                          (int)printAlgorithm, (float)theScaleFactor);
 #else
   Standard_NotImplemented::Raise ("OpenGl_GraphicDriver::Print is implemented "
     "only on Windows");
-
+  return Standard_False;
 #endif
 }
diff --git a/src/OpenGl/OpenGl_PrinterContext.cxx b/src/OpenGl/OpenGl_PrinterContext.cxx
new file mode 100644
index 0000000..4e3d4b2
--- /dev/null
+++ b/src/OpenGl/OpenGl_PrinterContext.cxx
@@ -0,0 +1,110 @@
+// File:      OpenGl_PrinterContext.cxx
+// Created:   20.05.11 10:00:00
+// Author:    Anton POLETAEV
+
+#include <OpenGl_PrinterContext.hxx>
+
+OpenGl_PrinterContext* OpenGl_PrinterContext::g_PrinterContext = NULL;
+GLCONTEXT              OpenGl_PrinterContext::g_ContextId      = NULL;
+
+//=======================================================================
+//function : OpenGl_PrinterContext
+//purpose  : Constructor
+//=======================================================================
+
+OpenGl_PrinterContext::OpenGl_PrinterContext (GLCONTEXT theCtx) :
+  myCtx (theCtx), myProjTransform (0, 3, 0, 3), myLayerViewportX (0),
+  myLayerViewportY (0), myScaleX (1.0f), myScaleY (1.0f)
+{
+  // assign global instance to the current object
+  if (myCtx != NULL)
+  {
+    g_PrinterContext = this;
+    g_ContextId      = myCtx;
+  }
+
+  // init projection matrix
+  Standard_Real anInitValue = 0.0;
+  myProjTransform.Init (anInitValue);
+  myProjTransform (0,0)  = 1.0f;
+  myProjTransform (1,1)  = 1.0f;
+  myProjTransform (2,2)  = 1.0f;
+  myProjTransform (3,3)  = 1.0f;
+}
+
+//=======================================================================
+//function : ~OpenGl_PrinterContext
+//purpose  : Destructor
+//=======================================================================
+
+OpenGl_PrinterContext::~OpenGl_PrinterContext () 
+{
+  // unassign global instance
+  if (g_PrinterContext == this)
+  {
+    g_ContextId      = NULL;
+    g_PrinterContext = NULL;
+  }
+}
+
+//=======================================================================
+//function : GetProjTransformation
+//purpose  : Get view projection transformation matrix.
+//=======================================================================
+
+void OpenGl_PrinterContext::GetProjTransformation (GLfloat theMatrix[16])
+{
+  for (int i = 0, k = 0; i < 4; i++)
+    for (int j = 0; j < 4; j++, k++)
+      theMatrix[k] = (GLfloat)myProjTransform (i,j);
+}
+
+//=======================================================================
+//function : SetProjTransformation
+//purpose  : Set view projection transformation matrix for printing purposes.
+//           theProjTransform parameter should be an 4x4 array.
+//=======================================================================
+
+bool OpenGl_PrinterContext::SetProjTransformation (TColStd_Array2OfReal& thePrj)
+{
+  if (thePrj.RowLength () != 4 || thePrj.ColLength () != 4)
+    return false;
+
+  myProjTransform = thePrj;
+
+  return true;
+}
+
+//=======================================================================
+//function : Deactivate
+//purpose  : Deactivate PrinterContext object.
+//           Useful when you need to redraw in usual mode the same
+//           OpenGl context that you used for printing right after printing,
+//           before the OpenGl_PrinterContext instance destroyed
+//=======================================================================
+
+void OpenGl_PrinterContext::Deactivate ()
+{
+  // unassign global instance
+  if (g_PrinterContext == this)
+  {
+    g_ContextId      = NULL;
+    g_PrinterContext = NULL;
+  }
+}
+
+
+//=======================================================================
+//function : GetInstance
+//purpose  : Get the PrinterContext instance assigned for OpenGl context.
+//           Return NULL, if there is no current printing operation and
+//           there is no assigned instance for "theCtx" OpenGl context.
+//=======================================================================
+
+OpenGl_PrinterContext* OpenGl_PrinterContext::GetPrinterContext (GLCONTEXT theCtx)
+{
+  if (g_ContextId == theCtx)
+    return g_PrinterContext;
+  else
+    return NULL;
+}
diff --git a/src/OpenGl/OpenGl_Resource.hxx b/src/OpenGl/OpenGl_Resource.hxx
deleted file mode 100644
index 9bb9a44..0000000
--- a/src/OpenGl/OpenGl_Resource.hxx
+++ /dev/null
@@ -1,63 +0,0 @@
-// File:      OpenGl_Resource.hxx
-// Created:   18.03.11 9:20:00
-// Author:    Anton POLETAEV
-
-#ifndef _OPENGL_RESOURCE_H
-#define _OPENGL_RESOURCE_H
-
-#include <OpenGl_ResourceCleaner.hxx>
-#include <MMgt_TShared.hxx>
-#include <Standard.hxx>
-#include <Standard_DefineHandle.hxx>
-#include <Handle_MMgt_TShared.hxx>
-
-class Standard_Transient;
-class Handle(Standard_Type);
-class Handle(MMgt_TShared);
-class OpenGl_ResourceCleaner;
-
-//! Class represents basic OpenGl memory resource, which
-//! could be removed only if appropriate context is avaliable;
-//! The cleaning procedure is done by OpenGl_ResourceCleaner
-class OpenGl_Resource : public MMgt_TShared
-{
-
-public:
-
-  //! Constructor
-  OpenGl_Resource() : myId(0) { }
- 
-  //! Constructor 
-  OpenGl_Resource(GLuint theId) : myId(theId) { }
-
-  //! Copy constructor
-  OpenGl_Resource(const OpenGl_Resource& theBase) : myId(theBase.myId) { }
-
-  //! Copy operation
-  OpenGl_Resource& operator = (const OpenGl_Resource& theBase)
-  {
-    this->myId = theBase.myId;
-    return *this; 
-  }
-
-  //! Destructor
-  virtual ~OpenGl_Resource() { }
-
-  //! method clean() is accessible only by OpenGl_ResourceCleaner
-  friend class OpenGl_ResourceCleaner;
-
-protected:
-
-  //! Clean procedure, should be called only by OpenGl_ResourceCleaner;
-  //! Each type of resource has its own cleaning procedure
-  virtual void Clean() = 0;
-
-protected:
-
-  GLuint myId; // Id of OpenGl memory resource
-
-};
-
-DEFINE_STANDARD_HANDLE(OpenGl_Resource,MMgt_TShared)
-
-#endif
diff --git a/src/OpenGl/OpenGl_ResourceCleaner.hxx b/src/OpenGl/OpenGl_ResourceCleaner.hxx
deleted file mode 100644
index a6ae698..0000000
--- a/src/OpenGl/OpenGl_ResourceCleaner.hxx
+++ /dev/null
@@ -1,79 +0,0 @@
-// File:      OpenGl_ResourceCleaner.hxx
-// Created:   18.03.11 9:30:00
-// Author:    Anton POLETAEV
-
-#ifndef _OPENGL_RESOURCECLEANER_H
-#define _OPENGL_RESOURCECLEANER_H
-
-#include <OpenGl_tgl_all.hxx>
-#include <NCollection_Queue.hxx>
-#include <NCollection_List.hxx>
-#include <NCollection_Map.hxx>
-#include <NCollection_DataMap.hxx>
-#include <OpenGl_Resource.hxx>
-
-class OpenGl_Resource;
-class Handle_OpenGl_Resource;
-
-typedef NCollection_Queue<Handle_OpenGl_Resource> QueueOfResources;
-typedef NCollection_DataMap<GLCONTEXT, QueueOfResources> DataMapOfContextsResources;
-typedef NCollection_Map<GLCONTEXT> MapOfContexts;
-
-//! OpenGl_ResourceCleaner should be used to clean OpenGl memory resources;
-//! The reason is that the resources might be shared between the contexts and
-//! should be cleaned up only while suitable context is active;
-class OpenGl_ResourceCleaner
-{
-
-public:
-	
-  //! Constructor
-  OpenGl_ResourceCleaner();
-
-  //! Destructor
-  virtual ~OpenGl_ResourceCleaner() { }
-
-  //! Append OpenGl context to the OpenGl_ResourceCleaner
-  //! control list.
-  void AppendContext(GLCONTEXT theContext, Standard_Boolean isShared);	
-  
-  //! Tell the OpenGl_ResourceCleaner to clean up the OpenGl memory resource
-  //! which has been created by the specified OpenGl context;
-  //! The context should be in the OpenGl_ResourceCleaner control list.
-  Standard_Boolean AddResource(GLCONTEXT theContext, Handle_OpenGl_Resource theResource);
-
-  //! Cancel clean procedure for all the resources added to the OpenGl_ResourceCleaner.
-  void Clear();
-
-  //! Cancel clean procedure for all the resources of the specific OpenGl context 
-  //! which were added to the OpenGl_ResourceCleaner.
-  Standard_Boolean Clear(GLCONTEXT theContext);
-
-  //! Cancel clean procedure for all of the shared resources.
-  void ClearShared();
-
-  //! Clear the unused resources for active OpenGl context;
-  //! You should add the cleaner resources by AddResources method;
-  //! It is suggested to call this method right before the OpenGl
-  //! new frame drawing procedure starts.
-  void Cleanup();
-
-  //! Remove the OpenGl context from the OpenGl_ResourceCleaner control list.
-  void RemoveContext(GLCONTEXT theContext);
-
-  //! Get any of shared contexts from the OpenGl_ResourceCleaner list 
-  //! to share resources with a new one
-  GLCONTEXT GetSharedContext() const;
-
-  //! Get the global instance of OpenGl_ResourceCleaner
-  static OpenGl_ResourceCleaner* GetInstance();
-
-private:
-
-  DataMapOfContextsResources myInstanceQueue;  // map for queues of non-shared context's resources
-  QueueOfResources mySharedQueue;              // queue of shared context's resources
-  MapOfContexts mySharedContexts;              // the control list of shared contexts
-
-};
-
-#endif
diff --git a/src/OpenGl/OpenGl_ResourceTexture.hxx b/src/OpenGl/OpenGl_ResourceTexture.hxx
deleted file mode 100644
index 1ab4d51..0000000
--- a/src/OpenGl/OpenGl_ResourceTexture.hxx
+++ /dev/null
@@ -1,37 +0,0 @@
-// File:      OpenGl_ResourceTexture.hxx
-// Created:   18.03.11 9:40:00
-// Author:    Anton POLETAEV
-
-#ifndef _OPENGL_RESOURCETEXTURE_H
-#define _OPENGL_RESOURCETEXTURE_H
-
-#include <OpenGl_Resource.hxx>
-#include <Standard.hxx>
-
-class OpenGl_Resource;
-
-//! OpenGl_ResourceTexture represents the texture resource
-//! for OpenGl_ResourceCleaner
-class OpenGl_ResourceTexture : public OpenGl_Resource 
-{
-
-public:
-
-  //! Constructor
-  OpenGl_ResourceTexture(GLuint theId);
-
-  //! Copy constructor
-  OpenGl_ResourceTexture(const OpenGl_ResourceTexture& theResource);
-
-  //! Destructor
-  ~OpenGl_ResourceTexture() { }
-
-protected:
-
-  //! Clean procedure for texture resource;
-  //! Should be called by the OpenGl_ResourceCleaner
-  void Clean();
-
-};
-
-#endif
diff --git a/src/OpenGl/OpenGl_ResourceVBO.hxx b/src/OpenGl/OpenGl_ResourceVBO.hxx
deleted file mode 100644
index 6f212cc..0000000
--- a/src/OpenGl/OpenGl_ResourceVBO.hxx
+++ /dev/null
@@ -1,37 +0,0 @@
-// File:      OpenGl_ResourceVBO.hxx
-// Created:   18.03.11 9:50:00
-// Author:    Anton POLETAEV
-
-#ifndef _OPENGL_RESOURCEVBO_H
-#define _OPENGL_RESOURCEVBO_H
-
-#include <OpenGl_Resource.hxx>
-#include <Standard.hxx>
-
-class OpenGl_Resource;
-
-//! OpenGl_ResourceVBO represents the Vertex Buffer
-//! Object resource (VBO) for OpenGl_ResourceCleaner
-class OpenGl_ResourceVBO : public OpenGl_Resource 
-{
-
-public:
-
-  //! Constructor
-  OpenGl_ResourceVBO(GLuint theId);
-
-  //! Copy constructor
-  OpenGl_ResourceVBO(const OpenGl_ResourceVBO& theResource);
-
-  //! Destructor
-  ~OpenGl_ResourceVBO() { }
-
-protected:
-
-  //! Clean procedure for VBO resource;
-  //! Should be called by the OpenGl_ResourceCleaner
-  void Clean();
-
-};
-
-#endif
diff --git a/src/OpenGl/OpenGl_TextRender.cxx b/src/OpenGl/OpenGl_TextRender.cxx
index cb6ea72..a9ad4f2 100644
--- a/src/OpenGl/OpenGl_TextRender.cxx
+++ b/src/OpenGl/OpenGl_TextRender.cxx
@@ -4,16 +4,16 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_HAsciiString.hxx>
-
-#include <Standard_Stream.hxx>
-
+#include <OpenGl_tgl_all.hxx>
 #include <OpenGl_FontMgr.hxx>   
 #include <OpenGl_tgl_funcs.hxx>
 #include <OpenGl_TextRender.hxx>
 #include <OpenGl_telem_attri.hxx>
 #include <OpenGl_cmn_varargs.hxx>
+#include <OpenGl_PrinterContext.hxx>
+#include <Standard_Stream.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_HAsciiString.hxx>
 
 #include <OSD_Environment.hxx>
 #include <Quantity_NameOfColor.hxx>
@@ -236,7 +236,7 @@ Tint OpenGl_TextRender::FindFont ( Tchar* fontName,
 }
 
 /*-----------------------------------------------------------------------------*/
-void OpenGl_TextRender::StringSize(char *str, GLint *Width, GLint *Ascent, GLint *Descent)
+void OpenGl_TextRender::StringSize(const wchar_t *str, GLint *Width, GLint *Ascent, GLint *Descent)
 {
 
   /*    int       dir, asc, des;*/
@@ -260,7 +260,7 @@ void OpenGl_TextRender::StringSize(char *str, GLint *Width, GLint *Ascent, GLint
 
 /*-----------------------------------------------------------------------------*/
 
-void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x, GLfloat y, GLfloat z ) 
+void OpenGl_TextRender::RenderText ( const wchar_t* str, GLuint base, int is2d, GLfloat x, GLfloat y, GLfloat z ) 
 {
   GLdouble projMatrix[4][4], modelMatrix[4][4];
   GLint viewport[4];
@@ -351,7 +351,7 @@ void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x
     glTranslatef(x, y, 0.f);
     glRotatef( 180, 1, 0, 0 );
   }
-  else {   
+  else {
     GLdouble wx, wy, wz;
     GLdouble x1, y1, z1;
     GLdouble x2, y2, z2;
@@ -385,6 +385,22 @@ void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x
 
     if( ! zoom )
     {
+#ifdef WNT
+      // if the context has assigned printer context, use it's parameters
+      OpenGl_PrinterContext* aPrinterContext = 
+        OpenGl_PrinterContext::GetPrinterContext( GET_GL_CONTEXT() );
+      if( aPrinterContext )
+      {
+        // get printing scaling in x and y dimensions
+        GLfloat aTextScalex = 1, aTextScaley = 1;
+        aPrinterContext->GetScale( aTextScalex, aTextScaley );
+        
+        // text should be scaled in all directions with same
+        // factor to save its proportions, so use height (y) scaling
+        // as it is better for keeping text/3d graphics proportions
+        glScalef( aTextScaley, aTextScaley, aTextScaley );
+      }
+#endif
       glScaled( h, h, h );
     }
     else
@@ -415,7 +431,6 @@ void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x
     glPopMatrix();
   }
   glPopAttrib();
-  return;
 
 }
 
@@ -465,7 +480,7 @@ int OpenGl_TextRender::alignmentforgl2ps(int vh, int vy)
 #endif
 
 /*-----------------------------------------------------------------------------*/
-void OpenGl_TextRender::ExportText( char* str, char* fontname, GLfloat height, GLfloat angle, GLint alignment,
+void OpenGl_TextRender::ExportText( const wchar_t* text, char* fontname, GLfloat height, GLfloat angle, GLint alignment,
                                     GLfloat x, GLfloat y, GLfloat z, GLboolean is2d )
 {
 #ifdef HAVE_GL2PS
@@ -479,11 +494,15 @@ void OpenGl_TextRender::ExportText( char* str, char* fontname, GLfloat height, G
     glRasterPos2f( x, y );
   else
     glRasterPos3f( x, y, z );
-  
+
   glBitmap( 1, 1, 0, 0, 0, 0, &zero );
 
-  gl2psTextOpt( str, ps_font, (GLshort)height, alignment, angle);
+  //szv: workaround for gl2ps!
+  const int len = 4 * (wcslen(text) + 1); //szv: should be more than enough
+  char *astr = new char[len];
+  wcstombs(astr,text,len);
+  gl2psTextOpt(astr, ps_font, (GLshort)height, alignment, angle);
+  delete[] astr;
 
 #endif
-
 }
diff --git a/src/OpenGl/OpenGl_funcs.cxx b/src/OpenGl/OpenGl_funcs.cxx
index fae36f7..f92b819 100644
--- a/src/OpenGl/OpenGl_funcs.cxx
+++ b/src/OpenGl/OpenGl_funcs.cxx
@@ -667,7 +667,7 @@ call_func_set_anno_align( Tint hor, Tint ver )
 /*----------------------------------------------------------------------*/
 
 void
-call_func_anno_text_rel3( tel_point pt, Tchar *str )
+call_func_anno_text_rel3( tel_point pt, Techar *str )
 {
   CMN_KEY  k[2];
 
diff --git a/src/OpenGl/OpenGl_graduatedtrihedron.cxx b/src/OpenGl/OpenGl_graduatedtrihedron.cxx
index 5edd93b..edd923e 100644
--- a/src/OpenGl/OpenGl_graduatedtrihedron.cxx
+++ b/src/OpenGl/OpenGl_graduatedtrihedron.cxx
@@ -1,3 +1,8 @@
+// File:      OpenGl_graduatedtrihedron.cxx
+// Created:   6 March 2011
+// Author:    Sergey ZERCHANINOV
+// Copyright: OPEN CASCADE SA 2011
+
 #include <OpenGl_tgl_all.hxx>
 #include <OpenGl_graduatedtrihedron.hxx>
 
@@ -24,262 +29,208 @@
 #include <string.h>
 #endif
 
+struct TEL_GRADUATEDTRIHEDRON_DATA
+{
+  int WsId;
+  wchar_t *xname, *yname, *zname;
+  unsigned char xdrawname, ydrawname, zdrawname;
+  unsigned char xdrawvalues, ydrawvalues, zdrawvalues;
+  unsigned char drawgrid;
+  unsigned char drawaxes;
+  unsigned int nbx, nby, nbz;
+  int xoffset, yoffset, zoffset;
+  int xaxisoffset, yaxisoffset, zaxisoffset;
+  unsigned char xdrawtickmarks, ydrawtickmarks, zdrawtickmarks;
+  unsigned int xtickmarklength, ytickmarklength, ztickmarklength;
+  float gridcolor[3];
+  float xnamecolor[3];
+  float ynamecolor[3];
+  float znamecolor[3];
+  float xcolor[3];
+  float ycolor[3];
+  float zcolor[3];
+  char* fontOfNames;
+  OSD_FontAspect styleOfNames;
+  int sizeOfNames;
+  char* fontOfValues;
+  OSD_FontAspect styleOfValues;
+  int sizeOfValues;
+  minMaxValuesCallback cbCubicAxes;
+  void* ptrVisual3dView;
+  IMPLEMENT_MEMORY_OPERATORS
+};
+typedef TEL_GRADUATEDTRIHEDRON_DATA* tel_graduatedtrihedron_data;
+
 /* Graduated trihedron data */
-static int  nbWsIds = 0;                       /* Number of the views (size of the arrays below */
-static int* WsIds = 0;                         /* The array contans indices of graduated trihedron data corresponding to the view ID */
-static CALL_DEF_GRADUATEDTRIHEDRON** graduatedTrihedronData = 0; /* The array contains graduated trihedron data of all views */
+static int nbWsIds = 0; /* Number of the views (size of the arrays below */
+static tel_graduatedtrihedron_data* graduatedTrihedronData = 0; /* The array contains graduated trihedron data of all views */
 
 /* Bounding box */
 float xmin = 0.0f, ymin = 0.0f, zmin = 0.0f, xmax = 100.0f, ymax = 100.0f, zmax = 100.0f;
 
-static void copyData(CALL_DEF_GRADUATEDTRIHEDRON* fromData, CALL_DEF_GRADUATEDTRIHEDRON* toData)
-{
-    int len;
-
-    /* Names of axes */
-    /* X-name */
-    if (fromData->xname)
-        len = strlen(fromData->xname) + 1;
-    else 
-        len = 1;
-    toData->xname = (char*) malloc(len * sizeof(char));
-    if (fromData->xname)
-        strcpy(toData->xname, fromData->xname);
-    else
-        toData->xname[0] = '\0';
-    /* Y-name */
-    if (fromData->yname)
-        len = strlen(fromData->yname) + 1;
-    else 
-        len = 1;
-    toData->yname = (char*) malloc(len * sizeof(char));
-    if (fromData->yname)
-        strcpy(toData->yname, fromData->yname);
-    else
-        toData->yname[0] = '\0';
-    /* Z-name */
-    if (fromData->zname)
-        len = strlen(fromData->zname) + 1;
-    else 
-        len = 1;
-    toData->zname = (char*) malloc(len * sizeof(char));
-    if (fromData->zname)
-        strcpy(toData->zname, fromData->zname);
-    else
-        toData->zname[0] = '\0';
-    /* Draw names */
-    toData->xdrawname = fromData->xdrawname; 
-    toData->ydrawname = fromData->ydrawname; 
-    toData->zdrawname = fromData->zdrawname;
-    /* Draw values */
-    toData->xdrawvalues = fromData->xdrawvalues; 
-    toData->ydrawvalues = fromData->ydrawvalues; 
-    toData->zdrawvalues = fromData->zdrawvalues;
-    /* Draw grid */
-    toData->drawgrid = fromData->drawgrid;
-    /* Draw axes */
-    toData->drawaxes = fromData->drawaxes;
-    /* Number of splits along axes */
-    toData->nbx = fromData->nbx; 
-    toData->nby = fromData->nby; 
-    toData->nbz = fromData->nbz;
-    /* Offset for drawing values */
-    toData->xoffset = fromData->xoffset; 
-    toData->yoffset = fromData->yoffset; 
-    toData->zoffset = fromData->zoffset;
-    /* Offset for drawing names of axes */
-    toData->xaxisoffset = fromData->xaxisoffset; 
-    toData->yaxisoffset = fromData->yaxisoffset; 
-    toData->zaxisoffset = fromData->zaxisoffset;
-    /* Draw tickmarks */
-    toData->xdrawtickmarks = fromData->xdrawtickmarks; 
-    toData->ydrawtickmarks = fromData->ydrawtickmarks; 
-    toData->zdrawtickmarks = fromData->zdrawtickmarks;
-    /* Length of tickmarks */
-    toData->xtickmarklength = fromData->xtickmarklength; 
-    toData->ytickmarklength = fromData->ytickmarklength; 
-    toData->ztickmarklength = fromData->ztickmarklength;
-    /* Grid color */
-    memcpy(toData->gridcolor, fromData->gridcolor, 3 * sizeof(float));
-    /* X name color */
-    memcpy(toData->xnamecolor, fromData->xnamecolor, 3 * sizeof(float));
-    /* Y name color */
-    memcpy(toData->ynamecolor, fromData->ynamecolor, 3 * sizeof(float));
-    /* Z name color */
-    memcpy(toData->znamecolor, fromData->znamecolor, 3 * sizeof(float));
-    /* X color of axis and values */
-    memcpy(toData->xcolor, fromData->xcolor, 3 * sizeof(float));
-    /* Y color of axis and values */
-    memcpy(toData->ycolor, fromData->ycolor, 3 * sizeof(float));
-    /* Z color of axis and values */
-    memcpy(toData->zcolor, fromData->zcolor, 3 * sizeof(float));
-    /* Font name of names of axes: Courier, Arial, ... */
-    if (fromData->fontOfNames)
-        len = strlen(fromData->fontOfNames) + 1;
-    else 
-        len = 1;
-    toData->fontOfNames = (char*) malloc(len * sizeof(char));
-    if (fromData->fontOfNames)
-        strcpy(toData->fontOfNames, fromData->fontOfNames);
-    else
-        toData->fontOfNames[0] = '\0';
-    /* Style of names of axes: OSD_FA_Regular, OSD_FA_Bold, ... */
-    toData->styleOfNames = fromData->styleOfNames;
-    /* Size of names of axes: 8, 10, 12, 14, ... */
-    toData->sizeOfNames = fromData->sizeOfNames;
-    /* Font name of values: Courier, Arial, ... */
-    if (fromData->fontOfValues)
-        len = strlen(fromData->fontOfValues) + 1;
-    else 
-        len = 1;
-    toData->fontOfValues = (char*) malloc(len * sizeof(char));
-    if (fromData->fontOfValues)
-        strcpy(toData->fontOfValues, fromData->fontOfValues);
-    else
-        toData->fontOfValues[0] = '\0';
-    /* Style of values: OSD_FA_Regular, OSD_FA_Bold, ... */
-    toData->styleOfValues = fromData->styleOfValues;
-    /* Size of values: 8, 10, 12, 14, ... */
-    toData->sizeOfValues = fromData->sizeOfValues;
-    /* Callback - updater of boundary box */
-    toData->cbCubicAxes = fromData->cbCubicAxes;
-    toData->ptrVisual3dView = fromData->ptrVisual3dView;
-}
-
-static void freeGraduatedTrihedronData(CALL_DEF_GRADUATEDTRIHEDRON* data)
+static void copyData(const Graphic3d_CGraduatedTrihedron *fromData, TEL_GRADUATEDTRIHEDRON_DATA* toData)
 {
-    /* Names of axes */
-    if (data->xname)
-        free(data->xname); 
-    if (data->yname)
-        free(data->yname); 
-    if (data->zname)
-        free(data->zname); 
-
-    /* Fonts */
-    if (data->fontOfNames)
-        free(data->fontOfNames); 
-    if (data->fontOfValues)
-        free(data->fontOfValues); 
-
-    free(data);
+  int len;
+
+  /* Names of axes */
+  /* X-name */
+  len = fromData->xname.Length();
+  if (len)
+  {
+    Standard_ExtString iname = fromData->xname.ToExtString();
+    toData->xname = new wchar_t[len+1];
+    len = 0; while (toData->xname[len] = (wchar_t)(iname[len])) len++;
+  }
+  else
+    toData->xname = NULL;
+  /* Y-name */
+  len = fromData->yname.Length();
+  if (len)
+  {
+    Standard_ExtString iname = fromData->yname.ToExtString();
+    toData->yname = new wchar_t[len+1];
+    len = 0; while (toData->yname[len] = (wchar_t)(iname[len])) len++;
+  }
+  else
+    toData->yname = NULL;
+  /* Z-name */
+  len = fromData->zname.Length();
+  if (len)
+  {
+    Standard_ExtString iname = fromData->zname.ToExtString();
+    toData->zname = new wchar_t[len+1];
+    len = 0; while (toData->zname[len] = (wchar_t)(iname[len])) len++;
+  }
+  else
+    toData->zname = NULL;
+  /* Draw names */
+  toData->xdrawname = fromData->xdrawname;
+  toData->ydrawname = fromData->ydrawname; 
+  toData->zdrawname = fromData->zdrawname;
+  /* Draw values */
+  toData->xdrawvalues = fromData->xdrawvalues; 
+  toData->ydrawvalues = fromData->ydrawvalues; 
+  toData->zdrawvalues = fromData->zdrawvalues;
+  /* Draw grid */
+  toData->drawgrid = fromData->drawgrid;
+  /* Draw axes */
+  toData->drawaxes = fromData->drawaxes;
+  /* Number of splits along axes */
+  toData->nbx = fromData->nbx; 
+  toData->nby = fromData->nby; 
+  toData->nbz = fromData->nbz;
+  /* Offset for drawing values */
+  toData->xoffset = fromData->xoffset; 
+  toData->yoffset = fromData->yoffset; 
+  toData->zoffset = fromData->zoffset;
+  /* Offset for drawing names of axes */
+  toData->xaxisoffset = fromData->xaxisoffset;
+  toData->yaxisoffset = fromData->yaxisoffset; 
+  toData->zaxisoffset = fromData->zaxisoffset;
+  /* Draw tickmarks */
+  toData->xdrawtickmarks = fromData->xdrawtickmarks; 
+  toData->ydrawtickmarks = fromData->ydrawtickmarks; 
+  toData->zdrawtickmarks = fromData->zdrawtickmarks;
+  /* Length of tickmarks */
+  toData->xtickmarklength = fromData->xtickmarklength; 
+  toData->ytickmarklength = fromData->ytickmarklength; 
+  toData->ztickmarklength = fromData->ztickmarklength;
+  /* Grid color */
+  toData->gridcolor[0] = (float) fromData->gridcolor.Red();
+  toData->gridcolor[1] = (float) fromData->gridcolor.Green();
+  toData->gridcolor[2] = (float) fromData->gridcolor.Blue();
+  /* X name color */
+  toData->xnamecolor[0] = (float) fromData->xnamecolor.Red();
+  toData->xnamecolor[1] = (float) fromData->xnamecolor.Green();
+  toData->xnamecolor[2] = (float) fromData->xnamecolor.Blue();
+  /* Y name color */
+  toData->ynamecolor[0] = (float) fromData->ynamecolor.Red();
+  toData->ynamecolor[1] = (float) fromData->ynamecolor.Green();
+  toData->ynamecolor[2] = (float) fromData->ynamecolor.Blue();
+  /* Z name color */
+  toData->znamecolor[0] = (float) fromData->znamecolor.Red();
+  toData->znamecolor[1] = (float) fromData->znamecolor.Green();
+  toData->znamecolor[2] = (float) fromData->znamecolor.Blue();
+  /* X color of axis and values */
+  toData->xcolor[0] = (float) fromData->xcolor.Red();
+  toData->xcolor[1] = (float) fromData->xcolor.Green();
+  toData->xcolor[2] = (float) fromData->xcolor.Blue();
+  /* Y color of axis and values */
+  toData->ycolor[0] = (float) fromData->ycolor.Red();
+  toData->ycolor[1] = (float) fromData->ycolor.Green();
+  toData->ycolor[2] = (float) fromData->ycolor.Blue();
+  /* Z color of axis and values */
+  toData->zcolor[0] = (float) fromData->zcolor.Red();
+  toData->zcolor[1] = (float) fromData->zcolor.Green();
+  toData->zcolor[2] = (float) fromData->zcolor.Blue();
+  /* Font name of names of axes: Courier, Arial, ... */
+  len = fromData->fontOfNames.Length();
+  toData->fontOfNames = new char[len+1];
+  if (len)
+    strcpy(toData->fontOfNames, fromData->fontOfNames.ToCString());
+  else
+    toData->fontOfNames[0] = L'\0';
+  /* Style of names of axes: OSD_FA_Regular, OSD_FA_Bold, ... */
+  toData->styleOfNames = fromData->styleOfNames;
+  /* Size of names of axes: 8, 10, 12, 14, ... */
+  toData->sizeOfNames = fromData->sizeOfNames;
+  /* Font name of values: Courier, Arial, ... */
+  len = fromData->fontOfValues.Length();
+  toData->fontOfValues = new char[len+1];
+  if (len)
+    strcpy(toData->fontOfValues, fromData->fontOfValues.ToCString());
+  else
+    toData->fontOfValues[0] = L'\0';
+  /* Style of values: OSD_FA_Regular, OSD_FA_Bold, ... */
+  toData->styleOfValues = fromData->styleOfValues;
+  /* Size of values: 8, 10, 12, 14, ... */
+  toData->sizeOfValues = fromData->sizeOfValues;
+  /* Callback - updater of boundary box */
+  toData->cbCubicAxes = fromData->cbCubicAxes;
+  toData->ptrVisual3dView = fromData->ptrVisual3dView;
 }
 
 static void freeData()
 {
-    int i;
-
-    if (WsIds)
-    {
-        free(WsIds);
-        for (i = 0; i < nbWsIds; i++)
-        {
-            freeGraduatedTrihedronData(graduatedTrihedronData[i]);
-        }
-        free(graduatedTrihedronData);
-
-        WsIds = 0;
-        graduatedTrihedronData = 0;
-    }
-}
-
-static int getGraduatedTrihedronDataIndex(int WsId)
-{
+  if (nbWsIds)
+  {
     int i = 0;
-    
-    if (!nbWsIds)
-        return -1;
-    
-    for (; i < nbWsIds; i++)
-    {
-        if (WsIds[i] == WsId)
-            return i;
-    }
-
-    return -1;
-}
-
-static unsigned char initView(int WsId)
-{
-    int i;
-    int* newWsIds;
-    CALL_DEF_GRADUATEDTRIHEDRON** newGraduatedTrihedronData;
-
-    /* Extend arrays for +1 */
-    nbWsIds++;
-    newWsIds = (int*) calloc(nbWsIds, sizeof(int));
-    newGraduatedTrihedronData = (CALL_DEF_GRADUATEDTRIHEDRON**) calloc(nbWsIds, sizeof(CALL_DEF_GRADUATEDTRIHEDRON*));
+    tel_graduatedtrihedron_data gtdata;
     for (i = 0; i < nbWsIds; i++)
     {
-        newGraduatedTrihedronData[i] = (CALL_DEF_GRADUATEDTRIHEDRON*) calloc(1, sizeof(CALL_DEF_GRADUATEDTRIHEDRON));
+      gtdata = graduatedTrihedronData[i];
+
+      // Names of axes
+      if (gtdata->xname)
+        delete[] gtdata->xname;
+      if (gtdata->yname)
+        delete[] gtdata->yname;
+      if (gtdata->zname)
+        delete[] gtdata->zname;
+
+      // Fonts
+      if (gtdata->fontOfNames)
+        delete[] gtdata->fontOfNames;
+      if (gtdata->fontOfValues)
+        delete[] gtdata->fontOfValues;
+
+      delete gtdata;
     }
-
-    /* Copy data from current arrays to the newly created */
-    if (nbWsIds > 1)
-    {
-        for (i = 0; i < nbWsIds - 1; i++)
-        {
-            newWsIds[i] = WsIds[i];
-            copyData(graduatedTrihedronData[i], newGraduatedTrihedronData[i]);
-        }
-    }
-
-    /* Delete the previous used arrays */
-    nbWsIds--; /* Don't delete just created graduated trihedron data */
-    freeData();
-    nbWsIds++; /* Return the counter back */
-
-    /* Switch to new arrays */
-    WsIds = newWsIds;
-    graduatedTrihedronData = newGraduatedTrihedronData;
-
-    /* Set view ID */
-    WsIds[nbWsIds - 1] = WsId;
-
-    return TSuccess;
+    delete graduatedTrihedronData;
+    graduatedTrihedronData = 0;
+    nbWsIds = 0;
+  }
 }
 
-/* Erases the trihedron from the view */
-static TStatus removeView(int WsId)
+static int getGraduatedTrihedronDataIndex(int WsId)
 {
-    int index, i, j;
-    int* newWsIds;
-    CALL_DEF_GRADUATEDTRIHEDRON** newGraduatedTrihedronData;
-
-    index = getGraduatedTrihedronDataIndex(WsId);
-    if (index == -1)
-        return TSuccess; /* Nothing to remove */
-
-    /* If trihedron is displayed only in one view,
-       just free the arrays and set nbWsIds equal to 0. */
-    if (nbWsIds == 1)
-    {
-        freeData();
-        nbWsIds = 0;
-        return TSuccess;
-    }
-
-    /* create new arrays with nbWsIds - 1 length. */
-    nbWsIds--;
-    newWsIds = (int*) calloc(nbWsIds, sizeof(int));
-    newGraduatedTrihedronData = (CALL_DEF_GRADUATEDTRIHEDRON**) calloc(nbWsIds, sizeof(CALL_DEF_GRADUATEDTRIHEDRON*));
-    for (i = 0; i < nbWsIds; i++)
-    {
-        newGraduatedTrihedronData[i] = (CALL_DEF_GRADUATEDTRIHEDRON*) calloc(1, sizeof(CALL_DEF_GRADUATEDTRIHEDRON));
-    }
-
-    /* Copy data from current arrays to the newly created */
-    for (i = 0, j = 0; j <= nbWsIds; j++)
-    {
-        if (j != index)
-        {
-            newWsIds[i] = WsIds[j];
-            copyData(graduatedTrihedronData[j], newGraduatedTrihedronData[i]);
-            i++;
-        }
-    }
-
-    return TSuccess;
+  int i = 0;
+  for (; i < nbWsIds; i++)
+  {
+    if (graduatedTrihedronData[i]->WsId == WsId)
+      return i;
+  }
+  return -1;
 }
 
 /* Normal of the view (not normalized!) */
@@ -363,12 +314,11 @@ static char getFarestCorner(float d000, float d100, float d010, float d001,
     return 8; /* d111 */
 }
 
-static void drawText(char* text, char* font, OSD_FontAspect style, int size, float x, float y, float z)
+static void drawText(const wchar_t* text, char* font, OSD_FontAspect style, int size, float x, float y, float z)
 {
-    GLuint fontBase = 0;
-    OpenGl_TextRender* textRenderer = OpenGl_TextRender::instance();
-    fontBase = textRenderer->FindFont((Tchar*) font, style, (float) size);
-    textRenderer->RenderText(text, fontBase, 0, x, y, z);
+  OpenGl_TextRender* textRenderer = OpenGl_TextRender::instance();
+  const GLuint fontBase = textRenderer->FindFont((Tchar*) font, style, (float) size);
+  textRenderer->RenderText(text, fontBase, 0, x, y, z);
 
 /* 4 OCC 6.3.1 and older:
     GLuint fontBase;
@@ -447,793 +397,744 @@ static void drawArrow(float x1, float y1, float z1,
     glEnd();
 }
 
-TStatus call_graduatedtrihedron_get(int WsId, CALL_DEF_GRADUATEDTRIHEDRON* data)
+TStatus call_graduatedtrihedron_display(int WsId, const Graphic3d_CGraduatedTrihedron &data)
 {
-    int index;
-
-    /* Get index of the view */
-    index = getGraduatedTrihedronDataIndex(WsId);
-    if (index == -1)
-    {
-        /* Default values */
-        data->xname = strdup("X\0");
-        data->yname = strdup("Y\0"); 
-        data->zname = strdup("Z\0");
-        data->xdrawname = 1;
-        data->ydrawname = 1; 
-        data->zdrawname = 1;
-        data->xdrawvalues = 1;
-        data->ydrawvalues = 1; 
-        data->zdrawvalues = 1;
-        data->drawgrid = 1;
-        data->drawaxes = 1;
-        data->nbx = 3;
-        data->nby = 3; 
-        data->nbz = 3;
-        data->xoffset = 10;
-        data->yoffset = 10; 
-        data->zoffset = 10;
-        data->xaxisoffset = 30;
-        data->yaxisoffset = 30; 
-        data->zaxisoffset = 30;
-        data->xdrawtickmarks = 1;
-        data->ydrawtickmarks = 1; 
-        data->zdrawtickmarks = 1;
-        data->xtickmarklength = 10;
-        data->ytickmarklength = 10; 
-        data->ztickmarklength = 10;
-        /*Quantity_NOC_WHITE*/;
-        data->gridcolor[0] = 1.0f;
-        data->gridcolor[1] = 1.0f;
-        data->gridcolor[2] = 1.0f;
-        /* Quantity_NOC_RED */
-        data->xnamecolor[0] = 1.0f;
-        data->xnamecolor[1] = 0.0f;
-        data->xnamecolor[2] = 0.0f;
-        /* Quantity_NOC_GREEN */
-        data->ynamecolor[0] = 0.0f;
-        data->ynamecolor[1] = 1.0f;
-        data->ynamecolor[2] = 0.0f;
-        /* Quantity_NOC_BLUE1 */
-        data->znamecolor[0] = 0.0f;
-        data->znamecolor[1] = 0.0f;
-        data->znamecolor[2] = 1.0f;
-        /* Quantity_NOC_RED */
-        data->xcolor[0] = 1.0f;
-        data->xcolor[1] = 0.0f;
-        data->xcolor[2] = 0.0f;
-        /* Quantity_NOC_GREEN */
-        data->ycolor[0] = 0.0f;
-        data->ycolor[1] = 1.0f;
-        data->ycolor[2] = 0.0f;
-        /* Quantity_NOC_BLUE1 */
-        data->zcolor[0] = 0.0f;
-        data->zcolor[1] = 0.0f;
-        data->zcolor[2] = 1.0f;
-    }
-    else
-    {
-        copyData(graduatedTrihedronData[index], data);
-    }
-    return TSuccess;
-}
+  /* Initialize data for a new view */
+  int index = getGraduatedTrihedronDataIndex(WsId);
+  if (index == -1)
+  {
+    /* Extend array for +1 */
+    tel_graduatedtrihedron_data* newGraduatedTrihedronData = new tel_graduatedtrihedron_data[nbWsIds+1];
+
+    /* Copy existing contents */
+    int i;
+    for (i = 0; i < nbWsIds; i++)
+      newGraduatedTrihedronData[i] = graduatedTrihedronData[i];
 
-TStatus call_graduatedtrihedron_display(int WsId, CALL_DEF_GRADUATEDTRIHEDRON* data)
-{
-    int index;
+    /* Add new item */
+    index = nbWsIds++;
+    newGraduatedTrihedronData[index] = new TEL_GRADUATEDTRIHEDRON_DATA;
+    newGraduatedTrihedronData[index]->WsId = WsId;
 
-    /* Initialize data for a new view */
-    index = getGraduatedTrihedronDataIndex(WsId);
-    if (index == -1)
-    {
-        initView(WsId);
-        index = getGraduatedTrihedronDataIndex(WsId);
-    }
-    copyData(data, graduatedTrihedronData[index]);
-    return call_graduatedtrihedron_redraw(WsId);
+    /* Switch to new array */
+    delete graduatedTrihedronData;
+    graduatedTrihedronData = newGraduatedTrihedronData;
+  }
+  copyData(&data, graduatedTrihedronData[index]);
+  return call_graduatedtrihedron_redraw(WsId);
 }
 
 TStatus call_graduatedtrihedron_erase(int WsId)
 {
-    return removeView(WsId);
+  int index = getGraduatedTrihedronDataIndex(WsId);
+  if (index == -1)
+    return TSuccess; /* Nothing to remove */
+
+  /* If trihedron is displayed only in one view, just free the array and set nbWsIds equal to 0. */
+  if (nbWsIds == 1)
+  {
+    freeData();
+    return TSuccess;
+  }
+
+  /* Reduce array for -1 */
+  tel_graduatedtrihedron_data* newGraduatedTrihedronData = new tel_graduatedtrihedron_data[nbWsIds-1];
+
+  /* Copy existing contents */
+  int i, j;
+  for (i = 0, j = 0; i < nbWsIds; i++)
+  {
+    if (graduatedTrihedronData[i]->WsId != WsId)
+      newGraduatedTrihedronData[j++] = graduatedTrihedronData[i];
+  }
+  nbWsIds--;
+
+  /* Switch to new array */
+  delete graduatedTrihedronData;
+  graduatedTrihedronData = newGraduatedTrihedronData;
+
+  return TSuccess;
 }
 
 TStatus call_graduatedtrihedron_redraw(int WsId)
 {
-    GLboolean light;
-    unsigned int i, offset;
-    unsigned char farestCorner;
-    float normal[3], center[3];
-    CALL_DEF_GRADUATEDTRIHEDRON* data;
-    float d000, d100, d010, d001, d110, d101, d011, d111; /* 0 - min, 1 - max */
-    float LX1[6], LX2[6], LX3[6]; /* Lines along X direction */
-    float LY1[6], LY2[6], LY3[6]; /* Lines along Y direction */
-    float LZ1[6], LZ2[6], LZ3[6]; /* Lines along Z direction */
-    unsigned char LX1draw, LX2draw, LX3draw; /* Allows drawing of X-line (000 - 100 is forbidden) */
-    unsigned char LY1draw, LY2draw, LY3draw; /* Allows drawing of Y-line (000 - 010 is forbidden) */
-    unsigned char LZ1draw, LZ2draw, LZ3draw; /* Allows drawing of Z-line (000 - 001 is forbidden) */
-    float m1[3], m2[3];
-    float step, d, dpix, dx, dy, dz;
-    char textValue[128];
-    int index;
-
-    /* Get index of the trihedron data */
-    index = getGraduatedTrihedronDataIndex(WsId);
-    if (index == -1)
-        return TFailure;
-    data = graduatedTrihedronData[index];
-
-    /* Update boundary box */
-    if (data->cbCubicAxes)
-        data->cbCubicAxes(data->ptrVisual3dView);
-
-    /* Disable lighting for lines */
-    light = glIsEnabled(GL_LIGHTING);
-    if (light)
-        glDisable(GL_LIGHTING);
+  /* Get index of the trihedron data */
+  int index = getGraduatedTrihedronDataIndex(WsId);
+  if (index == -1)
+    return TFailure;
+
+  tel_graduatedtrihedron_data data = graduatedTrihedronData[index];
+
+  /* Update boundary box */
+  if (data->cbCubicAxes)
+    data->cbCubicAxes(data->ptrVisual3dView);
+
+  /* Disable lighting for lines */
+  GLboolean light = glIsEnabled(GL_LIGHTING);
+  if (light)
+    glDisable(GL_LIGHTING);
     
-    /* Find the farest point of bounding box */
+  /* Find the farest point of bounding box */
 
-    /* Get normal of the view out of user. */
-    /* Also, the method return distance corresponding to 1 pixel */
-    dpix = getNormal(normal);
+  /* Get normal of the view out of user. */
+  /* Also, the method return distance corresponding to 1 pixel */
+  float normal[3];
+  float dpix = getNormal(normal);
     
-    /* Normalize normal */
-    d = sqrtf(normal[0] * normal[0] + normal[1] * normal[1] + normal[2] * normal[2]);
-    normal[0] = normal[0] / d;
-    normal[1] = normal[1] / d;
-    normal[2] = normal[2] / d;
-
-    /* Get central point of bounding box */
-    center[0] = 0.5f * (xmin + xmax);
-    center[1] = 0.5f * (ymin + ymax);
-    center[2] = 0.5f * (zmin + zmax);
-
-    /* Check distance to corners of bounding box along the normal*/
-    d000 = getDistance2Corner(normal, center, xmin, ymin, zmin);
-    d100 = getDistance2Corner(normal, center, xmax, ymin, zmin);
-    d010 = getDistance2Corner(normal, center, xmin, ymax, zmin);
-    d001 = getDistance2Corner(normal, center, xmin, ymin, zmax);
-    d110 = getDistance2Corner(normal, center, xmax, ymax, zmin);
-    d101 = getDistance2Corner(normal, center, xmax, ymin, zmax);
-    d011 = getDistance2Corner(normal, center, xmin, ymax, zmax);
-    d111 = getDistance2Corner(normal, center, xmax, ymax, zmax);
-    farestCorner = getFarestCorner(d000, d100, d010, d001, d110, d101, d011, d111);
-
-    /* Choose axes for the grid. */
-    /* The first axis will be used for drawing the text and the values. */
-    switch (farestCorner)
+  /* Normalize normal */
+  float d = sqrtf(normal[0] * normal[0] + normal[1] * normal[1] + normal[2] * normal[2]);
+  normal[0] /= d;
+  normal[1] /= d;
+  normal[2] /= d;
+
+  /* Get central point of bounding box */
+  float center[3];
+  center[0] = 0.5f * (xmin + xmax);
+  center[1] = 0.5f * (ymin + ymax);
+  center[2] = 0.5f * (zmin + zmax);
+
+  /* Check distance to corners of bounding box along the normal */
+  float d000 = getDistance2Corner(normal, center, xmin, ymin, zmin);
+  float d100 = getDistance2Corner(normal, center, xmax, ymin, zmin);
+  float d010 = getDistance2Corner(normal, center, xmin, ymax, zmin);
+  float d001 = getDistance2Corner(normal, center, xmin, ymin, zmax);
+  float d110 = getDistance2Corner(normal, center, xmax, ymax, zmin);
+  float d101 = getDistance2Corner(normal, center, xmax, ymin, zmax);
+  float d011 = getDistance2Corner(normal, center, xmin, ymax, zmax);
+  float d111 = getDistance2Corner(normal, center, xmax, ymax, zmax);
+  unsigned char farestCorner = getFarestCorner(d000, d100, d010, d001, d110, d101, d011, d111);
+
+  /* Choose axes for the grid. */
+  float LX1[6], LX2[6], LX3[6]; /* Lines along X direction */
+  float LY1[6], LY2[6], LY3[6]; /* Lines along Y direction */
+  float LZ1[6], LZ2[6], LZ3[6]; /* Lines along Z direction */
+  unsigned char LX1draw, LX2draw, LX3draw; /* Allows drawing of X-line (000 - 100 is forbidden) */
+  unsigned char LY1draw, LY2draw, LY3draw; /* Allows drawing of Y-line (000 - 010 is forbidden) */
+  unsigned char LZ1draw, LZ2draw, LZ3draw; /* Allows drawing of Z-line (000 - 001 is forbidden) */
+
+  /* The first axis will be used for drawing the text and the values. */
+  switch (farestCorner)
+  {
+    case 1: /* d000 */
     {
-        case 1: /* d000 */
-        {
-            /* 001 - 101 */
-            LX1draw = 1;
-            LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmax; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmax;
-            /* 000 - 100 */
-            LX2draw = 0; /* forbidden! */
-            LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmin;
-            /* 010 - 110 */
-            LX3draw = 1;
-            LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmin; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmin;
-
-            /* 100 - 110 */
-            LY1draw = 1;
-            LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
-            /* 000 - 010 */
-            LY2draw = 0; /* forbidden! */
-            LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmin;
-            /* 001 - 011 */
-            LY3draw = 1;
-            LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
-
-            /* 100 - 101 */
-            LZ1draw = 1;
-            LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
-            /* 000 - 001 */
-            LZ2draw = 0; /* forbidden! */
-            LZ2[0] = xmin; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymin; LZ2[5] = zmax;
-            /* 010 - 011 */
-            LZ3draw = 1;
-            LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
-
-            break;
-        }
-        case 2: /* d100 */
-        {
-            /* 001 - 101 */
-            LX1draw = 1;
-            LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmax; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmax;
-            /* 000 - 100 */
-            LX2draw = 0; /* forbidden! */
-            LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmin;
-            /* 010 - 110 */
-            LX3draw = 1;
-            LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmin; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmin;
-
-            /* 000 - 010 */
-            LY1draw = 0; /* forbidden! */
-            LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
-            /* 100 - 110 */
-            LY2draw = 1;
-            LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmin;
-            /* 101 - 111 */
-            LY3draw = 1;
-            LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
-
-            /* 000 - 001 */
-            LZ1draw = 0; /* forbidden! */
-            LZ1[0] = xmin; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmin; LZ1[4] = ymin; LZ1[5] = zmax;
-            /* 100 - 101 */
-            LZ2draw = 1;
-            LZ2[0] = xmax; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymin; LZ2[5] = zmax;
-            /* 110 - 111 */
-            LZ3draw = 1;
-            LZ3[0] = xmax; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmax; LZ3[4] = ymax; LZ3[5] = zmax;
-
-            break;
-        }
-        case 3: /* d010 */
-        {
-            /* 000 - 100 */
-            LX1draw = 0; /* forbidden */
-            LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
-            /* 010 - 110 */
-            LX2draw = 1;
-            LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmin;
-            /* 011 - 111 */
-            LX3draw = 1;
-            LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
-
-            /* 100 - 110 */
-            LY1draw = 1;
-            LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
-            /* 000 - 010 */
-            LY2draw = 0; /* forbidden */
-            LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmin;
-            /* 001 - 011 */
-            LY3draw = 1;
-            LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
-
-            /* 110 - 111 */
-            LZ1draw = 1;
-            LZ1[0] = xmax; LZ1[1] = ymax; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymax; LZ1[5] = zmax;
-            /* 010 - 011 */
-            LZ2draw = 1;
-            LZ2[0] = xmin; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymax; LZ2[5] = zmax;
-            /* 000 - 001 */
-            LZ3draw = 0; /* forbidden */
-            LZ3[0] = xmin; LZ3[1] = ymin; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymin; LZ3[5] = zmax;
-
-            break;
-        }
-        case 4: /* d001 */
-        {
-            /* 000 - 100 */
-            LX1draw = 0; /* forbidden */
-            LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
-            /* 001 - 101 */
-            LX2draw = 1;
-            LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmax;
-            /* 011 - 111 */
-            LX3draw = 1;
-            LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
-
-            /* 000 - 010 */
-            LY1draw = 0; /* forbidden */
-            LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
-            /* 001 - 011 */
-            LY2draw = 1;
-            LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmax;
-            /* 101 - 111 */
-            LY3draw = 1;
-            LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
-
-            /* 100 - 101 */
-            LZ1draw = 1;
-            LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
-            /* 000 - 001 */
-            LZ2draw = 0; /* forbidden */
-            LZ2[0] = xmin; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymin; LZ2[5] = zmax;
-            /* 010 - 011 */
-            LZ3draw = 1;
-            LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
-
-            break;
-        }
-        case 5: /* d110 */
-        {
-            /* 000 - 100 */
-            LX1draw = 0; /* forbidden */
-            LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
-            /* 010 - 110 */
-            LX2draw = 1;
-            LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmin;
-            /* 011 - 111 */
-            LX3draw = 1;
-            LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
-
-            /* 000 - 010 */
-            LY1draw = 0; /* forbidden */
-            LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
-            /* 100 - 110 */
-            LY2draw = 1;
-            LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmin;
-            /* 101 - 111 */
-            LY3draw = 1;
-            LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
-
-            /* 100 - 101 */
-            LZ1draw = 1;
-            LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
-            /* 110 - 111 */
-            LZ2draw = 1;
-            LZ2[0] = xmax; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymax; LZ2[5] = zmax;
-            /* 010 - 011 */
-            LZ3draw = 1;
-            LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
-
-            break;
-        }
-        case 6: /* d101 */
-        {
-            /* 000 - 100 */
-            LX1draw = 0; /* forbidden */
-            LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
-            /* 001 - 101 */
-            LX2draw = 1;
-            LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmax;
-            /* 011 - 111 */
-            LX3draw = 1;
-            LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
-
-            /* 100 - 110 */
-            LY1draw = 1;
-            LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
-            /* 101 - 111 */
-            LY2draw = 1;
-            LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmax;
-            /* 001 - 011 */
-            LY3draw = 1;
-            LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
-
-            /* 000 - 001 */
-            LZ1draw = 0; /* forbidden */
-            LZ1[0] = xmin; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmin; LZ1[4] = ymin; LZ1[5] = zmax;
-            /* 100 - 101 */
-            LZ2draw = 1;
-            LZ2[0] = xmax; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymin; LZ2[5] = zmax;
-            /* 110 - 111 */
-            LZ3draw = 1;
-            LZ3[0] = xmax; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmax; LZ3[4] = ymax; LZ3[5] = zmax;
-
-            break;
-        }
-        case 7: /* d011 */
-        {
-            /* 001 - 101 */
-            LX1draw = 1;
-            LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmax; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmax;
-            /* 011 - 111 */
-            LX2draw = 1;
-            LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmax;
-            /* 010 - 110 */
-            LX3draw = 1;
-            LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmin; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmin;
-
-            /* 000 - 010 */
-            LY1draw = 0; /* forbidden */
-            LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
-            /* 001 - 011 */
-            LY2draw = 1;
-            LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmax;
-            /* 101 - 111 */
-            LY3draw = 1;
-            LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
-
-            /* 000 - 001 */
-            LZ1draw = 0; /* forbidden */
-            LZ1[0] = xmin; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmin; LZ1[4] = ymin; LZ1[5] = zmax;
-            /* 010 - 011 */
-            LZ2draw = 1;
-            LZ2[0] = xmin; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymax; LZ2[5] = zmax;
-            /* 110 - 111 */
-            LZ3draw = 1;
-            LZ3[0] = xmax; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmax; LZ3[4] = ymax; LZ3[5] = zmax;
-
-            break;
-        }
-        case 8: /* d111 */
-        {
-            /* 010 - 110 */
-            LX1draw = 1;
-            LX1[0] = xmin; LX1[1] = ymax; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymax; LX1[5] = zmin;
-            /* 011 - 111 */
-            LX2draw = 1;
-            LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmax;
-            /* 001 - 101 */
-            LX3draw = 1;
-            LX3[0] = xmin; LX3[1] = ymin; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymin; LX3[5] = zmax;
-
-            /* 100 - 110 */
-            LY1draw = 1;
-            LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
-            /* 101 - 111 */
-            LY2draw = 1;
-            LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmax;
-            /* 001 - 011 */
-            LY3draw = 1;
-            LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
-
-            /* 100 - 101 */
-            LZ1draw = 1;
-            LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
-            /* 110 - 111 */
-            LZ2draw = 1;
-            LZ2[0] = xmax; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymax; LZ2[5] = zmax;
-            /* 010 - 011 */
-            LZ3draw = 1;
-            LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
-
-            break;
-        }
+      /* 001 - 101 */
+      LX1draw = 1;
+      LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmax; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmax;
+      /* 000 - 100 */
+      LX2draw = 0; /* forbidden! */
+      LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmin;
+      /* 010 - 110 */
+      LX3draw = 1;
+      LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmin; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmin;
+
+      /* 100 - 110 */
+      LY1draw = 1;
+      LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
+      /* 000 - 010 */
+      LY2draw = 0; /* forbidden! */
+      LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmin;
+      /* 001 - 011 */
+      LY3draw = 1;
+      LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
+
+      /* 100 - 101 */
+      LZ1draw = 1;
+      LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
+      /* 000 - 001 */
+      LZ2draw = 0; /* forbidden! */
+      LZ2[0] = xmin; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymin; LZ2[5] = zmax;
+      /* 010 - 011 */
+      LZ3draw = 1;
+      LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
+
+      break;
     }
+    case 2: /* d100 */
+    {
+      /* 001 - 101 */
+      LX1draw = 1;
+      LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmax; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmax;
+      /* 000 - 100 */
+      LX2draw = 0; /* forbidden! */
+      LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmin;
+      /* 010 - 110 */
+      LX3draw = 1;
+      LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmin; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmin;
+
+      /* 000 - 010 */
+      LY1draw = 0; /* forbidden! */
+      LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
+      /* 100 - 110 */
+      LY2draw = 1;
+      LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmin;
+      /* 101 - 111 */
+      LY3draw = 1;
+      LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
+
+      /* 000 - 001 */
+      LZ1draw = 0; /* forbidden! */
+      LZ1[0] = xmin; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmin; LZ1[4] = ymin; LZ1[5] = zmax;
+      /* 100 - 101 */
+      LZ2draw = 1;
+      LZ2[0] = xmax; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymin; LZ2[5] = zmax;
+      /* 110 - 111 */
+      LZ3draw = 1;
+      LZ3[0] = xmax; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmax; LZ3[4] = ymax; LZ3[5] = zmax;
+
+      break;
+    }
+    case 3: /* d010 */
+    {
+      /* 000 - 100 */
+      LX1draw = 0; /* forbidden */
+      LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
+      /* 010 - 110 */
+      LX2draw = 1;
+      LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmin;
+      /* 011 - 111 */
+      LX3draw = 1;
+      LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
+
+      /* 100 - 110 */
+      LY1draw = 1;
+      LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
+      /* 000 - 010 */
+      LY2draw = 0; /* forbidden */
+      LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmin;
+      /* 001 - 011 */
+      LY3draw = 1;
+      LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
+
+      /* 110 - 111 */
+      LZ1draw = 1;
+      LZ1[0] = xmax; LZ1[1] = ymax; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymax; LZ1[5] = zmax;
+      /* 010 - 011 */
+      LZ2draw = 1;
+      LZ2[0] = xmin; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymax; LZ2[5] = zmax;
+      /* 000 - 001 */
+      LZ3draw = 0; /* forbidden */
+      LZ3[0] = xmin; LZ3[1] = ymin; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymin; LZ3[5] = zmax;
+
+      break;
+    }
+    case 4: /* d001 */
+    {
+      /* 000 - 100 */
+      LX1draw = 0; /* forbidden */
+      LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
+      /* 001 - 101 */
+      LX2draw = 1;
+      LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmax;
+      /* 011 - 111 */
+      LX3draw = 1;
+      LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
+
+      /* 000 - 010 */
+      LY1draw = 0; /* forbidden */
+      LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
+      /* 001 - 011 */
+      LY2draw = 1;
+      LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmax;
+      /* 101 - 111 */
+      LY3draw = 1;
+      LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
+
+      /* 100 - 101 */
+      LZ1draw = 1;
+      LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
+      /* 000 - 001 */
+      LZ2draw = 0; /* forbidden */
+      LZ2[0] = xmin; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymin; LZ2[5] = zmax;
+      /* 010 - 011 */
+      LZ3draw = 1;
+      LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
+
+      break;
+    }
+    case 5: /* d110 */
+    {
+      /* 000 - 100 */
+      LX1draw = 0; /* forbidden */
+      LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
+      /* 010 - 110 */
+      LX2draw = 1;
+      LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmin;
+      /* 011 - 111 */
+      LX3draw = 1;
+      LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
+
+      /* 000 - 010 */
+      LY1draw = 0; /* forbidden */
+      LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
+      /* 100 - 110 */
+      LY2draw = 1;
+      LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmin;
+      /* 101 - 111 */
+      LY3draw = 1;
+      LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
+
+      /* 100 - 101 */
+      LZ1draw = 1;
+      LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
+      /* 110 - 111 */
+      LZ2draw = 1;
+      LZ2[0] = xmax; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymax; LZ2[5] = zmax;
+      /* 010 - 011 */
+      LZ3draw = 1;
+      LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
+
+      break;
+    }
+    case 6: /* d101 */
+    {
+      /* 000 - 100 */
+      LX1draw = 0; /* forbidden */
+      LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
+      /* 001 - 101 */
+      LX2draw = 1;
+      LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmax;
+      /* 011 - 111 */
+      LX3draw = 1;
+      LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
+
+      /* 100 - 110 */
+      LY1draw = 1;
+      LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
+      /* 101 - 111 */
+      LY2draw = 1;
+      LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmax;
+      /* 001 - 011 */
+      LY3draw = 1;
+      LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
+
+      /* 000 - 001 */
+      LZ1draw = 0; /* forbidden */
+      LZ1[0] = xmin; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmin; LZ1[4] = ymin; LZ1[5] = zmax;
+      /* 100 - 101 */
+      LZ2draw = 1;
+      LZ2[0] = xmax; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymin; LZ2[5] = zmax;
+      /* 110 - 111 */
+      LZ3draw = 1;
+      LZ3[0] = xmax; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmax; LZ3[4] = ymax; LZ3[5] = zmax;
+
+      break;
+    }
+    case 7: /* d011 */
+    {
+      /* 001 - 101 */
+      LX1draw = 1;
+      LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmax; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmax;
+      /* 011 - 111 */
+      LX2draw = 1;
+      LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmax;
+      /* 010 - 110 */
+      LX3draw = 1;
+      LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmin; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmin;
+
+      /* 000 - 010 */
+      LY1draw = 0; /* forbidden */
+      LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
+      /* 001 - 011 */
+      LY2draw = 1;
+      LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmax;
+      /* 101 - 111 */
+      LY3draw = 1;
+      LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
+
+      /* 000 - 001 */
+      LZ1draw = 0; /* forbidden */
+      LZ1[0] = xmin; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmin; LZ1[4] = ymin; LZ1[5] = zmax;
+      /* 010 - 011 */
+      LZ2draw = 1;
+      LZ2[0] = xmin; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymax; LZ2[5] = zmax;
+      /* 110 - 111 */
+      LZ3draw = 1;
+      LZ3[0] = xmax; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmax; LZ3[4] = ymax; LZ3[5] = zmax;
+
+      break;
+    }
+    case 8: /* d111 */
+    {
+      /* 010 - 110 */
+      LX1draw = 1;
+      LX1[0] = xmin; LX1[1] = ymax; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymax; LX1[5] = zmin;
+      /* 011 - 111 */
+      LX2draw = 1;
+      LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmax;
+      /* 001 - 101 */
+      LX3draw = 1;
+      LX3[0] = xmin; LX3[1] = ymin; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymin; LX3[5] = zmax;
+
+      /* 100 - 110 */
+      LY1draw = 1;
+      LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
+      /* 101 - 111 */
+      LY2draw = 1;
+      LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmax;
+      /* 001 - 011 */
+      LY3draw = 1;
+      LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
+
+      /* 100 - 101 */
+      LZ1draw = 1;
+      LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
+      /* 110 - 111 */
+      LZ2draw = 1;
+      LZ2[0] = xmax; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymax; LZ2[5] = zmax;
+      /* 010 - 011 */
+      LZ3draw = 1;
+      LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
+
+      break;
+    }
+  }
+
+  /* Draw the graduated trihedron */
+  unsigned int i, j, offset;
+  float m1[3], m2[3];
+  float step, dx, dy, dz;
 
-    /* Draw the graduated trihedron */
+  /* Grid */
+  if (data->drawgrid)
+  {
+    glColor3fv(data->gridcolor);
+    glBegin(GL_LINES);
+    /* Boundary grid-lines */
+    if (LX1draw == 1)
+    {
+      glVertex3fv(&(LX1[0]));
+      glVertex3fv(&(LX1[3]));
+    }
+    if (LX2draw == 1)
+    {
+      glVertex3fv(&(LX2[0]));
+      glVertex3fv(&(LX2[3]));
+    }
+    if (LX3draw == 1)
+    {
+      glVertex3fv(&(LX3[0]));
+      glVertex3fv(&(LX3[3]));
+    }
+    if (LY1draw == 1)
+    {
+      glVertex3fv(&(LY1[0]));
+      glVertex3fv(&(LY1[3]));
+    }
+    if (LY2draw == 1)
+    {
+      glVertex3fv(&(LY2[0]));
+      glVertex3fv(&(LY2[3]));
+    }
+    if (LY3draw == 1)
+    {
+      glVertex3fv(&(LY3[0]));
+      glVertex3fv(&(LY3[3]));
+    }
+    if (LZ1draw == 1)
+    {
+      glVertex3fv(&(LZ1[0]));
+      glVertex3fv(&(LZ1[3]));
+    }
+    if (LZ2draw == 1)
+    {
+      glVertex3fv(&(LZ2[0]));
+      glVertex3fv(&(LZ2[3]));
+    }
+    if (LZ3draw == 1)
+    {
+      glVertex3fv(&(LZ3[0]));
+      glVertex3fv(&(LZ3[3]));
+    }
+    glEnd();
 
-    /* Grid */
-    if (data->drawgrid)
+    /* Intermediate grid-lines */
+    /* X-Grid lines */
+    if (data->nbx > 0)
     {
-        glColor3fv(data->gridcolor);
+      i = data->drawaxes ? 1 : 0;
+      step = fabsf(LX1[3] - LX1[0]) / (float) data->nbx;
+      while (i < data->nbx)
+      {
+        glBegin(GL_LINE_STRIP);
+        glVertex3f(LX1[0] + i * step, LX1[1], LX1[2]);
+        glVertex3f(LX2[0] + i * step, LX2[1], LX2[2]);
+        glVertex3f(LX3[0] + i * step, LX3[1], LX3[2]);
+        glEnd();
+        i++;
+      }
+    }
+    /* Y-Grid lines */
+    if (data->nby > 0)
+    {
+      i = data->drawaxes ? 1 : 0;
+      step = fabsf(LY1[4] - LY1[1]) / (float) data->nby;
+      while (i < data->nby)
+      {
+        glBegin(GL_LINE_STRIP);
+        glVertex3f(LY1[0], LY1[1] + i * step, LY1[2]);
+        glVertex3f(LY2[0], LY2[1] + i * step, LY2[2]);
+        glVertex3f(LY3[0], LY3[1] + i * step, LY3[2]);
+        glEnd();
+        i++;
+      }
+    }
+    /* Z-Grid lines */
+    if (data->nbz > 0)
+    {
+      i = data->drawaxes ? 1 : 0;
+      step = fabsf(LZ1[5] - LZ1[2]) / (float) data->nbz;
+      while (i < data->nbz)
+      {
+        glBegin(GL_LINE_STRIP);
+        glVertex3f(LZ1[0], LZ1[1], LZ1[2] + i * step);
+        glVertex3f(LZ2[0], LZ2[1], LZ2[2] + i * step);
+        glVertex3f(LZ3[0], LZ3[1], LZ3[2] + i * step);
+        glEnd();
+        i++;
+      }
+    }
+  }
+
+  /* Axes (arrows) */
+  if (data->drawaxes)
+  {
+    /* X-axis */
+    glColor3fv(data->xcolor);
+    drawArrow(xmin, ymin, zmin, xmax, ymin, zmin, normal[0], normal[1], normal[2]);
+
+    /* Y-axis */
+    glColor3fv(data->ycolor);
+    drawArrow(xmin, ymin, zmin, xmin, ymax, zmin, normal[0], normal[1], normal[2]);
+
+    /* Z-axis */
+    glColor3fv(data->zcolor);
+    drawArrow(xmin, ymin, zmin, xmin, ymin, zmax, normal[0], normal[1], normal[2]);
+  }
+
+  /* Names of axes & values */
+  char textValue[128];
+  wchar_t wtextValue[128];
+
+  if (data->xdrawname || data->xdrawvalues)
+  {
+    /* Middle point of the first X-axis */
+    m1[0] = 0.5f * (LX1[0] + LX1[3]);
+    m1[1] = 0.5f * (LX1[1] + LX1[4]);
+    m1[2] = 0.5f * (LX1[2] + LX1[5]);
+
+    /* Middle point of the second X-axis */
+    m2[0] = 0.5f * (LX2[0] + LX2[3]);
+    m2[1] = 0.5f * (LX2[1] + LX2[4]);
+    m2[2] = 0.5f * (LX2[2] + LX2[5]);
+
+    /* Apply offset to m1 */
+    dy = m1[1] - m2[1];
+    if (fabsf(dy) > 1.e-7f)
+    {
+      dy = (dy > 0.0f)? 1.0f : -1.0f;
+    }
+    dz = m1[2] - m2[2];
+    if (fabsf(dz) > 1.e-7f)
+    {
+      dz = (dz > 0.0f)? 1.0f : -1.0f;
+    }
+    m2[1] = dpix * dy;
+    m2[2] = dpix * dz;
+
+    /* Name of X-axis */
+    if (data->xdrawname)
+    {
+      glColor3fv(data->xnamecolor);
+      offset = data->xaxisoffset + data->xtickmarklength;
+      drawText(data->xname, data->fontOfNames, data->styleOfNames, data->sizeOfNames, 
+               m1[0], m1[1] + offset * m2[1], m1[2] + offset * m2[2]);
+    }
+
+    /* X-values */
+    if (data->xdrawvalues && data->nbx > 0)
+    {
+      glColor3fv(data->xcolor);
+
+      i = 0;
+      step = fabsf(LX1[3] - LX1[0]) / (float) data->nbx;
+      offset = data->xoffset + data->xtickmarklength;
+      while (i <= data->nbx)
+      {
+        sprintf(textValue, "%g", LX1[0] + i * step);
+        j = 0; while (wtextValue[j] = textValue[j]) j++;
+        drawText(wtextValue, data->fontOfValues, data->styleOfValues, data->sizeOfValues, 
+                 LX1[0] + i * step, m1[1] + offset * m2[1], m1[2] + offset * m2[2]);
+        i++;
+      }
+    }
+
+    /* X-tickmark */
+    if (data->xdrawtickmarks && data->nbx > 0)
+    {
+      glColor3fv(data->gridcolor);
+
+      i = 0;
+      step = fabsf(LX1[3] - LX1[0]) / (float) data->nbx;
+      while (i <= data->nbx)
+      {
         glBegin(GL_LINES);
-            /* Boundary grid-lines */
-            if (LX1draw == 1)
-            {
-                glVertex3fv(&(LX1[0]));
-                glVertex3fv(&(LX1[3]));
-            }
-            if (LX2draw == 1)
-            {
-                glVertex3fv(&(LX2[0]));
-                glVertex3fv(&(LX2[3]));
-            }
-            if (LX3draw == 1)
-            {
-                glVertex3fv(&(LX3[0]));
-                glVertex3fv(&(LX3[3]));
-            }
-            if (LY1draw == 1)
-            {
-                glVertex3fv(&(LY1[0]));
-                glVertex3fv(&(LY1[3]));
-            }
-            if (LY2draw == 1)
-            {
-                glVertex3fv(&(LY2[0]));
-                glVertex3fv(&(LY2[3]));
-            }
-            if (LY3draw == 1)
-            {
-                glVertex3fv(&(LY3[0]));
-                glVertex3fv(&(LY3[3]));
-            }
-            if (LZ1draw == 1)
-            {
-                glVertex3fv(&(LZ1[0]));
-                glVertex3fv(&(LZ1[3]));
-            }
-            if (LZ2draw == 1)
-            {
-                glVertex3fv(&(LZ2[0]));
-                glVertex3fv(&(LZ2[3]));
-            }
-            if (LZ3draw == 1)
-            {
-                glVertex3fv(&(LZ3[0]));
-                glVertex3fv(&(LZ3[3]));
-            }
+        glVertex3f(LX1[0] + i * step, m1[1],                                 m1[2]);
+        glVertex3f(LX1[0] + i * step, m1[1] + data->xtickmarklength * m2[1], m1[2] + data->xtickmarklength * m2[2]);
         glEnd();
+        i++;
+      }
+    }
+  }
+
+  if (data->ydrawname || data->ydrawvalues)
+  {
+    /* Middle point of the first Y-axis */
+    m1[0] = 0.5f * (LY1[0] + LY1[3]);
+    m1[1] = 0.5f * (LY1[1] + LY1[4]);
+    m1[2] = 0.5f * (LY1[2] + LY1[5]);
+
+    /* Middle point of the second Y-axis */
+    m2[0] = 0.5f * (LY2[0] + LY2[3]);
+    m2[1] = 0.5f * (LY2[1] + LY2[4]);
+    m2[2] = 0.5f * (LY2[2] + LY2[5]);
+
+    /* Apply offset to m1 */
+    dx = m1[0] - m2[0];
+    if (fabsf(dx) > 1.e-7f)
+    {
+      dx = (dx > 0.0f)? 1.0f : -1.0f;
+    }
+    dz = m1[2] - m2[2];
+    if (fabsf(dz) > 1.e-7f)
+    {
+      dz = (dz > 0.0f)? 1.0f : -1.0f;
+    }
+
+    m2[0] = dpix * dx;
+    m2[2] = dpix * dz;
 
-        /* Intermediate grid-lines */
-        /* X-Grid lines */
-        if (data->nbx > 0)
-        {
-            i = data->drawaxes ? 1 : 0;
-            step = fabsf(LX1[3] - LX1[0]) / (float) data->nbx;
-            while (i < data->nbx)
-            {
-                glBegin(GL_LINE_STRIP);
-                    glVertex3f(LX1[0] + i * step, LX1[1], LX1[2]);
-                    glVertex3f(LX2[0] + i * step, LX2[1], LX2[2]);
-                    glVertex3f(LX3[0] + i * step, LX3[1], LX3[2]);
-                glEnd();
-                i = i + 1;
-            }
-        }
-        /* Y-Grid lines */
-        if (data->nby > 0)
-        {
-            i = data->drawaxes ? 1 : 0;
-            step = fabsf(LY1[4] - LY1[1]) / (float) data->nby;
-            while (i < data->nby)
-            {
-                glBegin(GL_LINE_STRIP);
-                    glVertex3f(LY1[0], LY1[1] + i * step, LY1[2]);
-                    glVertex3f(LY2[0], LY2[1] + i * step, LY2[2]);
-                    glVertex3f(LY3[0], LY3[1] + i * step, LY3[2]);
-                glEnd();
-                i = i + 1;
-            }
-        }
-        /* Z-Grid lines */
-        if (data->nbz > 0)
-        {
-            i = data->drawaxes ? 1 : 0;
-            step = fabsf(LZ1[5] - LZ1[2]) / (float) data->nbz;
-            while (i < data->nbz)
-            {
-                glBegin(GL_LINE_STRIP);
-                    glVertex3f(LZ1[0], LZ1[1], LZ1[2] + i * step);
-                    glVertex3f(LZ2[0], LZ2[1], LZ2[2] + i * step);
-                    glVertex3f(LZ3[0], LZ3[1], LZ3[2] + i * step);
-                glEnd();
-                i = i + 1;
-            }
-        }
+    /* Name of Y-axis */
+    if (data->ydrawname)
+    {
+      glColor3fv(data->ynamecolor);
+      offset = data->yaxisoffset + data->ytickmarklength;
+      drawText(data->yname, data->fontOfNames, data->styleOfNames, data->sizeOfNames, 
+               m1[0] + offset * m2[0], m1[1], m1[2] + offset * m2[2]);
     }
 
-    /* Axes (arrows) */
-    if (data->drawaxes)
+    /* Y-values */
+    if (data->ydrawvalues && data->nby > 0)
     {
-        /* X-axis */
-        glColor3fv(data->xcolor);
-        drawArrow(xmin, ymin, zmin, xmax, ymin, zmin, normal[0], normal[1], normal[2]);
-    
-        /* Y-axis */
-        glColor3fv(data->ycolor);
-        drawArrow(xmin, ymin, zmin, xmin, ymax, zmin, normal[0], normal[1], normal[2]);
-    
-        /* Z-axis */
-        glColor3fv(data->zcolor);
-        drawArrow(xmin, ymin, zmin, xmin, ymin, zmax, normal[0], normal[1], normal[2]);
+      glColor3fv(data->ycolor);
+
+      i = 0;
+      step = fabsf(LY1[4] - LY1[1]) / (float) data->nby;
+      offset = data->yoffset + data->ytickmarklength;
+      while (i <= data->nby)
+      {
+        sprintf(textValue, "%g", LY1[1] + i * step);
+        j = 0; while (wtextValue[j] = textValue[j]) j++;
+        drawText(wtextValue, data->fontOfValues, data->styleOfValues, data->sizeOfValues, 
+                 m1[0] + offset * m2[0], LY1[1] + i * step, m1[2] + offset * m2[2]);
+        i++;
+      }
+    }
+
+    /* Y-tickmark */
+    if (data->ydrawtickmarks && data->nby > 0)
+    {
+      glColor3fv(data->gridcolor);
+
+      i = 0;
+      step = fabsf(LY1[4] - LY1[1]) / (float) data->nby;
+      while (i <= data->nby)
+      {
+        glBegin(GL_LINES);
+        glVertex3f(m1[0],                                 LY1[1] + i * step, m1[2]);
+        glVertex3f(m1[0] + data->ytickmarklength * m2[0], LY1[1] + i * step, m1[2] + data->ytickmarklength * m2[2]);
+        glEnd();
+        i++;
+      }
     }
-    /* Names of axes & values*/
+  }
+
+  if (data->zdrawname || data->zdrawvalues)
+  {
+    /* Middle point of the first Z-axis */
+    m1[0] = 0.5f * (LZ1[0] + LZ1[3]);
+    m1[1] = 0.5f * (LZ1[1] + LZ1[4]);
+    m1[2] = 0.5f * (LZ1[2] + LZ1[5]);
+
+    /* Middle point of the second Z-axis */
+    m2[0] = 0.5f * (LZ2[0] + LZ2[3]);
+    m2[1] = 0.5f * (LZ2[1] + LZ2[4]);
+    m2[2] = 0.5f * (LZ2[2] + LZ2[5]);
+
+    /* Apply offset to m1 */
+    dx = m1[0] - m2[0];
+    if (fabsf(dx) > 1.e-7f)
+    {
+      dx = (dx > 0.0f)? 1.0f : -1.0f;
+    }
+    dy = m1[1] - m2[1];
+    if (fabsf(dy) > 1.e-7f)
+    {
+      dy = (dy > 0.0f)? 1.0f : -1.0f;
+    }
+
+    m2[0] = dpix * dx;
+    m2[1] = dpix * dy;
 
-    if (data->xdrawname || data->xdrawvalues)
+    /* Name of Z-axis */
+    if (data->zdrawname)
     {
-        /* Middle point of the first X-axis */
-        m1[0] = 0.5f * (LX1[0] + LX1[3]);
-        m1[1] = 0.5f * (LX1[1] + LX1[4]);
-        m1[2] = 0.5f * (LX1[2] + LX1[5]);
-
-        /* Middle point of the second X-axis */
-        m2[0] = 0.5f * (LX2[0] + LX2[3]);
-        m2[1] = 0.5f * (LX2[1] + LX2[4]);
-        m2[2] = 0.5f * (LX2[2] + LX2[5]);
-
-        /* Apply offset to m1 */
-        dy = m1[1] - m2[1];
-        if (fabsf(dy) > 1.e-7f)
-        {
-            if (dy > 0.0f)
-                dy = 1.0f;
-            else 
-                dy = -1.0f;
-        }
-        dz = m1[2] - m2[2];
-        if (fabsf(dz) > 1.e-7f)
-        {
-            if (dz > 0.0f)
-                dz = 1.0f;
-            else
-                dz = -1.0f;
-        }
-
-        m2[1] = dpix * dy;
-        m2[2] = dpix * dz;
-
-        /* Name of X-axis */
-        if (data->xdrawname)
-        {
-            glColor3fv(data->xnamecolor);
-            offset = data->xaxisoffset + data->xtickmarklength;
-            drawText(data->xname, data->fontOfNames, data->styleOfNames, data->sizeOfNames, 
-                     m1[0], m1[1] + offset * m2[1], m1[2] + offset * m2[2]);
-        }
-
-        /* X-values */
-        if (data->xdrawvalues && data->nbx > 0)
-        {
-            glColor3fv(data->xcolor);
-
-            i = 0;
-            step = fabsf(LX1[3] - LX1[0]) / (float) data->nbx;
-            offset = data->xoffset + data->xtickmarklength;
-            while (i <= data->nbx)
-            {
-                sprintf(textValue, "%g", LX1[0] + i * step);
-                drawText(textValue, data->fontOfValues, data->styleOfValues, data->sizeOfValues, 
-                         LX1[0] + i * step, m1[1] + offset * m2[1], m1[2] + offset * m2[2]);
-                i = i + 1;
-            }
-        }
-
-        /* X-tickmark */
-        if (data->xdrawtickmarks && data->nbx > 0)
-        {
-            glColor3fv(data->gridcolor);
-
-            i = 0;
-            step = fabsf(LX1[3] - LX1[0]) / (float) data->nbx;
-            while (i <= data->nbx)
-            {
-                glBegin(GL_LINES);
-                    glVertex3f(LX1[0] + i * step, m1[1],                                 m1[2]);
-                    glVertex3f(LX1[0] + i * step, m1[1] + data->xtickmarklength * m2[1], m1[2] + data->xtickmarklength * m2[2]);
-                glEnd();
-                i = i + 1;
-            }
-        }
+      glColor3fv(data->znamecolor);
+      offset = data->zaxisoffset + data->ztickmarklength;
+      drawText(data->zname, data->fontOfNames, data->styleOfNames, data->sizeOfNames, 
+               m1[0] + offset * m2[0], m1[1] + offset * m2[1], m1[2]);
     }
 
-    if (data->ydrawname || data->ydrawvalues)
+    /* Z-values */
+    if (data->zdrawvalues && data->nbz > 0)
     {
-        /* Middle point of the first Y-axis */
-        m1[0] = 0.5f * (LY1[0] + LY1[3]);
-        m1[1] = 0.5f * (LY1[1] + LY1[4]);
-        m1[2] = 0.5f * (LY1[2] + LY1[5]);
-
-        /* Middle point of the second Y-axis */
-        m2[0] = 0.5f * (LY2[0] + LY2[3]);
-        m2[1] = 0.5f * (LY2[1] + LY2[4]);
-        m2[2] = 0.5f * (LY2[2] + LY2[5]);
-
-        /* Apply offset to m1 */
-        dx = m1[0] - m2[0];
-        if (fabsf(dx) > 1.e-7f)
-        {
-            if (dx > 0.0f)
-                dx = 1.0f;
-            else
-                dx = -1.0f;
-        }
-        dz = m1[2] - m2[2];
-        if (fabsf(dz) > 1.e-7f)
-        {
-            if (dz > 0.0f)
-                dz = 1.0f;
-            else
-                dz = -1.0f;
-        }
-
-        m2[0] = dpix * dx;
-        m2[2] = dpix * dz;
-
-        /* Name of Y-axis */
-        if (data->ydrawname)
-        {
-            glColor3fv(data->ynamecolor);
-            offset = data->yaxisoffset + data->ytickmarklength;
-            drawText(data->yname, data->fontOfNames, data->styleOfNames, data->sizeOfNames, 
-                     m1[0] + offset * m2[0], m1[1], m1[2] + offset * m2[2]);
-        }
-
-        /* Y-values */
-        if (data->ydrawvalues && data->nby > 0)
-        {
-            glColor3fv(data->ycolor);
-
-            i = 0;
-            step = fabsf(LY1[4] - LY1[1]) / (float) data->nby;
-            offset = data->yoffset + data->ytickmarklength;
-            while (i <= data->nby)
-            {
-                sprintf(textValue, "%g", LY1[1] + i * step);
-                drawText(textValue, data->fontOfValues, data->styleOfValues, data->sizeOfValues, 
-                         m1[0] + offset * m2[0], LY1[1] + i * step, m1[2] + offset * m2[2]);
-                i = i + 1;
-            }
-        }
-
-        /* Y-tickmark */
-        if (data->ydrawtickmarks && data->nby > 0)
-        {
-            glColor3fv(data->gridcolor);
-
-            i = 0;
-            step = fabsf(LY1[4] - LY1[1]) / (float) data->nby;
-            while (i <= data->nby)
-            {
-                glBegin(GL_LINES);
-                    glVertex3f(m1[0],                                 LY1[1] + i * step, m1[2]);
-                    glVertex3f(m1[0] + data->ytickmarklength * m2[0], LY1[1] + i * step, m1[2] + data->ytickmarklength * m2[2]);
-                glEnd();
-                i = i + 1;
-            }
-        }
+      glColor3fv(data->zcolor);
+
+      i = 0;
+      step = fabsf(LZ1[5] - LZ1[2]) / (float) data->nbz;
+      offset = data->zoffset + data->ztickmarklength;
+      while (i <= data->nbz)
+      {
+        sprintf(textValue, "%g", LZ1[2] + i * step);
+        j = 0; while (wtextValue[j] = textValue[j]) j++;
+        drawText(wtextValue, data->fontOfValues, data->styleOfValues, data->sizeOfValues, 
+                 m1[0] + offset * m2[0], m1[1] + offset * m2[1], LZ1[2] + i * step);
+        i++;
+      }
     }
 
-    if (data->zdrawname || data->zdrawvalues)
+    /* Z-tickmark */
+    if (data->zdrawtickmarks && data->nbz > 0)
     {
-        /* Middle point of the first Z-axis */
-        m1[0] = 0.5f * (LZ1[0] + LZ1[3]);
-        m1[1] = 0.5f * (LZ1[1] + LZ1[4]);
-        m1[2] = 0.5f * (LZ1[2] + LZ1[5]);
-
-        /* Middle point of the second Z-axis */
-        m2[0] = 0.5f * (LZ2[0] + LZ2[3]);
-        m2[1] = 0.5f * (LZ2[1] + LZ2[4]);
-        m2[2] = 0.5f * (LZ2[2] + LZ2[5]);
-
-        /* Apply offset to m1 */
-        dx = m1[0] - m2[0];
-        if (fabsf(dx) > 1.e-7f)
-        {
-            if (dx > 0.0f)
-                dx = 1.0f;
-            else
-                dx = -1.0f;
-        }
-        dy = m1[1] - m2[1];
-        if (fabsf(dy) > 1.e-7f)
-        {
-            if (dy > 0.0f)
-                dy = 1.0f;
-            else
-                dy = -1.0f;
-        }
-
-        m2[0] = dpix * dx;
-        m2[1] = dpix * dy;
-
-        /* Name of Z-axis */
-        if (data->zdrawname)
-        {
-            glColor3fv(data->znamecolor);
-            offset = data->zaxisoffset + data->ztickmarklength;
-            drawText(data->zname, data->fontOfNames, data->styleOfNames, data->sizeOfNames, 
-                     m1[0] + offset * m2[0], m1[1] + offset * m2[1], m1[2]);
-        }
-
-        /* Z-values */
-        if (data->zdrawvalues && data->nbz > 0)
-        {
-            glColor3fv(data->zcolor);
-
-            i = 0;
-            step = fabsf(LZ1[5] - LZ1[2]) / (float) data->nbz;
-            offset = data->zoffset + data->ztickmarklength;
-            while (i <= data->nbz)
-            {
-                sprintf(textValue, "%g", LZ1[2] + i * step);
-                drawText(textValue, data->fontOfValues, data->styleOfValues, data->sizeOfValues, 
-                         m1[0] + offset * m2[0], m1[1] + offset * m2[1], LZ1[2] + i * step);
-                i = i + 1;
-            }
-        }
-
-        /* Z-tickmark */
-        if (data->zdrawtickmarks && data->nbz > 0)
-        {
-            glColor3fv(data->gridcolor);
-
-            i = 0;
-            step = fabsf(LZ1[5] - LZ1[2]) / (float) data->nbz;
-            while (i <= data->nbz)
-            {
-                glBegin(GL_LINES);
-                    glVertex3f(m1[0],                                 m1[1],                                LZ1[2] + i * step);
-                    glVertex3f(m1[0] + data->ztickmarklength * m2[0], m1[1] + data->ztickmarklength * m2[1], LZ1[2] + i * step);
-                glEnd();
-                i = i + 1;
-            }
-        }
+      glColor3fv(data->gridcolor);
+
+      i = 0;
+      step = fabsf(LZ1[5] - LZ1[2]) / (float) data->nbz;
+      while (i <= data->nbz)
+      {
+        glBegin(GL_LINES);
+        glVertex3f(m1[0],                                 m1[1],                                LZ1[2] + i * step);
+        glVertex3f(m1[0] + data->ztickmarklength * m2[0], m1[1] + data->ztickmarklength * m2[1], LZ1[2] + i * step);
+        glEnd();
+        i++;
+      }
     }
+  }
 
-    /* Activate the lighting if it was turned off by this method call */
-    if (light)
-        glEnable(GL_LIGHTING);
+  /* Activate the lighting if it was turned off by this method call */
+  if (light)
+    glEnable(GL_LIGHTING);
     
-    return TSuccess;
+  return TSuccess;
 }
 
 TStatus call_graduatedtrihedron_minmaxvalues(const float xMin,
diff --git a/src/OpenGl/OpenGl_subrs.cxx b/src/OpenGl/OpenGl_subrs.cxx
index 28c947f..ff724c8 100644
--- a/src/OpenGl/OpenGl_subrs.cxx
+++ b/src/OpenGl/OpenGl_subrs.cxx
@@ -1631,7 +1631,7 @@ call_subr_structure_exploration( Tint             Id,
           else
           {
             printf( "\tELEM_ANNO_TEXT_REL3\n" );
-            printf( "\t\tANNOTATION TEXT RELATIVE 3 %s\n",
+            printf( "\t\tANNOTATION TEXT RELATIVE 3 %S\n",
               data.atext3.string );
             printf( "\t\treference point %f %f %f\n",
               data.atext3.ref_pt.xyz[0],
diff --git a/src/OpenGl/OpenGl_text.cxx b/src/OpenGl/OpenGl_text.cxx
index 42a090e..e792e6d 100644
--- a/src/OpenGl/OpenGl_text.cxx
+++ b/src/OpenGl/OpenGl_text.cxx
@@ -49,9 +49,17 @@ xx-xx-xx : xxx ; Creation.
 #include <OpenGl_Extension.hxx>
 #include <OpenGl_Memory.hxx>
 
-
 #include <OpenGl_TextRender.hxx>
 
+struct TEL_TEXT_DATA
+{
+  TEL_POINT      attach_pt;
+  Tint           length;
+  const wchar_t *sdata;
+  IMPLEMENT_MEMORY_OPERATORS
+};
+typedef TEL_TEXT_DATA* tel_text_data;
+
 /*----------------------------------------------------------------------*/
 /*
 * Fonctions statiques
@@ -103,12 +111,6 @@ extern int    g_nDegenerateModel;
 extern float  g_fSkipRatio;
 #endif
 
-void putText( Tchar* data, Tfloat x, Tfloat y, Tfloat z )
-{
-  OpenGl_TextRender* textRender=OpenGl_TextRender::instance();
-  textRender->RenderText ( (char*)data, fontBase, 0, x, y, z );
-}
-
 /*----------------------------------------------------------------------*/
 
 MtblPtr
@@ -127,7 +129,7 @@ TextAdd( TSM_ELEM_DATA d, Tint n, cmn_key *k )
   TEL_POINT      def_pt = {{ ( float )0.0, ( float )0.0, ( float )0.0 }};
   tel_point      pt = &def_pt;
   tel_text_data  data;
-  Tchar          *str= 0;
+  Techar         *str= 0;
 
   for( i = 0; i < n; i++ )
   {
@@ -137,23 +139,27 @@ TextAdd( TSM_ELEM_DATA d, Tint n, cmn_key *k )
       pt = (tel_point)k[i]->data.pdata;
       break;
     case TEXT_STRING_ID:
-      str = (Tchar*)k[i]->data.pdata;
+      str = (Techar*)k[i]->data.pdata;
       break;
     }
   }
 
-  i = strlen((char*)str) + 1;
-
   data = new TEL_TEXT_DATA();
   if( !data )
     return TFailure;
-  data->data = new Tchar[i];
-  if( !data->data )
+
+  //szv: instead of strlen + 1
+  i = 0; while (str[i++]);
+
+  wchar_t *wstr = new wchar_t[i];
+  if( !wstr )
     return TFailure;
 
   data->attach_pt = *pt;
   data->length    = i;
-  memcpy( data->data, str, i );
+  //szv: instead of memcpy
+  i = 0; while (wstr[i++] = (wchar_t)(*str++));
+  data->sdata = wstr;
 
   ((tsm_elem_data)(d.pdata))->pdata = data;
 
@@ -225,6 +231,8 @@ TextDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
     if (flag_zbuffer) glDisable(GL_DEPTH_TEST);
   }
 
+  OpenGl_TextRender* textRender=OpenGl_TextRender::instance();
+
   /* display type of text */
   if (display_type != ASPECT_TODT_NORMAL)
   {
@@ -237,7 +245,6 @@ TextDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
     glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
     glGetDoublev (GL_PROJECTION_MATRIX, projMatrix);
 
-    OpenGl_TextRender* textRender=OpenGl_TextRender::instance();
     switch (display_type) 
     {
     case ASPECT_TODT_BLEND:            
@@ -272,7 +279,7 @@ TextDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
 #endif
       break;
     case ASPECT_TODT_SUBTITLE:
-      textRender->StringSize((char *)d->data, &sWidth, &sAscent, &sDescent);
+      textRender->StringSize(d->sdata, &sWidth, &sAscent, &sDescent);
       objrefX = (float)d->attach_pt.xyz[0];   
       objrefY = (float)d->attach_pt.xyz[1];   
       objrefZ = (float)d->attach_pt.xyz[2];
@@ -326,30 +333,30 @@ TextDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
         &objX, &objY, &objZ);
 
       glColor3fv( colours.rgb );
-      putText( d->data, (float)objX, (float)objY,(float)objZ );
+      textRender->RenderText( d->sdata, fontBase, 0, (float)objX, (float)objY,(float)objZ );
       winx = winx1-1;
       winy = winy1-1;
       status = gluUnProject (winx, winy, winz, modelMatrix, projMatrix, viewport,
         &objX, &objY, &objZ);
 
-      putText( d->data, (float)objX, (float)objY,(float)objZ );
+      textRender->RenderText( d->sdata, fontBase, 0, (float)objX, (float)objY,(float)objZ );
       winx = winx1-1;
       winy = winy1+1;
       status = gluUnProject (winx, winy, winz, modelMatrix, projMatrix, viewport,
         &objX, &objY, &objZ); 
 
-      putText( d->data, (float)objX, (float)objY,(float)objZ );
+      textRender->RenderText( d->sdata, fontBase, 0, (float)objX, (float)objY,(float)objZ );
       winx = winx1+1;
       winy = winy1-1;
       status = gluUnProject (winx, winy, winz, modelMatrix, projMatrix, viewport,
         &objX, &objY, &objZ);
-      putText( d->data, (float)objX, (float)objY,(float)objZ );
+      textRender->RenderText( d->sdata, fontBase, 0, (float)objX, (float)objY,(float)objZ );
       break;
     }
   }
 
   glColor3fv( colour.rgb );
-  putText( d->data, (float)d->attach_pt.xyz[0], (float)d->attach_pt.xyz[1],(float)d->attach_pt.xyz[2] );
+  textRender->RenderText( d->sdata, fontBase, 0, (float)d->attach_pt.xyz[0], (float)d->attach_pt.xyz[1],(float)d->attach_pt.xyz[2] );
   /* maj attributs */   
   if (flag_zbuffer) glEnable(GL_DEPTH_TEST); 
   if (display_type == ASPECT_TODT_BLEND) 
@@ -370,8 +377,12 @@ TextDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
 static  TStatus
 TextDelete( TSM_ELEM_DATA data, Tint n, cmn_key *k )
 {
-  if (data.pdata)
-    free(data.pdata);
+  tel_text_data d = (tel_text_data)data.pdata;
+  if (d)
+  {
+    delete[] d->sdata;
+    free(d);
+  }
   return TSuccess;
 }
 
@@ -385,7 +396,7 @@ TextPrint( TSM_ELEM_DATA data, Tint n, cmn_key *k )
   p = (tel_text_data)data.pdata;
 
   fprintf( stdout, "TelText.\n" );
-  fprintf( stdout, "\t\tString : %s\n", p->data );
+  fprintf( stdout, "\t\tString : %S\n", p->sdata );
   fprintf( stdout, "\t\tAttach Point : %f %f %f\n", p->attach_pt.xyz[0],
     p->attach_pt.xyz[1],
     p->attach_pt.xyz[2] );
@@ -406,7 +417,7 @@ TextInquire( TSM_ELEM_DATA data, Tint n, cmn_key *k )
 
   d = (tel_text_data)data.pdata;
 
-  size_reqd = d->length;
+  size_reqd = sizeof(Techar)*d->length;
 
   for( i = 0; i < n; i++ )
   {
@@ -429,12 +440,15 @@ TextInquire( TSM_ELEM_DATA data, Tint n, cmn_key *k )
 
         if( c->size >= size_reqd )
         {
-          w->atext3.string = c->buf;
+          w->atext3.string = (Techar*)c->buf;
           w->atext3.ref_pt = d->attach_pt;
           w->atext3.anno.xyz[0] = ( float )0.0;
           w->atext3.anno.xyz[1] = ( float )0.0;
           w->atext3.anno.xyz[2] = ( float )0.0;
-          strcpy( (char*)w->atext3.string, (char*)d->data );
+          //szv: instead of strcpy
+          Techar *ptr1 = w->atext3.string;
+          const wchar_t *ptr2 = d->sdata;
+          while (*ptr1++ = (Techar)(*ptr2++));
           status = TSuccess;
         }
         else
diff --git a/src/OpenGl/OpenGl_togl_begin_layer_mode.cxx b/src/OpenGl/OpenGl_togl_begin_layer_mode.cxx
index 114fc08..d21625e 100644
--- a/src/OpenGl/OpenGl_togl_begin_layer_mode.cxx
+++ b/src/OpenGl/OpenGl_togl_begin_layer_mode.cxx
@@ -57,6 +57,7 @@ HISTORIQUE DES MODIFICATIONS   :
 #include <Visual3d_Layer.hxx>
 
 #include <OpenGl_Extension.hxx>
+#include <OpenGl_PrinterContext.hxx>
 
 /*----------------------------------------------------------------------*/
 /*
@@ -112,7 +113,6 @@ static float     layerFontRed   = -1.;
 static float     layerFontGreen = -1.;
 static float     layerFontBlue  = -1.;
 
-
 static OSD_FontAspect FTGLLayerFontAspect = OSD_FA_Regular;
 static Tint           FTGLLayerFontHeight = 16;
 static Tint           FTGLLayerFontAscent = 0;
@@ -294,6 +294,35 @@ call_togl_redraw_layer2d (
   printf ("\tratio %f new ortho %f %f %f %f\n",
     ratio, left, right, bottom, top);
 #endif
+
+#ifdef WNT
+  // Check printer context that exists only for print operation
+  OpenGl_PrinterContext* aPrinterContext = 
+    OpenGl_PrinterContext::GetPrinterContext (GET_GL_CONTEXT());
+
+  if (aPrinterContext)
+  {
+    // additional transformation matrix could be applied to
+    // render only those parts of viewport that will be
+    // passed to a printer as a current "frame" to provide
+    // tiling; scaling of graphics by matrix helps render a
+    // part of a view (frame) in same viewport, but with higher
+    // resolution
+    GLfloat aProjMatrix[16];
+    aPrinterContext->GetProjTransformation (aProjMatrix);
+    glLoadMatrixf ((GLfloat*) aProjMatrix);
+
+    // printing operation also assumes other viewport dimension
+    // to comply with transformation matrix or graphics scaling
+    // factors for tiling for layer redraw
+    GLsizei anViewportX = 0;
+    GLsizei anViewportY = 0;
+    aPrinterContext->GetLayerViewport (anViewportX, anViewportY);
+    if (anViewportX != 0 && anViewportY != 0)
+      glViewport (0, 0, anViewportX, anViewportY);
+  }
+#endif 
+
   glOrtho (left, right, bottom, top, -1.0, 1.0);
 
 #ifdef TRACE_MAT
@@ -596,16 +625,15 @@ call_togl_rectangle2d
 
 /*----------------------------------------------------------------------*/
 void EXPORT
-call_togl_text2d ( char *s,
+call_togl_text2d ( Techar *s,
                   float x,
                   float y,
                   float height )
 {
-  call_def_ptrLayer ptrLayer;
   GLdouble objx1, objy1, objz1;
 
-  ptrLayer = (call_def_ptrLayer) ACLayer.ptrLayer;
-  if (ptrLayer == NULL) return;
+  call_def_ptrLayer ptrLayer = (call_def_ptrLayer) ACLayer.ptrLayer;
+  if (!ptrLayer) return;
   if (ptrLayer->listIndex == 0) return;
 #ifdef TRACE_TEXT
   printf ("call_togl_text2d %d\n", ptrLayer->listIndex);
@@ -624,6 +652,15 @@ call_togl_text2d ( char *s,
   objy1 = y,
   objz1 = 0.0;
 
+  //szv: conversion of Techar to wchar_t
+  wchar_t *s1 = (wchar_t*)s;
+  if (sizeof(Techar) != sizeof(wchar_t))
+  {
+    Tint i = 0; while (s[i++]);
+    s1 = new wchar_t[i];
+    i = 0; while (s1[i++] = (wchar_t)(*s++));
+  }
+
   /*
   * On traite les differents types d'affichage de texte
   */
@@ -634,7 +671,7 @@ call_togl_text2d ( char *s,
     printf ("texte normal %f %f\n", objx1, objy1);
 #endif
 
-    textRender->RenderText(s , fontBase, 1, (float )objx1, (float )objy1, 0.f );
+    textRender->RenderText(s1, fontBase, 1, (float )objx1, (float )objy1, 0.f );
 
     break;
   case 1 : /* Aspect_TODT_SubTitle */
@@ -721,8 +758,7 @@ call_togl_text2d ( char *s,
     glColor3f (layerRed, layerGreen, layerBlue);
 #endif /* OK */
 
-
-    textRender->RenderText(s, fontBase, 1, (float )objx1, (float )objy1, 0.f); 
+    textRender->RenderText(s1, fontBase, 1, (float )objx1, (float )objy1, 0.f); 
 
     break;
   case 2 : /* Aspect_TODT_Dekale */
@@ -774,7 +810,7 @@ call_togl_text2d ( char *s,
 
 
     OpenGl_TextRender* textRender=OpenGl_TextRender::instance();
-    textRender->RenderText(s, fontBase, 1, objx2, objy2, 0.f);
+    textRender->RenderText(s1, fontBase, 1, objx2, objy2, 0.f);
 
 
     winx2 = winx1-1;
@@ -787,7 +823,7 @@ call_togl_text2d ( char *s,
     printf ("status %s\n", (status == GL_FALSE ? "ko" : "ok"));
 #endif
 
-    textRender->RenderText(s, fontBase, 1, objx2, objy2, 0.f);
+    textRender->RenderText(s1, fontBase, 1, objx2, objy2, 0.f);
 
 
     winx2 = winx1-1;
@@ -801,7 +837,7 @@ call_togl_text2d ( char *s,
 #endif
 
 
-    textRender->RenderText(s, fontBase, 1, objx2, objy2, 0.f);
+    textRender->RenderText(s1, fontBase, 1, objx2, objy2, 0.f);
 
     winx2 = winx1+1;
     winy2 = winy1-1;
@@ -813,12 +849,12 @@ call_togl_text2d ( char *s,
     printf ("status %s\n", (status == GL_FALSE ? "ko" : "ok"));
 #endif
 
-    textRender->RenderText(s, fontBase, 1, objx2, objy2, 0.f);
+    textRender->RenderText(s1, fontBase, 1, objx2, objy2, 0.f);
 
     glColor3f (layerRed, layerGreen, layerBlue);
 #endif /* OK */
 
-    textRender->RenderText(s, fontBase, 1, (float )objx1, (float )objy1, 0.f);
+    textRender->RenderText(s1, fontBase, 1, (float )objx1, (float )objy1, 0.f);
 
 #ifdef DEBUG
     printf ("---------------------\n");
@@ -853,7 +889,7 @@ call_togl_text2d ( char *s,
 #else
     glColor3f (layerRed, layerGreen, layerBlue);
 
-    textRender->RenderText(s, fontBase, 1, (float )objx1, (float )objy1, 0.f);
+    textRender->RenderText(s1, fontBase, 1, (float )objx1, (float )objy1, 0.f);
 
 
 #endif //WNT
@@ -864,7 +900,7 @@ call_togl_text2d ( char *s,
     printf ("texte blend %f %f\n", objx1, objy1);
 #endif
 
-    textRender->RenderText(s, fontBase, 1, (float )objx1, (float )objy1, 0.f);
+    textRender->RenderText(s1, fontBase, 1, (float )objx1, (float )objy1, 0.f);
 
 #ifdef DEBUG
     printf ("---------------------\n");
@@ -872,35 +908,47 @@ call_togl_text2d ( char *s,
 #endif /* OK */
     break;
   }
+  //szv: delete temporary wide string
+  if (sizeof(Techar) != sizeof(wchar_t))
+    delete[] s1;
 }
 
 void EXPORT
 call_togl_textsize2d
 (
- char *s,
+ Techar *s,
  float height,
  float *width,
  float *ascent,
  float *descent
  )
 {
-  call_def_ptrLayer ptrLayer;
-
 
-  ptrLayer = (call_def_ptrLayer) ACLayer.ptrLayer;
-  if (ptrLayer == NULL) return;
+  call_def_ptrLayer ptrLayer = (call_def_ptrLayer) ACLayer.ptrLayer;
+  if (!ptrLayer) return;
   if (ptrLayer->listIndex == 0) return;
 
+  OpenGl_TextRender* textRender =  OpenGl_TextRender::instance();
 
-  if ( FTGLLayerFontHeight != height || layerFontFlag == IsModified || FTGLLayerFontCurrent == 0 ) {
+  if ( FTGLLayerFontHeight != height || layerFontFlag == IsModified || FTGLLayerFontCurrent == 0 )
+  {
     layerFontFlag = IsNotModified;
     FTGLLayerFontHeight = (Tint)height;  
-    OpenGl_TextRender*  textRender =  OpenGl_TextRender::instance();
     FTGLLayerFontCurrent = textRender -> FindFont(FTGLLayerFontName, FTGLLayerFontAspect, (Tfloat)FTGLLayerFontHeight);
-    textRender -> StringSize(s, &FTGLLayerFontWidth, &FTGLLayerFontAscent, &FTGLLayerFontDescent);
   }
 
-  
+  //szv: conversion of Techar to wchar_t
+  wchar_t *s1 = (wchar_t*)s, *s2 = 0;
+  if (sizeof(Techar) != sizeof(wchar_t))
+  {
+    Tint i = 0; while (s[i++]);
+    s1 = s2 = new wchar_t[i];
+    i = 0; while (s1[i++] = (wchar_t)(*s++));
+  }
+  textRender->StringSize(s1, &FTGLLayerFontWidth, &FTGLLayerFontAscent, &FTGLLayerFontDescent);
+  //szv: delete temporary wide string
+  if (s2) delete[] s2;
+
   *width = (float) FTGLLayerFontWidth;
   *ascent = (float) FTGLLayerFontAscent;
   *descent = (float) FTGLLayerFontDescent;
@@ -1088,7 +1136,7 @@ void call_togl_set_text_attributes( Tchar* font,
     FTGLLayerFontXScale = FTGLLayerFontYScale = 1.f;
     OpenGl_TextRender*  textRender =  OpenGl_TextRender::instance();
     FTGLLayerFontCurrent = textRender -> FindFont(FTGLLayerFontName, FTGLLayerFontAspect, (Tfloat)FTGLLayerFontHeight);
-   
+
     layerFontRed = r;
     layerFontGreen = g;
     layerFontBlue = b;
diff --git a/src/OpenGl/OpenGl_togl_graduatedtrihedron.cxx b/src/OpenGl/OpenGl_togl_graduatedtrihedron.cxx
index 93e4238..fc04543 100644
--- a/src/OpenGl/OpenGl_togl_graduatedtrihedron.cxx
+++ b/src/OpenGl/OpenGl_togl_graduatedtrihedron.cxx
@@ -1,3 +1,8 @@
+// File:      OpenGl_togl_graduatedtrihedron.cxx
+// Created:   6 March 2011
+// Author:    Sergey ZERCHANINOV
+// Copyright: OPEN CASCADE SA 2011
+
 #include <OpenGl_graduatedtrihedron.hxx>
 
 #include <OpenGl_tsm_ws.hxx>
@@ -7,14 +12,8 @@
 #include <InterfaceGraphic_Aspect.hxx>
 #include <InterfaceGraphic_Visual3d.hxx>
 
-void EXPORT call_togl_graduatedtrihedron_get(CALL_DEF_VIEW* view, 
-                                             CALL_DEF_GRADUATEDTRIHEDRON* cubic)
-{
-    call_graduatedtrihedron_get(view->WsId, cubic);
-}
-
 void EXPORT call_togl_graduatedtrihedron_display(CALL_DEF_VIEW* view, 
-                                                 CALL_DEF_GRADUATEDTRIHEDRON* cubic)
+                                                 const Graphic3d_CGraduatedTrihedron &cubic)
 {
     call_graduatedtrihedron_display(view->WsId, cubic);
 }
diff --git a/src/OpenGl/OpenGl_togl_parray.cxx b/src/OpenGl/OpenGl_togl_parray.cxx
index a336183..66b655b 100644
--- a/src/OpenGl/OpenGl_togl_parray.cxx
+++ b/src/OpenGl/OpenGl_togl_parray.cxx
@@ -21,3 +21,72 @@ void EXPORT call_togl_parray
   if (! agroup->IsOpen) call_togl_closegroup (agroup);
   return;
 }
+
+//=======================================================================
+//function : call_togl_parray_remove
+//purpose  : Remove the driver's element corresponding to the primitives
+//           array <thePArray> and clean its visualization data. The driver
+//           clears all its references to array and stops displaying it.
+//           <theGroup> is the group that has added <thePArray> to driver.
+//=======================================================================
+
+void EXPORT call_togl_parray_remove (CALL_DEF_GROUP*  theGroup,
+                                     CALL_DEF_PARRAY* thePArray)
+{
+  CALL_DEF_PARRAY* anElData;
+  Tint aBegId, aEndId, aCurId; 
+  TSM_ELEM anElem;
+
+  // set edit mode and open struct
+  call_func_set_edit_mode (CALL_PHIGS_EDIT_REPLACE);
+  call_func_open_struct (theGroup->Struct->Id);
+
+  // get begin label
+  call_func_set_elem_ptr (0);
+  if (call_func_set_elem_ptr_label (theGroup->LabelBegin) == TFailure)
+    return;
+  call_func_inq_elem_ptr (&aBegId);
+
+  // get end label
+  if (call_func_set_elem_ptr_label (theGroup->LabelEnd) == TFailure)
+    return;
+  call_func_inq_elem_ptr (&aEndId);
+
+  // iterate between labels and search for the array
+  if (aBegId != aEndId)
+  {
+    // move one element back
+    if (call_func_offset_elem_ptr (-1)   == TFailure ||
+        call_func_inq_elem_ptr (&aCurId) == TFailure)
+      return;
+
+    // iterate from end label to begin label
+    while (aCurId > aBegId)
+    {
+      call_func_inq_elem (&anElem);
+
+      // compare element with the array
+      if (anElem.el == TelParray && anElem.data.pdata == (void* )thePArray)
+      {
+        anElData = (CALL_DEF_PARRAY* )anElem.data.pdata;
+
+        // validate for correct pointer
+        if (anElData->num_bounds  == thePArray->num_bounds  && 
+            anElData->num_edges   == thePArray->num_edges   &&
+            anElData->num_vertexs == thePArray->num_vertexs &&
+            anElData->type        == thePArray->type)
+        {
+          call_func_del_elem();
+          break;
+        }
+      }
+      else
+      {
+        call_func_offset_elem_ptr (-1);
+        call_func_inq_elem_ptr (&aCurId);
+      }
+    }
+  }
+
+  call_func_close_struct();
+}
diff --git a/src/OpenGl/OpenGl_togl_print.cxx b/src/OpenGl/OpenGl_togl_print.cxx
index 6ae16f5..7429b7f 100644
--- a/src/OpenGl/OpenGl_togl_print.cxx
+++ b/src/OpenGl/OpenGl_togl_print.cxx
@@ -17,90 +17,316 @@ e-mail t-hartl at muenchen.matra-dtv.fr  */
 #include <OpenGl_tgl_funcs.hxx>
 #include <OpenGl_tgl_subrvis.hxx>
 #include <OpenGl_animation.hxx>
-
+#include <OpenGl_FrameBuffer.hxx>
+#include <OpenGl_PrinterContext.hxx>
+#include <Visual3d_Layer.hxx>
+#include <TColStd_Array2OfReal.hxx>
 #include <string.h>
 
-/* SAV - begin */
-/* MSDN says: point is 1/72 inch. But in our case text height in the 3D view
-differs from printed one. An experiment showed that delimeter equal to 2*72 gives
-practically equal text heights. */
-int defaultDelimeter = 72;
-int delimeter = 144;
-int defaultPntSize = 12;
+#ifdef HAVE_FREEIMAGE
+  #include <NCollection_Handle.hxx>
+  #include <FreeImagePlus.h>
+  #ifdef _MSC_VER
+  #pragma comment( lib, "FreeImage.lib" )
+  #pragma comment( lib, "FreeImagePlus.lib" )
+  #endif
+  typedef NCollection_Handle<fipImage> FipHandle;
+#endif
 
-GLuint printerFontBase = 0;
+// ---------------------------------------------------------------
+// Function: getNearestPowOfTwo
+// Purpose:  get the nearest power of two for theNumber
+// ---------------------------------------------------------------
+static GLsizei getNearestPowOfTwo (const GLsizei theNumber)
+{
+  GLsizei aLast = 1;
+  for (GLsizei p2 = 1; p2 <= theNumber; aLast = p2, p2 <<= 1);
+  return aLast;
+}
 
-/* printer DC needed to avoid passing OS specific type as a procedure parameter */
-#ifdef WNT
-HDC     printer;
-HGDIOBJ oldObj;
-#endif
+// ---------------------------------------------------------------
+// Function: getMaxFrameSize
+// Purpose:  get the maximum possible frame size
+// ---------------------------------------------------------------
+static void getMaxFrameSize(Standard_Integer& theWidth,
+                            Standard_Integer& theHeight)
+{
+  GLsizei aMaxX, aMaxY;
+  GLint aVpDim[2];
+  GLint aTexDim = 2048;
+  glGetIntegerv (GL_MAX_VIEWPORT_DIMS, (GLint*) &aVpDim);
+  glGetIntegerv (GL_MAX_TEXTURE_SIZE, &aTexDim);
+  (aVpDim[0] >= aTexDim) ? aMaxX = (GLsizei) aTexDim : 
+                           aMaxX = getNearestPowOfTwo((GLsizei)aVpDim[0]);
+  (aVpDim[1] >= aTexDim) ? aMaxY = (GLsizei) aTexDim :
+                           aMaxY = getNearestPowOfTwo((GLsizei)aVpDim[1]);
+
+  theWidth  = (Standard_Integer)aMaxX;
+  theHeight = (Standard_Integer)aMaxY;
+}
 
-#ifdef __BORLANDC__
-# define _stricmp stricmp
-#endif
+// ---------------------------------------------------------------
+// Function: fitDimensionsRatio
+// Purpose:  calculate correct width/height ratio for theWidth and
+//           theHeight parameters
+// ---------------------------------------------------------------
+static void fitDimensionsRatio (Standard_Integer& theWidth,
+                                Standard_Integer& theHeight,
+                                const Standard_Real theViewRatio)
+{
+  // set dimensions in accordance with the viewratio
+  if (theHeight <  theWidth/theViewRatio)
+      theWidth  = (Standard_Integer)(theHeight*theViewRatio);
+
+  if (theWidth  <  theHeight*theViewRatio)
+      theHeight = (Standard_Integer)(theWidth/theViewRatio);
+}
 
-GLuint createFont( char* typeFace, int height, int weight, int italic )
+// ---------------------------------------------------------------
+// Function: getDimensionsTiling
+// Purpose:  calculate maximum possible dimensions for framebuffer 
+//           in tiling mode according to the view size
+// ---------------------------------------------------------------
+static void getDimensionsTiling (Standard_Integer& theFrameWidth,
+                                 Standard_Integer& theFrameHeight,
+                                 const int theViewWidth,
+                                 const int theViewHeight)
 {
-#ifdef WNT
-  /* no unicode support yet*/
-  HFONT  font;
-  GLuint base;
-  DWORD  charSet = ANSI_CHARSET;
-
-  if ( ( base = glGenLists( 96 ) ) == 0 )
-    return 0;
-
-  if ( _stricmp( typeFace, "symbol" ) == 0 )
-    charSet = SYMBOL_CHARSET;
-
-  font = CreateFont( height, 0, 0, 0, weight, italic, FALSE, FALSE,
-    charSet, OUT_TT_PRECIS,
-    CLIP_DEFAULT_PRECIS, DRAFT_QUALITY,
-    DEFAULT_PITCH, typeFace );
-  oldObj = SelectObject( printer, font );
-  wglUseFontBitmaps( printer, 32, 96, base );
-  return base;
-#else
-  return 0;
-#endif
+  // fit the maximum dimensions into the printing area
+  if (theFrameWidth > theViewWidth)
+      theFrameWidth = theViewWidth;
+
+  if (theFrameHeight > theViewHeight)
+      theFrameHeight = theViewHeight;
 }
 
-void deleteFont( GLuint base )
+// ---------------------------------------------------------------
+// Function: initBufferStretch
+// Purpose:  calculate initialization sizes for frame buffer
+//           when the stretch algorithm is selected
+// ---------------------------------------------------------------
+static void initBufferStretch (Standard_Integer& theFrameWidth,
+                               Standard_Integer& theFrameHeight,
+                               const int theViewWidth,
+                               const int theViewHeight)
 {
-#ifdef WNT
-  HFONT currentFont;
-
-  if ( base == 0 )
-    /* no font created */
-    return;
-  /* deleting font list id */
-  glDeleteLists( base, 96 );
-  currentFont = (HFONT)SelectObject( printer, oldObj );
-  /* deleting current font structure */
-  DeleteObject( currentFont );
-#endif
+
+  // Calculate correct width/height for framebuffer
+  Standard_Real aViewRatio = (Standard_Real)theViewWidth/theViewHeight;
+  fitDimensionsRatio (theFrameWidth, theFrameHeight, aViewRatio);
+
+  // downscale the framebuffer if it is too large
+  Standard_Real aWidthRate  = (Standard_Real)theFrameWidth /theViewWidth;
+  Standard_Real aHeightRate = (Standard_Real)theFrameHeight/theViewHeight;
+
+  if ((aWidthRate > 1 && aHeightRate > 1 && aWidthRate >= aHeightRate) || 
+      (aWidthRate > 1 && aHeightRate <= 1))
+  {
+    theFrameWidth  = (Standard_Integer)(theFrameWidth /aWidthRate);
+    theFrameHeight = (Standard_Integer)(theFrameHeight/aWidthRate);
+  }
+  else if ((aWidthRate  > 1 && aHeightRate > 1 && aWidthRate < aHeightRate) ||
+           (aWidthRate <= 1 && aHeightRate > 1))
+  {
+    theFrameWidth  = (Standard_Integer)(theFrameWidth /aHeightRate);
+    theFrameHeight = (Standard_Integer)(theFrameHeight/aHeightRate);
+  }
+
+}
+
+// ---------------------------------------------------------------
+// Function: initBufferTiling
+// Purpose:  calculate initialization sizes for frame buffer
+//           when the tile algorithm is selected
+// ---------------------------------------------------------------
+static void initBufferTiling (Standard_Integer& theFrameWidth,
+                              Standard_Integer &theFrameHeight,
+                              const int theViewWidth,
+                              const int theViewHeight)
+{
+  // fit framebuffer into the printing area
+  if (theFrameWidth > theViewWidth)
+      theFrameWidth = theViewWidth;
+
+  if (theFrameHeight > theViewHeight)
+      theFrameHeight = theViewHeight;
 }
 
-void updatePrinterFont( char* type, int height )
+// ---------------------------------------------------------------
+// Function: redrawView
+// Purpose:  redraw view in printing mode
+// ---------------------------------------------------------------
+static void redrawView (CALL_DEF_VIEW *aview, 
+                        CALL_DEF_LAYER *anunderlayer, 
+                        CALL_DEF_LAYER *anoverlayer,
+                        const int isBackground)
 {
+  // prepare for redraw
+  call_func_redraw_all_structs_begin (aview->WsId);
+  call_subr_displayCB (aview, OCC_REDRAW_BITMAP | OCC_PRE_REDRAW);
+  call_togl_setplane (aview);
+
+  // clear background
+  if (isBackground == 0)
+  {
+    glClearColor (1.0, 1.0, 1.0, 1.0);
+    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+  }
+
+  // draw underlayer
+  if (anunderlayer->ptrLayer)
+  {
+    call_togl_redraw_layer2d (aview, anunderlayer);
+  }
+
+  // redraw main plane
+  call_func_redraw_all_structs_proc (aview->WsId);
+  call_subr_displayCB (aview,OCC_REDRAW_BITMAP | OCC_PRE_OVERLAY);
+  // draw overlayer
+  if (anoverlayer->ptrLayer)
+  {
+    call_togl_redraw_layer2d (aview, anoverlayer);
+  }
+  call_subr_displayCB (aview,OCC_REDRAW_BITMAP);
+
+
+  // tell to end redrawing
+  call_func_redraw_all_structs_end (aview->WsId, 0);
+  call_togl_redraw_immediat_mode (aview);
+}
+
+// ---------------------------------------------------------------
+// Function: initBitmapBuffer
+// Purpose:  init device independent bitmap to hold printing data
+// ---------------------------------------------------------------
 #ifdef WNT
-  int delim = delimeter;
-  if ( height <= 0 ) {
-    height = defaultPntSize;
-    delim = defaultDelimeter;
+#ifndef HAVE_FREEIMAGE
+static void initBitmapBuffer (const HDC theMemoryDC,
+                              HBITMAP &theMemoryBmp,
+                              const   Standard_Integer theBmpWidth,
+                              const   Standard_Integer theBmpHeight,
+                              VOID*   &theBufferPtr)
+{
+  // define compatible bitmap
+  BITMAPINFO aBitmapData;
+  memset (&aBitmapData, 0, sizeof (BITMAPINFOHEADER));
+  aBitmapData.bmiHeader.biSize          = sizeof (BITMAPINFOHEADER);
+  aBitmapData.bmiHeader.biWidth         = theBmpWidth;
+  aBitmapData.bmiHeader.biHeight        = theBmpHeight;
+  aBitmapData.bmiHeader.biPlanes        = 1;
+  aBitmapData.bmiHeader.biBitCount      = 24;
+  aBitmapData.bmiHeader.biXPelsPerMeter = 0;
+  aBitmapData.bmiHeader.biYPelsPerMeter = 0;
+  aBitmapData.bmiHeader.biClrUsed       = 0;
+  aBitmapData.bmiHeader.biClrImportant  = 0;
+  aBitmapData.bmiHeader.biCompression   = BI_RGB;
+  aBitmapData.bmiHeader.biSizeImage     = 0;
+
+  // Create Device Independent Bitmap
+  theMemoryBmp = CreateDIBSection (theMemoryDC, &aBitmapData, DIB_RGB_COLORS,
+                                   &theBufferPtr, NULL, 0);
+}
+#else
+// ---------------------------------------------------------------
+// Function: imagePasteDC
+// Purpose:  copy the data from image buffer to the device context
+// ---------------------------------------------------------------
+static bool imagePasteDC(HDC theDstDC,    FipHandle theImage, int theOffsetX,
+                         int theOffsetY,  int theWidth, int theHeight, 
+                         int theLeft = 0, int theTop = 0)
+{
+  // get image parameters
+  BITMAPINFO* aBitmapData = theImage->getInfo ();
+  SetStretchBltMode (theDstDC, STRETCH_HALFTONE);
+ 
+  // organize blocks data passing if memory isn't enough to pass all the data
+  // at once
+  int aLinesComplete = 0, aMaxBlockWidth = theHeight, aBlockWidth = 0,
+      aPassed        = 0, aInverseLine   = 0, aScan = 0;
+  BYTE *aDataPtr = 0;
+  while (aMaxBlockWidth >= 1 && aLinesComplete < theHeight)
+  {
+    // how much lines still to pass
+    aBlockWidth = theHeight - aLinesComplete;
+
+    // normalize count of lines to pass to maximum lines count at one pass.
+    if (aBlockWidth > aMaxBlockWidth)
+      aBlockWidth = aMaxBlockWidth;
+
+    // access image data at the start scan line, we need to calculate scan from
+    // the bottom of image (image is bottom-left, the src coord is top-left)
+    aInverseLine = theTop + aBlockWidth + aLinesComplete;
+    aScan = theImage->getHeight() - aInverseLine;
+    aDataPtr = theImage->getScanLine (aScan);
+    if (!aDataPtr)
+      return false;
+
+    // try to pass block to the device
+    if (aBlockWidth > 0)
+    {
+      // instead of banded output we provide blocked as it isn't always passed
+      // to printer as it is expected
+      aPassed = SetDIBitsToDevice (theDstDC, theOffsetX,
+                                   theOffsetY + aLinesComplete,
+                                   theWidth, aBlockWidth, theLeft, 0,
+                                   0, aBlockWidth,
+                                   aDataPtr, aBitmapData, DIB_RGB_COLORS);
+
+      // if result is bad, try to decrease band width
+      if (aPassed != aBlockWidth)
+      {
+        aMaxBlockWidth = aMaxBlockWidth >> 1;
+        aLinesComplete = 0;
+      }
+      else
+        aLinesComplete += aBlockWidth;
+    }
   }
-  /* deleting old font */
-  deleteFont( printerFontBase );
-  /* creating new one */
-  printerFontBase = createFont( type, -MulDiv( height, GetDeviceCaps( printer, LOGPIXELSY ), delim ),
-    (int)FW_NORMAL, 0 );
-#endif
+
+  // check for total failure
+  if (aMaxBlockWidth < 1)
+    return false;
+
+  return true;
 }
-/* SAV - end */
 
+// ---------------------------------------------------------------
+// Function: imageStretchDC
+// Purpose:  copy pixels from image to dc by stretching them
+// ---------------------------------------------------------------
+static bool imageStretchDC(HDC theDstDC,   FipHandle theImage, int theOffsetX,
+                           int theOffsetY, int theWidth, int theHeight)
+{
+  // access to raw image data
+  BYTE *aDataPtr = theImage->accessPixels ();
+  if (!aDataPtr)
+    return false;
+
+  // get image parameters
+  unsigned int widthPx    = theImage->getWidth ();
+  unsigned int heightPx   = theImage->getHeight ();
+  BITMAPINFO* aBitmapData = theImage->getInfo ();
+  SetStretchBltMode (theDstDC, STRETCH_HALFTONE);
+  
+  // pass lines and check if operation is succesfull
+  int aPassed = 0;
+  aPassed = StretchDIBits (theDstDC, theOffsetX, theOffsetY, theWidth,
+                           theHeight, 0, 0, widthPx, heightPx, aDataPtr,
+                           aBitmapData, DIB_RGB_COLORS, SRCCOPY);
+
+  if (aPassed != heightPx)
+    return false;
+ 
+  return true;
+}
+#endif
+#endif
 
-void EXPORT
+// ---------------------------------------------------------------
+// Function: call_togl_print
+// Purpose:
+// ---------------------------------------------------------------
+Standard_Boolean EXPORT
 call_togl_print
 (
  CALL_DEF_VIEW *aview,
@@ -108,293 +334,470 @@ call_togl_print
  CALL_DEF_LAYER *anoverlayer,
  const Aspect_Drawable hPrintDC,
  const int background,
- const char* filename
+ const char* filename,
+ const int   printalgo,
+ const float theScaleFactor
  )
 {
 
 #ifdef WNT
 
-  CMN_KEY_DATA data;
-  Tint swap = 1; /* swap buffers ? yes */
+  CMN_KEY_DATA data; 
+  DOCINFO di;
+  bool IsTiling = (printalgo == 1);
+  HDC  hPrnDC   = (HDC) hPrintDC;
+
+  TsmGetWSAttri (aview->WsId, WSWindow, &data);
+  if (TxglWinset (call_thedisplay, (WINDOW) data.ldata) != TSuccess)
+  {
+    MessageBox (NULL, "Print failed: can't setup the view for printing.",
+                "The operation couldn't be completed.", MB_OK);
+    return Standard_False;
+  }
+
+  // printer page dimensions
+  int devWidth  = GetDeviceCaps (hPrnDC, HORZRES);
+  int devHeight = GetDeviceCaps (hPrnDC, VERTRES);
 
-  HDC hPrnDC;
-  DOCINFO   di;
+  // if context is actually a memory dc, try to retrieve bitmap dimensions
+  // (memory dc could be used for testing purposes)
+  if (GetObjectType (hPrnDC) == OBJ_MEMDC)
+  {
+    // memory dc dimensions
+    BITMAP aBitmapInfo;
+    HBITMAP aMemoryBitmap = (HBITMAP) GetCurrentObject (hPrnDC, OBJ_BITMAP);
+    if (aMemoryBitmap)
+      if (GetObject (aMemoryBitmap, sizeof (BITMAP), &aBitmapInfo))
+      {
+        devWidth  = aBitmapInfo.bmWidth;
+        devHeight = aBitmapInfo.bmHeight;
+      }
+  }
 
-  hPrnDC = (HDC) hPrintDC;
-  printer = hPrnDC;
+  Standard_Integer tempWidth  = (Standard_Integer) devWidth;
+  Standard_Integer tempHeight = (Standard_Integer) devHeight;
 
-  /* Begin main routine **************************************************************/
-  TsmGetWSAttri (aview->WsId, WSWindow, &data);
-  if (TxglWinset (call_thedisplay, (WINDOW) data.ldata) == TSuccess) 
+  // view dimensions
+  RECT rect;
+  GetClientRect((WINDOW) data.ldata, &rect);
+  int viewWidth  = rect.right-rect.left;
+  int viewHeight = rect.bottom-rect.top;
+  if (viewWidth == 0 || viewHeight == 0)
   {
-    static PIXELFORMATDESCRIPTOR pfd = {
-      sizeof(PIXELFORMATDESCRIPTOR),  // size of this pfd
-        1,        // version number
-        PFD_SUPPORT_OPENGL|
-        PFD_DRAW_TO_BITMAP,
-        PFD_TYPE_RGBA,
-        0, 0, 0, 0, 0, 0,   // color bits ignored
-        0,        // no alpha buffer
-        0,        // shift bit ignored
-        0,        // no accumulation buffer
-        0, 0, 0, 0,       // accum bits ignored
-        32,       // 32-bit z-buffer  
-        0,        // no stencil buffer
-        0,        // no auxiliary buffer
-        PFD_MAIN_PLANE,     // main layer
-        0,        // reserved
-        0, 0, 0       // layer masks ignored
-    };
-    HWND w;
-    HDC hDC;    
-    HDC hMemDC;
-    HGLRC hGLRC;
-    RECT rect;
-
-    BITMAPINFO* pBMI;
-    BITMAPINFOHEADER* bmHeader;
-
-    BYTE  biInfo[sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD)];
-    HGDIOBJ hBmOld;
-    HBITMAP hBm;
-    VOID* base;
-
-    int nIndex;
-    int bmiSize;
-
-    float viewRatio;
-    int devWidth;
-    int devHeight;
-    int viewWidth;
-    int viewHeight;
-    int width;
-    int height;
-    float tempWidth;
-    float tempHeight;
-    int offsetx = 0;
-    int offsety = 0;
-
-#ifdef mydebug
-    devWidth = 640;
-    tempWidth = (float) devWidth;
-    devHeight = 480;
-    tempHeight = (float) devHeight;
+    MessageBox (NULL, "Print failed: can't setup the view for printing.",
+                "The operation couldn't be completed.", MB_OK);
+    return Standard_False;
+  }
+
+  // calculate correct width/height ratio
+  Standard_Real viewRatio = (Standard_Real)viewWidth/viewHeight;
+  fitDimensionsRatio(tempWidth, tempHeight, viewRatio);
+
+  // width and height for printing area
+  int width  = (int) (tempWidth  * theScaleFactor);
+  int height = (int) (tempHeight * theScaleFactor);
+
+  // device independent bitmap for the whole view
+#ifdef HAVE_FREEIMAGE
+  FipHandle  aViewImage  = NULL;
+  BYTE*      aViewBuffer = NULL;
 #else
-    devWidth = GetDeviceCaps(hPrnDC, HORZRES);
-    tempWidth = (float) devWidth;
-    devHeight = GetDeviceCaps(hPrnDC, VERTRES);
-    tempHeight = (float) devHeight;
-#endif
-    GetClientRect((WINDOW) data.ldata, &rect);
-    viewWidth = rect.right-rect.left;
-    viewHeight = rect.bottom-rect.top;
-
-    viewRatio = (float) viewWidth/(float) viewHeight;
-
-    // Calculate correct width/height ratio
-    if (tempHeight < tempWidth/viewRatio)
-      tempWidth = tempHeight*viewRatio;
-    if (tempWidth < tempHeight*viewRatio)
-      tempHeight = tempWidth/viewRatio;
-
-    width = (int) tempWidth;
-    height = (int) tempHeight;
-
-    // Create virtual window    
-    w = CreateWindow(
-      "Button",              
-      "",      
-      WS_OVERLAPPEDWINDOW |   
-      WS_CLIPCHILDREN |
-      WS_CLIPSIBLINGS,
-      0, 0,             
-      width, height,   
-      NULL,                
-      NULL,         
-      NULL,        
-      NULL);  
-#ifdef mydebug
-    ShowWindow(w, SW_SHOW);
+  HDC     hMemDC          = CreateCompatibleDC (hPrnDC);
+  HBITMAP hViewBitmap     = NULL;
+  HGDIOBJ hViewBitmapOld  = NULL;
+  VOID*   aViewBuffer    = NULL;
 #endif
 
-    hDC = GetDC(w);
-    if (!hDC)
-    {
-      MessageBox(0,"hDC == NULL", "Fehler", MB_OK);
-      return;
-    }
+  // Frame buffer initialization
+  OpenGl_FrameBuffer* aFrameBuffer = NULL;
+  OpenGl_FrameBuffer* aPrevBuffer = (OpenGl_FrameBuffer*) aview->ptrFBO;
+  Standard_Integer aFrameWidth (0),  aFrameHeight (0),
+                   aPrevBufferX (0), aPrevBufferY (0);
+
+  // try to use existing frame buffer
+  if (aPrevBuffer)
+  {
+    GLsizei aPrevWidth  = aPrevBuffer->GetSizeX();
+    GLsizei aPrevHeight = aPrevBuffer->GetSizeY();
+    bool isUsable = false;
 
-    // Initialize Bitmap Information
-
-    pBMI = (BITMAPINFO *) biInfo;
-    ZeroMemory(pBMI, sizeof(*pBMI));
-    bmiSize = sizeof(*pBMI);
-
-    pBMI = (BITMAPINFO *) calloc(1, bmiSize);
-    bmHeader = &pBMI->bmiHeader;
-
-    bmHeader->biSize = sizeof(*bmHeader);
-    bmHeader->biWidth = width;
-    bmHeader->biHeight = height;
-    bmHeader->biPlanes = 1;                     /* must be 1 */
-    bmHeader->biBitCount = 24;
-    bmHeader->biXPelsPerMeter = 0;
-    bmHeader->biYPelsPerMeter = 0;
-    bmHeader->biClrUsed = 0;                    /* all are used */
-    bmHeader->biClrImportant = 0;               /* all are important */
-    bmHeader->biCompression = BI_RGB;
-    bmHeader->biSizeImage = 0;
-
-    // Create Device Independent Bitmap 
-    hMemDC = CreateCompatibleDC(hPrnDC);
-    hBm = CreateDIBSection(hMemDC, pBMI, DIB_RGB_COLORS, &base, NULL, 0); 
-    hBmOld = SelectObject(hMemDC, hBm);
-
-    // Release Memory   
-    free(pBMI);
-    //    free(bmHeader);
-
-    // further initialization
-#ifdef mydebug
-    pfd.cColorBits = GetDeviceCaps(hDC, BITSPIXEL);
-    nIndex = ChoosePixelFormat(hDC, &pfd);
-    if (nIndex == 0)
+    // check if its possible to use previous frame buffer
+    if (!IsTiling && aPrevWidth >= width && aPrevHeight >= height)
     {
-      MessageBox(0,"ChoosePixelFormat failed", "Error", MB_OK | MB_ICONSTOP);
-      goto Error;
+      aFrameWidth  = (Standard_Integer) width;
+      aFrameHeight = (Standard_Integer) height;
+      isUsable = true;
     }
-
-
-    if (!SetPixelFormat(hDC, nIndex, &pfd))
+    else if (IsTiling)
     {
-      MessageBox(0,"SetPixelFormat failed", "Error", MB_OK | MB_ICONSTOP);
-      goto Error;
+      getDimensionsTiling (aFrameWidth, aFrameHeight, width, height);
+      if (aPrevWidth >= aFrameWidth && aPrevHeight >= aFrameHeight)
+        isUsable = true;
     }
 
-    // Create Rendering Context
-    hGLRC = wglCreateContext(hDC);
-
-    if (hGLRC == NULL) 
+    // if it is enough memory for image paste dc operation
+    if (isUsable)
     {
-      MessageBox(0,"No Rendering Context", "Error", MB_OK | MB_ICONSTOP);
-      goto Error;
-    }
-    wglMakeCurrent(hDC,hGLRC);
+#ifdef HAVE_FREEIMAGE
+      // try to allocate fipImage and necessary resources
+      fipImage* anImagePtr = new fipImage (FIT_BITMAP, aFrameWidth,
+                                           aFrameHeight, 24);
+
+      // if allocated succesfully
+      if (anImagePtr->isValid())
+      {
+        aViewImage  = anImagePtr;
+        aViewBuffer = aViewImage->accessPixels ();
+      }
+      else
+        delete anImagePtr;
+
+      if (!aViewBuffer)
+      {
+        isUsable = false;
+        aViewBuffer = NULL;
+        aViewImage  = NULL;
+      }
 #else
-    pfd.cColorBits = (BYTE)GetDeviceCaps(hMemDC, BITSPIXEL);
-    nIndex = ChoosePixelFormat(hMemDC, &pfd);
-    if (nIndex == 0)
-    {
-      MessageBox(0,"ChoosePixelFormat failed", "Error", MB_OK | MB_ICONSTOP);
-      goto Error;
+      // try to allocate compatible bitmap and necessary resources
+      initBitmapBuffer (hMemDC, hViewBitmap, 
+                        aFrameWidth, aFrameHeight, aViewBuffer);
+      if (!aViewBuffer)
+      {
+        isUsable = false;
+        if (hViewBitmap)
+          DeleteObject (hViewBitmap);
+        hViewBitmap = NULL;
+      }
+      else
+        hViewBitmapOld = SelectObject (hMemDC, hViewBitmap);
+#endif
     }
 
-
-    if (!SetPixelFormat(hMemDC, nIndex, &pfd))
+    // use previous frame buffer
+    if (isUsable)
     {
-      MessageBox(0,"SetPixelFormat failed", "Error", MB_OK | MB_ICONSTOP);
-      goto Error;
+      aPrevBufferX = aPrevWidth;
+      aPrevBufferY = aPrevHeight;
+      aFrameBuffer = aPrevBuffer;
+      aFrameBuffer->ChangeViewport (aFrameWidth, aFrameHeight);
     }
+  }
 
-    // Create Rendering Context
-    hGLRC = wglCreateContext(hMemDC);
+  // if previous buffer cannot be used, try to init a new one
+  if (!aFrameBuffer)
+  {
+    aFrameBuffer = new OpenGl_FrameBuffer();
 
-    if (hGLRC == NULL) 
+    // try to create the framebuffer with the best possible size
+    Standard_Integer aMaxWidth(0), aMaxHeight(0);
+    getMaxFrameSize (aMaxWidth, aMaxHeight);
+    while (aMaxWidth > 1 && aMaxHeight > 1)
     {
-      MessageBox(0,"No Rendering Context", "Error", MB_OK | MB_ICONSTOP);
-      goto Error;
-    }
-    wglMakeCurrent(hMemDC,hGLRC);
+      aFrameWidth  = aMaxWidth;
+      aFrameHeight = aMaxHeight;
+
+      // calculate dimensions for different printing algorithms
+      if (!IsTiling)
+        initBufferStretch (aFrameWidth, aFrameHeight, width, height);
+      else
+        initBufferTiling (aFrameWidth, aFrameHeight, width, height);
+
+      // try to initialize framebuffer
+      if (aFrameBuffer->Init (aFrameWidth, aFrameHeight))
+      {
+#ifdef HAVE_FREEIMAGE
+        // try to allocate fipImage and necessary resources
+        fipImage* anImagePtr = new fipImage (FIT_BITMAP, aFrameWidth,
+                                            aFrameHeight, 24);
+
+        // if allocated succesfully
+        if (anImagePtr->isValid())
+        {
+          aViewImage  = anImagePtr;
+          aViewBuffer = aViewImage->accessPixels ();
+        }
+        else
+          delete anImagePtr;
+
+        if (!aViewBuffer)
+        {
+          aFrameBuffer->Release ();
+          aViewBuffer = NULL;
+          aViewImage  = NULL;
+        }
+        else
+          break;
+#else
+        // try to allocate compatible bitmap and necessary resources
+        initBitmapBuffer (hMemDC, hViewBitmap, 
+                          aFrameWidth, aFrameHeight, aViewBuffer);
+        if (!aViewBuffer)
+        {
+          if (hViewBitmap)
+            DeleteObject (hViewBitmap);
+          aFrameBuffer->Release ();
+          hViewBitmap = NULL;
+        }
+        else
+        {
+          hViewBitmapOld = SelectObject (hMemDC, hViewBitmap);
+          break;
+        }
 #endif
+      }
 
-    /* creating default font */
-    printerFontBase = 
-      createFont( "", -MulDiv( defaultPntSize, GetDeviceCaps( hPrnDC, LOGPIXELSY ), defaultDelimeter ),
-      (int)FW_NORMAL, 0 );
-
-    // redraw to new Rendering Context
-    call_func_redraw_all_structs_begin (aview->WsId);
-
-    call_togl_setplane( aview ); /* update clipping planes */
-
-    if (background == 0)
-    {
-      glClearColor(1.0, 1.0, 1.0, 1.0);
-      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+      // not initialized, decrease dimensions
+      aMaxWidth  = aMaxWidth  >> 1;
+      aMaxHeight = aMaxHeight >> 1;
     }
 
-    if (anunderlayer->ptrLayer)
-      call_togl_redraw_layer2d (aview, anunderlayer);
-    call_func_redraw_all_structs_proc (aview->WsId);
-
-    if (anoverlayer->ptrLayer)
-      call_togl_redraw_layer2d (aview, anoverlayer);
-#ifdef RIC120302
-    call_subr_displayCB(aview,OCC_REDRAW_BITMAP);
+    // check if there are proper dimensions 
+    if (aMaxWidth <= 1 || aMaxHeight <= 1)
+    {
+      MessageBox (NULL, "Print failed: can't allocate buffer for printing.",
+                  "The operation couldn't be completed.", MB_OK);
+
+      if (aFrameBuffer)
+        delete aFrameBuffer;
+#ifndef HAVE_FREEIMAGE
+      if (hMemDC)
+        DeleteDC (hMemDC);
 #endif
 
-    call_func_redraw_all_structs_end (aview->WsId, swap);
+      return Standard_False;
+    }
+  }
 
-    call_togl_redraw_immediat_mode (aview);
-#ifndef mydebug
-    /* Start printing of DIB ********************************************************/
+  // setup printing context and viewport
+  GLint aViewPortBack[4]; 
+  GLint aReadBufferPrev = GL_BACK;
+  GLint anAlignBack     = 1;
+  OpenGl_PrinterContext aPrinterContext (GET_GL_CONTEXT());
+  aPrinterContext.SetLayerViewport ((GLsizei)aFrameWidth,
+                                    (GLsizei)aFrameHeight);
+  glGetIntegerv (GL_VIEWPORT, aViewPortBack);
+  glGetIntegerv (GL_PACK_ALIGNMENT, &anAlignBack);
+  glPixelStorei (GL_PACK_ALIGNMENT, 4);
+
+  // start document if the printer context is not actually a memory dc
+  // (memory dc could be used for testing purposes)
+  if (GetObjectType (hPrnDC) == OBJ_DC)
+  {
+    // Initalize printing procedure
     di.cbSize = sizeof(DOCINFO);
-    di.lpszDocName = "Text";
+    di.lpszDocName = "Open Cascade Document - print v3d view";
     di.lpszOutput = filename;
 
-    if (StartDoc(hPrnDC, &di) == SP_ERROR) goto Error;
-    if (StartPage(hPrnDC) <= 0) goto Error;
+    // if can't print the document
+    if (StartDoc (hPrnDC, &di) <= 0 || StartPage (hPrnDC) <= 0)
+    {
+      MessageBox (NULL, "Print failed: printer can't start operation.",
+                  "The operation couldn't be completed.", MB_OK);
+#ifndef HAVE_FREEIMAGE
+      if (hViewBitmap)
+      {
+        SelectObject (hMemDC, hViewBitmapOld);
+        DeleteObject (hViewBitmap);
+      }
+      DeleteDC (hMemDC);
+#endif
 
-    // calculate offset for centered printing
-    if (width < devWidth)
-      offsetx = (devWidth - width)/2;
-    if (height < devHeight)
-      offsety = (devHeight - height)/2;
+      return Standard_False;
+    }
+  }
 
-    BitBlt(hPrnDC, offsetx, offsety, width, height, hMemDC, 0, 0, SRCCOPY);
+  // activate the offscreen buffer
+  aFrameBuffer->BindBuffer ();
 
-    EndPage(hPrnDC);
-    EndDoc(hPrnDC);
-    /* releasing created font */
-    deleteFont( printerFontBase );
-    printerFontBase = 0;
+  // calculate offset for centered printing
+  int aDevOffx = (int)(devWidth  - width) /2;
+  int aDevOffy = (int)(devHeight - height)/2;
 
-    /* End of printing section ******************************************************/
+  // operation complete flag
+  bool isDone = true;
+  
+  if (!IsTiling)
+  {
+    aPrinterContext.SetScale ((GLfloat)aFrameWidth /viewWidth,
+                              (GLfloat)aFrameHeight/viewHeight);
+    aFrameBuffer->SetupViewport ();
+    redrawView (aview, anunderlayer, anoverlayer, background);
+    glReadPixels (0, 0, aFrameWidth, aFrameHeight,
+                  GL_BGR_EXT, GL_UNSIGNED_BYTE, (GLvoid* )aViewBuffer);
+
+    // copy result to the printer device and check for errors
+#ifdef HAVE_FREEIMAGE
+    if (!aViewImage->rescale(width, height, FILTER_BICUBIC) ||
+        !imagePasteDC (hPrnDC, aViewImage, aDevOffx, aDevOffy, width, height))
+      isDone = imageStretchDC (hPrnDC, aViewImage, aDevOffx, aDevOffy,
+                               width, height);
 #else
-    Sleep(5000);
-#endif
-
-Error:
-    /* Clean memory *****************************************************************/
-    if(hBm != NULL)
+    if (width > aFrameWidth && height > aFrameHeight)
     {
-      SelectObject(hMemDC, hBmOld);
-      DeleteObject(hBm);
-      DeleteObject(hBmOld);
+      SetStretchBltMode (hPrnDC, STRETCH_HALFTONE);
+      isDone = StretchBlt (hPrnDC, aDevOffx, aDevOffy, width, height,
+                           hMemDC, 0, 0, aFrameWidth, aFrameHeight, SRCCOPY);
     }
-    wglMakeCurrent(NULL, NULL);
-    if (hGLRC != NULL)
+    else
     {
-      wglDeleteContext(hGLRC);
+      isDone = BitBlt (hPrnDC, aDevOffx, aDevOffy, width, height,
+                       hMemDC, 0, 0, SRCCOPY);
     }
-    if (hMemDC != NULL)
+#endif
+  }
+  else
+  {
+    // calculate total count of frames and cropping size
+    Standard_Integer aPxCropx = 0;
+    Standard_Integer aPxCropy = 0;
+    Standard_Integer aTotalx = 
+                     (Standard_Integer)floor ((float)width /aFrameWidth);
+    Standard_Integer aTotaly = 
+                     (Standard_Integer)floor ((float)height/aFrameHeight);
+    if (width %aFrameWidth != 0)
     {
-      DeleteDC(hMemDC);
+      aPxCropx = (aFrameWidth - width%aFrameWidth)/2;
+      aTotalx++;
     }
-
-    if (hDC != NULL)
+    if (height%aFrameHeight != 0)
     {
-      ReleaseDC(w, hDC);
+      aPxCropy = (aFrameHeight - height%aFrameHeight)/2;
+      aTotaly++;
     }
-    if (w != NULL)
+
+    int anOddPixelx = (width %aFrameWidth) %2;
+    int anOddPixely = (height%aFrameHeight)%2;
+
+    // calculate scale factor for full frames
+    Standard_Real aScalex = (Standard_Real)width /aFrameWidth;
+    Standard_Real aScaley = (Standard_Real)height/aFrameHeight;
+
+    // calculate and set the text scaling factor for printing context
+    GLfloat aScaleRatex = (GLfloat)aFrameWidth /viewWidth;
+    GLfloat aScaleRatey = (GLfloat)aFrameHeight/viewHeight;
+    aPrinterContext.SetScale (aScaleRatex*(GLfloat)aScalex,
+                              aScaleRatey*(GLfloat)aScaley);
+
+    // initialize projection matrix for printer context
+    TColStd_Array2OfReal aProj (0, 3, 0, 3);
+    Standard_Real aDef = 0;
+    aProj.Init (aDef);
+    aProj(2,2) = 1.0;
+    aProj(3,3) = 1.0;
+
+    // projection matrix offsets for printer context
+    // offsets are even numbers
+    Standard_Real aOffsetx(0), aOffsety(0);
+    aOffsetx = -(aTotalx-1);
+    aOffsety = -(aTotaly-1);
+
+    // rect of frame image that will be copied
+    // and coordinates in view image where to put it
+    Standard_Integer aLeft = 0, aRight = 0, aBottom = 0, aTop = 0;
+    Standard_Integer aSubLeft = (Standard_Integer)aDevOffx;
+    Standard_Integer aSubTop  = (Standard_Integer)aDevOffy;
+
+    // draw sequence of full frames
+    for (int i = 0; i < aTotalx; i++)
     {
-      DestroyWindow(w);
+      // offsets are even numbers
+      aOffsety = -(aTotaly-1);
+      aSubTop  =  (Standard_Integer)aDevOffy;
+
+      // calculate cropped frame rect
+      aLeft  = (i == 0) ? aPxCropx : 0;
+      aRight = (i == aTotalx-1) ? aFrameWidth-(aPxCropx+anOddPixelx) :
+                                  aFrameWidth;
+
+      for (int j = 0; j < aTotaly; j++)
+      {
+        // no offset for single frames
+        aProj(3,0) = (aTotalx == 1) ? 0 : -aOffsetx;
+        aProj(3,1) = (aTotaly == 1) ? 0 :  aOffsety;
+
+        // set projection matrix
+        aProj(0,0) = aScalex;
+        aProj(1,1) = aScaley;
+        aPrinterContext.SetProjTransformation (aProj);
+
+        // calculate cropped frame rect
+        aTop    = (j == 0)         ? aPxCropy : 0;
+        aBottom = (j == aTotaly-1) ? aFrameHeight-(aPxCropy+anOddPixely) :
+                                     aFrameHeight;
+
+        // draw to the offscreen buffer and capture the result
+        aFrameBuffer->SetupViewport ();
+        redrawView (aview, anunderlayer, anoverlayer, background);
+        glReadPixels (0, 0, aFrameWidth, aFrameHeight,
+                      GL_BGR_EXT, GL_UNSIGNED_BYTE, (GLvoid* )aViewBuffer);
+#ifdef HAVE_FREEIMAGE
+        // cut out pixels that are out of printing area
+        isDone = imagePasteDC (hPrnDC, aViewImage, aSubLeft, aSubTop,
+                               aRight-aLeft, aBottom-aTop, aLeft, aTop);
+#else
+        isDone = BitBlt (hPrnDC, aSubLeft, aSubTop, aRight-aLeft, aBottom-aTop,
+                         hMemDC, aLeft, aTop, SRCCOPY);
+#endif
+
+        // stop operation if errors
+        if (!isDone)
+          break;
+
+        // calculate new view offset for y-coordinate
+        aOffsety += 2.0;
+        aSubTop  += aBottom-aTop;
+      }
+
+      // stop operation if errors
+      if (!isDone)
+        break;
+ 
+      // calculate new view offset for x-coordinate
+      aOffsetx += 2.0;
+      aSubLeft += aRight-aLeft;
     }
+  }
 
-    /* End of clean memory *****************************************************************/
+  // complete printing or indicate an error
+  if (GetObjectType (hPrnDC) == OBJ_DC && isDone == true)
+  {
+    EndPage (hPrnDC);
+    EndDoc (hPrnDC);
   }
+  else if (isDone == false)
+  {
+    MessageBox (NULL, "Print failed: insufficient memory or spool error.\nPlease use smaller printer resolution.",
+                "The opeartion couldn't be completed.", MB_OK);
+    if (GetObjectType (hPrnDC) == OBJ_DC)
+      AbortDoc (hPrnDC);
+  }
+  
+  // return OpenGl to the previous state
+  aPrinterContext.Deactivate ();
+  glPixelStorei (GL_PACK_ALIGNMENT, anAlignBack);
+  aFrameBuffer->UnbindBuffer();
+  glViewport (aViewPortBack[0], aViewPortBack[1], 
+              aViewPortBack[2], aViewPortBack[3]);
+  if (aPrevBuffer)
+    aPrevBuffer->ChangeViewport (aPrevBufferX, aPrevBufferY);
+  else
+    delete aFrameBuffer;
+
+  // delete resources
+#ifndef HAVE_FREEIMAGE
+  if (hViewBitmap)
+  {
+    SelectObject (hMemDC, hViewBitmapOld);
+    DeleteObject (hViewBitmap);
+  }
+  DeleteDC (hMemDC);
+#endif
+
+  return (Standard_Boolean) isDone;
 
-  /* End main routine ********************************************************************/
-  return;
-#endif /*WNT*/
+#else // not WNT
+  return Standard_False;
+#endif 
 }
+
diff --git a/src/OpenGl/OpenGl_togl_redraw.cxx b/src/OpenGl/OpenGl_togl_redraw.cxx
index 34fd933..8cc25a4 100644
--- a/src/OpenGl/OpenGl_togl_redraw.cxx
+++ b/src/OpenGl/OpenGl_togl_redraw.cxx
@@ -93,6 +93,7 @@ call_togl_redraw
     }
     OpenGl_ResourceCleaner::GetInstance()->Cleanup();
     call_func_redraw_all_structs_begin (aview->WsId);
+    call_subr_displayCB (aview, OCC_REDRAW_WINDOW | OCC_PRE_REDRAW);
     call_togl_setplane( aview );
     if (anunderlayer->ptrLayer)
     {
@@ -171,6 +172,7 @@ call_togl_redraw_area
                  (GLsizei )width, (GLsizei )height);
       OpenGl_ResourceCleaner::GetInstance()->Cleanup();
       call_func_redraw_all_structs_begin (aview->WsId);
+      call_subr_displayCB (aview, OCC_REDRAW_WINDOWAREA | OCC_PRE_REDRAW);
       call_togl_setplane( aview );
       if (anunderlayer->ptrLayer)
       {
diff --git a/src/OpenGl/OpenGl_togl_text.cxx b/src/OpenGl/OpenGl_togl_text.cxx
index 352455b..9774902 100644
--- a/src/OpenGl/OpenGl_togl_text.cxx
+++ b/src/OpenGl/OpenGl_togl_text.cxx
@@ -78,7 +78,6 @@ call_togl_text
   call_func_set_anno_char_up_vec (up_vect);
   call_func_set_anno_path (path);
   call_func_set_anno_align (hor_align, ver_align);
-  call_func_anno_text_rel3 (&text_pt, (Tchar*)atext->string);
+  call_func_anno_text_rel3 (&text_pt, (Techar*)atext->string);
   if (! agroup->IsOpen) call_togl_closegroup (agroup);
-  return;
 }
diff --git a/src/OpenGl/OpenGl_triedron.cxx b/src/OpenGl/OpenGl_triedron.cxx
index 5da2dab..c0fa5ed 100644
--- a/src/OpenGl/OpenGl_triedron.cxx
+++ b/src/OpenGl/OpenGl_triedron.cxx
@@ -299,7 +299,6 @@ TStatus call_triedron_redraw (
 
   GLuint fontBase = 0;
   GLint mode;
-  char AxeName[]="X\0";
 
 #ifdef QTOCC_PATCH /* PCD 10/02/08 */
   /* Fix to problem with clipping planes chopping off pieces of the triedron */
@@ -581,25 +580,22 @@ TStatus call_triedron_redraw (
   OpenGl_TextRender* textRender=OpenGl_TextRender::instance();
 
   /* Axe X */
-  strcpy ( AxeName, "X\0" );
   TriedronCoord[0] = TriedronOrigin[0] + ( L + rayon ) ;
   TriedronCoord[1] = TriedronOrigin[1] + 0.0;
   TriedronCoord[2] = TriedronOrigin[2] - rayon ;
+  textRender->RenderText(L"X", fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2] );
 
-  textRender->RenderText(AxeName, fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2] );
   /* Axe Y */
-  strcpy ( AxeName, "Y\0" );
   TriedronCoord[0] = TriedronOrigin[0] + rayon ;
   TriedronCoord[1] = TriedronOrigin[1] + ( L + 3.0 * rayon ) ;
   TriedronCoord[2] = TriedronOrigin[2] + ( 2.0 * rayon );
-  textRender->RenderText(AxeName, fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2]);
+  textRender->RenderText(L"Y", fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2]);
+
   /* Axe Z */
-  strcpy ( AxeName, "Z\0" );
   TriedronCoord[0] = TriedronOrigin[0] + ( - 2.0 * rayon ) ;
   TriedronCoord[1] = TriedronOrigin[1] +  rayon/2. ;
   TriedronCoord[2] = TriedronOrigin[2] + ( L + 3.0 * rayon ) ;
-
-  textRender->RenderText(AxeName, fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2]);
+  textRender->RenderText(L"Z", fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2]);
 
 #ifdef QTOCC_PATCH /* PCD 10/02/08 */
   /* Recover the clip planes */
@@ -658,7 +654,6 @@ TStatus call_zbuffer_triedron_redraw (
   GLdouble TriedronCoord[3] = { 1.0, 0.0, 0.0 };
 
   GLuint fontBase = 0;
-  char AxeName[]="X\0";
 
   GLuint startList;
   GLUquadricObj* aQuadric;
@@ -1092,27 +1087,22 @@ TStatus call_zbuffer_triedron_redraw (
   OpenGl_TextRender* textRender=OpenGl_TextRender::instance();
 
   /* Axe X */
-  strcpy ( AxeName, "X\0" );
   TriedronCoord[0] = TriedronOrigin[0] + ( L + rayon ) ;
   TriedronCoord[1] = TriedronOrigin[1] + 0.0;
   TriedronCoord[2] = TriedronOrigin[2] - rayon ;
-
-  textRender->RenderText(AxeName, fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2]);
+  textRender->RenderText(L"X", fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2]);
 
   /* Axe Y */
-  strcpy ( AxeName, "Y\0" );
   TriedronCoord[0] = TriedronOrigin[0] + rayon ;
   TriedronCoord[1] = TriedronOrigin[1] + ( L + 3.0 * rayon ) ;
   TriedronCoord[2] = TriedronOrigin[2] + ( 2.0 * rayon );
-
-  textRender->RenderText(AxeName, fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2]);
+  textRender->RenderText(L"Y", fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2]);
 
   /* Axe Z */
-  strcpy ( AxeName, "Z\0" );
   TriedronCoord[0] = TriedronOrigin[0] + ( - 2.0 * rayon ) ;
   TriedronCoord[1] = TriedronOrigin[1] +  rayon/2. ;
   TriedronCoord[2] = TriedronOrigin[2] + ( L + 3.0 * rayon ) ;
-  textRender->RenderText(AxeName, fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2]);
+  textRender->RenderText(L"Z", fontBase, 0, (float)TriedronCoord[0], (float)TriedronCoord[1], (float)TriedronCoord[2]);
 
 #ifdef QTOCC_PATCH 
   /*PCD 17/06/07    */
diff --git a/src/OpenGl/OpenGl_txgl.cxx b/src/OpenGl/OpenGl_txgl.cxx
index 2f29681..1fe42cc 100644
--- a/src/OpenGl/OpenGl_txgl.cxx
+++ b/src/OpenGl/OpenGl_txgl.cxx
@@ -177,70 +177,83 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
 #ifndef WNT
 
     GLCONTEXT ctx;
-    static int sdesc[11];
     Colormap cmap;
     XVisualInfo* vis=NULL;
     /*    XVisualInfo tmplt;*/
     XSetWindowAttributes cwa;
     XColor color;
-    /*    Tint i, n, nret;*/
-    Tint n;
-    Tint scr;
     int value;
     char string[CALL_DEF_STRING_LENGTH];
-    int DBuffer = True;
-    XWindowAttributes wattr;
-
     WINDOW win;
 
-    unsigned long mask = 0;
-    /*    unsigned long background_pixel = 0;*/
-
-    if (call_util_osd_getenv("CALL_OPENGL_NO_DBF", string, CALL_DEF_STRING_LENGTH))
-      DBuffer    = False;
+    int DBuffer = (call_util_osd_getenv ("CALL_OPENGL_NO_DBF", string, CALL_DEF_STRING_LENGTH)) ? False : True;
 
     if (call_util_osd_getenv("JWR_PIXMAP_DB", string, CALL_DEF_STRING_LENGTH))
       TelSetPixmapDB(1);
 
-    XGetWindowAttributes( disp , par , &wattr );
-
-    n = 0;
-    sdesc[n] = GLX_RGBA;n++;
+    XWindowAttributes wattr;
+    XGetWindowAttributes (disp, par, &wattr);
+    Tint scr = DefaultScreen (disp);
 
-    sdesc[n] = GLX_DEPTH_SIZE;n++;
-    sdesc[n] = 1;n++;
+#if defined(__linux) || defined(Linux)
+    {
+      XVisualInfo aVisInfo;
+      int aNbItems;
+      int isGl, isDoubleBuffer, isRGBA, aDepthSize;
+      unsigned long aVisInfoMask = VisualIDMask | VisualScreenMask;
+      aVisInfo.visualid = wattr.visual->visualid;
+      aVisInfo.screen   = DefaultScreen (disp);
+      vis = XGetVisualInfo (disp, aVisInfoMask, &aVisInfo, &aNbItems);
+      if (vis != NULL)
+      {
+        // check Visual for OpenGl context's parameters compability
+        if (glXGetConfig (disp, vis, GLX_USE_GL, &isGl) != 0)
+          isGl = 0;
 
-    sdesc[n] = GLX_RED_SIZE;n++;
-    sdesc[n] = (wattr.depth <= 8) ? 0 : 1;n++;
+        if (glXGetConfig (disp, vis, GLX_RGBA, &isRGBA) != 0)
+          isRGBA = 0;
 
-    sdesc[n] = GLX_GREEN_SIZE;n++;
-    sdesc[n] = (wattr.depth <= 8) ? 0 : 1;n++;
+        if (glXGetConfig (disp, vis, GLX_DOUBLEBUFFER, &isDoubleBuffer) != 0)
+          isDoubleBuffer = 0;
 
-    sdesc[n] = GLX_BLUE_SIZE;n++;
-    sdesc[n] = (wattr.depth <= 8) ? 0 : 1;n++;
+        if (glXGetConfig (disp, vis, GLX_DEPTH_SIZE, &aDepthSize) != 0)
+          aDepthSize = 0;
 
-    if (DBuffer) {
-      sdesc[n] = GLX_DOUBLEBUFFER;n++;
+        if (!isGl || !aDepthSize || !isRGBA  || isDoubleBuffer != DBuffer)
+        {
+          XFree (vis);
+          vis = NULL;
+        }
+      }
     }
+#endif
 
-    sdesc[n] = None;n++;
+    if (vis == NULL)
+    {
+      int anIter = 0;
+      int anAttribs[11];
+      anAttribs[anIter++] = GLX_RGBA;
 
-    scr = DefaultScreen( disp );
+      anAttribs[anIter++] = GLX_DEPTH_SIZE;
+      anAttribs[anIter++] = 1;
 
-#if defined(__linux) || defined(Linux)
-    {
-      XVisualInfo vinfo;
-      int ninfo;
-      unsigned long vmask = VisualIDMask |  VisualScreenMask;
-      vinfo.visualid = wattr.visual->visualid;
-      vinfo.screen = DefaultScreen( disp );
-      vis = XGetVisualInfo( disp, vmask, &vinfo, &ninfo);
-    }
-#endif
+      anAttribs[anIter++] = GLX_RED_SIZE;
+      anAttribs[anIter++] = (wattr.depth <= 8) ? 0 : 1;
 
-    if( !vis )
-      vis = glXChooseVisual( disp, scr, sdesc );
-    if( !vis) return TFailure;
+      anAttribs[anIter++] = GLX_GREEN_SIZE;
+      anAttribs[anIter++] = (wattr.depth <= 8) ? 0 : 1;
+
+      anAttribs[anIter++] = GLX_BLUE_SIZE;
+      anAttribs[anIter++] = (wattr.depth <= 8) ? 0 : 1;
+
+      if (DBuffer)
+        anAttribs[anIter++] = GLX_DOUBLEBUFFER;
+
+      anAttribs[anIter++] = None;
+
+      vis = glXChooseVisual (disp, scr, anAttribs);
+      if (vis == NULL) return TFailure;
+    }
 
 #ifdef TRACE
     printf ("TxglCreateWindow \n");
@@ -271,22 +284,8 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
     */
 
     glXGetConfig( disp, vis, GLX_RED_SIZE, &value );
-
-    if ( value < 8 ) {
-      DitherProp = True;
-    }
-    else
-    {
-      DitherProp = False;
-    }
-
-    if ( vis->depth <= 8 ) {
-      BackDitherProp = True;
-    }
-    else
-    {
-      BackDitherProp = False;
-    }
+    DitherProp = (value < 8) ? True : False;
+    BackDitherProp = (vis->depth <= 8) ? True : False;
 
 #ifdef TRACE
     printf("Dithering %d BackDithering %d \n",DitherProp,BackDitherProp);
@@ -334,7 +333,7 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
     cwa.border_pixel  = color.pixel;
     cwa.background_pixel = color.pixel;
 
-    mask = CWBackPixel | CWColormap | CWBorderPixel | CWEventMask;
+    unsigned long mask = CWBackPixel | CWColormap | CWBorderPixel | CWEventMask;
 
     if( vis->visualid == wattr.visual->visualid ) {
       win = par;
@@ -682,9 +681,9 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
     }
     if (!i)
     {
-      errorcode = glGetError();
-      errorstring = gluErrorString(errorcode);
-      printf("glXMakeCurrent failed: %d %s\n", errorcode, errorstring);
+      // if there is no current context it might be impossible to use
+      // glGetError correctly
+      printf("glXMakeCurrent failed!\n");
     }
 
     return  i == True ? TSuccess : TFailure;
diff --git a/src/OpenGl/OpenGl_view.cxx b/src/OpenGl/OpenGl_view.cxx
index 5a23926..3402ce1 100644
--- a/src/OpenGl/OpenGl_view.cxx
+++ b/src/OpenGl/OpenGl_view.cxx
@@ -87,6 +87,7 @@ if any was defined
 #include <OpenGl_txgl.hxx>
 #include <OpenGl_Memory.hxx>
 #include <Standard_TypeDef.hxx>
+#include <OpenGl_PrinterContext.hxx>
 
 /*----------------------------------------------------------------------*/
 /*
@@ -842,7 +843,22 @@ TelSetViewIndex( Tint  Wsid /* Workstation id */,
   printf("OpenGl_view.c::TelSetViewIndex::glMatrixMode(GL_PROJECTION) \n"); 
 #endif
   glMatrixMode(GL_PROJECTION);
-  glLoadMatrixf((GLfloat *) vptr->vrep.mapping_matrix );
+  glLoadIdentity();
+
+#ifdef WNT
+  // add printing scale/tiling transformation
+  OpenGl_PrinterContext* aPrinterContext = 
+    OpenGl_PrinterContext::GetPrinterContext(GET_GL_CONTEXT());
+
+  if (aPrinterContext)
+  {
+    GLfloat aProjMatrix[16];
+    aPrinterContext->GetProjTransformation(aProjMatrix);
+    glLoadMatrixf((GLfloat*) aProjMatrix);
+  }
+#endif
+
+  glMultMatrixf((GLfloat *) vptr->vrep.mapping_matrix );
 
 #ifdef TRACE_MAT
   printf( "\nTelSetViewIndex WS : %d, view : %d", Wsid, Vid );
diff --git a/src/PCDM/PCDM.cdl b/src/PCDM/PCDM.cdl
index 57d0d17..1406021 100644
--- a/src/PCDM/PCDM.cdl
+++ b/src/PCDM/PCDM.cdl
@@ -29,9 +29,25 @@ is
 	    RS_UnrecognizedFileFormat, 
 	    RS_MakeFailure,		     
 	    RS_PermissionDenied, 
-	    RS_DriverFailure
+	    RS_DriverFailure,
+	    RS_AlreadyRetrievedAndModified,
+	    RS_AlreadyRetrieved,
+	    RS_UnknownDocument,
+	    RS_WrongResource,
+	    RS_NoModel
     end ReaderStatus;
-
+    
+    enumeration StoreStatus is
+	    SS_OK,
+	    SS_DriverFailure,
+	    SS_WriteFailure,
+	    SS_Failure,
+	    SS_DiskWritingFailure,
+	    SS_UserRightsFailure,
+	    SS_Doc_IsNull,
+	    SS_No_Obj,
+	    SS_Info_Section_Error
+    end StoreStatus;
     
     deferred class Document;
     class SequenceOfDocument instantiates Sequence from TCollection(Document from PCDM);
@@ -84,4 +100,3 @@ is
     returns TypeOfFileDriver from PCDM
     is private;
 end PCDM;
-
diff --git a/src/PCDM/PCDM_StorageDriver.cdl b/src/PCDM/PCDM_StorageDriver.cdl
index 85263c0..9b3d339 100644
--- a/src/PCDM/PCDM_StorageDriver.cdl
+++ b/src/PCDM/PCDM_StorageDriver.cdl
@@ -23,7 +23,15 @@ deferred class StorageDriver from PCDM inherits Writer from PCDM
     --          
     ---Category: persistent implemention of storage.
 
-uses Document from CDM, Document from PCDM, Data from Storage, ExtendedString from TCollection, Schema from Storage,SequenceOfExtendedString from TColStd, SequenceOfDocument from PCDM
+uses
+    Document from CDM,
+    Document from PCDM,
+    Data from Storage,
+    ExtendedString from TCollection,
+    Schema from Storage,
+    SequenceOfExtendedString from TColStd,
+    SequenceOfDocument from PCDM,
+    StoreStatus from PCDM
 
 raises NoSuchObject from Standard,DriverError from PCDM
 is
@@ -62,9 +70,17 @@ is
 
     GetFormat (me)
     returns ExtendedString from TCollection;
-
+    
+    IsError   (me) returns Boolean from Standard;
+    SetIsError(me : mutable; theIsError : Boolean);
+    
+    GetStoreStatus   (me) returns StoreStatus from PCDM;
+    SetStoreStatus(me : mutable; theStoreStatus : StoreStatus from PCDM);
+ 
 fields 
 
     myFormat : ExtendedString from TCollection;
+    myIsError: Boolean        from Standard;
+    myStoreStatus: StoreStatus from PCDM;
 
 end StorageDriver from PCDM;
diff --git a/src/PCDM/PCDM_StorageDriver.cxx b/src/PCDM/PCDM_StorageDriver.cxx
index dd19fc5..a0cb0b3 100644
--- a/src/PCDM/PCDM_StorageDriver.cxx
+++ b/src/PCDM/PCDM_StorageDriver.cxx
@@ -133,3 +133,40 @@ TCollection_ExtendedString PCDM_StorageDriver::GetFormat () const
 {
   return myFormat;
 }
+
+//=======================================================================
+//function : IsError
+//purpose  :
+//=======================================================================
+
+Standard_Boolean PCDM_StorageDriver::IsError () const 
+{
+  return myIsError;
+}
+
+//=======================================================================
+//function : SetIsError
+//purpose  :
+//=======================================================================
+void PCDM_StorageDriver::SetIsError(const Standard_Boolean theIsError)
+{
+    myIsError = theIsError;
+}
+
+//=======================================================================
+//function : GetStoreStatus
+//purpose  :
+//=======================================================================
+
+PCDM_StoreStatus PCDM_StorageDriver::GetStoreStatus () const 
+{
+  return myStoreStatus;
+}
+//=======================================================================
+//function : SetStoreStatus
+//purpose  :
+//=======================================================================
+void PCDM_StorageDriver::SetStoreStatus(const PCDM_StoreStatus theStoreStatus)
+{
+    myStoreStatus = theStoreStatus;
+}
diff --git a/src/Plugin/Plugin.cdl b/src/Plugin/Plugin.cdl
index 901f121..238531a 100644
--- a/src/Plugin/Plugin.cdl
+++ b/src/Plugin/Plugin.cdl
@@ -12,7 +12,7 @@ is
 
     exception Failure inherits Failure from Standard;
 
-    private class MapOfFunctions instantiates DataMap from TCollection(AsciiString from TCollection ,Function from OSD, AsciiString from TCollection);
+    class MapOfFunctions instantiates DataMap from TCollection(AsciiString from TCollection ,Function from OSD, AsciiString from TCollection);
 
 
     Load(aGUID: GUID from Standard) returns Transient from Standard
diff --git a/src/Poly/Poly_Connect.cxx b/src/Poly/Poly_Connect.cxx
index 83fcfbb..49999fa 100644
--- a/src/Poly/Poly_Connect.cxx
+++ b/src/Poly/Poly_Connect.cxx
@@ -225,8 +225,8 @@ void Poly_Connect::Initialize(const Standard_Integer N)
 void Poly_Connect::Next()
 {
   Standard_Integer i, j;
-  static Standard_Integer n[3];
-  static Standard_Integer t[3];
+  Standard_Integer n[3];
+  Standard_Integer t[3];
   const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();
   Triangles(mytr, t[0], t[1], t[2]);
   if (mysense) {
diff --git a/src/RWStl/RWStl.cdl b/src/RWStl/RWStl.cdl
index d6685e6..24cd048 100644
--- a/src/RWStl/RWStl.cdl
+++ b/src/RWStl/RWStl.cdl
@@ -21,24 +21,28 @@ uses
 
     OSD, 
     Standard, 
-    StlMesh 
+    StlMesh,
+    Message
     
 is 
 
-	WriteBinary (aMesh : Mesh from StlMesh; aPath : Path from OSD) 
+	WriteBinary (aMesh : Mesh from StlMesh; aPath : Path from OSD;
+	    aProgInd : ProgressIndicator from Message = NULL) 
     	    	returns Boolean from Standard;
 	  ---Purpose : write the meshing in a file following the 
 	  --         binary format of an STL file.
 	  --         Returns false if the cannot be opened; 	    	
 
-	WriteAscii (aMesh : Mesh from StlMesh; aPath : Path from OSD) 
+	WriteAscii (aMesh : Mesh from StlMesh; aPath : Path from OSD;
+	    aProgInd : ProgressIndicator from Message = NULL) 
     	    	returns Boolean from Standard;
 	  ---Purpose : write the meshing in a file following the 
 	  --         Ascii  format of an STL file. 	    	
 	  --         Returns false if the cannot be opened; 	    	
 
 
-    	ReadFile   (aPath : Path from OSD) returns
+    	ReadFile   (aPath : Path from OSD;
+	    aProgInd : ProgressIndicator from Message = NULL) returns
     	    	Mesh from StlMesh;
 	  ---Purpose : This method will chwck if the file is a binary 
 	  --         file or an AsciiFile testing  the 5 first 
@@ -46,7 +50,8 @@ is
 	  --         ascii file. If we do not find that word we assume 
 	  --         that it is a binary file.	
 
-    	ReadBinary (aPath : Path from OSD) returns 
+    	ReadBinary (aPath : Path from OSD;
+	    aProgInd : ProgressIndicator from Message = NULL) returns 
     	    	Mesh from StlMesh;
 	 ---Purpose : Read a meshing from a binary file
 	 --        Raises NoMoreObject from Standard if a statement 
@@ -54,7 +59,8 @@ is
 	 --        Raises TypeMisMatch if a token has not the good 
 	 --        type (often real)
 
-    	ReadAscii (aPath : Path from OSD) returns 
+    	ReadAscii (aPath : Path from OSD;
+	    aProgInd : ProgressIndicator from Message = NULL) returns 
     	    	Mesh from StlMesh;
 	 ---Purpose : Read a meshing from a binary file
 	 --        Raises NoMoreObject from Standard if a statement 
diff --git a/src/RWStl/RWStl.cxx b/src/RWStl/RWStl.cxx
index a535873..cc23e01 100644
--- a/src/RWStl/RWStl.cxx
+++ b/src/RWStl/RWStl.cxx
@@ -8,6 +8,7 @@
 #include <RWStl.ixx>
 #include <OSD_Protection.hxx>
 #include <OSD_File.hxx>
+#include <Message_ProgressSentry.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <Standard_NoMoreObject.hxx>
 #include <Standard_TypeMismatch.hxx>
@@ -26,6 +27,7 @@ static const int HEADER_SIZE           =  84;
 static const int SIZEOF_STL_FACET      =  50;
 static const int STL_MIN_FILE_SIZE     = 284;
 static const int ASCII_LINES_PER_FACET =   7;
+static const int IND_THRESHOLD         = 1000; // increment the indicator every 1k triangles
 
 //=======================================================================
 //function : WriteInteger
@@ -108,94 +110,114 @@ inline static Standard_Real ReadFloat2Double(OSD_File &aFile)
 //purpose  : write a binary STL file in Little Endian format
 //=======================================================================
 
-Standard_Boolean RWStl::WriteBinary(const Handle(StlMesh_Mesh)& aMesh, const OSD_Path& aPath)
+Standard_Boolean RWStl::WriteBinary (const Handle(StlMesh_Mesh)& theMesh,
+                                     const OSD_Path& thePath,
+                                     const Handle(Message_ProgressIndicator)& theProgInd)
 {
-
-  OSD_File theFile = OSD_File (aPath);
-  theFile.Build(OSD_WriteOnly,OSD_Protection());
+  OSD_File aFile (thePath);
+  aFile.Build (OSD_WriteOnly, OSD_Protection());
 
   Standard_Real x1, y1, z1;
   Standard_Real x2, y2, z2;
   Standard_Real x3, y3, z3;
 
-  //pgo  Standard_Real x,y,z;
-
+  // writing 80 bytes of the trash?
   char sval[80];
-  Standard_Integer NBTRIANGLES=0;
-  unsigned int NBT;
-  NBTRIANGLES = aMesh->NbTriangles();
-  NBT = NBTRIANGLES ;
-  theFile.Write ((Standard_Address)sval,80);
-  WriteInteger(theFile,NBT);
-//  theFile.Write ((Standard_Address)&NBT,4);
+  aFile.Write ((Standard_Address)sval,80);
+  WriteInteger (aFile, theMesh->NbTriangles());
+
   int dum=0;
-  StlMesh_MeshExplorer aMexp (aMesh);
-
-
-  for (Standard_Integer nbd=1;nbd<=aMesh->NbDomains();nbd++) {
-    for (aMexp.InitTriangle (nbd); aMexp.MoreTriangle (); aMexp.NextTriangle ()) {
-	aMexp.TriangleVertices (x1,y1,z1,x2,y2,z2,x3,y3,z3);
-	//pgo	  aMexp.TriangleOrientation (x,y,z);
-	gp_XYZ Vect12 ((x2-x1), (y2-y1), (z2-z1));
-	gp_XYZ Vect13 ((x3-x1), (y3-y1), (z3-z1));
-	gp_XYZ Vnorm = Vect12 ^ Vect13;
-	Standard_Real Vmodul = Vnorm.Modulus ();
-	if (Vmodul > gp::Resolution()) {
-	  Vnorm.Divide(Vmodul);
-	}
-	else {
-	  // si Vnorm est quasi-nul, on le charge a 0 explicitement
-	  Vnorm.SetCoord (0., 0., 0.);
-	}
-
-	WriteDouble2Float (theFile,Vnorm.X());
-	WriteDouble2Float (theFile,Vnorm.Y());
-	WriteDouble2Float (theFile,Vnorm.Z());
-
-	WriteDouble2Float (theFile,x1);
-	WriteDouble2Float (theFile,y1);
-	WriteDouble2Float (theFile,z1);
-
-	WriteDouble2Float (theFile,x2);
-	WriteDouble2Float (theFile,y2);
-	WriteDouble2Float (theFile,z2);
-
-	WriteDouble2Float (theFile,x3);
-	WriteDouble2Float (theFile,y3);
-	WriteDouble2Float (theFile,z3);
-
-	theFile.Write (&dum,2);
+  StlMesh_MeshExplorer aMexp (theMesh);
+
+  // create progress sentry for domains
+  Standard_Integer aNbDomains = theMesh->NbDomains();
+  Message_ProgressSentry aDPS (theProgInd, "Mesh domains", 0, aNbDomains, 1);
+  for (Standard_Integer nbd = 1; nbd <= aNbDomains && aDPS.More(); nbd++, aDPS.Next())
+  {
+    // create progress sentry for triangles in domain
+    Message_ProgressSentry aTPS (theProgInd, "Triangles", 0,
+        theMesh->NbTriangles (nbd), IND_THRESHOLD);
+    Standard_Integer aTriangleInd = 0;
+    for (aMexp.InitTriangle (nbd); aMexp.MoreTriangle(); aMexp.NextTriangle())
+    {
+      aMexp.TriangleVertices (x1,y1,z1,x2,y2,z2,x3,y3,z3);
+      //pgo	  aMexp.TriangleOrientation (x,y,z);
+      gp_XYZ Vect12 ((x2-x1), (y2-y1), (z2-z1));
+      gp_XYZ Vect13 ((x3-x1), (y3-y1), (z3-z1));
+      gp_XYZ Vnorm = Vect12 ^ Vect13;
+      Standard_Real Vmodul = Vnorm.Modulus ();
+      if (Vmodul > gp::Resolution())
+      {
+        Vnorm.Divide(Vmodul);
+      }
+      else
+      {
+        // si Vnorm est quasi-nul, on le charge a 0 explicitement
+        Vnorm.SetCoord (0., 0., 0.);
+      }
+
+      WriteDouble2Float (aFile, Vnorm.X());
+      WriteDouble2Float (aFile, Vnorm.Y());
+      WriteDouble2Float (aFile, Vnorm.Z());
 
+      WriteDouble2Float (aFile, x1);
+      WriteDouble2Float (aFile, y1);
+      WriteDouble2Float (aFile, z1);
+
+      WriteDouble2Float (aFile, x2);
+      WriteDouble2Float (aFile, y2);
+      WriteDouble2Float (aFile, z2);
+
+      WriteDouble2Float (aFile, x3);
+      WriteDouble2Float (aFile, y3);
+      WriteDouble2Float (aFile, z3);
+
+      aFile.Write (&dum, 2);
+
+      // update progress only per 1k triangles
+      if (++aTriangleInd % IND_THRESHOLD == 0)
+      {
+        if (!aTPS.More())
+          break;
+        aTPS.Next();
       }
+    }
   }
-
-  theFile.Close ();
-  return Standard_True;
+  aFile.Close();
+  Standard_Boolean isInterrupted = !aDPS.More();
+  return !isInterrupted;
 }
 //=======================================================================
 //function : WriteAscii
 //purpose  : write an ASCII STL file
 //=======================================================================
 
-Standard_Boolean RWStl::WriteAscii(const Handle(StlMesh_Mesh)& aMesh, const OSD_Path& aPath)
+Standard_Boolean RWStl::WriteAscii (const Handle(StlMesh_Mesh)& theMesh,
+                                    const OSD_Path& thePath,
+                                    const Handle(Message_ProgressIndicator)& theProgInd)
 {
-  OSD_File theFile = OSD_File (aPath);
+  OSD_File theFile (thePath);
   theFile.Build(OSD_WriteOnly,OSD_Protection());
-  TCollection_AsciiString buf = TCollection_AsciiString ("solid\n");
+  TCollection_AsciiString buf ("solid\n");
   theFile.Write (buf,buf.Length());buf.Clear();
 
   Standard_Real x1, y1, z1;
   Standard_Real x2, y2, z2;
   Standard_Real x3, y3, z3;
-
-  //pgo  Standard_Real x,y,z;
-
-  char sval[16];
-
-  StlMesh_MeshExplorer aMexp (aMesh);
-
-  for (Standard_Integer nbd=1;nbd<=aMesh->NbDomains();nbd++) {
-    for (aMexp.InitTriangle (nbd); aMexp.MoreTriangle (); aMexp.NextTriangle ()) {
+  char sval[512];
+
+  // create progress sentry for domains
+  Standard_Integer aNbDomains = theMesh->NbDomains();
+  Message_ProgressSentry aDPS (theProgInd, "Mesh domains", 0, aNbDomains, 1);
+  StlMesh_MeshExplorer aMexp (theMesh);
+  for (Standard_Integer nbd = 1; nbd <= aNbDomains && aDPS.More(); nbd++, aDPS.Next())
+  {
+    // create progress sentry for triangles in domain
+    Message_ProgressSentry aTPS (theProgInd, "Triangles", 0,
+        theMesh->NbTriangles (nbd), IND_THRESHOLD);
+    Standard_Integer aTriangleInd = 0;
+    for (aMexp.InitTriangle (nbd); aMexp.MoreTriangle(); aMexp.NextTriangle())
+    {
       aMexp.TriangleVertices (x1,y1,z1,x2,y2,z2,x3,y3,z3);
 
 //      Standard_Real x, y, z;
@@ -203,76 +225,47 @@ Standard_Boolean RWStl::WriteAscii(const Handle(StlMesh_Mesh)& aMesh, const OSD_
 
       gp_XYZ Vect12 ((x2-x1), (y2-y1), (z2-z1));
       gp_XYZ Vect23 ((x3-x2), (y3-y2), (z3-z2));
-	gp_XYZ Vnorm = Vect12 ^ Vect23;
+      gp_XYZ Vnorm = Vect12 ^ Vect23;
       Standard_Real Vmodul = Vnorm.Modulus ();
-      if (Vmodul > gp::Resolution()){
-	Vnorm.Divide (Vmodul);
+      if (Vmodul > gp::Resolution())
+      {
+        Vnorm.Divide (Vmodul);
       }
-      else {
-	// si Vnorm est quasi-nul, on le charge a 0 explicitement
-	Vnorm.SetCoord (0., 0., 0.);
+      else
+      {
+        // si Vnorm est quasi-nul, on le charge a 0 explicitement
+        Vnorm.SetCoord (0., 0., 0.);
       }
-      buf += " facet normal ";
-      sprintf (sval,"% 12e",Vnorm.X());
-      buf += sval;
-      buf += " ";
-      sprintf (sval,"% 12e",Vnorm.Y());
-      buf += sval;
-      buf += " ";
-      sprintf (sval,"% 12e",Vnorm.Z());
-      buf += sval;
-      buf += '\n';
-      theFile.Write (buf,buf.Length());buf.Clear();
-      buf += "   outer loop\n";
-      theFile.Write (buf,buf.Length());buf.Clear();
-
-      buf += "     vertex ";
-      sprintf (sval,"% 12e",x1);
-      buf += sval;
-      buf += " ";
-      sprintf (sval,"% 12e",y1);
-      buf += sval;
-      buf += " ";
-      sprintf (sval,"% 12e",z1);
-      buf += sval;
-      buf += '\n';
-      theFile.Write (buf,buf.Length());buf.Clear();
-
-      buf += "     vertex ";
-      sprintf (sval,"% 12e",x2);
-      buf += sval;
-      buf += " ";
-      sprintf (sval,"% 12e",y2);
+      sprintf (sval,
+          " facet normal % 12e % 12e % 12e\n"
+          "   outer loop\n"
+          "     vertex % 12e % 12e % 12e\n"
+          "     vertex % 12e % 12e % 12e\n"
+          "     vertex % 12e % 12e % 12e\n"
+          "   endloop\n"
+          " endfacet\n",
+          Vnorm.X(), Vnorm.Y(), Vnorm.Z(),
+          x1, y1, z1,
+          x2, y2, z2,
+          x3, y3, z3);
       buf += sval;
-      buf += " ";
-      sprintf (sval,"% 12e",z2);
-      buf += sval;
-      buf += '\n';
-      theFile.Write (buf,buf.Length());buf.Clear();
-
-      buf += "     vertex ";
-      sprintf (sval,"% 12e",x3);
-      buf += sval;
-      buf += " ";
-      sprintf (sval,"% 12e",y3);
-      buf += sval;
-      buf += " ";
-      sprintf (sval,"% 12e",z3);
-      buf += sval;
-      buf += '\n';
-      theFile.Write (buf,buf.Length());buf.Clear();
-      buf += "   endloop\n";
-      theFile.Write (buf,buf.Length());buf.Clear();
-      buf += " endfacet\n";
-      theFile.Write (buf,buf.Length());buf.Clear();
+      theFile.Write (buf, buf.Length()); buf.Clear();
+
+      // update progress only per 1k triangles
+      if (++aTriangleInd % IND_THRESHOLD == 0)
+      {
+        if (!aTPS.More())
+            break;
+        aTPS.Next();
+      }
     }
   }
 
   buf += "endsolid\n";
-  theFile.Write (buf,buf.Length());buf.Clear();
-
-  theFile.Close ();
-  return Standard_True;
+  theFile.Write (buf, buf.Length()); buf.Clear();
+  theFile.Close();
+  Standard_Boolean isInterrupted = !aDPS.More();
+  return !isInterrupted;
 }
 //=======================================================================
 //function : ReadFile
@@ -280,9 +273,10 @@ Standard_Boolean RWStl::WriteAscii(const Handle(StlMesh_Mesh)& aMesh, const OSD_
 //Warning  :
 //=======================================================================
 
-Handle_StlMesh_Mesh RWStl::ReadFile(const OSD_Path& aPath)
+Handle_StlMesh_Mesh RWStl::ReadFile (const OSD_Path& thePath,
+                                     const Handle(Message_ProgressIndicator)& theProgInd)
 {
-  OSD_File file = OSD_File (aPath);
+  OSD_File file (thePath);
   file.Open(OSD_ReadOnly,OSD_Protection(OSD_RWD,OSD_RWD,OSD_RWD,OSD_RWD));
   Standard_Boolean IsAscii;
   unsigned char str[128];
@@ -307,11 +301,8 @@ Handle_StlMesh_Mesh RWStl::ReadFile(const OSD_Path& aPath)
 #endif
   file.Close();
 
-  if (IsAscii) {
-    return RWStl::ReadAscii (aPath);
-  } else {
-    return RWStl::ReadBinary (aPath);
-  }
+  return IsAscii ? RWStl::ReadAscii  (thePath, theProgInd)
+                 : RWStl::ReadBinary (thePath, theProgInd);
 }
 
 //=======================================================================
@@ -320,7 +311,8 @@ Handle_StlMesh_Mesh RWStl::ReadFile(const OSD_Path& aPath)
 //Warning  :
 //=======================================================================
 
-Handle_StlMesh_Mesh RWStl::ReadBinary(const OSD_Path& aPath)
+Handle_StlMesh_Mesh RWStl::ReadBinary (const OSD_Path& thePath,
+                                       const Handle(Message_ProgressIndicator)& /*theProgInd*/)
 {
   Standard_Integer NBFACET;
   Standard_Integer ifacet;
@@ -331,7 +323,7 @@ Handle_StlMesh_Mesh RWStl::ReadBinary(const OSD_Path& aPath)
   adr = (Standard_Address)buftest;
 
   // Open the file
-  OSD_File theFile = OSD_File(aPath);
+  OSD_File theFile (thePath);
   theFile.Open(OSD_ReadOnly,OSD_Protection(OSD_RWD,OSD_RWD,OSD_RWD,OSD_RWD));
 
   // the size of the file (minus the header size)
@@ -396,7 +388,8 @@ Handle_StlMesh_Mesh RWStl::ReadBinary(const OSD_Path& aPath)
 //Warning  :
 //=======================================================================
 
-Handle_StlMesh_Mesh RWStl::ReadAscii(const OSD_Path& aPath)
+Handle_StlMesh_Mesh RWStl::ReadAscii (const OSD_Path& thePath,
+                                      const Handle(Message_ProgressIndicator)& theProgInd)
 {
   TCollection_AsciiString filename;
   long ipos;
@@ -407,7 +400,7 @@ Handle_StlMesh_Mesh RWStl::ReadAscii(const OSD_Path& aPath)
   Standard_Integer i1,i2,i3;
   Handle(StlMesh_Mesh) ReadMesh;
 
-  aPath.SystemName( filename);
+  thePath.SystemName (filename);
 
   // Open the file
   FILE* file = fopen(filename.ToCString(),"r");
@@ -444,7 +437,9 @@ Handle_StlMesh_Mesh RWStl::ReadAscii(const OSD_Path& aPath)
   ReadMesh->AddDomain();
 
   // main reading
-  for (iTri = 0; iTri < nbTris; ++iTri) {
+  Message_ProgressSentry aPS (theProgInd, "Triangles", 0, (nbTris - 1) * 1.0 / IND_THRESHOLD, 1);
+  for (iTri = 0; iTri < nbTris && aPS.More();)
+  {
     // reading the facet normal
     fscanf(file,"%*s %*s %f %f %f\n",&x[0],&y[0],&z[0]);
 
@@ -469,6 +464,9 @@ Handle_StlMesh_Mesh RWStl::ReadAscii(const OSD_Path& aPath)
     // skip the keywords "endfacet"
     fscanf(file,"%*s");
 
+    // update progress only per 1k triangles
+    if (++iTri % IND_THRESHOLD == 0)
+      aPS.Next();
   }
 #ifdef DEB
   cout << "end mesh\n";
diff --git a/src/STEPControl/STEPControl_ActorRead.cxx b/src/STEPControl/STEPControl_ActorRead.cxx
index c391013..c1cec7c 100644
--- a/src/STEPControl/STEPControl_ActorRead.cxx
+++ b/src/STEPControl/STEPControl_ActorRead.cxx
@@ -131,7 +131,11 @@ static void DumpWhatIs(const TopoDS_Shape& S) {
                    nbFaces = 0, 
                    nbWires = 0, 
                    nbEdges = 0, 
-                   nbVertexes = 0;
+                   nbVertexes = 0,
+                   nbCompounds = 0;
+
+  if (S.ShapeType() == TopAbs_COMPOUND)
+    nbCompounds++;
 
   for( ; itL.More(); itL.Next() ) {
     TopoDS_Iterator it( itL.Value() );
@@ -140,6 +144,8 @@ static void DumpWhatIs(const TopoDS_Shape& S) {
       if ( !aMapOfShape.Add(aSubShape) )
         continue;
       aListOfShape.Append(aSubShape);
+      if (aSubShape.ShapeType() == TopAbs_COMPOUND)
+        nbCompounds++;
       if (aSubShape.ShapeType() == TopAbs_SOLID)
         nbSolids++;
       if (aSubShape.ShapeType() == TopAbs_SHELL) {
@@ -157,6 +163,7 @@ static void DumpWhatIs(const TopoDS_Shape& S) {
         nbVertexes++;
     }
   }
+  cout << "//What is?// NB COMPOUNDS: " << nbCompounds << endl;
   cout << "//What is?// NB SOLIDS: " << nbSolids << endl;
   cout << "//What is?// NB SHELLS: " << nbShells << endl;
   cout << "//What is?//    OPEN SHELLS: " << nbOpenShells << endl;
@@ -168,6 +175,13 @@ static void DumpWhatIs(const TopoDS_Shape& S) {
 }
 #endif
 
+namespace {
+  // Set global var to inform outer methods that current representation item is non-manifold.
+  // The better way is to pass this information via binder or via TopoDS_Shape itself, however,
+  // this is very specific info to do so...
+  Standard_Boolean NM_DETECTED = Standard_False;
+};
+
 // ============================================================================
 // Method  : STEPControl_ActorRead::STEPControl_ActorRead  ()    
 // Purpose : Empty constructor
@@ -514,7 +528,19 @@ static void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS,
     TopoDS_Shape theResult = TransferBRep::ShapeResult (binder);
     if (!theResult.IsNull()) {
       Result1 = theResult;
-      B.Add(Cund, theResult);
+      // [BEGIN] ssv: OCCT#22436: extra compound in NMSSR case
+      if (NM_DETECTED && Result1.ShapeType() == TopAbs_COMPOUND)
+      {
+        TopoDS_Iterator it(Result1);
+        for ( ; it.More(); it.Next() ) 
+        {
+          TopoDS_Shape aSubShape = it.Value();
+          B.Add(Cund, aSubShape);
+        }
+      }
+      else
+        B.Add(Cund, theResult);
+      // [END] ssv: OCCT#22436: extra compound in NMSSR case
       nbComponents++;
     }
   }
@@ -546,7 +572,19 @@ static void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS,
       theResult = TransferBRep::ShapeResult (binder);
       if (!theResult.IsNull()) {
         Result1 = theResult;
-        B.Add(Cund, theResult);
+        // [BEGIN] ssv: OCCT#22436: extra compound in NMSSR case
+        if (NM_DETECTED && Result1.ShapeType() == TopAbs_COMPOUND)
+        {
+          TopoDS_Iterator it(Result1);
+          for ( ; it.More(); it.Next() ) 
+          {
+            TopoDS_Shape aSubShape = it.Value();
+            B.Add(Cund, aSubShape);
+          }
+        }
+        else
+          B.Add(Cund, theResult);
+        // [END] ssv: OCCT#22436: extra compound in NMSSR case
         nbShapes++;
       }
     }
@@ -687,6 +725,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han
                                                                        const Handle(Transfer_TransientProcess)& TP,
                                                                        Standard_Boolean& isBound)
 {
+  NM_DETECTED = Standard_False;
   Handle(TransferBRep_ShapeBinder) shbinder;
   if(!Recognize(sr))
     return shbinder;
@@ -716,6 +755,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han
   Standard_Boolean isManifold = Standard_True;
   if ( isNMMode && sr->IsKind(STANDARD_TYPE(StepShape_NonManifoldSurfaceShapeRepresentation)) ) {
     isManifold = Standard_False;
+    NM_DETECTED = Standard_True;
     #ifdef DEB
     Standard_Integer NMSSRItemsLen = sr->Items()->Length();
     cout << "NMSSR with " << NMSSRItemsLen << " items detected" << endl;
@@ -726,6 +766,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han
     Standard_Integer isIDeasMode = Interface_Static::IVal("read.step.ideas");
     if (isNMMode && myNMTool.IsIDEASCase() && isIDeasMode) {
       isManifold = Standard_False;
+      NM_DETECTED = Standard_True;
       #ifdef DEB
       cout << "I-DEAS post processing for non-manifold topology ENABLED" << endl;
       #endif
@@ -1591,22 +1632,12 @@ Standard_Boolean STEPControl_ActorRead::ComputeTransformation (const Handle(Step
   Handle(Geom_Axis2Placement) theTarg;
   StepToGeom_MakeAxis2Placement::Convert(trg,theTarg);
   if ( oldSRContext != TargContext  ) PrepareUnits(oldSRContext,TP);
-  
+
   gp_Ax3 ax3Orig(theOrig->Ax2());
   gp_Ax3 ax3Targ(theTarg->Ax2());
-  //ax3Orig - defines CS for component(always is equal to (0 0 0 ))(related product from NAUO)
-  //ax3Targ - defines place of component in assemby CS (relating product
-  //  ne pas se tromper de sens !
 
-
-  gp_Trsf aTrsf2;
-  gp_Ax3 anAxis(gp_Pnt(0.,0.,0.), gp::DZ(), gp::DX());;
-  aTrsf2.SetTransformation(anAxis,ax3Orig);
-  gp_Trsf aTrsf3;
-  aTrsf3.SetTransformation(ax3Targ,anAxis);
-
-  Trsf = aTrsf3 * aTrsf2;
-  
+  //  ne pas se tromper de sens !
+  Trsf.SetTransformation(ax3Targ, ax3Orig);
   return Trsf.Form() != gp_Identity;
 }
 
diff --git a/src/Select3D/Select3D_SensitiveCurve.cxx b/src/Select3D/Select3D_SensitiveCurve.cxx
index 8259ac9..b338ee6 100644
--- a/src/Select3D/Select3D_SensitiveCurve.cxx
+++ b/src/Select3D/Select3D_SensitiveCurve.cxx
@@ -94,7 +94,7 @@ Matches (const Standard_Real XMin,
   Bnd_Box2d BoundBox;
   BoundBox.Update(XMin-aTol,YMin-aTol,XMax+aTol,YMax+aTol);
   
-  for(Standard_Integer j=0; j<mynbpoints-1; j++)
+  for(Standard_Integer j=0; j<mynbpoints; j++)
     {
       if(BoundBox.IsOut(((Select3D_Pnt2d*)mypolyg2d)[j])) return Standard_False;
     }
diff --git a/src/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cxx b/src/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cxx
index b11c003..bb84ee5 100644
--- a/src/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cxx
+++ b/src/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cxx
@@ -328,6 +328,8 @@ static Standard_Boolean MinMaxSmall
   Standard_Integer nb = 0;
   for (TopExp_Explorer ex(F,TopAbs_EDGE); ex.More(); ex.Next()) {
     TopoDS_Edge E = TopoDS::Edge (ex.Current());
+    if (nb == 1 && E.IsSame(E1))
+      continue; // ignore seam edge
     TopoDS_Vertex V1,V2;
     TopExp::Vertices (E,V1,V2);
     gp_Pnt p1,p2;
@@ -393,6 +395,8 @@ static Standard_Boolean MinMaxSmall
   nb = 0;
   for (TopExp_Explorer ite (F,TopAbs_EDGE); ite.More(); ite.Next()) {
     TopoDS_Edge E = TopoDS::Edge (ite.Current());
+    if (nb == 1 && E.IsSame(E1))
+      continue; // ignore seam edge
     TopoDS_Vertex VA,VB;
     TopExp::Vertices (E,VA,VB);
     if (tol < 0) {
diff --git a/src/ShapeFix/ShapeFix_ComposeShell.cxx b/src/ShapeFix/ShapeFix_ComposeShell.cxx
index e47d80e..d6dc90b 100644
--- a/src/ShapeFix/ShapeFix_ComposeShell.cxx
+++ b/src/ShapeFix/ShapeFix_ComposeShell.cxx
@@ -1467,13 +1467,22 @@ Standard_Boolean ShapeFix_ComposeShell::SplitByLine (ShapeFix_WireSegment &wire,
     // Two consecutive tangential segments are considered as one, merge them.
     for ( i=1; i <= IntEdgePar.Length(); i++ ) {
       j = ( i > 1 ? i-1 : IntEdgePar.Length() );
+
+      int k = ( i < IntEdgePar.Length() ? i + 1 : 1 ); // [ACIS22539]
+
       if ( SegmentCodes(j) == IOR_UNDEF && 
-	   SegmentCodes(i) == IOR_UNDEF ) {
-	IntEdgeInd.Remove(i);
-	IntEdgePar.Remove(i);
-	IntLinePar.Remove(i);
-	SegmentCodes.Remove(i);
-	i--;
+           SegmentCodes(i) == IOR_UNDEF ) {
+
+        // Very specific case when the constructed seam edge
+        // overlaps with spur edge [ACIS22539]
+        if (myClosedMode && (IntLinePar(i) - IntLinePar(j)) * (IntLinePar(k) - IntLinePar(i)) <= 0. )
+          continue;
+
+        IntEdgeInd.Remove(i);
+        IntEdgePar.Remove(i);
+        IntLinePar.Remove(i);
+        SegmentCodes.Remove(i);
+        i--;
       }
     }
     }
diff --git a/src/ShapeFix/ShapeFix_Edge.cxx b/src/ShapeFix/ShapeFix_Edge.cxx
index 2a1ba51..3170413 100644
--- a/src/ShapeFix/ShapeFix_Edge.cxx
+++ b/src/ShapeFix/ShapeFix_Edge.cxx
@@ -751,6 +751,13 @@ Standard_Boolean ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge,
 	//create copyedge as copy of edge with the same vertices and copy of pcurves on the same surface(s)
 	copyedge = ShapeBuild_Edge().Copy ( edge, Standard_False );
 	B.SameParameter ( copyedge, Standard_False );
+        // ShapeBuild_Edge::Copy() may change 3D curve range (if it's outside of its period).
+        // In this case pcurves in BRepLib::SameParameter() will be changed as well
+        // and later ShapeBuild_Edge::CopyPCurves() will copy pcurves keeping original range.
+        // To prevent this discrepancy we enforce original 3D range.
+        Standard_Real aF, aL;
+        BRep_Tool::Range (edge, aF, aL);
+        B.Range (copyedge, aF, aL, Standard_True); // only 3D
 	BRepLib::SameParameter ( copyedge, ( tolerance >= Precision::Confusion() ? 
 					    tolerance : tol ) );
 	SP = BRep_Tool::SameParameter ( copyedge );
diff --git a/src/ShapeFix/ShapeFix_Face.cxx b/src/ShapeFix/ShapeFix_Face.cxx
index a4f824c..0d08df1 100644
--- a/src/ShapeFix/ShapeFix_Face.cxx
+++ b/src/ShapeFix/ShapeFix_Face.cxx
@@ -764,7 +764,7 @@ Standard_Boolean ShapeFix_Face::FixAddNaturalBound()
 
   // deal with case of empty face: just create a new one by standard tool
   if ( ws.Length() <=0 ) {
-    BRepBuilderAPI_MakeFace mf (mySurf->Surface());
+    BRepBuilderAPI_MakeFace mf (mySurf->Surface(), Precision::Confusion());
     if ( ! Context().IsNull() ) Context()->Replace ( myFace, mf.Face() );
     myFace = mf.Face();
 
@@ -859,7 +859,7 @@ Standard_Boolean ShapeFix_Face::FixAddNaturalBound()
 /* variant 2 */
   TopLoc_Location L;
   Handle(Geom_Surface) surf = BRep_Tool::Surface ( myFace, L );
-  BRepBuilderAPI_MakeFace mf (surf);
+  BRepBuilderAPI_MakeFace mf (surf, Precision::Confusion());
   TopoDS_Face ftmp = mf.Face();
   ftmp.Location ( L );
   for (wi.Initialize (ftmp,Standard_False); wi.More(); wi.Next()) {
diff --git a/src/ShapeFix/ShapeFix_Wire.cxx b/src/ShapeFix/ShapeFix_Wire.cxx
index cacb11d..6cd3d98 100644
--- a/src/ShapeFix/ShapeFix_Wire.cxx
+++ b/src/ShapeFix/ShapeFix_Wire.cxx
@@ -2986,7 +2986,7 @@ Standard_Boolean ShapeFix_Wire::FixNotchedEdges()
   if ( ! Context().IsNull() ) UpdateWire();
   Handle(ShapeExtend_WireData) sewd = WireData();
   
-  for (Standard_Integer i = 1; i <= NbEdges() && NbEdges() > 2; i++ ) {
+  for (Standard_Integer i = 1; i <= NbEdges() && NbEdges() > 2; i++) {
     Standard_Real param;
     Standard_Integer toRemove;
     if(theAdvAnalyzer->CheckNotchedEdges(i,toRemove,param,MinTolerance())){
diff --git a/src/ShapeUpgrade/ShapeUpgrade_WireDivide.cxx b/src/ShapeUpgrade/ShapeUpgrade_WireDivide.cxx
index 6c13738..e3c4ec1 100644
--- a/src/ShapeUpgrade/ShapeUpgrade_WireDivide.cxx
+++ b/src/ShapeUpgrade/ShapeUpgrade_WireDivide.cxx
@@ -81,7 +81,7 @@ void ShapeUpgrade_WireDivide::Init(const TopoDS_Wire& W,
 {
 //  if (ShapeUpgrade::Debug()) cout <<"ShapeUpgrade_WireDivide::Init with Wire, Surface "<<endl;
   myWire = W;
-  BRepLib_MakeFace mkf(S);
+  BRepLib_MakeFace mkf(S, Precision::Confusion());
   myFace = mkf.Face();
   myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
 }
@@ -125,7 +125,7 @@ void ShapeUpgrade_WireDivide::SetFace(const TopoDS_Face& F)
 
 void ShapeUpgrade_WireDivide::SetSurface(const Handle(Geom_Surface)& S)
 {
-  BRepLib_MakeFace mkf(S);
+  BRepLib_MakeFace mkf(S, Precision::Confusion());
   myFace = mkf.Face();
 }
 
diff --git a/src/Standard/FILES b/src/Standard/FILES
index ee815d6..ddc3121 100644
--- a/src/Standard/FILES
+++ b/src/Standard/FILES
@@ -48,7 +48,6 @@ Standard_SStream.hxx
 Standard_ShallowDump.cxx
 Standard_ShortReal.cxx
 Standard_ShortReal.hxx
-Standard_Static.hxx
 Standard_Stream.hxx
 Standard_String.hxx
 Standard_Transient.hxx
diff --git a/src/Standard/Handle_Standard_Transient.cxx b/src/Standard/Handle_Standard_Transient.cxx
index 2344241..bad55c3 100644
--- a/src/Standard/Handle_Standard_Transient.cxx
+++ b/src/Standard/Handle_Standard_Transient.cxx
@@ -23,12 +23,9 @@ void Handle(Standard_Transient)::Assign (const Standard_Transient *anItem)
 
 void Handle(Standard_Transient)::BeginScope()
 {
-  if (entity != UndefinedHandleAddress) 
+  if (entity != UndefinedHandleAddress)
   {
-    if ( Standard::IsReentrant() ) 
-      Standard_Atomic_Increment (&entity->count);
-    else 
-      entity->count++;
+    Standard_Atomic_Increment (&entity->count);
   }
 }
 
@@ -36,11 +33,9 @@ void Handle(Standard_Transient)::BeginScope()
 
 void Handle(Standard_Transient)::EndScope()
 {
-  if (entity == UndefinedHandleAddress) 
+  if (entity == UndefinedHandleAddress)
     return;
-  if ( Standard::IsReentrant() ? 
-       Standard_Atomic_DecrementTest (&entity->count) : 
-       (--entity->count == 0) )
+  if (Standard_Atomic_Decrement (&entity->count) == 0)
     entity->Delete();
   entity = UndefinedHandleAddress;
 }
diff --git a/src/StdSelect/StdSelect_BRepOwner.cxx b/src/StdSelect/StdSelect_BRepOwner.cxx
index f4f9a23..7e3bd1b 100644
--- a/src/StdSelect/StdSelect_BRepOwner.cxx
+++ b/src/StdSelect/StdSelect_BRepOwner.cxx
@@ -139,7 +139,7 @@ void StdSelect_BRepOwner::Clear(const Handle(PrsMgr_PresentationManager)& PM,
 #else
   Standard_Integer M = (myCurMode==-1) ? aMode:myCurMode;
 #endif
-  if(myPrsSh.IsNull())
+  if (!myPrsSh.IsNull())
     PM->Clear(myPrsSh,M);
   myPrsSh.Nullify();
 }
@@ -157,7 +157,3 @@ void StdSelect_BRepOwner::ResetLocation()
   if(!myPrsSh.IsNull())
     myPrsSh.Nullify(); 
 }
-
-
-
-
diff --git a/src/StdSelect/StdSelect_BRepSelectionTool.cxx b/src/StdSelect/StdSelect_BRepSelectionTool.cxx
index f91311d..520fcf2 100644
--- a/src/StdSelect/StdSelect_BRepSelectionTool.cxx
+++ b/src/StdSelect/StdSelect_BRepSelectionTool.cxx
@@ -67,6 +67,12 @@ void StdSelect_BRepSelectionTool
         const Standard_Real theMaxParam)
 {
   Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority;
+
+  if( isAutoTriangulation && !BRepTools::Triangulation (theShape, Precision::Infinite()) )
+  {
+    BRepMesh_IncrementalMesh(theShape, theDeflection, Standard_False, theDeviationAngle);
+  }
+
   Handle(StdSelect_BRepOwner) aBrepOwner;
   switch (theType)
   {
@@ -586,13 +592,7 @@ Standard_Boolean StdSelect_BRepSelectionTool
   // check if there is triangulation of the face...
   TopLoc_Location aLoc;
   Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (theFace, aLoc);
-  if (aTriangulation.IsNull() && theAutoTriangulation)
-  {
-    Standard_Real aDefaultDefl = 0.2;
-    Standard_Real aDefaultAng  = 30 * PI / 180.0;
-    BRepMesh_IncrementalMesh (theFace, aDefaultDefl, Standard_True, aDefaultAng);
-    aTriangulation = BRep_Tool::Triangulation (theFace, aLoc);
-  }
+
   if (!aTriangulation.IsNull())
   {
     Handle(Select3D_SensitiveTriangulation) STG = new Select3D_SensitiveTriangulation (theOwner, aTriangulation, aLoc, theInteriorFlag);
diff --git a/src/StepToGeom/StepToGeom_MakeSurface.cxx b/src/StepToGeom/StepToGeom_MakeSurface.cxx
index f97d68b..76c3476 100644
--- a/src/StepToGeom/StepToGeom_MakeSurface.cxx
+++ b/src/StepToGeom/StepToGeom_MakeSurface.cxx
@@ -33,6 +33,7 @@
 #include <TopoDS.hxx>
 #include <BRep_Tool.hxx>  
 #include <gp_Trsf.hxx>
+#include <Precision.hxx>
 
 //=============================================================================
 // Creation d' une Surface de Geom a partir d' une Surface de Step
@@ -71,7 +72,7 @@ Standard_Boolean StepToGeom_MakeSurface::Convert (const Handle(StepGeom_Surface)
         const Standard_Real anOffset = OS->Distance() * UnitsMethods::LengthFactor();
         if (aBasisSurface->Continuity() == GeomAbs_C0)
         {
-          const BRepBuilderAPI_MakeFace aBFace(aBasisSurface);
+          const BRepBuilderAPI_MakeFace aBFace(aBasisSurface, Precision::Confusion());
           if (aBFace.IsDone())
           {
             const TopoDS_Shape aResult = ShapeAlgo::AlgoContainer()->C0ShapeToC1Shape(aBFace.Face(), Abs(anOffset));
diff --git a/src/StepToTopoDS/StepToTopoDS_Builder.cxx b/src/StepToTopoDS/StepToTopoDS_Builder.cxx
index adc1678..e9dfbd1 100644
--- a/src/StepToTopoDS/StepToTopoDS_Builder.cxx
+++ b/src/StepToTopoDS/StepToTopoDS_Builder.cxx
@@ -675,7 +675,8 @@ void StepToTopoDS_Builder::Init (const Handle(StepShape_FaceBasedSurfaceModel)&
 // ============================================================================
 //:i6 abv 17 Sep 98: ProSTEP TR9 r0601-ct.stp: to be able read GS: GeometricCurveSet -> GeometricSet
 
-static TopoDS_Face TranslateBoundedSurf (const Handle(StepGeom_Surface) &surf)
+static TopoDS_Face TranslateBoundedSurf (const Handle(StepGeom_Surface) &surf,
+                                         const Standard_Real TolDegen)
 {
   TopoDS_Face res;
 
@@ -684,7 +685,7 @@ static TopoDS_Face TranslateBoundedSurf (const Handle(StepGeom_Surface) &surf)
       !theSurf->IsKind(STANDARD_TYPE(Geom_BoundedSurface))) return res;
 
   //gka 11.01.99 file PRO7755.stp entity #2018 surface #1895: error BRepLib_MakeFace func IsDegenerated
-  BRepBuilderAPI_MakeFace myMkFace(theSurf);
+  BRepBuilderAPI_MakeFace myMkFace(theSurf, TolDegen);
   return myMkFace.Face();
 }
 
@@ -790,13 +791,13 @@ void StepToTopoDS_Builder::Init
 	for ( Standard_Integer ii=1; ii <= nbi; ii++ ) 
 	  for ( Standard_Integer j=1; j <= nbj; j++ ) {
 	    Handle(StepGeom_SurfacePatch) patch = RCS->SegmentsValue ( ii, j );
-	    TopoDS_Face f = TranslateBoundedSurf ( patch->ParentSurface() );
+	    TopoDS_Face f = TranslateBoundedSurf (patch->ParentSurface(), preci);
 	    if ( ! f.IsNull() ) B.Add ( C, f );
 	  }
 	res = C;
       }
       // try other surfs
-      else res = TranslateBoundedSurf ( aSurf );
+      else res = TranslateBoundedSurf (aSurf, preci);
     }
     else TP->AddWarning (ent," Entity is not a Curve, Point or Surface");
     if ( ! res.IsNull() ) {
diff --git a/src/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx b/src/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx
index 7561c9a..72cf162 100644
--- a/src/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx
+++ b/src/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx
@@ -90,7 +90,7 @@ Standard_Boolean StepToTopoDS_TranslateCurveBoundedSurface::Init (
   // add natural bound if implicit
   if ( CBS->ImplicitOuter() ) { 
     if ( Surf->IsKind(STANDARD_TYPE(Geom_BoundedSurface)) ) {
-      BRepBuilderAPI_MakeFace mf (Surf);
+      BRepBuilderAPI_MakeFace mf (Surf, Precision::Confusion());
       myFace = mf.Face();
     }
     else TP->AddWarning ( CBS, "Cannot make natural bounds on infinite surface" );
diff --git a/src/StepToTopoDS/StepToTopoDS_TranslateFace.cxx b/src/StepToTopoDS/StepToTopoDS_TranslateFace.cxx
index fc66e8f..8187d4c 100644
--- a/src/StepToTopoDS/StepToTopoDS_TranslateFace.cxx
+++ b/src/StepToTopoDS/StepToTopoDS_TranslateFace.cxx
@@ -229,11 +229,14 @@ void StepToTopoDS_TranslateFace::Init
       Handle(StepShape_VertexLoop) VL = Handle(StepShape_VertexLoop)::DownCast(Loop);
 
       // abv 10.07.00 pr1sy.stp: vertex_loop can be wrong; so just make natural bounds
-      if (GeomSurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
-	BRepBuilderAPI_MakeFace mf (GeomSurf);
-	for (TopoDS_Iterator it(mf); it.More(); it.Next() ) 
-	  B.Add ( F, it.Value() );
-	continue;
+      if (GeomSurf->IsKind (STANDARD_TYPE(Geom_SphericalSurface)) ||
+          GeomSurf->IsKind (STANDARD_TYPE(Geom_BSplineSurface)) )
+      {
+        BRepBuilderAPI_MakeFace mf (GeomSurf, Precision());
+        for (TopoDS_Iterator it(mf); it.More(); it.Next()) 
+          B.Add (F, it.Value());
+
+        continue;
       }
       
       if (//GeomSurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) ||
diff --git a/src/StlMesh/StlMesh_Mesh.cdl b/src/StlMesh/StlMesh_Mesh.cdl
index f62fbbb..f26f57e 100644
--- a/src/StlMesh/StlMesh_Mesh.cdl
+++ b/src/StlMesh/StlMesh_Mesh.cdl
@@ -150,10 +150,10 @@ is
 
 fields
 
-    nbTriangles : Integer;
-    nbVertices  : Integer;
-    domains     : SequenceOfMeshDomain;
-    xyzmax      : XYZ;
-    xyzmin      : XYZ;
+    nbTriangles : Integer is protected;
+    nbVertices  : Integer is protected;
+    domains     : SequenceOfMeshDomain is protected;
+    xyzmax      : XYZ is protected;
+    xyzmin      : XYZ is protected;
 	
 end Mesh;
diff --git a/src/TCollection/TCollection_DataMap.cdl b/src/TCollection/TCollection_DataMap.cdl
index d163bd9..72f1829 100644
--- a/src/TCollection/TCollection_DataMap.cdl
+++ b/src/TCollection/TCollection_DataMap.cdl
@@ -191,5 +191,16 @@ is
 	---C++: return &
     raises NoSuchObject from Standard 
     is static;
-    
+     
+--modified by NIZNHY-PKV Tue Jul 05 09:57:10 2011f 
+     Find1(me; K : TheKey) 
+    	returns Address from Standard;	
+	---Purpose: Returns the address of Item of the key <K>  
+        -- or NULL if K is not in the map. 
+     ChangeFind1(me:out; K : TheKey) 
+    	returns Address from Standard;	
+	---Purpose: Returns the address of Item of the key <K>  
+        -- or NULL if K is not in the map. 
+--modified by NIZNHY-PKV Tue Jul 05 09:57:14 2011t  
+
 end DataMap;
diff --git a/src/TCollection/TCollection_IndexedDataMap.cdl b/src/TCollection/TCollection_IndexedDataMap.cdl
index 4cb0b32..dd4118c 100644
--- a/src/TCollection/TCollection_IndexedDataMap.cdl
+++ b/src/TCollection/TCollection_IndexedDataMap.cdl
@@ -203,6 +203,17 @@ is
         -- Trigger: Raises NoSuchObject if K is not in the map.
     raises NoSuchObject from Standard 
     ---C++: return &
-    is static;
-    
+    is static; 
+     
+--modified by NIZNHY-PKV Tue Jul 05 08:38:26 2011f 
+    FindFromKey1(me; K : TheKey) 
+    	returns Address from Standard;	
+	---Purpose: Returns the address of Item of the key <K>  
+        -- or NULL if K is not in the map. 
+    ChangeFromKey1(me:out; K : TheKey) 
+    	returns Address from Standard;	
+	---Purpose: Returns the address of Item of the key <K>  
+        -- or NULL if K is not in the map. 
+--modified by NIZNHY-PKV Tue Jul 05 08:38:26 2011t
+ 
 end IndexedDataMap;
diff --git a/src/TDocStd/TDocStd.cdl b/src/TDocStd/TDocStd.cdl
index 7521aa1..bde0920 100644
--- a/src/TDocStd/TDocStd.cdl
+++ b/src/TDocStd/TDocStd.cdl
@@ -43,6 +43,7 @@ uses
      Standard,
      CDF,
      CDM,
+     PCDM,
      MDF,
      TDF,
      TColStd,
diff --git a/src/TDocStd/TDocStd_Application.cdl b/src/TDocStd/TDocStd_Application.cdl
index 7f91ddd..18ac706 100644
--- a/src/TDocStd/TDocStd_Application.cdl
+++ b/src/TDocStd/TDocStd_Application.cdl
@@ -43,8 +43,8 @@ uses Manager                  from Resource,
      CString                  from Standard,
      ExtendedString           from TCollection,
      SequenceOfExtendedString from TColStd,
-     RetrievableStatus        from CDF,
-     StoreStatus              from CDF
+     ReaderStatus             from PCDM,
+     StoreStatus              from PCDM
 
 raises NoSuchObject from Standard
 
@@ -182,13 +182,13 @@ is
     	-- In order not to override a version of aDoc which
     	-- is already in memory, this method can be made
     	-- to depend on the value returned by IsInSession.
-    returns RetrievableStatus from CDF;
+    returns ReaderStatus from PCDM;
 
     SaveAs (me : mutable; aDoc : Document from TDocStd;
                           path : ExtendedString from TCollection)
     	---Purpose:  Save the  active document  in the file  <name> in the
     	--           path <path> ; o verwrites  the file  if  it already exists.
-    returns StoreStatus from CDF;
+    returns StoreStatus from PCDM;
     
     
     Save (me : mutable; aDoc : Document from TDocStd)
@@ -196,7 +196,7 @@ is
         -- Exceptions:
     	--  Standard_NotImplemented if the document
     	-- was not retrieved in the applicative session by using Open. 
-    returns StoreStatus from CDF;
+    returns StoreStatus from PCDM;
     
     SaveAs (me : mutable; aDoc : Document from TDocStd;
                           path : ExtendedString from TCollection;
@@ -204,12 +204,12 @@ is
     	---Purpose:  Save the  active document  in the file  <name> in the
     	--           path <path>  .  overwrite  the file  if  it
     	--          already exist. 
-    returns StoreStatus from CDF;    
+    returns StoreStatus from PCDM;    
     
     Save (me : mutable; aDoc : Document from TDocStd; 
     	    	    	theStatusMessage:  out  ExtendedString from TCollection)
     	---Purpose: Save the document overwriting the previous file 
-    returns StoreStatus from CDF;
+    returns StoreStatus from PCDM;
     
     --Exit (me)
     --  to quit the application. the applicative documents must be closed before.
@@ -235,4 +235,3 @@ friends
     class Document from TDocStd
 
 end Application;
-
diff --git a/src/TDocStd/TDocStd_Application.cxx b/src/TDocStd/TDocStd_Application.cxx
index 65b811e..be237fc 100644
--- a/src/TDocStd/TDocStd_Application.cxx
+++ b/src/TDocStd/TDocStd_Application.cxx
@@ -174,8 +174,8 @@ Standard_Integer TDocStd_Application::IsInSession (const TCollection_ExtendedStr
 //purpose  :
 //=======================================================================
 
-CDF_RetrievableStatus TDocStd_Application::Open(const TCollection_ExtendedString& path,Handle(TDocStd_Document)& aDoc) {
-  CDF_RetrievableStatus status = CDF_RS_DriverFailure;
+PCDM_ReaderStatus TDocStd_Application::Open(const TCollection_ExtendedString& path,Handle(TDocStd_Document)& aDoc) {
+  PCDM_ReaderStatus status = PCDM_RS_DriverFailure;
   TDocStd_PathParser tool (path);
   TCollection_ExtendedString directory = tool.Trek();
   TCollection_ExtendedString file = tool.Name();
@@ -183,7 +183,7 @@ CDF_RetrievableStatus TDocStd_Application::Open(const TCollection_ExtendedString
   file+=tool.Extension();
 #ifdef BUC60867
   status = CanRetrieve(directory,file);
-  if (status != CDF_RS_OK) return status;
+  if (status != PCDM_RS_OK) return status;
 #endif
   try {
     OCC_CATCH_SIGNALS
@@ -215,7 +215,7 @@ CDF_RetrievableStatus TDocStd_Application::Open(const TCollection_ExtendedString
 //purpose  :
 //=======================================================================
 
-CDF_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D,const TCollection_ExtendedString& path) {
+PCDM_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D,const TCollection_ExtendedString& path) {
   TDocStd_PathParser tool (path);
   TCollection_ExtendedString directory = tool.Trek();
   TCollection_ExtendedString file = tool.Name();
@@ -246,7 +246,7 @@ CDF_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D,co
       MessageDriver()->Write(aString.ToExtString());
     }
   }
-  if(storer.StoreStatus() == CDF_SS_OK)
+  if(storer.StoreStatus() == PCDM_SS_OK)
     D->SetSaved();
 #ifdef BUC60867
 #ifdef DEB
@@ -261,9 +261,9 @@ CDF_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D,co
 //purpose  :
 //=======================================================================
 
-CDF_StoreStatus TDocStd_Application::Save (const Handle(TDocStd_Document)& D) {
+PCDM_StoreStatus TDocStd_Application::Save (const Handle(TDocStd_Document)& D) {
 #ifdef BUC60867
-  CDF_StoreStatus status = CDF_SS_OK;
+  PCDM_StoreStatus status = PCDM_SS_OK;
 #endif
   if (D->IsSaved()) {
     CDF_Store storer (D);
@@ -278,18 +278,17 @@ CDF_StoreStatus TDocStd_Application::Save (const Handle(TDocStd_Document)& D) {
         MessageDriver()->Write(aString.ToExtString());
       }
     }
-    if(storer.StoreStatus() == CDF_SS_OK)
+    if(storer.StoreStatus() == PCDM_SS_OK)
       D->SetSaved();
 #ifdef BUC60867
     status = storer.StoreStatus();
 #endif
   } else {
-//    Standard_DomainError::Raise ("TDocStd_Application::Save document is not already saved");
     if(!MessageDriver().IsNull()) {
-      TCollection_ExtendedString aMsg("Document is already saved");
+      TCollection_ExtendedString aMsg("Document has not been saved yet");
       MessageDriver()->Write(aMsg.ToExtString());
     }
-    status = CDF_SS_Failure;
+    status = PCDM_SS_Failure;
   }
 #ifdef BUC60867
 #ifdef DEB
@@ -330,12 +329,12 @@ CDF_StoreStatus TDocStd_Application::Save (const Handle(TDocStd_Document)& D) {
 //purpose  : 
 //=======================================================================
 
-CDF_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D,
+PCDM_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D,
 					      const TCollection_ExtendedString& path,
 					      TCollection_ExtendedString& theStatusMessage) 
 { 
   TDocStd_PathParser tool (path);
-  CDF_StoreStatus aStatus = CDF_SS_Failure;
+  PCDM_StoreStatus aStatus = PCDM_SS_Failure;
   TCollection_ExtendedString directory = tool.Trek();   
   TCollection_ExtendedString file = tool.Name();   
   file+=".";   
@@ -355,7 +354,7 @@ CDF_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D,
         MessageDriver()->Write(aString.ToExtString());
       }
     }
-    if(storer.StoreStatus() == CDF_SS_OK)
+    if(storer.StoreStatus() == PCDM_SS_OK)
       D->SetSaved();
     theStatusMessage = storer.AssociatedStatusText();
     aStatus = storer.StoreStatus();
@@ -363,7 +362,7 @@ CDF_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D,
     theStatusMessage =
       TCollection_ExtendedString("TDocStd_Application::SaveAs"
                                  ": No such directory ") + directory;
-    aStatus = CDF_SS_Failure;
+    aStatus = PCDM_SS_Failure;
   }
   return aStatus;
 }
@@ -373,10 +372,10 @@ CDF_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D,
 //purpose  : 
 //=======================================================================
 
-CDF_StoreStatus TDocStd_Application::Save (const Handle(TDocStd_Document)& D,
+PCDM_StoreStatus TDocStd_Application::Save (const Handle(TDocStd_Document)& D,
 					   TCollection_ExtendedString& theStatusMessage)
 {  
-  CDF_StoreStatus status = CDF_SS_OK;
+  PCDM_StoreStatus status = PCDM_SS_OK;
   if (D->IsSaved()) {  
     CDF_Store storer (D);  
     try {
@@ -390,14 +389,13 @@ CDF_StoreStatus TDocStd_Application::Save (const Handle(TDocStd_Document)& D,
         MessageDriver()->Write(aString.ToExtString());
       }
     }
-    if(storer.StoreStatus() == CDF_SS_OK)
+    if(storer.StoreStatus() == PCDM_SS_OK)
       D->SetSaved();
     status = storer.StoreStatus();
     theStatusMessage = storer.AssociatedStatusText();
   } else {
-    Standard_DomainError::Raise ("TDocStd_Application::Save"
-                                 " document is not already saved");
-    theStatusMessage = "TDocStd_Application::the document is not already saved";
+    theStatusMessage = "TDocStd_Application::the document has not been saved yet";
+    status = PCDM_SS_Failure;
   }
   return status;
 }
diff --git a/src/PTKernel/EXTERNLIB b/src/TKAdvTools/EXTERNLIB
similarity index 100%
copy from src/PTKernel/EXTERNLIB
copy to src/TKAdvTools/EXTERNLIB
diff --git a/src/TKAdvTools/FILES b/src/TKAdvTools/FILES
index 85fbd14..c999897 100644
--- a/src/TKAdvTools/FILES
+++ b/src/TKAdvTools/FILES
@@ -1 +1,2 @@
 PACKAGES
+EXTERNLIB
diff --git a/src/TKBO/EXTERNLIB b/src/TKBO/EXTERNLIB
index 6a8ac8a..c24e5be 100644
--- a/src/TKBO/EXTERNLIB
+++ b/src/TKBO/EXTERNLIB
@@ -1,3 +1,8 @@
-TKPrim
-
-
+TKBRep
+TKTopAlgo
+TKMath
+TKernel
+TKG2d
+TKG3d
+TKGeomAlgo
+TKGeomBase
diff --git a/src/TKBRep/EXTERNLIB b/src/TKBRep/EXTERNLIB
index 7976b60..5d98291 100644
--- a/src/TKBRep/EXTERNLIB
+++ b/src/TKBRep/EXTERNLIB
@@ -1 +1,5 @@
+TKMath
+TKernel
+TKG2d
+TKG3d
 TKGeomBase
diff --git a/src/TKBin/EXTERNLIB b/src/TKBin/EXTERNLIB
index 97d2032..27b51d7 100644
--- a/src/TKBin/EXTERNLIB
+++ b/src/TKBin/EXTERNLIB
@@ -1,2 +1,10 @@
+TKBRep
+TKMath
+TKernel
+TKG2d
+TKG3d
+TKCAF
+TKCDF
+TKLCAF
+TKV3d
 TKBinL
-
diff --git a/src/TKBinL/EXTERNLIB b/src/TKBinL/EXTERNLIB
new file mode 100644
index 0000000..b39644f
--- /dev/null
+++ b/src/TKBinL/EXTERNLIB
@@ -0,0 +1,3 @@
+TKCDF
+TKernel
+TKLCAF
diff --git a/src/TKBinL/FILES b/src/TKBinL/FILES
index 85fbd14..c999897 100644
--- a/src/TKBinL/FILES
+++ b/src/TKBinL/FILES
@@ -1 +1,2 @@
 PACKAGES
+EXTERNLIB
diff --git a/src/TKBinTObj/EXTERNLIB b/src/TKBinTObj/EXTERNLIB
index b94651b..692dbb9 100644
--- a/src/TKBinTObj/EXTERNLIB
+++ b/src/TKBinTObj/EXTERNLIB
@@ -1 +1,6 @@
+TKCDF
+TKernel
+TKTObj
+TKMath
+TKLCAF
 TKBinL
diff --git a/src/TKBinXCAF/EXTERNLIB b/src/TKBinXCAF/EXTERNLIB
index 40ea4e7..ac4b334 100644
--- a/src/TKBinXCAF/EXTERNLIB
+++ b/src/TKBinXCAF/EXTERNLIB
@@ -1 +1,11 @@
+TKBRep
+TKXCAF
+TKMath
+TKernel
+TKBinL
+TKG2d
+TKCAF
+TKCDF
+TKG3d
+TKLCAF
 TKBin
diff --git a/src/TKBool/EXTERNLIB b/src/TKBool/EXTERNLIB
index 4ad3897..fd338fe 100644
--- a/src/TKBool/EXTERNLIB
+++ b/src/TKBool/EXTERNLIB
@@ -1,3 +1,11 @@
+TKBRep
+TKTopAlgo
+TKMath
+TKernel
+TKPrim
+TKG2d
+TKG3d
+TKShHealing
+TKGeomBase
+TKGeomAlgo
 TKBO
-
-
diff --git a/src/TKCAF/EXTERNLIB b/src/TKCAF/EXTERNLIB
index 57cf2c8..5aa8272 100644
--- a/src/TKCAF/EXTERNLIB
+++ b/src/TKCAF/EXTERNLIB
@@ -1,3 +1,12 @@
+TKernel
+TKGeomBase
+TKBRep
+TKTopAlgo
+TKMath
+TKService
+TKG2d
+TKG3d
+TKV2d
 TKCDF
 TKLCAF
 TKV3d
diff --git a/src/TKDCAF/EXTERNLIB b/src/TKDCAF/EXTERNLIB
index 052e957..8af5499 100644
--- a/src/TKDCAF/EXTERNLIB
+++ b/src/TKDCAF/EXTERNLIB
@@ -1,2 +1,21 @@
+TKGeomBase
+TKBRep
+TKGeomAlgo
+TKernel
+TKMath
+TKG2d
+TKG3d
+TKDraw
+TKCDF
+TKV3d
+TKNIS
+TKService
+TKLCAF
+TKV2d
+TKFillet
+TKTopAlgo
+TKPrim
+TKBool
+TKBO
 TKCAF
 TKViewerTest
diff --git a/src/TKDraw/EXTERNLIB b/src/TKDraw/EXTERNLIB
index ff848d4..37112bc 100644
--- a/src/TKDraw/EXTERNLIB
+++ b/src/TKDraw/EXTERNLIB
@@ -1,9 +1,14 @@
+TKernel
+TKG2d
+TKGeomBase
+TKG3d
+TKMath
+TKBRep
+TKGeomAlgo
+TKTopAlgo
+TKMesh
 TKService
-TKBO
 TKHLR
-TKFillet
-TKFeat
-TKOffset
 CSF_TclLibs
 CSF_TclTkLibs
 CSF_gdi32
diff --git a/src/TKFeat/EXTERNLIB b/src/TKFeat/EXTERNLIB
index cd2d311..b5180e4 100644
--- a/src/TKFeat/EXTERNLIB
+++ b/src/TKFeat/EXTERNLIB
@@ -1 +1,11 @@
+TKBRep
+TKTopAlgo
+TKGeomAlgo
+TKMath
+TKernel
+TKGeomBase
+TKPrim
+TKG2d
+TKBO
+TKG3d
 TKBool
diff --git a/src/TKFillet/EXTERNLIB b/src/TKFillet/EXTERNLIB
index cd2d311..f7902e7 100644
--- a/src/TKFillet/EXTERNLIB
+++ b/src/TKFillet/EXTERNLIB
@@ -1 +1,9 @@
+TKBRep
+TKernel
+TKMath
+TKGeomBase
+TKGeomAlgo
+TKG2d
+TKTopAlgo
+TKG3d
 TKBool
diff --git a/src/TKG2d/EXTERNLIB b/src/TKG2d/EXTERNLIB
index cfe986d..1a12b23 100644
--- a/src/TKG2d/EXTERNLIB
+++ b/src/TKG2d/EXTERNLIB
@@ -1 +1,2 @@
+TKernel
 TKMath
diff --git a/src/TKG3d/EXTERNLIB b/src/TKG3d/EXTERNLIB
index e9a0908..f828e00 100644
--- a/src/TKG3d/EXTERNLIB
+++ b/src/TKG3d/EXTERNLIB
@@ -1 +1,3 @@
+TKMath
+TKernel
 TKG2d
diff --git a/src/TKGeomAlgo/EXTERNLIB b/src/TKGeomAlgo/EXTERNLIB
index d4974dc..ca0ecb9 100644
--- a/src/TKGeomAlgo/EXTERNLIB
+++ b/src/TKGeomAlgo/EXTERNLIB
@@ -1 +1,6 @@
+TKernel
+TKMath
+TKG3d
+TKG2d
+TKGeomBase
 TKBRep
diff --git a/src/TKGeomBase/EXTERNLIB b/src/TKGeomBase/EXTERNLIB
index 79e2b1d..a64cd8b 100644
--- a/src/TKGeomBase/EXTERNLIB
+++ b/src/TKGeomBase/EXTERNLIB
@@ -1 +1,4 @@
+TKernel
+TKMath
+TKG2d
 TKG3d
diff --git a/src/TKHLR/EXTERNLIB b/src/TKHLR/EXTERNLIB
index cd2d311..6a88cac 100644
--- a/src/TKHLR/EXTERNLIB
+++ b/src/TKHLR/EXTERNLIB
@@ -1 +1,8 @@
-TKBool
+TKBRep
+TKernel
+TKMath
+TKGeomBase
+TKG2d
+TKG3d
+TKGeomAlgo
+TKTopAlgo
diff --git a/src/TKIGES/EXTERNLIB b/src/TKIGES/EXTERNLIB
index dccbe61..b3b75d3 100644
--- a/src/TKIGES/EXTERNLIB
+++ b/src/TKIGES/EXTERNLIB
@@ -1,2 +1,13 @@
+TKBRep
+TKernel
+TKMath
+TKTopAlgo
+TKShHealing
+TKG2d
+TKG3d
+TKGeomBase
+TKGeomAlgo
+TKPrim
+TKBool
 TKOffset
 TKXSBase
diff --git a/src/TKLCAF/EXTERNLIB b/src/TKLCAF/EXTERNLIB
new file mode 100644
index 0000000..590b3c0
--- /dev/null
+++ b/src/TKLCAF/EXTERNLIB
@@ -0,0 +1,2 @@
+TKCDF
+TKernel
diff --git a/src/TKLCAF/FILES b/src/TKLCAF/FILES
index 85fbd14..c999897 100644
--- a/src/TKLCAF/FILES
+++ b/src/TKLCAF/FILES
@@ -1 +1,2 @@
 PACKAGES
+EXTERNLIB
diff --git a/src/TKMesh/EXTERNLIB b/src/TKMesh/EXTERNLIB
index 50eb2e2..9760506 100644
--- a/src/TKMesh/EXTERNLIB
+++ b/src/TKMesh/EXTERNLIB
@@ -1 +1,9 @@
+TKBRep
+TKMath
+TKernel
+TKG2d
+TKG3d
+TKGeomBase
+TKTopAlgo
+TKGeomAlgo
 CSF_TBB
diff --git a/src/TKMeshVS/EXTERNLIB b/src/TKMeshVS/EXTERNLIB
new file mode 100644
index 0000000..2ee3e96
--- /dev/null
+++ b/src/TKMeshVS/EXTERNLIB
@@ -0,0 +1,7 @@
+TKV3d
+TKMath
+TKService
+TKernel
+TKG3d
+TKV2d
+TKG2d
diff --git a/src/CDF/FILES b/src/TKMeshVS/FILES
similarity index 100%
copy from src/CDF/FILES
copy to src/TKMeshVS/FILES
diff --git a/src/TKNIS/EXTERNLIB b/src/TKNIS/EXTERNLIB
index 3b6e845..c9fd312 100644
--- a/src/TKNIS/EXTERNLIB
+++ b/src/TKNIS/EXTERNLIB
@@ -1,3 +1,11 @@
+TKBRep
+TKV3d
+TKMath
+TKernel
+TKService
+TKG2d
+TKG3d
+TKMesh
 CSF_OpenGlLibs
 CSF_user32
 CSF_gdi32
diff --git a/src/TKOffset/EXTERNLIB b/src/TKOffset/EXTERNLIB
index cd2d311..31a93d1 100644
--- a/src/TKOffset/EXTERNLIB
+++ b/src/TKOffset/EXTERNLIB
@@ -1 +1,13 @@
+TKFillet
+TKBRep
+TKTopAlgo
+TKMath
+TKernel
+TKGeomBase
+TKG2d
+TKG3d
+TKGeomAlgo
+TKShHealing
+TKBO
+TKPrim
 TKBool
diff --git a/src/TKOpenGl/EXTERNLIB b/src/TKOpenGl/EXTERNLIB
index 86db7da..a7d53f7 100644
--- a/src/TKOpenGl/EXTERNLIB
+++ b/src/TKOpenGl/EXTERNLIB
@@ -1,3 +1,5 @@
+TKernel
+TKService
 TKV3d
 CSF_OpenGlLibs
 CSF_FREETYPE
diff --git a/src/TKPCAF/EXTERNLIB b/src/TKPCAF/EXTERNLIB
index aadd1a6..bb1d537 100644
--- a/src/TKPCAF/EXTERNLIB
+++ b/src/TKPCAF/EXTERNLIB
@@ -1,3 +1,13 @@
+PTKernel
+TKBRep
+TKMath
+TKernel
+TKCDF
+TKG2d
+TKV3d
+TKService
+TKG3d
+TKV2d
 TKPShape
 TKCAF
 TKLCAF
diff --git a/src/TKPLCAF/EXTERNLIB b/src/TKPLCAF/EXTERNLIB
index faec485..947551f 100644
--- a/src/TKPLCAF/EXTERNLIB
+++ b/src/TKPLCAF/EXTERNLIB
@@ -1 +1,4 @@
+TKCDF
+PTKernel
+TKernel
 TKLCAF
diff --git a/src/TKPShape/EXTERNLIB b/src/TKPShape/EXTERNLIB
index 9184db9..2e05fdd 100644
--- a/src/TKPShape/EXTERNLIB
+++ b/src/TKPShape/EXTERNLIB
@@ -1,2 +1,6 @@
+TKMath
+TKernel
+TKG2d
+TKG3d
 PTKernel
 TKBRep
diff --git a/src/TKPrim/EXTERNLIB b/src/TKPrim/EXTERNLIB
index a30e318..00cb466 100644
--- a/src/TKPrim/EXTERNLIB
+++ b/src/TKPrim/EXTERNLIB
@@ -1 +1,7 @@
+TKBRep
+TKernel
+TKMath
+TKG2d
+TKGeomBase
+TKG3d
 TKTopAlgo
diff --git a/src/TKSTEP/EXTERNLIB b/src/TKSTEP/EXTERNLIB
index cfe292d..03d09cc 100644
--- a/src/TKSTEP/EXTERNLIB
+++ b/src/TKSTEP/EXTERNLIB
@@ -1,2 +1,14 @@
+TKernel
+TKSTEPAttr
+TKSTEP209
+TKSTEPBase
+TKBRep
+TKMath
+TKG2d
+TKShHealing
+TKTopAlgo
+TKG3d
+TKGeomBase
+TKGeomAlgo
 TKXSBase
 CSF_wsock32
diff --git a/src/TKSTEP209/EXTERNLIB b/src/TKSTEP209/EXTERNLIB
new file mode 100644
index 0000000..28cfbb0
--- /dev/null
+++ b/src/TKSTEP209/EXTERNLIB
@@ -0,0 +1,3 @@
+TKernel
+TKXSBase
+TKSTEPBase
diff --git a/src/TKSTEP209/FILES b/src/TKSTEP209/FILES
index 85fbd14..c999897 100644
--- a/src/TKSTEP209/FILES
+++ b/src/TKSTEP209/FILES
@@ -1 +1,2 @@
 PACKAGES
+EXTERNLIB
diff --git a/src/TKSTEPAttr/EXTERNLIB b/src/TKSTEPAttr/EXTERNLIB
new file mode 100644
index 0000000..28cfbb0
--- /dev/null
+++ b/src/TKSTEPAttr/EXTERNLIB
@@ -0,0 +1,3 @@
+TKernel
+TKXSBase
+TKSTEPBase
diff --git a/src/TKSTEPAttr/FILES b/src/TKSTEPAttr/FILES
index 85fbd14..c999897 100644
--- a/src/TKSTEPAttr/FILES
+++ b/src/TKSTEPAttr/FILES
@@ -1 +1,2 @@
 PACKAGES
+EXTERNLIB
diff --git a/src/TKSTEPBase/EXTERNLIB b/src/TKSTEPBase/EXTERNLIB
new file mode 100644
index 0000000..fb75d58
--- /dev/null
+++ b/src/TKSTEPBase/EXTERNLIB
@@ -0,0 +1,3 @@
+TKernel
+TKXSBase
+TKMath
diff --git a/src/TKSTEPBase/FILES b/src/TKSTEPBase/FILES
index 85fbd14..c999897 100644
--- a/src/TKSTEPBase/FILES
+++ b/src/TKSTEPBase/FILES
@@ -1 +1,2 @@
 PACKAGES
+EXTERNLIB
diff --git a/src/TKSTL/EXTERNLIB b/src/TKSTL/EXTERNLIB
index 75a6fe2..1efec1e 100644
--- a/src/TKSTL/EXTERNLIB
+++ b/src/TKSTL/EXTERNLIB
@@ -1 +1,7 @@
-TKOffset
+TKernel
+TKMath
+TKBRep
+TKG2d
+TKG3d
+TKMesh
+TKTopAlgo
diff --git a/src/TKService/EXTERNLIB b/src/TKService/EXTERNLIB
index b7b62fe..af7a3b1 100644
--- a/src/TKService/EXTERNLIB
+++ b/src/TKService/EXTERNLIB
@@ -1,3 +1,4 @@
+TKernel
 TKMath
 CSF_XwLibs
 CSF_dpsLibs
diff --git a/src/TKShHealing/EXTERNLIB b/src/TKShHealing/EXTERNLIB
index e0a6ef2..a3cf988 100644
--- a/src/TKShHealing/EXTERNLIB
+++ b/src/TKShHealing/EXTERNLIB
@@ -1,3 +1,9 @@
-TKBool
-TKOffset
+TKBRep
+TKernel
+TKMath
+TKG2d
+TKTopAlgo
+TKG3d
+TKGeomBase
+TKGeomAlgo
 CSF_wsock32
diff --git a/src/TKShapeSchema/EXTERNLIB b/src/TKShapeSchema/EXTERNLIB
index 3484224..10f0293 100644
--- a/src/TKShapeSchema/EXTERNLIB
+++ b/src/TKShapeSchema/EXTERNLIB
@@ -1,2 +1,6 @@
+TKernel
+TKG2d
+PTKernel
+TKMath
 TKCDF
 TKPShape
diff --git a/src/TKStdLSchema/EXTERNLIB b/src/TKStdLSchema/EXTERNLIB
index 1e7fcce..0c32293 100644
--- a/src/TKStdLSchema/EXTERNLIB
+++ b/src/TKStdLSchema/EXTERNLIB
@@ -1 +1,6 @@
+TKCDF
+PTKernel
+TKernel
+TKShapeSchema
+TKLCAF
 TKPLCAF
diff --git a/src/TKStdSchema/EXTERNLIB b/src/TKStdSchema/EXTERNLIB
index 505a715..a5d882f 100644
--- a/src/TKStdSchema/EXTERNLIB
+++ b/src/TKStdSchema/EXTERNLIB
@@ -1 +1,13 @@
+TKCDF
+PTKernel
+TKPLCAF
+TKernel
+TKCAF
+TKShapeSchema
+TKLCAF
+TKStdLSchema
+TKG3d
+TKPShape
+TKMath
+TKG2d
 TKPCAF
diff --git a/src/TKTObj/EXTERNLIB b/src/TKTObj/EXTERNLIB
index faec485..1f4bc90 100644
--- a/src/TKTObj/EXTERNLIB
+++ b/src/TKTObj/EXTERNLIB
@@ -1 +1,4 @@
+TKCDF
+TKernel
+TKMath
 TKLCAF
diff --git a/src/TKTObjDRAW/EXTERNLIB b/src/TKTObjDRAW/EXTERNLIB
index 6a19b00..56dfd2d 100644
--- a/src/TKTObjDRAW/EXTERNLIB
+++ b/src/TKTObjDRAW/EXTERNLIB
@@ -1 +1,7 @@
+TKernel
+TKCDF
+TKLCAF
+TKTObj
+TKMath
+TKDraw
 TKDCAF
diff --git a/src/TKTopAlgo/EXTERNLIB b/src/TKTopAlgo/EXTERNLIB
index d8910ad..7330cad 100644
--- a/src/TKTopAlgo/EXTERNLIB
+++ b/src/TKTopAlgo/EXTERNLIB
@@ -1,2 +1,7 @@
+TKMath
+TKernel
+TKG2d
+TKG3d
+TKGeomBase
 TKBRep
 TKGeomAlgo
diff --git a/src/TKTopTest/EXTERNLIB b/src/TKTopTest/EXTERNLIB
new file mode 100644
index 0000000..46755c6
--- /dev/null
+++ b/src/TKTopTest/EXTERNLIB
@@ -0,0 +1,20 @@
+TKBRep
+TKGeomAlgo
+TKTopAlgo
+TKernel
+TKMath
+TKBO
+TKG2d
+TKG3d
+TKDraw
+TKHLR
+TKGeomBase
+TKMesh
+TKService
+TKV3d
+TKV2d
+TKFillet
+TKPrim
+TKBool
+TKOffset
+TKFeat
diff --git a/src/TKTopTest/FILES b/src/TKTopTest/FILES
index 85fbd14..c999897 100644
--- a/src/TKTopTest/FILES
+++ b/src/TKTopTest/FILES
@@ -1 +1,2 @@
 PACKAGES
+EXTERNLIB
diff --git a/src/TKV2d/EXTERNLIB b/src/TKV2d/EXTERNLIB
index 13ed663..2f5e6a0 100644
--- a/src/TKV2d/EXTERNLIB
+++ b/src/TKV2d/EXTERNLIB
@@ -1 +1,10 @@
+TKernel
+TKMath
+TKGeomBase
+TKG2d
+TKGeomAlgo
+TKBRep
+TKHLR
+TKTopAlgo
+TKG3d
 TKService
diff --git a/src/TKV3d/EXTERNLIB b/src/TKV3d/EXTERNLIB
index 10a8727..bfa3942 100644
--- a/src/TKV3d/EXTERNLIB
+++ b/src/TKV3d/EXTERNLIB
@@ -1,5 +1,15 @@
+TKBRep
+TKMath
+TKernel
+TKService
+TKTopAlgo
+TKG2d
+TKG3d
+TKGeomBase
+TKMesh
+TKGeomAlgo
 TKV2d
 TKHLR
 CSF_user32
 CSF_gdi32
-CSF_OpenGlLibs
\ No newline at end of file
+CSF_OpenGlLibs
diff --git a/src/TKVRML/EXTERNLIB b/src/TKVRML/EXTERNLIB
index 49b9504..6f521bb 100644
--- a/src/TKVRML/EXTERNLIB
+++ b/src/TKVRML/EXTERNLIB
@@ -1 +1,13 @@
+TKBRep
+TKTopAlgo
+TKMath
+TKGeomBase
+TKernel
+TKPrim
+TKG2d
+TKG3d
+TKMesh
+TKHLR
+TKService
+TKGeomAlgo
 TKV3d
diff --git a/src/TKViewerTest/EXTERNLIB b/src/TKViewerTest/EXTERNLIB
index 28e8d05..dc182de 100644
--- a/src/TKViewerTest/EXTERNLIB
+++ b/src/TKViewerTest/EXTERNLIB
@@ -1,3 +1,21 @@
+TKGeomBase
+TKFillet
+TKBRep
+TKTopAlgo
+TKHLR
+TKernel
+TKMath
+TKNIS
+TKService
+TKBool
+TKPrim
+TKGeomAlgo
+TKG2d
+TKTopTest
+TKG3d
+TKOffset
+TKVoxel
+TKMesh
 TKV2d
 TKV3d
 TKDraw
diff --git a/src/TKVoxel/EXTERNLIB b/src/TKVoxel/EXTERNLIB
new file mode 100644
index 0000000..52ffa27
--- /dev/null
+++ b/src/TKVoxel/EXTERNLIB
@@ -0,0 +1,11 @@
+TKBRep
+TKernel
+TKV3d
+TKMath
+TKService
+TKGeomBase
+TKG2d
+TKTopAlgo
+TKG3d
+TKV2d
+TKMesh
diff --git a/src/CDF/FILES b/src/TKVoxel/FILES
similarity index 100%
copy from src/CDF/FILES
copy to src/TKVoxel/FILES
diff --git a/src/TKXCAF/EXTERNLIB b/src/TKXCAF/EXTERNLIB
index 21a5191..f9cf7e0 100644
--- a/src/TKXCAF/EXTERNLIB
+++ b/src/TKXCAF/EXTERNLIB
@@ -1 +1,12 @@
+TKBRep
+TKernel
+TKMath
+TKService
+TKG2d
+TKTopAlgo
+TKV3d
+TKCDF
+TKLCAF
+TKG3d
+TKV2d
 TKCAF
diff --git a/src/TKXCAFSchema/EXTERNLIB b/src/TKXCAFSchema/EXTERNLIB
index 3be6c14..b1b60ca 100644
--- a/src/TKXCAFSchema/EXTERNLIB
+++ b/src/TKXCAFSchema/EXTERNLIB
@@ -1,3 +1,11 @@
+TKPLCAF
+TKernel
+PTKernel
+TKMath
+TKPShape
+TKCDF
+TKShapeSchema
+TKLCAF
 TKPCAF
 TKXCAF
 TKStdLSchema
diff --git a/src/TKXDEDRAW/EXTERNLIB b/src/TKXDEDRAW/EXTERNLIB
index b75c085..0dcdadc 100644
--- a/src/TKXDEDRAW/EXTERNLIB
+++ b/src/TKXDEDRAW/EXTERNLIB
@@ -1,3 +1,22 @@
+TKCDF
+TKBRep
+TKXCAF
+TKernel
+TKIGES
+TKV3d
+TKMath
+TKNIS
+TKService
+TKXSBase
+TKG2d
+TKCAF
+TKDraw
+TKTopAlgo
+TKLCAF
+TKG3d
+TKSTEPBase
+TKSTEP
+TKMesh
 TKXSDRAW
 TKXDEIGES
 TKXDESTEP
diff --git a/src/TKXDEIGES/EXTERNLIB b/src/TKXDEIGES/EXTERNLIB
index e053255..8b253df 100644
--- a/src/TKXDEIGES/EXTERNLIB
+++ b/src/TKXDEIGES/EXTERNLIB
@@ -1,2 +1,9 @@
+TKBRep
+TKernel
+TKMath
+TKXSBase
+TKCDF
+TKLCAF
+TKG2d
 TKXCAF
 TKIGES
diff --git a/src/TKXDESTEP/EXTERNLIB b/src/TKXDESTEP/EXTERNLIB
index 751bf71..a2f9e06 100644
--- a/src/TKXDESTEP/EXTERNLIB
+++ b/src/TKXDESTEP/EXTERNLIB
@@ -1,2 +1,13 @@
+TKBRep
+TKSTEPAttr
+TKernel
+TKMath
+TKXSBase
+TKG2d
+TKCAF
+TKSTEPBase
+TKCDF
+TKLCAF
+TKG3d
 TKXCAF
 TKSTEP
diff --git a/src/TKXMesh/EXTERNLIB b/src/TKXMesh/EXTERNLIB
new file mode 100644
index 0000000..52df3c1
--- /dev/null
+++ b/src/TKXMesh/EXTERNLIB
@@ -0,0 +1,5 @@
+TKBRep
+TKMath
+TKernel
+TKG2d
+TKMesh
diff --git a/src/CDF/FILES b/src/TKXMesh/FILES
similarity index 100%
copy from src/CDF/FILES
copy to src/TKXMesh/FILES
diff --git a/src/TKXSBase/EXTERNLIB b/src/TKXSBase/EXTERNLIB
index 6119886..69976d2 100644
--- a/src/TKXSBase/EXTERNLIB
+++ b/src/TKXSBase/EXTERNLIB
@@ -1,2 +1,8 @@
+TKBRep
+TKernel
+TKMath
+TKG2d
+TKG3d
+TKTopAlgo
+TKGeomBase
 TKShHealing
-
diff --git a/src/TKXSDRAW/EXTERNLIB b/src/TKXSDRAW/EXTERNLIB
index bbfc927..ecab276 100644
--- a/src/TKXSDRAW/EXTERNLIB
+++ b/src/TKXSDRAW/EXTERNLIB
@@ -1,3 +1,21 @@
+TKBRep
+TKV3d
+TKMath
+TKNIS
+TKernel
+TKService
+TKXSBase
+TKMeshVS
+TKG3d
+TKViewerTest
+TKV2d
+TKG2d
+TKSTEPBase
+TKTopAlgo
+TKShHealing
+TKGeomBase
+TKGeomAlgo
+TKMesh
 TKDraw
 TKSTEP
 TKIGES
diff --git a/src/TKXml/EXTERNLIB b/src/TKXml/EXTERNLIB
index 6465382..28cccd9 100644
--- a/src/TKXml/EXTERNLIB
+++ b/src/TKXml/EXTERNLIB
@@ -1,3 +1,11 @@
+TKCDF
+TKernel
+TKV3d
+TKMath
+TKBRep
+TKG2d
+TKGeomBase
+TKG3d
 TKLCAF
 TKCAF
 TKXmlL
diff --git a/src/TKXmlL/EXTERNLIB b/src/TKXmlL/EXTERNLIB
index faec485..1f4bc90 100644
--- a/src/TKXmlL/EXTERNLIB
+++ b/src/TKXmlL/EXTERNLIB
@@ -1 +1,4 @@
+TKCDF
+TKernel
+TKMath
 TKLCAF
diff --git a/src/TKXmlTObj/EXTERNLIB b/src/TKXmlTObj/EXTERNLIB
index 9df0c19..b78e605 100644
--- a/src/TKXmlTObj/EXTERNLIB
+++ b/src/TKXmlTObj/EXTERNLIB
@@ -1 +1,6 @@
+TKCDF
+TKernel
+TKTObj
+TKMath
+TKLCAF
 TKXmlL
diff --git a/src/TKXmlXCAF/EXTERNLIB b/src/TKXmlXCAF/EXTERNLIB
index a6306b9..5b656d9 100644
--- a/src/TKXmlXCAF/EXTERNLIB
+++ b/src/TKXmlXCAF/EXTERNLIB
@@ -1,2 +1,12 @@
+TKXmlL
+TKBRep
+TKCDF
+TKMath
+TKernel
+TKG2d
+TKGeomBase
+TKCAF
+TKG3d
+TKLCAF
 TKXCAF
 TKXml
diff --git a/src/TObj/TObj.msg b/src/TObj/TObj.msg
index ab1f13c..a4546ec 100644
--- a/src/TObj/TObj.msg
+++ b/src/TObj/TObj.msg
@@ -52,6 +52,21 @@
 
 .TObj_Appl_SWriteFailure
   Error saving document %s : write failure
+  
+.TObj_Appl_SFailure
+  Error saving document %s : general failure of persistence driver
+  
+.TObj_Appl_SDiskWritingFailure
+  Error saving document %s : possibly the disk is full or other disk write problem occurred
+  
+.TObj_Appl_SDocIsNull
+  Error saving document %s : No document to save
+  
+.TObj_Appl_SNoObj
+ Error saving document %s : No objects written
+ 
+.TObj_Appl_SInfoSectionError
+ Error saving document %s : Write info section failure
 
 .TObj_Appl_SUnknownFailure
   Error saving document %s : unknown failure
diff --git a/src/TObj/TObj_Application.cxx b/src/TObj/TObj_Application.cxx
index 970a9e0..52cbdcd 100644
--- a/src/TObj/TObj_Application.cxx
+++ b/src/TObj/TObj_Application.cxx
@@ -73,19 +73,33 @@ Standard_Boolean TObj_Application::SaveDocument
   myIsError = Standard_False;
   TCollection_ExtendedString aPath ((const Standard_CString)theTargetFile);
 
-  CDF_StoreStatus aStatus = SaveAs (theSourceDoc, aPath);
-  myIsError = aStatus != CDF_SS_OK;
+  PCDM_StoreStatus aStatus = SaveAs (theSourceDoc, aPath);
+  myIsError = aStatus != PCDM_SS_OK;
   if (myIsError)
   {
     switch (aStatus)
     {
-    case CDF_SS_DriverFailure:
+    case PCDM_SS_DriverFailure:
       ErrorMessage (Message_Msg("TObj_Appl_SDriverFailure") << aPath);
       break;
-    case CDF_SS_WriteFailure:
+    case PCDM_SS_WriteFailure:
       ErrorMessage (Message_Msg("TObj_Appl_SWriteFailure") << aPath);
       break;
-    case CDF_SS_Failure:
+    case PCDM_SS_Failure:
+      ErrorMessage (Message_Msg("TObj_Appl_SFailure") << aPath);
+      break;
+    case PCDM_SS_DiskWritingFailure:
+      ErrorMessage (Message_Msg("TObj_Appl_SDiskWritingFailure") << aPath);
+      break;
+    case PCDM_SS_Doc_IsNull:
+      ErrorMessage (Message_Msg("TObj_Appl_SDocIsNull") << aPath);
+      break;
+    case PCDM_SS_No_Obj:
+      ErrorMessage (Message_Msg("TObj_Appl_SNoObj") << aPath);
+      break;
+    case PCDM_SS_Info_Section_Error:
+      ErrorMessage (Message_Msg("TObj_Appl_SInfoSectionError") << aPath);
+      break;
     default:
       ErrorMessage (Message_Msg("TObj_Appl_SUnknownFailure") << aPath);
       break;
@@ -109,7 +123,7 @@ Standard_Boolean TObj_Application::LoadDocument
   myIsError = Standard_False;
   TCollection_ExtendedString aPath ((const Standard_CString)theSourceFile);
 
-  CDF_RetrievableStatus aStatus = (CDF_RetrievableStatus) -1;
+  PCDM_ReaderStatus aStatus = (PCDM_ReaderStatus) -1;
   {
     try
     {
@@ -123,54 +137,54 @@ Standard_Boolean TObj_Application::LoadDocument
 #endif
     }
   }
-  myIsError = aStatus != CDF_RS_OK;
+  myIsError = aStatus != PCDM_RS_OK;
   if (myIsError)
   {
     switch ((int)aStatus)
     {
-    case CDF_RS_UnknownDocument:
+    case PCDM_RS_UnknownDocument:
       ErrorMessage (Message_Msg("TObj_Appl_RUnknownDocument") << aPath);
       break;
-    case CDF_RS_AlreadyRetrieved:
+    case PCDM_RS_AlreadyRetrieved:
       ErrorMessage (Message_Msg("TObj_Appl_RAlreadyRetrieved") << aPath);
       break;
-    case CDF_RS_AlreadyRetrievedAndModified:
+    case PCDM_RS_AlreadyRetrievedAndModified:
       ErrorMessage (Message_Msg("TObj_Appl_RAlreadyRetrievedAndModified") << aPath);
       break;
-    case CDF_RS_NoDriver:
+    case PCDM_RS_NoDriver:
       ErrorMessage (Message_Msg("TObj_Appl_RNoDriver") << aPath);
       break;
-    case CDF_RS_UnknownFileDriver:
+    case PCDM_RS_UnknownFileDriver:
       ErrorMessage (Message_Msg("TObj_Appl_RNoDriver") << aPath);
       break;
-    case CDF_RS_OpenError:
+    case PCDM_RS_OpenError:
       ErrorMessage (Message_Msg("TObj_Appl_ROpenError") << aPath);
       break;
-    case CDF_RS_NoVersion:
+    case PCDM_RS_NoVersion:
       ErrorMessage (Message_Msg("TObj_Appl_RNoVersion") << aPath);
       break;
-    case CDF_RS_NoModel:
+    case PCDM_RS_NoModel:
       ErrorMessage (Message_Msg("TObj_Appl_RNoModel") << aPath);
       break;
-    case CDF_RS_NoDocument:
+    case PCDM_RS_NoDocument:
       ErrorMessage (Message_Msg("TObj_Appl_RNoDocument") << aPath);
       break;
-    case CDF_RS_FormatFailure:
+    case PCDM_RS_FormatFailure:
       ErrorMessage (Message_Msg("TObj_Appl_RFormatFailure") << aPath);
       break;
-    case CDF_RS_TypeNotFoundInSchema:
+    case PCDM_RS_TypeNotFoundInSchema:
       ErrorMessage (Message_Msg("TObj_Appl_RTypeNotFound") << aPath);
       break;
-    case CDF_RS_UnrecognizedFileFormat:
+    case PCDM_RS_UnrecognizedFileFormat:
       ErrorMessage (Message_Msg("TObj_Appl_RBadFileFormat") << aPath);
       break;
-    case CDF_RS_MakeFailure:
+    case PCDM_RS_MakeFailure:
       ErrorMessage (Message_Msg("TObj_Appl_RMakeFailure") << aPath);
       break;
-    case CDF_RS_PermissionDenied:
+    case PCDM_RS_PermissionDenied:
       ErrorMessage (Message_Msg("TObj_Appl_RPermissionDenied") << aPath);
       break;
-    case CDF_RS_DriverFailure:
+    case PCDM_RS_DriverFailure:
       ErrorMessage (Message_Msg("TObj_Appl_RDriverFailure") << aPath);
       break;
     case -1:
diff --git a/src/TopOpeBRepBuild/TopOpeBRepBuild_FuseFace.cxx b/src/TopOpeBRepBuild/TopOpeBRepBuild_FuseFace.cxx
index 4ba9be6..69700a5 100644
--- a/src/TopOpeBRepBuild/TopOpeBRepBuild_FuseFace.cxx
+++ b/src/TopOpeBRepBuild/TopOpeBRepBuild_FuseFace.cxx
@@ -420,7 +420,7 @@ void TopOpeBRepBuild_FuseFace::PerformFace()
 	S = Handle(Geom_RectangularTrimmedSurface)::
 	  DownCast(S)->BasisSurface();
       }
-      BRepLib_MakeFace MF(S);  
+      BRepLib_MakeFace MF(S, Precision::Confusion());  
 
       for(it2.Initialize(myFaceLW); it2.More(); it2.Next()) {
 	const TopoDS_Wire& wir1 = TopoDS::Wire(it2.Value());
diff --git a/src/V3d/V3d_View.cdl b/src/V3d/V3d_View.cdl
index 4514284..5e4a608 100644
--- a/src/V3d/V3d_View.cdl
+++ b/src/V3d/V3d_View.cdl
@@ -142,7 +142,10 @@ uses
         GraphicCallbackProc               from Aspect,
         FillMethod                        from Aspect,
         GradientFillMethod                from Aspect,
-        FontAspect                        from OSD
+        FontAspect                        from OSD,
+        AsciiString                       from TCollection,
+        ExtendedString                    from TCollection,
+        PrintAlgo                         from Aspect
 
 raises
 
@@ -479,63 +482,39 @@ is
 
         GetGraduatedTrihedron(me;
                               -- Names of axes --
-                              xname : out CString from Standard;
-                              yname : out CString from Standard;
-                              zname : out CString from Standard;
+                              xname, yname, zname : out ExtendedString from TCollection;
                               -- Draw names --
-                              xdrawname : out Boolean from Standard;
-                              ydrawname : out Boolean from Standard;
-                              zdrawname : out Boolean from Standard;
+                              xdrawname, ydrawname, zdrawname : out Boolean from Standard;
                               -- Draw values --
-                              xdrawvalues : out Boolean from Standard;
-                              ydrawvalues : out Boolean from Standard;
-                              zdrawvalues : out Boolean from Standard;
+                              xdrawvalues, ydrawvalues, zdrawvalues : out Boolean from Standard;
                               -- Draw grid --
                               drawgrid : out Boolean from Standard;
                               -- Draw axes --
                               drawaxes : out Boolean from Standard;
                               -- Number of splits along axes --
-                              nbx : out Integer from Standard;
-                              nby : out Integer from Standard;
-                              nbz : out Integer from Standard;
+                              nbx, nby, nbz : out Integer from Standard;
                               -- Offset for drawing values --
-                              xoffset : out Integer from Standard;
-                              yoffset : out Integer from Standard;
-                              zoffset : out Integer from Standard;
+                              xoffset, yoffset, zoffset : out Integer from Standard;
                               -- Offset for drawing names of axes --
-                              xaxisoffset : out Integer from Standard;
-                              yaxisoffset : out Integer from Standard;
-                              zaxisoffset : out Integer from Standard;
+                              xaxisoffset, yaxisoffset, zaxisoffset : out Integer from Standard;
                               -- Draw tickmarks --
-                              xdrawtickmarks : out Boolean from Standard;
-                              ydrawtickmarks : out Boolean from Standard;
-                              zdrawtickmarks : out Boolean from Standard;
+                              xdrawtickmarks, ydrawtickmarks, zdrawtickmarks : out Boolean from Standard;
                               -- Length of tickmarks --
-                              xtickmarklength : out Integer from Standard;
-                              ytickmarklength : out Integer from Standard;
-                              ztickmarklength : out Integer from Standard;
+                              xtickmarklength, ytickmarklength, ztickmarklength : out Integer from Standard;
                               -- Grid color --
                               gridcolor : out Color from Quantity;
-                              -- X name color --
-                              xnamecolor : out Color from Quantity;
-                              -- Y name color --
-                              ynamecolor : out Color from Quantity;
-                              -- Z name color --
-                              znamecolor : out Color from Quantity;
-                              -- X color of axis and values --
-                              xcolor : out Color from Quantity;
-                              -- Y color of axis and values --
-                              ycolor : out Color from Quantity;
-                              -- Z color of axis and values --
-                              zcolor : out Color from Quantity;
+                              -- Colors of axis names --
+                              xnamecolor, ynamecolor, znamecolor : out Color from Quantity;
+                              -- Colors of axis and values --
+                              xcolor, ycolor, zcolor : out Color from Quantity;
                               -- Name of font for names of axes --
-                              fontOfNames : out CString from Standard;
+                              fontOfNames : out AsciiString from TCollection;
                               -- Style of names of axes --
                               styleOfNames : out FontAspect from OSD;
                               -- Size of names of axes --
                               sizeOfNames : out Integer from Standard;
                               -- Name of font for values --
-                              fontOfValues : out CString from Standard;
+                              fontOfValues : out AsciiString from TCollection;
                               -- Style of values --
                               styleOfValues : out FontAspect from OSD;
                               -- Size of values --
@@ -545,9 +524,9 @@ is
 
         GraduatedTrihedronDisplay(me : mutable;
                                   -- Names of axes --
-                                  xname : CString from Standard = "X\0";
-                                  yname : CString from Standard = "Y\0";
-                                  zname : CString from Standard = "Z\0";
+                                  xname : ExtendedString from TCollection = "X";
+                                  yname : ExtendedString from TCollection = "Y";
+                                  zname : ExtendedString from TCollection = "Z";
                                   -- Draw names --
                                   xdrawname : Boolean from Standard = Standard_True;
                                   ydrawname : Boolean from Standard = Standard_True;
@@ -595,13 +574,13 @@ is
                                   -- Z color of axis and values --
                                   zcolor : Color from Quantity = Quantity_NOC_BLUE1;
                                   -- Name of font for names of axes --
-                                  fontOfNames : CString from Standard = "Arial";
+                                  fontOfNames : AsciiString from TCollection = "Arial";
                                   -- Style of names of axes --
                                   styleOfNames : FontAspect from OSD = OSD_FA_Bold;
                                   -- Size of names of axes --
                                   sizeOfNames : Integer from Standard = 12;
                                   -- Name of font for values --
-                                  fontOfValues : CString from Standard = "Arial";
+                                  fontOfValues : AsciiString from TCollection = "Arial";
                                   -- Style of values --
                                   styleOfValues : FontAspect from OSD = OSD_FA_Regular;
                                   -- Size of values --
@@ -1628,9 +1607,10 @@ is
 
       Print (me; hPrnDC: Handle from Aspect = NULL;
              showDialog: Boolean = Standard_True;
-             showBackground: Boolean = Standard_True;
-             filename: CString = NULL)
-      is static;
+             showBackground : Boolean = Standard_True;
+             filename: CString = NULL;
+             printAlgorithm : PrintAlgo from Aspect = Aspect_PA_STRETCH)
+      returns Boolean from Standard is static;
 
         ---Level: Public
         ---Purpose: print the contents of the view to printer with preview.
@@ -1647,6 +1627,15 @@ is
     -- (background is white)
         -- else set to TRUE for printing with current background color.
     -- <filename>: If != NULL, then the view will be printed to a file.
+    -- <printAlgorithm>: If you want to select the print algorithm, then you can
+        -- specify one of existing algorithms: Aspect_PA_STRETCH, Aspect_PA_TILE.
+    -- Returns Standard_True if the data is passed to the printer, otherwise
+    -- Standard_False if the print operation failed. This might be related to
+    -- insufficient memory or some internal errors. All this errors are
+    -- indicated by the message boxes (on level of OpenGl_GraphicDriver).
+    --  Warning: This function can reuse FBO assigned to the 
+    --  view on level of OpenGl_GraphicDriver; Please take it into account if
+    --  you use it for your purposes;
     --  Warning: Works only under Windows.
 
         ToPixMap ( me : mutable;
diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx
index c9868fa..986f096 100644
--- a/src/V3d/V3d_View.cxx
+++ b/src/V3d/V3d_View.cxx
@@ -491,6 +491,11 @@ void V3d_View::SetWindow(const Handle(Aspect_Window)& TheWindow)
     "V3d_View::SetWindow, window of view already defined");
 
   MyView->SetWindow(TheWindow) ;
+  // AGV: Method V3d_View::SetWindow() should assign the field MyWindow before
+  // calling Redraw(). Otherwise it is impossible to call certain methods of
+  // V3d_View like Convert() inside the context of Redraw(),
+  // particularly in class NIS_View.
+  MyWindow = TheWindow;
   // SetWindow carries out SetRatio and modifies
   // ViewMapping and ViewMappingDefault of MyView.
   MyViewMapping = MyView->ViewMapping() ;
@@ -504,7 +509,6 @@ void V3d_View::SetWindow(const Handle(Aspect_Window)& TheWindow)
   MyGridEchoStructure->Display ();                              // S3892
 #endif
   MyView->Redraw() ;
-  MyWindow = TheWindow;
 
 }
 
@@ -520,6 +524,11 @@ void V3d_View::SetWindow(const Handle(Aspect_Window)&      aWindow,
   Standard_MultiplyDefined_Raise_if( MyView->IsDefined(),
     "V3d_View::SetWindow, "
     "window of view already defined");
+  // AGV: Method V3d_View::SetWindow() should assign the field MyWindow before
+  // calling Redraw(). Otherwise it is impossible to call certain methods of
+  // V3d_View like Convert() inside the context of Redraw(),
+  // particularly in class NIS_View.
+  MyWindow = aWindow;
   MyView->SetWindow(aWindow, aContext, aDisplayCB, aClientData) ;
   MyViewMapping = MyView->ViewMapping() ;
   MyView->SetContext(MyViewContext) ;
@@ -528,7 +537,6 @@ void V3d_View::SetWindow(const Handle(Aspect_Window)&      aWindow,
   MyView->SetBackground(MyBackground) ;
   MyViewer->SetViewOn(this) ;
   MyView->Redraw() ;
-  MyWindow = aWindow;
 
 }
 // RIC120302
diff --git a/src/V3d/V3d_View_4.cxx b/src/V3d/V3d_View_4.cxx
index ec4178f..48d0108 100644
--- a/src/V3d/V3d_View_4.cxx
+++ b/src/V3d/V3d_View_4.cxx
@@ -493,9 +493,9 @@ void V3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
 }
 
 void V3d_View::GetGraduatedTrihedron(/* Names of axes */
-                                     Standard_CString& xname, 
-                                     Standard_CString& yname, 
-                                     Standard_CString& zname,
+                                     TCollection_ExtendedString &xname,
+                                     TCollection_ExtendedString &yname,
+                                     TCollection_ExtendedString &zname,
                                      /* Draw names */
                                      Standard_Boolean& xdrawname, 
                                      Standard_Boolean& ydrawname, 
@@ -543,13 +543,13 @@ void V3d_View::GetGraduatedTrihedron(/* Names of axes */
                                      /* Z color of axis and values */
                                      Quantity_Color& zcolor,
                                      /* Name of font for names of axes */
-                                     Standard_CString& fontOfNames,
+                                     TCollection_AsciiString &fontOfNames,
                                      /* Style of names of axes */
                                      OSD_FontAspect& styleOfNames,
                                      /* Size of names of axes */
                                      Standard_Integer& sizeOfNames,
                                      /* Name of font for values */
-                                     Standard_CString& fontOfValues,
+                                     TCollection_AsciiString &fontOfValues,
                                      /* Style of values */
                                      OSD_FontAspect& styleOfValues,
                                      /* Size of values */
@@ -620,9 +620,9 @@ void V3d_View::GetGraduatedTrihedron(/* Names of axes */
 }
 
 void V3d_View::GraduatedTrihedronDisplay(/* Names of axes */
-                                         const Standard_CString xname, 
-                                         const Standard_CString yname, 
-                                         const Standard_CString zname,
+                                         const TCollection_ExtendedString &xname, 
+                                         const TCollection_ExtendedString &yname, 
+                                         const TCollection_ExtendedString &zname,
                                          /* Draw names */
                                          const Standard_Boolean xdrawname, 
                                          const Standard_Boolean ydrawname, 
@@ -670,13 +670,13 @@ void V3d_View::GraduatedTrihedronDisplay(/* Names of axes */
                                          /* Z color of axis and values */
                                          const Quantity_Color& zcolor,
                                          /* Name of font for names of axes */
-                                         const Standard_CString fontOfNames,
+                                         const TCollection_AsciiString &fontOfNames,
                                          /* Style of names of axes */
                                          const OSD_FontAspect styleOfNames,
                                          /* Size of names of axes */
                                          const Standard_Integer sizeOfNames,
                                          /* Name of font for values */
-                                         const Standard_CString fontOfValues,
+                                         const TCollection_AsciiString &fontOfValues,
                                          /* Style of values */
                                          const OSD_FontAspect styleOfValues,
                                          /* Size of values */
@@ -750,4 +750,3 @@ void V3d_View::GraduatedTrihedronErase()
 {
     MyView->GraduatedTrihedronErase();
 }
-
diff --git a/src/V3d/V3d_View_Print.cxx b/src/V3d/V3d_View_Print.cxx
index 9bb3164..6b6975a 100644
--- a/src/V3d/V3d_View_Print.cxx
+++ b/src/V3d/V3d_View_Print.cxx
@@ -53,18 +53,20 @@ Device::~Device()
 /* Print Method                                                        */
 /************************************************************************/
 
-void V3d_View::Print (const Aspect_Handle       hPrnDC,
-                      const Standard_Boolean    showDialog,
-                      const Standard_Boolean    showBackground,
-                      const Standard_CString    filename) const 
+Standard_Boolean V3d_View::Print (const Aspect_Handle    hPrnDC,
+                                  const Standard_Boolean showDialog,
+                                  const Standard_Boolean showBackground,
+                                  const Standard_CString filename,
+                                  const Aspect_PrintAlgo printAlgorithm) const
 {
 #ifdef WNT
 	if( MyView->IsDefined() ) 
 	{
 		if (hPrnDC != NULL)
 		{
-			MyView->Print(hPrnDC, showBackground, filename) ;
-			return;
+			return MyView->Print(hPrnDC, showBackground,
+			                     filename, printAlgorithm) ;
+			
 		}
 
 		if (device._pd.hDC == NULL || showDialog )
@@ -85,7 +87,7 @@ void V3d_View::Print (const Aspect_Handle       hPrnDC,
 		
 			if (!ispd)
 			{
-				return;
+				return Standard_False;
 			}
 			
 			if (!(device._pd.hDC)) 
@@ -101,12 +103,21 @@ void V3d_View::Print (const Aspect_Handle       hPrnDC,
 					device._pd.hDevMode = NULL;
 				}
 				MessageBox(0, "Couldn't create Printer Device Context", "Error", MB_OK | MB_ICONSTOP);
-				return;
+				return Standard_False;
 			}
 		}
-		MyView->Print(device._pd.hDC, showBackground, filename) ;
+
+    // process scale factor accordingly to the new printing approach
+    DEVMODE* aMode = (LPDEVMODE)GlobalLock(device._pd.hDevMode);
+
+    // convert percents to multiplication factor, 100% = 1.0
+    Standard_Real aScaleFactor = (Standard_Real) aMode->dmScale / 100.0;
+    GlobalUnlock (device._pd.hDevMode);
+   return MyView->Print(device._pd.hDC, showBackground,
+                        filename, printAlgorithm, aScaleFactor) ;
 	}
 #else
 	Standard_NotImplemented::Raise ("V3d_View::Print is implemented only on Windows");
 #endif
+  return Standard_False;
 }
diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx
index f693482..4d2a7a5 100644
--- a/src/ViewerTest/ViewerTest.cxx
+++ b/src/ViewerTest/ViewerTest.cxx
@@ -252,6 +252,57 @@ Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(){
   return TheMap;
 }
 
+
+//==============================================================================
+//function : VDisplayAISObject
+//purpose  : register interactive object in the map of AIS objects;
+//           if other object with such name already registered, it will be kept
+//           or replaced depending on value of <theReplaceIfExists>,
+//           if "true" - the old object will be cleared from AIS context;
+//           returns Standard_True if <theAISObj> registered in map;
+//==============================================================================
+Standard_EXPORT Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
+                                                    const Handle(AIS_InteractiveObject)& theAISObj,
+                                                    Standard_Boolean theReplaceIfExists = Standard_True)
+{
+  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
+  if (aContextAIS.IsNull())
+  {
+    std::cout << "AIS context is not available.\n";
+    return Standard_False;
+  }
+
+  if (aMap.IsBound2 (theName))
+  {
+    if (!theReplaceIfExists)
+    {
+      std::cout << "Other interactive object has been already "
+                << "registered with name: " << theName << ".\n"
+                << "Please use another name.\n";
+      return Standard_False;
+    }
+
+    // stop displaying object
+    Handle(AIS_InteractiveObject) anOldObj =
+       Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (theName));
+
+    if (!anOldObj.IsNull())
+      aContextAIS->Clear (anOldObj, Standard_True);
+
+    // remove name and old object from map
+    aMap.UnBind2 (theName);
+  }
+
+  // unbind AIS object if was bound with another name
+  aMap.UnBind1 (theAISObj);
+
+  // can be registered without rebinding
+  aMap.Bind (theAISObj, theName);
+  aContextAIS->Display (theAISObj, Standard_True);
+  return Standard_True;
+}
+
 static TColStd_MapOfInteger theactivatedmodes(8);
 static TColStd_ListOfTransient theEventMgrs;
 
diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx
index 945625d..3820292 100644
--- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx
+++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx
@@ -1,7 +1,7 @@
-// File:  ViewerTest_ObjectsCommands.cxx
-// Created: Thu Nov 12 15:50:42 1998
-// Author:  Robert COUBLANC
-//    <rob at robox.paris1.matra-dtv.fr>
+// File:      ViewerTest_ObjectsCommands.cxx
+// Created:   Thu Nov 12 15:50:42 1998
+// Author:    Robert COUBLANC
+// Copyright: OPEN CASCADE 1998
 
 
 //===============================================
@@ -76,6 +76,24 @@
 #include <Geom_Axis1Placement.hxx>
 #include <AIS_Trihedron.hxx>
 #include <AIS_Axis.hxx>
+
+#include <HLRAlgo_Projector.hxx>
+#include <HLRBRep_PolyAlgo.hxx>
+#include <HLRBRep_PolyHLRToShape.hxx>
+#include <Aspect_Window.hxx>
+
+#include <Graphic3d_ArrayOfPoints.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Graphic3d_ArrayOfTriangleFans.hxx>
+#include <Graphic3d_ArrayOfTriangleStrips.hxx>
+#include <Graphic3d_ArrayOfQuadrangles.hxx>
+#include <Graphic3d_ArrayOfQuadrangleStrips.hxx>
+#include <Graphic3d_ArrayOfPolygons.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Standard_Real.hxx>
+
 #ifdef HAVE_STRINGS_H
 #include <strings.h>
 #endif
@@ -85,6 +103,9 @@
 #endif
 
 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
+extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
+                                           const Handle(AIS_InteractiveObject)& theAISObj,
+                                           Standard_Boolean theReplaceIfExists = Standard_True);
 extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
 extern Handle(AIS_InteractiveContext)& TheAISContext();
 
@@ -1936,8 +1957,8 @@ static int VCircleBuilder(Draw_Interpretor& di, Standard_Integer argc, const cha
 
 DEFINE_STANDARD_HANDLE(MyTextClass, AIS_InteractiveObject)
 
-class MyTextClass:public AIS_InteractiveObject{
-
+class MyTextClass:public AIS_InteractiveObject
+{
 public:
   // CASCADE RTTI
   DEFINE_STANDARD_RTTI(MyTextClass );
@@ -1988,7 +2009,6 @@ IMPLEMENT_STANDARD_HANDLE(MyTextClass, AIS_InteractiveObject)
 IMPLEMENT_STANDARD_RTTIEXT(MyTextClass, AIS_InteractiveObject)
 
 
-
 MyTextClass::MyTextClass( const TCollection_ExtendedString& text, const gp_Pnt& position,
                           Quantity_Color    color       = Quantity_NOC_YELLOW,
                           Standard_Integer  aHJust      = Graphic3d_HTA_LEFT,
@@ -2048,75 +2068,90 @@ void MyTextClass::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentat
 
 static int VDrawText (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
 {
-  // Verification des arguments
-  if ( argc > 17 ) {di<<argv[0]<<" Syntaxe error"<<"\n"; return 1;}
-  Quantity_Parameter        R, G, B;
-  Quantity_Color            aColor;
-  Standard_Real             angle;
-  Standard_Real             height;
-  Standard_Boolean          zoom;
-  OSD_FontAspect            aspect;
-  TCollection_AsciiString   font;
-  gp_Pnt                    pnt;
-  int                       hor_align;
-  int                       ver_align;
-  TCollection_AsciiString   aFont;
-  TCollection_AsciiString   name = argv[1];
-
-  //Declarations et creation des objets par default
-  Standard_Real X,Y,Z;
-  X = atof(argv[2]);
-  Y = atof(argv[3]);
-  Z = atof(argv[4]);
-  pnt.SetCoord(X,Y,Z);
-
-  R = atof(argv[5])/255.;
-  G = atof(argv[6])/255.;
-  B = atof(argv[7])/255.;
-
-  hor_align = atoi(argv[8]);
-  ver_align = atoi(argv[9]);
-
-  angle = atof(argv[10]);
-
-  zoom = atoi(argv[11]);
-
-  height = atof(argv[12]);
-
-  aspect = OSD_FontAspect(atoi(argv[13]));
-
-  if(argc == 14)
-    font.AssignCat("Courier");
-  if(argc == 15)
-    font.AssignCat(argv[14]);
-  if(argc == 16)
+  // Check arguments
+  if (argc < 14)
   {
-    font.AssignCat(argv[14]);
-    font.AssignCat(" ");
-    font.AssignCat(argv[15]);
+    di<<"Error: "<<argv[0]<<" - invalid number of arguments\n";
+    di<<"Usage: type help "<<argv[0]<<"\n";
+    return 1; //TCL_ERROR
   }
-  if(argc == 17)
+
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+
+  // Create 3D view if it doesn't exist
+  if ( aContext.IsNull() )
   {
-    font.AssignCat(argv[14]);
-    font.AssignCat(" ");
-    font.AssignCat(argv[15]);
-    font.AssignCat(" ");
-    font.AssignCat(argv[16]);
+    ViewerTest::ViewerInit();
+    aContext = ViewerTest::GetAISContext();
+    if( aContext.IsNull() )
+    {
+      di << "Error: Cannot create a 3D view\n";
+      return 1; //TCL_ERROR
+    }
   }
 
-  aColor.SetValues( R, G, B, Quantity_TOC_RGB );
+  // Text position
+  const Standard_Real X = atof(argv[2]);
+  const Standard_Real Y = atof(argv[3]);
+  const Standard_Real Z = atof(argv[4]);
+  const gp_Pnt pnt(X,Y,Z);
 
-  Handle(AIS_InteractiveContext) aContext= ViewerTest::GetAISContext();
+  // Text color
+  const Quantity_Parameter R = atof(argv[5])/255.;
+  const Quantity_Parameter G = atof(argv[6])/255.;
+  const Quantity_Parameter B = atof(argv[7])/255.;
+  const Quantity_Color aColor( R, G, B, Quantity_TOC_RGB );
 
-  Handle(MyTextClass) my=new MyTextClass(argv[1],pnt,aColor,hor_align,ver_align,angle,zoom,height,aspect,font.ToCString());
+  // Text alignment
+  const int hor_align = atoi(argv[8]);
+  const int ver_align = atoi(argv[9]);
 
-  aContext->Display(my,Standard_True);
+  // Text angle
+  const Standard_Real angle = atof(argv[10]);
 
-  if(aContext.IsNull())
+  // Text zooming
+  const Standard_Boolean zoom = atoi(argv[11]);
+
+  // Text height
+  const Standard_Real height = atof(argv[12]);
+
+  // Text aspect
+  const OSD_FontAspect aspect = OSD_FontAspect(atoi(argv[13]));
+
+  // Text font
+  TCollection_AsciiString font;
+  if(argc < 15)
+    font.AssignCat("Courier");
+  else
+    font.AssignCat(argv[14]);
+
+  // Text is multibyte
+  const Standard_Boolean isMultibyte = (argc < 16)? Standard_False : (atoi(argv[15]) != 0);
+
+  // Read text string
+  TCollection_ExtendedString name;
+  if (isMultibyte)
+  {
+    const char *str = argv[1];
+    while (*str)
+    {
+      unsigned short c1 = *str++;
+      unsigned short c2 = *str++;
+      if (!c1 || !c2) break;
+      name += (Standard_ExtCharacter)((c1 << 8) | c2);
+    }
+  }
+  else
+  {
+    name += argv[1];
+  }
+
+  if (name.Length())
   {
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return -1;
+    Handle(MyTextClass) myT = new MyTextClass(name,pnt,aColor,hor_align,ver_align,angle,zoom,height,aspect,font.ToCString());
+    aContext->Display(myT,Standard_True);
   }
+
   return 0;
 }
 
@@ -2722,7 +2757,7 @@ static int VClipPlane (Draw_Interpretor& di, Standard_Integer argc, const char**
   if (anActivePlanes < aView->View()->PlaneLimit())
   {
     aView->SetPlaneOn (aPlaneV3d); // add to enabled planes list
-    aView->Update();    
+    aView->Update();
   }
   else
   {
@@ -2732,6 +2767,435 @@ static int VClipPlane (Draw_Interpretor& di, Standard_Integer argc, const char**
   return 0;
 }
 
+//=============================================================================
+//function : VComputeHLR
+//purpose  :
+//=============================================================================
+
+static int VComputeHLR (Draw_Interpretor& di,
+                        Standard_Integer argc,
+                        const char** argv)
+{
+  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext ();
+
+  if (aContextAIS.IsNull ())
+  {
+    di << "Please call vinit before\n";
+    return 1;
+  }
+
+  if ( argc != 3 &&  argc != 12 )
+  {
+    di << "Usage: " << argv[0] << " ShapeName HlrName "
+       << "[ eye_x eye_y eye_z dir_x dir_y dir_z upx upy upz ]" << "\n"
+       << "                    ShapeName - name of the initial shape\n"
+       << "                    HlrName - result hlr object from initial shape\n"
+       << "                    eye, dir are eye position and look direction\n"
+       << "                    up is the look up direction vector\n"
+       << "                    Use vtop to see projected hlr shape\n";
+    return 1;
+  }
+
+  // shape and new object name
+  TCollection_AsciiString aShapeName (argv[1]);
+  TCollection_AsciiString aHlrName (argv[2]);
+
+  TopoDS_Shape aSh = DBRep::Get (argv[1]);
+  if (aSh.IsNull()) 
+  {
+    BRep_Builder aBrepBuilder;
+    BRepTools::Read (aSh, argv[1], aBrepBuilder);
+    if (aSh.IsNull ())
+    {
+      di << "No shape with name " << argv[1] << " found\n";
+      return 1;
+    }
+  }
+
+  if (GetMapOfAIS ().IsBound2 (aHlrName))
+  {
+    di << "Presentable object with name " << argv[2] << " already exists\n";
+    return 1;
+  }
+
+  // close local context
+  if (aContextAIS->HasOpenedContext ())
+    aContextAIS->CloseLocalContext ();
+
+  Handle(HLRBRep_PolyAlgo) aPolyAlgo = new HLRBRep_PolyAlgo();
+  HLRBRep_PolyHLRToShape aHLRToShape;
+
+  gp_Pnt anEye;
+  gp_Dir aDir;
+  gp_Ax2 aProjAx;
+  if (argc == 9)
+  {
+    gp_Dir anUp;
+
+    anEye.SetCoord (atof (argv[3]), atof (argv[4]), atof (argv[5]));
+    aDir.SetCoord (atof (argv[6]), atof (argv[7]), atof (argv[8]));
+    anUp.SetCoord (atof (argv[9]), atof (argv[10]), atof (argv[11]));
+    aProjAx.SetLocation (anEye);
+    aProjAx.SetDirection (aDir);
+    aProjAx.SetYDirection (anUp);
+  }
+  else
+  {
+    gp_Dir aRight;
+
+    Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
+    Handle(V3d_View)   aView   = ViewerTest::CurrentView();
+    Standard_Integer aWidth, aHeight;
+    Standard_Real aCentX, aCentY, aCentZ, aDirX, aDirY, aDirZ;
+    Standard_Real aRightX, aRightY, aRightZ;
+    aView->Window()->Size (aWidth, aHeight);
+
+    aView->ConvertWithProj (aWidth, aHeight/2, 
+                            aRightX, aRightY, aRightZ,
+                            aDirX, aDirY, aDirZ);
+
+    aView->ConvertWithProj (aWidth/2, aHeight/2, 
+                            aCentX, aCentY, aCentZ,
+                            aDirX, aDirY, aDirZ);
+
+    anEye.SetCoord (-aCentX, -aCentY, -aCentZ);
+    aDir.SetCoord (-aDirX, -aDirY, -aDirZ);
+    aRight.SetCoord (aRightX - aCentX, aRightY - aCentY, aRightZ - aCentZ);
+    aProjAx.SetLocation (anEye);
+    aProjAx.SetDirection (aDir);
+    aProjAx.SetXDirection (aRight);
+  }
+
+  HLRAlgo_Projector aProjector (aProjAx);
+  aPolyAlgo->Projector (aProjector);
+  aPolyAlgo->Load (aSh);
+  aPolyAlgo->Update ();
+
+  aHLRToShape.Update (aPolyAlgo);
+
+  // make hlr shape from input shape
+  TopoDS_Compound aHlrShape;
+  BRep_Builder aBuilder;
+  aBuilder.MakeCompound (aHlrShape);
+
+  TopoDS_Shape aCompound = aHLRToShape.VCompound();
+  if (!aCompound.IsNull ())
+  {
+    aBuilder.Add (aHlrShape, aCompound);
+  }
+  
+  // extract visible outlines
+  aCompound = aHLRToShape.OutLineVCompound();
+  if (!aCompound.IsNull ())
+  {
+    aBuilder.Add (aHlrShape, aCompound);
+  }
+
+  // create an AIS shape and display it
+  Handle(AIS_Shape) anObject = new AIS_Shape (aHlrShape);
+  GetMapOfAIS().Bind (anObject, aHlrName);
+  aContextAIS->Display (anObject);
+
+  aContextAIS->UpdateCurrentViewer ();
+
+  return 0;
+}
+
+// This class is a wrap for Graphic3d_ArrayOfPrimitives; it is used for
+// manipulating and displaying such an array with AIS context
+DEFINE_STANDARD_HANDLE(MyPArrayObject, AIS_InteractiveObject)
+class MyPArrayObject : public AIS_InteractiveObject
+{
+
+public:
+
+  MyPArrayObject (const Handle(Graphic3d_ArrayOfPrimitives) theArray)
+  {
+    myArray = theArray;
+  }
+
+  DEFINE_STANDARD_RTTI(MyPArrayObject);
+
+private:
+
+  void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+                const Handle(Prs3d_Presentation)& aPresentation,
+                const Standard_Integer aMode);
+
+  void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection,
+                         const Standard_Integer aMode) {};
+
+protected:
+
+  Handle(Graphic3d_ArrayOfPrimitives) myArray;
+
+};
+
+IMPLEMENT_STANDARD_HANDLE(MyPArrayObject, AIS_InteractiveObject)
+IMPLEMENT_STANDARD_RTTIEXT(MyPArrayObject, AIS_InteractiveObject)
+
+void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+                              const Handle(Prs3d_Presentation)& aPresentation,
+                              const Standard_Integer aMode)
+{
+  aPresentation->Clear();
+
+  Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPresentation);
+  aGroup->BeginPrimitives ();
+  aGroup->AddPrimitiveArray (myArray);
+  aGroup->EndPrimitives ();
+}
+
+static bool CheckInputCommand (const TCollection_AsciiString theCommand,
+                               const char **theArgStr, int &theArgIndex,
+                               int theArgCount, int theMaxArgs)
+{
+  // check if there is more elements than expected
+  if (theArgIndex >= theMaxArgs)
+    return false;
+
+  TCollection_AsciiString aStrCommand(theArgStr[theArgIndex]);
+  aStrCommand.LowerCase();
+  if (aStrCommand.Search(theCommand) != 1 ||
+      theArgIndex + (theArgCount - 1) >= theMaxArgs)
+    return false;
+
+  // go to the first data element
+  theArgIndex++;
+
+  // check data if it can be converted to numeric
+  for (int aElement = 0; aElement < theArgCount; aElement++, theArgIndex++)
+  {
+    aStrCommand = theArgStr[theArgIndex];
+    if (!aStrCommand.IsRealValue())
+      return false;
+  }
+
+  return true;
+}
+
+//=============================================================================
+//function : VDrawPArray
+//purpose  : Draws primitives array from list of vertexes, bounds, edges
+//=============================================================================
+
+static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
+  if (aContextAIS.IsNull())
+  {
+    di << "Call vinit before!\n";
+    return 1;
+  }
+  else if (argc < 3)
+  {
+    di << "Use: " << argv[0] << " Name TypeOfArray [EnableVBO={0 | 1}]"
+       << " [vertex] ... [bounds] ... [edges]\n"
+       << "  TypeOfArray={ points | segments | polylines | triangles |\n"
+       << "                trianglefan | trianglestrips | quads |\n"
+       << "                quadstrips | polygons }\n"
+       << "  vertex={ 'v' x y z [normal={ 'n' nx ny nz }] [color={ 'c' r g b }]"
+       << " [texel={ 't' tx ty }] } \n"
+       << "  bounds={ 'b' verticies_count [color={ 'c' r g b }] }\n"
+       << "  edges={ 'e' vertex_id [hidden_edge={'h'}] }\n";
+    return 1;
+  }
+
+  // read the arguments
+  TCollection_AsciiString aName (argv[1]);
+  TCollection_AsciiString anArrayType (argv[2]);
+  
+  // is argument list has an vbo flag
+  Standard_Boolean hasFlagVbo = Standard_False;
+  if (isdigit (argv[3][0]) && atoi (argv[3]) >= 0 && atoi (argv[3]) <= 1)
+    hasFlagVbo = Standard_True;
+
+  // parse number of verticies, bounds, edges
+  Standard_Integer aVertexNum = 0, aBoundNum = 0, aEdgeNum = 0;
+  Standard_Boolean hasVColors, hasBColors, hasNormals, hasInfos, hasTexels;
+  hasVColors = hasNormals = hasBColors = hasInfos = hasTexels = Standard_False;
+
+  Standard_Integer aArgIndex = (hasFlagVbo) ? 4 : 3;
+  TCollection_AsciiString aCommand;
+  while (aArgIndex < argc)
+  {
+    aCommand = argv[aArgIndex];
+    aCommand.LowerCase();
+    if (!aCommand.IsAscii())
+    {
+      di << "Unexpected argument: #" << aArgIndex - 1 << " , "
+         << "should be an array element: 'v', 'b', 'e' \n";
+      break;
+    }
+
+    // vertex command
+    if (CheckInputCommand ("v", argv, aArgIndex, 3, argc))
+    {
+      // vertex has a normal or normal with color or texel
+      if (CheckInputCommand ("n", argv, aArgIndex, 3, argc))
+        hasNormals = Standard_True;
+
+      // vertex has a color
+      if (CheckInputCommand ("c", argv, aArgIndex, 3, argc))
+        hasVColors = Standard_True;
+
+      // vertex has a texel
+      if (CheckInputCommand ("t", argv, aArgIndex, 2, argc))
+        hasTexels = Standard_True;
+
+      aVertexNum++;
+    }
+    // bound command
+    else if (CheckInputCommand ("b", argv, aArgIndex, 1, argc))
+    {
+      // bound has color
+      if (CheckInputCommand ("c", argv, aArgIndex, 3, argc))
+        hasBColors = Standard_True;
+
+      aBoundNum++;
+    }
+    // edge command
+    else if (CheckInputCommand ("e", argv, aArgIndex, 1, argc))
+    {
+      // edge has a hide flag
+      if (CheckInputCommand ("h", argv, aArgIndex, 0, argc))
+        hasInfos = Standard_True;
+
+      aEdgeNum++;
+    }
+    // unknown command
+    else
+      aArgIndex++;
+  }
+
+  if (aVertexNum == 0)
+  {
+    di << "You should pass any verticies in the list of array elements\n";
+    return 1;
+  }
+
+  // create an array of primitives by types
+  Handle(Graphic3d_ArrayOfPrimitives) anArray;
+  if (anArrayType == "points")
+    anArray = new Graphic3d_ArrayOfPoints (aVertexNum);
+  else if (anArrayType == "segments")
+    anArray = new Graphic3d_ArrayOfSegments (aVertexNum, aEdgeNum, hasVColors);
+  else if (anArrayType == "polylines")
+    anArray = new Graphic3d_ArrayOfPolylines (aVertexNum, aBoundNum, aEdgeNum,
+                                              hasVColors, hasBColors, hasInfos);
+  else if (anArrayType == "triangles")
+    anArray = new Graphic3d_ArrayOfTriangles (aVertexNum, aEdgeNum, hasNormals,
+                                              hasVColors, hasTexels, hasInfos);
+  else if (anArrayType == "trianglefans")
+    anArray = new Graphic3d_ArrayOfTriangleFans (aVertexNum, aBoundNum,
+                                                 hasNormals, hasVColors,
+                                                 hasBColors, hasTexels);
+  else if (anArrayType == "trianglestrips")
+    anArray = new Graphic3d_ArrayOfTriangleStrips (aVertexNum, aBoundNum,
+                                                   hasNormals, hasVColors,
+                                                   hasBColors, hasTexels);
+  else if (anArrayType == "quads")
+    anArray = new Graphic3d_ArrayOfQuadrangles (aVertexNum, aEdgeNum,
+                                                hasNormals, hasVColors,
+                                                hasTexels, hasInfos);
+  else if (anArrayType == "quadstrips")
+    anArray = new Graphic3d_ArrayOfQuadrangleStrips (aVertexNum, aBoundNum,
+                                                     hasNormals, hasVColors,
+                                                     hasBColors, hasTexels);
+  else if (anArrayType == "polygons")
+    anArray = new Graphic3d_ArrayOfPolygons (aVertexNum, aBoundNum, aEdgeNum,
+                                             hasNormals, hasVColors, hasBColors,
+                                             hasTexels, hasInfos);
+  else
+  {
+    di << "Unexpected type of primitiives array\n";
+    return 1;
+  }
+
+  // parse an array of primitives
+  aArgIndex = (hasFlagVbo) ? 4 : 3;
+  while (aArgIndex < argc)
+  {
+    aCommand = argv[aArgIndex];
+    aCommand.LowerCase();
+    if (!aCommand.IsAscii())
+      break;
+
+    // vertex command
+    if (CheckInputCommand ("v", argv, aArgIndex, 3, argc))
+    {
+      anArray->AddVertex (atof (argv[aArgIndex - 3]),
+                          atof (argv[aArgIndex - 2]),
+                          atof (argv[aArgIndex - 1]));
+
+      // vertex has a normal or normal with color or texel
+      if (CheckInputCommand ("n", argv, aArgIndex, 3, argc))
+        anArray->SetVertexNormal (anArray->VertexNumber (),
+                                  atof (argv[aArgIndex - 3]),
+                                  atof (argv[aArgIndex - 2]),
+                                  atof (argv[aArgIndex - 1]));
+      
+      if (CheckInputCommand ("c", argv, aArgIndex, 3, argc))
+        anArray->SetVertexColor (anArray->VertexNumber (),
+                                 atof (argv[aArgIndex - 3]),
+                                 atof (argv[aArgIndex - 2]),
+                                 atof (argv[aArgIndex - 1]));
+      
+      if (CheckInputCommand ("t", argv, aArgIndex, 2, argc))
+        anArray->SetVertexTexel (anArray->VertexNumber (),
+                                 atof (argv[aArgIndex - 2]),
+                                 atof (argv[aArgIndex - 1]));
+    }
+    // bounds command
+    else if (CheckInputCommand ("b", argv, aArgIndex, 1, argc))
+    {
+      Standard_Integer aVertCount = atoi (argv[aArgIndex - 1]);
+
+      if (CheckInputCommand ("c", argv, aArgIndex, 3, argc))
+        anArray->AddBound (aVertCount,
+                           atof (argv[aArgIndex - 3]),
+                           atof (argv[aArgIndex - 2]),
+                           atof (argv[aArgIndex - 1]));
+
+      else
+        anArray->AddBound (aVertCount);
+    }
+    // edge command
+    else if (CheckInputCommand ("e", argv, aArgIndex, 1, argc))
+    {
+      Standard_Integer aVertIndex = atoi (argv[aArgIndex - 1]);
+
+      // edge has/hasn't hide flag
+      if (CheckInputCommand ("h", argv, aArgIndex, 0, argc))
+        anArray->AddEdge (aVertIndex, Standard_False);
+      else
+        anArray->AddEdge (aVertIndex, Standard_True);
+    }
+    // unknown command
+    else
+      aArgIndex++;
+  }
+
+  if (hasFlagVbo)
+  {
+    // enable / disable vbo
+    Handle(Graphic3d_GraphicDriver) aDriver =
+      Handle(Graphic3d_GraphicDriver)::DownCast (
+                      aContextAIS->CurrentViewer()->Device()->GraphicDriver());
+
+    if (!aDriver.IsNull())
+      aDriver->EnableVBO ((Standard_Boolean) atoi (argv[3]));
+  }
+
+  // create primitives array object
+  Handle (MyPArrayObject) aPObject = new MyPArrayObject (anArray);
+
+  // register the object in map
+  VDisplayAISObject (aName, aPObject);
+
+  return 0;
+}
+
 //=======================================================================
 //function : ObjectsCommands
 //purpose  :
@@ -2793,7 +3257,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     __FILE__,VCircleBuilder,group);
 
   theCommands.Add("vdrawtext",
-    "vdrawtext  : vdrawtext name X Y Z R G B hor_align ver_align angle zoomable height Aspect FONT ",
+    "vdrawtext  : vdrawtext name X Y Z R G B hor_align ver_align angle zoomable height Aspect [Font [isMultiByte]]",
     __FILE__,VDrawText,group);
 
   theCommands.Add("vdrawsphere",
@@ -2804,4 +3268,12 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     "vclipplane : vclipplane [x y z dx dy dz] [planeId {on/off/del/display/hide}]",
     __FILE__,VClipPlane,group);
 
+  theCommands.Add (
+    "vcomputehlr",
+    "vcomputehlr: shape hlrname [ eyex eyey eyez lookx looky lookz ]",
+    __FILE__, VComputeHLR, group);
+
+  theCommands.Add("vdrawparray",
+    "vdrawparray : vdrawparray Name TypeOfArray [EnableVbo=1] [vertex = { 'v' x y z [vertex_normal = { 'n' x y z }] [vertex_color = { 'c' r g b }] ] ... [bound = { 'b' vertex_count [bound_color = { 'c' r g b }] ] ... [edge = { 'e' vertex_id [edge_hidden = { 'h' }] ]",
+    __FILE__,VDrawPArray,group);
 }
diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx
index fe1cb33..e5d929a 100644
--- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx
+++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx
@@ -24,6 +24,8 @@
 #include <Draw_Interpretor.hxx>
 #include <Draw.hxx>
 #include <Draw_Appli.hxx>
+#include <Aspect_PrintAlgo.hxx>
+#include <Image_PixMap.hxx>
 
 #ifndef WNT
 #include <Graphic3d_GraphicDevice.hxx>
@@ -1651,54 +1653,240 @@ static int VColorScale (Draw_Interpretor& di, Standard_Integer argc, const char
 //function : VGraduatedTrihedron
 //purpose  : Displays a graduated trihedron
 //==============================================================================
+
+static void AddMultibyteString (TCollection_ExtendedString &name, const char *arg)
+{
+  const char *str = arg;
+  while (*str)
+  {
+    unsigned short c1 = *str++;
+    unsigned short c2 = *str++;
+    if (!c1 || !c2) break;
+    name += (Standard_ExtCharacter)((c1 << 8) | c2);
+  }
+}
+
 static int VGraduatedTrihedron(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
 {
-  Handle(V3d_View) V3dView = ViewerTest::CurrentView();
-  if (V3dView.IsNull())
-      return 1;
+  // Check arguments
+  if (argc != 2 && argc < 5)
+  {
+    di<<"Error: "<<argv[0]<<" - invalid number of arguments\n";
+    di<<"Usage: type help "<<argv[0]<<"\n";
+    return 1; //TCL_ERROR
+  }
 
-  if (argc < 2)
+  Handle(V3d_View) aV3dView = ViewerTest::CurrentView();
+
+  // Create 3D view if it doesn't exist
+  if ( aV3dView.IsNull() )
   {
-    di << argv[0] << " Invalid number of arguments" << "\n";
-    return 1;
+    ViewerTest::ViewerInit(); 
+    aV3dView = ViewerTest::CurrentView();
+    if( aV3dView.IsNull() )
+    {
+      di << "Error: Cannot create a 3D view\n";
+      return 1; //TCL_ERROR
+    }
   }
 
-  Standard_CString xname = "X (mm)";
-  Standard_CString yname = "Y (mm)";
-  Standard_CString zname = "Z (mm)";
+  // Erase (==0) or display (!=0)
+  const int display = atoi(argv[1]);
 
-  if (argc > 2)
+  if (display)
   {
-      if (argc != 5)
+    // Text font
+    TCollection_AsciiString font;
+    if (argc < 6)
+      font.AssignCat("Courier");
+    else
+      font.AssignCat(argv[5]);
+
+    // Text is multibyte
+    const Standard_Boolean isMultibyte = (argc < 7)? Standard_False : (atoi(argv[6]) != 0);
+
+    // Set axis names
+    TCollection_ExtendedString xname, yname, zname;
+    if (argc >= 5)
+    {
+      if (isMultibyte)
       {
-        di << argv[0] << " Define all X, Y and Z axes names, please" << "\n";
-        return 1;
+        AddMultibyteString(xname, argv[2]);
+        AddMultibyteString(yname, argv[3]);
+        AddMultibyteString(zname, argv[4]);
       }
-      xname = argv[2];
-      yname = argv[3];
-      zname = argv[4];
-  }
+      else
+      {
+        xname += argv[2];
+        yname += argv[3];
+        zname += argv[4];
+      }
+    }
+    else
+    {
+      xname += "X (mm)";
+      yname += "Y (mm)";
+      zname += "Z (mm)";
+    }
 
-  int display = atoi(argv[1]);
-  if (display)
-    V3dView->GraduatedTrihedronDisplay(xname, yname, zname,
-                                       Standard_True/*xdrawname*/, Standard_True/*ydrawname*/, Standard_True/*zdrawname*/,
-                                       Standard_True/*xdrawvalues*/, Standard_True/*ydrawvalues*/, Standard_True/*zdrawvalues*/,
-                                       Standard_True/*drawgrid*/,
-                                       Standard_True/*drawaxes*/,
-                                       5/*nbx*/, 5/*nby*/, 5/*nbz*/,
-                                       10/*xoffset*/, 10/*yoffset*/, 10/*zoffset*/,
-                                       30/*xaxisoffset*/, 30/*yaxisoffset*/, 30/*zaxisoffset*/,
-                                       Standard_True/*xdrawtickmarks*/, Standard_True/*ydrawtickmarks*/, Standard_True/*zdrawtickmarks*/,
-                                       10/*xtickmarklength*/, 10/*ytickmarklength*/, 10/*ztickmarklength*/);
+    aV3dView->GraduatedTrihedronDisplay(xname, yname, zname,
+                                        Standard_True/*xdrawname*/, Standard_True/*ydrawname*/, Standard_True/*zdrawname*/,
+                                        Standard_True/*xdrawvalues*/, Standard_True/*ydrawvalues*/, Standard_True/*zdrawvalues*/,
+                                        Standard_True/*drawgrid*/,
+                                        Standard_True/*drawaxes*/,
+                                        5/*nbx*/, 5/*nby*/, 5/*nbz*/,
+                                        10/*xoffset*/, 10/*yoffset*/, 10/*zoffset*/,
+                                        30/*xaxisoffset*/, 30/*yaxisoffset*/, 30/*zaxisoffset*/,
+                                        Standard_True/*xdrawtickmarks*/, Standard_True/*ydrawtickmarks*/, Standard_True/*zdrawtickmarks*/,
+                                        10/*xtickmarklength*/, 10/*ytickmarklength*/, 10/*ztickmarklength*/,
+                                        Quantity_NOC_WHITE/*gridcolor*/,
+                                        Quantity_NOC_RED/*xnamecolor*/,Quantity_NOC_GREEN/*ynamecolor*/,Quantity_NOC_BLUE1/*znamecolor*/,
+                                        Quantity_NOC_RED/*xcolor*/,Quantity_NOC_GREEN/*ycolor*/,Quantity_NOC_BLUE1/*zcolor*/,font);
+  }
   else
-    V3dView->GraduatedTrihedronErase();
+    aV3dView->GraduatedTrihedronErase();
 
   ViewerTest::GetAISContext()->UpdateCurrentViewer();
-  V3dView->Redraw();
+  aV3dView->Redraw();
+
   return 0;
 }
 
+//==============================================================================
+//function : VPrintView
+//purpose  : Test printing algorithm, print the view to image file with given
+//           width and height. Printing implemented only for WNT.
+//==============================================================================
+static int VPrintView (Draw_Interpretor& di, Standard_Integer argc, 
+                       const char** argv)
+{
+#ifndef WNT
+  di << "Printing implemented only for wnt!\n";
+  return 1;
+#else
+
+  Handle(AIS_InteractiveContext) aContextAIS = NULL;
+  Handle(V3d_View) aView = NULL;
+  aContextAIS = ViewerTest::GetAISContext();
+  if (!aContextAIS.IsNull())
+  {
+    const Handle(V3d_Viewer)& Vwr = aContextAIS->CurrentViewer();
+    Vwr->InitActiveViews();
+    if(Vwr->MoreActiveViews())
+      aView = Vwr->ActiveView();
+  }
+
+  // check for errors
+  if (aView.IsNull())
+  {
+    di << "Call vinit before!\n";
+    return 1;
+  }
+  else if (argc < 4)
+  {
+    di << "Use: " << argv[0];
+    di << " width height filename [print algo=0]\n";
+    di << "width, height of the intermediate buffer for operation\n";
+    di << "algo : {0|1}\n";
+    di << "        0 - stretch algorithm\n";
+    di << "        1 - tile algorithm\n";
+    di << "test printing algorithms into an intermediate buffer\n";
+    di << "with saving output to an image file\n";
+    return 1;
+  }
+
+  // get the input params
+  Standard_Integer aWidth  = atoi (argv[1]);
+  Standard_Integer aHeight = atoi (argv[2]);
+  Standard_Integer aMode   = 0;
+  TCollection_AsciiString aFileName = TCollection_AsciiString (argv[3]);
+  if (argc==5)
+    aMode = atoi (argv[4]);
+
+  // check the input parameters
+  if (aWidth <= 0 || aHeight <= 0)
+  {
+    di << "Width and height must be positive values!\n";
+    return 1;
+  }
+  if (aMode != 0 && aMode != 1)
+    aMode = 0;
+
+  Image_CRawBufferData aRawBuffer;
+  HDC anDC = CreateCompatibleDC(0);
+
+  // define compatible bitmap
+  BITMAPINFO aBitmapData;
+  memset (&aBitmapData, 0, sizeof (BITMAPINFOHEADER));
+  aBitmapData.bmiHeader.biSize          = sizeof (BITMAPINFOHEADER);
+  aBitmapData.bmiHeader.biWidth         = aWidth ;
+  aBitmapData.bmiHeader.biHeight        = aHeight;
+  aBitmapData.bmiHeader.biPlanes        = 1;
+  aBitmapData.bmiHeader.biBitCount      = 24;
+  aBitmapData.bmiHeader.biXPelsPerMeter = 0;
+  aBitmapData.bmiHeader.biYPelsPerMeter = 0;
+  aBitmapData.bmiHeader.biClrUsed       = 0;
+  aBitmapData.bmiHeader.biClrImportant  = 0;
+  aBitmapData.bmiHeader.biCompression   = BI_RGB;
+  aBitmapData.bmiHeader.biSizeImage     = 0;
+
+  // Create Device Independent Bitmap
+  HBITMAP aMemoryBitmap = CreateDIBSection (anDC, &aBitmapData, DIB_RGB_COLORS,
+                                            &aRawBuffer.dataPtr, NULL, 0);
+  HGDIOBJ anOldBitmap   = SelectObject(anDC, aMemoryBitmap);
+
+  Standard_Boolean isSaved = Standard_False, isPrinted = Standard_False;
+  if (aRawBuffer.dataPtr != 0)
+  {    
+    if (aMode == 0)
+      isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_STRETCH);
+    else
+      isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_TILE);
+
+    // succesfully printed into an intermediate buffer
+    if (isPrinted)
+    {
+      Handle(Image_PixMap) anImageBitmap =
+                         new Image_PixMap ((Standard_PByte)aRawBuffer.dataPtr,
+                                           aWidth, aHeight,
+                                           aWidth*3 + aWidth%4, 24, 0);
+      isSaved = anImageBitmap->Dump(aFileName.ToCString());
+    }
+    else
+    {
+      di << "Print operation failed due to printing errors or\n";
+      di << "insufficient memory available\n";
+      di << "Please, try to use smaller dimensions for this test\n";
+      di << "command, as it allocates intermediate buffer for storing\n";
+      di << "the result\n";
+    }
+  }
+  else
+  {
+    di << "Can't allocate memory for intermediate buffer\n";
+    di << "Please use smaller dimensions\n";
+  }
+
+  if (aMemoryBitmap)
+  {
+    SelectObject (anDC, anOldBitmap);
+    DeleteObject (aMemoryBitmap);
+    DeleteDC(anDC);
+  }
+
+  if (!isSaved)
+  {
+    di << "Save to file operation failed. This operation may fail\n";
+    di << "if you don't have enough available memory, then you can\n";
+    di << "use smaller dimensions for the output file\n";
+    return 1;
+  }
+
+  return 0;
+
+#endif
+}
+
 //=======================================================================
 //function : ViewerCommands
 //purpose  :
@@ -1763,6 +1951,10 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "vcolorscale     : vcolorscale [RangeMin = 0 RangeMax = 100 Intervals = 10 HeightFont = 16 Position = 2 X = 0 Y = 0]: draw color scale",
     __FILE__,VColorScale,group);
   theCommands.Add("vgraduatedtrihedron",
-    "vgraduatedtrihedron : 1/0 (display/erase) [Xname Yname Zname]",
+    "vgraduatedtrihedron : 1/0 (display/erase) [Xname Yname Zname [Font [isMultibyte]]]",
     __FILE__,VGraduatedTrihedron,group);
+  theCommands.Add("vprintview" ,
+    "vprintview : width height filename [algo=0] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile",
+    __FILE__,VPrintView,group);
+
 }
diff --git a/src/Visual3d/Visual3d_TransientManager.cxx b/src/Visual3d/Visual3d_TransientManager.cxx
index 3d56ed0..deabf50 100644
--- a/src/Visual3d/Visual3d_TransientManager.cxx
+++ b/src/Visual3d/Visual3d_TransientManager.cxx
@@ -78,6 +78,9 @@ return theCView;
 }
 #define theCView _theCView()
 
+static Aspect_CLayer2d UnderCLayer;
+static Aspect_CLayer2d OverCLayer;
+
 //
 //-Constructors
 //
@@ -113,17 +116,15 @@ Standard_Boolean Visual3d_TransientManager::BeginDraw (const Handle(Visual3d_Vie
 
 Handle(Visual3d_Layer) OverLayer = AView->OverLayer ();
 Handle(Visual3d_Layer) UnderLayer = AView->UnderLayer ();
-Aspect_CLayer2d OverCLayer;
-Aspect_CLayer2d UnderCLayer;
-	OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
+  OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
 	theCView	= *(CALL_DEF_VIEW *)AView->CView ();
 
 	if (! UnderLayer.IsNull ()){
-		UnderCLayer = UnderLayer->CLayer ();
+		UnderCLayer = UnderLayer->CLayer();
 		theCView.ptrUnderLayer = (CALL_DEF_LAYER *) &UnderCLayer;
 	}
 	if (! OverLayer.IsNull ()){
-		OverCLayer = OverLayer->CLayer ();
+		OverCLayer = OverLayer->CLayer();
 		theCView.ptrOverLayer = (CALL_DEF_LAYER *) &OverCLayer;
 	}
 
@@ -188,17 +189,14 @@ void Visual3d_TransientManager::ClearDraw (const Handle(Visual3d_View)& AView,
 
 	// Begin rendering
 	theCView	= *(CALL_DEF_VIEW *)AView->CView ();
-Aspect_CLayer2d OverCLayer;
-Aspect_CLayer2d UnderCLayer;
-	if (!AView->UnderLayer().IsNull()) {
-		UnderCLayer = AView->UnderLayer()->CLayer ();
-		theCView.ptrUnderLayer = (CALL_DEF_LAYER *)&UnderCLayer;
-	}
-	if (!AView->OverLayer().IsNull()) {
-		OverCLayer = AView->OverLayer()->CLayer();
-		theCView.ptrOverLayer = (CALL_DEF_LAYER *)&OverCLayer;
-	}
-
+  if (!AView->UnderLayer().IsNull()) {
+    UnderCLayer = AView->UnderLayer()->CLayer();
+    theCView.ptrUnderLayer = (CALL_DEF_LAYER *) &UnderCLayer;
+  }
+  if (!AView->OverLayer().IsNull()) {
+    OverCLayer = AView->OverLayer()->CLayer();
+    theCView.ptrOverLayer = (CALL_DEF_LAYER *) &OverCLayer;
+  }
 	Handle(Aspect_GraphicDriver) agd = AView->GraphicDriver ();
 
 	theGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
@@ -234,17 +232,14 @@ Standard_Boolean Visual3d_TransientManager::BeginAddDraw (const Handle(Visual3d_
 
 	// Begin rendering
 	theCView	= *(CALL_DEF_VIEW *)AView->CView ();
-Aspect_CLayer2d OverCLayer;
-Aspect_CLayer2d UnderCLayer;
-	if (!AView->UnderLayer().IsNull()) {
-		UnderCLayer = AView->UnderLayer()->CLayer ();
-		theCView.ptrUnderLayer = (CALL_DEF_LAYER *)&UnderCLayer;
-	}
-	if (!AView->OverLayer().IsNull()) {
-		OverCLayer = AView->OverLayer()->CLayer();
-		theCView.ptrOverLayer = (CALL_DEF_LAYER *)&OverCLayer;
-	}
-
+  if (!AView->UnderLayer().IsNull()) {
+    UnderCLayer = AView->UnderLayer()->CLayer();
+    theCView.ptrUnderLayer = (CALL_DEF_LAYER *) &UnderCLayer;
+  }
+  if (!AView->OverLayer().IsNull()) {
+    OverCLayer = AView->OverLayer()->CLayer();
+    theCView.ptrOverLayer = (CALL_DEF_LAYER *) &OverCLayer;
+  }
 	Handle(Aspect_GraphicDriver) agd = AView->GraphicDriver ();
 
 	theGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
diff --git a/src/Visual3d/Visual3d_View.cdl b/src/Visual3d/Visual3d_View.cdl
index a829e24..91ef918 100644
--- a/src/Visual3d/Visual3d_View.cdl
+++ b/src/Visual3d/Visual3d_View.cdl
@@ -74,6 +74,7 @@ uses
     RenderingContext        from Aspect,
     GraphicCallbackProc     from Aspect,
     ColorScale              from Aspect,
+    PrintAlgo               from Aspect,
 
     CRawBufferData          from Image,
 
@@ -106,7 +107,10 @@ uses
     ExportFormat            from Graphic3d,
     SortType                from Graphic3d,
     Color                   from Quantity,
-    FontAspect              from OSD
+    FontAspect              from OSD,
+    AsciiString             from TCollection,
+    ExtendedString          from TCollection,
+    CGraduatedTrihedron     from Graphic3d
 
 raises
     TransformError          from Visual3d,
@@ -591,129 +595,82 @@ is
 
     GetGraduatedTrihedron(me;
                           -- Names of axes --
-                          xname : out CString from Standard;
-                          yname : out CString from Standard;
-                          zname : out CString from Standard;
+                          xname, yname, zname : out ExtendedString from TCollection;
                           -- Draw names --
-                          xdrawname : out Boolean from Standard;
-                          ydrawname : out Boolean from Standard;
-                          zdrawname : out Boolean from Standard;
+                          xdrawname, ydrawname, zdrawname : out Boolean from Standard;
                           -- Draw values --
-                          xdrawvalues : out Boolean from Standard;
-                          ydrawvalues : out Boolean from Standard;
-                          zdrawvalues : out Boolean from Standard;
+                          xdrawvalues, ydrawvalues, zdrawvalues : out Boolean from Standard;
                           -- Draw grid --
                           drawgrid : out Boolean from Standard;
                           -- Draw axes --
                           drawaxes : out Boolean from Standard;
                           -- Number of splits along axes --
-                          nbx : out Integer from Standard;
-                          nby : out Integer from Standard;
-                          nbz : out Integer from Standard;
+                          nbx, nby, nbz : out Integer from Standard;
                           -- Offset for drawing values --
-                          xoffset : out Integer from Standard;
-                          yoffset : out Integer from Standard;
-                          zoffset : out Integer from Standard;
+                          xoffset, yoffset, zoffset : out Integer from Standard;
                           -- Offset for drawing names of axes --
-                          xaxisoffset : out Integer from Standard;
-                          yaxisoffset : out Integer from Standard;
-                          zaxisoffset : out Integer from Standard;
+                          xaxisoffset, yaxisoffset, zaxisoffset : out Integer from Standard;
                           -- Draw tickmarks --
-                          xdrawtickmarks : out Boolean from Standard;
-                          ydrawtickmarks : out Boolean from Standard;
-                          zdrawtickmarks : out Boolean from Standard;
+                          xdrawtickmarks, ydrawtickmarks, zdrawtickmarks : out Boolean from Standard;
                           -- Length of tickmarks --
-                          xtickmarklength : out Integer from Standard;
-                          ytickmarklength : out Integer from Standard;
-                          ztickmarklength : out Integer from Standard;
+                          xtickmarklength, ytickmarklength, ztickmarklength : out Integer from Standard;
                           -- Grid color --
                           gridcolor : out Color from Quantity;
-                          -- X name color --
-                          xnamecolor : out Color from Quantity;
-                          -- Y name color --
-                          ynamecolor : out Color from Quantity;
-                          -- Z name color --
-                          znamecolor : out Color from Quantity;
-                          -- X color of axis and values --
-                          xcolor : out Color from Quantity;
-                          -- Y color of axis and values --
-                          ycolor : out Color from Quantity;
-                          -- Z color of axis and values --
-                          zcolor : out Color from Quantity;
+                          -- Colors of axis names --
+                          xnamecolor, ynamecolor, znamecolor : out Color from Quantity;
+                          -- Colors of axis and values --
+                          xcolor, ycolor, zcolor : out Color from Quantity;
                           -- Name of font for names of axes --
-                          fontOfNames : out CString from Standard;
+                          fontOfNames : out AsciiString from TCollection;
                           -- Style of names of axes --
                           styleOfNames : out FontAspect from OSD;
                           -- Size of names of axes --
                           sizeOfNames : out Integer from Standard;
                           -- Name of font for values --
-                          fontOfValues : out CString from Standard;
+                          fontOfValues : out AsciiString from TCollection;
                           -- Style of values --
                           styleOfValues : out FontAspect from OSD;
                           -- Size of values --
                           sizeOfValues : out Integer from Standard)
-    ---Purpose: Returns data of a graduated trihedron.
+    returns Boolean from Standard
     is static;
+    ---Purpose: Returns data of a graduated trihedron if displayed (return value is True)
 
     GraduatedTrihedronDisplay(me : mutable;
                               -- Names of axes --
-                              xname : CString from Standard;
-                              yname : CString from Standard;
-                              zname : CString from Standard;
+                              xname, yname, zname : ExtendedString from TCollection;
                               -- Draw names --
-                              xdrawname : Boolean from Standard;
-                              ydrawname : Boolean from Standard;
-                              zdrawname : Boolean from Standard;
+                              xdrawname, ydrawname, zdrawname : Boolean from Standard;
                               -- Draw values --
-                              xdrawvalues : Boolean from Standard;
-                              ydrawvalues : Boolean from Standard;
-                              zdrawvalues : Boolean from Standard;
+                              xdrawvalues, ydrawvalues, zdrawvalues : Boolean from Standard;
                               -- Draw grid --
                               drawgrid : Boolean from Standard;
                               -- Draw axes --
                               drawaxes : Boolean from Standard;
                               -- Number of splits along axes --
-                              nbx : Integer from Standard;
-                              nby : Integer from Standard;
-                              nbz : Integer from Standard;
+                              nbx, nby, nbz : Integer from Standard;
                               -- Offset for drawing values --
-                              xoffset : Integer from Standard;
-                              yoffset : Integer from Standard;
-                              zoffset : Integer from Standard;
+                              xoffset, yoffset, zoffset : Integer from Standard;
                               -- Offset for drawing names of axes --
-                              xaxisoffset : Integer from Standard;
-                              yaxisoffset : Integer from Standard;
-                              zaxisoffset : Integer from Standard;
+                              xaxisoffset, yaxisoffset, zaxisoffset : Integer from Standard;
                               -- Draw tickmarks --
-                              xdrawtickmarks : Boolean from Standard;
-                              ydrawtickmarks : Boolean from Standard;
-                              zdrawtickmarks : Boolean from Standard;
+                              xdrawtickmarks, ydrawtickmarks, zdrawtickmarks : Boolean from Standard;
                               -- Length of tickmarks --
-                              xtickmarklength : Integer from Standard;
-                              ytickmarklength : Integer from Standard;
-                              ztickmarklength : Integer from Standard;
+                              xtickmarklength, ytickmarklength, ztickmarklength : Integer from Standard;
                               -- Grid color --
                               gridcolor : Color from Quantity;
-                              -- X name color --
-                              xnamecolor : Color from Quantity;
-                              -- Y name color --
-                              ynamecolor : Color from Quantity;
-                              -- Z name color --
-                              znamecolor : Color from Quantity;
-                              -- X color of axis and values --
-                              xcolor : Color from Quantity;
-                              -- Y color of axis and values --
-                              ycolor : Color from Quantity;
-                              -- Z color of axis and values --
-                              zcolor : Color from Quantity;
+                              -- Colors of axis names --
+                              xnamecolor, ynamecolor, znamecolor : Color from Quantity;
+                              -- Colors of axis and values --
+                              xcolor, ycolor, zcolor : Color from Quantity;
                               -- Name of font for names of axes --
-                              fontOfNames : CString from Standard;
+                              fontOfNames : AsciiString from TCollection;
                               -- Style of names of axes --
                               styleOfNames : FontAspect from OSD;
                               -- Size of names of axes --
                               sizeOfNames : Integer from Standard;
                               -- Name of font for values --
-                              fontOfValues : CString from Standard;
+                              fontOfValues : AsciiString from TCollection;
                               -- Style of values --
                               styleOfValues : FontAspect from OSD;
                               -- Size of values --
@@ -1119,12 +1076,14 @@ is
 	--	    displayed in <me>.
 	---Category: Private methods
 
-	  Print (me; AnUnderLayer	: Layer from Visual3d;
-		 	 AnOverLayer	: Layer from Visual3d;
-			 hPrnDC: Handle from Aspect;
-			 showBackground: Boolean;
-			 filename: CString)
-	  is static;
+	  Print (me; AnUnderLayer : Layer from Visual3d;
+		 AnOverLayer	  : Layer from Visual3d;
+		 hPrnDC           : Handle from Aspect;
+		 showBackground   : Boolean;
+		 filename         : CString;
+		 printAlgorithm   : PrintAlgo from Aspect = Aspect_PA_STRETCH;
+                 theScaleFactor   : Real from Standard = 1.0)
+	  returns Boolean from Standard is static;
 
       	---Level: Internal
       	---Purpose: print the contents of all layers of the view to the printer.
@@ -1133,12 +1092,21 @@ is
 	-- (background is white)
       	-- else set to TRUE for printing with current background color.
 	-- <filename>: If != NULL, then the view will be printed to a file.
+	-- <printAlgo>: Select print algorithm: stretch, tile.
+        -- <theScaleFactor>: Scaling coefficient, used internally to scale the
+        -- printings accordingly to the scale factor selected in the printer 
+        -- properties dialog.
+        -- Returns Standard_True if the data is passed to the printer, otherwise
+        -- Standard_False if the print operation failed due to printer error
+        -- or insufficient memory.
 	--  Warning: Works only under Windows.
 
-	  Print (me; hPrnDC: Handle from Aspect;
-			 showBackground: Boolean;
-			 filename: CString)
-	  is static;
+	  Print (me; hPrnDC     : Handle from Aspect;
+		 showBackground : Boolean;
+		 filename       : CString;
+		 printAlgorithm : PrintAlgo from Aspect = Aspect_PA_STRETCH;
+                 theScaleFactor : Real from Standard = 1.0 )
+	  returns Boolean from Standard is static;
 
       	---Level: Internal
       	---Purpose: print the contents of the view to printer.
@@ -1147,6 +1115,13 @@ is
 	-- (background is white)
       	-- else set to TRUE for printing with current background color.
 	-- <filename>: If != NULL, then the view will be printed to a file.
+	-- <printAlgo>: Select print algorithm: stretch, tile.
+        -- <theScaleFactor>: Scaling coefficient, used internally to scale the
+        -- printings accordingly to the scale factor selected in the printer 
+        -- properties dialog.
+        -- Returns Standard_True if the data is passed to the printer, otherwise
+        -- Standard_False if the print operation failed due to printer error
+        -- or insufficient memory.
 	--  Warning: Works only under Windows.
 
 	SetTransparency ( me : mutable;
@@ -1327,6 +1302,8 @@ fields
 	-- Booleans
 	MyCBitFields		:	CBitFields8 from Graphic3d;
 
+	MyGTrihedron        :   CGraduatedTrihedron from Graphic3d;
+
 friends
 
 	class ViewManager from Visual3d
diff --git a/src/Visual3d/Visual3d_View.cxx b/src/Visual3d/Visual3d_View.cxx
index c46d010..7a4d44f 100644
--- a/src/Visual3d/Visual3d_View.cxx
+++ b/src/Visual3d/Visual3d_View.cxx
@@ -3672,268 +3672,258 @@ void SetMinMaxValuesCallback(void* Visual3dView)
     }
 }
 
-void Visual3d_View::GetGraduatedTrihedron(/* Names of axes */
-                                          Standard_CString& xname,
-                                          Standard_CString& yname,
-                                          Standard_CString& zname,
-                                          /* Draw names */
-                                          Standard_Boolean& xdrawname,
-                                          Standard_Boolean& ydrawname,
-                                          Standard_Boolean& zdrawname,
-                                          /* Draw values */
-                                          Standard_Boolean& xdrawvalues,
-                                          Standard_Boolean& ydrawvalues,
-                                          Standard_Boolean& zdrawvalues,
-                                          /* Draw grid */
-                                          Standard_Boolean& drawgrid,
-                                          /* Draw axes */
-                                          Standard_Boolean& drawaxes,
-                                          /* Number of splits along axes */
-                                          Standard_Integer& nbx,
-                                          Standard_Integer& nby,
-                                          Standard_Integer& nbz,
-                                          /* Offset for drawing values */
-                                          Standard_Integer& xoffset,
-                                          Standard_Integer& yoffset,
-                                          Standard_Integer& zoffset,
-                                          /* Offset for drawing names of axes */
-                                          Standard_Integer& xaxisoffset,
-                                          Standard_Integer& yaxisoffset,
-                                          Standard_Integer& zaxisoffset,
-                                          /* Draw tickmarks */
-                                          Standard_Boolean& xdrawtickmarks,
-                                          Standard_Boolean& ydrawtickmarks,
-                                          Standard_Boolean& zdrawtickmarks,
-                                          /* Length of tickmarks */
-                                          Standard_Integer& xtickmarklength,
-                                          Standard_Integer& ytickmarklength,
-                                          Standard_Integer& ztickmarklength,
-                                          /* Grid color */
-                                          Quantity_Color& gridcolor,
-                                          /* X name color */
-                                          Quantity_Color& xnamecolor,
-                                          /* Y name color */
-                                          Quantity_Color& ynamecolor,
-                                          /* Z name color */
-                                          Quantity_Color& znamecolor,
-                                          /* X color of axis and values */
-                                          Quantity_Color& xcolor,
-                                          /* Y color of axis and values */
-                                          Quantity_Color& ycolor,
-                                          /* Z color of axis and values */
-                                          Quantity_Color& zcolor,
-                                          /* Name of font for names of axes */
-                                          Standard_CString& fontOfNames,
-                                          /* Style of names of axes */
-                                          OSD_FontAspect& styleOfNames,
-                                          /* Size of names of axes */
-                                          Standard_Integer& sizeOfNames,
-                                          /* Name of font for values */
-                                          Standard_CString& fontOfValues,
-                                          /* Style of values */
-                                          OSD_FontAspect& styleOfValues,
-                                          /* Size of values */
-                                          Standard_Integer& sizeOfValues) const
+Standard_Boolean Visual3d_View::GetGraduatedTrihedron
+    (/* Names of axes */
+     TCollection_ExtendedString& xname,
+     TCollection_ExtendedString& yname,
+     TCollection_ExtendedString& zname,
+     /* Draw names */
+     Standard_Boolean& xdrawname,
+     Standard_Boolean& ydrawname,
+     Standard_Boolean& zdrawname,
+     /* Draw values */
+     Standard_Boolean& xdrawvalues,
+     Standard_Boolean& ydrawvalues,
+     Standard_Boolean& zdrawvalues,
+     /* Draw grid */
+     Standard_Boolean& drawgrid,
+     /* Draw axes */
+     Standard_Boolean& drawaxes,
+     /* Number of splits along axes */
+     Standard_Integer& nbx,
+     Standard_Integer& nby,
+     Standard_Integer& nbz,
+     /* Offset for drawing values */
+     Standard_Integer& xoffset,
+     Standard_Integer& yoffset,
+     Standard_Integer& zoffset,
+     /* Offset for drawing names of axes */
+     Standard_Integer& xaxisoffset,
+     Standard_Integer& yaxisoffset,
+     Standard_Integer& zaxisoffset,
+     /* Draw tickmarks */
+     Standard_Boolean& xdrawtickmarks,
+     Standard_Boolean& ydrawtickmarks,
+     Standard_Boolean& zdrawtickmarks,
+     /* Length of tickmarks */
+     Standard_Integer& xtickmarklength,
+     Standard_Integer& ytickmarklength,
+     Standard_Integer& ztickmarklength,
+     /* Grid color */
+     Quantity_Color& gridcolor,
+     /* Colors of axis names */
+     Quantity_Color& xnamecolor,
+     Quantity_Color& ynamecolor,
+     Quantity_Color& znamecolor,
+     /* Colors of axis and values */
+     Quantity_Color& xcolor,
+     Quantity_Color& ycolor,
+     Quantity_Color& zcolor,
+     /* Name of font for names of axes */
+     TCollection_AsciiString& fontOfNames,
+     /* Style of names of axes */
+     OSD_FontAspect& styleOfNames,
+     /* Size of names of axes */
+     Standard_Integer& sizeOfNames,
+     /* Name of font for values */
+     TCollection_AsciiString& fontOfValues,
+     /* Style of values */
+     OSD_FontAspect& styleOfValues,
+     /* Size of values */
+     Standard_Integer& sizeOfValues) const
 {
-    MyGraphicDriver->GetGraduatedTrihedron(MyCView,
-                                           /* Names of axes */
-                                           xname,
-                                           yname,
-                                           zname,
-                                           /* Draw names */
-                                           xdrawname,
-                                           ydrawname,
-                                           zdrawname,
-                                           /* Draw values */
-                                           xdrawvalues,
-                                           ydrawvalues,
-                                           zdrawvalues,
-                                           /* Draw grid */
-                                           drawgrid,
-                                           /* Draw axes */
-                                           drawaxes,
-                                           /* Number of splits along axes */
-                                           nbx,
-                                           nby,
-                                           nbz,
-                                           /* Offset for drawing values */
-                                           xoffset,
-                                           yoffset,
-                                           zoffset,
-                                           /* Offset for drawing names of axes */
-                                           xaxisoffset,
-                                           yaxisoffset,
-                                           zaxisoffset,
-                                           /* Draw tickmarks */
-                                           xdrawtickmarks,
-                                           ydrawtickmarks,
-                                           zdrawtickmarks,
-                                           /* Length of tickmarks */
-                                           xtickmarklength,
-                                           ytickmarklength,
-                                           ztickmarklength,
-                                           /* Grid color */
-                                           gridcolor,
-                                           /* X name color */
-                                           xnamecolor,
-                                           /* Y name color */
-                                           ynamecolor,
-                                           /* Z name color */
-                                           znamecolor,
-                                           /* X color of axis and values */
-                                           xcolor,
-                                           /* Y color of axis and values */
-                                           ycolor,
-                                           /* Z color of axis and values */
-                                           zcolor,
-                                           /* Name of font for names of axes */
-                                           fontOfNames,
-                                           /* Style of names of axes */
-                                           styleOfNames,
-                                           /* Size of names of axes */
-                                           sizeOfNames,
-                                           /* Name of font for values */
-                                           fontOfValues,
-                                           /* Style of values */
-                                           styleOfValues,
-                                           /* Size of values */
-                                           sizeOfValues);
+    if (!MyGTrihedron.ptrVisual3dView)
+        return Standard_False;
+
+    /* Names of axes */
+    xname = MyGTrihedron.xname;
+    yname = MyGTrihedron.yname; 
+    zname = MyGTrihedron.zname;
+    /* Draw names */
+    xdrawname = MyGTrihedron.xdrawname; 
+    ydrawname = MyGTrihedron.ydrawname; 
+    zdrawname = MyGTrihedron.zdrawname;
+    /* Draw values */
+    xdrawvalues = MyGTrihedron.xdrawvalues; 
+    ydrawvalues = MyGTrihedron.ydrawvalues; 
+    zdrawvalues = MyGTrihedron.zdrawvalues;
+    /* Draw grid */
+    drawgrid = MyGTrihedron.drawgrid;
+    /* Draw axes */
+    drawaxes = MyGTrihedron.drawaxes;
+    /* Number of splits along axes */
+    nbx = MyGTrihedron.nbx;
+    nby = MyGTrihedron.nby;
+    nbz = MyGTrihedron.nbz;
+    /* Offset for drawing values */
+    xoffset = MyGTrihedron.xoffset;
+    yoffset = MyGTrihedron.yoffset;
+    zoffset = MyGTrihedron.zoffset;
+    /* Offset for drawing names of axes */
+    xaxisoffset = MyGTrihedron.xaxisoffset;
+    yaxisoffset = MyGTrihedron.yaxisoffset;
+    zaxisoffset = MyGTrihedron.zaxisoffset;
+    /* Draw tickmarks */
+    xdrawtickmarks = MyGTrihedron.xdrawtickmarks;
+    ydrawtickmarks = MyGTrihedron.ydrawtickmarks;
+    zdrawtickmarks = MyGTrihedron.zdrawtickmarks;
+    /* Length of tickmarks */
+    xtickmarklength = MyGTrihedron.xtickmarklength;
+    ytickmarklength = MyGTrihedron.ytickmarklength;
+    ztickmarklength = MyGTrihedron.ztickmarklength;
+    /* Grid color */
+    gridcolor = MyGTrihedron.gridcolor;
+    /* Colors of axis names */
+    xnamecolor = MyGTrihedron.xnamecolor;
+    ynamecolor = MyGTrihedron.ynamecolor;
+    znamecolor = MyGTrihedron.znamecolor;
+    /* Colors of axis and values */
+    xcolor = MyGTrihedron.xcolor;
+    ycolor = MyGTrihedron.ycolor;
+    zcolor = MyGTrihedron.zcolor;
+    /* Name of font for names of axes */
+    fontOfNames = MyGTrihedron.fontOfNames;
+    /* Style of names of axes */
+    styleOfNames = MyGTrihedron.styleOfNames;
+    /* Size of names of axes */
+    sizeOfNames = MyGTrihedron.sizeOfNames;
+    /* Name of font for values */
+    fontOfValues = MyGTrihedron.fontOfValues;
+    /* Style of values */
+    styleOfValues = MyGTrihedron.styleOfValues;
+    /* Size of values */
+    sizeOfValues = MyGTrihedron.sizeOfValues;
+
+    return Standard_True;
 }
 
-void Visual3d_View::GraduatedTrihedronDisplay(/* Names of axes */
-                                              const Standard_CString xname,
-                                              const Standard_CString yname,
-                                              const Standard_CString zname,
-                                              /* Draw names */
-                                              const Standard_Boolean xdrawname,
-                                              const Standard_Boolean ydrawname,
-                                              const Standard_Boolean zdrawname,
-                                              /* Draw values */
-                                              const Standard_Boolean xdrawvalues,
-                                              const Standard_Boolean ydrawvalues,
-                                              const Standard_Boolean zdrawvalues,
-                                              /* Draw grid */
-                                              const Standard_Boolean drawgrid,
-                                              /* Draw axes */
-                                              const Standard_Boolean drawaxes,
-                                              /* Number of splits along axes */
-                                              const Standard_Integer nbx,
-                                              const Standard_Integer nby,
-                                              const Standard_Integer nbz,
-                                              /* Offset for drawing values */
-                                              const Standard_Integer xoffset,
-                                              const Standard_Integer yoffset,
-                                              const Standard_Integer zoffset,
-                                              /* Offset for drawing names of axes */
-                                              const Standard_Integer xaxisoffset,
-                                              const Standard_Integer yaxisoffset,
-                                              const Standard_Integer zaxisoffset,
-                                              /* Draw tickmarks */
-                                              const Standard_Boolean xdrawtickmarks,
-                                              const Standard_Boolean ydrawtickmarks,
-                                              const Standard_Boolean zdrawtickmarks,
-                                              /* Length of tickmarks */
-                                              const Standard_Integer xtickmarklength,
-                                              const Standard_Integer ytickmarklength,
-                                              const Standard_Integer ztickmarklength,
-                                              /* Grid color */
-                                              const Quantity_Color& gridcolor,
-                                              /* X name color */
-                                              const Quantity_Color& xnamecolor,
-                                              /* Y name color */
-                                              const Quantity_Color& ynamecolor,
-                                              /* Z name color */
-                                              const Quantity_Color& znamecolor,
-                                              /* X color of axis and values */
-                                              const Quantity_Color& xcolor,
-                                              /* Y color of axis and values */
-                                              const Quantity_Color& ycolor,
-                                              /* Z color of axis and values */
-                                              const Quantity_Color& zcolor,
-                                              /* Name of font for names of axes */
-                                              const Standard_CString fontOfNames,
-                                              /* Style of names of axes */
-                                              const OSD_FontAspect styleOfNames,
-                                              /* Size of names of axes */
-                                              const Standard_Integer sizeOfNames,
-                                              /* Name of font for values */
-                                              const Standard_CString fontOfValues,
-                                              /* Style of values */
-                                              const OSD_FontAspect styleOfValues,
-                                              /* Size of values */
-                                              const Standard_Integer sizeOfValues)
+void Visual3d_View::GraduatedTrihedronDisplay
+    (/* Names of axes */
+     const TCollection_ExtendedString &xname,
+     const TCollection_ExtendedString &yname,
+     const TCollection_ExtendedString &zname,
+     /* Draw names */
+     const Standard_Boolean xdrawname,
+     const Standard_Boolean ydrawname,
+     const Standard_Boolean zdrawname,
+     /* Draw values */
+     const Standard_Boolean xdrawvalues,
+     const Standard_Boolean ydrawvalues,
+     const Standard_Boolean zdrawvalues,
+     /* Draw grid */
+     const Standard_Boolean drawgrid,
+     /* Draw axes */
+     const Standard_Boolean drawaxes,
+     /* Number of splits along axes */
+     const Standard_Integer nbx,
+     const Standard_Integer nby,
+     const Standard_Integer nbz,
+     /* Offset for drawing values */
+     const Standard_Integer xoffset,
+     const Standard_Integer yoffset,
+     const Standard_Integer zoffset,
+     /* Offset for drawing names of axes */
+     const Standard_Integer xaxisoffset,
+     const Standard_Integer yaxisoffset,
+     const Standard_Integer zaxisoffset,
+     /* Draw tickmarks */
+     const Standard_Boolean xdrawtickmarks,
+     const Standard_Boolean ydrawtickmarks,
+     const Standard_Boolean zdrawtickmarks,
+     /* Length of tickmarks */
+     const Standard_Integer xtickmarklength,
+     const Standard_Integer ytickmarklength,
+     const Standard_Integer ztickmarklength,
+     /* Grid color */
+     const Quantity_Color& gridcolor,
+     /* Colors of axis names */
+     const Quantity_Color& xnamecolor,
+     const Quantity_Color& ynamecolor,
+     const Quantity_Color& znamecolor,
+     /* Colors of axis and values */
+     const Quantity_Color& xcolor,
+     const Quantity_Color& ycolor,
+     const Quantity_Color& zcolor,
+     /* Name of font for names of axes */
+     const TCollection_AsciiString &fontOfNames,
+     /* Style of names of axes */
+     const OSD_FontAspect styleOfNames,
+     /* Size of names of axes */
+     const Standard_Integer sizeOfNames,
+     /* Name of font for values */
+     const TCollection_AsciiString &fontOfValues,
+     /* Style of values */
+     const OSD_FontAspect styleOfValues,
+     /* Size of values */
+     const Standard_Integer sizeOfValues)
 {
-    CALL_DEF_GRADUATEDTRIHEDRON cubic;
-    cubic.ptrVisual3dView = this;
-    cubic.cbCubicAxes = SetMinMaxValuesCallback;
-    MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,
-                                               cubic,
-                                               /* Names of axes */
-                                               xname,
-                                               yname,
-                                               zname,
-                                               /* Draw names */
-                                               xdrawname,
-                                               ydrawname,
-                                               zdrawname,
-                                               /* Draw values */
-                                               xdrawvalues,
-                                               ydrawvalues,
-                                               zdrawvalues,
-                                               /* Draw grid */
-                                               drawgrid,
-                                               /* Draw axes */
-                                               drawaxes,
-                                               /* Number of splits along axes */
-                                               nbx,
-                                               nby,
-                                               nbz,
-                                               /* Offset for drawing values */
-                                               xoffset,
-                                               yoffset,
-                                               zoffset,
-                                               /* Offset for drawing names of axes */
-                                               xaxisoffset,
-                                               yaxisoffset,
-                                               zaxisoffset,
-                                               /* Draw tickmarks */
-                                               xdrawtickmarks,
-                                               ydrawtickmarks,
-                                               zdrawtickmarks,
-                                               /* Length of tickmarks */
-                                               xtickmarklength,
-                                               ytickmarklength,
-                                               ztickmarklength,
-                                               /* Grid color */
-                                               gridcolor,
-                                               /* X name color */
-                                               xnamecolor,
-                                               /* Y name color */
-                                               ynamecolor,
-                                               /* Z name color */
-                                               znamecolor,
-                                               /* X color of axis and values */
-                                               xcolor,
-                                               /* Y color of axis and values */
-                                               ycolor,
-                                               /* Z color of axis and values */
-                                               zcolor,
-                                               /* Name of font for names of axes */
-                                               fontOfNames,
-                                               /* Style of names of axes */
-                                               styleOfNames,
-                                               /* Size of names of axes */
-                                               sizeOfNames,
-                                               /* Name of font for values */
-                                               fontOfValues,
-                                               /* Style of values */
-                                               styleOfValues,
-                                               /* Size of values */
-                                               sizeOfValues);
+    /* Names of axes */
+    MyGTrihedron.xname = xname;
+    MyGTrihedron.yname = yname;
+    MyGTrihedron.zname = zname;
+    /* Draw names */
+    MyGTrihedron.xdrawname = xdrawname;
+    MyGTrihedron.ydrawname = ydrawname;
+    MyGTrihedron.zdrawname = zdrawname;
+    /* Draw values */
+    MyGTrihedron.xdrawvalues = xdrawvalues;
+    MyGTrihedron.ydrawvalues = ydrawvalues;
+    MyGTrihedron.zdrawvalues = zdrawvalues;
+    /* Draw grid */
+    MyGTrihedron.drawgrid = drawgrid;
+    /* Draw axes */
+    MyGTrihedron.drawaxes = drawaxes;
+    /* Number of splits along axes */
+    MyGTrihedron.nbx = nbx;
+    MyGTrihedron.nby = nby;
+    MyGTrihedron.nbz = nbz;
+    /* Offset for drawing values */
+    MyGTrihedron.xoffset = xoffset;
+    MyGTrihedron.yoffset = yoffset;
+    MyGTrihedron.zoffset = zoffset;
+    /* Offset for drawing names of axes */
+    MyGTrihedron.xaxisoffset = xaxisoffset;
+    MyGTrihedron.yaxisoffset = yaxisoffset;
+    MyGTrihedron.zaxisoffset = zaxisoffset;
+    /* Draw tickmarks */
+    MyGTrihedron.xdrawtickmarks = xdrawtickmarks;
+    MyGTrihedron.ydrawtickmarks = ydrawtickmarks;
+    MyGTrihedron.zdrawtickmarks = zdrawtickmarks;
+    /* Length of tickmarks */
+    MyGTrihedron.xtickmarklength = xtickmarklength;
+    MyGTrihedron.ytickmarklength = ytickmarklength;
+    MyGTrihedron.ztickmarklength = ztickmarklength;
+    /* Grid color */
+    MyGTrihedron.gridcolor = gridcolor;
+    /* Colors of axis names */
+    MyGTrihedron.xnamecolor = xnamecolor;
+    MyGTrihedron.ynamecolor = ynamecolor;
+    MyGTrihedron.znamecolor = znamecolor;
+    /* Colors of axis and values */
+    MyGTrihedron.xcolor = xcolor;
+    MyGTrihedron.ycolor = ycolor;
+    MyGTrihedron.zcolor = zcolor;
+    /* Name of font for names of axes */
+    MyGTrihedron.fontOfNames = fontOfNames;
+    /* Style of names of axes */
+    MyGTrihedron.styleOfNames = styleOfNames;
+    /* Size of names of axes */
+    MyGTrihedron.sizeOfNames = sizeOfNames;
+    /* Name of font for values */
+    MyGTrihedron.fontOfValues = fontOfValues;
+    /* Style of values */
+    MyGTrihedron.styleOfValues = styleOfValues;
+    /* Size of values */
+    MyGTrihedron.sizeOfValues = sizeOfValues;
+
+    MyGTrihedron.ptrVisual3dView = this;
+    MyGTrihedron.cbCubicAxes = SetMinMaxValuesCallback;
+    MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,MyGTrihedron);
 }
 
 void Visual3d_View::GraduatedTrihedronErase()
 {
+    MyGTrihedron.ptrVisual3dView = NULL;
     MyGraphicDriver->GraduatedTrihedronErase(MyCView);
 }
 
diff --git a/src/Visual3d/Visual3d_View_Print.cxx b/src/Visual3d/Visual3d_View_Print.cxx
index 8b775df..796ea68 100644
--- a/src/Visual3d/Visual3d_View_Print.cxx
+++ b/src/Visual3d/Visual3d_View_Print.cxx
@@ -14,28 +14,34 @@
 /* Print Methods                                                        */
 /************************************************************************/
 
-void Visual3d_View::Print (const Aspect_Handle    hPrintDC, 
-                           const Standard_Boolean showBackground, 
-                           const Standard_CString filename) const
+Standard_Boolean Visual3d_View::Print
+  (const Aspect_Handle    hPrintDC, 
+   const Standard_Boolean showBackground,
+   const Standard_CString filename,
+   const Aspect_PrintAlgo printAlgorithm,
+   const Standard_Real    theScaleFactor) const
 {
-  Print (MyViewManager->UnderLayer (), 
-         MyViewManager->OverLayer (), 
-         hPrintDC, 
-         showBackground, 
-         filename);
+  return Print (MyViewManager->UnderLayer (),
+                MyViewManager->OverLayer (),
+                hPrintDC, showBackground,
+                filename, printAlgorithm, 
+                theScaleFactor);
 }
 
-void Visual3d_View::Print (const Handle(Visual3d_Layer)& AnUnderLayer, 
-                           const Handle(Visual3d_Layer)& AnOverLayer,
-                           const Aspect_Handle           hPrintDC,
-                           const Standard_Boolean        showBackground,
-                           const Standard_CString        aFilename) const
+Standard_Boolean Visual3d_View::Print
+  (const Handle(Visual3d_Layer)& AnUnderLayer,
+   const Handle(Visual3d_Layer)& AnOverLayer,
+   const Aspect_Handle           hPrintDC,
+   const Standard_Boolean        showBackground,
+   const Standard_CString        aFilename,
+   const Aspect_PrintAlgo        printAlgorithm,
+   const Standard_Real           theScaleFactor) const
 {
-  if (IsDeleted ()) return;
+  if (IsDeleted ()) return Standard_False;
 
-  if ((! IsDefined ()) || (! IsActive ())) return;
+  if ((! IsDefined ()) || (! IsActive ())) return Standard_False;
 
-  if (! MyWindow->IsMapped ()) return;
+  if (! MyWindow->IsMapped ()) return Standard_False;
 
   Aspect_CLayer2d OverCLayer;
   Aspect_CLayer2d UnderCLayer;
@@ -44,6 +50,7 @@ void Visual3d_View::Print (const Handle(Visual3d_Layer)& AnUnderLayer,
   if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
   if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
 
-  MyGraphicDriver->Print (MyCView, UnderCLayer, OverCLayer,
-                          hPrintDC, showBackground, aFilename);
+  return MyGraphicDriver->Print (MyCView, UnderCLayer, OverCLayer,
+                                 hPrintDC, showBackground, aFilename,
+                                 printAlgorithm, theScaleFactor);
 }
diff --git a/src/XCAFApp/XCAFApp_Application.cdl b/src/XCAFApp/XCAFApp_Application.cdl
index af53e60..be2f5d8 100644
--- a/src/XCAFApp/XCAFApp_Application.cdl
+++ b/src/XCAFApp/XCAFApp_Application.cdl
@@ -15,7 +15,7 @@ uses
 
 is
 
-    Create returns mutable Application from XCAFApp is private;
+    Create returns mutable Application from XCAFApp is protected;
 
 
     ---Purpose: methods from CDF_Application
diff --git a/src/XCAFDoc/XCAFDoc_ShapeTool.cxx b/src/XCAFDoc/XCAFDoc_ShapeTool.cxx
index b017488..13cc47d 100644
--- a/src/XCAFDoc/XCAFDoc_ShapeTool.cxx
+++ b/src/XCAFDoc/XCAFDoc_ShapeTool.cxx
@@ -978,17 +978,17 @@ void XCAFDoc_ShapeTool::UpdateAssembly (const TDF_Label& L) const
 //purpose  : 
 //=======================================================================
 
-static Standard_Boolean CheckSubShape (const TopoDS_Shape &S, const TopoDS_Shape &sub)
-{
-  if ( S.IsSame ( sub ) ) return Standard_True;
-  
-  if ( S.ShapeType() >= sub.ShapeType() ) return Standard_False;
-  
-  for ( TopoDS_Iterator it(S); it.More(); it.Next() ) {
-    if ( CheckSubShape ( it.Value(), sub ) ) return Standard_True;
-  }
-  return Standard_False;
-}
+//static Standard_Boolean CheckSubShape (const TopoDS_Shape &S, const TopoDS_Shape &sub)
+//{
+//  if ( S.IsSame ( sub ) ) return Standard_True;
+//  
+//  if ( S.ShapeType() >= sub.ShapeType() ) return Standard_False;
+//  
+//  for ( TopoDS_Iterator it(S); it.More(); it.Next() ) {
+//    if ( CheckSubShape ( it.Value(), sub ) ) return Standard_True;
+//  }
+//  return Standard_False;
+//}
 
 //=======================================================================
 //function : IsSubShape
diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx
index b4e130e..932e385 100644
--- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx
+++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx
@@ -24,6 +24,7 @@
 #include <AIS_InteractiveContext.hxx>
 #include <ViewerTest.hxx>
 #include <Draw.hxx>
+#include <Draw_ProgressIndicator.hxx>
 #include <RWStl.hxx>
 #include <Quantity_Color.hxx>
 #include <V3d_View.hxx>
@@ -119,7 +120,7 @@ static Standard_Integer writevrml
 
 //=======================================================================
 //function : loadvrml
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 static Standard_Integer loadvrml
@@ -185,7 +186,7 @@ static Standard_Integer loadvrml
 
 //=======================================================================
 //function : storevrml
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 static Standard_Integer storevrml
@@ -216,7 +217,7 @@ static Standard_Integer storevrml
     filebuf foc;
     ostream outStream (&foc);
     if (foc.open (argv[2], ios::out))
-      outStream << aScene;       
+      outStream << aScene;
   }
   return 0;
 }
@@ -233,9 +234,10 @@ static Standard_Integer createmesh
     return 1;
   }
 
+  // Progress indicator
   OSD_Path aFile( argv[2] );
-  Handle( StlMesh_Mesh ) aSTLMesh = RWStl::ReadFile( aFile );
-  //  DBRep::Set(argv[1],shape);
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di, 1);
+  Handle(StlMesh_Mesh) aSTLMesh = RWStl::ReadFile (aFile, aProgress);
 
   di << "Reading OK..." << "\n";
   Handle( XSDRAWSTLVRML_DataSource ) aDS = new XSDRAWSTLVRML_DataSource( aSTLMesh );
@@ -267,7 +269,7 @@ static Standard_Integer createmesh
 
   if ( aContext.IsNull() )
   {
-    ViewerTest::ViewerInit(); 
+    ViewerTest::ViewerInit();
     //To create a 3D view if it doesn't exist
     aContext = ViewerTest::GetAISContext();
     if( aContext.IsNull() )
@@ -616,9 +618,9 @@ static Standard_Integer showonly
     di << "The context is null" << "\n";
   else
   {
-    Handle(TColStd_HPackedMapOfInteger) aHiddenNodes = 
+    Handle(TColStd_HPackedMapOfInteger) aHiddenNodes =
       new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllNodes());
-    Handle(TColStd_HPackedMapOfInteger) aHiddenElements = 
+    Handle(TColStd_HPackedMapOfInteger) aHiddenElements =
       new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllElements());
     for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
     {
@@ -705,8 +707,8 @@ static Standard_Integer delmesh
 }
 //-----------------------------------------------------------------------------
 
-static Standard_Integer meshcolors( Draw_Interpretor& di, 
-                                    Standard_Integer argc, 
+static Standard_Integer meshcolors( Draw_Interpretor& di,
+                                    Standard_Integer argc,
                                     const char** argv )
 {
   try
@@ -720,9 +722,9 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
         di << "       elem2 - one color for one side"<<"\n";
         di << "       nodal - different color for each node"<< "\n";
         di << "       nodaltex - different color for each node with texture interpolation"<< "\n";
-        di << "       none  - clear"<< "\n"; 
+        di << "       none  - clear"<< "\n";
         di << "isreflect : {0|1} "<< "\n";
-         
+
         return 0;
       }
 
@@ -761,7 +763,7 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
 
           if( aMode.IsEqual("elem1") || aMode.IsEqual("elem2") )
           {
-            Handle(MeshVS_ElementalColorPrsBuilder) aBuilder = new MeshVS_ElementalColorPrsBuilder( 
+            Handle(MeshVS_ElementalColorPrsBuilder) aBuilder = new MeshVS_ElementalColorPrsBuilder(
                 aMesh, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask );
               // Color
             const TColStd_PackedMapOfInteger& anAllElements = aMesh->GetDataSource()->GetAllElements();
@@ -780,10 +782,10 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
             aMesh->AddBuilder( aBuilder, Standard_True );
           }
 
-          
+
           if( aMode.IsEqual("nodal") )
           {
-            Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder( 
+            Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
                 aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask );
             aMesh->AddBuilder( aBuilder, Standard_True );
 
@@ -793,7 +795,7 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
             TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllNodes );
             for ( ; anIter.More(); anIter.Next() )
             {
-              Quantity_Color aColor( (Quantity_NameOfColor)( 
+              Quantity_Color aColor( (Quantity_NameOfColor)(
                 anIter.Key() % Quantity_NOC_WHITE ) );
               aBuilder->SetColor( anIter.Key(), aColor );
             }
@@ -803,7 +805,7 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
           if(aMode.IsEqual("nodaltex"))
           {
             // assign nodal builder to the mesh
-            Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder( 
+            Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
                    aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask);
             aMesh->AddBuilder(aBuilder, Standard_True);
             aBuilder->UseTexture(Standard_True);
@@ -846,7 +848,7 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
                 aScaleValue = 0;
               }
 
-              aScaleMap.Bind(anIter.Key(), aScaleValue); 
+              aScaleMap.Bind(anIter.Key(), aScaleValue);
             }
 
             //set color map for builder and a color for invalid scale value
@@ -854,7 +856,7 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
             aBuilder->SetInvalidColor(Quantity_NOC_BLACK);
             aBuilder->SetTextureCoords(aScaleMap);
             aMesh->AddBuilder(aBuilder, Standard_True);
-			
+
             //set viewer to display texures
             const Handle(V3d_Viewer)& aViewer = anIC->CurrentViewer();
             for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
@@ -866,7 +868,7 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
           anIC->Redisplay( aMesh );
         }
         else
-        { 
+        {
           di << "Wrong mode name" << "\n";
           return 0;
         }
@@ -881,8 +883,8 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
 }
 //-----------------------------------------------------------------------------
 
-static Standard_Integer mesh_edge_width( Draw_Interpretor& di, 
-                                        Standard_Integer argc, 
+static Standard_Integer mesh_edge_width( Draw_Interpretor& di,
+                                        Standard_Integer argc,
                                         const char** argv )
 {
   try
diff --git a/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cdl b/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cdl
index 271bed5..2bea5a7 100644
--- a/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cdl
+++ b/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cdl
@@ -45,8 +45,6 @@ is
     AddNamespace      (me:mutable; thePrefix, theURI: AsciiString)
 	is protected;
 
-    IsError	      (me) returns Boolean from Standard;
-
     AttributeDrivers  (me : mutable; theMsgDriver: MessageDriver from CDM)
 	returns ADriverTable from XmlMDF
 	is virtual; 
@@ -60,6 +58,5 @@ fields
     mySeqOfNS	:	SequenceOfNamespaceDef	 from XmlLDrivers;
     myCopyright :       ExtendedString           from TCollection;
     myRelocTable:	SRelocationTable	 from XmlObjMgt  is protected;
-    myIsError   :	Boolean			 from Standard is protected;
 
 end DocumentStorageDriver;
diff --git a/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx b/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx
index 0074945..7489646 100644
--- a/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx
+++ b/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx
@@ -120,7 +120,7 @@ void XmlLDrivers_DocumentStorageDriver::Write
       ::take_time (0, " +++++ Fin formatting to XML : ", aMessageDriver);
 
     }else{
-      myIsError = Standard_True;
+      SetIsError (Standard_True);
       TCollection_ExtendedString aMsg =
         TCollection_ExtendedString("Error: the file ") + aFileName +
           " cannot be opened for writing";
@@ -143,7 +143,7 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument
                                    XmlObjMgt_Element&           theElement,
 				   const TCollection_ExtendedString& theFileName)
 {
-  myIsError = Standard_False;
+  SetIsError(Standard_False);
   Handle(CDM_MessageDriver) aMessageDriver =
     theDocument -> Application() -> MessageDriver();
   // 1. Write header information
@@ -294,13 +294,13 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument
     }
     catch (Standard_Failure)
     {
-      myIsError = Standard_True;
+      SetIsError (Standard_True);
       TCollection_ExtendedString anErrorString (Standard_Failure::Caught()->GetMessageString());
       aMessageDriver -> Write (anErrorString.ToExtString());
     }
   }
-  if (anObjNb <= 0 && myIsError == Standard_False) {
-    myIsError = Standard_True;
+  if (anObjNb <= 0 && IsError() == Standard_False) {
+    SetIsError (Standard_True);
     TCollection_ExtendedString anErrorString ("error occurred");
     aMessageDriver -> Write (anErrorString.ToExtString());
   }
@@ -316,7 +316,7 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument
   // 4. Write Shapes section
   if(WriteShapeSection(theElement))
     ::take_time (0, " +++ Fin DOM data for Shapes : ", aMessageDriver);
-  return myIsError;
+  return IsError();
 }
 
 //=======================================================================
@@ -359,16 +359,6 @@ Standard_Integer XmlLDrivers_DocumentStorageDriver::MakeDocument
 }
 
 //=======================================================================
-//function : IsError
-//purpose  : 
-//=======================================================================
-
-Standard_Boolean XmlLDrivers_DocumentStorageDriver::IsError () const
-{
-  return myIsError;
-}
-
-//=======================================================================
 //function : AttributeDrivers
 //purpose  : 
 //=======================================================================

-- 
OCE packaging



More information about the debian-science-commits mailing list