1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

Compare commits

..

1 Commits

Author SHA1 Message Date
nbv
a7276a9474 0025950: Bad performance of intersection algorithm.
1. Test case has been created.

2. Minor correction in DrawTrSurf.cxx file.
2018-11-06 18:10:53 +03:00
473 changed files with 5754 additions and 18732 deletions

View File

@@ -62,7 +62,6 @@ if (WIN32)
set (CSF_advapi32 "advapi32.lib")
set (CSF_gdi32 "gdi32.lib")
set (CSF_user32 "user32.lib")
set (CSF_shell32 "shell32.lib")
set (CSF_wsock32 "wsock32.lib")
set (CSF_psapi "psapi.lib")
set (CSF_d3d9 "D3D9.lib")

View File

@@ -1263,16 +1263,12 @@ proc wokUtils:FILES:FileToString { fin } {
# List extensions of compilable files in OCCT
proc osutils:compilable {thePlatform} {
if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } { return [list .c .cxx .cpp .mm] }
if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
return [list .c .cxx .cpp .mm]
}
return [list .c .cxx .cpp]
}
# List extensions of header file in OCCT
proc osutils:fileExtensionsHeaders {thePlatform} {
if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } { return [list .h .hxx .hpp .lxx .pxx .gxx ] }
return [list .h .hxx .hpp .lxx .pxx .gxx .mm ]
}
proc osutils:commonUsedTK { theToolKit } {
set anUsedToolKits [list]
set aDepToolkits [LibToLink $theToolKit]
@@ -1345,7 +1341,6 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
set aLibsMap(CSF_advapi32) "advapi32"
set aLibsMap(CSF_gdi32) "gdi32"
set aLibsMap(CSF_user32) "user32 comdlg32"
set aLibsMap(CSF_shell32) "shell32"
set aLibsMap(CSF_opengl32) "opengl32"
set aLibsMap(CSF_wsock32) "wsock32"
set aLibsMap(CSF_netapi32) "netapi32"
@@ -1470,7 +1465,8 @@ proc osutils:tk:units { tkloc } {
}
proc osutils:justwnt { listloc } {
set goaway [list Xw]
# ImageUtility is required for support for old (<6.5.4) versions of OCCT
set goaway [list Xdps Xw ImageUtility WOKUnix]
return [osutils:juststation $goaway $listloc]
}
@@ -1560,28 +1556,31 @@ proc wokUtils:FILES:wtail { f n } {
}
# Generate entry for one source file in Visual Studio 10 project file
proc osutils:vcxproj:cxxfile { theFile theParams } {
if { $theParams == "" } {
return " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\" />\n"
proc osutils:vcxproj:file { file params } {
append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
if { $params != "" } {
append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
}
if { $params != "" } {
append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
}
if { $params != "" } {
append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
}
if { $params != "" } {
append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
}
set aParams [string trim ${theParams}]
append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
append text " </ClCompile>\n"
return $text
}
# Generate entry for one header file in Visual Studio 10 project file
proc osutils:vcxproj:hxxfile { theFile } { return " <ClInclude Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\" />\n" }
# Generate Visual Studio 2010 project filters file
proc osutils:vcxproj:filters { dir proj theCxxFilesMap theHxxFilesMap } {
upvar $theCxxFilesMap aCxxFilesMap
upvar $theHxxFilesMap aHxxFilesMap
proc osutils:vcxproj:filters { dir proj theFilesMap } {
upvar $theFilesMap aFilesMap
# header
append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
@@ -1592,25 +1591,17 @@ proc osutils:vcxproj:filters { dir proj theCxxFilesMap theHxxFilesMap } {
append text " <Filter Include=\"Source files\">\n"
append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
append text " </Filter>\n"
append text " <Filter Include=\"Header files\">\n"
append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
append text " </Filter>\n"
foreach unit $aCxxFilesMap(units) {
foreach unit $aFilesMap(units) {
append text " <Filter Include=\"Source files\\${unit}\">\n"
append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
append text " </Filter>\n"
}
foreach unit $aHxxFilesMap(units) {
append text " <Filter Include=\"Header files\\${unit}\">\n"
append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
append text " </Filter>\n"
}
append text " </ItemGroup>\n"
# list of cxx files
# list of files
append text " <ItemGroup>\n"
foreach unit $aCxxFilesMap(units) {
foreach file $aCxxFilesMap($unit) {
foreach unit $aFilesMap(units) {
foreach file $aFilesMap($unit) {
append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
append text " <Filter>Source files\\${unit}</Filter>\n"
append text " </ClCompile>\n"
@@ -1618,19 +1609,51 @@ proc osutils:vcxproj:filters { dir proj theCxxFilesMap theHxxFilesMap } {
}
append text " </ItemGroup>\n"
# list of hxx files
# end
append text "</Project>"
# write file
set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
fconfigure $fp -translation crlf
puts $fp $text
close $fp
return ${proj}.vcxproj.filters
}
# Generate Visual Studio 2011 project filters file
proc osutils:vcx1proj:filters { dir proj theFilesMap } {
upvar $theFilesMap aFilesMap
# header
append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
# list of "filters" (units)
append text " <ItemGroup>\n"
foreach unit $aHxxFilesMap(units) {
foreach file $aHxxFilesMap($unit) {
append text " <ClInclude Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
append text " <Filter>Header files\\${unit}</Filter>\n"
append text " </ClInclude>\n"
append text " <Filter Include=\"Source files\">\n"
append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
append text " </Filter>\n"
foreach unit $aFilesMap(units) {
append text " <Filter Include=\"Source files\\${unit}\">\n"
append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
append text " </Filter>\n"
}
append text " </ItemGroup>\n"
# list of files
append text " <ItemGroup>\n"
foreach unit $aFilesMap(units) {
foreach file $aFilesMap($unit) {
append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
append text " <Filter>Source files\\${unit}</Filter>\n"
append text " </ClCompile>\n"
}
}
append text " </ItemGroup>\n"
append text " <ItemGroup>\n"
append text " <ResourceCompile Include=\"${proj}.rc\" />\n"
append text " <ResourceCompile Include=\"${proj}.rc\" />"
append text " </ItemGroup>\n"
# end
@@ -1703,9 +1726,9 @@ proc osutils:vcproj { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
set anIncPaths "..\\..\\..\\inc"
# set aTKDefines ""
set aFilesSection ""
set aVcFilesCxx(units) ""
set aVcFilesHxx(units) ""
set aVcFilesX(units) ""
set listloc [osutils:tk:units $theToolKit]
set resultloc [osutils:justwnt $listloc]
if [array exists written] { unset written }
#puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
#puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
@@ -1714,10 +1737,9 @@ proc osutils:vcproj { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
set fxloparamfc [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
set fxloparam ""
foreach fxlo $listloc {
foreach fxlo $resultloc {
set xlo $fxlo
set aSrcFiles [osutils:tk:cxxfiles $xlo wnt]
set aHxxFiles [osutils:tk:hxxfiles $xlo wnt]
set aSrcFiles [osutils:tk:files $xlo wnt]
set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
if {$fxlo_cmplrs_options_cxx == ""} {
set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
@@ -1746,22 +1768,12 @@ proc osutils:vcproj { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
foreach aSrcFile [lsort $aSrcFiles] {
if { ![info exists written([file tail $aSrcFile])] } {
set written([file tail $aSrcFile]) 1
append aFilesSection [osutils:vcxproj:cxxfile $aSrcFile $needparam]
append aFilesSection [osutils:vcxproj:file $aSrcFile $needparam]
} else {
puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
}
if { ! [info exists aVcFilesCxx($xlo)] } { lappend aVcFilesCxx(units) $xlo }
lappend aVcFilesCxx($xlo) $aSrcFile
}
foreach aHxxFile [lsort $aHxxFiles] {
if { ![info exists written([file tail $aHxxFile])] } {
set written([file tail $aHxxFile]) 1
append aFilesSection [osutils:vcxproj:hxxfile $aHxxFile]
} else {
puts "Warning : in vcproj more than one occurences for [file tail $aHxxFile]"
}
if { ! [info exists aVcFilesHxx($xlo)] } { lappend aVcFilesHxx(units) $xlo }
lappend aVcFilesHxx($xlo) $aHxxFile
if { ! [info exists aVcFilesX($xlo)] } { lappend aVcFilesX(units) $xlo }
lappend aVcFilesX($xlo) $aSrcFile
}
} else {
append aFilesSection "\t\t\t<Filter\n"
@@ -1777,9 +1789,15 @@ proc osutils:vcproj { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
}
append aFilesSection "\t\t\t</Filter>\n"
}
# macros
# append aTKDefines ";__${xlo}_DLL"
# common includes
# append anIncPaths ";..\\..\\..\\src\\${xlo}"
}
regsub -all -- {__TKINC__} $theProjTmpl $anIncPaths theProjTmpl
# regsub -all -- {__TKDEFS__} $theProjTmpl $aTKDefines theProjTmpl
regsub -all -- {__FILES__} $theProjTmpl $aFilesSection theProjTmpl
# write file
@@ -1789,8 +1807,12 @@ proc osutils:vcproj { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
close $aFile
# write filters file for vc10+
if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesCxx aVcFilesHxx]
if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" || "$theVcVer" == "vc9" } {
# nothing
} elseif { "$theVcVer" == "vc10" } {
lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesX]
} else {
lappend aVcFiles [osutils:vcx1proj:filters $theOutDir $theToolKit aVcFilesX]
}
# write resource file
@@ -1822,14 +1844,16 @@ proc osutils:tk:loadunit { loc map } {
return
}
# Returns the list of all files name in a toolkit within specified list of file extensions.
proc osutils:tk:files { tkloc theExtensions } {
# Returns the list of all compilable files name in a toolkit, or devunit of any type
# Tfiles lists for each unit the type of file that can be compiled.
proc osutils:tk:files { tkloc thePlatform } {
set Tfiles(source,nocdlpack) {source pubinclude}
set Tfiles(source,toolkit) {}
set Tfiles(source,executable) {source pubinclude}
set listloc [concat [osutils:tk:units $tkloc] $tkloc]
#puts " listloc = $listloc"
set l_comp [osutils:compilable $thePlatform]
set resultloc $listloc
set lret {}
foreach loc $resultloc {
@@ -1854,7 +1878,7 @@ proc osutils:tk:files { tkloc theExtensions } {
#puts $type
foreach f $map($type) {
#puts $f
if { [lsearch $theExtensions [file extension $f]] != -1 } {
if { [lsearch $l_comp [file extension $f]] != -1 } {
lappend lret $f
}
}
@@ -1863,16 +1887,10 @@ proc osutils:tk:files { tkloc theExtensions } {
return $lret
}
# Returns the list of all compilable files name in a toolkit.
proc osutils:tk:cxxfiles { tkloc thePlatform } { return [osutils:tk:files $tkloc [osutils:compilable $thePlatform]] }
# Returns the list of all header files name in a toolkit.
proc osutils:tk:hxxfiles { tkloc thePlatform } { return [osutils:tk:files $tkloc [osutils:fileExtensionsHeaders $thePlatform]] }
# Generate Visual Studio project file for executable
proc osutils:vcprojx { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
set aVcFiles {}
foreach f [osutils:tk:cxxfiles $theToolKit wnt] {
foreach f [osutils:tk:files $theToolKit wnt] {
set aProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 1]
set aProjName [file rootname [file tail $f]]
@@ -1907,16 +1925,15 @@ proc osutils:vcprojx { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
regsub -all -- {__TKDEP__} $aProjTmpl $aUsedLibs aProjTmpl
set aFilesSection ""
set aVcFilesCxx(units) ""
set aVcFilesHxx(units) ""
set aVcFilesX(units) ""
if { ![info exists written([file tail $f])] } {
set written([file tail $f]) 1
if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
append aFilesSection [osutils:vcxproj:cxxfile $f ""]
if { ! [info exists aVcFilesCxx($theToolKit)] } { lappend aVcFilesCxx(units) $theToolKit }
lappend aVcFilesCxx($theToolKit) $f
append aFilesSection [osutils:vcxproj:file $f ""]
if { ! [info exists aVcFilesX($theToolKit)] } { lappend aVcFilesX(units) $theToolKit }
lappend aVcFilesX($theToolKit) $f
} else {
append aFilesSection "\t\t\t<Filter\n"
append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
@@ -1928,8 +1945,10 @@ proc osutils:vcprojx { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
puts "Warning : in vcproj there are than one occurences for [file tail $f]"
}
#puts "$aProjTmpl $aFilesSection"
# set aTKDefines ";__${theToolKit}_DLL"
set anIncPaths "..\\..\\..\\inc"
regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
# regsub -all -- {__TKDEFS__} $aProjTmpl $aTKDefines aProjTmpl
regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
@@ -1945,12 +1964,9 @@ proc osutils:vcprojx { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
# write filters file for vc10
if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesCxx aVcFilesHxx]
lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesX]
}
# write resource file
lappend aVcFiles [osutils:readtemplate:rc $theOutDir $aProjName]
set aCommonSettingsFileTmpl ""
if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
# nothing
@@ -2133,7 +2149,7 @@ proc osutils:cbptk { theCmpl theOutDir theToolKit thePlatform} {
if [array exists written] { unset written }
foreach fxlo $resultloc {
set xlo $fxlo
set aSrcFiles [osutils:tk:cxxfiles $xlo $thePlatform]
set aSrcFiles [osutils:tk:files $xlo $thePlatform]
foreach aSrcFile [lsort $aSrcFiles] {
if { ![info exists written([file tail $aSrcFile])] } {
set written([file tail $aSrcFile]) 1
@@ -2227,7 +2243,7 @@ proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
set aWokArch "$::env(ARCH)"
set aCbpFiles {}
foreach aSrcFile [osutils:tk:cxxfiles $theToolKit $thePlatform] {
foreach aSrcFile [osutils:tk:files $theToolKit $thePlatform] {
# collect list of referred libraries to link with
set aUsedLibs [list]
set aFrameworks [list]
@@ -2666,7 +2682,7 @@ proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection
set aDepToolkits [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
if { "$theTargetType" == "executable" } {
set aFile [osutils:tk:cxxfiles $theToolKit mac]
set aFile [osutils:tk:files $theToolKit mac]
set aProjName [file rootname [file tail $aFile]]
set aDepToolkits [LibToLinkX $theToolKit $aProjName]
}
@@ -2732,7 +2748,7 @@ proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGro
set aGuidsMap($aPackage) [OS:genGUID "xcd"]
}
set aSrcFiles [osutils:tk:cxxfiles $xlo mac]
set aSrcFiles [osutils:tk:files $xlo mac]
foreach aSrcFile [lsort $aSrcFiles] {
set aFileExt "sourcecode.cpp.cpp"

View File

@@ -110,7 +110,7 @@
<PreprocessorDefinitions>NDEBUG;No_Exception;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP__;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\..\..\..\win32\__VCVER__\bin\__TKNAM__.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win32\__VCVER__\lib;$(CSF_OPT_LIB32);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@@ -159,7 +159,7 @@
<PreprocessorDefinitions>_DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP__;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\..\..\..\win32\__VCVER__\bind\__TKNAM__.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win32\__VCVER__\libd;$(CSF_OPT_LIB32D);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@@ -206,7 +206,7 @@
<PreprocessorDefinitions>NDEBUG;No_Exception;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP__;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\..\..\..\win64\__VCVER__\bin\__TKNAM__.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win64\__VCVER__\lib;$(CSF_OPT_LIB64);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@@ -255,7 +255,7 @@
<PreprocessorDefinitions>_DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP__;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\..\..\..\win64\__VCVER__\bind\__TKNAM__.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win64\__VCVER__\libd;$(CSF_OPT_LIB64D);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

View File

@@ -103,7 +103,7 @@
<PreprocessorDefinitions>NDEBUG;No_Exception;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP__;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win32\__VCVER__\lib;$(CSF_OPT_LIB32);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>__VCReleasePDB__</GenerateDebugInformation>
@@ -149,7 +149,7 @@
<PreprocessorDefinitions>_DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP__;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win32\__VCVER__\libd;$(CSF_OPT_LIB32D);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -193,7 +193,7 @@
<PreprocessorDefinitions>NDEBUG;No_Exception;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP__;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win64\__VCVER__\lib;$(CSF_OPT_LIB64);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>__VCReleasePDB__</GenerateDebugInformation>
@@ -238,7 +238,7 @@
<PreprocessorDefinitions>_DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP__;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win64\__VCVER__\libd;$(CSF_OPT_LIB64D);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -248,11 +248,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
__FILES__
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="__XQTNAM__.rc" />
</ItemGroup>
__FILES__ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@@ -1672,9 +1672,3 @@ Standard_Boolean meshing_new()
return !aStatus;
}
~~~~
@subsection upgrade_740_chamfer Changes in API of Chamfer algorithms
Some public methods of the class BRepFilletAPI_MakeChamfer are released from excess arguments:
- method Add for symmetric chamfer now takes only 2 arguments: distance and edge;
- method GetDistAngle now takes only 3 arguments: index of contour, distance and angle.

View File

@@ -5860,8 +5860,6 @@ The following topics are covered in the eight sections of this chapter:
* Topological operations, or booleans.
* Drafting and blending.
* Defeaturing.
* Making shapes periodic in 3D space.
* Making shapes connected.
* Analysis of shapes.
@@ -7193,160 +7191,6 @@ parallel - enables the parallel processing mode.
~~~~
@subsection occt_draw_makeperiodic 3D Model Periodicity
Draw module for @ref occt_modalg_makeperiodic "making the shape periodic" includes the following commands:
* **makeperiodic** - makes the shape periodic in required directions;
* **repeatshape** - repeats the periodic shape in requested periodic direction;
* **periodictwins** - returns the periodic twins for the shape;
* **clearrepetitions** - clears all previous repetitions of the periodic shape.
@subsubsection occt_draw_makeperiodic_makeperiodic makeperiodic
The command makes the shape periodic in the required directions with the required period.
If trimming is given it trims the shape to fit the requested period.
Syntax:
~~~~
makeperiodic result shape [-x/y/z period [-trim first]]
Where:
result - resulting periodic shape;
shape - input shape to make it periodic:
-x/y/z period - option to make the shape periodic in X, Y or Z direction with the given period;
-trim first - option to trim the shape to fit the required period, starting the period in first.
~~~~
@subsubsection occt_draw_makeperiodic_repeatshape repeatshape
The command repeats the periodic shape in periodic direction requested number of time.
The result contains the all the repeated shapes glued together.
The command should be called after **makeperiodic** command.
Syntax:
~~~~
repeatshape result -x/y/z times
Where:
result - resulting shape;
-x/y/z times - direction for repetition and number of repetitions (negative number of times means the repetition in negative direction).
~~~~
@subsubsection occt_draw_makeperiodic_periodictwins periodictwins
For the given shape the command returns the identical shapes located on the opposite sides of the periodic direction.
All periodic twins should have the same geometry.
The command should be called after **makeperiodic** command.
Syntax:
~~~~
periodictwins twins shape
Where:
twins - periodic twins for the given shape
shape - shape to find the twins for
~~~~
@subsubsection occt_draw_makeperiodic_clearrepetitions clearrepetitions
The command clears all previous repetitions of the periodic shape allowing to start the repetitions over.
No arguments are needed for the command.
@subsection occt_draw_makeconnected Making the touching shapes connected
Draw module for @ref occt_modalg_makeconnected "making the touching same-dimensional shapes connected" includes the following commands:
* **makeconnected** - make the input shapes connected or glued, performs material associations;
* **cmaterialson** - returns the materials located on the requested side of a shape;
* **cmakeperiodic** - makes the connected shape periodic in requested directions;
* **crepeatshape** - repeats the periodic connected shape in requested directions requested number of times;
* **cperiodictwins** - returns all periodic twins for the shape;
* **cclearrepetitions** - clears all previous repetitions of the periodic shape, keeping the shape periodic.
@subsubsection occt_draw_makeconnected_makeconnected makeconnected
The command makes the input touching shapes connected.
Syntax:
~~~~
makeconnected result shape1 shape2 ...
Where:
result - resulting connected shape.
shape1 shape2 ... - shapes to be made connected.
~~~~
@subsubsection occt_draw_makeconnected_cmaterialson cmaterialson
The command returns the materials located on the requested side of the shape.
The command should be called after the shapes have been made connected, i.e. after the command **makeconnected**.
Syntax:
~~~~
cmaterialson result +/- shape
Where:
result - material shapes
shape - shape for which the materials are needed
+/- - side of a given shape ('+' for positive side, '-' - for negative).
~~~~
@subsubsection occt_draw_makeconnected_cmakeperiodic cmakeperiodic
The command makes the connected shape periodic in the required directions with the required period.
The command should be called after the shapes have been made connected, i.e. after the command **makeconnected**.
Syntax:
~~~~
cmakeperiodic result [-x/y/z period [-trim first]]
Where:
result - resulting periodic shape;
shape - input shape to make it periodic:
-x/y/z period - option to make the shape periodic in X, Y or Z direction with the given period;
-trim first - option to trim the shape to fit the required period, starting the period in first.
~~~~
@subsubsection occt_draw_makeconnected_crepeatshape crepeatshape
The command repeats the connected periodic shape in the required periodic directions required number of times.
The command should be called after the shapes have been made connected and periodic, i.e. after the commands **makeconnected** and **cmakeperiodic**.
Syntax:
~~~~
crepeatshape result -x/y/z times
Where:
result - resulting shape;
-x/y/z times - direction for repetition and number of repetitions (negative number of times means the repetition in negative direction).
~~~~
@subsubsection occt_draw_makeconnected_cperiodictwins cperiodictwins
The command returns all periodic twins for the shape.
The command should be called after the shapes have been made connected and periodic, i.e. after the commands **makeconnected** and **cmakeperiodic**.
Syntax:
~~~~
cperiodictwins twins shape
Where:
twins - periodic twins of a shape.
shape - input shape.
~~~~
@subsubsection occt_draw_makeconnected_cclearrepetitions cclearrepetitions
The command clears all previous repetitions of the periodic shape keeping the shape periodic.
The command should be called after the shapes have been made connected, periodic and the repetitions have been applied to the periodic shape, i.e. after the commands **makeconnected**, **cmakeperiodic** and **crepeatshape**.
Otherwise the command will have no effect.
Syntax:
~~~~
cclearrepetitions [result]
~~~~
@subsection occt_draw_7_9 Analysis of topology and geometry
Analysis of shapes includes commands to compute length, area, volumes and inertial properties, as well as to compute some aspects impacting shape validity.
@@ -8707,7 +8551,7 @@ Where:
@subsubsection occt_draw_bop_options_warn Drawing warning shapes
**bdrawwarnshapes** command enables/disables drawing of warning shapes of BOP algorithms.
**bdrawwarnshapes** command enables/disables drawing of waring shapes of BOP algorithms.
Syntax:
~~~~

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -3438,312 +3438,3 @@ Here are the few examples of defeaturing of the model containing boxes with blen
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im029.png,"Result",220}</td></td>
</tr>
</table>
@section occt_modalg_makeperiodic 3D Model Periodicity
Open CASCADE Technology provides tools for making an arbitrary 3D model (or just shape) periodic in 3D space in the specified directions.
Periodicity of the shape means that the shape can be repeated in any periodic direction any number of times without creation of the new geometry or splits.
The idea of this algorithm is to make the shape look similarly on the opposite sides or on the period bounds of periodic directions.
It does not mean that the opposite sides of the shape will be mirrored. It just means that the opposite sides of the shape should be split by each other and obtain the same geometry on opposite sides.
Such approach will allow repeating the shape, i.e. translating the copy of a shape on the period, without creation of new geometry because there will be no coinciding parts of different dimension.
For better understanding of what periodicity means lets create a simple prism and make it periodic.
The following draw script creates the L-shape prism with extensions 10x5x10:
~~~~
polyline p 0 0 0 0 0 10 5 0 10 5 0 5 10 0 5 10 0 0 0 0 0
mkplane f p
prism s f 0 5 0
~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im001.png,"Shape to make periodic",220}
Making this shape periodic in X, Y and Z directions with the periods matching the shape's extensions should make the splits of negative X and Z sides of the shape. The shape is already similar on opposite sides of Y directions, thus no new splits is expected.
Here is the shape after making it periodic:
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im002.png,"Periodic shape",220}
And here is the repetition of the shape once in X and Z directions:
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im003.png,"Repeated shape",220}
The OCCT Shape Periodicity tools also allows making the shape periodic with the period not matching the shape's extensions. Let's make the shape periodic with 11, 6 and 11 for X, Y, Z periods accordingly.
Such values of periods mean that there will be a gap between repeated shapes, and since during repetition the opposite sides do not touch the shape will not be split at all.
Here is the repetition of the shape once in X and Z directions:
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im004.png,"Repeated shape",220}
As expected, the shape is not split and the repeated elements do not touch.
If necessary the algorithm will trim the shape to fit into the requested period by splitting it with the planes limiting the shape's requested periods.
E.g. let's make the L-shape periodic only in X direction with the period 2 starting at X parameter 4:
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im005.png,"Periodic trimmed shape",220}
@subsection occt_modalg_makeperiodic_how_it_works How the shape is made periodic
For making the shape periodic in certain direction the algorithm performs the following steps:
* Creates the copy of the shape and moves it on the period into negative side of the requested direction;
* Splits the negative side of the shape by the moved copy, ensuring copying of the geometry from positive side to negative;
* Creates the copy of the shape (with already split negative side) and moves it on the period into the positive side of the requested direction;
* Splits the positive side of the shape by the moved copy, ensuring copying of the geometry from negative side to positive.
Repeated copying of the geometry ensures that the corner edges of the periodic shape will have the same geometry on opposite sides of all periodic directions.
Thus, in the periodic shape the geometry from positive side of the shape is always copied on the negative side of periodic directions.
@subsection occt_modalg_makeperiodic_association Opposite shapes association
The algorithm also associates the identical (or twin) shapes located on the opposite sides of the periodic shape. By the construction, the twin shapes should always have the same geometry and distanced from each other on the period.
It is possible that the shape does not have any twins. It means that when repeating this shape will not touch the opposite side of the shape. In the example when the periods of the shape are grater than its extensions, non of the sub-shapes has a twin.
@subsection occt_modalg_makeperiodic_repetition Periodic shape repetition
The algorithm also provides the methods to repeat the periodic shape in periodic directions. To repeat shape the algorithm makes the requested number of copies of the shape and translates them one by one on the time * period value.
After all copies are made and translated they are glued to have valid shape.
The subsequent repetitions are performed on the repeated shape, thus e.g. repeating the shape two times in any periodic direction will create result containing three shapes (original plus two copies).
Single subsequent repetition in any direction will result already in 6 shapes.
The repetitions can be cleared and started over.
@subsection occt_modalg_makeperiodic_history History support
The algorithm supports the history of shapes modifications, thus it is possible to track how the shapes have been changed to make it periodic and what new shapes have been created during repetitions.
Both split history and history of periodic shape repetition are available here. Note, that all repeated shapes are stored as generated into the history.
*BRepTools_History* is used for history support.
@subsection occt_modalg_makeperiodic_errors Errors/Warnings
The algorithm supports the Error/Warning reporting system which allows obtaining the extended overview of the errors and warning occurred during the operation.
As soon as any error appears the algorithm stops working. The warnings allow continuing the job, informing the user that something went wrong.
The algorithm returns the following alerts:
* *BOPAlgo_AlertNoPeriodicityRequired* - Error alert is given if no periodicity has been requested in any direction;
* *BOPAlgo_AlertUnableToTrim* - Error alert is given if the trimming of the shape for fitting it into requested period has failed;
* *BOPAlgo_AlertUnableToMakeIdentical* - Error alert is given if splitting of the shape by its moved copies has failed;
* *BOPAlgo_AlertUnableToRepeat* - Warning alert is given if the gluing of the repeated shapes has failed.
For more information on the error/warning reporting system please see the chapter @ref occt_algorithms_ers "Errors and warnings reporting system" of Boolean operations user guide.
@subsection occt_modalg_makeperiodic_usage Usage
The algorithm is implemented in the class *BOPAlgo_MakePeriodic*.
Here is the example of its usage on the API level:
~~~~
TopoDS_Shape aShape = ...; // The shape to make periodic
Standard_Boolean bMakeXPeriodic = ...; // Flag for making or not the shape periodic in X direction
Standard_Real aXPeriod = ...; // X period for the shape
Standard_Boolean isXTrimmed = ...; // Flag defining whether it is necessary to trimming
// the shape to fit to X period
Standard_Real aXFirst = ...; // Start of the X period
// (really necessary only if the trimming is requested)
Standard_Boolean bRunParallel = ...; // Parallel processing mode or single
BOPAlgo_MakePeriodic aPeriodicityMaker; // Periodicity maker
aPeriodicityMaker.SetShape(aShape); // Set the shape
aPeriodicityMaker.MakeXPeriodic(bMakePeriodic, aXPeriod); // Making the shape periodic in X direction
aPeriodicityMaker.SetTrimmed(isXTrimmed, aXFirst); // Trim the shape to fit X period
aPeriodicityMaker.SetRunParallel(bRunParallel); // Set the parallel processing mode
aPeriodicityMaker.Perform(); // Performing the operation
if (aPeriodicityMaker.HasErrors()) // Check for the errors
{
// errors treatment
Standard_SStream aSStream;
aPeriodicityMaker.DumpErrors(aSStream);
return;
}
if (aPeriodicityMaker.HasWarnings()) // Check for the warnings
{
// warnings treatment
Standard_SStream aSStream;
aPeriodicityMaker.DumpWarnings(aSStream);
}
const TopoDS_Shape& aPeriodicShape = aPeriodicityMaker.Shape(); // Result periodic shape
aPeriodicityMaker.XRepeat(2); // Making repetitions
const TopoDS_Shape& aRepeat = aPeriodicityMaker.RepeatedShape(); // Getting the repeated shape
aPeriodicityMaker.ClearRepetitions(); // Clearing the repetitions
~~~~
Please note, that the class is based on the options class *BOPAlgo_Options*, which provides the following options for the algorithm:
* Error/Warning reporting system;
* Parallel processing mode.
The other options of the base class are not supported here and will have no effect.
All the history information obtained during the operation is stored into *BRepTools_History* object and available through *History()* method:
~~~~
// Get the history object
const Handle(BRepTools_History)& BOPAlgo_MakePeriodic::History();
~~~~
For the usage of the MakePeriodic algorithm on the Draw level the following commands have been implemented:
* **makeperiodic**
* **repeatshape**
* **periodictwins**
* **clearrepetitions**
For more details on the periodicity commands please refer the @ref occt_draw_makeperiodic "Periodicity commands" of the Draw test harness user guide.
To track the history of a shape modification during MakePeriodic operation the @ref occt_draw_hist "standard history commands" can be used.
To have possibility to access the error/warning shapes of the operation use the *bdrawwarnshapes* command before running the algorithm (see command usage in the @ref occt_algorithms_ers "Errors and warnings reporting system" of Boolean operations user guide).
@subsection occt_modalg_makeperiodic_examples Examples
Imagine that you need to make the drills in the plate on the same distance from each other. To model this process it is necessary to make a lot of cylinders (simulating the drills) and cut these cylinders from the plate.
With the periodicity tool, the process looks very simple:
~~~~
# create plate 100 x 100
box plate -50 -50 0 100 100 1
# create a single drill with radius 1
pcylinder drill 1 1
# locate the drill in the left corner
ttranslate drill -48 -48 0
# make the drill periodic with 4 as X and Y periods, so the distance between drills will be 2
makeperiodic drill drill -x 4 -trim -50 -y 4 -trim -50
# repeat the drill to fill the plate, in result we get net of 25 x 25 drills
repeatshape drills -x 24 -y 24
# cut the drills from the plate
bcut result plate drills
~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im006.png,"Plate with drills",220}
@section occt_modalg_makeconnected Making touching shapes connected
Open CASCADE Technology provides tools for making the same-dimensional touching shapes connected (or glued), i.e. for making the coinciding geometries topologically shared among shapes.
To make the shapes connected they are glued by the means of @ref occt_algorithms_7 "General Fuse algorithm". The option BOPAlgo_GlueShift is used, thus if the input shapes have been interfering the algorithm will be unable to recognize this.
Making the group of shapes connected can be useful e.g. before meshing the group. It will allow making the resulting mesh conformal.
The algorithm for making the shapes connected is implemented in the class *BOPAlgo_MakeConnected*.
@subsection occt_modalg_makeconnected_materials Material association
In frames of this tool the input shapes are called materials, and each input shape has a unique material.
After making the shapes connected, the border elements of the input shapes are associated with the shapes to which they belong. At that, the orientation of the border elements in the shape is taken into account.
The associations are made for the following types:
* For input SOLIDS the resulting FACES are associated with the input solids;
* For input FACES the resulting EDGES are associated with the input faces;
* For input EDGES the resulting VERTICES are associated with the input edges.
The association process is called the material association. It allows finding the coinciding elements for the opposite input shapes. These elements will be associated to at least two materials (one on the positive side of the shape, the other - on negative).
For obtaining the material information the following methods should be used
* *MaterialsOnPositiveSide()* - returns the original shapes (materials) located on the positive side of the given shape (i.e. with FORWARD orientation);
* *MaterialsOnNegativeSide()* - returns the original shapes (materials) located on the negative side of the given shape (i.e. with REVERSED orientation);
~~~~
// Returns the original shapes which images contain the given shape with FORWARD orientation.
const TopTools_ListOfShape& BOPAlgo_MakeConnected::MaterialsOnPositiveSide(const TopoDS_Shape& theS)
// Returns the original shapes which images contain the given shape with REVERSED orientation.
const TopTools_ListOfShape& BOPAlgo_MakeConnected::MaterialsOnNegativeSide(const TopoDS_Shape& theS)
~~~~
@subsection occt_modalg_makeconnected_makeperiodic Making connected shape periodic
The tool provides possibility to make the connected shape @ref occt_modalg_makeperiodic "periodic".
Since by making the shape periodic it ensures that the geometry of coinciding shapes on the opposite sides will be the same it allows reusing the mesh of the shape for its periodic twins.
After making the shape periodic the material associations are updated to correspond to the actual state of the result shape. Repetition of the periodic shape is also possible from here. Material associations are not going to be lost.
@subsection occt_modalg_makeconnected_history History support
The algorithm supports history of shapes modifications during the operation. Additionally to standard history method provided by *BRepTools_History* and used here as a history tool, the algorithm also provides the method to track the back connection - from resulting shapes to the input ones.
The method is called *GetOrigins()*:
~~~~
// Returns the list of original shapes from which the current shape has been created.
const TopTools_ListOfShape& BOPAlgo_MakeConnected::GetOrigins(const TopoDS_Shape& theS);
~~~~
Both Gluing history and history of making the shape periodic and periodic shape repetition are available here. Note, that all repeated shapes are stored as generated into the history.
@subsection occt_modalg_makeconnected_errors Errors/Warnings
The algorithm supports the Error/Warning reporting system which allows obtaining the extended overview of the errors and warning occurred during the operation.
As soon as any error appears the algorithm stops working. The warnings allow continuing the job, informing the user that something went wrong.
The algorithm returns the following alerts:
* *BOPAlgo_AlertTooFewArguments* - error alert is given on the attempt to run the algorithm without the arguments;
* *BOPAlgo_AlertMultiDimensionalArguments* - error alert is given on the attempt to run the algorithm on multi-dimensional arguments;
* *BOPAlgo_AlertUnableToGlue* - error alert is given if the gluer algorithm is unable to glue the given arguments;
* *BOPAlgo_AlertUnableToMakePeriodic* - warning alert is given if the periodicity maker is unable to make the connected shape periodic with given options;
* *BOPAlgo_AlertShapeIsNotPeriodic* - warning alert is given on the attempt to repeat the shape before making it periodic.
For more information on the error/warning reporting system please see the chapter @ref occt_algorithms_ers "Errors and warnings reporting system" of Boolean operations user guide.
@subsection occt_modalg_makeconnected_usage Usage
Here is the example of usage of the *BOPAlgo_MakePeriodic* algorithm on the API level:
~~~~
TopTools_ListOfShape anArguments = ...; // Shapes to make connected
Standard_Boolean bRunParallel = ...; // Parallel processing mode
BOPAlgo_MakeConnected aMC; // Tool for making the shapes connected
aMC.SetArguments(anArguments); // Set the shapes
aMC.SetRunParallel(bRunParallel); // Set parallel processing mode
aMC.Perform(); // Perform the operation
if (aMC.HasErrors()) // Check for the errors
{
// errors treatment
Standard_SStream aSStream;
aMC.DumpErrors(aSStream);
return;
}
if (aMC.HasWarnings()) // Check for the warnings
{
// warnings treatment
Standard_SStream aSStream;
aMC.DumpWarnings(aSStream);
}
const TopoDS_Shape& aGluedShape = aMC.Shape(); // Connected shape
// Checking material associations
TopAbs_ShapeEnum anElemType = ...; // Type of border element
TopExp_Explorer anExp(anArguments.First(), anElemType);
for (; anExp.More(); anExp.Next())
{
const TopoDS_Shape& anElement = anExp.Current();
const TopTools_ListOfShape& aNegativeM = aMC.MaterialsOnNegativeSide(anElement);
const TopTools_ListOfShape& aPositiveM = aMC.MaterialsOnPositiveSide(anElement);
}
// Making the connected shape periodic
BOPAlgo_MakePeriodic::PeriodicityParams aParams = ...; // Options for periodicity of the connected shape
aMC.MakePeriodic(aParams);
// Shape repetition after making it periodic
// Check if the shape has been made periodic successfully
if (aMC.PeriodicityTool().HasErrors())
{
// Periodicity maker error treatment
}
// Shape repetition in periodic directions
aMC.RepeatShape(0, 2);
const TopoDS_Shape& aShape = aMC.PeriodicShape(); // Periodic and repeated shape
~~~~
Please note, that the class is based on the options class *BOPAlgo_Options*, which provides the following options for the algorithm:
* Error/Warning reporting system;
* Parallel processing mode.
The other options of the base class are not supported here and will have no effect.
All the history information obtained during the operation is stored into *BRepTools_History* object and available through *History()* method:
~~~~
// Get the history object
const Handle(BRepTools_History)& BOPAlgo_MakeConnected::History();
~~~~
For the usage of the MakeConnected algorithm on the Draw level the following commands have been implemented:
* **makeconnected**
* **cmaterialson**
* **cmakeperiodic**
* **crepeatshape**
* **cperiodictwins**
* **cclearrepetitions**
For more details on the connexity commands please refer the @ref occt_draw_makeconnected "MakeConnected commands" of the Draw test harness user guide.
To track the history of a shape modification during MakeConnected operation the @ref occt_draw_hist "standard history commands" can be used.
To have possibility to access the error/warning shapes of the operation use the *bdrawwarnshapes* command before running the algorithm (see command usage in the @ref occt_algorithms_ers "Errors and warnings reporting system" of Boolean operations user guide).

View File

@@ -1,68 +0,0 @@
cmake_minimum_required(VERSION 3.2)
project(glfw-occt-demo)
set(CMAKE_CXX_STANDARD 11)
set(APP_VERSION_MAJOR 1)
set(APP_VERSION_MINOR 0)
set(APP_TARGET glfwocct)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
file(GLOB SOURCES
*.h
*.cpp
)
source_group ("Headers" FILES
GlfwOcctView.h
GlfwOcctWindow.h)
source_group ("Sources" FILES
GlfwOcctView.cpp
GlfwOcctWindow.cpp
main.cpp)
# OpenGL
find_package(OpenGL REQUIRED)
# Open CASCADE Technology
find_package(OpenCASCADE REQUIRED NO_DEFAULT_PATH)
if (OpenCASCADE_FOUND)
message (STATUS "Using OpenCASCADE from \"${OpenCASCADE_DIR}\"" )
INCLUDE_DIRECTORIES(${OpenCASCADE_INCLUDE_DIR})
LINK_DIRECTORIES(${OpenCASCADE_LIBRARY_DIR})
else()
message (WARNING "Could not find OpenCASCADE, please set OpenCASCADE_DIR variable." )
set (OCCT_LIBRARY_DIR)
set (OCCT_BIN_DIR)
endif()
SET(OpenCASCADE_LIBS
TKernel
TKService
TKV3d
TKOpenGl
TKBRep
TKGeomBase
TKGeomAlgo
TKG3d
TKG2d
TKTopAlgo
TKPrim
)
# glfw
find_package(glfw3 REQUIRED)
if (glfw3_FOUND)
message (STATUS "Using glfw3 ${glfw3_VERSION}" )
INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIRS})
LINK_DIRECTORIES(${GLFW_LIBRARY_DIRS})
else()
message (STATUS "glfw3 is not found." )
endif()
add_executable(${APP_TARGET} ${SOURCES})
target_link_libraries(
${APP_TARGET}
${OpenCASCADE_LIBS}
glfw
${OPENGL_LIBRARIES}
)

View File

@@ -1,324 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "GlfwOcctView.h"
#include <AIS_Shape.hxx>
#include <Aspect_Handle.hxx>
#include <Aspect_DisplayConnection.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeCone.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <iostream>
#include <GLFW/glfw3.h>
// ================================================================
// Function : GlfwOcctView
// Purpose :
// ================================================================
GlfwOcctView::GlfwOcctView()
: myCurAction3d (CurAction3d_Nothing),
myToRedraw (true)
{
}
// ================================================================
// Function : ~GlfwOcctView
// Purpose :
// ================================================================
GlfwOcctView::~GlfwOcctView()
{
}
// ================================================================
// Function : toView
// Purpose :
// ================================================================
GlfwOcctView* GlfwOcctView::toView (GLFWwindow* theWin)
{
return static_cast<GlfwOcctView*>(glfwGetWindowUserPointer (theWin));
}
// ================================================================
// Function : errorCallback
// Purpose :
// ================================================================
void GlfwOcctView::errorCallback (int theError, const char* theDescription)
{
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error") + theError + ": " + theDescription, Message_Fail);
}
// ================================================================
// Function : run
// Purpose :
// ================================================================
void GlfwOcctView::run()
{
initWindow (800, 600, "glfw occt");
initViewer();
initDemoScene();
if (myView.IsNull())
{
return;
}
myView->MustBeResized();
myOcctWindow->Map();
mainloop();
cleanup();
}
// ================================================================
// Function : initWindow
// Purpose :
// ================================================================
void GlfwOcctView::initWindow (int theWidth, int theHeight, const char* theTitle)
{
glfwSetErrorCallback (GlfwOcctView::errorCallback);
glfwInit();
const bool toAskCoreProfile = true;
if (toAskCoreProfile)
{
glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3);
#if defined (__APPLE__)
glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
}
myOcctWindow = new GlfwOcctWindow (theWidth, theHeight, theTitle);
glfwSetWindowUserPointer (myOcctWindow->getGlfwWindow(), this);
// window callback
glfwSetWindowSizeCallback (myOcctWindow->getGlfwWindow(), GlfwOcctView::onResizeCallback);
glfwSetFramebufferSizeCallback (myOcctWindow->getGlfwWindow(), GlfwOcctView::onFBResizeCallback);
// mouse callback
glfwSetScrollCallback (myOcctWindow->getGlfwWindow(), GlfwOcctView::onMouseScrollCallback);
glfwSetMouseButtonCallback (myOcctWindow->getGlfwWindow(), GlfwOcctView::onMouseButtonCallback);
glfwSetCursorPosCallback (myOcctWindow->getGlfwWindow(), GlfwOcctView::onMouseMoveCallback);
}
// ================================================================
// Function : initViewer
// Purpose :
// ================================================================
void GlfwOcctView::initViewer()
{
if (myOcctWindow.IsNull()
|| myOcctWindow->getGlfwWindow() == nullptr)
{
return;
}
Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver (myOcctWindow->GetDisplay(), false);
Handle(V3d_Viewer) aViewer = new V3d_Viewer (aGraphicDriver);
aViewer->SetDefaultLights();
aViewer->SetLightOn();
aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
aViewer->ActivateGrid (Aspect_GT_Rectangular, Aspect_GDM_Lines);
myView = aViewer->CreateView();
myView->SetImmediateUpdate (false);
myView->SetWindow (myOcctWindow, myOcctWindow->NativeGlContext());
myView->ChangeRenderingParams().ToShowStats = true;
myContext = new AIS_InteractiveContext (aViewer);
}
// ================================================================
// Function : initDemoScene
// Purpose :
// ================================================================
void GlfwOcctView::initDemoScene()
{
if (myContext.IsNull())
{
return;
}
myView->TriedronDisplay (Aspect_TOTP_LEFT_LOWER, Quantity_NOC_GOLD, 0.08, V3d_WIREFRAME);
gp_Ax2 anAxis;
anAxis.SetLocation (gp_Pnt (0.0, 0.0, 0.0));
Handle(AIS_Shape) aBox = new AIS_Shape (BRepPrimAPI_MakeBox (anAxis, 50, 50, 50).Shape());
myContext->Display (aBox, AIS_Shaded, 0, false);
anAxis.SetLocation (gp_Pnt (25.0, 125.0, 0.0));
Handle(AIS_Shape) aCone = new AIS_Shape (BRepPrimAPI_MakeCone (anAxis, 25, 0, 50).Shape());
myContext->Display (aCone, AIS_Shaded, 0, false);
TCollection_AsciiString aGlInfo;
{
TColStd_IndexedDataMapOfStringString aRendInfo;
myView->DiagnosticInformation (aRendInfo, Graphic3d_DiagnosticInfo_Basic);
for (TColStd_IndexedDataMapOfStringString::Iterator aValueIter (aRendInfo); aValueIter.More(); aValueIter.Next())
{
if (!aGlInfo.IsEmpty()) { aGlInfo += "\n"; }
aGlInfo += TCollection_AsciiString(" ") + aValueIter.Key() + ": " + aValueIter.Value();
}
}
Message::DefaultMessenger()->Send (TCollection_AsciiString("OpenGL info:\n") + aGlInfo, Message_Info);
}
// ================================================================
// Function : mainloop
// Purpose :
// ================================================================
void GlfwOcctView::mainloop()
{
while (!glfwWindowShouldClose (myOcctWindow->getGlfwWindow()))
{
// glfwPollEvents() for continuous rendering (immediate return if there are no new events)
// and glfwWaitEvents() for rendering on demand (something actually happened in the viewer)
//glfwPollEvents();
glfwWaitEvents();
if (!myView.IsNull())
{
if (myView->IsInvalidated())
{
myView->Redraw();
}
else if (myToRedraw)
{
myView->RedrawImmediate();
}
myToRedraw = false;
}
}
}
// ================================================================
// Function : cleanup
// Purpose :
// ================================================================
void GlfwOcctView::cleanup()
{
if (!myView.IsNull())
{
myView->Remove();
}
if (!myOcctWindow.IsNull())
{
myOcctWindow->Close();
}
glfwTerminate();
}
// ================================================================
// Function : onResize
// Purpose :
// ================================================================
void GlfwOcctView::onResize (int theWidth, int theHeight)
{
if (theWidth != 0
&& theHeight != 0
&& !myView.IsNull())
{
myView->Window()->DoResize();
myView->MustBeResized();
myView->Invalidate();
myView->Redraw();
//myToRedraw = true;
}
}
// ================================================================
// Function : onMouseScroll
// Purpose :
// ================================================================
void GlfwOcctView::onMouseScroll (double theOffsetX, double theOffsetY)
{
if (myView.IsNull()) { return; }
const Graphic3d_Vec2i aPos = myOcctWindow->CursorPosition();
myView->StartZoomAtPoint (aPos.x(), aPos.y());
myView->ZoomAtPoint (0, 0, int(theOffsetY * 4.0), int(theOffsetY * 4.0));
myView->Invalidate();
myToRedraw = true;
}
// ================================================================
// Function : onMouseButton
// Purpose :
// ================================================================
void GlfwOcctView::onMouseButton (int theButton, int theAction, int theMods)
{
if (myView.IsNull()) { return; }
const Graphic3d_Vec2i aPos = myOcctWindow->CursorPosition();
if (theAction != GLFW_PRESS)
{
myCurAction3d = CurAction3d_Nothing;
return;
}
myMouseMin = aPos;
myMouseMax = aPos;
switch (theButton)
{
case GLFW_MOUSE_BUTTON_RIGHT:
{
myCurAction3d = CurAction3d_DynamicRoation;
myView->StartRotation (aPos.x(), aPos.y());
break;
}
case GLFW_MOUSE_BUTTON_MIDDLE:
{
myCurAction3d = CurAction3d_DynamicPanning;
break;
}
}
}
// ================================================================
// Function : onMouseMove
// Purpose :
// ================================================================
void GlfwOcctView::onMouseMove (int thePosX, int thePosY)
{
if (myView.IsNull()) { return; }
switch (myCurAction3d)
{
case CurAction3d_DynamicRoation:
{
myView->Rotation (thePosX, thePosY);
myView->Invalidate();
myToRedraw = true;
break;
}
case CurAction3d_DynamicPanning:
{
myView->Pan (thePosX - myMouseMax.x(), -(thePosY - myMouseMax.y()));
myView->Invalidate();
myToRedraw = true;
myMouseMax.SetValues (thePosX, thePosY);
break;
}
default:
{
myContext->MoveTo (thePosX, thePosY, myView, false);
myToRedraw = true;
break;
}
}
}

View File

@@ -1,125 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef _GlfwOcctView_Header
#define _GlfwOcctView_Header
#include "GlfwOcctWindow.h"
#include <AIS_InteractiveContext.hxx>
#include <V3d_View.hxx>
//! Sample class creating 3D Viewer within GLFW window.
class GlfwOcctView
{
public:
enum CurAction3d
{
CurAction3d_Nothing,
CurAction3d_DynamicZooming,
CurAction3d_DynamicPanning,
CurAction3d_DynamicRoation
};
public:
//! Default constructor.
GlfwOcctView();
//! Destructor.
~GlfwOcctView();
//! Main application entry point.
void run();
private:
//! Create GLFW window.
void initWindow (int theWidth, int theHeight, const char* theTitle);
//! Create 3D Viewer.
void initViewer();
//! Fill 3D Viewer with a DEMO items.
void initDemoScene();
//! Application event loop.
void mainloop();
//! Clean up before .
void cleanup();
//! @name GLWF callbacks
private:
//! Window resize event.
void onResize (int theWidth, int theHeight);
//! Mouse scroll event.
void onMouseScroll (double theOffsetX, double theOffsetY);
//! Mouse click event.
void onMouseButton (int theButton, int theAction, int theMods);
//! Mouse move event.
void onMouseMove (int thePosX, int thePosY);
//! @name GLWF callbacks (static functions)
private:
//! GLFW callback redirecting messages into Message::DefaultMessenger().
static void errorCallback (int theError, const char* theDescription);
//! Wrapper for glfwGetWindowUserPointer() returning this class instance.
static GlfwOcctView* toView (GLFWwindow* theWin);
//! Window resize callback.
static void onResizeCallback (GLFWwindow* theWin, int theWidth, int theHeight)
{ toView(theWin)->onResize (theWidth, theHeight); }
//! Frame-buffer resize callback.
static void onFBResizeCallback (GLFWwindow* theWin, int theWidth, int theHeight)
{ toView(theWin)->onResize (theWidth, theHeight); }
//! Mouse scroll callback.
static void onMouseScrollCallback (GLFWwindow* theWin, double theOffsetX, double theOffsetY)
{ toView(theWin)->onMouseScroll (theOffsetX, theOffsetY); }
//! Mouse click callback.
static void onMouseButtonCallback (GLFWwindow* theWin, int theButton, int theAction, int theMods)
{ toView(theWin)->onMouseButton (theButton, theAction, theMods); }
//! Mouse move callback.
static void onMouseMoveCallback (GLFWwindow* theWin, double thePosX, double thePosY)
{ toView(theWin)->onMouseMove ((int )thePosX, (int )thePosY); }
private:
Handle(GlfwOcctWindow) myOcctWindow;
Handle(V3d_View) myView;
Handle(AIS_InteractiveContext) myContext;
CurAction3d myCurAction3d;
Graphic3d_Vec2i myMouseMin;
Graphic3d_Vec2i myMouseMax;
bool myToRedraw;
};
#endif // _GlfwOcctView_Header

View File

@@ -1,161 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "GlfwOcctWindow.h"
#if defined (__APPLE__)
#undef Handle // avoid name collisions in macOS headers
#define GLFW_EXPOSE_NATIVE_COCOA
#define GLFW_EXPOSE_NATIVE_NSGL
#elif defined (_WIN32)
#define GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WGL
#else
#define GLFW_EXPOSE_NATIVE_X11
#define GLFW_EXPOSE_NATIVE_GLX
#endif
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
// ================================================================
// Function : GlfwOcctWindow
// Purpose :
// ================================================================
GlfwOcctWindow::GlfwOcctWindow (int theWidth, int theHeight, const TCollection_AsciiString& theTitle)
: myGlfwWindow (glfwCreateWindow (theWidth, theHeight, theTitle.ToCString(), NULL, NULL)),
myXLeft (0),
myYTop (0),
myXRight (0),
myYBottom(0)
{
if (myGlfwWindow != nullptr)
{
int aWidth = 0, aHeight = 0;
glfwGetWindowPos (myGlfwWindow, &myXLeft, &myYTop);
glfwGetWindowSize(myGlfwWindow, &aWidth, &aHeight);
myXRight = myXLeft + aWidth;
myYBottom = myYTop + aHeight;
#if !defined(_WIN32) && !defined(__APPLE__)
myDisplay = new Aspect_DisplayConnection (glfwGetX11Display());
#endif
}
}
// ================================================================
// Function : Close
// Purpose :
// ================================================================
void GlfwOcctWindow::Close()
{
if (myGlfwWindow != nullptr)
{
glfwDestroyWindow (myGlfwWindow);
myGlfwWindow = nullptr;
}
}
// ================================================================
// Function : NativeHandle
// Purpose :
// ================================================================
Aspect_Drawable GlfwOcctWindow::NativeHandle() const
{
#if defined (__APPLE__)
return (Aspect_Drawable)glfwGetCocoaWindow (myGlfwWindow);
#elif defined (_WIN32)
return (Aspect_Drawable)glfwGetWin32Window (myGlfwWindow);
#else
return (Aspect_Drawable)glfwGetX11Window (myGlfwWindow);
#endif
}
// ================================================================
// Function : NativeGlContext
// Purpose :
// ================================================================
Aspect_RenderingContext GlfwOcctWindow::NativeGlContext() const
{
#if defined (__APPLE__)
return (NSOpenGLContext*)glfwGetNSGLContext (myGlfwWindow);
#elif defined (_WIN32)
return glfwGetWGLContext (myGlfwWindow);
#else
return glfwGetGLXContext (myGlfwWindow);
#endif
}
// ================================================================
// Function : IsMapped
// Purpose :
// ================================================================
Standard_Boolean GlfwOcctWindow::IsMapped() const
{
return glfwGetWindowAttrib (myGlfwWindow, GLFW_VISIBLE) != 0;
}
// ================================================================
// Function : Map
// Purpose :
// ================================================================
void GlfwOcctWindow::Map() const
{
glfwShowWindow (myGlfwWindow);
}
// ================================================================
// Function : Unmap
// Purpose :
// ================================================================
void GlfwOcctWindow::Unmap() const
{
glfwHideWindow (myGlfwWindow);
}
// ================================================================
// Function : DoResize
// Purpose :
// ================================================================
Aspect_TypeOfResize GlfwOcctWindow::DoResize() const
{
if (glfwGetWindowAttrib (myGlfwWindow, GLFW_VISIBLE) == 1)
{
int anXPos = 0, anYPos = 0, aWidth = 0, aHeight = 0;
glfwGetWindowPos (myGlfwWindow, &anXPos, &anYPos);
glfwGetWindowSize(myGlfwWindow, &aWidth, &aHeight);
*const_cast<Standard_Integer*>(&myXLeft ) = anXPos;
*const_cast<Standard_Integer*>(&myXRight ) = anXPos + aWidth;
*const_cast<Standard_Integer*>(&myYTop ) = anYPos;
*const_cast<Standard_Integer*>(&myYBottom) = anYPos + aHeight;
}
return Aspect_TOR_UNKNOWN;
}
// ================================================================
// Function : CursorPosition
// Purpose :
// ================================================================
Graphic3d_Vec2i GlfwOcctWindow::CursorPosition() const
{
Graphic3d_Vec2d aPos;
glfwGetCursorPos (myGlfwWindow, &aPos.x(), &aPos.y());
return Graphic3d_Vec2i ((int )aPos.x(), (int )aPos.y());
}

View File

@@ -1,115 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef _GlfwOcctWindow_Header
#define _GlfwOcctWindow_Header
#include <Aspect_DisplayConnection.hxx>
#include <Aspect_RenderingContext.hxx>
#include <Aspect_Window.hxx>
#include <Graphic3d_Vec.hxx>
#include <TCollection_AsciiString.hxx>
struct GLFWwindow;
//! GLFWwindow wrapper implementing Aspect_Window interface.
class GlfwOcctWindow : public Aspect_Window
{
DEFINE_STANDARD_RTTI_INLINE(GlfwOcctWindow, Aspect_Window)
public:
//! Main constructor.
GlfwOcctWindow (int theWidth, int theHeight, const TCollection_AsciiString& theTitle);
//! Close the window.
virtual ~GlfwOcctWindow() { Close(); }
//! Close the window.
void Close();
//! Return X Display connection.
const Handle(Aspect_DisplayConnection)& GetDisplay() const { return myDisplay; }
//! Return GLFW window.
GLFWwindow* getGlfwWindow() { return myGlfwWindow; }
//! Return native OpenGL context.
Aspect_RenderingContext NativeGlContext() const;
//! Return cursor position.
Graphic3d_Vec2i CursorPosition() const;
public:
//! Returns native Window handle
virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE;
//! Returns parent of native Window handle.
virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE { return 0; }
//! Applies the resizing to the window <me>
virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE;
//! Returns True if the window <me> is opened and False if the window is closed.
virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
//! Apply the mapping change to the window <me> and returns TRUE if the window is mapped at screen.
virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }
//! Opens the window <me>.
virtual void Map() const Standard_OVERRIDE;
//! Closes the window <me>.
virtual void Unmap() const Standard_OVERRIDE;
virtual void Position (Standard_Integer& theX1, Standard_Integer& theY1,
Standard_Integer& theX2, Standard_Integer& theY2) const Standard_OVERRIDE
{
theX1 = myXLeft;
theX2 = myXRight;
theY1 = myYTop;
theY2 = myYBottom;
}
//! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions.
virtual Standard_Real Ratio() const Standard_OVERRIDE
{
return Standard_Real (myXRight - myXLeft) / Standard_Real (myYBottom - myYTop);
}
//! Return window size.
virtual void Size (Standard_Integer& theWidth, Standard_Integer& theHeight) const Standard_OVERRIDE
{
theWidth = myXRight - myXLeft;
theHeight = myYBottom - myYTop;
}
virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return NULL; }
protected:
Handle(Aspect_DisplayConnection) myDisplay;
GLFWwindow* myGlfwWindow;
Standard_Integer myXLeft;
Standard_Integer myYTop;
Standard_Integer myXRight;
Standard_Integer myYBottom;
};
#endif // _GlfwOcctWindow_Header

View File

@@ -1,37 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "GlfwOcctView.h"
int main (int, char**)
{
GlfwOcctView anApp;
try
{
anApp.run();
}
catch (const std::runtime_error& theError)
{
std::cerr << theError.what() << std::endl;
return EXIT_FAILURE;
}
return 0;
}

View File

@@ -1,4 +0,0 @@
A sample demonstrating usage of OCCT 3D Viewer within a window created using GLFW.
Platforms: Windows, macOS, Linux
Required: glfw

View File

@@ -44,13 +44,13 @@ unix {
win32 {
CONFIG(debug, debug|release) {
DEFINES += _DEBUG
DESTDIR = ./win$$(ARCH)/$$(VCVER)/bind
OBJECTS_DIR = ./win$$(ARCH)/$$(VCVER)/objd
DESTDIR = ./win$(ARCH)/$(VCVER)/bind
OBJECTS_DIR = ./win$(ARCH)/$(VCVER)/objd
MOC_DIR = ./src
} else {
DEFINES += NDEBUG
DESTDIR = ./win$$(ARCH)/$$(VCVER)/bin
OBJECTS_DIR = ./win$$(ARCH)/$$(VCVER)/obj
DESTDIR = ./win$(ARCH)/$(VCVER)/bin
OBJECTS_DIR = ./win$(ARCH)/$(VCVER)/obj
MOC_DIR = ./src
}
LIBS = -L$$(QTDIR)/lib;$$(CSF_OCCTLibPath)

View File

@@ -58,14 +58,14 @@ unix {
win32 {
CONFIG(debug, debug|release) {
DEFINES += _DEBUG
DESTDIR = ./win$$(ARCH)/$$(VCVER)/bind
OBJECTS_DIR = ./win$$(ARCH)/$$(VCVER)/objd
MOC_DIR = ./win$$(ARCH)/$$(VCVER)/mocd
DESTDIR = ./win$(ARCH)/$(VCVER)/bind
OBJECTS_DIR = ./win$(ARCH)/$(VCVER)/objd
MOC_DIR = ./win$(ARCH)/$(VCVER)/mocd
} else {
DEFINES += NDEBUG
DESTDIR = ./win$$(ARCH)/$$(VCVER)/bin
OBJECTS_DIR = ./win$$(ARCH)/$$(VCVER)/obj
MOC_DIR = ./win$$(ARCH)/$$(VCVER)/moc
DESTDIR = ./win$(ARCH)/$(VCVER)/bin
OBJECTS_DIR = ./win$(ARCH)/$(VCVER)/obj
MOC_DIR = ./win$(ARCH)/$(VCVER)/moc
}
LIBS = -L$$(QTDIR)/lib;$$(CSF_OCCTLibPath)
DEFINES += NO_COMMONSAMPLE_EXPORTS NO_IESAMPLE_EXPORTS

View File

@@ -61,14 +61,14 @@ unix {
win32 {
CONFIG(debug, debug|release) {
DEFINES += _DEBUG
DESTDIR = ./win$$(ARCH)/$$(VCVER)/bind
OBJECTS_DIR = ./win$$(ARCH)/$$(VCVER)/objd
MOC_DIR = ./win$$(ARCH)/$$(VCVER)/mocd
DESTDIR = ./win$(ARCH)/$(VCVER)/bind
OBJECTS_DIR = ./win$(ARCH)/$(VCVER)/objd
MOC_DIR = ./win$(ARCH)/$(VCVER)/mocd
} else {
DEFINES += NDEBUG
DESTDIR = ./win$$(ARCH)/$$(VCVER)/bin
OBJECTS_DIR = ./win$$(ARCH)/$$(VCVER)/obj
MOC_DIR = ./win$$(ARCH)/$$(VCVER)/moc
DESTDIR = ./win$(ARCH)/$(VCVER)/bin
OBJECTS_DIR = ./win$(ARCH)/$(VCVER)/obj
MOC_DIR = ./win$(ARCH)/$(VCVER)/moc
}
LIBS = -L$$(QTDIR)/lib;$$(CSF_OCCTLibPath)
DEFINES += NO_COMMONSAMPLE_EXPORTS NO_IESAMPLE_EXPORTS

View File

@@ -1,285 +0,0 @@
// Created on: 2018-12-12
// Created by: Olga SURYANINOVA
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AIS_CameraFrustum.hxx>
#include <AIS_DisplayMode.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Select3D_SensitiveGroup.hxx>
#include <Select3D_SensitivePrimitiveArray.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <SelectMgr_EntityOwner.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_CameraFrustum, AIS_InteractiveObject)
namespace
{
static const Standard_ShortReal THE_DEFAULT_TRANSPARENCY = 0.7f;
static const Quantity_Color THE_DEFAULT_COLOR = Quantity_NOC_WHITE;
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_CameraFrustum::AIS_CameraFrustum()
: myPoints (0, Graphic3d_Camera::FrustumVerticesNB)
{
myDrawer->SetLineAspect (new Prs3d_LineAspect (THE_DEFAULT_COLOR, Aspect_TOL_SOLID, 1.0));
Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
aShadingAspect->SetMaterial (Graphic3d_NOM_PLASTIC);
aShadingAspect->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend);
aShadingAspect->SetTransparency (THE_DEFAULT_TRANSPARENCY);
aShadingAspect->SetColor (THE_DEFAULT_COLOR);
myDrawer->SetShadingAspect (aShadingAspect);
myDrawer->SetTransparency (THE_DEFAULT_TRANSPARENCY);
SetDisplayMode (AIS_Shaded);
}
//=======================================================================
//function : AcceptDisplayMode
//purpose :
//=======================================================================
Standard_Boolean AIS_CameraFrustum::AcceptDisplayMode (const Standard_Integer theMode) const
{
return theMode == AIS_Shaded || theMode == AIS_WireFrame;
}
//=======================================================================
//function : SetCameraFrustum
//purpose :
//=======================================================================
void AIS_CameraFrustum::SetCameraFrustum (const Handle(Graphic3d_Camera)& theCamera)
{
if (theCamera.IsNull())
{
return;
}
theCamera->FrustumPoints (myPoints);
fillTriangles();
fillBorders();
SetToUpdate();
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_CameraFrustum::SetColor (const Quantity_Color& theColor)
{
AIS_InteractiveObject::SetColor (theColor);
myDrawer->ShadingAspect()->SetColor (theColor);
myDrawer->LineAspect()->SetColor (theColor);
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_CameraFrustum::UnsetColor()
{
if (!HasColor())
{
return;
}
AIS_InteractiveObject::UnsetColor();
myDrawer->ShadingAspect()->SetColor (THE_DEFAULT_COLOR);
myDrawer->LineAspect()->SetColor (THE_DEFAULT_COLOR);
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_CameraFrustum::UnsetTransparency()
{
myDrawer->ShadingAspect()->SetTransparency (0.0f);
myDrawer->SetTransparency (0.0f);
}
//=======================================================================
//function : fillTriangles
//purpose :
//=======================================================================
void AIS_CameraFrustum::fillTriangles()
{
if (myTriangles.IsNull())
{
const Standard_Integer aPlaneTriangleVertsNb = 2 * 3;
const Standard_Integer aPlanesNb = 3 * 2;
myTriangles = new Graphic3d_ArrayOfTriangles (Graphic3d_Camera::FrustumVerticesNB, aPlaneTriangleVertsNb * aPlanesNb);
myTriangles->SetVertice (Graphic3d_Camera::FrustumVerticesNB, gp_Pnt (0.0, 0.0, 0.0));
// Triangles go in order (clockwise vertices traversing for correct normal):
// (0, 2, 1), (3, 1, 2)
const Standard_Integer aLookup1_clockwise[] = { 0, 1, 0, 1, 0, 1 };
const Standard_Integer aLookup2_clockwise[] = { 0, 0, 1, 1, 1, 0 };
// Triangles go in order (counterclockwise vertices traversing for correct normal):
// (1, 2, 0), (2, 1, 3)
const Standard_Integer aLookup1_anticlockwise[] = { 0, 1, 0, 1, 0, 1 };
const Standard_Integer aLookup2_anticlockwise[] = { 1, 0, 0, 0, 1, 1 };
Standard_Integer aShifts[] = { 0, 0, 0 };
// Planes go in order:
// LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
for (Standard_Integer aFaceIdx = 0; aFaceIdx < 3; ++aFaceIdx)
{
for (Standard_Integer i = 0; i < 2; ++i)
{
for (Standard_Integer aPntIter = 0; aPntIter < aPlaneTriangleVertsNb; ++aPntIter)
{
aShifts[aFaceIdx] = i;
if (i == 0)
{
aShifts[(aFaceIdx + 1) % 3] = aLookup1_clockwise[aPntIter];
aShifts[(aFaceIdx + 2) % 3] = aLookup2_clockwise[aPntIter];
}
else
{
aShifts[(aFaceIdx + 1) % 3] = aLookup1_anticlockwise[aPntIter];
aShifts[(aFaceIdx + 2) % 3] = aLookup2_anticlockwise[aPntIter];
}
Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2];
myTriangles->AddEdge (anIndex + 1);
}
}
}
}
for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB; ++aPointIter)
{
const Graphic3d_Vec3d aPnt = myPoints[aPointIter];
myTriangles->SetVertice (aPointIter + 1, gp_Pnt (aPnt.x(), aPnt.y(), aPnt.z()));
}
}
//=======================================================================
//function : fillBorders
//purpose :
//=======================================================================
void AIS_CameraFrustum::fillBorders()
{
if (myBorders.IsNull())
{
const Standard_Integer aPlaneSegmVertsNb = 2 * 4;
const Standard_Integer aPlanesNb = 3 * 2;
myBorders = new Graphic3d_ArrayOfSegments (Graphic3d_Camera::FrustumVerticesNB, aPlaneSegmVertsNb * aPlanesNb);
myBorders->SetVertice (Graphic3d_Camera::FrustumVerticesNB, gp_Pnt (0.0, 0.0, 0.0));
// Segments go in order:
// (0, 2), (2, 3), (3, 1), (1, 0)
const Standard_Integer aLookup1[] = { 0, 1, 1, 1, 1, 0, 0, 0 };
const Standard_Integer aLookup2[] = { 0, 0, 0, 1, 1, 1, 1, 0 };
Standard_Integer aShifts[] = { 0, 0, 0 };
// Planes go in order:
// LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
for (Standard_Integer aFaceIdx = 0; aFaceIdx < 3; ++aFaceIdx)
{
for (Standard_Integer i = 0; i < 2; ++i)
{
for (Standard_Integer aSegmVertIter = 0; aSegmVertIter < aPlaneSegmVertsNb; ++aSegmVertIter)
{
aShifts[aFaceIdx] = i;
aShifts[(aFaceIdx + 1) % 3] = aLookup1[aSegmVertIter];
aShifts[(aFaceIdx + 2) % 3] = aLookup2[aSegmVertIter];
Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2];
myBorders->AddEdge (anIndex + 1);
}
}
}
}
for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB; ++aPointIter)
{
const Graphic3d_Vec3d aPnt = myPoints[aPointIter];
myBorders->SetVertice (aPointIter + 1, gp_Pnt (aPnt.x(), aPnt.y(), aPnt.z()));
}
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_CameraFrustum::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
thePrs->SetInfiniteState (true);
if (myTriangles.IsNull())
{
return;
}
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
switch (theMode)
{
case AIS_Shaded:
{
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray (myTriangles);
}
Standard_FALLTHROUGH
case AIS_WireFrame:
{
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
aGroup->AddPrimitiveArray (myBorders);
break;
}
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_CameraFrustum::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this);
switch (theMode)
{
case SelectionMode_Edges:
{
Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup (anOwner);
for (Standard_Integer anIter = 1; anIter <= myBorders->EdgeNumber(); anIter += 2)
{
aSensitiveEntity->Add (new Select3D_SensitiveSegment (anOwner, myBorders->Vertice (myBorders->Edge (anIter)), myBorders->Vertice(myBorders->Edge (anIter + 1))));
}
theSelection->Add (aSensitiveEntity);
break;
}
case SelectionMode_Volume:
{
Handle(Select3D_SensitivePrimitiveArray) aSelArray = new Select3D_SensitivePrimitiveArray (anOwner);
aSelArray->InitTriangulation (myTriangles->Attributes(), myTriangles->Indices(), TopLoc_Location());
theSelection->Add (aSelArray);
break;
}
}
}

View File

@@ -1,85 +0,0 @@
// Created on: 2018-12-12
// Created by: Olga SURYANINOVA
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_CameraFrustum_HeaderFile
#define _AIS_CameraFrustum_HeaderFile
#include <AIS_InteractiveObject.hxx>
class Graphic3d_ArrayOfSegments;
class Graphic3d_ArrayOfTriangles;
//! Presentation for drawing camera frustum.
//! Default configuration is built with filling and some transparency.
class AIS_CameraFrustum : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_CameraFrustum, AIS_InteractiveObject)
public:
//! Selection modes supported by this object
enum SelectionMode
{
SelectionMode_Edges = 0, //!< detect by edges (default)
SelectionMode_Volume = 1, //!< detect by volume
};
public:
//! Constructs camera frustum with default configuration.
Standard_EXPORT AIS_CameraFrustum();
//! Sets camera frustum.
Standard_EXPORT void SetCameraFrustum (const Handle(Graphic3d_Camera)& theCamera);
//! Setup custom color.
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
//! Restore default color.
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
//! Restore transparency setting.
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
//! Return true if specified display mode is supported.
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE;
protected:
//! Computes presentation of camera frustum.
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection.
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
private:
//! Fills triangles primitive array for camera frustum filling.
void fillTriangles();
//! Fills polylines primitive array for camera frustum borders.
void fillBorders();
protected:
NCollection_Array1<Graphic3d_Vec3d> myPoints; //!< Array of points
Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for camera frustum filling
Handle(Graphic3d_ArrayOfSegments) myBorders; //!< Segments for camera frustum borders
};
#endif // _AIS_CameraFrustum_HeaderFile

View File

@@ -27,7 +27,6 @@ public:
AIS_ColoredDrawer (const Handle(Prs3d_Drawer)& theLink)
: myIsHidden (false),
myHasOwnColor (false),
myHasOwnTransp(false),
myHasOwnWidth (false)
{
Link (theLink);
@@ -35,15 +34,9 @@ public:
bool IsHidden() const { return myIsHidden; }
void SetHidden (const bool theToHide) { myIsHidden = theToHide;}
bool HasOwnColor() const { return myHasOwnColor; }
void UnsetOwnColor() { myHasOwnColor = false; }
void SetOwnColor (const Quantity_Color& /*theColor*/) { myHasOwnColor = true; }
bool HasOwnTransparency() const { return myHasOwnTransp; }
void UnsetOwnTransparency() { myHasOwnTransp = false; }
void SetOwnTransparency (Standard_Real /*theTransp*/) { myHasOwnTransp = true; }
bool HasOwnWidth() const { return myHasOwnWidth; }
void UnsetOwnWidth() { myHasOwnWidth = false; }
void SetOwnWidth (const Standard_Real /*theWidth*/) { myHasOwnWidth = true; }
@@ -52,7 +45,6 @@ public: //! @name list of overridden properties
bool myIsHidden;
bool myHasOwnColor;
bool myHasOwnTransp;
bool myHasOwnWidth;
};

View File

@@ -187,25 +187,6 @@ void AIS_ColoredShape::SetCustomColor (const TopoDS_Shape& theShape,
LoadRecomputable (AIS_Shaded);
}
//=======================================================================
//function : SetCustomTransparency
//purpose :
//=======================================================================
void AIS_ColoredShape::SetCustomTransparency (const TopoDS_Shape& theShape,
Standard_Real theTransparency)
{
if (theShape.IsNull())
{
return;
}
const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
setTransparency (aDrawer, theTransparency);
aDrawer->SetOwnTransparency (theTransparency);
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (AIS_Shaded);
}
//=======================================================================
//function : SetCustomWidth
//purpose :
@@ -219,7 +200,7 @@ void AIS_ColoredShape::SetCustomWidth (const TopoDS_Shape& theShape,
}
const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
setWidth (aDrawer, theLineWidth);
setWidth (CustomAspects (theShape), theLineWidth);
aDrawer->SetOwnWidth (theLineWidth);
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (AIS_Shaded);
@@ -311,12 +292,7 @@ void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
LoadRecomputable (AIS_Shaded);
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
if (aDrawer->HasOwnTransparency())
{
continue;
}
const Handle(Prs3d_Drawer)& aDrawer = anIter.Value();
if (aDrawer->HasOwnShadingAspect())
{
aDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
@@ -370,7 +346,7 @@ void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
//if (aDrawer->HasOwnMaterial()) continue;
if (aDrawer->HasOwnShadingAspect())
{
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), aDrawer->HasOwnTransparency());
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), Standard_False); // aDrawer->IsTransparent()
}
}
}
@@ -739,29 +715,13 @@ Standard_Boolean AIS_ColoredShape::dispatchColors (const Handle(AIS_ColoredDrawe
{
const TopoDS_Shape& aFace = aFaceIter.Value();
Handle(AIS_ColoredDrawer) aFaceDrawer;
if (aFace.ShapeType() != TopAbs_FACE
|| !theShapeDrawerMap.Find (aFace, aFaceDrawer))
{
continue;
}
if (aFaceDrawer->IsHidden())
if (aFace.ShapeType() == TopAbs_FACE
&& theShapeDrawerMap.Find (aFace, aFaceDrawer)
&& aFaceDrawer->IsHidden())
{
isClosedShell = Standard_False;
break;
}
else if (aFaceDrawer->HasOwnShadingAspect()
&& aFaceDrawer->ShadingAspect()->Aspect()->AlphaMode() != Graphic3d_AlphaMode_Opaque)
{
if (aFaceDrawer->ShadingAspect()->Aspect()->AlphaMode() != Graphic3d_AlphaMode_BlendAuto
|| aFaceDrawer->ShadingAspect()->Aspect()->FrontMaterial().Alpha() < 1.0f
|| (aFaceDrawer->ShadingAspect()->Aspect()->Distinguish()
&& aFaceDrawer->ShadingAspect()->Aspect()->BackMaterial().Alpha() < 1.0f))
{
isClosedShell = Standard_False;
break;
}
}
}
}

View File

@@ -56,10 +56,6 @@ public: //! @name sub-shape aspects
Standard_EXPORT void SetCustomColor (const TopoDS_Shape& theShape,
const Quantity_Color& theColor);
//! Customize transparency of specified sub-shape
Standard_EXPORT void SetCustomTransparency (const TopoDS_Shape& theShape,
Standard_Real theTransparency);
//! Customize line width of specified sub-shape
Standard_EXPORT void SetCustomWidth (const TopoDS_Shape& theShape,
const Standard_Real theLineWidth);

View File

@@ -416,14 +416,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
if (toUpdateViewer
&& theToRedrawOnUpdate)
{
if (theView->ComputedMode())
{
theView->Viewer()->Update();
}
else
{
theView->Viewer()->RedrawImmediate();
}
theView->Viewer()->Update();
}
return aStatus;

View File

@@ -335,10 +335,6 @@ void AIS_Trihedron::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManag
}
aGroup->AddPrimitiveArray (arrayOfPrimitives(aPart));
if (aPresentation->GetZLayer() != theStyle->ZLayer())
{
aPresentation->SetZLayer (theStyle->ZLayer());
}
aPresentation->Highlight (theStyle);
thePM->AddToImmediateList (aPresentation);
}

View File

@@ -19,8 +19,6 @@ AIS_BadEdgeFilter.cxx
AIS_BadEdgeFilter.hxx
AIS_C0RegularityFilter.cxx
AIS_C0RegularityFilter.hxx
AIS_CameraFrustum.cxx
AIS_CameraFrustum.hxx
AIS_Chamf2dDimension.cxx
AIS_Chamf2dDimension.hxx
AIS_Chamf2dDimension.lxx

View File

@@ -26,11 +26,9 @@ IMPLEMENT_STANDARD_RTTIEXT(Aspect_DisplayConnection,Standard_Transient)
Aspect_DisplayConnection::Aspect_DisplayConnection()
{
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
myDisplay = NULL;
myIsOwnDisplay = false;
OSD_Environment anEnv ("DISPLAY");
myDisplayName = anEnv.Value();
Init (NULL);
Init();
#endif
}
@@ -41,8 +39,7 @@ Aspect_DisplayConnection::Aspect_DisplayConnection()
Aspect_DisplayConnection::~Aspect_DisplayConnection()
{
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
if (myDisplay != NULL
&& myIsOwnDisplay)
if (myDisplay != NULL)
{
XCloseDisplay (myDisplay);
}
@@ -55,39 +52,38 @@ Aspect_DisplayConnection::~Aspect_DisplayConnection()
// purpose :
// =======================================================================
Aspect_DisplayConnection::Aspect_DisplayConnection (const TCollection_AsciiString& theDisplayName)
: myDisplay (NULL),
myIsOwnDisplay (false)
{
myDisplayName = theDisplayName;
Init (NULL);
Init();
}
// =======================================================================
// function : Aspect_DisplayConnection
// function : GetDisplay
// purpose :
// =======================================================================
Aspect_DisplayConnection::Aspect_DisplayConnection (Display* theDisplay)
: myDisplay (NULL),
myIsOwnDisplay (false)
Display* Aspect_DisplayConnection::GetDisplay()
{
Init (theDisplay);
return myDisplay;
}
// =======================================================================
// function : GetDisplayName
// purpose :
// =======================================================================
TCollection_AsciiString Aspect_DisplayConnection::GetDisplayName()
{
return myDisplayName;
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void Aspect_DisplayConnection::Init (Display* theDisplay)
void Aspect_DisplayConnection::Init()
{
if (myDisplay != NULL
&& myIsOwnDisplay)
{
XCloseDisplay (myDisplay);
}
myIsOwnDisplay = false;
myAtoms.Clear();
myDisplay = theDisplay != NULL ? theDisplay : XOpenDisplay (myDisplayName.ToCString());
myDisplay = XOpenDisplay (myDisplayName.ToCString());
myAtoms.Bind (Aspect_XA_DELETE_WINDOW, XInternAtom(myDisplay, "WM_DELETE_WINDOW", False));
if (myDisplay == NULL)
{
TCollection_AsciiString aMessage;
@@ -95,11 +91,6 @@ void Aspect_DisplayConnection::Init (Display* theDisplay)
aMessage += myDisplayName + "\"";
throw Aspect_DisplayConnectionDefinitionError(aMessage.ToCString());
}
else
{
myIsOwnDisplay = theDisplay == NULL;
myAtoms.Bind (Aspect_XA_DELETE_WINDOW, XInternAtom(myDisplay, "WM_DELETE_WINDOW", False));
}
}
// =======================================================================

View File

@@ -47,37 +47,25 @@ public:
//! screen_number - Specifies the screen to be used on that server. Optional variable.
Aspect_DisplayConnection (const TCollection_AsciiString& theDisplayName);
//! Constructor wrapping existing Display instance.
//! WARNING! it is a responsibility of application to keep this pointer
//! valid while Aspect_DisplayConnection is alive and to close Display when it is no more needed.
Aspect_DisplayConnection (Display* theDisplay);
//! @return pointer to Display structure that serves as the connection to the X server.
Display* GetDisplay() { return myDisplay; }
//! @return TRUE if X Display has been allocated by this class
Standard_Boolean IsOwnDisplay() const { return myIsOwnDisplay; }
Display* GetDisplay();
//! @return identifier(atom) for custom named property associated with windows that use current connection to X server.
Atom GetAtom (const Aspect_XAtom theAtom) const;
//! @return display name for this connection.
const TCollection_AsciiString& GetDisplayName() { return myDisplayName; }
TCollection_AsciiString GetDisplayName();
//! Open connection with display specified in myDisplayName class field
//! or takes theDisplay parameter when it is not NULL.
//! WARNING! When external Display is specified, it is a responsibility of application
//! to keep this pointer valid while Aspect_DisplayConnection is alive
//! and to close Display when it is no more needed.
//! @param theDisplay external pointer to allocated Display, or NULL if new connection should be created
void Init (Display* theDisplay);
private:
//! Open connection with display specified in myDisplayName class field.
void Init();
private:
Display* myDisplay;
NCollection_DataMap<Aspect_XAtom, Atom> myAtoms;
TCollection_AsciiString myDisplayName;
Standard_Boolean myIsOwnDisplay;
#endif
private:

View File

@@ -100,27 +100,3 @@ Unable to orient the shape correctly
.BOPAlgo_AlertUnknownShape
Shape is unknown for operation
.BOPAlgo_AlertNoPeriodicityRequired
No periodicity has been requested for the shape
.BOPAlgo_AlertUnableToTrim
Unable to trim the shape for making it periodic (BOP Common fails)
.BOPAlgo_AlertUnableToMakeIdentical
Unable to make the shape to look identical on opposite sides (Splitter fails)
.BOPAlgo_AlertUnableToRepeat
Unable to repeat the shape (Gluer fails)
.BOPAlgo_AlertMultiDimensionalArguments
Multi-dimensional arguments
.BOPAlgo_AlertUnableToMakePeriodic
Unable to make the shape periodic
.BOPAlgo_AlertUnableToGlue
Unable to glue the shapes
.BOPAlgo_AlertShapeIsNotPeriodic
The shape is not periodic

View File

@@ -30,7 +30,7 @@ DEFINE_SIMPLE_ALERT(BOPAlgo_AlertBuilderFailed)
//! The intersection of the arguments has failed
DEFINE_SIMPLE_ALERT(BOPAlgo_AlertIntersectionFailed)
//! More than one argument is provided
//! The type of Boolean Operation is not set
DEFINE_SIMPLE_ALERT(BOPAlgo_AlertMultipleArguments)
//! The Pave Filler (the intersection tool) has not been created
@@ -114,28 +114,4 @@ DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToOrientTheShape)
//! Shape is unknown for operation
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnknownShape)
//! No periodicity has been requested for the shape
DEFINE_SIMPLE_ALERT(BOPAlgo_AlertNoPeriodicityRequired)
//! Unable to trim the shape for making it periodic (BOP Common fails)
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToTrim)
//! Unable to make the shape to look identical on opposite sides (Splitter fails)
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToMakeIdentical)
//! Unable to repeat the shape (Gluer fails)
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToRepeat)
//! Multi-dimensional arguments
DEFINE_SIMPLE_ALERT(BOPAlgo_AlertMultiDimensionalArguments)
//! Unable to make the shape periodic
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToMakePeriodic)
//! Unable to glue the shapes
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToGlue)
//! The shape is not periodic
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertShapeIsNotPeriodic)
#endif // _BOPAlgo_Alerts_HeaderFile

View File

@@ -102,28 +102,4 @@ static const char BOPAlgo_BOPAlgo_msg[] =
"Unable to orient the shape correctly\n"
"\n"
".BOPAlgo_AlertUnknownShape\n"
"Shape is unknown for operation\n"
"\n"
".BOPAlgo_AlertNoPeriodicityRequired\n"
"No periodicity has been requested for the shape\n"
"\n"
".BOPAlgo_AlertUnableToTrim\n"
"Unable to trim the shape for making it periodic (BOP Common fails)\n"
"\n"
".BOPAlgo_AlertUnableToMakeIdentical\n"
"Unable to make the shape to look identical on opposite sides (Splitter fails)\n"
"\n"
".BOPAlgo_AlertUnableToRepeat\n"
"Unable to repeat the shape (Gluer fails)\n"
"\n"
".BOPAlgo_AlertMultiDimensionalArguments\n"
"Multi-dimensional arguments\n"
"\n"
".BOPAlgo_AlertUnableToMakePeriodic\n"
"Unable to make the shape periodic\n"
"\n"
".BOPAlgo_AlertUnableToGlue\n"
"Unable to glue the shapes\n"
"\n"
".BOPAlgo_AlertShapeIsNotPeriodic\n"
"The shape is not periodic\n";
"Shape is unknown for operation\n";

View File

@@ -112,35 +112,32 @@ void BOPAlgo_Builder::FillImagesVertices()
//function : BuildResult
//purpose :
//=======================================================================
void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType)
void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType)
{
// Fence map
TopTools_MapOfShape aMFence;
// Iterate on all arguments of given type
// and add their images into result
TopTools_ListIteratorOfListOfShape aItA(myArguments);
for (; aItA.More(); aItA.Next())
{
const TopoDS_Shape& aS = aItA.Value();
if (aS.ShapeType() != theType)
continue;
// Get images
const TopTools_ListOfShape* pLSIm = myImages.Seek(aS);
if (!pLSIm)
{
// No images -> add the argument shape itself into result
if (aMFence.Add(aS))
BRep_Builder().Add(myShape, aS);
}
else
{
// Add images of the argument shape into result
TopTools_ListIteratorOfListOfShape aItIm(*pLSIm);
for (; aItIm.More(); aItIm.Next())
{
const TopoDS_Shape& aSIm = aItIm.Value();
if (aMFence.Add(aSIm))
BRep_Builder().Add(myShape, aSIm);
TopAbs_ShapeEnum aType;
BRep_Builder aBB;
TopTools_MapOfShape aM;
TopTools_ListIteratorOfListOfShape aIt, aItIm;
//
aIt.Initialize(myArguments);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aType=aS.ShapeType();
if (aType==theType) {
if (myImages.IsBound(aS)){
const TopTools_ListOfShape& aLSIm=myImages.Find(aS);
aItIm.Initialize(aLSIm);
for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aSIm=aItIm.Value();
if (aM.Add(aSIm)) {
aBB.Add(myShape, aSIm);
}
}
}
else {
if (aM.Add(aS)) {
aBB.Add(myShape, aS);
}
}
}
}

View File

@@ -1,333 +0,0 @@
// Created on: 2018-03-29
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BOPAlgo_MakeConnected.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <BOPAlgo_Builder.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BRep_Builder.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Iterator.hxx>
//=======================================================================
//function : Perform
//purpose : Makes the shapes connected
//=======================================================================
void BOPAlgo_MakeConnected::Perform()
{
// Check the input data
CheckData();
if (HasErrors())
return;
if (myHistory.IsNull())
myHistory = new BRepTools_History;
// Glue the arguments
MakeConnected();
if (HasErrors())
return;
// Perform material associations for the faces
AssociateMaterials();
if (HasErrors())
return;
}
//=======================================================================
//function : CheckData
//purpose : Check the validity of input data
//=======================================================================
void BOPAlgo_MakeConnected::CheckData()
{
// Check the number of arguments
if (myArguments.IsEmpty())
{
// Not enough arguments
AddError(new BOPAlgo_AlertTooFewArguments());
return;
}
// Check that all shapes in arguments are of the same type
// Extract the shapes from the compound arguments
TopTools_ListOfShape aLA;
// Fence map
TopTools_MapOfShape aMFence;
TopTools_ListIteratorOfListOfShape itLA(myArguments);
for (; itLA.More(); itLA.Next())
BOPAlgo_Tools::TreatCompound(itLA.Value(), aMFence, aLA);
if (aLA.IsEmpty())
{
// It seems that all argument shapes are empty compounds
AddError(new BOPAlgo_AlertTooFewArguments());
return;
}
// Check dimensions of the extracted non-compound shapes
itLA.Initialize(aLA);
Standard_Integer iDim = BOPTools_AlgoTools::Dimension(itLA.Value());
for (itLA.Next(); itLA.More(); itLA.Next())
{
if (iDim != BOPTools_AlgoTools::Dimension(itLA.Value()))
{
// The arguments are of different type
AddError(new BOPAlgo_AlertMultiDimensionalArguments());
return;
}
}
}
//=======================================================================
//function : MakeConnected
//purpose : Glues the argument shapes
//=======================================================================
void BOPAlgo_MakeConnected::MakeConnected()
{
// Initialize the history
if (myGlueHistory.IsNull())
myGlueHistory = new BRepTools_History;
if (myArguments.Extent() == 1)
{
// No need to glue the single shape
myShape = myArguments.First();
}
else
{
// Glue the shapes
BOPAlgo_Builder aGluer;
aGluer.SetArguments(myArguments);
aGluer.SetGlue(BOPAlgo_GlueShift);
aGluer.SetRunParallel(myRunParallel);
aGluer.SetNonDestructive(Standard_True);
aGluer.Perform();
if (aGluer.HasErrors())
{
// Unable to glue the shapes
TopoDS_Compound aCW;
BRep_Builder().MakeCompound(aCW);
for (TopTools_ListIteratorOfListOfShape it(myArguments); it.More(); it.Next())
BRep_Builder().Add(aCW, it.Value());
AddError(new BOPAlgo_AlertUnableToGlue(aCW));
return;
}
myShape = aGluer.Shape();
// Save the gluing history
myGlueHistory->Merge(aGluer.Arguments(), aGluer);
myHistory->Merge(myGlueHistory);
}
// Keep the glued shape
myGlued = myShape;
// Fill the map of origins
FillOrigins();
}
//=======================================================================
//function : FillOrigins
//purpose : Fills the map of origins
//=======================================================================
void BOPAlgo_MakeConnected::FillOrigins()
{
myOrigins.Clear();
// Map the history shapes of the arguments
if (myAllInputsMap.IsEmpty())
{
TopTools_ListIteratorOfListOfShape itLA(myArguments);
for (; itLA.More(); itLA.Next())
TopExp::MapShapes(itLA.Value(), myAllInputsMap);
}
const Standard_Integer aNbS = myAllInputsMap.Extent();
for (Standard_Integer i = 1; i <= aNbS; ++i)
{
const TopoDS_Shape& aS = myAllInputsMap(i);
if (!BRepTools_History::IsSupportedType(aS))
continue;
// Get Modified & Generated shapes
for (Standard_Integer j = 0; j < 2; ++j)
{
const TopTools_ListOfShape& aLH = !j ? myHistory->Modified(aS) : myHistory->Generated(aS);
TopTools_ListIteratorOfListOfShape itLH(aLH);
for (; itLH.More(); itLH.Next())
{
const TopoDS_Shape& aHS = itLH.Value();
TopTools_ListOfShape* pLOr = myOrigins.ChangeSeek(aHS);
if (!pLOr)
pLOr = myOrigins.Bound(aHS, TopTools_ListOfShape());
if (!pLOr->Contains(aS))
pLOr->Append(aS);
}
}
}
}
//=======================================================================
//function : AssociateMaterials
//purpose : Associates the materials for the border elements
//=======================================================================
void BOPAlgo_MakeConnected::AssociateMaterials()
{
myMaterials.Clear();
// Extract all non-compound shapes from the result
TopTools_ListOfShape aLShapes;
TopTools_MapOfShape aMFence;
BOPAlgo_Tools::TreatCompound(myShape, aMFence, aLShapes);
if (aLShapes.IsEmpty())
return;
// Define the element type and the material type
TopAbs_ShapeEnum anElemType;
const TopAbs_ShapeEnum aMaterialType = aLShapes.First().ShapeType();
if (aMaterialType == TopAbs_SOLID || aMaterialType == TopAbs_COMPSOLID)
anElemType = TopAbs_FACE;
else if (aMaterialType == TopAbs_FACE || aMaterialType == TopAbs_SHELL)
anElemType = TopAbs_EDGE;
else if (aMaterialType == TopAbs_EDGE || aMaterialType == TopAbs_WIRE)
anElemType = TopAbs_VERTEX;
else
return;
TopTools_ListIteratorOfListOfShape itLS(aLShapes);
for (; itLS.More(); itLS.Next())
{
const TopoDS_Shape& aS = itLS.Value();
const TopTools_ListOfShape& aLOr = GetOrigins(aS);
const TopoDS_Shape& aSOr = aLOr.IsEmpty() ? aS : aLOr.First();
TopExp_Explorer anExp(aS, anElemType);
for (; anExp.More(); anExp.Next())
{
const TopoDS_Shape& anElement = anExp.Current();
TopTools_ListOfShape* pLM = myMaterials.ChangeSeek(anElement);
if (!pLM)
pLM = myMaterials.Bound(anElement, TopTools_ListOfShape());
pLM->Append(aSOr);
}
}
}
//=======================================================================
//function : Update
//purpose : Updates the history, material associations and origins map
// after periodicity operations
//=======================================================================
void BOPAlgo_MakeConnected::Update()
{
// Update history
myHistory->Clear();
if (!myGlueHistory.IsNull())
myHistory->Merge(myGlueHistory);
if (!myPeriodicityMaker.History().IsNull())
myHistory->Merge(myPeriodicityMaker.History());
// Fill the map of origins
FillOrigins();
// Update the material associations after making the shape periodic
AssociateMaterials();
}
//=======================================================================
//function : MakePeriodic
//purpose : Makes the shape periodic according to the given parameters
//=======================================================================
void BOPAlgo_MakeConnected::MakePeriodic(const BOPAlgo_MakePeriodic::PeriodicityParams& theParams)
{
if (HasErrors())
return;
// Make the shape periodic
myPeriodicityMaker.Clear();
myPeriodicityMaker.SetShape(myGlued);
myPeriodicityMaker.SetPeriodicityParameters(theParams);
myPeriodicityMaker.SetRunParallel(myRunParallel);
myPeriodicityMaker.Perform();
if (myPeriodicityMaker.HasErrors())
{
// Add warning informing the user that periodicity with
// given parameters is not possible
AddWarning(new BOPAlgo_AlertUnableToMakePeriodic(myShape));
return;
}
myShape = myPeriodicityMaker.Shape();
// Update history, materials, origins
Update();
}
//=======================================================================
//function : RepeatShape
//purpose : Repeats the shape in the given direction given number of times
//=======================================================================
void BOPAlgo_MakeConnected::RepeatShape(const Standard_Integer theDirectionID,
const Standard_Integer theTimes)
{
if (HasErrors())
return;
if (myPeriodicityMaker.Shape().IsNull() || myPeriodicityMaker.HasErrors())
{
// The shape has not been made periodic yet
AddWarning(new BOPAlgo_AlertShapeIsNotPeriodic(myShape));
return;
}
// Repeat the shape
myShape = myPeriodicityMaker.RepeatShape(theDirectionID, theTimes);
// Update history, materials, origins
Update();
}
//=======================================================================
//function : ClearRepetitions
//purpose : Clears the repetitions performed on the periodic shape
// keeping the shape periodic
//=======================================================================
void BOPAlgo_MakeConnected::ClearRepetitions()
{
if (HasErrors())
return;
if (myPeriodicityMaker.Shape().IsNull() || myPeriodicityMaker.HasErrors())
{
// The shape has not been made periodic yet
AddWarning(new BOPAlgo_AlertShapeIsNotPeriodic(myShape));
return;
}
// Clear repetitions
myPeriodicityMaker.ClearRepetitions();
myShape = myPeriodicityMaker.Shape();
// Update history, materials, origins
Update();
}

View File

@@ -1,338 +0,0 @@
// Created on: 2018-03-29
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BOPAlgo_MakeConnected_HeaderFile
#define _BOPAlgo_MakeConnected_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <BOPAlgo_Options.hxx>
#include <BOPAlgo_MakePeriodic.hxx>
#include <BRepTools_History.hxx>
#include <NCollection_DataMap.hxx>
#include <TopTools_OrientedShapeMapHasher.hxx>
//! BOPAlgo_MakeConnected is the algorithm for making the touching
//! shapes connected or glued, i.e. for making the coinciding geometries
//! be topologically shared among the shapes.
//!
//! The input shapes should be of the same dimension, otherwise
//! the gluing will not make any sense.
//!
//! After the shapes are made connected, the border elements of input shapes
//! are associated with the shapes to which they belong. At that, the orientation of
//! the border element in the shape is taken into account.
//! The associations are made for the following types:
//! - For input SOLIDS, the resulting FACES are associated with the input solids;
//! - For input FACES, the resulting EDGES are associated with the input faces;
//! - For input EDGES, the resulting VERTICES are associated with the input edges.
//!
//! In frames of this algorithm the input shapes are called materials,
//! and the association process is called the material association.
//! The material association allows finding the coinciding elements for the opposite
//! input shapes. These elements will be associated to at least two materials.
//!
//! After making the shapes connected, it is possible to make the connected
//! shape periodic using the *BOPAlgo_MakePeriodic* tool.
//! After making the shape periodic, the material associations will be updated
//! to correspond to the actual state of the result shape.
//! Repetition of the periodic shape is also possible here. Material associations
//! are not going to be lost.
//!
//! The algorithm supports history of shapes modification, thus it is possible
//! to track the modification of the input shapes during the operations.
//! Additionally to standard history methods, the algorithm provides the
//! the method *GetOrigins()* which allows obtaining the input shapes from which
//! the resulting shape has been created.
//!
//! The algorithm supports the parallel processing mode, which allows faster
//! completion of the operations.
//!
//! The algorithm returns the following Error/Warning messages:
//! - *BOPAlgo_AlertTooFewArguments* - error alert is given on the attempt to run
//! the algorithm without the arguments;
//! - *BOPAlgo_AlertMultiDimensionalArguments* - error alert is given on the attempt
//! to run the algorithm on multi-dimensional arguments;
//! - *BOPAlgo_AlertUnableToGlue* - error alert is given if the gluer algorithm
//! is unable to glue the given arguments;
//! - *BOPAlgo_AlertUnableToMakePeriodic* - warning alert is given if the periodicity
//! maker is unable to make the connected shape periodic with given options;
//! - *BOPAlgo_AlertShapeIsNotPeriodic* - warning alert is given on the attempt to
//! repeat the shape before making it periodic.
//!
//! Here is the example of usage of the algorithm:
//! ~~~~
//! TopTools_ListOfShape anArguments = ...; // Shapes to make connected
//! Standard_Boolean bRunParallel = ...; // Parallel processing mode
//!
//! BOPAlgo_MakeConnected aMC; // Tool for making the shapes connected
//! aMC.SetArguments(anArguments); // Set the shapes
//! aMC.SetRunParallel(bRunParallel); // Set parallel processing mode
//! aMC.Perform(); // Perform the operation
//!
//! if (aMC.HasErrors()) // Check for the errors
//! {
//! // errors treatment
//! Standard_SStream aSStream;
//! aMC.DumpErrors(aSStream);
//! return;
//! }
//! if (aMC.HasWarnings()) // Check for the warnings
//! {
//! // warnings treatment
//! Standard_SStream aSStream;
//! aMC.DumpWarnings(aSStream);
//! }
//!
//! const TopoDS_Shape& aGluedShape = aMC.Shape(); // Connected shape
//!
//! // Checking material associations
//! TopAbs_ShapeEnum anElemType = ...; // Type of border element
//! TopExp_Explorer anExp(anArguments.First(), anElemType);
//! for (; anExp.More(); anExp.Next())
//! {
//! const TopoDS_Shape& anElement = anExp.Current();
//! const TopTools_ListOfShape& aNegativeM = aMC.MaterialsOnNegativeSide(anElement);
//! const TopTools_ListOfShape& aPositiveM = aMC.MaterialsOnPositiveSide(anElement);
//! }
//!
//! // Making the connected shape periodic
//! BOPAlgo_MakePeriodic::PeriodicityParams aParams = ...; // Options for periodicity of the connected shape
//! aMC.MakePeriodic(aParams);
//!
//! // Shape repetition after making it periodic
//! // Check if the shape has been made periodic successfully
//! if (aMC.PeriodicityTool().HasErrors())
//! {
//! // Periodicity maker error treatment
//! }
//!
//! // Shape repetition in periodic directions
//! aMC.RepeatShape(0, 2);
//!
//! const TopoDS_Shape& aShape = aMC.PeriodicShape(); // Periodic and repeated shape
//! ~~~~
//!
class BOPAlgo_MakeConnected : public BOPAlgo_Options
{
public:
DEFINE_STANDARD_ALLOC
public: //! @name Constructor
//! Empty constructor
BOPAlgo_MakeConnected() : BOPAlgo_Options()
{
}
public: //! @name Setters for the shapes to make connected
//! Sets the shape for making them connected.
//! @param theArgs [in] The arguments for the operation.
void SetArguments(const TopTools_ListOfShape& theArgs)
{
myArguments = theArgs;
}
//! Adds the shape to the arguments.
//! @param theS [in] One of the argument shapes.
void AddArgument(const TopoDS_Shape& theS)
{
myArguments.Append(theS);
}
//! Returns the list of arguments of the operation.
const TopTools_ListOfShape& Arguments() const
{
return myArguments;
}
public: //! @name Performing the operations
//! Performs the operation, i.e. makes the input shapes connected.
Standard_EXPORT void Perform();
public: //! @name Shape periodicity & repetition
//! Makes the connected shape periodic.
//! Repeated calls of this method overwrite the previous calls
//! working with the basis connected shape.
//! @param theParams [in] Periodic options.
Standard_EXPORT void MakePeriodic(const BOPAlgo_MakePeriodic::PeriodicityParams& theParams);
//! Performs repetition of the periodic shape in specified direction
//! required number of times.
//! @param theDirectionID [in] The direction's ID (0 for X, 1 for Y, 2 for Z);
//! @param theTimes [in] Requested number of repetitions (sign of the value defines
//! the side of the repetition direction (positive or negative)).
Standard_EXPORT void RepeatShape(const Standard_Integer theDirectionID,
const Standard_Integer theTimes);
//! Clears the repetitions performed on the periodic shape,
//! keeping the shape periodic.
Standard_EXPORT void ClearRepetitions();
//! Returns the periodicity tool.
const BOPAlgo_MakePeriodic& PeriodicityTool() const
{
return myPeriodicityMaker;
}
public: //! @name Material transitions
//! Returns the original shapes which images contain the
//! the given shape with FORWARD orientation.
//! @param theS [in] The shape for which the materials are necessary.
const TopTools_ListOfShape& MaterialsOnPositiveSide(const TopoDS_Shape& theS)
{
const TopTools_ListOfShape* pLM = myMaterials.Seek(theS.Oriented(TopAbs_FORWARD));
return (pLM ? *pLM : EmptyList());
}
//! Returns the original shapes which images contain the
//! the given shape with REVERSED orientation.
//! @param theS [in] The shape for which the materials are necessary.
const TopTools_ListOfShape& MaterialsOnNegativeSide(const TopoDS_Shape& theS)
{
const TopTools_ListOfShape* pLM = myMaterials.Seek(theS.Oriented(TopAbs_REVERSED));
return (pLM ? *pLM : EmptyList());
}
public: //! @name History methods
//! Returns the history of operations
const Handle(BRepTools_History)& History() const
{
return myHistory;
}
//! Returns the list of shapes modified from the given shape.
//! @param theS [in] The shape for which the modified shapes are necessary.
const TopTools_ListOfShape& GetModified(const TopoDS_Shape& theS)
{
return (myHistory.IsNull() ? EmptyList() : myHistory->Modified(theS));
}
//! Returns the list of original shapes from which the current shape has been created.
//! @param theS [in] The shape for which the origins are necessary.
const TopTools_ListOfShape& GetOrigins(const TopoDS_Shape& theS)
{
const TopTools_ListOfShape* pLOr = myOrigins.Seek(theS);
return (pLOr ? *pLOr : EmptyList());
}
public: //! @name Getting the result shapes
//! Returns the resulting connected shape
const TopoDS_Shape& Shape() const
{
return myGlued;
}
//! Returns the resulting periodic & repeated shape
const TopoDS_Shape& PeriodicShape() const
{
return myShape;
}
public: //! @name Clearing the contents of the algorithm from previous runs
//! Clears the contents of the algorithm.
void Clear()
{
BOPAlgo_Options::Clear();
myArguments.Clear();
myAllInputsMap.Clear();
myPeriodicityMaker.Clear();
myOrigins.Clear();
myMaterials.Clear();
if (!myGlueHistory.IsNull())
myGlueHistory->Clear();
if (!myHistory.IsNull())
myHistory->Clear();
myGlued.Nullify();
myShape.Nullify();
}
protected: //! @name Protected methods performing the operation
//! Checks the validity of input data.
Standard_EXPORT void CheckData();
//! Makes the argument shapes connected (or glued).
Standard_EXPORT void MakeConnected();
//! Associates the materials transitions for the border elements:
//! - For input Solids, associates the Faces to Solids;
//! - For input Faces, associates the Edges to Faces;
//! - For input Edges, associates the Vertices to Edges.
Standard_EXPORT void AssociateMaterials();
//! Fills the map of origins
Standard_EXPORT void FillOrigins();
//! Updates the history, material associations, origins map
//! after periodicity operations.
Standard_EXPORT void Update();
private:
//! Returns an empty list.
const TopTools_ListOfShape& EmptyList()
{
static const TopTools_ListOfShape anEmptyList;
return anEmptyList;
}
protected: //! @name Fields
// Inputs
TopTools_ListOfShape myArguments; //!< Input shapes for making them connected
TopTools_IndexedMapOfShape myAllInputsMap; //!< Map of all BRep sub-elements of the input shapes
// Tools
BOPAlgo_MakePeriodic myPeriodicityMaker; //!< Tool for making the shape periodic
// Results
NCollection_DataMap
<TopoDS_Shape,
TopTools_ListOfShape,
TopTools_OrientedShapeMapHasher> myMaterials; //!< Map of the materials associations
//! for the border elements
TopTools_DataMapOfShapeListOfShape myOrigins; //!< Map of origins
//! (allows tracking the shape's ancestors)
Handle(BRepTools_History) myGlueHistory; //!< Gluing History
Handle(BRepTools_History) myHistory; //!< Final History of shapes modifications
//! (including making the shape periodic and repetitions)
TopoDS_Shape myGlued; //!< The resulting connected (glued) shape
TopoDS_Shape myShape; //!< The resulting shape
};
#endif // _BOPAlgo_MakeConnected_HeaderFile

View File

@@ -1,617 +0,0 @@
// Created on: 2018-03-16
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BOPAlgo_MakePeriodic.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <Bnd_Box.hxx>
#include <BOPAlgo_Builder.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Splitter.hxx>
#include <BRepBndLib.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <gp_Pln.hxx>
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
// Periodic/Trim/Repeat directions
static const gp_Dir MY_DIRECTIONS[3] = { gp::DX(),
gp::DY(),
gp::DZ() };
//=======================================================================
//function : Perform
//purpose : Performs the operation
//=======================================================================
void BOPAlgo_MakePeriodic::Perform()
{
// Check the validity of input data
CheckData();
if (HasErrors())
return;
// Trim the shape to fit to the required period in
// required periodic directions
Trim();
if (HasErrors())
return;
// Make the shape identical on the opposite sides in
// required periodic directions
MakeIdentical();
if (HasErrors())
return;
}
//=======================================================================
//function : CheckData
//purpose : Checks the validity of input data
//=======================================================================
void BOPAlgo_MakePeriodic::CheckData()
{
if ( (!IsXPeriodic() || XPeriod() < Precision::Confusion())
&& (!IsYPeriodic() || YPeriod() < Precision::Confusion())
&& (!IsZPeriodic() || ZPeriod() < Precision::Confusion()))
{
// Add error informing the user that no periodicity is required
// or no valid period is set.
AddError(new BOPAlgo_AlertNoPeriodicityRequired());
return;
}
}
//=======================================================================
//function : AddToShape
//purpose : Adds the shape <theWhat> to the shape <theWhere>
//=======================================================================
static void AddToShape(const TopoDS_Shape& theWhat,
TopoDS_Shape& theWhere)
{
if (theWhere.IsNull())
BRep_Builder().MakeCompound(TopoDS::Compound(theWhere));
BRep_Builder().Add(theWhere, theWhat);
}
//=======================================================================
//function : AddToShape
//purpose : Adds the shape in the list <theLWhat> to the shape <theWhere>
//=======================================================================
static void AddToShape(const TopTools_ListOfShape& theLWhat,
TopoDS_Shape& theWhere)
{
TopTools_ListIteratorOfListOfShape it(theLWhat);
for (; it.More(); it.Next())
AddToShape(it.Value(), theWhere);
}
//=======================================================================
//function : Trim
//purpose : Make the trim of the shape to fit to the periodic bounds.
//=======================================================================
void BOPAlgo_MakePeriodic::Trim()
{
// Check if trim is required at all
if (IsInputXTrimmed() &&
IsInputYTrimmed() &&
IsInputZTrimmed())
return;
// Compute bounding box for the shape to use it as a starting
// volume for trimming. If required, the volume will be modified
// to the requested trimming size in requested directions.
Bnd_Box aBox;
BRepBndLib::Add(myInputShape, aBox);
// Enlarge box to avoid overlapping with the shape
aBox.Enlarge(0.1 * sqrt(aBox.SquareExtent()));
// Get Corner points of the bounding box
gp_Pnt aPMin = aBox.CornerMin();
gp_Pnt aPMax = aBox.CornerMax();
// Update corner points according to the requested trim parameters
for (Standard_Integer i = 0; i < 3; ++i)
{
if (IsInputTrimmed(i))
continue;
aPMin.SetCoord(i + 1, PeriodFirst(i));
aPMax.SetCoord(i + 1, PeriodFirst(i) + Period(i));
}
// Build Trimming solid using corner points
BRepPrimAPI_MakeBox aMBox(aPMin, aPMax);
const TopoDS_Shape& aTrimBox = aMBox.Solid();
// Perform trimming of the shape by solid
BRepAlgoAPI_Common aCommon;
// Set Object
TopTools_ListOfShape anObj;
anObj.Append(myInputShape);
aCommon.SetArguments(anObj);
// Set Tool
TopTools_ListOfShape aTool;
aTool.Append(aTrimBox);
aCommon.SetTools(aTool);
// Set the parallel processing mode
aCommon.SetRunParallel(myRunParallel);
// Build
aCommon.Build();
if (aCommon.HasErrors())
{
// Unable to trim the shape
// Merge errors from Common operation
myReport->Merge(aCommon.GetReport());
// Add new error saving the shapes for analysis
TopoDS_Compound aWS;
AddToShape(myInputShape, aWS);
AddToShape(aTrimBox, aWS);
AddError(new BOPAlgo_AlertUnableToTrim(aWS));
return;
}
// Get the trimmed shape
myShape = aCommon.Shape();
// Fill the History for the object only
mySplitHistory = new BRepTools_History();
mySplitHistory->Merge(anObj, aCommon);
}
//=======================================================================
//function : MakeIdentical
//purpose : Make the shape look the same on the opposite sides in the
// required periodic directions.
//=======================================================================
void BOPAlgo_MakePeriodic::MakeIdentical()
{
if (myShape.IsNull())
myShape = myInputShape;
if (mySplitHistory.IsNull())
mySplitHistory = new BRepTools_History;
// Split the negative side of the shape with the geometry
// located on the positive side
SplitNegative();
if (HasErrors())
return;
// Split the positive side of the shape with the geometry
// located on the negative side.
// Make sure that the opposite sides have identical geometries.
// Make associations between identical opposite shapes.
SplitPositive();
myHistory = new BRepTools_History();
myHistory->Merge(mySplitHistory);
}
//=======================================================================
//function : SplitNegative
//purpose : Split the negative side of the shape with the geometry
// located on the positive side.
//=======================================================================
void BOPAlgo_MakePeriodic::SplitNegative()
{
// Copy geometry from positive side of the shape to the negative first.
// So, translate the shape in negative periodic directions only.
//
// To avoid conflicts when copying geometries from positive periodic sides
// perform split of each periodic side in a separate operation.
for (Standard_Integer i = 0; i < 3; ++i)
{
if (!IsPeriodic(i))
continue;
// Translate the shape to the negative side
gp_Trsf aNegTrsf;
aNegTrsf.SetTranslationPart(Period(i) * MY_DIRECTIONS[i].Reversed());
BRepBuilderAPI_Transform aNegT(myShape, aNegTrsf, Standard_False);
// Split the negative side of the shape.
TopTools_ListOfShape aTools;
aTools.Append(aNegT.Shape());
SplitShape(aTools, mySplitHistory);
}
}
//=======================================================================
//function : AddTwin
//purpose : Associates the shape <theS> with the shape <theTwin> in the map.
//=======================================================================
static void AddTwin(const TopoDS_Shape& theS,
const TopoDS_Shape& theTwin,
TopTools_DataMapOfShapeListOfShape& theMap)
{
TopTools_ListOfShape *aTwins = theMap.ChangeSeek(theS);
if (!aTwins)
{
theMap.Bound(theS, TopTools_ListOfShape())->Append(theTwin);
return;
}
// Check if the twin shape is not yet present in the list
TopTools_ListIteratorOfListOfShape itLT(*aTwins);
for (; itLT.More(); itLT.Next())
{
if (theTwin.IsSame(itLT.Value()))
break;
}
if (!itLT.More())
aTwins->Append(theTwin);
}
//=======================================================================
//function : SplitPositive
//purpose : Split the positive side of the shape with the geometry of the
// negative side. Associate the identical opposite sub-shapes.
//=======================================================================
void BOPAlgo_MakePeriodic::SplitPositive()
{
// Prepare map of the sub-shapes of the input shape to make
// associations of the opposite shapes
TopTools_IndexedMapOfShape aSubShapesMap;
TopExp::MapShapes(myShape, aSubShapesMap);
const Standard_Integer aNbS = aSubShapesMap.Extent();
// Translate the shape to the positive periodic directions to make the
// shapes look identical on the opposite sides.
TopTools_ListOfShape aTools;
// Remember the history of shapes translation
TopTools_IndexedDataMapOfShapeListOfShape aTranslationHistMap;
// Make translations for all periodic directions
for (Standard_Integer i = 0; i < 3; ++i)
{
if (!IsPeriodic(i))
continue;
// Translate the shape to the positive side
gp_Trsf aPosTrsf;
aPosTrsf.SetTranslationPart(Period(i) * MY_DIRECTIONS[i]);
BRepBuilderAPI_Transform aTranslator(myShape, aPosTrsf, Standard_False);
aTools.Append(aTranslator.Shape());
// Fill the translation history map
for (Standard_Integer j = 1; j <= aNbS; ++j)
{
const TopoDS_Shape& aS = aSubShapesMap(j);
if (BRepTools_History::IsSupportedType(aS))
{
const TopTools_ListOfShape& aSM = aTranslator.Modified(aS);
TopTools_ListOfShape* pTS = aTranslationHistMap.ChangeSeek(aS);
if (!pTS)
pTS = &aTranslationHistMap(aTranslationHistMap.Add(aS, TopTools_ListOfShape()));
pTS->Append(aSM.First());
}
}
}
// Keep the split shape history and history of tools modifications
// during the split for making association of the opposite identical shapes
Handle(BRepTools_History) aSplitShapeHist = new BRepTools_History,
aSplitToolsHist = new BRepTools_History;
// Split the positive side of the shape
SplitShape(aTools, aSplitShapeHist, aSplitToolsHist);
if (HasErrors())
return;
mySplitHistory->Merge(aSplitShapeHist);
// Make associations between identical opposite sub-shapes
const Standard_Integer aNbSH = aTranslationHistMap.Extent();
for (Standard_Integer i = 1; i <= aNbSH; ++i)
{
const TopoDS_Shape* pS = &aTranslationHistMap.FindKey(i);
const TopTools_ListOfShape& aSIm = aSplitShapeHist->Modified(*pS);
if (aSIm.Extent() == 1)
pS = &aSIm.First();
else if (aSIm.Extent() > 1)
continue;
const TopTools_ListOfShape& aLTranslated = aTranslationHistMap(i);
TopTools_ListIteratorOfListOfShape itLT(aLTranslated);
for (; itLT.More(); itLT.Next())
{
const TopoDS_Shape& aT = itLT.Value();
// Get shapes modifications during the split
const TopTools_ListOfShape& aTSplits = aSplitToolsHist->Modified(aT);
// Associate the shapes to each other
TopTools_ListIteratorOfListOfShape itSp(aTSplits);
for (; itSp.More(); itSp.Next())
{
const TopoDS_Shape& aSp = itSp.Value();
AddTwin(*pS, aSp, myTwins);
AddTwin(aSp, *pS, myTwins);
}
}
}
}
//=======================================================================
//function : SplitShape
//purpose : Splits the shape by the given tools
//=======================================================================
void BOPAlgo_MakePeriodic::SplitShape(const TopTools_ListOfShape& theTools,
Handle(BRepTools_History) theSplitShapeHistory,
Handle(BRepTools_History) theSplitToolsHistory)
{
// Make sure that the geometry from the tools will be copied to the split
// shape. For that, the tool shapes should be given to the Boolean Operations
// algorithm before the shape itself. This will make all coinciding parts
// use the geometry of the first argument.
// Intersection tool for passing ordered arguments
BOPAlgo_PaveFiller anIntersector;
anIntersector.SetArguments(theTools);
// Add the shape
anIntersector.AddArgument(myShape);
// Use gluing to speed-up intersections
anIntersector.SetGlue(BOPAlgo_GlueShift);
// Use safe input mode, to avoid reusing geometry of the shape
anIntersector.SetNonDestructive(Standard_True);
// Set parallel processing mode
anIntersector.SetRunParallel(myRunParallel);
// Perform Intersection of the arguments
anIntersector.Perform();
// Check for the errors
if (anIntersector.HasErrors())
{
// Unable to split the shape on opposite sides
// Copy the intersection errors
myReport->Merge(anIntersector.GetReport());
// Add new error saving the shapes for analysis
TopoDS_Compound aWS;
AddToShape(theTools, aWS);
AddToShape(myShape, aWS);
AddError(new BOPAlgo_AlertUnableToMakeIdentical(aWS));
return;
}
// Perform the splitting of the shape with the precomputed intersection results
BRepAlgoAPI_Splitter aSplitter(anIntersector);
// Set Object
TopTools_ListOfShape anObj;
anObj.Append(myShape);
aSplitter.SetArguments(anObj);
// Set Tools
aSplitter.SetTools(theTools);
// Use Gluing
aSplitter.SetGlue(BOPAlgo_GlueShift);
// Set parallel processing mode
aSplitter.SetRunParallel(myRunParallel);
// Perform splitting
aSplitter.Build();
// Check for the errors
if (aSplitter.HasErrors())
{
// Unable to split the shape on opposite sides
// Copy the splitter errors
myReport->Merge(aSplitter.GetReport());
// Add new error saving the shape for analysis
TopoDS_Compound aWS;
AddToShape(theTools, aWS);
AddToShape(myShape, aWS);
AddError(new BOPAlgo_AlertUnableToMakeIdentical(aWS));
return;
}
// Get the split shape
myShape = aSplitter.Shape();
// Remember the split history
if (!theSplitShapeHistory.IsNull())
theSplitShapeHistory->Merge(anObj, aSplitter);
if (!theSplitToolsHistory.IsNull())
theSplitToolsHistory->Merge(theTools, aSplitter);
}
//=======================================================================
//function : RepeatShape
//purpose : Repeats the shape in the required periodic direction
//=======================================================================
const TopoDS_Shape& BOPAlgo_MakePeriodic::RepeatShape(const Standard_Integer theDir,
const Standard_Integer theTimes)
{
if (myRepeatedShape.IsNull())
myRepeatedShape = myShape;
if (!IsPeriodic(theDir))
return myRepeatedShape;
if (theTimes == 0)
return myRepeatedShape;
// Get the shape's period in the required direction
const Standard_Integer id = BOPAlgo_MakePeriodic::ToDirectionID(theDir);
if (myRepeatPeriod[id] < Precision::Confusion())
myRepeatPeriod[id] = Period(id);
const Standard_Real aPeriod = myRepeatPeriod[id];
// Coefficient to define in which direction the repetition will be performed:
// theTimes is positive - in positive direction;
// theTimes is negative - in negative direction.
const Standard_Integer iDir = theTimes > 0 ? 1 : -1;
// Create the translation history - all translated shapes will be
// created as Generated from the shape.
BRepTools_History aTranslationHistory;
TopTools_IndexedMapOfShape aSubShapesMap;
TopExp::MapShapes(myRepeatedShape, aSubShapesMap);
const Standard_Integer aNbS = aSubShapesMap.Extent();
// Add shapes for gluing
TopTools_ListOfShape aShapes;
// Add the shape itself
aShapes.Append(myRepeatedShape);
for (Standard_Integer i = 1; i <= aNbS; ++i)
{
const TopoDS_Shape& aS = aSubShapesMap(i);
if (BRepTools_History::IsSupportedType(aS))
aTranslationHistory.AddGenerated(aS, aS);
}
// Create translated copies of the shape
for (Standard_Integer i = 1; i <= Abs(theTimes); ++i)
{
gp_Trsf aTrsf;
aTrsf.SetTranslationPart(iDir * i * aPeriod * MY_DIRECTIONS[id]);
BRepBuilderAPI_Transform aTranslator(myRepeatedShape, aTrsf, Standard_False);
aShapes.Append(aTranslator.Shape());
// Fill the translation history
for (Standard_Integer j = 1; j <= aNbS; ++j)
{
const TopoDS_Shape& aS = aSubShapesMap(j);
if (BRepTools_History::IsSupportedType(aS))
{
const TopTools_ListOfShape& aLT = aTranslator.Modified(aS);
aTranslationHistory.AddGenerated(aS, aLT.First());
}
}
}
// Update the history with the translation History
myHistory->Merge(aTranslationHistory);
// Glue the translated shapes all together
BOPAlgo_Builder aGluer;
aGluer.SetArguments(aShapes);
// Avoid intersections of the sub-shapes
aGluer.SetGlue(BOPAlgo_GlueFull);
// Set parallel processing mode
aGluer.SetRunParallel(myRunParallel);
// Perform gluing
aGluer.Perform();
if (aGluer.HasErrors())
{
// Repetition in this direction is not possible
// Add warning saving the shapes for analysis
TopoDS_Compound aWS;
AddToShape(aShapes, aWS);
AddWarning(new BOPAlgo_AlertUnableToRepeat(aWS));
return myRepeatedShape;
}
// Get glued shape
myRepeatedShape = aGluer.Shape();
// Update repetition period for the next repetitions
myRepeatPeriod[id] += Abs(theTimes) * myRepeatPeriod[id];
// Update history with the Gluing history
BRepTools_History aGluingHistory(aShapes, aGluer);
myHistory->Merge(aGluingHistory);
// Update the map of twins after repetition
UpdateTwins(aTranslationHistory, aGluingHistory);
return myRepeatedShape;
}
//=======================================================================
//function : UpdateTwins
//purpose : Updates the map of twins after repetition
//=======================================================================
void BOPAlgo_MakePeriodic::UpdateTwins(const BRepTools_History& theTranslationHistory,
const BRepTools_History& theGluingHistory)
{
if (myTwins.IsEmpty())
return;
if (myRepeatedTwins.IsEmpty())
myRepeatedTwins = myTwins;
// New twins
TopTools_DataMapOfShapeListOfShape aNewTwinsMap;
// Fence map to avoid repeated fill for the twins
TopTools_MapOfShape aMTwinsDone;
// Update the map of twins with the new repeated shapes
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itDMap(myRepeatedTwins);
for (; itDMap.More(); itDMap.Next())
{
const TopoDS_Shape& aS = itDMap.Key();
aMTwinsDone.Add(aS);
const TopTools_ListOfShape& aLTwins = itDMap.Value();
// Check if the twins have not been already processed
TopTools_ListIteratorOfListOfShape itLT(aLTwins);
for (; itLT.More(); itLT.Next())
{
if (aMTwinsDone.Contains(itLT.Value()))
break;
}
if (itLT.More())
// Group of twins has already been processed
continue;
// All shapes generated from the shape itself and generated
// from its twins will be the new twins for the shape
TopTools_IndexedMapOfShape aNewGroup;
itLT.Initialize(aLTwins);
for (Standard_Boolean bShape = Standard_True; itLT.More();)
{
const TopoDS_Shape& aTwin = bShape ? aS : itLT.Value();
const TopTools_ListOfShape& aLG = theTranslationHistory.Generated(aTwin);
TopTools_ListIteratorOfListOfShape itLG(aLG);
for (; itLG.More(); itLG.Next())
{
const TopoDS_Shape& aG = itLG.Value();
const TopTools_ListOfShape& aLM = theGluingHistory.Modified(aG);
if (aLM.IsEmpty())
aNewGroup.Add(aG);
else
{
TopTools_ListIteratorOfListOfShape itLM(aLM);
for (; itLM.More(); itLM.Next())
aNewGroup.Add(itLM.Value());
}
}
if (bShape)
bShape = Standard_False;
else
itLT.Next();
}
// Associate the twins to each other
const Standard_Integer aNbTwins = aNewGroup.Extent();
for (Standard_Integer i = 1; i <= aNbTwins; ++i)
{
TopTools_ListOfShape* pTwins = aNewTwinsMap.Bound(aNewGroup(i), TopTools_ListOfShape());
for (Standard_Integer j = 1; j <= aNbTwins; ++j)
if (i != j) pTwins->Append(aNewGroup(j));
}
}
myRepeatedTwins = aNewTwinsMap;
}

View File

@@ -1,603 +0,0 @@
// Created on: 2018-03-16
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BOPAlgo_MakePeriodic_HeaderFile
#define _BOPAlgo_MakePeriodic_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <BOPAlgo_Options.hxx>
#include <BRepTools_History.hxx>
#include <Standard_Boolean.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
//! BOPAlgo_MakePeriodic is the tool for making an arbitrary shape periodic
//! in 3D space in specified directions.
//!
//! Periodicity of the shape means that the shape can be repeated in any
//! periodic direction any number of times without creation of the new
//! geometry or splits.
//!
//! The idea is to make the shape look identical on the opposite sides of the
//! periodic directions, so when translating the copy of a shape on the period
//! there will be no coinciding parts of different dimensions.
//!
//! If necessary the algorithm will trim the shape to fit it into the
//! requested period by splitting it by the planes limiting the shape's
//! requested period.
//!
//! For making the shape periodic in certain direction the algorithm performs
//! the following steps:
//! * Creates the copy of the shape and moves it on the period into negative
//! side of the requested direction;
//! * Splits the negative side of the shape by the moved copy, ensuring copying
//! of the geometry from positive side to negative;
//! * Creates the copy of the shape (with already split negative side) and moves
//! it on the period into the positive side of the requested direction;
//! * Splits the positive side of the shape by the moved copy, ensuring copying
//! of the geometry from negative side to positive.
//!
//! The algorithm also associates the identical (or twin) shapes located
//! on the opposite sides of the result shape.
//! Using the *GetTwins()* method it is possible to get the twin shapes from
//! the opposite sides.
//!
//! Algorithm also provides the methods to repeat the periodic shape in
//! periodic directions. The subsequent repetitions are performed on the
//! repeated shape, thus repeating the shape two times in X direction will
//! create result in three shapes (original plus two copies).
//! Single subsequent repetition will result already in 6 shapes.
//! The repetitions can be cleared and started over.
//!
//! The algorithm supports History of shapes modifications, thus
//! it is possible to track how the shape has been changed to make it periodic
//! and what new shapes have been created during repetitions.
//!
//! The algorithm supports the parallel processing mode, which allows faster
//! completion of the operations.
//!
//! The algorithm supports the Error/Warning system and returns the following alerts:
//! - *BOPAlgo_AlertNoPeriodicityRequired* - Error alert is given if no periodicity
//! has been requested in any direction;
//! - *BOPAlgo_AlertUnableToTrim* - Error alert is given if the trimming of the shape
//! for fitting it into requested period has failed;
//! - *BOPAlgo_AlertUnableToMakeIdentical* - Error alert is given if splitting of the
//! shape by its moved copies has failed;
//! - *BOPAlgo_AlertUnableToRepeat* - Warning alert is given if the gluing of the repeated
//! shapes has failed.
//!
//! Example of usage of the algorithm:
//! ~~~~
//! TopoDS_Shape aShape = ...; // The shape to make periodic
//! Standard_Boolean bMakeXPeriodic = ...; // Flag for making or not the shape periodic in X direction
//! Standard_Real aXPeriod = ...; // X period for the shape
//! Standard_Boolean isXTrimmed = ...; // Flag defining whether it is necessary to trimming
//! // the shape to fit to X period
//! Standard_Real aXFirst = ...; // Start of the X period
//! // (really necessary only if the trimming is requested)
//! Standard_Boolean bRunParallel = ...; // Parallel processing mode or single
//!
//! BOPAlgo_MakePeriodic aPeriodicityMaker; // Periodicity maker
//! aPeriodicityMaker.SetShape(aShape); // Set the shape
//! aPeriodicityMaker.MakeXPeriodic(bMakePeriodic, aXPeriod); // Making the shape periodic in X direction
//! aPeriodicityMaker.SetTrimmed(isXTrimmed, aXFirst); // Trim the shape to fit X period
//! aPeriodicityMaker.SetRunParallel(bRunParallel); // Set the parallel processing mode
//! aPeriodicityMaker.Perform(); // Performing the operation
//!
//! if (aPeriodicityMaker.HasErrors()) // Check for the errors
//! {
//! // errors treatment
//! Standard_SStream aSStream;
//! aPeriodicityMaker.DumpErrors(aSStream);
//! return;
//! }
//! if (aPeriodicityMaker.HasWarnings()) // Check for the warnings
//! {
//! // warnings treatment
//! Standard_SStream aSStream;
//! aPeriodicityMaker.DumpWarnings(aSStream);
//! }
//! const TopoDS_Shape& aPeriodicShape = aPeriodicityMaker.Shape(); // Result periodic shape
//!
//!
//! aPeriodicityMaker.XRepeat(2); // Making repetitions
//! const TopoDS_Shape& aRepeat = aPeriodicityMaker.RepeatedShape(); // Getting the repeated shape
//! aPeriodicityMaker.ClearRepetitions(); // Clearing the repetitions
//! ~~~~
//!
class BOPAlgo_MakePeriodic : public BOPAlgo_Options
{
public:
DEFINE_STANDARD_ALLOC
public: //! @name Constructor
//! Empty constructor
BOPAlgo_MakePeriodic() : BOPAlgo_Options()
{
myRepeatPeriod[0] = myRepeatPeriod[1] = myRepeatPeriod[2] = 0.0;
}
public: //! @name Setting the shape to make it periodic
//! Sets the shape to make it periodic.
//! @param theShape [in] The shape to make periodic.
void SetShape(const TopoDS_Shape& theShape)
{
myInputShape = theShape;
}
public: //! @name Definition of the structure to keep all periodicity parameters
//! Structure to keep all periodicity parameters:
struct PeriodicityParams
{
PeriodicityParams()
{
Clear();
}
//! Returns all previously set parameters to default values
void Clear()
{
myPeriodic[0] = myPeriodic[1] = myPeriodic[2] = Standard_False;
myPeriod[0] = myPeriod[1] = myPeriod[2] = 0.0;
myIsTrimmed[0] = myIsTrimmed[1] = myIsTrimmed[2] = Standard_True;
myPeriodFirst[0] = myPeriodFirst[1] = myPeriodFirst[2] = 0.0;
}
Standard_Boolean myPeriodic[3]; //!< Array of flags defining whether the shape should be
//! periodic in XYZ directions
Standard_Real myPeriod[3]; //!< Array of XYZ period values. Defining the period for any
//! direction the corresponding flag for that direction in
//! myPeriodic should be set to true
Standard_Boolean myIsTrimmed[3]; //!< Array of flags defining whether the input shape has to be
//! trimmed to fit the required period in the required direction
Standard_Real myPeriodFirst[3]; //!< Array of start parameters of the XYZ periods: required for trimming
};
public: //! @name Setters/Getters for periodicity parameters structure
//! Sets the periodicity parameters.
//! @param theParams [in] Periodicity parameters
void SetPeriodicityParameters(const PeriodicityParams& theParams)
{
myPeriodicityParams = theParams;
}
const PeriodicityParams& PeriodicityParameters() const
{
return myPeriodicityParams;
}
public: //! @name Methods for setting/getting periodicity info using ID as a direction
//! Sets the flag to make the shape periodic in specified direction:
//! - 0 - X direction;
//! - 1 - Y direction;
//! - 2 - Z direction.
//!
//! @param theDirectionID [in] The direction's ID;
//! @param theIsPeriodic [in] Flag defining periodicity in given direction;
//! @param thePeriod [in] Required period in given direction.
void MakePeriodic(const Standard_Integer theDirectionID,
const Standard_Boolean theIsPeriodic,
const Standard_Real thePeriod = 0.0)
{
Standard_Integer id = ToDirectionID(theDirectionID);
myPeriodicityParams.myPeriodic[id] = theIsPeriodic;
myPeriodicityParams.myPeriod[id] = theIsPeriodic ? thePeriod : 0.0;
}
//! Returns the info about Periodicity of the shape in specified direction.
//! @param theDirectionID [in] The direction's ID.
Standard_Boolean IsPeriodic(const Standard_Integer theDirectionID) const
{
return myPeriodicityParams.myPeriodic[ToDirectionID(theDirectionID)];
}
//! Returns the Period of the shape in specified direction.
//! @param theDirectionID [in] The direction's ID.
Standard_Real Period(const Standard_Integer theDirectionID) const
{
Standard_Integer id = ToDirectionID(theDirectionID);
return myPeriodicityParams.myPeriodic[id] ? myPeriodicityParams.myPeriod[id] : 0.0;
}
public: //! @name Named methods for setting/getting info about shape's periodicity
//! Sets the flag to make the shape periodic in X direction.
//! @param theIsPeriodic [in] Flag defining periodicity in X direction;
//! @param thePeriod [in] Required period in X direction.
void MakeXPeriodic(const Standard_Boolean theIsPeriodic,
const Standard_Real thePeriod = 0.0)
{
MakePeriodic(0, theIsPeriodic, thePeriod);
}
//! Returns the info about periodicity of the shape in X direction.
Standard_Boolean IsXPeriodic() const { return IsPeriodic(0); }
//! Returns the XPeriod of the shape
Standard_Real XPeriod() const { return Period(0); }
//! Sets the flag to make the shape periodic in Y direction.
//! @param theIsPeriodic [in] Flag defining periodicity in Y direction;
//! @param thePeriod [in] Required period in Y direction.
void MakeYPeriodic(const Standard_Boolean theIsPeriodic,
const Standard_Real thePeriod = 0.0)
{
MakePeriodic(1, theIsPeriodic, thePeriod);
}
//! Returns the info about periodicity of the shape in Y direction.
Standard_Boolean IsYPeriodic() const { return IsPeriodic(1); }
//! Returns the YPeriod of the shape.
Standard_Real YPeriod() const { return Period(1); }
//! Sets the flag to make the shape periodic in Z direction.
//! @param theIsPeriodic [in] Flag defining periodicity in Z direction;
//! @param thePeriod [in] Required period in Z direction.
void MakeZPeriodic(const Standard_Boolean theIsPeriodic,
const Standard_Real thePeriod = 0.0)
{
MakePeriodic(2, theIsPeriodic, thePeriod);
}
//! Returns the info about periodicity of the shape in Z direction.
Standard_Boolean IsZPeriodic() const { return IsPeriodic(2); }
//! Returns the ZPeriod of the shape.
Standard_Real ZPeriod() const { return Period(2); }
public: //! @name Methods for setting/getting trimming info taking Direction ID as a parameter
//! Defines whether the input shape is already trimmed in specified direction
//! to fit the period in this direction.
//! Direction is defined by an ID:
//! - 0 - X direction;
//! - 1 - Y direction;
//! - 2 - Z direction.
//!
//! If the shape is not trimmed it is required to set the first parameter
//! of the period in that direction.
//! The algorithm will make the shape fit into the period.
//!
//! Before calling this method, the shape has to be set to be periodic in this direction.
//!
//! @param theDirectionID [in] The direction's ID;
//! @param theIsTrimmed [in] The flag defining trimming of the shape in given direction;
//! @param theFirst [in] The first periodic parameter in the given direction.
void SetTrimmed(const Standard_Integer theDirectionID,
const Standard_Boolean theIsTrimmed,
const Standard_Real theFirst = 0.0)
{
Standard_Integer id = ToDirectionID(theDirectionID);
if (IsPeriodic(id))
{
myPeriodicityParams.myIsTrimmed[id] = theIsTrimmed;
myPeriodicityParams.myPeriodFirst[id] = !theIsTrimmed ? theFirst : 0.0;
}
}
//! Returns whether the input shape was trimmed in the specified direction.
//! @param theDirectionID [in] The direction's ID.
Standard_Boolean IsInputTrimmed(const Standard_Integer theDirectionID) const
{
return myPeriodicityParams.myIsTrimmed[ToDirectionID(theDirectionID)];
}
//! Returns the first periodic parameter in the specified direction.
//! @param theDirectionID [in] The direction's ID.
Standard_Real PeriodFirst(const Standard_Integer theDirectionID) const
{
Standard_Integer id = ToDirectionID(theDirectionID);
return !myPeriodicityParams.myIsTrimmed[id] ? myPeriodicityParams.myPeriodFirst[id] : 0.0;
}
public: //! @name Named methods for setting/getting trimming info
//! Defines whether the input shape is already trimmed in X direction
//! to fit the X period. If the shape is not trimmed it is required
//! to set the first parameter for the X period.
//! The algorithm will make the shape fit into the period.
//!
//! Before calling this method, the shape has to be set to be periodic in this direction.
//!
//! @param theIsTrimmed [in] Flag defining whether the shape is already trimmed
//! in X direction to fit the X period;
//! @param theFirst [in] The first X periodic parameter.
void SetXTrimmed(const Standard_Boolean theIsTrimmed,
const Standard_Boolean theFirst = 0.0)
{
SetTrimmed(0, theIsTrimmed, theFirst);
}
//! Returns whether the input shape was already trimmed for X period.
Standard_Boolean IsInputXTrimmed() const
{
return IsInputTrimmed(0);
}
//! Returns the first parameter for the X period.
Standard_Real XPeriodFirst() const
{
return PeriodFirst(0);
}
//! Defines whether the input shape is already trimmed in Y direction
//! to fit the Y period. If the shape is not trimmed it is required
//! to set the first parameter for the Y period.
//! The algorithm will make the shape fit into the period.
//!
//! Before calling this method, the shape has to be set to be periodic in this direction.
//!
//! @param theIsTrimmed [in] Flag defining whether the shape is already trimmed
//! in Y direction to fit the Y period;
//! @param theFirst [in] The first Y periodic parameter.
void SetYTrimmed(const Standard_Boolean theIsTrimmed,
const Standard_Boolean theFirst = 0.0)
{
SetTrimmed(1, theIsTrimmed, theFirst);
}
//! Returns whether the input shape was already trimmed for Y period.
Standard_Boolean IsInputYTrimmed() const
{
return IsInputTrimmed(1);
}
//! Returns the first parameter for the Y period.
Standard_Real YPeriodFirst() const
{
return PeriodFirst(1);
}
//! Defines whether the input shape is already trimmed in Z direction
//! to fit the Z period. If the shape is not trimmed it is required
//! to set the first parameter for the Z period.
//! The algorithm will make the shape fit into the period.
//!
//! Before calling this method, the shape has to be set to be periodic in this direction.
//!
//! @param theIsTrimmed [in] Flag defining whether the shape is already trimmed
//! in Z direction to fit the Z period;
//! @param theFirst [in] The first Z periodic parameter.
void SetZTrimmed(const Standard_Boolean theIsTrimmed,
const Standard_Boolean theFirst = 0.0)
{
SetTrimmed(2, theIsTrimmed, theFirst);
}
//! Returns whether the input shape was already trimmed for Z period.
Standard_Boolean IsInputZTrimmed() const
{
return IsInputTrimmed(2);
}
//! Returns the first parameter for the Z period.
Standard_Real ZPeriodFirst() const
{
return PeriodFirst(2);
}
public: //! @name Performing the operation
//! Makes the shape periodic in necessary directions
Standard_EXPORT void Perform();
public: //! @name Using the algorithm to repeat the shape
//! Performs repetition of the shape in specified direction
//! required number of times.
//! Negative value of times means that the repetition should
//! be perform in negative direction.
//! Makes the repeated shape a base for following repetitions.
//!
//! @param theDirectionID [in] The direction's ID;
//! @param theTimes [in] Requested number of repetitions.
Standard_EXPORT const TopoDS_Shape& RepeatShape(const Standard_Integer theDirectionID,
const Standard_Integer theTimes);
//! Repeats the shape in X direction specified number of times.
//! Negative value of times means that the repetition should be
//! perform in negative X direction.
//! Makes the repeated shape a base for following repetitions.
//!
//! @param theTimes [in] Requested number of repetitions.
const TopoDS_Shape& XRepeat(const Standard_Integer theTimes)
{
return RepeatShape(0, theTimes);
}
//! Repeats the shape in Y direction specified number of times.
//! Negative value of times means that the repetition should be
//! perform in negative Y direction.
//! Makes the repeated shape a base for following repetitions.
//!
//! @param theTimes [in] Requested number of repetitions.
const TopoDS_Shape& YRepeat(const Standard_Integer theTimes)
{
return RepeatShape(1, theTimes);
}
//! Repeats the shape in Z direction specified number of times.
//! Negative value of times means that the repetition should be
//! perform in negative Z direction.
//! Makes the repeated shape a base for following repetitions.
//!
//! @param theTimes [in] Requested number of repetitions.
const TopoDS_Shape& ZRepeat(const Standard_Integer theTimes)
{
return RepeatShape(2, theTimes);
}
public: //! @name Starting the repetitions over
//! Returns the repeated shape
const TopoDS_Shape& RepeatedShape() const { return myRepeatedShape; }
//! Clears all performed repetitions.
//! The next repetition will be performed on the base shape.
void ClearRepetitions()
{
myRepeatPeriod[0] = myRepeatPeriod[1] = myRepeatPeriod[2] = 0.0;
myRepeatedShape.Nullify();
myRepeatedTwins.Clear();
if (!myHistory.IsNull())
{
myHistory->Clear();
if (!mySplitHistory.IsNull())
myHistory->Merge(mySplitHistory);
}
}
public: //! @name Obtaining the result shape
//! Returns the resulting periodic shape
const TopoDS_Shape& Shape() const { return myShape; }
public: //! @name Getting the identical shapes
//! Returns the identical shapes for the given shape located
//! on the opposite periodic side.
//! Returns empty list in case the shape has no twin.
//!
//! @param theS [in] Shape to get the twins for.
const TopTools_ListOfShape& GetTwins(const TopoDS_Shape& theS) const
{
static TopTools_ListOfShape empty;
const TopTools_ListOfShape* aTwins =
myRepeatedTwins.IsEmpty() ? myTwins.Seek(theS) : myRepeatedTwins.Seek(theS);
return (aTwins ? *aTwins : empty);
}
public: //! @name Getting the History of the algorithm
//! Returns the History of the algorithm
const Handle(BRepTools_History)& History() const
{
return myHistory;
}
public: //! @name Clearing the algorithm from previous runs
//! Clears the algorithm from previous runs
void Clear()
{
BOPAlgo_Options::Clear();
myPeriodicityParams.Clear();
myShape.Nullify();
if (!mySplitHistory.IsNull())
mySplitHistory->Clear();
if (!myHistory.IsNull())
myHistory->Clear();
ClearRepetitions();
}
public: //! @name Conversion of the integer to ID of periodic direction
//! Converts the integer to ID of periodic direction
static Standard_Integer ToDirectionID(const Standard_Integer theDirectionID)
{
return Abs(theDirectionID % 3);
}
protected: //! @name Protected methods performing the operation
//! Checks the validity of input data
Standard_EXPORT void CheckData();
//! Trims the shape to fit to the periodic bounds
Standard_EXPORT void Trim();
//! Makes the shape identical on opposite sides
Standard_EXPORT void MakeIdentical();
//! Splits the negative side of the shape with the geometry
//! located on the positive side copying the geometry from
//! positive side to the negative.
Standard_EXPORT void SplitNegative();
//! Splits the positive side of the shape with the geometry
//! located on the negative side of the shape.
//! Ensures that the geometries on the opposite sides will
//! be identical.
//! Associates the identical opposite sub-shapes.
Standard_EXPORT void SplitPositive();
//! Splits the shape by the given tools, copying the geometry of coinciding
//! parts from the given tools to the split shape.
//! @param theTools [in] The tools to split the shape and take the geometry
//! for coinciding parts.
//! @param theSplitShapeHistory [out] The history of shape split
//! @param theSplitToolsHistory [out] The history of tools modifications during the split
Standard_EXPORT void SplitShape(const TopTools_ListOfShape& theTools,
Handle(BRepTools_History) theSplitShapeHistory = NULL,
Handle(BRepTools_History) theSplitToolsHistory = NULL);
//! Updates the map of twins after periodic shape repetition.
//! @param theTranslationHistory [in] The history of translation of the periodic shape.
//! @param theGluingHistory [in] The history of gluing of the repeated shapes.
Standard_EXPORT void UpdateTwins(const BRepTools_History& theTranslationHistory,
const BRepTools_History& theGluingHistory);
protected: //! @name Fields
// Inputs
TopoDS_Shape myInputShape; //!< Input shape to make periodic
PeriodicityParams myPeriodicityParams; //!< Periodicity parameters
// Results
TopoDS_Shape myShape; //!< Resulting periodic shape (base for repetitions)
TopoDS_Shape myRepeatedShape; //!< Resulting shape after making repetitions of the base
Standard_Real myRepeatPeriod[3]; //!< XYZ repeat period
TopTools_DataMapOfShapeListOfShape myRepeatedTwins; //!< Map of associations of the identical sub-shapes
//! after repetition of the periodic shape
// Twins
TopTools_DataMapOfShapeListOfShape myTwins; //!< Map of associations of the identical sub-shapes
//! located on the opposite sides of the shape
// History
Handle(BRepTools_History) mySplitHistory; //!< Split history - history of shapes modification
//! after the split for making the shape periodic
Handle(BRepTools_History) myHistory; //!< Final history of shapes modifications
//! (to include the history of shape repetition)
};
#endif // _BOPAlgo_MakePeriodic_HeaderFile

View File

@@ -173,6 +173,22 @@ void BOPAlgo_PaveFiller::SetSectionAttribute
mySectionAttribute = theSecAttr;
}
//=======================================================================
//function : SetArguments
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::SetArguments(const TopTools_ListOfShape& theLS)
{
myArguments=theLS;
}
//=======================================================================
//function : Arguments
//purpose :
//=======================================================================
const TopTools_ListOfShape& BOPAlgo_PaveFiller::Arguments()const
{
return myArguments;
}
//=======================================================================
// function: Init
// purpose:
//=======================================================================

View File

@@ -125,23 +125,9 @@ public:
Standard_EXPORT const BOPDS_PIterator& Iterator();
//! Sets the arguments for operation
void SetArguments (const TopTools_ListOfShape& theLS)
{
myArguments = theLS;
}
//! Adds the argument for operation
void AddArgument(const TopoDS_Shape& theShape)
{
myArguments.Append(theShape);
}
//! Returns the list of arguments
const TopTools_ListOfShape& Arguments() const
{
return myArguments;
}
Standard_EXPORT void SetArguments (const TopTools_ListOfShape& theLS);
Standard_EXPORT const TopTools_ListOfShape& Arguments() const;
Standard_EXPORT const Handle(IntTools_Context)& Context();

View File

@@ -17,8 +17,6 @@
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <TopoDS_Iterator.hxx>
//=======================================================================
//function :
//purpose :
@@ -100,31 +98,3 @@ void BOPAlgo_Splitter::Perform()
myEntryPoint = 1;
PerformInternal(*pPF);
}
//=======================================================================
//function : BuildResult
//purpose :
//=======================================================================
void BOPAlgo_Splitter::BuildResult(const TopAbs_ShapeEnum theType)
{
BOPAlgo_Builder::BuildResult(theType);
if (theType == TopAbs_COMPOUND)
{
// The method is called for the last time for this operation.
// If there is only one argument shape and it has been modified into
// a single shape, or has not been modified at all, the result shape
// has to be overwritten to avoid the unnecessary enclosure into compound.
if (myArguments.Extent() == 1)
{
TopoDS_Iterator it(myShape);
if (it.More())
{
const TopoDS_Shape& aSFirst = it.Value();
it.Next();
if (!it.More())
myShape = aSFirst;
}
}
}
}

View File

@@ -66,12 +66,6 @@ protected:
//! Checks the input data
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
//! Adds images of the argument shapes into result.
//! When called the for the last time (for compound) it rebuilds the result
//! shape to avoid multiple enclosure into compounds.
Standard_EXPORT virtual void BuildResult(const TopAbs_ShapeEnum theType) Standard_OVERRIDE;
};
#endif // _BOPAlgo_Splitter_HeaderFile

View File

@@ -27,10 +27,6 @@ BOPAlgo_CheckResult.cxx
BOPAlgo_CheckResult.hxx
BOPAlgo_CheckStatus.hxx
BOPAlgo_ListOfCheckResult.hxx
BOPAlgo_MakeConnected.cxx
BOPAlgo_MakeConnected.hxx
BOPAlgo_MakePeriodic.cxx
BOPAlgo_MakePeriodic.hxx
BOPAlgo_MakerVolume.cxx
BOPAlgo_MakerVolume.hxx
BOPAlgo_MakerVolume.lxx

View File

@@ -57,8 +57,6 @@ void BOPTest::AllCommands(Draw_Interpretor& theCommands)
BOPTest::CellsCommands (theCommands);
BOPTest::UtilityCommands (theCommands);
BOPTest::RemoveFeaturesCommands(theCommands);
BOPTest::PeriodicityCommands(theCommands);
BOPTest::MkConnectedCommands(theCommands);
}
//=======================================================================
//function : Factory

View File

@@ -60,10 +60,6 @@ public:
Standard_EXPORT static void RemoveFeaturesCommands (Draw_Interpretor& aDI);
Standard_EXPORT static void PeriodicityCommands (Draw_Interpretor& aDI);
Standard_EXPORT static void MkConnectedCommands (Draw_Interpretor& aDI);
//! Prints errors and warnings if any and draws attached shapes
//! if flag BOPTest_Objects::DrawWarnShapes() is set
Standard_EXPORT static void ReportAlerts (const Handle(Message_Report)& theReport);

View File

@@ -1,413 +0,0 @@
// Created on: 04/02/2018
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BOPTest.hxx>
#include <BOPAlgo_MakeConnected.hxx>
#include <BOPTest_DrawableShape.hxx>
#include <BOPTest_Objects.hxx>
#include <BRep_Builder.hxx>
#include <BRepTest_Objects.hxx>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
static Standard_Integer MakeConnected(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer MakePeriodic(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer MaterialsOn(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer RepeatShape(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer GetTwins(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer ClearRepetitions(Draw_Interpretor&, Standard_Integer, const char**);
namespace
{
static BOPAlgo_MakeConnected TheMakeConnectedTool;
}
//=======================================================================
//function : MkConnectedCommands
//purpose :
//=======================================================================
void BOPTest::MkConnectedCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
// Chapter's name
const char* group = "BOPTest commands";
// Commands
theCommands.Add("makeconnected", "makeconnected result shape1 shape2 ...\n"
"\t\tMake the given shapes connected (glued).",
__FILE__, MakeConnected, group);
theCommands.Add("cmakeperiodic", "cmakeperiodic result [-x/y/z period [-trim first]]\n"
"\t\tMake the connected shape periodic in the required directions.\n"
"\t\tresult - resulting periodic shape;\n"
"\t\t-x/y/z period - option to make the shape periodic in X, Y or Z\n "
"\t\t direction with the given period;\n"
"\t\t-trim first - option to trim the shape to fit the required period,\n"
"\t\t starting the period in first.",
__FILE__, MakePeriodic, group);
theCommands.Add("cmaterialson", "cmaterialson result +/- shape\n"
"\t\tReturns the original shapes located on the required side of a shape:\n"
"\t\t'+' - on a positive side of a shape (containing the shape with orientation FORWARD)\n"
"\t\t'-' - on a negative side of a shape (containing the shape with orientation REVERSED).",
__FILE__, MaterialsOn, group);
theCommands.Add("crepeatshape", "crepeatshape result -x/y/z times\n"
"\t\tRepeats the periodic connected shape in periodic directions required number of times.\n"
"\t\tresult - resulting shape;\n"
"\t\t-x/y/z times - direction for repetition and number of repetitions.",
__FILE__, RepeatShape, group);
theCommands.Add("cperiodictwins", "cperiodictwins twins shape\n"
"\t\tReturns the twins for the shape located on the opposite side of the periodic shape.",
__FILE__, GetTwins, group);
theCommands.Add("cclearrepetitions", "cclearrepetitions [result]\n"
"\t\tClears all previous repetitions of the periodic shape.",
__FILE__, ClearRepetitions, group);
}
//=======================================================================
//function : MakeConnected
//purpose :
//=======================================================================
Standard_Integer MakeConnected(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char ** theArgv)
{
if (theArgc < 3)
{
theDI.PrintHelp(theArgv[0]);
return 1;
}
TheMakeConnectedTool.Clear();
for (Standard_Integer i = 2; i < theArgc; ++i)
{
TopoDS_Shape aS = DBRep::Get(theArgv[i]);
if (aS.IsNull())
{
theDI << "Error: " << theArgv[i] << " is a null shape. Skip it.\n";
continue;
}
TheMakeConnectedTool.AddArgument(aS);
}
TheMakeConnectedTool.SetRunParallel(BOPTest_Objects::RunParallel());
TheMakeConnectedTool.Perform();
// Print Error/Warning messages
BOPTest::ReportAlerts(TheMakeConnectedTool.GetReport());
// Set the history of the operation in session
BRepTest_Objects::SetHistory(TheMakeConnectedTool.History());
if (TheMakeConnectedTool.HasErrors())
return 0;
// Draw the result shape
const TopoDS_Shape& aResult = TheMakeConnectedTool.Shape();
DBRep::Set(theArgv[1], aResult);
return 0;
}
//=======================================================================
//function : MakePeriodic
//purpose :
//=======================================================================
Standard_Integer MakePeriodic(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char ** theArgv)
{
if (theArgc < 4)
{
theDI.PrintHelp(theArgv[0]);
return 1;
}
if (TheMakeConnectedTool.Shape().IsNull() || TheMakeConnectedTool.HasErrors())
{
theDI << "Make the shapes connected first.\n";
return 1;
}
BOPAlgo_MakePeriodic::PeriodicityParams aParams;
for (Standard_Integer i = 2; i < theArgc;)
{
Standard_Integer aDirID = -1;
if (!strcasecmp(theArgv[i], "-x"))
aDirID = 0;
else if (!strcasecmp(theArgv[i], "-y"))
aDirID = 1;
else if (!strcasecmp(theArgv[i], "-z"))
aDirID = 2;
else
{
theDI << theArgv[i] << " - Invalid key\n";
return 1;
}
char cDirName[2];
sprintf(cDirName, "%c", theArgv[i][1]);
Standard_Real aPeriod = 0;
if (theArgc > i + 1)
aPeriod = Draw::Atof(theArgv[++i]);
if (aPeriod <= Precision::Confusion())
{
theDI << "Period for " << cDirName << " direction is not set\n";
return 1;
}
aParams.myPeriodic[aDirID] = Standard_True;
aParams.myPeriod[aDirID] = aPeriod;
++i;
if (theArgc > i + 1)
{
// Check if trimming is necessary
if (!strcmp(theArgv[i], "-trim"))
{
if (theArgc == (i + 1))
{
theDI << "Trim bounds for " << cDirName << " direction are not set\n";
return 1;
}
Standard_Real aFirst = Draw::Atof(theArgv[++i]);
aParams.myIsTrimmed[aDirID] = Standard_False;
aParams.myPeriodFirst[aDirID] = aFirst;
++i;
}
}
}
TheMakeConnectedTool.MakePeriodic(aParams);
// Print Error/Warning messages
BOPTest::ReportAlerts(TheMakeConnectedTool.GetReport());
// Set the history of the operation in session
BRepTest_Objects::SetHistory(TheMakeConnectedTool.History());
if (TheMakeConnectedTool.HasErrors())
return 0;
// Draw the result shape
const TopoDS_Shape& aResult = TheMakeConnectedTool.PeriodicShape();
DBRep::Set(theArgv[1], aResult);
return 0;
}
//=======================================================================
//function : RepeatShape
//purpose :
//=======================================================================
Standard_Integer RepeatShape(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char ** theArgv)
{
if (theArgc < 4)
{
theDI.PrintHelp(theArgv[0]);
return 1;
}
if (TheMakeConnectedTool.PeriodicityTool().HasErrors())
{
theDI << "The shapes have not been made periodic yet.\n";
return 1;
}
for (Standard_Integer i = 2; i < theArgc; ++i)
{
Standard_Integer aDirID = -1;
if (!strcasecmp(theArgv[i], "-x"))
aDirID = 0;
else if (!strcasecmp(theArgv[i], "-y"))
aDirID = 1;
else if (!strcasecmp(theArgv[i], "-z"))
aDirID = 2;
else
{
theDI << theArgv[i] << " - Invalid key\n";
return 1;
}
char cDirName[2];
sprintf(cDirName, "%c", theArgv[i][1]);
Standard_Integer aTimes = 0;
if (theArgc > i + 1)
aTimes = Draw::Atoi(theArgv[++i]);
if (aTimes == 0)
{
theDI << "Number of repetitions for " << cDirName << " direction is not set\n";
return 1;
}
TheMakeConnectedTool.RepeatShape(aDirID, aTimes);
}
// Print Error/Warning messages
BOPTest::ReportAlerts(TheMakeConnectedTool.GetReport());
// Set the history of the operation in session
BRepTest_Objects::SetHistory(TheMakeConnectedTool.History());
if (TheMakeConnectedTool.HasErrors())
return 0;
// Draw the result shape
const TopoDS_Shape& aResult = TheMakeConnectedTool.PeriodicShape();
DBRep::Set(theArgv[1], aResult);
return 0;
}
//=======================================================================
//function : MaterialsOn
//purpose :
//=======================================================================
Standard_Integer MaterialsOn(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char ** theArgv)
{
if (theArgc != 4)
{
theDI.PrintHelp(theArgv[0]);
return 1;
}
// Get the shape to get materials
TopoDS_Shape aShape = DBRep::Get(theArgv[3]);
if (aShape.IsNull())
{
theDI << "Error: " << theArgv[3] << " is a null shape.\n";
return 1;
}
// Get the sign of a shape
Standard_Boolean bPositive;
if (!strcmp("+", theArgv[2]))
bPositive = Standard_True;
else if (!strcmp("-", theArgv[2]))
bPositive = Standard_False;
else
{
theDI << theArgv[2] << " - invalid key.\n";
return 1;
}
const TopTools_ListOfShape& aLS = bPositive ?
TheMakeConnectedTool.MaterialsOnPositiveSide(aShape) :
TheMakeConnectedTool.MaterialsOnNegativeSide(aShape);
TopoDS_Shape aResult;
if (aLS.IsEmpty())
theDI << "No materials on this side.\n";
else if (aLS.Extent() == 1)
aResult = aLS.First();
else
{
BRep_Builder().MakeCompound(TopoDS::Compound(aResult));
for (TopTools_ListIteratorOfListOfShape it(aLS); it.More(); it.Next())
BRep_Builder().Add(aResult, it.Value());
}
DBRep::Set(theArgv[1], aResult);
return 0;
}
//=======================================================================
//function : GetTwin
//purpose :
//=======================================================================
Standard_Integer GetTwins(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char ** theArgv)
{
if (theArgc != 3)
{
theDI.PrintHelp(theArgv[0]);
return 1;
}
// Get the shape to find twins
TopoDS_Shape aShape = DBRep::Get(theArgv[2]);
if (aShape.IsNull())
{
theDI << "Error: " << theArgv[2] << " is a null shape.\n";
return 1;
}
const TopTools_ListOfShape& aTwins = TheMakeConnectedTool.PeriodicityTool().GetTwins(aShape);
TopoDS_Shape aCTwins;
if (aTwins.IsEmpty())
theDI << "No twins for the shape.\n";
else if (aTwins.Extent() == 1)
aCTwins = aTwins.First();
else
{
BRep_Builder().MakeCompound(TopoDS::Compound(aCTwins));
for (TopTools_ListIteratorOfListOfShape it(aTwins); it.More(); it.Next())
BRep_Builder().Add(aCTwins, it.Value());
}
DBRep::Set(theArgv[1], aCTwins);
return 0;
}
//=======================================================================
//function : ClearRepetitions
//purpose :
//=======================================================================
Standard_Integer ClearRepetitions(Draw_Interpretor&,
Standard_Integer theArgc,
const char **theArgv)
{
// Clear all previous repetitions
TheMakeConnectedTool.ClearRepetitions();
// Set the history of the operation in session
BRepTest_Objects::SetHistory(TheMakeConnectedTool.History());
if (theArgc > 1)
DBRep::Set(theArgv[1], TheMakeConnectedTool.PeriodicShape());
return 0;
}

View File

@@ -1,296 +0,0 @@
// Created on: 03/19/2018
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BOPTest.hxx>
#include <BOPAlgo_MakePeriodic.hxx>
#include <BOPTest_DrawableShape.hxx>
#include <BOPTest_Objects.hxx>
#include <BRep_Builder.hxx>
#include <BRepTest_Objects.hxx>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
static Standard_Integer MakePeriodic(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer GetTwins(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer RepeatShape(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer ClearRepetitions(Draw_Interpretor&, Standard_Integer, const char**);
namespace
{
static BOPAlgo_MakePeriodic ThePeriodicityMaker;
}
//=======================================================================
//function : PeriodicityCommands
//purpose :
//=======================================================================
void BOPTest::PeriodicityCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
// Chapter's name
const char* group = "BOPTest commands";
// Commands
theCommands.Add("makeperiodic", "makeperiodic result shape [-x/y/z period [-trim first]]\n"
"\t\tMake the shape periodic in the required directions.\n"
"\t\tresult - resulting periodic shape;\n"
"\t\t-x/y/z period - option to make the shape periodic in X, Y or Z\n "
"\t\t direction with the given period;\n"
"\t\t-trim first - option to trim the shape to fit the required period,\n"
"\t\t starting the period in first.",
__FILE__, MakePeriodic, group);
theCommands.Add("periodictwins", "periodictwins twins shape\n"
"\t\tReturns the twins for the shape located on the opposite side of the periodic shape.",
__FILE__, GetTwins, group);
// Repetition commands
theCommands.Add("repeatshape", "repeatshape result -x/y/z times\n"
"\t\tRepeats the periodic shape in periodic directions required number of times.\n"
"\t\tresult - resulting shape;\n"
"\t\t-x/y/z times - direction for repetition and number of repetitions.",
__FILE__, RepeatShape, group);
theCommands.Add("clearrepetitions", "clearrepetitions [result]\n"
"\t\tClears all previous repetitions of the periodic shape.",
__FILE__, ClearRepetitions, group);
}
//=======================================================================
//function : MakePeriodic
//purpose :
//=======================================================================
Standard_Integer MakePeriodic(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char ** theArgv)
{
if (theArgc < 5)
{
theDI.PrintHelp(theArgv[0]);
return 1;
}
// Get the shape to make periodic
TopoDS_Shape aShape = DBRep::Get(theArgv[2]);
if (aShape.IsNull())
{
theDI << "Error: " << theArgv[2] << " is a null shape.\n";
return 1;
}
ThePeriodicityMaker.Clear();
ThePeriodicityMaker.SetShape(aShape);
for (Standard_Integer i = 3; i < theArgc;)
{
// Get periodicity
Standard_Integer iDir = i;
Standard_Integer aDirID = -1;
if (!strcasecmp(theArgv[i], "-x"))
aDirID = 0;
else if (!strcasecmp(theArgv[i], "-y"))
aDirID = 1;
else if (!strcasecmp(theArgv[i], "-z"))
aDirID = 2;
else
{
theDI << theArgv[i] << " - Invalid key\n";
return 1;
}
char cDirName[2];
sprintf(cDirName, "%c", theArgv[iDir][1]);
if (theArgc == (i + 1))
{
theDI << "Period for " << cDirName << " direction is not set\n";
return 1;
}
Standard_Real aPeriod = Draw::Atof(theArgv[++i]);
ThePeriodicityMaker.MakePeriodic(aDirID, Standard_True, aPeriod);
++i;
if (theArgc > i + 1)
{
// Check if trimming is necessary
if (!strcmp(theArgv[i], "-trim"))
{
if (theArgc == (i + 1))
{
theDI << "Trim bounds for " << cDirName << " direction are not set\n";
return 1;
}
Standard_Real aFirst = Draw::Atof(theArgv[++i]);
ThePeriodicityMaker.SetTrimmed(aDirID, Standard_False, aFirst);
++i;
}
}
}
ThePeriodicityMaker.SetRunParallel(BOPTest_Objects::RunParallel());
// Perform operation
ThePeriodicityMaker.Perform();
// Print Error/Warning messages
BOPTest::ReportAlerts(ThePeriodicityMaker.GetReport());
// Set the history of the operation in session
BRepTest_Objects::SetHistory(ThePeriodicityMaker.History());
if (ThePeriodicityMaker.HasErrors())
return 0;
// Draw the result shape
const TopoDS_Shape& aResult = ThePeriodicityMaker.Shape();
DBRep::Set(theArgv[1], aResult);
return 0;
}
//=======================================================================
//function : GetTwin
//purpose :
//=======================================================================
Standard_Integer GetTwins(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char ** theArgv)
{
if (theArgc != 3)
{
theDI.PrintHelp(theArgv[0]);
return 1;
}
// Get the shape to find twins
TopoDS_Shape aShape = DBRep::Get(theArgv[2]);
if (aShape.IsNull())
{
theDI << "Error: " << theArgv[2] << " is a null shape.\n";
return 1;
}
const TopTools_ListOfShape& aTwins = ThePeriodicityMaker.GetTwins(aShape);
TopoDS_Shape aCTwins;
if (aTwins.IsEmpty())
theDI << "No twins for the shape.\n";
else if (aTwins.Extent() == 1)
aCTwins = aTwins.First();
else
{
BRep_Builder().MakeCompound(TopoDS::Compound(aCTwins));
for (TopTools_ListIteratorOfListOfShape it(aTwins); it.More(); it.Next())
BRep_Builder().Add(aCTwins, it.Value());
}
DBRep::Set(theArgv[1], aCTwins);
return 0;
}
//=======================================================================
//function : RepeatShape
//purpose :
//=======================================================================
Standard_Integer RepeatShape(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char ** theArgv)
{
if (theArgc < 4)
{
theDI.PrintHelp(theArgv[0]);
return 1;
}
for (Standard_Integer i = 2; i < theArgc; ++i)
{
Standard_Integer aDirID = -1;
if (!strcasecmp(theArgv[i], "-x"))
aDirID = 0;
else if (!strcasecmp(theArgv[i], "-y"))
aDirID = 1;
else if (!strcasecmp(theArgv[i], "-z"))
aDirID = 2;
else
{
theDI << theArgv[i] << " - Invalid key\n";
return 1;
}
char cDirName[2];
sprintf(cDirName, "%c", theArgv[i][1]);
Standard_Integer aTimes = 0;
if (theArgc > i + 1)
aTimes = Draw::Atoi(theArgv[++i]);
if (aTimes == 0)
{
theDI << "Number of repetitions for " << cDirName << " direction is not set\n";
return 1;
}
ThePeriodicityMaker.RepeatShape(aDirID, aTimes);
}
// Print Error/Warning messages
BOPTest::ReportAlerts(ThePeriodicityMaker.GetReport());
// Set the history of the operation in session
BRepTest_Objects::SetHistory(ThePeriodicityMaker.History());
if (ThePeriodicityMaker.HasErrors())
return 0;
// Draw the result shape
const TopoDS_Shape& aResult = ThePeriodicityMaker.RepeatedShape();
DBRep::Set(theArgv[1], aResult);
return 0;
}
//=======================================================================
//function : ClearRepetitions
//purpose :
//=======================================================================
Standard_Integer ClearRepetitions(Draw_Interpretor&,
Standard_Integer theArgc,
const char **theArgv)
{
// Clear all previous repetitions
ThePeriodicityMaker.ClearRepetitions();
// Set the history of the operation in session
BRepTest_Objects::SetHistory(ThePeriodicityMaker.History());
if (theArgc > 1)
DBRep::Set(theArgv[1], ThePeriodicityMaker.Shape());
return 0;
}

View File

@@ -6,13 +6,11 @@ BOPTest_CheckCommands.cxx
BOPTest_DrawableShape.cxx
BOPTest_DrawableShape.hxx
BOPTest_LowCommands.cxx
BOPTest_MkConnectedCommands.cxx
BOPTest_ObjCommands.cxx
BOPTest_Objects.cxx
BOPTest_Objects.hxx
BOPTest_OptionCommands.cxx
BOPTest_PartitionCommands.cxx
BOPTest_PeriodicityCommands.cxx
BOPTest_TolerCommands.cxx
BOPTest_DebugCommands.cxx
BOPTest_CellsCommands.cxx

View File

@@ -83,12 +83,14 @@ void ResultChron( OSD_Chronometer & ch, Standard_Real & time)
//=======================================================================
BRepAlgo_NormalProjection::BRepAlgo_NormalProjection()
: myIsDone(Standard_False), myMaxDist(-1.),
myWith3d(Standard_True), myFaceBounds(Standard_True)
: myWith3d(Standard_True)
{
BRep_Builder BB;
BB.MakeCompound(TopoDS::Compound(myToProj));
myFaceBounds=Standard_True;
SetDefaultParams();
myMaxDist = -1;
}
//=======================================================================
@@ -97,12 +99,12 @@ void ResultChron( OSD_Chronometer & ch, Standard_Real & time)
//=======================================================================
BRepAlgo_NormalProjection::BRepAlgo_NormalProjection(const TopoDS_Shape& S)
: myIsDone(Standard_False), myMaxDist(-1.),
myWith3d(Standard_True), myFaceBounds(Standard_True)
: myWith3d(Standard_True)
{
BRep_Builder BB;
BB.MakeCompound(TopoDS::Compound(myToProj));
SetDefaultParams();
myMaxDist = -1;
Init(S);
}

View File

@@ -1,23 +0,0 @@
// Created by: Julia GERASIMOVA
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepBlend_ConstThroat_HeaderFile
#define _BRepBlend_ConstThroat_HeaderFile
#include <BlendFunc_ConstThroat.hxx>
typedef BlendFunc_ConstThroat BRepBlend_ConstThroat;
#endif // _BRepBlend_ConstThroat_HeaderFile

View File

@@ -1,23 +0,0 @@
// Created by: Julia GERASIMOVA
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepBlend_ConstThroatInv_HeaderFile
#define _BRepBlend_ConstThroatInv_HeaderFile
#include <BlendFunc_ConstThroatInv.hxx>
typedef BlendFunc_ConstThroatInv BRepBlend_ConstThroatInv;
#endif // _BRepBlend_ConstThroatInv_HeaderFile

View File

@@ -1,23 +0,0 @@
// Created by: Julia GERASIMOVA
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepBlend_ConstThroatWithPenetration_HeaderFile
#define _BRepBlend_ConstThroatWithPenetration_HeaderFile
#include <BlendFunc_ConstThroatWithPenetration.hxx>
typedef BlendFunc_ConstThroatWithPenetration BRepBlend_ConstThroatWithPenetration;
#endif // _BRepBlend_ConstThroatWithPenetration_HeaderFile

View File

@@ -1,23 +0,0 @@
// Created by: Julia GERASIMOVA
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepBlend_ConstThroatWithPenetrationInv_HeaderFile
#define _BRepBlend_ConstThroatWithPenetrationInv_HeaderFile
#include <BlendFunc_ConstThroatWithPenetrationInv.hxx>
typedef BlendFunc_ConstThroatWithPenetrationInv BRepBlend_ConstThroatWithPenetrationInv;
#endif // _BRepBlend_ConstThroatWithPenetrationInv_HeaderFile

View File

@@ -16,10 +16,6 @@ BRepBlend_BlendTool.hxx
BRepBlend_BlendTool.lxx
BRepBlend_Chamfer.hxx
BRepBlend_ChamfInv.hxx
BRepBlend_ConstThroat.hxx
BRepBlend_ConstThroatInv.hxx
BRepBlend_ConstThroatWithPenetration.hxx
BRepBlend_ConstThroatWithPenetrationInv.hxx
BRepBlend_ChAsym.hxx
BRepBlend_ChAsymInv.hxx
BRepBlend_ConstRad.hxx

View File

@@ -414,10 +414,6 @@ static void ComputePCA(const TopoDS_Shape& theS,
{
BRepBndLib::Add(aST, aShapeBox);
}
if (aShapeBox.IsVoid())
{
return;
}
gp_Pnt aPMin = aShapeBox.CornerMin();
gp_Pnt aPMax = aShapeBox.CornerMax();

View File

@@ -23,11 +23,6 @@
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <Adaptor3d_Curve.hxx>
#include <Adaptor3d_HSurface.hxx>
#include <GeomAbs_CurveType.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <gp_Elips.hxx>
//=======================================================================
//function : Add
@@ -49,7 +44,6 @@ void BRepCheck::Add(BRepCheck_ListOfStatus& lst, const BRepCheck_Status stat)
}
lst.Append(stat);
}
//=======================================================================
//function : SelfIntersection
//purpose :
@@ -63,67 +57,6 @@ Standard_Boolean BRepCheck::SelfIntersection(const TopoDS_Wire& W,
BRepCheck_Status stat = chkw->SelfIntersect(myFace,RetE1,RetE2);
return (stat == BRepCheck_SelfIntersectingWire);
}
//=======================================================================
//function : PrecCurve
//purpose :
//=======================================================================
Standard_Real BRepCheck::PrecCurve(const Adaptor3d_Curve& aAC3D)
{
Standard_Real aXEmax = RealEpsilon();
//
GeomAbs_CurveType aCT = aAC3D.GetType();
if (aCT==GeomAbs_Ellipse) {
Standard_Real aX[5];
//
gp_Elips aEL3D=aAC3D.Ellipse();
aEL3D.Location().Coord(aX[0], aX[1], aX[2]);
aX[3]=aEL3D.MajorRadius();
aX[4]=aEL3D.MinorRadius();
aXEmax=-1.;
for (Standard_Integer i = 0; i < 5; ++i) {
if (aX[i]<0.) {
aX[i]=-aX[i];
}
Standard_Real aXE = Epsilon(aX[i]);
if (aXE > aXEmax) {
aXEmax = aXE;
}
}
}//if (aCT=GeomAbs_Ellipse) {
//
return aXEmax;
}
//=======================================================================
//function : PrecSurface
//purpose :
//=======================================================================
Standard_Real BRepCheck::PrecSurface(const Handle(Adaptor3d_HSurface)& aAHSurf)
{
Standard_Real aXEmax = RealEpsilon();
//
GeomAbs_SurfaceType aST = aAHSurf->GetType();
if (aST == GeomAbs_Cone) {
gp_Cone aCone=aAHSurf->Cone();
Standard_Real aX[4];
//
aCone.Location().Coord(aX[0], aX[1], aX[2]);
aX[3]=aCone.RefRadius();
aXEmax=-1.;
for (Standard_Integer i = 0; i < 4; ++i) {
if (aX[i] < 0.) {
aX[i] = -aX[i];
}
Standard_Real aXE = Epsilon(aX[i]);
if (aXE > aXEmax) {
aXEmax = aXE;
}
}
}//if (aST==GeomAbs_Cone) {
return aXEmax;
}
//=======================================================================
//function : Print
//purpose :

View File

@@ -28,8 +28,6 @@
class TopoDS_Wire;
class TopoDS_Face;
class TopoDS_Edge;
class Adaptor3d_Curve;
class Adaptor3d_HSurface;
class BRepCheck_Result;
class BRepCheck_Vertex;
class BRepCheck_Edge;
@@ -55,11 +53,6 @@ public:
Standard_EXPORT static Standard_Boolean SelfIntersection (const TopoDS_Wire& W, const TopoDS_Face& F, TopoDS_Edge& E1, TopoDS_Edge& E2);
//! Returns the resolution on the 3d curve
Standard_EXPORT static Standard_Real PrecCurve(const Adaptor3d_Curve& aAC3D);
//! Returns the resolution on the surface
Standard_EXPORT static Standard_Real PrecSurface(const Handle(Adaptor3d_HSurface)& aAHSurf);

View File

@@ -77,6 +77,10 @@ static
static
Standard_Real Prec(const Adaptor3d_Curve& aAC3D,
const Adaptor3d_CurveOnSurface& aACS);
static
Standard_Real PrecCurve(const Adaptor3d_Curve& aAC3D);
static
Standard_Real PrecSurface(const Adaptor3d_CurveOnSurface& aACS);
//static Standard_Boolean Validate(const Adaptor3d_Curve&,
// const Adaptor3d_Curve&,
@@ -894,23 +898,87 @@ Standard_Boolean Validate(const Adaptor3d_Curve& CRef,
return Status ;
}
//=======================================================================
//function : Prec
//purpose :
//=======================================================================
Standard_Real Prec(const Adaptor3d_Curve& aAC3D,
const Adaptor3d_CurveOnSurface& aACS)
const Adaptor3d_CurveOnSurface& aACS)
{
Standard_Real aXEmax, aXC, aXS;
const Handle(Adaptor3d_HSurface)& aAHS = aACS.GetSurface();
//
aXC = BRepCheck::PrecCurve(aAC3D);
aXS = BRepCheck::PrecSurface(aAHS);
aXEmax = (aXC>aXS) ? aXC: aXS;
aXC=PrecCurve(aAC3D);
aXS=PrecSurface(aACS);
aXEmax=(aXC>aXS) ? aXC: aXS;
return aXEmax;
}
//=======================================================================
//function : PrecCurve
//purpose :
//=======================================================================
Standard_Real PrecCurve(const Adaptor3d_Curve& aAC3D)
{
Standard_Real aXEmax;
GeomAbs_CurveType aCT;
//
aXEmax=RealEpsilon();
//
aCT=aAC3D.GetType();
if (aCT==GeomAbs_Ellipse) {
Standard_Integer i;
Standard_Real aX[5], aXE;
//
gp_Elips aEL3D=aAC3D.Ellipse();
aEL3D.Location().Coord(aX[0], aX[1], aX[2]);
aX[3]=aEL3D.MajorRadius();
aX[4]=aEL3D.MinorRadius();
aXEmax=-1.;
for (i=0; i<5; ++i) {
if (aX[i]<0.) {
aX[i]=-aX[i];
}
aXE=Epsilon(aX[i]);
if (aXE>aXEmax) {
aXEmax=aXE;
}
}
}//if (aCT=GeomAbs_Ellipse) {
//
return aXEmax;
}
//=======================================================================
//function : PrecSurface
//purpose :
//=======================================================================
Standard_Real PrecSurface(const Adaptor3d_CurveOnSurface& aACS)
{
Standard_Real aXEmax;
GeomAbs_SurfaceType aST;
//
aXEmax=RealEpsilon();
//
const Handle(Adaptor3d_HSurface)& aAHS=aACS.GetSurface();
aST=aAHS->GetType();
if (aST==GeomAbs_Cone) {
gp_Cone aCone=aAHS->Cone();
Standard_Integer i;
Standard_Real aX[4], aXE;
//
aCone.Location().Coord(aX[0], aX[1], aX[2]);
aX[3]=aCone.RefRadius();
aXEmax=-1.;
for (i=0; i<4; ++i) {
if (aX[i]<0.) {
aX[i]=-aX[i];
}
aXE=Epsilon(aX[i]);
if (aXE>aXEmax) {
aXEmax=aXE;
}
}
}//if (aST==GeomAbs_Cone) {
return aXEmax;
}
//=======================================================================
//function : PrintProblematicPoint
//purpose :

View File

@@ -62,7 +62,6 @@
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopTools_DataMapOfIntegerShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_SequenceOfShape.hxx>
@@ -251,7 +250,7 @@ void BRepFill_Pipe::Perform(const TopoDS_Wire& Spine,
TopoDS_Shape aux;
TheProf = myProfile;
TheProf.Location(Loc2.Multiplied(Loc1));
// Construct First && Last Shape
Handle(GeomFill_LocationLaw) law;
@@ -308,7 +307,7 @@ void BRepFill_Pipe::Perform(const TopoDS_Wire& Spine,
}
#endif
myShape = MakeShape(TheProf, myProfile, myFirst, myLast);
myShape = MakeShape(TheProf, myFirst, myLast);
}
@@ -383,8 +382,36 @@ void BRepFill_Pipe::Generated(const TopoDS_Shape& theShape,
{
theList.Clear();
if(myGenMap.IsBound(theShape)) {
theList = myGenMap.Find(theShape);
if (theShape.IsSame(myProfile))
theList.Append(myShape);
else
{
if (theShape.ShapeType() == TopAbs_FACE ||
theShape.ShapeType() == TopAbs_WIRE)
{
if(myGenMap.IsBound(theShape))
theList = myGenMap.Find(theShape);
}
else if (theShape.ShapeType() == TopAbs_EDGE)
{
TopoDS_Iterator itw(mySpine);
for (; itw.More(); itw.Next())
{
const TopoDS_Edge& aSpineEdge = TopoDS::Edge(itw.Value());
const TopoDS_Shape& aFace = Face(aSpineEdge, TopoDS::Edge(theShape));
theList.Append(aFace);
}
}
else if (theShape.ShapeType() == TopAbs_VERTEX)
{
TopoDS_Iterator itw(mySpine);
for (; itw.More(); itw.Next())
{
const TopoDS_Edge& aSpineEdge = TopoDS::Edge(itw.Value());
const TopoDS_Shape& anEdge = Edge(aSpineEdge, TopoDS::Vertex(theShape));
theList.Append(anEdge);
}
}
}
}
@@ -513,9 +540,9 @@ TopoDS_Wire BRepFill_Pipe::PipeLine(const gp_Pnt& Point)
P = Point;
P.Transform(myTrsf);
TopoDS_Vertex VertexSection = BRepLib_MakeVertex(P);
BRepLib_MakeVertex MkV(P);
Handle(BRepFill_ShapeLaw) Section =
new (BRepFill_ShapeLaw) (VertexSection);
new (BRepFill_ShapeLaw) (MkV.Vertex());
// Sweeping
BRepFill_Sweep MkSw(Section, myLoc, Standard_True);
@@ -524,7 +551,6 @@ TopoDS_Wire BRepFill_Pipe::PipeLine(const gp_Pnt& Point)
BRepFill_Modified, myContinuity, GeomFill_Location, myDegmax, mySegmax );
TopoDS_Shape aLocalShape = MkSw.Shape();
myErrorOnSurf = MkSw.ErrorOnSurface();
BuildHistory(MkSw, VertexSection);
return TopoDS::Wire(aLocalShape);
// return TopoDS::Wire(MkSw.Shape());
}
@@ -535,7 +561,6 @@ TopoDS_Wire BRepFill_Pipe::PipeLine(const gp_Pnt& Point)
//=======================================================================
TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
const TopoDS_Shape& theOriginalS,
const TopoDS_Shape& FirstShape,
const TopoDS_Shape& LastShape)
{
@@ -549,8 +574,6 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
TheLast = LastShape;
if (! myFaces.IsNull()) InitialLength = myFaces->ColLength();
TopLoc_Location BackLoc(myTrsf.Inverted());
// there are two kinds of generation
// 1. generate with S from each Filler (Vertex, Edge)
// 2. call MakeShape recursively on the subshapes of S
@@ -635,15 +658,13 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
if (!TheFirst.IsNull()) itFirst.Initialize(TheFirst);
if (!TheLast.IsNull()) itLast.Initialize(TheLast);
TopoDS_Iterator it(S);
TopoDS_Iterator itorig(theOriginalS);
for (; it.More(); it.Next(),itorig.Next()) {
for (TopoDS_Iterator it(S); it.More(); it.Next()) {
if (!TheFirst.IsNull()) first = itFirst.Value();
if (!TheLast.IsNull()) last = itLast.Value();
if (TheS.ShapeType() == TopAbs_FACE )
MakeShape(it.Value(), itorig.Value(), first, last);
MakeShape(it.Value(), first, last);
else
B.Add(result,MakeShape(it.Value(), itorig.Value(), first, last));
B.Add(result,MakeShape(it.Value(), first, last));
if (!TheFirst.IsNull()) itFirst.Next();
if (!TheLast.IsNull()) itLast.Next();
@@ -659,7 +680,7 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
MkSw.Build( myReversedEdges, myTapes, myRails,
BRepFill_Modified, myContinuity, GeomFill_Location, myDegmax, mySegmax );
result = MkSw.Shape();
UpdateMap(theOriginalS, result, myGenMap);
UpdateMap(TheS.Located(myProfile.Location()), result, myGenMap);
myErrorOnSurf = MkSw.ErrorOnSurface();
Handle(TopTools_HArray2OfShape) aSections = MkSw.Sections();
@@ -670,8 +691,6 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
myFirst = aSections->Value(1, 1);
myLast = aSections->Value(1, aVLast);
}
BuildHistory(MkSw, theOriginalS);
}
if (TheS.ShapeType() == TopAbs_WIRE ) {
@@ -684,6 +703,7 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
MkSw.Build( myReversedEdges, myTapes, myRails,
BRepFill_Modified, myContinuity, GeomFill_Location, myDegmax, mySegmax );
result = MkSw.Shape();
UpdateMap(TheS.Located(myProfile.Location()), result, myGenMap);
myErrorOnSurf = MkSw.ErrorOnSurface();
// Labeling of elements
@@ -742,8 +762,6 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
myEdges = Somme;
}
BuildHistory(MkSw, theOriginalS);
}
}
@@ -790,7 +808,7 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
BS.Add(solid,TopoDS::Shell(aLocalShape));
// BS.Add(solid,TopoDS::Shell(result.Reversed()));
}
UpdateMap(theOriginalS, solid, myGenMap);
UpdateMap(TheS.Located(myProfile.Location()), solid, myGenMap);
return solid;
}
else {
@@ -1012,110 +1030,3 @@ void BRepFill_Pipe::RebuildTopOrBottomFace(const TopoDS_Shape& aFace,
}
}
}
//=======================================================================
//function : BuildHistory
//purpose : Builds history for edges and vertices
// of section and path
//=======================================================================
void BRepFill_Pipe::BuildHistory(const BRepFill_Sweep& theSweep,
const TopoDS_Shape& theSection)
{
//Filling of <myGenMap>
const Handle(TopTools_HArray2OfShape)& anUEdges = theSweep.InterFaces();
Standard_Integer inde;
TopoDS_Iterator itw;
if (theSection.ShapeType() == TopAbs_WIRE)
{
TopoDS_Wire aSection = TopoDS::Wire(theSection);
BRepTools_WireExplorer wexp_sec(aSection);
for (inde = 0; wexp_sec.More(); wexp_sec.Next())
{
inde++;
const TopoDS_Edge& anEdge = TopoDS::Edge(wexp_sec.Current());
if (BRep_Tool::Degenerated(anEdge))
continue;
if (myGenMap.IsBound(anEdge))
continue;
TopoDS_Vertex aVertex [2];
TopExp::Vertices(anEdge, aVertex[0], aVertex[1]);
//For an edge generated shape is a "tape" -
//a shell usually containing this edge and
//passing from beginning of path to its end
TopoDS_Shell aTape = TopoDS::Shell(theSweep.Tape(inde));
//Processing of vertices of <anEdge>
//We should choose right index in <anUEdges>
//for each vertex of edge
Standard_Integer UIndex [2];
UIndex[0] = inde;
UIndex[1] = inde+1;
if (anEdge.Orientation() == TopAbs_REVERSED)
{ Standard_Integer Tmp = UIndex[0]; UIndex[0] = UIndex[1]; UIndex[1] = Tmp; }
for (Standard_Integer kk = 0; kk < 2; kk++)
{
if (myGenMap.IsBound(aVertex[kk]))
continue;
//Assemble the list of edges ("rail" along the path)
TopTools_ListOfShape* Elist = myGenMap.Bound(aVertex[kk], TopTools_ListOfShape());
Standard_Integer jj;
for (jj = 1; jj <= anUEdges->UpperCol(); jj++)
{
const TopoDS_Shape& anUedge = anUEdges->Value(UIndex[kk], jj);
if (!anUedge.IsNull())
Elist->Append(anUedge);
}
} //for (Standard_Integer kk = 0; kk < 2; kk++)
TopTools_ListOfShape* Flist = myGenMap.Bound(anEdge, TopTools_ListOfShape());
TopoDS_Iterator itsh(aTape);
for (; itsh.More(); itsh.Next())
Flist->Append(itsh.Value());
} //for (inde = 0; wexp_sec.More(); wexp_sec.Next())
} //if (theSection.ShapeType() == TopAbs_WIRE)
//For subshapes of spine
const Handle(TopTools_HArray2OfShape)& aFaces = theSweep.SubShape();
const Handle(TopTools_HArray2OfShape)& aVEdges = theSweep.Sections();
BRepTools_WireExplorer wexp(mySpine);
inde = 0;
Standard_Boolean ToExit = Standard_False;
for (;;)
{
if (!wexp.More())
ToExit = Standard_True;
inde++;
if (!ToExit)
{
const TopoDS_Edge& anEdgeOfSpine = wexp.Current();
for (Standard_Integer i = 1; i <= aFaces->UpperRow(); i++)
{
const TopoDS_Shape& aFace = aFaces->Value(i, inde);
UpdateMap(anEdgeOfSpine, aFace, myGenMap);
}
}
const TopoDS_Vertex& aVertexOfSpine = wexp.CurrentVertex();
for (Standard_Integer i = 1; i <= aVEdges->UpperRow(); i++)
{
const TopoDS_Shape& aVedge = aVEdges->Value(i, inde);
UpdateMap(aVertexOfSpine, aVedge, myGenMap);
}
if (ToExit)
break;
if (wexp.More())
wexp.Next();
}
}

View File

@@ -42,7 +42,6 @@ class TopoDS_Face;
class TopoDS_Edge;
class TopoDS_Vertex;
class gp_Pnt;
class BRepFill_Sweep;
//! Create a shape by sweeping a shape (the profile)
@@ -60,15 +59,9 @@ public:
Standard_EXPORT BRepFill_Pipe();
Standard_EXPORT BRepFill_Pipe(const TopoDS_Wire& Spine,
const TopoDS_Shape& Profile,
const GeomFill_Trihedron aMode = GeomFill_IsCorrectedFrenet,
const Standard_Boolean ForceApproxC1 = Standard_False,
const Standard_Boolean GeneratePartCase = Standard_False);
Standard_EXPORT BRepFill_Pipe(const TopoDS_Wire& Spine, const TopoDS_Shape& Profile, const GeomFill_Trihedron aMode = GeomFill_IsCorrectedFrenet, const Standard_Boolean ForceApproxC1 = Standard_False, const Standard_Boolean GeneratePartCase = Standard_False);
Standard_EXPORT void Perform (const TopoDS_Wire& Spine,
const TopoDS_Shape& Profile,
const Standard_Boolean GeneratePartCase = Standard_False);
Standard_EXPORT void Perform (const TopoDS_Wire& Spine, const TopoDS_Shape& Profile, const Standard_Boolean GeneratePartCase = Standard_False);
Standard_EXPORT const TopoDS_Shape& Spine() const;
@@ -120,27 +113,22 @@ private:
//! Auxiliary recursive method used to build the
//! result.
Standard_EXPORT TopoDS_Shape MakeShape (const TopoDS_Shape& S,
const TopoDS_Shape& theOriginalS,
const TopoDS_Shape& FirstShape,
const TopoDS_Shape& LastShape);
Standard_EXPORT TopoDS_Shape MakeShape (const TopoDS_Shape& S, const TopoDS_Shape& FirstShape, const TopoDS_Shape& LastShape);
//! Auxiliary recursive method used to find the edge's index
Standard_EXPORT Standard_Integer FindEdge (const TopoDS_Shape& S,
const TopoDS_Edge& E,
Standard_Integer& Init) const;
Standard_EXPORT Standard_Integer FindEdge (const TopoDS_Shape& S, const TopoDS_Edge& E, Standard_Integer& Init) const;
Standard_EXPORT Standard_Integer FindVertex (const TopoDS_Shape& S, const
TopoDS_Vertex& V,
Standard_Integer& Init) const;
Standard_EXPORT Standard_Integer FindVertex (const TopoDS_Shape& S, const TopoDS_Vertex& V, Standard_Integer& Init) const;
Standard_EXPORT void DefineRealSegmax();
Standard_EXPORT void RebuildTopOrBottomFace (const TopoDS_Shape& aFace,
const Standard_Boolean IsTop) const;
Standard_EXPORT void RebuildTopOrBottomFace (const TopoDS_Shape& aFace, const Standard_Boolean IsTop) const;
Standard_EXPORT void BuildHistory (const BRepFill_Sweep& theSweep,
const TopoDS_Shape& theSection);
//! Performs sharing coincident faces in theShape. Also modifies
//! myFaces, mySections and myEdges to contain shared shapes.
//! Returns the shared shape. If theShape is not modified this
//! method returns it.
Standard_EXPORT TopoDS_Shape ShareFaces (const TopoDS_Shape& theShape, const Standard_Integer theInitialFacesLen, const Standard_Integer theInitialEdgesLen, const Standard_Integer theInitialSectionsLen);
TopoDS_Wire mySpine;

View File

@@ -1203,8 +1203,8 @@ void BRepFill_PipeShell::Place(const BRepFill_Section& Sec,
//=======================================================================
//function : BuildHistory
//purpose : Builds history for edges and vertices of sections,
// for edges and vertices of spine
//purpose : Builds history for edges and vertices
// of sections
//=======================================================================
void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
{
@@ -1226,11 +1226,11 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
//for punctual sections (first or last)
//we take all the wires generated along the path
TopTools_ListOfShape* Elist = myGenMap.Bound(Section, TopTools_ListOfShape());
TopTools_ListOfShape Elist;
for (Standard_Integer i = 1; i <= anUEdges->UpperRow(); i++)
for (Standard_Integer j = 1; j <= anUEdges->UpperCol(); j++)
Elist->Append(anUEdges->Value(i,j));
Elist.Append(anUEdges->Value(i,j));
myGenMap.Bind(Section, Elist);
continue;
}
else
@@ -1319,11 +1319,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
continue;
if (IndWireMap.IsBound(UIndex[kk]))
{
TopTools_ListOfShape* Elist = myGenMap.Bound(aVertex[kk], TopTools_ListOfShape());
for (itw.Initialize( IndWireMap(UIndex[kk]) ); itw.More(); itw.Next())
Elist->Append(itw.Value());
TopTools_ListOfShape Wlist;
Wlist.Append(IndWireMap(UIndex[kk]));
myGenMap.Bind(aVertex[kk], Wlist);
continue;
}
@@ -1395,21 +1393,17 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
}
}
}
TopTools_ListOfShape* Elist = myGenMap.Bound(aVertex[kk], TopTools_ListOfShape());
for (itw.Initialize(aWire); itw.More(); itw.Next())
Elist->Append(itw.Value());
TopTools_ListOfShape Wlist;
Wlist.Append(aWire);
myGenMap.Bind(aVertex[kk], Wlist);
//Save already built wire with its index
IndWireMap.Bind(UIndex[kk], aWire);
} //for (Standard_Integer kk = 0; kk < 2; kk++)
////////////////////////////////////
TopTools_ListOfShape* Flist = myGenMap.Bound(anOriginalEdge, TopTools_ListOfShape());
TopoDS_Iterator itsh(aShell);
for (; itsh.More(); itsh.Next())
Flist->Append(itsh.Value());
TopTools_ListOfShape ListShell;
ListShell.Append(aShell);
myGenMap.Bind(anOriginalEdge, ListShell);
////////////////////////
inde++;
@@ -1433,25 +1427,28 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
if (!ToExit)
{
const TopoDS_Edge& anEdgeOfSpine = wexp.Current();
TopTools_ListOfShape* Flist = myGenMap.Bound(anEdgeOfSpine, TopTools_ListOfShape());
TopoDS_Shell aShell;
BB.MakeShell(aShell);
for (Standard_Integer i = 1; i <= aFaces->UpperRow(); i++)
{
const TopoDS_Shape& aFace = aFaces->Value(i, inde);
if (aFace.ShapeType() == TopAbs_FACE)
Flist->Append(aFace);
BB.Add(aShell, aFace);
}
TopTools_ListOfShape ListShell;
ListShell.Append(aShell);
myGenMap.Bind(anEdgeOfSpine, ListShell);
}
const TopoDS_Vertex& aVertexOfSpine = wexp.CurrentVertex();
TopTools_ListOfShape* ListVshapes = myGenMap.Bound(aVertexOfSpine, TopTools_ListOfShape());
TopTools_ListOfShape ListVshapes;
for (Standard_Integer i = 1; i <= aVEdges->UpperRow(); i++)
{
const TopoDS_Shape& aVshape = aVEdges->Value(i, inde);
if (aVshape.ShapeType() == TopAbs_EDGE ||
aVshape.ShapeType() == TopAbs_FACE)
ListVshapes->Append(aVshape);
ListVshapes.Append(aVshape);
else
{
TopoDS_Iterator itvshape(aVshape);
@@ -1460,17 +1457,19 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
const TopoDS_Shape& aSubshape = itvshape.Value();
if (aSubshape.ShapeType() == TopAbs_EDGE ||
aSubshape.ShapeType() == TopAbs_FACE)
ListVshapes->Append(aSubshape);
ListVshapes.Append(aSubshape);
else
{
//it is wire
for (itw.Initialize(aSubshape); itw.More(); itw.Next())
ListVshapes->Append(itw.Value());
ListVshapes.Append(itw.Value());
}
}
}
}
myGenMap.Bind(aVertexOfSpine, ListVshapes);
if (ToExit)
break;

View File

@@ -55,9 +55,10 @@ void BRepFilletAPI_MakeChamfer::Add(const TopoDS_Edge &E )
//=======================================================================
void BRepFilletAPI_MakeChamfer::Add(const Standard_Real Dis,
const TopoDS_Edge &E)
const TopoDS_Edge &E,
const TopoDS_Face &F)
{
myBuilder.Add(Dis, E);
myBuilder.Add(Dis, E, F);
}
@@ -161,20 +162,12 @@ void BRepFilletAPI_MakeChamfer::SetDistAngle(const Standard_Real Dis,
//================================================================
void BRepFilletAPI_MakeChamfer::GetDistAngle(const Standard_Integer IC,
Standard_Real& Dis,
Standard_Real& Angle) const
Standard_Real& Dis,
Standard_Real& Angle,
Standard_Boolean& DisOnFace1) const
{
myBuilder.GetDistAngle(IC, Dis, Angle);
}
myBuilder.GetDistAngle(IC, Dis, Angle, DisOnFace1);
//=======================================================================
//function : SetMode
//purpose :
//=======================================================================
void BRepFilletAPI_MakeChamfer::SetMode(const ChFiDS_ChamfMode theMode)
{
myBuilder.SetMode(theMode);
}
//=======================================================================

View File

@@ -62,8 +62,9 @@ public:
//! Adds edge E to the table of edges used by this
//! algorithm to build chamfers, where
//! the parameters of the chamfer are given by
//! the distance Dis (symmetric chamfer).
//! the parameters of the chamfer are given by the two
//! distances Dis1 and Dis2; the face F identifies the side
//! where Dis1 is measured.
//! The Add function results in a contour being built by
//! propagation from the edge E (i.e. the contour contains at
//! least this edge). This contour is composed of edges of
@@ -72,7 +73,7 @@ public:
//! series of faces being located on either side of the contour.
//! Warning
//! Nothing is done if edge E or the face F does not belong to the initial shape.
Standard_EXPORT void Add (const Standard_Real Dis, const TopoDS_Edge& E);
Standard_EXPORT void Add (const Standard_Real Dis, const TopoDS_Edge& E, const TopoDS_Face& F);
//! Sets the distances Dis1 and Dis2 which give the
//! parameters of the chamfer along the contour of index
@@ -86,19 +87,9 @@ public:
Standard_EXPORT void GetDist (const Standard_Integer IC, Standard_Real& Dis) const;
//! Adds edge E to the table of edges used by this
//! algorithm to build chamfers, where
//! the parameters of the chamfer are given by the two
//! distances Dis1 and Dis2; the face F identifies the side
//! where Dis1 is measured.
//! The Add function results in a contour being built by
//! propagation from the edge E (i.e. the contour contains at
//! least this edge). This contour is composed of edges of
//! the shape which are tangential to one another and
//! which delimit two series of tangential faces, with one
//! series of faces being located on either side of the contour.
//! Warning
//! Nothing is done if edge E or the face F does not belong to the initial shape.
//! Adds a fillet contour in the builder (builds a
//! contour of tangent edges to <E> and sets the two
//! distances <Dis1> and <Dis2> ( parameters of the chamfer ) ).
Standard_EXPORT void Add (const Standard_Real Dis1, const Standard_Real Dis2, const TopoDS_Edge& E, const TopoDS_Face& F);
//! Sets the distances Dis1 and Dis2 which give the
@@ -131,10 +122,7 @@ public:
//! gives the distances <Dis> and <Angle> of the fillet
//! contour of index <IC> in the DS
Standard_EXPORT void GetDistAngle (const Standard_Integer IC, Standard_Real& Dis, Standard_Real& Angle) const;
//! Sets the mode of chamfer
Standard_EXPORT void SetMode (const ChFiDS_ChamfMode theMode);
Standard_EXPORT void GetDistAngle (const Standard_Integer IC, Standard_Real& Dis, Standard_Real& Angle, Standard_Boolean& DisOnFace1) const;
//! return True if chamfer symetric false else.
Standard_EXPORT Standard_Boolean IsSymetric (const Standard_Integer IC) const;

View File

@@ -29,7 +29,6 @@
#include <BRep_GCurve.hxx>
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
#include <BRep_ListOfCurveRepresentation.hxx>
#include <BRepCheck.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_TFace.hxx>
#include <BRep_Tool.hxx>
@@ -1312,8 +1311,6 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
}
GAC.Load(C3d,f3d,l3d);
Standard_Real Prec_C3d = BRepCheck::PrecCurve(GAC);
Standard_Boolean IsSameP = 1;
Standard_Real maxdist = 0.;
@@ -1600,9 +1597,7 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
// Modified by skv - Thu Jun 3 12:39:19 2004 OCC5898 Begin
if (!IsSameP) {
Standard_Real Prec_Surf = BRepCheck::PrecSurface(HS);
Standard_Real CurTol = anEdgeTol + Max(Prec_C3d, Prec_Surf);
if (CurTol >= error) {
if (anEdgeTol >= error) {
maxdist = Max(maxdist, anEdgeTol);
IsSameP = Standard_True;
}

View File

@@ -17,12 +17,11 @@
#include <GCPnts_TangentialDeflection.hxx>
//=======================================================================
// Function: GetSplitSteps
// Function: GenerateSurfaceNodes
// Purpose :
//=======================================================================
std::pair<Standard_Real, Standard_Real> BRepMesh_ConeRangeSplitter::GetSplitSteps(
const IMeshTools_Parameters& theParameters,
std::pair<Standard_Integer, Standard_Integer>& theStepsNb) const
Handle(IMeshData::ListOfPnt2d) BRepMesh_ConeRangeSplitter::GenerateSurfaceNodes(
const IMeshTools_Parameters& theParameters) const
{
const std::pair<Standard_Real, Standard_Real>& aRangeU = GetRangeU();
const std::pair<Standard_Real, Standard_Real>& aRangeV = GetRangeV();
@@ -44,33 +43,15 @@ std::pair<Standard_Real, Standard_Real> BRepMesh_ConeRangeSplitter::GetSplitStep
Du = aDiffU / (nbU + 1);
Dv = aDiffV / (nbV + 1);
theStepsNb.first = nbU;
theStepsNb.second = nbV;
return std::make_pair (Du, Dv);
}
//=======================================================================
// Function: GenerateSurfaceNodes
// Purpose :
//=======================================================================
Handle(IMeshData::ListOfPnt2d) BRepMesh_ConeRangeSplitter::GenerateSurfaceNodes(
const IMeshTools_Parameters& theParameters) const
{
const std::pair<Standard_Real, Standard_Real>& aRangeU = GetRangeU();
const std::pair<Standard_Real, Standard_Real>& aRangeV = GetRangeV();
std::pair<Standard_Integer, Standard_Integer> aStepsNb;
std::pair<Standard_Real, Standard_Real> aSteps = GetSplitSteps (theParameters, aStepsNb);
const Handle(NCollection_IncAllocator) aTmpAlloc =
new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE);
Handle(IMeshData::ListOfPnt2d) aNodes = new IMeshData::ListOfPnt2d(aTmpAlloc);
const Standard_Real aPasMaxV = aRangeV.second - aSteps.second*0.5;
const Standard_Real aPasMaxU = aRangeU.second - aSteps.first *0.5;
for (Standard_Real aPasV = aRangeV.first + aSteps.second; aPasV < aPasMaxV; aPasV += aSteps.second)
const Standard_Real aPasMaxV = aRangeV.second - Dv*0.5;
const Standard_Real aPasMaxU = aRangeU.second - Du*0.5;
for (Standard_Real aPasV = aRangeV.first + Dv; aPasV < aPasMaxV; aPasV += Dv)
{
for (Standard_Real aPasU = aRangeU.first + aSteps.first; aPasU < aPasMaxU; aPasU += aSteps.first)
for (Standard_Real aPasU = aRangeU.first + Du; aPasU < aPasMaxU; aPasU += Du)
{
aNodes->Append(gp_Pnt2d(aPasU, aPasV));
}

View File

@@ -35,13 +35,6 @@ public:
{
}
//! Returns split intervals along U and V direction.
//! @param theParameters meshing parameters.
//! @param[out] theStepsNb number of steps along corresponding direction.
std::pair<Standard_Real, Standard_Real> GetSplitSteps(
const IMeshTools_Parameters& theParameters,
std::pair<Standard_Integer, Standard_Integer>& theStepsNb) const;
//! Returns list of nodes generated using surface data and specified parameters.
Standard_EXPORT virtual Handle(IMeshData::ListOfPnt2d) GenerateSurfaceNodes(
const IMeshTools_Parameters& theParameters) const Standard_OVERRIDE;

View File

@@ -79,9 +79,6 @@ void BRepMesh_CurveTessellator::init()
aPreciseLinDef *= 0.5;
}
aPreciseLinDef = Max(aPreciseLinDef, Precision::Confusion());
aPreciseAngDef = Max(aPreciseAngDef, Precision::Angular());
mySquareEdgeDef = aPreciseLinDef * aPreciseLinDef;
mySquareMinSize = Max(mySquareEdgeDef, myParameters.MinSize * myParameters.MinSize);

View File

@@ -36,9 +36,6 @@ namespace
void operator()(const Standard_Integer theEdgeIndex) const
{
const IMeshData::IEdgeHandle& aDEdge = myModel->GetEdge(theEdgeIndex);
if (aDEdge->GetCurve()->ParametersNb() == 0)
return;
if (aDEdge->IsFree())
{
if (!aDEdge->IsSet(IMeshData_Reused))

View File

@@ -21,7 +21,6 @@
#include <IMeshData_Wire.hxx>
#include <IMeshData_PCurve.hxx>
#include <OSD_Parallel.hxx>
#include <BRepMesh_ConeRangeSplitter.hxx>
namespace
{
@@ -89,137 +88,6 @@ namespace
Handle(IMeshData_Model) myModel;
};
//! Adds additional points to seam edges on specific surfaces.
class SeamEdgeAmplifier
{
public:
//! Constructor
SeamEdgeAmplifier(const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters)
: myModel (theModel)
, myParameters (theParameters)
{
}
//! Main functor.
void operator()(const Standard_Integer theFaceIndex) const
{
const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex);
if (aDFace->GetSurface()->GetType() != GeomAbs_Cone)
{
return;
}
const IMeshData::IWireHandle& aDWire = aDFace->GetWire (0);
for (Standard_Integer aEdgeIdx = 0; aEdgeIdx < aDWire->EdgesNb() - 1; ++aEdgeIdx)
{
const IMeshData::IEdgePtr& aDEdge = aDWire->GetEdge (aEdgeIdx);
if (aDEdge->GetPCurve(aDFace.get(), TopAbs_FORWARD) != aDEdge->GetPCurve(aDFace.get(), TopAbs_REVERSED))
{
if (aDEdge->GetCurve()->ParametersNb() == 2)
{
if (splitEdge (aDEdge, Abs (getConeStep (aDFace))))
{
TopLoc_Location aLoc;
const Handle (Poly_Triangulation)& aTriangulation =
BRep_Tool::Triangulation (aDFace->GetFace (), aLoc);
if (!aTriangulation.IsNull ())
{
aDFace->SetStatus (IMeshData_Outdated);
}
}
}
return;
}
}
}
private:
//! Returns step for splitting seam edge of a cone.
Standard_Real getConeStep(const IMeshData::IFaceHandle& theDFace) const
{
BRepMesh_ConeRangeSplitter aSplitter;
aSplitter.Reset (theDFace, myParameters);
const IMeshData::IWireHandle& aDWire = theDFace->GetWire (0);
for (Standard_Integer aEdgeIt = 0; aEdgeIt < aDWire->EdgesNb(); ++aEdgeIt)
{
const IMeshData::IEdgeHandle aDEdge = aDWire->GetEdge(aEdgeIt);
const IMeshData::IPCurveHandle& aPCurve = aDEdge->GetPCurve(
theDFace.get(), aDWire->GetEdgeOrientation(aEdgeIt));
for (Standard_Integer aPointIt = 0; aPointIt < aPCurve->ParametersNb(); ++aPointIt)
{
const gp_Pnt2d& aPnt2d = aPCurve->GetPoint(aPointIt);
aSplitter.AddPoint(aPnt2d);
}
}
std::pair<Standard_Integer, Standard_Integer> aStepsNb;
std::pair<Standard_Real, Standard_Real> aSteps = aSplitter.GetSplitSteps (myParameters, aStepsNb);
return aSteps.second;
}
//! Splits 3D and all pcurves accoring using the specified step.
Standard_Boolean splitEdge(const IMeshData::IEdgePtr& theDEdge,
const Standard_Real theDU) const
{
if (!splitCurve<gp_XYZ> (theDEdge->GetCurve (), theDU))
{
return Standard_False;
}
for (Standard_Integer aPCurveIdx = 0; aPCurveIdx < theDEdge->PCurvesNb(); ++aPCurveIdx)
{
splitCurve<gp_XY> (theDEdge->GetPCurve (aPCurveIdx), theDU);
}
return Standard_True;
}
//! Splits the given curve using the specified step.
template<class PointType, class Curve>
Standard_Boolean splitCurve(Curve& theCurve, const Standard_Real theDU) const
{
Standard_Boolean isUpdated = Standard_False;
PointType aDir = theCurve->GetPoint(theCurve->ParametersNb() - 1).Coord() - theCurve->GetPoint(0).Coord();
const Standard_Real aModulus = aDir.Modulus();
if (aModulus < gp::Resolution())
{
return isUpdated;
}
aDir /= aModulus;
const Standard_Real aLastParam = theCurve->GetParameter(theCurve->ParametersNb() - 1);
const Standard_Boolean isReversed = theCurve->GetParameter(0) > aLastParam;
for (Standard_Integer aPointIdx = 1; ; ++aPointIdx)
{
const Standard_Real aCurrParam = theCurve->GetParameter(0) + aPointIdx * theDU * (isReversed ? -1.0 : 1.0);
if (( isReversed && (aCurrParam < aLastParam)) ||
(!isReversed && !(aCurrParam < aLastParam)))
{
break;
}
theCurve->InsertPoint(theCurve->ParametersNb() - 1,
theCurve->GetPoint(0).Translated (aDir * aPointIdx * theDU),
aCurrParam);
isUpdated = Standard_True;
}
return isUpdated;
}
private:
Handle(IMeshData_Model) myModel;
IMeshTools_Parameters myParameters;
};
}
//=======================================================================
@@ -251,8 +119,7 @@ Standard_Boolean BRepMesh_ModelPreProcessor::Perform(
return Standard_False;
}
OSD_Parallel::For(0, theModel->FacesNb(), SeamEdgeAmplifier(theModel, theParameters), !theParameters.InParallel);
OSD_Parallel::For(0, theModel->FacesNb(), TriangulationConsistency(theModel), !theParameters.InParallel);
OSD_Parallel::For(0, theModel->FacesNb(), TriangulationConsistency(theModel), !theParameters.InParallel);
// Clean edges and faces from outdated polygons.
Handle(NCollection_IncAllocator) aTmpAlloc(new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE));

View File

@@ -1474,9 +1474,6 @@ void BRepOffset_Inter2d::ConnexIntByInt
if (YaBuild) {
for (itL.Initialize(L); itL.More(); itL.Next()) {
const TopoDS_Edge& EI = TopoDS::Edge(itL.Value());
if (EI.Orientation() != TopAbs_FORWARD &&
EI.Orientation() != TopAbs_REVERSED)
continue;
TopoDS_Shape aLocalShape = OFI.Generated(EI);
const TopoDS_Edge& OE = TopoDS::Edge(aLocalShape);
if (!MES.IsBound(OE) && !Build.IsBound(EI)) {

View File

@@ -447,11 +447,6 @@ void BRepOffset_Inter3d::ConnexIntByInt
TopExp_Explorer aExp(aFV1, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aE = aExp.Current();
if (aE.Orientation() != TopAbs_FORWARD &&
aE.Orientation() != TopAbs_REVERSED)
// Face is connected to the vertex through internal edge
break;
TopoDS_Iterator aItV(aE);
for (; aItV.More(); aItV.Next()) {
if (aS.IsSame(aItV.Value())) {
@@ -460,9 +455,7 @@ void BRepOffset_Inter3d::ConnexIntByInt
}
}
}
if (aExp.More())
continue;
//
// get to the next face in the list
it1 = it;
for (it1.Next(); it1.More(); it1.Next()) {
@@ -471,10 +464,7 @@ void BRepOffset_Inter3d::ConnexIntByInt
aExp.Init(aFV2, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aEV2 = aExp.Current();
if (aME.Contains(aEV2) &&
(Analyse.Ancestors(aEV2).Extent() == 2 || // Multi-connexity is not supported in Analyzer
(aEV2.Orientation() != TopAbs_FORWARD && // Avoid intersection of faces connected by internal edge
aEV2.Orientation() != TopAbs_REVERSED))) {
if (aME.Contains(aEV2)) {
break;
}
}

View File

@@ -55,7 +55,6 @@
#include <TopTools_ListOfShape.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_MapOfOrientedShape.hxx>
#include <BOPTools_AlgoTools3D.hxx>
#include <BOPTools_AlgoTools.hxx>
@@ -187,7 +186,6 @@ static
const TopTools_ListOfShape& theLFImages,
const TopTools_MapOfShape& theInvertedEdges,
const TopTools_DataMapOfShapeListOfShape& theDMEOrLEIm,
const TopTools_IndexedDataMapOfShapeListOfShape& theEFMap,
TopTools_MapOfShape& theMFHoles,
TopTools_DataMapOfShapeListOfShape& theDMFNewHoles,
Handle(IntTools_Context)& theContext);
@@ -550,9 +548,6 @@ static
TopTools_MapOfShape& theModifiedEdges,
Handle(BRepAlgo_AsDes)& theAsDes);
static
void FillGaps(TopTools_IndexedDataMapOfShapeListOfShape& theFImages);
static
void FillHistory(const TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
const TopTools_DataMapOfShapeListOfShape& theEImages,
@@ -705,11 +700,6 @@ void BRepOffset_MakeOffset::BuildSplitsOfExtendedFaces(const TopTools_ListOfShap
anInvFaces, anArtInvFaces, aVAEmpty, theETrimEInf, theAsDes);
}
}
// Fill possible gaps in the splits of offset faces to increase possibility of
// creating closed volume from these splits
FillGaps(aFImages);
// Fill history for faces and edges
FillHistory(aFImages, anOEImages, theImage);
}
@@ -987,19 +977,7 @@ void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
BRep_Builder().Add(aCEInverted, aItM.Value());
}
#endif
// Build Edge-Face connectivity map to find faces which removal
// may potentially lead to creation of the holes in the faces
// preventing from obtaining closed volume in the result
TopTools_IndexedDataMapOfShapeListOfShape anEFMap;
const Standard_Integer aNbF = theFImages.Extent();
for (i = 1; i <= aNbF; ++i)
{
TopTools_ListIteratorOfListOfShape itLFIm(theFImages(i));
for (; itLFIm.More(); itLFIm.Next())
TopExp::MapShapesAndAncestors(itLFIm.Value(), TopAbs_EDGE, TopAbs_FACE, anEFMap);
}
//
TopTools_ListOfShape anEmptyList;
// invalid faces inside the holes
TopTools_IndexedMapOfShape aMFInvInHole;
@@ -1034,7 +1012,7 @@ void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
TopTools_MapOfShape aMFHoles;
const TopoDS_Face& aFOr = TopoDS::Face(theFacesOrigins.Find(aF));
FindFacesInsideHoleWires(aFOr, aF, aLFImages, theInvertedEdges,
aDMEOrLEIm, anEFMap, aMFHoles, theDMFNewHoles, aCtx);
aDMEOrLEIm, aMFHoles, theDMFNewHoles, aCtx);
//
TopTools_MapIteratorOfMapOfShape aItMH(aMFHoles);
for (; aItMH.More(); aItMH.Next()) {
@@ -2030,7 +2008,6 @@ void FindFacesInsideHoleWires(const TopoDS_Face& theFOrigin,
const TopTools_ListOfShape& theLFImages,
const TopTools_MapOfShape& theInvertedEdges,
const TopTools_DataMapOfShapeListOfShape& theDMEOrLEIm,
const TopTools_IndexedDataMapOfShapeListOfShape& theEFMap,
TopTools_MapOfShape& theMFHoles,
TopTools_DataMapOfShapeListOfShape& theDMFNewHoles,
Handle(IntTools_Context)& theContext)
@@ -2145,18 +2122,14 @@ void FindFacesInsideHoleWires(const TopoDS_Face& theFOrigin,
}
}
}
// Build Edge-Face map for splits of current offset face
TopTools_IndexedDataMapOfShapeListOfShape anEFSplitsMap;
// Build Edge-Face map for holes
TopTools_IndexedDataMapOfShapeListOfShape anEFHolesMap;
//
// among the splits of the offset face find those that are
// located inside the hole faces
//
TopTools_ListIteratorOfListOfShape aItLF(theLFImages);
for (; aItLF.More(); aItLF.Next()) {
const TopoDS_Face& aFIm = TopoDS::Face(aItLF.Value());
TopExp::MapShapesAndAncestors(aFIm, TopAbs_EDGE, TopAbs_FACE, anEFSplitsMap);
//
// get the point inside the face and classify it relatively hole faces
gp_Pnt aP3D;
gp_Pnt2d aP2D;
@@ -2173,40 +2146,10 @@ void FindFacesInsideHoleWires(const TopoDS_Face& theFOrigin,
if (theContext->IsValidPointForFace(aP3D, aFNew, aTol)) {
// the face is classified as IN
theMFHoles.Add(aFIm);
TopExp::MapShapesAndAncestors(aFIm, TopAbs_EDGE, TopAbs_FACE, anEFHolesMap);
break;
}
}
}
// Out of all found holes find those which cannot be removed
// by checking their connectivity to splits of other offset faces.
// These are the faces, which will create uncovered holes if removed.
const Standard_Integer aNbE = anEFHolesMap.Extent();
for (Standard_Integer i = 1; i <= aNbE; ++i)
{
const TopoDS_Shape& anEdge = anEFHolesMap.FindKey(i);
const TopTools_ListOfShape& aLFHoles = anEFHolesMap(i);
// Check if the edge is outer for holes
if (aLFHoles.Extent() != 1)
continue;
const TopoDS_Shape& aFHole = aLFHoles.First();
if (!theMFHoles.Contains(aFHole))
// Already removed
continue;
// Check if the edge is not outer for splits
const TopTools_ListOfShape& aLSplits = anEFSplitsMap.FindFromKey(anEdge);
if (aLSplits.Extent() == 1)
continue;
// Check if edge is only connected to splits of the current offset face
const TopTools_ListOfShape& aLFAll = theEFMap.FindFromKey(anEdge);
if (aLFAll.Extent() == 2)
// Avoid removal of the hole from the splits
theMFHoles.Remove(aFHole);
}
}
//=======================================================================
@@ -6677,98 +6620,6 @@ void UpdateNewIntersectionEdges(const TopTools_ListOfShape& theLE,
}
}
//=======================================================================
//function : FillGaps
//purpose : Fill possible gaps (holes) in the splits of the offset faces
//=======================================================================
void FillGaps(TopTools_IndexedDataMapOfShapeListOfShape& theFImages)
{
Standard_Integer aNbF = theFImages.Extent();
if (!aNbF)
return;
// Check the splits of offset faces on the free edges and fill the gaps (holes)
// in created splits, otherwise the closed volume will not be possible to create.
// Map the splits of faces to find free edges
TopTools_IndexedDataMapOfShapeListOfShape anEFMap;
for (Standard_Integer i = 1; i <= aNbF; ++i)
{
TopTools_ListIteratorOfListOfShape itLF(theFImages(i));
for (; itLF.More(); itLF.Next())
TopExp::MapShapesAndAncestors(itLF.Value(), TopAbs_EDGE, TopAbs_FACE, anEFMap);
}
// Analyze images of each offset face on the presence of free edges
// and try to fill the holes
for (Standard_Integer i = 1; i <= aNbF; ++i)
{
TopTools_ListOfShape& aLFImages = theFImages(i);
if (aLFImages.IsEmpty())
continue;
// Collect all edges from the splits
TopoDS_Compound anEdges;
BRep_Builder().MakeCompound(anEdges);
// Collect all free edges into a map with reverted orientation
TopTools_MapOfOrientedShape aFreeEdgesMap;
TopTools_ListIteratorOfListOfShape itLF(aLFImages);
for (; itLF.More(); itLF.Next())
{
const TopoDS_Shape& aFIm = itLF.Value();
TopExp_Explorer anExpE(aFIm, TopAbs_EDGE);
for (; anExpE.More(); anExpE.Next())
{
const TopoDS_Shape& aE = anExpE.Current();
if (aE.Orientation() != TopAbs_FORWARD &&
aE.Orientation() != TopAbs_REVERSED)
// Skip internals
continue;
const TopTools_ListOfShape& aLF = anEFMap.FindFromKey(aE);
if (aLF.Extent() == 1)
aFreeEdgesMap.Add(aE.Reversed());
BRep_Builder().Add(anEdges, aE);
}
}
if (aFreeEdgesMap.IsEmpty())
// No free edges
continue;
// Free edges are found - fill the gaps by creating new splits
// of the face using these free edges
const TopoDS_Shape& aF = theFImages.FindKey(i);
// Build new splits using all kept edges and among new splits
// find those containing free edges
TopTools_ListOfShape aLFNew;
TopTools_DataMapOfShapeShape aDummy;
BuildSplitsOfFace(TopoDS::Face(aF), anEdges, aDummy, aLFNew);
// Find faces filling holes
itLF.Initialize(aLFNew);
for (; itLF.More(); itLF.Next())
{
const TopoDS_Shape& aFNew = itLF.Value();
TopExp_Explorer anExpE(aFNew, TopAbs_EDGE);
for (; anExpE.More(); anExpE.Next())
{
const TopoDS_Shape& aE = anExpE.Current();
if (aFreeEdgesMap.Contains(aE))
{
// Add face to splits
aLFImages.Append(aFNew);
break;
}
}
}
}
}
//=======================================================================
//function : FillHistory
//purpose : Saving obtained results in history tools
@@ -6777,67 +6628,54 @@ void FillHistory(const TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
const TopTools_DataMapOfShapeListOfShape& theEImages,
BRepAlgo_Image& theImage)
{
Standard_Integer aNbF = theFImages.Extent();
if (!aNbF)
Standard_Integer i, aNb = theFImages.Extent();
if (!aNb) {
return;
#ifdef OFFSET_DEBUG
// Build compound of faces to see preliminary result
TopoDS_Compound aDFaces;
BRep_Builder().MakeCompound(aDFaces);
#endif
// Map of kept edges
TopTools_IndexedMapOfShape anEdgesMap;
}
//
BRep_Builder aBB;
TopoDS_Compound aFaces;
aBB.MakeCompound(aFaces);
//
// Fill history for faces
for (Standard_Integer i = 1; i <= aNbF; ++i)
{
const TopTools_ListOfShape& aLFImages = theFImages(i);
if (aLFImages.IsEmpty())
continue;
// Add the splits to history map
for (i = 1; i <= aNb; ++i) {
const TopoDS_Shape& aF = theFImages.FindKey(i);
if (theImage.HasImage(aF))
theImage.Add(aF, aLFImages);
else
theImage.Bind(aF, aLFImages);
// Collect edges from splits
TopTools_ListIteratorOfListOfShape itLF(aLFImages);
for (; itLF.More(); itLF.Next())
{
const TopoDS_Shape& aFIm = itLF.Value();
TopExp::MapShapes(aFIm, TopAbs_EDGE, anEdgesMap);
#ifdef OFFSET_DEBUG
BRep_Builder().Add(aDFaces, aFIm);
#endif
const TopTools_ListOfShape& aLFImages = theFImages(i);
//
if (aLFImages.Extent()) {
if (theImage.HasImage(aF)) {
theImage.Add(aF, aLFImages);
}
else {
theImage.Bind(aF, aLFImages);
}
}
//
TopTools_ListIteratorOfListOfShape aItLF(aLFImages);
for (; aItLF.More(); aItLF.Next()) {
const TopoDS_Shape& aFIm = aItLF.Value();
aBB.Add(aFaces, aFIm);
}
}
// Fill history for edges (iteration by the map is safe because the
// order is not important here)
//
// fill history for edges
TopTools_IndexedMapOfShape aMFE;
TopExp::MapShapes(aFaces, TopAbs_EDGE, aMFE);
//
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItEIm(theEImages);
for (; aItEIm.More(); aItEIm.Next())
{
for (; aItEIm.More(); aItEIm.Next()) {
const TopoDS_Shape& aE = aItEIm.Key();
const TopTools_ListOfShape& aLEIm = aItEIm.Value();
//
Standard_Boolean bHasImage = theImage.HasImage(aE);
TopTools_ListIteratorOfListOfShape aItLE(aLEIm);
for (; aItLE.More(); aItLE.Next())
{
for (; aItLE.More(); aItLE.Next()) {
const TopoDS_Shape& aEIm = aItLE.Value();
if (anEdgesMap.Contains(aEIm))
{
if (bHasImage)
{
if (aMFE.Contains(aEIm)) {
if (bHasImage) {
theImage.Add(aE, aEIm);
}
else
{
else {
theImage.Bind(aE, aEIm);
bHasImage = Standard_True;
}

View File

@@ -2667,25 +2667,21 @@ static void MakeFace(const Handle(Geom_Surface)& S,
//purpose :
//=======================================================================
static Standard_Boolean EnlargeGeometry(Handle(Geom_Surface)& S,
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& V1,
Standard_Real& V2,
Standard_Boolean& IsV1degen,
Standard_Boolean& IsV2degen,
const Standard_Real uf1,
const Standard_Real uf2,
const Standard_Real vf1,
const Standard_Real vf2,
const Standard_Real coeff,
const Standard_Boolean theGlobalEnlargeU,
const Standard_Boolean theGlobalEnlargeVfirst,
const Standard_Boolean theGlobalEnlargeVlast,
const Standard_Real theLenBeforeUfirst,
const Standard_Real theLenAfterUlast,
const Standard_Real theLenBeforeVfirst,
const Standard_Real theLenAfterVlast)
static Standard_Boolean EnlargeGeometry(Handle(Geom_Surface)& S,
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& V1,
Standard_Real& V2,
Standard_Boolean& IsV1degen,
Standard_Boolean& IsV2degen,
const Standard_Real uf1,
const Standard_Real uf2,
const Standard_Real vf1,
const Standard_Real vf2,
const Standard_Boolean GlobalEnlargeU,
const Standard_Boolean GlobalEnlargeVfirst,
const Standard_Boolean GlobalEnlargeVlast,
const Standard_Real coeff)
{
const Standard_Real TolApex = 1.e-5;
@@ -2693,14 +2689,12 @@ static Standard_Boolean EnlargeGeometry(Handle(Geom_Surface)& S,
if ( S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
Handle(Geom_Surface) BS = Handle(Geom_RectangularTrimmedSurface)::DownCast (S)->BasisSurface();
EnlargeGeometry(BS,U1,U2,V1,V2,IsV1degen,IsV2degen,
uf1,uf2,vf1,vf2,coeff,
theGlobalEnlargeU, theGlobalEnlargeVfirst, theGlobalEnlargeVlast,
theLenBeforeUfirst, theLenAfterUlast, theLenBeforeVfirst, theLenAfterVlast);
if (!theGlobalEnlargeVfirst)
uf1,uf2,vf1,vf2,GlobalEnlargeU,GlobalEnlargeVfirst,GlobalEnlargeVlast,coeff);
if (!GlobalEnlargeVfirst)
V1 = vf1;
if (!theGlobalEnlargeVlast)
if (!GlobalEnlargeVlast)
V2 = vf2;
if (!theGlobalEnlargeVfirst || !theGlobalEnlargeVlast)
if (!GlobalEnlargeVfirst || !GlobalEnlargeVlast)
//Handle(Geom_RectangularTrimmedSurface)::DownCast (S)->SetTrim( U1, U2, V1, V2 );
S = new Geom_RectangularTrimmedSurface( BS, U1, U2, V1, V2 );
else
@@ -2710,178 +2704,159 @@ static Standard_Boolean EnlargeGeometry(Handle(Geom_Surface)& S,
else if (S->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) {
Handle(Geom_Surface) Surf = Handle(Geom_OffsetSurface)::DownCast (S)->BasisSurface();
SurfaceChange = EnlargeGeometry(Surf,U1,U2,V1,V2,IsV1degen,IsV2degen,
uf1,uf2,vf1,vf2,coeff,
theGlobalEnlargeU, theGlobalEnlargeVfirst, theGlobalEnlargeVlast,
theLenBeforeUfirst, theLenAfterUlast, theLenBeforeVfirst, theLenAfterVlast);
uf1,uf2,vf1,vf2,GlobalEnlargeU,GlobalEnlargeVfirst,GlobalEnlargeVlast,coeff);
Handle(Geom_OffsetSurface)::DownCast(S)->SetBasisSurface(Surf);
}
else if (S->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion) ||
S->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfRevolution))
{
Standard_Real du_first = 0., du_last = 0.,
dv_first = 0., dv_last = 0.;
Handle( Geom_Curve ) uiso, viso, uiso1, uiso2, viso1, viso2;
Standard_Real u1, u2, v1, v2;
Standard_Boolean enlargeU = theGlobalEnlargeU, enlargeV = Standard_True;
Standard_Boolean enlargeUfirst = enlargeU, enlargeUlast = enlargeU;
Standard_Boolean enlargeVfirst = theGlobalEnlargeVfirst, enlargeVlast = theGlobalEnlargeVlast;
S->Bounds( u1, u2, v1, v2 );
if (Precision::IsInfinite(u1) || Precision::IsInfinite(u2))
{
du_first = du_last = uf2-uf1;
u1 = uf1 - du_first;
u2 = uf2 + du_last;
enlargeU = Standard_False;
Standard_Real du=0., dv=0.;
Handle( Geom_Curve ) uiso, viso, uiso1, uiso2, viso1, viso2;
Standard_Real u1, u2, v1, v2;
Standard_Boolean enlargeU = GlobalEnlargeU, enlargeV = Standard_True;
Standard_Boolean enlargeUfirst = enlargeU, enlargeUlast = enlargeU;
Standard_Boolean enlargeVfirst = GlobalEnlargeVfirst, enlargeVlast = GlobalEnlargeVlast;
S->Bounds( u1, u2, v1, v2 );
if (Precision::IsInfinite(u1) || Precision::IsInfinite(u2))
{
du = uf2-uf1;
u1 = uf1-du;
u2 = uf2+du;
enlargeU = Standard_False;
}
else if (S->IsUClosed())
enlargeU = Standard_False;
else
{
viso = S->VIso( vf1 );
GeomAdaptor_Curve gac( viso );
du = GCPnts_AbscissaPoint::Length( gac ) * coeff;
uiso1 = S->UIso( uf1 );
uiso2 = S->UIso( uf2 );
if (BRepOffset_Tool::Gabarit( uiso1 ) <= TolApex)
enlargeUfirst = Standard_False;
if (BRepOffset_Tool::Gabarit( uiso2 ) <= TolApex)
enlargeUlast = Standard_False;
}
if (Precision::IsInfinite(v1) || Precision::IsInfinite(v2))
{
dv = vf2-vf1;
v1 = vf1-dv;
v2 = vf2+dv;
enlargeV = Standard_False;
}
else if (S->IsVClosed())
enlargeV = Standard_False;
else
{
uiso = S->UIso( uf1 );
GeomAdaptor_Curve gac( uiso );
dv = GCPnts_AbscissaPoint::Length( gac ) * coeff;
viso1 = S->VIso( vf1 );
viso2 = S->VIso( vf2 );
if (BRepOffset_Tool::Gabarit( viso1 ) <= TolApex)
{
enlargeVfirst = Standard_False;
IsV1degen = Standard_True;
}
if (BRepOffset_Tool::Gabarit( viso2 ) <= TolApex)
{
enlargeVlast = Standard_False;
IsV2degen = Standard_True;
}
}
Handle(Geom_BoundedSurface) aSurf = new Geom_RectangularTrimmedSurface( S, u1, u2, v1, v2 );
if (enlargeU)
{
if (enlargeUfirst)
GeomLib::ExtendSurfByLength (aSurf, du, 1, Standard_True, Standard_False);
if (enlargeUlast)
GeomLib::ExtendSurfByLength (aSurf, du, 1, Standard_True, Standard_True);
}
if (enlargeV)
{
if (enlargeVfirst)
GeomLib::ExtendSurfByLength (aSurf, dv, 1, Standard_False, Standard_False);
if (enlargeVlast)
GeomLib::ExtendSurfByLength (aSurf, dv, 1, Standard_False, Standard_True);
}
S = aSurf;
S->Bounds( U1, U2, V1, V2 );
SurfaceChange = Standard_True;
}
else if (S->IsUClosed())
enlargeU = Standard_False;
else
{
viso = S->VIso( vf1 );
GeomAdaptor_Curve gac( viso );
Standard_Real du_default = GCPnts_AbscissaPoint::Length( gac ) * coeff;
du_first = (theLenBeforeUfirst == -1)? du_default : theLenBeforeUfirst;
du_last = (theLenAfterUlast == -1)? du_default : theLenAfterUlast;
uiso1 = S->UIso( uf1 );
uiso2 = S->UIso( uf2 );
if (BRepOffset_Tool::Gabarit( uiso1 ) <= TolApex)
enlargeUfirst = Standard_False;
if (BRepOffset_Tool::Gabarit( uiso2 ) <= TolApex)
enlargeUlast = Standard_False;
}
if (Precision::IsInfinite(v1) || Precision::IsInfinite(v2))
{
dv_first = dv_last = vf2-vf1;
v1 = vf1 - dv_first;
v2 = vf2 + dv_last;
enlargeV = Standard_False;
}
else if (S->IsVClosed())
enlargeV = Standard_False;
else
{
uiso = S->UIso( uf1 );
GeomAdaptor_Curve gac( uiso );
Standard_Real dv_default = GCPnts_AbscissaPoint::Length( gac ) * coeff;
dv_first = (theLenBeforeVfirst == -1)? dv_default : theLenBeforeVfirst;
dv_last = (theLenAfterVlast == -1)? dv_default : theLenAfterVlast;
viso1 = S->VIso( vf1 );
viso2 = S->VIso( vf2 );
if (BRepOffset_Tool::Gabarit( viso1 ) <= TolApex)
{
enlargeVfirst = Standard_False;
IsV1degen = Standard_True;
}
if (BRepOffset_Tool::Gabarit( viso2 ) <= TolApex)
{
enlargeVlast = Standard_False;
IsV2degen = Standard_True;
}
}
Handle(Geom_BoundedSurface) aSurf = new Geom_RectangularTrimmedSurface( S, u1, u2, v1, v2 );
if (enlargeU)
{
if (enlargeUfirst && du_first != 0.)
GeomLib::ExtendSurfByLength (aSurf, du_first, 1, Standard_True, Standard_False);
if (enlargeUlast && du_last != 0.)
GeomLib::ExtendSurfByLength (aSurf, du_last, 1, Standard_True, Standard_True);
}
if (enlargeV)
{
if (enlargeVfirst && dv_first != 0.)
GeomLib::ExtendSurfByLength (aSurf, dv_first, 1, Standard_False, Standard_False);
if (enlargeVlast && dv_last != 0.)
GeomLib::ExtendSurfByLength (aSurf, dv_last, 1, Standard_False, Standard_True);
}
S = aSurf;
S->Bounds( U1, U2, V1, V2 );
SurfaceChange = Standard_True;
}
else if (S->DynamicType() == STANDARD_TYPE(Geom_BezierSurface) ||
S->DynamicType() == STANDARD_TYPE(Geom_BSplineSurface))
{
Standard_Boolean enlargeU = theGlobalEnlargeU, enlargeV = Standard_True;
Standard_Boolean enlargeUfirst = enlargeU, enlargeUlast = enlargeU;
Standard_Boolean enlargeVfirst = theGlobalEnlargeVfirst, enlargeVlast = theGlobalEnlargeVlast;
if (S->IsUClosed())
enlargeU = Standard_False;
if (S->IsVClosed())
enlargeV = Standard_False;
Standard_Real duf = uf2-uf1, dvf = vf2-vf1;
Standard_Real u1, u2, v1, v2;
S->Bounds( u1, u2, v1, v2 );
Standard_Real du_first = 0., du_last = 0.,
dv_first = 0., dv_last = 0.;
Handle( Geom_Curve ) uiso1, uiso2, viso1, viso2;
Standard_Real gabarit_uiso1, gabarit_uiso2, gabarit_viso1, gabarit_viso2;
{
Standard_Boolean enlargeU = GlobalEnlargeU, enlargeV = Standard_True;
Standard_Boolean enlargeUfirst = enlargeU, enlargeUlast = enlargeU;
Standard_Boolean enlargeVfirst = GlobalEnlargeVfirst, enlargeVlast = GlobalEnlargeVlast;
if (S->IsUClosed())
enlargeU = Standard_False;
if (S->IsVClosed())
enlargeV = Standard_False;
uiso1 = S->UIso( u1 );
uiso2 = S->UIso( u2 );
viso1 = S->VIso( v1 );
viso2 = S->VIso( v2 );
gabarit_uiso1 = BRepOffset_Tool::Gabarit( uiso1 );
gabarit_uiso2 = BRepOffset_Tool::Gabarit( uiso2 );
gabarit_viso1 = BRepOffset_Tool::Gabarit( viso1 );
gabarit_viso2 = BRepOffset_Tool::Gabarit( viso2 );
if (gabarit_viso1 <= TolApex ||
gabarit_viso2 <= TolApex)
enlargeU = Standard_False;
if (gabarit_uiso1 <= TolApex ||
gabarit_uiso2 <= TolApex)
enlargeV = Standard_False;
GeomAdaptor_Curve gac;
if (enlargeU)
{
gac.Load( viso1 );
Standard_Real du_default = GCPnts_AbscissaPoint::Length( gac ) * coeff;
du_first = (theLenBeforeUfirst == -1)? du_default : theLenBeforeUfirst;
du_last = (theLenAfterUlast == -1)? du_default : theLenAfterUlast;
if (gabarit_uiso1 <= TolApex)
enlargeUfirst = Standard_False;
if (gabarit_uiso2 <= TolApex)
enlargeUlast = Standard_False;
Standard_Real duf = uf2-uf1, dvf = vf2-vf1;
Standard_Real u1, u2, v1, v2;
S->Bounds( u1, u2, v1, v2 );
Standard_Real du=0., dv=0.;
Handle( Geom_Curve ) uiso, viso, uiso1, uiso2, viso1, viso2;
GeomAdaptor_Curve gac;
if (enlargeU)
{
viso = S->VIso( v1 );
gac.Load( viso );
du = GCPnts_AbscissaPoint::Length( gac ) * coeff;
uiso1 = S->UIso( u1 );
uiso2 = S->UIso( u2 );
if (BRepOffset_Tool::Gabarit( uiso1 ) <= TolApex)
enlargeUfirst = Standard_False;
if (BRepOffset_Tool::Gabarit( uiso2 ) <= TolApex)
enlargeUlast = Standard_False;
}
if (enlargeV)
{
uiso = S->UIso( u1 );
gac.Load( uiso );
dv = GCPnts_AbscissaPoint::Length( gac ) * coeff;
viso1 = S->VIso( v1 );
viso2 = S->VIso( v2 );
if (BRepOffset_Tool::Gabarit( viso1 ) <= TolApex)
{
enlargeVfirst = Standard_False;
IsV1degen = Standard_True;
}
if (BRepOffset_Tool::Gabarit( viso2 ) <= TolApex)
{
enlargeVlast = Standard_False;
IsV2degen = Standard_True;
}
}
Handle(Geom_BoundedSurface) aSurf = Handle(Geom_BoundedSurface)::DownCast (S);
if (enlargeU)
{
if (enlargeUfirst && uf1-u1 < duf)
GeomLib::ExtendSurfByLength (aSurf, du, 1, Standard_True, Standard_False);
if (enlargeUlast && u2-uf2 < duf)
GeomLib::ExtendSurfByLength (aSurf, du, 1, Standard_True, Standard_True);
}
if (enlargeV)
{
if (enlargeVfirst && vf1-v1 < dvf)
GeomLib::ExtendSurfByLength (aSurf, dv, 1, Standard_False, Standard_False);
if (enlargeVlast && v2-vf2 < dvf)
GeomLib::ExtendSurfByLength (aSurf, dv, 1, Standard_False, Standard_True);
}
S = aSurf;
S->Bounds( U1, U2, V1, V2 );
SurfaceChange = Standard_True;
}
if (enlargeV)
{
gac.Load( uiso1 );
Standard_Real dv_default = GCPnts_AbscissaPoint::Length( gac ) * coeff;
dv_first = (theLenBeforeVfirst == -1)? dv_default : theLenBeforeVfirst;
dv_last = (theLenAfterVlast == -1)? dv_default : theLenAfterVlast;
if (gabarit_viso1 <= TolApex)
{
enlargeVfirst = Standard_False;
IsV1degen = Standard_True;
}
if (gabarit_viso2 <= TolApex)
{
enlargeVlast = Standard_False;
IsV2degen = Standard_True;
}
}
Handle(Geom_BoundedSurface) aSurf = Handle(Geom_BoundedSurface)::DownCast (S);
if (enlargeU)
{
if (enlargeUfirst && uf1-u1 < duf && du_first != 0.)
GeomLib::ExtendSurfByLength (aSurf, du_first, 1, Standard_True, Standard_False);
if (enlargeUlast && u2-uf2 < duf && du_last != 0.)
GeomLib::ExtendSurfByLength (aSurf, du_last, 1, Standard_True, Standard_True);
}
if (enlargeV)
{
if (enlargeVfirst && vf1-v1 < dvf && dv_first != 0.)
GeomLib::ExtendSurfByLength (aSurf, dv_first, 1, Standard_False, Standard_False);
if (enlargeVlast && v2-vf2 < dvf && dv_last != 0.)
GeomLib::ExtendSurfByLength (aSurf, dv_last, 1, Standard_False, Standard_True);
}
S = aSurf;
S->Bounds( U1, U2, V1, V2 );
SurfaceChange = Standard_True;
}
// else if (S->DynamicType() == STANDARD_TYPE(Geom_BezierSurface) ||
// S->DynamicType() == STANDARD_TYPE(Geom_BSplineSurface)) {
// S->Bounds(U1,U2,V1,V2);
// }
else {
Standard_Real UU1,UU2,VV1,VV2;
S->Bounds(UU1,UU2,VV1,VV2);
@@ -3088,14 +3063,10 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
TopoDS_Face& BF,
const Standard_Boolean CanExtentSurface,
const Standard_Boolean UpdatePCurve,
const Standard_Boolean theEnlargeU,
const Standard_Boolean theEnlargeVfirst,
const Standard_Boolean theEnlargeVlast,
const Standard_Integer theExtensionMode,
const Standard_Real theLenBeforeUfirst,
const Standard_Real theLenAfterUlast,
const Standard_Real theLenBeforeVfirst,
const Standard_Real theLenAfterVlast)
const Standard_Boolean enlargeU,
const Standard_Boolean enlargeVfirst,
const Standard_Boolean enlargeVlast,
const Standard_Integer ExtensionMode)
{
//---------------------------
// extension de la geometrie.
@@ -3118,7 +3089,7 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
S->Bounds (US1,US2,VS1,VS2);
Standard_Real coeff;
if (theExtensionMode == 1)
if (ExtensionMode == 1)
{
UU1 = VV1 = - TheInfini;
UU2 = VV2 = TheInfini;
@@ -3136,9 +3107,8 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
}
if (CanExtentSurface) {
SurfaceChange = EnlargeGeometry(S, UU1, UU2, VV1, VV2, isVV1degen, isVV2degen, UF1, UF2, VF1, VF2, coeff,
theEnlargeU, theEnlargeVfirst, theEnlargeVlast,
theLenBeforeUfirst, theLenAfterUlast, theLenBeforeVfirst, theLenAfterVlast);
SurfaceChange = EnlargeGeometry( S, UU1, UU2, VV1, VV2, isVV1degen, isVV2degen, UF1, UF2, VF1, VF2,
enlargeU, enlargeVfirst, enlargeVlast, coeff );
}
else {
UU1 = Max(US1,UU1); UU2 = Min(UU2,US2);
@@ -3187,13 +3157,13 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
}
}
if (!theEnlargeU)
if (!enlargeU)
{
UU1 = UF1; UU2 = UF2;
}
if (!theEnlargeVfirst)
if (!enlargeVfirst)
VV1 = VF1;
if (!theEnlargeVlast)
if (!enlargeVlast)
VV2 = VF2;
//Detect closedness in U and V directions

View File

@@ -131,22 +131,17 @@ public:
Standard_Boolean& enlargeVfirst,
Standard_Boolean& enlargeVlast);
//! Returns True if The Surface of <NF> has changed.
//! if <ChangeGeom> is TRUE , the surface can be
//! changed .
//! if <UpdatePCurve> is TRUE, update the pcurves of the
//! edges of <F> on the new surface if the surface has been changed.
//! <enlargeU>, <enlargeVfirst>, <enlargeVlast> allow or forbid
//! enlargement in U and V directions correspondingly.
//! <theExtensionMode> is a mode of extension of the surface of the face:
//! if <theExtensionMode> equals 1, potentially infinite surfaces are extended by maximum value,
//! edges of <F> on the new surface.if the surface has been changed,
//! Returns True if The Surface of <NF> has changed.
//! <ExtensionMode> is a mode of extension of the surface of the face:
//! if <ExtensionMode> equals 1, potentially infinite surfaces are extended by maximum value,
//! and limited surfaces are extended by 25%.
//! if <theExtensionMode> equals 2, potentially infinite surfaces are extended by
//! if <ExtensionMode> equals 2, potentially infinite surfaces are extended by
//! 10*(correspondent size of face),
//! and limited surfaces are extended by 100%.
//! <theLenBeforeUfirst>, <theLenAfterUlast>, <theLenBeforeVfirst>, <theLenAfterVlast>
//! set the values of enlargement on correspondent directions.
//! If some of them equals -1, the default value of enlargement is used.
Standard_EXPORT static Standard_Boolean EnLargeFace (const TopoDS_Face& F,
TopoDS_Face& NF,
const Standard_Boolean ChangeGeom,
@@ -154,11 +149,7 @@ public:
const Standard_Boolean enlargeU = Standard_True,
const Standard_Boolean enlargeVfirst = Standard_True,
const Standard_Boolean enlargeVlast = Standard_True,
const Standard_Integer theExtensionMode = 1,
const Standard_Real theLenBeforeUfirst = -1.,
const Standard_Real theLenAfterUlast = -1.,
const Standard_Real theLenBeforeVfirst = -1.,
const Standard_Real theLenAfterVlast = -1.);
const Standard_Integer ExtensionMode = 1);
Standard_EXPORT static void ExtentFace (const TopoDS_Face& F,
TopTools_DataMapOfShapeShape& ConstShapes,

View File

@@ -114,10 +114,7 @@ TopoDS_Shape BRepPrimAPI_MakePrism::LastShape()
const TopTools_ListOfShape& BRepPrimAPI_MakePrism::Generated (const TopoDS_Shape& S)
{
myGenerated.Clear();
if (myPrism.IsUsed(S) && myPrism.GenIsUsed(S))
{
myGenerated.Append(myPrism.Shape(S));
}
myGenerated.Append(myPrism.Shape (S));
return myGenerated;
}
@@ -149,13 +146,3 @@ TopoDS_Shape BRepPrimAPI_MakePrism::LastShape(const TopoDS_Shape &theShape)
}
// Modified by skv - Fri Mar 4 15:50:09 2005 End
//=======================================================================
//function : IsDeleted
//purpose :
//=======================================================================
Standard_Boolean BRepPrimAPI_MakePrism::IsDeleted(const TopoDS_Shape& S)
{
return !myPrism.IsUsed(S);
}

View File

@@ -87,10 +87,7 @@ public:
//! Returns ListOfShape from TopTools.
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE;
//! Returns true if the shape S has been deleted.
Standard_EXPORT virtual Standard_Boolean IsDeleted(const TopoDS_Shape& S) Standard_OVERRIDE;
//! Returns the TopoDS Shape of the bottom of the prism.
//! generated with theShape (subShape of the generating shape).
Standard_EXPORT TopoDS_Shape FirstShape (const TopoDS_Shape& theShape);
@@ -99,6 +96,9 @@ public:
//! generated with theShape (subShape of the generating shape).
Standard_EXPORT TopoDS_Shape LastShape (const TopoDS_Shape& theShape);
protected:

View File

@@ -240,49 +240,16 @@ TopoDS_Shape BRepPrimAPI_MakeRevol::LastShape()
const TopTools_ListOfShape& BRepPrimAPI_MakeRevol::Generated (const TopoDS_Shape& S)
{
myGenerated.Clear();
if (!myRevol.IsUsed(S))
{
return myGenerated;
}
TopoDS_Shape aGS = myRevol.Shape(S);
if (!aGS.IsNull())
{
if (BRepTools_History::IsSupportedType(aGS))
{
if (aGS.ShapeType() == TopAbs_EDGE)
{
Standard_Boolean isDeg = BRep_Tool::Degenerated(TopoDS::Edge(aGS));
if (isDeg)
{
TopTools_ListIteratorOfListOfShape anIt(myDegenerated);
for (; anIt.More(); anIt.Next())
{
if (aGS.IsSame(anIt.Value()))
{
myGenerated.Append(aGS);
if (!myHist.IsNull())
{
TopTools_ListIteratorOfListOfShape anIt1(myHist->Modified(aGS));
for (; anIt1.More(); anIt1.Next())
{
myGenerated.Append(anIt1.Value());
}
return myGenerated;
}
}
}
return myGenerated;
}
}
//
if (myHist.IsNull())
{
myGenerated.Append(aGS);
return myGenerated;
}
//
if (myHist->Modified(aGS).IsEmpty())
{
myGenerated.Append(aGS);
@@ -294,19 +261,18 @@ const TopTools_ListOfShape& BRepPrimAPI_MakeRevol::Generated (const TopoDS_Shape
{
myGenerated.Append(anIt.Value());
}
if (aGS.ShapeType() == TopAbs_EDGE)
{
if (BRep_Tool::Degenerated(TopoDS::Edge(aGS)))
{
//Append initial common deg. edge
myGenerated.Append(aGS);
}
}
}
}
return myGenerated;
}
//=======================================================================
//function : IsDeleted
//purpose :
//=======================================================================
Standard_Boolean BRepPrimAPI_MakeRevol::IsDeleted(const TopoDS_Shape& S)
{
return !myRevol.IsUsed(S);
}
//=======================================================================
//function : FirstShape

View File

@@ -95,10 +95,6 @@ public:
//! Warning: shape S must be shape of type VERTEX, EDGE, FACE, SOLID.
//! For shapes of other types method always returns empty list
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE;
//! Returns true if the shape S has been deleted.
Standard_EXPORT virtual Standard_Boolean IsDeleted(const TopoDS_Shape& S) Standard_OVERRIDE;
//! Returns the TopoDS Shape of the beginning of the revolution,
//! generated with theShape (subShape of the generating shape).

View File

@@ -30,7 +30,6 @@
#include <TopAbs_Orientation.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <TopoDS.hxx>
//=======================================================================
//function : BRepSweep_NumLinearRegularSweep
@@ -55,12 +54,9 @@ myBuilder(aBuilder),
myShapes(1,myGenShapeTool.NbShapes(),
1,myDirShapeTool.NbShapes()),
myBuiltShapes(1,myGenShapeTool.NbShapes(),
1,myDirShapeTool.NbShapes()),
myUsedShapes(1, myGenShapeTool.NbShapes(),
1, myDirShapeTool.NbShapes())
1,myDirShapeTool.NbShapes())
{
myBuiltShapes.Init(Standard_False);
myUsedShapes.Init(Standard_False);
}
//=======================================================================
@@ -160,9 +156,7 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
Or = It.Orientation();
if(HasShape(subGenS,aDirS)){
newShape = Shape(subGenS,aDirS);
Standard_Integer iNewGenS = myGenShapeTool.Index(subGenS);
Standard_Integer iNewDirS = iDirS;
if (GGDShapeIsToAdd(myShapes(iGenS, iDirS), newShape,
if (GGDShapeIsToAdd(myShapes(iGenS,iDirS),newShape,
aGenS,subGenS,aDirS)){
//Les "planchers" doivent etre construits par les
//fonctions de construcion geometrique identiquement
@@ -171,7 +165,6 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
//sur.
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
TopAbs_ShapeEnum subGenSType = myGenShapeTool.Type(subGenS);
if (aGenSType==TopAbs_FACE){
if(subGenSType==TopAbs_VERTEX){
@@ -255,9 +248,7 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
subGenS = It.Value();
if(HasShape(subGenS,aDirS)){
newShape = Shape(subGenS,aDirS);
Standard_Integer iNewGenS = myGenShapeTool.Index(subGenS);
Standard_Integer iNewDirS = iDirS;
if (GGDShapeIsToAdd(myShapes(iGenS, iDirS), newShape,
if (GGDShapeIsToAdd(myShapes(iGenS,iDirS),newShape,
aGenS,subGenS,aDirS)){
TopAbs_ShapeEnum subGenSType = myGenShapeTool.Type(subGenS);
if (aGenSType==TopAbs_EDGE){
@@ -268,13 +259,11 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
TopoDS_Shape wi;
myBuilder.MakeWire(wi);
myBuilder.Add(wi,newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
wi.Closed(BRep_Tool::IsClosed(wi));
WireSeq.Append(wi);
}
else{
myBuilder.Add(newWire,newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
}
SetDirectingPCurve (myShapes(iGenS,iDirS),
newShape,bGenS,subGenS,aDirS,Or);
@@ -282,7 +271,6 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
else if (aGenSType==TopAbs_WIRE){
Or = It.Orientation();
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
}
else if (aGenSType==TopAbs_FACE){
Or = It.Orientation();
@@ -294,23 +282,19 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
}
else if(subGenSType == TopAbs_EDGE) {
myBuilder.Add(newShell,newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
}
}
else if(aGenSType == TopAbs_SHELL){
Or = TopAbs_FORWARD;
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
}
else if(aGenSType == TopAbs_COMPOUND){
Or = TopAbs_FORWARD;
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
}
else{
Or = It.Orientation();
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
}
}
}
@@ -320,28 +304,23 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
subDirS = Kt.Value();
if(HasShape(aGenS,subDirS)){
newShape = Shape(aGenS,subDirS);
Standard_Integer iNewGenS = iGenS;
Standard_Integer iNewDirS = myDirShapeTool.Index(subDirS);
if (GDDShapeIsToAdd(myShapes(iGenS,iDirS),newShape,
aGenS,aDirS,subDirS)){
if (aGenSType==TopAbs_EDGE){
Or = TopAbs::Reverse(Kt.Orientation());
myBuilder.Add(newWire,newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
SetGeneratingPCurve
(myShapes(iGenS,iDirS),newShape,aGenS,aDirS,subDirS,Or);
}
else if(aGenSType==TopAbs_VERTEX){
Or = Kt.Orientation();
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
SetDirectingParameter
(myShapes(iGenS,iDirS),newShape,aGenS,aDirS,subDirS);
}
else if(aGenSType==TopAbs_FACE){
Or = Kt.Orientation();
myBuilder.Add(newShell,newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
}
}
}
@@ -411,12 +390,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
for (Kt.Init(aDirS);Kt.More();Kt.Next()){
subDirS = Kt.Value();
if(HasShape(aGenS,subDirS)){
Standard_Integer iNewGenS = iGenS;
Standard_Integer iNewDirS = myDirShapeTool.Index(subDirS);
Or = Kt.Orientation();
newShape = Shape(aGenS,subDirS);
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
}
}
}
@@ -516,67 +492,3 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::SplitShell(const TopoDS_Shape& aNe
return comp;
}
//=======================================================================
//function : IsUsed
//purpose :
//=======================================================================
Standard_Boolean BRepSweep_NumLinearRegularSweep::IsUsed(const TopoDS_Shape& aGenS) const
{
Standard_Integer iGenS = myGenShapeTool.Index(aGenS);
Standard_OutOfRange_Raise_if(iGenS == 0,
"BRepSweep_NumLinearRegularSweep::IsUsed: shape index = 0")
Standard_Integer j;
Standard_Boolean isBuilt = Standard_False;
Standard_Boolean isUsed = Standard_False;
for (j = 2; j <= myBuiltShapes.UpperCol(); ++j)
{
isBuilt = isBuilt || myBuiltShapes(iGenS, j);
isUsed = isUsed || myUsedShapes(iGenS, j);
}
if (isUsed)
{
if (aGenS.ShapeType() == TopAbs_VERTEX && IsInvariant(aGenS))
{
if (myUsedShapes(iGenS, 1) || !Closed())
{
return isUsed;
}
else
{
return Standard_False;
}
}
else
{
return isUsed;
}
}
//
if (isBuilt) //&& !IsUsed
{
if (!HasShape(aGenS, myDirWire) && !Closed())
{
return Standard_True;
}
else if (aGenS.ShapeType() == TopAbs_VERTEX && !Closed())
{
if (!myBuiltShapes(iGenS, 1))
{
return Standard_True;
}
}
}
return isUsed;
}
//=======================================================================
//function : GenIsUsed
//purpose :
//=======================================================================
Standard_Boolean BRepSweep_NumLinearRegularSweep::GenIsUsed(const TopoDS_Shape& aGenS) const
{
Standard_Integer iGenS = myGenShapeTool.Index(aGenS);
Standard_OutOfRange_Raise_if(iGenS == 0,
"BRepSweep_NumLinearRegularSweep::GenIsUsed: shape index = 0")
return myBuiltShapes(iGenS, 1) && myUsedShapes(iGenS, 1);
}

View File

@@ -171,10 +171,7 @@ public:
//! can be geometrically inexsistant, then this
//! function returns false.
Standard_EXPORT virtual Standard_Boolean HasShape (const TopoDS_Shape& aGenS, const Sweep_NumShape& aDirS) const = 0;
//! Returns true if aGenS cannot be transformed.
Standard_EXPORT virtual Standard_Boolean IsInvariant(const TopoDS_Shape& aGenS) const = 0;
//! Returns the resulting Shape indexed by aDirS and
//! aGenS.
Standard_EXPORT TopoDS_Shape Shape (const TopoDS_Shape& aGenS, const Sweep_NumShape& aDirS);
@@ -182,15 +179,7 @@ public:
//! Returns the resulting Shape indexed by myDirWire
//! and aGenS.
Standard_EXPORT TopoDS_Shape Shape (const TopoDS_Shape& aGenS);
//! Returns true if the initial shape aGenS
//! is used in result shape
Standard_EXPORT Standard_Boolean IsUsed(const TopoDS_Shape& aGenS) const;
//! Returns true if the shape, generated from theS
//! is used in result shape
Standard_EXPORT Standard_Boolean GenIsUsed(const TopoDS_Shape& theS) const;
//! Returns the resulting Shape indexed by myDirWire
//! and myGenShape.
Standard_EXPORT TopoDS_Shape Shape();
@@ -231,7 +220,6 @@ protected:
Sweep_NumShapeTool myDirShapeTool;
TopTools_Array2OfShape myShapes;
TColStd_Array2OfBoolean myBuiltShapes;
TColStd_Array2OfBoolean myUsedShapes;
private:

View File

@@ -185,21 +185,3 @@ TopLoc_Location BRepSweep_Prism::Location(const gp_Vec& V)const
TopLoc_Location L(gpt);
return L;
}
//=======================================================================
//function : IsUsed
//purpose :
//=======================================================================
Standard_Boolean BRepSweep_Prism::IsUsed(const TopoDS_Shape& aGenS) const
{
return myTranslation.IsUsed(aGenS);
}
//=======================================================================
//function : GenIsUsed
//purpose :
//=======================================================================
Standard_Boolean BRepSweep_Prism::GenIsUsed(const TopoDS_Shape& aGenS) const
{
return myTranslation.GenIsUsed(aGenS);
}

View File

@@ -80,13 +80,7 @@ public:
Standard_EXPORT gp_Vec Vec() const;
//! Returns true if the
//! aGenS is used in resulting shape
Standard_EXPORT Standard_Boolean IsUsed(const TopoDS_Shape& aGenS) const;
//! Returns true if the shape, generated from theS
//! is used in result shape
Standard_EXPORT Standard_Boolean GenIsUsed(const TopoDS_Shape& theS) const;
protected:

View File

@@ -215,11 +215,3 @@ gp_Ax1 BRepSweep_Revol::Axe()const
}
//=======================================================================
//function : IsUsed
//purpose :
//=======================================================================
Standard_Boolean BRepSweep_Revol::IsUsed(const TopoDS_Shape& aGenS) const
{
return myRotation.IsUsed(aGenS);
}

View File

@@ -77,10 +77,6 @@ public:
//! returns the angle.
Standard_EXPORT Standard_Real Angle() const;
//! Returns true if the aGenS is used in resulting Shape
Standard_EXPORT Standard_Boolean IsUsed(const TopoDS_Shape& aGenS) const;
private:
//! builds the NumShape.

View File

@@ -160,7 +160,7 @@ TopoDS_Shape BRepSweep_Rotation::MakeEmptyVertex
{
//call only in construction mode with copy.
Standard_ConstructionError_Raise_if
(!myCopy,"BRepSweep_Rotation::MakeEmptyVertex");
(!myCopy,"BRepSweep_Translation::MakeEmptyVertex");
gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aGenV));
TopoDS_Vertex V;
if (aDirV.Index()==2) P.Transform(myLocation.Transformation());

View File

@@ -28,127 +28,6 @@
#include <Precision.hxx>
//===============================================================================
// function : chamf_throat_with_penetration
// purpose : command to construct chamfers with constant throat with penetration
// on several edges
// Here the chamfer is propagated on tangential edges to the
// required edge
//===============================================================================
static Standard_Integer chamf_throat_with_penetration(Draw_Interpretor& di,
Standard_Integer narg,
const char** a)
{
if (narg < 7)
return 1;
TopoDS_Shape S = DBRep::Get(a[2]);
if (S.IsNull()) return 1;
TopoDS_Edge E;
TopoDS_Face F;
Standard_Real offset, throat;
Standard_Integer i = 3;
Standard_Integer NbArg = 4;
BRepFilletAPI_MakeChamfer aMCh(S);
aMCh.SetMode(ChFiDS_ConstThroatWithPenetrationChamfer);
while (i + NbArg <= narg) {
TopoDS_Shape aLocalEdge(DBRep::Get(a[i], TopAbs_EDGE));
E = TopoDS::Edge(aLocalEdge);
TopoDS_Shape aLocalFace(DBRep::Get(a[i + 1], TopAbs_FACE));
F = TopoDS::Face(aLocalFace);
// E = TopoDS::Edge(DBRep::Get(a[i], TopAbs_EDGE));
// F = TopoDS::Face(DBRep::Get(a[i + 1], TopAbs_FACE));
if (!E.IsNull() && !F.IsNull() && (aMCh.Contour(E) == 0) ) {
offset = Draw::Atof(a[i + 2]);
throat = Draw::Atof(a[i + 3]);
if (offset > Precision::Confusion() &&
throat > offset)
aMCh.Add(offset,throat,E ,F);
}
i += NbArg;
}
// compute the chamfer and display the result
if (aMCh.NbContours() == 0 )
{
//cout<<"No suitable edges to chamfer"<<endl;
di<<"No suitable edges to chamfer\n";
return 1;
}
else aMCh.Build();
if (aMCh.IsDone()){
DBRep::Set(a[1],aMCh);
return 0;
}
else {
//cout<<"compute of chamfer failed"<<endl;
di<<"compute of chamfer failed\n";
return 1;
}
}
//===============================================================================
// function : chamf_throat
// purpose : command to construct chamfers with constant throat on several edges
// Here the chamfer is propagated on tangential edges to the
// required edge
//===============================================================================
static Standard_Integer chamf_throat(Draw_Interpretor& di,
Standard_Integer narg,
const char** a)
{
if (narg < 5)
return 1;
TopoDS_Shape S = DBRep::Get(a[2]);
if (S.IsNull()) return 1;
TopoDS_Edge E;
Standard_Real throat;
Standard_Integer i = 3;
BRepFilletAPI_MakeChamfer aMCh(S);
aMCh.SetMode(ChFiDS_ConstThroatChamfer);
while (i + 1 < narg) {
TopoDS_Shape aLocalEdge(DBRep::Get(a[i], TopAbs_EDGE));
E = TopoDS::Edge(aLocalEdge);
if (!E.IsNull() && (aMCh.Contour(E) == 0) ) {
throat = Draw::Atof(a[i + 1]);
if (throat > Precision::Confusion())
aMCh.Add(throat, E);
}
i += 2;
}
// compute the chamfer and display the result
if (aMCh.NbContours() == 0 )
{
//cout<<"No suitable edges to chamfer"<<endl;
di<<"No suitable edges to chamfer\n";
return 1;
}
else aMCh.Build();
if (aMCh.IsDone()){
DBRep::Set(a[1],aMCh);
return 0;
}
else {
//cout<<"compute of chamfer failed"<<endl;
di<<"compute of chamfer failed\n";
return 1;
}
}
//=========================================================================
// function : chamfer
// purpose : command to construct chamfers on several edges
@@ -157,78 +36,98 @@ static Standard_Integer chamf_throat(Draw_Interpretor& di,
//=========================================================================
static Standard_Integer chamfer(Draw_Interpretor& di,
Standard_Integer narg,
const char** a)
Standard_Integer narg,
const char** a)
{
// check the argument number of the command
if (narg == 1) {
//cout <<" help for chamf : "<< endl;
//cout <<" Construction by equal distances from edge : chamf newname shape edge face S dist"<< endl;
//cout <<" Construction by two distances from edge : chamf newname shape edge face dist1 dist2"<< endl;
//cout <<" Construction by distance from edge and given angle : chamf newname shape edge face A dist angle"<< endl;
di <<" help for chamf : \n";
di <<" Construction by equal distances from edge : chamf newname shape edge dist\n";
di <<" Construction by equal distances from edge : chamf newname shape edge face S dist\n";
di <<" Construction by two distances from edge : chamf newname shape edge face dist1 dist2\n";
di <<" Construction by distance from edge and given angle : chamf newname shape edge face A dist angle\n";
}
else {
if (narg < 5)
return 1;
if (narg < 7) return 1;
TopoDS_Shape S = DBRep::Get(a[2]);
if (S.IsNull())
return 1;
if (S.IsNull()) return 1;
TopoDS_Edge E;
TopoDS_Face F;
Standard_Real d1,d2, angle;
Standard_Integer i = 3;
Standard_Integer Method = 1;
Standard_Integer NbArg = 3;
BRepFilletAPI_MakeChamfer aMCh(S);
while (i + 1 < narg) {
if (!strcasecmp(a[i + 2], "S") ) Method = 0;
if (Method != 0) {
if (!strcasecmp(a[i + 2], "A")) {
Method = 2;
NbArg++;
}
}
while (i + NbArg < narg) {
TopoDS_Shape aLocalEdge(DBRep::Get(a[i], TopAbs_EDGE));
if (aLocalEdge.IsNull())
return 1;
E = TopoDS::Edge(aLocalEdge);
TopoDS_Shape aLocalFace(DBRep::Get(a[i + 1], TopAbs_FACE));
if (aLocalFace.IsNull())
{
//symmetric chamfer (one distance)
d1 = atof(a[i + 1]);
if (aMCh.Contour(E) == 0 &&
d1 > Precision::Confusion())
aMCh.Add(d1, E);
i += 2;
}
else
{
F = TopoDS::Face(aLocalFace);
F = TopoDS::Face(aLocalFace);
// E = TopoDS::Edge(DBRep::Get(a[i], TopAbs_EDGE));
// F = TopoDS::Face(DBRep::Get(a[i + 1], TopAbs_FACE));
if (Method == 0) {
if (!E.IsNull() && !F.IsNull() && (aMCh.Contour(E) == 0) ) {
d1 = Draw::Atof(a[i + 3]);
if (i + 3 < narg)
{
if (!strcasecmp(a[i + 2], "A") &&
i + 4 < narg)
{
//chamfer with distance and angle
d1 = Draw::Atof(a[i + 3]);
angle = Draw::Atof(a[i + 4]);
angle *= M_PI / 180.;
if (aMCh.Contour(E) == 0 &&
d1 > Precision::Confusion() &&
angle > Precision::Confusion() &&
M_PI/2 - angle > Precision::Confusion())
aMCh.AddDA(d1, angle, E, F);
i += 5;
}
else
{
//chamfer with two distances
d1 = Draw::Atof(a[i + 2]);
d2 = Draw::Atof(a[i + 3]);
if (aMCh.Contour(E) == 0 &&
d1 > Precision::Confusion() &&
d2 > Precision::Confusion())
aMCh.Add(d1, d2, E, F);
i += 4;
if ( d1 > Precision::Confusion())
aMCh.Add(d1,E ,F);
}
i += 4;
}
else if (Method == 1) {
if (!E.IsNull() && !F.IsNull() && (aMCh.Contour(E) == 0) ) {
d1 = Draw::Atof(a[i + 2]);
d2 = Draw::Atof(a[i + 3]);
if ( (d1 > Precision::Confusion())
&& (d2 > Precision::Confusion()) )
aMCh.Add(d1,d2,E,F);
}
i += 4;
}
else {
if (!E.IsNull() && !F.IsNull() && (aMCh.Contour(E) == 0) ) {
d1 = Draw::Atof(a[i + 3]);
angle = Draw::Atof(a[i + 4]);
angle *= M_PI / 180.;
if ( (d1 > Precision::Confusion())
&& (angle > Precision::Confusion())
&& (M_PI / 2.- angle > Precision::Confusion()) )
aMCh.AddDA(d1, angle, E, F);
}
i += 5;
}
if ( i < narg) {
Method = 1;
NbArg = 3;
if (!strcasecmp(a[i + 2], "S") ) Method = 0;
if (Method != 0) {
if (!strcasecmp(a[i + 2], "A")) {
Method = 2;
NbArg++;
}
}
}
}
@@ -251,8 +150,8 @@ static Standard_Integer chamfer(Draw_Interpretor& di,
return 1;
}
}
return 0;
return 0;
}
@@ -278,11 +177,4 @@ void BRepTest::ChamferCommands(Draw_Interpretor& theCommands)
theCommands.Add("chamf",
"for help call chamf without arguments",__FILE__,chamfer,g);
theCommands.Add("chamf_throat",
"chamf_throat result shape edge throat"
,__FILE__,chamf_throat,g);
theCommands.Add("chamf_throat_with_penetration",
"chamf_throat_with_penetration result shape edge face offset throat",
__FILE__,chamf_throat_with_penetration,g);
}

File diff suppressed because it is too large Load Diff

View File

@@ -32,32 +32,19 @@ public:
//! Returns the maximum number of sub-elements in the leaf.
Standard_Integer LeafNodeSize() const { return myLeafNodeSize; }
//! Returns parallel flag.
inline Standard_Boolean IsParallel() const
{
return myIsParallel;
}
//! Set parallel flag contolling possibility of parallel execution.
inline void SetParallel(const Standard_Boolean isParallel)
{
myIsParallel = isParallel;
}
protected:
//! Creates new abstract BVH builder.
BVH_BuilderTransient (const Standard_Integer theLeafNodeSize,
const Standard_Integer theMaxTreeDepth)
: myMaxTreeDepth (theMaxTreeDepth),
myLeafNodeSize (theLeafNodeSize),
myIsParallel (Standard_False) {}
myLeafNodeSize (theLeafNodeSize) {}
protected:
Standard_Integer myMaxTreeDepth; //!< Maximum depth of constructed BVH
Standard_Integer myLeafNodeSize; //!< Maximum number of objects per leaf
Standard_Boolean myIsParallel; //!< Parallel execution flag.
};
//! Performs construction of BVH tree using bounding

View File

@@ -46,18 +46,6 @@ public:
//! Builds 3D distance field from BVH geometry.
Standard_Boolean Build (BVH_Geometry<T, N>& theGeometry);
//! Returns parallel flag.
inline Standard_Boolean IsParallel() const
{
return myIsParallel;
}
//! Set parallel flag contolling possibility of parallel execution.
inline void SetParallel(const Standard_Boolean isParallel)
{
myIsParallel = isParallel;
}
public:
//! Returns packed voxel data.
@@ -153,7 +141,6 @@ protected:
//! Enables/disables signing of distance field.
Standard_Boolean myComputeSign;
Standard_Boolean myIsParallel;
};
#include <BVH_DistanceField.lxx>

View File

@@ -14,7 +14,18 @@
// commercial license or contractual agreement.
#include <BVH_Triangulation.hxx>
#include <OSD_Parallel.hxx>
#ifdef HAVE_TBB
// On Windows, function TryEnterCriticalSection has appeared in Windows NT
// and is surrounded by #ifdef in MS VC++ 7.1 headers.
// Thus to use it we need to define appropriate macro saying that we will
// run on Windows NT 4.0 at least
#if defined(_WIN32) && !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x0501
#endif
#include <tbb/tbb.h>
#endif
// =======================================================================
// function : BVH_DistanceField
@@ -24,8 +35,7 @@ template<class T, int N>
BVH_DistanceField<T, N>::BVH_DistanceField (const Standard_Integer theMaximumSize,
const Standard_Boolean theComputeSign)
: myMaximumSize (theMaximumSize),
myComputeSign (theComputeSign),
myIsParallel (Standard_False)
myComputeSign (theComputeSign)
{
Standard_STATIC_ASSERT (N == 3 || N == 4);
@@ -397,6 +407,8 @@ namespace BVH
#undef BVH_DOT3
#ifdef HAVE_TBB
//! Tool object for parallel construction of distance field (uses Intel TBB).
template<class T, int N>
class BVH_ParallelDistanceFieldBuilder
@@ -418,12 +430,14 @@ public:
//
}
void operator() (const Standard_Integer theIndex) const
void operator() (const tbb::blocked_range<Standard_Integer>& theRange) const
{
myOutField->BuildSlices (*myGeometry, theIndex, theIndex + 1);
myOutField->BuildSlices (*myGeometry, theRange.begin(), theRange.end());
}
};
#endif
// =======================================================================
// function : BuildSlices
// purpose : Performs building of distance field for the given Z slices
@@ -496,7 +510,16 @@ Standard_Boolean BVH_DistanceField<T, N>::Build (BVH_Geometry<T, N>& theGeometry
myVoxelSize.y() = (myCornerMax.y() - myCornerMin.y()) / myDimensionY;
myVoxelSize.z() = (myCornerMax.z() - myCornerMin.z()) / myDimensionZ;
OSD_Parallel::For (0, myDimensionZ, BVH_ParallelDistanceFieldBuilder<T, N> (this, &theGeometry), !IsParallel());
#ifdef HAVE_TBB
tbb::parallel_for (tbb::blocked_range<Standard_Integer> (0, myDimensionZ),
BVH_ParallelDistanceFieldBuilder<T, N> (this, &theGeometry));
#else
BuildSlices (theGeometry, 0, myDimensionZ);
#endif
return Standard_True;
}

View File

@@ -211,88 +211,92 @@ namespace BVH
return 0;
}
#ifdef HAVE_TBB
//! TBB task for parallel bounds updating.
template<class T, int N>
struct BoundData
class UpdateBoundTask: public tbb::task
{
BVH_Set <T, N>* mySet; //!< Set of geometric objects
BVH_Set<T, N>* mySet; //!< Set of geometric objects
BVH_Tree<T, N>* myBVH; //!< BVH tree built over the set
Standard_Integer myNode; //!< BVH node to update bounding box
Standard_Integer myLevel; //!< Level of the processed BVH node
Standard_Integer* myHeight; //!< Height of the processed BVH node
};
//! Task for parallel bounds updating.
template<class T, int N>
class UpdateBoundTask
{
public:
UpdateBoundTask (const Standard_Boolean isParallel)
: myIsParallel (isParallel)
{
}
//! Creates new TBB parallel bound update task.
UpdateBoundTask (BVH_Set<T, N>* theSet,
BVH_Tree<T, N>* theBVH,
Standard_Integer theNode,
Standard_Integer theLevel,
Standard_Integer* theHeight)
: mySet (theSet), myBVH (theBVH), myNode (theNode), myLevel (theLevel), myHeight (theHeight) {}
//! Executes the task.
void operator()(const BoundData<T, N>& theData) const
tbb::task* execute()
{
if (theData.myBVH->IsOuter (theData.myNode) || theData.myLevel > 2)
if (myBVH->IsOuter (myNode) || myLevel > 2)
{
*theData.myHeight = BVH::UpdateBounds (theData.mySet, theData.myBVH, theData.myNode);
*myHeight = BVH::UpdateBounds (mySet, myBVH, myNode);
}
else
{
Standard_Integer aLftHeight = 0;
Standard_Integer aRghHeight = 0;
const Standard_Integer aLftChild = theData.myBVH->NodeInfoBuffer()[theData.myNode].y();
const Standard_Integer aRghChild = theData.myBVH->NodeInfoBuffer()[theData.myNode].z();
const Standard_Integer aLftChild = myBVH->NodeInfoBuffer()[myNode].y();
const Standard_Integer aRghChild = myBVH->NodeInfoBuffer()[myNode].z();
std::vector<BoundData<T, N> > aList;
aList.reserve (2);
if (!theData.myBVH->IsOuter (aLftChild))
Standard_Integer aCount = 1;
tbb::task_list aList;
if (!myBVH->IsOuter (aLftChild))
{
BoundData<T, N> aBoundData = {theData.mySet, theData.myBVH, aLftChild, theData.myLevel + 1, &aLftHeight};
aList.push_back (aBoundData);
++aCount;
aList.push_back (*new ( allocate_child() )
UpdateBoundTask (mySet, myBVH, aLftChild, myLevel + 1, &aLftHeight));
}
else
{
aLftHeight = BVH::UpdateBounds (theData.mySet, theData.myBVH, aLftChild);
aLftHeight = BVH::UpdateBounds (mySet, myBVH, aLftChild);
}
if (!theData.myBVH->IsOuter (aRghChild))
if (!myBVH->IsOuter (aRghChild))
{
BoundData<T, N> aBoundData = {theData.mySet, theData.myBVH, aRghChild, theData.myLevel + 1, &aRghHeight};
aList.push_back (aBoundData);
++aCount;
aList.push_back (*new( allocate_child() )
UpdateBoundTask (mySet, myBVH, aRghChild, myLevel + 1, &aRghHeight));
}
else
{
aRghHeight = BVH::UpdateBounds (theData.mySet, theData.myBVH, aRghChild);
aRghHeight = BVH::UpdateBounds (mySet, myBVH, aRghChild);
}
if (!aList.empty())
if (aCount > 1)
{
OSD_Parallel::ForEach (aList.begin (), aList.end (), UpdateBoundTask<T, N> (myIsParallel), !myIsParallel);
set_ref_count (aCount);
spawn_and_wait_for_all (aList);
}
typename BVH_Box<T, N>::BVH_VecNt aLftMinPoint = theData.myBVH->MinPointBuffer()[aLftChild];
typename BVH_Box<T, N>::BVH_VecNt aLftMaxPoint = theData.myBVH->MaxPointBuffer()[aLftChild];
typename BVH_Box<T, N>::BVH_VecNt aRghMinPoint = theData.myBVH->MinPointBuffer()[aRghChild];
typename BVH_Box<T, N>::BVH_VecNt aRghMaxPoint = theData.myBVH->MaxPointBuffer()[aRghChild];
typename BVH_Box<T, N>::BVH_VecNt aLftMinPoint = myBVH->MinPointBuffer()[aLftChild];
typename BVH_Box<T, N>::BVH_VecNt aLftMaxPoint = myBVH->MaxPointBuffer()[aLftChild];
typename BVH_Box<T, N>::BVH_VecNt aRghMinPoint = myBVH->MinPointBuffer()[aRghChild];
typename BVH_Box<T, N>::BVH_VecNt aRghMaxPoint = myBVH->MaxPointBuffer()[aRghChild];
BVH::BoxMinMax<T, N>::CwiseMin (aLftMinPoint, aRghMinPoint);
BVH::BoxMinMax<T, N>::CwiseMax (aLftMaxPoint, aRghMaxPoint);
theData.myBVH->MinPointBuffer()[theData.myNode] = aLftMinPoint;
theData.myBVH->MaxPointBuffer()[theData.myNode] = aLftMaxPoint;
myBVH->MinPointBuffer()[myNode] = aLftMinPoint;
myBVH->MaxPointBuffer()[myNode] = aLftMaxPoint;
*theData.myHeight = Max (aLftHeight, aRghHeight) + 1;
*myHeight = Max (aLftHeight, aRghHeight) + 1;
}
return NULL;
}
private:
Standard_Boolean myIsParallel;
};
#endif
}
// =======================================================================
@@ -315,7 +319,6 @@ void BVH_LinearBuilder<T, N>::Build (BVH_Set<T, N>* theSet,
// Step 0 -- Initialize parameter of virtual grid
BVH_RadixSorter<T, N> aRadixSorter (theBox);
aRadixSorter.SetParallel (this->IsParallel());
// Step 1 - Perform radix sorting of primitive set
aRadixSorter.Perform (theSet);
@@ -328,9 +331,21 @@ void BVH_LinearBuilder<T, N>::Build (BVH_Set<T, N>* theSet,
theBVH->MaxPointBuffer().resize (theBVH->NodeInfoBuffer().size());
Standard_Integer aHeight = 0;
BVH::BoundData<T, N> aBoundData = { theSet, theBVH, 0, 0, &aHeight };
BVH::UpdateBoundTask<T, N> aBoundTask (this->IsParallel());
aBoundTask (aBoundData);
#ifdef HAVE_TBB
// Note: Although TBB tasks are allocated using placement
// new, we do not need to delete them explicitly
BVH::UpdateBoundTask<T, N>& aRootTask = *new ( tbb::task::allocate_root() )
BVH::UpdateBoundTask<T, N> (theSet, theBVH, 0, 0, &aHeight);
tbb::task::spawn_root_and_wait (aRootTask);
#else
aHeight = BVH::UpdateBounds (theSet, theBVH, 0);
#endif
BVH_Builder<T, N>::updateDepth (theBVH, aHeight);
}

View File

@@ -20,10 +20,21 @@
#include <BVH_Builder.hxx>
#include <NCollection_Array1.hxx>
#include <NCollection_Shared.hxx>
#include <OSD_Parallel.hxx>
#include <algorithm>
#ifdef HAVE_TBB
// On Windows, function TryEnterCriticalSection has appeared in Windows NT
// and is surrounded by #ifdef in MS VC++ 7.1 headers.
// Thus to use it we need to define appropriate macro saying that we will
// run on Windows NT 4.0 at least
#if defined(_WIN32) && !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x0501
#endif
#include <tbb/parallel_invoke.h>
#endif
//! Pair of Morton code and primitive ID.
typedef std::pair<Standard_Integer, Standard_Integer> BVH_EncodedLink;
@@ -102,43 +113,29 @@ namespace BVH
private:
//! Structure defining sorting range.
struct SortRange
//! TBB functor class to run sorting.
struct Functor
{
LinkIterator myStart; //!< Start element of exclusive sorting range
LinkIterator myFinal; //!< Final element of exclusive sorting range
Standard_Integer myDigit; //!< Bit number used for partition operation
};
//! Functor class to run sorting in parallel.
class Functor
{
public:
Functor(const SortRange (&aSplits)[2], const Standard_Boolean isParallel)
: mySplits (aSplits),
myIsParallel (isParallel)
{
}
//! Creates new sorting functor.
Functor (LinkIterator theStart, LinkIterator theFinal, Standard_Integer theDigit)
: myStart (theStart), myFinal (theFinal), myDigit (theDigit) {}
//! Runs sorting function for the given range.
void operator()(const Standard_Integer theIndex) const
void operator() () const
{
RadixSorter::Sort (mySplits[theIndex].myStart, mySplits[theIndex].myFinal,
mySplits[theIndex].myDigit, myIsParallel);
RadixSorter::Sort (myStart, myFinal, myDigit);
}
private:
void operator=(const Functor&);
private:
const SortRange (&mySplits)[2];
Standard_Boolean myIsParallel;
};
public:
static void Sort (LinkIterator theStart, LinkIterator theFinal, Standard_Integer theDigit, const Standard_Boolean isParallel)
static void Sort (LinkIterator theStart, LinkIterator theFinal, Standard_Integer theDigit)
{
#ifdef HAVE_TBB
if (theDigit < 24)
{
BVH::RadixSorter::perform (theStart, theFinal, theDigit);
@@ -146,13 +143,12 @@ namespace BVH
else
{
LinkIterator anOffset = std::partition (theStart, theFinal, BitPredicate (theDigit));
SortRange aSplits[2] = {
{theStart, anOffset, theDigit - 1},
{anOffset, theFinal, theDigit - 1}
};
OSD_Parallel::For (0, 2, Functor (aSplits, isParallel), !isParallel);
tbb::parallel_invoke (Functor (theStart, anOffset, theDigit - 1),
Functor (anOffset, theFinal, theDigit - 1));
}
#else
BVH::RadixSorter::perform (theStart, theFinal, theDigit);
#endif
}
protected:
@@ -217,7 +213,7 @@ void BVH_RadixSorter<T, N>::Perform (BVH_Set<T, N>* theSet, const Standard_Integ
}
// Step 2 -- Sort primitives by their Morton codes using radix sort
BVH::RadixSorter::Sort (myEncodedLinks->begin(), myEncodedLinks->end(), 29, this->IsParallel());
BVH::RadixSorter::Sort (myEncodedLinks->begin(), myEncodedLinks->end(), 29);
NCollection_Array1<Standard_Integer> aLinkMap (theStart, theFinal);
for (Standard_Integer aLinkIdx = theStart; aLinkIdx <= theFinal; ++aLinkIdx)

View File

@@ -24,11 +24,6 @@ class BVH_Sorter
{
public:
//! Performs default initialization.
BVH_Sorter()
: myIsParallel (Standard_False)
{ }
//! Releases resources of BVH sorter.
virtual ~BVH_Sorter() { }
@@ -38,21 +33,6 @@ public:
//! Sorts the given (inclusive) range in the set.
virtual void Perform (BVH_Set<T, N>* theSet, const Standard_Integer theStart, const Standard_Integer theFinal) = 0;
//! Returns parallel flag.
inline Standard_Boolean IsParallel() const
{
return myIsParallel;
}
//! Set parallel flag contolling possibility of parallel execution.
inline void SetParallel(const Standard_Boolean isParallel)
{
myIsParallel = isParallel;
}
private:
Standard_Boolean myIsParallel;
};
#endif // _BVH_Sorter_Header

View File

@@ -74,9 +74,7 @@ public:
//! <D> for the variable <X>.
//! Returns True if the computation was done successfully,
//! False otherwise.
Standard_EXPORT virtual Standard_Boolean Values (const math_Vector& X,
math_Vector& F,
math_Matrix& D) = 0;
Standard_EXPORT virtual Standard_Boolean Values (const math_Vector& X, math_Vector& F, math_Matrix& D) = 0;
//! Sets the value of the parameter along the guide line.
//! This determines the plane in which the solution has
@@ -92,8 +90,7 @@ public:
//! Returns in the vector Tolerance the parametric tolerance
//! for each of the 4 variables;
//! Tol is the tolerance used in 3d space.
Standard_EXPORT virtual void GetTolerance (math_Vector& Tolerance,
const Standard_Real Tol) const = 0;
Standard_EXPORT virtual void GetTolerance (math_Vector& Tolerance, const Standard_Real Tol) const = 0;
//! Returns in the vector InfBound the lowest values allowed
//! for each of the 4 variables.
@@ -105,8 +102,7 @@ public:
//! Tol is the tolerance used in 3d space.
//! The computation is made at the current value of
//! the parameter on the guide line.
Standard_EXPORT virtual Standard_Boolean IsSolution (const math_Vector& Sol,
const Standard_Real Tol) = 0;
Standard_EXPORT virtual Standard_Boolean IsSolution (const math_Vector& Sol, const Standard_Real Tol) = 0;
//! Returns the minimal Distance beetween two
//! extremitys of calculed sections.
@@ -139,24 +135,16 @@ public:
//! for the parameters. i.e. T.Length() > NbIntervals()
//! raises
//! OutOfRange from Standard
Standard_EXPORT virtual void Intervals (TColStd_Array1OfReal& T,
const GeomAbs_Shape S) const = 0;
Standard_EXPORT virtual void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const = 0;
Standard_EXPORT virtual void GetShape (Standard_Integer& NbPoles,
Standard_Integer& NbKnots,
Standard_Integer& Degree,
Standard_Integer& NbPoles2d) = 0;
Standard_EXPORT virtual void GetShape (Standard_Integer& NbPoles, Standard_Integer& NbKnots, Standard_Integer& Degree, Standard_Integer& NbPoles2d) = 0;
//! Returns the tolerance to reach in approximation
//! to respecte
//! BoundTol error at the Boundary
//! AngleTol tangent error at the Boundary
//! SurfTol error inside the surface.
Standard_EXPORT virtual void GetTolerance (const Standard_Real BoundTol,
const Standard_Real SurfTol,
const Standard_Real AngleTol,
math_Vector& Tol3d,
math_Vector& Tol1D) const = 0;
Standard_EXPORT virtual void GetTolerance (const Standard_Real BoundTol, const Standard_Real SurfTol, const Standard_Real AngleTol, math_Vector& Tol3d, math_Vector& Tol1D) const = 0;
Standard_EXPORT virtual void Knots (TColStd_Array1OfReal& TKnots) = 0;
@@ -165,37 +153,16 @@ public:
//! Used for the first and last section
//! The method returns Standard_True if the derivatives
//! are computed, otherwise it returns Standard_False.
Standard_EXPORT virtual Standard_Boolean Section (const Blend_Point& P,
TColgp_Array1OfPnt& Poles,
TColgp_Array1OfVec& DPoles,
TColgp_Array1OfPnt2d& Poles2d,
TColgp_Array1OfVec2d& DPoles2d,
TColStd_Array1OfReal& Weigths,
TColStd_Array1OfReal& DWeigths) = 0;
Standard_EXPORT virtual Standard_Boolean Section (const Blend_Point& P, TColgp_Array1OfPnt& Poles, TColgp_Array1OfVec& DPoles, TColgp_Array1OfPnt2d& Poles2d, TColgp_Array1OfVec2d& DPoles2d, TColStd_Array1OfReal& Weigths, TColStd_Array1OfReal& DWeigths) = 0;
Standard_EXPORT virtual void Section (const Blend_Point& P,
TColgp_Array1OfPnt& Poles,
TColgp_Array1OfPnt2d& Poles2d,
TColStd_Array1OfReal& Weigths) = 0;
Standard_EXPORT virtual void Section (const Blend_Point& P, TColgp_Array1OfPnt& Poles, TColgp_Array1OfPnt2d& Poles2d, TColStd_Array1OfReal& Weigths) = 0;
//! Used for the first and last section
//! The method returns Standard_True if the derivatives
//! are computed, otherwise it returns Standard_False.
Standard_EXPORT virtual Standard_Boolean Section (const Blend_Point& P,
TColgp_Array1OfPnt& Poles,
TColgp_Array1OfVec& DPoles,
TColgp_Array1OfVec& D2Poles,
TColgp_Array1OfPnt2d& Poles2d,
TColgp_Array1OfVec2d& DPoles2d,
TColgp_Array1OfVec2d& D2Poles2d,
TColStd_Array1OfReal& Weigths,
TColStd_Array1OfReal& DWeigths,
TColStd_Array1OfReal& D2Weigths) = 0;
Standard_EXPORT virtual Standard_Boolean Section (const Blend_Point& P, TColgp_Array1OfPnt& Poles, TColgp_Array1OfVec& DPoles, TColgp_Array1OfVec& D2Poles, TColgp_Array1OfPnt2d& Poles2d, TColgp_Array1OfVec2d& DPoles2d, TColgp_Array1OfVec2d& D2Poles2d, TColStd_Array1OfReal& Weigths, TColStd_Array1OfReal& DWeigths, TColStd_Array1OfReal& D2Weigths) = 0;
Standard_EXPORT virtual void Resolution (const Standard_Integer IC2d,
const Standard_Real Tol,
Standard_Real& TolU,
Standard_Real& TolV) const = 0;
Standard_EXPORT virtual void Resolution (const Standard_Integer IC2d, const Standard_Real Tol, Standard_Real& TolU, Standard_Real& TolV) const = 0;
//! Returns the parameter of the point P. Used to
//! impose the parameters in the approximation.

View File

@@ -56,6 +56,55 @@ public:
//! Returns 4.
Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
//! returns the number of equations of the function.
Standard_EXPORT virtual Standard_Integer NbEquations() const Standard_OVERRIDE = 0;
//! computes the values <F> of the Functions for the
//! variable <X>.
//! Returns True if the computation was done successfully,
//! False otherwise.
Standard_EXPORT virtual Standard_Boolean Value (const math_Vector& X, math_Vector& F) Standard_OVERRIDE = 0;
//! returns the values <D> of the derivatives for the
//! variable <X>.
//! Returns True if the computation was done successfully,
//! False otherwise.
Standard_EXPORT virtual Standard_Boolean Derivatives (const math_Vector& X, math_Matrix& D) Standard_OVERRIDE = 0;
//! returns the values <F> of the functions and the derivatives
//! <D> for the variable <X>.
//! Returns True if the computation was done successfully,
//! False otherwise.
Standard_EXPORT virtual Standard_Boolean Values (const math_Vector& X, math_Vector& F, math_Matrix& D) Standard_OVERRIDE = 0;
//! Sets the value of the parameter along the guide line.
//! This determines the plane in which the solution has
//! to be found.
Standard_EXPORT virtual void Set (const Standard_Real Param) Standard_OVERRIDE = 0;
//! Sets the bounds of the parametric interval on
//! the guide line.
//! This determines the derivatives in these values if the
//! function is not Cn.
Standard_EXPORT virtual void Set (const Standard_Real First, const Standard_Real Last) Standard_OVERRIDE = 0;
//! Returns in the vector Tolerance the parametric tolerance
//! for each of the 4 variables;
//! Tol is the tolerance used in 3d space.
Standard_EXPORT virtual void GetTolerance (math_Vector& Tolerance, const Standard_Real Tol) const Standard_OVERRIDE = 0;
//! Returns in the vector InfBound the lowest values allowed
//! for each of the 4 variables.
//! Returns in the vector SupBound the greatest values allowed
//! for each of the 4 variables.
Standard_EXPORT virtual void GetBounds (math_Vector& InfBound, math_Vector& SupBound) const Standard_OVERRIDE = 0;
//! Returns Standard_True if Sol is a zero of the function.
//! Tol is the tolerance used in 3d space.
//! The computation is made at the current value of
//! the parameter on the guide line.
Standard_EXPORT virtual Standard_Boolean IsSolution (const math_Vector& Sol, const Standard_Real Tol) Standard_OVERRIDE = 0;
//! Returns the point on the first support.
Standard_EXPORT const gp_Pnt& Pnt1() const Standard_OVERRIDE;
@@ -94,37 +143,36 @@ public:
//! at the beginning and the end of the section, and
//! returns the normal (of the surfaces) at
//! these points.
Standard_EXPORT virtual void Tangent (const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2,
gp_Vec& TgFirst,
gp_Vec& TgLast,
gp_Vec& NormFirst,
gp_Vec& NormLast) const = 0;
Standard_EXPORT virtual void Tangent (const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, gp_Vec& TgFirst, gp_Vec& TgLast, gp_Vec& NormFirst, gp_Vec& NormLast) const = 0;
Standard_EXPORT virtual Standard_Boolean TwistOnS1() const;
Standard_EXPORT virtual Standard_Boolean TwistOnS2() const;
Standard_EXPORT virtual void Section (const Blend_Point& P,
TColgp_Array1OfPnt& Poles,
TColgp_Array1OfPnt2d& Poles2d,
TColStd_Array1OfReal& Weigths) Standard_OVERRIDE = 0;
Standard_EXPORT virtual void GetShape (Standard_Integer& NbPoles, Standard_Integer& NbKnots, Standard_Integer& Degree, Standard_Integer& NbPoles2d) Standard_OVERRIDE = 0;
//! Returns the tolerance to reach in approximation
//! to respecte
//! BoundTol error at the Boundary
//! AngleTol tangent error at the Boundary
//! SurfTol error inside the surface.
Standard_EXPORT virtual void GetTolerance (const Standard_Real BoundTol, const Standard_Real SurfTol, const Standard_Real AngleTol, math_Vector& Tol3d, math_Vector& Tol1D) const Standard_OVERRIDE = 0;
Standard_EXPORT virtual void Knots (TColStd_Array1OfReal& TKnots) Standard_OVERRIDE = 0;
Standard_EXPORT virtual void Mults (TColStd_Array1OfInteger& TMults) Standard_OVERRIDE = 0;
//! Used for the first and last section
//! The method returns Standard_True if the derivatives
//! are computed, otherwise it returns Standard_False.
Standard_EXPORT virtual Standard_Boolean Section (const Blend_Point& P, TColgp_Array1OfPnt& Poles, TColgp_Array1OfVec& DPoles, TColgp_Array1OfPnt2d& Poles2d, TColgp_Array1OfVec2d& DPoles2d, TColStd_Array1OfReal& Weigths, TColStd_Array1OfReal& DWeigths) Standard_OVERRIDE = 0;
Standard_EXPORT virtual void Section (const Blend_Point& P, TColgp_Array1OfPnt& Poles, TColgp_Array1OfPnt2d& Poles2d, TColStd_Array1OfReal& Weigths) Standard_OVERRIDE = 0;
//! Used for the first and last section
//! The method returns Standard_True if the derivatives
//! are computed, otherwise it returns Standard_False
Standard_EXPORT virtual Standard_Boolean Section (const Blend_Point& P,
TColgp_Array1OfPnt& Poles,
TColgp_Array1OfVec& DPoles,
TColgp_Array1OfVec& D2Poles,
TColgp_Array1OfPnt2d& Poles2d,
TColgp_Array1OfVec2d& DPoles2d,
TColgp_Array1OfVec2d& D2Poles2d,
TColStd_Array1OfReal& Weigths,
TColStd_Array1OfReal& DWeigths,
TColStd_Array1OfReal& D2Weigths) Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Section (const Blend_Point& P, TColgp_Array1OfPnt& Poles, TColgp_Array1OfVec& DPoles, TColgp_Array1OfVec& D2Poles, TColgp_Array1OfPnt2d& Poles2d, TColgp_Array1OfVec2d& DPoles2d, TColgp_Array1OfVec2d& D2Poles2d, TColStd_Array1OfReal& Weigths, TColStd_Array1OfReal& DWeigths, TColStd_Array1OfReal& D2Weigths) Standard_OVERRIDE;

View File

@@ -16,11 +16,6 @@
#include <Extrema_ExtPS.hxx>
#include <Extrema_ExtPC.hxx>
#ifdef DRAW
#include <DrawTrSurf.hxx>
#endif
static const Standard_Real CosRef3D = 0.88;
static void RecadreIfPeriodic(Standard_Real& NewU,
@@ -488,16 +483,6 @@ void Blend_Walking::InternalPerform(Blend_Function& Func,
else {
line->Prepend(previousP);
}
#ifdef DRAW
Standard_Integer nbpts = line->NbPoints();
char name [100];
sprintf(name, "pg%d", nbpts);
DrawTrSurf::Set(name, PtOnGuide);
sprintf(name, "p1_%d", nbpts);
DrawTrSurf::Set(name, previousP.PointOnS1());
sprintf(name, "p2_%d", nbpts);
DrawTrSurf::Set(name, previousP.PointOnS2());
#endif
parprec = param;
@@ -566,16 +551,6 @@ void Blend_Walking::InternalPerform(Blend_Function& Func,
else {
line->Prepend(previousP);
}
#ifdef DRAW
Standard_Integer nbpts = line->NbPoints();
char name [100];
sprintf(name, "pg%d", nbpts);
DrawTrSurf::Set(name, PtOnGuide);
sprintf(name, "p1_%d", nbpts);
DrawTrSurf::Set(name, previousP.PointOnS1());
sprintf(name, "p2_%d", nbpts);
DrawTrSurf::Set(name, previousP.PointOnS2());
#endif
parprec = param;
@@ -613,17 +588,6 @@ void Blend_Walking::InternalPerform(Blend_Function& Func,
else {
line->Prepend(previousP);
}
#ifdef DRAW
Standard_Integer nbpts = line->NbPoints();
char name [100];
sprintf(name, "pg%d", nbpts);
DrawTrSurf::Set(name, PtOnGuide);
sprintf(name, "p1_%d", nbpts);
DrawTrSurf::Set(name, previousP.PointOnS1());
sprintf(name, "p2_%d", nbpts);
DrawTrSurf::Set(name, previousP.PointOnS2());
#endif
MakeExtremity(Ext1,Standard_True,Index1,
solrst1(1),Isvtx1,Vtx1);
// On blinde le cas singulier ou un des recadrage a planter
@@ -649,17 +613,6 @@ void Blend_Walking::InternalPerform(Blend_Function& Func,
else {
line->Prepend(previousP);
}
#ifdef DRAW
Standard_Integer nbpts = line->NbPoints();
char name [100];
sprintf(name, "pg%d", nbpts);
DrawTrSurf::Set(name, PtOnGuide);
sprintf(name, "p1_%d", nbpts);
DrawTrSurf::Set(name, previousP.PointOnS1());
sprintf(name, "p2_%d", nbpts);
DrawTrSurf::Set(name, previousP.PointOnS2());
#endif
// On blinde le cas singulier ou un des recadrage a plante
if (previousP.PointOnS1().IsEqual(previousP.PointOnS2(), 2*tolesp)) {
Ext1.SetValue(previousP.PointOnS2(),
@@ -686,16 +639,6 @@ void Blend_Walking::InternalPerform(Blend_Function& Func,
else {
line->Prepend(previousP);
}
#ifdef DRAW
Standard_Integer nbpts = line->NbPoints();
char name [100];
sprintf(name, "pg%d", nbpts);
DrawTrSurf::Set(name, PtOnGuide);
sprintf(name, "p1_%d", nbpts);
DrawTrSurf::Set(name, previousP.PointOnS1());
sprintf(name, "p2_%d", nbpts);
DrawTrSurf::Set(name, previousP.PointOnS2());
#endif
if ( (Isvtx1 != Isvtx2) &&
(previousP.PointOnS1().IsEqual(previousP.PointOnS2(), 2*tolesp)) ) {

View File

@@ -27,12 +27,10 @@
//function : BlendFunc_ChamfInv
//purpose :
//=======================================================================
BlendFunc_ChamfInv::BlendFunc_ChamfInv(const Handle(Adaptor3d_HSurface)& S1,
const Handle(Adaptor3d_HSurface)& S2,
const Handle(Adaptor3d_HCurve)& C)
: BlendFunc_GenChamfInv(S1,S2,C),
corde1(surf1,curv),corde2(surf2,curv)
const Handle(Adaptor3d_HCurve)& C) :
surf1(S1),surf2(S2),curv(C),corde1(surf1,curv),corde2(surf2,curv)
{
}
@@ -85,6 +83,97 @@ void BlendFunc_ChamfInv::Set(const Standard_Real Dist1, const Standard_Real Dist
corde2.SetDist(dis2);
}
//=======================================================================
//function : NbEquations
//purpose :
//=======================================================================
Standard_Integer BlendFunc_ChamfInv::NbEquations () const
{
return 4;
}
//=======================================================================
//function : GetTolerance
//purpose :
//=======================================================================
void BlendFunc_ChamfInv::Set(const Standard_Boolean OnFirst, const Handle(Adaptor2d_HCurve2d)& C)
{
first = OnFirst;
csurf = C;
}
//=======================================================================
//function : GetTolerance
//purpose :
//=======================================================================
void BlendFunc_ChamfInv::GetTolerance(math_Vector& Tolerance, const Standard_Real Tol) const
{
Tolerance(1) = csurf->Resolution(Tol);
Tolerance(2) = curv->Resolution(Tol);
if (first) {
Tolerance(3) = surf2->UResolution(Tol);
Tolerance(4) = surf2->VResolution(Tol);
}
else {
Tolerance(3) = surf1->UResolution(Tol);
Tolerance(4) = surf1->VResolution(Tol);
}
}
//=======================================================================
//function : GetBounds
//purpose :
//=======================================================================
void BlendFunc_ChamfInv::GetBounds(math_Vector& InfBound, math_Vector& SupBound) const
{
InfBound(1) = csurf->FirstParameter();
InfBound(2) = curv->FirstParameter();
SupBound(1) = csurf->LastParameter();
SupBound(2) = curv->LastParameter();
if (first) {
InfBound(3) = surf2->FirstUParameter();
InfBound(4) = surf2->FirstVParameter();
SupBound(3) = surf2->LastUParameter();
SupBound(4) = surf2->LastVParameter();
if(!Precision::IsInfinite(InfBound(3)) &&
!Precision::IsInfinite(SupBound(3))) {
const Standard_Real range = (SupBound(3) - InfBound(3));
InfBound(3) -= range;
SupBound(3) += range;
}
if(!Precision::IsInfinite(InfBound(4)) &&
!Precision::IsInfinite(SupBound(4))) {
const Standard_Real range = (SupBound(4) - InfBound(4));
InfBound(4) -= range;
SupBound(4) += range;
}
}
else {
InfBound(3) = surf1->FirstUParameter();
InfBound(4) = surf1->FirstVParameter();
SupBound(3) = surf1->LastUParameter();
SupBound(4) = surf1->LastVParameter();
if(!Precision::IsInfinite(InfBound(3)) &&
!Precision::IsInfinite(SupBound(3))) {
const Standard_Real range = (SupBound(3) - InfBound(3));
InfBound(3) -= range;
SupBound(3) += range;
}
if(!Precision::IsInfinite(InfBound(4)) &&
!Precision::IsInfinite(SupBound(4))) {
const Standard_Real range = (SupBound(4) - InfBound(4));
InfBound(4) -= range;
SupBound(4) += range;
}
}
}
//=======================================================================
//function : IsSolution
//purpose :
@@ -118,6 +207,7 @@ Standard_Boolean BlendFunc_ChamfInv::IsSolution(const math_Vector& Sol, const St
}
//=======================================================================
//function : Value
//purpose :
@@ -234,3 +324,15 @@ Standard_Boolean BlendFunc_ChamfInv::Derivatives(const math_Vector& X, math_Matr
return Standard_True;
}
//=======================================================================
//function : Values
//purpose :
//=======================================================================
Standard_Boolean BlendFunc_ChamfInv::Values(const math_Vector& X, math_Vector& F, math_Matrix& D)
{
Value(X,F);
Derivatives(X,D);
return Standard_True;
}

Some files were not shown because too many files have changed in this diff Show More